clivly 0.16.0 → 0.17.1

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 (186) hide show
  1. package/README.md +21 -27
  2. package/{adapter-BMAUq4hf.d.mts → adapter-C63F9VZL.d.mts} +1 -3
  3. package/{adapter-IH3r_I8v.d.cts → adapter-OO5g17qF.d.cts} +1 -3
  4. package/{auth-adapter-CiEXcweZ.cjs → auth-adapter-CNVuxT9W.cjs} +1 -2
  5. package/{auth-adapter-Bt1GZiag.d.cts → auth-adapter-COMP0Fud.d.cts} +1 -3
  6. package/{auth-adapter-CHy273qb.d.mts → auth-adapter-ZlhllVpm.d.mts} +1 -3
  7. package/{auth-adapter-gfVDxf3d.mjs → auth-adapter-u91PByaw.mjs} +1 -2
  8. package/auth-better-auth.cjs +2 -4
  9. package/auth-better-auth.d.cts +1 -5
  10. package/auth-better-auth.d.mts +1 -5
  11. package/auth-better-auth.mjs +2 -4
  12. package/auth-clerk.cjs +2 -4
  13. package/auth-clerk.d.cts +1 -5
  14. package/auth-clerk.d.mts +1 -5
  15. package/auth-clerk.mjs +2 -4
  16. package/auth-workos.cjs +2 -4
  17. package/auth-workos.d.cts +1 -5
  18. package/auth-workos.d.mts +1 -5
  19. package/auth-workos.mjs +2 -4
  20. package/core-adapter.cjs +2 -3
  21. package/core-adapter.d.cts +1 -1
  22. package/core-adapter.d.mts +1 -1
  23. package/core-adapter.mjs +2 -3
  24. package/core-auth-adapter.cjs +3 -4
  25. package/core-auth-adapter.d.cts +1 -1
  26. package/core-auth-adapter.d.mts +1 -1
  27. package/core-auth-adapter.mjs +3 -5
  28. package/core-drizzle.cjs +3 -4
  29. package/core-drizzle.d.cts +1 -1
  30. package/core-drizzle.d.mts +1 -1
  31. package/core-drizzle.mjs +3 -5
  32. package/core-entity-config.cjs +3 -4
  33. package/core-entity-config.d.cts +1 -1
  34. package/core-entity-config.d.mts +1 -1
  35. package/core-entity-config.mjs +3 -5
  36. package/core-entity-heuristics.cjs +18 -18
  37. package/core-entity-heuristics.d.cts +3 -3
  38. package/core-entity-heuristics.d.mts +3 -3
  39. package/core-entity-heuristics.mjs +3 -5
  40. package/core-mapping-form.cjs +3 -4
  41. package/core-mapping-form.d.cts +1 -1
  42. package/core-mapping-form.d.mts +1 -1
  43. package/core-mapping-form.mjs +3 -5
  44. package/core-mapping-score.cjs +3 -4
  45. package/core-mapping-score.d.cts +1 -1
  46. package/core-mapping-score.d.mts +1 -1
  47. package/core-mapping-score.mjs +3 -5
  48. package/core-mappings-config.cjs +3 -4
  49. package/core-mappings-config.d.cts +1 -1
  50. package/core-mappings-config.d.mts +1 -1
  51. package/core-mappings-config.mjs +3 -5
  52. package/core-sync-engine.cjs +3 -4
  53. package/core-sync-engine.d.cts +1 -1
  54. package/core-sync-engine.d.mts +1 -1
  55. package/core-sync-engine.mjs +3 -5
  56. package/core-types.cjs +3 -4
  57. package/core-types.d.cts +1 -1
  58. package/core-types.d.mts +1 -1
  59. package/core-types.mjs +3 -5
  60. package/core-view-compiler.cjs +3 -4
  61. package/core-view-compiler.d.cts +1 -1
  62. package/core-view-compiler.d.mts +1 -1
  63. package/core-view-compiler.mjs +3 -5
  64. package/core.cjs +13 -13
  65. package/core.d.cts +11 -11
  66. package/core.d.mts +11 -11
  67. package/core.mjs +13 -14
  68. package/{deprecate-subpath-CmvZtCpE.mjs → deprecate-subpath-CK37DKXH.mjs} +1 -2
  69. package/{deprecate-subpath-B9ngvizt.cjs → deprecate-subpath-dGwDiHKV.cjs} +1 -2
  70. package/{drizzle-CiK37zJm.d.cts → drizzle-B9cjBavj.d.cts} +1 -3
  71. package/{drizzle-DcB7OfBp.cjs → drizzle-C0bfX-6a.cjs} +1 -2
  72. package/{drizzle-wbcuG-cy.mjs → drizzle-CZuOzIu4.mjs} +1 -2
  73. package/{drizzle-ehVWLSrN.d.mts → drizzle-L5FOGe_-.d.mts} +1 -3
  74. package/{drizzle-meta-Bb1JWYqf.cjs → drizzle-meta-BPnRLpsB.cjs} +1 -2
  75. package/{drizzle-meta-D-5k3n0i.mjs → drizzle-meta-D00lFvAk.mjs} +1 -2
  76. package/drizzle.cjs +7 -10
  77. package/drizzle.d.cts +3 -7
  78. package/drizzle.d.mts +3 -7
  79. package/drizzle.mjs +7 -10
  80. package/{entity-config-BI4RYNKL.cjs → entity-config-DiCJ6mhI.cjs} +8 -11
  81. package/entity-config-X-KlnYXX.d.mts +632 -0
  82. package/entity-config-dNclLyBM.d.cts +632 -0
  83. package/{entity-config-Ccfb2IL9.mjs → entity-config-g_oMPXlN.mjs} +8 -11
  84. package/entity-heuristics-CIParuQe.cjs +655 -0
  85. package/entity-heuristics-DE5ujoHw.mjs +566 -0
  86. package/index.cjs +65 -111
  87. package/index.d.cts +1 -12
  88. package/index.d.mts +1 -12
  89. package/index.mjs +53 -99
  90. package/{integration-state-BA4c0RbD.d.mts → integration-state-xK4PLm5T.d.cts} +0 -2
  91. package/{integration-state-BA4c0RbD.d.cts → integration-state-xK4PLm5T.d.mts} +0 -2
  92. package/{internal-CLvZdVj5.mjs → internal-9oDwwbNg.mjs} +37 -9
  93. package/{internal-DsArcqkP.cjs → internal-BKYt5j0l.cjs} +42 -8
  94. package/{internal-C7NlPM3M.d.mts → internal-COALpgov.d.cts} +1 -17
  95. package/{internal-D2J4VQWT.d.cts → internal-D3q4FPcA.d.mts} +1 -17
  96. package/internal-adapter.d.cts +1 -1
  97. package/internal-adapter.d.mts +1 -1
  98. package/internal-auth-adapter.cjs +1 -1
  99. package/internal-auth-adapter.d.cts +1 -1
  100. package/internal-auth-adapter.d.mts +1 -1
  101. package/internal-auth-adapter.mjs +1 -2
  102. package/internal-drizzle.cjs +1 -1
  103. package/internal-drizzle.d.cts +1 -1
  104. package/internal-drizzle.d.mts +1 -1
  105. package/internal-drizzle.mjs +1 -2
  106. package/internal-entity-config.cjs +1 -1
  107. package/internal-entity-config.d.cts +1 -1
  108. package/internal-entity-config.d.mts +1 -1
  109. package/internal-entity-config.mjs +1 -2
  110. package/internal-entity-heuristics.cjs +16 -576
  111. package/internal-entity-heuristics.d.cts +4 -4
  112. package/internal-entity-heuristics.d.mts +4 -4
  113. package/internal-entity-heuristics.mjs +1 -563
  114. package/internal-mapping-form.cjs +1 -1
  115. package/internal-mapping-form.d.cts +1 -1
  116. package/internal-mapping-form.d.mts +1 -1
  117. package/internal-mapping-form.mjs +1 -2
  118. package/internal-mapping-score.cjs +1 -1
  119. package/internal-mapping-score.d.cts +1 -1
  120. package/internal-mapping-score.d.mts +1 -1
  121. package/internal-mapping-score.mjs +1 -2
  122. package/internal-mappings-config.cjs +1 -1
  123. package/internal-mappings-config.d.cts +1 -1
  124. package/internal-mappings-config.d.mts +1 -1
  125. package/internal-mappings-config.mjs +1 -2
  126. package/internal-sync-engine.cjs +1 -1
  127. package/internal-sync-engine.d.cts +1 -1
  128. package/internal-sync-engine.d.mts +1 -1
  129. package/internal-sync-engine.mjs +1 -2
  130. package/internal-types.cjs +1 -1
  131. package/internal-types.d.cts +1 -1
  132. package/internal-types.d.mts +1 -1
  133. package/internal-types.mjs +1 -2
  134. package/internal-view-compiler.cjs +1 -1
  135. package/internal-view-compiler.d.cts +1 -1
  136. package/internal-view-compiler.d.mts +1 -1
  137. package/internal-view-compiler.mjs +1 -2
  138. package/internal.cjs +11 -10
  139. package/internal.d.cts +11 -11
  140. package/internal.d.mts +11 -11
  141. package/internal.mjs +11 -11
  142. package/{mapping-form-XsLLCqW_.d.cts → mapping-form-Bpvgf5b8.d.mts} +1 -3
  143. package/{mapping-form-BpfON_ME.cjs → mapping-form-Bs6JQurC.cjs} +1 -2
  144. package/{mapping-form-DigkuvFc.mjs → mapping-form-C7kDMWzp.mjs} +1 -2
  145. package/{mapping-form-Btn-7gzv.d.mts → mapping-form-CV7y6qox.d.cts} +1 -3
  146. package/{mapping-score-D7Gzg7Ii.d.cts → mapping-score-BKrxddz0.d.cts} +0 -2
  147. package/{mapping-score-D7Gzg7Ii.d.mts → mapping-score-BKrxddz0.d.mts} +0 -2
  148. package/{mapping-score-C68uAqGB.mjs → mapping-score-CS-MTDL9.mjs} +1 -2
  149. package/{mapping-score-CaB3F4Uu.cjs → mapping-score-D2TCQiOr.cjs} +1 -2
  150. package/{mappings-config-D6_oCi2Q.d.mts → mappings-config-BBppW9fp.d.cts} +1 -3
  151. package/{mappings-config-BCsRLohT.cjs → mappings-config-CNxBrbt9.cjs} +3 -4
  152. package/{mappings-config-CwQNQ6bA.mjs → mappings-config-D_g20PyS.mjs} +3 -4
  153. package/{mappings-config-iJzbcUMp.d.cts → mappings-config-Dmm0H6p_.d.mts} +1 -3
  154. package/{namespace-probe-DykR0kgh.d.mts → namespace-probe-BHk3NcyI.d.cts} +32 -9
  155. package/{namespace-probe-H7yWc0JV.d.cts → namespace-probe-Dt_HXcI-.d.mts} +32 -9
  156. package/package.json +1 -7
  157. package/{projection-DvNewmI1.mjs → projection-BkYXvjTr.mjs} +2444 -1166
  158. package/{projection-BELgANG2.cjs → projection-By63gMC-.cjs} +2447 -1163
  159. package/{projection-sql-DweUaWRc.mjs → projection-sql-C3gZE3GS.mjs} +2 -3
  160. package/{projection-sql-DuCtFE9t.cjs → projection-sql-CHz7KzNS.cjs} +2 -3
  161. package/schemas-BSuo_eZQ.d.cts +2160 -0
  162. package/schemas-BSuo_eZQ.d.mts +2160 -0
  163. package/{sdk-ZMy4C4VK.cjs → sdk-BZSTXPyK.cjs} +185 -74
  164. package/{sdk-DLoVPlGB.mjs → sdk-KzHpSf7F.mjs} +185 -74
  165. package/sdk.cjs +2 -2
  166. package/sdk.d.cts +4 -12
  167. package/sdk.d.mts +4 -12
  168. package/sdk.mjs +2 -2
  169. package/{sync-engine-C_5TpvfX.d.mts → sync-engine-C7W0Gkq0.d.cts} +2 -4
  170. package/{sync-engine-CYsWOujz.d.cts → sync-engine-C9Q2FkR9.d.mts} +2 -4
  171. package/{sync-engine-DH058G3w.mjs → sync-engine-CwdLkmch.mjs} +2 -3
  172. package/{sync-engine-BGVDsrOQ.cjs → sync-engine-Di-vF26b.cjs} +2 -3
  173. package/{types-YJTkXKzU.mjs → types-8KSw2AWg.mjs} +1 -2
  174. package/{types-Cq5gHCTq.cjs → types-B8m39L1s.cjs} +1 -2
  175. package/{types-CpAtAtxd.d.cts → types-C9_2vW5a.d.mts} +30 -3
  176. package/{types-CpAtAtxd.d.mts → types-CQ2DgEH7.d.cts} +30 -3
  177. package/{view-compiler-C-6RydKK.mjs → view-compiler-CLTi1VL-.mjs} +3 -4
  178. package/{view-compiler-xiwm5iar.cjs → view-compiler-DaOz5QVl.cjs} +3 -4
  179. package/{view-compiler-CwKVoK1w.d.mts → view-compiler-M23WiVGG.d.mts} +1 -3
  180. package/{view-compiler-Cq8apvZ4.d.cts → view-compiler-cXqt4X-c.d.cts} +1 -3
  181. package/vite.cjs +1 -2
  182. package/vite.d.cts +2 -4
  183. package/vite.d.mts +2 -4
  184. package/vite.mjs +1 -2
  185. package/entity-config-ApnT5j3X.d.cts +0 -4472
  186. package/entity-config-CKcj4-M_.d.mts +0 -4473
@@ -1,8 +1,9 @@
1
- import { i as projectionSchema } from "./projection-DvNewmI1.mjs";
2
- import { _ as validateProjection, s as customObjectDeclarations, w as primaryKeyColumns } from "./entity-config-Ccfb2IL9.mjs";
3
- import { t as entitiesToMappings } from "./mappings-config-CwQNQ6bA.mjs";
4
- import { t as DRIZZLE_META } from "./drizzle-meta-D-5k3n0i.mjs";
5
- //#region ../sdk/src/deployment-identity.ts
1
+ import { i as projectionSchema } from "./projection-BkYXvjTr.mjs";
2
+ import { _ as validateProjection, s as customObjectDeclarations, w as primaryKeyColumns } from "./entity-config-g_oMPXlN.mjs";
3
+ import { a as isSensitiveColumn } from "./entity-heuristics-DE5ujoHw.mjs";
4
+ import { t as entitiesToMappings } from "./mappings-config-D_g20PyS.mjs";
5
+ import { t as DRIZZLE_META } from "./drizzle-meta-D00lFvAk.mjs";
6
+ // ../sdk/src/deployment-identity.ts
6
7
  const MAX_DEPLOYMENT_ID_LENGTH = 128;
7
8
  const PLATFORM_DEPLOYMENT_KEYS = [
8
9
  "VERCEL_DEPLOYMENT_ID",
@@ -43,8 +44,7 @@ function resolveDeploymentId(env, configured) {
43
44
  if (deploymentId) return deploymentId.slice(0, MAX_DEPLOYMENT_ID_LENGTH);
44
45
  return `local-${hashLocalIdentity(firstNonBlank([env.HOSTNAME]) ?? "unidentified-host")}`;
45
46
  }
46
- //#endregion
47
- //#region ../sdk/src/entity-source.ts
47
+ // ../sdk/src/entity-source.ts
48
48
  const CONCEPT_KEYS = {
49
49
  contact: "contacts",
50
50
  company: "companies",
@@ -114,8 +114,7 @@ function customPushSource(config, source) {
114
114
  const entities = config.entities?.entities;
115
115
  return (entities?.[source.entity] ?? Object.values(entities ?? {}).find((e) => e.source === source.entity))?.projection?.baseTable ?? source.entity;
116
116
  }
117
- //#endregion
118
- //#region ../sdk/src/concept-coverage.ts
117
+ // ../sdk/src/concept-coverage.ts
119
118
  const CHECK_NAME$1 = "Entity → source coverage";
120
119
  function configuredKeys(config) {
121
120
  const src = config.source;
@@ -159,8 +158,7 @@ function checkConceptCoverage(config) {
159
158
  detail: `${problems.join(" ")} Configured source keys: ${listed}. \`source\` is keyed by CRM concept, not by entity key.`
160
159
  };
161
160
  }
162
- //#endregion
163
- //#region ../sdk/src/custom-slug.ts
161
+ // ../sdk/src/custom-slug.ts
164
162
  const SLUG_PATTERN = /^[a-z][a-z0-9_-]*$/;
165
163
  const NON_ALNUM = /[^a-z0-9]+/g;
166
164
  const EDGE_HYPHENS = /(^-|-$)/g;
@@ -208,8 +206,7 @@ function checkCustomObjectSlugs(config) {
208
206
  detail: `Ensure these object types exist in Clivly: ${undeclared.join(", ")}. Declare them with \`objectType\` in clivly.config and \`clivly push-schema\` will create them for you.`
209
207
  };
210
208
  }
211
- //#endregion
212
- //#region ../sdk/src/fetch-error.ts
209
+ // ../sdk/src/fetch-error.ts
213
210
  /** Deepest `Error` reachable through the `.cause` chain (the original error if none). */
214
211
  function rootError(error) {
215
212
  let current = error;
@@ -251,8 +248,7 @@ function describeFetchError(entity, error) {
251
248
  if (hint) return `Couldn't read "${entity}": ${hint}`;
252
249
  return `Couldn't read "${entity}": ${firstLine(root instanceof Error ? root.message : String(root?.message ?? root ?? "unknown error"))}`;
253
250
  }
254
- //#endregion
255
- //#region ../sdk/src/mapping-dry-run.ts
251
+ // ../sdk/src/mapping-dry-run.ts
256
252
  /**
257
253
  * Fetch one real row and push it through the entity's field map.
258
254
  *
@@ -311,8 +307,7 @@ async function runMappingDryRun(config, entityKey) {
311
307
  detail: `Row from "${resolved.source.entity}" is missing mapped column(s): ${missing.join(", ")}.`
312
308
  };
313
309
  }
314
- //#endregion
315
- //#region ../sdk/src/namespace-probe.ts
310
+ // ../sdk/src/namespace-probe.ts
316
311
  /**
317
312
  * Verify the tables the integration depends on are genuinely reachable:
318
313
  * connect, list tables, confirm each required table exists, then prove it's
@@ -378,8 +373,7 @@ function requiredTablesFromConfig(config) {
378
373
  function errorMessage(error) {
379
374
  return error instanceof Error ? error.message : String(error);
380
375
  }
381
- //#endregion
382
- //#region ../sdk/src/readiness.ts
376
+ // ../sdk/src/readiness.ts
383
377
  /**
384
378
  * Ask Clivly whether it can actually receive what this config pushes.
385
379
  *
@@ -451,8 +445,7 @@ function mappingReadinessCheck(requested, result) {
451
445
  detail: `No active mapping receives ${names}, so rows pushed for ${unmapped.length === 1 ? "it" : "them"} are dropped. Map them in Integrations → Mapping in Clivly, then sync again.`
452
446
  };
453
447
  }
454
- //#endregion
455
- //#region ../sdk/src/doctor.ts
448
+ // ../sdk/src/doctor.ts
456
449
  const TEMPORAL_CURSOR_TYPES = [
457
450
  "timestamp",
458
451
  "timestamptz",
@@ -652,8 +645,7 @@ async function runDoctor(args) {
652
645
  checks
653
646
  };
654
647
  }
655
- //#endregion
656
- //#region ../sdk/src/host-environment.ts
648
+ // ../sdk/src/host-environment.ts
657
649
  const KNOWN = [
658
650
  "local_dev",
659
651
  "preview",
@@ -698,8 +690,7 @@ function detectHostEnvironment(env, configured) {
698
690
  }
699
691
  return fromNodeEnv(env.NODE_ENV?.trim());
700
692
  }
701
- //#endregion
702
- //#region ../sdk/src/instant-push-support.ts
693
+ // ../sdk/src/instant-push-support.ts
703
694
  /**
704
695
  * The fast rollback switch for instant push (see
705
696
  * docs/reviews/2026-09-19-near-real-time-sync-plan.md, question 5).
@@ -712,8 +703,7 @@ function detectHostEnvironment(env, configured) {
712
703
  function isInstantPushDisabled(env) {
713
704
  return env.CLIVLY_INSTANT_PUSH_DISABLED === "true";
714
705
  }
715
- //#endregion
716
- //#region ../sdk/src/presence-machine.ts
706
+ // ../sdk/src/presence-machine.ts
717
707
  const PRESENCE_BACKOFF_BASE_MS = 1e3;
718
708
  const PRESENCE_BACKOFF_MAX_MS = 3e4;
719
709
  function effectsFor(state, overrides = {}) {
@@ -795,8 +785,7 @@ function presenceReduce(context, event, jitter) {
795
785
  effects: effectsFor(context.state)
796
786
  };
797
787
  }
798
- //#endregion
799
- //#region ../sdk/src/presence-client.ts
788
+ // ../sdk/src/presence-client.ts
800
789
  const PRESENCE_PING_INTERVAL_MS = 3e4;
801
790
  const UNSUPPORTED_TICKET_STATUSES = /* @__PURE__ */ new Set([404, 501]);
802
791
  function ticketUrl(options) {
@@ -992,8 +981,7 @@ function createPresenceClient(options) {
992
981
  }
993
982
  };
994
983
  }
995
- //#endregion
996
- //#region ../sdk/src/presence-support.ts
984
+ // ../sdk/src/presence-support.ts
997
985
  /**
998
986
  * This stays HTTP until the production gate in docs/presence-rollout-gate.md
999
987
  * has recorded a passing seven-day window. The later default-on rollout is a
@@ -1023,8 +1011,79 @@ function resolvePresenceTransport(host, configured) {
1023
1011
  transport: DEFAULT_TRANSPORT
1024
1012
  };
1025
1013
  }
1026
- //#endregion
1027
- //#region ../sdk/src/push-outcome.ts
1014
+ // ../sdk/src/projection-guard.ts
1015
+ /**
1016
+ * Tables auth libraries keep live credentials in. Whole-table: their secrets
1017
+ * sit in columns with generic names (`token`, `value`) that a column rule
1018
+ * cannot single out. `user`, `member` and `organization` are not here — they
1019
+ * are legitimate contact and company sources.
1020
+ */
1021
+ const CREDENTIAL_TABLES = /* @__PURE__ */ new Set([
1022
+ "session",
1023
+ "verification",
1024
+ "two_factor",
1025
+ "twofactor",
1026
+ "passkey",
1027
+ "apikey",
1028
+ "api_key",
1029
+ "jwks"
1030
+ ]);
1031
+ const BASE_ALIAS = "base";
1032
+ function normalise(name) {
1033
+ return name.toLowerCase().replaceAll("-", "_");
1034
+ }
1035
+ /** Every (table, column) a projection reads, with join aliases resolved. */
1036
+ function readColumns(projection) {
1037
+ const tableOf = /* @__PURE__ */ new Map([[BASE_ALIAS, projection.baseTable]]);
1038
+ for (const join of projection.joins) tableOf.set(join.key, join.table);
1039
+ const refs = [];
1040
+ for (const join of projection.joins) for (const condition of join.on) refs.push(condition.left, condition.right);
1041
+ for (const binding of Object.values(projection.fieldBindings)) refs.push(binding.from);
1042
+ const { identity } = projection;
1043
+ if (identity.kind === "column") refs.push(identity.from);
1044
+ else if (identity.kind === "composite") refs.push(...identity.parts);
1045
+ else if (identity.column) refs.push({
1046
+ table: BASE_ALIAS,
1047
+ column: identity.column
1048
+ });
1049
+ return refs.map((ref) => ({
1050
+ table: tableOf.get(ref.table) ?? ref.table,
1051
+ column: ref.column
1052
+ }));
1053
+ }
1054
+ function referencedTables(projection) {
1055
+ return [projection.baseTable, ...projection.joins.map((join) => join.table)];
1056
+ }
1057
+ /** Why this projection may not run here; empty when it may. */
1058
+ function projectionExposureErrors(projection, policy = {}) {
1059
+ const allowed = new Set((policy.allowSensitive ?? []).map(normalise));
1060
+ const errors = [];
1061
+ for (const table of referencedTables(projection)) {
1062
+ if (CREDENTIAL_TABLES.has(normalise(table)) && !allowed.has(normalise(`${table}.*`))) errors.push(`Table "${table}" holds credentials and is never synced.`);
1063
+ if (policy.tables && !(table in policy.tables)) errors.push(`Table "${table}" is not in this app's exposure.tables allowlist.`);
1064
+ }
1065
+ for (const { table, column } of readColumns(projection)) {
1066
+ const ref = `${table}.${column}`;
1067
+ if (isSensitiveColumn(column) && !allowed.has(normalise(ref))) errors.push(`Column "${ref}" looks like a credential and is never synced. List it in exposure.allowSensitive if it is safe.`);
1068
+ const columns = policy.tables?.[table];
1069
+ if (Array.isArray(columns) && !columns.includes(column)) errors.push(`Column "${ref}" is not in this app's exposure.tables allowlist.`);
1070
+ }
1071
+ return [...new Set(errors)];
1072
+ }
1073
+ /** Drop credential columns, and columns outside the allowlist, from a raw-row preview. */
1074
+ function exposableColumns(table, columns, policy = {}) {
1075
+ const allowed = new Set((policy.allowSensitive ?? []).map(normalise));
1076
+ const result = /* @__PURE__ */ new Set();
1077
+ if (CREDENTIAL_TABLES.has(normalise(table)) && !allowed.has(normalise(`${table}.*`)) || policy.tables !== void 0 && !(table in policy.tables)) return result;
1078
+ const listed = policy.tables?.[table];
1079
+ for (const column of columns) {
1080
+ if (isSensitiveColumn(column) && !allowed.has(normalise(`${table}.${column}`))) continue;
1081
+ if (Array.isArray(listed) && !listed.includes(column)) continue;
1082
+ result.add(column);
1083
+ }
1084
+ return result;
1085
+ }
1086
+ // ../sdk/src/push-outcome.ts
1028
1087
  function isCount(value) {
1029
1088
  return typeof value === "number" && Number.isFinite(value);
1030
1089
  }
@@ -1044,8 +1103,7 @@ function describeSilentPush(target, body) {
1044
1103
  if (received === 0 || upserted > 0 || archived > 0) return null;
1045
1104
  return `Clivly sync: pushed ${received} row(s) for ${objectType ? `"${source}" → "${objectType}"` : `"${source}"`} and none were stored — no active mapping in this workspace targets it, so the rows were dropped. Map it in Integrations → Mapping, then sync again.`;
1046
1105
  }
1047
- //#endregion
1048
- //#region ../sdk/src/remote-projections.ts
1106
+ // ../sdk/src/remote-projections.ts
1049
1107
  const SYNC_CUSTOM_PATH$1 = "/clivly/sdk/sync/custom";
1050
1108
  const MISSING_INTROSPECTOR = "this app cannot run dashboard-authored derived objects yet — add `introspector: drizzleIntrospector(db)` to clivly.config.ts";
1051
1109
  /**
@@ -1064,8 +1122,8 @@ const MISSING_INTROSPECTOR = "this app cannot run dashboard-authored derived obj
1064
1122
  * `sql.raw` at execution time.
1065
1123
  */
1066
1124
  function resolveRemoteProjections(args) {
1067
- const { entries, introspector, schema } = args;
1068
- return entries.map((entry) => resolveOne(entry, schema, introspector));
1125
+ const { entries, exposure, introspector, schema } = args;
1126
+ return entries.map((entry) => resolveOne(entry, schema, introspector, exposure));
1069
1127
  }
1070
1128
  /**
1071
1129
  * The base table's PK, resolved from the schema THIS app discovered — never
@@ -1086,7 +1144,7 @@ function resolveLocalBasePk(projection, schema) {
1086
1144
  if (!baseTable) return;
1087
1145
  return primaryKeyColumns(baseTable)[0];
1088
1146
  }
1089
- function resolveOne(entry, schema, introspector) {
1147
+ function resolveOne(entry, schema, introspector, exposure) {
1090
1148
  const parsed = projectionSchema.safeParse(entry.projection);
1091
1149
  if (!parsed.success) return {
1092
1150
  id: entry.id,
@@ -1094,6 +1152,12 @@ function resolveOne(entry, schema, introspector) {
1094
1152
  reason: `projection did not parse: ${parsed.error.issues.map((i) => `${i.path.join(".")}: ${i.message}`).join("; ")}`
1095
1153
  };
1096
1154
  const projection = parsed.data;
1155
+ const refused = projectionExposureErrors(projection, exposure);
1156
+ if (refused.length > 0) return {
1157
+ id: entry.id,
1158
+ status: "invalid",
1159
+ reason: refused.join("; ")
1160
+ };
1097
1161
  const errors = validateProjection(projection, schema, entry.entityKey);
1098
1162
  if (errors.length > 0) return {
1099
1163
  id: entry.id,
@@ -1278,8 +1342,7 @@ async function pushRemoteProjections(args) {
1278
1342
  }
1279
1343
  return pushed;
1280
1344
  }
1281
- //#endregion
1282
- //#region ../sdk/src/self-check.ts
1345
+ // ../sdk/src/self-check.ts
1283
1346
  function selfCheck(input) {
1284
1347
  const issues = [];
1285
1348
  if (input.reportsTriggerUrl && !input.hasTriggerSecret) issues.push({
@@ -1294,8 +1357,7 @@ function selfCheck(input) {
1294
1357
  });
1295
1358
  return issues;
1296
1359
  }
1297
- //#endregion
1298
- //#region ../sdk/src/sync.ts
1360
+ // ../sdk/src/sync.ts
1299
1361
  const DEFAULT_ID_FIELD = "id";
1300
1362
  function isAfter(candidate, current) {
1301
1363
  const ct = candidate.time.getTime();
@@ -1390,11 +1452,10 @@ async function fullSyncSource(args) {
1390
1452
  ok
1391
1453
  };
1392
1454
  }
1393
- //#endregion
1394
- //#region ../sdk/src/trigger-method.ts
1455
+ // ../sdk/src/trigger-method.ts
1395
1456
  /** Host-side override, mirroring `CLIVLY_INSTANT_PUSH_DISABLED`. */
1396
1457
  const REQUIRE_POST_ENV_VAR = "CLIVLY_TRIGGER_REQUIRE_POST";
1397
- const NON_POST_DEPRECATION_WARNING = `Clivly: this sync trigger was called with GET. It still ran the sync, but a future release will refuse any method except POST with a 405. Change the caller — your cron job or uptime check — to POST. To adopt the new behaviour now, set ${REQUIRE_POST_ENV_VAR}=true.`;
1458
+ const NON_POST_DEPRECATION_WARNING = `Clivly: this sync trigger was called with GET and ran only because ${REQUIRE_POST_ENV_VAR}=false. A GET can be started by a crawler or any web page, so change the caller — your cron job or uptime check — to POST, then remove ${REQUIRE_POST_ENV_VAR}.`;
1398
1459
  const METHOD_NOT_ALLOWED = 405;
1399
1460
  const NO_CONTENT = 204;
1400
1461
  const OK = 200;
@@ -1435,8 +1496,7 @@ function resolveTriggerMethod(input) {
1435
1496
  warn: NON_POST_DEPRECATION_WARNING
1436
1497
  };
1437
1498
  }
1438
- //#endregion
1439
- //#region ../sdk/src/trigger-url.ts
1499
+ // ../sdk/src/trigger-url.ts
1440
1500
  const SCHEME_REGEX = /^https?:\/\//;
1441
1501
  const INVALID_HOST_CHARS_REGEX = /[/\\@?#\s]/;
1442
1502
  const PLATFORM_ORIGIN_SOURCES = [
@@ -1517,8 +1577,7 @@ function resolveTriggerUrl(args) {
1517
1577
  if (origin && args.configuredPath) return `${origin}${args.configuredPath.startsWith("/") ? args.configuredPath : `/${args.configuredPath}`}`;
1518
1578
  return args.observedUrl;
1519
1579
  }
1520
- //#endregion
1521
- //#region ../sdk/src/chat-session.ts
1580
+ // ../sdk/src/chat-session.ts
1522
1581
  const DEFAULT_API_URL$1 = "https://api.clivly.com";
1523
1582
  const JSON_HEADERS = { "content-type": "application/json" };
1524
1583
  const TRAILING_SLASH$1 = /\/$/;
@@ -1559,6 +1618,16 @@ function reportedOrigin(req) {
1559
1618
  function trustedOrigin(req) {
1560
1619
  return req.headers.get("origin");
1561
1620
  }
1621
+ /**
1622
+ * The visitor's address as the host's platform reported it. Clivly throttles
1623
+ * new chats per visitor on it; without it the only address Clivly sees is this
1624
+ * server's, so every visitor shared one bucket.
1625
+ */
1626
+ function defaultVisitorIp(req) {
1627
+ const direct = req.headers.get("cf-connecting-ip") ?? req.headers.get("x-real-ip");
1628
+ if (direct) return direct.trim();
1629
+ return req.headers.get("x-forwarded-for")?.split(",")[0]?.trim() || null;
1630
+ }
1562
1631
  function isChatSessionRequestBody(value) {
1563
1632
  if (typeof value !== "object" || value === null) return false;
1564
1633
  const body = value;
@@ -1585,7 +1654,23 @@ function originAllowed(origin, allowedOrigins) {
1585
1654
  if (!origin) return false;
1586
1655
  return allowedOrigins.includes(origin);
1587
1656
  }
1588
- function createChatSessionHandler({ allowedOrigins, apiKey, apiUrl = DEFAULT_API_URL$1, fetchImpl = fetch, resolveUser }) {
1657
+ async function safeHostUser(resolveUser, request) {
1658
+ if (!resolveUser) return null;
1659
+ try {
1660
+ return await resolveUser(request);
1661
+ } catch {
1662
+ console.warn("[clivly] resolveUser threw; continuing without host identity");
1663
+ return null;
1664
+ }
1665
+ }
1666
+ function safeVisitorIp(resolveVisitorIp, request) {
1667
+ try {
1668
+ return resolveVisitorIp(request);
1669
+ } catch {
1670
+ return null;
1671
+ }
1672
+ }
1673
+ function createChatSessionHandler({ allowedOrigins, apiKey, apiUrl = DEFAULT_API_URL$1, fetchImpl = fetch, resolveUser, resolveVisitorIp = defaultVisitorIp }) {
1589
1674
  const sessionUrl = `${normalizeApiUrl(apiUrl)}/clivly/widget/session`;
1590
1675
  if (!allowedOrigins || allowedOrigins.length === 0) console.warn("[clivly] createChatSessionHandler has no allowedOrigins; every origin can open a chat session against this workspace. Pass allowedOrigins to restrict it.");
1591
1676
  return async (request) => {
@@ -1605,12 +1690,8 @@ function createChatSessionHandler({ allowedOrigins, apiKey, apiUrl = DEFAULT_API
1605
1690
  return jsonResponse$1({ error: "invalid_json" }, 400);
1606
1691
  }
1607
1692
  if (!isChatSessionRequestBody(body)) return jsonResponse$1({ error: "invalid_request" }, 400);
1608
- let hostUser = null;
1609
- if (resolveUser) try {
1610
- hostUser = await resolveUser(request);
1611
- } catch {
1612
- console.warn("[clivly] resolveUser threw; continuing without host identity");
1613
- }
1693
+ const hostUser = await safeHostUser(resolveUser, request);
1694
+ const visitorIp = safeVisitorIp(resolveVisitorIp, request);
1614
1695
  try {
1615
1696
  const upstream = await fetchImpl(sessionUrl, {
1616
1697
  method: "POST",
@@ -1624,7 +1705,8 @@ function createChatSessionHandler({ allowedOrigins, apiKey, apiUrl = DEFAULT_API
1624
1705
  visitor: body.visitor,
1625
1706
  visitorToken: body.visitorToken,
1626
1707
  origin,
1627
- ...hostUser ? { hostUser } : {}
1708
+ ...hostUser ? { hostUser } : {},
1709
+ ...visitorIp ? { visitorIp } : {}
1628
1710
  })
1629
1711
  });
1630
1712
  const responseBody = await upstream.text();
@@ -1637,8 +1719,7 @@ function createChatSessionHandler({ allowedOrigins, apiKey, apiUrl = DEFAULT_API
1637
1719
  }
1638
1720
  };
1639
1721
  }
1640
- //#endregion
1641
- //#region ../sdk/src/errors.ts
1722
+ // ../sdk/src/errors.ts
1642
1723
  var ClivlyError = class ClivlyError extends Error {
1643
1724
  /** HTTP status, or null when the request never completed (network error). */
1644
1725
  status;
@@ -1673,8 +1754,7 @@ var ClivlyAuthError = class extends ClivlyError {};
1673
1754
  var ClivlyRateLimitError = class extends ClivlyError {};
1674
1755
  /** The request never reached the server (network/DNS/TLS). Retryable. */
1675
1756
  var ClivlyNetworkError = class extends ClivlyError {};
1676
- //#endregion
1677
- //#region ../sdk/src/index.ts
1757
+ // ../sdk/src/index.ts
1678
1758
  const DEFAULT_API_URL = "https://api.clivly.com";
1679
1759
  const DEFAULT_HEARTBEAT_MS = 6e4;
1680
1760
  const DEFAULT_BATCH_SIZE = 500;
@@ -1988,11 +2068,11 @@ async function handlePreviewRequest(config, preview) {
1988
2068
  if (!source) return jsonResponse({ error: `No configured source for table "${preview.sourceTable}"` }, 400);
1989
2069
  const idField = source.idField ?? "id";
1990
2070
  const filterColumns = preview.filter ? Object.keys(preview.filter).filter((k) => k !== "$raw") : [];
1991
- const needed = /* @__PURE__ */ new Set([
2071
+ const needed = exposableColumns(preview.sourceTable, [
1992
2072
  idField,
1993
2073
  ...Object.values(preview.fieldMap),
1994
2074
  ...filterColumns
1995
- ]);
2075
+ ], config.exposure);
1996
2076
  const rows = (await source.fetchPage({
1997
2077
  since: null,
1998
2078
  limit: PREVIEW_LIMIT
@@ -2005,7 +2085,14 @@ async function handlePreviewRequest(config, preview) {
2005
2085
  async function handleProjectionPreviewRequest(config, request) {
2006
2086
  const run = config.introspector?.runProjection;
2007
2087
  if (!run) return jsonResponse({ error: "This app cannot preview derived objects. Set `introspector: drizzleIntrospector(db)` in clivly.config.ts, on a clivly version that supports runProjection." }, 400);
2008
- const rows = await run.call(config.introspector, request.projection, { limit: request.limit });
2088
+ const parsed = projectionSchema.safeParse(request.projection);
2089
+ if (!parsed.success) return jsonResponse({ error: "The projection did not parse." }, 400);
2090
+ const refused = [...projectionExposureErrors(parsed.data, config.exposure), ...validateProjection(parsed.data, buildSchema(config), parsed.data.entityKey).map((e) => `${e.path}: ${e.message}`)];
2091
+ if (refused.length > 0) return jsonResponse({
2092
+ error: "projection_refused",
2093
+ reasons: refused
2094
+ }, FORBIDDEN_STATUS);
2095
+ const rows = await run.call(config.introspector, parsed.data, { limit: request.limit });
2009
2096
  return jsonResponse({
2010
2097
  rows,
2011
2098
  sampledCount: rows.length
@@ -2040,6 +2127,7 @@ function createClivlySDK(config) {
2040
2127
  const fetcher = createFetcher(config.retry);
2041
2128
  let warnedUnsignedTrigger = false;
2042
2129
  let warnedNonPostTrigger = false;
2130
+ const acceptedSignatures = /* @__PURE__ */ new Map();
2043
2131
  const remoteProjections = createRemoteProjectionFetcher({
2044
2132
  apiKey: config.apiKey,
2045
2133
  apiUrl,
@@ -2166,6 +2254,7 @@ function createClivlySDK(config) {
2166
2254
  const runSync = async (options) => {
2167
2255
  const remoteOutcomes = resolveRemoteProjections({
2168
2256
  entries: await remoteProjections.fetch(),
2257
+ exposure: config.exposure,
2169
2258
  introspector: config.introspector,
2170
2259
  schema: buildSchema(config)
2171
2260
  });
@@ -2446,15 +2535,27 @@ function createClivlySDK(config) {
2446
2535
  await heartbeat();
2447
2536
  if (config.source || config.introspector) await runSync(options);
2448
2537
  };
2449
- const triggerRequestAllowed = async (req, rawBody) => {
2538
+ const triggerRequestAuth = async (req, rawBody) => {
2450
2539
  const secret = config.syncTrigger?.secret;
2451
- if (secret) return await verifyTriggerSignature(req.headers.get(SIGNATURE_HEADER), rawBody, secret);
2540
+ if (secret) {
2541
+ const header = req.headers.get(SIGNATURE_HEADER);
2542
+ if (!(await verifyTriggerSignature(header, rawBody, secret) && header)) return "refused";
2543
+ return claimSignature(header) ? "signed" : "refused";
2544
+ }
2452
2545
  if (!warnedUnsignedTrigger) {
2453
2546
  warnedUnsignedTrigger = true;
2454
- console.warn("Clivly: the sync trigger route is mounted without `syncTrigger.secret`, so anyone who can reach the URL can start a sync. Set a secret (Integrations → Remote sync in Clivly) to require signed requests.");
2547
+ console.warn("Clivly: the sync trigger route is mounted without `syncTrigger.secret`, so anyone who can reach the URL can start a sync. Set CLIVLY_SYNC_TRIGGER_SECRET to require signed requests; until then, previews and sample runs from Clivly are refused.");
2455
2548
  }
2549
+ return "unsigned";
2550
+ };
2551
+ const claimSignature = (header) => {
2552
+ const now = Date.now();
2553
+ for (const [seen, expiresAt] of acceptedSignatures) if (expiresAt <= now) acceptedSignatures.delete(seen);
2554
+ if (acceptedSignatures.has(header)) return false;
2555
+ acceptedSignatures.set(header, now + SIGNATURE_TOLERANCE_SECONDS * SECONDS_PER_MS * 2);
2456
2556
  return true;
2457
2557
  };
2558
+ const requiresSignature = (payload) => Boolean(payload.preview || payload.previewProjection || payload.sample);
2458
2559
  const parseTriggerBody = (rawBody) => {
2459
2560
  if (!rawBody) return {};
2460
2561
  try {
@@ -2470,11 +2571,11 @@ function createClivlySDK(config) {
2470
2571
  *
2471
2572
  * Split out of the handler so the method decision reads as one thing rather
2472
2573
  * than three branches ahead of the request plumbing — the same shape as
2473
- * `triggerRequestAllowed` below.
2574
+ * `triggerRequestAuth` above.
2474
2575
  */
2475
2576
  const refuseDisallowedMethod = (req) => {
2476
2577
  const decision = resolveTriggerMethod({
2477
- enforceDefault: false,
2578
+ enforceDefault: true,
2478
2579
  env: config.env ?? process.env,
2479
2580
  method: req.method
2480
2581
  });
@@ -2500,16 +2601,27 @@ function createClivlySDK(config) {
2500
2601
  if (payload.previewProjection) return await handleProjectionPreviewRequest(config, payload.previewProjection);
2501
2602
  return null;
2502
2603
  };
2604
+ const refuseUnauthorized = (auth, payload) => {
2605
+ if (auth === "refused") return jsonResponse({
2606
+ ok: false,
2607
+ error: "unauthorized"
2608
+ }, UNAUTHORIZED_STATUS);
2609
+ if (auth === "unsigned" && requiresSignature(payload)) return jsonResponse({
2610
+ ok: false,
2611
+ error: "signature_required",
2612
+ message: "Previews and sample runs need a signed request. Set CLIVLY_SYNC_TRIGGER_SECRET in this app's environment."
2613
+ }, FORBIDDEN_STATUS);
2614
+ return null;
2615
+ };
2503
2616
  const createClivlyHandler = () => async (req) => {
2504
2617
  observedUrl = observedTriggerUrl(req) ?? observedUrl;
2505
2618
  const refusal = refuseDisallowedMethod(req);
2506
2619
  if (refusal) return refusal;
2507
2620
  const rawBody = await req.text().catch(() => "");
2508
- if (!await triggerRequestAllowed(req, rawBody)) return jsonResponse({
2509
- ok: false,
2510
- error: "unauthorized"
2511
- }, UNAUTHORIZED_STATUS);
2621
+ const auth = await triggerRequestAuth(req, rawBody);
2512
2622
  const payload = parseTriggerBody(rawBody);
2623
+ const denied = refuseUnauthorized(auth, payload);
2624
+ if (denied) return denied;
2513
2625
  const runId = payload.runId ?? null;
2514
2626
  const startedAt = Date.now();
2515
2627
  try {
@@ -2619,5 +2731,4 @@ function createClivlySDK(config) {
2619
2731
  pushOne
2620
2732
  };
2621
2733
  }
2622
- //#endregion
2623
2734
  export { ClivlyAuthError as a, ClivlyRateLimitError as c, memoryCursorStore as i, createChatSessionHandler as l, createClivlySDK as n, ClivlyError as o, kvCursorStore as r, ClivlyNetworkError as s, CURSOR_KEY_PREFIX as t, isPlaceholderUrl as u };
package/sdk.cjs CHANGED
@@ -1,6 +1,6 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
- const require_entity_config = require("./entity-config-BI4RYNKL.cjs");
3
- const require_sdk = require("./sdk-ZMy4C4VK.cjs");
2
+ const require_entity_config = require("./entity-config-DiCJ6mhI.cjs");
3
+ const require_sdk = require("./sdk-BZSTXPyK.cjs");
4
4
  exports.CURSOR_KEY_PREFIX = require_sdk.CURSOR_KEY_PREFIX;
5
5
  exports.ClivlyAuthError = require_sdk.ClivlyAuthError;
6
6
  exports.ClivlyError = require_sdk.ClivlyError;
package/sdk.d.cts CHANGED
@@ -1,12 +1,7 @@
1
- import { C as customObjectDeclarations, M as validateEntitiesConfig, a as ClivlyEntitiesConfig, f as CustomObjectDeclaration, l as ConfigValidationError, m as DiscoveredSchemaTable, u as ConfigValidationResult, w as defineClivlyConfig } from "./entity-config-ApnT5j3X.cjs";
2
- import { _ as RemoteProjectionsDescription, a as ClivlyConnectResult, c as ClivlyUser, d as DiscoveredTable, f as DoctorCheck, g as EnsuredObjectTypeResult, h as EnsuredMappingResult, i as ClivlyConnectReason, l as CreateChatSessionHandlerOptions, m as EnsureSchemaResult, n as ChatSessionRequestBody, o as ClivlySDK, p as DoctorReport, r as ChatWidgetVisitor, s as ClivlySDKConfig, u as CursorStore, y as SyncTriggerDescription } from "./namespace-probe-H7yWc0JV.cjs";
3
- //#region ../sdk/src/trigger-url.d.ts
1
+ import { C as customObjectDeclarations, M as validateEntitiesConfig, a as ClivlyEntitiesConfig, f as CustomObjectDeclaration, l as ConfigValidationError, m as DiscoveredSchemaTable, u as ConfigValidationResult, w as defineClivlyConfig } from "./entity-config-dNclLyBM.cjs";
2
+ import { _ as RemoteProjectionsDescription, a as ClivlyConnectResult, b as ExposurePolicy, c as ClivlyUser, d as DiscoveredTable, f as DoctorCheck, g as EnsuredObjectTypeResult, h as EnsuredMappingResult, i as ClivlyConnectReason, l as CreateChatSessionHandlerOptions, m as EnsureSchemaResult, n as ChatSessionRequestBody, o as ClivlySDK, p as DoctorReport, r as ChatWidgetVisitor, s as ClivlySDKConfig, u as CursorStore, y as SyncTriggerDescription } from "./namespace-probe-BHk3NcyI.cjs";
4
3
  export declare function isPlaceholderUrl(value: string): boolean;
5
- //#endregion
6
- //#region ../sdk/src/chat-session.d.ts
7
- export declare function createChatSessionHandler({ allowedOrigins, apiKey, apiUrl, fetchImpl, resolveUser }: CreateChatSessionHandlerOptions): (request: Request) => Promise<Response>;
8
- //#endregion
9
- //#region ../sdk/src/errors.d.ts
4
+ export declare function createChatSessionHandler({ allowedOrigins, apiKey, apiUrl, fetchImpl, resolveUser, resolveVisitorIp }: CreateChatSessionHandlerOptions): (request: Request) => Promise<Response>;
10
5
  export declare class ClivlyError extends Error {
11
6
  /** HTTP status, or null when the request never completed (network error). */
12
7
  readonly status: number | null;
@@ -26,8 +21,6 @@ export declare class ClivlyAuthError extends ClivlyError {}
26
21
  export declare class ClivlyRateLimitError extends ClivlyError {}
27
22
  /** The request never reached the server (network/DNS/TLS). Retryable. */
28
23
  export declare class ClivlyNetworkError extends ClivlyError {}
29
- //#endregion
30
- //#region ../sdk/src/index.d.ts
31
24
  export declare function memoryCursorStore(): CursorStore;
32
25
  /** The shape every key-value client shares: Workers KV, Upstash, node-redis. */
33
26
  export interface CursorKV {
@@ -67,5 +60,4 @@ export declare function kvCursorStore(kv: CursorKV, options?: {
67
60
  * clearly-marked TODOs) and land with the Cloudflare infrastructure.
68
61
  */
69
62
  export declare function createClivlySDK(config: ClivlySDKConfig): ClivlySDK;
70
- //#endregion
71
- export { type ChatSessionRequestBody, type ChatWidgetVisitor, type ClivlyConnectReason, type ClivlyConnectResult, type ClivlyEntitiesConfig, type ClivlySDK, type ClivlySDKConfig, type ClivlyUser, type ConfigValidationError, type ConfigValidationResult, type CreateChatSessionHandlerOptions, type CursorStore, type CustomObjectDeclaration, type DiscoveredSchemaTable, type DiscoveredTable, type DoctorCheck, type DoctorReport, type EnsureSchemaResult, type EnsuredMappingResult, type EnsuredObjectTypeResult, type RemoteProjectionsDescription, type SyncTriggerDescription, customObjectDeclarations, defineClivlyConfig, validateEntitiesConfig };
63
+ export { type ChatSessionRequestBody, type ChatWidgetVisitor, type ClivlyConnectReason, type ClivlyConnectResult, type ClivlyEntitiesConfig, type ClivlySDK, type ClivlySDKConfig, type ClivlyUser, type ConfigValidationError, type ConfigValidationResult, type CreateChatSessionHandlerOptions, type CursorStore, type CustomObjectDeclaration, type DiscoveredSchemaTable, type DiscoveredTable, type DoctorCheck, type DoctorReport, type EnsureSchemaResult, type EnsuredMappingResult, type EnsuredObjectTypeResult, type ExposurePolicy, type RemoteProjectionsDescription, type SyncTriggerDescription, customObjectDeclarations, defineClivlyConfig, validateEntitiesConfig };
package/sdk.d.mts CHANGED
@@ -1,12 +1,7 @@
1
- import { C as customObjectDeclarations, M as validateEntitiesConfig, a as ClivlyEntitiesConfig, f as CustomObjectDeclaration, l as ConfigValidationError, m as DiscoveredSchemaTable, u as ConfigValidationResult, w as defineClivlyConfig } from "./entity-config-CKcj4-M_.mjs";
2
- import { _ as RemoteProjectionsDescription, a as ClivlyConnectResult, c as ClivlyUser, d as DiscoveredTable, f as DoctorCheck, g as EnsuredObjectTypeResult, h as EnsuredMappingResult, i as ClivlyConnectReason, l as CreateChatSessionHandlerOptions, m as EnsureSchemaResult, n as ChatSessionRequestBody, o as ClivlySDK, p as DoctorReport, r as ChatWidgetVisitor, s as ClivlySDKConfig, u as CursorStore, y as SyncTriggerDescription } from "./namespace-probe-DykR0kgh.mjs";
3
- //#region ../sdk/src/trigger-url.d.ts
1
+ import { C as customObjectDeclarations, M as validateEntitiesConfig, a as ClivlyEntitiesConfig, f as CustomObjectDeclaration, l as ConfigValidationError, m as DiscoveredSchemaTable, u as ConfigValidationResult, w as defineClivlyConfig } from "./entity-config-X-KlnYXX.mjs";
2
+ import { _ as RemoteProjectionsDescription, a as ClivlyConnectResult, b as ExposurePolicy, c as ClivlyUser, d as DiscoveredTable, f as DoctorCheck, g as EnsuredObjectTypeResult, h as EnsuredMappingResult, i as ClivlyConnectReason, l as CreateChatSessionHandlerOptions, m as EnsureSchemaResult, n as ChatSessionRequestBody, o as ClivlySDK, p as DoctorReport, r as ChatWidgetVisitor, s as ClivlySDKConfig, u as CursorStore, y as SyncTriggerDescription } from "./namespace-probe-Dt_HXcI-.mjs";
4
3
  export declare function isPlaceholderUrl(value: string): boolean;
5
- //#endregion
6
- //#region ../sdk/src/chat-session.d.ts
7
- export declare function createChatSessionHandler({ allowedOrigins, apiKey, apiUrl, fetchImpl, resolveUser }: CreateChatSessionHandlerOptions): (request: Request) => Promise<Response>;
8
- //#endregion
9
- //#region ../sdk/src/errors.d.ts
4
+ export declare function createChatSessionHandler({ allowedOrigins, apiKey, apiUrl, fetchImpl, resolveUser, resolveVisitorIp }: CreateChatSessionHandlerOptions): (request: Request) => Promise<Response>;
10
5
  export declare class ClivlyError extends Error {
11
6
  /** HTTP status, or null when the request never completed (network error). */
12
7
  readonly status: number | null;
@@ -26,8 +21,6 @@ export declare class ClivlyAuthError extends ClivlyError {}
26
21
  export declare class ClivlyRateLimitError extends ClivlyError {}
27
22
  /** The request never reached the server (network/DNS/TLS). Retryable. */
28
23
  export declare class ClivlyNetworkError extends ClivlyError {}
29
- //#endregion
30
- //#region ../sdk/src/index.d.ts
31
24
  export declare function memoryCursorStore(): CursorStore;
32
25
  /** The shape every key-value client shares: Workers KV, Upstash, node-redis. */
33
26
  export interface CursorKV {
@@ -67,5 +60,4 @@ export declare function kvCursorStore(kv: CursorKV, options?: {
67
60
  * clearly-marked TODOs) and land with the Cloudflare infrastructure.
68
61
  */
69
62
  export declare function createClivlySDK(config: ClivlySDKConfig): ClivlySDK;
70
- //#endregion
71
- export { type ChatSessionRequestBody, type ChatWidgetVisitor, type ClivlyConnectReason, type ClivlyConnectResult, type ClivlyEntitiesConfig, type ClivlySDK, type ClivlySDKConfig, type ClivlyUser, type ConfigValidationError, type ConfigValidationResult, type CreateChatSessionHandlerOptions, type CursorStore, type CustomObjectDeclaration, type DiscoveredSchemaTable, type DiscoveredTable, type DoctorCheck, type DoctorReport, type EnsureSchemaResult, type EnsuredMappingResult, type EnsuredObjectTypeResult, type RemoteProjectionsDescription, type SyncTriggerDescription, customObjectDeclarations, defineClivlyConfig, validateEntitiesConfig };
63
+ export { type ChatSessionRequestBody, type ChatWidgetVisitor, type ClivlyConnectReason, type ClivlyConnectResult, type ClivlyEntitiesConfig, type ClivlySDK, type ClivlySDKConfig, type ClivlyUser, type ConfigValidationError, type ConfigValidationResult, type CreateChatSessionHandlerOptions, type CursorStore, type CustomObjectDeclaration, type DiscoveredSchemaTable, type DiscoveredTable, type DoctorCheck, type DoctorReport, type EnsureSchemaResult, type EnsuredMappingResult, type EnsuredObjectTypeResult, type ExposurePolicy, type RemoteProjectionsDescription, type SyncTriggerDescription, customObjectDeclarations, defineClivlyConfig, validateEntitiesConfig };
package/sdk.mjs CHANGED
@@ -1,3 +1,3 @@
1
- import { c as defineClivlyConfig, g as validateEntitiesConfig, s as customObjectDeclarations } from "./entity-config-Ccfb2IL9.mjs";
2
- import { a as ClivlyAuthError, c as ClivlyRateLimitError, i as memoryCursorStore, l as createChatSessionHandler, n as createClivlySDK, o as ClivlyError, r as kvCursorStore, s as ClivlyNetworkError, t as CURSOR_KEY_PREFIX, u as isPlaceholderUrl } from "./sdk-DLoVPlGB.mjs";
1
+ import { c as defineClivlyConfig, g as validateEntitiesConfig, s as customObjectDeclarations } from "./entity-config-g_oMPXlN.mjs";
2
+ import { a as ClivlyAuthError, c as ClivlyRateLimitError, i as memoryCursorStore, l as createChatSessionHandler, n as createClivlySDK, o as ClivlyError, r as kvCursorStore, s as ClivlyNetworkError, t as CURSOR_KEY_PREFIX, u as isPlaceholderUrl } from "./sdk-KzHpSf7F.mjs";
3
3
  export { CURSOR_KEY_PREFIX, ClivlyAuthError, ClivlyError, ClivlyNetworkError, ClivlyRateLimitError, createChatSessionHandler, createClivlySDK, customObjectDeclarations, defineClivlyConfig, isPlaceholderUrl, kvCursorStore, memoryCursorStore, validateEntitiesConfig };
@@ -1,6 +1,5 @@
1
- import { a as ClivlyEntitiesConfig } from "./entity-config-CKcj4-M_.mjs";
2
- import { n as CompiledView, t as CompileOptions } from "./view-compiler-CwKVoK1w.mjs";
3
- //#region ../core/src/sync-engine.d.ts
1
+ import { a as ClivlyEntitiesConfig } from "./entity-config-dNclLyBM.cjs";
2
+ import { n as CompiledView, t as CompileOptions } from "./view-compiler-cXqt4X-c.cjs";
4
3
  /**
5
4
  * Sync engine (Phase 3) — materializes the read-only entity views into Clivly's
6
5
  * own mirror tables (`crm_companies`, `crm_contacts`).
@@ -221,5 +220,4 @@ declare function previewSync(store: SyncStore, view: CompiledView, opts: {
221
220
  requiredFields: string[];
222
221
  sourceTable: string;
223
222
  }): Promise<PreviewResult>;
224
- //#endregion
225
223
  export { PreviewWarning as a, SyncAction as c, computeSampleWarnings as d, isRemovalAction as f, runSync as g, resolveActions as h, PreviewResult as i, SyncResult as l, reconcile as m, MirrorRecord as n, ResolvedMembership as o, previewSync as p, PersistAction as r, SourceRow as s, EntitySyncResult as t, SyncStore as u };
@@ -1,6 +1,5 @@
1
- import { a as ClivlyEntitiesConfig } from "./entity-config-ApnT5j3X.cjs";
2
- import { n as CompiledView, t as CompileOptions } from "./view-compiler-Cq8apvZ4.cjs";
3
- //#region ../core/src/sync-engine.d.ts
1
+ import { a as ClivlyEntitiesConfig } from "./entity-config-X-KlnYXX.mjs";
2
+ import { n as CompiledView, t as CompileOptions } from "./view-compiler-M23WiVGG.mjs";
4
3
  /**
5
4
  * Sync engine (Phase 3) — materializes the read-only entity views into Clivly's
6
5
  * own mirror tables (`crm_companies`, `crm_contacts`).
@@ -221,5 +220,4 @@ declare function previewSync(store: SyncStore, view: CompiledView, opts: {
221
220
  requiredFields: string[];
222
221
  sourceTable: string;
223
222
  }): Promise<PreviewResult>;
224
- //#endregion
225
223
  export { PreviewWarning as a, SyncAction as c, computeSampleWarnings as d, isRemovalAction as f, runSync as g, resolveActions as h, PreviewResult as i, SyncResult as l, reconcile as m, MirrorRecord as n, ResolvedMembership as o, previewSync as p, PersistAction as r, SourceRow as s, EntitySyncResult as t, SyncStore as u };