@contentful/optimization-core 0.1.0-alpha → 0.1.0-alpha11

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (149) hide show
  1. package/README.md +329 -93
  2. package/dist/160.mjs +3 -0
  3. package/dist/260.mjs +14 -0
  4. package/dist/260.mjs.map +1 -0
  5. package/dist/499.mjs +4 -0
  6. package/dist/632.mjs +5 -0
  7. package/dist/632.mjs.map +1 -0
  8. package/dist/942.mjs +2 -0
  9. package/dist/api-client.cjs +60 -0
  10. package/dist/api-client.cjs.map +1 -0
  11. package/dist/api-client.d.cts +4 -0
  12. package/dist/api-client.d.mts +4 -0
  13. package/dist/api-client.d.ts +4 -0
  14. package/dist/api-client.mjs +2 -0
  15. package/dist/api-schemas.cjs +63 -0
  16. package/dist/api-schemas.cjs.map +1 -0
  17. package/dist/api-schemas.d.cts +4 -0
  18. package/dist/api-schemas.d.mts +4 -0
  19. package/dist/api-schemas.d.ts +4 -0
  20. package/dist/api-schemas.mjs +2 -0
  21. package/dist/constants.cjs +78 -0
  22. package/dist/constants.cjs.map +1 -0
  23. package/dist/constants.d.cts +88 -0
  24. package/dist/constants.d.mts +88 -0
  25. package/dist/constants.d.ts +88 -0
  26. package/dist/constants.mjs +1 -0
  27. package/dist/index.cjs +1509 -1715
  28. package/dist/index.cjs.map +1 -1
  29. package/dist/index.d.cts +2523 -0
  30. package/dist/index.d.mts +2523 -0
  31. package/dist/index.d.ts +2523 -15
  32. package/dist/index.mjs +1215 -1362
  33. package/dist/index.mjs.map +1 -1
  34. package/dist/logger.cjs +67 -0
  35. package/dist/logger.cjs.map +1 -0
  36. package/dist/logger.d.cts +8 -0
  37. package/dist/logger.d.mts +8 -0
  38. package/dist/logger.d.ts +8 -0
  39. package/dist/logger.mjs +2 -0
  40. package/dist/symbols.cjs +42 -0
  41. package/dist/symbols.cjs.map +1 -0
  42. package/dist/symbols.d.cts +10 -0
  43. package/dist/symbols.d.mts +10 -0
  44. package/dist/symbols.d.ts +10 -0
  45. package/dist/symbols.mjs +1 -0
  46. package/package.json +78 -12
  47. package/dist/Consent.d.ts +0 -44
  48. package/dist/Consent.d.ts.map +0 -1
  49. package/dist/Consent.js +0 -2
  50. package/dist/Consent.js.map +0 -1
  51. package/dist/CoreBase.d.ts +0 -161
  52. package/dist/CoreBase.d.ts.map +0 -1
  53. package/dist/CoreBase.js +0 -151
  54. package/dist/CoreBase.js.map +0 -1
  55. package/dist/CoreStateful.d.ts +0 -142
  56. package/dist/CoreStateful.d.ts.map +0 -1
  57. package/dist/CoreStateful.js +0 -137
  58. package/dist/CoreStateful.js.map +0 -1
  59. package/dist/CoreStateless.d.ts +0 -53
  60. package/dist/CoreStateless.d.ts.map +0 -1
  61. package/dist/CoreStateless.js +0 -43
  62. package/dist/CoreStateless.js.map +0 -1
  63. package/dist/ProductBase.d.ts +0 -83
  64. package/dist/ProductBase.d.ts.map +0 -1
  65. package/dist/ProductBase.js +0 -50
  66. package/dist/ProductBase.js.map +0 -1
  67. package/dist/analytics/AnalyticsBase.d.ts +0 -35
  68. package/dist/analytics/AnalyticsBase.d.ts.map +0 -1
  69. package/dist/analytics/AnalyticsBase.js +0 -13
  70. package/dist/analytics/AnalyticsBase.js.map +0 -1
  71. package/dist/analytics/AnalyticsStateful.d.ts +0 -138
  72. package/dist/analytics/AnalyticsStateful.d.ts.map +0 -1
  73. package/dist/analytics/AnalyticsStateful.js +0 -179
  74. package/dist/analytics/AnalyticsStateful.js.map +0 -1
  75. package/dist/analytics/AnalyticsStateless.d.ts +0 -48
  76. package/dist/analytics/AnalyticsStateless.d.ts.map +0 -1
  77. package/dist/analytics/AnalyticsStateless.js +0 -61
  78. package/dist/analytics/AnalyticsStateless.js.map +0 -1
  79. package/dist/analytics/index.d.ts +0 -5
  80. package/dist/analytics/index.d.ts.map +0 -1
  81. package/dist/analytics/index.js +0 -5
  82. package/dist/analytics/index.js.map +0 -1
  83. package/dist/global-constants.d.ts +0 -18
  84. package/dist/global-constants.d.ts.map +0 -1
  85. package/dist/global-constants.js +0 -18
  86. package/dist/global-constants.js.map +0 -1
  87. package/dist/index.d.ts.map +0 -1
  88. package/dist/index.js +0 -15
  89. package/dist/index.js.map +0 -1
  90. package/dist/lib/decorators/guardedBy.d.ts +0 -113
  91. package/dist/lib/decorators/guardedBy.d.ts.map +0 -1
  92. package/dist/lib/decorators/guardedBy.js +0 -143
  93. package/dist/lib/decorators/guardedBy.js.map +0 -1
  94. package/dist/lib/decorators/index.d.ts +0 -2
  95. package/dist/lib/decorators/index.d.ts.map +0 -1
  96. package/dist/lib/decorators/index.js +0 -2
  97. package/dist/lib/decorators/index.js.map +0 -1
  98. package/dist/lib/interceptor/InterceptorManager.d.ts +0 -127
  99. package/dist/lib/interceptor/InterceptorManager.d.ts.map +0 -1
  100. package/dist/lib/interceptor/InterceptorManager.js +0 -125
  101. package/dist/lib/interceptor/InterceptorManager.js.map +0 -1
  102. package/dist/lib/interceptor/index.d.ts +0 -2
  103. package/dist/lib/interceptor/index.d.ts.map +0 -1
  104. package/dist/lib/interceptor/index.js +0 -2
  105. package/dist/lib/interceptor/index.js.map +0 -1
  106. package/dist/lib/value-presence/ValuePresence.d.ts +0 -123
  107. package/dist/lib/value-presence/ValuePresence.d.ts.map +0 -1
  108. package/dist/lib/value-presence/ValuePresence.js +0 -141
  109. package/dist/lib/value-presence/ValuePresence.js.map +0 -1
  110. package/dist/lib/value-presence/index.d.ts +0 -2
  111. package/dist/lib/value-presence/index.d.ts.map +0 -1
  112. package/dist/lib/value-presence/index.js +0 -2
  113. package/dist/lib/value-presence/index.js.map +0 -1
  114. package/dist/personalization/PersonalizationBase.d.ts +0 -184
  115. package/dist/personalization/PersonalizationBase.d.ts.map +0 -1
  116. package/dist/personalization/PersonalizationBase.js +0 -76
  117. package/dist/personalization/PersonalizationBase.js.map +0 -1
  118. package/dist/personalization/PersonalizationStateful.d.ts +0 -226
  119. package/dist/personalization/PersonalizationStateful.d.ts.map +0 -1
  120. package/dist/personalization/PersonalizationStateful.js +0 -297
  121. package/dist/personalization/PersonalizationStateful.js.map +0 -1
  122. package/dist/personalization/PersonalizationStateless.d.ts +0 -74
  123. package/dist/personalization/PersonalizationStateless.d.ts.map +0 -1
  124. package/dist/personalization/PersonalizationStateless.js +0 -98
  125. package/dist/personalization/PersonalizationStateless.js.map +0 -1
  126. package/dist/personalization/index.d.ts +0 -6
  127. package/dist/personalization/index.d.ts.map +0 -1
  128. package/dist/personalization/index.js +0 -6
  129. package/dist/personalization/index.js.map +0 -1
  130. package/dist/personalization/resolvers/FlagsResolver.d.ts +0 -35
  131. package/dist/personalization/resolvers/FlagsResolver.d.ts.map +0 -1
  132. package/dist/personalization/resolvers/FlagsResolver.js +0 -47
  133. package/dist/personalization/resolvers/FlagsResolver.js.map +0 -1
  134. package/dist/personalization/resolvers/MergeTagValueResolver.d.ts +0 -74
  135. package/dist/personalization/resolvers/MergeTagValueResolver.d.ts.map +0 -1
  136. package/dist/personalization/resolvers/MergeTagValueResolver.js +0 -109
  137. package/dist/personalization/resolvers/MergeTagValueResolver.js.map +0 -1
  138. package/dist/personalization/resolvers/PersonalizedEntryResolver.d.ts +0 -142
  139. package/dist/personalization/resolvers/PersonalizedEntryResolver.d.ts.map +0 -1
  140. package/dist/personalization/resolvers/PersonalizedEntryResolver.js +0 -196
  141. package/dist/personalization/resolvers/PersonalizedEntryResolver.js.map +0 -1
  142. package/dist/personalization/resolvers/index.d.ts +0 -7
  143. package/dist/personalization/resolvers/index.d.ts.map +0 -1
  144. package/dist/personalization/resolvers/index.js +0 -7
  145. package/dist/personalization/resolvers/index.js.map +0 -1
  146. package/dist/signals.d.ts +0 -35
  147. package/dist/signals.d.ts.map +0 -1
  148. package/dist/signals.js +0 -30
  149. package/dist/signals.js.map +0 -1
package/dist/index.js.map DELETED
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,EAAE,OAAO,EAA6B,MAAM,WAAW,CAAA;AAE7E,cAAc,qCAAqC,CAAA;AACnD,cAAc,QAAQ,CAAA;AACtB,cAAc,aAAa,CAAA;AAC3B,cAAc,YAAY,CAAA;AAC1B,cAAc,gBAAgB,CAAA;AAC9B,cAAc,iBAAiB,CAAA;AAC/B,cAAc,oBAAoB,CAAA;AAClC,cAAc,kBAAkB,CAAA;AAChC,cAAc,mBAAmB,CAAA;AACjC,cAAc,sBAAsB,CAAA;AACpC,cAAc,mBAAmB,CAAA;AAEjC,OAAO,EAAE,OAAO,IAAI,YAAY,EAAE,MAAM,gBAAgB,CAAA;AACxD,OAAO,EAAE,OAAO,IAAI,aAAa,EAAE,MAAM,iBAAiB,CAAA"}
@@ -1,113 +0,0 @@
1
- /**
2
- * A callback invoked when a method call is blocked by {@link guardedBy}.
3
- *
4
- * @param methodName - The name of the method that was attempted.
5
- * @param args - The readonly array of arguments supplied to the blocked call.
6
- * @returns Nothing.
7
- *
8
- * @public
9
- */
10
- type BlockHandler = (methodName: string, args: readonly unknown[]) => void;
11
- /**
12
- * The original method implementation.
13
- *
14
- * @typeParam A - The parameter tuple of the original method.
15
- * @typeParam R - The return type of the original method.
16
- * @param value - The method being decorated.
17
- * @param context - The Stage-3 decorator context for a class method.
18
- * @returns Nothing.
19
- *
20
- * @remarks
21
- * Users do not call this directly; it's returned by {@link guardedBy}.
22
- */
23
- type GuardedByFunction<T extends object> = <A extends readonly unknown[], R>(value: (...args: A) => R, context: ClassMethodDecoratorContext<T, (...args: A) => R>) => void;
24
- /**
25
- * Options that tweak the behavior of {@link guardedBy}.
26
- *
27
- * @typeParam T - The instance type on which the decorator is applied.
28
- *
29
- * @public
30
- */
31
- export interface GuardedByOptions<T extends object> {
32
- /**
33
- * Inverts the predicate result.
34
- *
35
- * When `true`, a truthy predicate result **blocks** the method.
36
- * When `false` (default) or omitted, a truthy predicate result **allows** the method.
37
- *
38
- * @defaultValue `false`
39
- * @remarks
40
- * This option is useful when the predicate expresses a *forbid* condition
41
- * (e.g. "isLocked" or "isDestroyed") rather than an *allow* condition.
42
- */
43
- readonly invert?: boolean;
44
- /**
45
- * Either a function to call when a method is blocked, or the name/symbol of
46
- * an instance method on `this` to call when blocked.
47
- *
48
- * Both forms are **synchronous** and receive `(methodName, argsArray)`.
49
- * If omitted, blocked calls fail silently (i.e., return `undefined` or
50
- * `Promise<undefined>` for async methods).
51
- *
52
- * @remarks
53
- * - If a property key is supplied and the instance does not have a callable at that key,
54
- * the hook is ignored.
55
- * - The hook **must not** be `async`; any async work should be scheduled manually.
56
- */
57
- readonly onBlocked?: BlockHandler | (keyof T & (string | symbol));
58
- }
59
- /**
60
- * Decorator factory that **guards** class methods behind a synchronous predicate.
61
- *
62
- * When a decorated method is invoked:
63
- * - If the predicate returns a value that evaluates to **allowed** (see `invert`), the original
64
- * method is executed and its result is returned.
65
- * - If the call is **blocked**, the optional `onBlocked` hook is invoked (if configured) and:
66
- * - `undefined` is returned for sync methods; or
67
- * - `Promise<undefined>` is returned for async methods (to preserve `await` compatibility).
68
- *
69
- * @typeParam T - The instance type that owns both the predicate and the decorated method.
70
- *
71
- * @param predicateName - The name (string or symbol) of a **synchronous** instance method on `this`
72
- * that acts as the predicate. It is called as `this[predicateName](methodName, argsArray)`.
73
- * @param opts - Optional {@link GuardedByOptions | options} to configure inversion and `onBlocked`.
74
- *
75
- * @returns A methods-only class decorator compatible with Stage-3 decorators that wraps the method.
76
- *
77
- * @throws TypeError
78
- * Thrown at initialization time (first instance construction) if `predicateName` does not resolve
79
- * to a **synchronous function** on the instance.
80
- *
81
- * @remarks
82
- * - This is a **methods-only** decorator; applying it to accessors/fields is a no-op.
83
- * - The decorator preserves the original method's sync/async shape.
84
- * - The predicate is invoked with `(decoratedMethodName, argsArray)` to support context-aware checks.
85
- *
86
- * @example
87
- * Here, `canRun` allows the call when it returns truthy:
88
- * ```ts
89
- * class Runner {
90
- * canRun(method: string, _args: readonly unknown[]) { return method !== 'stop'; }
91
- *
92
- * @guardedBy<Runner>('canRun')
93
- * go() { console.log('running'); }
94
- * }
95
- * ```
96
- *
97
- * @example
98
- * Invert the predicate and call a handler on block:
99
- * ```ts
100
- * class Door {
101
- * isLocked() { return true } // truthy means "locked"
102
- * onBlocked(method: string) { console.warn(`${method} blocked`) }
103
- *
104
- * @guardedBy<Door>('isLocked', { invert: true, onBlocked: 'onBlocked' })
105
- * open() { /* ... *\/ }
106
- * }
107
- * ```
108
- *
109
- * @public
110
- */
111
- export declare function guardedBy<T extends object>(predicateName: keyof T & (string | symbol), opts?: GuardedByOptions<T>): GuardedByFunction<T>;
112
- export {};
113
- //# sourceMappingURL=guardedBy.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"guardedBy.d.ts","sourceRoot":"","sources":["../../../src/lib/decorators/guardedBy.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AACH,KAAK,YAAY,GAAG,CAAC,UAAU,EAAE,MAAM,EAAE,IAAI,EAAE,SAAS,OAAO,EAAE,KAAK,IAAI,CAAA;AAE1E;;;;;;;;;;;GAWG;AACH,KAAK,iBAAiB,CAAC,CAAC,SAAS,MAAM,IAAI,CAAC,CAAC,SAAS,SAAS,OAAO,EAAE,EAAE,CAAC,EACzE,KAAK,EAAE,CAAC,GAAG,IAAI,EAAE,CAAC,KAAK,CAAC,EACxB,OAAO,EAAE,2BAA2B,CAAC,CAAC,EAAE,CAAC,GAAG,IAAI,EAAE,CAAC,KAAK,CAAC,CAAC,KACvD,IAAI,CAAA;AAET;;;;;;GAMG;AACH,MAAM,WAAW,gBAAgB,CAAC,CAAC,SAAS,MAAM;IAChD;;;;;;;;;;OAUG;IACH,QAAQ,CAAC,MAAM,CAAC,EAAE,OAAO,CAAA;IAEzB;;;;;;;;;;;;OAYG;IACH,QAAQ,CAAC,SAAS,CAAC,EAAE,YAAY,GAAG,CAAC,MAAM,CAAC,GAAG,CAAC,MAAM,GAAG,MAAM,CAAC,CAAC,CAAA;CAClE;AAiDD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAmDG;AACH,wBAAgB,SAAS,CAAC,CAAC,SAAS,MAAM,EACxC,aAAa,EAAE,MAAM,CAAC,GAAG,CAAC,MAAM,GAAG,MAAM,CAAC,EAC1C,IAAI,CAAC,EAAE,gBAAgB,CAAC,CAAC,CAAC,GACzB,iBAAiB,CAAC,CAAC,CAAC,CAgEtB"}
@@ -1,143 +0,0 @@
1
- /**
2
- * Type guard for functions.
3
- *
4
- * @internal
5
- */
6
- const isFunction = (v) => typeof v === 'function';
7
- /**
8
- * Converts a property key to a readable string for logs and messages.
9
- *
10
- * @param name - The property key to stringify.
11
- * @returns A human-friendly name.
12
- *
13
- * @internal
14
- */
15
- const nameToString = (name) => typeof name === 'string'
16
- ? name
17
- : typeof name === 'symbol'
18
- ? (name.description ?? String(name))
19
- : String(name);
20
- /**
21
- * True when the `onBlocked` option is a property key (string or symbol).
22
- *
23
- * @typeParam T - The instance type.
24
- * @param v - The `onBlocked` option value.
25
- * @returns Whether `v` is a property key.
26
- *
27
- * @internal
28
- */
29
- const isOnBlockedKey = (v) => typeof v === 'string' || typeof v === 'symbol';
30
- /**
31
- * Detects declared `async` functions.
32
- *
33
- * @param fn - The candidate to test.
34
- * @returns `true` if `fn` is an async function, else `false`.
35
- *
36
- * @internal
37
- */
38
- const isAsyncFunction = (fn) => Object.prototype.toString.call(fn) === '[object AsyncFunction]';
39
- /**
40
- * Decorator factory that **guards** class methods behind a synchronous predicate.
41
- *
42
- * When a decorated method is invoked:
43
- * - If the predicate returns a value that evaluates to **allowed** (see `invert`), the original
44
- * method is executed and its result is returned.
45
- * - If the call is **blocked**, the optional `onBlocked` hook is invoked (if configured) and:
46
- * - `undefined` is returned for sync methods; or
47
- * - `Promise<undefined>` is returned for async methods (to preserve `await` compatibility).
48
- *
49
- * @typeParam T - The instance type that owns both the predicate and the decorated method.
50
- *
51
- * @param predicateName - The name (string or symbol) of a **synchronous** instance method on `this`
52
- * that acts as the predicate. It is called as `this[predicateName](methodName, argsArray)`.
53
- * @param opts - Optional {@link GuardedByOptions | options} to configure inversion and `onBlocked`.
54
- *
55
- * @returns A methods-only class decorator compatible with Stage-3 decorators that wraps the method.
56
- *
57
- * @throws TypeError
58
- * Thrown at initialization time (first instance construction) if `predicateName` does not resolve
59
- * to a **synchronous function** on the instance.
60
- *
61
- * @remarks
62
- * - This is a **methods-only** decorator; applying it to accessors/fields is a no-op.
63
- * - The decorator preserves the original method's sync/async shape.
64
- * - The predicate is invoked with `(decoratedMethodName, argsArray)` to support context-aware checks.
65
- *
66
- * @example
67
- * Here, `canRun` allows the call when it returns truthy:
68
- * ```ts
69
- * class Runner {
70
- * canRun(method: string, _args: readonly unknown[]) { return method !== 'stop'; }
71
- *
72
- * @guardedBy<Runner>('canRun')
73
- * go() { console.log('running'); }
74
- * }
75
- * ```
76
- *
77
- * @example
78
- * Invert the predicate and call a handler on block:
79
- * ```ts
80
- * class Door {
81
- * isLocked() { return true } // truthy means "locked"
82
- * onBlocked(method: string) { console.warn(`${method} blocked`) }
83
- *
84
- * @guardedBy<Door>('isLocked', { invert: true, onBlocked: 'onBlocked' })
85
- * open() { /* ... *\/ }
86
- * }
87
- * ```
88
- *
89
- * @public
90
- */
91
- export function guardedBy(predicateName, opts) {
92
- return function (_value, context) {
93
- const decoratedName = nameToString(context.name);
94
- context.addInitializer(function init() {
95
- // Original method on the instance
96
- const originalUnknown = Reflect.get(this, context.name);
97
- if (!isFunction(originalUnknown)) {
98
- return; // defensive: nothing to wrap
99
- }
100
- const original = originalUnknown;
101
- const originalIsAsync = isAsyncFunction(original);
102
- const resolvePredicate = (self) => {
103
- const { [predicateName]: cand } = self;
104
- if (!isFunction(cand)) {
105
- throw new TypeError(`@guardedBy expects predicate "${String(predicateName)}" to be a synchronous function.`);
106
- }
107
- return cand;
108
- };
109
- const computeAllowed = (self, args) => {
110
- const pred = resolvePredicate(self);
111
- const ok = Boolean(pred.call(self, decoratedName, args));
112
- return opts?.invert === true ? !ok : ok;
113
- };
114
- const runOnBlocked = (self, args) => {
115
- const { onBlocked } = opts ?? {};
116
- if (onBlocked === undefined) {
117
- return;
118
- }
119
- if (isFunction(onBlocked)) {
120
- onBlocked.call(self, decoratedName, args);
121
- return;
122
- }
123
- if (isOnBlockedKey(onBlocked)) {
124
- const { [onBlocked]: handlerCandidate } = self;
125
- if (isFunction(handlerCandidate)) {
126
- handlerCandidate.call(self, decoratedName, args);
127
- }
128
- }
129
- };
130
- const blockedReturn = () => originalIsAsync ? Promise.resolve(undefined) : undefined;
131
- const wrapped = function (...args) {
132
- if (!computeAllowed(this, args)) {
133
- runOnBlocked(this, args);
134
- return blockedReturn();
135
- }
136
- return original.call(this, ...args);
137
- };
138
- // Replace the instance method with our wrapper
139
- Reflect.set(this, context.name, wrapped);
140
- });
141
- };
142
- }
143
- //# sourceMappingURL=guardedBy.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"guardedBy.js","sourceRoot":"","sources":["../../../src/lib/decorators/guardedBy.ts"],"names":[],"mappings":"AAiEA;;;;GAIG;AACH,MAAM,UAAU,GAAG,CAAC,CAAU,EAAiD,EAAE,CAC/E,OAAO,CAAC,KAAK,UAAU,CAAA;AAEzB;;;;;;;GAOG;AACH,MAAM,YAAY,GAAG,CAAC,IAAiB,EAAU,EAAE,CACjD,OAAO,IAAI,KAAK,QAAQ;IACtB,CAAC,CAAC,IAAI;IACN,CAAC,CAAC,OAAO,IAAI,KAAK,QAAQ;QACxB,CAAC,CAAC,CAAC,IAAI,CAAC,WAAW,IAAI,MAAM,CAAC,IAAI,CAAC,CAAC;QACpC,CAAC,CAAC,MAAM,CAAC,IAAI,CAAC,CAAA;AAEpB;;;;;;;;GAQG;AACH,MAAM,cAAc,GAAG,CACrB,CAAmC,EACD,EAAE,CAAC,OAAO,CAAC,KAAK,QAAQ,IAAI,OAAO,CAAC,KAAK,QAAQ,CAAA;AAErF;;;;;;;GAOG;AACH,MAAM,eAAe,GAAG,CAAC,EAA4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,CAAC,IAAI,EAAE,OAAO,CAAC,CAAA;QAC1C,CAAC,CAAC,CAAA;IACJ,CAAC,CAAA;AACH,CAAC"}
@@ -1,2 +0,0 @@
1
- export { guardedBy } from './guardedBy';
2
- //# sourceMappingURL=index.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/lib/decorators/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAA"}
@@ -1,2 +0,0 @@
1
- export { guardedBy } from './guardedBy';
2
- //# sourceMappingURL=index.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/lib/decorators/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAA"}
@@ -1,127 +0,0 @@
1
- /**
2
- * A utility type representing a value that may be synchronously available or
3
- * produced asynchronously.
4
- *
5
- * @typeParam T - The resolved value type.
6
- * @public
7
- */
8
- type MaybePromise<T> = T | Promise<T>;
9
- /**
10
- * A function that receives a value of type `T` and returns a (possibly async)
11
- * value of the same type `T`. The input is marked as `readonly` to discourage
12
- * mutation of the original object.
13
- *
14
- * @typeParam T - The value type intercepted and returned.
15
- * @param value - The current (readonly) value in the interception chain.
16
- * @returns The next value for the chain, either directly or via a promise.
17
- * @remarks Implementations SHOULD avoid mutating `value` and instead return a
18
- * new or safely-updated instance.
19
- * @see {@link InterceptorManager}
20
- * @public
21
- */
22
- export type Interceptor<T> = (value: Readonly<T>) => MaybePromise<T>;
23
- /**
24
- * Manages a list of interceptors and provides a way to run them in sequence.
25
- *
26
- * Interceptors are executed in insertion order. Each interceptor receives the
27
- * result of the previous interceptor (or the initial input for the first one)
28
- * and may return a new value synchronously or asynchronously.
29
- *
30
- * @typeParam T - The value type processed by the interceptors.
31
- * @remarks This class snapshots the current interceptor list at invocation time
32
- * so additions/removals during `run` do not affect the in-flight execution.
33
- * @example
34
- * ```ts
35
- * const mgr = new InterceptorManager<number>();
36
- * const id = mgr.add((n) => n + 1);
37
- * const final = await mgr.run(1); // 2
38
- * mgr.remove(id);
39
- * ```
40
- * @public
41
- */
42
- export declare class InterceptorManager<T> {
43
- /**
44
- * The registry of interceptors keyed by their insertion id.
45
- *
46
- * @privateRemarks Internal storage; use {@link add}, {@link remove}, and
47
- * {@link clear} to manage contents.
48
- * @readonly
49
- * @defaultValue `new Map()`
50
- */
51
- private readonly interceptors;
52
- /**
53
- * The next numeric id to assign to an added interceptor.
54
- *
55
- * @privateRemarks Used only to generate unique, monotonically increasing ids.
56
- * @defaultValue `0`
57
- */
58
- private nextId;
59
- /**
60
- * Add an interceptor and return its identifier.
61
- *
62
- * @param interceptor - The interceptor function to register.
63
- * @returns The numeric id that can later be used with {@link remove}.
64
- * @remarks Interceptors are executed in the order they are added.
65
- * @example
66
- * ```ts
67
- * const id = manager.add(async (value) => transform(value));
68
- * ```
69
- * @public
70
- */
71
- add(interceptor: Interceptor<T>): number;
72
- /**
73
- * Remove an interceptor by its identifier.
74
- *
75
- * @param id - The id previously returned by {@link add}.
76
- * @returns `true` if an interceptor was removed; otherwise `false`.
77
- * @example
78
- * ```ts
79
- * const removed = manager.remove(id);
80
- * ```
81
- * @public
82
- */
83
- remove(id: number): boolean;
84
- /**
85
- * Remove all registered interceptors.
86
- *
87
- * @returns Nothing.
88
- * @remarks After calling this, {@link count} will return `0`.
89
- * @example
90
- * ```ts
91
- * manager.clear();
92
- * ```
93
- * @public
94
- */
95
- clear(): void;
96
- /**
97
- * Get the number of currently registered interceptors.
98
- *
99
- * @returns The count of interceptors.
100
- * @example
101
- * ```ts
102
- * if (manager.count() === 0) { /* ... *\/ }
103
- * ```
104
- * @public
105
- */
106
- count(): number;
107
- /**
108
- * Run all interceptors in sequence on an input value and return the final result.
109
- *
110
- * Supports both sync and async interceptors; the return type is always `Promise<T>`
111
- * for consistency.
112
- *
113
- * @param input - The initial value to pass to the first interceptor.
114
- * @returns A promise resolving to the final value after all interceptors have run.
115
- * @throws May rethrow any error thrown by an interceptor. <!-- Intentionally vague: error type depends on interceptor implementation -->
116
- * @remarks The interceptor list is snapshotted at invocation time; changes to
117
- * the registry during execution do not affect the running sequence.
118
- * @example
119
- * ```ts
120
- * const result = await manager.run(initial);
121
- * ```
122
- * @public
123
- */
124
- run(input: T): Promise<T>;
125
- }
126
- export {};
127
- //# sourceMappingURL=InterceptorManager.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"InterceptorManager.d.ts","sourceRoot":"","sources":["../../../src/lib/interceptor/InterceptorManager.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,KAAK,YAAY,CAAC,CAAC,IAAI,CAAC,GAAG,OAAO,CAAC,CAAC,CAAC,CAAA;AAErC;;;;;;;;;;;;GAYG;AACH,MAAM,MAAM,WAAW,CAAC,CAAC,IAAI,CAAC,KAAK,EAAE,QAAQ,CAAC,CAAC,CAAC,KAAK,YAAY,CAAC,CAAC,CAAC,CAAA;AAEpE;;;;;;;;;;;;;;;;;;GAkBG;AACH,qBAAa,kBAAkB,CAAC,CAAC;IAC/B;;;;;;;OAOG;IACH,OAAO,CAAC,QAAQ,CAAC,YAAY,CAAoC;IAEjE;;;;;OAKG;IACH,OAAO,CAAC,MAAM,CAAI;IAElB;;;;;;;;;;;OAWG;IACH,GAAG,CAAC,WAAW,EAAE,WAAW,CAAC,CAAC,CAAC,GAAG,MAAM;IAOxC;;;;;;;;;;OAUG;IACH,MAAM,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO;IAI3B;;;;;;;;;;OAUG;IACH,KAAK,IAAI,IAAI;IAIb;;;;;;;;;OASG;IACH,KAAK,IAAI,MAAM;IAIf;;;;;;;;;;;;;;;;OAgBG;IACG,GAAG,CAAC,KAAK,EAAE,CAAC,GAAG,OAAO,CAAC,CAAC,CAAC;CAchC"}
@@ -1,125 +0,0 @@
1
- /**
2
- * Manages a list of interceptors and provides a way to run them in sequence.
3
- *
4
- * Interceptors are executed in insertion order. Each interceptor receives the
5
- * result of the previous interceptor (or the initial input for the first one)
6
- * and may return a new value synchronously or asynchronously.
7
- *
8
- * @typeParam T - The value type processed by the interceptors.
9
- * @remarks This class snapshots the current interceptor list at invocation time
10
- * so additions/removals during `run` do not affect the in-flight execution.
11
- * @example
12
- * ```ts
13
- * const mgr = new InterceptorManager<number>();
14
- * const id = mgr.add((n) => n + 1);
15
- * const final = await mgr.run(1); // 2
16
- * mgr.remove(id);
17
- * ```
18
- * @public
19
- */
20
- export class InterceptorManager {
21
- /**
22
- * The registry of interceptors keyed by their insertion id.
23
- *
24
- * @privateRemarks Internal storage; use {@link add}, {@link remove}, and
25
- * {@link clear} to manage contents.
26
- * @readonly
27
- * @defaultValue `new Map()`
28
- */
29
- interceptors = new Map();
30
- /**
31
- * The next numeric id to assign to an added interceptor.
32
- *
33
- * @privateRemarks Used only to generate unique, monotonically increasing ids.
34
- * @defaultValue `0`
35
- */
36
- nextId = 0;
37
- /**
38
- * Add an interceptor and return its identifier.
39
- *
40
- * @param interceptor - The interceptor function to register.
41
- * @returns The numeric id that can later be used with {@link remove}.
42
- * @remarks Interceptors are executed in the order they are added.
43
- * @example
44
- * ```ts
45
- * const id = manager.add(async (value) => transform(value));
46
- * ```
47
- * @public
48
- */
49
- add(interceptor) {
50
- const { nextId: id } = this;
51
- this.nextId += 1;
52
- this.interceptors.set(id, interceptor);
53
- return id;
54
- }
55
- /**
56
- * Remove an interceptor by its identifier.
57
- *
58
- * @param id - The id previously returned by {@link add}.
59
- * @returns `true` if an interceptor was removed; otherwise `false`.
60
- * @example
61
- * ```ts
62
- * const removed = manager.remove(id);
63
- * ```
64
- * @public
65
- */
66
- remove(id) {
67
- return this.interceptors.delete(id);
68
- }
69
- /**
70
- * Remove all registered interceptors.
71
- *
72
- * @returns Nothing.
73
- * @remarks After calling this, {@link count} will return `0`.
74
- * @example
75
- * ```ts
76
- * manager.clear();
77
- * ```
78
- * @public
79
- */
80
- clear() {
81
- this.interceptors.clear();
82
- }
83
- /**
84
- * Get the number of currently registered interceptors.
85
- *
86
- * @returns The count of interceptors.
87
- * @example
88
- * ```ts
89
- * if (manager.count() === 0) { /* ... *\/ }
90
- * ```
91
- * @public
92
- */
93
- count() {
94
- return this.interceptors.size;
95
- }
96
- /**
97
- * Run all interceptors in sequence on an input value and return the final result.
98
- *
99
- * Supports both sync and async interceptors; the return type is always `Promise<T>`
100
- * for consistency.
101
- *
102
- * @param input - The initial value to pass to the first interceptor.
103
- * @returns A promise resolving to the final value after all interceptors have run.
104
- * @throws May rethrow any error thrown by an interceptor. <!-- Intentionally vague: error type depends on interceptor implementation -->
105
- * @remarks The interceptor list is snapshotted at invocation time; changes to
106
- * the registry during execution do not affect the running sequence.
107
- * @example
108
- * ```ts
109
- * const result = await manager.run(initial);
110
- * ```
111
- * @public
112
- */
113
- async run(input) {
114
- // Snapshot to avoid issues if interceptors are added/removed during execution.
115
- const fns = Array.from(this.interceptors.values());
116
- let acc = input;
117
- for (const fn of fns) {
118
- // Pass a readonly view to discourage mutation of intermediate values.
119
- // Each interceptor must return a T (or Promise<T>).
120
- acc = await fn(acc);
121
- }
122
- return acc;
123
- }
124
- }
125
- //# sourceMappingURL=InterceptorManager.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"InterceptorManager.js","sourceRoot":"","sources":["../../../src/lib/interceptor/InterceptorManager.ts"],"names":[],"mappings":"AAwBA;;;;;;;;;;;;;;;;;;GAkBG;AACH,MAAM,OAAO,kBAAkB;IAC7B;;;;;;;OAOG;IACc,YAAY,GAAG,IAAI,GAAG,EAA0B,CAAA;IAEjE;;;;;OAKG;IACK,MAAM,GAAG,CAAC,CAAA;IAElB;;;;;;;;;;;OAWG;IACH,GAAG,CAAC,WAA2B;QAC7B,MAAM,EAAE,MAAM,EAAE,EAAE,EAAE,GAAG,IAAI,CAAA;QAC3B,IAAI,CAAC,MAAM,IAAI,CAAC,CAAA;QAChB,IAAI,CAAC,YAAY,CAAC,GAAG,CAAC,EAAE,EAAE,WAAW,CAAC,CAAA;QACtC,OAAO,EAAE,CAAA;IACX,CAAC;IAED;;;;;;;;;;OAUG;IACH,MAAM,CAAC,EAAU;QACf,OAAO,IAAI,CAAC,YAAY,CAAC,MAAM,CAAC,EAAE,CAAC,CAAA;IACrC,CAAC;IAED;;;;;;;;;;OAUG;IACH,KAAK;QACH,IAAI,CAAC,YAAY,CAAC,KAAK,EAAE,CAAA;IAC3B,CAAC;IAED;;;;;;;;;OASG;IACH,KAAK;QACH,OAAO,IAAI,CAAC,YAAY,CAAC,IAAI,CAAA;IAC/B,CAAC;IAED;;;;;;;;;;;;;;;;OAgBG;IACH,KAAK,CAAC,GAAG,CAAC,KAAQ;QAChB,+EAA+E;QAC/E,MAAM,GAAG,GAAkC,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,YAAY,CAAC,MAAM,EAAE,CAAC,CAAA;QAEjF,IAAI,GAAG,GAAM,KAAK,CAAA;QAElB,KAAK,MAAM,EAAE,IAAI,GAAG,EAAE,CAAC;YACrB,sEAAsE;YACtE,oDAAoD;YACpD,GAAG,GAAG,MAAM,EAAE,CAAC,GAAkB,CAAC,CAAA;QACpC,CAAC;QAED,OAAO,GAAG,CAAA;IACZ,CAAC;CACF"}
@@ -1,2 +0,0 @@
1
- export * from './InterceptorManager';
2
- //# sourceMappingURL=index.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/lib/interceptor/index.ts"],"names":[],"mappings":"AAAA,cAAc,sBAAsB,CAAA"}
@@ -1,2 +0,0 @@
1
- export * from './InterceptorManager';
2
- //# sourceMappingURL=index.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/lib/interceptor/index.ts"],"names":[],"mappings":"AAAA,cAAc,sBAAsB,CAAA"}