@tailor-platform/sdk 2.0.0-next.0 → 2.0.0-next.2
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 +161 -0
- package/dist/application-Dtqap5jM.mjs +3 -0
- package/dist/{client-CobIRHl-.mjs → application-XuMWK4eq.mjs} +5869 -25
- package/dist/application-XuMWK4eq.mjs.map +1 -0
- package/dist/{assert-CKfwrmCV.mjs → assert-DBxo8jPo.mjs} +1 -2
- package/dist/{assert-CKfwrmCV.mjs.map → assert-DBxo8jPo.mjs.map} +1 -1
- package/dist/{authconnection-D8SJGMpj.mjs → authconnection-D2MhtTN5.mjs} +2 -3
- package/dist/{authconnection-D8SJGMpj.mjs.map → authconnection-D2MhtTN5.mjs.map} +1 -1
- package/dist/{authconnection-BIYzEh2p.d.mts → authconnection-DvUQAjQS.d.mts} +1 -1
- package/dist/{brand-DlnJ375c.mjs → brand-Eo4pLXPJ.mjs} +1 -2
- package/dist/{brand-DlnJ375c.mjs.map → brand-Eo4pLXPJ.mjs.map} +1 -1
- package/dist/cli/index.mjs +241 -237
- package/dist/cli/index.mjs.map +1 -1
- package/dist/cli/lib.d.mts +547 -620
- package/dist/cli/lib.mjs +9 -11
- package/dist/cli/lib.mjs.map +1 -1
- package/dist/completion/zsh-worker.zsh +4108 -0
- package/dist/configure/index.d.mts +9 -7
- package/dist/configure/index.mjs +76 -40
- package/dist/configure/index.mjs.map +1 -1
- package/dist/{context-s0lxhu8_.mjs → context-Bd266-ru.mjs} +2 -3
- package/dist/context-Bd266-ru.mjs.map +1 -0
- package/dist/{context-CUBwSBq4.d.mts → context-C2lEi9uw.d.mts} +7 -28
- package/dist/{crashreport-D1wKBJ8N.mjs → crashreport-BMWcxeSE.mjs} +1 -2
- package/dist/{crashreport-BhD0y14F.mjs → crashreport-DFq-vsU0.mjs} +21 -14
- package/dist/{crashreport-BhD0y14F.mjs.map → crashreport-DFq-vsU0.mjs.map} +1 -1
- package/dist/{enum-constants-C7DaWeQo.mjs → enum-constants-j9QBF0cB.mjs} +1 -2
- package/dist/enum-constants-j9QBF0cB.mjs.map +1 -0
- package/dist/{errors-EsY4XO6O.mjs → errors-Dtf2WPaW.mjs} +1 -2
- package/dist/{errors-EsY4XO6O.mjs.map → errors-Dtf2WPaW.mjs.map} +1 -1
- package/dist/{field-C4zdJLW5.mjs → field-DOsJCPFa.mjs} +1 -2
- package/dist/field-DOsJCPFa.mjs.map +1 -0
- package/dist/{file-B58Dm-2P.mjs → file-BbdFGdMV.mjs} +3 -12
- package/dist/file-BbdFGdMV.mjs.map +1 -0
- package/dist/{file-BzK8z3X-.d.mts → file-Dq3NIt_F.d.mts} +3 -42
- package/dist/{file-utils-BHPxPXmn.mjs → file-utils-CYZnO1pX.mjs} +6 -7
- package/dist/file-utils-CYZnO1pX.mjs.map +1 -0
- package/dist/{globals-ByrCoDip.mjs → globals-Cf0sxIt8.mjs} +53 -5
- package/dist/globals-Cf0sxIt8.mjs.map +1 -0
- package/dist/http-adapter.generated-DFsXDdm5.d.mts +581 -0
- package/dist/{iconv-kwrmd1U_.d.mts → iconv-Co-TOPuH.d.mts} +1 -1
- package/dist/{iconv-DreIffeM.mjs → iconv-D2vi8G36.mjs} +2 -3
- package/dist/{iconv-DreIffeM.mjs.map → iconv-D2vi8G36.mjs.map} +1 -1
- package/dist/{idp-Ch95ag8h.mjs → idp-BDbK5gjm.mjs} +2 -3
- package/dist/{idp-Ch95ag8h.mjs.map → idp-BDbK5gjm.mjs.map} +1 -1
- package/dist/{idp-BlBPtXJ-.d.mts → idp-DrhVrLmV.d.mts} +1 -1
- package/dist/{index-CLxubakC.d.mts → index-BI-_j9Z3.d.mts} +49 -261
- package/dist/{index-CPRnOjjt.d.mts → index-C4JirJH8.d.mts} +2 -2
- package/dist/{index-CQZVJ5SX.d.mts → index-CZfWhr0a.d.mts} +2 -2
- package/dist/{index-DRhMpdnA.d.mts → index-Cg8VKAdN.d.mts} +8 -8
- package/dist/{index-CfRFkXIO.d.mts → index-DYRjoLXD.d.mts} +2 -2
- package/dist/index-lFpcjHPU.d.mts +201 -0
- package/dist/{index-DUupuPhZ.d.mts → index-nW7hE6oE.d.mts} +2 -2
- package/dist/{interceptor-DOqRkCya.mjs → interceptor-D-q1rvRl.mjs} +1 -2
- package/dist/{interceptor-DOqRkCya.mjs.map → interceptor-D-q1rvRl.mjs.map} +1 -1
- package/dist/kysely/index.mjs +0 -1
- package/dist/kysely/index.mjs.map +1 -1
- package/dist/{kysely-type-D1e0Vwkd.mjs → kysely-type-DR8uzZTA.mjs} +2 -3
- package/dist/kysely-type-DR8uzZTA.mjs.map +1 -0
- package/dist/{logger-DpJyJvNz.mjs → logger-CxF-Ex5d.mjs} +1 -2
- package/dist/{logger-DpJyJvNz.mjs.map → logger-CxF-Ex5d.mjs.map} +1 -1
- package/dist/{mock-DMgIygjE.mjs → mock-FPxmnt-y.mjs} +9 -56
- package/dist/mock-FPxmnt-y.mjs.map +1 -0
- package/dist/{multiline-Cf9ODpr1.mjs → multiline-sfHpTZZK.mjs} +1 -2
- package/dist/{multiline-Cf9ODpr1.mjs.map → multiline-sfHpTZZK.mjs.map} +1 -1
- package/dist/{package-json-DcQApfPQ.mjs → package-json-8b0O9TlX.mjs} +1 -2
- package/dist/{package-json-DcQApfPQ.mjs.map → package-json-8b0O9TlX.mjs.map} +1 -1
- package/dist/package-json-Cv2Z-TqQ.mjs +3 -0
- package/dist/plugin/builtin/enum-constants/index.d.mts +1 -1
- package/dist/plugin/builtin/enum-constants/index.mjs +1 -2
- package/dist/plugin/builtin/file-utils/index.d.mts +1 -1
- package/dist/plugin/builtin/file-utils/index.mjs +1 -2
- package/dist/plugin/builtin/kysely-type/index.d.mts +1 -1
- package/dist/plugin/builtin/kysely-type/index.mjs +1 -2
- package/dist/plugin/builtin/seed/index.d.mts +1 -1
- package/dist/plugin/builtin/seed/index.mjs +1 -2
- package/dist/plugin/index.d.mts +4 -5
- package/dist/plugin/index.mjs +0 -1
- package/dist/plugin/index.mjs.map +1 -1
- package/dist/registry-DH4m7eYo.mjs +53 -0
- package/dist/registry-DH4m7eYo.mjs.map +1 -0
- package/dist/{repl-editor-CJG3sz7A.mjs → repl-editor-DmGr9zMw.mjs} +2 -3
- package/dist/{repl-editor-CJG3sz7A.mjs.map → repl-editor-DmGr9zMw.mjs.map} +1 -1
- package/dist/{chunk-BkoGK1jX.mjs → rolldown-runtime-DXywRVcq.mjs} +0 -1
- package/dist/runtime/authconnection.d.mts +1 -1
- package/dist/runtime/authconnection.mjs +1 -2
- package/dist/runtime/context.d.mts +1 -1
- package/dist/runtime/context.mjs +1 -2
- package/dist/runtime/file.d.mts +2 -2
- package/dist/runtime/file.mjs +2 -3
- package/dist/runtime/globals.d.mts +8 -41
- package/dist/runtime/globals.mjs +0 -1
- package/dist/runtime/iconv.d.mts +1 -1
- package/dist/runtime/iconv.mjs +1 -2
- package/dist/runtime/idp.d.mts +1 -1
- package/dist/runtime/idp.mjs +1 -2
- package/dist/runtime/index.d.mts +8 -8
- package/dist/runtime/index.mjs +7 -8
- package/dist/runtime/secretmanager.d.mts +1 -1
- package/dist/runtime/secretmanager.mjs +1 -2
- package/dist/runtime/workflow.d.mts +2 -2
- package/dist/runtime/workflow.mjs +1 -2
- package/dist/{runtime-C7qTBDD2.mjs → runtime-CY4JvrDj.mjs} +1069 -542
- package/dist/runtime-CY4JvrDj.mjs.map +1 -0
- package/dist/{schema-1msIhXwA.mjs → schema-Dtw9Orye.mjs} +18 -16
- package/dist/schema-Dtw9Orye.mjs.map +1 -0
- package/dist/{secret-file-CWzF8rry.mjs → secret-file-VSVGy1V0.mjs} +27 -3
- package/dist/{secret-file-CWzF8rry.mjs.map → secret-file-VSVGy1V0.mjs.map} +1 -1
- package/dist/{secretmanager-CKLB3wAQ.d.mts → secretmanager-B3n4KHfm.d.mts} +1 -1
- package/dist/{secretmanager-B9h-U_8U.mjs → secretmanager-BVxw3ih_.mjs} +2 -3
- package/dist/{secretmanager-B9h-U_8U.mjs.map → secretmanager-BVxw3ih_.mjs.map} +1 -1
- package/dist/seed/index.mjs +0 -1
- package/dist/seed/index.mjs.map +1 -1
- package/dist/{seed-BH2FbrPV.mjs → seed-izIEyP3z.mjs} +7 -19
- package/dist/seed-izIEyP3z.mjs.map +1 -0
- package/dist/service-DCqIWibD.mjs +3 -0
- package/dist/{service-DMohAx8a2.mjs → service-DU1mVzri2.mjs} +3 -4
- package/dist/{service-DMohAx8a2.mjs.map → service-DU1mVzri2.mjs.map} +1 -1
- package/dist/{service-wI3Hvrgx.mjs → service-DjyqbCaJ.mjs} +9 -10
- package/dist/service-DjyqbCaJ.mjs.map +1 -0
- package/dist/{telemetry-BQbbVo2t.mjs → telemetry-CdqJEzkj.mjs} +2 -3
- package/dist/{telemetry-BQbbVo2t.mjs.map → telemetry-CdqJEzkj.mjs.map} +1 -1
- package/dist/telemetry-ClwW5ohF.mjs +3 -0
- package/dist/test-env-key-D7UkZp99.mjs +75 -0
- package/dist/test-env-key-D7UkZp99.mjs.map +1 -0
- package/dist/type-source-DH_LH20p.mjs +13 -0
- package/dist/type-source-DH_LH20p.mjs.map +1 -0
- package/dist/types-74etvaxy.mjs +4 -0
- package/dist/{plugin-C_FyVSdl.d.mts → types-BDRml5C3.d.mts} +128 -188
- package/dist/{types-CmzfQP_m.mjs → types-BQijbo4m.mjs} +10 -11
- package/dist/types-BQijbo4m.mjs.map +1 -0
- package/dist/types-BX4q6Mo6.d.mts +339 -0
- package/dist/types-BZ7QKVE8.d.mts +21 -0
- package/dist/{tailordb-BlBGmQK-.d.mts → types-CdcQh4Z2.d.mts} +92 -242
- package/dist/utils/test/index.d.mts +6 -14
- package/dist/utils/test/index.mjs +4 -14
- package/dist/utils/test/index.mjs.map +1 -1
- package/dist/vitest/environment.mjs +1 -2
- package/dist/vitest/environment.mjs.map +1 -1
- package/dist/vitest/index.d.mts +42 -5
- package/dist/vitest/index.mjs +133 -4
- package/dist/vitest/index.mjs.map +1 -1
- package/dist/vitest/setup.mjs +2 -3
- package/dist/vitest/setup.mjs.map +1 -1
- package/dist/{workflow--aPbA8Uq.mjs → workflow-BOmaZwwG.mjs} +9 -5
- package/dist/workflow-BOmaZwwG.mjs.map +1 -0
- package/dist/{workflow-CMamswkK.d.mts → workflow-BVy4XWjS.d.mts} +15 -10
- package/dist/workflow.generated-ClEjBYhm.d.mts +671 -0
- package/docs/cli/application.md +0 -2
- package/docs/cli/completion.md +3 -0
- package/docs/cli/crashreport.md +0 -2
- package/docs/cli/executor.md +53 -0
- package/docs/cli/function.md +1 -1
- package/docs/cli/setup.md +35 -33
- package/docs/cli/user.md +3 -3
- package/docs/cli/workflow.md +157 -20
- package/docs/cli/workspace.md +3 -3
- package/docs/cli-reference.md +26 -20
- package/docs/configuration.md +0 -2
- package/docs/github-actions.md +29 -16
- package/docs/migration/v2.md +475 -0
- package/docs/plugin/custom.md +2 -2
- package/docs/plugin/index.md +1 -1
- package/docs/runtime.md +4 -4
- package/docs/services/aigateway.md +97 -0
- package/docs/services/auth.md +31 -14
- package/docs/services/executor.md +3 -5
- package/docs/services/resolver.md +8 -10
- package/docs/services/tailordb.md +15 -13
- package/docs/services/workflow.md +17 -19
- package/docs/testing.md +75 -56
- package/package.json +18 -17
- package/dist/actor-J2gJ0eK5.d.mts +0 -24
- package/dist/application-76hhIhnJ.mjs +0 -5594
- package/dist/application-76hhIhnJ.mjs.map +0 -1
- package/dist/application-av2raLs6.mjs +0 -4
- package/dist/cli/skills.d.mts +0 -1
- package/dist/cli/skills.mjs +0 -22
- package/dist/cli/skills.mjs.map +0 -1
- package/dist/client-C68VWo4g.mjs +0 -4
- package/dist/client-CobIRHl-.mjs.map +0 -1
- package/dist/context-s0lxhu8_.mjs.map +0 -1
- package/dist/enum-constants-C7DaWeQo.mjs.map +0 -1
- package/dist/env-B-g-qgE4.d.mts +0 -7
- package/dist/field-C4zdJLW5.mjs.map +0 -1
- package/dist/file-B58Dm-2P.mjs.map +0 -1
- package/dist/file-utils-BHPxPXmn.mjs.map +0 -1
- package/dist/globals-ByrCoDip.mjs.map +0 -1
- package/dist/job-BpsFXPbi.mjs +0 -54
- package/dist/job-BpsFXPbi.mjs.map +0 -1
- package/dist/kysely-type-D1e0Vwkd.mjs.map +0 -1
- package/dist/mock-DMgIygjE.mjs.map +0 -1
- package/dist/package-json-wzO6nV9O.mjs +0 -4
- package/dist/registry-D0uB0OrK.mjs +0 -178
- package/dist/registry-D0uB0OrK.mjs.map +0 -1
- package/dist/runtime-C7qTBDD2.mjs.map +0 -1
- package/dist/schema-1msIhXwA.mjs.map +0 -1
- package/dist/seed-BH2FbrPV.mjs.map +0 -1
- package/dist/service-BHQIerYh.mjs +0 -4
- package/dist/service-wI3Hvrgx.mjs.map +0 -1
- package/dist/telemetry-w92bvGdC.mjs +0 -4
- package/dist/types-2Be3wSMc.mjs +0 -5
- package/dist/types-CmzfQP_m.mjs.map +0 -1
- package/dist/workflow--aPbA8Uq.mjs.map +0 -1
- package/dist/workflow.generated-Bf1tWylx.d.mts +0 -1416
- package/docs/generator/builtin.md +0 -257
- package/docs/generator/custom.md +0 -147
- package/docs/generator/index.md +0 -66
|
@@ -1,257 +0,0 @@
|
|
|
1
|
-
# Builtin Generators
|
|
2
|
-
|
|
3
|
-
The SDK includes four builtin generators for common code generation tasks.
|
|
4
|
-
|
|
5
|
-
## @tailor-platform/kysely-type
|
|
6
|
-
|
|
7
|
-
Generates Kysely type definitions and the `getDB()` function for type-safe database access.
|
|
8
|
-
|
|
9
|
-
### Configuration
|
|
10
|
-
|
|
11
|
-
```typescript
|
|
12
|
-
["@tailor-platform/kysely-type", { distPath: "./generated/tailordb.ts" }];
|
|
13
|
-
```
|
|
14
|
-
|
|
15
|
-
| Option | Type | Description |
|
|
16
|
-
| ---------- | -------- | --------------------------- |
|
|
17
|
-
| `distPath` | `string` | Output file path (required) |
|
|
18
|
-
|
|
19
|
-
### Output
|
|
20
|
-
|
|
21
|
-
Generates a TypeScript file containing:
|
|
22
|
-
|
|
23
|
-
- Type definitions for all TailorDB types
|
|
24
|
-
- `getDB(namespace)` function to create Kysely instances
|
|
25
|
-
- Utility types for `Timestamp`, `Serial`, and `ObjectColumnType` (used for nested object fields so insert and select types stay correct)
|
|
26
|
-
|
|
27
|
-
### Usage
|
|
28
|
-
|
|
29
|
-
```typescript
|
|
30
|
-
import { getDB } from "./generated/tailordb";
|
|
31
|
-
|
|
32
|
-
// In resolvers
|
|
33
|
-
body: async (context) => {
|
|
34
|
-
const db = getDB("tailordb");
|
|
35
|
-
const users = await db
|
|
36
|
-
.selectFrom("User")
|
|
37
|
-
.selectAll()
|
|
38
|
-
.where("email", "=", context.input.email)
|
|
39
|
-
.execute();
|
|
40
|
-
return { users };
|
|
41
|
-
};
|
|
42
|
-
|
|
43
|
-
// In executors
|
|
44
|
-
body: async ({ newRecord }) => {
|
|
45
|
-
const db = getDB("tailordb");
|
|
46
|
-
await db.insertInto("AuditLog").values({ userId: newRecord.id, action: "created" }).execute();
|
|
47
|
-
};
|
|
48
|
-
|
|
49
|
-
// In workflow jobs
|
|
50
|
-
body: async (input, { env }) => {
|
|
51
|
-
const db = getDB("tailordb");
|
|
52
|
-
return await db
|
|
53
|
-
.selectFrom("Order")
|
|
54
|
-
.selectAll()
|
|
55
|
-
.where("id", "=", input.orderId)
|
|
56
|
-
.executeTakeFirst();
|
|
57
|
-
};
|
|
58
|
-
```
|
|
59
|
-
|
|
60
|
-
### Raw SQL
|
|
61
|
-
|
|
62
|
-
For queries that the Kysely query builder can't express, use the `sql` tag re-exported from `@tailor-platform/sdk/kysely`. Plain value substitutions (`${...}`) are sent as bound parameters, so user-supplied values are parameterized safely. SQL fragments produced by Kysely helpers (for example `sql.raw(...)`, identifiers, refs) are inlined into the generated SQL string by design — do not pass untrusted input through those.
|
|
63
|
-
|
|
64
|
-
```typescript
|
|
65
|
-
import { sql } from "@tailor-platform/sdk/kysely";
|
|
66
|
-
import { getDB } from "./generated/tailordb";
|
|
67
|
-
|
|
68
|
-
createResolver({
|
|
69
|
-
name: "supplierCountByState",
|
|
70
|
-
operation: "query",
|
|
71
|
-
input: { country: t.string() },
|
|
72
|
-
output: t.object({
|
|
73
|
-
rows: t.array(t.object({ state: t.string(), count: t.int() })),
|
|
74
|
-
}),
|
|
75
|
-
body: async ({ input }) => {
|
|
76
|
-
const db = getDB("tailordb");
|
|
77
|
-
const { rows } = await sql<{ state: string; count: number }>`
|
|
78
|
-
SELECT state, COUNT(*) AS count
|
|
79
|
-
FROM "Supplier"
|
|
80
|
-
WHERE country = ${input.country}
|
|
81
|
-
GROUP BY state
|
|
82
|
-
`.execute(db);
|
|
83
|
-
return { rows };
|
|
84
|
-
},
|
|
85
|
-
});
|
|
86
|
-
```
|
|
87
|
-
|
|
88
|
-
The same `sql` tag works inside `db.transaction().execute(async (trx) => ...)` by passing `trx` to `.execute()`:
|
|
89
|
-
|
|
90
|
-
```typescript
|
|
91
|
-
await db.transaction().execute(async (trx) => {
|
|
92
|
-
await sql`UPDATE "Supplier" SET state = ${state} WHERE id = ${id}`.execute(trx);
|
|
93
|
-
});
|
|
94
|
-
```
|
|
95
|
-
|
|
96
|
-
## @tailor-platform/enum-constants
|
|
97
|
-
|
|
98
|
-
Extracts enum constants from TailorDB type definitions.
|
|
99
|
-
|
|
100
|
-
### Configuration
|
|
101
|
-
|
|
102
|
-
```typescript
|
|
103
|
-
["@tailor-platform/enum-constants", { distPath: "./generated/enums.ts" }];
|
|
104
|
-
```
|
|
105
|
-
|
|
106
|
-
| Option | Type | Description |
|
|
107
|
-
| ---------- | -------- | --------------------------- |
|
|
108
|
-
| `distPath` | `string` | Output file path (required) |
|
|
109
|
-
|
|
110
|
-
### Output
|
|
111
|
-
|
|
112
|
-
Generates TypeScript constants for all enum fields:
|
|
113
|
-
|
|
114
|
-
```typescript
|
|
115
|
-
// Generated output
|
|
116
|
-
export const OrderStatus = {
|
|
117
|
-
PENDING: "PENDING",
|
|
118
|
-
PROCESSING: "PROCESSING",
|
|
119
|
-
COMPLETED: "COMPLETED",
|
|
120
|
-
CANCELLED: "CANCELLED",
|
|
121
|
-
} as const;
|
|
122
|
-
|
|
123
|
-
export type OrderStatus = (typeof OrderStatus)[keyof typeof OrderStatus];
|
|
124
|
-
```
|
|
125
|
-
|
|
126
|
-
### Usage
|
|
127
|
-
|
|
128
|
-
```typescript
|
|
129
|
-
import { OrderStatus } from "./generated/enums";
|
|
130
|
-
|
|
131
|
-
// Type-safe enum usage
|
|
132
|
-
const status: OrderStatus = OrderStatus.PENDING;
|
|
133
|
-
|
|
134
|
-
// In queries
|
|
135
|
-
const orders = await db
|
|
136
|
-
.selectFrom("Order")
|
|
137
|
-
.selectAll()
|
|
138
|
-
.where("status", "=", OrderStatus.COMPLETED)
|
|
139
|
-
.execute();
|
|
140
|
-
```
|
|
141
|
-
|
|
142
|
-
## @tailor-platform/file-utils
|
|
143
|
-
|
|
144
|
-
Generates utility functions for handling file-type fields in TailorDB.
|
|
145
|
-
|
|
146
|
-
### Configuration
|
|
147
|
-
|
|
148
|
-
```typescript
|
|
149
|
-
["@tailor-platform/file-utils", { distPath: "./generated/files.ts" }];
|
|
150
|
-
```
|
|
151
|
-
|
|
152
|
-
| Option | Type | Description |
|
|
153
|
-
| ---------- | -------- | --------------------------- |
|
|
154
|
-
| `distPath` | `string` | Output file path (required) |
|
|
155
|
-
|
|
156
|
-
### Output
|
|
157
|
-
|
|
158
|
-
Generates TypeScript interfaces and utilities for types with file fields:
|
|
159
|
-
|
|
160
|
-
```typescript
|
|
161
|
-
// Generated output
|
|
162
|
-
export interface UserFileFields {
|
|
163
|
-
avatar: string;
|
|
164
|
-
documents: string;
|
|
165
|
-
}
|
|
166
|
-
|
|
167
|
-
export function getUserFileFields(): (keyof UserFileFields)[] {
|
|
168
|
-
return ["avatar", "documents"];
|
|
169
|
-
}
|
|
170
|
-
```
|
|
171
|
-
|
|
172
|
-
## @tailor-platform/seed
|
|
173
|
-
|
|
174
|
-
Generates seed data configuration files for database initialization.
|
|
175
|
-
|
|
176
|
-
### Configuration
|
|
177
|
-
|
|
178
|
-
```typescript
|
|
179
|
-
// Basic configuration
|
|
180
|
-
["@tailor-platform/seed", { distPath: "./seed" }];
|
|
181
|
-
|
|
182
|
-
// With default machine user
|
|
183
|
-
["@tailor-platform/seed", { distPath: "./seed", machineUserName: "admin" }];
|
|
184
|
-
```
|
|
185
|
-
|
|
186
|
-
| Option | Type | Description |
|
|
187
|
-
| -------------------- | ---------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
188
|
-
| `distPath` | `string` | Output directory path (required) |
|
|
189
|
-
| `machineUserName` | `string` | Default machine user name (can be overridden at runtime) |
|
|
190
|
-
| `disableIdpUserSync` | `{ userToIdp?: boolean; idpToUser?: boolean }` | Skip emitting individual `_User <-> userProfile` foreign keys. Both directions are emitted by default. See [IdP user synchronization](#idp-user-synchronization). |
|
|
191
|
-
|
|
192
|
-
### IdP user synchronization
|
|
193
|
-
|
|
194
|
-
When `auth.userProfile` is configured, the seed plugin treats the userProfile
|
|
195
|
-
type (e.g. `User`) and the IdP-managed `_User` table as a pair. By default it
|
|
196
|
-
emits foreign keys in both directions so that `validate` rejects any row in
|
|
197
|
-
either table that does not have a matching counterpart:
|
|
198
|
-
|
|
199
|
-
| Direction | Foreign key | Catches |
|
|
200
|
-
| ----------- | ---------------------------------------------- | ---------------------------------------------- |
|
|
201
|
-
| `idpToUser` | `_User.name` → `<userProfile>.<usernameField>` | Creating an IdP credential with no profile row |
|
|
202
|
-
| `userToIdp` | `<userProfile>.<usernameField>` → `_User.name` | Creating a profile row with no IdP credential |
|
|
203
|
-
|
|
204
|
-
Neither direction is enforced by the runtime. In production it is normal for
|
|
205
|
-
one side to exist without the other — for example a userProfile row exists
|
|
206
|
-
the moment a user is invited, but the corresponding `_User` row appears only
|
|
207
|
-
after the user finishes signing up. To seed such states, set the relevant
|
|
208
|
-
direction in `disableIdpUserSync` to `true`:
|
|
209
|
-
|
|
210
|
-
```typescript
|
|
211
|
-
// Allow seeding invited-but-not-registered userProfile rows.
|
|
212
|
-
// Still rejects _User rows without a matching userProfile row.
|
|
213
|
-
["@tailor-platform/seed", { distPath: "./seed", disableIdpUserSync: { userToIdp: true } }];
|
|
214
|
-
|
|
215
|
-
// Allow seeding _User rows whose userProfile does not exist yet.
|
|
216
|
-
// Still rejects userProfile rows without a matching _User row.
|
|
217
|
-
["@tailor-platform/seed", { distPath: "./seed", disableIdpUserSync: { idpToUser: true } }];
|
|
218
|
-
```
|
|
219
|
-
|
|
220
|
-
Omitted directions default to `false` (FK emitted).
|
|
221
|
-
|
|
222
|
-
### Output
|
|
223
|
-
|
|
224
|
-
Generates a seed directory structure:
|
|
225
|
-
|
|
226
|
-
```
|
|
227
|
-
seed/
|
|
228
|
-
├── data/
|
|
229
|
-
│ ├── User.jsonl # Seed data files (JSONL format)
|
|
230
|
-
│ ├── User.schema.ts # lines-db schema definitions
|
|
231
|
-
│ └── Product.jsonl
|
|
232
|
-
└── exec.mjs # Executable script
|
|
233
|
-
```
|
|
234
|
-
|
|
235
|
-
### Usage
|
|
236
|
-
|
|
237
|
-
Run the generated executable script:
|
|
238
|
-
|
|
239
|
-
```bash
|
|
240
|
-
# With machine user from config
|
|
241
|
-
node seed/exec.mjs
|
|
242
|
-
|
|
243
|
-
# Specify machine user at runtime (required if not configured, or to override)
|
|
244
|
-
node seed/exec.mjs --machine-user admin
|
|
245
|
-
|
|
246
|
-
# Short form
|
|
247
|
-
node seed/exec.mjs -m admin
|
|
248
|
-
|
|
249
|
-
# With other options
|
|
250
|
-
node seed/exec.mjs -m admin --truncate --yes
|
|
251
|
-
```
|
|
252
|
-
|
|
253
|
-
The `--machine-user` option is required at runtime if `machineUserName` is not configured in the generator options.
|
|
254
|
-
|
|
255
|
-
The generated files are compatible with gql-ingest for bulk data import.
|
|
256
|
-
|
|
257
|
-
The `exec.mjs` is fully regenerated on every `sdk generate` and starts with an `@generated` header — do not hand-edit it. Its `--truncate` path reuses the `tailordb truncate` command, so namespaces declared with `{ external: true }` are skipped automatically and a shell app cannot wipe a sibling app's data via `seed:reset`.
|
package/docs/generator/custom.md
DELETED
|
@@ -1,147 +0,0 @@
|
|
|
1
|
-
# Custom Generators (Deprecated)
|
|
2
|
-
|
|
3
|
-
> **Deprecated**: Use `definePlugins()` with generation-time hooks (`onTypeLoaded`, `generate`, etc.) instead. See [Custom Plugins](../plugin/custom.md) for the recommended approach.
|
|
4
|
-
|
|
5
|
-
Create your own generators by implementing the `CodeGenerator` interface.
|
|
6
|
-
|
|
7
|
-
## CodeGenerator Interface
|
|
8
|
-
|
|
9
|
-
```typescript
|
|
10
|
-
interface CodeGenerator<T, R, E, Ts, Rs> {
|
|
11
|
-
id: string;
|
|
12
|
-
description: string;
|
|
13
|
-
|
|
14
|
-
// Process individual items
|
|
15
|
-
processType(args: {
|
|
16
|
-
type: TailorDBType;
|
|
17
|
-
namespace: string;
|
|
18
|
-
source: { filePath: string; exportName: string };
|
|
19
|
-
}): T | Promise<T>;
|
|
20
|
-
|
|
21
|
-
processResolver(args: { resolver: Resolver; namespace: string }): R | Promise<R>;
|
|
22
|
-
|
|
23
|
-
processExecutor(executor: Executor): E | Promise<E>;
|
|
24
|
-
|
|
25
|
-
// Aggregate per namespace (optional)
|
|
26
|
-
processTailorDBNamespace?(args: {
|
|
27
|
-
namespace: string;
|
|
28
|
-
types: Record<string, T>;
|
|
29
|
-
}): Ts | Promise<Ts>;
|
|
30
|
-
|
|
31
|
-
processResolverNamespace?(args: {
|
|
32
|
-
namespace: string;
|
|
33
|
-
resolvers: Record<string, R>;
|
|
34
|
-
}): Rs | Promise<Rs>;
|
|
35
|
-
|
|
36
|
-
// Final aggregation
|
|
37
|
-
aggregate(args: {
|
|
38
|
-
input: GeneratorInput<Ts, Rs>;
|
|
39
|
-
executorInputs: E[];
|
|
40
|
-
baseDir: string;
|
|
41
|
-
}): GeneratorResult | Promise<GeneratorResult>;
|
|
42
|
-
}
|
|
43
|
-
```
|
|
44
|
-
|
|
45
|
-
## GeneratorResult
|
|
46
|
-
|
|
47
|
-
Generators return a `GeneratorResult` containing files to create:
|
|
48
|
-
|
|
49
|
-
```typescript
|
|
50
|
-
interface GeneratorResult {
|
|
51
|
-
files: Array<{
|
|
52
|
-
path: string; // Relative path from project root
|
|
53
|
-
content: string; // File content
|
|
54
|
-
skipIfExists?: boolean; // Skip if file already exists (default: false)
|
|
55
|
-
executable?: boolean; // Make file executable (default: false)
|
|
56
|
-
}>;
|
|
57
|
-
errors?: string[];
|
|
58
|
-
}
|
|
59
|
-
```
|
|
60
|
-
|
|
61
|
-
## Example: Simple Type List Generator
|
|
62
|
-
|
|
63
|
-
```typescript
|
|
64
|
-
import type { CodeGenerator, GeneratorResult } from "@tailor-platform/sdk";
|
|
65
|
-
|
|
66
|
-
const typeListGenerator: CodeGenerator<string, null, null, string[], null> = {
|
|
67
|
-
id: "type-list",
|
|
68
|
-
description: "Generates a list of all TailorDB type names",
|
|
69
|
-
|
|
70
|
-
processType({ type }) {
|
|
71
|
-
return type.name;
|
|
72
|
-
},
|
|
73
|
-
|
|
74
|
-
processResolver() {
|
|
75
|
-
return null;
|
|
76
|
-
},
|
|
77
|
-
|
|
78
|
-
processExecutor() {
|
|
79
|
-
return null;
|
|
80
|
-
},
|
|
81
|
-
|
|
82
|
-
processTailorDBNamespace({ types }) {
|
|
83
|
-
return Object.values(types);
|
|
84
|
-
},
|
|
85
|
-
|
|
86
|
-
aggregate({ input }) {
|
|
87
|
-
const allTypes = input.tailordb.flatMap((ns) => ns.types);
|
|
88
|
-
const content = `// Generated type list\nexport const types = ${JSON.stringify(allTypes, null, 2)} as const;\n`;
|
|
89
|
-
|
|
90
|
-
return {
|
|
91
|
-
files: [{ path: "generated/types.ts", content }],
|
|
92
|
-
};
|
|
93
|
-
},
|
|
94
|
-
};
|
|
95
|
-
```
|
|
96
|
-
|
|
97
|
-
## Using Custom Generators
|
|
98
|
-
|
|
99
|
-
Pass the generator object directly to `defineGenerators()`:
|
|
100
|
-
|
|
101
|
-
```typescript
|
|
102
|
-
import { defineGenerators } from "@tailor-platform/sdk";
|
|
103
|
-
import { typeListGenerator } from "./generators/type-list";
|
|
104
|
-
|
|
105
|
-
export const generators = defineGenerators(
|
|
106
|
-
["@tailor-platform/kysely-type", { distPath: "./generated/tailordb.ts" }],
|
|
107
|
-
typeListGenerator, // Custom generator
|
|
108
|
-
);
|
|
109
|
-
```
|
|
110
|
-
|
|
111
|
-
## Available Input Data
|
|
112
|
-
|
|
113
|
-
### TailorDBType
|
|
114
|
-
|
|
115
|
-
Contains full type information including:
|
|
116
|
-
|
|
117
|
-
- `name`: Type name
|
|
118
|
-
- `fields`: Field definitions with types, validation, and descriptions
|
|
119
|
-
- `relations`: Relationship definitions
|
|
120
|
-
- `indexes`: Index configurations
|
|
121
|
-
- `permission`: Permission rules
|
|
122
|
-
|
|
123
|
-
### Resolver
|
|
124
|
-
|
|
125
|
-
Contains resolver configuration:
|
|
126
|
-
|
|
127
|
-
- `name`: Resolver name
|
|
128
|
-
- `operation`: Query or mutation
|
|
129
|
-
- `input`: Input schema
|
|
130
|
-
- `output`: Output schema
|
|
131
|
-
|
|
132
|
-
### Executor
|
|
133
|
-
|
|
134
|
-
Contains executor configuration:
|
|
135
|
-
|
|
136
|
-
- `name`: Executor name
|
|
137
|
-
- `trigger`: Trigger configuration
|
|
138
|
-
- `operation`: Execution target
|
|
139
|
-
|
|
140
|
-
### GeneratorAuthInput
|
|
141
|
-
|
|
142
|
-
Contains authentication configuration when available:
|
|
143
|
-
|
|
144
|
-
- `name`: Auth service name
|
|
145
|
-
- `userProfile`: User profile type information
|
|
146
|
-
- `machineUsers`: Machine user definitions
|
|
147
|
-
- `oauth2Clients`: OAuth2 client configurations
|
package/docs/generator/index.md
DELETED
|
@@ -1,66 +0,0 @@
|
|
|
1
|
-
# Generators
|
|
2
|
-
|
|
3
|
-
Generators analyze your TailorDB types, Resolvers, and Executors to automatically generate TypeScript code.
|
|
4
|
-
|
|
5
|
-
## Overview
|
|
6
|
-
|
|
7
|
-
When you run `tailor-sdk generate`, the SDK:
|
|
8
|
-
|
|
9
|
-
1. Loads all TailorDB types, Resolvers, and Executors from your configuration
|
|
10
|
-
2. Passes each definition to the configured generators
|
|
11
|
-
3. Aggregates the results and writes output files
|
|
12
|
-
|
|
13
|
-
This enables generators to create derived code based on your application's schema. For example, the `@tailor-platform/kysely-type` generator produces type-safe database access code from your TailorDB definitions.
|
|
14
|
-
|
|
15
|
-
## Configuration
|
|
16
|
-
|
|
17
|
-
Define generators in `tailor.config.ts` using `defineGenerators()`:
|
|
18
|
-
|
|
19
|
-
```typescript
|
|
20
|
-
import { defineConfig, defineGenerators } from "@tailor-platform/sdk";
|
|
21
|
-
|
|
22
|
-
export const generators = defineGenerators(
|
|
23
|
-
["@tailor-platform/kysely-type", { distPath: "./generated/tailordb.ts" }],
|
|
24
|
-
["@tailor-platform/enum-constants", { distPath: "./generated/enums.ts" }],
|
|
25
|
-
);
|
|
26
|
-
|
|
27
|
-
export default defineConfig({
|
|
28
|
-
name: "my-app",
|
|
29
|
-
// ...
|
|
30
|
-
});
|
|
31
|
-
```
|
|
32
|
-
|
|
33
|
-
**Important**: The `generators` export must be a named export (not default).
|
|
34
|
-
|
|
35
|
-
## CLI Commands
|
|
36
|
-
|
|
37
|
-
### Generate Files
|
|
38
|
-
|
|
39
|
-
```bash
|
|
40
|
-
tailor-sdk generate
|
|
41
|
-
```
|
|
42
|
-
|
|
43
|
-
Generates all configured output files.
|
|
44
|
-
|
|
45
|
-
### Watch Mode
|
|
46
|
-
|
|
47
|
-
```bash
|
|
48
|
-
tailor-sdk generate --watch
|
|
49
|
-
```
|
|
50
|
-
|
|
51
|
-
Watches for file changes and regenerates automatically.
|
|
52
|
-
|
|
53
|
-
## Environment Variables
|
|
54
|
-
|
|
55
|
-
### `TAILOR_PLATFORM_SDK_DTS_PATH`
|
|
56
|
-
|
|
57
|
-
Customize the output path of the generated `tailor.d.ts` type definition file. By default, `tailor.d.ts` is written next to `tailor.config.ts`.
|
|
58
|
-
|
|
59
|
-
```bash
|
|
60
|
-
TAILOR_PLATFORM_SDK_DTS_PATH=src/types/tailor.d.ts tailor-sdk generate
|
|
61
|
-
```
|
|
62
|
-
|
|
63
|
-
## Generator Types
|
|
64
|
-
|
|
65
|
-
- [Builtin Generators](./builtin.md) - Ready-to-use generators included with the SDK
|
|
66
|
-
- [Custom Generators](./custom.md) - Create your own generators (Preview)
|