@azure/provisioning-core 0.1.0-alpha.20261014.1
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 +21 -0
- package/README.md +62 -0
- package/dist/constructs/built-in-resources/resource-group.d.ts +50 -0
- package/dist/constructs/built-in-resources/resource-group.d.ts.map +1 -0
- package/dist/constructs/built-in-resources/resource-group.js +97 -0
- package/dist/constructs/built-in-resources/resource-group.js.map +1 -0
- package/dist/constructs/output.d.ts +80 -0
- package/dist/constructs/output.d.ts.map +1 -0
- package/dist/constructs/output.js +76 -0
- package/dist/constructs/output.js.map +1 -0
- package/dist/constructs/parameter.d.ts +77 -0
- package/dist/constructs/parameter.d.ts.map +1 -0
- package/dist/constructs/parameter.js +93 -0
- package/dist/constructs/parameter.js.map +1 -0
- package/dist/constructs/provisioning-component.d.ts +91 -0
- package/dist/constructs/provisioning-component.d.ts.map +1 -0
- package/dist/constructs/provisioning-component.js +150 -0
- package/dist/constructs/provisioning-component.js.map +1 -0
- package/dist/constructs/resource/resource-proxy.d.ts +134 -0
- package/dist/constructs/resource/resource-proxy.d.ts.map +1 -0
- package/dist/constructs/resource/resource-proxy.js +523 -0
- package/dist/constructs/resource/resource-proxy.js.map +1 -0
- package/dist/constructs/resource/resource-query.d.ts +23 -0
- package/dist/constructs/resource/resource-query.d.ts.map +1 -0
- package/dist/constructs/resource/resource-query.js +71 -0
- package/dist/constructs/resource/resource-query.js.map +1 -0
- package/dist/constructs/resource/resource-registry.d.ts +99 -0
- package/dist/constructs/resource/resource-registry.d.ts.map +1 -0
- package/dist/constructs/resource/resource-registry.js +51 -0
- package/dist/constructs/resource/resource-registry.js.map +1 -0
- package/dist/constructs/resource/resource-type-registry.d.ts +46 -0
- package/dist/constructs/resource/resource-type-registry.d.ts.map +1 -0
- package/dist/constructs/resource/resource-type-registry.js +156 -0
- package/dist/constructs/resource/resource-type-registry.js.map +1 -0
- package/dist/constructs/resource/resource-utils.d.ts +60 -0
- package/dist/constructs/resource/resource-utils.d.ts.map +1 -0
- package/dist/constructs/resource/resource-utils.js +77 -0
- package/dist/constructs/resource/resource-utils.js.map +1 -0
- package/dist/constructs/resource/resource.d.ts +460 -0
- package/dist/constructs/resource/resource.d.ts.map +1 -0
- package/dist/constructs/resource/resource.js +584 -0
- package/dist/constructs/resource/resource.js.map +1 -0
- package/dist/constructs/stack.d.ts +110 -0
- package/dist/constructs/stack.d.ts.map +1 -0
- package/dist/constructs/stack.js +110 -0
- package/dist/constructs/stack.js.map +1 -0
- package/dist/constructs/variable.d.ts +63 -0
- package/dist/constructs/variable.d.ts.map +1 -0
- package/dist/constructs/variable.js +74 -0
- package/dist/constructs/variable.js.map +1 -0
- package/dist/deployment-context/deployment-context.d.ts +27 -0
- package/dist/deployment-context/deployment-context.d.ts.map +1 -0
- package/dist/deployment-context/deployment-context.js +4 -0
- package/dist/deployment-context/deployment-context.js.map +1 -0
- package/dist/expression/ast-nodes.d.ts +100 -0
- package/dist/expression/ast-nodes.d.ts.map +1 -0
- package/dist/expression/ast-nodes.js +127 -0
- package/dist/expression/ast-nodes.js.map +1 -0
- package/dist/expression/expressions.d.ts +164 -0
- package/dist/expression/expressions.d.ts.map +1 -0
- package/dist/expression/expressions.js +211 -0
- package/dist/expression/expressions.js.map +1 -0
- package/dist/fn.d.ts +194 -0
- package/dist/fn.d.ts.map +1 -0
- package/dist/fn.js +353 -0
- package/dist/fn.js.map +1 -0
- package/dist/index.d.ts +25 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +19 -0
- package/dist/index.js.map +1 -0
- package/dist/internal-loop.d.ts +14 -0
- package/dist/internal-loop.d.ts.map +1 -0
- package/dist/internal-loop.js +16 -0
- package/dist/internal-loop.js.map +1 -0
- package/dist/internal.d.ts +13 -0
- package/dist/internal.d.ts.map +1 -0
- package/dist/internal.js +10 -0
- package/dist/internal.js.map +1 -0
- package/dist/naming/naming-policy.d.ts +56 -0
- package/dist/naming/naming-policy.d.ts.map +1 -0
- package/dist/naming/naming-policy.js +99 -0
- package/dist/naming/naming-policy.js.map +1 -0
- package/dist/naming/naming-rules.d.ts +15 -0
- package/dist/naming/naming-rules.d.ts.map +1 -0
- package/dist/naming/naming-rules.js +15 -0
- package/dist/naming/naming-rules.js.map +1 -0
- package/dist/serialization/contract/generated/ast.d.ts +508 -0
- package/dist/serialization/contract/generated/ast.d.ts.map +1 -0
- package/dist/serialization/contract/generated/ast.js +23 -0
- package/dist/serialization/contract/generated/ast.js.map +1 -0
- package/dist/serialization/contract/index.d.ts +2 -0
- package/dist/serialization/contract/index.d.ts.map +1 -0
- package/dist/serialization/contract/index.js +4 -0
- package/dist/serialization/contract/index.js.map +1 -0
- package/dist/serialization/index.d.ts +4 -0
- package/dist/serialization/index.d.ts.map +1 -0
- package/dist/serialization/index.js +5 -0
- package/dist/serialization/index.js.map +1 -0
- package/dist/serialization/json/deserialize.d.ts +24 -0
- package/dist/serialization/json/deserialize.d.ts.map +1 -0
- package/dist/serialization/json/deserialize.js +476 -0
- package/dist/serialization/json/deserialize.js.map +1 -0
- package/dist/serialization/json/encoding.d.ts +4 -0
- package/dist/serialization/json/encoding.d.ts.map +1 -0
- package/dist/serialization/json/encoding.js +323 -0
- package/dist/serialization/json/encoding.js.map +1 -0
- package/dist/serialization/json/expression.d.ts +32 -0
- package/dist/serialization/json/expression.d.ts.map +1 -0
- package/dist/serialization/json/expression.js +490 -0
- package/dist/serialization/json/expression.js.map +1 -0
- package/dist/serialization/json/lower.d.ts +41 -0
- package/dist/serialization/json/lower.d.ts.map +1 -0
- package/dist/serialization/json/lower.js +343 -0
- package/dist/serialization/json/lower.js.map +1 -0
- package/dist/serialization/json/pluralize-config.d.ts +3 -0
- package/dist/serialization/json/pluralize-config.d.ts.map +1 -0
- package/dist/serialization/json/pluralize-config.js +7 -0
- package/dist/serialization/json/pluralize-config.js.map +1 -0
- package/dist/serialization/json/serialize.d.ts +12 -0
- package/dist/serialization/json/serialize.d.ts.map +1 -0
- package/dist/serialization/json/serialize.js +399 -0
- package/dist/serialization/json/serialize.js.map +1 -0
- package/dist/serialization/json/util.d.ts +2 -0
- package/dist/serialization/json/util.d.ts.map +1 -0
- package/dist/serialization/json/util.js +19 -0
- package/dist/serialization/json/util.js.map +1 -0
- package/dist/serialization/utils.d.ts +3 -0
- package/dist/serialization/utils.d.ts.map +1 -0
- package/dist/serialization/utils.js +146 -0
- package/dist/serialization/utils.js.map +1 -0
- package/dist/shape/shape-registry.d.ts +51 -0
- package/dist/shape/shape-registry.d.ts.map +1 -0
- package/dist/shape/shape-registry.js +41 -0
- package/dist/shape/shape-registry.js.map +1 -0
- package/dist/shape/shape.d.ts +407 -0
- package/dist/shape/shape.d.ts.map +1 -0
- package/dist/shape/shape.js +425 -0
- package/dist/shape/shape.js.map +1 -0
- package/dist/shape/value-encoding.d.ts +121 -0
- package/dist/shape/value-encoding.d.ts.map +1 -0
- package/dist/shape/value-encoding.js +32 -0
- package/dist/shape/value-encoding.js.map +1 -0
- package/dist/tsconfig.tsbuildinfo +1 -0
- package/dist/types.d.ts +9 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +4 -0
- package/dist/types.js.map +1 -0
- package/dist/util.d.ts +33 -0
- package/dist/util.d.ts.map +1 -0
- package/dist/util.js +78 -0
- package/dist/util.js.map +1 -0
- package/package.json +49 -0
|
@@ -0,0 +1,523 @@
|
|
|
1
|
+
// Copyright (c) Microsoft Corporation.
|
|
2
|
+
// Licensed under the MIT License.
|
|
3
|
+
import { EXPRESSION_BRAND, isExpression, unwrapExpression, } from "../../expression/expressions.js";
|
|
4
|
+
import { accessExpressionNode, arrayAccessExpressionNode, identifierExpressionNode, isExpressionNode, } from "../../expression/ast-nodes.js";
|
|
5
|
+
import { navigateShape, } from "../../shape/shape.js";
|
|
6
|
+
import { getShape } from "../../shape/shape-registry.js";
|
|
7
|
+
export const RAW_RESOURCE_HANDLE = Symbol("raw-resource-handle");
|
|
8
|
+
export const RESOURCE_BRAND = Symbol.for("@azure/provisioning-core.Resource");
|
|
9
|
+
/**
|
|
10
|
+
* Brand present on every `LoopedResource` instance. Lives here (rather than
|
|
11
|
+
* on the `LoopedResource` class) so tree-walking utilities can brand-check
|
|
12
|
+
* for looped declarations without a runtime import of `resource.ts` — which
|
|
13
|
+
* would create an eval-time import cycle (`resource.ts` extends `ProvisioningComponent`).
|
|
14
|
+
* Use {@link isLoopedResource} in normal code.
|
|
15
|
+
*/
|
|
16
|
+
export const LOOPED_RESOURCE_BRAND = Symbol.for("@azure/provisioning-core.LoopedResource");
|
|
17
|
+
/**
|
|
18
|
+
* Brand present on every `ResourceDeclaration` instance (both scalar
|
|
19
|
+
* `Resource` and looped `LoopedResource`). Use
|
|
20
|
+
* {@link isResourceDeclaration} instead of a direct
|
|
21
|
+
* brand check.
|
|
22
|
+
*/
|
|
23
|
+
export const RESOURCE_DECLARATION_BRAND = Symbol.for("@azure/provisioning-core.ResourceDeclaration");
|
|
24
|
+
/**
|
|
25
|
+
* Present on indexed resource proxies (see {@link createIndexedResourceProxy}).
|
|
26
|
+
* Reading it off any resource-like value returns the stored index expression
|
|
27
|
+
* for indexed proxies, and `undefined` for plain outer proxies. The base
|
|
28
|
+
* `Resource` constructor probes for it on the `context` argument to detect
|
|
29
|
+
* `parents.at(i)` / `parents.current()` being passed as a child parent
|
|
30
|
+
* context; other consumers may probe it for their own purposes (the proxy
|
|
31
|
+
* itself doesn't imply any parent-child relationship — the index is simply
|
|
32
|
+
* what identifies which element of a looped declaration this proxy refers
|
|
33
|
+
* to).
|
|
34
|
+
*/
|
|
35
|
+
export const PROXY_INDEX_REF = Symbol.for("@azure/provisioning-core.PROXY_INDEX_REF");
|
|
36
|
+
/**
|
|
37
|
+
* Present on indexed resource proxies. Reading it returns the underlying
|
|
38
|
+
* outer-proxy resource that the indexed proxy wraps. Used by the base
|
|
39
|
+
* `Resource` constructor to normalize `this.parent` back to the raw parent
|
|
40
|
+
* (so tree walks and symbol-map lookups continue to work) while
|
|
41
|
+
* `PROXY_INDEX_REF` carries the "which index" information onto `state`.
|
|
42
|
+
*/
|
|
43
|
+
export const INDEXED_PROXY_TARGET = Symbol.for("@azure/provisioning-core.INDEXED_PROXY_TARGET");
|
|
44
|
+
/**
|
|
45
|
+
* State-object key under which the base `Resource` constructor records the
|
|
46
|
+
* index expression when the `context` argument is an indexed proxy (i.e.,
|
|
47
|
+
* `parent.at(i)` / `parent.current()`). The serializer reads this key
|
|
48
|
+
* from the child's raw state to emit `parent: parentSym[<index>]` instead
|
|
49
|
+
* of the bare `parent: parentSym` form. Kept as a shared const so writer
|
|
50
|
+
* (`resource.ts`) and reader (`serialize.ts`) never drift.
|
|
51
|
+
*
|
|
52
|
+
* Lives on the **child**, not the parent: siblings under the same parent
|
|
53
|
+
* can be created via different indexed proxies (e.g. `new Child(p.at(0), …)`
|
|
54
|
+
* and `new Child(p.at(1), …)` both resolve `.parent` to the same raw parent,
|
|
55
|
+
* so the index that distinguishes them must be recorded per-child).
|
|
56
|
+
*/
|
|
57
|
+
export const STATE_PARENT_INDEX = "parentIndex";
|
|
58
|
+
function stepsToPath(steps) {
|
|
59
|
+
return steps.map((s) => s.segment);
|
|
60
|
+
}
|
|
61
|
+
const PROPERTY_PROXY_STATE = Symbol("property-proxy-state");
|
|
62
|
+
function isPropertyProxy(value) {
|
|
63
|
+
return (typeof value === "object" &&
|
|
64
|
+
value !== null &&
|
|
65
|
+
Reflect.get(value, PROPERTY_PROXY_STATE) !== undefined);
|
|
66
|
+
}
|
|
67
|
+
function getPropertyProxyState(value) {
|
|
68
|
+
return value[PROPERTY_PROXY_STATE];
|
|
69
|
+
}
|
|
70
|
+
export function deref(value) {
|
|
71
|
+
if (isPropertyProxy(value)) {
|
|
72
|
+
const state = getPropertyProxyState(value);
|
|
73
|
+
return getValueAtPath(state.root, stepsToPath(state.steps));
|
|
74
|
+
}
|
|
75
|
+
if (isResourceHandle(value)) {
|
|
76
|
+
return unwrapResourceHandle(value);
|
|
77
|
+
}
|
|
78
|
+
return value;
|
|
79
|
+
}
|
|
80
|
+
// ---------------------------------------------------------------------------
|
|
81
|
+
// Path helpers
|
|
82
|
+
// ---------------------------------------------------------------------------
|
|
83
|
+
function isPlainObject(value) {
|
|
84
|
+
if (typeof value !== "object" || value === null) {
|
|
85
|
+
return false;
|
|
86
|
+
}
|
|
87
|
+
const prototype = Object.getPrototypeOf(value);
|
|
88
|
+
return prototype === Object.prototype || prototype === null;
|
|
89
|
+
}
|
|
90
|
+
function getValueAtPath(root, path) {
|
|
91
|
+
let current = root;
|
|
92
|
+
for (const segment of path) {
|
|
93
|
+
if (typeof current !== "object" || current === null) {
|
|
94
|
+
return undefined;
|
|
95
|
+
}
|
|
96
|
+
if (!Object.prototype.hasOwnProperty.call(current, String(segment))) {
|
|
97
|
+
return undefined;
|
|
98
|
+
}
|
|
99
|
+
current = current[String(segment)];
|
|
100
|
+
}
|
|
101
|
+
return current;
|
|
102
|
+
}
|
|
103
|
+
function setValueAtPath(root, path, value) {
|
|
104
|
+
let current = root;
|
|
105
|
+
for (let index = 0; index < path.length - 1; index += 1) {
|
|
106
|
+
const segment = String(path[index]);
|
|
107
|
+
const nextSegment = path[index + 1];
|
|
108
|
+
const existing = Object.prototype.hasOwnProperty.call(current, segment)
|
|
109
|
+
? current[segment]
|
|
110
|
+
: undefined;
|
|
111
|
+
if (typeof existing === "object" && existing !== null) {
|
|
112
|
+
current = existing;
|
|
113
|
+
continue;
|
|
114
|
+
}
|
|
115
|
+
const container = (typeof nextSegment === "number" ? [] : Object.create(null));
|
|
116
|
+
Object.defineProperty(current, segment, {
|
|
117
|
+
value: container,
|
|
118
|
+
enumerable: true,
|
|
119
|
+
configurable: true,
|
|
120
|
+
writable: true,
|
|
121
|
+
});
|
|
122
|
+
current = container;
|
|
123
|
+
}
|
|
124
|
+
Object.defineProperty(current, String(path[path.length - 1]), {
|
|
125
|
+
value,
|
|
126
|
+
enumerable: true,
|
|
127
|
+
configurable: true,
|
|
128
|
+
writable: true,
|
|
129
|
+
});
|
|
130
|
+
}
|
|
131
|
+
// ---------------------------------------------------------------------------
|
|
132
|
+
// Expression construction
|
|
133
|
+
// ---------------------------------------------------------------------------
|
|
134
|
+
function createMemberAccessPathExpression(resource, steps, index) {
|
|
135
|
+
let current = identifierExpressionNode(resource);
|
|
136
|
+
if (index !== undefined) {
|
|
137
|
+
current = arrayAccessExpressionNode(current, index);
|
|
138
|
+
}
|
|
139
|
+
for (const { segment, armPath } of steps) {
|
|
140
|
+
current = accessExpressionNode(current, segment, { armPath });
|
|
141
|
+
}
|
|
142
|
+
return current;
|
|
143
|
+
}
|
|
144
|
+
// ---------------------------------------------------------------------------
|
|
145
|
+
// Value normalization
|
|
146
|
+
// ---------------------------------------------------------------------------
|
|
147
|
+
export function normalizeAssignedValue(value, currentResource) {
|
|
148
|
+
if (isPropertyProxy(value)) {
|
|
149
|
+
const state = getPropertyProxyState(value);
|
|
150
|
+
if (currentResource && state.resource === currentResource) {
|
|
151
|
+
// Same-resource proxy → inline raw value (avoids self-references)
|
|
152
|
+
return getValueAtPath(state.root, stepsToPath(state.steps));
|
|
153
|
+
}
|
|
154
|
+
return createMemberAccessPathExpression(state.resource, state.steps, state.index);
|
|
155
|
+
}
|
|
156
|
+
if (isResourceHandle(value)) {
|
|
157
|
+
return identifierExpressionNode(value);
|
|
158
|
+
}
|
|
159
|
+
if (isExpression(value)) {
|
|
160
|
+
return unwrapExpression(value);
|
|
161
|
+
}
|
|
162
|
+
if (isExpressionNode(value)) {
|
|
163
|
+
return value;
|
|
164
|
+
}
|
|
165
|
+
if (Array.isArray(value)) {
|
|
166
|
+
return value.map((item) => normalizeAssignedValue(item, currentResource));
|
|
167
|
+
}
|
|
168
|
+
if (isPlainObject(value)) {
|
|
169
|
+
return normalizeObjectValue(value, currentResource);
|
|
170
|
+
}
|
|
171
|
+
return value;
|
|
172
|
+
}
|
|
173
|
+
function normalizeObjectValue(obj, currentResource) {
|
|
174
|
+
const entries = Object.entries(obj);
|
|
175
|
+
const result = Object.create(null);
|
|
176
|
+
for (const [key, value] of entries) {
|
|
177
|
+
if (isPropertyProxy(value)) {
|
|
178
|
+
const state = getPropertyProxyState(value);
|
|
179
|
+
if (currentResource && state.resource === currentResource) {
|
|
180
|
+
// Same-resource → inline raw value (avoids self-references)
|
|
181
|
+
result[key] = getValueAtPath(state.root, stepsToPath(state.steps));
|
|
182
|
+
continue;
|
|
183
|
+
}
|
|
184
|
+
}
|
|
185
|
+
result[key] = normalizeAssignedValue(value, currentResource);
|
|
186
|
+
}
|
|
187
|
+
return result;
|
|
188
|
+
}
|
|
189
|
+
// ---------------------------------------------------------------------------
|
|
190
|
+
// Property proxy
|
|
191
|
+
// ---------------------------------------------------------------------------
|
|
192
|
+
function toPropertySegment(property, nav, currentValue) {
|
|
193
|
+
const isIndexedContainer = nav?.kind === "array" ||
|
|
194
|
+
nav?.kind === "tuple" ||
|
|
195
|
+
Array.isArray(currentValue);
|
|
196
|
+
return isIndexedContainer && /^\d+$/u.test(property)
|
|
197
|
+
? Number(property)
|
|
198
|
+
: property;
|
|
199
|
+
}
|
|
200
|
+
function getPropertyProxyTarget(state) {
|
|
201
|
+
const currentValue = getValueAtPath(state.root, stepsToPath(state.steps));
|
|
202
|
+
if (typeof currentValue === "object" && currentValue !== null) {
|
|
203
|
+
return currentValue;
|
|
204
|
+
}
|
|
205
|
+
return {};
|
|
206
|
+
}
|
|
207
|
+
function createPropertyProxy(state) {
|
|
208
|
+
// Always use a fresh empty target — avoids Proxy invariant violations
|
|
209
|
+
// when the stored value has non-configurable properties (e.g. EXPRESSION_BRAND).
|
|
210
|
+
const target = {};
|
|
211
|
+
return new Proxy(target, {
|
|
212
|
+
has(proxyTarget, property) {
|
|
213
|
+
if (property === PROPERTY_PROXY_STATE || property === EXPRESSION_BRAND) {
|
|
214
|
+
return true;
|
|
215
|
+
}
|
|
216
|
+
const backing = getPropertyProxyTarget(state);
|
|
217
|
+
if (Reflect.has(backing, property))
|
|
218
|
+
return true;
|
|
219
|
+
return Reflect.has(proxyTarget, property);
|
|
220
|
+
},
|
|
221
|
+
ownKeys() {
|
|
222
|
+
const backing = getPropertyProxyTarget(state);
|
|
223
|
+
return Reflect.ownKeys(backing).filter((k) => typeof k === "string");
|
|
224
|
+
},
|
|
225
|
+
getOwnPropertyDescriptor(_proxyTarget, property) {
|
|
226
|
+
const backing = getPropertyProxyTarget(state);
|
|
227
|
+
if (typeof property === "string" &&
|
|
228
|
+
Object.prototype.hasOwnProperty.call(backing, property)) {
|
|
229
|
+
return { enumerable: true, configurable: true, writable: true };
|
|
230
|
+
}
|
|
231
|
+
return undefined;
|
|
232
|
+
},
|
|
233
|
+
get(proxyTarget, property, receiver) {
|
|
234
|
+
if (property === PROPERTY_PROXY_STATE) {
|
|
235
|
+
return state;
|
|
236
|
+
}
|
|
237
|
+
if (property === EXPRESSION_BRAND) {
|
|
238
|
+
return createMemberAccessPathExpression(state.resource, state.steps, state.index);
|
|
239
|
+
}
|
|
240
|
+
if (property === Symbol.toPrimitive) {
|
|
241
|
+
return () => `[ResourceMember ${stepsToPath(state.steps).map(String).join(".")}]`;
|
|
242
|
+
}
|
|
243
|
+
if (typeof property !== "string") {
|
|
244
|
+
return Reflect.get(proxyTarget, property, receiver);
|
|
245
|
+
}
|
|
246
|
+
if (property === "toString") {
|
|
247
|
+
return () => `[ResourceMember ${stepsToPath(state.steps).map(String).join(".")}]`;
|
|
248
|
+
}
|
|
249
|
+
if (property === "valueOf") {
|
|
250
|
+
return () => createMemberAccessPathExpression(state.resource, state.steps, state.index);
|
|
251
|
+
}
|
|
252
|
+
if (property === "then") {
|
|
253
|
+
return undefined;
|
|
254
|
+
}
|
|
255
|
+
const currentValue = getValueAtPath(state.root, stepsToPath(state.steps));
|
|
256
|
+
const segment = toPropertySegment(property, state.nav, currentValue);
|
|
257
|
+
// Pass the value at the current position so a discriminated nav
|
|
258
|
+
// can select its variant (see `resolveModelShape`).
|
|
259
|
+
const step = navigateShape(state.nav, segment, currentValue);
|
|
260
|
+
const nextArmPath = step.stamp?.armPath;
|
|
261
|
+
const nextNav = step.next;
|
|
262
|
+
return createPropertyProxy({
|
|
263
|
+
...state,
|
|
264
|
+
steps: [...state.steps, { segment, armPath: nextArmPath }],
|
|
265
|
+
nav: nextNav,
|
|
266
|
+
});
|
|
267
|
+
},
|
|
268
|
+
set(_proxyTarget, property, value) {
|
|
269
|
+
if (typeof property !== "string") {
|
|
270
|
+
return false;
|
|
271
|
+
}
|
|
272
|
+
// A looped element (`parent.at(i)`) yields member proxies stamped with
|
|
273
|
+
// an index. Writing through one would mutate the shared for-loop body,
|
|
274
|
+
// which is not valid Bicep — `sym[i].prop = ...` cannot be expressed.
|
|
275
|
+
if (state.index !== undefined) {
|
|
276
|
+
throwLoopedElementWriteError();
|
|
277
|
+
}
|
|
278
|
+
setValueAtPath(state.root, [
|
|
279
|
+
...stepsToPath(state.steps),
|
|
280
|
+
toPropertySegment(property, state.nav, getValueAtPath(state.root, stepsToPath(state.steps))),
|
|
281
|
+
], normalizeAssignedValue(value, state.resource));
|
|
282
|
+
return true;
|
|
283
|
+
},
|
|
284
|
+
});
|
|
285
|
+
}
|
|
286
|
+
// ---------------------------------------------------------------------------
|
|
287
|
+
// Resource member proxy
|
|
288
|
+
// ---------------------------------------------------------------------------
|
|
289
|
+
function isNonEnumerableOwnProperty(target, property) {
|
|
290
|
+
const descriptor = Reflect.getOwnPropertyDescriptor(target, property);
|
|
291
|
+
return descriptor?.enumerable === false;
|
|
292
|
+
}
|
|
293
|
+
function hasOwnOrPrototypeProperty(target, property) {
|
|
294
|
+
let current = target;
|
|
295
|
+
while (current !== null) {
|
|
296
|
+
if (Object.prototype.hasOwnProperty.call(current, property)) {
|
|
297
|
+
return true;
|
|
298
|
+
}
|
|
299
|
+
current = Object.getPrototypeOf(current);
|
|
300
|
+
}
|
|
301
|
+
return false;
|
|
302
|
+
}
|
|
303
|
+
export function createResourceMemberProxy(source, path) {
|
|
304
|
+
// Seed nav from the resource's shape (if any). Walk the existing
|
|
305
|
+
// path, transitioning nav at each step so every segment is stamped
|
|
306
|
+
// correctly. Pre-existing callers pass paths they built manually, so
|
|
307
|
+
// we treat unknown navigations as passthrough.
|
|
308
|
+
const rootShape = getResourceShape(source.resource);
|
|
309
|
+
let nav = rootShape;
|
|
310
|
+
const steps = [];
|
|
311
|
+
for (const segment of path) {
|
|
312
|
+
const step = navigateShape(nav, segment, getValueAtPath(source.root, stepsToPath(steps)));
|
|
313
|
+
steps.push({ segment, armPath: step.stamp?.armPath });
|
|
314
|
+
nav = step.next;
|
|
315
|
+
}
|
|
316
|
+
return createPropertyProxy({
|
|
317
|
+
...source,
|
|
318
|
+
steps,
|
|
319
|
+
nav,
|
|
320
|
+
});
|
|
321
|
+
}
|
|
322
|
+
function getResourceShape(resource) {
|
|
323
|
+
// Look up by (armType, apiVersion), letting the registry resolve
|
|
324
|
+
// any discriminated variant from the instance's own state (typically
|
|
325
|
+
// the hardcoded `name` literal each variant class sets).
|
|
326
|
+
const state = resource[RAW_RESOURCE_HANDLE];
|
|
327
|
+
return getShape(resource.type, resource.apiVersion, state);
|
|
328
|
+
}
|
|
329
|
+
// ---------------------------------------------------------------------------
|
|
330
|
+
// Resource-level proxy
|
|
331
|
+
// ---------------------------------------------------------------------------
|
|
332
|
+
export function createResourceProxy(resource) {
|
|
333
|
+
function getBackingResourceData(target) {
|
|
334
|
+
return Reflect.get(target, RAW_RESOURCE_HANDLE);
|
|
335
|
+
}
|
|
336
|
+
const proxy = new Proxy(resource, {
|
|
337
|
+
ownKeys(target) {
|
|
338
|
+
return Array.from(new Set([
|
|
339
|
+
...Reflect.ownKeys(target),
|
|
340
|
+
...Reflect.ownKeys(getBackingResourceData(target)).filter((key) => key !== RAW_RESOURCE_HANDLE),
|
|
341
|
+
]));
|
|
342
|
+
},
|
|
343
|
+
getOwnPropertyDescriptor(target, property) {
|
|
344
|
+
const targetDescriptor = Reflect.getOwnPropertyDescriptor(target, property);
|
|
345
|
+
if (targetDescriptor !== undefined) {
|
|
346
|
+
return targetDescriptor;
|
|
347
|
+
}
|
|
348
|
+
const backing = getBackingResourceData(target);
|
|
349
|
+
if (Object.prototype.hasOwnProperty.call(backing, property)) {
|
|
350
|
+
return { enumerable: true, configurable: true, writable: true };
|
|
351
|
+
}
|
|
352
|
+
return undefined;
|
|
353
|
+
},
|
|
354
|
+
get(target, property, receiver) {
|
|
355
|
+
if (typeof property !== "string") {
|
|
356
|
+
return Reflect.get(target, property, receiver);
|
|
357
|
+
}
|
|
358
|
+
if (property === "then") {
|
|
359
|
+
return Reflect.get(target, property, receiver);
|
|
360
|
+
}
|
|
361
|
+
if (hasOwnOrPrototypeProperty(target, property) ||
|
|
362
|
+
isNonEnumerableOwnProperty(target, property)) {
|
|
363
|
+
return Reflect.get(target, property, receiver);
|
|
364
|
+
}
|
|
365
|
+
const rootState = unwrapResourceHandle(proxy);
|
|
366
|
+
const rootShape = getResourceShape(target);
|
|
367
|
+
const segment = toPropertySegment(property, rootShape, rootState);
|
|
368
|
+
const step = navigateShape(rootShape, segment, rootState);
|
|
369
|
+
const armPath = step.stamp?.armPath;
|
|
370
|
+
const nav = step.next;
|
|
371
|
+
return createPropertyProxy({
|
|
372
|
+
resource: proxy,
|
|
373
|
+
root: rootState,
|
|
374
|
+
steps: [{ segment, armPath }],
|
|
375
|
+
nav,
|
|
376
|
+
});
|
|
377
|
+
},
|
|
378
|
+
set(target, property, value, receiver) {
|
|
379
|
+
if (typeof property !== "string") {
|
|
380
|
+
return Reflect.set(target, property, value, receiver);
|
|
381
|
+
}
|
|
382
|
+
if (hasOwnOrPrototypeProperty(target, property) ||
|
|
383
|
+
isNonEnumerableOwnProperty(target, property)) {
|
|
384
|
+
return Reflect.set(target, property, value, receiver);
|
|
385
|
+
}
|
|
386
|
+
setValueAtPath(unwrapResourceHandle(proxy), [
|
|
387
|
+
toPropertySegment(property, getResourceShape(target), unwrapResourceHandle(proxy)),
|
|
388
|
+
], normalizeAssignedValue(value, proxy));
|
|
389
|
+
return true;
|
|
390
|
+
},
|
|
391
|
+
});
|
|
392
|
+
return proxy;
|
|
393
|
+
}
|
|
394
|
+
// ---------------------------------------------------------------------------
|
|
395
|
+
// Resource handle detection
|
|
396
|
+
// ---------------------------------------------------------------------------
|
|
397
|
+
function isResourceHandle(value) {
|
|
398
|
+
return (typeof value === "object" &&
|
|
399
|
+
value !== null &&
|
|
400
|
+
value[RESOURCE_BRAND] === true);
|
|
401
|
+
}
|
|
402
|
+
export function unwrapResourceHandle(resource) {
|
|
403
|
+
const maybeRaw = Reflect.get(resource, RAW_RESOURCE_HANDLE);
|
|
404
|
+
if (maybeRaw === undefined) {
|
|
405
|
+
return resource;
|
|
406
|
+
}
|
|
407
|
+
return maybeRaw;
|
|
408
|
+
}
|
|
409
|
+
function throwLoopedElementWriteError() {
|
|
410
|
+
throw new Error("Cannot assign to a property of a looped resource declaration. Individual loop iterations cannot be mutated. Set the property in the declaration passed to `fromLoop(loop, ...)`");
|
|
411
|
+
}
|
|
412
|
+
export function createIndexedResourceProxy(resource, index) {
|
|
413
|
+
const resourceIndexExpression = isExpression(index)
|
|
414
|
+
? unwrapExpression(index)
|
|
415
|
+
: index;
|
|
416
|
+
const root = unwrapResourceHandle(resource);
|
|
417
|
+
// A looped declaration (`LoopedResource`) exposes the concrete subclass
|
|
418
|
+
// ctor it wraps via `wrappedCtor`; its prototype carries the subclass's
|
|
419
|
+
// ARM accessors (`.sku`, `.properties.*`, `.id`, `.name`). The `get` trap
|
|
420
|
+
// below walks this prototype to resolve those reads rooted at
|
|
421
|
+
// `sym[index]`. A scalar `Resource` has no `wrappedCtor` — it already
|
|
422
|
+
// carries those accessors on its own prototype, so `subclassProto` stays
|
|
423
|
+
// `undefined` and lookups resolve via the target's own chain.
|
|
424
|
+
const subclassProto = resource.wrappedCtor?.prototype;
|
|
425
|
+
return new Proxy(resource, {
|
|
426
|
+
// Deliberately NO `getPrototypeOf` trap. Exposing the subclass
|
|
427
|
+
// prototype here would make `proxy instanceof Subclass` report `true`,
|
|
428
|
+
// invoking subclass getters/methods against the bare `LoopedResource`
|
|
429
|
+
// target (which lacks the subclass's own instance slots). Property
|
|
430
|
+
// reads and writes don't need it: the `get`/`set` traps below have
|
|
431
|
+
// their own `subclassProto` fallbacks that run accessors with
|
|
432
|
+
// `this = receiver` (the proxy) so `this.expr(...)` resolves against the
|
|
433
|
+
// indexed element.
|
|
434
|
+
get(target, property, receiver) {
|
|
435
|
+
// Reveal-only symbols consulted by the base `Resource` constructor
|
|
436
|
+
// and by serialization; both are marker keys with no runtime prototype
|
|
437
|
+
// representation on plain resources.
|
|
438
|
+
if (property === PROXY_INDEX_REF)
|
|
439
|
+
return resourceIndexExpression;
|
|
440
|
+
if (property === INDEXED_PROXY_TARGET)
|
|
441
|
+
return target;
|
|
442
|
+
// Intercept the single funnel for ARM reads. `this.expr(...path)` is
|
|
443
|
+
// the getter body used by every generated ARM property (`.name`,
|
|
444
|
+
// `.id`, `.properties.*`, etc.). Route it through
|
|
445
|
+
// `createResourceMemberProxy` with our `resourceIndexExpression` so
|
|
446
|
+
// the whole emitted expression roots at `sym[index]` instead of `sym`.
|
|
447
|
+
if (property === "expr") {
|
|
448
|
+
return function boundIndexedExpr(...path) {
|
|
449
|
+
return createResourceMemberProxy({
|
|
450
|
+
resource: target,
|
|
451
|
+
root,
|
|
452
|
+
index: resourceIndexExpression,
|
|
453
|
+
}, path);
|
|
454
|
+
};
|
|
455
|
+
}
|
|
456
|
+
// Block ARM property writes on a looped element. Every generated ARM
|
|
457
|
+
// setter (`set sku`, `set properties`, `set name`, …) funnels through
|
|
458
|
+
// `this.setProperty(...)`, so intercepting that single method turns
|
|
459
|
+
// `parent.at(i).sku = ...` into a clear error.
|
|
460
|
+
if (property === "setProperty") {
|
|
461
|
+
return throwLoopedElementWriteError;
|
|
462
|
+
}
|
|
463
|
+
// First try the target's own chain. Two subtleties:
|
|
464
|
+
//
|
|
465
|
+
// 1. Getters (`.type`, `.apiVersion`, `.children`, `.parent`, …) must
|
|
466
|
+
// run with `this = target` so they see the raw resource's own
|
|
467
|
+
// properties — including class private fields (`#…`). Passing the
|
|
468
|
+
// proxy as `receiver` would cause private-field access inside a
|
|
469
|
+
// getter to fail because the proxy has no such slot.
|
|
470
|
+
// 2. Subclass methods need `this = target` for the same reason — private
|
|
471
|
+
// fields again — so
|
|
472
|
+
// we return a bound wrapper. This means `ctx.method === ctx.method`
|
|
473
|
+
// yields `false` between reads; acceptable trade-off given no
|
|
474
|
+
// caller relies on function identity on an indexed proxy.
|
|
475
|
+
if (property in target) {
|
|
476
|
+
const value = Reflect.get(target, property, target);
|
|
477
|
+
return typeof value === "function" ? value.bind(target) : value;
|
|
478
|
+
}
|
|
479
|
+
// Fall through to `subclassProto` for subclass-specific getters
|
|
480
|
+
// (e.g. `.id`, `.name`, `.sku`) when wrapping a `LoopedResource`.
|
|
481
|
+
// Getters must run with `this = receiver` (the proxy) so their
|
|
482
|
+
// `this.expr(...)` calls hit our intercept above, yielding an
|
|
483
|
+
// expression rooted at `sym[index]`. Methods bind to `target` to
|
|
484
|
+
// stay consistent with the passthrough branch above.
|
|
485
|
+
if (subclassProto !== undefined) {
|
|
486
|
+
let proto = subclassProto;
|
|
487
|
+
while (proto !== null && proto !== Object.prototype) {
|
|
488
|
+
const descriptor = Object.getOwnPropertyDescriptor(proto, property);
|
|
489
|
+
if (descriptor !== undefined) {
|
|
490
|
+
if (descriptor.get !== undefined) {
|
|
491
|
+
return descriptor.get.call(receiver);
|
|
492
|
+
}
|
|
493
|
+
const value = descriptor.value;
|
|
494
|
+
return typeof value === "function" ? value.bind(target) : value;
|
|
495
|
+
}
|
|
496
|
+
proto = Object.getPrototypeOf(proto);
|
|
497
|
+
}
|
|
498
|
+
}
|
|
499
|
+
return undefined;
|
|
500
|
+
},
|
|
501
|
+
// Route writes to an ARM property setter with `this = receiver` (the
|
|
502
|
+
// proxy), allowing its `setProperty` call to hit the rejection above.
|
|
503
|
+
// Falls back to a plain write on the raw target.
|
|
504
|
+
set(target, property, value, receiver) {
|
|
505
|
+
if (subclassProto !== undefined) {
|
|
506
|
+
let proto = subclassProto;
|
|
507
|
+
while (proto !== null && proto !== Object.prototype) {
|
|
508
|
+
const descriptor = Object.getOwnPropertyDescriptor(proto, property);
|
|
509
|
+
if (descriptor !== undefined) {
|
|
510
|
+
if (descriptor.set !== undefined) {
|
|
511
|
+
descriptor.set.call(receiver, value);
|
|
512
|
+
return true;
|
|
513
|
+
}
|
|
514
|
+
break;
|
|
515
|
+
}
|
|
516
|
+
proto = Object.getPrototypeOf(proto);
|
|
517
|
+
}
|
|
518
|
+
}
|
|
519
|
+
return Reflect.set(target, property, value, target);
|
|
520
|
+
},
|
|
521
|
+
});
|
|
522
|
+
}
|
|
523
|
+
//# sourceMappingURL=resource-proxy.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"resource-proxy.js","sourceRoot":"","sources":["../../../src/constructs/resource/resource-proxy.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAElC,OAAO,EACL,gBAAgB,EAChB,YAAY,EACZ,gBAAgB,GAGjB,MAAM,iCAAiC,CAAC;AACzC,OAAO,EACL,oBAAoB,EACpB,yBAAyB,EACzB,wBAAwB,EACxB,gBAAgB,GAGjB,MAAM,+BAA+B,CAAC;AAOvC,OAAO,EACL,aAAa,GAGd,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EAAE,QAAQ,EAAE,MAAM,+BAA+B,CAAC;AAEzD,MAAM,CAAC,MAAM,mBAAmB,GAAG,MAAM,CAAC,qBAAqB,CAAC,CAAC;AACjE,MAAM,CAAC,MAAM,cAAc,GAAG,MAAM,CAAC,GAAG,CAAC,mCAAmC,CAAC,CAAC;AAE9E;;;;;;GAMG;AACH,MAAM,CAAC,MAAM,qBAAqB,GAAG,MAAM,CAAC,GAAG,CAC7C,yCAAyC,CAC1C,CAAC;AAEF;;;;;GAKG;AACH,MAAM,CAAC,MAAM,0BAA0B,GAAG,MAAM,CAAC,GAAG,CAClD,8CAA8C,CAC/C,CAAC;AAE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iDAAiD;QACjD,GAAG,CAAC,MAAM,EAAE,QAAQ,EAAE,KAAK,EAAE,QAAQ;YACnC,IAAI,aAAa,KAAK,SAAS,EAAE,CAAC;gBAChC,IAAI,KAAK,GAAkB,aAAa,CAAC;gBACzC,OAAO,KAAK,KAAK,IAAI,IAAI,KAAK,KAAK,MAAM,CAAC,SAAS,EAAE,CAAC;oBACpD,MAAM,UAAU,GAAG,MAAM,CAAC,wBAAwB,CAAC,KAAK,EAAE,QAAQ,CAAC,CAAC;oBACpE,IAAI,UAAU,KAAK,SAAS,EAAE,CAAC;wBAC7B,IAAI,UAAU,CAAC,GAAG,KAAK,SAAS,EAAE,CAAC;4BACjC,UAAU,CAAC,GAAG,CAAC,IAAI,CAAC,QAAQ,EAAE,KAAK,CAAC,CAAC;4BACrC,OAAO,IAAI,CAAC;wBACd,CAAC;wBACD,MAAM;oBACR,CAAC;oBACD,KAAK,GAAG,MAAM,CAAC,cAAc,CAAC,KAAK,CAAC,CAAC;gBACvC,CAAC;YACH,CAAC;YACD,OAAO,OAAO,CAAC,GAAG,CAAC,MAAM,EAAE,QAAQ,EAAE,KAAK,EAAE,MAAM,CAAC,CAAC;QACtD,CAAC;KACF,CAAsB,CAAC;AAC1B,CAAC"}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import type { ProvisioningComponent } from "../provisioning-component.js";
|
|
2
|
+
import type { LoopedResource, Resource } from "./resource.js";
|
|
3
|
+
import type { ResourceCtor } from "./resource-registry.js";
|
|
4
|
+
/** Options accepted by the `Stack` resource queries. */
|
|
5
|
+
export interface QueryOptions {
|
|
6
|
+
/**
|
|
7
|
+
* Whether to walk the stack's entire subtree (default `true`) or only its
|
|
8
|
+
* **direct children** (`false`).
|
|
9
|
+
*/
|
|
10
|
+
readonly recursive?: boolean;
|
|
11
|
+
}
|
|
12
|
+
/** Scalar (un-looped) resource declarations. */
|
|
13
|
+
export declare function getResources(root: ProvisioningComponent, typeOrOptions?: ResourceCtor<Resource> | QueryOptions, maybeOptions?: QueryOptions): Resource[];
|
|
14
|
+
/** Loop-expanded resource declarations (`Ctor.fromLoop(...)`). */
|
|
15
|
+
export declare function getLoopedResources(root: ProvisioningComponent, typeOrOptions?: ResourceCtor<Resource> | QueryOptions, maybeOptions?: QueryOptions): LoopedResource<Resource>[];
|
|
16
|
+
/**
|
|
17
|
+
* First scalar resource of `type` whose literal name equals `name`, or
|
|
18
|
+
* `undefined`. `deref` resolves the name's expression proxy to its literal
|
|
19
|
+
* (a `Resource`'s `name` is an `Expression`, so `r.name === name` is always
|
|
20
|
+
* false without it).
|
|
21
|
+
*/
|
|
22
|
+
export declare function getResource<T extends Resource>(root: ProvisioningComponent, type: ResourceCtor<T>, name: string, options?: QueryOptions): T | undefined;
|
|
23
|
+
//# sourceMappingURL=resource-query.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"resource-query.d.ts","sourceRoot":"","sources":["../../../src/constructs/resource/resource-query.ts"],"names":[],"mappings":"AASA,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,8BAA8B,CAAC;AAC1E,OAAO,KAAK,EAAE,cAAc,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AAC9D,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,wBAAwB,CAAC;AAM3D,wDAAwD;AACxD,MAAM,WAAW,YAAY;IAC3B;;;OAGG;IACH,QAAQ,CAAC,SAAS,CAAC,EAAE,OAAO,CAAC;CAC9B;AAsCD,gDAAgD;AAChD,wBAAgB,YAAY,CAC1B,IAAI,EAAE,qBAAqB,EAC3B,aAAa,CAAC,EAAE,YAAY,CAAC,QAAQ,CAAC,GAAG,YAAY,EACrD,YAAY,CAAC,EAAE,YAAY,GAC1B,QAAQ,EAAE,CASZ;AAED,kEAAkE;AAClE,wBAAgB,kBAAkB,CAChC,IAAI,EAAE,qBAAqB,EAC3B,aAAa,CAAC,EAAE,YAAY,CAAC,QAAQ,CAAC,GAAG,YAAY,EACrD,YAAY,CAAC,EAAE,YAAY,GAC1B,cAAc,CAAC,QAAQ,CAAC,EAAE,CAe5B;AAED;;;;;GAKG;AACH,wBAAgB,WAAW,CAAC,CAAC,SAAS,QAAQ,EAC5C,IAAI,EAAE,qBAAqB,EAC3B,IAAI,EAAE,YAAY,CAAC,CAAC,CAAC,EACrB,IAAI,EAAE,MAAM,EACZ,OAAO,CAAC,EAAE,YAAY,GACrB,CAAC,GAAG,SAAS,CAKf"}
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
// Copyright (c) Microsoft Corporation.
|
|
2
|
+
// Licensed under the MIT License.
|
|
3
|
+
import { isResourceDeclaration, isLoopedResource, isLoopedResourceOf, } from "./resource-utils.js";
|
|
4
|
+
import { deref } from "./resource-proxy.js";
|
|
5
|
+
// ---------------------------------------------------------------------------
|
|
6
|
+
// Query engine (module-private)
|
|
7
|
+
// ---------------------------------------------------------------------------
|
|
8
|
+
// Imports only brand guards (`resource-utils`) — which do not import
|
|
9
|
+
// `ProvisioningComponent`/`Stack` at runtime — plus types (type-only), so there is no
|
|
10
|
+
// import cycle.
|
|
11
|
+
/**
|
|
12
|
+
* Collect the resource declarations beneath `root` (the root itself is never
|
|
13
|
+
* included). `recursive` descends the whole subtree via `visit`; otherwise
|
|
14
|
+
* only `root`'s direct children are considered. `wantLooped` selects the
|
|
15
|
+
* looped declarations (`Ctor.fromLoop(...)`) vs. the scalar ones.
|
|
16
|
+
*/
|
|
17
|
+
function collectResourcesUnder(root, wantLooped, recursive) {
|
|
18
|
+
const result = [];
|
|
19
|
+
const consider = (node) => {
|
|
20
|
+
if (!isResourceDeclaration(node))
|
|
21
|
+
return;
|
|
22
|
+
const r = node.self;
|
|
23
|
+
if (isLoopedResource(r) === wantLooped)
|
|
24
|
+
result.push(r);
|
|
25
|
+
};
|
|
26
|
+
for (const child of root.children) {
|
|
27
|
+
if (recursive)
|
|
28
|
+
child.visit(consider);
|
|
29
|
+
else
|
|
30
|
+
consider(child);
|
|
31
|
+
}
|
|
32
|
+
return result;
|
|
33
|
+
}
|
|
34
|
+
// ---------------------------------------------------------------------------
|
|
35
|
+
// Engine entry points — thin, loosely-typed; `Stack` supplies the public
|
|
36
|
+
// typed overloads and delegates here.
|
|
37
|
+
// ---------------------------------------------------------------------------
|
|
38
|
+
/** Scalar (un-looped) resource declarations. */
|
|
39
|
+
export function getResources(root, typeOrOptions, maybeOptions) {
|
|
40
|
+
const isCtor = typeof typeOrOptions === "function";
|
|
41
|
+
const type = isCtor ? typeOrOptions : undefined;
|
|
42
|
+
const options = (isCtor ? maybeOptions : typeOrOptions);
|
|
43
|
+
const recursive = options?.recursive ?? true;
|
|
44
|
+
const found = collectResourcesUnder(root, false, recursive);
|
|
45
|
+
return type === undefined ? found : found.filter((r) => r instanceof type);
|
|
46
|
+
}
|
|
47
|
+
/** Loop-expanded resource declarations (`Ctor.fromLoop(...)`). */
|
|
48
|
+
export function getLoopedResources(root, typeOrOptions, maybeOptions) {
|
|
49
|
+
const isCtor = typeof typeOrOptions === "function";
|
|
50
|
+
const type = isCtor ? typeOrOptions : undefined;
|
|
51
|
+
const options = (isCtor ? maybeOptions : typeOrOptions);
|
|
52
|
+
const recursive = options?.recursive ?? true;
|
|
53
|
+
const found = collectResourcesUnder(root, true, recursive);
|
|
54
|
+
return type === undefined
|
|
55
|
+
? found
|
|
56
|
+
: found.filter((r) => isLoopedResourceOf(r, type));
|
|
57
|
+
}
|
|
58
|
+
/**
|
|
59
|
+
* First scalar resource of `type` whose literal name equals `name`, or
|
|
60
|
+
* `undefined`. `deref` resolves the name's expression proxy to its literal
|
|
61
|
+
* (a `Resource`'s `name` is an `Expression`, so `r.name === name` is always
|
|
62
|
+
* false without it).
|
|
63
|
+
*/
|
|
64
|
+
export function getResource(root, type, name, options) {
|
|
65
|
+
for (const r of getResources(root, type, options)) {
|
|
66
|
+
if (deref(r.name) === name)
|
|
67
|
+
return r;
|
|
68
|
+
}
|
|
69
|
+
return undefined;
|
|
70
|
+
}
|
|
71
|
+
//# sourceMappingURL=resource-query.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"resource-query.js","sourceRoot":"","sources":["../../../src/constructs/resource/resource-query.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAElC,OAAO,EACL,qBAAqB,EACrB,gBAAgB,EAChB,kBAAkB,GACnB,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EAAE,KAAK,EAAE,MAAM,qBAAqB,CAAC;AAkB5C,8EAA8E;AAC9E,gCAAgC;AAChC,8EAA8E;AAC9E,qEAAqE;AACrE,sFAAsF;AACtF,gBAAgB;AAEhB;;;;;GAKG;AACH,SAAS,qBAAqB,CAC5B,IAA2B,EAC3B,UAAmB,EACnB,SAAkB;IAElB,MAAM,MAAM,GAA4C,EAAE,CAAC;IAC3D,MAAM,QAAQ,GAAG,CAAC,IAA2B,EAAQ,EAAE;QACrD,IAAI,CAAC,qBAAqB,CAAC,IAAI,CAAC;YAAE,OAAO;QACzC,MAAM,CAAC,GAAG,IAAI,CAAC,IAA2C,CAAC;QAC3D,IAAI,gBAAgB,CAAC,CAAC,CAAC,KAAK,UAAU;YAAE,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;IACzD,CAAC,CAAC;IACF,KAAK,MAAM,KAAK,IAAI,IAAI,CAAC,QAAQ,EAAE,CAAC;QAClC,IAAI,SAAS;YAAE,KAAK,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAC;;YAChC,QAAQ,CAAC,KAAK,CAAC,CAAC;IACvB,CAAC;IACD,OAAO,MAAM,CAAC;AAChB,CAAC;AAED,8EAA8E;AAC9E,yEAAyE;AACzE,sCAAsC;AACtC,8EAA8E;AAE9E,gDAAgD;AAChD,MAAM,UAAU,YAAY,CAC1B,IAA2B,EAC3B,aAAqD,EACrD,YAA2B;IAE3B,MAAM,MAAM,GAAG,OAAO,aAAa,KAAK,UAAU,CAAC;IACnD,MAAM,IAAI,GAAG,MAAM,CAAC,CAAC,CAAE,aA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