@ngrx/entity 20.1.0 → 21.0.0-beta.0

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 (47) hide show
  1. package/migrations/6_0_0/index.js +3 -6
  2. package/migrations/6_0_0/index.js.map +1 -1
  3. package/package.json +5 -5
  4. package/schematics/ng-add/index.js +8 -11
  5. package/schematics/ng-add/index.js.map +1 -1
  6. package/schematics/ng-add/schema.js +0 -2
  7. package/schematics-core/index.js +24 -75
  8. package/schematics-core/index.js.map +1 -1
  9. package/schematics-core/utility/ast-utils.js +28 -44
  10. package/schematics-core/utility/ast-utils.js.map +1 -1
  11. package/schematics-core/utility/change.js +8 -15
  12. package/schematics-core/utility/change.js.map +1 -1
  13. package/schematics-core/utility/config.js +4 -8
  14. package/schematics-core/utility/config.js.map +1 -1
  15. package/schematics-core/utility/find-component.js +17 -22
  16. package/schematics-core/utility/find-component.js.map +1 -1
  17. package/schematics-core/utility/find-module.js +19 -24
  18. package/schematics-core/utility/find-module.js.map +1 -1
  19. package/schematics-core/utility/json-utilts.js +1 -4
  20. package/schematics-core/utility/json-utilts.js.map +1 -1
  21. package/schematics-core/utility/libs-version.js +1 -4
  22. package/schematics-core/utility/libs-version.js.map +1 -1
  23. package/schematics-core/utility/ngrx-utils.js +28 -36
  24. package/schematics-core/utility/ngrx-utils.js.map +1 -1
  25. package/schematics-core/utility/package.js +1 -4
  26. package/schematics-core/utility/package.js.map +1 -1
  27. package/schematics-core/utility/parse-name.js +5 -8
  28. package/schematics-core/utility/parse-name.js.map +1 -1
  29. package/schematics-core/utility/project.js +9 -15
  30. package/schematics-core/utility/project.js.map +1 -1
  31. package/schematics-core/utility/strings.js +9 -20
  32. package/schematics-core/utility/strings.js.map +1 -1
  33. package/schematics-core/utility/update.js +4 -7
  34. package/schematics-core/utility/update.js.map +1 -1
  35. package/schematics-core/utility/visitors.js +16 -30
  36. package/schematics-core/utility/visitors.js.map +1 -1
  37. package/{src/models.d.ts → types/ngrx-entity.d.ts} +28 -23
  38. package/index.d.ts +0 -6
  39. package/public_api.d.ts +0 -1
  40. package/src/create_adapter.d.ts +0 -5
  41. package/src/entity_state.d.ts +0 -8
  42. package/src/index.d.ts +0 -2
  43. package/src/sorted_state_adapter.d.ts +0 -2
  44. package/src/state_adapter.d.ts +0 -7
  45. package/src/state_selectors.d.ts +0 -7
  46. package/src/unsorted_state_adapter.d.ts +0 -2
  47. package/src/utils.d.ts +0 -2
@@ -1,14 +1,3 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.decamelize = decamelize;
4
- exports.dasherize = dasherize;
5
- exports.camelize = camelize;
6
- exports.classify = classify;
7
- exports.underscore = underscore;
8
- exports.capitalize = capitalize;
9
- exports.pluralize = pluralize;
10
- exports.group = group;
11
- exports.featurePath = featurePath;
12
1
  /**
13
2
  * @license
14
3
  * Copyright Google Inc. All Rights Reserved.
@@ -31,7 +20,7 @@ var STRING_UNDERSCORE_REGEXP_2 = /-|\s+/g;
31
20
  decamelize('my favorite items'); // 'my favorite items'
32
21
  ```
33
22
  */
34
- function decamelize(str) {
23
+ export function decamelize(str) {
35
24
  return str.replace(STRING_DECAMELIZE_REGEXP, '$1_$2').toLowerCase();
36
25
  }
37
26
  /**
@@ -44,7 +33,7 @@ function decamelize(str) {
44
33
  dasherize('my favorite items'); // 'my-favorite-items'
45
34
  ```
46
35
  */
47
- function dasherize(str) {
36
+ export function dasherize(str) {
48
37
  return decamelize(str || '').replace(STRING_DASHERIZE_REGEXP, '-');
49
38
  }
50
39
  /**
@@ -58,7 +47,7 @@ function dasherize(str) {
58
47
  camelize('My Favorite Items'); // 'myFavoriteItems'
59
48
  ```
60
49
  */
61
- function camelize(str) {
50
+ export function camelize(str) {
62
51
  return str
63
52
  .replace(STRING_CAMELIZE_REGEXP, function (_match, _separator, chr) {
64
53
  return chr ? chr.toUpperCase() : '';
@@ -75,7 +64,7 @@ function camelize(str) {
75
64
  'my favorite items'.classify(); // 'MyFavoriteItems'
76
65
  ```
77
66
  */
78
- function classify(str) {
67
+ export function classify(str) {
79
68
  return str
80
69
  .split('.')
81
70
  .map(function (part) { return capitalize(camelize(part)); })
@@ -92,7 +81,7 @@ function classify(str) {
92
81
  'my favorite items'.underscore(); // 'my_favorite_items'
93
82
  ```
94
83
  */
95
- function underscore(str) {
84
+ export function underscore(str) {
96
85
  return str
97
86
  .replace(STRING_UNDERSCORE_REGEXP_1, '$1_$2')
98
87
  .replace(STRING_UNDERSCORE_REGEXP_2, '_')
@@ -108,7 +97,7 @@ function underscore(str) {
108
97
  'my favorite items'.capitalize() // 'My favorite items'
109
98
  ```
110
99
  */
111
- function capitalize(str) {
100
+ export function capitalize(str) {
112
101
  return str.charAt(0).toUpperCase() + str.substring(1);
113
102
  }
114
103
  /**
@@ -122,13 +111,13 @@ function capitalize(str) {
122
111
  'user'.pluralize() // 'users'
123
112
  ```
124
113
  */
125
- function pluralize(str) {
114
+ export function pluralize(str) {
126
115
  return camelize([/([^aeiou])y$/, /()fe?$/, /([^aeiou]o|[sxz]|[cs]h)$/].map(function (c, i) { return (str = str.replace(c, "$1".concat('iv'[i] || '', "e"))); }) && str + 's');
127
116
  }
128
- function group(name, group) {
117
+ export function group(name, group) {
129
118
  return group ? "".concat(group, "/").concat(name) : name;
130
119
  }
131
- function featurePath(group, flat, path, name) {
120
+ export function featurePath(group, flat, path, name) {
132
121
  if (group && !flat) {
133
122
  return "../../".concat(path, "/").concat(name, "/");
134
123
  }
@@ -1 +1 @@
1
- {"version":3,"file":"strings.js","sourceRoot":"","sources":["../../../../../modules/entity/schematics-core/utility/strings.ts"],"names":[],"mappings":";;AAuBA,gCAEC;AAYD,8BAEC;AAaD,4BASC;AAYD,4BAKC;AAaD,gCAKC;AAYD,gCAEC;AAaD,8BAMC;AAED,sBAEC;AAED,kCAWC;AAlJD;;;;;;GAMG;AACH,IAAM,uBAAuB,GAAG,OAAO,CAAC;AACxC,IAAM,wBAAwB,GAAG,mBAAmB,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AACnB,CAAC;AAED;;;;;;;;;GASG;AACH,SAAgB,UAAU,CAAC,GAAW;IACpC,OAAO,GAAG,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,WAAW,EAAE,GAAG,GAAG,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC;AACxD,CAAC;AAED;;;;;;;;;;GAUG;AACH,SAAgB,SAAS,CAAC,GAAW;IACnC,OAAO,QAAQ,CACb,CAAC,cAAc,EAAE,QAAQ,EAAE,0BAA0B,CAAC,CAAC,GAAG,CACxD,UAAC,CAAC,EAAE,CAAC,IAAK,OAAA,CAAC,GAAG,GAAG,GAAG,CAAC,OAAO,CAAC,CAAC,EAAE,YAAK,IAAI,CAAC,CAAC,CAAC,IAAI,EAAE,MAAG,CAAC,CAAC,EAA7C,CAA6C,CACxD,IAAI,GAAG,GAAG,GAAG,CACf,CAAC;AACJ,CAAC;AAED,SAAgB,KAAK,CAAC,IAAY,EAAE,KAAyB;IAC3D,OAAO,KAAK,CAAC,CAAC,CAAC,UAAG,KAAK,cAAI,IAAI,CAAE,CAAC,CAAC,CAAC,IAAI,CAAC;AAC3C,CAAC;AAED,SAAgB,WAAW,CACzB,KAA0B,EAC1B,IAAyB,EACzB,IAAY,EACZ,IAAY;IAEZ,IAAI,KAAK,IAAI,CAAC,IAAI,EAAE,CAAC;QACnB,OAAO,gBAAS,IAAI,cAAI,IAAI,MAAG,CAAC;IAClC,CAAC;IAED,OAAO,KAAK,CAAC,CAAC,CAAC,aAAM,IAAI,MAAG,CAAC,CAAC,CAAC,IAAI,CAAC;AACtC,CAAC","sourcesContent":["/**\n * @license\n * Copyright Google Inc. All Rights Reserved.\n *\n * Use of this source code is governed by an MIT-style license that can be\n * found in the LICENSE file at https://angular.io/license\n */\nconst STRING_DASHERIZE_REGEXP = /[ _]/g;\nconst STRING_DECAMELIZE_REGEXP = /([a-z\\d])([A-Z])/g;\nconst STRING_CAMELIZE_REGEXP = /(-|_|\\.|\\s)+(.)?/g;\nconst STRING_UNDERSCORE_REGEXP_1 = /([a-z\\d])([A-Z]+)/g;\nconst STRING_UNDERSCORE_REGEXP_2 = /-|\\s+/g;\n\n/**\n * Converts a camelized string into all lower case separated by underscores.\n *\n ```javascript\n decamelize('innerHTML'); // 'inner_html'\n decamelize('action_name'); // 'action_name'\n decamelize('css-class-name'); // 'css-class-name'\n decamelize('my favorite items'); // 'my favorite items'\n ```\n */\nexport function decamelize(str: string): string {\n return str.replace(STRING_DECAMELIZE_REGEXP, '$1_$2').toLowerCase();\n}\n\n/**\n Replaces underscores, spaces, or camelCase with dashes.\n\n ```javascript\n dasherize('innerHTML'); // 'inner-html'\n dasherize('action_name'); // 'action-name'\n dasherize('css-class-name'); // 'css-class-name'\n dasherize('my favorite items'); // 'my-favorite-items'\n ```\n */\nexport function dasherize(str?: string): string {\n return decamelize(str || '').replace(STRING_DASHERIZE_REGEXP, '-');\n}\n\n/**\n Returns the lowerCamelCase form of a string.\n\n ```javascript\n camelize('innerHTML'); // 'innerHTML'\n camelize('action_name'); // 'actionName'\n camelize('css-class-name'); // 'cssClassName'\n camelize('my favorite items'); // 'myFavoriteItems'\n camelize('My Favorite Items'); // 'myFavoriteItems'\n ```\n */\nexport function camelize(str: string): string {\n return str\n .replace(\n STRING_CAMELIZE_REGEXP,\n (_match: string, _separator: string, chr: string) => {\n return chr ? chr.toUpperCase() : '';\n }\n )\n .replace(/^([A-Z])/, (match: string) => match.toLowerCase());\n}\n\n/**\n Returns the UpperCamelCase form of a string.\n\n ```javascript\n 'innerHTML'.classify(); // 'InnerHTML'\n 'action_name'.classify(); // 'ActionName'\n 'css-class-name'.classify(); // 'CssClassName'\n 'my favorite items'.classify(); // 'MyFavoriteItems'\n ```\n */\nexport function classify(str: string): string {\n return str\n .split('.')\n .map((part) => capitalize(camelize(part)))\n .join('.');\n}\n\n/**\n More general than decamelize. Returns the lower\\_case\\_and\\_underscored\n form of a string.\n\n ```javascript\n 'innerHTML'.underscore(); // 'inner_html'\n 'action_name'.underscore(); // 'action_name'\n 'css-class-name'.underscore(); // 'css_class_name'\n 'my favorite items'.underscore(); // 'my_favorite_items'\n ```\n */\nexport function underscore(str: string): string {\n return str\n .replace(STRING_UNDERSCORE_REGEXP_1, '$1_$2')\n .replace(STRING_UNDERSCORE_REGEXP_2, '_')\n .toLowerCase();\n}\n\n/**\n Returns the Capitalized form of a string\n\n ```javascript\n 'innerHTML'.capitalize() // 'InnerHTML'\n 'action_name'.capitalize() // 'Action_name'\n 'css-class-name'.capitalize() // 'Css-class-name'\n 'my favorite items'.capitalize() // 'My favorite items'\n ```\n */\nexport function capitalize(str: string): string {\n return str.charAt(0).toUpperCase() + str.substring(1);\n}\n\n/**\n Returns the plural form of a string\n\n ```javascript\n 'innerHTML'.pluralize() // 'innerHTMLs'\n 'action_name'.pluralize() // 'actionNames'\n 'css-class-name'.pluralize() // 'cssClassNames'\n 'regex'.pluralize() // 'regexes'\n 'user'.pluralize() // 'users'\n ```\n */\nexport function pluralize(str: string): string {\n return camelize(\n [/([^aeiou])y$/, /()fe?$/, /([^aeiou]o|[sxz]|[cs]h)$/].map(\n (c, i) => (str = str.replace(c, `$1${'iv'[i] || ''}e`))\n ) && str + 's'\n );\n}\n\nexport function group(name: string, group: string | undefined) {\n return group ? `${group}/${name}` : name;\n}\n\nexport function featurePath(\n group: boolean | undefined,\n flat: boolean | undefined,\n path: string,\n name: string\n) {\n if (group && !flat) {\n return `../../${path}/${name}/`;\n }\n\n return group ? `../${path}/` : './';\n}\n"]}
1
+ {"version":3,"file":"strings.js","sourceRoot":"","sources":["../../../../../modules/entity/schematics-core/utility/strings.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,IAAM,uBAAuB,GAAG,OAAO,CAAC;AACxC,IAAM,wBAAwB,GAAG,mBAAmB,CAAC;AACrD,IAAM,sBAAsB,GAAG,mBAAmB,CAAC;AACnD,IAAM,0BAA0B,GAAG,oBAAoB,CAAC;AACxD,IAAM,0BAA0B,GAAG,QAAQ,CAAC;AAE5C;;;;;;;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C,WAAW,EAAE,GAAG,GAAG,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC;AACxD,CAAC;AAED;;;;;;;;;;GAUG;AACH,MAAM,UAAU,SAAS,CAAC,GAAW;IACnC,OAAO,QAAQ,CACb,CAAC,cAAc,EAAE,QAAQ,EAAE,0BAA0B,CAAC,CAAC,GAAG,CACxD,UAAC,CAAC,EAAE,CAAC,IAAK,OAAA,CAAC,GAAG,GAAG,GAAG,CAAC,OAAO,CAAC,CAAC,EAAE,YAAK,IAAI,CAAC,CAAC,CAAC,IAAI,EAAE,MAAG,CAAC,CAAC,EAA7C,CAA6C,CACxD,IAAI,GAAG,GAAG,GAAG,CACf,CAAC;AACJ,CAAC;AAED,MAAM,UAAU,KAAK,CAAC,IAAY,EAAE,KAAyB;IAC3D,OAAO,KAAK,CAAC,CAAC,CAAC,UAAG,KAAK,cAAI,IAAI,CAAE,CAAC,CAAC,CAAC,IAAI,CAAC;AAC3C,CAAC;AAED,MAAM,UAAU,WAAW,CACzB,KAA0B,EAC1B,IAAyB,EACzB,IAAY,EACZ,IAAY;IAEZ,IAAI,KAAK,IAAI,CAAC,IAAI,EAAE,CAAC;QACnB,OAAO,gBAAS,IAAI,cAAI,IAAI,MAAG,CAAC;IAClC,CAAC;IAED,OAAO,KAAK,CAAC,CAAC,CAAC,aAAM,IAAI,MAAG,CAAC,CAAC,CAAC,IAAI,CAAC;AACtC,CAAC","sourcesContent":["/**\n * @license\n * Copyright Google Inc. All Rights Reserved.\n *\n * Use of this source code is governed by an MIT-style license that can be\n * found in the LICENSE file at https://angular.io/license\n */\nconst STRING_DASHERIZE_REGEXP = /[ _]/g;\nconst STRING_DECAMELIZE_REGEXP = /([a-z\\d])([A-Z])/g;\nconst STRING_CAMELIZE_REGEXP = /(-|_|\\.|\\s)+(.)?/g;\nconst STRING_UNDERSCORE_REGEXP_1 = /([a-z\\d])([A-Z]+)/g;\nconst STRING_UNDERSCORE_REGEXP_2 = /-|\\s+/g;\n\n/**\n * Converts a camelized string into all lower case separated by underscores.\n *\n ```javascript\n decamelize('innerHTML'); // 'inner_html'\n decamelize('action_name'); // 'action_name'\n decamelize('css-class-name'); // 'css-class-name'\n decamelize('my favorite items'); // 'my favorite items'\n ```\n */\nexport function decamelize(str: string): string {\n return str.replace(STRING_DECAMELIZE_REGEXP, '$1_$2').toLowerCase();\n}\n\n/**\n Replaces underscores, spaces, or camelCase with dashes.\n\n ```javascript\n dasherize('innerHTML'); // 'inner-html'\n dasherize('action_name'); // 'action-name'\n dasherize('css-class-name'); // 'css-class-name'\n dasherize('my favorite items'); // 'my-favorite-items'\n ```\n */\nexport function dasherize(str?: string): string {\n return decamelize(str || '').replace(STRING_DASHERIZE_REGEXP, '-');\n}\n\n/**\n Returns the lowerCamelCase form of a string.\n\n ```javascript\n camelize('innerHTML'); // 'innerHTML'\n camelize('action_name'); // 'actionName'\n camelize('css-class-name'); // 'cssClassName'\n camelize('my favorite items'); // 'myFavoriteItems'\n camelize('My Favorite Items'); // 'myFavoriteItems'\n ```\n */\nexport function camelize(str: string): string {\n return str\n .replace(\n STRING_CAMELIZE_REGEXP,\n (_match: string, _separator: string, chr: string) => {\n return chr ? chr.toUpperCase() : '';\n }\n )\n .replace(/^([A-Z])/, (match: string) => match.toLowerCase());\n}\n\n/**\n Returns the UpperCamelCase form of a string.\n\n ```javascript\n 'innerHTML'.classify(); // 'InnerHTML'\n 'action_name'.classify(); // 'ActionName'\n 'css-class-name'.classify(); // 'CssClassName'\n 'my favorite items'.classify(); // 'MyFavoriteItems'\n ```\n */\nexport function classify(str: string): string {\n return str\n .split('.')\n .map((part) => capitalize(camelize(part)))\n .join('.');\n}\n\n/**\n More general than decamelize. Returns the lower\\_case\\_and\\_underscored\n form of a string.\n\n ```javascript\n 'innerHTML'.underscore(); // 'inner_html'\n 'action_name'.underscore(); // 'action_name'\n 'css-class-name'.underscore(); // 'css_class_name'\n 'my favorite items'.underscore(); // 'my_favorite_items'\n ```\n */\nexport function underscore(str: string): string {\n return str\n .replace(STRING_UNDERSCORE_REGEXP_1, '$1_$2')\n .replace(STRING_UNDERSCORE_REGEXP_2, '_')\n .toLowerCase();\n}\n\n/**\n Returns the Capitalized form of a string\n\n ```javascript\n 'innerHTML'.capitalize() // 'InnerHTML'\n 'action_name'.capitalize() // 'Action_name'\n 'css-class-name'.capitalize() // 'Css-class-name'\n 'my favorite items'.capitalize() // 'My favorite items'\n ```\n */\nexport function capitalize(str: string): string {\n return str.charAt(0).toUpperCase() + str.substring(1);\n}\n\n/**\n Returns the plural form of a string\n\n ```javascript\n 'innerHTML'.pluralize() // 'innerHTMLs'\n 'action_name'.pluralize() // 'actionNames'\n 'css-class-name'.pluralize() // 'cssClassNames'\n 'regex'.pluralize() // 'regexes'\n 'user'.pluralize() // 'users'\n ```\n */\nexport function pluralize(str: string): string {\n return camelize(\n [/([^aeiou])y$/, /()fe?$/, /([^aeiou]o|[sxz]|[cs]h)$/].map(\n (c, i) => (str = str.replace(c, `$1${'iv'[i] || ''}e`))\n ) && str + 's'\n );\n}\n\nexport function group(name: string, group: string | undefined) {\n return group ? `${group}/${name}` : name;\n}\n\nexport function featurePath(\n group: boolean | undefined,\n flat: boolean | undefined,\n path: string,\n name: string\n) {\n if (group && !flat) {\n return `../../${path}/${name}/`;\n }\n\n return group ? `../${path}/` : './';\n}\n"]}
@@ -1,18 +1,15 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.updatePackage = updatePackage;
4
- var schematics_1 = require("@angular-devkit/schematics");
5
- function updatePackage(name) {
1
+ import { SchematicsException, } from '@angular-devkit/schematics';
2
+ export function updatePackage(name) {
6
3
  return function (tree, context) {
7
4
  var pkgPath = '/package.json';
8
5
  var buffer = tree.read(pkgPath);
9
6
  if (buffer === null) {
10
- throw new schematics_1.SchematicsException('Could not read package.json');
7
+ throw new SchematicsException('Could not read package.json');
11
8
  }
12
9
  var content = buffer.toString();
13
10
  var pkg = JSON.parse(content);
14
11
  if (pkg === null || typeof pkg !== 'object' || Array.isArray(pkg)) {
15
- throw new schematics_1.SchematicsException('Error reading package.json');
12
+ throw new SchematicsException('Error reading package.json');
16
13
  }
17
14
  var dependencyCategories = ['dependencies', 'devDependencies'];
18
15
  dependencyCategories.forEach(function (category) {
@@ -1 +1 @@
1
- {"version":3,"file":"update.js","sourceRoot":"","sources":["../../../../../modules/entity/schematics-core/utility/update.ts"],"names":[],"mappings":";;AAOA,sCA+BC;AAtCD,yDAKoC;AAEpC,SAAgB,aAAa,CAAC,IAAY;IACxC,OAAO,UAAC,IAAU,EAAE,OAAyB;QAC3C,IAAM,OAAO,GAAG,eAAe,CAAC;QAChC,IAAM,MAAM,GAAG,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;QAClC,IAAI,MAAM,KAAK,IAAI,EAAE,CAAC;YACpB,MAAM,IAAI,gCAAmB,CAAC,6BAA6B,CAAC,CAAC;QAC/D,CAAC;QACD,IAAM,OAAO,GAAG,MAAM,CAAC,QAAQ,EAAE,CAAC;QAClC,IAAM,GAAG,GAAG,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC;QAEhC,IAAI,GAAG,KAAK,IAAI,IAAI,OAAO,GAAG,KAAK,QAAQ,IAAI,KAAK,CAAC,OAAO,CAAC,GAAG,CAAC,EAAE,CAAC;YAClE,MAAM,IAAI,gCAAmB,CAAC,4BAA4B,CAAC,CAAC;QAC9D,CAAC;QAED,IAAM,oBAAoB,GAAG,CAAC,cAAc,EAAE,iBAAiB,CAAC,CAAC;QAEjE,oBAAoB,CAAC,OAAO,CAAC,UAAC,QAAQ;YACpC,IAAM,WAAW,GAAG,gBAAS,IAAI,CAAE,CAAC;YAEpC,IAAI,GAAG,CAAC,QAAQ,CAAC,IAAI,GAAG,CAAC,QAAQ,CAAC,CAAC,WAAW,CAAC,EAAE,CAAC;gBAChD,IAAM,SAAS,GAAG,GAAG,CAAC,QAAQ,CAAC,CAAC,WAAW,CAAC,CAAC,CAAC,CAAC,CAAC;gBAChD,IAAM,MAAM,GAAG,KAAK,CAAC,SAAS,EAAE,GAAG,CAAC,IAAI,KAAK,CAAC,SAAS,EAAE,GAAG,CAAC,CAAC;gBAE9D,GAAG,CAAC,QAAQ,CAAC,CAAC,WAAW,CAAC,GAAG,UAAG,MAAM,UAAO,CAAC;YAChD,CAAC;QACH,CAAC,CAAC,CAAC;QAEH,IAAI,CAAC,SAAS,CAAC,OAAO,EAAE,IAAI,CAAC,SAAS,CAAC,GAAG,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC,CAAC;QAEtD,OAAO,IAAI,CAAC;IACd,CAAC,CAAC;AACJ,CAAC;AAED,SAAS,KAAK,CAAC,KAAa,EAAE,IAAY;IACxC,OAAO,KAAK,KAAK,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC;AACpC,CAAC","sourcesContent":["import {\n Rule,\n SchematicContext,\n Tree,\n SchematicsException,\n} from '@angular-devkit/schematics';\n\nexport function updatePackage(name: string): Rule {\n return (tree: Tree, context: SchematicContext) => {\n const pkgPath = '/package.json';\n const buffer = tree.read(pkgPath);\n if (buffer === null) {\n throw new SchematicsException('Could not read package.json');\n }\n const content = buffer.toString();\n const pkg = JSON.parse(content);\n\n if (pkg === null || typeof pkg !== 'object' || Array.isArray(pkg)) {\n throw new SchematicsException('Error reading package.json');\n }\n\n const dependencyCategories = ['dependencies', 'devDependencies'];\n\n dependencyCategories.forEach((category) => {\n const packageName = `@ngrx/${name}`;\n\n if (pkg[category] && pkg[category][packageName]) {\n const firstChar = pkg[category][packageName][0];\n const suffix = match(firstChar, '^') || match(firstChar, '~');\n\n pkg[category][packageName] = `${suffix}6.0.0`;\n }\n });\n\n tree.overwrite(pkgPath, JSON.stringify(pkg, null, 2));\n\n return tree;\n };\n}\n\nfunction match(value: string, test: string) {\n return value === test ? test : '';\n}\n"]}
1
+ {"version":3,"file":"update.js","sourceRoot":"","sources":["../../../../../modules/entity/schematics-core/utility/update.ts"],"names":[],"mappings":"AAAA,OA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AAS,CAAC,OAAO,EAAE,IAAI,CAAC,SAAS,CAAC,GAAG,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC,CAAC;QAEtD,OAAO,IAAI,CAAC;IACd,CAAC,CAAC;AACJ,CAAC;AAED,SAAS,KAAK,CAAC,KAAa,EAAE,IAAY;IACxC,OAAO,KAAK,KAAK,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC;AACpC,CAAC","sourcesContent":["import {\n Rule,\n SchematicContext,\n Tree,\n SchematicsException,\n} from '@angular-devkit/schematics';\n\nexport function updatePackage(name: string): Rule {\n return (tree: Tree, context: SchematicContext) => {\n const pkgPath = '/package.json';\n const buffer = tree.read(pkgPath);\n if (buffer === null) {\n throw new SchematicsException('Could not read package.json');\n }\n const content = buffer.toString();\n const pkg = JSON.parse(content);\n\n if (pkg === null || typeof pkg !== 'object' || Array.isArray(pkg)) {\n throw new SchematicsException('Error reading package.json');\n }\n\n const dependencyCategories = ['dependencies', 'devDependencies'];\n\n dependencyCategories.forEach((category) => {\n const packageName = `@ngrx/${name}`;\n\n if (pkg[category] && pkg[category][packageName]) {\n const firstChar = pkg[category][packageName][0];\n const suffix = match(firstChar, '^') || match(firstChar, '~');\n\n pkg[category][packageName] = `${suffix}6.0.0`;\n }\n });\n\n tree.overwrite(pkgPath, JSON.stringify(pkg, null, 2));\n\n return tree;\n };\n}\n\nfunction match(value: string, test: string) {\n return value === test ? test : '';\n}\n"]}
@@ -1,4 +1,3 @@
1
- "use strict";
2
1
  var __generator = (this && this.__generator) || function (thisArg, body) {
3
2
  var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g = Object.create((typeof Iterator === "function" ? Iterator : Object).prototype);
4
3
  return g.next = verb(0), g["throw"] = verb(1), g["return"] = verb(2), typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
@@ -53,22 +52,9 @@ var __read = (this && this.__read) || function (o, n) {
53
52
  }
54
53
  return ar;
55
54
  };
56
- Object.defineProperty(exports, "__esModule", { value: true });
57
- exports.visitTSSourceFiles = visitTSSourceFiles;
58
- exports.visitTemplates = visitTemplates;
59
- exports.visitNgModuleImports = visitNgModuleImports;
60
- exports.visitNgModuleExports = visitNgModuleExports;
61
- exports.visitComponents = visitComponents;
62
- exports.visitNgModules = visitNgModules;
63
- exports.visitDecorator = visitDecorator;
64
- exports.visitImportDeclaration = visitImportDeclaration;
65
- exports.visitImportSpecifier = visitImportSpecifier;
66
- exports.visitTypeReference = visitTypeReference;
67
- exports.visitTypeLiteral = visitTypeLiteral;
68
- exports.visitCallExpression = visitCallExpression;
69
- var ts = require("typescript");
70
- var core_1 = require("@angular-devkit/core");
71
- function visitTSSourceFiles(tree, visitor) {
55
+ import * as ts from 'typescript';
56
+ import { normalize, resolve } from '@angular-devkit/core';
57
+ export function visitTSSourceFiles(tree, visitor) {
72
58
  var e_1, _a;
73
59
  var result = undefined;
74
60
  try {
@@ -86,7 +72,7 @@ function visitTSSourceFiles(tree, visitor) {
86
72
  }
87
73
  return result;
88
74
  }
89
- function visitTemplates(tree, visitor) {
75
+ export function visitTemplates(tree, visitor) {
90
76
  visitTSSourceFiles(tree, function (source) {
91
77
  visitComponents(source, function (_, decoratorExpressionNode) {
92
78
  ts.forEachChild(decoratorExpressionNode, function findTemplates(n) {
@@ -106,8 +92,8 @@ function visitTemplates(tree, visitor) {
106
92
  }
107
93
  else if (n.name.text === 'templateUrl' &&
108
94
  ts.isStringLiteralLike(n.initializer)) {
109
- var parts = (0, core_1.normalize)(source.fileName).split('/').slice(0, -1);
110
- var templatePath = (0, core_1.resolve)((0, core_1.normalize)(parts.join('/')), (0, core_1.normalize)(n.initializer.text));
95
+ var parts = normalize(source.fileName).split('/').slice(0, -1);
96
+ var templatePath = resolve(normalize(parts.join('/')), normalize(n.initializer.text));
111
97
  if (!tree.exists(templatePath)) {
112
98
  return;
113
99
  }
@@ -129,10 +115,10 @@ function visitTemplates(tree, visitor) {
129
115
  });
130
116
  });
131
117
  }
132
- function visitNgModuleImports(sourceFile, callback) {
118
+ export function visitNgModuleImports(sourceFile, callback) {
133
119
  visitNgModuleProperty(sourceFile, callback, 'imports');
134
120
  }
135
- function visitNgModuleExports(sourceFile, callback) {
121
+ export function visitNgModuleExports(sourceFile, callback) {
136
122
  visitNgModuleProperty(sourceFile, callback, 'exports');
137
123
  }
138
124
  function visitNgModuleProperty(sourceFile, callback, property) {
@@ -149,13 +135,13 @@ function visitNgModuleProperty(sourceFile, callback, property) {
149
135
  });
150
136
  });
151
137
  }
152
- function visitComponents(sourceFile, callback) {
138
+ export function visitComponents(sourceFile, callback) {
153
139
  visitDecorator(sourceFile, 'Component', callback);
154
140
  }
155
- function visitNgModules(sourceFile, callback) {
141
+ export function visitNgModules(sourceFile, callback) {
156
142
  visitDecorator(sourceFile, 'NgModule', callback);
157
143
  }
158
- function visitDecorator(sourceFile, decoratorName, callback) {
144
+ export function visitDecorator(sourceFile, decoratorName, callback) {
159
145
  ts.forEachChild(sourceFile, function findClassDeclaration(node) {
160
146
  if (!ts.isClassDeclaration(node)) {
161
147
  ts.forEachChild(node, findClassDeclaration);
@@ -184,7 +170,7 @@ function visitDecorator(sourceFile, decoratorName, callback) {
184
170
  callback(classDeclarationNode, arg);
185
171
  });
186
172
  }
187
- function visitImportDeclaration(node, callback) {
173
+ export function visitImportDeclaration(node, callback) {
188
174
  if (ts.isImportDeclaration(node)) {
189
175
  var moduleSpecifier = node.moduleSpecifier.getText();
190
176
  var moduleName = moduleSpecifier.replaceAll('"', '').replaceAll("'", '');
@@ -194,7 +180,7 @@ function visitImportDeclaration(node, callback) {
194
180
  visitImportDeclaration(child, callback);
195
181
  });
196
182
  }
197
- function visitImportSpecifier(node, callback) {
183
+ export function visitImportSpecifier(node, callback) {
198
184
  var e_2, _a, e_3, _b;
199
185
  var importClause = node.importClause;
200
186
  if (!importClause) {
@@ -232,7 +218,7 @@ function visitImportSpecifier(node, callback) {
232
218
  finally { if (e_2) throw e_2.error; }
233
219
  }
234
220
  }
235
- function visitTypeReference(node, callback) {
221
+ export function visitTypeReference(node, callback) {
236
222
  if (ts.isTypeReferenceNode(node)) {
237
223
  callback(node);
238
224
  }
@@ -240,7 +226,7 @@ function visitTypeReference(node, callback) {
240
226
  visitTypeReference(child, callback);
241
227
  });
242
228
  }
243
- function visitTypeLiteral(node, callback) {
229
+ export function visitTypeLiteral(node, callback) {
244
230
  if (ts.isTypeLiteralNode(node)) {
245
231
  callback(node);
246
232
  }
@@ -248,7 +234,7 @@ function visitTypeLiteral(node, callback) {
248
234
  visitTypeLiteral(child, callback);
249
235
  });
250
236
  }
251
- function visitCallExpression(node, callback) {
237
+ export function visitCallExpression(node, callback) {
252
238
  if (ts.isCallExpression(node)) {
253
239
  callback(node);
254
240
  }
@@ -1 +1 @@
1
- {"version":3,"file":"visitors.js","sourceRoot":"","sources":["../../../../../modules/entity/schematics-core/utility/visitors.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAIA,gDAcC;AAED,wCAoEC;AAED,oDAQC;AAED,oDAQC;AA0BD,0CAQC;AAED,wCAQC;AAED,wCA4CC;AAED,wDAiBC;AAED,oDAoBC;AAED,gDAWC;AAED,4CAWC;AAED,kDAWC;AAtRD,+BAAiC;AACjC,6CAA0D;AAG1D,SAAgB,kBAAkB,CAChC,IAAU,EACV,OAIuB;;IAEvB,IAAI,MAAM,GAAuB,SAAS,CAAC;;QAC3C,KAAyB,IAAA,KAAA,SAAA,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAA,gBAAA,4BAAE,CAAC;YAAvC,IAAM,UAAU,WAAA;YACnB,MAAM,GAAG,OAAO,CAAC,UAAU,EAAE,IAAI,EAAE,MAAM,CAAC,CAAC;QAC7C,CAAC;;;;;;;;;IAED,OAAO,MAAM,CAAC;AAChB,CAAC;AAED,SAAgB,cAAc,CAC5B,IAAU,EACV,OAQS;IAET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C;IACvC,CAAC,CAAC,CAAC;AACL,CAAC;AAED,SAAU,KAAK,CAAC,SAAmB;;;;;;;gBACd,KAAA,SAAA,SAAS,CAAC,QAAQ,CAAA;;;;gBAA1B,IAAI;qBACT,CAAA,IAAI,CAAC,QAAQ,CAAC,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAA,EAA/C,wBAA+C;gBAC3C,KAAK,GAAG,SAAS,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;qBAC/B,KAAK,EAAL,wBAAK;gBACD,OAAO,GAAG,KAAK,CAAC,OAAO,CAAC;gBACxB,MAAM,GAAG,EAAE,CAAC,gBAAgB,CAChC,KAAK,CAAC,IAAI,EACV,OAAO,CAAC,QAAQ,EAAE,CAAC,OAAO,CAAC,SAAS,EAAE,EAAE,CAAC,EACzC,EAAE,CAAC,YAAY,CAAC,MAAM,EACtB,IAAI,CACL,CAAC;gBACF,qBAAM,MAAM,EAAA;;gBAAZ,SAAY,CAAC;;;;;;;;;;;;;;;;;;gBAKA,KAAA,SAAA,SAAS,CAAC,OAAO,CAAA;;;;gBAAzB,IAAI;gBACb,IAAI,IAAI,KAAK,cAAc,EAAE,CAAC;oBAC5B,yBAAS;gBACX,CAAC;gBAED,sBAAA,SAAO,KAAK,CAAC,SAAS,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC,CAAA,EAAA;;gBAAjC,SAAiC,CAAC;;;;;;;;;;;;;;;;;;;CAErC","sourcesContent":["import * as ts from 'typescript';\nimport { normalize, resolve } from '@angular-devkit/core';\nimport { Tree, DirEntry } from '@angular-devkit/schematics';\n\nexport function visitTSSourceFiles<Result = void>(\n tree: Tree,\n visitor: (\n sourceFile: ts.SourceFile,\n tree: Tree,\n result?: Result\n ) => Result | undefined\n): Result | undefined {\n let result: Result | undefined = undefined;\n for (const sourceFile of visit(tree.root)) {\n result = visitor(sourceFile, tree, result);\n }\n\n return result;\n}\n\nexport function visitTemplates(\n tree: Tree,\n visitor: (\n template: {\n fileName: string;\n content: string;\n inline: boolean;\n start: number;\n },\n tree: Tree\n ) => void\n): void {\n visitTSSourceFiles(tree, (source) => {\n visitComponents(source, (_, decoratorExpressionNode) => {\n ts.forEachChild(decoratorExpressionNode, function findTemplates(n) {\n if (ts.isPropertyAssignment(n) && ts.isIdentifier(n.name)) {\n if (\n n.name.text === 'template' &&\n ts.isStringLiteralLike(n.initializer)\n ) {\n // Need to add an offset of one to the start because the template quotes are\n // not part of the template content.\n const templateStartIdx = n.initializer.getStart() + 1;\n visitor(\n {\n fileName: source.fileName,\n content: n.initializer.text,\n inline: true,\n start: templateStartIdx,\n },\n tree\n );\n return;\n } else if (\n n.name.text === 'templateUrl' &&\n ts.isStringLiteralLike(n.initializer)\n ) {\n const parts = normalize(source.fileName).split('/').slice(0, -1);\n const templatePath = resolve(\n normalize(parts.join('/')),\n normalize(n.initializer.text)\n );\n if (!tree.exists(templatePath)) {\n return;\n }\n\n const fileContent = tree.read(templatePath);\n if (!fileContent) {\n return;\n }\n\n visitor(\n {\n fileName: templatePath,\n content: fileContent.toString(),\n inline: false,\n start: 0,\n },\n tree\n );\n return;\n }\n }\n\n ts.forEachChild(n, findTemplates);\n });\n });\n });\n}\n\nexport function visitNgModuleImports(\n sourceFile: ts.SourceFile,\n callback: (\n importNode: ts.PropertyAssignment,\n elementExpressions: ts.NodeArray<ts.Expression>\n ) => void\n) {\n visitNgModuleProperty(sourceFile, callback, 'imports');\n}\n\nexport function visitNgModuleExports(\n sourceFile: ts.SourceFile,\n callback: (\n exportNode: ts.PropertyAssignment,\n elementExpressions: ts.NodeArray<ts.Expression>\n ) => void\n) {\n visitNgModuleProperty(sourceFile, callback, 'exports');\n}\n\nfunction visitNgModuleProperty(\n sourceFile: ts.SourceFile,\n callback: (\n nodes: ts.PropertyAssignment,\n elementExpressions: ts.NodeArray<ts.Expression>\n ) => void,\n property: string\n) {\n visitNgModules(sourceFile, (_, decoratorExpressionNode) => {\n ts.forEachChild(decoratorExpressionNode, function findTemplates(n) {\n if (\n ts.isPropertyAssignment(n) &&\n ts.isIdentifier(n.name) &&\n n.name.text === property &&\n ts.isArrayLiteralExpression(n.initializer)\n ) {\n callback(n, n.initializer.elements);\n return;\n }\n\n ts.forEachChild(n, findTemplates);\n });\n });\n}\nexport function visitComponents(\n sourceFile: ts.SourceFile,\n callback: (\n classDeclarationNode: ts.ClassDeclaration,\n decoratorExpressionNode: ts.ObjectLiteralExpression\n ) => void\n) {\n visitDecorator(sourceFile, 'Component', callback);\n}\n\nexport function visitNgModules(\n sourceFile: ts.SourceFile,\n callback: (\n classDeclarationNode: ts.ClassDeclaration,\n decoratorExpressionNode: ts.ObjectLiteralExpression\n ) => void\n) {\n visitDecorator(sourceFile, 'NgModule', callback);\n}\n\nexport function visitDecorator(\n sourceFile: ts.SourceFile,\n decoratorName: string,\n callback: (\n classDeclarationNode: ts.ClassDeclaration,\n decoratorExpressionNode: ts.ObjectLiteralExpression\n ) => void\n) {\n ts.forEachChild(sourceFile, function findClassDeclaration(node) {\n if (!ts.isClassDeclaration(node)) {\n ts.forEachChild(node, findClassDeclaration);\n }\n\n const classDeclarationNode = node as ts.ClassDeclaration;\n const decorators = ts.getDecorators(classDeclarationNode);\n\n if (!decorators || !decorators.length) {\n return;\n }\n\n const componentDecorator = decorators.find((d) => {\n return (\n ts.isCallExpression(d.expression) &&\n ts.isIdentifier(d.expression.expression) &&\n d.expression.expression.text === decoratorName\n );\n });\n\n if (!componentDecorator) {\n return;\n }\n\n const { expression } = componentDecorator;\n if (!ts.isCallExpression(expression)) {\n return;\n }\n\n const [arg] = expression.arguments;\n if (!arg || !ts.isObjectLiteralExpression(arg)) {\n return;\n }\n\n callback(classDeclarationNode, arg);\n });\n}\n\nexport function visitImportDeclaration(\n node: ts.Node,\n callback: (\n importDeclaration: ts.ImportDeclaration,\n moduleName?: string\n ) => void\n) {\n if (ts.isImportDeclaration(node)) {\n const moduleSpecifier = node.moduleSpecifier.getText();\n const moduleName = moduleSpecifier.replaceAll('\"', '').replaceAll(\"'\", '');\n\n callback(node, moduleName);\n }\n\n ts.forEachChild(node, (child) => {\n visitImportDeclaration(child, callback);\n });\n}\n\nexport function visitImportSpecifier(\n node: ts.ImportDeclaration,\n callback: (importSpecifier: ts.ImportSpecifier) => void\n) {\n const { importClause } = node;\n if (!importClause) {\n return;\n }\n\n const importClauseChildren = importClause.getChildren();\n for (const namedImport of importClauseChildren) {\n if (ts.isNamedImports(namedImport)) {\n const namedImportChildren = namedImport.elements;\n for (const importSpecifier of namedImportChildren) {\n if (ts.isImportSpecifier(importSpecifier)) {\n callback(importSpecifier);\n }\n }\n }\n }\n}\n\nexport function visitTypeReference(\n node: ts.Node,\n callback: (typeReference: ts.TypeReferenceNode) => void\n) {\n if (ts.isTypeReferenceNode(node)) {\n callback(node);\n }\n\n ts.forEachChild(node, (child) => {\n visitTypeReference(child, callback);\n });\n}\n\nexport function visitTypeLiteral(\n node: ts.Node,\n callback: (typeLiteral: ts.TypeLiteralNode) => void\n) {\n if (ts.isTypeLiteralNode(node)) {\n callback(node);\n }\n\n ts.forEachChild(node, (child) => {\n visitTypeLiteral(child, callback);\n });\n}\n\nexport function visitCallExpression(\n node: ts.Node,\n callback: (callExpression: ts.CallExpression) => void\n) {\n if (ts.isCallExpression(node)) {\n callback(node);\n }\n\n ts.forEachChild(node, (child) => {\n visitCallExpression(child, callback);\n });\n}\n\nfunction* visit(directory: DirEntry): IterableIterator<ts.SourceFile> {\n for (const path of directory.subfiles) {\n if (path.endsWith('.ts') && !path.endsWith('.d.ts')) {\n const entry = directory.file(path);\n if (entry) {\n const content = entry.content;\n const source = ts.createSourceFile(\n entry.path,\n content.toString().replace(/^\\uFEFF/, ''),\n ts.ScriptTarget.Latest,\n true\n );\n yield source;\n }\n }\n }\n\n for (const path of directory.subdirs) {\n if (path === 'node_modules') {\n continue;\n }\n\n yield* visit(directory.dir(path));\n }\n}\n"]}
1
+ {"version":3,"file":"visitors.js","sourceRoot":"","sources":["../../../../../modules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BAAZ,SAAY,CAAC;;;;;;;;;;;;;;;;;;gBAKA,KAAA,SAAA,SAAS,CAAC,OAAO,CAAA;;;;gBAAzB,IAAI;gBACb,IAAI,IAAI,KAAK,cAAc,EAAE,CAAC;oBAC5B,yBAAS;gBACX,CAAC;gBAED,sBAAA,SAAO,KAAK,CAAC,SAAS,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC,CAAA,EAAA;;gBAAjC,SAAiC,CAAC;;;;;;;;;;;;;;;;;;;CAErC","sourcesContent":["import * as ts from 'typescript';\nimport { normalize, resolve } from '@angular-devkit/core';\nimport { Tree, DirEntry } from '@angular-devkit/schematics';\n\nexport function visitTSSourceFiles<Result = void>(\n tree: Tree,\n visitor: (\n sourceFile: ts.SourceFile,\n tree: Tree,\n result?: Result\n ) => Result | undefined\n): Result | undefined {\n let result: Result | undefined = undefined;\n for (const sourceFile of visit(tree.root)) {\n result = visitor(sourceFile, tree, result);\n }\n\n return result;\n}\n\nexport function visitTemplates(\n tree: Tree,\n visitor: (\n template: {\n fileName: string;\n content: string;\n inline: boolean;\n start: number;\n },\n tree: Tree\n ) => void\n): void {\n visitTSSourceFiles(tree, (source) => {\n visitComponents(source, (_, decoratorExpressionNode) => {\n ts.forEachChild(decoratorExpressionNode, function findTemplates(n) {\n if (ts.isPropertyAssignment(n) && ts.isIdentifier(n.name)) {\n if (\n n.name.text === 'template' &&\n ts.isStringLiteralLike(n.initializer)\n ) {\n // Need to add an offset of one to the start because the template quotes are\n // not part of the template content.\n const templateStartIdx = n.initializer.getStart() + 1;\n visitor(\n {\n fileName: source.fileName,\n content: n.initializer.text,\n inline: true,\n start: templateStartIdx,\n },\n tree\n );\n return;\n } else if (\n n.name.text === 'templateUrl' &&\n ts.isStringLiteralLike(n.initializer)\n ) {\n const parts = normalize(source.fileName).split('/').slice(0, -1);\n const templatePath = resolve(\n normalize(parts.join('/')),\n normalize(n.initializer.text)\n );\n if (!tree.exists(templatePath)) {\n return;\n }\n\n const fileContent = tree.read(templatePath);\n if (!fileContent) {\n return;\n }\n\n visitor(\n {\n fileName: templatePath,\n content: fileContent.toString(),\n inline: false,\n start: 0,\n },\n tree\n );\n return;\n }\n }\n\n ts.forEachChild(n, findTemplates);\n });\n });\n });\n}\n\nexport function visitNgModuleImports(\n sourceFile: ts.SourceFile,\n callback: (\n importNode: ts.PropertyAssignment,\n elementExpressions: ts.NodeArray<ts.Expression>\n ) => void\n) {\n visitNgModuleProperty(sourceFile, callback, 'imports');\n}\n\nexport function visitNgModuleExports(\n sourceFile: ts.SourceFile,\n callback: (\n exportNode: ts.PropertyAssignment,\n elementExpressions: ts.NodeArray<ts.Expression>\n ) => void\n) {\n visitNgModuleProperty(sourceFile, callback, 'exports');\n}\n\nfunction visitNgModuleProperty(\n sourceFile: ts.SourceFile,\n callback: (\n nodes: ts.PropertyAssignment,\n elementExpressions: ts.NodeArray<ts.Expression>\n ) => void,\n property: string\n) {\n visitNgModules(sourceFile, (_, decoratorExpressionNode) => {\n ts.forEachChild(decoratorExpressionNode, function findTemplates(n) {\n if (\n ts.isPropertyAssignment(n) &&\n ts.isIdentifier(n.name) &&\n n.name.text === property &&\n ts.isArrayLiteralExpression(n.initializer)\n ) {\n callback(n, n.initializer.elements);\n return;\n }\n\n ts.forEachChild(n, findTemplates);\n });\n });\n}\nexport function visitComponents(\n sourceFile: ts.SourceFile,\n callback: (\n classDeclarationNode: ts.ClassDeclaration,\n decoratorExpressionNode: ts.ObjectLiteralExpression\n ) => void\n) {\n visitDecorator(sourceFile, 'Component', callback);\n}\n\nexport function visitNgModules(\n sourceFile: ts.SourceFile,\n callback: (\n classDeclarationNode: ts.ClassDeclaration,\n decoratorExpressionNode: ts.ObjectLiteralExpression\n ) => void\n) {\n visitDecorator(sourceFile, 'NgModule', callback);\n}\n\nexport function visitDecorator(\n sourceFile: ts.SourceFile,\n decoratorName: string,\n callback: (\n classDeclarationNode: ts.ClassDeclaration,\n decoratorExpressionNode: ts.ObjectLiteralExpression\n ) => void\n) {\n ts.forEachChild(sourceFile, function findClassDeclaration(node) {\n if (!ts.isClassDeclaration(node)) {\n ts.forEachChild(node, findClassDeclaration);\n }\n\n const classDeclarationNode = node as ts.ClassDeclaration;\n const decorators = ts.getDecorators(classDeclarationNode);\n\n if (!decorators || !decorators.length) {\n return;\n }\n\n const componentDecorator = decorators.find((d) => {\n return (\n ts.isCallExpression(d.expression) &&\n ts.isIdentifier(d.expression.expression) &&\n d.expression.expression.text === decoratorName\n );\n });\n\n if (!componentDecorator) {\n return;\n }\n\n const { expression } = componentDecorator;\n if (!ts.isCallExpression(expression)) {\n return;\n }\n\n const [arg] = expression.arguments;\n if (!arg || !ts.isObjectLiteralExpression(arg)) {\n return;\n }\n\n callback(classDeclarationNode, arg);\n });\n}\n\nexport function visitImportDeclaration(\n node: ts.Node,\n callback: (\n importDeclaration: ts.ImportDeclaration,\n moduleName?: string\n ) => void\n) {\n if (ts.isImportDeclaration(node)) {\n const moduleSpecifier = node.moduleSpecifier.getText();\n const moduleName = moduleSpecifier.replaceAll('\"', '').replaceAll(\"'\", '');\n\n callback(node, moduleName);\n }\n\n ts.forEachChild(node, (child) => {\n visitImportDeclaration(child, callback);\n });\n}\n\nexport function visitImportSpecifier(\n node: ts.ImportDeclaration,\n callback: (importSpecifier: ts.ImportSpecifier) => void\n) {\n const { importClause } = node;\n if (!importClause) {\n return;\n }\n\n const importClauseChildren = importClause.getChildren();\n for (const namedImport of importClauseChildren) {\n if (ts.isNamedImports(namedImport)) {\n const namedImportChildren = namedImport.elements;\n for (const importSpecifier of namedImportChildren) {\n if (ts.isImportSpecifier(importSpecifier)) {\n callback(importSpecifier);\n }\n }\n }\n }\n}\n\nexport function visitTypeReference(\n node: ts.Node,\n callback: (typeReference: ts.TypeReferenceNode) => void\n) {\n if (ts.isTypeReferenceNode(node)) {\n callback(node);\n }\n\n ts.forEachChild(node, (child) => {\n visitTypeReference(child, callback);\n });\n}\n\nexport function visitTypeLiteral(\n node: ts.Node,\n callback: (typeLiteral: ts.TypeLiteralNode) => void\n) {\n if (ts.isTypeLiteralNode(node)) {\n callback(node);\n }\n\n ts.forEachChild(node, (child) => {\n visitTypeLiteral(child, callback);\n });\n}\n\nexport function visitCallExpression(\n node: ts.Node,\n callback: (callExpression: ts.CallExpression) => void\n) {\n if (ts.isCallExpression(node)) {\n callback(node);\n }\n\n ts.forEachChild(node, (child) => {\n visitCallExpression(child, callback);\n });\n}\n\nfunction* visit(directory: DirEntry): IterableIterator<ts.SourceFile> {\n for (const path of directory.subfiles) {\n if (path.endsWith('.ts') && !path.endsWith('.d.ts')) {\n const entry = directory.file(path);\n if (entry) {\n const content = entry.content;\n const source = ts.createSourceFile(\n entry.path,\n content.toString().replace(/^\\uFEFF/, ''),\n ts.ScriptTarget.Latest,\n true\n );\n yield source;\n }\n }\n }\n\n for (const path of directory.subdirs) {\n if (path === 'node_modules') {\n continue;\n }\n\n yield* visit(directory.dir(path));\n }\n}\n"]}
@@ -1,43 +1,40 @@
1
1
  import { MemoizedSelector } from '@ngrx/store';
2
- export type Comparer<T> = (a: T, b: T) => number;
3
- export type IdSelectorStr<T> = (model: T) => string;
4
- export type IdSelectorNum<T> = (model: T) => number;
5
- export type IdSelector<T> = IdSelectorStr<T> | IdSelectorNum<T>;
6
- export interface DictionaryNum<T> {
2
+
3
+ type Comparer<T> = (a: T, b: T) => number;
4
+ type IdSelectorStr<T> = (model: T) => string;
5
+ type IdSelectorNum<T> = (model: T) => number;
6
+ type IdSelector<T> = IdSelectorStr<T> | IdSelectorNum<T>;
7
+ interface DictionaryNum<T> {
7
8
  [id: number]: T | undefined;
8
9
  }
9
- export declare abstract class Dictionary<T> implements DictionaryNum<T> {
10
+ declare abstract class Dictionary<T> implements DictionaryNum<T> {
10
11
  [id: string]: T | undefined;
11
12
  }
12
- export interface UpdateStr<T> {
13
+ interface UpdateStr<T> {
13
14
  id: string;
14
15
  changes: Partial<T>;
15
16
  }
16
- export interface UpdateNum<T> {
17
+ interface UpdateNum<T> {
17
18
  id: number;
18
19
  changes: Partial<T>;
19
20
  }
20
- export type Update<T> = UpdateStr<T> | UpdateNum<T>;
21
- export type Predicate<T> = (entity: T) => boolean;
22
- export type EntityMap<T> = (entity: T) => T;
23
- export interface EntityMapOneNum<T> {
21
+ type Update<T> = UpdateStr<T> | UpdateNum<T>;
22
+ type Predicate<T> = (entity: T) => boolean;
23
+ type EntityMap<T> = (entity: T) => T;
24
+ interface EntityMapOneNum<T> {
24
25
  id: number;
25
26
  map: EntityMap<T>;
26
27
  }
27
- export interface EntityMapOneStr<T> {
28
+ interface EntityMapOneStr<T> {
28
29
  id: string;
29
30
  map: EntityMap<T>;
30
31
  }
31
- export type EntityMapOne<T> = EntityMapOneNum<T> | EntityMapOneStr<T>;
32
- export interface EntityState<T> {
32
+ type EntityMapOne<T> = EntityMapOneNum<T> | EntityMapOneStr<T>;
33
+ interface EntityState<T> {
33
34
  ids: string[] | number[];
34
35
  entities: Dictionary<T>;
35
36
  }
36
- export interface EntityDefinition<T> {
37
- selectId: IdSelector<T>;
38
- sortComparer: false | Comparer<T>;
39
- }
40
- export interface EntityStateAdapter<T> {
37
+ interface EntityStateAdapter<T> {
41
38
  addOne<S extends EntityState<T>>(entity: T, state: S): S;
42
39
  addMany<S extends EntityState<T>>(entities: T[], state: S): S;
43
40
  setAll<S extends EntityState<T>>(entities: T[], state: S): S;
@@ -56,19 +53,19 @@ export interface EntityStateAdapter<T> {
56
53
  mapOne<S extends EntityState<T>>(map: EntityMapOne<T>, state: S): S;
57
54
  map<S extends EntityState<T>>(map: EntityMap<T>, state: S): S;
58
55
  }
59
- export type EntitySelectors<T, V> = {
56
+ type EntitySelectors<T, V> = {
60
57
  selectIds: (state: V) => string[] | number[];
61
58
  selectEntities: (state: V) => Dictionary<T>;
62
59
  selectAll: (state: V) => T[];
63
60
  selectTotal: (state: V) => number;
64
61
  };
65
- export type MemoizedEntitySelectors<T, V> = {
62
+ type MemoizedEntitySelectors<T, V> = {
66
63
  selectIds: MemoizedSelector<V, string[] | number[], (entityState: EntityState<T>) => string[] | number[]>;
67
64
  selectEntities: MemoizedSelector<V, Dictionary<T>, (entityState: EntityState<T>) => Dictionary<T>>;
68
65
  selectAll: MemoizedSelector<V, T[], (entityState: EntityState<T>) => T[]>;
69
66
  selectTotal: MemoizedSelector<V, number, (entityState: EntityState<T>) => number>;
70
67
  };
71
- export interface EntityAdapter<T> extends EntityStateAdapter<T> {
68
+ interface EntityAdapter<T> extends EntityStateAdapter<T> {
72
69
  selectId: IdSelector<T>;
73
70
  sortComparer: false | Comparer<T>;
74
71
  getInitialState(): EntityState<T>;
@@ -76,3 +73,11 @@ export interface EntityAdapter<T> extends EntityStateAdapter<T> {
76
73
  getSelectors(): EntitySelectors<T, EntityState<T>>;
77
74
  getSelectors<V>(selectState: (state: V) => EntityState<T>): MemoizedEntitySelectors<T, V>;
78
75
  }
76
+
77
+ declare function createEntityAdapter<T>(options?: {
78
+ selectId?: IdSelector<T>;
79
+ sortComparer?: false | Comparer<T>;
80
+ }): EntityAdapter<T>;
81
+
82
+ export { Dictionary, createEntityAdapter };
83
+ export type { Comparer, DictionaryNum, EntityAdapter, EntityMap, EntityMapOne, EntityState, IdSelector, Predicate, Update };
package/index.d.ts DELETED
@@ -1,6 +0,0 @@
1
- /**
2
- * DO NOT EDIT
3
- *
4
- * This file is automatically generated at build
5
- */
6
- export * from './public_api';
package/public_api.d.ts DELETED
@@ -1 +0,0 @@
1
- export * from './src/index';
@@ -1,5 +0,0 @@
1
- import { Comparer, IdSelector, EntityAdapter } from './models';
2
- export declare function createEntityAdapter<T>(options?: {
3
- selectId?: IdSelector<T>;
4
- sortComparer?: false | Comparer<T>;
5
- }): EntityAdapter<T>;
@@ -1,8 +0,0 @@
1
- import { EntityState } from './models';
2
- export declare function getInitialEntityState<V>(): EntityState<V>;
3
- export declare function createInitialStateFactory<V>(): {
4
- getInitialState: {
5
- (): EntityState<V>;
6
- <S extends EntityState<V>>(additionalState: Omit<S, keyof EntityState<V>>): S;
7
- };
8
- };
package/src/index.d.ts DELETED
@@ -1,2 +0,0 @@
1
- export { createEntityAdapter } from './create_adapter';
2
- export { Comparer, Dictionary, DictionaryNum, EntityAdapter, EntityMap, EntityMapOne, EntityState, IdSelector, Predicate, Update, } from './models';
@@ -1,2 +0,0 @@
1
- import { IdSelector, Comparer, EntityStateAdapter } from './models';
2
- export declare function createSortedStateAdapter<T>(selectId: IdSelector<T>, sort: Comparer<T>): EntityStateAdapter<T>;
@@ -1,7 +0,0 @@
1
- import { EntityState } from './models';
2
- export declare enum DidMutate {
3
- EntitiesOnly = 0,
4
- Both = 1,
5
- None = 2
6
- }
7
- export declare function createStateOperator<V, R>(mutator: (arg: R, state: EntityState<V>) => DidMutate): EntityState<V>;
@@ -1,7 +0,0 @@
1
- import { EntityState, EntitySelectors, MemoizedEntitySelectors } from './models';
2
- export declare function createSelectorsFactory<T>(): {
3
- getSelectors: {
4
- (): EntitySelectors<T, EntityState<T>>;
5
- <V>(selectState: (state: V) => EntityState<T>): MemoizedEntitySelectors<T, V>;
6
- };
7
- };
@@ -1,2 +0,0 @@
1
- import { EntityStateAdapter, IdSelector } from './models';
2
- export declare function createUnsortedStateAdapter<T>(selectId: IdSelector<T>): EntityStateAdapter<T>;
package/src/utils.d.ts DELETED
@@ -1,2 +0,0 @@
1
- import { IdSelector } from './models';
2
- export declare function selectIdValue<T>(entity: T, selectId: IdSelector<T>): string | number;