@adaas/a-utils 0.1.10 → 0.1.12

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 (125) hide show
  1. package/README.md +87 -32
  2. package/dist/index.d.mts +933 -0
  3. package/dist/index.d.ts +933 -27
  4. package/dist/index.js +1786 -90
  5. package/dist/index.js.map +1 -1
  6. package/dist/index.mjs +1764 -0
  7. package/dist/index.mjs.map +1 -0
  8. package/examples/command-examples.ts +268 -0
  9. package/package.json +5 -3
  10. package/src/index.ts +70 -0
  11. package/src/lib/A-Command/A-Command.constants.ts +4 -0
  12. package/src/lib/A-Command/A-Command.entity.ts +31 -13
  13. package/src/lib/A-Command/A-Command.types.ts +6 -1
  14. package/src/lib/A-Command/README.md +645 -0
  15. package/src/lib/A-Logger/A-Logger.component.ts +10 -3
  16. package/src/lib/A-Memory/A-Memory.context.ts +15 -0
  17. package/src/lib/A-Polyfill/A-Polyfill.component.ts +153 -15
  18. package/src/lib/A-Polyfill/A-Polyfill.types.ts +54 -0
  19. package/src/lib/A-Polyfill/classes/A-Buffer-Polyfill.class.ts +85 -0
  20. package/src/lib/A-Polyfill/classes/A-Crypto-Polyfill.class.ts +87 -0
  21. package/src/lib/A-Polyfill/classes/A-FS-Polyfill.class.ts +61 -0
  22. package/src/lib/A-Polyfill/classes/A-Http-Polyfill.class.ts +100 -0
  23. package/src/lib/A-Polyfill/classes/A-Https-Polyfill.class.ts +100 -0
  24. package/src/lib/A-Polyfill/classes/A-Path-Polyfill.class.ts +97 -0
  25. package/src/lib/A-Polyfill/classes/A-Process-Polyfill.class.ts +73 -0
  26. package/src/lib/A-Polyfill/classes/A-Url-Polyfill.class.ts +88 -0
  27. package/tests/A-Command.test.ts +447 -2
  28. package/tests/A-Config.test.ts +5 -5
  29. package/tests/A-Memory.test.ts +189 -0
  30. package/tests/A-Polyfill.test.ts +446 -29
  31. package/tsconfig.json +1 -1
  32. package/tsup.config.ts +15 -0
  33. package/dist/src/constants/errors.constants.d.ts +0 -0
  34. package/dist/src/constants/errors.constants.js +0 -2
  35. package/dist/src/constants/errors.constants.js.map +0 -1
  36. package/dist/src/lib/A-Channel/A-Channel.component.d.ts +0 -22
  37. package/dist/src/lib/A-Channel/A-Channel.component.js +0 -84
  38. package/dist/src/lib/A-Channel/A-Channel.component.js.map +0 -1
  39. package/dist/src/lib/A-Channel/A-Channel.error.d.ts +0 -4
  40. package/dist/src/lib/A-Channel/A-Channel.error.js +0 -9
  41. package/dist/src/lib/A-Channel/A-Channel.error.js.map +0 -1
  42. package/dist/src/lib/A-Channel/A-Channel.types.d.ts +0 -0
  43. package/dist/src/lib/A-Channel/A-Channel.types.js +0 -2
  44. package/dist/src/lib/A-Channel/A-Channel.types.js.map +0 -1
  45. package/dist/src/lib/A-Command/A-Command.constants.d.ts +0 -22
  46. package/dist/src/lib/A-Command/A-Command.constants.js +0 -28
  47. package/dist/src/lib/A-Command/A-Command.constants.js.map +0 -1
  48. package/dist/src/lib/A-Command/A-Command.entity.d.ts +0 -133
  49. package/dist/src/lib/A-Command/A-Command.entity.js +0 -273
  50. package/dist/src/lib/A-Command/A-Command.entity.js.map +0 -1
  51. package/dist/src/lib/A-Command/A-Command.error.d.ts +0 -3
  52. package/dist/src/lib/A-Command/A-Command.error.js +0 -8
  53. package/dist/src/lib/A-Command/A-Command.error.js.map +0 -1
  54. package/dist/src/lib/A-Command/A-Command.types.d.ts +0 -73
  55. package/dist/src/lib/A-Command/A-Command.types.js +0 -4
  56. package/dist/src/lib/A-Command/A-Command.types.js.map +0 -1
  57. package/dist/src/lib/A-Config/A-Config.constants.d.ts +0 -3
  58. package/dist/src/lib/A-Config/A-Config.constants.js +0 -6
  59. package/dist/src/lib/A-Config/A-Config.constants.js.map +0 -1
  60. package/dist/src/lib/A-Config/A-Config.container.d.ts +0 -6
  61. package/dist/src/lib/A-Config/A-Config.container.js +0 -77
  62. package/dist/src/lib/A-Config/A-Config.container.js.map +0 -1
  63. package/dist/src/lib/A-Config/A-Config.context.d.ts +0 -29
  64. package/dist/src/lib/A-Config/A-Config.context.js +0 -63
  65. package/dist/src/lib/A-Config/A-Config.context.js.map +0 -1
  66. package/dist/src/lib/A-Config/A-Config.error.d.ts +0 -4
  67. package/dist/src/lib/A-Config/A-Config.error.js +0 -9
  68. package/dist/src/lib/A-Config/A-Config.error.js.map +0 -1
  69. package/dist/src/lib/A-Config/A-Config.types.d.ts +0 -19
  70. package/dist/src/lib/A-Config/A-Config.types.js +0 -7
  71. package/dist/src/lib/A-Config/A-Config.types.js.map +0 -1
  72. package/dist/src/lib/A-Config/components/ConfigReader.component.d.ts +0 -30
  73. package/dist/src/lib/A-Config/components/ConfigReader.component.js +0 -103
  74. package/dist/src/lib/A-Config/components/ConfigReader.component.js.map +0 -1
  75. package/dist/src/lib/A-Config/components/ENVConfigReader.component.d.ts +0 -14
  76. package/dist/src/lib/A-Config/components/ENVConfigReader.component.js +0 -72
  77. package/dist/src/lib/A-Config/components/ENVConfigReader.component.js.map +0 -1
  78. package/dist/src/lib/A-Config/components/FileConfigReader.component.d.ts +0 -11
  79. package/dist/src/lib/A-Config/components/FileConfigReader.component.js +0 -47
  80. package/dist/src/lib/A-Config/components/FileConfigReader.component.js.map +0 -1
  81. package/dist/src/lib/A-Logger/A-Logger.component.d.ts +0 -29
  82. package/dist/src/lib/A-Logger/A-Logger.component.js +0 -152
  83. package/dist/src/lib/A-Logger/A-Logger.component.js.map +0 -1
  84. package/dist/src/lib/A-Logger/A-Logger.types.d.ts +0 -0
  85. package/dist/src/lib/A-Logger/A-Logger.types.js +0 -2
  86. package/dist/src/lib/A-Logger/A-Logger.types.js.map +0 -1
  87. package/dist/src/lib/A-Manifest/A-Manifest.context.d.ts +0 -52
  88. package/dist/src/lib/A-Manifest/A-Manifest.context.js +0 -154
  89. package/dist/src/lib/A-Manifest/A-Manifest.context.js.map +0 -1
  90. package/dist/src/lib/A-Manifest/A-Manifest.error.d.ts +0 -4
  91. package/dist/src/lib/A-Manifest/A-Manifest.error.js +0 -9
  92. package/dist/src/lib/A-Manifest/A-Manifest.error.js.map +0 -1
  93. package/dist/src/lib/A-Manifest/A-Manifest.types.d.ts +0 -43
  94. package/dist/src/lib/A-Manifest/A-Manifest.types.js +0 -3
  95. package/dist/src/lib/A-Manifest/A-Manifest.types.js.map +0 -1
  96. package/dist/src/lib/A-Manifest/classes/A-ManifestChecker.class.d.ts +0 -14
  97. package/dist/src/lib/A-Manifest/classes/A-ManifestChecker.class.js +0 -24
  98. package/dist/src/lib/A-Manifest/classes/A-ManifestChecker.class.js.map +0 -1
  99. package/dist/src/lib/A-Memory/A-Memory.context.d.ts +0 -64
  100. package/dist/src/lib/A-Memory/A-Memory.context.js +0 -105
  101. package/dist/src/lib/A-Memory/A-Memory.context.js.map +0 -1
  102. package/dist/src/lib/A-Polyfill/A-Polyfill.component.d.ts +0 -20
  103. package/dist/src/lib/A-Polyfill/A-Polyfill.component.js +0 -53
  104. package/dist/src/lib/A-Polyfill/A-Polyfill.component.js.map +0 -1
  105. package/dist/src/lib/A-Polyfill/A-Polyfill.types.d.ts +0 -9
  106. package/dist/src/lib/A-Polyfill/A-Polyfill.types.js +0 -3
  107. package/dist/src/lib/A-Polyfill/A-Polyfill.types.js.map +0 -1
  108. package/dist/src/lib/A-Polyfill/A-Polyfills.class.d.ts +0 -11
  109. package/dist/src/lib/A-Polyfill/A-Polyfills.class.js +0 -123
  110. package/dist/src/lib/A-Polyfill/A-Polyfills.class.js.map +0 -1
  111. package/dist/src/lib/A-Schedule/A-Deferred.class.d.ts +0 -12
  112. package/dist/src/lib/A-Schedule/A-Deferred.class.js +0 -23
  113. package/dist/src/lib/A-Schedule/A-Deferred.class.js.map +0 -1
  114. package/dist/src/lib/A-Schedule/A-Schedule.component.d.ts +0 -57
  115. package/dist/src/lib/A-Schedule/A-Schedule.component.js +0 -49
  116. package/dist/src/lib/A-Schedule/A-Schedule.component.js.map +0 -1
  117. package/dist/src/lib/A-Schedule/A-Schedule.types.d.ts +0 -10
  118. package/dist/src/lib/A-Schedule/A-Schedule.types.js +0 -3
  119. package/dist/src/lib/A-Schedule/A-Schedule.types.js.map +0 -1
  120. package/dist/src/lib/A-Schedule/A-ScheduleObject.class.d.ts +0 -29
  121. package/dist/src/lib/A-Schedule/A-ScheduleObject.class.js +0 -58
  122. package/dist/src/lib/A-Schedule/A-ScheduleObject.class.js.map +0 -1
  123. package/index.ts +0 -71
  124. package/src/lib/A-Polyfill/A-Polyfills.class.ts +0 -99
  125. package/tsconfig.build.json +0 -56
package/index.ts DELETED
@@ -1,71 +0,0 @@
1
-
2
- // ============================================================================
3
- // A-Channel Components
4
- // ============================================================================
5
- export { A_Channel } from './src/lib/A-Channel/A-Channel.component';
6
- export { A_ChannelError } from './src/lib/A-Channel/A-Channel.error';
7
- // export * from './src/lib/A-Channel/A-Channel.types'; // Empty file
8
-
9
-
10
- // ============================================================================
11
- // A-Command Components
12
- // ============================================================================
13
- export { A_Command } from './src/lib/A-Command/A-Command.entity';
14
- export { A_CommandError } from './src/lib/A-Command/A-Command.error';
15
- export * from './src/lib/A-Command/A-Command.types';
16
- export * from './src/lib/A-Command/A-Command.constants';
17
-
18
-
19
- // ============================================================================
20
- // A-Config Components
21
- // ============================================================================
22
- export { A_ConfigLoader } from './src/lib/A-Config/A-Config.container';
23
- export { A_Config } from './src/lib/A-Config/A-Config.context';
24
- export { A_ConfigError } from './src/lib/A-Config/A-Config.error';
25
- export { ConfigReader } from './src/lib/A-Config/components/ConfigReader.component';
26
- export { ENVConfigReader } from './src/lib/A-Config/components/ENVConfigReader.component';
27
- export { FileConfigReader } from './src/lib/A-Config/components/FileConfigReader.component';
28
- export * from './src/lib/A-Config/A-Config.types';
29
- export * from './src/lib/A-Config/A-Config.constants';
30
-
31
-
32
- // ============================================================================
33
- // A-Logger Components
34
- // ============================================================================
35
- export { A_Logger } from './src/lib/A-Logger/A-Logger.component';
36
- // export * from './src/lib/A-Logger/A-Logger.types'; // Empty file
37
-
38
-
39
- // ============================================================================
40
- // A-Manifest Components
41
- // ============================================================================
42
- export { A_Manifest } from './src/lib/A-Manifest/A-Manifest.context';
43
- export { A_ManifestError } from './src/lib/A-Manifest/A-Manifest.error';
44
- export { A_ManifestChecker } from './src/lib/A-Manifest/classes/A-ManifestChecker.class';
45
- export * from './src/lib/A-Manifest/A-Manifest.types';
46
-
47
-
48
- // ============================================================================
49
- // A-Memory Components
50
- // ============================================================================
51
- export { A_Memory } from './src/lib/A-Memory/A-Memory.context';
52
-
53
-
54
- // ============================================================================
55
- // A-Polyfill Components
56
- // ============================================================================
57
- export { A_Polyfill } from './src/lib/A-Polyfill/A-Polyfill.component';
58
- export { A_PolyfillClass } from './src/lib/A-Polyfill/A-Polyfills.class';
59
- export * from './src/lib/A-Polyfill/A-Polyfill.types';
60
-
61
-
62
- // ============================================================================
63
- // A-Schedule Components
64
- // ============================================================================
65
- export { A_Schedule } from './src/lib/A-Schedule/A-Schedule.component';
66
- export { A_ScheduleObject } from './src/lib/A-Schedule/A-ScheduleObject.class';
67
- export { A_Deferred } from './src/lib/A-Schedule/A-Deferred.class';
68
- export * from './src/lib/A-Schedule/A-Schedule.types';
69
-
70
-
71
-
@@ -1,99 +0,0 @@
1
- import { IcryptoInterface, Ifspolyfill } from "./A-Polyfill.types";
2
-
3
-
4
-
5
- export class A_PolyfillClass {
6
-
7
- private _fs!: Ifspolyfill;
8
- private _crypto!: IcryptoInterface;
9
-
10
- // eslint-disable-next-line no-use-before-define
11
- private fsName = 'fs'
12
- private cryptoName = 'crypto'
13
-
14
-
15
- async fs() {
16
- if (!this._fs) {
17
- await this.init();
18
- }
19
- return this._fs;
20
- }
21
-
22
- async crypto() {
23
- if (!this._crypto) {
24
- await this.init();
25
- }
26
- return this._crypto;
27
- }
28
-
29
-
30
- get env(): 'server' | 'browser' {
31
- let testEnvironment: 'server' | 'browser' = 'browser';
32
-
33
- try {
34
- testEnvironment = window.location ? 'browser' : 'server';
35
-
36
- } catch (error) {
37
-
38
- testEnvironment = 'server';
39
- }
40
-
41
- return testEnvironment;
42
- }
43
-
44
-
45
- private async init() {
46
- try {
47
- if (this.env === 'server') {
48
- // eslint-disable-next-line no-use-before-define
49
- this._fs = await import('' + this.fsName) as Ifspolyfill;
50
- // eslint-disable-next-line no-use-before-define
51
- this._crypto = {
52
- createTextHash: () => Promise.resolve(''),
53
- createFileHash: (filePath: string, algorithm: string = 'sha384') => new Promise(async (resolve, reject) => {
54
- try {
55
- const crypto = await import('' + this.cryptoName);
56
-
57
- const hash = crypto.createHash(algorithm);
58
- const fileStream = this._fs.createReadStream(filePath);
59
-
60
- fileStream.on('data', (data) => hash.update(data));
61
- fileStream.on('end', () => resolve(`${algorithm}-${hash.digest('base64')}`));
62
- fileStream.on('error', (err) => reject(err));
63
-
64
- } catch (error) {
65
- return reject(error);
66
- }
67
-
68
- })
69
- }
70
- }
71
- else {
72
- throw new Error('Not Server Environment');
73
- }
74
- } catch (error) {
75
-
76
- this._fs = {
77
- readFileSync: (path: string, encoding: string) => '',
78
- existsSync: (path: string) => false,
79
- createReadStream: (path: string) => ''
80
- };
81
-
82
- this._crypto = {
83
- createFileHash: () => Promise.resolve(''),
84
- createTextHash: (text: string, algorithm: string = 'SHA-384') => new Promise<string>(async (resolve, reject) => {
85
- try {
86
- const encoder = new TextEncoder();
87
- const data = encoder.encode(text);
88
- const hashBuffer = await crypto.subtle.digest(algorithm, data);
89
- const hashArray = Array.from(new Uint8Array(hashBuffer));
90
- const hashBase64 = btoa(String.fromCharCode(...hashArray.map(byte => String.fromCharCode(byte) as any)));
91
- return resolve(`${algorithm}-${hashBase64}`);
92
- } catch (error) {
93
- return reject(error);
94
- }
95
- })
96
- };
97
- }
98
- }
99
- }
@@ -1,56 +0,0 @@
1
- {
2
- "compileOnSave": false,
3
- "compilerOptions": {
4
- "outDir": "dist",
5
- "strict": true,
6
- "noImplicitAny": false,
7
- "noFallthroughCasesInSwitch": true,
8
- "downlevelIteration": true,
9
- "strictFunctionTypes": true,
10
- "strictNullChecks": true,
11
- "strictPropertyInitialization": true,
12
- "forceConsistentCasingInFileNames": true,
13
- "resolveJsonModule": true,
14
- "noErrorTruncation": true,
15
- "jsx": "react",
16
- "target": "es2015",
17
- "module": "commonjs",
18
- "moduleResolution": "node",
19
- "allowSyntheticDefaultImports": true,
20
- "esModuleInterop": true,
21
- "noUnusedLocals": false,
22
- "noUnusedParameters": false,
23
- "removeComments": false,
24
- "preserveConstEnums": true,
25
- "sourceMap": true,
26
- "baseUrl": ".",
27
- "experimentalDecorators": true,
28
- "skipLibCheck": true,
29
- "typeRoots": [
30
- "node_modules/@types"
31
- ],
32
- "paths": {
33
- "@adaas/a-utils/constants/*": ["src/constants/*"],
34
- "@adaas/a-utils/lib/*": ["src/lib/*"],
35
- "@adaas/a-utils/types/*": ["src/types/*"],
36
- "@adaas/a-utils/helpers/*": ["src/helpers/*"],
37
- "@adaas/a-utils/utils/*": ["src/utils/*"]
38
- },
39
- "lib": [
40
- "dom",
41
- "esnext.asynciterable",
42
- "es2015",
43
- "es2016",
44
- "es2017.object"
45
- ]
46
- },
47
- "include": [
48
- "src/**/*",
49
- "index.ts"
50
- ],
51
- "exclude": [
52
- "node_modules/**/*",
53
- "dist/**/*",
54
- "node_modules/@types/mocha/index.d.ts"
55
- ]
56
- }