@boerules/sdk 0.0.0-stage → 5.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 +76 -2
- package/dist/client.d.ts +22 -0
- package/dist/client.d.ts.map +1 -0
- package/dist/client.js +264 -0
- package/dist/client.js.map +1 -0
- package/dist/errors.d.ts +100 -0
- package/dist/errors.d.ts.map +1 -0
- package/dist/errors.js +122 -0
- package/dist/errors.js.map +1 -0
- package/dist/index.d.ts +19 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +34 -0
- package/dist/index.js.map +1 -0
- package/dist/sdk-package-version.d.ts +2 -0
- package/dist/sdk-package-version.d.ts.map +1 -0
- package/dist/sdk-package-version.js +10 -0
- package/dist/sdk-package-version.js.map +1 -0
- package/dist/types/config.d.ts +11 -0
- package/dist/types/config.d.ts.map +1 -0
- package/dist/types/config.js +3 -0
- package/dist/types/config.js.map +1 -0
- package/dist/types/execution.d.ts +69 -0
- package/dist/types/execution.d.ts.map +1 -0
- package/dist/types/execution.js +3 -0
- package/dist/types/execution.js.map +1 -0
- package/dist/types/index.d.ts +4 -0
- package/dist/types/index.d.ts.map +1 -0
- package/dist/types/index.js +20 -0
- package/dist/types/index.js.map +1 -0
- package/dist/types/ruleset.d.ts +79 -0
- package/dist/types/ruleset.d.ts.map +1 -0
- package/dist/types/ruleset.js +3 -0
- package/dist/types/ruleset.js.map +1 -0
- package/package.json +50 -4
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 BOE
|
|
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
CHANGED
|
@@ -1,3 +1,77 @@
|
|
|
1
|
-
#
|
|
1
|
+
# @boerules/sdk
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
The TypeScript client for BOE. The wire protocol is `packages/sdk/implementation.md`.
|
|
4
|
+
|
|
5
|
+
```ts
|
|
6
|
+
import { createBOE } from '@boerules/sdk';
|
|
7
|
+
|
|
8
|
+
const boe = createBOE(); // reads BOE_API_KEY, targets https://api.boerules.com/v1
|
|
9
|
+
|
|
10
|
+
const ruleset = await boe.register(creditScoreRuleset);
|
|
11
|
+
const decision = await boe.execute(ruleset.shortCode, { income: 82000, missedPayments: 0 });
|
|
12
|
+
const pinned = await boe.execute(ruleset.shortCode, { income: 82000 }, { version: '1.0.0' });
|
|
13
|
+
|
|
14
|
+
console.log(decision.result, ruleset.executeUrl);
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
## Configuration
|
|
18
|
+
|
|
19
|
+
Every field of `createBOE(config?)` is optional.
|
|
20
|
+
|
|
21
|
+
| Setting | Config field | Environment variable | Default |
|
|
22
|
+
|---|---|---|---|
|
|
23
|
+
| API key | `apiKey` | `BOE_API_KEY` | none. A missing key throws `BOEConfigurationError` at construction. |
|
|
24
|
+
| Control plane base URL | `baseUrl` | `BOE_BASE_URL` | `https://api.boerules.com/v1` |
|
|
25
|
+
| Execute base URL | `executeBaseUrl` | none | the value of `baseUrl` |
|
|
26
|
+
| Request timeout in milliseconds | `timeout` | none | `30000` |
|
|
27
|
+
| Retries after the first attempt | `maxRetries` | none | `3` |
|
|
28
|
+
|
|
29
|
+
An explicit field wins over its environment variable. `register`, `listExecutions` and
|
|
30
|
+
`getExecution` use `baseUrl`. `execute` and the batch methods use `executeBaseUrl`.
|
|
31
|
+
|
|
32
|
+
## Methods
|
|
33
|
+
|
|
34
|
+
`register`, `execute`, `submitBatch`, `getBatchStatus`, `getBatchItems`, `pollBatch`,
|
|
35
|
+
`listExecutions`, `getExecution`. `BOEClient` also offers `iterateExecutions`.
|
|
36
|
+
|
|
37
|
+
## Errors
|
|
38
|
+
|
|
39
|
+
Every error extends `BOEError` and carries `code` and `status` when the server sent them.
|
|
40
|
+
|
|
41
|
+
| Class | Raised when |
|
|
42
|
+
|---|---|
|
|
43
|
+
| `BOEConfigurationError` | No API key at construction. |
|
|
44
|
+
| `BOEProductionKeyCannotRegisterError` | 403 `production_environment_key_cannot_register`: a Production key called `register`. Register with a Dev key. |
|
|
45
|
+
| `BOERulesetNotLiveInEnvironmentError` | 404 `ruleset_not_live_in_environment`: nothing is live in the key's environment. Promote a version. |
|
|
46
|
+
| `BOEApiError` | Any other refusal whose body carries a code. Fields: `code`, `status`, `serverMessage`. |
|
|
47
|
+
| `BOEFactValidationError` | Execute 400: the facts fail the input schema. `validationErrors` lists `instancePath`, `schemaPath`, `keyword` and `message` per failure. Extends `BOEExecutionError`. |
|
|
48
|
+
| `BOERegistrationError` | Register 400 without a code. |
|
|
49
|
+
| `BOEAuthorizationError` | 401 or 403 without a code. |
|
|
50
|
+
| `BOENotFoundError` | 404 without a code. |
|
|
51
|
+
| `BOEExecutionError` | 422: the engine ran and failed. Also any other execute 400. |
|
|
52
|
+
| `BOEConnectionError` | Network failure, timeout, or a 5xx after retries. |
|
|
53
|
+
|
|
54
|
+
```ts
|
|
55
|
+
try {
|
|
56
|
+
await boe.execute(shortCode, facts);
|
|
57
|
+
} catch (error) {
|
|
58
|
+
if (error instanceof BOERulesetNotLiveInEnvironmentError) {
|
|
59
|
+
console.error(error.serverMessage);
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
```
|
|
63
|
+
|
|
64
|
+
## Migrating from 4.x to 5.0.0
|
|
65
|
+
|
|
66
|
+
- `RegisterResult.endpoint` is now `RegisterResult.executeUrl`, an absolute URL.
|
|
67
|
+
- `execute` pins a version with `{ version }`, sent as `?version=`. It no longer travels in the body.
|
|
68
|
+
- `baseUrl` and `apiKey` are optional. `baseUrl` now includes `/v1`, and every path is relative to it.
|
|
69
|
+
- The 24 methods that threw "not implemented" are removed from `BOEClient`, `BOE` and `createBOE`:
|
|
70
|
+
`getProfile`, `updateProfile`, `listOrganizations`, `getOrganization`, `createChildOrganization`,
|
|
71
|
+
`updateOrganization`, `listMembers`, `inviteMember`, `updateMemberRole`, `suspendMember`,
|
|
72
|
+
`removeMember`, `listProjects`, `getProject`, `createProject`, `updateProject`, `deleteProject`,
|
|
73
|
+
`listProjectMembers`, `assignProjectMember`, `updateProjectMemberRole`, `removeProjectMember`,
|
|
74
|
+
`checkPermission`, `listPermissions`, `checkProjectPermission`, `listProjectPermissions`.
|
|
75
|
+
Their types and enums (`AccountStatus`, `OrgRole`, `MembershipStatus`, `Operation`, `ProjectRole`) are removed too.
|
|
76
|
+
- A 403 raises `BOEAuthorizationError`. A refusal with a `code` raises `BOEApiError` or a named subclass.
|
|
77
|
+
- `X-BOE-SDK-Version` reports the package version.
|
package/dist/client.d.ts
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import type { BOEConfig, RegisterResult, ExecuteResult, ExecuteOptions, BatchSubmitResult, BatchStatusResult, BatchItemsResult, BatchItemsOptions, ExecutionLogEntry, ListExecutionsOptions, ListExecutionsResult } from './types';
|
|
2
|
+
export declare class BOEClient {
|
|
3
|
+
private readonly baseUrl;
|
|
4
|
+
private readonly executeBaseUrl;
|
|
5
|
+
private readonly apiKey;
|
|
6
|
+
private readonly timeout;
|
|
7
|
+
private readonly maxRetries;
|
|
8
|
+
constructor(config?: BOEConfig);
|
|
9
|
+
register<T extends Record<string, unknown>>(ruleset: T): Promise<RegisterResult>;
|
|
10
|
+
execute<T = unknown>(shortCode: string, facts: Record<string, unknown>, options?: ExecuteOptions): Promise<ExecuteResult<T>>;
|
|
11
|
+
submitBatch(shortCode: string, items: Array<{
|
|
12
|
+
facts: Record<string, unknown>;
|
|
13
|
+
}>, options?: Record<string, unknown>): Promise<BatchSubmitResult>;
|
|
14
|
+
getBatchStatus(batchCode: string): Promise<BatchStatusResult>;
|
|
15
|
+
getBatchItems(batchCode: string, options?: BatchItemsOptions): Promise<BatchItemsResult>;
|
|
16
|
+
pollBatch(batchCode: string, intervalMs?: number): Promise<BatchStatusResult>;
|
|
17
|
+
listExecutions(options?: ListExecutionsOptions): Promise<ListExecutionsResult>;
|
|
18
|
+
getExecution(executionId: string): Promise<ExecutionLogEntry>;
|
|
19
|
+
iterateExecutions(options?: ListExecutionsOptions): AsyncGenerator<ExecutionLogEntry, void, void>;
|
|
20
|
+
private request;
|
|
21
|
+
}
|
|
22
|
+
//# sourceMappingURL=client.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../src/client.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,SAAS,EACT,cAAc,EACd,aAAa,EACb,cAAc,EACd,iBAAiB,EACjB,iBAAiB,EACjB,gBAAgB,EAChB,iBAAiB,EACjB,iBAAiB,EACjB,qBAAqB,EACrB,oBAAoB,EACrB,MAAM,SAAS,CAAC;AAmCjB,qBAAa,S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,EAAE,qBAAqB,GAC9B,cAAc,CAAC,iBAAiB,EAAE,IAAI,EAAE,IAAI,CAAC;YAclC,OAAO;CA6JtB"}
|
package/dist/client.js
ADDED
|
@@ -0,0 +1,264 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.BOEClient = void 0;
|
|
4
|
+
const errors_1 = require("./errors");
|
|
5
|
+
const sdk_package_version_1 = require("./sdk-package-version");
|
|
6
|
+
const DEFAULT_BASE_URL = 'https://api.boerules.com/v1';
|
|
7
|
+
// An `error` value that is itself a code (ruleset_archived on register 409 and
|
|
8
|
+
// execute 410). implementation.md, "Body shapes".
|
|
9
|
+
const ERROR_VALUES_THAT_ARE_CODES = new Set(['ruleset_archived']);
|
|
10
|
+
function trimTrailingSlash(url) {
|
|
11
|
+
return url.replace(/\/$/, '');
|
|
12
|
+
}
|
|
13
|
+
function readEnvironmentVariable(name) {
|
|
14
|
+
const value = typeof process !== 'undefined' ? process.env?.[name] : undefined;
|
|
15
|
+
return value ? value : undefined;
|
|
16
|
+
}
|
|
17
|
+
class BOEClient {
|
|
18
|
+
baseUrl;
|
|
19
|
+
executeBaseUrl;
|
|
20
|
+
apiKey;
|
|
21
|
+
timeout;
|
|
22
|
+
maxRetries;
|
|
23
|
+
constructor(config = {}) {
|
|
24
|
+
const apiKey = config.apiKey || readEnvironmentVariable('BOE_API_KEY');
|
|
25
|
+
if (!apiKey) {
|
|
26
|
+
throw new errors_1.BOEConfigurationError('No API key. Pass { apiKey } or set the BOE_API_KEY environment variable.');
|
|
27
|
+
}
|
|
28
|
+
this.apiKey = apiKey;
|
|
29
|
+
this.baseUrl = trimTrailingSlash(config.baseUrl || readEnvironmentVariable('BOE_BASE_URL') || DEFAULT_BASE_URL);
|
|
30
|
+
this.executeBaseUrl = config.executeBaseUrl
|
|
31
|
+
? trimTrailingSlash(config.executeBaseUrl)
|
|
32
|
+
: this.baseUrl;
|
|
33
|
+
this.timeout = config.timeout ?? 30_000;
|
|
34
|
+
this.maxRetries = config.maxRetries ?? 3;
|
|
35
|
+
}
|
|
36
|
+
// ── Rulesets ──
|
|
37
|
+
async register(ruleset) {
|
|
38
|
+
const result = await this.request('POST', '/register', ruleset);
|
|
39
|
+
// A register Lambda deployed before #1114 answers no executeUrl.
|
|
40
|
+
if (!result.executeUrl && typeof result.shortCode === 'string') {
|
|
41
|
+
result.executeUrl = `${this.executeBaseUrl}/execute/${encodeURIComponent(result.shortCode)}`;
|
|
42
|
+
}
|
|
43
|
+
return result;
|
|
44
|
+
}
|
|
45
|
+
async execute(shortCode, facts, options) {
|
|
46
|
+
const { version, ...bodyOptions } = options ?? {};
|
|
47
|
+
const qs = version ? `?version=${encodeURIComponent(version)}` : '';
|
|
48
|
+
return this.request('POST', `/execute/${encodeURIComponent(shortCode)}${qs}`, { facts, options: bodyOptions }, this.executeBaseUrl);
|
|
49
|
+
}
|
|
50
|
+
// ── Batch ──
|
|
51
|
+
async submitBatch(shortCode, items, options) {
|
|
52
|
+
return this.request('POST', `/execute-batch/${encodeURIComponent(shortCode)}`, { items, options }, this.executeBaseUrl);
|
|
53
|
+
}
|
|
54
|
+
async getBatchStatus(batchCode) {
|
|
55
|
+
return this.request('GET', `/execute-batch/${encodeURIComponent(batchCode)}`, undefined, this.executeBaseUrl);
|
|
56
|
+
}
|
|
57
|
+
async getBatchItems(batchCode, options) {
|
|
58
|
+
const params = new URLSearchParams();
|
|
59
|
+
if (options?.offset != null)
|
|
60
|
+
params.set('offset', String(options.offset));
|
|
61
|
+
if (options?.limit != null)
|
|
62
|
+
params.set('limit', String(options.limit));
|
|
63
|
+
if (options?.status)
|
|
64
|
+
params.set('status', options.status);
|
|
65
|
+
const qs = params.toString();
|
|
66
|
+
return this.request('GET', `/execute-batch/${encodeURIComponent(batchCode)}/items${qs ? `?${qs}` : ''}`, undefined, this.executeBaseUrl);
|
|
67
|
+
}
|
|
68
|
+
async pollBatch(batchCode, intervalMs = 2000) {
|
|
69
|
+
const terminalStatuses = new Set(['completed', 'partial', 'failed']);
|
|
70
|
+
let status = await this.getBatchStatus(batchCode);
|
|
71
|
+
while (!terminalStatuses.has(status.status)) {
|
|
72
|
+
await sleep(intervalMs);
|
|
73
|
+
status = await this.getBatchStatus(batchCode);
|
|
74
|
+
}
|
|
75
|
+
return status;
|
|
76
|
+
}
|
|
77
|
+
// ── Executions ──
|
|
78
|
+
async listExecutions(options) {
|
|
79
|
+
const params = new URLSearchParams();
|
|
80
|
+
if (options?.rulesetId)
|
|
81
|
+
params.set('rulesetId', options.rulesetId);
|
|
82
|
+
if (options?.engineMode) {
|
|
83
|
+
const modes = Array.isArray(options.engineMode) ? options.engineMode : [options.engineMode];
|
|
84
|
+
for (const mode of modes)
|
|
85
|
+
params.append('engineMode', mode);
|
|
86
|
+
}
|
|
87
|
+
if (options?.createdFrom)
|
|
88
|
+
params.set('createdFrom', options.createdFrom);
|
|
89
|
+
if (options?.createdUntil)
|
|
90
|
+
params.set('createdUntil', options.createdUntil);
|
|
91
|
+
if (options?.searchText !== undefined)
|
|
92
|
+
params.set('searchText', options.searchText);
|
|
93
|
+
if (options?.limit != null)
|
|
94
|
+
params.set('limit', String(options.limit));
|
|
95
|
+
if (options?.pageCursor)
|
|
96
|
+
params.set('pageCursor', options.pageCursor);
|
|
97
|
+
const qs = params.toString();
|
|
98
|
+
return this.request('GET', `/executions${qs ? `?${qs}` : ''}`);
|
|
99
|
+
}
|
|
100
|
+
async getExecution(executionId) {
|
|
101
|
+
return this.request('GET', `/executions/${encodeURIComponent(executionId)}`);
|
|
102
|
+
}
|
|
103
|
+
async *iterateExecutions(options) {
|
|
104
|
+
let pageCursor = options?.pageCursor;
|
|
105
|
+
for (;;) {
|
|
106
|
+
const page = await this.listExecutions({ ...options, pageCursor });
|
|
107
|
+
for (const execution of page.executions) {
|
|
108
|
+
yield execution;
|
|
109
|
+
}
|
|
110
|
+
if (!page.nextPageCursor)
|
|
111
|
+
return;
|
|
112
|
+
pageCursor = page.nextPageCursor;
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
// ── HTTP ──
|
|
116
|
+
async request(method, path, body, baseUrl = this.baseUrl) {
|
|
117
|
+
const url = `${baseUrl}${path}`;
|
|
118
|
+
let lastError;
|
|
119
|
+
for (let attempt = 0; attempt <= this.maxRetries; attempt++) {
|
|
120
|
+
if (attempt > 0) {
|
|
121
|
+
await sleep(100 * Math.pow(2, attempt - 1));
|
|
122
|
+
}
|
|
123
|
+
let timeoutId;
|
|
124
|
+
try {
|
|
125
|
+
const controller = new AbortController();
|
|
126
|
+
timeoutId = setTimeout(() => controller.abort(), this.timeout);
|
|
127
|
+
const response = await fetch(url, {
|
|
128
|
+
method,
|
|
129
|
+
headers: {
|
|
130
|
+
'Content-Type': 'application/json',
|
|
131
|
+
'Authorization': `Bearer ${this.apiKey}`,
|
|
132
|
+
'X-BOE-SDK': 'typescript',
|
|
133
|
+
'X-BOE-SDK-Version': sdk_package_version_1.BOE_SDK_PACKAGE_VERSION,
|
|
134
|
+
},
|
|
135
|
+
body: body ? JSON.stringify(body) : undefined,
|
|
136
|
+
signal: controller.signal,
|
|
137
|
+
});
|
|
138
|
+
clearTimeout(timeoutId);
|
|
139
|
+
if (response.ok) {
|
|
140
|
+
try {
|
|
141
|
+
return await response.json();
|
|
142
|
+
}
|
|
143
|
+
catch (parseError) {
|
|
144
|
+
// The server answered 2xx, so the call may have taken effect.
|
|
145
|
+
// Retrying would repeat it, and a bad body does not heal.
|
|
146
|
+
throw new errors_1.BOEInvalidResponseError(`Server returned ${response.status} with a body that is not valid JSON: ` +
|
|
147
|
+
`${parseError instanceof Error ? parseError.message : String(parseError)}`, { endpoint: url, status: response.status });
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
const errorBody = await response.json().catch(() => ({}));
|
|
151
|
+
const errorMessage = errorBody.error || response.statusText;
|
|
152
|
+
const code = classifyErrorCode(errorBody);
|
|
153
|
+
if (response.status === 429 || response.status >= 500) {
|
|
154
|
+
// 429 is final on the wire (implementation.md, Retry semantics) and
|
|
155
|
+
// carries its reason in executionRefusalReason.
|
|
156
|
+
if (response.status === 429 && code) {
|
|
157
|
+
throw new errors_1.BOEApiError(errorMessage, { code, status: response.status });
|
|
158
|
+
}
|
|
159
|
+
lastError = code
|
|
160
|
+
? new errors_1.BOEApiError(errorMessage, { code, status: response.status })
|
|
161
|
+
: new errors_1.BOEConnectionError(`Server returned ${response.status}: ${errorMessage}`, { endpoint: url, status: response.status });
|
|
162
|
+
continue;
|
|
163
|
+
}
|
|
164
|
+
if (code === 'production_environment_key_cannot_register') {
|
|
165
|
+
throw new errors_1.BOEProductionKeyCannotRegisterError(errorMessage, { status: response.status });
|
|
166
|
+
}
|
|
167
|
+
if (code === 'ruleset_not_live_in_environment') {
|
|
168
|
+
throw new errors_1.BOERulesetNotLiveInEnvironmentError(errorMessage, { status: response.status });
|
|
169
|
+
}
|
|
170
|
+
if (code) {
|
|
171
|
+
throw new errors_1.BOEApiError(errorMessage, { code, status: response.status });
|
|
172
|
+
}
|
|
173
|
+
if (response.status === 400 && isExecutePath(path)) {
|
|
174
|
+
// Execute 400s come from the dispatcher and engine Lambdas: facts that
|
|
175
|
+
// fail the input schema, a stored schema that will not compile, or a
|
|
176
|
+
// mode guard. None of them is a registration refusal.
|
|
177
|
+
if (Array.isArray(errorBody.validationErrors)) {
|
|
178
|
+
throw new errors_1.BOEFactValidationError(errorMessage, {
|
|
179
|
+
validationErrors: errorBody.validationErrors,
|
|
180
|
+
shortCode: executeShortCode(path),
|
|
181
|
+
statusCode: response.status,
|
|
182
|
+
});
|
|
183
|
+
}
|
|
184
|
+
throw new errors_1.BOEExecutionError(errorMessage, {
|
|
185
|
+
shortCode: executeShortCode(path),
|
|
186
|
+
statusCode: response.status,
|
|
187
|
+
});
|
|
188
|
+
}
|
|
189
|
+
if (response.status === 400) {
|
|
190
|
+
throw new errors_1.BOERegistrationError(errorMessage, {
|
|
191
|
+
rulesetId: errorBody.rulesetId ?? undefined,
|
|
192
|
+
statusCode: response.status,
|
|
193
|
+
});
|
|
194
|
+
}
|
|
195
|
+
if (response.status === 401 || response.status === 403) {
|
|
196
|
+
throw new errors_1.BOEAuthorizationError(errorMessage, {
|
|
197
|
+
statusCode: response.status,
|
|
198
|
+
});
|
|
199
|
+
}
|
|
200
|
+
if (response.status === 404) {
|
|
201
|
+
throw new errors_1.BOENotFoundError(errorMessage, {
|
|
202
|
+
shortCode: errorBody.shortCode ?? undefined,
|
|
203
|
+
});
|
|
204
|
+
}
|
|
205
|
+
if (response.status === 422) {
|
|
206
|
+
throw new errors_1.BOEExecutionError(errorMessage, {
|
|
207
|
+
shortCode: errorBody.shortCode ?? undefined,
|
|
208
|
+
statusCode: response.status,
|
|
209
|
+
});
|
|
210
|
+
}
|
|
211
|
+
throw new errors_1.BOEConnectionError(`Unexpected response ${response.status}: ${errorMessage}`, { endpoint: url, status: response.status });
|
|
212
|
+
}
|
|
213
|
+
catch (error) {
|
|
214
|
+
if (error instanceof errors_1.BOEError && !(error instanceof errors_1.BOEConnectionError) &&
|
|
215
|
+
!(error instanceof errors_1.BOEApiError && (error.status ?? 0) >= 500)) {
|
|
216
|
+
throw error;
|
|
217
|
+
}
|
|
218
|
+
if (error instanceof Error && error.name === 'AbortError') {
|
|
219
|
+
lastError = new errors_1.BOEConnectionError(`Request timed out after ${this.timeout}ms`, { endpoint: url });
|
|
220
|
+
continue;
|
|
221
|
+
}
|
|
222
|
+
if (error instanceof errors_1.BOEConnectionError || error instanceof errors_1.BOEApiError) {
|
|
223
|
+
lastError = error;
|
|
224
|
+
continue;
|
|
225
|
+
}
|
|
226
|
+
lastError = new errors_1.BOEConnectionError(`Network error: ${error instanceof Error ? error.message : String(error)}`, { endpoint: url });
|
|
227
|
+
continue;
|
|
228
|
+
}
|
|
229
|
+
finally {
|
|
230
|
+
// A rejected fetch skips the clearTimeout above; the timer would
|
|
231
|
+
// otherwise keep the process alive for the full timeout.
|
|
232
|
+
clearTimeout(timeoutId);
|
|
233
|
+
}
|
|
234
|
+
}
|
|
235
|
+
throw lastError ?? new errors_1.BOEConnectionError('Request failed after retries', { endpoint: url });
|
|
236
|
+
}
|
|
237
|
+
}
|
|
238
|
+
exports.BOEClient = BOEClient;
|
|
239
|
+
/**
|
|
240
|
+
* The code a refusal carries: the `code` member, then an `error` value that is
|
|
241
|
+
* itself a known code, then the 429 `executionRefusalReason`.
|
|
242
|
+
*/
|
|
243
|
+
function classifyErrorCode(errorBody) {
|
|
244
|
+
if (typeof errorBody.code === 'string' && errorBody.code)
|
|
245
|
+
return errorBody.code;
|
|
246
|
+
if (typeof errorBody.error === 'string' && ERROR_VALUES_THAT_ARE_CODES.has(errorBody.error)) {
|
|
247
|
+
return errorBody.error;
|
|
248
|
+
}
|
|
249
|
+
if (typeof errorBody.executionRefusalReason === 'string' && errorBody.executionRefusalReason) {
|
|
250
|
+
return errorBody.executionRefusalReason;
|
|
251
|
+
}
|
|
252
|
+
return undefined;
|
|
253
|
+
}
|
|
254
|
+
function isExecutePath(path) {
|
|
255
|
+
return path.startsWith('/execute/') || path.startsWith('/execute-batch/');
|
|
256
|
+
}
|
|
257
|
+
function executeShortCode(path) {
|
|
258
|
+
const segment = path.split('?')[0].split('/')[2];
|
|
259
|
+
return segment ? decodeURIComponent(segment) : undefined;
|
|
260
|
+
}
|
|
261
|
+
function sleep(ms) {
|
|
262
|
+
return new Promise(resolve => setTimeout(resolve, ms));
|
|
263
|
+
}
|
|
264
|
+
//# sourceMappingURL=client.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"client.js","sourceRoot":"","sources":["../src/client.ts"],"names":[],"mappings":";;;AAcA,qCAckB;AAElB,+DAAgE;AAEhE,MAAM,gBAAgB,GAAG,6BAA6B,CAAC;AAEvD,+EAA+E;AAC/E,kDAAkD;AAClD,MAAM,2BAA2B,GAAG,IAAI,GAAG,CAAC,CAAC,kBAAkB,CAAC,CAAC,CAAC;AAElE,SAAS,iBAAiB,CAAC,GAAW;I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CACF;AA/SD,8BA+SC;AAED;;;GAGG;AACH,SAAS,iBAAiB,CAAC,SAAkC;IAC3D,IAAI,OAAO,SAAS,CAAC,IAAI,KAAK,QAAQ,IAAI,SAAS,CAAC,IAAI;QAAE,OAAO,SAAS,CAAC,IAAI,CAAC;IAChF,IAAI,OAAO,SAAS,CAAC,KAAK,KAAK,QAAQ,IAAI,2BAA2B,CAAC,GAAG,CAAC,SAAS,CAAC,KAAK,CAAC,EAAE,CAAC;QAC5F,OAAO,SAAS,CAAC,KAAK,CAAC;IACzB,CAAC;IACD,IAAI,OAAO,SAAS,CAAC,sBAAsB,KAAK,QAAQ,IAAI,SAAS,CAAC,sBAAsB,EAAE,CAAC;QAC7F,OAAO,SAAS,CAAC,sBAAsB,CAAC;IAC1C,CAAC;IACD,OAAO,SAAS,CAAC;AACnB,CAAC;AAED,SAAS,aAAa,CAAC,IAAY;IACjC,OAAO,IAAI,CAAC,UAAU,CAAC,WAAW,CAAC,IAAI,IAAI,CAAC,UAAU,CAAC,iBAAiB,CAAC,CAAC;AAC5E,CAAC;AAED,SAAS,gBAAgB,CAAC,IAAY;IACpC,MAAM,OAAO,GAAG,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC;IACjD,OAAO,OAAO,CAAC,CAAC,CAAC,kBAAkB,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC;AAC3D,CAAC;AAED,SAAS,KAAK,CAAC,EAAU;IACvB,OAAO,IAAI,OAAO,CAAC,OAAO,CAAC,EAAE,CAAC,UAAU,CAAC,OAAO,EAAE,EAAE,CAAC,CAAC,CAAC;AACzD,CAAC"}
|
package/dist/errors.d.ts
ADDED
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
export declare class BOEError extends Error {
|
|
2
|
+
readonly code?: string;
|
|
3
|
+
readonly status?: number;
|
|
4
|
+
constructor(message: string, options?: {
|
|
5
|
+
code?: string;
|
|
6
|
+
status?: number;
|
|
7
|
+
});
|
|
8
|
+
}
|
|
9
|
+
/** Thrown at construction when no API key is passed and BOE_API_KEY is unset. */
|
|
10
|
+
export declare class BOEConfigurationError extends BOEError {
|
|
11
|
+
constructor(message: string);
|
|
12
|
+
}
|
|
13
|
+
/** A non 2xx response whose body carries a machine readable code. */
|
|
14
|
+
export declare class BOEApiError extends BOEError {
|
|
15
|
+
readonly serverMessage: string;
|
|
16
|
+
constructor(message: string, options: {
|
|
17
|
+
code?: string;
|
|
18
|
+
status: number;
|
|
19
|
+
});
|
|
20
|
+
}
|
|
21
|
+
export declare class BOEProductionKeyCannotRegisterError extends BOEApiError {
|
|
22
|
+
constructor(message: string, options: {
|
|
23
|
+
status: number;
|
|
24
|
+
});
|
|
25
|
+
}
|
|
26
|
+
export declare class BOERulesetNotLiveInEnvironmentError extends BOEApiError {
|
|
27
|
+
constructor(message: string, options: {
|
|
28
|
+
status: number;
|
|
29
|
+
});
|
|
30
|
+
}
|
|
31
|
+
export declare class BOERegistrationError extends BOEError {
|
|
32
|
+
readonly rulesetId?: string;
|
|
33
|
+
readonly statusCode?: number;
|
|
34
|
+
constructor(message: string, options?: {
|
|
35
|
+
rulesetId?: string;
|
|
36
|
+
statusCode?: number;
|
|
37
|
+
code?: string;
|
|
38
|
+
});
|
|
39
|
+
}
|
|
40
|
+
export declare class BOEExecutionError extends BOEError {
|
|
41
|
+
readonly shortCode?: string;
|
|
42
|
+
readonly statusCode?: number;
|
|
43
|
+
constructor(message: string, options?: {
|
|
44
|
+
shortCode?: string;
|
|
45
|
+
statusCode?: number;
|
|
46
|
+
code?: string;
|
|
47
|
+
});
|
|
48
|
+
}
|
|
49
|
+
/** One failing fact, in the shape the engine Lambda's validator emits (AJV style). */
|
|
50
|
+
export type FactValidationIssue = {
|
|
51
|
+
instancePath: string;
|
|
52
|
+
schemaPath: string;
|
|
53
|
+
keyword: string;
|
|
54
|
+
message: string;
|
|
55
|
+
};
|
|
56
|
+
/**
|
|
57
|
+
* Execute 400 `{ error, validationErrors }`: the facts do not match the
|
|
58
|
+
* version's input schema. Fix the facts named in `validationErrors`.
|
|
59
|
+
*/
|
|
60
|
+
export declare class BOEFactValidationError extends BOEExecutionError {
|
|
61
|
+
readonly validationErrors: FactValidationIssue[];
|
|
62
|
+
constructor(message: string, options: {
|
|
63
|
+
validationErrors: FactValidationIssue[];
|
|
64
|
+
shortCode?: string;
|
|
65
|
+
statusCode?: number;
|
|
66
|
+
});
|
|
67
|
+
}
|
|
68
|
+
export declare class BOEConnectionError extends BOEError {
|
|
69
|
+
readonly endpoint?: string;
|
|
70
|
+
constructor(message: string, options?: {
|
|
71
|
+
endpoint?: string;
|
|
72
|
+
status?: number;
|
|
73
|
+
});
|
|
74
|
+
}
|
|
75
|
+
export declare class BOENotFoundError extends BOEError {
|
|
76
|
+
readonly shortCode?: string;
|
|
77
|
+
constructor(message: string, options?: {
|
|
78
|
+
shortCode?: string;
|
|
79
|
+
code?: string;
|
|
80
|
+
});
|
|
81
|
+
}
|
|
82
|
+
export declare class BOEAuthorizationError extends BOEError {
|
|
83
|
+
readonly statusCode?: number;
|
|
84
|
+
constructor(message: string, options?: {
|
|
85
|
+
statusCode?: number;
|
|
86
|
+
code?: string;
|
|
87
|
+
});
|
|
88
|
+
}
|
|
89
|
+
/**
|
|
90
|
+
* A 2xx response whose body is not valid JSON. The server answered, so the
|
|
91
|
+
* request is not retried; the status and endpoint say which call to inspect.
|
|
92
|
+
*/
|
|
93
|
+
export declare class BOEInvalidResponseError extends BOEError {
|
|
94
|
+
readonly endpoint?: string;
|
|
95
|
+
constructor(message: string, options?: {
|
|
96
|
+
endpoint?: string;
|
|
97
|
+
status?: number;
|
|
98
|
+
});
|
|
99
|
+
}
|
|
100
|
+
//# sourceMappingURL=errors.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../src/errors.ts"],"names":[],"mappings":"AAAA,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AE,MAAM,CAAC;QAAC,IAAI,CAAC,EAAE,MAAM,CAAA;KAAE;CAK9E;AAED;;;GAGG;AACH,qBAAa,uBAAwB,SAAQ,QAAQ;IACnD,QAAQ,CAAC,QAAQ,CAAC,EAAE,MAAM,CAAC;gBAEf,OAAO,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE;QAAE,QAAQ,CAAC,EAAE,MAAM,CAAC;QAAC,MAAM,CAAC,EAAE,MAAM,CAAA;KAAE;CAK9E"}
|
package/dist/errors.js
ADDED
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.BOEInvalidResponseError = exports.BOEAuthorizationError = exports.BOENotFoundError = exports.BOEConnectionError = exports.BOEFactValidationError = exports.BOEExecutionError = exports.BOERegistrationError = exports.BOERulesetNotLiveInEnvironmentError = exports.BOEProductionKeyCannotRegisterError = exports.BOEApiError = exports.BOEConfigurationError = exports.BOEError = void 0;
|
|
4
|
+
class BOEError extends Error {
|
|
5
|
+
code;
|
|
6
|
+
status;
|
|
7
|
+
constructor(message, options) {
|
|
8
|
+
super(message);
|
|
9
|
+
this.name = 'BOEError';
|
|
10
|
+
this.code = options?.code;
|
|
11
|
+
this.status = options?.status;
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
exports.BOEError = BOEError;
|
|
15
|
+
/** Thrown at construction when no API key is passed and BOE_API_KEY is unset. */
|
|
16
|
+
class BOEConfigurationError extends BOEError {
|
|
17
|
+
constructor(message) {
|
|
18
|
+
super(message);
|
|
19
|
+
this.name = 'BOEConfigurationError';
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
exports.BOEConfigurationError = BOEConfigurationError;
|
|
23
|
+
/** A non 2xx response whose body carries a machine readable code. */
|
|
24
|
+
class BOEApiError extends BOEError {
|
|
25
|
+
serverMessage;
|
|
26
|
+
constructor(message, options) {
|
|
27
|
+
super(message, options);
|
|
28
|
+
this.name = 'BOEApiError';
|
|
29
|
+
this.serverMessage = message;
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
exports.BOEApiError = BOEApiError;
|
|
33
|
+
class BOEProductionKeyCannotRegisterError extends BOEApiError {
|
|
34
|
+
constructor(message, options) {
|
|
35
|
+
super(message, { code: 'production_environment_key_cannot_register', status: options.status });
|
|
36
|
+
this.name = 'BOEProductionKeyCannotRegisterError';
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
exports.BOEProductionKeyCannotRegisterError = BOEProductionKeyCannotRegisterError;
|
|
40
|
+
class BOERulesetNotLiveInEnvironmentError extends BOEApiError {
|
|
41
|
+
constructor(message, options) {
|
|
42
|
+
super(message, { code: 'ruleset_not_live_in_environment', status: options.status });
|
|
43
|
+
this.name = 'BOERulesetNotLiveInEnvironmentError';
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
exports.BOERulesetNotLiveInEnvironmentError = BOERulesetNotLiveInEnvironmentError;
|
|
47
|
+
class BOERegistrationError extends BOEError {
|
|
48
|
+
rulesetId;
|
|
49
|
+
statusCode;
|
|
50
|
+
constructor(message, options) {
|
|
51
|
+
super(message, { code: options?.code, status: options?.statusCode });
|
|
52
|
+
this.name = 'BOERegistrationError';
|
|
53
|
+
this.rulesetId = options?.rulesetId;
|
|
54
|
+
this.statusCode = options?.statusCode;
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
exports.BOERegistrationError = BOERegistrationError;
|
|
58
|
+
class BOEExecutionError extends BOEError {
|
|
59
|
+
shortCode;
|
|
60
|
+
statusCode;
|
|
61
|
+
constructor(message, options) {
|
|
62
|
+
super(message, { code: options?.code, status: options?.statusCode });
|
|
63
|
+
this.name = 'BOEExecutionError';
|
|
64
|
+
this.shortCode = options?.shortCode;
|
|
65
|
+
this.statusCode = options?.statusCode;
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
exports.BOEExecutionError = BOEExecutionError;
|
|
69
|
+
/**
|
|
70
|
+
* Execute 400 `{ error, validationErrors }`: the facts do not match the
|
|
71
|
+
* version's input schema. Fix the facts named in `validationErrors`.
|
|
72
|
+
*/
|
|
73
|
+
class BOEFactValidationError extends BOEExecutionError {
|
|
74
|
+
validationErrors;
|
|
75
|
+
constructor(message, options) {
|
|
76
|
+
super(message, { shortCode: options.shortCode, statusCode: options.statusCode ?? 400 });
|
|
77
|
+
this.name = 'BOEFactValidationError';
|
|
78
|
+
this.validationErrors = options.validationErrors;
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
exports.BOEFactValidationError = BOEFactValidationError;
|
|
82
|
+
class BOEConnectionError extends BOEError {
|
|
83
|
+
endpoint;
|
|
84
|
+
constructor(message, options) {
|
|
85
|
+
super(message, { status: options?.status });
|
|
86
|
+
this.name = 'BOEConnectionError';
|
|
87
|
+
this.endpoint = options?.endpoint;
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
exports.BOEConnectionError = BOEConnectionError;
|
|
91
|
+
class BOENotFoundError extends BOEError {
|
|
92
|
+
shortCode;
|
|
93
|
+
constructor(message, options) {
|
|
94
|
+
super(message, { code: options?.code, status: 404 });
|
|
95
|
+
this.name = 'BOENotFoundError';
|
|
96
|
+
this.shortCode = options?.shortCode;
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
exports.BOENotFoundError = BOENotFoundError;
|
|
100
|
+
class BOEAuthorizationError extends BOEError {
|
|
101
|
+
statusCode;
|
|
102
|
+
constructor(message, options) {
|
|
103
|
+
super(message, { code: options?.code, status: options?.statusCode });
|
|
104
|
+
this.name = 'BOEAuthorizationError';
|
|
105
|
+
this.statusCode = options?.statusCode;
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
exports.BOEAuthorizationError = BOEAuthorizationError;
|
|
109
|
+
/**
|
|
110
|
+
* A 2xx response whose body is not valid JSON. The server answered, so the
|
|
111
|
+
* request is not retried; the status and endpoint say which call to inspect.
|
|
112
|
+
*/
|
|
113
|
+
class BOEInvalidResponseError extends BOEError {
|
|
114
|
+
endpoint;
|
|
115
|
+
constructor(message, options) {
|
|
116
|
+
super(message, { status: options?.status });
|
|
117
|
+
this.name = 'BOEInvalidResponseError';
|
|
118
|
+
this.endpoint = options?.endpoint;
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
exports.BOEInvalidResponseError = BOEInvalidResponseError;
|
|
122
|
+
//# sourceMappingURL=errors.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"errors.js","sourceRoot":"","sources":["../src/errors.ts"],"names":[],"mappings":";;;AAAA,MAAa,QAAS,SAAQ,KAAK;IACxB,IAAI,CAAU;IACd,MAAM,CAAU;IAEzB,YAAY,OAAe,EAAE,OAA4C;QACvE,KAAK,CAAC,OAAO,CAAC,CAAC;QACf,IAAI,CAAC,IAAI,GAAG,UAAU,CAAC;QACvB,IAAI,CAAC,IAAI,GAAG,OAAO,EAAE,IAAI,CAAC;QAC1B,IAAI,CAAC,MAAM,GAAG,OAAO,EAAE,MAAM,CAAC;IAChC,CAAC;CACF;AAVD,4BAUC;AAED,iFAAiF;AACjF,MAAa,qBAAsB,SAAQ,QAAQ;IACjD,YAAY,OAAe;QACzB,KAAK,CAAC,OAAO,CAAC,CAAC;QACf,IAAI,CAAC,IAAI,GAAG,uBAAuB,CAAC;IACtC,CAAC;CACF;AALD,sDAKC;AAED,qEAAqE;AACrE,MAAa,WAAY,SAAQ,QAAQ;IAC9B,aAAa,CAAS;IAE/B,YAAY,OAAe,EAAE,OAA0C;QACrE,KAAK,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC;QACxB,IAAI,CAAC,IAAI,GAAG,aAAa,CAAC;QAC1B,IAAI,CAAC,aAAa,GAAG,OAAO,CAAC;IAC/B,CAAC;CACF;AARD,kCAQC;AAED,MAAa,mCAAoC,SAAQ,WAAW;IAClE,YAAY,OAAe,EAAE,OAA2B;QACtD,KAAK,CAAC,OAAO,EAAE,EAAE,IAAI,EAAE,4CAA4C,EAAE,MAA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,UAAU,CAAC;IACxC,CAAC;CACF;AARD,sDAQC;AAED;;;GAGG;AACH,MAAa,uBAAwB,SAAQ,QAAQ;IAC1C,QAAQ,CAAU;IAE3B,YAAY,OAAe,EAAE,OAAgD;QAC3E,KAAK,CAAC,OAAO,EAAE,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,CAAC,CAAC;QAC5C,IAAI,CAAC,IAAI,GAAG,yBAAyB,CAAC;QACtC,IAAI,CAAC,QAAQ,GAAG,OAAO,EAAE,QAAQ,CAAC;IACpC,CAAC;CACF;AARD,0DAQC"}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import type { BOEConfig, RegisterResult, ExecuteResult, ExecuteOptions, BatchSubmitResult, BatchStatusResult, BatchItemsResult, BatchItemsOptions, ExecutionLogEntry, ListExecutionsOptions, ListExecutionsResult } from './types';
|
|
2
|
+
export type { BOEConfig, RegisterResult, ExecuteResult, ExecuteOptions, BatchSubmitResult, BatchStatusResult, BatchItemsResult, BatchItemsOptions, ExecutionLogEntry, ScoringOutputBounds, ListExecutionsOptions, ListExecutionsResult, } from './types';
|
|
3
|
+
export type { FactValidationIssue } from './errors';
|
|
4
|
+
export { BOEError, BOEConfigurationError, BOEApiError, BOEProductionKeyCannotRegisterError, BOERulesetNotLiveInEnvironmentError, BOERegistrationError, BOEExecutionError, BOEFactValidationError, BOEConnectionError, BOEInvalidResponseError, BOENotFoundError, BOEAuthorizationError, } from './errors';
|
|
5
|
+
export { BOEClient } from './client';
|
|
6
|
+
export type BOE = {
|
|
7
|
+
register<T extends Record<string, unknown>>(ruleset: T): Promise<RegisterResult>;
|
|
8
|
+
execute<T = unknown>(shortCode: string, facts: Record<string, unknown>, options?: ExecuteOptions): Promise<ExecuteResult<T>>;
|
|
9
|
+
submitBatch(shortCode: string, items: Array<{
|
|
10
|
+
facts: Record<string, unknown>;
|
|
11
|
+
}>, options?: Record<string, unknown>): Promise<BatchSubmitResult>;
|
|
12
|
+
getBatchStatus(batchCode: string): Promise<BatchStatusResult>;
|
|
13
|
+
getBatchItems(batchCode: string, options?: BatchItemsOptions): Promise<BatchItemsResult>;
|
|
14
|
+
pollBatch(batchCode: string, intervalMs?: number): Promise<BatchStatusResult>;
|
|
15
|
+
listExecutions(options?: ListExecutionsOptions): Promise<ListExecutionsResult>;
|
|
16
|
+
getExecution(executionId: string): Promise<ExecutionLogEntry>;
|
|
17
|
+
};
|
|
18
|
+
export declare function createBOE(config?: BOEConfig): BOE;
|
|
19
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EACV,SAAS,EACT,cAAc,EACd,aAAa,EACb,cAAc,EACd,iBAAiB,EACjB,iBAAiB,EACjB,gBAAgB,EAChB,iBAAiB,EACjB,iBAAiB,EACjB,qBAAqB,EACrB,oBAAoB,EACrB,MAAM,SAAS,CAAC;AAEjB,YAAY,EACV,SAAS,EACT,cAAc,EACd,aAAa,EACb,cAAc,EACd,iBAAiB,EACjB,iBAAiB,EACjB,gBAAgB,EAChB,iBAAiB,EACjB,iBAAiB,EACjB,mBAAmB,EACnB,qBAAqB,EACrB,oBAAoB,GACrB,MAAM,SAAS,CAAC;AAEjB,YAAY,EAAE,mBAAmB,EAAE,MAAM,UAAU,CAAC;AAEpD,OAAO,EACL,QAAQ,EACR,qBAAqB,EACrB,WAAW,EACX,mCAAmC,EACnC,mCAAmC,EACnC,oBAAoB,EACpB,iBAAiB,EACjB,sBAAsB,EACtB,kBAAkB,EAClB,uBAAuB,EACvB,gBAAgB,EAChB,qBAAqB,GACtB,MAAM,UAAU,CAAC;AAElB,OAAO,EAAE,SAAS,EAAE,MAAM,UAAU,CAAC;AAIrC,MAAM,MAAM,GAAG,GAAG;IAChB,QAAQ,CAAC,CAAC,SAAS,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAAE,OAAO,EAAE,CAAC,GAAG,OAAO,CAAC,cAAc,CAAC,CAAC;IACjF,OAAO,CAAC,CAAC,GAAG,OAAO,EACjB,SAAS,EAAE,MAAM,EACjB,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAC9B,OAAO,CAAC,EAAE,cAAc,GACvB,OAAO,CAAC,aAAa,CAAC,CAAC,CAAC,CAAC,CAAC;IAC7B,WAAW,CACT,SAAS,EAAE,MAAM,EACjB,KAAK,EAAE,KAAK,CAAC;QAAE,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;KAAE,CAAC,EAChD,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAChC,OAAO,CAAC,iBAAiB,CAAC,CAAC;IAC9B,cAAc,CAAC,SAAS,EAAE,MAAM,GAAG,OAAO,CAAC,iBAAiB,CAAC,CAAC;IAC9D,aAAa,CAAC,SAAS,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,iBAAiB,GAAG,OAAO,CAAC,gBAAgB,CAAC,CAAC;IACzF,SAAS,CAAC,SAAS,EAAE,MAAM,EAAE,UAAU,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,iBAAiB,CAAC,CAAC;IAC9E,cAAc,CAAC,OAAO,CAAC,EAAE,qBAAqB,GAAG,OAAO,CAAC,oBAAoB,CAAC,CAAC;IAC/E,YAAY,CAAC,WAAW,EAAE,MAAM,GAAG,OAAO,CAAC,iBAAiB,CAAC,CAAC;CAC/D,CAAC;AAEF,wBAAgB,SAAS,CAAC,MAAM,GAAE,SAAc,GAAG,GAAG,CAarD"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.BOEClient = exports.BOEAuthorizationError = exports.BOENotFoundError = exports.BOEInvalidResponseError = exports.BOEConnectionError = exports.BOEFactValidationError = exports.BOEExecutionError = exports.BOERegistrationError = exports.BOERulesetNotLiveInEnvironmentError = exports.BOEProductionKeyCannotRegisterError = exports.BOEApiError = exports.BOEConfigurationError = exports.BOEError = void 0;
|
|
4
|
+
exports.createBOE = createBOE;
|
|
5
|
+
const client_1 = require("./client");
|
|
6
|
+
var errors_1 = require("./errors");
|
|
7
|
+
Object.defineProperty(exports, "BOEError", { enumerable: true, get: function () { return errors_1.BOEError; } });
|
|
8
|
+
Object.defineProperty(exports, "BOEConfigurationError", { enumerable: true, get: function () { return errors_1.BOEConfigurationError; } });
|
|
9
|
+
Object.defineProperty(exports, "BOEApiError", { enumerable: true, get: function () { return errors_1.BOEApiError; } });
|
|
10
|
+
Object.defineProperty(exports, "BOEProductionKeyCannotRegisterError", { enumerable: true, get: function () { return errors_1.BOEProductionKeyCannotRegisterError; } });
|
|
11
|
+
Object.defineProperty(exports, "BOERulesetNotLiveInEnvironmentError", { enumerable: true, get: function () { return errors_1.BOERulesetNotLiveInEnvironmentError; } });
|
|
12
|
+
Object.defineProperty(exports, "BOERegistrationError", { enumerable: true, get: function () { return errors_1.BOERegistrationError; } });
|
|
13
|
+
Object.defineProperty(exports, "BOEExecutionError", { enumerable: true, get: function () { return errors_1.BOEExecutionError; } });
|
|
14
|
+
Object.defineProperty(exports, "BOEFactValidationError", { enumerable: true, get: function () { return errors_1.BOEFactValidationError; } });
|
|
15
|
+
Object.defineProperty(exports, "BOEConnectionError", { enumerable: true, get: function () { return errors_1.BOEConnectionError; } });
|
|
16
|
+
Object.defineProperty(exports, "BOEInvalidResponseError", { enumerable: true, get: function () { return errors_1.BOEInvalidResponseError; } });
|
|
17
|
+
Object.defineProperty(exports, "BOENotFoundError", { enumerable: true, get: function () { return errors_1.BOENotFoundError; } });
|
|
18
|
+
Object.defineProperty(exports, "BOEAuthorizationError", { enumerable: true, get: function () { return errors_1.BOEAuthorizationError; } });
|
|
19
|
+
var client_2 = require("./client");
|
|
20
|
+
Object.defineProperty(exports, "BOEClient", { enumerable: true, get: function () { return client_2.BOEClient; } });
|
|
21
|
+
function createBOE(config = {}) {
|
|
22
|
+
const client = new client_1.BOEClient(config);
|
|
23
|
+
return {
|
|
24
|
+
register: (ruleset) => client.register(ruleset),
|
|
25
|
+
execute: (shortCode, facts, options) => client.execute(shortCode, facts, options),
|
|
26
|
+
submitBatch: (shortCode, items, options) => client.submitBatch(shortCode, items, options),
|
|
27
|
+
getBatchStatus: (batchCode) => client.getBatchStatus(batchCode),
|
|
28
|
+
getBatchItems: (batchCode, options) => client.getBatchItems(batchCode, options),
|
|
29
|
+
pollBatch: (batchCode, intervalMs) => client.pollBatch(batchCode, intervalMs),
|
|
30
|
+
listExecutions: (options) => client.listExecutions(options),
|
|
31
|
+
getExecution: (executionId) => client.getExecution(executionId),
|
|
32
|
+
};
|
|
33
|
+
}
|
|
34
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;AAsEA,8BAaC;AAnFD,qCAAqC;AAgCrC,mCAakB;AAZhB,kGAAA,QAAQ,OAAA;AACR,+GAAA,qBAAqB,OAAA;AACrB,qGAAA,WAAW,OAAA;AACX,6HAAA,mCAAmC,OAAA;AACnC,6HAAA,mCAAmC,OAAA;AACnC,8GAAA,oBAAoB,OAAA;AACpB,2GAAA,iBAAiB,OAAA;AACjB,gHAAA,sBAAsB,OAAA;AACtB,4GAAA,kBAAkB,OAAA;AAClB,iHAAA,uBAAuB,OAAA;AACvB,0GAAA,gBAAgB,OAAA;AAChB,+GAAA,qBAAqB,OAAA;AAGvB,mCAAqC;AAA5B,mGAAA,SAAS,OAAA;AAuBlB,SAAgB,SAAS,CAAC,SAAoB,EAAE;IAC9C,MAAM,MAAM,GAAG,IAAI,kBAAS,CAAC,MAAM,CAAC,CAAC;IAErC,OAAO;QACL,QAAQ,EAAE,CAAC,OAAO,EAAE,EAAE,CAAC,MAAM,CAAC,QAAQ,CAAC,OAAO,CAAC;QAC/C,OAAO,EAAE,CAAC,SAAS,EAAE,KAAK,EAAE,OAAO,EAAE,EAAE,CAAC,MAAM,CAAC,OAAO,CAAC,SAAS,EAAE,KAAK,EAAE,OAAO,CAAC;QACjF,WAAW,EAAE,CAAC,SAAS,EAAE,KAAK,EAAE,OAAO,EAAE,EAAE,CAAC,MAAM,CAAC,WAAW,CAAC,SAAS,EAAE,KAAK,EAAE,OAAO,CAAC;QACzF,cAAc,EAAE,CAAC,SAAS,EAAE,EAAE,CAAC,MAAM,CAAC,cAAc,CAAC,SAAS,CAAC;QAC/D,aAAa,EAAE,CAAC,SAAS,EAAE,OAAO,EAAE,EAAE,CAAC,MAAM,CAAC,aAAa,CAAC,SAAS,EAAE,OAAO,CAAC;QAC/E,SAAS,EAAE,CAAC,SAAS,EAAE,UAAU,EAAE,EAAE,CAAC,MAAM,CAAC,SAAS,CAAC,SAAS,EAAE,UAAU,CAAC;QAC7E,cAAc,EAAE,CAAC,OAAO,EAAE,EAAE,CAAC,MAAM,CAAC,cAAc,CAAC,OAAO,CAAC;QAC3D,YAAY,EAAE,CAAC,WAAW,EAAE,EAAE,CAAC,MAAM,CAAC,YAAY,CAAC,WAAW,CAAC;KAChE,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sdk-package-version.d.ts","sourceRoot":"","sources":["../src/sdk-package-version.ts"],"names":[],"mappings":"AAMA,eAAO,MAAM,uBAAuB,EAAE,MAA+B,CAAC"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.BOE_SDK_PACKAGE_VERSION = void 0;
|
|
4
|
+
// The version this client reports in X-BOE-SDK-Version, read from the
|
|
5
|
+
// package.json that ships beside dist/, so the header and the published
|
|
6
|
+
// package cannot disagree (#1115). implementation.md names this rule.
|
|
7
|
+
// eslint-disable-next-line @typescript-eslint/no-require-imports
|
|
8
|
+
const sdkPackageJson = require('../package.json');
|
|
9
|
+
exports.BOE_SDK_PACKAGE_VERSION = sdkPackageJson.version;
|
|
10
|
+
//# sourceMappingURL=sdk-package-version.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sdk-package-version.js","sourceRoot":"","sources":["../src/sdk-package-version.ts"],"names":[],"mappings":";;;AAAA,sEAAsE;AACtE,wEAAwE;AACxE,sEAAsE;AACtE,iEAAiE;AACjE,MAAM,cAAc,GAAG,OAAO,CAAC,iBAAiB,CAAwB,CAAC;AAE5D,QAAA,uBAAuB,GAAW,cAAc,CAAC,OAAO,CAAC"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
export type BOEConfig = {
|
|
2
|
+
/** API key. Defaults to the BOE_API_KEY environment variable. */
|
|
3
|
+
apiKey?: string;
|
|
4
|
+
/** Control plane base URL. Defaults to BOE_BASE_URL, then https://api.boerules.com/v1. */
|
|
5
|
+
baseUrl?: string;
|
|
6
|
+
/** Base URL for execute and batch calls. Defaults to baseUrl. */
|
|
7
|
+
executeBaseUrl?: string;
|
|
8
|
+
timeout?: number;
|
|
9
|
+
maxRetries?: number;
|
|
10
|
+
};
|
|
11
|
+
//# sourceMappingURL=config.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../../src/types/config.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,SAAS,GAAG;IACtB,iEAAiE;IACjE,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,0FAA0F;IAC1F,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,iEAAiE;IACjE,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,UAAU,CAAC,EAAE,MAAM,CAAC;CACrB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"config.js","sourceRoot":"","sources":["../../src/types/config.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The 40 routable engine modes, mirroring VALID_MODES in
|
|
3
|
+
* packages/sdk/server/lambda/shared/types.ts. Copied rather than imported:
|
|
4
|
+
* this package does not depend on packages/sdk/server, whose types carry AWS
|
|
5
|
+
* Lambda types this client has no business pulling in.
|
|
6
|
+
*/
|
|
7
|
+
export type EngineMode = 'allocation' | 'anomaly' | 'audit' | 'authorship' | 'backward' | 'bayesian' | 'classify' | 'constraint' | 'decay' | 'defeasible' | 'eligibility' | 'ensemble' | 'expert' | 'flow' | 'forward' | 'fuzzy' | 'leadtime' | 'loyalty' | 'matching' | 'menu-engineering' | 'monte-carlo' | 'negotiation' | 'pipeline' | 'policy' | 'prediction' | 'pricing' | 'q-evaluate' | 'queue' | 'ranking' | 'recipe-costing' | 'recommendation' | 'relay' | 'risk' | 'scoring' | 'sentiment' | 'sequential' | 'state-machine' | 'takt' | 'time-series' | 'utility';
|
|
8
|
+
/** The inclusive range a scoring ruleset clamps totalScore to. */
|
|
9
|
+
export type ScoringOutputBounds = {
|
|
10
|
+
min: number;
|
|
11
|
+
max: number;
|
|
12
|
+
};
|
|
13
|
+
export type ExecutionLogEntry = {
|
|
14
|
+
executionId: string;
|
|
15
|
+
createdAt: string;
|
|
16
|
+
rulesetId: string;
|
|
17
|
+
rulesetShortCode: string | null;
|
|
18
|
+
rulesetName: string | null;
|
|
19
|
+
rulesetVersionId: string | null;
|
|
20
|
+
/** boe.ruleset_versions.version, e.g. `"1.0.0"`. Null when the version row is gone. */
|
|
21
|
+
rulesetVersion: string | null;
|
|
22
|
+
engineMode: string;
|
|
23
|
+
apiKeyId: string | null;
|
|
24
|
+
totalDispatchDurationMs: number;
|
|
25
|
+
executionSucceeded: boolean;
|
|
26
|
+
executionFailureReason: string | null;
|
|
27
|
+
executionResultFragment: Record<string, unknown> | null;
|
|
28
|
+
/**
|
|
29
|
+
* The scale of `totalScore`: the range the scoring engine clamped it to,
|
|
30
|
+
* from the executed ruleset version's `config.outputBounds`, with presets
|
|
31
|
+
* such as `'percentage'` already resolved to `{ min: 0, max: 100 }`.
|
|
32
|
+
* Derived by the API at read time, never stored. Null for any mode other
|
|
33
|
+
* than `'scoring'`, for a ruleset that declares no bounds, and when the
|
|
34
|
+
* version row is gone.
|
|
35
|
+
*/
|
|
36
|
+
scoringOutputBounds: ScoringOutputBounds | null;
|
|
37
|
+
lineageRequested: boolean;
|
|
38
|
+
lineageAvailable: boolean;
|
|
39
|
+
executionResultRequested: boolean;
|
|
40
|
+
executionResultAvailable: boolean;
|
|
41
|
+
};
|
|
42
|
+
export type ListExecutionsOptions = {
|
|
43
|
+
rulesetId?: string;
|
|
44
|
+
/**
|
|
45
|
+
* One mode or several. Several serialize as repeated `engineMode` query
|
|
46
|
+
* parameters (`?engineMode=scoring&engineMode=pricing`), matched with OR
|
|
47
|
+
* semantics by the API. A single mode behaves exactly as before.
|
|
48
|
+
*/
|
|
49
|
+
engineMode?: EngineMode | EngineMode[];
|
|
50
|
+
/** ISO 8601 instant, inclusive. */
|
|
51
|
+
createdFrom?: string;
|
|
52
|
+
/** ISO 8601 instant, exclusive. */
|
|
53
|
+
createdUntil?: string;
|
|
54
|
+
/**
|
|
55
|
+
* Free text, 1 to 100 characters once the API trims it. Matches an
|
|
56
|
+
* execution id (in full, or a prefix of 8 or more hex digits), a ruleset
|
|
57
|
+
* id in full, a ruleset short code, or text inside the ruleset name. The
|
|
58
|
+
* last two ignore case. ANDed with every other option. Sent whenever it is
|
|
59
|
+
* set, including `''`, so the API, not the client, decides what is valid.
|
|
60
|
+
*/
|
|
61
|
+
searchText?: string;
|
|
62
|
+
limit?: number;
|
|
63
|
+
pageCursor?: string;
|
|
64
|
+
};
|
|
65
|
+
export type ListExecutionsResult = {
|
|
66
|
+
executions: ExecutionLogEntry[];
|
|
67
|
+
nextPageCursor: string | null;
|
|
68
|
+
};
|
|
69
|
+
//# sourceMappingURL=execution.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"execution.d.ts","sourceRoot":"","sources":["../../src/types/execution.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,MAAM,MAAM,UAAU,GAClB,YAAY,GACZ,SAAS,GACT,OAAO,GACP,YAAY,GACZ,UAAU,GACV,UAAU,GACV,UAAU,GACV,YAAY,GACZ,OAAO,GACP,YAAY,GACZ,aAAa,GACb,UAAU,GACV,QAAQ,GACR,MAAM,GACN,SAAS,GACT,OAAO,GACP,UAAU,GACV,SAAS,GACT,UAAU,GACV,kBAAkB,GAClB,aAAa,GACb,aAAa,GACb,UAAU,GACV,QAAQ,GACR,YAAY,GACZ,SAAS,GACT,YAAY,GACZ,OAAO,GACP,SAAS,GACT,gBAAgB,GAChB,gBAAgB,GAChB,OAAO,GACP,MAAM,GACN,SAAS,GACT,WAAW,GACX,YAAY,GACZ,eAAe,GACf,MAAM,GACN,aAAa,GACb,SAAS,CAAC;AAEd,kEAAkE;AAClE,MAAM,MAAM,mBAAmB,GAAG;IAAE,GAAG,EAAE,MAAM,CAAC;IAAC,GAAG,EAAE,MAAM,CAAA;CAAE,CAAC;AAE/D,MAAM,MAAM,iBAAiB,GAAG;IAC9B,WAAW,EAAE,MAAM,CAAC;IACpB,SAAS,EAAE,MAAM,CAAC;IAClB,SAAS,EAAE,MAAM,CAAC;IAClB,gBAAgB,EAAE,MAAM,GAAG,IAAI,CAAC;IAChC,WAAW,EAAE,MAAM,GAAG,IAAI,CAAC;IAC3B,gBAAgB,EAAE,MAAM,GAAG,IAAI,CAAC;IAChC,uFAAuF;IACvF,cAAc,EAAE,MAAM,GAAG,IAAI,CAAC;IAC9B,UAAU,EAAE,MAAM,CAAC;IACnB,QAAQ,EAAE,MAAM,GAAG,IAAI,CAAC;IACxB,uBAAuB,EAAE,MAAM,CAAC;IAChC,kBAAkB,EAAE,OAAO,CAAC;IAC5B,sBAAsB,EAAE,MAAM,GAAG,IAAI,CAAC;IACtC,uBAAuB,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,IAAI,CAAC;IACxD;;;;;;;OAOG;IACH,mBAAmB,EAAE,mBAAmB,GAAG,IAAI,CAAC;IAChD,gBAAgB,EAAE,OAAO,CAAC;IAC1B,gBAAgB,EAAE,OAAO,CAAC;IAC1B,wBAAwB,EAAE,OAAO,CAAC;IAClC,wBAAwB,EAAE,OAAO,CAAC;CACnC,CAAC;AAEF,MAAM,MAAM,qBAAqB,GAAG;IAClC,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB;;;;OAIG;IACH,UAAU,CAAC,EAAE,UAAU,GAAG,UAAU,EAAE,CAAC;IACvC,mCAAmC;IACnC,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,mCAAmC;IACnC,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB;;;;;;OAMG;IACH,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,UAAU,CAAC,EAAE,MAAM,CAAC;CACrB,CAAC;AAEF,MAAM,MAAM,oBAAoB,GAAG;IACjC,UAAU,EAAE,iBAAiB,EAAE,CAAC;IAChC,cAAc,EAAE,MAAM,GAAG,IAAI,CAAC;CAC/B,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"execution.js","sourceRoot":"","sources":["../../src/types/execution.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/types/index.ts"],"names":[],"mappings":"AAAA,cAAc,UAAU,CAAC;AACzB,cAAc,WAAW,CAAC;AAC1B,cAAc,aAAa,CAAC"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./config"), exports);
|
|
18
|
+
__exportStar(require("./ruleset"), exports);
|
|
19
|
+
__exportStar(require("./execution"), exports);
|
|
20
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/types/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,2CAAyB;AACzB,4CAA0B;AAC1B,8CAA4B"}
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
export type RegisterResult = {
|
|
2
|
+
rulesetId: string;
|
|
3
|
+
shortCode: string;
|
|
4
|
+
engineMode: string;
|
|
5
|
+
version: string;
|
|
6
|
+
created: boolean;
|
|
7
|
+
executeUrl: string;
|
|
8
|
+
};
|
|
9
|
+
export type ExecuteResult<T = unknown> = {
|
|
10
|
+
executionId: string;
|
|
11
|
+
ruleset: string;
|
|
12
|
+
result: T;
|
|
13
|
+
engineMode: string;
|
|
14
|
+
shortCode: string;
|
|
15
|
+
version: string;
|
|
16
|
+
executionTimeMs: number;
|
|
17
|
+
totalTimeMs: number;
|
|
18
|
+
lineage?: Record<string, unknown>;
|
|
19
|
+
};
|
|
20
|
+
export type ExecuteOptions = {
|
|
21
|
+
/** Pins a published version. Sent as the version query string parameter. */
|
|
22
|
+
version?: string;
|
|
23
|
+
lineage?: boolean;
|
|
24
|
+
archiveExecutionResult?: boolean;
|
|
25
|
+
runtime?: string;
|
|
26
|
+
correlationId?: string;
|
|
27
|
+
parentExecutionId?: string;
|
|
28
|
+
/** Pricing: calculate one rule by id. */
|
|
29
|
+
ruleId?: string;
|
|
30
|
+
/** Pricing: calculate under one named scenario. */
|
|
31
|
+
scenario?: string;
|
|
32
|
+
};
|
|
33
|
+
export type BatchSubmitResult = {
|
|
34
|
+
batchCode: string;
|
|
35
|
+
batchId: string;
|
|
36
|
+
rulesetShortCode: string;
|
|
37
|
+
engineMode: string;
|
|
38
|
+
version: string;
|
|
39
|
+
totalItems: number;
|
|
40
|
+
status: 'pending';
|
|
41
|
+
};
|
|
42
|
+
export type BatchStatusResult = {
|
|
43
|
+
batchCode: string;
|
|
44
|
+
status: 'pending' | 'processing' | 'completed' | 'partial' | 'failed';
|
|
45
|
+
totalItems: number;
|
|
46
|
+
completedCount: number;
|
|
47
|
+
errorCount: number;
|
|
48
|
+
progress: number;
|
|
49
|
+
engineMode: string;
|
|
50
|
+
version: string;
|
|
51
|
+
rulesetShortCode: string;
|
|
52
|
+
createdAt: string;
|
|
53
|
+
startedAt: string | null;
|
|
54
|
+
completedAt: string | null;
|
|
55
|
+
};
|
|
56
|
+
export type BatchItem = {
|
|
57
|
+
position: number;
|
|
58
|
+
status: 'queued' | 'processing' | 'completed' | 'error';
|
|
59
|
+
result: unknown | null;
|
|
60
|
+
errorMessage: string | null;
|
|
61
|
+
executionMs: number | null;
|
|
62
|
+
executionId: string | null;
|
|
63
|
+
completedAt: string | null;
|
|
64
|
+
};
|
|
65
|
+
export type BatchItemsResult = {
|
|
66
|
+
batchCode: string;
|
|
67
|
+
items: BatchItem[];
|
|
68
|
+
pagination: {
|
|
69
|
+
offset: number;
|
|
70
|
+
limit: number;
|
|
71
|
+
total: number;
|
|
72
|
+
};
|
|
73
|
+
};
|
|
74
|
+
export type BatchItemsOptions = {
|
|
75
|
+
offset?: number;
|
|
76
|
+
limit?: number;
|
|
77
|
+
status?: 'queued' | 'processing' | 'completed' | 'error';
|
|
78
|
+
};
|
|
79
|
+
//# sourceMappingURL=ruleset.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ruleset.d.ts","sourceRoot":"","sources":["../../src/types/ruleset.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,cAAc,GAAG;IAC3B,SAAS,EAAE,MAAM,CAAC;IAClB,SAAS,EAAE,MAAM,CAAC;IAClB,UAAU,EAAE,MAAM,CAAC;IACnB,OAAO,EAAE,MAAM,CAAC;IAChB,OAAO,EAAE,OAAO,CAAC;IACjB,UAAU,EAAE,MAAM,CAAC;CACpB,CAAC;AAEF,MAAM,MAAM,aAAa,CAAC,CAAC,GAAG,OAAO,IAAI;IACvC,WAAW,EAAE,MAAM,CAAC;IACpB,OAAO,EAAE,MAAM,CAAC;IAChB,MAAM,EAAE,CAAC,CAAC;IACV,UAAU,EAAE,MAAM,CAAC;IACnB,SAAS,EAAE,MAAM,CAAC;IAClB,OAAO,EAAE,MAAM,CAAC;IAChB,eAAe,EAAE,MAAM,CAAC;IACxB,WAAW,EAAE,MAAM,CAAC;IACpB,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CACnC,CAAC;AAEF,MAAM,MAAM,cAAc,GAAG;IAC3B,4EAA4E;IAC5E,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,sBAAsB,CAAC,EAAE,OAAO,CAAC;IACjC,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,iBAAiB,CAAC,EAAE,MAAM,CAAC;IAC3B,yCAAyC;IACzC,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,mDAAmD;IACnD,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB,CA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EAAE,MAAM,CAAC;QACf,KAAK,EAAE,MAAM,CAAC;QACd,KAAK,EAAE,MAAM,CAAC;KACf,CAAC;CACH,CAAC;AAEF,MAAM,MAAM,iBAAiB,GAAG;IAC9B,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,MAAM,CAAC,EAAE,QAAQ,GAAG,YAAY,GAAG,WAAW,GAAG,OAAO,CAAC;CAC1D,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ruleset.js","sourceRoot":"","sources":["../../src/types/ruleset.ts"],"names":[],"mappings":""}
|
package/package.json
CHANGED
|
@@ -1,6 +1,52 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@boerules/sdk",
|
|
3
|
-
"version": "
|
|
4
|
-
"
|
|
5
|
-
"
|
|
6
|
-
|
|
3
|
+
"version": "5.1.0",
|
|
4
|
+
"description": "BOE business rule engine SDK. Register and execute rulesets, and manage accounts and organizations.",
|
|
5
|
+
"main": "dist/index.js",
|
|
6
|
+
"types": "dist/index.d.ts",
|
|
7
|
+
"exports": {
|
|
8
|
+
".": {
|
|
9
|
+
"types": "./dist/index.d.ts",
|
|
10
|
+
"default": "./dist/index.js"
|
|
11
|
+
}
|
|
12
|
+
},
|
|
13
|
+
"scripts": {
|
|
14
|
+
"build": "tsc",
|
|
15
|
+
"dev": "tsc --watch",
|
|
16
|
+
"cdk": "cdk",
|
|
17
|
+
"test": "node --import tsx --test src/*.test.ts"
|
|
18
|
+
},
|
|
19
|
+
"author": "Kamau Washington",
|
|
20
|
+
"license": "MIT",
|
|
21
|
+
"homepage": "https://boerules.com",
|
|
22
|
+
"keywords": [
|
|
23
|
+
"rules-engine",
|
|
24
|
+
"business-rule-engine",
|
|
25
|
+
"scoring",
|
|
26
|
+
"sdk",
|
|
27
|
+
"json"
|
|
28
|
+
],
|
|
29
|
+
"files": [
|
|
30
|
+
"dist"
|
|
31
|
+
],
|
|
32
|
+
"publishConfig": {
|
|
33
|
+
"access": "public",
|
|
34
|
+
"registry": "https://registry.npmjs.org/"
|
|
35
|
+
},
|
|
36
|
+
"devDependencies": {
|
|
37
|
+
"@types/aws-lambda": "^8.10.145",
|
|
38
|
+
"@types/node": "^24.10.0",
|
|
39
|
+
"@types/pg": "^8.11.0",
|
|
40
|
+
"aws-cdk": "^2.1149.0",
|
|
41
|
+
"aws-cdk-lib": "^2.170.0",
|
|
42
|
+
"constructs": "^10.0.0",
|
|
43
|
+
"esbuild": "^0.24.0",
|
|
44
|
+
"source-map-support": "^0.5.21",
|
|
45
|
+
"ts-node": "^10.9.2",
|
|
46
|
+
"tsx": "^4.19.0",
|
|
47
|
+
"typescript": "^5.9.3"
|
|
48
|
+
},
|
|
49
|
+
"dependencies": {
|
|
50
|
+
"ajv-formats": "^3.0.1"
|
|
51
|
+
}
|
|
52
|
+
}
|