@workos-inc/node 7.33.0 → 7.33.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.
@@ -61,6 +61,7 @@ const schema = {
61
61
  baz: 'boolean',
62
62
  },
63
63
  };
64
+ const schemaWithoutMetadata = Object.assign(Object.assign({}, schema), { metadata: undefined });
64
65
  describe('AuditLogs', () => {
65
66
  beforeEach(() => jest_fetch_mock_1.default.resetMocks());
66
67
  describe('createEvent', () => {
@@ -328,6 +329,63 @@ describe('AuditLogs', () => {
328
329
  expect(workosSpy).toHaveBeenCalledWith('/audit_logs/actions/user.logged_in/schemas', (0, serializers_1.serializeCreateAuditLogSchemaOptions)(schema), { idempotencyKey: 'the-idempotency-key' });
329
330
  }));
330
331
  });
332
+ describe('without metadata', () => {
333
+ it('does not include metadata with the request', () => __awaiter(void 0, void 0, void 0, function* () {
334
+ const workosSpy = jest.spyOn(workos_1.WorkOS.prototype, 'post');
335
+ const time = new Date().toISOString();
336
+ const createSchemaResult = {
337
+ object: 'audit_log_schema',
338
+ version: 1,
339
+ targets: [
340
+ {
341
+ type: 'user',
342
+ metadata: {
343
+ user_id: 'string',
344
+ },
345
+ },
346
+ ],
347
+ actor: {
348
+ metadata: {
349
+ actor_id: 'string',
350
+ },
351
+ },
352
+ metadata: undefined,
353
+ createdAt: time,
354
+ };
355
+ const createSchemaResponse = {
356
+ object: 'audit_log_schema',
357
+ version: 1,
358
+ targets: [
359
+ {
360
+ type: 'user',
361
+ metadata: {
362
+ type: 'object',
363
+ properties: {
364
+ user_id: {
365
+ type: 'string',
366
+ },
367
+ },
368
+ },
369
+ },
370
+ ],
371
+ actor: {
372
+ metadata: {
373
+ type: 'object',
374
+ properties: {
375
+ actor_id: {
376
+ type: 'string',
377
+ },
378
+ },
379
+ },
380
+ },
381
+ created_at: time,
382
+ };
383
+ workosSpy.mockResolvedValueOnce((0, workos_mock_response_1.mockWorkOsResponse)(201, createSchemaResponse));
384
+ const workos = new workos_1.WorkOS('sk_test_Sz3IQjepeSWaI4cMS4ms4sMuU');
385
+ yield expect(workos.auditLogs.createSchema(schemaWithoutMetadata)).resolves.toEqual(createSchemaResult);
386
+ expect(workosSpy).toHaveBeenCalledWith('/audit_logs/actions/user.logged_in/schemas', (0, serializers_1.serializeCreateAuditLogSchemaOptions)(schemaWithoutMetadata), {});
387
+ }));
388
+ });
331
389
  describe('when the api responds with a 201', () => {
332
390
  it('returns `audit_log_schema`', () => __awaiter(void 0, void 0, void 0, function* () {
333
391
  const workosSpy = jest.spyOn(workos_1.WorkOS.prototype, 'post');
@@ -53,7 +53,7 @@ export interface CreateAuditLogSchemaResponse {
53
53
  properties: AuditLogSchemaMetadata;
54
54
  };
55
55
  };
56
- metadata: {
56
+ metadata?: {
57
57
  type: 'object';
58
58
  properties: AuditLogSchemaMetadata;
59
59
  };
@@ -33,10 +33,12 @@ const serializeCreateAuditLogSchemaOptions = (schema) => {
33
33
  : undefined,
34
34
  };
35
35
  }),
36
- metadata: {
37
- type: 'object',
38
- properties: serializeMetadata(schema.metadata),
39
- },
36
+ metadata: schema.metadata
37
+ ? {
38
+ type: 'object',
39
+ properties: serializeMetadata(schema.metadata),
40
+ }
41
+ : undefined,
40
42
  });
41
43
  };
42
44
  exports.serializeCreateAuditLogSchemaOptions = serializeCreateAuditLogSchemaOptions;
@@ -29,7 +29,9 @@ const deserializeAuditLogSchema = (auditLogSchema) => {
29
29
  actor: {
30
30
  metadata: deserializeMetadata((_a = auditLogSchema.actor) === null || _a === void 0 ? void 0 : _a.metadata),
31
31
  },
32
- metadata: deserializeMetadata(auditLogSchema.metadata),
32
+ metadata: auditLogSchema.metadata
33
+ ? deserializeMetadata(auditLogSchema.metadata)
34
+ : undefined,
33
35
  createdAt: auditLogSchema.created_at,
34
36
  });
35
37
  };
package/lib/workos.js CHANGED
@@ -29,7 +29,7 @@ const subtle_crypto_provider_1 = require("./common/crypto/subtle-crypto-provider
29
29
  const fetch_client_1 = require("./common/net/fetch-client");
30
30
  const widgets_1 = require("./widgets/widgets");
31
31
  const actions_1 = require("./actions/actions");
32
- const VERSION = '7.33.0';
32
+ const VERSION = '7.33.1';
33
33
  const DEFAULT_HOSTNAME = 'api.workos.com';
34
34
  const HEADER_AUTHORIZATION = 'Authorization';
35
35
  const HEADER_IDEMPOTENCY_KEY = 'Idempotency-Key';
package/package.json CHANGED
@@ -1,5 +1,5 @@
1
1
  {
2
- "version": "7.33.0",
2
+ "version": "7.33.1",
3
3
  "name": "@workos-inc/node",
4
4
  "author": "WorkOS",
5
5
  "description": "A Node wrapper for the WorkOS API",