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
|
@@ -1,3 +1,58 @@
|
|
|
1
|
+
import { r as identityRefs, t as BASE_REF } from "./projection-D7xmQP4S.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, aliased as `id`. Composite identities concatenate
|
|
22
|
+
* their parts with `::`; validation guarantees every part is NOT NULL and
|
|
23
|
+
* non-text, which is what makes the concatenation collision-free.
|
|
24
|
+
*/
|
|
25
|
+
function identitySql(projection, basePkColumn) {
|
|
26
|
+
const refs = identityRefs(projection.identity, basePkColumn);
|
|
27
|
+
if (projection.identity.kind === "composite") return `CONCAT_WS('::', ${refs.map((ref) => `${refSql(ref)}::text`).join(", ")}) AS ${quoteIdent("id")}`;
|
|
28
|
+
const [ref] = refs;
|
|
29
|
+
if (!ref) throw new Error("projection identity resolved to no column");
|
|
30
|
+
return `${refSql(ref)} AS ${quoteIdent("id")}`;
|
|
31
|
+
}
|
|
32
|
+
function compileProjectionSelect(projection, basePkColumn) {
|
|
33
|
+
const selectItems = [identitySql(projection, basePkColumn)];
|
|
34
|
+
const columns = ["id"];
|
|
35
|
+
for (const [field, binding] of Object.entries(projection.fieldBindings)) {
|
|
36
|
+
selectItems.push(`${refSql(binding.from)} AS ${quoteIdent(field)}`);
|
|
37
|
+
columns.push(field);
|
|
38
|
+
}
|
|
39
|
+
return {
|
|
40
|
+
columns,
|
|
41
|
+
selectItems
|
|
42
|
+
};
|
|
43
|
+
}
|
|
44
|
+
function compileProjectionJoins(projection) {
|
|
45
|
+
return projection.joins.map((join) => {
|
|
46
|
+
const keyword = join.type === "inner" ? "INNER JOIN" : "LEFT JOIN";
|
|
47
|
+
const on = join.on.map((c) => `${refSql(c.left)} = ${refSql(c.right)}`).join(" AND ");
|
|
48
|
+
return `${keyword} ${quoteIdent(join.table)} AS ${quoteIdent(join.key)} ON ${on}`;
|
|
49
|
+
});
|
|
50
|
+
}
|
|
51
|
+
/** `FROM <baseTable> AS "base"` — the alias every ref resolves against. */
|
|
52
|
+
function compileProjectionFrom(projection) {
|
|
53
|
+
return `FROM ${quoteIdent(projection.baseTable)} AS ${quoteIdent(BASE_REF)}`;
|
|
54
|
+
}
|
|
55
|
+
//#endregion
|
|
1
56
|
//#region ../core/src/view-compiler.ts
|
|
2
57
|
/**
|
|
3
58
|
* View compiler (Phase 2) — turns a validated entity config into read-only
|
|
@@ -22,10 +77,6 @@
|
|
|
22
77
|
const SOURCE_KEY = "id";
|
|
23
78
|
const DEFAULT_VIEW_PREFIX = "crm_src_";
|
|
24
79
|
const DEFAULT_ROLE = "primary";
|
|
25
|
-
/** Quote a single identifier part, escaping embedded double-quotes. */
|
|
26
|
-
function quoteIdent(name) {
|
|
27
|
-
return `"${name.replace(/"/g, "\"\"")}"`;
|
|
28
|
-
}
|
|
29
80
|
/** Emit a SQL literal for a scalar filter value. */
|
|
30
81
|
function quoteLiteral(value) {
|
|
31
82
|
if (typeof value === "number") return String(value);
|
|
@@ -106,17 +157,24 @@ function compileRelationship(relName, rel, source, related) {
|
|
|
106
157
|
refColumn: refCol
|
|
107
158
|
};
|
|
108
159
|
}
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
if (!entity) throw new Error(`entity "${entityKey}" is not defined`);
|
|
112
|
-
const viewName = `${options.viewPrefix ?? "crm_src_"}${entityKey}`;
|
|
113
|
-
const src = entity.source;
|
|
160
|
+
/** SELECT items for a legacy single-table entity: source key, then fields. */
|
|
161
|
+
function legacySelect(entity, src) {
|
|
114
162
|
const selectItems = [`${quoteIdent(src)}.${quoteIdent(SOURCE_KEY)} AS ${quoteIdent("id")}`];
|
|
115
163
|
const columns = ["id"];
|
|
116
164
|
for (const [field, column] of Object.entries(entity.fields)) {
|
|
117
165
|
selectItems.push(`${quoteIdent(src)}.${quoteIdent(column)} AS ${quoteIdent(field)}`);
|
|
118
166
|
columns.push(field);
|
|
119
167
|
}
|
|
168
|
+
return {
|
|
169
|
+
columns,
|
|
170
|
+
selectItems
|
|
171
|
+
};
|
|
172
|
+
}
|
|
173
|
+
/**
|
|
174
|
+
* Relationship JOINs for a legacy entity. Appends each relationship's ref
|
|
175
|
+
* column to `columns`/`selectItems` in place, preserving the existing order.
|
|
176
|
+
*/
|
|
177
|
+
function legacyJoins(config, entity, columns, selectItems) {
|
|
120
178
|
const joins = [];
|
|
121
179
|
for (const [relName, rel] of Object.entries(entity.relationships ?? {})) {
|
|
122
180
|
const compiled = compileRelationship(relName, rel, entity, config.entities[rel.entity]);
|
|
@@ -126,12 +184,23 @@ function compileEntityView(config, entityKey, options = {}) {
|
|
|
126
184
|
columns.push(compiled.refColumn);
|
|
127
185
|
}
|
|
128
186
|
}
|
|
129
|
-
|
|
130
|
-
|
|
187
|
+
return joins;
|
|
188
|
+
}
|
|
189
|
+
function compileEntityView(config, entityKey, options = {}) {
|
|
190
|
+
const entity = config.entities[entityKey];
|
|
191
|
+
if (!entity) throw new Error(`entity "${entityKey}" is not defined`);
|
|
192
|
+
const viewName = `${options.viewPrefix ?? "crm_src_"}${entityKey}`;
|
|
193
|
+
const src = entity.source;
|
|
194
|
+
const projection = entity.projection;
|
|
195
|
+
const filterTable = projection ? BASE_REF : src;
|
|
196
|
+
const { selectItems, columns } = projection ? compileProjectionSelect(projection, SOURCE_KEY) : legacySelect(entity, src);
|
|
197
|
+
const joins = projection ? compileProjectionJoins(projection) : legacyJoins(config, entity, columns, selectItems);
|
|
198
|
+
const conditions = compileFilterConditions(filterTable, entity.filter);
|
|
199
|
+
if (options.orgScope) conditions.push(`${quoteIdent(filterTable)}.${quoteIdent(options.orgScope.column)} = ${quoteLiteral(options.orgScope.value)}`);
|
|
131
200
|
const lines = [
|
|
132
201
|
options.securityInvoker ?? true ? `CREATE OR REPLACE VIEW ${quoteIdent(viewName)} WITH (security_invoker = true) AS` : `CREATE OR REPLACE VIEW ${quoteIdent(viewName)} AS`,
|
|
133
202
|
`SELECT ${selectItems.join(", ")}`,
|
|
134
|
-
`FROM ${quoteIdent(src)}`,
|
|
203
|
+
projection ? compileProjectionFrom(projection) : `FROM ${quoteIdent(src)}`,
|
|
135
204
|
...joins
|
|
136
205
|
];
|
|
137
206
|
if (conditions.length > 0) lines.push(`WHERE ${conditions.join(" AND ")}`);
|
|
@@ -1,3 +1,58 @@
|
|
|
1
|
+
const require_projection = require("./projection-C5244vGa.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, aliased as `id`. Composite identities concatenate
|
|
22
|
+
* their parts with `::`; validation guarantees every part is NOT NULL and
|
|
23
|
+
* non-text, which is what makes the concatenation collision-free.
|
|
24
|
+
*/
|
|
25
|
+
function identitySql(projection, basePkColumn) {
|
|
26
|
+
const refs = require_projection.identityRefs(projection.identity, basePkColumn);
|
|
27
|
+
if (projection.identity.kind === "composite") return `CONCAT_WS('::', ${refs.map((ref) => `${refSql(ref)}::text`).join(", ")}) AS ${quoteIdent("id")}`;
|
|
28
|
+
const [ref] = refs;
|
|
29
|
+
if (!ref) throw new Error("projection identity resolved to no column");
|
|
30
|
+
return `${refSql(ref)} AS ${quoteIdent("id")}`;
|
|
31
|
+
}
|
|
32
|
+
function compileProjectionSelect(projection, basePkColumn) {
|
|
33
|
+
const selectItems = [identitySql(projection, basePkColumn)];
|
|
34
|
+
const columns = ["id"];
|
|
35
|
+
for (const [field, binding] of Object.entries(projection.fieldBindings)) {
|
|
36
|
+
selectItems.push(`${refSql(binding.from)} AS ${quoteIdent(field)}`);
|
|
37
|
+
columns.push(field);
|
|
38
|
+
}
|
|
39
|
+
return {
|
|
40
|
+
columns,
|
|
41
|
+
selectItems
|
|
42
|
+
};
|
|
43
|
+
}
|
|
44
|
+
function compileProjectionJoins(projection) {
|
|
45
|
+
return projection.joins.map((join) => {
|
|
46
|
+
const keyword = join.type === "inner" ? "INNER JOIN" : "LEFT JOIN";
|
|
47
|
+
const on = join.on.map((c) => `${refSql(c.left)} = ${refSql(c.right)}`).join(" AND ");
|
|
48
|
+
return `${keyword} ${quoteIdent(join.table)} AS ${quoteIdent(join.key)} ON ${on}`;
|
|
49
|
+
});
|
|
50
|
+
}
|
|
51
|
+
/** `FROM <baseTable> AS "base"` — the alias every ref resolves against. */
|
|
52
|
+
function compileProjectionFrom(projection) {
|
|
53
|
+
return `FROM ${quoteIdent(projection.baseTable)} AS ${quoteIdent(require_projection.BASE_REF)}`;
|
|
54
|
+
}
|
|
55
|
+
//#endregion
|
|
1
56
|
//#region ../core/src/view-compiler.ts
|
|
2
57
|
/**
|
|
3
58
|
* View compiler (Phase 2) — turns a validated entity config into read-only
|
|
@@ -22,10 +77,6 @@
|
|
|
22
77
|
const SOURCE_KEY = "id";
|
|
23
78
|
const DEFAULT_VIEW_PREFIX = "crm_src_";
|
|
24
79
|
const DEFAULT_ROLE = "primary";
|
|
25
|
-
/** Quote a single identifier part, escaping embedded double-quotes. */
|
|
26
|
-
function quoteIdent(name) {
|
|
27
|
-
return `"${name.replace(/"/g, "\"\"")}"`;
|
|
28
|
-
}
|
|
29
80
|
/** Emit a SQL literal for a scalar filter value. */
|
|
30
81
|
function quoteLiteral(value) {
|
|
31
82
|
if (typeof value === "number") return String(value);
|
|
@@ -106,17 +157,24 @@ function compileRelationship(relName, rel, source, related) {
|
|
|
106
157
|
refColumn: refCol
|
|
107
158
|
};
|
|
108
159
|
}
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
if (!entity) throw new Error(`entity "${entityKey}" is not defined`);
|
|
112
|
-
const viewName = `${options.viewPrefix ?? "crm_src_"}${entityKey}`;
|
|
113
|
-
const src = entity.source;
|
|
160
|
+
/** SELECT items for a legacy single-table entity: source key, then fields. */
|
|
161
|
+
function legacySelect(entity, src) {
|
|
114
162
|
const selectItems = [`${quoteIdent(src)}.${quoteIdent(SOURCE_KEY)} AS ${quoteIdent("id")}`];
|
|
115
163
|
const columns = ["id"];
|
|
116
164
|
for (const [field, column] of Object.entries(entity.fields)) {
|
|
117
165
|
selectItems.push(`${quoteIdent(src)}.${quoteIdent(column)} AS ${quoteIdent(field)}`);
|
|
118
166
|
columns.push(field);
|
|
119
167
|
}
|
|
168
|
+
return {
|
|
169
|
+
columns,
|
|
170
|
+
selectItems
|
|
171
|
+
};
|
|
172
|
+
}
|
|
173
|
+
/**
|
|
174
|
+
* Relationship JOINs for a legacy entity. Appends each relationship's ref
|
|
175
|
+
* column to `columns`/`selectItems` in place, preserving the existing order.
|
|
176
|
+
*/
|
|
177
|
+
function legacyJoins(config, entity, columns, selectItems) {
|
|
120
178
|
const joins = [];
|
|
121
179
|
for (const [relName, rel] of Object.entries(entity.relationships ?? {})) {
|
|
122
180
|
const compiled = compileRelationship(relName, rel, entity, config.entities[rel.entity]);
|
|
@@ -126,12 +184,23 @@ function compileEntityView(config, entityKey, options = {}) {
|
|
|
126
184
|
columns.push(compiled.refColumn);
|
|
127
185
|
}
|
|
128
186
|
}
|
|
129
|
-
|
|
130
|
-
|
|
187
|
+
return joins;
|
|
188
|
+
}
|
|
189
|
+
function compileEntityView(config, entityKey, options = {}) {
|
|
190
|
+
const entity = config.entities[entityKey];
|
|
191
|
+
if (!entity) throw new Error(`entity "${entityKey}" is not defined`);
|
|
192
|
+
const viewName = `${options.viewPrefix ?? "crm_src_"}${entityKey}`;
|
|
193
|
+
const src = entity.source;
|
|
194
|
+
const projection = entity.projection;
|
|
195
|
+
const filterTable = projection ? require_projection.BASE_REF : src;
|
|
196
|
+
const { selectItems, columns } = projection ? compileProjectionSelect(projection, SOURCE_KEY) : legacySelect(entity, src);
|
|
197
|
+
const joins = projection ? compileProjectionJoins(projection) : legacyJoins(config, entity, columns, selectItems);
|
|
198
|
+
const conditions = compileFilterConditions(filterTable, entity.filter);
|
|
199
|
+
if (options.orgScope) conditions.push(`${quoteIdent(filterTable)}.${quoteIdent(options.orgScope.column)} = ${quoteLiteral(options.orgScope.value)}`);
|
|
131
200
|
const lines = [
|
|
132
201
|
options.securityInvoker ?? true ? `CREATE OR REPLACE VIEW ${quoteIdent(viewName)} WITH (security_invoker = true) AS` : `CREATE OR REPLACE VIEW ${quoteIdent(viewName)} AS`,
|
|
133
202
|
`SELECT ${selectItems.join(", ")}`,
|
|
134
|
-
`FROM ${quoteIdent(src)}`,
|
|
203
|
+
projection ? compileProjectionFrom(projection) : `FROM ${quoteIdent(src)}`,
|
|
135
204
|
...joins
|
|
136
205
|
];
|
|
137
206
|
if (conditions.length > 0) lines.push(`WHERE ${conditions.join(" AND ")}`);
|
package/vite.d.cts
CHANGED
package/vite.d.mts
CHANGED
package/drizzle-B89tLo4T.mjs
DELETED
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
import { Table, getTableColumns, getTableName, is } from "drizzle-orm";
|
|
2
|
-
//#region ../core/src/drizzle.ts
|
|
3
|
-
/**
|
|
4
|
-
* Derive Clivly's discovery shape (table + column names) from a Drizzle schema
|
|
5
|
-
* object — the `* as schema` you pass to `drizzle(client, { schema })`. This
|
|
6
|
-
* delivers the "reads your schema" promise for Drizzle hosts: no hand-authored
|
|
7
|
-
* `DiscoveredTable[]`. Feed the result to the SDK's `schema` option, or diff it
|
|
8
|
-
* against your entity config.
|
|
9
|
-
*
|
|
10
|
-
* Column names are the real database column names (e.g. `full_name`), not the
|
|
11
|
-
* Drizzle property keys (`fullName`). Non-table values in the schema object
|
|
12
|
-
* (relations, enums, helpers) are ignored.
|
|
13
|
-
*
|
|
14
|
-
* `drizzle-orm` is an **optional peer dependency** — you only need it installed
|
|
15
|
-
* when you import this entry (`@clivly/core/drizzle`); the rest of `@clivly/core`
|
|
16
|
-
* stays dependency-free.
|
|
17
|
-
*/
|
|
18
|
-
function discoverFromDrizzle(schema) {
|
|
19
|
-
const tables = [];
|
|
20
|
-
for (const value of Object.values(schema)) {
|
|
21
|
-
if (!is(value, Table)) continue;
|
|
22
|
-
const columns = getTableColumns(value);
|
|
23
|
-
tables.push({
|
|
24
|
-
name: getTableName(value),
|
|
25
|
-
columns: Object.values(columns).map((column) => column.name)
|
|
26
|
-
});
|
|
27
|
-
}
|
|
28
|
-
return tables;
|
|
29
|
-
}
|
|
30
|
-
//#endregion
|
|
31
|
-
export { discoverFromDrizzle as t };
|
package/drizzle-CFOr9dU9.d.mts
DELETED
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
import { u as DiscoveredSchemaTable } from "./entity-config-DoUCXtq5.mjs";
|
|
2
|
-
//#region ../core/src/drizzle.d.ts
|
|
3
|
-
/**
|
|
4
|
-
* Derive Clivly's discovery shape (table + column names) from a Drizzle schema
|
|
5
|
-
* object — the `* as schema` you pass to `drizzle(client, { schema })`. This
|
|
6
|
-
* delivers the "reads your schema" promise for Drizzle hosts: no hand-authored
|
|
7
|
-
* `DiscoveredTable[]`. Feed the result to the SDK's `schema` option, or diff it
|
|
8
|
-
* against your entity config.
|
|
9
|
-
*
|
|
10
|
-
* Column names are the real database column names (e.g. `full_name`), not the
|
|
11
|
-
* Drizzle property keys (`fullName`). Non-table values in the schema object
|
|
12
|
-
* (relations, enums, helpers) are ignored.
|
|
13
|
-
*
|
|
14
|
-
* `drizzle-orm` is an **optional peer dependency** — you only need it installed
|
|
15
|
-
* when you import this entry (`@clivly/core/drizzle`); the rest of `@clivly/core`
|
|
16
|
-
* stays dependency-free.
|
|
17
|
-
*/
|
|
18
|
-
declare function discoverFromDrizzle(schema: Record<string, unknown>): DiscoveredSchemaTable[];
|
|
19
|
-
//#endregion
|
|
20
|
-
export { discoverFromDrizzle as t };
|
package/drizzle-DiReZf6d.cjs
DELETED
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
let drizzle_orm = require("drizzle-orm");
|
|
2
|
-
//#region ../core/src/drizzle.ts
|
|
3
|
-
/**
|
|
4
|
-
* Derive Clivly's discovery shape (table + column names) from a Drizzle schema
|
|
5
|
-
* object — the `* as schema` you pass to `drizzle(client, { schema })`. This
|
|
6
|
-
* delivers the "reads your schema" promise for Drizzle hosts: no hand-authored
|
|
7
|
-
* `DiscoveredTable[]`. Feed the result to the SDK's `schema` option, or diff it
|
|
8
|
-
* against your entity config.
|
|
9
|
-
*
|
|
10
|
-
* Column names are the real database column names (e.g. `full_name`), not the
|
|
11
|
-
* Drizzle property keys (`fullName`). Non-table values in the schema object
|
|
12
|
-
* (relations, enums, helpers) are ignored.
|
|
13
|
-
*
|
|
14
|
-
* `drizzle-orm` is an **optional peer dependency** — you only need it installed
|
|
15
|
-
* when you import this entry (`@clivly/core/drizzle`); the rest of `@clivly/core`
|
|
16
|
-
* stays dependency-free.
|
|
17
|
-
*/
|
|
18
|
-
function discoverFromDrizzle(schema) {
|
|
19
|
-
const tables = [];
|
|
20
|
-
for (const value of Object.values(schema)) {
|
|
21
|
-
if (!(0, drizzle_orm.is)(value, drizzle_orm.Table)) continue;
|
|
22
|
-
const columns = (0, drizzle_orm.getTableColumns)(value);
|
|
23
|
-
tables.push({
|
|
24
|
-
name: (0, drizzle_orm.getTableName)(value),
|
|
25
|
-
columns: Object.values(columns).map((column) => column.name)
|
|
26
|
-
});
|
|
27
|
-
}
|
|
28
|
-
return tables;
|
|
29
|
-
}
|
|
30
|
-
//#endregion
|
|
31
|
-
Object.defineProperty(exports, "discoverFromDrizzle", {
|
|
32
|
-
enumerable: true,
|
|
33
|
-
get: function() {
|
|
34
|
-
return discoverFromDrizzle;
|
|
35
|
-
}
|
|
36
|
-
});
|
package/drizzle-DmeKSqeF.d.cts
DELETED
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
import { u as DiscoveredSchemaTable } from "./entity-config-DoUCXtq5.cjs";
|
|
2
|
-
//#region ../core/src/drizzle.d.ts
|
|
3
|
-
/**
|
|
4
|
-
* Derive Clivly's discovery shape (table + column names) from a Drizzle schema
|
|
5
|
-
* object — the `* as schema` you pass to `drizzle(client, { schema })`. This
|
|
6
|
-
* delivers the "reads your schema" promise for Drizzle hosts: no hand-authored
|
|
7
|
-
* `DiscoveredTable[]`. Feed the result to the SDK's `schema` option, or diff it
|
|
8
|
-
* against your entity config.
|
|
9
|
-
*
|
|
10
|
-
* Column names are the real database column names (e.g. `full_name`), not the
|
|
11
|
-
* Drizzle property keys (`fullName`). Non-table values in the schema object
|
|
12
|
-
* (relations, enums, helpers) are ignored.
|
|
13
|
-
*
|
|
14
|
-
* `drizzle-orm` is an **optional peer dependency** — you only need it installed
|
|
15
|
-
* when you import this entry (`@clivly/core/drizzle`); the rest of `@clivly/core`
|
|
16
|
-
* stays dependency-free.
|
|
17
|
-
*/
|
|
18
|
-
declare function discoverFromDrizzle(schema: Record<string, unknown>): DiscoveredSchemaTable[];
|
|
19
|
-
//#endregion
|
|
20
|
-
export { discoverFromDrizzle as t };
|
|
@@ -1,41 +0,0 @@
|
|
|
1
|
-
import { a as ClivlyEntitiesConfig } from "./entity-config-DoUCXtq5.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
|
-
relationships?: Record<string, unknown> | null;
|
|
27
|
-
role?: string | null;
|
|
28
|
-
sourceTable: string;
|
|
29
|
-
status?: string | null;
|
|
30
|
-
targetConcept: string;
|
|
31
|
-
targetObjectTypeId?: string | null;
|
|
32
|
-
}
|
|
33
|
-
/**
|
|
34
|
-
* Compile persisted mapping rows into a `ClivlyEntitiesConfig`. Only `active`
|
|
35
|
-
* rows with at least one mapped field are included; disabled/suggested rows and
|
|
36
|
-
* unmapped rows are skipped. Returns `{ entities: {} }` when nothing is
|
|
37
|
-
* eligible — a no-op the view compiler and sync engine both tolerate.
|
|
38
|
-
*/
|
|
39
|
-
declare function mappingsToEntitiesConfig(rows: EntityMappingRow[]): ClivlyEntitiesConfig;
|
|
40
|
-
//#endregion
|
|
41
|
-
export { mappingsToEntitiesConfig as n, EntityMappingRow as t };
|
|
@@ -1,41 +0,0 @@
|
|
|
1
|
-
import { a as ClivlyEntitiesConfig } from "./entity-config-DoUCXtq5.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
|
-
relationships?: Record<string, unknown> | null;
|
|
27
|
-
role?: string | null;
|
|
28
|
-
sourceTable: string;
|
|
29
|
-
status?: string | null;
|
|
30
|
-
targetConcept: string;
|
|
31
|
-
targetObjectTypeId?: string | null;
|
|
32
|
-
}
|
|
33
|
-
/**
|
|
34
|
-
* Compile persisted mapping rows into a `ClivlyEntitiesConfig`. Only `active`
|
|
35
|
-
* rows with at least one mapped field are included; disabled/suggested rows and
|
|
36
|
-
* unmapped rows are skipped. Returns `{ entities: {} }` when nothing is
|
|
37
|
-
* eligible — a no-op the view compiler and sync engine both tolerate.
|
|
38
|
-
*/
|
|
39
|
-
declare function mappingsToEntitiesConfig(rows: EntityMappingRow[]): ClivlyEntitiesConfig;
|
|
40
|
-
//#endregion
|
|
41
|
-
export { mappingsToEntitiesConfig as n, EntityMappingRow as t };
|