@servicelabsco/slabs-access-manager 1.0.70 → 1.0.71
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/access/controllers/report.view.controller.d.ts +30 -12
- package/dist/access/dtos/report.view.query.dto.d.ts +1 -0
- package/dist/access/dtos/report.view.query.dto.js +20 -0
- package/dist/access/dtos/report.view.query.dto.js.map +1 -1
- package/dist/access/entities/business.material.view.entity.d.ts +9 -0
- package/dist/access/entities/business.material.view.entity.js +44 -0
- package/dist/access/entities/business.material.view.entity.js.map +1 -0
- package/dist/access/entities/index.d.ts +1 -0
- package/dist/access/entities/index.js +1 -0
- package/dist/access/entities/index.js.map +1 -1
- package/dist/access/es6.classes.d.ts +10 -3
- package/dist/access/es6.classes.js +6 -0
- package/dist/access/es6.classes.js.map +1 -1
- package/dist/access/libraries/index.d.ts +1 -0
- package/dist/access/libraries/index.js +1 -0
- package/dist/access/libraries/index.js.map +1 -1
- package/dist/access/libraries/report.view.enablement.d.ts +11 -0
- package/dist/access/libraries/report.view.enablement.js +49 -0
- package/dist/access/libraries/report.view.enablement.js.map +1 -0
- package/dist/access/libraries/report.view.query.compiler.d.ts +35 -2
- package/dist/access/libraries/report.view.query.compiler.js +274 -46
- package/dist/access/libraries/report.view.query.compiler.js.map +1 -1
- package/dist/access/services/listing.preference.service.js +11 -1
- package/dist/access/services/listing.preference.service.js.map +1 -1
- package/dist/access/services/listing.service.d.ts +3 -1
- package/dist/access/services/listing.service.js +7 -6
- package/dist/access/services/listing.service.js.map +1 -1
- package/dist/access/services/report.view.service.d.ts +34 -12
- package/dist/access/services/report.view.service.js +80 -13
- package/dist/access/services/report.view.service.js.map +1 -1
- package/dist/access/subscribers/business.material.view.subscriber.d.ts +8 -0
- package/dist/access/subscribers/business.material.view.subscriber.js +31 -0
- package/dist/access/subscribers/business.material.view.subscriber.js.map +1 -0
- package/dist/access/subscribers/index.d.ts +1 -0
- package/dist/access/subscribers/index.js +1 -0
- package/dist/access/subscribers/index.js.map +1 -1
- package/dist/development/controllers/development.catalog.controller.d.ts +25 -0
- package/dist/development/controllers/development.catalog.controller.js +32 -0
- package/dist/development/controllers/development.catalog.controller.js.map +1 -1
- package/dist/development/dtos/material.view.catalog.attributes.dto.d.ts +16 -0
- package/dist/development/dtos/material.view.catalog.attributes.dto.js +63 -1
- package/dist/development/dtos/material.view.catalog.attributes.dto.js.map +1 -1
- package/dist/development/services/admin.report.view.service.d.ts +23 -0
- package/dist/development/services/admin.report.view.service.js +195 -13
- package/dist/development/services/admin.report.view.service.js.map +1 -1
- package/dist/mcp/admin/tools/admin.tool.registry.js +6 -0
- package/dist/mcp/admin/tools/admin.tool.registry.js.map +1 -1
- package/dist/mcp/admin/tools/catalog/admin.column.describe.tool.js +1 -1
- package/dist/mcp/admin/tools/catalog/admin.column.describe.tool.js.map +1 -1
- package/dist/mcp/admin/tools/catalog/admin.view.business.clear.tool.d.ts +18 -0
- package/dist/mcp/admin/tools/catalog/admin.view.business.clear.tool.js +27 -0
- package/dist/mcp/admin/tools/catalog/admin.view.business.clear.tool.js.map +1 -0
- package/dist/mcp/admin/tools/catalog/admin.view.business.set.tool.d.ts +20 -0
- package/dist/mcp/admin/tools/catalog/admin.view.business.set.tool.js +28 -0
- package/dist/mcp/admin/tools/catalog/admin.view.business.set.tool.js.map +1 -0
- package/dist/mcp/admin/tools/catalog/admin.view.businesses.tool.d.ts +17 -0
- package/dist/mcp/admin/tools/catalog/admin.view.businesses.tool.js +23 -0
- package/dist/mcp/admin/tools/catalog/admin.view.businesses.tool.js.map +1 -0
- package/dist/mcp/admin/tools/catalog/admin.view.columns.sync.tool.d.ts +3 -1
- package/dist/mcp/admin/tools/catalog/admin.view.columns.sync.tool.js +5 -1
- package/dist/mcp/admin/tools/catalog/admin.view.columns.sync.tool.js.map +1 -1
- package/dist/mcp/admin/tools/catalog/admin.view.update.tool.d.ts +1 -1
- package/dist/mcp/admin/tools/catalog/admin.view.update.tool.js +2 -2
- package/dist/mcp/admin/tools/catalog/admin.view.update.tool.js.map +1 -1
- package/dist/mcp/admin/tools/catalog/index.d.ts +3 -0
- package/dist/mcp/admin/tools/catalog/index.js +3 -0
- package/dist/mcp/admin/tools/catalog/index.js.map +1 -1
- package/dist/mcp/es6.classes.d.ts +4 -0
- package/dist/mcp/logging/mcp.call.log.interceptor.js +1 -0
- package/dist/mcp/logging/mcp.call.log.interceptor.js.map +1 -1
- package/dist/mcp/logging/sanitize.mcp.call.log.d.ts +25 -0
- package/dist/mcp/logging/sanitize.mcp.call.log.js +60 -1
- package/dist/mcp/logging/sanitize.mcp.call.log.js.map +1 -1
- package/dist/mcp/mentities/mcp.call.log.mentity.d.ts +1 -0
- package/dist/mcp/mentities/mcp.call.log.mentity.js +4 -0
- package/dist/mcp/mentities/mcp.call.log.mentity.js.map +1 -1
- package/dist/mcp/tools/view.describe.tool.d.ts +1 -1
- package/dist/mcp/tools/view.describe.tool.js +1 -1
- package/dist/mcp/tools/view.describe.tool.js.map +1 -1
- package/dist/mcp/tools/view.query.tool.d.ts +5 -1
- package/dist/mcp/tools/view.query.tool.js +11 -3
- package/dist/mcp/tools/view.query.tool.js.map +1 -1
- package/dist/migrations/1787174933444-CreateBusinessMaterialViewTable.d.ts +5 -0
- package/dist/migrations/1787174933444-CreateBusinessMaterialViewTable.js +21 -0
- package/dist/migrations/1787174933444-CreateBusinessMaterialViewTable.js.map +1 -0
- package/package.json +1 -1
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
5
|
+
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;
|
|
6
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
|
+
};
|
|
8
|
+
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
9
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
10
|
+
};
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.BusinessMaterialViewSubscriber = void 0;
|
|
13
|
+
const nestjs_utility_services_1 = require("@servicelabsco/nestjs-utility-services");
|
|
14
|
+
const typeorm_1 = require("typeorm");
|
|
15
|
+
const business_material_view_entity_1 = require("../entities/business.material.view.entity");
|
|
16
|
+
let BusinessMaterialViewSubscriber = class BusinessMaterialViewSubscriber extends nestjs_utility_services_1.CommonSubscriber {
|
|
17
|
+
constructor(dataSource) {
|
|
18
|
+
super();
|
|
19
|
+
this.dataSource = dataSource;
|
|
20
|
+
dataSource.subscribers.push(this);
|
|
21
|
+
}
|
|
22
|
+
listenTo() {
|
|
23
|
+
return business_material_view_entity_1.BusinessMaterialViewEntity;
|
|
24
|
+
}
|
|
25
|
+
};
|
|
26
|
+
exports.BusinessMaterialViewSubscriber = BusinessMaterialViewSubscriber;
|
|
27
|
+
exports.BusinessMaterialViewSubscriber = BusinessMaterialViewSubscriber = __decorate([
|
|
28
|
+
(0, typeorm_1.EventSubscriber)(),
|
|
29
|
+
__metadata("design:paramtypes", [typeorm_1.DataSource])
|
|
30
|
+
], BusinessMaterialViewSubscriber);
|
|
31
|
+
//# sourceMappingURL=business.material.view.subscriber.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"business.material.view.subscriber.js","sourceRoot":"","sources":["../../../src/access/subscribers/business.material.view.subscriber.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,oFAA0E;AAC1E,qCAAsD;AACtD,6FAAuF;AAGhF,IAAM,8BAA8B,GAApC,MAAM,8BAA+B,SAAQ,0CAA4C;IAC5F,YAA6B,UAAsB;QAC/C,KAAK,EAAE,CAAC;QADiB,eAAU,GAAV,UAAU,CAAY;QAE/C,UAAU,CAAC,WAAW,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IACtC,CAAC;IAED,QAAQ;QACJ,OAAO,0DAA0B,CAAC;IACtC,CAAC;CACJ,CAAA;AATY,wEAA8B;yCAA9B,8BAA8B;IAD1C,IAAA,yBAAe,GAAE;qCAE2B,oBAAU;GAD1C,8BAA8B,CAS1C"}
|
|
@@ -8,6 +8,7 @@ export * from './business.downloadable.report.subscriber';
|
|
|
8
8
|
export * from './business.email.subscriber';
|
|
9
9
|
export * from './business.feature.subscriber';
|
|
10
10
|
export * from './business.group.role.subscriber';
|
|
11
|
+
export * from './business.material.view.subscriber';
|
|
11
12
|
export * from './business.menu.subscriber';
|
|
12
13
|
export * from './business.preference.subscriber';
|
|
13
14
|
export * from './business.property.subscriber';
|
|
@@ -24,6 +24,7 @@ __exportStar(require("./business.downloadable.report.subscriber"), exports);
|
|
|
24
24
|
__exportStar(require("./business.email.subscriber"), exports);
|
|
25
25
|
__exportStar(require("./business.feature.subscriber"), exports);
|
|
26
26
|
__exportStar(require("./business.group.role.subscriber"), exports);
|
|
27
|
+
__exportStar(require("./business.material.view.subscriber"), exports);
|
|
27
28
|
__exportStar(require("./business.menu.subscriber"), exports);
|
|
28
29
|
__exportStar(require("./business.preference.subscriber"), exports);
|
|
29
30
|
__exportStar(require("./business.property.subscriber"), exports);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/access/subscribers/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,2DAAyC;AAAA,+DAA6C;AAAA,mFAAiE;AAAA,iFAA+D;AAAA,wEAAsD;AAAA,iEAA+C;AAAA,4EAA0D;AAAA,8DAA4C;AAAA,gEAA8C;AAAA,mEAAiD;AAAA,6DAA2C;AAAA,mEAAiD;AAAA,iEAA+C;AAAA,+DAA6C;AAAA,+DAA6C;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2C;AAAA,8DAA4C;AAAA,0DAAwC;AAAA,qEAAmD;AAAA,6DAA2C;AAAA,8DAA4C;AAAA,yDAAuC;AAAA,oEAAkD;AAAA,iEAA+C;AAAA,+DAA6C;AAAA,yDAAuC;AAAA,oEAAkD;AAAA,6DAA2C;AAAA,2DAAyC;AAAA,4DAA0C;AAAA,4DAA0C;AAAA,gEAA8C;AAAA,iEAA+C;AAAA,2EAAwD"}
|
|
@@ -24,12 +24,14 @@ export declare class DevelopmentCatalogController {
|
|
|
24
24
|
created: string[];
|
|
25
25
|
adopted: string[];
|
|
26
26
|
orphaned: string[];
|
|
27
|
+
pruned: string[];
|
|
27
28
|
}>;
|
|
28
29
|
columnsSyncByView(tableName: string, body: ColumnsSyncInput): Promise<{
|
|
29
30
|
table_name: string;
|
|
30
31
|
created: string[];
|
|
31
32
|
adopted: string[];
|
|
32
33
|
orphaned: string[];
|
|
34
|
+
pruned: string[];
|
|
33
35
|
}>;
|
|
34
36
|
sample(tableName: string, limit?: string, offset?: string): Promise<{
|
|
35
37
|
table_name: string;
|
|
@@ -50,4 +52,27 @@ export declare class DevelopmentCatalogController {
|
|
|
50
52
|
}): Promise<import("../services/admin.report.view.service").CatalogGateResult | {
|
|
51
53
|
views: import("../services/admin.report.view.service").CatalogGateResult[];
|
|
52
54
|
}>;
|
|
55
|
+
listBusinesses(tableName: string): Promise<{
|
|
56
|
+
table_name: string;
|
|
57
|
+
view_id: number;
|
|
58
|
+
grants: {
|
|
59
|
+
business_id: number;
|
|
60
|
+
active: boolean;
|
|
61
|
+
}[];
|
|
62
|
+
}>;
|
|
63
|
+
setBusiness(tableName: string, body: {
|
|
64
|
+
business_id?: number;
|
|
65
|
+
active?: boolean;
|
|
66
|
+
}): Promise<{
|
|
67
|
+
table_name: string;
|
|
68
|
+
business_id: number;
|
|
69
|
+
active: boolean;
|
|
70
|
+
}>;
|
|
71
|
+
clearBusiness(tableName: string, body: {
|
|
72
|
+
business_id?: number;
|
|
73
|
+
}): Promise<{
|
|
74
|
+
table_name: string;
|
|
75
|
+
business_id: number;
|
|
76
|
+
cleared: boolean;
|
|
77
|
+
}>;
|
|
53
78
|
}
|
|
@@ -43,6 +43,15 @@ let DevelopmentCatalogController = class DevelopmentCatalogController {
|
|
|
43
43
|
validate(body) {
|
|
44
44
|
return this.service.validate(body?.table_name);
|
|
45
45
|
}
|
|
46
|
+
listBusinesses(tableName) {
|
|
47
|
+
return this.service.listBusinesses(tableName);
|
|
48
|
+
}
|
|
49
|
+
setBusiness(tableName, body) {
|
|
50
|
+
return this.service.setBusiness(tableName, Number(body?.business_id), body?.active === true);
|
|
51
|
+
}
|
|
52
|
+
clearBusiness(tableName, body) {
|
|
53
|
+
return this.service.clearBusiness(tableName, Number(body?.business_id));
|
|
54
|
+
}
|
|
46
55
|
};
|
|
47
56
|
exports.DevelopmentCatalogController = DevelopmentCatalogController;
|
|
48
57
|
__decorate([
|
|
@@ -105,6 +114,29 @@ __decorate([
|
|
|
105
114
|
__metadata("design:paramtypes", [Object]),
|
|
106
115
|
__metadata("design:returntype", void 0)
|
|
107
116
|
], DevelopmentCatalogController.prototype, "validate", null);
|
|
117
|
+
__decorate([
|
|
118
|
+
(0, common_1.Get)('views/:tableName/businesses'),
|
|
119
|
+
__param(0, (0, common_1.Param)('tableName')),
|
|
120
|
+
__metadata("design:type", Function),
|
|
121
|
+
__metadata("design:paramtypes", [String]),
|
|
122
|
+
__metadata("design:returntype", void 0)
|
|
123
|
+
], DevelopmentCatalogController.prototype, "listBusinesses", null);
|
|
124
|
+
__decorate([
|
|
125
|
+
(0, common_1.Post)('views/:tableName/businesses'),
|
|
126
|
+
__param(0, (0, common_1.Param)('tableName')),
|
|
127
|
+
__param(1, (0, common_1.Body)()),
|
|
128
|
+
__metadata("design:type", Function),
|
|
129
|
+
__metadata("design:paramtypes", [String, Object]),
|
|
130
|
+
__metadata("design:returntype", void 0)
|
|
131
|
+
], DevelopmentCatalogController.prototype, "setBusiness", null);
|
|
132
|
+
__decorate([
|
|
133
|
+
(0, common_1.Post)('views/:tableName/businesses/clear'),
|
|
134
|
+
__param(0, (0, common_1.Param)('tableName')),
|
|
135
|
+
__param(1, (0, common_1.Body)()),
|
|
136
|
+
__metadata("design:type", Function),
|
|
137
|
+
__metadata("design:paramtypes", [String, Object]),
|
|
138
|
+
__metadata("design:returntype", void 0)
|
|
139
|
+
], DevelopmentCatalogController.prototype, "clearBusiness", null);
|
|
108
140
|
exports.DevelopmentCatalogController = DevelopmentCatalogController = __decorate([
|
|
109
141
|
(0, common_1.Controller)('development/catalog'),
|
|
110
142
|
__metadata("design:paramtypes", [admin_report_view_service_1.AdminReportViewService])
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"development.catalog.controller.js","sourceRoot":"","sources":["../../../src/development/controllers/development.catalog.controller.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,2CAAkF;AAClF,qFAAsH;AAO/G,IAAM,4BAA4B,GAAlC,MAAM,4BAA4B;IACrC,YAA6B,OAA+B;QAA/B,YAAO,GAAP,OAAO,CAAwB;IAAG,CAAC;IAGhE,IAAI;QACA,OAAO,IAAI,CAAC,OAAO,CAAC,IAAI,EAAE,CAAC;IAC/B,CAAC;IAGD,QAAQ,CAAS,IAAsG;QACnH,OAAO,IAAI,CAAC,OAAO,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC;IACvC,CAAC;IAGD,MAAM,CAAqB,SAAiB,EAAU,IAAiF;QACnI,OAAO,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,SAAS,EAAE,IAAI,CAAC,CAAC;IAChD,CAAC;IAGD,WAAW,CAAS,IAAsB;QACtC,OAAO,IAAI,CAAC,OAAO,CAAC,WAAW,CAAC,IAAI,CAAC,CAAC;IAC1C,CAAC;IAGD,iBAAiB,CAAqB,SAAiB,EAAU,IAAsB;QACnF,OAAO,IAAI,CAAC,OAAO,CAAC,WAAW,CAAC,EAAE,GAAG,CAAC,IAAI,IAAI,EAAE,CAAC,EAAE,UAAU,EAAE,SAAS,EAAE,CAAC,CAAC;IAChF,CAAC;IAGD,MAAM,CAAqB,SAAiB,EAAkB,KAAc,EAAmB,MAAe;QAC1G,OAAO,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,SAAS,EAAE,KAAK,EAAE,MAAM,CAAC,CAAC;IACzD,CAAC;IAGD,QAAQ,CAAqB,SAAiB,EAAU,IAAyC;QAC7F,OAAO,IAAI,CAAC,OAAO,CAAC,eAAe,CAAC,SAAS,EAAE,IAAI,EAAE,OAAO,CAAC,CAAC;IAClE,CAAC;IAGD,QAAQ,CAAS,IAA6B;QAC1C,OAAO,IAAI,CAAC,OAAO,CAAC,QAAQ,CAAC,IAAI,EAAE,UAAU,CAAC,CAAC;IACnD,CAAC;CACJ,CAAA;
|
|
1
|
+
{"version":3,"file":"development.catalog.controller.js","sourceRoot":"","sources":["../../../src/development/controllers/development.catalog.controller.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,2CAAkF;AAClF,qFAAsH;AAO/G,IAAM,4BAA4B,GAAlC,MAAM,4BAA4B;IACrC,YAA6B,OAA+B;QAA/B,YAAO,GAAP,OAAO,CAAwB;IAAG,CAAC;IAGhE,IAAI;QACA,OAAO,IAAI,CAAC,OAAO,CAAC,IAAI,EAAE,CAAC;IAC/B,CAAC;IAGD,QAAQ,CAAS,IAAsG;QACnH,OAAO,IAAI,CAAC,OAAO,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC;IACvC,CAAC;IAGD,MAAM,CAAqB,SAAiB,EAAU,IAAiF;QACnI,OAAO,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,SAAS,EAAE,IAAI,CAAC,CAAC;IAChD,CAAC;IAGD,WAAW,CAAS,IAAsB;QACtC,OAAO,IAAI,CAAC,OAAO,CAAC,WAAW,CAAC,IAAI,CAAC,CAAC;IAC1C,CAAC;IAGD,iBAAiB,CAAqB,SAAiB,EAAU,IAAsB;QACnF,OAAO,IAAI,CAAC,OAAO,CAAC,WAAW,CAA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class CatalogSuggestedVisualizationDto {
|
|
|
10
10
|
x?: string;
|
|
11
11
|
y?: string;
|
|
12
12
|
}
|
|
13
|
+
export declare class CatalogRelationshipDto {
|
|
14
|
+
name: string;
|
|
15
|
+
view: string;
|
|
16
|
+
on: Record<string, string>;
|
|
17
|
+
when?: Record<string, unknown>;
|
|
18
|
+
cardinality: 'many_to_one';
|
|
19
|
+
description?: string;
|
|
20
|
+
}
|
|
21
|
+
export declare function shouldRefreshReportingView(attributes?: {
|
|
22
|
+
view_kind?: string;
|
|
23
|
+
} | null): boolean;
|
|
13
24
|
export declare class MaterialViewCatalogAttributesDto {
|
|
14
25
|
catalog_name?: string;
|
|
15
26
|
title?: string;
|
|
@@ -22,4 +33,9 @@ export declare class MaterialViewCatalogAttributesDto {
|
|
|
22
33
|
example_queries?: CatalogExampleQueryDto[];
|
|
23
34
|
suggested_visualizations?: CatalogSuggestedVisualizationDto[];
|
|
24
35
|
agent_visible?: boolean;
|
|
36
|
+
relationships?: CatalogRelationshipDto[];
|
|
37
|
+
user_scoped?: boolean;
|
|
38
|
+
user_column?: string;
|
|
39
|
+
view_kind?: 'view' | 'materialized';
|
|
40
|
+
default_enabled?: boolean;
|
|
25
41
|
}
|
|
@@ -9,7 +9,8 @@ var __metadata = (this && this.__metadata) || function (k, v) {
|
|
|
9
9
|
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
10
10
|
};
|
|
11
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
-
exports.MaterialViewCatalogAttributesDto = exports.CatalogSuggestedVisualizationDto = exports.CatalogExampleQueryDto = exports.TABLE_NAME_PATTERN = exports.CATALOG_NAME_PATTERN = void 0;
|
|
12
|
+
exports.MaterialViewCatalogAttributesDto = exports.CatalogRelationshipDto = exports.CatalogSuggestedVisualizationDto = exports.CatalogExampleQueryDto = exports.TABLE_NAME_PATTERN = exports.CATALOG_NAME_PATTERN = void 0;
|
|
13
|
+
exports.shouldRefreshReportingView = shouldRefreshReportingView;
|
|
13
14
|
const class_transformer_1 = require("class-transformer");
|
|
14
15
|
const class_validator_1 = require("class-validator");
|
|
15
16
|
exports.CATALOG_NAME_PATTERN = /^[a-z][a-z0-9_]{1,40}$/;
|
|
@@ -46,6 +47,40 @@ __decorate([
|
|
|
46
47
|
(0, class_validator_1.IsString)(),
|
|
47
48
|
__metadata("design:type", String)
|
|
48
49
|
], CatalogSuggestedVisualizationDto.prototype, "y", void 0);
|
|
50
|
+
class CatalogRelationshipDto {
|
|
51
|
+
}
|
|
52
|
+
exports.CatalogRelationshipDto = CatalogRelationshipDto;
|
|
53
|
+
__decorate([
|
|
54
|
+
(0, class_validator_1.IsString)(),
|
|
55
|
+
(0, class_validator_1.Matches)(exports.CATALOG_NAME_PATTERN),
|
|
56
|
+
__metadata("design:type", String)
|
|
57
|
+
], CatalogRelationshipDto.prototype, "name", void 0);
|
|
58
|
+
__decorate([
|
|
59
|
+
(0, class_validator_1.IsString)(),
|
|
60
|
+
(0, class_validator_1.Matches)(exports.CATALOG_NAME_PATTERN),
|
|
61
|
+
__metadata("design:type", String)
|
|
62
|
+
], CatalogRelationshipDto.prototype, "view", void 0);
|
|
63
|
+
__decorate([
|
|
64
|
+
(0, class_validator_1.IsObject)(),
|
|
65
|
+
__metadata("design:type", Object)
|
|
66
|
+
], CatalogRelationshipDto.prototype, "on", void 0);
|
|
67
|
+
__decorate([
|
|
68
|
+
(0, class_validator_1.IsOptional)(),
|
|
69
|
+
(0, class_validator_1.IsObject)(),
|
|
70
|
+
__metadata("design:type", Object)
|
|
71
|
+
], CatalogRelationshipDto.prototype, "when", void 0);
|
|
72
|
+
__decorate([
|
|
73
|
+
(0, class_validator_1.IsIn)(['many_to_one']),
|
|
74
|
+
__metadata("design:type", String)
|
|
75
|
+
], CatalogRelationshipDto.prototype, "cardinality", void 0);
|
|
76
|
+
__decorate([
|
|
77
|
+
(0, class_validator_1.IsOptional)(),
|
|
78
|
+
(0, class_validator_1.IsString)(),
|
|
79
|
+
__metadata("design:type", String)
|
|
80
|
+
], CatalogRelationshipDto.prototype, "description", void 0);
|
|
81
|
+
function shouldRefreshReportingView(attributes) {
|
|
82
|
+
return attributes?.view_kind !== 'view';
|
|
83
|
+
}
|
|
49
84
|
class MaterialViewCatalogAttributesDto {
|
|
50
85
|
}
|
|
51
86
|
exports.MaterialViewCatalogAttributesDto = MaterialViewCatalogAttributesDto;
|
|
@@ -111,4 +146,31 @@ __decorate([
|
|
|
111
146
|
(0, class_validator_1.IsBoolean)(),
|
|
112
147
|
__metadata("design:type", Boolean)
|
|
113
148
|
], MaterialViewCatalogAttributesDto.prototype, "agent_visible", void 0);
|
|
149
|
+
__decorate([
|
|
150
|
+
(0, class_validator_1.IsOptional)(),
|
|
151
|
+
(0, class_validator_1.IsArray)(),
|
|
152
|
+
(0, class_validator_1.ValidateNested)({ each: true }),
|
|
153
|
+
(0, class_transformer_1.Type)(() => CatalogRelationshipDto),
|
|
154
|
+
__metadata("design:type", Array)
|
|
155
|
+
], MaterialViewCatalogAttributesDto.prototype, "relationships", void 0);
|
|
156
|
+
__decorate([
|
|
157
|
+
(0, class_validator_1.IsOptional)(),
|
|
158
|
+
(0, class_validator_1.IsBoolean)(),
|
|
159
|
+
__metadata("design:type", Boolean)
|
|
160
|
+
], MaterialViewCatalogAttributesDto.prototype, "user_scoped", void 0);
|
|
161
|
+
__decorate([
|
|
162
|
+
(0, class_validator_1.IsOptional)(),
|
|
163
|
+
(0, class_validator_1.IsString)(),
|
|
164
|
+
__metadata("design:type", String)
|
|
165
|
+
], MaterialViewCatalogAttributesDto.prototype, "user_column", void 0);
|
|
166
|
+
__decorate([
|
|
167
|
+
(0, class_validator_1.IsOptional)(),
|
|
168
|
+
(0, class_validator_1.IsIn)(['view', 'materialized']),
|
|
169
|
+
__metadata("design:type", String)
|
|
170
|
+
], MaterialViewCatalogAttributesDto.prototype, "view_kind", void 0);
|
|
171
|
+
__decorate([
|
|
172
|
+
(0, class_validator_1.IsOptional)(),
|
|
173
|
+
(0, class_validator_1.IsBoolean)(),
|
|
174
|
+
__metadata("design:type", Boolean)
|
|
175
|
+
], MaterialViewCatalogAttributesDto.prototype, "default_enabled", void 0);
|
|
114
176
|
//# sourceMappingURL=material.view.catalog.attributes.dto.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"material.view.catalog.attributes.dto.js","sourceRoot":"","sources":["../../../src/development/dtos/material.view.catalog.attributes.dto.ts"],"names":[],"mappings":";;;;;;;;;;;;
|
|
1
|
+
{"version":3,"file":"material.view.catalog.attributes.dto.js","sourceRoot":"","sources":["../../../src/development/dtos/material.view.catalog.attributes.dto.ts"],"names":[],"mappings":";;;;;;;;;;;;AAsDA,gEAEC;AAxDD,yDAAyC;AACzC,qDAAqI;AAExH,QAAA,oBAAoB,GAAG,wBAAwB,CAAC;AAChD,QAAA,kBAAkB,GAAG,wBAAwB,CAAC;AAE3D,MAAa,sBAAsB;CAMlC;AAND,wDAMC;AAJG;IADC,IAAA,0BAAQ,GAAE;;iDACD;AAGV;IADC,IAAA,0BAAQ,GAAE;;mDACkB;AAGjC,MAAa,gCAAgC;CAc5C;AAdD,4EAcC;AAZG;IADC,IAAA,0BAAQ,GAAE;;8DACE;AAGb;IADC,IAAA,0BAAQ,GAAE;;8DACE;AAIb;IAFC,IAAA,4BAAU,GAAE;IACZ,IAAA,0BAAQ,GAAE;;2DACA;AAIX;IAFC,IAAA,4BAAU,GAAE;IACZ,IAAA,0BAAQ,GAAE;;2DACA;AAGf,MAAa,sBAAsB;CAsBlC;AAtBD,wDAsBC;AAnBG;IAFC,IAAA,0BAAQ,GAAE;IACV,IAAA,yBAAO,EAAC,4BAAoB,CAAC;;oDACjB;AAIb;IAFC,IAAA,0BAAQ,GAAE;IACV,IAAA,yBAAO,EAAC,4BAAoB,CAAC;;oDACjB;AAGb;IADC,IAAA,0BAAQ,GAAE;;kDACgB;AAI3B;IAFC,IAAA,4BAAU,GAAE;IACZ,IAAA,0BAAQ,GAA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AAE,IAAI,EAAE,IAAI,EAAE,CAAC;IAC9B,IAAA,wBAAI,EAAC,GAAG,EAAE,CAAC,gCAAgC,CAAC;;kFACiB;AAI9D;IAFC,IAAA,4BAAU,GAAE;IACZ,IAAA,2BAAS,GAAE;;uEACY;AAMxB;IAJC,IAAA,4BAAU,GAAE;IACZ,IAAA,yBAAO,GAAE;IACT,IAAA,gCAAc,EAAC,EAAE,IAAI,EAAE,IAAI,EAAE,CAAC;IAC9B,IAAA,wBAAI,EAAC,GAAG,EAAE,CAAC,sBAAsB,CAAC;;uEACM;AAIzC;IAFC,IAAA,4BAAU,GAAE;IACZ,IAAA,2BAAS,GAAE;;qEACU;AAItB;IAFC,IAAA,4BAAU,GAAE;IACZ,IAAA,0BAAQ,GAAE;;qEACU;AAIrB;IAFC,IAAA,4BAAU,GAAE;IACZ,IAAA,sBAAI,EAAC,CAAC,MAAM,EAAE,cAAc,CAAC,CAAC;;mEACK;AAKpC;IAFC,IAAA,4BAAU,GAAE;IACZ,IAAA,2BAAS,GAAE;;yEACc"}
|
|
@@ -19,6 +19,7 @@ export type ColumnsSyncInput = {
|
|
|
19
19
|
source_type?: string;
|
|
20
20
|
source_id?: number;
|
|
21
21
|
name?: string;
|
|
22
|
+
prune?: boolean;
|
|
22
23
|
};
|
|
23
24
|
export declare class AdminReportViewService {
|
|
24
25
|
private readonly sqlService;
|
|
@@ -52,6 +53,7 @@ export declare class AdminReportViewService {
|
|
|
52
53
|
created: string[];
|
|
53
54
|
adopted: string[];
|
|
54
55
|
orphaned: string[];
|
|
56
|
+
pruned: string[];
|
|
55
57
|
}>;
|
|
56
58
|
private resolveView;
|
|
57
59
|
private upsertLiveColumn;
|
|
@@ -64,12 +66,32 @@ export declare class AdminReportViewService {
|
|
|
64
66
|
validate(tableName?: string): Promise<CatalogGateResult | {
|
|
65
67
|
views: CatalogGateResult[];
|
|
66
68
|
}>;
|
|
69
|
+
listBusinesses(tableName: string): Promise<{
|
|
70
|
+
table_name: string;
|
|
71
|
+
view_id: number;
|
|
72
|
+
grants: {
|
|
73
|
+
business_id: number;
|
|
74
|
+
active: boolean;
|
|
75
|
+
}[];
|
|
76
|
+
}>;
|
|
77
|
+
setBusiness(tableName: string, businessId: number, active: boolean): Promise<{
|
|
78
|
+
table_name: string;
|
|
79
|
+
business_id: number;
|
|
80
|
+
active: boolean;
|
|
81
|
+
}>;
|
|
82
|
+
clearBusiness(tableName: string, businessId: number): Promise<{
|
|
83
|
+
table_name: string;
|
|
84
|
+
business_id: number;
|
|
85
|
+
cleared: boolean;
|
|
86
|
+
}>;
|
|
67
87
|
private evaluate;
|
|
68
88
|
private parseViewAttributes;
|
|
69
89
|
private parseColumnAttributes;
|
|
70
90
|
private tryParseViewAttributes;
|
|
71
91
|
private tryParseColumnAttributes;
|
|
72
92
|
private formatErrors;
|
|
93
|
+
private assertRelationships;
|
|
94
|
+
private catalogNameOf;
|
|
73
95
|
private applyViewDefaults;
|
|
74
96
|
private defaultCatalogName;
|
|
75
97
|
private tenancyColumn;
|
|
@@ -86,6 +108,7 @@ export declare class AdminReportViewService {
|
|
|
86
108
|
private normalizeLiveColumn;
|
|
87
109
|
private resolveTypeId;
|
|
88
110
|
private loadLiveColumnsSafe;
|
|
111
|
+
private loadUniqueIndexKeys;
|
|
89
112
|
private columnTypeMapping;
|
|
90
113
|
private displayName;
|
|
91
114
|
private hasEnumMap;
|
|
@@ -13,6 +13,8 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
13
13
|
exports.AdminReportViewService = void 0;
|
|
14
14
|
const common_1 = require("@nestjs/common");
|
|
15
15
|
const nestjs_utility_services_1 = require("@servicelabsco/nestjs-utility-services");
|
|
16
|
+
const business_material_view_entity_1 = require("../../access/entities/business.material.view.entity");
|
|
17
|
+
const report_view_enablement_1 = require("../../access/libraries/report.view.enablement");
|
|
16
18
|
const class_transformer_1 = require("class-transformer");
|
|
17
19
|
const class_validator_1 = require("class-validator");
|
|
18
20
|
const typeorm_1 = require("typeorm");
|
|
@@ -115,6 +117,7 @@ let AdminReportViewService = AdminReportViewService_1 = class AdminReportViewSer
|
|
|
115
117
|
created: created ? [args.name] : [],
|
|
116
118
|
adopted: created ? [] : [args.name],
|
|
117
119
|
orphaned: [],
|
|
120
|
+
pruned: [],
|
|
118
121
|
};
|
|
119
122
|
}
|
|
120
123
|
const existing = await nestjs_utility_services_1.ColumnEntity.find({
|
|
@@ -133,7 +136,18 @@ let AdminReportViewService = AdminReportViewService_1 = class AdminReportViewSer
|
|
|
133
136
|
byName.delete(liveCol.column_name);
|
|
134
137
|
}
|
|
135
138
|
const orphaned = [...byName.keys()].filter((name) => !liveNames.has(name));
|
|
136
|
-
|
|
139
|
+
const pruned = [];
|
|
140
|
+
if (args.prune) {
|
|
141
|
+
for (const name of orphaned) {
|
|
142
|
+
const column = byName.get(name);
|
|
143
|
+
if (!column)
|
|
144
|
+
continue;
|
|
145
|
+
column.deleted_at = new Date();
|
|
146
|
+
await column.save();
|
|
147
|
+
pruned.push(name);
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
return { table_name: row.table_name, created, adopted, orphaned, pruned };
|
|
137
151
|
}
|
|
138
152
|
async resolveView(args) {
|
|
139
153
|
if (args.source_id) {
|
|
@@ -163,9 +177,10 @@ let AdminReportViewService = AdminReportViewService_1 = class AdminReportViewSer
|
|
|
163
177
|
column.type_id = this.resolveTypeId(liveCol.col_type || liveCol.udt_name || liveCol.data_type, typeMap);
|
|
164
178
|
if (isNew) {
|
|
165
179
|
const tenancy = this.tenancyColumn(row);
|
|
180
|
+
const userCol = row.attributes?.user_column;
|
|
166
181
|
column.display_name = this.displayName(liveCol.column_name);
|
|
167
182
|
column.description = '';
|
|
168
|
-
column.visibility = liveCol.column_name !== tenancy;
|
|
183
|
+
column.visibility = liveCol.column_name !== tenancy && liveCol.column_name !== userCol;
|
|
169
184
|
column.query_params = '{}';
|
|
170
185
|
column.is_custom_column = false;
|
|
171
186
|
column.attributes = {};
|
|
@@ -192,8 +207,13 @@ let AdminReportViewService = AdminReportViewService_1 = class AdminReportViewSer
|
|
|
192
207
|
}
|
|
193
208
|
if (patch.display_name !== undefined)
|
|
194
209
|
column.display_name = patch.display_name;
|
|
195
|
-
if (patch.description !== undefined)
|
|
196
|
-
|
|
210
|
+
if (patch.description !== undefined) {
|
|
211
|
+
const description = String(patch.description);
|
|
212
|
+
if (description.length > 255) {
|
|
213
|
+
throw new common_1.BadRequestException(`description_too_long: 255 max, got ${description.length}`);
|
|
214
|
+
}
|
|
215
|
+
column.description = description;
|
|
216
|
+
}
|
|
197
217
|
if (patch.visibility !== undefined)
|
|
198
218
|
column.visibility = Boolean(patch.visibility);
|
|
199
219
|
if (patch.attributes !== undefined) {
|
|
@@ -218,6 +238,48 @@ let AdminReportViewService = AdminReportViewService_1 = class AdminReportViewSer
|
|
|
218
238
|
}
|
|
219
239
|
return { views };
|
|
220
240
|
}
|
|
241
|
+
async listBusinesses(tableName) {
|
|
242
|
+
const row = await this.requireRegisteredView(tableName);
|
|
243
|
+
const overrides = await business_material_view_entity_1.BusinessMaterialViewEntity.find({ where: { view_id: row.id } });
|
|
244
|
+
return {
|
|
245
|
+
table_name: row.table_name,
|
|
246
|
+
view_id: row.id,
|
|
247
|
+
grants: (Array.isArray(overrides) ? overrides : []).map((override) => ({
|
|
248
|
+
business_id: override.business_id,
|
|
249
|
+
active: override.active === true,
|
|
250
|
+
})),
|
|
251
|
+
};
|
|
252
|
+
}
|
|
253
|
+
async setBusiness(tableName, businessId, active) {
|
|
254
|
+
const row = await this.requireRegisteredView(tableName);
|
|
255
|
+
if (!Number.isInteger(businessId) || businessId <= 0) {
|
|
256
|
+
throw new nestjs_utility_services_1.OperationException('business_id must be a positive integer');
|
|
257
|
+
}
|
|
258
|
+
const override = await business_material_view_entity_1.BusinessMaterialViewEntity.firstOrNew({ business_id: businessId, view_id: row.id });
|
|
259
|
+
override.business_id = businessId;
|
|
260
|
+
override.view_id = row.id;
|
|
261
|
+
override.active = Boolean(active);
|
|
262
|
+
if (!override.attributes)
|
|
263
|
+
override.attributes = {};
|
|
264
|
+
await override.save();
|
|
265
|
+
(0, report_view_enablement_1.invalidateReportViewEnablement)(businessId);
|
|
266
|
+
return { table_name: row.table_name, business_id: businessId, active: override.active };
|
|
267
|
+
}
|
|
268
|
+
async clearBusiness(tableName, businessId) {
|
|
269
|
+
const row = await this.requireRegisteredView(tableName);
|
|
270
|
+
if (!Number.isInteger(businessId) || businessId <= 0) {
|
|
271
|
+
throw new nestjs_utility_services_1.OperationException('business_id must be a positive integer');
|
|
272
|
+
}
|
|
273
|
+
const override = await business_material_view_entity_1.BusinessMaterialViewEntity.findOne({ where: { business_id: businessId, view_id: row.id } });
|
|
274
|
+
if (override) {
|
|
275
|
+
await override.remove();
|
|
276
|
+
(0, report_view_enablement_1.invalidateReportViewEnablement)(businessId);
|
|
277
|
+
}
|
|
278
|
+
else {
|
|
279
|
+
(0, report_view_enablement_1.invalidateReportViewEnablement)(businessId);
|
|
280
|
+
}
|
|
281
|
+
return { table_name: row.table_name, business_id: businessId, cleared: Boolean(override) };
|
|
282
|
+
}
|
|
221
283
|
async evaluate(row, options) {
|
|
222
284
|
const findings = [];
|
|
223
285
|
const attributes = row.attributes || {};
|
|
@@ -250,6 +312,21 @@ let AdminReportViewService = AdminReportViewService_1 = class AdminReportViewSer
|
|
|
250
312
|
if (tenancyColumn?.visibility) {
|
|
251
313
|
findings.push(`tenancy column '${tenancy}' must not be agent-exposed (visibility=false)`);
|
|
252
314
|
}
|
|
315
|
+
if (parsed.user_scoped) {
|
|
316
|
+
const userCol = parsed.user_column;
|
|
317
|
+
if (!userCol) {
|
|
318
|
+
findings.push('user_scoped views require user_column');
|
|
319
|
+
}
|
|
320
|
+
else {
|
|
321
|
+
const userColumn = columns.find((column) => column.name === userCol);
|
|
322
|
+
if (!userColumn) {
|
|
323
|
+
findings.push(`user_column '${userCol}' is missing from ${row.table_name}`);
|
|
324
|
+
}
|
|
325
|
+
else if (userColumn.visibility) {
|
|
326
|
+
findings.push(`user_column '${userCol}' must not be agent-exposed (visibility=false)`);
|
|
327
|
+
}
|
|
328
|
+
}
|
|
329
|
+
}
|
|
253
330
|
const agentVisible = Boolean(parsed.agent_visible);
|
|
254
331
|
if (agentVisible && !(parsed.description || '').trim()) {
|
|
255
332
|
findings.push('agent_visible views require a non-empty description');
|
|
@@ -269,6 +346,7 @@ let AdminReportViewService = AdminReportViewService_1 = class AdminReportViewSer
|
|
|
269
346
|
findings.push(`column '${column.name}' is enum but has no enum_map`);
|
|
270
347
|
}
|
|
271
348
|
}
|
|
349
|
+
await this.assertRelationships(row, parsed, columns, findings);
|
|
272
350
|
const ok = findings.length === 0;
|
|
273
351
|
let dropped = false;
|
|
274
352
|
if (!ok && agentVisible && options.persistDrop && row.id) {
|
|
@@ -310,12 +388,83 @@ let AdminReportViewService = AdminReportViewService_1 = class AdminReportViewSer
|
|
|
310
388
|
formatErrors(errors) {
|
|
311
389
|
if (!errors.length)
|
|
312
390
|
return null;
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
const
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
391
|
+
const parts = [];
|
|
392
|
+
const walk = (errs, prefix = '') => {
|
|
393
|
+
for (const error of errs) {
|
|
394
|
+
const path = prefix ? `${prefix}.${error.property}` : error.property;
|
|
395
|
+
if (error.constraints)
|
|
396
|
+
parts.push(`${path}: ${Object.values(error.constraints).join(', ')}`);
|
|
397
|
+
if (Array.isArray(error.children) && error.children.length) {
|
|
398
|
+
walk(error.children, path);
|
|
399
|
+
}
|
|
400
|
+
}
|
|
401
|
+
};
|
|
402
|
+
walk(errors);
|
|
403
|
+
return parts.length ? parts.join('; ') : null;
|
|
404
|
+
}
|
|
405
|
+
async assertRelationships(row, parsed, sourceColumns, findings) {
|
|
406
|
+
const relationships = parsed.relationships || [];
|
|
407
|
+
if (!relationships.length)
|
|
408
|
+
return;
|
|
409
|
+
const sourceNames = new Set(sourceColumns.map((column) => column.name));
|
|
410
|
+
const seen = new Set();
|
|
411
|
+
const siblings = await nestjs_utility_services_1.MaterialViewEntity.find();
|
|
412
|
+
const byCatalog = new Map();
|
|
413
|
+
for (const sibling of [...siblings, row]) {
|
|
414
|
+
const name = this.catalogNameOf(sibling);
|
|
415
|
+
if (name)
|
|
416
|
+
byCatalog.set(name, sibling);
|
|
417
|
+
}
|
|
418
|
+
for (const relationship of relationships) {
|
|
419
|
+
if (seen.has(relationship.name)) {
|
|
420
|
+
findings.push(`relationship '${relationship.name}' is declared more than once`);
|
|
421
|
+
}
|
|
422
|
+
seen.add(relationship.name);
|
|
423
|
+
if (relationship.cardinality !== 'many_to_one') {
|
|
424
|
+
findings.push(`relationship '${relationship.name}' cardinality must be many_to_one`);
|
|
425
|
+
}
|
|
426
|
+
const onEntries = Object.entries(relationship.on || {});
|
|
427
|
+
if (!onEntries.length) {
|
|
428
|
+
findings.push(`relationship '${relationship.name}' needs a non-empty on map`);
|
|
429
|
+
}
|
|
430
|
+
for (const [sourceCol, targetCol] of onEntries) {
|
|
431
|
+
if (!sourceNames.has(sourceCol)) {
|
|
432
|
+
findings.push(`relationship '${relationship.name}' on column '${sourceCol}' is missing from ${row.table_name}`);
|
|
433
|
+
}
|
|
434
|
+
if (!/^[a-z][a-z0-9_]*$/.test(String(targetCol || ''))) {
|
|
435
|
+
findings.push(`relationship '${relationship.name}' target column '${targetCol}' is not a valid identifier`);
|
|
436
|
+
}
|
|
437
|
+
}
|
|
438
|
+
for (const key of Object.keys(relationship.when || {})) {
|
|
439
|
+
if (!sourceNames.has(key)) {
|
|
440
|
+
findings.push(`relationship '${relationship.name}' when column '${key}' is missing from ${row.table_name}`);
|
|
441
|
+
}
|
|
442
|
+
}
|
|
443
|
+
const target = byCatalog.get(relationship.view);
|
|
444
|
+
if (!target) {
|
|
445
|
+
findings.push(`relationship '${relationship.name}' target view '${relationship.view}' is not registered`);
|
|
446
|
+
continue;
|
|
447
|
+
}
|
|
448
|
+
const targetCols = target.id ? await nestjs_utility_services_1.ColumnEntity.find({ where: { source_type: SourceHash.materialView, source_id: target.id } }) : [];
|
|
449
|
+
const targetNames = new Set(targetCols.map((column) => column.name));
|
|
450
|
+
for (const [, targetCol] of onEntries) {
|
|
451
|
+
if (targetNames.size && !targetNames.has(String(targetCol))) {
|
|
452
|
+
findings.push(`relationship '${relationship.name}' target column '${targetCol}' is missing from ${relationship.view}`);
|
|
453
|
+
}
|
|
454
|
+
}
|
|
455
|
+
if (!onEntries.length)
|
|
456
|
+
continue;
|
|
457
|
+
const targetJoinCols = onEntries.map(([, targetCol]) => String(targetCol));
|
|
458
|
+
const uniqueKeys = await this.loadUniqueIndexKeys(target.table_name);
|
|
459
|
+
const covered = uniqueKeys.some((key) => key.length && key.every((column) => targetJoinCols.includes(column)));
|
|
460
|
+
if (!covered) {
|
|
461
|
+
findings.push(`relationship '${relationship.name}' target column '${targetJoinCols.join(', ')}' is not a unique grain key on ${relationship.view}`);
|
|
462
|
+
}
|
|
463
|
+
}
|
|
464
|
+
}
|
|
465
|
+
catalogNameOf(row) {
|
|
466
|
+
const attrs = (row.attributes || {});
|
|
467
|
+
return attrs.catalog_name || this.defaultCatalogName(row.table_name);
|
|
319
468
|
}
|
|
320
469
|
applyViewDefaults(tableName, attributes) {
|
|
321
470
|
if (!attributes.catalog_name)
|
|
@@ -326,6 +475,8 @@ let AdminReportViewService = AdminReportViewService_1 = class AdminReportViewSer
|
|
|
326
475
|
attributes.row_cap = 500;
|
|
327
476
|
if (attributes.agent_visible === undefined)
|
|
328
477
|
attributes.agent_visible = false;
|
|
478
|
+
if (attributes.view_kind === undefined)
|
|
479
|
+
attributes.view_kind = 'materialized';
|
|
329
480
|
}
|
|
330
481
|
defaultCatalogName(tableName) {
|
|
331
482
|
return tableName.replace(/^rpt_/, '') || tableName;
|
|
@@ -369,7 +520,7 @@ let AdminReportViewService = AdminReportViewService_1 = class AdminReportViewSer
|
|
|
369
520
|
}
|
|
370
521
|
async assertRelationExists(tableName) {
|
|
371
522
|
if (!(await this.relationExists(tableName))) {
|
|
372
|
-
throw new nestjs_utility_services_1.OperationException(`
|
|
523
|
+
throw new nestjs_utility_services_1.OperationException(`relation '${tableName}' does not exist`);
|
|
373
524
|
}
|
|
374
525
|
}
|
|
375
526
|
async relationExists(tableName) {
|
|
@@ -378,7 +529,7 @@ let AdminReportViewService = AdminReportViewService_1 = class AdminReportViewSer
|
|
|
378
529
|
const row = await this.boundReadFirst(`SELECT 1 AS ok
|
|
379
530
|
FROM pg_catalog.pg_class c
|
|
380
531
|
JOIN pg_catalog.pg_namespace n ON n.oid = c.relnamespace
|
|
381
|
-
WHERE n.nspname = 'public' AND c.relname = $1 AND c.relkind
|
|
532
|
+
WHERE n.nspname = 'public' AND c.relname = $1 AND c.relkind IN ('m', 'v')
|
|
382
533
|
LIMIT 1`, [tableName], 'ok');
|
|
383
534
|
return Boolean(row);
|
|
384
535
|
}
|
|
@@ -397,7 +548,7 @@ let AdminReportViewService = AdminReportViewService_1 = class AdminReportViewSer
|
|
|
397
548
|
FROM pg_catalog.pg_attribute a
|
|
398
549
|
JOIN pg_catalog.pg_class c ON c.oid = a.attrelid
|
|
399
550
|
JOIN pg_catalog.pg_namespace n ON n.oid = c.relnamespace
|
|
400
|
-
WHERE n.nspname = 'public' AND c.relname = $1 AND c.relkind
|
|
551
|
+
WHERE n.nspname = 'public' AND c.relname = $1 AND c.relkind IN ('m', 'v')
|
|
401
552
|
AND a.attnum > 0 AND NOT a.attisdropped
|
|
402
553
|
ORDER BY a.attnum`, [tableName]);
|
|
403
554
|
if (!Array.isArray(rows))
|
|
@@ -431,6 +582,37 @@ let AdminReportViewService = AdminReportViewService_1 = class AdminReportViewSer
|
|
|
431
582
|
return [];
|
|
432
583
|
}
|
|
433
584
|
}
|
|
585
|
+
async loadUniqueIndexKeys(tableName) {
|
|
586
|
+
if (!tableName || !material_view_catalog_attributes_dto_1.TABLE_NAME_PATTERN.test(tableName))
|
|
587
|
+
return [];
|
|
588
|
+
try {
|
|
589
|
+
const rows = await this.sqlService.boundRead(`SELECT i.indexrelid::text AS indexrelid, a.attname
|
|
590
|
+
FROM pg_catalog.pg_index i
|
|
591
|
+
JOIN pg_catalog.pg_class c ON c.oid = i.indrelid
|
|
592
|
+
JOIN pg_catalog.pg_namespace n ON n.oid = c.relnamespace
|
|
593
|
+
JOIN LATERAL unnest(i.indkey) WITH ORDINALITY AS k(attnum, ord) ON true
|
|
594
|
+
JOIN pg_catalog.pg_attribute a ON a.attrelid = i.indrelid AND a.attnum = k.attnum
|
|
595
|
+
WHERE n.nspname = 'public' AND c.relname = $1 AND i.indisunique AND i.indpred IS NULL
|
|
596
|
+
AND a.attnum > 0 AND NOT a.attisdropped
|
|
597
|
+
ORDER BY i.indexrelid, k.ord`, [tableName]);
|
|
598
|
+
if (!Array.isArray(rows) || !rows.length)
|
|
599
|
+
return [];
|
|
600
|
+
const byIndex = new Map();
|
|
601
|
+
for (const row of rows) {
|
|
602
|
+
const id = String(row.indexrelid ?? '0');
|
|
603
|
+
const name = String(row.attname ?? '');
|
|
604
|
+
if (!name)
|
|
605
|
+
continue;
|
|
606
|
+
const cols = byIndex.get(id) || [];
|
|
607
|
+
cols.push(name);
|
|
608
|
+
byIndex.set(id, cols);
|
|
609
|
+
}
|
|
610
|
+
return [...byIndex.values()];
|
|
611
|
+
}
|
|
612
|
+
catch {
|
|
613
|
+
return [];
|
|
614
|
+
}
|
|
615
|
+
}
|
|
434
616
|
async columnTypeMapping() {
|
|
435
617
|
const mapping = {};
|
|
436
618
|
const types = await nestjs_utility_services_1.ColumnDefinitionEntity.find({ where: { supported_identifiers: (0, typeorm_1.Not)((0, typeorm_1.IsNull)()) } });
|