@digitalocean/functions-deployer 5.0.19 → 5.0.21

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/lib/index.js CHANGED
@@ -394,6 +394,10 @@ var staticRuntimes = {
394
394
  {
395
395
  default: true,
396
396
  kind: "python:3.9"
397
+ },
398
+ {
399
+ default: false,
400
+ kind: "python:3.11"
397
401
  }
398
402
  ]
399
403
  };
@@ -2423,7 +2427,7 @@ var path4 = __toESM(require("path"));
2423
2427
  var fs4 = __toESM(require("fs"));
2424
2428
  var yaml2 = __toESM(require("js-yaml"));
2425
2429
  var import_ignore = __toESM(require("ignore"));
2426
- var import_axios3 = __toESM(require("axios"));
2430
+ var import_axios4 = __toESM(require("axios"));
2427
2431
  var import_archiver = __toESM(require("archiver"));
2428
2432
  var import_touch = __toESM(require("touch"));
2429
2433
  var import_debug7 = __toESM(require("debug"));
@@ -2435,23 +2439,15 @@ var fs3 = __toESM(require("fs"));
2435
2439
  var import_debug6 = __toESM(require("debug"));
2436
2440
  var import_adm_zip = __toESM(require("adm-zip"));
2437
2441
  var rimraf = __toESM(require("rimraf"));
2438
- var import_client_s3 = require("@aws-sdk/client-s3");
2439
2442
  var import_memory_streams = require("memory-streams");
2443
+ var import_axios3 = __toESM(require("axios"));
2444
+ var import_openwhisk = __toESM(require("openwhisk"));
2440
2445
  var debug6 = (0, import_debug6.default)("nim:deployer:slice-reader");
2441
2446
  var TEMP = process.platform === "win32" ? process.env.TEMP : "/tmp";
2442
- var bucket = process.env.BUILDER_BUCKET_NAME;
2443
- var endpoint = process.env.S3_ENDPOINT;
2444
2447
  var MAX_SLICE_UPLOAD_SIZE = parseInt(process.env.MAX_SLICE_UPLOAD_SIZE) || 64 * 1024 * 1024;
2445
- var s3Client;
2446
2448
  function cacheArea() {
2447
2449
  return path3.join(TEMP, "slices");
2448
2450
  }
2449
- function getS3Client() {
2450
- if (!s3Client) {
2451
- s3Client = new import_client_s3.S3Client({ endpoint, region: "us-east-1" });
2452
- }
2453
- return s3Client;
2454
- }
2455
2451
  function pipe(input, output) {
2456
2452
  const toWait = new Promise(function(resolve5) {
2457
2453
  output.on("close", () => {
@@ -2465,20 +2461,49 @@ function pipe(input, output) {
2465
2461
  return toWait;
2466
2462
  }
2467
2463
  async function fetchSlice(sliceName) {
2464
+ var _a, _b;
2465
+ const GET_DOWNLOAD_URL = `/${BUILDER_NAMESPACE}/builder/getDownloadUrl`;
2466
+ const credentials = getCredentialsFromEnvironment();
2467
+ const owClient = (0, import_openwhisk.default)({
2468
+ apihost: credentials.ow.apihost,
2469
+ api_key: credentials.ow.api_key,
2470
+ namespace: credentials.namespace
2471
+ });
2472
+ const invoked = await owClient.actions.invoke({
2473
+ name: GET_DOWNLOAD_URL,
2474
+ params: {
2475
+ name: sliceName
2476
+ }
2477
+ });
2478
+ const activation = await waitForActivation(
2479
+ invoked.activationId,
2480
+ owClient,
2481
+ () => {
2482
+ debug6("fetching build assets ...");
2483
+ },
2484
+ 60
2485
+ );
2486
+ if (!activation) {
2487
+ throw new Error(`Timed out fetching assets url for '${sliceName}'`);
2488
+ }
2489
+ const activationResponse = activation.response;
2490
+ const downloadUrl = (_b = (_a = activation.response) == null ? void 0 : _a.result) == null ? void 0 : _b.url;
2491
+ if (!activationResponse || !(activationResponse == null ? void 0 : activationResponse.success) || !downloadUrl) {
2492
+ throw new Error(`Failed to fetch assets url for '${sliceName}'`);
2493
+ }
2494
+ const response = await import_axios3.default.get(downloadUrl, {
2495
+ responseType: "stream"
2496
+ });
2468
2497
  const cache = path3.join(cacheArea(), sliceName);
2469
2498
  if (fs3.existsSync(cache)) {
2470
2499
  rimraf.sync(cache);
2471
2500
  }
2472
2501
  debug6("Making cache directory: %s", cache);
2473
2502
  fs3.mkdirSync(cache, { recursive: true });
2474
- const s3 = getS3Client();
2475
- const cmd = new import_client_s3.GetObjectCommand({ Bucket: bucket, Key: sliceName });
2476
- const result = await s3.send(cmd);
2477
- const content = result.Body;
2478
2503
  const destination = new import_memory_streams.WritableStream({
2479
2504
  highWaterMark: MAX_SLICE_UPLOAD_SIZE
2480
2505
  });
2481
- await pipe(content, destination);
2506
+ await pipe(response.data, destination);
2482
2507
  const data = destination.toBuffer();
2483
2508
  const zip = new import_adm_zip.default(data);
2484
2509
  debug6("zip file has %d entries", zip.getEntries().length);
@@ -2495,14 +2520,30 @@ async function fetchSlice(sliceName) {
2495
2520
  return cache;
2496
2521
  }
2497
2522
  async function deleteSlice(project) {
2523
+ const DELETE_ASSETS_URL = `/${BUILDER_NAMESPACE}/builder/deleteBuildAssets`;
2498
2524
  const sliceName = path3.relative(cacheArea(), project.filePath);
2499
- const s3 = getS3Client();
2500
- const cmd = new import_client_s3.DeleteObjectCommand({ Bucket: bucket, Key: sliceName });
2501
- await s3.send(cmd);
2525
+ const credentials = getCredentialsFromEnvironment();
2526
+ const owClient = (0, import_openwhisk.default)({
2527
+ apihost: credentials.ow.apihost,
2528
+ api_key: credentials.ow.api_key,
2529
+ namespace: credentials.namespace
2530
+ });
2531
+ const invoked = await owClient.actions.invoke({
2532
+ name: DELETE_ASSETS_URL,
2533
+ params: {
2534
+ name: sliceName
2535
+ }
2536
+ });
2537
+ await waitForActivation(
2538
+ invoked.activationId,
2539
+ owClient,
2540
+ () => debug6("removing build assets ..."),
2541
+ 60
2542
+ );
2502
2543
  }
2503
2544
 
2504
2545
  // src/finder-builder.ts
2505
- var openwhisk = require("openwhisk");
2546
+ var openwhisk2 = require("openwhisk");
2506
2547
  var debug7 = (0, import_debug7.default)("nim:deployer:finder-builder");
2507
2548
  var zipDebug = (0, import_debug7.default)("nim:deployer:zip");
2508
2549
  var ZIP_TARGET = "__deployer__.zip";
@@ -3184,7 +3225,7 @@ async function invokeRemoteBuilder(zipped, owClient, feedback, action, encryptio
3184
3225
  maxBodyLength: MAX_SLICE_UPLOAD_SIZE,
3185
3226
  maxContentLength: MAX_SLICE_UPLOAD_SIZE
3186
3227
  };
3187
- const result = await import_axios3.default.put(url, zipped, axiosConfig);
3228
+ const result = await import_axios4.default.put(url, zipped, axiosConfig);
3188
3229
  if (result.status !== 200) {
3189
3230
  throw new Error(
3190
3231
  `Bad response [$result.status}] when uploading '${sliceName}' for remote build`
@@ -3575,7 +3616,7 @@ var import_debug9 = __toESM(require("debug"));
3575
3616
  // src/file-reader.ts
3576
3617
  var fs5 = __toESM(require("fs"));
3577
3618
  var Path = __toESM(require("path"));
3578
- var import_util4 = require("util");
3619
+ var import_util5 = require("util");
3579
3620
  var import_debug8 = __toESM(require("debug"));
3580
3621
  var debug8 = (0, import_debug8.default)("nim:deployer:file-reader");
3581
3622
  var fs_readdir;
@@ -3585,11 +3626,11 @@ var fs_realpath;
3585
3626
  var fs_readlink;
3586
3627
  function makeFileReader(basepath) {
3587
3628
  debug8("making file reader on basepath '%s'", basepath);
3588
- fs_readdir = (0, import_util4.promisify)(fs5.readdir);
3589
- fs_readfile = (0, import_util4.promisify)(fs5.readFile);
3590
- fs_lstat = (0, import_util4.promisify)(fs5.lstat);
3591
- fs_realpath = (0, import_util4.promisify)(fs5.realpath);
3592
- fs_readlink = (0, import_util4.promisify)(fs5.readlink);
3629
+ fs_readdir = (0, import_util5.promisify)(fs5.readdir);
3630
+ fs_readfile = (0, import_util5.promisify)(fs5.readFile);
3631
+ fs_lstat = (0, import_util5.promisify)(fs5.lstat);
3632
+ fs_realpath = (0, import_util5.promisify)(fs5.realpath);
3633
+ fs_readlink = (0, import_util5.promisify)(fs5.readlink);
3593
3634
  return new FileProjectReader(basepath);
3594
3635
  }
3595
3636
  var FileProjectReader = class {
@@ -4116,7 +4157,7 @@ var IncluderImpl = class {
4116
4157
 
4117
4158
  // src/api.ts
4118
4159
  var import_debug11 = __toESM(require("debug"));
4119
- var openwhisk2 = require("openwhisk");
4160
+ var openwhisk3 = require("openwhisk");
4120
4161
  var debug11 = (0, import_debug11.default)("nim:deployer:api");
4121
4162
  function initializeAPI(userAgent) {
4122
4163
  const result = {};
@@ -4300,7 +4341,7 @@ async function prepareToDeploy(inputSpec, credentials, flags) {
4300
4341
  inputSpec.flags = flags;
4301
4342
  debug11("Options merged");
4302
4343
  debug11("Auth sufficiency established");
4303
- inputSpec.owClient = openwhisk2(wskoptions);
4344
+ inputSpec.owClient = openwhisk3(wskoptions);
4304
4345
  if (!credentials.namespace) {
4305
4346
  credentials.namespace = await getTargetNamespace(inputSpec.owClient);
4306
4347
  } else {
@@ -4321,7 +4362,7 @@ async function wipeNamespace(credentials) {
4321
4362
  apihost: credentials.ow.apihost,
4322
4363
  api_key: credentials.ow.api_key
4323
4364
  };
4324
- const client = openwhisk2(init);
4365
+ const client = openwhisk3(init);
4325
4366
  debug11("Client opened");
4326
4367
  return wipe(client, credentials);
4327
4368
  }
@@ -4404,7 +4445,7 @@ var import_http = require("http");
4404
4445
  var import_debug12 = __toESM(require("debug"));
4405
4446
 
4406
4447
  // src/version.ts
4407
- var version = "5.0.19";
4448
+ var version = "5.0.21";
4408
4449
 
4409
4450
  // src/main.ts
4410
4451
  var verboseError = (0, import_debug12.default)("nim:error");