@workos-inc/node 6.0.1 → 6.0.3

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.
@@ -23,7 +23,9 @@ export declare class FetchClient {
23
23
  delete(path: string, options: {
24
24
  params?: Record<string, any>;
25
25
  headers?: HeadersInit;
26
- }): Promise<void>;
26
+ }): Promise<{
27
+ data: any;
28
+ }>;
27
29
  private getResourceURL;
28
30
  private fetch;
29
31
  }
@@ -19,38 +19,35 @@ class FetchClient {
19
19
  get(path, options) {
20
20
  return __awaiter(this, void 0, void 0, function* () {
21
21
  const resourceURL = this.getResourceURL(path, options.params);
22
- const response = yield this.fetch(resourceURL, {
22
+ return yield this.fetch(resourceURL, {
23
23
  headers: options.headers,
24
24
  });
25
- return { data: yield response.json() };
26
25
  });
27
26
  }
28
27
  post(path, entity, options) {
29
28
  return __awaiter(this, void 0, void 0, function* () {
30
29
  const resourceURL = this.getResourceURL(path, options.params);
31
- const response = yield this.fetch(resourceURL, {
30
+ return yield this.fetch(resourceURL, {
32
31
  method: 'POST',
33
32
  headers: Object.assign(Object.assign({}, getContentTypeHeader(entity)), options.headers),
34
33
  body: getBody(entity),
35
34
  });
36
- return { data: yield response.json() };
37
35
  });
38
36
  }
39
37
  put(path, entity, options) {
40
38
  return __awaiter(this, void 0, void 0, function* () {
41
39
  const resourceURL = this.getResourceURL(path, options.params);
42
- const response = yield this.fetch(resourceURL, {
40
+ return yield this.fetch(resourceURL, {
43
41
  method: 'PUT',
44
42
  headers: Object.assign(Object.assign({}, getContentTypeHeader(entity)), options.headers),
45
43
  body: getBody(entity),
46
44
  });
47
- return { data: yield response.json() };
48
45
  });
49
46
  }
50
47
  delete(path, options) {
51
48
  return __awaiter(this, void 0, void 0, function* () {
52
49
  const resourceURL = this.getResourceURL(path, options.params);
53
- yield this.fetch(resourceURL, {
50
+ return yield this.fetch(resourceURL, {
54
51
  method: 'DELETE',
55
52
  headers: options.headers,
56
53
  });
@@ -75,7 +72,12 @@ class FetchClient {
75
72
  },
76
73
  });
77
74
  }
78
- return response;
75
+ const contentType = response.headers.get('content-type');
76
+ const isJsonResponse = contentType === null || contentType === void 0 ? void 0 : contentType.includes('application/json');
77
+ if (isJsonResponse) {
78
+ return { data: yield response.json() };
79
+ }
80
+ return { data: null };
79
81
  });
80
82
  }
81
83
  }
@@ -1,5 +1,5 @@
1
1
  import { MockParams } from 'jest-fetch-mock';
2
- export declare function fetchOnce(response?: any, { status, ...rest }?: MockParams): import("jest-fetch-mock").FetchMock;
2
+ export declare function fetchOnce(response?: any, { status, headers, ...rest }?: MockParams): import("jest-fetch-mock").FetchMock;
3
3
  export declare function fetchURL(): string | Request | undefined;
4
4
  export declare function fetchSearchParams(): {
5
5
  [k: string]: string;
@@ -17,8 +17,8 @@ Object.defineProperty(exports, "__esModule", { value: true });
17
17
  exports.fetchBody = exports.fetchHeaders = exports.fetchSearchParams = exports.fetchURL = exports.fetchOnce = void 0;
18
18
  const jest_fetch_mock_1 = __importDefault(require("jest-fetch-mock"));
19
19
  function fetchOnce(response = {}, _a = {}) {
20
- var { status = 200 } = _a, rest = __rest(_a, ["status"]);
21
- return jest_fetch_mock_1.default.once(JSON.stringify(response), Object.assign({ status }, rest));
20
+ var { status = 200, headers } = _a, rest = __rest(_a, ["status", "headers"]);
21
+ return jest_fetch_mock_1.default.once(JSON.stringify(response), Object.assign({ status, headers: Object.assign({ 'content-type': 'application/json;charset=UTF-8' }, headers) }, rest));
22
22
  }
23
23
  exports.fetchOnce = fetchOnce;
24
24
  function fetchURL() {
@@ -1,9 +1,20 @@
1
1
  "use strict";
2
+ var __rest = (this && this.__rest) || function (s, e) {
3
+ var t = {};
4
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
5
+ t[p] = s[p];
6
+ if (s != null && typeof Object.getOwnPropertySymbols === "function")
7
+ for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
8
+ if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
9
+ t[p[i]] = s[p[i]];
10
+ }
11
+ return t;
12
+ };
2
13
  Object.defineProperty(exports, "__esModule", { value: true });
3
14
  exports.deserializeAuthenticationResponse = void 0;
4
15
  const user_serializer_1 = require("./user.serializer");
5
- const deserializeAuthenticationResponse = (authenticationResponse) => ({
6
- user: (0, user_serializer_1.deserializeUser)(authenticationResponse.user),
7
- organizationId: authenticationResponse.organization_id,
8
- });
16
+ const deserializeAuthenticationResponse = (authenticationResponse) => {
17
+ const { user, organization_id } = authenticationResponse, rest = __rest(authenticationResponse, ["user", "organization_id"]);
18
+ return Object.assign({ user: (0, user_serializer_1.deserializeUser)(user), organizationId: organization_id }, rest);
19
+ };
9
20
  exports.deserializeAuthenticationResponse = deserializeAuthenticationResponse;
package/lib/workos.js CHANGED
@@ -24,7 +24,7 @@ const audit_logs_1 = require("./audit-logs/audit-logs");
24
24
  const user_management_1 = require("./user-management/user-management");
25
25
  const bad_request_exception_1 = require("./common/exceptions/bad-request.exception");
26
26
  const fetch_client_1 = require("./common/utils/fetch-client");
27
- const VERSION = '6.0.1';
27
+ const VERSION = '6.0.3';
28
28
  const DEFAULT_HOSTNAME = 'api.workos.com';
29
29
  class WorkOS {
30
30
  constructor(key, options = {}) {
package/package.json CHANGED
@@ -1,5 +1,5 @@
1
1
  {
2
- "version": "6.0.1",
2
+ "version": "6.0.3",
3
3
  "name": "@workos-inc/node",
4
4
  "author": "WorkOS",
5
5
  "description": "A Node wrapper for the WorkOS API",