msw 0.42.0 → 0.42.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.
package/README.md CHANGED
@@ -200,10 +200,16 @@ test('handles login exception', () => {
200
200
 
201
201
  ### Silver Sponsors
202
202
 
203
- > Become our first _silver sponsor_ and get your profile image and link featured right here.
203
+ > Become our _silver sponsor_ and get your profile image and link featured right here.
204
204
  >
205
205
  > **Learn more on our [GitHub Sponsors profile](https://github.com/sponsors/mswjs)**.
206
206
 
207
+ <br />
208
+
209
+ <a href="https://www.chromatic.com/" target="_blank">
210
+ <img src="media/sponsors/chromatic.svg#1" alt="Chromatic" width="75" />
211
+ </a>
212
+
207
213
  ### Bronze Sponsors
208
214
 
209
215
  > Become our first _bronze sponsor_ and get your profile image and link featured in this section.
package/lib/iife/index.js CHANGED
@@ -1444,7 +1444,7 @@ var MockServiceWorker = (() => {
1444
1444
  }(Error);
1445
1445
  exports.InvariantError = InvariantError;
1446
1446
  function createInvariantWith(ErrorConstructor) {
1447
- var invariant2 = function(predicate, message) {
1447
+ var invariant3 = function(predicate, message) {
1448
1448
  var positionals = [];
1449
1449
  for (var _i = 2; _i < arguments.length; _i++) {
1450
1450
  positionals[_i - 2] = arguments[_i];
@@ -1457,7 +1457,7 @@ var MockServiceWorker = (() => {
1457
1457
  throw error2;
1458
1458
  }
1459
1459
  };
1460
- return invariant2;
1460
+ return invariant3;
1461
1461
  }
1462
1462
  exports.createInvariantWith = createInvariantWith;
1463
1463
  function polymorphicInvariant(ErrorClass) {
@@ -7643,8 +7643,8 @@ Learn more about creating the Service Worker script: https://mswjs.io/docs/cli/i
7643
7643
  }
7644
7644
  const parsedBody = {};
7645
7645
  try {
7646
- for (const field of fields) {
7647
- const [contentHeaders, ...rest2] = field.split("\r\n\r\n");
7646
+ for (const field2 of fields) {
7647
+ const [contentHeaders, ...rest2] = field2.split("\r\n\r\n");
7648
7648
  const contentBody = rest2.join("\r\n\r\n");
7649
7649
  const { contentType: contentType2, filename, name } = parseContentHeaders(contentHeaders);
7650
7650
  const value = filename === void 0 ? contentBody : new File([contentBody], filename, { type: contentType2 });
@@ -10140,6 +10140,23 @@ spurious results.`);
10140
10140
  }
10141
10141
  };
10142
10142
 
10143
+ // src/context/field.ts
10144
+ var import_outvariant2 = __toESM(require_lib5());
10145
+ var field = (fieldName, fieldValue) => {
10146
+ return (res) => {
10147
+ validateFieldName(fieldName);
10148
+ const prevBody = jsonParse(res.body) || {};
10149
+ const nextBody = mergeRight(prevBody, { [fieldName]: fieldValue });
10150
+ return json(nextBody)(res);
10151
+ };
10152
+ };
10153
+ function validateFieldName(fieldName) {
10154
+ (0, import_outvariant2.invariant)(fieldName.trim() !== "", devUtils.formatMessage("Failed to set a custom field on a GraphQL response: field name cannot be empty."));
10155
+ (0, import_outvariant2.invariant)(fieldName !== "data", devUtils.formatMessage('Failed to set a custom "%s" field on a mocked GraphQL response: forbidden field name. Did you mean to call "ctx.data()" instead?', fieldName));
10156
+ (0, import_outvariant2.invariant)(fieldName !== "errors", devUtils.formatMessage('Failed to set a custom "%s" field on a mocked GraphQL response: forbidden field name. Did you mean to call "ctx.errors()" instead?', fieldName));
10157
+ (0, import_outvariant2.invariant)(fieldName !== "extensions", devUtils.formatMessage('Failed to set a custom "%s" field on a mocked GraphQL response: forbidden field name. Did you mean to call "ctx.extensions()" instead?', fieldName));
10158
+ }
10159
+
10143
10160
  // src/utils/internal/tryCatch.ts
10144
10161
  function tryCatch(fn, onException) {
10145
10162
  try {
@@ -10155,7 +10172,8 @@ spurious results.`);
10155
10172
  data,
10156
10173
  extensions,
10157
10174
  errors,
10158
- cookie
10175
+ cookie,
10176
+ field
10159
10177
  });
10160
10178
  function isDocumentNode(value) {
10161
10179
  if (value == null) {