clivly 0.9.2 → 0.9.4
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 +60 -6
- package/core-entity-config.cjs +1 -1
- package/core-entity-config.mjs +1 -1
- package/core-mappings-config.cjs +1 -1
- package/core-mappings-config.mjs +1 -1
- package/core-sync-engine.cjs +1 -1
- package/core-sync-engine.mjs +1 -1
- package/core-view-compiler.cjs +1 -1
- package/core-view-compiler.mjs +1 -1
- package/core.cjs +11 -6
- package/core.d.cts +3 -2
- package/core.d.mts +3 -2
- package/core.mjs +8 -7
- package/drizzle.cjs +74 -9
- package/drizzle.d.cts +83 -7
- package/drizzle.d.mts +83 -7
- package/drizzle.mjs +74 -10
- package/{entity-config-DtBsl2MQ.cjs → entity-config-7sGCk_nw.cjs} +1 -1
- package/{entity-config-kUHri9yA.mjs → entity-config-B74SPOUZ.mjs} +1 -1
- package/index.cjs +141 -29
- package/index.d.cts +2 -1
- package/index.d.mts +2 -1
- package/index.mjs +141 -30
- package/integration-state-BK-riZnm.d.cts +130 -0
- package/integration-state-BK-riZnm.d.mts +130 -0
- package/{internal-Df-PtOH_.mjs → internal-CykXpEGk.mjs} +2 -2
- package/{internal-CwnEG6Wl.cjs → internal-DqduZU3l.cjs} +2 -2
- package/internal-entity-config.cjs +1 -1
- package/internal-entity-config.mjs +1 -1
- package/internal-entity-heuristics.cjs +1 -1
- package/internal-entity-heuristics.mjs +1 -1
- package/internal-mappings-config.cjs +1 -1
- package/internal-mappings-config.mjs +1 -1
- package/{internal-CDY8g9Ic.d.mts → internal-o2M7FGlR.d.mts} +29 -1
- package/internal-sync-engine.cjs +1 -1
- package/internal-sync-engine.mjs +1 -1
- package/internal-view-compiler.cjs +1 -1
- package/internal-view-compiler.mjs +1 -1
- package/{internal-Da_dlcQ_.d.cts → internal-wCXSELDN.d.cts} +29 -1
- package/internal.cjs +11 -6
- package/internal.d.cts +3 -2
- package/internal.d.mts +3 -2
- package/internal.mjs +8 -7
- package/{mappings-config-B0RqFLxu.cjs → mappings-config-CLyEg0sf.cjs} +1 -1
- package/{mappings-config-B1b1HVBg.mjs → mappings-config-DQS_s4dg.mjs} +1 -1
- package/{namespace-probe-C6aHjedO.d.cts → namespace-probe-BoGI18dQ.d.cts} +15 -0
- package/{namespace-probe-Dj-0Q3Hb.d.mts → namespace-probe-Cn7voAd0.d.mts} +15 -0
- package/package.json +1 -1
- package/{projection-D7xmQP4S.mjs → projection-CSGJbZlZ.mjs} +25 -4
- package/{projection-C5244vGa.cjs → projection-Dz6_i1-w.cjs} +25 -4
- package/projection-sql-BgnfiGqF.mjs +65 -0
- package/projection-sql-Cl1qIn8m.cjs +94 -0
- package/{sdk-D4Wp_uxb.cjs → sdk-CM1UO-I7.cjs} +59 -15
- package/{sdk-DXV8M_Io.mjs → sdk-DYBDR939.mjs} +54 -16
- package/sdk.cjs +3 -2
- package/sdk.d.cts +5 -2
- package/sdk.d.mts +5 -2
- package/sdk.mjs +3 -3
- package/{sync-engine-abE94g6X.cjs → sync-engine-C4A5jgA4.cjs} +1 -1
- package/{sync-engine-SuxSzbZ4.mjs → sync-engine-Dt5QQSKO.mjs} +1 -1
- package/{view-compiler-Blu4OXJ7.cjs → view-compiler-B5nDal14.cjs} +21 -74
- package/{view-compiler-CQx8TRrW.mjs → view-compiler-CSYwEWf5.mjs} +2 -55
- package/vite.d.cts +1 -1
- package/vite.d.mts +1 -1
package/internal-sync-engine.cjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
-
const require_sync_engine = require("./sync-engine-
|
|
2
|
+
const require_sync_engine = require("./sync-engine-C4A5jgA4.cjs");
|
|
3
3
|
exports.computeSampleWarnings = require_sync_engine.computeSampleWarnings;
|
|
4
4
|
exports.previewSync = require_sync_engine.previewSync;
|
|
5
5
|
exports.reconcile = require_sync_engine.reconcile;
|
package/internal-sync-engine.mjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { i as runSync, n as previewSync, r as reconcile, t as computeSampleWarnings } from "./sync-engine-
|
|
1
|
+
import { i as runSync, n as previewSync, r as reconcile, t as computeSampleWarnings } from "./sync-engine-Dt5QQSKO.mjs";
|
|
2
2
|
export { computeSampleWarnings, previewSync, reconcile, runSync };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
-
const require_view_compiler = require("./view-compiler-
|
|
2
|
+
const require_view_compiler = require("./view-compiler-B5nDal14.cjs");
|
|
3
3
|
exports.DEFAULT_VIEW_PREFIX = require_view_compiler.DEFAULT_VIEW_PREFIX;
|
|
4
4
|
exports.compileEntityView = require_view_compiler.compileEntityView;
|
|
5
5
|
exports.compileEntityViews = require_view_compiler.compileEntityViews;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { a as explainViewExecutionError, i as explainEntitiesConfig, n as compileEntityView, r as compileEntityViews, t as DEFAULT_VIEW_PREFIX } from "./view-compiler-
|
|
1
|
+
import { a as explainViewExecutionError, i as explainEntitiesConfig, n as compileEntityView, r as compileEntityViews, t as DEFAULT_VIEW_PREFIX } from "./view-compiler-CSYwEWf5.mjs";
|
|
2
2
|
export { DEFAULT_VIEW_PREFIX, compileEntityView, compileEntityViews, explainEntitiesConfig, explainViewExecutionError };
|
|
@@ -36,6 +36,34 @@ declare function describeCardinality(draft: ProjectionDraft, schema: DiscoveredS
|
|
|
36
36
|
joinKey: string;
|
|
37
37
|
}>;
|
|
38
38
|
//#endregion
|
|
39
|
+
//#region ../core/src/projection-sql.d.ts
|
|
40
|
+
/**
|
|
41
|
+
* SQL generation for projection-backed entities.
|
|
42
|
+
*
|
|
43
|
+
* Base and joins are aliased by their ref key (`base`, then each join's `key`),
|
|
44
|
+
* which is what allows the same table to be joined twice and keeps generated
|
|
45
|
+
* SQL independent of host table names.
|
|
46
|
+
*
|
|
47
|
+
* Pure string generation — no DB access. Identifiers are escaped so output is
|
|
48
|
+
* deterministic and injection-safe.
|
|
49
|
+
*/
|
|
50
|
+
/** Quote a single identifier part, escaping embedded double-quotes. */
|
|
51
|
+
declare function quoteIdent(name: string): string;
|
|
52
|
+
/**
|
|
53
|
+
* The identity expression. Composite identities concatenate their parts with
|
|
54
|
+
* `::`; validation guarantees every part is NOT NULL and non-text, which is
|
|
55
|
+
* what makes the concatenation collision-free.
|
|
56
|
+
*
|
|
57
|
+
* Exported unaliased because two paths need the same expression under different
|
|
58
|
+
* names: the view compiler aliases it `id`, and the SDK's projection push source
|
|
59
|
+
* also orders and keyset-paginates by it. Sharing one definition is what keeps
|
|
60
|
+
* a pushed row's `id` identical to the one the view would have produced.
|
|
61
|
+
*/
|
|
62
|
+
declare function compileProjectionIdentity(projection: ProjectionMapping, basePkColumn: string): string;
|
|
63
|
+
declare function compileProjectionJoins(projection: ProjectionMapping): string[];
|
|
64
|
+
/** `FROM <baseTable> AS "base"` — the alias every ref resolves against. */
|
|
65
|
+
declare function compileProjectionFrom(projection: ProjectionMapping): string;
|
|
66
|
+
//#endregion
|
|
39
67
|
//#region ../core/src/projection-validate.d.ts
|
|
40
68
|
/**
|
|
41
69
|
* Validate a projection against the discovered schema. Returns every error
|
|
@@ -69,4 +97,4 @@ declare function coversUniqueKey(table: DiscoveredSchemaTable, columns: string[]
|
|
|
69
97
|
/** Is this table's payload rich enough to validate a projection against? */
|
|
70
98
|
declare function hasRichMeta(table: DiscoveredSchemaTable): boolean;
|
|
71
99
|
//#endregion
|
|
72
|
-
export { validateProjection as a,
|
|
100
|
+
export { joinFansOut as _, validateProjection as a, compileProjectionJoins as c, describeCardinality as d, draftErrors as f, fanOutJoins as g, suggestJoinConditions as h, primaryKeyColumns as i, quoteIdent as l, emptyProjectionDraft as m, coversUniqueKey as n, compileProjectionFrom as o, draftToProjection as p, hasRichMeta as r, compileProjectionIdentity as s, columnMetaFor as t, ProjectionDraft as u };
|
package/internal.cjs
CHANGED
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
-
const require_projection = require("./projection-
|
|
3
|
-
const require_entity_config = require("./entity-config-
|
|
4
|
-
const require_mappings_config = require("./mappings-config-
|
|
2
|
+
const require_projection = require("./projection-Dz6_i1-w.cjs");
|
|
3
|
+
const require_entity_config = require("./entity-config-7sGCk_nw.cjs");
|
|
4
|
+
const require_mappings_config = require("./mappings-config-CLyEg0sf.cjs");
|
|
5
5
|
const require_auth_adapter = require("./auth-adapter-CiEXcweZ.cjs");
|
|
6
6
|
const require_mapping_form = require("./mapping-form-BpfON_ME.cjs");
|
|
7
|
-
const require_internal = require("./internal-
|
|
8
|
-
const
|
|
9
|
-
const
|
|
7
|
+
const require_internal = require("./internal-DqduZU3l.cjs");
|
|
8
|
+
const require_projection_sql = require("./projection-sql-Cl1qIn8m.cjs");
|
|
9
|
+
const require_view_compiler = require("./view-compiler-B5nDal14.cjs");
|
|
10
|
+
const require_sync_engine = require("./sync-engine-C4A5jgA4.cjs");
|
|
10
11
|
exports.BASE_REF = require_projection.BASE_REF;
|
|
11
12
|
exports.CANONICAL_FIELDS = require_entity_config.CANONICAL_FIELDS;
|
|
12
13
|
exports.CRM_CONCEPTS = require_entity_config.CRM_CONCEPTS;
|
|
@@ -19,6 +20,9 @@ exports.buildRelationships = require_mapping_form.buildRelationships;
|
|
|
19
20
|
exports.columnMetaFor = require_entity_config.columnMetaFor;
|
|
20
21
|
exports.compileEntityView = require_view_compiler.compileEntityView;
|
|
21
22
|
exports.compileEntityViews = require_view_compiler.compileEntityViews;
|
|
23
|
+
exports.compileProjectionFrom = require_projection_sql.compileProjectionFrom;
|
|
24
|
+
exports.compileProjectionIdentity = require_projection_sql.compileProjectionIdentity;
|
|
25
|
+
exports.compileProjectionJoins = require_projection_sql.compileProjectionJoins;
|
|
22
26
|
exports.coversUniqueKey = require_entity_config.coversUniqueKey;
|
|
23
27
|
exports.defineClivlyConfig = require_entity_config.defineClivlyConfig;
|
|
24
28
|
exports.describeCardinality = require_internal.describeCardinality;
|
|
@@ -35,6 +39,7 @@ exports.joinFansOut = require_entity_config.joinFansOut;
|
|
|
35
39
|
exports.mappingsToEntitiesConfig = require_mappings_config.mappingsToEntitiesConfig;
|
|
36
40
|
exports.primaryKeyColumns = require_entity_config.primaryKeyColumns;
|
|
37
41
|
exports.projectionSchema = require_projection.projectionSchema;
|
|
42
|
+
exports.quoteIdent = require_projection_sql.quoteIdent;
|
|
38
43
|
exports.reconcile = require_sync_engine.reconcile;
|
|
39
44
|
exports.relationshipSchema = require_entity_config.relationshipSchema;
|
|
40
45
|
exports.relationshipViaSignature = require_mapping_form.relationshipViaSignature;
|
package/internal.d.cts
CHANGED
|
@@ -6,5 +6,6 @@ import { i as relationshipViaSignature, n as buildFilterFromDiscriminator, r as
|
|
|
6
6
|
import { i as mappingsToEntitiesConfig, t as EntityMappingRow } from "./mappings-config-RQLGx8ub.cjs";
|
|
7
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-CmEdAMwj.cjs";
|
|
8
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-BG2O1an2.cjs";
|
|
9
|
-
import { a as
|
|
10
|
-
|
|
9
|
+
import { a as IntegrationStep, c as StepProblem, i as IntegrationStatus, l as StepState, n as IntegrationFacts, o as NextAction, r as IntegrationState, s as StepId, t as ConnectionLiveness } from "./integration-state-BK-riZnm.cjs";
|
|
10
|
+
import { _ as joinFansOut, a as validateProjection, c as compileProjectionJoins, d as describeCardinality, f as draftErrors, g as fanOutJoins, h as suggestJoinConditions, i as primaryKeyColumns, l as quoteIdent, m as emptyProjectionDraft, n as coversUniqueKey, o as compileProjectionFrom, p as draftToProjection, r as hasRichMeta, s as compileProjectionIdentity, t as columnMetaFor, u as ProjectionDraft } from "./internal-wCXSELDN.cjs";
|
|
11
|
+
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 ConnectionLiveness, 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, type IntegrationFacts, type IntegrationState, type IntegrationStatus, type IntegrationStep, MATERIALIZING_CONCEPTS, type MaterializingConcept, type MembershipResolver, type MirrorRecord, type NextAction, 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 StepId, type StepProblem, type StepState, 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, compileProjectionFrom, compileProjectionIdentity, compileProjectionJoins, coversUniqueKey, defineClivlyConfig, describeCardinality, draftErrors, draftToProjection, emptyProjectionDraft, entitiesConfigSchema, explainEntitiesConfig, fanOutJoins, filterSchema, hasRichMeta, identityRefs, joinFansOut, mappingsToEntitiesConfig, primaryKeyColumns, projectionSchema, quoteIdent, reconcile, relationshipSchema, relationshipViaSignature, relationshipsSchema, runSync, suggestJoinConditions, validateEntitiesConfig, validateProjection };
|
package/internal.d.mts
CHANGED
|
@@ -6,5 +6,6 @@ import { i as relationshipViaSignature, n as buildFilterFromDiscriminator, r as
|
|
|
6
6
|
import { i as mappingsToEntitiesConfig, t as EntityMappingRow } from "./mappings-config-D9dsonoi.mjs";
|
|
7
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-Bo7pqXW3.mjs";
|
|
8
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-DgQbrJON.mjs";
|
|
9
|
-
import { a as
|
|
10
|
-
|
|
9
|
+
import { a as IntegrationStep, c as StepProblem, i as IntegrationStatus, l as StepState, n as IntegrationFacts, o as NextAction, r as IntegrationState, s as StepId, t as ConnectionLiveness } from "./integration-state-BK-riZnm.mjs";
|
|
10
|
+
import { _ as joinFansOut, a as validateProjection, c as compileProjectionJoins, d as describeCardinality, f as draftErrors, g as fanOutJoins, h as suggestJoinConditions, i as primaryKeyColumns, l as quoteIdent, m as emptyProjectionDraft, n as coversUniqueKey, o as compileProjectionFrom, p as draftToProjection, r as hasRichMeta, s as compileProjectionIdentity, t as columnMetaFor, u as ProjectionDraft } from "./internal-o2M7FGlR.mjs";
|
|
11
|
+
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 ConnectionLiveness, 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, type IntegrationFacts, type IntegrationState, type IntegrationStatus, type IntegrationStep, MATERIALIZING_CONCEPTS, type MaterializingConcept, type MembershipResolver, type MirrorRecord, type NextAction, 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 StepId, type StepProblem, type StepState, 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, compileProjectionFrom, compileProjectionIdentity, compileProjectionJoins, coversUniqueKey, defineClivlyConfig, describeCardinality, draftErrors, draftToProjection, emptyProjectionDraft, entitiesConfigSchema, explainEntitiesConfig, fanOutJoins, filterSchema, hasRichMeta, identityRefs, joinFansOut, mappingsToEntitiesConfig, primaryKeyColumns, projectionSchema, quoteIdent, reconcile, relationshipSchema, relationshipViaSignature, relationshipsSchema, runSync, suggestJoinConditions, validateEntitiesConfig, validateProjection };
|
package/internal.mjs
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
1
|
-
import { i as projectionSchema, r as identityRefs, t as BASE_REF } from "./projection-
|
|
2
|
-
import { _ as columnMetaFor, a as MATERIALIZING_CONCEPTS, b as primaryKeyColumns, c as entitiesConfigSchema, d as relationshipSchema, f as relationshipsSchema, g as joinFansOut, h as fanOutJoins, i as ClivlyConfigError, l as filterSchema, m as validateProjection, n as CRM_CONCEPTS, p as validateEntitiesConfig, s as defineClivlyConfig, t as CANONICAL_FIELDS, v as coversUniqueKey, y as hasRichMeta } from "./entity-config-
|
|
3
|
-
import { n as mappingsToEntitiesConfig } from "./mappings-config-
|
|
1
|
+
import { i as projectionSchema, r as identityRefs, t as BASE_REF } from "./projection-CSGJbZlZ.mjs";
|
|
2
|
+
import { _ as columnMetaFor, a as MATERIALIZING_CONCEPTS, b as primaryKeyColumns, c as entitiesConfigSchema, d as relationshipSchema, f as relationshipsSchema, g as joinFansOut, h as fanOutJoins, i as ClivlyConfigError, l as filterSchema, m as validateProjection, n as CRM_CONCEPTS, p as validateEntitiesConfig, s as defineClivlyConfig, t as CANONICAL_FIELDS, v as coversUniqueKey, y as hasRichMeta } from "./entity-config-B74SPOUZ.mjs";
|
|
3
|
+
import { n as mappingsToEntitiesConfig } from "./mappings-config-DQS_s4dg.mjs";
|
|
4
4
|
import { t as authCustom } from "./auth-adapter-gfVDxf3d.mjs";
|
|
5
5
|
import { n as buildRelationships, r as relationshipViaSignature, t as buildFilterFromDiscriminator } from "./mapping-form-DigkuvFc.mjs";
|
|
6
|
-
import { a as suggestJoinConditions, i as emptyProjectionDraft, n as draftErrors, r as draftToProjection, t as describeCardinality } from "./internal-
|
|
7
|
-
import {
|
|
8
|
-
import { i as
|
|
9
|
-
|
|
6
|
+
import { a as suggestJoinConditions, i as emptyProjectionDraft, n as draftErrors, r as draftToProjection, t as describeCardinality } from "./internal-CykXpEGk.mjs";
|
|
7
|
+
import { a as quoteIdent, n as compileProjectionIdentity, r as compileProjectionJoins, t as compileProjectionFrom } from "./projection-sql-BgnfiGqF.mjs";
|
|
8
|
+
import { i as explainEntitiesConfig, n as compileEntityView, r as compileEntityViews, t as DEFAULT_VIEW_PREFIX } from "./view-compiler-CSYwEWf5.mjs";
|
|
9
|
+
import { i as runSync, r as reconcile } from "./sync-engine-Dt5QQSKO.mjs";
|
|
10
|
+
export { BASE_REF, CANONICAL_FIELDS, CRM_CONCEPTS, ClivlyConfigError, DEFAULT_VIEW_PREFIX, MATERIALIZING_CONCEPTS, authCustom, buildFilterFromDiscriminator, buildRelationships, columnMetaFor, compileEntityView, compileEntityViews, compileProjectionFrom, compileProjectionIdentity, compileProjectionJoins, coversUniqueKey, defineClivlyConfig, describeCardinality, draftErrors, draftToProjection, emptyProjectionDraft, entitiesConfigSchema, explainEntitiesConfig, fanOutJoins, filterSchema, hasRichMeta, identityRefs, joinFansOut, mappingsToEntitiesConfig, primaryKeyColumns, projectionSchema, quoteIdent, reconcile, relationshipSchema, relationshipViaSignature, relationshipsSchema, runSync, suggestJoinConditions, validateEntitiesConfig, validateProjection };
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { a as ClivlyEntitiesConfig } from "./entity-config-B2RA53nw.cjs";
|
|
2
|
+
import { r as IntegrationState } from "./integration-state-BK-riZnm.cjs";
|
|
2
3
|
//#region ../sdk/src/drizzle-meta.d.ts
|
|
3
4
|
declare const DRIZZLE_META: "__clivly_drizzle_source_meta__";
|
|
4
5
|
interface DrizzleSourceMeta {
|
|
@@ -301,6 +302,12 @@ interface ClivlyConnectResult {
|
|
|
301
302
|
retryable: boolean;
|
|
302
303
|
/** HTTP status, or null when the request never completed (network error). */
|
|
303
304
|
status: number | null;
|
|
305
|
+
/**
|
|
306
|
+
* The workspace's setup ladder, computed by the server. Present only on
|
|
307
|
+
* `ping()`, and null when the server is older than this field or could not
|
|
308
|
+
* read it — which the CLI renders as "unavailable", never as "not set up".
|
|
309
|
+
*/
|
|
310
|
+
workspace?: IntegrationState | null;
|
|
304
311
|
}
|
|
305
312
|
interface SyncCursor {
|
|
306
313
|
/** The row's id, breaking ties when timestamps collide. */
|
|
@@ -317,6 +324,14 @@ interface SyncSource {
|
|
|
317
324
|
}): Promise<Record<string, unknown>[]>;
|
|
318
325
|
/** Stable, unique tie-breaker column for keyset paging. Defaults to "id". */
|
|
319
326
|
idField?: string;
|
|
327
|
+
/**
|
|
328
|
+
* Custom-object slug this source mirrors into. Only meaningful for entries in
|
|
329
|
+
* `source.custom`, whose element type narrows it to required — declared here
|
|
330
|
+
* because the sync and readiness paths read `source.objectType` off a plain
|
|
331
|
+
* `SyncSource`, so leaving it off left the property required by one type,
|
|
332
|
+
* absent from another, and read by the runtime.
|
|
333
|
+
*/
|
|
334
|
+
objectType?: string;
|
|
320
335
|
/** Set by `fromDrizzle`; lets `doctor` introspect the backing table. */
|
|
321
336
|
[DRIZZLE_META]?: DrizzleSourceMeta;
|
|
322
337
|
}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { a as ClivlyEntitiesConfig } from "./entity-config-B2RA53nw.mjs";
|
|
2
|
+
import { r as IntegrationState } from "./integration-state-BK-riZnm.mjs";
|
|
2
3
|
//#region ../sdk/src/drizzle-meta.d.ts
|
|
3
4
|
declare const DRIZZLE_META: "__clivly_drizzle_source_meta__";
|
|
4
5
|
interface DrizzleSourceMeta {
|
|
@@ -301,6 +302,12 @@ interface ClivlyConnectResult {
|
|
|
301
302
|
retryable: boolean;
|
|
302
303
|
/** HTTP status, or null when the request never completed (network error). */
|
|
303
304
|
status: number | null;
|
|
305
|
+
/**
|
|
306
|
+
* The workspace's setup ladder, computed by the server. Present only on
|
|
307
|
+
* `ping()`, and null when the server is older than this field or could not
|
|
308
|
+
* read it — which the CLI renders as "unavailable", never as "not set up".
|
|
309
|
+
*/
|
|
310
|
+
workspace?: IntegrationState | null;
|
|
304
311
|
}
|
|
305
312
|
interface SyncCursor {
|
|
306
313
|
/** The row's id, breaking ties when timestamps collide. */
|
|
@@ -317,6 +324,14 @@ interface SyncSource {
|
|
|
317
324
|
}): Promise<Record<string, unknown>[]>;
|
|
318
325
|
/** Stable, unique tie-breaker column for keyset paging. Defaults to "id". */
|
|
319
326
|
idField?: string;
|
|
327
|
+
/**
|
|
328
|
+
* Custom-object slug this source mirrors into. Only meaningful for entries in
|
|
329
|
+
* `source.custom`, whose element type narrows it to required — declared here
|
|
330
|
+
* because the sync and readiness paths read `source.objectType` off a plain
|
|
331
|
+
* `SyncSource`, so leaving it off left the property required by one type,
|
|
332
|
+
* absent from another, and read by the runtime.
|
|
333
|
+
*/
|
|
334
|
+
objectType?: string;
|
|
320
335
|
/** Set by `fromDrizzle`; lets `doctor` introspect the backing table. */
|
|
321
336
|
[DRIZZLE_META]?: DrizzleSourceMeta;
|
|
322
337
|
}
|
package/package.json
CHANGED
|
@@ -4220,8 +4220,29 @@ function superRefine(fn, params) {
|
|
|
4220
4220
|
*/
|
|
4221
4221
|
/** The reserved ref name for the projection's base table. */
|
|
4222
4222
|
const BASE_REF = "base";
|
|
4223
|
-
/**
|
|
4224
|
-
|
|
4223
|
+
/**
|
|
4224
|
+
* Entity keys become view names (`crm_src_<entityKey>`), so keep them slugs.
|
|
4225
|
+
*
|
|
4226
|
+
* Accepts hyphens as well as underscores, matching `OBJECT_TYPE_SLUG_PATTERN`
|
|
4227
|
+
* on the server. Those two were widened apart: the server learned hyphens
|
|
4228
|
+
* because the SDK's own `slugify` collapses non-alphanumerics to them and
|
|
4229
|
+
* `clivly status` reports that form as canonical — but this pattern was missed,
|
|
4230
|
+
* so `clivly status` would tell you to key an entity `client-accounts` and then
|
|
4231
|
+
* `defineClivlyConfig` would reject the config it had just asked for. Same bug,
|
|
4232
|
+
* opposite half of the product.
|
|
4233
|
+
*
|
|
4234
|
+
* Widening is the safe direction: every key that was valid before still is, so
|
|
4235
|
+
* nothing existing is renamed. Safe at all because neither use is ever a bare
|
|
4236
|
+
* SQL identifier — the view name is quoted (`view-compiler.ts`, `quoteIdent`),
|
|
4237
|
+
* and so is a join's `key` when it is emitted as an alias.
|
|
4238
|
+
*/
|
|
4239
|
+
const PROJECTION_KEY_PATTERN = /^[a-z][a-z0-9_-]*$/;
|
|
4240
|
+
/**
|
|
4241
|
+
* Stated in prose because the default for a failed `.regex()` reports only the
|
|
4242
|
+
* pattern — the developer is told the config is wrong and handed a regex to
|
|
4243
|
+
* decode. Naming the rule is what makes the failure actionable.
|
|
4244
|
+
*/
|
|
4245
|
+
const PROJECTION_KEY_MESSAGE = "must be lowercase letters, digits, \"-\" or \"_\", starting with a letter";
|
|
4225
4246
|
const projectionRefSchema = strictObject({
|
|
4226
4247
|
table: string().min(1),
|
|
4227
4248
|
column: string().min(1)
|
|
@@ -4233,7 +4254,7 @@ const projectionJoinConditionSchema = strictObject({
|
|
|
4233
4254
|
});
|
|
4234
4255
|
const projectionJoinSchema = strictObject({
|
|
4235
4256
|
/** SQL alias and ref target. Unique within the projection. */
|
|
4236
|
-
key: string().regex(PROJECTION_KEY_PATTERN),
|
|
4257
|
+
key: string().regex(PROJECTION_KEY_PATTERN, { message: `join key ${PROJECTION_KEY_MESSAGE}` }),
|
|
4237
4258
|
table: string().min(1),
|
|
4238
4259
|
type: _enum(["inner", "left"]),
|
|
4239
4260
|
on: array(projectionJoinConditionSchema).min(1)
|
|
@@ -4257,7 +4278,7 @@ const projectionIdentitySchema = union([
|
|
|
4257
4278
|
const projectionSchema = strictObject({
|
|
4258
4279
|
version: literal(1),
|
|
4259
4280
|
kind: literal("projection"),
|
|
4260
|
-
entityKey: string().regex(PROJECTION_KEY_PATTERN),
|
|
4281
|
+
entityKey: string().regex(PROJECTION_KEY_PATTERN, { message: `entityKey ${PROJECTION_KEY_MESSAGE}` }),
|
|
4261
4282
|
baseTable: string().min(1),
|
|
4262
4283
|
joins: array(projectionJoinSchema),
|
|
4263
4284
|
fieldBindings: record(string(), projectionFieldBindingSchema).refine((b) => Object.keys(b).length > 0, { message: "at least one field must be bound" }),
|
|
@@ -4220,8 +4220,29 @@ function superRefine(fn, params) {
|
|
|
4220
4220
|
*/
|
|
4221
4221
|
/** The reserved ref name for the projection's base table. */
|
|
4222
4222
|
const BASE_REF = "base";
|
|
4223
|
-
/**
|
|
4224
|
-
|
|
4223
|
+
/**
|
|
4224
|
+
* Entity keys become view names (`crm_src_<entityKey>`), so keep them slugs.
|
|
4225
|
+
*
|
|
4226
|
+
* Accepts hyphens as well as underscores, matching `OBJECT_TYPE_SLUG_PATTERN`
|
|
4227
|
+
* on the server. Those two were widened apart: the server learned hyphens
|
|
4228
|
+
* because the SDK's own `slugify` collapses non-alphanumerics to them and
|
|
4229
|
+
* `clivly status` reports that form as canonical — but this pattern was missed,
|
|
4230
|
+
* so `clivly status` would tell you to key an entity `client-accounts` and then
|
|
4231
|
+
* `defineClivlyConfig` would reject the config it had just asked for. Same bug,
|
|
4232
|
+
* opposite half of the product.
|
|
4233
|
+
*
|
|
4234
|
+
* Widening is the safe direction: every key that was valid before still is, so
|
|
4235
|
+
* nothing existing is renamed. Safe at all because neither use is ever a bare
|
|
4236
|
+
* SQL identifier — the view name is quoted (`view-compiler.ts`, `quoteIdent`),
|
|
4237
|
+
* and so is a join's `key` when it is emitted as an alias.
|
|
4238
|
+
*/
|
|
4239
|
+
const PROJECTION_KEY_PATTERN = /^[a-z][a-z0-9_-]*$/;
|
|
4240
|
+
/**
|
|
4241
|
+
* Stated in prose because the default for a failed `.regex()` reports only the
|
|
4242
|
+
* pattern — the developer is told the config is wrong and handed a regex to
|
|
4243
|
+
* decode. Naming the rule is what makes the failure actionable.
|
|
4244
|
+
*/
|
|
4245
|
+
const PROJECTION_KEY_MESSAGE = "must be lowercase letters, digits, \"-\" or \"_\", starting with a letter";
|
|
4225
4246
|
const projectionRefSchema = strictObject({
|
|
4226
4247
|
table: string().min(1),
|
|
4227
4248
|
column: string().min(1)
|
|
@@ -4233,7 +4254,7 @@ const projectionJoinConditionSchema = strictObject({
|
|
|
4233
4254
|
});
|
|
4234
4255
|
const projectionJoinSchema = strictObject({
|
|
4235
4256
|
/** SQL alias and ref target. Unique within the projection. */
|
|
4236
|
-
key: string().regex(PROJECTION_KEY_PATTERN),
|
|
4257
|
+
key: string().regex(PROJECTION_KEY_PATTERN, { message: `join key ${PROJECTION_KEY_MESSAGE}` }),
|
|
4237
4258
|
table: string().min(1),
|
|
4238
4259
|
type: _enum(["inner", "left"]),
|
|
4239
4260
|
on: array(projectionJoinConditionSchema).min(1)
|
|
@@ -4257,7 +4278,7 @@ const projectionIdentitySchema = union([
|
|
|
4257
4278
|
const projectionSchema = strictObject({
|
|
4258
4279
|
version: literal(1),
|
|
4259
4280
|
kind: literal("projection"),
|
|
4260
|
-
entityKey: string().regex(PROJECTION_KEY_PATTERN),
|
|
4281
|
+
entityKey: string().regex(PROJECTION_KEY_PATTERN, { message: `entityKey ${PROJECTION_KEY_MESSAGE}` }),
|
|
4261
4282
|
baseTable: string().min(1),
|
|
4262
4283
|
joins: array(projectionJoinSchema),
|
|
4263
4284
|
fieldBindings: record(string(), projectionFieldBindingSchema).refine((b) => Object.keys(b).length > 0, { message: "at least one field must be bound" }),
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import { r as identityRefs, t as BASE_REF } from "./projection-CSGJbZlZ.mjs";
|
|
2
|
+
//#region ../core/src/projection-sql.ts
|
|
3
|
+
/**
|
|
4
|
+
* SQL generation for projection-backed entities.
|
|
5
|
+
*
|
|
6
|
+
* Base and joins are aliased by their ref key (`base`, then each join's `key`),
|
|
7
|
+
* which is what allows the same table to be joined twice and keeps generated
|
|
8
|
+
* SQL independent of host table names.
|
|
9
|
+
*
|
|
10
|
+
* Pure string generation — no DB access. Identifiers are escaped so output is
|
|
11
|
+
* deterministic and injection-safe.
|
|
12
|
+
*/
|
|
13
|
+
/** Quote a single identifier part, escaping embedded double-quotes. */
|
|
14
|
+
function quoteIdent(name) {
|
|
15
|
+
return `"${name.replace(/"/g, "\"\"")}"`;
|
|
16
|
+
}
|
|
17
|
+
function refSql(ref) {
|
|
18
|
+
return `${quoteIdent(ref.table)}.${quoteIdent(ref.column)}`;
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* The identity expression. Composite identities concatenate their parts with
|
|
22
|
+
* `::`; validation guarantees every part is NOT NULL and non-text, which is
|
|
23
|
+
* what makes the concatenation collision-free.
|
|
24
|
+
*
|
|
25
|
+
* Exported unaliased because two paths need the same expression under different
|
|
26
|
+
* names: the view compiler aliases it `id`, and the SDK's projection push source
|
|
27
|
+
* also orders and keyset-paginates by it. Sharing one definition is what keeps
|
|
28
|
+
* a pushed row's `id` identical to the one the view would have produced.
|
|
29
|
+
*/
|
|
30
|
+
function compileProjectionIdentity(projection, basePkColumn) {
|
|
31
|
+
const refs = identityRefs(projection.identity, basePkColumn);
|
|
32
|
+
if (projection.identity.kind === "composite") return `CONCAT_WS('::', ${refs.map((ref) => `${refSql(ref)}::text`).join(", ")})`;
|
|
33
|
+
const [ref] = refs;
|
|
34
|
+
if (!ref) throw new Error("projection identity resolved to no column");
|
|
35
|
+
return refSql(ref);
|
|
36
|
+
}
|
|
37
|
+
/** The identity expression, aliased as `id`. */
|
|
38
|
+
function identitySql(projection, basePkColumn) {
|
|
39
|
+
return `${compileProjectionIdentity(projection, basePkColumn)} AS ${quoteIdent("id")}`;
|
|
40
|
+
}
|
|
41
|
+
function compileProjectionSelect(projection, basePkColumn) {
|
|
42
|
+
const selectItems = [identitySql(projection, basePkColumn)];
|
|
43
|
+
const columns = ["id"];
|
|
44
|
+
for (const [field, binding] of Object.entries(projection.fieldBindings)) {
|
|
45
|
+
selectItems.push(`${refSql(binding.from)} AS ${quoteIdent(field)}`);
|
|
46
|
+
columns.push(field);
|
|
47
|
+
}
|
|
48
|
+
return {
|
|
49
|
+
columns,
|
|
50
|
+
selectItems
|
|
51
|
+
};
|
|
52
|
+
}
|
|
53
|
+
function compileProjectionJoins(projection) {
|
|
54
|
+
return projection.joins.map((join) => {
|
|
55
|
+
const keyword = join.type === "inner" ? "INNER JOIN" : "LEFT JOIN";
|
|
56
|
+
const on = join.on.map((c) => `${refSql(c.left)} = ${refSql(c.right)}`).join(" AND ");
|
|
57
|
+
return `${keyword} ${quoteIdent(join.table)} AS ${quoteIdent(join.key)} ON ${on}`;
|
|
58
|
+
});
|
|
59
|
+
}
|
|
60
|
+
/** `FROM <baseTable> AS "base"` — the alias every ref resolves against. */
|
|
61
|
+
function compileProjectionFrom(projection) {
|
|
62
|
+
return `FROM ${quoteIdent(projection.baseTable)} AS ${quoteIdent(BASE_REF)}`;
|
|
63
|
+
}
|
|
64
|
+
//#endregion
|
|
65
|
+
export { quoteIdent as a, compileProjectionSelect as i, compileProjectionIdentity as n, compileProjectionJoins as r, compileProjectionFrom as t };
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
const require_projection = require("./projection-Dz6_i1-w.cjs");
|
|
2
|
+
//#region ../core/src/projection-sql.ts
|
|
3
|
+
/**
|
|
4
|
+
* SQL generation for projection-backed entities.
|
|
5
|
+
*
|
|
6
|
+
* Base and joins are aliased by their ref key (`base`, then each join's `key`),
|
|
7
|
+
* which is what allows the same table to be joined twice and keeps generated
|
|
8
|
+
* SQL independent of host table names.
|
|
9
|
+
*
|
|
10
|
+
* Pure string generation — no DB access. Identifiers are escaped so output is
|
|
11
|
+
* deterministic and injection-safe.
|
|
12
|
+
*/
|
|
13
|
+
/** Quote a single identifier part, escaping embedded double-quotes. */
|
|
14
|
+
function quoteIdent(name) {
|
|
15
|
+
return `"${name.replace(/"/g, "\"\"")}"`;
|
|
16
|
+
}
|
|
17
|
+
function refSql(ref) {
|
|
18
|
+
return `${quoteIdent(ref.table)}.${quoteIdent(ref.column)}`;
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* The identity expression. Composite identities concatenate their parts with
|
|
22
|
+
* `::`; validation guarantees every part is NOT NULL and non-text, which is
|
|
23
|
+
* what makes the concatenation collision-free.
|
|
24
|
+
*
|
|
25
|
+
* Exported unaliased because two paths need the same expression under different
|
|
26
|
+
* names: the view compiler aliases it `id`, and the SDK's projection push source
|
|
27
|
+
* also orders and keyset-paginates by it. Sharing one definition is what keeps
|
|
28
|
+
* a pushed row's `id` identical to the one the view would have produced.
|
|
29
|
+
*/
|
|
30
|
+
function compileProjectionIdentity(projection, basePkColumn) {
|
|
31
|
+
const refs = require_projection.identityRefs(projection.identity, basePkColumn);
|
|
32
|
+
if (projection.identity.kind === "composite") return `CONCAT_WS('::', ${refs.map((ref) => `${refSql(ref)}::text`).join(", ")})`;
|
|
33
|
+
const [ref] = refs;
|
|
34
|
+
if (!ref) throw new Error("projection identity resolved to no column");
|
|
35
|
+
return refSql(ref);
|
|
36
|
+
}
|
|
37
|
+
/** The identity expression, aliased as `id`. */
|
|
38
|
+
function identitySql(projection, basePkColumn) {
|
|
39
|
+
return `${compileProjectionIdentity(projection, basePkColumn)} AS ${quoteIdent("id")}`;
|
|
40
|
+
}
|
|
41
|
+
function compileProjectionSelect(projection, basePkColumn) {
|
|
42
|
+
const selectItems = [identitySql(projection, basePkColumn)];
|
|
43
|
+
const columns = ["id"];
|
|
44
|
+
for (const [field, binding] of Object.entries(projection.fieldBindings)) {
|
|
45
|
+
selectItems.push(`${refSql(binding.from)} AS ${quoteIdent(field)}`);
|
|
46
|
+
columns.push(field);
|
|
47
|
+
}
|
|
48
|
+
return {
|
|
49
|
+
columns,
|
|
50
|
+
selectItems
|
|
51
|
+
};
|
|
52
|
+
}
|
|
53
|
+
function compileProjectionJoins(projection) {
|
|
54
|
+
return projection.joins.map((join) => {
|
|
55
|
+
const keyword = join.type === "inner" ? "INNER JOIN" : "LEFT JOIN";
|
|
56
|
+
const on = join.on.map((c) => `${refSql(c.left)} = ${refSql(c.right)}`).join(" AND ");
|
|
57
|
+
return `${keyword} ${quoteIdent(join.table)} AS ${quoteIdent(join.key)} ON ${on}`;
|
|
58
|
+
});
|
|
59
|
+
}
|
|
60
|
+
/** `FROM <baseTable> AS "base"` — the alias every ref resolves against. */
|
|
61
|
+
function compileProjectionFrom(projection) {
|
|
62
|
+
return `FROM ${quoteIdent(projection.baseTable)} AS ${quoteIdent(require_projection.BASE_REF)}`;
|
|
63
|
+
}
|
|
64
|
+
//#endregion
|
|
65
|
+
Object.defineProperty(exports, "compileProjectionFrom", {
|
|
66
|
+
enumerable: true,
|
|
67
|
+
get: function() {
|
|
68
|
+
return compileProjectionFrom;
|
|
69
|
+
}
|
|
70
|
+
});
|
|
71
|
+
Object.defineProperty(exports, "compileProjectionIdentity", {
|
|
72
|
+
enumerable: true,
|
|
73
|
+
get: function() {
|
|
74
|
+
return compileProjectionIdentity;
|
|
75
|
+
}
|
|
76
|
+
});
|
|
77
|
+
Object.defineProperty(exports, "compileProjectionJoins", {
|
|
78
|
+
enumerable: true,
|
|
79
|
+
get: function() {
|
|
80
|
+
return compileProjectionJoins;
|
|
81
|
+
}
|
|
82
|
+
});
|
|
83
|
+
Object.defineProperty(exports, "compileProjectionSelect", {
|
|
84
|
+
enumerable: true,
|
|
85
|
+
get: function() {
|
|
86
|
+
return compileProjectionSelect;
|
|
87
|
+
}
|
|
88
|
+
});
|
|
89
|
+
Object.defineProperty(exports, "quoteIdent", {
|
|
90
|
+
enumerable: true,
|
|
91
|
+
get: function() {
|
|
92
|
+
return quoteIdent;
|
|
93
|
+
}
|
|
94
|
+
});
|