primitive-admin 1.0.54 → 1.0.56

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (110) hide show
  1. package/assets/skill/skills/primitive-platform/SKILL.md +230 -2
  2. package/dist/bin/primitive.js +3 -1
  3. package/dist/bin/primitive.js.map +1 -1
  4. package/dist/src/commands/apps.js +54 -2
  5. package/dist/src/commands/apps.js.map +1 -1
  6. package/dist/src/commands/database-types.js +4 -4
  7. package/dist/src/commands/database-types.js.map +1 -1
  8. package/dist/src/commands/databases.js +35 -14
  9. package/dist/src/commands/databases.js.map +1 -1
  10. package/dist/src/commands/documents.js +77 -0
  11. package/dist/src/commands/documents.js.map +1 -1
  12. package/dist/src/commands/guides.d.ts +15 -12
  13. package/dist/src/commands/guides.js +22 -15
  14. package/dist/src/commands/guides.js.map +1 -1
  15. package/dist/src/commands/metadata.js +48 -3
  16. package/dist/src/commands/metadata.js.map +1 -1
  17. package/dist/src/commands/scripts.d.ts +18 -0
  18. package/dist/src/commands/scripts.js +59 -5
  19. package/dist/src/commands/scripts.js.map +1 -1
  20. package/dist/src/commands/settings.d.ts +15 -0
  21. package/dist/src/commands/settings.js +102 -0
  22. package/dist/src/commands/settings.js.map +1 -0
  23. package/dist/src/commands/sync-app-settings.d.ts +115 -0
  24. package/dist/src/commands/sync-app-settings.js +379 -0
  25. package/dist/src/commands/sync-app-settings.js.map +1 -0
  26. package/dist/src/commands/sync.d.ts +134 -19
  27. package/dist/src/commands/sync.js +1949 -600
  28. package/dist/src/commands/sync.js.map +1 -1
  29. package/dist/src/commands/workflows.js +54 -15
  30. package/dist/src/commands/workflows.js.map +1 -1
  31. package/dist/src/lib/api-client.d.ts +29 -1
  32. package/dist/src/lib/api-client.js +31 -2
  33. package/dist/src/lib/api-client.js.map +1 -1
  34. package/dist/src/lib/app-settings-descriptor.d.ts +108 -0
  35. package/dist/src/lib/app-settings-descriptor.js +254 -0
  36. package/dist/src/lib/app-settings-descriptor.js.map +1 -0
  37. package/dist/src/lib/codegen-shared/generatedFiles.d.ts +36 -0
  38. package/dist/src/lib/codegen-shared/generatedFiles.js +67 -10
  39. package/dist/src/lib/codegen-shared/generatedFiles.js.map +1 -1
  40. package/dist/src/lib/codegen-shared/prettierStable.d.ts +262 -0
  41. package/dist/src/lib/codegen-shared/prettierStable.js +610 -0
  42. package/dist/src/lib/codegen-shared/prettierStable.js.map +1 -0
  43. package/dist/src/lib/db-codegen/dbGenerator.d.ts +11 -83
  44. package/dist/src/lib/db-codegen/dbGenerator.js +96 -556
  45. package/dist/src/lib/db-codegen/dbGenerator.js.map +1 -1
  46. package/dist/src/lib/db-codegen/dbNaming.d.ts +20 -7
  47. package/dist/src/lib/db-codegen/dbNaming.js +31 -13
  48. package/dist/src/lib/db-codegen/dbNaming.js.map +1 -1
  49. package/dist/src/lib/db-codegen/dbTemplates.d.ts +70 -4
  50. package/dist/src/lib/db-codegen/dbTemplates.js +244 -70
  51. package/dist/src/lib/db-codegen/dbTemplates.js.map +1 -1
  52. package/dist/src/lib/db-codegen/dbTsTypes.d.ts +13 -22
  53. package/dist/src/lib/db-codegen/dbTsTypes.js +33 -28
  54. package/dist/src/lib/db-codegen/dbTsTypes.js.map +1 -1
  55. package/dist/src/lib/db-codegen/dbTypeIR.d.ts +146 -0
  56. package/dist/src/lib/db-codegen/dbTypeIR.js +517 -0
  57. package/dist/src/lib/db-codegen/dbTypeIR.js.map +1 -0
  58. package/dist/src/lib/db-codegen/generated-operation-def-descriptor.d.ts +112 -0
  59. package/dist/src/lib/db-codegen/generated-operation-def-descriptor.js +211 -0
  60. package/dist/src/lib/db-codegen/generated-operation-def-descriptor.js.map +1 -0
  61. package/dist/src/lib/generated-allowlist.js +7 -0
  62. package/dist/src/lib/generated-allowlist.js.map +1 -1
  63. package/dist/src/lib/platform-owned.d.ts +37 -0
  64. package/dist/src/lib/platform-owned.js +46 -0
  65. package/dist/src/lib/platform-owned.js.map +1 -0
  66. package/dist/src/lib/swift-codegen/dbGenerator.d.ts +100 -0
  67. package/dist/src/lib/swift-codegen/dbGenerator.js +682 -0
  68. package/dist/src/lib/swift-codegen/dbGenerator.js.map +1 -0
  69. package/dist/src/lib/swift-codegen/dbSwiftTypes.d.ts +42 -0
  70. package/dist/src/lib/swift-codegen/dbSwiftTypes.js +100 -0
  71. package/dist/src/lib/swift-codegen/dbSwiftTypes.js.map +1 -0
  72. package/dist/src/lib/swift-codegen/generator.d.ts +85 -0
  73. package/dist/src/lib/swift-codegen/generator.js +266 -0
  74. package/dist/src/lib/swift-codegen/generator.js.map +1 -0
  75. package/dist/src/lib/swift-codegen/schemaToSwift.d.ts +72 -0
  76. package/dist/src/lib/swift-codegen/schemaToSwift.js +644 -0
  77. package/dist/src/lib/swift-codegen/schemaToSwift.js.map +1 -0
  78. package/dist/src/lib/swift-codegen/siblingSymbols.d.ts +90 -0
  79. package/dist/src/lib/swift-codegen/siblingSymbols.js +152 -0
  80. package/dist/src/lib/swift-codegen/siblingSymbols.js.map +1 -0
  81. package/dist/src/lib/swift-codegen/swiftNaming.d.ts +85 -0
  82. package/dist/src/lib/swift-codegen/swiftNaming.js +198 -0
  83. package/dist/src/lib/swift-codegen/swiftNaming.js.map +1 -0
  84. package/dist/src/lib/sync-resource-types.d.ts +437 -0
  85. package/dist/src/lib/sync-resource-types.js +781 -0
  86. package/dist/src/lib/sync-resource-types.js.map +1 -0
  87. package/dist/src/lib/template.d.ts +1 -1
  88. package/dist/src/lib/template.js +6 -3
  89. package/dist/src/lib/template.js.map +1 -1
  90. package/dist/src/lib/toml-metadata-config.js +18 -0
  91. package/dist/src/lib/toml-metadata-config.js.map +1 -1
  92. package/dist/src/lib/workflow-apply.js +12 -2
  93. package/dist/src/lib/workflow-apply.js.map +1 -1
  94. package/dist/src/lib/workflow-codegen/generator.d.ts +27 -5
  95. package/dist/src/lib/workflow-codegen/generator.js +214 -68
  96. package/dist/src/lib/workflow-codegen/generator.js.map +1 -1
  97. package/dist/src/lib/workflow-codegen/invokerIR.d.ts +83 -0
  98. package/dist/src/lib/workflow-codegen/invokerIR.js +71 -0
  99. package/dist/src/lib/workflow-codegen/invokerIR.js.map +1 -0
  100. package/dist/src/lib/workflow-codegen/schemaToTs.d.ts +17 -1
  101. package/dist/src/lib/workflow-codegen/schemaToTs.js +59 -38
  102. package/dist/src/lib/workflow-codegen/schemaToTs.js.map +1 -1
  103. package/dist/src/lib/workflow-payload.d.ts +19 -0
  104. package/dist/src/lib/workflow-payload.js +21 -0
  105. package/dist/src/lib/workflow-payload.js.map +1 -1
  106. package/dist/src/lib/workflow-toml-validator.d.ts +30 -0
  107. package/dist/src/lib/workflow-toml-validator.js +206 -0
  108. package/dist/src/lib/workflow-toml-validator.js.map +1 -1
  109. package/dist/src/types/index.d.ts +1 -0
  110. package/package.json +5 -2
@@ -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"`). Each value is emitted via
55
- * `JSON.stringify` so quotes, backslashes, and other special characters are
56
- * properly escaped into a valid TS string literal.
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
- export function tsUnionFromEnum(values) {
64
- return values.map((v) => JSON.stringify(v)).join(" | ");
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, honoring an optional
68
- * string `enum` allowed-value set (#843). A non-empty `enum` on a `string`
69
- * field renders a string-literal union; otherwise falls back to the base
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 tsTypeForDbField(fieldType, enumValues) {
76
+ export function typeNodeForDbField(fieldType, enumValues) {
73
77
  if (fieldType === "string" &&
74
78
  Array.isArray(enumValues) &&
75
79
  enumValues.length > 0) {
76
- return tsUnionFromEnum(enumValues);
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, honoring an optional string
82
- * `enum` allowed-value set (#861). A non-empty `enum` on a `string` param
83
- * renders a string-literal union (`"a" | "b"`); otherwise falls back to the
84
- * base param-type mapping below. Mirrors `tsTypeForDbField` (the record-field
85
- * sibling) and reuses `tsUnionFromEnum` for a single escaping implementation.
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 tsTypeForDbParamType(paramType, enumValues, items) {
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 = `(${tsUnionFromEnum(enumValues)})`;
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 = tsTypeForDbParamType(items);
113
+ elem = typeNodeForDbParamType(items);
109
114
  }
110
115
  else {
111
- elem = "unknown";
116
+ elem = atom("unknown");
112
117
  }
113
- return `${elem}[]`;
118
+ return arrayOf(elem);
114
119
  }
115
120
  if (paramType === "string" &&
116
121
  Array.isArray(enumValues) &&
117
122
  enumValues.length > 0) {
118
- return tsUnionFromEnum(enumValues);
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 "Record<string, unknown>";
134
+ return recordOf("unknown");
130
135
  default:
131
- return "unknown";
136
+ return atom("unknown");
132
137
  }
133
138
  }
134
139
  //# sourceMappingURL=dbTsTypes.js.map
@@ -1 +1 @@
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,eAAe,CAAC,MAAgB;IAC9C,OAAO,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;AAC1D,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,gBAAgB,CAC9B,SAAiB,EACjB,UAAqB;IAErB,IACE,SAAS,KAAK,QAAQ;QACtB,KAAK,CAAC,OAAO,CAAC,UAAU,CAAC;QACzB,UAAU,CAAC,MAAM,GAAG,CAAC,EACrB,CAAC;QACD,OAAO,eAAe,CAAC,UAAU,CAAC,CAAC;IACrC,CAAC;IACD,OAAO,oBAAoB,CAAC,SAAS,CAAC,CAAC;AACzC,CAAC;AAED;;;;;;;;;;;;GAYG;AACH,MAAM,UAAU,oBAAoB,CAClC,SAAiB,EACjB,UAAqB,EACrB,KAAc;IAEd,6EAA6E;IAC7E,6EAA6E;IAC7E,0EAA0E;IAC1E,6EAA6E;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aAAM,IAAI,KAAK,EAAE,CAAC;YACjB,uEAAuE;YACvE,qBAAqB;YACrB,IAAI,GAAG,sBAAsB,CAAC,KAAK,CAAC,CAAC;QACvC,CAAC;aAAM,CAAC;YACN,IAAI,GAAG,IAAI,CAAC,SAAS,CAAC,CAAC;QACzB,CAAC;QACD,OAAO,OAAO,CAAC,IAAI,CAAC,CAAC;IACvB,CAAC;IACD,IACE,SAAS,KAAK,QAAQ;QACtB,KAAK,CAAC,OAAO,CAAC,UAAU,CAAC;QACzB,UAAU,CAAC,MAAM,GAAG,CAAC,EACrB,CAAC;QACD,OAAO,iBAAiB,CAAC,UAAU,CAAC,CAAC;IACvC,CAAC;IACD,QAAQ,SAAS,EAAE,CAAC;QAClB,KAAK,QAAQ;YACX,OAAO,IAAI,CAAC,QAAQ,CAAC,CAAC;QACxB,KAAK,QAAQ,CAAC;QACd,KAAK,SAAS;YACZ,OAAO,IAAI,CAAC,QAAQ,CAAC,CAAC;QACxB,KAAK,SAAS;YACZ,OAAO,IAAI,CAAC,SAAS,CAAC,CAAC;QACzB,KAAK,QAAQ;YACX,OAAO,QAAQ,CAAC,SAAS,CAAC,CAAC;QAC7B;YACE,OAAO,IAAI,CAAC,SAAS,CAAC,CAAC;IAC3B,CAAC;AACH,CAAC"}
@@ -0,0 +1,146 @@
1
+ /**
2
+ * Shared database-type operation IR (issue #1547, Phase 4).
3
+ *
4
+ * `describeDbType` resolves ONE database-type TOML into a naming-neutral
5
+ * descriptor of its record models and operations — the record fields (with
6
+ * inferred required-ness), the per-op input params, and the per-op result
7
+ * descriptor (query projection #1439, mutation, count, aggregate,
8
+ * applyToQuery, pipeline return #1437). It performs NO language-specific
9
+ * naming: the TS renderer (`dbGenerator.ts`) and the Swift renderer
10
+ * (`swift-codegen/dbGenerator.ts`) both consume this SAME IR and each apply
11
+ * their own identifier rules. Neither renderer re-walks the op definitions, so
12
+ * the two clients can never disagree on which operations a database type
13
+ * exposes, what params they take, or what shape they return (issue #1547
14
+ * binding item 5 — the same "shared operation IR, no metadata reconstruction"
15
+ * contract Phase 3's `describeWorkflowInvoker` gives the workflow invoker).
16
+ *
17
+ * The resolution logic here was lifted verbatim from `renderDbTypeFile`'s
18
+ * former inline body; the only change is that result descriptors reference a
19
+ * MODEL NAME (naming-neutral) rather than a resolved TS interface name, so the
20
+ * Swift renderer can map the same model to its own type name.
21
+ */
22
+ import type { RecordField, ParamField, ProjectionClassification } from "./dbTemplates.js";
23
+ export interface DbCodegenInput {
24
+ /** Database type name (drives the output filename). */
25
+ databaseType: string;
26
+ /** Path to the source `database-types/<type>.toml` file. */
27
+ tomlPath: string;
28
+ /** Raw TOML content (already read from disk). */
29
+ tomlContent: string;
30
+ }
31
+ /**
32
+ * Naming-neutral form of a pipeline op's resolved `return` step (#1437). Same
33
+ * shape as `dbTemplates.PipelineReturnDescriptor` but keyed on the returning
34
+ * step's MODEL NAME instead of a resolved interface name, so each renderer maps
35
+ * it to its own record type. `opaque` → the generic pipeline-result envelope.
36
+ */
37
+ export type PipelineReturnIR = {
38
+ kind: "query";
39
+ modelName: string | null;
40
+ projection: ProjectionClassification;
41
+ } | {
42
+ kind: "count";
43
+ } | {
44
+ kind: "aggregate";
45
+ } | {
46
+ kind: "opaque";
47
+ };
48
+ /** One record model on a database type (read shape), naming-neutral. */
49
+ export interface DbRecordIR {
50
+ /** TOML model name (e.g. `accounts`). */
51
+ modelName: string;
52
+ /** Optional `class_name` override from the schema (naming input). */
53
+ className?: string;
54
+ /**
55
+ * Record fields with required-ness already resolved (schema `required`,
56
+ * `id` auto-assign, and op-params inference #842 folded in). Rendered into a
57
+ * struct/interface member per field.
58
+ */
59
+ fields: RecordField[];
60
+ }
61
+ /** One operation on a database type, naming-neutral. */
62
+ export interface DbOpIR {
63
+ /** Exact operation name (the `executeOperation` string argument). */
64
+ opName: string;
65
+ /** Operation type (`query|mutation|count|aggregate|pipeline|applyToQuery`). */
66
+ opType: string;
67
+ /** Declared input params (sorted by name), write shape. */
68
+ params: ParamField[];
69
+ /** Whether the op declares any params (a param-less op is callable bare). */
70
+ hasParams: boolean;
71
+ /**
72
+ * For a `query` op, the model its result rows are typed over — or null when
73
+ * the op has no model or the model has no record schema (the result falls
74
+ * back to an open/untyped row).
75
+ */
76
+ resultModelName: string | null;
77
+ /** For a `query` op, how its static `projection` narrows the record (#1439). */
78
+ projection?: ProjectionClassification;
79
+ /** For a `pipeline` op, the resolved `return`-step shape (#1437). */
80
+ pipelineReturn?: PipelineReturnIR;
81
+ }
82
+ /**
83
+ * One realtime subscription on a database type (#1544 Phase 2), naming-neutral.
84
+ *
85
+ * `modelName` is guaranteed to name a model that has a record schema on this
86
+ * type (`describeDbType` throws otherwise — a subscription can't be typed
87
+ * against a model the type doesn't declare; matches the server's
88
+ * `modelName is required` create validation). `select` fields, when present,
89
+ * are each guaranteed to be a known member of that record (declared field or
90
+ * stamped field) unless the record is the open `Record<string, unknown>` form,
91
+ * so the renderer can emit a valid `Pick<Record, …>` without a further guard.
92
+ */
93
+ export interface DbSubscriptionIR {
94
+ /** Subscription key (the `subscribe()` string argument). */
95
+ subscriptionKey: string;
96
+ /** Model whose record type binds the delivered change payload. */
97
+ modelName: string;
98
+ /**
99
+ * Projected field names when the subscription declares `select` (→ the event
100
+ * record narrows to `Pick<Record, …fields>`), else null (→ the full record).
101
+ * Sorted + de-duplicated for deterministic output.
102
+ */
103
+ select: string[] | null;
104
+ }
105
+ /** The shared, naming-neutral descriptor of one database type. */
106
+ export interface DbTypeIR {
107
+ /** Database type name (drives the output filename). */
108
+ databaseType: string;
109
+ /** Content fingerprint stamped in the generated header. */
110
+ fingerprint: string;
111
+ /** Server-stamped field names appended as OPTIONAL props on every record. */
112
+ stampedFields: string[];
113
+ /** Record models (schema order; renderers sort by their own type name). */
114
+ records: DbRecordIR[];
115
+ /** Operations, sorted by op name for deterministic output. */
116
+ ops: DbOpIR[];
117
+ /** Subscriptions, sorted by subscription key for deterministic output. */
118
+ subscriptions: DbSubscriptionIR[];
119
+ }
120
+ /**
121
+ * Resolve a database-type TOML into the shared, naming-neutral IR. Pure: no
122
+ * I/O beyond parsing the passed content. Both the TS and Swift renderers call
123
+ * this so their op/record metadata can never diverge.
124
+ */
125
+ export declare function describeDbType(input: DbCodegenInput): DbTypeIR;
126
+ /**
127
+ * Infer the scalar element type for op params consumed by a `$in`/`$nin`
128
+ * filter operator (#1488). See the original doc in `dbGenerator.ts` — moved
129
+ * here unchanged. Returns a map of param name → element TS type
130
+ * (`"unknown"` sentinel → widen to an untyped element).
131
+ */
132
+ export declare function inferArrayParamElementTypes(op: any, fieldTypesByModel: Map<string, Map<string, string>>): Map<string, string>;
133
+ /**
134
+ * Per-model result of {@link inferRequiredRecordFields}. Shaped as an object so
135
+ * it can grow additional inferred metadata later without changing callers.
136
+ */
137
+ export interface InferredRecordModelInfo {
138
+ /** Record field names promoted to non-optional by op-params inference. */
139
+ fields: Set<string>;
140
+ }
141
+ /**
142
+ * Infer which record fields are always supplied at create time from `save` op
143
+ * params (#842). See the original doc in `dbGenerator.ts` — moved here
144
+ * unchanged.
145
+ */
146
+ export declare function inferRequiredRecordFields(operations: any[]): Map<string, InferredRecordModelInfo>;