@solidstarters/solid-core 1.2.133 → 1.2.135
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/dist/controllers/ai-interaction.controller.d.ts +45 -0
- package/dist/controllers/ai-interaction.controller.d.ts.map +1 -0
- package/dist/controllers/ai-interaction.controller.js +192 -0
- package/dist/controllers/ai-interaction.controller.js.map +1 -0
- package/dist/controllers/dashboard-variable.controller.d.ts +43 -0
- package/dist/controllers/dashboard-variable.controller.d.ts.map +1 -0
- package/dist/controllers/dashboard-variable.controller.js +179 -0
- package/dist/controllers/dashboard-variable.controller.js.map +1 -0
- package/dist/controllers/dashboard.controller.d.ts +45 -0
- package/dist/controllers/dashboard.controller.d.ts.map +1 -0
- package/dist/controllers/dashboard.controller.js +192 -0
- package/dist/controllers/dashboard.controller.js.map +1 -0
- package/dist/controllers/question-sql-dataset-config.controller.d.ts +43 -0
- package/dist/controllers/question-sql-dataset-config.controller.d.ts.map +1 -0
- package/dist/controllers/question-sql-dataset-config.controller.js +179 -0
- package/dist/controllers/question-sql-dataset-config.controller.js.map +1 -0
- package/dist/controllers/question.controller.d.ts +45 -0
- package/dist/controllers/question.controller.d.ts.map +1 -0
- package/dist/controllers/question.controller.js +194 -0
- package/dist/controllers/question.controller.js.map +1 -0
- package/dist/controllers/test.controller.d.ts.map +1 -1
- package/dist/controllers/test.controller.js.map +1 -1
- package/dist/decorators/dashboard-question-data-provider.decorator.d.ts +3 -0
- package/dist/decorators/dashboard-question-data-provider.decorator.d.ts.map +1 -0
- package/dist/decorators/dashboard-question-data-provider.decorator.js +11 -0
- package/dist/decorators/dashboard-question-data-provider.decorator.js.map +1 -0
- package/dist/decorators/dashboard-selection-provider.decorator.d.ts +3 -0
- package/dist/decorators/dashboard-selection-provider.decorator.d.ts.map +1 -0
- package/dist/decorators/dashboard-selection-provider.decorator.js +11 -0
- package/dist/decorators/dashboard-selection-provider.decorator.js.map +1 -0
- package/dist/dtos/create-ai-interaction.dto.d.ts +14 -0
- package/dist/dtos/create-ai-interaction.dto.d.ts.map +1 -0
- package/dist/dtos/create-ai-interaction.dto.js +90 -0
- package/dist/dtos/create-ai-interaction.dto.js.map +1 -0
- package/dist/dtos/create-dashboard-variable.dto.d.ts +18 -0
- package/dist/dtos/create-dashboard-variable.dto.d.ts.map +1 -0
- package/dist/dtos/create-dashboard-variable.dto.js +97 -0
- package/dist/dtos/create-dashboard-variable.dto.js.map +1 -0
- package/dist/dtos/create-dashboard.dto.d.ts +15 -0
- package/dist/dtos/create-dashboard.dto.d.ts.map +1 -0
- package/dist/dtos/create-dashboard.dto.js +90 -0
- package/dist/dtos/create-dashboard.dto.js.map +1 -0
- package/dist/dtos/create-question-sql-dataset-config.dto.d.ts +12 -0
- package/dist/dtos/create-question-sql-dataset-config.dto.d.ts.map +1 -0
- package/dist/dtos/create-question-sql-dataset-config.dto.js +77 -0
- package/dist/dtos/create-question-sql-dataset-config.dto.js.map +1 -0
- package/dist/dtos/create-question.dto.d.ts +16 -0
- package/dist/dtos/create-question.dto.d.ts.map +1 -0
- package/dist/dtos/create-question.dto.js +99 -0
- package/dist/dtos/create-question.dto.js.map +1 -0
- package/dist/dtos/dashboard-variable-selection-dynamic-query.dto.d.ts +8 -0
- package/dist/dtos/dashboard-variable-selection-dynamic-query.dto.d.ts.map +1 -0
- package/dist/dtos/dashboard-variable-selection-dynamic-query.dto.js +52 -0
- package/dist/dtos/dashboard-variable-selection-dynamic-query.dto.js.map +1 -0
- package/dist/dtos/invoke-ai-prompt.dto.d.ts +4 -0
- package/dist/dtos/invoke-ai-prompt.dto.d.ts.map +1 -0
- package/dist/dtos/invoke-ai-prompt.dto.js +25 -0
- package/dist/dtos/invoke-ai-prompt.dto.js.map +1 -0
- package/dist/dtos/update-ai-interaction.dto.d.ts +15 -0
- package/dist/dtos/update-ai-interaction.dto.d.ts.map +1 -0
- package/dist/dtos/update-ai-interaction.dto.js +96 -0
- package/dist/dtos/update-ai-interaction.dto.js.map +1 -0
- package/dist/dtos/update-dashboard-variable.dto.d.ts +15 -0
- package/dist/dtos/update-dashboard-variable.dto.d.ts.map +1 -0
- package/dist/dtos/update-dashboard-variable.dto.js +95 -0
- package/dist/dtos/update-dashboard-variable.dto.js.map +1 -0
- package/dist/dtos/update-dashboard.dto.d.ts +16 -0
- package/dist/dtos/update-dashboard.dto.d.ts.map +1 -0
- package/dist/dtos/update-dashboard.dto.js +96 -0
- package/dist/dtos/update-dashboard.dto.js.map +1 -0
- package/dist/dtos/update-question-sql-dataset-config.dto.d.ts +13 -0
- package/dist/dtos/update-question-sql-dataset-config.dto.d.ts.map +1 -0
- package/dist/dtos/update-question-sql-dataset-config.dto.js +86 -0
- package/dist/dtos/update-question-sql-dataset-config.dto.js.map +1 -0
- package/dist/dtos/update-question.dto.d.ts +17 -0
- package/dist/dtos/update-question.dto.d.ts.map +1 -0
- package/dist/dtos/update-question.dto.js +106 -0
- package/dist/dtos/update-question.dto.js.map +1 -0
- package/dist/entities/ai-interaction.entity.d.ts +15 -0
- package/dist/entities/ai-interaction.entity.d.ts.map +1 -0
- package/dist/entities/ai-interaction.entity.js +70 -0
- package/dist/entities/ai-interaction.entity.js.map +1 -0
- package/dist/entities/dashboard-variable.entity.d.ts +15 -0
- package/dist/entities/dashboard-variable.entity.d.ts.map +1 -0
- package/dist/entities/dashboard-variable.entity.js +73 -0
- package/dist/entities/dashboard-variable.entity.js.map +1 -0
- package/dist/entities/dashboard.entity.d.ts +12 -0
- package/dist/entities/dashboard.entity.d.ts.map +1 -0
- package/dist/entities/dashboard.entity.js +50 -0
- package/dist/entities/dashboard.entity.js.map +1 -0
- package/dist/entities/question-sql-dataset-config.entity.d.ts +13 -0
- package/dist/entities/question-sql-dataset-config.entity.d.ts.map +1 -0
- package/dist/entities/question-sql-dataset-config.entity.js +60 -0
- package/dist/entities/question-sql-dataset-config.entity.js.map +1 -0
- package/dist/entities/question.entity.d.ts +15 -0
- package/dist/entities/question.entity.d.ts.map +1 -0
- package/dist/entities/question.entity.js +67 -0
- package/dist/entities/question.entity.js.map +1 -0
- package/dist/helpers/field-crud-managers/SelectionDynamicFieldCrudManager.d.ts +1 -0
- package/dist/helpers/field-crud-managers/SelectionDynamicFieldCrudManager.d.ts.map +1 -1
- package/dist/helpers/field-crud-managers/SelectionDynamicFieldCrudManager.js +32 -7
- package/dist/helpers/field-crud-managers/SelectionDynamicFieldCrudManager.js.map +1 -1
- package/dist/helpers/field-crud-managers/SelectionStaticFieldCrudManager.d.ts +1 -0
- package/dist/helpers/field-crud-managers/SelectionStaticFieldCrudManager.d.ts.map +1 -1
- package/dist/helpers/field-crud-managers/SelectionStaticFieldCrudManager.js +32 -7
- package/dist/helpers/field-crud-managers/SelectionStaticFieldCrudManager.js.map +1 -1
- package/dist/helpers/solid-registry.d.ts +9 -1
- package/dist/helpers/solid-registry.d.ts.map +1 -1
- package/dist/helpers/solid-registry.js +32 -0
- package/dist/helpers/solid-registry.js.map +1 -1
- package/dist/index.d.ts +5 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +5 -0
- package/dist/index.js.map +1 -1
- package/dist/interfaces.d.ts +12 -1
- package/dist/interfaces.d.ts.map +1 -1
- package/dist/interfaces.js.map +1 -1
- package/dist/mappers/dashboard-mapper.d.ts +6 -0
- package/dist/mappers/dashboard-mapper.d.ts.map +1 -0
- package/dist/mappers/dashboard-mapper.js +60 -0
- package/dist/mappers/dashboard-mapper.js.map +1 -0
- package/dist/repository/dashboard.repository.d.ts +11 -0
- package/dist/repository/dashboard.repository.d.ts.map +1 -0
- package/dist/repository/dashboard.repository.js +93 -0
- package/dist/repository/dashboard.repository.js.map +1 -0
- package/dist/seeders/module-metadata-seeder.service.d.ts +5 -1
- package/dist/seeders/module-metadata-seeder.service.d.ts.map +1 -1
- package/dist/seeders/module-metadata-seeder.service.js +18 -2
- package/dist/seeders/module-metadata-seeder.service.js.map +1 -1
- package/dist/seeders/seed-data/solid-core-metadata.json +4222 -2418
- package/dist/services/ai-interaction.service.d.ts +23 -0
- package/dist/services/ai-interaction.service.d.ts.map +1 -0
- package/dist/services/ai-interaction.service.js +147 -0
- package/dist/services/ai-interaction.service.js.map +1 -0
- package/dist/services/dashboard-selection-providers/dashboard-variable-sql-dynamic-provider.service.d.ts +12 -0
- package/dist/services/dashboard-selection-providers/dashboard-variable-sql-dynamic-provider.service.d.ts.map +1 -0
- package/dist/services/dashboard-selection-providers/dashboard-variable-sql-dynamic-provider.service.js +55 -0
- package/dist/services/dashboard-selection-providers/dashboard-variable-sql-dynamic-provider.service.js.map +1 -0
- package/dist/services/dashboard-selection-providers/dashboard-variable-test-dynamic-provider.service.d.ts +11 -0
- package/dist/services/dashboard-selection-providers/dashboard-variable-test-dynamic-provider.service.d.ts.map +1 -0
- package/dist/services/dashboard-selection-providers/dashboard-variable-test-dynamic-provider.service.js +45 -0
- package/dist/services/dashboard-selection-providers/dashboard-variable-test-dynamic-provider.service.js.map +1 -0
- package/dist/services/dashboard-variable.service.d.ts +23 -0
- package/dist/services/dashboard-variable.service.d.ts.map +1 -0
- package/dist/services/dashboard-variable.service.js +57 -0
- package/dist/services/dashboard-variable.service.js.map +1 -0
- package/dist/services/dashboard.service.d.ts +38 -0
- package/dist/services/dashboard.service.d.ts.map +1 -0
- package/dist/services/dashboard.service.js +179 -0
- package/dist/services/dashboard.service.js.map +1 -0
- package/dist/services/import-transaction.service.d.ts.map +1 -1
- package/dist/services/import-transaction.service.js +2 -1
- package/dist/services/import-transaction.service.js.map +1 -1
- package/dist/services/menu-item-metadata.service.d.ts.map +1 -1
- package/dist/services/menu-item-metadata.service.js +1 -1
- package/dist/services/menu-item-metadata.service.js.map +1 -1
- package/dist/services/question-data-providers/chartjs-sql-data-provider.service.d.ts +36 -0
- package/dist/services/question-data-providers/chartjs-sql-data-provider.service.d.ts.map +1 -0
- package/dist/services/question-data-providers/chartjs-sql-data-provider.service.js +85 -0
- package/dist/services/question-data-providers/chartjs-sql-data-provider.service.js.map +1 -0
- package/dist/services/question-data-providers/helpers.d.ts +4 -0
- package/dist/services/question-data-providers/helpers.d.ts.map +1 -0
- package/dist/services/question-data-providers/helpers.js +10 -0
- package/dist/services/question-data-providers/helpers.js.map +1 -0
- package/dist/services/question-data-providers/prime-react-datatable-sql-data-provider.service.d.ts +17 -0
- package/dist/services/question-data-providers/prime-react-datatable-sql-data-provider.service.d.ts.map +1 -0
- package/dist/services/question-data-providers/prime-react-datatable-sql-data-provider.service.js +64 -0
- package/dist/services/question-data-providers/prime-react-datatable-sql-data-provider.service.js.map +1 -0
- package/dist/services/question-data-providers/prime-react-meter-group-sql-data-provider.service.d.ts +19 -0
- package/dist/services/question-data-providers/prime-react-meter-group-sql-data-provider.service.d.ts.map +1 -0
- package/dist/services/question-data-providers/prime-react-meter-group-sql-data-provider.service.js +84 -0
- package/dist/services/question-data-providers/prime-react-meter-group-sql-data-provider.service.js.map +1 -0
- package/dist/services/question-sql-dataset-config.service.d.ts +22 -0
- package/dist/services/question-sql-dataset-config.service.d.ts.map +1 -0
- package/dist/services/question-sql-dataset-config.service.js +56 -0
- package/dist/services/question-sql-dataset-config.service.js.map +1 -0
- package/dist/services/question.service.d.ts +29 -0
- package/dist/services/question.service.d.ts.map +1 -0
- package/dist/services/question.service.js +117 -0
- package/dist/services/question.service.js.map +1 -0
- package/dist/services/scheduled-jobs/scheduler.service.d.ts.map +1 -1
- package/dist/services/scheduled-jobs/scheduler.service.js +22 -11
- package/dist/services/scheduled-jobs/scheduler.service.js.map +1 -1
- package/dist/services/selection-providers/list-of-dashboard-question-providers-selection-provider.service.d.ts +11 -0
- package/dist/services/selection-providers/list-of-dashboard-question-providers-selection-provider.service.d.ts.map +1 -0
- package/dist/services/selection-providers/list-of-dashboard-question-providers-selection-provider.service.js +46 -0
- package/dist/services/selection-providers/list-of-dashboard-question-providers-selection-provider.service.js.map +1 -0
- package/dist/services/selection-providers/list-of-dashboard-variable-providers-selection-provider.service.d.ts +11 -0
- package/dist/services/selection-providers/list-of-dashboard-variable-providers-selection-provider.service.d.ts.map +1 -0
- package/dist/services/selection-providers/list-of-dashboard-variable-providers-selection-provider.service.js +47 -0
- package/dist/services/selection-providers/list-of-dashboard-variable-providers-selection-provider.service.js.map +1 -0
- package/dist/services/solid-introspect.service.d.ts +2 -0
- package/dist/services/solid-introspect.service.d.ts.map +1 -1
- package/dist/services/solid-introspect.service.js +28 -0
- package/dist/services/solid-introspect.service.js.map +1 -1
- package/dist/services/sql-expression-resolver.service.d.ts +9 -0
- package/dist/services/sql-expression-resolver.service.d.ts.map +1 -0
- package/dist/services/sql-expression-resolver.service.js +105 -0
- package/dist/services/sql-expression-resolver.service.js.map +1 -0
- package/dist/solid-core.module.d.ts.map +1 -1
- package/dist/solid-core.module.js +61 -0
- package/dist/solid-core.module.js.map +1 -1
- package/dist/subscribers/dashboard-variable.subscriber.d.ts +16 -0
- package/dist/subscribers/dashboard-variable.subscriber.d.ts.map +1 -0
- package/dist/subscribers/dashboard-variable.subscriber.js +72 -0
- package/dist/subscribers/dashboard-variable.subscriber.js.map +1 -0
- package/dist/subscribers/dashboard.subscriber.d.ts +15 -0
- package/dist/subscribers/dashboard.subscriber.d.ts.map +1 -0
- package/dist/subscribers/dashboard.subscriber.js +56 -0
- package/dist/subscribers/dashboard.subscriber.js.map +1 -0
- package/dist/subscribers/question-sql-dataset-config.subscriber.d.ts +16 -0
- package/dist/subscribers/question-sql-dataset-config.subscriber.d.ts.map +1 -0
- package/dist/subscribers/question-sql-dataset-config.subscriber.js +72 -0
- package/dist/subscribers/question-sql-dataset-config.subscriber.js.map +1 -0
- package/dist/subscribers/question.subscriber.d.ts +16 -0
- package/dist/subscribers/question.subscriber.d.ts.map +1 -0
- package/dist/subscribers/question.subscriber.js +72 -0
- package/dist/subscribers/question.subscriber.js.map +1 -0
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +1 -1
- package/src/controllers/ai-interaction.controller.ts +98 -0
- package/src/controllers/dashboard-variable.controller.ts +93 -0
- package/src/controllers/dashboard.controller.ts +99 -0
- package/src/controllers/question-sql-dataset-config.controller.ts +93 -0
- package/src/controllers/question.controller.ts +104 -0
- package/src/controllers/test.controller.ts +1 -2
- package/src/decorators/dashboard-question-data-provider.decorator.ts +7 -0
- package/src/decorators/dashboard-selection-provider.decorator.ts +7 -0
- package/src/dtos/create-ai-interaction.dto.ts +60 -0
- package/src/dtos/create-dashboard-variable.dto.ts +56 -0
- package/src/dtos/create-dashboard.dto.ts +53 -0
- package/src/dtos/create-question-sql-dataset-config.dto.ts +42 -0
- package/src/dtos/create-question.dto.ts +58 -0
- package/src/dtos/dashboard-variable-selection-dynamic-query.dto.ts +29 -0
- package/src/dtos/invoke-ai-prompt.dto.ts +6 -0
- package/src/dtos/update-ai-interaction.dto.ts +65 -0
- package/src/dtos/update-dashboard-variable.dto.ts +54 -0
- package/src/dtos/update-dashboard.dto.ts +57 -0
- package/src/dtos/update-question-sql-dataset-config.dto.ts +49 -0
- package/src/dtos/update-question.dto.ts +63 -0
- package/src/entities/ai-interaction.entity.ts +39 -0
- package/src/entities/dashboard-variable.entity.ts +30 -0
- package/src/entities/dashboard.entity.ts +21 -0
- package/src/entities/question-sql-dataset-config.entity.ts +25 -0
- package/src/entities/question.entity.ts +30 -0
- package/src/helpers/field-crud-managers/SelectionDynamicFieldCrudManager.ts +44 -18
- package/src/helpers/field-crud-managers/SelectionStaticFieldCrudManager.ts +43 -15
- package/src/helpers/solid-registry.ts +44 -2
- package/src/index.ts +5 -0
- package/src/interfaces.ts +41 -29
- package/src/mappers/dashboard-mapper.ts +52 -0
- package/src/repository/dashboard.repository.ts +100 -0
- package/src/seeders/module-metadata-seeder.service.ts +21 -1
- package/src/seeders/seed-data/solid-core-metadata.json +4225 -2421
- package/src/services/1. Create a context menu option i.py +12 -0
- package/src/services/ai-interaction.service.ts +127 -0
- package/src/services/dashboard-selection-providers/dashboard-variable-sql-dynamic-provider.service.ts +56 -0
- package/src/services/dashboard-selection-providers/dashboard-variable-test-dynamic-provider.service.ts +37 -0
- package/src/services/dashboard-variable.service.ts +36 -0
- package/src/services/dashboard.service.ts +147 -0
- package/src/services/import-transaction.service.ts +2 -1
- package/src/services/menu-item-metadata.service.ts +2 -1
- package/src/services/question-data-providers/chartjs-sql-data-provider.service.ts +121 -0
- package/src/services/question-data-providers/helpers.ts +11 -0
- package/src/services/question-data-providers/prime-react-datatable-sql-data-provider.service.ts +72 -0
- package/src/services/question-data-providers/prime-react-meter-group-sql-data-provider.service.ts +110 -0
- package/src/services/question-sql-dataset-config.service.ts +34 -0
- package/src/services/question.service.ts +115 -0
- package/src/services/scheduled-jobs/scheduler.service.ts +32 -64
- package/src/services/selection-providers/list-of-dashboard-question-providers-selection-provider.service.ts +41 -0
- package/src/services/selection-providers/list-of-dashboard-variable-providers-selection-provider.service.ts +41 -0
- package/src/services/solid-introspect.service.ts +42 -0
- package/src/services/sql-expression-resolver.service.ts +125 -0
- package/src/solid-core.module.ts +61 -1
- package/src/subscribers/dashboard-variable.subscriber.ts +63 -0
- package/src/subscribers/dashboard.subscriber.ts +43 -0
- package/src/subscribers/question-sql-dataset-config.subscriber.ts +63 -0
- package/src/subscribers/question.subscriber.ts +65 -0
|
@@ -0,0 +1,179 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
19
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
20
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
21
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
22
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
23
|
+
};
|
|
24
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
25
|
+
var ownKeys = function(o) {
|
|
26
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
27
|
+
var ar = [];
|
|
28
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
29
|
+
return ar;
|
|
30
|
+
};
|
|
31
|
+
return ownKeys(o);
|
|
32
|
+
};
|
|
33
|
+
return function (mod) {
|
|
34
|
+
if (mod && mod.__esModule) return mod;
|
|
35
|
+
var result = {};
|
|
36
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
37
|
+
__setModuleDefault(result, mod);
|
|
38
|
+
return result;
|
|
39
|
+
};
|
|
40
|
+
})();
|
|
41
|
+
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
42
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
43
|
+
};
|
|
44
|
+
var __param = (this && this.__param) || function (paramIndex, decorator) {
|
|
45
|
+
return function (target, key) { decorator(target, key, paramIndex); }
|
|
46
|
+
};
|
|
47
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
48
|
+
exports.DashboardService = exports.SQL_DYNAMIC_PROVIDER_NAME = void 0;
|
|
49
|
+
const common_1 = require("@nestjs/common");
|
|
50
|
+
const core_1 = require("@nestjs/core");
|
|
51
|
+
const typeorm_1 = require("@nestjs/typeorm");
|
|
52
|
+
const typeorm_2 = require("typeorm");
|
|
53
|
+
const config_1 = require("@nestjs/config");
|
|
54
|
+
const crud_helper_service_1 = require("./crud-helper.service");
|
|
55
|
+
const crud_service_1 = require("./crud.service");
|
|
56
|
+
const file_service_1 = require("./file.service");
|
|
57
|
+
const model_metadata_service_1 = require("./model-metadata.service");
|
|
58
|
+
const module_metadata_service_1 = require("./module-metadata.service");
|
|
59
|
+
const fs = __importStar(require("fs/promises"));
|
|
60
|
+
const create_dashboard_variable_dto_1 = require("../dtos/create-dashboard-variable.dto");
|
|
61
|
+
const dashboard_variable_entity_1 = require("../entities/dashboard-variable.entity");
|
|
62
|
+
const module_metadata_helper_service_1 = require("../helpers/module-metadata-helper.service");
|
|
63
|
+
const solid_registry_1 = require("../helpers/solid-registry");
|
|
64
|
+
const dashboard_mapper_1 = require("../mappers/dashboard-mapper");
|
|
65
|
+
const dashboard_repository_1 = require("../repository/dashboard.repository");
|
|
66
|
+
exports.SQL_DYNAMIC_PROVIDER_NAME = 'DashboardVariableSQLDynamicProvider';
|
|
67
|
+
let DashboardService = class DashboardService extends crud_service_1.CRUDService {
|
|
68
|
+
constructor(modelMetadataService, moduleMetadataService, configService, fileService, discoveryService, crudHelperService, entityManager, repo, moduleRef, solidRegistry, moduleMetadataHelperService, dashboardMapper) {
|
|
69
|
+
super(modelMetadataService, moduleMetadataService, configService, fileService, discoveryService, crudHelperService, entityManager, repo, 'dashboard', 'solid-core', moduleRef);
|
|
70
|
+
this.modelMetadataService = modelMetadataService;
|
|
71
|
+
this.moduleMetadataService = moduleMetadataService;
|
|
72
|
+
this.configService = configService;
|
|
73
|
+
this.fileService = fileService;
|
|
74
|
+
this.discoveryService = discoveryService;
|
|
75
|
+
this.crudHelperService = crudHelperService;
|
|
76
|
+
this.entityManager = entityManager;
|
|
77
|
+
this.repo = repo;
|
|
78
|
+
this.moduleRef = moduleRef;
|
|
79
|
+
this.solidRegistry = solidRegistry;
|
|
80
|
+
this.moduleMetadataHelperService = moduleMetadataHelperService;
|
|
81
|
+
this.dashboardMapper = dashboardMapper;
|
|
82
|
+
this.logger = new common_1.Logger(this.constructor.name);
|
|
83
|
+
}
|
|
84
|
+
async getSelectionDynamicValues(query) {
|
|
85
|
+
const dashboardVariable = await this.loadDashboardVariable(query.variableId);
|
|
86
|
+
const [providerName, context] = this.getProviderNameAndContext(dashboardVariable, query);
|
|
87
|
+
const selectionProviderInstance = this.solidRegistry.getDashboardVariableSelectionProviderInstance(providerName);
|
|
88
|
+
if (!selectionProviderInstance) {
|
|
89
|
+
throw new common_1.NotFoundException(`Field incorrectly configured. No provider with name ${providerName} registered in backend.`);
|
|
90
|
+
}
|
|
91
|
+
return selectionProviderInstance.values(query.query, context);
|
|
92
|
+
}
|
|
93
|
+
getProviderNameAndContext(dashboardVariable, query) {
|
|
94
|
+
const sourceType = dashboardVariable.selectionDynamicSourceType;
|
|
95
|
+
let providerName;
|
|
96
|
+
const context = { limit: query.limit, offset: query.offset };
|
|
97
|
+
switch (sourceType) {
|
|
98
|
+
case create_dashboard_variable_dto_1.SelectionDynamicSourceType.SQL:
|
|
99
|
+
providerName = exports.SQL_DYNAMIC_PROVIDER_NAME;
|
|
100
|
+
context['sql'] = dashboardVariable.selectionDynamicSQL;
|
|
101
|
+
break;
|
|
102
|
+
case create_dashboard_variable_dto_1.SelectionDynamicSourceType.PROVIDER:
|
|
103
|
+
providerName = dashboardVariable.selectionDynamicProviderName;
|
|
104
|
+
break;
|
|
105
|
+
default:
|
|
106
|
+
throw new Error(`Unsupported selection dynamic source type: ${sourceType}`);
|
|
107
|
+
}
|
|
108
|
+
return [providerName, context];
|
|
109
|
+
}
|
|
110
|
+
async loadDashboardVariable(variableId) {
|
|
111
|
+
const dashboardVariableRepo = this.entityManager.getRepository(dashboard_variable_entity_1.DashboardVariable);
|
|
112
|
+
const dashboardVariable = await dashboardVariableRepo.findOne({
|
|
113
|
+
where: {
|
|
114
|
+
id: variableId,
|
|
115
|
+
},
|
|
116
|
+
});
|
|
117
|
+
return dashboardVariable;
|
|
118
|
+
}
|
|
119
|
+
async saveDashboardToConfig(entity) {
|
|
120
|
+
if (!entity) {
|
|
121
|
+
this.logger.debug('No entity found in the DashboardSubscriber saveDashboardToConfig method');
|
|
122
|
+
return;
|
|
123
|
+
}
|
|
124
|
+
const dashboard = entity;
|
|
125
|
+
const moduleMetadata = entity.module;
|
|
126
|
+
if (!moduleMetadata) {
|
|
127
|
+
throw new Error(`Module metadata not found for dashboard id ${entity.id}`);
|
|
128
|
+
}
|
|
129
|
+
const { filePath, metaData } = await this.getConfigFileDetails(moduleMetadata.name);
|
|
130
|
+
if (!filePath || !metaData) {
|
|
131
|
+
throw new Error(`Configuration details not found for module: ${moduleMetadata.name}`);
|
|
132
|
+
}
|
|
133
|
+
await this.writeToConfig(metaData, dashboard, filePath);
|
|
134
|
+
}
|
|
135
|
+
async getConfigFileDetails(moduleName) {
|
|
136
|
+
const filePath = await this.moduleMetadataHelperService.getModuleMetadataFilePath(moduleName);
|
|
137
|
+
try {
|
|
138
|
+
await fs.access(filePath);
|
|
139
|
+
}
|
|
140
|
+
catch (error) {
|
|
141
|
+
throw new Error(`Configuration file not found for module: ${moduleName}`);
|
|
142
|
+
}
|
|
143
|
+
const metaData = await this.moduleMetadataHelperService.getModuleMetadataConfiguration(filePath);
|
|
144
|
+
return { filePath, metaData };
|
|
145
|
+
}
|
|
146
|
+
async writeToConfig(metaData, dashboard, filePath) {
|
|
147
|
+
if (metaData.dashboards) {
|
|
148
|
+
const dashboardIndex = metaData.dashboards?.findIndex((dashboardFromFile) => dashboardFromFile.name === dashboard.name);
|
|
149
|
+
const dto = await this.dashboardMapper.toDto(dashboard);
|
|
150
|
+
metaData.dashboards[dashboardIndex] = dto;
|
|
151
|
+
}
|
|
152
|
+
else {
|
|
153
|
+
const dashboards = [];
|
|
154
|
+
const dto = await this.dashboardMapper.toDto(dashboard);
|
|
155
|
+
dashboards.push(dto);
|
|
156
|
+
metaData.dashboards = dashboards;
|
|
157
|
+
}
|
|
158
|
+
const updatedContent = JSON.stringify(metaData, null, 2);
|
|
159
|
+
await fs.writeFile(filePath, updatedContent);
|
|
160
|
+
}
|
|
161
|
+
};
|
|
162
|
+
exports.DashboardService = DashboardService;
|
|
163
|
+
exports.DashboardService = DashboardService = __decorate([
|
|
164
|
+
(0, common_1.Injectable)(),
|
|
165
|
+
__param(6, (0, typeorm_1.InjectEntityManager)()),
|
|
166
|
+
__metadata("design:paramtypes", [model_metadata_service_1.ModelMetadataService,
|
|
167
|
+
module_metadata_service_1.ModuleMetadataService,
|
|
168
|
+
config_1.ConfigService,
|
|
169
|
+
file_service_1.FileService,
|
|
170
|
+
core_1.DiscoveryService,
|
|
171
|
+
crud_helper_service_1.CrudHelperService,
|
|
172
|
+
typeorm_2.EntityManager,
|
|
173
|
+
dashboard_repository_1.DashboardRepository,
|
|
174
|
+
core_1.ModuleRef,
|
|
175
|
+
solid_registry_1.SolidRegistry,
|
|
176
|
+
module_metadata_helper_service_1.ModuleMetadataHelperService,
|
|
177
|
+
dashboard_mapper_1.DashboardMapper])
|
|
178
|
+
], DashboardService);
|
|
179
|
+
//# sourceMappingURL=dashboard.service.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"dashboard.service.js","sourceRoot":"","sources":["../../src/services/dashboard.service.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,2CAAuE;AACvE,uCAA2D;AAC3D,6CAAsD;AACtD,qCAAwC;AAExC,2CAA+C;AAC/C,+DAAqE;AACrE,iDAAwD;AACxD,iDAAwD;AACxD,qEAA2E;AAC3E,uEAA6E;AAG7E,gDAAkC;AAClC,yFAAoF;AAEpF,qFAA2E;AAC3E,8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Aa,EAAE,SAAoB,EAAE,QAAgB;QAC/E,IAAI,QAAQ,CAAC,UAAU,EAAE,CAAC;YACxB,MAAM,cAAc,GAAG,QAAQ,CAAC,UAAU,EAAE,SAAS,CAAC,CAAC,iBAAoC,EAAE,EAAE,CAAC,iBAAiB,CAAC,IAAI,KAAK,SAAS,CAAC,IAAI,CAAC,CAAC;YAC3I,MAAM,GAAG,GAAG,MAAM,IAAI,CAAC,eAAe,CAAC,KAAK,CAAC,SAAS,CAAC,CAAC;YACxD,QAAQ,CAAC,UAAU,CAAC,cAAc,CAAC,GAAG,GAAG,CAAC;QAC5C,CAAC;aACI,CAAC;YACJ,MAAM,UAAU,GAAG,EAAE,CAAC;YACtB,MAAM,GAAG,GAAG,MAAM,IAAI,CAAC,eAAe,CAAC,KAAK,CAAC,SAAS,CAAC,CAAC;YACxD,UAAU,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;YACrB,QAAQ,CAAC,UAAU,GAAG,UAAU,CAAC;QACnC,CAAC;QAED,MAAM,cAAc,GAAG,IAAI,CAAC,SAAS,CAAC,QAAQ,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC;QACzD,MAAM,EAAE,CAAC,SAAS,CAAC,QAAQ,EAAE,cAAc,CAAC,CAAC;IAC/C,CAAC;CACF,CAAA;AAxHY,4CAAgB;2BAAhB,gBAAgB;IAD5B,IAAA,mBAAU,GAAE;IAUR,WAAA,IAAA,6BAAmB,GAAE,CAAA;qCANS,6CAAoB;QACnB,+CAAqB;QAC7B,sBAAa;QACf,0BAAW;QACN,uBAAgB;QACf,uCAAiB;QAErB,uBAAa;QACtB,0CAAmB;QACd,gBAAS;QACL,8BAAa;QACC,4DAA2B;QACvC,kCAAe;GAfhC,gBAAgB,CAwH5B","sourcesContent":["import { Injectable, Logger, NotFoundException } from '@nestjs/common';\nimport { DiscoveryService, ModuleRef } from \"@nestjs/core\";\nimport { InjectEntityManager } from '@nestjs/typeorm';\nimport { EntityManager } from 'typeorm';\n\nimport { ConfigService } from '@nestjs/config';\nimport { CrudHelperService } from 'src/services/crud-helper.service';\nimport { CRUDService } from 'src/services/crud.service';\nimport { FileService } from 'src/services/file.service';\nimport { ModelMetadataService } from 'src/services/model-metadata.service';\nimport { ModuleMetadataService } from 'src/services/module-metadata.service';\n\n\nimport * as fs from 'fs/promises'; // Use the Promise-based version of fs for async/await\nimport { SelectionDynamicSourceType } from 'src/dtos/create-dashboard-variable.dto';\nimport { DashboardVariableSelectionDynamicQueryDto } from 'src/dtos/dashboard-variable-selection-dynamic-query.dto';\nimport { DashboardVariable } from 'src/entities/dashboard-variable.entity';\nimport { ModuleMetadataHelperService } from 'src/helpers/module-metadata-helper.service';\nimport { SolidRegistry } from 'src/helpers/solid-registry';\nimport { DashboardMapper } from 'src/mappers/dashboard-mapper';\nimport { DashboardRepository } from 'src/repository/dashboard.repository';\nimport { Dashboard } from '../entities/dashboard.entity';\n\n\nexport const SQL_DYNAMIC_PROVIDER_NAME = 'DashboardVariableSQLDynamicProvider';\n@Injectable()\nexport class DashboardService extends CRUDService<Dashboard> {\n private readonly logger = new Logger(this.constructor.name);\n constructor(\n readonly modelMetadataService: ModelMetadataService,\n readonly moduleMetadataService: ModuleMetadataService,\n readonly configService: ConfigService,\n readonly fileService: FileService,\n readonly discoveryService: DiscoveryService,\n readonly crudHelperService: CrudHelperService,\n @InjectEntityManager()\n readonly entityManager: EntityManager,\n readonly repo: DashboardRepository, // Assuming you have a DashboardRepository for custom queries\n readonly moduleRef: ModuleRef,\n readonly solidRegistry: SolidRegistry, // Assuming solidRegistry is injected for selection providers\n readonly moduleMetadataHelperService: ModuleMetadataHelperService,\n readonly dashboardMapper: DashboardMapper,\n ) {\n super(modelMetadataService, moduleMetadataService, configService, fileService, discoveryService, crudHelperService, entityManager, repo, 'dashboard', 'solid-core', moduleRef);\n }\n\n async getSelectionDynamicValues(query: DashboardVariableSelectionDynamicQueryDto) {\n // Get the dashboard variable repo\n const dashboardVariable = await this.loadDashboardVariable(query.variableId);\n\n // Get the providerName and context for the dashboard variable\n const [providerName, context] = this.getProviderNameAndContext(dashboardVariable, query);\n\n // Get hold of the provider instance from the SolidRegistry\n const selectionProviderInstance = this.solidRegistry.getDashboardVariableSelectionProviderInstance(providerName);\n if (!selectionProviderInstance) {\n throw new NotFoundException(`Field incorrectly configured. No provider with name ${providerName} registered in backend.`);\n }\n\n // 4. Call the provider's getSelectionDynamicValues method\n return selectionProviderInstance.values(query.query, context);\n }\n\n\n private getProviderNameAndContext(dashboardVariable: DashboardVariable, query: DashboardVariableSelectionDynamicQueryDto): [string, any] {\n const sourceType = dashboardVariable.selectionDynamicSourceType;\n\n // Get the appropriate provide name based on the source type\n let providerName: string;\n const context = { limit: query.limit, offset: query.offset };\n switch (sourceType) {\n case SelectionDynamicSourceType.SQL:\n providerName = SQL_DYNAMIC_PROVIDER_NAME;\n context['sql'] = dashboardVariable.selectionDynamicSQL;\n break;\n case SelectionDynamicSourceType.PROVIDER:\n providerName = dashboardVariable.selectionDynamicProviderName;\n break;\n default:\n throw new Error(`Unsupported selection dynamic source type: ${sourceType}`);\n }\n return [providerName, context];\n }\n\n private async loadDashboardVariable(variableId: number) {\n const dashboardVariableRepo = this.entityManager.getRepository(DashboardVariable);\n\n // Load the dashboard record using the field\n const dashboardVariable = await dashboardVariableRepo.findOne({\n where: {\n id: variableId,\n },\n });\n return dashboardVariable;\n }\n\n async saveDashboardToConfig(entity: Dashboard) {\n if (!entity) {\n this.logger.debug('No entity found in the DashboardSubscriber saveDashboardToConfig method');\n return;\n }\n\n // Validate dashboard details\n const dashboard = entity as Dashboard;\n const moduleMetadata = entity.module;\n if (!moduleMetadata) {\n throw new Error(`Module metadata not found for dashboard id ${entity.id}`);\n }\n\n // Get config file details\n const { filePath, metaData } = await this.getConfigFileDetails(moduleMetadata.name);\n if (!filePath || !metaData) {\n throw new Error(`Configuration details not found for module: ${moduleMetadata.name}`);\n }\n\n // Write the dashboard to the config file\n await this.writeToConfig(metaData, dashboard, filePath);\n }\n\n private async getConfigFileDetails(moduleName: string): Promise<{ filePath: string; metaData: any }> {\n const filePath = await this.moduleMetadataHelperService.getModuleMetadataFilePath(moduleName);\n try {\n await fs.access(filePath);\n } catch (error) {\n throw new Error(`Configuration file not found for module: ${moduleName}`);\n }\n const metaData = await this.moduleMetadataHelperService.getModuleMetadataConfiguration(filePath);\n return { filePath, metaData };\n }\n\n private async writeToConfig(metaData: any, dashboard: Dashboard, filePath: string) {\n if (metaData.dashboards) {\n const dashboardIndex = metaData.dashboards?.findIndex((dashboardFromFile: { name: string; }) => dashboardFromFile.name === dashboard.name);\n const dto = await this.dashboardMapper.toDto(dashboard);\n metaData.dashboards[dashboardIndex] = dto;\n }\n else {\n const dashboards = [];\n const dto = await this.dashboardMapper.toDto(dashboard);\n dashboards.push(dto);\n metaData.dashboards = dashboards;\n }\n // Write the updated object back to the file\n const updatedContent = JSON.stringify(metaData, null, 2);\n await fs.writeFile(filePath, updatedContent);\n }\n}"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"import-transaction.service.d.ts","sourceRoot":"","sources":["../../src/services/import-transaction.service.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,gBAAgB,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AAE3D,OAAO,EAAE,aAAa,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AAEpD,OAAO,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAC;AAC/C,OAAO,EAAE,iBAAiB,EAAE,MAAM,kCAAkC,CAAC;AACrE,OAAO,EAAE,WAAW,EAAE,MAAM,2BAA2B,CAAC;AACxD,OAAO,EAAE,WAAW,EAAE,MAAM,2BAA2B,CAAC;AACxD,OAAO,EAAE,oBAAoB,EAAE,MAAM,qCAAqC,CAAC;AAC3E,OAAO,EAAE,qBAAqB,EAAE,MAAM,sCAAsC,CAAC;AAI7E,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAE5C,OAAO,EAAE,6BAA6B,EAAyC,MAAM,k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,YAAY;IAQ1B,OAAO,CAAC,eAAe;YAUT,0BAA0B;YAuB1B,mBAAmB;IAuBjC,OAAO,CAAC,qBAAqB;IAS7B,OAAO,CAAC,oBAAoB;IAS5B,OAAO,CAAC,kBAAkB;YAWZ,uBAAuB;YAoBvB,+BAA+B;CA2B9C"}
|
|
@@ -235,9 +235,10 @@ let ImportTransactionService = ImportTransactionService_1 = class ImportTransact
|
|
|
235
235
|
if (!exportStream) {
|
|
236
236
|
throw new common_1.BadRequestException(`Failed to create export stream for import transaction ID ${importTransactionId}.`);
|
|
237
237
|
}
|
|
238
|
+
const extension = templateFormat === "excel" ? 'xlsx' : 'csv';
|
|
238
239
|
return {
|
|
239
240
|
stream: exportStream,
|
|
240
|
-
fileName: `${importTransaction.modelMetadata.singularName}-failed-imports.${
|
|
241
|
+
fileName: `${importTransaction.modelMetadata.singularName}-failed-imports.${extension}`,
|
|
241
242
|
mimeType: templateFormat === "excel" ? ImportMimeTypes.EXCEL : ImportMimeTypes.CSV,
|
|
242
243
|
};
|
|
243
244
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"import-transaction.service.js","sourceRoot":"","sources":["../../src/services/import-transaction.service.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,2CAAyE;AACzE,uCAA2D;AAC3D,6CAAwE;AACxE,qCAAoD;AAEpD,2CAA+C;AAC/C,+DAAqE;AACrE,iDAAwD;AACxD,iDAAwD;AACxD,qEAA2E;AAC3E,uEAA6E;AAG7E,oEAAkE;AAClE,yCAA4C;AAC5C,iFAAyG;AAGzG,yGAA6F;AAI7F,+BAAoC;AACpC,qFAA0E;AAC1E,+CAA2C;AAC3C,mDAA+C;AAC/C,yEAAoE;AAQpE,IAAY,YAGX;AAHD,WAAY,YAAY;IACtB,2BAAW,CAAA;IACX,+BAAe,CAAA;AACjB,CAAC,EAHW,YAAY,4BAAZ,YAAY,QAGvB;AAED,IAAY,eAGX;AAHD,WAAY,eAAe;IACzB,mCAAgB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AAU;QACL,gBAAS;QACN,4BAAY;QACd,wBAAU;QACT,mBAAW;QACL,iDAAsB;GAhBzC,wBAAwB,CA0jBpC","sourcesContent":["import { BadRequestException, Injectable, Logger } from '@nestjs/common';\nimport { DiscoveryService, ModuleRef } from \"@nestjs/core\";\nimport { InjectEntityManager, InjectRepository } from '@nestjs/typeorm';\nimport { EntityManager, Repository } from 'typeorm';\n\nimport { ConfigService } from '@nestjs/config';\nimport { CrudHelperService } from 'src/services/crud-helper.service';\nimport { CRUDService } from 'src/services/crud.service';\nimport { FileService } from 'src/services/file.service';\nimport { ModelMetadataService } from 'src/services/model-metadata.service';\nimport { ModuleMetadataService } from 'src/services/module-metadata.service';\n\n\nimport { classify } from '@angular-devkit/core/src/utils/strings';\nimport { HttpService } from '@nestjs/axios';\nimport { RelationFieldsCommand, RelationType, SolidFieldType } from 'src/dtos/create-field-metadata.dto';\nimport { ImportInstructionsResponseDto, StandardImportInstructionsResponseDto } from 'src/dtos/import-instructions.dto';\nimport { FieldMetadata } from 'src/entities/field-metadata.entity';\nimport { ImportTransactionErrorLog } from 'src/entities/import-transaction-error-log.entity';\nimport { ModelMetadata } from 'src/entities/model-metadata.entity';\nimport { MediaWithFullUrl } from 'src/interfaces';\nimport { Readable } from 'stream';\nimport { v4 as uuidv4 } from 'uuid';\nimport { ImportTransaction } from '../entities/import-transaction.entity';\nimport { CsvService } from './csv.service';\nimport { ExcelService } from './excel.service';\nimport { SolidIntrospectService } from './solid-introspect.service';\n\ninterface ImportTemplateFileInfo {\n stream: NodeJS.ReadableStream;\n fileName: string;\n mimeType: string;\n}\n\nexport enum ImportFormat {\n CSV = 'csv',\n EXCEL = 'excel',\n}\n\nexport enum ImportMimeTypes {\n CSV = 'text/csv',\n EXCEL = 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet',\n}\nexport interface ImportMappingInfo {\n sampleImportedRecordInfo: SampleImportedRecordInfo[];\n importableFields: ImportableFieldInfo[];\n}\nexport interface SampleImportedRecordInfo {\n cellHeader: string; // The header of the cell in the import file\n cellValue: string; // The value of the cell in the import file\n defaultMappedFieldName: string; // The default mapped field name in the model metadata\n}\nexport interface ImportableFieldInfo {\n name: string;\n displayName: string;\n}\n\nexport interface ImportPaginatedReadResult {\n headers: string[]; // Headers of the CSV file\n data: Record<string, any>[]; // Data records in the current page\n}\n\ninterface ImportMapping {\n header: string; // The name of the field in the import file\n fieldName: string; // The name of the field in the model metadata to which the imported field is mapped\n}\n\nexport enum ImportTransactionStatus {\n draft = 'draft',\n mapping_created = 'mapping_created',\n import_started = 'import_started',\n import_succeeded = 'import_succeeded',\n import_failed = 'import_failed',\n}\n\nexport interface ImportSyncResult {\n status: string; // The status of the import transaction\n importedIds: Array<number>; // The IDs of the records created during the import\n importedCount: number; // The number of records created during the import\n failedCount: number; // The number of records that failed to import\n}\ninterface ImportRecordsResult {\n ids: Array<number>; // The IDs of the records created during the import\n errorLogIds: Array<number>; // The IDs of the error log entries created during the import\n}\n\n@Injectable()\nexport class ImportTransactionService extends CRUDService<ImportTransaction> {\n constructor(\n readonly modelMetadataService: ModelMetadataService,\n readonly moduleMetadataService: ModuleMetadataService,\n readonly configService: ConfigService,\n readonly fileService: FileService,\n readonly discoveryService: DiscoveryService,\n readonly crudHelperService: CrudHelperService,\n @InjectEntityManager()\n readonly entityManager: EntityManager,\n @InjectRepository(ImportTransaction, 'default')\n readonly repo: Repository<ImportTransaction>,\n readonly moduleRef: ModuleRef,\n readonly excelService: ExcelService,\n readonly csvService: CsvService,\n readonly httpService: HttpService,\n readonly introspectService: SolidIntrospectService,\n // readonly fieldMetadataService: FieldMetadataService,\n ) {\n super(modelMetadataService, moduleMetadataService, configService, fileService, discoveryService, crudHelperService, entityManager, repo, 'importTransaction', 'solid-core', moduleRef);\n }\n\n private readonly logger = new Logger(ImportTransactionService.name);\n\n /**\n * This method is used to return a csv / excel template for the import transaction\n * It will contain the display names of the fields in the header row\n * @param modelMetadataId \n */\n async getImportTemplate(modelMetadataId: number, format: ImportFormat = ImportFormat.CSV): Promise<ImportTemplateFileInfo> {\n // Load the model metadata for the given ID\n const modelMetadata = await this.modelMetadataService.findOne(modelMetadataId, {\n populate: ['fields'],\n });\n if (!modelMetadata) {\n throw new Error(`Model metadata with ID ${modelMetadataId} not found.`);\n }\n // Create a header row with the display names of the fields, excluding the media fields,computed fields\n const headers = this.fieldsAllowedForImport(modelMetadata.fields)\n .map(field => field.displayName);\n\n // Depending on the format, generate the template\n if (format === ImportFormat.CSV) {\n const stream = await this.csvService.createCsvStream(null, 0, headers); // Create a CSV stream with the header row\n const fileName = `${modelMetadata.singularName}-import-template.csv`;\n const mimeType = 'text/csv';\n return {\n stream,\n fileName,\n mimeType,\n };\n } else if (format === ImportFormat.EXCEL) {\n const stream = await this.excelService.createExcelStream(null, 0, headers); // Create an Excel stream with the header row\n const fileName = `${modelMetadata.singularName}-import-template.xlsx`;\n // Set the MIME type for Excel files\n const mimeType = 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet';\n return {\n stream,\n fileName,\n mimeType,\n };\n } else {\n throw new Error(`Unsupported import format: ${format}`);\n }\n\n }\n\n async getImportInstructions(modelMetadataId: number): Promise<ImportInstructionsResponseDto> {\n // Load the model metadata for the given ID\n const modelMetadata = await this.modelMetadataService.findOne(modelMetadataId, {\n populate: ['fields'],\n });\n if (!modelMetadata) {\n throw new Error(`Model metadata with ID ${modelMetadataId} not found.`);\n }\n\n // Create the standard import instructions\n const standardInstructions: StandardImportInstructionsResponseDto = {\n requiredFields: [],\n dateFields: [],\n dateTimeFields: [],\n numberFields: [],\n emailFields: [],\n regexFields: [],\n jsonFields: [],\n booleanFields: [],\n };\n\n // Iterate through the fields and populate the standard instructions\n for (const field of modelMetadata.fields) {\n if (field.isSystem) continue; // Skip system fields\n if (field.required) {\n standardInstructions.requiredFields.push(field.displayName);\n }\n if (field.type === SolidFieldType.date) {\n standardInstructions.dateFields.push(field.displayName);\n }\n if (field.type === SolidFieldType.datetime) {\n standardInstructions.dateTimeFields.push(field.displayName);\n }\n if ([SolidFieldType.bigint, SolidFieldType.int, SolidFieldType.decimal].includes(field.type as SolidFieldType)) {\n standardInstructions.numberFields.push(field.displayName);\n }\n if (field.type === SolidFieldType.email) {\n standardInstructions.emailFields.push(field.displayName);\n }\n if (field.regexPattern) {\n standardInstructions.regexFields.push({\n fieldName: field.displayName,\n regexPattern: field.regexPattern,\n });\n }\n if (field.type === SolidFieldType.json) {\n standardInstructions.jsonFields.push(field.displayName);\n }\n if (field.type === SolidFieldType.boolean) {\n standardInstructions.booleanFields.push(field.displayName);\n }\n }\n\n // Create the custom instructions\n const customInstructions: string[] = [];\n\n return {\n standard: standardInstructions,\n custom: customInstructions,\n };\n }\n\n async getImportMappingInfo(importTransactionId: number): Promise<ImportMappingInfo> {\n // Load the import transaction for the given ID\n const importTransaction = await this.loadImportTransaction(importTransactionId);\n\n // Get all the importable fields from the model metadata\n const importableFields: ImportableFieldInfo[] = this.fieldsAllowedForImport(importTransaction.modelMetadata.fields).map(field => ({\n name: field.name,\n displayName: field.displayName,\n required: field.required,\n }));\n\n // Get the import file media object from the import transaction\n const importFileMediaObject = this.getImportFileObject(importTransaction);\n\n // Get the import file stream for the import transaction\n const importFileStream = await this.getImportFileStream(importFileMediaObject);\n\n // Get a sample of records from the import file\n const sampleRecord = await this.getFileRecordsSample(importFileStream, importFileMediaObject.mimeType);\n\n // Convert sampleRecord to the format required for SampleImportedRecordInfo\n const wrappedRecords: SampleImportedRecordInfo[] = sampleRecord.data.map((record: Record<string, any>) => {\n return Object.entries(record).map(([key, value]) => ({\n cellHeader: key,\n cellValue: value,\n defaultMappedFieldName: importableFields.find(field => field.displayName === key)?.name || '',\n }));\n }).flat();\n\n // for await (const page of this.csvService.readCsvInPagesFromStream(importFileStream)) {\n // // await dbService.bulkInsert(page);\n // }\n\n return {\n sampleImportedRecordInfo: wrappedRecords, // This will hold the sample data from the file\n importableFields: importableFields, // This will hold the fields that can be imported\n };\n }\n\n async startImportSync(importTransactionId: number): Promise<ImportSyncResult> {\n // Load the import transaction for the given ID\n const importTransaction = await this.loadImportTransaction(importTransactionId);\n\n // Get the import file media object from the import transaction\n const importFileMediaObject = this.getImportFileObject(importTransaction);\n\n // Get the import file stream for the import transaction\n const importFileStream = await this.getImportFileStream(importFileMediaObject);\n\n const { ids, errorLogIds } = await this.importFromFileToDB(\n importTransaction,\n importFileStream,\n importFileMediaObject.mimeType,\n );\n\n // Update the import transaction status to 'completed'\n (errorLogIds.length > 0) ? importTransaction.status = ImportTransactionStatus.import_failed : importTransaction.status = ImportTransactionStatus.import_succeeded; //FIXME: We can probably have import_partially_failed status to differentiate\n // Save the import transaction\n await this.repo.save(importTransaction);\n return {\n status: importTransaction.status,\n importedIds: ids, // The IDs of the records created during the import\n importedCount: ids.length, // The number of records created during the import\n failedCount: errorLogIds.length, // The number of records that failed to import\n };\n }\n\n startImportAsync(importTransactionId: number): Promise<void> {\n throw new Error('Method not implemented.');\n }\n\n async exportFailedImportedImports(importTransactionId: number) {\n // Get the 1st error log entry to determine the headers for the export file\n const firstErrorLogEntry = await this.entityManager.getRepository(ImportTransactionErrorLog).findOne({\n where: {\n importTransaction: { id: importTransactionId },\n },\n });\n\n if (!firstErrorLogEntry) {\n throw new BadRequestException(`No error log entries found for import transaction ID ${importTransactionId}.`);\n }\n\n // Create the headers for the export file\n const headers = [\n ...Object.keys(firstErrorLogEntry.rowData ? JSON.parse(firstErrorLogEntry.rowData) : {}), // Include all keys from the rowData JSON\n 'Error', // Error message for the failed record\n ];\n\n\n // Depending upon the format of the import tranaction file, create a readable stream of the error log entries\n const importTransaction = await this.loadImportTransaction(importTransactionId);\n const importFileMediaObject = this.getImportFileObject(importTransaction);\n const mimeType = importFileMediaObject.mimeType;\n const templateFormat = mimeType === ImportMimeTypes.CSV ? \"csv\" : \"excel\";\n const dataRecordsFunc = async (chunkIndex: number, chunkSize: number): Promise<any[]> => {\n // Get the error log entries for the import transaction\n const errorLogEntries = await this.entityManager.getRepository(ImportTransactionErrorLog).find({\n where: {\n importTransaction: { id: importTransactionId },\n },\n skip: chunkIndex * chunkSize,\n take: chunkSize,\n });\n\n if (!errorLogEntries || errorLogEntries.length === 0) {\n return []; // Return an empty array if no error log entries found\n }\n\n // Read the row data json from the error log entry, parse it and write it as a record to the stream\n return errorLogEntries.map(entry => {\n const rowData = entry.rowData ? JSON.parse(entry.rowData) : {};\n return {\n ...rowData, // Spread the row data into the record\n Error: entry.errorMessage,\n };\n });\n };\n\n // Get the export stream for the failed records\n const exportStream = await this.getFailedRecordsStream(templateFormat, headers, dataRecordsFunc);\n if (!exportStream) {\n throw new BadRequestException(`Failed to create export stream for import transaction ID ${importTransactionId}.`);\n }\n // Return the export stream\n return {\n stream: exportStream,\n fileName: `${importTransaction.modelMetadata.singularName}-failed-imports.${templateFormat}`,\n mimeType: templateFormat === \"excel\" ? ImportMimeTypes.EXCEL : ImportMimeTypes.CSV,\n };\n\n }\n\n private async getFailedRecordsStream(templateFormat: string, headers: string[], dataRecordsFunc: (chunkIndex: number, chunkSize: number) => Promise<any[]>) {\n let exportStream = null;\n switch (templateFormat) {\n case \"excel\":\n exportStream = await this.excelService.createExcelStream(dataRecordsFunc, 100, headers);\n break;\n case \"csv\":\n exportStream = await this.csvService.createCsvStream(dataRecordsFunc, 100, headers);\n break;\n default:\n throw new Error('Invalid export format');\n }\n return exportStream;\n }\n\n\n private async loadImportTransaction(importTransactionId: number) {\n const importTransaction = await this.findOne(importTransactionId, {\n populate: ['modelMetadata', 'modelMetadata.fields'],\n populateMedia: ['fileLocation'],\n });\n if (!importTransaction) {\n throw new Error(`Import transaction with ID ${importTransactionId} not found.`);\n }\n return importTransaction;\n }\n\n private fieldsAllowedForImport(fields: FieldMetadata[]): FieldMetadata[] {\n // Filter out fields that are not allowed for import\n return fields.filter(field =>\n field.type !== SolidFieldType.mediaMultiple && // Exclude media multiple fields\n field.type !== SolidFieldType.mediaSingle &&\n field.type !== SolidFieldType.computed && // Exclude computed fields\n field.type !== SolidFieldType.password &&\n field.type !== SolidFieldType.richText &&\n field.type !== SolidFieldType.uuid &&\n field.isSystem !== true // Exclude system fields\n );\n }\n\n private async getFileRecordsSample(importFileStream: Readable, mimeType: string): Promise<ImportPaginatedReadResult> {\n // Depending upon the mime type of the file, read the file in pages\n // For CSV files, use the csvService to read the file in pages\n // For Excel files, use the excelService to read the file in pages\n if (mimeType === 'text/csv') {\n const generator = this.csvService.readCsvInPagesFromStream(importFileStream, { pageSize: 1 });\n const firstRecord = await generator.next(); // Get the first record to extract headers and sample data\n return firstRecord.value;\n } else if (mimeType === 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet') {\n const generator = this.excelService.readExcelInPagesFromStream(importFileStream, { pageSize: 1 });\n const firstRecord = await generator.next(); // Get the first record to extract headers and sample data\n return firstRecord.value;\n }\n else { // If the file is neither CSV nor Excel, throw an error\n throw new Error(`Unsupported file type: ${mimeType}`);\n }\n }\n\n private getImportFileObject(importTransaction: ImportTransaction): MediaWithFullUrl {\n const importFileMediaObject = importTransaction['_media']['fileLocation'][0] as MediaWithFullUrl; // Since there can be only one fileLocation, we can safely access the first element\n if (!importFileMediaObject) {\n throw new Error(`Import file for transaction ID ${importTransaction.id} not found.`);\n }\n return importFileMediaObject;\n }\n\n private async getImportFileStream(importFileMediaObject: MediaWithFullUrl): Promise<Readable> {\n const fileUrl = importFileMediaObject['_full_url'];\n const mimeType = importFileMediaObject['mimeType'];\n if (!fileUrl) {\n throw new Error(`File URL ${fileUrl} not found.`);\n }\n // From the file URL, convert the file URL to a readable stream using nestjs http service and axios\n const fileUrlResponse = await this.httpService.axiosRef.get(fileUrl, {\n responseType: 'stream',\n });\n\n if (!fileUrlResponse || !fileUrlResponse.data) {\n throw new Error(`Failed to read file from URL: ${fileUrl}`);\n }\n // fileUrlResponse.data is a Node.js Readable stream\n return fileUrlResponse.data;\n }\n\n private async importFromFileToDB(\n importTransaction: ImportTransaction,\n importFileStream: Readable,\n mimeType: string,\n ): Promise<ImportRecordsResult> {\n if (!importTransaction.modelMetadata) {\n throw new Error(`Model metadata for import transaction ID ${importTransaction.id} not found.`);\n }\n\n const createdRecordIds = [];\n const createdErrorLogIds = [];\n\n // Get the model service for the model metadata name\n const modelService = this.getModelService(importTransaction.modelMetadata.singularName);\n\n // Depending upon the mime type of the file, read the file in pages and insert the records into the database\n if (mimeType === ImportMimeTypes.CSV) {\n for await (const page of this.csvService.readCsvInPagesFromStream(importFileStream)) {\n const { ids, errorLogIds } = await this.importRecords(page, importTransaction, modelService);\n createdRecordIds.push(...ids);\n createdErrorLogIds.push(...errorLogIds);\n }\n }\n else if (mimeType === ImportMimeTypes.EXCEL) {\n for await (const page of this.excelService.readExcelInPagesFromStream(importFileStream)) {\n const { ids, errorLogIds } = await this.importRecords(page, importTransaction, modelService);\n createdRecordIds.push(...ids);\n createdErrorLogIds.push(...errorLogIds);\n }\n } else { // If the file is neither CSV nor Excel, throw an error\n throw new Error(`Unsupported file type: ${mimeType}`);\n }\n\n return {\n ids: createdRecordIds, // Return the IDs of the created records\n errorLogIds: createdErrorLogIds, // Return the IDs of the error log entries created during the import\n }\n }\n\n private async importRecords(page: ImportPaginatedReadResult, importTransaction: ImportTransaction, modelService: CRUDService<any>): Promise<ImportRecordsResult> {\n if (!importTransaction.modelMetadata || !importTransaction.modelMetadata.fields) {\n throw new Error(`Model metadata with fields for import transaction ID ${importTransaction.id} not found.`);\n }\n\n const ids: Array<number> = [];\n const errorLogIds: Array<number> = [];\n for (const record of page.data) {\n try {\n const createdRecord = await this.insertRecord(record, JSON.parse(importTransaction.mapping) as ImportMapping[], importTransaction.modelMetadata, modelService);\n ids.push(createdRecord.id); // Add the ID of the created record to the ids array\n }\n catch (error) {\n this.logger.debug(`Error inserting record: ${JSON.stringify(record)}. Error: ${error.message}`);\n // Get the Import transaction error log repo\n const errorLog = await this.createErrorLogEntry(importTransaction, record, error);\n errorLogIds.push(errorLog.id); // Add the ID of the error log entry to the errorLogIds array\n }\n }\n return {\n ids: ids, // Return the IDs of the created records\n errorLogIds: errorLogIds, // Return the IDs of the error log entries created during the import\n };\n }\n\n private async createErrorLogEntry(importTransaction: ImportTransaction, record: Record<string, any>, error: any) {\n const importTransactionRepo = this.entityManager.getRepository(ImportTransactionErrorLog);\n // Create a new ImportTransactionErrorLog entry\n const rowNumber = uuidv4(); // Generate a unique row number or use page.rowNumber if available \n\n const errorLogEntry = {\n importTransactionErrorLogId: `${importTransaction.id}-${rowNumber}`, // FIXME pending to retrieve the row number from the page\n rowNumber: 1, // FIXME pending to retrieve the row number from the page\n rowData: JSON.stringify(record), // Store the row data\n importTransaction: importTransaction, // Link to the import transaction\n errorMessage: error.message, // Store the error message\n errorTrace: error.stack || '', // Store the error stack trace if available\n } as ImportTransactionErrorLog;\n\n // Save the error log entry to the database\n const savedEntry = await importTransactionRepo.save(errorLogEntry);\n return savedEntry; // Return the ID of the saved error log entry\n }\n\n //FIXME Currently below method fails if any field in the record is not valid or if the record is not valid. It does not collect the errors for all fields in a record\n private async insertRecord(record: Record<string, any>, mapping: ImportMapping[], modelMetadataWithFields: ModelMetadata, modelService: CRUDService<any>): Promise<any> {\n // Convert the imported record to a DTO\n const dto = await this.convertImportedRecordToDto(record, mapping, modelMetadataWithFields);\n // Use the model service to create the record in the database\n const createdRecord = await modelService.create(dto, [], {}); //FIXME: Need to handle this part alongwith the refactoring of the CRUDService for permissions\n return createdRecord; // Return the created record\n }\n\n private getModelService(modelSingularName: string): CRUDService<any> {\n // Get the model service for the model metadata name\n const modelServiceWrapper = this.introspectService.getProvider(`${classify(modelSingularName)}Service`);\n const modelService = modelServiceWrapper.instance as CRUDService<any>;\n if (!modelService) {\n throw new Error(`Model service for ${modelSingularName} not found.`);\n }\n return modelService;\n }\n\n private async convertImportedRecordToDto(record: Record<string, any>, mapping: ImportMapping[], modelMetadataWithFields: ModelMetadata) {\n // Create a new record object\n const dtoRecord: Record<string, any> = {};\n\n // Iterate through every cell in the record\n // Using the saved mapping, populate the dtoRecord w.r.t the record and fields\n for (const key in record) {\n const mappedField = mapping.find(m => m.header === key);\n if (mappedField) {\n // If the field is found in the mapping, get the field metadata from the model metadata\n const fieldMetadata = modelMetadataWithFields.fields.find(f => f.name === mappedField.fieldName);\n // const userKeyField = modelMetadataWithFields.fields.find(f => f.isUserKey === true); // Assuming userKey is a field in the model metadata\n if (fieldMetadata) {\n // If the field is found in the model metadata, set the value in the dtoRecord\n await this.populateDtoForACell(dtoRecord, fieldMetadata, record, key);\n } else {\n this.logger.warn(`Field ${mappedField.fieldName} not found in model metadata ${modelMetadataWithFields.singularName}`);\n }\n }\n }\n return dtoRecord;\n }\n\n private async populateDtoForACell(dtoRecord: Record<string, any>, fieldMetadata: FieldMetadata, record: Record<string, any>, key: string): Promise<Record<string, any>> {\n const fieldType = fieldMetadata.type;\n // const userKeyFieldName = userKeyField?.name || 'id'; // Default to 'id' if not found\n\n // TODO Move this logic to field crud managers i.e add a parse method to the field crud manager interface\n switch (fieldType) {\n case SolidFieldType.relation: {\n return await this.populateDtoForRelations(fieldMetadata, record, key, dtoRecord);\n }\n case SolidFieldType.date:\n case SolidFieldType.datetime: return this.populateDtoForDate(record, key, fieldMetadata, dtoRecord);\n case SolidFieldType.int:\n case SolidFieldType.bigint:\n case SolidFieldType.decimal:\n return this.populateDtoForNumber(dtoRecord, fieldMetadata, record, key);\n case SolidFieldType.boolean:\n return this.populateDtoForBoolean(dtoRecord, fieldMetadata, record, key);\n default:\n dtoRecord[fieldMetadata.name] = record[key];\n return dtoRecord;\n }\n }\n\n private populateDtoForBoolean(dtoRecord: Record<string, any>, fieldMetadata: FieldMetadata, record: Record<string, any>, key: string) {\n const booleanValue = Boolean(record[key]);\n if (typeof booleanValue !== 'boolean') {\n throw new Error(`Invalid boolean value for cell ${key} with value ${record[key]}`);\n }\n dtoRecord[fieldMetadata.name] = booleanValue;\n return dtoRecord;\n }\n\n private populateDtoForNumber(dtoRecord: Record<string, any>, fieldMetadata: FieldMetadata, record: Record<string, any>, key: string) {\n const numberValue = Number(record[key]);\n if (isNaN(numberValue)) {\n throw new Error(`Invalid number value for cell ${key} with value ${record[key]}`);\n }\n dtoRecord[fieldMetadata.name] = numberValue;\n return dtoRecord;\n }\n\n private populateDtoForDate(record: Record<string, any>, key: string, fieldMetadata: FieldMetadata, dtoRecord: Record<string, any>) {\n {\n const dateValue = new Date(record[key]);\n if (isNaN(dateValue.getTime())) {\n throw new Error(`Invalid date value for cell ${key} with value ${record[key]}`);\n }\n dtoRecord[fieldMetadata.name] = dateValue;\n return dtoRecord;\n }\n }\n\n private async populateDtoForRelations(fieldMetadata: FieldMetadata, record: Record<string, any>, key: string, dtoRecord: Record<string, any>) {\n if (!fieldMetadata.relationCoModelSingularName) {\n throw new Error(`Relation coModelSingularName is not defined for relation field ${fieldMetadata.name}`);\n }\n\n const relatedRecordsIds = await this.getRelatedEntityIdsFromUserKeys(fieldMetadata, record, key);\n if (relatedRecordsIds.length === 0) {\n return dtoRecord; // If no related records found, return the dtoRecord as is\n }\n\n if (fieldMetadata.relationType === RelationType.manyTomany || fieldMetadata.relationType === RelationType.oneToMany) {\n dtoRecord[`${fieldMetadata.name}Ids`] = relatedRecordsIds;\n dtoRecord[`${fieldMetadata.name}Command`] = RelationFieldsCommand.set; // Reset the relation field association with the related records IDs\n }\n else if (fieldMetadata.relationType === RelationType.manyToOne) {\n dtoRecord[`${fieldMetadata.name}Id`] = relatedRecordsIds.pop(); // For many-to-one relations, we need only one ID\n }\n return dtoRecord;\n }\n\n private async getRelatedEntityIdsFromUserKeys(fieldMetadata: FieldMetadata, record: Record<string, any>, key: string): Promise<Array<number>> {\n // For many-to-many or one-to-many relations, we expect the record cell to contains a comma-separated list of userKeys\n const relationUserKeys = record[key] ? String(record[key]).split(',').map((userKey: string) => userKey.trim()) : [];\n if (relationUserKeys.length === 0) return [];\n\n const coModelService = this.getModelService(fieldMetadata.relationCoModelSingularName);\n const coModelWithUserKeyField = await this.modelMetadataService.findOneBySingularName(fieldMetadata.relationCoModelSingularName, ['userKeyField']);\n const coModelUserKeyFieldName = coModelWithUserKeyField?.userKeyField?.name || 'id'; // Default to 'id' if not found\n\n\n // Set the relation basic filter dto filters with the userkeys and call the find method of the model service to get the related records\n const relationFilterDto = {\n filters: {\n [coModelUserKeyFieldName]: {\n $in: relationUserKeys, // Use the userKeyFieldName to filter by userKeys\n },\n },\n };\n\n // From the userKeys, we will get the IDs of the related records using the userKeyFieldName and throw an error if any of the userKeys is not found\n const relatedRecordsResult = await coModelService.find(relationFilterDto);\n if (!relatedRecordsResult || !relatedRecordsResult.records || relatedRecordsResult.records.length === 0 || relatedRecordsResult.records.length !== relationUserKeys.length) {\n throw new Error(`Invalid related records userKey values found for cell ${key} with value ${record[key]}`);\n }\n const relatedRecordsIds = relatedRecordsResult.records.map(record => record.id);\n return relatedRecordsIds;\n }\n}"]}
|
|
1
|
+
{"version":3,"file":"import-transaction.service.js","sourceRoot":"","sources":["../../src/services/import-transaction.service.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,2CAAyE;AACzE,uCAA2D;AAC3D,6CAAwE;AACxE,qCAAoD;AAEpD,2CAA+C;AAC/C,+DAAqE;AACrE,iDAAwD;AACxD,iDAAwD;AACxD,qEAA2E;AAC3E,uEAA6E;AAG7E,oEAAkE;AAClE,yCAA4C;AAC5C,iFAAyG;AAGzG,yGAA6F;AAI7F,+BAAoC;AACpC,qFAA0E;AAC1E,+CAA2C;AAC3C,mDAA+C;AAC/C,yEAAoE;AAQpE,IAAY,YAGX;AAHD,WAAY,YAAY;IACtB,2BAAW,CAAA;IACX,+BAAe,CAAA;AACjB,CAAC,EAHW,YAAY,4BAAZ,YAAY,QAGvB;AAED,IAAY,eAGX;AAHD,WAAY,eAAe;IACzB,mCAAgB,CAAA;IAChB,8FAA2E,CAAA;AAC7E,CAAC,EAHW,eAAe,+BAAf,eAAe,QAG1B;AAyBD,IAAY,uBAMX;AAND,WAAY,uBAAuB;IACjC,0CAAe,CAAA;IACf,8DAAmC,CAAA;IACnC,4DAAiC,CAAA;IACjC,gEAAqC,CAAA;IACr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":["import { BadRequestException, Injectable, Logger } from '@nestjs/common';\nimport { DiscoveryService, ModuleRef } from \"@nestjs/core\";\nimport { InjectEntityManager, InjectRepository } from '@nestjs/typeorm';\nimport { EntityManager, Repository } from 'typeorm';\n\nimport { ConfigService } from '@nestjs/config';\nimport { CrudHelperService } from 'src/services/crud-helper.service';\nimport { CRUDService } from 'src/services/crud.service';\nimport { FileService } from 'src/services/file.service';\nimport { ModelMetadataService } from 'src/services/model-metadata.service';\nimport { ModuleMetadataService } from 'src/services/module-metadata.service';\n\n\nimport { classify } from '@angular-devkit/core/src/utils/strings';\nimport { HttpService } from '@nestjs/axios';\nimport { RelationFieldsCommand, RelationType, SolidFieldType } from 'src/dtos/create-field-metadata.dto';\nimport { ImportInstructionsResponseDto, StandardImportInstructionsResponseDto } from 'src/dtos/import-instructions.dto';\nimport { FieldMetadata } from 'src/entities/field-metadata.entity';\nimport { ImportTransactionErrorLog } from 'src/entities/import-transaction-error-log.entity';\nimport { ModelMetadata } from 'src/entities/model-metadata.entity';\nimport { MediaWithFullUrl } from 'src/interfaces';\nimport { Readable } from 'stream';\nimport { v4 as uuidv4 } from 'uuid';\nimport { ImportTransaction } from '../entities/import-transaction.entity';\nimport { CsvService } from './csv.service';\nimport { ExcelService } from './excel.service';\nimport { SolidIntrospectService } from './solid-introspect.service';\n\ninterface ImportTemplateFileInfo {\n stream: NodeJS.ReadableStream;\n fileName: string;\n mimeType: string;\n}\n\nexport enum ImportFormat {\n CSV = 'csv',\n EXCEL = 'excel',\n}\n\nexport enum ImportMimeTypes {\n CSV = 'text/csv',\n EXCEL = 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet',\n}\nexport interface ImportMappingInfo {\n sampleImportedRecordInfo: SampleImportedRecordInfo[];\n importableFields: ImportableFieldInfo[];\n}\nexport interface SampleImportedRecordInfo {\n cellHeader: string; // The header of the cell in the import file\n cellValue: string; // The value of the cell in the import file\n defaultMappedFieldName: string; // The default mapped field name in the model metadata\n}\nexport interface ImportableFieldInfo {\n name: string;\n displayName: string;\n}\n\nexport interface ImportPaginatedReadResult {\n headers: string[]; // Headers of the CSV file\n data: Record<string, any>[]; // Data records in the current page\n}\n\ninterface ImportMapping {\n header: string; // The name of the field in the import file\n fieldName: string; // The name of the field in the model metadata to which the imported field is mapped\n}\n\nexport enum ImportTransactionStatus {\n draft = 'draft',\n mapping_created = 'mapping_created',\n import_started = 'import_started',\n import_succeeded = 'import_succeeded',\n import_failed = 'import_failed',\n}\n\nexport interface ImportSyncResult {\n status: string; // The status of the import transaction\n importedIds: Array<number>; // The IDs of the records created during the import\n importedCount: number; // The number of records created during the import\n failedCount: number; // The number of records that failed to import\n}\ninterface ImportRecordsResult {\n ids: Array<number>; // The IDs of the records created during the import\n errorLogIds: Array<number>; // The IDs of the error log entries created during the import\n}\n\n@Injectable()\nexport class ImportTransactionService extends CRUDService<ImportTransaction> {\n constructor(\n readonly modelMetadataService: ModelMetadataService,\n readonly moduleMetadataService: ModuleMetadataService,\n readonly configService: ConfigService,\n readonly fileService: FileService,\n readonly discoveryService: DiscoveryService,\n readonly crudHelperService: CrudHelperService,\n @InjectEntityManager()\n readonly entityManager: EntityManager,\n @InjectRepository(ImportTransaction, 'default')\n readonly repo: Repository<ImportTransaction>,\n readonly moduleRef: ModuleRef,\n readonly excelService: ExcelService,\n readonly csvService: CsvService,\n readonly httpService: HttpService,\n readonly introspectService: SolidIntrospectService,\n // readonly fieldMetadataService: FieldMetadataService,\n ) {\n super(modelMetadataService, moduleMetadataService, configService, fileService, discoveryService, crudHelperService, entityManager, repo, 'importTransaction', 'solid-core', moduleRef);\n }\n\n private readonly logger = new Logger(ImportTransactionService.name);\n\n /**\n * This method is used to return a csv / excel template for the import transaction\n * It will contain the display names of the fields in the header row\n * @param modelMetadataId \n */\n async getImportTemplate(modelMetadataId: number, format: ImportFormat = ImportFormat.CSV): Promise<ImportTemplateFileInfo> {\n // Load the model metadata for the given ID\n const modelMetadata = await this.modelMetadataService.findOne(modelMetadataId, {\n populate: ['fields'],\n });\n if (!modelMetadata) {\n throw new Error(`Model metadata with ID ${modelMetadataId} not found.`);\n }\n // Create a header row with the display names of the fields, excluding the media fields,computed fields\n const headers = this.fieldsAllowedForImport(modelMetadata.fields)\n .map(field => field.displayName);\n\n // Depending on the format, generate the template\n if (format === ImportFormat.CSV) {\n const stream = await this.csvService.createCsvStream(null, 0, headers); // Create a CSV stream with the header row\n const fileName = `${modelMetadata.singularName}-import-template.csv`;\n const mimeType = 'text/csv';\n return {\n stream,\n fileName,\n mimeType,\n };\n } else if (format === ImportFormat.EXCEL) {\n const stream = await this.excelService.createExcelStream(null, 0, headers); // Create an Excel stream with the header row\n const fileName = `${modelMetadata.singularName}-import-template.xlsx`;\n // Set the MIME type for Excel files\n const mimeType = 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet';\n return {\n stream,\n fileName,\n mimeType,\n };\n } else {\n throw new Error(`Unsupported import format: ${format}`);\n }\n\n }\n\n async getImportInstructions(modelMetadataId: number): Promise<ImportInstructionsResponseDto> {\n // Load the model metadata for the given ID\n const modelMetadata = await this.modelMetadataService.findOne(modelMetadataId, {\n populate: ['fields'],\n });\n if (!modelMetadata) {\n throw new Error(`Model metadata with ID ${modelMetadataId} not found.`);\n }\n\n // Create the standard import instructions\n const standardInstructions: StandardImportInstructionsResponseDto = {\n requiredFields: [],\n dateFields: [],\n dateTimeFields: [],\n numberFields: [],\n emailFields: [],\n regexFields: [],\n jsonFields: [],\n booleanFields: [],\n };\n\n // Iterate through the fields and populate the standard instructions\n for (const field of modelMetadata.fields) {\n if (field.isSystem) continue; // Skip system fields\n if (field.required) {\n standardInstructions.requiredFields.push(field.displayName);\n }\n if (field.type === SolidFieldType.date) {\n standardInstructions.dateFields.push(field.displayName);\n }\n if (field.type === SolidFieldType.datetime) {\n standardInstructions.dateTimeFields.push(field.displayName);\n }\n if ([SolidFieldType.bigint, SolidFieldType.int, SolidFieldType.decimal].includes(field.type as SolidFieldType)) {\n standardInstructions.numberFields.push(field.displayName);\n }\n if (field.type === SolidFieldType.email) {\n standardInstructions.emailFields.push(field.displayName);\n }\n if (field.regexPattern) {\n standardInstructions.regexFields.push({\n fieldName: field.displayName,\n regexPattern: field.regexPattern,\n });\n }\n if (field.type === SolidFieldType.json) {\n standardInstructions.jsonFields.push(field.displayName);\n }\n if (field.type === SolidFieldType.boolean) {\n standardInstructions.booleanFields.push(field.displayName);\n }\n }\n\n // Create the custom instructions\n const customInstructions: string[] = [];\n\n return {\n standard: standardInstructions,\n custom: customInstructions,\n };\n }\n\n async getImportMappingInfo(importTransactionId: number): Promise<ImportMappingInfo> {\n // Load the import transaction for the given ID\n const importTransaction = await this.loadImportTransaction(importTransactionId);\n\n // Get all the importable fields from the model metadata\n const importableFields: ImportableFieldInfo[] = this.fieldsAllowedForImport(importTransaction.modelMetadata.fields).map(field => ({\n name: field.name,\n displayName: field.displayName,\n required: field.required,\n }));\n\n // Get the import file media object from the import transaction\n const importFileMediaObject = this.getImportFileObject(importTransaction);\n\n // Get the import file stream for the import transaction\n const importFileStream = await this.getImportFileStream(importFileMediaObject);\n\n // Get a sample of records from the import file\n const sampleRecord = await this.getFileRecordsSample(importFileStream, importFileMediaObject.mimeType);\n\n // Convert sampleRecord to the format required for SampleImportedRecordInfo\n const wrappedRecords: SampleImportedRecordInfo[] = sampleRecord.data.map((record: Record<string, any>) => {\n return Object.entries(record).map(([key, value]) => ({\n cellHeader: key,\n cellValue: value,\n defaultMappedFieldName: importableFields.find(field => field.displayName === key)?.name || '',\n }));\n }).flat();\n\n // for await (const page of this.csvService.readCsvInPagesFromStream(importFileStream)) {\n // // await dbService.bulkInsert(page);\n // }\n\n return {\n sampleImportedRecordInfo: wrappedRecords, // This will hold the sample data from the file\n importableFields: importableFields, // This will hold the fields that can be imported\n };\n }\n\n async startImportSync(importTransactionId: number): Promise<ImportSyncResult> {\n // Load the import transaction for the given ID\n const importTransaction = await this.loadImportTransaction(importTransactionId);\n\n // Get the import file media object from the import transaction\n const importFileMediaObject = this.getImportFileObject(importTransaction);\n\n // Get the import file stream for the import transaction\n const importFileStream = await this.getImportFileStream(importFileMediaObject);\n\n const { ids, errorLogIds } = await this.importFromFileToDB(\n importTransaction,\n importFileStream,\n importFileMediaObject.mimeType,\n );\n\n // Update the import transaction status to 'completed'\n (errorLogIds.length > 0) ? importTransaction.status = ImportTransactionStatus.import_failed : importTransaction.status = ImportTransactionStatus.import_succeeded; //FIXME: We can probably have import_partially_failed status to differentiate\n // Save the import transaction\n await this.repo.save(importTransaction);\n return {\n status: importTransaction.status,\n importedIds: ids, // The IDs of the records created during the import\n importedCount: ids.length, // The number of records created during the import\n failedCount: errorLogIds.length, // The number of records that failed to import\n };\n }\n\n startImportAsync(importTransactionId: number): Promise<void> {\n throw new Error('Method not implemented.');\n }\n\n async exportFailedImportedImports(importTransactionId: number) {\n // Get the 1st error log entry to determine the headers for the export file\n const firstErrorLogEntry = await this.entityManager.getRepository(ImportTransactionErrorLog).findOne({\n where: {\n importTransaction: { id: importTransactionId },\n },\n });\n\n if (!firstErrorLogEntry) {\n throw new BadRequestException(`No error log entries found for import transaction ID ${importTransactionId}.`);\n }\n\n // Create the headers for the export file\n const headers = [\n ...Object.keys(firstErrorLogEntry.rowData ? JSON.parse(firstErrorLogEntry.rowData) : {}), // Include all keys from the rowData JSON\n 'Error', // Error message for the failed record\n ];\n\n\n // Depending upon the format of the import tranaction file, create a readable stream of the error log entries\n const importTransaction = await this.loadImportTransaction(importTransactionId);\n const importFileMediaObject = this.getImportFileObject(importTransaction);\n const mimeType = importFileMediaObject.mimeType;\n const templateFormat = mimeType === ImportMimeTypes.CSV ? \"csv\" : \"excel\";\n const dataRecordsFunc = async (chunkIndex: number, chunkSize: number): Promise<any[]> => {\n // Get the error log entries for the import transaction\n const errorLogEntries = await this.entityManager.getRepository(ImportTransactionErrorLog).find({\n where: {\n importTransaction: { id: importTransactionId },\n },\n skip: chunkIndex * chunkSize,\n take: chunkSize,\n });\n\n if (!errorLogEntries || errorLogEntries.length === 0) {\n return []; // Return an empty array if no error log entries found\n }\n\n // Read the row data json from the error log entry, parse it and write it as a record to the stream\n return errorLogEntries.map(entry => {\n const rowData = entry.rowData ? JSON.parse(entry.rowData) : {};\n return {\n ...rowData, // Spread the row data into the record\n Error: entry.errorMessage,\n };\n });\n };\n\n // Get the export stream for the failed records\n const exportStream = await this.getFailedRecordsStream(templateFormat, headers, dataRecordsFunc);\n if (!exportStream) {\n throw new BadRequestException(`Failed to create export stream for import transaction ID ${importTransactionId}.`);\n }\n // Return the export stream\n const extension = templateFormat === \"excel\" ? 'xlsx' : 'csv';\n return {\n stream: exportStream,\n fileName: `${importTransaction.modelMetadata.singularName}-failed-imports.${extension}`,\n mimeType: templateFormat === \"excel\" ? ImportMimeTypes.EXCEL : ImportMimeTypes.CSV,\n };\n\n }\n\n private async getFailedRecordsStream(templateFormat: string, headers: string[], dataRecordsFunc: (chunkIndex: number, chunkSize: number) => Promise<any[]>) {\n let exportStream = null;\n switch (templateFormat) {\n case \"excel\":\n exportStream = await this.excelService.createExcelStream(dataRecordsFunc, 100, headers);\n break;\n case \"csv\":\n exportStream = await this.csvService.createCsvStream(dataRecordsFunc, 100, headers);\n break;\n default:\n throw new Error('Invalid export format');\n }\n return exportStream;\n }\n\n\n private async loadImportTransaction(importTransactionId: number) {\n const importTransaction = await this.findOne(importTransactionId, {\n populate: ['modelMetadata', 'modelMetadata.fields'],\n populateMedia: ['fileLocation'],\n });\n if (!importTransaction) {\n throw new Error(`Import transaction with ID ${importTransactionId} not found.`);\n }\n return importTransaction;\n }\n\n private fieldsAllowedForImport(fields: FieldMetadata[]): FieldMetadata[] {\n // Filter out fields that are not allowed for import\n return fields.filter(field =>\n field.type !== SolidFieldType.mediaMultiple && // Exclude media multiple fields\n field.type !== SolidFieldType.mediaSingle &&\n field.type !== SolidFieldType.computed && // Exclude computed fields\n field.type !== SolidFieldType.password &&\n field.type !== SolidFieldType.richText &&\n field.type !== SolidFieldType.uuid &&\n field.isSystem !== true // Exclude system fields\n );\n }\n\n private async getFileRecordsSample(importFileStream: Readable, mimeType: string): Promise<ImportPaginatedReadResult> {\n // Depending upon the mime type of the file, read the file in pages\n // For CSV files, use the csvService to read the file in pages\n // For Excel files, use the excelService to read the file in pages\n if (mimeType === 'text/csv') {\n const generator = this.csvService.readCsvInPagesFromStream(importFileStream, { pageSize: 1 });\n const firstRecord = await generator.next(); // Get the first record to extract headers and sample data\n return firstRecord.value;\n } else if (mimeType === 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet') {\n const generator = this.excelService.readExcelInPagesFromStream(importFileStream, { pageSize: 1 });\n const firstRecord = await generator.next(); // Get the first record to extract headers and sample data\n return firstRecord.value;\n }\n else { // If the file is neither CSV nor Excel, throw an error\n throw new Error(`Unsupported file type: ${mimeType}`);\n }\n }\n\n private getImportFileObject(importTransaction: ImportTransaction): MediaWithFullUrl {\n const importFileMediaObject = importTransaction['_media']['fileLocation'][0] as MediaWithFullUrl; // Since there can be only one fileLocation, we can safely access the first element\n if (!importFileMediaObject) {\n throw new Error(`Import file for transaction ID ${importTransaction.id} not found.`);\n }\n return importFileMediaObject;\n }\n\n private async getImportFileStream(importFileMediaObject: MediaWithFullUrl): Promise<Readable> {\n const fileUrl = importFileMediaObject['_full_url'];\n const mimeType = importFileMediaObject['mimeType'];\n if (!fileUrl) {\n throw new Error(`File URL ${fileUrl} not found.`);\n }\n // From the file URL, convert the file URL to a readable stream using nestjs http service and axios\n const fileUrlResponse = await this.httpService.axiosRef.get(fileUrl, {\n responseType: 'stream',\n });\n\n if (!fileUrlResponse || !fileUrlResponse.data) {\n throw new Error(`Failed to read file from URL: ${fileUrl}`);\n }\n // fileUrlResponse.data is a Node.js Readable stream\n return fileUrlResponse.data;\n }\n\n private async importFromFileToDB(\n importTransaction: ImportTransaction,\n importFileStream: Readable,\n mimeType: string,\n ): Promise<ImportRecordsResult> {\n if (!importTransaction.modelMetadata) {\n throw new Error(`Model metadata for import transaction ID ${importTransaction.id} not found.`);\n }\n\n const createdRecordIds = [];\n const createdErrorLogIds = [];\n\n // Get the model service for the model metadata name\n const modelService = this.getModelService(importTransaction.modelMetadata.singularName);\n\n // Depending upon the mime type of the file, read the file in pages and insert the records into the database\n if (mimeType === ImportMimeTypes.CSV) {\n for await (const page of this.csvService.readCsvInPagesFromStream(importFileStream)) {\n const { ids, errorLogIds } = await this.importRecords(page, importTransaction, modelService);\n createdRecordIds.push(...ids);\n createdErrorLogIds.push(...errorLogIds);\n }\n }\n else if (mimeType === ImportMimeTypes.EXCEL) {\n for await (const page of this.excelService.readExcelInPagesFromStream(importFileStream)) {\n const { ids, errorLogIds } = await this.importRecords(page, importTransaction, modelService);\n createdRecordIds.push(...ids);\n createdErrorLogIds.push(...errorLogIds);\n }\n } else { // If the file is neither CSV nor Excel, throw an error\n throw new Error(`Unsupported file type: ${mimeType}`);\n }\n\n return {\n ids: createdRecordIds, // Return the IDs of the created records\n errorLogIds: createdErrorLogIds, // Return the IDs of the error log entries created during the import\n }\n }\n\n private async importRecords(page: ImportPaginatedReadResult, importTransaction: ImportTransaction, modelService: CRUDService<any>): Promise<ImportRecordsResult> {\n if (!importTransaction.modelMetadata || !importTransaction.modelMetadata.fields) {\n throw new Error(`Model metadata with fields for import transaction ID ${importTransaction.id} not found.`);\n }\n\n const ids: Array<number> = [];\n const errorLogIds: Array<number> = [];\n for (const record of page.data) {\n try {\n const createdRecord = await this.insertRecord(record, JSON.parse(importTransaction.mapping) as ImportMapping[], importTransaction.modelMetadata, modelService);\n ids.push(createdRecord.id); // Add the ID of the created record to the ids array\n }\n catch (error) {\n this.logger.debug(`Error inserting record: ${JSON.stringify(record)}. Error: ${error.message}`);\n // Get the Import transaction error log repo\n const errorLog = await this.createErrorLogEntry(importTransaction, record, error);\n errorLogIds.push(errorLog.id); // Add the ID of the error log entry to the errorLogIds array\n }\n }\n return {\n ids: ids, // Return the IDs of the created records\n errorLogIds: errorLogIds, // Return the IDs of the error log entries created during the import\n };\n }\n\n private async createErrorLogEntry(importTransaction: ImportTransaction, record: Record<string, any>, error: any) {\n const importTransactionRepo = this.entityManager.getRepository(ImportTransactionErrorLog);\n // Create a new ImportTransactionErrorLog entry\n const rowNumber = uuidv4(); // Generate a unique row number or use page.rowNumber if available \n\n const errorLogEntry = {\n importTransactionErrorLogId: `${importTransaction.id}-${rowNumber}`, // FIXME pending to retrieve the row number from the page\n rowNumber: 1, // FIXME pending to retrieve the row number from the page\n rowData: JSON.stringify(record), // Store the row data\n importTransaction: importTransaction, // Link to the import transaction\n errorMessage: error.message, // Store the error message\n errorTrace: error.stack || '', // Store the error stack trace if available\n } as ImportTransactionErrorLog;\n\n // Save the error log entry to the database\n const savedEntry = await importTransactionRepo.save(errorLogEntry);\n return savedEntry; // Return the ID of the saved error log entry\n }\n\n //FIXME Currently below method fails if any field in the record is not valid or if the record is not valid. It does not collect the errors for all fields in a record\n private async insertRecord(record: Record<string, any>, mapping: ImportMapping[], modelMetadataWithFields: ModelMetadata, modelService: CRUDService<any>): Promise<any> {\n // Convert the imported record to a DTO\n const dto = await this.convertImportedRecordToDto(record, mapping, modelMetadataWithFields);\n // Use the model service to create the record in the database\n const createdRecord = await modelService.create(dto, [], {}); //FIXME: Need to handle this part alongwith the refactoring of the CRUDService for permissions\n return createdRecord; // Return the created record\n }\n\n private getModelService(modelSingularName: string): CRUDService<any> {\n // Get the model service for the model metadata name\n const modelServiceWrapper = this.introspectService.getProvider(`${classify(modelSingularName)}Service`);\n const modelService = modelServiceWrapper.instance as CRUDService<any>;\n if (!modelService) {\n throw new Error(`Model service for ${modelSingularName} not found.`);\n }\n return modelService;\n }\n\n private async convertImportedRecordToDto(record: Record<string, any>, mapping: ImportMapping[], modelMetadataWithFields: ModelMetadata) {\n // Create a new record object\n const dtoRecord: Record<string, any> = {};\n\n // Iterate through every cell in the record\n // Using the saved mapping, populate the dtoRecord w.r.t the record and fields\n for (const key in record) {\n const mappedField = mapping.find(m => m.header === key);\n if (mappedField) {\n // If the field is found in the mapping, get the field metadata from the model metadata\n const fieldMetadata = modelMetadataWithFields.fields.find(f => f.name === mappedField.fieldName);\n // const userKeyField = modelMetadataWithFields.fields.find(f => f.isUserKey === true); // Assuming userKey is a field in the model metadata\n if (fieldMetadata) {\n // If the field is found in the model metadata, set the value in the dtoRecord\n await this.populateDtoForACell(dtoRecord, fieldMetadata, record, key);\n } else {\n this.logger.warn(`Field ${mappedField.fieldName} not found in model metadata ${modelMetadataWithFields.singularName}`);\n }\n }\n }\n return dtoRecord;\n }\n\n private async populateDtoForACell(dtoRecord: Record<string, any>, fieldMetadata: FieldMetadata, record: Record<string, any>, key: string): Promise<Record<string, any>> {\n const fieldType = fieldMetadata.type;\n // const userKeyFieldName = userKeyField?.name || 'id'; // Default to 'id' if not found\n\n // TODO Move this logic to field crud managers i.e add a parse method to the field crud manager interface\n switch (fieldType) {\n case SolidFieldType.relation: {\n return await this.populateDtoForRelations(fieldMetadata, record, key, dtoRecord);\n }\n case SolidFieldType.date:\n case SolidFieldType.datetime: return this.populateDtoForDate(record, key, fieldMetadata, dtoRecord);\n case SolidFieldType.int:\n case SolidFieldType.bigint:\n case SolidFieldType.decimal:\n return this.populateDtoForNumber(dtoRecord, fieldMetadata, record, key);\n case SolidFieldType.boolean:\n return this.populateDtoForBoolean(dtoRecord, fieldMetadata, record, key);\n default:\n dtoRecord[fieldMetadata.name] = record[key];\n return dtoRecord;\n }\n }\n\n private populateDtoForBoolean(dtoRecord: Record<string, any>, fieldMetadata: FieldMetadata, record: Record<string, any>, key: string) {\n const booleanValue = Boolean(record[key]);\n if (typeof booleanValue !== 'boolean') {\n throw new Error(`Invalid boolean value for cell ${key} with value ${record[key]}`);\n }\n dtoRecord[fieldMetadata.name] = booleanValue;\n return dtoRecord;\n }\n\n private populateDtoForNumber(dtoRecord: Record<string, any>, fieldMetadata: FieldMetadata, record: Record<string, any>, key: string) {\n const numberValue = Number(record[key]);\n if (isNaN(numberValue)) {\n throw new Error(`Invalid number value for cell ${key} with value ${record[key]}`);\n }\n dtoRecord[fieldMetadata.name] = numberValue;\n return dtoRecord;\n }\n\n private populateDtoForDate(record: Record<string, any>, key: string, fieldMetadata: FieldMetadata, dtoRecord: Record<string, any>) {\n {\n const dateValue = new Date(record[key]);\n if (isNaN(dateValue.getTime())) {\n throw new Error(`Invalid date value for cell ${key} with value ${record[key]}`);\n }\n dtoRecord[fieldMetadata.name] = dateValue;\n return dtoRecord;\n }\n }\n\n private async populateDtoForRelations(fieldMetadata: FieldMetadata, record: Record<string, any>, key: string, dtoRecord: Record<string, any>) {\n if (!fieldMetadata.relationCoModelSingularName) {\n throw new Error(`Relation coModelSingularName is not defined for relation field ${fieldMetadata.name}`);\n }\n\n const relatedRecordsIds = await this.getRelatedEntityIdsFromUserKeys(fieldMetadata, record, key);\n if (relatedRecordsIds.length === 0) {\n return dtoRecord; // If no related records found, return the dtoRecord as is\n }\n\n if (fieldMetadata.relationType === RelationType.manyTomany || fieldMetadata.relationType === RelationType.oneToMany) {\n dtoRecord[`${fieldMetadata.name}Ids`] = relatedRecordsIds;\n dtoRecord[`${fieldMetadata.name}Command`] = RelationFieldsCommand.set; // Reset the relation field association with the related records IDs\n }\n else if (fieldMetadata.relationType === RelationType.manyToOne) {\n dtoRecord[`${fieldMetadata.name}Id`] = relatedRecordsIds.pop(); // For many-to-one relations, we need only one ID\n }\n return dtoRecord;\n }\n\n private async getRelatedEntityIdsFromUserKeys(fieldMetadata: FieldMetadata, record: Record<string, any>, key: string): Promise<Array<number>> {\n // For many-to-many or one-to-many relations, we expect the record cell to contains a comma-separated list of userKeys\n const relationUserKeys = record[key] ? String(record[key]).split(',').map((userKey: string) => userKey.trim()) : [];\n if (relationUserKeys.length === 0) return [];\n\n const coModelService = this.getModelService(fieldMetadata.relationCoModelSingularName);\n const coModelWithUserKeyField = await this.modelMetadataService.findOneBySingularName(fieldMetadata.relationCoModelSingularName, ['userKeyField']);\n const coModelUserKeyFieldName = coModelWithUserKeyField?.userKeyField?.name || 'id'; // Default to 'id' if not found\n\n\n // Set the relation basic filter dto filters with the userkeys and call the find method of the model service to get the related records\n const relationFilterDto = {\n filters: {\n [coModelUserKeyFieldName]: {\n $in: relationUserKeys, // Use the userKeyFieldName to filter by userKeys\n },\n },\n };\n\n // From the userKeys, we will get the IDs of the related records using the userKeyFieldName and throw an error if any of the userKeys is not found\n const relatedRecordsResult = await coModelService.find(relationFilterDto);\n if (!relatedRecordsResult || !relatedRecordsResult.records || relatedRecordsResult.records.length === 0 || relatedRecordsResult.records.length !== relationUserKeys.length) {\n throw new Error(`Invalid related records userKey values found for cell ${key} with value ${record[key]}`);\n }\n const relatedRecordsIds = relatedRecordsResult.records.map(record => record.id);\n return relatedRecordsIds;\n }\n}"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"menu-item-metadata.service.d.ts","sourceRoot":"","sources":["../../src/services/menu-item-metadata.service.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,gBAAgB,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AAC3D,OAAO,EAAE,aAAa,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AACpD,OAAO,EAAE,WAAW,EAAE,MAAM,2BAA2B,CAAC;AACxD,OAAO,EAAE,oBAAoB,EAAE,MAAM,qCAAqC,CAAC;AAC3E,OAAO,EAAE,qBAAqB,EAAE,MAAM,sCAAsC,CAAC;AAC7E,OAAO,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAC;AAC/C,OAAO,EAAE,WAAW,EAAE,MAAM,2BAA2B,CAAC;AACxD,OAAO,EAAE,iBAAiB,EAAE,MAAM,kCAAkC,CAAC;AAGrE,OAAO,EAAE,gBAAgB,EAAE,MAAM,uCAAuC,CAAC;AACzE,OAAO,EAAE,yBAAyB,EAAE,MAAM,uCAAuC,CAAC;AAClF,OAAO,EAAE,cAAc,EAAE,MAAM,2CAA2C,CAAC;AAI3E,qBACa,uBAAwB,SAAQ,WAAW,CAAC,gBAAgB,CAAC;IAEtE,QAAQ,CAAC,oBAAoB,EAAE,oBAAoB;IACnD,Q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A2B,CAAC;AACxD,OAAO,EAAE,iBAAiB,EAAE,MAAM,kCAAkC,CAAC;AAGrE,OAAO,EAAE,gBAAgB,EAAE,MAAM,uCAAuC,CAAC;AACzE,OAAO,EAAE,yBAAyB,EAAE,MAAM,uCAAuC,CAAC;AAClF,OAAO,EAAE,cAAc,EAAE,MAAM,2CAA2C,CAAC;AAI3E,qBACa,uBAAwB,SAAQ,WAAW,CAAC,gBAAgB,CAAC;IAEtE,QAAQ,CAAC,oBAAoB,EAAE,oBAAoB;IACnD,QAAQ,CAAC,qBAAqB,EAAE,qBAAqB;IACrD,QAAQ,CAAC,aAAa,EAAE,aAAa;IACrC,QAAQ,CAAC,WAAW,EAAE,WAAW;IACjC,QAAQ,CAAC,gBAAgB,EAAE,gBAAgB;IAC3C,QAAQ,CAAC,iBAAiB,EAAE,iBAAiB;IAE7C,QAAQ,CAAC,aAAa,EAAE,aAAa;IAErC,QAAQ,CAAC,IAAI,EAAE,UAAU,CAAC,gBAAgB,CAAC;IAC3C,QAAQ,CAAC,SAAS,EAAE,SAAS;gBAVpB,oBAAoB,EAAE,oBAAoB,EAC1C,qBAAqB,EAAE,qBAAqB,EAC5C,aAAa,EAAE,aAAa,EAC5B,WAAW,EAAE,WAAW,EACxB,gBAAgB,EAAE,gBAAgB,EAClC,iBAAiB,EAAE,iBAAiB,EAEpC,aAAa,EAAE,aAAa,EAE5B,IAAI,EAAE,UAAU,CAAC,gBAAgB,CAAC,EAClC,SAAS,EAAE,SAAS;IAOzB,gBAAgB,CAAC,IAAI,EAAE,MAAM,EAAE,SAAS,KAAK;IAU7C,MAAM,CAAC,sBAAsB,EAAE,yBAAyB;IA+BxD,aAAa,CAAC,UAAU,EAAE,cAAc;IAkE9C,OAAO,CAAC,aAAa;CAiDtB"}
|
|
@@ -120,7 +120,7 @@ let MenuItemMetadataService = class MenuItemMetadataService extends crud_service
|
|
|
120
120
|
}
|
|
121
121
|
if (rootItem.action && rootItem.action.type === 'solid') {
|
|
122
122
|
if (this.crudHelperService.hasReadPermissionOnModel(activeUser, rootItem.action.model.singularName)) {
|
|
123
|
-
path = `/admin/core/${rootItem.module.name}/${(0, strings_1.dasherize)(rootItem.action
|
|
123
|
+
path = `/admin/core/${rootItem.module.name}/${(0, strings_1.dasherize)(rootItem.action?.model?.singularName ?? 'unknown')}/${rootItem.action?.view?.type ?? 'list'}`;
|
|
124
124
|
}
|
|
125
125
|
}
|
|
126
126
|
const data = {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"menu-item-metadata.service.js","sourceRoot":"","sources":["../../src/services/menu-item-metadata.service.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,2CAA4C;AAC5C,6CAAwE;AACxE,uCAA2D;AAC3D,qCAAoD;AACpD,iDAAwD;AACxD,qEAA2E;AAC3E,uEAA6E;AAC7E,2CAA+C;AAC/C,iDAAwD;AACxD,+DAAqE;AAGrE,qFAAyE;AAIzE,oEAAmE;AAG5D,IAAM,uBAAuB,GAA7B,MAAM,uBAAwB,SAAQ,0BAA6B;IACxE,YACW,oBAA0C,EAC1C,qBAA4C,EAC5C,aAA4B,EAC5B,WAAwB,EACxB,gBAAkC,EAClC,iBAAoC,EAEpC,aAA4B,EAE5B,IAAkC,EAClC,SAAoB;QAG7B,KAAK,CAAC,oBAAoB,EAAE,qBAAqB,EAAE,aAAa,EAAE,WAAW,EAAE,gBAAgB,EAAE,iBAAiB,EAAE,aAAa,EAAE,IAAI,EAAE,kBAAkB,EAAE,YAAY,EAAE,SAAS,CAAC,CAAC;QAb7K,yBAAoB,GAApB,oBAAoB,CAAsB;QAC1C,0BAAqB,GAArB,qBAAqB,CAAuB;QAC5C,kBAAa,GAAb,aAAa,CAAe;QAC5B,gBAAW,GAAX,WAAW,CAAa;QACxB,qBAAgB,GAAhB,gBAAgB,CAAkB;QAClC,sBAAiB,GAAjB,iBAAiB,CAAmB;QAEpC,kBAAa,GAAb,aAAa,CAAe;QAE5B,SAAI,GAAJ,IAAI,CAA8B;Q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AAmB,GAAE,CAAA;IAErB,WAAA,IAAA,0BAAgB,EAAC,4CAAgB,EAAE,SAAS,CAAC,CAAA;qCARf,6CAAoB;QACnB,+CAAqB;QAC7B,sBAAa;QACf,0BAAW;QACN,uBAAgB;QACf,uCAAiB;QAErB,uBAAa;QAEtB,oBAAU;QACL,gBAAS;GAZpB,uBAAuB,CA8KnC","sourcesContent":["import { Injectable } from '@nestjs/common';\nimport { InjectEntityManager, InjectRepository } from '@nestjs/typeorm';\nimport { DiscoveryService, ModuleRef } from \"@nestjs/core\";\nimport { EntityManager, Repository } from 'typeorm';\nimport { CRUDService } from 'src/services/crud.service';\nimport { ModelMetadataService } from 'src/services/model-metadata.service';\nimport { ModuleMetadataService } from 'src/services/module-metadata.service';\nimport { ConfigService } from '@nestjs/config';\nimport { FileService } from \"src/services/file.service\";\nimport { CrudHelperService } from \"src/services/crud-helper.service\";\n\n\nimport { MenuItemMetadata } from '../entities/menu-item-metadata.entity';\nimport { UpdateMenuItemMetadataDto } from '../dtos/update-menu-item-metadata.dto';\nimport { ActiveUserData } from 'src/interfaces/active-user-data.interface';\nimport { ModuleMetadata } from '../entities/module-metadata.entity';\nimport { dasherize } from '@angular-devkit/core/src/utils/strings';\n\n@Injectable()\nexport class MenuItemMetadataService extends CRUDService<MenuItemMetadata> {\n constructor(\n readonly modelMetadataService: ModelMetadataService,\n readonly moduleMetadataService: ModuleMetadataService,\n readonly configService: ConfigService,\n readonly fileService: FileService,\n readonly discoveryService: DiscoveryService,\n readonly crudHelperService: CrudHelperService,\n @InjectEntityManager()\n readonly entityManager: EntityManager,\n @InjectRepository(MenuItemMetadata, 'default')\n readonly repo: Repository<MenuItemMetadata>,\n readonly moduleRef: ModuleRef\n\n ) {\n super(modelMetadataService, moduleMetadataService, configService, fileService, discoveryService, crudHelperService, entityManager, repo, 'menuItemMetadata', 'solid-core', moduleRef);\n }\n\n\n async findOneByUserKey(name: string, relations = {}) {\n const entity = await this.repo.findOne({\n where: {\n name: name,\n },\n relations: relations,\n });\n return entity;\n }\n\n async upsert(updateSolidMenuItemDto: UpdateMenuItemMetadataDto) {\n // Leave out all the extra attributes only keep the ones we are interested in updating.\n const { moduleUserKey, parentMenuItemUserKey, actionUserKey, rolesIds, rolesCommand, ...cleanUpdateSolidMenuItemDto } = updateSolidMenuItemDto;\n\n // First check if module already exists using name\n const existingMenuItem = await this.repo.findOne({\n where: {\n name: updateSolidMenuItemDto.name\n },\n relations: [\"roles\"]\n });\n\n // if found\n if (existingMenuItem) {\n const updatedSolidActionDto = { ...existingMenuItem, ...cleanUpdateSolidMenuItemDto };\n // @ts-ignore\n return this.repo.save(updatedSolidActionDto);\n // await this.repo.remove(existingSolidAction);\n }\n // if not found - create new \n else {\n // @ts-ignore\n const moduleMetadata = this.repo.create(cleanUpdateSolidMenuItemDto);\n return this.repo.save(moduleMetadata);\n }\n // const moduleMetadata = this.repo.create(updateSolidMenuItemDto);\n // return this.repo.save(moduleMetadata);\n\n }\n\n\n async findUserMenus(activeUser: ActiveUserData) {\n // 1. For the users role, fire a query to load all menus that this role has access to. \n // const usersMenuItems = this.solidMenuItemRepo.find({\n // where: {\n // roles: {\n // name: In(activeUser.roles)\n // }\n // },\n // relations: ['module', 'parentMenuItem', 'action']\n // });\n const menuItems = await this.repo\n .createQueryBuilder('menuItem')\n .leftJoinAndSelect('menuItem.module', 'module')\n .leftJoinAndSelect('menuItem.parentMenuItem', 'parentMenuItem')\n .leftJoinAndSelect('menuItem.action', 'action')\n .leftJoinAndSelect('action.model', 'model') // Join the model relation of action\n .leftJoinAndSelect('action.view', 'view') // Join the model relation of action\n .leftJoinAndSelect('menuItem.roles', 'roles')\n .where('roles.name IN (:...roleNames)', { roleNames: activeUser.roles })\n .addOrderBy('module.menuSequenceNumber', 'ASC')\n .addOrderBy('menuItem.sequenceNumber', 'ASC')\n .getMany();\n\n // 2. First arrange the output of the above query by module based on module\n const modulesToMenuItemsMap = new Map<string, MenuItemMetadata[]>();\n const modulesMap = new Map<string, ModuleMetadata>();\n menuItems.forEach(menuItem => {\n const moduleName = menuItem.module.name;\n\n // Keep track of all menu items under a given module.\n if (!modulesToMenuItemsMap.has(moduleName)) {\n modulesToMenuItemsMap.set(moduleName, []);\n }\n modulesToMenuItemsMap.get(moduleName).push(menuItem);\n\n // Keep track of the modules information separately.\n if (!modulesMap.has(moduleName)) {\n modulesMap.set(moduleName, menuItem.module);\n }\n });\n\n // 3. Then for each module, do a recursive compilation of children based on parentMenuItem, while doing this use the relation - action to get hold of the path. \n const menu: any[] = [];\n\n modulesToMenuItemsMap.forEach((menuItems, moduleName) => {\n const rootMenuItems = menuItems.filter(item => !item.parentMenuItem);\n const moduleMetadata = modulesMap.get(moduleName);\n\n const moduleMenu = {\n title: moduleMetadata.displayName,\n // No need for path the module level.\n // path: ``,\n key: moduleName.toLowerCase().replace(/\\s+/g, '-'),\n // TODO: We need to add the module icon as part of the metadata so it can be brought here. \n // icon: `/images/menu/${moduleName.toLowerCase().replace(/\\s+/g, '-')}.svg`,\n children: this.buildMenuTree(rootMenuItems, menuItems, activeUser),\n icon: moduleMetadata.menuIconUrl,\n };\n\n menu.push(moduleMenu);\n });\n\n return menu.filter(m => m.children.length > 0);\n }\n\n // Recursive function to build the tree\n private buildMenuTree(rootItems: MenuItemMetadata[], allMenuItems: MenuItemMetadata[], activeUser: ActiveUserData): any[] {\n const menuItemsData = rootItems.map(rootItem => {\n const allowedMenuItems = allMenuItems.filter(i => {\n if (!i.parentMenuItem) {\n return true\n } else {\n return this.crudHelperService.hasReadPermissionOnModel(activeUser, i.action.model.singularName)\n }\n });\n // Get immediate children of the current loop variable menuItem.\n const children = allowedMenuItems.filter(item => item.parentMenuItem && item.parentMenuItem.id === rootItem.id);\n\n // TODO: We should specify path only if there are no more children present. \n // For now adding path everywhere. \n let path = '';\n\n if (rootItem.action && rootItem.action.type === 'custom') {\n path = rootItem.action.customComponent;\n }\n if (rootItem.action && rootItem.action.type === 'solid') {\n if (this.crudHelperService.hasReadPermissionOnModel(activeUser, rootItem.action.model.singularName)) {\n\n\n // TODO: Here we are assuming that we will always take the user to collection view of a model. \n // We can make provision to take them other views also in the future. \n // path = `/admin/core/${rootItem.module.name}/${rootItem.action.model.singularName}/${rootItem.action.view.name}`;\n path = `/admin/core/${rootItem.module.name}/${dasherize(rootItem.action.model.singularName)}/${rootItem.action.view.type}`;\n }\n }\n\n // We are not checking for empty path coz, this is required for parent menu items.\n const data = {\n title: rootItem.displayName || rootItem.name,\n path: path,\n key: rootItem.name.toLowerCase().replace(/\\s+/g, '-'),\n icon: rootItem.iconName,\n // iconVariant : rootItem.iconVariant\n }\n if (children.length > 0) {\n data[\"children\"] = this.buildMenuTree(children, allMenuItems, activeUser);\n }\n return data;\n\n });\n return menuItemsData.filter(mi => mi && mi)\n }\n\n\n}\n"]}
|
|
1
|
+
{"version":3,"file":"menu-item-metadata.service.js","sourceRoot":"","sources":["../../src/services/menu-item-metadata.service.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,2CAA4C;AAC5C,6CAAwE;AACxE,uCAA2D;AAC3D,qCAAoD;AACpD,iDAAwD;AACxD,qEAA2E;AAC3E,uEAA6E;AAC7E,2CAA+C;AAC/C,iDAAwD;AACxD,+DAAqE;AAGrE,qFAAyE;AAIzE,oEAAmE;AAG5D,IAAM,uBAAuB,GAA7B,MAAM,uBAAwB,SAAQ,0BAA6B;IACxE,YACW,oBAA0C,EAC1C,qBAA4C,EAC5C,aAA4B,EAC5B,WAAwB,EACxB,gBAAkC,EAClC,iBAAoC,EAEpC,aAA4B,EAE5B,IAAkC,EAClC,SAAoB;QAG7B,KAAK,CAAC,oBAAoB,EAAE,qBAAqB,EAAE,aAAa,EAAE,WAAW,EAAE,gBAAgB,EAAE,iBAAiB,EAAE,aAAa,EAAE,IAAI,EAAE,kBAAkB,EAAE,YAAY,EAAE,SAAS,CAAC,CAAC;QAb7K,yBAAoB,GAApB,oBAAoB,CAAsB;QAC1C,0BAAqB,GAArB,qBAAqB,CAAuB;QAC5C,kBAA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AC;QAEd,CAAC,CAAC,CAAC;QACH,OAAO,aAAa,CAAC,MAAM,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,IAAI,EAAE,CAAC,CAAA;IAC7C,CAAC;CAGF,CAAA;AA/KY,0DAAuB;kCAAvB,uBAAuB;IADnC,IAAA,mBAAU,GAAE;IASR,WAAA,IAAA,6BAAmB,GAAE,CAAA;IAErB,WAAA,IAAA,0BAAgB,EAAC,4CAAgB,EAAE,SAAS,CAAC,CAAA;qCARf,6CAAoB;QACnB,+CAAqB;QAC7B,sBAAa;QACf,0BAAW;QACN,uBAAgB;QACf,uCAAiB;QAErB,uBAAa;QAEtB,oBAAU;QACL,gBAAS;GAZpB,uBAAuB,CA+KnC","sourcesContent":["import { Injectable } from '@nestjs/common';\nimport { InjectEntityManager, InjectRepository } from '@nestjs/typeorm';\nimport { DiscoveryService, ModuleRef } from \"@nestjs/core\";\nimport { EntityManager, Repository } from 'typeorm';\nimport { CRUDService } from 'src/services/crud.service';\nimport { ModelMetadataService } from 'src/services/model-metadata.service';\nimport { ModuleMetadataService } from 'src/services/module-metadata.service';\nimport { ConfigService } from '@nestjs/config';\nimport { FileService } from \"src/services/file.service\";\nimport { CrudHelperService } from \"src/services/crud-helper.service\";\n\n\nimport { MenuItemMetadata } from '../entities/menu-item-metadata.entity';\nimport { UpdateMenuItemMetadataDto } from '../dtos/update-menu-item-metadata.dto';\nimport { ActiveUserData } from 'src/interfaces/active-user-data.interface';\nimport { ModuleMetadata } from '../entities/module-metadata.entity';\nimport { dasherize } from '@angular-devkit/core/src/utils/strings';\n\n@Injectable()\nexport class MenuItemMetadataService extends CRUDService<MenuItemMetadata> {\n constructor(\n readonly modelMetadataService: ModelMetadataService,\n readonly moduleMetadataService: ModuleMetadataService,\n readonly configService: ConfigService,\n readonly fileService: FileService,\n readonly discoveryService: DiscoveryService,\n readonly crudHelperService: CrudHelperService,\n @InjectEntityManager()\n readonly entityManager: EntityManager,\n @InjectRepository(MenuItemMetadata, 'default')\n readonly repo: Repository<MenuItemMetadata>,\n readonly moduleRef: ModuleRef\n\n ) {\n super(modelMetadataService, moduleMetadataService, configService, fileService, discoveryService, crudHelperService, entityManager, repo, 'menuItemMetadata', 'solid-core', moduleRef);\n }\n\n\n async findOneByUserKey(name: string, relations = {}) {\n const entity = await this.repo.findOne({\n where: {\n name: name,\n },\n relations: relations,\n });\n return entity;\n }\n\n async upsert(updateSolidMenuItemDto: UpdateMenuItemMetadataDto) {\n // Leave out all the extra attributes only keep the ones we are interested in updating.\n const { moduleUserKey, parentMenuItemUserKey, actionUserKey, rolesIds, rolesCommand, ...cleanUpdateSolidMenuItemDto } = updateSolidMenuItemDto;\n\n // First check if module already exists using name\n const existingMenuItem = await this.repo.findOne({\n where: {\n name: updateSolidMenuItemDto.name\n },\n relations: [\"roles\"]\n });\n\n // if found\n if (existingMenuItem) {\n const updatedSolidActionDto = { ...existingMenuItem, ...cleanUpdateSolidMenuItemDto };\n // @ts-ignore\n return this.repo.save(updatedSolidActionDto);\n // await this.repo.remove(existingSolidAction);\n }\n // if not found - create new \n else {\n // @ts-ignore\n const moduleMetadata = this.repo.create(cleanUpdateSolidMenuItemDto);\n return this.repo.save(moduleMetadata);\n }\n // const moduleMetadata = this.repo.create(updateSolidMenuItemDto);\n // return this.repo.save(moduleMetadata);\n\n }\n\n\n async findUserMenus(activeUser: ActiveUserData) {\n // 1. For the users role, fire a query to load all menus that this role has access to. \n // const usersMenuItems = this.solidMenuItemRepo.find({\n // where: {\n // roles: {\n // name: In(activeUser.roles)\n // }\n // },\n // relations: ['module', 'parentMenuItem', 'action']\n // });\n const menuItems = await this.repo\n .createQueryBuilder('menuItem')\n .leftJoinAndSelect('menuItem.module', 'module')\n .leftJoinAndSelect('menuItem.parentMenuItem', 'parentMenuItem')\n .leftJoinAndSelect('menuItem.action', 'action')\n .leftJoinAndSelect('action.model', 'model') // Join the model relation of action\n .leftJoinAndSelect('action.view', 'view') // Join the model relation of action\n .leftJoinAndSelect('menuItem.roles', 'roles')\n .where('roles.name IN (:...roleNames)', { roleNames: activeUser.roles })\n .addOrderBy('module.menuSequenceNumber', 'ASC')\n .addOrderBy('menuItem.sequenceNumber', 'ASC')\n .getMany();\n\n // 2. First arrange the output of the above query by module based on module\n const modulesToMenuItemsMap = new Map<string, MenuItemMetadata[]>();\n const modulesMap = new Map<string, ModuleMetadata>();\n menuItems.forEach(menuItem => {\n const moduleName = menuItem.module.name;\n\n // Keep track of all menu items under a given module.\n if (!modulesToMenuItemsMap.has(moduleName)) {\n modulesToMenuItemsMap.set(moduleName, []);\n }\n modulesToMenuItemsMap.get(moduleName).push(menuItem);\n\n // Keep track of the modules information separately.\n if (!modulesMap.has(moduleName)) {\n modulesMap.set(moduleName, menuItem.module);\n }\n });\n\n // 3. Then for each module, do a recursive compilation of children based on parentMenuItem, while doing this use the relation - action to get hold of the path. \n const menu: any[] = [];\n\n modulesToMenuItemsMap.forEach((menuItems, moduleName) => {\n const rootMenuItems = menuItems.filter(item => !item.parentMenuItem);\n const moduleMetadata = modulesMap.get(moduleName);\n\n const moduleMenu = {\n title: moduleMetadata.displayName,\n // No need for path the module level.\n // path: ``,\n key: moduleName.toLowerCase().replace(/\\s+/g, '-'),\n // TODO: We need to add the module icon as part of the metadata so it can be brought here. \n // icon: `/images/menu/${moduleName.toLowerCase().replace(/\\s+/g, '-')}.svg`,\n children: this.buildMenuTree(rootMenuItems, menuItems, activeUser),\n icon: moduleMetadata.menuIconUrl,\n };\n\n menu.push(moduleMenu);\n });\n\n return menu.filter(m => m.children.length > 0);\n }\n\n // Recursive function to build the tree\n private buildMenuTree(rootItems: MenuItemMetadata[], allMenuItems: MenuItemMetadata[], activeUser: ActiveUserData): any[] {\n const menuItemsData = rootItems.map(rootItem => {\n const allowedMenuItems = allMenuItems.filter(i => {\n if (!i.parentMenuItem) {\n return true\n } else {\n return this.crudHelperService.hasReadPermissionOnModel(activeUser, i.action.model.singularName)\n }\n });\n // Get immediate children of the current loop variable menuItem.\n const children = allowedMenuItems.filter(item => item.parentMenuItem && item.parentMenuItem.id === rootItem.id);\n\n // TODO: We should specify path only if there are no more children present. \n // For now adding path everywhere. \n let path = '';\n\n if (rootItem.action && rootItem.action.type === 'custom') {\n path = rootItem.action.customComponent;\n }\n if (rootItem.action && rootItem.action.type === 'solid') {\n if (this.crudHelperService.hasReadPermissionOnModel(activeUser, rootItem.action.model.singularName)) {\n\n\n // TODO: Here we are assuming that we will always take the user to collection view of a model. \n // We can make provision to take them other views also in the future. \n // path = `/admin/core/${rootItem.module.name}/${rootItem.action.model.singularName}/${rootItem.action.view.name}`;\n path = `/admin/core/${rootItem.module.name}/${dasherize(rootItem.action?.model?.singularName ?? 'unknown')}/${rootItem.action?.view?.type ?? 'list'}`;\n\n }\n }\n\n // We are not checking for empty path coz, this is required for parent menu items.\n const data = {\n title: rootItem.displayName || rootItem.name,\n path: path,\n key: rootItem.name.toLowerCase().replace(/\\s+/g, '-'),\n icon: rootItem.iconName,\n // iconVariant : rootItem.iconVariant\n }\n if (children.length > 0) {\n data[\"children\"] = this.buildMenuTree(children, allMenuItems, activeUser);\n }\n return data;\n\n });\n return menuItemsData.filter(mi => mi && mi)\n }\n\n\n}\n"]}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { Question } from "src/entities/question.entity";
|
|
2
|
+
import { IDashboardQuestionDataProvider } from "src/interfaces";
|
|
3
|
+
import { EntityManager } from "typeorm";
|
|
4
|
+
import { SqlExpressionResolverService } from "../sql-expression-resolver.service";
|
|
5
|
+
export interface QuestionSqlDataProviderContext {
|
|
6
|
+
}
|
|
7
|
+
export declare enum SqlExpressionOperator {
|
|
8
|
+
EQUALS = "$equals",
|
|
9
|
+
NOT_EQUALS = "$notEquals",
|
|
10
|
+
CONTAINS = "$contains",
|
|
11
|
+
NOT_CONTAINS = "$notContains",
|
|
12
|
+
STARTS_WITH = "$startsWith",
|
|
13
|
+
ENDS_WITH = "$endsWith",
|
|
14
|
+
IN = "$in",
|
|
15
|
+
NOT_IN = "$notIn",
|
|
16
|
+
BETWEEN = "$between",
|
|
17
|
+
LT = "$lt",
|
|
18
|
+
LTE = "$lte",
|
|
19
|
+
GT = "$gt",
|
|
20
|
+
GTE = "$gte"
|
|
21
|
+
}
|
|
22
|
+
export interface SqlExpression {
|
|
23
|
+
variableName: string;
|
|
24
|
+
operator: SqlExpressionOperator;
|
|
25
|
+
value: string[];
|
|
26
|
+
}
|
|
27
|
+
export declare class ChartJsSqlDataProvider implements IDashboardQuestionDataProvider<QuestionSqlDataProviderContext, any> {
|
|
28
|
+
private readonly entityManager;
|
|
29
|
+
private readonly sqlExpressionResolver;
|
|
30
|
+
private readonly logger;
|
|
31
|
+
constructor(entityManager: EntityManager, sqlExpressionResolver: SqlExpressionResolverService);
|
|
32
|
+
help(): string;
|
|
33
|
+
name(): string;
|
|
34
|
+
getData(question: Question, expressions?: SqlExpression[], context?: QuestionSqlDataProviderContext): Promise<any>;
|
|
35
|
+
}
|
|
36
|
+
//# sourceMappingURL=chartjs-sql-data-provider.service.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"chartjs-sql-data-provider.service.d.ts","sourceRoot":"","sources":["../../../src/services/question-data-providers/chartjs-sql-data-provider.service.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,QAAQ,EAAE,MAAM,8BAA8B,CAAC;AACxD,OAAO,EAAE,8BAA8B,EAAE,MAAM,gBAAgB,CAAC;AAChE,OAAO,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AACxC,OAAO,EAAE,4BAA4B,EAAE,MAAM,oCAAoC,CAAC;AAIlF,MAAM,WAAW,8BAA8B;CAI9C;AAED,oBAAY,qBAAqB;IAC7B,MAAM,YAAY;IAClB,UAAU,eAAe;IACzB,QAAQ,cAAc;IACtB,YAAY,iBAAiB;IAC7B,WAAW,gBAAgB;IAC3B,SAAS,cAAc;IACvB,EAAE,QAAQ;IACV,MAAM,WAAW;IACjB,OAAO,aAAa;IACpB,EAAE,QAAQ;IACV,GAAG,SAAS;IACZ,EAAE,QAAQ;IACV,GAAG,SAAS;CACf;AAED,MAAM,WAAW,aAAa;IAC1B,YAAY,EAAE,MAAM,CAAC;IACrB,QAAQ,EAAE,qBAAqB,CAAC;IAChC,KAAK,EAAE,MAAM,EAAE,CAAC;CACnB;AAED,qBAEa,sBAAuB,YAAW,8BAA8B,CAAC,8BAA8B,EAAE,GAAG,CAAC;IAGlG,OAAO,CAAC,QAAQ,CAAC,aAAa;IAAiB,OAAO,CAAC,QAAQ,CAAC,qBAAqB;IAFjG,OAAO,CAAC,QAAQ,CAAC,MAAM,CAA2C;gBAErC,aAAa,EAAE,aAAa,EAAmB,qBAAqB,EAAE,4BAA4B;IAE/H,IAAI,IAAI,MAAM;IAId,IAAI,IAAI,MAAM;IAIR,OAAO,CAAC,QAAQ,EAAE,QAAQ,EAAE,WAAW,CAAC,EAAE,aAAa,EAAE,EAAE,OAAO,CAAC,EAAE,8BAA8B,GAAG,OAAO,CAAC,GAAG,CAAC;CAoE3H"}
|