primitive-admin 1.0.55 → 1.0.57

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 (92) hide show
  1. package/assets/skill/skills/primitive-platform/SKILL.md +230 -2
  2. package/dist/bin/primitive.js +1 -1
  3. package/dist/src/commands/database-types.js +4 -4
  4. package/dist/src/commands/database-types.js.map +1 -1
  5. package/dist/src/commands/databases.js +5 -5
  6. package/dist/src/commands/databases.js.map +1 -1
  7. package/dist/src/commands/documents.js +2 -2
  8. package/dist/src/commands/documents.js.map +1 -1
  9. package/dist/src/commands/guides.d.ts +15 -12
  10. package/dist/src/commands/guides.js +22 -15
  11. package/dist/src/commands/guides.js.map +1 -1
  12. package/dist/src/commands/metadata.js +48 -3
  13. package/dist/src/commands/metadata.js.map +1 -1
  14. package/dist/src/commands/scripts.d.ts +18 -0
  15. package/dist/src/commands/scripts.js +59 -5
  16. package/dist/src/commands/scripts.js.map +1 -1
  17. package/dist/src/commands/sync-app-settings.d.ts +14 -4
  18. package/dist/src/commands/sync-app-settings.js +48 -8
  19. package/dist/src/commands/sync-app-settings.js.map +1 -1
  20. package/dist/src/commands/sync.d.ts +100 -0
  21. package/dist/src/commands/sync.js +1578 -402
  22. package/dist/src/commands/sync.js.map +1 -1
  23. package/dist/src/commands/workflows.js +23 -6
  24. package/dist/src/commands/workflows.js.map +1 -1
  25. package/dist/src/lib/api-client.d.ts +27 -1
  26. package/dist/src/lib/api-client.js +25 -2
  27. package/dist/src/lib/api-client.js.map +1 -1
  28. package/dist/src/lib/app-settings-descriptor.js +4 -0
  29. package/dist/src/lib/app-settings-descriptor.js.map +1 -1
  30. package/dist/src/lib/codegen-shared/generatedFiles.d.ts +21 -0
  31. package/dist/src/lib/codegen-shared/generatedFiles.js +40 -0
  32. package/dist/src/lib/codegen-shared/generatedFiles.js.map +1 -1
  33. package/dist/src/lib/codegen-shared/prettierStable.d.ts +262 -0
  34. package/dist/src/lib/codegen-shared/prettierStable.js +610 -0
  35. package/dist/src/lib/codegen-shared/prettierStable.js.map +1 -0
  36. package/dist/src/lib/db-codegen/dbGenerator.js +8 -5
  37. package/dist/src/lib/db-codegen/dbGenerator.js.map +1 -1
  38. package/dist/src/lib/db-codegen/dbNaming.d.ts +5 -0
  39. package/dist/src/lib/db-codegen/dbNaming.js +8 -2
  40. package/dist/src/lib/db-codegen/dbNaming.js.map +1 -1
  41. package/dist/src/lib/db-codegen/dbTemplates.d.ts +17 -2
  42. package/dist/src/lib/db-codegen/dbTemplates.js +85 -40
  43. package/dist/src/lib/db-codegen/dbTemplates.js.map +1 -1
  44. package/dist/src/lib/db-codegen/dbTsTypes.d.ts +13 -22
  45. package/dist/src/lib/db-codegen/dbTsTypes.js +33 -28
  46. package/dist/src/lib/db-codegen/dbTsTypes.js.map +1 -1
  47. package/dist/src/lib/db-codegen/generated-operation-def-descriptor.d.ts +11 -0
  48. package/dist/src/lib/db-codegen/generated-operation-def-descriptor.js +11 -0
  49. package/dist/src/lib/db-codegen/generated-operation-def-descriptor.js.map +1 -1
  50. package/dist/src/lib/generated-allowlist.js +7 -0
  51. package/dist/src/lib/generated-allowlist.js.map +1 -1
  52. package/dist/src/lib/platform-owned.d.ts +37 -0
  53. package/dist/src/lib/platform-owned.js +46 -0
  54. package/dist/src/lib/platform-owned.js.map +1 -0
  55. package/dist/src/lib/swift-codegen/dbGenerator.d.ts +32 -0
  56. package/dist/src/lib/swift-codegen/dbGenerator.js +338 -36
  57. package/dist/src/lib/swift-codegen/dbGenerator.js.map +1 -1
  58. package/dist/src/lib/swift-codegen/dbSwiftTypes.d.ts +1 -1
  59. package/dist/src/lib/swift-codegen/dbSwiftTypes.js +1 -1
  60. package/dist/src/lib/swift-codegen/generator.d.ts +1 -0
  61. package/dist/src/lib/swift-codegen/generator.js +91 -3
  62. package/dist/src/lib/swift-codegen/generator.js.map +1 -1
  63. package/dist/src/lib/swift-codegen/siblingSymbols.d.ts +90 -0
  64. package/dist/src/lib/swift-codegen/siblingSymbols.js +152 -0
  65. package/dist/src/lib/swift-codegen/siblingSymbols.js.map +1 -0
  66. package/dist/src/lib/sync-resource-types.d.ts +222 -10
  67. package/dist/src/lib/sync-resource-types.js +407 -20
  68. package/dist/src/lib/sync-resource-types.js.map +1 -1
  69. package/dist/src/lib/template.d.ts +1 -1
  70. package/dist/src/lib/template.js +6 -3
  71. package/dist/src/lib/template.js.map +1 -1
  72. package/dist/src/lib/toml-metadata-config.js +18 -0
  73. package/dist/src/lib/toml-metadata-config.js.map +1 -1
  74. package/dist/src/lib/workflow-apply.js +12 -2
  75. package/dist/src/lib/workflow-apply.js.map +1 -1
  76. package/dist/src/lib/workflow-codegen/generator.d.ts +9 -0
  77. package/dist/src/lib/workflow-codegen/generator.js +126 -55
  78. package/dist/src/lib/workflow-codegen/generator.js.map +1 -1
  79. package/dist/src/lib/workflow-codegen/invokerIR.d.ts +6 -8
  80. package/dist/src/lib/workflow-codegen/invokerIR.js +8 -8
  81. package/dist/src/lib/workflow-codegen/invokerIR.js.map +1 -1
  82. package/dist/src/lib/workflow-codegen/schemaToTs.d.ts +17 -1
  83. package/dist/src/lib/workflow-codegen/schemaToTs.js +59 -38
  84. package/dist/src/lib/workflow-codegen/schemaToTs.js.map +1 -1
  85. package/dist/src/lib/workflow-payload.d.ts +19 -0
  86. package/dist/src/lib/workflow-payload.js +21 -0
  87. package/dist/src/lib/workflow-payload.js.map +1 -1
  88. package/dist/src/lib/workflow-toml-validator.d.ts +30 -0
  89. package/dist/src/lib/workflow-toml-validator.js +206 -0
  90. package/dist/src/lib/workflow-toml-validator.js.map +1 -1
  91. package/dist/src/types/index.d.ts +1 -0
  92. package/package.json +2 -1
@@ -0,0 +1,262 @@
1
+ /**
2
+ * Prettier-default-stable emission helpers for the codegen emitters (#1565).
3
+ *
4
+ * ─────────────────────────── FORMATTING CONTRACT ───────────────────────────
5
+ * Generated `*.generated.ts` output MUST be a fixed point of Prettier's DEFAULT
6
+ * config (printWidth 80, 2-space indent, `trailingComma: "all"`): running
7
+ * `prettier --write` over a freshly generated file must leave it byte-for-byte
8
+ * unchanged.
9
+ *
10
+ * Why it matters: `databases codegen --check` / `workflows codegen --check`
11
+ * compare the emission to what is on disk BYTE-FOR-BYTE
12
+ * (`codegen-shared/generatedFiles.ts`). A consumer whose pipeline runs codegen,
13
+ * then `prettier --write`, then `--check` in CI (the common shape) fails the
14
+ * check the moment the emission is not already prettier-formatted, even though
15
+ * nothing is semantically stale. That is the bug this module fixes.
16
+ *
17
+ * By maintainer decision (#1565) there is NO Prettier dependency anywhere — not
18
+ * at runtime, not as a devDependency, and there is no automated round-trip
19
+ * test. The contract is upheld by this module plus the exact-output unit tests
20
+ * in `cli/tests/unit/codegen-prettier-stable.test.ts`.
21
+ *
22
+ * **If you change an emitter or this module, verify the contract by hand before
23
+ * landing:** regenerate a representative output (a database type with long op
24
+ * names and a projection; a workflow with a long key and a `oneOf` output),
25
+ * run Prettier's default config over the files, and confirm they are unchanged
26
+ * and `--check` still passes.
27
+ *
28
+ * Note "always emit the multi-line shape" is NOT sufficient on its own:
29
+ * Prettier COLLAPSES a broken call/parameter/type-argument list that would fit
30
+ * within 80 columns, so an over-broken construct is just as unstable as an
31
+ * over-long one. It only preserves an author's line break inside an object
32
+ * literal / object type. So the helpers below reproduce Prettier's width
33
+ * decision for the handful of shapes these generators emit, and the emitters
34
+ * always break the object literals (where the break IS preserved).
35
+ * ───────────────────────────────────────────────────────────────────────────
36
+ */
37
+ /** Prettier's default `printWidth`. */
38
+ export declare const PRINT_WIDTH = 80;
39
+ /** `level` indentation levels of 2 spaces (Prettier's default `tabWidth`). */
40
+ export declare function indent(level: number): string;
41
+ /**
42
+ * A TS string literal for `value`, quoted the way Prettier's DEFAULT config
43
+ * would (`singleQuote: false`).
44
+ *
45
+ * `JSON.stringify` is NOT a fixed point: it always double-quotes and escapes
46
+ * every embedded `"`, but Prettier picks the quote that needs FEWER escapes
47
+ * (tie → double), so `JSON.stringify("say \"hi\"")` → `"say \"hi\""` while
48
+ * Prettier emits `'say "hi"'`, and `codegen --check` then fails on a
49
+ * semantically identical file (#1565). This reproduces Prettier's `printString`
50
+ * exactly: start from the canonical `JSON.stringify` escaping (correct for all
51
+ * control characters), count the quotes to choose the enclosing quote, then
52
+ * re-escape for that quote.
53
+ */
54
+ export declare function tsStringLiteral(value: string): string;
55
+ /**
56
+ * A small model of the TypeScript type expressions the emitters produce. The
57
+ * emitters build these instead of hand-joining strings so `printType` can make
58
+ * the same width decision Prettier would at every nesting level.
59
+ *
60
+ * - `atom` — an identifier, string literal, or any short expression
61
+ * that is emitted verbatim and never wrapped.
62
+ * - `block` — a type that is ALWAYS multi-line (an object type). It
63
+ * renders itself at a given indentation level; Prettier
64
+ * preserves the break, so it never collapses.
65
+ * - `union` — `A | B`, wrapping to Prettier's leading-pipe form.
66
+ * - `intersection` — `A & B`.
67
+ * - `generic` — `Name<A, B>`, wrapping to one type argument per line.
68
+ * - `array` — `T[]`, parenthesized when the element needs it.
69
+ * - `objectType` — `{ a: A; b: B }`, breaking one member per line when the
70
+ * inline form does not fit.
71
+ */
72
+ export type TypeNode = {
73
+ kind: "atom";
74
+ text: string;
75
+ } | {
76
+ kind: "block";
77
+ render: (level: number) => string;
78
+ } | {
79
+ kind: "union";
80
+ members: TypeNode[];
81
+ } | {
82
+ kind: "intersection";
83
+ members: TypeNode[];
84
+ } | {
85
+ kind: "generic";
86
+ name: string;
87
+ args: TypeNode[];
88
+ } | {
89
+ kind: "array";
90
+ element: TypeNode;
91
+ } | {
92
+ kind: "objectType";
93
+ members: string[];
94
+ };
95
+ export declare const atom: (text: string) => TypeNode;
96
+ export declare const block: (render: (level: number) => string) => TypeNode;
97
+ export declare const union: (members: TypeNode[]) => TypeNode;
98
+ export declare const intersection: (members: TypeNode[]) => TypeNode;
99
+ export declare const generic: (name: string, args: TypeNode[]) => TypeNode;
100
+ export declare const arrayOf: (element: TypeNode) => TypeNode;
101
+ /**
102
+ * An inline-first object type (`{ input: X }`). Unlike `block`, it starts
103
+ * inline and only breaks when it does not fit — which is exactly what Prettier
104
+ * does with an object type the emitter writes on one line.
105
+ */
106
+ export declare const objectType: (members: string[]) => TypeNode;
107
+ /**
108
+ * `Record<string, T>` — a two-argument generic, so Prettier breaks it open when
109
+ * a long alias name pushes it past the print width. Never emit it as a plain
110
+ * atom.
111
+ */
112
+ export declare const recordOf: (value: string) => TypeNode;
113
+ /**
114
+ * The node's single-line form, or null when it contains a `block` (which is
115
+ * always multi-line and can therefore never render inline).
116
+ */
117
+ export declare function inlineType(node: TypeNode): string | null;
118
+ /**
119
+ * Render a type expression the way Prettier's default config would.
120
+ *
121
+ * The returned string's FIRST line carries NO leading indentation — the caller
122
+ * has already positioned the cursor at `col`. Continuation lines are indented
123
+ * relative to `level`.
124
+ *
125
+ * @param node the type expression.
126
+ * @param col 0-based column where the node's first character sits.
127
+ * @param level indentation level for the node's continuation lines.
128
+ * @param reserve characters that follow the node on its closing line (a
129
+ * trailing `;` or `,`), counted in the fit decision so the wrap
130
+ * boundary matches Prettier's exactly.
131
+ */
132
+ export declare function printType(node: TypeNode, col: number, level: number, reserve?: number): string;
133
+ /**
134
+ * Render `export type <name> = <expr>;` as Prettier would.
135
+ *
136
+ * A union moves below the `=` in leading-pipe form (its own rule). Otherwise
137
+ * the RHS stays on the `=` line if it can REACH ITS FIRST BREAK there — so
138
+ * `= Record<` / `= QueryResult<` stays and breaks its argument list — and
139
+ * moves below the `=` whole when it cannot (`=\n MutationResult;`,
140
+ * `=\n QueryResult<Pick<M, "a">>;`). That is Prettier's "fluid" assignment
141
+ * layout: it fit-tests only up to the right-hand side's first break point, not
142
+ * its whole width.
143
+ */
144
+ export declare function renderTypeAlias(name: string, node: TypeNode): string;
145
+ /**
146
+ * Render an object-type member line (` name?: T;`) at `level` as Prettier
147
+ * would. A union that has to break moves below the `name:`; anything else
148
+ * breaks in place.
149
+ */
150
+ export declare function renderMember(level: number, name: string, optional: boolean, node: TypeNode): string;
151
+ /**
152
+ * A parameter (or argument) entry in a parenthesized list. A plain string is
153
+ * emitted verbatim and can only break BETWEEN entries. A `{ name, type }` entry
154
+ * carries a structured type so the printer can also break INSIDE it — e.g. a
155
+ * two-argument `Omit<CreateCronTriggerParams<...>, "workflowKey">` whose type-
156
+ * argument list Prettier opens up when it overflows. A pre-rendered string
157
+ * cannot express that break; a `TypeNode` can.
158
+ */
159
+ export type ParamEntry = string | {
160
+ name: string;
161
+ type: TypeNode;
162
+ };
163
+ /**
164
+ * Render a parenthesized value/parameter list, wrapping to one entry per line
165
+ * (WITH a trailing comma — Prettier's default is `trailingComma: "all"`) when
166
+ * the single-line form would not fit. A `{ name, type }` entry whose type is too
167
+ * wide for its own line breaks INSIDE itself the way Prettier would.
168
+ *
169
+ * `prefix` must include its own leading indentation; `level` is the
170
+ * indentation level of the line `prefix` sits on.
171
+ */
172
+ export declare function renderParenList(prefix: string, entries: ParamEntry[], tail: string, level: number): string;
173
+ /**
174
+ * Render a call whose LAST argument is an object literal, the way Prettier's
175
+ * default config would. Prettier tries three shapes in order and takes the
176
+ * first that fits, so this does too:
177
+ *
178
+ * 1. everything on one line;
179
+ * 2. "last argument expansion" — hug the object literal, keeping the earlier
180
+ * arguments on the call's line and breaking the object's members;
181
+ * 3. one argument per line (with a trailing comma), the object inline.
182
+ *
183
+ * `prefix` (callee + any type arguments) must include its own leading
184
+ * indentation; `level` is the indentation level of the line it sits on. `tail`
185
+ * is whatever follows the closing paren (e.g. `","`) and is counted in every
186
+ * fit decision.
187
+ *
188
+ * `objectMembers` is optional: a call with NO trailing object-literal argument
189
+ * (`define<O>(key, options)`, `subscribe<T>(dbId, key, options)`) passes
190
+ * `undefined`, and then only two shapes apply — everything on one line, or one
191
+ * argument per line — since there is no last-argument object to hug.
192
+ */
193
+ export declare function renderCall(prefix: string, leadingArgs: string[], objectMembers: ObjectMember[] | undefined, level: number, tail?: string): string;
194
+ /**
195
+ * A member of an emitted object literal: either a bare entry (`...opts`) or a
196
+ * `key: value` pair, which Prettier may break after the colon when the value is
197
+ * a long string literal.
198
+ */
199
+ export type ObjectMember = string | {
200
+ key: string;
201
+ value: string;
202
+ };
203
+ /**
204
+ * Render an arrow function whose body is a single call ending in an object
205
+ * literal — the shape both codegen factories emit.
206
+ *
207
+ * Prettier keeps the body on the `=>` line only when the WHOLE call fits there
208
+ * on one line; a call that has to break at all moves to its own indented line
209
+ * (it never hugs the object up onto the `=>` line). `head` is the arrow's
210
+ * signature through `=>` (it may itself be multi-line if the parameter list
211
+ * broke); `level` is the indentation level of the body line.
212
+ */
213
+ export declare function renderArrowCall(opts: {
214
+ head: string;
215
+ callee: TypeNode;
216
+ leadingArgs: string[];
217
+ objectMembers?: ObjectMember[];
218
+ level: number;
219
+ tail?: string;
220
+ }): string;
221
+ /**
222
+ * Render an object-literal property whose value is an arrow function returning a
223
+ * single call — the shape the database ops factory emits (` <op>: (params, …)
224
+ * => client.databases.executeOperation(…)`).
225
+ *
226
+ * Prettier applies its assignment layout to the `key: value` pair: the arrow
227
+ * stays on the key's line only when it can REACH ITS FIRST BREAK there — the
228
+ * `(` opening its parameter list. When even that `(` does not fit (a property
229
+ * key long enough that `<indent><key>: (` passes the print width), Prettier
230
+ * breaks after the colon and renders the WHOLE arrow — parameter list, return
231
+ * type, and body — one level deeper:
232
+ *
233
+ * aVeryLongOpName:
234
+ * (
235
+ * params: P,
236
+ * options?: OpsCallOptions,
237
+ * ): Promise<R> =>
238
+ * client.databases.executeOperation<R>(
239
+ * databaseId,
240
+ * "aVeryLongOpName",
241
+ * { params, ...options },
242
+ * ),
243
+ *
244
+ * Reproducing that break is what keeps a long-but-legal op name (>= 74
245
+ * characters, with this file's 4-space property indent) prettier-stable.
246
+ *
247
+ * @param level indentation level of the property line.
248
+ * @param key the property key, already quoted if it needs to be.
249
+ * @param params the arrow's parameter list entries.
250
+ * @param signatureTail what follows the parameter list's `)` — e.g.
251
+ * `": Promise<R> =>"`.
252
+ */
253
+ export declare function renderArrowProperty(opts: {
254
+ level: number;
255
+ key: string;
256
+ params: ParamEntry[];
257
+ signatureTail: string;
258
+ callee: TypeNode;
259
+ leadingArgs: string[];
260
+ objectMembers?: ObjectMember[];
261
+ tail?: string;
262
+ }): string;