@quandis/qbo4.configuration 4.0.1-CI-20240328-123132

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/license.js ADDED
@@ -0,0 +1,41 @@
1
+ import { promises as fs } from 'fs';
2
+ // import { glob } from 'glob';
3
+ import globModule from 'glob'
4
+ import { promisify } from 'util';
5
+
6
+ const globPromise = promisify(globModule);
7
+
8
+ const licenseFilesPattern = './wwwroot/js/*.min.*.LICENSE.txt';
9
+ const outputLicenseFile = './wwwroot/js/license.txt';
10
+
11
+ const deleteFile = async (file) => {
12
+ try {
13
+ await fs.unlink(file);
14
+ console.log(`Deleted file: ${file}`);
15
+ } catch (unlinkErr) {
16
+ console.error(`Error deleting file: ${file}`, unlinkErr);
17
+ }
18
+ };
19
+
20
+ const aggregateLicenses = async () => {
21
+ try {
22
+ const files = await globPromise(licenseFilesPattern);
23
+ console.log(files);
24
+ let aggregatedLicenses = '';
25
+ for (let file of files) {
26
+ const licenseContent = await fs.readFile(file, 'utf8');
27
+ aggregatedLicenses += licenseContent + '\n\n';
28
+
29
+ // Delete the file after its content has been added to the aggregation
30
+ console.log(`Deleting file: ${file}`);
31
+ await deleteFile(file);
32
+ }
33
+
34
+ await fs.writeFile(outputLicenseFile, aggregatedLicenses.trim());
35
+ console.log('Aggregated license file created:', outputLicenseFile);
36
+ } catch (err) {
37
+ console.error('An error occurred:', err);
38
+ }
39
+ };
40
+
41
+ await aggregateLicenses();
package/package.json ADDED
@@ -0,0 +1,44 @@
1
+ {
2
+ "name": "@quandis/qbo4.configuration",
3
+ "version": "4.0.1-CI-20240328-123132",
4
+ "type": "module",
5
+ "types": "./src/Program.d.ts",
6
+ "exports": {
7
+ ".": {
8
+ "import": "./src/Program.js"
9
+ }
10
+ },
11
+ "files": [
12
+ "wwwroot/js/",
13
+ "src/"
14
+ ],
15
+ "dependencies": {
16
+ "bootstrap": "^5.3.3",
17
+ "lit": "^3.1.2",
18
+ "reflect-metadata": "^0.2.1",
19
+ "tsyringe": "^4.8.0"
20
+ },
21
+ "devDependencies": {
22
+ "@fullhuman/postcss-purgecss": "^5.0.0",
23
+ "autoprefixer": "^10.4.18",
24
+ "clean-css": "^5.3.3",
25
+ "glob": "^10.3.10",
26
+ "mini-css-extract-plugin": "^2.8.1",
27
+ "postcss-cli": "^11.0.0",
28
+ "postcss-loader": "^8.1.1",
29
+ "sass": "^1.72.0",
30
+ "sass-loader": "^14.1.1",
31
+ "style-loader": "^3.3.4",
32
+ "typescript": "^5.4.2",
33
+ "webpack": "^5.90.3",
34
+ "webpack-cli": "^5.1.4",
35
+ "webpack-merge": "^5.10.0"
36
+ },
37
+ "scripts": {
38
+ "sass": "sass scss/:wwwroot/css && node cssshake.js",
39
+ "postcss": "postcss \"wwwroot/css/*.css\" --use autoprefixer --replace",
40
+ "packdev": "webpack --config webpack.dev.js --no-color",
41
+ "packprod": "webpack --config webpack.prod.js --no-color",
42
+ "build": "npm run sass && tsc && npm run packdev && npm run packprod && del *.tgz && npm pack && ren *.tgz qbo4.configuration.tgz"
43
+ }
44
+ }
package/readme.md ADDED
@@ -0,0 +1,11 @@
1
+ 
2
+
3
+ # Node Setup
4
+
5
+ # Setup
6
+
7
+ ```bash
8
+ npm install lit tsyringe reflect-metadata
9
+ npm install webpack webpack-cli webpack-merge clean-webpack-plugin css-loader mini-css-extract-plugin autoprefixer copy-webpack-plugin --save-dev
10
+ ```
11
+
@@ -0,0 +1,35 @@
1
+ import { ConfigData, IConfiguration, IConfigurationSource } from "./IConfiguration.js";
2
+ export declare class JsonConfigurationSource implements IConfigurationSource {
3
+ private jsonConfig;
4
+ constructor(jsonConfig: ConfigData);
5
+ getData(): ConfigData;
6
+ getValues(): IterableIterator<{
7
+ key: string;
8
+ value: any;
9
+ }>;
10
+ }
11
+ export declare class EmptyConfigurationSource implements IConfigurationSource {
12
+ getData(): ConfigData;
13
+ getValues(): IterableIterator<{
14
+ key: string;
15
+ value: any;
16
+ }>;
17
+ }
18
+ export declare class ConfigurationSection implements IConfiguration {
19
+ data: ConfigData;
20
+ constructor(sectionData: ConfigData);
21
+ getSection(path: string): IConfiguration;
22
+ get(path: string): any;
23
+ bind<T>(type: {
24
+ new (): T;
25
+ }): T;
26
+ getValues(): IterableIterator<{
27
+ key: string;
28
+ value: any;
29
+ }>;
30
+ }
31
+ export declare class Configuration extends ConfigurationSection {
32
+ private sources;
33
+ constructor(sources: IConfigurationSource[]);
34
+ private mergeConfigurations;
35
+ }
@@ -0,0 +1,105 @@
1
+ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
2
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
3
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
4
+ else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
5
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
6
+ };
7
+ var __metadata = (this && this.__metadata) || function (k, v) {
8
+ if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
9
+ };
10
+ var __param = (this && this.__param) || function (paramIndex, decorator) {
11
+ return function (target, key) { decorator(target, key, paramIndex); }
12
+ };
13
+ import { Lifecycle, injectAll, injectable } from "tsyringe";
14
+ import { services } from "./Services.js";
15
+ import { IConfigurationSourceToken, IConfigurationToken, iterateConfig } from "./IConfiguration.js";
16
+ export class JsonConfigurationSource {
17
+ constructor(jsonConfig) {
18
+ this.jsonConfig = jsonConfig;
19
+ }
20
+ getData() {
21
+ return this.jsonConfig;
22
+ }
23
+ *getValues() {
24
+ yield* iterateConfig(this.jsonConfig);
25
+ }
26
+ }
27
+ export class EmptyConfigurationSource {
28
+ getData() {
29
+ return {};
30
+ }
31
+ *getValues() {
32
+ yield* iterateConfig({});
33
+ }
34
+ }
35
+ export class ConfigurationSection {
36
+ constructor(sectionData) {
37
+ this.data = sectionData;
38
+ }
39
+ getSection(path) {
40
+ const keys = path.split(':');
41
+ let currentSection = this.data;
42
+ for (const key of keys) {
43
+ if (!(key in currentSection)) {
44
+ return new ConfigurationSection({}); // Or handle as needed
45
+ }
46
+ currentSection = currentSection[key];
47
+ }
48
+ return new ConfigurationSection(currentSection);
49
+ }
50
+ get(path) {
51
+ const keys = path.split(':');
52
+ let currentSection = this.data;
53
+ for (const key of keys) {
54
+ if (currentSection && (key in currentSection)) {
55
+ currentSection = currentSection[key];
56
+ }
57
+ else {
58
+ return {};
59
+ }
60
+ }
61
+ return currentSection;
62
+ }
63
+ bind(type) {
64
+ const instance = new type();
65
+ for (const key in this.data) {
66
+ if (this.data.hasOwnProperty(key)) {
67
+ instance[key] = this.data[key];
68
+ }
69
+ }
70
+ return instance;
71
+ }
72
+ *getValues() {
73
+ yield* iterateConfig(this.data);
74
+ }
75
+ }
76
+ let Configuration = class Configuration extends ConfigurationSection {
77
+ //constructor(config: ConfigSection) {
78
+ // this.config = config;
79
+ //}
80
+ //constructor(@injectAll(ILoggerToken) private loggers: ILogger[], @injectAll(ILogReaderToken) private readers: ILogReader[]) {
81
+ // this.logTrace(`LoggingService.constructor loaded with ${loggers.length} loggers and ${readers.length} readers.`);
82
+ //}
83
+ constructor(sources) {
84
+ super({});
85
+ this.sources = sources;
86
+ this.mergeConfigurations(sources);
87
+ }
88
+ mergeConfigurations(sources) {
89
+ sources.forEach(source => {
90
+ const section = source.getData();
91
+ this.data = { ...this.data, ...section };
92
+ });
93
+ }
94
+ };
95
+ Configuration = __decorate([
96
+ injectable(),
97
+ __param(0, injectAll(IConfigurationSourceToken)),
98
+ __metadata("design:paramtypes", [Array])
99
+ ], Configuration);
100
+ export { Configuration };
101
+ // Register the Configuration class as a singleton
102
+ services.container.register(IConfigurationToken, { useClass: Configuration }, { lifecycle: Lifecycle.Singleton });
103
+ // Ensure we can have a default configuration source.
104
+ services.container.register(IConfigurationSourceToken, { useClass: EmptyConfigurationSource }, { lifecycle: Lifecycle.Singleton });
105
+ //# sourceMappingURL=Configuration.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Configuration.js","sourceRoot":"","sources":["Configuration.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,OAAO,EAAE,SAAS,EAAE,SAAS,EAAE,UAAU,EAAE,MAAM,UAAU,CAAC;AAC5D,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AACzC,OAAO,EAAoD,yBAAyB,EAAE,mBAAmB,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AAGtJ,MAAM,OAAO,uBAAuB;IAChC,YAAoB,UAAsB;QAAtB,eAAU,GAAV,UAAU,CAAY;IAAI,CAAC;IAE/C,OAAO;QACH,OAAO,IAAI,CAAC,UAAU,CAAC;IAC3B,CAAC;IAED,CAAC,SAAS;QACN,KAAK,CAAC,CAAC,aAAa,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC;IAC1C,CAAC;CACJ;AAED,MAAM,OAAO,wBAAwB;IACjC,OAAO;QACH,OAAO,EAAE,CAAC;IACd,CAAC;IACD,CAAC,SAAS;QACN,KAAK,CAAC,CAAC,aAAa,CAAC,EAAE,CAAC,CAAC;IAC7B,CAAC;CACJ;AAED,MAAM,OAAO,oBAAoB;IAG7B,YAAY,WAAuB;QAC/B,IAAI,CAAC,IAAI,GAAG,WAAW,CAAC;IAC5B,CAAC;IAEM,UAAU,CAAC,IAAY;QAC1B,MAAM,IAAI,GAAG,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;QAC7B,IAAI,cAAc,GAAQ,IAAI,CAAC,IAAI,CAAC;QAEpC,KAAK,MAAM,GAAG,IAAI,IAAI,EAAE,CAAC;YACrB,IAAI,CAAC,CAAC,GAAG,IAAI,cAAc,CAAC,EAAE,CAAC;gBAC3B,OAAO,IAAI,oBAAoB,CAAC,EAAE,CAAC,CAAC,CAAC,sBAAsB;YAC/D,CAAC;YACD,cAAc,GAAG,cAAc,CAAC,GAAG,CAAC,CAAC;QACzC,CAAC;QAED,OAAO,IAAI,oBAAoB,CAAC,cAAc,CAAC,CAAC;IACpD,CAAC;IAEM,GAAG,CAAC,IAAY;QACnB,MAAM,IAAI,GAAG,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;QAC7B,IAAI,cAAc,GAAQ,IAAI,CAAC,IAAI,CAAC;QAEpC,KAAK,MAAM,GAAG,IAAI,IAAI,EAAE,CAAC;YACrB,IAAI,cAAc,IAAI,CAAC,GAAG,IAAI,cAAc,CAAC,EAAE,CAAC;gBAC5C,cAAc,GAAG,cAAc,CAAC,GAAG,CAAC,CAAC;YACzC,CAAC;iBAAM,CAAC;gBACJ,OAAO,EAAE,CAAC;YACd,CAAC;QACL,CAAC;QAED,OAAO,cAAc,CAAC;IAC1B,CAAC;IAEM,IAAI,CAAI,IAAkB;QAC7B,MAAM,QAAQ,GAAG,IAAI,IAAI,EAAE,CAAC;QAC5B,KAAK,MAAM,GAAG,IAAI,IAAI,CAAC,IAAI,EAAE,CAAC;YAC1B,IAAI,IAAI,CAAC,IAAI,CAAC,cAAc,CAAC,GAAG,CAAC,EAAE,CAAC;gBAC/B,QAAgB,CAAC,GAAG,CAAC,GAAG,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;YAC5C,CAAC;QACL,CAAC;QACD,OAAO,QAAQ,CAAC;IACpB,CAAC;IACD,CAAC,SAAS;QACN,KAAK,CAAC,CAAC,aAAa,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IACpC,CAAC;CACJ;AAGM,IAAM,aAAa,GAAnB,MAAM,aAAc,SAAQ,oBAAoB;IAEnD,sCAAsC;IACtC,2BAA2B;IAC3B,GAAG;IAEH,+HAA+H;IAC/H,uHAAuH;IACvH,GAAG;IACH,YAA0D,OAA+B;QACrF,KAAK,CAAC,EAAE,CAAC,CAAC;QAD4C,YAAO,GAAP,OAAO,CAAwB;QAErF,IAAI,CAAC,mBAAmB,CAAC,OAAO,CAAC,CAAC;IACtC,CAAC;IAEO,mBAAmB,CAAC,OAA+B;QACvD,OAAO,CAAC,OAAO,CAAC,MAAM,CAAC,EAAE;YACrB,MAAM,OAAO,GAAG,MAAM,CAAC,OAAO,EAAE,CAAC;YACjC,IAAI,CAAC,IAAI,GAAG,EAAE,GAAG,IAAI,CAAC,IAAI,EAAE,GAAG,OAAO,EAAE,CAAC;QAC7C,CAAC,CAAC,CAAC;IACP,CAAC;CACJ,CAAA;AApBY,aAAa;IADzB,UAAU,EAAE;IAUI,WAAA,SAAS,CAAC,yBAAyB,CAAC,CAAA;;GATxC,aAAa,CAoBzB;;AAED,kDAAkD;AAClD,QAAQ,CAAC,SAAS,CAAC,QAAQ,CAAiB,mBAAmB,EAAE,EAAE,QAAQ,EAAE,aAAa,EAAE,EAAE,EAAE,SAAS,EAAE,SAAS,CAAC,SAAS,EAAE,CAAC,CAAC;AAElI,qDAAqD;AACrD,QAAQ,CAAC,SAAS,CAAC,QAAQ,CAAuB,yBAAyB,EAAE,EAAE,QAAQ,EAAE,wBAAwB,EAAE,EAAE,EAAE,SAAS,EAAE,SAAS,CAAC,SAAS,EAAE,CAAC,CAAC"}
@@ -0,0 +1,105 @@
1
+ import { Lifecycle, injectAll, injectable } from "tsyringe";
2
+ import { services } from "./Services.js";
3
+ import { ConfigData, IConfiguration, IConfigurationSource, IConfigurationSourceToken, IConfigurationToken, iterateConfig } from "./IConfiguration.js";
4
+
5
+
6
+ export class JsonConfigurationSource implements IConfigurationSource {
7
+ constructor(private jsonConfig: ConfigData) { }
8
+
9
+ getData(): ConfigData {
10
+ return this.jsonConfig;
11
+ }
12
+
13
+ *getValues(): IterableIterator<{ key: string; value: any }> {
14
+ yield* iterateConfig(this.jsonConfig);
15
+ }
16
+ }
17
+
18
+ export class EmptyConfigurationSource implements IConfigurationSource {
19
+ getData(): ConfigData {
20
+ return {};
21
+ }
22
+ *getValues(): IterableIterator<{ key: string; value: any }> {
23
+ yield* iterateConfig({});
24
+ }
25
+ }
26
+
27
+ export class ConfigurationSection implements IConfiguration {
28
+ public data: ConfigData;
29
+
30
+ constructor(sectionData: ConfigData) {
31
+ this.data = sectionData;
32
+ }
33
+
34
+ public getSection(path: string): IConfiguration {
35
+ const keys = path.split(':');
36
+ let currentSection: any = this.data;
37
+
38
+ for (const key of keys) {
39
+ if (!(key in currentSection)) {
40
+ return new ConfigurationSection({}); // Or handle as needed
41
+ }
42
+ currentSection = currentSection[key];
43
+ }
44
+
45
+ return new ConfigurationSection(currentSection);
46
+ }
47
+
48
+ public get(path: string): any {
49
+ const keys = path.split(':');
50
+ let currentSection: any = this.data;
51
+
52
+ for (const key of keys) {
53
+ if (currentSection && (key in currentSection)) {
54
+ currentSection = currentSection[key];
55
+ } else {
56
+ return {};
57
+ }
58
+ }
59
+
60
+ return currentSection;
61
+ }
62
+
63
+ public bind<T>(type: { new(): T }): T {
64
+ const instance = new type();
65
+ for (const key in this.data) {
66
+ if (this.data.hasOwnProperty(key)) {
67
+ (instance as any)[key] = this.data[key];
68
+ }
69
+ }
70
+ return instance;
71
+ }
72
+ *getValues(): IterableIterator<{ key: string; value: any }> {
73
+ yield* iterateConfig(this.data);
74
+ }
75
+ }
76
+
77
+ @injectable()
78
+ export class Configuration extends ConfigurationSection {
79
+
80
+ //constructor(config: ConfigSection) {
81
+ // this.config = config;
82
+ //}
83
+
84
+ //constructor(@injectAll(ILoggerToken) private loggers: ILogger[], @injectAll(ILogReaderToken) private readers: ILogReader[]) {
85
+ // this.logTrace(`LoggingService.constructor loaded with ${loggers.length} loggers and ${readers.length} readers.`);
86
+ //}
87
+ constructor(@injectAll(IConfigurationSourceToken) private sources: IConfigurationSource[]) {
88
+ super({});
89
+ this.mergeConfigurations(sources);
90
+ }
91
+
92
+ private mergeConfigurations(sources: IConfigurationSource[]) {
93
+ sources.forEach(source => {
94
+ const section = source.getData();
95
+ this.data = { ...this.data, ...section };
96
+ });
97
+ }
98
+ }
99
+
100
+ // Register the Configuration class as a singleton
101
+ services.container.register<IConfiguration>(IConfigurationToken, { useClass: Configuration }, { lifecycle: Lifecycle.Singleton });
102
+
103
+ // Ensure we can have a default configuration source.
104
+ services.container.register<IConfigurationSource>(IConfigurationSourceToken, { useClass: EmptyConfigurationSource }, { lifecycle: Lifecycle.Singleton });
105
+
@@ -0,0 +1,34 @@
1
+ import { InjectionToken } from "tsyringe";
2
+ export type ConfigData = {
3
+ [key: string]: any;
4
+ };
5
+ export interface IConfigurationSource extends ConfigData {
6
+ getData(): ConfigData;
7
+ getValues(): IterableIterator<{
8
+ key: string;
9
+ value: any;
10
+ }>;
11
+ }
12
+ /**
13
+ * Define a token for the ILoggerService interface
14
+ */
15
+ export declare const IConfigurationSourceToken: InjectionToken<IConfigurationSource>;
16
+ export interface IConfiguration {
17
+ getSection(section: string): IConfiguration;
18
+ bind<T>(type: {
19
+ new (): T;
20
+ }): T;
21
+ get(path: string): any;
22
+ getValues(): IterableIterator<{
23
+ key: string;
24
+ value: any;
25
+ }>;
26
+ }
27
+ /**
28
+ * Define a token for the ILoggerService interface
29
+ */
30
+ export declare const IConfigurationToken: InjectionToken<IConfiguration>;
31
+ export declare function iterateConfig(obj: any, prefix?: string): IterableIterator<{
32
+ key: string;
33
+ value: any;
34
+ }>;
@@ -0,0 +1,38 @@
1
+ /**
2
+ * Define a token for the ILoggerService interface
3
+ */
4
+ export const IConfigurationSourceToken = 'IConfigurationSourceToken';
5
+ /**
6
+ * Define a token for the ILoggerService interface
7
+ */
8
+ export const IConfigurationToken = 'IConfigurationToken';
9
+ // Helper function to iterate over a configuration object and yield key-value pairs
10
+ export function* iterateConfig(obj, prefix = '') {
11
+ for (const [key, value] of Object.entries(obj)) {
12
+ const fullKey = prefix ? `${prefix}:${key}` : key;
13
+ // Check if the value is an array
14
+ if (Array.isArray(value)) {
15
+ for (let i = 0; i < value.length; i++) {
16
+ const item = value[i];
17
+ // For each item in the array, extend the prefix to include the index
18
+ if (typeof item === 'object' && item !== null) {
19
+ // Recursively yield nested object values, including arrays
20
+ yield* iterateConfig(item, `${fullKey}:${i}`);
21
+ }
22
+ else {
23
+ // Yield primitive values directly, with index in the key
24
+ yield { key: `${fullKey}:${i}`, value: item };
25
+ }
26
+ }
27
+ }
28
+ else if (typeof value === 'object' && value !== null) {
29
+ // Recursively yield nested object values
30
+ yield* iterateConfig(value, fullKey);
31
+ }
32
+ else {
33
+ // Yield primitive values directly
34
+ yield { key: fullKey, value };
35
+ }
36
+ }
37
+ }
38
+ //# sourceMappingURL=IConfiguration.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"IConfiguration.js","sourceRoot":"","sources":["IConfiguration.ts"],"names":[],"mappings":"AAQA;;GAEG;AACH,MAAM,CAAC,MAAM,yBAAyB,GAAyC,2BAA2B,CAAC;AAS3G;;GAEG;AACH,MAAM,CAAC,MAAM,mBAAmB,GAAmC,qBAAqB,CAAC;AAEzF,mFAAmF;AACnF,MAAM,SAAS,CAAC,CAAC,aAAa,CAAC,GAAQ,EAAE,SAAiB,EAAE;IACxD,KAAK,MAAM,CAAC,GAAG,EAAE,KAAK,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,GAAG,CAAC,EAAE,CAAC;QAC7C,MAAM,OAAO,GAAG,MAAM,CAAC,CAAC,CAAC,GAAG,MAAM,IAAI,GAAG,EAAE,CAAC,CAAC,CAAC,GAAG,CAAC;QAClD,iCAAiC;QACjC,IAAI,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,EAAE,CAAC;YACvB,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,KAAK,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE,CAAC;gBACpC,MAAM,IAAI,GAAG,KAAK,CAAC,CAAC,CAAC,CAAC;gBACtB,qEAAqE;gBACrE,IAAI,OAAO,IAAI,KAAK,QAAQ,IAAI,IAAI,KAAK,IAAI,EAAE,CAAC;oBAC5C,2DAA2D;oBAC3D,KAAK,CAAC,CAAC,aAAa,CAAC,IAAI,EAAE,GAAG,OAAO,IAAI,CAAC,EAAE,CAAC,CAAC;gBAClD,CAAC;qBAAM,CAAC;oBACJ,yDAAyD;oBACzD,MAAM,EAAE,GAAG,EAAE,GAAG,OAAO,IAAI,CAAC,EAAE,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC;gBAClD,CAAC;YACL,CAAC;QACL,CAAC;aAAM,IAAI,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,KAAK,IAAI,EAAE,CAAC;YACrD,yCAAyC;YACzC,KAAK,CAAC,CAAC,aAAa,CAAC,KAAK,EAAE,OAAO,CAAC,CAAC;QACzC,CAAC;aAAM,CAAC;YACJ,kCAAkC;YAClC,MAAM,EAAE,GAAG,EAAE,OAAO,EAAE,KAAK,EAAE,CAAC;QAClC,CAAC;IACL,CAAC;AACL,CAAC"}
@@ -0,0 +1,51 @@
1
+ import { InjectionToken } from "tsyringe";
2
+
3
+ export type ConfigData = { [key: string]: any };
4
+
5
+ export interface IConfigurationSource extends ConfigData {
6
+ getData(): ConfigData;
7
+ getValues(): IterableIterator<{ key: string; value: any }>;
8
+ }
9
+ /**
10
+ * Define a token for the ILoggerService interface
11
+ */
12
+ export const IConfigurationSourceToken: InjectionToken<IConfigurationSource> = 'IConfigurationSourceToken';
13
+
14
+ export interface IConfiguration {
15
+ getSection(section: string): IConfiguration;
16
+ bind<T>(type: { new(): T }): T;
17
+ get(path: string): any;
18
+ getValues(): IterableIterator<{ key: string; value: any }>;
19
+ }
20
+
21
+ /**
22
+ * Define a token for the ILoggerService interface
23
+ */
24
+ export const IConfigurationToken: InjectionToken<IConfiguration> = 'IConfigurationToken';
25
+
26
+ // Helper function to iterate over a configuration object and yield key-value pairs
27
+ export function* iterateConfig(obj: any, prefix: string = ''): IterableIterator<{ key: string; value: any }> {
28
+ for (const [key, value] of Object.entries(obj)) {
29
+ const fullKey = prefix ? `${prefix}:${key}` : key;
30
+ // Check if the value is an array
31
+ if (Array.isArray(value)) {
32
+ for (let i = 0; i < value.length; i++) {
33
+ const item = value[i];
34
+ // For each item in the array, extend the prefix to include the index
35
+ if (typeof item === 'object' && item !== null) {
36
+ // Recursively yield nested object values, including arrays
37
+ yield* iterateConfig(item, `${fullKey}:${i}`);
38
+ } else {
39
+ // Yield primitive values directly, with index in the key
40
+ yield { key: `${fullKey}:${i}`, value: item };
41
+ }
42
+ }
43
+ } else if (typeof value === 'object' && value !== null) {
44
+ // Recursively yield nested object values
45
+ yield* iterateConfig(value, fullKey);
46
+ } else {
47
+ // Yield primitive values directly
48
+ yield { key: fullKey, value };
49
+ }
50
+ }
51
+ }
@@ -0,0 +1,10 @@
1
+ declare global {
2
+ interface HTMLElement {
3
+ attachInternals(): ElementInternals;
4
+ }
5
+ }
6
+ import 'reflect-metadata';
7
+ export * from './Services.js';
8
+ export * from './IConfiguration.js';
9
+ export * from './Configuration.js';
10
+ export * from './qbo-config-editor.js';
package/src/Program.js ADDED
@@ -0,0 +1,6 @@
1
+ import 'reflect-metadata';
2
+ export * from './Services.js';
3
+ export * from './IConfiguration.js';
4
+ export * from './Configuration.js';
5
+ export * from './qbo-config-editor.js';
6
+ //# sourceMappingURL=Program.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Program.js","sourceRoot":"","sources":["Program.ts"],"names":[],"mappings":"AAOA,OAAO,kBAAkB,CAAC;AAC1B,cAAc,eAAe,CAAC;AAC9B,cAAc,qBAAqB,CAAC;AACpC,cAAc,oBAAoB,CAAC;AACnC,cAAc,wBAAwB,CAAC"}
package/src/Program.ts ADDED
@@ -0,0 +1,13 @@
1
+ // Extend the HTMLElement interface to include attachInternals
2
+ declare global {
3
+ interface HTMLElement {
4
+ attachInternals(): ElementInternals;
5
+ }
6
+ }
7
+
8
+ import 'reflect-metadata';
9
+ export * from './Services.js';
10
+ export * from './IConfiguration.js';
11
+ export * from './Configuration.js';
12
+ export * from './qbo-config-editor.js';
13
+
@@ -0,0 +1,16 @@
1
+ import { DependencyContainer, InjectionToken } from "tsyringe";
2
+ export declare class Services {
3
+ container: DependencyContainer;
4
+ options: any;
5
+ constructor(container: DependencyContainer, options: any);
6
+ getService<T>(token: string | InjectionToken<T>): T;
7
+ }
8
+ declare global {
9
+ interface Window {
10
+ qbo4: {
11
+ services?: Services;
12
+ };
13
+ }
14
+ }
15
+ declare const services: Services;
16
+ export { services };
@@ -0,0 +1,16 @@
1
+ import { container } from "tsyringe";
2
+ export class Services {
3
+ constructor(container, options) {
4
+ this.container = container;
5
+ this.options = options;
6
+ }
7
+ getService(token) {
8
+ return this.container.resolve(token);
9
+ }
10
+ }
11
+ // Expose tsyring.container as qbo4.Logging.Services, but ensure it's global.
12
+ window.qbo4 = window.qbo4 || {};
13
+ window.qbo4.services = window.qbo4.services || new Services(container.createChildContainer(), {});
14
+ const services = window.qbo4.services;
15
+ export { services };
16
+ //# sourceMappingURL=Services.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Services.js","sourceRoot":"","sources":["Services.ts"],"names":[],"mappings":"AAAA,OAAO,EAAuC,SAAS,EAAE,MAAM,UAAU,CAAC;AAE1E,MAAM,OAAO,QAAQ;IAGjB,YAAY,SAA8B,EAAE,OAAY;QACpD,IAAI,CAAC,SAAS,GAAG,SAAS,CAAC;QAC3B,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC;IAC3B,CAAC;IAED,UAAU,CAAI,KAAkC;QAC5C,OAAO,IAAI,CAAC,SAAS,CAAC,OAAO,CAAI,KAAK,CAAC,CAAC;IAC5C,CAAC;CACJ;AAUD,6EAA6E;AAC7E,MAAM,CAAC,IAAI,GAAG,MAAM,CAAC,IAAI,IAAI,EAAE,CAAC;AAChC,MAAM,CAAC,IAAI,CAAC,QAAQ,GAAG,MAAM,CAAC,IAAI,CAAC,QAAQ,IAAI,IAAI,QAAQ,CAAC,SAAS,CAAC,oBAAoB,EAAE,EAAE,EAAE,CAAC,CAAC;AAClG,MAAM,QAAQ,GAAG,MAAM,CAAC,IAAI,CAAC,QAAQ,CAAC;AAEtC,OAAO,EAAE,QAAQ,EAAE,CAAA"}
@@ -0,0 +1,29 @@
1
+ import { DependencyContainer, InjectionToken, container } from "tsyringe";
2
+
3
+ export class Services {
4
+ public container: DependencyContainer;
5
+ public options: any;
6
+ constructor(container: DependencyContainer, options: any) {
7
+ this.container = container;
8
+ this.options = options;
9
+ }
10
+
11
+ getService<T>(token: string | InjectionToken<T>): T {
12
+ return this.container.resolve<T>(token);
13
+ }
14
+ }
15
+
16
+ declare global {
17
+ interface Window {
18
+ qbo4: {
19
+ services?: Services;
20
+ };
21
+ }
22
+ }
23
+
24
+ // Expose tsyring.container as qbo4.Logging.Services, but ensure it's global.
25
+ window.qbo4 = window.qbo4 || {};
26
+ window.qbo4.services = window.qbo4.services || new Services(container.createChildContainer(), {});
27
+ const services = window.qbo4.services;
28
+
29
+ export { services }
@@ -0,0 +1,18 @@
1
+ import { LitElement } from 'lit';
2
+ export declare class QboConfigEditor extends LitElement {
3
+ private _internals;
4
+ static get formAssociated(): boolean;
5
+ value: any;
6
+ configData: Object;
7
+ static styles: import("lit").CSSResult;
8
+ constructor();
9
+ _handleInput(e: any): void;
10
+ connectedCallback(): Promise<void>;
11
+ handleInputChange(key: any, event: any): void;
12
+ updateConfigData(key: any, newValue: any, event: any, isKey?: boolean): void;
13
+ addKeyValuePair(event: any): void;
14
+ deleteKeyValuePair(key: any, event: any): void;
15
+ saveChanges(event: any): void;
16
+ cancelChanges(event: any): void;
17
+ render(): import("lit-html").TemplateResult<1>;
18
+ }