@temporal-contract/contract 0.0.4 → 0.0.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.cts +2 -179
- package/dist/index.d.mts +2 -179
- package/package.json +10 -10
package/dist/index.d.cts
CHANGED
|
@@ -55,157 +55,7 @@ interface ContractDefinition<TWorkflows extends Record<string, WorkflowDefinitio
|
|
|
55
55
|
readonly activities?: TActivities;
|
|
56
56
|
}
|
|
57
57
|
/**
|
|
58
|
-
*
|
|
59
|
-
* Worker receives the output type (after input schema parsing/transformation)
|
|
60
|
-
*/
|
|
61
|
-
type WorkerInferInput<T extends {
|
|
62
|
-
input: AnySchema;
|
|
63
|
-
}> = StandardSchemaV1.InferOutput<T["input"]>;
|
|
64
|
-
/**
|
|
65
|
-
* Infer output type from a definition (worker perspective)
|
|
66
|
-
* Worker returns the input type (before output schema parsing/transformation)
|
|
67
|
-
*/
|
|
68
|
-
type WorkerInferOutput<T extends {
|
|
69
|
-
output: AnySchema;
|
|
70
|
-
}> = StandardSchemaV1.InferInput<T["output"]>;
|
|
71
|
-
/**
|
|
72
|
-
* Infer input type from a definition (client perspective)
|
|
73
|
-
* Client sends the input type (before input schema parsing/transformation)
|
|
74
|
-
*/
|
|
75
|
-
type ClientInferInput<T extends {
|
|
76
|
-
input: AnySchema;
|
|
77
|
-
}> = StandardSchemaV1.InferInput<T["input"]>;
|
|
78
|
-
/**
|
|
79
|
-
* Infer output type from a definition (client perspective)
|
|
80
|
-
* Client receives the output type (after output schema parsing/transformation)
|
|
81
|
-
*/
|
|
82
|
-
type ClientInferOutput<T extends {
|
|
83
|
-
output: AnySchema;
|
|
84
|
-
}> = StandardSchemaV1.InferOutput<T["output"]>;
|
|
85
|
-
/**
|
|
86
|
-
* WORKER PERSPECTIVE
|
|
87
|
-
* Worker receives z.output of input (parsed data) and returns z.input of output (raw data)
|
|
88
|
-
*/
|
|
89
|
-
/**
|
|
90
|
-
* Infer workflow function signature from worker perspective
|
|
91
|
-
* Worker receives z.input and returns z.output
|
|
92
|
-
*/
|
|
93
|
-
type WorkerInferWorkflow<TWorkflow extends WorkflowDefinition> = (args: WorkerInferInput<TWorkflow>) => Promise<WorkerInferOutput<TWorkflow>>;
|
|
94
|
-
/**
|
|
95
|
-
* Infer activity function signature from worker perspective
|
|
96
|
-
* Worker receives z.input and returns z.output
|
|
97
|
-
*/
|
|
98
|
-
type WorkerInferActivity<TActivity extends ActivityDefinition> = (args: WorkerInferInput<TActivity>) => Promise<WorkerInferOutput<TActivity>>;
|
|
99
|
-
/**
|
|
100
|
-
* Infer signal handler signature from worker perspective
|
|
101
|
-
* Worker receives z.input
|
|
102
|
-
*/
|
|
103
|
-
type WorkerInferSignal<TSignal extends SignalDefinition> = (args: WorkerInferInput<TSignal>) => Promise<void>;
|
|
104
|
-
/**
|
|
105
|
-
* Infer query handler signature from worker perspective
|
|
106
|
-
* Worker receives z.input and returns z.output
|
|
107
|
-
*/
|
|
108
|
-
type WorkerInferQuery<TQuery extends QueryDefinition> = (args: WorkerInferInput<TQuery>) => Promise<WorkerInferOutput<TQuery>>;
|
|
109
|
-
/**
|
|
110
|
-
* Infer update handler signature from worker perspective
|
|
111
|
-
* Worker receives z.input and returns z.output
|
|
112
|
-
*/
|
|
113
|
-
type WorkerInferUpdate<TUpdate extends UpdateDefinition> = (args: WorkerInferInput<TUpdate>) => Promise<WorkerInferOutput<TUpdate>>;
|
|
114
|
-
/**
|
|
115
|
-
* CLIENT PERSPECTIVE
|
|
116
|
-
* Client sends z.output and receives z.input
|
|
117
|
-
*/
|
|
118
|
-
/**
|
|
119
|
-
* Infer workflow function signature from client perspective
|
|
120
|
-
* Client sends z.output and receives z.input
|
|
121
|
-
*/
|
|
122
|
-
type ClientInferWorkflow<TWorkflow extends WorkflowDefinition> = (args: ClientInferInput<TWorkflow>) => Promise<ClientInferOutput<TWorkflow>>;
|
|
123
|
-
/**
|
|
124
|
-
* Infer activity function signature from client perspective
|
|
125
|
-
* Client sends z.output and receives z.input
|
|
126
|
-
*/
|
|
127
|
-
type ClientInferActivity<TActivity extends ActivityDefinition> = (args: ClientInferInput<TActivity>) => Promise<ClientInferOutput<TActivity>>;
|
|
128
|
-
/**
|
|
129
|
-
* Infer signal handler signature from client perspective
|
|
130
|
-
* Client sends z.output
|
|
131
|
-
*/
|
|
132
|
-
type ClientInferSignal<TSignal extends SignalDefinition> = (args: ClientInferInput<TSignal>) => Promise<void>;
|
|
133
|
-
/**
|
|
134
|
-
* Infer query handler signature from client perspective
|
|
135
|
-
* Client sends z.output and receives z.input
|
|
136
|
-
*/
|
|
137
|
-
type ClientInferQuery<TQuery extends QueryDefinition> = (args: ClientInferInput<TQuery>) => Promise<ClientInferOutput<TQuery>>;
|
|
138
|
-
/**
|
|
139
|
-
* Infer update handler signature from client perspective
|
|
140
|
-
* Client sends z.output and receives z.input
|
|
141
|
-
*/
|
|
142
|
-
type ClientInferUpdate<TUpdate extends UpdateDefinition> = (args: ClientInferInput<TUpdate>) => Promise<ClientInferOutput<TUpdate>>;
|
|
143
|
-
/**
|
|
144
|
-
* WORKER PERSPECTIVE - Contract-level types
|
|
145
|
-
*/
|
|
146
|
-
/**
|
|
147
|
-
* Infer all workflows from a contract (worker perspective)
|
|
148
|
-
*/
|
|
149
|
-
type WorkerInferWorkflows<TContract extends ContractDefinition> = { [K in keyof TContract["workflows"]]: WorkerInferWorkflow<TContract["workflows"][K]> };
|
|
150
|
-
/**
|
|
151
|
-
* Infer all activities from a contract (worker perspective)
|
|
152
|
-
*/
|
|
153
|
-
type WorkerInferActivities<TContract extends ContractDefinition> = TContract["activities"] extends Record<string, ActivityDefinition> ? { [K in keyof TContract["activities"]]: WorkerInferActivity<TContract["activities"][K]> } : {};
|
|
154
|
-
/**
|
|
155
|
-
* Infer activities from a workflow definition (worker perspective)
|
|
156
|
-
*/
|
|
157
|
-
type WorkerInferWorkflowActivities<T extends WorkflowDefinition> = T["activities"] extends Record<string, ActivityDefinition> ? { [K in keyof T["activities"]]: WorkerInferActivity<T["activities"][K]> } : {};
|
|
158
|
-
/**
|
|
159
|
-
* Infer signals from a workflow definition (worker perspective)
|
|
160
|
-
*/
|
|
161
|
-
type WorkerInferWorkflowSignals<T extends WorkflowDefinition> = T["signals"] extends Record<string, SignalDefinition> ? { [K in keyof T["signals"]]: WorkerInferSignal<T["signals"][K]> } : {};
|
|
162
|
-
/**
|
|
163
|
-
* Infer queries from a workflow definition (worker perspective)
|
|
164
|
-
*/
|
|
165
|
-
type WorkerInferWorkflowQueries<T extends WorkflowDefinition> = T["queries"] extends Record<string, QueryDefinition> ? { [K in keyof T["queries"]]: WorkerInferQuery<T["queries"][K]> } : {};
|
|
166
|
-
/**
|
|
167
|
-
* Infer updates from a workflow definition (worker perspective)
|
|
168
|
-
*/
|
|
169
|
-
type WorkerInferWorkflowUpdates<T extends WorkflowDefinition> = T["updates"] extends Record<string, UpdateDefinition> ? { [K in keyof T["updates"]]: WorkerInferUpdate<T["updates"][K]> } : {};
|
|
170
|
-
/**
|
|
171
|
-
* Infer all activities available in a workflow context (worker perspective)
|
|
172
|
-
* Combines workflow-specific activities with global activities
|
|
173
|
-
*/
|
|
174
|
-
type WorkerInferWorkflowContextActivities<TContract extends ContractDefinition, TWorkflowName extends keyof TContract["workflows"]> = WorkerInferWorkflowActivities<TContract["workflows"][TWorkflowName]> & WorkerInferActivities<TContract>;
|
|
175
|
-
/**
|
|
176
|
-
* CLIENT PERSPECTIVE - Contract-level types
|
|
177
|
-
*/
|
|
178
|
-
/**
|
|
179
|
-
* Infer all workflows from a contract (client perspective)
|
|
180
|
-
*/
|
|
181
|
-
type ClientInferWorkflows<TContract extends ContractDefinition> = { [K in keyof TContract["workflows"]]: ClientInferWorkflow<TContract["workflows"][K]> };
|
|
182
|
-
/**
|
|
183
|
-
* Infer all activities from a contract (client perspective)
|
|
184
|
-
*/
|
|
185
|
-
type ClientInferActivities<TContract extends ContractDefinition> = TContract["activities"] extends Record<string, ActivityDefinition> ? { [K in keyof TContract["activities"]]: ClientInferActivity<TContract["activities"][K]> } : {};
|
|
186
|
-
/**
|
|
187
|
-
* Infer activities from a workflow definition (client perspective)
|
|
188
|
-
*/
|
|
189
|
-
type ClientInferWorkflowActivities<T extends WorkflowDefinition> = T["activities"] extends Record<string, ActivityDefinition> ? { [K in keyof T["activities"]]: ClientInferActivity<T["activities"][K]> } : {};
|
|
190
|
-
/**
|
|
191
|
-
* Infer signals from a workflow definition (client perspective)
|
|
192
|
-
*/
|
|
193
|
-
type ClientInferWorkflowSignals<T extends WorkflowDefinition> = T["signals"] extends Record<string, SignalDefinition> ? { [K in keyof T["signals"]]: ClientInferSignal<T["signals"][K]> } : {};
|
|
194
|
-
/**
|
|
195
|
-
* Infer queries from a workflow definition (client perspective)
|
|
196
|
-
*/
|
|
197
|
-
type ClientInferWorkflowQueries<T extends WorkflowDefinition> = T["queries"] extends Record<string, QueryDefinition> ? { [K in keyof T["queries"]]: ClientInferQuery<T["queries"][K]> } : {};
|
|
198
|
-
/**
|
|
199
|
-
* Infer updates from a workflow definition (client perspective)
|
|
200
|
-
*/
|
|
201
|
-
type ClientInferWorkflowUpdates<T extends WorkflowDefinition> = T["updates"] extends Record<string, UpdateDefinition> ? { [K in keyof T["updates"]]: ClientInferUpdate<T["updates"][K]> } : {};
|
|
202
|
-
/**
|
|
203
|
-
* Infer all activities available in a workflow context (client perspective)
|
|
204
|
-
* Combines workflow-specific activities with global activities
|
|
205
|
-
*/
|
|
206
|
-
type ClientInferWorkflowContextActivities<TContract extends ContractDefinition, TWorkflowName extends keyof TContract["workflows"]> = ClientInferWorkflowActivities<TContract["workflows"][TWorkflowName]> & ClientInferActivities<TContract>;
|
|
207
|
-
/**
|
|
208
|
-
* UTILITY TYPES FOR ACTIVITY HANDLERS
|
|
58
|
+
* UTILITY TYPES
|
|
209
59
|
*/
|
|
210
60
|
/**
|
|
211
61
|
* Extract workflow names from a contract as a union type
|
|
@@ -236,33 +86,6 @@ type InferActivityNames<TContract extends ContractDefinition> = TContract["activ
|
|
|
236
86
|
* ```
|
|
237
87
|
*/
|
|
238
88
|
type InferContractWorkflows<TContract extends ContractDefinition> = TContract["workflows"];
|
|
239
|
-
/**
|
|
240
|
-
* Infer the handler type for a global activity from a contract
|
|
241
|
-
*
|
|
242
|
-
* @example
|
|
243
|
-
* ```typescript
|
|
244
|
-
* const log: ActivityHandler<typeof myContract, "log"> = async ({ level, message }) => {
|
|
245
|
-
* logger[level](message);
|
|
246
|
-
* };
|
|
247
|
-
* ```
|
|
248
|
-
*/
|
|
249
|
-
type ActivityHandler<TContract extends ContractDefinition, TActivityName extends keyof TContract["activities"]> = TContract["activities"] extends Record<string, ActivityDefinition> ? (args: WorkerInferInput<TContract["activities"][TActivityName]>) => Promise<WorkerInferOutput<TContract["activities"][TActivityName]>> : never;
|
|
250
|
-
/**
|
|
251
|
-
* Infer the handler type for a workflow-specific activity from a contract
|
|
252
|
-
*
|
|
253
|
-
* @example
|
|
254
|
-
* ```typescript
|
|
255
|
-
* const processPayment: WorkflowActivityHandler<
|
|
256
|
-
* typeof myContract,
|
|
257
|
-
* "processOrder",
|
|
258
|
-
* "processPayment"
|
|
259
|
-
* > = async ({ customerId, amount }) => {
|
|
260
|
-
* // Implementation
|
|
261
|
-
* return { transactionId, status: "success" as const, paidAmount: amount };
|
|
262
|
-
* };
|
|
263
|
-
* ```
|
|
264
|
-
*/
|
|
265
|
-
type WorkflowActivityHandler<TContract extends ContractDefinition, TWorkflowName extends keyof TContract["workflows"], TActivityName extends keyof TContract["workflows"][TWorkflowName]["activities"]> = TContract["workflows"][TWorkflowName]["activities"] extends Record<string, ActivityDefinition> ? (args: WorkerInferInput<TContract["workflows"][TWorkflowName]["activities"][TActivityName]>) => Promise<WorkerInferOutput<TContract["workflows"][TWorkflowName]["activities"][TActivityName]>> : never;
|
|
266
89
|
//#endregion
|
|
267
90
|
//#region src/builder.d.ts
|
|
268
91
|
/**
|
|
@@ -573,4 +396,4 @@ declare function defineNexusOperation<TOperation extends NexusOperationDefinitio
|
|
|
573
396
|
*/
|
|
574
397
|
declare function defineNexusService<TService extends NexusServiceDefinition>(definition: TService): TService;
|
|
575
398
|
//#endregion
|
|
576
|
-
export { type ActivityDefinition, type
|
|
399
|
+
export { type ActivityDefinition, type AnySchema, type ClientInferNexusOperationInput, type ClientInferNexusOperationInvoker, type ClientInferNexusOperationOutput, type ClientInferNexusServiceOperations, type ClientInferNexusServices, type ContractDefinition, type ContractDefinitionWithNexus, type InferActivityNames, type InferContractWorkflows, type InferNexusOperationNames, type InferNexusServiceNames, type InferWorkflowNames, type NexusOperationDefinition, type NexusOperationHandler, type NexusServiceDefinition, type QueryDefinition, type SignalDefinition, type UpdateDefinition, type WorkerInferNexusOperationHandler, type WorkerInferNexusOperationInput, type WorkerInferNexusOperationOutput, type WorkerInferNexusServiceHandlers, type WorkerInferNexusServices, type WorkflowDefinition, defineActivity, defineContract, defineNexusOperation, defineNexusService, defineQuery, defineSignal, defineUpdate, defineWorkflow };
|
package/dist/index.d.mts
CHANGED
|
@@ -55,157 +55,7 @@ interface ContractDefinition<TWorkflows extends Record<string, WorkflowDefinitio
|
|
|
55
55
|
readonly activities?: TActivities;
|
|
56
56
|
}
|
|
57
57
|
/**
|
|
58
|
-
*
|
|
59
|
-
* Worker receives the output type (after input schema parsing/transformation)
|
|
60
|
-
*/
|
|
61
|
-
type WorkerInferInput<T extends {
|
|
62
|
-
input: AnySchema;
|
|
63
|
-
}> = StandardSchemaV1.InferOutput<T["input"]>;
|
|
64
|
-
/**
|
|
65
|
-
* Infer output type from a definition (worker perspective)
|
|
66
|
-
* Worker returns the input type (before output schema parsing/transformation)
|
|
67
|
-
*/
|
|
68
|
-
type WorkerInferOutput<T extends {
|
|
69
|
-
output: AnySchema;
|
|
70
|
-
}> = StandardSchemaV1.InferInput<T["output"]>;
|
|
71
|
-
/**
|
|
72
|
-
* Infer input type from a definition (client perspective)
|
|
73
|
-
* Client sends the input type (before input schema parsing/transformation)
|
|
74
|
-
*/
|
|
75
|
-
type ClientInferInput<T extends {
|
|
76
|
-
input: AnySchema;
|
|
77
|
-
}> = StandardSchemaV1.InferInput<T["input"]>;
|
|
78
|
-
/**
|
|
79
|
-
* Infer output type from a definition (client perspective)
|
|
80
|
-
* Client receives the output type (after output schema parsing/transformation)
|
|
81
|
-
*/
|
|
82
|
-
type ClientInferOutput<T extends {
|
|
83
|
-
output: AnySchema;
|
|
84
|
-
}> = StandardSchemaV1.InferOutput<T["output"]>;
|
|
85
|
-
/**
|
|
86
|
-
* WORKER PERSPECTIVE
|
|
87
|
-
* Worker receives z.output of input (parsed data) and returns z.input of output (raw data)
|
|
88
|
-
*/
|
|
89
|
-
/**
|
|
90
|
-
* Infer workflow function signature from worker perspective
|
|
91
|
-
* Worker receives z.input and returns z.output
|
|
92
|
-
*/
|
|
93
|
-
type WorkerInferWorkflow<TWorkflow extends WorkflowDefinition> = (args: WorkerInferInput<TWorkflow>) => Promise<WorkerInferOutput<TWorkflow>>;
|
|
94
|
-
/**
|
|
95
|
-
* Infer activity function signature from worker perspective
|
|
96
|
-
* Worker receives z.input and returns z.output
|
|
97
|
-
*/
|
|
98
|
-
type WorkerInferActivity<TActivity extends ActivityDefinition> = (args: WorkerInferInput<TActivity>) => Promise<WorkerInferOutput<TActivity>>;
|
|
99
|
-
/**
|
|
100
|
-
* Infer signal handler signature from worker perspective
|
|
101
|
-
* Worker receives z.input
|
|
102
|
-
*/
|
|
103
|
-
type WorkerInferSignal<TSignal extends SignalDefinition> = (args: WorkerInferInput<TSignal>) => Promise<void>;
|
|
104
|
-
/**
|
|
105
|
-
* Infer query handler signature from worker perspective
|
|
106
|
-
* Worker receives z.input and returns z.output
|
|
107
|
-
*/
|
|
108
|
-
type WorkerInferQuery<TQuery extends QueryDefinition> = (args: WorkerInferInput<TQuery>) => Promise<WorkerInferOutput<TQuery>>;
|
|
109
|
-
/**
|
|
110
|
-
* Infer update handler signature from worker perspective
|
|
111
|
-
* Worker receives z.input and returns z.output
|
|
112
|
-
*/
|
|
113
|
-
type WorkerInferUpdate<TUpdate extends UpdateDefinition> = (args: WorkerInferInput<TUpdate>) => Promise<WorkerInferOutput<TUpdate>>;
|
|
114
|
-
/**
|
|
115
|
-
* CLIENT PERSPECTIVE
|
|
116
|
-
* Client sends z.output and receives z.input
|
|
117
|
-
*/
|
|
118
|
-
/**
|
|
119
|
-
* Infer workflow function signature from client perspective
|
|
120
|
-
* Client sends z.output and receives z.input
|
|
121
|
-
*/
|
|
122
|
-
type ClientInferWorkflow<TWorkflow extends WorkflowDefinition> = (args: ClientInferInput<TWorkflow>) => Promise<ClientInferOutput<TWorkflow>>;
|
|
123
|
-
/**
|
|
124
|
-
* Infer activity function signature from client perspective
|
|
125
|
-
* Client sends z.output and receives z.input
|
|
126
|
-
*/
|
|
127
|
-
type ClientInferActivity<TActivity extends ActivityDefinition> = (args: ClientInferInput<TActivity>) => Promise<ClientInferOutput<TActivity>>;
|
|
128
|
-
/**
|
|
129
|
-
* Infer signal handler signature from client perspective
|
|
130
|
-
* Client sends z.output
|
|
131
|
-
*/
|
|
132
|
-
type ClientInferSignal<TSignal extends SignalDefinition> = (args: ClientInferInput<TSignal>) => Promise<void>;
|
|
133
|
-
/**
|
|
134
|
-
* Infer query handler signature from client perspective
|
|
135
|
-
* Client sends z.output and receives z.input
|
|
136
|
-
*/
|
|
137
|
-
type ClientInferQuery<TQuery extends QueryDefinition> = (args: ClientInferInput<TQuery>) => Promise<ClientInferOutput<TQuery>>;
|
|
138
|
-
/**
|
|
139
|
-
* Infer update handler signature from client perspective
|
|
140
|
-
* Client sends z.output and receives z.input
|
|
141
|
-
*/
|
|
142
|
-
type ClientInferUpdate<TUpdate extends UpdateDefinition> = (args: ClientInferInput<TUpdate>) => Promise<ClientInferOutput<TUpdate>>;
|
|
143
|
-
/**
|
|
144
|
-
* WORKER PERSPECTIVE - Contract-level types
|
|
145
|
-
*/
|
|
146
|
-
/**
|
|
147
|
-
* Infer all workflows from a contract (worker perspective)
|
|
148
|
-
*/
|
|
149
|
-
type WorkerInferWorkflows<TContract extends ContractDefinition> = { [K in keyof TContract["workflows"]]: WorkerInferWorkflow<TContract["workflows"][K]> };
|
|
150
|
-
/**
|
|
151
|
-
* Infer all activities from a contract (worker perspective)
|
|
152
|
-
*/
|
|
153
|
-
type WorkerInferActivities<TContract extends ContractDefinition> = TContract["activities"] extends Record<string, ActivityDefinition> ? { [K in keyof TContract["activities"]]: WorkerInferActivity<TContract["activities"][K]> } : {};
|
|
154
|
-
/**
|
|
155
|
-
* Infer activities from a workflow definition (worker perspective)
|
|
156
|
-
*/
|
|
157
|
-
type WorkerInferWorkflowActivities<T extends WorkflowDefinition> = T["activities"] extends Record<string, ActivityDefinition> ? { [K in keyof T["activities"]]: WorkerInferActivity<T["activities"][K]> } : {};
|
|
158
|
-
/**
|
|
159
|
-
* Infer signals from a workflow definition (worker perspective)
|
|
160
|
-
*/
|
|
161
|
-
type WorkerInferWorkflowSignals<T extends WorkflowDefinition> = T["signals"] extends Record<string, SignalDefinition> ? { [K in keyof T["signals"]]: WorkerInferSignal<T["signals"][K]> } : {};
|
|
162
|
-
/**
|
|
163
|
-
* Infer queries from a workflow definition (worker perspective)
|
|
164
|
-
*/
|
|
165
|
-
type WorkerInferWorkflowQueries<T extends WorkflowDefinition> = T["queries"] extends Record<string, QueryDefinition> ? { [K in keyof T["queries"]]: WorkerInferQuery<T["queries"][K]> } : {};
|
|
166
|
-
/**
|
|
167
|
-
* Infer updates from a workflow definition (worker perspective)
|
|
168
|
-
*/
|
|
169
|
-
type WorkerInferWorkflowUpdates<T extends WorkflowDefinition> = T["updates"] extends Record<string, UpdateDefinition> ? { [K in keyof T["updates"]]: WorkerInferUpdate<T["updates"][K]> } : {};
|
|
170
|
-
/**
|
|
171
|
-
* Infer all activities available in a workflow context (worker perspective)
|
|
172
|
-
* Combines workflow-specific activities with global activities
|
|
173
|
-
*/
|
|
174
|
-
type WorkerInferWorkflowContextActivities<TContract extends ContractDefinition, TWorkflowName extends keyof TContract["workflows"]> = WorkerInferWorkflowActivities<TContract["workflows"][TWorkflowName]> & WorkerInferActivities<TContract>;
|
|
175
|
-
/**
|
|
176
|
-
* CLIENT PERSPECTIVE - Contract-level types
|
|
177
|
-
*/
|
|
178
|
-
/**
|
|
179
|
-
* Infer all workflows from a contract (client perspective)
|
|
180
|
-
*/
|
|
181
|
-
type ClientInferWorkflows<TContract extends ContractDefinition> = { [K in keyof TContract["workflows"]]: ClientInferWorkflow<TContract["workflows"][K]> };
|
|
182
|
-
/**
|
|
183
|
-
* Infer all activities from a contract (client perspective)
|
|
184
|
-
*/
|
|
185
|
-
type ClientInferActivities<TContract extends ContractDefinition> = TContract["activities"] extends Record<string, ActivityDefinition> ? { [K in keyof TContract["activities"]]: ClientInferActivity<TContract["activities"][K]> } : {};
|
|
186
|
-
/**
|
|
187
|
-
* Infer activities from a workflow definition (client perspective)
|
|
188
|
-
*/
|
|
189
|
-
type ClientInferWorkflowActivities<T extends WorkflowDefinition> = T["activities"] extends Record<string, ActivityDefinition> ? { [K in keyof T["activities"]]: ClientInferActivity<T["activities"][K]> } : {};
|
|
190
|
-
/**
|
|
191
|
-
* Infer signals from a workflow definition (client perspective)
|
|
192
|
-
*/
|
|
193
|
-
type ClientInferWorkflowSignals<T extends WorkflowDefinition> = T["signals"] extends Record<string, SignalDefinition> ? { [K in keyof T["signals"]]: ClientInferSignal<T["signals"][K]> } : {};
|
|
194
|
-
/**
|
|
195
|
-
* Infer queries from a workflow definition (client perspective)
|
|
196
|
-
*/
|
|
197
|
-
type ClientInferWorkflowQueries<T extends WorkflowDefinition> = T["queries"] extends Record<string, QueryDefinition> ? { [K in keyof T["queries"]]: ClientInferQuery<T["queries"][K]> } : {};
|
|
198
|
-
/**
|
|
199
|
-
* Infer updates from a workflow definition (client perspective)
|
|
200
|
-
*/
|
|
201
|
-
type ClientInferWorkflowUpdates<T extends WorkflowDefinition> = T["updates"] extends Record<string, UpdateDefinition> ? { [K in keyof T["updates"]]: ClientInferUpdate<T["updates"][K]> } : {};
|
|
202
|
-
/**
|
|
203
|
-
* Infer all activities available in a workflow context (client perspective)
|
|
204
|
-
* Combines workflow-specific activities with global activities
|
|
205
|
-
*/
|
|
206
|
-
type ClientInferWorkflowContextActivities<TContract extends ContractDefinition, TWorkflowName extends keyof TContract["workflows"]> = ClientInferWorkflowActivities<TContract["workflows"][TWorkflowName]> & ClientInferActivities<TContract>;
|
|
207
|
-
/**
|
|
208
|
-
* UTILITY TYPES FOR ACTIVITY HANDLERS
|
|
58
|
+
* UTILITY TYPES
|
|
209
59
|
*/
|
|
210
60
|
/**
|
|
211
61
|
* Extract workflow names from a contract as a union type
|
|
@@ -236,33 +86,6 @@ type InferActivityNames<TContract extends ContractDefinition> = TContract["activ
|
|
|
236
86
|
* ```
|
|
237
87
|
*/
|
|
238
88
|
type InferContractWorkflows<TContract extends ContractDefinition> = TContract["workflows"];
|
|
239
|
-
/**
|
|
240
|
-
* Infer the handler type for a global activity from a contract
|
|
241
|
-
*
|
|
242
|
-
* @example
|
|
243
|
-
* ```typescript
|
|
244
|
-
* const log: ActivityHandler<typeof myContract, "log"> = async ({ level, message }) => {
|
|
245
|
-
* logger[level](message);
|
|
246
|
-
* };
|
|
247
|
-
* ```
|
|
248
|
-
*/
|
|
249
|
-
type ActivityHandler<TContract extends ContractDefinition, TActivityName extends keyof TContract["activities"]> = TContract["activities"] extends Record<string, ActivityDefinition> ? (args: WorkerInferInput<TContract["activities"][TActivityName]>) => Promise<WorkerInferOutput<TContract["activities"][TActivityName]>> : never;
|
|
250
|
-
/**
|
|
251
|
-
* Infer the handler type for a workflow-specific activity from a contract
|
|
252
|
-
*
|
|
253
|
-
* @example
|
|
254
|
-
* ```typescript
|
|
255
|
-
* const processPayment: WorkflowActivityHandler<
|
|
256
|
-
* typeof myContract,
|
|
257
|
-
* "processOrder",
|
|
258
|
-
* "processPayment"
|
|
259
|
-
* > = async ({ customerId, amount }) => {
|
|
260
|
-
* // Implementation
|
|
261
|
-
* return { transactionId, status: "success" as const, paidAmount: amount };
|
|
262
|
-
* };
|
|
263
|
-
* ```
|
|
264
|
-
*/
|
|
265
|
-
type WorkflowActivityHandler<TContract extends ContractDefinition, TWorkflowName extends keyof TContract["workflows"], TActivityName extends keyof TContract["workflows"][TWorkflowName]["activities"]> = TContract["workflows"][TWorkflowName]["activities"] extends Record<string, ActivityDefinition> ? (args: WorkerInferInput<TContract["workflows"][TWorkflowName]["activities"][TActivityName]>) => Promise<WorkerInferOutput<TContract["workflows"][TWorkflowName]["activities"][TActivityName]>> : never;
|
|
266
89
|
//#endregion
|
|
267
90
|
//#region src/builder.d.ts
|
|
268
91
|
/**
|
|
@@ -573,4 +396,4 @@ declare function defineNexusOperation<TOperation extends NexusOperationDefinitio
|
|
|
573
396
|
*/
|
|
574
397
|
declare function defineNexusService<TService extends NexusServiceDefinition>(definition: TService): TService;
|
|
575
398
|
//#endregion
|
|
576
|
-
export { type ActivityDefinition, type
|
|
399
|
+
export { type ActivityDefinition, type AnySchema, type ClientInferNexusOperationInput, type ClientInferNexusOperationInvoker, type ClientInferNexusOperationOutput, type ClientInferNexusServiceOperations, type ClientInferNexusServices, type ContractDefinition, type ContractDefinitionWithNexus, type InferActivityNames, type InferContractWorkflows, type InferNexusOperationNames, type InferNexusServiceNames, type InferWorkflowNames, type NexusOperationDefinition, type NexusOperationHandler, type NexusServiceDefinition, type QueryDefinition, type SignalDefinition, type UpdateDefinition, type WorkerInferNexusOperationHandler, type WorkerInferNexusOperationInput, type WorkerInferNexusOperationOutput, type WorkerInferNexusServiceHandlers, type WorkerInferNexusServices, type WorkflowDefinition, defineActivity, defineContract, defineNexusOperation, defineNexusService, defineQuery, defineSignal, defineUpdate, defineWorkflow };
|
package/package.json
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@temporal-contract/contract",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.5",
|
|
4
4
|
"description": "Contract builder for temporal-contract",
|
|
5
5
|
"keywords": [
|
|
6
|
+
"contract",
|
|
6
7
|
"temporal",
|
|
7
|
-
"typescript"
|
|
8
|
-
"contract"
|
|
8
|
+
"typescript"
|
|
9
9
|
],
|
|
10
10
|
"homepage": "https://github.com/btravers/temporal-contract#readme",
|
|
11
11
|
"bugs": {
|
|
@@ -39,17 +39,17 @@
|
|
|
39
39
|
"dist"
|
|
40
40
|
],
|
|
41
41
|
"dependencies": {
|
|
42
|
-
"@standard-schema/spec": "1.
|
|
43
|
-
"zod": "4.1
|
|
42
|
+
"@standard-schema/spec": "1.1.0",
|
|
43
|
+
"zod": "4.2.1"
|
|
44
44
|
},
|
|
45
45
|
"devDependencies": {
|
|
46
|
-
"@vitest/coverage-v8": "4.0.
|
|
47
|
-
"arktype": "2.1.
|
|
48
|
-
"tsdown": "0.
|
|
46
|
+
"@vitest/coverage-v8": "4.0.16",
|
|
47
|
+
"arktype": "2.1.29",
|
|
48
|
+
"tsdown": "0.18.0",
|
|
49
49
|
"typescript": "5.9.3",
|
|
50
50
|
"valibot": "1.2.0",
|
|
51
|
-
"vitest": "4.0.
|
|
52
|
-
"@temporal-contract/tsconfig": "0.0.
|
|
51
|
+
"vitest": "4.0.16",
|
|
52
|
+
"@temporal-contract/tsconfig": "0.0.5"
|
|
53
53
|
},
|
|
54
54
|
"scripts": {
|
|
55
55
|
"build": "tsdown src/index.ts --format cjs,esm --dts --clean",
|