@tailor-platform/create-sdk 1.52.0 → 1.54.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,9 @@
1
1
  # @tailor-platform/create-sdk
2
2
 
3
+ ## 1.54.0
4
+
5
+ ## 1.53.0
6
+
3
7
  ## 1.52.0
4
8
 
5
9
  ### Patch Changes
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tailor-platform/create-sdk",
3
- "version": "1.52.0",
3
+ "version": "1.54.0",
4
4
  "description": "A CLI tool to quickly create a new Tailor Platform SDK project",
5
5
  "license": "MIT",
6
6
  "repository": {
@@ -17,7 +17,7 @@
17
17
  ],
18
18
  "type": "module",
19
19
  "dependencies": {
20
- "@clack/prompts": "1.4.0",
20
+ "@clack/prompts": "1.5.0",
21
21
  "execa": "9.6.1",
22
22
  "picocolors": "1.1.1",
23
23
  "pkg-types": "2.3.1",
@@ -26,9 +26,9 @@
26
26
  },
27
27
  "devDependencies": {
28
28
  "@types/node": "24.12.4",
29
- "oxlint": "1.66.0",
29
+ "oxlint": "1.67.0",
30
30
  "oxlint-tsgolint": "0.23.0",
31
- "tsdown": "0.22.0",
31
+ "tsdown": "0.22.1",
32
32
  "typescript": "5.9.3"
33
33
  },
34
34
  "scripts": {
@@ -14,10 +14,10 @@
14
14
  "typecheck": "tsc --noEmit"
15
15
  },
16
16
  "devDependencies": {
17
- "@tailor-platform/sdk": "1.52.0",
17
+ "@tailor-platform/sdk": "1.54.0",
18
18
  "@types/node": "24.12.4",
19
- "oxfmt": "0.51.0",
20
- "oxlint": "1.66.0",
19
+ "oxfmt": "0.52.0",
20
+ "oxlint": "1.67.0",
21
21
  "oxlint-tsgolint": "0.23.0",
22
22
  "typescript": "5.9.3",
23
23
  "vitest": "4.1.7"
@@ -14,10 +14,10 @@
14
14
  "typecheck": "tsc --noEmit"
15
15
  },
16
16
  "devDependencies": {
17
- "@tailor-platform/sdk": "1.52.0",
17
+ "@tailor-platform/sdk": "1.54.0",
18
18
  "@types/node": "24.12.4",
19
- "oxfmt": "0.51.0",
20
- "oxlint": "1.66.0",
19
+ "oxfmt": "0.52.0",
20
+ "oxlint": "1.67.0",
21
21
  "oxlint-tsgolint": "0.23.0",
22
22
  "typescript": "5.9.3",
23
23
  "vitest": "4.1.7"
@@ -12,10 +12,10 @@
12
12
  "typecheck": "tsc --noEmit"
13
13
  },
14
14
  "devDependencies": {
15
- "@tailor-platform/sdk": "1.52.0",
15
+ "@tailor-platform/sdk": "1.54.0",
16
16
  "@types/node": "24.12.4",
17
- "oxfmt": "0.51.0",
18
- "oxlint": "1.66.0",
17
+ "oxfmt": "0.52.0",
18
+ "oxlint": "1.67.0",
19
19
  "oxlint-tsgolint": "0.23.0",
20
20
  "typescript": "5.9.3"
21
21
  }
@@ -12,10 +12,10 @@
12
12
  "typecheck": "tsc --noEmit"
13
13
  },
14
14
  "devDependencies": {
15
- "@tailor-platform/sdk": "1.52.0",
15
+ "@tailor-platform/sdk": "1.54.0",
16
16
  "@types/node": "24.12.4",
17
- "oxfmt": "0.51.0",
18
- "oxlint": "1.66.0",
17
+ "oxfmt": "0.52.0",
18
+ "oxlint": "1.67.0",
19
19
  "oxlint-tsgolint": "0.23.0",
20
20
  "typescript": "5.9.3"
21
21
  }
@@ -13,10 +13,10 @@
13
13
  "typecheck": "tsc --noEmit"
14
14
  },
15
15
  "devDependencies": {
16
- "@tailor-platform/sdk": "1.52.0",
16
+ "@tailor-platform/sdk": "1.54.0",
17
17
  "@types/node": "24.12.4",
18
- "oxfmt": "0.51.0",
19
- "oxlint": "1.66.0",
18
+ "oxfmt": "0.52.0",
19
+ "oxlint": "1.67.0",
20
20
  "oxlint-tsgolint": "0.23.0",
21
21
  "typescript": "5.9.3"
22
22
  }
@@ -14,10 +14,10 @@
14
14
  "typecheck": "tsc --noEmit"
15
15
  },
16
16
  "devDependencies": {
17
- "@tailor-platform/sdk": "1.52.0",
17
+ "@tailor-platform/sdk": "1.54.0",
18
18
  "@types/node": "24.12.4",
19
- "oxfmt": "0.51.0",
20
- "oxlint": "1.66.0",
19
+ "oxfmt": "0.52.0",
20
+ "oxlint": "1.67.0",
21
21
  "oxlint-tsgolint": "0.23.0",
22
22
  "typescript": "5.9.3",
23
23
  "vitest": "4.1.7"
@@ -0,0 +1,49 @@
1
+ import { unauthenticatedTailorUser } from "@tailor-platform/sdk/test";
2
+ import { createKyselyMock } from "@tailor-platform/sdk/vitest";
3
+ import { describe, expect, test, vi } from "vitest";
4
+ import { getDB, type Namespace } from "../generated/db";
5
+ import resolver from "./upsertUsers";
6
+
7
+ vi.mock("../generated/db", { spy: true });
8
+
9
+ describe("upsertUsers resolver", () => {
10
+ test("inserts new users and updates existing ones", async () => {
11
+ const mock = createKyselyMock<Namespace["main-db"]>();
12
+ vi.mocked(getDB).mockReturnValue(mock.db);
13
+
14
+ mock.setQueryResolver((query) => {
15
+ switch (query.kind) {
16
+ case "SelectQueryNode":
17
+ return query.parameters.includes("exists@example.com") ? [{ id: "user-1" }] : [];
18
+ case "InsertQueryNode":
19
+ case "UpdateQueryNode":
20
+ return { numAffectedRows: 1 };
21
+ default:
22
+ return [];
23
+ }
24
+ });
25
+
26
+ const result = await resolver.body({
27
+ input: {
28
+ users: [
29
+ { name: "Newcomer", email: "new@example.com", age: 22 },
30
+ { name: "Existing", email: "exists@example.com", age: 41 },
31
+ ],
32
+ },
33
+ user: unauthenticatedTailorUser,
34
+ env: { appName: "Resolver Template", version: 1 },
35
+ });
36
+
37
+ expect(result).toEqual({ created: 1, updated: 1 });
38
+ expect(mock.executedQueries).toHaveLength(4);
39
+ expect(mock.selects).toHaveLength(2);
40
+ expect(mock.inserts).toHaveLength(1);
41
+ expect(mock.inserts[0].parameters).toEqual(
42
+ expect.arrayContaining(["Newcomer", "new@example.com", 22]),
43
+ );
44
+ expect(mock.updates).toHaveLength(1);
45
+ expect(mock.updates[0].parameters).toEqual(
46
+ expect.arrayContaining(["Existing", "exists@example.com", 41]),
47
+ );
48
+ });
49
+ });
@@ -0,0 +1,46 @@
1
+ import { createResolver, t } from "@tailor-platform/sdk";
2
+ import { getDB } from "../generated/db";
3
+
4
+ const resolver = createResolver({
5
+ name: "upsertUsers",
6
+ operation: "mutation",
7
+ input: {
8
+ users: t.object({ name: t.string(), email: t.string(), age: t.int() }, { array: true }),
9
+ },
10
+ body: async (context) => {
11
+ const db = getDB("main-db");
12
+
13
+ return await db.transaction().execute(async (trx) => {
14
+ let created = 0;
15
+ let updated = 0;
16
+
17
+ for (const user of context.input.users) {
18
+ const existing = await trx
19
+ .selectFrom("User")
20
+ .select("id")
21
+ .where("email", "=", user.email)
22
+ .executeTakeFirst();
23
+
24
+ if (existing) {
25
+ await trx
26
+ .updateTable("User")
27
+ .set({ name: user.name, age: user.age })
28
+ .where("email", "=", user.email)
29
+ .execute();
30
+ updated++;
31
+ } else {
32
+ await trx.insertInto("User").values(user).execute();
33
+ created++;
34
+ }
35
+ }
36
+
37
+ return { created, updated };
38
+ });
39
+ },
40
+ output: t.object({
41
+ created: t.int(),
42
+ updated: t.int(),
43
+ }),
44
+ });
45
+
46
+ export default resolver;
@@ -12,10 +12,10 @@
12
12
  "typecheck": "tsc --noEmit"
13
13
  },
14
14
  "devDependencies": {
15
- "@tailor-platform/sdk": "1.52.0",
15
+ "@tailor-platform/sdk": "1.54.0",
16
16
  "@types/node": "24.12.4",
17
- "oxfmt": "0.51.0",
18
- "oxlint": "1.66.0",
17
+ "oxfmt": "0.52.0",
18
+ "oxlint": "1.67.0",
19
19
  "oxlint-tsgolint": "0.23.0",
20
20
  "typescript": "5.9.3"
21
21
  }
@@ -14,10 +14,10 @@
14
14
  "typecheck": "tsc --noEmit"
15
15
  },
16
16
  "devDependencies": {
17
- "@tailor-platform/sdk": "1.52.0",
17
+ "@tailor-platform/sdk": "1.54.0",
18
18
  "@types/node": "24.12.4",
19
- "oxfmt": "0.51.0",
20
- "oxlint": "1.66.0",
19
+ "oxfmt": "0.52.0",
20
+ "oxlint": "1.67.0",
21
21
  "oxlint-tsgolint": "0.23.0",
22
22
  "typescript": "5.9.3",
23
23
  "vitest": "4.1.7"
@@ -15,12 +15,12 @@
15
15
  "typecheck": "tsc --noEmit"
16
16
  },
17
17
  "devDependencies": {
18
- "@tailor-platform/sdk": "1.52.0",
18
+ "@tailor-platform/sdk": "1.54.0",
19
19
  "@types/node": "24.12.4",
20
20
  "graphql": "16.14.0",
21
21
  "graphql-request": "7.4.0",
22
- "oxfmt": "0.51.0",
23
- "oxlint": "1.66.0",
22
+ "oxfmt": "0.52.0",
23
+ "oxlint": "1.67.0",
24
24
  "oxlint-tsgolint": "0.23.0",
25
25
  "typescript": "5.9.3",
26
26
  "vitest": "4.1.7"