@nimba/api-client 2.5.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/dist/index.d.ts +57 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +50 -0
- package/dist/index.js.map +1 -0
- package/package.json +22 -0
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @nimba/api-client — the typed SDK over the Nimba HTTP API.
|
|
3
|
+
*
|
|
4
|
+
* Every client (CLI, web, anything else) talks to @nimba/server through this,
|
|
5
|
+
* and NEVER imports the engine, the bridge, or the tasks. This package has no
|
|
6
|
+
* dependency on the server-internal half of the monorepo — that boundary is the
|
|
7
|
+
* point.
|
|
8
|
+
*/
|
|
9
|
+
export interface NimbaApiClientOptions {
|
|
10
|
+
/** Base URL of the Nimba server, e.g. "http://localhost:3000". */
|
|
11
|
+
baseUrl: string;
|
|
12
|
+
/** Bearer token for the Nimba API, when authentication is enabled. */
|
|
13
|
+
token?: string;
|
|
14
|
+
}
|
|
15
|
+
export interface HealthResponse {
|
|
16
|
+
status: string;
|
|
17
|
+
}
|
|
18
|
+
export interface FlowSummary {
|
|
19
|
+
name: string;
|
|
20
|
+
description: string;
|
|
21
|
+
}
|
|
22
|
+
export interface FlowInfo {
|
|
23
|
+
name: string;
|
|
24
|
+
description: string;
|
|
25
|
+
unimplemented: string[];
|
|
26
|
+
steps: unknown[];
|
|
27
|
+
}
|
|
28
|
+
export interface FlowRunResponse {
|
|
29
|
+
flow: string;
|
|
30
|
+
success: boolean;
|
|
31
|
+
duration: number;
|
|
32
|
+
error?: string;
|
|
33
|
+
steps: Array<{
|
|
34
|
+
stepNumber: number;
|
|
35
|
+
name: string;
|
|
36
|
+
skipped: boolean;
|
|
37
|
+
success: boolean;
|
|
38
|
+
data?: unknown;
|
|
39
|
+
error?: string;
|
|
40
|
+
}>;
|
|
41
|
+
}
|
|
42
|
+
export declare class NimbaApiClient {
|
|
43
|
+
private readonly options;
|
|
44
|
+
constructor(options: NimbaApiClientOptions);
|
|
45
|
+
/** Liveness check against the server's /health endpoint. */
|
|
46
|
+
health(): Promise<HealthResponse>;
|
|
47
|
+
/** List the available flows. */
|
|
48
|
+
listFlows(): Promise<FlowSummary[]>;
|
|
49
|
+
/** Get a flow's expanded step plan and unimplemented-task list. */
|
|
50
|
+
getFlow(name: string): Promise<FlowInfo>;
|
|
51
|
+
/** Run a flow against an org and return the result. */
|
|
52
|
+
runFlow(name: string, org: string, params?: Record<string, unknown>): Promise<FlowRunResponse>;
|
|
53
|
+
private get;
|
|
54
|
+
private post;
|
|
55
|
+
private authHeaders;
|
|
56
|
+
}
|
|
57
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,MAAM,WAAW,qBAAqB;IACpC,kEAAkE;IAClE,OAAO,EAAE,MAAM,CAAC;IAChB,sEAAsE;IACtE,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB;AAED,MAAM,WAAW,cAAc;IAC7B,MAAM,EAAE,MAAM,CAAC;CAChB;AAED,MAAM,WAAW,WAAW;IAC1B,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,EAAE,MAAM,CAAC;CACrB;AAED,MAAM,WAAW,QAAQ;IACvB,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,EAAE,MAAM,CAAC;IACpB,aAAa,EAAE,MAAM,EAAE,CAAC;IACxB,KAAK,EAAE,OAAO,EAAE,CAAC;CAClB;AAED,MAAM,WAAW,eAAe;IAC9B,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,OAAO,CAAC;IACjB,QAAQ,EAAE,MAAM,CAAC;IACjB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,KAAK,EAAE,KAAK,CAAC;QAAE,UAAU,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,MAAM,CAAC;QAAC,OAAO,EAAE,OAAO,CAAC;QAAC,OAAO,EAAE,OAAO,CAAC;QAAC,IAAI,CAAC,EAAE,OAAO,CAAC;QAAC,KAAK,CAAC,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC;CACxH;AAED,qBAAa,cAAc;IACb,OAAO,CAAC,QAAQ,CAAC,OAAO;gBAAP,OAAO,EAAE,qBAAqB;IAE3D,4DAA4D;IAC5D,MAAM,IAAI,OAAO,CAAC,cAAc,CAAC;IAIjC,gCAAgC;IAChC,SAAS,IAAI,OAAO,CAAC,WAAW,EAAE,CAAC;IAInC,mEAAmE;IACnE,OAAO,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,QAAQ,CAAC;IAIxC,uDAAuD;IACvD,OAAO,CAAC,IAAI,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,EAAE,MAAM,GAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAM,GAAG,OAAO,CAAC,eAAe,CAAC;YAIpF,GAAG;YAMH,IAAI;IAUlB,OAAO,CAAC,WAAW;CAGpB"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @nimba/api-client — the typed SDK over the Nimba HTTP API.
|
|
3
|
+
*
|
|
4
|
+
* Every client (CLI, web, anything else) talks to @nimba/server through this,
|
|
5
|
+
* and NEVER imports the engine, the bridge, or the tasks. This package has no
|
|
6
|
+
* dependency on the server-internal half of the monorepo — that boundary is the
|
|
7
|
+
* point.
|
|
8
|
+
*/
|
|
9
|
+
export class NimbaApiClient {
|
|
10
|
+
options;
|
|
11
|
+
constructor(options) {
|
|
12
|
+
this.options = options;
|
|
13
|
+
}
|
|
14
|
+
/** Liveness check against the server's /health endpoint. */
|
|
15
|
+
health() {
|
|
16
|
+
return this.get('/health');
|
|
17
|
+
}
|
|
18
|
+
/** List the available flows. */
|
|
19
|
+
listFlows() {
|
|
20
|
+
return this.get('/flows');
|
|
21
|
+
}
|
|
22
|
+
/** Get a flow's expanded step plan and unimplemented-task list. */
|
|
23
|
+
getFlow(name) {
|
|
24
|
+
return this.get(`/flows/${encodeURIComponent(name)}`);
|
|
25
|
+
}
|
|
26
|
+
/** Run a flow against an org and return the result. */
|
|
27
|
+
runFlow(name, org, params = {}) {
|
|
28
|
+
return this.post(`/flows/${encodeURIComponent(name)}/run`, { org, params });
|
|
29
|
+
}
|
|
30
|
+
async get(path) {
|
|
31
|
+
const res = await fetch(new URL(path, this.options.baseUrl), { headers: this.authHeaders() });
|
|
32
|
+
if (!res.ok)
|
|
33
|
+
throw new Error(`Nimba API GET ${path} failed: ${res.status} ${res.statusText}`);
|
|
34
|
+
return (await res.json());
|
|
35
|
+
}
|
|
36
|
+
async post(path, body) {
|
|
37
|
+
const res = await fetch(new URL(path, this.options.baseUrl), {
|
|
38
|
+
method: 'POST',
|
|
39
|
+
headers: { ...this.authHeaders(), 'content-type': 'application/json' },
|
|
40
|
+
body: JSON.stringify(body),
|
|
41
|
+
});
|
|
42
|
+
if (!res.ok)
|
|
43
|
+
throw new Error(`Nimba API POST ${path} failed: ${res.status} ${res.statusText}`);
|
|
44
|
+
return (await res.json());
|
|
45
|
+
}
|
|
46
|
+
authHeaders() {
|
|
47
|
+
return this.options.token ? { authorization: `Bearer ${this.options.token}` } : {};
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAiCH,MAAM,OAAO,cAAc;IACI;IAA7B,YAA6B,OAA8B;QAA9B,YAAO,GAAP,OAAO,CAAuB;IAAG,CAAC;IAE/D,4DAA4D;IAC5D,MAAM;QACJ,OAAO,IAAI,CAAC,GAAG,CAAiB,SAAS,CAAC,CAAC;IAC7C,CAAC;IAED,gCAAgC;IAChC,SAAS;QACP,O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IAAI,KAAK,CAAC,kBAAkB,IAAI,YAAY,GAAG,CAAC,MAAM,IAAI,GAAG,CAAC,UAAU,EAAE,CAAC,CAAC;QAC/F,OAAO,CAAC,MAAM,GAAG,CAAC,IAAI,EAAE,CAAM,CAAC;IACjC,CAAC;IAEO,WAAW;QACjB,OAAO,IAAI,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,aAAa,EAAE,UAAU,IAAI,CAAC,OAAO,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;IACrF,CAAC;CACF"}
|
package/package.json
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@nimba/api-client",
|
|
3
|
+
"version": "2.5.0",
|
|
4
|
+
"type": "module",
|
|
5
|
+
"main": "./dist/index.js",
|
|
6
|
+
"types": "./dist/index.d.ts",
|
|
7
|
+
"exports": {
|
|
8
|
+
".": "./dist/index.js"
|
|
9
|
+
},
|
|
10
|
+
"publishConfig": {
|
|
11
|
+
"access": "public"
|
|
12
|
+
},
|
|
13
|
+
"files": [
|
|
14
|
+
"dist"
|
|
15
|
+
],
|
|
16
|
+
"scripts": {
|
|
17
|
+
"build": "tsc -b",
|
|
18
|
+
"typecheck": "tsc -b --noEmit",
|
|
19
|
+
"clean": "rimraf dist *.tsbuildinfo",
|
|
20
|
+
"test": "vitest run --passWithNoTests"
|
|
21
|
+
}
|
|
22
|
+
}
|