clivly 0.9.1 → 0.9.3

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 (86) hide show
  1. package/README.md +79 -13
  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 +8 -7
  22. package/core.d.mts +8 -7
  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 +452 -38
  33. package/index.d.cts +3 -1
  34. package/index.d.mts +3 -1
  35. package/index.mjs +452 -39
  36. package/integration-state-BK-riZnm.d.cts +130 -0
  37. package/integration-state-BK-riZnm.d.mts +130 -0
  38. package/{internal-C-YBW2DB.d.cts → internal-CDY8g9Ic.d.mts} +1 -1
  39. package/{internal-D4HDi2GC.cjs → internal-CwnEG6Wl.cjs} +1 -1
  40. package/{internal-BLCK81kB.d.mts → internal-Da_dlcQ_.d.cts} +1 -1
  41. package/{internal-BGVUG312.mjs → internal-Df-PtOH_.mjs} +1 -1
  42. package/internal-drizzle.d.cts +1 -1
  43. package/internal-drizzle.d.mts +1 -1
  44. package/internal-entity-config.cjs +2 -1
  45. package/internal-entity-config.d.cts +2 -2
  46. package/internal-entity-config.d.mts +2 -2
  47. package/internal-entity-config.mjs +2 -2
  48. package/internal-entity-heuristics.cjs +1 -1
  49. package/internal-entity-heuristics.d.cts +1 -1
  50. package/internal-entity-heuristics.d.mts +1 -1
  51. package/internal-entity-heuristics.mjs +1 -1
  52. package/internal-mapping-form.d.cts +1 -1
  53. package/internal-mapping-form.d.mts +1 -1
  54. package/internal-mappings-config.cjs +2 -1
  55. package/internal-mappings-config.d.cts +2 -2
  56. package/internal-mappings-config.d.mts +2 -2
  57. package/internal-mappings-config.mjs +2 -2
  58. package/internal-sync-engine.d.cts +1 -1
  59. package/internal-sync-engine.d.mts +1 -1
  60. package/internal-view-compiler.d.cts +1 -1
  61. package/internal-view-compiler.d.mts +1 -1
  62. package/internal.cjs +3 -3
  63. package/internal.d.cts +8 -7
  64. package/internal.d.mts +8 -7
  65. package/internal.mjs +3 -3
  66. package/{mapping-form-Du36VZr1.d.mts → mapping-form-DH77BXLv.d.mts} +1 -1
  67. package/{mapping-form-DhY0iFmN.d.cts → mapping-form-J0aU6O7l.d.cts} +1 -1
  68. package/{mappings-config-C8ynKmDK.cjs → mappings-config-B0RqFLxu.cjs} +30 -1
  69. package/{mappings-config-DNaYGyKN.mjs → mappings-config-B1b1HVBg.mjs} +25 -2
  70. package/{mappings-config-B1qNM8VL.d.cts → mappings-config-D9dsonoi.d.mts} +40 -2
  71. package/{mappings-config-BChZsany.d.mts → mappings-config-RQLGx8ub.d.cts} +40 -2
  72. package/{namespace-probe-BkUs8raG.d.mts → namespace-probe-BmdGnYMn.d.mts} +72 -3
  73. package/{namespace-probe-aRFmpU85.d.cts → namespace-probe-EYyxWZnf.d.cts} +72 -3
  74. package/package.json +1 -1
  75. package/{sdk-Bj-ZDf4u.cjs → sdk-COLUHhJq.cjs} +755 -44
  76. package/{sdk-BvRD2jAp.mjs → sdk-CZNXBsgA.mjs} +755 -44
  77. package/sdk.cjs +4 -2
  78. package/sdk.d.cts +3 -3
  79. package/sdk.d.mts +3 -3
  80. package/sdk.mjs +3 -3
  81. package/{sync-engine-DHQ7rXZe.d.mts → sync-engine-BG2O1an2.d.cts} +2 -2
  82. package/{sync-engine-DiPjH53O.d.cts → sync-engine-DgQbrJON.d.mts} +2 -2
  83. package/{view-compiler-CcUwzZut.d.mts → view-compiler-Bo7pqXW3.d.mts} +1 -1
  84. package/{view-compiler-DqAdVxLq.d.cts → view-compiler-CmEdAMwj.d.cts} +1 -1
  85. package/vite.d.cts +1 -1
  86. package/vite.d.mts +1 -1
@@ -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,5 @@
1
- import { a as ClivlyEntitiesConfig } from "./entity-config-fKQhimtD.mjs";
1
+ import { a as ClivlyEntitiesConfig } from "./entity-config-B2RA53nw.mjs";
2
+ import { r as IntegrationState } from "./integration-state-BK-riZnm.mjs";
2
3
  //#region ../sdk/src/drizzle-meta.d.ts
3
4
  declare const DRIZZLE_META: "__clivly_drizzle_source_meta__";
4
5
  interface DrizzleSourceMeta {
@@ -78,6 +79,12 @@ interface ClivlySDKConfig {
78
79
  * runtimes can supply their own.
79
80
  */
80
81
  env?: Record<string, string | undefined>;
82
+ /**
83
+ * Where this app is running: `local_dev`, `preview` or `production`. Reported
84
+ * on each heartbeat so the dashboard can name the environment it is watching.
85
+ * Inferred from platform variables and `NODE_ENV` when omitted.
86
+ */
87
+ environment?: "local_dev" | "preview" | "production";
81
88
  /**
82
89
  * 🚧 Not implemented in 0.1.x. Reserved options for tunnel mode and CRM
83
90
  * write-back — they have NO effect yet and land with the Cloudflare
@@ -112,6 +119,17 @@ interface ClivlySDKConfig {
112
119
  */
113
120
  namespaceReady?: boolean;
114
121
  orm?: string;
122
+ /**
123
+ * Presence transport override. HTTP remains the default until the recorded
124
+ * production rollout gate permits a WebSocket default; set `http` explicitly
125
+ * to keep the legacy transport after that rollout. Operators may also set
126
+ * `CLIVLY_PRESENCE_TRANSPORT` without changing application code.
127
+ */
128
+ presence?: {
129
+ /** Explicit release identity; platform deployment ids and commit SHAs follow. */
130
+ deploymentId?: string;
131
+ transport?: "http" | "websocket";
132
+ };
115
133
  /**
116
134
  * Network retry policy for outbound calls (heartbeat + sync push). Transient
117
135
  * failures (network errors, HTTP 429, HTTP 5xx) are retried with exponential
@@ -217,6 +235,26 @@ interface CreateChatSessionHandlerOptions {
217
235
  */
218
236
  resolveUser?: (req: Request) => Promise<ClivlyUser | null> | ClivlyUser | null;
219
237
  }
238
+ /** One object type ensured by `ensureSchema`. */
239
+ interface EnsuredObjectTypeResult {
240
+ /** True when this call created it, false when it already existed. */
241
+ created: boolean;
242
+ id: string;
243
+ slug: string;
244
+ }
245
+ /** One mapping ensured by `ensureSchema`. */
246
+ interface EnsuredMappingResult {
247
+ created: boolean;
248
+ /** The config entity key this mapping came from. */
249
+ entityKey: string;
250
+ id: string;
251
+ /** True when an existing config-owned mapping's definition changed. */
252
+ updated: boolean;
253
+ }
254
+ interface EnsureSchemaResult {
255
+ mappings: EnsuredMappingResult[];
256
+ objectTypes: EnsuredObjectTypeResult[];
257
+ }
220
258
  interface DoctorCheck {
221
259
  /** Human-readable outcome — what passed, or why it failed. */
222
260
  detail: string;
@@ -264,6 +302,12 @@ interface ClivlyConnectResult {
264
302
  retryable: boolean;
265
303
  /** HTTP status, or null when the request never completed (network error). */
266
304
  status: number | null;
305
+ /**
306
+ * The workspace's setup ladder, computed by the server. Present only on
307
+ * `ping()`, and null when the server is older than this field or could not
308
+ * read it — which the CLI renders as "unavailable", never as "not set up".
309
+ */
310
+ workspace?: IntegrationState | null;
267
311
  }
268
312
  interface SyncCursor {
269
313
  /** The row's id, breaking ties when timestamps collide. */
@@ -325,6 +369,31 @@ interface ClivlySDK {
325
369
  createClivlyHandler(): (req: Request) => Promise<Response>;
326
370
  /** Validate this setup end-to-end (read-only) before the first sync. */
327
371
  doctor(): Promise<DoctorReport>;
372
+ /**
373
+ * Create any custom object types the config declares that this workspace does
374
+ * not have yet, keyed by entity slug — so `clivly.config.ts` needs no
375
+ * dashboard-generated id. Create-only and idempotent.
376
+ *
377
+ * Resolves to the ensured objects (empty when the config declares none), or
378
+ * `null` when the request could not be delivered.
379
+ */
380
+ ensureCustomObjects(): Promise<{
381
+ slug: string;
382
+ id: string;
383
+ created: boolean;
384
+ }[] | null>;
385
+ /**
386
+ * Declare the whole schema this config describes — custom object types AND
387
+ * the mappings that make them receive rows. The superset of
388
+ * `ensureCustomObjects`, which creates the object container and nothing else.
389
+ *
390
+ * Resolves to `null` when the request could not be delivered (including
391
+ * against a server too old to have the route), and REJECTS when Clivly
392
+ * refuses the config — e.g. an entity that would overwrite a mapping managed
393
+ * in the dashboard. That distinction matters: unreachable is worth a retry,
394
+ * refused is worth reading.
395
+ */
396
+ ensureSchema(): Promise<EnsureSchemaResult | null>;
328
397
  /**
329
398
  * Send a single heartbeat now. Returns true on success. Kept for the keep-alive
330
399
  * loop and back-compat; use `connect()` when you need the failure reason.
@@ -357,7 +426,7 @@ interface ClivlySDK {
357
426
  */
358
427
  start(): Promise<void>;
359
428
  /** Stop the keep-alive loop. */
360
- stop(): void;
429
+ stop(): Promise<void>;
361
430
  /**
362
431
  * Sync all configured sources now. `delta` (default) pages changed rows since
363
432
  * the last cursor; `full` pushes each complete entity so the server can
@@ -378,4 +447,4 @@ interface NamespaceIntrospector {
378
447
  sampleSelect(table: string): Promise<void>;
379
448
  }
380
449
  //#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 };
450
+ 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,5 @@
1
- import { a as ClivlyEntitiesConfig } from "./entity-config-fKQhimtD.cjs";
1
+ import { a as ClivlyEntitiesConfig } from "./entity-config-B2RA53nw.cjs";
2
+ import { r as IntegrationState } from "./integration-state-BK-riZnm.cjs";
2
3
  //#region ../sdk/src/drizzle-meta.d.ts
3
4
  declare const DRIZZLE_META: "__clivly_drizzle_source_meta__";
4
5
  interface DrizzleSourceMeta {
@@ -78,6 +79,12 @@ interface ClivlySDKConfig {
78
79
  * runtimes can supply their own.
79
80
  */
80
81
  env?: Record<string, string | undefined>;
82
+ /**
83
+ * Where this app is running: `local_dev`, `preview` or `production`. Reported
84
+ * on each heartbeat so the dashboard can name the environment it is watching.
85
+ * Inferred from platform variables and `NODE_ENV` when omitted.
86
+ */
87
+ environment?: "local_dev" | "preview" | "production";
81
88
  /**
82
89
  * 🚧 Not implemented in 0.1.x. Reserved options for tunnel mode and CRM
83
90
  * write-back — they have NO effect yet and land with the Cloudflare
@@ -112,6 +119,17 @@ interface ClivlySDKConfig {
112
119
  */
113
120
  namespaceReady?: boolean;
114
121
  orm?: string;
122
+ /**
123
+ * Presence transport override. HTTP remains the default until the recorded
124
+ * production rollout gate permits a WebSocket default; set `http` explicitly
125
+ * to keep the legacy transport after that rollout. Operators may also set
126
+ * `CLIVLY_PRESENCE_TRANSPORT` without changing application code.
127
+ */
128
+ presence?: {
129
+ /** Explicit release identity; platform deployment ids and commit SHAs follow. */
130
+ deploymentId?: string;
131
+ transport?: "http" | "websocket";
132
+ };
115
133
  /**
116
134
  * Network retry policy for outbound calls (heartbeat + sync push). Transient
117
135
  * failures (network errors, HTTP 429, HTTP 5xx) are retried with exponential
@@ -217,6 +235,26 @@ interface CreateChatSessionHandlerOptions {
217
235
  */
218
236
  resolveUser?: (req: Request) => Promise<ClivlyUser | null> | ClivlyUser | null;
219
237
  }
238
+ /** One object type ensured by `ensureSchema`. */
239
+ interface EnsuredObjectTypeResult {
240
+ /** True when this call created it, false when it already existed. */
241
+ created: boolean;
242
+ id: string;
243
+ slug: string;
244
+ }
245
+ /** One mapping ensured by `ensureSchema`. */
246
+ interface EnsuredMappingResult {
247
+ created: boolean;
248
+ /** The config entity key this mapping came from. */
249
+ entityKey: string;
250
+ id: string;
251
+ /** True when an existing config-owned mapping's definition changed. */
252
+ updated: boolean;
253
+ }
254
+ interface EnsureSchemaResult {
255
+ mappings: EnsuredMappingResult[];
256
+ objectTypes: EnsuredObjectTypeResult[];
257
+ }
220
258
  interface DoctorCheck {
221
259
  /** Human-readable outcome — what passed, or why it failed. */
222
260
  detail: string;
@@ -264,6 +302,12 @@ interface ClivlyConnectResult {
264
302
  retryable: boolean;
265
303
  /** HTTP status, or null when the request never completed (network error). */
266
304
  status: number | null;
305
+ /**
306
+ * The workspace's setup ladder, computed by the server. Present only on
307
+ * `ping()`, and null when the server is older than this field or could not
308
+ * read it — which the CLI renders as "unavailable", never as "not set up".
309
+ */
310
+ workspace?: IntegrationState | null;
267
311
  }
268
312
  interface SyncCursor {
269
313
  /** The row's id, breaking ties when timestamps collide. */
@@ -325,6 +369,31 @@ interface ClivlySDK {
325
369
  createClivlyHandler(): (req: Request) => Promise<Response>;
326
370
  /** Validate this setup end-to-end (read-only) before the first sync. */
327
371
  doctor(): Promise<DoctorReport>;
372
+ /**
373
+ * Create any custom object types the config declares that this workspace does
374
+ * not have yet, keyed by entity slug — so `clivly.config.ts` needs no
375
+ * dashboard-generated id. Create-only and idempotent.
376
+ *
377
+ * Resolves to the ensured objects (empty when the config declares none), or
378
+ * `null` when the request could not be delivered.
379
+ */
380
+ ensureCustomObjects(): Promise<{
381
+ slug: string;
382
+ id: string;
383
+ created: boolean;
384
+ }[] | null>;
385
+ /**
386
+ * Declare the whole schema this config describes — custom object types AND
387
+ * the mappings that make them receive rows. The superset of
388
+ * `ensureCustomObjects`, which creates the object container and nothing else.
389
+ *
390
+ * Resolves to `null` when the request could not be delivered (including
391
+ * against a server too old to have the route), and REJECTS when Clivly
392
+ * refuses the config — e.g. an entity that would overwrite a mapping managed
393
+ * in the dashboard. That distinction matters: unreachable is worth a retry,
394
+ * refused is worth reading.
395
+ */
396
+ ensureSchema(): Promise<EnsureSchemaResult | null>;
328
397
  /**
329
398
  * Send a single heartbeat now. Returns true on success. Kept for the keep-alive
330
399
  * loop and back-compat; use `connect()` when you need the failure reason.
@@ -357,7 +426,7 @@ interface ClivlySDK {
357
426
  */
358
427
  start(): Promise<void>;
359
428
  /** Stop the keep-alive loop. */
360
- stop(): void;
429
+ stop(): Promise<void>;
361
430
  /**
362
431
  * Sync all configured sources now. `delta` (default) pages changed rows since
363
432
  * the last cursor; `full` pushes each complete entity so the server can
@@ -378,4 +447,4 @@ interface NamespaceIntrospector {
378
447
  sampleSelect(table: string): Promise<void>;
379
448
  }
380
449
  //#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 };
450
+ 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.3",
4
4
  "private": false,
5
5
  "type": "module",
6
6
  "description": "Clivly CLI — scaffold a CRM into your app (clivly init).",