@temporal-contract/contract 0.0.3 → 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.cjs +116 -0
- package/dist/index.d.cts +226 -179
- package/dist/index.d.mts +226 -179
- package/dist/index.mjs +115 -1
- package/package.json +21 -21
package/dist/index.cjs
CHANGED
|
@@ -189,9 +189,125 @@ const defineContract = (definition) => {
|
|
|
189
189
|
return definition;
|
|
190
190
|
};
|
|
191
191
|
|
|
192
|
+
//#endregion
|
|
193
|
+
//#region src/nexus-types.ts
|
|
194
|
+
/**
|
|
195
|
+
* BUILDER FUNCTIONS (Proposed API)
|
|
196
|
+
* These would be added to builder.ts when Nexus support is implemented
|
|
197
|
+
*/
|
|
198
|
+
/**
|
|
199
|
+
* Builder for creating Nexus operation definitions
|
|
200
|
+
*
|
|
201
|
+
* @template TOperation - A NexusOperationDefinition containing input and output schemas
|
|
202
|
+
* @param definition - The Nexus operation definition with typed input/output schemas
|
|
203
|
+
* @returns The same definition with preserved types
|
|
204
|
+
*
|
|
205
|
+
* @example
|
|
206
|
+
* ```typescript
|
|
207
|
+
* const processPayment = defineNexusOperation({
|
|
208
|
+
* input: z.object({ amount: z.number(), customerId: z.string() }),
|
|
209
|
+
* output: z.object({ transactionId: z.string(), status: z.enum(['success', 'failed']) }),
|
|
210
|
+
* });
|
|
211
|
+
* ```
|
|
212
|
+
*/
|
|
213
|
+
function defineNexusOperation(definition) {
|
|
214
|
+
return definition;
|
|
215
|
+
}
|
|
216
|
+
/**
|
|
217
|
+
* Builder for creating Nexus service definitions
|
|
218
|
+
*
|
|
219
|
+
* @template TService - A NexusServiceDefinition containing a record of operations
|
|
220
|
+
* @param definition - The Nexus service definition with typed operations
|
|
221
|
+
* @returns The same definition with preserved types
|
|
222
|
+
*
|
|
223
|
+
* @example
|
|
224
|
+
* ```typescript
|
|
225
|
+
* const PaymentService = defineNexusService({
|
|
226
|
+
* operations: {
|
|
227
|
+
* processPayment: defineNexusOperation({ ... }),
|
|
228
|
+
* refundPayment: defineNexusOperation({ ... }),
|
|
229
|
+
* },
|
|
230
|
+
* });
|
|
231
|
+
* ```
|
|
232
|
+
*/
|
|
233
|
+
function defineNexusService(definition) {
|
|
234
|
+
return definition;
|
|
235
|
+
}
|
|
236
|
+
/**
|
|
237
|
+
* USAGE EXAMPLE
|
|
238
|
+
*
|
|
239
|
+
* This example demonstrates the complete type-safe Nexus workflow:
|
|
240
|
+
*
|
|
241
|
+
* ```typescript
|
|
242
|
+
* import { defineContract, defineNexusService, defineNexusOperation } from '@temporal-contract/contract';
|
|
243
|
+
* import { z } from 'zod';
|
|
244
|
+
*
|
|
245
|
+
* // 1. Define contract with Nexus service
|
|
246
|
+
* const paymentContract = defineContract({
|
|
247
|
+
* taskQueue: 'payments',
|
|
248
|
+
* workflows: { ... },
|
|
249
|
+
* nexusServices: {
|
|
250
|
+
* PaymentService: defineNexusService({
|
|
251
|
+
* operations: {
|
|
252
|
+
* processPayment: defineNexusOperation({
|
|
253
|
+
* input: z.object({
|
|
254
|
+
* amount: z.number().positive(),
|
|
255
|
+
* customerId: z.string().uuid(),
|
|
256
|
+
* }),
|
|
257
|
+
* output: z.object({
|
|
258
|
+
* transactionId: z.string(),
|
|
259
|
+
* status: z.enum(['success', 'failed']),
|
|
260
|
+
* }),
|
|
261
|
+
* }),
|
|
262
|
+
* },
|
|
263
|
+
* }),
|
|
264
|
+
* },
|
|
265
|
+
* });
|
|
266
|
+
*
|
|
267
|
+
* // 2. Worker implementation (type-safe handlers)
|
|
268
|
+
* import { createNexusHandlers } from '@temporal-contract/worker';
|
|
269
|
+
*
|
|
270
|
+
* const nexusHandlers = createNexusHandlers(paymentContract, {
|
|
271
|
+
* PaymentService: {
|
|
272
|
+
* processPayment: async ({ amount, customerId }) => {
|
|
273
|
+
* // ✅ Fully typed parameters
|
|
274
|
+
* // ✅ Input automatically validated
|
|
275
|
+
* const payment = await processPaymentInDatabase(customerId, amount);
|
|
276
|
+
* // ✅ Return value validated against schema
|
|
277
|
+
* return {
|
|
278
|
+
* transactionId: payment.id,
|
|
279
|
+
* status: 'success',
|
|
280
|
+
* };
|
|
281
|
+
* },
|
|
282
|
+
* },
|
|
283
|
+
* });
|
|
284
|
+
*
|
|
285
|
+
* // 3. Client usage (type-safe invocation)
|
|
286
|
+
* import { createNexusClient } from '@temporal-contract/client';
|
|
287
|
+
*
|
|
288
|
+
* const nexusClient = createNexusClient<typeof paymentContract>(connection, {
|
|
289
|
+
* namespace: 'payments-ns',
|
|
290
|
+
* });
|
|
291
|
+
*
|
|
292
|
+
* // ✅ Fully typed invocation
|
|
293
|
+
* const result = await nexusClient.invoke('PaymentService', 'processPayment', {
|
|
294
|
+
* amount: 100,
|
|
295
|
+
* customerId: 'cust-123',
|
|
296
|
+
* });
|
|
297
|
+
*
|
|
298
|
+
* // ❌ TypeScript errors caught at compile time
|
|
299
|
+
* await nexusClient.invoke('PaymentService', 'processPayment', {
|
|
300
|
+
* amount: -50, // Error: amount must be positive
|
|
301
|
+
* customerId: 'invalid', // Error: customerId must be UUID
|
|
302
|
+
* });
|
|
303
|
+
* ```
|
|
304
|
+
*/
|
|
305
|
+
|
|
192
306
|
//#endregion
|
|
193
307
|
exports.defineActivity = defineActivity;
|
|
194
308
|
exports.defineContract = defineContract;
|
|
309
|
+
exports.defineNexusOperation = defineNexusOperation;
|
|
310
|
+
exports.defineNexusService = defineNexusService;
|
|
195
311
|
exports.defineQuery = defineQuery;
|
|
196
312
|
exports.defineSignal = defineSignal;
|
|
197
313
|
exports.defineUpdate = defineUpdate;
|
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
|
/**
|
|
@@ -349,4 +172,228 @@ declare const defineWorkflow: <TWorkflow extends WorkflowDefinition>(definition:
|
|
|
349
172
|
*/
|
|
350
173
|
declare const defineContract: <TContract extends ContractDefinition>(definition: TContract) => TContract;
|
|
351
174
|
//#endregion
|
|
352
|
-
|
|
175
|
+
//#region src/nexus-types.d.ts
|
|
176
|
+
/**
|
|
177
|
+
* Definition of a Nexus operation
|
|
178
|
+
* Similar to ActivityDefinition but for cross-namespace operations
|
|
179
|
+
*
|
|
180
|
+
* @example
|
|
181
|
+
* ```typescript
|
|
182
|
+
* const processPayment = {
|
|
183
|
+
* input: z.object({ amount: z.number(), customerId: z.string() }),
|
|
184
|
+
* output: z.object({ transactionId: z.string(), status: z.enum(['success', 'failed']) }),
|
|
185
|
+
* };
|
|
186
|
+
* ```
|
|
187
|
+
*/
|
|
188
|
+
interface NexusOperationDefinition<TInput extends AnySchema = AnySchema, TOutput extends AnySchema = AnySchema> {
|
|
189
|
+
readonly input: TInput;
|
|
190
|
+
readonly output: TOutput;
|
|
191
|
+
}
|
|
192
|
+
/**
|
|
193
|
+
* Definition of a Nexus service containing multiple operations
|
|
194
|
+
*
|
|
195
|
+
* @example
|
|
196
|
+
* ```typescript
|
|
197
|
+
* const PaymentService = {
|
|
198
|
+
* operations: {
|
|
199
|
+
* processPayment: { input: ..., output: ... },
|
|
200
|
+
* refundPayment: { input: ..., output: ... },
|
|
201
|
+
* },
|
|
202
|
+
* };
|
|
203
|
+
* ```
|
|
204
|
+
*/
|
|
205
|
+
interface NexusServiceDefinition<TOperations extends Record<string, NexusOperationDefinition> = Record<string, NexusOperationDefinition>> {
|
|
206
|
+
readonly operations: TOperations;
|
|
207
|
+
}
|
|
208
|
+
/**
|
|
209
|
+
* Extended ContractDefinition that includes Nexus services
|
|
210
|
+
* This would replace the current ContractDefinition when Nexus support is added
|
|
211
|
+
*
|
|
212
|
+
* @example
|
|
213
|
+
* ```typescript
|
|
214
|
+
* const contract = defineContract({
|
|
215
|
+
* taskQueue: 'payments',
|
|
216
|
+
* workflows: { ... },
|
|
217
|
+
* activities: { ... },
|
|
218
|
+
* nexusServices: {
|
|
219
|
+
* PaymentService: {
|
|
220
|
+
* operations: {
|
|
221
|
+
* processPayment: { input: ..., output: ... },
|
|
222
|
+
* },
|
|
223
|
+
* },
|
|
224
|
+
* },
|
|
225
|
+
* });
|
|
226
|
+
* ```
|
|
227
|
+
*/
|
|
228
|
+
interface ContractDefinitionWithNexus<TWorkflows extends Record<string, WorkflowDefinition> = Record<string, WorkflowDefinition>, TActivities extends Record<string, ActivityDefinition> = Record<string, ActivityDefinition>, TNexusServices extends Record<string, NexusServiceDefinition> = Record<string, NexusServiceDefinition>> {
|
|
229
|
+
readonly taskQueue: string;
|
|
230
|
+
readonly workflows: TWorkflows;
|
|
231
|
+
readonly activities?: TActivities;
|
|
232
|
+
readonly nexusServices?: TNexusServices;
|
|
233
|
+
}
|
|
234
|
+
/**
|
|
235
|
+
* WORKER PERSPECTIVE - Nexus operation handler type inference
|
|
236
|
+
* Worker receives the parsed input and returns the raw output
|
|
237
|
+
*/
|
|
238
|
+
/**
|
|
239
|
+
* Infer input type from a Nexus operation definition (worker perspective)
|
|
240
|
+
*/
|
|
241
|
+
type WorkerInferNexusOperationInput<T extends NexusOperationDefinition> = StandardSchemaV1.InferOutput<T["input"]>;
|
|
242
|
+
/**
|
|
243
|
+
* Infer output type from a Nexus operation definition (worker perspective)
|
|
244
|
+
*/
|
|
245
|
+
type WorkerInferNexusOperationOutput<T extends NexusOperationDefinition> = StandardSchemaV1.InferInput<T["output"]>;
|
|
246
|
+
/**
|
|
247
|
+
* Infer the handler function signature for a Nexus operation (worker perspective)
|
|
248
|
+
*
|
|
249
|
+
* @example
|
|
250
|
+
* ```typescript
|
|
251
|
+
* type ProcessPaymentHandler = WorkerInferNexusOperationHandler<typeof processPaymentOperation>;
|
|
252
|
+
* // (args: { amount: number; customerId: string }) => Promise<{ transactionId: string; status: 'success' | 'failed' }>
|
|
253
|
+
* ```
|
|
254
|
+
*/
|
|
255
|
+
type WorkerInferNexusOperationHandler<TOperation extends NexusOperationDefinition> = (args: WorkerInferNexusOperationInput<TOperation>) => Promise<WorkerInferNexusOperationOutput<TOperation>>;
|
|
256
|
+
/**
|
|
257
|
+
* Infer all operation handlers for a Nexus service (worker perspective)
|
|
258
|
+
*
|
|
259
|
+
* @example
|
|
260
|
+
* ```typescript
|
|
261
|
+
* type PaymentServiceHandlers = WorkerInferNexusServiceHandlers<typeof PaymentService>;
|
|
262
|
+
* // {
|
|
263
|
+
* // processPayment: (args: { ... }) => Promise<{ ... }>;
|
|
264
|
+
* // refundPayment: (args: { ... }) => Promise<{ ... }>;
|
|
265
|
+
* // }
|
|
266
|
+
* ```
|
|
267
|
+
*/
|
|
268
|
+
type WorkerInferNexusServiceHandlers<T extends NexusServiceDefinition> = { [K in keyof T["operations"]]: WorkerInferNexusOperationHandler<T["operations"][K]> };
|
|
269
|
+
/**
|
|
270
|
+
* Infer all Nexus service handlers from a contract (worker perspective)
|
|
271
|
+
*
|
|
272
|
+
* @example
|
|
273
|
+
* ```typescript
|
|
274
|
+
* type AllNexusHandlers = WorkerInferNexusServices<typeof myContract>;
|
|
275
|
+
* // {
|
|
276
|
+
* // PaymentService: { processPayment: ..., refundPayment: ... };
|
|
277
|
+
* // InventoryService: { reserveItems: ..., releaseItems: ... };
|
|
278
|
+
* // }
|
|
279
|
+
* ```
|
|
280
|
+
*/
|
|
281
|
+
type WorkerInferNexusServices<TContract extends ContractDefinitionWithNexus> = TContract["nexusServices"] extends Record<string, NexusServiceDefinition> ? { [K in keyof TContract["nexusServices"]]: WorkerInferNexusServiceHandlers<TContract["nexusServices"][K]> } : {};
|
|
282
|
+
/**
|
|
283
|
+
* CLIENT PERSPECTIVE - Nexus operation client type inference
|
|
284
|
+
* Client sends the raw input and receives the parsed output
|
|
285
|
+
*/
|
|
286
|
+
/**
|
|
287
|
+
* Infer input type from a Nexus operation definition (client perspective)
|
|
288
|
+
*/
|
|
289
|
+
type ClientInferNexusOperationInput<T extends NexusOperationDefinition> = StandardSchemaV1.InferInput<T["input"]>;
|
|
290
|
+
/**
|
|
291
|
+
* Infer output type from a Nexus operation definition (client perspective)
|
|
292
|
+
*/
|
|
293
|
+
type ClientInferNexusOperationOutput<T extends NexusOperationDefinition> = StandardSchemaV1.InferOutput<T["output"]>;
|
|
294
|
+
/**
|
|
295
|
+
* Infer the client function signature for a Nexus operation (client perspective)
|
|
296
|
+
*
|
|
297
|
+
* @example
|
|
298
|
+
* ```typescript
|
|
299
|
+
* type ProcessPaymentClient = ClientInferNexusOperationInvoker<typeof processPaymentOperation>;
|
|
300
|
+
* // (args: { amount: number; customerId: string }) => Promise<{ transactionId: string; status: 'success' | 'failed' }>
|
|
301
|
+
* ```
|
|
302
|
+
*/
|
|
303
|
+
type ClientInferNexusOperationInvoker<TOperation extends NexusOperationDefinition> = (args: ClientInferNexusOperationInput<TOperation>) => Promise<ClientInferNexusOperationOutput<TOperation>>;
|
|
304
|
+
/**
|
|
305
|
+
* Infer all operation invokers for a Nexus service (client perspective)
|
|
306
|
+
*/
|
|
307
|
+
type ClientInferNexusServiceOperations<T extends NexusServiceDefinition> = { [K in keyof T["operations"]]: ClientInferNexusOperationInvoker<T["operations"][K]> };
|
|
308
|
+
/**
|
|
309
|
+
* Infer all Nexus service operations from a contract (client perspective)
|
|
310
|
+
*
|
|
311
|
+
* @example
|
|
312
|
+
* ```typescript
|
|
313
|
+
* type AllNexusOperations = ClientInferNexusServices<typeof myContract>;
|
|
314
|
+
* // {
|
|
315
|
+
* // PaymentService: { processPayment: ..., refundPayment: ... };
|
|
316
|
+
* // InventoryService: { reserveItems: ..., releaseItems: ... };
|
|
317
|
+
* // }
|
|
318
|
+
* ```
|
|
319
|
+
*/
|
|
320
|
+
type ClientInferNexusServices<TContract extends ContractDefinitionWithNexus> = TContract["nexusServices"] extends Record<string, NexusServiceDefinition> ? { [K in keyof TContract["nexusServices"]]: ClientInferNexusServiceOperations<TContract["nexusServices"][K]> } : {};
|
|
321
|
+
/**
|
|
322
|
+
* UTILITY TYPES
|
|
323
|
+
*/
|
|
324
|
+
/**
|
|
325
|
+
* Extract service names from a contract as a union type
|
|
326
|
+
*
|
|
327
|
+
* @example
|
|
328
|
+
* ```typescript
|
|
329
|
+
* type MyServiceNames = InferNexusServiceNames<typeof myContract>;
|
|
330
|
+
* // "PaymentService" | "InventoryService"
|
|
331
|
+
* ```
|
|
332
|
+
*/
|
|
333
|
+
type InferNexusServiceNames<TContract extends ContractDefinitionWithNexus> = TContract["nexusServices"] extends Record<string, NexusServiceDefinition> ? keyof TContract["nexusServices"] & string : never;
|
|
334
|
+
/**
|
|
335
|
+
* Extract operation names from a service as a union type
|
|
336
|
+
*
|
|
337
|
+
* @example
|
|
338
|
+
* ```typescript
|
|
339
|
+
* type PaymentOperations = InferNexusOperationNames<typeof myContract, "PaymentService">;
|
|
340
|
+
* // "processPayment" | "refundPayment"
|
|
341
|
+
* ```
|
|
342
|
+
*/
|
|
343
|
+
type InferNexusOperationNames<TContract extends ContractDefinitionWithNexus, TServiceName extends InferNexusServiceNames<TContract>> = TContract["nexusServices"] extends Record<string, NexusServiceDefinition> ? keyof TContract["nexusServices"][TServiceName]["operations"] & string : never;
|
|
344
|
+
/**
|
|
345
|
+
* Infer the handler type for a specific Nexus operation (worker perspective)
|
|
346
|
+
*
|
|
347
|
+
* @example
|
|
348
|
+
* ```typescript
|
|
349
|
+
* const processPayment: NexusOperationHandler<
|
|
350
|
+
* typeof myContract,
|
|
351
|
+
* "PaymentService",
|
|
352
|
+
* "processPayment"
|
|
353
|
+
* > = async ({ amount, customerId }) => {
|
|
354
|
+
* // Implementation
|
|
355
|
+
* return { transactionId: 'tx-123', status: 'success' };
|
|
356
|
+
* };
|
|
357
|
+
* ```
|
|
358
|
+
*/
|
|
359
|
+
type NexusOperationHandler<TContract extends ContractDefinitionWithNexus, TServiceName extends InferNexusServiceNames<TContract>, TOperationName extends InferNexusOperationNames<TContract, TServiceName>> = TContract["nexusServices"] extends Record<string, NexusServiceDefinition> ? (args: WorkerInferNexusOperationInput<TContract["nexusServices"][TServiceName]["operations"][TOperationName]>) => Promise<WorkerInferNexusOperationOutput<TContract["nexusServices"][TServiceName]["operations"][TOperationName]>> : never;
|
|
360
|
+
/**
|
|
361
|
+
* BUILDER FUNCTIONS (Proposed API)
|
|
362
|
+
* These would be added to builder.ts when Nexus support is implemented
|
|
363
|
+
*/
|
|
364
|
+
/**
|
|
365
|
+
* Builder for creating Nexus operation definitions
|
|
366
|
+
*
|
|
367
|
+
* @template TOperation - A NexusOperationDefinition containing input and output schemas
|
|
368
|
+
* @param definition - The Nexus operation definition with typed input/output schemas
|
|
369
|
+
* @returns The same definition with preserved types
|
|
370
|
+
*
|
|
371
|
+
* @example
|
|
372
|
+
* ```typescript
|
|
373
|
+
* const processPayment = defineNexusOperation({
|
|
374
|
+
* input: z.object({ amount: z.number(), customerId: z.string() }),
|
|
375
|
+
* output: z.object({ transactionId: z.string(), status: z.enum(['success', 'failed']) }),
|
|
376
|
+
* });
|
|
377
|
+
* ```
|
|
378
|
+
*/
|
|
379
|
+
declare function defineNexusOperation<TOperation extends NexusOperationDefinition>(definition: TOperation): TOperation;
|
|
380
|
+
/**
|
|
381
|
+
* Builder for creating Nexus service definitions
|
|
382
|
+
*
|
|
383
|
+
* @template TService - A NexusServiceDefinition containing a record of operations
|
|
384
|
+
* @param definition - The Nexus service definition with typed operations
|
|
385
|
+
* @returns The same definition with preserved types
|
|
386
|
+
*
|
|
387
|
+
* @example
|
|
388
|
+
* ```typescript
|
|
389
|
+
* const PaymentService = defineNexusService({
|
|
390
|
+
* operations: {
|
|
391
|
+
* processPayment: defineNexusOperation({ ... }),
|
|
392
|
+
* refundPayment: defineNexusOperation({ ... }),
|
|
393
|
+
* },
|
|
394
|
+
* });
|
|
395
|
+
* ```
|
|
396
|
+
*/
|
|
397
|
+
declare function defineNexusService<TService extends NexusServiceDefinition>(definition: TService): TService;
|
|
398
|
+
//#endregion
|
|
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
|
/**
|
|
@@ -349,4 +172,228 @@ declare const defineWorkflow: <TWorkflow extends WorkflowDefinition>(definition:
|
|
|
349
172
|
*/
|
|
350
173
|
declare const defineContract: <TContract extends ContractDefinition>(definition: TContract) => TContract;
|
|
351
174
|
//#endregion
|
|
352
|
-
|
|
175
|
+
//#region src/nexus-types.d.ts
|
|
176
|
+
/**
|
|
177
|
+
* Definition of a Nexus operation
|
|
178
|
+
* Similar to ActivityDefinition but for cross-namespace operations
|
|
179
|
+
*
|
|
180
|
+
* @example
|
|
181
|
+
* ```typescript
|
|
182
|
+
* const processPayment = {
|
|
183
|
+
* input: z.object({ amount: z.number(), customerId: z.string() }),
|
|
184
|
+
* output: z.object({ transactionId: z.string(), status: z.enum(['success', 'failed']) }),
|
|
185
|
+
* };
|
|
186
|
+
* ```
|
|
187
|
+
*/
|
|
188
|
+
interface NexusOperationDefinition<TInput extends AnySchema = AnySchema, TOutput extends AnySchema = AnySchema> {
|
|
189
|
+
readonly input: TInput;
|
|
190
|
+
readonly output: TOutput;
|
|
191
|
+
}
|
|
192
|
+
/**
|
|
193
|
+
* Definition of a Nexus service containing multiple operations
|
|
194
|
+
*
|
|
195
|
+
* @example
|
|
196
|
+
* ```typescript
|
|
197
|
+
* const PaymentService = {
|
|
198
|
+
* operations: {
|
|
199
|
+
* processPayment: { input: ..., output: ... },
|
|
200
|
+
* refundPayment: { input: ..., output: ... },
|
|
201
|
+
* },
|
|
202
|
+
* };
|
|
203
|
+
* ```
|
|
204
|
+
*/
|
|
205
|
+
interface NexusServiceDefinition<TOperations extends Record<string, NexusOperationDefinition> = Record<string, NexusOperationDefinition>> {
|
|
206
|
+
readonly operations: TOperations;
|
|
207
|
+
}
|
|
208
|
+
/**
|
|
209
|
+
* Extended ContractDefinition that includes Nexus services
|
|
210
|
+
* This would replace the current ContractDefinition when Nexus support is added
|
|
211
|
+
*
|
|
212
|
+
* @example
|
|
213
|
+
* ```typescript
|
|
214
|
+
* const contract = defineContract({
|
|
215
|
+
* taskQueue: 'payments',
|
|
216
|
+
* workflows: { ... },
|
|
217
|
+
* activities: { ... },
|
|
218
|
+
* nexusServices: {
|
|
219
|
+
* PaymentService: {
|
|
220
|
+
* operations: {
|
|
221
|
+
* processPayment: { input: ..., output: ... },
|
|
222
|
+
* },
|
|
223
|
+
* },
|
|
224
|
+
* },
|
|
225
|
+
* });
|
|
226
|
+
* ```
|
|
227
|
+
*/
|
|
228
|
+
interface ContractDefinitionWithNexus<TWorkflows extends Record<string, WorkflowDefinition> = Record<string, WorkflowDefinition>, TActivities extends Record<string, ActivityDefinition> = Record<string, ActivityDefinition>, TNexusServices extends Record<string, NexusServiceDefinition> = Record<string, NexusServiceDefinition>> {
|
|
229
|
+
readonly taskQueue: string;
|
|
230
|
+
readonly workflows: TWorkflows;
|
|
231
|
+
readonly activities?: TActivities;
|
|
232
|
+
readonly nexusServices?: TNexusServices;
|
|
233
|
+
}
|
|
234
|
+
/**
|
|
235
|
+
* WORKER PERSPECTIVE - Nexus operation handler type inference
|
|
236
|
+
* Worker receives the parsed input and returns the raw output
|
|
237
|
+
*/
|
|
238
|
+
/**
|
|
239
|
+
* Infer input type from a Nexus operation definition (worker perspective)
|
|
240
|
+
*/
|
|
241
|
+
type WorkerInferNexusOperationInput<T extends NexusOperationDefinition> = StandardSchemaV1.InferOutput<T["input"]>;
|
|
242
|
+
/**
|
|
243
|
+
* Infer output type from a Nexus operation definition (worker perspective)
|
|
244
|
+
*/
|
|
245
|
+
type WorkerInferNexusOperationOutput<T extends NexusOperationDefinition> = StandardSchemaV1.InferInput<T["output"]>;
|
|
246
|
+
/**
|
|
247
|
+
* Infer the handler function signature for a Nexus operation (worker perspective)
|
|
248
|
+
*
|
|
249
|
+
* @example
|
|
250
|
+
* ```typescript
|
|
251
|
+
* type ProcessPaymentHandler = WorkerInferNexusOperationHandler<typeof processPaymentOperation>;
|
|
252
|
+
* // (args: { amount: number; customerId: string }) => Promise<{ transactionId: string; status: 'success' | 'failed' }>
|
|
253
|
+
* ```
|
|
254
|
+
*/
|
|
255
|
+
type WorkerInferNexusOperationHandler<TOperation extends NexusOperationDefinition> = (args: WorkerInferNexusOperationInput<TOperation>) => Promise<WorkerInferNexusOperationOutput<TOperation>>;
|
|
256
|
+
/**
|
|
257
|
+
* Infer all operation handlers for a Nexus service (worker perspective)
|
|
258
|
+
*
|
|
259
|
+
* @example
|
|
260
|
+
* ```typescript
|
|
261
|
+
* type PaymentServiceHandlers = WorkerInferNexusServiceHandlers<typeof PaymentService>;
|
|
262
|
+
* // {
|
|
263
|
+
* // processPayment: (args: { ... }) => Promise<{ ... }>;
|
|
264
|
+
* // refundPayment: (args: { ... }) => Promise<{ ... }>;
|
|
265
|
+
* // }
|
|
266
|
+
* ```
|
|
267
|
+
*/
|
|
268
|
+
type WorkerInferNexusServiceHandlers<T extends NexusServiceDefinition> = { [K in keyof T["operations"]]: WorkerInferNexusOperationHandler<T["operations"][K]> };
|
|
269
|
+
/**
|
|
270
|
+
* Infer all Nexus service handlers from a contract (worker perspective)
|
|
271
|
+
*
|
|
272
|
+
* @example
|
|
273
|
+
* ```typescript
|
|
274
|
+
* type AllNexusHandlers = WorkerInferNexusServices<typeof myContract>;
|
|
275
|
+
* // {
|
|
276
|
+
* // PaymentService: { processPayment: ..., refundPayment: ... };
|
|
277
|
+
* // InventoryService: { reserveItems: ..., releaseItems: ... };
|
|
278
|
+
* // }
|
|
279
|
+
* ```
|
|
280
|
+
*/
|
|
281
|
+
type WorkerInferNexusServices<TContract extends ContractDefinitionWithNexus> = TContract["nexusServices"] extends Record<string, NexusServiceDefinition> ? { [K in keyof TContract["nexusServices"]]: WorkerInferNexusServiceHandlers<TContract["nexusServices"][K]> } : {};
|
|
282
|
+
/**
|
|
283
|
+
* CLIENT PERSPECTIVE - Nexus operation client type inference
|
|
284
|
+
* Client sends the raw input and receives the parsed output
|
|
285
|
+
*/
|
|
286
|
+
/**
|
|
287
|
+
* Infer input type from a Nexus operation definition (client perspective)
|
|
288
|
+
*/
|
|
289
|
+
type ClientInferNexusOperationInput<T extends NexusOperationDefinition> = StandardSchemaV1.InferInput<T["input"]>;
|
|
290
|
+
/**
|
|
291
|
+
* Infer output type from a Nexus operation definition (client perspective)
|
|
292
|
+
*/
|
|
293
|
+
type ClientInferNexusOperationOutput<T extends NexusOperationDefinition> = StandardSchemaV1.InferOutput<T["output"]>;
|
|
294
|
+
/**
|
|
295
|
+
* Infer the client function signature for a Nexus operation (client perspective)
|
|
296
|
+
*
|
|
297
|
+
* @example
|
|
298
|
+
* ```typescript
|
|
299
|
+
* type ProcessPaymentClient = ClientInferNexusOperationInvoker<typeof processPaymentOperation>;
|
|
300
|
+
* // (args: { amount: number; customerId: string }) => Promise<{ transactionId: string; status: 'success' | 'failed' }>
|
|
301
|
+
* ```
|
|
302
|
+
*/
|
|
303
|
+
type ClientInferNexusOperationInvoker<TOperation extends NexusOperationDefinition> = (args: ClientInferNexusOperationInput<TOperation>) => Promise<ClientInferNexusOperationOutput<TOperation>>;
|
|
304
|
+
/**
|
|
305
|
+
* Infer all operation invokers for a Nexus service (client perspective)
|
|
306
|
+
*/
|
|
307
|
+
type ClientInferNexusServiceOperations<T extends NexusServiceDefinition> = { [K in keyof T["operations"]]: ClientInferNexusOperationInvoker<T["operations"][K]> };
|
|
308
|
+
/**
|
|
309
|
+
* Infer all Nexus service operations from a contract (client perspective)
|
|
310
|
+
*
|
|
311
|
+
* @example
|
|
312
|
+
* ```typescript
|
|
313
|
+
* type AllNexusOperations = ClientInferNexusServices<typeof myContract>;
|
|
314
|
+
* // {
|
|
315
|
+
* // PaymentService: { processPayment: ..., refundPayment: ... };
|
|
316
|
+
* // InventoryService: { reserveItems: ..., releaseItems: ... };
|
|
317
|
+
* // }
|
|
318
|
+
* ```
|
|
319
|
+
*/
|
|
320
|
+
type ClientInferNexusServices<TContract extends ContractDefinitionWithNexus> = TContract["nexusServices"] extends Record<string, NexusServiceDefinition> ? { [K in keyof TContract["nexusServices"]]: ClientInferNexusServiceOperations<TContract["nexusServices"][K]> } : {};
|
|
321
|
+
/**
|
|
322
|
+
* UTILITY TYPES
|
|
323
|
+
*/
|
|
324
|
+
/**
|
|
325
|
+
* Extract service names from a contract as a union type
|
|
326
|
+
*
|
|
327
|
+
* @example
|
|
328
|
+
* ```typescript
|
|
329
|
+
* type MyServiceNames = InferNexusServiceNames<typeof myContract>;
|
|
330
|
+
* // "PaymentService" | "InventoryService"
|
|
331
|
+
* ```
|
|
332
|
+
*/
|
|
333
|
+
type InferNexusServiceNames<TContract extends ContractDefinitionWithNexus> = TContract["nexusServices"] extends Record<string, NexusServiceDefinition> ? keyof TContract["nexusServices"] & string : never;
|
|
334
|
+
/**
|
|
335
|
+
* Extract operation names from a service as a union type
|
|
336
|
+
*
|
|
337
|
+
* @example
|
|
338
|
+
* ```typescript
|
|
339
|
+
* type PaymentOperations = InferNexusOperationNames<typeof myContract, "PaymentService">;
|
|
340
|
+
* // "processPayment" | "refundPayment"
|
|
341
|
+
* ```
|
|
342
|
+
*/
|
|
343
|
+
type InferNexusOperationNames<TContract extends ContractDefinitionWithNexus, TServiceName extends InferNexusServiceNames<TContract>> = TContract["nexusServices"] extends Record<string, NexusServiceDefinition> ? keyof TContract["nexusServices"][TServiceName]["operations"] & string : never;
|
|
344
|
+
/**
|
|
345
|
+
* Infer the handler type for a specific Nexus operation (worker perspective)
|
|
346
|
+
*
|
|
347
|
+
* @example
|
|
348
|
+
* ```typescript
|
|
349
|
+
* const processPayment: NexusOperationHandler<
|
|
350
|
+
* typeof myContract,
|
|
351
|
+
* "PaymentService",
|
|
352
|
+
* "processPayment"
|
|
353
|
+
* > = async ({ amount, customerId }) => {
|
|
354
|
+
* // Implementation
|
|
355
|
+
* return { transactionId: 'tx-123', status: 'success' };
|
|
356
|
+
* };
|
|
357
|
+
* ```
|
|
358
|
+
*/
|
|
359
|
+
type NexusOperationHandler<TContract extends ContractDefinitionWithNexus, TServiceName extends InferNexusServiceNames<TContract>, TOperationName extends InferNexusOperationNames<TContract, TServiceName>> = TContract["nexusServices"] extends Record<string, NexusServiceDefinition> ? (args: WorkerInferNexusOperationInput<TContract["nexusServices"][TServiceName]["operations"][TOperationName]>) => Promise<WorkerInferNexusOperationOutput<TContract["nexusServices"][TServiceName]["operations"][TOperationName]>> : never;
|
|
360
|
+
/**
|
|
361
|
+
* BUILDER FUNCTIONS (Proposed API)
|
|
362
|
+
* These would be added to builder.ts when Nexus support is implemented
|
|
363
|
+
*/
|
|
364
|
+
/**
|
|
365
|
+
* Builder for creating Nexus operation definitions
|
|
366
|
+
*
|
|
367
|
+
* @template TOperation - A NexusOperationDefinition containing input and output schemas
|
|
368
|
+
* @param definition - The Nexus operation definition with typed input/output schemas
|
|
369
|
+
* @returns The same definition with preserved types
|
|
370
|
+
*
|
|
371
|
+
* @example
|
|
372
|
+
* ```typescript
|
|
373
|
+
* const processPayment = defineNexusOperation({
|
|
374
|
+
* input: z.object({ amount: z.number(), customerId: z.string() }),
|
|
375
|
+
* output: z.object({ transactionId: z.string(), status: z.enum(['success', 'failed']) }),
|
|
376
|
+
* });
|
|
377
|
+
* ```
|
|
378
|
+
*/
|
|
379
|
+
declare function defineNexusOperation<TOperation extends NexusOperationDefinition>(definition: TOperation): TOperation;
|
|
380
|
+
/**
|
|
381
|
+
* Builder for creating Nexus service definitions
|
|
382
|
+
*
|
|
383
|
+
* @template TService - A NexusServiceDefinition containing a record of operations
|
|
384
|
+
* @param definition - The Nexus service definition with typed operations
|
|
385
|
+
* @returns The same definition with preserved types
|
|
386
|
+
*
|
|
387
|
+
* @example
|
|
388
|
+
* ```typescript
|
|
389
|
+
* const PaymentService = defineNexusService({
|
|
390
|
+
* operations: {
|
|
391
|
+
* processPayment: defineNexusOperation({ ... }),
|
|
392
|
+
* refundPayment: defineNexusOperation({ ... }),
|
|
393
|
+
* },
|
|
394
|
+
* });
|
|
395
|
+
* ```
|
|
396
|
+
*/
|
|
397
|
+
declare function defineNexusService<TService extends NexusServiceDefinition>(definition: TService): TService;
|
|
398
|
+
//#endregion
|
|
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.mjs
CHANGED
|
@@ -190,4 +190,118 @@ const defineContract = (definition) => {
|
|
|
190
190
|
};
|
|
191
191
|
|
|
192
192
|
//#endregion
|
|
193
|
-
|
|
193
|
+
//#region src/nexus-types.ts
|
|
194
|
+
/**
|
|
195
|
+
* BUILDER FUNCTIONS (Proposed API)
|
|
196
|
+
* These would be added to builder.ts when Nexus support is implemented
|
|
197
|
+
*/
|
|
198
|
+
/**
|
|
199
|
+
* Builder for creating Nexus operation definitions
|
|
200
|
+
*
|
|
201
|
+
* @template TOperation - A NexusOperationDefinition containing input and output schemas
|
|
202
|
+
* @param definition - The Nexus operation definition with typed input/output schemas
|
|
203
|
+
* @returns The same definition with preserved types
|
|
204
|
+
*
|
|
205
|
+
* @example
|
|
206
|
+
* ```typescript
|
|
207
|
+
* const processPayment = defineNexusOperation({
|
|
208
|
+
* input: z.object({ amount: z.number(), customerId: z.string() }),
|
|
209
|
+
* output: z.object({ transactionId: z.string(), status: z.enum(['success', 'failed']) }),
|
|
210
|
+
* });
|
|
211
|
+
* ```
|
|
212
|
+
*/
|
|
213
|
+
function defineNexusOperation(definition) {
|
|
214
|
+
return definition;
|
|
215
|
+
}
|
|
216
|
+
/**
|
|
217
|
+
* Builder for creating Nexus service definitions
|
|
218
|
+
*
|
|
219
|
+
* @template TService - A NexusServiceDefinition containing a record of operations
|
|
220
|
+
* @param definition - The Nexus service definition with typed operations
|
|
221
|
+
* @returns The same definition with preserved types
|
|
222
|
+
*
|
|
223
|
+
* @example
|
|
224
|
+
* ```typescript
|
|
225
|
+
* const PaymentService = defineNexusService({
|
|
226
|
+
* operations: {
|
|
227
|
+
* processPayment: defineNexusOperation({ ... }),
|
|
228
|
+
* refundPayment: defineNexusOperation({ ... }),
|
|
229
|
+
* },
|
|
230
|
+
* });
|
|
231
|
+
* ```
|
|
232
|
+
*/
|
|
233
|
+
function defineNexusService(definition) {
|
|
234
|
+
return definition;
|
|
235
|
+
}
|
|
236
|
+
/**
|
|
237
|
+
* USAGE EXAMPLE
|
|
238
|
+
*
|
|
239
|
+
* This example demonstrates the complete type-safe Nexus workflow:
|
|
240
|
+
*
|
|
241
|
+
* ```typescript
|
|
242
|
+
* import { defineContract, defineNexusService, defineNexusOperation } from '@temporal-contract/contract';
|
|
243
|
+
* import { z } from 'zod';
|
|
244
|
+
*
|
|
245
|
+
* // 1. Define contract with Nexus service
|
|
246
|
+
* const paymentContract = defineContract({
|
|
247
|
+
* taskQueue: 'payments',
|
|
248
|
+
* workflows: { ... },
|
|
249
|
+
* nexusServices: {
|
|
250
|
+
* PaymentService: defineNexusService({
|
|
251
|
+
* operations: {
|
|
252
|
+
* processPayment: defineNexusOperation({
|
|
253
|
+
* input: z.object({
|
|
254
|
+
* amount: z.number().positive(),
|
|
255
|
+
* customerId: z.string().uuid(),
|
|
256
|
+
* }),
|
|
257
|
+
* output: z.object({
|
|
258
|
+
* transactionId: z.string(),
|
|
259
|
+
* status: z.enum(['success', 'failed']),
|
|
260
|
+
* }),
|
|
261
|
+
* }),
|
|
262
|
+
* },
|
|
263
|
+
* }),
|
|
264
|
+
* },
|
|
265
|
+
* });
|
|
266
|
+
*
|
|
267
|
+
* // 2. Worker implementation (type-safe handlers)
|
|
268
|
+
* import { createNexusHandlers } from '@temporal-contract/worker';
|
|
269
|
+
*
|
|
270
|
+
* const nexusHandlers = createNexusHandlers(paymentContract, {
|
|
271
|
+
* PaymentService: {
|
|
272
|
+
* processPayment: async ({ amount, customerId }) => {
|
|
273
|
+
* // ✅ Fully typed parameters
|
|
274
|
+
* // ✅ Input automatically validated
|
|
275
|
+
* const payment = await processPaymentInDatabase(customerId, amount);
|
|
276
|
+
* // ✅ Return value validated against schema
|
|
277
|
+
* return {
|
|
278
|
+
* transactionId: payment.id,
|
|
279
|
+
* status: 'success',
|
|
280
|
+
* };
|
|
281
|
+
* },
|
|
282
|
+
* },
|
|
283
|
+
* });
|
|
284
|
+
*
|
|
285
|
+
* // 3. Client usage (type-safe invocation)
|
|
286
|
+
* import { createNexusClient } from '@temporal-contract/client';
|
|
287
|
+
*
|
|
288
|
+
* const nexusClient = createNexusClient<typeof paymentContract>(connection, {
|
|
289
|
+
* namespace: 'payments-ns',
|
|
290
|
+
* });
|
|
291
|
+
*
|
|
292
|
+
* // ✅ Fully typed invocation
|
|
293
|
+
* const result = await nexusClient.invoke('PaymentService', 'processPayment', {
|
|
294
|
+
* amount: 100,
|
|
295
|
+
* customerId: 'cust-123',
|
|
296
|
+
* });
|
|
297
|
+
*
|
|
298
|
+
* // ❌ TypeScript errors caught at compile time
|
|
299
|
+
* await nexusClient.invoke('PaymentService', 'processPayment', {
|
|
300
|
+
* amount: -50, // Error: amount must be positive
|
|
301
|
+
* customerId: 'invalid', // Error: customerId must be UUID
|
|
302
|
+
* });
|
|
303
|
+
* ```
|
|
304
|
+
*/
|
|
305
|
+
|
|
306
|
+
//#endregion
|
|
307
|
+
export { defineActivity, defineContract, defineNexusOperation, defineNexusService, defineQuery, defineSignal, defineUpdate, defineWorkflow };
|
package/package.json
CHANGED
|
@@ -1,8 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@temporal-contract/contract",
|
|
3
|
-
"version": "0.0.
|
|
4
|
-
"type": "module",
|
|
3
|
+
"version": "0.0.5",
|
|
5
4
|
"description": "Contract builder for temporal-contract",
|
|
5
|
+
"keywords": [
|
|
6
|
+
"contract",
|
|
7
|
+
"temporal",
|
|
8
|
+
"typescript"
|
|
9
|
+
],
|
|
6
10
|
"homepage": "https://github.com/btravers/temporal-contract#readme",
|
|
7
11
|
"bugs": {
|
|
8
12
|
"url": "https://github.com/btravers/temporal-contract/issues"
|
|
@@ -12,16 +16,9 @@
|
|
|
12
16
|
"url": "https://github.com/btravers/temporal-contract.git",
|
|
13
17
|
"directory": "packages/contract"
|
|
14
18
|
},
|
|
15
|
-
"author": "Benoit TRAVERS <benoit.travers.frgmail.com>",
|
|
16
19
|
"license": "MIT",
|
|
17
|
-
"
|
|
18
|
-
|
|
19
|
-
"typescript",
|
|
20
|
-
"contract"
|
|
21
|
-
],
|
|
22
|
-
"main": "./dist/index.cjs",
|
|
23
|
-
"module": "./dist/index.mjs",
|
|
24
|
-
"types": "./dist/index.d.mts",
|
|
20
|
+
"author": "Benoit TRAVERS <benoit.travers.frgmail.com>",
|
|
21
|
+
"type": "module",
|
|
25
22
|
"exports": {
|
|
26
23
|
".": {
|
|
27
24
|
"import": {
|
|
@@ -35,27 +32,30 @@
|
|
|
35
32
|
},
|
|
36
33
|
"./package.json": "./package.json"
|
|
37
34
|
},
|
|
35
|
+
"main": "./dist/index.cjs",
|
|
36
|
+
"module": "./dist/index.mjs",
|
|
37
|
+
"types": "./dist/index.d.mts",
|
|
38
38
|
"files": [
|
|
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
|
-
"dev": "tsdown src/index.ts --format cjs,esm --dts --watch",
|
|
56
55
|
"build": "tsdown src/index.ts --format cjs,esm --dts --clean",
|
|
57
|
-
"
|
|
56
|
+
"dev": "tsdown src/index.ts --format cjs,esm --dts --watch",
|
|
58
57
|
"test": "vitest run",
|
|
59
|
-
"test:watch": "vitest"
|
|
58
|
+
"test:watch": "vitest",
|
|
59
|
+
"typecheck": "tsc --noEmit"
|
|
60
60
|
}
|
|
61
61
|
}
|