@qlever-llc/trellis 0.10.4 → 0.10.7

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.
Files changed (85) hide show
  1. package/esm/generated-sdk/auth/client.d.ts +137 -76
  2. package/esm/generated-sdk/auth/client.d.ts.map +1 -1
  3. package/esm/generated-sdk/auth/mod.d.ts +1 -1
  4. package/esm/generated-sdk/auth/mod.d.ts.map +1 -1
  5. package/esm/generated-sdk/health/client.d.ts +27 -4
  6. package/esm/generated-sdk/health/client.d.ts.map +1 -1
  7. package/esm/generated-sdk/health/mod.d.ts +1 -1
  8. package/esm/generated-sdk/health/mod.d.ts.map +1 -1
  9. package/esm/generated-sdk/jobs/client.d.ts +38 -15
  10. package/esm/generated-sdk/jobs/client.d.ts.map +1 -1
  11. package/esm/generated-sdk/jobs/mod.d.ts +1 -1
  12. package/esm/generated-sdk/jobs/mod.d.ts.map +1 -1
  13. package/esm/generated-sdk/state/client.d.ts +36 -13
  14. package/esm/generated-sdk/state/client.d.ts.map +1 -1
  15. package/esm/generated-sdk/state/mod.d.ts +1 -1
  16. package/esm/generated-sdk/state/mod.d.ts.map +1 -1
  17. package/esm/generated-sdk/trellis-core/client.d.ts +17 -7
  18. package/esm/generated-sdk/trellis-core/client.d.ts.map +1 -1
  19. package/esm/generated-sdk/trellis-core/mod.d.ts +1 -1
  20. package/esm/generated-sdk/trellis-core/mod.d.ts.map +1 -1
  21. package/esm/index.d.ts +1 -1
  22. package/esm/index.d.ts.map +1 -1
  23. package/esm/server/service.d.ts +80 -2
  24. package/esm/server/service.d.ts.map +1 -1
  25. package/esm/server/service.js +100 -3
  26. package/esm/service/deno.d.ts +1 -1
  27. package/esm/service/deno.d.ts.map +1 -1
  28. package/esm/service/mod.d.ts +1 -1
  29. package/esm/service/mod.d.ts.map +1 -1
  30. package/esm/service/node.d.ts +1 -1
  31. package/esm/service/node.d.ts.map +1 -1
  32. package/esm/trellis.d.ts +17 -2
  33. package/esm/trellis.d.ts.map +1 -1
  34. package/esm/trellis.js +39 -3
  35. package/package.json +2 -2
  36. package/script/generated-sdk/auth/client.d.ts +137 -76
  37. package/script/generated-sdk/auth/client.d.ts.map +1 -1
  38. package/script/generated-sdk/auth/mod.d.ts +1 -1
  39. package/script/generated-sdk/auth/mod.d.ts.map +1 -1
  40. package/script/generated-sdk/health/client.d.ts +27 -4
  41. package/script/generated-sdk/health/client.d.ts.map +1 -1
  42. package/script/generated-sdk/health/mod.d.ts +1 -1
  43. package/script/generated-sdk/health/mod.d.ts.map +1 -1
  44. package/script/generated-sdk/jobs/client.d.ts +38 -15
  45. package/script/generated-sdk/jobs/client.d.ts.map +1 -1
  46. package/script/generated-sdk/jobs/mod.d.ts +1 -1
  47. package/script/generated-sdk/jobs/mod.d.ts.map +1 -1
  48. package/script/generated-sdk/state/client.d.ts +36 -13
  49. package/script/generated-sdk/state/client.d.ts.map +1 -1
  50. package/script/generated-sdk/state/mod.d.ts +1 -1
  51. package/script/generated-sdk/state/mod.d.ts.map +1 -1
  52. package/script/generated-sdk/trellis-core/client.d.ts +17 -7
  53. package/script/generated-sdk/trellis-core/client.d.ts.map +1 -1
  54. package/script/generated-sdk/trellis-core/mod.d.ts +1 -1
  55. package/script/generated-sdk/trellis-core/mod.d.ts.map +1 -1
  56. package/script/index.d.ts +1 -1
  57. package/script/index.d.ts.map +1 -1
  58. package/script/server/service.d.ts +80 -2
  59. package/script/server/service.d.ts.map +1 -1
  60. package/script/server/service.js +99 -2
  61. package/script/service/deno.d.ts +1 -1
  62. package/script/service/deno.d.ts.map +1 -1
  63. package/script/service/mod.d.ts +1 -1
  64. package/script/service/mod.d.ts.map +1 -1
  65. package/script/service/node.d.ts +1 -1
  66. package/script/service/node.d.ts.map +1 -1
  67. package/script/trellis.d.ts +17 -2
  68. package/script/trellis.d.ts.map +1 -1
  69. package/script/trellis.js +39 -3
  70. package/src/index.ts +1 -0
  71. package/src/sdk/_generated/auth/client.ts +100 -72
  72. package/src/sdk/_generated/auth/mod.ts +1 -1
  73. package/src/sdk/_generated/core/client.ts +25 -8
  74. package/src/sdk/_generated/core/mod.ts +1 -1
  75. package/src/sdk/_generated/health/client.ts +26 -5
  76. package/src/sdk/_generated/health/mod.ts +1 -1
  77. package/src/sdk/_generated/jobs/client.ts +35 -14
  78. package/src/sdk/_generated/jobs/mod.ts +1 -1
  79. package/src/sdk/_generated/state/client.ts +33 -12
  80. package/src/sdk/_generated/state/mod.ts +1 -1
  81. package/src/server/service.ts +485 -2
  82. package/src/service/deno.ts +1 -0
  83. package/src/service/mod.ts +1 -0
  84. package/src/service/node.ts +1 -0
  85. package/src/trellis.ts +80 -5
package/script/trellis.js CHANGED
@@ -295,6 +295,26 @@ function isTerminalRuntimeOperationSnapshot(value) {
295
295
  return isRuntimeOperationSnapshot(value) && (value.state === "completed" || value.state === "failed" ||
296
296
  value.state === "cancelled");
297
297
  }
298
+ function createEventListenerContext(args) {
299
+ const header = typeof args.payload === "object" && args.payload !== null
300
+ ? Reflect.get(args.payload, "header")
301
+ : undefined;
302
+ const id = typeof header === "object" && header !== null
303
+ ? Reflect.get(header, "id")
304
+ : undefined;
305
+ const time = typeof header === "object" && header !== null
306
+ ? Reflect.get(header, "time")
307
+ : undefined;
308
+ const sequence = Reflect.get(args.message, "seq");
309
+ return {
310
+ id: typeof id === "string" ? id : "",
311
+ time: new Date(typeof time === "string" ? time : 0),
312
+ subject: args.subject,
313
+ mode: args.mode,
314
+ ...(args.group ? { group: args.group } : {}),
315
+ ...(typeof sequence === "number" ? { sequence } : {}),
316
+ };
317
+ }
298
318
  let pendingInternalEventConsumers;
299
319
  /**
300
320
  * Creates a Trellis runtime with bootstrap-resolved bindings.
@@ -1931,7 +1951,12 @@ _Trellis_log = new WeakMap(), _Trellis_tasks = new WeakMap(), _Trellis_hasExplic
1931
1951
  __classPrivateFieldGet(this, _Trellis_log, "f").error({ error: m.error }, "Event validation failed");
1932
1952
  continue;
1933
1953
  }
1934
- const handlerResult = await result_1.AsyncResult.lift(fn(m));
1954
+ const handlerResult = await result_1.AsyncResult.lift(fn(m, createEventListenerContext({
1955
+ payload: m,
1956
+ subject: msg.subject,
1957
+ mode: "ephemeral",
1958
+ message: msg,
1959
+ })));
1935
1960
  if (handlerResult.isErr()) {
1936
1961
  __classPrivateFieldGet(this, _Trellis_log, "f").error({
1937
1962
  error: handlerResult.error.toSerializable(),
@@ -2068,7 +2093,12 @@ _Trellis_log = new WeakMap(), _Trellis_tasks = new WeakMap(), _Trellis_hasExplic
2068
2093
  msg.term();
2069
2094
  continue;
2070
2095
  }
2071
- const handlerResult = await result_1.AsyncResult.lift(fn(m));
2096
+ const handlerResult = await result_1.AsyncResult.lift(fn(m, createEventListenerContext({
2097
+ payload: m,
2098
+ subject: msg.subject,
2099
+ mode: "durable",
2100
+ message: msg,
2101
+ })));
2072
2102
  if (handlerResult.isErr()) {
2073
2103
  __classPrivateFieldGet(this, _Trellis_log, "f").error({
2074
2104
  error: handlerResult.error.toSerializable(),
@@ -2104,7 +2134,13 @@ _Trellis_log = new WeakMap(), _Trellis_tasks = new WeakMap(), _Trellis_hasExplic
2104
2134
  failed = true;
2105
2135
  break;
2106
2136
  }
2107
- const handlerResult = await result_1.AsyncResult.lift(registration.fn(eventPayload));
2137
+ const handlerResult = await result_1.AsyncResult.lift(registration.fn(eventPayload, createEventListenerContext({
2138
+ payload: eventPayload,
2139
+ subject: msg.subject,
2140
+ mode: "durable",
2141
+ group,
2142
+ message: msg,
2143
+ })));
2108
2144
  if (handlerResult.isErr()) {
2109
2145
  __classPrivateFieldGet(this, _Trellis_log, "f").error({
2110
2146
  error: handlerResult.error.toSerializable(),
package/src/index.ts CHANGED
@@ -200,6 +200,7 @@ export type {
200
200
  ClientTrellis,
201
201
  ConnectedTrellisClient,
202
202
  EventHandler,
203
+ EventListenerContext,
203
204
  EventName,
204
205
  EventOpts,
205
206
  EventPayload,
@@ -1,13 +1,21 @@
1
1
  // Generated from ./generated/contracts/manifests/trellis.auth@v1.json
2
- import type { AcceptedOperation, AsyncResult, BaseError, EventOpts, FeedSubscribeOpts, FeedSubscription, HandlerTrellis, MapStateStoreClient, MaybeAsync, OperationInputBuilder, OperationObserverCallbacks, OperationRef, OperationRefData, OperationRuntimeHandle, PreparedTrellisEvent, ReceiveTransferGrant, ReceiveTransferHandle, RequestOpts, Result, RpcHandlerContext, SendTransferGrant, SendTransferHandle, TerminalOperation, TransferCapableOperationInputBuilder, TrellisConnection, UnexpectedError, ValidationError, ValueStateStoreClient } from "../../../index.js";
2
+ import type { AcceptedOperation, AsyncResult, BaseError, EventListenerContext, EventOpts, FeedSubscribeOpts, FeedSubscription, HandlerTrellis, MapStateStoreClient, MaybeAsync, OperationInputBuilder, OperationObserverCallbacks, OperationRef, OperationRefData, OperationRuntimeHandle, OperationTransferHandle, PreparedTrellisEvent, ReceiveTransferGrant, ReceiveTransferHandle, RequestOpts, Result, RpcHandlerContext, SendTransferGrant, SendTransferHandle, TerminalOperation, TransferCapableOperationInputBuilder, TrellisConnection, UnexpectedError, ValidationError, ValueStateStoreClient } from "../../../index.js";
3
3
  import type { API, Api } from "./api.js";
4
4
  import type * as Types from "./types.js";
5
5
 
6
+ type WithDeps<TDeps> = [TDeps] extends [undefined] ? {} : { deps: TDeps };
7
+
6
8
  type EventCallback<TMessage> = {
7
- bivarianceHack(message: TMessage): MaybeAsync<void, BaseError>;
9
+ bivarianceHack(message: TMessage, context: EventListenerContext): MaybeAsync<void, BaseError>;
8
10
  }["bivarianceHack"];
9
11
 
10
- type RpcHandler<TInput, TOutput> = (args: { input: TInput; context: RpcHandlerContext; client: HandlerClient }) => MaybeAsync<TOutput, BaseError>;
12
+ type ServiceEventHandler<TEvent, TDeps = undefined> = (args: { event: TEvent; context: EventListenerContext; client: HandlerClient } & WithDeps<TDeps>) => MaybeAsync<void, BaseError>;
13
+
14
+ type RpcHandler<TInput, TOutput, TDeps = undefined> = (args: { input: TInput; context: RpcHandlerContext; client: HandlerClient } & WithDeps<TDeps>) => MaybeAsync<TOutput, BaseError>;
15
+
16
+ type FeedHandler<TInput, TEvent, TDeps = undefined> = (context: { input: TInput; caller: unknown; signal: AbortSignal; emit(event: TEvent): AsyncResult<void, ValidationError | UnexpectedError>; client: HandlerClient } & WithDeps<TDeps>) => unknown | Promise<unknown>;
17
+
18
+ type OperationHandler<TInput, TProgress, TOutput, TTransfer, TDeps = undefined> = (context: { input: TInput; op: OperationRuntimeHandle<TProgress, TOutput>; caller: unknown; client: HandlerClient } & TTransfer & WithDeps<TDeps>) => unknown | Promise<unknown>;
11
19
 
12
20
  export type TrellisAuthState = {};
13
21
 
@@ -120,85 +128,105 @@ export interface TrellisAuthClient {
120
128
  wait(): AsyncResult<void, BaseError>;
121
129
  }
122
130
 
123
- export interface Service extends Client {
131
+ export interface Service extends TrellisAuthClient {
124
132
  readonly handle: ServiceHandle;
133
+ with<TDeps>(deps: TDeps): ServiceWithDeps<TDeps>;
134
+ }
135
+
136
+ export type ServiceWithDeps<TDeps> = Omit<TrellisAuthClient, "event"> & {
137
+ readonly event: ServiceEventSurface<TDeps>;
138
+ readonly handle: ServiceHandle<TDeps>;
139
+ with<TNextDeps>(deps: TNextDeps): ServiceWithDeps<TNextDeps>;
140
+ };
141
+
142
+ export interface ServiceEventSurface<TDeps> {
143
+ readonly auth: {
144
+ connectionsClosed: { publish(event: Omit<Types.AuthConnectionsClosedEvent, "header">): AsyncResult<void, ValidationError | UnexpectedError>; prepare(event: Omit<Types.AuthConnectionsClosedEvent, "header">): Result<PreparedTrellisEvent<Omit<Types.AuthConnectionsClosedEvent, "header">>, ValidationError | UnexpectedError>; listen(handler: ServiceEventHandler<Types.AuthConnectionsClosedEvent, TDeps>, subjectData?: Record<string, unknown>, opts?: EventOpts): AsyncResult<void, ValidationError | UnexpectedError>; };
145
+ connectionsKicked: { publish(event: Omit<Types.AuthConnectionsKickedEvent, "header">): AsyncResult<void, ValidationError | UnexpectedError>; prepare(event: Omit<Types.AuthConnectionsKickedEvent, "header">): Result<PreparedTrellisEvent<Omit<Types.AuthConnectionsKickedEvent, "header">>, ValidationError | UnexpectedError>; listen(handler: ServiceEventHandler<Types.AuthConnectionsKickedEvent, TDeps>, subjectData?: Record<string, unknown>, opts?: EventOpts): AsyncResult<void, ValidationError | UnexpectedError>; };
146
+ connectionsOpened: { publish(event: Omit<Types.AuthConnectionsOpenedEvent, "header">): AsyncResult<void, ValidationError | UnexpectedError>; prepare(event: Omit<Types.AuthConnectionsOpenedEvent, "header">): Result<PreparedTrellisEvent<Omit<Types.AuthConnectionsOpenedEvent, "header">>, ValidationError | UnexpectedError>; listen(handler: ServiceEventHandler<Types.AuthConnectionsOpenedEvent, TDeps>, subjectData?: Record<string, unknown>, opts?: EventOpts): AsyncResult<void, ValidationError | UnexpectedError>; };
147
+ deviceUserAuthoritiesApproved: { publish(event: Omit<Types.AuthDeviceUserAuthoritiesApprovedEvent, "header">): AsyncResult<void, ValidationError | UnexpectedError>; prepare(event: Omit<Types.AuthDeviceUserAuthoritiesApprovedEvent, "header">): Result<PreparedTrellisEvent<Omit<Types.AuthDeviceUserAuthoritiesApprovedEvent, "header">>, ValidationError | UnexpectedError>; listen(handler: ServiceEventHandler<Types.AuthDeviceUserAuthoritiesApprovedEvent, TDeps>, subjectData?: Record<string, unknown>, opts?: EventOpts): AsyncResult<void, ValidationError | UnexpectedError>; };
148
+ deviceUserAuthoritiesRequested: { publish(event: Omit<Types.AuthDeviceUserAuthoritiesRequestedEvent, "header">): AsyncResult<void, ValidationError | UnexpectedError>; prepare(event: Omit<Types.AuthDeviceUserAuthoritiesRequestedEvent, "header">): Result<PreparedTrellisEvent<Omit<Types.AuthDeviceUserAuthoritiesRequestedEvent, "header">>, ValidationError | UnexpectedError>; listen(handler: ServiceEventHandler<Types.AuthDeviceUserAuthoritiesRequestedEvent, TDeps>, subjectData?: Record<string, unknown>, opts?: EventOpts): AsyncResult<void, ValidationError | UnexpectedError>; };
149
+ deviceUserAuthoritiesResolved: { publish(event: Omit<Types.AuthDeviceUserAuthoritiesResolvedEvent, "header">): AsyncResult<void, ValidationError | UnexpectedError>; prepare(event: Omit<Types.AuthDeviceUserAuthoritiesResolvedEvent, "header">): Result<PreparedTrellisEvent<Omit<Types.AuthDeviceUserAuthoritiesResolvedEvent, "header">>, ValidationError | UnexpectedError>; listen(handler: ServiceEventHandler<Types.AuthDeviceUserAuthoritiesResolvedEvent, TDeps>, subjectData?: Record<string, unknown>, opts?: EventOpts): AsyncResult<void, ValidationError | UnexpectedError>; };
150
+ deviceUserAuthoritiesReviewRequested: { publish(event: Omit<Types.AuthDeviceUserAuthoritiesReviewRequestedEvent, "header">): AsyncResult<void, ValidationError | UnexpectedError>; prepare(event: Omit<Types.AuthDeviceUserAuthoritiesReviewRequestedEvent, "header">): Result<PreparedTrellisEvent<Omit<Types.AuthDeviceUserAuthoritiesReviewRequestedEvent, "header">>, ValidationError | UnexpectedError>; listen(handler: ServiceEventHandler<Types.AuthDeviceUserAuthoritiesReviewRequestedEvent, TDeps>, subjectData?: Record<string, unknown>, opts?: EventOpts): AsyncResult<void, ValidationError | UnexpectedError>; };
151
+ sessionsRevoked: { publish(event: Omit<Types.AuthSessionsRevokedEvent, "header">): AsyncResult<void, ValidationError | UnexpectedError>; prepare(event: Omit<Types.AuthSessionsRevokedEvent, "header">): Result<PreparedTrellisEvent<Omit<Types.AuthSessionsRevokedEvent, "header">>, ValidationError | UnexpectedError>; listen(handler: ServiceEventHandler<Types.AuthSessionsRevokedEvent, TDeps>, subjectData?: Record<string, unknown>, opts?: EventOpts): AsyncResult<void, ValidationError | UnexpectedError>; };
152
+ };
125
153
  }
126
154
 
127
- export interface ServiceHandle {
155
+ export interface ServiceHandle<TDeps = undefined> {
128
156
  readonly rpc: {
129
157
  readonly auth: {
130
- capabilitiesList(handler: RpcHandler<Types.AuthCapabilitiesListInput, Types.AuthCapabilitiesListOutput>): Promise<void>;
131
- capabilityGroupsDelete(handler: RpcHandler<Types.AuthCapabilityGroupsDeleteInput, Types.AuthCapabilityGroupsDeleteOutput>): Promise<void>;
132
- capabilityGroupsGet(handler: RpcHandler<Types.AuthCapabilityGroupsGetInput, Types.AuthCapabilityGroupsGetOutput>): Promise<void>;
133
- capabilityGroupsList(handler: RpcHandler<Types.AuthCapabilityGroupsListInput, Types.AuthCapabilityGroupsListOutput>): Promise<void>;
134
- capabilityGroupsPut(handler: RpcHandler<Types.AuthCapabilityGroupsPutInput, Types.AuthCapabilityGroupsPutOutput>): Promise<void>;
135
- catalogIssuesResolve(handler: RpcHandler<Types.AuthCatalogIssuesResolveInput, Types.AuthCatalogIssuesResolveOutput>): Promise<void>;
136
- connectionsKick(handler: RpcHandler<Types.AuthConnectionsKickInput, Types.AuthConnectionsKickOutput>): Promise<void>;
137
- connectionsList(handler: RpcHandler<Types.AuthConnectionsListInput, Types.AuthConnectionsListOutput>): Promise<void>;
138
- deploymentAuthorityAcceptMigration(handler: RpcHandler<Types.AuthDeploymentAuthorityAcceptMigrationInput, Types.AuthDeploymentAuthorityAcceptMigrationOutput>): Promise<void>;
139
- deploymentAuthorityAcceptUpdate(handler: RpcHandler<Types.AuthDeploymentAuthorityAcceptUpdateInput, Types.AuthDeploymentAuthorityAcceptUpdateOutput>): Promise<void>;
140
- deploymentAuthorityGet(handler: RpcHandler<Types.AuthDeploymentAuthorityGetInput, Types.AuthDeploymentAuthorityGetOutput>): Promise<void>;
141
- deploymentAuthorityGrantOverridesList(handler: RpcHandler<Types.AuthDeploymentAuthorityGrantOverridesListInput, Types.AuthDeploymentAuthorityGrantOverridesListOutput>): Promise<void>;
142
- deploymentAuthorityGrantOverridesPut(handler: RpcHandler<Types.AuthDeploymentAuthorityGrantOverridesPutInput, Types.AuthDeploymentAuthorityGrantOverridesPutOutput>): Promise<void>;
143
- deploymentAuthorityGrantOverridesRemove(handler: RpcHandler<Types.AuthDeploymentAuthorityGrantOverridesRemoveInput, Types.AuthDeploymentAuthorityGrantOverridesRemoveOutput>): Promise<void>;
144
- deploymentAuthorityList(handler: RpcHandler<Types.AuthDeploymentAuthorityListInput, Types.AuthDeploymentAuthorityListOutput>): Promise<void>;
145
- deploymentAuthorityPlan(handler: RpcHandler<Types.AuthDeploymentAuthorityPlanInput, Types.AuthDeploymentAuthorityPlanOutput>): Promise<void>;
146
- deploymentAuthorityPlansGet(handler: RpcHandler<Types.AuthDeploymentAuthorityPlansGetInput, Types.AuthDeploymentAuthorityPlansGetOutput>): Promise<void>;
147
- deploymentAuthorityPlansList(handler: RpcHandler<Types.AuthDeploymentAuthorityPlansListInput, Types.AuthDeploymentAuthorityPlansListOutput>): Promise<void>;
148
- deploymentAuthorityReconcile(handler: RpcHandler<Types.AuthDeploymentAuthorityReconcileInput, Types.AuthDeploymentAuthorityReconcileOutput>): Promise<void>;
149
- deploymentAuthorityReject(handler: RpcHandler<Types.AuthDeploymentAuthorityRejectInput, Types.AuthDeploymentAuthorityRejectOutput>): Promise<void>;
150
- deploymentsCreate(handler: RpcHandler<Types.AuthDeploymentsCreateInput, Types.AuthDeploymentsCreateOutput>): Promise<void>;
151
- deploymentsDisable(handler: RpcHandler<Types.AuthDeploymentsDisableInput, Types.AuthDeploymentsDisableOutput>): Promise<void>;
152
- deploymentsEnable(handler: RpcHandler<Types.AuthDeploymentsEnableInput, Types.AuthDeploymentsEnableOutput>): Promise<void>;
153
- deploymentsList(handler: RpcHandler<Types.AuthDeploymentsListInput, Types.AuthDeploymentsListOutput>): Promise<void>;
154
- deploymentsRemove(handler: RpcHandler<Types.AuthDeploymentsRemoveInput, Types.AuthDeploymentsRemoveOutput>): Promise<void>;
155
- deviceUserAuthoritiesList(handler: RpcHandler<Types.AuthDeviceUserAuthoritiesListInput, Types.AuthDeviceUserAuthoritiesListOutput>): Promise<void>;
156
- deviceUserAuthoritiesReviewsDecide(handler: RpcHandler<Types.AuthDeviceUserAuthoritiesReviewsDecideInput, Types.AuthDeviceUserAuthoritiesReviewsDecideOutput>): Promise<void>;
157
- deviceUserAuthoritiesReviewsList(handler: RpcHandler<Types.AuthDeviceUserAuthoritiesReviewsListInput, Types.AuthDeviceUserAuthoritiesReviewsListOutput>): Promise<void>;
158
- deviceUserAuthoritiesRevoke(handler: RpcHandler<Types.AuthDeviceUserAuthoritiesRevokeInput, Types.AuthDeviceUserAuthoritiesRevokeOutput>): Promise<void>;
159
- devicesConnectInfoGet(handler: RpcHandler<Types.AuthDevicesConnectInfoGetInput, Types.AuthDevicesConnectInfoGetOutput>): Promise<void>;
160
- devicesDisable(handler: RpcHandler<Types.AuthDevicesDisableInput, Types.AuthDevicesDisableOutput>): Promise<void>;
161
- devicesEnable(handler: RpcHandler<Types.AuthDevicesEnableInput, Types.AuthDevicesEnableOutput>): Promise<void>;
162
- devicesList(handler: RpcHandler<Types.AuthDevicesListInput, Types.AuthDevicesListOutput>): Promise<void>;
163
- devicesProvision(handler: RpcHandler<Types.AuthDevicesProvisionInput, Types.AuthDevicesProvisionOutput>): Promise<void>;
164
- devicesRemove(handler: RpcHandler<Types.AuthDevicesRemoveInput, Types.AuthDevicesRemoveOutput>): Promise<void>;
165
- health(handler: RpcHandler<Types.AuthHealthInput, Types.AuthHealthOutput>): Promise<void>;
166
- identitiesList(handler: RpcHandler<Types.AuthIdentitiesListInput, Types.AuthIdentitiesListOutput>): Promise<void>;
167
- identityGrantsList(handler: RpcHandler<Types.AuthIdentityGrantsListInput, Types.AuthIdentityGrantsListOutput>): Promise<void>;
168
- identityGrantsRevoke(handler: RpcHandler<Types.AuthIdentityGrantsRevokeInput, Types.AuthIdentityGrantsRevokeOutput>): Promise<void>;
169
- portalsGet(handler: RpcHandler<Types.AuthPortalsGetInput, Types.AuthPortalsGetOutput>): Promise<void>;
170
- portalsList(handler: RpcHandler<Types.AuthPortalsListInput, Types.AuthPortalsListOutput>): Promise<void>;
171
- portalsLoginSettingsGet(handler: RpcHandler<Types.AuthPortalsLoginSettingsGetInput, Types.AuthPortalsLoginSettingsGetOutput>): Promise<void>;
172
- portalsLoginSettingsUpdate(handler: RpcHandler<Types.AuthPortalsLoginSettingsUpdateInput, Types.AuthPortalsLoginSettingsUpdateOutput>): Promise<void>;
173
- portalsPut(handler: RpcHandler<Types.AuthPortalsPutInput, Types.AuthPortalsPutOutput>): Promise<void>;
174
- portalsRemove(handler: RpcHandler<Types.AuthPortalsRemoveInput, Types.AuthPortalsRemoveOutput>): Promise<void>;
175
- portalsRoutesPut(handler: RpcHandler<Types.AuthPortalsRoutesPutInput, Types.AuthPortalsRoutesPutOutput>): Promise<void>;
176
- portalsRoutesRemove(handler: RpcHandler<Types.AuthPortalsRoutesRemoveInput, Types.AuthPortalsRoutesRemoveOutput>): Promise<void>;
177
- requestsValidate(handler: RpcHandler<Types.AuthRequestsValidateInput, Types.AuthRequestsValidateOutput>): Promise<void>;
178
- serviceInstancesDisable(handler: RpcHandler<Types.AuthServiceInstancesDisableInput, Types.AuthServiceInstancesDisableOutput>): Promise<void>;
179
- serviceInstancesEnable(handler: RpcHandler<Types.AuthServiceInstancesEnableInput, Types.AuthServiceInstancesEnableOutput>): Promise<void>;
180
- serviceInstancesList(handler: RpcHandler<Types.AuthServiceInstancesListInput, Types.AuthServiceInstancesListOutput>): Promise<void>;
181
- serviceInstancesProvision(handler: RpcHandler<Types.AuthServiceInstancesProvisionInput, Types.AuthServiceInstancesProvisionOutput>): Promise<void>;
182
- serviceInstancesRemove(handler: RpcHandler<Types.AuthServiceInstancesRemoveInput, Types.AuthServiceInstancesRemoveOutput>): Promise<void>;
183
- sessionsList(handler: RpcHandler<Types.AuthSessionsListInput, Types.AuthSessionsListOutput>): Promise<void>;
184
- sessionsLogout(handler: RpcHandler<Types.AuthSessionsLogoutInput, Types.AuthSessionsLogoutOutput>): Promise<void>;
185
- sessionsMe(handler: RpcHandler<Types.AuthSessionsMeInput, Types.AuthSessionsMeOutput>): Promise<void>;
186
- sessionsRevoke(handler: RpcHandler<Types.AuthSessionsRevokeInput, Types.AuthSessionsRevokeOutput>): Promise<void>;
187
- userIdentitiesList(handler: RpcHandler<Types.AuthUserIdentitiesListInput, Types.AuthUserIdentitiesListOutput>): Promise<void>;
188
- userIdentitiesUnlink(handler: RpcHandler<Types.AuthUserIdentitiesUnlinkInput, Types.AuthUserIdentitiesUnlinkOutput>): Promise<void>;
189
- usersCreate(handler: RpcHandler<Types.AuthUsersCreateInput, Types.AuthUsersCreateOutput>): Promise<void>;
190
- usersGet(handler: RpcHandler<Types.AuthUsersGetInput, Types.AuthUsersGetOutput>): Promise<void>;
191
- usersIdentityLinkCreate(handler: RpcHandler<Types.AuthUsersIdentityLinkCreateInput, Types.AuthUsersIdentityLinkCreateOutput>): Promise<void>;
192
- usersList(handler: RpcHandler<Types.AuthUsersListInput, Types.AuthUsersListOutput>): Promise<void>;
193
- usersPasswordChange(handler: RpcHandler<Types.AuthUsersPasswordChangeInput, Types.AuthUsersPasswordChangeOutput>): Promise<void>;
194
- usersPasswordResetCreate(handler: RpcHandler<Types.AuthUsersPasswordResetCreateInput, Types.AuthUsersPasswordResetCreateOutput>): Promise<void>;
195
- usersUpdate(handler: RpcHandler<Types.AuthUsersUpdateInput, Types.AuthUsersUpdateOutput>): Promise<void>;
158
+ capabilitiesList(handler: RpcHandler<Types.AuthCapabilitiesListInput, Types.AuthCapabilitiesListOutput, TDeps>): Promise<void>;
159
+ capabilityGroupsDelete(handler: RpcHandler<Types.AuthCapabilityGroupsDeleteInput, Types.AuthCapabilityGroupsDeleteOutput, TDeps>): Promise<void>;
160
+ capabilityGroupsGet(handler: RpcHandler<Types.AuthCapabilityGroupsGetInput, Types.AuthCapabilityGroupsGetOutput, TDeps>): Promise<void>;
161
+ capabilityGroupsList(handler: RpcHandler<Types.AuthCapabilityGroupsListInput, Types.AuthCapabilityGroupsListOutput, TDeps>): Promise<void>;
162
+ capabilityGroupsPut(handler: RpcHandler<Types.AuthCapabilityGroupsPutInput, Types.AuthCapabilityGroupsPutOutput, TDeps>): Promise<void>;
163
+ catalogIssuesResolve(handler: RpcHandler<Types.AuthCatalogIssuesResolveInput, Types.AuthCatalogIssuesResolveOutput, TDeps>): Promise<void>;
164
+ connectionsKick(handler: RpcHandler<Types.AuthConnectionsKickInput, Types.AuthConnectionsKickOutput, TDeps>): Promise<void>;
165
+ connectionsList(handler: RpcHandler<Types.AuthConnectionsListInput, Types.AuthConnectionsListOutput, TDeps>): Promise<void>;
166
+ deploymentAuthorityAcceptMigration(handler: RpcHandler<Types.AuthDeploymentAuthorityAcceptMigrationInput, Types.AuthDeploymentAuthorityAcceptMigrationOutput, TDeps>): Promise<void>;
167
+ deploymentAuthorityAcceptUpdate(handler: RpcHandler<Types.AuthDeploymentAuthorityAcceptUpdateInput, Types.AuthDeploymentAuthorityAcceptUpdateOutput, TDeps>): Promise<void>;
168
+ deploymentAuthorityGet(handler: RpcHandler<Types.AuthDeploymentAuthorityGetInput, Types.AuthDeploymentAuthorityGetOutput, TDeps>): Promise<void>;
169
+ deploymentAuthorityGrantOverridesList(handler: RpcHandler<Types.AuthDeploymentAuthorityGrantOverridesListInput, Types.AuthDeploymentAuthorityGrantOverridesListOutput, TDeps>): Promise<void>;
170
+ deploymentAuthorityGrantOverridesPut(handler: RpcHandler<Types.AuthDeploymentAuthorityGrantOverridesPutInput, Types.AuthDeploymentAuthorityGrantOverridesPutOutput, TDeps>): Promise<void>;
171
+ deploymentAuthorityGrantOverridesRemove(handler: RpcHandler<Types.AuthDeploymentAuthorityGrantOverridesRemoveInput, Types.AuthDeploymentAuthorityGrantOverridesRemoveOutput, TDeps>): Promise<void>;
172
+ deploymentAuthorityList(handler: RpcHandler<Types.AuthDeploymentAuthorityListInput, Types.AuthDeploymentAuthorityListOutput, TDeps>): Promise<void>;
173
+ deploymentAuthorityPlan(handler: RpcHandler<Types.AuthDeploymentAuthorityPlanInput, Types.AuthDeploymentAuthorityPlanOutput, TDeps>): Promise<void>;
174
+ deploymentAuthorityPlansGet(handler: RpcHandler<Types.AuthDeploymentAuthorityPlansGetInput, Types.AuthDeploymentAuthorityPlansGetOutput, TDeps>): Promise<void>;
175
+ deploymentAuthorityPlansList(handler: RpcHandler<Types.AuthDeploymentAuthorityPlansListInput, Types.AuthDeploymentAuthorityPlansListOutput, TDeps>): Promise<void>;
176
+ deploymentAuthorityReconcile(handler: RpcHandler<Types.AuthDeploymentAuthorityReconcileInput, Types.AuthDeploymentAuthorityReconcileOutput, TDeps>): Promise<void>;
177
+ deploymentAuthorityReject(handler: RpcHandler<Types.AuthDeploymentAuthorityRejectInput, Types.AuthDeploymentAuthorityRejectOutput, TDeps>): Promise<void>;
178
+ deploymentsCreate(handler: RpcHandler<Types.AuthDeploymentsCreateInput, Types.AuthDeploymentsCreateOutput, TDeps>): Promise<void>;
179
+ deploymentsDisable(handler: RpcHandler<Types.AuthDeploymentsDisableInput, Types.AuthDeploymentsDisableOutput, TDeps>): Promise<void>;
180
+ deploymentsEnable(handler: RpcHandler<Types.AuthDeploymentsEnableInput, Types.AuthDeploymentsEnableOutput, TDeps>): Promise<void>;
181
+ deploymentsList(handler: RpcHandler<Types.AuthDeploymentsListInput, Types.AuthDeploymentsListOutput, TDeps>): Promise<void>;
182
+ deploymentsRemove(handler: RpcHandler<Types.AuthDeploymentsRemoveInput, Types.AuthDeploymentsRemoveOutput, TDeps>): Promise<void>;
183
+ deviceUserAuthoritiesList(handler: RpcHandler<Types.AuthDeviceUserAuthoritiesListInput, Types.AuthDeviceUserAuthoritiesListOutput, TDeps>): Promise<void>;
184
+ deviceUserAuthoritiesReviewsDecide(handler: RpcHandler<Types.AuthDeviceUserAuthoritiesReviewsDecideInput, Types.AuthDeviceUserAuthoritiesReviewsDecideOutput, TDeps>): Promise<void>;
185
+ deviceUserAuthoritiesReviewsList(handler: RpcHandler<Types.AuthDeviceUserAuthoritiesReviewsListInput, Types.AuthDeviceUserAuthoritiesReviewsListOutput, TDeps>): Promise<void>;
186
+ deviceUserAuthoritiesRevoke(handler: RpcHandler<Types.AuthDeviceUserAuthoritiesRevokeInput, Types.AuthDeviceUserAuthoritiesRevokeOutput, TDeps>): Promise<void>;
187
+ devicesConnectInfoGet(handler: RpcHandler<Types.AuthDevicesConnectInfoGetInput, Types.AuthDevicesConnectInfoGetOutput, TDeps>): Promise<void>;
188
+ devicesDisable(handler: RpcHandler<Types.AuthDevicesDisableInput, Types.AuthDevicesDisableOutput, TDeps>): Promise<void>;
189
+ devicesEnable(handler: RpcHandler<Types.AuthDevicesEnableInput, Types.AuthDevicesEnableOutput, TDeps>): Promise<void>;
190
+ devicesList(handler: RpcHandler<Types.AuthDevicesListInput, Types.AuthDevicesListOutput, TDeps>): Promise<void>;
191
+ devicesProvision(handler: RpcHandler<Types.AuthDevicesProvisionInput, Types.AuthDevicesProvisionOutput, TDeps>): Promise<void>;
192
+ devicesRemove(handler: RpcHandler<Types.AuthDevicesRemoveInput, Types.AuthDevicesRemoveOutput, TDeps>): Promise<void>;
193
+ health(handler: RpcHandler<Types.AuthHealthInput, Types.AuthHealthOutput, TDeps>): Promise<void>;
194
+ identitiesList(handler: RpcHandler<Types.AuthIdentitiesListInput, Types.AuthIdentitiesListOutput, TDeps>): Promise<void>;
195
+ identityGrantsList(handler: RpcHandler<Types.AuthIdentityGrantsListInput, Types.AuthIdentityGrantsListOutput, TDeps>): Promise<void>;
196
+ identityGrantsRevoke(handler: RpcHandler<Types.AuthIdentityGrantsRevokeInput, Types.AuthIdentityGrantsRevokeOutput, TDeps>): Promise<void>;
197
+ portalsGet(handler: RpcHandler<Types.AuthPortalsGetInput, Types.AuthPortalsGetOutput, TDeps>): Promise<void>;
198
+ portalsList(handler: RpcHandler<Types.AuthPortalsListInput, Types.AuthPortalsListOutput, TDeps>): Promise<void>;
199
+ portalsLoginSettingsGet(handler: RpcHandler<Types.AuthPortalsLoginSettingsGetInput, Types.AuthPortalsLoginSettingsGetOutput, TDeps>): Promise<void>;
200
+ portalsLoginSettingsUpdate(handler: RpcHandler<Types.AuthPortalsLoginSettingsUpdateInput, Types.AuthPortalsLoginSettingsUpdateOutput, TDeps>): Promise<void>;
201
+ portalsPut(handler: RpcHandler<Types.AuthPortalsPutInput, Types.AuthPortalsPutOutput, TDeps>): Promise<void>;
202
+ portalsRemove(handler: RpcHandler<Types.AuthPortalsRemoveInput, Types.AuthPortalsRemoveOutput, TDeps>): Promise<void>;
203
+ portalsRoutesPut(handler: RpcHandler<Types.AuthPortalsRoutesPutInput, Types.AuthPortalsRoutesPutOutput, TDeps>): Promise<void>;
204
+ portalsRoutesRemove(handler: RpcHandler<Types.AuthPortalsRoutesRemoveInput, Types.AuthPortalsRoutesRemoveOutput, TDeps>): Promise<void>;
205
+ requestsValidate(handler: RpcHandler<Types.AuthRequestsValidateInput, Types.AuthRequestsValidateOutput, TDeps>): Promise<void>;
206
+ serviceInstancesDisable(handler: RpcHandler<Types.AuthServiceInstancesDisableInput, Types.AuthServiceInstancesDisableOutput, TDeps>): Promise<void>;
207
+ serviceInstancesEnable(handler: RpcHandler<Types.AuthServiceInstancesEnableInput, Types.AuthServiceInstancesEnableOutput, TDeps>): Promise<void>;
208
+ serviceInstancesList(handler: RpcHandler<Types.AuthServiceInstancesListInput, Types.AuthServiceInstancesListOutput, TDeps>): Promise<void>;
209
+ serviceInstancesProvision(handler: RpcHandler<Types.AuthServiceInstancesProvisionInput, Types.AuthServiceInstancesProvisionOutput, TDeps>): Promise<void>;
210
+ serviceInstancesRemove(handler: RpcHandler<Types.AuthServiceInstancesRemoveInput, Types.AuthServiceInstancesRemoveOutput, TDeps>): Promise<void>;
211
+ sessionsList(handler: RpcHandler<Types.AuthSessionsListInput, Types.AuthSessionsListOutput, TDeps>): Promise<void>;
212
+ sessionsLogout(handler: RpcHandler<Types.AuthSessionsLogoutInput, Types.AuthSessionsLogoutOutput, TDeps>): Promise<void>;
213
+ sessionsMe(handler: RpcHandler<Types.AuthSessionsMeInput, Types.AuthSessionsMeOutput, TDeps>): Promise<void>;
214
+ sessionsRevoke(handler: RpcHandler<Types.AuthSessionsRevokeInput, Types.AuthSessionsRevokeOutput, TDeps>): Promise<void>;
215
+ userIdentitiesList(handler: RpcHandler<Types.AuthUserIdentitiesListInput, Types.AuthUserIdentitiesListOutput, TDeps>): Promise<void>;
216
+ userIdentitiesUnlink(handler: RpcHandler<Types.AuthUserIdentitiesUnlinkInput, Types.AuthUserIdentitiesUnlinkOutput, TDeps>): Promise<void>;
217
+ usersCreate(handler: RpcHandler<Types.AuthUsersCreateInput, Types.AuthUsersCreateOutput, TDeps>): Promise<void>;
218
+ usersGet(handler: RpcHandler<Types.AuthUsersGetInput, Types.AuthUsersGetOutput, TDeps>): Promise<void>;
219
+ usersIdentityLinkCreate(handler: RpcHandler<Types.AuthUsersIdentityLinkCreateInput, Types.AuthUsersIdentityLinkCreateOutput, TDeps>): Promise<void>;
220
+ usersList(handler: RpcHandler<Types.AuthUsersListInput, Types.AuthUsersListOutput, TDeps>): Promise<void>;
221
+ usersPasswordChange(handler: RpcHandler<Types.AuthUsersPasswordChangeInput, Types.AuthUsersPasswordChangeOutput, TDeps>): Promise<void>;
222
+ usersPasswordResetCreate(handler: RpcHandler<Types.AuthUsersPasswordResetCreateInput, Types.AuthUsersPasswordResetCreateOutput, TDeps>): Promise<void>;
223
+ usersUpdate(handler: RpcHandler<Types.AuthUsersUpdateInput, Types.AuthUsersUpdateOutput, TDeps>): Promise<void>;
196
224
  };
197
225
  };
198
226
  readonly feed: {};
199
227
  readonly operation: {
200
228
  readonly auth: {
201
- deviceUserAuthoritiesResolve: ((handler: (context: { input: Types.AuthDeviceUserAuthoritiesResolveInput; client: HandlerClient }) => unknown | Promise<unknown>) => Promise<void>) & { accept(args: { sessionKey: string }): AsyncResult<AcceptedOperation<Types.AuthDeviceUserAuthoritiesResolveProgress, Types.AuthDeviceUserAuthoritiesResolveOutput>, UnexpectedError>; control(operationId: string): AsyncResult<OperationRuntimeHandle<Types.AuthDeviceUserAuthoritiesResolveProgress, Types.AuthDeviceUserAuthoritiesResolveOutput>, BaseError>; };
229
+ deviceUserAuthoritiesResolve: ((handler: OperationHandler<Types.AuthDeviceUserAuthoritiesResolveInput, Types.AuthDeviceUserAuthoritiesResolveProgress, Types.AuthDeviceUserAuthoritiesResolveOutput, {}, TDeps>) => Promise<void>) & { accept(args: { sessionKey: string }): AsyncResult<AcceptedOperation<Types.AuthDeviceUserAuthoritiesResolveProgress, Types.AuthDeviceUserAuthoritiesResolveOutput>, UnexpectedError>; control(operationId: string): AsyncResult<OperationRuntimeHandle<Types.AuthDeviceUserAuthoritiesResolveProgress, Types.AuthDeviceUserAuthoritiesResolveOutput>, BaseError>; };
202
230
  };
203
231
  };
204
232
  }
@@ -2,6 +2,6 @@ export { API, OWNED_API } from "./api.js";
2
2
  export type { Api, ApiViews, OwnedApi } from "./api.js";
3
3
  export * from "./types.js";
4
4
  export * from "./schemas.js";
5
- export type { Client, HandlerClient, TrellisAuthClient, TrellisAuthState } from "./client.js";
5
+ export type { Client, HandlerClient, Service, ServiceEventSurface, ServiceHandle, ServiceWithDeps, TrellisAuthClient, TrellisAuthState } from "./client.js";
6
6
  export type { AuthDeviceUserAuthoritiesResolveOperation, AuthDeviceUserAuthoritiesResolveOperationRef, AuthDeviceUserAuthoritiesResolveTerminal } from "./client.js";
7
7
  export { CONTRACT, CONTRACT_DIGEST, CONTRACT_ID, use, sdk } from "./contract.js";
@@ -1,13 +1,21 @@
1
1
  // Generated from ./generated/contracts/manifests/trellis.core@v1.json
2
- import type { AcceptedOperation, AsyncResult, BaseError, EventOpts, FeedSubscribeOpts, FeedSubscription, HandlerTrellis, MapStateStoreClient, MaybeAsync, OperationInputBuilder, OperationObserverCallbacks, OperationRef, OperationRefData, OperationRuntimeHandle, PreparedTrellisEvent, ReceiveTransferGrant, ReceiveTransferHandle, RequestOpts, Result, RpcHandlerContext, SendTransferGrant, SendTransferHandle, TerminalOperation, TransferCapableOperationInputBuilder, TrellisConnection, UnexpectedError, ValidationError, ValueStateStoreClient } from "../../../index.js";
2
+ import type { AcceptedOperation, AsyncResult, BaseError, EventListenerContext, EventOpts, FeedSubscribeOpts, FeedSubscription, HandlerTrellis, MapStateStoreClient, MaybeAsync, OperationInputBuilder, OperationObserverCallbacks, OperationRef, OperationRefData, OperationRuntimeHandle, OperationTransferHandle, PreparedTrellisEvent, ReceiveTransferGrant, ReceiveTransferHandle, RequestOpts, Result, RpcHandlerContext, SendTransferGrant, SendTransferHandle, TerminalOperation, TransferCapableOperationInputBuilder, TrellisConnection, UnexpectedError, ValidationError, ValueStateStoreClient } from "../../../index.js";
3
3
  import type { API, Api } from "./api.js";
4
4
  import type * as Types from "./types.js";
5
5
 
6
+ type WithDeps<TDeps> = [TDeps] extends [undefined] ? {} : { deps: TDeps };
7
+
6
8
  type EventCallback<TMessage> = {
7
- bivarianceHack(message: TMessage): MaybeAsync<void, BaseError>;
9
+ bivarianceHack(message: TMessage, context: EventListenerContext): MaybeAsync<void, BaseError>;
8
10
  }["bivarianceHack"];
9
11
 
10
- type RpcHandler<TInput, TOutput> = (args: { input: TInput; context: RpcHandlerContext; client: HandlerClient }) => MaybeAsync<TOutput, BaseError>;
12
+ type ServiceEventHandler<TEvent, TDeps = undefined> = (args: { event: TEvent; context: EventListenerContext; client: HandlerClient } & WithDeps<TDeps>) => MaybeAsync<void, BaseError>;
13
+
14
+ type RpcHandler<TInput, TOutput, TDeps = undefined> = (args: { input: TInput; context: RpcHandlerContext; client: HandlerClient } & WithDeps<TDeps>) => MaybeAsync<TOutput, BaseError>;
15
+
16
+ type FeedHandler<TInput, TEvent, TDeps = undefined> = (context: { input: TInput; caller: unknown; signal: AbortSignal; emit(event: TEvent): AsyncResult<void, ValidationError | UnexpectedError>; client: HandlerClient } & WithDeps<TDeps>) => unknown | Promise<unknown>;
17
+
18
+ type OperationHandler<TInput, TProgress, TOutput, TTransfer, TDeps = undefined> = (context: { input: TInput; op: OperationRuntimeHandle<TProgress, TOutput>; caller: unknown; client: HandlerClient } & TTransfer & WithDeps<TDeps>) => unknown | Promise<unknown>;
11
19
 
12
20
  export type TrellisCoreState = {};
13
21
 
@@ -33,16 +41,25 @@ export interface TrellisCoreClient {
33
41
  wait(): AsyncResult<void, BaseError>;
34
42
  }
35
43
 
36
- export interface Service extends Client {
44
+ export interface Service extends TrellisCoreClient {
37
45
  readonly handle: ServiceHandle;
46
+ with<TDeps>(deps: TDeps): ServiceWithDeps<TDeps>;
38
47
  }
39
48
 
40
- export interface ServiceHandle {
49
+ export type ServiceWithDeps<TDeps> = Omit<TrellisCoreClient, "event"> & {
50
+ readonly event: ServiceEventSurface<TDeps>;
51
+ readonly handle: ServiceHandle<TDeps>;
52
+ with<TNextDeps>(deps: TNextDeps): ServiceWithDeps<TNextDeps>;
53
+ };
54
+
55
+ export type ServiceEventSurface<TDeps> = {};
56
+
57
+ export interface ServiceHandle<TDeps = undefined> {
41
58
  readonly rpc: {
42
59
  readonly trellis: {
43
- catalog(handler: RpcHandler<Types.TrellisCatalogInput, Types.TrellisCatalogOutput>): Promise<void>;
44
- contractGet(handler: RpcHandler<Types.TrellisContractGetInput, Types.TrellisContractGetOutput>): Promise<void>;
45
- surfaceStatus(handler: RpcHandler<Types.TrellisSurfaceStatusInput, Types.TrellisSurfaceStatusOutput>): Promise<void>;
60
+ catalog(handler: RpcHandler<Types.TrellisCatalogInput, Types.TrellisCatalogOutput, TDeps>): Promise<void>;
61
+ contractGet(handler: RpcHandler<Types.TrellisContractGetInput, Types.TrellisContractGetOutput, TDeps>): Promise<void>;
62
+ surfaceStatus(handler: RpcHandler<Types.TrellisSurfaceStatusInput, Types.TrellisSurfaceStatusOutput, TDeps>): Promise<void>;
46
63
  };
47
64
  };
48
65
  readonly feed: {};
@@ -2,5 +2,5 @@ export { API, OWNED_API } from "./api.js";
2
2
  export type { Api, ApiViews, OwnedApi } from "./api.js";
3
3
  export * from "./types.js";
4
4
  export * from "./schemas.js";
5
- export type { Client, HandlerClient, TrellisCoreClient, TrellisCoreState } from "./client.js";
5
+ export type { Client, HandlerClient, Service, ServiceEventSurface, ServiceHandle, ServiceWithDeps, TrellisCoreClient, TrellisCoreState } from "./client.js";
6
6
  export { CONTRACT, CONTRACT_DIGEST, CONTRACT_ID, use, sdk } from "./contract.js";
@@ -1,13 +1,21 @@
1
1
  // Generated from ./generated/contracts/manifests/trellis.health@v1.json
2
- import type { AcceptedOperation, AsyncResult, BaseError, EventOpts, FeedSubscribeOpts, FeedSubscription, HandlerTrellis, MapStateStoreClient, MaybeAsync, OperationInputBuilder, OperationObserverCallbacks, OperationRef, OperationRefData, OperationRuntimeHandle, PreparedTrellisEvent, ReceiveTransferGrant, ReceiveTransferHandle, RequestOpts, Result, RpcHandlerContext, SendTransferGrant, SendTransferHandle, TerminalOperation, TransferCapableOperationInputBuilder, TrellisConnection, UnexpectedError, ValidationError, ValueStateStoreClient } from "../../../index.js";
2
+ import type { AcceptedOperation, AsyncResult, BaseError, EventListenerContext, EventOpts, FeedSubscribeOpts, FeedSubscription, HandlerTrellis, MapStateStoreClient, MaybeAsync, OperationInputBuilder, OperationObserverCallbacks, OperationRef, OperationRefData, OperationRuntimeHandle, OperationTransferHandle, PreparedTrellisEvent, ReceiveTransferGrant, ReceiveTransferHandle, RequestOpts, Result, RpcHandlerContext, SendTransferGrant, SendTransferHandle, TerminalOperation, TransferCapableOperationInputBuilder, TrellisConnection, UnexpectedError, ValidationError, ValueStateStoreClient } from "../../../index.js";
3
3
  import type { API, Api } from "./api.js";
4
4
  import type * as Types from "./types.js";
5
5
 
6
+ type WithDeps<TDeps> = [TDeps] extends [undefined] ? {} : { deps: TDeps };
7
+
6
8
  type EventCallback<TMessage> = {
7
- bivarianceHack(message: TMessage): MaybeAsync<void, BaseError>;
9
+ bivarianceHack(message: TMessage, context: EventListenerContext): MaybeAsync<void, BaseError>;
8
10
  }["bivarianceHack"];
9
11
 
10
- type RpcHandler<TInput, TOutput> = (args: { input: TInput; context: RpcHandlerContext; client: HandlerClient }) => MaybeAsync<TOutput, BaseError>;
12
+ type ServiceEventHandler<TEvent, TDeps = undefined> = (args: { event: TEvent; context: EventListenerContext; client: HandlerClient } & WithDeps<TDeps>) => MaybeAsync<void, BaseError>;
13
+
14
+ type RpcHandler<TInput, TOutput, TDeps = undefined> = (args: { input: TInput; context: RpcHandlerContext; client: HandlerClient } & WithDeps<TDeps>) => MaybeAsync<TOutput, BaseError>;
15
+
16
+ type FeedHandler<TInput, TEvent, TDeps = undefined> = (context: { input: TInput; caller: unknown; signal: AbortSignal; emit(event: TEvent): AsyncResult<void, ValidationError | UnexpectedError>; client: HandlerClient } & WithDeps<TDeps>) => unknown | Promise<unknown>;
17
+
18
+ type OperationHandler<TInput, TProgress, TOutput, TTransfer, TDeps = undefined> = (context: { input: TInput; op: OperationRuntimeHandle<TProgress, TOutput>; caller: unknown; client: HandlerClient } & TTransfer & WithDeps<TDeps>) => unknown | Promise<unknown>;
11
19
 
12
20
  export type TrellisHealthState = {};
13
21
 
@@ -31,11 +39,24 @@ export interface TrellisHealthClient {
31
39
  wait(): AsyncResult<void, BaseError>;
32
40
  }
33
41
 
34
- export interface Service extends Client {
42
+ export interface Service extends TrellisHealthClient {
35
43
  readonly handle: ServiceHandle;
44
+ with<TDeps>(deps: TDeps): ServiceWithDeps<TDeps>;
45
+ }
46
+
47
+ export type ServiceWithDeps<TDeps> = Omit<TrellisHealthClient, "event"> & {
48
+ readonly event: ServiceEventSurface<TDeps>;
49
+ readonly handle: ServiceHandle<TDeps>;
50
+ with<TNextDeps>(deps: TNextDeps): ServiceWithDeps<TNextDeps>;
51
+ };
52
+
53
+ export interface ServiceEventSurface<TDeps> {
54
+ readonly health: {
55
+ heartbeat: { publish(event: Omit<Types.HealthHeartbeatEvent, "header">): AsyncResult<void, ValidationError | UnexpectedError>; prepare(event: Omit<Types.HealthHeartbeatEvent, "header">): Result<PreparedTrellisEvent<Omit<Types.HealthHeartbeatEvent, "header">>, ValidationError | UnexpectedError>; listen(handler: ServiceEventHandler<Types.HealthHeartbeatEvent, TDeps>, subjectData?: Record<string, unknown>, opts?: EventOpts): AsyncResult<void, ValidationError | UnexpectedError>; };
56
+ };
36
57
  }
37
58
 
38
- export interface ServiceHandle {
59
+ export interface ServiceHandle<TDeps = undefined> {
39
60
  readonly rpc: {};
40
61
  readonly feed: {};
41
62
  readonly operation: {};
@@ -2,5 +2,5 @@ export { API, OWNED_API } from "./api.js";
2
2
  export type { Api, ApiViews, OwnedApi } from "./api.js";
3
3
  export * from "./types.js";
4
4
  export * from "./schemas.js";
5
- export type { Client, HandlerClient, TrellisHealthClient, TrellisHealthState } from "./client.js";
5
+ export type { Client, HandlerClient, Service, ServiceEventSurface, ServiceHandle, ServiceWithDeps, TrellisHealthClient, TrellisHealthState } from "./client.js";
6
6
  export { CONTRACT, CONTRACT_DIGEST, CONTRACT_ID, use, sdk } from "./contract.js";
@@ -1,16 +1,24 @@
1
1
  // Generated from ./generated/contracts/manifests/trellis.jobs@v1.json
2
- import type { AcceptedOperation, AsyncResult, BaseError, EventOpts, FeedSubscribeOpts, FeedSubscription, HandlerTrellis, MapStateStoreClient, MaybeAsync, OperationInputBuilder, OperationObserverCallbacks, OperationRef, OperationRefData, OperationRuntimeHandle, PreparedTrellisEvent, ReceiveTransferGrant, ReceiveTransferHandle, RequestOpts, Result, RpcHandlerContext, SendTransferGrant, SendTransferHandle, TerminalOperation, TransferCapableOperationInputBuilder, TrellisConnection, UnexpectedError, ValidationError, ValueStateStoreClient } from "../../../index.js";
2
+ import type { AcceptedOperation, AsyncResult, BaseError, EventListenerContext, EventOpts, FeedSubscribeOpts, FeedSubscription, HandlerTrellis, MapStateStoreClient, MaybeAsync, OperationInputBuilder, OperationObserverCallbacks, OperationRef, OperationRefData, OperationRuntimeHandle, OperationTransferHandle, PreparedTrellisEvent, ReceiveTransferGrant, ReceiveTransferHandle, RequestOpts, Result, RpcHandlerContext, SendTransferGrant, SendTransferHandle, TerminalOperation, TransferCapableOperationInputBuilder, TrellisConnection, UnexpectedError, ValidationError, ValueStateStoreClient } from "../../../index.js";
3
3
  import type { API, Api } from "./api.js";
4
4
  import type * as Types from "./types.js";
5
5
  import type * as AuthSdk from "../auth/mod.js";
6
6
  import type * as CoreSdk from "../core/mod.js";
7
7
  import type * as HealthSdk from "../health/mod.js";
8
8
 
9
+ type WithDeps<TDeps> = [TDeps] extends [undefined] ? {} : { deps: TDeps };
10
+
9
11
  type EventCallback<TMessage> = {
10
- bivarianceHack(message: TMessage): MaybeAsync<void, BaseError>;
12
+ bivarianceHack(message: TMessage, context: EventListenerContext): MaybeAsync<void, BaseError>;
11
13
  }["bivarianceHack"];
12
14
 
13
- type RpcHandler<TInput, TOutput> = (args: { input: TInput; context: RpcHandlerContext; client: HandlerClient }) => MaybeAsync<TOutput, BaseError>;
15
+ type ServiceEventHandler<TEvent, TDeps = undefined> = (args: { event: TEvent; context: EventListenerContext; client: HandlerClient } & WithDeps<TDeps>) => MaybeAsync<void, BaseError>;
16
+
17
+ type RpcHandler<TInput, TOutput, TDeps = undefined> = (args: { input: TInput; context: RpcHandlerContext; client: HandlerClient } & WithDeps<TDeps>) => MaybeAsync<TOutput, BaseError>;
18
+
19
+ type FeedHandler<TInput, TEvent, TDeps = undefined> = (context: { input: TInput; caller: unknown; signal: AbortSignal; emit(event: TEvent): AsyncResult<void, ValidationError | UnexpectedError>; client: HandlerClient } & WithDeps<TDeps>) => unknown | Promise<unknown>;
20
+
21
+ type OperationHandler<TInput, TProgress, TOutput, TTransfer, TDeps = undefined> = (context: { input: TInput; op: OperationRuntimeHandle<TProgress, TOutput>; caller: unknown; client: HandlerClient } & TTransfer & WithDeps<TDeps>) => unknown | Promise<unknown>;
14
22
 
15
23
  export type TrellisJobsState = {};
16
24
 
@@ -52,22 +60,35 @@ export interface TrellisJobsClient {
52
60
  wait(): AsyncResult<void, BaseError>;
53
61
  }
54
62
 
55
- export interface Service extends Client {
63
+ export interface Service extends TrellisJobsClient {
56
64
  readonly handle: ServiceHandle;
65
+ with<TDeps>(deps: TDeps): ServiceWithDeps<TDeps>;
66
+ }
67
+
68
+ export type ServiceWithDeps<TDeps> = Omit<TrellisJobsClient, "event"> & {
69
+ readonly event: ServiceEventSurface<TDeps>;
70
+ readonly handle: ServiceHandle<TDeps>;
71
+ with<TNextDeps>(deps: TNextDeps): ServiceWithDeps<TNextDeps>;
72
+ };
73
+
74
+ export interface ServiceEventSurface<TDeps> {
75
+ readonly health: {
76
+ heartbeat: { publish(event: Omit<HealthSdk.HealthHeartbeatEvent, "header">): AsyncResult<void, ValidationError | UnexpectedError>; prepare(event: Omit<HealthSdk.HealthHeartbeatEvent, "header">): Result<PreparedTrellisEvent<Omit<HealthSdk.HealthHeartbeatEvent, "header">>, ValidationError | UnexpectedError>; listen(handler: ServiceEventHandler<HealthSdk.HealthHeartbeatEvent, TDeps>, subjectData?: Record<string, unknown>, opts?: EventOpts): AsyncResult<void, ValidationError | UnexpectedError>; };
77
+ };
57
78
  }
58
79
 
59
- export interface ServiceHandle {
80
+ export interface ServiceHandle<TDeps = undefined> {
60
81
  readonly rpc: {
61
82
  readonly jobs: {
62
- cancel(handler: RpcHandler<Types.JobsCancelInput, Types.JobsCancelOutput>): Promise<void>;
63
- dismissDLQ(handler: RpcHandler<Types.JobsDismissDLQInput, Types.JobsDismissDLQOutput>): Promise<void>;
64
- get(handler: RpcHandler<Types.JobsGetInput, Types.JobsGetOutput>): Promise<void>;
65
- health(handler: RpcHandler<Types.JobsHealthInput, Types.JobsHealthOutput>): Promise<void>;
66
- list(handler: RpcHandler<Types.JobsListInput, Types.JobsListOutput>): Promise<void>;
67
- listDLQ(handler: RpcHandler<Types.JobsListDLQInput, Types.JobsListDLQOutput>): Promise<void>;
68
- listServices(handler: RpcHandler<Types.JobsListServicesInput, Types.JobsListServicesOutput>): Promise<void>;
69
- replayDLQ(handler: RpcHandler<Types.JobsReplayDLQInput, Types.JobsReplayDLQOutput>): Promise<void>;
70
- retry(handler: RpcHandler<Types.JobsRetryInput, Types.JobsRetryOutput>): Promise<void>;
83
+ cancel(handler: RpcHandler<Types.JobsCancelInput, Types.JobsCancelOutput, TDeps>): Promise<void>;
84
+ dismissDLQ(handler: RpcHandler<Types.JobsDismissDLQInput, Types.JobsDismissDLQOutput, TDeps>): Promise<void>;
85
+ get(handler: RpcHandler<Types.JobsGetInput, Types.JobsGetOutput, TDeps>): Promise<void>;
86
+ health(handler: RpcHandler<Types.JobsHealthInput, Types.JobsHealthOutput, TDeps>): Promise<void>;
87
+ list(handler: RpcHandler<Types.JobsListInput, Types.JobsListOutput, TDeps>): Promise<void>;
88
+ listDLQ(handler: RpcHandler<Types.JobsListDLQInput, Types.JobsListDLQOutput, TDeps>): Promise<void>;
89
+ listServices(handler: RpcHandler<Types.JobsListServicesInput, Types.JobsListServicesOutput, TDeps>): Promise<void>;
90
+ replayDLQ(handler: RpcHandler<Types.JobsReplayDLQInput, Types.JobsReplayDLQOutput, TDeps>): Promise<void>;
91
+ retry(handler: RpcHandler<Types.JobsRetryInput, Types.JobsRetryOutput, TDeps>): Promise<void>;
71
92
  };
72
93
  };
73
94
  readonly feed: {};
@@ -2,5 +2,5 @@ export { API, OWNED_API } from "./api.js";
2
2
  export type { Api, ApiViews, OwnedApi } from "./api.js";
3
3
  export * from "./types.js";
4
4
  export * from "./schemas.js";
5
- export type { Client, HandlerClient, TrellisJobsClient, TrellisJobsState } from "./client.js";
5
+ export type { Client, HandlerClient, Service, ServiceEventSurface, ServiceHandle, ServiceWithDeps, TrellisJobsClient, TrellisJobsState } from "./client.js";
6
6
  export { CONTRACT, CONTRACT_DIGEST, CONTRACT_ID, use, sdk } from "./contract.js";
@@ -1,14 +1,22 @@
1
1
  // Generated from ./generated/contracts/manifests/trellis.state@v1.json
2
- import type { AcceptedOperation, AsyncResult, BaseError, EventOpts, FeedSubscribeOpts, FeedSubscription, HandlerTrellis, MapStateStoreClient, MaybeAsync, OperationInputBuilder, OperationObserverCallbacks, OperationRef, OperationRefData, OperationRuntimeHandle, PreparedTrellisEvent, ReceiveTransferGrant, ReceiveTransferHandle, RequestOpts, Result, RpcHandlerContext, SendTransferGrant, SendTransferHandle, TerminalOperation, TransferCapableOperationInputBuilder, TrellisConnection, UnexpectedError, ValidationError, ValueStateStoreClient } from "../../../index.js";
2
+ import type { AcceptedOperation, AsyncResult, BaseError, EventListenerContext, EventOpts, FeedSubscribeOpts, FeedSubscription, HandlerTrellis, MapStateStoreClient, MaybeAsync, OperationInputBuilder, OperationObserverCallbacks, OperationRef, OperationRefData, OperationRuntimeHandle, OperationTransferHandle, PreparedTrellisEvent, ReceiveTransferGrant, ReceiveTransferHandle, RequestOpts, Result, RpcHandlerContext, SendTransferGrant, SendTransferHandle, TerminalOperation, TransferCapableOperationInputBuilder, TrellisConnection, UnexpectedError, ValidationError, ValueStateStoreClient } from "../../../index.js";
3
3
  import type { API, Api } from "./api.js";
4
4
  import type * as Types from "./types.js";
5
5
  import type * as HealthSdk from "../health/mod.js";
6
6
 
7
+ type WithDeps<TDeps> = [TDeps] extends [undefined] ? {} : { deps: TDeps };
8
+
7
9
  type EventCallback<TMessage> = {
8
- bivarianceHack(message: TMessage): MaybeAsync<void, BaseError>;
10
+ bivarianceHack(message: TMessage, context: EventListenerContext): MaybeAsync<void, BaseError>;
9
11
  }["bivarianceHack"];
10
12
 
11
- type RpcHandler<TInput, TOutput> = (args: { input: TInput; context: RpcHandlerContext; client: HandlerClient }) => MaybeAsync<TOutput, BaseError>;
13
+ type ServiceEventHandler<TEvent, TDeps = undefined> = (args: { event: TEvent; context: EventListenerContext; client: HandlerClient } & WithDeps<TDeps>) => MaybeAsync<void, BaseError>;
14
+
15
+ type RpcHandler<TInput, TOutput, TDeps = undefined> = (args: { input: TInput; context: RpcHandlerContext; client: HandlerClient } & WithDeps<TDeps>) => MaybeAsync<TOutput, BaseError>;
16
+
17
+ type FeedHandler<TInput, TEvent, TDeps = undefined> = (context: { input: TInput; caller: unknown; signal: AbortSignal; emit(event: TEvent): AsyncResult<void, ValidationError | UnexpectedError>; client: HandlerClient } & WithDeps<TDeps>) => unknown | Promise<unknown>;
18
+
19
+ type OperationHandler<TInput, TProgress, TOutput, TTransfer, TDeps = undefined> = (context: { input: TInput; op: OperationRuntimeHandle<TProgress, TOutput>; caller: unknown; client: HandlerClient } & TTransfer & WithDeps<TDeps>) => unknown | Promise<unknown>;
12
20
 
13
21
  export type TrellisStateState = {};
14
22
 
@@ -42,20 +50,33 @@ export interface TrellisStateClient {
42
50
  wait(): AsyncResult<void, BaseError>;
43
51
  }
44
52
 
45
- export interface Service extends Client {
53
+ export interface Service extends TrellisStateClient {
46
54
  readonly handle: ServiceHandle;
55
+ with<TDeps>(deps: TDeps): ServiceWithDeps<TDeps>;
56
+ }
57
+
58
+ export type ServiceWithDeps<TDeps> = Omit<TrellisStateClient, "event"> & {
59
+ readonly event: ServiceEventSurface<TDeps>;
60
+ readonly handle: ServiceHandle<TDeps>;
61
+ with<TNextDeps>(deps: TNextDeps): ServiceWithDeps<TNextDeps>;
62
+ };
63
+
64
+ export interface ServiceEventSurface<TDeps> {
65
+ readonly health: {
66
+ heartbeat: { publish(event: Omit<HealthSdk.HealthHeartbeatEvent, "header">): AsyncResult<void, ValidationError | UnexpectedError>; prepare(event: Omit<HealthSdk.HealthHeartbeatEvent, "header">): Result<PreparedTrellisEvent<Omit<HealthSdk.HealthHeartbeatEvent, "header">>, ValidationError | UnexpectedError>; listen(handler: ServiceEventHandler<HealthSdk.HealthHeartbeatEvent, TDeps>, subjectData?: Record<string, unknown>, opts?: EventOpts): AsyncResult<void, ValidationError | UnexpectedError>; };
67
+ };
47
68
  }
48
69
 
49
- export interface ServiceHandle {
70
+ export interface ServiceHandle<TDeps = undefined> {
50
71
  readonly rpc: {
51
72
  readonly state: {
52
- adminDelete(handler: RpcHandler<Types.StateAdminDeleteInput, Types.StateAdminDeleteOutput>): Promise<void>;
53
- adminGet(handler: RpcHandler<Types.StateAdminGetInput, Types.StateAdminGetOutput>): Promise<void>;
54
- adminList(handler: RpcHandler<Types.StateAdminListInput, Types.StateAdminListOutput>): Promise<void>;
55
- delete(handler: RpcHandler<Types.StateDeleteInput, Types.StateDeleteOutput>): Promise<void>;
56
- get(handler: RpcHandler<Types.StateGetInput, Types.StateGetOutput>): Promise<void>;
57
- list(handler: RpcHandler<Types.StateListInput, Types.StateListOutput>): Promise<void>;
58
- put(handler: RpcHandler<Types.StatePutInput, Types.StatePutOutput>): Promise<void>;
73
+ adminDelete(handler: RpcHandler<Types.StateAdminDeleteInput, Types.StateAdminDeleteOutput, TDeps>): Promise<void>;
74
+ adminGet(handler: RpcHandler<Types.StateAdminGetInput, Types.StateAdminGetOutput, TDeps>): Promise<void>;
75
+ adminList(handler: RpcHandler<Types.StateAdminListInput, Types.StateAdminListOutput, TDeps>): Promise<void>;
76
+ delete(handler: RpcHandler<Types.StateDeleteInput, Types.StateDeleteOutput, TDeps>): Promise<void>;
77
+ get(handler: RpcHandler<Types.StateGetInput, Types.StateGetOutput, TDeps>): Promise<void>;
78
+ list(handler: RpcHandler<Types.StateListInput, Types.StateListOutput, TDeps>): Promise<void>;
79
+ put(handler: RpcHandler<Types.StatePutInput, Types.StatePutOutput, TDeps>): Promise<void>;
59
80
  };
60
81
  };
61
82
  readonly feed: {};
@@ -2,5 +2,5 @@ export { API, OWNED_API } from "./api.js";
2
2
  export type { Api, ApiViews, OwnedApi } from "./api.js";
3
3
  export * from "./types.js";
4
4
  export * from "./schemas.js";
5
- export type { Client, HandlerClient, TrellisStateClient, TrellisStateState } from "./client.js";
5
+ export type { Client, HandlerClient, Service, ServiceEventSurface, ServiceHandle, ServiceWithDeps, TrellisStateClient, TrellisStateState } from "./client.js";
6
6
  export { CONTRACT, CONTRACT_DIGEST, CONTRACT_ID, use, sdk } from "./contract.js";