diff --git a/.github/.release-please-manifest.json b/.github/.release-please-manifest.json index 8c47fd945..df2552e0a 100644 --- a/.github/.release-please-manifest.json +++ b/.github/.release-please-manifest.json @@ -1,3 +1,3 @@ { - ".": "1.15.0" + ".": "1.15.1" } diff --git a/CHANGELOG.md b/CHANGELOG.md index 9157f76df..f48d022f6 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,12 @@ # Changelog +## [1.15.1](https://github.com/trycompai/crm/compare/v1.15.0...v1.15.1) (2026-08-20) + + +### Fixes + +* **api:** serve openapi.json and bundle swagger deps in function build ([#166](https://github.com/trycompai/crm/issues/166)) ([7ea4f37](https://github.com/trycompai/crm/commit/7ea4f37cd65e93d62d3977e08a0df476b3aa4479)) + ## [1.15.0](https://github.com/trycompai/crm/compare/v1.14.0...v1.15.0) (2026-08-20) diff --git a/apps/api/scripts/build-func.mjs b/apps/api/scripts/build-func.mjs index ea6e15838..7c10a9c1a 100644 --- a/apps/api/scripts/build-func.mjs +++ b/apps/api/scripts/build-func.mjs @@ -30,7 +30,7 @@ const EXTERNALS = [ "cardinal", ]; -const VENDOR_ROOTS = ["express"]; +const VENDOR_ROOTS = ["express", "@nestjs/swagger", "reflect-metadata"]; rmSync(outDir, { recursive: true, force: true }); mkdirSync(funcDir, { recursive: true }); diff --git a/apps/api/src/create-app.ts b/apps/api/src/create-app.ts index c14a57bd6..4a436e71c 100644 --- a/apps/api/src/create-app.ts +++ b/apps/api/src/create-app.ts @@ -58,45 +58,50 @@ export async function createApp(): Promise { // routing (wired up during init) otherwise shadows anything registered after // it. The factory form defers building the document (which needs the tRPC // router, only available post-init) to first request instead. - SwaggerModule.setup("", app, () => { - const { appRouter } = app.get(AppRouterHost); + SwaggerModule.setup( + "", + app, + () => { + const { appRouter } = app.get(AppRouterHost); - const trpcDocument = generateOpenApiDocument(appRouter, { - title: "CRM API — tRPC bridge", - description: - "Every tRPC procedure, reachable over REST for tooling that cannot speak tRPC. Same validation, same middlewares, same services as the tRPC transport — this only translates the wire format.", - version: "1.0", - baseUrl: `${apiUrl}${REST_BRIDGE_PATH}`, - securitySchemes: { apiKey: apiKeySecurityScheme }, - }); + const trpcDocument = generateOpenApiDocument(appRouter, { + title: "CRM API — tRPC bridge", + description: + "Every tRPC procedure, reachable over REST for tooling that cannot speak tRPC. Same validation, same middlewares, same services as the tRPC transport — this only translates the wire format.", + version: "1.0", + baseUrl: `${apiUrl}${REST_BRIDGE_PATH}`, + securitySchemes: { apiKey: apiKeySecurityScheme }, + }); - const swaggerConfig = new DocumentBuilder() - .setTitle("CRM API") - .setDescription( - `REST surface of the CRM API — auth, health, the internal cron routes, and a generated REST bridge (under ${REST_BRIDGE_PATH}) for every tRPC procedure.`, - ) - .setVersion("1.0") - .addCookieAuth(SESSION_COOKIE_NAME) - .addApiKey(apiKeySecurityScheme, "apiKey") - .build(); - const swaggerDocument = SwaggerModule.createDocument(app, swaggerConfig); + const swaggerConfig = new DocumentBuilder() + .setTitle("CRM API") + .setDescription( + `REST surface of the CRM API — auth, health, the internal cron routes, and a generated REST bridge (under ${REST_BRIDGE_PATH}) for every tRPC procedure.`, + ) + .setVersion("1.0") + .addCookieAuth(SESSION_COOKIE_NAME) + .addApiKey(apiKeySecurityScheme, "apiKey") + .build(); + const swaggerDocument = SwaggerModule.createDocument(app, swaggerConfig); - swaggerDocument.paths = { - ...swaggerDocument.paths, - ...(trpcDocument.paths as typeof swaggerDocument.paths), - }; - swaggerDocument.components = { - ...swaggerDocument.components, - schemas: { - ...swaggerDocument.components?.schemas, - ...(trpcDocument.components?.schemas as NonNullable< - typeof swaggerDocument.components - >["schemas"]), - }, - }; + swaggerDocument.paths = { + ...swaggerDocument.paths, + ...(trpcDocument.paths as typeof swaggerDocument.paths), + }; + swaggerDocument.components = { + ...swaggerDocument.components, + schemas: { + ...swaggerDocument.components?.schemas, + ...(trpcDocument.components?.schemas as NonNullable< + typeof swaggerDocument.components + >["schemas"]), + }, + }; - return swaggerDocument; - }); + return swaggerDocument; + }, + { jsonDocumentUrl: "openapi.json" }, + ); await app.init(); diff --git a/package.json b/package.json index c89609a18..c99f9db19 100644 --- a/package.json +++ b/package.json @@ -2,7 +2,7 @@ "name": "crm", "private": true, "license": "MIT", - "version": "1.15.0", + "version": "1.15.1", "scripts": { "prepare": "git config core.hooksPath .githooks 2>/dev/null || true", "build": "turbo run build",