scratch-storage 2.2.0 → 2.2.1

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.
@@ -0,0 +1 @@
1
+ {"parent":null,"pid":257,"argv":["/usr/local/bin/node","/home/circleci/project/node_modules/.bin/tap","./test/integration/download-known-assets.js"],"execArgv":[],"cwd":"/home/circleci/project","time":1680278197547,"ppid":246,"coverageFilename":"/home/circleci/project/.nyc_output/f1105466-7461-4f73-8b18-ee824eb652b1.json","externalId":"","uuid":"f1105466-7461-4f73-8b18-ee824eb652b1","files":[]}
@@ -0,0 +1 @@
1
+ {"parent":"f1105466-7461-4f73-8b18-ee824eb652b1","pid":268,"argv":["/usr/local/bin/node","/home/circleci/project/test/integration/download-known-assets.js"],"execArgv":[],"cwd":"/home/circleci/project","time":1680278198785,"ppid":257,"coverageFilename":"/home/circleci/project/.nyc_output/fd8f05df-43a0-4695-b45d-f4877b37f387.json","externalId":"./test/integration/download-known-assets.js","uuid":"fd8f05df-43a0-4695-b45d-f4877b37f387","files":[]}
@@ -1 +1 @@
1
- {"processes":{"c826ae6b-4ae2-4d8e-bdb2-162df5761fa7":{"parent":null,"children":["ec2d52a1-5131-4dd0-9c23-59106f297082"]},"ec2d52a1-5131-4dd0-9c23-59106f297082":{"parent":"c826ae6b-4ae2-4d8e-bdb2-162df5761fa7","externalId":"./test/integration/download-known-assets.js","children":[]}},"files":{},"externalIds":{"./test/integration/download-known-assets.js":{"root":"ec2d52a1-5131-4dd0-9c23-59106f297082","children":[]}}}
1
+ {"processes":{"f1105466-7461-4f73-8b18-ee824eb652b1":{"parent":null,"children":["fd8f05df-43a0-4695-b45d-f4877b37f387"]},"fd8f05df-43a0-4695-b45d-f4877b37f387":{"parent":"f1105466-7461-4f73-8b18-ee824eb652b1","externalId":"./test/integration/download-known-assets.js","children":[]}},"files":{},"externalIds":{"./test/integration/download-known-assets.js":{"root":"fd8f05df-43a0-4695-b45d-f4877b37f387","children":[]}}}
@@ -6001,6 +6001,7 @@ function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o =
6001
6001
  function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
6002
6002
 
6003
6003
  var _require = __webpack_require__(/*! ./scratchFetch */ "./src/scratchFetch.js"),
6004
+ Headers = _require.Headers,
6004
6005
  applyMetadata = _require.applyMetadata;
6005
6006
  /**
6006
6007
  * Get and send assets with a worker that uses fetch.
@@ -6119,7 +6120,14 @@ var PrivateFetchWorkerTool = /*#__PURE__*/function () {
6119
6120
  var id = Math.random().toString(16).substring(2);
6120
6121
  var augmentedOptions = applyMetadata(Object.assign({
6121
6122
  method: 'GET'
6122
- }, options));
6123
+ }, options)); // the Fetch spec says options.headers could be:
6124
+ // "A Headers object, an object literal, or an array of two-item arrays to set request's headers."
6125
+ // structured clone (postMessage) doesn't support Headers objects
6126
+ // so turn it into an array of two-item arrays to make it to the worker intact
6127
+
6128
+ if (augmentedOptions && augmentedOptions.headers instanceof Headers) {
6129
+ augmentedOptions.headers = Array.from(augmentedOptions.headers.entries());
6130
+ }
6123
6131
 
6124
6132
  _this2.worker.postMessage({
6125
6133
  id: id,
@@ -6473,6 +6481,8 @@ var _AssetType = __webpack_require__(/*! ./AssetType */ "./src/AssetType.js");
6473
6481
 
6474
6482
  var _DataFormat = __webpack_require__(/*! ./DataFormat */ "./src/DataFormat.js");
6475
6483
 
6484
+ var _scratchFetch = __webpack_require__(/*! ./scratchFetch */ "./src/scratchFetch.js");
6485
+
6476
6486
  var ScratchStorage = /*#__PURE__*/function () {
6477
6487
  "use strict";
6478
6488
 
@@ -6522,6 +6532,16 @@ var ScratchStorage = /*#__PURE__*/function () {
6522
6532
  get: function get() {
6523
6533
  return _DataFormat;
6524
6534
  }
6535
+ /**
6536
+ * Access the `scratchFetch` module within this library.
6537
+ * @return {module} the scratchFetch module, with properties for `scratchFetch`, `setMetadata`, etc.
6538
+ */
6539
+
6540
+ }, {
6541
+ key: "scratchFetch",
6542
+ get: function get() {
6543
+ return _scratchFetch;
6544
+ }
6525
6545
  /**
6526
6546
  * @deprecated Please use the `Asset` member of a storage instance instead.
6527
6547
  * @return {Asset} - the `Asset` class constructor.
@@ -7042,9 +7062,7 @@ function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o =
7042
7062
 
7043
7063
  function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
7044
7064
 
7045
- var _require = __webpack_require__(/*! cross-fetch */ "./node_modules/cross-fetch/dist/node-ponyfill.js"),
7046
- fetch = _require.fetch,
7047
- Headers = _require.Headers;
7065
+ var crossFetch = __webpack_require__(/*! cross-fetch */ "./node_modules/cross-fetch/dist/node-ponyfill.js");
7048
7066
  /**
7049
7067
  * Metadata header names
7050
7068
  * @enum {string} The enum value is the name of the associated header.
@@ -7054,17 +7072,39 @@ var _require = __webpack_require__(/*! cross-fetch */ "./node_modules/cross-fetc
7054
7072
 
7055
7073
  var RequestMetadata = {
7056
7074
  /** The ID of the project associated with this request */
7057
- ProjectId: 'X-ProjectId',
7075
+ ProjectId: 'X-Project-ID',
7058
7076
 
7059
7077
  /** The ID of the project run associated with this request */
7060
- RunId: 'X-RunId'
7078
+ RunId: 'X-Run-ID'
7061
7079
  };
7062
7080
  /**
7063
- * Metadata for requests
7064
- * @type {Map<string, string>}
7081
+ * Metadata headers for requests
7082
+ * @type {Headers}
7083
+ */
7084
+
7085
+ var metadata = new crossFetch.Headers();
7086
+ /**
7087
+ * Check if there is any metadata to apply.
7088
+ * @returns {boolean} true if `metadata` has contents, or false if it is empty.
7065
7089
  */
7066
7090
 
7067
- var metadata = new Map();
7091
+ var hasMetadata = function hasMetadata() {
7092
+ var _iterator = _createForOfIteratorHelper(metadata),
7093
+ _step;
7094
+
7095
+ try {
7096
+ for (_iterator.s(); !(_step = _iterator.n()).done;) {
7097
+ var _ = _step.value;
7098
+ return true;
7099
+ }
7100
+ } catch (err) {
7101
+ _iterator.e(err);
7102
+ } finally {
7103
+ _iterator.f();
7104
+ }
7105
+
7106
+ return false;
7107
+ };
7068
7108
  /**
7069
7109
  * Non-destructively merge any metadata state (if any) with the provided options object (if any).
7070
7110
  * If there is metadata state but no options object is provided, make a new object.
@@ -7075,29 +7115,33 @@ var metadata = new Map();
7075
7115
  * @returns {RequestInit|undefined} the provided options parameter without modification, or a new options object.
7076
7116
  */
7077
7117
 
7118
+
7078
7119
  var applyMetadata = function applyMetadata(options) {
7079
- if (metadata.size > 0) {
7120
+ if (hasMetadata()) {
7080
7121
  var augmentedOptions = Object.assign({}, options);
7081
- augmentedOptions.headers = new Headers(Array.from(metadata));
7122
+ augmentedOptions.headers = new crossFetch.Headers(metadata);
7082
7123
 
7083
7124
  if (options && options.headers) {
7084
- var overrideHeaders = options.headers instanceof Headers ? options.headers : new Headers(options.headers);
7125
+ // the Fetch spec says options.headers could be:
7126
+ // "A Headers object, an object literal, or an array of two-item arrays to set request's headers."
7127
+ // turn it into a Headers object to be sure of how to interact with it
7128
+ var overrideHeaders = options.headers instanceof crossFetch.Headers ? options.headers : new crossFetch.Headers(options.headers);
7085
7129
 
7086
- var _iterator = _createForOfIteratorHelper(overrideHeaders.entries()),
7087
- _step;
7130
+ var _iterator2 = _createForOfIteratorHelper(overrideHeaders.entries()),
7131
+ _step2;
7088
7132
 
7089
7133
  try {
7090
- for (_iterator.s(); !(_step = _iterator.n()).done;) {
7091
- var _step$value = _slicedToArray(_step.value, 2),
7092
- name = _step$value[0],
7093
- value = _step$value[1];
7134
+ for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
7135
+ var _step2$value = _slicedToArray(_step2.value, 2),
7136
+ name = _step2$value[0],
7137
+ value = _step2$value[1];
7094
7138
 
7095
7139
  augmentedOptions.headers.set(name, value);
7096
7140
  }
7097
7141
  } catch (err) {
7098
- _iterator.e(err);
7142
+ _iterator2.e(err);
7099
7143
  } finally {
7100
- _iterator.f();
7144
+ _iterator2.f();
7101
7145
  }
7102
7146
  }
7103
7147
 
@@ -7118,7 +7162,7 @@ var applyMetadata = function applyMetadata(options) {
7118
7162
 
7119
7163
  var scratchFetch = function scratchFetch(resource, options) {
7120
7164
  var augmentedOptions = applyMetadata(options);
7121
- return fetch(resource, augmentedOptions);
7165
+ return crossFetch.fetch(resource, augmentedOptions);
7122
7166
  };
7123
7167
  /**
7124
7168
  * Set the value of a named request metadata item.
@@ -7144,6 +7188,7 @@ var unsetMetadata = function unsetMetadata(name) {
7144
7188
 
7145
7189
  module.exports = {
7146
7190
  default: scratchFetch,
7191
+ Headers: crossFetch.Headers,
7147
7192
  RequestMetadata: RequestMetadata,
7148
7193
  applyMetadata: applyMetadata,
7149
7194
  scratchFetch: scratchFetch,
@@ -7151,6 +7196,20 @@ module.exports = {
7151
7196
  unsetMetadata: unsetMetadata
7152
7197
  };
7153
7198
 
7199
+ if (true) {
7200
+ /**
7201
+ * Retrieve a named request metadata item.
7202
+ * Only for use in tests.
7203
+ * @param {RequestMetadata} name The name of the metadata item to retrieve.
7204
+ * @returns {any} value The value of the metadata item, or `undefined` if it was not found.
7205
+ */
7206
+ var getMetadata = function getMetadata(name) {
7207
+ return metadata.get(name);
7208
+ };
7209
+
7210
+ module.exports.getMetadata = getMetadata;
7211
+ }
7212
+
7154
7213
  /***/ }),
7155
7214
 
7156
7215
  /***/ "base64-js":