primitive-admin 1.0.55 → 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.
- package/assets/skill/skills/primitive-platform/SKILL.md +230 -2
- package/dist/bin/primitive.js +1 -1
- package/dist/src/commands/database-types.js +4 -4
- package/dist/src/commands/database-types.js.map +1 -1
- package/dist/src/commands/databases.js +5 -5
- package/dist/src/commands/databases.js.map +1 -1
- package/dist/src/commands/documents.js +2 -2
- package/dist/src/commands/documents.js.map +1 -1
- package/dist/src/commands/guides.d.ts +15 -12
- package/dist/src/commands/guides.js +22 -15
- package/dist/src/commands/guides.js.map +1 -1
- package/dist/src/commands/metadata.js +48 -3
- package/dist/src/commands/metadata.js.map +1 -1
- package/dist/src/commands/scripts.d.ts +18 -0
- package/dist/src/commands/scripts.js +59 -5
- package/dist/src/commands/scripts.js.map +1 -1
- package/dist/src/commands/sync-app-settings.d.ts +14 -4
- package/dist/src/commands/sync-app-settings.js +48 -8
- package/dist/src/commands/sync-app-settings.js.map +1 -1
- package/dist/src/commands/sync.d.ts +100 -0
- package/dist/src/commands/sync.js +1578 -402
- package/dist/src/commands/sync.js.map +1 -1
- package/dist/src/commands/workflows.js +23 -6
- package/dist/src/commands/workflows.js.map +1 -1
- package/dist/src/lib/api-client.d.ts +27 -1
- package/dist/src/lib/api-client.js +25 -2
- package/dist/src/lib/api-client.js.map +1 -1
- package/dist/src/lib/app-settings-descriptor.js +4 -0
- package/dist/src/lib/app-settings-descriptor.js.map +1 -1
- package/dist/src/lib/codegen-shared/generatedFiles.d.ts +21 -0
- package/dist/src/lib/codegen-shared/generatedFiles.js +40 -0
- package/dist/src/lib/codegen-shared/generatedFiles.js.map +1 -1
- package/dist/src/lib/codegen-shared/prettierStable.d.ts +262 -0
- package/dist/src/lib/codegen-shared/prettierStable.js +610 -0
- package/dist/src/lib/codegen-shared/prettierStable.js.map +1 -0
- package/dist/src/lib/db-codegen/dbGenerator.js +8 -5
- package/dist/src/lib/db-codegen/dbGenerator.js.map +1 -1
- package/dist/src/lib/db-codegen/dbNaming.d.ts +5 -0
- package/dist/src/lib/db-codegen/dbNaming.js +8 -2
- package/dist/src/lib/db-codegen/dbNaming.js.map +1 -1
- package/dist/src/lib/db-codegen/dbTemplates.d.ts +17 -2
- package/dist/src/lib/db-codegen/dbTemplates.js +85 -40
- package/dist/src/lib/db-codegen/dbTemplates.js.map +1 -1
- package/dist/src/lib/db-codegen/dbTsTypes.d.ts +13 -22
- package/dist/src/lib/db-codegen/dbTsTypes.js +33 -28
- package/dist/src/lib/db-codegen/dbTsTypes.js.map +1 -1
- package/dist/src/lib/db-codegen/generated-operation-def-descriptor.d.ts +11 -0
- package/dist/src/lib/db-codegen/generated-operation-def-descriptor.js +11 -0
- package/dist/src/lib/db-codegen/generated-operation-def-descriptor.js.map +1 -1
- package/dist/src/lib/generated-allowlist.js +7 -0
- package/dist/src/lib/generated-allowlist.js.map +1 -1
- package/dist/src/lib/platform-owned.d.ts +37 -0
- package/dist/src/lib/platform-owned.js +46 -0
- package/dist/src/lib/platform-owned.js.map +1 -0
- package/dist/src/lib/swift-codegen/dbGenerator.d.ts +32 -0
- package/dist/src/lib/swift-codegen/dbGenerator.js +338 -36
- package/dist/src/lib/swift-codegen/dbGenerator.js.map +1 -1
- package/dist/src/lib/swift-codegen/dbSwiftTypes.d.ts +1 -1
- package/dist/src/lib/swift-codegen/dbSwiftTypes.js +1 -1
- package/dist/src/lib/swift-codegen/generator.d.ts +1 -0
- package/dist/src/lib/swift-codegen/generator.js +91 -3
- package/dist/src/lib/swift-codegen/generator.js.map +1 -1
- package/dist/src/lib/swift-codegen/siblingSymbols.d.ts +90 -0
- package/dist/src/lib/swift-codegen/siblingSymbols.js +152 -0
- package/dist/src/lib/swift-codegen/siblingSymbols.js.map +1 -0
- package/dist/src/lib/sync-resource-types.d.ts +222 -10
- package/dist/src/lib/sync-resource-types.js +407 -20
- package/dist/src/lib/sync-resource-types.js.map +1 -1
- package/dist/src/lib/template.d.ts +1 -1
- package/dist/src/lib/template.js +6 -3
- package/dist/src/lib/template.js.map +1 -1
- package/dist/src/lib/toml-metadata-config.js +18 -0
- package/dist/src/lib/toml-metadata-config.js.map +1 -1
- package/dist/src/lib/workflow-apply.js +12 -2
- package/dist/src/lib/workflow-apply.js.map +1 -1
- package/dist/src/lib/workflow-codegen/generator.d.ts +9 -0
- package/dist/src/lib/workflow-codegen/generator.js +126 -55
- package/dist/src/lib/workflow-codegen/generator.js.map +1 -1
- package/dist/src/lib/workflow-codegen/invokerIR.d.ts +6 -8
- package/dist/src/lib/workflow-codegen/invokerIR.js +8 -8
- package/dist/src/lib/workflow-codegen/invokerIR.js.map +1 -1
- package/dist/src/lib/workflow-codegen/schemaToTs.d.ts +17 -1
- package/dist/src/lib/workflow-codegen/schemaToTs.js +59 -38
- package/dist/src/lib/workflow-codegen/schemaToTs.js.map +1 -1
- package/dist/src/lib/workflow-payload.d.ts +19 -0
- package/dist/src/lib/workflow-payload.js +21 -0
- package/dist/src/lib/workflow-payload.js.map +1 -1
- package/dist/src/lib/workflow-toml-validator.d.ts +30 -0
- package/dist/src/lib/workflow-toml-validator.js +206 -0
- package/dist/src/lib/workflow-toml-validator.js.map +1 -1
- package/dist/src/types/index.d.ts +1 -0
- package/package.json +2 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"dbGenerator.js","sourceRoot":"","sources":["../../../../src/lib/db-codegen/dbGenerator.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAEH,OAAO,KAAK,IAAI,MAAM,MAAM,CAAC;AAC7B,OAAO,EACL,0BAA0B,GAE3B,MAAM,qCAAqC,CAAC;AAC7C,OAAO,EACL,cAAc,GAGf,MAAM,eAAe,CAAC;AACvB,OAAO,EACL,0BAA0B,EAC1B,qBAAqB,EACrB,iBAAiB,EACjB,cAAc,EACd,wBAAwB,EACxB,iBAAiB,GAClB,MAAM,eAAe,CAAC;AACvB,OAAO,EACL,YAAY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AAC;QAC7D,MAAM,CAAC,IAAI,CACT,eAAe,CAAC;YACd,YAAY,EAAE,KAAK,CAAC,YAAY;YAChC,cAAc,EAAE,cAAc,CAAC,KAAK,CAAC,YAAY,CAAC;YAClD,wBAAwB,EAAE,wBAAwB,CAAC,KAAK,CAAC,YAAY,CAAC;YACtE,GAAG,EAAE,UAAU;YACf,aAAa,EAAE,oBAAoB;SACpC,CAAC,CACH,CAAC;IACJ,CAAC;IAED,6DAA6D;IAC7D,OAAO,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,GAAG,IAAI,CAAC;AACpC,CAAC;AAED;;;;GAIG;AACH,MAAM,CAAC,KAAK,UAAU,eAAe,CACnC,OAA+B;IAE/B,MAAM,MAAM,GAAG,IAAI,CAAC,OAAO,CAAC,OAAO,CAAC,SAAS,CAAC,CAAC;IAE/C,MAAM,YAAY,GAAG,IAAI,GAAG,EAAkB,CAAC;IAC/C,KAAK,MAAM,KAAK,IAAI,OAAO,CAAC,MAAM,EAAE,CAAC;QACnC,MAAM,QAAQ,GAAG,IAAI,CAAC,IAAI,CACxB,MAAM,EACN,GAAG,KAAK,CAAC,YAAY,GAAG,qBAAqB,EAAE,CAChD,CAAC;QACF,YAAY,CAAC,GAAG,CAAC,QAAQ,EAAE,gBAAgB,CAAC,KAAK,CAAC,CAAC,CAAC;IACtD,CAAC;IAED,OAAO,MAAM,0BAA0B,CAAC;QACtC,SAAS,EAAE,MAAM;QACjB,YAAY;QACZ,KAAK,EAAE,OAAO,CAAC,KAAK;QACpB,yEAAyE;QACzE,wEAAwE;QACxE,aAAa,EAAE,OAAO,CAAC,UAAU,KAAK,IAAI;QAC1C,eAAe,EAAE,qBAAqB;KACvC,CAAC,CAAC;AACL,CAAC"}
|
|
@@ -64,6 +64,11 @@ export declare function camelCase(name: string): string;
|
|
|
64
64
|
* `"__proto__":` form set the object's prototype instead of defining an own
|
|
65
65
|
* method — silently dropping that operation. Only a computed key
|
|
66
66
|
* (`["__proto__"]:`) defines a normal own property, so emit that form.
|
|
67
|
+
*
|
|
68
|
+
* A quoted key uses `tsStringLiteral` (Prettier's fewer-escapes quote choice),
|
|
69
|
+
* not `JSON.stringify`, so a quote-bearing op name / subscription key (e.g.
|
|
70
|
+
* `weird"key` → `'weird"key':`) stays a fixed point of Prettier's default
|
|
71
|
+
* config (#1678). For identifier and quote-free keys the two are identical.
|
|
67
72
|
*/
|
|
68
73
|
export declare function objectPropertyKey(name: string): string;
|
|
69
74
|
/**
|
|
@@ -19,6 +19,7 @@
|
|
|
19
19
|
* `Params` / `Result` suffix (e.g. `saveAccount` → `SaveAccountParams`,
|
|
20
20
|
* `SaveAccountResult`).
|
|
21
21
|
*/
|
|
22
|
+
import { tsStringLiteral } from "../codegen-shared/prettierStable.js";
|
|
22
23
|
/**
|
|
23
24
|
* Resolve the record-interface name for a model. Honors a `class_name`
|
|
24
25
|
* override, then tries plural→singular Pascal, then falls back to a verbatim
|
|
@@ -104,14 +105,19 @@ const RESERVED_WORDS = new Set([
|
|
|
104
105
|
* `"__proto__":` form set the object's prototype instead of defining an own
|
|
105
106
|
* method — silently dropping that operation. Only a computed key
|
|
106
107
|
* (`["__proto__"]:`) defines a normal own property, so emit that form.
|
|
108
|
+
*
|
|
109
|
+
* A quoted key uses `tsStringLiteral` (Prettier's fewer-escapes quote choice),
|
|
110
|
+
* not `JSON.stringify`, so a quote-bearing op name / subscription key (e.g.
|
|
111
|
+
* `weird"key` → `'weird"key':`) stays a fixed point of Prettier's default
|
|
112
|
+
* config (#1678). For identifier and quote-free keys the two are identical.
|
|
107
113
|
*/
|
|
108
114
|
export function objectPropertyKey(name) {
|
|
109
115
|
if (name === "__proto__")
|
|
110
|
-
return `[${
|
|
116
|
+
return `[${tsStringLiteral(name)}]`;
|
|
111
117
|
const isPlainIdentifier = /^[A-Za-z_$][A-Za-z0-9_$]*$/.test(name);
|
|
112
118
|
if (isPlainIdentifier && !RESERVED_WORDS.has(name))
|
|
113
119
|
return name;
|
|
114
|
-
return
|
|
120
|
+
return tsStringLiteral(name);
|
|
115
121
|
}
|
|
116
122
|
/**
|
|
117
123
|
* Convert a snake_case plural model name (`user_prefs`, `categories`) into a
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"dbNaming.js","sourceRoot":"","sources":["../../../../src/lib/db-codegen/dbNaming.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;AAEH;;;;GAIG;AACH,MAAM,UAAU,0BAA0B,CACxC,SAAiB,EACjB,iBAAqC;IAErC,IAAI,iBAAiB,IAAI,iBAAiB,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;QACtD,OAAO,iBAAiB,CAAC;IAC3B,CAAC;IACD,MAAM,QAAQ,GAAG,uBAAuB,CAAC,SAAS,CAAC,CAAC;IACpD,IAAI,QAAQ,KAAK,IAAI;QAAE,OAAO,QAAQ,CAAC;IACvC,0EAA0E;IAC1E,oDAAoD;IACpD,OAAO,UAAU,CAAC,SAAS,CAAC,CAAC;AAC/B,CAAC;AAED,2CAA2C;AAC3C,MAAM,UAAU,qBAAqB,CAAC,MAAc;IAClD,OAAO,GAAG,UAAU,CAAC,MAAM,CAAC,QAAQ,CAAC;AACvC,CAAC;AAED,2CAA2C;AAC3C,MAAM,UAAU,iBAAiB,CAAC,MAAc;IAC9C,OAAO,GAAG,UAAU,CAAC,MAAM,CAAC,QAAQ,CAAC;AACvC,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,cAAc,CAAC,YAAoB;IACjD,MAAM,IAAI,GAAG,SAAS,CAAC,YAAY,CAAC,CAAC;IACrC,MAAM,IAAI,GAAG,QAAQ,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,IAAI,IAAI,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC;IACrD,OAAO,GAAG,IAAI,KAAK,CAAC;AACtB,CAAC;AAED;;;;;;GAMG;AACH,MAAM,UAAU,wBAAwB,CAAC,YAAoB;IAC3D,MAAM,IAAI,GAAG,S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;SACZ,GAAG,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,WAAW,EAAE,GAAG,GAAG,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;SACxD,IAAI,CAAC,EAAE,CAAC,CAAC;AACd,CAAC"}
|
|
@@ -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,6 +27,7 @@
|
|
|
18
27
|
* resolves those into the small descriptors below; the templates stay pure
|
|
19
28
|
* string-emitters.
|
|
20
29
|
*/
|
|
30
|
+
import { type TypeNode } from "../codegen-shared/prettierStable.js";
|
|
21
31
|
/** A field on a record interface (read shape). */
|
|
22
32
|
export interface RecordField {
|
|
23
33
|
name: string;
|
|
@@ -161,6 +171,8 @@ export declare function renderRecordInterface(input: RenderRecordInterfaceInput)
|
|
|
161
171
|
* `Record<string, any>`.
|
|
162
172
|
*/
|
|
163
173
|
export declare function renderOpParamsInterface(input: RenderOpParamsInterfaceInput): string;
|
|
174
|
+
/** A `Pick`/`Omit` key union (`"a" | "b"`), wrappable when it gets long. */
|
|
175
|
+
export declare function fieldNameUnion(fields: string[]): TypeNode;
|
|
164
176
|
/**
|
|
165
177
|
* Render a per-op result alias. The alias is derived from `op.type` and, where
|
|
166
178
|
* the shape is derivable from the parsed op definition, a narrowed form:
|
|
@@ -224,9 +236,12 @@ export interface SubscriptionFactoryEntry {
|
|
|
224
236
|
/**
|
|
225
237
|
* The record type bound to the change payload — a record interface name
|
|
226
238
|
* (`Task`) or a projection (`Pick<Task, "id" | "name">`) when the
|
|
227
|
-
* subscription declares `select`.
|
|
239
|
+
* subscription declares `select`. A `TypeNode` (not a pre-joined string) so
|
|
240
|
+
* `SubscribeOptions<...>` and the `subscribe<...>` type argument break the way
|
|
241
|
+
* Prettier would when a projection pushes the line past the print width
|
|
242
|
+
* (built by the generator via `fieldNameUnion`, mirroring `queryResultGeneric`).
|
|
228
243
|
*/
|
|
229
|
-
eventType:
|
|
244
|
+
eventType: TypeNode;
|
|
230
245
|
}
|
|
231
246
|
export interface RenderFactoriesInput {
|
|
232
247
|
/** Database type name, for the doc comments. */
|
|
@@ -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 {
|
|
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
|
-
|
|
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
|
|
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
|
|
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
|
-
|
|
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,21 +179,21 @@ export function renderOpParamsInterface(input) {
|
|
|
171
179
|
*/
|
|
172
180
|
function queryResultGeneric(recordInterfaceName, projection) {
|
|
173
181
|
if (recordInterfaceName === null)
|
|
174
|
-
return "
|
|
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
|
|
187
|
+
return record;
|
|
179
188
|
case "partial":
|
|
180
|
-
return
|
|
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
|
|
187
|
-
|
|
188
|
-
return `Pick<${recordInterfaceName}, ${members}>`;
|
|
195
|
+
return record;
|
|
196
|
+
return generic("Pick", [record, fieldNameUnion(p.fields)]);
|
|
189
197
|
}
|
|
190
198
|
case "omit": {
|
|
191
199
|
// Static all-exclusion over known members (id/type already filtered out by
|
|
@@ -193,12 +201,15 @@ function queryResultGeneric(recordInterfaceName, projection) {
|
|
|
193
201
|
// guarded list; the defensive empty check keeps this total. Same literal
|
|
194
202
|
// emission style as `pick`.
|
|
195
203
|
if (p.fields.length === 0)
|
|
196
|
-
return
|
|
197
|
-
|
|
198
|
-
return `Omit<${recordInterfaceName}, ${members}>`;
|
|
204
|
+
return record;
|
|
205
|
+
return generic("Omit", [record, fieldNameUnion(p.fields)]);
|
|
199
206
|
}
|
|
200
207
|
}
|
|
201
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
|
+
}
|
|
202
213
|
/**
|
|
203
214
|
* Render a per-op result alias. The alias is derived from `op.type` and, where
|
|
204
215
|
* the shape is derivable from the parsed op definition, a narrowed form:
|
|
@@ -210,39 +221,44 @@ function queryResultGeneric(recordInterfaceName, projection) {
|
|
|
210
221
|
*/
|
|
211
222
|
export function renderOpResultAlias(input) {
|
|
212
223
|
const { aliasName, opType, recordInterfaceName, projection } = input;
|
|
224
|
+
const alias = (node) => renderTypeAlias(aliasName, node);
|
|
213
225
|
switch (opType) {
|
|
214
226
|
case "query":
|
|
215
|
-
return
|
|
227
|
+
return alias(generic("QueryResult", [
|
|
228
|
+
queryResultGeneric(recordInterfaceName, projection),
|
|
229
|
+
]));
|
|
216
230
|
case "mutation":
|
|
217
231
|
// Every mutation op returns the uniform `{ results: MutationStepResult[] }`
|
|
218
232
|
// in definition-step order (#1458) — no more per-category flat shapes.
|
|
219
|
-
return
|
|
233
|
+
return alias(atom("MutationResult"));
|
|
220
234
|
case "count":
|
|
221
|
-
return
|
|
235
|
+
return alias(atom("CountResult"));
|
|
222
236
|
case "aggregate":
|
|
223
|
-
return
|
|
237
|
+
return alias(atom("AggregateResult"));
|
|
224
238
|
case "applyToQuery":
|
|
225
|
-
return
|
|
239
|
+
return alias(atom("ApplyToQueryResult"));
|
|
226
240
|
case "pipeline": {
|
|
227
241
|
const d = input.pipelineReturn ?? { kind: "opaque" };
|
|
228
242
|
switch (d.kind) {
|
|
229
243
|
case "query":
|
|
230
|
-
return
|
|
244
|
+
return alias(generic("QueryResult", [
|
|
245
|
+
queryResultGeneric(d.recordInterfaceName, d.projection),
|
|
246
|
+
]));
|
|
231
247
|
case "count":
|
|
232
|
-
return
|
|
248
|
+
return alias(atom("CountResult"));
|
|
233
249
|
case "aggregate":
|
|
234
|
-
return
|
|
250
|
+
return alias(atom("AggregateResult"));
|
|
235
251
|
// `opaque` — `return: "all"`, no `return`, or a step the generator
|
|
236
252
|
// couldn't resolve — keeps the generic `PipelineResult` (unchanged).
|
|
237
253
|
case "opaque":
|
|
238
254
|
default:
|
|
239
|
-
return
|
|
255
|
+
return alias(atom("PipelineResult"));
|
|
240
256
|
}
|
|
241
257
|
}
|
|
242
258
|
default:
|
|
243
259
|
// Unknown op type — emit a permissive alias rather than throwing,
|
|
244
260
|
// so one stray op doesn't block codegen for the whole file.
|
|
245
|
-
return
|
|
261
|
+
return alias(atom("unknown"));
|
|
246
262
|
}
|
|
247
263
|
}
|
|
248
264
|
// The `databases.executeOperation<R>` member on the structural client shape.
|
|
@@ -334,21 +350,30 @@ function renderClientInterface(members) {
|
|
|
334
350
|
function opsMethodLines(ops) {
|
|
335
351
|
return ops.map((op) => {
|
|
336
352
|
const nameLiteral = JSON.stringify(op.opName);
|
|
337
|
-
if (op.hasParams) {
|
|
338
|
-
return (` ${op.propertyKey}: (params: ${op.paramsInterfaceName}, options?: OpsCallOptions): Promise<${op.resultAliasName}> =>\n` +
|
|
339
|
-
` client.databases.executeOperation<${op.resultAliasName}>(databaseId, ${nameLiteral}, { params, ...options }),`);
|
|
340
|
-
}
|
|
341
353
|
// No declared params: the method takes only the optional options object, so
|
|
342
354
|
// it stays callable with no arguments (`ops.foo()`).
|
|
343
|
-
|
|
344
|
-
`
|
|
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
|
+
});
|
|
345
370
|
});
|
|
346
371
|
}
|
|
347
372
|
/** The `export function <type>Ops(...)` factory body. */
|
|
348
373
|
function opsFactoryBlock(factoryName, databaseType, ops) {
|
|
349
374
|
return [
|
|
350
375
|
`/** Typed accessor for \`${databaseType}\` operations. */`,
|
|
351
|
-
`export function ${factoryName}
|
|
376
|
+
renderParenList(`export function ${factoryName}`, ["client: OpsClient", "databaseId: string"], " {", 0),
|
|
352
377
|
" return {",
|
|
353
378
|
...opsMethodLines(ops),
|
|
354
379
|
" };",
|
|
@@ -376,16 +401,36 @@ export function renderOpsFactory(input) {
|
|
|
376
401
|
opsFactoryBlock(factoryName, databaseType, ops),
|
|
377
402
|
].join("\n\n");
|
|
378
403
|
}
|
|
379
|
-
/**
|
|
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
|
+
*/
|
|
380
417
|
function subscriptionsFactoryBlock(factoryName, databaseType, subscriptions) {
|
|
381
|
-
const methodLines = subscriptions.map((sub) => {
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
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
|
+
}));
|
|
386
431
|
return [
|
|
387
432
|
`/** Typed accessor for \`${databaseType}\` realtime subscriptions. */`,
|
|
388
|
-
`export function ${factoryName}
|
|
433
|
+
renderParenList(`export function ${factoryName}`, ["client: OpsClient", "databaseId: string"], " {", 0),
|
|
389
434
|
" return {",
|
|
390
435
|
...methodLines,
|
|
391
436
|
" };",
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"dbTemplates.js","sourceRoot":"","sources":["../../../../src/lib/db-codegen/dbTemplates.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"dbTemplates.js","sourceRoot":"","sources":["../../../../src/lib/db-codegen/dbTemplates.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;AAEH,OAAO,EAAE,kBAAkB,EAAE,sBAAsB,EAAE,MAAM,gBAAgB,CAAC;AAC5E,OAAO,EACL,IAAI,EACJ,OAAO,EACP,QAAQ,EACR,mBAAmB,EACnB,YAAY,EACZ,eAAe,EACf,eAAe,EACf,eAAe,EACf,KAAK,GAEN,MAAM,qCAAqC,CAAC;AAE7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Y,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
|
-
*
|
|
52
|
-
*
|
|
53
|
-
* `
|
|
54
|
-
*
|
|
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
|
|
58
|
+
export declare function typeNodeForDbField(fieldType: string, enumValues?: string[]): TypeNode;
|
|
69
59
|
/**
|
|
70
|
-
* Returns the TS type expression for an op param
|
|
71
|
-
* `enum` allowed-value set (#861). A non-empty `enum` on a
|
|
72
|
-
* renders a string-literal union (`"a" | "b"
|
|
73
|
-
*
|
|
74
|
-
*
|
|
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
|
|
73
|
+
export declare function typeNodeForDbParamType(paramType: string, enumValues?: string[], items?: string): TypeNode;
|
|
@@ -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 { arrayOf, atom, recordOf, tsStringLiteral, union, } from "../codegen-shared/prettierStable.js";
|
|
28
29
|
/**
|
|
29
30
|
* Returns the TS type expression for a record field type. Unknown types
|
|
30
31
|
* fall back to `unknown` rather than throwing: the database-type TOML is
|
|
@@ -50,39 +51,43 @@ export function tsTypeForDbFieldType(fieldType) {
|
|
|
50
51
|
}
|
|
51
52
|
}
|
|
52
53
|
/**
|
|
53
|
-
* Render a TypeScript string-literal union from an `enum` allowed-value set
|
|
54
|
-
* (e.g. `["a", "b"]` → `"a" | "b"
|
|
55
|
-
*
|
|
56
|
-
*
|
|
54
|
+
* Render a TypeScript string-literal union from an `enum` allowed-value set as
|
|
55
|
+
* a wrappable node (e.g. `["a", "b"]` → `"a" | "b"`; a long union renders as
|
|
56
|
+
* Prettier's leading-pipe form rather than one over-width line, #1565). Each
|
|
57
|
+
* value is emitted via `tsStringLiteral` so quotes, backslashes, and other
|
|
58
|
+
* special characters escape into a valid TS string literal AND the quote choice
|
|
59
|
+
* matches Prettier's (fewer-escapes rule), keeping the output a fixed point.
|
|
57
60
|
*
|
|
58
61
|
* Shared enum vocabulary with the doc-model v2 codegen
|
|
59
62
|
* (`packages/js-bao/src/cli/v2/tsTypes.ts`). The `enum` array is validated
|
|
60
63
|
* upstream by the TOML loader (`parseFieldOptions`): non-empty, all-string,
|
|
61
64
|
* string-field-only. This renderer assumes that contract has held.
|
|
62
65
|
*/
|
|
63
|
-
|
|
64
|
-
return values.map((v) =>
|
|
66
|
+
function unionNodeFromEnum(values) {
|
|
67
|
+
return union(values.map((v) => atom(tsStringLiteral(v))));
|
|
65
68
|
}
|
|
66
69
|
/**
|
|
67
|
-
* Returns the TS type expression for a record field
|
|
68
|
-
* string `enum` allowed-value set (#843). A non-empty
|
|
69
|
-
* field renders a string-literal union
|
|
70
|
+
* Returns the TS type expression for a record field as a wrappable node,
|
|
71
|
+
* honoring an optional string `enum` allowed-value set (#843). A non-empty
|
|
72
|
+
* `enum` on a `string` field renders a string-literal union (a long one in
|
|
73
|
+
* Prettier's leading-pipe form, #1565); otherwise falls back to the base
|
|
70
74
|
* `tsTypeForDbFieldType` mapping.
|
|
71
75
|
*/
|
|
72
|
-
export function
|
|
76
|
+
export function typeNodeForDbField(fieldType, enumValues) {
|
|
73
77
|
if (fieldType === "string" &&
|
|
74
78
|
Array.isArray(enumValues) &&
|
|
75
79
|
enumValues.length > 0) {
|
|
76
|
-
return
|
|
80
|
+
return unionNodeFromEnum(enumValues);
|
|
77
81
|
}
|
|
78
|
-
return tsTypeForDbFieldType(fieldType);
|
|
82
|
+
return atom(tsTypeForDbFieldType(fieldType));
|
|
79
83
|
}
|
|
80
84
|
/**
|
|
81
|
-
* Returns the TS type expression for an op param
|
|
82
|
-
* `enum` allowed-value set (#861). A non-empty `enum` on a
|
|
83
|
-
* renders a string-literal union (`"a" | "b"
|
|
84
|
-
*
|
|
85
|
-
*
|
|
85
|
+
* Returns the TS type expression for an op param as a wrappable node, honoring
|
|
86
|
+
* an optional string `enum` allowed-value set (#861). A non-empty `enum` on a
|
|
87
|
+
* `string` param renders a string-literal union (`"a" | "b"`; a long one in
|
|
88
|
+
* Prettier's leading-pipe form, #1565); otherwise falls back to the base
|
|
89
|
+
* param-type mapping below. Mirrors `typeNodeForDbField` (the record-field
|
|
90
|
+
* sibling) and reuses `unionNodeFromEnum` for a single escaping implementation.
|
|
86
91
|
*
|
|
87
92
|
* Unlike the record-field path (validated upstream by `parseFieldOptions`,
|
|
88
93
|
* which throws), op-param enum *shape* is validated server-side in
|
|
@@ -90,7 +95,7 @@ export function tsTypeForDbField(fieldType, enumValues) {
|
|
|
90
95
|
* the base type for a non-string param or an empty enum rather than throwing —
|
|
91
96
|
* the server is the source of truth for rejecting a malformed param `enum`.
|
|
92
97
|
*/
|
|
93
|
-
export function
|
|
98
|
+
export function typeNodeForDbParamType(paramType, enumValues, items) {
|
|
94
99
|
// Array param (#1488): a declared `type = "array"` (Phase 2) or one inferred
|
|
95
100
|
// from a `$in`/`$nin` binding (Phase 1). `items` is the scalar element type;
|
|
96
101
|
// a per-element `enum` on a string-element array renders `("a" | "b")[]`.
|
|
@@ -100,35 +105,35 @@ export function tsTypeForDbParamType(paramType, enumValues, items) {
|
|
|
100
105
|
if (items === "string" &&
|
|
101
106
|
Array.isArray(enumValues) &&
|
|
102
107
|
enumValues.length > 0) {
|
|
103
|
-
elem =
|
|
108
|
+
elem = unionNodeFromEnum(enumValues);
|
|
104
109
|
}
|
|
105
110
|
else if (items) {
|
|
106
111
|
// Element type is always scalar here, so the recursion never re-enters
|
|
107
112
|
// this array branch.
|
|
108
|
-
elem =
|
|
113
|
+
elem = typeNodeForDbParamType(items);
|
|
109
114
|
}
|
|
110
115
|
else {
|
|
111
|
-
elem = "unknown";
|
|
116
|
+
elem = atom("unknown");
|
|
112
117
|
}
|
|
113
|
-
return
|
|
118
|
+
return arrayOf(elem);
|
|
114
119
|
}
|
|
115
120
|
if (paramType === "string" &&
|
|
116
121
|
Array.isArray(enumValues) &&
|
|
117
122
|
enumValues.length > 0) {
|
|
118
|
-
return
|
|
123
|
+
return unionNodeFromEnum(enumValues);
|
|
119
124
|
}
|
|
120
125
|
switch (paramType) {
|
|
121
126
|
case "string":
|
|
122
|
-
return "string";
|
|
127
|
+
return atom("string");
|
|
123
128
|
case "number":
|
|
124
129
|
case "integer":
|
|
125
|
-
return "number";
|
|
130
|
+
return atom("number");
|
|
126
131
|
case "boolean":
|
|
127
|
-
return "boolean";
|
|
132
|
+
return atom("boolean");
|
|
128
133
|
case "object":
|
|
129
|
-
return "
|
|
134
|
+
return recordOf("unknown");
|
|
130
135
|
default:
|
|
131
|
-
return "unknown";
|
|
136
|
+
return atom("unknown");
|
|
132
137
|
}
|
|
133
138
|
}
|
|
134
139
|
//# sourceMappingURL=dbTsTypes.js.map
|