clivly 0.17.0 → 0.18.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.
Files changed (130) hide show
  1. package/README.md +36 -33
  2. package/{adapter-BpAfha3z.d.mts → adapter-BXykDFyG.d.mts} +1 -1
  3. package/{adapter-BvSigBPG.d.cts → adapter-BiUN_I3u.d.cts} +1 -1
  4. package/{auth-adapter-CsZE4ugg.d.cts → auth-adapter-BNvri2gX.d.mts} +1 -1
  5. package/{auth-adapter-Q6CL2VHr.d.mts → auth-adapter-D2MUT1Hk.d.cts} +1 -1
  6. package/auth-better-auth.d.cts +1 -1
  7. package/auth-better-auth.d.mts +1 -1
  8. package/auth-clerk.d.cts +1 -1
  9. package/auth-clerk.d.mts +1 -1
  10. package/auth-workos.d.cts +1 -1
  11. package/auth-workos.d.mts +1 -1
  12. package/core-adapter.d.cts +1 -1
  13. package/core-adapter.d.mts +1 -1
  14. package/core-auth-adapter.d.cts +1 -1
  15. package/core-auth-adapter.d.mts +1 -1
  16. package/core-drizzle.d.cts +1 -1
  17. package/core-drizzle.d.mts +1 -1
  18. package/core-entity-config.cjs +1 -1
  19. package/core-entity-config.d.cts +1 -1
  20. package/core-entity-config.d.mts +1 -1
  21. package/core-entity-config.mjs +1 -1
  22. package/core-entity-heuristics.cjs +16 -15
  23. package/core-entity-heuristics.d.cts +3 -3
  24. package/core-entity-heuristics.d.mts +3 -3
  25. package/core-entity-heuristics.mjs +1 -1
  26. package/core-mapping-form.d.cts +1 -1
  27. package/core-mapping-form.d.mts +1 -1
  28. package/core-mappings-config.cjs +1 -1
  29. package/core-mappings-config.d.cts +1 -1
  30. package/core-mappings-config.d.mts +1 -1
  31. package/core-mappings-config.mjs +1 -1
  32. package/core-sync-engine.cjs +1 -1
  33. package/core-sync-engine.d.cts +1 -1
  34. package/core-sync-engine.d.mts +1 -1
  35. package/core-sync-engine.mjs +1 -1
  36. package/core-types.d.cts +2 -2
  37. package/core-types.d.mts +2 -2
  38. package/core-view-compiler.cjs +1 -1
  39. package/core-view-compiler.d.cts +1 -1
  40. package/core-view-compiler.d.mts +1 -1
  41. package/core-view-compiler.mjs +1 -1
  42. package/core.cjs +7 -7
  43. package/core.d.cts +10 -10
  44. package/core.d.mts +10 -10
  45. package/core.mjs +7 -7
  46. package/{drizzle-MUNZgh1l.d.cts → drizzle-B9cjBavj.d.cts} +1 -1
  47. package/{drizzle-UJbPCzPJ.d.mts → drizzle-L5FOGe_-.d.mts} +1 -1
  48. package/drizzle.cjs +2 -2
  49. package/drizzle.d.cts +3 -3
  50. package/drizzle.d.mts +3 -3
  51. package/drizzle.mjs +2 -2
  52. package/{entity-config-nWWgJXLw.cjs → entity-config-DiCJ6mhI.cjs} +1 -1
  53. package/{entity-config-BF7pcXFB.d.cts → entity-config-X-KlnYXX.d.mts} +1 -1
  54. package/{entity-config-pzamFSKw.d.mts → entity-config-dNclLyBM.d.cts} +1 -1
  55. package/{entity-config-DQVSprlG.mjs → entity-config-g_oMPXlN.mjs} +1 -1
  56. package/entity-heuristics-CIParuQe.cjs +655 -0
  57. package/entity-heuristics-DE5ujoHw.mjs +566 -0
  58. package/index.cjs +69 -20
  59. package/index.mjs +57 -8
  60. package/{internal-DtLZyjf8.mjs → internal-9oDwwbNg.mjs} +1 -1
  61. package/{internal-CjJy-cy1.cjs → internal-BKYt5j0l.cjs} +1 -1
  62. package/{internal-Gie7hCpK.d.mts → internal-COALpgov.d.cts} +1 -1
  63. package/{internal-C-uvosSL.d.cts → internal-D3q4FPcA.d.mts} +1 -1
  64. package/internal-adapter.d.cts +1 -1
  65. package/internal-adapter.d.mts +1 -1
  66. package/internal-auth-adapter.d.cts +1 -1
  67. package/internal-auth-adapter.d.mts +1 -1
  68. package/internal-drizzle.d.cts +1 -1
  69. package/internal-drizzle.d.mts +1 -1
  70. package/internal-entity-config.cjs +1 -1
  71. package/internal-entity-config.d.cts +1 -1
  72. package/internal-entity-config.d.mts +1 -1
  73. package/internal-entity-config.mjs +1 -1
  74. package/internal-entity-heuristics.cjs +16 -575
  75. package/internal-entity-heuristics.d.cts +3 -1
  76. package/internal-entity-heuristics.d.mts +3 -1
  77. package/internal-entity-heuristics.mjs +1 -562
  78. package/internal-mapping-form.d.cts +1 -1
  79. package/internal-mapping-form.d.mts +1 -1
  80. package/internal-mappings-config.cjs +1 -1
  81. package/internal-mappings-config.d.cts +1 -1
  82. package/internal-mappings-config.d.mts +1 -1
  83. package/internal-mappings-config.mjs +1 -1
  84. package/internal-sync-engine.cjs +1 -1
  85. package/internal-sync-engine.d.cts +1 -1
  86. package/internal-sync-engine.d.mts +1 -1
  87. package/internal-sync-engine.mjs +1 -1
  88. package/internal-types.d.cts +2 -2
  89. package/internal-types.d.mts +2 -2
  90. package/internal-view-compiler.cjs +1 -1
  91. package/internal-view-compiler.d.cts +1 -1
  92. package/internal-view-compiler.d.mts +1 -1
  93. package/internal-view-compiler.mjs +1 -1
  94. package/internal.cjs +7 -7
  95. package/internal.d.cts +10 -10
  96. package/internal.d.mts +10 -10
  97. package/internal.mjs +7 -7
  98. package/{mapping-form-BymksK7h.d.mts → mapping-form-Bpvgf5b8.d.mts} +1 -1
  99. package/{mapping-form-Cmf8y-1m.d.cts → mapping-form-CV7y6qox.d.cts} +1 -1
  100. package/{mappings-config-Dsz6rcJb.d.cts → mappings-config-BBppW9fp.d.cts} +1 -1
  101. package/{mappings-config-DBG-KnYl.cjs → mappings-config-CNxBrbt9.cjs} +1 -1
  102. package/{mappings-config-C7FPwrJT.mjs → mappings-config-D_g20PyS.mjs} +1 -1
  103. package/{mappings-config-ktJhxmHm.d.mts → mappings-config-Dmm0H6p_.d.mts} +1 -1
  104. package/{namespace-probe-By8SCnym.d.mts → namespace-probe-BAXprXQh.d.mts} +49 -5
  105. package/{namespace-probe-CTkb35Ro.d.cts → namespace-probe-qgjiudCo.d.cts} +49 -5
  106. package/package.json +1 -7
  107. package/{projection-DNi_2dVa.mjs → projection-BkYXvjTr.mjs} +2434 -1147
  108. package/{projection-B8RtxuEq.cjs → projection-By63gMC-.cjs} +2434 -1147
  109. package/{projection-sql-BYv40Hen.mjs → projection-sql-C3gZE3GS.mjs} +1 -1
  110. package/{projection-sql-SuhzhsMe.cjs → projection-sql-CHz7KzNS.cjs} +1 -1
  111. package/{schemas-DySv963y.d.cts → schemas-BSuo_eZQ.d.cts} +97 -35
  112. package/{schemas-DySv963y.d.mts → schemas-BSuo_eZQ.d.mts} +97 -35
  113. package/{sdk-BJ3OkhCq.cjs → sdk-D53fH4uu.cjs} +164 -28
  114. package/{sdk-CXrarwvs.mjs → sdk-D5J7kRQm.mjs} +164 -28
  115. package/sdk.cjs +2 -2
  116. package/sdk.d.cts +4 -4
  117. package/sdk.d.mts +4 -4
  118. package/sdk.mjs +2 -2
  119. package/{sync-engine-D9ltfqkD.d.cts → sync-engine-C7W0Gkq0.d.cts} +2 -2
  120. package/{sync-engine-C_SwnFgF.d.mts → sync-engine-C9Q2FkR9.d.mts} +2 -2
  121. package/{sync-engine-BTUoH82k.mjs → sync-engine-CwdLkmch.mjs} +1 -1
  122. package/{sync-engine-DBlSP9r2.cjs → sync-engine-Di-vF26b.cjs} +1 -1
  123. package/{types-BtQCi_qP.d.cts → types-C08UluBS.d.cts} +23 -2
  124. package/{types-CTOl3pAX.d.mts → types-CZsSYbeC.d.mts} +23 -2
  125. package/{view-compiler-B8tJ5IGw.mjs → view-compiler-CLTi1VL-.mjs} +2 -2
  126. package/{view-compiler-Ce_QE3dh.cjs → view-compiler-DaOz5QVl.cjs} +2 -2
  127. package/{view-compiler-BZgZisTG.d.mts → view-compiler-M23WiVGG.d.mts} +1 -1
  128. package/{view-compiler-D7GLf1n8.d.cts → view-compiler-cXqt4X-c.d.cts} +1 -1
  129. package/vite.d.cts +1 -1
  130. package/vite.d.mts +1 -1
@@ -1,562 +1 @@
1
- import { a as MATERIALIZING_CONCEPTS } from "./entity-config-DQVSprlG.mjs";
2
- import { a as W, c as isTextLike, i as RELATIONSHIP_TIERS, l as isTimestampLike, n as CONCEPT_TIERS, o as isAmbiguous, r as FIELD_TIERS, s as isNumericLike, u as tierFor } from "./mapping-score-CS-MTDL9.mjs";
3
- // ../core/src/entity-heuristics.ts
4
- const TARGET_CONCEPTS = [
5
- "contact",
6
- "company",
7
- "deal",
8
- "activity",
9
- "conversation",
10
- "note"
11
- ];
12
- const TABLE_PATTERNS = [
13
- {
14
- concept: "contact",
15
- names: [
16
- "users",
17
- "customers",
18
- "clients",
19
- "accounts",
20
- "participants",
21
- "attendees",
22
- "people",
23
- "members",
24
- "contacts",
25
- "students",
26
- "pupils",
27
- "learners",
28
- "patients",
29
- "subscribers",
30
- "donors",
31
- "guests",
32
- "residents",
33
- "tenants",
34
- "applicants",
35
- "candidates",
36
- "leads",
37
- "prospects"
38
- ]
39
- },
40
- {
41
- concept: "company",
42
- names: [
43
- "companies",
44
- "organizations",
45
- "organisations",
46
- "orgs",
47
- "teams",
48
- "businesses",
49
- "accounts"
50
- ]
51
- },
52
- {
53
- concept: "deal",
54
- names: [
55
- "deals",
56
- "opportunities",
57
- "subscriptions",
58
- "orders",
59
- "invoices",
60
- "sales"
61
- ]
62
- },
63
- {
64
- concept: "conversation",
65
- names: [
66
- "conversations",
67
- "messages",
68
- "tickets",
69
- "threads",
70
- "chats",
71
- "inbox"
72
- ]
73
- },
74
- {
75
- concept: "activity",
76
- names: [
77
- "events",
78
- "activities",
79
- "jobs",
80
- "logs",
81
- "audit",
82
- "shifts",
83
- "scans",
84
- "sessions"
85
- ]
86
- },
87
- {
88
- concept: "note",
89
- names: [
90
- "notes",
91
- "comments",
92
- "annotations"
93
- ]
94
- }
95
- ];
96
- const CONCEPT_FIELDS = {
97
- contact: [
98
- {
99
- field: "name",
100
- candidates: [
101
- "name",
102
- "full_name",
103
- "fullname",
104
- "display_name",
105
- "first_name",
106
- "firstname",
107
- "given_name"
108
- ],
109
- required: false
110
- },
111
- {
112
- field: "email",
113
- candidates: ["email", "email_address"],
114
- required: true
115
- },
116
- {
117
- field: "phone",
118
- candidates: [
119
- "phone",
120
- "phone_number",
121
- "phonenumber",
122
- "mobile",
123
- "mobile_number",
124
- "mobilenumber",
125
- "telephone"
126
- ],
127
- required: false
128
- }
129
- ],
130
- company: [{
131
- field: "name",
132
- candidates: [
133
- "name",
134
- "company_name",
135
- "legal_name",
136
- "title"
137
- ],
138
- required: true
139
- }, {
140
- field: "domain",
141
- candidates: [
142
- "domain",
143
- "website",
144
- "url"
145
- ],
146
- required: false
147
- }],
148
- deal: [
149
- {
150
- field: "name",
151
- candidates: ["name", "title"],
152
- required: true
153
- },
154
- {
155
- field: "value",
156
- candidates: [
157
- "value",
158
- "amount",
159
- "total",
160
- "price"
161
- ],
162
- required: false
163
- },
164
- {
165
- field: "stage",
166
- candidates: [
167
- "stage",
168
- "status",
169
- "state"
170
- ],
171
- required: false
172
- }
173
- ],
174
- activity: [
175
- {
176
- field: "type",
177
- candidates: [
178
- "type",
179
- "kind",
180
- "event_type"
181
- ],
182
- required: false
183
- },
184
- {
185
- field: "summary",
186
- candidates: [
187
- "summary",
188
- "description",
189
- "message",
190
- "title"
191
- ],
192
- required: false
193
- },
194
- {
195
- field: "createdAt",
196
- candidates: [
197
- "created_at",
198
- "createdat",
199
- "timestamp"
200
- ],
201
- required: false
202
- }
203
- ],
204
- conversation: [{
205
- field: "status",
206
- candidates: ["status", "state"],
207
- required: false
208
- }, {
209
- field: "subject",
210
- candidates: [
211
- "subject",
212
- "title",
213
- "preview"
214
- ],
215
- required: false
216
- }],
217
- note: [{
218
- field: "body",
219
- candidates: [
220
- "body",
221
- "content",
222
- "text",
223
- "note"
224
- ],
225
- required: true
226
- }]
227
- };
228
- const CURSOR_CANDIDATES = [
229
- "updatedat",
230
- "updated_at",
231
- "modifiedat",
232
- "modified_at",
233
- "createdat",
234
- "created_at"
235
- ];
236
- function suggestCursorField(columnKeys) {
237
- const lowerToActual = new Map(columnKeys.map((c) => [c.toLowerCase(), c]));
238
- for (const candidate of CURSOR_CANDIDATES) {
239
- const match = lowerToActual.get(candidate);
240
- if (match) return match;
241
- }
242
- return null;
243
- }
244
- const MATERIALIZING = new Set(MATERIALIZING_CONCEPTS);
245
- const ENDS_IN_CONSONANT_Y = /[^aeiou]y$/;
246
- const NEEDS_ES = /(s|x|z|ch|sh)$/;
247
- const IRREGULAR_PLURALS = {
248
- person: "people",
249
- child: "children",
250
- man: "men",
251
- woman: "women"
252
- };
253
- function pluralize(name) {
254
- const irregular = IRREGULAR_PLURALS[name];
255
- if (irregular) return irregular;
256
- if (ENDS_IN_CONSONANT_Y.test(name)) return `${name.slice(0, -1)}ies`;
257
- if (NEEDS_ES.test(name)) return `${name}es`;
258
- return `${name}s`;
259
- }
260
- function matchesConcept(tableName, concept) {
261
- const normalized = tableName.toLowerCase();
262
- const entry = TABLE_PATTERNS.find((p) => p.concept === concept);
263
- if (!entry) return null;
264
- const candidates = [normalized, pluralize(normalized)];
265
- if (candidates.some((candidate) => entry.names.includes(candidate))) return { exact: true };
266
- if (entry.names.some((name) => candidates.some((candidate) => candidate.includes(name)))) return { exact: false };
267
- return null;
268
- }
269
- const SENSITIVE_COLUMNS = /* @__PURE__ */ new Set([
270
- "password",
271
- "password_hash",
272
- "passwordhash",
273
- "access_token",
274
- "accesstoken",
275
- "api_key",
276
- "apikey",
277
- "client_secret",
278
- "clientsecret",
279
- "encrypted_password",
280
- "encryptedpassword",
281
- "refresh_token",
282
- "refreshtoken",
283
- "id_token",
284
- "idtoken",
285
- "password_digest",
286
- "passworddigest",
287
- "private_key",
288
- "privatekey",
289
- "secret",
290
- "session_token",
291
- "sessiontoken"
292
- ]);
293
- /**
294
- * Does this table carry credentials? Such tables are withheld from suggestions
295
- * and from bulk apply, so one click can never map an auth table into the CRM.
296
- * They stay manually selectable — an explicit, informed choice is legitimate.
297
- */
298
- function hasSensitiveColumns(columns) {
299
- return columns.some((column) => SENSITIVE_COLUMNS.has(column.toLowerCase().replaceAll("-", "_")));
300
- }
301
- /**
302
- * Table names the supported auth libraries create.
303
- *
304
- * `hasSensitiveColumns` cannot catch these. Better Auth's `organization` table
305
- * is `{id, name, slug, logo}` — no credential column anywhere, a real `name`,
306
- * and "organizations" is in the company vocabulary above. It is, by every
307
- * signal this module has, an excellent company candidate. On `vue-academy`
308
- * `clivly init` duly chose it over `campuses`, the actual business table that
309
- * every student row points at, and the first sync exported rows nothing could
310
- * receive.
311
- *
312
- * Matched on name, deliberately, and this is the inverse of the rule above:
313
- * withholding a table on a wrong guess is a real loss, so that is decided on
314
- * columns; *ranking* one below another is cheap to get wrong, so a name match
315
- * is enough. These are fixed names the plugins create, and an app whose own
316
- * business table is called `member` still ranks — just after its rivals.
317
- */
318
- const FRAMEWORK_TABLE_NAMES = /* @__PURE__ */ new Set([
319
- "account",
320
- "session",
321
- "user",
322
- "verification",
323
- "invitation",
324
- "member",
325
- "organization",
326
- "team",
327
- "team_member",
328
- "apikey",
329
- "api_key",
330
- "jwks",
331
- "passkey",
332
- "rate_limit",
333
- "ratelimit",
334
- "two_factor",
335
- "twofactor",
336
- "__drizzle_migrations",
337
- "drizzle_migrations"
338
- ]);
339
- /**
340
- * Is this table one your auth library created, rather than one you wrote?
341
- *
342
- * Used to rank such tables below the developer's own when both could serve a
343
- * concept. Never to exclude them: mapping `user` as the contact entity is
344
- * legitimate for plenty of apps, and it stays selectable.
345
- */
346
- function isFrameworkTable(name) {
347
- return FRAMEWORK_TABLE_NAMES.has(name.toLowerCase().replaceAll("-", "_"));
348
- }
349
- function metaFor(table, column) {
350
- return table.columnsMeta?.find((c) => c.name === column);
351
- }
352
- function hasDefiningColumn(concept, columns) {
353
- const lower = new Set(columns.map((c) => c.toLowerCase()));
354
- const required = CONCEPT_FIELDS[concept].filter((f) => f.required);
355
- return required.length > 0 && required.every((f) => f.candidates.some((c) => lower.has(c)));
356
- }
357
- function scoreConcepts(table) {
358
- const out = [];
359
- for (const concept of TARGET_CONCEPTS) {
360
- if (!MATERIALIZING.has(concept)) continue;
361
- const nameMatch = matchesConcept(table.name, concept);
362
- const definingColumns = hasDefiningColumn(concept, table.columns);
363
- if (!(nameMatch || definingColumns)) continue;
364
- let score = 0;
365
- const reasons = [];
366
- if (nameMatch?.exact) {
367
- score += W.nameExact;
368
- reasons.push(`name matches "${table.name}"`);
369
- } else if (nameMatch) {
370
- score += W.nameSubstring;
371
- reasons.push(`name looks like ${concept}`);
372
- }
373
- if (definingColumns) {
374
- score += W.definingColumn;
375
- reasons.push(`has the columns a ${concept} needs`);
376
- }
377
- if (table.columnsMeta?.some((c) => c.isPrimaryKey)) {
378
- score += W.hasPrimaryKey;
379
- reasons.push("has primary key");
380
- }
381
- if (table.rowCount !== void 0) {
382
- if (table.rowCount === 0) {
383
- score += W.emptyTable;
384
- reasons.push("table is empty");
385
- } else {
386
- score += W.hasRows;
387
- reasons.push(`${table.rowCount.toLocaleString("en-US")} rows`);
388
- }
389
- }
390
- out.push({
391
- value: concept,
392
- score,
393
- tier: tierFor(score, CONCEPT_TIERS),
394
- reasons
395
- });
396
- }
397
- return out.sort((a, b) => b.score - a.score);
398
- }
399
- function topConcept(table) {
400
- const ranked = scoreConcepts(table);
401
- const best = ranked[0];
402
- if (!best) return null;
403
- return {
404
- best,
405
- ambiguous: isAmbiguous(ranked)
406
- };
407
- }
408
- function requiredFieldsFor(concept) {
409
- if (concept === "custom") return [];
410
- return CONCEPT_FIELDS[concept].filter((f) => f.required).map((f) => f.field);
411
- }
412
- function validateMapping(requiredFields, fieldMap) {
413
- const missing = requiredFields.filter((field) => !fieldMap[field]);
414
- return {
415
- valid: missing.length === 0,
416
- missing
417
- };
418
- }
419
- const DISCRIMINATOR_COLUMNS = [
420
- "role",
421
- "type",
422
- "kind",
423
- "status",
424
- "state",
425
- "category",
426
- "tier"
427
- ];
428
- function suggestDiscriminatorColumns(columns) {
429
- const lowerToActual = new Map(columns.map((c) => [c.toLowerCase(), c]));
430
- const out = [];
431
- for (const name of DISCRIMINATOR_COLUMNS) {
432
- const match = lowerToActual.get(name);
433
- if (match) out.push(match);
434
- }
435
- return out;
436
- }
437
- const COMPANY_FK_HINTS = [
438
- "organization_id",
439
- "organisation_id",
440
- "org_id",
441
- "company_id",
442
- "account_id",
443
- "team_id"
444
- ];
445
- function firstMatchingColumn(columns, hints) {
446
- const lowerToActual = new Map(columns.map((c) => [c.toLowerCase(), c]));
447
- for (const hint of hints) {
448
- const match = lowerToActual.get(hint);
449
- if (match) return match;
450
- }
451
- return null;
452
- }
453
- /**
454
- * Suggest contact→company relationships. When the source table carries FK
455
- * metadata (`references`), the target table is a *fact*, not a name guess —
456
- * that scores highest. Without metadata (v1 hosts) we fall back to the legacy
457
- * FK-name hints at a lower tier.
458
- */
459
- function scoreRelationships(source, allTables) {
460
- const companyTables = allTables.filter((t) => t.name !== source.name && topConcept(t)?.best.value === "company");
461
- if (companyTables.length === 0) return [];
462
- const companyNames = new Set(companyTables.map((t) => t.name.toLowerCase()));
463
- const out = [];
464
- const seenTargets = /* @__PURE__ */ new Set();
465
- for (const col of source.columnsMeta ?? []) {
466
- const ref = col.references;
467
- if (!(ref && companyNames.has(ref.table.toLowerCase()))) continue;
468
- if (seenTargets.has(ref.table.toLowerCase())) continue;
469
- seenTargets.add(ref.table.toLowerCase());
470
- out.push({
471
- value: {
472
- name: "company",
473
- entityTable: ref.table,
474
- via: {
475
- fkOn: "contact",
476
- column: `${source.name}.${col.name}`
477
- }
478
- },
479
- score: W.fkResolved,
480
- tier: tierFor(W.fkResolved, RELATIONSHIP_TIERS),
481
- reasons: [`foreign key → ${ref.table}.${ref.column}`]
482
- });
483
- }
484
- if (source.columnsMeta?.length) return out.sort((a, b) => b.score - a.score);
485
- const contactFk = firstMatchingColumn(source.columns, COMPANY_FK_HINTS);
486
- if (contactFk) out.push({
487
- value: {
488
- name: "company",
489
- entityTable: companyTables[0]?.name ?? "",
490
- via: {
491
- fkOn: "contact",
492
- column: `${source.name}.${contactFk}`
493
- }
494
- },
495
- score: W.fkNameHint,
496
- tier: tierFor(W.fkNameHint, RELATIONSHIP_TIERS),
497
- reasons: [`column "${contactFk}" looks like a company link`]
498
- });
499
- return out.sort((a, b) => b.score - a.score);
500
- }
501
- const FIELD_TYPE_EXPECTATION = {
502
- name: "text",
503
- email: "text",
504
- phone: "text",
505
- domain: "text",
506
- stage: "text",
507
- status: "text",
508
- subject: "text",
509
- body: "text",
510
- summary: "text",
511
- type: "text",
512
- value: "numeric",
513
- createdAt: "timestamp"
514
- };
515
- function typeFits(field, type) {
516
- const expectation = FIELD_TYPE_EXPECTATION[field];
517
- if (!(expectation && type)) return null;
518
- if (expectation === "text") return isTextLike(type);
519
- if (expectation === "numeric") return isNumericLike(type);
520
- return isTimestampLike(type);
521
- }
522
- function scoreFieldMap(concept, table) {
523
- const lowerToActual = new Map(table.columns.map((c) => [c.toLowerCase(), c]));
524
- const out = [];
525
- for (const { field, candidates, required } of CONCEPT_FIELDS[concept]) for (const candidate of candidates) {
526
- const column = lowerToActual.get(candidate);
527
- if (!column) continue;
528
- let score = W.fieldNameMatch;
529
- const reasons = [`name matches "${column}"`];
530
- const meta = metaFor(table, column);
531
- const fits = typeFits(field, meta?.type);
532
- if (fits === true) {
533
- score += W.typeCompatible;
534
- reasons.push(`type ${meta?.type}`);
535
- } else if (fits === false) {
536
- score += W.typeMismatch;
537
- reasons.push(`type ${meta?.type} does not fit ${field}`);
538
- }
539
- if (required && meta?.nullable === false) {
540
- score += W.requiredNotNull;
541
- reasons.push("not null");
542
- }
543
- out.push({
544
- value: {
545
- field,
546
- column,
547
- required
548
- },
549
- score,
550
- tier: tierFor(score, FIELD_TIERS),
551
- reasons
552
- });
553
- break;
554
- }
555
- return out;
556
- }
557
- function toFieldMap(scored) {
558
- const map = {};
559
- for (const { value } of scored) map[value.field] = value.column;
560
- return map;
561
- }
562
- export { TARGET_CONCEPTS, hasDefiningColumn, hasSensitiveColumns, isFrameworkTable, matchesConcept, requiredFieldsFor, scoreConcepts, scoreFieldMap, scoreRelationships, suggestCursorField, suggestDiscriminatorColumns, toFieldMap, topConcept, validateMapping };
1
+ export { t as TARGET_CONCEPTS, n as hasDefiningColumn, r as hasSensitiveColumns, i as isFrameworkTable, a as isSensitiveColumn, o as matchesConcept, s as requiredFieldsFor, c as scoreConcepts, l as scoreFieldMap, u as scoreRelationships, d as suggestCursorField, f as suggestDiscriminatorColumns, p as toFieldMap, m as topConcept, h as validateMapping } from "./entity-heuristics-DE5ujoHw.mjs";
@@ -1,2 +1,2 @@
1
- import { i as relationshipViaSignature, n as buildFilterFromDiscriminator, r as buildRelationships, t as RelationshipCandidate } from "./mapping-form-Cmf8y-1m.cjs";
1
+ import { i as relationshipViaSignature, n as buildFilterFromDiscriminator, r as buildRelationships, t as RelationshipCandidate } from "./mapping-form-CV7y6qox.cjs";
2
2
  export { RelationshipCandidate, buildFilterFromDiscriminator, buildRelationships, relationshipViaSignature };
@@ -1,2 +1,2 @@
1
- import { i as relationshipViaSignature, n as buildFilterFromDiscriminator, r as buildRelationships, t as RelationshipCandidate } from "./mapping-form-BymksK7h.mjs";
1
+ import { i as relationshipViaSignature, n as buildFilterFromDiscriminator, r as buildRelationships, t as RelationshipCandidate } from "./mapping-form-Bpvgf5b8.mjs";
2
2
  export { RelationshipCandidate, buildFilterFromDiscriminator, buildRelationships, relationshipViaSignature };
@@ -1,4 +1,4 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
- const require_mappings_config = require("./mappings-config-DBG-KnYl.cjs");
2
+ const require_mappings_config = require("./mappings-config-CNxBrbt9.cjs");
3
3
  exports.entitiesToMappings = require_mappings_config.entitiesToMappings;
4
4
  exports.mappingsToEntitiesConfig = require_mappings_config.mappingsToEntitiesConfig;
@@ -1,2 +1,2 @@
1
- import { i as mappingsToEntitiesConfig, n as MappingFromConfig, r as entitiesToMappings, t as EntityMappingRow } from "./mappings-config-Dsz6rcJb.cjs";
1
+ import { i as mappingsToEntitiesConfig, n as MappingFromConfig, r as entitiesToMappings, t as EntityMappingRow } from "./mappings-config-BBppW9fp.cjs";
2
2
  export { EntityMappingRow, MappingFromConfig, entitiesToMappings, mappingsToEntitiesConfig };
@@ -1,2 +1,2 @@
1
- import { i as mappingsToEntitiesConfig, n as MappingFromConfig, r as entitiesToMappings, t as EntityMappingRow } from "./mappings-config-ktJhxmHm.mjs";
1
+ import { i as mappingsToEntitiesConfig, n as MappingFromConfig, r as entitiesToMappings, t as EntityMappingRow } from "./mappings-config-Dmm0H6p_.mjs";
2
2
  export { EntityMappingRow, MappingFromConfig, entitiesToMappings, mappingsToEntitiesConfig };
@@ -1 +1 @@
1
- export { t as entitiesToMappings, n as mappingsToEntitiesConfig } from "./mappings-config-C7FPwrJT.mjs";
1
+ export { t as entitiesToMappings, n as mappingsToEntitiesConfig } from "./mappings-config-D_g20PyS.mjs";
@@ -1,5 +1,5 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
- const require_sync_engine = require("./sync-engine-DBlSP9r2.cjs");
2
+ const require_sync_engine = require("./sync-engine-Di-vF26b.cjs");
3
3
  exports.computeSampleWarnings = require_sync_engine.computeSampleWarnings;
4
4
  exports.isRemovalAction = require_sync_engine.isRemovalAction;
5
5
  exports.previewSync = require_sync_engine.previewSync;
@@ -1,2 +1,2 @@
1
- import { a as PreviewWarning, c as SyncAction, d as computeSampleWarnings, f as isRemovalAction, g as runSync, h as resolveActions, i as PreviewResult, l as SyncResult, m as reconcile, n as MirrorRecord, o as ResolvedMembership, p as previewSync, r as PersistAction, s as SourceRow, t as EntitySyncResult, u as SyncStore } from "./sync-engine-D9ltfqkD.cjs";
1
+ import { a as PreviewWarning, c as SyncAction, d as computeSampleWarnings, f as isRemovalAction, g as runSync, h as resolveActions, i as PreviewResult, l as SyncResult, m as reconcile, n as MirrorRecord, o as ResolvedMembership, p as previewSync, r as PersistAction, s as SourceRow, t as EntitySyncResult, u as SyncStore } from "./sync-engine-C7W0Gkq0.cjs";
2
2
  export { EntitySyncResult, MirrorRecord, PersistAction, PreviewResult, PreviewWarning, ResolvedMembership, SourceRow, SyncAction, SyncResult, SyncStore, computeSampleWarnings, isRemovalAction, previewSync, reconcile, resolveActions, runSync };
@@ -1,2 +1,2 @@
1
- import { a as PreviewWarning, c as SyncAction, d as computeSampleWarnings, f as isRemovalAction, g as runSync, h as resolveActions, i as PreviewResult, l as SyncResult, m as reconcile, n as MirrorRecord, o as ResolvedMembership, p as previewSync, r as PersistAction, s as SourceRow, t as EntitySyncResult, u as SyncStore } from "./sync-engine-C_SwnFgF.mjs";
1
+ import { a as PreviewWarning, c as SyncAction, d as computeSampleWarnings, f as isRemovalAction, g as runSync, h as resolveActions, i as PreviewResult, l as SyncResult, m as reconcile, n as MirrorRecord, o as ResolvedMembership, p as previewSync, r as PersistAction, s as SourceRow, t as EntitySyncResult, u as SyncStore } from "./sync-engine-C9Q2FkR9.mjs";
2
2
  export { EntitySyncResult, MirrorRecord, PersistAction, PreviewResult, PreviewWarning, ResolvedMembership, SourceRow, SyncAction, SyncResult, SyncStore, computeSampleWarnings, isRemovalAction, previewSync, reconcile, resolveActions, runSync };
@@ -1 +1 @@
1
- export { t as computeSampleWarnings, n as isRemovalAction, r as previewSync, i as reconcile, a as resolveActions, o as runSync } from "./sync-engine-BTUoH82k.mjs";
1
+ export { t as computeSampleWarnings, n as isRemovalAction, r as previewSync, i as reconcile, a as resolveActions, o as runSync } from "./sync-engine-CwdLkmch.mjs";
@@ -1,2 +1,2 @@
1
- import { A as UpdateCompanyInput, C as RecordSource, D as TaskFilters, E as TaskEntityType, F as isClosedStageType, M as UpdateDealInput, N as UpdateTaskInput, O as TaskPriority, P as ValueInterval, S as PipelineStageConfig, T as Task, _ as OPEN_STAGE_TYPE, a as Contact, b as PipelineConfig, c as CreateActivityInput, d as CreateDealInput, f as CreateTaskInput, g as Note, h as DealStage, i as CompanyFilters, j as UpdateContactInput, k as TaskStatus, l as CreateCompanyInput, m as Deal, n as ActivityType, o as ContactFilters, p as CrmRole, r as Company, s as ContactStatus, t as Activity, u as CreateContactInput, v as Page, w as StageType, x as PipelineKind, y as PageRequest } from "./types-BtQCi_qP.cjs";
2
- export { Activity, ActivityType, Company, CompanyFilters, Contact, ContactFilters, ContactStatus, CreateActivityInput, CreateCompanyInput, CreateContactInput, CreateDealInput, CreateTaskInput, CrmRole, Deal, DealStage, Note, OPEN_STAGE_TYPE, Page, PageRequest, PipelineConfig, PipelineKind, PipelineStageConfig, RecordSource, StageType, Task, TaskEntityType, TaskFilters, TaskPriority, TaskStatus, UpdateCompanyInput, UpdateContactInput, UpdateDealInput, UpdateTaskInput, ValueInterval, isClosedStageType };
1
+ import { A as TaskStatus, C as PipelineStageConfig, D as TaskEntityType, E as Task, F as ValueInterval, I as isClosedStageType, M as UpdateContactInput, N as UpdateDealInput, O as TaskFilters, P as UpdateTaskInput, S as PipelineKind, T as StageType, _ as Note, a as Contact, b as PageRequest, c as ContactStatus, d as CreateContactInput, f as CreateDealInput, g as DealStage, h as Deal, i as CompanyFilters, j as UpdateCompanyInput, k as TaskPriority, l as CreateActivityInput, m as CrmRole, n as ActivityType, o as ContactFilters, p as CreateTaskInput, r as Company, s as ContactSource, t as Activity, u as CreateCompanyInput, v as OPEN_STAGE_TYPE, w as RecordSource, x as PipelineConfig, y as Page } from "./types-C08UluBS.cjs";
2
+ export { Activity, ActivityType, Company, CompanyFilters, Contact, ContactFilters, ContactSource, ContactStatus, CreateActivityInput, CreateCompanyInput, CreateContactInput, CreateDealInput, CreateTaskInput, CrmRole, Deal, DealStage, Note, OPEN_STAGE_TYPE, Page, PageRequest, PipelineConfig, PipelineKind, PipelineStageConfig, RecordSource, StageType, Task, TaskEntityType, TaskFilters, TaskPriority, TaskStatus, UpdateCompanyInput, UpdateContactInput, UpdateDealInput, UpdateTaskInput, ValueInterval, isClosedStageType };
@@ -1,2 +1,2 @@
1
- import { A as UpdateCompanyInput, C as RecordSource, D as TaskFilters, E as TaskEntityType, F as isClosedStageType, M as UpdateDealInput, N as UpdateTaskInput, O as TaskPriority, P as ValueInterval, S as PipelineStageConfig, T as Task, _ as OPEN_STAGE_TYPE, a as Contact, b as PipelineConfig, c as CreateActivityInput, d as CreateDealInput, f as CreateTaskInput, g as Note, h as DealStage, i as CompanyFilters, j as UpdateContactInput, k as TaskStatus, l as CreateCompanyInput, m as Deal, n as ActivityType, o as ContactFilters, p as CrmRole, r as Company, s as ContactStatus, t as Activity, u as CreateContactInput, v as Page, w as StageType, x as PipelineKind, y as PageRequest } from "./types-CTOl3pAX.mjs";
2
- export { Activity, ActivityType, Company, CompanyFilters, Contact, ContactFilters, ContactStatus, CreateActivityInput, CreateCompanyInput, CreateContactInput, CreateDealInput, CreateTaskInput, CrmRole, Deal, DealStage, Note, OPEN_STAGE_TYPE, Page, PageRequest, PipelineConfig, PipelineKind, PipelineStageConfig, RecordSource, StageType, Task, TaskEntityType, TaskFilters, TaskPriority, TaskStatus, UpdateCompanyInput, UpdateContactInput, UpdateDealInput, UpdateTaskInput, ValueInterval, isClosedStageType };
1
+ import { A as TaskStatus, C as PipelineStageConfig, D as TaskEntityType, E as Task, F as ValueInterval, I as isClosedStageType, M as UpdateContactInput, N as UpdateDealInput, O as TaskFilters, P as UpdateTaskInput, S as PipelineKind, T as StageType, _ as Note, a as Contact, b as PageRequest, c as ContactStatus, d as CreateContactInput, f as CreateDealInput, g as DealStage, h as Deal, i as CompanyFilters, j as UpdateCompanyInput, k as TaskPriority, l as CreateActivityInput, m as CrmRole, n as ActivityType, o as ContactFilters, p as CreateTaskInput, r as Company, s as ContactSource, t as Activity, u as CreateCompanyInput, v as OPEN_STAGE_TYPE, w as RecordSource, x as PipelineConfig, y as Page } from "./types-CZsSYbeC.mjs";
2
+ export { Activity, ActivityType, Company, CompanyFilters, Contact, ContactFilters, ContactSource, ContactStatus, CreateActivityInput, CreateCompanyInput, CreateContactInput, CreateDealInput, CreateTaskInput, CrmRole, Deal, DealStage, Note, OPEN_STAGE_TYPE, Page, PageRequest, PipelineConfig, PipelineKind, PipelineStageConfig, RecordSource, StageType, Task, TaskEntityType, TaskFilters, TaskPriority, TaskStatus, UpdateCompanyInput, UpdateContactInput, UpdateDealInput, UpdateTaskInput, ValueInterval, isClosedStageType };
@@ -1,5 +1,5 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
- const require_view_compiler = require("./view-compiler-Ce_QE3dh.cjs");
2
+ const require_view_compiler = require("./view-compiler-DaOz5QVl.cjs");
3
3
  exports.DEFAULT_VIEW_PREFIX = require_view_compiler.DEFAULT_VIEW_PREFIX;
4
4
  exports.compileEntityView = require_view_compiler.compileEntityView;
5
5
  exports.compileEntityViews = require_view_compiler.compileEntityViews;
@@ -1,2 +1,2 @@
1
- import { a as compileEntityView, c as explainViewExecutionError, i as ExplainResult, n as CompiledView, o as compileEntityViews, r as DEFAULT_VIEW_PREFIX, s as explainEntitiesConfig, t as CompileOptions } from "./view-compiler-D7GLf1n8.cjs";
1
+ import { a as compileEntityView, c as explainViewExecutionError, i as ExplainResult, n as CompiledView, o as compileEntityViews, r as DEFAULT_VIEW_PREFIX, s as explainEntitiesConfig, t as CompileOptions } from "./view-compiler-cXqt4X-c.cjs";
2
2
  export { CompileOptions, CompiledView, DEFAULT_VIEW_PREFIX, ExplainResult, compileEntityView, compileEntityViews, explainEntitiesConfig, explainViewExecutionError };
@@ -1,2 +1,2 @@
1
- import { a as compileEntityView, c as explainViewExecutionError, i as ExplainResult, n as CompiledView, o as compileEntityViews, r as DEFAULT_VIEW_PREFIX, s as explainEntitiesConfig, t as CompileOptions } from "./view-compiler-BZgZisTG.mjs";
1
+ import { a as compileEntityView, c as explainViewExecutionError, i as ExplainResult, n as CompiledView, o as compileEntityViews, r as DEFAULT_VIEW_PREFIX, s as explainEntitiesConfig, t as CompileOptions } from "./view-compiler-M23WiVGG.mjs";
2
2
  export { CompileOptions, CompiledView, DEFAULT_VIEW_PREFIX, ExplainResult, compileEntityView, compileEntityViews, explainEntitiesConfig, explainViewExecutionError };
@@ -1 +1 @@
1
- export { t as DEFAULT_VIEW_PREFIX, n as compileEntityView, r as compileEntityViews, i as explainEntitiesConfig, a as explainViewExecutionError } from "./view-compiler-B8tJ5IGw.mjs";
1
+ export { t as DEFAULT_VIEW_PREFIX, n as compileEntityView, r as compileEntityViews, i as explainEntitiesConfig, a as explainViewExecutionError } from "./view-compiler-CLTi1VL-.mjs";