@solidxai/core 0.1.13-beta.13 → 0.1.13-beta.15
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/CHANGELOG.md +1147 -0
- package/README.md +19 -0
- package/dist/constants/media-file-types.d.ts +1 -0
- package/dist/constants/media-file-types.d.ts.map +1 -1
- package/dist/constants/media-file-types.js +2 -1
- package/dist/constants/media-file-types.js.map +1 -1
- package/dist/controllers/field-metadata.controller.d.ts +2 -2
- package/dist/dtos/create-field-metadata.dto.d.ts +2 -6
- package/dist/dtos/create-field-metadata.dto.d.ts.map +1 -1
- package/dist/dtos/create-field-metadata.dto.js +4 -10
- package/dist/dtos/create-field-metadata.dto.js.map +1 -1
- package/dist/dtos/create-model-sequence.dto.d.ts +1 -1
- package/dist/dtos/create-model-sequence.dto.d.ts.map +1 -1
- package/dist/dtos/create-model-sequence.dto.js +1 -1
- package/dist/dtos/create-model-sequence.dto.js.map +1 -1
- package/dist/filters/http-exception.filter.d.ts.map +1 -1
- package/dist/filters/http-exception.filter.js +5 -1
- package/dist/filters/http-exception.filter.js.map +1 -1
- package/dist/helpers/bootstrap.helper.d.ts +5 -2
- package/dist/helpers/bootstrap.helper.d.ts.map +1 -1
- package/dist/helpers/bootstrap.helper.js +7 -3
- package/dist/helpers/bootstrap.helper.js.map +1 -1
- package/dist/helpers/security.helper.d.ts +5 -1
- package/dist/helpers/security.helper.d.ts.map +1 -1
- package/dist/helpers/security.helper.js +15 -4
- package/dist/helpers/security.helper.js.map +1 -1
- package/dist/seeders/module-metadata-seeder.service.d.ts.map +1 -1
- package/dist/seeders/module-metadata-seeder.service.js +7 -3
- package/dist/seeders/module-metadata-seeder.service.js.map +1 -1
- package/dist/services/field-metadata.service.d.ts +2 -2
- package/dist/services/field-metadata.service.d.ts.map +1 -1
- package/dist/services/field-metadata.service.js +2 -1
- package/dist/services/field-metadata.service.js.map +1 -1
- package/dist/solid-core.module.d.ts +1 -3
- package/dist/solid-core.module.d.ts.map +1 -1
- package/dist/solid-core.module.js +0 -39
- package/dist/solid-core.module.js.map +1 -1
- package/package.json +1 -1
- package/src/constants/media-file-types.ts +2 -0
- package/src/dtos/create-field-metadata.dto.ts +4 -9
- package/src/dtos/create-model-sequence.dto.ts +1 -1
- package/src/filters/http-exception.filter.ts +11 -1
- package/src/helpers/bootstrap.helper.ts +39 -6
- package/src/helpers/security.helper.ts +35 -8
- package/src/seeders/module-metadata-seeder.service.ts +11 -3
- package/src/services/field-metadata.service.ts +3 -2
- package/src/solid-core.module.ts +5 -12
package/README.md
CHANGED
|
@@ -160,6 +160,25 @@ export class AppModule {}
|
|
|
160
160
|
|
|
161
161
|
For full configuration options — environment variables, storage providers, queue setup, and OAuth credentials — see the [Developer Documentation](https://docs.solidxai.com/docs).
|
|
162
162
|
|
|
163
|
+
### Security headers and iframe embedding
|
|
164
|
+
|
|
165
|
+
`bootstrapSolidApp` applies security headers through Helmet. The `frame-ancestors` CSP directive controls which origins are allowed to embed responses from the API in an iframe. This is relevant when rendering PDFs or other protected resources in the browser's built-in viewer.
|
|
166
|
+
|
|
167
|
+
By default, the bootstrap helper allows the current origin and local development origins (`localhost`, `127.0.0.1`, and `::1`) over HTTP or HTTPS on any port. This supports common setups where the UI and API run on different local ports, such as `localhost:3001` embedding a PDF served by `localhost:3000`.
|
|
168
|
+
|
|
169
|
+
To customize the allowlist, pass `security.frameAncestors` when bootstrapping the API. The configured list replaces the default list, so include every origin that should be allowed:
|
|
170
|
+
|
|
171
|
+
```typescript
|
|
172
|
+
bootstrapSolidApp(() => AppModule.forRoot(), {
|
|
173
|
+
swagger: { title: 'My API', description: 'My API description' },
|
|
174
|
+
security: {
|
|
175
|
+
frameAncestors: ["'self'", 'https://portal.example.com'],
|
|
176
|
+
},
|
|
177
|
+
});
|
|
178
|
+
```
|
|
179
|
+
|
|
180
|
+
For a fully restricted application, use `frameAncestors: ["'none'"]`. When cross-origin ancestors are allowed, `@solidxai/core` omits the legacy `X-Frame-Options` header because that header cannot express an origin allowlist; the CSP directive remains the source of truth.
|
|
181
|
+
|
|
163
182
|
|
|
164
183
|
## Technology Stack
|
|
165
184
|
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
export type MediaCategory = 'image' | 'audio' | 'video' | 'file' | 'pdf';
|
|
2
|
+
export declare const MEDIA_CATEGORIES: readonly ["image", "audio", "video", "file", "pdf"];
|
|
2
3
|
export declare const DANGEROUS_EXTENSIONS: Set<string>;
|
|
3
4
|
export declare const DANGEROUS_MIME_TYPES: Set<string>;
|
|
4
5
|
export declare function getLowercaseFileExtension(fileName?: string | null): string | undefined;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"media-file-types.d.ts","sourceRoot":"","sources":["../../src/constants/media-file-types.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,aAAa,GAAG,OAAO,GAAG,OAAO,GAAG,OAAO,GAAG,MAAM,GAAG,KAAK,CAAC;
|
|
1
|
+
{"version":3,"file":"media-file-types.d.ts","sourceRoot":"","sources":["../../src/constants/media-file-types.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,aAAa,GAAG,OAAO,GAAG,OAAO,GAAG,OAAO,GAAG,MAAM,GAAG,KAAK,CAAC;AAEzE,eAAO,MAAM,gBAAgB,qDAAsD,CAAC;AAapF,eAAO,MAAM,oBAAoB,aAI/B,CAAC;AAQH,eAAO,MAAM,oBAAoB,aAE/B,CAAC;AAEH,wBAAgB,yBAAyB,CAAC,QAAQ,CAAC,EAAE,MAAM,GAAG,IAAI,GAAG,MAAM,GAAG,SAAS,CAWtF;AAGD,MAAM,WAAW,gBAAgB;IAC7B,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,EAAE,MAAM,CAAC;CACrB;AAGD,wBAAgB,mBAAmB,CAAC,IAAI,CAAC,EAAE,gBAAgB,GAAG,IAAI,GAAG,MAAM,CAE1E;AAQD,wBAAgB,oBAAoB,CAAC,IAAI,CAAC,EAAE,gBAAgB,GAAG,IAAI,GAAG,OAAO,CAO5E;AASD,eAAO,MAAM,iBAAiB,EAAE,MAAM,CAAC,MAAM,EAAE,aAAa,CAM3D,CAAC;AAMF,eAAO,MAAM,sBAAsB,aAKjC,CAAC"}
|
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.INLINE_SAFE_EXTENSIONS = exports.EXT_TO_MEDIA_TYPE = exports.DANGEROUS_MIME_TYPES = exports.DANGEROUS_EXTENSIONS = void 0;
|
|
3
|
+
exports.INLINE_SAFE_EXTENSIONS = exports.EXT_TO_MEDIA_TYPE = exports.DANGEROUS_MIME_TYPES = exports.DANGEROUS_EXTENSIONS = exports.MEDIA_CATEGORIES = void 0;
|
|
4
4
|
exports.getLowercaseFileExtension = getLowercaseFileExtension;
|
|
5
5
|
exports.getUploadedFileName = getUploadedFileName;
|
|
6
6
|
exports.isDangerousMediaFile = isDangerousMediaFile;
|
|
7
|
+
exports.MEDIA_CATEGORIES = ['image', 'audio', 'video', 'file', 'pdf'];
|
|
7
8
|
const IMAGE_EXTENSIONS = ['png', 'jpg', 'jpeg', 'webp', 'gif', 'bmp', 'tiff', 'heic', 'heif'];
|
|
8
9
|
const AUDIO_EXTENSIONS = ['mp3', 'wav', 'ogg', 'aac', 'm4a', 'flac', 'webm'];
|
|
9
10
|
const VIDEO_EXTENSIONS = ['mp4', 'mov', 'avi', 'mkv', 'mpeg', 'mpg', '3gp', '3g2', 'webm', 'ogg'];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"media-file-types.js","sourceRoot":"","sources":["../../src/constants/media-file-types.ts"],"names":[],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"media-file-types.js","sourceRoot":"","sources":["../../src/constants/media-file-types.ts"],"names":[],"mappings":";;;AA+BA,8DAWC;AAUD,kDAEC;AAQD,oDAOC;AAnEY,QAA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C,CAAC;IAC7E,GAAG,MAAM,CAAC,WAAW,CAAC,mBAAmB,CAAC,GAAG,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,CAAC,GAAG,EAAE,MAAe,CAAC,CAAC,CAAC;IAC/E,CAAC,aAAa,CAAC,EAAE,KAAK;CACzB,CAAC;AAMW,QAAA,sBAAsB,GAAG,IAAI,GAAG,CAAS;IAClD,GAAG,gBAAgB;IACnB,GAAG,gBAAgB;IACnB,GAAG,gBAAgB;IACnB,aAAa;CAChB,CAAC,CAAC","sourcesContent":["export type MediaCategory = 'image' | 'audio' | 'video' | 'file' | 'pdf';\n\nexport const MEDIA_CATEGORIES = ['image', 'audio', 'video', 'file', 'pdf'] as const;\n\nconst IMAGE_EXTENSIONS = ['png', 'jpg', 'jpeg', 'webp', 'gif', 'bmp', 'tiff', 'heic', 'heif'];\nconst AUDIO_EXTENSIONS = ['mp3', 'wav', 'ogg', 'aac', 'm4a', 'flac', 'webm'];\nconst VIDEO_EXTENSIONS = ['mp4', 'mov', 'avi', 'mkv', 'mpeg', 'mpg', '3gp', '3g2', 'webm', 'ogg'];\nconst DOCUMENT_EXTENSIONS = ['txt', 'md', 'csv', 'json', 'doc', 'docx', 'xls', 'xlsx', 'ppt', 'pptx', 'zip', 'rar', '7z'];\nconst PDF_EXTENSION = 'pdf';\n\n/**\n * Extensions that must never be accepted as media uploads, regardless of declared mimetype or\n * admin-configured mediaTypes allowlist. Checked before any other resolution so a spoofed\n * Content-Type (e.g. application/octet-stream on an .html file) can't bypass this.\n */\nexport const DANGEROUS_EXTENSIONS = new Set([\n 'html', 'htm', 'xhtml', 'svg', 'xml',\n 'js', 'mjs', 'php', 'phtml', 'jsp', 'asp', 'aspx',\n 'exe', 'sh', 'bat', 'cmd', 'ps1', 'jar', 'dll',\n]);\n\n\n/**\n * Mimetypes that are never safe to accept, regardless of extension. These render as active\n * content in a browser (svg can carry <script>), so they are rejected even when the filename\n * looks harmless. Kept alongside DANGEROUS_EXTENSIONS so upload paths check both.\n */\nexport const DANGEROUS_MIME_TYPES = new Set([\n 'image/svg+xml', 'text/html', 'application/xhtml+xml',\n]);\n\nexport function getLowercaseFileExtension(fileName?: string | null): string | undefined {\n if (!fileName) {\n return undefined;\n }\n\n const lastDotIndex = fileName.lastIndexOf('.');\n if (lastDotIndex < 0 || lastDotIndex === fileName.length - 1) {\n return undefined;\n }\n\n return fileName.slice(lastDotIndex + 1).toLowerCase();\n}\n\n/** Minimal shape of an uploaded file, so this module stays free of framework imports. */\nexport interface UploadedFileLike {\n mimetype?: string;\n originalname?: string;\n filename?: string;\n}\n\n/** originalname is the client-supplied name; filename is multer's on-disk name. */\nexport function getUploadedFileName(file?: UploadedFileLike | null): string {\n return file?.originalname ?? file?.filename ?? '';\n}\n\n/**\n * Single predicate for \"must never be stored\". Shared by every upload entry point\n * (MediaFieldCrudManager, chatter attachments) so the rules can't drift between them.\n * Extension is checked before mimetype so a spoofed Content-Type (e.g.\n * application/octet-stream on an .html file) can't bypass it.\n */\nexport function isDangerousMediaFile(file?: UploadedFileLike | null): boolean {\n const ext = getLowercaseFileExtension(getUploadedFileName(file));\n if (ext && DANGEROUS_EXTENSIONS.has(ext)) {\n return true;\n }\n\n return DANGEROUS_MIME_TYPES.has((file?.mimetype || '').toLowerCase().trim());\n}\n\n/**\n * Single source of truth for extension -> coarse media category. Shared by upload-time\n * validation (MediaFieldCrudManager) and serve-time header hardening (ServeStaticModule), so\n * both agree on which extensions belong to which category and neither drifts out of sync.\n * webm/ogg are shared between AUDIO_EXTENSIONS and VIDEO_EXTENSIONS - last one wins here, they\n * default to 'video' since that's the more common upload case.\n */\nexport const EXT_TO_MEDIA_TYPE: Record<string, MediaCategory> = {\n ...Object.fromEntries(IMAGE_EXTENSIONS.map((ext) => [ext, 'image' as const])),\n ...Object.fromEntries(AUDIO_EXTENSIONS.map((ext) => [ext, 'audio' as const])),\n ...Object.fromEntries(VIDEO_EXTENSIONS.map((ext) => [ext, 'video' as const])),\n ...Object.fromEntries(DOCUMENT_EXTENSIONS.map((ext) => [ext, 'file' as const])),\n [PDF_EXTENSION]: 'pdf',\n};\n\n/**\n * Extensions safe to serve inline with their natural Content-Type; everything else served from\n * media-files-storage is forced to application/octet-stream + Content-Disposition: attachment.\n */\nexport const INLINE_SAFE_EXTENSIONS = new Set<string>([\n ...IMAGE_EXTENSIONS,\n ...AUDIO_EXTENSIONS,\n ...VIDEO_EXTENSIONS,\n PDF_EXTENSION,\n]);\n"]}
|
|
@@ -347,8 +347,8 @@ export declare class FieldMetadataController {
|
|
|
347
347
|
value: unknown;
|
|
348
348
|
}[];
|
|
349
349
|
mediaTypes: {
|
|
350
|
-
label:
|
|
351
|
-
value:
|
|
350
|
+
label: "file" | "image" | "audio" | "video" | "pdf";
|
|
351
|
+
value: "file" | "image" | "audio" | "video" | "pdf";
|
|
352
352
|
}[];
|
|
353
353
|
relationTypes: {
|
|
354
354
|
label: unknown;
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { MediaCategory } from '../constants/media-file-types';
|
|
1
2
|
export declare enum RelationFieldsCommand {
|
|
2
3
|
set = "set",
|
|
3
4
|
clear = "clear",
|
|
@@ -86,12 +87,7 @@ export declare enum DecryptWhenType {
|
|
|
86
87
|
beforeTransit = "before-transit",
|
|
87
88
|
afterTransit = "after-transit"
|
|
88
89
|
}
|
|
89
|
-
export
|
|
90
|
-
image = "image",
|
|
91
|
-
audio = "audio",
|
|
92
|
-
video = "video",
|
|
93
|
-
file = "file"
|
|
94
|
-
}
|
|
90
|
+
export type MediaType = MediaCategory;
|
|
95
91
|
export declare enum RelationType {
|
|
96
92
|
manyToOne = "many-to-one",
|
|
97
93
|
manyTomany = "many-to-many",
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"create-field-metadata.dto.d.ts","sourceRoot":"","sources":["../../src/dtos/create-field-metadata.dto.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"create-field-metadata.dto.d.ts","sourceRoot":"","sources":["../../src/dtos/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AM,EAAE,CAAC;IAKhC,kBAAkB,EAAE,kBAAkB,CAAC;IAKvC,0BAA0B,EAAE,MAAM,CAAC;IAKnC,8BAA8B,EAAE,MAAM,CAAC;IAKvC,sBAAsB,EAAE,sBAAsB,CAAC;IAK/C,0BAA0B,EAAE,0BAA0B,EAAE,CAAC;IAMzD,IAAI,EAAE,MAAM,CAAC;IAKb,QAAQ,EAAE,OAAO,CAAC;IAKlB,kBAAkB,EAAE,OAAO,CAAC;IAK5B,UAAU,EAAE,MAAM,CAAA;IAKlB,yBAAyB,EAAE,MAAM,CAAA;IAKjC,QAAQ,CAAC,SAAS,EAAE,OAAO,CAAA;IAK3B,qBAAqB,EAAE,MAAM,CAAA;IAK7B,mBAAmB,CAAC,EAAE,OAAO,CAAC;IAK9B,aAAa,EAAE,OAAO,CAAC;IAKvB,YAAY,CAAC,EAAE,OAAO,CAAC;CACxB"}
|
|
@@ -9,10 +9,11 @@ var __metadata = (this && this.__metadata) || function (k, v) {
|
|
|
9
9
|
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
10
10
|
};
|
|
11
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
-
exports.CreateFieldMetadataDto = exports.ComputedFieldTriggerConfig = exports.ComputedFieldTriggerOperation = exports.ComputedFieldValueType = exports.SelectionValueType = exports.CascadeType = exports.RelationType = exports.
|
|
12
|
+
exports.CreateFieldMetadataDto = exports.ComputedFieldTriggerConfig = exports.ComputedFieldTriggerOperation = exports.ComputedFieldValueType = exports.SelectionValueType = exports.CascadeType = exports.RelationType = exports.DecryptWhenType = exports.EncryptionType = exports.ALL_ORM_TYPES = exports.MSSQLType = exports.PSQLType = exports.MySQLType = exports.SolidFieldType = exports.RelationFieldsCommand = void 0;
|
|
13
13
|
const openapi = require("@nestjs/swagger");
|
|
14
14
|
const swagger_1 = require("@nestjs/swagger");
|
|
15
15
|
const class_transformer_1 = require("class-transformer");
|
|
16
|
+
const media_file_types_1 = require("../constants/media-file-types");
|
|
16
17
|
const class_validator_1 = require("class-validator");
|
|
17
18
|
var RelationFieldsCommand;
|
|
18
19
|
(function (RelationFieldsCommand) {
|
|
@@ -112,13 +113,6 @@ var DecryptWhenType;
|
|
|
112
113
|
DecryptWhenType["beforeTransit"] = "before-transit";
|
|
113
114
|
DecryptWhenType["afterTransit"] = "after-transit";
|
|
114
115
|
})(DecryptWhenType || (exports.DecryptWhenType = DecryptWhenType = {}));
|
|
115
|
-
var MediaType;
|
|
116
|
-
(function (MediaType) {
|
|
117
|
-
MediaType["image"] = "image";
|
|
118
|
-
MediaType["audio"] = "audio";
|
|
119
|
-
MediaType["video"] = "video";
|
|
120
|
-
MediaType["file"] = "file";
|
|
121
|
-
})(MediaType || (exports.MediaType = MediaType = {}));
|
|
122
116
|
var RelationType;
|
|
123
117
|
(function (RelationType) {
|
|
124
118
|
RelationType["manyToOne"] = "many-to-one";
|
|
@@ -162,7 +156,7 @@ class ComputedFieldTriggerConfig {
|
|
|
162
156
|
exports.ComputedFieldTriggerConfig = ComputedFieldTriggerConfig;
|
|
163
157
|
class CreateFieldMetadataDto {
|
|
164
158
|
static _OPENAPI_METADATA_FACTORY() {
|
|
165
|
-
return { name: { required: true, type: () => String }, displayName: { required: true, type: () => String }, description: { required: true, type: () => String }, type: { required: true, enum: require("./create-field-metadata.dto").SolidFieldType }, modelId: { required: true, type: () => Number }, ormType: { required: true, type: () => Object, enum: exports.ALL_ORM_TYPES }, length: { required: true, type: () => Number }, defaultValue: { required: true, type: () => String }, regexPattern: { required: true, type: () => String }, regexPatternNotMatchingErrorMsg: { required: true, type: () => String }, required: { required: true, type: () => Boolean }, unique: { required: true, type: () => Boolean }, encrypt: { required: true, type: () => Boolean }, encryptionType: { required: true, enum: require("./create-field-metadata.dto").EncryptionType }, decryptWhen: { required: true, enum: require("./create-field-metadata.dto").DecryptWhenType }, index: { required: true, type: () => Boolean }, max: { required: true, type: () => Number }, min: { required: true, type: () => Number }, private: { required: true, type: () => Boolean }, mediaTypes: { required: true,
|
|
159
|
+
return { name: { required: true, type: () => String }, displayName: { required: true, type: () => String }, description: { required: true, type: () => String }, type: { required: true, enum: require("./create-field-metadata.dto").SolidFieldType }, modelId: { required: true, type: () => Number }, ormType: { required: true, type: () => Object, enum: exports.ALL_ORM_TYPES }, length: { required: true, type: () => Number }, defaultValue: { required: true, type: () => String }, regexPattern: { required: true, type: () => String }, regexPatternNotMatchingErrorMsg: { required: true, type: () => String }, required: { required: true, type: () => Boolean }, unique: { required: true, type: () => Boolean }, encrypt: { required: true, type: () => Boolean }, encryptionType: { required: true, enum: require("./create-field-metadata.dto").EncryptionType }, decryptWhen: { required: true, enum: require("./create-field-metadata.dto").DecryptWhenType }, index: { required: true, type: () => Boolean }, max: { required: true, type: () => Number }, min: { required: true, type: () => Number }, private: { required: true, type: () => Boolean }, mediaTypes: { required: true, type: () => [Object], enum: [...media_file_types_1.MEDIA_CATEGORIES] }, mediaMaxSizeKb: { required: true, type: () => Number }, mediaStorageProviderId: { required: false, type: () => Number }, mediaStorageProviderUserKey: { required: false, type: () => String }, relationType: { required: true, enum: require("./create-field-metadata.dto").RelationType }, relationCoModelSingularName: { required: true, type: () => String }, relationCreateInverse: { required: true, type: () => Boolean }, relationCascade: { required: true, enum: require("./create-field-metadata.dto").CascadeType }, relationModelModuleName: { required: true, type: () => String }, relationCoModelFieldName: { required: true, type: () => String }, isRelationManyToManyOwner: { required: true, type: () => Boolean }, relationFieldFixedFilter: { required: true, type: () => String }, selectionDynamicProvider: { required: true, type: () => String }, selectionDynamicProviderCtxt: { required: true, type: () => String }, selectionStaticValues: { required: true, type: () => [String] }, selectionValueType: { required: true, enum: require("./create-field-metadata.dto").SelectionValueType }, computedFieldValueProvider: { required: true, type: () => String }, computedFieldValueProviderCtxt: { required: true, type: () => String }, computedFieldValueType: { required: true, enum: require("./create-field-metadata.dto").ComputedFieldValueType }, computedFieldTriggerConfig: { required: true, type: () => [require("./create-field-metadata.dto").ComputedFieldTriggerConfig] }, uuid: { required: true, type: () => String }, isSystem: { required: true, type: () => Boolean }, isMarkedForRemoval: { required: true, type: () => Boolean }, columnName: { required: true, type: () => String }, relationCoModelColumnName: { required: true, type: () => String }, isUserKey: { required: true, type: () => Boolean }, relationJoinTableName: { required: true, type: () => String }, enableAuditTracking: { required: false, type: () => Boolean }, isMultiSelect: { required: true, type: () => Boolean }, isPrimaryKey: { required: false, type: () => Boolean } };
|
|
166
160
|
}
|
|
167
161
|
}
|
|
168
162
|
exports.CreateFieldMetadataDto = CreateFieldMetadataDto;
|
|
@@ -275,7 +269,7 @@ __decorate([
|
|
|
275
269
|
], CreateFieldMetadataDto.prototype, "private", void 0);
|
|
276
270
|
__decorate([
|
|
277
271
|
(0, swagger_1.ApiProperty)({ description: 'Allowed media types for the field. Only for type=mediaSingle,mediaMultiple', }),
|
|
278
|
-
(0, class_validator_1.
|
|
272
|
+
(0, class_validator_1.IsIn)([...media_file_types_1.MEDIA_CATEGORIES], { each: true }),
|
|
279
273
|
(0, class_validator_1.IsOptional)(),
|
|
280
274
|
__metadata("design:type", Array)
|
|
281
275
|
], CreateFieldMetadataDto.prototype, "mediaTypes", void 0);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"create-field-metadata.dto.js","sourceRoot":"","sources":["../../src/dtos/create-field-metadata.dto.ts"],"names":[],"mappings":";;;;;;;;;;;;;AAAA,6CAA8C;AAC9C,yDAAoD;AAEpD,qDAUyB;AACzB,IAAY,qBAQX;AARD,WAAY,qBAAqB;IAC/B,oCAAW,CAAA;IACX,wCAAe,CAAA;IACf,sCAAa,CAAA;IACb,0CAAiB,CAAA;IACjB,0CAAiB,CAAA;IACjB,0CAAiB,CAAA;IACjB,0CAAiB,CAAA;AACnB,CAAC,EARW,qBAAqB,qCAArB,qBAAqB,QAQhC;AAED,IAAY,cAuCX;AAvCD,WAAY,cAAc;IAExB,6BAAW,CAAA;IACX,mCAAiB,CAAA;IAGjB,qCAAmB,CAAA;IAGnB,yCAAuB,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;IAHR,IAAA,qBAAW,EAAC,EAAE,WAAW,EAAE,aAAa,EAAE,CAAC;IAC3C,IAAA,4BAAU,GAAE;IACZ,IAAA,2BAAS,GAAE;;yDACe;AAK3B;IAHC,IAAA,qBAAW,EAAC,EAAE,WAAW,EAAE,mCAAmC,GAAG,CAAC;IAClE,IAAA,0BAAQ,GAAE;IACV,IAAA,4BAAU,GAAE;;qEACgB;AAK7B;IAHC,IAAA,qBAAW,EAAC,EAAE,WAAW,EAAE,sCAAsC,GAAG,CAAC;IACrE,IAAA,4BAAU,GAAE;IACZ,IAAA,2BAAS,GAAE;;mEACkB;AAK9B;IAHC,IAAA,4BAAU,GAAE;IACZ,IAAA,qBAAW,EAAC,EAAE,WAAW,EAAE,sBAAsB,GAAG,CAAC;IACrD,IAAA,2BAAS,GAAE;;6DACW;AAKvB;IAHC,IAAA,4BAAU,GAAE;IACZ,IAAA,qBAAW,EAAC,EAAE,WAAW,EAAE,sBAAsB,GAAG,CAAC;IACrD,IAAA,2BAAS,GAAE;;4DACW","sourcesContent":["import { ApiProperty } from '@nestjs/swagger';\nimport { Transform, Type } from 'class-transformer';\n\nimport {\n IsArray,\n IsBoolean,\n IsEnum,\n IsIn,\n IsInt,\n IsOptional,\n IsString,\n Matches,\n ValidateIf\n} from 'class-validator';\nexport enum RelationFieldsCommand {\n set = \"set\",\n clear = \"clear\",\n link = \"link\",\n unlink = \"unlink\",\n create = \"create\",\n update = \"update\",\n delete = \"delete\"\n}\n\nexport enum SolidFieldType {\n // numeric types\n int = 'int',\n bigint = 'bigint',\n // float = 'float',\n // double = 'double',\n decimal = 'decimal',\n\n // text types\n shortText = 'shortText',\n longtext = 'longText',\n richText = 'richText',\n json = 'json',\n\n // boolean types\n boolean = 'boolean',\n\n // date\n date = 'date',\n datetime = 'datetime',\n time = 'time',\n\n // relation\n relation = 'relation',\n\n // media\n mediaSingle = 'mediaSingle',\n mediaMultiple = 'mediaMultiple',\n\n email = 'email',\n password = 'password',\n\n // selection\n selectionStatic = 'selectionStatic',\n selectionDynamic = 'selectionDynamic',\n\n computed = 'computed',\n\n uuid = 'uuid'\n}\n\nexport enum MySQLType { //FIXME Currently this type is being used in the definition, Need to use OrmType instead\n // Numeric types\n int = 'int',\n decimal = 'decimal',\n double = 'double',\n\n // Text types\n // fieldType=shortText\n varchar = 'varchar',\n // fieldType=longText\n text = 'shortText',\n mediumtext = 'mediumtext',\n longtext = 'longtext',\n\n // Boolean types\n // fieldType=boolean\n bool = 'bool',\n boolean = 'boolean',\n\n //Date Types\n date = 'date',\n datetime = 'datetime',\n timestamp = 'timestamp',\n time = 'time',\n\n // Other types\n json = 'json',\n\n}\n\nexport enum PSQLType { //FIXME Currently this type is being used in the definition, Need to use OrmType instead\n // Numeric types\n integer = 'integer',\n decimal = 'decimal',\n bigint = 'bigint',\n\n // Text types\n varchar = 'varchar',\n text = 'text',\n\n // Boolean types\n boolean = 'boolean',\n\n // Date types\n timestamp = 'timestamp',\n timestamptz = 'timestamptz',\n time = 'time',\n date = 'date',\n\n // Other types\n json = 'json',\n jsonb = 'jsonb',\n simplejson = 'simple-json'\n}\n\nexport enum MSSQLType {\n int = \"int\",\n bigint = \"bigint\",\n decimal = \"decimal\",\n numeric = \"numeric\",\n varchar = \"varchar\",\n nvarchar = \"nvarchar\",\n simplejson = \"simple-json\",\n text = \"text\",\n bit = \"bit\",\n date = \"date\",\n datetime = \"datetime\",\n datetime2 = \"datetime2\",\n time = \"time\",\n uniqueidentifier = \"uniqueidentifier\"\n}\n\nexport const ALL_ORM_TYPES = [\n ...Object.values(PSQLType),\n ...Object.values(MSSQLType),\n ...Object.values(MySQLType),\n] as const;\n\nexport type OrmType = typeof ALL_ORM_TYPES[number];\n\n// export type OrmType = PSQLType | MySQLType | MSSQLType;\n\nexport enum EncryptionType {\n aes128 = 'aes-128',\n aes256 = 'aes-256',\n}\n\nexport enum DecryptWhenType {\n beforeTransit = 'before-transit',\n afterTransit = 'after-transit',\n}\n\nexport enum MediaType {\n image = 'image',\n audio = 'audio',\n video = 'video',\n // document = 'document',\n file = 'file',\n}\n\nexport enum RelationType {\n manyToOne = 'many-to-one',\n manyTomany = 'many-to-many',\n oneToMany = 'one-to-many',\n}\n\nexport enum CascadeType {\n setNull = 'set null',\n restrict = 'restrict',\n cascade = 'cascade',\n}\n\n// export enum MediaStorageProviderType {\n// database = 'database',\n// file = 'file',\n// s3 = 's3',\n// }\n\nexport enum SelectionValueType {\n string = 'string',\n int = 'int',\n}\n\nexport enum ComputedFieldValueType {\n string = 'string',\n int = 'int',\n decimal = 'decimal',\n boolean = 'boolean',\n date = 'date',\n datetime = 'datetime',\n}\n\nexport enum ComputedFieldTriggerOperation {\n beforeInsert = \"before-insert\",\n afterInsert = \"after-insert\",\n beforeUpdate = \"before-update\",\n afterUpdate = \"after-update\",\n beforeRemove = \"before-delete\",\n afterRemove = \"after-delete\",\n}\n\nexport class ComputedFieldTriggerConfig {\n moduleName: string; // Name of the module where the computed field is defined\n modelName: string;\n operations: ComputedFieldTriggerOperation[]; // List of operations where this computed field should be triggered\n}\n\nexport class CreateFieldMetadataDto {\n @ApiProperty({ description: 'Name of your field, this is also the name of the column or attribute', })\n // @Matches(/[a-z]+(_[a-z]+)*/, { message: 'Field name should follow snake case conventions only with all lower case.', })\n @IsString()\n name: string;\n\n @ApiProperty({ description: 'Display name of your field' })\n @IsString()\n readonly displayName: string;\n\n\n @ApiProperty({ description: 'Description of your field' })\n @IsOptional()\n @IsString()\n readonly description: string;\n\n // @ApiProperty({ description: \"Help text associated with this field\" })\n // @IsString()\n // readonly helpText: string;\n\n @ApiProperty({ description: 'Field can have types' })\n @IsEnum(SolidFieldType)\n readonly type: SolidFieldType;\n\n @ApiProperty({ description: 'Related model id' })\n @IsInt()\n @IsOptional()\n readonly modelId: number;\n\n //For all types of fields\n @ApiProperty({ description: 'Field can have orm types specific to your database', })\n @IsIn(ALL_ORM_TYPES)\n @IsOptional()\n readonly ormType: OrmType;\n\n @ApiProperty({ description: 'Length of the field. Only for type=text' })\n @IsInt()\n @IsOptional()\n readonly length: number;\n\n @ApiProperty({ description: 'Default value of the field' })\n @IsString()\n @IsOptional()\n readonly defaultValue: string;\n\n @ApiProperty({ description: 'Format regex pattern for the field. Only for type=text, longText, email, password', })\n @IsString()\n @IsOptional()\n readonly regexPattern: string;\n\n @ApiProperty({ description: 'If the regex pattern matching fails, then what is the error message to be displayed', })\n @IsString()\n @IsOptional()\n readonly regexPatternNotMatchingErrorMsg: string;\n\n @ApiProperty({ description: 'Is the field mandatory?' })\n @IsBoolean()\n readonly required: boolean;\n\n @ApiProperty({ description: 'Is the field value unique?' })\n @IsBoolean()\n @IsOptional()\n readonly unique: boolean;\n\n @ApiProperty({ description: 'Is the field symmetric encrypted?' })\n @IsBoolean()\n readonly encrypt: boolean;\n\n @ApiProperty({ description: 'Type of encryption. Only if encrypt=true' })\n @IsEnum(EncryptionType)\n @IsOptional()\n readonly encryptionType: EncryptionType;\n\n //Pending\n @ApiProperty({ description: 'At what point do we want to decrypt the data? Only if encrypt=true', })\n @IsEnum(DecryptWhenType)\n @IsOptional()\n decryptWhen: DecryptWhenType;\n\n @ApiProperty({ description: 'Is the field indexed? For all types, except:richText, longText', })\n @IsBoolean()\n index: boolean;\n\n @ApiProperty({ description: 'for text fields, this is length. for numeric fields, this is the range of values allowed. Only for type=shortText,longText,richText,json,int,decimal,date,dateTime,time', })\n @IsInt()\n @IsOptional()\n max: number;\n\n @ApiProperty({ description: 'for text fields, this is length. for numeric fields, this is the range of values allowed. Only for type=shortText,longText,richText,json,int,decimal,date,dateTime,time', })\n @IsInt()\n @IsOptional()\n min: number;\n\n @ApiProperty({ description: 'Is the field private?' })\n @IsBoolean()\n private: boolean;\n\n @ApiProperty({ description: 'Allowed media types for the field. Only for type=mediaSingle,mediaMultiple', })\n @IsEnum(MediaType, { each: true })\n @IsOptional()\n mediaTypes: MediaType[];\n\n @ApiProperty({ description: 'Maximum size of the media in KB. Only for type=mediaSingle,mediaMultiple', })\n @IsInt()\n @IsOptional()\n mediaMaxSizeKb: number;\n\n @ApiProperty({ description: 'Configured Media storage provider. Only for type=mediaSingle,mediaMultiple', })\n @IsInt()\n @IsOptional()\n mediaStorageProviderId?: number;\n\n @ApiProperty({ description: 'Configured Media storage provider. Only for type=mediaSingle,mediaMultiple. When you need to specify the storage provider by name.', })\n @IsInt()\n @IsOptional()\n mediaStorageProviderUserKey?: string;\n\n // @ApiProperty({ description: 'Is the media embedded in the entity table? Only for type=mediaSingle', })\n // @IsBoolean()\n // @IsOptional()\n // mediaEmbedded: boolean;\n\n @ApiProperty({ description: 'Relation Type. Only for type=relation' })\n @IsEnum(RelationType)\n @IsOptional()\n relationType: RelationType;\n\n @ApiProperty({ description: 'Related model for the relation. Only for type=relation' })\n @IsString()\n @IsOptional()\n relationCoModelSingularName: string;\n\n @ApiProperty({ description: 'Create inverse relation. Only for type=relation', })\n @IsBoolean()\n @IsOptional()\n relationCreateInverse: boolean;\n\n @ApiProperty({ description: 'Cascade type. Only for type=relation' })\n @IsEnum(CascadeType)\n @IsOptional()\n relationCascade: CascadeType;\n\n @ApiProperty({ description: 'Related field module. Only required for type=relation, if the related field belongs to a different module' })\n @IsOptional()\n relationModelModuleName: string;\n\n @ApiProperty({ description: 'Related field module. Only required for type=relation and relationType=many-to-many, i.e if the related many to many field belongs to a different model' })\n @IsOptional()\n relationCoModelFieldName: string;\n\n @ApiProperty({ description: 'Only for type=relation, many-to-many. This field is used to set the owner of the many-to-many relation' })\n @IsOptional()\n isRelationManyToManyOwner: boolean;\n\n\n @ApiProperty({ description: 'Only for type=relation, many-to-many. This field is used to store fixed filters that needs to applied on related model' })\n @IsOptional()\n relationFieldFixedFilter: string;\n\n @ApiProperty({\n description:\n 'Dynamic provider for selection. Only for type=selectionDynamic',\n })\n @IsString()\n @IsOptional()\n selectionDynamicProvider: string;\n\n @ApiProperty({ description: 'Dynamic provider Context. Only for type=selectionDynamic', })\n @IsString()\n @IsOptional()\n selectionDynamicProviderCtxt: string;\n\n @ApiProperty({ description: 'Static values for selection. Only for type=selectionStatic', })\n @IsArray()\n @IsString({ each: true })\n // @Matches(/^[\\w\\s\\d\\-\\/]+:[\\w\\s\\-\\/]+$/, { each: true })\n @IsOptional()\n selectionStaticValues: string[];\n\n @ApiProperty({ description: 'Type of value for selection. Applicable for type=selectionStatic,selectionDynamic', })\n @IsEnum(SelectionValueType)\n @IsOptional()\n selectionValueType: SelectionValueType;\n\n @ApiProperty({ description: 'Computed Field Value Provider. Only for type=computed', })\n @IsString()\n @IsOptional()\n computedFieldValueProvider: string;\n\n @ApiProperty({ description: 'Computed Field Value Provider Context. Only for type=computed', })\n @IsString()\n @IsOptional()\n computedFieldValueProviderCtxt: string;\n\n @ApiProperty({ description: 'Computed field value type. Only for type=computed', })\n @IsEnum(ComputedFieldValueType)\n @IsOptional()\n computedFieldValueType: ComputedFieldValueType;\n\n @IsArray()\n @Type(() => ComputedFieldTriggerConfig)\n @IsOptional()\n computedFieldTriggerConfig: ComputedFieldTriggerConfig[];\n\n @IsOptional()\n @ApiProperty({ description: 'Uuid.', })\n @IsString()\n @IsOptional()\n uuid: string;\n\n @IsOptional()\n @ApiProperty({ description: 'System fields are not included in the code generation, the assumption being that system fields have manually written code.', })\n @IsBoolean()\n isSystem: boolean;\n\n @IsOptional()\n @ApiProperty({ description: 'Marked for removal, this is used to soft delete the field.', })\n @IsBoolean()\n isMarkedForRemoval: boolean;\n\n @ApiProperty({ description: 'Column Name of Field', })\n @IsString()\n @IsOptional()\n columnName: string\n\n @ApiProperty({ description: 'Relation CoModel Column Name of Field', })\n @IsString()\n @IsOptional()\n relationCoModelColumnName: string\n\n @ApiProperty({ description: \"Is User Key\" })\n @IsOptional()\n @IsBoolean()\n readonly isUserKey: boolean\n\n @ApiProperty({ description: 'Relation Join Table Name of Field', })\n @IsString()\n @IsOptional()\n relationJoinTableName: string\n\n @ApiProperty({ description: 'Enable Audit Tracking for this field', })\n @IsOptional()\n @IsBoolean()\n enableAuditTracking?: boolean;\n\n @IsOptional()\n @ApiProperty({ description: 'Is MultiSelect Field', })\n @IsBoolean()\n isMultiSelect: boolean;\n\n @IsOptional()\n @ApiProperty({ description: 'Is Primary Key Field', })\n @IsBoolean()\n isPrimaryKey?: boolean;\n}"]}
|
|
1
|
+
{"version":3,"file":"create-field-metadata.dto.js","sourceRoot":"","sources":["../../src/dtos/create-field-metadata.dto.ts"],"names":[],"mappings":";;;;;;;;;;;;;AAAA,6CAA8C;AAC9C,yDAAoD;AACpD,oEAAgF;AAEhF,qDAUyB;AACzB,IAAY,qBAQX;AARD,WAAY,qBAAqB;IAC/B,oCAAW,CAAA;IACX,wCAAe,CAAA;IACf,sCAAa,CAAA;IACb,0CAAiB,CAAA;IACjB,0CAAiB,CAAA;IACjB,0CAAiB,CAAA;IACjB,0CAAiB,CAAA;AACnB,CAAC,EARW,qBAAqB,qCAArB,qBAAqB,QAQhC;AAED,IAAY,cAuCX;AAvCD,WAAY,cAAc;IAExB,6BAAW,CAAA;IACX,mCAAiB,CAAA;IAGjB,qCAAmB,CAAA;IAGnB,yCAAuB,CAAA;IACvB,uCAAqB,CAAA;IACrB,uCAAqB,CAAA;IACrB,+BAAa,CAAA;IAGb,qCAAmB,CAAA;IAGnB,+BAAa,CAAA;IACb,uCAAqB,CAAA;IACrB,+BAAa,CAAA;IAGb,uCAAqB,CAAA;IAGrB,6CAA2B,CAAA;IAC3B,iDAA+B,CAAA;IAE/B,iCAAe,CAAA;IACf,uCAAqB,CAAA;IAGrB,qDAAmC,CAAA;IACnC,uDAAqC,CAAA;IAErC,uCAAqB,CAAA;IAErB,+BAAa,CAAA;AACf,CAAC,EAvCW,cAAc,8BAAd,cAAc,QAuCzB;AAED,IAAY,SA4BX;AA5BD,WAAY,SAAS;IAEnB,wBAAW,CAAA;IACX,gCAAmB,CAAA;IACnB,8BAAiB,CAAA;IAIjB,gCAAmB,CAAA;IAEnB,+BAAkB,CAAA;IAClB,sCAAyB,CAAA;IACzB,kCAAqB,CAAA;IAIrB,0BAAa,CAAA;IACb,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import { Transform, Type } from 'class-transformer';\nimport { MEDIA_CATEGORIES, MediaCategory } from '../constants/media-file-types';\n\nimport {\n IsArray,\n IsBoolean,\n IsEnum,\n IsIn,\n IsInt,\n IsOptional,\n IsString,\n Matches,\n ValidateIf\n} from 'class-validator';\nexport enum RelationFieldsCommand {\n set = \"set\",\n clear = \"clear\",\n link = \"link\",\n unlink = \"unlink\",\n create = \"create\",\n update = \"update\",\n delete = \"delete\"\n}\n\nexport enum SolidFieldType {\n // numeric types\n int = 'int',\n bigint = 'bigint',\n // float = 'float',\n // double = 'double',\n decimal = 'decimal',\n\n // text types\n shortText = 'shortText',\n longtext = 'longText',\n richText = 'richText',\n json = 'json',\n\n // boolean types\n boolean = 'boolean',\n\n // date\n date = 'date',\n datetime = 'datetime',\n time = 'time',\n\n // relation\n relation = 'relation',\n\n // media\n mediaSingle = 'mediaSingle',\n mediaMultiple = 'mediaMultiple',\n\n email = 'email',\n password = 'password',\n\n // selection\n selectionStatic = 'selectionStatic',\n selectionDynamic = 'selectionDynamic',\n\n computed = 'computed',\n\n uuid = 'uuid'\n}\n\nexport enum MySQLType { //FIXME Currently this type is being used in the definition, Need to use OrmType instead\n // Numeric types\n int = 'int',\n decimal = 'decimal',\n double = 'double',\n\n // Text types\n // fieldType=shortText\n varchar = 'varchar',\n // fieldType=longText\n text = 'shortText',\n mediumtext = 'mediumtext',\n longtext = 'longtext',\n\n // Boolean types\n // fieldType=boolean\n bool = 'bool',\n boolean = 'boolean',\n\n //Date Types\n date = 'date',\n datetime = 'datetime',\n timestamp = 'timestamp',\n time = 'time',\n\n // Other types\n json = 'json',\n\n}\n\nexport enum PSQLType { //FIXME Currently this type is being used in the definition, Need to use OrmType instead\n // Numeric types\n integer = 'integer',\n decimal = 'decimal',\n bigint = 'bigint',\n\n // Text types\n varchar = 'varchar',\n text = 'text',\n\n // Boolean types\n boolean = 'boolean',\n\n // Date types\n timestamp = 'timestamp',\n timestamptz = 'timestamptz',\n time = 'time',\n date = 'date',\n\n // Other types\n json = 'json',\n jsonb = 'jsonb',\n simplejson = 'simple-json'\n}\n\nexport enum MSSQLType {\n int = \"int\",\n bigint = \"bigint\",\n decimal = \"decimal\",\n numeric = \"numeric\",\n varchar = \"varchar\",\n nvarchar = \"nvarchar\",\n simplejson = \"simple-json\",\n text = \"text\",\n bit = \"bit\",\n date = \"date\",\n datetime = \"datetime\",\n datetime2 = \"datetime2\",\n time = \"time\",\n uniqueidentifier = \"uniqueidentifier\"\n}\n\nexport const ALL_ORM_TYPES = [\n ...Object.values(PSQLType),\n ...Object.values(MSSQLType),\n ...Object.values(MySQLType),\n] as const;\n\nexport type OrmType = typeof ALL_ORM_TYPES[number];\n\n// export type OrmType = PSQLType | MySQLType | MSSQLType;\n\nexport enum EncryptionType {\n aes128 = 'aes-128',\n aes256 = 'aes-256',\n}\n\nexport enum DecryptWhenType {\n beforeTransit = 'before-transit',\n afterTransit = 'after-transit',\n}\n\nexport type MediaType = MediaCategory;\n\nexport enum RelationType {\n manyToOne = 'many-to-one',\n manyTomany = 'many-to-many',\n oneToMany = 'one-to-many',\n}\n\nexport enum CascadeType {\n setNull = 'set null',\n restrict = 'restrict',\n cascade = 'cascade',\n}\n\n// export enum MediaStorageProviderType {\n// database = 'database',\n// file = 'file',\n// s3 = 's3',\n// }\n\nexport enum SelectionValueType {\n string = 'string',\n int = 'int',\n}\n\nexport enum ComputedFieldValueType {\n string = 'string',\n int = 'int',\n decimal = 'decimal',\n boolean = 'boolean',\n date = 'date',\n datetime = 'datetime',\n}\n\nexport enum ComputedFieldTriggerOperation {\n beforeInsert = \"before-insert\",\n afterInsert = \"after-insert\",\n beforeUpdate = \"before-update\",\n afterUpdate = \"after-update\",\n beforeRemove = \"before-delete\",\n afterRemove = \"after-delete\",\n}\n\nexport class ComputedFieldTriggerConfig {\n moduleName: string; // Name of the module where the computed field is defined\n modelName: string;\n operations: ComputedFieldTriggerOperation[]; // List of operations where this computed field should be triggered\n}\n\nexport class CreateFieldMetadataDto {\n @ApiProperty({ description: 'Name of your field, this is also the name of the column or attribute', })\n // @Matches(/[a-z]+(_[a-z]+)*/, { message: 'Field name should follow snake case conventions only with all lower case.', })\n @IsString()\n name: string;\n\n @ApiProperty({ description: 'Display name of your field' })\n @IsString()\n readonly displayName: string;\n\n\n @ApiProperty({ description: 'Description of your field' })\n @IsOptional()\n @IsString()\n readonly description: string;\n\n // @ApiProperty({ description: \"Help text associated with this field\" })\n // @IsString()\n // readonly helpText: string;\n\n @ApiProperty({ description: 'Field can have types' })\n @IsEnum(SolidFieldType)\n readonly type: SolidFieldType;\n\n @ApiProperty({ description: 'Related model id' })\n @IsInt()\n @IsOptional()\n readonly modelId: number;\n\n //For all types of fields\n @ApiProperty({ description: 'Field can have orm types specific to your database', })\n @IsIn(ALL_ORM_TYPES)\n @IsOptional()\n readonly ormType: OrmType;\n\n @ApiProperty({ description: 'Length of the field. Only for type=text' })\n @IsInt()\n @IsOptional()\n readonly length: number;\n\n @ApiProperty({ description: 'Default value of the field' })\n @IsString()\n @IsOptional()\n readonly defaultValue: string;\n\n @ApiProperty({ description: 'Format regex pattern for the field. Only for type=text, longText, email, password', })\n @IsString()\n @IsOptional()\n readonly regexPattern: string;\n\n @ApiProperty({ description: 'If the regex pattern matching fails, then what is the error message to be displayed', })\n @IsString()\n @IsOptional()\n readonly regexPatternNotMatchingErrorMsg: string;\n\n @ApiProperty({ description: 'Is the field mandatory?' })\n @IsBoolean()\n readonly required: boolean;\n\n @ApiProperty({ description: 'Is the field value unique?' })\n @IsBoolean()\n @IsOptional()\n readonly unique: boolean;\n\n @ApiProperty({ description: 'Is the field symmetric encrypted?' })\n @IsBoolean()\n readonly encrypt: boolean;\n\n @ApiProperty({ description: 'Type of encryption. Only if encrypt=true' })\n @IsEnum(EncryptionType)\n @IsOptional()\n readonly encryptionType: EncryptionType;\n\n //Pending\n @ApiProperty({ description: 'At what point do we want to decrypt the data? Only if encrypt=true', })\n @IsEnum(DecryptWhenType)\n @IsOptional()\n decryptWhen: DecryptWhenType;\n\n @ApiProperty({ description: 'Is the field indexed? For all types, except:richText, longText', })\n @IsBoolean()\n index: boolean;\n\n @ApiProperty({ description: 'for text fields, this is length. for numeric fields, this is the range of values allowed. Only for type=shortText,longText,richText,json,int,decimal,date,dateTime,time', })\n @IsInt()\n @IsOptional()\n max: number;\n\n @ApiProperty({ description: 'for text fields, this is length. for numeric fields, this is the range of values allowed. Only for type=shortText,longText,richText,json,int,decimal,date,dateTime,time', })\n @IsInt()\n @IsOptional()\n min: number;\n\n @ApiProperty({ description: 'Is the field private?' })\n @IsBoolean()\n private: boolean;\n\n @ApiProperty({ description: 'Allowed media types for the field. Only for type=mediaSingle,mediaMultiple', })\n @IsIn([...MEDIA_CATEGORIES], { each: true })\n @IsOptional()\n mediaTypes: MediaType[];\n\n @ApiProperty({ description: 'Maximum size of the media in KB. Only for type=mediaSingle,mediaMultiple', })\n @IsInt()\n @IsOptional()\n mediaMaxSizeKb: number;\n\n @ApiProperty({ description: 'Configured Media storage provider. Only for type=mediaSingle,mediaMultiple', })\n @IsInt()\n @IsOptional()\n mediaStorageProviderId?: number;\n\n @ApiProperty({ description: 'Configured Media storage provider. Only for type=mediaSingle,mediaMultiple. When you need to specify the storage provider by name.', })\n @IsInt()\n @IsOptional()\n mediaStorageProviderUserKey?: string;\n\n // @ApiProperty({ description: 'Is the media embedded in the entity table? Only for type=mediaSingle', })\n // @IsBoolean()\n // @IsOptional()\n // mediaEmbedded: boolean;\n\n @ApiProperty({ description: 'Relation Type. Only for type=relation' })\n @IsEnum(RelationType)\n @IsOptional()\n relationType: RelationType;\n\n @ApiProperty({ description: 'Related model for the relation. Only for type=relation' })\n @IsString()\n @IsOptional()\n relationCoModelSingularName: string;\n\n @ApiProperty({ description: 'Create inverse relation. Only for type=relation', })\n @IsBoolean()\n @IsOptional()\n relationCreateInverse: boolean;\n\n @ApiProperty({ description: 'Cascade type. Only for type=relation' })\n @IsEnum(CascadeType)\n @IsOptional()\n relationCascade: CascadeType;\n\n @ApiProperty({ description: 'Related field module. Only required for type=relation, if the related field belongs to a different module' })\n @IsOptional()\n relationModelModuleName: string;\n\n @ApiProperty({ description: 'Related field module. Only required for type=relation and relationType=many-to-many, i.e if the related many to many field belongs to a different model' })\n @IsOptional()\n relationCoModelFieldName: string;\n\n @ApiProperty({ description: 'Only for type=relation, many-to-many. This field is used to set the owner of the many-to-many relation' })\n @IsOptional()\n isRelationManyToManyOwner: boolean;\n\n\n @ApiProperty({ description: 'Only for type=relation, many-to-many. This field is used to store fixed filters that needs to applied on related model' })\n @IsOptional()\n relationFieldFixedFilter: string;\n\n @ApiProperty({\n description:\n 'Dynamic provider for selection. Only for type=selectionDynamic',\n })\n @IsString()\n @IsOptional()\n selectionDynamicProvider: string;\n\n @ApiProperty({ description: 'Dynamic provider Context. Only for type=selectionDynamic', })\n @IsString()\n @IsOptional()\n selectionDynamicProviderCtxt: string;\n\n @ApiProperty({ description: 'Static values for selection. Only for type=selectionStatic', })\n @IsArray()\n @IsString({ each: true })\n // @Matches(/^[\\w\\s\\d\\-\\/]+:[\\w\\s\\-\\/]+$/, { each: true })\n @IsOptional()\n selectionStaticValues: string[];\n\n @ApiProperty({ description: 'Type of value for selection. Applicable for type=selectionStatic,selectionDynamic', })\n @IsEnum(SelectionValueType)\n @IsOptional()\n selectionValueType: SelectionValueType;\n\n @ApiProperty({ description: 'Computed Field Value Provider. Only for type=computed', })\n @IsString()\n @IsOptional()\n computedFieldValueProvider: string;\n\n @ApiProperty({ description: 'Computed Field Value Provider Context. Only for type=computed', })\n @IsString()\n @IsOptional()\n computedFieldValueProviderCtxt: string;\n\n @ApiProperty({ description: 'Computed field value type. Only for type=computed', })\n @IsEnum(ComputedFieldValueType)\n @IsOptional()\n computedFieldValueType: ComputedFieldValueType;\n\n @IsArray()\n @Type(() => ComputedFieldTriggerConfig)\n @IsOptional()\n computedFieldTriggerConfig: ComputedFieldTriggerConfig[];\n\n @IsOptional()\n @ApiProperty({ description: 'Uuid.', })\n @IsString()\n @IsOptional()\n uuid: string;\n\n @IsOptional()\n @ApiProperty({ description: 'System fields are not included in the code generation, the assumption being that system fields have manually written code.', })\n @IsBoolean()\n isSystem: boolean;\n\n @IsOptional()\n @ApiProperty({ description: 'Marked for removal, this is used to soft delete the field.', })\n @IsBoolean()\n isMarkedForRemoval: boolean;\n\n @ApiProperty({ description: 'Column Name of Field', })\n @IsString()\n @IsOptional()\n columnName: string\n\n @ApiProperty({ description: 'Relation CoModel Column Name of Field', })\n @IsString()\n @IsOptional()\n relationCoModelColumnName: string\n\n @ApiProperty({ description: \"Is User Key\" })\n @IsOptional()\n @IsBoolean()\n readonly isUserKey: boolean\n\n @ApiProperty({ description: 'Relation Join Table Name of Field', })\n @IsString()\n @IsOptional()\n relationJoinTableName: string\n\n @ApiProperty({ description: 'Enable Audit Tracking for this field', })\n @IsOptional()\n @IsBoolean()\n enableAuditTracking?: boolean;\n\n @IsOptional()\n @ApiProperty({ description: 'Is MultiSelect Field', })\n @IsBoolean()\n isMultiSelect: boolean;\n\n @IsOptional()\n @ApiProperty({ description: 'Is Primary Key Field', })\n @IsBoolean()\n isPrimaryKey?: boolean;\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"create-model-sequence.dto.d.ts","sourceRoot":"","sources":["../../src/dtos/create-model-sequence.dto.ts"],"names":[],"mappings":"AAKA,qBAAa,sBAAsB;IAI/B,QAAQ,EAAE,MAAM,CAAC;IAIjB,aAAa,EAAE,MAAM,CAAC;IAItB,OAAO,EAAE,MAAM,CAAC;IAIhB,YAAY,EAAE,MAAM,CAAC;IAIrB,OAAO,EAAE,MAAM,CAAC;IAIhB,YAAY,EAAE,MAAM,CAAC;IAIrB,YAAY,EAAE,MAAM,CAAC;IAIrB,YAAY,EAAE,MAAM,CAAC;
|
|
1
|
+
{"version":3,"file":"create-model-sequence.dto.d.ts","sourceRoot":"","sources":["../../src/dtos/create-model-sequence.dto.ts"],"names":[],"mappings":"AAKA,qBAAa,sBAAsB;IAI/B,QAAQ,EAAE,MAAM,CAAC;IAIjB,aAAa,EAAE,MAAM,CAAC;IAItB,OAAO,EAAE,MAAM,CAAC;IAIhB,YAAY,EAAE,MAAM,CAAC;IAIrB,OAAO,EAAE,MAAM,CAAC;IAIhB,YAAY,EAAE,MAAM,CAAC;IAIrB,YAAY,EAAE,MAAM,CAAC;IAIrB,YAAY,CAAC,EAAE,MAAM,CAAC;IAItB,MAAM,EAAE,MAAM,CAAC;IAIf,OAAO,EAAE,MAAM,CAAC;IAIhB,SAAS,EAAE,MAAM,CAAC;CACrB"}
|
|
@@ -17,7 +17,7 @@ const class_validator_2 = require("class-validator");
|
|
|
17
17
|
const class_validator_3 = require("class-validator");
|
|
18
18
|
class CreateModelSequenceDto {
|
|
19
19
|
static _OPENAPI_METADATA_FACTORY() {
|
|
20
|
-
return { moduleId: { required: true, type: () => Number }, moduleUserKey: { required: true, type: () => String }, modelId: { required: true, type: () => Number }, modelUserKey: { required: true, type: () => String }, fieldId: { required: true, type: () => Number }, fieldUserKey: { required: true, type: () => String }, sequenceName: { required: true, type: () => String }, currentValue: { required:
|
|
20
|
+
return { moduleId: { required: true, type: () => Number }, moduleUserKey: { required: true, type: () => String }, modelId: { required: true, type: () => Number }, modelUserKey: { required: true, type: () => String }, fieldId: { required: true, type: () => Number }, fieldUserKey: { required: true, type: () => String }, sequenceName: { required: true, type: () => String }, currentValue: { required: false, type: () => Number }, prefix: { required: true, type: () => String }, padding: { required: true, type: () => Number }, separator: { required: true, type: () => String } };
|
|
21
21
|
}
|
|
22
22
|
}
|
|
23
23
|
exports.CreateModelSequenceDto = CreateModelSequenceDto;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"create-model-sequence.dto.js","sourceRoot":"","sources":["../../src/dtos/create-model-sequence.dto.ts"],"names":[],"mappings":";;;;;;;;;;;;;AAAA,6CAA8C;AAC9C,qDAAwC;AACxC,qDAA6C;AAC7C,qDAAuD;AAEvD,MAAa,sBAAsB;;;;CA6ClC;AA7C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BAAQ,GAAE;IACV,IAAA,4BAAU,GAAE;IACZ,IAAA,qBAAW,GAAE;;4DACO;AAIrB;IAHC,IAAA,4BAAU,GAAE;IACZ,IAAA,uBAAK,GAAE;IACP,IAAA,qBAAW,GAAE;;uDACE;AAIhB;IAHC,IAAA,0BAAQ,GAAE;IACV,IAAA,4BAAU,GAAE;IACZ,IAAA,qBAAW,GAAE;;4DACO;AAIrB;IAHC,IAAA,4BAAU,GAAE;IACZ,IAAA,0BAAQ,GAAE;IACV,IAAA,qBAAW,GAAE;;4DACO;AAIrB;IAHC,IAAA,4BAAU,GAAE;IACZ,IAAA,uBAAK,GAAE;IACP,IAAA,qBAAW,GAAE;;4DACQ;AAItB;IAHC,IAAA,4BAAU,GAAE;IACZ,IAAA,0BAAQ,GAAE;IACV,IAAA,qBAAW,GAAE;;sDACC;AAIf;IAHC,IAAA,4BAAU,GAAE;IACZ,IAAA,uBAAK,GAAE;IACP,IAAA,qBAAW,GAAE;;uDACE;AAIhB;IAHC,IAAA,4BAAU,GAAE;IACZ,IAAA,0BAAQ,GAAE;IACV,IAAA,qBAAW,GAAE;;yDACI","sourcesContent":["import { ApiProperty } from '@nestjs/swagger';\nimport { IsInt } from 'class-validator';\nimport { IsOptional } from 'class-validator';\nimport { IsString, IsNotEmpty } from 'class-validator';\n\nexport class CreateModelSequenceDto {\n @IsOptional()\n @IsInt()\n @ApiProperty()\n moduleId: number;\n @IsString()\n @IsOptional()\n @ApiProperty()\n moduleUserKey: string;\n @IsOptional()\n @IsInt()\n @ApiProperty()\n modelId: number;\n @IsString()\n @IsOptional()\n @ApiProperty()\n modelUserKey: string;\n @IsOptional()\n @IsInt()\n @ApiProperty()\n fieldId: number;\n @IsString()\n @IsOptional()\n @ApiProperty()\n fieldUserKey: string;\n @IsNotEmpty()\n @IsString()\n @ApiProperty()\n sequenceName: string;\n @IsOptional()\n @IsInt()\n @ApiProperty()\n currentValue?: number;\n @IsOptional()\n @IsString()\n @ApiProperty()\n prefix: string;\n @IsOptional()\n @IsInt()\n @ApiProperty()\n padding: number;\n @IsOptional()\n @IsString()\n @ApiProperty()\n separator: string;\n}"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"http-exception.filter.d.ts","sourceRoot":"","sources":["../../src/filters/http-exception.filter.ts"],"names":[],"mappings":"AACA,OAAO,EACH,eAAe,EAEf,aAAa,EAIhB,MAAM,gBAAgB,CAAC;AAGxB,OAAO,EAAE,kBAAkB,EAAE,MAAM,kCAAkC,CAAC;AAItE,qBAEa,mBAAoB,YAAW,eAAe;IAG3C,OAAO,CAAC,QAAQ,CAAC,WAAW;IAFxC,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAwC;gBAElC,WAAW,EAAE,kBAAkB;IAI5D,KAAK,CAAC,SAAS,EAAE,GAAG,EAAE,IAAI,EAAE,aAAa;
|
|
1
|
+
{"version":3,"file":"http-exception.filter.d.ts","sourceRoot":"","sources":["../../src/filters/http-exception.filter.ts"],"names":[],"mappings":"AACA,OAAO,EACH,eAAe,EAEf,aAAa,EAIhB,MAAM,gBAAgB,CAAC;AAGxB,OAAO,EAAE,kBAAkB,EAAE,MAAM,kCAAkC,CAAC;AAItE,qBAEa,mBAAoB,YAAW,eAAe;IAG3C,OAAO,CAAC,QAAQ,CAAC,WAAW;IAFxC,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAwC;gBAElC,WAAW,EAAE,kBAAkB;IAI5D,KAAK,CAAC,SAAS,EAAE,GAAG,EAAE,IAAI,EAAE,aAAa;CAoD5C"}
|
|
@@ -26,10 +26,14 @@ let HttpExceptionFilter = HttpExceptionFilter_1 = class HttpExceptionFilter {
|
|
|
26
26
|
const request = ctx.getRequest();
|
|
27
27
|
const isHttp = exception instanceof common_1.HttpException;
|
|
28
28
|
const explicitStatus = isHttp ? exception.getStatus() : undefined;
|
|
29
|
+
const rawStatus = exception?.status ?? exception?.statusCode;
|
|
30
|
+
const derivedStatus = typeof rawStatus === 'number' && rawStatus >= 400 && rawStatus < 600
|
|
31
|
+
? rawStatus
|
|
32
|
+
: undefined;
|
|
29
33
|
const code = this.errorMapper.mapException(exception);
|
|
30
34
|
const defaultStatus = this.errorMapper.getHttpStatus(code);
|
|
31
35
|
const message = code === 'solidx-unknown-error' ? `${exception?.message}` : this.errorMapper.getMessage(code);
|
|
32
|
-
const status = explicitStatus ?? defaultStatus ?? 500;
|
|
36
|
+
const status = explicitStatus ?? derivedStatus ?? defaultStatus ?? 500;
|
|
33
37
|
this.logger.error(`[${status} ${logging_interceptor_1.HttpStatusCodeMessages[status] || 'Internal Server Error'}] ${request?.method} ${request?.url} - ${exception?.message || message} [code=${code}]`);
|
|
34
38
|
if (exception?.stack) {
|
|
35
39
|
this.logger.error(exception.stack);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"http-exception.filter.js","sourceRoot":"","sources":["../../src/filters/http-exception.filter.ts"],"names":[],"mappings":";;;;;;;;;;;;;AACA,2CAOwB;AAExB,6EAA6E;AAC7E,0EAAsE;AAM/D,IAAM,mBAAmB,2BAAzB,MAAM,mBAAmB;IAG5B,YAA6B,WAA+B;QAA/B,gBAAW,GAAX,WAAW,CAAoB;QAF3C,WAAM,GAAG,IAAI,eAAM,CAAC,qBAAmB,CAAC,IAAI,CAAC,CAAC;QAG3D,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,iCAAiC,CAAC,CAAC;IACzD,CAAC;IAED,KAAK,CAAC,SAAc,EAAE,IAAmB;QACrC,MAAM,GAAG,GAAG,IAAI,CAAC,YAAY,EAAE,CAAC;QAChC,MAAM,QAAQ,GAAG,GAAG,CAAC,WAAW,EAAY,CAAC;QAC7C,MAAM,OAAO,GAAG,GAAG,CAAC,UAAU,EAAW,CAAC;QAE1C,MAAM,MAAM,GAAG,SAAS,YAAY,sBAAa,CAAC;QAClD,MAAM,cAAc,GAAG,MAAM,CAAC,CAAC,CAAC,SAAS,CAAC,SAAS,EAAE,CAAC,CAAC,CAAC,SAAS,CAAC;
|
|
1
|
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I,CAAC,WAAW,CAAC,UAAU,CAAC,IAAI,CAAC,CAAC;QAI9G,MAAM,MAAM,GAAG,cAAc,IAAI,aAAa,IAAI,aAAa,IAAI,GAAG,CAAC;QAGvE,IAAI,CAAC,MAAM,CAAC,KAAK,CACb,IAAI,MAAM,IAAI,4CAAsB,CAAC,MAAM,CAAC,IAAI,uBAAuB,KAAK,OAAO,EAAE,MAAM,IAAI,OAAO,EAAE,GAAG,MAAM,SAAS,EAAE,OAAO,IAAI,OAAO,UAAU,IAAI,GAAG,CAClK,CAAC;QACF,IAAI,SAAS,EAAE,KAAK,EAAE,CAAC;YACnB,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC;QACvC,CAAC;QAGD,MAAM,KAAK,GACP,CAAC,MAAM,IAAK,SAAS,CAAC,WAAW,EAAE,EAAU,CAAC;YAC9C,SAAS,EAAE,QAAQ;YACnB,EAAE,CAAC;QAGP,QAAQ,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC,IAAI,CAAC;YACzB,UAAU,EAAE,MAAM;YAClB,iBAAiB,EAAE,4CAAsB,CAAC,MAAM,CAAC,IAAI,uBAAuB;YAE5E,OAAO,EAAE,OAAO;YAChB,SAAS,EAAE,IAAI;YACf,KAAK,EAAE,OAAO;YAGd,IAAI,EAAE,KAAK;SACd,CAAC,CAAC;IACP,CAAC;CACJ,CAAA;AA3DY,kDAAmB;8BAAnB,mBAAmB;IAF/B,IAAA,cAAK,GAAE;IACP,IAAA,mBAAU,GAAE;qCAIiC,yCAAkB;GAHnD,mBAAmB,CA2D/B","sourcesContent":["// src/common/filters/http-exception.filter.ts\nimport {\n ExceptionFilter,\n Catch,\n ArgumentsHost,\n Logger,\n Injectable,\n HttpException,\n} from '@nestjs/common';\nimport { Response, Request } from 'express';\nimport { HttpStatusCodeMessages } from '../interceptors/logging.interceptor';\nimport { ErrorMapperService } from 'src/helpers/error-mapper.service';\nimport { ErrorCode } from 'src/interfaces';\n\n\n@Catch()\n@Injectable()\nexport class HttpExceptionFilter implements ExceptionFilter {\n private readonly logger = new Logger(HttpExceptionFilter.name);\n\n constructor(private readonly errorMapper: ErrorMapperService) {\n this.logger.debug('HttpExceptionFilter initialized');\n }\n\n catch(exception: any, host: ArgumentsHost) {\n const ctx = host.switchToHttp();\n const response = ctx.getResponse<Response>();\n const request = ctx.getRequest<Request>();\n\n const isHttp = exception instanceof HttpException;\n const explicitStatus = isHttp ? exception.getStatus() : undefined;\n\n // Errors from http-errors-style libraries (e.g. body-parser's PayloadTooLargeError)\n // are plain Errors carrying their own status. Honour it rather than collapsing to 500.\n const rawStatus = exception?.status ?? exception?.statusCode;\n const derivedStatus =\n typeof rawStatus === 'number' && rawStatus >= 400 && rawStatus < 600\n ? rawStatus\n : undefined;\n\n // Canonical code + static message\n const code: ErrorCode = this.errorMapper.mapException(exception);\n const defaultStatus = this.errorMapper.getHttpStatus(code);\n const message = code === 'solidx-unknown-error' ? `${exception?.message}` : this.errorMapper.getMessage(code);\n\n // derivedStatus must precede defaultStatus: getHttpStatus() returns a hard 500\n // for unmatched codes, so it is never undefined and would always win otherwise.\n const status = explicitStatus ?? derivedStatus ?? defaultStatus ?? 500;\n\n // Logging\n this.logger.error(\n `[${status} ${HttpStatusCodeMessages[status] || 'Internal Server Error'}] ${request?.method} ${request?.url} - ${exception?.message || message} [code=${code}]`,\n );\n if (exception?.stack) {\n this.logger.error(exception.stack);\n }\n\n // Preserve any extra data the exception carried (optional)\n const extra =\n (isHttp && (exception.getResponse?.() as any)) ??\n exception?.response ??\n {};\n\n // Keep your legacy shape; add canonical code\n response.status(status).json({\n statusCode: status,\n statusCodeMessage: HttpStatusCodeMessages[status] || 'Internal Server Error',\n // Keeping this for backward compatibility..\n message: message,\n errorCode: code,\n error: message,\n // We can make this conditional based on whether we are running in prod mode or dev mode...\n // errorStack: exception.stack,\n data: extra,\n });\n }\n}"]}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { NestExpressApplication } from '@nestjs/platform-express';
|
|
2
|
+
import { PermissionsPolicyConfig, SolidSecurityOptions } from './security.helper';
|
|
2
3
|
export interface SolidSwaggerOptions {
|
|
3
4
|
title?: string;
|
|
4
5
|
description?: string;
|
|
@@ -8,8 +9,10 @@ export interface SolidBootstrapOptions {
|
|
|
8
9
|
globalPrefix?: string;
|
|
9
10
|
swagger?: SolidSwaggerOptions | false;
|
|
10
11
|
permissionsPolicyOverrides?: Partial<PermissionsPolicyConfig>;
|
|
12
|
+
security?: SolidSecurityOptions;
|
|
11
13
|
verboseBootstrap?: boolean;
|
|
14
|
+
bodyLimit?: string;
|
|
12
15
|
}
|
|
13
|
-
export declare function bootstrapSolidApp(appModuleFactory: () => Promise<any>, options?: SolidBootstrapOptions): Promise<
|
|
16
|
+
export declare function bootstrapSolidApp(appModuleFactory: () => Promise<any>, options?: SolidBootstrapOptions): Promise<NestExpressApplication>;
|
|
14
17
|
export declare function bootstrapSolidCli(appModuleFactory: () => Promise<any>): Promise<void>;
|
|
15
18
|
//# sourceMappingURL=bootstrap.helper.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"bootstrap.helper.d.ts","sourceRoot":"","sources":["../../src/helpers/bootstrap.helper.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"bootstrap.helper.d.ts","sourceRoot":"","sources":["../../src/helpers/bootstrap.helper.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,sBAAsB,EAAE,MAAM,0BAA0B,CAAC;AAalE,OAAO,EAGL,uBAAuB,EACvB,oBAAoB,EACrB,MAAM,mBAAmB,CAAC;AAyB3B,MAAM,WAAW,mBAAmB;IAClC,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB;AAED,MAAM,WAAW,qBAAqB;IAEpC,YAAY,CAAC,EAAE,MAAM,CAAC;IAEtB,OAAO,CAAC,EAAE,mBAAmB,GAAG,KAAK,CAAC;IAEtC,0BAA0B,CAAC,EAAE,OAAO,CAAC,uBAAuB,CAAC,CAAC;IAE9D,QAAQ,CAAC,EAAE,oBAAoB,CAAC;IAEhC,gBAAgB,CAAC,EAAE,OAAO,CAAC;IAM3B,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAeD,wBAAsB,iBAAiB,CACrC,gBAAgB,EAAE,MAAM,OAAO,CAAC,GAAG,CAAC,EACpC,OAAO,GAAE,qBAA0B,GAClC,OAAO,CAAC,sBAAsB,CAAC,CAgJjC;AAgBD,wBAAsB,iBAAiB,CACrC,gBAAgB,EAAE,MAAM,OAAO,CAAC,GAAG,CAAC,GACnC,OAAO,CAAC,IAAI,CAAC,CAwCf"}
|
|
@@ -36,10 +36,11 @@ function registerGlobalProcessHandlers() {
|
|
|
36
36
|
}
|
|
37
37
|
async function bootstrapSolidApp(appModuleFactory, options = {}) {
|
|
38
38
|
registerGlobalProcessHandlers();
|
|
39
|
-
const { globalPrefix = 'api', swagger = {}, permissionsPolicyOverrides = {}, verboseBootstrap = false } = options;
|
|
39
|
+
const { globalPrefix = 'api', swagger = {}, permissionsPolicyOverrides = {}, security = {}, verboseBootstrap = false, bodyLimit = '25mb', } = options;
|
|
40
40
|
const startTime = Date.now();
|
|
41
41
|
const appModule = await appModuleFactory();
|
|
42
42
|
const app = await core_1.NestFactory.create(appModule, {
|
|
43
|
+
bodyParser: false,
|
|
43
44
|
logger: nest_winston_1.WinstonModule.createLogger({ ...(0, winston_logger_1.createWinstonLoggerConfig)(), level: verboseBootstrap ? 'debug' : 'error' }),
|
|
44
45
|
});
|
|
45
46
|
const apiEnabled = (0, environment_helper_1.parseBooleanEnv)('API_ENABLED', true);
|
|
@@ -48,11 +49,11 @@ async function bootstrapSolidApp(appModuleFactory, options = {}) {
|
|
|
48
49
|
app
|
|
49
50
|
.get(nest_winston_1.WINSTON_MODULE_NEST_PROVIDER)
|
|
50
51
|
.log('API server disabled via API_ENABLED=false. Skipping HTTP listen.', 'Bootstrap');
|
|
51
|
-
return;
|
|
52
|
+
return app;
|
|
52
53
|
}
|
|
53
54
|
const server = app.getHttpAdapter().getInstance();
|
|
54
55
|
server.get('/', (_req, res) => res.status(200).send('SOLID OK'));
|
|
55
|
-
app.use((0, helmet_1.default)((0, security_helper_1.buildDefaultSecurityHeaderOptions)()));
|
|
56
|
+
app.use((0, helmet_1.default)((0, security_helper_1.buildDefaultSecurityHeaderOptions)(security)));
|
|
56
57
|
const isSwaggerPath = (path) => path === '/docs' ||
|
|
57
58
|
path === '/docs/' ||
|
|
58
59
|
path.startsWith('/docs/') ||
|
|
@@ -82,6 +83,8 @@ async function bootstrapSolidApp(appModuleFactory, options = {}) {
|
|
|
82
83
|
}
|
|
83
84
|
next();
|
|
84
85
|
});
|
|
86
|
+
app.useBodyParser('json', { limit: bodyLimit });
|
|
87
|
+
app.useBodyParser('urlencoded', { limit: bodyLimit, extended: true });
|
|
85
88
|
app.useGlobalPipes(new common_1.ValidationPipe({
|
|
86
89
|
transform: true,
|
|
87
90
|
transformOptions: { enableImplicitConversion: true },
|
|
@@ -116,6 +119,7 @@ async function bootstrapSolidApp(appModuleFactory, options = {}) {
|
|
|
116
119
|
app.useLogger(app.get(nest_winston_1.WINSTON_MODULE_NEST_PROVIDER));
|
|
117
120
|
const elapsed = ((Date.now() - startTime) / 1000).toFixed(2);
|
|
118
121
|
process.stdout.write(`\x1b[32mServer started on port ${port} in ${elapsed}s\x1b[0m\n`);
|
|
122
|
+
return app;
|
|
119
123
|
}
|
|
120
124
|
async function bootstrapSolidCli(appModuleFactory) {
|
|
121
125
|
registerGlobalProcessHandlers();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"bootstrap.helper.js","sourceRoot":"","sources":["../../src/helpers/bootstrap.helper.ts"],"names":[],"mappings":";;;;;AAoEA,8CAiIC;AAgBD,8CA0CC;AA/PD,2CAA4E;AAC5E,uCAAsD;AACtD,qDAAgD;AAChD,6C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G,CAAC,iBAAiB,GAAG,MAAM,CAAC;IAGvC,MAAM,GAAG,GAAG,MAAM,+BAAc,CAAC,oBAAoB,CAAC,SAAS,EAAE;QAC/D,MAAM,EAAE,QAAQ,CAAC,CAAC,CAAC,CAAC,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,SAAS,EAAE,MAAM,CAAC,CAAC,CAAC,CAAC,KAAK;KACjF,CAAC,CAAC;IAEH,IAAI,CAAC;QACH,MAAM,+BAAc,CAAC,cAAc,CAAC,GAAG,CAAC,CAAC;IAC3C,CAAC;IAAC,OAAO,CAAC,EAAE,CAAC;QACX,OAAO,CAAC,KAAK,CAAC,sCAAsC,EAAE,CAAC,CAAC,CAAC;QACzD,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;IAClB,CAAC;IAED,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;AAClB,CAAC","sourcesContent":["import { ClassSerializerInterceptor, ValidationPipe } from '@nestjs/common';\nimport { NestFactory, Reflector } from '@nestjs/core';\nimport { WsAdapter } from '@nestjs/platform-ws';\nimport { DocumentBuilder, SwaggerModule } from '@nestjs/swagger';\nimport { NextFunction, Request, Response } from 'express';\nimport helmet from 'helmet';\nimport qs from 'qs';\nimport { existsSync } from 'fs';\nimport { resolve } from 'path';\nimport { WINSTON_MODULE_NEST_PROVIDER, WinstonModule } from 'nest-winston';\nimport { CommandFactory } from 'nest-commander';\nimport { createWinstonLoggerConfig } from '../winston.logger';\nimport { WrapResponseInterceptor } from '../interceptors/wrap-response.interceptor';\nimport { buildDefaultCorsOptions } from './cors.helper';\nimport { buildDefaultSecurityHeaderOptions, buildPermissionsPolicyHeader, PermissionsPolicyConfig } from './security.helper';\nimport { parseBooleanEnv } from './environment.helper';\n\n// ---- Shared process handlers ----\n\nfunction registerGlobalProcessHandlers() {\n process.on('unhandledRejection', (reason, promise) => {\n console.error('Unhandled Rejection at:', promise, 'reason:', reason);\n });\n\n process.on('uncaughtException', (err) => {\n console.error('Uncaught Exception thrown:', err);\n });\n\n // Suppress pg deprecation warning caused by TypeORM's internal query scheduling\n process.on('warning', (warning) => {\n if (warning.name === 'DeprecationWarning' && (warning.message.includes('client.query()') || warning.message.includes('punycode'))) {\n return;\n }\n console.warn(warning);\n });\n}\n\n// ---- HTTP server bootstrap ----\n\nexport interface SolidSwaggerOptions {\n title?: string;\n description?: string;\n version?: string;\n}\n\nexport interface SolidBootstrapOptions {\n /** Global API prefix. Defaults to 'api'. Set to '' to disable. */\n globalPrefix?: string;\n /** Swagger configuration. Set to false to disable Swagger entirely. */\n swagger?: SolidSwaggerOptions | false;\n /** Permissions-Policy header overrides (merged with defaults). */\n permissionsPolicyOverrides?: Partial<PermissionsPolicyConfig>;\n /** Show full NestJS init logs during bootstrap (route mapping, module deps, pollers). Defaults to false. */\n verboseBootstrap?: boolean;\n}\n\n/**\n * Bootstraps a SolidX NestJS HTTP application with sensible defaults:\n * security headers, CORS, Winston logger, ValidationPipe,\n * WrapResponseInterceptor, qs deep query parsing, Swagger, and the\n * pg BIGINT type parser.\n *\n * @example\n * // main.ts\n * bootstrapSolidApp(() => AppModule.forRoot(), {\n * swagger: { title: 'My API', description: 'My API description' },\n * });\n */\nexport async function bootstrapSolidApp(\n appModuleFactory: () => Promise<any>,\n options: SolidBootstrapOptions = {},\n): Promise<void> {\n registerGlobalProcessHandlers();\n\n const { globalPrefix = 'api', swagger = {}, permissionsPolicyOverrides = {}, verboseBootstrap = false } = options;\n\n const startTime = Date.now();\n const appModule = await appModuleFactory();\n const app = await NestFactory.create(appModule, {\n logger: WinstonModule.createLogger({ ...createWinstonLoggerConfig(), level: verboseBootstrap ? 'debug' : 'error' }),\n });\n\n const apiEnabled = parseBooleanEnv('API_ENABLED', true);\n\n if (!apiEnabled) {\n await app.init();\n app\n .get(WINSTON_MODULE_NEST_PROVIDER)\n .log('API server disabled via API_ENABLED=false. Skipping HTTP listen.', 'Bootstrap');\n return;\n }\n\n // Health check at root path\n const server = app.getHttpAdapter().getInstance();\n server.get('/', (_req, res) => res.status(200).send('SOLID OK'));\n\n // Security headers\n app.use(helmet(buildDefaultSecurityHeaderOptions()));\n\n // Nest's Swagger UI HTML injects inline styles; keep CSP strict elsewhere.\n const isSwaggerPath = (path: string) =>\n path === '/docs' ||\n path === '/docs/' ||\n path.startsWith('/docs/') ||\n path === '/docs-json' ||\n path === '/docs-yaml';\n\n app.use((req: Request, res: Response, next: NextFunction) => {\n if (isSwaggerPath(req.path)) {\n res.removeHeader('Content-Security-Policy');\n }\n next();\n });\n\n // Permissions-Policy header\n app.use((_req: Request, res: Response, next: NextFunction) => {\n res.setHeader('Permissions-Policy', buildPermissionsPolicyHeader(permissionsPolicyOverrides));\n next();\n });\n\n const port = process.env.PORT || 3000;\n\n if (globalPrefix) {\n app.setGlobalPrefix(globalPrefix);\n }\n\n // qs-based deep query parsing (dot notation, nested objects, arrays)\n app.use((req: Request, _res: Response, next: NextFunction) => {\n if (req.query) {\n req.query = qs.parse(req.url.split('?')[1], {\n allowDots: true,\n depth: 20,\n arrayLimit: 100,\n });\n }\n next();\n });\n\n // Global ValidationPipe\n app.useGlobalPipes(\n new ValidationPipe({\n transform: true,\n transformOptions: { enableImplicitConversion: true },\n }),\n );\n\n // Swagger\n if (swagger !== false) {\n const { title = process.env.SOLID_APP_NAME, description = process.env.SOLID_APP_DESCRIPTION, version = '1.0' } = swagger;\n const swaggerConfig = new DocumentBuilder()\n .setTitle(title)\n .setDescription(description)\n .setVersion(version)\n .setExternalDoc('Postman Collection', '/docs-json')\n .addBearerAuth(\n {\n description: 'Please enter token in following format: Bearer <JWT>',\n name: 'Authorization',\n bearerFormat: 'Bearer',\n scheme: 'Bearer',\n type: 'http',\n in: 'Header',\n },\n 'jwt',\n )\n .build();\n const document = SwaggerModule.createDocument(app, swaggerConfig);\n SwaggerModule.setup('/docs', app, document);\n }\n\n // Global interceptor\n app.useGlobalInterceptors(\n new ClassSerializerInterceptor(app.get(Reflector), {\n enableImplicitConversion: true, // optional but handy\n // groups: ['client'], // if you use groups\n }),\n new WrapResponseInterceptor()\n );\n\n // CORS\n app.enableCors(buildDefaultCorsOptions());\n\n // Fix pg returning BIGINT columns as strings\n // eslint-disable-next-line @typescript-eslint/no-var-requires\n const types = require('pg').types;\n types.setTypeParser(types.builtins.INT8, (val: string) => parseInt(val));\n\n app.useWebSocketAdapter(new WsAdapter(app));\n\n await app.listen(port);\n\n // Wire up Winston as the runtime logger only AFTER listen — this suppresses all\n // framework init noise (route mapping, module deps, onModuleInit) during boot.\n app.useLogger(app.get(WINSTON_MODULE_NEST_PROVIDER));\n\n const elapsed = ((Date.now() - startTime) / 1000).toFixed(2);\n process.stdout.write(`\\x1b[32mServer started on port ${port} in ${elapsed}s\\x1b[0m\\n`);\n}\n\n// ---- CLI bootstrap ----\n\n/**\n * Bootstraps a SolidX NestJS CLI application using nest-commander.\n * Handles verbose flag stripping, project root validation, and clean process exit.\n *\n * @example\n * // main-cli.ts\n * #!/usr/bin/env node\n * import { bootstrapSolidCli } from '@solidxai/core';\n * import { AppModule } from './app.module';\n *\n * bootstrapSolidCli(() => AppModule.forRoot());\n */\nexport async function bootstrapSolidCli(\n appModuleFactory: () => Promise<any>,\n): Promise<void> {\n registerGlobalProcessHandlers();\n\n process.on('exit', (code) => {\n if (code !== 0) {\n console.error(`Exiting with error status code: ${code}`);\n }\n });\n\n // Validate that cwd is a valid Solid API project\n const packageJsonPath = resolve(process.cwd(), 'package.json');\n if (!existsSync(packageJsonPath)) {\n console.error('Does not seem to be a valid solid-api project.');\n console.error('Exit reason: missing package.json in the current directory.');\n process.exit(1);\n }\n\n // Strip --verbose / -v before nest-commander processes argv\n const showLogs = process.argv.includes('--verbose') || process.argv.includes('-v');\n for (const flag of ['--verbose', '-v']) {\n const idx = process.argv.indexOf(flag);\n if (idx !== -1) process.argv.splice(idx, 1);\n }\n\n const appModule = await appModuleFactory();\n process.env.SOLID_CLI_RUNNING = 'true';\n\n // @ts-ignore\n const app = await CommandFactory.createWithoutRunning(appModule, {\n logger: showLogs ? ['debug', 'error', 'fatal', 'log', 'verbose', 'warn'] : false,\n });\n\n try {\n await CommandFactory.runApplication(app);\n } catch (e) {\n console.error('CLI exited abruptly due to an error:', e);\n process.exit(1);\n }\n\n process.exit(0);\n}\n"]}
|
|
1
|
+
{"version":3,"file":"bootstrap.helper.js","sourceRoot":"","sources":["../../src/helpers/bootstrap.helper.ts"],"names":[],"mappings":";;;;;AAmFA,8CAmJC;AAgBD,8CA0CC;AAhSD,2CAA4E;AAC5E,uCAAsD;AAEtD,qDAAgD;AAChD,6CAAiE;AAEjE,oDAA4B;AAC5B,4CAAoB;AACpB,2BAAgC;AAChC,+BAA+B;AAC/B,+CAA2E;AAC3E,mDAAgD;AAChD,sDAA8D;AAC9D,yFAAoF;AACpF,+CAAwD;AACxD,uDAK2B;AAC3B,6DAAuD;AAIvD,SAAS,6BAA6B;IACpC,OAAO,CAAC,EAAE,CAAC,oBAAoB,EAAE,CAAC,MAAM,EAAE,OAAO,EAAE,EAAE;QACnD,OAAO,CAAC,KAAK,CAAC,yBAAyB,EAAE,OAAO,EAAE,SAAS,EAAE,MAAM,CAAC,CAAC;IACvE,CAAC,CAAC,CAAC;IAEH,OAAO,CAAC,EAAE,CAAC,mBAAmB,EAAE,CAAC,GAAG,EAAE,EAAE;QACtC,OAAO,CAAC,KAAK,CAAC,4BAA4B,EAAE,GAAG,CAAC,CAAC;IACnD,CAAC,CAAC,CAAC;IAGH,OAAO,CAAC,EAAE,CAAC,SAAS,EAAE,CAAC,OAAO,EAAE,EAAE;QAChC,IAAI,OAAO,CAAC,IAAI,KAAK,oBAAoB,IAAI,CAAC,OAAO,CAAC,OAAO,CAAC,QAAQ,CAAC,gBAAgB,CAAC,IAAI,OAAO,CAAC,OAAO,CAAC,QAAQ,CAAC,UAAU,CAAC,CAAC,EAAE,CAAC;YAClI,OAAO;QACT,CAAC;QACD,OAAO,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;IACxB,CAAC,CAAC,C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ClB,CAAC","sourcesContent":["import { ClassSerializerInterceptor, ValidationPipe } from '@nestjs/common';\nimport { NestFactory, Reflector } from '@nestjs/core';\nimport { NestExpressApplication } from '@nestjs/platform-express';\nimport { WsAdapter } from '@nestjs/platform-ws';\nimport { DocumentBuilder, SwaggerModule } from '@nestjs/swagger';\nimport { NextFunction, Request, Response } from 'express';\nimport helmet from 'helmet';\nimport qs from 'qs';\nimport { existsSync } from 'fs';\nimport { resolve } from 'path';\nimport { WINSTON_MODULE_NEST_PROVIDER, WinstonModule } from 'nest-winston';\nimport { CommandFactory } from 'nest-commander';\nimport { createWinstonLoggerConfig } from '../winston.logger';\nimport { WrapResponseInterceptor } from '../interceptors/wrap-response.interceptor';\nimport { buildDefaultCorsOptions } from './cors.helper';\nimport {\n buildDefaultSecurityHeaderOptions,\n buildPermissionsPolicyHeader,\n PermissionsPolicyConfig,\n SolidSecurityOptions,\n} from './security.helper';\nimport { parseBooleanEnv } from './environment.helper';\n\n// ---- Shared process handlers ----\n\nfunction registerGlobalProcessHandlers() {\n process.on('unhandledRejection', (reason, promise) => {\n console.error('Unhandled Rejection at:', promise, 'reason:', reason);\n });\n\n process.on('uncaughtException', (err) => {\n console.error('Uncaught Exception thrown:', err);\n });\n\n // Suppress pg deprecation warning caused by TypeORM's internal query scheduling\n process.on('warning', (warning) => {\n if (warning.name === 'DeprecationWarning' && (warning.message.includes('client.query()') || warning.message.includes('punycode'))) {\n return;\n }\n console.warn(warning);\n });\n}\n\n// ---- HTTP server bootstrap ----\n\nexport interface SolidSwaggerOptions {\n title?: string;\n description?: string;\n version?: string;\n}\n\nexport interface SolidBootstrapOptions {\n /** Global API prefix. Defaults to 'api'. Set to '' to disable. */\n globalPrefix?: string;\n /** Swagger configuration. Set to false to disable Swagger entirely. */\n swagger?: SolidSwaggerOptions | false;\n /** Permissions-Policy header overrides (merged with defaults). */\n permissionsPolicyOverrides?: Partial<PermissionsPolicyConfig>;\n /** Security header overrides, including iframe frame-ancestor allowlists. */\n security?: SolidSecurityOptions;\n /** Show full NestJS init logs during bootstrap (route mapping, module deps, pollers). Defaults to false. */\n verboseBootstrap?: boolean;\n /**\n * Max request body size for JSON and urlencoded payloads, as a `bytes`-compatible\n * string (e.g. '25mb', '512kb'). Defaults to '25mb'.\n * Note: does not apply to multipart uploads — those are governed by Multer.\n */\n bodyLimit?: string;\n}\n\n/**\n * Bootstraps a SolidX NestJS HTTP application with sensible defaults:\n * security headers, CORS, Winston logger, ValidationPipe,\n * WrapResponseInterceptor, qs deep query parsing, Swagger, and the\n * pg BIGINT type parser.\n *\n * @example\n * // main.ts\n * bootstrapSolidApp(() => AppModule.forRoot(), {\n * swagger: { title: 'My API', description: 'My API description' },\n * security: { frameAncestors: [\"'self'\", 'https://portal.example.com'] },\n * });\n */\nexport async function bootstrapSolidApp(\n appModuleFactory: () => Promise<any>,\n options: SolidBootstrapOptions = {},\n): Promise<NestExpressApplication> {\n registerGlobalProcessHandlers();\n\n const {\n globalPrefix = 'api',\n swagger = {},\n permissionsPolicyOverrides = {},\n security = {},\n verboseBootstrap = false,\n bodyLimit = '25mb',\n } = options;\n\n const startTime = Date.now();\n const appModule = await appModuleFactory();\n const app = await NestFactory.create<NestExpressApplication>(appModule, {\n // Nest's default parsers are registered during init() with a 100kb limit, ahead of\n // any module middleware. Disable them so the parsers below own the limit outright.\n bodyParser: false,\n logger: WinstonModule.createLogger({ ...createWinstonLoggerConfig(), level: verboseBootstrap ? 'debug' : 'error' }),\n });\n\n const apiEnabled = parseBooleanEnv('API_ENABLED', true);\n\n if (!apiEnabled) {\n await app.init();\n app\n .get(WINSTON_MODULE_NEST_PROVIDER)\n .log('API server disabled via API_ENABLED=false. Skipping HTTP listen.', 'Bootstrap');\n return app;\n }\n\n // Health check at root path\n const server = app.getHttpAdapter().getInstance();\n server.get('/', (_req, res) => res.status(200).send('SOLID OK'));\n\n // Security headers\n app.use(helmet(buildDefaultSecurityHeaderOptions(security)));\n\n // Nest's Swagger UI HTML injects inline styles; keep CSP strict elsewhere.\n const isSwaggerPath = (path: string) =>\n path === '/docs' ||\n path === '/docs/' ||\n path.startsWith('/docs/') ||\n path === '/docs-json' ||\n path === '/docs-yaml';\n\n app.use((req: Request, res: Response, next: NextFunction) => {\n if (isSwaggerPath(req.path)) {\n res.removeHeader('Content-Security-Policy');\n }\n next();\n });\n\n // Permissions-Policy header\n app.use((_req: Request, res: Response, next: NextFunction) => {\n res.setHeader('Permissions-Policy', buildPermissionsPolicyHeader(permissionsPolicyOverrides));\n next();\n });\n\n const port = process.env.PORT || 3000;\n\n if (globalPrefix) {\n app.setGlobalPrefix(globalPrefix);\n }\n\n // qs-based deep query parsing (dot notation, nested objects, arrays)\n app.use((req: Request, _res: Response, next: NextFunction) => {\n if (req.query) {\n req.query = qs.parse(req.url.split('?')[1], {\n allowDots: true,\n depth: 20,\n arrayLimit: 100,\n });\n }\n next();\n });\n\n // Body parsers — replaces Nest's default 100kb parsers (disabled via bodyParser: false).\n // Registered here so the middleware order Nest applied by default is preserved:\n // helmet -> CSP -> Permissions-Policy -> qs -> body parsers -> routes.\n app.useBodyParser('json', { limit: bodyLimit });\n app.useBodyParser('urlencoded', { limit: bodyLimit, extended: true });\n\n // Global ValidationPipe\n app.useGlobalPipes(\n new ValidationPipe({\n transform: true,\n transformOptions: { enableImplicitConversion: true },\n }),\n );\n\n // Swagger\n if (swagger !== false) {\n const { title = process.env.SOLID_APP_NAME, description = process.env.SOLID_APP_DESCRIPTION, version = '1.0' } = swagger;\n const swaggerConfig = new DocumentBuilder()\n .setTitle(title)\n .setDescription(description)\n .setVersion(version)\n .setExternalDoc('Postman Collection', '/docs-json')\n .addBearerAuth(\n {\n description: 'Please enter token in following format: Bearer <JWT>',\n name: 'Authorization',\n bearerFormat: 'Bearer',\n scheme: 'Bearer',\n type: 'http',\n in: 'Header',\n },\n 'jwt',\n )\n .build();\n const document = SwaggerModule.createDocument(app, swaggerConfig);\n SwaggerModule.setup('/docs', app, document);\n }\n\n // Global interceptor\n app.useGlobalInterceptors(\n new ClassSerializerInterceptor(app.get(Reflector), {\n enableImplicitConversion: true, // optional but handy\n // groups: ['client'], // if you use groups\n }),\n new WrapResponseInterceptor()\n );\n\n // CORS\n app.enableCors(buildDefaultCorsOptions());\n\n // Fix pg returning BIGINT columns as strings\n // eslint-disable-next-line @typescript-eslint/no-var-requires\n const types = require('pg').types;\n types.setTypeParser(types.builtins.INT8, (val: string) => parseInt(val));\n\n app.useWebSocketAdapter(new WsAdapter(app));\n\n await app.listen(port);\n\n // Wire up Winston as the runtime logger only AFTER listen — this suppresses all\n // framework init noise (route mapping, module deps, onModuleInit) during boot.\n app.useLogger(app.get(WINSTON_MODULE_NEST_PROVIDER));\n\n const elapsed = ((Date.now() - startTime) / 1000).toFixed(2);\n process.stdout.write(`\\x1b[32mServer started on port ${port} in ${elapsed}s\\x1b[0m\\n`);\n\n return app;\n}\n\n// ---- CLI bootstrap ----\n\n/**\n * Bootstraps a SolidX NestJS CLI application using nest-commander.\n * Handles verbose flag stripping, project root validation, and clean process exit.\n *\n * @example\n * // main-cli.ts\n * #!/usr/bin/env node\n * import { bootstrapSolidCli } from '@solidxai/core';\n * import { AppModule } from './app.module';\n *\n * bootstrapSolidCli(() => AppModule.forRoot());\n */\nexport async function bootstrapSolidCli(\n appModuleFactory: () => Promise<any>,\n): Promise<void> {\n registerGlobalProcessHandlers();\n\n process.on('exit', (code) => {\n if (code !== 0) {\n console.error(`Exiting with error status code: ${code}`);\n }\n });\n\n // Validate that cwd is a valid Solid API project\n const packageJsonPath = resolve(process.cwd(), 'package.json');\n if (!existsSync(packageJsonPath)) {\n console.error('Does not seem to be a valid solid-api project.');\n console.error('Exit reason: missing package.json in the current directory.');\n process.exit(1);\n }\n\n // Strip --verbose / -v before nest-commander processes argv\n const showLogs = process.argv.includes('--verbose') || process.argv.includes('-v');\n for (const flag of ['--verbose', '-v']) {\n const idx = process.argv.indexOf(flag);\n if (idx !== -1) process.argv.splice(idx, 1);\n }\n\n const appModule = await appModuleFactory();\n process.env.SOLID_CLI_RUNNING = 'true';\n\n // @ts-ignore\n const app = await CommandFactory.createWithoutRunning(appModule, {\n logger: showLogs ? ['debug', 'error', 'fatal', 'log', 'verbose', 'warn'] : false,\n });\n\n try {\n await CommandFactory.runApplication(app);\n } catch (e) {\n console.error('CLI exited abruptly due to an error:', e);\n process.exit(1);\n }\n\n process.exit(0);\n}\n"]}
|
|
@@ -1,5 +1,9 @@
|
|
|
1
1
|
import { HelmetOptions } from "helmet";
|
|
2
|
-
export
|
|
2
|
+
export interface SolidSecurityOptions {
|
|
3
|
+
frameAncestors?: string[];
|
|
4
|
+
}
|
|
5
|
+
export declare const DEFAULT_FRAME_ANCESTORS: string[];
|
|
6
|
+
export declare function buildDefaultSecurityHeaderOptions(options?: SolidSecurityOptions): Readonly<HelmetOptions>;
|
|
3
7
|
type Source = "self" | "none" | string;
|
|
4
8
|
type DirectiveConfig = "self" | "none" | Source[];
|
|
5
9
|
export type PermissionsPolicyConfig = Record<string, DirectiveConfig>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"security.helper.d.ts","sourceRoot":"","sources":["../../src/helpers/security.helper.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,QAAQ,CAAC;
|
|
1
|
+
{"version":3,"file":"security.helper.d.ts","sourceRoot":"","sources":["../../src/helpers/security.helper.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,QAAQ,CAAC;AAGvC,MAAM,WAAW,oBAAoB;IAKnC,cAAc,CAAC,EAAE,MAAM,EAAE,CAAC;CAC3B;AAED,eAAO,MAAM,uBAAuB,UAQnC,CAAC;AASF,wBAAgB,iCAAiC,CAC/C,OAAO,GAAE,oBAAyB,GACjC,QAAQ,CAAC,aAAa,CAAC,CA+CzB;AAID,KAAK,MAAM,GAAG,MAAM,GAAG,MAAM,GAAG,MAAM,CAAC;AACvC,KAAK,eAAe,GAAG,MAAM,GAAG,MAAM,GAAG,MAAM,EAAE,CAAC;AAClD,MAAM,MAAM,uBAAuB,GAAG,MAAM,CAAC,MAAM,EAAE,eAAe,CAAC,CAAC;AAEtE,eAAO,MAAM,0BAA0B,EAAE,uBAaxC,CAAC;AAEF,wBAAgB,4BAA4B,CAC1C,SAAS,GAAE,OAAO,CAAC,uBAAuB,CAAM,GAC/C,MAAM,CAKR;AAeD,eAAO,MAAM,qBAAqB,iFAC8C,CAAC;AAEjF,wBAAgB,sBAAsB,KAElC,MAAM,OAAO,SAAS,EAAE,OAAO,EAC/B,MAAM,OAAO,SAAS,EAAE,QAAQ,EAChC,MAAM,OAAO,SAAS,EAAE,YAAY,UAKvC"}
|