@highstate/pulumi 0.2.0 → 0.2.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.
@@ -0,0 +1,78 @@
1
+ import { Input, Output, Unwrap } from '@pulumi/pulumi';
2
+ export * from '@pulumi/pulumi';
3
+ import { ArgumentValue, ComponentInputSpec, Unit, Entity } from '@highstate/contract';
4
+ import { Static } from '@sinclair/typebox';
5
+
6
+ /**
7
+ * The input type for an array of inputs.
8
+ * The same as `Input<Input<T>[]>`, but more readable.
9
+ */
10
+ type InputArray<T> = Input<Input<T>[]>;
11
+ /**
12
+ * The input type for a map of inputs.
13
+ * The same as `Input<Record<string, Input<T>>>`, but more readable.
14
+ */
15
+ type InputMap<T> = Input<Readonly<Record<string, Input<T>>>>;
16
+ /**
17
+ * The input or input array type for a value.
18
+ */
19
+ type InputOrArray<T> = Input<T> | InputArray<T> | undefined;
20
+ /**
21
+ * The input of inputs of inputs of inputs, so you got the idea.
22
+ */
23
+ type DeepInput<T> = T extends Record<string, unknown> ? Input<{
24
+ [K in keyof T]: DeepInput<T[K]>;
25
+ }> : T extends Array<unknown> ? Input<DeepInput<T[number]>[]> : T extends infer U | undefined ? Input<U | undefined> | undefined : Input<T>;
26
+ /**
27
+ * Merges the given array of `InputOrArray` values into a single flat output array.
28
+ *
29
+ * @param values The values to merge.
30
+ * @returns The merged output array.
31
+ */
32
+ declare function mergeInputs<T>(...values: InputOrArray<T>[]): Output<T[]>;
33
+ /**
34
+ * Flattens an array of input arrays into a single output array.
35
+ *
36
+ * @param array The input array.
37
+ * @returns The output array.
38
+ */
39
+ declare function flattenInputs<T>(array: InputArray<InputArray<T>>): Output<T[]>;
40
+ /**
41
+ * Maps each element of an input array to a new value.
42
+ * Produces an output array with the same length.
43
+ *
44
+ * @param array The input array.
45
+ * @param fn The mapping function.
46
+ * @returns The output array.
47
+ */
48
+ declare function mapInputs<T, U>(array: InputArray<T>, fn: (v: Unwrap<T>, index: number, all: Unwrap<T>[]) => U): Output<U[]>;
49
+ declare function mergeMapInputs<T, U>(v1: InputOrArray<T>, v2: InputOrArray<T>, fn: (v: Unwrap<T>, index: number, all: Unwrap<T>[]) => U): Output<U[]>;
50
+ declare function mergeMapInputs<T, U>(v1: InputOrArray<T>, v2: InputOrArray<T>, v3: InputOrArray<T>, fn: (v: Unwrap<T>, index: number, all: Unwrap<T>[]) => U): Output<U[]>;
51
+ /**
52
+ * Map an optional value to another optional value.
53
+ *
54
+ * @param input The input value.
55
+ * @param func The function to apply to the input value.
56
+ * @returns The output value, or `undefined` if the input value is `undefined`.
57
+ */
58
+ declare function mapOptional<T, U>(input: T | undefined, func: (value: T) => U): U | undefined;
59
+ declare function toPromise<T>(output: Output<T>): Promise<T>;
60
+ declare function singleton<T>(factory: () => T): () => T;
61
+ declare function namedSingleton<T>(factory: (name: string) => T): (name: string) => T;
62
+
63
+ interface UnitContext<TArgs extends Record<string, ArgumentValue>, TInputs extends Record<string, unknown>, TOutputs extends Record<string, unknown>, TSecrets extends Record<string, ArgumentValue>> {
64
+ args: TArgs;
65
+ name: string;
66
+ secrets: Output<TSecrets>;
67
+ inputs: Output<TInputs>;
68
+ outputs(this: void, outputs: DeepInput<TOutputs>): Output<TOutputs>;
69
+ }
70
+ type InputSpecToValue<T extends ComponentInputSpec> = T[2] extends true ? Static<T[0]["schema"]>[] : Static<T[0]["schema"]>;
71
+ declare function forUnit<TArgs extends Record<string, ArgumentValue>, TInputs extends Record<string, ComponentInputSpec>, TOutputs extends Record<string, ComponentInputSpec>, TSecrets extends Record<string, ArgumentValue>>(unit: Unit<TArgs, TInputs, TOutputs, TSecrets>): UnitContext<TArgs, {
72
+ [K in keyof TInputs]: InputSpecToValue<TInputs[K]>;
73
+ }, {
74
+ [K in keyof TOutputs]: InputSpecToValue<TOutputs[K]>;
75
+ }, TSecrets>;
76
+ type EntityInput<T extends Entity> = Output<Static<T["schema"]>>;
77
+
78
+ export { type DeepInput, type EntityInput, type InputArray, type InputMap, type InputOrArray, type UnitContext, flattenInputs, forUnit, mapInputs, mapOptional, mergeInputs, mergeMapInputs, namedSingleton, singleton, toPromise };
package/dist/index.mjs ADDED
@@ -0,0 +1,62 @@
1
+ import { all, output } from '@pulumi/pulumi';
2
+ export * from '@pulumi/pulumi';
3
+
4
+ function forUnit(unit) {
5
+ throw new Error("Not implemented");
6
+ }
7
+
8
+ function mergeInputs(...values) {
9
+ return all(values).apply((allValues) => {
10
+ const result = [];
11
+ for (const value of allValues) {
12
+ if (Array.isArray(value)) {
13
+ result.push(...value);
14
+ } else if (value) {
15
+ result.push(value);
16
+ }
17
+ }
18
+ return result;
19
+ });
20
+ }
21
+ function flattenInputs(array) {
22
+ return output(array).apply((array2) => array2.flat());
23
+ }
24
+ function mapInputs(array, fn) {
25
+ return output(array).apply(
26
+ (array2) => array2.map((v, index) => fn(v, index, array2))
27
+ );
28
+ }
29
+ function mergeMapInputs(...args) {
30
+ const fn = args.pop();
31
+ const values = args;
32
+ return mapInputs(mergeInputs(...values), fn);
33
+ }
34
+ function mapOptional(input, func) {
35
+ if (input === void 0) {
36
+ return void 0;
37
+ }
38
+ return func(input);
39
+ }
40
+ function toPromise(output2) {
41
+ return new Promise((resolve) => output2.apply(resolve));
42
+ }
43
+ function singleton(factory) {
44
+ let instance;
45
+ return () => {
46
+ if (instance === void 0) {
47
+ instance = factory();
48
+ }
49
+ return instance;
50
+ };
51
+ }
52
+ function namedSingleton(factory) {
53
+ const instances = /* @__PURE__ */ new Map();
54
+ return (name) => {
55
+ if (!instances.has(name)) {
56
+ instances.set(name, factory(name));
57
+ }
58
+ return instances.get(name);
59
+ };
60
+ }
61
+
62
+ export { flattenInputs, forUnit, mapInputs, mapOptional, mergeInputs, mergeMapInputs, namedSingleton, singleton, toPromise };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@highstate/pulumi",
3
- "version": "0.2.0",
3
+ "version": "0.2.1",
4
4
  "type": "module",
5
5
  "module": "dist/index.mjs",
6
6
  "types": "dist/index.d.ts",
@@ -20,12 +20,12 @@
20
20
  "build": "pkgroll --clean-dist"
21
21
  },
22
22
  "dependencies": {
23
- "@highstate/contract": "^0.2.0",
23
+ "@highstate/contract": "^0.2.1",
24
24
  "@pulumi/pulumi": "^3.142.0",
25
25
  "@sinclair/typebox": "^0.34.11"
26
26
  },
27
27
  "devDependencies": {
28
28
  "pkgroll": "^2.5.1"
29
29
  },
30
- "gitHead": "41f789ef9d6da623923812bba9783c216605495d"
30
+ "gitHead": "205bae57e7b9e8e8ebe979859df3f18fdb8cfe81"
31
31
  }