@clivly/core 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/README.md +88 -3
- package/dist/drizzle.d.cts +1 -1
- package/dist/drizzle.d.mts +1 -1
- package/dist/{entity-config-Tb5bbKLj.mjs → entity-config-8Fgr6IOH.mjs} +47 -2
- package/dist/entity-config-CLxI8dVb.d.cts +556 -0
- package/dist/entity-config-CLxI8dVb.d.mts +556 -0
- package/dist/{entity-config-PoOGzvpN.cjs → entity-config-Dh8aEcgj.cjs} +52 -1
- package/dist/entity-config.cjs +2 -1
- package/dist/entity-config.d.cts +2 -414
- package/dist/entity-config.d.mts +2 -414
- package/dist/entity-config.mjs +2 -2
- package/dist/entity-heuristics.cjs +1 -1
- package/dist/entity-heuristics.d.cts +1 -1
- package/dist/entity-heuristics.d.mts +1 -1
- package/dist/entity-heuristics.mjs +1 -1
- package/dist/index.cjs +2 -2
- package/dist/index.d.cts +2 -2
- package/dist/index.d.mts +2 -2
- package/dist/index.mjs +2 -2
- package/dist/mapping-form.d.cts +1 -1
- package/dist/mapping-form.d.mts +1 -1
- package/dist/mappings-config.cjs +1 -1
- package/dist/mappings-config.d.cts +46 -1
- package/dist/mappings-config.d.mts +46 -1
- package/dist/mappings-config.mjs +1 -1
- package/dist/sync-engine.cjs +1 -1
- package/dist/sync-engine.d.cts +1 -1
- package/dist/sync-engine.d.mts +1 -1
- package/dist/sync-engine.mjs +1 -1
- package/dist/{view-compiler-BwZ9UgLp.cjs → view-compiler-BpNI8Ttw.cjs} +22 -0
- package/dist/{view-compiler-BKrBA_II.mjs → view-compiler-CcqsGxv4.mjs} +17 -1
- package/dist/view-compiler.cjs +2 -1
- package/dist/view-compiler.d.cts +12 -2
- package/dist/view-compiler.d.mts +12 -2
- package/dist/view-compiler.mjs +2 -2
- package/package.json +1 -1
- package/dist/mappings-config-B0W5bVZj.d.mts +0 -168
- package/dist/mappings-config-BWo4cRDF.d.cts +0 -168
package/dist/entity-config.d.mts
CHANGED
|
@@ -1,414 +1,2 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* Entity Config v2 — the declarative contract that turns Clivly's "schema-aware"
|
|
5
|
-
* promise into a real capability.
|
|
6
|
-
*
|
|
7
|
-
* A CRM entity is no longer a flat table name. It is a *derived entity*: a
|
|
8
|
-
* filtered slice of a host table (`source` + `filter`), a column allowlist
|
|
9
|
-
* (`fields` + `readOnly`), and declared `relationships` to other entities. The
|
|
10
|
-
* same host table can back several entities (e.g. `users` → owners + members)
|
|
11
|
-
* distinguished by `role`.
|
|
12
|
-
*
|
|
13
|
-
* This module is the Phase 1 slice: types, schema, `defineClivlyConfig` (a
|
|
14
|
-
* structural helper) and `validateEntitiesConfig` (semantic validation against
|
|
15
|
-
* the host's discovered schema). It performs NO DB access and generates no SQL —
|
|
16
|
-
* the view compiler (Phase 2) and sync engine (Phase 3) consume this contract.
|
|
17
|
-
*/
|
|
18
|
-
/** Canonical CRM concepts a host entity can map onto. */
|
|
19
|
-
declare const CRM_CONCEPTS: readonly ["contact", "company", "deal", "activity", "conversation", "note"];
|
|
20
|
-
type CrmConcept = (typeof CRM_CONCEPTS)[number];
|
|
21
|
-
/**
|
|
22
|
-
* The canonical `fields` keys the mirror actually persists, per concept — the
|
|
23
|
-
* crm_* columns the sync store writes. An entity's `fields` map keys must be one
|
|
24
|
-
* of these: a non-canonical key (e.g. `fullName` instead of `name`) validates
|
|
25
|
-
* structurally but has no destination column, so the store silently writes an
|
|
26
|
-
* empty value. `validateEntitiesConfig` flags those.
|
|
27
|
-
*
|
|
28
|
-
* This is the single source of truth — the Drizzle store imports it, so the
|
|
29
|
-
* two can't drift (the drift is what made the silent-data-loss trap possible).
|
|
30
|
-
* Concepts absent here aren't materialized yet, so their field keys are
|
|
31
|
-
* unconstrained.
|
|
32
|
-
*/
|
|
33
|
-
declare const CANONICAL_FIELDS: {
|
|
34
|
-
readonly contact: readonly ["name", "email", "title", "status"];
|
|
35
|
-
readonly company: readonly ["name", "domain", "industry", "size"];
|
|
36
|
-
readonly deal: readonly ["name", "value", "stage"];
|
|
37
|
-
};
|
|
38
|
-
/**
|
|
39
|
-
* The concepts the mapping→sync pipeline can actually materialize into `crm_*`
|
|
40
|
-
* tables. These are exactly the CANONICAL_FIELDS keys — the Drizzle sync store's
|
|
41
|
-
* `persist()` throws for any other concept, so offering one (in the mapping
|
|
42
|
-
* editor, in suggestions, or via the upsert API) is a broken affordance.
|
|
43
|
-
*
|
|
44
|
-
* The broader CRM_CONCEPTS set still validates structurally, so previously
|
|
45
|
-
* stored rows for not-yet-materialized concepts keep rendering. When a concept
|
|
46
|
-
* gains a sync-store path, add its canonical fields above and it joins this set
|
|
47
|
-
* automatically (guarded by the MATERIALIZING_CONCEPTS drift test).
|
|
48
|
-
*/
|
|
49
|
-
declare const MATERIALIZING_CONCEPTS: readonly ["contact", "company", "deal"];
|
|
50
|
-
type MaterializingConcept = (typeof MATERIALIZING_CONCEPTS)[number];
|
|
51
|
-
/**
|
|
52
|
-
* The org-defined custom-object target. Deliberately NOT a member of
|
|
53
|
-
* CRM_CONCEPTS / CANONICAL_FIELDS / MATERIALIZING_CONCEPTS — a custom object has
|
|
54
|
-
* no fixed canonical columns; its mapping's fieldMap keys ARE its properties.
|
|
55
|
-
* Handled as an explicit branch wherever concepts are switched on, so the
|
|
56
|
-
* canonical-concept invariants (and their drift test) stay intact.
|
|
57
|
-
*/
|
|
58
|
-
declare const CUSTOM_CONCEPT: "custom";
|
|
59
|
-
declare const filterValueSchema: z.ZodUnion<readonly [z.ZodString, z.ZodNumber, z.ZodBoolean, z.ZodUnion<readonly [z.ZodObject<{
|
|
60
|
-
eq: z.ZodUnion<readonly [z.ZodString, z.ZodNumber, z.ZodBoolean]>;
|
|
61
|
-
}, z.core.$strict>, z.ZodObject<{
|
|
62
|
-
ne: z.ZodUnion<readonly [z.ZodString, z.ZodNumber, z.ZodBoolean]>;
|
|
63
|
-
}, z.core.$strict>, z.ZodObject<{
|
|
64
|
-
in: z.ZodArray<z.ZodUnion<readonly [z.ZodString, z.ZodNumber, z.ZodBoolean]>>;
|
|
65
|
-
}, z.core.$strict>, z.ZodObject<{
|
|
66
|
-
notIn: z.ZodArray<z.ZodUnion<readonly [z.ZodString, z.ZodNumber, z.ZodBoolean]>>;
|
|
67
|
-
}, z.core.$strict>, z.ZodObject<{
|
|
68
|
-
isNull: z.ZodLiteral<true>;
|
|
69
|
-
}, z.core.$strict>, z.ZodObject<{
|
|
70
|
-
isNotNull: z.ZodLiteral<true>;
|
|
71
|
-
}, z.core.$strict>]>]>;
|
|
72
|
-
/** `$raw` is a reserved key; a column literally named `$raw` is not addressable. */
|
|
73
|
-
declare const filterSchema: z.ZodUnion<readonly [z.ZodObject<{
|
|
74
|
-
$raw: z.ZodString;
|
|
75
|
-
}, z.core.$strict>, z.ZodRecord<z.ZodString, z.ZodUnion<readonly [z.ZodString, z.ZodNumber, z.ZodBoolean, z.ZodUnion<readonly [z.ZodObject<{
|
|
76
|
-
eq: z.ZodUnion<readonly [z.ZodString, z.ZodNumber, z.ZodBoolean]>;
|
|
77
|
-
}, z.core.$strict>, z.ZodObject<{
|
|
78
|
-
ne: z.ZodUnion<readonly [z.ZodString, z.ZodNumber, z.ZodBoolean]>;
|
|
79
|
-
}, z.core.$strict>, z.ZodObject<{
|
|
80
|
-
in: z.ZodArray<z.ZodUnion<readonly [z.ZodString, z.ZodNumber, z.ZodBoolean]>>;
|
|
81
|
-
}, z.core.$strict>, z.ZodObject<{
|
|
82
|
-
notIn: z.ZodArray<z.ZodUnion<readonly [z.ZodString, z.ZodNumber, z.ZodBoolean]>>;
|
|
83
|
-
}, z.core.$strict>, z.ZodObject<{
|
|
84
|
-
isNull: z.ZodLiteral<true>;
|
|
85
|
-
}, z.core.$strict>, z.ZodObject<{
|
|
86
|
-
isNotNull: z.ZodLiteral<true>;
|
|
87
|
-
}, z.core.$strict>]>]>>]>;
|
|
88
|
-
type FilterExpr = z.infer<typeof filterSchema>;
|
|
89
|
-
/** A single column predicate value (scalar shorthand or operator object). */
|
|
90
|
-
type FilterValue = z.infer<typeof filterValueSchema>;
|
|
91
|
-
/**
|
|
92
|
-
* How the link between two entities is expressed in the host schema:
|
|
93
|
-
* - `fkOn: "company"` — FK lives on the company table (e.g. organizations.owner_id)
|
|
94
|
-
* - `fkOn: "contact"` — FK lives on the contact table (e.g. users.organization_id)
|
|
95
|
-
* - `through` — a join table sits between them (many-to-many, role often here)
|
|
96
|
-
* - `$raw` — opaque SQL join fragment (escape hatch; not schema-validated)
|
|
97
|
-
*
|
|
98
|
-
* `column` and the join-table keys are `table.column` or bare `column` strings.
|
|
99
|
-
*/
|
|
100
|
-
declare const relationshipViaSchema: z.ZodUnion<readonly [z.ZodObject<{
|
|
101
|
-
fkOn: z.ZodEnum<{
|
|
102
|
-
contact: "contact";
|
|
103
|
-
company: "company";
|
|
104
|
-
}>;
|
|
105
|
-
column: z.ZodString;
|
|
106
|
-
}, z.core.$strict>, z.ZodObject<{
|
|
107
|
-
through: z.ZodString;
|
|
108
|
-
localKey: z.ZodString;
|
|
109
|
-
foreignKey: z.ZodString;
|
|
110
|
-
}, z.core.$strict>, z.ZodObject<{
|
|
111
|
-
$raw: z.ZodString;
|
|
112
|
-
}, z.core.$strict>]>;
|
|
113
|
-
type RelationshipVia = z.infer<typeof relationshipViaSchema>;
|
|
114
|
-
declare const relationshipSchema: z.ZodObject<{
|
|
115
|
-
entity: z.ZodString;
|
|
116
|
-
via: z.ZodUnion<readonly [z.ZodObject<{
|
|
117
|
-
fkOn: z.ZodEnum<{
|
|
118
|
-
contact: "contact";
|
|
119
|
-
company: "company";
|
|
120
|
-
}>;
|
|
121
|
-
column: z.ZodString;
|
|
122
|
-
}, z.core.$strict>, z.ZodObject<{
|
|
123
|
-
through: z.ZodString;
|
|
124
|
-
localKey: z.ZodString;
|
|
125
|
-
foreignKey: z.ZodString;
|
|
126
|
-
}, z.core.$strict>, z.ZodObject<{
|
|
127
|
-
$raw: z.ZodString;
|
|
128
|
-
}, z.core.$strict>]>;
|
|
129
|
-
}, z.core.$strict>;
|
|
130
|
-
type RelationshipSpec = z.infer<typeof relationshipSchema>;
|
|
131
|
-
/** A named map of relationships, as stored on an entity / in the mappings row. */
|
|
132
|
-
declare const relationshipsSchema: z.ZodRecord<z.ZodString, z.ZodObject<{
|
|
133
|
-
entity: z.ZodString;
|
|
134
|
-
via: z.ZodUnion<readonly [z.ZodObject<{
|
|
135
|
-
fkOn: z.ZodEnum<{
|
|
136
|
-
contact: "contact";
|
|
137
|
-
company: "company";
|
|
138
|
-
}>;
|
|
139
|
-
column: z.ZodString;
|
|
140
|
-
}, z.core.$strict>, z.ZodObject<{
|
|
141
|
-
through: z.ZodString;
|
|
142
|
-
localKey: z.ZodString;
|
|
143
|
-
foreignKey: z.ZodString;
|
|
144
|
-
}, z.core.$strict>, z.ZodObject<{
|
|
145
|
-
$raw: z.ZodString;
|
|
146
|
-
}, z.core.$strict>]>;
|
|
147
|
-
}, z.core.$strict>>;
|
|
148
|
-
type RelationshipsMap = z.infer<typeof relationshipsSchema>;
|
|
149
|
-
declare const entitySchema: z.ZodObject<{
|
|
150
|
-
concept: z.ZodUnion<readonly [z.ZodEnum<{
|
|
151
|
-
contact: "contact";
|
|
152
|
-
company: "company";
|
|
153
|
-
deal: "deal";
|
|
154
|
-
activity: "activity";
|
|
155
|
-
conversation: "conversation";
|
|
156
|
-
note: "note";
|
|
157
|
-
}>, z.ZodLiteral<"custom">]>;
|
|
158
|
-
source: z.ZodString;
|
|
159
|
-
role: z.ZodOptional<z.ZodString>;
|
|
160
|
-
filter: z.ZodOptional<z.ZodUnion<readonly [z.ZodObject<{
|
|
161
|
-
$raw: z.ZodString;
|
|
162
|
-
}, z.core.$strict>, z.ZodRecord<z.ZodString, z.ZodUnion<readonly [z.ZodString, z.ZodNumber, z.ZodBoolean, z.ZodUnion<readonly [z.ZodObject<{
|
|
163
|
-
eq: z.ZodUnion<readonly [z.ZodString, z.ZodNumber, z.ZodBoolean]>;
|
|
164
|
-
}, z.core.$strict>, z.ZodObject<{
|
|
165
|
-
ne: z.ZodUnion<readonly [z.ZodString, z.ZodNumber, z.ZodBoolean]>;
|
|
166
|
-
}, z.core.$strict>, z.ZodObject<{
|
|
167
|
-
in: z.ZodArray<z.ZodUnion<readonly [z.ZodString, z.ZodNumber, z.ZodBoolean]>>;
|
|
168
|
-
}, z.core.$strict>, z.ZodObject<{
|
|
169
|
-
notIn: z.ZodArray<z.ZodUnion<readonly [z.ZodString, z.ZodNumber, z.ZodBoolean]>>;
|
|
170
|
-
}, z.core.$strict>, z.ZodObject<{
|
|
171
|
-
isNull: z.ZodLiteral<true>;
|
|
172
|
-
}, z.core.$strict>, z.ZodObject<{
|
|
173
|
-
isNotNull: z.ZodLiteral<true>;
|
|
174
|
-
}, z.core.$strict>]>]>>]>>;
|
|
175
|
-
fields: z.ZodRecord<z.ZodString, z.ZodString>;
|
|
176
|
-
readOnly: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
177
|
-
relationships: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodObject<{
|
|
178
|
-
entity: z.ZodString;
|
|
179
|
-
via: z.ZodUnion<readonly [z.ZodObject<{
|
|
180
|
-
fkOn: z.ZodEnum<{
|
|
181
|
-
contact: "contact";
|
|
182
|
-
company: "company";
|
|
183
|
-
}>;
|
|
184
|
-
column: z.ZodString;
|
|
185
|
-
}, z.core.$strict>, z.ZodObject<{
|
|
186
|
-
through: z.ZodString;
|
|
187
|
-
localKey: z.ZodString;
|
|
188
|
-
foreignKey: z.ZodString;
|
|
189
|
-
}, z.core.$strict>, z.ZodObject<{
|
|
190
|
-
$raw: z.ZodString;
|
|
191
|
-
}, z.core.$strict>]>;
|
|
192
|
-
}, z.core.$strict>>>;
|
|
193
|
-
targetObjectTypeId: z.ZodOptional<z.ZodString>;
|
|
194
|
-
projection: z.ZodOptional<z.ZodObject<{
|
|
195
|
-
version: z.ZodLiteral<1>;
|
|
196
|
-
kind: z.ZodLiteral<"projection">;
|
|
197
|
-
entityKey: z.ZodString;
|
|
198
|
-
baseTable: z.ZodString;
|
|
199
|
-
joins: z.ZodArray<z.ZodObject<{
|
|
200
|
-
key: z.ZodString;
|
|
201
|
-
table: z.ZodString;
|
|
202
|
-
type: z.ZodEnum<{
|
|
203
|
-
inner: "inner";
|
|
204
|
-
left: "left";
|
|
205
|
-
}>;
|
|
206
|
-
on: z.ZodArray<z.ZodObject<{
|
|
207
|
-
left: z.ZodObject<{
|
|
208
|
-
table: z.ZodString;
|
|
209
|
-
column: z.ZodString;
|
|
210
|
-
}, z.core.$strict>;
|
|
211
|
-
op: z.ZodLiteral<"eq">;
|
|
212
|
-
right: z.ZodObject<{
|
|
213
|
-
table: z.ZodString;
|
|
214
|
-
column: z.ZodString;
|
|
215
|
-
}, z.core.$strict>;
|
|
216
|
-
}, z.core.$strict>>;
|
|
217
|
-
}, z.core.$strict>>;
|
|
218
|
-
fieldBindings: z.ZodRecord<z.ZodString, z.ZodObject<{
|
|
219
|
-
from: z.ZodObject<{
|
|
220
|
-
table: z.ZodString;
|
|
221
|
-
column: z.ZodString;
|
|
222
|
-
}, z.core.$strict>;
|
|
223
|
-
}, z.core.$strict>>;
|
|
224
|
-
identity: z.ZodUnion<readonly [z.ZodObject<{
|
|
225
|
-
kind: z.ZodLiteral<"base_pk">;
|
|
226
|
-
column: z.ZodOptional<z.ZodString>;
|
|
227
|
-
}, z.core.$strict>, z.ZodObject<{
|
|
228
|
-
kind: z.ZodLiteral<"column">;
|
|
229
|
-
from: z.ZodObject<{
|
|
230
|
-
table: z.ZodString;
|
|
231
|
-
column: z.ZodString;
|
|
232
|
-
}, z.core.$strict>;
|
|
233
|
-
}, z.core.$strict>, z.ZodObject<{
|
|
234
|
-
kind: z.ZodLiteral<"composite">;
|
|
235
|
-
parts: z.ZodArray<z.ZodObject<{
|
|
236
|
-
table: z.ZodString;
|
|
237
|
-
column: z.ZodString;
|
|
238
|
-
}, z.core.$strict>>;
|
|
239
|
-
}, z.core.$strict>]>;
|
|
240
|
-
}, z.core.$strict>>;
|
|
241
|
-
}, z.core.$strict>;
|
|
242
|
-
type ClivlyEntityConfig = z.infer<typeof entitySchema>;
|
|
243
|
-
declare const entitiesConfigSchema: z.ZodObject<{
|
|
244
|
-
entities: z.ZodRecord<z.ZodString, z.ZodObject<{
|
|
245
|
-
concept: z.ZodUnion<readonly [z.ZodEnum<{
|
|
246
|
-
contact: "contact";
|
|
247
|
-
company: "company";
|
|
248
|
-
deal: "deal";
|
|
249
|
-
activity: "activity";
|
|
250
|
-
conversation: "conversation";
|
|
251
|
-
note: "note";
|
|
252
|
-
}>, z.ZodLiteral<"custom">]>;
|
|
253
|
-
source: z.ZodString;
|
|
254
|
-
role: z.ZodOptional<z.ZodString>;
|
|
255
|
-
filter: z.ZodOptional<z.ZodUnion<readonly [z.ZodObject<{
|
|
256
|
-
$raw: z.ZodString;
|
|
257
|
-
}, z.core.$strict>, z.ZodRecord<z.ZodString, z.ZodUnion<readonly [z.ZodString, z.ZodNumber, z.ZodBoolean, z.ZodUnion<readonly [z.ZodObject<{
|
|
258
|
-
eq: z.ZodUnion<readonly [z.ZodString, z.ZodNumber, z.ZodBoolean]>;
|
|
259
|
-
}, z.core.$strict>, z.ZodObject<{
|
|
260
|
-
ne: z.ZodUnion<readonly [z.ZodString, z.ZodNumber, z.ZodBoolean]>;
|
|
261
|
-
}, z.core.$strict>, z.ZodObject<{
|
|
262
|
-
in: z.ZodArray<z.ZodUnion<readonly [z.ZodString, z.ZodNumber, z.ZodBoolean]>>;
|
|
263
|
-
}, z.core.$strict>, z.ZodObject<{
|
|
264
|
-
notIn: z.ZodArray<z.ZodUnion<readonly [z.ZodString, z.ZodNumber, z.ZodBoolean]>>;
|
|
265
|
-
}, z.core.$strict>, z.ZodObject<{
|
|
266
|
-
isNull: z.ZodLiteral<true>;
|
|
267
|
-
}, z.core.$strict>, z.ZodObject<{
|
|
268
|
-
isNotNull: z.ZodLiteral<true>;
|
|
269
|
-
}, z.core.$strict>]>]>>]>>;
|
|
270
|
-
fields: z.ZodRecord<z.ZodString, z.ZodString>;
|
|
271
|
-
readOnly: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
272
|
-
relationships: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodObject<{
|
|
273
|
-
entity: z.ZodString;
|
|
274
|
-
via: z.ZodUnion<readonly [z.ZodObject<{
|
|
275
|
-
fkOn: z.ZodEnum<{
|
|
276
|
-
contact: "contact";
|
|
277
|
-
company: "company";
|
|
278
|
-
}>;
|
|
279
|
-
column: z.ZodString;
|
|
280
|
-
}, z.core.$strict>, z.ZodObject<{
|
|
281
|
-
through: z.ZodString;
|
|
282
|
-
localKey: z.ZodString;
|
|
283
|
-
foreignKey: z.ZodString;
|
|
284
|
-
}, z.core.$strict>, z.ZodObject<{
|
|
285
|
-
$raw: z.ZodString;
|
|
286
|
-
}, z.core.$strict>]>;
|
|
287
|
-
}, z.core.$strict>>>;
|
|
288
|
-
targetObjectTypeId: z.ZodOptional<z.ZodString>;
|
|
289
|
-
projection: z.ZodOptional<z.ZodObject<{
|
|
290
|
-
version: z.ZodLiteral<1>;
|
|
291
|
-
kind: z.ZodLiteral<"projection">;
|
|
292
|
-
entityKey: z.ZodString;
|
|
293
|
-
baseTable: z.ZodString;
|
|
294
|
-
joins: z.ZodArray<z.ZodObject<{
|
|
295
|
-
key: z.ZodString;
|
|
296
|
-
table: z.ZodString;
|
|
297
|
-
type: z.ZodEnum<{
|
|
298
|
-
inner: "inner";
|
|
299
|
-
left: "left";
|
|
300
|
-
}>;
|
|
301
|
-
on: z.ZodArray<z.ZodObject<{
|
|
302
|
-
left: z.ZodObject<{
|
|
303
|
-
table: z.ZodString;
|
|
304
|
-
column: z.ZodString;
|
|
305
|
-
}, z.core.$strict>;
|
|
306
|
-
op: z.ZodLiteral<"eq">;
|
|
307
|
-
right: z.ZodObject<{
|
|
308
|
-
table: z.ZodString;
|
|
309
|
-
column: z.ZodString;
|
|
310
|
-
}, z.core.$strict>;
|
|
311
|
-
}, z.core.$strict>>;
|
|
312
|
-
}, z.core.$strict>>;
|
|
313
|
-
fieldBindings: z.ZodRecord<z.ZodString, z.ZodObject<{
|
|
314
|
-
from: z.ZodObject<{
|
|
315
|
-
table: z.ZodString;
|
|
316
|
-
column: z.ZodString;
|
|
317
|
-
}, z.core.$strict>;
|
|
318
|
-
}, z.core.$strict>>;
|
|
319
|
-
identity: z.ZodUnion<readonly [z.ZodObject<{
|
|
320
|
-
kind: z.ZodLiteral<"base_pk">;
|
|
321
|
-
column: z.ZodOptional<z.ZodString>;
|
|
322
|
-
}, z.core.$strict>, z.ZodObject<{
|
|
323
|
-
kind: z.ZodLiteral<"column">;
|
|
324
|
-
from: z.ZodObject<{
|
|
325
|
-
table: z.ZodString;
|
|
326
|
-
column: z.ZodString;
|
|
327
|
-
}, z.core.$strict>;
|
|
328
|
-
}, z.core.$strict>, z.ZodObject<{
|
|
329
|
-
kind: z.ZodLiteral<"composite">;
|
|
330
|
-
parts: z.ZodArray<z.ZodObject<{
|
|
331
|
-
table: z.ZodString;
|
|
332
|
-
column: z.ZodString;
|
|
333
|
-
}, z.core.$strict>>;
|
|
334
|
-
}, z.core.$strict>]>;
|
|
335
|
-
}, z.core.$strict>>;
|
|
336
|
-
}, z.core.$strict>>;
|
|
337
|
-
}, z.core.$strict>;
|
|
338
|
-
type ClivlyEntitiesConfig = z.infer<typeof entitiesConfigSchema>;
|
|
339
|
-
/** Thrown by `defineClivlyConfig({ strict: true })` on non-canonical field keys. */
|
|
340
|
-
declare class ClivlyConfigError extends Error {
|
|
341
|
-
readonly issues: ConfigValidationError[];
|
|
342
|
-
constructor(issues: ConfigValidationError[]);
|
|
343
|
-
}
|
|
344
|
-
/**
|
|
345
|
-
* Structural helper for `clivly.config.ts`. Gives full type inference on the
|
|
346
|
-
* literal you pass and eagerly parses it, so shape errors surface at config
|
|
347
|
-
* load rather than at sync time.
|
|
348
|
-
*
|
|
349
|
-
* It also catches the silent-data-loss footgun: a non-canonical field key for a
|
|
350
|
-
* materialised concept (e.g. `fullName` instead of `name` on a `contact`) has no
|
|
351
|
-
* destination column, so the store would write an empty value. By default these
|
|
352
|
-
* are reported via `onWarn` (a `console.warn`); pass `{ strict: true }` to throw
|
|
353
|
-
* a `ClivlyConfigError` instead. Does NOT validate against the host schema — that
|
|
354
|
-
* needs the discovered schema; see `validateEntitiesConfig`.
|
|
355
|
-
*/
|
|
356
|
-
declare function defineClivlyConfig(config: ClivlyEntitiesConfig, options?: {
|
|
357
|
-
strict?: boolean;
|
|
358
|
-
onWarn?: (message: string) => void;
|
|
359
|
-
}): ClivlyEntitiesConfig;
|
|
360
|
-
/**
|
|
361
|
-
* Per-column metadata a host reports for a discovered table. Structurally
|
|
362
|
-
* identical to the SDK's `DiscoveredColumn` and to `entity-heuristics.ts`'s
|
|
363
|
-
* (currently separate) `DiscoveredColumnMeta` — a later task converges that
|
|
364
|
-
* module onto this one. Every field is optional: a v1 host reports column
|
|
365
|
-
* names only.
|
|
366
|
-
*/
|
|
367
|
-
interface DiscoveredColumnMeta {
|
|
368
|
-
isForeignKey?: boolean;
|
|
369
|
-
isPrimaryKey?: boolean;
|
|
370
|
-
name: string;
|
|
371
|
-
nullable?: boolean;
|
|
372
|
-
references?: {
|
|
373
|
-
table: string;
|
|
374
|
-
column: string;
|
|
375
|
-
};
|
|
376
|
-
type?: string;
|
|
377
|
-
}
|
|
378
|
-
/**
|
|
379
|
-
* A host table the SDK reported for discovery. Structurally identical to the
|
|
380
|
-
* SDK's `DiscoveredTable`; duplicated here to keep `@clivly/core` free of an
|
|
381
|
-
* SDK dependency (core is the base contract SDK builds on).
|
|
382
|
-
*
|
|
383
|
-
* `columns` is the stable v1 contract. `columnsMeta` and `uniqueConstraints`
|
|
384
|
-
* are the enrichment projection mappings require — absent on v1 hosts, which
|
|
385
|
-
* is why projection validation fails closed rather than assuming "no keys".
|
|
386
|
-
*/
|
|
387
|
-
interface DiscoveredSchemaTable {
|
|
388
|
-
columns: string[];
|
|
389
|
-
columnsMeta?: DiscoveredColumnMeta[];
|
|
390
|
-
name: string;
|
|
391
|
-
/** Every unique key as DB column names; PKs included. Absent = unknown. */
|
|
392
|
-
uniqueConstraints?: string[][];
|
|
393
|
-
}
|
|
394
|
-
interface ConfigValidationError {
|
|
395
|
-
message: string;
|
|
396
|
-
/** Dotted path into the config, e.g. `entities.owner.fields.email`. */
|
|
397
|
-
path: string;
|
|
398
|
-
}
|
|
399
|
-
interface ConfigValidationResult {
|
|
400
|
-
errors: ConfigValidationError[];
|
|
401
|
-
valid: boolean;
|
|
402
|
-
}
|
|
403
|
-
/**
|
|
404
|
-
* Validate a (structurally valid) config against the host's discovered schema:
|
|
405
|
-
* source tables exist, mapped columns exist, `readOnly` ⊆ `fields`, filter
|
|
406
|
-
* columns exist, and relationships point at real entities/tables/columns.
|
|
407
|
-
*
|
|
408
|
-
* `$raw` filters and `$raw` relationship joins are opaque and skipped. Returns
|
|
409
|
-
* every error found (not just the first) so a mapping UI or CLI can show them
|
|
410
|
-
* all at once.
|
|
411
|
-
*/
|
|
412
|
-
declare function validateEntitiesConfig(config: ClivlyEntitiesConfig, schema: DiscoveredSchemaTable[]): ConfigValidationResult;
|
|
413
|
-
//#endregion
|
|
414
|
-
export { CANONICAL_FIELDS, CRM_CONCEPTS, CUSTOM_CONCEPT, ClivlyConfigError, ClivlyEntitiesConfig, ClivlyEntityConfig, ConfigValidationError, ConfigValidationResult, CrmConcept, DiscoveredColumnMeta, DiscoveredSchemaTable, FilterExpr, FilterValue, MATERIALIZING_CONCEPTS, MaterializingConcept, RelationshipSpec, RelationshipVia, RelationshipsMap, defineClivlyConfig, entitiesConfigSchema, filterSchema, relationshipSchema, relationshipsSchema, validateEntitiesConfig };
|
|
1
|
+
import { C as filterSchema, D as validateEntitiesConfig, E as relationshipsSchema, S as entitiesConfigSchema, T as relationshipSchema, _ as MaterializingConcept, a as ClivlyEntitiesConfig, b as RelationshipsMap, c as ClivlyEntityConfigInput, d as CrmConcept, f as DiscoveredColumnMeta, g as MATERIALIZING_CONCEPTS, h as FilterValue, i as ClivlyConfigError, l as ConfigValidationError, m as FilterExpr, n as CRM_CONCEPTS, o as ClivlyEntitiesConfigInput, p as DiscoveredSchemaTable, r as CUSTOM_CONCEPT, s as ClivlyEntityConfig, t as CANONICAL_FIELDS, u as ConfigValidationResult, v as RelationshipSpec, w as projectionFields, x as defineClivlyConfig, y as RelationshipVia } from "./entity-config-CLxI8dVb.mjs";
|
|
2
|
+
export { CANONICAL_FIELDS, CRM_CONCEPTS, CUSTOM_CONCEPT, ClivlyConfigError, ClivlyEntitiesConfig, ClivlyEntitiesConfigInput, ClivlyEntityConfig, ClivlyEntityConfigInput, ConfigValidationError, ConfigValidationResult, CrmConcept, DiscoveredColumnMeta, DiscoveredSchemaTable, FilterExpr, FilterValue, MATERIALIZING_CONCEPTS, MaterializingConcept, RelationshipSpec, RelationshipVia, RelationshipsMap, defineClivlyConfig, entitiesConfigSchema, filterSchema, projectionFields, relationshipSchema, relationshipsSchema, validateEntitiesConfig };
|
package/dist/entity-config.mjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { a as MATERIALIZING_CONCEPTS, c as filterSchema, d as validateEntitiesConfig, i as ClivlyConfigError, l as
|
|
2
|
-
export { CANONICAL_FIELDS, CRM_CONCEPTS, CUSTOM_CONCEPT, ClivlyConfigError, MATERIALIZING_CONCEPTS, defineClivlyConfig, entitiesConfigSchema, filterSchema, relationshipSchema, relationshipsSchema, validateEntitiesConfig };
|
|
1
|
+
import { a as MATERIALIZING_CONCEPTS, c as filterSchema, d as relationshipsSchema, f as validateEntitiesConfig, i as ClivlyConfigError, l as projectionFields, n as CRM_CONCEPTS, o as defineClivlyConfig, r as CUSTOM_CONCEPT, s as entitiesConfigSchema, t as CANONICAL_FIELDS, u as relationshipSchema } from "./entity-config-8Fgr6IOH.mjs";
|
|
2
|
+
export { CANONICAL_FIELDS, CRM_CONCEPTS, CUSTOM_CONCEPT, ClivlyConfigError, MATERIALIZING_CONCEPTS, defineClivlyConfig, entitiesConfigSchema, filterSchema, projectionFields, relationshipSchema, relationshipsSchema, validateEntitiesConfig };
|
|
@@ -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-Dh8aEcgj.cjs");
|
|
3
3
|
const require_mapping_score = require("./mapping-score.cjs");
|
|
4
4
|
//#region src/entity-heuristics.ts
|
|
5
5
|
const TARGET_CONCEPTS = [
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { DiscoveredColumnMeta } from "./entity-config.cjs";
|
|
1
|
+
import { f as DiscoveredColumnMeta } from "./entity-config-CLxI8dVb.cjs";
|
|
2
2
|
import { Scored } from "./mapping-score.cjs";
|
|
3
3
|
//#region src/entity-heuristics.d.ts
|
|
4
4
|
declare const TARGET_CONCEPTS: readonly ["contact", "company", "deal", "activity", "conversation", "note"];
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { DiscoveredColumnMeta } from "./entity-config.mjs";
|
|
1
|
+
import { f as DiscoveredColumnMeta } from "./entity-config-CLxI8dVb.mjs";
|
|
2
2
|
import { Scored } from "./mapping-score.mjs";
|
|
3
3
|
//#region src/entity-heuristics.d.ts
|
|
4
4
|
declare const TARGET_CONCEPTS: readonly ["contact", "company", "deal", "activity", "conversation", "note"];
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { a as MATERIALIZING_CONCEPTS } from "./entity-config-
|
|
1
|
+
import { a as MATERIALIZING_CONCEPTS } from "./entity-config-8Fgr6IOH.mjs";
|
|
2
2
|
import { CONCEPT_TIERS, FIELD_TIERS, RELATIONSHIP_TIERS, W, isAmbiguous, isNumericLike, isTextLike, isTimestampLike, tierFor } from "./mapping-score.mjs";
|
|
3
3
|
//#region src/entity-heuristics.ts
|
|
4
4
|
const TARGET_CONCEPTS = [
|
package/dist/index.cjs
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
2
|
const require_auth_adapter = require("./auth-adapter.cjs");
|
|
3
3
|
const require_projection = require("./projection-BXBkh7qp.cjs");
|
|
4
|
-
const require_entity_config = require("./entity-config-
|
|
4
|
+
const require_entity_config = require("./entity-config-Dh8aEcgj.cjs");
|
|
5
5
|
const require_mapping_form = require("./mapping-form.cjs");
|
|
6
6
|
const require_mappings_config = require("./mappings-config.cjs");
|
|
7
|
-
const require_view_compiler = require("./view-compiler-
|
|
7
|
+
const require_view_compiler = require("./view-compiler-BpNI8Ttw.cjs");
|
|
8
8
|
const require_sync_engine = require("./sync-engine.cjs");
|
|
9
9
|
//#region src/projection-draft.ts
|
|
10
10
|
function emptyProjectionDraft(baseTable) {
|
package/dist/index.d.cts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { Activity, ActivityType, Company, Contact, ContactFilters, ContactStatus, CreateActivityInput, CreateCompanyInput, CreateContactInput, CreateDealInput, CreateTaskInput, CrmRole, Deal, DealStage, Note, RecordSource, Task, TaskEntityType, TaskFilters, TaskPriority, TaskStatus, UpdateContactInput, UpdateDealInput, UpdateTaskInput } from "./types.cjs";
|
|
2
2
|
import { CRMAdapter } from "./adapter.cjs";
|
|
3
3
|
import { ClivlyAuthAdapter, ClivlyUser, CrmMembership, MembershipResolver, authCustom } from "./auth-adapter.cjs";
|
|
4
|
-
import {
|
|
4
|
+
import { A as ProjectionIdentity, C as filterSchema, D as validateEntitiesConfig, E as relationshipsSchema, F as projectionSchema, M as ProjectionMapping, N as ProjectionRef, O as BASE_REF, P as identityRefs, S as entitiesConfigSchema, T as relationshipSchema, _ as MaterializingConcept, a as ClivlyEntitiesConfig, b as RelationshipsMap, d as CrmConcept, f as DiscoveredColumnMeta, g as MATERIALIZING_CONCEPTS, h as FilterValue, i as ClivlyConfigError, j as ProjectionJoin, k as ProjectionFieldBinding, l as ConfigValidationError, m as FilterExpr, n as CRM_CONCEPTS, p as DiscoveredSchemaTable, s as ClivlyEntityConfig, t as CANONICAL_FIELDS, u as ConfigValidationResult, v as RelationshipSpec, x as defineClivlyConfig, y as RelationshipVia } from "./entity-config-CLxI8dVb.cjs";
|
|
5
5
|
import { RelationshipCandidate, buildFilterFromDiscriminator, buildRelationships, relationshipViaSignature } from "./mapping-form.cjs";
|
|
6
|
-
import {
|
|
6
|
+
import { EntityMappingRow, mappingsToEntitiesConfig } from "./mappings-config.cjs";
|
|
7
7
|
import { CompileOptions, CompiledView, DEFAULT_VIEW_PREFIX, ExplainResult, compileEntityView, compileEntityViews, explainEntitiesConfig } from "./view-compiler.cjs";
|
|
8
8
|
import { EntitySyncResult, MirrorRecord, PersistAction, SourceRow, SyncAction, SyncResult, SyncStore, reconcile, runSync } from "./sync-engine.cjs";
|
|
9
9
|
//#region src/projection-cardinality.d.ts
|
package/dist/index.d.mts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { Activity, ActivityType, Company, Contact, ContactFilters, ContactStatus, CreateActivityInput, CreateCompanyInput, CreateContactInput, CreateDealInput, CreateTaskInput, CrmRole, Deal, DealStage, Note, RecordSource, Task, TaskEntityType, TaskFilters, TaskPriority, TaskStatus, UpdateContactInput, UpdateDealInput, UpdateTaskInput } from "./types.mjs";
|
|
2
2
|
import { CRMAdapter } from "./adapter.mjs";
|
|
3
3
|
import { ClivlyAuthAdapter, ClivlyUser, CrmMembership, MembershipResolver, authCustom } from "./auth-adapter.mjs";
|
|
4
|
-
import {
|
|
4
|
+
import { A as ProjectionIdentity, C as filterSchema, D as validateEntitiesConfig, E as relationshipsSchema, F as projectionSchema, M as ProjectionMapping, N as ProjectionRef, O as BASE_REF, P as identityRefs, S as entitiesConfigSchema, T as relationshipSchema, _ as MaterializingConcept, a as ClivlyEntitiesConfig, b as RelationshipsMap, d as CrmConcept, f as DiscoveredColumnMeta, g as MATERIALIZING_CONCEPTS, h as FilterValue, i as ClivlyConfigError, j as ProjectionJoin, k as ProjectionFieldBinding, l as ConfigValidationError, m as FilterExpr, n as CRM_CONCEPTS, p as DiscoveredSchemaTable, s as ClivlyEntityConfig, t as CANONICAL_FIELDS, u as ConfigValidationResult, v as RelationshipSpec, x as defineClivlyConfig, y as RelationshipVia } from "./entity-config-CLxI8dVb.mjs";
|
|
5
5
|
import { RelationshipCandidate, buildFilterFromDiscriminator, buildRelationships, relationshipViaSignature } from "./mapping-form.mjs";
|
|
6
|
-
import {
|
|
6
|
+
import { EntityMappingRow, mappingsToEntitiesConfig } from "./mappings-config.mjs";
|
|
7
7
|
import { CompileOptions, CompiledView, DEFAULT_VIEW_PREFIX, ExplainResult, compileEntityView, compileEntityViews, explainEntitiesConfig } from "./view-compiler.mjs";
|
|
8
8
|
import { EntitySyncResult, MirrorRecord, PersistAction, SourceRow, SyncAction, SyncResult, SyncStore, reconcile, runSync } from "./sync-engine.mjs";
|
|
9
9
|
//#region src/projection-cardinality.d.ts
|
package/dist/index.mjs
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { authCustom } from "./auth-adapter.mjs";
|
|
2
2
|
import { i as projectionSchema, n as PROJECTION_KEY_PATTERN, r as identityRefs, t as BASE_REF } from "./projection-C_EMRmZ8.mjs";
|
|
3
|
-
import { _ as
|
|
3
|
+
import { _ as coversUniqueKey, a as MATERIALIZING_CONCEPTS, c as filterSchema, d as relationshipsSchema, f as validateEntitiesConfig, g as columnMetaFor, h as joinFansOut, i as ClivlyConfigError, m as fanOutJoins, n as CRM_CONCEPTS, o as defineClivlyConfig, p as validateProjection, s as entitiesConfigSchema, t as CANONICAL_FIELDS, u as relationshipSchema, v as hasRichMeta, y as primaryKeyColumns } from "./entity-config-8Fgr6IOH.mjs";
|
|
4
4
|
import { buildFilterFromDiscriminator, buildRelationships, relationshipViaSignature } from "./mapping-form.mjs";
|
|
5
5
|
import { mappingsToEntitiesConfig } from "./mappings-config.mjs";
|
|
6
|
-
import { i as explainEntitiesConfig, n as compileEntityView, r as compileEntityViews, t as DEFAULT_VIEW_PREFIX } from "./view-compiler-
|
|
6
|
+
import { i as explainEntitiesConfig, n as compileEntityView, r as compileEntityViews, t as DEFAULT_VIEW_PREFIX } from "./view-compiler-CcqsGxv4.mjs";
|
|
7
7
|
import { reconcile, runSync } from "./sync-engine.mjs";
|
|
8
8
|
//#region src/projection-draft.ts
|
|
9
9
|
function emptyProjectionDraft(baseTable) {
|
package/dist/mapping-form.d.cts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { FilterExpr, RelationshipVia
|
|
1
|
+
import { b as RelationshipsMap, m as FilterExpr, y as RelationshipVia } from "./entity-config-CLxI8dVb.cjs";
|
|
2
2
|
//#region src/mapping-form.d.ts
|
|
3
3
|
/**
|
|
4
4
|
* A relationship the mapping UI can offer or has configured, in the shape the
|
package/dist/mapping-form.d.mts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { FilterExpr, RelationshipVia
|
|
1
|
+
import { b as RelationshipsMap, m as FilterExpr, y as RelationshipVia } from "./entity-config-CLxI8dVb.mjs";
|
|
2
2
|
//#region src/mapping-form.d.ts
|
|
3
3
|
/**
|
|
4
4
|
* A relationship the mapping UI can offer or has configured, in the shape the
|
package/dist/mappings-config.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-Dh8aEcgj.cjs");
|
|
3
3
|
//#region src/mappings-config.ts
|
|
4
4
|
const RESERVED_FIELD = "id";
|
|
5
5
|
/**
|
|
@@ -1,2 +1,47 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { M as ProjectionMapping, a as ClivlyEntitiesConfig } from "./entity-config-CLxI8dVb.cjs";
|
|
2
|
+
//#region 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
|
|
2
47
|
export { EntityMappingRow, mappingsToEntitiesConfig };
|
|
@@ -1,2 +1,47 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { M as ProjectionMapping, a as ClivlyEntitiesConfig } from "./entity-config-CLxI8dVb.mjs";
|
|
2
|
+
//#region 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
|
|
2
47
|
export { EntityMappingRow, mappingsToEntitiesConfig };
|
package/dist/mappings-config.mjs
CHANGED
package/dist/sync-engine.cjs
CHANGED
|
@@ -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-BpNI8Ttw.cjs");
|
|
3
3
|
//#region src/sync-engine.ts
|
|
4
4
|
/**
|
|
5
5
|
* Diff a view's rows against the current mirror population for one entity.
|