Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/adopt-lefthook-oxfmt.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@temporal-contract/contract": patch
---

Enable oxfmt import sorting (the `.oxfmtrc.json` used a key oxfmt 0.58 dropped, so sorting was silently off) and adopt the shared `@btravstack/lefthook` hooks preset.
5 changes: 1 addition & 4 deletions .oxfmtrc.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
{
"$schema": "./node_modules/oxfmt/configuration_schema.json",
"ignorePatterns": ["pnpm-lock.yaml"],
"organizeImports": {
"sortImports": true,
"separateGroups": true
}
"sortImports": true
}
1 change: 1 addition & 0 deletions docs/.vitepress/theme/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import Theme from "@btravstack/theme";

import "./custom.css";

export default Theme;
1 change: 0 additions & 1 deletion docs/scripts/copy-docs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import "@temporal-contract/client";
import "@temporal-contract/contract";
import "@temporal-contract/testing/global-setup";
import "@temporal-contract/worker/activity";

import { cp, mkdir, rm } from "node:fs/promises";
import { dirname, join } from "node:path";
import { fileURLToPath } from "node:url";
Expand Down
7 changes: 4 additions & 3 deletions examples/order-processing-client/src/client.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
import { Client, Connection } from "@temporalio/client";
import { TypedClient } from "@temporal-contract/client";
import {
orderProcessingContract,
OrderSchema,
type OrderSchema,
} from "@temporal-contract/sample-order-processing-contract";
import type { z } from "zod";
import { Client, Connection } from "@temporalio/client";
import { matchTags } from "unthrown";
import type { z } from "zod";

import { logger } from "./logger.js";

type Order = z.infer<typeof OrderSchema>;
Expand Down
1 change: 1 addition & 0 deletions examples/order-processing-contract/src/contract.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { defineContract } from "@temporal-contract/contract";
import { z } from "zod";

import {
OrderSchema,
OrderItemSchema,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { fromPromise } from "unthrown";
import { declareActivitiesHandler, qualify } from "@temporal-contract/worker/activity";
import { orderProcessingContract } from "@temporal-contract/sample-order-processing-contract";
import { declareActivitiesHandler, qualify } from "@temporal-contract/worker/activity";
import { fromPromise } from "unthrown";

import {
sendNotificationUseCase,
processPaymentUseCase,
Expand Down
10 changes: 6 additions & 4 deletions examples/order-processing-worker/src/application/worker.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
import { NativeConnection } from "@temporalio/worker";
import { createWorker } from "@temporal-contract/worker/worker";
import { orderProcessingContract } from "@temporal-contract/sample-order-processing-contract";
import { extname } from "node:path";
import { fileURLToPath } from "node:url";
import { activities } from "./activities.js";

import { orderProcessingContract } from "@temporal-contract/sample-order-processing-contract";
import { createWorker } from "@temporal-contract/worker/worker";
import { NativeConnection } from "@temporalio/worker";

import { logger } from "../logger.js";
import { activities } from "./activities.js";

function workflowPath(filename: string): string {
return fileURLToPath(new URL(`./${filename}${extname(import.meta.url)}`, import.meta.url));
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { orderProcessingContract } from "@temporal-contract/sample-order-processing-contract";
import { declareWorkflow } from "@temporal-contract/worker/workflow";
import { isCancellation, log } from "@temporalio/workflow";
import { orderProcessingContract } from "@temporal-contract/sample-order-processing-contract";

/**
* Process Order Workflow Implementation
Expand Down
11 changes: 5 additions & 6 deletions examples/order-processing-worker/src/dependencies.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,19 +3,18 @@
* Centralizes the instantiation and wiring of all domain and infrastructure components
*/

import { CreateShipmentUseCase } from "./domain/usecases/create-shipment.usecase.js";
// Domain
import { ProcessPaymentUseCase } from "./domain/usecases/process-payment.usecase.js";
import { ReserveInventoryUseCase } from "./domain/usecases/reserve-inventory.usecase.js";
import { RefundPaymentUseCase } from "./domain/usecases/refund-payment.usecase.js";
import { ReleaseInventoryUseCase } from "./domain/usecases/release-inventory.usecase.js";
import { CreateShipmentUseCase } from "./domain/usecases/create-shipment.usecase.js";
import { ReserveInventoryUseCase } from "./domain/usecases/reserve-inventory.usecase.js";
import { SendNotificationUseCase } from "./domain/usecases/send-notification.usecase.js";
import { RefundPaymentUseCase } from "./domain/usecases/refund-payment.usecase.js";

import { MockInventoryAdapter } from "./infrastructure/adapters/inventory.adapter.js";
import { ConsoleNotificationAdapter } from "./infrastructure/adapters/notification.adapter.js";
// Infrastructure
import { MockPaymentAdapter } from "./infrastructure/adapters/payment.adapter.js";
import { MockInventoryAdapter } from "./infrastructure/adapters/inventory.adapter.js";
import { MockShippingAdapter } from "./infrastructure/adapters/shipping.adapter.js";
import { ConsoleNotificationAdapter } from "./infrastructure/adapters/notification.adapter.js";

// ============================================================================
// Adapters
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,13 @@
* The schemas themselves are defined in the contract package.
*/

import type { z } from "zod";
import {
OrderItemSchema,
PaymentResultSchema,
InventoryReservationSchema,
ShippingResultSchema,
type OrderItemSchema,
type PaymentResultSchema,
type InventoryReservationSchema,
type ShippingResultSchema,
} from "@temporal-contract/sample-order-processing-contract";
import type { z } from "zod";

export type OrderItem = z.infer<typeof OrderItemSchema>;
export type PaymentResult = z.infer<typeof PaymentResultSchema>;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import type { ShippingPort } from "../ports/shipping.port.js";
import type { ShippingResult } from "../entities/order.schema.js";
import type { ShippingPort } from "../ports/shipping.port.js";

/**
* Create Shipment Use Case
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import type { PaymentPort } from "../ports/payment.port.js";
import type { PaymentResult } from "../entities/order.schema.js";
import type { PaymentPort } from "../ports/payment.port.js";

/**
* Process Payment Use Case
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import type { InventoryPort } from "../ports/inventory.port.js";
import type { InventoryReservation, OrderItem } from "../entities/order.schema.js";
import type { InventoryPort } from "../ports/inventory.port.js";

/**
* Reserve Inventory Use Case
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import type { InventoryPort } from "../../domain/ports/inventory.port.js";
import type { InventoryReservation, OrderItem } from "../../domain/entities/order.schema.js";
import type { InventoryPort } from "../../domain/ports/inventory.port.js";
import { logger } from "../../logger.js";

/**
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import type { PaymentPort } from "../../domain/ports/payment.port.js";
import type { PaymentResult } from "../../domain/entities/order.schema.js";
import type { PaymentPort } from "../../domain/ports/payment.port.js";
import { logger } from "../../logger.js";

/**
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import type { ShippingPort } from "../../domain/ports/shipping.port.js";
import type { ShippingResult } from "../../domain/entities/order.schema.js";
import type { ShippingPort } from "../../domain/ports/shipping.port.js";
import { logger } from "../../logger.js";

/**
Expand Down
18 changes: 10 additions & 8 deletions examples/order-processing-worker/src/integration.spec.ts
Original file line number Diff line number Diff line change
@@ -1,17 +1,19 @@
import { describe, expect, vi, beforeEach } from "vitest";
import { Worker } from "@temporalio/worker";
import { extname } from "node:path";
import { fileURLToPath } from "node:url";

import { TypedClient, WorkflowValidationError } from "@temporal-contract/client";
import { it as baseIt } from "@temporal-contract/testing/extension";
import {
orderProcessingContract,
OrderSchema,
type OrderSchema,
} from "@temporal-contract/sample-order-processing-contract";
import { activities } from "./application/activities.js";
import { extname } from "node:path";
import { fileURLToPath } from "node:url";
import { it as baseIt } from "@temporal-contract/testing/extension";
import { Client } from "@temporalio/client";
import { Worker } from "@temporalio/worker";
import { describe, expect, vi, beforeEach } from "vitest";
import type { z } from "zod";

import { activities } from "./application/activities.js";
import { paymentAdapter } from "./dependencies.js";
import { Client } from "@temporalio/client";

type Order = z.infer<typeof OrderSchema>;

Expand Down
1 change: 1 addition & 0 deletions knip.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
"ignoreDependencies": [
"@btravstack/typedoc",
"@btravstack/oxlint",
"@btravstack/lefthook",
"typedoc-plugin-markdown",
"@changesets/config"
],
Expand Down
20 changes: 7 additions & 13 deletions lefthook.yml
Original file line number Diff line number Diff line change
@@ -1,16 +1,10 @@
# Shared hooks come from @btravstack/lefthook (format + lint + commit-msg).
extends:
- node_modules/@btravstack/lefthook/lefthook.yml

# Repo-specific excludes (the shared base sets none so they merge in here).
pre-commit:
parallel: true
commands:
format:
glob: "**/*.{ts,tsx,js,jsx,json,yaml,yml,md}"
exclude: "pnpm-lock.yaml"
run: pnpm oxfmt {staged_files}
stage_fixed: true
lint:
glob: "**/*.{ts,tsx,js,jsx}"
run: pnpm oxlint {staged_files}

commit-msg:
commands:
commitlint:
run: pnpm exec commitlint --edit {1}
exclude:
- "pnpm-lock.yaml"
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
},
"devDependencies": {
"@btravstack/commitlint": "catalog:",
"@btravstack/lefthook": "catalog:",
"@btravstack/oxlint": "catalog:",
"@changesets/cli": "catalog:",
"@commitlint/cli": "catalog:",
Expand Down
12 changes: 7 additions & 5 deletions packages/client/src/__tests__/client.spec.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
import { describe, expect, vi, beforeEach } from "vitest";
import { extname } from "node:path";
import { fileURLToPath } from "node:url";

import { it as baseIt } from "@temporal-contract/testing/extension";
import { Client } from "@temporalio/client";
import { Worker } from "@temporalio/worker";
import { describe, expect, vi, beforeEach } from "vitest";

import { TypedClient } from "../client.js";
import { WorkflowValidationError } from "../errors.js";
import { it as baseIt } from "@temporal-contract/testing/extension";
import { extname } from "node:path";
import { fileURLToPath } from "node:url";
import { testContract } from "./test.contract.js";
import { Client } from "@temporalio/client";

// ============================================================================
// Test Setup
Expand Down
29 changes: 15 additions & 14 deletions packages/client/src/client.spec.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,20 @@
import { defineContract, defineSearchAttribute, defineWorkflow } from "@temporal-contract/contract";
import { ContractError } from "@temporal-contract/contract/errors";
import {
type Client,
WorkflowExecutionAlreadyStartedError,
WorkflowFailedError as TemporalWorkflowFailedError,
} from "@temporalio/client";
import {
ApplicationFailure,
defineSearchAttributeKey,
TypedSearchAttributes,
WorkflowNotFoundError as TemporalWorkflowNotFoundError,
} from "@temporalio/common";
import { Err } from "unthrown";
import { describe, it, expect, vi, beforeEach } from "vitest";
import { z } from "zod";
import { defineContract, defineSearchAttribute, defineWorkflow } from "@temporal-contract/contract";

import { readTypedSearchAttributes, TypedClient } from "./client.js";
import {
QueryValidationError,
Expand All @@ -13,19 +27,6 @@ import {
WorkflowNotFoundError,
WorkflowValidationError,
} from "./errors.js";
import {
Client,
WorkflowExecutionAlreadyStartedError,
WorkflowFailedError as TemporalWorkflowFailedError,
} from "@temporalio/client";
import {
ApplicationFailure,
defineSearchAttributeKey,
TypedSearchAttributes,
WorkflowNotFoundError as TemporalWorkflowNotFoundError,
} from "@temporalio/common";
import { ContractError } from "@temporal-contract/contract/errors";
import { Err } from "unthrown";
import type { ClientInterceptor } from "./interceptors.js";

// Create mock workflow object
Expand Down
41 changes: 21 additions & 20 deletions packages/client/src/client.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
import { Client, WorkflowHandle } from "@temporalio/client";
import type { WorkflowSignalWithStartOptions, WorkflowStartOptions } from "@temporalio/client";
import { defineSearchAttributeKey, TypedSearchAttributes } from "@temporalio/common";
import type { StandardSchemaV1 } from "@standard-schema/spec";
import type {
AnyWorkflowDefinition,
Expand All @@ -12,20 +9,14 @@ import type {
SignalNamesOf,
} from "@temporal-contract/contract";
import { TechnicalError, type ContractErrorUnion } from "@temporal-contract/contract/errors";
import {
chainInterceptors,
type ClientCallError,
type ClientInterceptor,
type ClientInterceptorArgs,
} from "./interceptors.js";
import type {
ClientInferInput,
ClientInferOutput,
ClientInferWorkflowQueries,
ClientInferWorkflowSignals,
ClientInferWorkflowUpdates,
} from "./types.js";
import { type Client, type WorkflowHandle } from "@temporalio/client";
import type { WorkflowSignalWithStartOptions, WorkflowStartOptions } from "@temporalio/client";
import { WorkflowExecutionAlreadyStartedError } from "@temporalio/client";
import { WorkflowFailedError as TemporalWorkflowFailedError } from "@temporalio/client";
import { defineSearchAttributeKey, type TypedSearchAttributes } from "@temporalio/common";
import { WorkflowNotFoundError as TemporalWorkflowNotFoundError } from "@temporalio/common";
import { type AsyncResult, type Result, Ok, Err, fromPromise } from "unthrown";

import {
type TemporalFailure,
WorkflowAlreadyStartedError,
Expand All @@ -38,7 +29,12 @@ import {
UpdateValidationError,
RuntimeClientError,
} from "./errors.js";
import { TypedScheduleClient } from "./schedule.js";
import {
chainInterceptors,
type ClientCallError,
type ClientInterceptor,
type ClientInterceptorArgs,
} from "./interceptors.js";
import {
assertNoDefect,
classifyHandleError,
Expand All @@ -48,9 +44,14 @@ import {
rehydrateWorkflowContractError,
toTypedSearchAttributes,
} from "./internal.js";
import { WorkflowExecutionAlreadyStartedError } from "@temporalio/client";
import { WorkflowFailedError as TemporalWorkflowFailedError } from "@temporalio/client";
import { WorkflowNotFoundError as TemporalWorkflowNotFoundError } from "@temporalio/common";
import { TypedScheduleClient } from "./schedule.js";
import type {
ClientInferInput,
ClientInferOutput,
ClientInferWorkflowQueries,
ClientInferWorkflowSignals,
ClientInferWorkflowUpdates,
} from "./types.js";

/**
* Typed `searchAttributes` map for a workflow, derived from the workflow's
Expand Down
Loading
Loading