@layerall/sdk 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/LICENSE +21 -0
- package/README.md +30 -0
- package/dist/index.d.ts +33 -0
- package/dist/index.js +54 -0
- package/package.json +58 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Sidarta Veloso
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
# @layerall/sdk
|
|
2
|
+
|
|
3
|
+
Minimal TypeScript client for LayerAll orchestrator services.
|
|
4
|
+
|
|
5
|
+
## Install
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
npm install @layerall/sdk
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
## Usage
|
|
12
|
+
|
|
13
|
+
```ts
|
|
14
|
+
import { Orchestrator } from '@layerall/sdk';
|
|
15
|
+
|
|
16
|
+
const client = new Orchestrator({
|
|
17
|
+
apiKey: process.env.LAYERALL_API_KEY!,
|
|
18
|
+
baseUrl: 'https://api.your-allx.com',
|
|
19
|
+
});
|
|
20
|
+
|
|
21
|
+
const result = await client.operation('create', {
|
|
22
|
+
payload: { externalId: 'req_123', data: { /* domain payload */ } },
|
|
23
|
+
strategy: 'round_robin',
|
|
24
|
+
timeoutMs: 8000,
|
|
25
|
+
});
|
|
26
|
+
|
|
27
|
+
console.log(result.id, result.provider, result.status, result.providerReceipt);
|
|
28
|
+
```
|
|
29
|
+
|
|
30
|
+
The same SDK works across any "All‑X" backend (e‑signature, payments, messaging, storage, LLMs, KYC…). See the root [README](../../README.md).
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { OperationName, OperationRequestOptions, OperationResult } from '@layerall/core';
|
|
2
|
+
|
|
3
|
+
declare class Orchestrator {
|
|
4
|
+
private readonly apiKey;
|
|
5
|
+
private readonly baseUrl;
|
|
6
|
+
private readonly endpoint;
|
|
7
|
+
private readonly fetchImpl;
|
|
8
|
+
constructor(opts: {
|
|
9
|
+
apiKey: string;
|
|
10
|
+
baseUrl: string;
|
|
11
|
+
/** Mount path of the operation endpoint (default `/v1/operation`). */
|
|
12
|
+
endpoint?: string;
|
|
13
|
+
/** Injectable fetch (for tests/non-browser runtimes). */
|
|
14
|
+
fetchImpl?: typeof fetch;
|
|
15
|
+
});
|
|
16
|
+
/**
|
|
17
|
+
* Performs an agnostic operation against the orchestrator backend.
|
|
18
|
+
* The backend resolves policy/strategy and routes to the chosen provider.
|
|
19
|
+
*/
|
|
20
|
+
operation<TData = unknown, TResult = unknown>(operation: OperationName, params: {
|
|
21
|
+
payload: {
|
|
22
|
+
externalId?: string;
|
|
23
|
+
data: TData;
|
|
24
|
+
};
|
|
25
|
+
} & OperationRequestOptions): Promise<OperationResult<TResult>>;
|
|
26
|
+
}
|
|
27
|
+
declare class OrchestratorError extends Error {
|
|
28
|
+
status: number;
|
|
29
|
+
code: string;
|
|
30
|
+
constructor(message: string, status: number, code: string);
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
export { Orchestrator, OrchestratorError };
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
// src/index.ts
|
|
2
|
+
var Orchestrator = class {
|
|
3
|
+
constructor(opts) {
|
|
4
|
+
this.apiKey = opts.apiKey;
|
|
5
|
+
this.baseUrl = opts.baseUrl.replace(/\/$/, "");
|
|
6
|
+
this.endpoint = opts.endpoint ?? "/v1/operation";
|
|
7
|
+
this.fetchImpl = opts.fetchImpl ?? globalThis.fetch.bind(globalThis);
|
|
8
|
+
}
|
|
9
|
+
/**
|
|
10
|
+
* Performs an agnostic operation against the orchestrator backend.
|
|
11
|
+
* The backend resolves policy/strategy and routes to the chosen provider.
|
|
12
|
+
*/
|
|
13
|
+
async operation(operation, params) {
|
|
14
|
+
const url = `${this.baseUrl}${this.endpoint}/${encodeURIComponent(operation)}`;
|
|
15
|
+
const body = {
|
|
16
|
+
payload: params.payload,
|
|
17
|
+
...params.strategy ? { strategy: params.strategy } : {},
|
|
18
|
+
...typeof params.timeoutMs === "number" ? { timeoutMs: params.timeoutMs } : {},
|
|
19
|
+
...typeof params.failover === "boolean" ? { failover: params.failover } : {}
|
|
20
|
+
};
|
|
21
|
+
const res = await this.fetchImpl(url, {
|
|
22
|
+
method: "POST",
|
|
23
|
+
headers: {
|
|
24
|
+
Authorization: `Bearer ${this.apiKey}`,
|
|
25
|
+
"Content-Type": "application/json"
|
|
26
|
+
},
|
|
27
|
+
body: JSON.stringify(body),
|
|
28
|
+
...params.signal ? { signal: params.signal } : {}
|
|
29
|
+
});
|
|
30
|
+
const json = await res.json().catch(() => ({}));
|
|
31
|
+
if (!res.ok) {
|
|
32
|
+
const err = new OrchestratorError(
|
|
33
|
+
json?.error?.message ?? `HTTP ${res.status}`,
|
|
34
|
+
res.status,
|
|
35
|
+
json?.error?.code ?? "http_error"
|
|
36
|
+
);
|
|
37
|
+
err.result = json;
|
|
38
|
+
throw err;
|
|
39
|
+
}
|
|
40
|
+
return json;
|
|
41
|
+
}
|
|
42
|
+
};
|
|
43
|
+
var OrchestratorError = class extends Error {
|
|
44
|
+
constructor(message, status, code) {
|
|
45
|
+
super(message);
|
|
46
|
+
this.name = "OrchestratorError";
|
|
47
|
+
this.status = status;
|
|
48
|
+
this.code = code;
|
|
49
|
+
}
|
|
50
|
+
};
|
|
51
|
+
export {
|
|
52
|
+
Orchestrator,
|
|
53
|
+
OrchestratorError
|
|
54
|
+
};
|
package/package.json
ADDED
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@layerall/sdk",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "Minimal TypeScript client SDK for LayerAll orchestrator services",
|
|
5
|
+
"keywords": [
|
|
6
|
+
"sdk",
|
|
7
|
+
"client",
|
|
8
|
+
"orchestration",
|
|
9
|
+
"layerall",
|
|
10
|
+
"typescript"
|
|
11
|
+
],
|
|
12
|
+
"author": "Sidarta Veloso <sidartaveloso@gmail.com>",
|
|
13
|
+
"license": "MIT",
|
|
14
|
+
"repository": {
|
|
15
|
+
"type": "git",
|
|
16
|
+
"url": "https://github.com/sidartaveloso/layerall.git",
|
|
17
|
+
"directory": "packages/sdk"
|
|
18
|
+
},
|
|
19
|
+
"bugs": {
|
|
20
|
+
"url": "https://github.com/sidartaveloso/layerall/issues"
|
|
21
|
+
},
|
|
22
|
+
"homepage": "https://github.com/sidartaveloso/layerall#readme",
|
|
23
|
+
"type": "module",
|
|
24
|
+
"publishConfig": {
|
|
25
|
+
"access": "public"
|
|
26
|
+
},
|
|
27
|
+
"main": "./dist/index.js",
|
|
28
|
+
"types": "./dist/index.d.ts",
|
|
29
|
+
"exports": {
|
|
30
|
+
".": {
|
|
31
|
+
"types": "./dist/index.d.ts",
|
|
32
|
+
"import": "./dist/index.js"
|
|
33
|
+
}
|
|
34
|
+
},
|
|
35
|
+
"files": [
|
|
36
|
+
"dist",
|
|
37
|
+
"README.md"
|
|
38
|
+
],
|
|
39
|
+
"dependencies": {
|
|
40
|
+
"@layerall/core": "0.1.0"
|
|
41
|
+
},
|
|
42
|
+
"devDependencies": {
|
|
43
|
+
"@vitest/coverage-v8": "^2.1.0",
|
|
44
|
+
"tsup": "^8.3.0",
|
|
45
|
+
"typescript": "^5.6.0",
|
|
46
|
+
"vitest": "^2.1.0"
|
|
47
|
+
},
|
|
48
|
+
"scripts": {
|
|
49
|
+
"build": "tsup src/index.ts --format esm --dts",
|
|
50
|
+
"dev": "tsup src/index.ts --format esm --dts --watch",
|
|
51
|
+
"clean": "rm -rf dist",
|
|
52
|
+
"lint": "tsc --noEmit",
|
|
53
|
+
"typecheck": "tsc --noEmit",
|
|
54
|
+
"test": "vitest run --coverage",
|
|
55
|
+
"test:watch": "vitest",
|
|
56
|
+
"test:no-coverage": "vitest run"
|
|
57
|
+
}
|
|
58
|
+
}
|