@clivly/core 0.9.0 → 0.9.2
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 +91 -3
- package/dist/drizzle.d.cts +1 -1
- package/dist/drizzle.d.mts +1 -1
- package/dist/{entity-config-PoOGzvpN.cjs → entity-config-Bfq3OkCU.cjs} +88 -13
- package/dist/{entity-config-Tb5bbKLj.mjs → entity-config-DFJ8L9jm.mjs} +77 -14
- package/dist/entity-config-buOIVtMM.d.cts +580 -0
- package/dist/entity-config-buOIVtMM.d.mts +580 -0
- package/dist/entity-config.cjs +3 -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/integration-state.cjs +98 -26
- package/dist/integration-state.d.cts +94 -7
- package/dist/integration-state.d.mts +94 -7
- package/dist/integration-state.mjs +96 -27
- package/dist/mapping-form.d.cts +1 -1
- package/dist/mapping-form.d.mts +1 -1
- package/dist/mappings-config.cjs +25 -1
- package/dist/mappings-config.d.cts +85 -2
- package/dist/mappings-config.d.mts +85 -2
- package/dist/mappings-config.mjs +25 -2
- 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.cts
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 defineClivlyConfig, D as relationshipSchema, E as projectionFields, O as relationshipsSchema, S as customObjectDeclarations, T as filterSchema, _ as MATERIALIZING_CONCEPTS, a as ClivlyEntitiesConfig, b as RelationshipVia, c as ClivlyEntityConfigInput, d as CrmConcept, f as CustomObjectDeclaration, g as FilterValue, h as FilterExpr, i as ClivlyConfigError, k as validateEntitiesConfig, l as ConfigValidationError, m as DiscoveredSchemaTable, n as CRM_CONCEPTS, o as ClivlyEntitiesConfigInput, p as DiscoveredColumnMeta, r as CUSTOM_CONCEPT, s as ClivlyEntityConfig, t as CANONICAL_FIELDS, u as ConfigValidationResult, v as MaterializingConcept, w as entitiesConfigSchema, x as RelationshipsMap, y as RelationshipSpec } from "./entity-config-buOIVtMM.cjs";
|
|
2
|
+
export { CANONICAL_FIELDS, CRM_CONCEPTS, CUSTOM_CONCEPT, ClivlyConfigError, ClivlyEntitiesConfig, ClivlyEntitiesConfigInput, ClivlyEntityConfig, ClivlyEntityConfigInput, ConfigValidationError, ConfigValidationResult, CrmConcept, CustomObjectDeclaration, DiscoveredColumnMeta, DiscoveredSchemaTable, FilterExpr, FilterValue, MATERIALIZING_CONCEPTS, MaterializingConcept, RelationshipSpec, RelationshipVia, RelationshipsMap, customObjectDeclarations, defineClivlyConfig, entitiesConfigSchema, filterSchema, projectionFields, relationshipSchema, relationshipsSchema, validateEntitiesConfig };
|