@workos-inc/node 2.17.0 → 2.19.0

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.
@@ -150,6 +150,8 @@ describe('AuditLogs', () => {
150
150
  const options = {
151
151
  actions: ['foo', 'bar'],
152
152
  actors: ['Jon', 'Smith'],
153
+ actor_names: ['Jon', 'Smith'],
154
+ actor_ids: ['user_foo', 'user_bar'],
153
155
  organization_id: 'org_123',
154
156
  range_end: new Date(),
155
157
  range_start: new Date(),
@@ -1,6 +1,11 @@
1
1
  export interface AuditLogExportOptions {
2
2
  actions?: string[];
3
+ /**
4
+ * @deprecated Please use `actor_names` instead.
5
+ */
3
6
  actors?: string[];
7
+ actor_names?: string[];
8
+ actor_ids?: string[];
4
9
  organization_id: string;
5
10
  range_end: Date;
6
11
  range_start: Date;
@@ -1,5 +1,5 @@
1
1
  import { CreateEventOptions } from './interfaces/create-event-options.interface';
2
- import { Event } from './interfaces/event.interface';
2
+ import { AuditTrailEvent } from './interfaces/event.interface';
3
3
  import { EventOptions } from './interfaces/event-options.interface';
4
4
  import { List } from '../common/interfaces/list.interface';
5
5
  import { ListEventsOptions } from './interfaces/list-events-options.interface';
@@ -8,5 +8,5 @@ export declare class AuditTrail {
8
8
  private readonly workos;
9
9
  constructor(workos: WorkOS);
10
10
  createEvent(event: EventOptions, { idempotencyKey }?: CreateEventOptions): Promise<void>;
11
- listEvents(options?: ListEventsOptions): Promise<List<Event>>;
11
+ listEvents(options?: ListEventsOptions): Promise<List<AuditTrailEvent>>;
12
12
  }
@@ -1,9 +1,9 @@
1
- export interface EventAction {
1
+ export interface AuditTrailEventAction {
2
2
  object: 'event_action';
3
3
  id: string;
4
4
  name: string;
5
5
  }
6
- export interface Event {
6
+ export interface AuditTrailEvent {
7
7
  object: 'event';
8
8
  id: string;
9
9
  group: string;
@@ -16,7 +16,7 @@ export interface Event {
16
16
  target_name: string;
17
17
  target_id: string;
18
18
  occurred_at: Date;
19
- action: EventAction;
19
+ action: AuditTrailEventAction;
20
20
  metadata?: {
21
21
  [key: string]: string;
22
22
  };
@@ -1,4 +1,4 @@
1
1
  export { CreateEventOptions } from './create-event-options.interface';
2
2
  export { EventOptions } from './event-options.interface';
3
- export { Event } from './event.interface';
3
+ export { AuditTrailEvent } from './event.interface';
4
4
  export { ListEventsOptions } from './list-events-options.interface';
@@ -0,0 +1,9 @@
1
+ import { WorkOS } from '../workos';
2
+ import { Event } from './interfaces/event.interface';
3
+ import { List } from '../common/interfaces/list.interface';
4
+ import { ListEventOptions } from './interfaces';
5
+ export declare class Events {
6
+ private readonly workos;
7
+ constructor(workos: WorkOS);
8
+ listEvents(options: ListEventOptions): Promise<List<Event>>;
9
+ }
@@ -0,0 +1,26 @@
1
+ "use strict";
2
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
+ return new (P || (P = Promise))(function (resolve, reject) {
5
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
9
+ });
10
+ };
11
+ Object.defineProperty(exports, "__esModule", { value: true });
12
+ exports.Events = void 0;
13
+ class Events {
14
+ constructor(workos) {
15
+ this.workos = workos;
16
+ }
17
+ listEvents(options) {
18
+ return __awaiter(this, void 0, void 0, function* () {
19
+ const { data } = yield this.workos.get(`/events`, {
20
+ query: options,
21
+ });
22
+ return data;
23
+ });
24
+ }
25
+ }
26
+ exports.Events = Events;
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,49 @@
1
+ "use strict";
2
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
+ return new (P || (P = Promise))(function (resolve, reject) {
5
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
9
+ });
10
+ };
11
+ var __importDefault = (this && this.__importDefault) || function (mod) {
12
+ return (mod && mod.__esModule) ? mod : { "default": mod };
13
+ };
14
+ Object.defineProperty(exports, "__esModule", { value: true });
15
+ const axios_1 = __importDefault(require("axios"));
16
+ const axios_mock_adapter_1 = __importDefault(require("axios-mock-adapter"));
17
+ const workos_1 = require("../workos");
18
+ const mock = new axios_mock_adapter_1.default(axios_1.default);
19
+ describe('Event', () => {
20
+ afterEach(() => mock.resetHistory());
21
+ const workos = new workos_1.WorkOS('sk_test_Sz3IQjepeSWaI4cMS4ms4sMuU');
22
+ const eventResponse = {
23
+ id: 'event_01234ABCD',
24
+ created_at: '2020-05-06 04:21:48.649164',
25
+ event: 'dsync.user.created',
26
+ data: {
27
+ id: 'event_01234ABCD',
28
+ },
29
+ };
30
+ describe('listEvents', () => {
31
+ const eventsListResponse = {
32
+ object: 'list',
33
+ data: [eventResponse],
34
+ list_metadata: {},
35
+ };
36
+ it(`requests Events`, () => __awaiter(void 0, void 0, void 0, function* () {
37
+ mock.onGet('/events', {}).replyOnce(200, eventsListResponse);
38
+ const list = yield workos.events.listEvents({});
39
+ expect(list).toEqual(eventsListResponse);
40
+ }));
41
+ it(`requests Events with a valid event name`, () => __awaiter(void 0, void 0, void 0, function* () {
42
+ mock.onGet('/events').replyOnce(200, eventsListResponse);
43
+ const list = yield workos.events.listEvents({
44
+ events: ['connection.activated'],
45
+ });
46
+ expect(list).toEqual(eventsListResponse);
47
+ }));
48
+ });
49
+ });
@@ -0,0 +1,63 @@
1
+ interface EventBase {
2
+ id: string;
3
+ created_at: string;
4
+ }
5
+ export interface ConnectionActivatedEvent extends EventBase {
6
+ event: 'connection.activated';
7
+ data: Record<string, unknown>;
8
+ }
9
+ export interface ConnectionDeactivatedEvent extends EventBase {
10
+ event: 'connection.deactivated';
11
+ data: Record<string, unknown>;
12
+ }
13
+ export interface ConnectionDeletedEvent extends EventBase {
14
+ event: 'connection.deleted';
15
+ data: Record<string, unknown>;
16
+ }
17
+ export interface DsyncActivatedEvent extends EventBase {
18
+ event: 'dsync.activated';
19
+ data: Record<string, unknown>;
20
+ }
21
+ export interface DsyncDeactivatedEvent extends EventBase {
22
+ event: 'dsync.deactivated';
23
+ data: Record<string, unknown>;
24
+ }
25
+ export interface DsyncDeletedEvent extends EventBase {
26
+ event: 'dsync.deleted';
27
+ data: Record<string, unknown>;
28
+ }
29
+ export interface DsyncGroupCreatedEvent extends EventBase {
30
+ event: 'dsync.group.created';
31
+ data: Record<string, unknown>;
32
+ }
33
+ export interface DsyncGroupDeletedEvent extends EventBase {
34
+ event: 'dsync.group.deleted';
35
+ data: Record<string, unknown>;
36
+ }
37
+ export interface DsyncGroupUpdatedEvent extends EventBase {
38
+ event: 'dsync.group.updated';
39
+ data: Record<string, unknown>;
40
+ }
41
+ export interface DsyncGroupUserAddedEvent extends EventBase {
42
+ event: 'dsync.group.user_added';
43
+ data: Record<string, unknown>;
44
+ }
45
+ export interface DsyncGroupUserRemovedEvent extends EventBase {
46
+ event: 'dsync.group.user_removed';
47
+ data: Record<string, unknown>;
48
+ }
49
+ export interface DsyncUserCreatedEvent extends EventBase {
50
+ event: 'dsync.user.created';
51
+ data: Record<string, unknown>;
52
+ }
53
+ export interface DsyncUserDeletedEvent extends EventBase {
54
+ event: 'dsync.user.deleted';
55
+ data: Record<string, unknown>;
56
+ }
57
+ export interface DsyncUserUpdatedEvent extends EventBase {
58
+ event: 'dsync.user.updated';
59
+ data: Record<string, unknown>;
60
+ }
61
+ export type Event = ConnectionActivatedEvent | ConnectionDeactivatedEvent | ConnectionDeletedEvent | DsyncActivatedEvent | DsyncDeactivatedEvent | DsyncDeletedEvent | DsyncGroupCreatedEvent | DsyncGroupUpdatedEvent | DsyncGroupDeletedEvent | DsyncGroupUserAddedEvent | DsyncGroupUserRemovedEvent | DsyncUserCreatedEvent | DsyncUserUpdatedEvent | DsyncUserDeletedEvent;
62
+ export type EventNames = 'connection.activated' | 'connection.deactivated' | 'connection.deleted' | 'dsync.activated' | 'dsync.deactivated' | 'dsync.deleted' | 'dsync.group.created' | 'dsync.group.deleted' | 'dsync.group.updated' | 'dsync.group.user_added' | 'dsync.group.user_removed' | 'dsync.user.created' | 'dsync.user.deleted' | 'dsync.user.updated';
63
+ export {};
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,2 @@
1
+ export * from './list-events-options.interface';
2
+ export * from './event.interface';
@@ -0,0 +1,18 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ __exportStar(require("./list-events-options.interface"), exports);
18
+ __exportStar(require("./event.interface"), exports);
@@ -0,0 +1,8 @@
1
+ import { EventNames } from './event.interface';
2
+ export interface ListEventOptions {
3
+ events?: EventNames[];
4
+ rangeStart?: string;
5
+ rangeEnd?: string;
6
+ limit?: number;
7
+ after?: string;
8
+ }
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
package/lib/index.d.ts CHANGED
@@ -5,6 +5,7 @@ export * from './common/exceptions';
5
5
  export * from './common/interfaces';
6
6
  export * from './directory-sync/interfaces';
7
7
  export * from './directory-sync/utils/get-primary-email';
8
+ export * from './events/interfaces';
8
9
  export * from './organizations/interfaces';
9
10
  export * from './passwordless/interfaces';
10
11
  export * from './portal/interfaces';
package/lib/index.js CHANGED
@@ -23,6 +23,7 @@ __exportStar(require("./common/exceptions"), exports);
23
23
  __exportStar(require("./common/interfaces"), exports);
24
24
  __exportStar(require("./directory-sync/interfaces"), exports);
25
25
  __exportStar(require("./directory-sync/utils/get-primary-email"), exports);
26
+ __exportStar(require("./events/interfaces"), exports);
26
27
  __exportStar(require("./organizations/interfaces"), exports);
27
28
  __exportStar(require("./passwordless/interfaces"), exports);
28
29
  __exportStar(require("./portal/interfaces"), exports);
package/lib/workos.d.ts CHANGED
@@ -2,6 +2,7 @@ import { AxiosResponse } from 'axios';
2
2
  import { AuditTrail } from './audit-trail/audit-trail';
3
3
  import { GetOptions, PostOptions, PutOptions, WorkOSOptions } from './common/interfaces';
4
4
  import { DirectorySync } from './directory-sync/directory-sync';
5
+ import { Events } from './events/events';
5
6
  import { Organizations } from './organizations/organizations';
6
7
  import { Passwordless } from './passwordless/passwordless';
7
8
  import { Portal } from './portal/portal';
@@ -23,6 +24,7 @@ export declare class WorkOS {
23
24
  readonly sso: SSO;
24
25
  readonly webhooks: Webhooks;
25
26
  readonly mfa: Mfa;
27
+ readonly events: Events;
26
28
  constructor(key?: string | undefined, options?: WorkOSOptions);
27
29
  post(path: string, entity: any, options?: PostOptions): Promise<AxiosResponse>;
28
30
  get(path: string, options?: GetOptions): Promise<AxiosResponse>;
package/lib/workos.js CHANGED
@@ -17,6 +17,7 @@ const axios_1 = __importDefault(require("axios"));
17
17
  const audit_trail_1 = require("./audit-trail/audit-trail");
18
18
  const exceptions_1 = require("./common/exceptions");
19
19
  const directory_sync_1 = require("./directory-sync/directory-sync");
20
+ const events_1 = require("./events/events");
20
21
  const organizations_1 = require("./organizations/organizations");
21
22
  const passwordless_1 = require("./passwordless/passwordless");
22
23
  const portal_1 = require("./portal/portal");
@@ -25,7 +26,7 @@ const webhooks_1 = require("./webhooks/webhooks");
25
26
  const mfa_1 = require("./mfa/mfa");
26
27
  const audit_logs_1 = require("./audit-logs/audit-logs");
27
28
  const bad_request_exception_1 = require("./common/exceptions/bad-request.exception");
28
- const VERSION = '2.17.0';
29
+ const VERSION = '2.19.0';
29
30
  const DEFAULT_HOSTNAME = 'api.workos.com';
30
31
  class WorkOS {
31
32
  constructor(key, options = {}) {
@@ -41,6 +42,7 @@ class WorkOS {
41
42
  this.sso = new sso_1.SSO(this);
42
43
  this.webhooks = new webhooks_1.Webhooks();
43
44
  this.mfa = new mfa_1.Mfa(this);
45
+ this.events = new events_1.Events(this);
44
46
  if (!key) {
45
47
  this.key = process.env.WORKOS_API_KEY;
46
48
  if (!this.key) {
package/package.json CHANGED
@@ -1,5 +1,5 @@
1
1
  {
2
- "version": "2.17.0",
2
+ "version": "2.19.0",
3
3
  "name": "@workos-inc/node",
4
4
  "author": "WorkOS",
5
5
  "description": "A Node wrapper for the WorkOS API",