@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/errors/index.js
ADDED
|
@@ -0,0 +1,238 @@
|
|
|
1
|
+
import { UnexpectedError, UnexpectedErrorDataSchema, } from "@oatscenter/result";
|
|
2
|
+
import { AuthError } from "./AuthError.js";
|
|
3
|
+
import { AuthErrorDataSchema } from "./AuthError.js";
|
|
4
|
+
import { ValidationError } from "./ValidationError.js";
|
|
5
|
+
import { ValidationErrorDataSchema } from "./ValidationError.js";
|
|
6
|
+
import { SchemaValidationError } from "./SchemaValidationError.js";
|
|
7
|
+
import { SchemaValidationErrorDataSchema, SchemaValidationIssueSchema, } from "./SchemaValidationError.js";
|
|
8
|
+
import { RemoteError } from "./RemoteError.js";
|
|
9
|
+
import { KVError } from "./KVError.js";
|
|
10
|
+
import { KVErrorDataSchema } from "./KVError.js";
|
|
11
|
+
import { OperationAlreadyTerminalError, OperationAlreadyTerminalErrorDataSchema, OperationMismatchError, OperationMismatchErrorDataSchema, OperationNotFoundError, OperationNotFoundErrorDataSchema, } from "./OperationLifecycleError.js";
|
|
12
|
+
import { StoreError } from "./StoreError.js";
|
|
13
|
+
import { StoreErrorDataSchema } from "./StoreError.js";
|
|
14
|
+
import { TransportError } from "./TransportError.js";
|
|
15
|
+
import { TransportErrorDataSchema } from "./TransportError.js";
|
|
16
|
+
import { TransferError } from "./TransferError.js";
|
|
17
|
+
import { TransferErrorDataSchema } from "./TransferError.js";
|
|
18
|
+
export { UnexpectedError } from "@oatscenter/result";
|
|
19
|
+
export { TrellisError } from "./TrellisError.js";
|
|
20
|
+
export { AuthError } from "./AuthError.js";
|
|
21
|
+
export { ValidationError } from "./ValidationError.js";
|
|
22
|
+
export { SchemaValidationError } from "./SchemaValidationError.js";
|
|
23
|
+
export { RemoteError } from "./RemoteError.js";
|
|
24
|
+
export { KVError } from "./KVError.js";
|
|
25
|
+
export { OperationAlreadyTerminalError, OperationMismatchError, OperationNotFoundError, } from "./OperationLifecycleError.js";
|
|
26
|
+
export { StoreError } from "./StoreError.js";
|
|
27
|
+
export { TransportError } from "./TransportError.js";
|
|
28
|
+
export { TransferError } from "./TransferError.js";
|
|
29
|
+
export { AuthErrorDataSchema } from "./AuthError.js";
|
|
30
|
+
export { ValidationErrorDataSchema, ValidationIssueSchema, } from "./ValidationError.js";
|
|
31
|
+
export { SchemaValidationErrorDataSchema, SchemaValidationIssueSchema, } from "./SchemaValidationError.js";
|
|
32
|
+
export { RemoteErrorDataSchema } from "./RemoteError.js";
|
|
33
|
+
export { KVErrorDataSchema } from "./KVError.js";
|
|
34
|
+
export { OperationAlreadyTerminalErrorDataSchema, OperationMismatchErrorDataSchema, OperationNotFoundErrorDataSchema, } from "./OperationLifecycleError.js";
|
|
35
|
+
export { StoreErrorDataSchema } from "./StoreError.js";
|
|
36
|
+
export { TransportErrorDataSchema, } from "./TransportError.js";
|
|
37
|
+
export { TransferErrorDataSchema, } from "./TransferError.js";
|
|
38
|
+
/**
|
|
39
|
+
* Single source of truth for all Trellis errors.
|
|
40
|
+
* This object is used for compile-time type inference.
|
|
41
|
+
*/
|
|
42
|
+
const TRANSPORTABLE_TRELLIS_ERRORS = {
|
|
43
|
+
UnexpectedError,
|
|
44
|
+
TransportError,
|
|
45
|
+
AuthError,
|
|
46
|
+
ValidationError,
|
|
47
|
+
SchemaValidationError,
|
|
48
|
+
KVError,
|
|
49
|
+
OperationNotFoundError,
|
|
50
|
+
OperationAlreadyTerminalError,
|
|
51
|
+
OperationMismatchError,
|
|
52
|
+
StoreError,
|
|
53
|
+
TransferError,
|
|
54
|
+
};
|
|
55
|
+
const TRELLIS_ERRORS = {
|
|
56
|
+
...TRANSPORTABLE_TRELLIS_ERRORS,
|
|
57
|
+
RemoteError,
|
|
58
|
+
};
|
|
59
|
+
export const BUILTIN_RPC_ERRORS = {
|
|
60
|
+
UnexpectedError: {
|
|
61
|
+
type: "UnexpectedError",
|
|
62
|
+
schema: UnexpectedErrorDataSchema,
|
|
63
|
+
fromSerializable(data) {
|
|
64
|
+
return new UnexpectedError({
|
|
65
|
+
id: data.id,
|
|
66
|
+
context: data.context,
|
|
67
|
+
traceId: data.traceId,
|
|
68
|
+
});
|
|
69
|
+
},
|
|
70
|
+
},
|
|
71
|
+
AuthError: {
|
|
72
|
+
type: "AuthError",
|
|
73
|
+
schema: AuthErrorDataSchema,
|
|
74
|
+
fromSerializable(data) {
|
|
75
|
+
return new AuthError({
|
|
76
|
+
reason: data.reason,
|
|
77
|
+
message: data.message,
|
|
78
|
+
id: data.id,
|
|
79
|
+
context: data.context,
|
|
80
|
+
});
|
|
81
|
+
},
|
|
82
|
+
},
|
|
83
|
+
TransportError: {
|
|
84
|
+
type: "TransportError",
|
|
85
|
+
schema: TransportErrorDataSchema,
|
|
86
|
+
fromSerializable(data) {
|
|
87
|
+
return new TransportError({
|
|
88
|
+
code: data.code,
|
|
89
|
+
message: data.message,
|
|
90
|
+
hint: data.hint,
|
|
91
|
+
id: data.id,
|
|
92
|
+
context: data.context,
|
|
93
|
+
traceId: data.traceId,
|
|
94
|
+
});
|
|
95
|
+
},
|
|
96
|
+
},
|
|
97
|
+
ValidationError: {
|
|
98
|
+
type: "ValidationError",
|
|
99
|
+
schema: ValidationErrorDataSchema,
|
|
100
|
+
fromSerializable(data) {
|
|
101
|
+
return new ValidationError({
|
|
102
|
+
errors: data.issues.map((issue) => ({
|
|
103
|
+
path: issue.path,
|
|
104
|
+
message: issue.message,
|
|
105
|
+
})),
|
|
106
|
+
id: data.id,
|
|
107
|
+
context: data.context,
|
|
108
|
+
});
|
|
109
|
+
},
|
|
110
|
+
},
|
|
111
|
+
SchemaValidationError: {
|
|
112
|
+
type: "SchemaValidationError",
|
|
113
|
+
schema: SchemaValidationErrorDataSchema,
|
|
114
|
+
fromSerializable(data) {
|
|
115
|
+
return new SchemaValidationError({
|
|
116
|
+
issues: data.issues,
|
|
117
|
+
id: data.id,
|
|
118
|
+
context: data.context,
|
|
119
|
+
});
|
|
120
|
+
},
|
|
121
|
+
},
|
|
122
|
+
KVError: {
|
|
123
|
+
type: "KVError",
|
|
124
|
+
schema: KVErrorDataSchema,
|
|
125
|
+
fromSerializable(data) {
|
|
126
|
+
return new KVError({
|
|
127
|
+
operation: data.operation,
|
|
128
|
+
id: data.id,
|
|
129
|
+
context: data.context,
|
|
130
|
+
});
|
|
131
|
+
},
|
|
132
|
+
},
|
|
133
|
+
OperationNotFoundError: {
|
|
134
|
+
type: "OperationNotFoundError",
|
|
135
|
+
schema: OperationNotFoundErrorDataSchema,
|
|
136
|
+
fromSerializable(data) {
|
|
137
|
+
return new OperationNotFoundError({
|
|
138
|
+
operationId: data.operationId,
|
|
139
|
+
message: data.message,
|
|
140
|
+
id: data.id,
|
|
141
|
+
context: data.context,
|
|
142
|
+
traceId: data.traceId,
|
|
143
|
+
});
|
|
144
|
+
},
|
|
145
|
+
},
|
|
146
|
+
OperationAlreadyTerminalError: {
|
|
147
|
+
type: "OperationAlreadyTerminalError",
|
|
148
|
+
schema: OperationAlreadyTerminalErrorDataSchema,
|
|
149
|
+
fromSerializable(data) {
|
|
150
|
+
return new OperationAlreadyTerminalError({
|
|
151
|
+
operationId: data.operationId,
|
|
152
|
+
state: data.state,
|
|
153
|
+
operation: data.operation,
|
|
154
|
+
service: data.service,
|
|
155
|
+
message: data.message,
|
|
156
|
+
id: data.id,
|
|
157
|
+
context: data.context,
|
|
158
|
+
traceId: data.traceId,
|
|
159
|
+
});
|
|
160
|
+
},
|
|
161
|
+
},
|
|
162
|
+
OperationMismatchError: {
|
|
163
|
+
type: "OperationMismatchError",
|
|
164
|
+
schema: OperationMismatchErrorDataSchema,
|
|
165
|
+
fromSerializable(data) {
|
|
166
|
+
return new OperationMismatchError({
|
|
167
|
+
operationId: data.operationId,
|
|
168
|
+
expectedService: data.expectedService,
|
|
169
|
+
expectedOperation: data.expectedOperation,
|
|
170
|
+
actualService: data.actualService,
|
|
171
|
+
actualOperation: data.actualOperation,
|
|
172
|
+
message: data.message,
|
|
173
|
+
id: data.id,
|
|
174
|
+
context: data.context,
|
|
175
|
+
traceId: data.traceId,
|
|
176
|
+
});
|
|
177
|
+
},
|
|
178
|
+
},
|
|
179
|
+
StoreError: {
|
|
180
|
+
type: "StoreError",
|
|
181
|
+
schema: StoreErrorDataSchema,
|
|
182
|
+
fromSerializable(data) {
|
|
183
|
+
return new StoreError({
|
|
184
|
+
operation: data.operation,
|
|
185
|
+
id: data.id,
|
|
186
|
+
context: data.context,
|
|
187
|
+
});
|
|
188
|
+
},
|
|
189
|
+
},
|
|
190
|
+
TransferError: {
|
|
191
|
+
type: "TransferError",
|
|
192
|
+
schema: TransferErrorDataSchema,
|
|
193
|
+
fromSerializable(data) {
|
|
194
|
+
return new TransferError({
|
|
195
|
+
operation: data.operation,
|
|
196
|
+
id: data.id,
|
|
197
|
+
context: data.context,
|
|
198
|
+
});
|
|
199
|
+
},
|
|
200
|
+
},
|
|
201
|
+
};
|
|
202
|
+
export function getBuiltinRpcError(type) {
|
|
203
|
+
return BUILTIN_RPC_ERRORS[type];
|
|
204
|
+
}
|
|
205
|
+
/**
|
|
206
|
+
* Reads the machine-readable failure code from any Trellis error shape.
|
|
207
|
+
*
|
|
208
|
+
* Declared RPC errors reconstruct into generated error classes that carry the
|
|
209
|
+
* code under `data`, built-in errors carry `reason`, and undecoded remote
|
|
210
|
+
* failures carry it under `remoteError`. Callers that must branch on a specific
|
|
211
|
+
* server code use this instead of matching one historical shape.
|
|
212
|
+
*/
|
|
213
|
+
export function machineErrorCode(error) {
|
|
214
|
+
if (!error || typeof error !== "object")
|
|
215
|
+
return undefined;
|
|
216
|
+
const record = error;
|
|
217
|
+
if (typeof record.code === "string")
|
|
218
|
+
return record.code;
|
|
219
|
+
if (typeof record.reason === "string")
|
|
220
|
+
return record.reason;
|
|
221
|
+
const data = record.data;
|
|
222
|
+
if (data && typeof data === "object") {
|
|
223
|
+
const dataRecord = data;
|
|
224
|
+
if (typeof dataRecord.code === "string")
|
|
225
|
+
return dataRecord.code;
|
|
226
|
+
if (typeof dataRecord.reason === "string")
|
|
227
|
+
return dataRecord.reason;
|
|
228
|
+
}
|
|
229
|
+
const remote = record.remoteError;
|
|
230
|
+
if (remote && typeof remote === "object") {
|
|
231
|
+
const remoteRecord = remote;
|
|
232
|
+
if (typeof remoteRecord.code === "string")
|
|
233
|
+
return remoteRecord.code;
|
|
234
|
+
if (typeof remoteRecord.reason === "string")
|
|
235
|
+
return remoteRecord.reason;
|
|
236
|
+
}
|
|
237
|
+
return undefined;
|
|
238
|
+
}
|
package/generated.d.ts
ADDED
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
/** Portable runtime support for generated Trellis packages. */
|
|
2
|
+
export { TrellisError } from "./errors/TrellisError.ts";
|
|
3
|
+
export { apiDescriptor, type Codec, codecs, participantDescriptor, type SerializableErrorData, } from "./generated_support.ts";
|
|
4
|
+
export type { ParticipantJobsFromResources, ParticipantKvFromResources, RuntimeApiFromGenerated, } from "./participant_runtime/participant.ts";
|
package/generated.js
ADDED
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
/** A runtime codec emitted and composed by generated Trellis packages. */
|
|
2
|
+
export type Codec<T> = Readonly<{
|
|
3
|
+
decode(value: unknown): T;
|
|
4
|
+
encode(value: T): unknown;
|
|
5
|
+
}>;
|
|
6
|
+
/** Serializable fields shared by generated declared errors. */
|
|
7
|
+
export type SerializableErrorData = {
|
|
8
|
+
id: string;
|
|
9
|
+
type: string;
|
|
10
|
+
message: string;
|
|
11
|
+
context?: Record<string, unknown>;
|
|
12
|
+
traceId?: string;
|
|
13
|
+
} & Record<string, unknown>;
|
|
14
|
+
type CodecValue<C> = C extends {
|
|
15
|
+
decode(value: unknown): infer T;
|
|
16
|
+
} ? T : never;
|
|
17
|
+
type OpenEnum<T extends string> = T | (string & {
|
|
18
|
+
readonly __openEnum?: never;
|
|
19
|
+
});
|
|
20
|
+
type Timestamp = string & {
|
|
21
|
+
readonly __timestamp: unique symbol;
|
|
22
|
+
};
|
|
23
|
+
type Ulid = string & {
|
|
24
|
+
readonly __ulid: unique symbol;
|
|
25
|
+
};
|
|
26
|
+
type OptionalCodec<T> = Codec<T | undefined> & Readonly<{
|
|
27
|
+
optional: true;
|
|
28
|
+
}>;
|
|
29
|
+
type ModelField = Codec<unknown> | OptionalCodec<unknown>;
|
|
30
|
+
type ModelValue<F extends Readonly<Record<string, ModelField>>> = {
|
|
31
|
+
[K in keyof F as F[K] extends OptionalCodec<unknown> ? never : K]: CodecValue<F[K]>;
|
|
32
|
+
} & {
|
|
33
|
+
[K in keyof F as F[K] extends OptionalCodec<unknown> ? K : never]?: Exclude<CodecValue<F[K]>, undefined>;
|
|
34
|
+
};
|
|
35
|
+
/** Browser-safe codec vocabulary consumed by generated TypeScript packages. */
|
|
36
|
+
export declare const codecs: Readonly<{
|
|
37
|
+
string: Readonly<{
|
|
38
|
+
decode(value: unknown): string;
|
|
39
|
+
encode(value: string): unknown;
|
|
40
|
+
}>;
|
|
41
|
+
bool: Readonly<{
|
|
42
|
+
decode(value: unknown): boolean;
|
|
43
|
+
encode(value: boolean): unknown;
|
|
44
|
+
}>;
|
|
45
|
+
i32: Readonly<{
|
|
46
|
+
decode(value: unknown): number;
|
|
47
|
+
encode(value: number): unknown;
|
|
48
|
+
}>;
|
|
49
|
+
u32: Readonly<{
|
|
50
|
+
decode(value: unknown): number;
|
|
51
|
+
encode(value: number): unknown;
|
|
52
|
+
}>;
|
|
53
|
+
i64: Readonly<{
|
|
54
|
+
decode(value: unknown): bigint;
|
|
55
|
+
encode(value: bigint): unknown;
|
|
56
|
+
}>;
|
|
57
|
+
u64: Readonly<{
|
|
58
|
+
decode(value: unknown): bigint;
|
|
59
|
+
encode(value: bigint): unknown;
|
|
60
|
+
}>;
|
|
61
|
+
f64: Readonly<{
|
|
62
|
+
decode(value: unknown): number;
|
|
63
|
+
encode(value: number): unknown;
|
|
64
|
+
}>;
|
|
65
|
+
bytes: Readonly<{
|
|
66
|
+
decode(value: unknown): Uint8Array<ArrayBufferLike>;
|
|
67
|
+
encode(value: Uint8Array<ArrayBufferLike>): unknown;
|
|
68
|
+
}>;
|
|
69
|
+
timestamp: Readonly<{
|
|
70
|
+
decode(value: unknown): Timestamp;
|
|
71
|
+
encode(value: Timestamp): unknown;
|
|
72
|
+
}>;
|
|
73
|
+
ulid: Readonly<{
|
|
74
|
+
decode(value: unknown): Ulid;
|
|
75
|
+
encode(value: Ulid): unknown;
|
|
76
|
+
}>;
|
|
77
|
+
openEnum<const T extends string>(values: readonly T[]): Codec<OpenEnum<T>>;
|
|
78
|
+
model<const F extends Readonly<Record<string, ModelField>>>(fields: F): Codec<ModelValue<F>>;
|
|
79
|
+
named<T, Named extends T>(_name: string, value: Codec<T>): Codec<Named>;
|
|
80
|
+
list<T>(item: Codec<T>): Codec<T[]>;
|
|
81
|
+
map<T>(item: Codec<T>): Codec<Record<string, T>>;
|
|
82
|
+
nullable<T>(value: Codec<T>): Codec<T | null>;
|
|
83
|
+
optional<T>(value: Codec<T>): OptionalCodec<T>;
|
|
84
|
+
ref<T>(get: () => Codec<T>): Codec<T>;
|
|
85
|
+
recursive<T>(build: (self: Codec<T>) => Codec<T>): Codec<T>;
|
|
86
|
+
}>;
|
|
87
|
+
type ApiDescriptorInput = Readonly<{
|
|
88
|
+
identity: string;
|
|
89
|
+
actions: Readonly<Record<string, Readonly<Record<string, unknown>>>>;
|
|
90
|
+
}>;
|
|
91
|
+
type PackageEvidenceInput = Readonly<{
|
|
92
|
+
rootPackage: string;
|
|
93
|
+
rootDigest: string;
|
|
94
|
+
packages: readonly Readonly<{
|
|
95
|
+
name: string;
|
|
96
|
+
version: string;
|
|
97
|
+
digest: string;
|
|
98
|
+
source: string;
|
|
99
|
+
}>[];
|
|
100
|
+
}>;
|
|
101
|
+
type ParticipantDescriptorInput = Readonly<{
|
|
102
|
+
kind: "service" | "device" | "app" | "agent";
|
|
103
|
+
id: string;
|
|
104
|
+
identity: string;
|
|
105
|
+
path: string;
|
|
106
|
+
implements: readonly ApiDescriptorInput[];
|
|
107
|
+
uses: readonly Readonly<Record<string, unknown>>[];
|
|
108
|
+
actionNames: Readonly<Record<string, string>>;
|
|
109
|
+
resources: Readonly<Record<string, Readonly<Record<string, unknown>>>>;
|
|
110
|
+
companion?: Readonly<{
|
|
111
|
+
participant: ParticipantDescriptorInput;
|
|
112
|
+
availability: "required" | "optional";
|
|
113
|
+
}>;
|
|
114
|
+
packageEvidence: PackageEvidenceInput;
|
|
115
|
+
}>;
|
|
116
|
+
/** Validate and retain generated API evidence without deriving authority from it. */
|
|
117
|
+
export declare function apiDescriptor<const T extends ApiDescriptorInput>(descriptor: T): T;
|
|
118
|
+
/** Validate and retain generated participant evidence without resolving grants or authority. */
|
|
119
|
+
export declare function participantDescriptor<const T extends ParticipantDescriptorInput>(descriptor: T): T;
|
|
120
|
+
export {};
|