@clivly/core 0.11.0-next.0 → 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 (43) hide show
  1. package/dist/adapter.d.cts +44 -7
  2. package/dist/adapter.d.mts +44 -7
  3. package/dist/auth-adapter.d.cts +6 -7
  4. package/dist/auth-adapter.d.mts +6 -7
  5. package/dist/builder.d.cts +12 -12
  6. package/dist/builder.d.mts +12 -12
  7. package/dist/drizzle.d.cts +5 -6
  8. package/dist/drizzle.d.mts +5 -6
  9. package/dist/{entity-config-BTAJe1Zj.mjs → entity-config-C0rtu-K_.mjs} +19 -2
  10. package/dist/{entity-config-CqJknGOn.cjs → entity-config-C2sKAti2.cjs} +19 -2
  11. package/dist/{entity-config-Ddgukq_E.d.cts → entity-config-OhC4Otkz.d.cts} +3 -1
  12. package/dist/{entity-config-Ddgukq_E.d.mts → entity-config-OhC4Otkz.d.mts} +3 -1
  13. package/dist/entity-config.cjs +1 -1
  14. package/dist/entity-config.d.cts +1 -1
  15. package/dist/entity-config.d.mts +1 -1
  16. package/dist/entity-config.mjs +1 -1
  17. package/dist/entity-heuristics.cjs +9 -7
  18. package/dist/entity-heuristics.d.cts +21 -21
  19. package/dist/entity-heuristics.d.mts +21 -21
  20. package/dist/entity-heuristics.mjs +9 -7
  21. package/dist/env-file.d.cts +6 -7
  22. package/dist/env-file.d.mts +6 -7
  23. package/dist/index.cjs +83 -1
  24. package/dist/index.d.cts +89 -22
  25. package/dist/index.d.mts +89 -22
  26. package/dist/index.mjs +80 -2
  27. package/dist/integration-state.d.cts +30 -31
  28. package/dist/integration-state.d.mts +30 -31
  29. package/dist/mapping-form.d.cts +6 -7
  30. package/dist/mapping-form.d.mts +6 -7
  31. package/dist/mapping-score.d.cts +14 -15
  32. package/dist/mapping-score.d.mts +14 -15
  33. package/dist/mappings-config.cjs +2 -1
  34. package/dist/mappings-config.d.cts +8 -7
  35. package/dist/mappings-config.d.mts +8 -7
  36. package/dist/mappings-config.mjs +2 -1
  37. package/dist/sync-engine.d.cts +15 -16
  38. package/dist/sync-engine.d.mts +15 -16
  39. package/dist/types.d.cts +96 -33
  40. package/dist/types.d.mts +96 -33
  41. package/dist/view-compiler.d.cts +10 -11
  42. package/dist/view-compiler.d.mts +10 -11
  43. package/package.json +1 -1
@@ -1,4 +1,4 @@
1
- import { S as RelationshipsMap, h as FilterExpr, x as RelationshipVia } from "./entity-config-Ddgukq_E.cjs";
1
+ import { S as RelationshipsMap, h as FilterExpr, x as RelationshipVia } from "./entity-config-OhC4Otkz.cjs";
2
2
  //#region src/mapping-form.d.ts
3
3
  /**
4
4
  * A relationship the mapping UI can offer or has configured, in the shape the
@@ -6,7 +6,7 @@ import { S as RelationshipsMap, h as FilterExpr, x as RelationshipVia } from "./
6
6
  * mappings→config compiler resolves it to the canonical entity key, so it is
7
7
  * persisted verbatim as the relationship's `entity` reference.
8
8
  */
9
- interface RelationshipCandidate {
9
+ export interface RelationshipCandidate {
10
10
  entityTable: string;
11
11
  name: string;
12
12
  via: RelationshipVia;
@@ -16,19 +16,18 @@ interface RelationshipCandidate {
16
16
  * `value` belong to this entity (e.g. `role = "owner"`). Returns `undefined`
17
17
  * when either side is blank so the caller can omit the filter entirely.
18
18
  */
19
- declare function buildFilterFromDiscriminator(column: string | null | undefined, value: string): FilterExpr | undefined;
19
+ export declare function buildFilterFromDiscriminator(column: string | null | undefined, value: string): FilterExpr | undefined;
20
20
  /**
21
21
  * A stable identity string for a relationship's `via`. Two candidates on the
22
22
  * same source table always differ in their join (`fkOn`+column, join-table
23
23
  * keys, or raw SQL), so this disambiguates candidates the heuristic gives the
24
24
  * same `name` (every contact→company candidate is named "company").
25
25
  */
26
- declare function relationshipViaSignature(via: RelationshipVia): string;
26
+ export declare function relationshipViaSignature(via: RelationshipVia): string;
27
27
  /**
28
28
  * Compile the selected relationship candidates into the persisted
29
29
  * `RelationshipsMap`. Returns `undefined` for an empty selection so the caller
30
30
  * omits the field.
31
31
  */
32
- declare function buildRelationships(candidates: RelationshipCandidate[]): RelationshipsMap | undefined;
33
- //#endregion
34
- export { RelationshipCandidate, buildFilterFromDiscriminator, buildRelationships, relationshipViaSignature };
32
+ export declare function buildRelationships(candidates: RelationshipCandidate[]): RelationshipsMap | undefined;
33
+ //#endregion
@@ -1,4 +1,4 @@
1
- import { S as RelationshipsMap, h as FilterExpr, x as RelationshipVia } from "./entity-config-Ddgukq_E.mjs";
1
+ import { S as RelationshipsMap, h as FilterExpr, x as RelationshipVia } from "./entity-config-OhC4Otkz.mjs";
2
2
  //#region src/mapping-form.d.ts
3
3
  /**
4
4
  * A relationship the mapping UI can offer or has configured, in the shape the
@@ -6,7 +6,7 @@ import { S as RelationshipsMap, h as FilterExpr, x as RelationshipVia } from "./
6
6
  * mappings→config compiler resolves it to the canonical entity key, so it is
7
7
  * persisted verbatim as the relationship's `entity` reference.
8
8
  */
9
- interface RelationshipCandidate {
9
+ export interface RelationshipCandidate {
10
10
  entityTable: string;
11
11
  name: string;
12
12
  via: RelationshipVia;
@@ -16,19 +16,18 @@ interface RelationshipCandidate {
16
16
  * `value` belong to this entity (e.g. `role = "owner"`). Returns `undefined`
17
17
  * when either side is blank so the caller can omit the filter entirely.
18
18
  */
19
- declare function buildFilterFromDiscriminator(column: string | null | undefined, value: string): FilterExpr | undefined;
19
+ export declare function buildFilterFromDiscriminator(column: string | null | undefined, value: string): FilterExpr | undefined;
20
20
  /**
21
21
  * A stable identity string for a relationship's `via`. Two candidates on the
22
22
  * same source table always differ in their join (`fkOn`+column, join-table
23
23
  * keys, or raw SQL), so this disambiguates candidates the heuristic gives the
24
24
  * same `name` (every contact→company candidate is named "company").
25
25
  */
26
- declare function relationshipViaSignature(via: RelationshipVia): string;
26
+ export declare function relationshipViaSignature(via: RelationshipVia): string;
27
27
  /**
28
28
  * Compile the selected relationship candidates into the persisted
29
29
  * `RelationshipsMap`. Returns `undefined` for an empty selection so the caller
30
30
  * omits the field.
31
31
  */
32
- declare function buildRelationships(candidates: RelationshipCandidate[]): RelationshipsMap | undefined;
33
- //#endregion
34
- export { RelationshipCandidate, buildFilterFromDiscriminator, buildRelationships, relationshipViaSignature };
32
+ export declare function buildRelationships(candidates: RelationshipCandidate[]): RelationshipsMap | undefined;
33
+ //#endregion
@@ -1,6 +1,6 @@
1
1
  //#region src/mapping-score.d.ts
2
- type Tier = "High" | "Medium" | "Low";
3
- interface Scored<T> {
2
+ export type Tier = "High" | "Medium" | "Low";
3
+ export interface Scored<T> {
4
4
  /** Human-readable chips, e.g. `type text`, `name matches "contacts"`. */
5
5
  reasons: string[];
6
6
  /** Internal — used for ranking and the apply threshold. Never rendered. */
@@ -9,17 +9,17 @@ interface Scored<T> {
9
9
  value: T;
10
10
  }
11
11
  /** Tier cut-offs: score >= high → High; >= medium → Medium; else Low. */
12
- interface Thresholds {
12
+ export interface Thresholds {
13
13
  high: number;
14
14
  medium: number;
15
15
  }
16
- declare const CONCEPT_TIERS: Thresholds;
17
- declare const FIELD_TIERS: Thresholds;
18
- declare const RELATIONSHIP_TIERS: Thresholds;
16
+ export declare const CONCEPT_TIERS: Thresholds;
17
+ export declare const FIELD_TIERS: Thresholds;
18
+ export declare const RELATIONSHIP_TIERS: Thresholds;
19
19
  /** Two concept candidates closer than this are treated as ambiguous. */
20
- declare const AMBIGUITY_MARGIN = 15;
20
+ export declare const AMBIGUITY_MARGIN = 15;
21
21
  /** Signal weights. Tuned against fixtures; adjust here, not at call sites. */
22
- declare const W: {
22
+ export declare const W: {
23
23
  readonly nameExact: 50;
24
24
  readonly nameSubstring: 25;
25
25
  readonly definingColumn: 20;
@@ -34,16 +34,15 @@ declare const W: {
34
34
  readonly fkNameHint: 30;
35
35
  readonly joinTable: 20;
36
36
  };
37
- declare function tierFor(score: number, t: Thresholds): Tier;
38
- declare function isTextLike(type: string | undefined): boolean;
39
- declare function isNumericLike(type: string | undefined): boolean;
40
- declare function isTimestampLike(type: string | undefined): boolean;
37
+ export declare function tierFor(score: number, t: Thresholds): Tier;
38
+ export declare function isTextLike(type: string | undefined): boolean;
39
+ export declare function isNumericLike(type: string | undefined): boolean;
40
+ export declare function isTimestampLike(type: string | undefined): boolean;
41
41
  /**
42
42
  * True when the top two candidates are too close to call. Callers must never
43
43
  * one-click apply an ambiguous result — the user picks.
44
44
  */
45
- declare function isAmbiguous(ranked: Array<{
45
+ export declare function isAmbiguous(ranked: Array<{
46
46
  score: number;
47
47
  }>): boolean;
48
- //#endregion
49
- export { AMBIGUITY_MARGIN, CONCEPT_TIERS, FIELD_TIERS, RELATIONSHIP_TIERS, Scored, Thresholds, Tier, W, isAmbiguous, isNumericLike, isTextLike, isTimestampLike, tierFor };
48
+ //#endregion
@@ -1,6 +1,6 @@
1
1
  //#region src/mapping-score.d.ts
2
- type Tier = "High" | "Medium" | "Low";
3
- interface Scored<T> {
2
+ export type Tier = "High" | "Medium" | "Low";
3
+ export interface Scored<T> {
4
4
  /** Human-readable chips, e.g. `type text`, `name matches "contacts"`. */
5
5
  reasons: string[];
6
6
  /** Internal — used for ranking and the apply threshold. Never rendered. */
@@ -9,17 +9,17 @@ interface Scored<T> {
9
9
  value: T;
10
10
  }
11
11
  /** Tier cut-offs: score >= high → High; >= medium → Medium; else Low. */
12
- interface Thresholds {
12
+ export interface Thresholds {
13
13
  high: number;
14
14
  medium: number;
15
15
  }
16
- declare const CONCEPT_TIERS: Thresholds;
17
- declare const FIELD_TIERS: Thresholds;
18
- declare const RELATIONSHIP_TIERS: Thresholds;
16
+ export declare const CONCEPT_TIERS: Thresholds;
17
+ export declare const FIELD_TIERS: Thresholds;
18
+ export declare const RELATIONSHIP_TIERS: Thresholds;
19
19
  /** Two concept candidates closer than this are treated as ambiguous. */
20
- declare const AMBIGUITY_MARGIN = 15;
20
+ export declare const AMBIGUITY_MARGIN = 15;
21
21
  /** Signal weights. Tuned against fixtures; adjust here, not at call sites. */
22
- declare const W: {
22
+ export declare const W: {
23
23
  readonly nameExact: 50;
24
24
  readonly nameSubstring: 25;
25
25
  readonly definingColumn: 20;
@@ -34,16 +34,15 @@ declare const W: {
34
34
  readonly fkNameHint: 30;
35
35
  readonly joinTable: 20;
36
36
  };
37
- declare function tierFor(score: number, t: Thresholds): Tier;
38
- declare function isTextLike(type: string | undefined): boolean;
39
- declare function isNumericLike(type: string | undefined): boolean;
40
- declare function isTimestampLike(type: string | undefined): boolean;
37
+ export declare function tierFor(score: number, t: Thresholds): Tier;
38
+ export declare function isTextLike(type: string | undefined): boolean;
39
+ export declare function isNumericLike(type: string | undefined): boolean;
40
+ export declare function isTimestampLike(type: string | undefined): boolean;
41
41
  /**
42
42
  * True when the top two candidates are too close to call. Callers must never
43
43
  * one-click apply an ambiguous result — the user picks.
44
44
  */
45
- declare function isAmbiguous(ranked: Array<{
45
+ export declare function isAmbiguous(ranked: Array<{
46
46
  score: number;
47
47
  }>): boolean;
48
- //#endregion
49
- export { AMBIGUITY_MARGIN, CONCEPT_TIERS, FIELD_TIERS, RELATIONSHIP_TIERS, Scored, Thresholds, Tier, W, isAmbiguous, isNumericLike, isTextLike, isTimestampLike, tierFor };
48
+ //#endregion
@@ -1,5 +1,5 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
- const require_entity_config = require("./entity-config-CqJknGOn.cjs");
2
+ const require_entity_config = require("./entity-config-C2sKAti2.cjs");
3
3
  //#region src/mappings-config.ts
4
4
  const RESERVED_FIELD = "id";
5
5
  /**
@@ -120,6 +120,7 @@ function entitiesToMappings(config) {
120
120
  fieldMap: entity.projection ? {} : entity.fields
121
121
  };
122
122
  if (entity.filter) row.filter = entity.filter;
123
+ if (entity.isPrimaryContact) row.isPrimaryContact = true;
123
124
  if (entity.relationships) row.relationships = entity.relationships;
124
125
  if (entity.projection) row.projection = entity.projection;
125
126
  if (entity.concept === CUSTOM_CONCEPT) {
@@ -1,4 +1,4 @@
1
- import { R as ProjectionMapping, S as RelationshipsMap, a as ClivlyEntitiesConfig, h as FilterExpr } from "./entity-config-Ddgukq_E.cjs";
1
+ import { R as ProjectionMapping, S as RelationshipsMap, a as ClivlyEntitiesConfig, h as FilterExpr } from "./entity-config-OhC4Otkz.cjs";
2
2
  //#region src/mappings-config.d.ts
3
3
  /**
4
4
  * Mappings → Entity Config bridge.
@@ -20,7 +20,7 @@ import { R as ProjectionMapping, S as RelationshipsMap, a as ClivlyEntitiesConfi
20
20
  * reads. Structurally compatible with the Drizzle row (jsonb columns typed
21
21
  * loosely) so the API layer can pass `db.select()` results straight in.
22
22
  */
23
- interface EntityMappingRow {
23
+ export interface EntityMappingRow {
24
24
  fieldMap: Record<string, string>;
25
25
  filter?: Record<string, unknown> | null;
26
26
  /**
@@ -42,7 +42,7 @@ interface EntityMappingRow {
42
42
  * unmapped rows are skipped. Returns `{ entities: {} }` when nothing is
43
43
  * eligible — a no-op the view compiler and sync engine both tolerate.
44
44
  */
45
- declare function mappingsToEntitiesConfig(rows: EntityMappingRow[]): ClivlyEntitiesConfig;
45
+ export declare function mappingsToEntitiesConfig(rows: EntityMappingRow[]): ClivlyEntitiesConfig;
46
46
  /**
47
47
  * Entity Config → Mappings, the inverse of `mappingsToEntitiesConfig`.
48
48
  *
@@ -57,7 +57,7 @@ declare function mappingsToEntitiesConfig(rows: EntityMappingRow[]): ClivlyEntit
57
57
  * ("client-accounts" derived from "accounts"). So the key travels explicitly on
58
58
  * every row rather than being left for the reverse derivation to guess.
59
59
  */
60
- interface MappingFromConfig {
60
+ export interface MappingFromConfig {
61
61
  /**
62
62
  * The config entity key this row came from. Not a row column — the caller
63
63
  * needs it to resolve a custom object type and to report what it wrote.
@@ -65,6 +65,8 @@ interface MappingFromConfig {
65
65
  entityKey: string;
66
66
  fieldMap: Record<string, string>;
67
67
  filter?: FilterExpr;
68
+ /** Rows from this entity are their company's point of contact. */
69
+ isPrimaryContact?: boolean;
68
70
  /** Declared custom object, when the config declares one rather than pinning an id. */
69
71
  objectType?: {
70
72
  iconKey?: string;
@@ -80,6 +82,5 @@ interface MappingFromConfig {
80
82
  targetConcept: string;
81
83
  targetObjectTypeId?: string;
82
84
  }
83
- declare function entitiesToMappings(config: ClivlyEntitiesConfig): MappingFromConfig[];
84
- //#endregion
85
- export { EntityMappingRow, MappingFromConfig, entitiesToMappings, mappingsToEntitiesConfig };
85
+ export declare function entitiesToMappings(config: ClivlyEntitiesConfig): MappingFromConfig[];
86
+ //#endregion
@@ -1,4 +1,4 @@
1
- import { R as ProjectionMapping, S as RelationshipsMap, a as ClivlyEntitiesConfig, h as FilterExpr } from "./entity-config-Ddgukq_E.mjs";
1
+ import { R as ProjectionMapping, S as RelationshipsMap, a as ClivlyEntitiesConfig, h as FilterExpr } from "./entity-config-OhC4Otkz.mjs";
2
2
  //#region src/mappings-config.d.ts
3
3
  /**
4
4
  * Mappings → Entity Config bridge.
@@ -20,7 +20,7 @@ import { R as ProjectionMapping, S as RelationshipsMap, a as ClivlyEntitiesConfi
20
20
  * reads. Structurally compatible with the Drizzle row (jsonb columns typed
21
21
  * loosely) so the API layer can pass `db.select()` results straight in.
22
22
  */
23
- interface EntityMappingRow {
23
+ export interface EntityMappingRow {
24
24
  fieldMap: Record<string, string>;
25
25
  filter?: Record<string, unknown> | null;
26
26
  /**
@@ -42,7 +42,7 @@ interface EntityMappingRow {
42
42
  * unmapped rows are skipped. Returns `{ entities: {} }` when nothing is
43
43
  * eligible — a no-op the view compiler and sync engine both tolerate.
44
44
  */
45
- declare function mappingsToEntitiesConfig(rows: EntityMappingRow[]): ClivlyEntitiesConfig;
45
+ export declare function mappingsToEntitiesConfig(rows: EntityMappingRow[]): ClivlyEntitiesConfig;
46
46
  /**
47
47
  * Entity Config → Mappings, the inverse of `mappingsToEntitiesConfig`.
48
48
  *
@@ -57,7 +57,7 @@ declare function mappingsToEntitiesConfig(rows: EntityMappingRow[]): ClivlyEntit
57
57
  * ("client-accounts" derived from "accounts"). So the key travels explicitly on
58
58
  * every row rather than being left for the reverse derivation to guess.
59
59
  */
60
- interface MappingFromConfig {
60
+ export interface MappingFromConfig {
61
61
  /**
62
62
  * The config entity key this row came from. Not a row column — the caller
63
63
  * needs it to resolve a custom object type and to report what it wrote.
@@ -65,6 +65,8 @@ interface MappingFromConfig {
65
65
  entityKey: string;
66
66
  fieldMap: Record<string, string>;
67
67
  filter?: FilterExpr;
68
+ /** Rows from this entity are their company's point of contact. */
69
+ isPrimaryContact?: boolean;
68
70
  /** Declared custom object, when the config declares one rather than pinning an id. */
69
71
  objectType?: {
70
72
  iconKey?: string;
@@ -80,6 +82,5 @@ interface MappingFromConfig {
80
82
  targetConcept: string;
81
83
  targetObjectTypeId?: string;
82
84
  }
83
- declare function entitiesToMappings(config: ClivlyEntitiesConfig): MappingFromConfig[];
84
- //#endregion
85
- export { EntityMappingRow, MappingFromConfig, entitiesToMappings, mappingsToEntitiesConfig };
85
+ export declare function entitiesToMappings(config: ClivlyEntitiesConfig): MappingFromConfig[];
86
+ //#endregion
@@ -1,4 +1,4 @@
1
- import { f as projectionFields, t as CANONICAL_FIELDS } from "./entity-config-BTAJe1Zj.mjs";
1
+ import { f as projectionFields, t as CANONICAL_FIELDS } from "./entity-config-C0rtu-K_.mjs";
2
2
  //#region src/mappings-config.ts
3
3
  const RESERVED_FIELD = "id";
4
4
  /**
@@ -119,6 +119,7 @@ function entitiesToMappings(config) {
119
119
  fieldMap: entity.projection ? {} : entity.fields
120
120
  };
121
121
  if (entity.filter) row.filter = entity.filter;
122
+ if (entity.isPrimaryContact) row.isPrimaryContact = true;
122
123
  if (entity.relationships) row.relationships = entity.relationships;
123
124
  if (entity.projection) row.projection = entity.projection;
124
125
  if (entity.concept === CUSTOM_CONCEPT) {
@@ -1,4 +1,4 @@
1
- import { a as ClivlyEntitiesConfig } from "./entity-config-Ddgukq_E.cjs";
1
+ import { a as ClivlyEntitiesConfig } from "./entity-config-OhC4Otkz.cjs";
2
2
  import { CompileOptions, CompiledView } from "./view-compiler.cjs";
3
3
  //#region src/sync-engine.d.ts
4
4
  /**
@@ -19,7 +19,7 @@ import { CompileOptions, CompiledView } from "./view-compiler.cjs";
19
19
  * package provides the concrete store.
20
20
  */
21
21
  /** A row read from a compiled view (what Postgres returns). */
22
- interface SourceRow {
22
+ export interface SourceRow {
23
23
  /** Host-side company key from `<relationship>_ref`; resolved before persist. */
24
24
  companyRef?: string | null;
25
25
  /** Mapped identity fields (clivly field → value). */
@@ -28,14 +28,14 @@ interface SourceRow {
28
28
  sourceRef: string;
29
29
  }
30
30
  /** An existing mirror row, as far as reconciliation needs to know. */
31
- interface MirrorRecord {
31
+ export interface MirrorRecord {
32
32
  archivedAt: Date | null;
33
33
  /** Host-side company key; only consulted in composite (join-table) mode. */
34
34
  companyRef: string | null;
35
35
  id: string;
36
36
  sourceRef: string;
37
37
  }
38
- type SyncAction = {
38
+ export type SyncAction = {
39
39
  kind: "create";
40
40
  sourceRef: string;
41
41
  fields: Record<string, string | null>;
@@ -58,7 +58,7 @@ type SyncAction = {
58
58
  sourceRef: string;
59
59
  };
60
60
  /** A persist action with the company ref resolved to a `crm_companies.id`. */
61
- type PersistAction = {
61
+ export type PersistAction = {
62
62
  kind: "create";
63
63
  sourceRef: string;
64
64
  fields: Record<string, string | null>;
@@ -99,11 +99,11 @@ type PersistAction = {
99
99
  * person in several companies materializes one mirror row per company and a
100
100
  * single membership leaving archives only that one row.
101
101
  */
102
- declare function reconcile(source: SourceRow[], mirror: MirrorRecord[], opts?: {
102
+ export declare function reconcile(source: SourceRow[], mirror: MirrorRecord[], opts?: {
103
103
  composite?: boolean;
104
104
  }): SyncAction[];
105
105
  /** DB I/O port. The concrete store lives in the SDK/drizzle package. */
106
- interface SyncStore {
106
+ export interface SyncStore {
107
107
  /** Current mirror rows for a concept + role (including archived). */
108
108
  listMirror(input: {
109
109
  concept: string;
@@ -129,7 +129,7 @@ interface SyncStore {
129
129
  /** Map host-side company refs → `crm_companies.id` (already-synced companies only). */
130
130
  resolveCompanyRefs(refs: string[]): Promise<Map<string, string>>;
131
131
  }
132
- interface EntitySyncResult {
132
+ export interface EntitySyncResult {
133
133
  archived: number;
134
134
  concept: string;
135
135
  created: number;
@@ -138,7 +138,7 @@ interface EntitySyncResult {
138
138
  role: string;
139
139
  updated: number;
140
140
  }
141
- interface SyncResult {
141
+ export interface SyncResult {
142
142
  entities: EntitySyncResult[];
143
143
  totals: {
144
144
  created: number;
@@ -151,12 +151,12 @@ interface SyncResult {
151
151
  * Run a full sync: compile the config's views, then reconcile + persist each,
152
152
  * companies first. Returns per-entity and total action counts.
153
153
  */
154
- declare function runSync(config: ClivlyEntitiesConfig, store: SyncStore, options?: CompileOptions): Promise<SyncResult>;
155
- interface PreviewWarning {
154
+ export declare function runSync(config: ClivlyEntitiesConfig, store: SyncStore, options?: CompileOptions): Promise<SyncResult>;
155
+ export interface PreviewWarning {
156
156
  field?: string;
157
157
  message: string;
158
158
  }
159
- interface PreviewResult {
159
+ export interface PreviewResult {
160
160
  rows: SourceRow[];
161
161
  sampledCount: number;
162
162
  warnings: PreviewWarning[];
@@ -167,7 +167,7 @@ interface PreviewResult {
167
167
  * a required field empty in ≥1 row → `K/N` form; an optional field empty in
168
168
  * ALL rows → all-empty form; zero source rows → a single table-level warning.
169
169
  */
170
- declare function computeSampleWarnings(rows: SourceRow[], requiredFields: string[], sourceTable: string): PreviewWarning[];
170
+ export declare function computeSampleWarnings(rows: SourceRow[], requiredFields: string[], sourceTable: string): PreviewWarning[];
171
171
  /**
172
172
  * Zero-write preview: read ≤`limit` rows through the compiled view (a pure
173
173
  * SELECT whose SQL already projects each row into its mapped fields) and
@@ -175,10 +175,9 @@ declare function computeSampleWarnings(rows: SourceRow[], requiredFields: string
175
175
  * so it can never mutate the mirror. The distinct, write-one-row sibling is
176
176
  * `runSync`'s sample mode (T13).
177
177
  */
178
- declare function previewSync(store: SyncStore, view: CompiledView, opts: {
178
+ export declare function previewSync(store: SyncStore, view: CompiledView, opts: {
179
179
  limit: number;
180
180
  requiredFields: string[];
181
181
  sourceTable: string;
182
182
  }): Promise<PreviewResult>;
183
- //#endregion
184
- export { EntitySyncResult, MirrorRecord, PersistAction, PreviewResult, PreviewWarning, SourceRow, SyncAction, SyncResult, SyncStore, computeSampleWarnings, previewSync, reconcile, runSync };
183
+ //#endregion
@@ -1,4 +1,4 @@
1
- import { a as ClivlyEntitiesConfig } from "./entity-config-Ddgukq_E.mjs";
1
+ import { a as ClivlyEntitiesConfig } from "./entity-config-OhC4Otkz.mjs";
2
2
  import { CompileOptions, CompiledView } from "./view-compiler.mjs";
3
3
  //#region src/sync-engine.d.ts
4
4
  /**
@@ -19,7 +19,7 @@ import { CompileOptions, CompiledView } from "./view-compiler.mjs";
19
19
  * package provides the concrete store.
20
20
  */
21
21
  /** A row read from a compiled view (what Postgres returns). */
22
- interface SourceRow {
22
+ export interface SourceRow {
23
23
  /** Host-side company key from `<relationship>_ref`; resolved before persist. */
24
24
  companyRef?: string | null;
25
25
  /** Mapped identity fields (clivly field → value). */
@@ -28,14 +28,14 @@ interface SourceRow {
28
28
  sourceRef: string;
29
29
  }
30
30
  /** An existing mirror row, as far as reconciliation needs to know. */
31
- interface MirrorRecord {
31
+ export interface MirrorRecord {
32
32
  archivedAt: Date | null;
33
33
  /** Host-side company key; only consulted in composite (join-table) mode. */
34
34
  companyRef: string | null;
35
35
  id: string;
36
36
  sourceRef: string;
37
37
  }
38
- type SyncAction = {
38
+ export type SyncAction = {
39
39
  kind: "create";
40
40
  sourceRef: string;
41
41
  fields: Record<string, string | null>;
@@ -58,7 +58,7 @@ type SyncAction = {
58
58
  sourceRef: string;
59
59
  };
60
60
  /** A persist action with the company ref resolved to a `crm_companies.id`. */
61
- type PersistAction = {
61
+ export type PersistAction = {
62
62
  kind: "create";
63
63
  sourceRef: string;
64
64
  fields: Record<string, string | null>;
@@ -99,11 +99,11 @@ type PersistAction = {
99
99
  * person in several companies materializes one mirror row per company and a
100
100
  * single membership leaving archives only that one row.
101
101
  */
102
- declare function reconcile(source: SourceRow[], mirror: MirrorRecord[], opts?: {
102
+ export declare function reconcile(source: SourceRow[], mirror: MirrorRecord[], opts?: {
103
103
  composite?: boolean;
104
104
  }): SyncAction[];
105
105
  /** DB I/O port. The concrete store lives in the SDK/drizzle package. */
106
- interface SyncStore {
106
+ export interface SyncStore {
107
107
  /** Current mirror rows for a concept + role (including archived). */
108
108
  listMirror(input: {
109
109
  concept: string;
@@ -129,7 +129,7 @@ interface SyncStore {
129
129
  /** Map host-side company refs → `crm_companies.id` (already-synced companies only). */
130
130
  resolveCompanyRefs(refs: string[]): Promise<Map<string, string>>;
131
131
  }
132
- interface EntitySyncResult {
132
+ export interface EntitySyncResult {
133
133
  archived: number;
134
134
  concept: string;
135
135
  created: number;
@@ -138,7 +138,7 @@ interface EntitySyncResult {
138
138
  role: string;
139
139
  updated: number;
140
140
  }
141
- interface SyncResult {
141
+ export interface SyncResult {
142
142
  entities: EntitySyncResult[];
143
143
  totals: {
144
144
  created: number;
@@ -151,12 +151,12 @@ interface SyncResult {
151
151
  * Run a full sync: compile the config's views, then reconcile + persist each,
152
152
  * companies first. Returns per-entity and total action counts.
153
153
  */
154
- declare function runSync(config: ClivlyEntitiesConfig, store: SyncStore, options?: CompileOptions): Promise<SyncResult>;
155
- interface PreviewWarning {
154
+ export declare function runSync(config: ClivlyEntitiesConfig, store: SyncStore, options?: CompileOptions): Promise<SyncResult>;
155
+ export interface PreviewWarning {
156
156
  field?: string;
157
157
  message: string;
158
158
  }
159
- interface PreviewResult {
159
+ export interface PreviewResult {
160
160
  rows: SourceRow[];
161
161
  sampledCount: number;
162
162
  warnings: PreviewWarning[];
@@ -167,7 +167,7 @@ interface PreviewResult {
167
167
  * a required field empty in ≥1 row → `K/N` form; an optional field empty in
168
168
  * ALL rows → all-empty form; zero source rows → a single table-level warning.
169
169
  */
170
- declare function computeSampleWarnings(rows: SourceRow[], requiredFields: string[], sourceTable: string): PreviewWarning[];
170
+ export declare function computeSampleWarnings(rows: SourceRow[], requiredFields: string[], sourceTable: string): PreviewWarning[];
171
171
  /**
172
172
  * Zero-write preview: read ≤`limit` rows through the compiled view (a pure
173
173
  * SELECT whose SQL already projects each row into its mapped fields) and
@@ -175,10 +175,9 @@ declare function computeSampleWarnings(rows: SourceRow[], requiredFields: string
175
175
  * so it can never mutate the mirror. The distinct, write-one-row sibling is
176
176
  * `runSync`'s sample mode (T13).
177
177
  */
178
- declare function previewSync(store: SyncStore, view: CompiledView, opts: {
178
+ export declare function previewSync(store: SyncStore, view: CompiledView, opts: {
179
179
  limit: number;
180
180
  requiredFields: string[];
181
181
  sourceTable: string;
182
182
  }): Promise<PreviewResult>;
183
- //#endregion
184
- export { EntitySyncResult, MirrorRecord, PersistAction, PreviewResult, PreviewWarning, SourceRow, SyncAction, SyncResult, SyncStore, computeSampleWarnings, previewSync, reconcile, runSync };
183
+ //#endregion