@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
package/env.js
ADDED
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import Type, { type Static } from "typebox";
|
|
2
|
+
import { TrellisError } from "./TrellisError.ts";
|
|
3
|
+
export declare const AuthErrorDataSchema: Type.TObject<{
|
|
4
|
+
id: Type.TString;
|
|
5
|
+
type: Type.TLiteral<"AuthError">;
|
|
6
|
+
message: Type.TString;
|
|
7
|
+
reason: Type.TString;
|
|
8
|
+
context: Type.TOptional<Type.TRecord<"^.*$", Type.TUnknown>>;
|
|
9
|
+
traceId: Type.TOptional<Type.TString>;
|
|
10
|
+
}>;
|
|
11
|
+
export type AuthErrorData = Static<typeof AuthErrorDataSchema>;
|
|
12
|
+
/**
|
|
13
|
+
* Error for authentication and authorization failures.
|
|
14
|
+
*/
|
|
15
|
+
export declare class AuthError extends TrellisError<AuthErrorData> {
|
|
16
|
+
readonly name: "AuthError";
|
|
17
|
+
readonly reason: AuthErrorData["reason"];
|
|
18
|
+
constructor(options: ErrorOptions & {
|
|
19
|
+
reason: AuthErrorData["reason"];
|
|
20
|
+
message?: string;
|
|
21
|
+
context?: Record<string, unknown>;
|
|
22
|
+
id?: string;
|
|
23
|
+
});
|
|
24
|
+
/**
|
|
25
|
+
* Serializes error to a plain object.
|
|
26
|
+
*
|
|
27
|
+
* @returns Plain object representation of the error
|
|
28
|
+
*/
|
|
29
|
+
toSerializable(): AuthErrorData;
|
|
30
|
+
}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import Type, {} from "typebox";
|
|
2
|
+
import { TrellisError } from "./TrellisError.js";
|
|
3
|
+
export const AuthErrorDataSchema = Type.Object({
|
|
4
|
+
id: Type.String(),
|
|
5
|
+
type: Type.Literal("AuthError"),
|
|
6
|
+
message: Type.String(),
|
|
7
|
+
reason: Type.String(),
|
|
8
|
+
context: Type.Optional(Type.Record(Type.String(), Type.Unknown())),
|
|
9
|
+
traceId: Type.Optional(Type.String()),
|
|
10
|
+
});
|
|
11
|
+
/**
|
|
12
|
+
* Error for authentication and authorization failures.
|
|
13
|
+
*/
|
|
14
|
+
export class AuthError extends TrellisError {
|
|
15
|
+
name = "AuthError";
|
|
16
|
+
reason;
|
|
17
|
+
constructor(options) {
|
|
18
|
+
const { reason, message, ...baseOptions } = options;
|
|
19
|
+
super(message ?? `Auth failed: ${reason}`, baseOptions);
|
|
20
|
+
this.reason = reason;
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* Serializes error to a plain object.
|
|
24
|
+
*
|
|
25
|
+
* @returns Plain object representation of the error
|
|
26
|
+
*/
|
|
27
|
+
toSerializable() {
|
|
28
|
+
return {
|
|
29
|
+
...this.baseSerializable(),
|
|
30
|
+
type: this.name,
|
|
31
|
+
reason: this.reason,
|
|
32
|
+
};
|
|
33
|
+
}
|
|
34
|
+
}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import Type, { type Static } from "typebox";
|
|
2
|
+
import { TrellisError } from "./TrellisError.ts";
|
|
3
|
+
export declare const KVErrorDataSchema: Type.TObject<{
|
|
4
|
+
id: Type.TString;
|
|
5
|
+
type: Type.TLiteral<"KVError">;
|
|
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 KVErrorData = Static<typeof KVErrorDataSchema>;
|
|
12
|
+
/**
|
|
13
|
+
* Error for KV storage operations.
|
|
14
|
+
* Used when key-value store operations fail.
|
|
15
|
+
*/
|
|
16
|
+
export declare class KVError extends TrellisError<KVErrorData> {
|
|
17
|
+
readonly name: "KVError";
|
|
18
|
+
readonly operation?: string;
|
|
19
|
+
constructor(options: ErrorOptions & {
|
|
20
|
+
operation?: string;
|
|
21
|
+
context?: Record<string, unknown>;
|
|
22
|
+
id?: string;
|
|
23
|
+
});
|
|
24
|
+
/**
|
|
25
|
+
* Serializes error to a plain object.
|
|
26
|
+
*
|
|
27
|
+
* @returns Plain object representation of the error
|
|
28
|
+
*/
|
|
29
|
+
toSerializable(): KVErrorData;
|
|
30
|
+
}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import Type, {} from "typebox";
|
|
2
|
+
import { TrellisError } from "./TrellisError.js";
|
|
3
|
+
export const KVErrorDataSchema = Type.Object({
|
|
4
|
+
id: Type.String(),
|
|
5
|
+
type: Type.Literal("KVError"),
|
|
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
|
+
/**
|
|
12
|
+
* Error for KV storage operations.
|
|
13
|
+
* Used when key-value store operations fail.
|
|
14
|
+
*/
|
|
15
|
+
export class KVError extends TrellisError {
|
|
16
|
+
name = "KVError";
|
|
17
|
+
operation;
|
|
18
|
+
constructor(options) {
|
|
19
|
+
const { operation, ...baseOptions } = options;
|
|
20
|
+
const msg = `KV ${operation || ""} failed`;
|
|
21
|
+
super(msg, baseOptions);
|
|
22
|
+
this.operation = operation;
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* Serializes error to a plain object.
|
|
26
|
+
*
|
|
27
|
+
* @returns Plain object representation of the error
|
|
28
|
+
*/
|
|
29
|
+
toSerializable() {
|
|
30
|
+
return {
|
|
31
|
+
...this.baseSerializable(),
|
|
32
|
+
type: this.name,
|
|
33
|
+
operation: this.operation,
|
|
34
|
+
};
|
|
35
|
+
}
|
|
36
|
+
}
|
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
import Type, { type Static } from "typebox";
|
|
2
|
+
import { TrellisError } from "./TrellisError.ts";
|
|
3
|
+
export declare const OperationNotFoundErrorDataSchema: Type.TObject<{
|
|
4
|
+
id: Type.TString;
|
|
5
|
+
type: Type.TLiteral<"OperationNotFoundError">;
|
|
6
|
+
message: Type.TString;
|
|
7
|
+
operationId: Type.TString;
|
|
8
|
+
context: Type.TOptional<Type.TRecord<"^.*$", Type.TUnknown>>;
|
|
9
|
+
traceId: Type.TOptional<Type.TString>;
|
|
10
|
+
}>;
|
|
11
|
+
export type OperationNotFoundErrorData = Static<typeof OperationNotFoundErrorDataSchema>;
|
|
12
|
+
/**
|
|
13
|
+
* Error raised when a requested Trellis operation id cannot be found.
|
|
14
|
+
*/
|
|
15
|
+
export declare class OperationNotFoundError extends TrellisError<OperationNotFoundErrorData> {
|
|
16
|
+
readonly name: "OperationNotFoundError";
|
|
17
|
+
readonly operationId: string;
|
|
18
|
+
constructor(options: ErrorOptions & {
|
|
19
|
+
operationId: string;
|
|
20
|
+
message?: string;
|
|
21
|
+
context?: Record<string, unknown>;
|
|
22
|
+
id?: string;
|
|
23
|
+
traceId?: string;
|
|
24
|
+
});
|
|
25
|
+
/**
|
|
26
|
+
* Serializes error to a plain object.
|
|
27
|
+
*
|
|
28
|
+
* @returns Plain object representation of the error.
|
|
29
|
+
*/
|
|
30
|
+
toSerializable(): OperationNotFoundErrorData;
|
|
31
|
+
}
|
|
32
|
+
export declare const OperationAlreadyTerminalErrorDataSchema: Type.TObject<{
|
|
33
|
+
id: Type.TString;
|
|
34
|
+
type: Type.TLiteral<"OperationAlreadyTerminalError">;
|
|
35
|
+
message: Type.TString;
|
|
36
|
+
operationId: Type.TString;
|
|
37
|
+
state: Type.TOptional<Type.TString>;
|
|
38
|
+
operation: Type.TOptional<Type.TString>;
|
|
39
|
+
service: Type.TOptional<Type.TString>;
|
|
40
|
+
context: Type.TOptional<Type.TRecord<"^.*$", Type.TUnknown>>;
|
|
41
|
+
traceId: Type.TOptional<Type.TString>;
|
|
42
|
+
}>;
|
|
43
|
+
export type OperationAlreadyTerminalErrorData = Static<typeof OperationAlreadyTerminalErrorDataSchema>;
|
|
44
|
+
/**
|
|
45
|
+
* Error raised when a Trellis operation lifecycle mutation targets a terminal operation.
|
|
46
|
+
*/
|
|
47
|
+
export declare class OperationAlreadyTerminalError extends TrellisError<OperationAlreadyTerminalErrorData> {
|
|
48
|
+
readonly name: "OperationAlreadyTerminalError";
|
|
49
|
+
readonly operationId: string;
|
|
50
|
+
readonly state?: string;
|
|
51
|
+
readonly operation?: string;
|
|
52
|
+
readonly service?: string;
|
|
53
|
+
constructor(options: ErrorOptions & {
|
|
54
|
+
operationId: string;
|
|
55
|
+
state?: string;
|
|
56
|
+
operation?: string;
|
|
57
|
+
service?: string;
|
|
58
|
+
message?: string;
|
|
59
|
+
context?: Record<string, unknown>;
|
|
60
|
+
id?: string;
|
|
61
|
+
traceId?: string;
|
|
62
|
+
});
|
|
63
|
+
/**
|
|
64
|
+
* Serializes error to a plain object.
|
|
65
|
+
*
|
|
66
|
+
* @returns Plain object representation of the error.
|
|
67
|
+
*/
|
|
68
|
+
toSerializable(): OperationAlreadyTerminalErrorData;
|
|
69
|
+
}
|
|
70
|
+
export declare const OperationMismatchErrorDataSchema: Type.TObject<{
|
|
71
|
+
id: Type.TString;
|
|
72
|
+
type: Type.TLiteral<"OperationMismatchError">;
|
|
73
|
+
message: Type.TString;
|
|
74
|
+
operationId: Type.TString;
|
|
75
|
+
expectedService: Type.TString;
|
|
76
|
+
expectedOperation: Type.TString;
|
|
77
|
+
actualService: Type.TOptional<Type.TString>;
|
|
78
|
+
actualOperation: Type.TOptional<Type.TString>;
|
|
79
|
+
context: Type.TOptional<Type.TRecord<"^.*$", Type.TUnknown>>;
|
|
80
|
+
traceId: Type.TOptional<Type.TString>;
|
|
81
|
+
}>;
|
|
82
|
+
export type OperationMismatchErrorData = Static<typeof OperationMismatchErrorDataSchema>;
|
|
83
|
+
/**
|
|
84
|
+
* Error raised when a Trellis operation id belongs to a different service or operation.
|
|
85
|
+
*/
|
|
86
|
+
export declare class OperationMismatchError extends TrellisError<OperationMismatchErrorData> {
|
|
87
|
+
readonly name: "OperationMismatchError";
|
|
88
|
+
readonly operationId: string;
|
|
89
|
+
readonly expectedService: string;
|
|
90
|
+
readonly expectedOperation: string;
|
|
91
|
+
readonly actualService?: string;
|
|
92
|
+
readonly actualOperation?: string;
|
|
93
|
+
constructor(options: ErrorOptions & {
|
|
94
|
+
operationId: string;
|
|
95
|
+
expectedService: string;
|
|
96
|
+
expectedOperation: string;
|
|
97
|
+
actualService?: string;
|
|
98
|
+
actualOperation?: string;
|
|
99
|
+
message?: string;
|
|
100
|
+
context?: Record<string, unknown>;
|
|
101
|
+
id?: string;
|
|
102
|
+
traceId?: string;
|
|
103
|
+
});
|
|
104
|
+
/**
|
|
105
|
+
* Serializes error to a plain object.
|
|
106
|
+
*
|
|
107
|
+
* @returns Plain object representation of the error.
|
|
108
|
+
*/
|
|
109
|
+
toSerializable(): OperationMismatchErrorData;
|
|
110
|
+
}
|
|
@@ -0,0 +1,142 @@
|
|
|
1
|
+
import Type, {} from "typebox";
|
|
2
|
+
import { TrellisError } from "./TrellisError.js";
|
|
3
|
+
export const OperationNotFoundErrorDataSchema = Type.Object({
|
|
4
|
+
id: Type.String(),
|
|
5
|
+
type: Type.Literal("OperationNotFoundError"),
|
|
6
|
+
message: Type.String(),
|
|
7
|
+
operationId: Type.String(),
|
|
8
|
+
context: Type.Optional(Type.Record(Type.String(), Type.Unknown())),
|
|
9
|
+
traceId: Type.Optional(Type.String()),
|
|
10
|
+
});
|
|
11
|
+
/**
|
|
12
|
+
* Error raised when a requested Trellis operation id cannot be found.
|
|
13
|
+
*/
|
|
14
|
+
export class OperationNotFoundError extends TrellisError {
|
|
15
|
+
name = "OperationNotFoundError";
|
|
16
|
+
operationId;
|
|
17
|
+
constructor(options) {
|
|
18
|
+
const { operationId, message, ...baseOptions } = options;
|
|
19
|
+
super(message ?? `Operation not found: ${operationId}`, baseOptions);
|
|
20
|
+
this.operationId = operationId;
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* Serializes error to a plain object.
|
|
24
|
+
*
|
|
25
|
+
* @returns Plain object representation of the error.
|
|
26
|
+
*/
|
|
27
|
+
toSerializable() {
|
|
28
|
+
const base = this.baseSerializable();
|
|
29
|
+
return {
|
|
30
|
+
id: base.id,
|
|
31
|
+
type: this.name,
|
|
32
|
+
message: base.message,
|
|
33
|
+
operationId: this.operationId,
|
|
34
|
+
...(base.context !== undefined ? { context: base.context } : {}),
|
|
35
|
+
...(base.traceId !== undefined ? { traceId: base.traceId } : {}),
|
|
36
|
+
};
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
export const OperationAlreadyTerminalErrorDataSchema = Type.Object({
|
|
40
|
+
id: Type.String(),
|
|
41
|
+
type: Type.Literal("OperationAlreadyTerminalError"),
|
|
42
|
+
message: Type.String(),
|
|
43
|
+
operationId: Type.String(),
|
|
44
|
+
state: Type.Optional(Type.String()),
|
|
45
|
+
operation: Type.Optional(Type.String()),
|
|
46
|
+
service: Type.Optional(Type.String()),
|
|
47
|
+
context: Type.Optional(Type.Record(Type.String(), Type.Unknown())),
|
|
48
|
+
traceId: Type.Optional(Type.String()),
|
|
49
|
+
});
|
|
50
|
+
/**
|
|
51
|
+
* Error raised when a Trellis operation lifecycle mutation targets a terminal operation.
|
|
52
|
+
*/
|
|
53
|
+
export class OperationAlreadyTerminalError extends TrellisError {
|
|
54
|
+
name = "OperationAlreadyTerminalError";
|
|
55
|
+
operationId;
|
|
56
|
+
state;
|
|
57
|
+
operation;
|
|
58
|
+
service;
|
|
59
|
+
constructor(options) {
|
|
60
|
+
const { operationId, state, operation, service, message, ...baseOptions } = options;
|
|
61
|
+
super(message ?? `Operation already terminal: ${operationId}`, baseOptions);
|
|
62
|
+
this.operationId = operationId;
|
|
63
|
+
this.state = state;
|
|
64
|
+
this.operation = operation;
|
|
65
|
+
this.service = service;
|
|
66
|
+
}
|
|
67
|
+
/**
|
|
68
|
+
* Serializes error to a plain object.
|
|
69
|
+
*
|
|
70
|
+
* @returns Plain object representation of the error.
|
|
71
|
+
*/
|
|
72
|
+
toSerializable() {
|
|
73
|
+
const base = this.baseSerializable();
|
|
74
|
+
return {
|
|
75
|
+
id: base.id,
|
|
76
|
+
type: this.name,
|
|
77
|
+
message: base.message,
|
|
78
|
+
operationId: this.operationId,
|
|
79
|
+
...(this.state !== undefined ? { state: this.state } : {}),
|
|
80
|
+
...(this.operation !== undefined ? { operation: this.operation } : {}),
|
|
81
|
+
...(this.service !== undefined ? { service: this.service } : {}),
|
|
82
|
+
...(base.context !== undefined ? { context: base.context } : {}),
|
|
83
|
+
...(base.traceId !== undefined ? { traceId: base.traceId } : {}),
|
|
84
|
+
};
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
export const OperationMismatchErrorDataSchema = Type.Object({
|
|
88
|
+
id: Type.String(),
|
|
89
|
+
type: Type.Literal("OperationMismatchError"),
|
|
90
|
+
message: Type.String(),
|
|
91
|
+
operationId: Type.String(),
|
|
92
|
+
expectedService: Type.String(),
|
|
93
|
+
expectedOperation: Type.String(),
|
|
94
|
+
actualService: Type.Optional(Type.String()),
|
|
95
|
+
actualOperation: Type.Optional(Type.String()),
|
|
96
|
+
context: Type.Optional(Type.Record(Type.String(), Type.Unknown())),
|
|
97
|
+
traceId: Type.Optional(Type.String()),
|
|
98
|
+
});
|
|
99
|
+
/**
|
|
100
|
+
* Error raised when a Trellis operation id belongs to a different service or operation.
|
|
101
|
+
*/
|
|
102
|
+
export class OperationMismatchError extends TrellisError {
|
|
103
|
+
name = "OperationMismatchError";
|
|
104
|
+
operationId;
|
|
105
|
+
expectedService;
|
|
106
|
+
expectedOperation;
|
|
107
|
+
actualService;
|
|
108
|
+
actualOperation;
|
|
109
|
+
constructor(options) {
|
|
110
|
+
const { operationId, expectedService, expectedOperation, actualService, actualOperation, message, ...baseOptions } = options;
|
|
111
|
+
super(message ?? `Operation mismatch: ${operationId}`, baseOptions);
|
|
112
|
+
this.operationId = operationId;
|
|
113
|
+
this.expectedService = expectedService;
|
|
114
|
+
this.expectedOperation = expectedOperation;
|
|
115
|
+
this.actualService = actualService;
|
|
116
|
+
this.actualOperation = actualOperation;
|
|
117
|
+
}
|
|
118
|
+
/**
|
|
119
|
+
* Serializes error to a plain object.
|
|
120
|
+
*
|
|
121
|
+
* @returns Plain object representation of the error.
|
|
122
|
+
*/
|
|
123
|
+
toSerializable() {
|
|
124
|
+
const base = this.baseSerializable();
|
|
125
|
+
return {
|
|
126
|
+
id: base.id,
|
|
127
|
+
type: this.name,
|
|
128
|
+
message: base.message,
|
|
129
|
+
operationId: this.operationId,
|
|
130
|
+
expectedService: this.expectedService,
|
|
131
|
+
expectedOperation: this.expectedOperation,
|
|
132
|
+
...(this.actualService !== undefined
|
|
133
|
+
? { actualService: this.actualService }
|
|
134
|
+
: {}),
|
|
135
|
+
...(this.actualOperation !== undefined
|
|
136
|
+
? { actualOperation: this.actualOperation }
|
|
137
|
+
: {}),
|
|
138
|
+
...(base.context !== undefined ? { context: base.context } : {}),
|
|
139
|
+
...(base.traceId !== undefined ? { traceId: base.traceId } : {}),
|
|
140
|
+
};
|
|
141
|
+
}
|
|
142
|
+
}
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import { Result, type UnexpectedError, type UnexpectedErrorData } from "@oatscenter/result";
|
|
2
|
+
import Type, { type Static } from "typebox";
|
|
3
|
+
import type { AuthErrorData } from "./AuthError.ts";
|
|
4
|
+
import type { KVErrorData } from "./KVError.ts";
|
|
5
|
+
import type { OperationAlreadyTerminalErrorData, OperationMismatchErrorData, OperationNotFoundErrorData } from "./OperationLifecycleError.ts";
|
|
6
|
+
import type { StoreErrorData } from "./StoreError.ts";
|
|
7
|
+
import type { TransportErrorData } from "./TransportError.ts";
|
|
8
|
+
import type { TransferErrorData } from "./TransferError.ts";
|
|
9
|
+
import { TrellisError } from "./TrellisError.ts";
|
|
10
|
+
import { ValidationError } from "./ValidationError.ts";
|
|
11
|
+
import type { ValidationErrorData } from "./ValidationError.ts";
|
|
12
|
+
export declare const RemoteErrorDataSchema: Type.TObject<{
|
|
13
|
+
id: Type.TString;
|
|
14
|
+
type: Type.TLiteral<"RemoteError">;
|
|
15
|
+
message: Type.TString;
|
|
16
|
+
remoteError: Type.TAny;
|
|
17
|
+
context: Type.TOptional<Type.TRecord<"^.*$", Type.TUnknown>>;
|
|
18
|
+
traceId: Type.TOptional<Type.TString>;
|
|
19
|
+
}>;
|
|
20
|
+
export type RemoteErrorData = Static<typeof RemoteErrorDataSchema>;
|
|
21
|
+
export declare const TrellisErrorDataSchema: Type.TObject<{
|
|
22
|
+
id: Type.TString;
|
|
23
|
+
type: Type.TString;
|
|
24
|
+
message: Type.TString;
|
|
25
|
+
context: Type.TOptional<Type.TRecord<"^.*$", Type.TUnknown>>;
|
|
26
|
+
traceId: Type.TOptional<Type.TString>;
|
|
27
|
+
}>;
|
|
28
|
+
export type TrellisErrorData = Static<typeof TrellisErrorDataSchema>;
|
|
29
|
+
export type TransportableTrellisErrorData = UnexpectedErrorData | AuthErrorData | ValidationErrorData | KVErrorData | OperationNotFoundErrorData | OperationAlreadyTerminalErrorData | OperationMismatchErrorData | StoreErrorData | TransportErrorData | TransferErrorData | TrellisErrorData;
|
|
30
|
+
/**
|
|
31
|
+
* Error for wrapping errors received from remote Trellis services.
|
|
32
|
+
* This is the only error type with parseJSON/parseObject methods for deserializing remote errors.
|
|
33
|
+
*/
|
|
34
|
+
export declare class RemoteError extends TrellisError<RemoteErrorData> {
|
|
35
|
+
readonly name: "RemoteError";
|
|
36
|
+
readonly remoteError: TransportableTrellisErrorData;
|
|
37
|
+
constructor(options: ErrorOptions & {
|
|
38
|
+
error: TransportableTrellisErrorData;
|
|
39
|
+
context?: Record<string, unknown>;
|
|
40
|
+
id?: string;
|
|
41
|
+
});
|
|
42
|
+
/**
|
|
43
|
+
* Serializes error to a plain object.
|
|
44
|
+
*
|
|
45
|
+
* @returns Plain object representation of the error
|
|
46
|
+
*/
|
|
47
|
+
toSerializable(): RemoteErrorData;
|
|
48
|
+
/**
|
|
49
|
+
* Parses and validates a plain object as TrellisErrorData.
|
|
50
|
+
* Use this to deserialize errors received from remote services.
|
|
51
|
+
*
|
|
52
|
+
* @param obj - Plain object to validate
|
|
53
|
+
* @returns Result containing validated TrellisError or a ValidationError or UnexpectedError
|
|
54
|
+
*/
|
|
55
|
+
static parse(data: unknown): Result<TransportableTrellisErrorData, ValidationError | UnexpectedError>;
|
|
56
|
+
/**
|
|
57
|
+
* Alias for parse() - parses JSON string or object as TrellisErrorData.
|
|
58
|
+
* @see parse
|
|
59
|
+
*/
|
|
60
|
+
static parseJSON: typeof RemoteError.parse;
|
|
61
|
+
}
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
import { Result, } from "@oatscenter/result";
|
|
2
|
+
import Type, {} from "typebox";
|
|
3
|
+
import { ParseError, Value } from "typebox/value";
|
|
4
|
+
import { TrellisError } from "./TrellisError.js";
|
|
5
|
+
import { ValidationError } from "./ValidationError.js";
|
|
6
|
+
export const RemoteErrorDataSchema = Type.Object({
|
|
7
|
+
id: Type.String(),
|
|
8
|
+
type: Type.Literal("RemoteError"),
|
|
9
|
+
message: Type.String(),
|
|
10
|
+
remoteError: Type.Any(),
|
|
11
|
+
context: Type.Optional(Type.Record(Type.String(), Type.Unknown())),
|
|
12
|
+
traceId: Type.Optional(Type.String()),
|
|
13
|
+
});
|
|
14
|
+
export const TrellisErrorDataSchema = Type.Object({
|
|
15
|
+
id: Type.String(),
|
|
16
|
+
type: Type.String(),
|
|
17
|
+
message: Type.String(),
|
|
18
|
+
context: Type.Optional(Type.Record(Type.String(), Type.Unknown())),
|
|
19
|
+
traceId: Type.Optional(Type.String()),
|
|
20
|
+
}, { additionalProperties: true });
|
|
21
|
+
/**
|
|
22
|
+
* Error for wrapping errors received from remote Trellis services.
|
|
23
|
+
* This is the only error type with parseJSON/parseObject methods for deserializing remote errors.
|
|
24
|
+
*/
|
|
25
|
+
export class RemoteError extends TrellisError {
|
|
26
|
+
name = "RemoteError";
|
|
27
|
+
remoteError;
|
|
28
|
+
constructor(options) {
|
|
29
|
+
const { error, ...baseOptions } = options;
|
|
30
|
+
super(`Remote error: ${error.message}`, baseOptions);
|
|
31
|
+
this.remoteError = error;
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* Serializes error to a plain object.
|
|
35
|
+
*
|
|
36
|
+
* @returns Plain object representation of the error
|
|
37
|
+
*/
|
|
38
|
+
toSerializable() {
|
|
39
|
+
return {
|
|
40
|
+
...this.baseSerializable(),
|
|
41
|
+
type: this.name,
|
|
42
|
+
remoteError: this.remoteError,
|
|
43
|
+
};
|
|
44
|
+
}
|
|
45
|
+
/**
|
|
46
|
+
* Parses and validates a plain object as TrellisErrorData.
|
|
47
|
+
* Use this to deserialize errors received from remote services.
|
|
48
|
+
*
|
|
49
|
+
* @param obj - Plain object to validate
|
|
50
|
+
* @returns Result containing validated TrellisError or a ValidationError or UnexpectedError
|
|
51
|
+
*/
|
|
52
|
+
static parse(data) {
|
|
53
|
+
return Result.try(() => typeof data === "string" ? JSON.parse(data) : data)
|
|
54
|
+
.andThen((obj) => {
|
|
55
|
+
const parseResult = Result.try(() => Value.Parse(TrellisErrorDataSchema, obj));
|
|
56
|
+
if (parseResult.isErr()) {
|
|
57
|
+
const cause = parseResult.error.cause;
|
|
58
|
+
if (cause instanceof ParseError) {
|
|
59
|
+
const errors = Value.Errors(TrellisErrorDataSchema, obj);
|
|
60
|
+
return Result.err(new ValidationError({ errors, cause }));
|
|
61
|
+
}
|
|
62
|
+
return Result.err(parseResult.error);
|
|
63
|
+
}
|
|
64
|
+
return Result.ok(parseResult.take());
|
|
65
|
+
});
|
|
66
|
+
}
|
|
67
|
+
/**
|
|
68
|
+
* Alias for parse() - parses JSON string or object as TrellisErrorData.
|
|
69
|
+
* @see parse
|
|
70
|
+
*/
|
|
71
|
+
static parseJSON = RemoteError.parse;
|
|
72
|
+
}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import Type, { type Static } from "typebox";
|
|
2
|
+
import { TrellisError } from "./TrellisError.ts";
|
|
3
|
+
export declare const SchemaValidationIssueSchema: Type.TObject<{
|
|
4
|
+
path: Type.TString;
|
|
5
|
+
schemaPath: Type.TOptional<Type.TString>;
|
|
6
|
+
keyword: Type.TString;
|
|
7
|
+
code: Type.TString;
|
|
8
|
+
message: Type.TString;
|
|
9
|
+
label: Type.TOptional<Type.TString>;
|
|
10
|
+
note: Type.TOptional<Type.TString>;
|
|
11
|
+
i18nKey: Type.TOptional<Type.TString>;
|
|
12
|
+
severity: Type.TOptional<Type.TUnion<[Type.TLiteral<"error">, Type.TLiteral<"warning">, Type.TLiteral<"info">]>>;
|
|
13
|
+
params: Type.TOptional<Type.TRecord<"^.*$", Type.TUnknown>>;
|
|
14
|
+
}>;
|
|
15
|
+
export type SchemaValidationIssue = Static<typeof SchemaValidationIssueSchema>;
|
|
16
|
+
export declare const SchemaValidationErrorDataSchema: Type.TObject<{
|
|
17
|
+
id: Type.TString;
|
|
18
|
+
type: Type.TLiteral<"SchemaValidationError">;
|
|
19
|
+
message: Type.TString;
|
|
20
|
+
issues: Type.TArray<Type.TObject<{
|
|
21
|
+
path: Type.TString;
|
|
22
|
+
schemaPath: Type.TOptional<Type.TString>;
|
|
23
|
+
keyword: Type.TString;
|
|
24
|
+
code: Type.TString;
|
|
25
|
+
message: Type.TString;
|
|
26
|
+
label: Type.TOptional<Type.TString>;
|
|
27
|
+
note: Type.TOptional<Type.TString>;
|
|
28
|
+
i18nKey: Type.TOptional<Type.TString>;
|
|
29
|
+
severity: Type.TOptional<Type.TUnion<[Type.TLiteral<"error">, Type.TLiteral<"warning">, Type.TLiteral<"info">]>>;
|
|
30
|
+
params: Type.TOptional<Type.TRecord<"^.*$", Type.TUnknown>>;
|
|
31
|
+
}>>;
|
|
32
|
+
context: Type.TOptional<Type.TRecord<"^.*$", Type.TUnknown>>;
|
|
33
|
+
traceId: Type.TOptional<Type.TString>;
|
|
34
|
+
}>;
|
|
35
|
+
export type SchemaValidationErrorData = Static<typeof SchemaValidationErrorDataSchema>;
|
|
36
|
+
export declare class SchemaValidationError extends TrellisError<SchemaValidationErrorData> {
|
|
37
|
+
#private;
|
|
38
|
+
readonly name: "SchemaValidationError";
|
|
39
|
+
constructor(options: {
|
|
40
|
+
issues: SchemaValidationIssue[];
|
|
41
|
+
context?: Record<string, unknown>;
|
|
42
|
+
cause?: unknown;
|
|
43
|
+
id?: string;
|
|
44
|
+
});
|
|
45
|
+
/** The validation issues that caused this error. */
|
|
46
|
+
get issues(): readonly SchemaValidationIssue[];
|
|
47
|
+
toSerializable(): SchemaValidationErrorData;
|
|
48
|
+
}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import Type, {} from "typebox";
|
|
2
|
+
import { TrellisError } from "./TrellisError.js";
|
|
3
|
+
export const SchemaValidationIssueSchema = Type.Object({
|
|
4
|
+
path: Type.String(),
|
|
5
|
+
schemaPath: Type.Optional(Type.String()),
|
|
6
|
+
keyword: Type.String(),
|
|
7
|
+
code: Type.String(),
|
|
8
|
+
message: Type.String(),
|
|
9
|
+
label: Type.Optional(Type.String()),
|
|
10
|
+
note: Type.Optional(Type.String()),
|
|
11
|
+
i18nKey: Type.Optional(Type.String()),
|
|
12
|
+
severity: Type.Optional(Type.Union([
|
|
13
|
+
Type.Literal("error"),
|
|
14
|
+
Type.Literal("warning"),
|
|
15
|
+
Type.Literal("info"),
|
|
16
|
+
])),
|
|
17
|
+
params: Type.Optional(Type.Record(Type.String(), Type.Unknown())),
|
|
18
|
+
});
|
|
19
|
+
export const SchemaValidationErrorDataSchema = Type.Object({
|
|
20
|
+
id: Type.String(),
|
|
21
|
+
type: Type.Literal("SchemaValidationError"),
|
|
22
|
+
message: Type.String(),
|
|
23
|
+
issues: Type.Array(SchemaValidationIssueSchema),
|
|
24
|
+
context: Type.Optional(Type.Record(Type.String(), Type.Unknown())),
|
|
25
|
+
traceId: Type.Optional(Type.String()),
|
|
26
|
+
});
|
|
27
|
+
export class SchemaValidationError extends TrellisError {
|
|
28
|
+
name = "SchemaValidationError";
|
|
29
|
+
#issues;
|
|
30
|
+
constructor(options) {
|
|
31
|
+
const { issues: rawIssues, ...baseOptions } = options;
|
|
32
|
+
const msg = rawIssues
|
|
33
|
+
.map((issue) => issue.message)
|
|
34
|
+
.join("\n");
|
|
35
|
+
super(msg.length ? msg : "Schema validation failed.", baseOptions);
|
|
36
|
+
this.#issues = rawIssues;
|
|
37
|
+
}
|
|
38
|
+
/** The validation issues that caused this error. */
|
|
39
|
+
get issues() {
|
|
40
|
+
return this.#issues;
|
|
41
|
+
}
|
|
42
|
+
toSerializable() {
|
|
43
|
+
return {
|
|
44
|
+
...this.baseSerializable(),
|
|
45
|
+
type: this.name,
|
|
46
|
+
issues: this.#issues,
|
|
47
|
+
};
|
|
48
|
+
}
|
|
49
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import Type, { type Static } from "typebox";
|
|
2
|
+
import { TrellisError } from "./TrellisError.ts";
|
|
3
|
+
export declare const StoreErrorDataSchema: Type.TObject<{
|
|
4
|
+
id: Type.TString;
|
|
5
|
+
type: Type.TLiteral<"StoreError">;
|
|
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 StoreErrorData = Static<typeof StoreErrorDataSchema>;
|
|
12
|
+
export declare class StoreError extends TrellisError<StoreErrorData> {
|
|
13
|
+
readonly name: "StoreError";
|
|
14
|
+
readonly operation?: string;
|
|
15
|
+
constructor(options: ErrorOptions & {
|
|
16
|
+
operation?: string;
|
|
17
|
+
context?: Record<string, unknown>;
|
|
18
|
+
id?: string;
|
|
19
|
+
});
|
|
20
|
+
toSerializable(): StoreErrorData;
|
|
21
|
+
}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import Type, {} from "typebox";
|
|
2
|
+
import { TrellisError } from "./TrellisError.js";
|
|
3
|
+
export const StoreErrorDataSchema = Type.Object({
|
|
4
|
+
id: Type.String(),
|
|
5
|
+
type: Type.Literal("StoreError"),
|
|
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 StoreError extends TrellisError {
|
|
12
|
+
name = "StoreError";
|
|
13
|
+
operation;
|
|
14
|
+
constructor(options) {
|
|
15
|
+
const { operation, ...baseOptions } = options;
|
|
16
|
+
const message = `Store ${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
|
+
}
|