@nestjs-dash/schematics 0.0.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.
Files changed (92) hide show
  1. package/README.md +19 -0
  2. package/dist/collection.json +58 -0
  3. package/dist/index.d.ts +4 -0
  4. package/dist/index.d.ts.map +1 -0
  5. package/dist/index.js +4 -0
  6. package/dist/index.js.map +1 -0
  7. package/dist/lib/action/action.factory.d.ts +4 -0
  8. package/dist/lib/action/action.factory.d.ts.map +1 -0
  9. package/dist/lib/action/action.factory.js +41 -0
  10. package/dist/lib/action/action.factory.js.map +1 -0
  11. package/dist/lib/action/schema.json +42 -0
  12. package/dist/lib/entity/entity.factory.d.ts +4 -0
  13. package/dist/lib/entity/entity.factory.d.ts.map +1 -0
  14. package/dist/lib/entity/entity.factory.js +20 -0
  15. package/dist/lib/entity/entity.factory.js.map +1 -0
  16. package/dist/lib/entity/files/ts/__name@dasherize__.entity.ts +32 -0
  17. package/dist/lib/entity/schema.json +38 -0
  18. package/dist/lib/filter/filter.factory.d.ts +4 -0
  19. package/dist/lib/filter/filter.factory.d.ts.map +1 -0
  20. package/dist/lib/filter/filter.factory.js +66 -0
  21. package/dist/lib/filter/filter.factory.js.map +1 -0
  22. package/dist/lib/filter/schema.json +46 -0
  23. package/dist/lib/module/module.factory.d.ts +4 -0
  24. package/dist/lib/module/module.factory.d.ts.map +1 -0
  25. package/dist/lib/module/module.factory.js +75 -0
  26. package/dist/lib/module/module.factory.js.map +1 -0
  27. package/dist/lib/module/module.render.d.ts +13 -0
  28. package/dist/lib/module/module.render.d.ts.map +1 -0
  29. package/dist/lib/module/module.render.js +42 -0
  30. package/dist/lib/module/module.render.js.map +1 -0
  31. package/dist/lib/module/schema.json +57 -0
  32. package/dist/lib/page/files/ts/pages/__name@dasherize__-overview.page.ts +15 -0
  33. package/dist/lib/page/page.factory.d.ts +4 -0
  34. package/dist/lib/page/page.factory.d.ts.map +1 -0
  35. package/dist/lib/page/page.factory.js +18 -0
  36. package/dist/lib/page/page.factory.js.map +1 -0
  37. package/dist/lib/page/schema.json +28 -0
  38. package/dist/lib/panel/files/ts/__name@dasherize__.panel.ts +17 -0
  39. package/dist/lib/panel/panel.factory.d.ts +4 -0
  40. package/dist/lib/panel/panel.factory.d.ts.map +1 -0
  41. package/dist/lib/panel/panel.factory.js +20 -0
  42. package/dist/lib/panel/panel.factory.js.map +1 -0
  43. package/dist/lib/panel/schema.json +28 -0
  44. package/dist/lib/relation-manager/files/ts/relation-managers/__name@dasherize__.relation-manager.ts +13 -0
  45. package/dist/lib/relation-manager/relation-manager.factory.d.ts +4 -0
  46. package/dist/lib/relation-manager/relation-manager.factory.d.ts.map +1 -0
  47. package/dist/lib/relation-manager/relation-manager.factory.js +59 -0
  48. package/dist/lib/relation-manager/relation-manager.factory.js.map +1 -0
  49. package/dist/lib/relation-manager/schema.json +56 -0
  50. package/dist/lib/resource/resource.factory.d.ts +4 -0
  51. package/dist/lib/resource/resource.factory.d.ts.map +1 -0
  52. package/dist/lib/resource/resource.factory.js +112 -0
  53. package/dist/lib/resource/resource.factory.js.map +1 -0
  54. package/dist/lib/resource/resource.render.d.ts +10 -0
  55. package/dist/lib/resource/resource.render.d.ts.map +1 -0
  56. package/dist/lib/resource/resource.render.js +125 -0
  57. package/dist/lib/resource/resource.render.js.map +1 -0
  58. package/dist/lib/resource/schema.json +62 -0
  59. package/dist/lib/widget/schema.json +39 -0
  60. package/dist/lib/widget/widget.factory.d.ts +4 -0
  61. package/dist/lib/widget/widget.factory.d.ts.map +1 -0
  62. package/dist/lib/widget/widget.factory.js +40 -0
  63. package/dist/lib/widget/widget.factory.js.map +1 -0
  64. package/dist/utils/class-codemod.d.ts +33 -0
  65. package/dist/utils/class-codemod.d.ts.map +1 -0
  66. package/dist/utils/class-codemod.js +146 -0
  67. package/dist/utils/class-codemod.js.map +1 -0
  68. package/dist/utils/detect.d.ts +27 -0
  69. package/dist/utils/detect.d.ts.map +1 -0
  70. package/dist/utils/detect.js +135 -0
  71. package/dist/utils/detect.js.map +1 -0
  72. package/dist/utils/entity-introspect.d.ts +17 -0
  73. package/dist/utils/entity-introspect.d.ts.map +1 -0
  74. package/dist/utils/entity-introspect.js +164 -0
  75. package/dist/utils/entity-introspect.js.map +1 -0
  76. package/dist/utils/field-mapping.d.ts +14 -0
  77. package/dist/utils/field-mapping.d.ts.map +1 -0
  78. package/dist/utils/field-mapping.js +100 -0
  79. package/dist/utils/field-mapping.js.map +1 -0
  80. package/dist/utils/module-codemod.d.ts +26 -0
  81. package/dist/utils/module-codemod.d.ts.map +1 -0
  82. package/dist/utils/module-codemod.js +134 -0
  83. package/dist/utils/module-codemod.js.map +1 -0
  84. package/dist/utils/naming.d.ts +5 -0
  85. package/dist/utils/naming.d.ts.map +1 -0
  86. package/dist/utils/naming.js +21 -0
  87. package/dist/utils/naming.js.map +1 -0
  88. package/dist/utils/ts-morph-utils.d.ts +10 -0
  89. package/dist/utils/ts-morph-utils.d.ts.map +1 -0
  90. package/dist/utils/ts-morph-utils.js +34 -0
  91. package/dist/utils/ts-morph-utils.js.map +1 -0
  92. package/package.json +69 -0
package/README.md ADDED
@@ -0,0 +1,19 @@
1
+ # @nestjs-dash/schematics
2
+
3
+ Angular DevKit schematics powering `nestjs-dash generate` — entity/resource/page/panel/module scaffolding for nestjs-dash.
4
+
5
+ ## Install
6
+
7
+ Usually installed transitively via `@nestjs-dash/cli`. To depend on the collection directly:
8
+
9
+ ```bash
10
+ pnpm add -D @nestjs-dash/schematics
11
+ ```
12
+
13
+ ## Part of nestjs-dash
14
+
15
+ This package is one piece of [nestjs-dash](https://github.com/nestjs-dash/nestjs-dash), a NestJS-native admin framework.
16
+
17
+ ## License
18
+
19
+ MIT
@@ -0,0 +1,58 @@
1
+ {
2
+ "$schema": "../node_modules/@angular-devkit/schematics/collection-schema.json",
3
+ "schematics": {
4
+ "entity": {
5
+ "factory": "./lib/entity/entity.factory#main",
6
+ "description": "Create a TypeORM entity wired for Nestjs-Dash (@Sortable/@Searchable/@Filterable).",
7
+ "schema": "./lib/entity/schema.json",
8
+ "aliases": ["e"]
9
+ },
10
+ "module": {
11
+ "factory": "./lib/module/module.factory#main",
12
+ "description": "Create an Nestjs-Dash feature module (TypeOrmModule.forFeature + AdminModule.forFeature) and wire it into the root app module.",
13
+ "schema": "./lib/module/schema.json",
14
+ "aliases": ["mo"]
15
+ },
16
+ "page": {
17
+ "factory": "./lib/page/page.factory#main",
18
+ "description": "Create a standalone Nestjs-Dash custom Page.",
19
+ "schema": "./lib/page/schema.json",
20
+ "aliases": ["pg"]
21
+ },
22
+ "panel": {
23
+ "factory": "./lib/panel/panel.factory#main",
24
+ "description": "Scaffold a standalone Panel + AdminModule.forRoot() file.",
25
+ "schema": "./lib/panel/schema.json"
26
+ },
27
+ "resource": {
28
+ "factory": "./lib/resource/resource.factory#main",
29
+ "description": "Scaffold an entity + Resource (and optionally a Page), wiring both into a feature module and the root app module.",
30
+ "schema": "./lib/resource/schema.json",
31
+ "aliases": ["res"]
32
+ },
33
+ "relation-manager": {
34
+ "factory": "./lib/relation-manager/relation-manager.factory#main",
35
+ "description": "Scaffold a RelationManager subclass, optionally wiring it into an existing Resource's relationManagers array.",
36
+ "schema": "./lib/relation-manager/schema.json",
37
+ "aliases": ["rm"]
38
+ },
39
+ "filter": {
40
+ "factory": "./lib/filter/filter.factory#main",
41
+ "description": "Wire a SelectFilter/TextFilter/DateFilter into an existing resource's table().",
42
+ "schema": "./lib/filter/schema.json",
43
+ "aliases": ["fi"]
44
+ },
45
+ "action": {
46
+ "factory": "./lib/action/action.factory#main",
47
+ "description": "Wire a custom Action.make(...).handler(...) into an existing resource's table() (row/bulk/toolbar).",
48
+ "schema": "./lib/action/schema.json",
49
+ "aliases": ["ac"]
50
+ },
51
+ "widget": {
52
+ "factory": "./lib/widget/widget.factory#main",
53
+ "description": "Wire a DashboardWidget (StatCard or a BarChart/LineChart/PieChart) into an existing Panel's widgets().",
54
+ "schema": "./lib/widget/schema.json",
55
+ "aliases": ["wi"]
56
+ }
57
+ }
58
+ }
@@ -0,0 +1,4 @@
1
+ export { introspectEntitySource, type EntityField, type EntityFieldRole, type EntityFieldType, type IntrospectedEntity, } from './utils/entity-introspect.js';
2
+ export { buildResourceDeclarations, type ResourceDeclarations } from './utils/field-mapping.js';
3
+ export { humanize, toCamelCase, toKebabCase, toPascalCase } from './utils/naming.js';
4
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,sBAAsB,EACtB,KAAK,WAAW,EAChB,KAAK,eAAe,EACpB,KAAK,eAAe,EACpB,KAAK,kBAAkB,GACxB,MAAM,8BAA8B,CAAC;AACtC,OAAO,EAAE,yBAAyB,EAAE,KAAK,oBAAoB,EAAE,MAAM,0BAA0B,CAAC;AAChG,OAAO,EAAE,QAAQ,EAAE,WAAW,EAAE,WAAW,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC"}
package/dist/index.js ADDED
@@ -0,0 +1,4 @@
1
+ export { introspectEntitySource, } from './utils/entity-introspect.js';
2
+ export { buildResourceDeclarations } from './utils/field-mapping.js';
3
+ export { humanize, toCamelCase, toKebabCase, toPascalCase } from './utils/naming.js';
4
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,sBAAsB,GAKvB,MAAM,8BAA8B,CAAC;AACtC,OAAO,EAAE,yBAAyB,EAA6B,MAAM,0BAA0B,CAAC;AAChG,OAAO,EAAE,QAAQ,EAAE,WAAW,EAAE,WAAW,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC"}
@@ -0,0 +1,4 @@
1
+ import { type Rule } from '@angular-devkit/schematics';
2
+ import type { ActionOptions } from './action.schema.js';
3
+ export declare function main(options: ActionOptions): Rule;
4
+ //# sourceMappingURL=action.factory.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"action.factory.d.ts","sourceRoot":"","sources":["../../../src/lib/action/action.factory.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,KAAK,IAAI,EAGV,MAAM,4BAA4B,CAAC;AAIpC,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AAiBxD,wBAAgB,IAAI,CAAC,OAAO,EAAE,aAAa,GAAG,IAAI,CAuBjD"}
@@ -0,0 +1,41 @@
1
+ import { SchematicsException, } from '@angular-devkit/schematics';
2
+ import { codemodFluentChainArray } from '../../utils/class-codemod.js';
3
+ import { normalizePath } from '../../utils/detect.js';
4
+ import { humanize, toPascalCase } from '../../utils/naming.js';
5
+ const CHAIN_METHOD_BY_VARIANT = {
6
+ record: 'actions',
7
+ bulk: 'bulkActions',
8
+ toolbar: 'toolbarActions',
9
+ };
10
+ function buildActionElement(options) {
11
+ const label = options.label ?? humanize(toPascalCase(options.name));
12
+ let text = `Action.make('${options.name}')`;
13
+ if (options.icon)
14
+ text += `.icon('${options.icon}')`;
15
+ text += `.label('${label}')`;
16
+ text += `.handler(async (ctx) => {\n // TODO: implement ${options.name}\n })`;
17
+ return text;
18
+ }
19
+ export function main(options) {
20
+ return (tree, context) => {
21
+ const resourcePath = normalizePath(options.resource);
22
+ if (!tree.exists(resourcePath)) {
23
+ throw new SchematicsException(`--resource points at ${resourcePath}, which doesn't exist.`);
24
+ }
25
+ const chainMethodName = CHAIN_METHOD_BY_VARIANT[options.variant ?? 'record'];
26
+ const elementText = buildActionElement(options);
27
+ const result = codemodFluentChainArray({
28
+ tree,
29
+ filePath: resourcePath,
30
+ owner: { kind: 'class-static-method', methodName: 'table' },
31
+ chainMethodName,
32
+ elementText,
33
+ namedImports: [{ moduleSpecifier: '@nestjs-dash/core', name: 'Action' }],
34
+ });
35
+ if (options.verbose) {
36
+ context.logger.info(`${result.changed ? 'Modified' : 'No changes needed'}: ${resourcePath}`);
37
+ }
38
+ return tree;
39
+ };
40
+ }
41
+ //# sourceMappingURL=action.factory.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"action.factory.js","sourceRoot":"","sources":["../../../src/lib/action/action.factory.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,mBAAmB,GAIpB,MAAM,4BAA4B,CAAC;AACpC,OAAO,EAAE,uBAAuB,EAAE,MAAM,8BAA8B,CAAC;AACvE,OAAO,EAAE,aAAa,EAAE,MAAM,uBAAuB,CAAC;AACtD,OAAO,EAAE,QAAQ,EAAE,YAAY,EAAE,MAAM,uBAAuB,CAAC;AAG/D,MAAM,uBAAuB,GAAG;IAC9B,MAAM,EAAE,SAAS;IACjB,IAAI,EAAE,aAAa;IACnB,OAAO,EAAE,gBAAgB;CACjB,CAAC;AAEX,SAAS,kBAAkB,CAAC,OAAsB;IAChD,MAAM,KAAK,GAAG,OAAO,CAAC,KAAK,IAAI,QAAQ,CAAC,YAAY,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC;IACpE,IAAI,IAAI,GAAG,gBAAgB,OAAO,CAAC,IAAI,IAAI,CAAC;IAC5C,IAAI,OAAO,CAAC,IAAI;QAAE,IAAI,IAAI,UAAU,OAAO,CAAC,IAAI,IAAI,CAAC;IACrD,IAAI,IAAI,WAAW,KAAK,IAAI,CAAC;IAC7B,IAAI,IAAI,qDAAqD,OAAO,CAAC,IAAI,QAAQ,CAAC;IAClF,OAAO,IAAI,CAAC;AACd,CAAC;AAED,MAAM,UAAU,IAAI,CAAC,OAAsB;IACzC,OAAO,CAAC,IAAU,EAAE,OAAyB,EAAE,EAAE;QAC/C,MAAM,YAAY,GAAG,aAAa,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC;QACrD,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,YAAY,CAAC,EAAE,CAAC;YAC/B,MAAM,IAAI,mBAAmB,CAAC,wBAAwB,YAAY,wBAAwB,CAAC,CAAC;QAC9F,CAAC;QAED,MAAM,eAAe,GAAG,uBAAuB,CAAC,OAAO,CAAC,OAAO,IAAI,QAAQ,CAAC,CAAC;QAC7E,MAAM,WAAW,GAAG,kBAAkB,CAAC,OAAO,CAAC,CAAC;QAChD,MAAM,MAAM,GAAG,uBAAuB,CAAC;YACrC,IAAI;YACJ,QAAQ,EAAE,YAAY;YACtB,KAAK,EAAE,EAAE,IAAI,EAAE,qBAAqB,EAAE,UAAU,EAAE,OAAO,EAAE;YAC3D,eAAe;YACf,WAAW;YACX,YAAY,EAAE,CAAC,EAAE,eAAe,EAAE,mBAAmB,EAAE,IAAI,EAAE,QAAQ,EAAE,CAAC;SACzE,CAAC,CAAC;QAEH,IAAI,OAAO,CAAC,OAAO,EAAE,CAAC;YACpB,OAAO,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,MAAM,CAAC,OAAO,CAAC,CAAC,CAAC,UAAU,CAAC,CAAC,CAAC,mBAAmB,KAAK,YAAY,EAAE,CAAC,CAAC;QAC/F,CAAC;QACD,OAAO,IAAI,CAAC;IACd,CAAC,CAAC;AACJ,CAAC"}
@@ -0,0 +1,42 @@
1
+ {
2
+ "$schema": "http://json-schema.org/schema",
3
+ "$id": "SchematicsNestjs-DashAction",
4
+ "title": "Nestjs-Dash Action Options Schema",
5
+ "type": "object",
6
+ "properties": {
7
+ "name": {
8
+ "type": "string",
9
+ "description": "The action's name/verb, e.g. publish.",
10
+ "$default": {
11
+ "$source": "argv",
12
+ "index": 0
13
+ },
14
+ "x-prompt": "What should this action be called?"
15
+ },
16
+ "resource": {
17
+ "type": "string",
18
+ "format": "path",
19
+ "description": "Path to the Resource (or RelationManager) file whose table() gets the new action."
20
+ },
21
+ "variant": {
22
+ "type": "string",
23
+ "enum": ["record", "bulk", "toolbar"],
24
+ "default": "record",
25
+ "description": "record -> .actions([...]) (row action), bulk -> .bulkActions([...]), toolbar -> .toolbarActions([...])."
26
+ },
27
+ "icon": {
28
+ "type": "string",
29
+ "description": "Lucide icon name, e.g. star."
30
+ },
31
+ "label": {
32
+ "type": "string",
33
+ "description": "Button label. Defaults to the humanized action name."
34
+ },
35
+ "verbose": {
36
+ "type": "boolean",
37
+ "default": false,
38
+ "description": "Print diagnostics about the codemod result."
39
+ }
40
+ },
41
+ "required": ["name", "resource"]
42
+ }
@@ -0,0 +1,4 @@
1
+ import { type Rule } from '@angular-devkit/schematics';
2
+ import type { EntityOptions } from './entity.schema.js';
3
+ export declare function main(options: EntityOptions): Rule;
4
+ //# sourceMappingURL=entity.factory.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"entity.factory.d.ts","sourceRoot":"","sources":["../../../src/lib/entity/entity.factory.ts"],"names":[],"mappings":"AACA,OAAO,EAOL,KAAK,IAAI,EAGV,MAAM,4BAA4B,CAAC;AAEpC,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AAExD,wBAAgB,IAAI,CAAC,OAAO,EAAE,aAAa,GAAG,IAAI,CAwBjD"}
@@ -0,0 +1,20 @@
1
+ import { join, normalize, strings } from '@angular-devkit/core';
2
+ import { apply, MergeStrategy, mergeWith, move, template, url, } from '@angular-devkit/schematics';
3
+ import { toKebabCase } from '../../utils/naming.js';
4
+ export function main(options) {
5
+ return (tree, context) => {
6
+ const basePath = normalize(options.path ?? '/');
7
+ const path = options.flat ? basePath : join(basePath, 'entities');
8
+ const targetPath = join(path, `${toKebabCase(options.name)}.entity.ts`);
9
+ if (tree.exists(targetPath) && !options.force) {
10
+ context.logger.warn(`Skipped (already exists): ${targetPath}`);
11
+ return tree;
12
+ }
13
+ const strategy = tree.exists(targetPath) ? MergeStrategy.Overwrite : MergeStrategy.Default;
14
+ return mergeWith(apply(url('./files/ts'), [
15
+ template({ softDelete: false, ...strings, ...options }),
16
+ move(path),
17
+ ]), strategy)(tree, context);
18
+ };
19
+ }
20
+ //# sourceMappingURL=entity.factory.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"entity.factory.js","sourceRoot":"","sources":["../../../src/lib/entity/entity.factory.ts"],"names":[],"mappings":"AAAA,O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,CAAC,CAAC;AACJ,CAAC"}
@@ -0,0 +1,32 @@
1
+ import { Filterable, Searchable, Sortable } from '@nestjs-dash/typeorm';
2
+ import {
3
+ BaseEntity,
4
+ Column,
5
+ CreateDateColumn,<% if (softDelete) { %>
6
+ DeleteDateColumn,<% } %>
7
+ Entity,
8
+ PrimaryGeneratedColumn,
9
+ UpdateDateColumn,
10
+ } from 'typeorm';
11
+
12
+ @Entity('<%= dasherize(name) %>s')
13
+ export class <%= classify(name) %>Entity extends BaseEntity {
14
+ @PrimaryGeneratedColumn('uuid')
15
+ id!: string;
16
+
17
+ @Column({ type: 'varchar' })
18
+ @Sortable()
19
+ @Searchable()
20
+ @Filterable(['$eq', '$ilike'])
21
+ name!: string;
22
+
23
+ @CreateDateColumn()
24
+ @Sortable('DESC')
25
+ createdAt!: Date;
26
+
27
+ @UpdateDateColumn()
28
+ updatedAt!: Date;
29
+ <% if (softDelete) { %>
30
+ @DeleteDateColumn()
31
+ deletedAt?: Date;
32
+ <% } %>}
@@ -0,0 +1,38 @@
1
+ {
2
+ "$schema": "http://json-schema.org/schema",
3
+ "$id": "SchematicsNestjs-DashEntity",
4
+ "title": "Nestjs-Dash Entity Options Schema",
5
+ "type": "object",
6
+ "properties": {
7
+ "name": {
8
+ "type": "string",
9
+ "description": "The name of the entity, e.g. Bid or bid.",
10
+ "$default": {
11
+ "$source": "argv",
12
+ "index": 0
13
+ },
14
+ "x-prompt": "What name would you like to use for this entity?"
15
+ },
16
+ "path": {
17
+ "type": "string",
18
+ "format": "path",
19
+ "description": "Directory to create the entity in (an entities/ subfolder is added unless flat is set)."
20
+ },
21
+ "flat": {
22
+ "type": "boolean",
23
+ "default": false,
24
+ "description": "Do not create an entities/ subfolder — write the entity file directly into path."
25
+ },
26
+ "force": {
27
+ "type": "boolean",
28
+ "default": false,
29
+ "description": "Overwrite an existing entity file without prompting."
30
+ },
31
+ "softDelete": {
32
+ "type": "boolean",
33
+ "default": false,
34
+ "description": "Add a @DeleteDateColumn() so Nestjs-Dash's TypeORM adapter soft-deletes this entity."
35
+ }
36
+ },
37
+ "required": ["name"]
38
+ }
@@ -0,0 +1,4 @@
1
+ import { type Rule } from '@angular-devkit/schematics';
2
+ import type { FilterOptions } from './filter.schema.js';
3
+ export declare function main(options: FilterOptions): Rule;
4
+ //# sourceMappingURL=filter.factory.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"filter.factory.d.ts","sourceRoot":"","sources":["../../../src/lib/filter/filter.factory.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,KAAK,IAAI,EAGV,MAAM,4BAA4B,CAAC;AAIpC,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AA6CxD,wBAAgB,IAAI,CAAC,OAAO,EAAE,aAAa,GAAG,IAAI,CAsBjD"}
@@ -0,0 +1,66 @@
1
+ import { SchematicsException, } from '@angular-devkit/schematics';
2
+ import { codemodFluentChainArray } from '../../utils/class-codemod.js';
3
+ import { normalizePath } from '../../utils/detect.js';
4
+ import { humanize, toPascalCase } from '../../utils/naming.js';
5
+ const BUILDER_BY_KIND = { text: 'TextFilter', select: 'SelectFilter', date: 'DateFilter' };
6
+ function parseOperators(value) {
7
+ if (!value)
8
+ return undefined;
9
+ const operators = value
10
+ .split(',')
11
+ .map((o) => o.trim())
12
+ .filter(Boolean);
13
+ return operators.length ? `[${operators.map((o) => `'${o}'`).join(', ')}]` : undefined;
14
+ }
15
+ function parseSelectOptions(value) {
16
+ if (!value)
17
+ return undefined;
18
+ const entries = value
19
+ .split(',')
20
+ .map((pair) => pair.trim())
21
+ .filter(Boolean)
22
+ .map((pair) => {
23
+ const [rawValue, ...rest] = pair.split(':');
24
+ const key = (rawValue ?? '').trim();
25
+ const label = rest.join(':').trim() || key;
26
+ return `${key}: '${label}'`;
27
+ });
28
+ return entries.length ? `{ ${entries.join(', ')} }` : undefined;
29
+ }
30
+ function buildFilterElement(options) {
31
+ const kind = options.kind ?? 'text';
32
+ const builder = BUILDER_BY_KIND[kind];
33
+ const label = options.label ?? humanize(toPascalCase(options.name));
34
+ let text = `${builder}.make('${options.name}').label('${label}')`;
35
+ if (kind === 'select') {
36
+ const optionsLiteral = parseSelectOptions(options.options);
37
+ if (optionsLiteral)
38
+ text += `.options(${optionsLiteral})`;
39
+ }
40
+ const operatorsLiteral = parseOperators(options.operators);
41
+ if (operatorsLiteral)
42
+ text += `.operators(${operatorsLiteral})`;
43
+ return { elementText: text, builder };
44
+ }
45
+ export function main(options) {
46
+ return (tree, context) => {
47
+ const resourcePath = normalizePath(options.resource);
48
+ if (!tree.exists(resourcePath)) {
49
+ throw new SchematicsException(`--resource points at ${resourcePath}, which doesn't exist.`);
50
+ }
51
+ const { elementText, builder } = buildFilterElement(options);
52
+ const result = codemodFluentChainArray({
53
+ tree,
54
+ filePath: resourcePath,
55
+ owner: { kind: 'class-static-method', methodName: 'table' },
56
+ chainMethodName: 'filters',
57
+ elementText,
58
+ namedImports: [{ moduleSpecifier: '@nestjs-dash/core', name: builder }],
59
+ });
60
+ if (options.verbose) {
61
+ context.logger.info(`${result.changed ? 'Modified' : 'No changes needed'}: ${resourcePath}`);
62
+ }
63
+ return tree;
64
+ };
65
+ }
66
+ //# sourceMappingURL=filter.factory.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"filter.factory.js","sourceRoot":"","sources":["../../../src/lib/filter/filter.factory.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,mBAAmB,GAIpB,MAAM,4BAA4B,CAAC;AACpC,OAAO,EAAE,uBAAuB,EAAE,MAAM,8BAA8B,CAAC;AACvE,OAAO,EAAE,aAAa,EAAE,MAAM,uBAAuB,CAAC;AACtD,OAAO,EAAE,QAAQ,EAAE,YAAY,EAAE,MAAM,uBAAuB,CAAC;AAG/D,MAAM,eAAe,GAAG,EAAE,IAAI,EAAE,YAAY,EAAE,MAAM,EAAE,cAAc,EAAE,IAAI,EAAE,YAAY,EAAW,CAAC;AAEpG,SAAS,cAAc,CAAC,KAAyB;IAC/C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O,EAAE;YAC3D,eAAe,EAAE,SAAS;YAC1B,WAAW;YACX,YAAY,EAAE,CAAC,EAAE,eAAe,EAAE,mBAAmB,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC;SACxE,CAAC,CAAC;QAEH,IAAI,OAAO,CAAC,OAAO,EAAE,CAAC;YACpB,OAAO,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,MAAM,CAAC,OAAO,CAAC,CAAC,CAAC,UAAU,CAAC,CAAC,CAAC,mBAAmB,KAAK,YAAY,EAAE,CAAC,CAAC;QAC/F,CAAC;QACD,OAAO,IAAI,CAAC;IACd,CAAC,CAAC;AACJ,CAAC"}
@@ -0,0 +1,46 @@
1
+ {
2
+ "$schema": "http://json-schema.org/schema",
3
+ "$id": "SchematicsNestjs-DashFilter",
4
+ "title": "Nestjs-Dash Filter Options Schema",
5
+ "type": "object",
6
+ "properties": {
7
+ "name": {
8
+ "type": "string",
9
+ "description": "The column to filter on, e.g. status.",
10
+ "$default": {
11
+ "$source": "argv",
12
+ "index": 0
13
+ },
14
+ "x-prompt": "Which column should this filter target?"
15
+ },
16
+ "resource": {
17
+ "type": "string",
18
+ "format": "path",
19
+ "description": "Path to the Resource (or RelationManager) file whose table() gets a new .filters([...]) entry."
20
+ },
21
+ "kind": {
22
+ "type": "string",
23
+ "enum": ["text", "select", "date"],
24
+ "default": "text",
25
+ "description": "Which filter builder to scaffold."
26
+ },
27
+ "label": {
28
+ "type": "string",
29
+ "description": "Filter label. Defaults to the humanized column name."
30
+ },
31
+ "options": {
32
+ "type": "string",
33
+ "description": "kind=select only: comma-separated value:Label pairs, e.g. \"active:Active,banned:Banned\"."
34
+ },
35
+ "operators": {
36
+ "type": "string",
37
+ "description": "Comma-separated FilterOperator list, e.g. \"$eq,$ilike\". Defaults to the builder's own default operator(s)."
38
+ },
39
+ "verbose": {
40
+ "type": "boolean",
41
+ "default": false,
42
+ "description": "Print diagnostics about the codemod result."
43
+ }
44
+ },
45
+ "required": ["name", "resource"]
46
+ }
@@ -0,0 +1,4 @@
1
+ import type { Rule } from '@angular-devkit/schematics';
2
+ import type { ModuleOptions } from './module.schema.js';
3
+ export declare function main(options: ModuleOptions): Rule;
4
+ //# sourceMappingURL=module.factory.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"module.factory.d.ts","sourceRoot":"","sources":["../../../src/lib/module/module.factory.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAA0B,MAAM,4BAA4B,CAAC;AAY/E,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AAExD,wBAAgB,IAAI,CAAC,OAAO,EAAE,aAAa,GAAG,IAAI,CAqFjD"}
@@ -0,0 +1,75 @@
1
+ import { join, normalize } from 'node:path/posix';
2
+ import { detectOrm, findModuleFileInDir, findRootAppModule, relativeImportPath, resolveSourceRoot, } from '../../utils/detect.js';
3
+ import { codemodFeatureModule, codemodRootModule } from '../../utils/module-codemod.js';
4
+ import { toKebabCase, toPascalCase } from '../../utils/naming.js';
5
+ import { renderModuleTemplate } from './module.render.js';
6
+ export function main(options) {
7
+ return (tree, context) => {
8
+ const kebab = toKebabCase(options.name);
9
+ const dir = options.path ? join(normalize(`/${options.path}`), kebab) : normalize(`/${kebab}`);
10
+ const moduleClassName = `${toPascalCase(options.name)}Module`;
11
+ const { orm, detected } = detectOrm(tree);
12
+ if (options.verbose && !orm && detected.length !== 1) {
13
+ context.logger.info(detected.length === 0
14
+ ? 'No ORM dependency detected in package.json — defaulting to TypeORM-shaped module wiring.'
15
+ : `Multiple ORM dependencies detected (${detected.join(', ')}) — defaulting to TypeORM-shaped module wiring.`);
16
+ }
17
+ const entityRef = options.entityClassName
18
+ ? { className: options.entityClassName, importPath: options.entityImportPath }
19
+ : undefined;
20
+ const resourceRef = options.resourceClassName
21
+ ? { className: options.resourceClassName, importPath: options.resourceImportPath }
22
+ : undefined;
23
+ const pageRef = options.pageClassName
24
+ ? { className: options.pageClassName, importPath: options.pageImportPath }
25
+ : undefined;
26
+ const existingModulePath = findModuleFileInDir(tree, dir);
27
+ if (existingModulePath) {
28
+ const result = codemodFeatureModule({
29
+ tree,
30
+ modulePath: existingModulePath,
31
+ entity: entityRef,
32
+ resource: resourceRef,
33
+ page: pageRef,
34
+ orm,
35
+ });
36
+ if (options.verbose) {
37
+ context.logger.info(`${result.changed ? 'Modified' : 'No changes needed'}: ${existingModulePath}`);
38
+ }
39
+ return tree;
40
+ }
41
+ const modulePath = join(dir, `${kebab}.module.ts`);
42
+ const moduleSource = renderModuleTemplate({
43
+ moduleClassName,
44
+ entityClassName: options.entityClassName,
45
+ entityImportPath: options.entityImportPath,
46
+ resourceClassName: options.resourceClassName,
47
+ resourceImportPath: options.resourceImportPath,
48
+ pageClassName: options.pageClassName,
49
+ pageImportPath: options.pageImportPath,
50
+ orm,
51
+ });
52
+ tree.create(modulePath, moduleSource);
53
+ if (options.skipRootImport)
54
+ return tree;
55
+ const sourceRoot = resolveSourceRoot(tree);
56
+ const rootModulePath = findRootAppModule(tree, sourceRoot);
57
+ if (!rootModulePath) {
58
+ context.logger.warn(`No root app module found under ${sourceRoot} — skipped wiring ${moduleClassName} into it. Import and register it manually.`);
59
+ return tree;
60
+ }
61
+ const result = codemodRootModule({
62
+ tree,
63
+ modulePath: rootModulePath,
64
+ featureModule: {
65
+ className: moduleClassName,
66
+ importPath: relativeImportPath(rootModulePath, modulePath),
67
+ },
68
+ });
69
+ if (options.verbose) {
70
+ context.logger.info(`${result.changed ? 'Modified' : 'No changes needed'}: ${rootModulePath}`);
71
+ }
72
+ return tree;
73
+ };
74
+ }
75
+ //# sourceMappingURL=module.factory.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"module.factory.js","sourceRoot":"","sources":["../../../src/lib/module/module.factory.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,IAAI,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAClD,OAAO,EACL,SAAS,EACT,mBAAmB,EACnB,iBAAiB,EACjB,kB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ACJ,CAAC,CAAC;QACH,IAAI,CAAC,MAAM,CAAC,UAAU,EAAE,YAAY,CAAC,CAAC;QAEtC,IAAI,OAAO,CAAC,cAAc;YAAE,OAAO,IAAI,CAAC;QAExC,MAAM,UAAU,GAAG,iBAAiB,CAAC,IAAI,CAAC,CAAC;QAC3C,MAAM,cAAc,GAAG,iBAAiB,CAAC,IAAI,EAAE,UAAU,CAAC,CAAC;QAC3D,IAAI,CAAC,cAAc,EAAE,CAAC;YACpB,OAAO,CAAC,MAAM,CAAC,IAAI,CACjB,kCAAkC,UAAU,qBAAqB,eAAe,4CAA4C,CAC7H,CAAC;YACF,OAAO,IAAI,CAAC;QACd,CAAC;QAED,MAAM,MAAM,GAAG,iBAAiB,CAAC;YAC/B,IAAI;YACJ,UAAU,EAAE,cAAc;YAC1B,aAAa,EAAE;gBACb,SAAS,EAAE,eAAe;gBAC1B,UAAU,EAAE,kBAAkB,CAAC,cAAc,EAAE,UAAU,CAAC;aAC3D;SACF,CAAC,CAAC;QACH,IAAI,OAAO,CAAC,OAAO,EAAE,CAAC;YACpB,OAAO,CAAC,MAAM,CAAC,IAAI,CACjB,GAAG,MAAM,CAAC,OAAO,CAAC,CAAC,CAAC,UAAU,CAAC,CAAC,CAAC,mBAAmB,KAAK,cAAc,EAAE,CAC1E,CAAC;QACJ,CAAC;QACD,OAAO,IAAI,CAAC;IACd,CAAC,CAAC;AACJ,CAAC"}
@@ -0,0 +1,13 @@
1
+ import type { DetectedOrm } from '../../utils/detect.js';
2
+ export interface RenderModuleOptions {
3
+ moduleClassName: string;
4
+ entityClassName?: string;
5
+ entityImportPath?: string;
6
+ resourceClassName?: string;
7
+ resourceImportPath?: string;
8
+ pageClassName?: string;
9
+ pageImportPath?: string;
10
+ orm?: DetectedOrm;
11
+ }
12
+ export declare function renderModuleTemplate(options: RenderModuleOptions): string;
13
+ //# sourceMappingURL=module.render.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"module.render.d.ts","sourceRoot":"","sources":["../../../src/lib/module/module.render.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAC;AAEzD,MAAM,WAAW,mBAAmB;IAClC,eAAe,EAAE,MAAM,CAAC;IACxB,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B,iBAAiB,CAAC,EAAE,MAAM,CAAC;IAC3B,kBAAkB,CAAC,EAAE,MAAM,CAAC;IAC5B,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,cAAc,CAAC,EAAE,MAAM,CAAC;IAQxB,GAAG,CAAC,EAAE,WAAW,CAAC;CACnB;AAeD,wBAAgB,oBAAoB,CAAC,OAAO,EAAE,mBAAmB,GAAG,MAAM,CAsCzE"}
@@ -0,0 +1,42 @@
1
+ const ORM_MODULE = {
2
+ typeorm: { importPath: '@nestjs/typeorm', className: 'TypeOrmModule' },
3
+ mikroorm: { importPath: '@mikro-orm/nestjs', className: 'MikroOrmModule' },
4
+ };
5
+ export function renderModuleTemplate(options) {
6
+ const ormModule = options.entityClassName ? ORM_MODULE[options.orm ?? 'typeorm'] : undefined;
7
+ const needsAdminImport = Boolean(options.entityClassName || options.resourceClassName);
8
+ const imports = [];
9
+ if (needsAdminImport)
10
+ imports.push("import { AdminModule } from '@nestjs-dash/nestjs';");
11
+ imports.push("import { Module } from '@nestjs/common';");
12
+ if (ormModule)
13
+ imports.push(`import { ${ormModule.className} } from '${ormModule.importPath}';`);
14
+ if (options.entityClassName && options.entityImportPath) {
15
+ imports.push(`import { ${options.entityClassName} } from '${options.entityImportPath}';`);
16
+ }
17
+ if (options.resourceClassName && options.resourceImportPath) {
18
+ imports.push(`import { ${options.resourceClassName} } from '${options.resourceImportPath}';`);
19
+ }
20
+ if (options.pageClassName && options.pageImportPath) {
21
+ imports.push(`import { ${options.pageClassName} } from '${options.pageImportPath}';`);
22
+ }
23
+ const importsArrayLines = [];
24
+ if (ormModule)
25
+ importsArrayLines.push(` ${ormModule.className}.forFeature([${options.entityClassName}]),`);
26
+ if (options.resourceClassName)
27
+ importsArrayLines.push(` AdminModule.forFeature([${options.resourceClassName}]),`);
28
+ const providers = options.pageClassName ? `[${options.pageClassName}]` : '[]';
29
+ const exportsBlock = ormModule ? `[${ormModule.className}]` : '[]';
30
+ return `${imports.join('\n')}
31
+
32
+ @Module({
33
+ imports: [
34
+ ${importsArrayLines.join('\n')}
35
+ ],
36
+ providers: ${providers},
37
+ exports: ${exportsBlock},
38
+ })
39
+ export class ${options.moduleClassName} {}
40
+ `;
41
+ }
42
+ //# sourceMappingURL=module.render.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"module.render.js","sourceRoot":"","sources":["../../../src/lib/module/module.render.ts"],"names":[],"mappings":"AAqBA,MAAM,UAAU,GAA4E;IAC1F,OAAO,EAAE,EAAE,UAAU,EAAE,iBAAiB,EAAE,SAAS,EAAE,eAAe,EAAE;IACtE,QAAQ,EAAE,EAAE,UAAU,EAAE,mBAAmB,EAAE,SAAS,EAAE,gBAAgB,EAAE;CAC3E,CAAC;AASF,MAAM,UAAU,oBAAoB,CAAC,OAA4B;IAC/D,MAAM,SAAS,GAAG,OAAO,CAAC,eAAe,CAAC,CAAC,CAAC,UAAU,CAAC,OAAO,CAAC,GAAG,IAAI,SAAS,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC;IAC7F,MAAM,gBAAgB,GAAG,OAAO,CAAC,OAAO,CAAC,eAAe,IAAI,OAAO,CAAC,iBAAiB,CAAC,CAAC;IAEvF,MAAM,OAAO,GAAa,EAAE,CAAC;IAC7B,IAAI,gBAAgB;QAAE,OAAO,CAAC,IAAI,CAAC,oDAAoD,CAAC,CAAC;IACzF,OAAO,CAAC,IAAI,CAAC,0CAA0C,CAAC,CAAC;IACzD,IAAI,SAAS;QAAE,OAAO,CAAC,IAAI,CAAC,YAAY,SAAS,CAAC,SAAS,YAAY,SAAS,CAAC,UAAU,IAAI,CAAC,CAAC;IACjG,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