@siteping/server 0.0.0-stage → 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.
- package/README.md +40 -2
- package/dist/concurrency.d.cts +14 -0
- package/dist/concurrency.d.ts +14 -0
- package/dist/deep-link.d.cts +14 -0
- package/dist/deep-link.d.ts +14 -0
- package/dist/email.d.cts +22 -0
- package/dist/email.d.ts +22 -0
- package/dist/errors.d.cts +55 -0
- package/dist/errors.d.ts +55 -0
- package/dist/filters.d.cts +82 -0
- package/dist/filters.d.ts +82 -0
- package/dist/i18n.d.cts +85 -0
- package/dist/i18n.d.ts +85 -0
- package/dist/index.cjs +1270 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +488 -0
- package/dist/index.d.ts +488 -0
- package/dist/index.js +1237 -0
- package/dist/index.js.map +1 -0
- package/dist/schema.d.cts +317 -0
- package/dist/schema.d.ts +317 -0
- package/dist/screenshot-storage.d.cts +103 -0
- package/dist/screenshot-storage.d.ts +103 -0
- package/dist/siteping-core.d.cts +20 -0
- package/dist/siteping-core.d.ts +20 -0
- package/dist/store-helpers.d.cts +140 -0
- package/dist/store-helpers.d.ts +140 -0
- package/dist/type-utils.d.cts +66 -0
- package/dist/type-utils.d.ts +66 -0
- package/dist/types.d.cts +1206 -0
- package/dist/types.d.ts +1206 -0
- package/dist/wire.d.cts +68 -0
- package/dist/wire.d.ts +68 -0
- package/package.json +64 -4
package/dist/wire.d.cts
ADDED
|
@@ -0,0 +1,68 @@
|
|
|
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
|
+
* A fresh `clientId` for a write the server dedupes a resend of — a feedback,
|
|
14
|
+
* or a reply in a thread.
|
|
15
|
+
*/
|
|
16
|
+
export declare function newClientId(): string;
|
|
17
|
+
/**
|
|
18
|
+
* Encode a `FeedbackQuery` as the endpoint's expected query string.
|
|
19
|
+
* Omitted/empty filters are not serialized; `statuses` uses the CSV form
|
|
20
|
+
* the server's schema splits (`statuses=open,in_progress`).
|
|
21
|
+
*/
|
|
22
|
+
export declare function feedbackQueryToSearchParams(query: FeedbackQuery): URLSearchParams;
|
|
23
|
+
/**
|
|
24
|
+
* Merge caller-supplied `extra` headers over a client's `defaults`
|
|
25
|
+
* (`Content-Type`, `Authorization` from `apiKey`). Header names are
|
|
26
|
+
* case-insensitive, so a default spelled differently is dropped and the
|
|
27
|
+
* explicit value replaces it — a plain object merge kept both, and fetch
|
|
28
|
+
* joined them (`authorization: "Basic x"` over an apiKey went out as
|
|
29
|
+
* "Bearer k, Basic x").
|
|
30
|
+
*/
|
|
31
|
+
export declare function mergeRequestHeaders(defaults: Record<string, string>, extra: Record<string, string> | undefined): Record<string, string>;
|
|
32
|
+
/**
|
|
33
|
+
* Append `params` to `endpoint`, which may already carry a query string
|
|
34
|
+
* (`/api/siteping?tenant=acme`) or a fragment — naive `${endpoint}?${params}`
|
|
35
|
+
* produced `?tenant=acme?projectName=…`, a 400. Plain string work, so
|
|
36
|
+
* relative endpoints stay relative and nothing depends on `location`.
|
|
37
|
+
*/
|
|
38
|
+
export declare function withSearchParams(endpoint: string, params: URLSearchParams): string;
|
|
39
|
+
/**
|
|
40
|
+
* Map a non-OK `Response` to the appropriate typed error:
|
|
41
|
+
* - 401 / 403 → `SitepingAuthError`, with its `status`
|
|
42
|
+
* - other 4xx → `SitepingValidationError`, with its `status`
|
|
43
|
+
* - 5xx (or anything else) → generic `SitepingError` (code `"SERVER"`)
|
|
44
|
+
*
|
|
45
|
+
* The response body is consumed via `.text()` so the caller keeps the
|
|
46
|
+
* server-supplied message in the thrown error; `.text()` failures fall back
|
|
47
|
+
* to `"Unknown error"` (kept verbatim — host apps grep for it).
|
|
48
|
+
*/
|
|
49
|
+
export declare function errorFromResponse(response: Response, label: string): Promise<SitepingError>;
|
|
50
|
+
/**
|
|
51
|
+
* Whether a failed reply met a full thread — a store's `StoreLimitError`, or
|
|
52
|
+
* a 409 (the endpoint's other 409, a clientId reused on another feedback,
|
|
53
|
+
* never comes from clients that mint one per reply). Retrying won't help.
|
|
54
|
+
*/
|
|
55
|
+
export declare function isThreadFull(error: unknown): boolean;
|
|
56
|
+
/**
|
|
57
|
+
* Whether a failed reply delete found nothing to delete — a store's
|
|
58
|
+
* `StoreNotFoundError`, or a 404: it is gone already. (Unlike
|
|
59
|
+
* `isStoreNotFound`, no Prisma `P2025`: a browser source never meets one.)
|
|
60
|
+
*/
|
|
61
|
+
export declare function isCommentGone(error: unknown): boolean;
|
|
62
|
+
/**
|
|
63
|
+
* Normalise an exception thrown by `fetch` (or a timeout AbortController)
|
|
64
|
+
* into a `SitepingNetworkError`. AbortErrors count as network failures —
|
|
65
|
+
* in Siteping client code they always come from internal timeouts, never a
|
|
66
|
+
* user-driven cancellation.
|
|
67
|
+
*/
|
|
68
|
+
export declare function networkErrorFromException(error: unknown, label: string): SitepingNetworkError;
|
package/dist/wire.d.ts
ADDED
|
@@ -0,0 +1,68 @@
|
|
|
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
|
+
* A fresh `clientId` for a write the server dedupes a resend of — a feedback,
|
|
14
|
+
* or a reply in a thread.
|
|
15
|
+
*/
|
|
16
|
+
export declare function newClientId(): string;
|
|
17
|
+
/**
|
|
18
|
+
* Encode a `FeedbackQuery` as the endpoint's expected query string.
|
|
19
|
+
* Omitted/empty filters are not serialized; `statuses` uses the CSV form
|
|
20
|
+
* the server's schema splits (`statuses=open,in_progress`).
|
|
21
|
+
*/
|
|
22
|
+
export declare function feedbackQueryToSearchParams(query: FeedbackQuery): URLSearchParams;
|
|
23
|
+
/**
|
|
24
|
+
* Merge caller-supplied `extra` headers over a client's `defaults`
|
|
25
|
+
* (`Content-Type`, `Authorization` from `apiKey`). Header names are
|
|
26
|
+
* case-insensitive, so a default spelled differently is dropped and the
|
|
27
|
+
* explicit value replaces it — a plain object merge kept both, and fetch
|
|
28
|
+
* joined them (`authorization: "Basic x"` over an apiKey went out as
|
|
29
|
+
* "Bearer k, Basic x").
|
|
30
|
+
*/
|
|
31
|
+
export declare function mergeRequestHeaders(defaults: Record<string, string>, extra: Record<string, string> | undefined): Record<string, string>;
|
|
32
|
+
/**
|
|
33
|
+
* Append `params` to `endpoint`, which may already carry a query string
|
|
34
|
+
* (`/api/siteping?tenant=acme`) or a fragment — naive `${endpoint}?${params}`
|
|
35
|
+
* produced `?tenant=acme?projectName=…`, a 400. Plain string work, so
|
|
36
|
+
* relative endpoints stay relative and nothing depends on `location`.
|
|
37
|
+
*/
|
|
38
|
+
export declare function withSearchParams(endpoint: string, params: URLSearchParams): string;
|
|
39
|
+
/**
|
|
40
|
+
* Map a non-OK `Response` to the appropriate typed error:
|
|
41
|
+
* - 401 / 403 → `SitepingAuthError`, with its `status`
|
|
42
|
+
* - other 4xx → `SitepingValidationError`, with its `status`
|
|
43
|
+
* - 5xx (or anything else) → generic `SitepingError` (code `"SERVER"`)
|
|
44
|
+
*
|
|
45
|
+
* The response body is consumed via `.text()` so the caller keeps the
|
|
46
|
+
* server-supplied message in the thrown error; `.text()` failures fall back
|
|
47
|
+
* to `"Unknown error"` (kept verbatim — host apps grep for it).
|
|
48
|
+
*/
|
|
49
|
+
export declare function errorFromResponse(response: Response, label: string): Promise<SitepingError>;
|
|
50
|
+
/**
|
|
51
|
+
* Whether a failed reply met a full thread — a store's `StoreLimitError`, or
|
|
52
|
+
* a 409 (the endpoint's other 409, a clientId reused on another feedback,
|
|
53
|
+
* never comes from clients that mint one per reply). Retrying won't help.
|
|
54
|
+
*/
|
|
55
|
+
export declare function isThreadFull(error: unknown): boolean;
|
|
56
|
+
/**
|
|
57
|
+
* Whether a failed reply delete found nothing to delete — a store's
|
|
58
|
+
* `StoreNotFoundError`, or a 404: it is gone already. (Unlike
|
|
59
|
+
* `isStoreNotFound`, no Prisma `P2025`: a browser source never meets one.)
|
|
60
|
+
*/
|
|
61
|
+
export declare function isCommentGone(error: unknown): boolean;
|
|
62
|
+
/**
|
|
63
|
+
* Normalise an exception thrown by `fetch` (or a timeout AbortController)
|
|
64
|
+
* into a `SitepingNetworkError`. AbortErrors count as network failures —
|
|
65
|
+
* in Siteping client code they always come from internal timeouts, never a
|
|
66
|
+
* user-driven cancellation.
|
|
67
|
+
*/
|
|
68
|
+
export declare function networkErrorFromException(error: unknown, label: string): SitepingNetworkError;
|
package/package.json
CHANGED
|
@@ -1,6 +1,66 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@siteping/server",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"
|
|
5
|
-
"
|
|
6
|
-
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "Store- and framework-agnostic HTTP handler for Siteping — any SitepingStore behind one Fetch API endpoint",
|
|
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
|
+
},
|
|
19
|
+
"main": "./dist/index.cjs",
|
|
20
|
+
"module": "./dist/index.js",
|
|
21
|
+
"types": "./dist/index.d.ts",
|
|
22
|
+
"files": [
|
|
23
|
+
"dist"
|
|
24
|
+
],
|
|
25
|
+
"scripts": {
|
|
26
|
+
"build": "tsup && node ../../scripts/fix-dts.mjs dist",
|
|
27
|
+
"check": "tsc --noEmit",
|
|
28
|
+
"clean": "rm -rf dist"
|
|
29
|
+
},
|
|
30
|
+
"keywords": [
|
|
31
|
+
"siteping",
|
|
32
|
+
"server",
|
|
33
|
+
"api-handler",
|
|
34
|
+
"fetch-api",
|
|
35
|
+
"feedback",
|
|
36
|
+
"feedback-api",
|
|
37
|
+
"self-hosted",
|
|
38
|
+
"typescript"
|
|
39
|
+
],
|
|
40
|
+
"author": "neosianexus",
|
|
41
|
+
"license": "MIT",
|
|
42
|
+
"homepage": "https://siteping.dev",
|
|
43
|
+
"repository": {
|
|
44
|
+
"type": "git",
|
|
45
|
+
"url": "git+https://github.com/NeosiaNexus/SitePing.git",
|
|
46
|
+
"directory": "packages/server"
|
|
47
|
+
},
|
|
48
|
+
"bugs": {
|
|
49
|
+
"url": "https://github.com/NeosiaNexus/SitePing/issues"
|
|
50
|
+
},
|
|
51
|
+
"publishConfig": {
|
|
52
|
+
"access": "public"
|
|
53
|
+
},
|
|
54
|
+
"engines": {
|
|
55
|
+
"node": ">=20"
|
|
56
|
+
},
|
|
57
|
+
"dependencies": {
|
|
58
|
+
"zod": "^4.6.5"
|
|
59
|
+
},
|
|
60
|
+
"devDependencies": {
|
|
61
|
+
"@siteping/adapter-memory": "workspace:*",
|
|
62
|
+
"@siteping/core": "workspace:*",
|
|
63
|
+
"better-auth": "^1.7.5",
|
|
64
|
+
"jose": "^6.2.12"
|
|
65
|
+
}
|
|
66
|
+
}
|