@commercelayer/provisioning-sdk 1.0.4 → 2.0.0-beta.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.
Files changed (99) hide show
  1. package/lib/index.d.mts +665 -0
  2. package/lib/index.d.ts +665 -0
  3. package/lib/index.js +1 -0
  4. package/lib/index.mjs +1 -0
  5. package/package.json +22 -26
  6. package/lib/cjs/api.d.ts +0 -43
  7. package/lib/cjs/api.js +0 -45
  8. package/lib/cjs/client.d.ts +0 -42
  9. package/lib/cjs/client.js +0 -149
  10. package/lib/cjs/commercelayer.d.ts +0 -39
  11. package/lib/cjs/commercelayer.js +0 -130
  12. package/lib/cjs/common.d.ts +0 -5
  13. package/lib/cjs/common.js +0 -12
  14. package/lib/cjs/config.d.ts +0 -15
  15. package/lib/cjs/config.js +0 -19
  16. package/lib/cjs/debug.d.ts +0 -3
  17. package/lib/cjs/debug.js +0 -38
  18. package/lib/cjs/error.d.ts +0 -31
  19. package/lib/cjs/error.js +0 -77
  20. package/lib/cjs/index.d.ts +0 -7
  21. package/lib/cjs/index.js +0 -13
  22. package/lib/cjs/interceptor.d.ts +0 -25
  23. package/lib/cjs/interceptor.js +0 -2
  24. package/lib/cjs/jsonapi.d.ts +0 -6
  25. package/lib/cjs/jsonapi.js +0 -94
  26. package/lib/cjs/model.d.ts +0 -11
  27. package/lib/cjs/model.js +0 -3
  28. package/lib/cjs/query.d.ts +0 -17
  29. package/lib/cjs/query.js +0 -52
  30. package/lib/cjs/resource.d.ts +0 -86
  31. package/lib/cjs/resource.js +0 -194
  32. package/lib/cjs/resources/api_credentials.d.ts +0 -59
  33. package/lib/cjs/resources/api_credentials.js +0 -33
  34. package/lib/cjs/resources/application_memberships.d.ts +0 -57
  35. package/lib/cjs/resources/application_memberships.js +0 -41
  36. package/lib/cjs/resources/memberships.d.ts +0 -58
  37. package/lib/cjs/resources/memberships.js +0 -45
  38. package/lib/cjs/resources/organizations.d.ts +0 -84
  39. package/lib/cjs/resources/organizations.js +0 -42
  40. package/lib/cjs/resources/permissions.d.ts +0 -52
  41. package/lib/cjs/resources/permissions.js +0 -34
  42. package/lib/cjs/resources/roles.d.ts +0 -47
  43. package/lib/cjs/resources/roles.js +0 -42
  44. package/lib/cjs/resources/user.d.ts +0 -29
  45. package/lib/cjs/resources/user.js +0 -20
  46. package/lib/cjs/resources/versions.d.ts +0 -22
  47. package/lib/cjs/resources/versions.js +0 -16
  48. package/lib/cjs/static.d.ts +0 -12
  49. package/lib/cjs/static.js +0 -51
  50. package/lib/cjs/util.d.ts +0 -9
  51. package/lib/cjs/util.js +0 -16
  52. package/lib/esm/api.d.ts +0 -43
  53. package/lib/esm/api.js +0 -31
  54. package/lib/esm/client.d.ts +0 -42
  55. package/lib/esm/client.js +0 -144
  56. package/lib/esm/commercelayer.d.ts +0 -39
  57. package/lib/esm/commercelayer.js +0 -101
  58. package/lib/esm/common.d.ts +0 -5
  59. package/lib/esm/common.js +0 -8
  60. package/lib/esm/config.d.ts +0 -15
  61. package/lib/esm/config.js +0 -17
  62. package/lib/esm/debug.d.ts +0 -3
  63. package/lib/esm/debug.js +0 -36
  64. package/lib/esm/error.d.ts +0 -31
  65. package/lib/esm/error.js +0 -69
  66. package/lib/esm/index.d.ts +0 -7
  67. package/lib/esm/index.js +0 -4
  68. package/lib/esm/interceptor.d.ts +0 -25
  69. package/lib/esm/interceptor.js +0 -1
  70. package/lib/esm/jsonapi.d.ts +0 -6
  71. package/lib/esm/jsonapi.js +0 -87
  72. package/lib/esm/model.d.ts +0 -11
  73. package/lib/esm/model.js +0 -2
  74. package/lib/esm/query.d.ts +0 -17
  75. package/lib/esm/query.js +0 -45
  76. package/lib/esm/resource.d.ts +0 -86
  77. package/lib/esm/resource.js +0 -187
  78. package/lib/esm/resources/api_credentials.d.ts +0 -59
  79. package/lib/esm/resources/api_credentials.js +0 -31
  80. package/lib/esm/resources/application_memberships.d.ts +0 -57
  81. package/lib/esm/resources/application_memberships.js +0 -39
  82. package/lib/esm/resources/memberships.d.ts +0 -58
  83. package/lib/esm/resources/memberships.js +0 -43
  84. package/lib/esm/resources/organizations.d.ts +0 -84
  85. package/lib/esm/resources/organizations.js +0 -40
  86. package/lib/esm/resources/permissions.d.ts +0 -52
  87. package/lib/esm/resources/permissions.js +0 -32
  88. package/lib/esm/resources/roles.d.ts +0 -47
  89. package/lib/esm/resources/roles.js +0 -40
  90. package/lib/esm/resources/user.d.ts +0 -29
  91. package/lib/esm/resources/user.js +0 -18
  92. package/lib/esm/resources/versions.d.ts +0 -22
  93. package/lib/esm/resources/versions.js +0 -14
  94. package/lib/esm/static.d.ts +0 -12
  95. package/lib/esm/static.js +0 -25
  96. package/lib/esm/util.d.ts +0 -9
  97. package/lib/esm/util.js +0 -37
  98. package/lib/tsconfig.esm.tsbuildinfo +0 -1
  99. package/lib/tsconfig.tsbuildinfo +0 -1
@@ -1,194 +0,0 @@
1
- "use strict";
2
- var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
3
- if (kind === "m") throw new TypeError("Private method is not writable");
4
- if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
5
- if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
6
- return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
7
- };
8
- var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
9
- if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
10
- if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
11
- return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
12
- };
13
- var __importDefault = (this && this.__importDefault) || function (mod) {
14
- return (mod && mod.__esModule) ? mod : { "default": mod };
15
- };
16
- var _ResourceAdapter_client, _ResourceAdapter_config;
17
- Object.defineProperty(exports, "__esModule", { value: true });
18
- exports.ApiSingleton = exports.ApiResource = void 0;
19
- const client_1 = __importDefault(require("./client"));
20
- const jsonapi_1 = require("./jsonapi");
21
- const query_1 = require("./query");
22
- const config_1 = __importDefault(require("./config"));
23
- const error_1 = require("./error");
24
- const static_1 = require("./static");
25
- const debug_1 = __importDefault(require("./debug"));
26
- const debug = (0, debug_1.default)('resource');
27
- class ListResponse extends Array {
28
- constructor(meta, data) {
29
- super(...(data || []));
30
- this.meta = meta;
31
- }
32
- first() { return this.length ? this[0] : undefined; }
33
- last() { return this.length ? this[this.length - 1] : undefined; }
34
- get(index) { return (this.length && (index >= 0)) ? this[index] : undefined; }
35
- hasNextPage() { return (this.meta.currentPage < this.meta.pageCount); }
36
- hasPrevPage() { return (this.meta.currentPage > 1); }
37
- getRecordCount() { return this.meta.recordCount; }
38
- getPageCount() { return this.meta.pageCount; }
39
- get recordCount() { return this.meta.recordCount; }
40
- get pageCount() { return this.meta.pageCount; }
41
- }
42
- class ResourceAdapter {
43
- constructor(config) {
44
- _ResourceAdapter_client.set(this, void 0);
45
- _ResourceAdapter_config.set(this, {});
46
- __classPrivateFieldSet(this, _ResourceAdapter_client, client_1.default.create(config), "f");
47
- this.localConfig(config);
48
- }
49
- get interceptors() { return __classPrivateFieldGet(this, _ResourceAdapter_client, "f").interceptors; }
50
- localConfig(config) {
51
- // if (typeof config.xyz !== 'undefined') this.#config.xyz = config.xyz
52
- }
53
- config(config) {
54
- debug('config %o', config);
55
- // ResourceAdapter config
56
- this.localConfig(config);
57
- // Client config
58
- __classPrivateFieldGet(this, _ResourceAdapter_client, "f").config(config);
59
- return this;
60
- }
61
- /*
62
- get clientInstance(): ApiClient {
63
- return this.#client
64
- }
65
- */
66
- async retrieve(resource, params, options) {
67
- const singleton = !('id' in resource) || static_1.CommerceLayerProvisioningStatic.isSingleton(resource.type);
68
- debug('retrieve:%s %o, %O, %O', (singleton ? ' singleton,' : ''), resource, params || {}, options || {});
69
- const queryParams = (0, query_1.generateQueryStringParams)(params, resource);
70
- if (options === null || options === void 0 ? void 0 : options.params)
71
- Object.assign(queryParams, options === null || options === void 0 ? void 0 : options.params);
72
- const path = `${resource.type}${singleton ? '' : `/${resource.id}`}`;
73
- const res = await __classPrivateFieldGet(this, _ResourceAdapter_client, "f").request('get', path, undefined, { ...options, params: queryParams });
74
- const r = (0, jsonapi_1.denormalize)(res);
75
- return r;
76
- }
77
- async list(resource, params, options) {
78
- var _a, _b;
79
- debug('list: %o, %O, %O', resource, params || {}, options || {});
80
- const queryParams = (0, query_1.generateQueryStringParams)(params, resource);
81
- if (options === null || options === void 0 ? void 0 : options.params)
82
- Object.assign(queryParams, options === null || options === void 0 ? void 0 : options.params);
83
- const res = await __classPrivateFieldGet(this, _ResourceAdapter_client, "f").request('get', `${resource.type}`, undefined, { ...options, params: queryParams });
84
- const r = (0, jsonapi_1.denormalize)(res);
85
- const meta = {
86
- pageCount: Number((_a = res.meta) === null || _a === void 0 ? void 0 : _a.page_count),
87
- recordCount: Number((_b = res.meta) === null || _b === void 0 ? void 0 : _b.record_count),
88
- currentPage: (params === null || params === void 0 ? void 0 : params.pageNumber) || config_1.default.default.pageNumber,
89
- recordsPerPage: (params === null || params === void 0 ? void 0 : params.pageSize) || config_1.default.default.pageSize
90
- };
91
- return new ListResponse(meta, r);
92
- }
93
- async create(resource, params, options) {
94
- debug('create: %o, %O, %O', resource, params || {}, options || {});
95
- const queryParams = (0, query_1.generateQueryStringParams)(params, resource);
96
- if (options === null || options === void 0 ? void 0 : options.params)
97
- Object.assign(queryParams, options === null || options === void 0 ? void 0 : options.params);
98
- const data = (0, jsonapi_1.normalize)(resource);
99
- const res = await __classPrivateFieldGet(this, _ResourceAdapter_client, "f").request('post', resource.type, data, { ...options, params: queryParams });
100
- const r = (0, jsonapi_1.denormalize)(res);
101
- return r;
102
- }
103
- async update(resource, params, options) {
104
- const singleton = !('id' in resource) || static_1.CommerceLayerProvisioningStatic.isSingleton(resource.type);
105
- debug('update:%s %o, %O, %O', (singleton ? ' singleton,' : ''), resource, params || {}, options || {});
106
- const queryParams = (0, query_1.generateQueryStringParams)(params, resource);
107
- if (options === null || options === void 0 ? void 0 : options.params)
108
- Object.assign(queryParams, options === null || options === void 0 ? void 0 : options.params);
109
- const path = `${resource.type}${singleton ? '' : `/${resource.id}`}`;
110
- const data = (0, jsonapi_1.normalize)(resource);
111
- const res = await __classPrivateFieldGet(this, _ResourceAdapter_client, "f").request('patch', path, data, { ...options, params: queryParams });
112
- const r = (0, jsonapi_1.denormalize)(res);
113
- return r;
114
- }
115
- async delete(resource, options) {
116
- debug('delete: %o, %O', resource, options || {});
117
- await __classPrivateFieldGet(this, _ResourceAdapter_client, "f").request('delete', `${resource.type}/${resource.id}`, undefined, options);
118
- }
119
- async fetch(resource, path, params, options) {
120
- var _a, _b;
121
- debug('fetch: %o, %O, %O', path, params || {}, options || {});
122
- const queryParams = (0, query_1.generateQueryStringParams)(params, resource);
123
- if (options === null || options === void 0 ? void 0 : options.params)
124
- Object.assign(queryParams, options === null || options === void 0 ? void 0 : options.params);
125
- const res = await __classPrivateFieldGet(this, _ResourceAdapter_client, "f").request('get', path, undefined, { ...options, params: queryParams });
126
- const r = (0, jsonapi_1.denormalize)(res);
127
- if (Array.isArray(r)) {
128
- const p = params;
129
- const meta = {
130
- pageCount: Number((_a = res.meta) === null || _a === void 0 ? void 0 : _a.page_count),
131
- recordCount: Number((_b = res.meta) === null || _b === void 0 ? void 0 : _b.record_count),
132
- currentPage: (p === null || p === void 0 ? void 0 : p.pageNumber) || config_1.default.default.pageNumber,
133
- recordsPerPage: (p === null || p === void 0 ? void 0 : p.pageSize) || config_1.default.default.pageSize
134
- };
135
- return new ListResponse(meta, r);
136
- }
137
- else
138
- return r;
139
- }
140
- async action(cmd, path, payload, options) {
141
- debug('action: %o %o, %O', cmd, path, options || {});
142
- const queryParams = {};
143
- if (options === null || options === void 0 ? void 0 : options.params)
144
- Object.assign(queryParams, options === null || options === void 0 ? void 0 : options.params);
145
- await __classPrivateFieldGet(this, _ResourceAdapter_client, "f").request(cmd, path, payload, { ...options, params: queryParams });
146
- }
147
- }
148
- _ResourceAdapter_client = new WeakMap(), _ResourceAdapter_config = new WeakMap();
149
- class ApiResourceBase {
150
- constructor(adapter) {
151
- debug('new resource instance: %s', this.type());
152
- this.resources = adapter;
153
- }
154
- parse(resource) {
155
- var _a, _b;
156
- try {
157
- const res = JSON.parse(resource);
158
- if (((_a = res.data) === null || _a === void 0 ? void 0 : _a.type) !== this.type())
159
- throw new error_1.SdkError({ message: `Invalid resource type [${(_b = res.data) === null || _b === void 0 ? void 0 : _b.type}]`, type: error_1.ErrorType.PARSE });
160
- return (0, jsonapi_1.denormalize)(res);
161
- }
162
- catch (error) {
163
- if (error_1.SdkError.isSdkError(error))
164
- throw error;
165
- else
166
- throw new error_1.SdkError({ message: `Payload parse error [${error.message}]`, type: error_1.ErrorType.PARSE });
167
- }
168
- }
169
- // reference, reference_origin and metadata attributes are always updatable
170
- async update(resource, params, options) {
171
- return this.resources.update({ ...resource, type: this.type() }, params, options);
172
- }
173
- }
174
- class ApiResource extends ApiResourceBase {
175
- async retrieve(id, params, options) {
176
- return this.resources.retrieve((typeof id === 'string') ? { type: this.type(), id } : id, params, options);
177
- }
178
- async list(params, options) {
179
- return this.resources.list({ type: this.type() }, params, options);
180
- }
181
- async count(filter, options) {
182
- const params = { filters: (0, query_1.isParamsList)(filter) ? filter.filters : filter, pageNumber: 1, pageSize: 1 };
183
- const response = await this.list(params, options);
184
- return Promise.resolve(response.meta.recordCount);
185
- }
186
- }
187
- exports.ApiResource = ApiResource;
188
- class ApiSingleton extends ApiResourceBase {
189
- async retrieve(params, options) {
190
- return this.resources.retrieve({ type: this.type() }, params, options);
191
- }
192
- }
193
- exports.ApiSingleton = ApiSingleton;
194
- exports.default = ResourceAdapter;
@@ -1,59 +0,0 @@
1
- import { ApiResource } from '../resource';
2
- import type { Resource, ResourceCreate, ResourceUpdate, ResourceId, ResourcesConfig, ResourceRel } from '../resource';
3
- import type { QueryParamsRetrieve } from '../query';
4
- import type { Organization, OrganizationType } from './organizations';
5
- import type { Role, RoleType } from './roles';
6
- type ApiCredentialType = 'api_credentials';
7
- type ApiCredentialRel = ResourceRel & {
8
- type: ApiCredentialType;
9
- };
10
- type OrganizationRel = ResourceRel & {
11
- type: OrganizationType;
12
- };
13
- type RoleRel = ResourceRel & {
14
- type: RoleType;
15
- };
16
- interface ApiCredential extends Resource {
17
- readonly type: ApiCredentialType;
18
- name: string;
19
- kind: string;
20
- confidential: boolean;
21
- redirect_uri?: string | null;
22
- client_id: string;
23
- client_secret: string;
24
- scopes: string;
25
- expires_in?: number | null;
26
- mode?: string | null;
27
- custom?: boolean | null;
28
- organization?: Organization | null;
29
- role?: Role | null;
30
- }
31
- interface ApiCredentialCreate extends ResourceCreate {
32
- name: string;
33
- kind: string;
34
- redirect_uri?: string | null;
35
- expires_in?: number | null;
36
- mode?: string | null;
37
- custom?: boolean | null;
38
- organization: OrganizationRel;
39
- role?: RoleRel | null;
40
- }
41
- interface ApiCredentialUpdate extends ResourceUpdate {
42
- name?: string | null;
43
- redirect_uri?: string | null;
44
- expires_in?: number | null;
45
- role?: RoleRel | null;
46
- }
47
- declare class ApiCredentials extends ApiResource<ApiCredential> {
48
- static readonly TYPE: ApiCredentialType;
49
- create(resource: ApiCredentialCreate, params?: QueryParamsRetrieve, options?: ResourcesConfig): Promise<ApiCredential>;
50
- update(resource: ApiCredentialUpdate, params?: QueryParamsRetrieve, options?: ResourcesConfig): Promise<ApiCredential>;
51
- delete(id: string | ResourceId, options?: ResourcesConfig): Promise<void>;
52
- organization(apiCredentialId: string | ApiCredential, params?: QueryParamsRetrieve, options?: ResourcesConfig): Promise<Organization>;
53
- role(apiCredentialId: string | ApiCredential, params?: QueryParamsRetrieve, options?: ResourcesConfig): Promise<Role>;
54
- isApiCredential(resource: any): resource is ApiCredential;
55
- relationship(id: string | ResourceId | null): ApiCredentialRel;
56
- type(): ApiCredentialType;
57
- }
58
- export default ApiCredentials;
59
- export type { ApiCredential, ApiCredentialCreate, ApiCredentialUpdate, ApiCredentialType };
@@ -1,33 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- const resource_1 = require("../resource");
4
- class ApiCredentials extends resource_1.ApiResource {
5
- async create(resource, params, options) {
6
- return this.resources.create({ ...resource, type: ApiCredentials.TYPE }, params, options);
7
- }
8
- async update(resource, params, options) {
9
- return this.resources.update({ ...resource, type: ApiCredentials.TYPE }, params, options);
10
- }
11
- async delete(id, options) {
12
- await this.resources.delete((typeof id === 'string') ? { id, type: ApiCredentials.TYPE } : id, options);
13
- }
14
- async organization(apiCredentialId, params, options) {
15
- const _apiCredentialId = apiCredentialId.id || apiCredentialId;
16
- return this.resources.fetch({ type: 'organizations' }, `api_credentials/${_apiCredentialId}/organization`, params, options);
17
- }
18
- async role(apiCredentialId, params, options) {
19
- const _apiCredentialId = apiCredentialId.id || apiCredentialId;
20
- return this.resources.fetch({ type: 'roles' }, `api_credentials/${_apiCredentialId}/role`, params, options);
21
- }
22
- isApiCredential(resource) {
23
- return resource.type && (resource.type === ApiCredentials.TYPE);
24
- }
25
- relationship(id) {
26
- return ((id === null) || (typeof id === 'string')) ? { id, type: ApiCredentials.TYPE } : { id: id.id, type: ApiCredentials.TYPE };
27
- }
28
- type() {
29
- return ApiCredentials.TYPE;
30
- }
31
- }
32
- ApiCredentials.TYPE = 'api_credentials';
33
- exports.default = ApiCredentials;
@@ -1,57 +0,0 @@
1
- import { ApiResource } from '../resource';
2
- import type { Resource, ResourceCreate, ResourceUpdate, ResourceId, ResourcesConfig, ResourceRel } from '../resource';
3
- import type { QueryParamsRetrieve } from '../query';
4
- import type { ApiCredential, ApiCredentialType } from './api_credentials';
5
- import type { Membership, MembershipType } from './memberships';
6
- import type { Organization, OrganizationType } from './organizations';
7
- import type { Role, RoleType } from './roles';
8
- type ApplicationMembershipType = 'application_memberships';
9
- type ApplicationMembershipRel = ResourceRel & {
10
- type: ApplicationMembershipType;
11
- };
12
- type ApiCredentialRel = ResourceRel & {
13
- type: ApiCredentialType;
14
- };
15
- type MembershipRel = ResourceRel & {
16
- type: MembershipType;
17
- };
18
- type OrganizationRel = ResourceRel & {
19
- type: OrganizationType;
20
- };
21
- type RoleRel = ResourceRel & {
22
- type: RoleType;
23
- };
24
- interface ApplicationMembership extends Resource {
25
- readonly type: ApplicationMembershipType;
26
- filters?: Record<string, any> | null;
27
- api_credential?: ApiCredential | null;
28
- membership?: Membership | null;
29
- organization?: Organization | null;
30
- role?: Role | null;
31
- }
32
- interface ApplicationMembershipCreate extends ResourceCreate {
33
- filters?: Record<string, any> | null;
34
- api_credential: ApiCredentialRel;
35
- membership: MembershipRel;
36
- organization: OrganizationRel;
37
- role: RoleRel;
38
- }
39
- interface ApplicationMembershipUpdate extends ResourceUpdate {
40
- filters?: Record<string, any> | null;
41
- role?: RoleRel | null;
42
- }
43
- declare class ApplicationMemberships extends ApiResource<ApplicationMembership> {
44
- static readonly TYPE: ApplicationMembershipType;
45
- create(resource: ApplicationMembershipCreate, params?: QueryParamsRetrieve, options?: ResourcesConfig): Promise<ApplicationMembership>;
46
- update(resource: ApplicationMembershipUpdate, params?: QueryParamsRetrieve, options?: ResourcesConfig): Promise<ApplicationMembership>;
47
- delete(id: string | ResourceId, options?: ResourcesConfig): Promise<void>;
48
- api_credential(applicationMembershipId: string | ApplicationMembership, params?: QueryParamsRetrieve, options?: ResourcesConfig): Promise<ApiCredential>;
49
- membership(applicationMembershipId: string | ApplicationMembership, params?: QueryParamsRetrieve, options?: ResourcesConfig): Promise<Membership>;
50
- organization(applicationMembershipId: string | ApplicationMembership, params?: QueryParamsRetrieve, options?: ResourcesConfig): Promise<Organization>;
51
- role(applicationMembershipId: string | ApplicationMembership, params?: QueryParamsRetrieve, options?: ResourcesConfig): Promise<Role>;
52
- isApplicationMembership(resource: any): resource is ApplicationMembership;
53
- relationship(id: string | ResourceId | null): ApplicationMembershipRel;
54
- type(): ApplicationMembershipType;
55
- }
56
- export default ApplicationMemberships;
57
- export type { ApplicationMembership, ApplicationMembershipCreate, ApplicationMembershipUpdate, ApplicationMembershipType };
@@ -1,41 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- const resource_1 = require("../resource");
4
- class ApplicationMemberships extends resource_1.ApiResource {
5
- async create(resource, params, options) {
6
- return this.resources.create({ ...resource, type: ApplicationMemberships.TYPE }, params, options);
7
- }
8
- async update(resource, params, options) {
9
- return this.resources.update({ ...resource, type: ApplicationMemberships.TYPE }, params, options);
10
- }
11
- async delete(id, options) {
12
- await this.resources.delete((typeof id === 'string') ? { id, type: ApplicationMemberships.TYPE } : id, options);
13
- }
14
- async api_credential(applicationMembershipId, params, options) {
15
- const _applicationMembershipId = applicationMembershipId.id || applicationMembershipId;
16
- return this.resources.fetch({ type: 'api_credentials' }, `application_memberships/${_applicationMembershipId}/api_credential`, params, options);
17
- }
18
- async membership(applicationMembershipId, params, options) {
19
- const _applicationMembershipId = applicationMembershipId.id || applicationMembershipId;
20
- return this.resources.fetch({ type: 'memberships' }, `application_memberships/${_applicationMembershipId}/membership`, params, options);
21
- }
22
- async organization(applicationMembershipId, params, options) {
23
- const _applicationMembershipId = applicationMembershipId.id || applicationMembershipId;
24
- return this.resources.fetch({ type: 'organizations' }, `application_memberships/${_applicationMembershipId}/organization`, params, options);
25
- }
26
- async role(applicationMembershipId, params, options) {
27
- const _applicationMembershipId = applicationMembershipId.id || applicationMembershipId;
28
- return this.resources.fetch({ type: 'roles' }, `application_memberships/${_applicationMembershipId}/role`, params, options);
29
- }
30
- isApplicationMembership(resource) {
31
- return resource.type && (resource.type === ApplicationMemberships.TYPE);
32
- }
33
- relationship(id) {
34
- return ((id === null) || (typeof id === 'string')) ? { id, type: ApplicationMemberships.TYPE } : { id: id.id, type: ApplicationMemberships.TYPE };
35
- }
36
- type() {
37
- return ApplicationMemberships.TYPE;
38
- }
39
- }
40
- ApplicationMemberships.TYPE = 'application_memberships';
41
- exports.default = ApplicationMemberships;
@@ -1,58 +0,0 @@
1
- import { ApiResource } from '../resource';
2
- import type { Resource, ResourceCreate, ResourceUpdate, ResourceId, ResourcesConfig, ResourceRel, ListResponse } from '../resource';
3
- import type { QueryParamsRetrieve, QueryParamsList } from '../query';
4
- import type { Organization, OrganizationType } from './organizations';
5
- import type { Role, RoleType } from './roles';
6
- import type { ApplicationMembership, ApplicationMembershipType } from './application_memberships';
7
- import type { Version } from './versions';
8
- type MembershipType = 'memberships';
9
- type MembershipRel = ResourceRel & {
10
- type: MembershipType;
11
- };
12
- type OrganizationRel = ResourceRel & {
13
- type: OrganizationType;
14
- };
15
- type RoleRel = ResourceRel & {
16
- type: RoleType;
17
- };
18
- type ApplicationMembershipRel = ResourceRel & {
19
- type: ApplicationMembershipType;
20
- };
21
- interface Membership extends Resource {
22
- readonly type: MembershipType;
23
- user_email: string;
24
- user_first_name: string;
25
- user_last_name: string;
26
- status: 'pending' | 'active';
27
- owner: boolean;
28
- organization?: Organization | null;
29
- role?: Role | null;
30
- application_memberships?: ApplicationMembership[] | null;
31
- versions?: Version[] | null;
32
- }
33
- interface MembershipCreate extends ResourceCreate {
34
- user_email: string;
35
- organization: OrganizationRel;
36
- role: RoleRel;
37
- application_memberships?: ApplicationMembershipRel[] | null;
38
- }
39
- interface MembershipUpdate extends ResourceUpdate {
40
- role?: RoleRel | null;
41
- application_memberships?: ApplicationMembershipRel[] | null;
42
- }
43
- declare class Memberships extends ApiResource<Membership> {
44
- static readonly TYPE: MembershipType;
45
- create(resource: MembershipCreate, params?: QueryParamsRetrieve, options?: ResourcesConfig): Promise<Membership>;
46
- update(resource: MembershipUpdate, params?: QueryParamsRetrieve, options?: ResourcesConfig): Promise<Membership>;
47
- delete(id: string | ResourceId, options?: ResourcesConfig): Promise<void>;
48
- resend(membershipId: string | Membership, options?: ResourcesConfig): Promise<void>;
49
- organization(membershipId: string | Membership, params?: QueryParamsRetrieve, options?: ResourcesConfig): Promise<Organization>;
50
- role(membershipId: string | Membership, params?: QueryParamsRetrieve, options?: ResourcesConfig): Promise<Role>;
51
- application_memberships(membershipId: string | Membership, params?: QueryParamsList, options?: ResourcesConfig): Promise<ListResponse<ApplicationMembership>>;
52
- versions(membershipId: string | Membership, params?: QueryParamsList, options?: ResourcesConfig): Promise<ListResponse<Version>>;
53
- isMembership(resource: any): resource is Membership;
54
- relationship(id: string | ResourceId | null): MembershipRel;
55
- type(): MembershipType;
56
- }
57
- export default Memberships;
58
- export type { Membership, MembershipCreate, MembershipUpdate, MembershipType };
@@ -1,45 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- const resource_1 = require("../resource");
4
- class Memberships extends resource_1.ApiResource {
5
- async create(resource, params, options) {
6
- return this.resources.create({ ...resource, type: Memberships.TYPE }, params, options);
7
- }
8
- async update(resource, params, options) {
9
- return this.resources.update({ ...resource, type: Memberships.TYPE }, params, options);
10
- }
11
- async delete(id, options) {
12
- await this.resources.delete((typeof id === 'string') ? { id, type: Memberships.TYPE } : id, options);
13
- }
14
- async resend(membershipId, options) {
15
- const _membershipId = membershipId.id || membershipId;
16
- await this.resources.action('post', `memberships/${_membershipId}/resend`, {}, options);
17
- }
18
- async organization(membershipId, params, options) {
19
- const _membershipId = membershipId.id || membershipId;
20
- return this.resources.fetch({ type: 'organizations' }, `memberships/${_membershipId}/organization`, params, options);
21
- }
22
- async role(membershipId, params, options) {
23
- const _membershipId = membershipId.id || membershipId;
24
- return this.resources.fetch({ type: 'roles' }, `memberships/${_membershipId}/role`, params, options);
25
- }
26
- async application_memberships(membershipId, params, options) {
27
- const _membershipId = membershipId.id || membershipId;
28
- return this.resources.fetch({ type: 'application_memberships' }, `memberships/${_membershipId}/application_memberships`, params, options);
29
- }
30
- async versions(membershipId, params, options) {
31
- const _membershipId = membershipId.id || membershipId;
32
- return this.resources.fetch({ type: 'versions' }, `memberships/${_membershipId}/versions`, params, options);
33
- }
34
- isMembership(resource) {
35
- return resource.type && (resource.type === Memberships.TYPE);
36
- }
37
- relationship(id) {
38
- return ((id === null) || (typeof id === 'string')) ? { id, type: Memberships.TYPE } : { id: id.id, type: Memberships.TYPE };
39
- }
40
- type() {
41
- return Memberships.TYPE;
42
- }
43
- }
44
- Memberships.TYPE = 'memberships';
45
- exports.default = Memberships;
@@ -1,84 +0,0 @@
1
- import { ApiResource } from '../resource';
2
- import type { Resource, ResourceCreate, ResourceUpdate, ResourceId, ResourcesConfig, ResourceRel, ListResponse } from '../resource';
3
- import type { QueryParamsRetrieve, QueryParamsList } from '../query';
4
- import type { Membership } from './memberships';
5
- import type { Role } from './roles';
6
- import type { Permission } from './permissions';
7
- import type { ApiCredential } from './api_credentials';
8
- type OrganizationType = 'organizations';
9
- type OrganizationRel = ResourceRel & {
10
- type: OrganizationType;
11
- };
12
- interface Organization extends Resource {
13
- readonly type: OrganizationType;
14
- name: string;
15
- slug: string;
16
- domain: string;
17
- support_phone?: string | null;
18
- support_email?: string | null;
19
- logo_url?: string | null;
20
- favicon_url?: string | null;
21
- primary_color?: string | null;
22
- contrast_color?: string | null;
23
- gtm_id?: string | null;
24
- gtm_id_test?: string | null;
25
- discount_disabled?: boolean | null;
26
- account_disabled?: boolean | null;
27
- acceptance_disabled?: boolean | null;
28
- max_concurrent_promotions: number;
29
- max_concurrent_imports: number;
30
- region?: string | null;
31
- can_switch_live: boolean;
32
- subscription_info: Record<string, any>;
33
- memberships?: Membership[] | null;
34
- roles?: Role[] | null;
35
- permissions?: Permission[] | null;
36
- api_credentials?: ApiCredential[] | null;
37
- }
38
- interface OrganizationCreate extends ResourceCreate {
39
- name: string;
40
- support_phone?: string | null;
41
- support_email?: string | null;
42
- logo_url?: string | null;
43
- favicon_url?: string | null;
44
- primary_color?: string | null;
45
- contrast_color?: string | null;
46
- gtm_id?: string | null;
47
- gtm_id_test?: string | null;
48
- discount_disabled?: boolean | null;
49
- account_disabled?: boolean | null;
50
- acceptance_disabled?: boolean | null;
51
- region?: string | null;
52
- }
53
- interface OrganizationUpdate extends ResourceUpdate {
54
- name?: string | null;
55
- support_phone?: string | null;
56
- support_email?: string | null;
57
- logo_url?: string | null;
58
- favicon_url?: string | null;
59
- primary_color?: string | null;
60
- contrast_color?: string | null;
61
- gtm_id?: string | null;
62
- gtm_id_test?: string | null;
63
- discount_disabled?: boolean | null;
64
- account_disabled?: boolean | null;
65
- acceptance_disabled?: boolean | null;
66
- }
67
- declare class Organizations extends ApiResource<Organization> {
68
- static readonly TYPE: OrganizationType;
69
- create(resource: OrganizationCreate, params?: QueryParamsRetrieve, options?: ResourcesConfig): Promise<Organization>;
70
- update(resource: OrganizationUpdate, params?: QueryParamsRetrieve, options?: ResourcesConfig): Promise<Organization>;
71
- transfer_ownership(organizationId: string | Organization, payload: TransferOwnershipDataType, options?: ResourcesConfig): Promise<void>;
72
- memberships(organizationId: string | Organization, params?: QueryParamsList, options?: ResourcesConfig): Promise<ListResponse<Membership>>;
73
- roles(organizationId: string | Organization, params?: QueryParamsList, options?: ResourcesConfig): Promise<ListResponse<Role>>;
74
- permissions(organizationId: string | Organization, params?: QueryParamsList, options?: ResourcesConfig): Promise<ListResponse<Permission>>;
75
- api_credentials(organizationId: string | Organization, params?: QueryParamsList, options?: ResourcesConfig): Promise<ListResponse<ApiCredential>>;
76
- isOrganization(resource: any): resource is Organization;
77
- relationship(id: string | ResourceId | null): OrganizationRel;
78
- type(): OrganizationType;
79
- }
80
- export default Organizations;
81
- export type { Organization, OrganizationCreate, OrganizationUpdate, OrganizationType };
82
- export type TransferOwnershipDataType = {
83
- new_owner_email: string;
84
- };
@@ -1,42 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- const resource_1 = require("../resource");
4
- class Organizations extends resource_1.ApiResource {
5
- async create(resource, params, options) {
6
- return this.resources.create({ ...resource, type: Organizations.TYPE }, params, options);
7
- }
8
- async update(resource, params, options) {
9
- return this.resources.update({ ...resource, type: Organizations.TYPE }, params, options);
10
- }
11
- async transfer_ownership(organizationId, payload, options) {
12
- const _organizationId = organizationId.id || organizationId;
13
- await this.resources.action('patch', `organizations/${_organizationId}/transfer_ownership`, { ...payload }, options);
14
- }
15
- async memberships(organizationId, params, options) {
16
- const _organizationId = organizationId.id || organizationId;
17
- return this.resources.fetch({ type: 'memberships' }, `organizations/${_organizationId}/memberships`, params, options);
18
- }
19
- async roles(organizationId, params, options) {
20
- const _organizationId = organizationId.id || organizationId;
21
- return this.resources.fetch({ type: 'roles' }, `organizations/${_organizationId}/roles`, params, options);
22
- }
23
- async permissions(organizationId, params, options) {
24
- const _organizationId = organizationId.id || organizationId;
25
- return this.resources.fetch({ type: 'permissions' }, `organizations/${_organizationId}/permissions`, params, options);
26
- }
27
- async api_credentials(organizationId, params, options) {
28
- const _organizationId = organizationId.id || organizationId;
29
- return this.resources.fetch({ type: 'api_credentials' }, `organizations/${_organizationId}/api_credentials`, params, options);
30
- }
31
- isOrganization(resource) {
32
- return resource.type && (resource.type === Organizations.TYPE);
33
- }
34
- relationship(id) {
35
- return ((id === null) || (typeof id === 'string')) ? { id, type: Organizations.TYPE } : { id: id.id, type: Organizations.TYPE };
36
- }
37
- type() {
38
- return Organizations.TYPE;
39
- }
40
- }
41
- Organizations.TYPE = 'organizations';
42
- exports.default = Organizations;