@siteping/adapter-kit 0.1.0

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.
@@ -0,0 +1,35 @@
1
+ /**
2
+ * HTTP wire helpers shared by every client that talks to a Siteping
3
+ * endpoint (widget `ApiClient`, dashboard `createEndpointSource`).
4
+ *
5
+ * One definition of the query-string encoding and the HTTP→typed-error
6
+ * mapping — two clients implementing them independently already drifted
7
+ * once (the dashboard forgot to serialize `statuses`), so they live here
8
+ * now.
9
+ */
10
+ import { SitepingError, SitepingNetworkError } from "./errors.cjs";
11
+ import type { FeedbackQuery } from "./types.cjs";
12
+ /**
13
+ * Encode a `FeedbackQuery` as the endpoint's expected query string.
14
+ * Omitted/empty filters are not serialized; `statuses` uses the CSV form
15
+ * the server's schema splits (`statuses=open,in_progress`).
16
+ */
17
+ export declare function feedbackQueryToSearchParams(query: FeedbackQuery): URLSearchParams;
18
+ /**
19
+ * Map a non-OK `Response` to the appropriate typed error:
20
+ * - 401 / 403 → `SitepingAuthError`
21
+ * - other 4xx → `SitepingValidationError`
22
+ * - 5xx (or anything else) → generic `SitepingError` (code `"SERVER"`)
23
+ *
24
+ * The response body is consumed via `.text()` so the caller keeps the
25
+ * server-supplied message in the thrown error; `.text()` failures fall back
26
+ * to `"Unknown error"` (kept verbatim — host apps grep for it).
27
+ */
28
+ export declare function errorFromResponse(response: Response, label: string): Promise<SitepingError>;
29
+ /**
30
+ * Normalise an exception thrown by `fetch` (or a timeout AbortController)
31
+ * into a `SitepingNetworkError`. AbortErrors count as network failures —
32
+ * in Siteping client code they always come from internal timeouts, never a
33
+ * user-driven cancellation.
34
+ */
35
+ export declare function networkErrorFromException(error: unknown, label: string): SitepingNetworkError;
package/dist/wire.d.ts ADDED
@@ -0,0 +1,35 @@
1
+ /**
2
+ * HTTP wire helpers shared by every client that talks to a Siteping
3
+ * endpoint (widget `ApiClient`, dashboard `createEndpointSource`).
4
+ *
5
+ * One definition of the query-string encoding and the HTTP→typed-error
6
+ * mapping — two clients implementing them independently already drifted
7
+ * once (the dashboard forgot to serialize `statuses`), so they live here
8
+ * now.
9
+ */
10
+ import { SitepingError, SitepingNetworkError } from "./errors.js";
11
+ import type { FeedbackQuery } from "./types.js";
12
+ /**
13
+ * Encode a `FeedbackQuery` as the endpoint's expected query string.
14
+ * Omitted/empty filters are not serialized; `statuses` uses the CSV form
15
+ * the server's schema splits (`statuses=open,in_progress`).
16
+ */
17
+ export declare function feedbackQueryToSearchParams(query: FeedbackQuery): URLSearchParams;
18
+ /**
19
+ * Map a non-OK `Response` to the appropriate typed error:
20
+ * - 401 / 403 → `SitepingAuthError`
21
+ * - other 4xx → `SitepingValidationError`
22
+ * - 5xx (or anything else) → generic `SitepingError` (code `"SERVER"`)
23
+ *
24
+ * The response body is consumed via `.text()` so the caller keeps the
25
+ * server-supplied message in the thrown error; `.text()` failures fall back
26
+ * to `"Unknown error"` (kept verbatim — host apps grep for it).
27
+ */
28
+ export declare function errorFromResponse(response: Response, label: string): Promise<SitepingError>;
29
+ /**
30
+ * Normalise an exception thrown by `fetch` (or a timeout AbortController)
31
+ * into a `SitepingNetworkError`. AbortErrors count as network failures —
32
+ * in Siteping client code they always come from internal timeouts, never a
33
+ * user-driven cancellation.
34
+ */
35
+ export declare function networkErrorFromException(error: unknown, label: string): SitepingNetworkError;
package/package.json ADDED
@@ -0,0 +1,77 @@
1
+ {
2
+ "name": "@siteping/adapter-kit",
3
+ "version": "0.1.0",
4
+ "description": "Everything needed to build and conformance-test a custom Siteping store adapter",
5
+ "type": "module",
6
+ "sideEffects": false,
7
+ "exports": {
8
+ ".": {
9
+ "import": {
10
+ "types": "./dist/index.d.ts",
11
+ "default": "./dist/index.js"
12
+ },
13
+ "require": {
14
+ "types": "./dist/index.d.cts",
15
+ "default": "./dist/index.cjs"
16
+ }
17
+ },
18
+ "./testing": {
19
+ "import": {
20
+ "types": "./dist/testing.d.ts",
21
+ "default": "./dist/testing.js"
22
+ },
23
+ "require": {
24
+ "types": "./dist/testing.d.cts",
25
+ "default": "./dist/testing.cjs"
26
+ }
27
+ }
28
+ },
29
+ "main": "./dist/index.cjs",
30
+ "module": "./dist/index.js",
31
+ "types": "./dist/index.d.ts",
32
+ "files": [
33
+ "dist"
34
+ ],
35
+ "scripts": {
36
+ "build": "tsup && node ../../scripts/fix-dts.mjs dist",
37
+ "check": "tsc --noEmit",
38
+ "clean": "rm -rf dist"
39
+ },
40
+ "keywords": [
41
+ "siteping",
42
+ "adapter",
43
+ "store",
44
+ "conformance",
45
+ "testing",
46
+ "feedback",
47
+ "typescript"
48
+ ],
49
+ "author": "neosianexus",
50
+ "license": "MIT",
51
+ "homepage": "https://siteping.dev",
52
+ "repository": {
53
+ "type": "git",
54
+ "url": "git+https://github.com/NeosiaNexus/SitePing.git",
55
+ "directory": "packages/adapter-kit"
56
+ },
57
+ "bugs": {
58
+ "url": "https://github.com/NeosiaNexus/SitePing/issues"
59
+ },
60
+ "publishConfig": {
61
+ "access": "public"
62
+ },
63
+ "engines": {
64
+ "node": ">=20"
65
+ },
66
+ "peerDependencies": {
67
+ "vitest": ">=3"
68
+ },
69
+ "peerDependenciesMeta": {
70
+ "vitest": {
71
+ "optional": true
72
+ }
73
+ },
74
+ "devDependencies": {
75
+ "@siteping/core": "workspace:*"
76
+ }
77
+ }