primitive-admin 1.0.53 → 1.0.54
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/README.md +38 -10
- package/dist/bin/primitive.js +6 -0
- package/dist/bin/primitive.js.map +1 -1
- package/dist/src/commands/auth.js +16 -6
- package/dist/src/commands/auth.js.map +1 -1
- package/dist/src/commands/blob-buckets.js +84 -7
- package/dist/src/commands/blob-buckets.js.map +1 -1
- package/dist/src/commands/catalog.js +3 -3
- package/dist/src/commands/catalog.js.map +1 -1
- package/dist/src/commands/collections.js +12 -9
- package/dist/src/commands/collections.js.map +1 -1
- package/dist/src/commands/databases.js +191 -74
- package/dist/src/commands/databases.js.map +1 -1
- package/dist/src/commands/group-type-configs.js +1 -9
- package/dist/src/commands/group-type-configs.js.map +1 -1
- package/dist/src/commands/groups.js +12 -6
- package/dist/src/commands/groups.js.map +1 -1
- package/dist/src/commands/guides.d.ts +161 -0
- package/dist/src/commands/guides.js +502 -84
- package/dist/src/commands/guides.js.map +1 -1
- package/dist/src/commands/integrations.js +2 -2
- package/dist/src/commands/integrations.js.map +1 -1
- package/dist/src/commands/metadata.d.ts +2 -0
- package/dist/src/commands/metadata.js +344 -0
- package/dist/src/commands/metadata.js.map +1 -0
- package/dist/src/commands/prompts.js +2 -2
- package/dist/src/commands/prompts.js.map +1 -1
- package/dist/src/commands/rule-sets.d.ts +1 -0
- package/dist/src/commands/rule-sets.js +25 -3
- package/dist/src/commands/rule-sets.js.map +1 -1
- package/dist/src/commands/scripts.d.ts +2 -0
- package/dist/src/commands/scripts.js +667 -0
- package/dist/src/commands/scripts.js.map +1 -0
- package/dist/src/commands/sync.d.ts +189 -9
- package/dist/src/commands/sync.js +1418 -256
- package/dist/src/commands/sync.js.map +1 -1
- package/dist/src/commands/vars.d.ts +8 -0
- package/dist/src/commands/vars.js +110 -0
- package/dist/src/commands/vars.js.map +1 -0
- package/dist/src/commands/webhooks.js +17 -3
- package/dist/src/commands/webhooks.js.map +1 -1
- package/dist/src/commands/workflows.d.ts +30 -0
- package/dist/src/commands/workflows.js +645 -59
- package/dist/src/commands/workflows.js.map +1 -1
- package/dist/src/lib/api-client.d.ts +120 -18
- package/dist/src/lib/api-client.js +125 -2
- package/dist/src/lib/api-client.js.map +1 -1
- package/dist/src/lib/batch.d.ts +26 -0
- package/dist/src/lib/batch.js +32 -0
- package/dist/src/lib/batch.js.map +1 -0
- package/dist/src/lib/block-layout.d.ts +160 -0
- package/dist/src/lib/block-layout.js +451 -0
- package/dist/src/lib/block-layout.js.map +1 -0
- package/dist/src/lib/codegen-shared/generatedFiles.d.ts +61 -0
- package/dist/src/lib/codegen-shared/generatedFiles.js +127 -0
- package/dist/src/lib/codegen-shared/generatedFiles.js.map +1 -0
- package/dist/src/lib/codegen-shared/resolveCodegenSourceDir.d.ts +68 -0
- package/dist/src/lib/codegen-shared/resolveCodegenSourceDir.js +168 -0
- package/dist/src/lib/codegen-shared/resolveCodegenSourceDir.js.map +1 -0
- package/dist/src/lib/config-toml.d.ts +10 -0
- package/dist/src/lib/config-toml.js +42 -0
- package/dist/src/lib/config-toml.js.map +1 -0
- package/dist/src/lib/config.d.ts +16 -0
- package/dist/src/lib/config.js +41 -0
- package/dist/src/lib/config.js.map +1 -1
- package/dist/src/lib/constants.d.ts +9 -0
- package/dist/src/lib/constants.js +9 -0
- package/dist/src/lib/constants.js.map +1 -1
- package/dist/src/lib/csv.d.ts +1 -2
- package/dist/src/lib/csv.js +3 -8
- package/dist/src/lib/csv.js.map +1 -1
- package/dist/src/lib/db-codegen/dbGenerator.d.ts +35 -7
- package/dist/src/lib/db-codegen/dbGenerator.js +384 -125
- package/dist/src/lib/db-codegen/dbGenerator.js.map +1 -1
- package/dist/src/lib/db-codegen/dbNaming.d.ts +29 -0
- package/dist/src/lib/db-codegen/dbNaming.js +58 -0
- package/dist/src/lib/db-codegen/dbNaming.js.map +1 -1
- package/dist/src/lib/db-codegen/dbTemplates.d.ts +114 -5
- package/dist/src/lib/db-codegen/dbTemplates.js +163 -16
- package/dist/src/lib/db-codegen/dbTemplates.js.map +1 -1
- package/dist/src/lib/db-codegen/dbTsTypes.d.ts +7 -3
- package/dist/src/lib/db-codegen/dbTsTypes.js +23 -1
- package/dist/src/lib/db-codegen/dbTsTypes.js.map +1 -1
- package/dist/src/lib/generated-allowlist.js +43 -0
- package/dist/src/lib/generated-allowlist.js.map +1 -1
- package/dist/src/lib/init-config.js +2 -2
- package/dist/src/lib/init-config.js.map +1 -1
- package/dist/src/lib/output.d.ts +25 -5
- package/dist/src/lib/output.js +32 -4
- package/dist/src/lib/output.js.map +1 -1
- package/dist/src/lib/query-operators.d.ts +43 -0
- package/dist/src/lib/query-operators.js +80 -0
- package/dist/src/lib/query-operators.js.map +1 -0
- package/dist/src/lib/toml-database-config.d.ts +10 -19
- package/dist/src/lib/toml-database-config.js +28 -59
- package/dist/src/lib/toml-database-config.js.map +1 -1
- package/dist/src/lib/toml-metadata-config.d.ts +147 -0
- package/dist/src/lib/toml-metadata-config.js +463 -0
- package/dist/src/lib/toml-metadata-config.js.map +1 -0
- package/dist/src/lib/toml-native-form.d.ts +46 -0
- package/dist/src/lib/toml-native-form.js +78 -0
- package/dist/src/lib/toml-native-form.js.map +1 -0
- package/dist/src/lib/toml-params-validator.d.ts +34 -0
- package/dist/src/lib/toml-params-validator.js +118 -3
- package/dist/src/lib/toml-params-validator.js.map +1 -1
- package/dist/src/lib/workflow-apply.d.ts +86 -0
- package/dist/src/lib/workflow-apply.js +127 -0
- package/dist/src/lib/workflow-apply.js.map +1 -0
- package/dist/src/lib/workflow-codegen/generated-schema-descriptor.d.ts +129 -0
- package/dist/src/lib/workflow-codegen/generated-schema-descriptor.js +269 -0
- package/dist/src/lib/workflow-codegen/generated-schema-descriptor.js.map +1 -0
- package/dist/src/lib/workflow-codegen/generator.d.ts +74 -0
- package/dist/src/lib/workflow-codegen/generator.js +215 -0
- package/dist/src/lib/workflow-codegen/generator.js.map +1 -0
- package/dist/src/lib/workflow-codegen/naming.d.ts +33 -0
- package/dist/src/lib/workflow-codegen/naming.js +81 -0
- package/dist/src/lib/workflow-codegen/naming.js.map +1 -0
- package/dist/src/lib/workflow-codegen/schemaToTs.d.ts +64 -0
- package/dist/src/lib/workflow-codegen/schemaToTs.js +282 -0
- package/dist/src/lib/workflow-codegen/schemaToTs.js.map +1 -0
- package/dist/src/lib/workflow-fragments.js +3 -3
- package/dist/src/lib/workflow-fragments.js.map +1 -1
- package/dist/src/lib/workflow-payload.d.ts +68 -0
- package/dist/src/lib/workflow-payload.js +150 -0
- package/dist/src/lib/workflow-payload.js.map +1 -0
- package/dist/src/lib/workflow-toml-validator.d.ts +1 -1
- package/dist/src/lib/workflow-toml-validator.js +37 -1
- package/dist/src/lib/workflow-toml-validator.js.map +1 -1
- package/dist/src/types/index.d.ts +11 -0
- package/dist/src/validators.d.ts +4 -3
- package/dist/src/validators.js +6 -5
- package/dist/src/validators.js.map +1 -1
- package/package.json +5 -3
|
@@ -29,6 +29,35 @@ export declare function resolveRecordInterfaceName(modelName: string, classNameO
|
|
|
29
29
|
export declare function opParamsInterfaceName(opName: string): string;
|
|
30
30
|
/** `saveAccount` → `SaveAccountResult`. */
|
|
31
31
|
export declare function opResultAliasName(opName: string): string;
|
|
32
|
+
/**
|
|
33
|
+
* Name of the generated typed-operations factory for a database type (#1441).
|
|
34
|
+
* `securities-ref` → `securitiesRefOps`, `portfolio` → `portfolioOps`. A type
|
|
35
|
+
* whose camelCased name would start with a digit (e.g. `2fa`) gets a leading
|
|
36
|
+
* `_` so the emitted `export function` name is a valid JS identifier.
|
|
37
|
+
*/
|
|
38
|
+
export declare function opsFactoryName(databaseType: string): string;
|
|
39
|
+
/**
|
|
40
|
+
* camelCase an identifier: splits on non-alphanumeric separators, lower-cases
|
|
41
|
+
* the first segment's first char and PascalCases the rest
|
|
42
|
+
* (`securities-ref` → `securitiesRef`, `save_account` → `saveAccount`). Existing
|
|
43
|
+
* internal casing after the first char is preserved.
|
|
44
|
+
*/
|
|
45
|
+
export declare function camelCase(name: string): string;
|
|
46
|
+
/**
|
|
47
|
+
* Render an operation name as an object-literal property key (#1441). A name
|
|
48
|
+
* that is a plain, non-reserved JS identifier is emitted bare (`getX:`);
|
|
49
|
+
* anything else — a hyphen, a leading digit, or a reserved word — is emitted as
|
|
50
|
+
* a quoted key (`"get-x":`, `"delete":`) so the factory stays valid TypeScript.
|
|
51
|
+
* The op-name string passed to `executeOperation` is always the exact original
|
|
52
|
+
* name.
|
|
53
|
+
*
|
|
54
|
+
* `__proto__` is a special case. The factory return value is a *runtime* object
|
|
55
|
+
* literal, and in that position both the bare `__proto__:` form AND the quoted
|
|
56
|
+
* `"__proto__":` form set the object's prototype instead of defining an own
|
|
57
|
+
* method — silently dropping that operation. Only a computed key
|
|
58
|
+
* (`["__proto__"]:`) defines a normal own property, so emit that form.
|
|
59
|
+
*/
|
|
60
|
+
export declare function opPropertyKey(opName: string): string;
|
|
32
61
|
/**
|
|
33
62
|
* Convert a snake_case plural model name (`user_prefs`, `categories`) into a
|
|
34
63
|
* PascalCase singular interface name (`UserPref`, `Category`). Returns null
|
|
@@ -43,6 +43,64 @@ export function opParamsInterfaceName(opName) {
|
|
|
43
43
|
export function opResultAliasName(opName) {
|
|
44
44
|
return `${pascalCase(opName)}Result`;
|
|
45
45
|
}
|
|
46
|
+
/**
|
|
47
|
+
* Name of the generated typed-operations factory for a database type (#1441).
|
|
48
|
+
* `securities-ref` → `securitiesRefOps`, `portfolio` → `portfolioOps`. A type
|
|
49
|
+
* whose camelCased name would start with a digit (e.g. `2fa`) gets a leading
|
|
50
|
+
* `_` so the emitted `export function` name is a valid JS identifier.
|
|
51
|
+
*/
|
|
52
|
+
export function opsFactoryName(databaseType) {
|
|
53
|
+
const base = camelCase(databaseType);
|
|
54
|
+
const safe = /^[0-9]/.test(base) ? `_${base}` : base;
|
|
55
|
+
return `${safe}Ops`;
|
|
56
|
+
}
|
|
57
|
+
/**
|
|
58
|
+
* camelCase an identifier: splits on non-alphanumeric separators, lower-cases
|
|
59
|
+
* the first segment's first char and PascalCases the rest
|
|
60
|
+
* (`securities-ref` → `securitiesRef`, `save_account` → `saveAccount`). Existing
|
|
61
|
+
* internal casing after the first char is preserved.
|
|
62
|
+
*/
|
|
63
|
+
export function camelCase(name) {
|
|
64
|
+
const pascal = pascalCase(name);
|
|
65
|
+
if (pascal.length === 0)
|
|
66
|
+
return pascal;
|
|
67
|
+
return pascal.charAt(0).toLowerCase() + pascal.slice(1);
|
|
68
|
+
}
|
|
69
|
+
/**
|
|
70
|
+
* JS reserved words. Used as object-literal property keys these are actually
|
|
71
|
+
* legal unquoted, but quoting them keeps the generated output unambiguous and
|
|
72
|
+
* matches the "non-identifier op name -> quoted key" behavior (#1441).
|
|
73
|
+
*/
|
|
74
|
+
const RESERVED_WORDS = new Set([
|
|
75
|
+
"break", "case", "catch", "class", "const", "continue", "debugger",
|
|
76
|
+
"default", "delete", "do", "else", "enum", "export", "extends", "false",
|
|
77
|
+
"finally", "for", "function", "if", "import", "in", "instanceof", "new",
|
|
78
|
+
"null", "return", "super", "switch", "this", "throw", "true", "try",
|
|
79
|
+
"typeof", "var", "void", "while", "with", "yield", "let", "static",
|
|
80
|
+
"implements", "interface", "package", "private", "protected", "public",
|
|
81
|
+
]);
|
|
82
|
+
/**
|
|
83
|
+
* Render an operation name as an object-literal property key (#1441). A name
|
|
84
|
+
* that is a plain, non-reserved JS identifier is emitted bare (`getX:`);
|
|
85
|
+
* anything else — a hyphen, a leading digit, or a reserved word — is emitted as
|
|
86
|
+
* a quoted key (`"get-x":`, `"delete":`) so the factory stays valid TypeScript.
|
|
87
|
+
* The op-name string passed to `executeOperation` is always the exact original
|
|
88
|
+
* name.
|
|
89
|
+
*
|
|
90
|
+
* `__proto__` is a special case. The factory return value is a *runtime* object
|
|
91
|
+
* literal, and in that position both the bare `__proto__:` form AND the quoted
|
|
92
|
+
* `"__proto__":` form set the object's prototype instead of defining an own
|
|
93
|
+
* method — silently dropping that operation. Only a computed key
|
|
94
|
+
* (`["__proto__"]:`) defines a normal own property, so emit that form.
|
|
95
|
+
*/
|
|
96
|
+
export function opPropertyKey(opName) {
|
|
97
|
+
if (opName === "__proto__")
|
|
98
|
+
return `[${JSON.stringify(opName)}]`;
|
|
99
|
+
const isPlainIdentifier = /^[A-Za-z_$][A-Za-z0-9_$]*$/.test(opName);
|
|
100
|
+
if (isPlainIdentifier && !RESERVED_WORDS.has(opName))
|
|
101
|
+
return opName;
|
|
102
|
+
return JSON.stringify(opName);
|
|
103
|
+
}
|
|
46
104
|
/**
|
|
47
105
|
* Convert a snake_case plural model name (`user_prefs`, `categories`) into a
|
|
48
106
|
* PascalCase singular interface name (`UserPref`, `Category`). Returns null
|
|
@@ -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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SACxD,IAAI,CAAC,EAAE,CAAC,CAAC;AACd,CAAC"}
|
|
@@ -11,7 +11,12 @@
|
|
|
11
11
|
* classes — so we emit plain `export interface` types with no class
|
|
12
12
|
* shell, no barrel registration, and `import type` only.
|
|
13
13
|
* 2. We add an OPERATIONS half codegen-v2 has no analog for: per-op
|
|
14
|
-
* input-params interfaces + per-op result aliases
|
|
14
|
+
* input-params interfaces + per-op result aliases. The alias for an op
|
|
15
|
+
* is derived from `op.type` AND, where it matters, the op's parsed
|
|
16
|
+
* `definition`: a query op's `projection` (#1439), a mutation op's step
|
|
17
|
+
* kinds (#1438), and a pipeline op's `return` step (#1437). The generator
|
|
18
|
+
* resolves those into the small descriptors below; the templates stay pure
|
|
19
|
+
* string-emitters.
|
|
15
20
|
*/
|
|
16
21
|
/** A field on a record interface (read shape). */
|
|
17
22
|
export interface RecordField {
|
|
@@ -42,7 +47,7 @@ export interface RenderRecordInterfaceInput {
|
|
|
42
47
|
/** One declared param on an op-input interface (write shape). */
|
|
43
48
|
export interface ParamField {
|
|
44
49
|
name: string;
|
|
45
|
-
/** TOML param type (`string|number|boolean|object`). */
|
|
50
|
+
/** TOML param type (`string|number|boolean|object|array`). */
|
|
46
51
|
type: string;
|
|
47
52
|
required: boolean;
|
|
48
53
|
/**
|
|
@@ -51,6 +56,13 @@ export interface ParamField {
|
|
|
51
56
|
* renders the union when present and falls back to the base type otherwise.
|
|
52
57
|
*/
|
|
53
58
|
enum?: string[];
|
|
59
|
+
/**
|
|
60
|
+
* Scalar element type for an `array` param (#1488), either declared
|
|
61
|
+
* (`type = "array"` + `items = "..."`) or inferred from a `$in`/`$nin`
|
|
62
|
+
* binding. Undefined on a non-array param, or on an array whose element type
|
|
63
|
+
* could not be resolved (renders `unknown[]`).
|
|
64
|
+
*/
|
|
65
|
+
items?: string;
|
|
54
66
|
}
|
|
55
67
|
export interface RenderOpParamsInterfaceInput {
|
|
56
68
|
/** PascalCase params interface name (e.g. `SaveAccountParams`). */
|
|
@@ -59,6 +71,42 @@ export interface RenderOpParamsInterfaceInput {
|
|
|
59
71
|
opName: string;
|
|
60
72
|
params: ParamField[];
|
|
61
73
|
}
|
|
74
|
+
/**
|
|
75
|
+
* How a query op's static `projection` narrows its record type (#1439). The
|
|
76
|
+
* generator resolves the projection against the model's record fields (guarding
|
|
77
|
+
* unknown / nested keys) and hands the template one of these; the template only
|
|
78
|
+
* assembles the `Pick`/`Partial` string.
|
|
79
|
+
* - `full` → `QueryResult<M>` (no projection, empty `{}`, or no schema).
|
|
80
|
+
* - `pick` → `QueryResult<Pick<M, ...fields>>` (inclusion; `id` folded in).
|
|
81
|
+
* - `partial` → `QueryResult<Partial<M>>` (dynamic / mixed / unknown-key, and
|
|
82
|
+
* exclusion — the DO runtime does not strip excluded fields yet,
|
|
83
|
+
* so an `Omit` would hide fields still returned; #1439/Codex-P2).
|
|
84
|
+
*/
|
|
85
|
+
export type ProjectionClassification = {
|
|
86
|
+
kind: "full";
|
|
87
|
+
} | {
|
|
88
|
+
kind: "pick";
|
|
89
|
+
fields: string[];
|
|
90
|
+
} | {
|
|
91
|
+
kind: "partial";
|
|
92
|
+
};
|
|
93
|
+
/**
|
|
94
|
+
* A `pipeline` op's resolved `return` step (#1437). The runtime flattens a
|
|
95
|
+
* returning pipeline to the returned step's shape, so codegen types it as that
|
|
96
|
+
* step's result. `return: "all"`, no `return`, or any step the generator can't
|
|
97
|
+
* resolve fall back to `opaque` → the generic `PipelineResult`.
|
|
98
|
+
*/
|
|
99
|
+
export type PipelineReturnDescriptor = {
|
|
100
|
+
kind: "query";
|
|
101
|
+
recordInterfaceName: string | null;
|
|
102
|
+
projection?: ProjectionClassification;
|
|
103
|
+
} | {
|
|
104
|
+
kind: "count";
|
|
105
|
+
} | {
|
|
106
|
+
kind: "aggregate";
|
|
107
|
+
} | {
|
|
108
|
+
kind: "opaque";
|
|
109
|
+
};
|
|
62
110
|
export interface RenderOpResultAliasInput {
|
|
63
111
|
/** Per-op result alias name (e.g. `SaveAccountResult`). */
|
|
64
112
|
aliasName: string;
|
|
@@ -72,9 +120,24 @@ export interface RenderOpResultAliasInput {
|
|
|
72
120
|
* interface (e.g. pipeline) — falls back to `QueryResult<Record<string, unknown>>`.
|
|
73
121
|
*/
|
|
74
122
|
recordInterfaceName: string | null;
|
|
123
|
+
/**
|
|
124
|
+
* For `query` ops (#1439), how the op's `projection` narrows the record type.
|
|
125
|
+
* Absent → treated as `full`.
|
|
126
|
+
*/
|
|
127
|
+
projection?: ProjectionClassification;
|
|
128
|
+
/**
|
|
129
|
+
* For `pipeline` ops (#1437), the resolved `return`-step descriptor. Absent
|
|
130
|
+
* or `opaque` → the generic `PipelineResult`.
|
|
131
|
+
*/
|
|
132
|
+
pipelineReturn?: PipelineReturnDescriptor;
|
|
75
133
|
}
|
|
76
|
-
/**
|
|
77
|
-
|
|
134
|
+
/**
|
|
135
|
+
* The shared generic result shapes referenced by the per-op aliases. These
|
|
136
|
+
* mirror the runtime result shapes produced by the database-operations
|
|
137
|
+
* controller; per-op aliases point at them (and, where the definition makes the
|
|
138
|
+
* shape derivable, at a narrowed form — see `renderOpResultAlias`).
|
|
139
|
+
*/
|
|
140
|
+
export declare const RESULT_ALIASES_BLOCK = "// Generic per-op result shapes. These mirror the runtime result shapes\n// produced by the database-operations controller; per-op aliases reference\n// them (or a narrowed form when the op definition makes the shape derivable).\n\n/** `query` ops return a page of records. */\nexport interface QueryResult<T = Record<string, unknown>> {\n data: T[];\n hasMore?: boolean;\n nextCursor?: string;\n}\n\n/**\n * One step's result inside a `mutation` op's uniform response (#1458).\n * `op` is the step kind; `id` is the record id (the resolved canonical id for\n * `upsertOn` saves). `values` carries an `increment` step's post-increment\n * counters; `error` a per-step failure string.\n */\nexport interface MutationStepResult {\n op: \"save\" | \"patch\" | \"delete\" | \"increment\" | \"addToSet\" | \"removeFromSet\";\n success: boolean;\n id: string;\n values?: Record<string, number>;\n error?: string;\n}\n\n/**\n * Every `mutation` op returns a uniform `{ results: MutationStepResult[] }`\n * in DEFINITION-STEP order \u2014 one entry per step, tagged with its `op` kind and\n * record `id` (#1458). This is a SUCCESS-PATH guarantee: a step that fails at\n * the HTTP level surfaces as an error, and committed sibling writes in the same\n * op are not reported (the ops are not yet executed atomically \u2014 see #1478).\n */\nexport interface MutationResult {\n results: MutationStepResult[];\n}\n\n/** `count` ops return a single count. */\nexport interface CountResult {\n count: number;\n}\n\n/** `aggregate` ops return a single result object. */\nexport interface AggregateResult {\n result: Record<string, unknown>;\n}\n\n/** `applyToQuery` ops return match/affect/fail counts. */\nexport interface ApplyToQueryResult {\n matched: number;\n affected: number;\n failed: number;\n sample?: unknown[];\n}\n\n/** `pipeline` ops return per-step results keyed by step name. */\nexport interface PipelineResult {\n steps: Record<string, unknown>;\n}\n";
|
|
78
141
|
/**
|
|
79
142
|
* Render the header (banner + regen hint + fingerprint).
|
|
80
143
|
*/
|
|
@@ -92,6 +155,52 @@ export declare function renderRecordInterface(input: RenderRecordInterfaceInput)
|
|
|
92
155
|
*/
|
|
93
156
|
export declare function renderOpParamsInterface(input: RenderOpParamsInterfaceInput): string;
|
|
94
157
|
/**
|
|
95
|
-
* Render a per-op result alias
|
|
158
|
+
* Render a per-op result alias. The alias is derived from `op.type` and, where
|
|
159
|
+
* the shape is derivable from the parsed op definition, a narrowed form:
|
|
160
|
+
* - `query` → `QueryResult<M>`, narrowed by the op `projection` (#1439).
|
|
161
|
+
* - `mutation` → `MutationResult` — every mutation op returns the uniform
|
|
162
|
+
* `{ results: MutationStepResult[] }` in definition order (#1458).
|
|
163
|
+
* - `pipeline` → the returned step's result type (#1437); `return: "all"` /
|
|
164
|
+
* no-return / unresolvable keep the generic `PipelineResult`.
|
|
96
165
|
*/
|
|
97
166
|
export declare function renderOpResultAlias(input: RenderOpResultAliasInput): string;
|
|
167
|
+
/** One operation the typed-ops factory exposes as a method (#1441). */
|
|
168
|
+
export interface OpsFactoryOp {
|
|
169
|
+
/**
|
|
170
|
+
* Object-literal property key for the method — bare (`getX`) for a plain JS
|
|
171
|
+
* identifier, or a quoted string (`"get-x"`, `"delete"`) for a hyphenated /
|
|
172
|
+
* reserved-word / leading-digit op name. Produced by `opPropertyKey`.
|
|
173
|
+
*/
|
|
174
|
+
propertyKey: string;
|
|
175
|
+
/** Exact operation name passed as the `executeOperation` string argument. */
|
|
176
|
+
opName: string;
|
|
177
|
+
/** The op's `<Op>Params` interface name (write shape). */
|
|
178
|
+
paramsInterfaceName: string;
|
|
179
|
+
/** The op's `<Op>Result` alias name (read shape). */
|
|
180
|
+
resultAliasName: string;
|
|
181
|
+
/**
|
|
182
|
+
* Whether the op declares any params. A param-less op yields a method callable
|
|
183
|
+
* with no arguments (`ops.foo()`); its only arg is the optional `options`.
|
|
184
|
+
*/
|
|
185
|
+
hasParams: boolean;
|
|
186
|
+
}
|
|
187
|
+
export interface RenderOpsFactoryInput {
|
|
188
|
+
/** Factory function name (e.g. `securitiesRefOps`). */
|
|
189
|
+
factoryName: string;
|
|
190
|
+
/** Database type name, for the doc comment. */
|
|
191
|
+
databaseType: string;
|
|
192
|
+
/** Operations to expose, in deterministic (name-sorted) order. */
|
|
193
|
+
ops: OpsFactoryOp[];
|
|
194
|
+
}
|
|
195
|
+
/**
|
|
196
|
+
* Render the typed-operations factory (#1441): an inlined structural client
|
|
197
|
+
* interface + a shared call-options type + the `export function <type>Ops`
|
|
198
|
+
* factory. Each method pairs an op's `<Op>Params` input with its `<Op>Result`
|
|
199
|
+
* output and calls `client.databases.executeOperation<<Op>Result>(...)`, so the
|
|
200
|
+
* generated code carries no `as` cast and no import — the real `JsBaoClient`
|
|
201
|
+
* satisfies the structural `OpsClient` param.
|
|
202
|
+
*
|
|
203
|
+
* Returns "" for a database type with no operations, so the caller can omit the
|
|
204
|
+
* factory entirely rather than emit an empty function.
|
|
205
|
+
*/
|
|
206
|
+
export declare function renderOpsFactory(input: RenderOpsFactoryInput): string;
|
|
@@ -11,15 +11,25 @@
|
|
|
11
11
|
* classes — so we emit plain `export interface` types with no class
|
|
12
12
|
* shell, no barrel registration, and `import type` only.
|
|
13
13
|
* 2. We add an OPERATIONS half codegen-v2 has no analog for: per-op
|
|
14
|
-
* input-params interfaces + per-op result aliases
|
|
14
|
+
* input-params interfaces + per-op result aliases. The alias for an op
|
|
15
|
+
* is derived from `op.type` AND, where it matters, the op's parsed
|
|
16
|
+
* `definition`: a query op's `projection` (#1439), a mutation op's step
|
|
17
|
+
* kinds (#1438), and a pipeline op's `return` step (#1437). The generator
|
|
18
|
+
* resolves those into the small descriptors below; the templates stay pure
|
|
19
|
+
* string-emitters.
|
|
15
20
|
*/
|
|
16
21
|
import { tsTypeForDbField, tsTypeForDbParamType } from "./dbTsTypes.js";
|
|
17
22
|
const HEADER_BANNER = "// AUTO-GENERATED FROM database-types TOML — DO NOT EDIT.";
|
|
18
23
|
const REGEN_INSTRUCTION = "// Run `primitive databases codegen <database-type>` to regenerate.";
|
|
19
|
-
/**
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
24
|
+
/**
|
|
25
|
+
* The shared generic result shapes referenced by the per-op aliases. These
|
|
26
|
+
* mirror the runtime result shapes produced by the database-operations
|
|
27
|
+
* controller; per-op aliases point at them (and, where the definition makes the
|
|
28
|
+
* shape derivable, at a narrowed form — see `renderOpResultAlias`).
|
|
29
|
+
*/
|
|
30
|
+
export const RESULT_ALIASES_BLOCK = `// Generic per-op result shapes. These mirror the runtime result shapes
|
|
31
|
+
// produced by the database-operations controller; per-op aliases reference
|
|
32
|
+
// them (or a narrowed form when the op definition makes the shape derivable).
|
|
23
33
|
|
|
24
34
|
/** \`query\` ops return a page of records. */
|
|
25
35
|
export interface QueryResult<T = Record<string, unknown>> {
|
|
@@ -28,9 +38,29 @@ export interface QueryResult<T = Record<string, unknown>> {
|
|
|
28
38
|
nextCursor?: string;
|
|
29
39
|
}
|
|
30
40
|
|
|
31
|
-
/**
|
|
41
|
+
/**
|
|
42
|
+
* One step's result inside a \`mutation\` op's uniform response (#1458).
|
|
43
|
+
* \`op\` is the step kind; \`id\` is the record id (the resolved canonical id for
|
|
44
|
+
* \`upsertOn\` saves). \`values\` carries an \`increment\` step's post-increment
|
|
45
|
+
* counters; \`error\` a per-step failure string.
|
|
46
|
+
*/
|
|
47
|
+
export interface MutationStepResult {
|
|
48
|
+
op: "save" | "patch" | "delete" | "increment" | "addToSet" | "removeFromSet";
|
|
49
|
+
success: boolean;
|
|
50
|
+
id: string;
|
|
51
|
+
values?: Record<string, number>;
|
|
52
|
+
error?: string;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
/**
|
|
56
|
+
* Every \`mutation\` op returns a uniform \`{ results: MutationStepResult[] }\`
|
|
57
|
+
* in DEFINITION-STEP order — one entry per step, tagged with its \`op\` kind and
|
|
58
|
+
* record \`id\` (#1458). This is a SUCCESS-PATH guarantee: a step that fails at
|
|
59
|
+
* the HTTP level surfaces as an error, and committed sibling writes in the same
|
|
60
|
+
* op are not reported (the ops are not yet executed atomically — see #1478).
|
|
61
|
+
*/
|
|
32
62
|
export interface MutationResult {
|
|
33
|
-
results:
|
|
63
|
+
results: MutationStepResult[];
|
|
34
64
|
}
|
|
35
65
|
|
|
36
66
|
/** \`count\` ops return a single count. */
|
|
@@ -125,22 +155,57 @@ export function renderOpParamsInterface(input) {
|
|
|
125
155
|
lines.push(`export interface ${interfaceName} {`);
|
|
126
156
|
for (const p of params) {
|
|
127
157
|
const optional = p.required ? "" : "?";
|
|
128
|
-
lines.push(` ${p.name}${optional}: ${tsTypeForDbParamType(p.type, p.enum)};`);
|
|
158
|
+
lines.push(` ${p.name}${optional}: ${tsTypeForDbParamType(p.type, p.enum, p.items)};`);
|
|
129
159
|
}
|
|
130
160
|
lines.push(`}`);
|
|
131
161
|
return lines.join("\n");
|
|
132
162
|
}
|
|
133
163
|
/**
|
|
134
|
-
*
|
|
164
|
+
* Compute the generic argument for a `QueryResult<...>` from the op's record
|
|
165
|
+
* interface + projection classification (#1439). Reused for a pipeline op's
|
|
166
|
+
* returning `query` step (#1437), so both type identically to a plain query.
|
|
167
|
+
*
|
|
168
|
+
* A null record interface (the op's model has no `[models.*]` schema) has
|
|
169
|
+
* nothing to `Pick` from, so it always falls back to
|
|
170
|
+
* `Record<string, unknown>` regardless of any projection.
|
|
171
|
+
*/
|
|
172
|
+
function queryResultGeneric(recordInterfaceName, projection) {
|
|
173
|
+
if (recordInterfaceName === null)
|
|
174
|
+
return "Record<string, unknown>";
|
|
175
|
+
const p = projection ?? { kind: "full" };
|
|
176
|
+
switch (p.kind) {
|
|
177
|
+
case "full":
|
|
178
|
+
return recordInterfaceName;
|
|
179
|
+
case "partial":
|
|
180
|
+
return `Partial<${recordInterfaceName}>`;
|
|
181
|
+
case "pick": {
|
|
182
|
+
// The generator guarantees a non-empty, field-guarded, sorted list; a
|
|
183
|
+
// defensive empty check keeps this total. Field names are emitted as TS
|
|
184
|
+
// string literals via JSON.stringify.
|
|
185
|
+
if (p.fields.length === 0)
|
|
186
|
+
return recordInterfaceName;
|
|
187
|
+
const members = p.fields.map((f) => JSON.stringify(f)).join(" | ");
|
|
188
|
+
return `Pick<${recordInterfaceName}, ${members}>`;
|
|
189
|
+
}
|
|
190
|
+
}
|
|
191
|
+
}
|
|
192
|
+
/**
|
|
193
|
+
* Render a per-op result alias. The alias is derived from `op.type` and, where
|
|
194
|
+
* the shape is derivable from the parsed op definition, a narrowed form:
|
|
195
|
+
* - `query` → `QueryResult<M>`, narrowed by the op `projection` (#1439).
|
|
196
|
+
* - `mutation` → `MutationResult` — every mutation op returns the uniform
|
|
197
|
+
* `{ results: MutationStepResult[] }` in definition order (#1458).
|
|
198
|
+
* - `pipeline` → the returned step's result type (#1437); `return: "all"` /
|
|
199
|
+
* no-return / unresolvable keep the generic `PipelineResult`.
|
|
135
200
|
*/
|
|
136
201
|
export function renderOpResultAlias(input) {
|
|
137
|
-
const { aliasName, opType, recordInterfaceName } = input;
|
|
202
|
+
const { aliasName, opType, recordInterfaceName, projection } = input;
|
|
138
203
|
switch (opType) {
|
|
139
|
-
case "query":
|
|
140
|
-
|
|
141
|
-
return `export type ${aliasName} = QueryResult<${generic}>;`;
|
|
142
|
-
}
|
|
204
|
+
case "query":
|
|
205
|
+
return `export type ${aliasName} = QueryResult<${queryResultGeneric(recordInterfaceName, projection)}>;`;
|
|
143
206
|
case "mutation":
|
|
207
|
+
// Every mutation op returns the uniform `{ results: MutationStepResult[] }`
|
|
208
|
+
// in definition-step order (#1458) — no more per-category flat shapes.
|
|
144
209
|
return `export type ${aliasName} = MutationResult;`;
|
|
145
210
|
case "count":
|
|
146
211
|
return `export type ${aliasName} = CountResult;`;
|
|
@@ -148,12 +213,94 @@ export function renderOpResultAlias(input) {
|
|
|
148
213
|
return `export type ${aliasName} = AggregateResult;`;
|
|
149
214
|
case "applyToQuery":
|
|
150
215
|
return `export type ${aliasName} = ApplyToQueryResult;`;
|
|
151
|
-
case "pipeline":
|
|
152
|
-
|
|
216
|
+
case "pipeline": {
|
|
217
|
+
const d = input.pipelineReturn ?? { kind: "opaque" };
|
|
218
|
+
switch (d.kind) {
|
|
219
|
+
case "query":
|
|
220
|
+
return `export type ${aliasName} = QueryResult<${queryResultGeneric(d.recordInterfaceName, d.projection)}>;`;
|
|
221
|
+
case "count":
|
|
222
|
+
return `export type ${aliasName} = CountResult;`;
|
|
223
|
+
case "aggregate":
|
|
224
|
+
return `export type ${aliasName} = AggregateResult;`;
|
|
225
|
+
// `opaque` — `return: "all"`, no `return`, or a step the generator
|
|
226
|
+
// couldn't resolve — keeps the generic `PipelineResult` (unchanged).
|
|
227
|
+
case "opaque":
|
|
228
|
+
default:
|
|
229
|
+
return `export type ${aliasName} = PipelineResult;`;
|
|
230
|
+
}
|
|
231
|
+
}
|
|
153
232
|
default:
|
|
154
233
|
// Unknown op type — emit a permissive alias rather than throwing,
|
|
155
234
|
// so one stray op doesn't block codegen for the whole file.
|
|
156
235
|
return `export type ${aliasName} = unknown;`;
|
|
157
236
|
}
|
|
158
237
|
}
|
|
238
|
+
/**
|
|
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.
|
|
248
|
+
*/
|
|
249
|
+
export function renderOpsFactory(input) {
|
|
250
|
+
const { factoryName, databaseType, ops } = input;
|
|
251
|
+
if (ops.length === 0)
|
|
252
|
+
return "";
|
|
253
|
+
const clientInterface = [
|
|
254
|
+
"// Minimal structural client shape — inlined so this file stays import-free",
|
|
255
|
+
"// and carries no runtime dependency on the client package. The real",
|
|
256
|
+
"// `JsBaoClient` satisfies it structurally.",
|
|
257
|
+
"interface OpsClient {",
|
|
258
|
+
" 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>;",
|
|
272
|
+
" };",
|
|
273
|
+
"}",
|
|
274
|
+
].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) => {
|
|
286
|
+
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
|
+
// No declared params: the method takes only the optional options object, so
|
|
292
|
+
// 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 }),`);
|
|
295
|
+
});
|
|
296
|
+
const factory = [
|
|
297
|
+
`/** Typed accessor for \`${databaseType}\` operations. */`,
|
|
298
|
+
`export function ${factoryName}(client: OpsClient, databaseId: string) {`,
|
|
299
|
+
" return {",
|
|
300
|
+
...methodLines,
|
|
301
|
+
" };",
|
|
302
|
+
"}",
|
|
303
|
+
].join("\n");
|
|
304
|
+
return [clientInterface, optionsType, factory].join("\n\n");
|
|
305
|
+
}
|
|
159
306
|
//# sourceMappingURL=dbTemplates.js.map
|
|
@@ -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;;;;;;;;;;;;;;;;;;;GAmBG;AAEH,OAAO,EAAE,gBAAgB,EAAE,oBAAoB,EAAE,MAAM,gBAAgB,CAAC;AAExE,MAAM,aAAa,GACjB,2DAA2D,CAAC;AA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| "id" | "stringset";
|
|
36
|
-
/**
|
|
37
|
-
|
|
36
|
+
/**
|
|
37
|
+
* Param types accepted in an `[[operations]]` `params` block. `array` (#1488)
|
|
38
|
+
* carries a scalar `items` element type; `integer` (also surfaced in #1488 when
|
|
39
|
+
* reconciling the registration/runtime type lists) maps to `number`.
|
|
40
|
+
*/
|
|
41
|
+
export type DbParamType = "string" | "number" | "boolean" | "integer" | "object" | "array";
|
|
38
42
|
/**
|
|
39
43
|
* Returns the TS type expression for a record field type. Unknown types
|
|
40
44
|
* fall back to `unknown` rather than throwing: the database-type TOML is
|
|
@@ -75,4 +79,4 @@ export declare function tsTypeForDbField(fieldType: string, enumValues?: string[
|
|
|
75
79
|
* the base type for a non-string param or an empty enum rather than throwing —
|
|
76
80
|
* the server is the source of truth for rejecting a malformed param `enum`.
|
|
77
81
|
*/
|
|
78
|
-
export declare function tsTypeForDbParamType(paramType: string, enumValues?: string[]): string;
|
|
82
|
+
export declare function tsTypeForDbParamType(paramType: string, enumValues?: string[], items?: string): string;
|
|
@@ -90,7 +90,28 @@ export function tsTypeForDbField(fieldType, enumValues) {
|
|
|
90
90
|
* the base type for a non-string param or an empty enum rather than throwing —
|
|
91
91
|
* the server is the source of truth for rejecting a malformed param `enum`.
|
|
92
92
|
*/
|
|
93
|
-
export function tsTypeForDbParamType(paramType, enumValues) {
|
|
93
|
+
export function tsTypeForDbParamType(paramType, enumValues, items) {
|
|
94
|
+
// Array param (#1488): a declared `type = "array"` (Phase 2) or one inferred
|
|
95
|
+
// from a `$in`/`$nin` binding (Phase 1). `items` is the scalar element type;
|
|
96
|
+
// a per-element `enum` on a string-element array renders `("a" | "b")[]`.
|
|
97
|
+
// A missing/unresolved `items` renders `unknown[]` (the conservative widen).
|
|
98
|
+
if (paramType === "array") {
|
|
99
|
+
let elem;
|
|
100
|
+
if (items === "string" &&
|
|
101
|
+
Array.isArray(enumValues) &&
|
|
102
|
+
enumValues.length > 0) {
|
|
103
|
+
elem = `(${tsUnionFromEnum(enumValues)})`;
|
|
104
|
+
}
|
|
105
|
+
else if (items) {
|
|
106
|
+
// Element type is always scalar here, so the recursion never re-enters
|
|
107
|
+
// this array branch.
|
|
108
|
+
elem = tsTypeForDbParamType(items);
|
|
109
|
+
}
|
|
110
|
+
else {
|
|
111
|
+
elem = "unknown";
|
|
112
|
+
}
|
|
113
|
+
return `${elem}[]`;
|
|
114
|
+
}
|
|
94
115
|
if (paramType === "string" &&
|
|
95
116
|
Array.isArray(enumValues) &&
|
|
96
117
|
enumValues.length > 0) {
|
|
@@ -100,6 +121,7 @@ export function tsTypeForDbParamType(paramType, enumValues) {
|
|
|
100
121
|
case "string":
|
|
101
122
|
return "string";
|
|
102
123
|
case "number":
|
|
124
|
+
case "integer":
|
|
103
125
|
return "number";
|
|
104
126
|
case "boolean":
|
|
105
127
|
return "boolean";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"dbTsTypes.js","sourceRoot":"","sources":["../../../../src/lib/db-codegen/dbTsTypes.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;
|
|
1
|
+
{"version":3,"file":"dbTsTypes.js","sourceRoot":"","sources":["../../../../src/lib/db-codegen/dbTsTypes.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AA8BH;;;;;;GAMG;AACH,MAAM,UAAU,oBAAoB,CAAC,SAAiB;IACpD,QAAQ,SAAS,EAAE,CAAC;QAClB,KAAK,QAAQ,CAAC;QACd,KAAK,IAAI,CAAC;QACV,KAAK,MAAM;YACT,OAAO,QAAQ,CAAC;QAClB,KAAK,QAAQ;YACX,OAAO,QAAQ,CAAC;QAClB,KAAK,SAAS;YACZ,OAAO,SAAS,CAAC;QACnB,KAAK,WAAW;YACd,sDAAsD;YACtD,OAAO,UAAU,CAAC;QACpB;YACE,OAAO,SAAS,CAAC;IACrB,CAAC;AACH,CAAC;AAED;;;;;;;;;;GAUG;AACH,MAAM,UAAU,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