clivly 0.19.0 → 0.21.0

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 (136) hide show
  1. package/README.md +14 -4
  2. package/{adapter-BXykDFyG.d.mts → adapter-B4v4dwgD.d.mts} +1 -1
  3. package/{adapter-BiUN_I3u.d.cts → adapter-BK3gsby5.d.cts} +1 -1
  4. package/{auth-adapter-BNvri2gX.d.mts → auth-adapter-BIa-ZyVV.d.mts} +1 -1
  5. package/{auth-adapter-D2MUT1Hk.d.cts → auth-adapter-DwtMJb7D.d.cts} +1 -1
  6. package/auth-better-auth.d.cts +1 -1
  7. package/auth-better-auth.d.mts +1 -1
  8. package/auth-clerk.d.cts +1 -1
  9. package/auth-clerk.d.mts +1 -1
  10. package/auth-workos.d.cts +1 -1
  11. package/auth-workos.d.mts +1 -1
  12. package/core-adapter.d.cts +2 -1
  13. package/core-adapter.d.mts +2 -1
  14. package/core-auth-adapter.d.cts +2 -1
  15. package/core-auth-adapter.d.mts +2 -1
  16. package/core-drizzle.d.cts +1 -1
  17. package/core-drizzle.d.mts +1 -1
  18. package/core-entity-config.cjs +1 -1
  19. package/core-entity-config.d.cts +2 -1
  20. package/core-entity-config.d.mts +2 -1
  21. package/core-entity-config.mjs +1 -1
  22. package/core-entity-heuristics.cjs +1 -1
  23. package/core-entity-heuristics.d.cts +1 -1
  24. package/core-entity-heuristics.d.mts +1 -1
  25. package/core-entity-heuristics.mjs +1 -1
  26. package/core-mapping-form.d.cts +2 -1
  27. package/core-mapping-form.d.mts +2 -1
  28. package/core-mappings-config.cjs +1 -1
  29. package/core-mappings-config.d.cts +2 -1
  30. package/core-mappings-config.d.mts +2 -1
  31. package/core-mappings-config.mjs +1 -1
  32. package/core-sync-engine.cjs +1 -1
  33. package/core-sync-engine.d.cts +2 -1
  34. package/core-sync-engine.d.mts +2 -1
  35. package/core-sync-engine.mjs +1 -1
  36. package/core-types.d.cts +2 -1
  37. package/core-types.d.mts +2 -1
  38. package/core-view-compiler.cjs +1 -1
  39. package/core-view-compiler.d.cts +2 -1
  40. package/core-view-compiler.d.mts +2 -1
  41. package/core-view-compiler.mjs +1 -1
  42. package/core.cjs +7 -7
  43. package/core.d.cts +10 -10
  44. package/core.d.mts +10 -10
  45. package/core.mjs +7 -7
  46. package/{drizzle-B9cjBavj.d.cts → drizzle-BNHGQXiY.d.cts} +1 -1
  47. package/{drizzle-L5FOGe_-.d.mts → drizzle-DFe7ILmd.d.mts} +1 -1
  48. package/drizzle.cjs +2 -2
  49. package/drizzle.d.cts +4 -3
  50. package/drizzle.d.mts +4 -3
  51. package/drizzle.mjs +2 -2
  52. package/{entity-config-DiCJ6mhI.cjs → entity-config-BP8Cc_nC.cjs} +54 -53
  53. package/{entity-config-g_oMPXlN.mjs → entity-config-CI5CGfaN.mjs} +54 -53
  54. package/{entity-config-X-KlnYXX.d.mts → entity-config-CXpGowQa.d.cts} +339 -339
  55. package/{entity-config-dNclLyBM.d.cts → entity-config-CXpGowQa.d.mts} +339 -339
  56. package/{entity-heuristics-DE5ujoHw.mjs → entity-heuristics-DAxqagJA.mjs} +1 -1
  57. package/{entity-heuristics-CIParuQe.cjs → entity-heuristics-DNmrcd0b.cjs} +1 -1
  58. package/index-Bh7o2J7K.d.mts +308 -0
  59. package/index-DRRTE5IJ.d.cts +308 -0
  60. package/index.cjs +3 -3
  61. package/index.mjs +3 -3
  62. package/{internal-COALpgov.d.cts → internal-C8TGcv_X.d.mts} +2 -131
  63. package/{internal-9oDwwbNg.mjs → internal-DWpLw0t5.mjs} +5 -5
  64. package/{internal-BKYt5j0l.cjs → internal-G5tXjqwl.cjs} +5 -5
  65. package/{internal-D3q4FPcA.d.mts → internal-Nrhf76Jn.d.cts} +2 -131
  66. package/internal-adapter.d.cts +1 -1
  67. package/internal-adapter.d.mts +1 -1
  68. package/internal-auth-adapter.d.cts +1 -1
  69. package/internal-auth-adapter.d.mts +1 -1
  70. package/internal-drizzle.d.cts +1 -1
  71. package/internal-drizzle.d.mts +1 -1
  72. package/internal-entity-config.cjs +1 -1
  73. package/internal-entity-config.d.cts +1 -1
  74. package/internal-entity-config.d.mts +1 -1
  75. package/internal-entity-config.mjs +1 -1
  76. package/internal-entity-heuristics.cjs +1 -1
  77. package/internal-entity-heuristics.d.cts +1 -1
  78. package/internal-entity-heuristics.d.mts +1 -1
  79. package/internal-entity-heuristics.mjs +1 -1
  80. package/internal-mapping-form.d.cts +1 -1
  81. package/internal-mapping-form.d.mts +1 -1
  82. package/internal-mappings-config.cjs +1 -1
  83. package/internal-mappings-config.d.cts +1 -1
  84. package/internal-mappings-config.d.mts +1 -1
  85. package/internal-mappings-config.mjs +1 -1
  86. package/internal-sync-engine.cjs +1 -1
  87. package/internal-sync-engine.d.cts +1 -1
  88. package/internal-sync-engine.d.mts +1 -1
  89. package/internal-sync-engine.mjs +1 -1
  90. package/internal-types.d.cts +1 -1
  91. package/internal-types.d.mts +1 -1
  92. package/internal-view-compiler.cjs +1 -1
  93. package/internal-view-compiler.d.cts +1 -1
  94. package/internal-view-compiler.d.mts +1 -1
  95. package/internal-view-compiler.mjs +1 -1
  96. package/internal.cjs +7 -7
  97. package/internal.d.cts +10 -10
  98. package/internal.d.mts +10 -10
  99. package/internal.mjs +7 -7
  100. package/{mapping-form-Bpvgf5b8.d.mts → mapping-form-Bg_hgNoL.d.cts} +1 -1
  101. package/{mapping-form-CV7y6qox.d.cts → mapping-form-KHUlnC7A.d.mts} +1 -1
  102. package/{mappings-config-CNxBrbt9.cjs → mappings-config-CC-vltWb.cjs} +1 -1
  103. package/{mappings-config-BBppW9fp.d.cts → mappings-config-DNo_Cum_.d.cts} +1 -1
  104. package/{mappings-config-D_g20PyS.mjs → mappings-config-Opw7ZM6Y.mjs} +1 -1
  105. package/{mappings-config-Dmm0H6p_.d.mts → mappings-config-wAe-p1rG.d.mts} +1 -1
  106. package/{namespace-probe-C1tm5rGh.d.cts → namespace-probe-Dh6LFwfo.d.cts} +9 -2
  107. package/{namespace-probe-ah2awcHO.d.mts → namespace-probe-xESu83KG.d.mts} +9 -2
  108. package/package.json +6 -4
  109. package/projection-CzBI2NL8.mjs +95 -0
  110. package/{projection-sql-CHz7KzNS.cjs → projection-sql-BkrHR2ea.cjs} +1 -1
  111. package/{projection-sql-C3gZE3GS.mjs → projection-sql-DQQdjw9I.mjs} +1 -1
  112. package/projection-w4Z6vSL2.cjs +118 -0
  113. package/{sdk-ChyrSl32.mjs → sdk-DfdHv-S9.mjs} +154 -13
  114. package/{sdk-BEHVvB18.cjs → sdk-oUjl5HNU.cjs} +154 -13
  115. package/sdk.cjs +2 -2
  116. package/sdk.d.cts +2 -2
  117. package/sdk.d.mts +2 -2
  118. package/sdk.mjs +2 -2
  119. package/{sync-engine-C7W0Gkq0.d.cts → sync-engine-DCjTr2XQ.d.cts} +2 -2
  120. package/{sync-engine-Di-vF26b.cjs → sync-engine-DNSoZeo0.cjs} +1 -1
  121. package/{sync-engine-C9Q2FkR9.d.mts → sync-engine-UNORma7f.d.mts} +2 -2
  122. package/{sync-engine-CwdLkmch.mjs → sync-engine-yFLEyId3.mjs} +1 -1
  123. package/{types-C08UluBS.d.cts → types-BBfwsDxe.d.cts} +13 -7
  124. package/{types-CZsSYbeC.d.mts → types-BBfwsDxe.d.mts} +13 -7
  125. package/{view-compiler-M23WiVGG.d.mts → view-compiler-BDD93Luw.d.cts} +1 -1
  126. package/{view-compiler-CLTi1VL-.mjs → view-compiler-CSHSqZl7.mjs} +2 -2
  127. package/{view-compiler-cXqt4X-c.d.cts → view-compiler-CSNhmCY2.d.mts} +1 -1
  128. package/{view-compiler-DaOz5QVl.cjs → view-compiler-NqiortOA.cjs} +2 -2
  129. package/vite.d.cts +1 -1
  130. package/vite.d.mts +1 -1
  131. package/integration-state-xK4PLm5T.d.cts +0 -171
  132. package/integration-state-xK4PLm5T.d.mts +0 -171
  133. package/projection-BkYXvjTr.mjs +0 -5587
  134. package/projection-By63gMC-.cjs +0 -5670
  135. package/schemas-BSuo_eZQ.d.cts +0 -2160
  136. package/schemas-BSuo_eZQ.d.mts +0 -2160
@@ -1,4 +1,5 @@
1
- const require_projection = require("./projection-By63gMC-.cjs");
1
+ const require_projection = require("./projection-w4Z6vSL2.cjs");
2
+ let zod = require("zod");
2
3
  // ../core/src/schema-meta.ts
3
4
  /**
4
5
  * Accessors over a discovered table's schema-v2 metadata.
@@ -475,34 +476,34 @@ const CUSTOM_CONCEPT = "custom";
475
476
  * AND-ed together. `$raw` (see FilterExpr) is the escape hatch for anything the
476
477
  * operators can't express.
477
478
  */
478
- const filterOperatorsSchema = require_projection.union([
479
- require_projection.strictObject({ eq: require_projection.union([
480
- require_projection.string(),
481
- require_projection.number(),
482
- require_projection.boolean()
479
+ const filterOperatorsSchema = zod.z.union([
480
+ zod.z.strictObject({ eq: zod.z.union([
481
+ zod.z.string(),
482
+ zod.z.number(),
483
+ zod.z.boolean()
483
484
  ]) }),
484
- require_projection.strictObject({ ne: require_projection.union([
485
- require_projection.string(),
486
- require_projection.number(),
487
- require_projection.boolean()
485
+ zod.z.strictObject({ ne: zod.z.union([
486
+ zod.z.string(),
487
+ zod.z.number(),
488
+ zod.z.boolean()
488
489
  ]) }),
489
- require_projection.strictObject({ in: require_projection.array(require_projection.union([
490
- require_projection.string(),
491
- require_projection.number(),
492
- require_projection.boolean()
490
+ zod.z.strictObject({ in: zod.z.array(zod.z.union([
491
+ zod.z.string(),
492
+ zod.z.number(),
493
+ zod.z.boolean()
493
494
  ])).min(1) }),
494
- require_projection.strictObject({ notIn: require_projection.array(require_projection.union([
495
- require_projection.string(),
496
- require_projection.number(),
497
- require_projection.boolean()
495
+ zod.z.strictObject({ notIn: zod.z.array(zod.z.union([
496
+ zod.z.string(),
497
+ zod.z.number(),
498
+ zod.z.boolean()
498
499
  ])).min(1) }),
499
- require_projection.strictObject({ isNull: require_projection.literal(true) }),
500
- require_projection.strictObject({ isNotNull: require_projection.literal(true) })
500
+ zod.z.strictObject({ isNull: zod.z.literal(true) }),
501
+ zod.z.strictObject({ isNotNull: zod.z.literal(true) })
501
502
  ]);
502
- const filterValueSchema = require_projection.union([
503
- require_projection.string(),
504
- require_projection.number(),
505
- require_projection.boolean(),
503
+ const filterValueSchema = zod.z.union([
504
+ zod.z.string(),
505
+ zod.z.number(),
506
+ zod.z.boolean(),
506
507
  filterOperatorsSchema
507
508
  ]);
508
509
  /**
@@ -511,10 +512,10 @@ const filterValueSchema = require_projection.union([
511
512
  * `crm_entity_mappings` and shipped to the cloud unchanged. Embedded-only in
512
513
  * practice; not validated against the schema.
513
514
  */
514
- const rawFilterSchema = require_projection.strictObject({ $raw: require_projection.string().min(1) });
515
- const columnFilterSchema = require_projection.record(require_projection.string(), filterValueSchema);
515
+ const rawFilterSchema = zod.z.strictObject({ $raw: zod.z.string().min(1) });
516
+ const columnFilterSchema = zod.z.record(zod.z.string(), filterValueSchema);
516
517
  /** `$raw` is a reserved key; a column literally named `$raw` is not addressable. */
517
- const filterSchema = require_projection.union([rawFilterSchema, columnFilterSchema]);
518
+ const filterSchema = zod.z.union([rawFilterSchema, columnFilterSchema]);
518
519
  /**
519
520
  * How the link between two entities is expressed in the host schema:
520
521
  * - `fkOn: "company"` — FK lives on the company table (e.g. organizations.owner_id)
@@ -524,46 +525,46 @@ const filterSchema = require_projection.union([rawFilterSchema, columnFilterSche
524
525
  *
525
526
  * `column` and the join-table keys are `table.column` or bare `column` strings.
526
527
  */
527
- const relationshipViaSchema = require_projection.union([
528
- require_projection.strictObject({
529
- fkOn: require_projection._enum(["company", "contact"]),
530
- column: require_projection.string().min(1)
528
+ const relationshipViaSchema = zod.z.union([
529
+ zod.z.strictObject({
530
+ fkOn: zod.z.enum(["company", "contact"]),
531
+ column: zod.z.string().min(1)
531
532
  }),
532
- require_projection.strictObject({
533
- through: require_projection.string().min(1),
534
- localKey: require_projection.string().min(1),
535
- foreignKey: require_projection.string().min(1)
533
+ zod.z.strictObject({
534
+ through: zod.z.string().min(1),
535
+ localKey: zod.z.string().min(1),
536
+ foreignKey: zod.z.string().min(1)
536
537
  }),
537
- require_projection.strictObject({ $raw: require_projection.string().min(1) })
538
+ zod.z.strictObject({ $raw: zod.z.string().min(1) })
538
539
  ]);
539
- const relationshipSchema = require_projection.strictObject({
540
+ const relationshipSchema = zod.z.strictObject({
540
541
  /** Key of the related entity in the `entities` map. */
541
- entity: require_projection.string().min(1),
542
+ entity: zod.z.string().min(1),
542
543
  via: relationshipViaSchema
543
544
  });
544
545
  /** A named map of relationships, as stored on an entity / in the mappings row. */
545
- const relationshipsSchema = require_projection.record(require_projection.string(), relationshipSchema);
546
- const entitySchema = require_projection.strictObject({
546
+ const relationshipsSchema = zod.z.record(zod.z.string(), relationshipSchema);
547
+ const entitySchema = zod.z.strictObject({
547
548
  /** Which CRM concept this entity maps onto — a canonical concept or "custom". */
548
- concept: require_projection.union([require_projection._enum(CRM_CONCEPTS), require_projection.literal(CUSTOM_CONCEPT)]),
549
+ concept: zod.z.union([zod.z.enum(CRM_CONCEPTS), zod.z.literal(CUSTOM_CONCEPT)]),
549
550
  /** Host table (or view) this entity is derived from. */
550
- source: require_projection.string().min(1),
551
+ source: zod.z.string().min(1),
551
552
  /**
552
553
  * Distinguishes multiple entities backed by the same table (e.g. "primary"
553
554
  * for owners, "secondary" for members). Free text; defaults to "primary".
554
555
  */
555
- role: require_projection.string().min(1).optional(),
556
+ role: zod.z.string().min(1).optional(),
556
557
  /** Predicate that narrows `source` into this entity's rows. Omit = whole table. */
557
558
  filter: filterSchema.optional(),
558
559
  /** clivlyField → sourceColumn. At least one field is required. */
559
- fields: require_projection.record(require_projection.string(), require_projection.string()).refine((f) => Object.keys(f).length > 0, { message: "at least one field must be mapped" }),
560
+ fields: zod.z.record(zod.z.string(), zod.z.string()).refine((f) => Object.keys(f).length > 0, { message: "at least one field must be mapped" }),
560
561
  /**
561
562
  * Host-owned identity fields. Sync overwrites them; the CRM UI cannot edit
562
563
  * them. Must be a subset of `fields` keys.
563
564
  */
564
- readOnly: require_projection.array(require_projection.string()).optional(),
565
+ readOnly: zod.z.array(zod.z.string()).optional(),
565
566
  /** Named relationships to other entities in this config. */
566
- relationships: require_projection.record(require_projection.string(), relationshipSchema).optional(),
567
+ relationships: zod.z.record(zod.z.string(), relationshipSchema).optional(),
567
568
  /**
568
569
  * Treat rows from this entity as their company's point of contact.
569
570
  *
@@ -577,24 +578,24 @@ const entitySchema = require_projection.strictObject({
577
578
  * alone. Without that the user's choice would be silently reverted on the
578
579
  * next run — see `syncPrimaryContacts` and `host-owned-fields.ts`.
579
580
  */
580
- isPrimaryContact: require_projection.boolean().optional(),
581
+ isPrimaryContact: zod.z.boolean().optional(),
581
582
  /**
582
583
  * For a "custom" entity, the crm_object_types row this materializes into.
583
584
  * Server-generated, so pasting one into config couples the file to a
584
585
  * specific workspace. Prefer declaring `objectType` and letting
585
586
  * `clivly push-schema` resolve the id by slug.
586
587
  */
587
- targetObjectTypeId: require_projection.string().min(1).optional(),
588
+ targetObjectTypeId: zod.z.string().min(1).optional(),
588
589
  /**
589
590
  * Declares the custom object this entity materializes into, so config is
590
591
  * self-contained: the entity key is the slug (unique per org and immutable),
591
592
  * and `clivly push-schema` creates the object type if the workspace does not
592
593
  * have it yet. An alternative to pasting a `targetObjectTypeId`.
593
594
  */
594
- objectType: require_projection.strictObject({
595
- name: require_projection.string().min(1),
596
- pluralName: require_projection.string().min(1).optional(),
597
- iconKey: require_projection.string().min(1).optional()
595
+ objectType: zod.z.strictObject({
596
+ name: zod.z.string().min(1),
597
+ pluralName: zod.z.string().min(1).optional(),
598
+ iconKey: zod.z.string().min(1).optional()
598
599
  }).optional(),
599
600
  /**
600
601
  * Advanced mapping: derive this entity from a base table plus explicit joins
@@ -607,7 +608,7 @@ const entitySchema = require_projection.strictObject({
607
608
  */
608
609
  projection: require_projection.projectionSchema.optional()
609
610
  });
610
- const entitiesConfigSchema = require_projection.strictObject({ entities: require_projection.record(require_projection.string(), entitySchema).refine((e) => Object.keys(e).length > 0, { message: "at least one entity must be defined" }) });
611
+ const entitiesConfigSchema = zod.z.strictObject({ entities: zod.z.record(zod.z.string(), entitySchema).refine((e) => Object.keys(e).length > 0, { message: "at least one entity must be defined" }) });
611
612
  /** Thrown by `defineClivlyConfig({ strict: true })` on non-canonical field keys. */
612
613
  var ClivlyConfigError = class extends Error {
613
614
  issues;
@@ -1,4 +1,5 @@
1
- import { a as _enum, c as literal, d as record, f as strictObject, i as projectionSchema, l as number, m as union, o as array, p as string, r as identityRefs, s as boolean, t as BASE_REF } from "./projection-BkYXvjTr.mjs";
1
+ import { i as projectionSchema, r as identityRefs, t as BASE_REF } from "./projection-CzBI2NL8.mjs";
2
+ import { z } from "zod";
2
3
  // ../core/src/schema-meta.ts
3
4
  /**
4
5
  * Accessors over a discovered table's schema-v2 metadata.
@@ -475,34 +476,34 @@ const CUSTOM_CONCEPT = "custom";
475
476
  * AND-ed together. `$raw` (see FilterExpr) is the escape hatch for anything the
476
477
  * operators can't express.
477
478
  */
478
- const filterOperatorsSchema = union([
479
- strictObject({ eq: union([
480
- string(),
481
- number(),
482
- boolean()
479
+ const filterOperatorsSchema = z.union([
480
+ z.strictObject({ eq: z.union([
481
+ z.string(),
482
+ z.number(),
483
+ z.boolean()
483
484
  ]) }),
484
- strictObject({ ne: union([
485
- string(),
486
- number(),
487
- boolean()
485
+ z.strictObject({ ne: z.union([
486
+ z.string(),
487
+ z.number(),
488
+ z.boolean()
488
489
  ]) }),
489
- strictObject({ in: array(union([
490
- string(),
491
- number(),
492
- boolean()
490
+ z.strictObject({ in: z.array(z.union([
491
+ z.string(),
492
+ z.number(),
493
+ z.boolean()
493
494
  ])).min(1) }),
494
- strictObject({ notIn: array(union([
495
- string(),
496
- number(),
497
- boolean()
495
+ z.strictObject({ notIn: z.array(z.union([
496
+ z.string(),
497
+ z.number(),
498
+ z.boolean()
498
499
  ])).min(1) }),
499
- strictObject({ isNull: literal(true) }),
500
- strictObject({ isNotNull: literal(true) })
500
+ z.strictObject({ isNull: z.literal(true) }),
501
+ z.strictObject({ isNotNull: z.literal(true) })
501
502
  ]);
502
- const filterValueSchema = union([
503
- string(),
504
- number(),
505
- boolean(),
503
+ const filterValueSchema = z.union([
504
+ z.string(),
505
+ z.number(),
506
+ z.boolean(),
506
507
  filterOperatorsSchema
507
508
  ]);
508
509
  /**
@@ -511,10 +512,10 @@ const filterValueSchema = union([
511
512
  * `crm_entity_mappings` and shipped to the cloud unchanged. Embedded-only in
512
513
  * practice; not validated against the schema.
513
514
  */
514
- const rawFilterSchema = strictObject({ $raw: string().min(1) });
515
- const columnFilterSchema = record(string(), filterValueSchema);
515
+ const rawFilterSchema = z.strictObject({ $raw: z.string().min(1) });
516
+ const columnFilterSchema = z.record(z.string(), filterValueSchema);
516
517
  /** `$raw` is a reserved key; a column literally named `$raw` is not addressable. */
517
- const filterSchema = union([rawFilterSchema, columnFilterSchema]);
518
+ const filterSchema = z.union([rawFilterSchema, columnFilterSchema]);
518
519
  /**
519
520
  * How the link between two entities is expressed in the host schema:
520
521
  * - `fkOn: "company"` — FK lives on the company table (e.g. organizations.owner_id)
@@ -524,46 +525,46 @@ const filterSchema = union([rawFilterSchema, columnFilterSchema]);
524
525
  *
525
526
  * `column` and the join-table keys are `table.column` or bare `column` strings.
526
527
  */
527
- const relationshipViaSchema = union([
528
- strictObject({
529
- fkOn: _enum(["company", "contact"]),
530
- column: string().min(1)
528
+ const relationshipViaSchema = z.union([
529
+ z.strictObject({
530
+ fkOn: z.enum(["company", "contact"]),
531
+ column: z.string().min(1)
531
532
  }),
532
- strictObject({
533
- through: string().min(1),
534
- localKey: string().min(1),
535
- foreignKey: string().min(1)
533
+ z.strictObject({
534
+ through: z.string().min(1),
535
+ localKey: z.string().min(1),
536
+ foreignKey: z.string().min(1)
536
537
  }),
537
- strictObject({ $raw: string().min(1) })
538
+ z.strictObject({ $raw: z.string().min(1) })
538
539
  ]);
539
- const relationshipSchema = strictObject({
540
+ const relationshipSchema = z.strictObject({
540
541
  /** Key of the related entity in the `entities` map. */
541
- entity: string().min(1),
542
+ entity: z.string().min(1),
542
543
  via: relationshipViaSchema
543
544
  });
544
545
  /** A named map of relationships, as stored on an entity / in the mappings row. */
545
- const relationshipsSchema = record(string(), relationshipSchema);
546
- const entitySchema = strictObject({
546
+ const relationshipsSchema = z.record(z.string(), relationshipSchema);
547
+ const entitySchema = z.strictObject({
547
548
  /** Which CRM concept this entity maps onto — a canonical concept or "custom". */
548
- concept: union([_enum(CRM_CONCEPTS), literal(CUSTOM_CONCEPT)]),
549
+ concept: z.union([z.enum(CRM_CONCEPTS), z.literal(CUSTOM_CONCEPT)]),
549
550
  /** Host table (or view) this entity is derived from. */
550
- source: string().min(1),
551
+ source: z.string().min(1),
551
552
  /**
552
553
  * Distinguishes multiple entities backed by the same table (e.g. "primary"
553
554
  * for owners, "secondary" for members). Free text; defaults to "primary".
554
555
  */
555
- role: string().min(1).optional(),
556
+ role: z.string().min(1).optional(),
556
557
  /** Predicate that narrows `source` into this entity's rows. Omit = whole table. */
557
558
  filter: filterSchema.optional(),
558
559
  /** clivlyField → sourceColumn. At least one field is required. */
559
- fields: record(string(), string()).refine((f) => Object.keys(f).length > 0, { message: "at least one field must be mapped" }),
560
+ fields: z.record(z.string(), z.string()).refine((f) => Object.keys(f).length > 0, { message: "at least one field must be mapped" }),
560
561
  /**
561
562
  * Host-owned identity fields. Sync overwrites them; the CRM UI cannot edit
562
563
  * them. Must be a subset of `fields` keys.
563
564
  */
564
- readOnly: array(string()).optional(),
565
+ readOnly: z.array(z.string()).optional(),
565
566
  /** Named relationships to other entities in this config. */
566
- relationships: record(string(), relationshipSchema).optional(),
567
+ relationships: z.record(z.string(), relationshipSchema).optional(),
567
568
  /**
568
569
  * Treat rows from this entity as their company's point of contact.
569
570
  *
@@ -577,24 +578,24 @@ const entitySchema = strictObject({
577
578
  * alone. Without that the user's choice would be silently reverted on the
578
579
  * next run — see `syncPrimaryContacts` and `host-owned-fields.ts`.
579
580
  */
580
- isPrimaryContact: boolean().optional(),
581
+ isPrimaryContact: z.boolean().optional(),
581
582
  /**
582
583
  * For a "custom" entity, the crm_object_types row this materializes into.
583
584
  * Server-generated, so pasting one into config couples the file to a
584
585
  * specific workspace. Prefer declaring `objectType` and letting
585
586
  * `clivly push-schema` resolve the id by slug.
586
587
  */
587
- targetObjectTypeId: string().min(1).optional(),
588
+ targetObjectTypeId: z.string().min(1).optional(),
588
589
  /**
589
590
  * Declares the custom object this entity materializes into, so config is
590
591
  * self-contained: the entity key is the slug (unique per org and immutable),
591
592
  * and `clivly push-schema` creates the object type if the workspace does not
592
593
  * have it yet. An alternative to pasting a `targetObjectTypeId`.
593
594
  */
594
- objectType: strictObject({
595
- name: string().min(1),
596
- pluralName: string().min(1).optional(),
597
- iconKey: string().min(1).optional()
595
+ objectType: z.strictObject({
596
+ name: z.string().min(1),
597
+ pluralName: z.string().min(1).optional(),
598
+ iconKey: z.string().min(1).optional()
598
599
  }).optional(),
599
600
  /**
600
601
  * Advanced mapping: derive this entity from a base table plus explicit joins
@@ -607,7 +608,7 @@ const entitySchema = strictObject({
607
608
  */
608
609
  projection: projectionSchema.optional()
609
610
  });
610
- const entitiesConfigSchema = strictObject({ entities: record(string(), entitySchema).refine((e) => Object.keys(e).length > 0, { message: "at least one entity must be defined" }) });
611
+ const entitiesConfigSchema = z.strictObject({ entities: z.record(z.string(), entitySchema).refine((e) => Object.keys(e).length > 0, { message: "at least one entity must be defined" }) });
611
612
  /** Thrown by `defineClivlyConfig({ strict: true })` on non-canonical field keys. */
612
613
  var ClivlyConfigError = class extends Error {
613
614
  issues;