@sdux-vault/core-extensions-angular 0.0.4
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/LICENSE
ADDED
|
@@ -0,0 +1,249 @@
|
|
|
1
|
+
# MIT License
|
|
2
|
+
|
|
3
|
+
(with SDuX Clarification Notice)
|
|
4
|
+
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
## MIT License (Standard Text)
|
|
8
|
+
|
|
9
|
+
Copyright (c) 2026 NextGen Luminary
|
|
10
|
+
|
|
11
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
12
|
+
of this software and associated documentation files (the “Software”), to deal
|
|
13
|
+
in the Software without restriction, including without limitation the rights
|
|
14
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
15
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
16
|
+
furnished to do so, subject to the following conditions:
|
|
17
|
+
|
|
18
|
+
The above copyright notice and this permission notice shall be included in all
|
|
19
|
+
copies or substantial portions of the Software.
|
|
20
|
+
|
|
21
|
+
THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
22
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
23
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
24
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
25
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
26
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
27
|
+
SOFTWARE.
|
|
28
|
+
|
|
29
|
+
---
|
|
30
|
+
|
|
31
|
+
## SDuX Clarification Notice (Non-License Commentary)
|
|
32
|
+
|
|
33
|
+
**IMPORTANT:**
|
|
34
|
+
The following sections are **clarifying notices** provided for transparency, auditability, ecosystem boundary clarity, acquisition readiness, and architectural separation within the SDuX ecosystem. They **do not modify, amend, replace, restrict, supersede, or reinterpret** the MIT License above.
|
|
35
|
+
|
|
36
|
+
If any conflict is perceived between this clarification notice and the MIT License text above, the MIT License text **controls in all cases**.
|
|
37
|
+
|
|
38
|
+
The MIT License text above applies **only** to the specific SDuX repositories and npm packages explicitly designated as open source by NextGen Luminary.
|
|
39
|
+
|
|
40
|
+
---
|
|
41
|
+
|
|
42
|
+
## 1. Scope of This License
|
|
43
|
+
|
|
44
|
+
This MIT License applies exclusively to the following SDuX components:
|
|
45
|
+
|
|
46
|
+
### SDuX Framework Source
|
|
47
|
+
|
|
48
|
+
- @sdux-vault/core
|
|
49
|
+
- @sdux-vault/add-ons
|
|
50
|
+
- @sdux-vault/shared
|
|
51
|
+
- @sdux-vault/devtools/tooling
|
|
52
|
+
- @sdux-vault/devtools/ui
|
|
53
|
+
- @sdux-vault/ui/web-components
|
|
54
|
+
|
|
55
|
+
### SDuX Open-Source npm Packages
|
|
56
|
+
|
|
57
|
+
- Identical package names as listed above when distributed via npm
|
|
58
|
+
|
|
59
|
+
No other SDuX components are licensed under the MIT License unless explicitly stated in writing by NextGen Luminary.
|
|
60
|
+
|
|
61
|
+
The MIT License does **not** apply to any repository, package, module, runtime, binary, service, distribution artifact, hosted system, entitlement service, or enforcement subsystem that is not expressly designated as MIT-licensed.
|
|
62
|
+
|
|
63
|
+
---
|
|
64
|
+
|
|
65
|
+
## 2. Explicit Exclusion of Proprietary Components
|
|
66
|
+
|
|
67
|
+
For the avoidance of doubt:
|
|
68
|
+
|
|
69
|
+
This MIT License **does not apply** to:
|
|
70
|
+
|
|
71
|
+
- @sdux-vault/engine
|
|
72
|
+
- SDuX Vault runtime components
|
|
73
|
+
- Persistence modules
|
|
74
|
+
- Encryption modules
|
|
75
|
+
- Licensing enforcement modules
|
|
76
|
+
- Telemetry systems
|
|
77
|
+
- Commercial-only features
|
|
78
|
+
- Runtime gating mechanisms
|
|
79
|
+
- Deterministic license validation infrastructure
|
|
80
|
+
- Any proprietary binaries, services, network services, entitlement servers, or internal source code
|
|
81
|
+
|
|
82
|
+
Use of proprietary SDuX components is governed exclusively by their applicable commercial or community licenses.
|
|
83
|
+
|
|
84
|
+
No rights—express or implied—are granted to proprietary components by virtue of this MIT License.
|
|
85
|
+
|
|
86
|
+
In particular, this MIT License does **not** grant rights to:
|
|
87
|
+
|
|
88
|
+
- Proprietary runtime enforcement systems
|
|
89
|
+
- Deterministic gating or validation logic
|
|
90
|
+
- License timeout mechanisms
|
|
91
|
+
- Runtime license tokens
|
|
92
|
+
- Production-gating systems
|
|
93
|
+
- Commercial entitlement APIs
|
|
94
|
+
- Proprietary network services or validation endpoints
|
|
95
|
+
- Internal orchestration engines not explicitly released under MIT
|
|
96
|
+
|
|
97
|
+
---
|
|
98
|
+
|
|
99
|
+
## 3. No Transitive or Implied Licensing
|
|
100
|
+
|
|
101
|
+
This MIT License:
|
|
102
|
+
|
|
103
|
+
- Does **not** grant rights to dependencies that are not themselves MIT-licensed
|
|
104
|
+
- Does **not** extend rights to runtime engines, orchestrators, execution layers, or enforcement systems
|
|
105
|
+
- Does **not** create any obligation for NextGen Luminary to open-source additional components
|
|
106
|
+
- Does **not** grant rights to use proprietary licensing APIs, enforcement surfaces, runtime validation endpoints, or commercial network services outside their intended licensed boundaries
|
|
107
|
+
|
|
108
|
+
Each SDuX package is licensed independently and must be evaluated on its own terms.
|
|
109
|
+
|
|
110
|
+
No transitive, derivative, architectural, structural, or implied licensing rights arise merely because MIT-licensed components may interoperate with proprietary components.
|
|
111
|
+
|
|
112
|
+
Interoperability does not imply relicensing, source disclosure obligations, or any grant of rights to non-MIT components.
|
|
113
|
+
|
|
114
|
+
---
|
|
115
|
+
|
|
116
|
+
## 4. Use in Commercial and Enterprise Environments
|
|
117
|
+
|
|
118
|
+
The MIT-licensed SDuX framework components:
|
|
119
|
+
|
|
120
|
+
- May be used in commercial, enterprise, and production environments
|
|
121
|
+
- May be modified and redistributed in accordance with the MIT License
|
|
122
|
+
- May be included in proprietary products, subject to MIT attribution requirements
|
|
123
|
+
|
|
124
|
+
This permissive licensing is intentional and designed to:
|
|
125
|
+
|
|
126
|
+
- Encourage adoption
|
|
127
|
+
- Support long-term maintainability
|
|
128
|
+
- Reduce legal friction during audits and acquisitions
|
|
129
|
+
|
|
130
|
+
No additional enterprise license is required for the MIT-designated components themselves.
|
|
131
|
+
|
|
132
|
+
---
|
|
133
|
+
|
|
134
|
+
## 5. Separation From Third-Party Extensions
|
|
135
|
+
|
|
136
|
+
Third-party extensions, add-ons, Behaviors, Controllers, integrations, or other modules developed by independent Vendors are **independently licensed**.
|
|
137
|
+
|
|
138
|
+
This MIT License:
|
|
139
|
+
|
|
140
|
+
- Does **not** apply to third-party extensions unless explicitly stated by their respective authors
|
|
141
|
+
- Does **not** grant rights to any Vendor-developed Licensed Extension
|
|
142
|
+
- Does **not** modify, override, validate, or enforce any Vendor commercial license
|
|
143
|
+
|
|
144
|
+
MIT-licensed SDuX components may be used to build extensions.
|
|
145
|
+
However:
|
|
146
|
+
|
|
147
|
+
- Any proprietary enforcement components used by such extensions remain separately licensed
|
|
148
|
+
- Runtime gating systems remain governed by their applicable community or commercial licenses
|
|
149
|
+
- Validation, entitlement, or enforcement behavior implemented outside MIT-designated repositories remains subject to its own governing license
|
|
150
|
+
|
|
151
|
+
No open-source contamination, copyleft effect, reciprocal licensing obligation, or forced disclosure requirement is created by virtue of integrating MIT-licensed SDuX components with proprietary or third-party components.
|
|
152
|
+
|
|
153
|
+
---
|
|
154
|
+
|
|
155
|
+
## 6. No Grant of Rights to Commercial Services or APIs
|
|
156
|
+
|
|
157
|
+
For clarity:
|
|
158
|
+
|
|
159
|
+
This MIT License does **not** grant rights to:
|
|
160
|
+
|
|
161
|
+
- Access proprietary commercial APIs
|
|
162
|
+
- Access proprietary network services
|
|
163
|
+
- Access entitlement servers
|
|
164
|
+
- Access validation infrastructure
|
|
165
|
+
- Access hosted SDuX services
|
|
166
|
+
- Bypass production-gating or enforcement systems
|
|
167
|
+
|
|
168
|
+
Any such rights, if available, are governed exclusively by their respective commercial or community licenses.
|
|
169
|
+
|
|
170
|
+
---
|
|
171
|
+
|
|
172
|
+
## 7. Trademark and Branding Clarification
|
|
173
|
+
|
|
174
|
+
This MIT License does **not** grant any trademark rights in the names, logos, product branding, or service marks of NextGen Luminary or SDuX, except as required for reasonable and customary attribution consistent with the MIT License.
|
|
175
|
+
|
|
176
|
+
Use of SDuX or NextGen Luminary trademarks in product names, marketplace listings, or marketing materials may require separate permission.
|
|
177
|
+
|
|
178
|
+
Nothing in this clarification notice modifies the trademark rights (or lack thereof) under the MIT License; it is provided solely for clarity and avoidance of confusion.
|
|
179
|
+
|
|
180
|
+
---
|
|
181
|
+
|
|
182
|
+
## 8. Relationship to Other SDuX Licenses
|
|
183
|
+
|
|
184
|
+
This MIT License operates independently from:
|
|
185
|
+
|
|
186
|
+
- NGL Commercial License 1.0
|
|
187
|
+
- SDuX / Vault Community License
|
|
188
|
+
- Any enterprise or custom licensing agreements
|
|
189
|
+
|
|
190
|
+
Possession or use of MIT-licensed SDuX components does **not** grant access to or rights under those other licenses.
|
|
191
|
+
|
|
192
|
+
Likewise, possession of proprietary SDuX licenses does not alter the terms of the MIT License for designated open-source components.
|
|
193
|
+
|
|
194
|
+
Each license operates independently and must be interpreted separately.
|
|
195
|
+
|
|
196
|
+
---
|
|
197
|
+
|
|
198
|
+
## 9. Assignment and Acquisition Clarity
|
|
199
|
+
|
|
200
|
+
The MIT License is inherently **assignable** and **transferable**.
|
|
201
|
+
|
|
202
|
+
Accordingly:
|
|
203
|
+
|
|
204
|
+
- Use of MIT-licensed SDuX components **does not prevent acquisition**
|
|
205
|
+
- No special approval is required to transfer ownership of products containing these components
|
|
206
|
+
- Auditors and acquiring entities may rely on standard MIT interpretations without exception
|
|
207
|
+
|
|
208
|
+
This aligns with industry-standard expectations for permissive open-source frameworks.
|
|
209
|
+
|
|
210
|
+
---
|
|
211
|
+
|
|
212
|
+
## 10. Audit and Due-Diligence Statement
|
|
213
|
+
|
|
214
|
+
During security reviews, license audits, or acquisition due diligence:
|
|
215
|
+
|
|
216
|
+
- MIT-licensed SDuX components should be reviewed as standard permissive open-source software
|
|
217
|
+
- No copyleft, reciprocity, source disclosure, or distribution obligations apply beyond standard MIT attribution
|
|
218
|
+
- No viral or contaminating license effects exist
|
|
219
|
+
- No patent retaliation, field-of-use restrictions, sublicense limitations, or production-gating obligations exist beyond those inherent in MIT
|
|
220
|
+
|
|
221
|
+
These characteristics are intentional and designed to be acquisition-safe and enterprise-friendly.
|
|
222
|
+
|
|
223
|
+
---
|
|
224
|
+
|
|
225
|
+
## 11. No Modification of License Terms
|
|
226
|
+
|
|
227
|
+
Nothing in this clarification notice:
|
|
228
|
+
|
|
229
|
+
- Modifies the MIT License text
|
|
230
|
+
- Adds restrictions to the MIT License
|
|
231
|
+
- Removes rights granted by the MIT License
|
|
232
|
+
- Expands rights beyond those granted by the MIT License
|
|
233
|
+
|
|
234
|
+
If any conflict is perceived between this clarification notice and the MIT License text above, the MIT License text **controls**.
|
|
235
|
+
|
|
236
|
+
---
|
|
237
|
+
|
|
238
|
+
## 12. Entire Notice
|
|
239
|
+
|
|
240
|
+
This document consists of:
|
|
241
|
+
|
|
242
|
+
1. The unmodified MIT License text
|
|
243
|
+
2. A non-binding clarification notice for transparency, architectural boundary clarity, compliance certainty, and acquisition readiness
|
|
244
|
+
|
|
245
|
+
Together, they provide a complete and accurate description of how MIT licensing is applied within the SDuX ecosystem.
|
|
246
|
+
|
|
247
|
+
---
|
|
248
|
+
|
|
249
|
+
**END OF MIT LICENSE (WITH SDUX CLARIFICATION NOTICE)**
|
package/README.md
ADDED
|
@@ -0,0 +1,207 @@
|
|
|
1
|
+
# @sdux-vault/core-extensions/angular
|
|
2
|
+
|
|
3
|
+
> Angular integration layer for SDuX Vault.
|
|
4
|
+
|
|
5
|
+
`@sdux-vault/core-extensions/angular` provides the **Angular bindings for SDuX Vault**, enabling seamless integration with Angular’s dependency injection, signals, and reactive model.
|
|
6
|
+
|
|
7
|
+
This package connects the SDuX runtime to Angular applications in a **framework-native, reactive, and declarative way**.
|
|
8
|
+
|
|
9
|
+
---
|
|
10
|
+
|
|
11
|
+
## TL;DR
|
|
12
|
+
|
|
13
|
+
For full documentation, guides, and API references:
|
|
14
|
+
https://www.sdux-vault.com
|
|
15
|
+
|
|
16
|
+
---
|
|
17
|
+
|
|
18
|
+
## Overview
|
|
19
|
+
|
|
20
|
+
SDuX is built as a layered system:
|
|
21
|
+
|
|
22
|
+
```plaintext
|
|
23
|
+
shared → engine → core → core-extensions → apps
|
|
24
|
+
└─────────────────────────────→ devtools
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
- **apps** → Angular applications
|
|
28
|
+
- **core** → behavior execution runtime
|
|
29
|
+
- **core-extensions/angular** → Angular integration layer (this package)
|
|
30
|
+
- **devtools** → debugging and inspection
|
|
31
|
+
- **engine** → orchestration, conductor, decision engine
|
|
32
|
+
- **shared** → contracts, types, utilities
|
|
33
|
+
|
|
34
|
+
---
|
|
35
|
+
|
|
36
|
+
## What This Package Does
|
|
37
|
+
|
|
38
|
+
This package bridges SDuX Vault with Angular by providing:
|
|
39
|
+
|
|
40
|
+
- Angular-friendly **state access**
|
|
41
|
+
- integration with **Angular signals**
|
|
42
|
+
- support for **dependency injection (DI)**
|
|
43
|
+
- reactive bindings for **state updates**
|
|
44
|
+
|
|
45
|
+
It allows SDuX state to behave like a **first-class Angular reactive source**.
|
|
46
|
+
|
|
47
|
+
---
|
|
48
|
+
|
|
49
|
+
## What This Package Provides
|
|
50
|
+
|
|
51
|
+
- **Angular bindings for FeatureCells**
|
|
52
|
+
- **Signal-based state access**
|
|
53
|
+
- **DI-compatible providers**
|
|
54
|
+
- **Reactive state consumption utilities**
|
|
55
|
+
- **Framework-native integration patterns**
|
|
56
|
+
|
|
57
|
+
---
|
|
58
|
+
|
|
59
|
+
## Key Concept: Angular Integration
|
|
60
|
+
|
|
61
|
+
This package adapts SDuX to Angular’s model:
|
|
62
|
+
|
|
63
|
+
```plaintext
|
|
64
|
+
SDuX state → Angular signal → component/template
|
|
65
|
+
```
|
|
66
|
+
|
|
67
|
+
This enables:
|
|
68
|
+
|
|
69
|
+
- automatic UI updates
|
|
70
|
+
- reactive rendering
|
|
71
|
+
- clean separation of state and view
|
|
72
|
+
|
|
73
|
+
---
|
|
74
|
+
|
|
75
|
+
## Signals Integration
|
|
76
|
+
|
|
77
|
+
State is exposed as Angular signals:
|
|
78
|
+
|
|
79
|
+
- always up-to-date
|
|
80
|
+
- reactive by default
|
|
81
|
+
- safe to consume in templates
|
|
82
|
+
|
|
83
|
+
```ts
|
|
84
|
+
const state = myFeatureCell.state();
|
|
85
|
+
```
|
|
86
|
+
|
|
87
|
+
Signals ensure:
|
|
88
|
+
|
|
89
|
+
- no manual subscriptions
|
|
90
|
+
- no memory leaks
|
|
91
|
+
- consistent reactivity
|
|
92
|
+
|
|
93
|
+
---
|
|
94
|
+
|
|
95
|
+
## Dependency Injection (DI)
|
|
96
|
+
|
|
97
|
+
FeatureCells and related utilities can be registered and consumed via Angular DI:
|
|
98
|
+
|
|
99
|
+
- injectable services
|
|
100
|
+
- scoped providers
|
|
101
|
+
- application-level configuration
|
|
102
|
+
|
|
103
|
+
This allows SDuX to integrate naturally with Angular architecture.
|
|
104
|
+
|
|
105
|
+
---
|
|
106
|
+
|
|
107
|
+
## Execution Model
|
|
108
|
+
|
|
109
|
+
```plaintext
|
|
110
|
+
SDuX pipeline (core + engine)
|
|
111
|
+
↓
|
|
112
|
+
Angular extension layer
|
|
113
|
+
↓
|
|
114
|
+
Angular signals / DI
|
|
115
|
+
↓
|
|
116
|
+
components & templates
|
|
117
|
+
```
|
|
118
|
+
|
|
119
|
+
This package does **not**:
|
|
120
|
+
|
|
121
|
+
- execute pipelines (core responsibility)
|
|
122
|
+
- make decisions (engine/controllers responsibility)
|
|
123
|
+
|
|
124
|
+
It only **adapts runtime state to Angular**.
|
|
125
|
+
|
|
126
|
+
---
|
|
127
|
+
|
|
128
|
+
## When to Use This Package
|
|
129
|
+
|
|
130
|
+
Use this package when:
|
|
131
|
+
|
|
132
|
+
- building Angular applications with SDuX
|
|
133
|
+
- you want signal-based state access
|
|
134
|
+
- you need DI-friendly integration
|
|
135
|
+
- you want reactive UI updates without manual subscriptions
|
|
136
|
+
|
|
137
|
+
---
|
|
138
|
+
|
|
139
|
+
## Installation
|
|
140
|
+
|
|
141
|
+
```bash
|
|
142
|
+
npm install @sdux-vault/core-extensions/angular
|
|
143
|
+
```
|
|
144
|
+
|
|
145
|
+
---
|
|
146
|
+
|
|
147
|
+
## Development
|
|
148
|
+
|
|
149
|
+
### Build
|
|
150
|
+
|
|
151
|
+
```bash
|
|
152
|
+
npm run build:core-extensions-angular
|
|
153
|
+
```
|
|
154
|
+
|
|
155
|
+
Output:
|
|
156
|
+
|
|
157
|
+
```plaintext
|
|
158
|
+
dist/core-extensions/angular
|
|
159
|
+
```
|
|
160
|
+
|
|
161
|
+
---
|
|
162
|
+
|
|
163
|
+
### Test
|
|
164
|
+
|
|
165
|
+
```bash
|
|
166
|
+
npm run test:core-extensions-angular
|
|
167
|
+
```
|
|
168
|
+
|
|
169
|
+
---
|
|
170
|
+
|
|
171
|
+
### Verify
|
|
172
|
+
|
|
173
|
+
```bash
|
|
174
|
+
npm run verify
|
|
175
|
+
```
|
|
176
|
+
|
|
177
|
+
Includes:
|
|
178
|
+
|
|
179
|
+
- linting
|
|
180
|
+
- formatting
|
|
181
|
+
- type checking
|
|
182
|
+
- tests
|
|
183
|
+
|
|
184
|
+
---
|
|
185
|
+
|
|
186
|
+
## Publishing
|
|
187
|
+
|
|
188
|
+
See [RELEASE.md](./RELEASE.md) for publishing instructions.
|
|
189
|
+
|
|
190
|
+
---
|
|
191
|
+
|
|
192
|
+
## Ecosystem
|
|
193
|
+
|
|
194
|
+
- `@sdux-vault/addons` — runtime policies and controllers ([README](../addons/README.md))
|
|
195
|
+
- `@sdux-vault/core` — behavior runtime and pipeline execution ([README](../core/README.md))
|
|
196
|
+
- `@sdux-vault/devtools` — observability and debugging layer for runtime inspection ([README](../devtools/tooling/README.md))
|
|
197
|
+
- `@sdux-vault/engine` — orchestration, conductor, decision engine
|
|
198
|
+
- `@sdux-vault/shared` — contracts, types, utilities ([README](../shared/README.md))
|
|
199
|
+
|
|
200
|
+
---
|
|
201
|
+
|
|
202
|
+
## License
|
|
203
|
+
|
|
204
|
+
For full licensing details:
|
|
205
|
+
https://www.sdux-vault.com/docs/welcome/license#license-texts
|
|
206
|
+
|
|
207
|
+
MIT © SDuX Vault
|
|
@@ -0,0 +1,359 @@
|
|
|
1
|
+
import { InjectionToken, inject, signal, computed, DestroyRef, provideAppInitializer } from '@angular/core';
|
|
2
|
+
import { DevMode, registerVersion } from '@sdux-vault/shared';
|
|
3
|
+
import { FeatureCell as FeatureCell$1 } from '@sdux-vault/core';
|
|
4
|
+
import { Subscription } from 'rxjs';
|
|
5
|
+
import { VaultCore, resetVaultForTests } from '@sdux-vault/engine';
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* Metadata keys used internally by SDuX to annotate FeatureCell classes.
|
|
9
|
+
*
|
|
10
|
+
* These string constants are attached directly to the provider class
|
|
11
|
+
* (via the `@FeatureCell()` decorator) and are later consumed by
|
|
12
|
+
* the Vault orchestrator when resolving cell identity and state type.
|
|
13
|
+
*
|
|
14
|
+
* @constant FEATURE_CELL_KEY
|
|
15
|
+
* Stores the unique identifier for a FeatureCell.
|
|
16
|
+
* This value is required and is used during vault registration,
|
|
17
|
+
* state lookup, debugging, and pipeline analytics.
|
|
18
|
+
*
|
|
19
|
+
* @constant FEATURE_CELL_STATE
|
|
20
|
+
* Stores a *type anchor* for the FeatureCell’s state (TState).
|
|
21
|
+
* This field contains no runtime value — instead, it allows SDuX
|
|
22
|
+
* to extract strong generic types from the decorated class, enabling:
|
|
23
|
+
* • typed vault injection (`injectVault<T>()`)
|
|
24
|
+
* • typed reducers, filters, and merge behaviors
|
|
25
|
+
* • fully inferred state signatures across the pipeline
|
|
26
|
+
*
|
|
27
|
+
* These metadata keys must remain stable and unique, as they serve
|
|
28
|
+
* as the primary lookup mechanism for FeatureCell configuration.
|
|
29
|
+
*/
|
|
30
|
+
const VAULT_METADATA_KEYS = {
|
|
31
|
+
/** Unique FeatureCell identifier assigned by the @FeatureCell decorator. */
|
|
32
|
+
FEATURE_CELL_KEY: 'vault:feature-cell-key',
|
|
33
|
+
/**
|
|
34
|
+
* Type anchor used to infer a FeatureCell’s state type (TState).
|
|
35
|
+
* This exists for TypeScript inference only and has no runtime value.
|
|
36
|
+
*/
|
|
37
|
+
FEATURE_CELL_STATE: 'vault:feature-cell-state'
|
|
38
|
+
};
|
|
39
|
+
|
|
40
|
+
/**
|
|
41
|
+
* Decorator factory that marks a class as a FeatureCell with an associated state type.
|
|
42
|
+
*
|
|
43
|
+
* This function produces a class decorator that attaches identifying metadata
|
|
44
|
+
* used to associate a FeatureCell instance with a unique key and a compile-time
|
|
45
|
+
* state type anchor.
|
|
46
|
+
*
|
|
47
|
+
* @param key - Unique identifier assigned to the FeatureCell.
|
|
48
|
+
*/
|
|
49
|
+
function FeatureCell(key) {
|
|
50
|
+
/**
|
|
51
|
+
* Applies FeatureCell metadata to the decorated class.
|
|
52
|
+
*
|
|
53
|
+
* This decorator assigns a stable FeatureCell key and a state type anchor
|
|
54
|
+
* used for compile-time inference without introducing runtime behavior.
|
|
55
|
+
*
|
|
56
|
+
* @param target - The class constructor being decorated.
|
|
57
|
+
*/
|
|
58
|
+
// eslint-disable-next-line
|
|
59
|
+
return function (target) {
|
|
60
|
+
/**
|
|
61
|
+
* Attaches the unique FeatureCell identifier to the target class.
|
|
62
|
+
*/
|
|
63
|
+
// eslint-disable-next-line
|
|
64
|
+
target[VAULT_METADATA_KEYS.FEATURE_CELL_KEY] = key;
|
|
65
|
+
/**
|
|
66
|
+
* Attaches a state type anchor to the target class.
|
|
67
|
+
*/
|
|
68
|
+
// eslint-disable-next-line
|
|
69
|
+
target[VAULT_METADATA_KEYS.FEATURE_CELL_STATE] = null;
|
|
70
|
+
};
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
// angular/feature-cell-di-tokens.ts
|
|
74
|
+
/**
|
|
75
|
+
* Internal registry mapping FeatureCell keys to Angular injection tokens.
|
|
76
|
+
*
|
|
77
|
+
* This map ensures a one-to-one association between a FeatureCell key and its
|
|
78
|
+
* corresponding InjectionToken instance.
|
|
79
|
+
*/
|
|
80
|
+
// eslint-disable-next-line
|
|
81
|
+
const featureCellTokens = new Map();
|
|
82
|
+
/**
|
|
83
|
+
* Tracks whether a FeatureCell token has already been requested for injection.
|
|
84
|
+
*
|
|
85
|
+
* This is used to enforce single-injection constraints in non-development modes.
|
|
86
|
+
*/
|
|
87
|
+
const featureCellTokenRequested = new Map();
|
|
88
|
+
/**
|
|
89
|
+
* Creates or retrieves an Angular InjectionToken for a FeatureCell.
|
|
90
|
+
*
|
|
91
|
+
* This function enforces uniqueness rules for FeatureCell keys and controls
|
|
92
|
+
* whether a token is being created or retrieved based on the `isCreate` flag.
|
|
93
|
+
*
|
|
94
|
+
* @param key - The unique FeatureCell key.
|
|
95
|
+
* @param isCreate - Whether the token is being created or retrieved.
|
|
96
|
+
* @returns The Angular InjectionToken associated with the FeatureCell.
|
|
97
|
+
*/
|
|
98
|
+
function internalAngularFeatureCellToken(key, isCreate) {
|
|
99
|
+
let token = featureCellTokens.get(key);
|
|
100
|
+
if (isCreate) {
|
|
101
|
+
if (featureCellTokens.has(key)) {
|
|
102
|
+
if (!DevMode.active) {
|
|
103
|
+
throw new Error(`[vault] Duplicate FeatureCell key detected: "${key}". ` +
|
|
104
|
+
`Each FeatureCell must have a unique key. Existing token: "${key}"`);
|
|
105
|
+
}
|
|
106
|
+
return featureCellTokens.get(key);
|
|
107
|
+
}
|
|
108
|
+
token = new InjectionToken(`FEATURE_CELL:${key}`);
|
|
109
|
+
featureCellTokens.set(key, token);
|
|
110
|
+
return token;
|
|
111
|
+
}
|
|
112
|
+
else {
|
|
113
|
+
if (!featureCellTokens.has(key)) {
|
|
114
|
+
throw new Error(`[vault] FeatureCell token not found for key "${key}". You must call provideFeatureCell() before retrieving this FeatureCell.`);
|
|
115
|
+
}
|
|
116
|
+
if (featureCellTokenRequested.has(key)) {
|
|
117
|
+
if (!DevMode.active) {
|
|
118
|
+
throw new Error(`[vault] FeatureCell "${key}" can only be injected into a single decorated @FeatureCell service.`);
|
|
119
|
+
}
|
|
120
|
+
return featureCellTokens.get(key);
|
|
121
|
+
}
|
|
122
|
+
featureCellTokenRequested.set(key, true);
|
|
123
|
+
return featureCellTokens.get(key);
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
/**
|
|
127
|
+
* Creates and registers an Angular InjectionToken for a FeatureCell key.
|
|
128
|
+
*
|
|
129
|
+
* @param key - The unique FeatureCell key.
|
|
130
|
+
* @returns The created InjectionToken.
|
|
131
|
+
*/
|
|
132
|
+
function createAngularFeatureCellToken(key) {
|
|
133
|
+
return internalAngularFeatureCellToken(key, true);
|
|
134
|
+
}
|
|
135
|
+
/**
|
|
136
|
+
* Retrieves an existing Angular InjectionToken for a FeatureCell key.
|
|
137
|
+
*
|
|
138
|
+
* @param key - The unique FeatureCell key.
|
|
139
|
+
* @returns The existing InjectionToken.
|
|
140
|
+
*/
|
|
141
|
+
function getAngularFeatureCellToken(key) {
|
|
142
|
+
return internalAngularFeatureCellToken(key, false);
|
|
143
|
+
}
|
|
144
|
+
/**
|
|
145
|
+
* Resets all FeatureCell token state for development or test isolation.
|
|
146
|
+
*
|
|
147
|
+
* This function clears internal token registries and is only active when
|
|
148
|
+
* development mode is enabled.
|
|
149
|
+
*/
|
|
150
|
+
function resetAngularFeatureCellTokenDevMode() {
|
|
151
|
+
if (!DevMode.active)
|
|
152
|
+
return;
|
|
153
|
+
featureCellTokens.clear();
|
|
154
|
+
featureCellTokenRequested.clear();
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
/**
|
|
158
|
+
* injectVault
|
|
159
|
+
* @function injectVault
|
|
160
|
+
* @description
|
|
161
|
+
* Retrieves the strongly-typed vault instance associated with a
|
|
162
|
+
* `@FeatureCell()`-decorated class. This function must be called **inside**
|
|
163
|
+
* the constructor (or instance initializer) of a FeatureCell service.
|
|
164
|
+
*
|
|
165
|
+
* This version uses static metadata written by the FeatureCell decorator:
|
|
166
|
+
*
|
|
167
|
+
* target[FEATURE_CELL_KEY] = "myCell"
|
|
168
|
+
* target[FEATURE_CELL_STATE] = null as TState
|
|
169
|
+
*
|
|
170
|
+
* No Reflect metadata is required.
|
|
171
|
+
*
|
|
172
|
+
* @typeParam T - The typed state stored in this FeatureCell.
|
|
173
|
+
*
|
|
174
|
+
* @param featureCellClass - The decorated class whose vault should be injected.
|
|
175
|
+
*/
|
|
176
|
+
function injectVault(
|
|
177
|
+
// eslint-disable-next-line
|
|
178
|
+
featureCellClass) {
|
|
179
|
+
/**
|
|
180
|
+
* The target
|
|
181
|
+
*/
|
|
182
|
+
const target = featureCellClass;
|
|
183
|
+
if (!target) {
|
|
184
|
+
throw new Error(`injectVault() must be called inside a @FeatureCell()-decorated service and must be given the class reference.`);
|
|
185
|
+
}
|
|
186
|
+
/**
|
|
187
|
+
* Read static metadata created by the FeatureCell decorator
|
|
188
|
+
*/
|
|
189
|
+
// eslint-disable-next-line
|
|
190
|
+
const key = target[VAULT_METADATA_KEYS.FEATURE_CELL_KEY];
|
|
191
|
+
if (!key) {
|
|
192
|
+
throw new Error(`injectVault() must be called inside a @FeatureCell()-decorated service.`);
|
|
193
|
+
}
|
|
194
|
+
/**
|
|
195
|
+
* Resolve DI token for this FeatureCell
|
|
196
|
+
*/
|
|
197
|
+
const token = getAngularFeatureCellToken(key);
|
|
198
|
+
/**
|
|
199
|
+
* Inject the vault instance
|
|
200
|
+
*/
|
|
201
|
+
return inject(token);
|
|
202
|
+
}
|
|
203
|
+
|
|
204
|
+
/**
|
|
205
|
+
* Angular adapter that augments a core FeatureCell with Angular Signal-based state access.
|
|
206
|
+
*
|
|
207
|
+
* This class bridges a framework-agnostic FeatureCellBaseShape into an Angular-friendly
|
|
208
|
+
* representation by subscribing to state emissions and exposing derived, read-only
|
|
209
|
+
* Angular Signals for value, loading state, error state, and value presence.
|
|
210
|
+
*/
|
|
211
|
+
class AngularFeatureCellAdapter {
|
|
212
|
+
core;
|
|
213
|
+
/**
|
|
214
|
+
* Manages internal subscriptions to the core FeatureCell state stream.
|
|
215
|
+
*/
|
|
216
|
+
#subscriptions = new Subscription();
|
|
217
|
+
/**
|
|
218
|
+
* Signal representing the current pipeline value.
|
|
219
|
+
*/
|
|
220
|
+
#value = signal(undefined, ...(ngDevMode ? [{ debugName: "#value" }] : /* istanbul ignore next */ []));
|
|
221
|
+
/**
|
|
222
|
+
* Signal representing the current error state.
|
|
223
|
+
*/
|
|
224
|
+
#error = signal(null, ...(ngDevMode ? [{ debugName: "#error" }] : /* istanbul ignore next */ []));
|
|
225
|
+
/**
|
|
226
|
+
* Signal representing whether the FeatureCell is currently loading.
|
|
227
|
+
*/
|
|
228
|
+
#isLoading = signal(false, ...(ngDevMode ? [{ debugName: "#isLoading" }] : /* istanbul ignore next */ []));
|
|
229
|
+
/**
|
|
230
|
+
* Computed signal indicating whether a non-null, non-undefined value is present.
|
|
231
|
+
*/
|
|
232
|
+
#hasValue = computed(() => {
|
|
233
|
+
const value = this.#value();
|
|
234
|
+
return value !== null && value !== undefined;
|
|
235
|
+
}, ...(ngDevMode ? [{ debugName: "#hasValue" }] : /* istanbul ignore next */ []));
|
|
236
|
+
/**
|
|
237
|
+
* Angular destroy reference used to coordinate lifecycle teardown.
|
|
238
|
+
*/
|
|
239
|
+
#destroyRef = inject(DestroyRef);
|
|
240
|
+
/**
|
|
241
|
+
* Creates a new AngularFeatureCellAdapter for the provided core FeatureCell.
|
|
242
|
+
*
|
|
243
|
+
* @param core - The framework-agnostic FeatureCell instance to adapt.
|
|
244
|
+
*/
|
|
245
|
+
constructor(core) {
|
|
246
|
+
this.core = core;
|
|
247
|
+
this.#subscriptions.add(this.core.state$.subscribe((stateEmitSnapshot) => {
|
|
248
|
+
this.#isLoading.set(stateEmitSnapshot?.snapshot?.isLoading ?? false);
|
|
249
|
+
this.#error.set(stateEmitSnapshot?.snapshot?.error ?? null);
|
|
250
|
+
this.#value.set(stateEmitSnapshot?.snapshot?.value ?? undefined);
|
|
251
|
+
}));
|
|
252
|
+
this.#destroyRef.onDestroy(() => this.destroy());
|
|
253
|
+
}
|
|
254
|
+
/**
|
|
255
|
+
* Builds and returns the Angular-augmented FeatureCell instance.
|
|
256
|
+
*
|
|
257
|
+
* @returns The FeatureCell with an attached Angular Signal-based state property.
|
|
258
|
+
*/
|
|
259
|
+
build() {
|
|
260
|
+
const cell = this.core;
|
|
261
|
+
Object.defineProperty(cell, 'state', {
|
|
262
|
+
configurable: true,
|
|
263
|
+
enumerable: true,
|
|
264
|
+
get: () => ({
|
|
265
|
+
isLoading: this.#isLoading.asReadonly(),
|
|
266
|
+
value: this.#value.asReadonly(),
|
|
267
|
+
error: this.#error.asReadonly(),
|
|
268
|
+
hasValue: this.#hasValue
|
|
269
|
+
})
|
|
270
|
+
});
|
|
271
|
+
return cell;
|
|
272
|
+
}
|
|
273
|
+
/**
|
|
274
|
+
* Destroys the adapter by tearing down subscriptions and delegating to the core FeatureCell.
|
|
275
|
+
*
|
|
276
|
+
* @returns void
|
|
277
|
+
*/
|
|
278
|
+
destroy() {
|
|
279
|
+
this.core.destroy();
|
|
280
|
+
this.#subscriptions.unsubscribe();
|
|
281
|
+
}
|
|
282
|
+
}
|
|
283
|
+
|
|
284
|
+
/**
|
|
285
|
+
* Angular provider factory that registers and exposes a FeatureCell instance.
|
|
286
|
+
*
|
|
287
|
+
* This function creates the dependency injection providers required to construct
|
|
288
|
+
* a FeatureCell, adapt it for Angular-specific consumption, and register it for
|
|
289
|
+
* global access using the provided configuration.
|
|
290
|
+
*
|
|
291
|
+
* @param service - Angular service type associated with the FeatureCell.
|
|
292
|
+
* @param descriptor - Configuration object defining the FeatureCell contract.
|
|
293
|
+
* @param behaviors - Optional list of behavior classes applied to the FeatureCell.
|
|
294
|
+
* @param controllers - Optional list of controller classes applied to the FeatureCell.
|
|
295
|
+
* @returns An array of Angular providers that supply the configured FeatureCell.
|
|
296
|
+
*/
|
|
297
|
+
function provideFeatureCell(service, descriptor, behaviors = [], controllers = []) {
|
|
298
|
+
const angularToken = createAngularFeatureCellToken(descriptor.key);
|
|
299
|
+
return [
|
|
300
|
+
{
|
|
301
|
+
provide: angularToken,
|
|
302
|
+
useFactory: () => {
|
|
303
|
+
const coreCell = FeatureCell$1(descriptor, behaviors, controllers);
|
|
304
|
+
return new AngularFeatureCellAdapter(coreCell).build();
|
|
305
|
+
}
|
|
306
|
+
},
|
|
307
|
+
service
|
|
308
|
+
];
|
|
309
|
+
}
|
|
310
|
+
|
|
311
|
+
/**
|
|
312
|
+
* Registers and initializes the SDuX Vault core within an Angular application.
|
|
313
|
+
*
|
|
314
|
+
* This function sets up the global FeatureCell registry and returns Angular
|
|
315
|
+
* environment providers that ensure Vault core initialization occurs during
|
|
316
|
+
* application bootstrap using the supplied configuration.
|
|
317
|
+
*
|
|
318
|
+
* @param config - Optional Vault configuration used to initialize core services.
|
|
319
|
+
* @returns Angular environment providers that perform Vault initialization at app startup.
|
|
320
|
+
*/
|
|
321
|
+
function provideVault(config = {}) {
|
|
322
|
+
return provideAppInitializer(() => {
|
|
323
|
+
VaultCore(config);
|
|
324
|
+
});
|
|
325
|
+
}
|
|
326
|
+
|
|
327
|
+
function provideVaultTesting(config) {
|
|
328
|
+
const finalConfig = {
|
|
329
|
+
devMode: true,
|
|
330
|
+
logLevel: 'off',
|
|
331
|
+
...config // overrides defaults
|
|
332
|
+
};
|
|
333
|
+
if (finalConfig?.devMode) {
|
|
334
|
+
DevMode.setDevMode(true);
|
|
335
|
+
resetVaultForTests();
|
|
336
|
+
}
|
|
337
|
+
return provideVault(finalConfig);
|
|
338
|
+
}
|
|
339
|
+
|
|
340
|
+
// --- AI Model File Path (DO NOT DELETE) ---
|
|
341
|
+
// FilePath: libs > angular > src > lib > version > version.register.ts
|
|
342
|
+
// Updated: 2026-03-03 08:06
|
|
343
|
+
// Generated by pathcomment [tab] (see .vscode/typescript.code-snippets) or
|
|
344
|
+
// cmd+alt+j (see .vscode/keybindings.json)
|
|
345
|
+
// --- END AI MODEL FILE PATH ---
|
|
346
|
+
const SDUX_PACKAGE = '@sdux-vault/core-extensions-angular';
|
|
347
|
+
const SDUX_VERSION = '0.0.4';
|
|
348
|
+
registerVersion(SDUX_PACKAGE, SDUX_VERSION);
|
|
349
|
+
|
|
350
|
+
/*
|
|
351
|
+
* Public API Surface of angular
|
|
352
|
+
*/
|
|
353
|
+
|
|
354
|
+
/**
|
|
355
|
+
* Generated bundle index. Do not edit.
|
|
356
|
+
*/
|
|
357
|
+
|
|
358
|
+
export { FeatureCell, injectVault, provideFeatureCell, provideVault, provideVaultTesting, resetAngularFeatureCellTokenDevMode };
|
|
359
|
+
//# sourceMappingURL=sdux-vault-core-extensions-angular.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sdux-vault-core-extensions-angular.mjs","sources":["../../../../libs/core-extensions/angular/src/lib/constants/metadata-keys.constant.ts","../../../../libs/core-extensions/angular/src/lib/decorators/feature-cell.decorator.ts","../../../../libs/core-extensions/angular/src/lib/tokens/feature-cell-di.token.ts","../../../../libs/core-extensions/angular/src/lib/injectors/feature-vault.injector.ts","../../../../libs/core-extensions/angular/src/lib/providers/feature-cell/feature.cell.adapter.ts","../../../../libs/core-extensions/angular/src/lib/providers/feature-cell/provide-feature-cell.provider.ts","../../../../libs/core-extensions/angular/src/lib/providers/vault/provide-vault.provider.ts","../../../../libs/core-extensions/angular/src/testing/provide-vault-testing.ts","../../../../libs/core-extensions/angular/src/lib/version/version.register.ts","../../../../libs/core-extensions/angular/src/public-api.ts","../../../../libs/core-extensions/angular/src/sdux-vault-core-extensions-angular.ts"],"sourcesContent":["/**\n * Metadata keys used internally by SDuX to annotate FeatureCell classes.\n *\n * These string constants are attached directly to the provider class\n * (via the `@FeatureCell()` decorator) and are later consumed by\n * the Vault orchestrator when resolving cell identity and state type.\n *\n * @constant FEATURE_CELL_KEY\n * Stores the unique identifier for a FeatureCell.\n * This value is required and is used during vault registration,\n * state lookup, debugging, and pipeline analytics.\n *\n * @constant FEATURE_CELL_STATE\n * Stores a *type anchor* for the FeatureCell’s state (TState).\n * This field contains no runtime value — instead, it allows SDuX\n * to extract strong generic types from the decorated class, enabling:\n * • typed vault injection (`injectVault<T>()`)\n * • typed reducers, filters, and merge behaviors\n * • fully inferred state signatures across the pipeline\n *\n * These metadata keys must remain stable and unique, as they serve\n * as the primary lookup mechanism for FeatureCell configuration.\n */\nexport const VAULT_METADATA_KEYS = {\n /** Unique FeatureCell identifier assigned by the @FeatureCell decorator. */\n FEATURE_CELL_KEY: 'vault:feature-cell-key',\n\n /**\n * Type anchor used to infer a FeatureCell’s state type (TState).\n * This exists for TypeScript inference only and has no runtime value.\n */\n FEATURE_CELL_STATE: 'vault:feature-cell-state'\n} as const;\n","import { VAULT_METADATA_KEYS } from '../constants/metadata-keys.constant';\n\n/**\n * Decorator factory that marks a class as a FeatureCell with an associated state type.\n *\n * This function produces a class decorator that attaches identifying metadata\n * used to associate a FeatureCell instance with a unique key and a compile-time\n * state type anchor.\n *\n * @param key - Unique identifier assigned to the FeatureCell.\n */\nexport function FeatureCell<TState>(key: string) {\n /**\n * Applies FeatureCell metadata to the decorated class.\n *\n * This decorator assigns a stable FeatureCell key and a state type anchor\n * used for compile-time inference without introducing runtime behavior.\n *\n * @param target - The class constructor being decorated.\n */\n // eslint-disable-next-line\n return function <T extends new (...args: any[]) => {}>(target: T) {\n /**\n * Attaches the unique FeatureCell identifier to the target class.\n */\n // eslint-disable-next-line\n (target as any)[VAULT_METADATA_KEYS.FEATURE_CELL_KEY] = key;\n\n /**\n * Attaches a state type anchor to the target class.\n */\n // eslint-disable-next-line\n (target as any)[VAULT_METADATA_KEYS.FEATURE_CELL_STATE] = null as unknown as TState;\n };\n}\n","// angular/feature-cell-di-tokens.ts\nimport { InjectionToken } from '@angular/core';\nimport { DevMode } from '@sdux-vault/shared';\nimport { FeatureCellShape } from '../shapes/feature-cell.shape';\n\n/**\n * Internal registry mapping FeatureCell keys to Angular injection tokens.\n *\n * This map ensures a one-to-one association between a FeatureCell key and its\n * corresponding InjectionToken instance.\n */\n// eslint-disable-next-line\nconst featureCellTokens = new Map<string, InjectionToken<FeatureCellShape<any>>>();\n\n/**\n * Tracks whether a FeatureCell token has already been requested for injection.\n *\n * This is used to enforce single-injection constraints in non-development modes.\n */\nconst featureCellTokenRequested = new Map<string, boolean>();\n\n/**\n * Creates or retrieves an Angular InjectionToken for a FeatureCell.\n *\n * This function enforces uniqueness rules for FeatureCell keys and controls\n * whether a token is being created or retrieved based on the `isCreate` flag.\n *\n * @param key - The unique FeatureCell key.\n * @param isCreate - Whether the token is being created or retrieved.\n * @returns The Angular InjectionToken associated with the FeatureCell.\n */\nfunction internalAngularFeatureCellToken<T>(key: string, isCreate: boolean): InjectionToken<FeatureCellShape<T>> {\n let token = featureCellTokens.get(key);\n\n if (isCreate) {\n if (featureCellTokens.has(key)) {\n if (!DevMode.active) {\n throw new Error(\n `[vault] Duplicate FeatureCell key detected: \"${key}\". ` +\n `Each FeatureCell must have a unique key. Existing token: \"${key}\"`\n );\n }\n\n return featureCellTokens.get(key)!;\n }\n\n token = new InjectionToken<FeatureCellShape<T>>(`FEATURE_CELL:${key}`);\n featureCellTokens.set(key, token);\n return token as InjectionToken<FeatureCellShape<T>>;\n } else {\n if (!featureCellTokens.has(key)) {\n throw new Error(\n `[vault] FeatureCell token not found for key \"${key}\". You must call provideFeatureCell() before retrieving this FeatureCell.`\n );\n }\n\n if (featureCellTokenRequested.has(key)) {\n if (!DevMode.active) {\n throw new Error(\n `[vault] FeatureCell \"${key}\" can only be injected into a single decorated @FeatureCell service.`\n );\n }\n\n return featureCellTokens.get(key)! as InjectionToken<FeatureCellShape<T>>;\n }\n\n featureCellTokenRequested.set(key, true);\n return featureCellTokens.get(key)! as InjectionToken<FeatureCellShape<T>>;\n }\n}\n\n/**\n * Creates and registers an Angular InjectionToken for a FeatureCell key.\n *\n * @param key - The unique FeatureCell key.\n * @returns The created InjectionToken.\n */\nexport function createAngularFeatureCellToken<T>(key: string) {\n return internalAngularFeatureCellToken<T>(key, true);\n}\n\n/**\n * Retrieves an existing Angular InjectionToken for a FeatureCell key.\n *\n * @param key - The unique FeatureCell key.\n * @returns The existing InjectionToken.\n */\nexport function getAngularFeatureCellToken<T>(key: string) {\n return internalAngularFeatureCellToken<T>(key, false);\n}\n\n/**\n * Resets all FeatureCell token state for development or test isolation.\n *\n * This function clears internal token registries and is only active when\n * development mode is enabled.\n */\nexport function resetAngularFeatureCellTokenDevMode(): void {\n if (!DevMode.active) return;\n\n featureCellTokens.clear();\n featureCellTokenRequested.clear();\n}\n","import { inject } from '@angular/core';\nimport { VAULT_METADATA_KEYS } from '../constants/metadata-keys.constant';\nimport { FeatureCellShape } from '../shapes/feature-cell.shape';\nimport { getAngularFeatureCellToken } from '../tokens/feature-cell-di.token';\n\n/**\n * injectVault\n * @function injectVault\n * @description\n * Retrieves the strongly-typed vault instance associated with a\n * `@FeatureCell()`-decorated class. This function must be called **inside**\n * the constructor (or instance initializer) of a FeatureCell service.\n *\n * This version uses static metadata written by the FeatureCell decorator:\n *\n * target[FEATURE_CELL_KEY] = \"myCell\"\n * target[FEATURE_CELL_STATE] = null as TState\n *\n * No Reflect metadata is required.\n *\n * @typeParam T - The typed state stored in this FeatureCell.\n *\n * @param featureCellClass - The decorated class whose vault should be injected.\n */\nexport function injectVault<T>(\n // eslint-disable-next-line\n featureCellClass?: abstract new (...args: any[]) => object\n): FeatureCellShape<T> {\n /**\n * The target\n */\n const target = featureCellClass;\n\n if (!target) {\n throw new Error(\n `injectVault() must be called inside a @FeatureCell()-decorated service and must be given the class reference.`\n );\n }\n\n /**\n * Read static metadata created by the FeatureCell decorator\n */\n // eslint-disable-next-line\n const key = (target as any)[VAULT_METADATA_KEYS.FEATURE_CELL_KEY];\n\n if (!key) {\n throw new Error(`injectVault() must be called inside a @FeatureCell()-decorated service.`);\n }\n\n /**\n * Resolve DI token for this FeatureCell\n */\n const token = getAngularFeatureCellToken(key);\n\n /**\n * Inject the vault instance\n */\n return inject(token) as FeatureCellShape<T>;\n}\n","import { computed, DestroyRef, inject, signal } from '@angular/core';\nimport { FeatureCellBaseShape, PipelineValue, StateEmitSnapshotShape, VaultErrorShape } from '@sdux-vault/shared';\nimport { Subscription } from 'rxjs';\nimport { FeatureCellShape } from '../../shapes/feature-cell.shape';\n\n/**\n * Angular adapter that augments a core FeatureCell with Angular Signal-based state access.\n *\n * This class bridges a framework-agnostic FeatureCellBaseShape into an Angular-friendly\n * representation by subscribing to state emissions and exposing derived, read-only\n * Angular Signals for value, loading state, error state, and value presence.\n */\nexport class AngularFeatureCellAdapter<T> {\n /**\n * Manages internal subscriptions to the core FeatureCell state stream.\n */\n readonly #subscriptions = new Subscription();\n\n /**\n * Signal representing the current pipeline value.\n */\n readonly #value = signal<PipelineValue<T>>(undefined);\n\n /**\n * Signal representing the current error state.\n */\n readonly #error = signal<VaultErrorShape | null>(null);\n\n /**\n * Signal representing whether the FeatureCell is currently loading.\n */\n readonly #isLoading = signal(false);\n\n /**\n * Computed signal indicating whether a non-null, non-undefined value is present.\n */\n readonly #hasValue = computed(() => {\n const value = this.#value();\n return value !== null && value !== undefined;\n });\n\n /**\n * Angular destroy reference used to coordinate lifecycle teardown.\n */\n readonly #destroyRef = inject(DestroyRef);\n\n /**\n * Creates a new AngularFeatureCellAdapter for the provided core FeatureCell.\n *\n * @param core - The framework-agnostic FeatureCell instance to adapt.\n */\n constructor(private readonly core: FeatureCellBaseShape<T>) {\n this.#subscriptions.add(\n this.core.state$.subscribe((stateEmitSnapshot: StateEmitSnapshotShape<T>) => {\n this.#isLoading.set(stateEmitSnapshot?.snapshot?.isLoading ?? false);\n this.#error.set(stateEmitSnapshot?.snapshot?.error ?? null);\n this.#value.set(stateEmitSnapshot?.snapshot?.value ?? undefined);\n })\n );\n\n this.#destroyRef.onDestroy(() => this.destroy());\n }\n\n /**\n * Builds and returns the Angular-augmented FeatureCell instance.\n *\n * @returns The FeatureCell with an attached Angular Signal-based state property.\n */\n build(): FeatureCellShape<T> {\n const cell = this.core as FeatureCellShape<T>;\n\n Object.defineProperty(cell, 'state', {\n configurable: true,\n enumerable: true,\n get: () => ({\n isLoading: this.#isLoading.asReadonly(),\n value: this.#value.asReadonly(),\n error: this.#error.asReadonly(),\n hasValue: this.#hasValue\n })\n });\n\n return cell;\n }\n\n /**\n * Destroys the adapter by tearing down subscriptions and delegating to the core FeatureCell.\n *\n * @returns void\n */\n destroy(): void {\n this.core.destroy();\n this.#subscriptions.unsubscribe();\n }\n}\n","import { Provider, Type } from '@angular/core';\nimport { FeatureCell } from '@sdux-vault/core';\nimport { FeatureCellConfig } from '@sdux-vault/engine';\nimport { BehaviorClassContract, ControllerClassContract } from '@sdux-vault/shared';\nimport { createAngularFeatureCellToken } from '../../tokens/feature-cell-di.token';\nimport { AngularFeatureCellAdapter } from './feature.cell.adapter';\n\n/**\n * Angular provider factory that registers and exposes a FeatureCell instance.\n *\n * This function creates the dependency injection providers required to construct\n * a FeatureCell, adapt it for Angular-specific consumption, and register it for\n * global access using the provided configuration.\n *\n * @param service - Angular service type associated with the FeatureCell.\n * @param descriptor - Configuration object defining the FeatureCell contract.\n * @param behaviors - Optional list of behavior classes applied to the FeatureCell.\n * @param controllers - Optional list of controller classes applied to the FeatureCell.\n * @returns An array of Angular providers that supply the configured FeatureCell.\n */\nexport function provideFeatureCell<Service, T>(\n service: Type<Service>,\n descriptor: FeatureCellConfig<T>,\n behaviors: BehaviorClassContract<T>[] = [],\n controllers: ControllerClassContract<T>[] = []\n): Provider[] {\n const angularToken = createAngularFeatureCellToken(descriptor.key);\n\n return [\n {\n provide: angularToken,\n useFactory: () => {\n const coreCell = FeatureCell(descriptor, behaviors, controllers);\n\n return new AngularFeatureCellAdapter(coreCell).build();\n }\n },\n\n service\n ];\n}\n","import { EnvironmentProviders, provideAppInitializer } from '@angular/core';\nimport { VaultCore } from '@sdux-vault/engine';\nimport { VaultConfig } from '@sdux-vault/shared';\n\n/**\n * Registers and initializes the SDuX Vault core within an Angular application.\n *\n * This function sets up the global FeatureCell registry and returns Angular\n * environment providers that ensure Vault core initialization occurs during\n * application bootstrap using the supplied configuration.\n *\n * @param config - Optional Vault configuration used to initialize core services.\n * @returns Angular environment providers that perform Vault initialization at app startup.\n */\nexport function provideVault(config: VaultConfig = {}): EnvironmentProviders {\n return provideAppInitializer(() => {\n VaultCore(config);\n });\n}\n","import { EnvironmentProviders } from '@angular/core';\nimport { resetVaultForTests } from '@sdux-vault/engine';\nimport { DevMode, VaultConfig } from '@sdux-vault/shared';\nimport { provideVault } from '../lib/providers/vault/provide-vault.provider';\n\nexport function provideVaultTesting(config?: VaultConfig): EnvironmentProviders {\n const finalConfig: VaultConfig = {\n devMode: true,\n logLevel: 'off',\n ...config // overrides defaults\n };\n\n if (finalConfig?.devMode) {\n DevMode.setDevMode(true);\n\n resetVaultForTests();\n }\n\n return provideVault(finalConfig);\n}\n","// --- AI Model File Path (DO NOT DELETE) ---\n// FilePath: libs > angular > src > lib > version > version.register.ts\n// Updated: 2026-03-03 08:06\n//\t Generated by pathcomment [tab] (see .vscode/typescript.code-snippets) or\n//\t cmd+alt+j (see .vscode/keybindings.json)\n// --- END AI MODEL FILE PATH ---\n\nimport { registerVersion } from '@sdux-vault/shared';\n\nconst SDUX_PACKAGE = '@sdux-vault/core-extensions-angular';\nconst SDUX_VERSION = '0.0.4';\n\nregisterVersion(SDUX_PACKAGE, SDUX_VERSION);\n","/*\n * Public API Surface of angular\n */\n\nexport { FeatureCell } from './lib/decorators/feature-cell.decorator';\nexport { injectVault } from './lib/injectors/feature-vault.injector';\nexport { provideFeatureCell } from './lib/providers/feature-cell/provide-feature-cell.provider';\nexport { provideVault } from './lib/providers/vault/provide-vault.provider';\nexport type { VaultSignalStateRef } from './lib/references/vault-signal.reference';\nexport type { FeatureCellShape } from './lib/shapes/feature-cell.shape';\nexport { resetAngularFeatureCellTokenDevMode } from './lib/tokens/feature-cell-di.token';\nexport { provideVaultTesting } from './testing/provide-vault-testing';\nimport './lib/version/version.register';\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './public-api';\n"],"names":["FeatureCell"],"mappings":"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"}
|
package/package.json
ADDED
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@sdux-vault/core-extensions-angular",
|
|
3
|
+
"version": "0.0.4",
|
|
4
|
+
"license": "MIT",
|
|
5
|
+
"repository": {
|
|
6
|
+
"type": "git",
|
|
7
|
+
"url": "git+https://github.com/sdux-vault/core.git"
|
|
8
|
+
},
|
|
9
|
+
"publishConfig": {
|
|
10
|
+
"access": "public"
|
|
11
|
+
},
|
|
12
|
+
"homepage": "https://www.sdux-vault.com",
|
|
13
|
+
"dependencies": {
|
|
14
|
+
"tslib": "^2.3.0"
|
|
15
|
+
},
|
|
16
|
+
"peerDependencies": {
|
|
17
|
+
"@angular/core": "^21.0.0",
|
|
18
|
+
"@sdux-vault/core": "^0.0.9",
|
|
19
|
+
"@sdux-vault/engine": "^0.0.9",
|
|
20
|
+
"@sdux-vault/shared": ">=0.0.6 <0.1.0",
|
|
21
|
+
"rxjs": "^7.0.0"
|
|
22
|
+
},
|
|
23
|
+
"files": [
|
|
24
|
+
"fesm2022/",
|
|
25
|
+
"types/",
|
|
26
|
+
"README.md",
|
|
27
|
+
"LICENSE",
|
|
28
|
+
"package.json"
|
|
29
|
+
],
|
|
30
|
+
"engines": {
|
|
31
|
+
"node": ">=18"
|
|
32
|
+
},
|
|
33
|
+
"types": "./types/sdux-vault-core-extensions-angular.d.ts",
|
|
34
|
+
"main": "./fesm2022/sdux-vault-core-extensions-angular.mjs",
|
|
35
|
+
"sideEffects": [
|
|
36
|
+
"./fesm2022/*.mjs",
|
|
37
|
+
"src/lib/version/version.register.ts"
|
|
38
|
+
],
|
|
39
|
+
"module": "fesm2022/sdux-vault-core-extensions-angular.mjs",
|
|
40
|
+
"typings": "types/sdux-vault-core-extensions-angular.d.ts",
|
|
41
|
+
"exports": {
|
|
42
|
+
"./package.json": {
|
|
43
|
+
"default": "./package.json"
|
|
44
|
+
},
|
|
45
|
+
".": {
|
|
46
|
+
"types": "./types/sdux-vault-core-extensions-angular.d.ts",
|
|
47
|
+
"default": "./fesm2022/sdux-vault-core-extensions-angular.mjs"
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
}
|
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
import { PipelineValue, VaultErrorShape, FeatureCellBaseShape, BehaviorClassContract, ControllerClassContract, VaultConfig } from '@sdux-vault/shared';
|
|
2
|
+
import { Signal, Type, Provider, EnvironmentProviders } from '@angular/core';
|
|
3
|
+
import { FeatureCellConfig } from '@sdux-vault/engine';
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Decorator factory that marks a class as a FeatureCell with an associated state type.
|
|
7
|
+
*
|
|
8
|
+
* This function produces a class decorator that attaches identifying metadata
|
|
9
|
+
* used to associate a FeatureCell instance with a unique key and a compile-time
|
|
10
|
+
* state type anchor.
|
|
11
|
+
*
|
|
12
|
+
* @param key - Unique identifier assigned to the FeatureCell.
|
|
13
|
+
*/
|
|
14
|
+
declare function FeatureCell<TState>(key: string): <T extends new (...args: any[]) => {}>(target: T) => void;
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* Reactive signal-based view of a FeatureCell’s current state.
|
|
18
|
+
*
|
|
19
|
+
* This interface defines the set of Angular signals exposed for observing
|
|
20
|
+
* loading status, resolved value, error state, and value presence for a
|
|
21
|
+
* FeatureCell.
|
|
22
|
+
*/
|
|
23
|
+
interface VaultSignalStateRef<T> {
|
|
24
|
+
/**
|
|
25
|
+
* Indicates whether the FeatureCell is currently processing a pipeline operation.
|
|
26
|
+
*/
|
|
27
|
+
isLoading: Signal<boolean>;
|
|
28
|
+
/**
|
|
29
|
+
* Holds the resolved pipeline value or undefined when no value is present.
|
|
30
|
+
*/
|
|
31
|
+
value: Signal<PipelineValue<T>>;
|
|
32
|
+
/**
|
|
33
|
+
* Holds the most recent error emitted by the pipeline or null when no error exists.
|
|
34
|
+
*/
|
|
35
|
+
error: Signal<VaultErrorShape | null>;
|
|
36
|
+
/**
|
|
37
|
+
* Indicates whether the FeatureCell currently holds a non-null resolved value.
|
|
38
|
+
*/
|
|
39
|
+
hasValue: Signal<boolean>;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
/**
|
|
43
|
+
* Angular-augmented FeatureCell shape that exposes reactive signal-based state.
|
|
44
|
+
*
|
|
45
|
+
* This interface extends the core FeatureCellBaseShape by adding a `state`
|
|
46
|
+
* property that provides signal references for loading, value, error, and
|
|
47
|
+
* derived state visibility.
|
|
48
|
+
*/
|
|
49
|
+
interface FeatureCellShape<T> extends FeatureCellBaseShape<T> {
|
|
50
|
+
/**
|
|
51
|
+
* Reactive signal-based reference to the FeatureCell's resolved state.
|
|
52
|
+
*/
|
|
53
|
+
state: VaultSignalStateRef<T>;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
/**
|
|
57
|
+
* injectVault
|
|
58
|
+
* @function injectVault
|
|
59
|
+
* @description
|
|
60
|
+
* Retrieves the strongly-typed vault instance associated with a
|
|
61
|
+
* `@FeatureCell()`-decorated class. This function must be called **inside**
|
|
62
|
+
* the constructor (or instance initializer) of a FeatureCell service.
|
|
63
|
+
*
|
|
64
|
+
* This version uses static metadata written by the FeatureCell decorator:
|
|
65
|
+
*
|
|
66
|
+
* target[FEATURE_CELL_KEY] = "myCell"
|
|
67
|
+
* target[FEATURE_CELL_STATE] = null as TState
|
|
68
|
+
*
|
|
69
|
+
* No Reflect metadata is required.
|
|
70
|
+
*
|
|
71
|
+
* @typeParam T - The typed state stored in this FeatureCell.
|
|
72
|
+
*
|
|
73
|
+
* @param featureCellClass - The decorated class whose vault should be injected.
|
|
74
|
+
*/
|
|
75
|
+
declare function injectVault<T>(featureCellClass?: abstract new (...args: any[]) => object): FeatureCellShape<T>;
|
|
76
|
+
|
|
77
|
+
/**
|
|
78
|
+
* Angular provider factory that registers and exposes a FeatureCell instance.
|
|
79
|
+
*
|
|
80
|
+
* This function creates the dependency injection providers required to construct
|
|
81
|
+
* a FeatureCell, adapt it for Angular-specific consumption, and register it for
|
|
82
|
+
* global access using the provided configuration.
|
|
83
|
+
*
|
|
84
|
+
* @param service - Angular service type associated with the FeatureCell.
|
|
85
|
+
* @param descriptor - Configuration object defining the FeatureCell contract.
|
|
86
|
+
* @param behaviors - Optional list of behavior classes applied to the FeatureCell.
|
|
87
|
+
* @param controllers - Optional list of controller classes applied to the FeatureCell.
|
|
88
|
+
* @returns An array of Angular providers that supply the configured FeatureCell.
|
|
89
|
+
*/
|
|
90
|
+
declare function provideFeatureCell<Service, T>(service: Type<Service>, descriptor: FeatureCellConfig<T>, behaviors?: BehaviorClassContract<T>[], controllers?: ControllerClassContract<T>[]): Provider[];
|
|
91
|
+
|
|
92
|
+
/**
|
|
93
|
+
* Registers and initializes the SDuX Vault core within an Angular application.
|
|
94
|
+
*
|
|
95
|
+
* This function sets up the global FeatureCell registry and returns Angular
|
|
96
|
+
* environment providers that ensure Vault core initialization occurs during
|
|
97
|
+
* application bootstrap using the supplied configuration.
|
|
98
|
+
*
|
|
99
|
+
* @param config - Optional Vault configuration used to initialize core services.
|
|
100
|
+
* @returns Angular environment providers that perform Vault initialization at app startup.
|
|
101
|
+
*/
|
|
102
|
+
declare function provideVault(config?: VaultConfig): EnvironmentProviders;
|
|
103
|
+
|
|
104
|
+
/**
|
|
105
|
+
* Resets all FeatureCell token state for development or test isolation.
|
|
106
|
+
*
|
|
107
|
+
* This function clears internal token registries and is only active when
|
|
108
|
+
* development mode is enabled.
|
|
109
|
+
*/
|
|
110
|
+
declare function resetAngularFeatureCellTokenDevMode(): void;
|
|
111
|
+
|
|
112
|
+
declare function provideVaultTesting(config?: VaultConfig): EnvironmentProviders;
|
|
113
|
+
|
|
114
|
+
export { FeatureCell, injectVault, provideFeatureCell, provideVault, provideVaultTesting, resetAngularFeatureCellTokenDevMode };
|
|
115
|
+
export type { FeatureCellShape, VaultSignalStateRef };
|