@highstate/pulumi 0.19.1 → 0.21.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/dist/index.js +279 -149
- package/package.json +13 -13
- package/src/entity.ts +108 -0
- package/src/file.ts +87 -49
- package/src/index.ts +2 -0
- package/src/resource-hooks.ts +14 -0
- package/src/unit.ts +150 -110
- package/LICENSE +0 -21
- package/dist/index.js.map +0 -1
package/dist/index.js
CHANGED
|
@@ -1,40 +1,16 @@
|
|
|
1
|
-
|
|
2
|
-
export * from '@pulumi/pulumi';
|
|
3
|
-
import { pathToFileURL } from 'node:url';
|
|
4
|
-
import { HighstateConfigKey, unitConfigSchema, z, parseArgumentValue, runtimeSchema, parseInstanceId, compact, camelCaseToHumanReadable, unitArtifactSchema, decompact } from '@highstate/contract';
|
|
5
|
-
import { mapValues } from 'remeda';
|
|
6
|
-
|
|
1
|
+
// @bun
|
|
7
2
|
// src/index.ts
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
}
|
|
20
|
-
});
|
|
21
|
-
}
|
|
22
|
-
function fileFromBuffer(name, content, { contentType = "application/octet-stream", isSecret = false, mode } = {}) {
|
|
23
|
-
const base64Content = content.toString("base64");
|
|
24
|
-
return output({
|
|
25
|
-
meta: {
|
|
26
|
-
name,
|
|
27
|
-
contentType,
|
|
28
|
-
size: output(content).apply((content2) => content2.byteLength),
|
|
29
|
-
mode
|
|
30
|
-
},
|
|
31
|
-
content: {
|
|
32
|
-
type: "embedded",
|
|
33
|
-
isBinary: true,
|
|
34
|
-
value: isSecret ? secret(base64Content) : base64Content
|
|
35
|
-
}
|
|
36
|
-
});
|
|
37
|
-
}
|
|
3
|
+
export * from "@pulumi/pulumi";
|
|
4
|
+
|
|
5
|
+
// src/entity.ts
|
|
6
|
+
import {
|
|
7
|
+
getEntityId,
|
|
8
|
+
HighstateSignature
|
|
9
|
+
} from "@highstate/contract";
|
|
10
|
+
import { output as output2 } from "@pulumi/pulumi";
|
|
11
|
+
|
|
12
|
+
// src/utils.ts
|
|
13
|
+
import { output } from "@pulumi/pulumi";
|
|
38
14
|
function toPromise(input) {
|
|
39
15
|
return new Promise((resolve) => output(input).apply(resolve));
|
|
40
16
|
}
|
|
@@ -57,9 +33,128 @@ function apply(fn) {
|
|
|
57
33
|
return (input) => output(input).apply(fn);
|
|
58
34
|
}
|
|
59
35
|
|
|
36
|
+
// src/entity.ts
|
|
37
|
+
function makeEntity({
|
|
38
|
+
entity,
|
|
39
|
+
identity,
|
|
40
|
+
meta,
|
|
41
|
+
value
|
|
42
|
+
}) {
|
|
43
|
+
const built = {
|
|
44
|
+
...value,
|
|
45
|
+
$meta: {
|
|
46
|
+
type: entity.type,
|
|
47
|
+
identity,
|
|
48
|
+
...meta
|
|
49
|
+
}
|
|
50
|
+
};
|
|
51
|
+
return entity.schema.parse(built);
|
|
52
|
+
}
|
|
53
|
+
function makeSecret(value) {
|
|
54
|
+
return {
|
|
55
|
+
[HighstateSignature.Secret]: true,
|
|
56
|
+
value
|
|
57
|
+
};
|
|
58
|
+
}
|
|
59
|
+
function makeSecretOutput(value) {
|
|
60
|
+
return output2(value).apply(makeSecret);
|
|
61
|
+
}
|
|
62
|
+
function makeSecretAsync(value) {
|
|
63
|
+
return toPromise(makeSecretOutput(value));
|
|
64
|
+
}
|
|
65
|
+
function makeEntityOutput({
|
|
66
|
+
entity,
|
|
67
|
+
identity,
|
|
68
|
+
meta,
|
|
69
|
+
value
|
|
70
|
+
}) {
|
|
71
|
+
return output2({
|
|
72
|
+
...value,
|
|
73
|
+
$meta: {
|
|
74
|
+
type: entity.type,
|
|
75
|
+
identity,
|
|
76
|
+
...meta
|
|
77
|
+
}
|
|
78
|
+
}).apply((built) => entity.schema.parse(built));
|
|
79
|
+
}
|
|
80
|
+
function makeEntityAsync(options) {
|
|
81
|
+
return toPromise(makeEntityOutput(options));
|
|
82
|
+
}
|
|
83
|
+
function getCombinedIdentity(entities) {
|
|
84
|
+
const sortedIds = entities.map((source) => typeof source === "string" ? source : getEntityId(source)).sort();
|
|
85
|
+
return sortedIds.join(":");
|
|
86
|
+
}
|
|
87
|
+
function getCombinedIdentityOutput(entities) {
|
|
88
|
+
return output2(entities).apply(getCombinedIdentity);
|
|
89
|
+
}
|
|
90
|
+
function getCombinedIdentityAsync(entities) {
|
|
91
|
+
return toPromise(getCombinedIdentityOutput(entities));
|
|
92
|
+
}
|
|
93
|
+
// src/file.ts
|
|
94
|
+
import { crc32 } from "zlib";
|
|
95
|
+
import { output as output3 } from "@pulumi/pulumi";
|
|
96
|
+
function makeFile({
|
|
97
|
+
name,
|
|
98
|
+
content,
|
|
99
|
+
contentType,
|
|
100
|
+
identity,
|
|
101
|
+
isSecret,
|
|
102
|
+
mode
|
|
103
|
+
}) {
|
|
104
|
+
const stringContent = typeof content === "string" ? content : content.toString("base64");
|
|
105
|
+
const isBinary = typeof content !== "string";
|
|
106
|
+
const inferredContentType = contentType ?? (typeof content === "string" ? "text/plain" : "application/octet-stream");
|
|
107
|
+
const size = typeof content === "string" ? Buffer.byteLength(content, "utf-8") : content.byteLength;
|
|
108
|
+
return {
|
|
109
|
+
$meta: {
|
|
110
|
+
type: "common.file.v1",
|
|
111
|
+
identity: identity ?? crc32(stringContent).toString(16)
|
|
112
|
+
},
|
|
113
|
+
meta: {
|
|
114
|
+
name,
|
|
115
|
+
contentType: inferredContentType,
|
|
116
|
+
size,
|
|
117
|
+
mode
|
|
118
|
+
},
|
|
119
|
+
content: isSecret ? { type: "embedded-secret", value: makeSecret(stringContent), isBinary } : { type: "embedded", value: stringContent, isBinary }
|
|
120
|
+
};
|
|
121
|
+
}
|
|
122
|
+
function makeFileOutput(options) {
|
|
123
|
+
return output3(options).apply((opts) => makeFile(opts));
|
|
124
|
+
}
|
|
125
|
+
function makeFileAsync(options) {
|
|
126
|
+
return toPromise(makeFileOutput(options));
|
|
127
|
+
}
|
|
128
|
+
// src/resource-hooks.ts
|
|
129
|
+
var hasResourceHooks = false;
|
|
130
|
+
function setResourceHooks() {
|
|
131
|
+
hasResourceHooks = true;
|
|
132
|
+
}
|
|
133
|
+
function getHasResourceHooks() {
|
|
134
|
+
return hasResourceHooks;
|
|
135
|
+
}
|
|
60
136
|
// src/unit.ts
|
|
61
|
-
|
|
137
|
+
import { join } from "path";
|
|
138
|
+
import { pathToFileURL } from "url";
|
|
139
|
+
import {
|
|
140
|
+
camelCaseToHumanReadable,
|
|
141
|
+
HighstateConfigKey,
|
|
142
|
+
HighstateSignature as HighstateSignature2,
|
|
143
|
+
parseArgumentValue,
|
|
144
|
+
parseInstanceId,
|
|
145
|
+
runtimeSchema,
|
|
146
|
+
unitArtifactSchema,
|
|
147
|
+
unitConfigSchema,
|
|
148
|
+
z
|
|
149
|
+
} from "@highstate/contract";
|
|
150
|
+
import {
|
|
151
|
+
Config,
|
|
152
|
+
output as output4,
|
|
153
|
+
secret as pulumiSecret
|
|
154
|
+
} from "@pulumi/pulumi";
|
|
155
|
+
import { isPlainObject, mapValues } from "remeda";
|
|
62
156
|
var instanceId;
|
|
157
|
+
var stateId;
|
|
63
158
|
var instanceName;
|
|
64
159
|
var importBaseUrl;
|
|
65
160
|
function getUnitInstanceId() {
|
|
@@ -68,6 +163,12 @@ function getUnitInstanceId() {
|
|
|
68
163
|
}
|
|
69
164
|
return instanceId;
|
|
70
165
|
}
|
|
166
|
+
function getUnitStateId() {
|
|
167
|
+
if (!stateId) {
|
|
168
|
+
throw new Error(`State id is not set. Did you call "forUnit" function?`);
|
|
169
|
+
}
|
|
170
|
+
return stateId;
|
|
171
|
+
}
|
|
71
172
|
function getUnitInstanceName() {
|
|
72
173
|
if (!instanceName) {
|
|
73
174
|
throw new Error(`Instance name is not set. Did you call "forUnit" function?`);
|
|
@@ -81,65 +182,34 @@ function getImportBaseUrl() {
|
|
|
81
182
|
return importBaseUrl;
|
|
82
183
|
}
|
|
83
184
|
function getResourceComment() {
|
|
84
|
-
return `Managed by Highstate
|
|
185
|
+
return `Managed by Highstate [${getUnitStateId()}]`;
|
|
85
186
|
}
|
|
86
|
-
function
|
|
87
|
-
const [instanceType] = parseInstanceId(input.instanceId);
|
|
88
|
-
const stateId = config.stateIdMap[input.instanceId];
|
|
89
|
-
if (!stateId) {
|
|
90
|
-
throw new Error(`State ID for instance "${input.instanceId}" not found in the unit config.`);
|
|
91
|
-
}
|
|
92
|
-
const key = `organization/${instanceType}/${stateId}`;
|
|
93
|
-
let stackRef = stackRefMap.get(key);
|
|
94
|
-
if (!stackRef) {
|
|
95
|
-
stackRef = new StackReference(key);
|
|
96
|
-
stackRefMap.set(key, stackRef);
|
|
97
|
-
}
|
|
98
|
-
return stackRef;
|
|
99
|
-
}
|
|
100
|
-
function getOutput(config, unit, inputName, input, refs) {
|
|
187
|
+
function getInputValue(unit, inputName, input, entries) {
|
|
101
188
|
const entity = unit.entities.get(input.type);
|
|
102
189
|
if (!entity) {
|
|
103
190
|
throw new Error(`Entity "${input.type}" not found in the unit "${unit.model.type}".`);
|
|
104
191
|
}
|
|
105
|
-
const
|
|
106
|
-
const value =
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
const result = schema.safeParse(value2);
|
|
118
|
-
if (!result.success) {
|
|
119
|
-
throw new Error(
|
|
120
|
-
`Invalid output "${ref.output}" from "${ref.instanceId}" for input "${inputName}": ${result.error.message}`
|
|
121
|
-
);
|
|
122
|
-
}
|
|
123
|
-
if (Array.isArray(value2)) {
|
|
124
|
-
return value2;
|
|
125
|
-
}
|
|
126
|
-
return input.multiple ? [value2] : value2;
|
|
127
|
-
});
|
|
128
|
-
};
|
|
129
|
-
const _getDecompactedOutput = (ref) => {
|
|
130
|
-
return _getOutput(ref).apply(decompact);
|
|
131
|
-
};
|
|
132
|
-
const values = output(refs.map(_getDecompactedOutput)).apply((values2) => values2.flat());
|
|
192
|
+
const values = entries.flatMap((entry) => {
|
|
193
|
+
const value = parseArgumentValue(entry.value);
|
|
194
|
+
const schema = Array.isArray(value) ? entity.schema.array() : entity.schema;
|
|
195
|
+
const result = schema.safeParse(value);
|
|
196
|
+
if (!result.success) {
|
|
197
|
+
throw new Error(`Invalid value for input "${inputName}": ${z.prettifyError(result.error)}`);
|
|
198
|
+
}
|
|
199
|
+
if (Array.isArray(result.data)) {
|
|
200
|
+
return result.data;
|
|
201
|
+
}
|
|
202
|
+
return input.multiple ? [result.data] : [result.data];
|
|
203
|
+
});
|
|
133
204
|
if (!input.multiple) {
|
|
134
|
-
return values
|
|
205
|
+
return values[0];
|
|
135
206
|
}
|
|
136
207
|
return values;
|
|
137
208
|
}
|
|
138
209
|
function forUnit(unit) {
|
|
139
|
-
const config = new Config
|
|
210
|
+
const config = new Config;
|
|
140
211
|
const rawHSConfig = config.requireObject(HighstateConfigKey.Config);
|
|
141
212
|
const hsConfig = unitConfigSchema.parse(rawHSConfig);
|
|
142
|
-
const rawHsSecrets = config.requireSecretObject(HighstateConfigKey.Secrets).apply((secrets2) => z.record(z.string(), z.unknown()).parse(secrets2));
|
|
143
213
|
const args = mapValues(unit.model.args, (arg, argName) => {
|
|
144
214
|
const value = parseArgumentValue(hsConfig.args[argName]);
|
|
145
215
|
const result = arg[runtimeSchema].safeParse(value);
|
|
@@ -148,99 +218,93 @@ function forUnit(unit) {
|
|
|
148
218
|
}
|
|
149
219
|
return result.data;
|
|
150
220
|
});
|
|
151
|
-
const secrets = mapValues(unit.model.secrets, (
|
|
152
|
-
const hasValue = hsConfig.
|
|
153
|
-
if (!hasValue && !
|
|
154
|
-
return
|
|
221
|
+
const secrets = mapValues(unit.model.secrets, (secret, secretName) => {
|
|
222
|
+
const hasValue = secretName in hsConfig.secretValues;
|
|
223
|
+
if (!hasValue && !secret.required) {
|
|
224
|
+
return secret.schema.default ? pulumiSecret(secret.schema.default) : undefined;
|
|
155
225
|
}
|
|
156
|
-
if (!hasValue &&
|
|
226
|
+
if (!hasValue && secret.required) {
|
|
157
227
|
throw new Error(`Secret "${secretName}" is required but not provided.`);
|
|
158
228
|
}
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
});
|
|
229
|
+
const rawValue = hsConfig.secretValues[secretName];
|
|
230
|
+
const value = parseArgumentValue(rawValue);
|
|
231
|
+
const result = secret[runtimeSchema].safeParse(value);
|
|
232
|
+
if (!result.success) {
|
|
233
|
+
throw new Error(`Invalid secret "${secretName}": ${z.prettifyError(result.error)}`);
|
|
234
|
+
}
|
|
235
|
+
return pulumiSecret(result.data);
|
|
167
236
|
});
|
|
168
237
|
const inputs = mapValues(unit.model.inputs, (input, inputName) => {
|
|
169
238
|
const value = hsConfig.inputs[inputName];
|
|
170
239
|
if (!value) {
|
|
171
240
|
if (input.multiple) {
|
|
172
|
-
return
|
|
241
|
+
return [];
|
|
173
242
|
}
|
|
174
|
-
return
|
|
243
|
+
return;
|
|
175
244
|
}
|
|
176
|
-
return
|
|
245
|
+
return getInputValue(unit, inputName, input, value);
|
|
177
246
|
});
|
|
178
247
|
const [type, name] = parseInstanceId(hsConfig.instanceId);
|
|
179
248
|
instanceId = hsConfig.instanceId;
|
|
249
|
+
stateId = hsConfig.stateId;
|
|
180
250
|
instanceName = name;
|
|
181
251
|
importBaseUrl = pathToFileURL(hsConfig.importBasePath);
|
|
182
252
|
return {
|
|
183
253
|
instanceId: hsConfig.instanceId,
|
|
254
|
+
stateId: hsConfig.stateId,
|
|
184
255
|
type,
|
|
185
256
|
name,
|
|
186
257
|
args,
|
|
187
258
|
secrets,
|
|
188
259
|
inputs,
|
|
189
260
|
invokedTriggers: hsConfig.invokedTriggers,
|
|
190
|
-
getSecret: (
|
|
261
|
+
getSecret: (name2, factory) => {
|
|
191
262
|
if (!factory) {
|
|
192
263
|
return secrets[name2];
|
|
193
264
|
}
|
|
194
|
-
const value = secrets[name2] ??
|
|
265
|
+
const value = secrets[name2] ?? pulumiSecret(factory());
|
|
195
266
|
secrets[name2] = value;
|
|
196
267
|
return value;
|
|
197
|
-
}
|
|
268
|
+
},
|
|
269
|
+
setSecret: (name2, value) => {
|
|
270
|
+
secrets[name2] = pulumiSecret(value);
|
|
271
|
+
},
|
|
198
272
|
outputs: async (outputs = {}) => {
|
|
199
|
-
const
|
|
273
|
+
const resolvedOutputs = await toPromise(outputs);
|
|
274
|
+
const result = mapValues(resolvedOutputs, (outputValue, outputName) => {
|
|
200
275
|
if (outputName === "$statusFields") {
|
|
201
|
-
return
|
|
276
|
+
return mapStatusFields(outputValue);
|
|
202
277
|
}
|
|
203
278
|
if (outputName === "$pages") {
|
|
204
|
-
return
|
|
279
|
+
return mapPages(outputValue);
|
|
205
280
|
}
|
|
206
281
|
if (outputName === "$terminals") {
|
|
207
|
-
return
|
|
282
|
+
return mapTerminals(outputValue);
|
|
208
283
|
}
|
|
209
284
|
if (outputName === "$triggers") {
|
|
210
|
-
return
|
|
285
|
+
return mapTriggers(outputValue);
|
|
211
286
|
}
|
|
212
287
|
if (outputName === "$workers") {
|
|
213
|
-
return
|
|
288
|
+
return mapWorkers(outputValue);
|
|
214
289
|
}
|
|
215
290
|
if (outputName.startsWith("$")) {
|
|
216
291
|
throw new Error(`Unknown extra output "${outputName}".`);
|
|
217
292
|
}
|
|
218
293
|
const outputModel = unit.model.outputs[outputName];
|
|
219
294
|
if (!outputModel) {
|
|
220
|
-
throw new Error(
|
|
221
|
-
`Output "${outputName}" not found in the unit "${unit.model.type}", but was passed to outputs(...).`
|
|
222
|
-
);
|
|
295
|
+
throw new Error(`Output "${outputName}" not found in the unit "${unit.model.type}", but was passed to outputs(...).`);
|
|
223
296
|
}
|
|
224
297
|
const entity = unit.entities.get(outputModel.type);
|
|
225
298
|
if (!entity) {
|
|
226
|
-
throw new Error(
|
|
227
|
-
|
|
228
|
-
|
|
299
|
+
throw new Error(`Entity "${outputModel.type}" not found in the unit "${unit.model.type}". It looks like a bug in the unit definition.`);
|
|
300
|
+
}
|
|
301
|
+
const schema = outputModel.multiple ? entity.schema.array() : entity.schema;
|
|
302
|
+
const result2 = schema.safeParse(outputValue);
|
|
303
|
+
if (!result2.success) {
|
|
304
|
+
throw new Error(`Invalid value for output "${outputName}" of type "${outputModel.type}": ${z.prettifyError(result2.error)}`);
|
|
229
305
|
}
|
|
230
|
-
return
|
|
231
|
-
const schema = outputModel.multiple ? entity.schema.array() : entity.schema;
|
|
232
|
-
const result2 = schema.safeParse(value);
|
|
233
|
-
if (!result2.success) {
|
|
234
|
-
throw new Error(
|
|
235
|
-
`Invalid value for output "${outputName}" of type "${outputModel.type}": ${z.prettifyError(
|
|
236
|
-
result2.error
|
|
237
|
-
)}`
|
|
238
|
-
);
|
|
239
|
-
}
|
|
240
|
-
return compact(result2.data);
|
|
241
|
-
});
|
|
306
|
+
return result2.data;
|
|
242
307
|
});
|
|
243
|
-
await Promise.all(Object.values(result).map((o) => toPromise(o)));
|
|
244
308
|
result.$secrets = secrets;
|
|
245
309
|
const artifactsMap = {};
|
|
246
310
|
for (const [outputName, outputValue] of Object.entries(outputs)) {
|
|
@@ -253,16 +317,55 @@ function forUnit(unit) {
|
|
|
253
317
|
if (Object.keys(artifactsMap).length > 0) {
|
|
254
318
|
result.$artifacts = artifactsMap;
|
|
255
319
|
}
|
|
256
|
-
|
|
320
|
+
result.$hasResourceHooks = getHasResourceHooks();
|
|
321
|
+
return wrapHighstateSecretValues(result);
|
|
257
322
|
}
|
|
258
323
|
};
|
|
259
324
|
}
|
|
325
|
+
function wrapHighstateSecretValues(data) {
|
|
326
|
+
const cache = new WeakMap;
|
|
327
|
+
const traverse = (value) => {
|
|
328
|
+
if (value === null || value === undefined || typeof value !== "object") {
|
|
329
|
+
return value;
|
|
330
|
+
}
|
|
331
|
+
if (Array.isArray(value)) {
|
|
332
|
+
const cached2 = cache.get(value);
|
|
333
|
+
if (cached2) {
|
|
334
|
+
return cached2;
|
|
335
|
+
}
|
|
336
|
+
const mapped2 = [];
|
|
337
|
+
cache.set(value, mapped2);
|
|
338
|
+
for (const item of value) {
|
|
339
|
+
mapped2.push(traverse(item));
|
|
340
|
+
}
|
|
341
|
+
return mapped2;
|
|
342
|
+
}
|
|
343
|
+
if (!isPlainObject(value)) {
|
|
344
|
+
return value;
|
|
345
|
+
}
|
|
346
|
+
const cached = cache.get(value);
|
|
347
|
+
if (cached) {
|
|
348
|
+
return cached;
|
|
349
|
+
}
|
|
350
|
+
const record = value;
|
|
351
|
+
const mapped = {};
|
|
352
|
+
cache.set(value, mapped);
|
|
353
|
+
for (const [key, nestedValue] of Object.entries(record)) {
|
|
354
|
+
mapped[key] = traverse(nestedValue);
|
|
355
|
+
}
|
|
356
|
+
if (record[HighstateSignature2.Secret] === true && "value" in record) {
|
|
357
|
+
return pulumiSecret(mapped);
|
|
358
|
+
}
|
|
359
|
+
return mapped;
|
|
360
|
+
};
|
|
361
|
+
return traverse(data);
|
|
362
|
+
}
|
|
260
363
|
function mapStatusFields(status) {
|
|
261
364
|
if (!status) {
|
|
262
365
|
return [];
|
|
263
366
|
}
|
|
264
367
|
if (Array.isArray(status)) {
|
|
265
|
-
return status.filter((field) => field?.value !==
|
|
368
|
+
return status.filter((field) => field?.value !== undefined).map((field) => {
|
|
266
369
|
return {
|
|
267
370
|
name: field.name,
|
|
268
371
|
meta: {
|
|
@@ -274,7 +377,7 @@ function mapStatusFields(status) {
|
|
|
274
377
|
}
|
|
275
378
|
return Object.entries(status).map(([name, field]) => {
|
|
276
379
|
if (!field) {
|
|
277
|
-
return
|
|
380
|
+
return;
|
|
278
381
|
}
|
|
279
382
|
if (typeof field === "string" || typeof field === "number" || typeof field === "boolean" || Array.isArray(field)) {
|
|
280
383
|
return {
|
|
@@ -293,68 +396,68 @@ function mapStatusFields(status) {
|
|
|
293
396
|
},
|
|
294
397
|
name
|
|
295
398
|
};
|
|
296
|
-
}).filter((field) => field?.value !==
|
|
399
|
+
}).filter((field) => field?.value !== undefined);
|
|
297
400
|
}
|
|
298
401
|
function mapPages(pages) {
|
|
299
402
|
if (!pages) {
|
|
300
|
-
return
|
|
403
|
+
return output4([]);
|
|
301
404
|
}
|
|
302
405
|
if (!Array.isArray(pages)) {
|
|
303
406
|
pages = Object.entries(pages).map(([name, page]) => {
|
|
304
407
|
if (!page) {
|
|
305
|
-
return
|
|
408
|
+
return;
|
|
306
409
|
}
|
|
307
410
|
return { ...page, name };
|
|
308
411
|
});
|
|
309
412
|
}
|
|
310
|
-
return
|
|
413
|
+
return output4(pages.filter((page) => !!page));
|
|
311
414
|
}
|
|
312
415
|
function mapTerminals(terminals) {
|
|
313
416
|
if (!terminals) {
|
|
314
|
-
return
|
|
417
|
+
return output4([]);
|
|
315
418
|
}
|
|
316
419
|
if (!Array.isArray(terminals)) {
|
|
317
420
|
terminals = Object.entries(terminals).map(([name, terminal]) => {
|
|
318
421
|
if (!terminal) {
|
|
319
|
-
return
|
|
422
|
+
return;
|
|
320
423
|
}
|
|
321
424
|
return { ...terminal, name };
|
|
322
425
|
});
|
|
323
426
|
}
|
|
324
|
-
return
|
|
427
|
+
return output4(terminals.filter((terminal) => !!terminal));
|
|
325
428
|
}
|
|
326
429
|
function mapTriggers(triggers) {
|
|
327
430
|
if (!triggers) {
|
|
328
|
-
return
|
|
431
|
+
return output4([]);
|
|
329
432
|
}
|
|
330
433
|
if (!Array.isArray(triggers)) {
|
|
331
434
|
triggers = Object.entries(triggers).map(([name, trigger]) => {
|
|
332
435
|
if (!trigger) {
|
|
333
|
-
return
|
|
436
|
+
return;
|
|
334
437
|
}
|
|
335
438
|
return { ...trigger, name };
|
|
336
439
|
});
|
|
337
440
|
}
|
|
338
|
-
return
|
|
441
|
+
return output4(triggers.filter((trigger) => !!trigger));
|
|
339
442
|
}
|
|
340
443
|
function mapWorkers(workers) {
|
|
341
444
|
if (!workers) {
|
|
342
|
-
return
|
|
445
|
+
return output4([]);
|
|
343
446
|
}
|
|
344
447
|
if (!Array.isArray(workers)) {
|
|
345
448
|
workers = Object.entries(workers).map(([name, worker]) => {
|
|
346
449
|
if (!worker) {
|
|
347
|
-
return
|
|
450
|
+
return;
|
|
348
451
|
}
|
|
349
452
|
return { ...worker, name };
|
|
350
453
|
});
|
|
351
454
|
}
|
|
352
|
-
return
|
|
455
|
+
return output4(workers.filter((worker) => !!worker));
|
|
353
456
|
}
|
|
354
457
|
function extractObjectsFromValue(schema, data) {
|
|
355
458
|
const result = [];
|
|
356
459
|
function traverse(obj) {
|
|
357
|
-
if (obj === null || obj ===
|
|
460
|
+
if (obj === null || obj === undefined || typeof obj !== "object") {
|
|
358
461
|
return;
|
|
359
462
|
}
|
|
360
463
|
if (Array.isArray(obj)) {
|
|
@@ -375,7 +478,34 @@ function extractObjectsFromValue(schema, data) {
|
|
|
375
478
|
traverse(data);
|
|
376
479
|
return result;
|
|
377
480
|
}
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
481
|
+
function getUnitTempPath() {
|
|
482
|
+
return join("/tmp/highstate", getUnitStateId());
|
|
483
|
+
}
|
|
484
|
+
export {
|
|
485
|
+
toPromise,
|
|
486
|
+
setResourceHooks,
|
|
487
|
+
normalizeInputsAndMap,
|
|
488
|
+
normalizeInputs,
|
|
489
|
+
normalize,
|
|
490
|
+
makeSecretOutput,
|
|
491
|
+
makeSecretAsync,
|
|
492
|
+
makeSecret,
|
|
493
|
+
makeFileOutput,
|
|
494
|
+
makeFileAsync,
|
|
495
|
+
makeFile,
|
|
496
|
+
makeEntityOutput,
|
|
497
|
+
makeEntityAsync,
|
|
498
|
+
makeEntity,
|
|
499
|
+
getUnitTempPath,
|
|
500
|
+
getUnitStateId,
|
|
501
|
+
getUnitInstanceName,
|
|
502
|
+
getUnitInstanceId,
|
|
503
|
+
getResourceComment,
|
|
504
|
+
getImportBaseUrl,
|
|
505
|
+
getHasResourceHooks,
|
|
506
|
+
getCombinedIdentityOutput,
|
|
507
|
+
getCombinedIdentityAsync,
|
|
508
|
+
getCombinedIdentity,
|
|
509
|
+
forUnit,
|
|
510
|
+
apply
|
|
511
|
+
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@highstate/pulumi",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.21.1",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"files": [
|
|
6
6
|
"dist",
|
|
@@ -28,25 +28,25 @@
|
|
|
28
28
|
"platform"
|
|
29
29
|
]
|
|
30
30
|
},
|
|
31
|
+
"scripts": {
|
|
32
|
+
"build": "highstate build",
|
|
33
|
+
"typecheck": "tsgo --noEmit --skipLibCheck",
|
|
34
|
+
"biome": "biome check --write --unsafe --error-on-warnings",
|
|
35
|
+
"biome:check": "biome check --error-on-warnings"
|
|
36
|
+
},
|
|
31
37
|
"dependencies": {
|
|
32
|
-
"@
|
|
38
|
+
"@highstate/contract": "0.20.0",
|
|
39
|
+
"@pulumi/pulumi": "3.232.0",
|
|
33
40
|
"deepmerge-ts": "^7.1.5",
|
|
34
41
|
"remeda": "^2.21.0",
|
|
35
|
-
"type-fest": "^4.41.0"
|
|
36
|
-
"@highstate/contract": "0.19.1"
|
|
42
|
+
"type-fest": "^4.41.0"
|
|
37
43
|
},
|
|
38
44
|
"devDependencies": {
|
|
39
45
|
"@biomejs/biome": "2.2.0",
|
|
40
|
-
"@
|
|
41
|
-
"@
|
|
46
|
+
"@highstate/cli": "0.20.0",
|
|
47
|
+
"@typescript/native-preview": "^7.0.0-dev.20250920.1"
|
|
42
48
|
},
|
|
43
49
|
"repository": {
|
|
44
50
|
"url": "https://github.com/highstate-io/highstate"
|
|
45
|
-
},
|
|
46
|
-
"scripts": {
|
|
47
|
-
"build": "highstate build",
|
|
48
|
-
"typecheck": "tsgo --noEmit --skipLibCheck",
|
|
49
|
-
"biome": "biome check --write --unsafe --error-on-warnings",
|
|
50
|
-
"biome:check": "biome check --error-on-warnings"
|
|
51
51
|
}
|
|
52
|
-
}
|
|
52
|
+
}
|