@agentuity/core 0.0.59 → 0.0.61
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/error.d.ts +90 -0
- package/dist/error.d.ts.map +1 -0
- package/dist/error.js +258 -0
- package/dist/error.js.map +1 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -0
- package/dist/index.js.map +1 -1
- package/dist/json.d.ts +1 -1
- package/dist/json.d.ts.map +1 -1
- package/dist/json.js +2 -2
- package/dist/json.js.map +1 -1
- package/dist/services/_util.d.ts +2 -6
- package/dist/services/_util.d.ts.map +1 -1
- package/dist/services/_util.js +56 -8
- package/dist/services/_util.js.map +1 -1
- package/dist/services/adapter.d.ts +2 -1
- package/dist/services/adapter.d.ts.map +1 -1
- package/dist/services/exception.d.ts +20 -6
- package/dist/services/exception.d.ts.map +1 -1
- package/dist/services/exception.js +2 -11
- package/dist/services/exception.js.map +1 -1
- package/dist/services/index.d.ts +0 -1
- package/dist/services/index.d.ts.map +1 -1
- package/dist/services/keyvalue.d.ts.map +1 -1
- package/dist/services/keyvalue.js +5 -1
- package/dist/services/keyvalue.js.map +1 -1
- package/dist/services/objectstore.d.ts.map +1 -1
- package/dist/services/objectstore.js +65 -26
- package/dist/services/objectstore.js.map +1 -1
- package/dist/services/stream.d.ts.map +1 -1
- package/dist/services/stream.js +25 -9
- package/dist/services/stream.js.map +1 -1
- package/dist/services/vector.d.ts.map +1 -1
- package/dist/services/vector.js +48 -30
- package/dist/services/vector.js.map +1 -1
- package/dist/workbench-config.d.ts +38 -0
- package/dist/workbench-config.d.ts.map +1 -1
- package/dist/workbench-config.js +7 -5
- package/dist/workbench-config.js.map +1 -1
- package/package.json +1 -1
- package/src/__test__/error.test.ts +431 -0
- package/src/error.ts +384 -0
- package/src/index.ts +1 -0
- package/src/json.ts +2 -2
- package/src/services/__test__/vector.test.ts +20 -14
- package/src/services/_util.ts +56 -18
- package/src/services/adapter.ts +3 -1
- package/src/services/exception.ts +7 -9
- package/src/services/index.ts +0 -1
- package/src/services/keyvalue.ts +6 -1
- package/src/services/objectstore.ts +79 -44
- package/src/services/stream.ts +45 -11
- package/src/services/vector.ts +99 -30
- package/src/workbench-config.ts +16 -5
package/dist/error.d.ts
ADDED
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
import util from 'node:util';
|
|
2
|
+
type PlainObject = Record<string, any>;
|
|
3
|
+
declare const _argsSym: unique symbol;
|
|
4
|
+
declare const _causeSym: unique symbol;
|
|
5
|
+
declare const _metaSym: unique symbol;
|
|
6
|
+
export declare class RichError extends Error {
|
|
7
|
+
private [_argsSym]?;
|
|
8
|
+
private [_causeSym]?;
|
|
9
|
+
private [_metaSym]?;
|
|
10
|
+
constructor(args?: PlainObject);
|
|
11
|
+
/** Return the stored plain args (if any) */
|
|
12
|
+
get plainArgs(): PlainObject | undefined;
|
|
13
|
+
/** Return the cause (if any) */
|
|
14
|
+
get cause(): unknown | undefined;
|
|
15
|
+
/** Pretty, recursive string representation (follows cause chain). */
|
|
16
|
+
prettyPrint(space?: number): string;
|
|
17
|
+
toJSON(): any;
|
|
18
|
+
toString(): string;
|
|
19
|
+
[util.inspect.custom](_depth: number, _options: any): string;
|
|
20
|
+
}
|
|
21
|
+
type StructuredErrorConstructor<Tag extends string, Shape extends PlainObject, HasDefault extends boolean> = {
|
|
22
|
+
new (args?: Shape extends Record<string, never> ? HasDefault extends true ? {
|
|
23
|
+
cause?: unknown;
|
|
24
|
+
} : {
|
|
25
|
+
message?: string;
|
|
26
|
+
cause?: unknown;
|
|
27
|
+
} : HasDefault extends true ? Shape & {
|
|
28
|
+
cause?: unknown;
|
|
29
|
+
} : Shape & {
|
|
30
|
+
message?: string;
|
|
31
|
+
cause?: unknown;
|
|
32
|
+
}): RichError & {
|
|
33
|
+
readonly _tag: Tag;
|
|
34
|
+
} & Readonly<Shape>;
|
|
35
|
+
readonly defaultMessage?: string;
|
|
36
|
+
};
|
|
37
|
+
/**
|
|
38
|
+
* StructuredError factory with automatic tag inference and payload typing.
|
|
39
|
+
*
|
|
40
|
+
* Creates a custom error class with:
|
|
41
|
+
* - A readonly `_tag` property for runtime type discrimination
|
|
42
|
+
* - Automatic stack trace capture
|
|
43
|
+
* - Cause chaining support
|
|
44
|
+
* - Pretty printing with `prettyPrint()` and `toString()`
|
|
45
|
+
* - JSON serialization with `toJSON()`
|
|
46
|
+
*
|
|
47
|
+
* @template Tag - The literal string tag type (automatically inferred from the tag parameter)
|
|
48
|
+
* @param tag - The unique identifier for this error type (used as the error name)
|
|
49
|
+
* @param defaultMessage - Optional default message to use when no message is provided in args
|
|
50
|
+
* @returns A constructor function that can be called directly or with a shape generic
|
|
51
|
+
*
|
|
52
|
+
* @example
|
|
53
|
+
* // Without shape (tag auto-inferred)
|
|
54
|
+
* const NotFound = StructuredError("NotFound")
|
|
55
|
+
* throw new NotFound({ id: 1, message: "nope", cause: someError })
|
|
56
|
+
*
|
|
57
|
+
* @example
|
|
58
|
+
* // With typed shape (tag auto-inferred, shape explicitly typed)
|
|
59
|
+
* const ValidationError = StructuredError("ValidationError")<{ field: string; code: string }>()
|
|
60
|
+
* throw new ValidationError({ field: "email", code: "INVALID", message: "Invalid email" })
|
|
61
|
+
*
|
|
62
|
+
* @example
|
|
63
|
+
* // With default message (message cannot be overridden)
|
|
64
|
+
* const UpgradeRequired = StructuredError("UpgradeRequired", "Upgrade required to access this feature")
|
|
65
|
+
* throw new UpgradeRequired({ feature: "advanced" }) // message is automatically set and cannot be changed
|
|
66
|
+
*/
|
|
67
|
+
type StructuredErrorFactory<Tag extends string, HasDefault extends boolean> = StructuredErrorConstructor<Tag, Record<string, never>, HasDefault> & (<Shape extends PlainObject = Record<string, never>>() => StructuredErrorConstructor<Tag, Shape, HasDefault>);
|
|
68
|
+
export declare function StructuredError<const Tag extends string>(tag: Tag, defaultMessage: string): StructuredErrorFactory<Tag, true>;
|
|
69
|
+
export declare function StructuredError<const Tag extends string>(tag: Tag): StructuredErrorFactory<Tag, false>;
|
|
70
|
+
/**
|
|
71
|
+
* Returns true if the error passed is an instance of a StructuredObject
|
|
72
|
+
*
|
|
73
|
+
* @param err the error object
|
|
74
|
+
* @returns true if err is a StructuredError
|
|
75
|
+
*
|
|
76
|
+
* @example
|
|
77
|
+
* const UpgradeRequired = StructuredError("UpgradeRequired", "Upgrade required to access this feature")
|
|
78
|
+
* try {
|
|
79
|
+
* throw UpgradeRequired();
|
|
80
|
+
* } catch (ex) {
|
|
81
|
+
* if (isStructuredError(ex)) {
|
|
82
|
+
* console.log(ex._tag);
|
|
83
|
+
* }
|
|
84
|
+
* }
|
|
85
|
+
*/
|
|
86
|
+
export declare function isStructuredError(err: unknown): err is RichError & {
|
|
87
|
+
_tag: string;
|
|
88
|
+
};
|
|
89
|
+
export {};
|
|
90
|
+
//# sourceMappingURL=error.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"error.d.ts","sourceRoot":"","sources":["../src/error.ts"],"names":[],"mappings":"AAIA,OAAO,IAAI,MAAM,WAAW,CAAC;AAG7B,KAAK,WAAW,GAAG,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;AAEvC,QAAA,MAAM,QAAQ,eAAkC,CAAC;AACjD,QAAA,MAAM,SAAS,eAA8B,CAAC;AAC9C,QAAA,MAAM,QAAQ,eAA6B,CAAC;AAK5C,qBAAa,SAAU,SAAQ,KAAK;IAEnC,OAAO,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAc;IACjC,OAAO,CAAC,CAAC,SAAS,CAAC,CAAC,CAAU;IAC9B,OAAO,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAc;gBAErB,IAAI,CAAC,EAAE,WAAW;IAsD9B,4CAA4C;IAC5C,IAAI,SAAS,IAAI,WAAW,GAAG,SAAS,CAEvC;IAED,gCAAgC;IAChC,IAAI,KAAK,IAAI,OAAO,GAAG,SAAS,CAE/B;IAED,qEAAqE;IACrE,WAAW,CAA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CAAC,GAAG,SAAS,MAAM,EACvD,GAAG,EAAE,GAAG,EACR,cAAc,EAAE,MAAM,GACpB,sBAAsB,CAAC,GAAG,EAAE,IAAI,CAAC,CAAC;AACrC,wBAAgB,eAAe,CAAC,KAAK,CAAC,GAAG,SAAS,MAAM,EACvD,GAAG,EAAE,GAAG,GACN,sBAAsB,CAAC,GAAG,EAAE,KAAK,CAAC,CAAC;AAoGtC;;;;;;;;;;;;;;;GAeG;AACH,wBAAgB,iBAAiB,CAAC,GAAG,EAAE,OAAO,GAAG,GAAG,IAAI,SAAS,GAAG;IAAE,IAAI,EAAE,MAAM,CAAA;CAAE,CAOnF"}
|
package/dist/error.js
ADDED
|
@@ -0,0 +1,258 @@
|
|
|
1
|
+
/* eslint-disable @typescript-eslint/no-explicit-any */
|
|
2
|
+
// NOTE: these ideas are borrowed from https://github.com/Effect-TS/effect
|
|
3
|
+
import util from 'node:util';
|
|
4
|
+
import { safeStringify } from './json';
|
|
5
|
+
const _argsSym = Symbol('@@RichError:plainArgs');
|
|
6
|
+
const _causeSym = Symbol('@@RichError:cause');
|
|
7
|
+
const _metaSym = Symbol('@@RichError:meta'); // reserved for future use (non-enumerable)
|
|
8
|
+
const _structuredSym = Symbol.for('@@StructuredError');
|
|
9
|
+
const spacer = ' ';
|
|
10
|
+
export class RichError extends Error {
|
|
11
|
+
// private slots (non-enumerable)
|
|
12
|
+
[_argsSym];
|
|
13
|
+
[_causeSym];
|
|
14
|
+
[_metaSym];
|
|
15
|
+
constructor(args) {
|
|
16
|
+
const message = args?.message ?? undefined;
|
|
17
|
+
const cause = (args?.cause ?? undefined);
|
|
18
|
+
// If platform supports error cause option, pass it to Error constructor
|
|
19
|
+
// (Node 16+ / modern engines)
|
|
20
|
+
if (cause !== undefined) {
|
|
21
|
+
super(message, { cause });
|
|
22
|
+
}
|
|
23
|
+
else {
|
|
24
|
+
super(message);
|
|
25
|
+
}
|
|
26
|
+
// correct prototype chain when transpiled to older JS
|
|
27
|
+
Object.setPrototypeOf(this, new.target.prototype);
|
|
28
|
+
// capture a clean stack (omit this constructor)
|
|
29
|
+
if (typeof Error.captureStackTrace === 'function') {
|
|
30
|
+
Error.captureStackTrace(this, new.target);
|
|
31
|
+
}
|
|
32
|
+
else {
|
|
33
|
+
// fallback: ensure stack exists
|
|
34
|
+
if (!this.stack) {
|
|
35
|
+
this.stack = new Error(message).stack;
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
if (args && typeof args === 'object') {
|
|
39
|
+
// copy all fields except cause and message (we keep them separate)
|
|
40
|
+
const { cause: _c, message: _m, ...rest } = args;
|
|
41
|
+
if (Object.keys(rest).length > 0) {
|
|
42
|
+
Object.assign(this, rest);
|
|
43
|
+
this[_argsSym] = rest;
|
|
44
|
+
}
|
|
45
|
+
if (cause !== undefined) {
|
|
46
|
+
this[_causeSym] = cause;
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
// hide internal symbols and meta (redefine non-enumerable)
|
|
50
|
+
Object.defineProperty(this, _argsSym, {
|
|
51
|
+
value: this[_argsSym],
|
|
52
|
+
enumerable: false,
|
|
53
|
+
writable: true,
|
|
54
|
+
});
|
|
55
|
+
Object.defineProperty(this, _causeSym, {
|
|
56
|
+
value: this[_causeSym],
|
|
57
|
+
enumerable: false,
|
|
58
|
+
writable: true,
|
|
59
|
+
});
|
|
60
|
+
Object.defineProperty(this, _metaSym, {
|
|
61
|
+
value: this[_metaSym] ?? {},
|
|
62
|
+
enumerable: false,
|
|
63
|
+
writable: true,
|
|
64
|
+
});
|
|
65
|
+
}
|
|
66
|
+
/** Return the stored plain args (if any) */
|
|
67
|
+
get plainArgs() {
|
|
68
|
+
return this[_argsSym];
|
|
69
|
+
}
|
|
70
|
+
/** Return the cause (if any) */
|
|
71
|
+
get cause() {
|
|
72
|
+
return this[_causeSym];
|
|
73
|
+
}
|
|
74
|
+
/** Pretty, recursive string representation (follows cause chain). */
|
|
75
|
+
prettyPrint(space = 2) {
|
|
76
|
+
const lines = [];
|
|
77
|
+
const visited = new Set();
|
|
78
|
+
// eslint-disable-next-line @typescript-eslint/no-this-alias
|
|
79
|
+
let cur = this;
|
|
80
|
+
let depth = 0;
|
|
81
|
+
while (cur && cur instanceof Error && !visited.has(cur)) {
|
|
82
|
+
const curAny = cur;
|
|
83
|
+
visited.add(cur);
|
|
84
|
+
const header = `${cur.name}${curAny._tag && curAny._tag !== cur.name ? ` (${String(curAny._tag)})` : ''}${depth === 0 ? '' : ' [cause]'}`;
|
|
85
|
+
const msg = cur.message !== undefined && cur.message !== '' ? `: ${cur.message}` : '';
|
|
86
|
+
lines.push(header + msg);
|
|
87
|
+
// include stack if present (limit to first line of stack header for brevity)
|
|
88
|
+
if (cur.stack) {
|
|
89
|
+
lines.push('');
|
|
90
|
+
lines.push(spacer + 'stack trace:');
|
|
91
|
+
const stackLines = String(cur.stack).split('\n').slice(1); // drop first line (it's message)
|
|
92
|
+
if (stackLines.length > 0) {
|
|
93
|
+
// indent stack
|
|
94
|
+
let s = stackLines.map((s) => spacer + spacer + s.trim());
|
|
95
|
+
if (s[s.length - 1].includes('processTicksAndRejections')) {
|
|
96
|
+
s = s.slice(0, s.length - 1);
|
|
97
|
+
}
|
|
98
|
+
lines.push(...s);
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
// include plain args as formatted output (if any)
|
|
102
|
+
if (curAny[_argsSym]) {
|
|
103
|
+
let argsStr = util.formatWithOptions({
|
|
104
|
+
depth: 10,
|
|
105
|
+
sorted: true,
|
|
106
|
+
showHidden: false,
|
|
107
|
+
showProxy: false,
|
|
108
|
+
maxArrayLength: 10,
|
|
109
|
+
maxStringLength: 80 - spacer.length * 2,
|
|
110
|
+
}, curAny[_argsSym]);
|
|
111
|
+
argsStr = argsStr.replace(/^{/, '').replace(/}$/, '');
|
|
112
|
+
const jsonlines = argsStr
|
|
113
|
+
.split('\n')
|
|
114
|
+
.filter(Boolean)
|
|
115
|
+
.map((l) => spacer + spacer + l + '\n')
|
|
116
|
+
.join('');
|
|
117
|
+
lines.push('');
|
|
118
|
+
lines.push(spacer + 'context:\n' + jsonlines);
|
|
119
|
+
}
|
|
120
|
+
// include cause summary if non-Error (could be object)
|
|
121
|
+
const c = cur.cause ?? curAny[_causeSym];
|
|
122
|
+
if (c && !(c instanceof Error)) {
|
|
123
|
+
lines.push(spacer + 'cause: ' + safeStringify(c, space));
|
|
124
|
+
}
|
|
125
|
+
cur = c instanceof Error ? c : undefined;
|
|
126
|
+
depth += 1;
|
|
127
|
+
if (cur)
|
|
128
|
+
lines.push('-- caused by --');
|
|
129
|
+
}
|
|
130
|
+
return lines.join('\n');
|
|
131
|
+
}
|
|
132
|
+
toJSON() {
|
|
133
|
+
// Represent as merged: args, public enumerable props, plus well-known fields
|
|
134
|
+
const output = {};
|
|
135
|
+
// include args first (non-enumerable original values)
|
|
136
|
+
if (this[_argsSym]) {
|
|
137
|
+
Object.assign(output, this[_argsSym]);
|
|
138
|
+
}
|
|
139
|
+
// copy enumerable own props
|
|
140
|
+
for (const k of Object.keys(this)) {
|
|
141
|
+
// skip internal symbols (they are non-enumerable anyway)
|
|
142
|
+
output[k] = this[k];
|
|
143
|
+
}
|
|
144
|
+
// canonical fields
|
|
145
|
+
output.name = this.name;
|
|
146
|
+
if (this.message !== undefined)
|
|
147
|
+
output.message = this.message;
|
|
148
|
+
if (this.stack !== undefined)
|
|
149
|
+
output.stack = this.stack;
|
|
150
|
+
if (this.cause !== undefined) {
|
|
151
|
+
if (this.cause instanceof Error) {
|
|
152
|
+
output.cause = {
|
|
153
|
+
name: this.cause.name,
|
|
154
|
+
message: this.cause.message,
|
|
155
|
+
stack: this.cause.stack,
|
|
156
|
+
};
|
|
157
|
+
}
|
|
158
|
+
else {
|
|
159
|
+
output.cause = this.cause;
|
|
160
|
+
}
|
|
161
|
+
}
|
|
162
|
+
return output;
|
|
163
|
+
}
|
|
164
|
+
toString() {
|
|
165
|
+
// default to pretty print with small indent
|
|
166
|
+
return this.prettyPrint(2);
|
|
167
|
+
}
|
|
168
|
+
[util.inspect.custom](_depth, _options) {
|
|
169
|
+
return this.prettyPrint(); // or some concise string/JSON
|
|
170
|
+
}
|
|
171
|
+
}
|
|
172
|
+
export function StructuredError(tag, defaultMessage) {
|
|
173
|
+
function createErrorClass() {
|
|
174
|
+
// create a unique symbol for this tag's args storage so different factories don't clash
|
|
175
|
+
const tagArgsSym = Symbol.for(`@StructuredError:tag:${tag}`);
|
|
176
|
+
class Tagged extends RichError {
|
|
177
|
+
// runtime readonly property for tag
|
|
178
|
+
_tag = tag;
|
|
179
|
+
static defaultMessage = defaultMessage;
|
|
180
|
+
constructor(args) {
|
|
181
|
+
// ensure `_tag` isn't copied from args accidentally
|
|
182
|
+
const safeArgs = args && typeof args === 'object'
|
|
183
|
+
? (() => {
|
|
184
|
+
const { _tag: _discard, ...rest } = args;
|
|
185
|
+
return rest;
|
|
186
|
+
})()
|
|
187
|
+
: args;
|
|
188
|
+
// Apply default message if no message provided
|
|
189
|
+
const finalArgs = safeArgs && typeof safeArgs === 'object'
|
|
190
|
+
? { ...safeArgs, message: safeArgs.message ?? defaultMessage }
|
|
191
|
+
: defaultMessage
|
|
192
|
+
? { message: defaultMessage }
|
|
193
|
+
: safeArgs;
|
|
194
|
+
super(finalArgs);
|
|
195
|
+
// name the class for nicer stacks
|
|
196
|
+
try {
|
|
197
|
+
Object.defineProperty(this, 'name', { value: tag, configurable: true });
|
|
198
|
+
}
|
|
199
|
+
catch {
|
|
200
|
+
this.name = tag;
|
|
201
|
+
}
|
|
202
|
+
// mark as StructuredError with brand symbol
|
|
203
|
+
Object.defineProperty(this, _structuredSym, {
|
|
204
|
+
value: true,
|
|
205
|
+
enumerable: false,
|
|
206
|
+
writable: false,
|
|
207
|
+
});
|
|
208
|
+
// store tag args symbol to hide anything specific to this factory (non-enumerable)
|
|
209
|
+
Object.defineProperty(this, tagArgsSym, {
|
|
210
|
+
value: safeArgs,
|
|
211
|
+
enumerable: false,
|
|
212
|
+
writable: true,
|
|
213
|
+
});
|
|
214
|
+
}
|
|
215
|
+
}
|
|
216
|
+
// set prototype name (works in many engines)
|
|
217
|
+
try {
|
|
218
|
+
Object.defineProperty(Tagged, 'name', { value: String(tag) });
|
|
219
|
+
}
|
|
220
|
+
catch {
|
|
221
|
+
Tagged.name = tag;
|
|
222
|
+
}
|
|
223
|
+
return Tagged;
|
|
224
|
+
}
|
|
225
|
+
const baseClass = createErrorClass();
|
|
226
|
+
// Use a Proxy to intercept calls and return shaped classes
|
|
227
|
+
const callable = new Proxy(baseClass, {
|
|
228
|
+
apply(_target, _thisArg, _args) {
|
|
229
|
+
// When called as a function (for generic type application), return a new class
|
|
230
|
+
// This happens when TypeScript sees: StructuredError("Tag")<Shape>()
|
|
231
|
+
return createErrorClass();
|
|
232
|
+
},
|
|
233
|
+
});
|
|
234
|
+
return callable;
|
|
235
|
+
}
|
|
236
|
+
/**
|
|
237
|
+
* Returns true if the error passed is an instance of a StructuredObject
|
|
238
|
+
*
|
|
239
|
+
* @param err the error object
|
|
240
|
+
* @returns true if err is a StructuredError
|
|
241
|
+
*
|
|
242
|
+
* @example
|
|
243
|
+
* const UpgradeRequired = StructuredError("UpgradeRequired", "Upgrade required to access this feature")
|
|
244
|
+
* try {
|
|
245
|
+
* throw UpgradeRequired();
|
|
246
|
+
* } catch (ex) {
|
|
247
|
+
* if (isStructuredError(ex)) {
|
|
248
|
+
* console.log(ex._tag);
|
|
249
|
+
* }
|
|
250
|
+
* }
|
|
251
|
+
*/
|
|
252
|
+
export function isStructuredError(err) {
|
|
253
|
+
return (typeof err === 'object' &&
|
|
254
|
+
err !== null &&
|
|
255
|
+
(_structuredSym in err || err instanceof RichError) &&
|
|
256
|
+
typeof err._tag === 'string');
|
|
257
|
+
}
|
|
258
|
+
//# sourceMappingURL=error.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"error.js","sourceRoot":"","sources":["../src/error.ts"],"names":[],"mappings":"AAAA,uDAAuD;AAEvD,0EAA0E;AAE1E,OAAO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AC;QAC/D,CAAC;QAAC,MAAM,CAAC;YACP,MAAc,CAAC,IAAI,GAAG,GAAG,CAAC;QAC5B,CAAC;QAED,OAAO,MAIN,CAAC;IACH,CAAC;IAiBD,MAAM,SAAS,GAAG,gBAAgB,EAAyB,CAAC;IAE5D,2DAA2D;IAC3D,MAAM,QAAQ,GAAG,IAAI,KAAK,CAAC,SAAS,EAAE;QACrC,KAAK,CAAC,OAAO,EAAE,QAAQ,EAAE,KAAK;YAC7B,+EAA+E;YAC/E,qEAAqE;YACrE,OAAO,gBAAgB,EAAE,CAAC;QAC3B,CAAC;KACD,CAAC,CAAC;IAEH,OAAO,QAAkB,CAAC;AAC3B,CAAC;AAED;;;;;;;;;;;;;;;GAeG;AACH,MAAM,UAAU,iBAAiB,CAAC,GAAY;IAC7C,OAAO,CACN,OAAO,GAAG,KAAK,QAAQ;QACvB,GAAG,KAAK,IAAI;QACZ,CAAC,cAAc,IAAI,GAAG,IAAI,GAAG,YAAY,SAAS,CAAC;QACnD,OAAQ,GAAW,CAAC,IAAI,KAAK,QAAQ,CACrC,CAAC;AACH,CAAC"}
|
package/dist/index.d.ts
CHANGED
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,QAAQ,CAAC;AACvB,cAAc,UAAU,CAAC;AACzB,cAAc,YAAY,CAAC;AAC3B,cAAc,mBAAmB,CAAC;AAClC,cAAc,cAAc,CAAC;AAC7B,cAAc,oBAAoB,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,SAAS,CAAC;AACxB,cAAc,QAAQ,CAAC;AACvB,cAAc,UAAU,CAAC;AACzB,cAAc,YAAY,CAAC;AAC3B,cAAc,mBAAmB,CAAC;AAClC,cAAc,cAAc,CAAC;AAC7B,cAAc,oBAAoB,CAAC"}
|
package/dist/index.js
CHANGED
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,QAAQ,CAAC;AACvB,cAAc,UAAU,CAAC;AACzB,cAAc,YAAY,CAAC;AAC3B,cAAc,mBAAmB,CAAC;AAClC,cAAc,cAAc,CAAC;AAC7B,cAAc,oBAAoB,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,SAAS,CAAC;AACxB,cAAc,QAAQ,CAAC;AACvB,cAAc,UAAU,CAAC;AACzB,cAAc,YAAY,CAAC;AAC3B,cAAc,mBAAmB,CAAC;AAClC,cAAc,cAAc,CAAC;AAC7B,cAAc,oBAAoB,CAAC"}
|
package/dist/json.d.ts
CHANGED
|
@@ -3,5 +3,5 @@
|
|
|
3
3
|
* @param obj - The object to stringify
|
|
4
4
|
* @returns JSON string representation
|
|
5
5
|
*/
|
|
6
|
-
export declare function safeStringify(obj: unknown): string;
|
|
6
|
+
export declare function safeStringify(obj: unknown, space?: number | string): string;
|
|
7
7
|
//# sourceMappingURL=json.d.ts.map
|
package/dist/json.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"json.d.ts","sourceRoot":"","sources":["../src/json.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,wBAAgB,aAAa,CAAC,GAAG,EAAE,OAAO,GAAG,MAAM,
|
|
1
|
+
{"version":3,"file":"json.d.ts","sourceRoot":"","sources":["../src/json.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,wBAAgB,aAAa,CAAC,GAAG,EAAE,OAAO,EAAE,KAAK,CAAC,EAAE,MAAM,GAAG,MAAM,GAAG,MAAM,CAoB3E"}
|
package/dist/json.js
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
* @param obj - The object to stringify
|
|
4
4
|
* @returns JSON string representation
|
|
5
5
|
*/
|
|
6
|
-
export function safeStringify(obj) {
|
|
6
|
+
export function safeStringify(obj, space) {
|
|
7
7
|
const visited = new WeakSet();
|
|
8
8
|
function replacer(_key, value) {
|
|
9
9
|
if (typeof value === 'bigint') {
|
|
@@ -18,6 +18,6 @@ export function safeStringify(obj) {
|
|
|
18
18
|
}
|
|
19
19
|
return value;
|
|
20
20
|
}
|
|
21
|
-
return JSON.stringify(obj, replacer);
|
|
21
|
+
return JSON.stringify(obj, replacer, space);
|
|
22
22
|
}
|
|
23
23
|
//# sourceMappingURL=json.js.map
|
package/dist/json.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"json.js","sourceRoot":"","sources":["../src/json.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,MAAM,UAAU,aAAa,CAAC,GAAY;
|
|
1
|
+
{"version":3,"file":"json.js","sourceRoot":"","sources":["../src/json.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,MAAM,UAAU,aAAa,CAAC,GAAY,EAAE,KAAuB;IAClE,MAAM,OAAO,GAAG,IAAI,OAAO,EAAE,CAAC;IAE9B,SAAS,QAAQ,CAAC,IAAY,EAAE,KAAc;QAC7C,IAAI,OAAO,KAAK,KAAK,QAAQ,EAAE,CAAC;YAC/B,OAAO,KAAK,CAAC,QAAQ,EAAE,CAAC;QACzB,CAAC;QAED,IAAI,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,KAAK,IAAI,EAAE,CAAC;YACjD,IAAI,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,EAAE,CAAC;gBACxB,OAAO,YAAY,CAAC;YACrB,CAAC;YACD,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC;YACnB,OAAO,KAAK,CAAC;QACd,CAAC;QAED,OAAO,KAAK,CAAC;IACd,CAAC;IAED,OAAO,IAAI,CAAC,SAAS,CAAC,GAAG,EAAE,QAAQ,EAAE,KAAK,CAAC,CAAC;AAC7C,CAAC"}
|
package/dist/services/_util.d.ts
CHANGED
|
@@ -1,11 +1,7 @@
|
|
|
1
|
-
import type { Body } from './adapter';
|
|
1
|
+
import type { Body, HttpMethod } from './adapter';
|
|
2
2
|
import { ServiceException } from './exception';
|
|
3
|
-
/**
|
|
4
|
-
* Valid HTTP methods for service calls
|
|
5
|
-
*/
|
|
6
|
-
export type HttpMethod = 'GET' | 'POST' | 'PUT' | 'DELETE' | 'PATCH' | 'HEAD' | 'OPTIONS';
|
|
7
3
|
export declare const buildUrl: (base: string, path: string, subpath?: string, query?: URLSearchParams) => string;
|
|
8
|
-
export declare function toServiceException(method: HttpMethod, url: string, response: Response): Promise<ServiceException
|
|
4
|
+
export declare function toServiceException(method: HttpMethod, url: string, response: Response): Promise<InstanceType<typeof ServiceException>>;
|
|
9
5
|
export declare function toPayload(data: unknown): Promise<[Body, string]>;
|
|
10
6
|
export declare function fromResponse<T>(method: HttpMethod, url: string, response: Response): Promise<T>;
|
|
11
7
|
//# sourceMappingURL=_util.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"_util.d.ts","sourceRoot":"","sources":["../../src/services/_util.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;
|
|
1
|
+
{"version":3,"file":"_util.d.ts","sourceRoot":"","sources":["../../src/services/_util.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,IAAI,EAAE,UAAU,EAAE,MAAM,WAAW,CAAC;AAClD,OAAO,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAE/C,eAAO,MAAM,QAAQ,GACpB,MAAM,MAAM,EACZ,MAAM,MAAM,EACZ,UAAU,MAAM,EAChB,QAAQ,eAAe,KACrB,MAWF,CAAC;AAEF,wBAAsB,kBAAkB,CACvC,MAAM,EAAE,UAAU,EAClB,GAAG,EAAE,MAAM,EACX,QAAQ,EAAE,QAAQ,GAChB,OAAO,CAAC,YAAY,CAAC,OAAO,gBAAgB,CAAC,CAAC,CA2EhD;AAMD,wBAAsB,SAAS,CAAC,IAAI,EAAE,OAAO,GAAG,OAAO,CAAC,CAAC,IAAI,EAAE,MAAM,CAAC,CAAC,CA0CtE;AAED,wBAAsB,YAAY,CAAC,CAAC,EACnC,MAAM,EAAE,UAAU,EAClB,GAAG,EAAE,MAAM,EACX,QAAQ,EAAE,QAAQ,GAChB,OAAO,CAAC,CAAC,CAAC,CAiBZ"}
|
package/dist/services/_util.js
CHANGED
|
@@ -13,12 +13,25 @@ export const buildUrl = (base, path, subpath, query) => {
|
|
|
13
13
|
return url;
|
|
14
14
|
};
|
|
15
15
|
export async function toServiceException(method, url, response) {
|
|
16
|
+
const sessionId = response.headers.get('x-session-id');
|
|
16
17
|
switch (response.status) {
|
|
17
18
|
case 401:
|
|
18
19
|
case 403:
|
|
19
|
-
return new ServiceException(
|
|
20
|
+
return new ServiceException({
|
|
21
|
+
message: 'Unauthorized',
|
|
22
|
+
method,
|
|
23
|
+
url,
|
|
24
|
+
statusCode: response.status,
|
|
25
|
+
sessionId,
|
|
26
|
+
});
|
|
20
27
|
case 404:
|
|
21
|
-
return new ServiceException(
|
|
28
|
+
return new ServiceException({
|
|
29
|
+
message: 'Not Found',
|
|
30
|
+
method,
|
|
31
|
+
url,
|
|
32
|
+
statusCode: response.status,
|
|
33
|
+
sessionId,
|
|
34
|
+
});
|
|
22
35
|
default:
|
|
23
36
|
}
|
|
24
37
|
const ct = response.headers.get('content-type');
|
|
@@ -26,12 +39,30 @@ export async function toServiceException(method, url, response) {
|
|
|
26
39
|
try {
|
|
27
40
|
const payload = (await response.json());
|
|
28
41
|
if (payload.error) {
|
|
29
|
-
return new ServiceException(
|
|
42
|
+
return new ServiceException({
|
|
43
|
+
message: payload.error,
|
|
44
|
+
method,
|
|
45
|
+
url,
|
|
46
|
+
statusCode: response.status,
|
|
47
|
+
sessionId,
|
|
48
|
+
});
|
|
30
49
|
}
|
|
31
50
|
if (payload.message) {
|
|
32
|
-
return new ServiceException(
|
|
51
|
+
return new ServiceException({
|
|
52
|
+
message: payload.message,
|
|
53
|
+
method,
|
|
54
|
+
url,
|
|
55
|
+
statusCode: response.status,
|
|
56
|
+
sessionId,
|
|
57
|
+
});
|
|
33
58
|
}
|
|
34
|
-
return new ServiceException(
|
|
59
|
+
return new ServiceException({
|
|
60
|
+
message: JSON.stringify(payload),
|
|
61
|
+
method,
|
|
62
|
+
url,
|
|
63
|
+
statusCode: response.status,
|
|
64
|
+
sessionId,
|
|
65
|
+
});
|
|
35
66
|
}
|
|
36
67
|
catch {
|
|
37
68
|
/** don't worry */
|
|
@@ -39,12 +70,24 @@ export async function toServiceException(method, url, response) {
|
|
|
39
70
|
}
|
|
40
71
|
try {
|
|
41
72
|
const body = await response.text();
|
|
42
|
-
return new ServiceException(
|
|
73
|
+
return new ServiceException({
|
|
74
|
+
message: body,
|
|
75
|
+
method,
|
|
76
|
+
url,
|
|
77
|
+
statusCode: response.status,
|
|
78
|
+
sessionId,
|
|
79
|
+
});
|
|
43
80
|
}
|
|
44
81
|
catch {
|
|
45
82
|
/* fall through */
|
|
46
83
|
}
|
|
47
|
-
return new ServiceException(
|
|
84
|
+
return new ServiceException({
|
|
85
|
+
message: response.statusText,
|
|
86
|
+
method,
|
|
87
|
+
url,
|
|
88
|
+
statusCode: response.status,
|
|
89
|
+
sessionId,
|
|
90
|
+
});
|
|
48
91
|
}
|
|
49
92
|
const binaryContentType = 'application/octet-stream';
|
|
50
93
|
const textContentType = 'text/plain';
|
|
@@ -102,6 +145,11 @@ export async function fromResponse(method, url, response) {
|
|
|
102
145
|
if (contentType?.includes(binaryContentType)) {
|
|
103
146
|
return (await response.arrayBuffer());
|
|
104
147
|
}
|
|
105
|
-
throw new ServiceException(
|
|
148
|
+
throw new ServiceException({
|
|
149
|
+
message: `Unsupported content-type: ${contentType}`,
|
|
150
|
+
method,
|
|
151
|
+
url,
|
|
152
|
+
statusCode: response.status,
|
|
153
|
+
});
|
|
106
154
|
}
|
|
107
155
|
//# sourceMappingURL=_util.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"_util.js","sourceRoot":"","sources":["../../src/services/_util.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AAExC,OAAO,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;
|
|
1
|
+
{"version":3,"file":"_util.js","sourceRoot":"","sources":["../../src/services/_util.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AAExC,OAAO,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAE/C,MAAM,CAAC,MAAM,QAAQ,GAAG,CACvB,IAAY,EACZ,IAAY,EACZ,OAAgB,EAChB,KAAuB,EACd,EAAE;IACX,IAAI,GAAG,IAAI,CAAC,UAAU,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,IAAI,EAAE,CAAC;IAChD,IAAI,GAAG,GAAG,IAAI,CAAC,OAAO,CAAC,KAAK,EAAE,EAAE,CAAC,GAAG,IAAI,CAAC;IACzC,IAAI,OAAO,EAAE,CAAC;QACb,OAAO,GAAG,OAAO,CAAC,UAAU,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,IAAI,OAAO,EAAE,CAAC;QAC5D,GAAG,IAAI,OAAO,CAAC;IAChB,CAAC;IACD,IAAI,KAAK,EAAE,CAAC;QACX,GAAG,IAAI,IAAI,KAAK,CAAC,QAAQ,EAAE,EAAE,CAAC;IAC/B,CAAC;IACD,OAAO,GAAG,CAAC;AACZ,CAAC,CAAC;AAEF,MAAM,CAAC,KAAK,UAAU,kBAAkB,CACvC,MAAkB,EAClB,GAAW,EACX,QAAkB;IAElB,MAAM,SAAS,GAAG,QAAQ,CAAC,OAAO,CAAC,GAAG,CAAC,cAAc,CAAC,CAAC;IACvD,QAAQ,QAAQ,CAAC,M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AC;IACzD,IAAI,CAAC,WAAW,IAAI,WAAW,EAAE,QAAQ,CAAC,OAAO,CAAC,EAAE,CAAC;QACpD,OAAO,CAAC,MAAM,QAAQ,CAAC,IAAI,EAAE,CAAM,CAAC;IACrC,CAAC;IACD,IAAI,WAAW,EAAE,QAAQ,CAAC,OAAO,CAAC,EAAE,CAAC;QACpC,OAAO,CAAC,MAAM,QAAQ,CAAC,IAAI,EAAE,CAAM,CAAC;IACrC,CAAC;IACD,IAAI,WAAW,EAAE,QAAQ,CAAC,iBAAiB,CAAC,EAAE,CAAC;QAC9C,OAAO,CAAC,MAAM,QAAQ,CAAC,WAAW,EAAE,CAAM,CAAC;IAC5C,CAAC;IACD,MAAM,IAAI,gBAAgB,CAAC;QAC1B,OAAO,EAAE,6BAA6B,WAAW,EAAE;QACnD,MAAM;QACN,GAAG;QACH,UAAU,EAAE,QAAQ,CAAC,MAAM;KAC3B,CAAC,CAAC;AACJ,CAAC"}
|
|
@@ -10,8 +10,9 @@ export interface FetchErrorResponse {
|
|
|
10
10
|
}
|
|
11
11
|
export type FetchResponse<T> = FetchErrorResponse | FetchSuccessResponse<T>;
|
|
12
12
|
export type Body = string | Buffer | ArrayBuffer | ReadableStream;
|
|
13
|
+
export type HttpMethod = 'GET' | 'PUT' | 'POST' | 'DELETE' | 'HEAD' | 'OPTIONS' | 'PATCH';
|
|
13
14
|
export interface FetchRequest {
|
|
14
|
-
method:
|
|
15
|
+
method: HttpMethod;
|
|
15
16
|
body?: Body;
|
|
16
17
|
signal?: AbortSignal;
|
|
17
18
|
contentType?: string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"adapter.d.ts","sourceRoot":"","sources":["../../src/services/adapter.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,oBAAoB,CAAC,KAAK;IAC1C,EAAE,EAAE,IAAI,CAAC;IACT,IAAI,EAAE,KAAK,CAAC;IACZ,QAAQ,EAAE,QAAQ,CAAC;CACnB;AAED,MAAM,WAAW,kB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EAAE,MAAM,CAAC,CAAC;KACpC,CAAC;IACF,MAAM,CAAC,EAAE,IAAI,CAAC;IACd,MAAM,CAAC,EAAE,MAAM,CAAC;CAChB;AAED,MAAM,WAAW,YAAY;IAC5B,MAAM,CAAC,CAAC,EAAE,GAAG,EAAE,MAAM,EAAE,OAAO,EAAE,YAAY,GAAG,OAAO,CAAC,aAAa,CAAC,CAAC,CAAC,CAAC,CAAC;CACzE"}
|
|
@@ -1,7 +1,21 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
1
|
+
import { HttpMethod } from './adapter';
|
|
2
|
+
export declare const ServiceException: {
|
|
3
|
+
new (args?: ({
|
|
4
|
+
statusCode: number;
|
|
5
|
+
method: HttpMethod;
|
|
6
|
+
url: string;
|
|
7
|
+
sessionId?: string | null;
|
|
8
|
+
} & {
|
|
9
|
+
message?: string;
|
|
10
|
+
cause?: unknown;
|
|
11
|
+
}) | undefined): import("..").RichError & {
|
|
12
|
+
readonly _tag: "ServiceException";
|
|
13
|
+
} & Readonly<{
|
|
14
|
+
statusCode: number;
|
|
15
|
+
method: HttpMethod;
|
|
16
|
+
url: string;
|
|
17
|
+
sessionId?: string | null;
|
|
18
|
+
}>;
|
|
19
|
+
readonly defaultMessage?: string;
|
|
20
|
+
};
|
|
7
21
|
//# sourceMappingURL=exception.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"exception.d.ts","sourceRoot":"","sources":["../../src/services/exception.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"exception.d.ts","sourceRoot":"","sources":["../../src/services/exception.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,UAAU,EAAE,MAAM,WAAW,CAAC;AAEvC,eAAO,MAAM,gBAAgB;;oBAChB,MAAM;gBACV,UAAU;aACb,MAAM;oBACC,MAAM,GAAG,IAAI;;;;;;;oBAHb,MAAM;gBACV,UAAU;aACb,MAAM;oBACC,MAAM,GAAG,IAAI;;;CACtB,CAAC"}
|
|
@@ -1,12 +1,3 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
method;
|
|
4
|
-
url;
|
|
5
|
-
constructor(message, method, url, statusCode) {
|
|
6
|
-
super(message);
|
|
7
|
-
this.method = method;
|
|
8
|
-
this.url = url;
|
|
9
|
-
this.statusCode = statusCode;
|
|
10
|
-
}
|
|
11
|
-
}
|
|
1
|
+
import { StructuredError } from '../error';
|
|
2
|
+
export const ServiceException = StructuredError('ServiceException')();
|
|
12
3
|
//# sourceMappingURL=exception.js.map
|