primitive-admin 1.0.44 → 1.0.46

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 (81) hide show
  1. package/README.md +43 -0
  2. package/assets/skill/skills/primitive-platform/SKILL.md +85 -26
  3. package/dist/bin/primitive.js +6 -0
  4. package/dist/bin/primitive.js.map +1 -1
  5. package/dist/src/commands/analytics.js +16 -16
  6. package/dist/src/commands/analytics.js.map +1 -1
  7. package/dist/src/commands/apps.js +14 -14
  8. package/dist/src/commands/apps.js.map +1 -1
  9. package/dist/src/commands/auth.js +70 -20
  10. package/dist/src/commands/auth.js.map +1 -1
  11. package/dist/src/commands/blob-buckets.js +11 -11
  12. package/dist/src/commands/blob-buckets.js.map +1 -1
  13. package/dist/src/commands/catalog.js +17 -17
  14. package/dist/src/commands/catalog.js.map +1 -1
  15. package/dist/src/commands/collection-type-configs.js +5 -5
  16. package/dist/src/commands/collection-type-configs.js.map +1 -1
  17. package/dist/src/commands/collections.js +6 -6
  18. package/dist/src/commands/collections.js.map +1 -1
  19. package/dist/src/commands/comparisons.js +6 -6
  20. package/dist/src/commands/comparisons.js.map +1 -1
  21. package/dist/src/commands/cron-triggers.js +17 -17
  22. package/dist/src/commands/cron-triggers.js.map +1 -1
  23. package/dist/src/commands/database-types.js +13 -13
  24. package/dist/src/commands/database-types.js.map +1 -1
  25. package/dist/src/commands/databases.js +266 -8
  26. package/dist/src/commands/databases.js.map +1 -1
  27. package/dist/src/commands/email-templates.js +6 -6
  28. package/dist/src/commands/email-templates.js.map +1 -1
  29. package/dist/src/commands/env.js +6 -6
  30. package/dist/src/commands/env.js.map +1 -1
  31. package/dist/src/commands/group-type-configs.js +6 -6
  32. package/dist/src/commands/group-type-configs.js.map +1 -1
  33. package/dist/src/commands/groups.js +7 -7
  34. package/dist/src/commands/groups.js.map +1 -1
  35. package/dist/src/commands/init.js +175 -144
  36. package/dist/src/commands/init.js.map +1 -1
  37. package/dist/src/commands/integrations.js +31 -21
  38. package/dist/src/commands/integrations.js.map +1 -1
  39. package/dist/src/commands/prompts.js +17 -16
  40. package/dist/src/commands/prompts.js.map +1 -1
  41. package/dist/src/commands/rule-sets.js +8 -8
  42. package/dist/src/commands/rule-sets.js.map +1 -1
  43. package/dist/src/commands/sync.js +1054 -284
  44. package/dist/src/commands/sync.js.map +1 -1
  45. package/dist/src/commands/tokens.js +9 -9
  46. package/dist/src/commands/tokens.js.map +1 -1
  47. package/dist/src/commands/users.js +44 -3
  48. package/dist/src/commands/users.js.map +1 -1
  49. package/dist/src/commands/webhooks.js +18 -18
  50. package/dist/src/commands/webhooks.js.map +1 -1
  51. package/dist/src/commands/workflows.js +285 -63
  52. package/dist/src/commands/workflows.js.map +1 -1
  53. package/dist/src/lib/api-client.js +273 -72
  54. package/dist/src/lib/api-client.js.map +1 -1
  55. package/dist/src/lib/db-codegen/dbFingerprint.js +17 -0
  56. package/dist/src/lib/db-codegen/dbFingerprint.js.map +1 -0
  57. package/dist/src/lib/db-codegen/dbGenerator.js +255 -0
  58. package/dist/src/lib/db-codegen/dbGenerator.js.map +1 -0
  59. package/dist/src/lib/db-codegen/dbNaming.js +104 -0
  60. package/dist/src/lib/db-codegen/dbNaming.js.map +1 -0
  61. package/dist/src/lib/db-codegen/dbTemplates.js +138 -0
  62. package/dist/src/lib/db-codegen/dbTemplates.js.map +1 -0
  63. package/dist/src/lib/db-codegen/dbTsTypes.js +61 -0
  64. package/dist/src/lib/db-codegen/dbTsTypes.js.map +1 -0
  65. package/dist/src/lib/migration-nag.js +163 -0
  66. package/dist/src/lib/migration-nag.js.map +1 -0
  67. package/dist/src/lib/output.js +58 -6
  68. package/dist/src/lib/output.js.map +1 -1
  69. package/dist/src/lib/refresh-admin-credentials.js +103 -0
  70. package/dist/src/lib/refresh-admin-credentials.js.map +1 -0
  71. package/dist/src/lib/template.js +80 -1
  72. package/dist/src/lib/template.js.map +1 -1
  73. package/dist/src/lib/toml-database-config.js +565 -0
  74. package/dist/src/lib/toml-database-config.js.map +1 -0
  75. package/dist/src/lib/toml-params-validator.js +183 -0
  76. package/dist/src/lib/toml-params-validator.js.map +1 -0
  77. package/dist/src/lib/workflow-fragments.js +121 -0
  78. package/dist/src/lib/workflow-fragments.js.map +1 -0
  79. package/dist/src/lib/workflow-toml-validator.js +343 -0
  80. package/dist/src/lib/workflow-toml-validator.js.map +1 -0
  81. package/package.json +2 -1
@@ -0,0 +1,565 @@
1
+ /**
2
+ * Helpers for emitting `DatabaseTypeOperation` configs as native TOML.
3
+ *
4
+ * Background (issue #752): historically `sync pull` serialized
5
+ * `definition` and `params` as JSON strings stuffed into a single TOML
6
+ * field, which produced unreviewable 800-char one-liners. This module
7
+ * lets us emit them as nested TOML tables when they're representable,
8
+ * while preserving the existing file's shape so we don't generate
9
+ * surprise diffs.
10
+ *
11
+ * Three responsibilities:
12
+ * 1. `detectExistingOperationForms()` — read the raw TOML source and
13
+ * decide, per operation name, whether the file uses JSON-string
14
+ * form ("legacy") or nested-table form ("native") for each of
15
+ * `definition` and `params`. This drives form preservation on
16
+ * `sync pull`.
17
+ * 2. `canEmitNative()` — recursively check whether a JS value is
18
+ * representable as a TOML value. Returns a reason string if not.
19
+ * Mainly catches `null` and mixed-type arrays, which `@iarna/toml`
20
+ * either rejects or silently mangles.
21
+ * 3. `buildDatabaseTypeTomlData()` — builds the JS object that we
22
+ * hand to `TOML.stringify`. Per operation, decides JSON-string vs
23
+ * native based on (existing form, can-emit, override mode).
24
+ */
25
+ import * as TOML from "@iarna/toml";
26
+ /**
27
+ * Inspect the raw TOML source for a database-type file and decide which
28
+ * form each operation's `definition`/`params` currently use.
29
+ *
30
+ * Detection is intentionally simple: we walk `[[operations]]` blocks in
31
+ * source order and, for each one, look for either a `definition = '...'`
32
+ * line (legacy) or an `[operations.definition]` / `[operations.definition.X]`
33
+ * sub-header (native).
34
+ */
35
+ export function detectExistingOperationForms(rawToml) {
36
+ const lines = rawToml.split(/\r?\n/);
37
+ const operations = [];
38
+ let current = null;
39
+ // `inSubTable` flips to true the moment we descend into a sub-table of
40
+ // the current operation (e.g. `[operations.definition]` or
41
+ // `[[operations.params]]`). Once true, subsequent `name = "..."` /
42
+ // `definition = "..."` / `params = "..."` lines belong to the sub-table,
43
+ // not to the operation itself, so we must not let them overwrite the
44
+ // op-level fields (review feedback r3246634568).
45
+ let inSubTable = false;
46
+ for (const rawLine of lines) {
47
+ const line = rawLine.trim();
48
+ if (line === "[[operations]]") {
49
+ if (current)
50
+ operations.push(current);
51
+ current = { name: null, definition: null, params: null };
52
+ inSubTable = false;
53
+ continue;
54
+ }
55
+ if (!current)
56
+ continue;
57
+ // Sub-header for this op's definition or params.
58
+ if (/^\[operations\.definition(\..+)?\]/.test(line) || /^\[\[operations\.definition\..+\]\]/.test(line)) {
59
+ if (current.definition === null)
60
+ current.definition = "native";
61
+ inSubTable = true;
62
+ continue;
63
+ }
64
+ if (/^\[\[operations\.params\]\]/.test(line) || /^\[operations\.params(\..+)?\]/.test(line)) {
65
+ if (current.params === null)
66
+ current.params = "native";
67
+ inSubTable = true;
68
+ continue;
69
+ }
70
+ // A new top-level array-of-tables block ends the operation's scope
71
+ // for our purposes. We don't fully parse TOML here; we just stop
72
+ // ascribing later lines to this op.
73
+ if (/^\[\[/.test(line) && !line.startsWith("[[operations.")) {
74
+ operations.push(current);
75
+ current = null;
76
+ inSubTable = false;
77
+ continue;
78
+ }
79
+ if (/^\[/.test(line) && !line.startsWith("[operations.")) {
80
+ operations.push(current);
81
+ current = null;
82
+ inSubTable = false;
83
+ continue;
84
+ }
85
+ // Op-level fields. Skip if we've already descended into a sub-table —
86
+ // a `name = "id"` inside `[[operations.params]]` belongs to the param,
87
+ // not to the operation. Same for any other key we recognize here.
88
+ if (inSubTable)
89
+ continue;
90
+ const m = line.match(/^([a-zA-Z_][a-zA-Z0-9_]*)\s*=\s*(.*)$/);
91
+ if (!m)
92
+ continue;
93
+ const key = m[1];
94
+ const value = m[2];
95
+ if (key === "name") {
96
+ const nameMatch = value.match(/^["'](.+)["']\s*$/);
97
+ if (nameMatch)
98
+ current.name = nameMatch[1];
99
+ }
100
+ else if (key === "definition" && current.definition === null) {
101
+ current.definition = "legacy";
102
+ }
103
+ else if (key === "params" && current.params === null) {
104
+ current.params = "legacy";
105
+ }
106
+ }
107
+ if (current)
108
+ operations.push(current);
109
+ const definition = new Map();
110
+ const params = new Map();
111
+ for (const op of operations) {
112
+ if (!op.name)
113
+ continue;
114
+ if (op.definition)
115
+ definition.set(op.name, op.definition);
116
+ if (op.params)
117
+ params.set(op.name, op.params);
118
+ }
119
+ return { definition, params };
120
+ }
121
+ /**
122
+ * Recursively check whether a JS value can be safely serialized to TOML
123
+ * using `@iarna/toml`. Returns null if OK, a reason string otherwise.
124
+ *
125
+ * Things TOML can't represent (in `@iarna/toml`):
126
+ * - `null` (TOML has no null).
127
+ * - Arrays containing values of different "TOML types" (e.g. mixed
128
+ * string and number). Spec-wise TOML 1.0 actually allows this, but
129
+ * `@iarna/toml` is strict and throws.
130
+ * - `undefined` (different from null but equally not representable).
131
+ */
132
+ export function canEmitNative(value) {
133
+ if (value === null)
134
+ return "value is null";
135
+ if (value === undefined)
136
+ return "value is undefined";
137
+ if (Array.isArray(value)) {
138
+ if (value.length > 0) {
139
+ const types = new Set();
140
+ for (const item of value) {
141
+ if (item === null)
142
+ return "array contains null";
143
+ if (Array.isArray(item))
144
+ types.add("array");
145
+ else
146
+ types.add(typeof item);
147
+ }
148
+ if (types.size > 1) {
149
+ return `array contains mixed types (${[...types].sort().join(", ")})`;
150
+ }
151
+ }
152
+ for (const item of value) {
153
+ const sub = canEmitNative(item);
154
+ if (sub)
155
+ return sub;
156
+ }
157
+ return null;
158
+ }
159
+ if (typeof value === "object") {
160
+ for (const v of Object.values(value)) {
161
+ const sub = canEmitNative(v);
162
+ if (sub)
163
+ return sub;
164
+ }
165
+ return null;
166
+ }
167
+ // primitives: string, number, boolean.
168
+ return null;
169
+ }
170
+ /**
171
+ * Normalize a `params` value into a sorted array of
172
+ * `{ name, type, required, ... }` rows, suitable for emitting as
173
+ * `[[operations.params]]`. Accepts both shapes the wire/parser supports:
174
+ * - object form: `{ projectId: { type: "string", required: true } }`
175
+ * - array form: `[{ name: "projectId", type: "string", required: true }]`
176
+ */
177
+ export function normalizeParamsToArray(params) {
178
+ if (params == null)
179
+ return null;
180
+ if (Array.isArray(params)) {
181
+ return params
182
+ .map((p) => ({ ...p }))
183
+ .filter((p) => p && typeof p === "object");
184
+ }
185
+ if (typeof params === "object") {
186
+ return Object.entries(params).map(([name, spec]) => ({
187
+ name,
188
+ ...(spec && typeof spec === "object" ? spec : {}),
189
+ }));
190
+ }
191
+ return null;
192
+ }
193
+ /**
194
+ * Default form for a new operation (no existing form hint): native.
195
+ * That matches the issue's "new file from server → native by default"
196
+ * requirement.
197
+ */
198
+ const DEFAULT_FORM = "native";
199
+ /**
200
+ * Build the JS object to pass to `TOML.stringify` for a database-type
201
+ * config file. Per operation:
202
+ * - If the chosen form is "native" AND `definition` is TOML-emittable,
203
+ * emit `[operations.definition]` (nested table).
204
+ * - Else emit `definition = '<json string>'` and log a message.
205
+ * - Same logic independently for `params`, but the native form for
206
+ * params is `[[operations.params]]` (array-of-tables).
207
+ */
208
+ export function buildDatabaseTypeTomlData(typeConfig, operations, ruleSetIdToName, options = {}) {
209
+ const hints = options.hints;
210
+ const defaultForm = options.defaultForm ?? DEFAULT_FORM;
211
+ const log = options.logger ?? (() => { });
212
+ // Prefer the parsed-from-key-based-reference name when present
213
+ // (`_ruleSetName` is set by `parseDatabaseTypeToml` when the source TOML
214
+ // uses the modern `ruleSetName = "..."` form). This makes the
215
+ // parse → serialize cycle a no-op for the rule-set field even when the
216
+ // caller passes an empty `ruleSetIdToName` map (e.g. `sync migrate-toml`,
217
+ // review feedback r3246633010).
218
+ let ruleSetName = "";
219
+ if (typeConfig._ruleSetName) {
220
+ ruleSetName = typeConfig._ruleSetName;
221
+ }
222
+ else if (typeConfig.ruleSetId) {
223
+ ruleSetName = ruleSetIdToName.get(typeConfig.ruleSetId) || "";
224
+ }
225
+ const data = {
226
+ type: {
227
+ databaseType: typeConfig.databaseType,
228
+ ruleSetName,
229
+ },
230
+ };
231
+ if (typeConfig.metadataAccess) {
232
+ data.type.celContextAccess = typeConfig.metadataAccess;
233
+ }
234
+ if (typeConfig.defaultAccess) {
235
+ data.type.defaultAccess = typeConfig.defaultAccess;
236
+ }
237
+ if (typeConfig.autoPopulatedFields) {
238
+ data.type.autoPopulatedFields = typeConfig.autoPopulatedFields;
239
+ }
240
+ // timestamps (issue #748) — emitted as an inline table under `[type]`. The
241
+ // server returns the parsed `{ create?, update?, models? }` object, which
242
+ // serializes 1:1 so a pull → push cycle is idempotent.
243
+ if (typeConfig.timestamps) {
244
+ data.type.timestamps = typeConfig.timestamps;
245
+ }
246
+ if (typeConfig.triggers) {
247
+ data.triggers = typeConfig.triggers;
248
+ }
249
+ // Issue #666: inline schema TOML. The server-side `schema` field is a raw
250
+ // TOML string of `[models.*.fields.*]` blocks. Parse + merge into the same
251
+ // TOML object so the result serializes as `[models.<Name>.fields.<field>]`
252
+ // headers (matches the round-2 plan-of-record CLI sync layout).
253
+ if (typeConfig.schema && typeof typeConfig.schema === "string") {
254
+ try {
255
+ const parsedSchema = TOML.parse(typeConfig.schema);
256
+ if (parsedSchema?.models) {
257
+ data.models = parsedSchema.models;
258
+ }
259
+ }
260
+ catch {
261
+ // If the stored TOML is malformed (operationally surprising), don't
262
+ // crash the serializer — fall through without the models block.
263
+ }
264
+ }
265
+ // Subscriptions (issue #803) — emitted as `[[subscriptions]]` array-of-
266
+ // tables, independent of operations. Built before the operations-only
267
+ // early return so a type with subscriptions but no operations still emits
268
+ // them.
269
+ const subscriptionRows = buildSubscriptionRows(options.subscriptions, log);
270
+ if (operations.length === 0) {
271
+ if (subscriptionRows.length > 0) {
272
+ data.subscriptions = subscriptionRows;
273
+ }
274
+ return data;
275
+ }
276
+ data.operations = operations.map((op) => {
277
+ const opRow = {
278
+ name: op.name,
279
+ type: op.type,
280
+ modelName: op.modelName,
281
+ };
282
+ if (op.access) {
283
+ opRow.access = op.access;
284
+ }
285
+ // ---- definition ----
286
+ const defForm = hints?.definition.get(op.name) ?? defaultForm;
287
+ const defValue = typeof op.definition === "string"
288
+ ? safeParseJson(op.definition)
289
+ : op.definition;
290
+ let definitionEmitted = false;
291
+ if (defForm === "native" && defValue && typeof defValue === "object") {
292
+ const reason = canEmitNative(defValue);
293
+ if (reason) {
294
+ log(`Operation '${op.name}': cannot emit \`definition\` as native TOML (${reason}); falling back to JSON string for this field.`);
295
+ }
296
+ else {
297
+ opRow.definition = defValue;
298
+ definitionEmitted = true;
299
+ }
300
+ }
301
+ if (!definitionEmitted) {
302
+ opRow.definition = typeof op.definition === "object"
303
+ ? JSON.stringify(op.definition)
304
+ : op.definition;
305
+ }
306
+ // ---- params ----
307
+ if (op.params != null) {
308
+ const paramsForm = hints?.params.get(op.name) ?? defaultForm;
309
+ let paramsEmitted = false;
310
+ if (paramsForm === "native") {
311
+ const paramsParsed = typeof op.params === "string"
312
+ ? safeParseJson(op.params)
313
+ : op.params;
314
+ const paramsArray = normalizeParamsToArray(paramsParsed);
315
+ if (paramsArray && paramsArray.length > 0) {
316
+ const reason = canEmitNative(paramsArray);
317
+ if (reason) {
318
+ log(`Operation '${op.name}': cannot emit \`params\` as native TOML (${reason}); falling back to JSON string for this field.`);
319
+ }
320
+ else {
321
+ opRow.params = paramsArray;
322
+ paramsEmitted = true;
323
+ }
324
+ }
325
+ else if (paramsArray && paramsArray.length === 0) {
326
+ // Empty params: skip entirely rather than emitting an empty table.
327
+ paramsEmitted = true;
328
+ }
329
+ }
330
+ if (!paramsEmitted) {
331
+ opRow.params = typeof op.params === "object"
332
+ ? JSON.stringify(op.params)
333
+ : op.params;
334
+ }
335
+ }
336
+ return opRow;
337
+ });
338
+ if (subscriptionRows.length > 0) {
339
+ data.subscriptions = subscriptionRows;
340
+ }
341
+ return data;
342
+ }
343
+ /**
344
+ * Build the `[[subscriptions]]` rows for a database-type TOML file from the
345
+ * server's sanitized subscription list (issue #803).
346
+ *
347
+ * Emits the canonical TOML key order and uses the wire key `access` (we read
348
+ * both `access` and `accessRule` on parse, but always emit `access` so a
349
+ * pull → push round-trip is stable). `select` / `emit` are plain string
350
+ * arrays; `params` is an inline object. Falls back to a JSON string for any
351
+ * field that TOML can't represent natively (mirrors operations'
352
+ * `definition` / `params` fallback), so an exotic `params` shape never
353
+ * breaks serialization.
354
+ */
355
+ function buildSubscriptionRows(subscriptions, log) {
356
+ if (!Array.isArray(subscriptions) || subscriptions.length === 0)
357
+ return [];
358
+ return subscriptions.map((sub) => {
359
+ const row = {
360
+ subscriptionKey: sub.subscriptionKey,
361
+ displayName: sub.displayName,
362
+ modelName: sub.modelName,
363
+ };
364
+ if (sub.description != null && sub.description !== "") {
365
+ row.description = sub.description;
366
+ }
367
+ if (sub.filter != null) {
368
+ row.filter = sub.filter;
369
+ }
370
+ if (sub.access != null) {
371
+ row.access = sub.access;
372
+ }
373
+ // `select` / `emit`: server sanitizes to arrays (or null). Emit when a
374
+ // non-empty array is present.
375
+ if (Array.isArray(sub.select) && sub.select.length > 0) {
376
+ row.select = sub.select;
377
+ }
378
+ if (Array.isArray(sub.emit) && sub.emit.length > 0) {
379
+ row.emit = sub.emit;
380
+ }
381
+ // `params`: server sanitizes to an object (or {}). Emit when non-empty.
382
+ if (sub.params &&
383
+ typeof sub.params === "object" &&
384
+ !Array.isArray(sub.params) &&
385
+ Object.keys(sub.params).length > 0) {
386
+ const reason = canEmitNative(sub.params);
387
+ if (reason) {
388
+ log(`Subscription '${sub.subscriptionKey}': cannot emit \`params\` as native TOML (${reason}); falling back to JSON string.`);
389
+ row.params = JSON.stringify(sub.params);
390
+ }
391
+ else {
392
+ row.params = sub.params;
393
+ }
394
+ }
395
+ // `status`: only emit when not the default "active" so round-tripped
396
+ // files stay clean.
397
+ if (sub.status && sub.status !== "active") {
398
+ row.status = sub.status;
399
+ }
400
+ return row;
401
+ });
402
+ }
403
+ function safeParseJson(s) {
404
+ try {
405
+ return JSON.parse(s);
406
+ }
407
+ catch {
408
+ return s;
409
+ }
410
+ }
411
+ /**
412
+ * Thrown when a `[[subscriptions]]` block declares both `accessRule` and
413
+ * `access` with different values. We never silently drop the field
414
+ * (issue #803 maintainer decision): prefer `access` when they agree, error
415
+ * when they conflict so the operator fixes the source of truth.
416
+ */
417
+ export class SubscriptionAccessKeyConflictError extends Error {
418
+ subscriptionKey;
419
+ constructor(subscriptionKey) {
420
+ super(`Subscription ${subscriptionKey ? `'${subscriptionKey}' ` : ""}declares both \`access\` and \`accessRule\` with different values. ` +
421
+ `Use one (prefer \`access\`, the wire/server key) or make them identical.`);
422
+ this.subscriptionKey = subscriptionKey;
423
+ this.name = "SubscriptionAccessKeyConflictError";
424
+ }
425
+ }
426
+ /**
427
+ * Resolve the subscription `access` CEL expression from a TOML row.
428
+ *
429
+ * The server's wire key is `access`; the issue author (and the guides) used
430
+ * `accessRule`. We accept both: prefer `access` when present, fall back to
431
+ * `accessRule`, and never silently drop the field. If both are present with
432
+ * different values, throw so the conflict is surfaced rather than guessed.
433
+ */
434
+ export function resolveSubscriptionAccess(sub) {
435
+ const hasAccess = sub.access !== undefined && sub.access !== null;
436
+ const hasAccessRule = sub.accessRule !== undefined && sub.accessRule !== null;
437
+ if (hasAccess && hasAccessRule && sub.access !== sub.accessRule) {
438
+ throw new SubscriptionAccessKeyConflictError(sub.subscriptionKey);
439
+ }
440
+ if (hasAccess)
441
+ return sub.access;
442
+ if (hasAccessRule)
443
+ return sub.accessRule;
444
+ return undefined;
445
+ }
446
+ /**
447
+ * Normalize a `[[subscriptions]]` TOML row into the server's wire shape.
448
+ *
449
+ * Mirrors `normalizeOperationFromToml`. Maps the `accessRule`→`access`
450
+ * alias (issue #803), and passes `select` / `emit` / `params` through in
451
+ * native form — the server stores them as JSON strings and re-parses on
452
+ * read (`sanitizeSubscription`), so the parse → push → pull round-trip is
453
+ * symmetric with operations' `definition` / `params`.
454
+ *
455
+ * `filter` stays required server-side; we forward whatever is present (or
456
+ * undefined) and let the controller's clean named 400 surface.
457
+ */
458
+ export function normalizeSubscriptionFromToml(sub) {
459
+ const normalized = {
460
+ subscriptionKey: sub.subscriptionKey,
461
+ displayName: sub.displayName,
462
+ modelName: sub.modelName,
463
+ filter: sub.filter,
464
+ access: resolveSubscriptionAccess(sub),
465
+ };
466
+ // Optional fields are *always* assigned (explicit `null` when absent),
467
+ // mirroring how `normalizeOperationFromToml` always assigns `params`
468
+ // (`= null` when absent). This is load-bearing for the update path: when an
469
+ // operator deletes one of these lines from a `[[subscriptions]]` block and
470
+ // re-pushes, the explicit `null` survives `JSON.stringify` in the PUT body
471
+ // (only `undefined` keys are dropped), passes the controller's
472
+ // `if (body.X !== undefined)` guard, and clears the prior server value.
473
+ // Leaving these `undefined` would silently retain the old server value and
474
+ // re-emit the just-deleted field on the next pull (a spurious diff, and for
475
+ // `select` a tighter-than-intended projection left live).
476
+ normalized.description =
477
+ sub.description !== undefined ? sub.description : null;
478
+ if (sub.status !== undefined) {
479
+ normalized.status = sub.status;
480
+ }
481
+ // `select` / `emit` are plain string arrays in native TOML form. The
482
+ // server validates and JSON-stringifies them; we forward as-is (or `null`
483
+ // to clear a removed line).
484
+ normalized.select = sub.select !== undefined ? sub.select : null;
485
+ normalized.emit = sub.emit !== undefined ? sub.emit : null;
486
+ // `params` accepts either native object form
487
+ // (`{ projectId = { type = "string" } }`) or the array-of-tables form
488
+ // (`[[subscriptions.params]]` rows with a `name` key). Convert array form
489
+ // back to the object the server expects, mirroring operations' params.
490
+ // Always assign (`null` when absent) so a removed `params` clears.
491
+ if (sub.params != null) {
492
+ if (Array.isArray(sub.params)) {
493
+ const obj = {};
494
+ for (const row of sub.params) {
495
+ if (!row || typeof row !== "object" || !row.name)
496
+ continue;
497
+ const { name, ...rest } = row;
498
+ obj[name] = rest;
499
+ }
500
+ normalized.params = obj;
501
+ }
502
+ else if (typeof sub.params === "object") {
503
+ normalized.params = sub.params;
504
+ }
505
+ else {
506
+ normalized.params = null;
507
+ }
508
+ }
509
+ else {
510
+ normalized.params = null;
511
+ }
512
+ return normalized;
513
+ }
514
+ /**
515
+ * After parsing TOML, normalize the `definition` and `params` of each
516
+ * operation row into the JS objects the server expects. Handles both
517
+ * native and legacy forms transparently. The server payload is the
518
+ * source of truth; native TOML is purely a source-control affordance.
519
+ *
520
+ * Mirrors `parseDatabaseTypeToml` in `sync.ts`, but is broken out here
521
+ * so the migrate-toml command can call it without re-implementing.
522
+ */
523
+ export function normalizeOperationFromToml(op) {
524
+ const normalized = {
525
+ name: op.name,
526
+ type: op.type,
527
+ modelName: op.modelName,
528
+ // `access` is optional — when the parent type sets `defaultAccess`,
529
+ // an operation may inherit by omitting this key. Keep null so the
530
+ // server-side controller decides whether to require it.
531
+ access: op.access ?? null,
532
+ };
533
+ if (typeof op.definition === "string") {
534
+ normalized.definition = safeParseJson(op.definition);
535
+ }
536
+ else {
537
+ // Preserve undefined-vs-set parity with the legacy parser by always
538
+ // assigning the key.
539
+ normalized.definition = op.definition;
540
+ }
541
+ if (op.params != null) {
542
+ if (typeof op.params === "string") {
543
+ normalized.params = safeParseJson(op.params);
544
+ }
545
+ else if (Array.isArray(op.params)) {
546
+ // Convert array form back into object form for the server payload.
547
+ const obj = {};
548
+ for (const row of op.params) {
549
+ if (!row || typeof row !== "object" || !row.name)
550
+ continue;
551
+ const { name, ...rest } = row;
552
+ obj[name] = rest;
553
+ }
554
+ normalized.params = obj;
555
+ }
556
+ else if (typeof op.params === "object") {
557
+ normalized.params = op.params;
558
+ }
559
+ }
560
+ else {
561
+ normalized.params = null;
562
+ }
563
+ return normalized;
564
+ }
565
+ //# sourceMappingURL=toml-database-config.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"toml-database-config.js","sourceRoot":"","sources":["../../../src/lib/toml-database-config.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AAEH,OAAO,KAAK,IAAI,MAAM,aAAa,CAAC;AAWpC;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