@o3r/configuration 10.3.0-prerelease.4 → 10.3.0-prerelease.41

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/README.md +2 -2
  2. package/collection.json +6 -0
  3. package/core/configurable.d.ts +1 -1
  4. package/core/configurable.d.ts.map +1 -1
  5. package/esm2022/core/configurable.mjs +1 -1
  6. package/esm2022/devkit/configuration-devtools.console.service.mjs +3 -3
  7. package/esm2022/devkit/configuration-devtools.message.service.mjs +3 -3
  8. package/esm2022/devkit/configuration-devtools.module.mjs +4 -4
  9. package/esm2022/devkit/configuration-devtools.service.mjs +3 -3
  10. package/esm2022/rules-engine/configuration.handler-action.mjs +3 -3
  11. package/esm2022/rules-engine/configuration.rules-engine.module.mjs +4 -4
  12. package/esm2022/services/configuration/configuration.base.module.mjs +4 -4
  13. package/esm2022/services/configuration/configuration.base.service.mjs +3 -3
  14. package/esm2022/stores/config-override/config-override.module.mjs +4 -4
  15. package/esm2022/stores/configuration/configuration.module.mjs +4 -4
  16. package/esm2022/tools/configuration.decorators.mjs +35 -0
  17. package/esm2022/tools/configuration.signal.mjs +19 -0
  18. package/esm2022/tools/index.mjs +3 -2
  19. package/fesm2022/o3r-configuration-rules-engine.mjs +7 -7
  20. package/fesm2022/o3r-configuration.mjs +74 -48
  21. package/fesm2022/o3r-configuration.mjs.map +1 -1
  22. package/migration.json +10 -0
  23. package/package.json +7 -7
  24. package/schematics/configuration-to-component/index.d.ts.map +1 -1
  25. package/schematics/configuration-to-component/index.js +93 -13
  26. package/schematics/configuration-to-component/schema.d.ts +2 -0
  27. package/schematics/configuration-to-component/schema.d.ts.map +1 -1
  28. package/schematics/configuration-to-component/schema.json +5 -0
  29. package/schematics/ng-update/v10-3/index.d.ts +6 -0
  30. package/schematics/ng-update/v10-3/index.d.ts.map +1 -0
  31. package/schematics/ng-update/v10-3/index.js +21 -0
  32. package/schematics/use-config-signal/index.d.ts +8 -0
  33. package/schematics/use-config-signal/index.d.ts.map +1 -0
  34. package/schematics/use-config-signal/index.js +95 -0
  35. package/schematics/use-config-signal/schema.d.ts +8 -0
  36. package/schematics/use-config-signal/schema.d.ts.map +1 -0
  37. package/schematics/use-config-signal/schema.js +3 -0
  38. package/schematics/use-config-signal/schema.json +21 -0
  39. package/tools/configuration.decorators.d.ts +10 -0
  40. package/tools/configuration.decorators.d.ts.map +1 -0
  41. package/tools/configuration.signal.d.ts +16 -0
  42. package/tools/configuration.signal.d.ts.map +1 -0
  43. package/tools/index.d.ts +2 -1
  44. package/tools/index.d.ts.map +1 -1
  45. package/esm2022/tools/configuration.decorator.mjs +0 -26
  46. package/tools/configuration.decorator.d.ts +0 -5
  47. package/tools/configuration.decorator.d.ts.map +0 -1
@@ -0,0 +1,21 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.updateV10_3 = void 0;
4
+ const schematics_1 = require("@o3r/schematics");
5
+ const configObserverRegExp = /\bConfigObserver\b/g;
6
+ function updateV10_3Fn() {
7
+ return (tree) => {
8
+ const files = (0, schematics_1.findFilesInTree)(tree.getDir(''), (filePath) => /.*\.ts/.test(filePath));
9
+ files.forEach(({ content, path }) => {
10
+ const str = content.toString();
11
+ if (configObserverRegExp.test(str)) {
12
+ tree.overwrite(path, str.replaceAll(configObserverRegExp, 'O3rConfig'));
13
+ }
14
+ });
15
+ };
16
+ }
17
+ /**
18
+ * Update of Otter configuration V10.3
19
+ */
20
+ exports.updateV10_3 = (0, schematics_1.createSchematicWithMetricsIfInstalled)(updateV10_3Fn);
21
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1,8 @@
1
+ import { type Rule } from '@angular-devkit/schematics';
2
+ import type { NgUseConfigSignalSchematicsSchema } from './schema';
3
+ /**
4
+ * Migrate from configuration observable to signal
5
+ * @param options
6
+ */
7
+ export declare const ngUseConfigSignal: (options: NgUseConfigSignalSchematicsSchema) => Rule;
8
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../schematics/use-config-signal/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAGL,KAAK,IAAI,EAEV,MAAM,4BAA4B,CAAC;AAYpC,OAAO,KAAK,EAAE,iCAAiC,EAAE,MAAM,UAAU,CAAC;AAgIlE;;;GAGG;AACH,eAAO,MAAM,iBAAiB,sDAA6D,CAAC"}
@@ -0,0 +1,95 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.ngUseConfigSignal = void 0;
4
+ const schematics_1 = require("@angular-devkit/schematics");
5
+ const schematics_2 = require("@o3r/schematics");
6
+ const ts = require("typescript");
7
+ const configObserverRegexp = /.*new ConfigurationObserver<(?<configName>\w+)>\(\s*(?<configId>\w+),\s*(?<defaultConfig>\w+)(,\s*\w+)?\s*\);/;
8
+ function ngUseConfigSignalFn(options) {
9
+ return (0, schematics_1.chain)([
10
+ (0, schematics_2.addImportsRule)(options.path, [
11
+ {
12
+ from: '@angular/core',
13
+ importNames: [
14
+ 'inject',
15
+ 'input'
16
+ ]
17
+ },
18
+ {
19
+ from: '@angular/core/rxjs-interop',
20
+ importNames: [
21
+ 'toObservable'
22
+ ]
23
+ },
24
+ {
25
+ from: '@o3r/configuration',
26
+ importNames: [
27
+ 'configSignal',
28
+ 'O3rConfig',
29
+ 'ConfigurationBaseService',
30
+ 'DynamicConfigurableWithSignal'
31
+ ]
32
+ }
33
+ ]),
34
+ (tree) => {
35
+ const content = tree.readText(options.path);
36
+ // Retrieve all info
37
+ const match = content.match(configObserverRegexp);
38
+ const { configName, configId, defaultConfig } = match?.groups || {};
39
+ if (!configName || !configId || !defaultConfig) {
40
+ throw new schematics_2.O3rCliError(`Configuration name, id or default value not found in ${options.path}.\nCannot migrate to signal based configuration.`);
41
+ }
42
+ const componentSourceFile = ts.createSourceFile(options.path, content, ts.ScriptTarget.ES2020, true);
43
+ const result = ts.transform(componentSourceFile, [
44
+ (0, schematics_2.addInterfaceToClassTransformerFactory)(`DynamicConfigurableWithSignal<${configName}>`, schematics_2.isO3rClassComponent, new Set(['DynamicConfigurable'])),
45
+ (ctx) => (rootNode) => {
46
+ const { factory } = ctx;
47
+ const visit = (node) => {
48
+ if (ts.isClassDeclaration(node) && (0, schematics_2.isO3rClassComponent)(node)) {
49
+ const propertiesToAdd = (0, schematics_2.generateClassElementsFromString)(`
50
+ private readonly configurationService = inject(ConfigurationBaseService);
51
+
52
+ public config = input<Partial<${configName}>>();
53
+
54
+ @O3rConfig()
55
+ public readonly configSignal = configSignal(this.config, ${configId}, ${defaultConfig}, this.configurationService);
56
+
57
+ public readonly config$ = toObservable(this.configSignal);`);
58
+ const newMembers = propertiesToAdd.concat(node.members.filter((member) => !member.name
59
+ || (ts.isIdentifier(member.name)
60
+ && member.name.escapedText !== 'config$'
61
+ && member.name.escapedText !== 'config'
62
+ && member.name.escapedText !== 'dynamicConfig$')));
63
+ (0, schematics_2.addCommentsOnClassProperties)(newMembers, {
64
+ config: 'Input configuration to override the default configuration of the component',
65
+ configSignal: 'Configuration signal based on the input and the stored configuration',
66
+ config$: '@deprecated use configSignal instead'
67
+ });
68
+ return factory.updateClassDeclaration(node, ts.getModifiers(node), node.name, node.typeParameters, node.heritageClauses, newMembers);
69
+ }
70
+ return ts.visitEachChild(node, visit, ctx);
71
+ };
72
+ return ts.visitNode(rootNode, visit);
73
+ }
74
+ ]);
75
+ const printer = ts.createPrinter({
76
+ removeComments: false,
77
+ newLine: ts.NewLineKind.LineFeed
78
+ });
79
+ let newContent = printer.printFile(result.transformed[0]);
80
+ newContent = newContent
81
+ .replace(/this\.dynamicConfig\$\.next\(this.config\);/, '// TODO remove the ngOnChanges if empty')
82
+ .replace(configObserverRegexp, '')
83
+ .replace(/this\.config\$\s*=\s*this\.dynamicConfig\$\s*\.asObservable\(\);/, '');
84
+ tree.overwrite(options.path, newContent);
85
+ return tree;
86
+ },
87
+ options.skipLinter ? (0, schematics_1.noop)() : (0, schematics_2.applyEsLintFix)()
88
+ ]);
89
+ }
90
+ /**
91
+ * Migrate from configuration observable to signal
92
+ * @param options
93
+ */
94
+ exports.ngUseConfigSignal = (0, schematics_2.createSchematicWithMetricsIfInstalled)(ngUseConfigSignalFn);
95
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1,8 @@
1
+ import type { SchematicOptionObject } from '@o3r/schematics';
2
+ export interface NgUseConfigSignalSchematicsSchema extends SchematicOptionObject {
3
+ /** Path to the component */
4
+ path: string;
5
+ /** Skip the linter process */
6
+ skipLinter: boolean;
7
+ }
8
+ //# sourceMappingURL=schema.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"schema.d.ts","sourceRoot":"","sources":["../../../schematics/use-config-signal/schema.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,iBAAiB,CAAC;AAE7D,MAAM,WAAW,iCAAkC,SAAQ,qBAAqB;IAC9E,4BAA4B;IAC5B,IAAI,EAAE,MAAM,CAAC;IAEb,8BAA8B;IAC9B,UAAU,EAAE,OAAO,CAAC;CACrB"}
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ //# sourceMappingURL=schema.js.map
@@ -0,0 +1,21 @@
1
+ {
2
+ "$schema": "http://json-schema.org/draft-07/schema",
3
+ "$id": "NgUseConfigSignalSchematicsSchema",
4
+ "title": "Migrate from configuration observable to signal",
5
+ "description": "Migrate from configuration observable to signal",
6
+ "properties": {
7
+ "path": {
8
+ "type": "string",
9
+ "description": "Path to the component"
10
+ },
11
+ "skipLinter": {
12
+ "type": "boolean",
13
+ "description": "Skip the linter process",
14
+ "default": false
15
+ }
16
+ },
17
+ "additionalProperties": true,
18
+ "required": [
19
+ "path"
20
+ ]
21
+ }
@@ -0,0 +1,10 @@
1
+ /**
2
+ * Decorator to identify the configuration observer
3
+ * @deprecated please use O3rConfig, will be removed in v12
4
+ */
5
+ export declare function ConfigObserver(): (target: any, key: string) => void;
6
+ /**
7
+ * Decorator to identify the component's configuration
8
+ */
9
+ export declare function O3rConfig(): (target: any, key: string) => void;
10
+ //# sourceMappingURL=configuration.decorators.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"configuration.decorators.d.ts","sourceRoot":"","sources":["../../src/tools/configuration.decorators.ts"],"names":[],"mappings":"AAwBA;;;GAGG;AAEH,wBAAgB,cAAc,uCAE7B;AAED;;GAEG;AAEH,wBAAgB,SAAS,uCAExB"}
@@ -0,0 +1,16 @@
1
+ import type { InputSignal, Signal } from '@angular/core';
2
+ import type { Configuration } from '@o3r/core';
3
+ import type { ConfigurationBaseService } from '../services';
4
+ /** Configuration signal */
5
+ export type ConfigurationSignal<T> = Signal<T> & {
6
+ configId: string;
7
+ };
8
+ /**
9
+ * Get a configuration signal
10
+ * @param configInput
11
+ * @param configId
12
+ * @param defaultConfig
13
+ * @param configurationService
14
+ */
15
+ export declare const configSignal: <T extends Configuration>(configInput: InputSignal<Partial<T> | undefined>, configId: string, defaultConfig: T, configurationService?: ConfigurationBaseService | null) => ConfigurationSignal<T>;
16
+ //# sourceMappingURL=configuration.signal.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"configuration.signal.d.ts","sourceRoot":"","sources":["../../src/tools/configuration.signal.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,EAAE,MAAM,eAAe,CAAC;AAEzD,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,WAAW,CAAC;AAG/C,OAAO,KAAK,EAAE,wBAAwB,EAAE,MAAM,aAAa,CAAC;AAE5D,2BAA2B;AAC3B,MAAM,MAAM,mBAAmB,CAAC,CAAC,IAAI,MAAM,CAAC,CAAC,CAAC,GAAG;IAAE,QAAQ,EAAE,MAAM,CAAA;CAAE,CAAC;AAEtE;;;;;;GAMG;AACH,eAAO,MAAM,YAAY,yCACV,YAAY,QAAQ,CAAC,CAAC,GAAG,SAAS,CAAC,YACtC,MAAM,iBACD,CAAC,yBACO,wBAAwB,GAAG,IAAI,KACrD,oBAAoB,CAAC,CAcvB,CAAC"}
package/tools/index.d.ts CHANGED
@@ -1,3 +1,4 @@
1
- export * from './configuration.decorator';
1
+ export * from './configuration.decorators';
2
2
  export * from './configuration.observer';
3
+ export * from './configuration.signal';
3
4
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/tools/index.ts"],"names":[],"mappings":"AAAA,cAAc,2BAA2B,CAAC;AAC1C,cAAc,0BAA0B,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/tools/index.ts"],"names":[],"mappings":"AAAA,cAAc,4BAA4B,CAAC;AAC3C,cAAc,0BAA0B,CAAC;AACzC,cAAc,wBAAwB,CAAC"}
@@ -1,26 +0,0 @@
1
- import { otterComponentInfoPropertyName } from '@o3r/core';
2
- /**
3
- * Decorator to identify the configuration observer
4
- */
5
- // eslint-disable-next-line @typescript-eslint/naming-convention
6
- export function ConfigObserver() {
7
- return (target, key) => {
8
- const privateField = `_${key}`;
9
- if (delete target[key]) {
10
- Object.defineProperty(target, key, {
11
- get: function () {
12
- return this[privateField];
13
- },
14
- set: function (value) {
15
- this[privateField] = value;
16
- if (this[otterComponentInfoPropertyName]) {
17
- this[otterComponentInfoPropertyName].configId = this[privateField].configId;
18
- }
19
- },
20
- enumerable: true,
21
- configurable: true
22
- });
23
- }
24
- };
25
- }
26
- //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiY29uZmlndXJhdGlvbi5kZWNvcmF0b3IuanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi8uLi9zcmMvdG9vbHMvY29uZmlndXJhdGlvbi5kZWNvcmF0b3IudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IkFBQUEsT0FBTyxFQUFpQiw4QkFBOEIsRUFBRSxNQUFNLFdB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bnRpZnkgdGhlIGNvbmZpZ3VyYXRpb24gb2JzZXJ2ZXJcbiAqL1xuLy8gZXNsaW50LWRpc2FibGUtbmV4dC1saW5lIEB0eXBlc2NyaXB0LWVzbGludC9uYW1pbmctY29udmVudGlvblxuZXhwb3J0IGZ1bmN0aW9uIENvbmZpZ09ic2VydmVyKCkge1xuICByZXR1cm4gKHRhcmdldDogYW55LCBrZXk6IHN0cmluZykgPT4ge1xuICAgIGNvbnN0IHByaXZhdGVGaWVsZCA9IGBfJHtrZXl9YDtcblxuICAgIGlmIChkZWxldGUgdGFyZ2V0W2tleV0pIHtcbiAgICAgIE9iamVjdC5kZWZpbmVQcm9wZXJ0eSh0YXJnZXQsIGtleSwge1xuICAgICAgICBnZXQ6IGZ1bmN0aW9uICh0aGlzOiBhbnkpIHtcbiAgICAgICAgICByZXR1cm4gdGhpc1twcml2YXRlRmllbGRdO1xuICAgICAgICB9LFxuICAgICAgICBzZXQ6IGZ1bmN0aW9uICh0aGlzOiBhbnksIHZhbHVlOiBSZWNvcmQ8c3RyaW5nLCB1bmtub3duPikge1xuICAgICAgICAgIHRoaXNbcHJpdmF0ZUZpZWxkXSA9IHZhbHVlO1xuICAgICAgICAgIGlmICh0aGlzW290dGVyQ29tcG9uZW50SW5mb1Byb3BlcnR5TmFtZV0pIHtcbiAgICAgICAgICAgIHRoaXNbb3R0ZXJDb21wb25lbnRJbmZvUHJvcGVydHlOYW1lXS5jb25maWdJZCA9ICh0aGlzW3ByaXZhdGVGaWVsZF0gYXMgQ29uZmlndXJhdGlvbk9ic2VydmVyPENvbmZpZ3VyYXRpb24+KS5jb25maWdJZDtcbiAgICAgICAgICB9XG4gICAgICAgIH0sXG4gICAgICAgIGVudW1lcmFibGU6IHRydWUsXG4gICAgICAgIGNvbmZpZ3VyYWJsZTogdHJ1ZVxuICAgICAgfSk7XG4gICAgfVxuICB9O1xufVxuIl19
@@ -1,5 +0,0 @@
1
- /**
2
- * Decorator to identify the configuration observer
3
- */
4
- export declare function ConfigObserver(): (target: any, key: string) => void;
5
- //# sourceMappingURL=configuration.decorator.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"configuration.decorator.d.ts","sourceRoot":"","sources":["../../src/tools/configuration.decorator.ts"],"names":[],"mappings":"AAGA;;GAEG;AAEH,wBAAgB,cAAc,aACZ,GAAG,OAAO,MAAM,UAmBjC"}