primitive-admin 1.1.0-alpha.49 → 1.1.0-alpha.50

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 (85) hide show
  1. package/dist/bin/primitive.js +1 -1
  2. package/dist/src/commands/database-types.js +4 -4
  3. package/dist/src/commands/database-types.js.map +1 -1
  4. package/dist/src/commands/databases.js +5 -5
  5. package/dist/src/commands/databases.js.map +1 -1
  6. package/dist/src/commands/documents.js +2 -2
  7. package/dist/src/commands/documents.js.map +1 -1
  8. package/dist/src/commands/metadata.js +48 -3
  9. package/dist/src/commands/metadata.js.map +1 -1
  10. package/dist/src/commands/scripts.d.ts +18 -0
  11. package/dist/src/commands/scripts.js +59 -5
  12. package/dist/src/commands/scripts.js.map +1 -1
  13. package/dist/src/commands/sync-app-settings.d.ts +14 -4
  14. package/dist/src/commands/sync-app-settings.js +48 -8
  15. package/dist/src/commands/sync-app-settings.js.map +1 -1
  16. package/dist/src/commands/sync.d.ts +98 -0
  17. package/dist/src/commands/sync.js +1576 -400
  18. package/dist/src/commands/sync.js.map +1 -1
  19. package/dist/src/commands/workflows.js +23 -6
  20. package/dist/src/commands/workflows.js.map +1 -1
  21. package/dist/src/lib/api-client.d.ts +27 -1
  22. package/dist/src/lib/api-client.js +25 -2
  23. package/dist/src/lib/api-client.js.map +1 -1
  24. package/dist/src/lib/app-settings-descriptor.js +4 -0
  25. package/dist/src/lib/app-settings-descriptor.js.map +1 -1
  26. package/dist/src/lib/codegen-shared/generatedFiles.d.ts +21 -0
  27. package/dist/src/lib/codegen-shared/generatedFiles.js +40 -0
  28. package/dist/src/lib/codegen-shared/generatedFiles.js.map +1 -1
  29. package/dist/src/lib/codegen-shared/prettierStable.d.ts +262 -0
  30. package/dist/src/lib/codegen-shared/prettierStable.js +610 -0
  31. package/dist/src/lib/codegen-shared/prettierStable.js.map +1 -0
  32. package/dist/src/lib/db-codegen/dbGenerator.js +8 -5
  33. package/dist/src/lib/db-codegen/dbGenerator.js.map +1 -1
  34. package/dist/src/lib/db-codegen/dbNaming.d.ts +5 -0
  35. package/dist/src/lib/db-codegen/dbNaming.js +8 -2
  36. package/dist/src/lib/db-codegen/dbNaming.js.map +1 -1
  37. package/dist/src/lib/db-codegen/dbTemplates.d.ts +17 -2
  38. package/dist/src/lib/db-codegen/dbTemplates.js +84 -39
  39. package/dist/src/lib/db-codegen/dbTemplates.js.map +1 -1
  40. package/dist/src/lib/db-codegen/dbTsTypes.d.ts +13 -22
  41. package/dist/src/lib/db-codegen/dbTsTypes.js +33 -28
  42. package/dist/src/lib/db-codegen/dbTsTypes.js.map +1 -1
  43. package/dist/src/lib/db-codegen/generated-operation-def-descriptor.d.ts +11 -0
  44. package/dist/src/lib/db-codegen/generated-operation-def-descriptor.js +11 -0
  45. package/dist/src/lib/db-codegen/generated-operation-def-descriptor.js.map +1 -1
  46. package/dist/src/lib/generated-allowlist.js +5 -0
  47. package/dist/src/lib/generated-allowlist.js.map +1 -1
  48. package/dist/src/lib/platform-owned.d.ts +37 -0
  49. package/dist/src/lib/platform-owned.js +46 -0
  50. package/dist/src/lib/platform-owned.js.map +1 -0
  51. package/dist/src/lib/swift-codegen/dbGenerator.d.ts +32 -0
  52. package/dist/src/lib/swift-codegen/dbGenerator.js +338 -36
  53. package/dist/src/lib/swift-codegen/dbGenerator.js.map +1 -1
  54. package/dist/src/lib/swift-codegen/dbSwiftTypes.d.ts +1 -1
  55. package/dist/src/lib/swift-codegen/dbSwiftTypes.js +1 -1
  56. package/dist/src/lib/swift-codegen/generator.d.ts +1 -0
  57. package/dist/src/lib/swift-codegen/generator.js +91 -3
  58. package/dist/src/lib/swift-codegen/generator.js.map +1 -1
  59. package/dist/src/lib/swift-codegen/siblingSymbols.d.ts +90 -0
  60. package/dist/src/lib/swift-codegen/siblingSymbols.js +152 -0
  61. package/dist/src/lib/swift-codegen/siblingSymbols.js.map +1 -0
  62. package/dist/src/lib/sync-resource-types.d.ts +222 -10
  63. package/dist/src/lib/sync-resource-types.js +407 -20
  64. package/dist/src/lib/sync-resource-types.js.map +1 -1
  65. package/dist/src/lib/toml-metadata-config.js +18 -0
  66. package/dist/src/lib/toml-metadata-config.js.map +1 -1
  67. package/dist/src/lib/workflow-apply.js +12 -2
  68. package/dist/src/lib/workflow-apply.js.map +1 -1
  69. package/dist/src/lib/workflow-codegen/generator.d.ts +9 -0
  70. package/dist/src/lib/workflow-codegen/generator.js +126 -55
  71. package/dist/src/lib/workflow-codegen/generator.js.map +1 -1
  72. package/dist/src/lib/workflow-codegen/invokerIR.d.ts +6 -8
  73. package/dist/src/lib/workflow-codegen/invokerIR.js +8 -8
  74. package/dist/src/lib/workflow-codegen/invokerIR.js.map +1 -1
  75. package/dist/src/lib/workflow-codegen/schemaToTs.d.ts +17 -1
  76. package/dist/src/lib/workflow-codegen/schemaToTs.js +59 -38
  77. package/dist/src/lib/workflow-codegen/schemaToTs.js.map +1 -1
  78. package/dist/src/lib/workflow-payload.d.ts +19 -0
  79. package/dist/src/lib/workflow-payload.js +21 -0
  80. package/dist/src/lib/workflow-payload.js.map +1 -1
  81. package/dist/src/lib/workflow-toml-validator.d.ts +30 -0
  82. package/dist/src/lib/workflow-toml-validator.js +206 -0
  83. package/dist/src/lib/workflow-toml-validator.js.map +1 -1
  84. package/dist/src/types/index.d.ts +1 -0
  85. package/package.json +2 -1
@@ -247,6 +247,45 @@ export declare function rewriteWorkflowSchemasToNative(rawToml: string, workflow
247
247
  };
248
248
  export declare function serializeWorkflow(workflow: any, draft: any, configs: any[], logger?: (message: string) => void): string;
249
249
  export declare function serializeGroupTypeConfig(config: any, ruleSetIdToName: Map<string, string>): string;
250
+ /**
251
+ * Issue #1567 — the TOML-owned scalar fields of a database-type config.
252
+ *
253
+ * These are fields the `database-types/*.toml` file OWNS: the local file is the
254
+ * source of truth, so removing one from the TOML must clear it server-side
255
+ * (config-as-code), not silently preserve the stale value. `schema` is NOT in
256
+ * this list — it keeps its own `hasSchema` prior-state discriminator, since a
257
+ * schema is a large sub-tree, not a scalar.
258
+ */
259
+ export declare const DB_TYPE_OWNED_SCALARS: readonly ["ruleSetId", "triggers", "metadataAccess", "defaultAccess", "autoPopulatedFields", "timestamps", "metadataManifest"];
260
+ /** The user-facing TOML key for a wire field (for push output). */
261
+ export declare function dbTypeFieldLabel(key: string): string;
262
+ /**
263
+ * True when a value carries real content. null/undefined, blank/whitespace
264
+ * strings, and empty objects/arrays all count as "no value" — the same
265
+ * normalization the server applies (`value || null`) when it decides whether a
266
+ * field is set.
267
+ */
268
+ export declare function hasMeaningfulValue(v: any): boolean;
269
+ /**
270
+ * Issue #1567 — always-send owned db-type scalars as value-or-`null`.
271
+ *
272
+ * The server PATCH endpoint distinguishes an omitted key (preserve) from an
273
+ * explicit `null` (clear), so sending every owned scalar as `value ?? null`
274
+ * converges the server to the local TOML: a field removed from the file lands
275
+ * as `null` and is cleared. Matches the always-send pattern the sibling
276
+ * `collection-type-config` push already uses.
277
+ */
278
+ export declare function buildOwnedScalarUpdate(typeConfig: any): Record<string, any>;
279
+ /**
280
+ * Issue #1567 — the owned scalars this push genuinely clears: the outgoing
281
+ * value is empty but the server currently holds a real value (a non-null →
282
+ * null transition). Used for the "Cleared <field>" report so removing an
283
+ * access gate is never silent, and to decide whether an otherwise
284
+ * type-field-less push still needs a type-config PATCH. Returns wire field
285
+ * names (map with `dbTypeFieldLabel` for output). `serverConfig` is the live
286
+ * GET; without it (fresh type or a failed fetch) nothing is reported cleared.
287
+ */
288
+ export declare function ownedScalarsBeingCleared(updateData: Record<string, any>, serverConfig: any): string[];
250
289
  export declare function parseDatabaseTypeToml(tomlData: any): {
251
290
  typeConfig: any;
252
291
  operations: any[];
@@ -254,6 +293,17 @@ export declare function parseDatabaseTypeToml(tomlData: any): {
254
293
  };
255
294
  export declare function parseGroupTypeConfigToml(tomlData: any): any;
256
295
  export declare function parseCollectionTypeConfigToml(tomlData: any): any;
296
+ export declare function hashLocalRuleSetForDiff(parsedToml: any): string;
297
+ export declare function hashRemoteRuleSetForDiff(ruleSet: any): string;
298
+ export declare function hashLocalGroupTypeConfigForDiff(parsedToml: any, ruleSetNameToId: Map<string, string>): string;
299
+ export declare function hashRemoteGroupTypeConfigForDiff(config: any, ruleSetIdToName: Map<string, string>, ruleSetNameToId: Map<string, string>): string;
300
+ export declare function hashLocalCollectionTypeConfigForDiff(parsedToml: any, ruleSetNameToId: Map<string, string>): string;
301
+ export declare function hashRemoteCollectionTypeConfigForDiff(config: any, ruleSetIdToName: Map<string, string>, ruleSetNameToId: Map<string, string>): string;
302
+ export declare function hashLocalDatabaseTypeForDiff(parsedToml: any, ruleSetNameToId: Map<string, string>): string;
303
+ export declare function hashRemoteDatabaseTypeForDiff(typeConfig: any, operations: any[], subscriptions: any[], ruleSetIdToName: Map<string, string>, ruleSetNameToId: Map<string, string>): string;
304
+ export declare function hashLocalMetadataCategoryForDiff(parsedToml: any): string;
305
+ export declare function hashRemoteMetadataCategoryForDiff(config: any): string;
306
+ export declare function parseTomlFile(filePath: string): any;
257
307
  /**
258
308
  * Paginate through a list endpoint, collecting all items.
259
309
  */
@@ -264,6 +314,54 @@ export declare function fetchAll<T>(listFn: (params: {
264
314
  items: T[];
265
315
  nextCursor?: string | null;
266
316
  }>, pageSize?: number, maxPages?: number): Promise<T[]>;
317
+ /**
318
+ * Issue #976 / #1006: shared 409 → adopt-by-key recovery for `sync push`
319
+ * create paths. When a CREATE hits a per-app unique-key constraint, the resource
320
+ * is already on the server but missing from local sync state: orphaned by a
321
+ * prior push that aborted before recording it, a mid-apply crash, or an
322
+ * out-of-band create with the same key. Rather than hard-fail forever, this
323
+ * helper looks the resource up by its unique key and hands the matched item
324
+ * back so the caller can re-issue the create as an UPDATE and converge.
325
+ *
326
+ * The conflict surfaces inconsistently across create routes, so detection is
327
+ * deliberately broad (see `isConflict` below):
328
+ * - a 409 status (webhooks, cron triggers, the standard case);
329
+ * - an "already exists" message — some routes surface the 409 as HTTP 400,
330
+ * e.g. workflows;
331
+ * - a "must be unique" message — routes with no explicit conflict catch let
332
+ * dynamo-bao's per-app unique-constraint error propagate verbatim (e.g. rule
333
+ * sets, whose create route has no 409 translation). This matches the
334
+ * server's own admin-api convention (`src/admin-api.ts`), which treats
335
+ * "must be unique" as a duplicate-key conflict.
336
+ * Any other error is NOT a conflict and re-throws unchanged (see below).
337
+ *
338
+ * Safety (load-bearing): exact-key match only. The `lookup` is app-scoped, so a
339
+ * key match is also an ownership match — an unrelated resource is never
340
+ * overwritten. The three non-adopt outcomes each surface a clear error and do
341
+ * NOT touch the server:
342
+ * - a non-409 create error is re-wrapped via `wrapEntityError` and re-thrown
343
+ * (no lookup is attempted);
344
+ * - a lookup failure throws a clear "already exists but could not be adopted
345
+ * (lookup failed: …)";
346
+ * - a 409 with no matching key re-throws the ORIGINAL create error rather
347
+ * than silently proceeding.
348
+ *
349
+ * Pagination is the caller's concern: `lookup` must return the COMPLETE
350
+ * candidate set. For cursor-based lists (webhooks, integrations, prompts,
351
+ * workflows) wrap the list call in `fetchAll`; the cron-triggers route already
352
+ * drains every page server-side (#1668) so its flat `{ items }` is complete.
353
+ * The UPDATE re-issue and sync-state stamping stay with the caller because they
354
+ * differ per entity.
355
+ *
356
+ * @returns the matched existing item (guaranteed non-null on return).
357
+ */
358
+ export declare function adoptByKeyOnCreate409<T>(opts: {
359
+ err: unknown;
360
+ kind: string;
361
+ key: string;
362
+ lookup: () => Promise<T[]>;
363
+ matchKey: (item: T) => boolean;
364
+ }): Promise<T>;
267
365
  /**
268
366
  * Resolve a key-based rule set name reference to an ID.
269
367
  * Throws if the name cannot be resolved and throwOnMissing is true.