@tailor-platform/sdk 1.66.1 → 2.0.0-next.1

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.
Files changed (198) hide show
  1. package/CHANGELOG.md +89 -2
  2. package/dist/application-DB2r36Et.mjs +3 -0
  3. package/dist/{application-DGDmL8i_.mjs → application-DqS1yBg3.mjs} +188 -128
  4. package/dist/application-DqS1yBg3.mjs.map +1 -0
  5. package/dist/{assert-CKfwrmCV.mjs → assert-DBxo8jPo.mjs} +1 -2
  6. package/dist/{assert-CKfwrmCV.mjs.map → assert-DBxo8jPo.mjs.map} +1 -1
  7. package/dist/{authconnection-D8SJGMpj.mjs → authconnection-D2MhtTN5.mjs} +2 -3
  8. package/dist/{authconnection-D8SJGMpj.mjs.map → authconnection-D2MhtTN5.mjs.map} +1 -1
  9. package/dist/{authconnection-BIYzEh2p.d.mts → authconnection-DvUQAjQS.d.mts} +1 -1
  10. package/dist/{brand-DlnJ375c.mjs → brand-Eo4pLXPJ.mjs} +1 -2
  11. package/dist/{brand-DlnJ375c.mjs.map → brand-Eo4pLXPJ.mjs.map} +1 -1
  12. package/dist/cli/index.mjs +78 -131
  13. package/dist/cli/index.mjs.map +1 -1
  14. package/dist/cli/lib.d.mts +15 -154
  15. package/dist/cli/lib.mjs +9 -10
  16. package/dist/cli/lib.mjs.map +1 -1
  17. package/dist/{client-boxXYevx.mjs → client-Dbohmtkv.mjs} +1 -2
  18. package/dist/{client-F0a4cWUM.mjs → client-z_oHGVNy.mjs} +8 -6
  19. package/dist/client-z_oHGVNy.mjs.map +1 -0
  20. package/dist/completion/zsh-worker.zsh +5 -19
  21. package/dist/configure/index.d.mts +8 -7
  22. package/dist/configure/index.mjs +11 -28
  23. package/dist/configure/index.mjs.map +1 -1
  24. package/dist/{context-s0lxhu8_.mjs → context-Bd266-ru.mjs} +2 -3
  25. package/dist/{context-s0lxhu8_.mjs.map → context-Bd266-ru.mjs.map} +1 -1
  26. package/dist/{context-CUBwSBq4.d.mts → context-BuuIb8CC.d.mts} +1 -1
  27. package/dist/{crashreport-0EHy-ayY.mjs → crashreport-BsjAkFWw.mjs} +19 -10
  28. package/dist/{crashreport-0EHy-ayY.mjs.map → crashreport-BsjAkFWw.mjs.map} +1 -1
  29. package/dist/{crashreport-Bf6uT6mf.mjs → crashreport-pr6Rhvza.mjs} +1 -2
  30. package/dist/{enum-constants-C7DaWeQo.mjs → enum-constants-j9QBF0cB.mjs} +1 -2
  31. package/dist/enum-constants-j9QBF0cB.mjs.map +1 -0
  32. package/dist/{errors-EsY4XO6O.mjs → errors-Dtf2WPaW.mjs} +1 -2
  33. package/dist/{errors-EsY4XO6O.mjs.map → errors-Dtf2WPaW.mjs.map} +1 -1
  34. package/dist/{field-C4zdJLW5.mjs → field-DOsJCPFa.mjs} +1 -2
  35. package/dist/field-DOsJCPFa.mjs.map +1 -0
  36. package/dist/{file-BzK8z3X-.d.mts → file-BB8Vs9O_.d.mts} +1 -1
  37. package/dist/{file-B58Dm-2P.mjs → file-_oUZo76X.mjs} +2 -3
  38. package/dist/{file-B58Dm-2P.mjs.map → file-_oUZo76X.mjs.map} +1 -1
  39. package/dist/{file-utils-BHPxPXmn.mjs → file-utils-DcyIPFQh.mjs} +2 -3
  40. package/dist/{file-utils-BHPxPXmn.mjs.map → file-utils-DcyIPFQh.mjs.map} +1 -1
  41. package/dist/{globals-ByrCoDip.mjs → globals-Crz8o65k.mjs} +53 -5
  42. package/dist/globals-Crz8o65k.mjs.map +1 -0
  43. package/dist/http-adapter.generated-WgMnb7Sb.d.mts +580 -0
  44. package/dist/{iconv-kwrmd1U_.d.mts → iconv-Co-TOPuH.d.mts} +1 -1
  45. package/dist/{iconv-DreIffeM.mjs → iconv-D2vi8G36.mjs} +2 -3
  46. package/dist/{iconv-DreIffeM.mjs.map → iconv-D2vi8G36.mjs.map} +1 -1
  47. package/dist/{idp-Ch95ag8h.mjs → idp-BDbK5gjm.mjs} +2 -3
  48. package/dist/{idp-Ch95ag8h.mjs.map → idp-BDbK5gjm.mjs.map} +1 -1
  49. package/dist/{idp-BlBPtXJ-.d.mts → idp-DrhVrLmV.d.mts} +1 -1
  50. package/dist/{index-QpC0TNbH.d.mts → index-5vPyRu1y.d.mts} +2 -2
  51. package/dist/{index-Bhjep8cS.d.mts → index-B7AKc18V.d.mts} +2 -2
  52. package/dist/{index-BdLqzJDu.d.mts → index-BlpzXncY.d.mts} +25 -247
  53. package/dist/{index-DRhMpdnA.d.mts → index-CK7u9isy.d.mts} +8 -8
  54. package/dist/{index-CZ2r3qiO.d.mts → index-CNYe5lnW.d.mts} +2 -2
  55. package/dist/{index-Db2RvnEH.d.mts → index-DjUdWlzf.d.mts} +2 -2
  56. package/dist/index-ZePLwxw7.d.mts +208 -0
  57. package/dist/{interceptor-DOqRkCya.mjs → interceptor-D-q1rvRl.mjs} +1 -2
  58. package/dist/{interceptor-DOqRkCya.mjs.map → interceptor-D-q1rvRl.mjs.map} +1 -1
  59. package/dist/{job-BpsFXPbi.mjs → job-fuc3j1Ma.mjs} +9 -10
  60. package/dist/job-fuc3j1Ma.mjs.map +1 -0
  61. package/dist/kysely/index.mjs +0 -1
  62. package/dist/kysely/index.mjs.map +1 -1
  63. package/dist/{kysely-type-D1e0Vwkd.mjs → kysely-type-DR8uzZTA.mjs} +2 -3
  64. package/dist/kysely-type-DR8uzZTA.mjs.map +1 -0
  65. package/dist/{logger-DpJyJvNz.mjs → logger-CxF-Ex5d.mjs} +1 -2
  66. package/dist/{logger-DpJyJvNz.mjs.map → logger-CxF-Ex5d.mjs.map} +1 -1
  67. package/dist/{mock-DMgIygjE.mjs → mock-BjFj5o1I.mjs} +9 -11
  68. package/dist/mock-BjFj5o1I.mjs.map +1 -0
  69. package/dist/{multiline-Cf9ODpr1.mjs → multiline-sfHpTZZK.mjs} +1 -2
  70. package/dist/{multiline-Cf9ODpr1.mjs.map → multiline-sfHpTZZK.mjs.map} +1 -1
  71. package/dist/{package-json-DcQApfPQ.mjs → package-json-8b0O9TlX.mjs} +1 -2
  72. package/dist/{package-json-DcQApfPQ.mjs.map → package-json-8b0O9TlX.mjs.map} +1 -1
  73. package/dist/package-json-Cv2Z-TqQ.mjs +3 -0
  74. package/dist/plugin/builtin/enum-constants/index.d.mts +1 -1
  75. package/dist/plugin/builtin/enum-constants/index.mjs +1 -2
  76. package/dist/plugin/builtin/file-utils/index.d.mts +1 -1
  77. package/dist/plugin/builtin/file-utils/index.mjs +1 -2
  78. package/dist/plugin/builtin/kysely-type/index.d.mts +1 -1
  79. package/dist/plugin/builtin/kysely-type/index.mjs +1 -2
  80. package/dist/plugin/builtin/seed/index.d.mts +1 -1
  81. package/dist/plugin/builtin/seed/index.mjs +1 -2
  82. package/dist/plugin/index.d.mts +1 -3
  83. package/dist/plugin/index.mjs +0 -1
  84. package/dist/plugin/index.mjs.map +1 -1
  85. package/dist/registry-DdsYlL_P.mjs +51 -0
  86. package/dist/registry-DdsYlL_P.mjs.map +1 -0
  87. package/dist/{repl-editor-CJG3sz7A.mjs → repl-editor-DmGr9zMw.mjs} +2 -3
  88. package/dist/{repl-editor-CJG3sz7A.mjs.map → repl-editor-DmGr9zMw.mjs.map} +1 -1
  89. package/dist/{chunk-BkoGK1jX.mjs → rolldown-runtime-DXywRVcq.mjs} +0 -1
  90. package/dist/runtime/authconnection.d.mts +1 -1
  91. package/dist/runtime/authconnection.mjs +1 -2
  92. package/dist/runtime/context.d.mts +1 -1
  93. package/dist/runtime/context.mjs +1 -2
  94. package/dist/runtime/file.d.mts +1 -1
  95. package/dist/runtime/file.mjs +1 -2
  96. package/dist/runtime/globals.d.mts +6 -39
  97. package/dist/runtime/globals.mjs +0 -1
  98. package/dist/runtime/iconv.d.mts +1 -1
  99. package/dist/runtime/iconv.mjs +1 -2
  100. package/dist/runtime/idp.d.mts +1 -1
  101. package/dist/runtime/idp.mjs +1 -2
  102. package/dist/runtime/index.d.mts +8 -8
  103. package/dist/runtime/index.mjs +7 -8
  104. package/dist/runtime/secretmanager.d.mts +1 -1
  105. package/dist/runtime/secretmanager.mjs +1 -2
  106. package/dist/runtime/workflow.d.mts +1 -1
  107. package/dist/runtime/workflow.mjs +1 -2
  108. package/dist/{runtime-2nzOZCUb.mjs → runtime-n9NCkjee.mjs} +65 -232
  109. package/dist/runtime-n9NCkjee.mjs.map +1 -0
  110. package/dist/{schema-1msIhXwA.mjs → schema-BhkpP5Hw.mjs} +3 -4
  111. package/dist/schema-BhkpP5Hw.mjs.map +1 -0
  112. package/dist/{secret-file-CWzF8rry.mjs → secret-file-DBqZhjFQ.mjs} +1 -2
  113. package/dist/{secret-file-CWzF8rry.mjs.map → secret-file-DBqZhjFQ.mjs.map} +1 -1
  114. package/dist/{secretmanager-CKLB3wAQ.d.mts → secretmanager-B3n4KHfm.d.mts} +1 -1
  115. package/dist/{secretmanager-B9h-U_8U.mjs → secretmanager-BVxw3ih_.mjs} +2 -3
  116. package/dist/{secretmanager-B9h-U_8U.mjs.map → secretmanager-BVxw3ih_.mjs.map} +1 -1
  117. package/dist/seed/index.mjs +0 -1
  118. package/dist/seed/index.mjs.map +1 -1
  119. package/dist/{seed-BH2FbrPV.mjs → seed-jf3008-h.mjs} +5 -16
  120. package/dist/seed-jf3008-h.mjs.map +1 -0
  121. package/dist/{service-wI3Hvrgx.mjs → service-CCL8ruDf.mjs} +3 -4
  122. package/dist/service-CCL8ruDf.mjs.map +1 -0
  123. package/dist/service-D6yonf2I.mjs +3 -0
  124. package/dist/{service-DMohAx8a2.mjs → service-DU1mVzri.mjs} +3 -4
  125. package/dist/service-DU1mVzri.mjs.map +1 -0
  126. package/dist/{telemetry-BQbbVo2t.mjs → telemetry-CdqJEzkj.mjs} +2 -3
  127. package/dist/{telemetry-BQbbVo2t.mjs.map → telemetry-CdqJEzkj.mjs.map} +1 -1
  128. package/dist/telemetry-ClwW5ohF.mjs +3 -0
  129. package/dist/test-env-key-D9kM6ETE.mjs +49 -0
  130. package/dist/test-env-key-D9kM6ETE.mjs.map +1 -0
  131. package/dist/type-source-DH_LH20p.mjs +13 -0
  132. package/dist/type-source-DH_LH20p.mjs.map +1 -0
  133. package/dist/{types-CmzfQP_m.mjs → types-B2RpYyA_.mjs} +2 -3
  134. package/dist/types-B2RpYyA_.mjs.map +1 -0
  135. package/dist/types-ClhIrW_C.mjs +4 -0
  136. package/dist/{tailordb-C-ar4XCX.d.mts → types-DCUhgpyI.d.mts} +142 -221
  137. package/dist/{plugin-DylAsA4Z.d.mts → types-DhO_VEZd.d.mts} +119 -179
  138. package/dist/types-DwDgacni.d.mts +338 -0
  139. package/dist/utils/test/index.d.mts +4 -3
  140. package/dist/utils/test/index.mjs +1 -2
  141. package/dist/utils/test/index.mjs.map +1 -1
  142. package/dist/vitest/environment.mjs +1 -2
  143. package/dist/vitest/environment.mjs.map +1 -1
  144. package/dist/vitest/index.d.mts +42 -5
  145. package/dist/vitest/index.mjs +133 -4
  146. package/dist/vitest/index.mjs.map +1 -1
  147. package/dist/vitest/setup.mjs +2 -3
  148. package/dist/vitest/setup.mjs.map +1 -1
  149. package/dist/{workflow-CMamswkK.d.mts → workflow-BbKvGLQg.d.mts} +1 -1
  150. package/dist/{workflow--aPbA8Uq.mjs → workflow-DgemCAz3.mjs} +2 -3
  151. package/dist/{workflow--aPbA8Uq.mjs.map → workflow-DgemCAz3.mjs.map} +1 -1
  152. package/dist/workflow.generated-DtQwEo-x.d.mts +671 -0
  153. package/docs/cli/application.md +0 -2
  154. package/docs/cli/crashreport.md +0 -2
  155. package/docs/cli/function.md +1 -1
  156. package/docs/cli/user.md +3 -3
  157. package/docs/cli/workspace.md +3 -3
  158. package/docs/configuration.md +0 -2
  159. package/docs/plugin/custom.md +2 -2
  160. package/docs/plugin/index.md +1 -1
  161. package/docs/runtime.md +3 -3
  162. package/docs/services/auth.md +0 -2
  163. package/docs/services/executor.md +0 -2
  164. package/docs/services/resolver.md +2 -4
  165. package/docs/services/tailordb.md +1 -1
  166. package/docs/services/workflow.md +13 -15
  167. package/docs/testing.md +18 -11
  168. package/package.json +9 -8
  169. package/dist/actor-D_2aJjYO.d.mts +0 -24
  170. package/dist/application-DGDmL8i_.mjs.map +0 -1
  171. package/dist/application-nTydHJm8.mjs +0 -4
  172. package/dist/cli/skills.d.mts +0 -1
  173. package/dist/cli/skills.mjs +0 -22
  174. package/dist/cli/skills.mjs.map +0 -1
  175. package/dist/client-F0a4cWUM.mjs.map +0 -1
  176. package/dist/enum-constants-C7DaWeQo.mjs.map +0 -1
  177. package/dist/env-B-g-qgE4.d.mts +0 -7
  178. package/dist/field-C4zdJLW5.mjs.map +0 -1
  179. package/dist/globals-ByrCoDip.mjs.map +0 -1
  180. package/dist/job-BpsFXPbi.mjs.map +0 -1
  181. package/dist/kysely-type-D1e0Vwkd.mjs.map +0 -1
  182. package/dist/mock-DMgIygjE.mjs.map +0 -1
  183. package/dist/package-json-wzO6nV9O.mjs +0 -4
  184. package/dist/registry-D0uB0OrK.mjs +0 -178
  185. package/dist/registry-D0uB0OrK.mjs.map +0 -1
  186. package/dist/runtime-2nzOZCUb.mjs.map +0 -1
  187. package/dist/schema-1msIhXwA.mjs.map +0 -1
  188. package/dist/seed-BH2FbrPV.mjs.map +0 -1
  189. package/dist/service-BHQIerYh.mjs +0 -4
  190. package/dist/service-DMohAx8a2.mjs.map +0 -1
  191. package/dist/service-wI3Hvrgx.mjs.map +0 -1
  192. package/dist/telemetry-w92bvGdC.mjs +0 -4
  193. package/dist/types-2Be3wSMc.mjs +0 -5
  194. package/dist/types-CmzfQP_m.mjs.map +0 -1
  195. package/dist/workflow.generated--1Qc15Et.d.mts +0 -1471
  196. package/docs/generator/builtin.md +0 -257
  197. package/docs/generator/custom.md +0 -147
  198. 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`.
@@ -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
@@ -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)