clivly 0.9.1 → 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 (84) 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 +2 -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.d.cts +1 -1
  17. package/core-sync-engine.d.mts +1 -1
  18. package/core-view-compiler.d.cts +1 -1
  19. package/core-view-compiler.d.mts +1 -1
  20. package/core.cjs +3 -3
  21. package/core.d.cts +6 -6
  22. package/core.d.mts +6 -6
  23. package/core.mjs +3 -3
  24. package/{drizzle-DooDUGqO.d.mts → drizzle-CiK8MMEZ.d.mts} +1 -1
  25. package/{drizzle-jz0lrAgl.d.cts → drizzle-DEtRrqtc.d.cts} +1 -1
  26. package/drizzle.d.cts +2 -2
  27. package/drizzle.d.mts +2 -2
  28. package/{entity-config-fKQhimtD.d.mts → entity-config-B2RA53nw.d.cts} +25 -1
  29. package/{entity-config-fKQhimtD.d.cts → entity-config-B2RA53nw.d.mts} +25 -1
  30. package/{entity-config-nuXge6rY.cjs → entity-config-DtBsl2MQ.cjs} +36 -12
  31. package/{entity-config-D08zAeFY.mjs → entity-config-kUHri9yA.mjs} +31 -13
  32. package/index.cjs +371 -27
  33. package/index.d.cts +1 -0
  34. package/index.d.mts +1 -0
  35. package/index.mjs +371 -27
  36. package/{internal-C-YBW2DB.d.cts → internal-CDY8g9Ic.d.mts} +1 -1
  37. package/{internal-D4HDi2GC.cjs → internal-CwnEG6Wl.cjs} +1 -1
  38. package/{internal-BLCK81kB.d.mts → internal-Da_dlcQ_.d.cts} +1 -1
  39. package/{internal-BGVUG312.mjs → internal-Df-PtOH_.mjs} +1 -1
  40. package/internal-drizzle.d.cts +1 -1
  41. package/internal-drizzle.d.mts +1 -1
  42. package/internal-entity-config.cjs +2 -1
  43. package/internal-entity-config.d.cts +2 -2
  44. package/internal-entity-config.d.mts +2 -2
  45. package/internal-entity-config.mjs +2 -2
  46. package/internal-entity-heuristics.cjs +1 -1
  47. package/internal-entity-heuristics.d.cts +1 -1
  48. package/internal-entity-heuristics.d.mts +1 -1
  49. package/internal-entity-heuristics.mjs +1 -1
  50. package/internal-mapping-form.d.cts +1 -1
  51. package/internal-mapping-form.d.mts +1 -1
  52. package/internal-mappings-config.cjs +2 -1
  53. package/internal-mappings-config.d.cts +2 -2
  54. package/internal-mappings-config.d.mts +2 -2
  55. package/internal-mappings-config.mjs +2 -2
  56. package/internal-sync-engine.d.cts +1 -1
  57. package/internal-sync-engine.d.mts +1 -1
  58. package/internal-view-compiler.d.cts +1 -1
  59. package/internal-view-compiler.d.mts +1 -1
  60. package/internal.cjs +3 -3
  61. package/internal.d.cts +6 -6
  62. package/internal.d.mts +6 -6
  63. package/internal.mjs +3 -3
  64. package/{mapping-form-Du36VZr1.d.mts → mapping-form-DH77BXLv.d.mts} +1 -1
  65. package/{mapping-form-DhY0iFmN.d.cts → mapping-form-J0aU6O7l.d.cts} +1 -1
  66. package/{mappings-config-C8ynKmDK.cjs → mappings-config-B0RqFLxu.cjs} +30 -1
  67. package/{mappings-config-DNaYGyKN.mjs → mappings-config-B1b1HVBg.mjs} +25 -2
  68. package/{mappings-config-B1qNM8VL.d.cts → mappings-config-D9dsonoi.d.mts} +40 -2
  69. package/{mappings-config-BChZsany.d.mts → mappings-config-RQLGx8ub.d.cts} +40 -2
  70. package/{namespace-probe-BkUs8raG.d.mts → namespace-probe-C6aHjedO.d.cts} +65 -3
  71. package/{namespace-probe-aRFmpU85.d.cts → namespace-probe-Dj-0Q3Hb.d.mts} +65 -3
  72. package/package.json +1 -1
  73. package/{sdk-Bj-ZDf4u.cjs → sdk-D4Wp_uxb.cjs} +754 -44
  74. package/{sdk-BvRD2jAp.mjs → sdk-DXV8M_Io.mjs} +754 -44
  75. package/sdk.cjs +4 -2
  76. package/sdk.d.cts +3 -3
  77. package/sdk.d.mts +3 -3
  78. package/sdk.mjs +3 -3
  79. package/{sync-engine-DHQ7rXZe.d.mts → sync-engine-BG2O1an2.d.cts} +2 -2
  80. package/{sync-engine-DiPjH53O.d.cts → sync-engine-DgQbrJON.d.mts} +2 -2
  81. package/{view-compiler-CcUwzZut.d.mts → view-compiler-Bo7pqXW3.d.mts} +1 -1
  82. package/{view-compiler-DqAdVxLq.d.cts → view-compiler-CmEdAMwj.d.cts} +1 -1
  83. package/vite.d.cts +1 -1
  84. package/vite.d.mts +1 -1
@@ -1,4 +1,4 @@
1
- import { a as MATERIALIZING_CONCEPTS } from "./entity-config-D08zAeFY.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-DhY0iFmN.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-Du36VZr1.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-C8ynKmDK.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-B1qNM8VL.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-BChZsany.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-DNaYGyKN.mjs";
2
- export { mappingsToEntitiesConfig };
1
+ import { n as mappingsToEntitiesConfig, t as entitiesToMappings } from "./mappings-config-B1b1HVBg.mjs";
2
+ export { entitiesToMappings, mappingsToEntitiesConfig };
@@ -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-DiPjH53O.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-DHQ7rXZe.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 { 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-DqAdVxLq.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-CmEdAMwj.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-CcUwzZut.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-Bo7pqXW3.mjs";
2
2
  export { CompileOptions, CompiledView, DEFAULT_VIEW_PREFIX, ExplainResult, compileEntityView, compileEntityViews, explainEntitiesConfig, explainViewExecutionError };
package/internal.cjs CHANGED
@@ -1,10 +1,10 @@
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-nuXge6rY.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-C8ynKmDK.cjs");
7
- const require_internal = require("./internal-D4HDi2GC.cjs");
7
+ const require_internal = require("./internal-CwnEG6Wl.cjs");
8
8
  const require_view_compiler = require("./view-compiler-Blu4OXJ7.cjs");
9
9
  const require_sync_engine = require("./sync-engine-abE94g6X.cjs");
10
10
  exports.BASE_REF = require_projection.BASE_REF;
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 { A as ProjectionIdentity, C as filterSchema, D as validateEntitiesConfig, E as relationshipsSchema, F as projectionSchema, M as ProjectionMapping, N as ProjectionRef, O as BASE_REF, P as identityRefs, S as entitiesConfigSchema, T as relationshipSchema, _ as MaterializingConcept, a as ClivlyEntitiesConfig, b as RelationshipsMap, d as CrmConcept, f as DiscoveredColumnMeta, g as MATERIALIZING_CONCEPTS, h as FilterValue, i as ClivlyConfigError, j as ProjectionJoin, k as ProjectionFieldBinding, l as ConfigValidationError, m as FilterExpr, n as CRM_CONCEPTS, p as DiscoveredSchemaTable, s as ClivlyEntityConfig, t as CANONICAL_FIELDS, u as ConfigValidationResult, v as RelationshipSpec, x as defineClivlyConfig, y as RelationshipVia } from "./entity-config-fKQhimtD.cjs";
5
- import { i as relationshipViaSignature, n as buildFilterFromDiscriminator, r as buildRelationships, t as RelationshipCandidate } from "./mapping-form-DhY0iFmN.cjs";
6
- import { n as mappingsToEntitiesConfig, t as EntityMappingRow } from "./mappings-config-B1qNM8VL.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-DqAdVxLq.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-DiPjH53O.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-C-YBW2DB.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 { A as ProjectionIdentity, C as filterSchema, D as validateEntitiesConfig, E as relationshipsSchema, F as projectionSchema, M as ProjectionMapping, N as ProjectionRef, O as BASE_REF, P as identityRefs, S as entitiesConfigSchema, T as relationshipSchema, _ as MaterializingConcept, a as ClivlyEntitiesConfig, b as RelationshipsMap, d as CrmConcept, f as DiscoveredColumnMeta, g as MATERIALIZING_CONCEPTS, h as FilterValue, i as ClivlyConfigError, j as ProjectionJoin, k as ProjectionFieldBinding, l as ConfigValidationError, m as FilterExpr, n as CRM_CONCEPTS, p as DiscoveredSchemaTable, s as ClivlyEntityConfig, t as CANONICAL_FIELDS, u as ConfigValidationResult, v as RelationshipSpec, x as defineClivlyConfig, y as RelationshipVia } from "./entity-config-fKQhimtD.mjs";
5
- import { i as relationshipViaSignature, n as buildFilterFromDiscriminator, r as buildRelationships, t as RelationshipCandidate } from "./mapping-form-Du36VZr1.mjs";
6
- import { n as mappingsToEntitiesConfig, t as EntityMappingRow } from "./mappings-config-BChZsany.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-CcUwzZut.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-DHQ7rXZe.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-BLCK81kB.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 coversUniqueKey, a as MATERIALIZING_CONCEPTS, c as filterSchema, d as relationshipsSchema, f as validateEntitiesConfig, g as columnMetaFor, h as joinFansOut, i as ClivlyConfigError, m as fanOutJoins, n as CRM_CONCEPTS, o as defineClivlyConfig, p as validateProjection, s as entitiesConfigSchema, t as CANONICAL_FIELDS, u as relationshipSchema, v as hasRichMeta, y as primaryKeyColumns } from "./entity-config-D08zAeFY.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-DNaYGyKN.mjs";
6
- import { a as suggestJoinConditions, i as emptyProjectionDraft, n as draftErrors, r as draftToProjection, t as describeCardinality } from "./internal-BGVUG312.mjs";
6
+ import { a as suggestJoinConditions, i as emptyProjectionDraft, n as draftErrors, r as draftToProjection, t as describeCardinality } from "./internal-Df-PtOH_.mjs";
7
7
  import { i as explainEntitiesConfig, n as compileEntityView, r as compileEntityViews, t as DEFAULT_VIEW_PREFIX } from "./view-compiler-CQx8TRrW.mjs";
8
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 { b as RelationshipsMap, m as FilterExpr, y as RelationshipVia } from "./entity-config-fKQhimtD.mjs";
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 { b as RelationshipsMap, m as FilterExpr, y as RelationshipVia } from "./entity-config-fKQhimtD.cjs";
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-nuXge6rY.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-D08zAeFY.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 };
@@ -1,4 +1,4 @@
1
- import { M as ProjectionMapping, a as ClivlyEntitiesConfig } from "./entity-config-fKQhimtD.cjs";
1
+ import { P as ProjectionMapping, a as ClivlyEntitiesConfig, h as FilterExpr, x as RelationshipsMap } from "./entity-config-B2RA53nw.mjs";
2
2
  //#region ../core/src/mappings-config.d.ts
3
3
  /**
4
4
  * Mappings → Entity Config bridge.
@@ -43,5 +43,43 @@ interface EntityMappingRow {
43
43
  * eligible — a no-op the view compiler and sync engine both tolerate.
44
44
  */
45
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[];
46
84
  //#endregion
47
- export { mappingsToEntitiesConfig as n, EntityMappingRow as t };
85
+ export { mappingsToEntitiesConfig as i, MappingFromConfig as n, entitiesToMappings as r, EntityMappingRow as t };
@@ -1,4 +1,4 @@
1
- import { M as ProjectionMapping, a as ClivlyEntitiesConfig } from "./entity-config-fKQhimtD.mjs";
1
+ import { P as ProjectionMapping, a as ClivlyEntitiesConfig, h as FilterExpr, x as RelationshipsMap } from "./entity-config-B2RA53nw.cjs";
2
2
  //#region ../core/src/mappings-config.d.ts
3
3
  /**
4
4
  * Mappings → Entity Config bridge.
@@ -43,5 +43,43 @@ interface EntityMappingRow {
43
43
  * eligible — a no-op the view compiler and sync engine both tolerate.
44
44
  */
45
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[];
46
84
  //#endregion
47
- export { mappingsToEntitiesConfig as n, EntityMappingRow as t };
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-fKQhimtD.mjs";
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 };
@@ -1,4 +1,4 @@
1
- import { a as ClivlyEntitiesConfig } from "./entity-config-fKQhimtD.cjs";
1
+ import { a as ClivlyEntitiesConfig } from "./entity-config-B2RA53nw.mjs";
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 };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "clivly",
3
- "version": "0.9.1",
3
+ "version": "0.9.2",
4
4
  "private": false,
5
5
  "type": "module",
6
6
  "description": "Clivly CLI — scaffold a CRM into your app (clivly init).",