wrangler 4.4.1 → 4.5.0

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "wrangler",
3
- "version": "4.4.1",
3
+ "version": "4.5.0",
4
4
  "description": "Command-line interface for all things Cloudflare Workers",
5
5
  "keywords": [
6
6
  "wrangler",
@@ -50,7 +50,7 @@
50
50
  "config-schema.json"
51
51
  ],
52
52
  "dependencies": {
53
- "@cloudflare/unenv-preset": "2.3.0",
53
+ "@cloudflare/unenv-preset": "2.3.1",
54
54
  "blake3-wasm": "2.1.5",
55
55
  "esbuild": "0.24.2",
56
56
  "path-to-regexp": "6.3.0",
@@ -81185,7 +81185,7 @@ var import_undici3 = __toESM(require_undici());
81185
81185
 
81186
81186
  // package.json
81187
81187
  var name = "wrangler";
81188
- var version = "4.4.1";
81188
+ var version = "4.5.0";
81189
81189
 
81190
81190
  // src/environment-variables/misc-variables.ts
81191
81191
  init_import_meta_url();
@@ -83884,7 +83884,8 @@ function printBindings(bindings, context2 = {}) {
83884
83884
  wasm_modules,
83885
83885
  dispatch_namespaces,
83886
83886
  mtls_certificates,
83887
- pipelines: pipelines2
83887
+ pipelines: pipelines2,
83888
+ assets
83888
83889
  } = bindings;
83889
83890
  if (data_blobs !== void 0 && Object.keys(data_blobs).length > 0) {
83890
83891
  output.push({
@@ -84141,6 +84142,12 @@ function printBindings(bindings, context2 = {}) {
84141
84142
  }))
84142
84143
  });
84143
84144
  }
84145
+ if (assets !== void 0) {
84146
+ output.push({
84147
+ name: friendlyBindingNames.assets,
84148
+ entries: [{ key: "Binding", value: assets.binding }]
84149
+ });
84150
+ }
84144
84151
  if (version_metadata !== void 0) {
84145
84152
  output.push({
84146
84153
  name: friendlyBindingNames.version_metadata,
@@ -99624,6 +99631,19 @@ function logBulkProgress(operation, index, total) {
99624
99631
  );
99625
99632
  }
99626
99633
  __name(logBulkProgress, "logBulkProgress");
99634
+ async function getKVBulkKeyValue(accountId, namespaceId, keys) {
99635
+ const requestPayload = { keys };
99636
+ const result = await fetchResult(
99637
+ `/accounts/${accountId}/storage/kv/namespaces/${namespaceId}/bulk/get`,
99638
+ {
99639
+ method: "POST",
99640
+ body: JSON.stringify(requestPayload),
99641
+ headers: { "Content-Type": "application/json" }
99642
+ }
99643
+ );
99644
+ return result.values;
99645
+ }
99646
+ __name(getKVBulkKeyValue, "getKVBulkKeyValue");
99627
99647
  async function putKVBulkKeyValue(accountId, namespaceId, keyValues, quiet = false, abortSignal) {
99628
99648
  for (let index = 0; index < keyValues.length; index += BATCH_KEY_MAX) {
99629
99649
  if (!quiet && keyValues.length > BATCH_KEY_MAX) {
@@ -118478,7 +118498,7 @@ var kvNamespaceDeleteCommand = createCommand({
118478
118498
  binding: {
118479
118499
  type: "string",
118480
118500
  requiresArg: true,
118481
- describe: "The name of the namespace to delete"
118501
+ describe: "The binding name to the namespace to delete from"
118482
118502
  },
118483
118503
  "namespace-id": {
118484
118504
  type: "string",
@@ -118532,7 +118552,7 @@ var kvKeyPutCommand = createCommand({
118532
118552
  binding: {
118533
118553
  type: "string",
118534
118554
  requiresArg: true,
118535
- describe: "The binding of the namespace to write to"
118555
+ describe: "The binding name to the namespace to write to"
118536
118556
  },
118537
118557
  "namespace-id": {
118538
118558
  type: "string",
@@ -118641,7 +118661,7 @@ var kvKeyListCommand = createCommand({
118641
118661
  binding: {
118642
118662
  type: "string",
118643
118663
  requiresArg: true,
118644
- describe: "The name of the namespace to list"
118664
+ describe: "The binding name to the namespace to list"
118645
118665
  },
118646
118666
  "namespace-id": {
118647
118667
  type: "string",
@@ -118719,7 +118739,7 @@ var kvKeyGetCommand = createCommand({
118719
118739
  binding: {
118720
118740
  type: "string",
118721
118741
  requiresArg: true,
118722
- describe: "The name of the namespace to get from"
118742
+ describe: "The binding name to the namespace to get from"
118723
118743
  },
118724
118744
  "namespace-id": {
118725
118745
  type: "string",
@@ -118811,7 +118831,7 @@ var kvKeyDeleteCommand = createCommand({
118811
118831
  binding: {
118812
118832
  type: "string",
118813
118833
  requiresArg: true,
118814
- describe: "The name of the namespace to delete from"
118834
+ describe: "The binding name to the namespace to delete from"
118815
118835
  },
118816
118836
  "namespace-id": {
118817
118837
  type: "string",
@@ -118860,6 +118880,110 @@ var kvKeyDeleteCommand = createCommand({
118860
118880
  });
118861
118881
  }
118862
118882
  });
118883
+ var kvBulkGetCommand = createCommand({
118884
+ metadata: {
118885
+ description: "Gets multiple key-value pairs from a namespace",
118886
+ status: "open-beta",
118887
+ owner: "Product: KV"
118888
+ },
118889
+ positionalArgs: ["filename"],
118890
+ args: {
118891
+ filename: {
118892
+ describe: "The file containing the keys to get",
118893
+ type: "string",
118894
+ demandOption: true
118895
+ },
118896
+ binding: {
118897
+ type: "string",
118898
+ requiresArg: true,
118899
+ describe: "The binding name to the namespace to get from"
118900
+ },
118901
+ "namespace-id": {
118902
+ type: "string",
118903
+ requiresArg: true,
118904
+ describe: "The id of the namespace to get from"
118905
+ },
118906
+ preview: {
118907
+ type: "boolean",
118908
+ describe: "Interact with a preview namespace"
118909
+ },
118910
+ local: {
118911
+ type: "boolean",
118912
+ describe: "Interact with local storage"
118913
+ },
118914
+ remote: {
118915
+ type: "boolean",
118916
+ describe: "Interact with remote storage",
118917
+ conflicts: "local"
118918
+ },
118919
+ "persist-to": {
118920
+ type: "string",
118921
+ describe: "Directory for local persistence"
118922
+ }
118923
+ },
118924
+ async handler({ filename, ...args }) {
118925
+ const localMode = isLocal(args);
118926
+ const config = readConfig(args);
118927
+ const namespaceId = getKVNamespaceId(args, config);
118928
+ const content = parseJSON(readFileSync6(filename), filename);
118929
+ if (!Array.isArray(content)) {
118930
+ throw new UserError(
118931
+ `Unexpected JSON input from "${filename}".
118932
+ Expected an array of strings but got:
118933
+ ${content}`
118934
+ );
118935
+ }
118936
+ const errors = [];
118937
+ const keysToGet = [];
118938
+ for (const [index, item] of content.entries()) {
118939
+ const key = typeof item !== "string" ? item?.name : item;
118940
+ if (typeof key !== "string") {
118941
+ errors.push(
118942
+ `The item at index ${index} is type: "${typeof item}" - ${JSON.stringify(
118943
+ item
118944
+ )}`
118945
+ );
118946
+ continue;
118947
+ }
118948
+ keysToGet.push(key);
118949
+ }
118950
+ if (errors.length > 0) {
118951
+ throw new UserError(
118952
+ `Unexpected JSON input from "${filename}".
118953
+ Expected an array of strings or objects with a "name" key.
118954
+ ` + errors.join("\n")
118955
+ );
118956
+ }
118957
+ if (localMode) {
118958
+ const result = await usingLocalNamespace(
118959
+ args.persistTo,
118960
+ config,
118961
+ namespaceId,
118962
+ async (namespace) => {
118963
+ const out = {};
118964
+ for (const key of keysToGet) {
118965
+ const value = await namespace.get(key, "text");
118966
+ out[key] = {
118967
+ value
118968
+ };
118969
+ }
118970
+ return out;
118971
+ }
118972
+ );
118973
+ logger.log(JSON.stringify(result, null, 2));
118974
+ } else {
118975
+ const accountId = await requireAuth(config);
118976
+ logger.log(
118977
+ JSON.stringify(
118978
+ await getKVBulkKeyValue(accountId, namespaceId, keysToGet),
118979
+ null,
118980
+ 2
118981
+ )
118982
+ );
118983
+ }
118984
+ logger.log("\nSuccess!");
118985
+ }
118986
+ });
118863
118987
  var kvBulkPutCommand = createCommand({
118864
118988
  metadata: {
118865
118989
  description: "Upload multiple key-value pairs to a namespace",
@@ -118876,7 +119000,7 @@ var kvBulkPutCommand = createCommand({
118876
119000
  binding: {
118877
119001
  type: "string",
118878
119002
  requiresArg: true,
118879
- describe: "The name of the namespace to write to"
119003
+ describe: "The binding name to the namespace to write to"
118880
119004
  },
118881
119005
  "namespace-id": {
118882
119006
  type: "string",
@@ -119018,7 +119142,7 @@ var kvBulkDeleteCommand = createCommand({
119018
119142
  binding: {
119019
119143
  type: "string",
119020
119144
  requiresArg: true,
119021
- describe: "The name of the namespace to delete from"
119145
+ describe: "The binding name to the namespace to delete from"
119022
119146
  },
119023
119147
  "namespace-id": {
119024
119148
  type: "string",
@@ -149297,6 +149421,7 @@ function createCLIParser(argv) {
149297
149421
  { command: "wrangler kv key list", definition: kvKeyListCommand },
149298
149422
  { command: "wrangler kv key get", definition: kvKeyGetCommand },
149299
149423
  { command: "wrangler kv key delete", definition: kvKeyDeleteCommand },
149424
+ { command: "wrangler kv bulk get", definition: kvBulkGetCommand },
149300
149425
  { command: "wrangler kv bulk put", definition: kvBulkPutCommand },
149301
149426
  { command: "wrangler kv bulk delete", definition: kvBulkDeleteCommand }
149302
149427
  ]);
@@ -154886,4 +155011,3 @@ yargs-parser/build/lib/index.js:
154886
155011
  * SPDX-License-Identifier: ISC
154887
155012
  *)
154888
155013
  */
154889
- //# sourceMappingURL=cli.js.map