primitive-admin 1.0.53 → 1.0.55

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 (173) hide show
  1. package/README.md +38 -10
  2. package/dist/bin/primitive.js +8 -0
  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/auth.js +16 -6
  7. package/dist/src/commands/auth.js.map +1 -1
  8. package/dist/src/commands/blob-buckets.js +84 -7
  9. package/dist/src/commands/blob-buckets.js.map +1 -1
  10. package/dist/src/commands/catalog.js +3 -3
  11. package/dist/src/commands/catalog.js.map +1 -1
  12. package/dist/src/commands/collections.js +12 -9
  13. package/dist/src/commands/collections.js.map +1 -1
  14. package/dist/src/commands/databases.js +220 -82
  15. package/dist/src/commands/databases.js.map +1 -1
  16. package/dist/src/commands/documents.js +77 -0
  17. package/dist/src/commands/documents.js.map +1 -1
  18. package/dist/src/commands/group-type-configs.js +1 -9
  19. package/dist/src/commands/group-type-configs.js.map +1 -1
  20. package/dist/src/commands/groups.js +12 -6
  21. package/dist/src/commands/groups.js.map +1 -1
  22. package/dist/src/commands/guides.d.ts +161 -0
  23. package/dist/src/commands/guides.js +502 -84
  24. package/dist/src/commands/guides.js.map +1 -1
  25. package/dist/src/commands/integrations.js +2 -2
  26. package/dist/src/commands/integrations.js.map +1 -1
  27. package/dist/src/commands/metadata.d.ts +2 -0
  28. package/dist/src/commands/metadata.js +344 -0
  29. package/dist/src/commands/metadata.js.map +1 -0
  30. package/dist/src/commands/prompts.js +2 -2
  31. package/dist/src/commands/prompts.js.map +1 -1
  32. package/dist/src/commands/rule-sets.d.ts +1 -0
  33. package/dist/src/commands/rule-sets.js +25 -3
  34. package/dist/src/commands/rule-sets.js.map +1 -1
  35. package/dist/src/commands/scripts.d.ts +2 -0
  36. package/dist/src/commands/scripts.js +667 -0
  37. package/dist/src/commands/scripts.js.map +1 -0
  38. package/dist/src/commands/settings.d.ts +15 -0
  39. package/dist/src/commands/settings.js +102 -0
  40. package/dist/src/commands/settings.js.map +1 -0
  41. package/dist/src/commands/sync-app-settings.d.ts +105 -0
  42. package/dist/src/commands/sync-app-settings.js +339 -0
  43. package/dist/src/commands/sync-app-settings.js.map +1 -0
  44. package/dist/src/commands/sync.d.ts +204 -9
  45. package/dist/src/commands/sync.js +1706 -371
  46. package/dist/src/commands/sync.js.map +1 -1
  47. package/dist/src/commands/vars.d.ts +8 -0
  48. package/dist/src/commands/vars.js +110 -0
  49. package/dist/src/commands/vars.js.map +1 -0
  50. package/dist/src/commands/webhooks.js +17 -3
  51. package/dist/src/commands/webhooks.js.map +1 -1
  52. package/dist/src/commands/workflows.d.ts +30 -0
  53. package/dist/src/commands/workflows.js +667 -59
  54. package/dist/src/commands/workflows.js.map +1 -1
  55. package/dist/src/lib/api-client.d.ts +122 -18
  56. package/dist/src/lib/api-client.js +131 -2
  57. package/dist/src/lib/api-client.js.map +1 -1
  58. package/dist/src/lib/app-settings-descriptor.d.ts +108 -0
  59. package/dist/src/lib/app-settings-descriptor.js +250 -0
  60. package/dist/src/lib/app-settings-descriptor.js.map +1 -0
  61. package/dist/src/lib/batch.d.ts +26 -0
  62. package/dist/src/lib/batch.js +32 -0
  63. package/dist/src/lib/batch.js.map +1 -0
  64. package/dist/src/lib/block-layout.d.ts +160 -0
  65. package/dist/src/lib/block-layout.js +451 -0
  66. package/dist/src/lib/block-layout.js.map +1 -0
  67. package/dist/src/lib/codegen-shared/generatedFiles.d.ts +76 -0
  68. package/dist/src/lib/codegen-shared/generatedFiles.js +144 -0
  69. package/dist/src/lib/codegen-shared/generatedFiles.js.map +1 -0
  70. package/dist/src/lib/codegen-shared/resolveCodegenSourceDir.d.ts +68 -0
  71. package/dist/src/lib/codegen-shared/resolveCodegenSourceDir.js +168 -0
  72. package/dist/src/lib/codegen-shared/resolveCodegenSourceDir.js.map +1 -0
  73. package/dist/src/lib/config-toml.d.ts +10 -0
  74. package/dist/src/lib/config-toml.js +42 -0
  75. package/dist/src/lib/config-toml.js.map +1 -0
  76. package/dist/src/lib/config.d.ts +16 -0
  77. package/dist/src/lib/config.js +41 -0
  78. package/dist/src/lib/config.js.map +1 -1
  79. package/dist/src/lib/constants.d.ts +9 -0
  80. package/dist/src/lib/constants.js +9 -0
  81. package/dist/src/lib/constants.js.map +1 -1
  82. package/dist/src/lib/csv.d.ts +1 -2
  83. package/dist/src/lib/csv.js +3 -8
  84. package/dist/src/lib/csv.js.map +1 -1
  85. package/dist/src/lib/db-codegen/dbGenerator.d.ts +21 -65
  86. package/dist/src/lib/db-codegen/dbGenerator.js +117 -321
  87. package/dist/src/lib/db-codegen/dbGenerator.js.map +1 -1
  88. package/dist/src/lib/db-codegen/dbNaming.d.ts +37 -0
  89. package/dist/src/lib/db-codegen/dbNaming.js +70 -0
  90. package/dist/src/lib/db-codegen/dbNaming.js.map +1 -1
  91. package/dist/src/lib/db-codegen/dbTemplates.d.ts +165 -5
  92. package/dist/src/lib/db-codegen/dbTemplates.js +292 -16
  93. package/dist/src/lib/db-codegen/dbTemplates.js.map +1 -1
  94. package/dist/src/lib/db-codegen/dbTsTypes.d.ts +7 -3
  95. package/dist/src/lib/db-codegen/dbTsTypes.js +23 -1
  96. package/dist/src/lib/db-codegen/dbTsTypes.js.map +1 -1
  97. package/dist/src/lib/db-codegen/dbTypeIR.d.ts +146 -0
  98. package/dist/src/lib/db-codegen/dbTypeIR.js +517 -0
  99. package/dist/src/lib/db-codegen/dbTypeIR.js.map +1 -0
  100. package/dist/src/lib/db-codegen/generated-operation-def-descriptor.d.ts +101 -0
  101. package/dist/src/lib/db-codegen/generated-operation-def-descriptor.js +200 -0
  102. package/dist/src/lib/db-codegen/generated-operation-def-descriptor.js.map +1 -0
  103. package/dist/src/lib/generated-allowlist.js +43 -0
  104. package/dist/src/lib/generated-allowlist.js.map +1 -1
  105. package/dist/src/lib/init-config.js +2 -2
  106. package/dist/src/lib/init-config.js.map +1 -1
  107. package/dist/src/lib/output.d.ts +25 -5
  108. package/dist/src/lib/output.js +32 -4
  109. package/dist/src/lib/output.js.map +1 -1
  110. package/dist/src/lib/query-operators.d.ts +43 -0
  111. package/dist/src/lib/query-operators.js +80 -0
  112. package/dist/src/lib/query-operators.js.map +1 -0
  113. package/dist/src/lib/swift-codegen/dbGenerator.d.ts +68 -0
  114. package/dist/src/lib/swift-codegen/dbGenerator.js +380 -0
  115. package/dist/src/lib/swift-codegen/dbGenerator.js.map +1 -0
  116. package/dist/src/lib/swift-codegen/dbSwiftTypes.d.ts +42 -0
  117. package/dist/src/lib/swift-codegen/dbSwiftTypes.js +100 -0
  118. package/dist/src/lib/swift-codegen/dbSwiftTypes.js.map +1 -0
  119. package/dist/src/lib/swift-codegen/generator.d.ts +84 -0
  120. package/dist/src/lib/swift-codegen/generator.js +178 -0
  121. package/dist/src/lib/swift-codegen/generator.js.map +1 -0
  122. package/dist/src/lib/swift-codegen/schemaToSwift.d.ts +72 -0
  123. package/dist/src/lib/swift-codegen/schemaToSwift.js +644 -0
  124. package/dist/src/lib/swift-codegen/schemaToSwift.js.map +1 -0
  125. package/dist/src/lib/swift-codegen/swiftNaming.d.ts +85 -0
  126. package/dist/src/lib/swift-codegen/swiftNaming.js +198 -0
  127. package/dist/src/lib/swift-codegen/swiftNaming.js.map +1 -0
  128. package/dist/src/lib/sync-resource-types.d.ts +225 -0
  129. package/dist/src/lib/sync-resource-types.js +394 -0
  130. package/dist/src/lib/sync-resource-types.js.map +1 -0
  131. package/dist/src/lib/toml-database-config.d.ts +10 -19
  132. package/dist/src/lib/toml-database-config.js +28 -59
  133. package/dist/src/lib/toml-database-config.js.map +1 -1
  134. package/dist/src/lib/toml-metadata-config.d.ts +147 -0
  135. package/dist/src/lib/toml-metadata-config.js +463 -0
  136. package/dist/src/lib/toml-metadata-config.js.map +1 -0
  137. package/dist/src/lib/toml-native-form.d.ts +46 -0
  138. package/dist/src/lib/toml-native-form.js +78 -0
  139. package/dist/src/lib/toml-native-form.js.map +1 -0
  140. package/dist/src/lib/toml-params-validator.d.ts +34 -0
  141. package/dist/src/lib/toml-params-validator.js +118 -3
  142. package/dist/src/lib/toml-params-validator.js.map +1 -1
  143. package/dist/src/lib/workflow-apply.d.ts +86 -0
  144. package/dist/src/lib/workflow-apply.js +127 -0
  145. package/dist/src/lib/workflow-apply.js.map +1 -0
  146. package/dist/src/lib/workflow-codegen/generated-schema-descriptor.d.ts +129 -0
  147. package/dist/src/lib/workflow-codegen/generated-schema-descriptor.js +269 -0
  148. package/dist/src/lib/workflow-codegen/generated-schema-descriptor.js.map +1 -0
  149. package/dist/src/lib/workflow-codegen/generator.d.ts +87 -0
  150. package/dist/src/lib/workflow-codegen/generator.js +290 -0
  151. package/dist/src/lib/workflow-codegen/generator.js.map +1 -0
  152. package/dist/src/lib/workflow-codegen/invokerIR.d.ts +85 -0
  153. package/dist/src/lib/workflow-codegen/invokerIR.js +71 -0
  154. package/dist/src/lib/workflow-codegen/invokerIR.js.map +1 -0
  155. package/dist/src/lib/workflow-codegen/naming.d.ts +33 -0
  156. package/dist/src/lib/workflow-codegen/naming.js +81 -0
  157. package/dist/src/lib/workflow-codegen/naming.js.map +1 -0
  158. package/dist/src/lib/workflow-codegen/schemaToTs.d.ts +64 -0
  159. package/dist/src/lib/workflow-codegen/schemaToTs.js +282 -0
  160. package/dist/src/lib/workflow-codegen/schemaToTs.js.map +1 -0
  161. package/dist/src/lib/workflow-fragments.js +3 -3
  162. package/dist/src/lib/workflow-fragments.js.map +1 -1
  163. package/dist/src/lib/workflow-payload.d.ts +68 -0
  164. package/dist/src/lib/workflow-payload.js +150 -0
  165. package/dist/src/lib/workflow-payload.js.map +1 -0
  166. package/dist/src/lib/workflow-toml-validator.d.ts +1 -1
  167. package/dist/src/lib/workflow-toml-validator.js +37 -1
  168. package/dist/src/lib/workflow-toml-validator.js.map +1 -1
  169. package/dist/src/types/index.d.ts +11 -0
  170. package/dist/src/validators.d.ts +4 -3
  171. package/dist/src/validators.js +6 -5
  172. package/dist/src/validators.js.map +1 -1
  173. package/package.json +7 -3
@@ -0,0 +1,129 @@
1
+ /**
2
+ * GENERATED FILE — DO NOT EDIT BY HAND.
3
+ *
4
+ * Vendored byte-for-byte from the canonical server module
5
+ * `src/workflows/schema-descriptor.ts` — the SAME interpretation the server
6
+ * validator (`validateValue`) enforces. The CLI cannot import server `src/`
7
+ * at runtime, so `workflows codegen`'s type converter imports this committed
8
+ * copy instead.
9
+ *
10
+ * Regenerate with:
11
+ * node cli/scripts/gen-workflow-schema-descriptor.mjs (runs at CLI prebuild)
12
+ *
13
+ * A CI freshness guard
14
+ * (`cli/scripts/gen-workflow-schema-descriptor.mjs --check`, also asserted by
15
+ * `cli/tests/unit/workflow-codegen-descriptor-drift-guard.test.ts`) fails if
16
+ * this committed copy does not match the source — see issue #1442 / #998.
17
+ */
18
+ /**
19
+ * Canonical interpretation of the JSON-Schema subset the workflow platform
20
+ * supports (issue #1442).
21
+ *
22
+ * The server validator (`validateValue` in `schema-validation.ts`) and the CLI
23
+ * `workflows codegen` type converter (`workflow-codegen/schemaToTs.ts`) must
24
+ * agree EXACTLY on how a workflow `inputSchema`/`outputSchema` is interpreted —
25
+ * otherwise a generated `<Key>Input` type promises a shape the runtime does not
26
+ * enforce (or rejects a value the runtime accepts). Previously the converter
27
+ * re-derived those interpretation decisions by hand, which drifts from the
28
+ * validator over time.
29
+ *
30
+ * This module is the single source of that interpretation. Both consumers read
31
+ * from `describeSchema` + `isType`:
32
+ *
33
+ * - the type gate is checked before `enum` (a value failing `type` is
34
+ * rejected before `enum` is consulted);
35
+ * - a type UNION (`type: ["string","null"]`) never descends into
36
+ * `properties`/`items` — only the exact string types `"object"`/`"array"`
37
+ * do;
38
+ * - `integer` means `Number.isInteger`;
39
+ * - `additionalProperties` only closes an object; it is not a nested schema.
40
+ *
41
+ * It is deliberately dependency-free (no imports) so the CLI can vendor a
42
+ * byte-for-byte copy as a committed artifact via
43
+ * `cli/scripts/gen-workflow-schema-descriptor.mjs` (the #998 gen-allowlist
44
+ * pattern). A drift-guard test runs that generator in `--check` mode, so a
45
+ * change here that isn't regenerated into the CLI artifact fails CI. The CLI
46
+ * never imports server `src/` at runtime — only the build-time generator reads
47
+ * this file.
48
+ */
49
+ /** Does a value satisfy a JSON-schema `type` name? `integer` = `Number.isInteger`. */
50
+ export declare function isType(value: any, type: string): boolean;
51
+ /**
52
+ * The interpretation of a single schema node, normalized so both the validator
53
+ * and the type converter can consume it without re-reading raw schema fields.
54
+ */
55
+ export interface SchemaDescriptor {
56
+ /** True when `schema.type` is an array (a type union). */
57
+ isUnion: boolean;
58
+ /** `schema.type` when it is a single string; null for a union or absent type. */
59
+ singularType: string | null;
60
+ /**
61
+ * The declared type(s) normalized to an array. An array `type` is kept as-is;
62
+ * a single string becomes a one-element array; an absent/falsy type is `[]`
63
+ * (no type gate). Matches the validator's `allowedTypes` normalization.
64
+ */
65
+ types: string[];
66
+ /** The `enum` array when present, else null. */
67
+ enumValues: any[] | null;
68
+ /**
69
+ * Object descent info — non-null ONLY when `schema.type` is exactly the
70
+ * string `"object"` AND `properties` is a declared object (matching the
71
+ * validator's `schema.type === "object" && schema.properties` descent gate).
72
+ * A type UNION containing `"object"` never descends.
73
+ */
74
+ object: {
75
+ /** The raw `properties` map (child schemas). May be empty `{}`. */
76
+ properties: Record<string, any>;
77
+ /** The raw `required` list (unfiltered, as the validator reads it). */
78
+ required: any[];
79
+ /** True when `additionalProperties === false` (a closed object). */
80
+ additionalPropertiesClosed: boolean;
81
+ } | null;
82
+ /**
83
+ * Array descent info — non-null ONLY when `schema.type` is exactly the string
84
+ * `"array"` AND `items` is present (matching the validator's
85
+ * `schema.type === "array" && schema.items` descent gate).
86
+ */
87
+ array: {
88
+ /** The raw `items` schema (may be a tuple array the validator no-ops on). */
89
+ items: any;
90
+ } | null;
91
+ /**
92
+ * Discriminated-union (tagged-union) interpretation of a `oneOf` node (#1511).
93
+ *
94
+ * Populated ONLY when the node carries a `oneOf` (or `anyOf`) array whose
95
+ * members are ALL `type: "object"` — a clearly-intended tagged union. A
96
+ * `oneOf`/`anyOf` with any non-object member is NOT a tagged union: `oneOf`
97
+ * stays `null` here and is ignored (renders `unknown` / validates
98
+ * permissively) exactly as before, preserving backward compatibility.
99
+ *
100
+ * - `kind: "valid"` — a clean discriminated union: ≥2 object members sharing
101
+ * exactly one discriminator property declared as a single-literal `enum`
102
+ * in every member with distinct literals across members. The validator
103
+ * branch-selects by `discriminant` and validates only the matched member;
104
+ * the type converter renders the `|`-union of member object types.
105
+ * - `kind: "invalid"` — an all-object-member union that LOOKS like a tagged
106
+ * union but is defective (fewer than 2 members, no/ambiguous discriminator,
107
+ * or `anyOf` — unsupported in v1). `reason` is the codegen error message.
108
+ * The runtime validator ignores this (stays permissive); the codegen
109
+ * converter throws `reason` (Fork 3 = strict, resolved by the maintainer).
110
+ */
111
+ oneOf: {
112
+ kind: "valid";
113
+ /** The auto-detected discriminator property name. */
114
+ discriminant: string;
115
+ /** One entry per member: its discriminant literal + raw member schema. */
116
+ members: Array<{
117
+ discriminantValue: any;
118
+ schema: any;
119
+ }>;
120
+ } | {
121
+ kind: "invalid";
122
+ reason: string;
123
+ } | null;
124
+ }
125
+ /**
126
+ * Interpret a parsed schema node. A non-object schema (null, array, scalar)
127
+ * enforces nothing → the empty descriptor.
128
+ */
129
+ export declare function describeSchema(schema: any): SchemaDescriptor;
@@ -0,0 +1,269 @@
1
+ /**
2
+ * GENERATED FILE — DO NOT EDIT BY HAND.
3
+ *
4
+ * Vendored byte-for-byte from the canonical server module
5
+ * `src/workflows/schema-descriptor.ts` — the SAME interpretation the server
6
+ * validator (`validateValue`) enforces. The CLI cannot import server `src/`
7
+ * at runtime, so `workflows codegen`'s type converter imports this committed
8
+ * copy instead.
9
+ *
10
+ * Regenerate with:
11
+ * node cli/scripts/gen-workflow-schema-descriptor.mjs (runs at CLI prebuild)
12
+ *
13
+ * A CI freshness guard
14
+ * (`cli/scripts/gen-workflow-schema-descriptor.mjs --check`, also asserted by
15
+ * `cli/tests/unit/workflow-codegen-descriptor-drift-guard.test.ts`) fails if
16
+ * this committed copy does not match the source — see issue #1442 / #998.
17
+ */
18
+ /**
19
+ * Canonical interpretation of the JSON-Schema subset the workflow platform
20
+ * supports (issue #1442).
21
+ *
22
+ * The server validator (`validateValue` in `schema-validation.ts`) and the CLI
23
+ * `workflows codegen` type converter (`workflow-codegen/schemaToTs.ts`) must
24
+ * agree EXACTLY on how a workflow `inputSchema`/`outputSchema` is interpreted —
25
+ * otherwise a generated `<Key>Input` type promises a shape the runtime does not
26
+ * enforce (or rejects a value the runtime accepts). Previously the converter
27
+ * re-derived those interpretation decisions by hand, which drifts from the
28
+ * validator over time.
29
+ *
30
+ * This module is the single source of that interpretation. Both consumers read
31
+ * from `describeSchema` + `isType`:
32
+ *
33
+ * - the type gate is checked before `enum` (a value failing `type` is
34
+ * rejected before `enum` is consulted);
35
+ * - a type UNION (`type: ["string","null"]`) never descends into
36
+ * `properties`/`items` — only the exact string types `"object"`/`"array"`
37
+ * do;
38
+ * - `integer` means `Number.isInteger`;
39
+ * - `additionalProperties` only closes an object; it is not a nested schema.
40
+ *
41
+ * It is deliberately dependency-free (no imports) so the CLI can vendor a
42
+ * byte-for-byte copy as a committed artifact via
43
+ * `cli/scripts/gen-workflow-schema-descriptor.mjs` (the #998 gen-allowlist
44
+ * pattern). A drift-guard test runs that generator in `--check` mode, so a
45
+ * change here that isn't regenerated into the CLI artifact fails CI. The CLI
46
+ * never imports server `src/` at runtime — only the build-time generator reads
47
+ * this file.
48
+ */
49
+ /** Does a value satisfy a JSON-schema `type` name? `integer` = `Number.isInteger`. */
50
+ export function isType(value, type) {
51
+ if (type === "array")
52
+ return Array.isArray(value);
53
+ if (type === "object")
54
+ return !!value && typeof value === "object" && !Array.isArray(value);
55
+ if (type === "string")
56
+ return typeof value === "string";
57
+ if (type === "number")
58
+ return typeof value === "number" && !Number.isNaN(value);
59
+ if (type === "integer")
60
+ return Number.isInteger(value);
61
+ if (type === "boolean")
62
+ return typeof value === "boolean";
63
+ if (type === "null")
64
+ return value === null;
65
+ // Unknown type name: nothing to enforce, so treat as a match (the validator
66
+ // must not reject a value against a keyword it does not model).
67
+ return true;
68
+ }
69
+ const EMPTY_DESCRIPTOR = {
70
+ isUnion: false,
71
+ singularType: null,
72
+ types: [],
73
+ enumValues: null,
74
+ object: null,
75
+ array: null,
76
+ oneOf: null,
77
+ };
78
+ /**
79
+ * Sibling constraint keywords that make a `oneOf` node a MIXED schema rather
80
+ * than a clean tagged union (#1511). A clean discriminated union carries only
81
+ * the `oneOf` keyword (plus annotations like `description`/`title`); it never
82
+ * combines with a top-level `type`/`properties`/`required`/`additionalProperties`/
83
+ * `items`/`enum`. When any of these co-occur with `oneOf`, the validator's
84
+ * branch-select would early-return and skip those sibling constraints, silently
85
+ * loosening validation. So a mixed node is NOT treated as a clean tagged union.
86
+ */
87
+ const ONEOF_SIBLING_CONSTRAINT_KEYS = [
88
+ "type",
89
+ "properties",
90
+ "required",
91
+ "additionalProperties",
92
+ "items",
93
+ "enum",
94
+ ];
95
+ function hasOneOfSiblingConstraints(schema) {
96
+ return ONEOF_SIBLING_CONSTRAINT_KEYS.some((k) => Object.prototype.hasOwnProperty.call(schema, k));
97
+ }
98
+ /**
99
+ * A discriminator tag must be a comparable scalar (string/number/boolean) so
100
+ * the validator's strict-`===` branch-select can match it against a JSON-parsed
101
+ * value (#1511). An object/array literal is structurally identical after a JSON
102
+ * round-trip but never the same reference, so it would always "match no case".
103
+ * Restricting the auto-detected discriminator to scalars keeps a non-scalar tag
104
+ * from being treated as a (never-matchable) discriminator.
105
+ */
106
+ function isScalarDiscriminatorLiteral(value) {
107
+ return (typeof value === "string" ||
108
+ typeof value === "number" ||
109
+ typeof value === "boolean");
110
+ }
111
+ /**
112
+ * Interpret a `oneOf`/`anyOf` node as a discriminated (tagged) union (#1511).
113
+ *
114
+ * The tagged-union interpretation is scoped to a clearly-intended tagged union:
115
+ * EVERY member must be `type: "object"`. Anything else (a mixed/scalar `oneOf`)
116
+ * returns `null` and is ignored downstream, exactly as before.
117
+ *
118
+ * Within that scope:
119
+ * - `anyOf` is not supported in v1 → `invalid` (codegen error suggests `oneOf`);
120
+ * - a `oneOf` with fewer than 2 members → `invalid`;
121
+ * - the discriminator is auto-detected: the single property present in EVERY
122
+ * member as a single-literal `enum` whose literal is a comparable scalar
123
+ * (string/number/boolean), with distinct literals across members (a
124
+ * non-scalar literal is not a candidate — see `isScalarDiscriminatorLiteral`);
125
+ * - zero or more-than-one candidate discriminator → `invalid` (ambiguity).
126
+ *
127
+ * Pure and dependency-free so the CLI can vendor a byte-for-byte copy.
128
+ */
129
+ function describeOneOf(schema) {
130
+ const rawOneOf = Array.isArray(schema.oneOf) ? schema.oneOf : null;
131
+ const rawAnyOf = Array.isArray(schema.anyOf) ? schema.anyOf : null;
132
+ // `oneOf` takes precedence; only one keyword is interpreted per node.
133
+ const keyword = rawOneOf
134
+ ? "oneOf"
135
+ : rawAnyOf
136
+ ? "anyOf"
137
+ : null;
138
+ const members = rawOneOf ?? rawAnyOf;
139
+ if (!keyword || !members)
140
+ return null;
141
+ // Scope to a clearly-intended tagged union: every member is `type: "object"`.
142
+ // A member that is not a plain object type means this is NOT a tagged union;
143
+ // leave it to the existing ignore-and-render-`unknown` path (backward compat).
144
+ const allObjects = members.length >= 1 &&
145
+ members.every((m) => !!m &&
146
+ typeof m === "object" &&
147
+ !Array.isArray(m) &&
148
+ m.type === "object");
149
+ if (!allObjects)
150
+ return null;
151
+ // `anyOf` is not supported in v1 (resolved Fork 1 = oneOf only). An all-object
152
+ // `anyOf` that looks like a tagged union gets a clear error suggesting oneOf.
153
+ if (keyword === "anyOf") {
154
+ return {
155
+ kind: "invalid",
156
+ reason: "anyOf is not supported for discriminated unions (issue #1511). Use oneOf instead.",
157
+ };
158
+ }
159
+ if (members.length < 2) {
160
+ return {
161
+ kind: "invalid",
162
+ reason: "A discriminated-union oneOf needs at least 2 object members (issue #1511).",
163
+ };
164
+ }
165
+ // For each member, collect its single-literal-enum properties → { name: literal }.
166
+ // The literal must be a comparable scalar (string/number/boolean): the
167
+ // validator branch-selects with strict `===`, so a non-scalar tag (object or
168
+ // array) on a JSON-parsed value is never the same reference as the schema
169
+ // literal and would always "match no case". Restricting the auto-detected
170
+ // discriminator to scalars means a non-scalar tag is not a candidate, so the
171
+ // union routes through the normal not-a-tagged-union path (below) instead of
172
+ // being accepted as a union that can never validate.
173
+ const memberLiteralProps = members.map((m) => {
174
+ const map = new Map();
175
+ const props = m.properties;
176
+ if (props && typeof props === "object" && !Array.isArray(props)) {
177
+ for (const [name, sub] of Object.entries(props)) {
178
+ if (sub &&
179
+ typeof sub === "object" &&
180
+ Array.isArray(sub.enum) &&
181
+ sub.enum.length === 1 &&
182
+ isScalarDiscriminatorLiteral(sub.enum[0])) {
183
+ map.set(name, sub.enum[0]);
184
+ }
185
+ }
186
+ }
187
+ return map;
188
+ });
189
+ // A candidate discriminator is present as a single-literal enum in EVERY
190
+ // member, with distinct literals across members (so a value's tag selects
191
+ // exactly one branch).
192
+ const candidates = [];
193
+ for (const name of memberLiteralProps[0].keys()) {
194
+ if (!memberLiteralProps.every((mp) => mp.has(name)))
195
+ continue;
196
+ const literals = memberLiteralProps.map((mp) => mp.get(name));
197
+ const distinct = new Set(literals.map((l) => JSON.stringify(l)));
198
+ if (distinct.size === literals.length)
199
+ candidates.push(name);
200
+ }
201
+ if (candidates.length !== 1) {
202
+ return {
203
+ kind: "invalid",
204
+ reason: candidates.length === 0
205
+ ? "No discriminator found for the oneOf tagged union (issue #1511): every member must share exactly one property declared as a distinct single-literal enum."
206
+ : `Ambiguous discriminator for the oneOf tagged union (issue #1511): multiple candidate properties (${candidates.join(", ")}). Exactly one is required.`,
207
+ };
208
+ }
209
+ // A clean tagged union carries ONLY `oneOf`. If it co-occurs with sibling
210
+ // top-level constraints (`type`, `properties`, `required`,
211
+ // `additionalProperties`, `items`, `enum`), it is a MIXED schema, not a clean
212
+ // tagged union: the validator's branch-select would early-return and skip
213
+ // those siblings, loosening validation. Reject-mixed keeps all three
214
+ // consumers fail-closed — the validator falls through to the normal
215
+ // type/object gates (still enforcing the siblings, exactly as before #1511),
216
+ // codegen throws this `reason`, and the request guard flags `unsupported-oneof`.
217
+ if (hasOneOfSiblingConstraints(schema)) {
218
+ return {
219
+ kind: "invalid",
220
+ reason: "A discriminated-union oneOf must be the only top-level constraint (issue #1511): it cannot be combined with sibling type/properties/required/additionalProperties/items/enum. Move the shared constraints into each member instead.",
221
+ };
222
+ }
223
+ const discriminant = candidates[0];
224
+ return {
225
+ kind: "valid",
226
+ discriminant,
227
+ members: members.map((m, i) => ({
228
+ discriminantValue: memberLiteralProps[i].get(discriminant),
229
+ schema: m,
230
+ })),
231
+ };
232
+ }
233
+ /**
234
+ * Interpret a parsed schema node. A non-object schema (null, array, scalar)
235
+ * enforces nothing → the empty descriptor.
236
+ */
237
+ export function describeSchema(schema) {
238
+ if (!schema || typeof schema !== "object" || Array.isArray(schema)) {
239
+ return EMPTY_DESCRIPTOR;
240
+ }
241
+ const typeSpec = schema.type;
242
+ const isUnion = Array.isArray(typeSpec);
243
+ const singularType = typeof typeSpec === "string" ? typeSpec : null;
244
+ // Mirror the validator's normalization exactly: an array stays an array; a
245
+ // truthy non-array becomes `[typeSpec]`; anything falsy is `[]`.
246
+ const types = isUnion ? typeSpec : typeSpec ? [typeSpec] : [];
247
+ const enumValues = Array.isArray(schema.enum)
248
+ ? schema.enum
249
+ : null;
250
+ const props = schema.properties;
251
+ const object = singularType === "object" &&
252
+ props &&
253
+ typeof props === "object" &&
254
+ !Array.isArray(props)
255
+ ? {
256
+ properties: props,
257
+ required: Array.isArray(schema.required)
258
+ ? schema.required
259
+ : [],
260
+ additionalPropertiesClosed: schema.additionalProperties === false,
261
+ }
262
+ : null;
263
+ const array = singularType === "array" && schema.items
264
+ ? { items: schema.items }
265
+ : null;
266
+ const oneOf = describeOneOf(schema);
267
+ return { isUnion, singularType, types, enumValues, object, array, oneOf };
268
+ }
269
+ //# sourceMappingURL=generated-schema-descriptor.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"generated-schema-descriptor.js","sourceRoot":"","sources":["../../../../src/lib/workflow-codegen/generated-schema-descriptor.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAEH;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8BG;AAEH,sFAAsF;AACtF,MAAM,UAAU,MAAM,CAAC,KAAU,EAAE,IAAY;IAC7C,IAAI,IAAI,KAAK,OAAO;QAAE,OAAO,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC;IAClD,IAAI,IAAI,KAAK,QAAQ;QACnB,OAAO,CAAC,CAAC,KAAK,IAAI,OAAO,KAAK,KAAK,QAAQ,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC;IACvE,IAAI,IAAI,KAAK,QAAQ;QAAE,OAAO,OAAO,KAAK,KAAK,QAAQ,CAAC;IACxD,IAAI,IAAI,KAAK,QAAQ;QAAE,OAAO,OAAO,KAAK,KAAK,QAAQ,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;IAChF,IAAI,IAAI,KAAK,SAAS;QAAE,OAAO,MAAM,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC;IACvD,IAAI,IAAI,KAAK,SAAS;QAAE,OAAO,OAAO,KAAK,KAAK,SAAS,CAAC;IAC1D,IAAI,IAAI,KAAK,MAAM;QAAE,OAAO,KAAK,KAAK,IAAI,CAAC;IAC3C,4EAA4E;IAC5E,gEAAgE;IAChE,OAAO,IAAI,CAAC;AACd,CAAC;AA0ED,MAAM,gBAAgB,GAAqB;IACzC,OAAO,EAAE,KAAK;IACd,YAAY,EAAE,IAAI;IAClB,KAAK,EAAE,EAAE;IACT,UAAU,EAAE,IAAI;IAChB,MAAM,EAAE,IAAI;IACZ,KAAK,EAAE,IAAI;IACX,KAAK,EAAE,IAAI;CACZ,CAAC;AAEF;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CAAC,IAAI,CAAC;IAET,MAAM,KAAK,GAAI,MAAc,CAAC,UAAU,CAAC;IACzC,MAAM,MAAM,GACV,YAAY,KAAK,QAAQ;QACzB,KAAK;QACL,OAAO,KAAK,KAAK,QAAQ;QACzB,CAAC,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC;QACnB,CAAC,CAAC;YACE,UAAU,EAAE,KAA4B;YACxC,QAAQ,EAAE,KAAK,CAAC,OAAO,CAAE,MAAc,CAAC,QAAQ,CAAC;gBAC/C,CAAC,CAAE,MAAc,CAAC,QAAQ;gBAC1B,CAAC,CAAC,EAAE;YACN,0BAA0B,EACvB,MAAc,CAAC,oBAAoB,KAAK,KAAK;SACjD;QACH,CAAC,CAAC,IAAI,CAAC;IAEX,MAAM,KAAK,GACT,YAAY,KAAK,OAAO,IAAK,MAAc,CAAC,KAAK;QAC/C,CAAC,CAAC,EAAE,KAAK,EAAG,MAAc,CAAC,KAAK,EAAE;QAClC,CAAC,CAAC,IAAI,CAAC;IAEX,MAAM,KAAK,GAAG,aAAa,CAAC,MAA6B,CAAC,CAAC;IAE3D,OAAO,EAAE,OAAO,EAAE,YAAY,EAAE,KAAK,EAAE,UAAU,EAAE,MAAM,EAAE,KAAK,EAAE,KAAK,EAAE,CAAC;AAC5E,CAAC"}
@@ -0,0 +1,87 @@
1
+ /**
2
+ * `workflows codegen` orchestrator (issue #1442).
3
+ *
4
+ * Reads synced workflow TOMLs (`.primitive/sync/<env>/<appId>/workflows/*.toml`)
5
+ * and emits ONE generated file per workflow —
6
+ * `workflows/generated/<key>.generated.ts` — each containing the workflow's
7
+ * `<Key>Input`/`<Key>Output` types plus a typed `<key>(client)` invoker factory
8
+ * returning `{ runSync?, start, getStatus }`. This mirrors `databases codegen`'s per-type
9
+ * `<Type>.generated.ts` layout (#1441's `<type>Ops`): per-file artifacts keep
10
+ * team merges conflict-free and let a `[workflow-key]` filter regenerate exactly
11
+ * one file.
12
+ *
13
+ * Design decisions (see the plan of record on #1442, post-pivot):
14
+ * - Schemas are interpreted through the SHARED descriptor
15
+ * (`generated-schema-descriptor.ts`, a vendored copy of the server's
16
+ * `schema-validation` descriptor) so the generated types match runtime
17
+ * validation exactly. A malformed schema throws (fail-and-exit).
18
+ * - `.runSync` is emitted only for `syncCallable: true` workflows (the server
19
+ * rejects run-sync otherwise); `.start`, `.getStatus`, and `.terminate` for
20
+ * every non-reserved workflow (the typed async path, issue #1512 —
21
+ * async-only workflows are exactly the ones that need a typed `getStatus` /
22
+ * `terminate`). `.terminate` binds `<Key>Output` (a terminated run can carry
23
+ * partial output); issue #1543 added the member, reversing #1512's
24
+ * start/status-only decision.
25
+ * - `.define` is emitted only for an apply-mode workflow
26
+ * (`requiresClientApply !== false`, the server's default). It binds
27
+ * `<Key>Output` so the `onApply` handler's `output` is the workflow's real
28
+ * output type rather than `any` (issue #1543, on top of #1542's
29
+ * `define<O>` / `WorkflowDefineOptions<O>` generics). `getPendingApplies`
30
+ * gets no member — #1542 made it a concrete `PendingApply[]` with no output
31
+ * to bind, and it is scoped to a document rather than a workflow.
32
+ * - `.cronTriggers.{create,update}` bind `<Key>Input` to the trigger's
33
+ * `rootInput` and pin `workflowKey`, so a cron helper can't be redirected at
34
+ * another workflow (issue #1543). `rootInput` is `Partial<<Key>Input>` for
35
+ * an object-shaped input schema (an `inputMapping` may supply the rest) and
36
+ * the full `<Key>Input` otherwise.
37
+ * - `input` is a REQUIRED option iff the schema rejects `{}` (the client's
38
+ * `input ?? {}` fallback would fail validation); otherwise `input?`.
39
+ * - The runtime call always passes the ORIGINAL key string; only identifiers
40
+ * are sanitized. `workflowKey` is set AFTER spreading `opts`, so a caller
41
+ * cannot override it.
42
+ * - Disk lifecycle (write / `--check` / suffix-based cleanup) delegates to the
43
+ * shared `writeOrCheckGeneratedFiles`, exactly like `databases codegen`.
44
+ */
45
+ import { type WriteOrCheckResult } from "../codegen-shared/generatedFiles.js";
46
+ /** Suffix identifying a generated file (shared with `databases codegen`). */
47
+ export declare const GENERATED_FILE_SUFFIX = ".generated.ts";
48
+ export interface WorkflowCodegenInput {
49
+ /** Source `.toml` filename stem (fallback key when `[workflow].key` is absent). */
50
+ fileStem: string;
51
+ /** Path to the source `workflows/<key>.toml` file. */
52
+ tomlPath: string;
53
+ /** Raw TOML content (already read from disk). */
54
+ tomlContent: string;
55
+ }
56
+ export interface GenerateWorkflowTypesOptions {
57
+ inputs: WorkflowCodegenInput[];
58
+ /** Directory where the `<key>.generated.ts` files are written. */
59
+ outputDir: string;
60
+ /** `--check`: compare against disk, do not write. */
61
+ check?: boolean;
62
+ /**
63
+ * Set when the run was filtered to a single workflow key (the
64
+ * `primitive workflows codegen <key>` argument). The `inputs` set is then
65
+ * PARTIAL — it does not represent the full set of owned generated files — so
66
+ * stale-output cleanup (and `--check` stale detection) is scoped to the
67
+ * filtered workflow's own file and must NOT touch / flag sibling workflows'
68
+ * `*.generated.ts` files. The unfiltered "generate all" run leaves this unset
69
+ * and keeps full orphan cleanup. Mirrors `databases codegen`'s `singleType`.
70
+ */
71
+ singleWorkflow?: boolean;
72
+ }
73
+ /**
74
+ * Render the full `<key>.generated.ts` content for a single workflow TOML input.
75
+ * Returns null for a reserved (`__internal.*`) workflow. Pure — exported so
76
+ * tests can assert on the string directly.
77
+ */
78
+ export declare function renderWorkflowFile(input: WorkflowCodegenInput): {
79
+ key: string;
80
+ content: string;
81
+ } | null;
82
+ /**
83
+ * Run workflow codegen end-to-end. One `<key>.generated.ts` per workflow;
84
+ * delegates the disk lifecycle to the shared writer/checker, exactly like
85
+ * `databases codegen`.
86
+ */
87
+ export declare function generateWorkflowTypes(options: GenerateWorkflowTypesOptions): Promise<WriteOrCheckResult>;