Socket
Socket
Sign inDemoInstall

@pulumi/pulumi

Package Overview
Dependencies
Maintainers
2
Versions
4388
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@pulumi/pulumi - npm Package Compare versions

Comparing version 3.125.0-alpha.x584ff1c to 3.125.0-alpha.x6215d96

44

invoke.d.ts

@@ -0,1 +1,2 @@

import { Inputs } from "./output";
import { ProviderResource, Resource } from "./resource";

@@ -37,1 +38,44 @@ /**

}
/**
* {@link InvokeTransform} is the callback signature for the `transforms`
* resource option for invokes. A transform is passed the same set of inputs
* provided to the {@link Invoke} constructor, and can optionally return back
* alternate values for the `args` and/or `opts` prior to the invoke actually
* being executed. The effect will be as though those args and opts were passed
* in place of the original call to the {@link Invoke}. If the transform
* returns nil, this indicates
* that the Invoke
*/
export declare type InvokeTransform = (args: InvokeTransformArgs) => Promise<InvokeTransformResult | undefined> | InvokeTransformResult | undefined;
/**
* {@link InvokeTransformArgs} is the argument bag passed to a invoke transform.
*/
export interface InvokeTransformArgs {
/**
* The token of the Invoke.
*/
token: string;
/**
* The original args passed to the Invoke constructor.
*/
args: Inputs;
/**
* The original invoke options passed to the Invoke constructor.
*/
opts: InvokeOptions;
}
/**
* {@link InvokeTransformResult} is the result that must be returned by an invoke
* transform callback. It includes new values to use for the `args` and `opts`
* of the `Invoke` in place of the originally provided values.
*/
export interface InvokeTransformResult {
/**
* The new properties to use in place of the original `args`
*/
args: Inputs;
/**
* The new resource options to use in place of the original `opts`
*/
opts: InvokeOptions;
}

2

package.json
{
"name": "@pulumi/pulumi",
"version": "3.125.0-alpha.x584ff1c",
"version": "3.125.0-alpha.x6215d96",
"description": "Pulumi's Node.js SDK",

@@ -5,0 +5,0 @@ "license": "Apache-2.0",

@@ -315,3 +315,3 @@ import { Input, Inputs, Output } from "./output";

* {@link ResourceTransformResult} is the result that must be returned by a
* resource transformation callback. It includes new values to use for the
* resource transform callback. It includes new values to use for the
* `props` and `opts` of the {@link Resource} in place of the originally

@@ -318,0 +318,0 @@ * provided values.

import * as callproto from "../proto/callback_pb";
import * as resrpc from "../proto/resource_grpc_pb";
import { ResourceTransform } from "../resource";
import { InvokeTransform } from "../invoke";
export interface ICallbackServer {
registerTransform(callback: ResourceTransform): Promise<callproto.Callback>;
registerStackTransform(callback: ResourceTransform): void;
registerStackInvokeTransform(callback: InvokeTransform): void;
registerStackInvokeTransformAsync(callback: InvokeTransform): Promise<callproto.Callback>;
shutdown(): void;

@@ -23,2 +26,4 @@ awaitStackRegistrations(): Promise<void>;

registerStackTransform(transform: ResourceTransform): void;
registerStackInvokeTransformAsync(transform: InvokeTransform): Promise<callproto.Callback>;
registerStackInvokeTransform(transform: InvokeTransform): void;
}

@@ -367,4 +367,91 @@ "use strict";

}
registerStackInvokeTransformAsync(transform) {
return __awaiter(this, void 0, void 0, function* () {
const cb = (bytes) => __awaiter(this, void 0, void 0, function* () {
const request = resproto.TransformInvokeRequest.deserializeBinary(bytes);
let opts = request.getOptions() || new resproto.TransformInvokeOptions();
const ropts = {};
ropts.pluginDownloadURL = opts.getPluginDownloadUrl() !== "" ? opts.getPluginDownloadUrl() : undefined;
ropts.provider = opts.getProvider() !== "" ? new resource_1.DependencyProviderResource(opts.getProvider()) : undefined;
ropts.version = opts.getVersion() !== "" ? opts.getVersion() : undefined;
const invokeArgs = request.getArgs();
const args = {
token: request.getToken(),
args: invokeArgs === undefined ? {} : rpc_1.deserializeProperties(invokeArgs),
opts: ropts,
};
const result = yield transform(args);
const response = new resproto.TransformInvokeResponse();
if (result === undefined) {
response.setArgs(request.getArgs());
response.setOptions(request.getOptions());
}
else {
const margs = yield rpc_1.serializeProperties("args", result.args);
response.setArgs(gstruct.Struct.fromJavaScript(margs));
// Copy the options over.
if (result.opts !== undefined) {
opts = new resproto.TransformInvokeOptions();
if (result.opts.pluginDownloadURL !== undefined) {
opts.setPluginDownloadUrl(result.opts.pluginDownloadURL);
}
if (result.opts.provider !== undefined) {
const providerURN = yield result.opts.provider.urn.promise();
const providerID = (yield result.opts.provider.id.promise()) || rpc_1.unknownValue;
opts.setProvider(`${providerURN}::${providerID}`);
}
if (result.opts.version !== undefined) {
opts.setVersion(result.opts.version);
}
response.setOptions(opts);
}
}
return response;
});
const tryCb = (bytes) => __awaiter(this, void 0, void 0, function* () {
try {
return yield cb(bytes);
}
catch (e) {
throw new Error(`transform failed: ${e}`);
}
});
const uuid = crypto_1.randomUUID();
this._callbacks.set(uuid, tryCb);
const req = new callback_pb_1.Callback();
req.setToken(uuid);
req.setTarget(yield this._target);
return req;
});
}
registerStackInvokeTransform(transform) {
this._pendingRegistrations++;
this.registerStackInvokeTransformAsync(transform)
.then((req) => {
return new Promise((resolve, reject) => {
this._monitor.registerStackInvokeTransform(req, (err, _) => {
if (err !== null) {
// Remove this from the list of callbacks given we didn't manage to actually register it.
this._callbacks.delete(req.getToken());
reject();
}
else {
resolve();
}
});
});
}, (err) => log.error(`failed to register stack transform: ${err}`))
.finally(() => {
this._pendingRegistrations--;
if (this._pendingRegistrations === 0) {
const queue = this._awaitQueue;
this._awaitQueue = [];
for (const waiter of queue) {
waiter();
}
}
});
}
}
exports.CallbackServer = CallbackServer;
//# sourceMappingURL=callbacks.js.map

@@ -141,2 +141,3 @@ "use strict";

log.debug(label + (settings_1.excessiveDebugOutput ? `, props=${JSON.stringify(props)}` : ``));
yield settings_1.awaitStackRegistrations();
// Wait for all values to be available, and then perform the RPC.

@@ -143,0 +144,0 @@ const done = settings_1.rpcKeepAlive();

@@ -86,2 +86,3 @@ "use strict";

store.supportsTransforms = false;
store.supportsInvokeTransforms = false;
store.callbacks = undefined;

@@ -161,2 +162,3 @@ }

store.supportsTransforms = yield monitorSupportsFeature(monitorRef, "transforms");
store.supportsInvokeTransforms = yield monitorSupportsFeature(monitorRef, "invokeTransforms");
}

@@ -163,0 +165,0 @@ });

import { Inputs, Output } from "../output";
import { ComponentResource, ResourceTransform, ResourceTransformation } from "../resource";
import { InvokeTransform } from "../invoke";
/**

@@ -56,2 +57,6 @@ * The type name that should be used to construct the root component in the tree

export declare function registerStackTransform(t: ResourceTransform): void;
/**
* Add a transformation to all future invoke calls in this Pulumi stack.
*/
export declare function registerInvokeTransform(t: InvokeTransform): void;
export declare function getStackResource(): Stack | undefined;

@@ -258,2 +258,16 @@ "use strict";

exports.registerStackTransform = registerStackTransform;
/**
* Add a transformation to all future invoke calls in this Pulumi stack.
*/
function registerInvokeTransform(t) {
if (!state_1.getStore().supportsInvokeTransforms) {
throw new Error("The Pulumi CLI does not support transforms. Please update the Pulumi CLI");
}
const callbacks = settings_1.getCallbacks();
if (!callbacks) {
throw new Error("No callback server registered.");
}
callbacks.registerStackInvokeTransform(t);
}
exports.registerInvokeTransform = registerInvokeTransform;
function getStackResource() {

@@ -260,0 +274,0 @@ return state_1.getStackResource();

@@ -84,2 +84,3 @@ "use strict";

this.supportsTransforms = false;
this.supportsInvokeTransforms = false;
}

@@ -86,0 +87,0 @@ }

@@ -16,3 +16,3 @@ "use strict";

Object.defineProperty(exports, "__esModule", { value: true });
exports.version = "3.125.0-alpha.x584ff1c";
exports.version = "3.125.0-alpha.x6215d96";
//# sourceMappingURL=version.js.map

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc