primitive-admin 1.0.54 → 1.0.56

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 (110) hide show
  1. package/assets/skill/skills/primitive-platform/SKILL.md +230 -2
  2. package/dist/bin/primitive.js +3 -1
  3. package/dist/bin/primitive.js.map +1 -1
  4. package/dist/src/commands/apps.js +54 -2
  5. package/dist/src/commands/apps.js.map +1 -1
  6. package/dist/src/commands/database-types.js +4 -4
  7. package/dist/src/commands/database-types.js.map +1 -1
  8. package/dist/src/commands/databases.js +35 -14
  9. package/dist/src/commands/databases.js.map +1 -1
  10. package/dist/src/commands/documents.js +77 -0
  11. package/dist/src/commands/documents.js.map +1 -1
  12. package/dist/src/commands/guides.d.ts +15 -12
  13. package/dist/src/commands/guides.js +22 -15
  14. package/dist/src/commands/guides.js.map +1 -1
  15. package/dist/src/commands/metadata.js +48 -3
  16. package/dist/src/commands/metadata.js.map +1 -1
  17. package/dist/src/commands/scripts.d.ts +18 -0
  18. package/dist/src/commands/scripts.js +59 -5
  19. package/dist/src/commands/scripts.js.map +1 -1
  20. package/dist/src/commands/settings.d.ts +15 -0
  21. package/dist/src/commands/settings.js +102 -0
  22. package/dist/src/commands/settings.js.map +1 -0
  23. package/dist/src/commands/sync-app-settings.d.ts +115 -0
  24. package/dist/src/commands/sync-app-settings.js +379 -0
  25. package/dist/src/commands/sync-app-settings.js.map +1 -0
  26. package/dist/src/commands/sync.d.ts +134 -19
  27. package/dist/src/commands/sync.js +1949 -600
  28. package/dist/src/commands/sync.js.map +1 -1
  29. package/dist/src/commands/workflows.js +54 -15
  30. package/dist/src/commands/workflows.js.map +1 -1
  31. package/dist/src/lib/api-client.d.ts +29 -1
  32. package/dist/src/lib/api-client.js +31 -2
  33. package/dist/src/lib/api-client.js.map +1 -1
  34. package/dist/src/lib/app-settings-descriptor.d.ts +108 -0
  35. package/dist/src/lib/app-settings-descriptor.js +254 -0
  36. package/dist/src/lib/app-settings-descriptor.js.map +1 -0
  37. package/dist/src/lib/codegen-shared/generatedFiles.d.ts +36 -0
  38. package/dist/src/lib/codegen-shared/generatedFiles.js +67 -10
  39. package/dist/src/lib/codegen-shared/generatedFiles.js.map +1 -1
  40. package/dist/src/lib/codegen-shared/prettierStable.d.ts +262 -0
  41. package/dist/src/lib/codegen-shared/prettierStable.js +610 -0
  42. package/dist/src/lib/codegen-shared/prettierStable.js.map +1 -0
  43. package/dist/src/lib/db-codegen/dbGenerator.d.ts +11 -83
  44. package/dist/src/lib/db-codegen/dbGenerator.js +96 -556
  45. package/dist/src/lib/db-codegen/dbGenerator.js.map +1 -1
  46. package/dist/src/lib/db-codegen/dbNaming.d.ts +20 -7
  47. package/dist/src/lib/db-codegen/dbNaming.js +31 -13
  48. package/dist/src/lib/db-codegen/dbNaming.js.map +1 -1
  49. package/dist/src/lib/db-codegen/dbTemplates.d.ts +70 -4
  50. package/dist/src/lib/db-codegen/dbTemplates.js +244 -70
  51. package/dist/src/lib/db-codegen/dbTemplates.js.map +1 -1
  52. package/dist/src/lib/db-codegen/dbTsTypes.d.ts +13 -22
  53. package/dist/src/lib/db-codegen/dbTsTypes.js +33 -28
  54. package/dist/src/lib/db-codegen/dbTsTypes.js.map +1 -1
  55. package/dist/src/lib/db-codegen/dbTypeIR.d.ts +146 -0
  56. package/dist/src/lib/db-codegen/dbTypeIR.js +517 -0
  57. package/dist/src/lib/db-codegen/dbTypeIR.js.map +1 -0
  58. package/dist/src/lib/db-codegen/generated-operation-def-descriptor.d.ts +112 -0
  59. package/dist/src/lib/db-codegen/generated-operation-def-descriptor.js +211 -0
  60. package/dist/src/lib/db-codegen/generated-operation-def-descriptor.js.map +1 -0
  61. package/dist/src/lib/generated-allowlist.js +7 -0
  62. package/dist/src/lib/generated-allowlist.js.map +1 -1
  63. package/dist/src/lib/platform-owned.d.ts +37 -0
  64. package/dist/src/lib/platform-owned.js +46 -0
  65. package/dist/src/lib/platform-owned.js.map +1 -0
  66. package/dist/src/lib/swift-codegen/dbGenerator.d.ts +100 -0
  67. package/dist/src/lib/swift-codegen/dbGenerator.js +682 -0
  68. package/dist/src/lib/swift-codegen/dbGenerator.js.map +1 -0
  69. package/dist/src/lib/swift-codegen/dbSwiftTypes.d.ts +42 -0
  70. package/dist/src/lib/swift-codegen/dbSwiftTypes.js +100 -0
  71. package/dist/src/lib/swift-codegen/dbSwiftTypes.js.map +1 -0
  72. package/dist/src/lib/swift-codegen/generator.d.ts +85 -0
  73. package/dist/src/lib/swift-codegen/generator.js +266 -0
  74. package/dist/src/lib/swift-codegen/generator.js.map +1 -0
  75. package/dist/src/lib/swift-codegen/schemaToSwift.d.ts +72 -0
  76. package/dist/src/lib/swift-codegen/schemaToSwift.js +644 -0
  77. package/dist/src/lib/swift-codegen/schemaToSwift.js.map +1 -0
  78. package/dist/src/lib/swift-codegen/siblingSymbols.d.ts +90 -0
  79. package/dist/src/lib/swift-codegen/siblingSymbols.js +152 -0
  80. package/dist/src/lib/swift-codegen/siblingSymbols.js.map +1 -0
  81. package/dist/src/lib/swift-codegen/swiftNaming.d.ts +85 -0
  82. package/dist/src/lib/swift-codegen/swiftNaming.js +198 -0
  83. package/dist/src/lib/swift-codegen/swiftNaming.js.map +1 -0
  84. package/dist/src/lib/sync-resource-types.d.ts +437 -0
  85. package/dist/src/lib/sync-resource-types.js +781 -0
  86. package/dist/src/lib/sync-resource-types.js.map +1 -0
  87. package/dist/src/lib/template.d.ts +1 -1
  88. package/dist/src/lib/template.js +6 -3
  89. package/dist/src/lib/template.js.map +1 -1
  90. package/dist/src/lib/toml-metadata-config.js +18 -0
  91. package/dist/src/lib/toml-metadata-config.js.map +1 -1
  92. package/dist/src/lib/workflow-apply.js +12 -2
  93. package/dist/src/lib/workflow-apply.js.map +1 -1
  94. package/dist/src/lib/workflow-codegen/generator.d.ts +27 -5
  95. package/dist/src/lib/workflow-codegen/generator.js +214 -68
  96. package/dist/src/lib/workflow-codegen/generator.js.map +1 -1
  97. package/dist/src/lib/workflow-codegen/invokerIR.d.ts +83 -0
  98. package/dist/src/lib/workflow-codegen/invokerIR.js +71 -0
  99. package/dist/src/lib/workflow-codegen/invokerIR.js.map +1 -0
  100. package/dist/src/lib/workflow-codegen/schemaToTs.d.ts +17 -1
  101. package/dist/src/lib/workflow-codegen/schemaToTs.js +59 -38
  102. package/dist/src/lib/workflow-codegen/schemaToTs.js.map +1 -1
  103. package/dist/src/lib/workflow-payload.d.ts +19 -0
  104. package/dist/src/lib/workflow-payload.js +21 -0
  105. package/dist/src/lib/workflow-payload.js.map +1 -1
  106. package/dist/src/lib/workflow-toml-validator.d.ts +30 -0
  107. package/dist/src/lib/workflow-toml-validator.js +206 -0
  108. package/dist/src/lib/workflow-toml-validator.js.map +1 -1
  109. package/dist/src/types/index.d.ts +1 -0
  110. package/package.json +5 -2
@@ -1,6 +1,15 @@
1
1
  /**
2
2
  * Pure string templates for the `databases codegen` generator (issue #814).
3
3
  *
4
+ * FORMATTING CONTRACT (#1565): the emitted TypeScript must be a fixed point of
5
+ * Prettier's DEFAULT config — `prettier --write` over a generated file must
6
+ * leave it byte-for-byte unchanged, because `--check` byte-compares. There is
7
+ * no Prettier dependency and no automated round-trip test to catch a
8
+ * regression, so any edit here that changes line shapes must be verified by
9
+ * hand (regenerate a representative output, run Prettier over it, confirm no
10
+ * diff). Wrap long constructs through `codegen-shared/prettierStable.ts` rather
11
+ * than hand-joining strings — see that file's header for the full contract.
12
+ *
4
13
  * Mirrors the codegen-v2 template style
5
14
  * (`packages/js-bao/src/cli/v2/templates.ts`): total functions (no I/O, no
6
15
  * hidden state), an auto-generated banner + fingerprint header, and
@@ -18,7 +27,8 @@
18
27
  * resolves those into the small descriptors below; the templates stay pure
19
28
  * string-emitters.
20
29
  */
21
- import { tsTypeForDbField, tsTypeForDbParamType } from "./dbTsTypes.js";
30
+ import { typeNodeForDbField, typeNodeForDbParamType } from "./dbTsTypes.js";
31
+ import { atom, generic, recordOf, renderArrowProperty, renderMember, renderParenList, renderTypeAlias, tsStringLiteral, union, } from "../codegen-shared/prettierStable.js";
22
32
  const HEADER_BANNER = "// AUTO-GENERATED FROM database-types TOML — DO NOT EDIT.";
23
33
  const REGEN_INSTRUCTION = "// Run `primitive databases codegen <database-type>` to regenerate.";
24
34
  /**
@@ -107,8 +117,7 @@ export function renderRecordInterface(input) {
107
117
  const declared = new Set();
108
118
  for (const f of fields) {
109
119
  declared.add(f.name);
110
- const optional = f.required ? "" : "?";
111
- memberLines.push(` ${f.name}${optional}: ${tsTypeForDbField(f.type, f.enum)};`);
120
+ memberLines.push(renderMember(1, f.name, !f.required, typeNodeForDbField(f.type, f.enum)));
112
121
  }
113
122
  // Server-stamped fields appear on the read interface as optional —
114
123
  // the runtime populates them, but a freshly-built object may not have
@@ -129,7 +138,7 @@ export function renderRecordInterface(input) {
129
138
  // (Contrast with the no-param-op case in `renderOpParamsInterface`, where
130
139
  // `Record<string, never>` is correct: it means "no params allowed".)
131
140
  if (memberLines.length === 0) {
132
- return `export type ${interfaceName} = Record<string, unknown>;`;
141
+ return renderTypeAlias(interfaceName, recordOf("unknown"));
133
142
  }
134
143
  const lines = [];
135
144
  lines.push(`export interface ${interfaceName} {`);
@@ -149,13 +158,12 @@ export function renderOpParamsInterface(input) {
149
158
  // render a `Record<string, never>` type alias instead — it types "no
150
159
  // params allowed" and stays call-site compatible (`op({})`).
151
160
  if (params.length === 0) {
152
- return `export type ${interfaceName} = Record<string, never>;`;
161
+ return renderTypeAlias(interfaceName, recordOf("never"));
153
162
  }
154
163
  const lines = [];
155
164
  lines.push(`export interface ${interfaceName} {`);
156
165
  for (const p of params) {
157
- const optional = p.required ? "" : "?";
158
- lines.push(` ${p.name}${optional}: ${tsTypeForDbParamType(p.type, p.enum, p.items)};`);
166
+ lines.push(renderMember(1, p.name, !p.required, typeNodeForDbParamType(p.type, p.enum, p.items)));
159
167
  }
160
168
  lines.push(`}`);
161
169
  return lines.join("\n");
@@ -171,24 +179,37 @@ export function renderOpParamsInterface(input) {
171
179
  */
172
180
  function queryResultGeneric(recordInterfaceName, projection) {
173
181
  if (recordInterfaceName === null)
174
- return "Record<string, unknown>";
182
+ return recordOf("unknown");
183
+ const record = atom(recordInterfaceName);
175
184
  const p = projection ?? { kind: "full" };
176
185
  switch (p.kind) {
177
186
  case "full":
178
- return recordInterfaceName;
187
+ return record;
179
188
  case "partial":
180
- return `Partial<${recordInterfaceName}>`;
189
+ return generic("Partial", [record]);
181
190
  case "pick": {
182
191
  // The generator guarantees a non-empty, field-guarded, sorted list; a
183
192
  // defensive empty check keeps this total. Field names are emitted as TS
184
193
  // string literals via JSON.stringify.
185
194
  if (p.fields.length === 0)
186
- return recordInterfaceName;
187
- const members = p.fields.map((f) => JSON.stringify(f)).join(" | ");
188
- return `Pick<${recordInterfaceName}, ${members}>`;
195
+ return record;
196
+ return generic("Pick", [record, fieldNameUnion(p.fields)]);
197
+ }
198
+ case "omit": {
199
+ // Static all-exclusion over known members (id/type already filtered out by
200
+ // the generator). The classifier guarantees a non-empty, sorted, member-
201
+ // guarded list; the defensive empty check keeps this total. Same literal
202
+ // emission style as `pick`.
203
+ if (p.fields.length === 0)
204
+ return record;
205
+ return generic("Omit", [record, fieldNameUnion(p.fields)]);
189
206
  }
190
207
  }
191
208
  }
209
+ /** A `Pick`/`Omit` key union (`"a" | "b"`), wrappable when it gets long. */
210
+ export function fieldNameUnion(fields) {
211
+ return union(fields.map((f) => atom(JSON.stringify(f))));
212
+ }
192
213
  /**
193
214
  * Render a per-op result alias. The alias is derived from `op.type` and, where
194
215
  * the shape is derivable from the parsed op definition, a narrowed form:
@@ -200,107 +221,260 @@ function queryResultGeneric(recordInterfaceName, projection) {
200
221
  */
201
222
  export function renderOpResultAlias(input) {
202
223
  const { aliasName, opType, recordInterfaceName, projection } = input;
224
+ const alias = (node) => renderTypeAlias(aliasName, node);
203
225
  switch (opType) {
204
226
  case "query":
205
- return `export type ${aliasName} = QueryResult<${queryResultGeneric(recordInterfaceName, projection)}>;`;
227
+ return alias(generic("QueryResult", [
228
+ queryResultGeneric(recordInterfaceName, projection),
229
+ ]));
206
230
  case "mutation":
207
231
  // Every mutation op returns the uniform `{ results: MutationStepResult[] }`
208
232
  // in definition-step order (#1458) — no more per-category flat shapes.
209
- return `export type ${aliasName} = MutationResult;`;
233
+ return alias(atom("MutationResult"));
210
234
  case "count":
211
- return `export type ${aliasName} = CountResult;`;
235
+ return alias(atom("CountResult"));
212
236
  case "aggregate":
213
- return `export type ${aliasName} = AggregateResult;`;
237
+ return alias(atom("AggregateResult"));
214
238
  case "applyToQuery":
215
- return `export type ${aliasName} = ApplyToQueryResult;`;
239
+ return alias(atom("ApplyToQueryResult"));
216
240
  case "pipeline": {
217
241
  const d = input.pipelineReturn ?? { kind: "opaque" };
218
242
  switch (d.kind) {
219
243
  case "query":
220
- return `export type ${aliasName} = QueryResult<${queryResultGeneric(d.recordInterfaceName, d.projection)}>;`;
244
+ return alias(generic("QueryResult", [
245
+ queryResultGeneric(d.recordInterfaceName, d.projection),
246
+ ]));
221
247
  case "count":
222
- return `export type ${aliasName} = CountResult;`;
248
+ return alias(atom("CountResult"));
223
249
  case "aggregate":
224
- return `export type ${aliasName} = AggregateResult;`;
250
+ return alias(atom("AggregateResult"));
225
251
  // `opaque` — `return: "all"`, no `return`, or a step the generator
226
252
  // couldn't resolve — keeps the generic `PipelineResult` (unchanged).
227
253
  case "opaque":
228
254
  default:
229
- return `export type ${aliasName} = PipelineResult;`;
255
+ return alias(atom("PipelineResult"));
230
256
  }
231
257
  }
232
258
  default:
233
259
  // Unknown op type — emit a permissive alias rather than throwing,
234
260
  // so one stray op doesn't block codegen for the whole file.
235
- return `export type ${aliasName} = unknown;`;
261
+ return alias(atom("unknown"));
236
262
  }
237
263
  }
264
+ // The `databases.executeOperation<R>` member on the structural client shape.
265
+ // `object` (not `Record<string, unknown>`) so a strict generated `<Op>Params`
266
+ // interface — which has no index signature — is still assignable here.
267
+ const EXECUTE_OPERATION_MEMBER = [
268
+ " executeOperation<R>(",
269
+ " databaseId: string,",
270
+ " name: string,",
271
+ " options?: {",
272
+ " params?: object;",
273
+ " limit?: number;",
274
+ " cursor?: string;",
275
+ " direction?: 1 | -1;",
276
+ " timing?: boolean;",
277
+ " },",
278
+ " ): Promise<R>;",
279
+ ];
280
+ // The `databases.subscribe<T>` member on the structural client shape
281
+ // (#1544 Phase 2). Mirrors the client's `subscribe<T, P>` closely enough that
282
+ // the real `JsBaoClient` satisfies it structurally; `P` defaults there so the
283
+ // single generic here is compatible.
284
+ const SUBSCRIBE_MEMBER = [
285
+ " subscribe<T>(",
286
+ " databaseId: string,",
287
+ " subscriptionKey: string,",
288
+ " options: SubscribeOptions<T>,",
289
+ " ): () => void;",
290
+ ];
291
+ // Non-param options (pagination + diagnostics) each ops factory method accepts.
292
+ const OPS_CALL_OPTIONS_BLOCK = [
293
+ "// Non-param options (pagination + diagnostics) each factory method accepts",
294
+ "// alongside its params, passed straight through to `executeOperation`.",
295
+ "interface OpsCallOptions {",
296
+ " limit?: number;",
297
+ " cursor?: string;",
298
+ " direction?: 1 | -1;",
299
+ " timing?: boolean;",
300
+ "}",
301
+ ].join("\n");
302
+ // Inlined structural subscribe types (#1544 Phase 2) — import-free mirrors of
303
+ // the client's `DatabaseSubscribeOptions` / `DatabaseChangePayload` /
304
+ // `DatabaseChangeEvent`. `T` is the record type bound to each change; a
305
+ // projected subscription binds `T` to a `Pick<Record, …select>`.
306
+ const SUBSCRIBE_TYPES_BLOCK = [
307
+ "interface SubscribeOptions<T> {",
308
+ " params?: Record<string, any>;",
309
+ " onChange: (event: SubscribeChangePayload<T>) => void;",
310
+ "}",
311
+ "interface SubscribeChangePayload<T> {",
312
+ ' type: "db.change";',
313
+ " databaseId: string;",
314
+ " subscriptionKey: string;",
315
+ " changes: SubscribeChangeEvent<T>[];",
316
+ " timestamp: string;",
317
+ " originConnectionId: string | null;",
318
+ " originUserId: string | null;",
319
+ " isOrigin: boolean;",
320
+ " isOriginUser: boolean;",
321
+ "}",
322
+ "interface SubscribeChangeEvent<T> {",
323
+ ' changeType?: "enter" | "update" | "leave";',
324
+ ' op: "save" | "patch" | "delete" | "increment" | "addToSet" | "removeFromSet";',
325
+ " modelName: string;",
326
+ " id: string;",
327
+ " data?: T | null;",
328
+ " previousData?: T | null;",
329
+ "}",
330
+ ].join("\n");
238
331
  /**
239
- * Render the typed-operations factory (#1441): an inlined structural client
240
- * interface + a shared call-options type + the `export function <type>Ops`
241
- * factory. Each method pairs an op's `<Op>Params` input with its `<Op>Result`
242
- * output and calls `client.databases.executeOperation<<Op>Result>(...)`, so the
243
- * generated code carries no `as` cast and no import — the real `JsBaoClient`
244
- * satisfies the structural `OpsClient` param.
245
- *
246
- * Returns "" for a database type with no operations, so the caller can omit the
247
- * factory entirely rather than emit an empty function.
332
+ * The inlined structural client shape, carrying whichever members the file
333
+ * needs (`executeOperation` for ops, `subscribe` for subscriptions). One shared
334
+ * `OpsClient` interface serves both the `<type>Ops` and `<type>Subscriptions`
335
+ * factories so the file never declares the interface twice.
248
336
  */
249
- export function renderOpsFactory(input) {
250
- const { factoryName, databaseType, ops } = input;
251
- if (ops.length === 0)
252
- return "";
253
- const clientInterface = [
337
+ function renderClientInterface(members) {
338
+ return [
254
339
  "// Minimal structural client shape — inlined so this file stays import-free",
255
340
  "// and carries no runtime dependency on the client package. The real",
256
341
  "// `JsBaoClient` satisfies it structurally.",
257
342
  "interface OpsClient {",
258
343
  " databases: {",
259
- " executeOperation<R>(",
260
- " databaseId: string,",
261
- " name: string,",
262
- " options?: {",
263
- // `object` (not `Record<string, unknown>`) so a strict generated `<Op>Params`
264
- // interface — which has no index signature — is still assignable here.
265
- " params?: object;",
266
- " limit?: number;",
267
- " cursor?: string;",
268
- " direction?: 1 | -1;",
269
- " timing?: boolean;",
270
- " },",
271
- " ): Promise<R>;",
344
+ ...members,
272
345
  " };",
273
346
  "}",
274
347
  ].join("\n");
275
- const optionsType = [
276
- "// Non-param options (pagination + diagnostics) each factory method accepts",
277
- "// alongside its params, passed straight through to `executeOperation`.",
278
- "interface OpsCallOptions {",
279
- " limit?: number;",
280
- " cursor?: string;",
281
- " direction?: 1 | -1;",
282
- " timing?: boolean;",
283
- "}",
284
- ].join("\n");
285
- const methodLines = ops.map((op) => {
348
+ }
349
+ /** One factory method per op, pairing `<Op>Params` in with `<Op>Result` out. */
350
+ function opsMethodLines(ops) {
351
+ return ops.map((op) => {
286
352
  const nameLiteral = JSON.stringify(op.opName);
287
- if (op.hasParams) {
288
- return (` ${op.propertyKey}: (params: ${op.paramsInterfaceName}, options?: OpsCallOptions): Promise<${op.resultAliasName}> =>\n` +
289
- ` client.databases.executeOperation<${op.resultAliasName}>(databaseId, ${nameLiteral}, { params, ...options }),`);
290
- }
291
353
  // No declared params: the method takes only the optional options object, so
292
354
  // it stays callable with no arguments (`ops.foo()`).
293
- return (` ${op.propertyKey}: (options?: OpsCallOptions): Promise<${op.resultAliasName}> =>\n` +
294
- ` client.databases.executeOperation<${op.resultAliasName}>(databaseId, ${nameLiteral}, { ...options }),`);
355
+ const params = op.hasParams
356
+ ? [`params: ${op.paramsInterfaceName}`, "options?: OpsCallOptions"]
357
+ : ["options?: OpsCallOptions"];
358
+ return renderArrowProperty({
359
+ level: 2,
360
+ key: op.propertyKey,
361
+ params,
362
+ signatureTail: `: Promise<${op.resultAliasName}> =>`,
363
+ callee: generic("client.databases.executeOperation", [
364
+ atom(op.resultAliasName),
365
+ ]),
366
+ leadingArgs: ["databaseId", nameLiteral],
367
+ objectMembers: op.hasParams ? ["params", "...options"] : ["...options"],
368
+ tail: ",",
369
+ });
295
370
  });
296
- const factory = [
371
+ }
372
+ /** The `export function <type>Ops(...)` factory body. */
373
+ function opsFactoryBlock(factoryName, databaseType, ops) {
374
+ return [
297
375
  `/** Typed accessor for \`${databaseType}\` operations. */`,
298
- `export function ${factoryName}(client: OpsClient, databaseId: string) {`,
376
+ renderParenList(`export function ${factoryName}`, ["client: OpsClient", "databaseId: string"], " {", 0),
377
+ " return {",
378
+ ...opsMethodLines(ops),
379
+ " };",
380
+ "}",
381
+ ].join("\n");
382
+ }
383
+ /**
384
+ * Render the typed-operations factory (#1441): an inlined structural client
385
+ * interface + a shared call-options type + the `export function <type>Ops`
386
+ * factory. Each method pairs an op's `<Op>Params` input with its `<Op>Result`
387
+ * output and calls `client.databases.executeOperation<<Op>Result>(...)`, so the
388
+ * generated code carries no `as` cast and no import — the real `JsBaoClient`
389
+ * satisfies the structural `OpsClient` param.
390
+ *
391
+ * Returns "" for a database type with no operations, so the caller can omit the
392
+ * factory entirely rather than emit an empty function.
393
+ */
394
+ export function renderOpsFactory(input) {
395
+ const { factoryName, databaseType, ops } = input;
396
+ if (ops.length === 0)
397
+ return "";
398
+ return [
399
+ renderClientInterface(EXECUTE_OPERATION_MEMBER),
400
+ OPS_CALL_OPTIONS_BLOCK,
401
+ opsFactoryBlock(factoryName, databaseType, ops),
402
+ ].join("\n\n");
403
+ }
404
+ /**
405
+ * The `export function <type>Subscriptions(...)` factory body.
406
+ *
407
+ * Each method is a `key: (options) => client.databases.subscribe<T>(...)` arrow
408
+ * routed through `renderArrowProperty` (#1678), so its signature and the
409
+ * `subscribe(...)` call are a fixed point of Prettier's default config at every
410
+ * subscription-key length. The `subscribe` call carries NO trailing object-
411
+ * literal argument (`objectMembers` omitted); `eventType` is a `TypeNode`, so a
412
+ * `Pick<...>` projection breaks inside `SubscribeOptions<...>` / the type
413
+ * argument the way Prettier breaks it. The subscription key literal uses
414
+ * `tsStringLiteral` (Prettier's fewer-escapes quote choice), not
415
+ * `JSON.stringify`.
416
+ */
417
+ function subscriptionsFactoryBlock(factoryName, databaseType, subscriptions) {
418
+ const methodLines = subscriptions.map((sub) => renderArrowProperty({
419
+ level: 2,
420
+ key: sub.propertyKey,
421
+ params: [{ name: "options", type: generic("SubscribeOptions", [sub.eventType]) }],
422
+ signatureTail: ": (() => void) =>",
423
+ callee: generic("client.databases.subscribe", [sub.eventType]),
424
+ leadingArgs: [
425
+ "databaseId",
426
+ tsStringLiteral(sub.subscriptionKey),
427
+ "options",
428
+ ],
429
+ tail: ",",
430
+ }));
431
+ return [
432
+ `/** Typed accessor for \`${databaseType}\` realtime subscriptions. */`,
433
+ renderParenList(`export function ${factoryName}`, ["client: OpsClient", "databaseId: string"], " {", 0),
299
434
  " return {",
300
435
  ...methodLines,
301
436
  " };",
302
437
  "}",
303
438
  ].join("\n");
304
- return [clientInterface, optionsType, factory].join("\n\n");
439
+ }
440
+ /**
441
+ * Render the typed-ops factory (#1441) and the typed-subscriptions factory
442
+ * (#1544 Phase 2) for one database type, sharing a single structural `OpsClient`
443
+ * interface (Fork 4 = A).
444
+ *
445
+ * With no subscriptions this is byte-identical to {@link renderOpsFactory}, so
446
+ * every existing generated file (none of which has subscriptions) is unchanged.
447
+ * When subscriptions exist, the shared `OpsClient` gains a `subscribe<T>`
448
+ * member, the inlined subscribe types are emitted once, and a separate
449
+ * `<type>Subscriptions` factory follows the ops factory. The file stays
450
+ * import-free (behavior 10).
451
+ *
452
+ * Returns "" when the type has neither ops nor subscriptions.
453
+ */
454
+ export function renderFactories(input) {
455
+ const { databaseType, ops, subscriptions } = input;
456
+ // No subscriptions → identical to the standalone ops factory (keeps every
457
+ // pre-#1544 generated file byte-for-byte unchanged).
458
+ if (subscriptions.length === 0) {
459
+ return renderOpsFactory({
460
+ factoryName: input.opsFactoryName,
461
+ databaseType,
462
+ ops,
463
+ });
464
+ }
465
+ const hasOps = ops.length > 0;
466
+ const members = [
467
+ ...(hasOps ? EXECUTE_OPERATION_MEMBER : []),
468
+ ...SUBSCRIBE_MEMBER,
469
+ ];
470
+ const blocks = [renderClientInterface(members)];
471
+ if (hasOps)
472
+ blocks.push(OPS_CALL_OPTIONS_BLOCK);
473
+ blocks.push(SUBSCRIBE_TYPES_BLOCK);
474
+ if (hasOps) {
475
+ blocks.push(opsFactoryBlock(input.opsFactoryName, databaseType, ops));
476
+ }
477
+ blocks.push(subscriptionsFactoryBlock(input.subscriptionsFactoryName, databaseType, subscriptions));
478
+ return blocks.join("\n\n");
305
479
  }
306
480
  //# sourceMappingURL=dbTemplates.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"dbTemplates.js","sourceRoot":"","sources":["../../../../src/lib/db-codegen/dbTemplates.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AAEH,OAAO,EAAE,gBAAgB,EAAE,oBAAoB,EAAE,MAAM,gBAAgB,CAAC;AAExE,MAAM,aAAa,GACjB,2DAA2D,CAAC;AAC9D,MAAM,iBAAiB,GACrB,qEAAqE,CAAC;AAgHxE;;;;;GAKG;AACH,MAAM,CAAC,MAAM,oBAAoB,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA0DnC,CAAC;AAEF;;GAEG;AACH,MAAM,UAAU,YAAY,CAAC,WAAmB;IAC9C,OAAO;QACL,aAAa;QACb,iBAAiB;QACjB,mBAAmB,WAAW,EAAE;KACjC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;AACf,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,qBAAqB,CACnC,KAAiC;IAEjC,MAAM,EAAE,aAAa,EAAE,MAAM,EAAE,aAAa,EAAE,GAAG,KAAK,CAAC;IACvD,MAAM,WAAW,GAAa,EAAE,CAAC;IAEjC,MAAM,QAAQ,GAAG,IAAI,GAAG,EAAU,CAAC;IACnC,KAAK,MAAM,CAAC,IAAI,MAAM,EAAE,CAAC;QACvB,QAAQ,CAAC,GAAG,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC;QACrB,MAAM,QAAQ,GAAG,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,GAAG,CAAC;QACvC,WAAW,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,IAAI,GAAG,QAAQ,KAAK,gBAAgB,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;IACnF,CAAC;IAED,mEAAmE;IACnE,sE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AAG;SACJ,CAAC,CAAC;IACL,CAAC;IAED,MAAM,MAAM,GAAG,GAAG,CAAC,MAAM,GAAG,CAAC,CAAC;IAC9B,MAAM,OAAO,GAAG;QACd,GAAG,CAAC,MAAM,CAAC,CAAC,CAAC,wBAAwB,CAAC,CAAC,CAAC,EAAE,CAAC;QAC3C,GAAG,gBAAgB;KACpB,CAAC;IAEF,MAAM,MAAM,GAAa,CAAC,qBAAqB,CAAC,OAAO,CAAC,CAAC,CAAC;IAC1D,IAAI,MAAM;QAAE,MAAM,CAAC,IAAI,CAAC,sBAAsB,CAAC,CAAC;IAChD,MAAM,CAAC,IAAI,CAAC,qBAAqB,CAAC,CAAC;IACnC,IAAI,MAAM,EAAE,CAAC;QACX,MAAM,CAAC,IAAI,CAAC,eAAe,CAAC,KAAK,CAAC,cAAc,EAAE,YAAY,EAAE,GAAG,CAAC,CAAC,CAAC;IACxE,CAAC;IACD,MAAM,CAAC,IAAI,CACT,yBAAyB,CACvB,KAAK,CAAC,wBAAwB,EAC9B,YAAY,EACZ,aAAa,CACd,CACF,CAAC;IAEF,OAAO,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;AAC7B,CAAC"}
@@ -25,6 +25,7 @@
25
25
  * pass consumed by BOTH the scaffold (#845, field *type*) and codegen (#842,
26
26
  * field *required-ness*). Lift it rather than re-walking the ops here.
27
27
  */
28
+ import { type TypeNode } from "../codegen-shared/prettierStable.js";
28
29
  /**
29
30
  * Field types accepted in a database-type `[models.*]` schema. Mirrors
30
31
  * `FieldType` in `packages/js-bao/src/types/ormTypes.ts`. Declared locally
@@ -48,30 +49,20 @@ export type DbParamType = "string" | "number" | "boolean" | "integer" | "object"
48
49
  */
49
50
  export declare function tsTypeForDbFieldType(fieldType: string): string;
50
51
  /**
51
- * Render a TypeScript string-literal union from an `enum` allowed-value set
52
- * (e.g. `["a", "b"]` `"a" | "b"`). Each value is emitted via
53
- * `JSON.stringify` so quotes, backslashes, and other special characters are
54
- * properly escaped into a valid TS string literal.
55
- *
56
- * Shared enum vocabulary with the doc-model v2 codegen
57
- * (`packages/js-bao/src/cli/v2/tsTypes.ts`). The `enum` array is validated
58
- * upstream by the TOML loader (`parseFieldOptions`): non-empty, all-string,
59
- * string-field-only. This renderer assumes that contract has held.
60
- */
61
- export declare function tsUnionFromEnum(values: string[]): string;
62
- /**
63
- * Returns the TS type expression for a record field, honoring an optional
64
- * string `enum` allowed-value set (#843). A non-empty `enum` on a `string`
65
- * field renders a string-literal union; otherwise falls back to the base
52
+ * Returns the TS type expression for a record field as a wrappable node,
53
+ * honoring an optional string `enum` allowed-value set (#843). A non-empty
54
+ * `enum` on a `string` field renders a string-literal union (a long one in
55
+ * Prettier's leading-pipe form, #1565); otherwise falls back to the base
66
56
  * `tsTypeForDbFieldType` mapping.
67
57
  */
68
- export declare function tsTypeForDbField(fieldType: string, enumValues?: string[]): string;
58
+ export declare function typeNodeForDbField(fieldType: string, enumValues?: string[]): TypeNode;
69
59
  /**
70
- * Returns the TS type expression for an op param, honoring an optional string
71
- * `enum` allowed-value set (#861). A non-empty `enum` on a `string` param
72
- * renders a string-literal union (`"a" | "b"`); otherwise falls back to the
73
- * base param-type mapping below. Mirrors `tsTypeForDbField` (the record-field
74
- * sibling) and reuses `tsUnionFromEnum` for a single escaping implementation.
60
+ * Returns the TS type expression for an op param as a wrappable node, honoring
61
+ * an optional string `enum` allowed-value set (#861). A non-empty `enum` on a
62
+ * `string` param renders a string-literal union (`"a" | "b"`; a long one in
63
+ * Prettier's leading-pipe form, #1565); otherwise falls back to the base
64
+ * param-type mapping below. Mirrors `typeNodeForDbField` (the record-field
65
+ * sibling) and reuses `unionNodeFromEnum` for a single escaping implementation.
75
66
  *
76
67
  * Unlike the record-field path (validated upstream by `parseFieldOptions`,
77
68
  * which throws), op-param enum *shape* is validated server-side in
@@ -79,4 +70,4 @@ export declare function tsTypeForDbField(fieldType: string, enumValues?: string[
79
70
  * the base type for a non-string param or an empty enum rather than throwing —
80
71
  * the server is the source of truth for rejecting a malformed param `enum`.
81
72
  */
82
- export declare function tsTypeForDbParamType(paramType: string, enumValues?: string[], items?: string): string;
73
+ export declare function typeNodeForDbParamType(paramType: string, enumValues?: string[], items?: string): TypeNode;