@clivly/core 0.10.3 → 0.10.4

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.
@@ -31,6 +31,32 @@ const STEP_PREREQUISITES = {
31
31
  function stepIndex(id) {
32
32
  return INTEGRATION_STEPS.indexOf(id);
33
33
  }
34
+ const UNREACHABLE_STATUSES = /* @__PURE__ */ new Set([
35
+ 502,
36
+ 503,
37
+ 504,
38
+ 520,
39
+ 521,
40
+ 522,
41
+ 523,
42
+ 524,
43
+ 525,
44
+ 526,
45
+ 527,
46
+ 530
47
+ ]);
48
+ /**
49
+ * Did the last trigger attempt fail to reach the app at all?
50
+ *
51
+ * Deliberately narrow. A signature rejection (401) or a handler error (500)
52
+ * both prove the trigger works — the request arrived. Only a total failure to
53
+ * get an answer un-ticks the rung, so this cannot demote setup progress for
54
+ * faults that live somewhere else.
55
+ */
56
+ function triggerUnreachable(facts) {
57
+ const status = facts.lastRun?.status;
58
+ return facts.lastRun?.ok === false && status !== void 0 && UNREACHABLE_STATUSES.has(status);
59
+ }
34
60
  function formatAge(ms) {
35
61
  if (ms < 6e4) return `${Math.max(1, Math.round(ms / 1e3))}s ago`;
36
62
  if (ms < 36e5) return `${Math.round(ms / 6e4)}m ago`;
@@ -144,7 +170,7 @@ function isSatisfied(id, facts) {
144
170
  case "application": return facts.everConnected || age !== null;
145
171
  case "schema": return facts.discoveredTableCount > 0;
146
172
  case "mapping": return facts.mappedEntityCount > 0;
147
- case "trigger": return facts.triggerConfigured;
173
+ case "trigger": return facts.triggerConfigured && !triggerUnreachable(facts);
148
174
  case "sync": return facts.lastRun?.ok === true;
149
175
  default: return facts.widgetInstalled;
150
176
  }
@@ -154,11 +180,16 @@ function evidenceFor(id, facts) {
154
180
  if (id === "application" && age !== null) return `heartbeat ${formatAge(age)}`;
155
181
  if (id === "schema" && facts.discoveredTableCount > 0) return `found ${facts.discoveredTableCount} tables`;
156
182
  if (id === "mapping" && facts.mappedEntityCount > 0) return `${facts.mappedEntityCount} entity mapped`;
157
- if (id === "trigger" && facts.triggerConfigured) return "trigger URL and secret set";
183
+ if (id === "trigger" && facts.triggerConfigured) return triggerUnreachable(facts) ? "set, but the last attempt could not reach your app" : "trigger URL and secret set";
158
184
  if (id === "sync" && facts.lastRun) return `last run ${formatAge(facts.now - facts.lastRun.at)}`;
159
185
  return null;
160
186
  }
161
187
  function problemFor(id, facts) {
188
+ if (id === "trigger" && triggerUnreachable(facts)) return {
189
+ code: "trigger_unreachable",
190
+ message: "The trigger URL is set, but Clivly could not reach your app there.",
191
+ fix: "Check the app is running and serving that URL. A dev tunnel URL changes every session — `clivly dev` keeps it registered for you."
192
+ };
162
193
  if (id === "sync" && facts.lastRun && !facts.lastRun.ok) return {
163
194
  code: "sync_failed",
164
195
  message: facts.lastRun.message ?? "The last sync run failed.",
@@ -18,6 +18,14 @@ interface RunFact {
18
18
  at: number;
19
19
  message?: string;
20
20
  ok: boolean;
21
+ /**
22
+ * The HTTP status the host answered with, when there was one.
23
+ *
24
+ * Absent for a run that failed before any response existed, and for callers
25
+ * that do not track it — so every read must treat `undefined` as "unknown",
26
+ * never as "fine".
27
+ */
28
+ status?: number;
21
29
  }
22
30
  /**
23
31
  * Where the reporting app is running, as the app itself understands it.
@@ -18,6 +18,14 @@ interface RunFact {
18
18
  at: number;
19
19
  message?: string;
20
20
  ok: boolean;
21
+ /**
22
+ * The HTTP status the host answered with, when there was one.
23
+ *
24
+ * Absent for a run that failed before any response existed, and for callers
25
+ * that do not track it — so every read must treat `undefined` as "unknown",
26
+ * never as "fine".
27
+ */
28
+ status?: number;
21
29
  }
22
30
  /**
23
31
  * Where the reporting app is running, as the app itself understands it.
@@ -30,6 +30,32 @@ const STEP_PREREQUISITES = {
30
30
  function stepIndex(id) {
31
31
  return INTEGRATION_STEPS.indexOf(id);
32
32
  }
33
+ const UNREACHABLE_STATUSES = /* @__PURE__ */ new Set([
34
+ 502,
35
+ 503,
36
+ 504,
37
+ 520,
38
+ 521,
39
+ 522,
40
+ 523,
41
+ 524,
42
+ 525,
43
+ 526,
44
+ 527,
45
+ 530
46
+ ]);
47
+ /**
48
+ * Did the last trigger attempt fail to reach the app at all?
49
+ *
50
+ * Deliberately narrow. A signature rejection (401) or a handler error (500)
51
+ * both prove the trigger works — the request arrived. Only a total failure to
52
+ * get an answer un-ticks the rung, so this cannot demote setup progress for
53
+ * faults that live somewhere else.
54
+ */
55
+ function triggerUnreachable(facts) {
56
+ const status = facts.lastRun?.status;
57
+ return facts.lastRun?.ok === false && status !== void 0 && UNREACHABLE_STATUSES.has(status);
58
+ }
33
59
  function formatAge(ms) {
34
60
  if (ms < 6e4) return `${Math.max(1, Math.round(ms / 1e3))}s ago`;
35
61
  if (ms < 36e5) return `${Math.round(ms / 6e4)}m ago`;
@@ -143,7 +169,7 @@ function isSatisfied(id, facts) {
143
169
  case "application": return facts.everConnected || age !== null;
144
170
  case "schema": return facts.discoveredTableCount > 0;
145
171
  case "mapping": return facts.mappedEntityCount > 0;
146
- case "trigger": return facts.triggerConfigured;
172
+ case "trigger": return facts.triggerConfigured && !triggerUnreachable(facts);
147
173
  case "sync": return facts.lastRun?.ok === true;
148
174
  default: return facts.widgetInstalled;
149
175
  }
@@ -153,11 +179,16 @@ function evidenceFor(id, facts) {
153
179
  if (id === "application" && age !== null) return `heartbeat ${formatAge(age)}`;
154
180
  if (id === "schema" && facts.discoveredTableCount > 0) return `found ${facts.discoveredTableCount} tables`;
155
181
  if (id === "mapping" && facts.mappedEntityCount > 0) return `${facts.mappedEntityCount} entity mapped`;
156
- if (id === "trigger" && facts.triggerConfigured) return "trigger URL and secret set";
182
+ if (id === "trigger" && facts.triggerConfigured) return triggerUnreachable(facts) ? "set, but the last attempt could not reach your app" : "trigger URL and secret set";
157
183
  if (id === "sync" && facts.lastRun) return `last run ${formatAge(facts.now - facts.lastRun.at)}`;
158
184
  return null;
159
185
  }
160
186
  function problemFor(id, facts) {
187
+ if (id === "trigger" && triggerUnreachable(facts)) return {
188
+ code: "trigger_unreachable",
189
+ message: "The trigger URL is set, but Clivly could not reach your app there.",
190
+ fix: "Check the app is running and serving that URL. A dev tunnel URL changes every session — `clivly dev` keeps it registered for you."
191
+ };
161
192
  if (id === "sync" && facts.lastRun && !facts.lastRun.ok) return {
162
193
  code: "sync_failed",
163
194
  message: facts.lastRun.message ?? "The last sync run failed.",
package/package.json CHANGED
@@ -1,11 +1,11 @@
1
1
  {
2
2
  "name": "@clivly/core",
3
- "version": "0.10.3",
3
+ "version": "0.10.4",
4
4
  "private": false,
5
- "type": "module",
6
5
  "description": "ORM/auth-agnostic CRM adapter contracts and shared domain types for Clivly.",
7
6
  "license": "MIT",
8
7
  "sideEffects": false,
8
+ "type": "module",
9
9
  "exports": {
10
10
  ".": {
11
11
  "import": {
@@ -161,12 +161,15 @@
161
161
  "files": [
162
162
  "dist"
163
163
  ],
164
- "publishConfig": {
165
- "access": "public"
166
- },
167
164
  "dependencies": {
168
165
  "zod": "^4.1.13"
169
166
  },
167
+ "devDependencies": {
168
+ "drizzle-orm": "^0.45.1",
169
+ "tsdown": "^0.22.14",
170
+ "typescript": "^6",
171
+ "vitest": "3.2.7"
172
+ },
170
173
  "peerDependencies": {
171
174
  "drizzle-orm": ">=0.30 || >=1.0.0-rc.0"
172
175
  },
@@ -175,21 +178,18 @@
175
178
  "optional": true
176
179
  }
177
180
  },
178
- "devDependencies": {
179
- "drizzle-orm": "^0.45.1",
180
- "tsdown": "^0.22.14",
181
- "typescript": "^6",
182
- "vitest": "3.2.7"
183
- },
184
181
  "engines": {
185
182
  "node": ">=22"
186
183
  },
184
+ "publishConfig": {
185
+ "access": "public"
186
+ },
187
187
  "scripts": {
188
188
  "build": "tsdown",
189
189
  "check-types": "tsc --noEmit",
190
190
  "test": "vitest run"
191
191
  },
192
192
  "main": "./dist/index.cjs",
193
- "types": "./dist/index.d.cts",
194
- "module": "./dist/index.mjs"
193
+ "module": "./dist/index.mjs",
194
+ "types": "./dist/index.d.cts"
195
195
  }