@pulumi/pulumi 3.163.0-alpha.xdc88586 → 3.163.0-alpha.xe7c1e4f

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.
Files changed (70) hide show
  1. package/automation/cmd.js +92 -111
  2. package/automation/cmd.js.map +1 -1
  3. package/automation/localWorkspace.js +383 -476
  4. package/automation/localWorkspace.js.map +1 -1
  5. package/automation/remoteWorkspace.js +38 -55
  6. package/automation/remoteWorkspace.js.map +1 -1
  7. package/automation/server.js +6 -16
  8. package/automation/server.js.map +1 -1
  9. package/automation/stack.js +537 -608
  10. package/automation/stack.js.map +1 -1
  11. package/cmd/dynamic-provider/index.js +204 -235
  12. package/cmd/dynamic-provider/index.js.map +1 -1
  13. package/cmd/run/error.js +3 -3
  14. package/cmd/run/error.js.map +1 -1
  15. package/cmd/run/run.js +322 -336
  16. package/cmd/run/run.js.map +1 -1
  17. package/cmd/run/tracing.js +1 -2
  18. package/cmd/run/tracing.js.map +1 -1
  19. package/cmd/run-plugin/run.js +13 -17
  20. package/cmd/run-plugin/run.js.map +1 -1
  21. package/cmd/run-policy-pack/run.js +12 -16
  22. package/cmd/run-policy-pack/run.js.map +1 -1
  23. package/output.js +61 -78
  24. package/output.js.map +1 -1
  25. package/package.json +1 -1
  26. package/provider/experimental/analyzer.js +43 -46
  27. package/provider/experimental/analyzer.js.map +1 -1
  28. package/provider/experimental/provider.js +22 -36
  29. package/provider/experimental/provider.js.map +1 -1
  30. package/provider/server.js +359 -397
  31. package/provider/server.js.map +1 -1
  32. package/resource.js +29 -41
  33. package/resource.js.map +1 -1
  34. package/runtime/asyncIterableUtil.js +6 -17
  35. package/runtime/asyncIterableUtil.js.map +1 -1
  36. package/runtime/callbacks.js +254 -269
  37. package/runtime/callbacks.js.map +1 -1
  38. package/runtime/closure/codePaths.js +117 -135
  39. package/runtime/closure/codePaths.js.map +1 -1
  40. package/runtime/closure/createClosure.js +807 -871
  41. package/runtime/closure/createClosure.js.map +1 -1
  42. package/runtime/closure/parseFunction.js +2 -3
  43. package/runtime/closure/parseFunction.js.map +1 -1
  44. package/runtime/closure/serializeClosure.js +17 -30
  45. package/runtime/closure/serializeClosure.js.map +1 -1
  46. package/runtime/closure/v8.js +166 -190
  47. package/runtime/closure/v8.js.map +1 -1
  48. package/runtime/closure/v8Hooks.js +19 -34
  49. package/runtime/closure/v8Hooks.js.map +1 -1
  50. package/runtime/dependsOn.js +61 -80
  51. package/runtime/dependsOn.js.map +1 -1
  52. package/runtime/invoke.js +155 -170
  53. package/runtime/invoke.js.map +1 -1
  54. package/runtime/mocks.js +77 -96
  55. package/runtime/mocks.js.map +1 -1
  56. package/runtime/resource.js +238 -252
  57. package/runtime/resource.js.map +1 -1
  58. package/runtime/rpc.js +193 -215
  59. package/runtime/rpc.js.map +1 -1
  60. package/runtime/settings.js +70 -87
  61. package/runtime/settings.js.map +1 -1
  62. package/runtime/stack.js +111 -131
  63. package/runtime/stack.js.map +1 -1
  64. package/stackReference.js +39 -58
  65. package/stackReference.js.map +1 -1
  66. package/tsutils.js +1 -2
  67. package/tsutils.js.map +1 -1
  68. package/utils.js +2 -3
  69. package/utils.js.map +1 -1
  70. package/version.js +1 -1
@@ -12,15 +12,6 @@
12
12
  // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
13
  // See the License for the specific language governing permissions and
14
14
  // limitations under the License.
15
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
16
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
17
- return new (P || (P = Promise))(function (resolve, reject) {
18
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
19
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
20
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
21
- step((generator = generator.apply(thisArg, _arguments || [])).next());
22
- });
23
- };
24
15
  Object.defineProperty(exports, "__esModule", { value: true });
25
16
  const output_1 = require("../output");
26
17
  const resource_1 = require("../resource");
@@ -29,36 +20,34 @@ const resource_1 = require("../resource");
29
20
  *
30
21
  * @internal
31
22
  */
32
- function gatherExplicitDependencies(dependsOn) {
33
- return __awaiter(this, void 0, void 0, function* () {
34
- if (dependsOn) {
35
- if (Array.isArray(dependsOn)) {
36
- const dos = [];
37
- for (const d of dependsOn) {
38
- dos.push(...(yield gatherExplicitDependencies(d)));
39
- }
40
- return dos;
41
- }
42
- else if (dependsOn instanceof Promise) {
43
- return gatherExplicitDependencies(yield dependsOn);
23
+ async function gatherExplicitDependencies(dependsOn) {
24
+ if (dependsOn) {
25
+ if (Array.isArray(dependsOn)) {
26
+ const dos = [];
27
+ for (const d of dependsOn) {
28
+ dos.push(...(await gatherExplicitDependencies(d)));
44
29
  }
45
- else if (output_1.Output.isInstance(dependsOn)) {
46
- // Recursively gather dependencies, await the promise, and append the output's dependencies.
47
- const dos = dependsOn.apply((v) => gatherExplicitDependencies(v));
48
- const urns = yield dos.promise();
49
- const dosResources = yield output_1.getAllResources(dos);
50
- const implicits = yield gatherExplicitDependencies([...dosResources]);
51
- return (urns !== null && urns !== void 0 ? urns : []).concat(implicits);
52
- }
53
- else {
54
- if (!resource_1.Resource.isInstance(dependsOn)) {
55
- throw new Error("'dependsOn' was passed a value that was not a Resource.");
56
- }
57
- return [dependsOn];
30
+ return dos;
31
+ }
32
+ else if (dependsOn instanceof Promise) {
33
+ return gatherExplicitDependencies(await dependsOn);
34
+ }
35
+ else if (output_1.Output.isInstance(dependsOn)) {
36
+ // Recursively gather dependencies, await the promise, and append the output's dependencies.
37
+ const dos = dependsOn.apply((v) => gatherExplicitDependencies(v));
38
+ const urns = await dos.promise();
39
+ const dosResources = await output_1.getAllResources(dos);
40
+ const implicits = await gatherExplicitDependencies([...dosResources]);
41
+ return (urns ?? []).concat(implicits);
42
+ }
43
+ else {
44
+ if (!resource_1.Resource.isInstance(dependsOn)) {
45
+ throw new Error("'dependsOn' was passed a value that was not a Resource.");
58
46
  }
47
+ return [dependsOn];
59
48
  }
60
- return [];
61
- });
49
+ }
50
+ return [];
62
51
  }
63
52
  exports.gatherExplicitDependencies = gatherExplicitDependencies;
64
53
  /**
@@ -93,13 +82,11 @@ exports.gatherExplicitDependencies = gatherExplicitDependencies;
93
82
  *
94
83
  * @internal
95
84
  */
96
- function getAllTransitivelyReferencedResources(resources, exclude) {
97
- return __awaiter(this, void 0, void 0, function* () {
98
- const transitivelyReachableResources = yield getTransitivelyReferencedChildResourcesOfComponentResources(resources, exclude);
99
- // Then we filter to only include Custom and Remote resources.
100
- const transitivelyReachableCustomResources = [...transitivelyReachableResources].filter((r) => (resource_1.CustomResource.isInstance(r) || r.__remote) && !exclude.has(r));
101
- return transitivelyReachableCustomResources;
102
- });
85
+ async function getAllTransitivelyReferencedResources(resources, exclude) {
86
+ const transitivelyReachableResources = await getTransitivelyReferencedChildResourcesOfComponentResources(resources, exclude);
87
+ // Then we filter to only include Custom and Remote resources.
88
+ const transitivelyReachableCustomResources = [...transitivelyReachableResources].filter((r) => (resource_1.CustomResource.isInstance(r) || r.__remote) && !exclude.has(r));
89
+ return transitivelyReachableCustomResources;
103
90
  }
104
91
  exports.getAllTransitivelyReferencedResources = getAllTransitivelyReferencedResources;
105
92
  /**
@@ -108,13 +95,11 @@ exports.getAllTransitivelyReferencedResources = getAllTransitivelyReferencedReso
108
95
  *
109
96
  * @internal
110
97
  */
111
- function getAllTransitivelyReferencedResourceURNs(resources, exclude) {
112
- return __awaiter(this, void 0, void 0, function* () {
113
- const transitivelyReachableCustomResources = yield getAllTransitivelyReferencedResources(resources, exclude);
114
- const promises = transitivelyReachableCustomResources.map((r) => r.urn.promise());
115
- const urns = yield Promise.all(promises);
116
- return new Set(urns);
117
- });
98
+ async function getAllTransitivelyReferencedResourceURNs(resources, exclude) {
99
+ const transitivelyReachableCustomResources = await getAllTransitivelyReferencedResources(resources, exclude);
100
+ const promises = transitivelyReachableCustomResources.map((r) => r.urn.promise());
101
+ const urns = await Promise.all(promises);
102
+ return new Set(urns);
118
103
  }
119
104
  exports.getAllTransitivelyReferencedResourceURNs = getAllTransitivelyReferencedResourceURNs;
120
105
  /**
@@ -122,40 +107,36 @@ exports.getAllTransitivelyReferencedResourceURNs = getAllTransitivelyReferencedR
122
107
  * reachable from {@link Resource.__childResources} through any **component**
123
108
  * resources we encounter.
124
109
  */
125
- function getTransitivelyReferencedChildResourcesOfComponentResources(resources, exclude) {
126
- return __awaiter(this, void 0, void 0, function* () {
127
- // Recursively walk the dependent resources through their children, adding them to the result set.
128
- const result = new Set();
129
- yield addTransitivelyReferencedChildResourcesOfComponentResources(resources, exclude, result);
130
- return result;
131
- });
110
+ async function getTransitivelyReferencedChildResourcesOfComponentResources(resources, exclude) {
111
+ // Recursively walk the dependent resources through their children, adding them to the result set.
112
+ const result = new Set();
113
+ await addTransitivelyReferencedChildResourcesOfComponentResources(resources, exclude, result);
114
+ return result;
132
115
  }
133
- function addTransitivelyReferencedChildResourcesOfComponentResources(resources, exclude, result) {
134
- return __awaiter(this, void 0, void 0, function* () {
135
- // We can collect the resources out of the loop
136
- const promises = [];
137
- if (resources) {
138
- for (const resource of resources) {
139
- if (!result.has(resource)) {
140
- result.add(resource);
141
- if (resource_1.ComponentResource.isInstance(resource)) {
142
- // Skip including children of a resource in the excluded set to avoid depending on
143
- // children that haven't been registered yet.
144
- if (exclude.has(resource)) {
145
- continue;
146
- }
147
- // This await is safe even if __isConstructed is undefined. Ensure that the
148
- // resource has completely finished construction. That way all parent/child
149
- // relationships will have been setup.
150
- promises.push(resource.__data.then(() => {
151
- const children = resource.__childResources;
152
- return addTransitivelyReferencedChildResourcesOfComponentResources(children, exclude, result);
153
- }));
116
+ async function addTransitivelyReferencedChildResourcesOfComponentResources(resources, exclude, result) {
117
+ // We can collect the resources out of the loop
118
+ const promises = [];
119
+ if (resources) {
120
+ for (const resource of resources) {
121
+ if (!result.has(resource)) {
122
+ result.add(resource);
123
+ if (resource_1.ComponentResource.isInstance(resource)) {
124
+ // Skip including children of a resource in the excluded set to avoid depending on
125
+ // children that haven't been registered yet.
126
+ if (exclude.has(resource)) {
127
+ continue;
154
128
  }
129
+ // This await is safe even if __isConstructed is undefined. Ensure that the
130
+ // resource has completely finished construction. That way all parent/child
131
+ // relationships will have been setup.
132
+ promises.push(resource.__data.then(() => {
133
+ const children = resource.__childResources;
134
+ return addTransitivelyReferencedChildResourcesOfComponentResources(children, exclude, result);
135
+ }));
155
136
  }
156
137
  }
157
138
  }
158
- yield Promise.all(promises);
159
- });
139
+ }
140
+ await Promise.all(promises);
160
141
  }
161
142
  //# sourceMappingURL=dependsOn.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"dependsOn.js","sourceRoot":"","sources":["../../runtime/dependsOn.ts"],"names":[],"mappings":";AAAA,2CAA2C;AAC3C,EAAE;AACF,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,iDAAiD;AACjD,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;;;;;;;;;;;AAEjC,sCAA2D;AAC3D,0CAA0E;AAE1E;;;;GAIG;AACH,SAAsB,0BAA0B,CAC5C,SAAiE;;QAEjE,IAAI,SAAS,EAAE;YACX,IAAI,KAAK,CAAC,OAAO,CAAC,SAAS,CAAC,EAAE;gBAC1B,MAAM,GAAG,GAAe,EAAE,CAAC;gBAC3B,KAAK,MAAM,CAAC,IAAI,SAAS,EAAE;oBACvB,GAAG,CAAC,IAAI,CAAC,GAAG,CAAC,MAAM,0BAA0B,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;iBACtD;gBACD,OAAO,GAAG,CAAC;aACd;iBAAM,IAAI,SAAS,YAAY,OAAO,EAAE;gBACrC,OAAO,0BAA0B,CAAC,MAAM,SAAS,CAAC,CAAC;aACtD;iBAAM,IAAI,eAAM,CAAC,UAAU,CAAC,SAAS,CAAC,EAAE;gBACrC,4FAA4F;gBAC5F,MAAM,G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I,CAAC,CAAC;AACjC,CAAC;AARD,4FAQC;AAED;;;;GAIG;AACH,KAAK,UAAU,2DAA2D,CACtE,SAAwB,EACxB,OAAsB;IAEtB,kGAAkG;IAClG,MAAM,MAAM,GAAG,IAAI,GAAG,EAAY,CAAC;IACnC,MAAM,2DAA2D,CAAC,SAAS,EAAE,OAAO,EAAE,MAAM,CAAC,CAAC;IAC9F,OAAO,MAAM,CAAC;AAClB,CAAC;AAED,KAAK,UAAU,2DAA2D,CACtE,SAAoC,EACpC,OAAsB,EACtB,MAAqB;IAErB,+CAA+C;IAC/C,MAAM,QAAQ,GAAoB,EAAE,CAAC;IAErC,IAAI,SAAS,EAAE;QACX,KAAK,MAAM,QAAQ,IAAI,SAAS,EAAE;YAC9B,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,QAAQ,CAAC,EAAE;gBACvB,MAAM,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC;gBAErB,IAAI,4BAAiB,CAAC,UAAU,CAAC,QAAQ,CAAC,EAAE;oBACxC,kFAAkF;oBAClF,6CAA6C;oBAC7C,IAAI,OAAO,CAAC,GAAG,CAAC,QAAQ,CAAC,EAAE;wBACvB,SAAS;qBACZ;oBAED,2EAA2E;oBAC3E,4EAA4E;oBAC5E,sCAAsC;oBACtC,QAAQ,CAAC,IAAI,CACT,QAAQ,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,EAAE;wBACtB,MAAM,QAAQ,GAAG,QAAQ,CAAC,gBAAgB,CAAC;wBAC3C,OAAO,2DAA2D,CAC9D,QAAQ,EACR,OAAO,EACP,MAAM,CACT,CAAC;oBACN,CAAC,CAAC,CACL,CAAC;iBACL;aACJ;SACJ;KACJ;IAED,MAAM,OAAO,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC;AAChC,CAAC"}
package/runtime/invoke.js CHANGED
@@ -12,15 +12,6 @@
12
12
  // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
13
  // See the License for the specific language governing permissions and
14
14
  // limitations under the License.
15
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
16
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
17
- return new (P || (P = Promise))(function (resolve, reject) {
18
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
19
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
20
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
21
- step((generator = generator.apply(thisArg, _arguments || [])).next());
22
- });
23
- };
24
15
  var __importStar = (this && this.__importStar) || function (mod) {
25
16
  if (mod && mod.__esModule) return mod;
26
17
  var result = {};
@@ -79,7 +70,7 @@ const resourceproto = __importStar(require("../proto/resource_pb"));
79
70
  * to operate synchronously.
80
71
  */
81
72
  function invoke(tok, props, opts = {}, packageRef) {
82
- const optsCopy = Object.assign({}, opts);
73
+ const optsCopy = { ...opts };
83
74
  if ("dependsOn" in optsCopy) {
84
75
  // DependsOn is only allowed for invokeOutput.
85
76
  //@ts-ignore
@@ -149,143 +140,139 @@ function invokeSingleOutput(tok, props, opts = {}, packageRef) {
149
140
  return output;
150
141
  }
151
142
  exports.invokeSingleOutput = invokeSingleOutput;
152
- function invokeAsync(tok, props, opts, packageRef, checkDependencies) {
153
- return __awaiter(this, void 0, void 0, function* () {
154
- const label = `Invoking function: tok=${tok} asynchronously`;
155
- log.debug(label + (settings_1.excessiveDebugOutput ? `, props=${JSON.stringify(props)}` : ``));
156
- yield settings_1.awaitStackRegistrations();
157
- // Wait for all values to be available, and then perform the RPC.
158
- const done = settings_1.rpcKeepAlive();
159
- try {
160
- // The direct dependencies of the invoke call from the dependsOn option.
161
- const dependsOnDeps = yield dependsOn_1.gatherExplicitDependencies(opts.dependsOn);
162
- // The dependencies of the inputs to the invoke call.
163
- const [serialized, deps] = yield rpc_1.serializePropertiesReturnDeps(`invoke:${tok}`, props);
164
- if (rpc_1.containsUnknownValues(serialized)) {
165
- // if any of the input properties are unknown,
166
- // make sure the entire response is marked as unknown
167
- return {
168
- result: {},
169
- isKnown: false,
170
- containsSecrets: false,
171
- dependencies: [],
172
- };
173
- }
174
- // Only check the resource dependencies for output form invokes. For
175
- // plain invokes, we do not want to check the dependencies. Technically,
176
- // these should only receive plain arguments, but this is not strictly
177
- // enforced, and in practice people pass in outputs. This happens to
178
- // work because we serialize the arguments.
179
- if (checkDependencies) {
180
- // If we depend on any CustomResources, we need to ensure that their
181
- // ID is known before proceeding. If it is not known, we will return
182
- // an unknown result.
183
- const resourcesToWaitFor = new Set(dependsOnDeps);
184
- // Add the dependencies from the inputs to the set of resources to wait for.
185
- for (const resourceDeps of deps.values()) {
186
- for (const value of resourceDeps.values()) {
187
- resourcesToWaitFor.add(value);
188
- }
189
- }
190
- // The expanded set of dependencies, including children of components.
191
- const expandedDeps = yield dependsOn_1.getAllTransitivelyReferencedResources(resourcesToWaitFor, new Set());
192
- // Ensure that all resource IDs are known before proceeding.
193
- for (const dep of expandedDeps.values()) {
194
- // DependencyResources inherit from CustomResource, but they don't set the id. Skip them.
195
- if (resource_1.CustomResource.isInstance(dep) && dep.id) {
196
- const known = yield dep.id.isKnown;
197
- if (!known) {
198
- return {
199
- result: {},
200
- isKnown: false,
201
- containsSecrets: false,
202
- dependencies: [],
203
- };
204
- }
205
- }
143
+ async function invokeAsync(tok, props, opts, packageRef, checkDependencies) {
144
+ const label = `Invoking function: tok=${tok} asynchronously`;
145
+ log.debug(label + (settings_1.excessiveDebugOutput ? `, props=${JSON.stringify(props)}` : ``));
146
+ await settings_1.awaitStackRegistrations();
147
+ // Wait for all values to be available, and then perform the RPC.
148
+ const done = settings_1.rpcKeepAlive();
149
+ try {
150
+ // The direct dependencies of the invoke call from the dependsOn option.
151
+ const dependsOnDeps = await dependsOn_1.gatherExplicitDependencies(opts.dependsOn);
152
+ // The dependencies of the inputs to the invoke call.
153
+ const [serialized, deps] = await rpc_1.serializePropertiesReturnDeps(`invoke:${tok}`, props);
154
+ if (rpc_1.containsUnknownValues(serialized)) {
155
+ // if any of the input properties are unknown,
156
+ // make sure the entire response is marked as unknown
157
+ return {
158
+ result: {},
159
+ isKnown: false,
160
+ containsSecrets: false,
161
+ dependencies: [],
162
+ };
163
+ }
164
+ // Only check the resource dependencies for output form invokes. For
165
+ // plain invokes, we do not want to check the dependencies. Technically,
166
+ // these should only receive plain arguments, but this is not strictly
167
+ // enforced, and in practice people pass in outputs. This happens to
168
+ // work because we serialize the arguments.
169
+ if (checkDependencies) {
170
+ // If we depend on any CustomResources, we need to ensure that their
171
+ // ID is known before proceeding. If it is not known, we will return
172
+ // an unknown result.
173
+ const resourcesToWaitFor = new Set(dependsOnDeps);
174
+ // Add the dependencies from the inputs to the set of resources to wait for.
175
+ for (const resourceDeps of deps.values()) {
176
+ for (const value of resourceDeps.values()) {
177
+ resourcesToWaitFor.add(value);
206
178
  }
207
179
  }
208
- log.debug(`Invoke RPC prepared: tok=${tok}` + settings_1.excessiveDebugOutput ? `, obj=${JSON.stringify(serialized)}` : ``);
209
- // Fetch the monitor and make an RPC request.
210
- const monitor = settings_1.getMonitor();
211
- const provider = yield resource_1.ProviderResource.register(getProvider(tok, opts));
212
- // keep track of the the secretness of the inputs
213
- // if any of the inputs are secret, the invoke response should be marked as secret
214
- const [plainInputs, inputsContainSecrets] = rpc_1.unwrapSecretValues(serialized);
215
- const req = yield createInvokeRequest(tok, plainInputs, provider, opts, packageRef);
216
- const resp = yield debuggable_1.debuggablePromise(new Promise((innerResolve, innerReject) => monitor.invoke(req, (err, innerResponse) => {
217
- log.debug(`Invoke RPC finished: tok=${tok}; err: ${err}, resp: ${innerResponse}`);
218
- if (err) {
219
- // If the monitor is unavailable, it is in the process of shutting down or has already
220
- // shut down. Don't emit an error and don't do any more RPCs, just exit.
221
- if (err.code === grpc.status.UNAVAILABLE || err.code === grpc.status.CANCELLED) {
222
- settings_1.terminateRpcs();
223
- err.message = "Resource monitor is terminating";
224
- innerReject(err);
225
- return;
180
+ // The expanded set of dependencies, including children of components.
181
+ const expandedDeps = await dependsOn_1.getAllTransitivelyReferencedResources(resourcesToWaitFor, new Set());
182
+ // Ensure that all resource IDs are known before proceeding.
183
+ for (const dep of expandedDeps.values()) {
184
+ // DependencyResources inherit from CustomResource, but they don't set the id. Skip them.
185
+ if (resource_1.CustomResource.isInstance(dep) && dep.id) {
186
+ const known = await dep.id.isKnown;
187
+ if (!known) {
188
+ return {
189
+ result: {},
190
+ isKnown: false,
191
+ containsSecrets: false,
192
+ dependencies: [],
193
+ };
226
194
  }
227
- // If the RPC failed, rethrow the error with a native exception and the message that
228
- // the engine provided - it's suitable for user presentation.
229
- innerReject(new Error(err.details));
230
195
  }
231
- else {
232
- innerResolve(innerResponse);
196
+ }
197
+ }
198
+ log.debug(`Invoke RPC prepared: tok=${tok}` + settings_1.excessiveDebugOutput ? `, obj=${JSON.stringify(serialized)}` : ``);
199
+ // Fetch the monitor and make an RPC request.
200
+ const monitor = settings_1.getMonitor();
201
+ const provider = await resource_1.ProviderResource.register(getProvider(tok, opts));
202
+ // keep track of the the secretness of the inputs
203
+ // if any of the inputs are secret, the invoke response should be marked as secret
204
+ const [plainInputs, inputsContainSecrets] = rpc_1.unwrapSecretValues(serialized);
205
+ const req = await createInvokeRequest(tok, plainInputs, provider, opts, packageRef);
206
+ const resp = await debuggable_1.debuggablePromise(new Promise((innerResolve, innerReject) => monitor.invoke(req, (err, innerResponse) => {
207
+ log.debug(`Invoke RPC finished: tok=${tok}; err: ${err}, resp: ${innerResponse}`);
208
+ if (err) {
209
+ // If the monitor is unavailable, it is in the process of shutting down or has already
210
+ // shut down. Don't emit an error and don't do any more RPCs, just exit.
211
+ if (err.code === grpc.status.UNAVAILABLE || err.code === grpc.status.CANCELLED) {
212
+ settings_1.terminateRpcs();
213
+ err.message = "Resource monitor is terminating";
214
+ innerReject(err);
215
+ return;
233
216
  }
234
- })), label);
235
- const flatDependencies = dependsOnDeps;
236
- for (const dep of deps.values()) {
237
- for (const d of dep) {
238
- if (!flatDependencies.includes(d)) {
239
- flatDependencies.push(d);
240
- }
217
+ // If the RPC failed, rethrow the error with a native exception and the message that
218
+ // the engine provided - it's suitable for user presentation.
219
+ innerReject(new Error(err.details));
220
+ }
221
+ else {
222
+ innerResolve(innerResponse);
223
+ }
224
+ })), label);
225
+ const flatDependencies = dependsOnDeps;
226
+ for (const dep of deps.values()) {
227
+ for (const d of dep) {
228
+ if (!flatDependencies.includes(d)) {
229
+ flatDependencies.push(d);
241
230
  }
242
231
  }
243
- // Finally propagate any other properties that were given to us as outputs.
244
- const deserialized = deserializeResponse(tok, resp);
245
- return {
246
- result: deserialized.result,
247
- containsSecrets: deserialized.containsSecrets || inputsContainSecrets,
248
- dependencies: flatDependencies,
249
- isKnown: true,
250
- };
251
232
  }
252
- finally {
253
- done();
254
- }
255
- });
233
+ // Finally propagate any other properties that were given to us as outputs.
234
+ const deserialized = deserializeResponse(tok, resp);
235
+ return {
236
+ result: deserialized.result,
237
+ containsSecrets: deserialized.containsSecrets || inputsContainSecrets,
238
+ dependencies: flatDependencies,
239
+ isKnown: true,
240
+ };
241
+ }
242
+ finally {
243
+ done();
244
+ }
256
245
  }
257
- function createInvokeRequest(tok, serialized, provider, opts, packageRef) {
258
- return __awaiter(this, void 0, void 0, function* () {
259
- if (provider !== undefined && typeof provider !== "string") {
260
- throw new Error("Incorrect provider type.");
261
- }
262
- const obj = gstruct.Struct.fromJavaScript(serialized);
263
- let packageRefStr = undefined;
264
- if (packageRef !== undefined) {
265
- packageRefStr = yield packageRef;
266
- if (packageRefStr !== undefined) {
267
- // If we have a package reference we can clear some of the resource options
268
- opts.version = undefined;
269
- opts.pluginDownloadURL = undefined;
270
- }
246
+ async function createInvokeRequest(tok, serialized, provider, opts, packageRef) {
247
+ if (provider !== undefined && typeof provider !== "string") {
248
+ throw new Error("Incorrect provider type.");
249
+ }
250
+ const obj = gstruct.Struct.fromJavaScript(serialized);
251
+ let packageRefStr = undefined;
252
+ if (packageRef !== undefined) {
253
+ packageRefStr = await packageRef;
254
+ if (packageRefStr !== undefined) {
255
+ // If we have a package reference we can clear some of the resource options
256
+ opts.version = undefined;
257
+ opts.pluginDownloadURL = undefined;
271
258
  }
272
- const req = new resourceproto.ResourceInvokeRequest();
273
- req.setTok(tok);
274
- req.setArgs(obj);
275
- req.setProvider(provider || "");
276
- req.setVersion(opts.version || "");
277
- req.setPlugindownloadurl(opts.pluginDownloadURL || "");
278
- req.setAcceptresources(!utils.disableResourceReferences);
279
- req.setPackageref(packageRefStr || "");
280
- return req;
281
- });
259
+ }
260
+ const req = new resourceproto.ResourceInvokeRequest();
261
+ req.setTok(tok);
262
+ req.setArgs(obj);
263
+ req.setProvider(provider || "");
264
+ req.setVersion(opts.version || "");
265
+ req.setPlugindownloadurl(opts.pluginDownloadURL || "");
266
+ req.setAcceptresources(!utils.disableResourceReferences);
267
+ req.setPackageref(packageRefStr || "");
268
+ return req;
282
269
  }
283
270
  function getProvider(tok, opts) {
284
271
  return opts.provider ? opts.provider : opts.parent ? opts.parent.getProvider(tok) : undefined;
285
272
  }
286
273
  function deserializeResponse(tok, resp) {
287
274
  const failures = resp.getFailuresList();
288
- if (failures === null || failures === void 0 ? void 0 : failures.length) {
275
+ if (failures?.length) {
289
276
  let reasons = "";
290
277
  for (let i = 0; i < failures.length; i++) {
291
278
  if (reasons !== "") {
@@ -322,7 +309,7 @@ function call(tok, props, res, packageRef) {
322
309
  const label = `Calling function: tok=${tok}`;
323
310
  log.debug(label + (settings_1.excessiveDebugOutput ? `, props=${JSON.stringify(props)}` : ``));
324
311
  const [out, resolver] = createOutput(`call(${tok})`);
325
- debuggable_1.debuggablePromise(Promise.resolve().then(() => __awaiter(this, void 0, void 0, function* () {
312
+ debuggable_1.debuggablePromise(Promise.resolve().then(async () => {
326
313
  const done = settings_1.rpcKeepAlive();
327
314
  try {
328
315
  // Construct a provider reference from the given provider, if one is available on the resource.
@@ -331,12 +318,12 @@ function call(tok, props, res, packageRef) {
331
318
  let pluginDownloadURL = undefined;
332
319
  if (res) {
333
320
  if (res.__prov) {
334
- provider = yield resource_1.ProviderResource.register(res.__prov);
321
+ provider = await resource_1.ProviderResource.register(res.__prov);
335
322
  }
336
323
  version = res.__version;
337
324
  pluginDownloadURL = res.__pluginDownloadURL;
338
325
  }
339
- const [serialized, propertyDepsResources] = yield rpc_1.serializePropertiesReturnDeps(`call:${tok}`, props, {
326
+ const [serialized, propertyDepsResources] = await rpc_1.serializePropertiesReturnDeps(`call:${tok}`, props, {
340
327
  // We keep output values when serializing inputs for call.
341
328
  keepOutputValues: true,
342
329
  // We exclude resource references from 'argDependencies' when serializing inputs for call.
@@ -345,9 +332,9 @@ function call(tok, props, res, packageRef) {
345
332
  excludeResourceReferencesFromDependencies: true,
346
333
  });
347
334
  log.debug(`Call RPC prepared: tok=${tok}` + settings_1.excessiveDebugOutput ? `, obj=${JSON.stringify(serialized)}` : ``);
348
- const req = yield createCallRequest(tok, serialized, propertyDepsResources, provider, version, pluginDownloadURL, packageRef);
335
+ const req = await createCallRequest(tok, serialized, propertyDepsResources, provider, version, pluginDownloadURL, packageRef);
349
336
  const monitor = settings_1.getMonitor();
350
- const resp = yield debuggable_1.debuggablePromise(new Promise((innerResolve, innerReject) => {
337
+ const resp = await debuggable_1.debuggablePromise(new Promise((innerResolve, innerReject) => {
351
338
  if (monitor === undefined) {
352
339
  throw new Error("No monitor available");
353
340
  }
@@ -398,7 +385,7 @@ function call(tok, props, res, packageRef) {
398
385
  finally {
399
386
  done();
400
387
  }
401
- })), label);
388
+ }), label);
402
389
  return out;
403
390
  }
404
391
  exports.call = call;
@@ -440,40 +427,38 @@ function createOutput(label) {
440
427
  }), `${label}Deps`));
441
428
  return [out, resolver];
442
429
  }
443
- function createCallRequest(tok, serialized, serializedDeps, provider, version, pluginDownloadURL, packageRef) {
444
- return __awaiter(this, void 0, void 0, function* () {
445
- if (provider !== undefined && typeof provider !== "string") {
446
- throw new Error("Incorrect provider type.");
447
- }
448
- const obj = gstruct.Struct.fromJavaScript(serialized);
449
- let packageRefStr = undefined;
450
- if (packageRef !== undefined) {
451
- packageRefStr = yield packageRef;
452
- if (packageRefStr !== undefined) {
453
- // If we have a package reference we can clear some of the resource options
454
- version = undefined;
455
- pluginDownloadURL = undefined;
456
- }
430
+ async function createCallRequest(tok, serialized, serializedDeps, provider, version, pluginDownloadURL, packageRef) {
431
+ if (provider !== undefined && typeof provider !== "string") {
432
+ throw new Error("Incorrect provider type.");
433
+ }
434
+ const obj = gstruct.Struct.fromJavaScript(serialized);
435
+ let packageRefStr = undefined;
436
+ if (packageRef !== undefined) {
437
+ packageRefStr = await packageRef;
438
+ if (packageRefStr !== undefined) {
439
+ // If we have a package reference we can clear some of the resource options
440
+ version = undefined;
441
+ pluginDownloadURL = undefined;
457
442
  }
458
- const req = new resourceproto.ResourceCallRequest();
459
- req.setTok(tok);
460
- req.setArgs(obj);
461
- req.setProvider(provider || "");
462
- req.setVersion(version || "");
463
- req.setPlugindownloadurl(pluginDownloadURL || "");
464
- req.setPackageref(packageRefStr || "");
465
- const argDependencies = req.getArgdependenciesMap();
466
- for (const [key, propertyDeps] of serializedDeps) {
467
- const urns = new Set();
468
- for (const dep of propertyDeps) {
469
- const urn = yield dep.urn.promise();
470
- urns.add(urn);
471
- }
472
- const deps = new resourceproto.ResourceCallRequest.ArgumentDependencies();
473
- deps.setUrnsList(Array.from(urns));
474
- argDependencies.set(key, deps);
443
+ }
444
+ const req = new resourceproto.ResourceCallRequest();
445
+ req.setTok(tok);
446
+ req.setArgs(obj);
447
+ req.setProvider(provider || "");
448
+ req.setVersion(version || "");
449
+ req.setPlugindownloadurl(pluginDownloadURL || "");
450
+ req.setPackageref(packageRefStr || "");
451
+ const argDependencies = req.getArgdependenciesMap();
452
+ for (const [key, propertyDeps] of serializedDeps) {
453
+ const urns = new Set();
454
+ for (const dep of propertyDeps) {
455
+ const urn = await dep.urn.promise();
456
+ urns.add(urn);
475
457
  }
476
- return req;
477
- });
458
+ const deps = new resourceproto.ResourceCallRequest.ArgumentDependencies();
459
+ deps.setUrnsList(Array.from(urns));
460
+ argDependencies.set(key, deps);
461
+ }
462
+ return req;
478
463
  }
479
464
  //# sourceMappingURL=invoke.js.map