clivly 0.9.0 → 0.9.1
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.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 +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 +2 -1
- package/core-view-compiler.d.cts +2 -2
- package/core-view-compiler.d.mts +2 -2
- package/core-view-compiler.mjs +2 -2
- package/core.cjs +5 -5
- package/core.d.cts +6 -6
- package/core.d.mts +6 -6
- package/core.mjs +5 -5
- package/{drizzle-BhN5M9zt.d.cts → drizzle-DooDUGqO.d.mts} +1 -1
- package/{drizzle-kBULBAOa.d.mts → drizzle-jz0lrAgl.d.cts} +1 -1
- package/drizzle.d.cts +2 -2
- package/drizzle.d.mts +2 -2
- package/{entity-config-D3LmzgLb.mjs → entity-config-D08zAeFY.mjs} +47 -2
- package/{entity-config-C4Yf_fPj.d.cts → entity-config-fKQhimtD.d.cts} +144 -2
- package/{entity-config-C4Yf_fPj.d.mts → entity-config-fKQhimtD.d.mts} +144 -2
- package/{entity-config-CsLl-ftC.cjs → entity-config-nuXge6rY.cjs} +52 -1
- package/index.cjs +5 -3
- package/index.mjs +5 -3
- package/{internal-DMySVbM0.mjs → internal-BGVUG312.mjs} +1 -1
- package/{internal-MBkNo3bw.d.mts → internal-BLCK81kB.d.mts} +1 -2
- package/{internal-B8ydhsKd.d.cts → internal-C-YBW2DB.d.cts} +1 -2
- package/{internal-BARjyN4n.cjs → internal-D4HDi2GC.cjs} +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 +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 +2 -1
- package/internal-view-compiler.d.cts +2 -2
- package/internal-view-compiler.d.mts +2 -2
- package/internal-view-compiler.mjs +2 -2
- package/internal.cjs +5 -5
- package/internal.d.cts +6 -6
- package/internal.d.mts +6 -6
- package/internal.mjs +5 -5
- package/{mapping-form-43bwOTat.d.cts → mapping-form-DhY0iFmN.d.cts} +1 -1
- package/{mapping-form-DUvWUYCo.d.mts → mapping-form-Du36VZr1.d.mts} +1 -1
- package/mappings-config-B1qNM8VL.d.cts +47 -0
- package/mappings-config-BChZsany.d.mts +47 -0
- package/{mappings-config-BSSwdHiq.cjs → mappings-config-C8ynKmDK.cjs} +1 -1
- package/{mappings-config-bJQT_gSa.mjs → mappings-config-DNaYGyKN.mjs} +1 -1
- package/{namespace-probe-BSH_p9TK.d.cts → namespace-probe-BkUs8raG.d.mts} +1 -1
- package/{namespace-probe-Dsp5uNkS.d.mts → namespace-probe-aRFmpU85.d.cts} +1 -1
- package/package.json +1 -1
- 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-GNqRB8eS.d.cts → sync-engine-DHQ7rXZe.d.mts} +2 -2
- package/{sync-engine-ZsusW-q_.d.mts → sync-engine-DiPjH53O.d.cts} +2 -2
- package/{sync-engine-Bg6-SznL.mjs → sync-engine-SuxSzbZ4.mjs} +1 -1
- package/{sync-engine-DEJvKw6E.cjs → sync-engine-abE94g6X.cjs} +1 -1
- package/{view-compiler-DplczSjF.cjs → view-compiler-Blu4OXJ7.cjs} +22 -0
- package/{view-compiler-DlTpOfZi.mjs → view-compiler-CQx8TRrW.mjs} +17 -1
- package/{view-compiler-Cin0neDO.d.mts → view-compiler-CcUwzZut.d.mts} +12 -2
- package/{view-compiler-Ll9cbIJz.d.cts → view-compiler-DqAdVxLq.d.cts} +12 -2
- package/vite.d.cts +1 -1
- package/vite.d.mts +1 -1
- package/mappings-config-BpcR8bBo.d.mts +0 -167
- package/mappings-config-xsLMn3I-.d.cts +0 -167
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { b as RelationshipsMap, m as FilterExpr, y as RelationshipVia } from "./entity-config-fKQhimtD.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 {
|
|
1
|
+
import { b as RelationshipsMap, m as FilterExpr, y as RelationshipVia } from "./entity-config-fKQhimtD.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
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import { M as ProjectionMapping, a as ClivlyEntitiesConfig } from "./entity-config-fKQhimtD.cjs";
|
|
2
|
+
//#region ../core/src/mappings-config.d.ts
|
|
3
|
+
/**
|
|
4
|
+
* Mappings → Entity Config bridge.
|
|
5
|
+
*
|
|
6
|
+
* `crm_entity_mappings` rows are the single source of truth for how a host
|
|
7
|
+
* schema maps onto Clivly's CRM concepts. This module compiles those rows into
|
|
8
|
+
* a `ClivlyEntitiesConfig` — the contract the view compiler and sync engine
|
|
9
|
+
* consume — so the persisted mapping and the runtime pipeline never diverge.
|
|
10
|
+
*
|
|
11
|
+
* The row model has no explicit entity-key column (it's keyed by
|
|
12
|
+
* `sourceTable + targetConcept + role`), but the config's `relationships`
|
|
13
|
+
* reference other entities *by key*. This builder therefore derives a stable
|
|
14
|
+
* key per row and resolves each relationship's `entity` reference through the
|
|
15
|
+
* same derivation — so a relationship stored as `entity: "<relatedTable>"`
|
|
16
|
+
* (the shape `mappings.suggest` produces) resolves to the right entity.
|
|
17
|
+
*/
|
|
18
|
+
/**
|
|
19
|
+
* A persisted `crm_entity_mappings` row, narrowed to the columns the builder
|
|
20
|
+
* reads. Structurally compatible with the Drizzle row (jsonb columns typed
|
|
21
|
+
* loosely) so the API layer can pass `db.select()` results straight in.
|
|
22
|
+
*/
|
|
23
|
+
interface EntityMappingRow {
|
|
24
|
+
fieldMap: Record<string, string>;
|
|
25
|
+
filter?: Record<string, unknown> | null;
|
|
26
|
+
/**
|
|
27
|
+
* Advanced mapping: a base table plus explicit joins. When set, this — not
|
|
28
|
+
* `fieldMap` — is the authored source of truth, and `sourceTable` merely
|
|
29
|
+
* mirrors `projection.baseTable`.
|
|
30
|
+
*/
|
|
31
|
+
projection?: ProjectionMapping | null;
|
|
32
|
+
relationships?: Record<string, unknown> | null;
|
|
33
|
+
role?: string | null;
|
|
34
|
+
sourceTable: string;
|
|
35
|
+
status?: string | null;
|
|
36
|
+
targetConcept: string;
|
|
37
|
+
targetObjectTypeId?: string | null;
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* Compile persisted mapping rows into a `ClivlyEntitiesConfig`. Only `active`
|
|
41
|
+
* rows with at least one mapped field are included; disabled/suggested rows and
|
|
42
|
+
* unmapped rows are skipped. Returns `{ entities: {} }` when nothing is
|
|
43
|
+
* eligible — a no-op the view compiler and sync engine both tolerate.
|
|
44
|
+
*/
|
|
45
|
+
declare function mappingsToEntitiesConfig(rows: EntityMappingRow[]): ClivlyEntitiesConfig;
|
|
46
|
+
//#endregion
|
|
47
|
+
export { mappingsToEntitiesConfig as n, EntityMappingRow as t };
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import { M as ProjectionMapping, a as ClivlyEntitiesConfig } from "./entity-config-fKQhimtD.mjs";
|
|
2
|
+
//#region ../core/src/mappings-config.d.ts
|
|
3
|
+
/**
|
|
4
|
+
* Mappings → Entity Config bridge.
|
|
5
|
+
*
|
|
6
|
+
* `crm_entity_mappings` rows are the single source of truth for how a host
|
|
7
|
+
* schema maps onto Clivly's CRM concepts. This module compiles those rows into
|
|
8
|
+
* a `ClivlyEntitiesConfig` — the contract the view compiler and sync engine
|
|
9
|
+
* consume — so the persisted mapping and the runtime pipeline never diverge.
|
|
10
|
+
*
|
|
11
|
+
* The row model has no explicit entity-key column (it's keyed by
|
|
12
|
+
* `sourceTable + targetConcept + role`), but the config's `relationships`
|
|
13
|
+
* reference other entities *by key*. This builder therefore derives a stable
|
|
14
|
+
* key per row and resolves each relationship's `entity` reference through the
|
|
15
|
+
* same derivation — so a relationship stored as `entity: "<relatedTable>"`
|
|
16
|
+
* (the shape `mappings.suggest` produces) resolves to the right entity.
|
|
17
|
+
*/
|
|
18
|
+
/**
|
|
19
|
+
* A persisted `crm_entity_mappings` row, narrowed to the columns the builder
|
|
20
|
+
* reads. Structurally compatible with the Drizzle row (jsonb columns typed
|
|
21
|
+
* loosely) so the API layer can pass `db.select()` results straight in.
|
|
22
|
+
*/
|
|
23
|
+
interface EntityMappingRow {
|
|
24
|
+
fieldMap: Record<string, string>;
|
|
25
|
+
filter?: Record<string, unknown> | null;
|
|
26
|
+
/**
|
|
27
|
+
* Advanced mapping: a base table plus explicit joins. When set, this — not
|
|
28
|
+
* `fieldMap` — is the authored source of truth, and `sourceTable` merely
|
|
29
|
+
* mirrors `projection.baseTable`.
|
|
30
|
+
*/
|
|
31
|
+
projection?: ProjectionMapping | null;
|
|
32
|
+
relationships?: Record<string, unknown> | null;
|
|
33
|
+
role?: string | null;
|
|
34
|
+
sourceTable: string;
|
|
35
|
+
status?: string | null;
|
|
36
|
+
targetConcept: string;
|
|
37
|
+
targetObjectTypeId?: string | null;
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* Compile persisted mapping rows into a `ClivlyEntitiesConfig`. Only `active`
|
|
41
|
+
* rows with at least one mapped field are included; disabled/suggested rows and
|
|
42
|
+
* unmapped rows are skipped. Returns `{ entities: {} }` when nothing is
|
|
43
|
+
* eligible — a no-op the view compiler and sync engine both tolerate.
|
|
44
|
+
*/
|
|
45
|
+
declare function mappingsToEntitiesConfig(rows: EntityMappingRow[]): ClivlyEntitiesConfig;
|
|
46
|
+
//#endregion
|
|
47
|
+
export { mappingsToEntitiesConfig as n, EntityMappingRow as t };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { a as ClivlyEntitiesConfig } from "./entity-config-
|
|
1
|
+
import { a as ClivlyEntitiesConfig } from "./entity-config-fKQhimtD.mjs";
|
|
2
2
|
//#region ../sdk/src/drizzle-meta.d.ts
|
|
3
3
|
declare const DRIZZLE_META: "__clivly_drizzle_source_meta__";
|
|
4
4
|
interface DrizzleSourceMeta {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { a as ClivlyEntitiesConfig } from "./entity-config-
|
|
1
|
+
import { a as ClivlyEntitiesConfig } from "./entity-config-fKQhimtD.cjs";
|
|
2
2
|
//#region ../sdk/src/drizzle-meta.d.ts
|
|
3
3
|
declare const DRIZZLE_META: "__clivly_drizzle_source_meta__";
|
|
4
4
|
interface DrizzleSourceMeta {
|
package/package.json
CHANGED
package/sdk.cjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
-
const require_entity_config = require("./entity-config-
|
|
2
|
+
const require_entity_config = require("./entity-config-nuXge6rY.cjs");
|
|
3
3
|
const require_sdk = require("./sdk-Bj-ZDf4u.cjs");
|
|
4
4
|
exports.ClivlyAuthError = require_sdk.ClivlyAuthError;
|
|
5
5
|
exports.ClivlyError = require_sdk.ClivlyError;
|
package/sdk.d.cts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { a as ClivlyEntitiesConfig,
|
|
2
|
-
import { a as ClivlyConnectResult, c as ClivlyUser, d as DiscoveredTable, f as DoctorCheck, i as ClivlyConnectReason, l as CreateChatSessionHandlerOptions, n as ChatSessionRequestBody, o as ClivlySDK, p as DoctorReport, r as ChatWidgetVisitor, s as ClivlySDKConfig, u as CursorStore } from "./namespace-probe-
|
|
1
|
+
import { a as ClivlyEntitiesConfig, x as defineClivlyConfig } from "./entity-config-fKQhimtD.cjs";
|
|
2
|
+
import { a as ClivlyConnectResult, c as ClivlyUser, d as DiscoveredTable, f as DoctorCheck, i as ClivlyConnectReason, l as CreateChatSessionHandlerOptions, n as ChatSessionRequestBody, o as ClivlySDK, p as DoctorReport, r as ChatWidgetVisitor, s as ClivlySDKConfig, u as CursorStore } from "./namespace-probe-aRFmpU85.cjs";
|
|
3
3
|
//#region ../sdk/src/chat-session.d.ts
|
|
4
4
|
declare function createChatSessionHandler({ allowedOrigins, apiKey, apiUrl, fetchImpl, resolveUser }: CreateChatSessionHandlerOptions): (request: Request) => Promise<Response>;
|
|
5
5
|
//#endregion
|
package/sdk.d.mts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { a as ClivlyEntitiesConfig,
|
|
2
|
-
import { a as ClivlyConnectResult, c as ClivlyUser, d as DiscoveredTable, f as DoctorCheck, i as ClivlyConnectReason, l as CreateChatSessionHandlerOptions, n as ChatSessionRequestBody, o as ClivlySDK, p as DoctorReport, r as ChatWidgetVisitor, s as ClivlySDKConfig, u as CursorStore } from "./namespace-probe-
|
|
1
|
+
import { a as ClivlyEntitiesConfig, x as defineClivlyConfig } from "./entity-config-fKQhimtD.mjs";
|
|
2
|
+
import { a as ClivlyConnectResult, c as ClivlyUser, d as DiscoveredTable, f as DoctorCheck, i as ClivlyConnectReason, l as CreateChatSessionHandlerOptions, n as ChatSessionRequestBody, o as ClivlySDK, p as DoctorReport, r as ChatWidgetVisitor, s as ClivlySDKConfig, u as CursorStore } from "./namespace-probe-BkUs8raG.mjs";
|
|
3
3
|
//#region ../sdk/src/chat-session.d.ts
|
|
4
4
|
declare function createChatSessionHandler({ allowedOrigins, apiKey, apiUrl, fetchImpl, resolveUser }: CreateChatSessionHandlerOptions): (request: Request) => Promise<Response>;
|
|
5
5
|
//#endregion
|
package/sdk.mjs
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import { o as defineClivlyConfig } from "./entity-config-
|
|
1
|
+
import { o as defineClivlyConfig } from "./entity-config-D08zAeFY.mjs";
|
|
2
2
|
import { a as ClivlyRateLimitError, i as ClivlyNetworkError, n as ClivlyAuthError, o as createChatSessionHandler, r as ClivlyError, t as createClivlySDK } from "./sdk-BvRD2jAp.mjs";
|
|
3
3
|
export { ClivlyAuthError, ClivlyError, ClivlyNetworkError, ClivlyRateLimitError, createChatSessionHandler, createClivlySDK, defineClivlyConfig };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { a as ClivlyEntitiesConfig } from "./entity-config-
|
|
2
|
-
import { n as CompiledView, t as CompileOptions } from "./view-compiler-
|
|
1
|
+
import { a as ClivlyEntitiesConfig } from "./entity-config-fKQhimtD.mjs";
|
|
2
|
+
import { n as CompiledView, t as CompileOptions } from "./view-compiler-CcUwzZut.mjs";
|
|
3
3
|
//#region ../core/src/sync-engine.d.ts
|
|
4
4
|
/**
|
|
5
5
|
* Sync engine (Phase 3) — materializes the read-only entity views into Clivly's
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { a as ClivlyEntitiesConfig } from "./entity-config-
|
|
2
|
-
import { n as CompiledView, t as CompileOptions } from "./view-compiler-
|
|
1
|
+
import { a as ClivlyEntitiesConfig } from "./entity-config-fKQhimtD.cjs";
|
|
2
|
+
import { n as CompiledView, t as CompileOptions } from "./view-compiler-DqAdVxLq.cjs";
|
|
3
3
|
//#region ../core/src/sync-engine.d.ts
|
|
4
4
|
/**
|
|
5
5
|
* Sync engine (Phase 3) — materializes the read-only entity views into Clivly's
|
|
@@ -186,6 +186,22 @@ function legacyJoins(config, entity, columns, selectItems) {
|
|
|
186
186
|
}
|
|
187
187
|
return joins;
|
|
188
188
|
}
|
|
189
|
+
/**
|
|
190
|
+
* Translate a driver error from executing a compiled view into something
|
|
191
|
+
* actionable, or `undefined` when it is not one we recognise (caller rethrows).
|
|
192
|
+
*
|
|
193
|
+
* The case that matters: `WITH (security_invoker = true)` needs Postgres 15,
|
|
194
|
+
* and PG 14 rejects it with sqlstate 22023 naming a Postgres internal
|
|
195
|
+
* (`reloptions.c`) — no mention of Clivly, the option, or the version. The
|
|
196
|
+
* compiler cannot catch this itself because the host executes the SQL.
|
|
197
|
+
*/
|
|
198
|
+
function explainViewExecutionError(error) {
|
|
199
|
+
if (typeof error !== "object" || error === null) return;
|
|
200
|
+
const { code, routine } = error;
|
|
201
|
+
const message = error instanceof Error ? error.message : "";
|
|
202
|
+
if (!(code === "22023" && (routine === "parseRelOptionsInternal" || message.includes("security_invoker")))) return;
|
|
203
|
+
return "CREATE VIEW … WITH (security_invoker = true) requires Postgres 15+. Pass `securityInvoker: false` to compile without it — but note the view then runs with its owner's privileges instead of the querying role's, which bypasses row-level security (RLS) on the underlying tables. Prefer upgrading Postgres if you rely on RLS to separate tenants.";
|
|
204
|
+
}
|
|
189
205
|
function compileEntityView(config, entityKey, options = {}) {
|
|
190
206
|
const entity = config.entities[entityKey];
|
|
191
207
|
if (!entity) throw new Error(`entity "${entityKey}" is not defined`);
|
|
@@ -275,3 +291,9 @@ Object.defineProperty(exports, "explainEntitiesConfig", {
|
|
|
275
291
|
return explainEntitiesConfig;
|
|
276
292
|
}
|
|
277
293
|
});
|
|
294
|
+
Object.defineProperty(exports, "explainViewExecutionError", {
|
|
295
|
+
enumerable: true,
|
|
296
|
+
get: function() {
|
|
297
|
+
return explainViewExecutionError;
|
|
298
|
+
}
|
|
299
|
+
});
|
|
@@ -186,6 +186,22 @@ function legacyJoins(config, entity, columns, selectItems) {
|
|
|
186
186
|
}
|
|
187
187
|
return joins;
|
|
188
188
|
}
|
|
189
|
+
/**
|
|
190
|
+
* Translate a driver error from executing a compiled view into something
|
|
191
|
+
* actionable, or `undefined` when it is not one we recognise (caller rethrows).
|
|
192
|
+
*
|
|
193
|
+
* The case that matters: `WITH (security_invoker = true)` needs Postgres 15,
|
|
194
|
+
* and PG 14 rejects it with sqlstate 22023 naming a Postgres internal
|
|
195
|
+
* (`reloptions.c`) — no mention of Clivly, the option, or the version. The
|
|
196
|
+
* compiler cannot catch this itself because the host executes the SQL.
|
|
197
|
+
*/
|
|
198
|
+
function explainViewExecutionError(error) {
|
|
199
|
+
if (typeof error !== "object" || error === null) return;
|
|
200
|
+
const { code, routine } = error;
|
|
201
|
+
const message = error instanceof Error ? error.message : "";
|
|
202
|
+
if (!(code === "22023" && (routine === "parseRelOptionsInternal" || message.includes("security_invoker")))) return;
|
|
203
|
+
return "CREATE VIEW … WITH (security_invoker = true) requires Postgres 15+. Pass `securityInvoker: false` to compile without it — but note the view then runs with its owner's privileges instead of the querying role's, which bypasses row-level security (RLS) on the underlying tables. Prefer upgrading Postgres if you rely on RLS to separate tenants.";
|
|
204
|
+
}
|
|
189
205
|
function compileEntityView(config, entityKey, options = {}) {
|
|
190
206
|
const entity = config.entities[entityKey];
|
|
191
207
|
if (!entity) throw new Error(`entity "${entityKey}" is not defined`);
|
|
@@ -251,4 +267,4 @@ async function explainEntitiesConfig(config, run, options = {}) {
|
|
|
251
267
|
return results;
|
|
252
268
|
}
|
|
253
269
|
//#endregion
|
|
254
|
-
export { explainEntitiesConfig as i, compileEntityView as n, compileEntityViews as r, DEFAULT_VIEW_PREFIX as t };
|
|
270
|
+
export { explainViewExecutionError as a, explainEntitiesConfig as i, compileEntityView as n, compileEntityViews as r, DEFAULT_VIEW_PREFIX as t };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { a as ClivlyEntitiesConfig } from "./entity-config-
|
|
1
|
+
import { a as ClivlyEntitiesConfig } from "./entity-config-fKQhimtD.mjs";
|
|
2
2
|
//#region ../core/src/view-compiler.d.ts
|
|
3
3
|
declare const DEFAULT_VIEW_PREFIX = "crm_src_";
|
|
4
4
|
interface CompileOptions {
|
|
@@ -43,6 +43,16 @@ interface CompiledView {
|
|
|
43
43
|
sql: string;
|
|
44
44
|
viewName: string;
|
|
45
45
|
}
|
|
46
|
+
/**
|
|
47
|
+
* Translate a driver error from executing a compiled view into something
|
|
48
|
+
* actionable, or `undefined` when it is not one we recognise (caller rethrows).
|
|
49
|
+
*
|
|
50
|
+
* The case that matters: `WITH (security_invoker = true)` needs Postgres 15,
|
|
51
|
+
* and PG 14 rejects it with sqlstate 22023 naming a Postgres internal
|
|
52
|
+
* (`reloptions.c`) — no mention of Clivly, the option, or the version. The
|
|
53
|
+
* compiler cannot catch this itself because the host executes the SQL.
|
|
54
|
+
*/
|
|
55
|
+
declare function explainViewExecutionError(error: unknown): string | undefined;
|
|
46
56
|
declare function compileEntityView(config: ClivlyEntitiesConfig, entityKey: string, options?: CompileOptions): CompiledView;
|
|
47
57
|
/** Compile every entity in the config into its view, in declaration order. */
|
|
48
58
|
declare function compileEntityViews(config: ClivlyEntitiesConfig, options?: CompileOptions): CompiledView[];
|
|
@@ -68,4 +78,4 @@ interface ExplainResult {
|
|
|
68
78
|
*/
|
|
69
79
|
declare function explainEntitiesConfig(config: ClivlyEntitiesConfig, run: (sql: string) => Promise<unknown>, options?: CompileOptions): Promise<ExplainResult[]>;
|
|
70
80
|
//#endregion
|
|
71
|
-
export { compileEntityView as a, ExplainResult as i, CompiledView as n, compileEntityViews as o, DEFAULT_VIEW_PREFIX as r, explainEntitiesConfig as s, CompileOptions as t };
|
|
81
|
+
export { compileEntityView as a, explainViewExecutionError as c, ExplainResult as i, CompiledView as n, compileEntityViews as o, DEFAULT_VIEW_PREFIX as r, explainEntitiesConfig as s, CompileOptions as t };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { a as ClivlyEntitiesConfig } from "./entity-config-
|
|
1
|
+
import { a as ClivlyEntitiesConfig } from "./entity-config-fKQhimtD.cjs";
|
|
2
2
|
//#region ../core/src/view-compiler.d.ts
|
|
3
3
|
declare const DEFAULT_VIEW_PREFIX = "crm_src_";
|
|
4
4
|
interface CompileOptions {
|
|
@@ -43,6 +43,16 @@ interface CompiledView {
|
|
|
43
43
|
sql: string;
|
|
44
44
|
viewName: string;
|
|
45
45
|
}
|
|
46
|
+
/**
|
|
47
|
+
* Translate a driver error from executing a compiled view into something
|
|
48
|
+
* actionable, or `undefined` when it is not one we recognise (caller rethrows).
|
|
49
|
+
*
|
|
50
|
+
* The case that matters: `WITH (security_invoker = true)` needs Postgres 15,
|
|
51
|
+
* and PG 14 rejects it with sqlstate 22023 naming a Postgres internal
|
|
52
|
+
* (`reloptions.c`) — no mention of Clivly, the option, or the version. The
|
|
53
|
+
* compiler cannot catch this itself because the host executes the SQL.
|
|
54
|
+
*/
|
|
55
|
+
declare function explainViewExecutionError(error: unknown): string | undefined;
|
|
46
56
|
declare function compileEntityView(config: ClivlyEntitiesConfig, entityKey: string, options?: CompileOptions): CompiledView;
|
|
47
57
|
/** Compile every entity in the config into its view, in declaration order. */
|
|
48
58
|
declare function compileEntityViews(config: ClivlyEntitiesConfig, options?: CompileOptions): CompiledView[];
|
|
@@ -68,4 +78,4 @@ interface ExplainResult {
|
|
|
68
78
|
*/
|
|
69
79
|
declare function explainEntitiesConfig(config: ClivlyEntitiesConfig, run: (sql: string) => Promise<unknown>, options?: CompileOptions): Promise<ExplainResult[]>;
|
|
70
80
|
//#endregion
|
|
71
|
-
export { compileEntityView as a, ExplainResult as i, CompiledView as n, compileEntityViews as o, DEFAULT_VIEW_PREFIX as r, explainEntitiesConfig as s, CompileOptions as t };
|
|
81
|
+
export { compileEntityView as a, explainViewExecutionError as c, ExplainResult as i, CompiledView as n, compileEntityViews as o, DEFAULT_VIEW_PREFIX as r, explainEntitiesConfig as s, CompileOptions as t };
|
package/vite.d.cts
CHANGED
package/vite.d.mts
CHANGED
|
@@ -1,167 +0,0 @@
|
|
|
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 };
|