clivly 0.7.4 → 0.9.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.
- package/core-drizzle.cjs +3 -1
- package/core-drizzle.d.cts +3 -2
- package/core-drizzle.d.mts +3 -2
- package/core-drizzle.mjs +2 -2
- package/core-entity-config.cjs +1 -1
- package/core-entity-config.d.cts +2 -2
- package/core-entity-config.d.mts +2 -2
- package/core-entity-config.mjs +1 -1
- package/core-entity-heuristics.d.cts +3 -2
- package/core-entity-heuristics.d.mts +3 -2
- package/core-mapping-form.d.cts +1 -1
- package/core-mapping-form.d.mts +1 -1
- package/core-mappings-config.cjs +1 -1
- package/core-mappings-config.d.cts +1 -1
- package/core-mappings-config.d.mts +1 -1
- package/core-mappings-config.mjs +1 -1
- package/core-sync-engine.cjs +1 -1
- package/core-sync-engine.d.cts +1 -1
- package/core-sync-engine.d.mts +1 -1
- package/core-sync-engine.mjs +1 -1
- package/core-view-compiler.cjs +1 -1
- package/core-view-compiler.d.cts +1 -1
- package/core-view-compiler.d.mts +1 -1
- package/core-view-compiler.mjs +1 -1
- package/core.cjs +21 -5
- package/core.d.cts +7 -6
- package/core.d.mts +7 -6
- package/core.mjs +7 -6
- package/drizzle-3kvhkwO7.mjs +110 -0
- package/drizzle-BhN5M9zt.d.cts +41 -0
- package/drizzle-bfjVzYR6.cjs +127 -0
- package/drizzle-kBULBAOa.d.mts +41 -0
- package/drizzle.cjs +5 -37
- package/drizzle.d.cts +3 -3
- package/drizzle.d.mts +3 -3
- package/drizzle.mjs +5 -38
- package/{entity-config-DoUCXtq5.d.cts → entity-config-C4Yf_fPj.d.cts} +120 -1
- package/{entity-config-DoUCXtq5.d.mts → entity-config-C4Yf_fPj.d.mts} +120 -1
- package/entity-config-CsLl-ftC.cjs +727 -0
- package/entity-config-D3LmzgLb.mjs +612 -0
- package/index.cjs +28 -2
- package/index.d.cts +6 -0
- package/index.d.mts +6 -0
- package/index.mjs +28 -2
- package/internal-B8ydhsKd.d.cts +73 -0
- package/internal-BARjyN4n.cjs +97 -0
- package/internal-DMySVbM0.mjs +68 -0
- package/internal-MBkNo3bw.d.mts +73 -0
- package/internal-drizzle.cjs +3 -1
- package/internal-drizzle.d.cts +2 -2
- package/internal-drizzle.d.mts +2 -2
- package/internal-drizzle.mjs +2 -2
- package/internal-entity-config.cjs +1 -1
- package/internal-entity-config.d.cts +2 -2
- package/internal-entity-config.d.mts +2 -2
- package/internal-entity-config.mjs +1 -1
- package/internal-entity-heuristics.cjs +1 -1
- package/internal-entity-heuristics.d.cts +2 -12
- package/internal-entity-heuristics.d.mts +2 -12
- 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 +1 -1
- package/internal-mappings-config.d.cts +1 -1
- package/internal-mappings-config.d.mts +1 -1
- package/internal-mappings-config.mjs +1 -1
- package/internal-sync-engine.cjs +1 -1
- package/internal-sync-engine.d.cts +1 -1
- package/internal-sync-engine.d.mts +1 -1
- package/internal-sync-engine.mjs +1 -1
- package/internal-view-compiler.cjs +1 -1
- package/internal-view-compiler.d.cts +1 -1
- package/internal-view-compiler.d.mts +1 -1
- package/internal-view-compiler.mjs +1 -1
- package/internal.cjs +21 -4
- package/internal.d.cts +7 -6
- package/internal.d.mts +7 -6
- package/internal.mjs +7 -5
- package/{mapping-form-D93lhHEc.d.mts → mapping-form-43bwOTat.d.cts} +1 -1
- package/{mapping-form-lfyEE7EJ.d.cts → mapping-form-DUvWUYCo.d.mts} +1 -1
- package/{mappings-config-BsRADNRv.cjs → mappings-config-BSSwdHiq.cjs} +32 -6
- package/mappings-config-BpcR8bBo.d.mts +167 -0
- package/{mappings-config-Dbgxx3Nv.mjs → mappings-config-bJQT_gSa.mjs} +32 -6
- package/mappings-config-xsLMn3I-.d.cts +167 -0
- package/{namespace-probe-B4WE45TH.d.mts → namespace-probe-BSH_p9TK.d.cts} +10 -1
- package/{namespace-probe-DRzOtaRT.d.cts → namespace-probe-Dsp5uNkS.d.mts} +10 -1
- package/package.json +1 -1
- package/{entity-config-va2bkH5o.mjs → projection-C5244vGa.cjs} +130 -309
- package/{entity-config-D87rV-tE.cjs → projection-D7xmQP4S.mjs} +60 -381
- package/sdk.cjs +1 -1
- package/sdk.d.cts +2 -2
- package/sdk.d.mts +2 -2
- package/sdk.mjs +1 -1
- package/{sync-engine-Do5ru3WF.mjs → sync-engine-Bg6-SznL.mjs} +9 -2
- package/{sync-engine-CzEbpQGv.cjs → sync-engine-DEJvKw6E.cjs} +9 -2
- package/{sync-engine-DGk_AeHJ.d.mts → sync-engine-GNqRB8eS.d.cts} +2 -2
- package/{sync-engine-B7QIbXro.d.cts → sync-engine-ZsusW-q_.d.mts} +2 -2
- package/{view-compiler-BWz0sGdm.d.cts → view-compiler-Cin0neDO.d.mts} +1 -1
- package/{view-compiler-ChWr_Lml.mjs → view-compiler-DlTpOfZi.mjs} +81 -12
- package/{view-compiler-BIwvm-o2.cjs → view-compiler-DplczSjF.cjs} +81 -12
- package/{view-compiler-Bn_EJJMO.d.mts → view-compiler-Ll9cbIJz.d.cts} +1 -1
- package/vite.d.cts +1 -1
- package/vite.d.mts +1 -1
- package/drizzle-B89tLo4T.mjs +0 -31
- package/drizzle-CFOr9dU9.d.mts +0 -20
- package/drizzle-DiReZf6d.cjs +0 -36
- package/drizzle-DmeKSqeF.d.cts +0 -20
- package/mappings-config-DsUa7-1w.d.mts +0 -41
- package/mappings-config-XmzB4dag.d.cts +0 -41
package/internal.d.cts
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import { C as UpdateDealInput, S as UpdateContactInput, _ as Task, a as ContactFilters, b as TaskPriority, c as CreateCompanyInput, d as CreateTaskInput, f as CrmRole, g as RecordSource, h as Note, i as Contact, l as CreateContactInput, m as DealStage, n as ActivityType, o as ContactStatus, p as Deal, r as Company, s as CreateActivityInput, t as Activity, u as CreateDealInput, v as TaskEntityType, w as UpdateTaskInput, x as TaskStatus, y as TaskFilters } from "./types-B1oRXdNP.cjs";
|
|
2
2
|
import { a as authCustom, i as MembershipResolver, n as ClivlyUser, r as CrmMembership, t as ClivlyAuthAdapter } from "./auth-adapter-DWzgl5Yq.cjs";
|
|
3
3
|
import { t as CRMAdapter } from "./adapter-C2eRbBfo.cjs";
|
|
4
|
-
import { C as
|
|
5
|
-
import { i as relationshipViaSignature, n as buildFilterFromDiscriminator, r as buildRelationships, t as RelationshipCandidate } from "./mapping-form-
|
|
6
|
-
import { n as mappingsToEntitiesConfig, t as EntityMappingRow } from "./mappings-config-
|
|
7
|
-
import { a as compileEntityView, i as ExplainResult, n as CompiledView, o as compileEntityViews, r as DEFAULT_VIEW_PREFIX, s as explainEntitiesConfig, t as CompileOptions } from "./view-compiler-
|
|
8
|
-
import { c as SyncResult, f as reconcile, l as SyncStore, n as MirrorRecord, o as SourceRow, p as runSync, r as PersistAction, s as SyncAction, t as EntitySyncResult } from "./sync-engine-
|
|
9
|
-
|
|
4
|
+
import { C as relationshipsSchema, S as relationshipSchema, _ as RelationshipVia, a as ClivlyEntitiesConfig, b as entitiesConfigSchema, c as ConfigValidationResult, d as DiscoveredSchemaTable, f as FilterExpr, g as RelationshipSpec, h as MaterializingConcept, i as ClivlyConfigError, l as CrmConcept, m as MATERIALIZING_CONCEPTS, n as CRM_CONCEPTS, o as ClivlyEntityConfig, p as FilterValue, s as ConfigValidationError, t as CANONICAL_FIELDS, u as DiscoveredColumnMeta, v as RelationshipsMap, w as validateEntitiesConfig, x as filterSchema, y as defineClivlyConfig } from "./entity-config-C4Yf_fPj.cjs";
|
|
5
|
+
import { i as relationshipViaSignature, n as buildFilterFromDiscriminator, r as buildRelationships, t as RelationshipCandidate } from "./mapping-form-43bwOTat.cjs";
|
|
6
|
+
import { a as ProjectionIdentity, c as ProjectionRef, i as ProjectionFieldBinding, l as identityRefs, n as mappingsToEntitiesConfig, o as ProjectionJoin, r as BASE_REF, s as ProjectionMapping, t as EntityMappingRow, u as projectionSchema } from "./mappings-config-xsLMn3I-.cjs";
|
|
7
|
+
import { a as compileEntityView, i as ExplainResult, n as CompiledView, o as compileEntityViews, r as DEFAULT_VIEW_PREFIX, s as explainEntitiesConfig, t as CompileOptions } from "./view-compiler-Ll9cbIJz.cjs";
|
|
8
|
+
import { c as SyncResult, f as reconcile, l as SyncStore, n as MirrorRecord, o as SourceRow, p as runSync, r as PersistAction, s as SyncAction, t as EntitySyncResult } from "./sync-engine-GNqRB8eS.cjs";
|
|
9
|
+
import { a as validateProjection, c as draftErrors, d as suggestJoinConditions, f as fanOutJoins, i as primaryKeyColumns, l as draftToProjection, n as coversUniqueKey, o as ProjectionDraft, p as joinFansOut, r as hasRichMeta, s as describeCardinality, t as columnMetaFor, u as emptyProjectionDraft } from "./internal-B8ydhsKd.cjs";
|
|
10
|
+
export { type Activity, type ActivityType, BASE_REF, CANONICAL_FIELDS, type CRMAdapter, CRM_CONCEPTS, type ClivlyAuthAdapter, ClivlyConfigError, type ClivlyEntitiesConfig, type ClivlyEntityConfig, type ClivlyUser, type Company, type CompileOptions, type CompiledView, type ConfigValidationError, type ConfigValidationResult, type Contact, type ContactFilters, type ContactStatus, type CreateActivityInput, type CreateCompanyInput, type CreateContactInput, type CreateDealInput, type CreateTaskInput, type CrmConcept, type CrmMembership, type CrmRole, DEFAULT_VIEW_PREFIX, type Deal, type DealStage, type DiscoveredColumnMeta, type DiscoveredSchemaTable, type EntityMappingRow, type EntitySyncResult, type ExplainResult, type FilterExpr, type FilterValue, MATERIALIZING_CONCEPTS, type MaterializingConcept, type MembershipResolver, type MirrorRecord, type Note, type PersistAction, type ProjectionDraft, type ProjectionFieldBinding, type ProjectionIdentity, type ProjectionJoin, type ProjectionMapping, type ProjectionRef, type RecordSource, type RelationshipCandidate, type RelationshipSpec, type RelationshipVia, type RelationshipsMap, type SourceRow, type SyncAction, type SyncResult, type SyncStore, type Task, type TaskEntityType, type TaskFilters, type TaskPriority, type TaskStatus, type UpdateContactInput, type UpdateDealInput, type UpdateTaskInput, authCustom, buildFilterFromDiscriminator, buildRelationships, columnMetaFor, compileEntityView, compileEntityViews, coversUniqueKey, defineClivlyConfig, describeCardinality, draftErrors, draftToProjection, emptyProjectionDraft, entitiesConfigSchema, explainEntitiesConfig, fanOutJoins, filterSchema, hasRichMeta, identityRefs, joinFansOut, mappingsToEntitiesConfig, primaryKeyColumns, projectionSchema, reconcile, relationshipSchema, relationshipViaSignature, relationshipsSchema, runSync, suggestJoinConditions, validateEntitiesConfig, validateProjection };
|
package/internal.d.mts
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import { C as UpdateDealInput, S as UpdateContactInput, _ as Task, a as ContactFilters, b as TaskPriority, c as CreateCompanyInput, d as CreateTaskInput, f as CrmRole, g as RecordSource, h as Note, i as Contact, l as CreateContactInput, m as DealStage, n as ActivityType, o as ContactStatus, p as Deal, r as Company, s as CreateActivityInput, t as Activity, u as CreateDealInput, v as TaskEntityType, w as UpdateTaskInput, x as TaskStatus, y as TaskFilters } from "./types-B1oRXdNP.mjs";
|
|
2
2
|
import { a as authCustom, i as MembershipResolver, n as ClivlyUser, r as CrmMembership, t as ClivlyAuthAdapter } from "./auth-adapter-Bjgo8LhN.mjs";
|
|
3
3
|
import { t as CRMAdapter } from "./adapter-D5LRa-NA.mjs";
|
|
4
|
-
import { C as
|
|
5
|
-
import { i as relationshipViaSignature, n as buildFilterFromDiscriminator, r as buildRelationships, t as RelationshipCandidate } from "./mapping-form-
|
|
6
|
-
import { n as mappingsToEntitiesConfig, t as EntityMappingRow } from "./mappings-config-
|
|
7
|
-
import { a as compileEntityView, i as ExplainResult, n as CompiledView, o as compileEntityViews, r as DEFAULT_VIEW_PREFIX, s as explainEntitiesConfig, t as CompileOptions } from "./view-compiler-
|
|
8
|
-
import { c as SyncResult, f as reconcile, l as SyncStore, n as MirrorRecord, o as SourceRow, p as runSync, r as PersistAction, s as SyncAction, t as EntitySyncResult } from "./sync-engine-
|
|
9
|
-
|
|
4
|
+
import { C as relationshipsSchema, S as relationshipSchema, _ as RelationshipVia, a as ClivlyEntitiesConfig, b as entitiesConfigSchema, c as ConfigValidationResult, d as DiscoveredSchemaTable, f as FilterExpr, g as RelationshipSpec, h as MaterializingConcept, i as ClivlyConfigError, l as CrmConcept, m as MATERIALIZING_CONCEPTS, n as CRM_CONCEPTS, o as ClivlyEntityConfig, p as FilterValue, s as ConfigValidationError, t as CANONICAL_FIELDS, u as DiscoveredColumnMeta, v as RelationshipsMap, w as validateEntitiesConfig, x as filterSchema, y as defineClivlyConfig } from "./entity-config-C4Yf_fPj.mjs";
|
|
5
|
+
import { i as relationshipViaSignature, n as buildFilterFromDiscriminator, r as buildRelationships, t as RelationshipCandidate } from "./mapping-form-DUvWUYCo.mjs";
|
|
6
|
+
import { a as ProjectionIdentity, c as ProjectionRef, i as ProjectionFieldBinding, l as identityRefs, n as mappingsToEntitiesConfig, o as ProjectionJoin, r as BASE_REF, s as ProjectionMapping, t as EntityMappingRow, u as projectionSchema } from "./mappings-config-BpcR8bBo.mjs";
|
|
7
|
+
import { a as compileEntityView, i as ExplainResult, n as CompiledView, o as compileEntityViews, r as DEFAULT_VIEW_PREFIX, s as explainEntitiesConfig, t as CompileOptions } from "./view-compiler-Cin0neDO.mjs";
|
|
8
|
+
import { c as SyncResult, f as reconcile, l as SyncStore, n as MirrorRecord, o as SourceRow, p as runSync, r as PersistAction, s as SyncAction, t as EntitySyncResult } from "./sync-engine-ZsusW-q_.mjs";
|
|
9
|
+
import { a as validateProjection, c as draftErrors, d as suggestJoinConditions, f as fanOutJoins, i as primaryKeyColumns, l as draftToProjection, n as coversUniqueKey, o as ProjectionDraft, p as joinFansOut, r as hasRichMeta, s as describeCardinality, t as columnMetaFor, u as emptyProjectionDraft } from "./internal-MBkNo3bw.mjs";
|
|
10
|
+
export { type Activity, type ActivityType, BASE_REF, CANONICAL_FIELDS, type CRMAdapter, CRM_CONCEPTS, type ClivlyAuthAdapter, ClivlyConfigError, type ClivlyEntitiesConfig, type ClivlyEntityConfig, type ClivlyUser, type Company, type CompileOptions, type CompiledView, type ConfigValidationError, type ConfigValidationResult, type Contact, type ContactFilters, type ContactStatus, type CreateActivityInput, type CreateCompanyInput, type CreateContactInput, type CreateDealInput, type CreateTaskInput, type CrmConcept, type CrmMembership, type CrmRole, DEFAULT_VIEW_PREFIX, type Deal, type DealStage, type DiscoveredColumnMeta, type DiscoveredSchemaTable, type EntityMappingRow, type EntitySyncResult, type ExplainResult, type FilterExpr, type FilterValue, MATERIALIZING_CONCEPTS, type MaterializingConcept, type MembershipResolver, type MirrorRecord, type Note, type PersistAction, type ProjectionDraft, type ProjectionFieldBinding, type ProjectionIdentity, type ProjectionJoin, type ProjectionMapping, type ProjectionRef, type RecordSource, type RelationshipCandidate, type RelationshipSpec, type RelationshipVia, type RelationshipsMap, type SourceRow, type SyncAction, type SyncResult, type SyncStore, type Task, type TaskEntityType, type TaskFilters, type TaskPriority, type TaskStatus, type UpdateContactInput, type UpdateDealInput, type UpdateTaskInput, authCustom, buildFilterFromDiscriminator, buildRelationships, columnMetaFor, compileEntityView, compileEntityViews, coversUniqueKey, defineClivlyConfig, describeCardinality, draftErrors, draftToProjection, emptyProjectionDraft, entitiesConfigSchema, explainEntitiesConfig, fanOutJoins, filterSchema, hasRichMeta, identityRefs, joinFansOut, mappingsToEntitiesConfig, primaryKeyColumns, projectionSchema, reconcile, relationshipSchema, relationshipViaSignature, relationshipsSchema, runSync, suggestJoinConditions, validateEntitiesConfig, validateProjection };
|
package/internal.mjs
CHANGED
|
@@ -1,7 +1,9 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { i as projectionSchema, r as identityRefs, t as BASE_REF } from "./projection-D7xmQP4S.mjs";
|
|
2
|
+
import { _ as hasRichMeta, a as MATERIALIZING_CONCEPTS, c as filterSchema, d as validateEntitiesConfig, f as validateProjection, g as coversUniqueKey, h as columnMetaFor, i as ClivlyConfigError, l as relationshipSchema, m as joinFansOut, n as CRM_CONCEPTS, o as defineClivlyConfig, p as fanOutJoins, s as entitiesConfigSchema, t as CANONICAL_FIELDS, u as relationshipsSchema, v as primaryKeyColumns } from "./entity-config-D3LmzgLb.mjs";
|
|
2
3
|
import { t as authCustom } from "./auth-adapter-gfVDxf3d.mjs";
|
|
3
4
|
import { n as buildRelationships, r as relationshipViaSignature, t as buildFilterFromDiscriminator } from "./mapping-form-DigkuvFc.mjs";
|
|
4
|
-
import { t as mappingsToEntitiesConfig } from "./mappings-config-
|
|
5
|
-
import { i as
|
|
6
|
-
import { i as
|
|
7
|
-
|
|
5
|
+
import { t as mappingsToEntitiesConfig } from "./mappings-config-bJQT_gSa.mjs";
|
|
6
|
+
import { a as suggestJoinConditions, i as emptyProjectionDraft, n as draftErrors, r as draftToProjection, t as describeCardinality } from "./internal-DMySVbM0.mjs";
|
|
7
|
+
import { i as explainEntitiesConfig, n as compileEntityView, r as compileEntityViews, t as DEFAULT_VIEW_PREFIX } from "./view-compiler-DlTpOfZi.mjs";
|
|
8
|
+
import { i as runSync, r as reconcile } from "./sync-engine-Bg6-SznL.mjs";
|
|
9
|
+
export { BASE_REF, CANONICAL_FIELDS, CRM_CONCEPTS, ClivlyConfigError, DEFAULT_VIEW_PREFIX, MATERIALIZING_CONCEPTS, authCustom, buildFilterFromDiscriminator, buildRelationships, columnMetaFor, compileEntityView, compileEntityViews, coversUniqueKey, defineClivlyConfig, describeCardinality, draftErrors, draftToProjection, emptyProjectionDraft, entitiesConfigSchema, explainEntitiesConfig, fanOutJoins, filterSchema, hasRichMeta, identityRefs, joinFansOut, mappingsToEntitiesConfig, primaryKeyColumns, projectionSchema, reconcile, relationshipSchema, relationshipViaSignature, relationshipsSchema, runSync, suggestJoinConditions, validateEntitiesConfig, validateProjection };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { _ as
|
|
1
|
+
import { _ as RelationshipVia, f as FilterExpr, v as RelationshipsMap } from "./entity-config-C4Yf_fPj.cjs";
|
|
2
2
|
//#region ../core/src/mapping-form.d.ts
|
|
3
3
|
/**
|
|
4
4
|
* A relationship the mapping UI can offer or has configured, in the shape the
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { _ as
|
|
1
|
+
import { _ as RelationshipVia, f as FilterExpr, v as RelationshipsMap } from "./entity-config-C4Yf_fPj.mjs";
|
|
2
2
|
//#region ../core/src/mapping-form.d.ts
|
|
3
3
|
/**
|
|
4
4
|
* A relationship the mapping UI can offer or has configured, in the shape the
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
const require_entity_config = require("./entity-config-
|
|
1
|
+
const require_entity_config = require("./entity-config-CsLl-ftC.cjs");
|
|
2
2
|
//#region ../core/src/mappings-config.ts
|
|
3
3
|
const RESERVED_FIELD = "id";
|
|
4
4
|
/**
|
|
@@ -21,7 +21,9 @@ function canonicalFields(concept, fieldMap) {
|
|
|
21
21
|
const DEFAULT_ROLE = "primary";
|
|
22
22
|
const ACTIVE_STATUS = "active";
|
|
23
23
|
function isEligible(row) {
|
|
24
|
-
|
|
24
|
+
if ((row.status ?? ACTIVE_STATUS) !== ACTIVE_STATUS) return false;
|
|
25
|
+
if (row.projection) return Object.keys(row.projection.fieldBindings ?? {}).length > 0;
|
|
26
|
+
return Object.keys(row.fieldMap ?? {}).length > 0;
|
|
25
27
|
}
|
|
26
28
|
/**
|
|
27
29
|
* Preferred key for a row: the bare source table when it backs a single entity,
|
|
@@ -45,13 +47,28 @@ function uniquify(base, used) {
|
|
|
45
47
|
used.add(key);
|
|
46
48
|
return key;
|
|
47
49
|
}
|
|
50
|
+
/**
|
|
51
|
+
* A projection's `fields` map, derived mechanically from its bindings.
|
|
52
|
+
*
|
|
53
|
+
* `ClivlyEntityConfig.fields` is required and read by existing consumers, so a
|
|
54
|
+
* projection entity must populate it. The values are ref *tokens*
|
|
55
|
+
* (`"base.full_name"`), never host column names — the compiler reads
|
|
56
|
+
* `projection.fieldBindings`, and `validateEntitiesConfig` skips the legacy
|
|
57
|
+
* column check for projection entities precisely because of this.
|
|
58
|
+
*/
|
|
59
|
+
function projectionFields(projection) {
|
|
60
|
+
const fields = {};
|
|
61
|
+
for (const [field, binding] of Object.entries(projection.fieldBindings)) fields[field] = `${binding.from.table}.${binding.from.column}`;
|
|
62
|
+
return fields;
|
|
63
|
+
}
|
|
48
64
|
function buildEntity(row, refIndex) {
|
|
49
65
|
const entity = {
|
|
50
66
|
concept: row.targetConcept,
|
|
51
|
-
source: row.sourceTable,
|
|
67
|
+
source: row.projection?.baseTable ?? row.sourceTable,
|
|
52
68
|
role: row.role ?? DEFAULT_ROLE,
|
|
53
|
-
fields: canonicalFields(row.targetConcept, row.fieldMap)
|
|
69
|
+
fields: row.projection ? projectionFields(row.projection) : canonicalFields(row.targetConcept, row.fieldMap)
|
|
54
70
|
};
|
|
71
|
+
if (row.projection) entity.projection = row.projection;
|
|
55
72
|
if (row.targetConcept === "custom" && row.targetObjectTypeId) entity.targetObjectTypeId = row.targetObjectTypeId;
|
|
56
73
|
if (row.filter && Object.keys(row.filter).length > 0) entity.filter = row.filter;
|
|
57
74
|
if (row.relationships && Object.keys(row.relationships).length > 0) {
|
|
@@ -76,11 +93,16 @@ function buildEntity(row, refIndex) {
|
|
|
76
93
|
function mappingsToEntitiesConfig(rows) {
|
|
77
94
|
const eligible = rows.filter(isEligible);
|
|
78
95
|
const tableCounts = /* @__PURE__ */ new Map();
|
|
79
|
-
for (const row of eligible)
|
|
96
|
+
for (const row of eligible) {
|
|
97
|
+
if (row.projection) continue;
|
|
98
|
+
tableCounts.set(row.sourceTable, (tableCounts.get(row.sourceTable) ?? 0) + 1);
|
|
99
|
+
}
|
|
80
100
|
const used = /* @__PURE__ */ new Set();
|
|
81
101
|
const tableAnchor = /* @__PURE__ */ new Map();
|
|
82
102
|
const assigned = [];
|
|
83
|
-
|
|
103
|
+
const legacyRows = eligible.filter((row) => !row.projection);
|
|
104
|
+
const projectionRows = eligible.filter((row) => row.projection);
|
|
105
|
+
for (const row of legacyRows) {
|
|
84
106
|
const key = uniquify(preferredKey(row, tableCounts), used);
|
|
85
107
|
assigned.push({
|
|
86
108
|
row,
|
|
@@ -88,6 +110,10 @@ function mappingsToEntitiesConfig(rows) {
|
|
|
88
110
|
});
|
|
89
111
|
if ((row.role ?? DEFAULT_ROLE) === DEFAULT_ROLE || !tableAnchor.has(row.sourceTable)) tableAnchor.set(row.sourceTable, key);
|
|
90
112
|
}
|
|
113
|
+
for (const row of projectionRows) assigned.push({
|
|
114
|
+
row,
|
|
115
|
+
key: uniquify(row.projection?.entityKey ?? row.sourceTable, used)
|
|
116
|
+
});
|
|
91
117
|
const refIndex = /* @__PURE__ */ new Map();
|
|
92
118
|
for (const { key } of assigned) refIndex.set(key, key);
|
|
93
119
|
for (const [table, key] of tableAnchor) if (!refIndex.has(table)) refIndex.set(table, key);
|
|
@@ -0,0 +1,167 @@
|
|
|
1
|
+
import { A as ZodRecord, D as ZodLiteral, E as ZodEnum, M as ZodUnion, N as output, O as ZodObject, P as $strict, T as ZodArray, a as ClivlyEntitiesConfig, j as ZodString, k as ZodOptional } from "./entity-config-C4Yf_fPj.mjs";
|
|
2
|
+
//#region ../core/src/projection.d.ts
|
|
3
|
+
/**
|
|
4
|
+
* Projection-backed custom mappings — one custom object derived from a base
|
|
5
|
+
* table plus explicit joins.
|
|
6
|
+
*
|
|
7
|
+
* A projection is deliberately narrow: equality joins only, direct column
|
|
8
|
+
* bindings only, no expressions and no aggregation. Everything a user can
|
|
9
|
+
* express here compiles to a single read-only view whose `id` column is
|
|
10
|
+
* provably unique per row, which is what lets the sync engine consume it
|
|
11
|
+
* unchanged.
|
|
12
|
+
*
|
|
13
|
+
* Refs address tables symbolically: `"base"` for the base table, or a join's
|
|
14
|
+
* `key`. Raw table names are never accepted in a ref, so a projection can
|
|
15
|
+
* never reach a table it did not declare.
|
|
16
|
+
*/
|
|
17
|
+
/** The reserved ref name for the projection's base table. */
|
|
18
|
+
declare const BASE_REF = "base";
|
|
19
|
+
declare const projectionRefSchema: ZodObject<{
|
|
20
|
+
table: ZodString;
|
|
21
|
+
column: ZodString;
|
|
22
|
+
}, $strict>;
|
|
23
|
+
type ProjectionRef = output<typeof projectionRefSchema>;
|
|
24
|
+
declare const projectionJoinSchema: ZodObject<{
|
|
25
|
+
key: ZodString;
|
|
26
|
+
table: ZodString;
|
|
27
|
+
type: ZodEnum<{
|
|
28
|
+
inner: "inner";
|
|
29
|
+
left: "left";
|
|
30
|
+
}>;
|
|
31
|
+
on: ZodArray<ZodObject<{
|
|
32
|
+
left: ZodObject<{
|
|
33
|
+
table: ZodString;
|
|
34
|
+
column: ZodString;
|
|
35
|
+
}, $strict>;
|
|
36
|
+
op: ZodLiteral<"eq">;
|
|
37
|
+
right: ZodObject<{
|
|
38
|
+
table: ZodString;
|
|
39
|
+
column: ZodString;
|
|
40
|
+
}, $strict>;
|
|
41
|
+
}, $strict>>;
|
|
42
|
+
}, $strict>;
|
|
43
|
+
type ProjectionJoin = output<typeof projectionJoinSchema>;
|
|
44
|
+
declare const projectionFieldBindingSchema: ZodObject<{
|
|
45
|
+
from: ZodObject<{
|
|
46
|
+
table: ZodString;
|
|
47
|
+
column: ZodString;
|
|
48
|
+
}, $strict>;
|
|
49
|
+
}, $strict>;
|
|
50
|
+
type ProjectionFieldBinding = output<typeof projectionFieldBindingSchema>;
|
|
51
|
+
declare const projectionIdentitySchema: ZodUnion<readonly [ZodObject<{
|
|
52
|
+
kind: ZodLiteral<"base_pk">;
|
|
53
|
+
column: ZodOptional<ZodString>;
|
|
54
|
+
}, $strict>, ZodObject<{
|
|
55
|
+
kind: ZodLiteral<"column">;
|
|
56
|
+
from: ZodObject<{
|
|
57
|
+
table: ZodString;
|
|
58
|
+
column: ZodString;
|
|
59
|
+
}, $strict>;
|
|
60
|
+
}, $strict>, ZodObject<{
|
|
61
|
+
kind: ZodLiteral<"composite">;
|
|
62
|
+
parts: ZodArray<ZodObject<{
|
|
63
|
+
table: ZodString;
|
|
64
|
+
column: ZodString;
|
|
65
|
+
}, $strict>>;
|
|
66
|
+
}, $strict>]>;
|
|
67
|
+
type ProjectionIdentity = output<typeof projectionIdentitySchema>;
|
|
68
|
+
declare const projectionSchema: ZodObject<{
|
|
69
|
+
version: ZodLiteral<1>;
|
|
70
|
+
kind: ZodLiteral<"projection">;
|
|
71
|
+
entityKey: ZodString;
|
|
72
|
+
baseTable: ZodString;
|
|
73
|
+
joins: ZodArray<ZodObject<{
|
|
74
|
+
key: ZodString;
|
|
75
|
+
table: ZodString;
|
|
76
|
+
type: ZodEnum<{
|
|
77
|
+
inner: "inner";
|
|
78
|
+
left: "left";
|
|
79
|
+
}>;
|
|
80
|
+
on: ZodArray<ZodObject<{
|
|
81
|
+
left: ZodObject<{
|
|
82
|
+
table: ZodString;
|
|
83
|
+
column: ZodString;
|
|
84
|
+
}, $strict>;
|
|
85
|
+
op: ZodLiteral<"eq">;
|
|
86
|
+
right: ZodObject<{
|
|
87
|
+
table: ZodString;
|
|
88
|
+
column: ZodString;
|
|
89
|
+
}, $strict>;
|
|
90
|
+
}, $strict>>;
|
|
91
|
+
}, $strict>>;
|
|
92
|
+
fieldBindings: ZodRecord<ZodString, ZodObject<{
|
|
93
|
+
from: ZodObject<{
|
|
94
|
+
table: ZodString;
|
|
95
|
+
column: ZodString;
|
|
96
|
+
}, $strict>;
|
|
97
|
+
}, $strict>>;
|
|
98
|
+
identity: ZodUnion<readonly [ZodObject<{
|
|
99
|
+
kind: ZodLiteral<"base_pk">;
|
|
100
|
+
column: ZodOptional<ZodString>;
|
|
101
|
+
}, $strict>, ZodObject<{
|
|
102
|
+
kind: ZodLiteral<"column">;
|
|
103
|
+
from: ZodObject<{
|
|
104
|
+
table: ZodString;
|
|
105
|
+
column: ZodString;
|
|
106
|
+
}, $strict>;
|
|
107
|
+
}, $strict>, ZodObject<{
|
|
108
|
+
kind: ZodLiteral<"composite">;
|
|
109
|
+
parts: ZodArray<ZodObject<{
|
|
110
|
+
table: ZodString;
|
|
111
|
+
column: ZodString;
|
|
112
|
+
}, $strict>>;
|
|
113
|
+
}, $strict>]>;
|
|
114
|
+
}, $strict>;
|
|
115
|
+
type ProjectionMapping = output<typeof projectionSchema>;
|
|
116
|
+
/**
|
|
117
|
+
* Every column ref an identity depends on. `basePkColumn` is the base table's
|
|
118
|
+
* discovered PK, used only when a `base_pk` identity omits an explicit column.
|
|
119
|
+
*/
|
|
120
|
+
declare function identityRefs(identity: ProjectionIdentity, basePkColumn: string): ProjectionRef[];
|
|
121
|
+
//#endregion
|
|
122
|
+
//#region ../core/src/mappings-config.d.ts
|
|
123
|
+
/**
|
|
124
|
+
* Mappings → Entity Config bridge.
|
|
125
|
+
*
|
|
126
|
+
* `crm_entity_mappings` rows are the single source of truth for how a host
|
|
127
|
+
* schema maps onto Clivly's CRM concepts. This module compiles those rows into
|
|
128
|
+
* a `ClivlyEntitiesConfig` — the contract the view compiler and sync engine
|
|
129
|
+
* consume — so the persisted mapping and the runtime pipeline never diverge.
|
|
130
|
+
*
|
|
131
|
+
* The row model has no explicit entity-key column (it's keyed by
|
|
132
|
+
* `sourceTable + targetConcept + role`), but the config's `relationships`
|
|
133
|
+
* reference other entities *by key*. This builder therefore derives a stable
|
|
134
|
+
* key per row and resolves each relationship's `entity` reference through the
|
|
135
|
+
* same derivation — so a relationship stored as `entity: "<relatedTable>"`
|
|
136
|
+
* (the shape `mappings.suggest` produces) resolves to the right entity.
|
|
137
|
+
*/
|
|
138
|
+
/**
|
|
139
|
+
* A persisted `crm_entity_mappings` row, narrowed to the columns the builder
|
|
140
|
+
* reads. Structurally compatible with the Drizzle row (jsonb columns typed
|
|
141
|
+
* loosely) so the API layer can pass `db.select()` results straight in.
|
|
142
|
+
*/
|
|
143
|
+
interface EntityMappingRow {
|
|
144
|
+
fieldMap: Record<string, string>;
|
|
145
|
+
filter?: Record<string, unknown> | null;
|
|
146
|
+
/**
|
|
147
|
+
* Advanced mapping: a base table plus explicit joins. When set, this — not
|
|
148
|
+
* `fieldMap` — is the authored source of truth, and `sourceTable` merely
|
|
149
|
+
* mirrors `projection.baseTable`.
|
|
150
|
+
*/
|
|
151
|
+
projection?: ProjectionMapping | null;
|
|
152
|
+
relationships?: Record<string, unknown> | null;
|
|
153
|
+
role?: string | null;
|
|
154
|
+
sourceTable: string;
|
|
155
|
+
status?: string | null;
|
|
156
|
+
targetConcept: string;
|
|
157
|
+
targetObjectTypeId?: string | null;
|
|
158
|
+
}
|
|
159
|
+
/**
|
|
160
|
+
* Compile persisted mapping rows into a `ClivlyEntitiesConfig`. Only `active`
|
|
161
|
+
* rows with at least one mapped field are included; disabled/suggested rows and
|
|
162
|
+
* unmapped rows are skipped. Returns `{ entities: {} }` when nothing is
|
|
163
|
+
* eligible — a no-op the view compiler and sync engine both tolerate.
|
|
164
|
+
*/
|
|
165
|
+
declare function mappingsToEntitiesConfig(rows: EntityMappingRow[]): ClivlyEntitiesConfig;
|
|
166
|
+
//#endregion
|
|
167
|
+
export { ProjectionIdentity as a, ProjectionRef as c, ProjectionFieldBinding as i, identityRefs as l, mappingsToEntitiesConfig as n, ProjectionJoin as o, BASE_REF as r, ProjectionMapping as s, EntityMappingRow as t, projectionSchema as u };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { t as CANONICAL_FIELDS } from "./entity-config-
|
|
1
|
+
import { t as CANONICAL_FIELDS } from "./entity-config-D3LmzgLb.mjs";
|
|
2
2
|
//#region ../core/src/mappings-config.ts
|
|
3
3
|
const RESERVED_FIELD = "id";
|
|
4
4
|
/**
|
|
@@ -21,7 +21,9 @@ function canonicalFields(concept, fieldMap) {
|
|
|
21
21
|
const DEFAULT_ROLE = "primary";
|
|
22
22
|
const ACTIVE_STATUS = "active";
|
|
23
23
|
function isEligible(row) {
|
|
24
|
-
|
|
24
|
+
if ((row.status ?? ACTIVE_STATUS) !== ACTIVE_STATUS) return false;
|
|
25
|
+
if (row.projection) return Object.keys(row.projection.fieldBindings ?? {}).length > 0;
|
|
26
|
+
return Object.keys(row.fieldMap ?? {}).length > 0;
|
|
25
27
|
}
|
|
26
28
|
/**
|
|
27
29
|
* Preferred key for a row: the bare source table when it backs a single entity,
|
|
@@ -45,13 +47,28 @@ function uniquify(base, used) {
|
|
|
45
47
|
used.add(key);
|
|
46
48
|
return key;
|
|
47
49
|
}
|
|
50
|
+
/**
|
|
51
|
+
* A projection's `fields` map, derived mechanically from its bindings.
|
|
52
|
+
*
|
|
53
|
+
* `ClivlyEntityConfig.fields` is required and read by existing consumers, so a
|
|
54
|
+
* projection entity must populate it. The values are ref *tokens*
|
|
55
|
+
* (`"base.full_name"`), never host column names — the compiler reads
|
|
56
|
+
* `projection.fieldBindings`, and `validateEntitiesConfig` skips the legacy
|
|
57
|
+
* column check for projection entities precisely because of this.
|
|
58
|
+
*/
|
|
59
|
+
function projectionFields(projection) {
|
|
60
|
+
const fields = {};
|
|
61
|
+
for (const [field, binding] of Object.entries(projection.fieldBindings)) fields[field] = `${binding.from.table}.${binding.from.column}`;
|
|
62
|
+
return fields;
|
|
63
|
+
}
|
|
48
64
|
function buildEntity(row, refIndex) {
|
|
49
65
|
const entity = {
|
|
50
66
|
concept: row.targetConcept,
|
|
51
|
-
source: row.sourceTable,
|
|
67
|
+
source: row.projection?.baseTable ?? row.sourceTable,
|
|
52
68
|
role: row.role ?? DEFAULT_ROLE,
|
|
53
|
-
fields: canonicalFields(row.targetConcept, row.fieldMap)
|
|
69
|
+
fields: row.projection ? projectionFields(row.projection) : canonicalFields(row.targetConcept, row.fieldMap)
|
|
54
70
|
};
|
|
71
|
+
if (row.projection) entity.projection = row.projection;
|
|
55
72
|
if (row.targetConcept === "custom" && row.targetObjectTypeId) entity.targetObjectTypeId = row.targetObjectTypeId;
|
|
56
73
|
if (row.filter && Object.keys(row.filter).length > 0) entity.filter = row.filter;
|
|
57
74
|
if (row.relationships && Object.keys(row.relationships).length > 0) {
|
|
@@ -76,11 +93,16 @@ function buildEntity(row, refIndex) {
|
|
|
76
93
|
function mappingsToEntitiesConfig(rows) {
|
|
77
94
|
const eligible = rows.filter(isEligible);
|
|
78
95
|
const tableCounts = /* @__PURE__ */ new Map();
|
|
79
|
-
for (const row of eligible)
|
|
96
|
+
for (const row of eligible) {
|
|
97
|
+
if (row.projection) continue;
|
|
98
|
+
tableCounts.set(row.sourceTable, (tableCounts.get(row.sourceTable) ?? 0) + 1);
|
|
99
|
+
}
|
|
80
100
|
const used = /* @__PURE__ */ new Set();
|
|
81
101
|
const tableAnchor = /* @__PURE__ */ new Map();
|
|
82
102
|
const assigned = [];
|
|
83
|
-
|
|
103
|
+
const legacyRows = eligible.filter((row) => !row.projection);
|
|
104
|
+
const projectionRows = eligible.filter((row) => row.projection);
|
|
105
|
+
for (const row of legacyRows) {
|
|
84
106
|
const key = uniquify(preferredKey(row, tableCounts), used);
|
|
85
107
|
assigned.push({
|
|
86
108
|
row,
|
|
@@ -88,6 +110,10 @@ function mappingsToEntitiesConfig(rows) {
|
|
|
88
110
|
});
|
|
89
111
|
if ((row.role ?? DEFAULT_ROLE) === DEFAULT_ROLE || !tableAnchor.has(row.sourceTable)) tableAnchor.set(row.sourceTable, key);
|
|
90
112
|
}
|
|
113
|
+
for (const row of projectionRows) assigned.push({
|
|
114
|
+
row,
|
|
115
|
+
key: uniquify(row.projection?.entityKey ?? row.sourceTable, used)
|
|
116
|
+
});
|
|
91
117
|
const refIndex = /* @__PURE__ */ new Map();
|
|
92
118
|
for (const { key } of assigned) refIndex.set(key, key);
|
|
93
119
|
for (const [table, key] of tableAnchor) if (!refIndex.has(table)) refIndex.set(table, key);
|
|
@@ -0,0 +1,167 @@
|
|
|
1
|
+
import { A as ZodRecord, D as ZodLiteral, E as ZodEnum, M as ZodUnion, N as output, O as ZodObject, P as $strict, T as ZodArray, a as ClivlyEntitiesConfig, j as ZodString, k as ZodOptional } from "./entity-config-C4Yf_fPj.cjs";
|
|
2
|
+
//#region ../core/src/projection.d.ts
|
|
3
|
+
/**
|
|
4
|
+
* Projection-backed custom mappings — one custom object derived from a base
|
|
5
|
+
* table plus explicit joins.
|
|
6
|
+
*
|
|
7
|
+
* A projection is deliberately narrow: equality joins only, direct column
|
|
8
|
+
* bindings only, no expressions and no aggregation. Everything a user can
|
|
9
|
+
* express here compiles to a single read-only view whose `id` column is
|
|
10
|
+
* provably unique per row, which is what lets the sync engine consume it
|
|
11
|
+
* unchanged.
|
|
12
|
+
*
|
|
13
|
+
* Refs address tables symbolically: `"base"` for the base table, or a join's
|
|
14
|
+
* `key`. Raw table names are never accepted in a ref, so a projection can
|
|
15
|
+
* never reach a table it did not declare.
|
|
16
|
+
*/
|
|
17
|
+
/** The reserved ref name for the projection's base table. */
|
|
18
|
+
declare const BASE_REF = "base";
|
|
19
|
+
declare const projectionRefSchema: ZodObject<{
|
|
20
|
+
table: ZodString;
|
|
21
|
+
column: ZodString;
|
|
22
|
+
}, $strict>;
|
|
23
|
+
type ProjectionRef = output<typeof projectionRefSchema>;
|
|
24
|
+
declare const projectionJoinSchema: ZodObject<{
|
|
25
|
+
key: ZodString;
|
|
26
|
+
table: ZodString;
|
|
27
|
+
type: ZodEnum<{
|
|
28
|
+
inner: "inner";
|
|
29
|
+
left: "left";
|
|
30
|
+
}>;
|
|
31
|
+
on: ZodArray<ZodObject<{
|
|
32
|
+
left: ZodObject<{
|
|
33
|
+
table: ZodString;
|
|
34
|
+
column: ZodString;
|
|
35
|
+
}, $strict>;
|
|
36
|
+
op: ZodLiteral<"eq">;
|
|
37
|
+
right: ZodObject<{
|
|
38
|
+
table: ZodString;
|
|
39
|
+
column: ZodString;
|
|
40
|
+
}, $strict>;
|
|
41
|
+
}, $strict>>;
|
|
42
|
+
}, $strict>;
|
|
43
|
+
type ProjectionJoin = output<typeof projectionJoinSchema>;
|
|
44
|
+
declare const projectionFieldBindingSchema: ZodObject<{
|
|
45
|
+
from: ZodObject<{
|
|
46
|
+
table: ZodString;
|
|
47
|
+
column: ZodString;
|
|
48
|
+
}, $strict>;
|
|
49
|
+
}, $strict>;
|
|
50
|
+
type ProjectionFieldBinding = output<typeof projectionFieldBindingSchema>;
|
|
51
|
+
declare const projectionIdentitySchema: ZodUnion<readonly [ZodObject<{
|
|
52
|
+
kind: ZodLiteral<"base_pk">;
|
|
53
|
+
column: ZodOptional<ZodString>;
|
|
54
|
+
}, $strict>, ZodObject<{
|
|
55
|
+
kind: ZodLiteral<"column">;
|
|
56
|
+
from: ZodObject<{
|
|
57
|
+
table: ZodString;
|
|
58
|
+
column: ZodString;
|
|
59
|
+
}, $strict>;
|
|
60
|
+
}, $strict>, ZodObject<{
|
|
61
|
+
kind: ZodLiteral<"composite">;
|
|
62
|
+
parts: ZodArray<ZodObject<{
|
|
63
|
+
table: ZodString;
|
|
64
|
+
column: ZodString;
|
|
65
|
+
}, $strict>>;
|
|
66
|
+
}, $strict>]>;
|
|
67
|
+
type ProjectionIdentity = output<typeof projectionIdentitySchema>;
|
|
68
|
+
declare const projectionSchema: ZodObject<{
|
|
69
|
+
version: ZodLiteral<1>;
|
|
70
|
+
kind: ZodLiteral<"projection">;
|
|
71
|
+
entityKey: ZodString;
|
|
72
|
+
baseTable: ZodString;
|
|
73
|
+
joins: ZodArray<ZodObject<{
|
|
74
|
+
key: ZodString;
|
|
75
|
+
table: ZodString;
|
|
76
|
+
type: ZodEnum<{
|
|
77
|
+
inner: "inner";
|
|
78
|
+
left: "left";
|
|
79
|
+
}>;
|
|
80
|
+
on: ZodArray<ZodObject<{
|
|
81
|
+
left: ZodObject<{
|
|
82
|
+
table: ZodString;
|
|
83
|
+
column: ZodString;
|
|
84
|
+
}, $strict>;
|
|
85
|
+
op: ZodLiteral<"eq">;
|
|
86
|
+
right: ZodObject<{
|
|
87
|
+
table: ZodString;
|
|
88
|
+
column: ZodString;
|
|
89
|
+
}, $strict>;
|
|
90
|
+
}, $strict>>;
|
|
91
|
+
}, $strict>>;
|
|
92
|
+
fieldBindings: ZodRecord<ZodString, ZodObject<{
|
|
93
|
+
from: ZodObject<{
|
|
94
|
+
table: ZodString;
|
|
95
|
+
column: ZodString;
|
|
96
|
+
}, $strict>;
|
|
97
|
+
}, $strict>>;
|
|
98
|
+
identity: ZodUnion<readonly [ZodObject<{
|
|
99
|
+
kind: ZodLiteral<"base_pk">;
|
|
100
|
+
column: ZodOptional<ZodString>;
|
|
101
|
+
}, $strict>, ZodObject<{
|
|
102
|
+
kind: ZodLiteral<"column">;
|
|
103
|
+
from: ZodObject<{
|
|
104
|
+
table: ZodString;
|
|
105
|
+
column: ZodString;
|
|
106
|
+
}, $strict>;
|
|
107
|
+
}, $strict>, ZodObject<{
|
|
108
|
+
kind: ZodLiteral<"composite">;
|
|
109
|
+
parts: ZodArray<ZodObject<{
|
|
110
|
+
table: ZodString;
|
|
111
|
+
column: ZodString;
|
|
112
|
+
}, $strict>>;
|
|
113
|
+
}, $strict>]>;
|
|
114
|
+
}, $strict>;
|
|
115
|
+
type ProjectionMapping = output<typeof projectionSchema>;
|
|
116
|
+
/**
|
|
117
|
+
* Every column ref an identity depends on. `basePkColumn` is the base table's
|
|
118
|
+
* discovered PK, used only when a `base_pk` identity omits an explicit column.
|
|
119
|
+
*/
|
|
120
|
+
declare function identityRefs(identity: ProjectionIdentity, basePkColumn: string): ProjectionRef[];
|
|
121
|
+
//#endregion
|
|
122
|
+
//#region ../core/src/mappings-config.d.ts
|
|
123
|
+
/**
|
|
124
|
+
* Mappings → Entity Config bridge.
|
|
125
|
+
*
|
|
126
|
+
* `crm_entity_mappings` rows are the single source of truth for how a host
|
|
127
|
+
* schema maps onto Clivly's CRM concepts. This module compiles those rows into
|
|
128
|
+
* a `ClivlyEntitiesConfig` — the contract the view compiler and sync engine
|
|
129
|
+
* consume — so the persisted mapping and the runtime pipeline never diverge.
|
|
130
|
+
*
|
|
131
|
+
* The row model has no explicit entity-key column (it's keyed by
|
|
132
|
+
* `sourceTable + targetConcept + role`), but the config's `relationships`
|
|
133
|
+
* reference other entities *by key*. This builder therefore derives a stable
|
|
134
|
+
* key per row and resolves each relationship's `entity` reference through the
|
|
135
|
+
* same derivation — so a relationship stored as `entity: "<relatedTable>"`
|
|
136
|
+
* (the shape `mappings.suggest` produces) resolves to the right entity.
|
|
137
|
+
*/
|
|
138
|
+
/**
|
|
139
|
+
* A persisted `crm_entity_mappings` row, narrowed to the columns the builder
|
|
140
|
+
* reads. Structurally compatible with the Drizzle row (jsonb columns typed
|
|
141
|
+
* loosely) so the API layer can pass `db.select()` results straight in.
|
|
142
|
+
*/
|
|
143
|
+
interface EntityMappingRow {
|
|
144
|
+
fieldMap: Record<string, string>;
|
|
145
|
+
filter?: Record<string, unknown> | null;
|
|
146
|
+
/**
|
|
147
|
+
* Advanced mapping: a base table plus explicit joins. When set, this — not
|
|
148
|
+
* `fieldMap` — is the authored source of truth, and `sourceTable` merely
|
|
149
|
+
* mirrors `projection.baseTable`.
|
|
150
|
+
*/
|
|
151
|
+
projection?: ProjectionMapping | null;
|
|
152
|
+
relationships?: Record<string, unknown> | null;
|
|
153
|
+
role?: string | null;
|
|
154
|
+
sourceTable: string;
|
|
155
|
+
status?: string | null;
|
|
156
|
+
targetConcept: string;
|
|
157
|
+
targetObjectTypeId?: string | null;
|
|
158
|
+
}
|
|
159
|
+
/**
|
|
160
|
+
* Compile persisted mapping rows into a `ClivlyEntitiesConfig`. Only `active`
|
|
161
|
+
* rows with at least one mapped field are included; disabled/suggested rows and
|
|
162
|
+
* unmapped rows are skipped. Returns `{ entities: {} }` when nothing is
|
|
163
|
+
* eligible — a no-op the view compiler and sync engine both tolerate.
|
|
164
|
+
*/
|
|
165
|
+
declare function mappingsToEntitiesConfig(rows: EntityMappingRow[]): ClivlyEntitiesConfig;
|
|
166
|
+
//#endregion
|
|
167
|
+
export { ProjectionIdentity as a, ProjectionRef as c, ProjectionFieldBinding as i, identityRefs as l, mappingsToEntitiesConfig as n, ProjectionJoin as o, BASE_REF as r, ProjectionMapping as s, EntityMappingRow as t, projectionSchema as u };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { a as ClivlyEntitiesConfig } from "./entity-config-
|
|
1
|
+
import { a as ClivlyEntitiesConfig } from "./entity-config-C4Yf_fPj.cjs";
|
|
2
2
|
//#region ../sdk/src/drizzle-meta.d.ts
|
|
3
3
|
declare const DRIZZLE_META: "__clivly_drizzle_source_meta__";
|
|
4
4
|
interface DrizzleSourceMeta {
|
|
@@ -10,6 +10,8 @@ interface DrizzleSourceMeta {
|
|
|
10
10
|
idField: string;
|
|
11
11
|
/** The backing table's real name, so discovery can key metadata by table. */
|
|
12
12
|
tableName?: string;
|
|
13
|
+
/** Every unique key on the table, each as its DB column names. */
|
|
14
|
+
uniqueConstraints?: string[][];
|
|
13
15
|
}
|
|
14
16
|
//#endregion
|
|
15
17
|
//#region ../sdk/src/types.d.ts
|
|
@@ -33,6 +35,13 @@ interface DiscoveredTable {
|
|
|
33
35
|
name: string;
|
|
34
36
|
/** Approximate source row count, when cheaply derivable. */
|
|
35
37
|
rowCount?: number;
|
|
38
|
+
/**
|
|
39
|
+
* Every unique key on the table, each as its DB column names. Primary keys
|
|
40
|
+
* are included (a PK is a unique key). Absent on v1 hosts and for
|
|
41
|
+
* hand-declared tables — consumers must treat absence as "unknown", never
|
|
42
|
+
* as "no unique keys".
|
|
43
|
+
*/
|
|
44
|
+
uniqueConstraints?: string[][];
|
|
36
45
|
}
|
|
37
46
|
interface ClivlySDKConfig {
|
|
38
47
|
/** Org-scoped API token (sk_live_…) from Settings → API keys. */
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { a as ClivlyEntitiesConfig } from "./entity-config-
|
|
1
|
+
import { a as ClivlyEntitiesConfig } from "./entity-config-C4Yf_fPj.mjs";
|
|
2
2
|
//#region ../sdk/src/drizzle-meta.d.ts
|
|
3
3
|
declare const DRIZZLE_META: "__clivly_drizzle_source_meta__";
|
|
4
4
|
interface DrizzleSourceMeta {
|
|
@@ -10,6 +10,8 @@ interface DrizzleSourceMeta {
|
|
|
10
10
|
idField: string;
|
|
11
11
|
/** The backing table's real name, so discovery can key metadata by table. */
|
|
12
12
|
tableName?: string;
|
|
13
|
+
/** Every unique key on the table, each as its DB column names. */
|
|
14
|
+
uniqueConstraints?: string[][];
|
|
13
15
|
}
|
|
14
16
|
//#endregion
|
|
15
17
|
//#region ../sdk/src/types.d.ts
|
|
@@ -33,6 +35,13 @@ interface DiscoveredTable {
|
|
|
33
35
|
name: string;
|
|
34
36
|
/** Approximate source row count, when cheaply derivable. */
|
|
35
37
|
rowCount?: number;
|
|
38
|
+
/**
|
|
39
|
+
* Every unique key on the table, each as its DB column names. Primary keys
|
|
40
|
+
* are included (a PK is a unique key). Absent on v1 hosts and for
|
|
41
|
+
* hand-declared tables — consumers must treat absence as "unknown", never
|
|
42
|
+
* as "no unique keys".
|
|
43
|
+
*/
|
|
44
|
+
uniqueConstraints?: string[][];
|
|
36
45
|
}
|
|
37
46
|
interface ClivlySDKConfig {
|
|
38
47
|
/** Org-scoped API token (sk_live_…) from Settings → API keys. */
|