@workos-inc/node 7.27.0 → 7.27.2

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.
@@ -500,6 +500,7 @@ describe.skip('FGA Live Test', () => {
500
500
  resource: newPermission,
501
501
  relation: 'member',
502
502
  subject: user2,
503
+ policy: 'region == "us"',
503
504
  });
504
505
  expect(warrant2.warrantToken).toBeDefined();
505
506
  const warrants1 = yield workos.fga.listWarrants({ limit: 1 }, { warrantToken: 'latest' });
@@ -509,6 +510,7 @@ describe.skip('FGA Live Test', () => {
509
510
  expect(warrants1.data[0].relation).toEqual('member');
510
511
  expect(warrants1.data[0].subject.resourceType).toEqual('user');
511
512
  expect(warrants1.data[0].subject.resourceId).toEqual(user2.resourceId);
513
+ expect(warrants1.data[0].policy).toEqual('region == "us"');
512
514
  const warrants2 = yield workos.fga.listWarrants({ limit: 1, after: warrants1.listMetadata.after }, { warrantToken: 'latest' });
513
515
  expect(warrants2.data.length).toEqual(1);
514
516
  expect(warrants2.data[0].resourceType).toEqual('permission');
@@ -869,4 +871,57 @@ describe.skip('FGA Live Test', () => {
869
871
  yield workos.fga.deleteResource(userA);
870
872
  yield workos.fga.deleteResource(userB);
871
873
  }));
874
+ it('batch write resources', () => __awaiter(void 0, void 0, void 0, function* () {
875
+ const objects = yield workos.fga.batchWriteResources({
876
+ op: interfaces_1.ResourceOp.Create,
877
+ resources: [
878
+ {
879
+ resource: {
880
+ resourceType: 'user',
881
+ resourceId: 'user1',
882
+ },
883
+ },
884
+ {
885
+ resource: {
886
+ resourceType: 'user',
887
+ resourceId: 'user2',
888
+ },
889
+ },
890
+ {
891
+ resource: {
892
+ resourceType: 'tenant',
893
+ resourceId: 'tenantA',
894
+ },
895
+ meta: {
896
+ name: 'Tenant A',
897
+ },
898
+ },
899
+ ],
900
+ });
901
+ expect(objects.length).toEqual(3);
902
+ expect(objects[0].resourceType).toEqual('user');
903
+ expect(objects[0].resourceId).toEqual('user1');
904
+ expect(objects[1].resourceType).toEqual('user');
905
+ expect(objects[1].resourceId).toEqual('user2');
906
+ expect(objects[2].resourceType).toEqual('tenant');
907
+ expect(objects[2].resourceId).toEqual('tenantA');
908
+ expect(objects[2].meta).toEqual({ name: 'Tenant A' });
909
+ yield workos.fga.batchWriteResources({
910
+ op: interfaces_1.ResourceOp.Delete,
911
+ resources: [
912
+ {
913
+ resourceType: 'user',
914
+ resourceId: 'user1',
915
+ },
916
+ {
917
+ resourceType: 'user',
918
+ resourceId: 'user2',
919
+ },
920
+ {
921
+ resourceType: 'tenant',
922
+ resourceId: 'tenantA',
923
+ },
924
+ ],
925
+ });
926
+ }));
872
927
  });
package/lib/fga/fga.js CHANGED
@@ -81,7 +81,7 @@ class FGA {
81
81
  }
82
82
  batchWriteResources(options) {
83
83
  return __awaiter(this, void 0, void 0, function* () {
84
- const { data } = yield this.workos.post('/fga/v1/resources/batch', options);
84
+ const { data } = yield this.workos.post('/fga/v1/resources/batch', (0, serializers_1.serializeBatchWriteResourcesOptions)(options));
85
85
  return (0, serializers_1.deserializeBatchWriteResourcesResponse)(data);
86
86
  });
87
87
  }
@@ -497,6 +497,7 @@ describe('FGA', () => {
497
497
  resource_type: 'user',
498
498
  resource_id: 'user_124',
499
499
  },
500
+ policy: 'region == "us"',
500
501
  },
501
502
  ],
502
503
  list_metadata: {
@@ -524,6 +525,7 @@ describe('FGA', () => {
524
525
  resourceType: 'user',
525
526
  resourceId: 'user_124',
526
527
  },
528
+ policy: 'region == "us"',
527
529
  },
528
530
  ]);
529
531
  }));
@@ -63,6 +63,10 @@ export interface BatchWriteResourcesOptions {
63
63
  op: ResourceOp;
64
64
  resources: CreateResourceOptions[] | DeleteResourceOptions[];
65
65
  }
66
+ export interface SerializedBatchWriteResourcesOptions {
67
+ op: string;
68
+ resources: SerializedCreateResourceOptions[] | SerializedDeleteResourceOptions[];
69
+ }
66
70
  export interface BatchWriteResourcesResponse {
67
71
  data: ResourceResponse[];
68
72
  }
@@ -62,4 +62,5 @@ export interface WarrantResponse {
62
62
  resource_id: string;
63
63
  relation: string;
64
64
  subject: SerializedSubject;
65
+ policy?: string;
65
66
  }
@@ -0,0 +1,2 @@
1
+ import { BatchWriteResourcesOptions, SerializedBatchWriteResourcesOptions } from '../interfaces';
2
+ export declare const serializeBatchWriteResourcesOptions: (options: BatchWriteResourcesOptions) => SerializedBatchWriteResourcesOptions;
@@ -0,0 +1,22 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.serializeBatchWriteResourcesOptions = void 0;
4
+ const interfaces_1 = require("../interfaces");
5
+ const create_resource_options_serializer_1 = require("./create-resource-options.serializer");
6
+ const delete_resource_options_serializer_1 = require("./delete-resource-options.serializer");
7
+ const serializeBatchWriteResourcesOptions = (options) => {
8
+ let serializedResources = [];
9
+ if (options.op === interfaces_1.ResourceOp.Create) {
10
+ const resources = options.resources;
11
+ serializedResources = resources.map((options) => (0, create_resource_options_serializer_1.serializeCreateResourceOptions)(options));
12
+ }
13
+ else if (options.op === interfaces_1.ResourceOp.Delete) {
14
+ const resources = options.resources;
15
+ serializedResources = resources.map((options) => (0, delete_resource_options_serializer_1.serializeDeleteResourceOptions)(options));
16
+ }
17
+ return {
18
+ op: options.op,
19
+ resources: serializedResources,
20
+ };
21
+ };
22
+ exports.serializeBatchWriteResourcesOptions = serializeBatchWriteResourcesOptions;
@@ -1,4 +1,5 @@
1
1
  export * from './check-options.serializer';
2
+ export * from './batch-write-resources-options.serializer';
2
3
  export * from './create-resource-options.serializer';
3
4
  export * from './delete-resource-options.serializer';
4
5
  export * from './list-resources-options.serializer';
@@ -15,6 +15,7 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
15
15
  };
16
16
  Object.defineProperty(exports, "__esModule", { value: true });
17
17
  __exportStar(require("./check-options.serializer"), exports);
18
+ __exportStar(require("./batch-write-resources-options.serializer"), exports);
18
19
  __exportStar(require("./create-resource-options.serializer"), exports);
19
20
  __exportStar(require("./delete-resource-options.serializer"), exports);
20
21
  __exportStar(require("./list-resources-options.serializer"), exports);
@@ -10,5 +10,6 @@ const deserializeWarrant = (warrant) => ({
10
10
  resourceId: warrant.subject.resource_id,
11
11
  relation: warrant.subject.relation,
12
12
  },
13
+ policy: warrant.policy,
13
14
  });
14
15
  exports.deserializeWarrant = deserializeWarrant;
package/lib/index.d.ts CHANGED
@@ -12,6 +12,7 @@ export * from './directory-sync/utils/get-primary-email';
12
12
  export * from './events/interfaces';
13
13
  export * from './fga/interfaces';
14
14
  export * from './organizations/interfaces';
15
+ export * from './organization-domains/interfaces';
15
16
  export * from './passwordless/interfaces';
16
17
  export * from './portal/interfaces';
17
18
  export * from './sso/interfaces';
package/lib/index.js CHANGED
@@ -31,6 +31,7 @@ __exportStar(require("./directory-sync/utils/get-primary-email"), exports);
31
31
  __exportStar(require("./events/interfaces"), exports);
32
32
  __exportStar(require("./fga/interfaces"), exports);
33
33
  __exportStar(require("./organizations/interfaces"), exports);
34
+ __exportStar(require("./organization-domains/interfaces"), exports);
34
35
  __exportStar(require("./passwordless/interfaces"), exports);
35
36
  __exportStar(require("./portal/interfaces"), exports);
36
37
  __exportStar(require("./sso/interfaces"), exports);
@@ -1,6 +1,5 @@
1
1
  export * from './create-organization-options.interface';
2
2
  export * from './domain-data.interface';
3
3
  export * from './list-organizations-options.interface';
4
- export * from './organization-domain.interface';
5
4
  export * from './organization.interface';
6
5
  export * from './update-organization-options.interface';
@@ -17,6 +17,5 @@ Object.defineProperty(exports, "__esModule", { value: true });
17
17
  __exportStar(require("./create-organization-options.interface"), exports);
18
18
  __exportStar(require("./domain-data.interface"), exports);
19
19
  __exportStar(require("./list-organizations-options.interface"), exports);
20
- __exportStar(require("./organization-domain.interface"), exports);
21
20
  __exportStar(require("./organization.interface"), exports);
22
21
  __exportStar(require("./update-organization-options.interface"), exports);
@@ -1,4 +1,4 @@
1
- import { OrganizationDomain } from './organization-domain.interface';
1
+ import { OrganizationDomain } from '../../organization-domains/interfaces/organization-domain.interface';
2
2
  export interface Organization {
3
3
  object: 'organization';
4
4
  id: string;
package/lib/workos.js CHANGED
@@ -27,7 +27,7 @@ const bad_request_exception_1 = require("./common/exceptions/bad-request.excepti
27
27
  const http_client_1 = require("./common/net/http-client");
28
28
  const subtle_crypto_provider_1 = require("./common/crypto/subtle-crypto-provider");
29
29
  const fetch_client_1 = require("./common/net/fetch-client");
30
- const VERSION = '7.27.0';
30
+ const VERSION = '7.27.2';
31
31
  const DEFAULT_HOSTNAME = 'api.workos.com';
32
32
  const HEADER_AUTHORIZATION = 'Authorization';
33
33
  const HEADER_IDEMPOTENCY_KEY = 'Idempotency-Key';
package/package.json CHANGED
@@ -1,5 +1,5 @@
1
1
  {
2
- "version": "7.27.0",
2
+ "version": "7.27.2",
3
3
  "name": "@workos-inc/node",
4
4
  "author": "WorkOS",
5
5
  "description": "A Node wrapper for the WorkOS API",
@@ -1,5 +0,0 @@
1
- export interface OrganizationDomain {
2
- object: 'organization_domain';
3
- id: string;
4
- domain: string;
5
- }
@@ -1,2 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });