clivly 0.9.1 → 0.9.3
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.
- package/README.md +79 -13
- package/core-drizzle.d.cts +1 -1
- package/core-drizzle.d.mts +1 -1
- package/core-entity-config.cjs +2 -1
- package/core-entity-config.d.cts +2 -2
- package/core-entity-config.d.mts +2 -2
- package/core-entity-config.mjs +2 -2
- package/core-entity-heuristics.d.cts +1 -1
- package/core-entity-heuristics.d.mts +1 -1
- package/core-mapping-form.d.cts +1 -1
- package/core-mapping-form.d.mts +1 -1
- package/core-mappings-config.cjs +2 -1
- package/core-mappings-config.d.cts +2 -2
- package/core-mappings-config.d.mts +2 -2
- package/core-mappings-config.mjs +2 -2
- package/core-sync-engine.d.cts +1 -1
- package/core-sync-engine.d.mts +1 -1
- package/core-view-compiler.d.cts +1 -1
- package/core-view-compiler.d.mts +1 -1
- package/core.cjs +3 -3
- package/core.d.cts +8 -7
- package/core.d.mts +8 -7
- package/core.mjs +3 -3
- package/{drizzle-DooDUGqO.d.mts → drizzle-CiK8MMEZ.d.mts} +1 -1
- package/{drizzle-jz0lrAgl.d.cts → drizzle-DEtRrqtc.d.cts} +1 -1
- package/drizzle.d.cts +2 -2
- package/drizzle.d.mts +2 -2
- package/{entity-config-fKQhimtD.d.mts → entity-config-B2RA53nw.d.cts} +25 -1
- package/{entity-config-fKQhimtD.d.cts → entity-config-B2RA53nw.d.mts} +25 -1
- package/{entity-config-nuXge6rY.cjs → entity-config-DtBsl2MQ.cjs} +36 -12
- package/{entity-config-D08zAeFY.mjs → entity-config-kUHri9yA.mjs} +31 -13
- package/index.cjs +452 -38
- package/index.d.cts +3 -1
- package/index.d.mts +3 -1
- package/index.mjs +452 -39
- package/integration-state-BK-riZnm.d.cts +130 -0
- package/integration-state-BK-riZnm.d.mts +130 -0
- package/{internal-C-YBW2DB.d.cts → internal-CDY8g9Ic.d.mts} +1 -1
- package/{internal-D4HDi2GC.cjs → internal-CwnEG6Wl.cjs} +1 -1
- package/{internal-BLCK81kB.d.mts → internal-Da_dlcQ_.d.cts} +1 -1
- package/{internal-BGVUG312.mjs → internal-Df-PtOH_.mjs} +1 -1
- package/internal-drizzle.d.cts +1 -1
- package/internal-drizzle.d.mts +1 -1
- package/internal-entity-config.cjs +2 -1
- package/internal-entity-config.d.cts +2 -2
- package/internal-entity-config.d.mts +2 -2
- package/internal-entity-config.mjs +2 -2
- package/internal-entity-heuristics.cjs +1 -1
- package/internal-entity-heuristics.d.cts +1 -1
- package/internal-entity-heuristics.d.mts +1 -1
- package/internal-entity-heuristics.mjs +1 -1
- package/internal-mapping-form.d.cts +1 -1
- package/internal-mapping-form.d.mts +1 -1
- package/internal-mappings-config.cjs +2 -1
- package/internal-mappings-config.d.cts +2 -2
- package/internal-mappings-config.d.mts +2 -2
- package/internal-mappings-config.mjs +2 -2
- package/internal-sync-engine.d.cts +1 -1
- package/internal-sync-engine.d.mts +1 -1
- package/internal-view-compiler.d.cts +1 -1
- package/internal-view-compiler.d.mts +1 -1
- package/internal.cjs +3 -3
- package/internal.d.cts +8 -7
- package/internal.d.mts +8 -7
- package/internal.mjs +3 -3
- package/{mapping-form-Du36VZr1.d.mts → mapping-form-DH77BXLv.d.mts} +1 -1
- package/{mapping-form-DhY0iFmN.d.cts → mapping-form-J0aU6O7l.d.cts} +1 -1
- package/{mappings-config-C8ynKmDK.cjs → mappings-config-B0RqFLxu.cjs} +30 -1
- package/{mappings-config-DNaYGyKN.mjs → mappings-config-B1b1HVBg.mjs} +25 -2
- package/{mappings-config-B1qNM8VL.d.cts → mappings-config-D9dsonoi.d.mts} +40 -2
- package/{mappings-config-BChZsany.d.mts → mappings-config-RQLGx8ub.d.cts} +40 -2
- package/{namespace-probe-BkUs8raG.d.mts → namespace-probe-BmdGnYMn.d.mts} +72 -3
- package/{namespace-probe-aRFmpU85.d.cts → namespace-probe-EYyxWZnf.d.cts} +72 -3
- package/package.json +1 -1
- package/{sdk-Bj-ZDf4u.cjs → sdk-COLUHhJq.cjs} +755 -44
- package/{sdk-BvRD2jAp.mjs → sdk-CZNXBsgA.mjs} +755 -44
- package/sdk.cjs +4 -2
- package/sdk.d.cts +3 -3
- package/sdk.d.mts +3 -3
- package/sdk.mjs +3 -3
- package/{sync-engine-DHQ7rXZe.d.mts → sync-engine-BG2O1an2.d.cts} +2 -2
- package/{sync-engine-DiPjH53O.d.cts → sync-engine-DgQbrJON.d.mts} +2 -2
- package/{view-compiler-CcUwzZut.d.mts → view-compiler-Bo7pqXW3.d.mts} +1 -1
- package/{view-compiler-DqAdVxLq.d.cts → view-compiler-CmEdAMwj.d.cts} +1 -1
- package/vite.d.cts +1 -1
- package/vite.d.mts +1 -1
|
@@ -437,10 +437,23 @@ const entitySchema = require_projection.strictObject({
|
|
|
437
437
|
relationships: require_projection.record(require_projection.string(), relationshipSchema).optional(),
|
|
438
438
|
/**
|
|
439
439
|
* For a "custom" entity, the crm_object_types row this materializes into.
|
|
440
|
-
*
|
|
440
|
+
* Server-generated, so pasting one into config couples the file to a
|
|
441
|
+
* specific workspace. Prefer declaring `objectType` and letting
|
|
442
|
+
* `clivly push-schema` resolve the id by slug.
|
|
441
443
|
*/
|
|
442
444
|
targetObjectTypeId: require_projection.string().min(1).optional(),
|
|
443
445
|
/**
|
|
446
|
+
* Declares the custom object this entity materializes into, so config is
|
|
447
|
+
* self-contained: the entity key is the slug (unique per org and immutable),
|
|
448
|
+
* and `clivly push-schema` creates the object type if the workspace does not
|
|
449
|
+
* have it yet. An alternative to pasting a `targetObjectTypeId`.
|
|
450
|
+
*/
|
|
451
|
+
objectType: require_projection.strictObject({
|
|
452
|
+
name: require_projection.string().min(1),
|
|
453
|
+
pluralName: require_projection.string().min(1).optional(),
|
|
454
|
+
iconKey: require_projection.string().min(1).optional()
|
|
455
|
+
}).optional(),
|
|
456
|
+
/**
|
|
444
457
|
* Advanced mapping: derive this entity from a base table plus explicit joins
|
|
445
458
|
* instead of a single source table. Valid only for `concept: "custom"`.
|
|
446
459
|
*
|
|
@@ -482,17 +495,22 @@ function defaultWarn(message) {
|
|
|
482
495
|
console.warn(message);
|
|
483
496
|
}
|
|
484
497
|
/**
|
|
485
|
-
*
|
|
486
|
-
*
|
|
487
|
-
*
|
|
488
|
-
*
|
|
489
|
-
* It also catches the silent-data-loss footgun: a non-canonical field key for a
|
|
490
|
-
* materialised concept (e.g. `fullName` instead of `name` on a `contact`) has no
|
|
491
|
-
* destination column, so the store would write an empty value. By default these
|
|
492
|
-
* are reported via `onWarn` (a `console.warn`); pass `{ strict: true }` to throw
|
|
493
|
-
* a `ClivlyConfigError` instead. Does NOT validate against the host schema — that
|
|
494
|
-
* needs the discovered schema; see `validateEntitiesConfig`.
|
|
498
|
+
* The custom objects a config declares, keyed by entity slug. Entities that
|
|
499
|
+
* already carry an explicit `targetObjectTypeId` are omitted: their object type
|
|
500
|
+
* exists server-side and re-declaring it would be a no-op at best.
|
|
495
501
|
*/
|
|
502
|
+
function customObjectDeclarations(config) {
|
|
503
|
+
const declarations = [];
|
|
504
|
+
for (const [slug, entity] of Object.entries(config.entities)) {
|
|
505
|
+
if (entity.concept !== "custom" || entity.targetObjectTypeId) continue;
|
|
506
|
+
if (!entity.objectType) continue;
|
|
507
|
+
declarations.push({
|
|
508
|
+
slug,
|
|
509
|
+
...entity.objectType
|
|
510
|
+
});
|
|
511
|
+
}
|
|
512
|
+
return declarations;
|
|
513
|
+
}
|
|
496
514
|
/**
|
|
497
515
|
* The `fields` entry a projection binding implies, qualified as `ref.column`.
|
|
498
516
|
* Qualified rather than bare: two bindings can pull the same column name from
|
|
@@ -632,7 +650,7 @@ function validateEntity(v, config, key, entity, schema) {
|
|
|
632
650
|
}
|
|
633
651
|
if (entity.projection) {
|
|
634
652
|
if (entity.concept !== "custom") v.report(`${base}.projection`, `projection mappings are only supported for concept "${CUSTOM_CONCEPT}"`);
|
|
635
|
-
if (!entity.targetObjectTypeId) v.report(`${base}.targetObjectTypeId`, "a projection mapping must target a custom object type");
|
|
653
|
+
if (!(entity.targetObjectTypeId || entity.objectType)) v.report(`${base}.targetObjectTypeId`, "a projection mapping must target a custom object type — declare `objectType: { name: \"…\" }` (recommended: the entity key becomes its slug) or set an explicit `targetObjectTypeId`");
|
|
636
654
|
if (entity.source !== entity.projection.baseTable) v.report(`${base}.source`, `"source" ("${entity.source}") must match "projection.baseTable" ("${entity.projection.baseTable}") — the view compiler reads baseTable and the sync engine reads source, so a mismatch makes them disagree about which table this entity is`);
|
|
637
655
|
for (const error of validateProjection(entity.projection, schema, base)) v.report(error.path, error.message);
|
|
638
656
|
validateReadOnly(v, base, entity);
|
|
@@ -704,6 +722,12 @@ Object.defineProperty(exports, "coversUniqueKey", {
|
|
|
704
722
|
return coversUniqueKey;
|
|
705
723
|
}
|
|
706
724
|
});
|
|
725
|
+
Object.defineProperty(exports, "customObjectDeclarations", {
|
|
726
|
+
enumerable: true,
|
|
727
|
+
get: function() {
|
|
728
|
+
return customObjectDeclarations;
|
|
729
|
+
}
|
|
730
|
+
});
|
|
707
731
|
Object.defineProperty(exports, "defineClivlyConfig", {
|
|
708
732
|
enumerable: true,
|
|
709
733
|
get: function() {
|
|
@@ -429,10 +429,23 @@ const entitySchema = strictObject({
|
|
|
429
429
|
relationships: record(string(), relationshipSchema).optional(),
|
|
430
430
|
/**
|
|
431
431
|
* For a "custom" entity, the crm_object_types row this materializes into.
|
|
432
|
-
*
|
|
432
|
+
* Server-generated, so pasting one into config couples the file to a
|
|
433
|
+
* specific workspace. Prefer declaring `objectType` and letting
|
|
434
|
+
* `clivly push-schema` resolve the id by slug.
|
|
433
435
|
*/
|
|
434
436
|
targetObjectTypeId: string().min(1).optional(),
|
|
435
437
|
/**
|
|
438
|
+
* Declares the custom object this entity materializes into, so config is
|
|
439
|
+
* self-contained: the entity key is the slug (unique per org and immutable),
|
|
440
|
+
* and `clivly push-schema` creates the object type if the workspace does not
|
|
441
|
+
* have it yet. An alternative to pasting a `targetObjectTypeId`.
|
|
442
|
+
*/
|
|
443
|
+
objectType: strictObject({
|
|
444
|
+
name: string().min(1),
|
|
445
|
+
pluralName: string().min(1).optional(),
|
|
446
|
+
iconKey: string().min(1).optional()
|
|
447
|
+
}).optional(),
|
|
448
|
+
/**
|
|
436
449
|
* Advanced mapping: derive this entity from a base table plus explicit joins
|
|
437
450
|
* instead of a single source table. Valid only for `concept: "custom"`.
|
|
438
451
|
*
|
|
@@ -474,17 +487,22 @@ function defaultWarn(message) {
|
|
|
474
487
|
console.warn(message);
|
|
475
488
|
}
|
|
476
489
|
/**
|
|
477
|
-
*
|
|
478
|
-
*
|
|
479
|
-
*
|
|
480
|
-
*
|
|
481
|
-
* It also catches the silent-data-loss footgun: a non-canonical field key for a
|
|
482
|
-
* materialised concept (e.g. `fullName` instead of `name` on a `contact`) has no
|
|
483
|
-
* destination column, so the store would write an empty value. By default these
|
|
484
|
-
* are reported via `onWarn` (a `console.warn`); pass `{ strict: true }` to throw
|
|
485
|
-
* a `ClivlyConfigError` instead. Does NOT validate against the host schema — that
|
|
486
|
-
* needs the discovered schema; see `validateEntitiesConfig`.
|
|
490
|
+
* The custom objects a config declares, keyed by entity slug. Entities that
|
|
491
|
+
* already carry an explicit `targetObjectTypeId` are omitted: their object type
|
|
492
|
+
* exists server-side and re-declaring it would be a no-op at best.
|
|
487
493
|
*/
|
|
494
|
+
function customObjectDeclarations(config) {
|
|
495
|
+
const declarations = [];
|
|
496
|
+
for (const [slug, entity] of Object.entries(config.entities)) {
|
|
497
|
+
if (entity.concept !== "custom" || entity.targetObjectTypeId) continue;
|
|
498
|
+
if (!entity.objectType) continue;
|
|
499
|
+
declarations.push({
|
|
500
|
+
slug,
|
|
501
|
+
...entity.objectType
|
|
502
|
+
});
|
|
503
|
+
}
|
|
504
|
+
return declarations;
|
|
505
|
+
}
|
|
488
506
|
/**
|
|
489
507
|
* The `fields` entry a projection binding implies, qualified as `ref.column`.
|
|
490
508
|
* Qualified rather than bare: two bindings can pull the same column name from
|
|
@@ -624,7 +642,7 @@ function validateEntity(v, config, key, entity, schema) {
|
|
|
624
642
|
}
|
|
625
643
|
if (entity.projection) {
|
|
626
644
|
if (entity.concept !== "custom") v.report(`${base}.projection`, `projection mappings are only supported for concept "${CUSTOM_CONCEPT}"`);
|
|
627
|
-
if (!entity.targetObjectTypeId) v.report(`${base}.targetObjectTypeId`, "a projection mapping must target a custom object type");
|
|
645
|
+
if (!(entity.targetObjectTypeId || entity.objectType)) v.report(`${base}.targetObjectTypeId`, "a projection mapping must target a custom object type — declare `objectType: { name: \"…\" }` (recommended: the entity key becomes its slug) or set an explicit `targetObjectTypeId`");
|
|
628
646
|
if (entity.source !== entity.projection.baseTable) v.report(`${base}.source`, `"source" ("${entity.source}") must match "projection.baseTable" ("${entity.projection.baseTable}") — the view compiler reads baseTable and the sync engine reads source, so a mismatch makes them disagree about which table this entity is`);
|
|
629
647
|
for (const error of validateProjection(entity.projection, schema, base)) v.report(error.path, error.message);
|
|
630
648
|
validateReadOnly(v, base, entity);
|
|
@@ -654,4 +672,4 @@ function validateEntitiesConfig(config, schema) {
|
|
|
654
672
|
};
|
|
655
673
|
}
|
|
656
674
|
//#endregion
|
|
657
|
-
export {
|
|
675
|
+
export { columnMetaFor as _, MATERIALIZING_CONCEPTS as a, primaryKeyColumns as b, entitiesConfigSchema as c, relationshipSchema as d, relationshipsSchema as f, joinFansOut as g, fanOutJoins as h, ClivlyConfigError as i, filterSchema as l, validateProjection as m, CRM_CONCEPTS as n, customObjectDeclarations as o, validateEntitiesConfig as p, CUSTOM_CONCEPT as r, defineClivlyConfig as s, CANONICAL_FIELDS as t, projectionFields as u, coversUniqueKey as v, hasRichMeta as y };
|