@creact-labs/creact 0.1.7 → 0.2.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/README.md +72 -21
- package/dist/cli.d.ts +11 -0
- package/dist/cli.js +88 -0
- package/dist/index.d.ts +19 -44
- package/dist/index.js +20 -68
- package/dist/jsx/index.d.ts +2 -0
- package/dist/jsx/index.js +1 -0
- package/dist/jsx/jsx-dev-runtime.d.ts +4 -0
- package/dist/jsx/jsx-dev-runtime.js +4 -0
- package/dist/jsx/jsx-runtime.d.ts +38 -0
- package/dist/jsx/jsx-runtime.js +38 -0
- package/dist/jsx/types.d.ts +12 -0
- package/dist/jsx/types.js +4 -0
- package/dist/primitives/context.d.ts +34 -0
- package/dist/primitives/context.js +63 -0
- package/dist/primitives/index.d.ts +3 -0
- package/dist/primitives/index.js +3 -0
- package/dist/primitives/instance.d.ts +72 -0
- package/dist/primitives/instance.js +235 -0
- package/dist/primitives/store.d.ts +22 -0
- package/dist/primitives/store.js +97 -0
- package/dist/provider/backend.d.ts +110 -0
- package/dist/provider/backend.js +37 -0
- package/dist/provider/interface.d.ts +48 -0
- package/dist/provider/interface.js +39 -0
- package/dist/reactive/effect.d.ts +11 -0
- package/dist/reactive/effect.js +42 -0
- package/dist/reactive/index.d.ts +3 -0
- package/dist/reactive/index.js +3 -0
- package/dist/reactive/signal.d.ts +32 -0
- package/dist/reactive/signal.js +60 -0
- package/dist/reactive/tracking.d.ts +41 -0
- package/dist/reactive/tracking.js +161 -0
- package/dist/runtime/fiber.d.ts +21 -0
- package/dist/runtime/fiber.js +16 -0
- package/dist/runtime/index.d.ts +4 -0
- package/dist/runtime/index.js +4 -0
- package/dist/runtime/reconcile.d.ts +66 -0
- package/dist/runtime/reconcile.js +210 -0
- package/dist/runtime/render.d.ts +42 -0
- package/dist/runtime/render.js +231 -0
- package/dist/runtime/run.d.ts +119 -0
- package/dist/runtime/run.js +334 -0
- package/dist/runtime/state-machine.d.ts +95 -0
- package/dist/runtime/state-machine.js +209 -0
- package/dist/types.d.ts +13 -0
- package/dist/types.js +4 -0
- package/package.json +11 -27
- package/dist/cli/commands/BuildCommand.d.ts +0 -40
- package/dist/cli/commands/BuildCommand.js +0 -151
- package/dist/cli/commands/DeployCommand.d.ts +0 -38
- package/dist/cli/commands/DeployCommand.js +0 -194
- package/dist/cli/commands/DevCommand.d.ts +0 -52
- package/dist/cli/commands/DevCommand.js +0 -394
- package/dist/cli/commands/PlanCommand.d.ts +0 -39
- package/dist/cli/commands/PlanCommand.js +0 -164
- package/dist/cli/commands/index.d.ts +0 -36
- package/dist/cli/commands/index.js +0 -43
- package/dist/cli/core/ArgumentParser.d.ts +0 -46
- package/dist/cli/core/ArgumentParser.js +0 -127
- package/dist/cli/core/BaseCommand.d.ts +0 -75
- package/dist/cli/core/BaseCommand.js +0 -95
- package/dist/cli/core/CLIContext.d.ts +0 -68
- package/dist/cli/core/CLIContext.js +0 -183
- package/dist/cli/core/CommandRegistry.d.ts +0 -64
- package/dist/cli/core/CommandRegistry.js +0 -89
- package/dist/cli/core/index.d.ts +0 -36
- package/dist/cli/core/index.js +0 -43
- package/dist/cli/index.d.ts +0 -35
- package/dist/cli/index.js +0 -100
- package/dist/cli/output.d.ts +0 -204
- package/dist/cli/output.js +0 -437
- package/dist/cli/utils.d.ts +0 -59
- package/dist/cli/utils.js +0 -76
- package/dist/context/createContext.d.ts +0 -90
- package/dist/context/createContext.js +0 -113
- package/dist/context/index.d.ts +0 -30
- package/dist/context/index.js +0 -35
- package/dist/core/CReact.d.ts +0 -409
- package/dist/core/CReact.js +0 -1151
- package/dist/core/CloudDOMBuilder.d.ts +0 -447
- package/dist/core/CloudDOMBuilder.js +0 -1234
- package/dist/core/ContextDependencyTracker.d.ts +0 -165
- package/dist/core/ContextDependencyTracker.js +0 -448
- package/dist/core/ErrorRecoveryManager.d.ts +0 -145
- package/dist/core/ErrorRecoveryManager.js +0 -443
- package/dist/core/EventBus.d.ts +0 -91
- package/dist/core/EventBus.js +0 -185
- package/dist/core/ProviderOutputTracker.d.ts +0 -211
- package/dist/core/ProviderOutputTracker.js +0 -476
- package/dist/core/ReactiveUpdateQueue.d.ts +0 -76
- package/dist/core/ReactiveUpdateQueue.js +0 -121
- package/dist/core/Reconciler.d.ts +0 -415
- package/dist/core/Reconciler.js +0 -1044
- package/dist/core/RenderScheduler.d.ts +0 -153
- package/dist/core/RenderScheduler.js +0 -519
- package/dist/core/Renderer.d.ts +0 -336
- package/dist/core/Renderer.js +0 -944
- package/dist/core/Runtime.d.ts +0 -246
- package/dist/core/Runtime.js +0 -640
- package/dist/core/StateBindingManager.d.ts +0 -121
- package/dist/core/StateBindingManager.js +0 -309
- package/dist/core/StateMachine.d.ts +0 -441
- package/dist/core/StateMachine.js +0 -883
- package/dist/core/StructuralChangeDetector.d.ts +0 -140
- package/dist/core/StructuralChangeDetector.js +0 -363
- package/dist/core/Validator.d.ts +0 -127
- package/dist/core/Validator.js +0 -279
- package/dist/core/errors.d.ts +0 -153
- package/dist/core/errors.js +0 -202
- package/dist/core/index.d.ts +0 -38
- package/dist/core/index.js +0 -64
- package/dist/core/types.d.ts +0 -265
- package/dist/core/types.js +0 -48
- package/dist/hooks/context.d.ts +0 -147
- package/dist/hooks/context.js +0 -334
- package/dist/hooks/useContext.d.ts +0 -113
- package/dist/hooks/useContext.js +0 -169
- package/dist/hooks/useEffect.d.ts +0 -105
- package/dist/hooks/useEffect.js +0 -540
- package/dist/hooks/useInstance.d.ts +0 -139
- package/dist/hooks/useInstance.js +0 -455
- package/dist/hooks/useState.d.ts +0 -120
- package/dist/hooks/useState.js +0 -298
- package/dist/jsx.d.ts +0 -143
- package/dist/jsx.js +0 -76
- package/dist/providers/DummyBackendProvider.d.ts +0 -193
- package/dist/providers/DummyBackendProvider.js +0 -189
- package/dist/providers/DummyCloudProvider.d.ts +0 -128
- package/dist/providers/DummyCloudProvider.js +0 -157
- package/dist/providers/IBackendProvider.d.ts +0 -177
- package/dist/providers/IBackendProvider.js +0 -31
- package/dist/providers/ICloudProvider.d.ts +0 -230
- package/dist/providers/ICloudProvider.js +0 -31
- package/dist/providers/index.d.ts +0 -31
- package/dist/providers/index.js +0 -31
- package/dist/test-event-callbacks.d.ts +0 -0
- package/dist/test-event-callbacks.js +0 -1
- package/dist/utils/Logger.d.ts +0 -144
- package/dist/utils/Logger.js +0 -220
- package/dist/utils/Output.d.ts +0 -161
- package/dist/utils/Output.js +0 -401
- package/dist/utils/deepEqual.d.ts +0 -71
- package/dist/utils/deepEqual.js +0 -276
- package/dist/utils/naming.d.ts +0 -241
- package/dist/utils/naming.js +0 -376
|
@@ -1,193 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
|
|
3
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
4
|
-
|
|
5
|
-
* you may not use this file except in compliance with the License.
|
|
6
|
-
|
|
7
|
-
* You may obtain a copy of the License at
|
|
8
|
-
|
|
9
|
-
*
|
|
10
|
-
|
|
11
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
12
|
-
|
|
13
|
-
*
|
|
14
|
-
|
|
15
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
16
|
-
|
|
17
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
18
|
-
|
|
19
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
20
|
-
|
|
21
|
-
* See the License for the specific language governing permissions and
|
|
22
|
-
|
|
23
|
-
* limitations under the License.
|
|
24
|
-
|
|
25
|
-
*
|
|
26
|
-
|
|
27
|
-
* Copyright 2025 Daniel Coutinho Ribeiro
|
|
28
|
-
|
|
29
|
-
*/
|
|
30
|
-
|
|
31
|
-
/**
|
|
32
|
-
|
|
33
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
34
|
-
|
|
35
|
-
* you may not use this file except in compliance with the License.
|
|
36
|
-
|
|
37
|
-
* You may obtain a copy of the License at
|
|
38
|
-
|
|
39
|
-
*
|
|
40
|
-
|
|
41
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
42
|
-
|
|
43
|
-
*
|
|
44
|
-
|
|
45
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
46
|
-
|
|
47
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
48
|
-
|
|
49
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
50
|
-
|
|
51
|
-
* See the License for the specific language governing permissions and
|
|
52
|
-
|
|
53
|
-
* limitations under the License.
|
|
54
|
-
|
|
55
|
-
*
|
|
56
|
-
|
|
57
|
-
* Copyright 2025 Daniel Coutinho Ribeiro
|
|
58
|
-
|
|
59
|
-
*/
|
|
60
|
-
|
|
61
|
-
import { IBackendProvider } from './IBackendProvider';
|
|
62
|
-
/**
|
|
63
|
-
* DummyBackendProvider is a POC implementation using in-memory Map storage.
|
|
64
|
-
*
|
|
65
|
-
* Use cases:
|
|
66
|
-
* - POC demonstrations
|
|
67
|
-
* - Testing without remote state backend
|
|
68
|
-
* - Development and debugging
|
|
69
|
-
* - CI/CD validation
|
|
70
|
-
*
|
|
71
|
-
* This is a standalone implementation, NOT a base class.
|
|
72
|
-
*
|
|
73
|
-
* @example
|
|
74
|
-
* ```typescript
|
|
75
|
-
* const provider = new DummyBackendProvider();
|
|
76
|
-
* await provider.initialize();
|
|
77
|
-
* await provider.saveState('stack', { cloudDOM: [...] });
|
|
78
|
-
* const state = await provider.getState('stack');
|
|
79
|
-
* ```
|
|
80
|
-
*/
|
|
81
|
-
export declare class DummyBackendProvider implements IBackendProvider {
|
|
82
|
-
private state;
|
|
83
|
-
private initialized;
|
|
84
|
-
private locks;
|
|
85
|
-
private auditLogs;
|
|
86
|
-
private snapshots;
|
|
87
|
-
/**
|
|
88
|
-
* Optional initialization (simulates async setup)
|
|
89
|
-
* REQ-04.4: Support async initialization
|
|
90
|
-
*/
|
|
91
|
-
initialize(): Promise<void>;
|
|
92
|
-
/**
|
|
93
|
-
* Check if provider is initialized
|
|
94
|
-
* Useful for integration testing
|
|
95
|
-
*/
|
|
96
|
-
isInitialized(): boolean;
|
|
97
|
-
/**
|
|
98
|
-
* Retrieve state for a given stack
|
|
99
|
-
* Returns undefined if no state exists
|
|
100
|
-
*
|
|
101
|
-
* REQ-04: Core provider interface implementation
|
|
102
|
-
* REQ-05: State management for deployment tracking
|
|
103
|
-
* REQ-06: Universal output access
|
|
104
|
-
*
|
|
105
|
-
* @param stackName - Name of the stack to retrieve state for
|
|
106
|
-
* @returns Promise resolving to stack state, or undefined if not found
|
|
107
|
-
*/
|
|
108
|
-
getState(stackName: string): Promise<any | undefined>;
|
|
109
|
-
/**
|
|
110
|
-
* Save state for a given stack
|
|
111
|
-
*
|
|
112
|
-
* REQ-04: Core provider interface implementation
|
|
113
|
-
* REQ-05: State management for deployment tracking
|
|
114
|
-
* REQ-08.5: Store migration map versions in backend state
|
|
115
|
-
*
|
|
116
|
-
* @param stackName - Name of the stack to save state for
|
|
117
|
-
* @param state - State object to persist (CloudDOM, outputs, metadata)
|
|
118
|
-
* @returns Promise that resolves when state is saved
|
|
119
|
-
*/
|
|
120
|
-
saveState(stackName: string, state: any): Promise<void>;
|
|
121
|
-
/**
|
|
122
|
-
* Helper method: Clear all state (useful for testing)
|
|
123
|
-
* Not part of IBackendProvider interface
|
|
124
|
-
*/
|
|
125
|
-
clearAll(): void;
|
|
126
|
-
/**
|
|
127
|
-
* Helper method: Get all state (useful for debugging)
|
|
128
|
-
* Not part of IBackendProvider interface
|
|
129
|
-
*
|
|
130
|
-
* @returns Map of all stack states
|
|
131
|
-
*/
|
|
132
|
-
getAllState(): Map<string, any>;
|
|
133
|
-
/**
|
|
134
|
-
* Acquire lock for a stack (optional method for StateMachine)
|
|
135
|
-
* REQ-O02: State locking to prevent concurrent deployments
|
|
136
|
-
*
|
|
137
|
-
* @param stackName - Name of the stack to lock
|
|
138
|
-
* @param holder - Identifier of the lock holder (user/process)
|
|
139
|
-
* @param ttl - Time-to-live in seconds
|
|
140
|
-
* @throws Error if lock is already held and not expired
|
|
141
|
-
*/
|
|
142
|
-
acquireLock(stackName: string, holder: string, ttl: number): Promise<void>;
|
|
143
|
-
/**
|
|
144
|
-
* Release lock for a stack (optional method for StateMachine)
|
|
145
|
-
* REQ-O02: State locking to prevent concurrent deployments
|
|
146
|
-
*
|
|
147
|
-
* @param stackName - Name of the stack to unlock
|
|
148
|
-
*/
|
|
149
|
-
releaseLock(stackName: string): Promise<void>;
|
|
150
|
-
/**
|
|
151
|
-
* Check lock status for a stack (optional method for StateMachine)
|
|
152
|
-
* REQ-O02: State locking to prevent concurrent deployments
|
|
153
|
-
*
|
|
154
|
-
* @param stackName - Name of the stack to check
|
|
155
|
-
* @returns Lock info if lock exists, null otherwise
|
|
156
|
-
*/
|
|
157
|
-
checkLock(stackName: string): Promise<{
|
|
158
|
-
holder: string;
|
|
159
|
-
acquiredAt: number;
|
|
160
|
-
ttl: number;
|
|
161
|
-
} | null>;
|
|
162
|
-
/**
|
|
163
|
-
* Append audit log entry (optional method for StateMachine)
|
|
164
|
-
* REQ-O05: Audit log for compliance and debugging
|
|
165
|
-
*
|
|
166
|
-
* @param stackName - Name of the stack
|
|
167
|
-
* @param entry - Audit log entry to append
|
|
168
|
-
*/
|
|
169
|
-
appendAuditLog(stackName: string, entry: any): Promise<void>;
|
|
170
|
-
/**
|
|
171
|
-
* Save state snapshot (optional method for StateMachine)
|
|
172
|
-
* REQ-O01: State snapshots for time-travel debugging
|
|
173
|
-
*
|
|
174
|
-
* @param stackName - Name of the stack
|
|
175
|
-
* @param state - State snapshot to save
|
|
176
|
-
*/
|
|
177
|
-
saveSnapshot(stackName: string, state: any): Promise<void>;
|
|
178
|
-
/**
|
|
179
|
-
* Helper method: Check if lock exists (useful for testing)
|
|
180
|
-
* Not part of IBackendProvider interface
|
|
181
|
-
*/
|
|
182
|
-
hasLock(stackName: string): boolean;
|
|
183
|
-
/**
|
|
184
|
-
* Helper method: Get audit logs (useful for testing)
|
|
185
|
-
* Not part of IBackendProvider interface
|
|
186
|
-
*/
|
|
187
|
-
getAuditLogs(stackName: string): any[];
|
|
188
|
-
/**
|
|
189
|
-
* Helper method: Get snapshots (useful for testing)
|
|
190
|
-
* Not part of IBackendProvider interface
|
|
191
|
-
*/
|
|
192
|
-
getSnapshots(stackName: string): any[];
|
|
193
|
-
}
|
|
@@ -1,189 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
// REQ-04: Dummy backend provider implementation for POC and testing
|
|
3
|
-
// REQ-05: State management for deployment tracking
|
|
4
|
-
// REQ-06: Universal output access
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.DummyBackendProvider = void 0;
|
|
7
|
-
/**
|
|
8
|
-
* DummyBackendProvider is a POC implementation using in-memory Map storage.
|
|
9
|
-
*
|
|
10
|
-
* Use cases:
|
|
11
|
-
* - POC demonstrations
|
|
12
|
-
* - Testing without remote state backend
|
|
13
|
-
* - Development and debugging
|
|
14
|
-
* - CI/CD validation
|
|
15
|
-
*
|
|
16
|
-
* This is a standalone implementation, NOT a base class.
|
|
17
|
-
*
|
|
18
|
-
* @example
|
|
19
|
-
* ```typescript
|
|
20
|
-
* const provider = new DummyBackendProvider();
|
|
21
|
-
* await provider.initialize();
|
|
22
|
-
* await provider.saveState('stack', { cloudDOM: [...] });
|
|
23
|
-
* const state = await provider.getState('stack');
|
|
24
|
-
* ```
|
|
25
|
-
*/
|
|
26
|
-
class DummyBackendProvider {
|
|
27
|
-
constructor() {
|
|
28
|
-
this.state = new Map();
|
|
29
|
-
this.initialized = false;
|
|
30
|
-
this.locks = new Map();
|
|
31
|
-
this.auditLogs = new Map();
|
|
32
|
-
this.snapshots = new Map();
|
|
33
|
-
}
|
|
34
|
-
/**
|
|
35
|
-
* Optional initialization (simulates async setup)
|
|
36
|
-
* REQ-04.4: Support async initialization
|
|
37
|
-
*/
|
|
38
|
-
async initialize() {
|
|
39
|
-
console.log('[DummyBackendProvider] Initializing...');
|
|
40
|
-
this.initialized = true;
|
|
41
|
-
}
|
|
42
|
-
/**
|
|
43
|
-
* Check if provider is initialized
|
|
44
|
-
* Useful for integration testing
|
|
45
|
-
*/
|
|
46
|
-
isInitialized() {
|
|
47
|
-
return this.initialized;
|
|
48
|
-
}
|
|
49
|
-
/**
|
|
50
|
-
* Retrieve state for a given stack
|
|
51
|
-
* Returns undefined if no state exists
|
|
52
|
-
*
|
|
53
|
-
* REQ-04: Core provider interface implementation
|
|
54
|
-
* REQ-05: State management for deployment tracking
|
|
55
|
-
* REQ-06: Universal output access
|
|
56
|
-
*
|
|
57
|
-
* @param stackName - Name of the stack to retrieve state for
|
|
58
|
-
* @returns Promise resolving to stack state, or undefined if not found
|
|
59
|
-
*/
|
|
60
|
-
async getState(stackName) {
|
|
61
|
-
console.debug(`[DummyBackendProvider] Getting state for stack: ${stackName}`);
|
|
62
|
-
return this.state.get(stackName);
|
|
63
|
-
}
|
|
64
|
-
/**
|
|
65
|
-
* Save state for a given stack
|
|
66
|
-
*
|
|
67
|
-
* REQ-04: Core provider interface implementation
|
|
68
|
-
* REQ-05: State management for deployment tracking
|
|
69
|
-
* REQ-08.5: Store migration map versions in backend state
|
|
70
|
-
*
|
|
71
|
-
* @param stackName - Name of the stack to save state for
|
|
72
|
-
* @param state - State object to persist (CloudDOM, outputs, metadata)
|
|
73
|
-
* @returns Promise that resolves when state is saved
|
|
74
|
-
*/
|
|
75
|
-
async saveState(stackName, state) {
|
|
76
|
-
console.debug(`[DummyBackendProvider] Saving state for stack: ${stackName}`);
|
|
77
|
-
this.state.set(stackName, state);
|
|
78
|
-
}
|
|
79
|
-
/**
|
|
80
|
-
* Helper method: Clear all state (useful for testing)
|
|
81
|
-
* Not part of IBackendProvider interface
|
|
82
|
-
*/
|
|
83
|
-
clearAll() {
|
|
84
|
-
console.debug('[DummyBackendProvider] Clearing all state');
|
|
85
|
-
this.state.clear();
|
|
86
|
-
}
|
|
87
|
-
/**
|
|
88
|
-
* Helper method: Get all state (useful for debugging)
|
|
89
|
-
* Not part of IBackendProvider interface
|
|
90
|
-
*
|
|
91
|
-
* @returns Map of all stack states
|
|
92
|
-
*/
|
|
93
|
-
getAllState() {
|
|
94
|
-
return new Map(this.state);
|
|
95
|
-
}
|
|
96
|
-
/**
|
|
97
|
-
* Acquire lock for a stack (optional method for StateMachine)
|
|
98
|
-
* REQ-O02: State locking to prevent concurrent deployments
|
|
99
|
-
*
|
|
100
|
-
* @param stackName - Name of the stack to lock
|
|
101
|
-
* @param holder - Identifier of the lock holder (user/process)
|
|
102
|
-
* @param ttl - Time-to-live in seconds
|
|
103
|
-
* @throws Error if lock is already held and not expired
|
|
104
|
-
*/
|
|
105
|
-
async acquireLock(stackName, holder, ttl) {
|
|
106
|
-
const existingLock = this.locks.get(stackName);
|
|
107
|
-
if (existingLock) {
|
|
108
|
-
const now = Date.now();
|
|
109
|
-
const lockAge = now - existingLock.acquiredAt;
|
|
110
|
-
const lockTTL = existingLock.ttl * 1000; // Convert to milliseconds
|
|
111
|
-
if (lockAge < lockTTL) {
|
|
112
|
-
throw new Error(`Stack "${stackName}" is locked by ${existingLock.holder} ` +
|
|
113
|
-
`(acquired ${new Date(existingLock.acquiredAt).toISOString()})`);
|
|
114
|
-
}
|
|
115
|
-
}
|
|
116
|
-
this.locks.set(stackName, { holder, acquiredAt: Date.now(), ttl });
|
|
117
|
-
console.debug(`[DummyBackendProvider] Lock acquired for stack: ${stackName} by ${holder}`);
|
|
118
|
-
}
|
|
119
|
-
/**
|
|
120
|
-
* Release lock for a stack (optional method for StateMachine)
|
|
121
|
-
* REQ-O02: State locking to prevent concurrent deployments
|
|
122
|
-
*
|
|
123
|
-
* @param stackName - Name of the stack to unlock
|
|
124
|
-
*/
|
|
125
|
-
async releaseLock(stackName) {
|
|
126
|
-
this.locks.delete(stackName);
|
|
127
|
-
console.debug(`[DummyBackendProvider] Lock released for stack: ${stackName}`);
|
|
128
|
-
}
|
|
129
|
-
/**
|
|
130
|
-
* Check lock status for a stack (optional method for StateMachine)
|
|
131
|
-
* REQ-O02: State locking to prevent concurrent deployments
|
|
132
|
-
*
|
|
133
|
-
* @param stackName - Name of the stack to check
|
|
134
|
-
* @returns Lock info if lock exists, null otherwise
|
|
135
|
-
*/
|
|
136
|
-
async checkLock(stackName) {
|
|
137
|
-
return this.locks.get(stackName) || null;
|
|
138
|
-
}
|
|
139
|
-
/**
|
|
140
|
-
* Append audit log entry (optional method for StateMachine)
|
|
141
|
-
* REQ-O05: Audit log for compliance and debugging
|
|
142
|
-
*
|
|
143
|
-
* @param stackName - Name of the stack
|
|
144
|
-
* @param entry - Audit log entry to append
|
|
145
|
-
*/
|
|
146
|
-
async appendAuditLog(stackName, entry) {
|
|
147
|
-
if (!this.auditLogs.has(stackName)) {
|
|
148
|
-
this.auditLogs.set(stackName, []);
|
|
149
|
-
}
|
|
150
|
-
this.auditLogs.get(stackName).push(entry);
|
|
151
|
-
console.debug(`[DummyBackendProvider] Audit log entry appended for stack: ${stackName}`);
|
|
152
|
-
}
|
|
153
|
-
/**
|
|
154
|
-
* Save state snapshot (optional method for StateMachine)
|
|
155
|
-
* REQ-O01: State snapshots for time-travel debugging
|
|
156
|
-
*
|
|
157
|
-
* @param stackName - Name of the stack
|
|
158
|
-
* @param state - State snapshot to save
|
|
159
|
-
*/
|
|
160
|
-
async saveSnapshot(stackName, state) {
|
|
161
|
-
if (!this.snapshots.has(stackName)) {
|
|
162
|
-
this.snapshots.set(stackName, []);
|
|
163
|
-
}
|
|
164
|
-
this.snapshots.get(stackName).push(state);
|
|
165
|
-
console.debug(`[DummyBackendProvider] Snapshot saved for stack: ${stackName}`);
|
|
166
|
-
}
|
|
167
|
-
/**
|
|
168
|
-
* Helper method: Check if lock exists (useful for testing)
|
|
169
|
-
* Not part of IBackendProvider interface
|
|
170
|
-
*/
|
|
171
|
-
hasLock(stackName) {
|
|
172
|
-
return this.locks.has(stackName);
|
|
173
|
-
}
|
|
174
|
-
/**
|
|
175
|
-
* Helper method: Get audit logs (useful for testing)
|
|
176
|
-
* Not part of IBackendProvider interface
|
|
177
|
-
*/
|
|
178
|
-
getAuditLogs(stackName) {
|
|
179
|
-
return this.auditLogs.get(stackName) || [];
|
|
180
|
-
}
|
|
181
|
-
/**
|
|
182
|
-
* Helper method: Get snapshots (useful for testing)
|
|
183
|
-
* Not part of IBackendProvider interface
|
|
184
|
-
*/
|
|
185
|
-
getSnapshots(stackName) {
|
|
186
|
-
return this.snapshots.get(stackName) || [];
|
|
187
|
-
}
|
|
188
|
-
}
|
|
189
|
-
exports.DummyBackendProvider = DummyBackendProvider;
|
|
@@ -1,128 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
|
|
3
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
4
|
-
|
|
5
|
-
* you may not use this file except in compliance with the License.
|
|
6
|
-
|
|
7
|
-
* You may obtain a copy of the License at
|
|
8
|
-
|
|
9
|
-
*
|
|
10
|
-
|
|
11
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
12
|
-
|
|
13
|
-
*
|
|
14
|
-
|
|
15
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
16
|
-
|
|
17
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
18
|
-
|
|
19
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
20
|
-
|
|
21
|
-
* See the License for the specific language governing permissions and
|
|
22
|
-
|
|
23
|
-
* limitations under the License.
|
|
24
|
-
|
|
25
|
-
*
|
|
26
|
-
|
|
27
|
-
* Copyright 2025 Daniel Coutinho Ribeiro
|
|
28
|
-
|
|
29
|
-
*/
|
|
30
|
-
|
|
31
|
-
/**
|
|
32
|
-
|
|
33
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
34
|
-
|
|
35
|
-
* you may not use this file except in compliance with the License.
|
|
36
|
-
|
|
37
|
-
* You may obtain a copy of the License at
|
|
38
|
-
|
|
39
|
-
*
|
|
40
|
-
|
|
41
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
42
|
-
|
|
43
|
-
*
|
|
44
|
-
|
|
45
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
46
|
-
|
|
47
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
48
|
-
|
|
49
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
50
|
-
|
|
51
|
-
* See the License for the specific language governing permissions and
|
|
52
|
-
|
|
53
|
-
* limitations under the License.
|
|
54
|
-
|
|
55
|
-
*
|
|
56
|
-
|
|
57
|
-
* Copyright 2025 Daniel Coutinho Ribeiro
|
|
58
|
-
|
|
59
|
-
*/
|
|
60
|
-
|
|
61
|
-
import { ICloudProvider, CloudDOMNode } from './ICloudProvider';
|
|
62
|
-
/**
|
|
63
|
-
* DummyCloudProvider is a POC implementation that logs CloudDOM structure
|
|
64
|
-
* instead of deploying actual infrastructure.
|
|
65
|
-
*
|
|
66
|
-
* Use cases:
|
|
67
|
-
* - POC demonstrations
|
|
68
|
-
* - Testing without cloud credentials
|
|
69
|
-
* - Development and debugging
|
|
70
|
-
* - CI/CD validation
|
|
71
|
-
*
|
|
72
|
-
* This is a standalone implementation, NOT a base class.
|
|
73
|
-
*
|
|
74
|
-
* @example
|
|
75
|
-
* ```typescript
|
|
76
|
-
* const provider = new DummyCloudProvider();
|
|
77
|
-
* await provider.initialize();
|
|
78
|
-
* provider.materialize(cloudDOM);
|
|
79
|
-
* ```
|
|
80
|
-
*/
|
|
81
|
-
export declare class DummyCloudProvider implements ICloudProvider {
|
|
82
|
-
private initialized;
|
|
83
|
-
/**
|
|
84
|
-
* Optional initialization (simulates async setup)
|
|
85
|
-
* REQ-04.4: Support async initialization
|
|
86
|
-
*/
|
|
87
|
-
initialize(): Promise<void>;
|
|
88
|
-
/**
|
|
89
|
-
* Check if provider is initialized
|
|
90
|
-
* Useful for integration testing
|
|
91
|
-
*/
|
|
92
|
-
isInitialized(): boolean;
|
|
93
|
-
/**
|
|
94
|
-
* Materialize CloudDOM by logging structure with indentation
|
|
95
|
-
* REQ-04: Core provider interface implementation
|
|
96
|
-
*
|
|
97
|
-
* @param cloudDOM - Array of CloudDOM nodes to materialize
|
|
98
|
-
*/
|
|
99
|
-
materialize(cloudDOM: CloudDOMNode[]): void;
|
|
100
|
-
/**
|
|
101
|
-
* Recursively log CloudDOM node with indentation
|
|
102
|
-
* Outputs are logged in format: nodeId.outputKey = value
|
|
103
|
-
*/
|
|
104
|
-
private logNode;
|
|
105
|
-
/**
|
|
106
|
-
* Safely stringify objects, handling circular references and non-JSON values
|
|
107
|
-
*/
|
|
108
|
-
private safeStringify;
|
|
109
|
-
/**
|
|
110
|
-
* JSON replacer function that handles circular references
|
|
111
|
-
*/
|
|
112
|
-
private getCircularReplacer;
|
|
113
|
-
/**
|
|
114
|
-
* Optional lifecycle hook: called before deployment
|
|
115
|
-
* REQ-09.1: preDeploy lifecycle hook
|
|
116
|
-
*/
|
|
117
|
-
preDeploy(cloudDOM: CloudDOMNode[]): Promise<void>;
|
|
118
|
-
/**
|
|
119
|
-
* Optional lifecycle hook: called after successful deployment
|
|
120
|
-
* REQ-09.2: postDeploy lifecycle hook
|
|
121
|
-
*/
|
|
122
|
-
postDeploy(cloudDOM: CloudDOMNode[], outputs: Record<string, any>): Promise<void>;
|
|
123
|
-
/**
|
|
124
|
-
* Optional lifecycle hook: called when deployment fails
|
|
125
|
-
* REQ-09.3: onError lifecycle hook
|
|
126
|
-
*/
|
|
127
|
-
onError(error: Error, cloudDOM: CloudDOMNode[]): Promise<void>;
|
|
128
|
-
}
|
|
@@ -1,157 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
// REQ-04: Dummy provider implementation for POC and testing
|
|
3
|
-
// REQ-09: Lifecycle hooks implementation
|
|
4
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
5
|
-
exports.DummyCloudProvider = void 0;
|
|
6
|
-
/**
|
|
7
|
-
* DummyCloudProvider is a POC implementation that logs CloudDOM structure
|
|
8
|
-
* instead of deploying actual infrastructure.
|
|
9
|
-
*
|
|
10
|
-
* Use cases:
|
|
11
|
-
* - POC demonstrations
|
|
12
|
-
* - Testing without cloud credentials
|
|
13
|
-
* - Development and debugging
|
|
14
|
-
* - CI/CD validation
|
|
15
|
-
*
|
|
16
|
-
* This is a standalone implementation, NOT a base class.
|
|
17
|
-
*
|
|
18
|
-
* @example
|
|
19
|
-
* ```typescript
|
|
20
|
-
* const provider = new DummyCloudProvider();
|
|
21
|
-
* await provider.initialize();
|
|
22
|
-
* provider.materialize(cloudDOM);
|
|
23
|
-
* ```
|
|
24
|
-
*/
|
|
25
|
-
class DummyCloudProvider {
|
|
26
|
-
constructor() {
|
|
27
|
-
this.initialized = false;
|
|
28
|
-
}
|
|
29
|
-
/**
|
|
30
|
-
* Optional initialization (simulates async setup)
|
|
31
|
-
* REQ-04.4: Support async initialization
|
|
32
|
-
*/
|
|
33
|
-
async initialize() {
|
|
34
|
-
console.log('[DummyCloudProvider] Initializing...');
|
|
35
|
-
this.initialized = true;
|
|
36
|
-
}
|
|
37
|
-
/**
|
|
38
|
-
* Check if provider is initialized
|
|
39
|
-
* Useful for integration testing
|
|
40
|
-
*/
|
|
41
|
-
isInitialized() {
|
|
42
|
-
return this.initialized;
|
|
43
|
-
}
|
|
44
|
-
/**
|
|
45
|
-
* Materialize CloudDOM by logging structure with indentation
|
|
46
|
-
* REQ-04: Core provider interface implementation
|
|
47
|
-
*
|
|
48
|
-
* @param cloudDOM - Array of CloudDOM nodes to materialize
|
|
49
|
-
*/
|
|
50
|
-
materialize(cloudDOM) {
|
|
51
|
-
console.debug('\n=== DummyCloudProvider: Materializing CloudDOM ===\n');
|
|
52
|
-
cloudDOM.forEach((node) => {
|
|
53
|
-
this.logNode(node, 0);
|
|
54
|
-
});
|
|
55
|
-
console.debug('\n=== Materialization Complete ===\n');
|
|
56
|
-
}
|
|
57
|
-
/**
|
|
58
|
-
* Recursively log CloudDOM node with indentation
|
|
59
|
-
* Outputs are logged in format: nodeId.outputKey = value
|
|
60
|
-
*/
|
|
61
|
-
logNode(node, depth, visited = new Set()) {
|
|
62
|
-
// Prevent infinite recursion from circular references
|
|
63
|
-
if (visited.has(node)) {
|
|
64
|
-
const indent = ' '.repeat(depth);
|
|
65
|
-
console.debug(`${indent}[Circular reference to ${node.id}]`);
|
|
66
|
-
return;
|
|
67
|
-
}
|
|
68
|
-
visited.add(node);
|
|
69
|
-
// Limit depth to prevent stack overflow
|
|
70
|
-
if (depth > 50) {
|
|
71
|
-
const indent = ' '.repeat(depth);
|
|
72
|
-
console.debug(`${indent}[Max depth reached]`);
|
|
73
|
-
return;
|
|
74
|
-
}
|
|
75
|
-
const indent = ' '.repeat(depth);
|
|
76
|
-
// Log resource
|
|
77
|
-
console.debug(`${indent}Deploying: ${node.id} (${node.construct?.name || 'Unknown'})`);
|
|
78
|
-
// Safely log props (handle undefined/null)
|
|
79
|
-
const propsStr = this.safeStringify(node.props || {}, 2);
|
|
80
|
-
const propsLines = propsStr.split('\n');
|
|
81
|
-
console.debug(`${indent} Props: ${propsLines.join(`\n${indent} `)}`);
|
|
82
|
-
// Log outputs
|
|
83
|
-
if (node.outputs && Object.keys(node.outputs).length > 0) {
|
|
84
|
-
console.debug(`${indent} Outputs:`);
|
|
85
|
-
Object.entries(node.outputs).forEach(([outputKey, value]) => {
|
|
86
|
-
console.debug(`${indent} ${node.id}.${outputKey} = ${this.safeStringify(value)}`);
|
|
87
|
-
});
|
|
88
|
-
}
|
|
89
|
-
// Log children recursively
|
|
90
|
-
if (node.children && node.children.length > 0) {
|
|
91
|
-
node.children.forEach((child) => {
|
|
92
|
-
this.logNode(child, depth + 1, visited);
|
|
93
|
-
});
|
|
94
|
-
}
|
|
95
|
-
}
|
|
96
|
-
/**
|
|
97
|
-
* Safely stringify objects, handling circular references and non-JSON values
|
|
98
|
-
*/
|
|
99
|
-
safeStringify(obj, indent) {
|
|
100
|
-
try {
|
|
101
|
-
return JSON.stringify(obj, this.getCircularReplacer(), indent);
|
|
102
|
-
}
|
|
103
|
-
catch {
|
|
104
|
-
return '[Unable to stringify: contains circular references or non-JSON values]';
|
|
105
|
-
}
|
|
106
|
-
}
|
|
107
|
-
/**
|
|
108
|
-
* JSON replacer function that handles circular references
|
|
109
|
-
*/
|
|
110
|
-
getCircularReplacer() {
|
|
111
|
-
const seen = new WeakSet();
|
|
112
|
-
return (key, value) => {
|
|
113
|
-
if (typeof value === 'object' && value !== null) {
|
|
114
|
-
if (seen.has(value)) {
|
|
115
|
-
return '[Circular]';
|
|
116
|
-
}
|
|
117
|
-
seen.add(value);
|
|
118
|
-
}
|
|
119
|
-
// Handle functions
|
|
120
|
-
if (typeof value === 'function') {
|
|
121
|
-
return '[Function]';
|
|
122
|
-
}
|
|
123
|
-
// Handle symbols
|
|
124
|
-
if (typeof value === 'symbol') {
|
|
125
|
-
return '[Symbol]';
|
|
126
|
-
}
|
|
127
|
-
return value;
|
|
128
|
-
};
|
|
129
|
-
}
|
|
130
|
-
/**
|
|
131
|
-
* Optional lifecycle hook: called before deployment
|
|
132
|
-
* REQ-09.1: preDeploy lifecycle hook
|
|
133
|
-
*/
|
|
134
|
-
async preDeploy(cloudDOM) {
|
|
135
|
-
console.debug('[DummyCloudProvider] preDeploy hook called');
|
|
136
|
-
console.debug(`[DummyCloudProvider] Validating ${cloudDOM.length} resources...`);
|
|
137
|
-
}
|
|
138
|
-
/**
|
|
139
|
-
* Optional lifecycle hook: called after successful deployment
|
|
140
|
-
* REQ-09.2: postDeploy lifecycle hook
|
|
141
|
-
*/
|
|
142
|
-
async postDeploy(cloudDOM, outputs) {
|
|
143
|
-
console.debug('[DummyCloudProvider] postDeploy hook called');
|
|
144
|
-
console.debug(`[DummyCloudProvider] Deployed ${cloudDOM.length} resources`);
|
|
145
|
-
console.debug(`[DummyCloudProvider] Collected ${Object.keys(outputs).length} outputs`);
|
|
146
|
-
}
|
|
147
|
-
/**
|
|
148
|
-
* Optional lifecycle hook: called when deployment fails
|
|
149
|
-
* REQ-09.3: onError lifecycle hook
|
|
150
|
-
*/
|
|
151
|
-
async onError(error, cloudDOM) {
|
|
152
|
-
console.error('[DummyCloudProvider] onError hook called');
|
|
153
|
-
console.error(`[DummyCloudProvider] Deployment failed: ${error.message}`);
|
|
154
|
-
console.error(`[DummyCloudProvider] Failed while deploying ${cloudDOM.length} resources`);
|
|
155
|
-
}
|
|
156
|
-
}
|
|
157
|
-
exports.DummyCloudProvider = DummyCloudProvider;
|