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