@futdevpro/fsm-dynamo 1.11.15 → 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.
- package/build/_collections/utils/stack.util.js +13 -13
- package/build/_collections/utils/stack.util.js.map +1 -1
- package/build/_collections/utils/stack.util.spec.d.ts +2 -0
- package/build/_collections/utils/stack.util.spec.d.ts.map +1 -0
- package/build/_collections/utils/stack.util.spec.js +290 -0
- package/build/_collections/utils/stack.util.spec.js.map +1 -0
- package/futdevpro-fsm-dynamo-01.11.16.tgz +0 -0
- package/package.json +1 -1
- package/src/_collections/utils/stack.util.spec.ts +373 -0
- package/src/_collections/utils/stack.util.ts +15 -15
- package/futdevpro-fsm-dynamo-01.11.15.tgz +0 -0
|
@@ -18,23 +18,23 @@ function DyFM_getConstructionStackLocation(level = 0) {
|
|
|
18
18
|
!line.includes('new') &&
|
|
19
19
|
!line.includes('node_modules') &&
|
|
20
20
|
!line.includes('node:internal'));
|
|
21
|
+
if (isNaN(level)) {
|
|
22
|
+
throw new Error('level must be a number');
|
|
23
|
+
}
|
|
21
24
|
if (level) {
|
|
22
|
-
if (isNaN(level)) {
|
|
23
|
-
throw new Error('level must be a number');
|
|
24
|
-
}
|
|
25
25
|
while (level) {
|
|
26
26
|
stackLines = stackLines?.filter(line => line !== constructorLine);
|
|
27
27
|
level--;
|
|
28
28
|
constructorLine = stackLines?.find(line => line &&
|
|
29
|
-
!line.includes('
|
|
29
|
+
!line.includes('getConstructionStackLocation') &&
|
|
30
30
|
!line.includes('new') &&
|
|
31
31
|
!line.includes('node_modules') &&
|
|
32
32
|
!line.includes('node:internal'));
|
|
33
33
|
}
|
|
34
34
|
}
|
|
35
35
|
if (!constructorLine) {
|
|
36
|
-
|
|
37
|
-
!line.includes('
|
|
36
|
+
constructorLine = stack?.split(' at ')?.find(line => line &&
|
|
37
|
+
!line.includes('getConstructionStackLocation') &&
|
|
38
38
|
!line.includes('new') &&
|
|
39
39
|
!line.includes('node_modules') &&
|
|
40
40
|
!line.includes('node:internal'));
|
|
@@ -46,10 +46,10 @@ function DyFM_getConstructionStackLocation(level = 0) {
|
|
|
46
46
|
}
|
|
47
47
|
}
|
|
48
48
|
// Remove the 'constructorLine at ... (' and the ')'
|
|
49
|
-
if (constructorLine
|
|
49
|
+
if (constructorLine?.includes('(')) {
|
|
50
50
|
constructorLine = constructorLine?.split('(')[1];
|
|
51
51
|
}
|
|
52
|
-
if (constructorLine
|
|
52
|
+
if (constructorLine?.includes(')')) {
|
|
53
53
|
constructorLine = constructorLine?.split(')')[0];
|
|
54
54
|
}
|
|
55
55
|
if (!constructorLine) {
|
|
@@ -70,10 +70,10 @@ function DyFM_getLocalStackLocation(level = 0) {
|
|
|
70
70
|
let constructorLine = stackLines?.find(line => line &&
|
|
71
71
|
!line.includes('node_modules') &&
|
|
72
72
|
!line.includes('node:internal'));
|
|
73
|
+
if (isNaN(level)) {
|
|
74
|
+
throw new Error('level must be a number');
|
|
75
|
+
}
|
|
73
76
|
if (level) {
|
|
74
|
-
if (isNaN(level)) {
|
|
75
|
-
throw new Error('level must be a number');
|
|
76
|
-
}
|
|
77
77
|
while (level) {
|
|
78
78
|
stackLines = stackLines?.filter(line => line !== constructorLine);
|
|
79
79
|
level--;
|
|
@@ -94,10 +94,10 @@ function DyFM_getLocalStackLocation(level = 0) {
|
|
|
94
94
|
}
|
|
95
95
|
}
|
|
96
96
|
// Remove the 'constructorLine at ... (' and the ')'
|
|
97
|
-
if (constructorLine
|
|
97
|
+
if (constructorLine?.includes('(')) {
|
|
98
98
|
constructorLine = constructorLine?.split('(')[1];
|
|
99
99
|
}
|
|
100
|
-
if (constructorLine
|
|
100
|
+
if (constructorLine?.includes(')')) {
|
|
101
101
|
constructorLine = constructorLine?.split(')')[0];
|
|
102
102
|
}
|
|
103
103
|
if (!constructorLine) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"stack.util.js","sourceRoot":"","sources":["../../../src/_collections/utils/stack.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AC,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 @@
|
|
|
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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binary file
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@futdevpro/fsm-dynamo",
|
|
3
|
-
"version": "01.11.
|
|
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
|
+
});
|
|
@@ -21,17 +21,17 @@ export function DyFM_getConstructionStackLocation(level: number = 0): string {
|
|
|
21
21
|
!line.includes('node:internal')
|
|
22
22
|
);
|
|
23
23
|
|
|
24
|
-
if (level) {
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
}
|
|
24
|
+
if (isNaN(level)) {
|
|
25
|
+
throw new Error('level must be a number');
|
|
26
|
+
}
|
|
28
27
|
|
|
28
|
+
if (level) {
|
|
29
29
|
while (level) {
|
|
30
30
|
stackLines = stackLines?.filter(line => line !== constructorLine);
|
|
31
31
|
level--;
|
|
32
32
|
constructorLine = stackLines?.find(line =>
|
|
33
33
|
line &&
|
|
34
|
-
!line.includes('
|
|
34
|
+
!line.includes('getConstructionStackLocation') &&
|
|
35
35
|
!line.includes('new') &&
|
|
36
36
|
!line.includes('node_modules') &&
|
|
37
37
|
!line.includes('node:internal')
|
|
@@ -40,9 +40,9 @@ export function DyFM_getConstructionStackLocation(level: number = 0): string {
|
|
|
40
40
|
}
|
|
41
41
|
|
|
42
42
|
if (!constructorLine) {
|
|
43
|
-
|
|
43
|
+
constructorLine = stack?.split(' at ')?.find(line =>
|
|
44
44
|
line &&
|
|
45
|
-
!line.includes('
|
|
45
|
+
!line.includes('getConstructionStackLocation') &&
|
|
46
46
|
!line.includes('new') &&
|
|
47
47
|
!line.includes('node_modules') &&
|
|
48
48
|
!line.includes('node:internal')
|
|
@@ -58,10 +58,10 @@ export function DyFM_getConstructionStackLocation(level: number = 0): string {
|
|
|
58
58
|
}
|
|
59
59
|
|
|
60
60
|
// Remove the 'constructorLine at ... (' and the ')'
|
|
61
|
-
if (constructorLine
|
|
61
|
+
if (constructorLine?.includes('(')) {
|
|
62
62
|
constructorLine = constructorLine?.split('(')[1];
|
|
63
63
|
}
|
|
64
|
-
if (constructorLine
|
|
64
|
+
if (constructorLine?.includes(')')) {
|
|
65
65
|
constructorLine = constructorLine?.split(')')[0];
|
|
66
66
|
}
|
|
67
67
|
|
|
@@ -90,11 +90,11 @@ export function DyFM_getLocalStackLocation(level: number = 0): string {
|
|
|
90
90
|
!line.includes('node:internal')
|
|
91
91
|
);
|
|
92
92
|
|
|
93
|
-
if (level) {
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
}
|
|
93
|
+
if (isNaN(level)) {
|
|
94
|
+
throw new Error('level must be a number');
|
|
95
|
+
}
|
|
97
96
|
|
|
97
|
+
if (level) {
|
|
98
98
|
while (level) {
|
|
99
99
|
stackLines = stackLines?.filter(line => line !== constructorLine);
|
|
100
100
|
level--;
|
|
@@ -123,10 +123,10 @@ export function DyFM_getLocalStackLocation(level: number = 0): string {
|
|
|
123
123
|
}
|
|
124
124
|
|
|
125
125
|
// Remove the 'constructorLine at ... (' and the ')'
|
|
126
|
-
if (constructorLine
|
|
126
|
+
if (constructorLine?.includes('(')) {
|
|
127
127
|
constructorLine = constructorLine?.split('(')[1];
|
|
128
128
|
}
|
|
129
|
-
if (constructorLine
|
|
129
|
+
if (constructorLine?.includes(')')) {
|
|
130
130
|
constructorLine = constructorLine?.split(')')[0];
|
|
131
131
|
}
|
|
132
132
|
|
|
Binary file
|