@oatscenter/trellis 0.100.0-rc.1
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/README.md +59 -0
- package/auth/authorization/client_context.d.ts +61 -0
- package/auth/authorization/client_context.js +266 -0
- package/auth/authorization/nats_registry.d.ts +41 -0
- package/auth/authorization/nats_registry.js +283 -0
- package/auth/authorization/provider_cache.d.ts +90 -0
- package/auth/authorization/provider_cache.js +783 -0
- package/auth/authorization/refresh.d.ts +46 -0
- package/auth/authorization/refresh.js +246 -0
- package/auth/authorization/types.d.ts +207 -0
- package/auth/authorization/types.js +60 -0
- package/auth/authorization_context.d.ts +11 -0
- package/auth/authorization_context.js +10 -0
- package/auth/browser/flow_types.d.ts +84 -0
- package/auth/browser/flow_types.js +70 -0
- package/auth/browser/portal.d.ts +21 -0
- package/auth/browser/portal.js +307 -0
- package/auth/browser/storage.d.ts +26 -0
- package/auth/browser/storage.js +224 -0
- package/auth/browser.d.ts +11 -0
- package/auth/browser.js +10 -0
- package/auth/browser_recovery.d.ts +13 -0
- package/auth/browser_recovery.js +38 -0
- package/auth/device_activation.d.ts +134 -0
- package/auth/device_activation.js +376 -0
- package/auth/http_error.d.ts +12 -0
- package/auth/http_error.js +32 -0
- package/auth/keys.d.ts +5 -0
- package/auth/keys.js +63 -0
- package/auth/mod.d.ts +16 -0
- package/auth/mod.js +16 -0
- package/auth/proof.d.ts +31 -0
- package/auth/proof.js +95 -0
- package/auth/protocol_wasm/trellis_protocol_wasm.d.ts +138 -0
- package/auth/protocol_wasm/trellis_protocol_wasm.js +605 -0
- package/auth/protocol_wasm/trellis_protocol_wasm_bg.wasm +0 -0
- package/auth/protocol_wasm/trellis_protocol_wasm_bytes.d.ts +1 -0
- package/auth/protocol_wasm/trellis_protocol_wasm_bytes.js +2 -0
- package/auth/protocol_wasm.d.ts +179 -0
- package/auth/protocol_wasm.js +133 -0
- package/auth/session_auth.d.ts +30 -0
- package/auth/session_auth.js +77 -0
- package/auth/session_proof.d.ts +53 -0
- package/auth/session_proof.js +43 -0
- package/auth/time.d.ts +6 -0
- package/auth/time.js +7 -0
- package/auth/trellis_id.d.ts +1 -0
- package/auth/trellis_id.js +5 -0
- package/auth/utils.d.ts +10 -0
- package/auth/utils.js +69 -0
- package/auth.d.ts +1 -0
- package/auth.js +1 -0
- package/caller.d.ts +111 -0
- package/caller.js +85 -0
- package/client.d.ts +14 -0
- package/client.js +1 -0
- package/client_connect.d.ts +143 -0
- package/client_connect.js +1097 -0
- package/codec.d.ts +13 -0
- package/codec.js +192 -0
- package/connection.d.ts +107 -0
- package/connection.js +396 -0
- package/device/activation.d.ts +42 -0
- package/device/activation.js +319 -0
- package/device.d.ts +80 -0
- package/device.js +687 -0
- package/env.d.ts +2 -0
- package/env.js +10 -0
- package/errors/AuthError.d.ts +30 -0
- package/errors/AuthError.js +34 -0
- package/errors/KVError.d.ts +30 -0
- package/errors/KVError.js +36 -0
- package/errors/OperationLifecycleError.d.ts +110 -0
- package/errors/OperationLifecycleError.js +142 -0
- package/errors/RemoteError.d.ts +61 -0
- package/errors/RemoteError.js +72 -0
- package/errors/SchemaValidationError.d.ts +48 -0
- package/errors/SchemaValidationError.js +49 -0
- package/errors/StoreError.d.ts +21 -0
- package/errors/StoreError.js +31 -0
- package/errors/TransferError.d.ts +21 -0
- package/errors/TransferError.js +31 -0
- package/errors/TransportError.d.ts +29 -0
- package/errors/TransportError.js +33 -0
- package/errors/TrellisError.d.ts +15 -0
- package/errors/TrellisError.js +15 -0
- package/errors/ValidationError.d.ts +50 -0
- package/errors/ValidationError.js +59 -0
- package/errors/index.d.ts +254 -0
- package/errors/index.js +238 -0
- package/generated.d.ts +4 -0
- package/generated.js +3 -0
- package/generated_support.d.ts +120 -0
- package/generated_support.js +359 -0
- package/globals.d.ts +9 -0
- package/globals.js +16 -0
- package/health_transport.d.ts +18 -0
- package/health_transport.js +32 -0
- package/helpers.d.ts +11 -0
- package/helpers.js +53 -0
- package/index.d.ts +2 -0
- package/index.js +2 -0
- package/internal_sdk/generated/apis/auth/mod.d.ts +805 -0
- package/internal_sdk/generated/apis/auth/mod.js +958 -0
- package/internal_sdk/generated/apis/core/mod.d.ts +79 -0
- package/internal_sdk/generated/apis/core/mod.js +93 -0
- package/internal_sdk/generated/apis/events/mod.d.ts +224 -0
- package/internal_sdk/generated/apis/events/mod.js +313 -0
- package/internal_sdk/generated/apis/health/mod.d.ts +106 -0
- package/internal_sdk/generated/apis/health/mod.js +132 -0
- package/internal_sdk/generated/apis/index.d.ts +7 -0
- package/internal_sdk/generated/apis/index.js +8 -0
- package/internal_sdk/generated/apis/jobs/mod.d.ts +176 -0
- package/internal_sdk/generated/apis/jobs/mod.js +209 -0
- package/internal_sdk/generated/apis/state/mod.d.ts +104 -0
- package/internal_sdk/generated/apis/state/mod.js +139 -0
- package/internal_sdk/generated/index.d.ts +4 -0
- package/internal_sdk/generated/index.js +5 -0
- package/internal_sdk/generated/package.json +18 -0
- package/internal_sdk/generated/participants/cli/mod.d.ts +402 -0
- package/internal_sdk/generated/participants/cli/mod.js +460 -0
- package/internal_sdk/generated/participants/cli/types.d.ts +2 -0
- package/internal_sdk/generated/participants/cli/types.js +3 -0
- package/internal_sdk/generated/participants/console/mod.d.ts +489 -0
- package/internal_sdk/generated/participants/console/mod.js +579 -0
- package/internal_sdk/generated/participants/console/types.d.ts +2 -0
- package/internal_sdk/generated/participants/console/types.js +3 -0
- package/internal_sdk/generated/participants/eventsRuntime/mod.d.ts +64 -0
- package/internal_sdk/generated/participants/eventsRuntime/mod.js +42 -0
- package/internal_sdk/generated/participants/eventsRuntime/types.d.ts +2 -0
- package/internal_sdk/generated/participants/eventsRuntime/types.js +3 -0
- package/internal_sdk/generated/participants/healthRuntime/mod.d.ts +58 -0
- package/internal_sdk/generated/participants/healthRuntime/mod.js +36 -0
- package/internal_sdk/generated/participants/healthRuntime/types.d.ts +2 -0
- package/internal_sdk/generated/participants/healthRuntime/types.js +3 -0
- package/internal_sdk/generated/participants/index.d.ts +8 -0
- package/internal_sdk/generated/participants/index.js +9 -0
- package/internal_sdk/generated/participants/jobsRuntime/mod.d.ts +64 -0
- package/internal_sdk/generated/participants/jobsRuntime/mod.js +42 -0
- package/internal_sdk/generated/participants/jobsRuntime/types.d.ts +2 -0
- package/internal_sdk/generated/participants/jobsRuntime/types.js +3 -0
- package/internal_sdk/generated/participants/platform/mod.d.ts +164 -0
- package/internal_sdk/generated/participants/platform/mod.js +149 -0
- package/internal_sdk/generated/participants/platform/types.d.ts +7 -0
- package/internal_sdk/generated/participants/platform/types.js +5 -0
- package/internal_sdk/generated/participants/portal/mod.d.ts +131 -0
- package/internal_sdk/generated/participants/portal/mod.js +109 -0
- package/internal_sdk/generated/participants/portal/types.d.ts +2 -0
- package/internal_sdk/generated/participants/portal/types.js +3 -0
- package/internal_sdk/generated/types/_internal/p0.d.ts +13511 -0
- package/internal_sdk/generated/types/_internal/p0.js +6105 -0
- package/internal_sdk/generated/types/index.d.ts +2951 -0
- package/internal_sdk/generated/types/index.js +1477 -0
- package/jobs.d.ts +309 -0
- package/jobs.js +389 -0
- package/kv.d.ts +85 -0
- package/kv.js +330 -0
- package/operations.d.ts +189 -0
- package/operations.js +847 -0
- package/package.json +73 -0
- package/pagination.d.ts +25 -0
- package/pagination.js +117 -0
- package/participant.d.ts +6 -0
- package/participant.js +6 -0
- package/participant_runtime/api.d.ts +131 -0
- package/participant_runtime/api.js +42 -0
- package/participant_runtime/json.d.ts +16 -0
- package/participant_runtime/json.js +193 -0
- package/participant_runtime/metadata.d.ts +34 -0
- package/participant_runtime/metadata.js +4 -0
- package/participant_runtime/participant.d.ts +200 -0
- package/participant_runtime/participant.js +330 -0
- package/participant_runtime/schemas.d.ts +347 -0
- package/participant_runtime/schemas.js +211 -0
- package/participant_runtime/surface_names.d.ts +16 -0
- package/participant_runtime/surface_names.js +34 -0
- package/portable.d.ts +30 -0
- package/portable.js +14 -0
- package/provider.d.ts +69 -0
- package/provider.js +68 -0
- package/runtime_transport.d.ts +25 -0
- package/runtime_transport.js +48 -0
- package/service/mod.d.ts +14 -0
- package/service/mod.js +13 -0
- package/service/outbox_inbox.d.ts +259 -0
- package/service/outbox_inbox.js +908 -0
- package/service/runtime/bootstrap.d.ts +56 -0
- package/service/runtime/bootstrap.js +226 -0
- package/service/runtime/core.d.ts +46 -0
- package/service/runtime/core.js +1747 -0
- package/service/runtime/health.d.ts +97 -0
- package/service/runtime/health.js +153 -0
- package/service/runtime/health_schemas.d.ts +23 -0
- package/service/runtime/health_schemas.js +20 -0
- package/service/runtime/internal_jobs/active-job.d.ts +40 -0
- package/service/runtime/internal_jobs/active-job.js +91 -0
- package/service/runtime/internal_jobs/bindings.d.ts +40 -0
- package/service/runtime/internal_jobs/bindings.js +1 -0
- package/service/runtime/internal_jobs/cancellation-registry.d.ts +13 -0
- package/service/runtime/internal_jobs/cancellation-registry.js +55 -0
- package/service/runtime/internal_jobs/heartbeat.d.ts +33 -0
- package/service/runtime/internal_jobs/heartbeat.js +65 -0
- package/service/runtime/internal_jobs/job-manager.d.ts +126 -0
- package/service/runtime/internal_jobs/job-manager.js +821 -0
- package/service/runtime/internal_jobs/key-coordinator.d.ts +280 -0
- package/service/runtime/internal_jobs/key-coordinator.js +747 -0
- package/service/runtime/internal_jobs/projection.d.ts +3 -0
- package/service/runtime/internal_jobs/projection.js +42 -0
- package/service/runtime/internal_jobs/runtime-worker.d.ts +126 -0
- package/service/runtime/internal_jobs/runtime-worker.js +454 -0
- package/service/runtime/internal_jobs/types.d.ts +246 -0
- package/service/runtime/internal_jobs/types.js +163 -0
- package/service/runtime/logger.d.ts +2 -0
- package/service/runtime/logger.js +7 -0
- package/service/runtime/runtime.d.ts +16 -0
- package/service/runtime/runtime.js +1 -0
- package/service/runtime/service.d.ts +372 -0
- package/service/runtime/service.js +1896 -0
- package/service/runtime/transfer/download.d.ts +27 -0
- package/service/runtime/transfer/download.js +1 -0
- package/service/runtime/transfer/protocol.d.ts +15 -0
- package/service/runtime/transfer/protocol.js +46 -0
- package/service/runtime/transfer/queue.d.ts +18 -0
- package/service/runtime/transfer/queue.js +136 -0
- package/service/runtime/transfer/upload.d.ts +40 -0
- package/service/runtime/transfer/upload.js +27 -0
- package/service/runtime/transfer.d.ts +62 -0
- package/service/runtime/transfer.js +763 -0
- package/session.d.ts +862 -0
- package/session.js +3407 -0
- package/store.d.ts +71 -0
- package/store.js +412 -0
- package/store_entry.d.ts +20 -0
- package/store_entry.js +75 -0
- package/tasks.d.ts +10 -0
- package/tasks.js +28 -0
- package/telemetry/carrier.d.ts +8 -0
- package/telemetry/carrier.js +20 -0
- package/telemetry/core.d.ts +7 -0
- package/telemetry/core.js +14 -0
- package/telemetry/env.d.ts +2 -0
- package/telemetry/env.js +10 -0
- package/telemetry/init.d.ts +2 -0
- package/telemetry/init.js +7 -0
- package/telemetry/metrics.d.ts +81 -0
- package/telemetry/metrics.js +267 -0
- package/telemetry/mod.d.ts +13 -0
- package/telemetry/mod.js +8 -0
- package/telemetry/nats.d.ts +6 -0
- package/telemetry/nats.js +6 -0
- package/telemetry/result.d.ts +1 -0
- package/telemetry/result.js +18 -0
- package/telemetry/runtime.d.ts +1 -0
- package/telemetry/runtime.js +141 -0
- package/telemetry/trace.d.ts +4 -0
- package/telemetry/trace.js +26 -0
- package/telemetry/trellis.d.ts +1 -0
- package/telemetry/trellis.js +1 -0
- package/telemetry.d.ts +1 -0
- package/telemetry.js +1 -0
- package/transfer.d.ts +112 -0
- package/transfer.js +525 -0
- package/transfer_protocol.d.ts +1 -0
- package/transfer_protocol.js +13 -0
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import Type, { type Static } from "typebox";
|
|
2
|
+
import { TrellisError } from "./TrellisError.ts";
|
|
3
|
+
export declare const TransferErrorDataSchema: Type.TObject<{
|
|
4
|
+
id: Type.TString;
|
|
5
|
+
type: Type.TLiteral<"TransferError">;
|
|
6
|
+
message: Type.TString;
|
|
7
|
+
operation: Type.TOptional<Type.TString>;
|
|
8
|
+
context: Type.TOptional<Type.TRecord<"^.*$", Type.TUnknown>>;
|
|
9
|
+
traceId: Type.TOptional<Type.TString>;
|
|
10
|
+
}>;
|
|
11
|
+
export type TransferErrorData = Static<typeof TransferErrorDataSchema>;
|
|
12
|
+
export declare class TransferError extends TrellisError<TransferErrorData> {
|
|
13
|
+
readonly name: "TransferError";
|
|
14
|
+
readonly operation?: string;
|
|
15
|
+
constructor(options: ErrorOptions & {
|
|
16
|
+
operation?: string;
|
|
17
|
+
context?: Record<string, unknown>;
|
|
18
|
+
id?: string;
|
|
19
|
+
});
|
|
20
|
+
toSerializable(): TransferErrorData;
|
|
21
|
+
}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import Type, {} from "typebox";
|
|
2
|
+
import { TrellisError } from "./TrellisError.js";
|
|
3
|
+
export const TransferErrorDataSchema = Type.Object({
|
|
4
|
+
id: Type.String(),
|
|
5
|
+
type: Type.Literal("TransferError"),
|
|
6
|
+
message: Type.String(),
|
|
7
|
+
operation: Type.Optional(Type.String()),
|
|
8
|
+
context: Type.Optional(Type.Record(Type.String(), Type.Unknown())),
|
|
9
|
+
traceId: Type.Optional(Type.String()),
|
|
10
|
+
});
|
|
11
|
+
export class TransferError extends TrellisError {
|
|
12
|
+
name = "TransferError";
|
|
13
|
+
operation;
|
|
14
|
+
constructor(options) {
|
|
15
|
+
const { operation, ...baseOptions } = options;
|
|
16
|
+
const message = `Transfer ${operation || "operation"} failed`;
|
|
17
|
+
super(message, baseOptions);
|
|
18
|
+
this.operation = operation;
|
|
19
|
+
}
|
|
20
|
+
toSerializable() {
|
|
21
|
+
const base = this.baseSerializable();
|
|
22
|
+
return {
|
|
23
|
+
id: base.id,
|
|
24
|
+
type: this.name,
|
|
25
|
+
message: base.message,
|
|
26
|
+
...(this.operation !== undefined ? { operation: this.operation } : {}),
|
|
27
|
+
...(base.context !== undefined ? { context: base.context } : {}),
|
|
28
|
+
...(base.traceId !== undefined ? { traceId: base.traceId } : {}),
|
|
29
|
+
};
|
|
30
|
+
}
|
|
31
|
+
}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import Type, { type Static } from "typebox";
|
|
2
|
+
import { TrellisError } from "./TrellisError.ts";
|
|
3
|
+
export declare const TransportErrorDataSchema: Type.TObject<{
|
|
4
|
+
id: Type.TString;
|
|
5
|
+
type: Type.TLiteral<"TransportError">;
|
|
6
|
+
message: Type.TString;
|
|
7
|
+
code: Type.TString;
|
|
8
|
+
hint: Type.TString;
|
|
9
|
+
context: Type.TOptional<Type.TRecord<"^.*$", Type.TUnknown>>;
|
|
10
|
+
traceId: Type.TOptional<Type.TString>;
|
|
11
|
+
}>;
|
|
12
|
+
export type TransportErrorData = Static<typeof TransportErrorDataSchema>;
|
|
13
|
+
/**
|
|
14
|
+
* Error for Trellis runtime transport failures.
|
|
15
|
+
*/
|
|
16
|
+
export declare class TransportError extends TrellisError<TransportErrorData> {
|
|
17
|
+
readonly name: "TransportError";
|
|
18
|
+
readonly code: string;
|
|
19
|
+
readonly hint: string;
|
|
20
|
+
constructor(options: ErrorOptions & {
|
|
21
|
+
code: string;
|
|
22
|
+
message: string;
|
|
23
|
+
hint: string;
|
|
24
|
+
context?: Record<string, unknown>;
|
|
25
|
+
id?: string;
|
|
26
|
+
traceId?: string;
|
|
27
|
+
});
|
|
28
|
+
toSerializable(): TransportErrorData;
|
|
29
|
+
}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import Type, {} from "typebox";
|
|
2
|
+
import { TrellisError } from "./TrellisError.js";
|
|
3
|
+
export const TransportErrorDataSchema = Type.Object({
|
|
4
|
+
id: Type.String(),
|
|
5
|
+
type: Type.Literal("TransportError"),
|
|
6
|
+
message: Type.String(),
|
|
7
|
+
code: Type.String(),
|
|
8
|
+
hint: Type.String(),
|
|
9
|
+
context: Type.Optional(Type.Record(Type.String(), Type.Unknown())),
|
|
10
|
+
traceId: Type.Optional(Type.String()),
|
|
11
|
+
});
|
|
12
|
+
/**
|
|
13
|
+
* Error for Trellis runtime transport failures.
|
|
14
|
+
*/
|
|
15
|
+
export class TransportError extends TrellisError {
|
|
16
|
+
name = "TransportError";
|
|
17
|
+
code;
|
|
18
|
+
hint;
|
|
19
|
+
constructor(options) {
|
|
20
|
+
const { code, message, hint, ...baseOptions } = options;
|
|
21
|
+
super(message, baseOptions);
|
|
22
|
+
this.code = code;
|
|
23
|
+
this.hint = hint;
|
|
24
|
+
}
|
|
25
|
+
toSerializable() {
|
|
26
|
+
return {
|
|
27
|
+
...this.baseSerializable(),
|
|
28
|
+
type: this.name,
|
|
29
|
+
code: this.code,
|
|
30
|
+
hint: this.hint,
|
|
31
|
+
};
|
|
32
|
+
}
|
|
33
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Base class for all Trellis-specific errors.
|
|
3
|
+
* Extends BaseError and relies on the traceId getter being configured via initTelemetry.
|
|
4
|
+
*/
|
|
5
|
+
import { BaseError, type BaseErrorSchema } from "@oatscenter/result";
|
|
6
|
+
/**
|
|
7
|
+
* Abstract base class for Trellis errors.
|
|
8
|
+
* Trellis errors automatically include traceId when initTelemetry() has been called
|
|
9
|
+
* and a span is active in the current context.
|
|
10
|
+
*
|
|
11
|
+
* The traceId integration is configured by the telemetry module's initTelemetry() function,
|
|
12
|
+
* which sets up BaseError.traceIdGetter to retrieve the traceId from the active span.
|
|
13
|
+
*/
|
|
14
|
+
export declare abstract class TrellisError<TData extends BaseErrorSchema = BaseErrorSchema> extends BaseError<TData> {
|
|
15
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Base class for all Trellis-specific errors.
|
|
3
|
+
* Extends BaseError and relies on the traceId getter being configured via initTelemetry.
|
|
4
|
+
*/
|
|
5
|
+
import { BaseError } from "@oatscenter/result";
|
|
6
|
+
/**
|
|
7
|
+
* Abstract base class for Trellis errors.
|
|
8
|
+
* Trellis errors automatically include traceId when initTelemetry() has been called
|
|
9
|
+
* and a span is active in the current context.
|
|
10
|
+
*
|
|
11
|
+
* The traceId integration is configured by the telemetry module's initTelemetry() function,
|
|
12
|
+
* which sets up BaseError.traceIdGetter to retrieve the traceId from the active span.
|
|
13
|
+
*/
|
|
14
|
+
export class TrellisError extends BaseError {
|
|
15
|
+
}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import type { TLocalizedValidationError } from "typebox/error";
|
|
2
|
+
import Type, { type Static } from "typebox";
|
|
3
|
+
import { TrellisError } from "./TrellisError.ts";
|
|
4
|
+
export type ValidationErrorInput = TLocalizedValidationError | {
|
|
5
|
+
path: string;
|
|
6
|
+
message: string;
|
|
7
|
+
};
|
|
8
|
+
/**
|
|
9
|
+
* Schema for validation issue in ValidationError.
|
|
10
|
+
*/
|
|
11
|
+
export declare const ValidationIssueSchema: Type.TObject<{
|
|
12
|
+
path: Type.TString;
|
|
13
|
+
message: Type.TString;
|
|
14
|
+
}>;
|
|
15
|
+
export type ValidationIssue = Static<typeof ValidationIssueSchema>;
|
|
16
|
+
/**
|
|
17
|
+
* Schema for ValidationError serialization.
|
|
18
|
+
*/
|
|
19
|
+
export declare const ValidationErrorDataSchema: Type.TObject<{
|
|
20
|
+
id: Type.TString;
|
|
21
|
+
type: Type.TLiteral<"ValidationError">;
|
|
22
|
+
message: Type.TString;
|
|
23
|
+
issues: Type.TArray<Type.TObject<{
|
|
24
|
+
path: Type.TString;
|
|
25
|
+
message: Type.TString;
|
|
26
|
+
}>>;
|
|
27
|
+
context: Type.TOptional<Type.TRecord<"^.*$", Type.TUnknown>>;
|
|
28
|
+
traceId: Type.TOptional<Type.TString>;
|
|
29
|
+
}>;
|
|
30
|
+
export type ValidationErrorData = Static<typeof ValidationErrorDataSchema>;
|
|
31
|
+
/**
|
|
32
|
+
* Error for data validation failures.
|
|
33
|
+
* Includes schema validation and missing required data.
|
|
34
|
+
*/
|
|
35
|
+
export declare class ValidationError extends TrellisError<ValidationErrorData> {
|
|
36
|
+
#private;
|
|
37
|
+
readonly name: "ValidationError";
|
|
38
|
+
constructor(options: ErrorOptions & {
|
|
39
|
+
errors: Iterable<ValidationErrorInput>;
|
|
40
|
+
context?: Record<string, unknown>;
|
|
41
|
+
id?: string;
|
|
42
|
+
});
|
|
43
|
+
/**
|
|
44
|
+
* Serializes error to a plain object.
|
|
45
|
+
* Transforms internal errors array to issues array for serialization.
|
|
46
|
+
*
|
|
47
|
+
* @returns Plain object representation of the error
|
|
48
|
+
*/
|
|
49
|
+
toSerializable(): ValidationErrorData;
|
|
50
|
+
}
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import Type, {} from "typebox";
|
|
2
|
+
import { TrellisError } from "./TrellisError.js";
|
|
3
|
+
function normalizeError(e) {
|
|
4
|
+
if ("schemaPath" in e) {
|
|
5
|
+
return { schemaPath: e.schemaPath, message: e.message ?? "Invalid value" };
|
|
6
|
+
}
|
|
7
|
+
return { schemaPath: e.path, message: e.message };
|
|
8
|
+
}
|
|
9
|
+
/**
|
|
10
|
+
* Schema for validation issue in ValidationError.
|
|
11
|
+
*/
|
|
12
|
+
export const ValidationIssueSchema = Type.Object({
|
|
13
|
+
path: Type.String(),
|
|
14
|
+
message: Type.String(),
|
|
15
|
+
});
|
|
16
|
+
/**
|
|
17
|
+
* Schema for ValidationError serialization.
|
|
18
|
+
*/
|
|
19
|
+
export const ValidationErrorDataSchema = Type.Object({
|
|
20
|
+
id: Type.String(),
|
|
21
|
+
type: Type.Literal("ValidationError"),
|
|
22
|
+
message: Type.String(),
|
|
23
|
+
issues: Type.Array(ValidationIssueSchema),
|
|
24
|
+
context: Type.Optional(Type.Record(Type.String(), Type.Unknown())),
|
|
25
|
+
traceId: Type.Optional(Type.String()),
|
|
26
|
+
});
|
|
27
|
+
/**
|
|
28
|
+
* Error for data validation failures.
|
|
29
|
+
* Includes schema validation and missing required data.
|
|
30
|
+
*/
|
|
31
|
+
export class ValidationError extends TrellisError {
|
|
32
|
+
name = "ValidationError";
|
|
33
|
+
#normalizedErrors;
|
|
34
|
+
constructor(options) {
|
|
35
|
+
const { errors: rawErrors, ...baseOptions } = options;
|
|
36
|
+
const errors = [...rawErrors].map(normalizeError);
|
|
37
|
+
const msg = errors
|
|
38
|
+
.map((e) => `Validation failed. ${e.schemaPath}: ${e.message}.`)
|
|
39
|
+
.join("\n");
|
|
40
|
+
super(msg.length ? msg : "Data validation failed.", baseOptions);
|
|
41
|
+
this.#normalizedErrors = errors;
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* Serializes error to a plain object.
|
|
45
|
+
* Transforms internal errors array to issues array for serialization.
|
|
46
|
+
*
|
|
47
|
+
* @returns Plain object representation of the error
|
|
48
|
+
*/
|
|
49
|
+
toSerializable() {
|
|
50
|
+
return {
|
|
51
|
+
...this.baseSerializable(),
|
|
52
|
+
type: this.name,
|
|
53
|
+
issues: this.#normalizedErrors.map((e) => ({
|
|
54
|
+
path: e.schemaPath,
|
|
55
|
+
message: e.message,
|
|
56
|
+
})),
|
|
57
|
+
};
|
|
58
|
+
}
|
|
59
|
+
}
|
|
@@ -0,0 +1,254 @@
|
|
|
1
|
+
import { UnexpectedError, type UnexpectedErrorData } from "@oatscenter/result";
|
|
2
|
+
import { AuthError } from "./AuthError.ts";
|
|
3
|
+
import type { AuthErrorData } from "./AuthError.ts";
|
|
4
|
+
import { ValidationError } from "./ValidationError.ts";
|
|
5
|
+
import type { ValidationErrorData } from "./ValidationError.ts";
|
|
6
|
+
import { SchemaValidationError } from "./SchemaValidationError.ts";
|
|
7
|
+
import type { SchemaValidationErrorData } from "./SchemaValidationError.ts";
|
|
8
|
+
import { RemoteError } from "./RemoteError.ts";
|
|
9
|
+
import { KVError } from "./KVError.ts";
|
|
10
|
+
import type { KVErrorData } from "./KVError.ts";
|
|
11
|
+
import { OperationAlreadyTerminalError, OperationMismatchError, OperationNotFoundError } from "./OperationLifecycleError.ts";
|
|
12
|
+
import type { OperationAlreadyTerminalErrorData, OperationMismatchErrorData, OperationNotFoundErrorData } from "./OperationLifecycleError.ts";
|
|
13
|
+
import { StoreError } from "./StoreError.ts";
|
|
14
|
+
import type { StoreErrorData } from "./StoreError.ts";
|
|
15
|
+
import { TransportError } from "./TransportError.ts";
|
|
16
|
+
import type { TransportErrorData } from "./TransportError.ts";
|
|
17
|
+
import { TransferError } from "./TransferError.ts";
|
|
18
|
+
import type { TransferErrorData } from "./TransferError.ts";
|
|
19
|
+
type RuntimeRpcErrorDesc = {
|
|
20
|
+
type: string;
|
|
21
|
+
schema?: unknown;
|
|
22
|
+
fromSerializable(data: unknown): Error;
|
|
23
|
+
};
|
|
24
|
+
export { UnexpectedError } from "@oatscenter/result";
|
|
25
|
+
export { TrellisError } from "./TrellisError.ts";
|
|
26
|
+
export { AuthError } from "./AuthError.ts";
|
|
27
|
+
export { ValidationError } from "./ValidationError.ts";
|
|
28
|
+
export { SchemaValidationError } from "./SchemaValidationError.ts";
|
|
29
|
+
export { RemoteError } from "./RemoteError.ts";
|
|
30
|
+
export { KVError } from "./KVError.ts";
|
|
31
|
+
export { OperationAlreadyTerminalError, OperationMismatchError, OperationNotFoundError, } from "./OperationLifecycleError.ts";
|
|
32
|
+
export { StoreError } from "./StoreError.ts";
|
|
33
|
+
export { TransportError } from "./TransportError.ts";
|
|
34
|
+
export { TransferError } from "./TransferError.ts";
|
|
35
|
+
export { type AuthErrorData, AuthErrorDataSchema } from "./AuthError.ts";
|
|
36
|
+
export { type ValidationErrorData, ValidationErrorDataSchema, type ValidationIssue, ValidationIssueSchema, } from "./ValidationError.ts";
|
|
37
|
+
export { type SchemaValidationErrorData, SchemaValidationErrorDataSchema, type SchemaValidationIssue, SchemaValidationIssueSchema, } from "./SchemaValidationError.ts";
|
|
38
|
+
export { type RemoteErrorData, RemoteErrorDataSchema } from "./RemoteError.ts";
|
|
39
|
+
export { type KVErrorData, KVErrorDataSchema } from "./KVError.ts";
|
|
40
|
+
export { type OperationAlreadyTerminalErrorData, OperationAlreadyTerminalErrorDataSchema, type OperationMismatchErrorData, OperationMismatchErrorDataSchema, type OperationNotFoundErrorData, OperationNotFoundErrorDataSchema, } from "./OperationLifecycleError.ts";
|
|
41
|
+
export { type StoreErrorData, StoreErrorDataSchema } from "./StoreError.ts";
|
|
42
|
+
export { type TransportErrorData, TransportErrorDataSchema, } from "./TransportError.ts";
|
|
43
|
+
export { type TransferErrorData, TransferErrorDataSchema, } from "./TransferError.ts";
|
|
44
|
+
/**
|
|
45
|
+
* Single source of truth for all Trellis errors.
|
|
46
|
+
* This object is used for compile-time type inference.
|
|
47
|
+
*/
|
|
48
|
+
declare const TRANSPORTABLE_TRELLIS_ERRORS: {
|
|
49
|
+
readonly UnexpectedError: typeof UnexpectedError;
|
|
50
|
+
readonly TransportError: typeof TransportError;
|
|
51
|
+
readonly AuthError: typeof AuthError;
|
|
52
|
+
readonly ValidationError: typeof ValidationError;
|
|
53
|
+
readonly SchemaValidationError: typeof SchemaValidationError;
|
|
54
|
+
readonly KVError: typeof KVError;
|
|
55
|
+
readonly OperationNotFoundError: typeof OperationNotFoundError;
|
|
56
|
+
readonly OperationAlreadyTerminalError: typeof OperationAlreadyTerminalError;
|
|
57
|
+
readonly OperationMismatchError: typeof OperationMismatchError;
|
|
58
|
+
readonly StoreError: typeof StoreError;
|
|
59
|
+
readonly TransferError: typeof TransferError;
|
|
60
|
+
};
|
|
61
|
+
declare const TRELLIS_ERRORS: {
|
|
62
|
+
readonly RemoteError: typeof RemoteError;
|
|
63
|
+
readonly UnexpectedError: typeof UnexpectedError;
|
|
64
|
+
readonly TransportError: typeof TransportError;
|
|
65
|
+
readonly AuthError: typeof AuthError;
|
|
66
|
+
readonly ValidationError: typeof ValidationError;
|
|
67
|
+
readonly SchemaValidationError: typeof SchemaValidationError;
|
|
68
|
+
readonly KVError: typeof KVError;
|
|
69
|
+
readonly OperationNotFoundError: typeof OperationNotFoundError;
|
|
70
|
+
readonly OperationAlreadyTerminalError: typeof OperationAlreadyTerminalError;
|
|
71
|
+
readonly OperationMismatchError: typeof OperationMismatchError;
|
|
72
|
+
readonly StoreError: typeof StoreError;
|
|
73
|
+
readonly TransferError: typeof TransferError;
|
|
74
|
+
};
|
|
75
|
+
/**
|
|
76
|
+
* Compile-time mapping from error names to their instance types.
|
|
77
|
+
* Derived from TRELLIS_ERRORS to ensure types stay in sync with runtime.
|
|
78
|
+
*/
|
|
79
|
+
export type TrellisErrorMap = {
|
|
80
|
+
[K in keyof typeof TRELLIS_ERRORS]: InstanceType<(typeof TRELLIS_ERRORS)[K]>;
|
|
81
|
+
};
|
|
82
|
+
export type TransportableTrellisErrorMap = {
|
|
83
|
+
[K in keyof typeof TRANSPORTABLE_TRELLIS_ERRORS]: InstanceType<(typeof TRANSPORTABLE_TRELLIS_ERRORS)[K]>;
|
|
84
|
+
};
|
|
85
|
+
export type TrellisErrorName = keyof TransportableTrellisErrorMap;
|
|
86
|
+
export type TrellisErrorInstance = TrellisErrorMap[TrellisErrorName];
|
|
87
|
+
export type MapErrorNamesToTypes<T extends readonly TrellisErrorName[]> = {
|
|
88
|
+
[K in keyof T]: T[K] extends TrellisErrorName ? TransportableTrellisErrorMap[T[K]] : never;
|
|
89
|
+
}[number];
|
|
90
|
+
export declare const BUILTIN_RPC_ERRORS: {
|
|
91
|
+
readonly UnexpectedError: {
|
|
92
|
+
readonly type: "UnexpectedError";
|
|
93
|
+
readonly schema: import("typebox").TObject<{
|
|
94
|
+
id: import("typebox").TString;
|
|
95
|
+
type: import("typebox").TLiteral<"UnexpectedError">;
|
|
96
|
+
message: import("typebox").TString;
|
|
97
|
+
context: import("typebox").TOptional<import("typebox").TRecord<"^.*$", import("typebox").TUnknown>>;
|
|
98
|
+
traceId: import("typebox").TOptional<import("typebox").TString>;
|
|
99
|
+
}>;
|
|
100
|
+
readonly fromSerializable: (data: UnexpectedErrorData) => UnexpectedError;
|
|
101
|
+
};
|
|
102
|
+
readonly AuthError: {
|
|
103
|
+
readonly type: "AuthError";
|
|
104
|
+
readonly schema: import("typebox").TObject<{
|
|
105
|
+
id: import("typebox").TString;
|
|
106
|
+
type: import("typebox").TLiteral<"AuthError">;
|
|
107
|
+
message: import("typebox").TString;
|
|
108
|
+
reason: import("typebox").TString;
|
|
109
|
+
context: import("typebox").TOptional<import("typebox").TRecord<"^.*$", import("typebox").TUnknown>>;
|
|
110
|
+
traceId: import("typebox").TOptional<import("typebox").TString>;
|
|
111
|
+
}>;
|
|
112
|
+
readonly fromSerializable: (data: AuthErrorData) => AuthError;
|
|
113
|
+
};
|
|
114
|
+
readonly TransportError: {
|
|
115
|
+
readonly type: "TransportError";
|
|
116
|
+
readonly schema: import("typebox").TObject<{
|
|
117
|
+
id: import("typebox").TString;
|
|
118
|
+
type: import("typebox").TLiteral<"TransportError">;
|
|
119
|
+
message: import("typebox").TString;
|
|
120
|
+
code: import("typebox").TString;
|
|
121
|
+
hint: import("typebox").TString;
|
|
122
|
+
context: import("typebox").TOptional<import("typebox").TRecord<"^.*$", import("typebox").TUnknown>>;
|
|
123
|
+
traceId: import("typebox").TOptional<import("typebox").TString>;
|
|
124
|
+
}>;
|
|
125
|
+
readonly fromSerializable: (data: TransportErrorData) => TransportError;
|
|
126
|
+
};
|
|
127
|
+
readonly ValidationError: {
|
|
128
|
+
readonly type: "ValidationError";
|
|
129
|
+
readonly schema: import("typebox").TObject<{
|
|
130
|
+
id: import("typebox").TString;
|
|
131
|
+
type: import("typebox").TLiteral<"ValidationError">;
|
|
132
|
+
message: import("typebox").TString;
|
|
133
|
+
issues: import("typebox").TArray<import("typebox").TObject<{
|
|
134
|
+
path: import("typebox").TString;
|
|
135
|
+
message: import("typebox").TString;
|
|
136
|
+
}>>;
|
|
137
|
+
context: import("typebox").TOptional<import("typebox").TRecord<"^.*$", import("typebox").TUnknown>>;
|
|
138
|
+
traceId: import("typebox").TOptional<import("typebox").TString>;
|
|
139
|
+
}>;
|
|
140
|
+
readonly fromSerializable: (data: ValidationErrorData) => ValidationError;
|
|
141
|
+
};
|
|
142
|
+
readonly SchemaValidationError: {
|
|
143
|
+
readonly type: "SchemaValidationError";
|
|
144
|
+
readonly schema: import("typebox").TObject<{
|
|
145
|
+
id: import("typebox").TString;
|
|
146
|
+
type: import("typebox").TLiteral<"SchemaValidationError">;
|
|
147
|
+
message: import("typebox").TString;
|
|
148
|
+
issues: import("typebox").TArray<import("typebox").TObject<{
|
|
149
|
+
path: import("typebox").TString;
|
|
150
|
+
schemaPath: import("typebox").TOptional<import("typebox").TString>;
|
|
151
|
+
keyword: import("typebox").TString;
|
|
152
|
+
code: import("typebox").TString;
|
|
153
|
+
message: import("typebox").TString;
|
|
154
|
+
label: import("typebox").TOptional<import("typebox").TString>;
|
|
155
|
+
note: import("typebox").TOptional<import("typebox").TString>;
|
|
156
|
+
i18nKey: import("typebox").TOptional<import("typebox").TString>;
|
|
157
|
+
severity: import("typebox").TOptional<import("typebox").TUnion<[import("typebox").TLiteral<"error">, import("typebox").TLiteral<"warning">, import("typebox").TLiteral<"info">]>>;
|
|
158
|
+
params: import("typebox").TOptional<import("typebox").TRecord<"^.*$", import("typebox").TUnknown>>;
|
|
159
|
+
}>>;
|
|
160
|
+
context: import("typebox").TOptional<import("typebox").TRecord<"^.*$", import("typebox").TUnknown>>;
|
|
161
|
+
traceId: import("typebox").TOptional<import("typebox").TString>;
|
|
162
|
+
}>;
|
|
163
|
+
readonly fromSerializable: (data: SchemaValidationErrorData) => SchemaValidationError;
|
|
164
|
+
};
|
|
165
|
+
readonly KVError: {
|
|
166
|
+
readonly type: "KVError";
|
|
167
|
+
readonly schema: import("typebox").TObject<{
|
|
168
|
+
id: import("typebox").TString;
|
|
169
|
+
type: import("typebox").TLiteral<"KVError">;
|
|
170
|
+
message: import("typebox").TString;
|
|
171
|
+
operation: import("typebox").TOptional<import("typebox").TString>;
|
|
172
|
+
context: import("typebox").TOptional<import("typebox").TRecord<"^.*$", import("typebox").TUnknown>>;
|
|
173
|
+
traceId: import("typebox").TOptional<import("typebox").TString>;
|
|
174
|
+
}>;
|
|
175
|
+
readonly fromSerializable: (data: KVErrorData) => KVError;
|
|
176
|
+
};
|
|
177
|
+
readonly OperationNotFoundError: {
|
|
178
|
+
readonly type: "OperationNotFoundError";
|
|
179
|
+
readonly schema: import("typebox").TObject<{
|
|
180
|
+
id: import("typebox").TString;
|
|
181
|
+
type: import("typebox").TLiteral<"OperationNotFoundError">;
|
|
182
|
+
message: import("typebox").TString;
|
|
183
|
+
operationId: import("typebox").TString;
|
|
184
|
+
context: import("typebox").TOptional<import("typebox").TRecord<"^.*$", import("typebox").TUnknown>>;
|
|
185
|
+
traceId: import("typebox").TOptional<import("typebox").TString>;
|
|
186
|
+
}>;
|
|
187
|
+
readonly fromSerializable: (data: OperationNotFoundErrorData) => OperationNotFoundError;
|
|
188
|
+
};
|
|
189
|
+
readonly OperationAlreadyTerminalError: {
|
|
190
|
+
readonly type: "OperationAlreadyTerminalError";
|
|
191
|
+
readonly schema: import("typebox").TObject<{
|
|
192
|
+
id: import("typebox").TString;
|
|
193
|
+
type: import("typebox").TLiteral<"OperationAlreadyTerminalError">;
|
|
194
|
+
message: import("typebox").TString;
|
|
195
|
+
operationId: import("typebox").TString;
|
|
196
|
+
state: import("typebox").TOptional<import("typebox").TString>;
|
|
197
|
+
operation: import("typebox").TOptional<import("typebox").TString>;
|
|
198
|
+
service: import("typebox").TOptional<import("typebox").TString>;
|
|
199
|
+
context: import("typebox").TOptional<import("typebox").TRecord<"^.*$", import("typebox").TUnknown>>;
|
|
200
|
+
traceId: import("typebox").TOptional<import("typebox").TString>;
|
|
201
|
+
}>;
|
|
202
|
+
readonly fromSerializable: (data: OperationAlreadyTerminalErrorData) => OperationAlreadyTerminalError;
|
|
203
|
+
};
|
|
204
|
+
readonly OperationMismatchError: {
|
|
205
|
+
readonly type: "OperationMismatchError";
|
|
206
|
+
readonly schema: import("typebox").TObject<{
|
|
207
|
+
id: import("typebox").TString;
|
|
208
|
+
type: import("typebox").TLiteral<"OperationMismatchError">;
|
|
209
|
+
message: import("typebox").TString;
|
|
210
|
+
operationId: import("typebox").TString;
|
|
211
|
+
expectedService: import("typebox").TString;
|
|
212
|
+
expectedOperation: import("typebox").TString;
|
|
213
|
+
actualService: import("typebox").TOptional<import("typebox").TString>;
|
|
214
|
+
actualOperation: import("typebox").TOptional<import("typebox").TString>;
|
|
215
|
+
context: import("typebox").TOptional<import("typebox").TRecord<"^.*$", import("typebox").TUnknown>>;
|
|
216
|
+
traceId: import("typebox").TOptional<import("typebox").TString>;
|
|
217
|
+
}>;
|
|
218
|
+
readonly fromSerializable: (data: OperationMismatchErrorData) => OperationMismatchError;
|
|
219
|
+
};
|
|
220
|
+
readonly StoreError: {
|
|
221
|
+
readonly type: "StoreError";
|
|
222
|
+
readonly schema: import("typebox").TObject<{
|
|
223
|
+
id: import("typebox").TString;
|
|
224
|
+
type: import("typebox").TLiteral<"StoreError">;
|
|
225
|
+
message: import("typebox").TString;
|
|
226
|
+
operation: import("typebox").TOptional<import("typebox").TString>;
|
|
227
|
+
context: import("typebox").TOptional<import("typebox").TRecord<"^.*$", import("typebox").TUnknown>>;
|
|
228
|
+
traceId: import("typebox").TOptional<import("typebox").TString>;
|
|
229
|
+
}>;
|
|
230
|
+
readonly fromSerializable: (data: StoreErrorData) => StoreError;
|
|
231
|
+
};
|
|
232
|
+
readonly TransferError: {
|
|
233
|
+
readonly type: "TransferError";
|
|
234
|
+
readonly schema: import("typebox").TObject<{
|
|
235
|
+
id: import("typebox").TString;
|
|
236
|
+
type: import("typebox").TLiteral<"TransferError">;
|
|
237
|
+
message: import("typebox").TString;
|
|
238
|
+
operation: import("typebox").TOptional<import("typebox").TString>;
|
|
239
|
+
context: import("typebox").TOptional<import("typebox").TRecord<"^.*$", import("typebox").TUnknown>>;
|
|
240
|
+
traceId: import("typebox").TOptional<import("typebox").TString>;
|
|
241
|
+
}>;
|
|
242
|
+
readonly fromSerializable: (data: TransferErrorData) => TransferError;
|
|
243
|
+
};
|
|
244
|
+
};
|
|
245
|
+
export declare function getBuiltinRpcError(type: string): RuntimeRpcErrorDesc | undefined;
|
|
246
|
+
/**
|
|
247
|
+
* Reads the machine-readable failure code from any Trellis error shape.
|
|
248
|
+
*
|
|
249
|
+
* Declared RPC errors reconstruct into generated error classes that carry the
|
|
250
|
+
* code under `data`, built-in errors carry `reason`, and undecoded remote
|
|
251
|
+
* failures carry it under `remoteError`. Callers that must branch on a specific
|
|
252
|
+
* server code use this instead of matching one historical shape.
|
|
253
|
+
*/
|
|
254
|
+
export declare function machineErrorCode(error: unknown): string | undefined;
|