clivly 0.9.0 → 0.9.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (98) hide show
  1. package/README.md +19 -7
  2. package/core-drizzle.d.cts +1 -1
  3. package/core-drizzle.d.mts +1 -1
  4. package/core-entity-config.cjs +3 -1
  5. package/core-entity-config.d.cts +2 -2
  6. package/core-entity-config.d.mts +2 -2
  7. package/core-entity-config.mjs +2 -2
  8. package/core-entity-heuristics.d.cts +1 -1
  9. package/core-entity-heuristics.d.mts +1 -1
  10. package/core-mapping-form.d.cts +1 -1
  11. package/core-mapping-form.d.mts +1 -1
  12. package/core-mappings-config.cjs +2 -1
  13. package/core-mappings-config.d.cts +2 -2
  14. package/core-mappings-config.d.mts +2 -2
  15. package/core-mappings-config.mjs +2 -2
  16. package/core-sync-engine.cjs +1 -1
  17. package/core-sync-engine.d.cts +1 -1
  18. package/core-sync-engine.d.mts +1 -1
  19. package/core-sync-engine.mjs +1 -1
  20. package/core-view-compiler.cjs +2 -1
  21. package/core-view-compiler.d.cts +2 -2
  22. package/core-view-compiler.d.mts +2 -2
  23. package/core-view-compiler.mjs +2 -2
  24. package/core.cjs +5 -5
  25. package/core.d.cts +6 -6
  26. package/core.d.mts +6 -6
  27. package/core.mjs +5 -5
  28. package/{drizzle-BhN5M9zt.d.cts → drizzle-CiK8MMEZ.d.mts} +1 -1
  29. package/{drizzle-kBULBAOa.d.mts → drizzle-DEtRrqtc.d.cts} +1 -1
  30. package/drizzle.d.cts +2 -2
  31. package/drizzle.d.mts +2 -2
  32. package/{entity-config-C4Yf_fPj.d.cts → entity-config-B2RA53nw.d.cts} +168 -2
  33. package/{entity-config-C4Yf_fPj.d.mts → entity-config-B2RA53nw.d.mts} +168 -2
  34. package/{entity-config-CsLl-ftC.cjs → entity-config-DtBsl2MQ.cjs} +88 -13
  35. package/{entity-config-D3LmzgLb.mjs → entity-config-kUHri9yA.mjs} +77 -14
  36. package/index.cjs +375 -29
  37. package/index.d.cts +1 -0
  38. package/index.d.mts +1 -0
  39. package/index.mjs +375 -29
  40. package/{internal-MBkNo3bw.d.mts → internal-CDY8g9Ic.d.mts} +1 -2
  41. package/{internal-BARjyN4n.cjs → internal-CwnEG6Wl.cjs} +1 -1
  42. package/{internal-B8ydhsKd.d.cts → internal-Da_dlcQ_.d.cts} +1 -2
  43. package/{internal-DMySVbM0.mjs → internal-Df-PtOH_.mjs} +1 -1
  44. package/internal-drizzle.d.cts +1 -1
  45. package/internal-drizzle.d.mts +1 -1
  46. package/internal-entity-config.cjs +3 -1
  47. package/internal-entity-config.d.cts +2 -2
  48. package/internal-entity-config.d.mts +2 -2
  49. package/internal-entity-config.mjs +2 -2
  50. package/internal-entity-heuristics.cjs +1 -1
  51. package/internal-entity-heuristics.d.cts +1 -1
  52. package/internal-entity-heuristics.d.mts +1 -1
  53. package/internal-entity-heuristics.mjs +1 -1
  54. package/internal-mapping-form.d.cts +1 -1
  55. package/internal-mapping-form.d.mts +1 -1
  56. package/internal-mappings-config.cjs +2 -1
  57. package/internal-mappings-config.d.cts +2 -2
  58. package/internal-mappings-config.d.mts +2 -2
  59. package/internal-mappings-config.mjs +2 -2
  60. package/internal-sync-engine.cjs +1 -1
  61. package/internal-sync-engine.d.cts +1 -1
  62. package/internal-sync-engine.d.mts +1 -1
  63. package/internal-sync-engine.mjs +1 -1
  64. package/internal-view-compiler.cjs +2 -1
  65. package/internal-view-compiler.d.cts +2 -2
  66. package/internal-view-compiler.d.mts +2 -2
  67. package/internal-view-compiler.mjs +2 -2
  68. package/internal.cjs +5 -5
  69. package/internal.d.cts +6 -6
  70. package/internal.d.mts +6 -6
  71. package/internal.mjs +5 -5
  72. package/{mapping-form-43bwOTat.d.cts → mapping-form-DH77BXLv.d.mts} +1 -1
  73. package/{mapping-form-DUvWUYCo.d.mts → mapping-form-J0aU6O7l.d.cts} +1 -1
  74. package/{mappings-config-BSSwdHiq.cjs → mappings-config-B0RqFLxu.cjs} +30 -1
  75. package/{mappings-config-bJQT_gSa.mjs → mappings-config-B1b1HVBg.mjs} +25 -2
  76. package/mappings-config-D9dsonoi.d.mts +85 -0
  77. package/mappings-config-RQLGx8ub.d.cts +85 -0
  78. package/{namespace-probe-BSH_p9TK.d.cts → namespace-probe-C6aHjedO.d.cts} +65 -3
  79. package/{namespace-probe-Dsp5uNkS.d.mts → namespace-probe-Dj-0Q3Hb.d.mts} +65 -3
  80. package/package.json +1 -1
  81. package/{sdk-Bj-ZDf4u.cjs → sdk-D4Wp_uxb.cjs} +754 -44
  82. package/{sdk-BvRD2jAp.mjs → sdk-DXV8M_Io.mjs} +754 -44
  83. package/sdk.cjs +4 -2
  84. package/sdk.d.cts +3 -3
  85. package/sdk.d.mts +3 -3
  86. package/sdk.mjs +3 -3
  87. package/{sync-engine-GNqRB8eS.d.cts → sync-engine-BG2O1an2.d.cts} +2 -2
  88. package/{sync-engine-ZsusW-q_.d.mts → sync-engine-DgQbrJON.d.mts} +2 -2
  89. package/{sync-engine-Bg6-SznL.mjs → sync-engine-SuxSzbZ4.mjs} +1 -1
  90. package/{sync-engine-DEJvKw6E.cjs → sync-engine-abE94g6X.cjs} +1 -1
  91. package/{view-compiler-DplczSjF.cjs → view-compiler-Blu4OXJ7.cjs} +22 -0
  92. package/{view-compiler-Cin0neDO.d.mts → view-compiler-Bo7pqXW3.d.mts} +12 -2
  93. package/{view-compiler-DlTpOfZi.mjs → view-compiler-CQx8TRrW.mjs} +17 -1
  94. package/{view-compiler-Ll9cbIJz.d.cts → view-compiler-CmEdAMwj.d.cts} +12 -2
  95. package/vite.d.cts +1 -1
  96. package/vite.d.mts +1 -1
  97. package/mappings-config-BpcR8bBo.d.mts +0 -167
  98. package/mappings-config-xsLMn3I-.d.cts +0 -167
@@ -1,5 +1,5 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
- const require_entity_config = require("./entity-config-CsLl-ftC.cjs");
2
+ const require_entity_config = require("./entity-config-DtBsl2MQ.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 = [
@@ -1,4 +1,4 @@
1
- import { u as DiscoveredColumnMeta } from "./entity-config-C4Yf_fPj.cjs";
1
+ import { p as DiscoveredColumnMeta } from "./entity-config-B2RA53nw.cjs";
2
2
  import { a as Scored } from "./mapping-score-D7Gzg7Ii.cjs";
3
3
  //#region ../core/src/entity-heuristics.d.ts
4
4
  declare const TARGET_CONCEPTS: readonly ["contact", "company", "deal", "activity", "conversation", "note"];
@@ -1,4 +1,4 @@
1
- import { u as DiscoveredColumnMeta } from "./entity-config-C4Yf_fPj.mjs";
1
+ import { p as DiscoveredColumnMeta } from "./entity-config-B2RA53nw.mjs";
2
2
  import { a as Scored } from "./mapping-score-D7Gzg7Ii.mjs";
3
3
  //#region ../core/src/entity-heuristics.d.ts
4
4
  declare const TARGET_CONCEPTS: readonly ["contact", "company", "deal", "activity", "conversation", "note"];
@@ -1,4 +1,4 @@
1
- import { a as MATERIALIZING_CONCEPTS } from "./entity-config-D3LmzgLb.mjs";
1
+ import { a as MATERIALIZING_CONCEPTS } from "./entity-config-kUHri9yA.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 = [
@@ -1,2 +1,2 @@
1
- import { i as relationshipViaSignature, n as buildFilterFromDiscriminator, r as buildRelationships, t as RelationshipCandidate } from "./mapping-form-43bwOTat.cjs";
1
+ import { i as relationshipViaSignature, n as buildFilterFromDiscriminator, r as buildRelationships, t as RelationshipCandidate } from "./mapping-form-J0aU6O7l.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-DUvWUYCo.mjs";
1
+ import { i as relationshipViaSignature, n as buildFilterFromDiscriminator, r as buildRelationships, t as RelationshipCandidate } from "./mapping-form-DH77BXLv.mjs";
2
2
  export { RelationshipCandidate, buildFilterFromDiscriminator, buildRelationships, relationshipViaSignature };
@@ -1,3 +1,4 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
- const require_mappings_config = require("./mappings-config-BSSwdHiq.cjs");
2
+ const require_mappings_config = require("./mappings-config-B0RqFLxu.cjs");
3
+ exports.entitiesToMappings = require_mappings_config.entitiesToMappings;
3
4
  exports.mappingsToEntitiesConfig = require_mappings_config.mappingsToEntitiesConfig;
@@ -1,2 +1,2 @@
1
- import { n as mappingsToEntitiesConfig, t as EntityMappingRow } from "./mappings-config-xsLMn3I-.cjs";
2
- export { EntityMappingRow, mappingsToEntitiesConfig };
1
+ import { i as mappingsToEntitiesConfig, n as MappingFromConfig, r as entitiesToMappings, t as EntityMappingRow } from "./mappings-config-RQLGx8ub.cjs";
2
+ export { EntityMappingRow, MappingFromConfig, entitiesToMappings, mappingsToEntitiesConfig };
@@ -1,2 +1,2 @@
1
- import { n as mappingsToEntitiesConfig, t as EntityMappingRow } from "./mappings-config-BpcR8bBo.mjs";
2
- export { EntityMappingRow, mappingsToEntitiesConfig };
1
+ import { i as mappingsToEntitiesConfig, n as MappingFromConfig, r as entitiesToMappings, t as EntityMappingRow } from "./mappings-config-D9dsonoi.mjs";
2
+ export { EntityMappingRow, MappingFromConfig, entitiesToMappings, mappingsToEntitiesConfig };
@@ -1,2 +1,2 @@
1
- import { t as mappingsToEntitiesConfig } from "./mappings-config-bJQT_gSa.mjs";
2
- export { mappingsToEntitiesConfig };
1
+ import { n as mappingsToEntitiesConfig, t as entitiesToMappings } from "./mappings-config-B1b1HVBg.mjs";
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-DEJvKw6E.cjs");
2
+ const require_sync_engine = require("./sync-engine-abE94g6X.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-GNqRB8eS.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-BG2O1an2.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-ZsusW-q_.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-DgQbrJON.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-Bg6-SznL.mjs";
1
+ import { i as runSync, n as previewSync, r as reconcile, t as computeSampleWarnings } from "./sync-engine-SuxSzbZ4.mjs";
2
2
  export { computeSampleWarnings, previewSync, reconcile, runSync };
@@ -1,6 +1,7 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
- const require_view_compiler = require("./view-compiler-DplczSjF.cjs");
2
+ const require_view_compiler = require("./view-compiler-Blu4OXJ7.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;
6
6
  exports.explainEntitiesConfig = require_view_compiler.explainEntitiesConfig;
7
+ exports.explainViewExecutionError = require_view_compiler.explainViewExecutionError;
@@ -1,2 +1,2 @@
1
- import { a as compileEntityView, i as ExplainResult, n as CompiledView, o as compileEntityViews, r as DEFAULT_VIEW_PREFIX, s as explainEntitiesConfig, t as CompileOptions } from "./view-compiler-Ll9cbIJz.cjs";
2
- export { CompileOptions, CompiledView, DEFAULT_VIEW_PREFIX, ExplainResult, compileEntityView, compileEntityViews, explainEntitiesConfig };
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-CmEdAMwj.cjs";
2
+ export { CompileOptions, CompiledView, DEFAULT_VIEW_PREFIX, ExplainResult, compileEntityView, compileEntityViews, explainEntitiesConfig, explainViewExecutionError };
@@ -1,2 +1,2 @@
1
- import { a as compileEntityView, i as ExplainResult, n as CompiledView, o as compileEntityViews, r as DEFAULT_VIEW_PREFIX, s as explainEntitiesConfig, t as CompileOptions } from "./view-compiler-Cin0neDO.mjs";
2
- export { CompileOptions, CompiledView, DEFAULT_VIEW_PREFIX, ExplainResult, compileEntityView, compileEntityViews, explainEntitiesConfig };
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-Bo7pqXW3.mjs";
2
+ export { CompileOptions, CompiledView, DEFAULT_VIEW_PREFIX, ExplainResult, compileEntityView, compileEntityViews, explainEntitiesConfig, explainViewExecutionError };
@@ -1,2 +1,2 @@
1
- import { i as explainEntitiesConfig, n as compileEntityView, r as compileEntityViews, t as DEFAULT_VIEW_PREFIX } from "./view-compiler-DlTpOfZi.mjs";
2
- export { DEFAULT_VIEW_PREFIX, compileEntityView, compileEntityViews, explainEntitiesConfig };
1
+ import { a as explainViewExecutionError, i as explainEntitiesConfig, n as compileEntityView, r as compileEntityViews, t as DEFAULT_VIEW_PREFIX } from "./view-compiler-CQx8TRrW.mjs";
2
+ export { DEFAULT_VIEW_PREFIX, compileEntityView, compileEntityViews, explainEntitiesConfig, explainViewExecutionError };
package/internal.cjs CHANGED
@@ -1,12 +1,12 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
2
  const require_projection = require("./projection-C5244vGa.cjs");
3
- const require_entity_config = require("./entity-config-CsLl-ftC.cjs");
3
+ const require_entity_config = require("./entity-config-DtBsl2MQ.cjs");
4
+ const require_mappings_config = require("./mappings-config-B0RqFLxu.cjs");
4
5
  const require_auth_adapter = require("./auth-adapter-CiEXcweZ.cjs");
5
6
  const require_mapping_form = require("./mapping-form-BpfON_ME.cjs");
6
- const require_mappings_config = require("./mappings-config-BSSwdHiq.cjs");
7
- const require_internal = require("./internal-BARjyN4n.cjs");
8
- const require_view_compiler = require("./view-compiler-DplczSjF.cjs");
9
- const require_sync_engine = require("./sync-engine-DEJvKw6E.cjs");
7
+ const require_internal = require("./internal-CwnEG6Wl.cjs");
8
+ const require_view_compiler = require("./view-compiler-Blu4OXJ7.cjs");
9
+ const require_sync_engine = require("./sync-engine-abE94g6X.cjs");
10
10
  exports.BASE_REF = require_projection.BASE_REF;
11
11
  exports.CANONICAL_FIELDS = require_entity_config.CANONICAL_FIELDS;
12
12
  exports.CRM_CONCEPTS = require_entity_config.CRM_CONCEPTS;
package/internal.d.cts CHANGED
@@ -1,10 +1,10 @@
1
1
  import { C as UpdateDealInput, S as UpdateContactInput, _ as Task, a as ContactFilters, b as TaskPriority, c as CreateCompanyInput, d as CreateTaskInput, f as CrmRole, g as RecordSource, h as Note, i as Contact, 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 TaskEntityType, w as UpdateTaskInput, x as TaskStatus, y as TaskFilters } from "./types-B1oRXdNP.cjs";
2
2
  import { a as authCustom, i as MembershipResolver, n as ClivlyUser, r as CrmMembership, t as ClivlyAuthAdapter } from "./auth-adapter-DWzgl5Yq.cjs";
3
3
  import { t as CRMAdapter } from "./adapter-C2eRbBfo.cjs";
4
- import { C as relationshipsSchema, S as relationshipSchema, _ as RelationshipVia, a as ClivlyEntitiesConfig, b as entitiesConfigSchema, c as ConfigValidationResult, d as DiscoveredSchemaTable, f as FilterExpr, g as RelationshipSpec, h as MaterializingConcept, i as ClivlyConfigError, l as CrmConcept, m as MATERIALIZING_CONCEPTS, n as CRM_CONCEPTS, o as ClivlyEntityConfig, p as FilterValue, s as ConfigValidationError, t as CANONICAL_FIELDS, u as DiscoveredColumnMeta, v as RelationshipsMap, w as validateEntitiesConfig, x as filterSchema, y as defineClivlyConfig } from "./entity-config-C4Yf_fPj.cjs";
5
- import { i as relationshipViaSignature, n as buildFilterFromDiscriminator, r as buildRelationships, t as RelationshipCandidate } from "./mapping-form-43bwOTat.cjs";
6
- import { a as ProjectionIdentity, c as ProjectionRef, i as ProjectionFieldBinding, l as identityRefs, n as mappingsToEntitiesConfig, o as ProjectionJoin, r as BASE_REF, s as ProjectionMapping, t as EntityMappingRow, u as projectionSchema } from "./mappings-config-xsLMn3I-.cjs";
7
- import { a as compileEntityView, i as ExplainResult, n as CompiledView, o as compileEntityViews, r as DEFAULT_VIEW_PREFIX, s as explainEntitiesConfig, t as CompileOptions } from "./view-compiler-Ll9cbIJz.cjs";
8
- import { c as SyncResult, f as reconcile, l as SyncStore, n as MirrorRecord, o as SourceRow, p as runSync, r as PersistAction, s as SyncAction, t as EntitySyncResult } from "./sync-engine-GNqRB8eS.cjs";
9
- import { a as validateProjection, c as draftErrors, d as suggestJoinConditions, f as fanOutJoins, i as primaryKeyColumns, l as draftToProjection, n as coversUniqueKey, o as ProjectionDraft, p as joinFansOut, r as hasRichMeta, s as describeCardinality, t as columnMetaFor, u as emptyProjectionDraft } from "./internal-B8ydhsKd.cjs";
4
+ import { A as BASE_REF, C as defineClivlyConfig, D as relationshipSchema, F as ProjectionRef, I as identityRefs, L as projectionSchema, M as ProjectionIdentity, N as ProjectionJoin, O as relationshipsSchema, P as ProjectionMapping, T as filterSchema, _ as MATERIALIZING_CONCEPTS, a as ClivlyEntitiesConfig, b as RelationshipVia, d as CrmConcept, g as FilterValue, h as FilterExpr, i as ClivlyConfigError, j as ProjectionFieldBinding, k as validateEntitiesConfig, l as ConfigValidationError, m as DiscoveredSchemaTable, n as CRM_CONCEPTS, p as DiscoveredColumnMeta, s as ClivlyEntityConfig, t as CANONICAL_FIELDS, u as ConfigValidationResult, v as MaterializingConcept, w as entitiesConfigSchema, x as RelationshipsMap, y as RelationshipSpec } from "./entity-config-B2RA53nw.cjs";
5
+ import { i as relationshipViaSignature, n as buildFilterFromDiscriminator, r as buildRelationships, t as RelationshipCandidate } from "./mapping-form-J0aU6O7l.cjs";
6
+ import { i as mappingsToEntitiesConfig, t as EntityMappingRow } from "./mappings-config-RQLGx8ub.cjs";
7
+ import { a as compileEntityView, i as ExplainResult, n as CompiledView, o as compileEntityViews, r as DEFAULT_VIEW_PREFIX, s as explainEntitiesConfig, t as CompileOptions } from "./view-compiler-CmEdAMwj.cjs";
8
+ import { c as SyncResult, f as reconcile, l as SyncStore, n as MirrorRecord, o as SourceRow, p as runSync, r as PersistAction, s as SyncAction, t as EntitySyncResult } from "./sync-engine-BG2O1an2.cjs";
9
+ import { a as validateProjection, c as draftErrors, d as suggestJoinConditions, f as fanOutJoins, i as primaryKeyColumns, l as draftToProjection, n as coversUniqueKey, o as ProjectionDraft, p as joinFansOut, r as hasRichMeta, s as describeCardinality, t as columnMetaFor, u as emptyProjectionDraft } from "./internal-Da_dlcQ_.cjs";
10
10
  export { type Activity, type ActivityType, BASE_REF, CANONICAL_FIELDS, type CRMAdapter, CRM_CONCEPTS, type ClivlyAuthAdapter, ClivlyConfigError, type ClivlyEntitiesConfig, type ClivlyEntityConfig, type ClivlyUser, type Company, type CompileOptions, type CompiledView, type ConfigValidationError, type ConfigValidationResult, type Contact, type ContactFilters, type ContactStatus, type CreateActivityInput, type CreateCompanyInput, type CreateContactInput, type CreateDealInput, type CreateTaskInput, type CrmConcept, type CrmMembership, type CrmRole, DEFAULT_VIEW_PREFIX, type Deal, type DealStage, type DiscoveredColumnMeta, type DiscoveredSchemaTable, type EntityMappingRow, type EntitySyncResult, type ExplainResult, type FilterExpr, type FilterValue, MATERIALIZING_CONCEPTS, type MaterializingConcept, type MembershipResolver, type MirrorRecord, type Note, type PersistAction, type ProjectionDraft, type ProjectionFieldBinding, type ProjectionIdentity, type ProjectionJoin, type ProjectionMapping, type ProjectionRef, type RecordSource, type RelationshipCandidate, type RelationshipSpec, type RelationshipVia, type RelationshipsMap, type SourceRow, type SyncAction, type SyncResult, type SyncStore, type Task, type TaskEntityType, type TaskFilters, type TaskPriority, type TaskStatus, type UpdateContactInput, type UpdateDealInput, type UpdateTaskInput, authCustom, buildFilterFromDiscriminator, buildRelationships, columnMetaFor, compileEntityView, compileEntityViews, coversUniqueKey, defineClivlyConfig, describeCardinality, draftErrors, draftToProjection, emptyProjectionDraft, entitiesConfigSchema, explainEntitiesConfig, fanOutJoins, filterSchema, hasRichMeta, identityRefs, joinFansOut, mappingsToEntitiesConfig, primaryKeyColumns, projectionSchema, reconcile, relationshipSchema, relationshipViaSignature, relationshipsSchema, runSync, suggestJoinConditions, validateEntitiesConfig, validateProjection };
package/internal.d.mts CHANGED
@@ -1,10 +1,10 @@
1
1
  import { C as UpdateDealInput, S as UpdateContactInput, _ as Task, a as ContactFilters, b as TaskPriority, c as CreateCompanyInput, d as CreateTaskInput, f as CrmRole, g as RecordSource, h as Note, i as Contact, 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 TaskEntityType, w as UpdateTaskInput, x as TaskStatus, y as TaskFilters } from "./types-B1oRXdNP.mjs";
2
2
  import { a as authCustom, i as MembershipResolver, n as ClivlyUser, r as CrmMembership, t as ClivlyAuthAdapter } from "./auth-adapter-Bjgo8LhN.mjs";
3
3
  import { t as CRMAdapter } from "./adapter-D5LRa-NA.mjs";
4
- import { C as relationshipsSchema, S as relationshipSchema, _ as RelationshipVia, a as ClivlyEntitiesConfig, b as entitiesConfigSchema, c as ConfigValidationResult, d as DiscoveredSchemaTable, f as FilterExpr, g as RelationshipSpec, h as MaterializingConcept, i as ClivlyConfigError, l as CrmConcept, m as MATERIALIZING_CONCEPTS, n as CRM_CONCEPTS, o as ClivlyEntityConfig, p as FilterValue, s as ConfigValidationError, t as CANONICAL_FIELDS, u as DiscoveredColumnMeta, v as RelationshipsMap, w as validateEntitiesConfig, x as filterSchema, y as defineClivlyConfig } from "./entity-config-C4Yf_fPj.mjs";
5
- import { i as relationshipViaSignature, n as buildFilterFromDiscriminator, r as buildRelationships, t as RelationshipCandidate } from "./mapping-form-DUvWUYCo.mjs";
6
- import { a as ProjectionIdentity, c as ProjectionRef, i as ProjectionFieldBinding, l as identityRefs, n as mappingsToEntitiesConfig, o as ProjectionJoin, r as BASE_REF, s as ProjectionMapping, t as EntityMappingRow, u as projectionSchema } from "./mappings-config-BpcR8bBo.mjs";
7
- import { a as compileEntityView, i as ExplainResult, n as CompiledView, o as compileEntityViews, r as DEFAULT_VIEW_PREFIX, s as explainEntitiesConfig, t as CompileOptions } from "./view-compiler-Cin0neDO.mjs";
8
- import { c as SyncResult, f as reconcile, l as SyncStore, n as MirrorRecord, o as SourceRow, p as runSync, r as PersistAction, s as SyncAction, t as EntitySyncResult } from "./sync-engine-ZsusW-q_.mjs";
9
- import { a as validateProjection, c as draftErrors, d as suggestJoinConditions, f as fanOutJoins, i as primaryKeyColumns, l as draftToProjection, n as coversUniqueKey, o as ProjectionDraft, p as joinFansOut, r as hasRichMeta, s as describeCardinality, t as columnMetaFor, u as emptyProjectionDraft } from "./internal-MBkNo3bw.mjs";
4
+ import { A as BASE_REF, C as defineClivlyConfig, D as relationshipSchema, F as ProjectionRef, I as identityRefs, L as projectionSchema, M as ProjectionIdentity, N as ProjectionJoin, O as relationshipsSchema, P as ProjectionMapping, T as filterSchema, _ as MATERIALIZING_CONCEPTS, a as ClivlyEntitiesConfig, b as RelationshipVia, d as CrmConcept, g as FilterValue, h as FilterExpr, i as ClivlyConfigError, j as ProjectionFieldBinding, k as validateEntitiesConfig, l as ConfigValidationError, m as DiscoveredSchemaTable, n as CRM_CONCEPTS, p as DiscoveredColumnMeta, s as ClivlyEntityConfig, t as CANONICAL_FIELDS, u as ConfigValidationResult, v as MaterializingConcept, w as entitiesConfigSchema, x as RelationshipsMap, y as RelationshipSpec } from "./entity-config-B2RA53nw.mjs";
5
+ import { i as relationshipViaSignature, n as buildFilterFromDiscriminator, r as buildRelationships, t as RelationshipCandidate } from "./mapping-form-DH77BXLv.mjs";
6
+ import { i as mappingsToEntitiesConfig, t as EntityMappingRow } from "./mappings-config-D9dsonoi.mjs";
7
+ import { a as compileEntityView, i as ExplainResult, n as CompiledView, o as compileEntityViews, r as DEFAULT_VIEW_PREFIX, s as explainEntitiesConfig, t as CompileOptions } from "./view-compiler-Bo7pqXW3.mjs";
8
+ import { c as SyncResult, f as reconcile, l as SyncStore, n as MirrorRecord, o as SourceRow, p as runSync, r as PersistAction, s as SyncAction, t as EntitySyncResult } from "./sync-engine-DgQbrJON.mjs";
9
+ import { a as validateProjection, c as draftErrors, d as suggestJoinConditions, f as fanOutJoins, i as primaryKeyColumns, l as draftToProjection, n as coversUniqueKey, o as ProjectionDraft, p as joinFansOut, r as hasRichMeta, s as describeCardinality, t as columnMetaFor, u as emptyProjectionDraft } from "./internal-CDY8g9Ic.mjs";
10
10
  export { type Activity, type ActivityType, BASE_REF, CANONICAL_FIELDS, type CRMAdapter, CRM_CONCEPTS, type ClivlyAuthAdapter, ClivlyConfigError, type ClivlyEntitiesConfig, type ClivlyEntityConfig, type ClivlyUser, type Company, type CompileOptions, type CompiledView, type ConfigValidationError, type ConfigValidationResult, type Contact, type ContactFilters, type ContactStatus, type CreateActivityInput, type CreateCompanyInput, type CreateContactInput, type CreateDealInput, type CreateTaskInput, type CrmConcept, type CrmMembership, type CrmRole, DEFAULT_VIEW_PREFIX, type Deal, type DealStage, type DiscoveredColumnMeta, type DiscoveredSchemaTable, type EntityMappingRow, type EntitySyncResult, type ExplainResult, type FilterExpr, type FilterValue, MATERIALIZING_CONCEPTS, type MaterializingConcept, type MembershipResolver, type MirrorRecord, type Note, type PersistAction, type ProjectionDraft, type ProjectionFieldBinding, type ProjectionIdentity, type ProjectionJoin, type ProjectionMapping, type ProjectionRef, type RecordSource, type RelationshipCandidate, type RelationshipSpec, type RelationshipVia, type RelationshipsMap, type SourceRow, type SyncAction, type SyncResult, type SyncStore, type Task, type TaskEntityType, type TaskFilters, type TaskPriority, type TaskStatus, type UpdateContactInput, type UpdateDealInput, type UpdateTaskInput, authCustom, buildFilterFromDiscriminator, buildRelationships, columnMetaFor, compileEntityView, compileEntityViews, coversUniqueKey, defineClivlyConfig, describeCardinality, draftErrors, draftToProjection, emptyProjectionDraft, entitiesConfigSchema, explainEntitiesConfig, fanOutJoins, filterSchema, hasRichMeta, identityRefs, joinFansOut, mappingsToEntitiesConfig, primaryKeyColumns, projectionSchema, reconcile, relationshipSchema, relationshipViaSignature, relationshipsSchema, runSync, suggestJoinConditions, validateEntitiesConfig, validateProjection };
package/internal.mjs CHANGED
@@ -1,9 +1,9 @@
1
1
  import { i as projectionSchema, r as identityRefs, t as BASE_REF } from "./projection-D7xmQP4S.mjs";
2
- import { _ as hasRichMeta, a as MATERIALIZING_CONCEPTS, c as filterSchema, d as validateEntitiesConfig, f as validateProjection, g as coversUniqueKey, h as columnMetaFor, i as ClivlyConfigError, l as relationshipSchema, m as joinFansOut, n as CRM_CONCEPTS, o as defineClivlyConfig, p as fanOutJoins, s as entitiesConfigSchema, t as CANONICAL_FIELDS, u as relationshipsSchema, v as primaryKeyColumns } from "./entity-config-D3LmzgLb.mjs";
2
+ import { _ as columnMetaFor, a as MATERIALIZING_CONCEPTS, b as primaryKeyColumns, c as entitiesConfigSchema, d as relationshipSchema, f as relationshipsSchema, g as joinFansOut, h as fanOutJoins, i as ClivlyConfigError, l as filterSchema, m as validateProjection, n as CRM_CONCEPTS, p as validateEntitiesConfig, s as defineClivlyConfig, t as CANONICAL_FIELDS, v as coversUniqueKey, y as hasRichMeta } from "./entity-config-kUHri9yA.mjs";
3
+ import { n as mappingsToEntitiesConfig } from "./mappings-config-B1b1HVBg.mjs";
3
4
  import { t as authCustom } from "./auth-adapter-gfVDxf3d.mjs";
4
5
  import { n as buildRelationships, r as relationshipViaSignature, t as buildFilterFromDiscriminator } from "./mapping-form-DigkuvFc.mjs";
5
- import { t as mappingsToEntitiesConfig } from "./mappings-config-bJQT_gSa.mjs";
6
- import { a as suggestJoinConditions, i as emptyProjectionDraft, n as draftErrors, r as draftToProjection, t as describeCardinality } from "./internal-DMySVbM0.mjs";
7
- import { i as explainEntitiesConfig, n as compileEntityView, r as compileEntityViews, t as DEFAULT_VIEW_PREFIX } from "./view-compiler-DlTpOfZi.mjs";
8
- import { i as runSync, r as reconcile } from "./sync-engine-Bg6-SznL.mjs";
6
+ import { a as suggestJoinConditions, i as emptyProjectionDraft, n as draftErrors, r as draftToProjection, t as describeCardinality } from "./internal-Df-PtOH_.mjs";
7
+ import { i as explainEntitiesConfig, n as compileEntityView, r as compileEntityViews, t as DEFAULT_VIEW_PREFIX } from "./view-compiler-CQx8TRrW.mjs";
8
+ import { i as runSync, r as reconcile } from "./sync-engine-SuxSzbZ4.mjs";
9
9
  export { BASE_REF, CANONICAL_FIELDS, CRM_CONCEPTS, ClivlyConfigError, DEFAULT_VIEW_PREFIX, MATERIALIZING_CONCEPTS, authCustom, buildFilterFromDiscriminator, buildRelationships, columnMetaFor, compileEntityView, compileEntityViews, coversUniqueKey, defineClivlyConfig, describeCardinality, draftErrors, draftToProjection, emptyProjectionDraft, entitiesConfigSchema, explainEntitiesConfig, fanOutJoins, filterSchema, hasRichMeta, identityRefs, joinFansOut, mappingsToEntitiesConfig, primaryKeyColumns, projectionSchema, reconcile, relationshipSchema, relationshipViaSignature, relationshipsSchema, runSync, suggestJoinConditions, validateEntitiesConfig, validateProjection };
@@ -1,4 +1,4 @@
1
- import { _ as RelationshipVia, f as FilterExpr, v as RelationshipsMap } from "./entity-config-C4Yf_fPj.cjs";
1
+ import { b as RelationshipVia, h as FilterExpr, x as RelationshipsMap } from "./entity-config-B2RA53nw.mjs";
2
2
  //#region ../core/src/mapping-form.d.ts
3
3
  /**
4
4
  * A relationship the mapping UI can offer or has configured, in the shape the
@@ -1,4 +1,4 @@
1
- import { _ as RelationshipVia, f as FilterExpr, v as RelationshipsMap } from "./entity-config-C4Yf_fPj.mjs";
1
+ import { b as RelationshipVia, h as FilterExpr, x as RelationshipsMap } from "./entity-config-B2RA53nw.cjs";
2
2
  //#region ../core/src/mapping-form.d.ts
3
3
  /**
4
4
  * A relationship the mapping UI can offer or has configured, in the shape the
@@ -1,4 +1,4 @@
1
- const require_entity_config = require("./entity-config-CsLl-ftC.cjs");
1
+ const require_entity_config = require("./entity-config-DtBsl2MQ.cjs");
2
2
  //#region ../core/src/mappings-config.ts
3
3
  const RESERVED_FIELD = "id";
4
4
  /**
@@ -121,7 +121,36 @@ function mappingsToEntitiesConfig(rows) {
121
121
  for (const { row, key } of assigned) entities[key] = buildEntity(row, refIndex);
122
122
  return { entities };
123
123
  }
124
+ const CUSTOM_CONCEPT = "custom";
125
+ function entitiesToMappings(config) {
126
+ const rows = [];
127
+ for (const [entityKey, entity] of Object.entries(config.entities)) {
128
+ const row = {
129
+ entityKey,
130
+ sourceTable: entity.projection?.baseTable ?? entity.source,
131
+ targetConcept: entity.concept,
132
+ role: entity.role ?? DEFAULT_ROLE,
133
+ fieldMap: entity.projection ? {} : entity.fields
134
+ };
135
+ if (entity.filter) row.filter = entity.filter;
136
+ if (entity.relationships) row.relationships = entity.relationships;
137
+ if (entity.projection) row.projection = entity.projection;
138
+ if (entity.concept === CUSTOM_CONCEPT) {
139
+ row.objectTypeSlug = entityKey;
140
+ if (entity.objectType) row.objectType = entity.objectType;
141
+ }
142
+ if (entity.targetObjectTypeId) row.targetObjectTypeId = entity.targetObjectTypeId;
143
+ rows.push(row);
144
+ }
145
+ return rows;
146
+ }
124
147
  //#endregion
148
+ Object.defineProperty(exports, "entitiesToMappings", {
149
+ enumerable: true,
150
+ get: function() {
151
+ return entitiesToMappings;
152
+ }
153
+ });
125
154
  Object.defineProperty(exports, "mappingsToEntitiesConfig", {
126
155
  enumerable: true,
127
156
  get: function() {
@@ -1,4 +1,4 @@
1
- import { t as CANONICAL_FIELDS } from "./entity-config-D3LmzgLb.mjs";
1
+ import { t as CANONICAL_FIELDS } from "./entity-config-kUHri9yA.mjs";
2
2
  //#region ../core/src/mappings-config.ts
3
3
  const RESERVED_FIELD = "id";
4
4
  /**
@@ -121,5 +121,28 @@ function mappingsToEntitiesConfig(rows) {
121
121
  for (const { row, key } of assigned) entities[key] = buildEntity(row, refIndex);
122
122
  return { entities };
123
123
  }
124
+ const CUSTOM_CONCEPT = "custom";
125
+ function entitiesToMappings(config) {
126
+ const rows = [];
127
+ for (const [entityKey, entity] of Object.entries(config.entities)) {
128
+ const row = {
129
+ entityKey,
130
+ sourceTable: entity.projection?.baseTable ?? entity.source,
131
+ targetConcept: entity.concept,
132
+ role: entity.role ?? DEFAULT_ROLE,
133
+ fieldMap: entity.projection ? {} : entity.fields
134
+ };
135
+ if (entity.filter) row.filter = entity.filter;
136
+ if (entity.relationships) row.relationships = entity.relationships;
137
+ if (entity.projection) row.projection = entity.projection;
138
+ if (entity.concept === CUSTOM_CONCEPT) {
139
+ row.objectTypeSlug = entityKey;
140
+ if (entity.objectType) row.objectType = entity.objectType;
141
+ }
142
+ if (entity.targetObjectTypeId) row.targetObjectTypeId = entity.targetObjectTypeId;
143
+ rows.push(row);
144
+ }
145
+ return rows;
146
+ }
124
147
  //#endregion
125
- export { mappingsToEntitiesConfig as t };
148
+ export { mappingsToEntitiesConfig as n, entitiesToMappings as t };
@@ -0,0 +1,85 @@
1
+ import { P as ProjectionMapping, a as ClivlyEntitiesConfig, h as FilterExpr, x as RelationshipsMap } from "./entity-config-B2RA53nw.mjs";
2
+ //#region ../core/src/mappings-config.d.ts
3
+ /**
4
+ * Mappings → Entity Config bridge.
5
+ *
6
+ * `crm_entity_mappings` rows are the single source of truth for how a host
7
+ * schema maps onto Clivly's CRM concepts. This module compiles those rows into
8
+ * a `ClivlyEntitiesConfig` — the contract the view compiler and sync engine
9
+ * consume — so the persisted mapping and the runtime pipeline never diverge.
10
+ *
11
+ * The row model has no explicit entity-key column (it's keyed by
12
+ * `sourceTable + targetConcept + role`), but the config's `relationships`
13
+ * reference other entities *by key*. This builder therefore derives a stable
14
+ * key per row and resolves each relationship's `entity` reference through the
15
+ * same derivation — so a relationship stored as `entity: "<relatedTable>"`
16
+ * (the shape `mappings.suggest` produces) resolves to the right entity.
17
+ */
18
+ /**
19
+ * A persisted `crm_entity_mappings` row, narrowed to the columns the builder
20
+ * reads. Structurally compatible with the Drizzle row (jsonb columns typed
21
+ * loosely) so the API layer can pass `db.select()` results straight in.
22
+ */
23
+ interface EntityMappingRow {
24
+ fieldMap: Record<string, string>;
25
+ filter?: Record<string, unknown> | null;
26
+ /**
27
+ * Advanced mapping: a base table plus explicit joins. When set, this — not
28
+ * `fieldMap` — is the authored source of truth, and `sourceTable` merely
29
+ * mirrors `projection.baseTable`.
30
+ */
31
+ projection?: ProjectionMapping | null;
32
+ relationships?: Record<string, unknown> | null;
33
+ role?: string | null;
34
+ sourceTable: string;
35
+ status?: string | null;
36
+ targetConcept: string;
37
+ targetObjectTypeId?: string | null;
38
+ }
39
+ /**
40
+ * Compile persisted mapping rows into a `ClivlyEntitiesConfig`. Only `active`
41
+ * rows with at least one mapped field are included; disabled/suggested rows and
42
+ * unmapped rows are skipped. Returns `{ entities: {} }` when nothing is
43
+ * eligible — a no-op the view compiler and sync engine both tolerate.
44
+ */
45
+ declare function mappingsToEntitiesConfig(rows: EntityMappingRow[]): ClivlyEntitiesConfig;
46
+ /**
47
+ * Entity Config → Mappings, the inverse of `mappingsToEntitiesConfig`.
48
+ *
49
+ * `objectType` in config creates the custom object but nothing creates the
50
+ * MAPPING, so config-as-code ended at a created object and a sync that stored
51
+ * nothing. This produces the rows that close that gap.
52
+ *
53
+ * The two shapes align column for column, with one asymmetry that cannot be
54
+ * resolved by naming: the row model has no entity-key column — a row is keyed by
55
+ * `(sourceTable, targetConcept, role)` — while a CUSTOM entity's key *is* its
56
+ * object type slug, and is routinely different from its source table
57
+ * ("client-accounts" derived from "accounts"). So the key travels explicitly on
58
+ * every row rather than being left for the reverse derivation to guess.
59
+ */
60
+ interface MappingFromConfig {
61
+ /**
62
+ * The config entity key this row came from. Not a row column — the caller
63
+ * needs it to resolve a custom object type and to report what it wrote.
64
+ */
65
+ entityKey: string;
66
+ fieldMap: Record<string, string>;
67
+ filter?: FilterExpr;
68
+ /** Declared custom object, when the config declares one rather than pinning an id. */
69
+ objectType?: {
70
+ iconKey?: string;
71
+ name: string;
72
+ pluralName?: string;
73
+ };
74
+ /** The custom object type's slug — the entity key. Custom entities only. */
75
+ objectTypeSlug?: string;
76
+ projection?: ProjectionMapping;
77
+ relationships?: RelationshipsMap;
78
+ role: string;
79
+ sourceTable: string;
80
+ targetConcept: string;
81
+ targetObjectTypeId?: string;
82
+ }
83
+ declare function entitiesToMappings(config: ClivlyEntitiesConfig): MappingFromConfig[];
84
+ //#endregion
85
+ export { mappingsToEntitiesConfig as i, MappingFromConfig as n, entitiesToMappings as r, EntityMappingRow as t };
@@ -0,0 +1,85 @@
1
+ import { P as ProjectionMapping, a as ClivlyEntitiesConfig, h as FilterExpr, x as RelationshipsMap } from "./entity-config-B2RA53nw.cjs";
2
+ //#region ../core/src/mappings-config.d.ts
3
+ /**
4
+ * Mappings → Entity Config bridge.
5
+ *
6
+ * `crm_entity_mappings` rows are the single source of truth for how a host
7
+ * schema maps onto Clivly's CRM concepts. This module compiles those rows into
8
+ * a `ClivlyEntitiesConfig` — the contract the view compiler and sync engine
9
+ * consume — so the persisted mapping and the runtime pipeline never diverge.
10
+ *
11
+ * The row model has no explicit entity-key column (it's keyed by
12
+ * `sourceTable + targetConcept + role`), but the config's `relationships`
13
+ * reference other entities *by key*. This builder therefore derives a stable
14
+ * key per row and resolves each relationship's `entity` reference through the
15
+ * same derivation — so a relationship stored as `entity: "<relatedTable>"`
16
+ * (the shape `mappings.suggest` produces) resolves to the right entity.
17
+ */
18
+ /**
19
+ * A persisted `crm_entity_mappings` row, narrowed to the columns the builder
20
+ * reads. Structurally compatible with the Drizzle row (jsonb columns typed
21
+ * loosely) so the API layer can pass `db.select()` results straight in.
22
+ */
23
+ interface EntityMappingRow {
24
+ fieldMap: Record<string, string>;
25
+ filter?: Record<string, unknown> | null;
26
+ /**
27
+ * Advanced mapping: a base table plus explicit joins. When set, this — not
28
+ * `fieldMap` — is the authored source of truth, and `sourceTable` merely
29
+ * mirrors `projection.baseTable`.
30
+ */
31
+ projection?: ProjectionMapping | null;
32
+ relationships?: Record<string, unknown> | null;
33
+ role?: string | null;
34
+ sourceTable: string;
35
+ status?: string | null;
36
+ targetConcept: string;
37
+ targetObjectTypeId?: string | null;
38
+ }
39
+ /**
40
+ * Compile persisted mapping rows into a `ClivlyEntitiesConfig`. Only `active`
41
+ * rows with at least one mapped field are included; disabled/suggested rows and
42
+ * unmapped rows are skipped. Returns `{ entities: {} }` when nothing is
43
+ * eligible — a no-op the view compiler and sync engine both tolerate.
44
+ */
45
+ declare function mappingsToEntitiesConfig(rows: EntityMappingRow[]): ClivlyEntitiesConfig;
46
+ /**
47
+ * Entity Config → Mappings, the inverse of `mappingsToEntitiesConfig`.
48
+ *
49
+ * `objectType` in config creates the custom object but nothing creates the
50
+ * MAPPING, so config-as-code ended at a created object and a sync that stored
51
+ * nothing. This produces the rows that close that gap.
52
+ *
53
+ * The two shapes align column for column, with one asymmetry that cannot be
54
+ * resolved by naming: the row model has no entity-key column — a row is keyed by
55
+ * `(sourceTable, targetConcept, role)` — while a CUSTOM entity's key *is* its
56
+ * object type slug, and is routinely different from its source table
57
+ * ("client-accounts" derived from "accounts"). So the key travels explicitly on
58
+ * every row rather than being left for the reverse derivation to guess.
59
+ */
60
+ interface MappingFromConfig {
61
+ /**
62
+ * The config entity key this row came from. Not a row column — the caller
63
+ * needs it to resolve a custom object type and to report what it wrote.
64
+ */
65
+ entityKey: string;
66
+ fieldMap: Record<string, string>;
67
+ filter?: FilterExpr;
68
+ /** Declared custom object, when the config declares one rather than pinning an id. */
69
+ objectType?: {
70
+ iconKey?: string;
71
+ name: string;
72
+ pluralName?: string;
73
+ };
74
+ /** The custom object type's slug — the entity key. Custom entities only. */
75
+ objectTypeSlug?: string;
76
+ projection?: ProjectionMapping;
77
+ relationships?: RelationshipsMap;
78
+ role: string;
79
+ sourceTable: string;
80
+ targetConcept: string;
81
+ targetObjectTypeId?: string;
82
+ }
83
+ declare function entitiesToMappings(config: ClivlyEntitiesConfig): MappingFromConfig[];
84
+ //#endregion
85
+ export { mappingsToEntitiesConfig as i, MappingFromConfig as n, entitiesToMappings as r, EntityMappingRow as t };
@@ -1,4 +1,4 @@
1
- import { a as ClivlyEntitiesConfig } from "./entity-config-C4Yf_fPj.cjs";
1
+ import { a as ClivlyEntitiesConfig } from "./entity-config-B2RA53nw.cjs";
2
2
  //#region ../sdk/src/drizzle-meta.d.ts
3
3
  declare const DRIZZLE_META: "__clivly_drizzle_source_meta__";
4
4
  interface DrizzleSourceMeta {
@@ -78,6 +78,12 @@ interface ClivlySDKConfig {
78
78
  * runtimes can supply their own.
79
79
  */
80
80
  env?: Record<string, string | undefined>;
81
+ /**
82
+ * Where this app is running: `local_dev`, `preview` or `production`. Reported
83
+ * on each heartbeat so the dashboard can name the environment it is watching.
84
+ * Inferred from platform variables and `NODE_ENV` when omitted.
85
+ */
86
+ environment?: "local_dev" | "preview" | "production";
81
87
  /**
82
88
  * 🚧 Not implemented in 0.1.x. Reserved options for tunnel mode and CRM
83
89
  * write-back — they have NO effect yet and land with the Cloudflare
@@ -112,6 +118,17 @@ interface ClivlySDKConfig {
112
118
  */
113
119
  namespaceReady?: boolean;
114
120
  orm?: string;
121
+ /**
122
+ * Presence transport override. HTTP remains the default until the recorded
123
+ * production rollout gate permits a WebSocket default; set `http` explicitly
124
+ * to keep the legacy transport after that rollout. Operators may also set
125
+ * `CLIVLY_PRESENCE_TRANSPORT` without changing application code.
126
+ */
127
+ presence?: {
128
+ /** Explicit release identity; platform deployment ids and commit SHAs follow. */
129
+ deploymentId?: string;
130
+ transport?: "http" | "websocket";
131
+ };
115
132
  /**
116
133
  * Network retry policy for outbound calls (heartbeat + sync push). Transient
117
134
  * failures (network errors, HTTP 429, HTTP 5xx) are retried with exponential
@@ -217,6 +234,26 @@ interface CreateChatSessionHandlerOptions {
217
234
  */
218
235
  resolveUser?: (req: Request) => Promise<ClivlyUser | null> | ClivlyUser | null;
219
236
  }
237
+ /** One object type ensured by `ensureSchema`. */
238
+ interface EnsuredObjectTypeResult {
239
+ /** True when this call created it, false when it already existed. */
240
+ created: boolean;
241
+ id: string;
242
+ slug: string;
243
+ }
244
+ /** One mapping ensured by `ensureSchema`. */
245
+ interface EnsuredMappingResult {
246
+ created: boolean;
247
+ /** The config entity key this mapping came from. */
248
+ entityKey: string;
249
+ id: string;
250
+ /** True when an existing config-owned mapping's definition changed. */
251
+ updated: boolean;
252
+ }
253
+ interface EnsureSchemaResult {
254
+ mappings: EnsuredMappingResult[];
255
+ objectTypes: EnsuredObjectTypeResult[];
256
+ }
220
257
  interface DoctorCheck {
221
258
  /** Human-readable outcome — what passed, or why it failed. */
222
259
  detail: string;
@@ -325,6 +362,31 @@ interface ClivlySDK {
325
362
  createClivlyHandler(): (req: Request) => Promise<Response>;
326
363
  /** Validate this setup end-to-end (read-only) before the first sync. */
327
364
  doctor(): Promise<DoctorReport>;
365
+ /**
366
+ * Create any custom object types the config declares that this workspace does
367
+ * not have yet, keyed by entity slug — so `clivly.config.ts` needs no
368
+ * dashboard-generated id. Create-only and idempotent.
369
+ *
370
+ * Resolves to the ensured objects (empty when the config declares none), or
371
+ * `null` when the request could not be delivered.
372
+ */
373
+ ensureCustomObjects(): Promise<{
374
+ slug: string;
375
+ id: string;
376
+ created: boolean;
377
+ }[] | null>;
378
+ /**
379
+ * Declare the whole schema this config describes — custom object types AND
380
+ * the mappings that make them receive rows. The superset of
381
+ * `ensureCustomObjects`, which creates the object container and nothing else.
382
+ *
383
+ * Resolves to `null` when the request could not be delivered (including
384
+ * against a server too old to have the route), and REJECTS when Clivly
385
+ * refuses the config — e.g. an entity that would overwrite a mapping managed
386
+ * in the dashboard. That distinction matters: unreachable is worth a retry,
387
+ * refused is worth reading.
388
+ */
389
+ ensureSchema(): Promise<EnsureSchemaResult | null>;
328
390
  /**
329
391
  * Send a single heartbeat now. Returns true on success. Kept for the keep-alive
330
392
  * loop and back-compat; use `connect()` when you need the failure reason.
@@ -357,7 +419,7 @@ interface ClivlySDK {
357
419
  */
358
420
  start(): Promise<void>;
359
421
  /** Stop the keep-alive loop. */
360
- stop(): void;
422
+ stop(): Promise<void>;
361
423
  /**
362
424
  * Sync all configured sources now. `delta` (default) pages changed rows since
363
425
  * the last cursor; `full` pushes each complete entity so the server can
@@ -378,4 +440,4 @@ interface NamespaceIntrospector {
378
440
  sampleSelect(table: string): Promise<void>;
379
441
  }
380
442
  //#endregion
381
- export { ClivlyConnectResult as a, ClivlyUser as c, DiscoveredTable as d, DoctorCheck as f, ClivlyConnectReason as i, CreateChatSessionHandlerOptions as l, SyncSource as m, ChatSessionRequestBody as n, ClivlySDK as o, DoctorReport as p, ChatWidgetVisitor as r, ClivlySDKConfig as s, NamespaceIntrospector as t, CursorStore as u };
443
+ export { SyncSource as _, ClivlyConnectResult as a, ClivlyUser as c, DiscoveredTable as d, DoctorCheck as f, EnsuredObjectTypeResult as g, EnsuredMappingResult as h, ClivlyConnectReason as i, CreateChatSessionHandlerOptions as l, EnsureSchemaResult as m, ChatSessionRequestBody as n, ClivlySDK as o, DoctorReport as p, ChatWidgetVisitor as r, ClivlySDKConfig as s, NamespaceIntrospector as t, CursorStore as u };