@clivly/sdk 0.3.0-next.3 → 0.3.0-next.5
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.
- package/dist/index.cjs +45 -2
- package/dist/index.mjs +45 -2
- package/package.json +2 -2
package/dist/index.cjs
CHANGED
|
@@ -12,7 +12,7 @@ function checkCustomObjectSlugs(config) {
|
|
|
12
12
|
name: "Custom object slugs",
|
|
13
13
|
ok: false,
|
|
14
14
|
skipped: true,
|
|
15
|
-
detail: "No custom objects
|
|
15
|
+
detail: "No custom objects in clivly.config. Objects added in the dashboard need a matching source.custom entry here to sync."
|
|
16
16
|
};
|
|
17
17
|
const problems = [];
|
|
18
18
|
const seen = /* @__PURE__ */ new Map();
|
|
@@ -37,6 +37,49 @@ function checkCustomObjectSlugs(config) {
|
|
|
37
37
|
};
|
|
38
38
|
}
|
|
39
39
|
//#endregion
|
|
40
|
+
//#region src/fetch-error.ts
|
|
41
|
+
/** Deepest `Error` reachable through the `.cause` chain (the original error if none). */
|
|
42
|
+
function rootError(error) {
|
|
43
|
+
let current = error;
|
|
44
|
+
const seen = /* @__PURE__ */ new Set();
|
|
45
|
+
while (current instanceof Error && current.cause !== void 0 && !seen.has(current)) {
|
|
46
|
+
seen.add(current);
|
|
47
|
+
current = current.cause;
|
|
48
|
+
}
|
|
49
|
+
return current;
|
|
50
|
+
}
|
|
51
|
+
function codeOf(error) {
|
|
52
|
+
const code = error?.code;
|
|
53
|
+
return typeof code === "string" ? code : void 0;
|
|
54
|
+
}
|
|
55
|
+
const CODE_HINTS = {
|
|
56
|
+
ECONNREFUSED: "the database refused the connection — is Postgres running and is your database URL (e.g. DATABASE_URL) pointing at it?",
|
|
57
|
+
ENOTFOUND: "the database host couldn't be resolved — check the host in your connection string.",
|
|
58
|
+
ETIMEDOUT: "the database connection timed out — check the host, port, and firewall.",
|
|
59
|
+
"28P01": "password authentication failed — check the credentials in your connection string.",
|
|
60
|
+
"28000": "the database rejected the connection role — check the user in your connection string.",
|
|
61
|
+
"3D000": "that database does not exist — check the database name in your connection string.",
|
|
62
|
+
"08006": "the database connection was lost — check that Postgres is reachable."
|
|
63
|
+
};
|
|
64
|
+
const NEWLINE = /\r?\n/;
|
|
65
|
+
/** One-line, single-spaced version of an error message (drops the SQL/params blob). */
|
|
66
|
+
function firstLine(message) {
|
|
67
|
+
const line = message.split(NEWLINE)[0]?.trim() ?? "";
|
|
68
|
+
return line === "" ? message.trim() : line;
|
|
69
|
+
}
|
|
70
|
+
/**
|
|
71
|
+
* Build the `detail` string for a failed sample fetch of `entity`.
|
|
72
|
+
* Recognised connection errors get a plain-English hint; everything else
|
|
73
|
+
* surfaces the root cause's first line rather than the wrapper's SQL dump.
|
|
74
|
+
*/
|
|
75
|
+
function describeFetchError(entity, error) {
|
|
76
|
+
const root = rootError(error);
|
|
77
|
+
const code = codeOf(root) ?? codeOf(error);
|
|
78
|
+
const hint = code ? CODE_HINTS[code] : void 0;
|
|
79
|
+
if (hint) return `Couldn't read "${entity}": ${hint}`;
|
|
80
|
+
return `Couldn't read "${entity}": ${firstLine(root instanceof Error ? root.message : String(root?.message ?? root ?? "unknown error"))}`;
|
|
81
|
+
}
|
|
82
|
+
//#endregion
|
|
40
83
|
//#region src/namespace-probe.ts
|
|
41
84
|
/**
|
|
42
85
|
* Verify the tables the integration depends on are genuinely reachable:
|
|
@@ -188,7 +231,7 @@ async function runDoctor(args) {
|
|
|
188
231
|
checks.push({
|
|
189
232
|
name: `Sample fetch (${source.entity})`,
|
|
190
233
|
ok: false,
|
|
191
|
-
detail:
|
|
234
|
+
detail: describeFetchError(source.entity, error)
|
|
192
235
|
});
|
|
193
236
|
}
|
|
194
237
|
const result = await connect();
|
package/dist/index.mjs
CHANGED
|
@@ -11,7 +11,7 @@ function checkCustomObjectSlugs(config) {
|
|
|
11
11
|
name: "Custom object slugs",
|
|
12
12
|
ok: false,
|
|
13
13
|
skipped: true,
|
|
14
|
-
detail: "No custom objects
|
|
14
|
+
detail: "No custom objects in clivly.config. Objects added in the dashboard need a matching source.custom entry here to sync."
|
|
15
15
|
};
|
|
16
16
|
const problems = [];
|
|
17
17
|
const seen = /* @__PURE__ */ new Map();
|
|
@@ -36,6 +36,49 @@ function checkCustomObjectSlugs(config) {
|
|
|
36
36
|
};
|
|
37
37
|
}
|
|
38
38
|
//#endregion
|
|
39
|
+
//#region src/fetch-error.ts
|
|
40
|
+
/** Deepest `Error` reachable through the `.cause` chain (the original error if none). */
|
|
41
|
+
function rootError(error) {
|
|
42
|
+
let current = error;
|
|
43
|
+
const seen = /* @__PURE__ */ new Set();
|
|
44
|
+
while (current instanceof Error && current.cause !== void 0 && !seen.has(current)) {
|
|
45
|
+
seen.add(current);
|
|
46
|
+
current = current.cause;
|
|
47
|
+
}
|
|
48
|
+
return current;
|
|
49
|
+
}
|
|
50
|
+
function codeOf(error) {
|
|
51
|
+
const code = error?.code;
|
|
52
|
+
return typeof code === "string" ? code : void 0;
|
|
53
|
+
}
|
|
54
|
+
const CODE_HINTS = {
|
|
55
|
+
ECONNREFUSED: "the database refused the connection — is Postgres running and is your database URL (e.g. DATABASE_URL) pointing at it?",
|
|
56
|
+
ENOTFOUND: "the database host couldn't be resolved — check the host in your connection string.",
|
|
57
|
+
ETIMEDOUT: "the database connection timed out — check the host, port, and firewall.",
|
|
58
|
+
"28P01": "password authentication failed — check the credentials in your connection string.",
|
|
59
|
+
"28000": "the database rejected the connection role — check the user in your connection string.",
|
|
60
|
+
"3D000": "that database does not exist — check the database name in your connection string.",
|
|
61
|
+
"08006": "the database connection was lost — check that Postgres is reachable."
|
|
62
|
+
};
|
|
63
|
+
const NEWLINE = /\r?\n/;
|
|
64
|
+
/** One-line, single-spaced version of an error message (drops the SQL/params blob). */
|
|
65
|
+
function firstLine(message) {
|
|
66
|
+
const line = message.split(NEWLINE)[0]?.trim() ?? "";
|
|
67
|
+
return line === "" ? message.trim() : line;
|
|
68
|
+
}
|
|
69
|
+
/**
|
|
70
|
+
* Build the `detail` string for a failed sample fetch of `entity`.
|
|
71
|
+
* Recognised connection errors get a plain-English hint; everything else
|
|
72
|
+
* surfaces the root cause's first line rather than the wrapper's SQL dump.
|
|
73
|
+
*/
|
|
74
|
+
function describeFetchError(entity, error) {
|
|
75
|
+
const root = rootError(error);
|
|
76
|
+
const code = codeOf(root) ?? codeOf(error);
|
|
77
|
+
const hint = code ? CODE_HINTS[code] : void 0;
|
|
78
|
+
if (hint) return `Couldn't read "${entity}": ${hint}`;
|
|
79
|
+
return `Couldn't read "${entity}": ${firstLine(root instanceof Error ? root.message : String(root?.message ?? root ?? "unknown error"))}`;
|
|
80
|
+
}
|
|
81
|
+
//#endregion
|
|
39
82
|
//#region src/namespace-probe.ts
|
|
40
83
|
/**
|
|
41
84
|
* Verify the tables the integration depends on are genuinely reachable:
|
|
@@ -187,7 +230,7 @@ async function runDoctor(args) {
|
|
|
187
230
|
checks.push({
|
|
188
231
|
name: `Sample fetch (${source.entity})`,
|
|
189
232
|
ok: false,
|
|
190
|
-
detail:
|
|
233
|
+
detail: describeFetchError(source.entity, error)
|
|
191
234
|
});
|
|
192
235
|
}
|
|
193
236
|
const result = await connect();
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@clivly/sdk",
|
|
3
|
-
"version": "0.3.0-next.
|
|
3
|
+
"version": "0.3.0-next.5",
|
|
4
4
|
"private": false,
|
|
5
5
|
"type": "module",
|
|
6
6
|
"description": "Clivly SDK — connect your app to Clivly Cloud (heartbeat, discovery, auth bridge).",
|
|
@@ -45,7 +45,7 @@
|
|
|
45
45
|
"access": "public"
|
|
46
46
|
},
|
|
47
47
|
"dependencies": {
|
|
48
|
-
"@clivly/core": "0.3.0-next.
|
|
48
|
+
"@clivly/core": "0.3.0-next.5"
|
|
49
49
|
},
|
|
50
50
|
"peerDependencies": {
|
|
51
51
|
"drizzle-orm": ">=0.30",
|