tempest-express-sdk 0.22.0 → 0.23.0

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/README.md CHANGED
@@ -47,7 +47,7 @@ with `npm ls zod`: a single line, marked `deduped`.
47
47
  | **server utils** | `TOTPHelper` (MFA), `HTTPClient` (retry + circuit breaker), `MetricsUtils` (+ Prometheus, GPU), `makeMetricsRouter`, `getClientIp` |
48
48
  | **integrations** | `MessagingProvider` contract; `WhatsAppProvider` (zap-api), `TelegramProvider` (Bot API), `TwilioSmsProvider` (SMS), `EmailProvider`, `MessagingHub` + `broadcastText`, webhook receivers |
49
49
  | **admin** | `AdminSite` + `makeAdminRouter` — JSON admin with auto-derived CRUD + introspection |
50
- | **api** | `createApp`, `runServer`, `registerExceptionHandlers`, `createOpenApiRegistry`, `generateOpenApiDocument`, `mountSwaggerUi`, `mountRedoc`, `makeHealthRouter` |
50
+ | **api** | `createApp`, `runServer`, `registerExceptionHandlers`, `createOpenApiRegistry`, `generateOpenApiDocument`, `mountSwaggerUi` (configurable via `ui`), `mountRedoc` (both ship a favicon; Redoc serves its bundle locally when the optional `redoc` peer is installed), `makeHealthRouter` |
51
51
  | **api/middlewares** | `rateLimitMiddleware` (memory/Redis stores, IP/header/JWT keys), `bodySizeLimitMiddleware`, `csrfMiddleware`, `idempotencyMiddleware` (memory/Redis), `GracefulShutdown`, `requestTracingMiddleware`, `prometheusMiddleware` / `HttpMetrics` |
52
52
  | **api/oauth** | `GoogleOAuthClient`, `GitHubOAuthClient`, `OIDCProvider`, `generateOAuthState`; `WebhookSignatureVerifier`; `makeToolSpecRouter` |
53
53
  | **testing** | `createTestDatabase`, `withTestDatabase` — in-memory SQLite engine with tables reflected from your models |
@@ -129,8 +129,8 @@ var PasswordUtils = class {
129
129
  };
130
130
 
131
131
  // src/version.ts
132
- var VERSION = "0.22.0";
132
+ var VERSION = "0.23.0";
133
133
 
134
134
  export { PasswordUtils, VERSION, baseAppSettingsSchema, baseAppSettingsShape, baseResponseSchema, centsField, corsSettingsShape, databaseSettingsShape, hexColorField, latitudeField, loadSettings, longitudeField, looseBoolean, nonEmptyStrField, nonNegativeFloatField, nonNegativeIntField, percentField, portField, positiveFloatField, positiveIntField, priceField, ratingField, ratioField, serverSettingsShape, slugField, toDict };
135
- //# sourceMappingURL=chunk-7Q5NBMSP.js.map
136
- //# sourceMappingURL=chunk-7Q5NBMSP.js.map
135
+ //# sourceMappingURL=chunk-HC3TIN4M.js.map
136
+ //# sourceMappingURL=chunk-HC3TIN4M.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/schemas/base.ts","../src/schemas/fields.ts","../src/settings/base.ts","../src/utils/password.ts","../src/version.ts"],"names":[],"mappings":";;;;;AAcA,oBAAA,CAAqB,CAAC,CAAA;AAoBf,SAAS,MAAA,CACd,IAAA,EACA,OAAA,GAAyB,EAAC,EACD;AACzB,EAAA,MAAM,UAAU,IAAI,GAAA,CAAI,OAAA,CAAQ,OAAA,IAAW,EAAE,CAAA;AAC7C,EAAA,MAAM,MAA+B,EAAC;AACtC,EAAA,KAAA,MAAW,CAAC,GAAA,EAAK,KAAK,KAAK,MAAA,CAAO,OAAA,CAAQ,IAAI,CAAA,EAAG;AAC/C,IAAA,IAAI,OAAA,CAAQ,GAAA,CAAI,GAAG,CAAA,EAAG;AACtB,IAAA,IAAI,KAAA,KAAU,IAAA,IAAQ,KAAA,KAAU,MAAA,EAAW;AAC3C,IAAA,GAAA,CAAI,GAAG,CAAA,GAAI,KAAA;AAAA,EACb;AACA,EAAA,OAAO,EAAE,GAAG,GAAA,EAAK,GAAI,OAAA,CAAQ,OAAA,IAAW,EAAC,EAAG;AAC9C;AAOO,IAAM,kBAAA,GAAqB,EAAE,MAAA,CAAO;AAAA,EACzC,EAAA,EAAI,EAAE,IAAA,EAAK,CAAE,QAAQ,EAAE,WAAA,EAAa,wCAAwC,CAAA;AAAA,EAC5E,QAAA,EAAU,EACP,OAAA,EAAQ,CACR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AAAA;AAAA;AAAA;AAAA,EAQ7B,MAAM,KAAK,KAAA,EAAgC;AACzC,IAAA,MAAM,MAAA,GAAS,MAAM,UAAA,EAAW;AAChC,IAAA,MAAM,IAAA,GAAO,MAAM,MAAA,CAAO,OAAA,CAAQ,KAAK,MAAM,CAAA;AAC7C,IAAA,OAAO,MAAA,CAAO,IAAA,CAAK,KAAA,EAAO,IAAI,CAAA;AAAA,EAChC;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAUA,MAAM,MAAA,CAAO,KAAA,EAAe,MAAA,EAAkC;AAC5D,IAAA,IAAI;AACF,MAAA,MAAM,MAAA,GAAS,MAAM,UAAA,EAAW;AAChC,MAAA,OAAO,MAAM,MAAA,CAAO,OAAA,CAAQ,KAAA,EAAO,MAAM,CAAA;AAAA,IAC3C,CAAA,CAAA,MAAQ;AACN,MAAA,OAAO,KAAA;AAAA,IACT;AAAA,EACF;AACF;;;AC/DO,IAAM,OAAA,GAAU","file":"chunk-HC3TIN4M.js","sourcesContent":["/**\n * Zod foundation shared by every DTO, mirroring `schemas.base.BaseSchema`.\n *\n * Pydantic uses class inheritance for shared config; Zod composes instead. This\n * module re-exports a `z` already augmented with `.openapi()` (so every schema\n * can carry OpenAPI metadata) and a {@link toDict} helper matching\n * `BaseSchema.to_dict` (drop nullish, exclude keys, merge extras).\n */\n\nimport { extendZodWithOpenApi } from \"@asteasolutions/zod-to-openapi\";\nimport { z } from \"zod\";\n\n// Augment the shared `z` instance with `.openapi(...)`. Idempotent — calling it\n// more than once across modules is safe.\nextendZodWithOpenApi(z);\n\nexport { z };\n\n/** Options for {@link toDict}. */\nexport interface ToDictOptions {\n /** Field names to drop from the output. */\n exclude?: string[];\n /** Extra entries merged on top (override existing keys). */\n include?: Record<string, unknown>;\n}\n\n/**\n * Serialize a validated object to a plain record, dropping `null`/`undefined`,\n * removing `exclude`d keys and merging `include` on top.\n *\n * @param data - The source object (typically a parsed schema).\n * @param options - Keys to exclude and entries to merge in.\n * @returns The cleaned record.\n */\nexport function toDict(\n data: Record<string, unknown>,\n options: ToDictOptions = {},\n): Record<string, unknown> {\n const exclude = new Set(options.exclude ?? []);\n const out: Record<string, unknown> = {};\n for (const [key, value] of Object.entries(data)) {\n if (exclude.has(key)) continue;\n if (value === null || value === undefined) continue;\n out[key] = value;\n }\n return { ...out, ...(options.include ?? {}) };\n}\n\n/**\n * Response schema fields every ORM record carries (`id`, `isActive`,\n * `createdAt`, `updatedAt`). Mirrors `BaseResponseSchema`. Extend it with\n * `baseResponseSchema.extend({ ... })` to build concrete `*ResponseSchema`s.\n */\nexport const baseResponseSchema = z.object({\n id: z.uuid().openapi({ description: \"The unique identifier of the record.\" }),\n isActive: z\n .boolean()\n .openapi({ description: \"Whether the record is active (soft-delete flag).\" }),\n createdAt: z.coerce\n .date()\n .openapi({ description: \"The creation timestamp of the record (UTC).\" }),\n updatedAt: z.coerce\n .date()\n .openapi({ description: \"The last update timestamp of the record (UTC).\" }),\n});\n\n/** The inferred TS type of a {@link baseResponseSchema} payload. */\nexport type BaseResponse = z.infer<typeof baseResponseSchema>;\n","/**\n * Ready-made, validated Zod field types, mirroring `utils.fields`.\n *\n * Reusable building blocks for DTOs so you don't re-derive the same constraint\n * everywhere: money in cents, a price string, a percentage, a latitude, a slug,\n * a hex color. Compose them into schemas with `z.object({ price: priceField })`.\n */\n\nimport { z } from \"@/schemas/base\";\n\n// --- Integers ---------------------------------------------------------------\n\n/** A strictly positive integer (`> 0`). */\nexport const positiveIntField = z.number().int().positive();\n/** A non-negative integer (`>= 0`). */\nexport const nonNegativeIntField = z.number().int().min(0);\n/** A monetary amount in the smallest unit (cents), `>= 0`. Avoids float drift. */\nexport const centsField = z.number().int().min(0);\n/** A TCP port (`1..65535`). */\nexport const portField = z.number().int().min(1).max(65535);\n/** A 0–5 star rating. */\nexport const ratingField = z.number().int().min(0).max(5);\n\n// --- Floats -----------------------------------------------------------------\n\n/** A strictly positive float (`> 0`). */\nexport const positiveFloatField = z.number().positive();\n/** A non-negative float (`>= 0`). */\nexport const nonNegativeFloatField = z.number().min(0);\n/** A percentage (`0..100`). */\nexport const percentField = z.number().min(0).max(100);\n/** A ratio (`0..1`). */\nexport const ratioField = z.number().min(0).max(1);\n/** A WGS-84 latitude (`-90..90`). */\nexport const latitudeField = z.number().min(-90).max(90);\n/** A WGS-84 longitude (`-180..180`). */\nexport const longitudeField = z.number().min(-180).max(180);\n\n// --- Strings ----------------------------------------------------------------\n\n/** A non-empty string; whitespace is trimmed before the length check. */\nexport const nonEmptyStrField = z\n .string()\n .transform((value) => value.trim())\n .pipe(z.string().min(1));\n\n/** A URL slug: lowercase alphanumerics separated by single hyphens. */\nexport const slugField = z.string().regex(/^[a-z0-9]+(?:-[a-z0-9]+)*$/, {\n message: \"Must be a lowercase hyphen-separated slug.\",\n});\n\n/** A hex color: `#rgb` or `#rrggbb`. */\nexport const hexColorField = z.string().regex(/^#(?:[0-9a-fA-F]{3}|[0-9a-fA-F]{6})$/, {\n message: \"Must be a #rgb or #rrggbb hex color.\",\n});\n\n/**\n * A money amount as an exact decimal **string** with up to two decimal places\n * (e.g. `\"19.90\"`). Mirrors `PriceField` — `tempest-db-js` `numeric` columns map\n * to strings, so money stays exact instead of drifting through a float.\n */\nexport const priceField = z.string().regex(/^\\d+(?:\\.\\d{1,2})?$/, {\n message: 'Must be a decimal money string, e.g. \"19.90\".',\n});\n\n// --- Booleans ---------------------------------------------------------------\n\n/** Message shown when a value is neither a boolean nor a boolean-ish token. */\nconst LOOSE_BOOLEAN_ERROR =\n 'Must be a boolean value such as \"true\", \"false\", \"1\", \"0\", \"yes\" or \"no\".';\n\n/**\n * A boolean read from a **textual** source — a query string or an environment\n * variable, where every value arrives as a string.\n *\n * `z.coerce.boolean()` is the wrong tool for those: it is `Boolean(input)`, so\n * every non-empty string is `true` — `\"false\"` and `\"0\"` included — and there is\n * no way to ask for `false` over the wire. This reads the usual textual tokens\n * in both directions (`true`/`1`/`yes`/`on`/`y`/`enabled` and\n * `false`/`0`/`no`/`off`/`n`/`disabled`, case-insensitive, surrounding\n * whitespace trimmed) and **rejects** anything else, so a typo surfaces as a\n * validation error instead of silently becoming `false`.\n *\n * An absent value — and an empty or whitespace-only string, which is how an\n * unset `.env` entry (`DEBUG=`) reaches the schema — falls back to\n * `defaultValue`. Real booleans pass through untouched, so a schema built for\n * `process.env` still parses a synthetic object in tests.\n *\n * The OpenAPI metadata is pinned to `type: boolean` (with the default) so the\n * document describes the field the client actually sends, not the union used to\n * parse it.\n *\n * @param defaultValue - The value used when the field is absent or empty.\n * @returns A zod schema producing a `boolean`.\n */\nexport function looseBoolean(defaultValue: boolean) {\n return z\n .preprocess(\n (value) => (typeof value === \"string\" ? value.trim() || undefined : value),\n z\n .union([z.boolean(), z.stringbool()], { error: LOOSE_BOOLEAN_ERROR })\n .default(defaultValue),\n )\n .openapi({ type: \"boolean\", default: defaultValue });\n}\n","/**\n * Environment-driven settings, mirroring `settings.base.BaseAppSettings`.\n *\n * Pydantic-settings reads env vars into a frozen, validated model. Here a zod\n * schema plays the same role: {@link loadSettings} parses `process.env` (env\n * names are matched case-sensitively, like the FastAPI SDK) and returns a\n * frozen, fully-typed object. Composable fragments ({@link serverSettingsShape}\n * etc.) cover the common server/database/CORS knobs.\n */\n\nimport { z } from \"@/schemas/base\";\nimport { looseBoolean } from \"@/schemas/fields\";\n\n/** Server bind/runtime settings. Defaults bind to localhost. */\nexport const serverSettingsShape = {\n HOST: z.string().default(\"127.0.0.1\"),\n PORT: z.coerce.number().int().min(0).max(65535).default(8000),\n DEBUG: looseBoolean(false),\n} as const;\n\n/** Database connection settings. */\nexport const databaseSettingsShape = {\n DATABASE_URL: z.string().default(\"sqlite://./app.db\"),\n} as const;\n\n/** CORS settings. `CORS_ORIGINS` is a comma-separated list. */\nexport const corsSettingsShape = {\n CORS_ORIGINS: z\n .string()\n .default(\"*\")\n .transform((value) =>\n value\n .split(\",\")\n .map((origin) => origin.trim())\n .filter((origin) => origin.length > 0),\n ),\n} as const;\n\n/** The combined base settings shape (server + database + CORS). */\nexport const baseAppSettingsShape = {\n ...serverSettingsShape,\n ...databaseSettingsShape,\n ...corsSettingsShape,\n} as const;\n\n/** A zod object built from {@link baseAppSettingsShape}. */\nexport const baseAppSettingsSchema = z.object(baseAppSettingsShape);\n\n/** The parsed shape of {@link baseAppSettingsSchema}. */\nexport type BaseAppSettings = z.infer<typeof baseAppSettingsSchema>;\n\n/**\n * Parse and freeze settings from an environment source.\n *\n * Extend the base shape with project fields:\n *\n * ```ts\n * const settings = loadSettings(\n * z.object({ ...baseAppSettingsShape, JWT_SECRET: z.string() }),\n * );\n * ```\n *\n * @param schema - The settings zod schema.\n * @param env - The environment source (defaults to `process.env`).\n * @returns The validated, frozen settings object.\n * @throws {z.ZodError} When required env vars are missing or malformed.\n */\nexport function loadSettings<S extends z.ZodType>(\n schema: S,\n env: NodeJS.ProcessEnv = process.env,\n): Readonly<z.infer<S>> {\n return Object.freeze(schema.parse(env));\n}\n","/**\n * Password hashing backed by bcrypt, mirroring `utils.password.PasswordUtils`.\n *\n * `bcryptjs` is an optional peer dependency, imported lazily so that\n * `import \"tempest-express-sdk\"` keeps working when it is not installed — the\n * clear error is deferred to first use. Methods are async (the idiomatic Node\n * bcrypt surface).\n */\n\ntype BcryptModule = typeof import(\"bcryptjs\");\n\nlet cached: BcryptModule | null = null;\n\n/** Lazily load `bcryptjs`, with a clear install hint when missing. */\nasync function loadBcrypt(): Promise<BcryptModule> {\n if (cached) return cached;\n try {\n const mod = (await import(\"bcryptjs\")) as BcryptModule & { default?: BcryptModule };\n cached = mod.default ?? mod;\n } catch (cause) {\n throw new Error(\n \"PasswordUtils requires the 'bcryptjs' peer dependency. Install with `npm i bcryptjs`.\",\n { cause },\n );\n }\n return cached;\n}\n\n/** Hash and verify passwords using bcrypt. Stateless — construct once, reuse. */\nexport class PasswordUtils {\n /**\n * @param rounds - The bcrypt cost factor. Higher is slower and harder to\n * brute-force. Defaults to 12.\n */\n constructor(private readonly rounds: number = 12) {}\n\n /**\n * Hash a plaintext password.\n *\n * @param plain - The plaintext password.\n * @returns The bcrypt hash, ready to persist.\n */\n async hash(plain: string): Promise<string> {\n const bcrypt = await loadBcrypt();\n const salt = await bcrypt.genSalt(this.rounds);\n return bcrypt.hash(plain, salt);\n }\n\n /**\n * Verify a plaintext password against a stored hash. Returns `false` for\n * malformed hashes rather than throwing.\n *\n * @param plain - The plaintext password to verify.\n * @param hashed - The previously stored bcrypt hash.\n * @returns `true` when the password matches.\n */\n async verify(plain: string, hashed: string): Promise<boolean> {\n try {\n const bcrypt = await loadBcrypt();\n return await bcrypt.compare(plain, hashed);\n } catch {\n return false;\n }\n }\n}\n","/** The installed SDK version. Single source of truth for the barrel + CLI. */\nexport const VERSION = \"0.23.0\";\n"]}
package/dist/cli.cjs CHANGED
@@ -11,7 +11,7 @@ var zodToOpenapi = require('@asteasolutions/zod-to-openapi');
11
11
  var zod = require('zod');
12
12
 
13
13
  // src/version.ts
14
- var VERSION = "0.22.0";
14
+ var VERSION = "0.23.0";
15
15
 
16
16
  // src/cli/template.ts
17
17
  var SDK_VERSION = `^${VERSION}`;
package/dist/cli.cjs.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/version.ts","../src/cli/template.ts","../src/schemas/base.ts","../src/schemas/fields.ts","../src/settings/base.ts","../src/utils/password.ts","../src/cli/index.ts"],"names":["extendZodWithOpenApi","z","existsSync","readFileSync","join","mkdir","dirname","writeFile","resolve","parseArgs","randomBytes","spawnSync","randomUUID"],"mappings":";;;;;;;;;;;;;AACO,IAAM,OAAA,GAAU,QAAA;;;ACiBvB,IAAM,WAAA,GAAc,IAAI,OAAO,CAAA,CAAA;AAQxB,SAAS,aAAa,IAAA,EAAsC;AACjE,EAAA,OAAO;AAAA,IACL,cAAA,EAAgB,GAAG,IAAA,CAAK,SAAA;AAAA,MACtB;AAAA,QACE,IAAA;AAAA,QACA,OAAA,EAAS,OAAA;AAAA,QACT,OAAA,EAAS,IAAA;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IAAA,CAAK,CAAC,IAAA,KAAS;AACd,IAAA,OAAA,CAAQ,QAAA,GAAW,IAAA;AAAA,EACrB,CAAC,CAAA,CACA,KAAA,CAAM,CAAC,KAAA,KAAmB;AACzB,IAAA,MAAM,UAAU,KAAA,YAAiB,KAAA,GAAQ,KAAA,CAAM,OAAA,GAAU,OAAO,KAAK,CAAA;AACrE,IAAA,OAAA,CAAQ,MAAA,CAAO,KAAA,CAAM,CAAA,OAAA,EAAU,OAAO;AAAA,CAAI,CAAA;AAC1C,IAAA,OAAA,CAAQ,QAAA,GAAW,CAAA;AAAA,EACrB,CAAC,CAAA;AACL","file":"cli.cjs","sourcesContent":["/** The installed SDK version. Single source of truth for the barrel + CLI. */\nexport const VERSION = \"0.22.0\";\n","/**\n * Project-template generator for the `new` command, mirroring `cli.new`.\n *\n * Produces a complete, runnable Express service that follows the SDK's layered\n * architecture (router → controller → service → repository → model) and is\n * pre-wired with `createApp`, native Swagger + Redoc, Zod validation, and a\n * `tempest-db-js` model. {@link projectFiles} returns a `path → contents` map\n * the CLI writes to disk.\n */\n\nimport { VERSION } from \"@/version\";\n\n/**\n * Caret range for the SDK the generated project depends on. Derived from\n * {@link VERSION} so a release bump can never leave the scaffold pinned to an\n * older major/minor — a stale pin here would install a different SDK (and, with\n * it, a different `zod` peer range) than the CLI that wrote the project.\n */\nconst SDK_VERSION = `^${VERSION}`;\n\n/**\n * Build the file map for a new service named `name`.\n *\n * @param name - The project (and package) name.\n * @returns A map of relative file path to file contents.\n */\nexport function projectFiles(name: string): Record<string, string> {\n return {\n \"package.json\": `${JSON.stringify(\n {\n name,\n version: \"0.1.0\",\n private: true,\n type: \"module\",\n scripts: {\n dev: \"tsx watch main.ts\",\n start: \"tsx main.ts\",\n build: \"tsc -p tsconfig.json\",\n typecheck: \"tsc --noEmit\",\n },\n dependencies: {\n express: \"^5.1.0\",\n \"tempest-db-js\": \"^0.4.0\",\n \"tempest-express-sdk\": SDK_VERSION,\n zod: \"^4.0.0\",\n },\n devDependencies: {\n \"@types/express\": \"^5.0.0\",\n \"@types/node\": \"^22.10.0\",\n tsx: \"^4.19.2\",\n typescript: \"^5.7.0\",\n },\n },\n null,\n 2,\n )}\\n`,\n\n \"tsconfig.json\": `${JSON.stringify(\n {\n compilerOptions: {\n target: \"ES2022\",\n module: \"ESNext\",\n moduleResolution: \"Bundler\",\n lib: [\"ES2022\"],\n strict: true,\n noUncheckedIndexedAccess: true,\n verbatimModuleSyntax: true,\n esModuleInterop: true,\n skipLibCheck: true,\n forceConsistentCasingInFileNames: true,\n outDir: \"dist\",\n paths: { \"@/*\": [\"./src/*\"] },\n },\n include: [\"src\", \"main.ts\"],\n },\n null,\n 2,\n )}\\n`,\n\n \".gitignore\": \"node_modules\\ndist\\n.env\\n*.log\\n\",\n\n \".env.example\":\n \"HOST=127.0.0.1\\nPORT=8000\\nDEBUG=false\\nDATABASE_URL=sqlite://./app.db\\nCORS_ORIGINS=*\\n\",\n\n \"main.ts\": `import { run } from \"@/index\";\n\nrun();\n`,\n\n \"src/index.ts\": `import { run } from \"@/server\";\n\nexport { run };\n`,\n\n \"src/core/settings.ts\": `import { baseAppSettingsShape, loadSettings, z } from \"tempest-express-sdk\";\n\n/** Application settings — extend the SDK base shape with project fields. */\nexport const settingsSchema = z.object({\n ...baseAppSettingsShape,\n});\n\nexport const settings = loadSettings(settingsSchema);\n`,\n\n \"src/db/models/itemModel.ts\": `import { BaseModel, column, tableNameFor } from \"tempest-express-sdk\";\n\n/** A sample domain model. Replace with your own. */\nexport class ItemModel extends BaseModel {\n static tablename = tableNameFor(\"ItemModel\");\n name = column.text().notNull();\n price = column.integer().notNull();\n}\n`,\n\n \"src/schemas/item.ts\": `import { baseResponseSchema, z } from \"tempest-express-sdk\";\n\n/** Request payload to create an item. */\nexport const itemCreateSchema = z\n .object({\n name: z.string().min(1).openapi({ description: \"The item name.\" }),\n price: z.number().int().min(0).openapi({ description: \"Price in cents.\" }),\n })\n .openapi(\"ItemCreate\");\n\n/** Response payload for an item (base columns + domain fields). */\nexport const itemResponseSchema = baseResponseSchema\n .extend({\n name: z.string(),\n price: z.number().int(),\n })\n .openapi(\"Item\");\n\nexport type ItemCreate = z.infer<typeof itemCreateSchema>;\nexport type ItemResponse = z.infer<typeof itemResponseSchema>;\n`,\n\n \"src/db/repositories/itemRepository.ts\": `import { type AsyncSession, BaseRepository } from \"tempest-express-sdk\";\nimport { ItemModel } from \"@/db/models/itemModel\";\n\n/** Data-access layer for items. */\nexport class ItemRepository extends BaseRepository<typeof ItemModel> {\n constructor(session: AsyncSession) {\n super(ItemModel, session);\n }\n}\n`,\n\n \"src/services/itemService.ts\": `import { BaseService } from \"tempest-express-sdk\";\nimport type { ItemRepository } from \"@/db/repositories/itemRepository\";\nimport type { ItemModel } from \"@/db/models/itemModel\";\nimport type { ItemResponse } from \"@/schemas/item\";\n\n/** Business logic for items. Maps raw rows to the response shape. */\nexport class ItemService extends BaseService<typeof ItemModel, ItemResponse> {\n constructor(repository: ItemRepository) {\n super(repository, (row) => ({\n id: row.id,\n isActive: row.isActive,\n createdAt: row.createdAt,\n updatedAt: row.updatedAt,\n name: row.name,\n price: row.price,\n }));\n }\n}\n`,\n\n \"src/controllers/itemController.ts\": `import { BaseController } from \"tempest-express-sdk\";\nimport type { ItemModel } from \"@/db/models/itemModel\";\nimport type { ItemResponse } from \"@/schemas/item\";\nimport type { ItemService } from \"@/services/itemService\";\n\n/** Orchestration boundary between the router and the item service. */\nexport class ItemController extends BaseController<typeof ItemModel, ItemResponse> {\n constructor(service: ItemService) {\n super(service);\n }\n}\n`,\n\n \"src/api/routers/items.ts\": `import { Router } from \"express\";\nimport type { OpenAPIRegistry } from \"tempest-express-sdk\";\nimport { itemCreateSchema, itemResponseSchema } from \"@/schemas/item\";\n\n/**\n * Build the items router and register its OpenAPI paths.\n *\n * NOTE: wire a real controller (with a DB session) here. This stub returns\n * static data so a freshly generated project boots without a database.\n */\nexport function makeItemsRouter(registry: OpenAPIRegistry): Router {\n const router = Router();\n\n registry.registerPath({\n method: \"get\",\n path: \"/api/items\",\n summary: \"List items\",\n responses: {\n 200: {\n description: \"The items\",\n content: { \"application/json\": { schema: itemResponseSchema.array() } },\n },\n },\n });\n\n registry.registerPath({\n method: \"post\",\n path: \"/api/items\",\n summary: \"Create an item\",\n request: {\n body: { content: { \"application/json\": { schema: itemCreateSchema } } },\n },\n responses: {\n 201: {\n description: \"The created item\",\n content: { \"application/json\": { schema: itemResponseSchema } },\n },\n },\n });\n\n router.get(\"/api/items\", (_req, res) => {\n res.json([]);\n });\n\n router.post(\"/api/items\", (req, res) => {\n const data = itemCreateSchema.parse(req.body);\n res.status(201).json({\n id: \"00000000-0000-0000-0000-000000000000\",\n isActive: true,\n createdAt: new Date().toISOString(),\n updatedAt: new Date().toISOString(),\n ...data,\n });\n });\n\n return router;\n}\n`,\n\n \"src/api/app.ts\": `import type { Express } from \"express\";\nimport { createApp, createOpenApiRegistry } from \"tempest-express-sdk\";\nimport { settings } from \"@/core/settings\";\nimport { makeItemsRouter } from \"@/api/routers/items\";\n\n/** Build the configured Express application. */\nexport async function makeApp(): Promise<Express> {\n const registry = createOpenApiRegistry();\n\n return createApp({\n corsOrigins: settings.CORS_ORIGINS,\n openapi: {\n registry,\n info: { title: \"${name}\", version: \"0.1.0\", description: \"Powered by tempest-express-sdk.\" },\n },\n configure: (app) => {\n app.use(makeItemsRouter(registry));\n },\n });\n}\n`,\n\n \"src/server.ts\": `import { runServer } from \"tempest-express-sdk\";\nimport { settings } from \"@/core/settings\";\nimport { makeApp } from \"@/api/app\";\n\n/** Build the app and start listening. */\nexport async function run(): Promise<void> {\n const app = await makeApp();\n await runServer(app, { host: settings.HOST, port: settings.PORT });\n}\n`,\n\n \"docker-compose.yml\": dockerComposeFile(name),\n\n \"README.md\": `# ${name}\n\nGenerated with \\`tempest-express new\\` — an Express + Zod + tempest-db-js service.\n\n## Develop\n\n\\`\\`\\`bash\nnpm install\ncp .env.example .env\nnpm run dev\n\\`\\`\\`\n\n- API: http://127.0.0.1:8000/api/items\n- Swagger UI: http://127.0.0.1:8000/docs\n- Redoc: http://127.0.0.1:8000/redoc\n- Health: http://127.0.0.1:8000/health\n\\`\\`\\`\n`,\n };\n}\n\n/** Lowercase the first letter (PascalCase → camelCase). */\nfunction toCamel(name: string): string {\n return name.charAt(0).toLowerCase() + name.slice(1);\n}\n\n/** Convert `CamelCase` to `snake_case`. */\nfunction toSnake(name: string): string {\n return name.replace(/(?<!^)(?=[A-Z])/g, \"_\").toLowerCase();\n}\n\n/**\n * Build a full CRUD resource file map for a PascalCase resource name.\n *\n * Generates model + schema + repository + service + controller + router under\n * `src/`, mirroring the layered slice the `new` template ships with.\n *\n * @param pascal - The resource name in PascalCase (e.g. `Product`).\n * @returns A map of relative file path to file contents.\n */\nexport function resourceFiles(pascal: string): Record<string, string> {\n const camel = toCamel(pascal);\n const table = toSnake(pascal);\n\n return {\n [`src/db/models/${camel}Model.ts`]: `import { BaseModel, column, tableNameFor } from \"tempest-express-sdk\";\n\n/** The ${pascal} domain model. */\nexport class ${pascal}Model extends BaseModel {\n static tablename = tableNameFor(\"${pascal}Model\"); // \"${table}\"\n name = column.text().notNull();\n}\n`,\n\n [`src/schemas/${camel}.ts`]: `import { baseResponseSchema, z } from \"tempest-express-sdk\";\n\n/** Request payload to create a ${pascal}. */\nexport const ${camel}CreateSchema = z\n .object({ name: z.string().min(1) })\n .openapi(\"${pascal}Create\");\n\n/** Response payload for a ${pascal}. */\nexport const ${camel}ResponseSchema = baseResponseSchema\n .extend({ name: z.string() })\n .openapi(\"${pascal}\");\n\nexport type ${pascal}Create = z.infer<typeof ${camel}CreateSchema>;\nexport type ${pascal}Response = z.infer<typeof ${camel}ResponseSchema>;\n`,\n\n [`src/db/repositories/${camel}Repository.ts`]: `import { type AsyncSession, BaseRepository } from \"tempest-express-sdk\";\nimport { ${pascal}Model } from \"@/db/models/${camel}Model\";\n\n/** Data-access layer for ${pascal}. */\nexport class ${pascal}Repository extends BaseRepository<typeof ${pascal}Model> {\n constructor(session: AsyncSession) {\n super(${pascal}Model, session);\n }\n}\n`,\n\n [`src/services/${camel}Service.ts`]: `import { BaseService } from \"tempest-express-sdk\";\nimport type { ${pascal}Model } from \"@/db/models/${camel}Model\";\nimport type { ${pascal}Repository } from \"@/db/repositories/${camel}Repository\";\nimport type { ${pascal}Response } from \"@/schemas/${camel}\";\n\n/** Business logic for ${pascal}. */\nexport class ${pascal}Service extends BaseService<typeof ${pascal}Model, ${pascal}Response> {\n constructor(repository: ${pascal}Repository) {\n super(repository, (row) => ({\n id: row.id,\n isActive: row.isActive,\n createdAt: row.createdAt,\n updatedAt: row.updatedAt,\n name: row.name,\n }));\n }\n}\n`,\n\n [`src/controllers/${camel}Controller.ts`]: `import { BaseController } from \"tempest-express-sdk\";\nimport type { ${pascal}Model } from \"@/db/models/${camel}Model\";\nimport type { ${pascal}Response } from \"@/schemas/${camel}\";\nimport type { ${pascal}Service } from \"@/services/${camel}Service\";\n\n/** Orchestration boundary for ${pascal}. */\nexport class ${pascal}Controller extends BaseController<typeof ${pascal}Model, ${pascal}Response> {\n constructor(service: ${pascal}Service) {\n super(service);\n }\n}\n`,\n\n [`src/api/routers/${camel}s.ts`]: `import { Router } from \"express\";\nimport type { OpenAPIRegistry } from \"tempest-express-sdk\";\nimport { ${camel}CreateSchema, ${camel}ResponseSchema } from \"@/schemas/${camel}\";\n\n/** Build the ${pascal} router and register its OpenAPI paths. */\nexport function make${pascal}sRouter(registry: OpenAPIRegistry): Router {\n const router = Router();\n\n registry.registerPath({\n method: \"get\",\n path: \"/api/${camel}s\",\n summary: \"List ${camel}s\",\n responses: {\n 200: {\n description: \"OK\",\n content: { \"application/json\": { schema: ${camel}ResponseSchema.array() } },\n },\n },\n });\n registry.registerPath({\n method: \"post\",\n path: \"/api/${camel}s\",\n summary: \"Create a ${camel}\",\n request: {\n body: { content: { \"application/json\": { schema: ${camel}CreateSchema } } },\n },\n responses: {\n 201: {\n description: \"Created\",\n content: { \"application/json\": { schema: ${camel}ResponseSchema } },\n },\n },\n });\n\n router.get(\"/api/${camel}s\", (_req, res) => res.json([]));\n router.post(\"/api/${camel}s\", (req, res) => {\n const data = ${camel}CreateSchema.parse(req.body);\n res.status(201).json({\n id: \"00000000-0000-0000-0000-000000000000\",\n isActive: true,\n createdAt: new Date().toISOString(),\n updatedAt: new Date().toISOString(),\n ...data,\n });\n });\n\n return router;\n}\n`,\n };\n}\n\n/** Build a `docker-compose.yml` with Postgres + Redis for local dev. */\nexport function dockerComposeFile(name: string): string {\n return `services:\n postgres:\n image: postgres:16-alpine\n environment:\n POSTGRES_USER: ${name}\n POSTGRES_PASSWORD: ${name}\n POSTGRES_DB: ${name}\n ports:\n - \"5432:5432\"\n volumes:\n - pgdata:/var/lib/postgresql/data\n redis:\n image: redis:7-alpine\n ports:\n - \"6379:6379\"\n\nvolumes:\n pgdata:\n`;\n}\n","/**\n * Zod foundation shared by every DTO, mirroring `schemas.base.BaseSchema`.\n *\n * Pydantic uses class inheritance for shared config; Zod composes instead. This\n * module re-exports a `z` already augmented with `.openapi()` (so every schema\n * can carry OpenAPI metadata) and a {@link toDict} helper matching\n * `BaseSchema.to_dict` (drop nullish, exclude keys, merge extras).\n */\n\nimport { extendZodWithOpenApi } from \"@asteasolutions/zod-to-openapi\";\nimport { z } from \"zod\";\n\n// Augment the shared `z` instance with `.openapi(...)`. Idempotent — calling it\n// more than once across modules is safe.\nextendZodWithOpenApi(z);\n\nexport { z };\n\n/** Options for {@link toDict}. */\nexport interface ToDictOptions {\n /** Field names to drop from the output. */\n exclude?: string[];\n /** Extra entries merged on top (override existing keys). */\n include?: Record<string, unknown>;\n}\n\n/**\n * Serialize a validated object to a plain record, dropping `null`/`undefined`,\n * removing `exclude`d keys and merging `include` on top.\n *\n * @param data - The source object (typically a parsed schema).\n * @param options - Keys to exclude and entries to merge in.\n * @returns The cleaned record.\n */\nexport function toDict(\n data: Record<string, unknown>,\n options: ToDictOptions = {},\n): Record<string, unknown> {\n const exclude = new Set(options.exclude ?? []);\n const out: Record<string, unknown> = {};\n for (const [key, value] of Object.entries(data)) {\n if (exclude.has(key)) continue;\n if (value === null || value === undefined) continue;\n out[key] = value;\n }\n return { ...out, ...(options.include ?? {}) };\n}\n\n/**\n * Response schema fields every ORM record carries (`id`, `isActive`,\n * `createdAt`, `updatedAt`). Mirrors `BaseResponseSchema`. Extend it with\n * `baseResponseSchema.extend({ ... })` to build concrete `*ResponseSchema`s.\n */\nexport const baseResponseSchema = z.object({\n id: z.uuid().openapi({ description: \"The unique identifier of the record.\" }),\n isActive: z\n .boolean()\n .openapi({ description: \"Whether the record is active (soft-delete flag).\" }),\n createdAt: z.coerce\n .date()\n .openapi({ description: \"The creation timestamp of the record (UTC).\" }),\n updatedAt: z.coerce\n .date()\n .openapi({ description: \"The last update timestamp of the record (UTC).\" }),\n});\n\n/** The inferred TS type of a {@link baseResponseSchema} payload. */\nexport type BaseResponse = z.infer<typeof baseResponseSchema>;\n","/**\n * Ready-made, validated Zod field types, mirroring `utils.fields`.\n *\n * Reusable building blocks for DTOs so you don't re-derive the same constraint\n * everywhere: money in cents, a price string, a percentage, a latitude, a slug,\n * a hex color. Compose them into schemas with `z.object({ price: priceField })`.\n */\n\nimport { z } from \"@/schemas/base\";\n\n// --- Integers ---------------------------------------------------------------\n\n/** A strictly positive integer (`> 0`). */\nexport const positiveIntField = z.number().int().positive();\n/** A non-negative integer (`>= 0`). */\nexport const nonNegativeIntField = z.number().int().min(0);\n/** A monetary amount in the smallest unit (cents), `>= 0`. Avoids float drift. */\nexport const centsField = z.number().int().min(0);\n/** A TCP port (`1..65535`). */\nexport const portField = z.number().int().min(1).max(65535);\n/** A 0–5 star rating. */\nexport const ratingField = z.number().int().min(0).max(5);\n\n// --- Floats -----------------------------------------------------------------\n\n/** A strictly positive float (`> 0`). */\nexport const positiveFloatField = z.number().positive();\n/** A non-negative float (`>= 0`). */\nexport const nonNegativeFloatField = z.number().min(0);\n/** A percentage (`0..100`). */\nexport const percentField = z.number().min(0).max(100);\n/** A ratio (`0..1`). */\nexport const ratioField = z.number().min(0).max(1);\n/** A WGS-84 latitude (`-90..90`). */\nexport const latitudeField = z.number().min(-90).max(90);\n/** A WGS-84 longitude (`-180..180`). */\nexport const longitudeField = z.number().min(-180).max(180);\n\n// --- Strings ----------------------------------------------------------------\n\n/** A non-empty string; whitespace is trimmed before the length check. */\nexport const nonEmptyStrField = z\n .string()\n .transform((value) => value.trim())\n .pipe(z.string().min(1));\n\n/** A URL slug: lowercase alphanumerics separated by single hyphens. */\nexport const slugField = z.string().regex(/^[a-z0-9]+(?:-[a-z0-9]+)*$/, {\n message: \"Must be a lowercase hyphen-separated slug.\",\n});\n\n/** A hex color: `#rgb` or `#rrggbb`. */\nexport const hexColorField = z.string().regex(/^#(?:[0-9a-fA-F]{3}|[0-9a-fA-F]{6})$/, {\n message: \"Must be a #rgb or #rrggbb hex color.\",\n});\n\n/**\n * A money amount as an exact decimal **string** with up to two decimal places\n * (e.g. `\"19.90\"`). Mirrors `PriceField` — `tempest-db-js` `numeric` columns map\n * to strings, so money stays exact instead of drifting through a float.\n */\nexport const priceField = z\n .string()\n .regex(/^\\d+(?:\\.\\d{1,2})?$/, {\n message: 'Must be a decimal money string, e.g. \"19.90\".',\n });\n\n// --- Booleans ---------------------------------------------------------------\n\n/** Message shown when a value is neither a boolean nor a boolean-ish token. */\nconst LOOSE_BOOLEAN_ERROR =\n 'Must be a boolean value such as \"true\", \"false\", \"1\", \"0\", \"yes\" or \"no\".';\n\n/**\n * A boolean read from a **textual** source — a query string or an environment\n * variable, where every value arrives as a string.\n *\n * `z.coerce.boolean()` is the wrong tool for those: it is `Boolean(input)`, so\n * every non-empty string is `true` — `\"false\"` and `\"0\"` included — and there is\n * no way to ask for `false` over the wire. This reads the usual textual tokens\n * in both directions (`true`/`1`/`yes`/`on`/`y`/`enabled` and\n * `false`/`0`/`no`/`off`/`n`/`disabled`, case-insensitive, surrounding\n * whitespace trimmed) and **rejects** anything else, so a typo surfaces as a\n * validation error instead of silently becoming `false`.\n *\n * An absent value — and an empty or whitespace-only string, which is how an\n * unset `.env` entry (`DEBUG=`) reaches the schema — falls back to\n * `defaultValue`. Real booleans pass through untouched, so a schema built for\n * `process.env` still parses a synthetic object in tests.\n *\n * The OpenAPI metadata is pinned to `type: boolean` (with the default) so the\n * document describes the field the client actually sends, not the union used to\n * parse it.\n *\n * @param defaultValue - The value used when the field is absent or empty.\n * @returns A zod schema producing a `boolean`.\n */\nexport function looseBoolean(defaultValue: boolean) {\n return z\n .preprocess(\n (value) => (typeof value === \"string\" ? value.trim() || undefined : value),\n z\n .union([z.boolean(), z.stringbool()], { error: LOOSE_BOOLEAN_ERROR })\n .default(defaultValue),\n )\n .openapi({ type: \"boolean\", default: defaultValue });\n}\n","/**\n * Environment-driven settings, mirroring `settings.base.BaseAppSettings`.\n *\n * Pydantic-settings reads env vars into a frozen, validated model. Here a zod\n * schema plays the same role: {@link loadSettings} parses `process.env` (env\n * names are matched case-sensitively, like the FastAPI SDK) and returns a\n * frozen, fully-typed object. Composable fragments ({@link serverSettingsShape}\n * etc.) cover the common server/database/CORS knobs.\n */\n\nimport { z } from \"@/schemas/base\";\nimport { looseBoolean } from \"@/schemas/fields\";\n\n/** Server bind/runtime settings. Defaults bind to localhost. */\nexport const serverSettingsShape = {\n HOST: z.string().default(\"127.0.0.1\"),\n PORT: z.coerce.number().int().min(0).max(65535).default(8000),\n DEBUG: looseBoolean(false),\n} as const;\n\n/** Database connection settings. */\nexport const databaseSettingsShape = {\n DATABASE_URL: z.string().default(\"sqlite://./app.db\"),\n} as const;\n\n/** CORS settings. `CORS_ORIGINS` is a comma-separated list. */\nexport const corsSettingsShape = {\n CORS_ORIGINS: z\n .string()\n .default(\"*\")\n .transform((value) =>\n value\n .split(\",\")\n .map((origin) => origin.trim())\n .filter((origin) => origin.length > 0),\n ),\n} as const;\n\n/** The combined base settings shape (server + database + CORS). */\nexport const baseAppSettingsShape = {\n ...serverSettingsShape,\n ...databaseSettingsShape,\n ...corsSettingsShape,\n} as const;\n\n/** A zod object built from {@link baseAppSettingsShape}. */\nexport const baseAppSettingsSchema = z.object(baseAppSettingsShape);\n\n/** The parsed shape of {@link baseAppSettingsSchema}. */\nexport type BaseAppSettings = z.infer<typeof baseAppSettingsSchema>;\n\n/**\n * Parse and freeze settings from an environment source.\n *\n * Extend the base shape with project fields:\n *\n * ```ts\n * const settings = loadSettings(\n * z.object({ ...baseAppSettingsShape, JWT_SECRET: z.string() }),\n * );\n * ```\n *\n * @param schema - The settings zod schema.\n * @param env - The environment source (defaults to `process.env`).\n * @returns The validated, frozen settings object.\n * @throws {z.ZodError} When required env vars are missing or malformed.\n */\nexport function loadSettings<S extends z.ZodType>(\n schema: S,\n env: NodeJS.ProcessEnv = process.env,\n): Readonly<z.infer<S>> {\n return Object.freeze(schema.parse(env));\n}\n","/**\n * Password hashing backed by bcrypt, mirroring `utils.password.PasswordUtils`.\n *\n * `bcryptjs` is an optional peer dependency, imported lazily so that\n * `import \"tempest-express-sdk\"` keeps working when it is not installed — the\n * clear error is deferred to first use. Methods are async (the idiomatic Node\n * bcrypt surface).\n */\n\ntype BcryptModule = typeof import(\"bcryptjs\");\n\nlet cached: BcryptModule | null = null;\n\n/** Lazily load `bcryptjs`, with a clear install hint when missing. */\nasync function loadBcrypt(): Promise<BcryptModule> {\n if (cached) return cached;\n try {\n const mod = (await import(\"bcryptjs\")) as BcryptModule & { default?: BcryptModule };\n cached = mod.default ?? mod;\n } catch (cause) {\n throw new Error(\n \"PasswordUtils requires the 'bcryptjs' peer dependency. Install with `npm i bcryptjs`.\",\n { cause },\n );\n }\n return cached;\n}\n\n/** Hash and verify passwords using bcrypt. Stateless — construct once, reuse. */\nexport class PasswordUtils {\n /**\n * @param rounds - The bcrypt cost factor. Higher is slower and harder to\n * brute-force. Defaults to 12.\n */\n constructor(private readonly rounds: number = 12) {}\n\n /**\n * Hash a plaintext password.\n *\n * @param plain - The plaintext password.\n * @returns The bcrypt hash, ready to persist.\n */\n async hash(plain: string): Promise<string> {\n const bcrypt = await loadBcrypt();\n const salt = await bcrypt.genSalt(this.rounds);\n return bcrypt.hash(plain, salt);\n }\n\n /**\n * Verify a plaintext password against a stored hash. Returns `false` for\n * malformed hashes rather than throwing.\n *\n * @param plain - The plaintext password to verify.\n * @param hashed - The previously stored bcrypt hash.\n * @returns `true` when the password matches.\n */\n async verify(plain: string, hashed: string): Promise<boolean> {\n try {\n const bcrypt = await loadBcrypt();\n return await bcrypt.compare(plain, hashed);\n } catch {\n return false;\n }\n }\n}\n","#!/usr/bin/env node\n/**\n * `tempest-express` command-line interface, mirroring `cli.main`.\n *\n * Commands:\n * - `new <name>` — scaffold a runnable Express service from the SDK template.\n * - `--version` — print the CLI/SDK version.\n * - `--help` — print usage.\n */\n\nimport { spawnSync } from \"node:child_process\";\nimport { randomBytes, randomUUID } from \"node:crypto\";\nimport { existsSync, readFileSync } from \"node:fs\";\nimport { mkdir, writeFile } from \"node:fs/promises\";\nimport { dirname, join, resolve } from \"node:path\";\nimport { parseArgs } from \"node:util\";\nimport { dockerComposeFile, projectFiles, resourceFiles } from \"@/cli/template\";\nimport { baseAppSettingsSchema, loadSettings } from \"@/settings/base\";\nimport { PasswordUtils } from \"@/utils/password\";\nimport { VERSION } from \"@/version\";\n\nconst USAGE = `tempest-express — Express SDK CLI\n\nUsage:\n tempest-express new <name> [--dir <path>] Scaffold a new service\n tempest-express generate <Name> [--dir <path>] Scaffold a CRUD resource\n tempest-express secret [--bytes <n>] Print a random secret\n tempest-express docker-compose [--dir <path>] Write a docker-compose.yml\n tempest-express db Migration guidance\n tempest-express lint [--dir <path>] Run Biome check in a project\n tempest-express config [--dir <path>] Print the resolved base settings\n tempest-express user --email <e> --password <p> [--admin]\n Print a ready-to-insert user record\n tempest-express --version Print the version\n tempest-express --help Show this help\n`;\n\nconst DB_HELP = `Migrations are handled by tempest-db-js (programmatic API):\n\n import { ... } from \"tempest-db-js/migrations\";\n\nSee https://www.npmjs.com/package/tempest-db-js for the migration workflow.\n`;\n\n/** Parse a `.env` file's `KEY=VALUE` lines into a record (ignores comments). */\nfunction parseDotEnv(path: string): Record<string, string> {\n const out: Record<string, string> = {};\n if (!existsSync(path)) return out;\n for (const raw of readFileSync(path, \"utf8\").split(\"\\n\")) {\n const line = raw.trim();\n if (!line || line.startsWith(\"#\")) continue;\n const eq = line.indexOf(\"=\");\n if (eq === -1) continue;\n const key = line.slice(0, eq).trim();\n let value = line.slice(eq + 1).trim();\n if (\n (value.startsWith('\"') && value.endsWith('\"')) ||\n (value.startsWith(\"'\") && value.endsWith(\"'\"))\n ) {\n value = value.slice(1, -1);\n }\n out[key] = value;\n }\n return out;\n}\n\n/** Write a project file map under `root`, creating directories as needed. */\nasync function writeFiles(root: string, files: Record<string, string>): Promise<void> {\n for (const [relative, contents] of Object.entries(files)) {\n const target = join(root, relative);\n await mkdir(dirname(target), { recursive: true });\n await writeFile(target, contents, \"utf8\");\n }\n}\n\n/** Scaffold a new project named `name` into `dir/name`. */\nasync function runNew(name: string, dir: string): Promise<void> {\n if (!/^[a-z0-9][a-z0-9-_]*$/i.test(name)) {\n throw new Error(`Invalid project name: ${JSON.stringify(name)}`);\n }\n const root = resolve(dir, name);\n await writeFiles(root, projectFiles(name));\n process.stdout.write(\n `Created ${name} at ${root}\\n\\nNext steps:\\n cd ${name}\\n npm install\\n cp .env.example .env\\n npm run dev\\n`,\n );\n}\n\n/** Scaffold a CRUD resource into `dir` (PascalCase name required). */\nasync function runGenerate(name: string, dir: string): Promise<void> {\n if (!/^[A-Z][A-Za-z0-9]*$/.test(name)) {\n throw new Error(`Resource name must be PascalCase, got ${JSON.stringify(name)}`);\n }\n const files = resourceFiles(name);\n await writeFiles(resolve(dir), files);\n const written = Object.keys(files)\n .map((path) => ` ${path}`)\n .join(\"\\n\");\n process.stdout.write(`Generated ${name} resource:\\n${written}\\n`);\n}\n\n/**\n * Parse `argv` and dispatch to the matching command.\n *\n * @param argv - Arguments after `node script` (defaults to `process.argv`).\n * @returns The process exit code.\n */\nexport async function main(argv: string[] = process.argv.slice(2)): Promise<number> {\n const { values, positionals } = parseArgs({\n args: argv,\n allowPositionals: true,\n options: {\n version: { type: \"boolean\", short: \"v\" },\n help: { type: \"boolean\", short: \"h\" },\n dir: { type: \"string\", default: \".\" },\n bytes: { type: \"string\", default: \"32\" },\n email: { type: \"string\" },\n password: { type: \"string\" },\n admin: { type: \"boolean\", default: false },\n },\n });\n\n if (values.version) {\n process.stdout.write(`${VERSION}\\n`);\n return 0;\n }\n\n const [command, ...rest] = positionals;\n\n if (values.help || command === undefined || command === \"help\") {\n process.stdout.write(USAGE);\n return 0;\n }\n\n const dir = values.dir ?? \".\";\n\n if (command === \"new\") {\n const name = rest[0];\n if (!name) {\n process.stderr.write(`error: \\`new\\` requires a project name\\n\\n${USAGE}`);\n return 1;\n }\n await runNew(name, dir);\n return 0;\n }\n\n if (command === \"generate\" || command === \"g\") {\n const name = rest[0];\n if (!name) {\n process.stderr.write(`error: \\`generate\\` requires a resource name\\n\\n${USAGE}`);\n return 1;\n }\n await runGenerate(name, dir);\n return 0;\n }\n\n if (command === \"secret\") {\n const nbytes = Number.parseInt(values.bytes ?? \"32\", 10);\n if (!Number.isInteger(nbytes) || nbytes < 16) {\n process.stderr.write(\"error: --bytes must be an integer >= 16\\n\");\n return 1;\n }\n process.stdout.write(`${randomBytes(nbytes).toString(\"base64url\")}\\n`);\n return 0;\n }\n\n if (command === \"docker-compose\") {\n await writeFiles(resolve(dir), { \"docker-compose.yml\": dockerComposeFile(\"app\") });\n process.stdout.write(`Wrote ${resolve(dir, \"docker-compose.yml\")}\\n`);\n return 0;\n }\n\n if (command === \"db\") {\n process.stdout.write(DB_HELP);\n return 0;\n }\n\n if (command === \"lint\") {\n const target = resolve(dir);\n const result = spawnSync(\"npx\", [\"biome\", \"check\", target], {\n stdio: \"inherit\",\n shell: process.platform === \"win32\",\n });\n return result.status ?? 1;\n }\n\n if (command === \"config\") {\n const env = { ...process.env, ...parseDotEnv(join(resolve(dir), \".env\")) };\n const settings = loadSettings(baseAppSettingsSchema, env);\n process.stdout.write(`${JSON.stringify(settings, null, 2)}\\n`);\n return 0;\n }\n\n if (command === \"user\") {\n const { email, password } = values;\n if (!email || !password) {\n process.stderr.write(\"error: `user` requires --email and --password\\n\");\n return 1;\n }\n const hashedPassword = await new PasswordUtils().hash(password);\n const record = {\n id: randomUUID(),\n email,\n hashedPassword,\n isAdmin: Boolean(values.admin),\n isActive: true,\n };\n process.stdout.write(`${JSON.stringify(record, null, 2)}\\n`);\n return 0;\n }\n\n process.stderr.write(`error: unknown command ${JSON.stringify(command)}\\n\\n${USAGE}`);\n return 1;\n}\n\n// Auto-run as a binary, but stay importable from tests without executing.\nif (!process.env.VITEST) {\n main()\n .then((code) => {\n process.exitCode = code;\n })\n .catch((error: unknown) => {\n const message = error instanceof Error ? error.message : String(error);\n process.stderr.write(`error: ${message}\\n`);\n process.exitCode = 1;\n });\n}\n"]}
1
+ {"version":3,"sources":["../src/version.ts","../src/cli/template.ts","../src/schemas/base.ts","../src/schemas/fields.ts","../src/settings/base.ts","../src/utils/password.ts","../src/cli/index.ts"],"names":["extendZodWithOpenApi","z","existsSync","readFileSync","join","mkdir","dirname","writeFile","resolve","parseArgs","randomBytes","spawnSync","randomUUID"],"mappings":";;;;;;;;;;;;;AACO,IAAM,OAAA,GAAU,QAAA;;;ACiBvB,IAAM,WAAA,GAAc,IAAI,OAAO,CAAA,CAAA;AAQxB,SAAS,aAAa,IAAA,EAAsC;AACjE,EAAA,OAAO;AAAA,IACL,cAAA,EAAgB,GAAG,IAAA,CAAK,SAAA;AAAA,MACtB;AAAA,QACE,IAAA;AAAA,QACA,OAAA,EAAS,OAAA;AAAA,QACT,OAAA,EAAS,IAAA;AAAA,QACT,IAAA,EAAM,QAAA;AAAA,QACN,OAAA,EAAS;AAAA,UACP,GAAA,EAAK,mBAAA;AAAA,UACL,KAAA,EAAO,aAAA;AAAA,UACP,KAAA,EAAO,sBAAA;AAAA,UACP,SAAA,EAAW;AAAA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,KAAA,GAAQ,KAAA,CAAM,OAAA,GAAU,OAAO,KAAK,CAAA;AACrE,IAAA,OAAA,CAAQ,MAAA,CAAO,KAAA,CAAM,CAAA,OAAA,EAAU,OAAO;AAAA,CAAI,CAAA;AAC1C,IAAA,OAAA,CAAQ,QAAA,GAAW,CAAA;AAAA,EACrB,CAAC,CAAA;AACL","file":"cli.cjs","sourcesContent":["/** The installed SDK version. Single source of truth for the barrel + CLI. */\nexport const VERSION = \"0.23.0\";\n","/**\n * Project-template generator for the `new` command, mirroring `cli.new`.\n *\n * Produces a complete, runnable Express service that follows the SDK's layered\n * architecture (router → controller → service → repository → model) and is\n * pre-wired with `createApp`, native Swagger + Redoc, Zod validation, and a\n * `tempest-db-js` model. {@link projectFiles} returns a `path → contents` map\n * the CLI writes to disk.\n */\n\nimport { VERSION } from \"@/version\";\n\n/**\n * Caret range for the SDK the generated project depends on. Derived from\n * {@link VERSION} so a release bump can never leave the scaffold pinned to an\n * older major/minor — a stale pin here would install a different SDK (and, with\n * it, a different `zod` peer range) than the CLI that wrote the project.\n */\nconst SDK_VERSION = `^${VERSION}`;\n\n/**\n * Build the file map for a new service named `name`.\n *\n * @param name - The project (and package) name.\n * @returns A map of relative file path to file contents.\n */\nexport function projectFiles(name: string): Record<string, string> {\n return {\n \"package.json\": `${JSON.stringify(\n {\n name,\n version: \"0.1.0\",\n private: true,\n type: \"module\",\n scripts: {\n dev: \"tsx watch main.ts\",\n start: \"tsx main.ts\",\n build: \"tsc -p tsconfig.json\",\n typecheck: \"tsc --noEmit\",\n },\n dependencies: {\n express: \"^5.1.0\",\n \"tempest-db-js\": \"^0.4.0\",\n \"tempest-express-sdk\": SDK_VERSION,\n zod: \"^4.0.0\",\n },\n devDependencies: {\n \"@types/express\": \"^5.0.0\",\n \"@types/node\": \"^22.10.0\",\n tsx: \"^4.19.2\",\n typescript: \"^5.7.0\",\n },\n },\n null,\n 2,\n )}\\n`,\n\n \"tsconfig.json\": `${JSON.stringify(\n {\n compilerOptions: {\n target: \"ES2022\",\n module: \"ESNext\",\n moduleResolution: \"Bundler\",\n lib: [\"ES2022\"],\n strict: true,\n noUncheckedIndexedAccess: true,\n verbatimModuleSyntax: true,\n esModuleInterop: true,\n skipLibCheck: true,\n forceConsistentCasingInFileNames: true,\n outDir: \"dist\",\n paths: { \"@/*\": [\"./src/*\"] },\n },\n include: [\"src\", \"main.ts\"],\n },\n null,\n 2,\n )}\\n`,\n\n \".gitignore\": \"node_modules\\ndist\\n.env\\n*.log\\n\",\n\n \".env.example\":\n \"HOST=127.0.0.1\\nPORT=8000\\nDEBUG=false\\nDATABASE_URL=sqlite://./app.db\\nCORS_ORIGINS=*\\n\",\n\n \"main.ts\": `import { run } from \"@/index\";\n\nrun();\n`,\n\n \"src/index.ts\": `import { run } from \"@/server\";\n\nexport { run };\n`,\n\n \"src/core/settings.ts\": `import { baseAppSettingsShape, loadSettings, z } from \"tempest-express-sdk\";\n\n/** Application settings — extend the SDK base shape with project fields. */\nexport const settingsSchema = z.object({\n ...baseAppSettingsShape,\n});\n\nexport const settings = loadSettings(settingsSchema);\n`,\n\n \"src/db/models/itemModel.ts\": `import { BaseModel, column, tableNameFor } from \"tempest-express-sdk\";\n\n/** A sample domain model. Replace with your own. */\nexport class ItemModel extends BaseModel {\n static tablename = tableNameFor(\"ItemModel\");\n name = column.text().notNull();\n price = column.integer().notNull();\n}\n`,\n\n \"src/schemas/item.ts\": `import { baseResponseSchema, z } from \"tempest-express-sdk\";\n\n/** Request payload to create an item. */\nexport const itemCreateSchema = z\n .object({\n name: z.string().min(1).openapi({ description: \"The item name.\" }),\n price: z.number().int().min(0).openapi({ description: \"Price in cents.\" }),\n })\n .openapi(\"ItemCreate\");\n\n/** Response payload for an item (base columns + domain fields). */\nexport const itemResponseSchema = baseResponseSchema\n .extend({\n name: z.string(),\n price: z.number().int(),\n })\n .openapi(\"Item\");\n\nexport type ItemCreate = z.infer<typeof itemCreateSchema>;\nexport type ItemResponse = z.infer<typeof itemResponseSchema>;\n`,\n\n \"src/db/repositories/itemRepository.ts\": `import { type AsyncSession, BaseRepository } from \"tempest-express-sdk\";\nimport { ItemModel } from \"@/db/models/itemModel\";\n\n/** Data-access layer for items. */\nexport class ItemRepository extends BaseRepository<typeof ItemModel> {\n constructor(session: AsyncSession) {\n super(ItemModel, session);\n }\n}\n`,\n\n \"src/services/itemService.ts\": `import { BaseService } from \"tempest-express-sdk\";\nimport type { ItemRepository } from \"@/db/repositories/itemRepository\";\nimport type { ItemModel } from \"@/db/models/itemModel\";\nimport type { ItemResponse } from \"@/schemas/item\";\n\n/** Business logic for items. Maps raw rows to the response shape. */\nexport class ItemService extends BaseService<typeof ItemModel, ItemResponse> {\n constructor(repository: ItemRepository) {\n super(repository, (row) => ({\n id: row.id,\n isActive: row.isActive,\n createdAt: row.createdAt,\n updatedAt: row.updatedAt,\n name: row.name,\n price: row.price,\n }));\n }\n}\n`,\n\n \"src/controllers/itemController.ts\": `import { BaseController } from \"tempest-express-sdk\";\nimport type { ItemModel } from \"@/db/models/itemModel\";\nimport type { ItemResponse } from \"@/schemas/item\";\nimport type { ItemService } from \"@/services/itemService\";\n\n/** Orchestration boundary between the router and the item service. */\nexport class ItemController extends BaseController<typeof ItemModel, ItemResponse> {\n constructor(service: ItemService) {\n super(service);\n }\n}\n`,\n\n \"src/api/routers/items.ts\": `import { Router } from \"express\";\nimport type { OpenAPIRegistry } from \"tempest-express-sdk\";\nimport { itemCreateSchema, itemResponseSchema } from \"@/schemas/item\";\n\n/**\n * Build the items router and register its OpenAPI paths.\n *\n * NOTE: wire a real controller (with a DB session) here. This stub returns\n * static data so a freshly generated project boots without a database.\n */\nexport function makeItemsRouter(registry: OpenAPIRegistry): Router {\n const router = Router();\n\n registry.registerPath({\n method: \"get\",\n path: \"/api/items\",\n summary: \"List items\",\n responses: {\n 200: {\n description: \"The items\",\n content: { \"application/json\": { schema: itemResponseSchema.array() } },\n },\n },\n });\n\n registry.registerPath({\n method: \"post\",\n path: \"/api/items\",\n summary: \"Create an item\",\n request: {\n body: { content: { \"application/json\": { schema: itemCreateSchema } } },\n },\n responses: {\n 201: {\n description: \"The created item\",\n content: { \"application/json\": { schema: itemResponseSchema } },\n },\n },\n });\n\n router.get(\"/api/items\", (_req, res) => {\n res.json([]);\n });\n\n router.post(\"/api/items\", (req, res) => {\n const data = itemCreateSchema.parse(req.body);\n res.status(201).json({\n id: \"00000000-0000-0000-0000-000000000000\",\n isActive: true,\n createdAt: new Date().toISOString(),\n updatedAt: new Date().toISOString(),\n ...data,\n });\n });\n\n return router;\n}\n`,\n\n \"src/api/app.ts\": `import type { Express } from \"express\";\nimport { createApp, createOpenApiRegistry } from \"tempest-express-sdk\";\nimport { settings } from \"@/core/settings\";\nimport { makeItemsRouter } from \"@/api/routers/items\";\n\n/** Build the configured Express application. */\nexport async function makeApp(): Promise<Express> {\n const registry = createOpenApiRegistry();\n\n return createApp({\n corsOrigins: settings.CORS_ORIGINS,\n openapi: {\n registry,\n info: { title: \"${name}\", version: \"0.1.0\", description: \"Powered by tempest-express-sdk.\" },\n },\n configure: (app) => {\n app.use(makeItemsRouter(registry));\n },\n });\n}\n`,\n\n \"src/server.ts\": `import { runServer } from \"tempest-express-sdk\";\nimport { settings } from \"@/core/settings\";\nimport { makeApp } from \"@/api/app\";\n\n/** Build the app and start listening. */\nexport async function run(): Promise<void> {\n const app = await makeApp();\n await runServer(app, { host: settings.HOST, port: settings.PORT });\n}\n`,\n\n \"docker-compose.yml\": dockerComposeFile(name),\n\n \"README.md\": `# ${name}\n\nGenerated with \\`tempest-express new\\` — an Express + Zod + tempest-db-js service.\n\n## Develop\n\n\\`\\`\\`bash\nnpm install\ncp .env.example .env\nnpm run dev\n\\`\\`\\`\n\n- API: http://127.0.0.1:8000/api/items\n- Swagger UI: http://127.0.0.1:8000/docs\n- Redoc: http://127.0.0.1:8000/redoc\n- Health: http://127.0.0.1:8000/health\n\\`\\`\\`\n`,\n };\n}\n\n/** Lowercase the first letter (PascalCase → camelCase). */\nfunction toCamel(name: string): string {\n return name.charAt(0).toLowerCase() + name.slice(1);\n}\n\n/** Convert `CamelCase` to `snake_case`. */\nfunction toSnake(name: string): string {\n return name.replace(/(?<!^)(?=[A-Z])/g, \"_\").toLowerCase();\n}\n\n/**\n * Build a full CRUD resource file map for a PascalCase resource name.\n *\n * Generates model + schema + repository + service + controller + router under\n * `src/`, mirroring the layered slice the `new` template ships with.\n *\n * @param pascal - The resource name in PascalCase (e.g. `Product`).\n * @returns A map of relative file path to file contents.\n */\nexport function resourceFiles(pascal: string): Record<string, string> {\n const camel = toCamel(pascal);\n const table = toSnake(pascal);\n\n return {\n [`src/db/models/${camel}Model.ts`]: `import { BaseModel, column, tableNameFor } from \"tempest-express-sdk\";\n\n/** The ${pascal} domain model. */\nexport class ${pascal}Model extends BaseModel {\n static tablename = tableNameFor(\"${pascal}Model\"); // \"${table}\"\n name = column.text().notNull();\n}\n`,\n\n [`src/schemas/${camel}.ts`]: `import { baseResponseSchema, z } from \"tempest-express-sdk\";\n\n/** Request payload to create a ${pascal}. */\nexport const ${camel}CreateSchema = z\n .object({ name: z.string().min(1) })\n .openapi(\"${pascal}Create\");\n\n/** Response payload for a ${pascal}. */\nexport const ${camel}ResponseSchema = baseResponseSchema\n .extend({ name: z.string() })\n .openapi(\"${pascal}\");\n\nexport type ${pascal}Create = z.infer<typeof ${camel}CreateSchema>;\nexport type ${pascal}Response = z.infer<typeof ${camel}ResponseSchema>;\n`,\n\n [`src/db/repositories/${camel}Repository.ts`]: `import { type AsyncSession, BaseRepository } from \"tempest-express-sdk\";\nimport { ${pascal}Model } from \"@/db/models/${camel}Model\";\n\n/** Data-access layer for ${pascal}. */\nexport class ${pascal}Repository extends BaseRepository<typeof ${pascal}Model> {\n constructor(session: AsyncSession) {\n super(${pascal}Model, session);\n }\n}\n`,\n\n [`src/services/${camel}Service.ts`]: `import { BaseService } from \"tempest-express-sdk\";\nimport type { ${pascal}Model } from \"@/db/models/${camel}Model\";\nimport type { ${pascal}Repository } from \"@/db/repositories/${camel}Repository\";\nimport type { ${pascal}Response } from \"@/schemas/${camel}\";\n\n/** Business logic for ${pascal}. */\nexport class ${pascal}Service extends BaseService<typeof ${pascal}Model, ${pascal}Response> {\n constructor(repository: ${pascal}Repository) {\n super(repository, (row) => ({\n id: row.id,\n isActive: row.isActive,\n createdAt: row.createdAt,\n updatedAt: row.updatedAt,\n name: row.name,\n }));\n }\n}\n`,\n\n [`src/controllers/${camel}Controller.ts`]: `import { BaseController } from \"tempest-express-sdk\";\nimport type { ${pascal}Model } from \"@/db/models/${camel}Model\";\nimport type { ${pascal}Response } from \"@/schemas/${camel}\";\nimport type { ${pascal}Service } from \"@/services/${camel}Service\";\n\n/** Orchestration boundary for ${pascal}. */\nexport class ${pascal}Controller extends BaseController<typeof ${pascal}Model, ${pascal}Response> {\n constructor(service: ${pascal}Service) {\n super(service);\n }\n}\n`,\n\n [`src/api/routers/${camel}s.ts`]: `import { Router } from \"express\";\nimport type { OpenAPIRegistry } from \"tempest-express-sdk\";\nimport { ${camel}CreateSchema, ${camel}ResponseSchema } from \"@/schemas/${camel}\";\n\n/** Build the ${pascal} router and register its OpenAPI paths. */\nexport function make${pascal}sRouter(registry: OpenAPIRegistry): Router {\n const router = Router();\n\n registry.registerPath({\n method: \"get\",\n path: \"/api/${camel}s\",\n summary: \"List ${camel}s\",\n responses: {\n 200: {\n description: \"OK\",\n content: { \"application/json\": { schema: ${camel}ResponseSchema.array() } },\n },\n },\n });\n registry.registerPath({\n method: \"post\",\n path: \"/api/${camel}s\",\n summary: \"Create a ${camel}\",\n request: {\n body: { content: { \"application/json\": { schema: ${camel}CreateSchema } } },\n },\n responses: {\n 201: {\n description: \"Created\",\n content: { \"application/json\": { schema: ${camel}ResponseSchema } },\n },\n },\n });\n\n router.get(\"/api/${camel}s\", (_req, res) => res.json([]));\n router.post(\"/api/${camel}s\", (req, res) => {\n const data = ${camel}CreateSchema.parse(req.body);\n res.status(201).json({\n id: \"00000000-0000-0000-0000-000000000000\",\n isActive: true,\n createdAt: new Date().toISOString(),\n updatedAt: new Date().toISOString(),\n ...data,\n });\n });\n\n return router;\n}\n`,\n };\n}\n\n/** Build a `docker-compose.yml` with Postgres + Redis for local dev. */\nexport function dockerComposeFile(name: string): string {\n return `services:\n postgres:\n image: postgres:16-alpine\n environment:\n POSTGRES_USER: ${name}\n POSTGRES_PASSWORD: ${name}\n POSTGRES_DB: ${name}\n ports:\n - \"5432:5432\"\n volumes:\n - pgdata:/var/lib/postgresql/data\n redis:\n image: redis:7-alpine\n ports:\n - \"6379:6379\"\n\nvolumes:\n pgdata:\n`;\n}\n","/**\n * Zod foundation shared by every DTO, mirroring `schemas.base.BaseSchema`.\n *\n * Pydantic uses class inheritance for shared config; Zod composes instead. This\n * module re-exports a `z` already augmented with `.openapi()` (so every schema\n * can carry OpenAPI metadata) and a {@link toDict} helper matching\n * `BaseSchema.to_dict` (drop nullish, exclude keys, merge extras).\n */\n\nimport { extendZodWithOpenApi } from \"@asteasolutions/zod-to-openapi\";\nimport { z } from \"zod\";\n\n// Augment the shared `z` instance with `.openapi(...)`. Idempotent — calling it\n// more than once across modules is safe.\nextendZodWithOpenApi(z);\n\nexport { z };\n\n/** Options for {@link toDict}. */\nexport interface ToDictOptions {\n /** Field names to drop from the output. */\n exclude?: string[];\n /** Extra entries merged on top (override existing keys). */\n include?: Record<string, unknown>;\n}\n\n/**\n * Serialize a validated object to a plain record, dropping `null`/`undefined`,\n * removing `exclude`d keys and merging `include` on top.\n *\n * @param data - The source object (typically a parsed schema).\n * @param options - Keys to exclude and entries to merge in.\n * @returns The cleaned record.\n */\nexport function toDict(\n data: Record<string, unknown>,\n options: ToDictOptions = {},\n): Record<string, unknown> {\n const exclude = new Set(options.exclude ?? []);\n const out: Record<string, unknown> = {};\n for (const [key, value] of Object.entries(data)) {\n if (exclude.has(key)) continue;\n if (value === null || value === undefined) continue;\n out[key] = value;\n }\n return { ...out, ...(options.include ?? {}) };\n}\n\n/**\n * Response schema fields every ORM record carries (`id`, `isActive`,\n * `createdAt`, `updatedAt`). Mirrors `BaseResponseSchema`. Extend it with\n * `baseResponseSchema.extend({ ... })` to build concrete `*ResponseSchema`s.\n */\nexport const baseResponseSchema = z.object({\n id: z.uuid().openapi({ description: \"The unique identifier of the record.\" }),\n isActive: z\n .boolean()\n .openapi({ description: \"Whether the record is active (soft-delete flag).\" }),\n createdAt: z.coerce\n .date()\n .openapi({ description: \"The creation timestamp of the record (UTC).\" }),\n updatedAt: z.coerce\n .date()\n .openapi({ description: \"The last update timestamp of the record (UTC).\" }),\n});\n\n/** The inferred TS type of a {@link baseResponseSchema} payload. */\nexport type BaseResponse = z.infer<typeof baseResponseSchema>;\n","/**\n * Ready-made, validated Zod field types, mirroring `utils.fields`.\n *\n * Reusable building blocks for DTOs so you don't re-derive the same constraint\n * everywhere: money in cents, a price string, a percentage, a latitude, a slug,\n * a hex color. Compose them into schemas with `z.object({ price: priceField })`.\n */\n\nimport { z } from \"@/schemas/base\";\n\n// --- Integers ---------------------------------------------------------------\n\n/** A strictly positive integer (`> 0`). */\nexport const positiveIntField = z.number().int().positive();\n/** A non-negative integer (`>= 0`). */\nexport const nonNegativeIntField = z.number().int().min(0);\n/** A monetary amount in the smallest unit (cents), `>= 0`. Avoids float drift. */\nexport const centsField = z.number().int().min(0);\n/** A TCP port (`1..65535`). */\nexport const portField = z.number().int().min(1).max(65535);\n/** A 0–5 star rating. */\nexport const ratingField = z.number().int().min(0).max(5);\n\n// --- Floats -----------------------------------------------------------------\n\n/** A strictly positive float (`> 0`). */\nexport const positiveFloatField = z.number().positive();\n/** A non-negative float (`>= 0`). */\nexport const nonNegativeFloatField = z.number().min(0);\n/** A percentage (`0..100`). */\nexport const percentField = z.number().min(0).max(100);\n/** A ratio (`0..1`). */\nexport const ratioField = z.number().min(0).max(1);\n/** A WGS-84 latitude (`-90..90`). */\nexport const latitudeField = z.number().min(-90).max(90);\n/** A WGS-84 longitude (`-180..180`). */\nexport const longitudeField = z.number().min(-180).max(180);\n\n// --- Strings ----------------------------------------------------------------\n\n/** A non-empty string; whitespace is trimmed before the length check. */\nexport const nonEmptyStrField = z\n .string()\n .transform((value) => value.trim())\n .pipe(z.string().min(1));\n\n/** A URL slug: lowercase alphanumerics separated by single hyphens. */\nexport const slugField = z.string().regex(/^[a-z0-9]+(?:-[a-z0-9]+)*$/, {\n message: \"Must be a lowercase hyphen-separated slug.\",\n});\n\n/** A hex color: `#rgb` or `#rrggbb`. */\nexport const hexColorField = z.string().regex(/^#(?:[0-9a-fA-F]{3}|[0-9a-fA-F]{6})$/, {\n message: \"Must be a #rgb or #rrggbb hex color.\",\n});\n\n/**\n * A money amount as an exact decimal **string** with up to two decimal places\n * (e.g. `\"19.90\"`). Mirrors `PriceField` — `tempest-db-js` `numeric` columns map\n * to strings, so money stays exact instead of drifting through a float.\n */\nexport const priceField = z.string().regex(/^\\d+(?:\\.\\d{1,2})?$/, {\n message: 'Must be a decimal money string, e.g. \"19.90\".',\n});\n\n// --- Booleans ---------------------------------------------------------------\n\n/** Message shown when a value is neither a boolean nor a boolean-ish token. */\nconst LOOSE_BOOLEAN_ERROR =\n 'Must be a boolean value such as \"true\", \"false\", \"1\", \"0\", \"yes\" or \"no\".';\n\n/**\n * A boolean read from a **textual** source — a query string or an environment\n * variable, where every value arrives as a string.\n *\n * `z.coerce.boolean()` is the wrong tool for those: it is `Boolean(input)`, so\n * every non-empty string is `true` — `\"false\"` and `\"0\"` included — and there is\n * no way to ask for `false` over the wire. This reads the usual textual tokens\n * in both directions (`true`/`1`/`yes`/`on`/`y`/`enabled` and\n * `false`/`0`/`no`/`off`/`n`/`disabled`, case-insensitive, surrounding\n * whitespace trimmed) and **rejects** anything else, so a typo surfaces as a\n * validation error instead of silently becoming `false`.\n *\n * An absent value — and an empty or whitespace-only string, which is how an\n * unset `.env` entry (`DEBUG=`) reaches the schema — falls back to\n * `defaultValue`. Real booleans pass through untouched, so a schema built for\n * `process.env` still parses a synthetic object in tests.\n *\n * The OpenAPI metadata is pinned to `type: boolean` (with the default) so the\n * document describes the field the client actually sends, not the union used to\n * parse it.\n *\n * @param defaultValue - The value used when the field is absent or empty.\n * @returns A zod schema producing a `boolean`.\n */\nexport function looseBoolean(defaultValue: boolean) {\n return z\n .preprocess(\n (value) => (typeof value === \"string\" ? value.trim() || undefined : value),\n z\n .union([z.boolean(), z.stringbool()], { error: LOOSE_BOOLEAN_ERROR })\n .default(defaultValue),\n )\n .openapi({ type: \"boolean\", default: defaultValue });\n}\n","/**\n * Environment-driven settings, mirroring `settings.base.BaseAppSettings`.\n *\n * Pydantic-settings reads env vars into a frozen, validated model. Here a zod\n * schema plays the same role: {@link loadSettings} parses `process.env` (env\n * names are matched case-sensitively, like the FastAPI SDK) and returns a\n * frozen, fully-typed object. Composable fragments ({@link serverSettingsShape}\n * etc.) cover the common server/database/CORS knobs.\n */\n\nimport { z } from \"@/schemas/base\";\nimport { looseBoolean } from \"@/schemas/fields\";\n\n/** Server bind/runtime settings. Defaults bind to localhost. */\nexport const serverSettingsShape = {\n HOST: z.string().default(\"127.0.0.1\"),\n PORT: z.coerce.number().int().min(0).max(65535).default(8000),\n DEBUG: looseBoolean(false),\n} as const;\n\n/** Database connection settings. */\nexport const databaseSettingsShape = {\n DATABASE_URL: z.string().default(\"sqlite://./app.db\"),\n} as const;\n\n/** CORS settings. `CORS_ORIGINS` is a comma-separated list. */\nexport const corsSettingsShape = {\n CORS_ORIGINS: z\n .string()\n .default(\"*\")\n .transform((value) =>\n value\n .split(\",\")\n .map((origin) => origin.trim())\n .filter((origin) => origin.length > 0),\n ),\n} as const;\n\n/** The combined base settings shape (server + database + CORS). */\nexport const baseAppSettingsShape = {\n ...serverSettingsShape,\n ...databaseSettingsShape,\n ...corsSettingsShape,\n} as const;\n\n/** A zod object built from {@link baseAppSettingsShape}. */\nexport const baseAppSettingsSchema = z.object(baseAppSettingsShape);\n\n/** The parsed shape of {@link baseAppSettingsSchema}. */\nexport type BaseAppSettings = z.infer<typeof baseAppSettingsSchema>;\n\n/**\n * Parse and freeze settings from an environment source.\n *\n * Extend the base shape with project fields:\n *\n * ```ts\n * const settings = loadSettings(\n * z.object({ ...baseAppSettingsShape, JWT_SECRET: z.string() }),\n * );\n * ```\n *\n * @param schema - The settings zod schema.\n * @param env - The environment source (defaults to `process.env`).\n * @returns The validated, frozen settings object.\n * @throws {z.ZodError} When required env vars are missing or malformed.\n */\nexport function loadSettings<S extends z.ZodType>(\n schema: S,\n env: NodeJS.ProcessEnv = process.env,\n): Readonly<z.infer<S>> {\n return Object.freeze(schema.parse(env));\n}\n","/**\n * Password hashing backed by bcrypt, mirroring `utils.password.PasswordUtils`.\n *\n * `bcryptjs` is an optional peer dependency, imported lazily so that\n * `import \"tempest-express-sdk\"` keeps working when it is not installed — the\n * clear error is deferred to first use. Methods are async (the idiomatic Node\n * bcrypt surface).\n */\n\ntype BcryptModule = typeof import(\"bcryptjs\");\n\nlet cached: BcryptModule | null = null;\n\n/** Lazily load `bcryptjs`, with a clear install hint when missing. */\nasync function loadBcrypt(): Promise<BcryptModule> {\n if (cached) return cached;\n try {\n const mod = (await import(\"bcryptjs\")) as BcryptModule & { default?: BcryptModule };\n cached = mod.default ?? mod;\n } catch (cause) {\n throw new Error(\n \"PasswordUtils requires the 'bcryptjs' peer dependency. Install with `npm i bcryptjs`.\",\n { cause },\n );\n }\n return cached;\n}\n\n/** Hash and verify passwords using bcrypt. Stateless — construct once, reuse. */\nexport class PasswordUtils {\n /**\n * @param rounds - The bcrypt cost factor. Higher is slower and harder to\n * brute-force. Defaults to 12.\n */\n constructor(private readonly rounds: number = 12) {}\n\n /**\n * Hash a plaintext password.\n *\n * @param plain - The plaintext password.\n * @returns The bcrypt hash, ready to persist.\n */\n async hash(plain: string): Promise<string> {\n const bcrypt = await loadBcrypt();\n const salt = await bcrypt.genSalt(this.rounds);\n return bcrypt.hash(plain, salt);\n }\n\n /**\n * Verify a plaintext password against a stored hash. Returns `false` for\n * malformed hashes rather than throwing.\n *\n * @param plain - The plaintext password to verify.\n * @param hashed - The previously stored bcrypt hash.\n * @returns `true` when the password matches.\n */\n async verify(plain: string, hashed: string): Promise<boolean> {\n try {\n const bcrypt = await loadBcrypt();\n return await bcrypt.compare(plain, hashed);\n } catch {\n return false;\n }\n }\n}\n","#!/usr/bin/env node\n/**\n * `tempest-express` command-line interface, mirroring `cli.main`.\n *\n * Commands:\n * - `new <name>` — scaffold a runnable Express service from the SDK template.\n * - `--version` — print the CLI/SDK version.\n * - `--help` — print usage.\n */\n\nimport { spawnSync } from \"node:child_process\";\nimport { randomBytes, randomUUID } from \"node:crypto\";\nimport { existsSync, readFileSync } from \"node:fs\";\nimport { mkdir, writeFile } from \"node:fs/promises\";\nimport { dirname, join, resolve } from \"node:path\";\nimport { parseArgs } from \"node:util\";\nimport { dockerComposeFile, projectFiles, resourceFiles } from \"@/cli/template\";\nimport { baseAppSettingsSchema, loadSettings } from \"@/settings/base\";\nimport { PasswordUtils } from \"@/utils/password\";\nimport { VERSION } from \"@/version\";\n\nconst USAGE = `tempest-express — Express SDK CLI\n\nUsage:\n tempest-express new <name> [--dir <path>] Scaffold a new service\n tempest-express generate <Name> [--dir <path>] Scaffold a CRUD resource\n tempest-express secret [--bytes <n>] Print a random secret\n tempest-express docker-compose [--dir <path>] Write a docker-compose.yml\n tempest-express db Migration guidance\n tempest-express lint [--dir <path>] Run Biome check in a project\n tempest-express config [--dir <path>] Print the resolved base settings\n tempest-express user --email <e> --password <p> [--admin]\n Print a ready-to-insert user record\n tempest-express --version Print the version\n tempest-express --help Show this help\n`;\n\nconst DB_HELP = `Migrations are handled by tempest-db-js (programmatic API):\n\n import { ... } from \"tempest-db-js/migrations\";\n\nSee https://www.npmjs.com/package/tempest-db-js for the migration workflow.\n`;\n\n/** Parse a `.env` file's `KEY=VALUE` lines into a record (ignores comments). */\nfunction parseDotEnv(path: string): Record<string, string> {\n const out: Record<string, string> = {};\n if (!existsSync(path)) return out;\n for (const raw of readFileSync(path, \"utf8\").split(\"\\n\")) {\n const line = raw.trim();\n if (!line || line.startsWith(\"#\")) continue;\n const eq = line.indexOf(\"=\");\n if (eq === -1) continue;\n const key = line.slice(0, eq).trim();\n let value = line.slice(eq + 1).trim();\n if (\n (value.startsWith('\"') && value.endsWith('\"')) ||\n (value.startsWith(\"'\") && value.endsWith(\"'\"))\n ) {\n value = value.slice(1, -1);\n }\n out[key] = value;\n }\n return out;\n}\n\n/** Write a project file map under `root`, creating directories as needed. */\nasync function writeFiles(root: string, files: Record<string, string>): Promise<void> {\n for (const [relative, contents] of Object.entries(files)) {\n const target = join(root, relative);\n await mkdir(dirname(target), { recursive: true });\n await writeFile(target, contents, \"utf8\");\n }\n}\n\n/** Scaffold a new project named `name` into `dir/name`. */\nasync function runNew(name: string, dir: string): Promise<void> {\n if (!/^[a-z0-9][a-z0-9-_]*$/i.test(name)) {\n throw new Error(`Invalid project name: ${JSON.stringify(name)}`);\n }\n const root = resolve(dir, name);\n await writeFiles(root, projectFiles(name));\n process.stdout.write(\n `Created ${name} at ${root}\\n\\nNext steps:\\n cd ${name}\\n npm install\\n cp .env.example .env\\n npm run dev\\n`,\n );\n}\n\n/** Scaffold a CRUD resource into `dir` (PascalCase name required). */\nasync function runGenerate(name: string, dir: string): Promise<void> {\n if (!/^[A-Z][A-Za-z0-9]*$/.test(name)) {\n throw new Error(`Resource name must be PascalCase, got ${JSON.stringify(name)}`);\n }\n const files = resourceFiles(name);\n await writeFiles(resolve(dir), files);\n const written = Object.keys(files)\n .map((path) => ` ${path}`)\n .join(\"\\n\");\n process.stdout.write(`Generated ${name} resource:\\n${written}\\n`);\n}\n\n/**\n * Parse `argv` and dispatch to the matching command.\n *\n * @param argv - Arguments after `node script` (defaults to `process.argv`).\n * @returns The process exit code.\n */\nexport async function main(argv: string[] = process.argv.slice(2)): Promise<number> {\n const { values, positionals } = parseArgs({\n args: argv,\n allowPositionals: true,\n options: {\n version: { type: \"boolean\", short: \"v\" },\n help: { type: \"boolean\", short: \"h\" },\n dir: { type: \"string\", default: \".\" },\n bytes: { type: \"string\", default: \"32\" },\n email: { type: \"string\" },\n password: { type: \"string\" },\n admin: { type: \"boolean\", default: false },\n },\n });\n\n if (values.version) {\n process.stdout.write(`${VERSION}\\n`);\n return 0;\n }\n\n const [command, ...rest] = positionals;\n\n if (values.help || command === undefined || command === \"help\") {\n process.stdout.write(USAGE);\n return 0;\n }\n\n const dir = values.dir ?? \".\";\n\n if (command === \"new\") {\n const name = rest[0];\n if (!name) {\n process.stderr.write(`error: \\`new\\` requires a project name\\n\\n${USAGE}`);\n return 1;\n }\n await runNew(name, dir);\n return 0;\n }\n\n if (command === \"generate\" || command === \"g\") {\n const name = rest[0];\n if (!name) {\n process.stderr.write(`error: \\`generate\\` requires a resource name\\n\\n${USAGE}`);\n return 1;\n }\n await runGenerate(name, dir);\n return 0;\n }\n\n if (command === \"secret\") {\n const nbytes = Number.parseInt(values.bytes ?? \"32\", 10);\n if (!Number.isInteger(nbytes) || nbytes < 16) {\n process.stderr.write(\"error: --bytes must be an integer >= 16\\n\");\n return 1;\n }\n process.stdout.write(`${randomBytes(nbytes).toString(\"base64url\")}\\n`);\n return 0;\n }\n\n if (command === \"docker-compose\") {\n await writeFiles(resolve(dir), { \"docker-compose.yml\": dockerComposeFile(\"app\") });\n process.stdout.write(`Wrote ${resolve(dir, \"docker-compose.yml\")}\\n`);\n return 0;\n }\n\n if (command === \"db\") {\n process.stdout.write(DB_HELP);\n return 0;\n }\n\n if (command === \"lint\") {\n const target = resolve(dir);\n const result = spawnSync(\"npx\", [\"biome\", \"check\", target], {\n stdio: \"inherit\",\n shell: process.platform === \"win32\",\n });\n return result.status ?? 1;\n }\n\n if (command === \"config\") {\n const env = { ...process.env, ...parseDotEnv(join(resolve(dir), \".env\")) };\n const settings = loadSettings(baseAppSettingsSchema, env);\n process.stdout.write(`${JSON.stringify(settings, null, 2)}\\n`);\n return 0;\n }\n\n if (command === \"user\") {\n const { email, password } = values;\n if (!email || !password) {\n process.stderr.write(\"error: `user` requires --email and --password\\n\");\n return 1;\n }\n const hashedPassword = await new PasswordUtils().hash(password);\n const record = {\n id: randomUUID(),\n email,\n hashedPassword,\n isAdmin: Boolean(values.admin),\n isActive: true,\n };\n process.stdout.write(`${JSON.stringify(record, null, 2)}\\n`);\n return 0;\n }\n\n process.stderr.write(`error: unknown command ${JSON.stringify(command)}\\n\\n${USAGE}`);\n return 1;\n}\n\n// Auto-run as a binary, but stay importable from tests without executing.\nif (!process.env.VITEST) {\n main()\n .then((code) => {\n process.exitCode = code;\n })\n .catch((error: unknown) => {\n const message = error instanceof Error ? error.message : String(error);\n process.stderr.write(`error: ${message}\\n`);\n process.exitCode = 1;\n });\n}\n"]}
package/dist/cli.js CHANGED
@@ -1,5 +1,5 @@
1
1
  #!/usr/bin/env node
2
- import { VERSION, loadSettings, baseAppSettingsSchema, PasswordUtils } from './chunk-7Q5NBMSP.js';
2
+ import { VERSION, loadSettings, baseAppSettingsSchema, PasswordUtils } from './chunk-HC3TIN4M.js';
3
3
  import { spawnSync } from 'child_process';
4
4
  import { randomBytes, randomUUID } from 'crypto';
5
5
  import { existsSync, readFileSync } from 'fs';
package/dist/index.cjs CHANGED
@@ -12,6 +12,7 @@ var path = require('path');
12
12
  var os = require('os');
13
13
  var util = require('util');
14
14
  var express2 = require('express');
15
+ var module$1 = require('module');
15
16
  var swaggerUiDist = require('swagger-ui-dist');
16
17
  var migrations = require('tempest-db-js/migrations');
17
18
 
@@ -7683,7 +7684,6 @@ var HTTPClient = class {
7683
7684
  this.breakerRecord(host, true);
7684
7685
  if (attempt < this.retryPolicy.maxRetries) {
7685
7686
  await this.sleep(this.retryPolicy.sleepFor(attempt));
7686
- continue;
7687
7687
  }
7688
7688
  }
7689
7689
  }
@@ -10242,64 +10242,178 @@ function generateOpenApiDocument(registry, options) {
10242
10242
  const document = new Generator(registry.definitions).generateDocument(config);
10243
10243
  return document;
10244
10244
  }
10245
+ var DEFAULT_DOCS_FAVICON = "data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHZpZXdCb3g9IjAgMCAzMiAzMiI+PHJlY3Qgd2lkdGg9IjMyIiBoZWlnaHQ9IjMyIiByeD0iNyIgZmlsbD0iIzRjNmVmNSIvPjxwYXRoIGQ9Ik0xNy45IDQuNSA4LjYgMTguNGg1LjJMMTMgMjcuNWw5LjQtMTMuOWgtNS4zeiIgZmlsbD0iI2ZmZiIvPjwvc3ZnPg==";
10246
+ var REDOC_CDN_URL = "https://cdn.jsdelivr.net/npm/redoc@2/bundles/redoc.standalone.js";
10247
+ var REDOC_BUNDLE_SPECIFIER = "redoc/bundles/redoc.standalone.js";
10248
+ function escapeHtml(value) {
10249
+ return value.replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;").replace(/"/g, "&quot;").replace(/'/g, "&#39;");
10250
+ }
10251
+ function scriptLiteral(value) {
10252
+ return JSON.stringify(value).replace(/</g, "\\u003c");
10253
+ }
10254
+ function faviconTag(favicon) {
10255
+ if (favicon === false) return "";
10256
+ return `
10257
+ <link rel="icon" href="${escapeHtml(favicon)}" />`;
10258
+ }
10245
10259
  function mountOpenApiJson(app, path, document) {
10246
10260
  app.get(path, (_req, res) => {
10247
10261
  res.json(document);
10248
10262
  });
10249
10263
  }
10250
- function swaggerHtml(specUrl, title, assetsBase) {
10264
+ var SWAGGER_UI_DEFAULTS = Object.freeze({
10265
+ deepLinking: true,
10266
+ persistAuthorization: true,
10267
+ layout: "BaseLayout"
10268
+ });
10269
+ function assertSerializableUiOptions(options, trail = []) {
10270
+ if (typeof options === "function") {
10271
+ throw new Error(
10272
+ [
10273
+ `mountSwaggerUi: \`ui.${trail.join(".")}\` is a function, and the options are`,
10274
+ "serialized as JSON into the page, so it would be dropped silently. Swagger UI",
10275
+ "options that take a callback have to be wired in the browser."
10276
+ ].join(" ")
10277
+ );
10278
+ }
10279
+ if (Array.isArray(options)) {
10280
+ options.forEach(
10281
+ (entry, index) => assertSerializableUiOptions(entry, [...trail, String(index)])
10282
+ );
10283
+ return;
10284
+ }
10285
+ if (typeof options === "object" && options !== null) {
10286
+ for (const [key, value] of Object.entries(options)) {
10287
+ assertSerializableUiOptions(value, [...trail, key]);
10288
+ }
10289
+ }
10290
+ }
10291
+ function swaggerHtml(options) {
10292
+ const { specUrl, title, assetsBase, favicon, ui } = options;
10293
+ const merged = {
10294
+ url: specUrl,
10295
+ dom_id: "#swagger-ui",
10296
+ ...SWAGGER_UI_DEFAULTS,
10297
+ ...ui
10298
+ };
10299
+ const standalone = merged.layout === "StandaloneLayout";
10300
+ const presetScript = standalone ? `
10301
+ <script src="${escapeHtml(assetsBase)}/swagger-ui-standalone-preset.js"></script>` : "";
10302
+ const presets = standalone ? "[SwaggerUIBundle.presets.apis, SwaggerUIStandalonePreset]" : "[SwaggerUIBundle.presets.apis]";
10251
10303
  return `<!doctype html>
10252
10304
  <html lang="en">
10253
10305
  <head>
10254
10306
  <meta charset="utf-8" />
10255
10307
  <meta name="viewport" content="width=device-width, initial-scale=1" />
10256
- <title>${title}</title>
10257
- <link rel="stylesheet" href="${assetsBase}/swagger-ui.css" />
10308
+ <title>${escapeHtml(title)}</title>${faviconTag(favicon)}
10309
+ <link rel="stylesheet" href="${escapeHtml(assetsBase)}/swagger-ui.css" />
10258
10310
  </head>
10259
10311
  <body>
10260
10312
  <div id="swagger-ui"></div>
10261
- <script src="${assetsBase}/swagger-ui-bundle.js"></script>
10262
- <script src="${assetsBase}/swagger-ui-standalone-preset.js"></script>
10313
+ <script src="${escapeHtml(assetsBase)}/swagger-ui-bundle.js"></script>${presetScript}
10263
10314
  <script>
10264
- window.ui = SwaggerUIBundle({
10265
- url: ${JSON.stringify(specUrl)},
10266
- dom_id: "#swagger-ui",
10267
- presets: [SwaggerUIBundle.presets.apis, SwaggerUIStandalonePreset],
10268
- layout: "StandaloneLayout",
10269
- });
10315
+ var options = ${scriptLiteral(merged)};
10316
+ options.presets = ${presets};
10317
+ window.ui = SwaggerUIBundle(options);
10270
10318
  </script>
10271
10319
  </body>
10272
10320
  </html>`;
10273
10321
  }
10274
10322
  function mountSwaggerUi(app, path, specUrl, options = {}) {
10275
10323
  const title = options.title ?? "API docs";
10324
+ const favicon = options.favicon ?? DEFAULT_DOCS_FAVICON;
10325
+ const ui = options.ui ?? {};
10326
+ assertSerializableUiOptions(ui);
10276
10327
  const assetsPath = `${path.replace(/\/$/, "")}/assets`;
10277
10328
  app.use(assetsPath, express2__default.default.static(swaggerUiDist.getAbsoluteFSPath()));
10278
10329
  const handler = (_req, res) => {
10279
- res.type("html").send(swaggerHtml(specUrl, title, assetsPath));
10330
+ res.type("html").send(swaggerHtml({ specUrl, title, assetsBase: assetsPath, favicon, ui }));
10280
10331
  };
10281
10332
  app.get(path, handler);
10282
10333
  }
10283
- function redocHtml(specUrl, title, scriptUrl) {
10334
+ function resolveRedocBundle() {
10335
+ try {
10336
+ const requireFrom = module$1.createRequire(path.join(process.cwd(), "package.json"));
10337
+ return requireFrom.resolve(REDOC_BUNDLE_SPECIFIER);
10338
+ } catch {
10339
+ return null;
10340
+ }
10341
+ }
10342
+ function redocHtml(specUrl, title, scriptUrl, favicon) {
10284
10343
  return `<!doctype html>
10285
10344
  <html lang="en">
10286
10345
  <head>
10287
10346
  <meta charset="utf-8" />
10288
10347
  <meta name="viewport" content="width=device-width, initial-scale=1" />
10289
- <title>${title}</title>
10290
- <style>body { margin: 0; padding: 0; }</style>
10348
+ <title>${escapeHtml(title)}</title>${faviconTag(favicon)}
10349
+ <style>
10350
+ body { margin: 0; padding: 0; }
10351
+ #redoc-load-error {
10352
+ display: none;
10353
+ font: 14px/1.6 system-ui, sans-serif;
10354
+ margin: 3rem auto;
10355
+ max-width: 40rem;
10356
+ padding: 0 1rem;
10357
+ }
10358
+ #redoc-load-error code {
10359
+ background: #f1f3f5;
10360
+ border-radius: 3px;
10361
+ padding: 0.1rem 0.3rem;
10362
+ }
10363
+ </style>
10291
10364
  </head>
10292
10365
  <body>
10293
- <redoc spec-url=${JSON.stringify(specUrl)}></redoc>
10294
- <script src=${JSON.stringify(scriptUrl)}></script>
10366
+ <div id="redoc-load-error">
10367
+ <h1>The API reference could not load</h1>
10368
+ <p>
10369
+ The Redoc renderer was requested from
10370
+ <code id="redoc-script-url"></code> and did not load. The OpenAPI
10371
+ document itself is fine \u2014 it is served at
10372
+ <code id="redoc-spec-url"></code>.
10373
+ </p>
10374
+ <p>
10375
+ On a closed network, install the renderer next to the service
10376
+ (<code>npm install redoc</code>) so it is served locally, or point
10377
+ <code>scriptUrl</code> at a copy you host.
10378
+ </p>
10379
+ </div>
10380
+ <redoc spec-url="${escapeHtml(specUrl)}"></redoc>
10381
+ <script>
10382
+ window.__redocLoadFailed = function () {
10383
+ document.getElementById("redoc-script-url").textContent = ${scriptLiteral(scriptUrl)};
10384
+ document.getElementById("redoc-spec-url").textContent = ${scriptLiteral(specUrl)};
10385
+ document.getElementById("redoc-load-error").style.display = "block";
10386
+ var element = document.querySelector("redoc");
10387
+ if (element) element.style.display = "none";
10388
+ };
10389
+ </script>
10390
+ <script src="${escapeHtml(scriptUrl)}" onerror="window.__redocLoadFailed()"></script>
10295
10391
  </body>
10296
10392
  </html>`;
10297
10393
  }
10298
10394
  function mountRedoc(app, path, specUrl, options = {}) {
10299
10395
  const title = options.title ?? "API reference";
10300
- const scriptUrl = options.scriptUrl ?? "https://cdn.jsdelivr.net/npm/redoc@2/bundles/redoc.standalone.js";
10396
+ const favicon = options.favicon ?? DEFAULT_DOCS_FAVICON;
10397
+ const source = options.bundle ?? "auto";
10398
+ const assetsPath = `${path.replace(/\/$/, "")}/assets`;
10399
+ const bundleRoute = `${assetsPath}/redoc.standalone.js`;
10400
+ let scriptUrl = options.scriptUrl;
10401
+ if (scriptUrl === void 0 && source !== "cdn") {
10402
+ const bundlePath = options.bundlePath ?? resolveRedocBundle();
10403
+ if (bundlePath !== null && bundlePath !== void 0) {
10404
+ app.get(bundleRoute, (_req, res) => {
10405
+ res.sendFile(bundlePath);
10406
+ });
10407
+ scriptUrl = bundleRoute;
10408
+ } else if (source === "local") {
10409
+ throw new Error(
10410
+ 'mountRedoc: bundle "local" requires the `redoc` package. Install it (`npm install redoc`) or pass `bundlePath` with an absolute path to a Redoc standalone bundle.'
10411
+ );
10412
+ }
10413
+ }
10414
+ const resolvedScriptUrl = scriptUrl ?? REDOC_CDN_URL;
10301
10415
  app.get(path, (_req, res) => {
10302
- res.type("html").send(redocHtml(specUrl, title, scriptUrl));
10416
+ res.type("html").send(redocHtml(specUrl, title, resolvedScriptUrl, favicon));
10303
10417
  });
10304
10418
  }
10305
10419
  function makeHealthRouter(options = {}) {
@@ -11329,7 +11443,7 @@ async function withTestDatabase(models, fn) {
11329
11443
  }
11330
11444
 
11331
11445
  // src/version.ts
11332
- var VERSION = "0.22.0";
11446
+ var VERSION = "0.23.0";
11333
11447
 
11334
11448
  Object.defineProperty(exports, "OpenAPIRegistry", {
11335
11449
  enumerable: true,
@@ -11505,6 +11619,7 @@ exports.CSRF_HEADER_NAME = CSRF_HEADER_NAME;
11505
11619
  exports.CircuitOpenError = CircuitOpenError;
11506
11620
  exports.CompositeFeatureFlagBackend = CompositeFeatureFlagBackend;
11507
11621
  exports.ConflictException = ConflictException;
11622
+ exports.DEFAULT_DOCS_FAVICON = DEFAULT_DOCS_FAVICON;
11508
11623
  exports.DEFAULT_LOCALE = DEFAULT_LOCALE;
11509
11624
  exports.EmailProvider = EmailProvider;
11510
11625
  exports.EmailUtils = EmailUtils;
@@ -11545,6 +11660,7 @@ exports.OutboxStatus = OutboxStatus;
11545
11660
  exports.PHONE_BR_PATTERN = PHONE_BR_PATTERN;
11546
11661
  exports.PasswordResetService = PasswordResetService;
11547
11662
  exports.PasswordUtils = PasswordUtils;
11663
+ exports.REDOC_CDN_URL = REDOC_CDN_URL;
11548
11664
  exports.REQUEST_ID_HEADER = REQUEST_ID_HEADER;
11549
11665
  exports.RabbitBroker = RabbitBroker;
11550
11666
  exports.RedisCacheManager = RedisCacheManager;
@@ -11710,6 +11826,7 @@ exports.requestIdMiddleware = requestIdMiddleware;
11710
11826
  exports.requestTracingMiddleware = requestTracingMiddleware;
11711
11827
  exports.requireRoles = requireRoles;
11712
11828
  exports.resolveDownloadPath = resolveDownloadPath;
11829
+ exports.resolveRedocBundle = resolveRedocBundle;
11713
11830
  exports.runServer = runServer;
11714
11831
  exports.runWithRequestContext = runWithRequestContext;
11715
11832
  exports.sendBytesDownload = sendBytesDownload;