@temporal-contract/contract 0.0.2 → 0.0.4

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.mjs CHANGED
@@ -190,4 +190,118 @@ const defineContract = (definition) => {
190
190
  };
191
191
 
192
192
  //#endregion
193
- export { defineActivity, defineContract, defineQuery, defineSignal, defineUpdate, defineWorkflow };
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.2",
4
- "type": "module",
3
+ "version": "0.0.4",
5
4
  "description": "Contract builder for temporal-contract",
5
+ "keywords": [
6
+ "temporal",
7
+ "typescript",
8
+ "contract"
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
- "keywords": [
18
- "temporal",
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,6 +32,12 @@
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
+ "files": [
39
+ "dist"
40
+ ],
38
41
  "dependencies": {
39
42
  "@standard-schema/spec": "1.0.0",
40
43
  "zod": "4.1.13"
@@ -42,17 +45,17 @@
42
45
  "devDependencies": {
43
46
  "@vitest/coverage-v8": "4.0.15",
44
47
  "arktype": "2.1.28",
45
- "tsdown": "0.17.2",
48
+ "tsdown": "0.17.3",
46
49
  "typescript": "5.9.3",
47
50
  "valibot": "1.2.0",
48
51
  "vitest": "4.0.15",
49
- "@temporal-contract/tsconfig": "0.0.2"
52
+ "@temporal-contract/tsconfig": "0.0.4"
50
53
  },
51
54
  "scripts": {
52
- "dev": "tsdown src/index.ts --format cjs,esm --dts --watch",
53
55
  "build": "tsdown src/index.ts --format cjs,esm --dts --clean",
54
- "typecheck": "tsc --noEmit",
56
+ "dev": "tsdown src/index.ts --format cjs,esm --dts --watch",
55
57
  "test": "vitest run",
56
- "test:watch": "vitest"
58
+ "test:watch": "vitest",
59
+ "typecheck": "tsc --noEmit"
57
60
  }
58
61
  }
@@ -1,17 +0,0 @@
1
-
2
- > @temporal-contract/contract@0.0.2 build /home/runner/work/temporal-contract/temporal-contract/packages/contract
3
- > tsdown src/index.ts --format cjs,esm --dts --clean
4
-
5
- ℹ tsdown v0.17.2 powered by rolldown v1.0.0-beta.53
6
- ℹ entry: src/index.ts
7
- ℹ tsconfig: tsconfig.json
8
- ℹ Build start
9
- ℹ [CJS] dist/index.cjs 6.97 kB │ gzip: 1.69 kB
10
- ℹ [CJS] 1 files, total: 6.97 kB
11
- ℹ [CJS] dist/index.d.cts 15.66 kB │ gzip: 2.56 kB
12
- ℹ [CJS] 1 files, total: 15.66 kB
13
- ✔ Build complete in 1491ms
14
- ℹ [ESM] dist/index.mjs  6.74 kB │ gzip: 1.67 kB
15
- ℹ [ESM] dist/index.d.mts 15.66 kB │ gzip: 2.56 kB
16
- ℹ [ESM] 2 files, total: 22.40 kB
17
- ✔ Build complete in 1492ms
package/CHANGELOG.md DELETED
@@ -1,7 +0,0 @@
1
- # @temporal-contract/contract
2
-
3
- ## 0.0.2
4
-
5
- ### Patch Changes
6
-
7
- - Release version 0.0.2