iii-sdk 0.22.0 → 0.22.1-alpha.2
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/channel.d.cts +1 -1
- package/dist/channel.d.mts +1 -1
- package/dist/engine.d.cts +1 -2
- package/dist/engine.d.mts +1 -2
- package/dist/errors-BK88qe9x.d.cts +64 -0
- package/dist/errors-BK88qe9x.d.cts.map +1 -0
- package/dist/errors-CUOlcEUP.d.mts +64 -0
- package/dist/errors-CUOlcEUP.d.mts.map +1 -0
- package/dist/errors.cjs +12 -0
- package/dist/errors.cjs.map +1 -1
- package/dist/errors.d.cts +2 -40
- package/dist/errors.d.mts +2 -40
- package/dist/errors.mjs +12 -1
- package/dist/errors.mjs.map +1 -1
- package/dist/helpers.d.cts +1 -1
- package/dist/helpers.d.mts +1 -1
- package/dist/{iii-types-BvaIabiX.cjs → iii-types-BHasLgj1.cjs} +2 -1
- package/dist/iii-types-BHasLgj1.cjs.map +1 -0
- package/dist/{iii-types-wPYrg7hX.mjs → iii-types-Btz-0RpP.mjs} +2 -1
- package/dist/iii-types-Btz-0RpP.mjs.map +1 -0
- package/dist/index.cjs +117 -14
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +25 -9
- package/dist/index.d.cts.map +1 -1
- package/dist/index.d.mts +25 -9
- package/dist/index.d.mts.map +1 -1
- package/dist/index.mjs +117 -16
- package/dist/index.mjs.map +1 -1
- package/dist/internal.d.cts +1 -1
- package/dist/internal.d.mts +1 -1
- package/dist/protocol.cjs +1 -1
- package/dist/protocol.d.cts +1 -1
- package/dist/protocol.d.mts +1 -1
- package/dist/protocol.mjs +1 -1
- package/dist/runtime.d.cts +1 -2
- package/dist/runtime.d.mts +1 -2
- package/dist/trigger.d.cts +1 -1
- package/dist/trigger.d.mts +1 -1
- package/dist/{types-BD2fp4Py.d.mts → types-HYwMK3aJ.d.cts} +88 -2
- package/dist/types-HYwMK3aJ.d.cts.map +1 -0
- package/dist/{types-n-760A15.d.cts → types-hpT5GrK4.d.mts} +88 -2
- package/dist/types-hpT5GrK4.d.mts.map +1 -0
- package/package.json +2 -2
- package/dist/errors.d.cts.map +0 -1
- package/dist/errors.d.mts.map +0 -1
- package/dist/iii-constants-Baptl8nm.d.mts +0 -47
- package/dist/iii-constants-Baptl8nm.d.mts.map +0 -1
- package/dist/iii-constants-BqXp8xSN.d.cts +0 -47
- package/dist/iii-constants-BqXp8xSN.d.cts.map +0 -1
- package/dist/iii-types-BvaIabiX.cjs.map +0 -1
- package/dist/iii-types-wPYrg7hX.mjs.map +0 -1
- package/dist/types-BD2fp4Py.d.mts.map +0 -1
- package/dist/types-n-760A15.d.cts.map +0 -1
package/dist/channel.d.cts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { C as ChannelWriter, M as StreamChannelRef, S as ChannelReader, t as Channel } from "./types-HYwMK3aJ.cjs";
|
|
2
2
|
export { type Channel, ChannelReader, ChannelWriter, type StreamChannelRef };
|
package/dist/channel.d.mts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { C as ChannelWriter, M as StreamChannelRef, S as ChannelReader, t as Channel } from "./types-hpT5GrK4.mjs";
|
|
2
2
|
export { type Channel, ChannelReader, ChannelWriter, type StreamChannelRef };
|
package/dist/engine.d.cts
CHANGED
|
@@ -1,3 +1,2 @@
|
|
|
1
|
-
import { l as RemoteFunctionHandler } from "./types-
|
|
2
|
-
import { n as EngineTriggers, t as EngineFunctions } from "./iii-constants-BqXp8xSN.cjs";
|
|
1
|
+
import { _ as EngineTriggers, g as EngineFunctions, l as RemoteFunctionHandler } from "./types-HYwMK3aJ.cjs";
|
|
3
2
|
export { EngineFunctions, EngineTriggers, type RemoteFunctionHandler };
|
package/dist/engine.d.mts
CHANGED
|
@@ -1,3 +1,2 @@
|
|
|
1
|
-
import { l as RemoteFunctionHandler } from "./types-
|
|
2
|
-
import { n as EngineTriggers, t as EngineFunctions } from "./iii-constants-Baptl8nm.mjs";
|
|
1
|
+
import { _ as EngineTriggers, g as EngineFunctions, l as RemoteFunctionHandler } from "./types-hpT5GrK4.mjs";
|
|
3
2
|
export { EngineFunctions, EngineTriggers, type RemoteFunctionHandler };
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
//#region src/errors.d.ts
|
|
2
|
+
/**
|
|
3
|
+
* Typed error surfaced when an invocation dispatched over the SDK fails, RBAC
|
|
4
|
+
* rejection (FORBIDDEN), handler-level failure, or a timeout waiting for the
|
|
5
|
+
* engine to respond. Wraps the wire `ErrorBody` shape plus the `function_id`
|
|
6
|
+
* that was targeted, so callers get a single error type across all failure
|
|
7
|
+
* modes and can disambiguate via `err.code`.
|
|
8
|
+
*
|
|
9
|
+
* Before this existed, rejection values were plain `ErrorBody`-shaped objects,
|
|
10
|
+
* which printed as `[object Object]` when stringified, leaving developers to
|
|
11
|
+
* grep through SDK source to figure out what tripped. The class name, `code`
|
|
12
|
+
* prefix in the message, and `function_id` field together make a rejection
|
|
13
|
+
* self-describing.
|
|
14
|
+
*/
|
|
15
|
+
type InvocationErrorInit = {
|
|
16
|
+
code: string;
|
|
17
|
+
message: string;
|
|
18
|
+
function_id?: string;
|
|
19
|
+
stacktrace?: string;
|
|
20
|
+
};
|
|
21
|
+
declare class InvocationError extends Error {
|
|
22
|
+
readonly code: string;
|
|
23
|
+
readonly function_id?: string;
|
|
24
|
+
readonly stacktrace?: string;
|
|
25
|
+
constructor(init: InvocationErrorInit);
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* Fatal error surfaced when the engine rejects this worker's registration with
|
|
29
|
+
* a `registrationrejected` message: another live worker already owns this
|
|
30
|
+
* registration identity in the target `namespace`. The
|
|
31
|
+
* engine closes the connection on rejection, so this is terminal -- the SDK
|
|
32
|
+
* stops the worker and does not reconnect. Carries the wire fields
|
|
33
|
+
* (`code`, `namespace`, `worker_name` or `function_id`, `owner_worker_id`) so callers can tell
|
|
34
|
+
* exactly which identity collided and with whom.
|
|
35
|
+
*/
|
|
36
|
+
type RegistrationRejectedInit = {
|
|
37
|
+
code: string;
|
|
38
|
+
namespace: string;
|
|
39
|
+
worker_name?: string;
|
|
40
|
+
function_id?: string;
|
|
41
|
+
owner_worker_id: string;
|
|
42
|
+
};
|
|
43
|
+
declare class RegistrationRejectedError extends Error {
|
|
44
|
+
readonly code: string;
|
|
45
|
+
readonly namespace: string;
|
|
46
|
+
readonly worker_name?: string;
|
|
47
|
+
readonly function_id?: string;
|
|
48
|
+
readonly owner_worker_id: string;
|
|
49
|
+
constructor(init: RegistrationRejectedInit);
|
|
50
|
+
}
|
|
51
|
+
/**
|
|
52
|
+
* True when `value` looks like the wire `ErrorBody` the engine sends in
|
|
53
|
+
* `InvocationResult.error`: `{ code: string, message: string, stacktrace?: string }`.
|
|
54
|
+
* Used to distinguish an engine rejection (which we wrap in
|
|
55
|
+
* {@link InvocationError}) from a JS `Error` thrown elsewhere.
|
|
56
|
+
*/
|
|
57
|
+
declare function isErrorBody(value: unknown): value is {
|
|
58
|
+
code: string;
|
|
59
|
+
message: string;
|
|
60
|
+
stacktrace?: string;
|
|
61
|
+
};
|
|
62
|
+
//#endregion
|
|
63
|
+
export { isErrorBody as a, RegistrationRejectedInit as i, InvocationErrorInit as n, RegistrationRejectedError as r, InvocationError as t };
|
|
64
|
+
//# sourceMappingURL=errors-BK88qe9x.d.cts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"errors-BK88qe9x.d.cts","names":[],"sources":["../src/errors.ts"],"mappings":";;AAaA;;;;;;;;;;AAOA;;KAPY,mBAAA;EACV,IAAA;EACA,OAAA;EACA,WAAA;EACA,UAAA;AAAA;AAAA,cAGW,eAAA,SAAwB,KAAA;EAAA,SACnB,IAAA;EAAA,SACA,WAAA;EAAA,SACA,UAAA;cAEJ,IAAA,EAAM,mBAAA;AAAA;;;;;;;;;;KAkBR,wBAAA;EACV,IAAA;EACA,SAAA;EACA,WAAA;EACA,WAAA;EACA,eAAA;AAAA;AAAA,cAGW,yBAAA,SAAkC,KAAA;EAAA,SAC7B,IAAA;EAAA,SACA,SAAA;EAAA,SACA,WAAA;EAAA,SACA,WAAA;EAAA,SACA,eAAA;cAEJ,IAAA,EAAM,wBAAA;AAAA;;AAmBpB;;;;;iBAAgB,WAAA,CAAY,KAAA,YAAiB,KAAA;EAC3C,IAAA;EACA,OAAA;EACA,UAAA;AAAA"}
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
//#region src/errors.d.ts
|
|
2
|
+
/**
|
|
3
|
+
* Typed error surfaced when an invocation dispatched over the SDK fails, RBAC
|
|
4
|
+
* rejection (FORBIDDEN), handler-level failure, or a timeout waiting for the
|
|
5
|
+
* engine to respond. Wraps the wire `ErrorBody` shape plus the `function_id`
|
|
6
|
+
* that was targeted, so callers get a single error type across all failure
|
|
7
|
+
* modes and can disambiguate via `err.code`.
|
|
8
|
+
*
|
|
9
|
+
* Before this existed, rejection values were plain `ErrorBody`-shaped objects,
|
|
10
|
+
* which printed as `[object Object]` when stringified, leaving developers to
|
|
11
|
+
* grep through SDK source to figure out what tripped. The class name, `code`
|
|
12
|
+
* prefix in the message, and `function_id` field together make a rejection
|
|
13
|
+
* self-describing.
|
|
14
|
+
*/
|
|
15
|
+
type InvocationErrorInit = {
|
|
16
|
+
code: string;
|
|
17
|
+
message: string;
|
|
18
|
+
function_id?: string;
|
|
19
|
+
stacktrace?: string;
|
|
20
|
+
};
|
|
21
|
+
declare class InvocationError extends Error {
|
|
22
|
+
readonly code: string;
|
|
23
|
+
readonly function_id?: string;
|
|
24
|
+
readonly stacktrace?: string;
|
|
25
|
+
constructor(init: InvocationErrorInit);
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* Fatal error surfaced when the engine rejects this worker's registration with
|
|
29
|
+
* a `registrationrejected` message: another live worker already owns this
|
|
30
|
+
* registration identity in the target `namespace`. The
|
|
31
|
+
* engine closes the connection on rejection, so this is terminal -- the SDK
|
|
32
|
+
* stops the worker and does not reconnect. Carries the wire fields
|
|
33
|
+
* (`code`, `namespace`, `worker_name` or `function_id`, `owner_worker_id`) so callers can tell
|
|
34
|
+
* exactly which identity collided and with whom.
|
|
35
|
+
*/
|
|
36
|
+
type RegistrationRejectedInit = {
|
|
37
|
+
code: string;
|
|
38
|
+
namespace: string;
|
|
39
|
+
worker_name?: string;
|
|
40
|
+
function_id?: string;
|
|
41
|
+
owner_worker_id: string;
|
|
42
|
+
};
|
|
43
|
+
declare class RegistrationRejectedError extends Error {
|
|
44
|
+
readonly code: string;
|
|
45
|
+
readonly namespace: string;
|
|
46
|
+
readonly worker_name?: string;
|
|
47
|
+
readonly function_id?: string;
|
|
48
|
+
readonly owner_worker_id: string;
|
|
49
|
+
constructor(init: RegistrationRejectedInit);
|
|
50
|
+
}
|
|
51
|
+
/**
|
|
52
|
+
* True when `value` looks like the wire `ErrorBody` the engine sends in
|
|
53
|
+
* `InvocationResult.error`: `{ code: string, message: string, stacktrace?: string }`.
|
|
54
|
+
* Used to distinguish an engine rejection (which we wrap in
|
|
55
|
+
* {@link InvocationError}) from a JS `Error` thrown elsewhere.
|
|
56
|
+
*/
|
|
57
|
+
declare function isErrorBody(value: unknown): value is {
|
|
58
|
+
code: string;
|
|
59
|
+
message: string;
|
|
60
|
+
stacktrace?: string;
|
|
61
|
+
};
|
|
62
|
+
//#endregion
|
|
63
|
+
export { isErrorBody as a, RegistrationRejectedInit as i, InvocationErrorInit as n, RegistrationRejectedError as r, InvocationError as t };
|
|
64
|
+
//# sourceMappingURL=errors-CUOlcEUP.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"errors-CUOlcEUP.d.mts","names":[],"sources":["../src/errors.ts"],"mappings":";;AAaA;;;;;;;;;;AAOA;;KAPY,mBAAA;EACV,IAAA;EACA,OAAA;EACA,WAAA;EACA,UAAA;AAAA;AAAA,cAGW,eAAA,SAAwB,KAAA;EAAA,SACnB,IAAA;EAAA,SACA,WAAA;EAAA,SACA,UAAA;cAEJ,IAAA,EAAM,mBAAA;AAAA;;;;;;;;;;KAkBR,wBAAA;EACV,IAAA;EACA,SAAA;EACA,WAAA;EACA,WAAA;EACA,eAAA;AAAA;AAAA,cAGW,yBAAA,SAAkC,KAAA;EAAA,SAC7B,IAAA;EAAA,SACA,SAAA;EAAA,SACA,WAAA;EAAA,SACA,WAAA;EAAA,SACA,eAAA;cAEJ,IAAA,EAAM,wBAAA;AAAA;;AAmBpB;;;;;iBAAgB,WAAA,CAAY,KAAA,YAAiB,KAAA;EAC3C,IAAA;EACA,OAAA;EACA,UAAA;AAAA"}
|
package/dist/errors.cjs
CHANGED
|
@@ -10,6 +10,17 @@ var InvocationError = class extends Error {
|
|
|
10
10
|
this.stacktrace = init.stacktrace;
|
|
11
11
|
}
|
|
12
12
|
};
|
|
13
|
+
var RegistrationRejectedError = class extends Error {
|
|
14
|
+
constructor(init) {
|
|
15
|
+
super(`${init.code}: registration rejected for ${init.function_id !== void 0 ? `function "${init.function_id}"` : `worker "${init.worker_name ?? "<unknown>"}"`} in namespace "${init.namespace}" (already owned by worker ${init.owner_worker_id})`);
|
|
16
|
+
this.name = "RegistrationRejectedError";
|
|
17
|
+
this.code = init.code;
|
|
18
|
+
this.namespace = init.namespace;
|
|
19
|
+
this.worker_name = init.worker_name;
|
|
20
|
+
this.function_id = init.function_id;
|
|
21
|
+
this.owner_worker_id = init.owner_worker_id;
|
|
22
|
+
}
|
|
23
|
+
};
|
|
13
24
|
/**
|
|
14
25
|
* True when `value` looks like the wire `ErrorBody` the engine sends in
|
|
15
26
|
* `InvocationResult.error`: `{ code: string, message: string, stacktrace?: string }`.
|
|
@@ -24,5 +35,6 @@ function isErrorBody(value) {
|
|
|
24
35
|
|
|
25
36
|
//#endregion
|
|
26
37
|
exports.InvocationError = InvocationError;
|
|
38
|
+
exports.RegistrationRejectedError = RegistrationRejectedError;
|
|
27
39
|
exports.isErrorBody = isErrorBody;
|
|
28
40
|
//# sourceMappingURL=errors.cjs.map
|
package/dist/errors.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"errors.cjs","names":[],"sources":["../src/errors.ts"],"sourcesContent":["/**\n * Typed error surfaced when an invocation dispatched over the SDK fails, RBAC\n * rejection (FORBIDDEN), handler-level failure, or a timeout waiting for the\n * engine to respond. Wraps the wire `ErrorBody` shape plus the `function_id`\n * that was targeted, so callers get a single error type across all failure\n * modes and can disambiguate via `err.code`.\n *\n * Before this existed, rejection values were plain `ErrorBody`-shaped objects,\n * which printed as `[object Object]` when stringified, leaving developers to\n * grep through SDK source to figure out what tripped. The class name, `code`\n * prefix in the message, and `function_id` field together make a rejection\n * self-describing.\n */\nexport type InvocationErrorInit = {\n code: string\n message: string\n function_id?: string\n stacktrace?: string\n}\n\nexport class InvocationError extends Error {\n public readonly code: string\n public readonly function_id?: string\n public readonly stacktrace?: string\n\n constructor(init: InvocationErrorInit) {\n super(`${init.code}: ${init.message}`)\n this.name = 'InvocationError'\n this.code = init.code\n this.function_id = init.function_id\n this.stacktrace = init.stacktrace\n }\n}\n\n/**\n * True when `value` looks like the wire `ErrorBody` the engine sends in\n * `InvocationResult.error`: `{ code: string, message: string, stacktrace?: string }`.\n * Used to distinguish an engine rejection (which we wrap in\n * {@link InvocationError}) from a JS `Error` thrown elsewhere.\n */\nexport function isErrorBody(value: unknown): value is {\n code: string\n message: string\n stacktrace?: string\n} {\n if (typeof value !== 'object' || value === null) return false\n const v = value as { code?: unknown; message?: unknown; stacktrace?: unknown }\n return (\n typeof v.code === 'string' &&\n typeof v.message === 'string' &&\n (v.stacktrace === undefined || typeof v.stacktrace === 'string')\n )\n}\n"],"mappings":";;;AAoBA,IAAa,kBAAb,cAAqC,MAAM;CAKzC,YAAY,MAA2B;AACrC,QAAM,GAAG,KAAK,KAAK,IAAI,KAAK,UAAU;AACtC,OAAK,OAAO;AACZ,OAAK,OAAO,KAAK;AACjB,OAAK,cAAc,KAAK;AACxB,OAAK,aAAa,KAAK;;;;;;;;;
|
|
1
|
+
{"version":3,"file":"errors.cjs","names":[],"sources":["../src/errors.ts"],"sourcesContent":["/**\n * Typed error surfaced when an invocation dispatched over the SDK fails, RBAC\n * rejection (FORBIDDEN), handler-level failure, or a timeout waiting for the\n * engine to respond. Wraps the wire `ErrorBody` shape plus the `function_id`\n * that was targeted, so callers get a single error type across all failure\n * modes and can disambiguate via `err.code`.\n *\n * Before this existed, rejection values were plain `ErrorBody`-shaped objects,\n * which printed as `[object Object]` when stringified, leaving developers to\n * grep through SDK source to figure out what tripped. The class name, `code`\n * prefix in the message, and `function_id` field together make a rejection\n * self-describing.\n */\nexport type InvocationErrorInit = {\n code: string\n message: string\n function_id?: string\n stacktrace?: string\n}\n\nexport class InvocationError extends Error {\n public readonly code: string\n public readonly function_id?: string\n public readonly stacktrace?: string\n\n constructor(init: InvocationErrorInit) {\n super(`${init.code}: ${init.message}`)\n this.name = 'InvocationError'\n this.code = init.code\n this.function_id = init.function_id\n this.stacktrace = init.stacktrace\n }\n}\n\n/**\n * Fatal error surfaced when the engine rejects this worker's registration with\n * a `registrationrejected` message: another live worker already owns this\n * registration identity in the target `namespace`. The\n * engine closes the connection on rejection, so this is terminal -- the SDK\n * stops the worker and does not reconnect. Carries the wire fields\n * (`code`, `namespace`, `worker_name` or `function_id`, `owner_worker_id`) so callers can tell\n * exactly which identity collided and with whom.\n */\nexport type RegistrationRejectedInit = {\n code: string\n namespace: string\n worker_name?: string\n function_id?: string\n owner_worker_id: string\n}\n\nexport class RegistrationRejectedError extends Error {\n public readonly code: string\n public readonly namespace: string\n public readonly worker_name?: string\n public readonly function_id?: string\n public readonly owner_worker_id: string\n\n constructor(init: RegistrationRejectedInit) {\n super(\n `${init.code}: registration rejected for ${init.function_id !== undefined ? `function \"${init.function_id}\"` : `worker \"${init.worker_name ?? '<unknown>'}\"`} in namespace \"${init.namespace}\" (already owned by worker ${init.owner_worker_id})`,\n )\n this.name = 'RegistrationRejectedError'\n this.code = init.code\n this.namespace = init.namespace\n this.worker_name = init.worker_name\n this.function_id = init.function_id\n this.owner_worker_id = init.owner_worker_id\n }\n}\n\n/**\n * True when `value` looks like the wire `ErrorBody` the engine sends in\n * `InvocationResult.error`: `{ code: string, message: string, stacktrace?: string }`.\n * Used to distinguish an engine rejection (which we wrap in\n * {@link InvocationError}) from a JS `Error` thrown elsewhere.\n */\nexport function isErrorBody(value: unknown): value is {\n code: string\n message: string\n stacktrace?: string\n} {\n if (typeof value !== 'object' || value === null) return false\n const v = value as { code?: unknown; message?: unknown; stacktrace?: unknown }\n return (\n typeof v.code === 'string' &&\n typeof v.message === 'string' &&\n (v.stacktrace === undefined || typeof v.stacktrace === 'string')\n )\n}\n"],"mappings":";;;AAoBA,IAAa,kBAAb,cAAqC,MAAM;CAKzC,YAAY,MAA2B;AACrC,QAAM,GAAG,KAAK,KAAK,IAAI,KAAK,UAAU;AACtC,OAAK,OAAO;AACZ,OAAK,OAAO,KAAK;AACjB,OAAK,cAAc,KAAK;AACxB,OAAK,aAAa,KAAK;;;AAqB3B,IAAa,4BAAb,cAA+C,MAAM;CAOnD,YAAY,MAAgC;AAC1C,QACE,GAAG,KAAK,KAAK,8BAA8B,KAAK,gBAAgB,SAAY,aAAa,KAAK,YAAY,KAAK,WAAW,KAAK,eAAe,YAAY,GAAG,iBAAiB,KAAK,UAAU,6BAA6B,KAAK,gBAAgB,GAChP;AACD,OAAK,OAAO;AACZ,OAAK,OAAO,KAAK;AACjB,OAAK,YAAY,KAAK;AACtB,OAAK,cAAc,KAAK;AACxB,OAAK,cAAc,KAAK;AACxB,OAAK,kBAAkB,KAAK;;;;;;;;;AAUhC,SAAgB,YAAY,OAI1B;AACA,KAAI,OAAO,UAAU,YAAY,UAAU,KAAM,QAAO;CACxD,MAAM,IAAI;AACV,QACE,OAAO,EAAE,SAAS,YAClB,OAAO,EAAE,YAAY,aACpB,EAAE,eAAe,UAAa,OAAO,EAAE,eAAe"}
|
package/dist/errors.d.cts
CHANGED
|
@@ -1,40 +1,2 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
* Typed error surfaced when an invocation dispatched over the SDK fails, RBAC
|
|
4
|
-
* rejection (FORBIDDEN), handler-level failure, or a timeout waiting for the
|
|
5
|
-
* engine to respond. Wraps the wire `ErrorBody` shape plus the `function_id`
|
|
6
|
-
* that was targeted, so callers get a single error type across all failure
|
|
7
|
-
* modes and can disambiguate via `err.code`.
|
|
8
|
-
*
|
|
9
|
-
* Before this existed, rejection values were plain `ErrorBody`-shaped objects,
|
|
10
|
-
* which printed as `[object Object]` when stringified, leaving developers to
|
|
11
|
-
* grep through SDK source to figure out what tripped. The class name, `code`
|
|
12
|
-
* prefix in the message, and `function_id` field together make a rejection
|
|
13
|
-
* self-describing.
|
|
14
|
-
*/
|
|
15
|
-
type InvocationErrorInit = {
|
|
16
|
-
code: string;
|
|
17
|
-
message: string;
|
|
18
|
-
function_id?: string;
|
|
19
|
-
stacktrace?: string;
|
|
20
|
-
};
|
|
21
|
-
declare class InvocationError extends Error {
|
|
22
|
-
readonly code: string;
|
|
23
|
-
readonly function_id?: string;
|
|
24
|
-
readonly stacktrace?: string;
|
|
25
|
-
constructor(init: InvocationErrorInit);
|
|
26
|
-
}
|
|
27
|
-
/**
|
|
28
|
-
* True when `value` looks like the wire `ErrorBody` the engine sends in
|
|
29
|
-
* `InvocationResult.error`: `{ code: string, message: string, stacktrace?: string }`.
|
|
30
|
-
* Used to distinguish an engine rejection (which we wrap in
|
|
31
|
-
* {@link InvocationError}) from a JS `Error` thrown elsewhere.
|
|
32
|
-
*/
|
|
33
|
-
declare function isErrorBody(value: unknown): value is {
|
|
34
|
-
code: string;
|
|
35
|
-
message: string;
|
|
36
|
-
stacktrace?: string;
|
|
37
|
-
};
|
|
38
|
-
//#endregion
|
|
39
|
-
export { InvocationError, InvocationErrorInit, isErrorBody };
|
|
40
|
-
//# sourceMappingURL=errors.d.cts.map
|
|
1
|
+
import { a as isErrorBody, i as RegistrationRejectedInit, n as InvocationErrorInit, r as RegistrationRejectedError, t as InvocationError } from "./errors-BK88qe9x.cjs";
|
|
2
|
+
export { InvocationError, InvocationErrorInit, RegistrationRejectedError, RegistrationRejectedInit, isErrorBody };
|
package/dist/errors.d.mts
CHANGED
|
@@ -1,40 +1,2 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
* Typed error surfaced when an invocation dispatched over the SDK fails, RBAC
|
|
4
|
-
* rejection (FORBIDDEN), handler-level failure, or a timeout waiting for the
|
|
5
|
-
* engine to respond. Wraps the wire `ErrorBody` shape plus the `function_id`
|
|
6
|
-
* that was targeted, so callers get a single error type across all failure
|
|
7
|
-
* modes and can disambiguate via `err.code`.
|
|
8
|
-
*
|
|
9
|
-
* Before this existed, rejection values were plain `ErrorBody`-shaped objects,
|
|
10
|
-
* which printed as `[object Object]` when stringified, leaving developers to
|
|
11
|
-
* grep through SDK source to figure out what tripped. The class name, `code`
|
|
12
|
-
* prefix in the message, and `function_id` field together make a rejection
|
|
13
|
-
* self-describing.
|
|
14
|
-
*/
|
|
15
|
-
type InvocationErrorInit = {
|
|
16
|
-
code: string;
|
|
17
|
-
message: string;
|
|
18
|
-
function_id?: string;
|
|
19
|
-
stacktrace?: string;
|
|
20
|
-
};
|
|
21
|
-
declare class InvocationError extends Error {
|
|
22
|
-
readonly code: string;
|
|
23
|
-
readonly function_id?: string;
|
|
24
|
-
readonly stacktrace?: string;
|
|
25
|
-
constructor(init: InvocationErrorInit);
|
|
26
|
-
}
|
|
27
|
-
/**
|
|
28
|
-
* True when `value` looks like the wire `ErrorBody` the engine sends in
|
|
29
|
-
* `InvocationResult.error`: `{ code: string, message: string, stacktrace?: string }`.
|
|
30
|
-
* Used to distinguish an engine rejection (which we wrap in
|
|
31
|
-
* {@link InvocationError}) from a JS `Error` thrown elsewhere.
|
|
32
|
-
*/
|
|
33
|
-
declare function isErrorBody(value: unknown): value is {
|
|
34
|
-
code: string;
|
|
35
|
-
message: string;
|
|
36
|
-
stacktrace?: string;
|
|
37
|
-
};
|
|
38
|
-
//#endregion
|
|
39
|
-
export { InvocationError, InvocationErrorInit, isErrorBody };
|
|
40
|
-
//# sourceMappingURL=errors.d.mts.map
|
|
1
|
+
import { a as isErrorBody, i as RegistrationRejectedInit, n as InvocationErrorInit, r as RegistrationRejectedError, t as InvocationError } from "./errors-CUOlcEUP.mjs";
|
|
2
|
+
export { InvocationError, InvocationErrorInit, RegistrationRejectedError, RegistrationRejectedInit, isErrorBody };
|
package/dist/errors.mjs
CHANGED
|
@@ -8,6 +8,17 @@ var InvocationError = class extends Error {
|
|
|
8
8
|
this.stacktrace = init.stacktrace;
|
|
9
9
|
}
|
|
10
10
|
};
|
|
11
|
+
var RegistrationRejectedError = class extends Error {
|
|
12
|
+
constructor(init) {
|
|
13
|
+
super(`${init.code}: registration rejected for ${init.function_id !== void 0 ? `function "${init.function_id}"` : `worker "${init.worker_name ?? "<unknown>"}"`} in namespace "${init.namespace}" (already owned by worker ${init.owner_worker_id})`);
|
|
14
|
+
this.name = "RegistrationRejectedError";
|
|
15
|
+
this.code = init.code;
|
|
16
|
+
this.namespace = init.namespace;
|
|
17
|
+
this.worker_name = init.worker_name;
|
|
18
|
+
this.function_id = init.function_id;
|
|
19
|
+
this.owner_worker_id = init.owner_worker_id;
|
|
20
|
+
}
|
|
21
|
+
};
|
|
11
22
|
/**
|
|
12
23
|
* True when `value` looks like the wire `ErrorBody` the engine sends in
|
|
13
24
|
* `InvocationResult.error`: `{ code: string, message: string, stacktrace?: string }`.
|
|
@@ -21,5 +32,5 @@ function isErrorBody(value) {
|
|
|
21
32
|
}
|
|
22
33
|
|
|
23
34
|
//#endregion
|
|
24
|
-
export { InvocationError, isErrorBody };
|
|
35
|
+
export { InvocationError, RegistrationRejectedError, isErrorBody };
|
|
25
36
|
//# sourceMappingURL=errors.mjs.map
|
package/dist/errors.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"errors.mjs","names":[],"sources":["../src/errors.ts"],"sourcesContent":["/**\n * Typed error surfaced when an invocation dispatched over the SDK fails, RBAC\n * rejection (FORBIDDEN), handler-level failure, or a timeout waiting for the\n * engine to respond. Wraps the wire `ErrorBody` shape plus the `function_id`\n * that was targeted, so callers get a single error type across all failure\n * modes and can disambiguate via `err.code`.\n *\n * Before this existed, rejection values were plain `ErrorBody`-shaped objects,\n * which printed as `[object Object]` when stringified, leaving developers to\n * grep through SDK source to figure out what tripped. The class name, `code`\n * prefix in the message, and `function_id` field together make a rejection\n * self-describing.\n */\nexport type InvocationErrorInit = {\n code: string\n message: string\n function_id?: string\n stacktrace?: string\n}\n\nexport class InvocationError extends Error {\n public readonly code: string\n public readonly function_id?: string\n public readonly stacktrace?: string\n\n constructor(init: InvocationErrorInit) {\n super(`${init.code}: ${init.message}`)\n this.name = 'InvocationError'\n this.code = init.code\n this.function_id = init.function_id\n this.stacktrace = init.stacktrace\n }\n}\n\n/**\n * True when `value` looks like the wire `ErrorBody` the engine sends in\n * `InvocationResult.error`: `{ code: string, message: string, stacktrace?: string }`.\n * Used to distinguish an engine rejection (which we wrap in\n * {@link InvocationError}) from a JS `Error` thrown elsewhere.\n */\nexport function isErrorBody(value: unknown): value is {\n code: string\n message: string\n stacktrace?: string\n} {\n if (typeof value !== 'object' || value === null) return false\n const v = value as { code?: unknown; message?: unknown; stacktrace?: unknown }\n return (\n typeof v.code === 'string' &&\n typeof v.message === 'string' &&\n (v.stacktrace === undefined || typeof v.stacktrace === 'string')\n )\n}\n"],"mappings":";AAoBA,IAAa,kBAAb,cAAqC,MAAM;CAKzC,YAAY,MAA2B;AACrC,QAAM,GAAG,KAAK,KAAK,IAAI,KAAK,UAAU;AACtC,OAAK,OAAO;AACZ,OAAK,OAAO,KAAK;AACjB,OAAK,cAAc,KAAK;AACxB,OAAK,aAAa,KAAK;;;;;;;;;
|
|
1
|
+
{"version":3,"file":"errors.mjs","names":[],"sources":["../src/errors.ts"],"sourcesContent":["/**\n * Typed error surfaced when an invocation dispatched over the SDK fails, RBAC\n * rejection (FORBIDDEN), handler-level failure, or a timeout waiting for the\n * engine to respond. Wraps the wire `ErrorBody` shape plus the `function_id`\n * that was targeted, so callers get a single error type across all failure\n * modes and can disambiguate via `err.code`.\n *\n * Before this existed, rejection values were plain `ErrorBody`-shaped objects,\n * which printed as `[object Object]` when stringified, leaving developers to\n * grep through SDK source to figure out what tripped. The class name, `code`\n * prefix in the message, and `function_id` field together make a rejection\n * self-describing.\n */\nexport type InvocationErrorInit = {\n code: string\n message: string\n function_id?: string\n stacktrace?: string\n}\n\nexport class InvocationError extends Error {\n public readonly code: string\n public readonly function_id?: string\n public readonly stacktrace?: string\n\n constructor(init: InvocationErrorInit) {\n super(`${init.code}: ${init.message}`)\n this.name = 'InvocationError'\n this.code = init.code\n this.function_id = init.function_id\n this.stacktrace = init.stacktrace\n }\n}\n\n/**\n * Fatal error surfaced when the engine rejects this worker's registration with\n * a `registrationrejected` message: another live worker already owns this\n * registration identity in the target `namespace`. The\n * engine closes the connection on rejection, so this is terminal -- the SDK\n * stops the worker and does not reconnect. Carries the wire fields\n * (`code`, `namespace`, `worker_name` or `function_id`, `owner_worker_id`) so callers can tell\n * exactly which identity collided and with whom.\n */\nexport type RegistrationRejectedInit = {\n code: string\n namespace: string\n worker_name?: string\n function_id?: string\n owner_worker_id: string\n}\n\nexport class RegistrationRejectedError extends Error {\n public readonly code: string\n public readonly namespace: string\n public readonly worker_name?: string\n public readonly function_id?: string\n public readonly owner_worker_id: string\n\n constructor(init: RegistrationRejectedInit) {\n super(\n `${init.code}: registration rejected for ${init.function_id !== undefined ? `function \"${init.function_id}\"` : `worker \"${init.worker_name ?? '<unknown>'}\"`} in namespace \"${init.namespace}\" (already owned by worker ${init.owner_worker_id})`,\n )\n this.name = 'RegistrationRejectedError'\n this.code = init.code\n this.namespace = init.namespace\n this.worker_name = init.worker_name\n this.function_id = init.function_id\n this.owner_worker_id = init.owner_worker_id\n }\n}\n\n/**\n * True when `value` looks like the wire `ErrorBody` the engine sends in\n * `InvocationResult.error`: `{ code: string, message: string, stacktrace?: string }`.\n * Used to distinguish an engine rejection (which we wrap in\n * {@link InvocationError}) from a JS `Error` thrown elsewhere.\n */\nexport function isErrorBody(value: unknown): value is {\n code: string\n message: string\n stacktrace?: string\n} {\n if (typeof value !== 'object' || value === null) return false\n const v = value as { code?: unknown; message?: unknown; stacktrace?: unknown }\n return (\n typeof v.code === 'string' &&\n typeof v.message === 'string' &&\n (v.stacktrace === undefined || typeof v.stacktrace === 'string')\n )\n}\n"],"mappings":";AAoBA,IAAa,kBAAb,cAAqC,MAAM;CAKzC,YAAY,MAA2B;AACrC,QAAM,GAAG,KAAK,KAAK,IAAI,KAAK,UAAU;AACtC,OAAK,OAAO;AACZ,OAAK,OAAO,KAAK;AACjB,OAAK,cAAc,KAAK;AACxB,OAAK,aAAa,KAAK;;;AAqB3B,IAAa,4BAAb,cAA+C,MAAM;CAOnD,YAAY,MAAgC;AAC1C,QACE,GAAG,KAAK,KAAK,8BAA8B,KAAK,gBAAgB,SAAY,aAAa,KAAK,YAAY,KAAK,WAAW,KAAK,eAAe,YAAY,GAAG,iBAAiB,KAAK,UAAU,6BAA6B,KAAK,gBAAgB,GAChP;AACD,OAAK,OAAO;AACZ,OAAK,OAAO,KAAK;AACjB,OAAK,YAAY,KAAK;AACtB,OAAK,cAAc,KAAK;AACxB,OAAK,cAAc,KAAK;AACxB,OAAK,kBAAkB,KAAK;;;;;;;;;AAUhC,SAAgB,YAAY,OAI1B;AACA,KAAI,OAAO,UAAU,YAAY,UAAU,KAAM,QAAO;CACxD,MAAM,IAAI;AACV,QACE,OAAO,EAAE,SAAS,YAClB,OAAO,EAAE,YAAY,aACpB,EAAE,eAAe,UAAa,OAAO,EAAE,eAAe"}
|
package/dist/helpers.d.cts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { M as StreamChannelRef, b as ChannelDirection, r as IIIClient, t as Channel, x as ChannelItem } from "./types-HYwMK3aJ.cjs";
|
|
2
2
|
import { IStream } from "./stream.cjs";
|
|
3
3
|
|
|
4
4
|
//#region src/utils.d.ts
|
package/dist/helpers.d.mts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { M as StreamChannelRef, b as ChannelDirection, r as IIIClient, t as Channel, x as ChannelItem } from "./types-hpT5GrK4.mjs";
|
|
2
2
|
import { IStream } from "./stream.mjs";
|
|
3
3
|
|
|
4
4
|
//#region src/utils.d.ts
|
|
@@ -11,6 +11,7 @@ let MessageType = /* @__PURE__ */ function(MessageType) {
|
|
|
11
11
|
MessageType["UnregisterTriggerType"] = "unregistertriggertype";
|
|
12
12
|
MessageType["TriggerRegistrationResult"] = "triggerregistrationresult";
|
|
13
13
|
MessageType["WorkerRegistered"] = "workerregistered";
|
|
14
|
+
MessageType["RegistrationRejected"] = "registrationrejected";
|
|
14
15
|
MessageType["Reattach"] = "reattach";
|
|
15
16
|
return MessageType;
|
|
16
17
|
}({});
|
|
@@ -22,4 +23,4 @@ Object.defineProperty(exports, 'MessageType', {
|
|
|
22
23
|
return MessageType;
|
|
23
24
|
}
|
|
24
25
|
});
|
|
25
|
-
//# sourceMappingURL=iii-types-
|
|
26
|
+
//# sourceMappingURL=iii-types-BHasLgj1.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"iii-types-BHasLgj1.cjs","names":[],"sources":["../src/iii-types.ts"],"sourcesContent":["import type { HttpInvocationConfig } from '@iii-dev/helpers/http'\n\n/**\n * Any JSON value: the TypeScript equivalent of the engine's arbitrary-JSON\n * wire values (Rust `serde_json::Value`). Used where the wire contract is\n * \"any JSON\", e.g. per-invocation `metadata`.\n */\nexport type JsonValue =\n | string\n | number\n | boolean\n | null\n | JsonValue[]\n | { [key: string]: JsonValue }\n\nexport enum MessageType {\n RegisterFunction = 'registerfunction',\n UnregisterFunction = 'unregisterfunction',\n InvokeFunction = 'invokefunction',\n InvocationResult = 'invocationresult',\n RegisterTriggerType = 'registertriggertype',\n RegisterTrigger = 'registertrigger',\n UnregisterTrigger = 'unregistertrigger',\n UnregisterTriggerType = 'unregistertriggertype',\n TriggerRegistrationResult = 'triggerregistrationresult',\n WorkerRegistered = 'workerregistered',\n RegistrationRejected = 'registrationrejected',\n Reattach = 'reattach',\n}\n\nexport type RegisterTriggerTypeMessage = {\n message_type: MessageType.RegisterTriggerType\n /** Unique identifier for the trigger type (e.g. `state`, `durable:subscriber`). */\n id: string\n /** Human-readable description of what this trigger type does. */\n description: string\n}\n\nexport type UnregisterTriggerTypeMessage = {\n message_type: MessageType.UnregisterTriggerType\n id: string\n}\n\nexport type UnregisterTriggerMessage = {\n message_type: MessageType.UnregisterTrigger\n id: string\n type?: string\n}\n\nexport type ErrorBody = {\n code: string\n message: string\n stacktrace?: string\n}\n\nexport type TriggerRegistrationResultMessage = {\n message_type: MessageType.TriggerRegistrationResult\n id: string\n type: string\n function_id: string\n error?: ErrorBody\n}\n\nexport type RegisterTriggerMessage = {\n /** Wire discriminator; always `MessageType.RegisterTrigger`. */\n message_type: MessageType.RegisterTrigger\n /** Unique trigger identifier, generated by the SDK during registration. */\n id: string\n /** Identifier of the registered trigger type this trigger uses (e.g. `storage::object-created`, `http`). */\n type: string\n /** ID of the function this trigger invokes when it fires. */\n function_id: string\n /** Trigger-type-specific configuration, matching the shape the trigger type expects. */\n config: unknown\n /** Arbitrary user-specifiable metadata supplied to the triggered handler function on every invocation. */\n metadata?: Record<string, unknown>\n /**\n * Namespace the trigger's target function resolves in. Omit for the engine's\n * default namespace, independent of this connection's namespace.\n */\n namespace?: string\n}\n\nexport type RegisterFunctionFormat = {\n /**\n * The name of the parameter.\n */\n name?: string\n /**\n * The description of the parameter.\n */\n description?: string\n /**\n * The type of the parameter.\n */\n type?: 'string' | 'number' | 'boolean' | 'object' | 'array' | 'null' | 'map' | 'integer'\n /**\n * The body of the parameter (for objects).\n */\n properties?: Record<string, unknown>\n /**\n * The items of the parameter (for arrays).\n */\n items?: unknown\n /**\n * Whether the parameter is required.\n */\n required?: string[]\n [key: string]: unknown\n}\n\nexport type RegisterFunctionMessage = {\n message_type: MessageType.RegisterFunction\n /**\n * The path of the function (use :: for namespacing, e.g. external::my_lambda).\n */\n id: string\n /**\n * The description of the function.\n */\n description?: string\n /**\n * The request format of the function.\n */\n request_format?: RegisterFunctionFormat\n /**\n * The response format of the function.\n */\n response_format?: RegisterFunctionFormat\n /**\n * Arbitrary metadata attached to the function.\n */\n metadata?: Record<string, unknown>\n /**\n * HTTP invocation config for external HTTP functions (Lambda, Cloudflare Workers, etc.).\n */\n invocation?: HttpInvocationConfig\n}\n\n/**\n * Routing action for {@link TriggerRequest}. Determines how the engine\n * handles the invocation.\n *\n * - `enqueue`: Routes through a named queue for async processing.\n * - `void`: Fire-and-forget, no response.\n */\nexport type TriggerAction = { type: 'enqueue'; queue: string } | { type: 'void' }\n\n/**\n * Input passed to the RBAC middleware function on every function invocation\n * through the RBAC port. The middleware can inspect, modify, or reject the\n * call before it reaches the target function.\n */\nexport type MiddlewareFunctionInput = {\n /** ID of the function being invoked. */\n function_id: string\n /** Payload sent by the caller. */\n payload: Record<string, unknown>\n /** Routing action, if any. */\n action?: TriggerAction\n /** Auth context returned by the auth function for this session. */\n context: Record<string, unknown>\n /**\n * Target namespace the invoke addressed; forward the call here to stay in the\n * caller's namespace. Absent → the engine's default namespace.\n */\n namespace?: string\n}\n\n/**\n * Request object passed to {@link IIIClient.trigger}.\n *\n * @typeParam TInput - Type of the payload.\n */\nexport type TriggerRequest<TInput = unknown> = {\n /** ID of the function to invoke. */\n function_id: string\n /** Input data passed to the function. */\n payload: TInput\n /** Sets how the trigger is routed. Omit for a synchronous request/response. Specify for a specific routing scheme (e.g. `TriggerAction.Enqueue()`, `TriggerAction.Void()`). */\n action?: TriggerAction\n /** Override the default invocation timeout, in milliseconds. */\n timeoutMs?: number\n /** Arbitrary user-specifiable metadata supplied to the triggered handler function on every invocation. */\n metadata?: unknown\n /**\n * Target namespace for routing. Omit to route within the engine's default\n * namespace. Serialized into the {@link InvokeFunctionMessage} `namespace`\n * field; omitted from the wire when undefined.\n */\n namespace?: string\n}\n\nexport type InvokeFunctionMessage = {\n message_type: MessageType.InvokeFunction\n /**\n * This is optional for async invocations\n */\n invocation_id?: string\n /**\n * The path of the function.\n */\n function_id: string\n /**\n * The data to pass to the function\n */\n data: unknown\n /**\n * W3C trace-context traceparent header for distributed tracing\n */\n traceparent?: string\n /**\n * W3C baggage header for cross-cutting context propagation\n */\n baggage?: string\n /**\n * Trigger action for queue routing or fire-and-forget\n */\n action?: TriggerAction\n /**\n * Optional per-invocation metadata (arbitrary JSON). Travels as a separate\n * channel from `data`. Omitted from the JSON when undefined; absence on\n * inbound means \"no metadata\" (backward compatible with older engines).\n */\n metadata?: JsonValue\n /**\n * Target namespace for routing. Optional and additive: omitted from the JSON\n * when undefined, and absence on inbound means the engine's default\n * namespace (backward compatible with older engines).\n */\n namespace?: string\n}\n\nexport type InvocationResultMessage = {\n message_type: MessageType.InvocationResult\n /**\n * The id of the invocation\n */\n invocation_id: string\n /**\n * The path of the function.\n */\n function_id: string\n result?: unknown\n error?: unknown\n /**\n * W3C trace-context traceparent header for distributed tracing\n */\n traceparent?: string\n /**\n * W3C baggage header for cross-cutting context propagation\n */\n baggage?: string\n}\n\nexport type WorkerRegisteredMessage = {\n message_type: MessageType.WorkerRegistered\n worker_id: string\n /** Secret to present in a reattach frame on reconnect; absent on older engines. */\n reattach_token?: string\n}\n\n/**\n * Sent by the engine when this worker's registration collides with a live\n * worker in `namespace`. The `code` decides severity:\n *\n * - `WORKER_NAMESPACE_CONFLICT`: another worker already holds this\n * `(namespace, worker_name)`. The engine closes the connection -- fatal: the\n * SDK stops the worker and does not reconnect.\n * - `FUNCTION_NAMESPACE_CONFLICT`: another worker already exports this one\n * `function_id`. The engine keeps the connection\n * open -- non-fatal: only that registration is refused and the worker keeps\n * serving its other functions.\n */\nexport type RegistrationRejectedMessage = {\n message_type: MessageType.RegistrationRejected\n /** Machine-readable rejection code (`WORKER_NAMESPACE_CONFLICT` | `FUNCTION_NAMESPACE_CONFLICT`). */\n code: string\n /** Namespace in which the collision occurred. */\n namespace: string\n /** Contested worker name. Present only for `WORKER_NAMESPACE_CONFLICT`. */\n worker_name?: string\n /** Contested function id. Present only for `FUNCTION_NAMESPACE_CONFLICT`. */\n function_id?: string\n /** ID of the live worker that already owns the contested identity. */\n owner_worker_id: string\n}\n\nexport type UnregisterFunctionMessage = {\n message_type: MessageType.UnregisterFunction\n id: string\n}\n\n/**\n * Serializable reference to one end of a streaming channel. Can be included\n * in invocation payloads to pass channel endpoints between workers.\n */\nexport type StreamChannelRef = {\n /** Unique channel identifier. */\n channel_id: string\n /** Access key for authentication. */\n access_key: string\n /** Whether this ref is for reading or writing. */\n direction: 'read' | 'write'\n}\n\nexport type IIIMessage =\n | RegisterFunctionMessage\n | UnregisterFunctionMessage\n | InvokeFunctionMessage\n | InvocationResultMessage\n | RegisterTriggerMessage\n | RegisterTriggerTypeMessage\n | UnregisterTriggerMessage\n | UnregisterTriggerTypeMessage\n | TriggerRegistrationResultMessage\n | WorkerRegisteredMessage\n | RegistrationRejectedMessage\n"],"mappings":";;AAeA,IAAY,cAAL;AACL;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;KACD"}
|
|
@@ -10,10 +10,11 @@ let MessageType = /* @__PURE__ */ function(MessageType) {
|
|
|
10
10
|
MessageType["UnregisterTriggerType"] = "unregistertriggertype";
|
|
11
11
|
MessageType["TriggerRegistrationResult"] = "triggerregistrationresult";
|
|
12
12
|
MessageType["WorkerRegistered"] = "workerregistered";
|
|
13
|
+
MessageType["RegistrationRejected"] = "registrationrejected";
|
|
13
14
|
MessageType["Reattach"] = "reattach";
|
|
14
15
|
return MessageType;
|
|
15
16
|
}({});
|
|
16
17
|
|
|
17
18
|
//#endregion
|
|
18
19
|
export { MessageType as t };
|
|
19
|
-
//# sourceMappingURL=iii-types-
|
|
20
|
+
//# sourceMappingURL=iii-types-Btz-0RpP.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"iii-types-Btz-0RpP.mjs","names":[],"sources":["../src/iii-types.ts"],"sourcesContent":["import type { HttpInvocationConfig } from '@iii-dev/helpers/http'\n\n/**\n * Any JSON value: the TypeScript equivalent of the engine's arbitrary-JSON\n * wire values (Rust `serde_json::Value`). Used where the wire contract is\n * \"any JSON\", e.g. per-invocation `metadata`.\n */\nexport type JsonValue =\n | string\n | number\n | boolean\n | null\n | JsonValue[]\n | { [key: string]: JsonValue }\n\nexport enum MessageType {\n RegisterFunction = 'registerfunction',\n UnregisterFunction = 'unregisterfunction',\n InvokeFunction = 'invokefunction',\n InvocationResult = 'invocationresult',\n RegisterTriggerType = 'registertriggertype',\n RegisterTrigger = 'registertrigger',\n UnregisterTrigger = 'unregistertrigger',\n UnregisterTriggerType = 'unregistertriggertype',\n TriggerRegistrationResult = 'triggerregistrationresult',\n WorkerRegistered = 'workerregistered',\n RegistrationRejected = 'registrationrejected',\n Reattach = 'reattach',\n}\n\nexport type RegisterTriggerTypeMessage = {\n message_type: MessageType.RegisterTriggerType\n /** Unique identifier for the trigger type (e.g. `state`, `durable:subscriber`). */\n id: string\n /** Human-readable description of what this trigger type does. */\n description: string\n}\n\nexport type UnregisterTriggerTypeMessage = {\n message_type: MessageType.UnregisterTriggerType\n id: string\n}\n\nexport type UnregisterTriggerMessage = {\n message_type: MessageType.UnregisterTrigger\n id: string\n type?: string\n}\n\nexport type ErrorBody = {\n code: string\n message: string\n stacktrace?: string\n}\n\nexport type TriggerRegistrationResultMessage = {\n message_type: MessageType.TriggerRegistrationResult\n id: string\n type: string\n function_id: string\n error?: ErrorBody\n}\n\nexport type RegisterTriggerMessage = {\n /** Wire discriminator; always `MessageType.RegisterTrigger`. */\n message_type: MessageType.RegisterTrigger\n /** Unique trigger identifier, generated by the SDK during registration. */\n id: string\n /** Identifier of the registered trigger type this trigger uses (e.g. `storage::object-created`, `http`). */\n type: string\n /** ID of the function this trigger invokes when it fires. */\n function_id: string\n /** Trigger-type-specific configuration, matching the shape the trigger type expects. */\n config: unknown\n /** Arbitrary user-specifiable metadata supplied to the triggered handler function on every invocation. */\n metadata?: Record<string, unknown>\n /**\n * Namespace the trigger's target function resolves in. Omit for the engine's\n * default namespace, independent of this connection's namespace.\n */\n namespace?: string\n}\n\nexport type RegisterFunctionFormat = {\n /**\n * The name of the parameter.\n */\n name?: string\n /**\n * The description of the parameter.\n */\n description?: string\n /**\n * The type of the parameter.\n */\n type?: 'string' | 'number' | 'boolean' | 'object' | 'array' | 'null' | 'map' | 'integer'\n /**\n * The body of the parameter (for objects).\n */\n properties?: Record<string, unknown>\n /**\n * The items of the parameter (for arrays).\n */\n items?: unknown\n /**\n * Whether the parameter is required.\n */\n required?: string[]\n [key: string]: unknown\n}\n\nexport type RegisterFunctionMessage = {\n message_type: MessageType.RegisterFunction\n /**\n * The path of the function (use :: for namespacing, e.g. external::my_lambda).\n */\n id: string\n /**\n * The description of the function.\n */\n description?: string\n /**\n * The request format of the function.\n */\n request_format?: RegisterFunctionFormat\n /**\n * The response format of the function.\n */\n response_format?: RegisterFunctionFormat\n /**\n * Arbitrary metadata attached to the function.\n */\n metadata?: Record<string, unknown>\n /**\n * HTTP invocation config for external HTTP functions (Lambda, Cloudflare Workers, etc.).\n */\n invocation?: HttpInvocationConfig\n}\n\n/**\n * Routing action for {@link TriggerRequest}. Determines how the engine\n * handles the invocation.\n *\n * - `enqueue`: Routes through a named queue for async processing.\n * - `void`: Fire-and-forget, no response.\n */\nexport type TriggerAction = { type: 'enqueue'; queue: string } | { type: 'void' }\n\n/**\n * Input passed to the RBAC middleware function on every function invocation\n * through the RBAC port. The middleware can inspect, modify, or reject the\n * call before it reaches the target function.\n */\nexport type MiddlewareFunctionInput = {\n /** ID of the function being invoked. */\n function_id: string\n /** Payload sent by the caller. */\n payload: Record<string, unknown>\n /** Routing action, if any. */\n action?: TriggerAction\n /** Auth context returned by the auth function for this session. */\n context: Record<string, unknown>\n /**\n * Target namespace the invoke addressed; forward the call here to stay in the\n * caller's namespace. Absent → the engine's default namespace.\n */\n namespace?: string\n}\n\n/**\n * Request object passed to {@link IIIClient.trigger}.\n *\n * @typeParam TInput - Type of the payload.\n */\nexport type TriggerRequest<TInput = unknown> = {\n /** ID of the function to invoke. */\n function_id: string\n /** Input data passed to the function. */\n payload: TInput\n /** Sets how the trigger is routed. Omit for a synchronous request/response. Specify for a specific routing scheme (e.g. `TriggerAction.Enqueue()`, `TriggerAction.Void()`). */\n action?: TriggerAction\n /** Override the default invocation timeout, in milliseconds. */\n timeoutMs?: number\n /** Arbitrary user-specifiable metadata supplied to the triggered handler function on every invocation. */\n metadata?: unknown\n /**\n * Target namespace for routing. Omit to route within the engine's default\n * namespace. Serialized into the {@link InvokeFunctionMessage} `namespace`\n * field; omitted from the wire when undefined.\n */\n namespace?: string\n}\n\nexport type InvokeFunctionMessage = {\n message_type: MessageType.InvokeFunction\n /**\n * This is optional for async invocations\n */\n invocation_id?: string\n /**\n * The path of the function.\n */\n function_id: string\n /**\n * The data to pass to the function\n */\n data: unknown\n /**\n * W3C trace-context traceparent header for distributed tracing\n */\n traceparent?: string\n /**\n * W3C baggage header for cross-cutting context propagation\n */\n baggage?: string\n /**\n * Trigger action for queue routing or fire-and-forget\n */\n action?: TriggerAction\n /**\n * Optional per-invocation metadata (arbitrary JSON). Travels as a separate\n * channel from `data`. Omitted from the JSON when undefined; absence on\n * inbound means \"no metadata\" (backward compatible with older engines).\n */\n metadata?: JsonValue\n /**\n * Target namespace for routing. Optional and additive: omitted from the JSON\n * when undefined, and absence on inbound means the engine's default\n * namespace (backward compatible with older engines).\n */\n namespace?: string\n}\n\nexport type InvocationResultMessage = {\n message_type: MessageType.InvocationResult\n /**\n * The id of the invocation\n */\n invocation_id: string\n /**\n * The path of the function.\n */\n function_id: string\n result?: unknown\n error?: unknown\n /**\n * W3C trace-context traceparent header for distributed tracing\n */\n traceparent?: string\n /**\n * W3C baggage header for cross-cutting context propagation\n */\n baggage?: string\n}\n\nexport type WorkerRegisteredMessage = {\n message_type: MessageType.WorkerRegistered\n worker_id: string\n /** Secret to present in a reattach frame on reconnect; absent on older engines. */\n reattach_token?: string\n}\n\n/**\n * Sent by the engine when this worker's registration collides with a live\n * worker in `namespace`. The `code` decides severity:\n *\n * - `WORKER_NAMESPACE_CONFLICT`: another worker already holds this\n * `(namespace, worker_name)`. The engine closes the connection -- fatal: the\n * SDK stops the worker and does not reconnect.\n * - `FUNCTION_NAMESPACE_CONFLICT`: another worker already exports this one\n * `function_id`. The engine keeps the connection\n * open -- non-fatal: only that registration is refused and the worker keeps\n * serving its other functions.\n */\nexport type RegistrationRejectedMessage = {\n message_type: MessageType.RegistrationRejected\n /** Machine-readable rejection code (`WORKER_NAMESPACE_CONFLICT` | `FUNCTION_NAMESPACE_CONFLICT`). */\n code: string\n /** Namespace in which the collision occurred. */\n namespace: string\n /** Contested worker name. Present only for `WORKER_NAMESPACE_CONFLICT`. */\n worker_name?: string\n /** Contested function id. Present only for `FUNCTION_NAMESPACE_CONFLICT`. */\n function_id?: string\n /** ID of the live worker that already owns the contested identity. */\n owner_worker_id: string\n}\n\nexport type UnregisterFunctionMessage = {\n message_type: MessageType.UnregisterFunction\n id: string\n}\n\n/**\n * Serializable reference to one end of a streaming channel. Can be included\n * in invocation payloads to pass channel endpoints between workers.\n */\nexport type StreamChannelRef = {\n /** Unique channel identifier. */\n channel_id: string\n /** Access key for authentication. */\n access_key: string\n /** Whether this ref is for reading or writing. */\n direction: 'read' | 'write'\n}\n\nexport type IIIMessage =\n | RegisterFunctionMessage\n | UnregisterFunctionMessage\n | InvokeFunctionMessage\n | InvocationResultMessage\n | RegisterTriggerMessage\n | RegisterTriggerTypeMessage\n | UnregisterTriggerMessage\n | UnregisterTriggerTypeMessage\n | TriggerRegistrationResultMessage\n | WorkerRegisteredMessage\n | RegistrationRejectedMessage\n"],"mappings":";AAeA,IAAY,cAAL;AACL;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;KACD"}
|