@workos-inc/node 3.0.0 → 3.1.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.
@@ -2,6 +2,7 @@ export declare class GenericServerException extends Error {
2
2
  readonly status: number;
3
3
  readonly requestID: string;
4
4
  readonly name: string;
5
+ readonly rawData: unknown;
5
6
  readonly message: string;
6
- constructor(status: number, message: string | undefined, requestID: string);
7
+ constructor(status: number, message: string | undefined, rawData: unknown, requestID: string);
7
8
  }
@@ -2,7 +2,7 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.GenericServerException = void 0;
4
4
  class GenericServerException extends Error {
5
- constructor(status, message, requestID) {
5
+ constructor(status, message, rawData, requestID) {
6
6
  super();
7
7
  this.status = status;
8
8
  this.requestID = requestID;
@@ -10,6 +10,7 @@ class GenericServerException extends Error {
10
10
  this.message = 'The request could not be completed.';
11
11
  if (message) {
12
12
  this.message = message;
13
+ this.rawData = rawData;
13
14
  }
14
15
  }
15
16
  }
@@ -1,4 +1,3 @@
1
- export * from './at-least-one-property-of.interface';
2
1
  export * from './event.interface';
3
2
  export * from './get-options.interface';
4
3
  export * from './list.interface';
@@ -14,7 +14,6 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
14
  for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
15
  };
16
16
  Object.defineProperty(exports, "__esModule", { value: true });
17
- __exportStar(require("./at-least-one-property-of.interface"), exports);
18
17
  __exportStar(require("./event.interface"), exports);
19
18
  __exportStar(require("./get-options.interface"), exports);
20
19
  __exportStar(require("./list.interface"), exports);
@@ -19,7 +19,7 @@ class DirectorySync {
19
19
  }
20
20
  listDirectories(options) {
21
21
  return __awaiter(this, void 0, void 0, function* () {
22
- return new pagination_1.AutoPaginatable(yield (0, fetch_and_deserialize_1.fetchAndDeserialize)(this.workos, '/directories', serializers_1.deserializeDirectory, options), (params) => (0, fetch_and_deserialize_1.fetchAndDeserialize)(this.workos, '/directories', serializers_1.deserializeDirectory, params), options);
22
+ return new pagination_1.AutoPaginatable(yield (0, fetch_and_deserialize_1.fetchAndDeserialize)(this.workos, '/directories', serializers_1.deserializeDirectory, options ? (0, serializers_1.serializeListDirectoriesOptions)(options) : undefined), (params) => (0, fetch_and_deserialize_1.fetchAndDeserialize)(this.workos, '/directories', serializers_1.deserializeDirectory, params), options);
23
23
  });
24
24
  }
25
25
  getDirectory(id) {
@@ -130,10 +130,12 @@ describe('DirectorySync', () => {
130
130
  mock
131
131
  .onGet('/directories', {
132
132
  domain: 'google.com',
133
+ organization_id: 'org_1234',
133
134
  })
134
135
  .replyOnce(200, directoryListResponse);
135
136
  const subject = yield workos.directorySync.listDirectories({
136
137
  domain: 'google.com',
138
+ organizationId: 'org_1234',
137
139
  });
138
140
  expect(subject).toMatchObject({
139
141
  object: 'list',
@@ -4,3 +4,8 @@ export interface ListDirectoriesOptions extends PaginationOptions {
4
4
  organizationId?: string;
5
5
  search?: string;
6
6
  }
7
+ export interface SerializedListDirectoriesOptions extends PaginationOptions {
8
+ domain?: string;
9
+ organization_id?: string;
10
+ search?: string;
11
+ }
@@ -1,3 +1,4 @@
1
1
  export * from './directory-group.serializer';
2
2
  export * from './directory-user.serializer';
3
3
  export * from './directory.serializer';
4
+ export * from './list-directories-options.serializer';
@@ -17,3 +17,4 @@ Object.defineProperty(exports, "__esModule", { value: true });
17
17
  __exportStar(require("./directory-group.serializer"), exports);
18
18
  __exportStar(require("./directory-user.serializer"), exports);
19
19
  __exportStar(require("./directory.serializer"), exports);
20
+ __exportStar(require("./list-directories-options.serializer"), exports);
@@ -0,0 +1,2 @@
1
+ import { ListDirectoriesOptions, SerializedListDirectoriesOptions } from '../interfaces';
2
+ export declare const serializeListDirectoriesOptions: (options: ListDirectoriesOptions) => SerializedListDirectoriesOptions;
@@ -0,0 +1,13 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.serializeListDirectoriesOptions = void 0;
4
+ const serializeListDirectoriesOptions = (options) => ({
5
+ domain: options.domain,
6
+ organization_id: options.organizationId,
7
+ search: options.search,
8
+ limit: options.limit,
9
+ before: options.before,
10
+ after: options.after,
11
+ order: options.order,
12
+ });
13
+ exports.serializeListDirectoriesOptions = serializeListDirectoriesOptions;
package/lib/index.d.ts CHANGED
@@ -3,6 +3,7 @@ export * from './audit-logs/interfaces';
3
3
  export * from './audit-trail/interfaces';
4
4
  export * from './common/exceptions';
5
5
  export * from './common/interfaces';
6
+ export * from './common/utils/pagination';
6
7
  export * from './directory-sync/interfaces';
7
8
  export * from './directory-sync/utils/get-primary-email';
8
9
  export * from './events/interfaces';
package/lib/index.js CHANGED
@@ -21,6 +21,7 @@ __exportStar(require("./audit-logs/interfaces"), exports);
21
21
  __exportStar(require("./audit-trail/interfaces"), exports);
22
22
  __exportStar(require("./common/exceptions"), exports);
23
23
  __exportStar(require("./common/interfaces"), exports);
24
+ __exportStar(require("./common/utils/pagination"), exports);
24
25
  __exportStar(require("./directory-sync/interfaces"), exports);
25
26
  __exportStar(require("./directory-sync/utils/get-primary-email"), exports);
26
27
  __exportStar(require("./events/interfaces"), exports);
@@ -1,3 +1,4 @@
1
1
  export * from './connection.serializer';
2
+ export * from './list-connections-options.serializer';
2
3
  export * from './profile-and-token.serializer';
3
4
  export * from './profile.serializer';
@@ -15,5 +15,6 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
15
15
  };
16
16
  Object.defineProperty(exports, "__esModule", { value: true });
17
17
  __exportStar(require("./connection.serializer"), exports);
18
+ __exportStar(require("./list-connections-options.serializer"), exports);
18
19
  __exportStar(require("./profile-and-token.serializer"), exports);
19
20
  __exportStar(require("./profile.serializer"), exports);
@@ -0,0 +1,2 @@
1
+ import { ListConnectionsOptions, SerializedListConnectionsOptions } from '../interfaces';
2
+ export declare const serializeListConnectionsOptions: (options: ListConnectionsOptions) => SerializedListConnectionsOptions;
@@ -0,0 +1,13 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.serializeListConnectionsOptions = void 0;
4
+ const serializeListConnectionsOptions = (options) => ({
5
+ connection_type: options.connectionType,
6
+ domain: options.domain,
7
+ organization_id: options.organizationId,
8
+ limit: options.limit,
9
+ before: options.before,
10
+ after: options.after,
11
+ order: options.order,
12
+ });
13
+ exports.serializeListConnectionsOptions = serializeListConnectionsOptions;
package/lib/sso/sso.js CHANGED
@@ -30,7 +30,7 @@ class SSO {
30
30
  }
31
31
  listConnections(options) {
32
32
  return __awaiter(this, void 0, void 0, function* () {
33
- return new pagination_1.AutoPaginatable(yield (0, fetch_and_deserialize_1.fetchAndDeserialize)(this.workos, '/connections', serializers_1.deserializeConnection, options), (params) => (0, fetch_and_deserialize_1.fetchAndDeserialize)(this.workos, '/connections', serializers_1.deserializeConnection, params), options);
33
+ return new pagination_1.AutoPaginatable(yield (0, fetch_and_deserialize_1.fetchAndDeserialize)(this.workos, '/connections', serializers_1.deserializeConnection, options ? (0, serializers_1.serializeListConnectionsOptions)(options) : undefined), (params) => (0, fetch_and_deserialize_1.fetchAndDeserialize)(this.workos, '/connections', serializers_1.deserializeConnection, params), options);
34
34
  });
35
35
  }
36
36
  deleteConnection(id) {
@@ -309,7 +309,9 @@ describe('SSO', () => {
309
309
  list_metadata: {},
310
310
  });
311
311
  const workos = new workos_1.WorkOS('sk_test_Sz3IQjepeSWaI4cMS4ms4sMuU');
312
- const subject = yield workos.sso.listConnections();
312
+ const subject = yield workos.sso.listConnections({
313
+ organizationId: 'org_1234',
314
+ });
313
315
  expect(mock.history.get[0].url).toEqual('/connections');
314
316
  expect(subject.data).toHaveLength(1);
315
317
  }));
@@ -1,14 +1,9 @@
1
- import { AtLeastOnePropertyOf } from '../../common/interfaces';
2
- interface BaseUpdateUserOptions {
1
+ export interface UpdateUserOptions {
3
2
  userId: string;
3
+ firstName?: string;
4
+ lastName?: string;
4
5
  }
5
- interface UpdateUserOptionsProperties {
6
- firstName: string;
7
- lastName: string;
8
- }
9
- export type UpdateUserOptions = BaseUpdateUserOptions & AtLeastOnePropertyOf<UpdateUserOptionsProperties>;
10
6
  export interface SerializedUpdateUserOptions {
11
7
  first_name?: string;
12
8
  last_name?: string;
13
9
  }
14
- export {};
package/lib/workos.js CHANGED
@@ -27,7 +27,7 @@ const mfa_1 = require("./mfa/mfa");
27
27
  const audit_logs_1 = require("./audit-logs/audit-logs");
28
28
  const users_1 = require("./users/users");
29
29
  const bad_request_exception_1 = require("./common/exceptions/bad-request.exception");
30
- const VERSION = '3.0.0';
30
+ const VERSION = '3.1.1';
31
31
  const DEFAULT_HOSTNAME = 'api.workos.com';
32
32
  class WorkOS {
33
33
  constructor(key, options = {}) {
@@ -183,7 +183,7 @@ class WorkOS {
183
183
  });
184
184
  }
185
185
  else {
186
- throw new exceptions_1.GenericServerException(status, data.message, requestID);
186
+ throw new exceptions_1.GenericServerException(status, data.message, data, requestID);
187
187
  }
188
188
  }
189
189
  }
@@ -140,7 +140,7 @@ describe('WorkOS', () => {
140
140
  'X-Request-ID': 'a-request-id',
141
141
  });
142
142
  const workos = new workos_1.WorkOS('sk_test_Sz3IQjepeSWaI4cMS4ms4sMuU');
143
- yield expect(workos.post('/path', {})).rejects.toStrictEqual(new exceptions_1.GenericServerException(500, undefined, 'a-request-id'));
143
+ yield expect(workos.post('/path', {})).rejects.toStrictEqual(new exceptions_1.GenericServerException(500, undefined, {}, 'a-request-id'));
144
144
  }));
145
145
  });
146
146
  describe('when the api responds with a 400 and an error/error_description', () => {
package/package.json CHANGED
@@ -1,5 +1,5 @@
1
1
  {
2
- "version": "3.0.0",
2
+ "version": "3.1.1",
3
3
  "name": "@workos-inc/node",
4
4
  "author": "WorkOS",
5
5
  "description": "A Node wrapper for the WorkOS API",
@@ -49,4 +49,4 @@
49
49
  "tslint": "6.1.3",
50
50
  "typescript": "5.1.6"
51
51
  }
52
- }
52
+ }
@@ -1,7 +0,0 @@
1
- export type AtLeastOnePropertyOf<T> = {
2
- [K in keyof T]: {
3
- [L in K]: T[L];
4
- } & {
5
- [L in Exclude<keyof T, K>]?: T[L];
6
- };
7
- }[keyof T];
@@ -1,2 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });