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,250 @@
1
+ /**
2
+ * Shared field descriptor for app-settings TOML sync (issue #1033).
3
+ *
4
+ * A single source of truth describing every app setting that round-trips
5
+ * through `app.toml`. It drives BOTH directions:
6
+ * - pull (`serializeAppSettingsToToml`): server settings -> `app.toml` object
7
+ * - push (`parseTomlToAppSettings`): `app.toml` object -> settings payload
8
+ *
9
+ * Driving serializer and parser from one table means the two can never drift
10
+ * apart, and a single drift test can assert the descriptor stays in step with
11
+ * the server's `GET /settings` response and `PUT /settings` allow-list. This
12
+ * generalizes the earlier hand-maintained `AUTH_BOOLEAN_KEYS` /
13
+ * `RECOGNIZED_AUTH_KEYS` pattern to every section, and fully replaces it.
14
+ *
15
+ * Design decisions of record (issue #1033):
16
+ * - `googleClientSecret` is a secret: never written to `app.toml` on pull, and
17
+ * a hard error (abort before any PUT) if hand-added on push. Non-secret
18
+ * `googleClientId` syncs normally.
19
+ * - `[cors]` is always emitted (the `mode` key is `emit: "always"`), even in
20
+ * universal mode. A one-time diff on the next pull for existing apps is
21
+ * acceptable.
22
+ * - `[invitations]` is an additive table for the member-invitation fields.
23
+ * - Legacy `passkeyRpId` / `passkeyRpName` are still writable server-side but
24
+ * excluded from TOML (superseded by `passkeyRpConfig` -> `[auth.passkeys]`).
25
+ * The coverage test classifies them as deprecated-writable exclusions, NOT
26
+ * computed/read-only.
27
+ * - Push type mismatches are field-named validation errors — no silent
28
+ * coercion of a mistyped TOML value.
29
+ */
30
+ /**
31
+ * Every field that round-trips through `app.toml`. 26 entries — the server's
32
+ * `PUT /settings` allow-list minus the two deprecated legacy passkey fields.
33
+ * `googleClientSecret` is present but flagged `secret` (excluded from TOML).
34
+ */
35
+ export const APP_SETTINGS_DESCRIPTOR = [
36
+ // ---- [app] --------------------------------------------------------------
37
+ { field: "name", section: "app", key: "name", type: "string", emit: "always" },
38
+ { field: "mode", section: "app", key: "mode", type: "string", emit: "always" },
39
+ { field: "baseUrl", section: "app", key: "baseUrl", type: "string", emit: "whenSet" },
40
+ { field: "waitlistEnabled", section: "app", key: "waitlistEnabled", type: "boolean", emit: "always" },
41
+ { field: "waitlistNotifyAdmins", section: "app", key: "waitlistNotifyAdmins", type: "boolean", emit: "always" },
42
+ { field: "allowedDomains", section: "app", key: "allowedDomains", type: "string[]", emit: "whenSet" },
43
+ { field: "testAccountBaseEmails", section: "app", key: "testAccountBaseEmails", type: "string[]", emit: "whenSet" },
44
+ // ---- [auth] -------------------------------------------------------------
45
+ { field: "googleOAuthEnabled", section: "auth", key: "googleOAuthEnabled", type: "boolean", emit: "whenSet" },
46
+ { field: "googleClientId", section: "auth", key: "googleClientId", type: "string", emit: "whenSet" },
47
+ // Secret — omitted on pull, hard error on push. See GOOGLE_CLIENT_SECRET_PUSH_ERROR.
48
+ { field: "googleClientSecret", section: "auth", key: "googleClientSecret", type: "string", emit: "whenSet", secret: true },
49
+ { field: "passkeyEnabled", section: "auth", key: "passkeyEnabled", type: "boolean", emit: "always" },
50
+ { field: "magicLinkEnabled", section: "auth", key: "magicLinkEnabled", type: "boolean", emit: "always" },
51
+ { field: "appleSignInEnabled", section: "auth", key: "appleSignInEnabled", type: "boolean", emit: "whenSet" },
52
+ { field: "otpEnabled", section: "auth", key: "otpEnabled", type: "boolean", emit: "whenSet" },
53
+ { field: "appleAudiences", section: "auth", key: "appleAudiences", type: "string[]", emit: "whenSet" },
54
+ { field: "redirectUris", section: "auth", key: "redirectUris", type: "string[]", emit: "whenSet" },
55
+ // passkeyRpConfig <-> [auth.passkeys] (nested object of rpId -> { name }).
56
+ { field: "passkeyRpConfig", section: "auth", key: "passkeys", type: "object", emit: "whenSet" },
57
+ // ---- [cors] -------------------------------------------------------------
58
+ // `mode` is `always` so the [cors] table is always emitted (decision 3).
59
+ { field: "corsMode", section: "cors", key: "mode", type: "string", emit: "always" },
60
+ { field: "corsAllowedOrigins", section: "cors", key: "allowedOrigins", type: "string[]", emit: "whenSet" },
61
+ { field: "corsAllowCredentials", section: "cors", key: "allowCredentials", type: "boolean", emit: "whenSet" },
62
+ { field: "corsAllowedMethods", section: "cors", key: "allowedMethods", type: "string[]", emit: "whenSet" },
63
+ { field: "corsAllowedHeaders", section: "cors", key: "allowedHeaders", type: "string[]", emit: "whenSet" },
64
+ { field: "corsExposedHeaders", section: "cors", key: "exposedHeaders", type: "string[]", emit: "whenSet" },
65
+ { field: "corsMaxAge", section: "cors", key: "maxAge", type: "number", emit: "whenSet" },
66
+ // ---- [invitations] ------------------------------------------------------
67
+ { field: "memberInvitationsEnabled", section: "invitations", key: "enabled", type: "boolean", emit: "always" },
68
+ { field: "memberInvitationLimit", section: "invitations", key: "limit", type: "number", emit: "always" },
69
+ ];
70
+ /** Section render order for a stable, diff-friendly `app.toml`. */
71
+ export const APP_SETTINGS_SECTIONS = [
72
+ "app",
73
+ "auth",
74
+ "cors",
75
+ "invitations",
76
+ ];
77
+ /**
78
+ * `GET /settings` keys that are computed/read-only and never sync (no server
79
+ * setter). The external coverage drift test classifies these here.
80
+ */
81
+ export const IGNORED_GET_KEYS = new Set([
82
+ "appId",
83
+ "hasGoogleAuth",
84
+ "hasAppleAuth",
85
+ "hasPasskey",
86
+ "createdAt",
87
+ "modifiedAt",
88
+ ]);
89
+ /**
90
+ * Fields that ARE still writable server-side (present in the `PUT /settings`
91
+ * allow-list) but are deliberately excluded from TOML because a newer field
92
+ * supersedes them. Kept distinct from `IGNORED_GET_KEYS` so the coverage test's
93
+ * "every allow-listed field is covered" claim stays true — these are excluded,
94
+ * not read-only. (Codex design-review concern #1.)
95
+ */
96
+ export const DEPRECATED_WRITABLE_EXCLUDED = new Set([
97
+ "passkeyRpId",
98
+ "passkeyRpName",
99
+ ]);
100
+ /** Push error for a hand-added `googleClientSecret` — points at a real command. */
101
+ export const GOOGLE_CLIENT_SECRET_PUSH_ERROR = 'app.toml must not contain a "googleClientSecret" key under [auth]. ' +
102
+ "Secrets are excluded from synced config by design. Remove the key, then set " +
103
+ "the secret with:\n primitive apps update <appId> --google-client-secret <secret>";
104
+ const DESCRIPTOR_BY_SECTION = (() => {
105
+ const m = new Map();
106
+ for (const d of APP_SETTINGS_DESCRIPTOR) {
107
+ const list = m.get(d.section) ?? [];
108
+ list.push(d);
109
+ m.set(d.section, list);
110
+ }
111
+ return m;
112
+ })();
113
+ /** Descriptor `field` names, for parity/coverage tests. */
114
+ export const DESCRIPTOR_FIELDS = new Set(APP_SETTINGS_DESCRIPTOR.map((d) => d.field));
115
+ function typeOfValue(value) {
116
+ if (value === null || value === undefined)
117
+ return "null";
118
+ if (typeof value === "boolean")
119
+ return "boolean";
120
+ if (typeof value === "number")
121
+ return "number";
122
+ if (typeof value === "string")
123
+ return "string";
124
+ if (Array.isArray(value))
125
+ return "string[]";
126
+ if (typeof value === "object")
127
+ return "object";
128
+ return "unknown";
129
+ }
130
+ /** True if a value should be omitted under `emit: "whenSet"`. */
131
+ function isEmptyForEmit(value, type) {
132
+ if (value === null || value === undefined)
133
+ return true;
134
+ if (type === "string")
135
+ return value === "";
136
+ if (type === "string[]")
137
+ return !Array.isArray(value) || value.length === 0;
138
+ if (type === "object")
139
+ return (typeof value !== "object" ||
140
+ value === null ||
141
+ Object.keys(value).length === 0);
142
+ return false; // booleans (false) and numbers (0) are meaningful, never empty
143
+ }
144
+ /**
145
+ * Validate a push value against its descriptor type. Returns an error string
146
+ * (field-named) on mismatch, or `null` when the value is acceptable. Arrays are
147
+ * checked element-by-element so a `["a", 1]` mistype is caught.
148
+ */
149
+ function typeError(descriptor, value) {
150
+ const actual = typeOfValue(value);
151
+ if (actual === "null")
152
+ return null; // null clears; server owns clear semantics
153
+ if (descriptor.type === "string[]") {
154
+ if (!Array.isArray(value) || !value.every((v) => typeof v === "string")) {
155
+ return `[${descriptor.section}].${descriptor.key} must be an array of strings (got ${actual})`;
156
+ }
157
+ return null;
158
+ }
159
+ if (descriptor.type === "object") {
160
+ if (actual !== "object") {
161
+ return `[${descriptor.section}].${descriptor.key} must be a table (got ${actual})`;
162
+ }
163
+ return null;
164
+ }
165
+ if (actual !== descriptor.type) {
166
+ return `[${descriptor.section}].${descriptor.key} must be a ${descriptor.type} (got ${actual})`;
167
+ }
168
+ return null;
169
+ }
170
+ /**
171
+ * Build one `app.toml` section object from server settings (pull direction).
172
+ * Secret fields are never written. Applies each field's `emit` rule; a `null`
173
+ * value is always omitted (TOML cannot encode null).
174
+ */
175
+ export function serializeSection(settings, section) {
176
+ const out = {};
177
+ for (const d of DESCRIPTOR_BY_SECTION.get(section) ?? []) {
178
+ if (d.secret)
179
+ continue;
180
+ const value = settings[d.field];
181
+ if (value === null || value === undefined)
182
+ continue;
183
+ if (d.emit === "whenSet" && isEmptyForEmit(value, d.type))
184
+ continue;
185
+ out[d.key] = value;
186
+ }
187
+ return out;
188
+ }
189
+ /**
190
+ * Build the full `app.toml` data object (all sections) from server settings.
191
+ * Empty sections are omitted, though in practice every section has at least one
192
+ * `emit: "always"` key so all four are present.
193
+ */
194
+ export function serializeAppSettingsToToml(settings) {
195
+ const data = {};
196
+ for (const section of APP_SETTINGS_SECTIONS) {
197
+ const obj = serializeSection(settings, section);
198
+ if (Object.keys(obj).length > 0)
199
+ data[section] = obj;
200
+ }
201
+ return data;
202
+ }
203
+ /**
204
+ * Translate a parsed `app.toml` object into a `PUT /settings` payload (push
205
+ * direction). Only keys present in the TOML are forwarded — an omitted key
206
+ * never overwrites server state. Unknown keys warn; type mismatches and any
207
+ * secret key are hard errors that the caller must treat as abort-before-PUT.
208
+ *
209
+ * `isCrossAppPush` strips `name` so a cross-app push never overwrites the
210
+ * target app's name.
211
+ */
212
+ export function parseTomlToAppSettings(tomlData, options = {}) {
213
+ const settings = {};
214
+ const warnings = [];
215
+ const errors = [];
216
+ for (const section of APP_SETTINGS_SECTIONS) {
217
+ const sectionData = tomlData?.[section];
218
+ if (sectionData === undefined || sectionData === null)
219
+ continue;
220
+ if (typeof sectionData !== "object" || Array.isArray(sectionData)) {
221
+ errors.push(`[${section}] must be a table`);
222
+ continue;
223
+ }
224
+ const descriptors = DESCRIPTOR_BY_SECTION.get(section) ?? [];
225
+ const byKey = new Map(descriptors.map((d) => [d.key, d]));
226
+ for (const key of Object.keys(sectionData)) {
227
+ const d = byKey.get(key);
228
+ if (!d) {
229
+ warnings.push(`Unrecognized [${section}] key "${key}" in app.toml — ignored. ` +
230
+ `Recognized keys: ${descriptors.map((x) => x.key).join(", ")}.`);
231
+ continue;
232
+ }
233
+ if (d.secret) {
234
+ errors.push(GOOGLE_CLIENT_SECRET_PUSH_ERROR);
235
+ continue;
236
+ }
237
+ if (options.isCrossAppPush && d.field === "name")
238
+ continue;
239
+ const value = sectionData[key];
240
+ const err = typeError(d, value);
241
+ if (err) {
242
+ errors.push(err);
243
+ continue;
244
+ }
245
+ settings[d.field] = value;
246
+ }
247
+ }
248
+ return { settings, warnings, errors };
249
+ }
250
+ //# sourceMappingURL=app-settings-descriptor.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"app-settings-descriptor.js","sourceRoot":"","sources":["../../../src/lib/app-settings-descriptor.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;AAgCH;;;;GAIG;AACH,MAAM,CAAC,MAAM,uBAAuB,GAAoC;IACtE,4EAA4E;IAC5E,EAAE,KAAK,EAAE,MAAM,EAAE,OAAO,EAAE,KAAK,EAAE,GAAG,EAAE,MAAM,EAAE,IAAI,EAAE,QAAQ,EAAE,IAAI,EAAE,QAAQ,EAAE;IAC9E,EAAE,KAAK,EAAE,MAAM,EAAE,OAAO,EAAE,KAAK,EAAE,GAAG,EAAE,MAAM,EAAE,IAAI,EAAE,QAAQ,EAAE,IAAI,EAAE,QAAQ,EAAE;IAC9E,EAAE,KAAK,EAAE,SAAS,EAAE,OAAO,EAAE,KAAK,EAAE,GAAG,EAAE,SAAS,EAAE,IAAI,EAAE,QAAQ,EAAE,IAAI,EAAE,SAAS,EAAE;IACrF,EAAE,KAAK,EAAE,iBAAiB,EAAE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AC,cAAc,IAAI,CAAC,CAAC,KAAK,KAAK,MAAM;gBAAE,SAAS;YAC3D,MAAM,KAAK,GAAG,WAAW,CAAC,GAAG,CAAC,CAAC;YAC/B,MAAM,GAAG,GAAG,SAAS,CAAC,CAAC,EAAE,KAAK,CAAC,CAAC;YAChC,IAAI,GAAG,EAAE,CAAC;gBACR,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;gBACjB,SAAS;YACX,CAAC;YACD,QAAQ,CAAC,CAAC,CAAC,KAAK,CAAC,GAAG,KAAK,CAAC;QAC5B,CAAC;IACH,CAAC;IAED,OAAO,EAAE,QAAQ,EAAE,QAAQ,EAAE,MAAM,EAAE,CAAC;AACxC,CAAC"}
@@ -0,0 +1,26 @@
1
+ /**
2
+ * Shared helpers for the CLI's batch-import commands
3
+ * (`databases import` and `databases import-csv`).
4
+ */
5
+ /** Split an array into fixed-size chunks. */
6
+ export declare function chunk<T>(items: T[], size: number): T[][];
7
+ export interface ParseBatchSizeOptions {
8
+ /** Largest batch size the caller will accept. */
9
+ max: number;
10
+ /** Message shown when the value exceeds `max`. */
11
+ overMaxMessage: string;
12
+ }
13
+ /**
14
+ * Parse and validate a `--batch-size` flag value.
15
+ *
16
+ * Returns the parsed integer on success, or a human-readable error message
17
+ * on failure (non-integer, `< 1`, or over the caller's ceiling). Callers
18
+ * decide how to surface the error — typically `error(msg); process.exit(1)`.
19
+ * Validating up front means a bad `--batch-size` fails before any write, so
20
+ * there are no partial imports.
21
+ */
22
+ export declare function parseBatchSize(raw: string, opts: ParseBatchSizeOptions): {
23
+ value: number;
24
+ } | {
25
+ error: string;
26
+ };
@@ -0,0 +1,32 @@
1
+ /**
2
+ * Shared helpers for the CLI's batch-import commands
3
+ * (`databases import` and `databases import-csv`).
4
+ */
5
+ /** Split an array into fixed-size chunks. */
6
+ export function chunk(items, size) {
7
+ const out = [];
8
+ for (let i = 0; i < items.length; i += size) {
9
+ out.push(items.slice(i, i + size));
10
+ }
11
+ return out;
12
+ }
13
+ /**
14
+ * Parse and validate a `--batch-size` flag value.
15
+ *
16
+ * Returns the parsed integer on success, or a human-readable error message
17
+ * on failure (non-integer, `< 1`, or over the caller's ceiling). Callers
18
+ * decide how to surface the error — typically `error(msg); process.exit(1)`.
19
+ * Validating up front means a bad `--batch-size` fails before any write, so
20
+ * there are no partial imports.
21
+ */
22
+ export function parseBatchSize(raw, opts) {
23
+ const n = Number(raw);
24
+ if (!Number.isInteger(n) || n < 1) {
25
+ return { error: "--batch-size must be a positive integer." };
26
+ }
27
+ if (n > opts.max) {
28
+ return { error: opts.overMaxMessage };
29
+ }
30
+ return { value: n };
31
+ }
32
+ //# sourceMappingURL=batch.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"batch.js","sourceRoot":"","sources":["../../../src/lib/batch.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,6CAA6C;AAC7C,MAAM,UAAU,KAAK,CAAI,KAAU,EAAE,IAAY;IAC/C,MAAM,GAAG,GAAU,EAAE,CAAC;IACtB,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,KAAK,CAAC,MAAM,EAAE,CAAC,IAAI,IAAI,EAAE,CAAC;QAC5C,GAAG,CAAC,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,GAAG,IAAI,CAAC,CAAC,CAAC;IACrC,CAAC;IACD,OAAO,GAAG,CAAC;AACb,CAAC;AASD;;;;;;;;GAQG;AACH,MAAM,UAAU,cAAc,CAC5B,GAAW,EACX,IAA2B;IAE3B,MAAM,CAAC,GAAG,MAAM,CAAC,GAAG,CAAC,CAAC;IACtB,IAAI,CAAC,MAAM,CAAC,SAAS,CAAC,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC;QAClC,OAAO,EAAE,KAAK,EAAE,0CAA0C,EAAE,CAAC;IAC/D,CAAC;IACD,IAAI,CAAC,GAAG,IAAI,CAAC,GAAG,EAAE,CAAC;QACjB,OAAO,EAAE,KAAK,EAAE,IAAI,CAAC,cAAc,EAAE,CAAC;IACxC,CAAC;IACD,OAAO,EAAE,KAAK,EAAE,CAAC,EAAE,CAAC;AACtB,CAAC"}
@@ -0,0 +1,160 @@
1
+ /**
2
+ * Sync v2 "unified block" layout — issue #1183, Phase 3.
3
+ *
4
+ * The current (legacy) sync layout stores each managed block type in its own
5
+ * flat directory:
6
+ *
7
+ * config/
8
+ * prompts/<key>.toml
9
+ * integrations/<key>.toml
10
+ * workflows/<key>.toml
11
+ * transforms/<name>.rhai # scripts
12
+ *
13
+ * The v2 layout introduced by the unified block model groups every block type
14
+ * under one `blocks/` tree keyed by type and block key, with a single
15
+ * `block.toml` envelope per block (and a sibling `source.rhai` for scripts):
16
+ *
17
+ * config/
18
+ * blocks/
19
+ * prompts/<key>/block.toml
20
+ * integrations/<key>/block.toml
21
+ * workflows/<key>/block.toml
22
+ * scripts/<key>/block.toml
23
+ * scripts/<key>/source.rhai
24
+ *
25
+ * Per the proposal (docs/proposals/unified-block-model.md, "Phase 3: Sync v2"),
26
+ * the CLI must:
27
+ * - Read both legacy and v2 layouts.
28
+ * - Preserve the legacy layout as the default until v2 is proven.
29
+ * - Provide a migration command to convert legacy sync directories.
30
+ *
31
+ * This module is the pure, side-effect-light core of that work: the v2 path
32
+ * builders, the `block.toml` codec, layout detection, and the legacy -> v2
33
+ * migration. It stores the *verbatim* legacy TOML body under
34
+ * `[[versions]].spec`, so the transform is loss-free and a v2 block round-trips
35
+ * back to a byte-for-byte-equivalent legacy object (see `reconstructLegacyBlock`).
36
+ * That is what lets a later pass read a v2 directory through the same push path
37
+ * the legacy layout uses without re-deriving every type's field mapping.
38
+ */
39
+ export type BlockType = "prompt" | "integration" | "workflow" | "script";
40
+ export declare const BLOCK_TYPES: BlockType[];
41
+ /** The `schemaVersion` string written at the top of every v2 `block.toml`. */
42
+ export declare const BLOCK_SCHEMA_VERSION = "block/v1";
43
+ /** The filename of the script body written next to a v2 script `block.toml`. */
44
+ export declare const SCRIPT_SOURCE_FILENAME = "source.rhai";
45
+ export declare function isBlockType(value: unknown): value is BlockType;
46
+ /** `<configDir>/blocks` — the root of the v2 tree. */
47
+ export declare function v2BlocksRoot(configDir: string): string;
48
+ /** `<configDir>/blocks/<typeDir>/<key>` — a single v2 block's directory. */
49
+ export declare function v2BlockDir(configDir: string, type: BlockType, key: string): string;
50
+ /** `<configDir>/blocks/<typeDir>/<key>/block.toml`. */
51
+ export declare function v2BlockTomlPath(configDir: string, type: BlockType, key: string): string;
52
+ /** `<configDir>/blocks/scripts/<key>/source.rhai`. */
53
+ export declare function v2ScriptSourcePath(configDir: string, key: string): string;
54
+ /** `<configDir>/<legacyDir>` for a block type (flat layout). */
55
+ export declare function legacyBlockDir(configDir: string, type: BlockType): string;
56
+ export interface BlockVersionToml {
57
+ key: string;
58
+ status?: string;
59
+ contentHash?: string;
60
+ /** Verbatim type-native spec body (the legacy TOML object for this block). */
61
+ spec: Record<string, unknown>;
62
+ }
63
+ export interface BlockHeaderToml {
64
+ type: BlockType;
65
+ key: string;
66
+ displayName?: string;
67
+ description?: string;
68
+ status?: string;
69
+ activeVersion?: string;
70
+ }
71
+ export interface BlockToml {
72
+ schemaVersion: string;
73
+ block: BlockHeaderToml;
74
+ versions: BlockVersionToml[];
75
+ }
76
+ /**
77
+ * Serialize a v2 block into `block.toml` text. Key order is fixed
78
+ * (`schemaVersion`, `[block]`, `[[versions]]`) so a pull/migrate followed by a
79
+ * re-serialize is stable and produces no spurious diffs.
80
+ */
81
+ export declare function serializeBlockToml(block: BlockToml): string;
82
+ /**
83
+ * Parse `block.toml` text into a `BlockToml`. Throws with a clear message when
84
+ * the envelope is malformed (missing/invalid `[block].type`, no versions).
85
+ */
86
+ export declare function parseBlockToml(text: string): BlockToml;
87
+ /** `sha256:<hex>` content identity over the canonical JSON of a spec object. */
88
+ export declare function specContentHash(spec: unknown): string;
89
+ /**
90
+ * Wrap a parsed legacy block object into a v2 `BlockToml`. The full legacy
91
+ * object is stored verbatim as the single version's `spec`, so the transform
92
+ * loses nothing. The `[block]` header is a projection derived from the legacy
93
+ * header table for the unified vocabulary; the spec remains the source of truth
94
+ * for reconstructing the legacy file.
95
+ */
96
+ export declare function legacyObjectToBlock(type: Exclude<BlockType, "script">, legacy: Record<string, unknown>, fallbackKey: string): BlockToml;
97
+ /** Wrap a raw Rhai script body into a v2 script `BlockToml`. */
98
+ export declare function scriptSourceToBlock(key: string, source: string): BlockToml;
99
+ export interface ReconstructedLegacy {
100
+ /** For prompt/integration/workflow: the legacy `.toml` text. */
101
+ toml?: string;
102
+ /** For scripts: the raw `.rhai` body. */
103
+ rhai?: string;
104
+ }
105
+ /**
106
+ * Reverse `legacyObjectToBlock` / `scriptSourceToBlock`: rebuild the legacy
107
+ * on-disk content from a v2 block. This is the read half of dual-layout
108
+ * support — a v2 directory can be projected back to the exact legacy object a
109
+ * legacy consumer (e.g. the push path) expects. `sourceText` is required for
110
+ * scripts (the body lives in `source.rhai`, not the `block.toml`).
111
+ */
112
+ export declare function reconstructLegacyBlock(block: BlockToml, sourceText?: string): ReconstructedLegacy;
113
+ /**
114
+ * Report which layouts a config directory currently holds. A directory can
115
+ * hold both during/after a migration (legacy preserved, v2 written).
116
+ */
117
+ export declare function detectLayout(configDir: string): {
118
+ legacy: boolean;
119
+ v2: boolean;
120
+ };
121
+ export interface V2BlockRef {
122
+ type: BlockType;
123
+ key: string;
124
+ tomlPath: string;
125
+ sourcePath?: string;
126
+ }
127
+ /** Enumerate every v2 block present under `<configDir>/blocks/`. */
128
+ export declare function listV2Blocks(configDir: string): V2BlockRef[];
129
+ export interface MigratedBlock {
130
+ type: BlockType;
131
+ key: string;
132
+ tomlPath: string;
133
+ sourcePath?: string;
134
+ /** Number of test-case files copied into the v2 block's `tests/` dir. */
135
+ testsCopied: number;
136
+ }
137
+ export interface SkippedBlock {
138
+ type: BlockType;
139
+ key: string;
140
+ reason: string;
141
+ }
142
+ export interface MigrationResult {
143
+ blocks: MigratedBlock[];
144
+ skipped: SkippedBlock[];
145
+ dryRun: boolean;
146
+ }
147
+ export interface MigrateOptions {
148
+ /** Report what would happen without writing anything. */
149
+ dryRun?: boolean;
150
+ /** Overwrite an existing v2 `block.toml` instead of skipping it. */
151
+ force?: boolean;
152
+ }
153
+ /**
154
+ * Convert a legacy sync directory into the v2 `blocks/<type>/<key>/block.toml`
155
+ * layout. Non-destructive: the legacy files are left in place (the legacy
156
+ * layout stays the default until v2 is proven). Test-case directories
157
+ * (`<key>.tests/`) are copied verbatim into `blocks/<type>/<key>/tests/` so a
158
+ * tested block migrates without losing its cases.
159
+ */
160
+ export declare function migrateLegacyToV2(configDir: string, options?: MigrateOptions): MigrationResult;