ngx-essentials-schematics 0.0.16 → 0.0.18

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ngx-essentials-schematics",
3
- "version": "0.0.16",
3
+ "version": "0.0.18",
4
4
  "description": "A collection of Angular schematics for essential functionalities.",
5
5
  "main": "dist/index.js",
6
6
  "scripts": {
@@ -24,6 +24,7 @@
24
24
  "dependencies": {
25
25
  "@angular-devkit/core": "^20.3.13",
26
26
  "@angular-devkit/schematics": "^20.3.13",
27
+ "@schematics/angular": "^21.0.4",
27
28
  "typescript": "~5.9.2"
28
29
  },
29
30
  "devDependencies": {
@@ -1,4 +1,3 @@
1
1
  import { Rule } from "@angular-devkit/schematics";
2
- export declare function ngAdd(options: {
3
- primaryKey: string;
4
- }): Rule;
2
+ import { NgAddSchema } from "./schema";
3
+ export declare function ngAdd(options: NgAddSchema): Rule;
@@ -63,7 +63,7 @@ function updateAngularJson(tree, options) {
63
63
  if (!workspace.schematics)
64
64
  workspace.schematics = {};
65
65
  workspace.schematics["ngx-essentials-schematics:all"] = {
66
- primaryKey: options.primaryKey,
66
+ pk: options.pk,
67
67
  };
68
68
  tree.overwrite(path, JSON.stringify(workspace, null, 2));
69
69
  }
@@ -1,8 +1,18 @@
1
1
  "use strict";
2
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
+ return new (P || (P = Promise))(function (resolve, reject) {
5
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
9
+ });
10
+ };
2
11
  Object.defineProperty(exports, "__esModule", { value: true });
3
12
  exports.signalStore = signalStore;
4
13
  const core_1 = require("@angular-devkit/core");
5
14
  const schematics_1 = require("@angular-devkit/schematics");
15
+ const workspace_1 = require("@schematics/angular/utility/workspace");
6
16
  const pluralizeEs = (name) => {
7
17
  if (!name)
8
18
  return name;
@@ -51,7 +61,13 @@ function mergeFilesSmart(urlPath, destPath, options) {
51
61
  }
52
62
  let treeRef;
53
63
  function signalStore(options) {
54
- return (tree) => {
64
+ return (tree) => __awaiter(this, void 0, void 0, function* () {
65
+ var _a;
66
+ const workspace = yield (0, workspace_1.getWorkspace)(tree);
67
+ const globalConfig = (_a = workspace.extensions.schematics) === null || _a === void 0 ? void 0 : _a["ngx-essentials-schematics:all"];
68
+ if (globalConfig && globalConfig.pk && !options.pk) {
69
+ options.pk = globalConfig.pk;
70
+ }
55
71
  treeRef = tree;
56
72
  const movePath = (0, core_1.normalize)(options.path);
57
73
  const indexPath = (0, core_1.join)(movePath, "index.ts");
@@ -95,7 +111,7 @@ function signalStore(options) {
95
111
  default:
96
112
  return pluralizeEn(word);
97
113
  }
98
- }, pk: options.pk })),
114
+ }, pk: options.pk || "id" })),
99
115
  (0, schematics_1.move)((0, core_1.join)(movePath, core_1.strings.dasherize(options.name))),
100
116
  ]);
101
117
  const commonEntityRule = mergeFilesSmart("./files/entity", (0, core_1.join)(movePath, "common/entity"), options);
@@ -105,6 +121,6 @@ function signalStore(options) {
105
121
  commonEntityRule,
106
122
  commonFormRule,
107
123
  ]);
108
- };
124
+ });
109
125
  }
110
126
  //# sourceMappingURL=index.js.map
@@ -2,5 +2,5 @@ export interface SchemaOptions {
2
2
  name: string;
3
3
  path: string;
4
4
  language: "en" | "es";
5
- pk: string;
5
+ pk?: string;
6
6
  }