clivly 0.10.9 → 0.11.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 (127) hide show
  1. package/adapter-BWrOtOw5.d.mts +83 -0
  2. package/adapter-Bd5HjLYa.d.cts +83 -0
  3. package/{auth-adapter-CXTiW3Mb.d.cts → auth-adapter-C3BQpc-q.d.cts} +1 -1
  4. package/{auth-adapter-DSuYwv1c.d.mts → auth-adapter-D54ajbl7.d.mts} +1 -1
  5. package/auth-better-auth.d.cts +6 -6
  6. package/auth-better-auth.d.mts +6 -6
  7. package/auth-clerk.d.cts +5 -5
  8. package/auth-clerk.d.mts +5 -5
  9. package/auth-workos.d.cts +5 -5
  10. package/auth-workos.d.mts +5 -5
  11. package/core-adapter.d.cts +1 -1
  12. package/core-adapter.d.mts +1 -1
  13. package/core-auth-adapter.d.cts +1 -1
  14. package/core-auth-adapter.d.mts +1 -1
  15. package/core-drizzle.d.cts +1 -1
  16. package/core-drizzle.d.mts +1 -1
  17. package/core-entity-config.cjs +1 -1
  18. package/core-entity-config.d.cts +1 -1
  19. package/core-entity-config.d.mts +1 -1
  20. package/core-entity-config.mjs +1 -1
  21. package/core-entity-heuristics.d.cts +1 -1
  22. package/core-entity-heuristics.d.mts +1 -1
  23. package/core-mapping-form.d.cts +1 -1
  24. package/core-mapping-form.d.mts +1 -1
  25. package/core-mappings-config.cjs +1 -1
  26. package/core-mappings-config.d.cts +1 -1
  27. package/core-mappings-config.d.mts +1 -1
  28. package/core-mappings-config.mjs +1 -1
  29. package/core-sync-engine.cjs +1 -1
  30. package/core-sync-engine.d.cts +1 -1
  31. package/core-sync-engine.d.mts +1 -1
  32. package/core-sync-engine.mjs +1 -1
  33. package/core-types.d.cts +2 -2
  34. package/core-types.d.mts +2 -2
  35. package/core-view-compiler.cjs +1 -1
  36. package/core-view-compiler.d.cts +1 -1
  37. package/core-view-compiler.d.mts +1 -1
  38. package/core-view-compiler.mjs +1 -1
  39. package/core.cjs +11 -7
  40. package/core.d.cts +10 -10
  41. package/core.d.mts +10 -10
  42. package/core.mjs +8 -8
  43. package/{drizzle-SD8WCvYj.d.cts → drizzle-CiK37zJm.d.cts} +1 -1
  44. package/{drizzle-axugRJ0u.d.mts → drizzle-ehVWLSrN.d.mts} +1 -1
  45. package/drizzle.cjs +2 -2
  46. package/drizzle.d.cts +9 -9
  47. package/drizzle.d.mts +9 -9
  48. package/drizzle.mjs +2 -2
  49. package/{entity-config-w8oMBWf8.d.cts → entity-config-ApnT5j3X.d.cts} +1735 -17
  50. package/{entity-config-C2MfIDL2.cjs → entity-config-BI4RYNKL.cjs} +19 -2
  51. package/{entity-config-w8oMBWf8.d.mts → entity-config-CKcj4-M_.d.mts} +1736 -17
  52. package/{entity-config-bC3DX9f1.mjs → entity-config-Ccfb2IL9.mjs} +28 -3
  53. package/index.cjs +15 -11
  54. package/index.d.cts +10 -11
  55. package/index.d.mts +10 -11
  56. package/index.mjs +15 -11
  57. package/{internal-CHvZMvxC.d.cts → internal-Bjpq7S2G.d.mts} +69 -2
  58. package/{internal-Cz59xMj8.cjs → internal-CRIgf9jS.cjs} +102 -0
  59. package/{internal-WximMGmH.d.mts → internal-D9kqkhPs.d.cts} +69 -2
  60. package/internal-adapter.d.cts +1 -1
  61. package/internal-adapter.d.mts +1 -1
  62. package/internal-auth-adapter.d.cts +1 -1
  63. package/internal-auth-adapter.d.mts +1 -1
  64. package/internal-drizzle.d.cts +1 -1
  65. package/internal-drizzle.d.mts +1 -1
  66. package/internal-entity-config.cjs +1 -1
  67. package/internal-entity-config.d.cts +1 -1
  68. package/internal-entity-config.d.mts +1 -1
  69. package/internal-entity-config.mjs +1 -1
  70. package/internal-entity-heuristics.cjs +43 -24
  71. package/internal-entity-heuristics.d.cts +21 -21
  72. package/internal-entity-heuristics.d.mts +21 -21
  73. package/internal-entity-heuristics.mjs +43 -24
  74. package/internal-mapping-form.d.cts +1 -1
  75. package/internal-mapping-form.d.mts +1 -1
  76. package/internal-mappings-config.cjs +1 -1
  77. package/internal-mappings-config.d.cts +1 -1
  78. package/internal-mappings-config.d.mts +1 -1
  79. package/internal-mappings-config.mjs +1 -1
  80. package/internal-sync-engine.cjs +1 -1
  81. package/internal-sync-engine.d.cts +1 -1
  82. package/internal-sync-engine.d.mts +1 -1
  83. package/internal-sync-engine.mjs +1 -1
  84. package/internal-types.d.cts +2 -2
  85. package/internal-types.d.mts +2 -2
  86. package/{internal-Bgiimp5D.mjs → internal-v6P9MZY1.mjs} +79 -1
  87. package/internal-view-compiler.cjs +1 -1
  88. package/internal-view-compiler.d.cts +1 -1
  89. package/internal-view-compiler.d.mts +1 -1
  90. package/internal-view-compiler.mjs +1 -1
  91. package/internal.cjs +11 -7
  92. package/internal.d.cts +10 -10
  93. package/internal.d.mts +10 -10
  94. package/internal.mjs +8 -8
  95. package/{mapping-form-BsTxv8w3.d.cts → mapping-form-Btn-7gzv.d.mts} +1 -1
  96. package/{mapping-form-OTFwr1sN.d.mts → mapping-form-XsLLCqW_.d.cts} +1 -1
  97. package/{mappings-config-Dpv08-x4.cjs → mappings-config-BCsRLohT.cjs} +2 -1
  98. package/{mappings-config-CRSL9dzw.mjs → mappings-config-CwQNQ6bA.mjs} +2 -1
  99. package/{mappings-config-DbznSjTX.d.cts → mappings-config-D6_oCi2Q.d.mts} +3 -1
  100. package/{mappings-config-SXu_zlmp.d.mts → mappings-config-iJzbcUMp.d.cts} +3 -1
  101. package/{namespace-probe-C3xMOqWE.d.cts → namespace-probe-C5RLl74M.d.cts} +1 -1
  102. package/{namespace-probe-BmxtnOfc.d.mts → namespace-probe-CNQKSmxz.d.mts} +1 -1
  103. package/package.json +1 -1
  104. package/{projection-Dz6_i1-w.cjs → projection-BELgANG2.cjs} +32 -23
  105. package/{projection-CSGJbZlZ.mjs → projection-DvNewmI1.mjs} +32 -23
  106. package/{projection-sql-CbXCKt3s.cjs → projection-sql-DuCtFE9t.cjs} +1 -1
  107. package/{projection-sql-iHoiYr1R.mjs → projection-sql-DweUaWRc.mjs} +1 -1
  108. package/{sdk-BIYu0N3V.cjs → sdk-BvGSxBQc.cjs} +3 -3
  109. package/{sdk-DofHordq.mjs → sdk-C-Pjxj2y.mjs} +3 -3
  110. package/sdk.cjs +2 -2
  111. package/sdk.d.cts +10 -10
  112. package/sdk.d.mts +10 -10
  113. package/sdk.mjs +2 -2
  114. package/{sync-engine-CUKWXUv7.d.mts → sync-engine--M9EaONC.d.mts} +2 -2
  115. package/{sync-engine-CTSIcLlZ.mjs → sync-engine-Df2MCs_n.mjs} +1 -1
  116. package/{sync-engine-B0FT1ax6.cjs → sync-engine-Dwm_KDUS.cjs} +1 -1
  117. package/{sync-engine-D2YlIHZB.d.cts → sync-engine-V3_UutGv.d.cts} +2 -2
  118. package/{types-Cq1uHUKp.d.mts → types-D08UzDqe.d.cts} +69 -2
  119. package/{types-Cq1uHUKp.d.cts → types-D08UzDqe.d.mts} +69 -2
  120. package/{view-compiler-BzKk8nY3.mjs → view-compiler-C-6RydKK.mjs} +2 -2
  121. package/{view-compiler-BO4CKamn.d.cts → view-compiler-Cq8apvZ4.d.cts} +1 -1
  122. package/{view-compiler-iEwUOuba.d.mts → view-compiler-CwKVoK1w.d.mts} +1 -1
  123. package/{view-compiler-ZKZbd3SK.cjs → view-compiler-xiwm5iar.cjs} +2 -2
  124. package/vite.d.cts +4 -5
  125. package/vite.d.mts +4 -5
  126. package/adapter-1TN0zohk.d.cts +0 -45
  127. package/adapter-uxirB88i.d.mts +0 -45
@@ -1,5 +1,5 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
- const require_entity_config = require("./entity-config-C2MfIDL2.cjs");
2
+ const require_entity_config = require("./entity-config-BI4RYNKL.cjs");
3
3
  const require_mapping_score = require("./mapping-score-CaB3F4Uu.cjs");
4
4
  //#region ../core/src/entity-heuristics.ts
5
5
  const TARGET_CONCEPTS = [
@@ -95,23 +95,39 @@ const TABLE_PATTERNS = [
95
95
  }
96
96
  ];
97
97
  const CONCEPT_FIELDS = {
98
- contact: [{
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
- field: "email",
112
- candidates: ["email", "email_address"],
113
- required: true
114
- }],
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
+ ],
115
131
  company: [{
116
132
  field: "name",
117
133
  candidates: [
@@ -363,12 +379,14 @@ function scoreConcepts(table) {
363
379
  score += require_mapping_score.W.hasPrimaryKey;
364
380
  reasons.push("has primary key");
365
381
  }
366
- if (table.rowCount !== void 0) if (table.rowCount === 0) {
367
- score += require_mapping_score.W.emptyTable;
368
- reasons.push("table is empty");
369
- } else {
370
- score += require_mapping_score.W.hasRows;
371
- reasons.push(`${table.rowCount.toLocaleString("en-US")} rows`);
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
+ }
372
390
  }
373
391
  out.push({
374
392
  value: concept,
@@ -484,6 +502,7 @@ function scoreRelationships(source, allTables) {
484
502
  const FIELD_TYPE_EXPECTATION = {
485
503
  name: "text",
486
504
  email: "text",
505
+ phone: "text",
487
506
  domain: "text",
488
507
  stage: "text",
489
508
  status: "text",
@@ -1,13 +1,13 @@
1
- import { p as DiscoveredColumnMeta } from "./entity-config-w8oMBWf8.cjs";
1
+ import { p as DiscoveredColumnMeta } from "./entity-config-ApnT5j3X.cjs";
2
2
  import { a as Scored } from "./mapping-score-D7Gzg7Ii.cjs";
3
3
  //#region ../core/src/entity-heuristics.d.ts
4
- declare const TARGET_CONCEPTS: readonly ["contact", "company", "deal", "activity", "conversation", "note"];
5
- type TargetConcept = (typeof TARGET_CONCEPTS)[number];
6
- declare function suggestCursorField(columnKeys: string[]): string | null;
7
- declare function matchesConcept(tableName: string, concept: TargetConcept): {
4
+ export declare const TARGET_CONCEPTS: readonly ["contact", "company", "deal", "activity", "conversation", "note"];
5
+ export type TargetConcept = (typeof TARGET_CONCEPTS)[number];
6
+ export declare function suggestCursorField(columnKeys: string[]): string | null;
7
+ export declare function matchesConcept(tableName: string, concept: TargetConcept): {
8
8
  exact: boolean;
9
9
  } | null;
10
- interface ScoredTable {
10
+ export interface ScoredTable {
11
11
  columns: string[];
12
12
  columnsMeta?: DiscoveredColumnMeta[];
13
13
  name: string;
@@ -18,7 +18,7 @@ interface ScoredTable {
18
18
  * and from bulk apply, so one click can never map an auth table into the CRM.
19
19
  * They stay manually selectable — an explicit, informed choice is legitimate.
20
20
  */
21
- declare function hasSensitiveColumns(columns: string[]): boolean;
21
+ export declare function hasSensitiveColumns(columns: string[]): boolean;
22
22
  /**
23
23
  * Is this table one your auth library created, rather than one you wrote?
24
24
  *
@@ -26,20 +26,20 @@ declare function hasSensitiveColumns(columns: string[]): boolean;
26
26
  * concept. Never to exclude them: mapping `user` as the contact entity is
27
27
  * legitimate for plenty of apps, and it stays selectable.
28
28
  */
29
- declare function isFrameworkTable(name: string): boolean;
30
- declare function hasDefiningColumn(concept: TargetConcept, columns: string[]): boolean;
31
- declare function scoreConcepts(table: ScoredTable): Scored<TargetConcept>[];
32
- declare function topConcept(table: ScoredTable): {
29
+ export declare function isFrameworkTable(name: string): boolean;
30
+ export declare function hasDefiningColumn(concept: TargetConcept, columns: string[]): boolean;
31
+ export declare function scoreConcepts(table: ScoredTable): Scored<TargetConcept>[];
32
+ export declare function topConcept(table: ScoredTable): {
33
33
  best: Scored<TargetConcept>;
34
34
  ambiguous: boolean;
35
35
  } | null;
36
- declare function requiredFieldsFor(concept: TargetConcept | "custom"): string[];
37
- declare function validateMapping(requiredFields: string[], fieldMap: Record<string, string>): {
36
+ export declare function requiredFieldsFor(concept: TargetConcept | "custom"): string[];
37
+ export declare function validateMapping(requiredFields: string[], fieldMap: Record<string, string>): {
38
38
  valid: boolean;
39
39
  missing: string[];
40
40
  };
41
- declare function suggestDiscriminatorColumns(columns: string[]): string[];
42
- type SuggestedVia = {
41
+ export declare function suggestDiscriminatorColumns(columns: string[]): string[];
42
+ export type SuggestedVia = {
43
43
  fkOn: "company" | "contact";
44
44
  column: string;
45
45
  } | {
@@ -47,7 +47,7 @@ type SuggestedVia = {
47
47
  localKey: string;
48
48
  foreignKey: string;
49
49
  };
50
- interface RelationshipSuggestion {
50
+ export interface RelationshipSuggestion {
51
51
  /** The related host table. */
52
52
  entityTable: string;
53
53
  /** Suggested relationship name (defaults to the related concept). */
@@ -60,13 +60,13 @@ interface RelationshipSuggestion {
60
60
  * that scores highest. Without metadata (v1 hosts) we fall back to the legacy
61
61
  * FK-name hints at a lower tier.
62
62
  */
63
- declare function scoreRelationships(source: ScoredTable, allTables: ScoredTable[]): Scored<RelationshipSuggestion>[];
64
- interface FieldSuggestion {
63
+ export declare function scoreRelationships(source: ScoredTable, allTables: ScoredTable[]): Scored<RelationshipSuggestion>[];
64
+ export interface FieldSuggestion {
65
65
  column: string;
66
66
  field: string;
67
67
  required: boolean;
68
68
  }
69
- declare function scoreFieldMap(concept: TargetConcept, table: ScoredTable): Scored<FieldSuggestion>[];
70
- declare function toFieldMap(scored: Scored<FieldSuggestion>[]): Record<string, string>;
69
+ export declare function scoreFieldMap(concept: TargetConcept, table: ScoredTable): Scored<FieldSuggestion>[];
70
+ export declare function toFieldMap(scored: Scored<FieldSuggestion>[]): Record<string, string>;
71
71
  //#endregion
72
- export { type DiscoveredColumnMeta, FieldSuggestion, RelationshipSuggestion, ScoredTable, SuggestedVia, TARGET_CONCEPTS, TargetConcept, hasDefiningColumn, hasSensitiveColumns, isFrameworkTable, matchesConcept, requiredFieldsFor, scoreConcepts, scoreFieldMap, scoreRelationships, suggestCursorField, suggestDiscriminatorColumns, toFieldMap, topConcept, validateMapping };
72
+ export type { DiscoveredColumnMeta };
@@ -1,13 +1,13 @@
1
- import { p as DiscoveredColumnMeta } from "./entity-config-w8oMBWf8.mjs";
1
+ import { p as DiscoveredColumnMeta } from "./entity-config-CKcj4-M_.mjs";
2
2
  import { a as Scored } from "./mapping-score-D7Gzg7Ii.mjs";
3
3
  //#region ../core/src/entity-heuristics.d.ts
4
- declare const TARGET_CONCEPTS: readonly ["contact", "company", "deal", "activity", "conversation", "note"];
5
- type TargetConcept = (typeof TARGET_CONCEPTS)[number];
6
- declare function suggestCursorField(columnKeys: string[]): string | null;
7
- declare function matchesConcept(tableName: string, concept: TargetConcept): {
4
+ export declare const TARGET_CONCEPTS: readonly ["contact", "company", "deal", "activity", "conversation", "note"];
5
+ export type TargetConcept = (typeof TARGET_CONCEPTS)[number];
6
+ export declare function suggestCursorField(columnKeys: string[]): string | null;
7
+ export declare function matchesConcept(tableName: string, concept: TargetConcept): {
8
8
  exact: boolean;
9
9
  } | null;
10
- interface ScoredTable {
10
+ export interface ScoredTable {
11
11
  columns: string[];
12
12
  columnsMeta?: DiscoveredColumnMeta[];
13
13
  name: string;
@@ -18,7 +18,7 @@ interface ScoredTable {
18
18
  * and from bulk apply, so one click can never map an auth table into the CRM.
19
19
  * They stay manually selectable — an explicit, informed choice is legitimate.
20
20
  */
21
- declare function hasSensitiveColumns(columns: string[]): boolean;
21
+ export declare function hasSensitiveColumns(columns: string[]): boolean;
22
22
  /**
23
23
  * Is this table one your auth library created, rather than one you wrote?
24
24
  *
@@ -26,20 +26,20 @@ declare function hasSensitiveColumns(columns: string[]): boolean;
26
26
  * concept. Never to exclude them: mapping `user` as the contact entity is
27
27
  * legitimate for plenty of apps, and it stays selectable.
28
28
  */
29
- declare function isFrameworkTable(name: string): boolean;
30
- declare function hasDefiningColumn(concept: TargetConcept, columns: string[]): boolean;
31
- declare function scoreConcepts(table: ScoredTable): Scored<TargetConcept>[];
32
- declare function topConcept(table: ScoredTable): {
29
+ export declare function isFrameworkTable(name: string): boolean;
30
+ export declare function hasDefiningColumn(concept: TargetConcept, columns: string[]): boolean;
31
+ export declare function scoreConcepts(table: ScoredTable): Scored<TargetConcept>[];
32
+ export declare function topConcept(table: ScoredTable): {
33
33
  best: Scored<TargetConcept>;
34
34
  ambiguous: boolean;
35
35
  } | null;
36
- declare function requiredFieldsFor(concept: TargetConcept | "custom"): string[];
37
- declare function validateMapping(requiredFields: string[], fieldMap: Record<string, string>): {
36
+ export declare function requiredFieldsFor(concept: TargetConcept | "custom"): string[];
37
+ export declare function validateMapping(requiredFields: string[], fieldMap: Record<string, string>): {
38
38
  valid: boolean;
39
39
  missing: string[];
40
40
  };
41
- declare function suggestDiscriminatorColumns(columns: string[]): string[];
42
- type SuggestedVia = {
41
+ export declare function suggestDiscriminatorColumns(columns: string[]): string[];
42
+ export type SuggestedVia = {
43
43
  fkOn: "company" | "contact";
44
44
  column: string;
45
45
  } | {
@@ -47,7 +47,7 @@ type SuggestedVia = {
47
47
  localKey: string;
48
48
  foreignKey: string;
49
49
  };
50
- interface RelationshipSuggestion {
50
+ export interface RelationshipSuggestion {
51
51
  /** The related host table. */
52
52
  entityTable: string;
53
53
  /** Suggested relationship name (defaults to the related concept). */
@@ -60,13 +60,13 @@ interface RelationshipSuggestion {
60
60
  * that scores highest. Without metadata (v1 hosts) we fall back to the legacy
61
61
  * FK-name hints at a lower tier.
62
62
  */
63
- declare function scoreRelationships(source: ScoredTable, allTables: ScoredTable[]): Scored<RelationshipSuggestion>[];
64
- interface FieldSuggestion {
63
+ export declare function scoreRelationships(source: ScoredTable, allTables: ScoredTable[]): Scored<RelationshipSuggestion>[];
64
+ export interface FieldSuggestion {
65
65
  column: string;
66
66
  field: string;
67
67
  required: boolean;
68
68
  }
69
- declare function scoreFieldMap(concept: TargetConcept, table: ScoredTable): Scored<FieldSuggestion>[];
70
- declare function toFieldMap(scored: Scored<FieldSuggestion>[]): Record<string, string>;
69
+ export declare function scoreFieldMap(concept: TargetConcept, table: ScoredTable): Scored<FieldSuggestion>[];
70
+ export declare function toFieldMap(scored: Scored<FieldSuggestion>[]): Record<string, string>;
71
71
  //#endregion
72
- export { type DiscoveredColumnMeta, FieldSuggestion, RelationshipSuggestion, ScoredTable, SuggestedVia, TARGET_CONCEPTS, TargetConcept, hasDefiningColumn, hasSensitiveColumns, isFrameworkTable, matchesConcept, requiredFieldsFor, scoreConcepts, scoreFieldMap, scoreRelationships, suggestCursorField, suggestDiscriminatorColumns, toFieldMap, topConcept, validateMapping };
72
+ export type { DiscoveredColumnMeta };
@@ -1,4 +1,4 @@
1
- import { a as MATERIALIZING_CONCEPTS } from "./entity-config-bC3DX9f1.mjs";
1
+ import { a as MATERIALIZING_CONCEPTS } from "./entity-config-Ccfb2IL9.mjs";
2
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-C68uAqGB.mjs";
3
3
  //#region ../core/src/entity-heuristics.ts
4
4
  const TARGET_CONCEPTS = [
@@ -94,23 +94,39 @@ const TABLE_PATTERNS = [
94
94
  }
95
95
  ];
96
96
  const CONCEPT_FIELDS = {
97
- contact: [{
98
- field: "name",
99
- candidates: [
100
- "name",
101
- "full_name",
102
- "fullname",
103
- "display_name",
104
- "first_name",
105
- "firstname",
106
- "given_name"
107
- ],
108
- required: false
109
- }, {
110
- field: "email",
111
- candidates: ["email", "email_address"],
112
- required: true
113
- }],
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
+ ],
114
130
  company: [{
115
131
  field: "name",
116
132
  candidates: [
@@ -362,12 +378,14 @@ function scoreConcepts(table) {
362
378
  score += W.hasPrimaryKey;
363
379
  reasons.push("has primary key");
364
380
  }
365
- if (table.rowCount !== void 0) if (table.rowCount === 0) {
366
- score += W.emptyTable;
367
- reasons.push("table is empty");
368
- } else {
369
- score += W.hasRows;
370
- reasons.push(`${table.rowCount.toLocaleString("en-US")} rows`);
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
+ }
371
389
  }
372
390
  out.push({
373
391
  value: concept,
@@ -483,6 +501,7 @@ function scoreRelationships(source, allTables) {
483
501
  const FIELD_TYPE_EXPECTATION = {
484
502
  name: "text",
485
503
  email: "text",
504
+ phone: "text",
486
505
  domain: "text",
487
506
  stage: "text",
488
507
  status: "text",
@@ -1,2 +1,2 @@
1
- import { i as relationshipViaSignature, n as buildFilterFromDiscriminator, r as buildRelationships, t as RelationshipCandidate } from "./mapping-form-BsTxv8w3.cjs";
1
+ import { i as relationshipViaSignature, n as buildFilterFromDiscriminator, r as buildRelationships, t as RelationshipCandidate } from "./mapping-form-XsLLCqW_.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-OTFwr1sN.mjs";
1
+ import { i as relationshipViaSignature, n as buildFilterFromDiscriminator, r as buildRelationships, t as RelationshipCandidate } from "./mapping-form-Btn-7gzv.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-Dpv08-x4.cjs");
2
+ const require_mappings_config = require("./mappings-config-BCsRLohT.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-DbznSjTX.cjs";
1
+ import { i as mappingsToEntitiesConfig, n as MappingFromConfig, r as entitiesToMappings, t as EntityMappingRow } from "./mappings-config-iJzbcUMp.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-SXu_zlmp.mjs";
1
+ import { i as mappingsToEntitiesConfig, n as MappingFromConfig, r as entitiesToMappings, t as EntityMappingRow } from "./mappings-config-D6_oCi2Q.mjs";
2
2
  export { EntityMappingRow, MappingFromConfig, entitiesToMappings, mappingsToEntitiesConfig };
@@ -1,2 +1,2 @@
1
- import { n as mappingsToEntitiesConfig, t as entitiesToMappings } from "./mappings-config-CRSL9dzw.mjs";
1
+ import { n as mappingsToEntitiesConfig, t as entitiesToMappings } from "./mappings-config-CwQNQ6bA.mjs";
2
2
  export { entitiesToMappings, mappingsToEntitiesConfig };
@@ -1,5 +1,5 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
- const require_sync_engine = require("./sync-engine-B0FT1ax6.cjs");
2
+ const require_sync_engine = require("./sync-engine-Dwm_KDUS.cjs");
3
3
  exports.computeSampleWarnings = require_sync_engine.computeSampleWarnings;
4
4
  exports.previewSync = require_sync_engine.previewSync;
5
5
  exports.reconcile = require_sync_engine.reconcile;
@@ -1,2 +1,2 @@
1
- import { a as PreviewWarning, c as SyncResult, d as previewSync, f as reconcile, i as PreviewResult, l as SyncStore, n as MirrorRecord, o as SourceRow, p as runSync, r as PersistAction, s as SyncAction, t as EntitySyncResult, u as computeSampleWarnings } from "./sync-engine-D2YlIHZB.cjs";
1
+ import { a as PreviewWarning, c as SyncResult, d as previewSync, f as reconcile, i as PreviewResult, l as SyncStore, n as MirrorRecord, o as SourceRow, p as runSync, r as PersistAction, s as SyncAction, t as EntitySyncResult, u as computeSampleWarnings } from "./sync-engine-V3_UutGv.cjs";
2
2
  export { EntitySyncResult, MirrorRecord, PersistAction, PreviewResult, PreviewWarning, SourceRow, SyncAction, SyncResult, SyncStore, computeSampleWarnings, previewSync, reconcile, runSync };
@@ -1,2 +1,2 @@
1
- import { a as PreviewWarning, c as SyncResult, d as previewSync, f as reconcile, i as PreviewResult, l as SyncStore, n as MirrorRecord, o as SourceRow, p as runSync, r as PersistAction, s as SyncAction, t as EntitySyncResult, u as computeSampleWarnings } from "./sync-engine-CUKWXUv7.mjs";
1
+ import { a as PreviewWarning, c as SyncResult, d as previewSync, f as reconcile, i as PreviewResult, l as SyncStore, n as MirrorRecord, o as SourceRow, p as runSync, r as PersistAction, s as SyncAction, t as EntitySyncResult, u as computeSampleWarnings } from "./sync-engine--M9EaONC.mjs";
2
2
  export { EntitySyncResult, MirrorRecord, PersistAction, PreviewResult, PreviewWarning, SourceRow, SyncAction, SyncResult, SyncStore, computeSampleWarnings, previewSync, reconcile, runSync };
@@ -1,2 +1,2 @@
1
- import { i as runSync, n as previewSync, r as reconcile, t as computeSampleWarnings } from "./sync-engine-CTSIcLlZ.mjs";
1
+ import { i as runSync, n as previewSync, r as reconcile, t as computeSampleWarnings } from "./sync-engine-Df2MCs_n.mjs";
2
2
  export { computeSampleWarnings, previewSync, reconcile, runSync };
@@ -1,2 +1,2 @@
1
- import { A as ValueInterval, C as TaskEntityType, D as UpdateContactInput, E as TaskStatus, O as UpdateDealInput, S as Task, T as TaskPriority, _ as PipelineConfig, a as ContactFilters, b as RecordSource, c as CreateCompanyInput, d as CreateTaskInput, f as CrmRole, g as OPEN_STAGE_TYPE, h as Note, i as Contact, j as isClosedStageType, k as UpdateTaskInput, l as CreateContactInput, m as DealStage, n as ActivityType, o as ContactStatus, p as Deal, r as Company, s as CreateActivityInput, t as Activity, u as CreateDealInput, v as PipelineKind, w as TaskFilters, x as StageType, y as PipelineStageConfig } from "./types-Cq1uHUKp.cjs";
2
- export { Activity, ActivityType, Company, Contact, ContactFilters, ContactStatus, CreateActivityInput, CreateCompanyInput, CreateContactInput, CreateDealInput, CreateTaskInput, CrmRole, Deal, DealStage, Note, OPEN_STAGE_TYPE, PipelineConfig, PipelineKind, PipelineStageConfig, RecordSource, StageType, Task, TaskEntityType, TaskFilters, TaskPriority, TaskStatus, UpdateContactInput, UpdateDealInput, UpdateTaskInput, ValueInterval, isClosedStageType };
1
+ import { A as UpdateDealInput, C as Task, D as TaskStatus, E as TaskPriority, M as ValueInterval, N as isClosedStageType, O as UpdateCompanyInput, S as StageType, T as TaskFilters, _ as OPEN_STAGE_TYPE, a as Contact, b as PipelineStageConfig, c as CreateActivityInput, d as CreateDealInput, f as CreateTaskInput, g as Note, h as DealStage, i as CompanyFilters, j as UpdateTaskInput, k as UpdateContactInput, 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 PipelineConfig, w as TaskEntityType, x as RecordSource, y as PipelineKind } from "./types-D08UzDqe.cjs";
2
+ export { Activity, ActivityType, Company, CompanyFilters, Contact, ContactFilters, ContactStatus, CreateActivityInput, CreateCompanyInput, CreateContactInput, CreateDealInput, CreateTaskInput, CrmRole, Deal, DealStage, Note, OPEN_STAGE_TYPE, PipelineConfig, PipelineKind, PipelineStageConfig, RecordSource, StageType, Task, TaskEntityType, TaskFilters, TaskPriority, TaskStatus, UpdateCompanyInput, UpdateContactInput, UpdateDealInput, UpdateTaskInput, ValueInterval, isClosedStageType };
@@ -1,2 +1,2 @@
1
- import { A as ValueInterval, C as TaskEntityType, D as UpdateContactInput, E as TaskStatus, O as UpdateDealInput, S as Task, T as TaskPriority, _ as PipelineConfig, a as ContactFilters, b as RecordSource, c as CreateCompanyInput, d as CreateTaskInput, f as CrmRole, g as OPEN_STAGE_TYPE, h as Note, i as Contact, j as isClosedStageType, k as UpdateTaskInput, l as CreateContactInput, m as DealStage, n as ActivityType, o as ContactStatus, p as Deal, r as Company, s as CreateActivityInput, t as Activity, u as CreateDealInput, v as PipelineKind, w as TaskFilters, x as StageType, y as PipelineStageConfig } from "./types-Cq1uHUKp.mjs";
2
- export { Activity, ActivityType, Company, Contact, ContactFilters, ContactStatus, CreateActivityInput, CreateCompanyInput, CreateContactInput, CreateDealInput, CreateTaskInput, CrmRole, Deal, DealStage, Note, OPEN_STAGE_TYPE, PipelineConfig, PipelineKind, PipelineStageConfig, RecordSource, StageType, Task, TaskEntityType, TaskFilters, TaskPriority, TaskStatus, UpdateContactInput, UpdateDealInput, UpdateTaskInput, ValueInterval, isClosedStageType };
1
+ import { A as UpdateDealInput, C as Task, D as TaskStatus, E as TaskPriority, M as ValueInterval, N as isClosedStageType, O as UpdateCompanyInput, S as StageType, T as TaskFilters, _ as OPEN_STAGE_TYPE, a as Contact, b as PipelineStageConfig, c as CreateActivityInput, d as CreateDealInput, f as CreateTaskInput, g as Note, h as DealStage, i as CompanyFilters, j as UpdateTaskInput, k as UpdateContactInput, 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 PipelineConfig, w as TaskEntityType, x as RecordSource, y as PipelineKind } from "./types-D08UzDqe.mjs";
2
+ export { Activity, ActivityType, Company, CompanyFilters, Contact, ContactFilters, ContactStatus, CreateActivityInput, CreateCompanyInput, CreateContactInput, CreateDealInput, CreateTaskInput, CrmRole, Deal, DealStage, Note, OPEN_STAGE_TYPE, PipelineConfig, PipelineKind, PipelineStageConfig, RecordSource, StageType, Task, TaskEntityType, TaskFilters, TaskPriority, TaskStatus, UpdateCompanyInput, UpdateContactInput, UpdateDealInput, UpdateTaskInput, ValueInterval, isClosedStageType };
@@ -1,3 +1,81 @@
1
+ //#region ../core/src/host-owned-fields.ts
2
+ /**
3
+ * Which fields a CRM record lets a user edit.
4
+ *
5
+ * A record synced from the host app carries a `sourceRef`. Its identity fields
6
+ * are rewritten from the host view on every sync run, so an edit to one would
7
+ * be silently reverted minutes later — the user sees their change accepted,
8
+ * then gone, with nothing explaining why. That is worse than refusing it.
9
+ *
10
+ * So host-owned fields are rejected at the API, not merely disabled in the UI:
11
+ * the UI is not the security boundary, and the SDK and any future public API
12
+ * reach the same routers.
13
+ *
14
+ * Records created inside the CRM have no `sourceRef` and are fully editable —
15
+ * nothing else owns them.
16
+ *
17
+ * This is the cheap half of a capability matrix. It answers "may a user write
18
+ * this?" but not "may the sync engine write this?", which stays implicit
19
+ * because sync bypasses these routers entirely. An override model (the
20
+ * `stageOverrideAt` pattern on `crm_deals`) can replace this later without
21
+ * changing callers.
22
+ */
23
+ /** Contact fields the host view owns when the row is synced. */
24
+ const HOST_OWNED_CONTACT_FIELDS = ["email", "name"];
25
+ /**
26
+ * Company fields the host view owns when the row is synced.
27
+ *
28
+ * `email` and `phone` joined this list in the same change that made them
29
+ * mappable (migration 0048). They are not identity fields, but ownership here
30
+ * follows what sync rewrites, not what feels identity-like: both flow from the
31
+ * host view on every run, exactly as `email` does for contacts above. Widening
32
+ * `CANONICAL_FIELDS.company` without widening this list is the specific bug
33
+ * this module's doc comment calls worse than refusing the edit.
34
+ *
35
+ * `primaryContactId` is deliberately absent: it is a CRM-side judgement about
36
+ * who to talk to, never sourced from the host, so it stays editable on synced
37
+ * rows.
38
+ */
39
+ const HOST_OWNED_COMPANY_FIELDS = [
40
+ "domain",
41
+ "name",
42
+ "email",
43
+ "phone"
44
+ ];
45
+ /**
46
+ * True when the record is owned by a host view rather than by the CRM.
47
+ *
48
+ * Deliberately keyed on `sourceRef` and not `entityRole`: `entityRole` is a
49
+ * mapping label that can be absent on a synced row, while `sourceRef` is the
50
+ * identity the sync engine reconciles against and is set for exactly the rows
51
+ * sync will rewrite.
52
+ */
53
+ function isHostOwned(record) {
54
+ return Boolean(record.sourceRef);
55
+ }
56
+ function rejectedFields(record, patch, owned) {
57
+ if (!isHostOwned(record)) return [];
58
+ return owned.filter((field) => patch[field] !== void 0);
59
+ }
60
+ /**
61
+ * Host-owned contact fields this patch would change, or `[]` when the patch is
62
+ * allowed. Callers turn a non-empty result into a 400 naming the fields.
63
+ */
64
+ function rejectedContactFields(contact, patch) {
65
+ return rejectedFields(contact, patch, HOST_OWNED_CONTACT_FIELDS);
66
+ }
67
+ /** Host-owned company fields this patch would change, or `[]`. */
68
+ function rejectedCompanyFields(company, patch) {
69
+ return rejectedFields(company, patch, HOST_OWNED_COMPANY_FIELDS);
70
+ }
71
+ /**
72
+ * The message shown when a write is refused. Names the fields and says where
73
+ * they come from, so the reason is actionable rather than a bare "forbidden".
74
+ */
75
+ function hostOwnedFieldMessage(fields) {
76
+ return `The ${fields.join(", ")} ${fields.length > 1 ? "fields are" : "field is"} synced from your app and cannot be edited here. Change it in your app and it will update on the next sync.`;
77
+ }
78
+ //#endregion
1
79
  //#region ../core/src/slug.ts
2
80
  /**
3
81
  * The one `slugify`.
@@ -141,4 +219,4 @@ function evaluateStage(rules, fields, mappedFields) {
141
219
  return null;
142
220
  }
143
221
  //#endregion
144
- export { toObjectTypeSlug as i, matchesCondition as n, slugify as r, evaluateStage as t };
222
+ export { hostOwnedFieldMessage as a, rejectedContactFields as c, toObjectTypeSlug as i, matchesCondition as n, isHostOwned as o, slugify as r, rejectedCompanyFields as s, evaluateStage as t };
@@ -1,5 +1,5 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
- const require_view_compiler = require("./view-compiler-ZKZbd3SK.cjs");
2
+ const require_view_compiler = require("./view-compiler-xiwm5iar.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-BO4CKamn.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-Cq8apvZ4.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-iEwUOuba.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-CwKVoK1w.mjs";
2
2
  export { CompileOptions, CompiledView, DEFAULT_VIEW_PREFIX, ExplainResult, compileEntityView, compileEntityViews, explainEntitiesConfig, explainViewExecutionError };
@@ -1,2 +1,2 @@
1
- import { a as explainViewExecutionError, i as explainEntitiesConfig, n as compileEntityView, r as compileEntityViews, t as DEFAULT_VIEW_PREFIX } from "./view-compiler-BzKk8nY3.mjs";
1
+ import { a as explainViewExecutionError, i as explainEntitiesConfig, n as compileEntityView, r as compileEntityViews, t as DEFAULT_VIEW_PREFIX } from "./view-compiler-C-6RydKK.mjs";
2
2
  export { DEFAULT_VIEW_PREFIX, compileEntityView, compileEntityViews, explainEntitiesConfig, explainViewExecutionError };
package/internal.cjs CHANGED
@@ -1,13 +1,13 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
- const require_projection = require("./projection-Dz6_i1-w.cjs");
3
- const require_entity_config = require("./entity-config-C2MfIDL2.cjs");
4
- const require_mappings_config = require("./mappings-config-Dpv08-x4.cjs");
2
+ const require_projection = require("./projection-BELgANG2.cjs");
3
+ const require_entity_config = require("./entity-config-BI4RYNKL.cjs");
4
+ const require_mappings_config = require("./mappings-config-BCsRLohT.cjs");
5
5
  const require_auth_adapter = require("./auth-adapter-CiEXcweZ.cjs");
6
+ const require_internal = require("./internal-CRIgf9jS.cjs");
6
7
  const require_mapping_form = require("./mapping-form-BpfON_ME.cjs");
7
- const require_projection_sql = require("./projection-sql-CbXCKt3s.cjs");
8
- const require_internal = require("./internal-Cz59xMj8.cjs");
9
- const require_view_compiler = require("./view-compiler-ZKZbd3SK.cjs");
10
- const require_sync_engine = require("./sync-engine-B0FT1ax6.cjs");
8
+ const require_projection_sql = require("./projection-sql-DuCtFE9t.cjs");
9
+ const require_view_compiler = require("./view-compiler-xiwm5iar.cjs");
10
+ const require_sync_engine = require("./sync-engine-Dwm_KDUS.cjs");
11
11
  const require_types = require("./types-Cq5gHCTq.cjs");
12
12
  exports.BASE_REF = require_projection.BASE_REF;
13
13
  exports.CANONICAL_FIELDS = require_entity_config.CANONICAL_FIELDS;
@@ -38,8 +38,10 @@ exports.explainEntitiesConfig = require_view_compiler.explainEntitiesConfig;
38
38
  exports.fanOutJoins = require_entity_config.fanOutJoins;
39
39
  exports.filterSchema = require_entity_config.filterSchema;
40
40
  exports.hasRichMeta = require_entity_config.hasRichMeta;
41
+ exports.hostOwnedFieldMessage = require_internal.hostOwnedFieldMessage;
41
42
  exports.identityRefs = require_projection.identityRefs;
42
43
  exports.isClosedStageType = require_types.isClosedStageType;
44
+ exports.isHostOwned = require_internal.isHostOwned;
43
45
  exports.joinFansOut = require_entity_config.joinFansOut;
44
46
  exports.mappingsToEntitiesConfig = require_mappings_config.mappingsToEntitiesConfig;
45
47
  exports.matchesCondition = require_internal.matchesCondition;
@@ -49,6 +51,8 @@ exports.projectionFields = require_entity_config.projectionFields;
49
51
  exports.projectionSchema = require_projection.projectionSchema;
50
52
  exports.quoteIdent = require_projection_sql.quoteIdent;
51
53
  exports.reconcile = require_sync_engine.reconcile;
54
+ exports.rejectedCompanyFields = require_internal.rejectedCompanyFields;
55
+ exports.rejectedContactFields = require_internal.rejectedContactFields;
52
56
  exports.relationshipSchema = require_entity_config.relationshipSchema;
53
57
  exports.relationshipViaSignature = require_mapping_form.relationshipViaSignature;
54
58
  exports.relationshipsSchema = require_entity_config.relationshipsSchema;