From 16d95cfb73e1da9ec21270cf6a29fde3523dc0d2 Mon Sep 17 00:00:00 2001 From: "Yui T." Date: Mon, 9 Mar 2026 11:44:32 -0700 Subject: [PATCH 1/3] Ignore dist folder resulted from compiled typescript files --- .gitignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitignore b/.gitignore index 85c491c..453b3dc 100644 --- a/.gitignore +++ b/.gitignore @@ -4,3 +4,4 @@ uv.lock .venv **/node_modules +**/dist From da5e966b3cc377fdd572a6d108c61750e5116639 Mon Sep 17 00:00:00 2001 From: "Yui T." Date: Mon, 9 Mar 2026 11:58:24 -0700 Subject: [PATCH 2/3] Use type-only import statement so TypeScript will not emit corresponding import statement in JS. --- rest/nodejs/src/api/checkout.ts | 2 +- rest/nodejs/src/api/discovery.ts | 4 ++-- rest/nodejs/src/api/order.ts | 4 ++-- rest/nodejs/src/api/testing.ts | 2 +- rest/nodejs/src/data/transactions.ts | 2 +- rest/nodejs/src/utils/validation.ts | 2 +- 6 files changed, 8 insertions(+), 8 deletions(-) diff --git a/rest/nodejs/src/api/checkout.ts b/rest/nodejs/src/api/checkout.ts index 840b3d0..6a3325b 100644 --- a/rest/nodejs/src/api/checkout.ts +++ b/rest/nodejs/src/api/checkout.ts @@ -1,5 +1,5 @@ import { createHash } from "crypto"; -import { type Context } from "hono"; +import type { Context } from "hono"; import { v4 as uuidv4 } from "uuid"; import { z } from "zod"; diff --git a/rest/nodejs/src/api/discovery.ts b/rest/nodejs/src/api/discovery.ts index 14b992f..cbcd60e 100644 --- a/rest/nodejs/src/api/discovery.ts +++ b/rest/nodejs/src/api/discovery.ts @@ -1,5 +1,5 @@ -import { type Context } from "hono"; -import { type UcpDiscoveryProfile } from "../models"; +import type { Context } from "hono"; +import type { UcpDiscoveryProfile } from "../models"; /** * Service for handling UCP discovery requests. diff --git a/rest/nodejs/src/api/order.ts b/rest/nodejs/src/api/order.ts index a65f25c..eeffd53 100644 --- a/rest/nodejs/src/api/order.ts +++ b/rest/nodejs/src/api/order.ts @@ -1,6 +1,6 @@ -import { type Context } from "hono"; +import type { Context } from "hono"; import { getOrder, logRequest, saveOrder } from "../data"; -import { type Order } from "../models"; +import type { Order } from "../models"; /** * Service for managing orders. diff --git a/rest/nodejs/src/api/testing.ts b/rest/nodejs/src/api/testing.ts index 00b2144..f7c9ae2 100644 --- a/rest/nodejs/src/api/testing.ts +++ b/rest/nodejs/src/api/testing.ts @@ -1,4 +1,4 @@ -import { type Context } from "hono"; +import type { Context } from "hono"; import { CheckoutService } from "./checkout"; diff --git a/rest/nodejs/src/data/transactions.ts b/rest/nodejs/src/data/transactions.ts index c2369a8..e48d1b1 100644 --- a/rest/nodejs/src/data/transactions.ts +++ b/rest/nodejs/src/data/transactions.ts @@ -1,4 +1,4 @@ -import { type ExtendedCheckoutResponse, type Order } from "../models"; +import type { ExtendedCheckoutResponse, Order } from "../models"; import { getTransactionsDb } from "./db"; diff --git a/rest/nodejs/src/utils/validation.ts b/rest/nodejs/src/utils/validation.ts index 093d18a..b7a5426 100644 --- a/rest/nodejs/src/utils/validation.ts +++ b/rest/nodejs/src/utils/validation.ts @@ -1,4 +1,4 @@ -import { type Context } from "hono"; +import type { Context } from "hono"; import * as z from "zod"; /** From c94f16eac3d1c99d1e36d2ff0ae72691ef487f9a Mon Sep 17 00:00:00 2001 From: "Yui T." Date: Mon, 9 Mar 2026 12:00:49 -0700 Subject: [PATCH 3/3] Fix ERR_MODULE_NOT_FOUND. Provide mandatory file extension for ECMAScript module --- rest/nodejs/src/api/checkout.ts | 4 ++-- rest/nodejs/src/api/order.ts | 2 +- rest/nodejs/src/api/testing.ts | 2 +- rest/nodejs/src/data/index.ts | 8 ++++---- rest/nodejs/src/data/inventory.ts | 2 +- rest/nodejs/src/data/products.ts | 2 +- rest/nodejs/src/data/transactions.ts | 2 +- rest/nodejs/src/index.ts | 14 +++++++------- rest/nodejs/src/models/extensions.ts | 2 +- rest/nodejs/src/models/index.ts | 4 ++-- 10 files changed, 21 insertions(+), 21 deletions(-) diff --git a/rest/nodejs/src/api/checkout.ts b/rest/nodejs/src/api/checkout.ts index 6a3325b..a1dafaa 100644 --- a/rest/nodejs/src/api/checkout.ts +++ b/rest/nodejs/src/api/checkout.ts @@ -15,7 +15,7 @@ import { saveCheckout, saveIdempotencyRecord, saveOrder, -} from "../data"; +} from "../data/index.js"; import { CheckoutResponseStatusSchema, type Expectation, @@ -36,7 +36,7 @@ import { type PaymentCreateRequest, PaymentDataSchema, type PostalAddress, -} from "../models"; +} from "../models/index.js"; /** * Schema for the request body when completing a checkout session. diff --git a/rest/nodejs/src/api/order.ts b/rest/nodejs/src/api/order.ts index eeffd53..d55f028 100644 --- a/rest/nodejs/src/api/order.ts +++ b/rest/nodejs/src/api/order.ts @@ -1,5 +1,5 @@ import type { Context } from "hono"; -import { getOrder, logRequest, saveOrder } from "../data"; +import { getOrder, logRequest, saveOrder } from "../data/index.js"; import type { Order } from "../models"; /** diff --git a/rest/nodejs/src/api/testing.ts b/rest/nodejs/src/api/testing.ts index f7c9ae2..a850d77 100644 --- a/rest/nodejs/src/api/testing.ts +++ b/rest/nodejs/src/api/testing.ts @@ -1,6 +1,6 @@ import type { Context } from "hono"; -import { CheckoutService } from "./checkout"; +import { CheckoutService } from "./checkout.js"; export class TestingService { constructor(private readonly checkoutService: CheckoutService) {} diff --git a/rest/nodejs/src/data/index.ts b/rest/nodejs/src/data/index.ts index 4d5e042..ac57414 100644 --- a/rest/nodejs/src/data/index.ts +++ b/rest/nodejs/src/data/index.ts @@ -4,7 +4,7 @@ * transactions databases (SQLite). */ -export * from "./db"; -export * from "./inventory"; -export * from "./products"; -export * from "./transactions"; +export * from "./db.js"; +export * from "./inventory.js"; +export * from "./products.js"; +export * from "./transactions.js"; diff --git a/rest/nodejs/src/data/inventory.ts b/rest/nodejs/src/data/inventory.ts index d23d373..ca4b97c 100644 --- a/rest/nodejs/src/data/inventory.ts +++ b/rest/nodejs/src/data/inventory.ts @@ -1,4 +1,4 @@ -import { getTransactionsDb } from "./db"; +import { getTransactionsDb } from "./db.js"; /** * Retrieves the available inventory quantity for a given product. diff --git a/rest/nodejs/src/data/products.ts b/rest/nodejs/src/data/products.ts index f6c3623..5923896 100644 --- a/rest/nodejs/src/data/products.ts +++ b/rest/nodejs/src/data/products.ts @@ -1,4 +1,4 @@ -import { getProductsDb } from "./db"; +import { getProductsDb } from "./db.js"; /** * Represents a product in the catalog. diff --git a/rest/nodejs/src/data/transactions.ts b/rest/nodejs/src/data/transactions.ts index e48d1b1..17e3816 100644 --- a/rest/nodejs/src/data/transactions.ts +++ b/rest/nodejs/src/data/transactions.ts @@ -1,6 +1,6 @@ import type { ExtendedCheckoutResponse, Order } from "../models"; -import { getTransactionsDb } from "./db"; +import { getTransactionsDb } from "./db.js"; /** * Represents the structure of a checkout session stored in the database. diff --git a/rest/nodejs/src/index.ts b/rest/nodejs/src/index.ts index 7ffdf3d..8d03f9b 100644 --- a/rest/nodejs/src/index.ts +++ b/rest/nodejs/src/index.ts @@ -4,17 +4,17 @@ import { type Context, Hono } from "hono"; import { requestId } from "hono/request-id"; import { pinoHttp } from "pino-http"; -import { CheckoutService, zCompleteCheckoutRequest } from "./api/checkout"; -import { DiscoveryService } from "./api/discovery"; -import { OrderService } from "./api/order"; -import { TestingService } from "./api/testing"; -import { initDbs } from "./data/db"; +import { CheckoutService, zCompleteCheckoutRequest } from "./api/checkout.js"; +import { DiscoveryService } from "./api/discovery.js"; +import { OrderService } from "./api/order.js"; +import { TestingService } from "./api/testing.js"; +import { initDbs } from "./data/db.js"; import { ExtendedCheckoutCreateRequestSchema, ExtendedCheckoutUpdateRequestSchema, OrderSchema, -} from "./models"; -import { IdParamSchema, prettyValidation } from "./utils/validation"; +} from "./models/index.js"; +import { IdParamSchema, prettyValidation } from "./utils/validation.js"; const app = new Hono(); diff --git a/rest/nodejs/src/models/extensions.ts b/rest/nodejs/src/models/extensions.ts index 7c2b3f5..88eb037 100644 --- a/rest/nodejs/src/models/extensions.ts +++ b/rest/nodejs/src/models/extensions.ts @@ -11,7 +11,7 @@ import { FulfillmentDestinationResponseSchema, OrderSchema, PaymentCredentialSchema, -} from "./spec_generated"; +} from "./spec_generated.js"; export const ExtendedPaymentCredentialSchema = PaymentCredentialSchema.extend({ token: z.string().optional(), diff --git a/rest/nodejs/src/models/index.ts b/rest/nodejs/src/models/index.ts index 28e9880..8adad2d 100644 --- a/rest/nodejs/src/models/index.ts +++ b/rest/nodejs/src/models/index.ts @@ -1,2 +1,2 @@ -export * from "./extensions"; -export * from "./spec_generated"; +export * from "./extensions.js"; +export * from "./spec_generated.js";