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
package/index.mjs CHANGED
@@ -1,8 +1,8 @@
1
1
  #!/usr/bin/env node
2
- import { t as CANONICAL_FIELDS } from "./entity-config-Ccfb2IL9.mjs";
3
- import "./mapping-score-C68uAqGB.mjs";
4
- import { hasDefiningColumn, isFrameworkTable, matchesConcept, requiredFieldsFor, scoreFieldMap, scoreRelationships, suggestCursorField, toFieldMap } from "./internal-entity-heuristics.mjs";
5
- import { n as createClivlySDK, u as isPlaceholderUrl } from "./sdk-DLoVPlGB.mjs";
2
+ import { t as CANONICAL_FIELDS } from "./entity-config-g_oMPXlN.mjs";
3
+ import "./mapping-score-CS-MTDL9.mjs";
4
+ import { d as suggestCursorField, i as isFrameworkTable, l as scoreFieldMap, n as hasDefiningColumn, o as matchesConcept, p as toFieldMap, s as requiredFieldsFor, u as scoreRelationships } from "./entity-heuristics-DE5ujoHw.mjs";
5
+ import { n as createClivlySDK, u as isPlaceholderUrl } from "./sdk-KzHpSf7F.mjs";
6
6
  import { createRequire } from "node:module";
7
7
  import { spawn } from "node:child_process";
8
8
  import { accessSync, constants, existsSync, mkdirSync, readFileSync, readdirSync, realpathSync, statSync, watch, writeFileSync } from "node:fs";
@@ -12,7 +12,7 @@ import { createInterface } from "node:readline/promises";
12
12
  import { createJiti } from "jiti";
13
13
  import { fileURLToPath, pathToFileURL } from "node:url";
14
14
  import { Socket } from "node:net";
15
- //#region ../core/src/env-file.ts
15
+ // ../core/src/env-file.ts
16
16
  const ENV_FILES = {
17
17
  next: ".env.local",
18
18
  "tanstack-start": ".env",
@@ -57,8 +57,7 @@ function resolveEnvFile(input) {
57
57
  if (input.existing.includes(conventional)) return conventional;
58
58
  return input.existing[0] ?? conventional;
59
59
  }
60
- //#endregion
61
- //#region src/app-layout.ts
60
+ // src/app-layout.ts
62
61
  function resolveAppLayout(cwd, fileExists = existsSync) {
63
62
  if (fileExists(join(cwd, "src", "app"))) return "src/app";
64
63
  if (fileExists(join(cwd, "app"))) return "app";
@@ -77,8 +76,7 @@ Nothing was written. Please report this at https://github.com/amani-joseph/clivl
77
76
  — Clivly should have detected the src/app layout automatically.
78
77
  `;
79
78
  }
80
- //#endregion
81
- //#region src/load-config.ts
79
+ // src/load-config.ts
82
80
  const CONFIG_HINT = "Expected clivly.config.ts at your app root exporting `createClivlySDK({...})`.";
83
81
  function resolveConfigPath(cwd, configPath) {
84
82
  return resolve(cwd, configPath ?? "clivly.config.ts");
@@ -130,8 +128,7 @@ async function loadConfigSdk(path, requiredMethod) {
130
128
  if (typeof sdk?.[requiredMethod] !== "function") throw new Error("default export is not a Clivly SDK instance");
131
129
  return sdk;
132
130
  }
133
- //#endregion
134
- //#region src/cli-config.ts
131
+ // src/cli-config.ts
135
132
  const CLI_CONFIG_NAMES = [
136
133
  "clivly.cli.ts",
137
134
  "clivly.cli.js",
@@ -174,16 +171,14 @@ async function loadCliConfig(cwd) {
174
171
  const envFiles = readEnvFiles(config);
175
172
  return envFiles ? { envFiles } : {};
176
173
  }
177
- //#endregion
178
- //#region src/dashboard-locations.ts
174
+ // src/dashboard-locations.ts
179
175
  /** Secret + publishable keys. The Connect dialog mints them and shows the secret once. */
180
176
  const CREDENTIALS_LOCATION = "Clivly dashboard → Connect app (or Settings → API keys)";
181
177
  /** The signing secret Clivly Cloud uses on sync-trigger callbacks. */
182
178
  const SYNC_SECRET_LOCATION = "Clivly dashboard → Integrations → Remote sync";
183
179
  /** Chat widget records and their allowed origins. */
184
180
  const WIDGET_LOCATION = "Clivly dashboard → Settings → Chat widget";
185
- //#endregion
186
- //#region src/detect.ts
181
+ // src/detect.ts
187
182
  const FRAMEWORK_MARKERS = [
188
183
  {
189
184
  framework: "nextjs",
@@ -291,8 +286,7 @@ function addCommand(pm, packages) {
291
286
  args: [pm === "npm" ? "install" : "add", ...packages]
292
287
  };
293
288
  }
294
- //#endregion
295
- //#region src/detect-workspace.ts
289
+ // src/detect-workspace.ts
296
290
  const SELECTABLE_FRAMEWORKS = [
297
291
  "nextjs",
298
292
  "tanstack-start",
@@ -409,8 +403,7 @@ function detectAcrossWorkspace(appDeps, packages) {
409
403
  sources
410
404
  };
411
405
  }
412
- //#endregion
413
- //#region src/tick-route.ts
406
+ // src/tick-route.ts
414
407
  /**
415
408
  * The tick route's public URL path, and the template `clivly login` writes for
416
409
  * it.
@@ -447,8 +440,7 @@ const CLIVLY_TICK_PATH = "/api/clivly/tick";
447
440
  * auto-detected, and `clivly dev` handles local development.
448
441
  */
449
442
  const TRIGGER_URL_PLACEHOLDER = `https://<yourDomain.com>${CLIVLY_TICK_PATH}`;
450
- //#endregion
451
- //#region src/dev-tunnel.ts
443
+ // src/dev-tunnel.ts
452
444
  const CLOUDFLARE_QUICK_TUNNEL_REGEX = /https:\/\/[a-z0-9-]+\.trycloudflare\.com/;
453
445
  const DEFAULT_PORT = "3000";
454
446
  /**
@@ -567,8 +559,7 @@ function cloudflaredMissingMessage() {
567
559
  "Your app will still run locally; only dashboard-triggered sync is unavailable."
568
560
  ].join("\n");
569
561
  }
570
- //#endregion
571
- //#region src/tunnel-identity.ts
562
+ // src/tunnel-identity.ts
572
563
  /**
573
564
  * Whether the published tunnel actually reaches *this* app's Clivly route.
574
565
  *
@@ -686,8 +677,7 @@ function tunnelMismatchMessage(port) {
686
677
  " Until then, dashboard-triggered syncs will not reach this app."
687
678
  ].join("\n");
688
679
  }
689
- //#endregion
690
- //#region src/dev.ts
680
+ // src/dev.ts
691
681
  const UNREACHABLE_RESULT = {
692
682
  ok: false,
693
683
  kind: "unreachable"
@@ -769,8 +759,7 @@ async function runDev(options) {
769
759
  });
770
760
  });
771
761
  }
772
- //#endregion
773
- //#region src/dev-override.ts
762
+ // src/dev-override.ts
774
763
  const TRIGGER_URL_PATH = "/clivly/sdk/trigger-url";
775
764
  const HTTP_UNAUTHORIZED = 401;
776
765
  const HTTP_NOT_FOUND = 404;
@@ -810,8 +799,7 @@ async function clearTunnelOverride(deps) {
810
799
  if (res.ok) return { ok: true };
811
800
  return failureFor(res.status);
812
801
  }
813
- //#endregion
814
- //#region src/probe-module.ts
802
+ // src/probe-module.ts
815
803
  async function probeModule(opts) {
816
804
  for (const candidate of opts.candidates) {
817
805
  let mod;
@@ -827,8 +815,7 @@ async function probeModule(opts) {
827
815
  }
828
816
  return null;
829
817
  }
830
- //#endregion
831
- //#region src/workspace-graph.ts
818
+ // src/workspace-graph.ts
832
819
  const WINDOWS_SEP$3 = /\\/g;
833
820
  const MODULE_EXT$1 = /\.(ts|tsx|js|jsx|mjs|cjs|cts|mts)$/;
834
821
  const BRACE_GROUP = /\{([^{}]*)\}/;
@@ -1064,8 +1051,7 @@ function toPackageSpecifier(pkg, absPath) {
1064
1051
  if (subpath.length === 0) return pkg.name;
1065
1052
  return exportsAllowSubpath(pkg.dir, subpath) ? `${pkg.name}/${subpath}` : null;
1066
1053
  }
1067
- //#endregion
1068
- //#region src/discover-schema.ts
1054
+ // src/discover-schema.ts
1069
1055
  const WINDOWS_SEP$2 = /\\/g;
1070
1056
  const MODULE_EXT = /\.(ts|js|mjs|cts|mts)$/;
1071
1057
  /**
@@ -1240,8 +1226,7 @@ async function discoverSchema(opts) {
1240
1226
  db
1241
1227
  };
1242
1228
  }
1243
- //#endregion
1244
- //#region src/engine-check.ts
1229
+ // src/engine-check.ts
1245
1230
  const MAJOR = /^v?(\d+)/;
1246
1231
  const FIRST_NUMBER = /(\d+)/;
1247
1232
  function currentMajor(version) {
@@ -1263,8 +1248,7 @@ Upgrade with \`nvm install ${need}\` (or your version manager of choice), then r
1263
1248
  Set CLIVLY_SKIP_ENGINE_CHECK=1 to run anyway — expect unrelated-looking failures.
1264
1249
  `;
1265
1250
  }
1266
- //#endregion
1267
- //#region src/env-file.ts
1251
+ // src/env-file.ts
1268
1252
  const REGEX_METACHARACTERS = /[.*+?^${}()|[\]\\]/g;
1269
1253
  function escapeForRegExp(key) {
1270
1254
  return key.replace(REGEX_METACHARACTERS, "\\$&");
@@ -1347,8 +1331,7 @@ function upsertEnvValues(existing, entries, options = {}) {
1347
1331
  written
1348
1332
  };
1349
1333
  }
1350
- //#endregion
1351
- //#region src/help.ts
1334
+ // src/help.ts
1352
1335
  const ROOT_HELP = `clivly — embed a CRM in your app
1353
1336
 
1354
1337
  Usage:
@@ -1477,10 +1460,9 @@ function isHelpRequest(argv) {
1477
1460
  }
1478
1461
  function helpFor(command) {
1479
1462
  if (!command) return ROOT_HELP;
1480
- return COMMAND_HELP[command] ?? ROOT_HELP;
1463
+ return COMMAND_HELP[command] ?? "clivly — embed a CRM in your app\n\nUsage:\n clivly init [options] Scaffold Clivly (config, routes, env file) for your app\n clivly add widget [options] Scaffold the chat-session route\n clivly status [options] Check your setup, step by step\n clivly push-schema [options] Push schema, custom objects and mappings to Clivly\n clivly dev [options] Tunnel localhost so remote sync can reach you\n clivly login [options] Pair this machine and write credentials to your env file\n clivly --version Print the installed clivly version\n\nDeprecated aliases — each runs part of `clivly status` and still works:\n clivly ping credential + reachability\n clivly connect the above, plus config and trigger URL\n clivly doctor config, setup checks and edge safety\n\nPrefer `clivly status`: it runs the whole ladder and tells you which step you\nare on. The aliases are kept because output and docs have recommended them.\n\nRun `clivly <command> --help` for details on a command.\n";
1481
1464
  }
1482
- //#endregion
1483
- //#region src/install.ts
1465
+ // src/install.ts
1484
1466
  const defaultRun = (command, args, cwd) => new Promise((resolvePromise, reject) => {
1485
1467
  const child = spawn(command, args, {
1486
1468
  cwd,
@@ -1521,8 +1503,7 @@ async function installPackages(options) {
1521
1503
  };
1522
1504
  }
1523
1505
  }
1524
- //#endregion
1525
- //#region src/install-needed.ts
1506
+ // src/install-needed.ts
1526
1507
  /** Exact `name@version` only. Anything else is left for the package manager. */
1527
1508
  const EXACT_VERSION = /^\d+\.\d+\.\d+(?:[-+][0-9A-Za-z.-]+)?$/;
1528
1509
  /**
@@ -1561,8 +1542,7 @@ function packagesNeedingInstall(packages, installedVersion) {
1561
1542
  return present !== version;
1562
1543
  });
1563
1544
  }
1564
- //#endregion
1565
- //#region src/is-entry.ts
1545
+ // src/is-entry.ts
1566
1546
  function isEntrypoint(argv1, moduleUrl, realpath = realpathSync) {
1567
1547
  if (!argv1) return false;
1568
1548
  const modulePath = fileURLToPath(moduleUrl);
@@ -1575,8 +1555,7 @@ function isEntrypoint(argv1, moduleUrl, realpath = realpathSync) {
1575
1555
  };
1576
1556
  return resolve(argv1) === resolve(modulePath);
1577
1557
  }
1578
- //#endregion
1579
- //#region src/load-env.ts
1558
+ // src/load-env.ts
1580
1559
  const LINE = /^\s*(?:export\s+)?([A-Za-z_][A-Za-z0-9_]*)\s*=(.*)$/;
1581
1560
  const NEWLINE$1 = /\r?\n/;
1582
1561
  const ESCAPED_NEWLINE = /\\n/g;
@@ -1651,8 +1630,7 @@ function loadEnv(cwd, env = process.env, options = {}) {
1651
1630
  files
1652
1631
  };
1653
1632
  }
1654
- //#endregion
1655
- //#region src/secret-key-env.ts
1633
+ // src/secret-key-env.ts
1656
1634
  const SECRET_KEY_ENV = "CLIVLY_SECRET_KEY";
1657
1635
  const LEGACY_SECRET_KEY_ENV = "CLIVLY_API_KEY";
1658
1636
  function readSecretKeyEnv(env) {
@@ -1660,8 +1638,7 @@ function readSecretKeyEnv(env) {
1660
1638
  if (next && next.length > 0) return next;
1661
1639
  return env[LEGACY_SECRET_KEY_ENV];
1662
1640
  }
1663
- //#endregion
1664
- //#region src/login.ts
1641
+ // src/login.ts
1665
1642
  const POLL_INTERVAL_MS = 2e3;
1666
1643
  const POLL_BACKOFF_MULTIPLIER = 1.5;
1667
1644
  const POLL_INTERVAL_MAX_MS = 1e4;
@@ -1793,6 +1770,7 @@ async function runLogin(options) {
1793
1770
  const session = await createPairingSession(options.apiUrl, deps, options.rotate);
1794
1771
  if ("exitCode" in session) return session.exitCode;
1795
1772
  deps.out(`\nApprove this login in your browser:\n ${session.approveUrl}\n`);
1773
+ if (session.userCode) deps.out(`When asked, enter this code: ${session.userCode}\nOnly enter it on a page you opened from this terminal. Never share it.\n`);
1796
1774
  if (options.openBrowser) deps.open(session.approveUrl);
1797
1775
  deps.out("Waiting for approval…");
1798
1776
  const outcome = await pollForApproval(options.apiUrl, deps, session);
@@ -1804,8 +1782,7 @@ async function runLogin(options) {
1804
1782
  writeCredentials(options, outcome);
1805
1783
  return 0;
1806
1784
  }
1807
- //#endregion
1808
- //#region src/plan-init.ts
1785
+ // src/plan-init.ts
1809
1786
  function toScoredTable(table) {
1810
1787
  return {
1811
1788
  name: table.tableName,
@@ -2080,15 +2057,13 @@ function rankContactCandidates(tables) {
2080
2057
  table
2081
2058
  }));
2082
2059
  }
2083
- //#endregion
2084
- //#region src/config-import.ts
2060
+ // src/config-import.ts
2085
2061
  const WINDOWS_SEP$1 = /\\/g;
2086
2062
  function configImport(generatedFilePath) {
2087
2063
  const rel = relative(dirname(generatedFilePath), "clivly.config").replace(WINDOWS_SEP$1, "/");
2088
2064
  return rel.startsWith(".") ? rel : `./${rel}`;
2089
2065
  }
2090
- //#endregion
2091
- //#region src/boot-hook.ts
2066
+ // src/boot-hook.ts
2092
2067
  const BOOT_HOOK_PATHS = {
2093
2068
  nextjs: "instrumentation.ts",
2094
2069
  nuxt: "server/plugins/clivly.ts",
@@ -2237,8 +2212,7 @@ function planBootHook(framework, layout) {
2237
2212
  owned: true
2238
2213
  };
2239
2214
  }
2240
- //#endregion
2241
- //#region src/render-config.ts
2215
+ // src/render-config.ts
2242
2216
  const CLIVLY_ENV_KEYS = [
2243
2217
  {
2244
2218
  key: "CLIVLY_SECRET_KEY",
@@ -2363,8 +2337,7 @@ ${sources.join(",\n")},
2363
2337
  });
2364
2338
  `;
2365
2339
  }
2366
- //#endregion
2367
- //#region src/render-auth.ts
2340
+ // src/render-auth.ts
2368
2341
  const RESOLVE_USER = "const resolveUser = (req: Request) => adapter.getUser(req);";
2369
2342
  const STUB = {
2370
2343
  complete: false,
@@ -2438,8 +2411,7 @@ function renderAuthWiring(auth, authInstance = null) {
2438
2411
  default: return STUB;
2439
2412
  }
2440
2413
  }
2441
- //#endregion
2442
- //#region src/tsconfig-alias.ts
2414
+ // src/tsconfig-alias.ts
2443
2415
  const LEADING_DOT_SLASH$1 = /^\.\//;
2444
2416
  const TRAILING_WILDCARD = /\/?\*$/;
2445
2417
  const TRAILING_SLASH = /\/$/;
@@ -2515,8 +2487,7 @@ function baseReaching(mapped, target) {
2515
2487
  if (base === "") return target === "" ? null : "";
2516
2488
  return target.startsWith(`${base}/`) ? base : null;
2517
2489
  }
2518
- //#endregion
2519
- //#region src/scaffold.ts
2490
+ // src/scaffold.ts
2520
2491
  const TANSTACK_ROUTE_PREFIX = /^src\/routes\//;
2521
2492
  const TS_EXTENSION = /\.ts$/;
2522
2493
  const ROUTE_PATHS = {
@@ -2688,8 +2659,7 @@ function planWidgetScaffold(framework, layout = "app") {
2688
2659
  owned: true
2689
2660
  }];
2690
2661
  }
2691
- //#endregion
2692
- //#region src/vite-boot-patch.ts
2662
+ // src/vite-boot-patch.ts
2693
2663
  /** Config filenames to look for, in precedence order. */
2694
2664
  const VITE_CONFIG_CANDIDATES = [
2695
2665
  "vite.config.ts",
@@ -2727,8 +2697,7 @@ function patchViteConfig(source) {
2727
2697
  const separator = rest.startsWith("\n") ? "" : " ";
2728
2698
  return insertImports(`${source.slice(0, openBracketEnd)}${PLUGIN_CALL},${separator}${rest}`);
2729
2699
  }
2730
- //#endregion
2731
- //#region src/plan-mutations.ts
2700
+ // src/plan-mutations.ts
2732
2701
  function fileAction(existing, next, force) {
2733
2702
  if (existing === null) return "create";
2734
2703
  if (existing === next) return "unchanged";
@@ -2854,8 +2823,7 @@ function planWidgetMutations(args) {
2854
2823
  };
2855
2824
  });
2856
2825
  }
2857
- //#endregion
2858
- //#region src/port-probe.ts
2826
+ // src/port-probe.ts
2859
2827
  const PORT_PROBE_TIMEOUT_MS = 1500;
2860
2828
  /** One connect attempt against a single address family. */
2861
2829
  function connectsOn(port, host) {
@@ -2891,8 +2859,7 @@ function connectsOn(port, host) {
2891
2859
  function isLocalPortListening(port) {
2892
2860
  return Promise.all([connectsOn(port, "127.0.0.1"), connectsOn(port, "::1")]).then((results) => results.some(Boolean));
2893
2861
  }
2894
- //#endregion
2895
- //#region src/quiet-host-output.ts
2862
+ // src/quiet-host-output.ts
2896
2863
  /**
2897
2864
  * Run `fn` with the process's stdout/stderr captured. Always restores the
2898
2865
  * original writers, including when `fn` throws — a leaked patch would silence
@@ -2934,8 +2901,7 @@ async function quietly(fn) {
2934
2901
  const { result } = await captureHostOutput(fn);
2935
2902
  return result;
2936
2903
  }
2937
- //#endregion
2938
- //#region src/probe-auth.ts
2904
+ // src/probe-auth.ts
2939
2905
  const AUTH_MODULE_PATHS = [
2940
2906
  "auth",
2941
2907
  "lib/auth",
@@ -2969,8 +2935,7 @@ function probeAuthInstance(cwd, load) {
2969
2935
  match: isBetterAuthInstance
2970
2936
  }));
2971
2937
  }
2972
- //#endregion
2973
- //#region src/push-schema.ts
2938
+ // src/push-schema.ts
2974
2939
  /**
2975
2940
  * "1 mapping" / "3 mappings" — a count nobody has to decode. The plural is
2976
2941
  * explicit because appending "s" turns "entity" into "entitys".
@@ -3048,8 +3013,7 @@ async function runPushSchema(options) {
3048
3013
  out(" Open Integrations → Mapping to map your tables.\n");
3049
3014
  return 0;
3050
3015
  }
3051
- //#endregion
3052
- //#region src/resolve-schema-path.ts
3016
+ // src/resolve-schema-path.ts
3053
3017
  const COMMON_PATHS = [
3054
3018
  "src/db/schema.ts",
3055
3019
  "src/db/schema",
@@ -3127,8 +3091,7 @@ function resolveSchemaPath(opts) {
3127
3091
  }
3128
3092
  return null;
3129
3093
  }
3130
- //#endregion
3131
- //#region src/resolve-target-app.ts
3094
+ // src/resolve-target-app.ts
3132
3095
  function packageDeps(dir) {
3133
3096
  const pkg = readPackageManifest(dir);
3134
3097
  return {
@@ -3207,8 +3170,7 @@ function resolveTargetApp(start, boundary = homedir()) {
3207
3170
  candidates: ranked
3208
3171
  };
3209
3172
  }
3210
- //#endregion
3211
- //#region src/status-ladder.ts
3173
+ // src/status-ladder.ts
3212
3174
  const SATISFYING = /* @__PURE__ */ new Set(["pass", "warn"]);
3213
3175
  function unmetPrerequisites(stage, satisfied) {
3214
3176
  return (stage.needs ?? []).filter((id) => !satisfied.has(id));
@@ -3258,8 +3220,7 @@ async function runLadder(stages, ctx) {
3258
3220
  function ladderExitCode(results) {
3259
3221
  return results.every((result) => result.state !== "fail" && result.state !== "pending") ? 0 : 1;
3260
3222
  }
3261
- //#endregion
3262
- //#region src/boot-hook-check.ts
3223
+ // src/boot-hook-check.ts
3263
3224
  const REMIX_ENTRY_CANDIDATES = [
3264
3225
  "app/entry.server.tsx",
3265
3226
  "app/entry.server.ts",
@@ -3355,8 +3316,7 @@ function checkBootHook(readFile) {
3355
3316
  detail: site
3356
3317
  };
3357
3318
  }
3358
- //#endregion
3359
- //#region src/cursor-store-check.ts
3319
+ // src/cursor-store-check.ts
3360
3320
  /**
3361
3321
  * Whether a config that will run on a serverless runtime persists its sync
3362
3322
  * cursor.
@@ -3436,8 +3396,7 @@ function cursorStoreDetail(verdict) {
3436
3396
  if (verdict.edgeRuntime === null) return "in-memory (fine on a long-lived host)";
3437
3397
  return `No \`cursorStore\` on ${verdict.edgeRuntime} — memory does not survive between invocations, so every delta sync re-reads your entire source tables.`;
3438
3398
  }
3439
- //#endregion
3440
- //#region src/edge-safety.ts
3399
+ // src/edge-safety.ts
3441
3400
  const NODE_BUILTINS = /* @__PURE__ */ new Set([
3442
3401
  "assert",
3443
3402
  "buffer",
@@ -3591,8 +3550,7 @@ function analyzeConfigTree(input) {
3591
3550
  }
3592
3551
  return issues;
3593
3552
  }
3594
- //#endregion
3595
- //#region src/status-stages.ts
3553
+ // src/status-stages.ts
3596
3554
  const MODULE_CANDIDATES = [
3597
3555
  ".ts",
3598
3556
  ".tsx",
@@ -3850,8 +3808,7 @@ const STATUS_STAGES = [
3850
3808
  function defaultLoadSdk(path) {
3851
3809
  return loadConfigSdk(path, "doctor");
3852
3810
  }
3853
- //#endregion
3854
- //#region src/workspace-section.ts
3811
+ // src/workspace-section.ts
3855
3812
  const MARK$1 = {
3856
3813
  active: "⏳",
3857
3814
  blocked: "🔒",
@@ -3888,8 +3845,7 @@ function workspaceSection(result) {
3888
3845
  lines: result.workspace.steps.map((step) => ` ${MARK$1[step.state]} ${step.label}${step.evidence ? ` ${step.evidence}` : ""}`)
3889
3846
  };
3890
3847
  }
3891
- //#endregion
3892
- //#region src/status.ts
3848
+ // src/status.ts
3893
3849
  /** Stage ids each legacy command maps onto. */
3894
3850
  const ALIAS_STAGE_IDS = {
3895
3851
  status: STATUS_STAGES.map((stage) => stage.id),
@@ -3971,8 +3927,7 @@ async function runStatus(options) {
3971
3927
  if (code !== 0 && results.some((result) => result.state === "pending")) out("\nSetup is incomplete — finish the steps above and re-run.\n");
3972
3928
  return code;
3973
3929
  }
3974
- //#endregion
3975
- //#region src/index.ts
3930
+ // src/index.ts
3976
3931
  const ENV_FILE_CANDIDATES = [
3977
3932
  ".env",
3978
3933
  ".env.local",
@@ -4813,5 +4768,4 @@ async function main(argv) {
4813
4768
  if (isEntrypoint(process.argv[1], import.meta.url)) main(process.argv.slice(2)).then((code) => {
4814
4769
  process.exitCode = code;
4815
4770
  });
4816
- //#endregion
4817
4771
  export { KNOWN_COMMANDS, credentialsMissing, main, nearestCommand, runAdd, runInit, runInitFromArgv };
@@ -1,4 +1,3 @@
1
- //#region ../core/src/integration-state.d.ts
2
1
  declare const INTEGRATION_STEPS: readonly ["credential", "application", "schema", "mapping", "trigger", "sync", "widget"];
3
2
  type StepId = (typeof INTEGRATION_STEPS)[number];
4
3
  /** `blocked` means "prerequisite unmet", never "broken" — see C-19. */
@@ -169,5 +168,4 @@ interface IntegrationState {
169
168
  status: IntegrationStatus;
170
169
  steps: IntegrationStep[];
171
170
  }
172
- //#endregion
173
171
  export { IntegrationStep as a, StepProblem as c, IntegrationStatus as i, StepState as l, IntegrationFacts as n, NextAction as o, IntegrationState as r, StepId as s, ConnectionLiveness as t };
@@ -1,4 +1,3 @@
1
- //#region ../core/src/integration-state.d.ts
2
1
  declare const INTEGRATION_STEPS: readonly ["credential", "application", "schema", "mapping", "trigger", "sync", "widget"];
3
2
  type StepId = (typeof INTEGRATION_STEPS)[number];
4
3
  /** `blocked` means "prerequisite unmet", never "broken" — see C-19. */
@@ -169,5 +168,4 @@ interface IntegrationState {
169
168
  status: IntegrationStatus;
170
169
  steps: IntegrationStep[];
171
170
  }
172
- //#endregion
173
171
  export { IntegrationStep as a, StepProblem as c, IntegrationStatus as i, StepState as l, IntegrationFacts as n, NextAction as o, IntegrationState as r, StepId as s, ConnectionLiveness as t };
@@ -1,4 +1,36 @@
1
- //#region ../core/src/deal-value.ts
1
+ import { a as _enum, o as array, p as string, u as object } from "./projection-BkYXvjTr.mjs";
2
+ // ../core/src/contact-segment.ts
3
+ /** AND conditions over deliberately mapped host fields, never SQL identifiers. */
4
+ const contactSegmentSchema = array(object({
5
+ field: string().min(1).max(160),
6
+ operator: _enum([
7
+ "equals",
8
+ "not_equals",
9
+ "contains",
10
+ "gt",
11
+ "gte",
12
+ "lt",
13
+ "lte",
14
+ "is_set",
15
+ "is_not_set"
16
+ ]),
17
+ value: string().max(1e3).optional()
18
+ }).strict().superRefine((rule, ctx) => {
19
+ if (!["is_set", "is_not_set"].includes(rule.operator) && rule.value === void 0) ctx.addIssue({
20
+ code: "custom",
21
+ message: "Enter a value for this condition."
22
+ });
23
+ if ([
24
+ "gt",
25
+ "gte",
26
+ "lt",
27
+ "lte"
28
+ ].includes(rule.operator) && !(rule.value?.trim() && Number.isFinite(Number(rule.value)))) ctx.addIssue({
29
+ code: "custom",
30
+ message: "Enter a finite number for this comparison."
31
+ });
32
+ })).max(20);
33
+ // ../core/src/deal-value.ts
2
34
  const MONTHS_PER_YEAR = 12;
3
35
  /** Only two decimal-free seat counts make sense; anything else is bad data. */
4
36
  const SEAT_COUNT_REGEX = /^\d+$/;
@@ -37,8 +69,7 @@ function normalizePrice(monthly, source, fields, mappedFields) {
37
69
  }
38
70
  return source.intervalField !== void 0 && mappedFields.has(source.intervalField) && fields[source.intervalField] === "year" ? Math.round(monthly / MONTHS_PER_YEAR) : monthly;
39
71
  }
40
- //#endregion
41
- //#region ../core/src/host-owned-fields.ts
72
+ // ../core/src/host-owned-fields.ts
42
73
  /**
43
74
  * Which fields a CRM record lets a user edit.
44
75
  *
@@ -115,8 +146,7 @@ function rejectedCompanyFields(company, patch) {
115
146
  function hostOwnedFieldMessage(fields) {
116
147
  return `The ${fields.join(", ")} ${fields.length > 1 ? "fields are" : "field is"} synced from your app and cannot be edited here. Change it in your app and it will update on the next sync.`;
117
148
  }
118
- //#endregion
119
- //#region ../core/src/slug.ts
149
+ // ../core/src/slug.ts
120
150
  /**
121
151
  * The one `slugify`.
122
152
  *
@@ -184,8 +214,7 @@ function toObjectTypeSlug(displayName) {
184
214
  if (slug === "") return "";
185
215
  return MUST_START_WITH_LETTER.test(slug) ? slug : `${LEADING_DIGIT_PREFIX}${slug}`;
186
216
  }
187
- //#endregion
188
- //#region ../core/src/stage-rules.ts
217
+ // ../core/src/stage-rules.ts
189
218
  const CONDITION_OPS = /* @__PURE__ */ new Set([
190
219
  "is_empty",
191
220
  "is_not_empty",
@@ -258,5 +287,4 @@ function evaluateStage(rules, fields, mappedFields) {
258
287
  }
259
288
  return null;
260
289
  }
261
- //#endregion
262
- export { hostOwnedFieldMessage as a, rejectedContactFields as c, toObjectTypeSlug as i, computeDealValue as l, matchesCondition as n, isHostOwned as o, slugify as r, rejectedCompanyFields as s, evaluateStage as t };
290
+ export { hostOwnedFieldMessage as a, rejectedContactFields as c, toObjectTypeSlug as i, computeDealValue as l, matchesCondition as n, isHostOwned as o, slugify as r, rejectedCompanyFields as s, evaluateStage as t, contactSegmentSchema as u };
@@ -1,4 +1,36 @@
1
- //#region ../core/src/deal-value.ts
1
+ const require_projection = require("./projection-By63gMC-.cjs");
2
+ // ../core/src/contact-segment.ts
3
+ /** AND conditions over deliberately mapped host fields, never SQL identifiers. */
4
+ const contactSegmentSchema = require_projection.array(require_projection.object({
5
+ field: require_projection.string().min(1).max(160),
6
+ operator: require_projection._enum([
7
+ "equals",
8
+ "not_equals",
9
+ "contains",
10
+ "gt",
11
+ "gte",
12
+ "lt",
13
+ "lte",
14
+ "is_set",
15
+ "is_not_set"
16
+ ]),
17
+ value: require_projection.string().max(1e3).optional()
18
+ }).strict().superRefine((rule, ctx) => {
19
+ if (!["is_set", "is_not_set"].includes(rule.operator) && rule.value === void 0) ctx.addIssue({
20
+ code: "custom",
21
+ message: "Enter a value for this condition."
22
+ });
23
+ if ([
24
+ "gt",
25
+ "gte",
26
+ "lt",
27
+ "lte"
28
+ ].includes(rule.operator) && !(rule.value?.trim() && Number.isFinite(Number(rule.value)))) ctx.addIssue({
29
+ code: "custom",
30
+ message: "Enter a finite number for this comparison."
31
+ });
32
+ })).max(20);
33
+ // ../core/src/deal-value.ts
2
34
  const MONTHS_PER_YEAR = 12;
3
35
  /** Only two decimal-free seat counts make sense; anything else is bad data. */
4
36
  const SEAT_COUNT_REGEX = /^\d+$/;
@@ -37,8 +69,7 @@ function normalizePrice(monthly, source, fields, mappedFields) {
37
69
  }
38
70
  return source.intervalField !== void 0 && mappedFields.has(source.intervalField) && fields[source.intervalField] === "year" ? Math.round(monthly / MONTHS_PER_YEAR) : monthly;
39
71
  }
40
- //#endregion
41
- //#region ../core/src/host-owned-fields.ts
72
+ // ../core/src/host-owned-fields.ts
42
73
  /**
43
74
  * Which fields a CRM record lets a user edit.
44
75
  *
@@ -115,8 +146,7 @@ function rejectedCompanyFields(company, patch) {
115
146
  function hostOwnedFieldMessage(fields) {
116
147
  return `The ${fields.join(", ")} ${fields.length > 1 ? "fields are" : "field is"} synced from your app and cannot be edited here. Change it in your app and it will update on the next sync.`;
117
148
  }
118
- //#endregion
119
- //#region ../core/src/slug.ts
149
+ // ../core/src/slug.ts
120
150
  /**
121
151
  * The one `slugify`.
122
152
  *
@@ -184,8 +214,7 @@ function toObjectTypeSlug(displayName) {
184
214
  if (slug === "") return "";
185
215
  return MUST_START_WITH_LETTER.test(slug) ? slug : `${LEADING_DIGIT_PREFIX}${slug}`;
186
216
  }
187
- //#endregion
188
- //#region ../core/src/stage-rules.ts
217
+ // ../core/src/stage-rules.ts
189
218
  const CONDITION_OPS = /* @__PURE__ */ new Set([
190
219
  "is_empty",
191
220
  "is_not_empty",
@@ -258,13 +287,18 @@ function evaluateStage(rules, fields, mappedFields) {
258
287
  }
259
288
  return null;
260
289
  }
261
- //#endregion
262
290
  Object.defineProperty(exports, "computeDealValue", {
263
291
  enumerable: true,
264
292
  get: function() {
265
293
  return computeDealValue;
266
294
  }
267
295
  });
296
+ Object.defineProperty(exports, "contactSegmentSchema", {
297
+ enumerable: true,
298
+ get: function() {
299
+ return contactSegmentSchema;
300
+ }
301
+ });
268
302
  Object.defineProperty(exports, "evaluateStage", {
269
303
  enumerable: true,
270
304
  get: function() {