wrangler 2.0.3 → 2.0.7

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.
@@ -48,10 +48,7 @@ describe("wrangler", () => {
48
48
  );
49
49
  expect(std.out).toMatchInlineSnapshot(`
50
50
  "
51
- "
52
- `);
53
- expect(std.err).toMatchInlineSnapshot(`
54
- "wrangler kv:namespace create <namespace>
51
+ wrangler kv:namespace create <namespace>
55
52
 
56
53
  Create a new namespace
57
54
 
@@ -65,8 +62,10 @@ describe("wrangler", () => {
65
62
 
66
63
  Options:
67
64
  -e, --env Perform on a specific environment [string]
68
- --preview Interact with a preview namespace [boolean]
69
- X [ERROR] Not enough non-option arguments: got 0, need at least 1
65
+ --preview Interact with a preview namespace [boolean]"
66
+ `);
67
+ expect(std.err).toMatchInlineSnapshot(`
68
+ "X [ERROR] Not enough non-option arguments: got 0, need at least 1
70
69
 
71
70
  "
72
71
  `);
@@ -80,10 +79,7 @@ describe("wrangler", () => {
80
79
  );
81
80
  expect(std.out).toMatchInlineSnapshot(`
82
81
  "
83
- "
84
- `);
85
- expect(std.err).toMatchInlineSnapshot(`
86
- "wrangler kv:namespace create <namespace>
82
+ wrangler kv:namespace create <namespace>
87
83
 
88
84
  Create a new namespace
89
85
 
@@ -97,8 +93,10 @@ describe("wrangler", () => {
97
93
 
98
94
  Options:
99
95
  -e, --env Perform on a specific environment [string]
100
- --preview Interact with a preview namespace [boolean]
101
- X [ERROR] Unknown arguments: def, ghi
96
+ --preview Interact with a preview namespace [boolean]"
97
+ `);
98
+ expect(std.err).toMatchInlineSnapshot(`
99
+ "X [ERROR] Unknown arguments: def, ghi
102
100
 
103
101
  "
104
102
  `);
@@ -113,10 +111,7 @@ describe("wrangler", () => {
113
111
 
114
112
  expect(std.out).toMatchInlineSnapshot(`
115
113
  "
116
- "
117
- `);
118
- expect(std.err).toMatchInlineSnapshot(`
119
- "wrangler kv:namespace create <namespace>
114
+ wrangler kv:namespace create <namespace>
120
115
 
121
116
  Create a new namespace
122
117
 
@@ -130,8 +125,10 @@ describe("wrangler", () => {
130
125
 
131
126
  Options:
132
127
  -e, --env Perform on a specific environment [string]
133
- --preview Interact with a preview namespace [boolean]
134
- X [ERROR] The namespace binding name \\"abc-def\\" is invalid. It can only have alphanumeric and _ characters, and cannot begin with a number.
128
+ --preview Interact with a preview namespace [boolean]"
129
+ `);
130
+ expect(std.err).toMatchInlineSnapshot(`
131
+ "X [ERROR] The namespace binding name \\"abc-def\\" is invalid. It can only have alphanumeric and _ characters, and cannot begin with a number.
135
132
 
136
133
  "
137
134
  `);
@@ -257,14 +254,6 @@ describe("wrangler", () => {
257
254
  expect(requests.count).toEqual(1);
258
255
  });
259
256
 
260
- it("should encode URI id properly for deleting namespace", async () => {
261
- const requests = mockDeleteRequest("%2Fvoyager");
262
- await runWrangler(`kv:namespace delete --namespace-id /voyager`);
263
- expect(requests.count).toEqual(1);
264
- expect(std.out).toMatchInlineSnapshot(`""`);
265
- expect(std.err).toMatchInlineSnapshot(`""`);
266
- });
267
-
268
257
  it("should delete a namespace specified by binding name", async () => {
269
258
  writeWranglerConfig();
270
259
  const requests = mockDeleteRequest("bound-id");
@@ -291,21 +280,7 @@ describe("wrangler", () => {
291
280
  A namespace with binding name \\"otherBinding\\" was not found in the configured \\"kv_namespaces\\"."
292
281
  `);
293
282
  expect(std.err).toMatchInlineSnapshot(`
294
- "wrangler kv:namespace delete
295
-
296
- Deletes a given namespace.
297
-
298
- Flags:
299
- -c, --config Path to .toml configuration file [string]
300
- -h, --help Show help [boolean]
301
- -v, --version Show version number [boolean]
302
-
303
- Options:
304
- --binding The name of the namespace to delete [string]
305
- --namespace-id The id of the namespace to delete [string]
306
- -e, --env Perform on a specific environment [string]
307
- --preview Interact with a preview namespace [boolean]
308
- X [ERROR] Not able to delete namespace.
283
+ "X [ERROR] Not able to delete namespace.
309
284
 
310
285
  A namespace with binding name \\"otherBinding\\" was not found in the configured \\"kv_namespaces\\".
311
286
 
@@ -389,7 +364,7 @@ describe("wrangler", () => {
389
364
  expect(std.err).toMatchInlineSnapshot(`""`);
390
365
  });
391
366
 
392
- it("should encode URI key's properly for putting in a key request", async () => {
367
+ it("should encode the key in the api request to put a value", async () => {
393
368
  const requests = mockKeyPutRequest("DS9", {
394
369
  key: "%2Fmy-key",
395
370
  value: "my-value",
@@ -497,10 +472,7 @@ describe("wrangler", () => {
497
472
 
498
473
  expect(std.out).toMatchInlineSnapshot(`
499
474
  "
500
- "
501
- `);
502
- expect(std.err).toMatchInlineSnapshot(`
503
- "wrangler kv:key put <key> [value]
475
+ wrangler kv:key put <key> [value]
504
476
 
505
477
  Writes a single key/value pair to the given namespace.
506
478
 
@@ -520,8 +492,10 @@ describe("wrangler", () => {
520
492
  --preview Interact with a preview namespace [boolean]
521
493
  --ttl Time for which the entries should be visible [number]
522
494
  --expiration Time since the UNIX epoch after which the entry expires [number]
523
- --path Read value from the file at a given path [string]
524
- X [ERROR] Not enough non-option arguments: got 0, need at least 1
495
+ --path Read value from the file at a given path [string]"
496
+ `);
497
+ expect(std.err).toMatchInlineSnapshot(`
498
+ "X [ERROR] Not enough non-option arguments: got 0, need at least 1
525
499
 
526
500
  "
527
501
  `);
@@ -536,10 +510,7 @@ describe("wrangler", () => {
536
510
 
537
511
  expect(std.out).toMatchInlineSnapshot(`
538
512
  "
539
- "
540
- `);
541
- expect(std.err).toMatchInlineSnapshot(`
542
- "wrangler kv:key put <key> [value]
513
+ wrangler kv:key put <key> [value]
543
514
 
544
515
  Writes a single key/value pair to the given namespace.
545
516
 
@@ -559,8 +530,10 @@ describe("wrangler", () => {
559
530
  --preview Interact with a preview namespace [boolean]
560
531
  --ttl Time for which the entries should be visible [number]
561
532
  --expiration Time since the UNIX epoch after which the entry expires [number]
562
- --path Read value from the file at a given path [string]
563
- X [ERROR] Exactly one of the arguments binding and namespace-id is required
533
+ --path Read value from the file at a given path [string]"
534
+ `);
535
+ expect(std.err).toMatchInlineSnapshot(`
536
+ "X [ERROR] Exactly one of the arguments binding and namespace-id is required
564
537
 
565
538
  "
566
539
  `);
@@ -575,10 +548,7 @@ describe("wrangler", () => {
575
548
 
576
549
  expect(std.out).toMatchInlineSnapshot(`
577
550
  "
578
- "
579
- `);
580
- expect(std.err).toMatchInlineSnapshot(`
581
- "wrangler kv:key put <key> [value]
551
+ wrangler kv:key put <key> [value]
582
552
 
583
553
  Writes a single key/value pair to the given namespace.
584
554
 
@@ -598,8 +568,10 @@ describe("wrangler", () => {
598
568
  --preview Interact with a preview namespace [boolean]
599
569
  --ttl Time for which the entries should be visible [number]
600
570
  --expiration Time since the UNIX epoch after which the entry expires [number]
601
- --path Read value from the file at a given path [string]
602
- X [ERROR] Arguments binding and namespace-id are mutually exclusive
571
+ --path Read value from the file at a given path [string]"
572
+ `);
573
+ expect(std.err).toMatchInlineSnapshot(`
574
+ "X [ERROR] Arguments binding and namespace-id are mutually exclusive
603
575
 
604
576
  "
605
577
  `);
@@ -614,10 +586,7 @@ describe("wrangler", () => {
614
586
 
615
587
  expect(std.out).toMatchInlineSnapshot(`
616
588
  "
617
- "
618
- `);
619
- expect(std.err).toMatchInlineSnapshot(`
620
- "wrangler kv:key put <key> [value]
589
+ wrangler kv:key put <key> [value]
621
590
 
622
591
  Writes a single key/value pair to the given namespace.
623
592
 
@@ -637,8 +606,10 @@ describe("wrangler", () => {
637
606
  --preview Interact with a preview namespace [boolean]
638
607
  --ttl Time for which the entries should be visible [number]
639
608
  --expiration Time since the UNIX epoch after which the entry expires [number]
640
- --path Read value from the file at a given path [string]
641
- X [ERROR] Exactly one of the arguments value and path is required
609
+ --path Read value from the file at a given path [string]"
610
+ `);
611
+ expect(std.err).toMatchInlineSnapshot(`
612
+ "X [ERROR] Exactly one of the arguments value and path is required
642
613
 
643
614
  "
644
615
  `);
@@ -653,10 +624,7 @@ describe("wrangler", () => {
653
624
 
654
625
  expect(std.out).toMatchInlineSnapshot(`
655
626
  "
656
- "
657
- `);
658
- expect(std.err).toMatchInlineSnapshot(`
659
- "wrangler kv:key put <key> [value]
627
+ wrangler kv:key put <key> [value]
660
628
 
661
629
  Writes a single key/value pair to the given namespace.
662
630
 
@@ -676,8 +644,10 @@ describe("wrangler", () => {
676
644
  --preview Interact with a preview namespace [boolean]
677
645
  --ttl Time for which the entries should be visible [number]
678
646
  --expiration Time since the UNIX epoch after which the entry expires [number]
679
- --path Read value from the file at a given path [string]
680
- X [ERROR] Arguments value and path are mutually exclusive
647
+ --path Read value from the file at a given path [string]"
648
+ `);
649
+ expect(std.err).toMatchInlineSnapshot(`
650
+ "X [ERROR] Arguments value and path are mutually exclusive
681
651
 
682
652
  "
683
653
  `);
@@ -951,6 +921,20 @@ describe("wrangler", () => {
951
921
  expect(std.err).toMatchInlineSnapshot(`""`);
952
922
  });
953
923
 
924
+ it("should encode the key in the api request to get a value", async () => {
925
+ setMockFetchKVGetValue(
926
+ "some-account-id",
927
+ "some-namespace-id",
928
+ "%2Fmy%2Ckey",
929
+ "my-value"
930
+ );
931
+ await runWrangler(
932
+ "kv:key get /my,key --namespace-id some-namespace-id"
933
+ );
934
+ expect(std.out).toMatchInlineSnapshot(`"my-value"`);
935
+ expect(std.err).toMatchInlineSnapshot(`""`);
936
+ });
937
+
954
938
  it("should error if no key is provided", async () => {
955
939
  await expect(
956
940
  runWrangler("kv:key get")
@@ -959,10 +943,7 @@ describe("wrangler", () => {
959
943
  );
960
944
  expect(std.out).toMatchInlineSnapshot(`
961
945
  "
962
- "
963
- `);
964
- expect(std.err).toMatchInlineSnapshot(`
965
- "wrangler kv:key get <key>
946
+ wrangler kv:key get <key>
966
947
 
967
948
  Reads a single value by key from the given namespace.
968
949
 
@@ -978,8 +959,10 @@ describe("wrangler", () => {
978
959
  --binding The name of the namespace to get from [string]
979
960
  --namespace-id The id of the namespace to get from [string]
980
961
  -e, --env Perform on a specific environment [string]
981
- --preview Interact with a preview namespace [boolean] [default: false]
982
- X [ERROR] Not enough non-option arguments: got 0, need at least 1
962
+ --preview Interact with a preview namespace [boolean] [default: false]"
963
+ `);
964
+ expect(std.err).toMatchInlineSnapshot(`
965
+ "X [ERROR] Not enough non-option arguments: got 0, need at least 1
983
966
 
984
967
  "
985
968
  `);
@@ -993,10 +976,7 @@ describe("wrangler", () => {
993
976
  );
994
977
  expect(std.out).toMatchInlineSnapshot(`
995
978
  "
996
- "
997
- `);
998
- expect(std.err).toMatchInlineSnapshot(`
999
- "wrangler kv:key get <key>
979
+ wrangler kv:key get <key>
1000
980
 
1001
981
  Reads a single value by key from the given namespace.
1002
982
 
@@ -1012,8 +992,10 @@ describe("wrangler", () => {
1012
992
  --binding The name of the namespace to get from [string]
1013
993
  --namespace-id The id of the namespace to get from [string]
1014
994
  -e, --env Perform on a specific environment [string]
1015
- --preview Interact with a preview namespace [boolean] [default: false]
1016
- X [ERROR] Exactly one of the arguments binding and namespace-id is required
995
+ --preview Interact with a preview namespace [boolean] [default: false]"
996
+ `);
997
+ expect(std.err).toMatchInlineSnapshot(`
998
+ "X [ERROR] Exactly one of the arguments binding and namespace-id is required
1017
999
 
1018
1000
  "
1019
1001
  `);
@@ -1028,10 +1010,7 @@ describe("wrangler", () => {
1028
1010
 
1029
1011
  expect(std.out).toMatchInlineSnapshot(`
1030
1012
  "
1031
- "
1032
- `);
1033
- expect(std.err).toMatchInlineSnapshot(`
1034
- "wrangler kv:key get <key>
1013
+ wrangler kv:key get <key>
1035
1014
 
1036
1015
  Reads a single value by key from the given namespace.
1037
1016
 
@@ -1047,8 +1026,10 @@ describe("wrangler", () => {
1047
1026
  --binding The name of the namespace to get from [string]
1048
1027
  --namespace-id The id of the namespace to get from [string]
1049
1028
  -e, --env Perform on a specific environment [string]
1050
- --preview Interact with a preview namespace [boolean] [default: false]
1051
- X [ERROR] Arguments binding and namespace-id are mutually exclusive
1029
+ --preview Interact with a preview namespace [boolean] [default: false]"
1030
+ `);
1031
+ expect(std.err).toMatchInlineSnapshot(`
1032
+ "X [ERROR] Arguments binding and namespace-id are mutually exclusive
1052
1033
 
1053
1034
  "
1054
1035
  `);
@@ -1101,7 +1082,7 @@ describe("wrangler", () => {
1101
1082
  expect(requests.count).toEqual(1);
1102
1083
  });
1103
1084
 
1104
- it("should encode the URI properly for deleting a key requests", async () => {
1085
+ it("should encode the key in the api request to delete a value", async () => {
1105
1086
  const requests = mockDeleteRequest("voyager", "%2FNCC-74656");
1106
1087
  await runWrangler(`kv:key delete --namespace-id voyager /NCC-74656`);
1107
1088
  expect(requests.count).toEqual(1);
@@ -1224,10 +1205,10 @@ describe("wrangler", () => {
1224
1205
  );
1225
1206
  expect(requests.count).toEqual(3);
1226
1207
  expect(std.out).toMatchInlineSnapshot(`
1227
- "Uploaded 0 of 12000.
1228
- Uploaded 5000 of 12000.
1229
- Uploaded 10000 of 12000.
1230
- Uploaded 12000 of 12000.
1208
+ "Uploaded 0% (0 out of 12,000)
1209
+ Uploaded 41% (5,000 out of 12,000)
1210
+ Uploaded 83% (10,000 out of 12,000)
1211
+ Uploaded 100% (12,000 out of 12,000)
1231
1212
  Success!"
1232
1213
  `);
1233
1214
  expect(std.warn).toMatchInlineSnapshot(`""`);
@@ -1256,7 +1237,25 @@ describe("wrangler", () => {
1256
1237
  "a string",
1257
1238
  { key: "someKey" },
1258
1239
  { value: "someValue" },
1240
+ // add a valid object here to make sure it's not included
1241
+ { key: "someKey1", value: "someValue1" },
1242
+ // this one will only add a warning
1259
1243
  { key: "someKey1", value: "someValue1", invalid: true },
1244
+ // back to the invalid ones
1245
+ { key: 123, value: "somevalue" },
1246
+ { key: "somekey", value: 123 },
1247
+ { key: "someKey1", value: "someValue1", expiration: "string" },
1248
+ { key: "someKey1", value: "someValue1", expiration_ttl: "string" },
1249
+ {
1250
+ key: 123,
1251
+ value: {
1252
+ a: {
1253
+ nested: "object",
1254
+ },
1255
+ },
1256
+ },
1257
+ { key: "someKey1", value: "someValue1", metadata: 123 },
1258
+ { key: "someKey1", value: "someValue1", base64: "string" },
1260
1259
  ];
1261
1260
  writeFileSync("./keys.json", JSON.stringify(keyValues));
1262
1261
  await expect(
@@ -1274,10 +1273,17 @@ describe("wrangler", () => {
1274
1273
  base64?: boolean;
1275
1274
  }
1276
1275
 
1277
- The item at index 0 is type: \\"number\\" - 123
1278
- The item at index 1 is type: \\"string\\" - \\"a string\\"
1276
+ The item at index 0 is 123
1277
+ The item at index 1 is \\"a string\\"
1279
1278
  The item at index 2 is {\\"key\\":\\"someKey\\"}
1280
- The item at index 3 is {\\"value\\":\\"someValue\\"}"
1279
+ The item at index 3 is {\\"value\\":\\"someValue\\"}
1280
+ The item at index 6 is {\\"key\\":123,\\"value\\":\\"somevalue\\"}
1281
+ The item at index 7 is {\\"key\\":\\"somekey\\",\\"value\\":123}
1282
+ The item at index 8 is {\\"key\\":\\"someKey1\\",\\"value\\":\\"someValue1\\",\\"expiration\\":\\"string\\"}
1283
+ The item at index 9 is {\\"key\\":\\"someKey1\\",\\"value\\":\\"someValue1\\",\\"expiration_ttl\\":\\"string\\"}
1284
+ The item at index 10 is {\\"key\\":123,\\"value\\":{\\"a\\":{\\"nested\\":\\"object\\"}}}
1285
+ The item at index 11 is {\\"key\\":\\"someKey1\\",\\"value\\":\\"someValue1\\",\\"metadata\\":123}
1286
+ The item at index 12 is {\\"key\\":\\"someKey1\\",\\"value\\":\\"someValue1\\",\\"base64\\":\\"string\\"}"
1281
1287
  `);
1282
1288
 
1283
1289
  expect(std.out).toMatchInlineSnapshot(`
@@ -1287,7 +1293,7 @@ describe("wrangler", () => {
1287
1293
  expect(std.warn).toMatchInlineSnapshot(`
1288
1294
  "â–² [WARNING] Unexpected key-value properties in \\"keys.json\\".
1289
1295
 
1290
- The item at index 4 contains unexpected properties: [\\"invalid\\"].
1296
+ The item at index 5 contains unexpected properties: [\\"invalid\\"].
1291
1297
 
1292
1298
  "
1293
1299
  `);
@@ -1352,10 +1358,10 @@ describe("wrangler", () => {
1352
1358
  );
1353
1359
  expect(requests.count).toEqual(3);
1354
1360
  expect(std.out).toMatchInlineSnapshot(`
1355
- "Deleted 0 of 12000.
1356
- Deleted 5000 of 12000.
1357
- Deleted 10000 of 12000.
1358
- Deleted 12000 of 12000.
1361
+ "Deleted 0% (0 out of 12,000)
1362
+ Deleted 41% (5,000 out of 12,000)
1363
+ Deleted 83% (10,000 out of 12,000)
1364
+ Deleted 100% (12,000 out of 12,000)
1359
1365
  Success!"
1360
1366
  `);
1361
1367
  expect(std.warn).toMatchInlineSnapshot(`""`);