Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/lix-integration' into paraglide-…
Browse files Browse the repository at this point in the history
…prerelease
  • Loading branch information
LorisSigrist committed Aug 28, 2024
2 parents 0a859f0 + 20fae1a commit f551ff4
Show file tree
Hide file tree
Showing 39 changed files with 606 additions and 419 deletions.
3 changes: 0 additions & 3 deletions inlang/source-code/bundle-component/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,6 @@
"author": "",
"license": "ISC",
"devDependencies": {
"@inlang/marketplace-manifest": "workspace:^",
"@inlang/marketplace-registry": "workspace:^",
"@inlang/message-lint-rule": "workspace:^",
"@nx/storybook": "^18.0.4",
"@storybook/addon-essentials": "^7.6.16",
"@storybook/addon-links": "^7.6.16",
Expand Down
5 changes: 3 additions & 2 deletions inlang/source-code/fink2/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"type": "module",
"scripts": {
"dev": "vite --host",
"build": "tsc -b && vite build",
"build": "vite build",
"lint": "eslint . --ext ts,tsx --report-unused-disable-directives --max-warnings 0",
"preview": "vite preview",
"generate": "node ./scripts/generateDemoData.js"
Expand Down Expand Up @@ -37,8 +37,9 @@
"eslint-plugin-react-hooks": "^4.6.2",
"eslint-plugin-react-refresh": "^0.4.7",
"eslint-plugin-unicorn": "^55.0.0",
"prettier": "^3.3.3",
"tailwindcss": "^4.0.0-alpha.17",
"typescript": "^5.2.2",
"vite": "^5.3.4"
}
}
}
6 changes: 3 additions & 3 deletions inlang/source-code/fink2/src/components/VariantHistory.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,9 @@ const VariantHistory = (props: { variantId: string }) => {
}, [latestCommit]);
return (
<div className="flex items-center text-zinc-400 text-sm!">
{latestCommit?.user_id && (
{latestCommit?.author && (
<p>
by {latestCommit?.user_id} | {timeAgo(latestCommit?.created)}
by {latestCommit?.author} | {timeAgo(latestCommit?.created)}
</p>
)}
</div>
Expand All @@ -44,7 +44,7 @@ const queryLatestCommit = async (project: InlangProject, variantId: string) => {
.where("change.commit_id", "!=", "null")
.where((eb) => eb.ref("value", "->>").key("id"), "=", variantId)
.innerJoin("commit", "commit.id", "change.commit_id")
.orderBy("commit.user_id desc")
.orderBy("commit.author desc")
.orderBy("commit.created desc")
.executeTakeFirst();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ const VariantHistoryList = (props: {
.selectFrom("conflict")
.select("conflict.conflicting_change_id")
)
.orderBy("commit.user_id desc")
.orderBy("commit.author desc")
.orderBy("commit.created desc")
.execute();

Expand Down Expand Up @@ -71,7 +71,7 @@ const VariantHistoryList = (props: {
<div className="flex items-center justify-between">
<h3 className="text-[16px] text-zinc-500">
<span className="font-medium text-zinc-950">
{change.user_id}
{change.author}
</span>{" "}
changed variant
</h3>
Expand Down
9 changes: 8 additions & 1 deletion inlang/source-code/fink2/src/layout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -33,14 +33,21 @@ export default function Layout(props: { children: React.ReactNode }) {
});

const [authorName] = useAtom(authorNameAtom);
const [project] = useAtom(projectAtom);
const [selectedProjectPath] = useAtom(selectedProjectPathAtom);
const [showAuthorDialog, setShowAuthorDialog] = useState(false);

useEffect(() => {
if (selectedProjectPath && !authorName) {
setShowAuthorDialog(true);
}
}, [authorName, project?.lix.currentAuthor, selectedProjectPath]);

useEffect(() => {
if (authorName && project?.lix.currentAuthor.get() !== authorName) {
project?.lix.currentAuthor.set(authorName);
}
}, [authorName, selectedProjectPath]);
}, [authorName, project?.lix.currentAuthor])

return (
<div className="w-full min-h-screen bg-zinc-50">
Expand Down
12 changes: 3 additions & 9 deletions inlang/source-code/fink2/src/routes/changes/Page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -37,17 +37,11 @@ export default function App() {
const [commitDescription, setCommitDescription] = useState<string>("");
const [showDialog, setShowDialog] = useState(false);
const navigate = useNavigate();
const [author] = useAtom(authorNameAtom);

const handleCommit = async () => {
if (author) {
await project?.lix.commit({
userId: author,
description: commitDescription,
});
} else {
console.error("Author not set");
}
await project?.lix.commit({
description: commitDescription,
});
};

useEffect(() => {
Expand Down
2 changes: 1 addition & 1 deletion inlang/source-code/fink2/src/routes/history/Page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ export default function App() {
<div className="flex-1 flex gap-2 items-center justify-between pr-4 py-3 rounded h-[46px]">
<div className="flex gap-2 items-center">
<p className="text-zinc-950 text-sm! font-semibold">
By {commit.user_id}
By {commit.author}
</p>
<p className="text-sm! text-zinc-600">
{commit.description}
Expand Down
2 changes: 1 addition & 1 deletion inlang/source-code/fink2/src/state.ts
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ export const committedChangesAtom = atom(async (get) => {
.selectFrom("commit")
.select([
"commit.id",
"commit.user_id",
"commit.author",
"commit.description",
"commit.created",
])
Expand Down
12 changes: 5 additions & 7 deletions inlang/source-code/marketplace-registry/buildRegistry.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
import { privateEnv } from "@inlang/env-variables"
import fs from "node:fs/promises"
import { MarketplaceManifest } from "@inlang/marketplace-manifest"
import { Value } from "@sinclair/typebox/value"
import algoliasearch from "algoliasearch"
import fetch from "node-fetch"

// eslint-disable-next-line no-undef
const envVariables = process.env

const repositoryRoot = import.meta.url.slice(0, import.meta.url.lastIndexOf("inlang/source-code"))
const manifestLinks = JSON.parse(await fs.readFile("./registry.json", "utf-8"))

Expand Down Expand Up @@ -72,12 +74,8 @@ await fs.writeFile(
)}`
)

if (!privateEnv.ALGOLIA_ADMIN || !privateEnv.ALGOLIA_APPLICATION) {
throw new Error("Algolia API keys are not set")
}

if (privateEnv.DOPPLER_ENVIRONMENT === "production") {
const client = algoliasearch(privateEnv.ALGOLIA_APPLICATION, privateEnv.ALGOLIA_ADMIN)
if (envVariables.DOPPLER_ENVIRONMENT === "production") {
const client = algoliasearch(envVariables.ALGOLIA_APPLICATION, envVariables.ALGOLIA_ADMIN)
const index = client.initIndex("registry")

const objects = await Promise.all(
Expand Down
1 change: 0 additions & 1 deletion inlang/source-code/marketplace-registry/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@
},
"dependencies": {
"@inlang/marketplace-manifest": "workspace:*",
"@inlang/env-variables": "workspace:*",
"@sinclair/typebox": "^0.31.8",
"algoliasearch": "4.20.0",
"node-fetch": "3.3.2"
Expand Down
11 changes: 9 additions & 2 deletions inlang/source-code/sdk2/src/database/serializeJsonPlugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -82,8 +82,15 @@ class ParseJsonTransformer extends OperationNodeTransformer {
}
}

function serializeJson(value: any): string {
if (typeof value === "object" || Array.isArray(value)) {
function serializeJson(value: any): any {
if (
// binary data
value instanceof ArrayBuffer ||
// uint8array, etc
ArrayBuffer.isView(value)
) {
return value;
} else if (typeof value === "object" || Array.isArray(value)) {
return JSON.stringify(value);
}
return value;
Expand Down
14 changes: 5 additions & 9 deletions inlang/source-code/sdk2/src/lix-plugin/applyChanges.test.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { test, expect } from "vitest";
import { loadProjectInMemory } from "../project/loadProjectInMemory.js";
import { newProject } from "../project/newProject.js";
import type { Change } from "@lix-js/sdk";
import type { Change, NewChange } from "@lix-js/sdk";
import type { Bundle } from "../schema/schemaV2.js";
import { applyChanges } from "./applyChanges.js";
import { loadDatabaseInMemory } from "sqlite-wasm-kysely";
Expand All @@ -12,7 +12,7 @@ test("it should be able to delete", async () => {
blob: await newProject(),
});

const changes: Change[] = [
const changes: NewChange[] = [
{
id: "1",
parent_id: undefined,
Expand All @@ -21,7 +21,6 @@ test("it should be able to delete", async () => {
plugin_key: "mock",
type: "bundle",
meta: { id: "mock" },
// @ts-expect-error - type error somewhere
value: {
id: "mock",
alias: {
Expand All @@ -39,7 +38,6 @@ test("it should be able to delete", async () => {
meta: {
id: "mock",
},
// @ts-expect-error - type error somewhere
value: {
id: "mock",
alias: {
Expand Down Expand Up @@ -80,7 +78,7 @@ test("it should be able to delete", async () => {
const dbFileAfter = await applyChanges({
lix: project.lix,
file: dbFile,
changes,
changes: changes as Change[],
});

const db = initDb({
Expand All @@ -97,7 +95,7 @@ test("it should be able to upsert (insert & update)", async () => {
blob: await newProject(),
});

const changes: Change[] = [
const changes: NewChange[] = [
{
id: "1",
parent_id: undefined,
Expand All @@ -106,7 +104,6 @@ test("it should be able to upsert (insert & update)", async () => {
plugin_key: "mock",
type: "bundle",
meta: { id: "mock" },
// @ts-expect-error - type error somewhere
value: {
id: "mock",
alias: {
Expand All @@ -124,7 +121,6 @@ test("it should be able to upsert (insert & update)", async () => {
meta: {
id: "mock",
},
// @ts-expect-error - type error somewhere
value: {
id: "mock",
alias: {
Expand Down Expand Up @@ -154,7 +150,7 @@ test("it should be able to upsert (insert & update)", async () => {
const dbFileAfter = await applyChanges({
lix: project.lix,
file: dbFile,
changes,
changes: changes as Change[],
});

const db = initDb({
Expand Down
Loading

0 comments on commit f551ff4

Please sign in to comment.