Skip to content

Commit e99b0d6

Browse files
committed
fix: shared build
1 parent 825065a commit e99b0d6

File tree

9 files changed

+727
-901
lines changed

9 files changed

+727
-901
lines changed

apps/api/.swcrc

+4-2
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,13 @@
66
"syntax": "typescript",
77
"tsx": true,
88
"decorators": true,
9-
"dynamicImport": true
9+
"dynamicImport": true,
10+
"decoratorsBeforeExport": true
1011
}
1112
},
1213
"module": {
13-
"type": "commonjs"
14+
"type": "nodenext",
15+
"resolveFully": true
1416
},
1517
"sourceMaps": "inline"
1618
}

apps/api/package.json

+4-2
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
"author": "",
66
"private": "true",
77
"license": "MIT",
8+
"type": "module",
89
"scripts": {
910
"prebuild": "rimraf dist",
1011
"build": "pnpm build:metadata && nest build",
@@ -18,12 +19,12 @@
1819
"start:test": "cross-env NODE_ENV=test nest start",
1920
"start:debug": "nest start --debug",
2021
"start:prod": "node dist/main.js",
21-
"build:metadata": "cross-env ts-node scripts/generate-metadata.ts",
22+
"build:metadata": "cross-env npx tsx scripts/generate-metadata.ts",
2223
"lint": "eslint src",
2324
"lint:fix": "pnpm lint -- --fix",
2425
"lint:openapi": "spectral lint http://127.0.0.1:${PORT:-3000}/openapi.yaml",
2526
"pretest": "pnpm build:metadata",
26-
"generate:swagger": "cross-env NODE_ENV=test ts-node exportOpenAPIJSON.ts",
27+
"generate:swagger": "cross-env NODE_ENV=test npx tsx exportOpenAPIJSON.ts",
2728
"generate:sdk": " (cd ../../libs/internal-sdk && speakeasy run --skip-compile --minimal --skip-versioning) && (cd ../../libs/internal-sdk && pnpm build) ",
2829
"test": "cross-env TS_NODE_COMPILER_OPTIONS='{\"strictNullChecks\": false}' NODE_ENV=test mocha --timeout 5000 --require ts-node/register --exit 'src/**/*.spec.ts'",
2930
"test:e2e:novu-v0": "cross-env TS_NODE_COMPILER_OPTIONS='{\"strictNullChecks\": false}' NODE_ENV=test mocha --timeout 5000 --retries 3 --grep '#novu-v0' --require ts-node/register --exit --file e2e/setup.ts src/**/*.e2e{,-ee}.ts",
@@ -106,6 +107,7 @@
106107
"sanitize-html": "^2.4.0",
107108
"shortid": "^2.2.16",
108109
"swagger-ui-express": "^4.4.0",
110+
"tsx": "4.16.2",
109111
"twilio": "^4.14.1",
110112
"uuid": "^8.3.2",
111113
"zod": "^3.23.8",

apps/api/src/app/environments-v1/usecases/create-environment/create-environment.usecase.ts

+7-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
import { BadRequestException, Injectable, UnprocessableEntityException } from '@nestjs/common';
22
import { createHash } from 'crypto';
3-
import { nanoid } from 'nanoid';
43

54
import { encryptApiKey } from '@novu/application-generic';
65
import { EnvironmentEntity, EnvironmentRepository, NotificationGroupRepository } from '@novu/dal';
@@ -61,7 +60,7 @@ export class CreateEnvironment {
6160
const environment = await this.environmentRepository.create({
6261
_organizationId: command.organizationId,
6362
name: normalizedName,
64-
identifier: nanoid(12),
63+
identifier: await this.generateId(),
6564
_parentId: command.parentEnvironmentId,
6665
color,
6766
apiKeys: [
@@ -139,4 +138,10 @@ export class CreateEnvironment {
139138

140139
return commandColor;
141140
}
141+
142+
private async generateId() {
143+
const { nanoid } = await import('nanoid');
144+
145+
return nanoid(12);
146+
}
142147
}

apps/api/src/app/shared/framework/swagger/open.api.manipulation.component.ts

+43-8
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,48 @@
1-
import Nimma from 'nimma';
1+
/* eslint-disable no-inner-declarations */
22
import { OpenAPIObject } from '@nestjs/swagger';
33
import { API_KEY_SWAGGER_SECURITY_NAME } from '@novu/application-generic';
44
import { OperationObject, PathItemObject, PathsObject } from '@nestjs/swagger/dist/interfaces/open-api-spec.interface';
55

6-
const jpath = '$.paths..responses["200","201"].content["application/json"]';
6+
// Custom JSON path query implementation
7+
function jsonPathQuery(obj: any, path: string, callback: (scope: any) => void) {
8+
// Simple implementation to match the specific use case in the original code
9+
if (path === '$.paths..responses["200","201"].content["application/json"]') {
10+
// Recursively traverse paths
11+
function traversePaths(currentObj: any) {
12+
if (typeof currentObj !== 'object' || currentObj === null) return;
13+
14+
if (currentObj.paths) {
15+
Object.values(currentObj.paths).forEach((pathItem) => {
16+
if (typeof pathItem === 'object' && pathItem !== null) {
17+
Object.values(pathItem).forEach((operation) => {
18+
if (operation && operation.responses) {
19+
['200', '201'].forEach((responseCode) => {
20+
if (
21+
operation.responses[responseCode] &&
22+
operation.responses[responseCode].content &&
23+
operation.responses[responseCode].content['application/json']
24+
) {
25+
const scope = {
26+
value: operation.responses[responseCode].content['application/json'],
27+
};
28+
callback(scope);
29+
}
30+
});
31+
}
32+
});
33+
}
34+
});
35+
}
36+
}
37+
38+
traversePaths(obj);
39+
}
40+
}
741

842
/**
9-
* @param {import("nimma").EmittedScope} scope
43+
* @param {Object} scope
1044
*/
11-
function liftDataProperty(scope) {
45+
function liftDataProperty(scope: any) {
1246
if (
1347
typeof scope.value !== 'object' ||
1448
!scope.value ||
@@ -70,13 +104,13 @@ export function removeEndpointsWithoutApiKey<T>(openApiDocument: T): T {
70104
}
71105

72106
function unwrapDataAttribute(inputDocument: OpenAPIObject) {
73-
Nimma.query(inputDocument, {
74-
[jpath]: liftDataProperty,
75-
});
107+
const jpath = '$.paths..responses["200","201"].content["application/json"]';
108+
109+
// Use custom JSON path query instead of Nimma
110+
jsonPathQuery(inputDocument, jpath, liftDataProperty);
76111
}
77112

78113
function filterBearerOnlyIfExternal(isForInternalSdk: boolean, inputDocument: OpenAPIObject) {
79-
let openAPIObject: OpenAPIObject;
80114
if (isForInternalSdk) {
81115
return inputDocument;
82116
} else {
@@ -130,6 +164,7 @@ export function addIdempotencyKeyHeader<T>(openApiDocument: T): T {
130164

131165
return parsedDocument;
132166
}
167+
133168
export function sortOpenAPIDocument(openApiDoc: OpenAPIObject): OpenAPIObject {
134169
// Create a deep copy of the original document
135170
const sortedDoc: OpenAPIObject = JSON.parse(JSON.stringify(openApiDoc));

apps/api/tsconfig.build.json

+3-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
{
22
"extends": "../../tsconfig.json",
33
"compilerOptions": {
4-
"module": "commonjs",
54
"declaration": true,
65
"noImplicitAny": false,
76
"removeComments": true,
@@ -14,7 +13,9 @@
1413
"sourceMap": true,
1514
"skipLibCheck": true,
1615
"outDir": "./dist",
17-
"baseUrl": "./src"
16+
"baseUrl": "./src",
17+
"module": "preserve",
18+
"moduleResolution": "bundler"
1819
},
1920
"include": ["src/**/*", "src/**/*.d.ts"],
2021
"exclude": ["node_modules", "**/*.spec.ts", "**/*.e2e.ts", "**/*.e2e-ee.ts"]

apps/api/tsconfig.json

+2-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,8 @@
55
"allowSyntheticDefaultImports": true,
66
"emitDecoratorMetadata": true,
77
"esModuleInterop": true,
8-
"module": "commonjs",
8+
"module": "preserve",
9+
"moduleResolution": "bundler",
910
"skipLibCheck": true,
1011
"sourceMap": true,
1112
"strictNullChecks": true,

libs/internal-sdk/core.js.map

-1
This file was deleted.

libs/internal-sdk/index.js.map

-1
This file was deleted.

0 commit comments

Comments
 (0)