@nestjs-dash/nestjs 0.1.1
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/client/nestjs-dash.js +2126 -0
- package/dist/client/nestjs-dash.js.map +7 -0
- package/dist/controllers/admin-api.controller.d.ts +41 -0
- package/dist/controllers/admin-api.controller.d.ts.map +1 -0
- package/dist/controllers/admin-api.controller.js +299 -0
- package/dist/controllers/admin-api.controller.js.map +1 -0
- package/dist/controllers/admin-auth.controller.d.ts +17 -0
- package/dist/controllers/admin-auth.controller.d.ts.map +1 -0
- package/dist/controllers/admin-auth.controller.js +111 -0
- package/dist/controllers/admin-auth.controller.js.map +1 -0
- package/dist/controllers/admin-upload.controller.d.ts +50 -0
- package/dist/controllers/admin-upload.controller.d.ts.map +1 -0
- package/dist/controllers/admin-upload.controller.js +210 -0
- package/dist/controllers/admin-upload.controller.js.map +1 -0
- package/dist/controllers/admin.controller.d.ts +69 -0
- package/dist/controllers/admin.controller.d.ts.map +1 -0
- package/dist/controllers/admin.controller.js +1062 -0
- package/dist/controllers/admin.controller.js.map +1 -0
- package/dist/decorators/admin-action.decorator.d.ts +4 -0
- package/dist/decorators/admin-action.decorator.d.ts.map +1 -0
- package/dist/decorators/admin-action.decorator.js +6 -0
- package/dist/decorators/admin-action.decorator.js.map +1 -0
- package/dist/decorators/admin-page.decorator.d.ts +3 -0
- package/dist/decorators/admin-page.decorator.d.ts.map +1 -0
- package/dist/decorators/admin-page.decorator.js +6 -0
- package/dist/decorators/admin-page.decorator.js.map +1 -0
- package/dist/decorators/admin-resource.decorator.d.ts +3 -0
- package/dist/decorators/admin-resource.decorator.d.ts.map +1 -0
- package/dist/decorators/admin-resource.decorator.js +6 -0
- package/dist/decorators/admin-resource.decorator.js.map +1 -0
- package/dist/features/audit/audit.interceptor.d.ts +17 -0
- package/dist/features/audit/audit.interceptor.d.ts.map +1 -0
- package/dist/features/audit/audit.interceptor.js +94 -0
- package/dist/features/audit/audit.interceptor.js.map +1 -0
- package/dist/features/audit/index.d.ts +2 -0
- package/dist/features/audit/index.d.ts.map +1 -0
- package/dist/features/audit/index.js +2 -0
- package/dist/features/audit/index.js.map +1 -0
- package/dist/features/auth/auth.types.d.ts +13 -0
- package/dist/features/auth/auth.types.d.ts.map +1 -0
- package/dist/features/auth/auth.types.js +2 -0
- package/dist/features/auth/auth.types.js.map +1 -0
- package/dist/features/auth/index.d.ts +12 -0
- package/dist/features/auth/index.d.ts.map +1 -0
- package/dist/features/auth/index.js +7 -0
- package/dist/features/auth/index.js.map +1 -0
- package/dist/features/auth/public.decorator.d.ts +3 -0
- package/dist/features/auth/public.decorator.d.ts.map +1 -0
- package/dist/features/auth/public.decorator.js +4 -0
- package/dist/features/auth/public.decorator.js.map +1 -0
- package/dist/features/auth/resolvers/credentials.resolver.d.ts +10 -0
- package/dist/features/auth/resolvers/credentials.resolver.d.ts.map +1 -0
- package/dist/features/auth/resolvers/credentials.resolver.js +35 -0
- package/dist/features/auth/resolvers/credentials.resolver.js.map +1 -0
- package/dist/features/auth/resolvers/custom.resolver.d.ts +7 -0
- package/dist/features/auth/resolvers/custom.resolver.d.ts.map +1 -0
- package/dist/features/auth/resolvers/custom.resolver.js +9 -0
- package/dist/features/auth/resolvers/custom.resolver.js.map +1 -0
- package/dist/features/auth/resolvers/jwt.resolver.d.ts +10 -0
- package/dist/features/auth/resolvers/jwt.resolver.d.ts.map +1 -0
- package/dist/features/auth/resolvers/jwt.resolver.js +24 -0
- package/dist/features/auth/resolvers/jwt.resolver.js.map +1 -0
- package/dist/features/auth/resolvers/passport.resolver.d.ts +9 -0
- package/dist/features/auth/resolvers/passport.resolver.d.ts.map +1 -0
- package/dist/features/auth/resolvers/passport.resolver.js +15 -0
- package/dist/features/auth/resolvers/passport.resolver.js.map +1 -0
- package/dist/features/auth/session.d.ts +9 -0
- package/dist/features/auth/session.d.ts.map +1 -0
- package/dist/features/auth/session.js +55 -0
- package/dist/features/auth/session.js.map +1 -0
- package/dist/features/media/enrich.d.ts +13 -0
- package/dist/features/media/enrich.d.ts.map +1 -0
- package/dist/features/media/enrich.js +56 -0
- package/dist/features/media/enrich.js.map +1 -0
- package/dist/features/media/index.d.ts +3 -0
- package/dist/features/media/index.d.ts.map +1 -0
- package/dist/features/media/index.js +3 -0
- package/dist/features/media/index.js.map +1 -0
- package/dist/features/media/media.helpers.d.ts +13 -0
- package/dist/features/media/media.helpers.d.ts.map +1 -0
- package/dist/features/media/media.helpers.js +63 -0
- package/dist/features/media/media.helpers.js.map +1 -0
- package/dist/guards/admin-auth.guard.d.ts +17 -0
- package/dist/guards/admin-auth.guard.d.ts.map +1 -0
- package/dist/guards/admin-auth.guard.js +82 -0
- package/dist/guards/admin-auth.guard.js.map +1 -0
- package/dist/guards/admin-policy.guard.d.ts +10 -0
- package/dist/guards/admin-policy.guard.d.ts.map +1 -0
- package/dist/guards/admin-policy.guard.js +60 -0
- package/dist/guards/admin-policy.guard.js.map +1 -0
- package/dist/helpers/action.helpers.d.ts +6 -0
- package/dist/helpers/action.helpers.d.ts.map +1 -0
- package/dist/helpers/action.helpers.js +14 -0
- package/dist/helpers/action.helpers.js.map +1 -0
- package/dist/helpers/data-source.helpers.d.ts +4 -0
- package/dist/helpers/data-source.helpers.d.ts.map +1 -0
- package/dist/helpers/data-source.helpers.js +14 -0
- package/dist/helpers/data-source.helpers.js.map +1 -0
- package/dist/helpers/icons.d.ts +8 -0
- package/dist/helpers/icons.d.ts.map +1 -0
- package/dist/helpers/icons.js +50 -0
- package/dist/helpers/icons.js.map +1 -0
- package/dist/helpers/nav-collapse.helper.d.ts +6 -0
- package/dist/helpers/nav-collapse.helper.d.ts.map +1 -0
- package/dist/helpers/nav-collapse.helper.js +25 -0
- package/dist/helpers/nav-collapse.helper.js.map +1 -0
- package/dist/helpers/relation.helpers.d.ts +17 -0
- package/dist/helpers/relation.helpers.d.ts.map +1 -0
- package/dist/helpers/relation.helpers.js +98 -0
- package/dist/helpers/relation.helpers.js.map +1 -0
- package/dist/helpers/shell-assets.helper.d.ts +6 -0
- package/dist/helpers/shell-assets.helper.d.ts.map +1 -0
- package/dist/helpers/shell-assets.helper.js +14 -0
- package/dist/helpers/shell-assets.helper.js.map +1 -0
- package/dist/index.d.ts +29 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +27 -0
- package/dist/index.js.map +1 -0
- package/dist/modules/admin-api-host.module.d.ts +3 -0
- package/dist/modules/admin-api-host.module.d.ts.map +1 -0
- package/dist/modules/admin-api-host.module.js +17 -0
- package/dist/modules/admin-api-host.module.js.map +1 -0
- package/dist/modules/admin-core.module.d.ts +3 -0
- package/dist/modules/admin-core.module.d.ts.map +1 -0
- package/dist/modules/admin-core.module.js +37 -0
- package/dist/modules/admin-core.module.js.map +1 -0
- package/dist/modules/admin-feature.module.d.ts +3 -0
- package/dist/modules/admin-feature.module.d.ts.map +1 -0
- package/dist/modules/admin-feature.module.js +14 -0
- package/dist/modules/admin-feature.module.js.map +1 -0
- package/dist/modules/admin-ui-host.module.d.ts +3 -0
- package/dist/modules/admin-ui-host.module.d.ts.map +1 -0
- package/dist/modules/admin-ui-host.module.js +19 -0
- package/dist/modules/admin-ui-host.module.js.map +1 -0
- package/dist/modules/admin.module.d.ts +18 -0
- package/dist/modules/admin.module.d.ts.map +1 -0
- package/dist/modules/admin.module.js +197 -0
- package/dist/modules/admin.module.js.map +1 -0
- package/dist/plugin-contracts.d.ts +88 -0
- package/dist/plugin-contracts.d.ts.map +1 -0
- package/dist/plugin-contracts.js +4 -0
- package/dist/plugin-contracts.js.map +1 -0
- package/dist/plugins/openapi/admin-openapi.d.ts +21 -0
- package/dist/plugins/openapi/admin-openapi.d.ts.map +1 -0
- package/dist/plugins/openapi/admin-openapi.js +237 -0
- package/dist/plugins/openapi/admin-openapi.js.map +1 -0
- package/dist/providers/admin-page.explorer.d.ts +8 -0
- package/dist/providers/admin-page.explorer.d.ts.map +1 -0
- package/dist/providers/admin-page.explorer.js +43 -0
- package/dist/providers/admin-page.explorer.js.map +1 -0
- package/dist/providers/admin-page.registry.d.ts +9 -0
- package/dist/providers/admin-page.registry.d.ts.map +1 -0
- package/dist/providers/admin-page.registry.js +39 -0
- package/dist/providers/admin-page.registry.js.map +1 -0
- package/dist/providers/admin-panel.bootstrap.d.ts +23 -0
- package/dist/providers/admin-panel.bootstrap.d.ts.map +1 -0
- package/dist/providers/admin-panel.bootstrap.js +122 -0
- package/dist/providers/admin-panel.bootstrap.js.map +1 -0
- package/dist/providers/admin-resource.explorer.d.ts +8 -0
- package/dist/providers/admin-resource.explorer.d.ts.map +1 -0
- package/dist/providers/admin-resource.explorer.js +43 -0
- package/dist/providers/admin-resource.explorer.js.map +1 -0
- package/dist/providers/admin-resource.registry.d.ts +9 -0
- package/dist/providers/admin-resource.registry.d.ts.map +1 -0
- package/dist/providers/admin-resource.registry.js +39 -0
- package/dist/providers/admin-resource.registry.js.map +1 -0
- package/dist/react/admin-app.d.ts +14 -0
- package/dist/react/admin-app.d.ts.map +1 -0
- package/dist/react/admin-app.js +421 -0
- package/dist/react/admin-app.js.map +1 -0
- package/dist/react/document.d.ts +13 -0
- package/dist/react/document.d.ts.map +1 -0
- package/dist/react/document.js +47 -0
- package/dist/react/document.js.map +1 -0
- package/dist/react/nav-client.d.ts +10 -0
- package/dist/react/nav-client.d.ts.map +1 -0
- package/dist/react/nav-client.js +153 -0
- package/dist/react/nav-client.js.map +1 -0
- package/dist/react/theme.d.ts +6 -0
- package/dist/react/theme.d.ts.map +1 -0
- package/dist/react/theme.js +51 -0
- package/dist/react/theme.js.map +1 -0
- package/dist/react/types.d.ts +107 -0
- package/dist/react/types.d.ts.map +1 -0
- package/dist/react/types.js +2 -0
- package/dist/react/types.js.map +1 -0
- package/dist/tokens.d.ts +106 -0
- package/dist/tokens.d.ts.map +1 -0
- package/dist/tokens.js +74 -0
- package/dist/tokens.js.map +1 -0
- package/dist/views/admin.views.d.ts +114 -0
- package/dist/views/admin.views.d.ts.map +1 -0
- package/dist/views/admin.views.js +212 -0
- package/dist/views/admin.views.js.map +1 -0
- package/package.json +98 -0
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
import type { StorageDisk, StorageVisibility } from './tokens.js';
|
|
2
|
+
export declare const NESTJS_DASH_STORAGE_SERVICE: unique symbol;
|
|
3
|
+
export declare const NESTJS_DASH_MEDIA_SERVICE: unique symbol;
|
|
4
|
+
export declare const NESTJS_DASH_AUDIT_SERVICE: unique symbol;
|
|
5
|
+
export interface AdminLocalDiskContract {
|
|
6
|
+
readonly visibility: StorageVisibility;
|
|
7
|
+
verifySignedRequest(key: string, expiresAt: number, signature: string): boolean;
|
|
8
|
+
exists(key: string): Promise<boolean>;
|
|
9
|
+
get(key: string): Promise<Buffer>;
|
|
10
|
+
}
|
|
11
|
+
export interface AdminStorageServiceContract {
|
|
12
|
+
put(body: Buffer, options: {
|
|
13
|
+
disk?: string;
|
|
14
|
+
directory?: string;
|
|
15
|
+
fileName: string;
|
|
16
|
+
contentType: string;
|
|
17
|
+
}): Promise<{
|
|
18
|
+
path: string;
|
|
19
|
+
url: string;
|
|
20
|
+
disk: string;
|
|
21
|
+
size: number;
|
|
22
|
+
contentType: string;
|
|
23
|
+
}>;
|
|
24
|
+
disk(name?: string): StorageDisk;
|
|
25
|
+
urlFor(diskName: string, key: string, visibility?: StorageVisibility): Promise<string>;
|
|
26
|
+
delete(diskName: string, key: string): Promise<void>;
|
|
27
|
+
getDefaultDiskName(): string;
|
|
28
|
+
getLocalDisk(name?: string): AdminLocalDiskContract | null;
|
|
29
|
+
}
|
|
30
|
+
export type MediaOwner = {
|
|
31
|
+
modelType: string;
|
|
32
|
+
modelId: string | number;
|
|
33
|
+
};
|
|
34
|
+
export type PendingMediaItem = {
|
|
35
|
+
id?: string | number;
|
|
36
|
+
path?: string;
|
|
37
|
+
disk?: string;
|
|
38
|
+
fileName?: string;
|
|
39
|
+
mimeType?: string;
|
|
40
|
+
size?: number;
|
|
41
|
+
url?: string;
|
|
42
|
+
};
|
|
43
|
+
export interface AdminMediaServiceContract {
|
|
44
|
+
isEnabled(): boolean;
|
|
45
|
+
getFirst(owner: MediaOwner, collection: string): Promise<{
|
|
46
|
+
disk: string;
|
|
47
|
+
path: string;
|
|
48
|
+
} | null>;
|
|
49
|
+
toClientItems(owner: MediaOwner, collection: string): Promise<Array<{
|
|
50
|
+
id: number;
|
|
51
|
+
path: string;
|
|
52
|
+
disk: string;
|
|
53
|
+
fileName: string;
|
|
54
|
+
url: string;
|
|
55
|
+
size: number;
|
|
56
|
+
}>>;
|
|
57
|
+
addFromUpload(owner: MediaOwner, collection: string, upload: {
|
|
58
|
+
path: string;
|
|
59
|
+
disk: string;
|
|
60
|
+
fileName: string;
|
|
61
|
+
mimeType?: string;
|
|
62
|
+
size?: number;
|
|
63
|
+
customProperties?: Record<string, unknown>;
|
|
64
|
+
}): Promise<{
|
|
65
|
+
id: string | number;
|
|
66
|
+
path: string;
|
|
67
|
+
disk: string;
|
|
68
|
+
fileName: string;
|
|
69
|
+
}>;
|
|
70
|
+
reorder(owner: MediaOwner, collection: string, ids: Array<string | number>): Promise<void>;
|
|
71
|
+
remove(mediaId: string | number): Promise<void>;
|
|
72
|
+
syncCollection(owner: MediaOwner, collection: string, items: PendingMediaItem[], defaults?: {
|
|
73
|
+
disk?: string;
|
|
74
|
+
}): Promise<unknown>;
|
|
75
|
+
}
|
|
76
|
+
export interface AdminAuditServiceContract {
|
|
77
|
+
isEnabled(): boolean;
|
|
78
|
+
record(entry: {
|
|
79
|
+
actorId?: string | null;
|
|
80
|
+
actorLabel?: string | null;
|
|
81
|
+
action: string;
|
|
82
|
+
resourceSlug: string;
|
|
83
|
+
recordId?: string | null;
|
|
84
|
+
before?: Record<string, unknown> | null;
|
|
85
|
+
after?: Record<string, unknown> | null;
|
|
86
|
+
}): Promise<void>;
|
|
87
|
+
}
|
|
88
|
+
//# sourceMappingURL=plugin-contracts.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"plugin-contracts.d.ts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GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;CACnB"}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
export const NESTJS_DASH_STORAGE_SERVICE = Symbol('NESTJS_DASH_STORAGE_SERVICE');
|
|
2
|
+
export const NESTJS_DASH_MEDIA_SERVICE = Symbol('NESTJS_DASH_MEDIA_SERVICE');
|
|
3
|
+
export const NESTJS_DASH_AUDIT_SERVICE = Symbol('NESTJS_DASH_AUDIT_SERVICE');
|
|
4
|
+
//# sourceMappingURL=plugin-contracts.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"plugin-contracts.js","sourceRoot":"","sources":["../src/plugin-contracts.ts"],"names":[],"mappings":"AAqBA,MAAM,CAAC,MAAM,2BAA2B,GAAG,MAAM,CAAC,6BAA6B,CAAC,CAAC;AACjF,MAAM,CAAC,MAAM,yBAAyB,GAAG,MAAM,CAAC,2BAA2B,CAAC,CAAC;AAC7E,MAAM,CAAC,MAAM,yBAAyB,GAAG,MAAM,CAAC,2BAA2B,CAAC,CAAC"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import type { Panel } from '@nestjs-dash/core';
|
|
2
|
+
import type { SetupAdminSwaggerOptions } from '../../tokens.js';
|
|
3
|
+
export type { SetupAdminSwaggerOptions } from '../../tokens.js';
|
|
4
|
+
export type AdminOpenApiDocument = {
|
|
5
|
+
openapi: string;
|
|
6
|
+
info: {
|
|
7
|
+
title: string;
|
|
8
|
+
description?: string;
|
|
9
|
+
version: string;
|
|
10
|
+
};
|
|
11
|
+
paths: Record<string, Record<string, unknown>>;
|
|
12
|
+
components: {
|
|
13
|
+
schemas: Record<string, unknown>;
|
|
14
|
+
};
|
|
15
|
+
};
|
|
16
|
+
export declare function buildAdminOpenApiDocument(panel: Panel, options?: {
|
|
17
|
+
title?: string;
|
|
18
|
+
version?: string;
|
|
19
|
+
}): AdminOpenApiDocument;
|
|
20
|
+
export declare function setupAdminSwagger(app: unknown, panel: Panel, options?: SetupAdminSwaggerOptions): Promise<void>;
|
|
21
|
+
//# sourceMappingURL=admin-openapi.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"admin-openapi.d.ts","sourceRoot":"","sources":["../../../src/plugins/openapi/admin-openapi.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAsB,MAAM,mBAAmB,CAAC;AACnE,OAAO,KAAK,EAAE,wBAAwB,EAAE,MAAM,iBAAiB,CAAC;AAEhE,YAAY,EAAE,wBAAwB,EAAE,MAAM,iBAAiB,CAAC;AAEhE,MAAM,MAAM,oBAAoB,GAAG;IACjC,OAAO,EAAE,MAAM,CAAC;IAChB,IAAI,EAAE;QACJ,KAAK,EAAE,MAAM,CAAC;QACd,WAAW,CAAC,EAAE,MAAM,CAAC;QACrB,OAAO,EAAE,MAAM,CAAC;KACjB,CAAC;IACF,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CAAC;IAC/C,UAAU,EAAE;QACV,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;KAClC,CAAC;CACH,CAAC;AAsNF,wBAAgB,yBAAyB,CACvC,KAAK,EAAE,KAAK,EACZ,OAAO,GAAE;IAAE,KAAK,CAAC,EAAE,MAAM,CAAC;IAAC,OAAO,CAAC,EAAE,MAAM,CAAA;CAAO,GACjD,oBAAoB,CAwBtB;AA2BD,wBAAsB,iBAAiB,CACrC,GAAG,EAAE,OAAO,EACZ,KAAK,EAAE,KAAK,EACZ,OAAO,GAAE,wBAA6B,GACrC,OAAO,CAAC,IAAI,CAAC,CAOf"}
|
|
@@ -0,0 +1,237 @@
|
|
|
1
|
+
function fieldSchema(fields) {
|
|
2
|
+
if (fields == null || fields === '*' || fields.length === 0) {
|
|
3
|
+
return {
|
|
4
|
+
type: 'object',
|
|
5
|
+
additionalProperties: true,
|
|
6
|
+
};
|
|
7
|
+
}
|
|
8
|
+
const properties = {};
|
|
9
|
+
for (const field of fields) {
|
|
10
|
+
properties[field] = { type: 'string' };
|
|
11
|
+
}
|
|
12
|
+
return {
|
|
13
|
+
type: 'object',
|
|
14
|
+
properties,
|
|
15
|
+
additionalProperties: true,
|
|
16
|
+
};
|
|
17
|
+
}
|
|
18
|
+
function listQueryParameters() {
|
|
19
|
+
return [
|
|
20
|
+
{
|
|
21
|
+
name: 'page',
|
|
22
|
+
in: 'query',
|
|
23
|
+
schema: { type: 'integer', minimum: 1 },
|
|
24
|
+
description: 'Page number',
|
|
25
|
+
},
|
|
26
|
+
{
|
|
27
|
+
name: 'limit',
|
|
28
|
+
in: 'query',
|
|
29
|
+
schema: { type: 'integer', minimum: 1 },
|
|
30
|
+
description: 'Page size',
|
|
31
|
+
},
|
|
32
|
+
{
|
|
33
|
+
name: 'search',
|
|
34
|
+
in: 'query',
|
|
35
|
+
schema: { type: 'string' },
|
|
36
|
+
description: 'Full-text search across searchable columns',
|
|
37
|
+
},
|
|
38
|
+
{
|
|
39
|
+
name: 'sortBy',
|
|
40
|
+
in: 'query',
|
|
41
|
+
schema: { type: 'string' },
|
|
42
|
+
description: 'Comma-separated column:ASC|DESC pairs',
|
|
43
|
+
example: 'email:ASC,id:DESC',
|
|
44
|
+
},
|
|
45
|
+
{
|
|
46
|
+
name: 'filter.*',
|
|
47
|
+
in: 'query',
|
|
48
|
+
style: 'form',
|
|
49
|
+
explode: true,
|
|
50
|
+
schema: { type: 'string' },
|
|
51
|
+
description: 'Filter expressions as filter.<column>=$op:value (e.g. filter.role=$eq:admin)',
|
|
52
|
+
},
|
|
53
|
+
];
|
|
54
|
+
}
|
|
55
|
+
function resourceSchemas(resource) {
|
|
56
|
+
const createFields = resource.api.fields.create;
|
|
57
|
+
const updateFields = resource.api.fields.update;
|
|
58
|
+
const responseFields = resource.api.fields.response;
|
|
59
|
+
return {
|
|
60
|
+
[`${resource.slug}Create`]: fieldSchema(createFields === '*' ? undefined : createFields),
|
|
61
|
+
[`${resource.slug}Update`]: fieldSchema(updateFields === '*' ? undefined : updateFields),
|
|
62
|
+
[`${resource.slug}Response`]: fieldSchema(responseFields === '*' ? undefined : responseFields),
|
|
63
|
+
};
|
|
64
|
+
}
|
|
65
|
+
function resourcePaths(apiPath, resource) {
|
|
66
|
+
if (!resource.api.enabled) {
|
|
67
|
+
return {};
|
|
68
|
+
}
|
|
69
|
+
const base = `${apiPath.replace(/\/$/, '')}/${resource.slug}`;
|
|
70
|
+
const methods = new Set(resource.api.methods);
|
|
71
|
+
const tag = resource.label;
|
|
72
|
+
const paths = {};
|
|
73
|
+
const collection = {};
|
|
74
|
+
if (methods.has('list')) {
|
|
75
|
+
collection.get = {
|
|
76
|
+
tags: [tag],
|
|
77
|
+
summary: `List ${resource.label}`,
|
|
78
|
+
operationId: `list_${resource.slug}`,
|
|
79
|
+
parameters: listQueryParameters(),
|
|
80
|
+
responses: {
|
|
81
|
+
'200': {
|
|
82
|
+
description: 'Paginated list',
|
|
83
|
+
content: {
|
|
84
|
+
'application/json': {
|
|
85
|
+
schema: {
|
|
86
|
+
type: 'object',
|
|
87
|
+
properties: {
|
|
88
|
+
data: {
|
|
89
|
+
type: 'array',
|
|
90
|
+
items: { $ref: `#/components/schemas/${resource.slug}Response` },
|
|
91
|
+
},
|
|
92
|
+
meta: { type: 'object', additionalProperties: true },
|
|
93
|
+
},
|
|
94
|
+
},
|
|
95
|
+
},
|
|
96
|
+
},
|
|
97
|
+
},
|
|
98
|
+
},
|
|
99
|
+
};
|
|
100
|
+
}
|
|
101
|
+
if (methods.has('create')) {
|
|
102
|
+
collection.post = {
|
|
103
|
+
tags: [tag],
|
|
104
|
+
summary: `Create ${resource.label}`,
|
|
105
|
+
operationId: `create_${resource.slug}`,
|
|
106
|
+
requestBody: {
|
|
107
|
+
required: true,
|
|
108
|
+
content: {
|
|
109
|
+
'application/json': {
|
|
110
|
+
schema: { $ref: `#/components/schemas/${resource.slug}Create` },
|
|
111
|
+
},
|
|
112
|
+
},
|
|
113
|
+
},
|
|
114
|
+
responses: {
|
|
115
|
+
'201': {
|
|
116
|
+
description: 'Created',
|
|
117
|
+
content: {
|
|
118
|
+
'application/json': {
|
|
119
|
+
schema: { $ref: `#/components/schemas/${resource.slug}Response` },
|
|
120
|
+
},
|
|
121
|
+
},
|
|
122
|
+
},
|
|
123
|
+
},
|
|
124
|
+
};
|
|
125
|
+
}
|
|
126
|
+
if (Object.keys(collection).length) {
|
|
127
|
+
paths[base] = collection;
|
|
128
|
+
}
|
|
129
|
+
const item = {};
|
|
130
|
+
const idParam = {
|
|
131
|
+
name: 'id',
|
|
132
|
+
in: 'path',
|
|
133
|
+
required: true,
|
|
134
|
+
schema: { type: 'string' },
|
|
135
|
+
};
|
|
136
|
+
if (methods.has('get')) {
|
|
137
|
+
item.get = {
|
|
138
|
+
tags: [tag],
|
|
139
|
+
summary: `Get ${resource.label}`,
|
|
140
|
+
operationId: `get_${resource.slug}`,
|
|
141
|
+
parameters: [idParam],
|
|
142
|
+
responses: {
|
|
143
|
+
'200': {
|
|
144
|
+
description: 'Record',
|
|
145
|
+
content: {
|
|
146
|
+
'application/json': {
|
|
147
|
+
schema: { $ref: `#/components/schemas/${resource.slug}Response` },
|
|
148
|
+
},
|
|
149
|
+
},
|
|
150
|
+
},
|
|
151
|
+
},
|
|
152
|
+
};
|
|
153
|
+
}
|
|
154
|
+
if (methods.has('update')) {
|
|
155
|
+
const putOp = {
|
|
156
|
+
tags: [tag],
|
|
157
|
+
summary: `Update ${resource.label}`,
|
|
158
|
+
operationId: `update_${resource.slug}`,
|
|
159
|
+
parameters: [idParam],
|
|
160
|
+
requestBody: {
|
|
161
|
+
required: true,
|
|
162
|
+
content: {
|
|
163
|
+
'application/json': {
|
|
164
|
+
schema: { $ref: `#/components/schemas/${resource.slug}Update` },
|
|
165
|
+
},
|
|
166
|
+
},
|
|
167
|
+
},
|
|
168
|
+
responses: {
|
|
169
|
+
'200': {
|
|
170
|
+
description: 'Updated',
|
|
171
|
+
content: {
|
|
172
|
+
'application/json': {
|
|
173
|
+
schema: { $ref: `#/components/schemas/${resource.slug}Response` },
|
|
174
|
+
},
|
|
175
|
+
},
|
|
176
|
+
},
|
|
177
|
+
},
|
|
178
|
+
};
|
|
179
|
+
item.put = putOp;
|
|
180
|
+
item.patch = { ...putOp, operationId: `patch_${resource.slug}` };
|
|
181
|
+
}
|
|
182
|
+
if (methods.has('delete')) {
|
|
183
|
+
item.delete = {
|
|
184
|
+
tags: [tag],
|
|
185
|
+
summary: `Delete ${resource.label}`,
|
|
186
|
+
operationId: `delete_${resource.slug}`,
|
|
187
|
+
parameters: [idParam],
|
|
188
|
+
responses: {
|
|
189
|
+
'200': { description: 'Deleted' },
|
|
190
|
+
},
|
|
191
|
+
};
|
|
192
|
+
}
|
|
193
|
+
if (Object.keys(item).length) {
|
|
194
|
+
paths[`${base}/{id}`] = item;
|
|
195
|
+
}
|
|
196
|
+
return paths;
|
|
197
|
+
}
|
|
198
|
+
export function buildAdminOpenApiDocument(panel, options = {}) {
|
|
199
|
+
const serialized = panel.serialize();
|
|
200
|
+
const apiPath = serialized.apiPath.startsWith('/')
|
|
201
|
+
? serialized.apiPath
|
|
202
|
+
: `/${serialized.apiPath}`;
|
|
203
|
+
const schemas = {};
|
|
204
|
+
const paths = {};
|
|
205
|
+
for (const resource of serialized.resources) {
|
|
206
|
+
Object.assign(schemas, resourceSchemas(resource));
|
|
207
|
+
Object.assign(paths, resourcePaths(apiPath, resource));
|
|
208
|
+
}
|
|
209
|
+
return {
|
|
210
|
+
openapi: '3.0.3',
|
|
211
|
+
info: {
|
|
212
|
+
title: options.title ?? `${serialized.brandName} Admin API`,
|
|
213
|
+
description: 'Dynamically generated OpenAPI document for NestJS Dash resource endpoints.',
|
|
214
|
+
version: options.version ?? '1.0.0',
|
|
215
|
+
},
|
|
216
|
+
paths,
|
|
217
|
+
components: { schemas },
|
|
218
|
+
};
|
|
219
|
+
}
|
|
220
|
+
async function loadNestSwagger() {
|
|
221
|
+
const moduleName = '@nestjs/swagger';
|
|
222
|
+
try {
|
|
223
|
+
return (await import(moduleName));
|
|
224
|
+
}
|
|
225
|
+
catch {
|
|
226
|
+
throw new Error('NestJS Dash Swagger requires `@nestjs/swagger`. Install it with: pnpm add @nestjs/swagger');
|
|
227
|
+
}
|
|
228
|
+
}
|
|
229
|
+
export async function setupAdminSwagger(app, panel, options = {}) {
|
|
230
|
+
const swagger = await loadNestSwagger();
|
|
231
|
+
const document = buildAdminOpenApiDocument(panel, {
|
|
232
|
+
title: options.title,
|
|
233
|
+
version: options.version,
|
|
234
|
+
});
|
|
235
|
+
swagger.SwaggerModule.setup(options.path ?? 'api/docs', app, document);
|
|
236
|
+
}
|
|
237
|
+
//# sourceMappingURL=admin-openapi.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"admin-openapi.js","sourceRoot":"","sources":["../../../src/plugins/openapi/admin-openapi.ts"],"names":[],"mappings":"AAkBA,SAAS,WAAW,CAAC,MAAkC;IACrD,IAAI,MAAM,IAAI,IAAI,IAAI,MAAM,KAAK,GAAG,IAAI,MAAM,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QAC5D,OAAO;YACL,IAAI,EAAE,QAAQ;YACd,oBAAoB,EAAE,IAAI;SAC3B,CAAC;IACJ,CAAC;IACD,MAAM,UAAU,GAA4B,EAAE,CAAC;IAC/C,KAAK,MAAM,KAAK,IAAI,MAAM,EAAE,CAAC;QAC3B,UAAU,CAAC,KAAK,CAAC,GAAG,EAAE,IAAI,EAAE,QAAQ,EAAE,CAAC;IACzC,CAAC;IACD,OAAO;QACL,IAAI,EAAE,QAAQ;QACd,UAAU;QACV,oBAAoB,EAAE,IAAI;KAC3B,CAAC;AACJ,CAAC;AAED,SAAS,mBAAmB;IAC1B,OAAO;QACL;YACE,IAAI,EAAE,MAAM;YACZ,EAAE,EAAE,OAAO;YACX,MAAM,EAAE,EAAE,IAAI,EAAE,SAAS,EAAE,OAAO,EAAE,CAAC,EAAE;YACv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AAE;KACxB,CAAC;AACJ,CAAC;AAYD,KAAK,UAAU,eAAe;IAC5B,MAAM,UAAU,GAAG,iBAAiB,CAAC;IACrC,IAAI,CAAC;QACH,OAAO,CAAC,MAAM,MAAM,CAAC,UAAU,CAAC,CAAqB,CAAC;IACxD,CAAC;IAAC,MAAM,CAAC;QACP,MAAM,IAAI,KAAK,CACb,2FAA2F,CAC5F,CAAC;IACJ,CAAC;AACH,CAAC;AAMD,MAAM,CAAC,KAAK,UAAU,iBAAiB,CACrC,GAAY,EACZ,KAAY,EACZ,UAAoC,EAAE;IAEtC,MAAM,OAAO,GAAG,MAAM,eAAe,EAAE,CAAC;IACxC,MAAM,QAAQ,GAAG,yBAAyB,CAAC,KAAK,EAAE;QAChD,KAAK,EAAE,OAAO,CAAC,KAAK;QACpB,OAAO,EAAE,OAAO,CAAC,OAAO;KACzB,CAAC,CAAC;IACH,OAAO,CAAC,aAAa,CAAC,KAAK,CAAC,OAAO,CAAC,IAAI,IAAI,UAAU,EAAE,GAAG,EAAE,QAAiB,CAAC,CAAC;AAClF,CAAC"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { DiscoveryService, Reflector } from '@nestjs/core';
|
|
2
|
+
export declare class AdminPageExplorer {
|
|
3
|
+
private readonly discovery;
|
|
4
|
+
private readonly reflector;
|
|
5
|
+
constructor(discovery: DiscoveryService, reflector: Reflector);
|
|
6
|
+
discover(): void;
|
|
7
|
+
}
|
|
8
|
+
//# sourceMappingURL=admin-page.explorer.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"admin-page.explorer.d.ts","sourceRoot":"","sources":["../../src/providers/admin-page.explorer.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,gBAAgB,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AAU3D,qBACa,iBAAiB;IAE1B,OAAO,CAAC,QAAQ,CAAC,SAAS;IAC1B,OAAO,CAAC,QAAQ,CAAC,SAAS;gBADT,SAAS,EAAE,gBAAgB,EAC3B,SAAS,EAAE,SAAS;IAGvC,QAAQ,IAAI,IAAI;CAiBjB"}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
2
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
3
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
4
|
+
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;
|
|
5
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
6
|
+
};
|
|
7
|
+
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
8
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
9
|
+
};
|
|
10
|
+
import { Injectable } from '@nestjs/common';
|
|
11
|
+
import { DiscoveryService, Reflector } from '@nestjs/core';
|
|
12
|
+
import { ADMIN_PAGE_METADATA } from '../decorators/admin-page.decorator.js';
|
|
13
|
+
import { registerAdminPages } from './admin-page.registry.js';
|
|
14
|
+
let AdminPageExplorer = class AdminPageExplorer {
|
|
15
|
+
constructor(discovery, reflector) {
|
|
16
|
+
this.discovery = discovery;
|
|
17
|
+
this.reflector = reflector;
|
|
18
|
+
}
|
|
19
|
+
discover() {
|
|
20
|
+
const discovered = [];
|
|
21
|
+
for (const wrapper of this.discovery.getProviders()) {
|
|
22
|
+
const metatype = wrapper.metatype;
|
|
23
|
+
if (!metatype || typeof metatype !== 'function') {
|
|
24
|
+
continue;
|
|
25
|
+
}
|
|
26
|
+
const flagged = this.reflector.get(ADMIN_PAGE_METADATA, metatype);
|
|
27
|
+
if (!flagged) {
|
|
28
|
+
continue;
|
|
29
|
+
}
|
|
30
|
+
discovered.push(metatype);
|
|
31
|
+
}
|
|
32
|
+
if (discovered.length) {
|
|
33
|
+
registerAdminPages(discovered);
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
};
|
|
37
|
+
AdminPageExplorer = __decorate([
|
|
38
|
+
Injectable(),
|
|
39
|
+
__metadata("design:paramtypes", [DiscoveryService,
|
|
40
|
+
Reflector])
|
|
41
|
+
], AdminPageExplorer);
|
|
42
|
+
export { AdminPageExplorer };
|
|
43
|
+
//# sourceMappingURL=admin-page.explorer.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"admin-page.explorer.js","sourceRoot":"","sources":["../../src/providers/admin-page.explorer.ts"],"names":[],"mappings":";;;;;;;;;AACA,OAAO,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC;AAC5C,OAAO,EAAE,gBAAgB,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AAC3D,OAAO,EAAE,mBAAmB,EAAE,MAAM,uCAAuC,CAAC;AAC5E,OAAO,EAAE,kBAAkB,EAAE,MAAM,0BAA0B,CAAC;AASvD,IAAM,iBAAiB,GAAvB,MAAM,iBAAiB;IAC5B,YACmB,SAA2B,EAC3B,SAAoB;QADpB,cAAS,GAAT,SAAS,CAAkB;QAC3B,cAAS,GAAT,SAAS,CAAW;IACpC,CAAC;IAEJ,QAAQ;QACN,MAAM,UAAU,GAAgB,EAAE,CAAC;QACnC,KAAK,MAAM,OAAO,IAAI,IAAI,CAAC,SAAS,CAAC,YAAY,EAAE,EAAE,CAAC;YACpD,MAAM,QAAQ,GAAG,OAAO,CAAC,QAAQ,CAAC;YAClC,IAAI,CAAC,QAAQ,IAAI,OAAO,QAAQ,KAAK,UAAU,EAAE,CAAC;gBAChD,SAAS;YACX,CAAC;YACD,MAAM,OAAO,GAAG,IAAI,CAAC,SAAS,CAAC,GAAG,CAAsB,mBAAmB,EAAE,QAAQ,CAAC,CAAC;YACvF,IAAI,CAAC,OAAO,EAAE,CAAC;gBACb,SAAS;YACX,CAAC;YACD,UAAU,CAAC,IAAI,CAAC,QAAqB,CAAC,CAAC;QACzC,CAAC;QACD,IAAI,UAAU,CAAC,MAAM,EAAE,CAAC;YACtB,kBAAkB,CAAC,UAAU,CAAC,CAAC;QACjC,CAAC;IACH,CAAC;CACF,CAAA;AAvBY,iBAAiB;IAD7B,UAAU,EAAE;qCAGmB,gBAAgB;QAChB,SAAS;GAH5B,iBAAiB,CAuB7B"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { type PageClass } from '@nestjs-dash/core';
|
|
2
|
+
export declare class AdminPageRegistry {
|
|
3
|
+
register(pages: PageClass[]): void;
|
|
4
|
+
getPages(): PageClass[];
|
|
5
|
+
}
|
|
6
|
+
export declare function registerAdminPages(pages: PageClass[]): void;
|
|
7
|
+
export declare function getRegisteredAdminPages(): PageClass[];
|
|
8
|
+
export declare function clearRegisteredAdminPages(): void;
|
|
9
|
+
//# sourceMappingURL=admin-page.registry.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"admin-page.registry.d.ts","sourceRoot":"","sources":["../../src/providers/admin-page.registry.ts"],"names":[],"mappings":"AAAA,OAAO,EAAmB,KAAK,SAAS,EAAE,MAAM,mBAAmB,CAAC;AAUpE,qBACa,iBAAiB;IAC5B,QAAQ,CAAC,KAAK,EAAE,SAAS,EAAE,GAAG,IAAI;IAIlC,QAAQ,IAAI,SAAS,EAAE;CAGxB;AAED,wBAAgB,kBAAkB,CAAC,KAAK,EAAE,SAAS,EAAE,GAAG,IAAI,CAU3D;AAED,wBAAgB,uBAAuB,IAAI,SAAS,EAAE,CAErD;AAGD,wBAAgB,yBAAyB,IAAI,IAAI,CAEhD"}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
2
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
3
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
4
|
+
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;
|
|
5
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
6
|
+
};
|
|
7
|
+
import { resolvePageSlug } from '@nestjs-dash/core';
|
|
8
|
+
import { Injectable } from '@nestjs/common';
|
|
9
|
+
const sharedPages = [];
|
|
10
|
+
let AdminPageRegistry = class AdminPageRegistry {
|
|
11
|
+
register(pages) {
|
|
12
|
+
registerAdminPages(pages);
|
|
13
|
+
}
|
|
14
|
+
getPages() {
|
|
15
|
+
return getRegisteredAdminPages();
|
|
16
|
+
}
|
|
17
|
+
};
|
|
18
|
+
AdminPageRegistry = __decorate([
|
|
19
|
+
Injectable()
|
|
20
|
+
], AdminPageRegistry);
|
|
21
|
+
export { AdminPageRegistry };
|
|
22
|
+
export function registerAdminPages(pages) {
|
|
23
|
+
const seen = new Set(sharedPages.map((page) => resolvePageSlug(page)));
|
|
24
|
+
for (const page of pages) {
|
|
25
|
+
const slug = resolvePageSlug(page);
|
|
26
|
+
if (seen.has(slug)) {
|
|
27
|
+
continue;
|
|
28
|
+
}
|
|
29
|
+
seen.add(slug);
|
|
30
|
+
sharedPages.push(page);
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
export function getRegisteredAdminPages() {
|
|
34
|
+
return [...sharedPages];
|
|
35
|
+
}
|
|
36
|
+
export function clearRegisteredAdminPages() {
|
|
37
|
+
sharedPages.length = 0;
|
|
38
|
+
}
|
|
39
|
+
//# sourceMappingURL=admin-page.registry.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"admin-page.registry.js","sourceRoot":"","sources":["../../src/providers/admin-page.registry.ts"],"names":[],"mappings":";;;;;;AAAA,OAAO,EAAE,eAAe,EAAkB,MAAM,mBAAmB,CAAC;AACpE,OAAO,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC;AAO5C,MAAM,WAAW,GAAgB,EAAE,CAAC;AAG7B,IAAM,iBAAiB,GAAvB,MAAM,iBAAiB;IAC5B,QAAQ,CAAC,KAAkB;QACzB,kBAAkB,CAAC,KAAK,CAAC,CAAC;IAC5B,CAAC;IAED,QAAQ;QACN,OAAO,uBAAuB,EAAE,CAAC;IACnC,CAAC;CACF,CAAA;AARY,iBAAiB;IAD7B,UAAU,EAAE;GACA,iBAAiB,CAQ7B;;AAED,MAAM,UAAU,kBAAkB,CAAC,KAAkB;IACnD,MAAM,IAAI,GAAG,IAAI,GAAG,CAAC,WAAW,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,eAAe,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;IACvE,KAAK,MAAM,IAAI,IAAI,KAAK,EAAE,CAAC;QACzB,MAAM,IAAI,GAAG,eAAe,CAAC,IAAI,CAAC,CAAC;QACnC,IAAI,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE,CAAC;YACnB,SAAS;QACX,CAAC;QACD,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;QACf,WAAW,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IACzB,CAAC;AACH,CAAC;AAED,MAAM,UAAU,uBAAuB;IACrC,OAAO,CAAC,GAAG,WAAW,CAAC,CAAC;AAC1B,CAAC;AAGD,MAAM,UAAU,yBAAyB;IACvC,WAAW,CAAC,MAAM,GAAG,CAAC,CAAC;AACzB,CAAC"}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import type { Panel } from '@nestjs-dash/core';
|
|
2
|
+
import { type OnModuleInit } from '@nestjs/common';
|
|
3
|
+
import { ModuleRef, ModulesContainer } from '@nestjs/core';
|
|
4
|
+
import { type AdminModuleOptions } from '../tokens.js';
|
|
5
|
+
import { AdminPageExplorer } from './admin-page.explorer.js';
|
|
6
|
+
import { AdminPageRegistry } from './admin-page.registry.js';
|
|
7
|
+
import { AdminResourceExplorer } from './admin-resource.explorer.js';
|
|
8
|
+
import { AdminResourceRegistry } from './admin-resource.registry.js';
|
|
9
|
+
export declare class AdminPanelBootstrap implements OnModuleInit {
|
|
10
|
+
private readonly panel;
|
|
11
|
+
private readonly registry;
|
|
12
|
+
private readonly explorer;
|
|
13
|
+
private readonly pageRegistry;
|
|
14
|
+
private readonly pageExplorer;
|
|
15
|
+
private readonly moduleRef;
|
|
16
|
+
private readonly modulesContainer;
|
|
17
|
+
private readonly options;
|
|
18
|
+
constructor(panel: Panel, registry: AdminResourceRegistry, explorer: AdminResourceExplorer, pageRegistry: AdminPageRegistry, pageExplorer: AdminPageExplorer, moduleRef: ModuleRef, modulesContainer: ModulesContainer, options?: AdminModuleOptions | null);
|
|
19
|
+
onModuleInit(): Promise<void>;
|
|
20
|
+
private bindActivityResource;
|
|
21
|
+
private resolveDataSource;
|
|
22
|
+
}
|
|
23
|
+
//# sourceMappingURL=admin-panel.bootstrap.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"admin-panel.bootstrap.d.ts","sourceRoot":"","sources":["../../src/providers/admin-panel.bootstrap.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,KAAK,EAAiB,MAAM,mBAAmB,CAAC;AAC9D,OAAO,EAAgC,KAAK,YAAY,EAAE,MAAM,gBAAgB,CAAC;AACjF,OAAO,EAAE,SAAS,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAC;AAG3D,OAAO,EAA0C,KAAK,kBAAkB,EAAE,MAAM,cAAc,CAAC;AAC/F,OAAO,EAAE,iBAAiB,EAAE,MAAM,0BAA0B,CAAC;AAC7D,OAAO,EAAE,iBAAiB,EAAE,MAAM,0BAA0B,CAAC;AAC7D,OAAO,EAAE,qBAAqB,EAAE,MAAM,8BAA8B,CAAC;AACrE,OAAO,EAAE,qBAAqB,EAAE,MAAM,8BAA8B,CAAC;AA6CrE,qBACa,mBAAoB,YAAW,YAAY;IAEzB,OAAO,CAAC,QAAQ,CAAC,KAAK;IACjD,OAAO,CAAC,QAAQ,CAAC,QAAQ;IACzB,OAAO,CAAC,QAAQ,CAAC,QAAQ;IACzB,OAAO,CAAC,QAAQ,CAAC,YAAY;IAC7B,OAAO,CAAC,QAAQ,CAAC,YAAY;IAC7B,OAAO,CAAC,QAAQ,CAAC,SAAS;IAC1B,OAAO,CAAC,QAAQ,CAAC,gBAAgB;IAGjC,OAAO,CAAC,QAAQ,CAAC,OAAO;gBAToB,KAAK,EAAE,KAAK,EACvC,QAAQ,EAAE,qBAAqB,EAC/B,QAAQ,EAAE,qBAAqB,EAC/B,YAAY,EAAE,iBAAiB,EAC/B,YAAY,EAAE,iBAAiB,EAC/B,SAAS,EAAE,SAAS,EACpB,gBAAgB,EAAE,gBAAgB,EAGlC,OAAO,GAAE,kBAAkB,GAAG,IAAW;IAGtD,YAAY,IAAI,OAAO,CAAC,IAAI,CAAC;YAyCrB,oBAAoB;YAqBpB,iBAAiB;CA2BhC"}
|
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
2
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
3
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
4
|
+
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;
|
|
5
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
6
|
+
};
|
|
7
|
+
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
8
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
9
|
+
};
|
|
10
|
+
var __param = (this && this.__param) || function (paramIndex, decorator) {
|
|
11
|
+
return function (target, key) { decorator(target, key, paramIndex); }
|
|
12
|
+
};
|
|
13
|
+
import { Inject, Injectable, Optional } from '@nestjs/common';
|
|
14
|
+
import { ModuleRef, ModulesContainer } from '@nestjs/core';
|
|
15
|
+
import { isDataSourceLike } from '../helpers/data-source.helpers.js';
|
|
16
|
+
import { NESTJS_DASH_OPTIONS, NESTJS_DASH_PANEL } from '../tokens.js';
|
|
17
|
+
import { AdminPageExplorer } from './admin-page.explorer.js';
|
|
18
|
+
import { AdminPageRegistry } from './admin-page.registry.js';
|
|
19
|
+
import { AdminResourceExplorer } from './admin-resource.explorer.js';
|
|
20
|
+
import { AdminResourceRegistry } from './admin-resource.registry.js';
|
|
21
|
+
const TYPEORM_ADAPTER_SPECIFIER = '@nestjs-dash/typeorm';
|
|
22
|
+
function importTypeOrmAdapter() {
|
|
23
|
+
return import(TYPEORM_ADAPTER_SPECIFIER);
|
|
24
|
+
}
|
|
25
|
+
const AUDIT_LOG_PLUGIN_SPECIFIER = '@nestjs-dash/audit-log';
|
|
26
|
+
function importAuditActivityResource() {
|
|
27
|
+
return import(AUDIT_LOG_PLUGIN_SPECIFIER);
|
|
28
|
+
}
|
|
29
|
+
let AdminPanelBootstrap = class AdminPanelBootstrap {
|
|
30
|
+
constructor(panel, registry, explorer, pageRegistry, pageExplorer, moduleRef, modulesContainer, options = null) {
|
|
31
|
+
this.panel = panel;
|
|
32
|
+
this.registry = registry;
|
|
33
|
+
this.explorer = explorer;
|
|
34
|
+
this.pageRegistry = pageRegistry;
|
|
35
|
+
this.pageExplorer = pageExplorer;
|
|
36
|
+
this.moduleRef = moduleRef;
|
|
37
|
+
this.modulesContainer = modulesContainer;
|
|
38
|
+
this.options = options;
|
|
39
|
+
}
|
|
40
|
+
async onModuleInit() {
|
|
41
|
+
this.explorer.discover();
|
|
42
|
+
this.panel.registerResources(this.registry.getResources());
|
|
43
|
+
this.pageExplorer.discover();
|
|
44
|
+
this.panel.registerPages(this.pageRegistry.getPages());
|
|
45
|
+
if (this.options?.audit?.enabled) {
|
|
46
|
+
await this.bindActivityResource();
|
|
47
|
+
}
|
|
48
|
+
if (!this.options?.autoBindTypeOrm) {
|
|
49
|
+
return;
|
|
50
|
+
}
|
|
51
|
+
const dataSource = await this.resolveDataSource();
|
|
52
|
+
if (!dataSource) {
|
|
53
|
+
throw new Error('AdminModule autoBindTypeOrm is enabled but no TypeORM DataSource was found. Import TypeOrmModule.forRoot() before AdminModule.forRoot(), or pass dataSource via AdminModule.forRootAsync({ inject: [DataSource], useFactory: (dataSource) => ({ dataSource, autoBindTypeOrm: true, panel: ... }) }).');
|
|
54
|
+
}
|
|
55
|
+
try {
|
|
56
|
+
const { bindTypeOrmResourcesFromModels } = await importTypeOrmAdapter();
|
|
57
|
+
bindTypeOrmResourcesFromModels(this.registry.getResources(), dataSource);
|
|
58
|
+
}
|
|
59
|
+
catch (error) {
|
|
60
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
61
|
+
if (message.includes('Cannot find package') || message.includes('Cannot find module')) {
|
|
62
|
+
throw new Error('AdminModule autoBindTypeOrm requires peer dependency "typeorm"', {
|
|
63
|
+
cause: error,
|
|
64
|
+
});
|
|
65
|
+
}
|
|
66
|
+
throw error;
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
async bindActivityResource() {
|
|
70
|
+
const { AdminActivityResource } = await importAuditActivityResource();
|
|
71
|
+
if (AdminActivityResource.adapter) {
|
|
72
|
+
return;
|
|
73
|
+
}
|
|
74
|
+
const dataSource = this.options?.dataSource;
|
|
75
|
+
if (!isDataSourceLike(dataSource)) {
|
|
76
|
+
throw new Error('AdminModule audit.enabled requires a TypeORM DataSource: ' +
|
|
77
|
+
'AdminModule.forRoot({ audit: { enabled: true }, dataSource }).');
|
|
78
|
+
}
|
|
79
|
+
this.panel.registerResources([AdminActivityResource]);
|
|
80
|
+
const { createTypeOrmResourceFromModel } = await importTypeOrmAdapter();
|
|
81
|
+
const repository = dataSource.getRepository(AdminActivityResource.model);
|
|
82
|
+
AdminActivityResource.adapter = createTypeOrmResourceFromModel(AdminActivityResource, repository);
|
|
83
|
+
}
|
|
84
|
+
async resolveDataSource() {
|
|
85
|
+
if (isDataSourceLike(this.options?.dataSource)) {
|
|
86
|
+
return this.options.dataSource;
|
|
87
|
+
}
|
|
88
|
+
try {
|
|
89
|
+
const { getDataSourceToken } = await import('@nestjs/typeorm');
|
|
90
|
+
const fromToken = this.moduleRef.get(getDataSourceToken(), {
|
|
91
|
+
strict: false,
|
|
92
|
+
});
|
|
93
|
+
if (isDataSourceLike(fromToken)) {
|
|
94
|
+
return fromToken;
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
catch {
|
|
98
|
+
}
|
|
99
|
+
for (const moduleRef of this.modulesContainer.values()) {
|
|
100
|
+
for (const wrapper of moduleRef.providers.values()) {
|
|
101
|
+
if (isDataSourceLike(wrapper.instance)) {
|
|
102
|
+
return wrapper.instance;
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
return null;
|
|
107
|
+
}
|
|
108
|
+
};
|
|
109
|
+
AdminPanelBootstrap = __decorate([
|
|
110
|
+
Injectable(),
|
|
111
|
+
__param(0, Inject(NESTJS_DASH_PANEL)),
|
|
112
|
+
__param(7, Optional()),
|
|
113
|
+
__param(7, Inject(NESTJS_DASH_OPTIONS)),
|
|
114
|
+
__metadata("design:paramtypes", [Function, AdminResourceRegistry,
|
|
115
|
+
AdminResourceExplorer,
|
|
116
|
+
AdminPageRegistry,
|
|
117
|
+
AdminPageExplorer,
|
|
118
|
+
ModuleRef,
|
|
119
|
+
ModulesContainer, Object])
|
|
120
|
+
], AdminPanelBootstrap);
|
|
121
|
+
export { AdminPanelBootstrap };
|
|
122
|
+
//# sourceMappingURL=admin-panel.bootstrap.js.map
|