@sdux-vault/shared 0.6.0 → 0.7.0
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/fesm2022/sdux-vault-shared.mjs +248 -232
- package/fesm2022/sdux-vault-shared.mjs.map +1 -1
- package/package.json +26 -2
- package/types/sdux-vault-shared.d.ts +1116 -122
|
@@ -1,18 +1,6 @@
|
|
|
1
1
|
import { BehaviorSubject, Subscription, tap } from 'rxjs';
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
// FilePath: libs > shared > src > typings > global.d.ts
|
|
5
|
-
// Updated: 2026-03-24 12:38
|
|
6
|
-
// Generated by pathcomment [tab] (see .vscode/typescript.code-snippets) or
|
|
7
|
-
// cmd+alt+j (see .vscode/keybindings.json)
|
|
8
|
-
// --- END AI MODEL FILE PATH ---
|
|
9
|
-
|
|
10
|
-
// --- AI Model File Path (DO NOT DELETE) ---
|
|
11
|
-
// FilePath: libs > shared > src > lib > utils > dev-mode > testing-environment.util.ts
|
|
12
|
-
// Updated: 2026-03-09 14:47
|
|
13
|
-
// Generated by pathcomment [tab] (see .vscode/typescript.code-snippets) or
|
|
14
|
-
// cmd+alt+j (see .vscode/keybindings.json)
|
|
15
|
-
// --- END AI MODEL FILE PATH ---
|
|
3
|
+
/** Singleton accessor that detects whether code is running in a test environment. */
|
|
16
4
|
const isTestEnv = {
|
|
17
5
|
get active() {
|
|
18
6
|
return (
|
|
@@ -27,13 +15,9 @@ const isTestEnv = {
|
|
|
27
15
|
}
|
|
28
16
|
};
|
|
29
17
|
|
|
30
|
-
|
|
31
|
-
// FilePath: libs > shared > src > lib > utils > dev-mode > dev-mode.util.ts
|
|
32
|
-
// Updated: 2026-03-09 14:46
|
|
33
|
-
// Generated by pathcomment [tab] (see .vscode/typescript.code-snippets) or
|
|
34
|
-
// cmd+alt+j (see .vscode/keybindings.json)
|
|
35
|
-
// --- END AI MODEL FILE PATH ---
|
|
18
|
+
/** Tracks whether Vault development mode has been enabled. */
|
|
36
19
|
let devMode = null;
|
|
20
|
+
/** Singleton accessor for Vault development mode state. */
|
|
37
21
|
const DevMode = {
|
|
38
22
|
get active() {
|
|
39
23
|
return devMode === true;
|
|
@@ -46,12 +30,12 @@ const DevMode = {
|
|
|
46
30
|
}
|
|
47
31
|
};
|
|
48
32
|
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
33
|
+
/**
|
|
34
|
+
* Registers a package version on the global SDuX debug widget when dev mode is active.
|
|
35
|
+
*
|
|
36
|
+
* @param packageName - The npm package name to register.
|
|
37
|
+
* @param version - The semver version string.
|
|
38
|
+
*/
|
|
55
39
|
const registerVersion = (packageName, version) => {
|
|
56
40
|
if (!DevMode.active || typeof globalThis === 'undefined')
|
|
57
41
|
return;
|
|
@@ -63,14 +47,10 @@ const registerVersion = (packageName, version) => {
|
|
|
63
47
|
versions[packageName] = version;
|
|
64
48
|
};
|
|
65
49
|
|
|
66
|
-
|
|
67
|
-
// FilePath: libs > shared > src > lib > version > version.register.ts
|
|
68
|
-
// Updated: 2026-03-03 08:12
|
|
69
|
-
// Generated by pathcomment [tab] (see .vscode/typescript.code-snippets) or
|
|
70
|
-
// cmd+alt+j (see .vscode/keybindings.json)
|
|
71
|
-
// --- END AI MODEL FILE PATH ---
|
|
50
|
+
/** Package name used for version registration. */
|
|
72
51
|
const SDUX_PACKAGE = '@sdux-vault/shared';
|
|
73
|
-
|
|
52
|
+
/** Current package version string. */
|
|
53
|
+
const SDUX_VERSION = '0.7.0';
|
|
74
54
|
registerVersion(SDUX_PACKAGE, SDUX_VERSION);
|
|
75
55
|
|
|
76
56
|
/**
|
|
@@ -111,12 +91,6 @@ const BehaviorTypes = {
|
|
|
111
91
|
TabSyncState: 'tabSyncState'
|
|
112
92
|
};
|
|
113
93
|
|
|
114
|
-
// --- AI Model File Path (DO NOT DELETE) ---
|
|
115
|
-
// FilePath: libs > shared > src > lib > types > logging > console.type.ts
|
|
116
|
-
// Updated: 2026-03-21 21:00
|
|
117
|
-
// Generated by pathcomment [tab] (see .vscode/typescript.code-snippets) or
|
|
118
|
-
// cmd+alt+j (see .vscode/keybindings.json)
|
|
119
|
-
// --- END AI MODEL FILE PATH ---
|
|
120
94
|
/**
|
|
121
95
|
* Defines the allowable verbosity levels for Vault logging.
|
|
122
96
|
*
|
|
@@ -130,6 +104,7 @@ const BehaviorTypes = {
|
|
|
130
104
|
* - `'log'` — standard log events, warnings, and errors are logged
|
|
131
105
|
* - `'debug'` — all debug-level information is emitted
|
|
132
106
|
*/
|
|
107
|
+
/** Enumeration of console output severity levels. */
|
|
133
108
|
const ConsoleTypes = {
|
|
134
109
|
Error: 'error',
|
|
135
110
|
Warn: 'warn',
|
|
@@ -137,12 +112,6 @@ const ConsoleTypes = {
|
|
|
137
112
|
Debug: 'debug'
|
|
138
113
|
};
|
|
139
114
|
|
|
140
|
-
// --- AI Model File Path (DO NOT DELETE) ---
|
|
141
|
-
// FilePath: libs > shared > src > lib > types > logging > log-level.type.ts
|
|
142
|
-
// Updated: 2026-03-21 21:00
|
|
143
|
-
// Generated by pathcomment [tab] (see .vscode/typescript.code-snippets) or
|
|
144
|
-
// cmd+alt+j (see .vscode/keybindings.json)
|
|
145
|
-
// --- END AI MODEL FILE PATH ---
|
|
146
115
|
/**
|
|
147
116
|
* Defines the allowable verbosity levels for Vault logging.
|
|
148
117
|
*
|
|
@@ -156,6 +125,7 @@ const ConsoleTypes = {
|
|
|
156
125
|
* - `'log'` — standard log events, warnings, and errors are logged
|
|
157
126
|
* - `'debug'` — all debug-level information is emitted
|
|
158
127
|
*/
|
|
128
|
+
/** Enumeration of Vault log verbosity levels. */
|
|
159
129
|
const LogLevelTypes = {
|
|
160
130
|
Off: 'off',
|
|
161
131
|
Error: 'error',
|
|
@@ -164,18 +134,19 @@ const LogLevelTypes = {
|
|
|
164
134
|
Debug: 'debug'
|
|
165
135
|
};
|
|
166
136
|
|
|
167
|
-
|
|
168
|
-
// FilePath: libs > shared > src > lib > utils > logger > logger.util.ts
|
|
169
|
-
// Updated: 2026-03-23 16:50
|
|
170
|
-
// Generated by pathcomment [tab] (see .vscode/typescript.code-snippets) or
|
|
171
|
-
// cmd+alt+j (see .vscode/keybindings.json)
|
|
172
|
-
// --- END AI MODEL FILE PATH ---
|
|
137
|
+
/** Current log level threshold controlling which messages are emitted. */
|
|
173
138
|
let _logLevel = LogLevelTypes.Off;
|
|
174
139
|
/**
|
|
175
140
|
* Prefix applied to all vault-related console output. Used to keep log
|
|
176
141
|
* messages consistently identifiable across all log levels.
|
|
177
142
|
*/
|
|
178
143
|
const LOG_PREFIX = '[vault]';
|
|
144
|
+
/**
|
|
145
|
+
* Routes a log message to the console if the current log level permits it.
|
|
146
|
+
*
|
|
147
|
+
* @param level - The console severity level for this message.
|
|
148
|
+
* @param args - Console arguments to log.
|
|
149
|
+
*/
|
|
179
150
|
// eslint-disable-next-line
|
|
180
151
|
function push(level, ...args) {
|
|
181
152
|
const logLevel = getVaultLogLevel();
|
|
@@ -221,13 +192,27 @@ const vaultLog = (...args) => push('log', ...args);
|
|
|
221
192
|
*/
|
|
222
193
|
// eslint-disable-next-line
|
|
223
194
|
const vaultDebug = (...args) => push('debug', ...args);
|
|
195
|
+
/**
|
|
196
|
+
* Sets the global Vault log level threshold.
|
|
197
|
+
*
|
|
198
|
+
* @param level - The log level to apply.
|
|
199
|
+
*/
|
|
224
200
|
function setVaultLogLevel(level) {
|
|
225
201
|
_logLevel = level ?? 'off';
|
|
226
202
|
}
|
|
203
|
+
/**
|
|
204
|
+
* Returns the current global Vault log level.
|
|
205
|
+
*
|
|
206
|
+
* @returns The active log level threshold.
|
|
207
|
+
*/
|
|
227
208
|
function getVaultLogLevel() {
|
|
228
209
|
return _logLevel;
|
|
229
210
|
}
|
|
230
211
|
|
|
212
|
+
/**
|
|
213
|
+
* Abstract base class for error callback behaviors that execute consumer-supplied
|
|
214
|
+
* error handlers during the error stage of the Vault pipeline.
|
|
215
|
+
*/
|
|
231
216
|
class AbstractErrorCallbackBehavior {
|
|
232
217
|
behaviorCtx;
|
|
233
218
|
/** Indicates that this error behavior is critical and always executed. */
|
|
@@ -247,19 +232,13 @@ class AbstractErrorCallbackBehavior {
|
|
|
247
232
|
this.key = key;
|
|
248
233
|
}
|
|
249
234
|
/**
|
|
250
|
-
*
|
|
251
|
-
*
|
|
252
|
-
* Error behaviors do not allocate runtime resources and therefore require
|
|
253
|
-
* no cleanup. A diagnostic entry is logged for lifecycle visibility.
|
|
235
|
+
* Teardown hook invoked when the behavior instance is destroyed.
|
|
254
236
|
*/
|
|
255
237
|
destroy() {
|
|
256
238
|
vaultWarn(`${this.key} - destroy "noop"`);
|
|
257
239
|
}
|
|
258
240
|
/**
|
|
259
|
-
*
|
|
260
|
-
*
|
|
261
|
-
* Error behaviors hold no internal state, making this a no-operation.
|
|
262
|
-
* The hook ensures lifecycle uniformity across all behaviors.
|
|
241
|
+
* Resets the error behavior to its initial state.
|
|
263
242
|
*/
|
|
264
243
|
reset() {
|
|
265
244
|
vaultWarn(`${this.key} - reset "noop"`);
|
|
@@ -270,12 +249,6 @@ class AbstractErrorCallbackBehavior {
|
|
|
270
249
|
* Abstract base behavior for transforming errors during pipeline execution.
|
|
271
250
|
* This class defines the contract and lifecycle hooks required for error transformation behaviors.
|
|
272
251
|
*
|
|
273
|
-
* --RelatedStart--
|
|
274
|
-
* ErrorTransformBehaviorContract
|
|
275
|
-
* BehaviorClassContext
|
|
276
|
-
* StateSnapshotShape
|
|
277
|
-
* VaultErrorShape
|
|
278
|
-
* --RelatedEnd--
|
|
279
252
|
*/
|
|
280
253
|
class AbstractErrorTransformBehavior {
|
|
281
254
|
behaviorCtx;
|
|
@@ -374,19 +347,36 @@ function jsonSafeReplacer(_key, val) {
|
|
|
374
347
|
/** ------------------------------------------
|
|
375
348
|
* INTERNAL CLASS (NOT EXPORTED)
|
|
376
349
|
* ------------------------------------------ */
|
|
350
|
+
/**
|
|
351
|
+
* Internal singleton error service that holds the current Vault error state.
|
|
352
|
+
* Not exported directly; consumed exclusively by the public VaultErrorService.
|
|
353
|
+
*/
|
|
377
354
|
class VaultPrivateErrorClass {
|
|
355
|
+
/** Subject backing the private error observable. */
|
|
378
356
|
#error$ = new BehaviorSubject(null);
|
|
357
|
+
/** Initializes the private error service singleton. */
|
|
379
358
|
constructor() {
|
|
380
359
|
vaultDebug('[VaultPrivateErrorService] initialized (singleton instance created)');
|
|
381
360
|
}
|
|
361
|
+
/**
|
|
362
|
+
* Publishes a new error or clears the current error.
|
|
363
|
+
*
|
|
364
|
+
* @param error - The error shape to publish, or null to clear.
|
|
365
|
+
*/
|
|
382
366
|
setError(error) {
|
|
383
367
|
vaultDebug(`[VaultPrivateErrorService] setError() ${safeStringify(error)}`);
|
|
384
368
|
this.#error$.next(error);
|
|
385
369
|
}
|
|
370
|
+
/**
|
|
371
|
+
* Returns an observable of the current error state.
|
|
372
|
+
*
|
|
373
|
+
* @returns Observable emitting the current error or null.
|
|
374
|
+
*/
|
|
386
375
|
getError() {
|
|
387
376
|
vaultDebug('[VaultPrivateErrorService] getError() → observable subscribed');
|
|
388
377
|
return this.#error$.asObservable();
|
|
389
378
|
}
|
|
379
|
+
/** Resets the error state to null. */
|
|
390
380
|
clear() {
|
|
391
381
|
vaultDebug('[VaultPrivateErrorService] clear() → error reset to null');
|
|
392
382
|
this.#error$.next(null);
|
|
@@ -396,6 +386,11 @@ class VaultPrivateErrorClass {
|
|
|
396
386
|
* SINGLETON FACTORY (EXPORTED)
|
|
397
387
|
* ------------------------------------------ */
|
|
398
388
|
let _instance$1 = null;
|
|
389
|
+
/**
|
|
390
|
+
* Returns the singleton VaultPrivateErrorService instance, creating it on first call.
|
|
391
|
+
*
|
|
392
|
+
* @returns The shared private error service instance.
|
|
393
|
+
*/
|
|
399
394
|
function VaultPrivateErrorService() {
|
|
400
395
|
if (!_instance$1) {
|
|
401
396
|
vaultDebug('[VaultPrivateErrorService] creating new singleton instance');
|
|
@@ -407,14 +402,23 @@ function VaultPrivateErrorService() {
|
|
|
407
402
|
return _instance$1;
|
|
408
403
|
}
|
|
409
404
|
|
|
405
|
+
/**
|
|
406
|
+
* Singleton service that aggregates and exposes the current Vault error state.
|
|
407
|
+
* Subscribes to the private error service and mirrors updates through a public
|
|
408
|
+
* observable stream for consumer consumption.
|
|
409
|
+
*/
|
|
410
410
|
class VaultErrorServiceClass {
|
|
411
|
+
/** Internal delegate responsible for low-level error state management. */
|
|
411
412
|
#privateVaultErrorService = VaultPrivateErrorService();
|
|
413
|
+
/** Subject backing the public error observable. */
|
|
412
414
|
#error$ = new BehaviorSubject(null);
|
|
415
|
+
/** Tracks whether an active error is currently held. */
|
|
413
416
|
#hasErrorState = false;
|
|
414
|
-
/**
|
|
417
|
+
/** Aggregate subscription used for cleanup on teardown. */
|
|
415
418
|
#subscription = new Subscription();
|
|
416
|
-
/** Public observable error
|
|
419
|
+
/** Public observable stream of the current error state. */
|
|
417
420
|
error$ = this.#error$.asObservable();
|
|
421
|
+
/** Initializes the service and subscribes to the private error stream. */
|
|
418
422
|
constructor() {
|
|
419
423
|
vaultDebug('[VaultErrorService] Initializing service and subscribing to private error stream.');
|
|
420
424
|
// Mirror the private error service into this one
|
|
@@ -427,18 +431,23 @@ class VaultErrorServiceClass {
|
|
|
427
431
|
});
|
|
428
432
|
this.#subscription.add(sub);
|
|
429
433
|
}
|
|
434
|
+
/** Whether an active error is currently present. */
|
|
430
435
|
get hasError() {
|
|
431
436
|
return this.#hasErrorState;
|
|
432
437
|
}
|
|
438
|
+
/** Clears the current error state via the private error service. */
|
|
433
439
|
clear() {
|
|
434
440
|
vaultDebug('[VaultErrorService] Clearing current error.');
|
|
435
441
|
this.#privateVaultErrorService.clear();
|
|
436
442
|
}
|
|
437
443
|
}
|
|
438
|
-
|
|
439
|
-
// SINGLETON FACTORY (EXPORTED)
|
|
440
|
-
// --------------------------------
|
|
444
|
+
/** Cached singleton instance of the VaultErrorService. */
|
|
441
445
|
let _instance = null;
|
|
446
|
+
/**
|
|
447
|
+
* Returns the singleton VaultErrorService instance, creating it on first call.
|
|
448
|
+
*
|
|
449
|
+
* @returns The shared VaultErrorService instance.
|
|
450
|
+
*/
|
|
442
451
|
function VaultErrorService() {
|
|
443
452
|
if (!_instance) {
|
|
444
453
|
vaultDebug('[VaultErrorService] Creating new singleton instance.');
|
|
@@ -447,13 +456,28 @@ function VaultErrorService() {
|
|
|
447
456
|
return _instance;
|
|
448
457
|
}
|
|
449
458
|
|
|
459
|
+
/**
|
|
460
|
+
* Abstract base class for active controllers that react to external error
|
|
461
|
+
* state changes and participate in pipeline admission voting.
|
|
462
|
+
*/
|
|
450
463
|
class AbstractActiveController {
|
|
451
464
|
ctx;
|
|
465
|
+
/** Unique identifier for this controller instance. */
|
|
452
466
|
key;
|
|
467
|
+
/** Whether errors from this controller halt the pipeline. */
|
|
453
468
|
critical = false;
|
|
469
|
+
/** Tracks whether the global error service currently holds an error. */
|
|
454
470
|
hasError = false;
|
|
471
|
+
/** Trace identifier from the most recent pipeline operation. */
|
|
455
472
|
traceId = null;
|
|
473
|
+
/** Subscription to the global VaultErrorService stream. */
|
|
456
474
|
#subscription;
|
|
475
|
+
/**
|
|
476
|
+
* Creates an active controller and subscribes to the global error stream.
|
|
477
|
+
*
|
|
478
|
+
* @param key - Unique controller identifier supplied by the factory.
|
|
479
|
+
* @param ctx - Class-level context providing revote and lifecycle access.
|
|
480
|
+
*/
|
|
457
481
|
constructor(key, ctx) {
|
|
458
482
|
this.ctx = ctx;
|
|
459
483
|
this.key = key;
|
|
@@ -475,47 +499,34 @@ class AbstractActiveController {
|
|
|
475
499
|
}))
|
|
476
500
|
.subscribe();
|
|
477
501
|
}
|
|
478
|
-
/**
|
|
502
|
+
/**
|
|
503
|
+
* Hook invoked when the external error state changes.
|
|
504
|
+
*
|
|
505
|
+
* @param _newErrorState - The updated error state flag.
|
|
506
|
+
*/
|
|
479
507
|
//istanbul ignore next
|
|
480
508
|
onExternalTrigger(_newErrorState) { }
|
|
509
|
+
/** Tears down the controller and unsubscribes from the error stream. */
|
|
481
510
|
destroy() {
|
|
482
511
|
this.#subscription.unsubscribe();
|
|
483
512
|
vaultWarn(`${this.key} - destroy`);
|
|
484
513
|
}
|
|
514
|
+
/** Resets the controller to its initial state. */
|
|
485
515
|
reset() {
|
|
486
516
|
vaultWarn(`${this.key} - reset "noop"`);
|
|
487
517
|
}
|
|
488
518
|
}
|
|
489
519
|
|
|
490
|
-
// --- AI Model File Path (DO NOT DELETE) ---
|
|
491
|
-
// FilePath: libs > shared > src > lib > abstracts > index.ts
|
|
492
|
-
// Updated: 2026-03-23 17:27
|
|
493
|
-
// Generated by pathcomment [tab] (see .vscode/typescript.code-snippets) or
|
|
494
|
-
// cmd+alt+j (see .vscode/keybindings.json)
|
|
495
|
-
// --- END AI MODEL FILE PATH ---
|
|
496
520
|
/* -----------------------------------------------------------
|
|
497
521
|
* Abstracts
|
|
498
522
|
* --------------------------------------------------------- */
|
|
499
523
|
|
|
500
|
-
|
|
501
|
-
// FilePath: libs > shared > src > lib > config > index.ts
|
|
502
|
-
// Updated: 2026-03-23 16:54
|
|
503
|
-
// Generated by pathcomment [tab] (see .vscode/typescript.code-snippets) or
|
|
504
|
-
// cmd+alt+j (see .vscode/keybindings.json)
|
|
505
|
-
// --- END AI MODEL FILE PATH ---
|
|
506
|
-
|
|
507
|
-
// --- AI Model File Path (DO NOT DELETE) ---
|
|
508
|
-
// FilePath: libs > shared > src > lib > constants > behavior-meta.constant.ts
|
|
509
|
-
// Updated: 2026-03-28 14:09
|
|
510
|
-
// Generated by pathcomment [tab] (see .vscode/typescript.code-snippets) or
|
|
511
|
-
// cmd+alt+j (see .vscode/keybindings.json)
|
|
512
|
-
// --- END AI MODEL FILE PATH ---
|
|
524
|
+
/** Symbol key used to attach behavior metadata to a behavior class. */
|
|
513
525
|
const BEHAVIOR_META = Symbol.for('BEHAVIOR_META');
|
|
514
526
|
|
|
527
|
+
/** Symbol key used to attach controller metadata to a controller class. */
|
|
515
528
|
const CONTROLLER_META = Symbol.for('CONTROLLER_META');
|
|
516
529
|
|
|
517
|
-
// --- AI Model File Path ---
|
|
518
|
-
// libs > shared > src > lib > constants > dev-tools > devtools-aggregate-key.constant.ts
|
|
519
530
|
/**
|
|
520
531
|
* String token used to uniquely identify the DevTools Aggregate FeatureCell.
|
|
521
532
|
*
|
|
@@ -528,8 +539,6 @@ const CONTROLLER_META = Symbol.for('CONTROLLER_META');
|
|
|
528
539
|
*/
|
|
529
540
|
const DEVTOOLS_AGGREGATE_KEY_CONSTANT = 'vault::devtools::aggregate:feature::cell';
|
|
530
541
|
|
|
531
|
-
// --- AI Model File Path ---
|
|
532
|
-
// libs > shared > src > lib > constants > dev-tools > devtools-logging-key.constant.ts
|
|
533
542
|
/**
|
|
534
543
|
* String token used to uniquely identify the DevTools Logging FeatureCell.
|
|
535
544
|
*
|
|
@@ -542,31 +551,22 @@ const DEVTOOLS_AGGREGATE_KEY_CONSTANT = 'vault::devtools::aggregate:feature::cel
|
|
|
542
551
|
*/
|
|
543
552
|
const DEVTOOLS_LOGGING_KEY_CONSTANT = 'vault::devtools::logging::feature::cell';
|
|
544
553
|
|
|
554
|
+
/** Sentinel symbol that signals the pipeline to clear the current state. */
|
|
545
555
|
const VAULT_CLEAR_STATE = Symbol.for('VAULT_CLEAR_STATE');
|
|
546
556
|
|
|
557
|
+
/** Sentinel symbol that signals the pipeline to continue processing. */
|
|
547
558
|
const VAULT_CONTINUE = Symbol.for('VAULT_CONTINUE');
|
|
548
559
|
|
|
560
|
+
/** Sentinel symbol that signals the pipeline to skip the current operation. */
|
|
549
561
|
const VAULT_NOOP = Symbol.for('VAULT_NOOP');
|
|
550
562
|
|
|
563
|
+
/** Sentinel symbol that signals the pipeline to halt execution. */
|
|
551
564
|
const VAULT_STOP = Symbol.for('VAULT_STOP');
|
|
552
565
|
|
|
553
|
-
// --- AI Model File Path (DO NOT DELETE) ---
|
|
554
|
-
// FilePath: libs > shared > src > lib > constants > public-api.ts
|
|
555
|
-
// Updated: 2026-03-23 18:48
|
|
556
|
-
// Generated by pathcomment [tab] (see .vscode/typescript.code-snippets) or
|
|
557
|
-
// cmd+alt+j (see .vscode/keybindings.json)
|
|
558
|
-
// --- END AI MODEL FILE PATH ---
|
|
559
566
|
/* -----------------------------------------------------------
|
|
560
567
|
* META + DECORATORS
|
|
561
568
|
* --------------------------------------------------------- */
|
|
562
569
|
|
|
563
|
-
// --- AI Model File Path (DO NOT DELETE) ---
|
|
564
|
-
// FilePath: libs > shared > src > lib > contexts > index.ts
|
|
565
|
-
// Updated: 2026-03-23 17:31
|
|
566
|
-
// Generated by pathcomment [tab] (see .vscode/typescript.code-snippets) or
|
|
567
|
-
// cmd+alt+j (see .vscode/keybindings.json)
|
|
568
|
-
// --- END AI MODEL FILE PATH ---
|
|
569
|
-
|
|
570
570
|
// vault-behavior.decorator.ts
|
|
571
571
|
/**
|
|
572
572
|
* Decorator that registers a class as an Vault behavior.
|
|
@@ -625,6 +625,12 @@ function VaultBehavior(meta) {
|
|
|
625
625
|
}
|
|
626
626
|
|
|
627
627
|
// vault-behavior.decorator.ts
|
|
628
|
+
/**
|
|
629
|
+
* Class decorator that attaches controller metadata to the target class.
|
|
630
|
+
*
|
|
631
|
+
* @param meta - The controller metadata shape to apply.
|
|
632
|
+
* @returns A class decorator function.
|
|
633
|
+
*/
|
|
628
634
|
function VaultController(meta) {
|
|
629
635
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
630
636
|
return function (target) {
|
|
@@ -661,27 +667,17 @@ function VaultController(meta) {
|
|
|
661
667
|
};
|
|
662
668
|
}
|
|
663
669
|
|
|
664
|
-
// --- AI Model File Path (DO NOT DELETE) ---
|
|
665
|
-
// FilePath: libs > shared > src > lib > decorators > index.ts
|
|
666
|
-
// Updated: 2026-03-23 18:29
|
|
667
|
-
// Generated by pathcomment [tab] (see .vscode/typescript.code-snippets) or
|
|
668
|
-
// cmd+alt+j (see .vscode/keybindings.json)
|
|
669
|
-
// --- END AI MODEL FILE PATH ---
|
|
670
670
|
/* -----------------------------------------------------------
|
|
671
671
|
* META + DECORATORS
|
|
672
672
|
* --------------------------------------------------------- */
|
|
673
673
|
|
|
674
|
+
/** Enumeration of top-level Vault error kind classifications. */
|
|
674
675
|
const VaultErrorKindTypes = {
|
|
675
676
|
Usage: 'VaultErrorUsage',
|
|
676
677
|
VaultError: 'VaultError'
|
|
677
678
|
};
|
|
678
679
|
|
|
679
|
-
|
|
680
|
-
// FilePath: libs > shared > src > lib > types > error > vault-error-name.type.ts
|
|
681
|
-
// Updated: 2026-03-12 11:57
|
|
682
|
-
// Generated by pathcomment [tab] (see .vscode/typescript.code-snippets) or
|
|
683
|
-
// cmd+alt+j (see .vscode/keybindings.json)
|
|
684
|
-
// --- END AI MODEL FILE PATH ---
|
|
680
|
+
/** Enumeration of Vault error name identifiers. */
|
|
685
681
|
const VaultErrorNameTypes = {
|
|
686
682
|
EncryptionIntegrity: 'VaultErrorEncryptionIntegrity',
|
|
687
683
|
License: 'VaultErrorLicense',
|
|
@@ -689,14 +685,20 @@ const VaultErrorNameTypes = {
|
|
|
689
685
|
VaultError: 'VaultError'
|
|
690
686
|
};
|
|
691
687
|
|
|
692
|
-
|
|
693
|
-
|
|
694
|
-
|
|
695
|
-
|
|
696
|
-
// cmd+alt+j (see .vscode/keybindings.json)
|
|
697
|
-
// --- END AI MODEL FILE PATH ---
|
|
688
|
+
/**
|
|
689
|
+
* Base error class for all Vault-specific errors. Extends the native Error
|
|
690
|
+
* with a typed name and kind for structured error classification.
|
|
691
|
+
*/
|
|
698
692
|
class VaultError extends Error {
|
|
693
|
+
/** Classification kind used to categorize this error in diagnostics. */
|
|
699
694
|
kind;
|
|
695
|
+
/**
|
|
696
|
+
* Creates a new VaultError instance with prototype chain correction.
|
|
697
|
+
*
|
|
698
|
+
* @param message - Human-readable description of the error.
|
|
699
|
+
* @param name - Typed error name used for identification.
|
|
700
|
+
* @param kind - Error kind used for diagnostic classification.
|
|
701
|
+
*/
|
|
700
702
|
constructor(message, name = VaultErrorNameTypes.VaultError, kind = VaultErrorKindTypes.VaultError) {
|
|
701
703
|
super(message);
|
|
702
704
|
this.name = name;
|
|
@@ -712,25 +714,12 @@ class VaultError extends Error {
|
|
|
712
714
|
}
|
|
713
715
|
}
|
|
714
716
|
|
|
715
|
-
// --- AI Model File Path (DO NOT DELETE) ---
|
|
716
|
-
// FilePath: libs > shared > src > lib > errors > vault-error.encryption.integrity.ts
|
|
717
|
-
// Updated: 2026-03-12
|
|
718
|
-
// --- END AI MODEL FILE PATH ---
|
|
719
717
|
/**
|
|
720
|
-
* Thrown when encrypted payload integrity verification
|
|
721
|
-
*
|
|
722
|
-
* This occurs when AES-GCM authentication fails during decryption.
|
|
723
|
-
* Causes may include:
|
|
724
|
-
*
|
|
725
|
-
* - Tampered ciphertext
|
|
726
|
-
* - Modified IV
|
|
727
|
-
* - Incorrect encryption key
|
|
728
|
-
* - Corrupted storage payload
|
|
729
|
-
*
|
|
730
|
-
* AES-GCM provides authenticated encryption, so any modification to the
|
|
731
|
-
* encrypted envelope will cause the WebCrypto decrypt operation to throw.
|
|
718
|
+
* Thrown when an encrypted payload fails AES-GCM integrity verification
|
|
719
|
+
* during decryption, indicating tampered, corrupted, or mismatched key data.
|
|
732
720
|
*/
|
|
733
721
|
class VaultEncryptionIntegrityError extends VaultError {
|
|
722
|
+
/** Creates the error with a descriptive integrity-failure message. */
|
|
734
723
|
constructor() {
|
|
735
724
|
const message = `Encrypted snapshot failed integrity verification.
|
|
736
725
|
|
|
@@ -748,12 +737,7 @@ Vault refuses to restore state from unauthenticated encrypted data.`;
|
|
|
748
737
|
}
|
|
749
738
|
}
|
|
750
739
|
|
|
751
|
-
|
|
752
|
-
// FilePath: libs > shared > src > lib > types > error > vault-error-usage-kind.type.ts
|
|
753
|
-
// Updated: 2026-03-12 11:57
|
|
754
|
-
// Generated by pathcomment [tab] (see .vscode/typescript.code-snippets) or
|
|
755
|
-
// cmd+alt+j (see .vscode/keybindings.json)
|
|
756
|
-
// --- END AI MODEL FILE PATH ---
|
|
740
|
+
/** Enumeration of usage-specific Vault error sub-kind classifications. */
|
|
757
741
|
const VaultErrorUsageKindTypes = {
|
|
758
742
|
Encryption: 'VaultErrorEncryption',
|
|
759
743
|
License: 'VaultErrorLicense',
|
|
@@ -762,31 +746,42 @@ const VaultErrorUsageKindTypes = {
|
|
|
762
746
|
Usage: 'VaultErrorUsage'
|
|
763
747
|
};
|
|
764
748
|
|
|
765
|
-
|
|
766
|
-
|
|
767
|
-
|
|
768
|
-
// Generated by pathcomment [tab] (see .vscode/typescript.code-snippets) or
|
|
769
|
-
// cmd+alt+j (see .vscode/keybindings.json)
|
|
770
|
-
// --- END AI MODEL FILE PATH ---
|
|
749
|
+
/**
|
|
750
|
+
* Thrown when a behavior or controller fails license validation.
|
|
751
|
+
*/
|
|
771
752
|
class VaultLicenseError extends VaultError {
|
|
753
|
+
/**
|
|
754
|
+
* Creates a license validation error.
|
|
755
|
+
*
|
|
756
|
+
* @param message - Description of the license violation.
|
|
757
|
+
* @param kind - Usage-kind classification for diagnostics.
|
|
758
|
+
*/
|
|
772
759
|
constructor(message, kind = VaultErrorUsageKindTypes.License) {
|
|
773
760
|
super(message, VaultErrorNameTypes.License, kind);
|
|
774
761
|
}
|
|
775
762
|
}
|
|
776
763
|
|
|
764
|
+
/**
|
|
765
|
+
* Base error for Vault API usage violations detected at runtime.
|
|
766
|
+
*/
|
|
777
767
|
class VaultUsageError extends VaultError {
|
|
768
|
+
/**
|
|
769
|
+
* Creates a usage error with the specified message and kind.
|
|
770
|
+
*
|
|
771
|
+
* @param message - Description of the usage violation.
|
|
772
|
+
* @param kind - Usage-kind classification for diagnostics.
|
|
773
|
+
*/
|
|
778
774
|
constructor(message, kind = VaultErrorUsageKindTypes.Usage) {
|
|
779
775
|
super(message, VaultErrorNameTypes.Usage, kind);
|
|
780
776
|
}
|
|
781
777
|
}
|
|
782
778
|
|
|
783
|
-
|
|
784
|
-
|
|
785
|
-
|
|
786
|
-
|
|
787
|
-
// cmd+alt+j (see .vscode/keybindings.json)
|
|
788
|
-
// --- END AI MODEL FILE PATH ---
|
|
779
|
+
/**
|
|
780
|
+
* Thrown when an eager Promise is passed directly to the state pipeline
|
|
781
|
+
* instead of a deferred factory function.
|
|
782
|
+
*/
|
|
789
783
|
class VaultUsagePromiseError extends VaultUsageError {
|
|
784
|
+
/** Creates the error with a descriptive usage-violation message. */
|
|
790
785
|
constructor() {
|
|
791
786
|
const message = `Invalid incoming value: Promise detected.
|
|
792
787
|
|
|
@@ -799,7 +794,12 @@ This guarantees the promise is created and executed inside the pipeline.`;
|
|
|
799
794
|
}
|
|
800
795
|
}
|
|
801
796
|
|
|
797
|
+
/**
|
|
798
|
+
* Thrown when a Promise-based state method receives a raw value instead
|
|
799
|
+
* of a factory function that returns a Promise.
|
|
800
|
+
*/
|
|
802
801
|
class VaultUsagePromiseFactoryRequiredError extends VaultUsageError {
|
|
802
|
+
/** Creates the error with a descriptive usage-violation message. */
|
|
803
803
|
constructor() {
|
|
804
804
|
const message = `Invalid usage of Promise-based state API.
|
|
805
805
|
|
|
@@ -820,34 +820,15 @@ inside the pipeline.`;
|
|
|
820
820
|
}
|
|
821
821
|
}
|
|
822
822
|
|
|
823
|
-
// --- AI Model File Path (DO NOT DELETE) ---
|
|
824
|
-
// FilePath: libs > shared > src > lib > errors > index.ts
|
|
825
|
-
// Updated: 2026-03-23 17:21
|
|
826
|
-
// Generated by pathcomment [tab] (see .vscode/typescript.code-snippets) or
|
|
827
|
-
// cmd+alt+j (see .vscode/keybindings.json)
|
|
828
|
-
// --- END AI MODEL FILE PATH ---
|
|
829
823
|
/* -----------------------------------------------------------
|
|
830
824
|
* ERRORS
|
|
831
825
|
* --------------------------------------------------------- */
|
|
832
826
|
|
|
833
|
-
// --- AI Model File Path (DO NOT DELETE) ---
|
|
834
|
-
// FilePath: libs > shared > src > lib > interfaces > index.ts
|
|
835
|
-
// Updated: 2026-03-23 18:45
|
|
836
|
-
// Generated by pathcomment [tab] (see .vscode/typescript.code-snippets) or
|
|
837
|
-
// cmd+alt+j (see .vscode/keybindings.json)
|
|
838
|
-
// --- END AI MODEL FILE PATH ---
|
|
839
|
-
|
|
840
827
|
/* -----------------------------------------------------------
|
|
841
828
|
* SERVICES
|
|
842
829
|
* --------------------------------------------------------- */
|
|
843
830
|
|
|
844
|
-
|
|
845
|
-
// FilePath: libs > shared > src > lib > shapes > index.ts
|
|
846
|
-
// Updated: 2026-03-23 18:42
|
|
847
|
-
// Generated by pathcomment [tab] (see .vscode/typescript.code-snippets) or
|
|
848
|
-
// cmd+alt+j (see .vscode/keybindings.json)
|
|
849
|
-
// --- END AI MODEL FILE PATH ---
|
|
850
|
-
|
|
831
|
+
/** Enumeration of message types dispatched to controllers during pipeline orchestration. */
|
|
851
832
|
const ControllerMessageTypes = {
|
|
852
833
|
Attempt: 'attempt',
|
|
853
834
|
Failure: 'failure',
|
|
@@ -856,12 +837,14 @@ const ControllerMessageTypes = {
|
|
|
856
837
|
Vote: 'vote' // mostly internal
|
|
857
838
|
};
|
|
858
839
|
|
|
840
|
+
/** Enumeration of votes a controller may cast during pipeline admission. */
|
|
859
841
|
const ControllerVotes = {
|
|
860
842
|
Abstain: 'abstain',
|
|
861
843
|
Abort: 'abort',
|
|
862
844
|
Deny: 'deny'
|
|
863
845
|
};
|
|
864
846
|
|
|
847
|
+
/** Enumeration of controller category classifications. */
|
|
865
848
|
const ControllerTypes = {
|
|
866
849
|
CoreAbstain: 'coreAbstain',
|
|
867
850
|
Error: 'error',
|
|
@@ -872,18 +855,14 @@ const ControllerTypes = {
|
|
|
872
855
|
TabSync: 'tabSync'
|
|
873
856
|
};
|
|
874
857
|
|
|
858
|
+
/** Enumeration of conductor decision outcomes after controller voting. */
|
|
875
859
|
const DecisionOutcomeTypes = {
|
|
876
860
|
Abort: 'abort',
|
|
877
861
|
Abstain: 'abstain',
|
|
878
862
|
Deny: 'deny'
|
|
879
863
|
};
|
|
880
864
|
|
|
881
|
-
|
|
882
|
-
// FilePath: libs > shared > src > lib > types > event > event-boundary.type.ts
|
|
883
|
-
// Updated: 2026-03-10 09:56
|
|
884
|
-
// Generated by pathcomment [tab] (see .vscode/typescript.code-snippets) or
|
|
885
|
-
// cmd+alt+j (see .vscode/keybindings.json)
|
|
886
|
-
// --- END AI MODEL FILE PATH ---
|
|
865
|
+
/** Enumeration of event boundary positions within a lifecycle span. */
|
|
887
866
|
const EventBoundaryTypes = {
|
|
888
867
|
End: 'end',
|
|
889
868
|
Notification: 'notification',
|
|
@@ -891,12 +870,7 @@ const EventBoundaryTypes = {
|
|
|
891
870
|
Unknown: 'unknown'
|
|
892
871
|
};
|
|
893
872
|
|
|
894
|
-
|
|
895
|
-
// FilePath: libs > shared > src > lib > types > event > event.type.ts
|
|
896
|
-
// Updated: 2026-03-10 09:56
|
|
897
|
-
// Generated by pathcomment [tab] (see .vscode/typescript.code-snippets) or
|
|
898
|
-
// cmd+alt+j (see .vscode/keybindings.json)
|
|
899
|
-
// --- END AI MODEL FILE PATH ---
|
|
873
|
+
/** Enumeration of monitor event category classifications. */
|
|
900
874
|
const EventTypes = {
|
|
901
875
|
Conductor: 'conductor',
|
|
902
876
|
Controller: 'controller',
|
|
@@ -905,6 +879,7 @@ const EventTypes = {
|
|
|
905
879
|
Unknown: 'unknown'
|
|
906
880
|
};
|
|
907
881
|
|
|
882
|
+
/** Enumeration of pipeline operation modes. */
|
|
908
883
|
const OperationTypes = {
|
|
909
884
|
Merge: 'merge',
|
|
910
885
|
Replace: 'replace',
|
|
@@ -928,6 +903,7 @@ const ResolveTypes = {
|
|
|
928
903
|
Value: 'value'
|
|
929
904
|
};
|
|
930
905
|
|
|
906
|
+
/** Enumeration of state emission event classifications. */
|
|
931
907
|
const StateEmitTypes = {
|
|
932
908
|
IncomingPipeline: 'Incoming Pipeline',
|
|
933
909
|
FinalizePipeline: 'Finalize Pipeline',
|
|
@@ -939,22 +915,10 @@ const StateEmitTypes = {
|
|
|
939
915
|
TabSync: 'Tab Sync'
|
|
940
916
|
};
|
|
941
917
|
|
|
942
|
-
// --- AI Model File Path (DO NOT DELETE) ---
|
|
943
|
-
// FilePath: libs > shared > src > lib > types > index.ts
|
|
944
|
-
// Updated: 2026-03-23 18:51
|
|
945
|
-
// Generated by pathcomment [tab] (see .vscode/typescript.code-snippets) or
|
|
946
|
-
// cmd+alt+j (see .vscode/keybindings.json)
|
|
947
|
-
// --- END AI MODEL FILE PATH ---
|
|
948
918
|
/* -----------------------------------------------------------
|
|
949
919
|
* TYPES (USER-FACING)
|
|
950
920
|
* --------------------------------------------------------- */
|
|
951
921
|
|
|
952
|
-
// --- AI Model File Path (DO NOT DELETE) ---
|
|
953
|
-
// FilePath: libs > shared > src > lib > utils > behavior > define-behavior-key.util.ts
|
|
954
|
-
// Updated: 2026-03-28 10:46
|
|
955
|
-
// Generated by pathcomment [tab] (see .vscode/typescript.code-snippets) or
|
|
956
|
-
// cmd+alt+j (see .vscode/keybindings.json)
|
|
957
|
-
// --- END AI MODEL FILE PATH ---
|
|
958
922
|
/**
|
|
959
923
|
* Creates a normalized behavior key identifier used for behavior registration.
|
|
960
924
|
*
|
|
@@ -977,6 +941,14 @@ const StateEmitTypes = {
|
|
|
977
941
|
function defineBehaviorKey(domain, name) {
|
|
978
942
|
return defineVaultKey('Behavior', domain, name);
|
|
979
943
|
}
|
|
944
|
+
/**
|
|
945
|
+
* Constructs a normalized Vault key for behavior or controller registration.
|
|
946
|
+
*
|
|
947
|
+
* @param kind - Whether the key is for a Behavior or Controller.
|
|
948
|
+
* @param domain - The logical domain or category.
|
|
949
|
+
* @param name - The specific name within the domain.
|
|
950
|
+
* @returns A normalized Vault key string.
|
|
951
|
+
*/
|
|
980
952
|
function defineVaultKey(kind, domain, name) {
|
|
981
953
|
const normalize = (s) => s.charAt(0).toUpperCase() + s.slice(1).replace(/[^A-Za-z0-9]/g, '');
|
|
982
954
|
return `SDUX::${kind}::${normalize(domain)}::${normalize(name)}`;
|
|
@@ -1001,19 +973,32 @@ function validateBehaviorKey(key) {
|
|
|
1001
973
|
return pattern.test(key);
|
|
1002
974
|
}
|
|
1003
975
|
|
|
976
|
+
/**
|
|
977
|
+
* Creates a normalized controller key following the Vault key format.
|
|
978
|
+
*
|
|
979
|
+
* @param domain - The logical domain or category of the controller.
|
|
980
|
+
* @param name - The specific controller name within the domain.
|
|
981
|
+
* @returns A normalized controller key string.
|
|
982
|
+
*/
|
|
1004
983
|
function defineControllerKey(domain, name) {
|
|
1005
984
|
return defineVaultKey('Controller', domain, name);
|
|
1006
985
|
}
|
|
986
|
+
/**
|
|
987
|
+
* Validates whether a string conforms to the Vault controller key format.
|
|
988
|
+
*
|
|
989
|
+
* @param key - The controller key string to validate.
|
|
990
|
+
* @returns `true` if the key matches the required pattern.
|
|
991
|
+
*/
|
|
1007
992
|
function validateControllerKey(key) {
|
|
1008
993
|
return validateBehaviorKey(key);
|
|
1009
994
|
}
|
|
1010
995
|
|
|
1011
|
-
|
|
1012
|
-
|
|
1013
|
-
|
|
1014
|
-
|
|
1015
|
-
|
|
1016
|
-
|
|
996
|
+
/**
|
|
997
|
+
* Determines whether a value conforms to the DeferredFactory contract.
|
|
998
|
+
*
|
|
999
|
+
* @param value - The value to inspect.
|
|
1000
|
+
* @returns `true` if the value is an object with a callable `value` property.
|
|
1001
|
+
*/
|
|
1017
1002
|
function isDeferredFactory(value) {
|
|
1018
1003
|
return (!!value &&
|
|
1019
1004
|
typeof value === 'object' &&
|
|
@@ -1069,12 +1054,6 @@ function createVaultError(err, featureCellKey) {
|
|
|
1069
1054
|
};
|
|
1070
1055
|
}
|
|
1071
1056
|
|
|
1072
|
-
// --- AI Model File Path (DO NOT DELETE) ---
|
|
1073
|
-
// FilePath: libs > shared > src > lib > utils > isolate-value > isolate-value.util.ts
|
|
1074
|
-
// Updated: 2026-04-07 15:49
|
|
1075
|
-
// Generated by pathcomment [tab] (see .vscode/typescript.code-snippets) or
|
|
1076
|
-
// cmd+alt+j (see .vscode/keybindings.json)
|
|
1077
|
-
// --- END AI MODEL FILE PATH ---
|
|
1078
1057
|
/*
|
|
1079
1058
|
| Category | Type / Example | structuredClone behavior | deepFreeze fallback behavior | Isolated? | Notes |
|
|
1080
1059
|
| ------------------------ | --------------------- | ------------------------- | ------------------------------------- | ---------- | ---------------------------------------------- |
|
|
@@ -1119,6 +1098,13 @@ function createVaultError(err, featureCellKey) {
|
|
|
1119
1098
|
| **Frozen Objects** | `Object.freeze(obj)` | Cloned (unfrozen) | Preserved frozen OR cloned+frozen | ✅ Yes | Freeze state not guaranteed |
|
|
1120
1099
|
| **Boxed Primitives** | `new Number(1)` | Cloned | Frozen | ✅ Yes | Unboxed behavior retained |
|
|
1121
1100
|
*/
|
|
1101
|
+
/**
|
|
1102
|
+
* Recursively freezes an object and all nested properties to prevent mutation.
|
|
1103
|
+
*
|
|
1104
|
+
* @param obj - The object to deep-freeze.
|
|
1105
|
+
* @param seen - WeakSet used to track visited references and prevent cycles.
|
|
1106
|
+
* @returns The frozen object.
|
|
1107
|
+
*/
|
|
1122
1108
|
function deepFreeze(obj, seen = new WeakSet()) {
|
|
1123
1109
|
if (obj === null || typeof obj !== 'object')
|
|
1124
1110
|
return obj;
|
|
@@ -1141,6 +1127,12 @@ function deepFreeze(obj, seen = new WeakSet()) {
|
|
|
1141
1127
|
}
|
|
1142
1128
|
return obj;
|
|
1143
1129
|
}
|
|
1130
|
+
/**
|
|
1131
|
+
* Creates an immutable copy of a value using structuredClone with a deepFreeze fallback.
|
|
1132
|
+
*
|
|
1133
|
+
* @param value - The value to isolate.
|
|
1134
|
+
* @returns An immutable copy of the value.
|
|
1135
|
+
*/
|
|
1144
1136
|
const isolateValue = (value) => {
|
|
1145
1137
|
if (value === null || typeof value !== 'object')
|
|
1146
1138
|
return value;
|
|
@@ -1169,12 +1161,6 @@ const isolateValue = (value) => {
|
|
|
1169
1161
|
}
|
|
1170
1162
|
};
|
|
1171
1163
|
|
|
1172
|
-
// --- AI Model File Path (DO NOT DELETE) ---
|
|
1173
|
-
// FilePath: libs > shared > src > lib > utils > logic > logic.utils.ts
|
|
1174
|
-
// Updated: 2026-04-09 18:30
|
|
1175
|
-
// Generated by pathcomment [tab] (see .vscode/typescript.code-snippets) or
|
|
1176
|
-
// cmd+alt+j (see .vscode/keybindings.json)
|
|
1177
|
-
// --- END AI MODEL FILE PATH ---
|
|
1178
1164
|
/**
|
|
1179
1165
|
* Indicates whether a final pipeline value represents a NOOP condition.
|
|
1180
1166
|
*
|
|
@@ -1184,9 +1170,21 @@ const isolateValue = (value) => {
|
|
|
1184
1170
|
const isVaultNoop = (current) => {
|
|
1185
1171
|
return current === VAULT_NOOP;
|
|
1186
1172
|
};
|
|
1173
|
+
/**
|
|
1174
|
+
* Indicates whether a final pipeline value represents the clear-state sentinel.
|
|
1175
|
+
*
|
|
1176
|
+
* @param current - The computed pipeline result.
|
|
1177
|
+
* @returns `true` if the value is the `VAULT_CLEAR_STATE` sentinel.
|
|
1178
|
+
*/
|
|
1187
1179
|
const isVaultClearState = (current) => {
|
|
1188
1180
|
return current === VAULT_CLEAR_STATE;
|
|
1189
1181
|
};
|
|
1182
|
+
/**
|
|
1183
|
+
* Indicates whether a final pipeline value represents the continue sentinel.
|
|
1184
|
+
*
|
|
1185
|
+
* @param current - The computed pipeline result.
|
|
1186
|
+
* @returns `true` if the value is the `VAULT_CONTINUE` sentinel.
|
|
1187
|
+
*/
|
|
1190
1188
|
const isVaultContinue = (current) => {
|
|
1191
1189
|
return current === VAULT_CONTINUE;
|
|
1192
1190
|
};
|
|
@@ -1219,14 +1217,38 @@ const isDefined = (current) => !isUndefined(current);
|
|
|
1219
1217
|
* @returns `true` for `null` or `undefined`, otherwise `false`.
|
|
1220
1218
|
*/
|
|
1221
1219
|
const isNullish = (current) => current == null;
|
|
1220
|
+
/**
|
|
1221
|
+
* Determines whether a value is a function.
|
|
1222
|
+
*
|
|
1223
|
+
* @param value - The value to check.
|
|
1224
|
+
* @returns `true` if the value is a function.
|
|
1225
|
+
*/
|
|
1222
1226
|
const isFunction = (value) => typeof value === 'function';
|
|
1227
|
+
/**
|
|
1228
|
+
* Determines whether a value is a non-null object.
|
|
1229
|
+
*
|
|
1230
|
+
* @param value - The value to check.
|
|
1231
|
+
* @returns `true` if the value is an object and not null.
|
|
1232
|
+
*/
|
|
1223
1233
|
const isObject = (value) => typeof value === 'object' && value !== null;
|
|
1234
|
+
/**
|
|
1235
|
+
* Determines whether a value is a plain object with no custom prototype.
|
|
1236
|
+
*
|
|
1237
|
+
* @param value - The value to check.
|
|
1238
|
+
* @returns `true` if the value is a plain object.
|
|
1239
|
+
*/
|
|
1224
1240
|
const isPlainObject = (value) => {
|
|
1225
1241
|
if (value === null || typeof value !== 'object')
|
|
1226
1242
|
return false;
|
|
1227
1243
|
const proto = Object.getPrototypeOf(value);
|
|
1228
1244
|
return proto === Object.prototype || proto === null;
|
|
1229
1245
|
};
|
|
1246
|
+
/**
|
|
1247
|
+
* Determines whether a value conforms to the StateInputShape contract.
|
|
1248
|
+
*
|
|
1249
|
+
* @param value - The value to inspect.
|
|
1250
|
+
* @returns `true` if the value is a plain object with recognized state keys or is empty.
|
|
1251
|
+
*/
|
|
1230
1252
|
const isStateInputShape = (value) => {
|
|
1231
1253
|
if (!isPlainObject(value))
|
|
1232
1254
|
return false;
|
|
@@ -1238,6 +1260,12 @@ const isStateInputShape = (value) => {
|
|
|
1238
1260
|
return hasKnownKey || isEmptyObject;
|
|
1239
1261
|
};
|
|
1240
1262
|
|
|
1263
|
+
/**
|
|
1264
|
+
* Determines whether a value is a thenable Promise-like object.
|
|
1265
|
+
*
|
|
1266
|
+
* @param value - The value to inspect.
|
|
1267
|
+
* @returns `true` if the value has a callable `then` property.
|
|
1268
|
+
*/
|
|
1241
1269
|
function isPromise(value) {
|
|
1242
1270
|
return (!!value &&
|
|
1243
1271
|
(typeof value === 'object' || typeof value === 'function') &&
|
|
@@ -1272,22 +1300,10 @@ function isHttpResourceRef(obj) {
|
|
|
1272
1300
|
'hasValue' in obj);
|
|
1273
1301
|
}
|
|
1274
1302
|
|
|
1275
|
-
// --- AI Model File Path (DO NOT DELETE) ---
|
|
1276
|
-
// FilePath: libs > shared > src > lib > utils > index.ts
|
|
1277
|
-
// Updated: 2026-03-24 09:59
|
|
1278
|
-
// Generated by pathcomment [tab] (see .vscode/typescript.code-snippets) or
|
|
1279
|
-
// cmd+alt+j (see .vscode/keybindings.json)
|
|
1280
|
-
// --- END AI MODEL FILE PATH ---
|
|
1281
1303
|
/* -----------------------------------------------------------
|
|
1282
1304
|
* UTILITY FUNCTIONS (SAFE TO WILDCARD)
|
|
1283
1305
|
* --------------------------------------------------------- */
|
|
1284
1306
|
|
|
1285
|
-
// --- AI Model File Path (DO NOT DELETE) ---
|
|
1286
|
-
// FilePath: libs > shared > src > public-api.ts
|
|
1287
|
-
// Updated: 2026-03-23 16:55
|
|
1288
|
-
// Generated by pathcomment [tab] (see .vscode/typescript.code-snippets) or
|
|
1289
|
-
// cmd+alt+j (see .vscode/keybindings.json)
|
|
1290
|
-
// --- END AI MODEL FILE PATH ---
|
|
1291
1307
|
/*
|
|
1292
1308
|
* Public API Surface of @sdux-vault/shared
|
|
1293
1309
|
*
|