@futdevpro/fsm-dynamo 1.11.14 → 1.11.16

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.
@@ -1 +1 @@
1
- {"version":3,"file":"stack.util.d.ts","sourceRoot":"","sources":["../../../src/_collections/utils/stack.util.ts"],"names":[],"mappings":"AAEA;;;;GAIG;AACH,wBAAgB,iCAAiC,CAAC,KAAK,GAAE,MAAU,GAAG,MAAM,CAiE3E;AAED,wBAAgB,0BAA0B,CAAC,KAAK,GAAE,MAAU,GAAG,MAAM,CA2DpE"}
1
+ {"version":3,"file":"stack.util.d.ts","sourceRoot":"","sources":["../../../src/_collections/utils/stack.util.ts"],"names":[],"mappings":"AAEA;;;;GAIG;AACH,wBAAgB,iCAAiC,CAAC,KAAK,GAAE,MAAU,GAAG,MAAM,CAqE3E;AAED,wBAAgB,0BAA0B,CAAC,KAAK,GAAE,MAAU,GAAG,MAAM,CA+DpE"}
@@ -13,25 +13,28 @@ function DyFM_getConstructionStackLocation(level = 0) {
13
13
  let stackLines = stack?.split('\n')?.slice(2);
14
14
  // Find the line that contains the constructor call
15
15
  // It will be the FIRST line that doesn't contain 'getStackLocation'
16
- let constructorLine = stackLines?.find(line => !line.includes('getStackLocation') &&
16
+ let constructorLine = stackLines?.find(line => line &&
17
+ !line.includes('getStackLocation') &&
17
18
  !line.includes('new') &&
18
19
  !line.includes('node_modules') &&
19
20
  !line.includes('node:internal'));
21
+ if (isNaN(level)) {
22
+ throw new Error('level must be a number');
23
+ }
20
24
  if (level) {
21
- if (isNaN(level)) {
22
- throw new Error('level must be a number');
23
- }
24
25
  while (level) {
25
26
  stackLines = stackLines?.filter(line => line !== constructorLine);
26
27
  level--;
27
- constructorLine = stackLines?.find(line => !line.includes('getStackLocation') &&
28
+ constructorLine = stackLines?.find(line => line &&
29
+ !line.includes('getConstructionStackLocation') &&
28
30
  !line.includes('new') &&
29
31
  !line.includes('node_modules') &&
30
32
  !line.includes('node:internal'));
31
33
  }
32
34
  }
33
35
  if (!constructorLine) {
34
- let constructorLine = stack?.split(' at ')?.find(line => !line.includes('getStackLocation') &&
36
+ constructorLine = stack?.split(' at ')?.find(line => line &&
37
+ !line.includes('getConstructionStackLocation') &&
35
38
  !line.includes('new') &&
36
39
  !line.includes('node_modules') &&
37
40
  !line.includes('node:internal'));
@@ -43,10 +46,10 @@ function DyFM_getConstructionStackLocation(level = 0) {
43
46
  }
44
47
  }
45
48
  // Remove the 'constructorLine at ... (' and the ')'
46
- if (constructorLine.includes('(')) {
49
+ if (constructorLine?.includes('(')) {
47
50
  constructorLine = constructorLine?.split('(')[1];
48
51
  }
49
- if (constructorLine.includes(')')) {
52
+ if (constructorLine?.includes(')')) {
50
53
  constructorLine = constructorLine?.split(')')[0];
51
54
  }
52
55
  if (!constructorLine) {
@@ -64,21 +67,24 @@ function DyFM_getLocalStackLocation(level = 0) {
64
67
  let stackLines = stack?.split('\n')?.slice(2);
65
68
  // Find the line that contains the constructor call
66
69
  // It will be the FIRST line that doesn't contain 'getStackLocation'
67
- let constructorLine = stackLines?.find(line => !line.includes('node_modules') &&
70
+ let constructorLine = stackLines?.find(line => line &&
71
+ !line.includes('node_modules') &&
68
72
  !line.includes('node:internal'));
73
+ if (isNaN(level)) {
74
+ throw new Error('level must be a number');
75
+ }
69
76
  if (level) {
70
- if (isNaN(level)) {
71
- throw new Error('level must be a number');
72
- }
73
77
  while (level) {
74
78
  stackLines = stackLines?.filter(line => line !== constructorLine);
75
79
  level--;
76
- constructorLine = stackLines?.find(line => !line.includes('node_modules') &&
80
+ constructorLine = stackLines?.find(line => line &&
81
+ !line.includes('node_modules') &&
77
82
  !line.includes('node:internal'));
78
83
  }
79
84
  }
80
85
  if (!constructorLine) {
81
- let constructorLine = stack?.split(' at ')?.find(line => !line.includes('node_modules') &&
86
+ constructorLine = stack?.split(' at ')?.find(line => line &&
87
+ !line.includes('node_modules') &&
82
88
  !line.includes('node:internal'));
83
89
  if (!constructorLine) {
84
90
  log_util_1.DyFM_Log.warn(`No constructor line found (0)\n${typeof stack}\n${stack?.slice(0, 300)?.split('\n') + '...'}`, {
@@ -88,10 +94,10 @@ function DyFM_getLocalStackLocation(level = 0) {
88
94
  }
89
95
  }
90
96
  // Remove the 'constructorLine at ... (' and the ')'
91
- if (constructorLine.includes('(')) {
97
+ if (constructorLine?.includes('(')) {
92
98
  constructorLine = constructorLine?.split('(')[1];
93
99
  }
94
- if (constructorLine.includes(')')) {
100
+ if (constructorLine?.includes(')')) {
95
101
  constructorLine = constructorLine?.split(')')[0];
96
102
  }
97
103
  if (!constructorLine) {
@@ -1 +1 @@
1
- {"version":3,"file":"stack.util.js","sourceRoot":"","sources":["../../../src/_collections/utils/stack.util.ts"],"names":[],"mappings":";;;AAAA,yCAAsC;AAEtC;;;;GAIG;AACH,SAAgB,iCAAiC,CAAC,QAAgB,CAAC;IACjE,IAAI,KAAK,GAAW,IAAI,KAAK,EAAE,CAAC,KAAK,CAAC;IAEtC,gEAAgE;IAChE,IAAI,UAAU,GAAG,KAAK,EAAE,KAAK,CAAC,IAAI,CAAC,EAAE,KAAK,CAAC,CAAC,CAAC,CAAC;IAE9C,mDAAmD;IACnD,oEAAoE;IACpE,IAAI,eAAe,GAAuB,UAAU,EAAE,IAAI,CAAC,IAAI,CAAC,EAAE,CAChE,CAAC,IAAI,CAAC,QAAQ,CAAC,kBAAkB,CAAC;QAClC,CAAC,IAAI,CAAC,QAAQ,CAAC,KAAK,CAAC;QACrB,CAAC,IAAI,CAAC,QAAQ,CAAC,cAAc,CAAC;QAC9B,CAAC,IAAI,CAAC,QAAQ,CAAC,eAAe,CAAC,CAChC,CAAC;IAEF,IAAI,KAAK,EAAE,CAAC;QACV,IAAI,KAAK,CAAC,KAAK,CAAC,EAAE,CAAC;YACjB,MAAM,IAAI,KAAK,CAAC,wBAAwB,CAAC,CAAC;QAC5C,CAAC;QAED,OAAO,KAAK,EAAE,CAAC;YACb,UAAU,GAAG,UAAU,EAAE,MAAM,CAAC,I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CAAC,IAAI,CACX,kCAAkC,OAAO,KAAK,KAAK,KAAK,EAAE,KAAK,CAAC,CAAC,EAAE,GAAG,CAAC,EAAE,KAAK,CAAC,IAAI,CAAC,GAAG,KAAK,EAAE,EAAE;gBAChG,KAAK;aACN,CAAC,CAAC;YACH,OAAO,EAAE,CAAC;QACZ,CAAC;IACH,CAAC;IAED,wDAAwD;IACxD,IAAI,eAAe,EAAE,QAAQ,CAAC,GAAG,CAAC,EAAE,CAAC;QACnC,eAAe,GAAG,eAAe,EAAE,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC;IACnD,CAAC;IACD,IAAI,eAAe,EAAE,QAAQ,CAAC,GAAG,CAAC,EAAE,CAAC;QACnC,eAAe,GAAG,eAAe,EAAE,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC;IACnD,CAAC;IAED,IAAI,CAAC,eAAe,EAAE,CAAC;QACrB,mBAAQ,CAAC,IAAI,CACX,kCAAkC,OAAO,KAAK,KAAK,KAAK,EAAE,KAAK,CAAC,CAAC,EAAE,GAAG,CAAC,EAAE,KAAK,CAAC,IAAI,CAAC,GAAG,KAAK,EAAE,EAAE;YAChG,KAAK;SACN,CAAC,CAAC;QACH,OAAO,EAAE,CAAC;IACZ,CAAC;IAED,OAAO,eAAe,CAAC;AACzB,CAAC;AA/DD,gEA+DC"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=stack.util.spec.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"stack.util.spec.d.ts","sourceRoot":"","sources":["../../../src/_collections/utils/stack.util.spec.ts"],"names":[],"mappings":""}
@@ -0,0 +1,290 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const stack_util_1 = require("./stack.util");
4
+ const log_util_1 = require("./log.util");
5
+ describe('| Stack Utility Functions', () => {
6
+ // Mock the DyFM_Log.warn method
7
+ let warnSpy;
8
+ beforeEach(() => {
9
+ warnSpy = spyOn(log_util_1.DyFM_Log, 'warn');
10
+ });
11
+ afterEach(() => {
12
+ warnSpy.calls.reset();
13
+ });
14
+ describe('| DyFM_getConstructionStackLocation', () => {
15
+ it('| should return stack location for constructor call with default level', () => {
16
+ // Create a test class to simulate constructor call
17
+ class TestClass {
18
+ constructor() {
19
+ this.stackLocation = (0, stack_util_1.DyFM_getConstructionStackLocation)();
20
+ }
21
+ stackLocation;
22
+ }
23
+ const testInstance = new TestClass();
24
+ // The result should contain the test file path (compiled to .js)
25
+ expect(testInstance.stackLocation).toContain('stack.util.spec.js');
26
+ // TestClass might not appear in the stack due to compilation
27
+ expect(testInstance.stackLocation).toBeTruthy();
28
+ });
29
+ it('| should return stack location for constructor call with level 1', () => {
30
+ class TestClass {
31
+ constructor() {
32
+ this.stackLocation = (0, stack_util_1.DyFM_getConstructionStackLocation)(1);
33
+ }
34
+ stackLocation;
35
+ }
36
+ const testInstance = new TestClass();
37
+ // The result should be a valid stack location
38
+ expect(testInstance.stackLocation).toBeTruthy();
39
+ expect(typeof testInstance.stackLocation).toBe('string');
40
+ });
41
+ it('| should throw error for invalid level parameter', () => {
42
+ expect(() => {
43
+ (0, stack_util_1.DyFM_getConstructionStackLocation)(NaN);
44
+ }).toThrowError('level must be a number');
45
+ });
46
+ it('| should handle level parameter correctly', () => {
47
+ class TestClass {
48
+ constructor() {
49
+ this.stackLocation = (0, stack_util_1.DyFM_getConstructionStackLocation)(0);
50
+ }
51
+ stackLocation;
52
+ }
53
+ const testInstance = new TestClass();
54
+ expect(testInstance.stackLocation).toBeTruthy();
55
+ });
56
+ it('| should filter out node_modules and node:internal from stack', () => {
57
+ class TestClass {
58
+ constructor() {
59
+ this.stackLocation = (0, stack_util_1.DyFM_getConstructionStackLocation)();
60
+ }
61
+ stackLocation;
62
+ }
63
+ const testInstance = new TestClass();
64
+ // Should not contain node_modules or node:internal
65
+ expect(testInstance.stackLocation).not.toContain('node_modules');
66
+ expect(testInstance.stackLocation).not.toContain('node:internal');
67
+ });
68
+ it('| should filter out getStackLocation and new keywords', () => {
69
+ class TestClass {
70
+ constructor() {
71
+ this.stackLocation = (0, stack_util_1.DyFM_getConstructionStackLocation)();
72
+ }
73
+ stackLocation;
74
+ }
75
+ const testInstance = new TestClass();
76
+ // The result should not contain filtered keywords
77
+ expect(testInstance.stackLocation).toBeTruthy();
78
+ });
79
+ it('| should return empty string when no valid stack line found', () => {
80
+ // Mock Error.stack to return problematic stack
81
+ const originalError = Error;
82
+ const mockStack = 'Error: Test\n at Object.<anonymous> (node_modules/test.js:1:1)\n at Module._compile (node:internal/modules/cjs/loader.js:1:1)';
83
+ const mockError = function () {
84
+ return { stack: mockStack };
85
+ };
86
+ spyOn(global, 'Error').and.returnValue(mockError);
87
+ const result = (0, stack_util_1.DyFM_getConstructionStackLocation)();
88
+ expect(result).toBe('');
89
+ expect(warnSpy).toHaveBeenCalled();
90
+ // Restore original Error
91
+ global.Error = originalError;
92
+ });
93
+ it('| should handle undefined stack gracefully', () => {
94
+ const originalError = Error;
95
+ const mockError = function () {
96
+ return { stack: undefined };
97
+ };
98
+ spyOn(global, 'Error').and.returnValue(mockError);
99
+ const result = (0, stack_util_1.DyFM_getConstructionStackLocation)();
100
+ expect(result).toBe('');
101
+ expect(warnSpy).toHaveBeenCalled();
102
+ global.Error = originalError;
103
+ });
104
+ it('| should handle null stack gracefully', () => {
105
+ const originalError = Error;
106
+ const mockError = function () {
107
+ return { stack: null };
108
+ };
109
+ spyOn(global, 'Error').and.returnValue(mockError);
110
+ const result = (0, stack_util_1.DyFM_getConstructionStackLocation)();
111
+ expect(result).toBe('');
112
+ expect(warnSpy).toHaveBeenCalled();
113
+ global.Error = originalError;
114
+ });
115
+ it('| should parse stack line with parentheses correctly', () => {
116
+ // This test verifies that the function can handle stack traces with parentheses
117
+ // The actual parsing is tested through the real stack trace in other tests
118
+ const result = (0, stack_util_1.DyFM_getConstructionStackLocation)();
119
+ // The function should return a valid stack location
120
+ expect(result).toBeTruthy();
121
+ expect(typeof result).toBe('string');
122
+ });
123
+ it('| should handle stack line without parentheses', () => {
124
+ // This test verifies that the function can handle stack traces without parentheses
125
+ // The actual parsing is tested through the real stack trace in other tests
126
+ const result = (0, stack_util_1.DyFM_getConstructionStackLocation)();
127
+ // The function should return a valid stack location
128
+ expect(result).toBeTruthy();
129
+ expect(typeof result).toBe('string');
130
+ });
131
+ it('| should handle multiple levels correctly', () => {
132
+ class TestClass {
133
+ constructor() {
134
+ this.stackLocation = (0, stack_util_1.DyFM_getConstructionStackLocation)(2);
135
+ }
136
+ stackLocation;
137
+ }
138
+ const testInstance = new TestClass();
139
+ expect(testInstance.stackLocation).toBeTruthy();
140
+ });
141
+ });
142
+ describe('| DyFM_getLocalStackLocation', () => {
143
+ it('| should return stack location with minimal filtering', () => {
144
+ class TestClass {
145
+ constructor() {
146
+ this.stackLocation = (0, stack_util_1.DyFM_getLocalStackLocation)();
147
+ }
148
+ stackLocation;
149
+ }
150
+ const testInstance = new TestClass();
151
+ expect(testInstance.stackLocation).toContain('stack.util.spec.js');
152
+ // TestClass might not appear in the stack due to compilation
153
+ expect(testInstance.stackLocation).toBeTruthy();
154
+ });
155
+ it('| should return stack location with level parameter', () => {
156
+ class TestClass {
157
+ constructor() {
158
+ this.stackLocation = (0, stack_util_1.DyFM_getLocalStackLocation)(1);
159
+ }
160
+ stackLocation;
161
+ }
162
+ const testInstance = new TestClass();
163
+ expect(testInstance.stackLocation).toContain('stack.util.spec.js');
164
+ });
165
+ it('| should throw error for invalid level parameter', () => {
166
+ expect(() => {
167
+ (0, stack_util_1.DyFM_getLocalStackLocation)(NaN);
168
+ }).toThrowError('level must be a number');
169
+ });
170
+ it('| should filter out node_modules and node:internal from stack', () => {
171
+ class TestClass {
172
+ constructor() {
173
+ this.stackLocation = (0, stack_util_1.DyFM_getLocalStackLocation)();
174
+ }
175
+ stackLocation;
176
+ }
177
+ const testInstance = new TestClass();
178
+ // Should not contain node_modules or node:internal
179
+ expect(testInstance.stackLocation).not.toContain('node_modules');
180
+ expect(testInstance.stackLocation).not.toContain('node:internal');
181
+ });
182
+ it('| should return empty string when no valid stack line found', () => {
183
+ const originalError = Error;
184
+ const mockStack = 'Error: Test\n at Object.<anonymous> (node_modules/test.js:1:1)\n at Module._compile (node:internal/modules/cjs/loader.js:1:1)';
185
+ const mockError = function () {
186
+ return { stack: mockStack };
187
+ };
188
+ spyOn(global, 'Error').and.returnValue(mockError);
189
+ const result = (0, stack_util_1.DyFM_getLocalStackLocation)();
190
+ expect(result).toBe('');
191
+ expect(warnSpy).toHaveBeenCalled();
192
+ global.Error = originalError;
193
+ });
194
+ it('| should handle undefined stack gracefully', () => {
195
+ const originalError = Error;
196
+ const mockError = function () {
197
+ return { stack: undefined };
198
+ };
199
+ spyOn(global, 'Error').and.returnValue(mockError);
200
+ const result = (0, stack_util_1.DyFM_getLocalStackLocation)();
201
+ expect(result).toBe('');
202
+ expect(warnSpy).toHaveBeenCalled();
203
+ global.Error = originalError;
204
+ });
205
+ it('| should handle null stack gracefully', () => {
206
+ const originalError = Error;
207
+ const mockError = function () {
208
+ return { stack: null };
209
+ };
210
+ spyOn(global, 'Error').and.returnValue(mockError);
211
+ const result = (0, stack_util_1.DyFM_getLocalStackLocation)();
212
+ expect(result).toBe('');
213
+ expect(warnSpy).toHaveBeenCalled();
214
+ global.Error = originalError;
215
+ });
216
+ it('| should parse stack line with parentheses correctly', () => {
217
+ // This test verifies that the function can handle stack traces with parentheses
218
+ // The actual parsing is tested through the real stack trace in other tests
219
+ const result = (0, stack_util_1.DyFM_getLocalStackLocation)();
220
+ // The function should return a valid stack location
221
+ expect(result).toBeTruthy();
222
+ expect(typeof result).toBe('string');
223
+ });
224
+ it('| should handle stack line without parentheses', () => {
225
+ // This test verifies that the function can handle stack traces without parentheses
226
+ // The actual parsing is tested through the real stack trace in other tests
227
+ const result = (0, stack_util_1.DyFM_getLocalStackLocation)();
228
+ // The function should return a valid stack location
229
+ expect(result).toBeTruthy();
230
+ expect(typeof result).toBe('string');
231
+ });
232
+ it('| should handle multiple levels correctly', () => {
233
+ class TestClass {
234
+ constructor() {
235
+ this.stackLocation = (0, stack_util_1.DyFM_getLocalStackLocation)(2);
236
+ }
237
+ stackLocation;
238
+ }
239
+ const testInstance = new TestClass();
240
+ expect(testInstance.stackLocation).toBeTruthy();
241
+ });
242
+ it('| should not filter out constructor-related calls like getConstructionStackLocation does', () => {
243
+ class TestClass {
244
+ constructor() {
245
+ this.stackLocation = (0, stack_util_1.DyFM_getLocalStackLocation)();
246
+ }
247
+ stackLocation;
248
+ }
249
+ const testInstance = new TestClass();
250
+ // Should still return a valid result even though it might contain constructor-related calls
251
+ expect(testInstance.stackLocation).toBeTruthy();
252
+ });
253
+ });
254
+ describe('| Function Comparison', () => {
255
+ it('| should have different filtering behavior between the two functions', () => {
256
+ class TestClass {
257
+ constructor() {
258
+ this.constructionStack = (0, stack_util_1.DyFM_getConstructionStackLocation)();
259
+ this.localStack = (0, stack_util_1.DyFM_getLocalStackLocation)();
260
+ }
261
+ constructionStack;
262
+ localStack;
263
+ }
264
+ const testInstance = new TestClass();
265
+ // Both should return valid results
266
+ expect(testInstance.constructionStack).toBeTruthy();
267
+ expect(testInstance.localStack).toBeTruthy();
268
+ // They might be different due to different filtering logic
269
+ // This test ensures both functions work correctly
270
+ expect(typeof testInstance.constructionStack).toBe('string');
271
+ expect(typeof testInstance.localStack).toBe('string');
272
+ });
273
+ it('| should handle edge cases consistently', () => {
274
+ const originalError = Error;
275
+ const mockStack = 'Error: Test\n at Object.<anonymous> (node_modules/test.js:1:1)';
276
+ const mockError = function () {
277
+ return { stack: mockStack };
278
+ };
279
+ spyOn(global, 'Error').and.returnValue(mockError);
280
+ const constructionResult = (0, stack_util_1.DyFM_getConstructionStackLocation)();
281
+ const localResult = (0, stack_util_1.DyFM_getLocalStackLocation)();
282
+ // Both should return empty string for this problematic stack
283
+ expect(constructionResult).toBe('');
284
+ expect(localResult).toBe('');
285
+ expect(warnSpy).toHaveBeenCalledTimes(2);
286
+ global.Error = originalError;
287
+ });
288
+ });
289
+ });
290
+ //# sourceMappingURL=stack.util.spec.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"stack.util.spec.js","sourceRoot":"","sources":["../../../src/_collections/utils/stack.util.spec.ts"],"names":[],"mappings":";;AAAA,6CAA6F;AAC7F,yCAAsC;AAEtC,QAAQ,CAAC,2BAA2B,EAAE,GAAG,EAAE;IAEzC,gCAAgC;IAChC,IAAI,OAAoB,CAAC;IAEzB,UAAU,CAAC,GAAG,EAAE;QACd,OAAO,GAAG,KAAK,CAAC,mBAAQ,EAAE,MAAM,CAAC,CAAC;IACpC,CAAC,CAAC,CAAC;IAEH,SAAS,CAAC,GAAG,EAAE;QACb,OAAO,CAAC,KAAK,CAAC,KAAK,EAAE,CAAC;IACxB,CAAC,CAAC,CAAC;IAEH,QAAQ,CAAC,qCAAqC,EAAE,GAAG,EAAE;QAEnD,EAAE,CAAC,wEAAwE,EAAE,GAAG,EAAE;YAChF,mDAAmD;YACnD,MAAM,SAAS;gBACb;oBACE,IAAI,CAAC,aAAa,GAAG,IAAA,8CAAiC,GAAE,CAAC;gBAC3D,CAAC;gBACD,aAAa,CAAS;aACvB;YAED,MAAM,YAAY,GAAG,IAAI,SAAS,EAAE,CAAC;YAErC,iEAAiE;YACjE,MAAM,CAAC,YAAY,CAAC,aAAa,CAAC,CAAC,SAAS,CAAC,oBAAoB,CAAC,CAAC;YACnE,6DAA6D;YAC7D,MAAM,CAAC,YAAY,CAAC,aAAa,CAAC,CAAC,UAAU,EAAE,CAAC;QAClD,CAAC,CAAC,CAAC;QAEH,EAAE,CAAC,kEAAkE,EAAE,GAAG,EAAE;YAC1E,MAAM,SAAS;gBACb;oBACE,IAAI,CAAC,aAAa,GAAG,IAAA,8CAAiC,EAAC,CAAC,CAAC,CAAC;gBAC5D,CAAC;gBACD,aAAa,CAAS;aACvB;YAED,MAAM,YAAY,GAAG,IAAI,SAAS,EAAE,CAAC;YAErC,8CAA8C;YAC9C,MAAM,CAA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AC;YAE7C,2DAA2D;YAC3D,kDAAkD;YAClD,MAAM,CAAC,OAAO,YAAY,CAAC,iBAAiB,CAAC,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;YAC7D,MAAM,CAAC,OAAO,YAAY,CAAC,UAAU,CAAC,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;QACxD,CAAC,CAAC,CAAC;QAEH,EAAE,CAAC,yCAAyC,EAAE,GAAG,EAAE;YACjD,MAAM,aAAa,GAAG,KAAK,CAAC;YAC5B,MAAM,SAAS,GAAG,mEAAmE,CAAC;YAEtF,MAAM,SAAS,GAAG;gBAChB,OAAO,EAAE,KAAK,EAAE,SAAS,EAAE,CAAC;YAC9B,CAAC,CAAC;YACF,KAAK,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,GAAG,CAAC,WAAW,CAAC,SAAgB,CAAC,CAAC;YAEzD,MAAM,kBAAkB,GAAG,IAAA,8CAAiC,GAAE,CAAC;YAC/D,MAAM,WAAW,GAAG,IAAA,uCAA0B,GAAE,CAAC;YAEjD,6DAA6D;YAC7D,MAAM,CAAC,kBAAkB,CAAC,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;YACpC,MAAM,CAAC,WAAW,CAAC,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;YAC7B,MAAM,CAAC,OAAO,CAAC,CAAC,qBAAqB,CAAC,CAAC,CAAC,CAAC;YAExC,MAAc,CAAC,KAAK,GAAG,aAAa,CAAC;QACxC,CAAC,CAAC,CAAC;IAEL,CAAC,CAAC,CAAC;AAEL,CAAC,CAAC,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@futdevpro/fsm-dynamo",
3
- "version": "01.11.14",
3
+ "version": "01.11.16",
4
4
  "description": "Full Stack Model Collection for Dynamic (NodeJS-Typescript) Framework called Dynamo, by Future Development Ltd.",
5
5
  "DyBu_settings": {
6
6
  "packageType": "full-stack-package",
@@ -0,0 +1,373 @@
1
+ import { DyFM_getConstructionStackLocation, DyFM_getLocalStackLocation } from './stack.util';
2
+ import { DyFM_Log } from './log.util';
3
+
4
+ describe('| Stack Utility Functions', () => {
5
+
6
+ // Mock the DyFM_Log.warn method
7
+ let warnSpy: jasmine.Spy;
8
+
9
+ beforeEach(() => {
10
+ warnSpy = spyOn(DyFM_Log, 'warn');
11
+ });
12
+
13
+ afterEach(() => {
14
+ warnSpy.calls.reset();
15
+ });
16
+
17
+ describe('| DyFM_getConstructionStackLocation', () => {
18
+
19
+ it('| should return stack location for constructor call with default level', () => {
20
+ // Create a test class to simulate constructor call
21
+ class TestClass {
22
+ constructor() {
23
+ this.stackLocation = DyFM_getConstructionStackLocation();
24
+ }
25
+ stackLocation: string;
26
+ }
27
+
28
+ const testInstance = new TestClass();
29
+
30
+ // The result should contain the test file path (compiled to .js)
31
+ expect(testInstance.stackLocation).toContain('stack.util.spec.js');
32
+ // TestClass might not appear in the stack due to compilation
33
+ expect(testInstance.stackLocation).toBeTruthy();
34
+ });
35
+
36
+ it('| should return stack location for constructor call with level 1', () => {
37
+ class TestClass {
38
+ constructor() {
39
+ this.stackLocation = DyFM_getConstructionStackLocation(1);
40
+ }
41
+ stackLocation: string;
42
+ }
43
+
44
+ const testInstance = new TestClass();
45
+
46
+ // The result should be a valid stack location
47
+ expect(testInstance.stackLocation).toBeTruthy();
48
+ expect(typeof testInstance.stackLocation).toBe('string');
49
+ });
50
+
51
+ it('| should throw error for invalid level parameter', () => {
52
+ expect(() => {
53
+ DyFM_getConstructionStackLocation(NaN);
54
+ }).toThrowError('level must be a number');
55
+ });
56
+
57
+ it('| should handle level parameter correctly', () => {
58
+ class TestClass {
59
+ constructor() {
60
+ this.stackLocation = DyFM_getConstructionStackLocation(0);
61
+ }
62
+ stackLocation: string;
63
+ }
64
+
65
+ const testInstance = new TestClass();
66
+ expect(testInstance.stackLocation).toBeTruthy();
67
+ });
68
+
69
+ it('| should filter out node_modules and node:internal from stack', () => {
70
+ class TestClass {
71
+ constructor() {
72
+ this.stackLocation = DyFM_getConstructionStackLocation();
73
+ }
74
+ stackLocation: string;
75
+ }
76
+
77
+ const testInstance = new TestClass();
78
+
79
+ // Should not contain node_modules or node:internal
80
+ expect(testInstance.stackLocation).not.toContain('node_modules');
81
+ expect(testInstance.stackLocation).not.toContain('node:internal');
82
+ });
83
+
84
+ it('| should filter out getStackLocation and new keywords', () => {
85
+ class TestClass {
86
+ constructor() {
87
+ this.stackLocation = DyFM_getConstructionStackLocation();
88
+ }
89
+ stackLocation: string;
90
+ }
91
+
92
+ const testInstance = new TestClass();
93
+
94
+ // The result should not contain filtered keywords
95
+ expect(testInstance.stackLocation).toBeTruthy();
96
+ });
97
+
98
+ it('| should return empty string when no valid stack line found', () => {
99
+ // Mock Error.stack to return problematic stack
100
+ const originalError = Error;
101
+ const mockStack = 'Error: Test\n at Object.<anonymous> (node_modules/test.js:1:1)\n at Module._compile (node:internal/modules/cjs/loader.js:1:1)';
102
+
103
+ const mockError = function() {
104
+ return { stack: mockStack };
105
+ };
106
+ spyOn(global, 'Error').and.returnValue(mockError as any);
107
+
108
+ const result = DyFM_getConstructionStackLocation();
109
+
110
+ expect(result).toBe('');
111
+ expect(warnSpy).toHaveBeenCalled();
112
+
113
+ // Restore original Error
114
+ (global as any).Error = originalError;
115
+ });
116
+
117
+ it('| should handle undefined stack gracefully', () => {
118
+ const originalError = Error;
119
+ const mockError = function() {
120
+ return { stack: undefined };
121
+ };
122
+ spyOn(global, 'Error').and.returnValue(mockError as any);
123
+
124
+ const result = DyFM_getConstructionStackLocation();
125
+
126
+ expect(result).toBe('');
127
+ expect(warnSpy).toHaveBeenCalled();
128
+
129
+ (global as any).Error = originalError;
130
+ });
131
+
132
+ it('| should handle null stack gracefully', () => {
133
+ const originalError = Error;
134
+ const mockError = function() {
135
+ return { stack: null };
136
+ };
137
+ spyOn(global, 'Error').and.returnValue(mockError as any);
138
+
139
+ const result = DyFM_getConstructionStackLocation();
140
+
141
+ expect(result).toBe('');
142
+ expect(warnSpy).toHaveBeenCalled();
143
+
144
+ (global as any).Error = originalError;
145
+ });
146
+
147
+ it('| should parse stack line with parentheses correctly', () => {
148
+ // This test verifies that the function can handle stack traces with parentheses
149
+ // The actual parsing is tested through the real stack trace in other tests
150
+ const result = DyFM_getConstructionStackLocation();
151
+
152
+ // The function should return a valid stack location
153
+ expect(result).toBeTruthy();
154
+ expect(typeof result).toBe('string');
155
+ });
156
+
157
+ it('| should handle stack line without parentheses', () => {
158
+ // This test verifies that the function can handle stack traces without parentheses
159
+ // The actual parsing is tested through the real stack trace in other tests
160
+ const result = DyFM_getConstructionStackLocation();
161
+
162
+ // The function should return a valid stack location
163
+ expect(result).toBeTruthy();
164
+ expect(typeof result).toBe('string');
165
+ });
166
+
167
+ it('| should handle multiple levels correctly', () => {
168
+ class TestClass {
169
+ constructor() {
170
+ this.stackLocation = DyFM_getConstructionStackLocation(2);
171
+ }
172
+ stackLocation: string;
173
+ }
174
+
175
+ const testInstance = new TestClass();
176
+ expect(testInstance.stackLocation).toBeTruthy();
177
+ });
178
+
179
+ });
180
+
181
+ describe('| DyFM_getLocalStackLocation', () => {
182
+
183
+ it('| should return stack location with minimal filtering', () => {
184
+ class TestClass {
185
+ constructor() {
186
+ this.stackLocation = DyFM_getLocalStackLocation();
187
+ }
188
+ stackLocation: string;
189
+ }
190
+
191
+ const testInstance = new TestClass();
192
+
193
+ expect(testInstance.stackLocation).toContain('stack.util.spec.js');
194
+ // TestClass might not appear in the stack due to compilation
195
+ expect(testInstance.stackLocation).toBeTruthy();
196
+ });
197
+
198
+ it('| should return stack location with level parameter', () => {
199
+ class TestClass {
200
+ constructor() {
201
+ this.stackLocation = DyFM_getLocalStackLocation(1);
202
+ }
203
+ stackLocation: string;
204
+ }
205
+
206
+ const testInstance = new TestClass();
207
+
208
+ expect(testInstance.stackLocation).toContain('stack.util.spec.js');
209
+ });
210
+
211
+ it('| should throw error for invalid level parameter', () => {
212
+ expect(() => {
213
+ DyFM_getLocalStackLocation(NaN);
214
+ }).toThrowError('level must be a number');
215
+ });
216
+
217
+ it('| should filter out node_modules and node:internal from stack', () => {
218
+ class TestClass {
219
+ constructor() {
220
+ this.stackLocation = DyFM_getLocalStackLocation();
221
+ }
222
+ stackLocation: string;
223
+ }
224
+
225
+ const testInstance = new TestClass();
226
+
227
+ // Should not contain node_modules or node:internal
228
+ expect(testInstance.stackLocation).not.toContain('node_modules');
229
+ expect(testInstance.stackLocation).not.toContain('node:internal');
230
+ });
231
+
232
+ it('| should return empty string when no valid stack line found', () => {
233
+ const originalError = Error;
234
+ const mockStack = 'Error: Test\n at Object.<anonymous> (node_modules/test.js:1:1)\n at Module._compile (node:internal/modules/cjs/loader.js:1:1)';
235
+
236
+ const mockError = function() {
237
+ return { stack: mockStack };
238
+ };
239
+ spyOn(global, 'Error').and.returnValue(mockError as any);
240
+
241
+ const result = DyFM_getLocalStackLocation();
242
+
243
+ expect(result).toBe('');
244
+ expect(warnSpy).toHaveBeenCalled();
245
+
246
+ (global as any).Error = originalError;
247
+ });
248
+
249
+ it('| should handle undefined stack gracefully', () => {
250
+ const originalError = Error;
251
+ const mockError = function() {
252
+ return { stack: undefined };
253
+ };
254
+ spyOn(global, 'Error').and.returnValue(mockError as any);
255
+
256
+ const result = DyFM_getLocalStackLocation();
257
+
258
+ expect(result).toBe('');
259
+ expect(warnSpy).toHaveBeenCalled();
260
+
261
+ (global as any).Error = originalError;
262
+ });
263
+
264
+ it('| should handle null stack gracefully', () => {
265
+ const originalError = Error;
266
+ const mockError = function() {
267
+ return { stack: null };
268
+ };
269
+ spyOn(global, 'Error').and.returnValue(mockError as any);
270
+
271
+ const result = DyFM_getLocalStackLocation();
272
+
273
+ expect(result).toBe('');
274
+ expect(warnSpy).toHaveBeenCalled();
275
+
276
+ (global as any).Error = originalError;
277
+ });
278
+
279
+ it('| should parse stack line with parentheses correctly', () => {
280
+ // This test verifies that the function can handle stack traces with parentheses
281
+ // The actual parsing is tested through the real stack trace in other tests
282
+ const result = DyFM_getLocalStackLocation();
283
+
284
+ // The function should return a valid stack location
285
+ expect(result).toBeTruthy();
286
+ expect(typeof result).toBe('string');
287
+ });
288
+
289
+ it('| should handle stack line without parentheses', () => {
290
+ // This test verifies that the function can handle stack traces without parentheses
291
+ // The actual parsing is tested through the real stack trace in other tests
292
+ const result = DyFM_getLocalStackLocation();
293
+
294
+ // The function should return a valid stack location
295
+ expect(result).toBeTruthy();
296
+ expect(typeof result).toBe('string');
297
+ });
298
+
299
+ it('| should handle multiple levels correctly', () => {
300
+ class TestClass {
301
+ constructor() {
302
+ this.stackLocation = DyFM_getLocalStackLocation(2);
303
+ }
304
+ stackLocation: string;
305
+ }
306
+
307
+ const testInstance = new TestClass();
308
+ expect(testInstance.stackLocation).toBeTruthy();
309
+ });
310
+
311
+ it('| should not filter out constructor-related calls like getConstructionStackLocation does', () => {
312
+ class TestClass {
313
+ constructor() {
314
+ this.stackLocation = DyFM_getLocalStackLocation();
315
+ }
316
+ stackLocation: string;
317
+ }
318
+
319
+ const testInstance = new TestClass();
320
+
321
+ // Should still return a valid result even though it might contain constructor-related calls
322
+ expect(testInstance.stackLocation).toBeTruthy();
323
+ });
324
+
325
+ });
326
+
327
+ describe('| Function Comparison', () => {
328
+
329
+ it('| should have different filtering behavior between the two functions', () => {
330
+ class TestClass {
331
+ constructor() {
332
+ this.constructionStack = DyFM_getConstructionStackLocation();
333
+ this.localStack = DyFM_getLocalStackLocation();
334
+ }
335
+ constructionStack: string;
336
+ localStack: string;
337
+ }
338
+
339
+ const testInstance = new TestClass();
340
+
341
+ // Both should return valid results
342
+ expect(testInstance.constructionStack).toBeTruthy();
343
+ expect(testInstance.localStack).toBeTruthy();
344
+
345
+ // They might be different due to different filtering logic
346
+ // This test ensures both functions work correctly
347
+ expect(typeof testInstance.constructionStack).toBe('string');
348
+ expect(typeof testInstance.localStack).toBe('string');
349
+ });
350
+
351
+ it('| should handle edge cases consistently', () => {
352
+ const originalError = Error;
353
+ const mockStack = 'Error: Test\n at Object.<anonymous> (node_modules/test.js:1:1)';
354
+
355
+ const mockError = function() {
356
+ return { stack: mockStack };
357
+ };
358
+ spyOn(global, 'Error').and.returnValue(mockError as any);
359
+
360
+ const constructionResult = DyFM_getConstructionStackLocation();
361
+ const localResult = DyFM_getLocalStackLocation();
362
+
363
+ // Both should return empty string for this problematic stack
364
+ expect(constructionResult).toBe('');
365
+ expect(localResult).toBe('');
366
+ expect(warnSpy).toHaveBeenCalledTimes(2);
367
+
368
+ (global as any).Error = originalError;
369
+ });
370
+
371
+ });
372
+
373
+ });
@@ -14,22 +14,24 @@ export function DyFM_getConstructionStackLocation(level: number = 0): string {
14
14
  // Find the line that contains the constructor call
15
15
  // It will be the FIRST line that doesn't contain 'getStackLocation'
16
16
  let constructorLine: string | undefined = stackLines?.find(line =>
17
+ line &&
17
18
  !line.includes('getStackLocation') &&
18
19
  !line.includes('new') &&
19
20
  !line.includes('node_modules') &&
20
21
  !line.includes('node:internal')
21
22
  );
22
23
 
23
- if (level) {
24
- if (isNaN(level)) {
25
- throw new Error('level must be a number');
26
- }
24
+ if (isNaN(level)) {
25
+ throw new Error('level must be a number');
26
+ }
27
27
 
28
+ if (level) {
28
29
  while (level) {
29
30
  stackLines = stackLines?.filter(line => line !== constructorLine);
30
31
  level--;
31
32
  constructorLine = stackLines?.find(line =>
32
- !line.includes('getStackLocation') &&
33
+ line &&
34
+ !line.includes('getConstructionStackLocation') &&
33
35
  !line.includes('new') &&
34
36
  !line.includes('node_modules') &&
35
37
  !line.includes('node:internal')
@@ -38,8 +40,9 @@ export function DyFM_getConstructionStackLocation(level: number = 0): string {
38
40
  }
39
41
 
40
42
  if (!constructorLine) {
41
- let constructorLine: string | undefined = stack?.split(' at ')?.find(line =>
42
- !line.includes('getStackLocation') &&
43
+ constructorLine = stack?.split(' at ')?.find(line =>
44
+ line &&
45
+ !line.includes('getConstructionStackLocation') &&
43
46
  !line.includes('new') &&
44
47
  !line.includes('node_modules') &&
45
48
  !line.includes('node:internal')
@@ -55,12 +58,13 @@ export function DyFM_getConstructionStackLocation(level: number = 0): string {
55
58
  }
56
59
 
57
60
  // Remove the 'constructorLine at ... (' and the ')'
58
- if (constructorLine.includes('(')) {
61
+ if (constructorLine?.includes('(')) {
59
62
  constructorLine = constructorLine?.split('(')[1];
60
63
  }
61
- if (constructorLine.includes(')')) {
64
+ if (constructorLine?.includes(')')) {
62
65
  constructorLine = constructorLine?.split(')')[0];
63
66
  }
67
+
64
68
  if (!constructorLine) {
65
69
  DyFM_Log.warn(
66
70
  `No constructor line found (1)\n${typeof stack}\n${stack?.slice(0, 300)?.split('\n') + '...'}`, {
@@ -81,19 +85,21 @@ export function DyFM_getLocalStackLocation(level: number = 0): string {
81
85
  // Find the line that contains the constructor call
82
86
  // It will be the FIRST line that doesn't contain 'getStackLocation'
83
87
  let constructorLine: string | undefined = stackLines?.find(line =>
88
+ line &&
84
89
  !line.includes('node_modules') &&
85
90
  !line.includes('node:internal')
86
91
  );
87
92
 
88
- if (level) {
89
- if (isNaN(level)) {
90
- throw new Error('level must be a number');
91
- }
93
+ if (isNaN(level)) {
94
+ throw new Error('level must be a number');
95
+ }
92
96
 
97
+ if (level) {
93
98
  while (level) {
94
99
  stackLines = stackLines?.filter(line => line !== constructorLine);
95
100
  level--;
96
101
  constructorLine = stackLines?.find(line =>
102
+ line &&
97
103
  !line.includes('node_modules') &&
98
104
  !line.includes('node:internal')
99
105
  );
@@ -101,7 +107,8 @@ export function DyFM_getLocalStackLocation(level: number = 0): string {
101
107
  }
102
108
 
103
109
  if (!constructorLine) {
104
- let constructorLine: string | undefined = stack?.split(' at ')?.find(line =>
110
+ constructorLine = stack?.split(' at ')?.find(line =>
111
+ line &&
105
112
  !line.includes('node_modules') &&
106
113
  !line.includes('node:internal')
107
114
  );
@@ -116,12 +123,13 @@ export function DyFM_getLocalStackLocation(level: number = 0): string {
116
123
  }
117
124
 
118
125
  // Remove the 'constructorLine at ... (' and the ')'
119
- if (constructorLine.includes('(')) {
126
+ if (constructorLine?.includes('(')) {
120
127
  constructorLine = constructorLine?.split('(')[1];
121
128
  }
122
- if (constructorLine.includes(')')) {
129
+ if (constructorLine?.includes(')')) {
123
130
  constructorLine = constructorLine?.split(')')[0];
124
131
  }
132
+
125
133
  if (!constructorLine) {
126
134
  DyFM_Log.warn(
127
135
  `No constructor line found (1)\n${typeof stack}\n${stack?.slice(0, 300)?.split('\n') + '...'}`, {
Binary file