@nself/sdk 1.1.9

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,36 @@
1
+ /**
2
+ * @nself/sdk — TypeScript consumer SDK for a running nSelf instance.
3
+ *
4
+ * Purpose: Thin typed HTTP client over a local nSelf backend's admin API
5
+ * (health checks, plugin status). Not a GraphQL client — for
6
+ * Hasura GraphQL access, use @nself/graphql-client instead.
7
+ * Inputs: NselfClientOptions (baseUrl + optional adminSecret).
8
+ * Outputs: Typed HealthStatus / Plugin results; throws on non-2xx responses.
9
+ * Constraints: Requires a global `fetch` (Node 18+ or browser).
10
+ * SPORT: F13-CROSS-REPO-DEPS.md — @nself/sdk consumer SDK.
11
+ */
12
+ export interface NselfClientOptions {
13
+ baseUrl: string;
14
+ adminSecret?: string;
15
+ }
16
+ export interface HealthStatus {
17
+ status: string;
18
+ version: string;
19
+ uptime: number;
20
+ }
21
+ export interface Plugin {
22
+ name: string;
23
+ version: string;
24
+ status: string;
25
+ tier: string;
26
+ }
27
+ export declare class NselfClient {
28
+ private readonly baseUrl;
29
+ private readonly adminSecret?;
30
+ constructor(options: NselfClientOptions);
31
+ private buildHeaders;
32
+ private request;
33
+ health(): Promise<HealthStatus>;
34
+ listPlugins(): Promise<Plugin[]>;
35
+ }
36
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH,MAAM,WAAW,kBAAkB;IACjC,OAAO,EAAE,MAAM,CAAA;IACf,WAAW,CAAC,EAAE,MAAM,CAAA;CACrB;AAED,MAAM,WAAW,YAAY;IAC3B,MAAM,EAAE,MAAM,CAAA;IACd,OAAO,EAAE,MAAM,CAAA;IACf,MAAM,EAAE,MAAM,CAAA;CACf;AAED,MAAM,WAAW,MAAM;IACrB,IAAI,EAAE,MAAM,CAAA;IACZ,OAAO,EAAE,MAAM,CAAA;IACf,MAAM,EAAE,MAAM,CAAA;IACd,IAAI,EAAE,MAAM,CAAA;CACb;AAED,qBAAa,WAAW;IACtB,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAQ;IAChC,OAAO,CAAC,QAAQ,CAAC,WAAW,CAAC,CAAQ;gBAEzB,OAAO,EAAE,kBAAkB;IAKvC,OAAO,CAAC,YAAY;YAQN,OAAO;IAQf,MAAM,IAAI,OAAO,CAAC,YAAY,CAAC;IAI/B,WAAW,IAAI,OAAO,CAAC,MAAM,EAAE,CAAC;CAGvC"}
package/dist/index.js ADDED
@@ -0,0 +1,42 @@
1
+ "use strict";
2
+ /**
3
+ * @nself/sdk — TypeScript consumer SDK for a running nSelf instance.
4
+ *
5
+ * Purpose: Thin typed HTTP client over a local nSelf backend's admin API
6
+ * (health checks, plugin status). Not a GraphQL client — for
7
+ * Hasura GraphQL access, use @nself/graphql-client instead.
8
+ * Inputs: NselfClientOptions (baseUrl + optional adminSecret).
9
+ * Outputs: Typed HealthStatus / Plugin results; throws on non-2xx responses.
10
+ * Constraints: Requires a global `fetch` (Node 18+ or browser).
11
+ * SPORT: F13-CROSS-REPO-DEPS.md — @nself/sdk consumer SDK.
12
+ */
13
+ Object.defineProperty(exports, "__esModule", { value: true });
14
+ exports.NselfClient = void 0;
15
+ class NselfClient {
16
+ constructor(options) {
17
+ this.baseUrl = options.baseUrl.replace(/\/+$/, '');
18
+ this.adminSecret = options.adminSecret;
19
+ }
20
+ buildHeaders() {
21
+ const headers = { 'content-type': 'application/json' };
22
+ if (this.adminSecret) {
23
+ headers['x-hasura-admin-secret'] = this.adminSecret;
24
+ }
25
+ return headers;
26
+ }
27
+ async request(path) {
28
+ const response = await fetch(`${this.baseUrl}${path}`, { headers: this.buildHeaders() });
29
+ if (!response.ok) {
30
+ throw new Error(`nSelf API error: ${response.status}`);
31
+ }
32
+ return response.json();
33
+ }
34
+ async health() {
35
+ return this.request('/health');
36
+ }
37
+ async listPlugins() {
38
+ return this.request('/plugins');
39
+ }
40
+ }
41
+ exports.NselfClient = NselfClient;
42
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;GAUG;;;AAoBH,MAAa,WAAW;IAItB,YAAY,OAA2B;QACrC,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC,OAAO,CAAC,OAAO,CAAC,MAAM,EAAE,EAAE,CAAC,CAAA;QAClD,IAAI,CAAC,WAAW,GAAG,OAAO,CAAC,WAAW,CAAA;IACxC,CAAC;IAEO,YAAY;QAClB,MAAM,OAAO,GAA2B,EAAE,cAAc,EAAE,kBAAkB,EAAE,CAAA;QAC9E,IAAI,IAAI,CAAC,WAAW,EAAE,CAAC;YACrB,OAAO,CAAC,uBAAuB,CAAC,GAAG,IAAI,CAAC,WAAW,CAAA;QACrD,CAAC;QACD,OAAO,OAAO,CAAA;IAChB,CAAC;IAEO,KAAK,CAAC,OAAO,CAAI,IAAY;QACnC,MAAM,QAAQ,GAAG,MAAM,KAAK,CAAC,GAAG,IAAI,CAAC,OAAO,GAAG,IAAI,EAAE,EAAE,EAAE,OAAO,EAAE,IAAI,CAAC,YAAY,EAAE,EAAE,CAAC,CAAA;QACxF,IAAI,CAAC,QAAQ,CAAC,EAAE,EAAE,CAAC;YACjB,MAAM,IAAI,KAAK,CAAC,oBAAoB,QAAQ,CAAC,MAAM,EAAE,CAAC,CAAA;QACxD,CAAC;QACD,OAAO,QAAQ,CAAC,IAAI,EAAgB,CAAA;IACtC,CAAC;IAED,KAAK,CAAC,MAAM;QACV,OAAO,IAAI,CAAC,OAAO,CAAe,SAAS,CAAC,CAAA;IAC9C,CAAC;IAED,KAAK,CAAC,WAAW;QACf,OAAO,IAAI,CAAC,OAAO,CAAW,UAAU,CAAC,CAAA;IAC3C,CAAC;CACF;AAhCD,kCAgCC"}
package/package.json ADDED
@@ -0,0 +1,50 @@
1
+ {
2
+ "name": "@nself/sdk",
3
+ "version": "1.1.9",
4
+ "description": "TypeScript consumer SDK for nSelf — query GraphQL, manage plugins, auth, and admin from any TS/JS app.",
5
+ "main": "dist/index.js",
6
+ "types": "dist/index.d.ts",
7
+ "exports": {
8
+ ".": {
9
+ "import": "./dist/index.js",
10
+ "types": "./dist/index.d.ts"
11
+ }
12
+ },
13
+ "files": [
14
+ "dist"
15
+ ],
16
+ "license": "MIT",
17
+ "repository": {
18
+ "type": "git",
19
+ "url": "https://github.com/nself-org/cli.git",
20
+ "directory": "sdk/ts-sdk"
21
+ },
22
+ "keywords": [
23
+ "nself",
24
+ "sdk",
25
+ "graphql",
26
+ "self-hosted"
27
+ ],
28
+ "engines": {
29
+ "node": ">=18"
30
+ },
31
+ "devDependencies": {
32
+ "typescript": "^5.4.5",
33
+ "@types/node": "^20.12.12",
34
+ "jest": "^29.7.0",
35
+ "@types/jest": "^29.5.12",
36
+ "ts-jest": "^29.2.0"
37
+ },
38
+ "jest": {
39
+ "preset": "ts-jest",
40
+ "testEnvironment": "node",
41
+ "roots": [
42
+ "<rootDir>/src"
43
+ ]
44
+ },
45
+ "scripts": {
46
+ "build": "tsc",
47
+ "typecheck": "tsc --noEmit",
48
+ "test": "jest"
49
+ }
50
+ }