@commercelayer/provisioning-sdk 1.0.5 → 2.0.0-beta.10
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.
- package/lib/index.d.mts +1104 -0
- package/lib/index.d.ts +1104 -0
- package/lib/index.js +1 -0
- package/lib/index.mjs +1 -0
- package/package.json +19 -23
- package/lib/cjs/api.d.ts +0 -43
- package/lib/cjs/api.js +0 -45
- package/lib/cjs/client.d.ts +0 -42
- package/lib/cjs/client.js +0 -149
- package/lib/cjs/commercelayer.d.ts +0 -39
- package/lib/cjs/commercelayer.js +0 -130
- package/lib/cjs/common.d.ts +0 -5
- package/lib/cjs/common.js +0 -12
- package/lib/cjs/config.d.ts +0 -15
- package/lib/cjs/config.js +0 -19
- package/lib/cjs/debug.d.ts +0 -3
- package/lib/cjs/debug.js +0 -38
- package/lib/cjs/error.d.ts +0 -31
- package/lib/cjs/error.js +0 -77
- package/lib/cjs/index.d.ts +0 -7
- package/lib/cjs/index.js +0 -13
- package/lib/cjs/interceptor.d.ts +0 -25
- package/lib/cjs/interceptor.js +0 -2
- package/lib/cjs/jsonapi.d.ts +0 -6
- package/lib/cjs/jsonapi.js +0 -94
- package/lib/cjs/model.d.ts +0 -11
- package/lib/cjs/model.js +0 -3
- package/lib/cjs/query.d.ts +0 -17
- package/lib/cjs/query.js +0 -52
- package/lib/cjs/resource.d.ts +0 -86
- package/lib/cjs/resource.js +0 -194
- package/lib/cjs/resources/api_credentials.d.ts +0 -59
- package/lib/cjs/resources/api_credentials.js +0 -33
- package/lib/cjs/resources/application_memberships.d.ts +0 -57
- package/lib/cjs/resources/application_memberships.js +0 -41
- package/lib/cjs/resources/memberships.d.ts +0 -58
- package/lib/cjs/resources/memberships.js +0 -45
- package/lib/cjs/resources/organizations.d.ts +0 -84
- package/lib/cjs/resources/organizations.js +0 -42
- package/lib/cjs/resources/permissions.d.ts +0 -52
- package/lib/cjs/resources/permissions.js +0 -34
- package/lib/cjs/resources/roles.d.ts +0 -47
- package/lib/cjs/resources/roles.js +0 -42
- package/lib/cjs/resources/user.d.ts +0 -29
- package/lib/cjs/resources/user.js +0 -20
- package/lib/cjs/resources/versions.d.ts +0 -22
- package/lib/cjs/resources/versions.js +0 -16
- package/lib/cjs/static.d.ts +0 -12
- package/lib/cjs/static.js +0 -51
- package/lib/cjs/util.d.ts +0 -9
- package/lib/cjs/util.js +0 -16
- package/lib/esm/api.d.ts +0 -43
- package/lib/esm/api.js +0 -31
- package/lib/esm/client.d.ts +0 -42
- package/lib/esm/client.js +0 -144
- package/lib/esm/commercelayer.d.ts +0 -39
- package/lib/esm/commercelayer.js +0 -101
- package/lib/esm/common.d.ts +0 -5
- package/lib/esm/common.js +0 -8
- package/lib/esm/config.d.ts +0 -15
- package/lib/esm/config.js +0 -17
- package/lib/esm/debug.d.ts +0 -3
- package/lib/esm/debug.js +0 -36
- package/lib/esm/error.d.ts +0 -31
- package/lib/esm/error.js +0 -69
- package/lib/esm/index.d.ts +0 -7
- package/lib/esm/index.js +0 -4
- package/lib/esm/interceptor.d.ts +0 -25
- package/lib/esm/interceptor.js +0 -1
- package/lib/esm/jsonapi.d.ts +0 -6
- package/lib/esm/jsonapi.js +0 -87
- package/lib/esm/model.d.ts +0 -11
- package/lib/esm/model.js +0 -2
- package/lib/esm/query.d.ts +0 -17
- package/lib/esm/query.js +0 -45
- package/lib/esm/resource.d.ts +0 -86
- package/lib/esm/resource.js +0 -187
- package/lib/esm/resources/api_credentials.d.ts +0 -59
- package/lib/esm/resources/api_credentials.js +0 -31
- package/lib/esm/resources/application_memberships.d.ts +0 -57
- package/lib/esm/resources/application_memberships.js +0 -39
- package/lib/esm/resources/memberships.d.ts +0 -58
- package/lib/esm/resources/memberships.js +0 -43
- package/lib/esm/resources/organizations.d.ts +0 -84
- package/lib/esm/resources/organizations.js +0 -40
- package/lib/esm/resources/permissions.d.ts +0 -52
- package/lib/esm/resources/permissions.js +0 -32
- package/lib/esm/resources/roles.d.ts +0 -47
- package/lib/esm/resources/roles.js +0 -40
- package/lib/esm/resources/user.d.ts +0 -29
- package/lib/esm/resources/user.js +0 -18
- package/lib/esm/resources/versions.d.ts +0 -22
- package/lib/esm/resources/versions.js +0 -14
- package/lib/esm/static.d.ts +0 -12
- package/lib/esm/static.js +0 -25
- package/lib/esm/util.d.ts +0 -9
- package/lib/esm/util.js +0 -37
- package/lib/tsconfig.esm.tsbuildinfo +0 -1
- package/lib/tsconfig.tsbuildinfo +0 -1
package/lib/index.d.mts
ADDED
|
@@ -0,0 +1,1104 @@
|
|
|
1
|
+
type Fetch = (input: string | URL | Request, init?: RequestInit) => Promise<Response>;
|
|
2
|
+
type FetchResponse = any;
|
|
3
|
+
type FetchRequestOptions = RequestInit;
|
|
4
|
+
declare class FetchError extends Error {
|
|
5
|
+
#private;
|
|
6
|
+
static isFetchError: (error: any) => error is FetchError;
|
|
7
|
+
constructor(status: number, statusText: string, body?: any);
|
|
8
|
+
get errors(): any[] | undefined;
|
|
9
|
+
get status(): number;
|
|
10
|
+
get statusText(): string;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
type InterceptorEventManager<S extends (RequestInterceptor | ResponseInterceptor), F extends (ErrorInterceptor | ResponseInterceptor)> = {
|
|
14
|
+
onSuccess?: S;
|
|
15
|
+
onFailure?: F;
|
|
16
|
+
};
|
|
17
|
+
type RequestEventManager = InterceptorEventManager<RequestInterceptor, ErrorInterceptor>;
|
|
18
|
+
type ResponseEventManager = InterceptorEventManager<ResponseInterceptor, ErrorInterceptor>;
|
|
19
|
+
type ErrorEventManager = InterceptorEventManager<ResponseInterceptor, ResponseInterceptor>;
|
|
20
|
+
type InterceptorManager = {
|
|
21
|
+
request?: RequestEventManager;
|
|
22
|
+
response?: ResponseEventManager;
|
|
23
|
+
rawReader?: ErrorEventManager;
|
|
24
|
+
};
|
|
25
|
+
type RequestObj = {
|
|
26
|
+
url: URL;
|
|
27
|
+
options: FetchRequestOptions;
|
|
28
|
+
};
|
|
29
|
+
type RequestInterceptor = (request: RequestObj) => RequestObj | Promise<RequestObj>;
|
|
30
|
+
type ResponseObj = Response;
|
|
31
|
+
type ResponseInterceptor = (response: ResponseObj) => ResponseObj | Promise<ResponseObj>;
|
|
32
|
+
type ApiHeadersList = 'x-ratelimit-limit' | 'x-ratelimit-count' | 'x-ratelimit-period' | 'x-ratelimit-interval' | 'x-ratelimit-remaining';
|
|
33
|
+
type ApiHeaders = {
|
|
34
|
+
[key in ApiHeadersList]: string | number | boolean;
|
|
35
|
+
};
|
|
36
|
+
type HeadersObj = Record<string, string> | ApiHeaders;
|
|
37
|
+
type ErrorObj = FetchError;
|
|
38
|
+
type ErrorInterceptor = (error: ErrorObj) => ErrorObj | Promise<ErrorObj>;
|
|
39
|
+
type InterceptorType = 'request' | 'response';
|
|
40
|
+
|
|
41
|
+
type RawResponseReader = {
|
|
42
|
+
id: number;
|
|
43
|
+
rawResponse?: any;
|
|
44
|
+
headers?: HeadersObj;
|
|
45
|
+
ok: boolean;
|
|
46
|
+
};
|
|
47
|
+
|
|
48
|
+
type RequestParams = Record<string, string | number | boolean>;
|
|
49
|
+
type RequestHeaders = Record<string, string>;
|
|
50
|
+
type RequestConfig = {
|
|
51
|
+
timeout?: number;
|
|
52
|
+
params?: RequestParams;
|
|
53
|
+
headers?: RequestHeaders;
|
|
54
|
+
userAgent?: string;
|
|
55
|
+
fetch?: Fetch;
|
|
56
|
+
};
|
|
57
|
+
type ApiConfig = {
|
|
58
|
+
domain?: string;
|
|
59
|
+
accessToken: string;
|
|
60
|
+
};
|
|
61
|
+
type ApiClientInitConfig = ApiConfig & RequestConfig;
|
|
62
|
+
type ApiClientConfig = Partial<ApiClientInitConfig>;
|
|
63
|
+
type Method = 'GET' | 'DELETE' | 'POST' | 'PUT' | 'PATCH';
|
|
64
|
+
declare class ApiClient {
|
|
65
|
+
#private;
|
|
66
|
+
static create(options: ApiClientInitConfig): ApiClient;
|
|
67
|
+
private constructor();
|
|
68
|
+
get interceptors(): InterceptorManager;
|
|
69
|
+
get requestHeaders(): RequestHeaders;
|
|
70
|
+
config(config: ApiClientConfig): this;
|
|
71
|
+
userAgent(userAgent: string): this;
|
|
72
|
+
request(method: Method, path: string, body?: any, options?: ApiClientConfig): Promise<FetchResponse>;
|
|
73
|
+
private customHeaders;
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
type Nullable<T> = T | null;
|
|
77
|
+
type CreateArrayWithLengthX<LENGTH extends number, ACC extends unknown[] = []> = ACC['length'] extends LENGTH ? ACC : CreateArrayWithLengthX<LENGTH, [...ACC, 1]>;
|
|
78
|
+
type NumericNumberRange<START_ARR extends number[], END extends number, ACC extends number = never> = START_ARR['length'] extends END ? ACC | END : NumericNumberRange<[...START_ARR, 1], END, ACC | START_ARR['length']>;
|
|
79
|
+
type PositiveNumberRange<MAX extends number> = NumericNumberRange<CreateArrayWithLengthX<1>, MAX>;
|
|
80
|
+
type StringKey<T> = Extract<keyof T, string>;
|
|
81
|
+
|
|
82
|
+
type QueryResType<T extends Resource> = T['type'];
|
|
83
|
+
type QueryInclude = string[];
|
|
84
|
+
type QueryResourceFields<R extends ResourceTypeLock> = keyof ResourceFields[R];
|
|
85
|
+
type QueryArrayFields<R extends Resource> = Array<QueryResourceFields<QueryResType<R>>>;
|
|
86
|
+
type QueryRecordFields = {
|
|
87
|
+
[key in keyof ResourceFields]?: Array<(QueryResourceFields<key>)>;
|
|
88
|
+
};
|
|
89
|
+
interface QueryParamsRetrieve<R extends Resource = Resource> {
|
|
90
|
+
include?: QueryInclude;
|
|
91
|
+
fields?: QueryArrayFields<R> | QueryRecordFields;
|
|
92
|
+
}
|
|
93
|
+
type QuerySortType = 'asc' | 'desc';
|
|
94
|
+
type QueryResourceSortable<R extends Resource> = ResourceSortFields[QueryResType<R>];
|
|
95
|
+
type QueryResourceSortableFields<R extends Resource> = StringKey<QueryResourceSortable<R>>;
|
|
96
|
+
type QueryArraySortable<R extends Resource> = Array<QueryResourceSortableFields<R> | `-${QueryResourceSortableFields<R>}`>;
|
|
97
|
+
type QueryRecordSortable<R extends Resource> = Partial<Record<keyof QueryResourceSortable<R>, QuerySortType>>;
|
|
98
|
+
type QueryFilter = Record<string, string | number | boolean | object | Array<string | number>>;
|
|
99
|
+
type QueryPageNumber = number;
|
|
100
|
+
type QueryPageSize = PositiveNumberRange<25>;
|
|
101
|
+
interface QueryParamsList<R extends Resource = Resource> extends QueryParamsRetrieve<R> {
|
|
102
|
+
sort?: QueryArraySortable<R> | QueryRecordSortable<R>;
|
|
103
|
+
filters?: QueryFilter;
|
|
104
|
+
pageNumber?: QueryPageNumber;
|
|
105
|
+
pageSize?: QueryPageSize;
|
|
106
|
+
}
|
|
107
|
+
type QueryParams<R extends Resource = Resource> = QueryParamsRetrieve<R> | QueryParamsList<R>;
|
|
108
|
+
|
|
109
|
+
declare const isParamsList: <R extends Resource>(params: any) => params is QueryParamsList<R>;
|
|
110
|
+
type QueryStringParams = Record<string, string>;
|
|
111
|
+
declare const generateQueryStringParams: <R extends Resource>(params: QueryParams<R> | undefined, res: string | ResourceType) => QueryStringParams;
|
|
112
|
+
declare const generateSearchString: (params?: QueryStringParams, questionMark?: boolean) => string;
|
|
113
|
+
|
|
114
|
+
type ResourceNull = {
|
|
115
|
+
id: null;
|
|
116
|
+
} & ResourceType;
|
|
117
|
+
type ResourceRel = ResourceId | ResourceNull;
|
|
118
|
+
type Metadata = Record<string, any>;
|
|
119
|
+
interface ResourceType {
|
|
120
|
+
readonly type: ResourceTypeLock;
|
|
121
|
+
}
|
|
122
|
+
interface ResourceId extends ResourceType {
|
|
123
|
+
readonly id: string;
|
|
124
|
+
}
|
|
125
|
+
interface ResourceBase {
|
|
126
|
+
reference?: Nullable<string>;
|
|
127
|
+
reference_origin?: Nullable<string>;
|
|
128
|
+
metadata?: Metadata;
|
|
129
|
+
}
|
|
130
|
+
interface Resource extends ResourceBase, ResourceId {
|
|
131
|
+
readonly created_at: string;
|
|
132
|
+
readonly updated_at: string;
|
|
133
|
+
}
|
|
134
|
+
interface ResourceCreate extends ResourceBase {
|
|
135
|
+
}
|
|
136
|
+
interface ResourceUpdate extends ResourceBase {
|
|
137
|
+
readonly id: string;
|
|
138
|
+
}
|
|
139
|
+
type ListMeta = {
|
|
140
|
+
readonly pageCount: number;
|
|
141
|
+
readonly recordCount: number;
|
|
142
|
+
readonly currentPage: number;
|
|
143
|
+
readonly recordsPerPage: number;
|
|
144
|
+
};
|
|
145
|
+
declare class ListResponse<R> extends Array<R> {
|
|
146
|
+
readonly meta: ListMeta;
|
|
147
|
+
constructor(meta: ListMeta, data: R[]);
|
|
148
|
+
first(): R | undefined;
|
|
149
|
+
last(): R | undefined;
|
|
150
|
+
get(index: number): R | undefined;
|
|
151
|
+
hasNextPage(): boolean;
|
|
152
|
+
hasPrevPage(): boolean;
|
|
153
|
+
getRecordCount(): number;
|
|
154
|
+
getPageCount(): number;
|
|
155
|
+
get recordCount(): number;
|
|
156
|
+
get pageCount(): number;
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
type ResourceSort = Pick<Resource, 'id' | 'reference' | 'reference_origin' | 'created_at' | 'updated_at'>;
|
|
160
|
+
type ResourceFilter = Pick<Resource, 'id' | 'reference' | 'reference_origin' | 'metadata' | 'created_at' | 'updated_at'>;
|
|
161
|
+
type ResourceAdapterConfig = {};
|
|
162
|
+
type ResourcesInitConfig = ResourceAdapterConfig & ApiClientInitConfig;
|
|
163
|
+
type ResourcesConfig = Partial<ResourcesInitConfig>;
|
|
164
|
+
declare const apiResourceAdapter: (config: ResourcesInitConfig) => ResourceAdapter;
|
|
165
|
+
declare class ResourceAdapter {
|
|
166
|
+
#private;
|
|
167
|
+
constructor(config: ResourcesInitConfig);
|
|
168
|
+
private localConfig;
|
|
169
|
+
config(config: ResourcesConfig): this;
|
|
170
|
+
get client(): Readonly<ApiClient>;
|
|
171
|
+
retrieve<R extends Resource>(resource: ResourceId | ResourceType, params?: QueryParamsRetrieve, options?: ResourcesConfig): Promise<R>;
|
|
172
|
+
list<R extends Resource>(resource: ResourceType, params?: QueryParamsList, options?: ResourcesConfig): Promise<ListResponse<R>>;
|
|
173
|
+
create<C extends ResourceCreate, R extends Resource>(resource: C & ResourceType, params?: QueryParamsRetrieve<R>, options?: ResourcesConfig): Promise<R>;
|
|
174
|
+
update<U extends ResourceUpdate, R extends Resource>(resource: U & ResourceId, params?: QueryParamsRetrieve, options?: ResourcesConfig): Promise<R>;
|
|
175
|
+
delete(resource: ResourceId, options?: ResourcesConfig): Promise<void>;
|
|
176
|
+
fetch<R extends Resource>(resource: string | ResourceType, path: string, params?: QueryParams<R>, options?: ResourcesConfig): Promise<R | ListResponse<R>>;
|
|
177
|
+
action(cmd: Extract<Method, 'POST' | 'PATCH'>, path: string, payload?: any, options?: ResourcesConfig): Promise<void>;
|
|
178
|
+
}
|
|
179
|
+
declare abstract class ApiResourceBase<R extends Resource> {
|
|
180
|
+
static readonly TYPE: ResourceTypeLock;
|
|
181
|
+
protected readonly resources: ResourceAdapter;
|
|
182
|
+
constructor(adapter: ResourceAdapter);
|
|
183
|
+
abstract relationship(id: string | ResourceId | null): ResourceRel;
|
|
184
|
+
protected relationshipOneToOne<RR extends ResourceRel>(id: string | ResourceId | null): RR;
|
|
185
|
+
protected relationshipOneToMany<RR extends ResourceRel>(...ids: string[]): RR[];
|
|
186
|
+
abstract type(): ResourceTypeLock;
|
|
187
|
+
parse(resource: string): R | R[];
|
|
188
|
+
update(resource: ResourceUpdate, params?: QueryParamsRetrieve, options?: ResourcesConfig): Promise<R>;
|
|
189
|
+
}
|
|
190
|
+
declare abstract class ApiResource<R extends Resource> extends ApiResourceBase<R> {
|
|
191
|
+
retrieve(id: string | ResourceId, params?: QueryParamsRetrieve, options?: ResourcesConfig): Promise<R>;
|
|
192
|
+
list(params?: QueryParamsList, options?: ResourcesConfig): Promise<ListResponse<R>>;
|
|
193
|
+
count(filter?: QueryFilter | QueryParamsList, options?: ResourcesConfig): Promise<number>;
|
|
194
|
+
}
|
|
195
|
+
declare abstract class ApiSingleton<R extends Resource> extends ApiResourceBase<R> {
|
|
196
|
+
retrieve(params?: QueryParamsRetrieve, options?: ResourcesConfig): Promise<R>;
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
type VersionType = 'versions';
|
|
200
|
+
type VersionRel = ResourceRel & {
|
|
201
|
+
type: VersionType;
|
|
202
|
+
};
|
|
203
|
+
type VersionSort = Pick<Version, 'id'> & ResourceSort;
|
|
204
|
+
interface Version extends Resource {
|
|
205
|
+
readonly type: VersionType;
|
|
206
|
+
/**
|
|
207
|
+
* The type of the versioned resource..
|
|
208
|
+
* @example ```"roles"```
|
|
209
|
+
*/
|
|
210
|
+
resource_type: string;
|
|
211
|
+
/**
|
|
212
|
+
* The versioned resource ID..
|
|
213
|
+
* @example ```"PzdJhdLdYV"```
|
|
214
|
+
*/
|
|
215
|
+
resource_id: string;
|
|
216
|
+
/**
|
|
217
|
+
* The event which generates the version..
|
|
218
|
+
* @example ```"update"```
|
|
219
|
+
*/
|
|
220
|
+
event: string;
|
|
221
|
+
/**
|
|
222
|
+
* The object changes payload..
|
|
223
|
+
* @example ```"[object Object]"```
|
|
224
|
+
*/
|
|
225
|
+
changes: Record<string, any>;
|
|
226
|
+
/**
|
|
227
|
+
* Information about who triggered the change, only showed when it's from a JWT token..
|
|
228
|
+
* @example ```"[object Object]"```
|
|
229
|
+
*/
|
|
230
|
+
who: Record<string, any>;
|
|
231
|
+
}
|
|
232
|
+
declare class Versions extends ApiResource<Version> {
|
|
233
|
+
static readonly TYPE: VersionType;
|
|
234
|
+
isVersion(resource: any): resource is Version;
|
|
235
|
+
relationship(id: string | ResourceId | null): VersionRel;
|
|
236
|
+
relationshipToMany(...ids: string[]): VersionRel[];
|
|
237
|
+
type(): VersionType;
|
|
238
|
+
}
|
|
239
|
+
|
|
240
|
+
type PermissionType = 'permissions';
|
|
241
|
+
type PermissionRel = ResourceRel & {
|
|
242
|
+
type: PermissionType;
|
|
243
|
+
};
|
|
244
|
+
type RoleRel$4 = ResourceRel & {
|
|
245
|
+
type: RoleType;
|
|
246
|
+
};
|
|
247
|
+
type PermissionSort = Pick<Permission, 'id'> & ResourceSort;
|
|
248
|
+
interface Permission extends Resource {
|
|
249
|
+
readonly type: PermissionType;
|
|
250
|
+
/**
|
|
251
|
+
* Determines if the permission have access to create rights..
|
|
252
|
+
*/
|
|
253
|
+
can_create: boolean;
|
|
254
|
+
/**
|
|
255
|
+
* Determines if the permission have access to read rights..
|
|
256
|
+
*/
|
|
257
|
+
can_read: boolean;
|
|
258
|
+
/**
|
|
259
|
+
* Determines if the permission have access to update rights..
|
|
260
|
+
*/
|
|
261
|
+
can_update: boolean;
|
|
262
|
+
/**
|
|
263
|
+
* Determines if the permission have access to destroy rights..
|
|
264
|
+
*/
|
|
265
|
+
can_destroy: boolean;
|
|
266
|
+
/**
|
|
267
|
+
* The resource where this permission is applied..
|
|
268
|
+
*/
|
|
269
|
+
subject: string;
|
|
270
|
+
/**
|
|
271
|
+
* An object that contains additional restrictions..
|
|
272
|
+
* @example ```"[object Object]"```
|
|
273
|
+
*/
|
|
274
|
+
restrictions: Record<string, any>;
|
|
275
|
+
organization?: Nullable<Organization>;
|
|
276
|
+
role?: Nullable<Role>;
|
|
277
|
+
versions?: Nullable<Version[]>;
|
|
278
|
+
}
|
|
279
|
+
interface PermissionCreate extends ResourceCreate {
|
|
280
|
+
/**
|
|
281
|
+
* Determines if the permission have access to create rights..
|
|
282
|
+
*/
|
|
283
|
+
can_create: boolean;
|
|
284
|
+
/**
|
|
285
|
+
* Determines if the permission have access to read rights..
|
|
286
|
+
*/
|
|
287
|
+
can_read: boolean;
|
|
288
|
+
/**
|
|
289
|
+
* Determines if the permission have access to update rights..
|
|
290
|
+
*/
|
|
291
|
+
can_update: boolean;
|
|
292
|
+
/**
|
|
293
|
+
* Determines if the permission have access to destroy rights..
|
|
294
|
+
*/
|
|
295
|
+
can_destroy: boolean;
|
|
296
|
+
/**
|
|
297
|
+
* The resource where this permission is applied..
|
|
298
|
+
*/
|
|
299
|
+
subject: string;
|
|
300
|
+
role: RoleRel$4;
|
|
301
|
+
}
|
|
302
|
+
interface PermissionUpdate extends ResourceUpdate {
|
|
303
|
+
/**
|
|
304
|
+
* Determines if the permission have access to create rights..
|
|
305
|
+
*/
|
|
306
|
+
can_create?: Nullable<boolean>;
|
|
307
|
+
/**
|
|
308
|
+
* Determines if the permission have access to read rights..
|
|
309
|
+
*/
|
|
310
|
+
can_read?: Nullable<boolean>;
|
|
311
|
+
/**
|
|
312
|
+
* Determines if the permission have access to update rights..
|
|
313
|
+
*/
|
|
314
|
+
can_update?: Nullable<boolean>;
|
|
315
|
+
/**
|
|
316
|
+
* Determines if the permission have access to destroy rights..
|
|
317
|
+
*/
|
|
318
|
+
can_destroy?: Nullable<boolean>;
|
|
319
|
+
}
|
|
320
|
+
declare class Permissions extends ApiResource<Permission> {
|
|
321
|
+
static readonly TYPE: PermissionType;
|
|
322
|
+
create(resource: PermissionCreate, params?: QueryParamsRetrieve, options?: ResourcesConfig): Promise<Permission>;
|
|
323
|
+
update(resource: PermissionUpdate, params?: QueryParamsRetrieve, options?: ResourcesConfig): Promise<Permission>;
|
|
324
|
+
organization(permissionId: string | Permission, params?: QueryParamsRetrieve<Organization>, options?: ResourcesConfig): Promise<Organization>;
|
|
325
|
+
role(permissionId: string | Permission, params?: QueryParamsRetrieve<Role>, options?: ResourcesConfig): Promise<Role>;
|
|
326
|
+
versions(permissionId: string | Permission, params?: QueryParamsList<Version>, options?: ResourcesConfig): Promise<ListResponse<Version>>;
|
|
327
|
+
isPermission(resource: any): resource is Permission;
|
|
328
|
+
relationship(id: string | ResourceId | null): PermissionRel;
|
|
329
|
+
relationshipToMany(...ids: string[]): PermissionRel[];
|
|
330
|
+
type(): PermissionType;
|
|
331
|
+
}
|
|
332
|
+
|
|
333
|
+
type RoleType = 'roles';
|
|
334
|
+
type RoleRel$3 = ResourceRel & {
|
|
335
|
+
type: RoleType;
|
|
336
|
+
};
|
|
337
|
+
type OrganizationRel$4 = ResourceRel & {
|
|
338
|
+
type: OrganizationType;
|
|
339
|
+
};
|
|
340
|
+
type RoleSort = Pick<Role, 'id'> & ResourceSort;
|
|
341
|
+
interface Role extends Resource {
|
|
342
|
+
readonly type: RoleType;
|
|
343
|
+
/**
|
|
344
|
+
* The role name..
|
|
345
|
+
* @example ```"Custom role"```
|
|
346
|
+
*/
|
|
347
|
+
name: string;
|
|
348
|
+
/**
|
|
349
|
+
* The kind of role, one of: `custom`, `admin`, `read_only`.
|
|
350
|
+
* @example ```"custom"```
|
|
351
|
+
*/
|
|
352
|
+
kind: string;
|
|
353
|
+
organization?: Nullable<Organization>;
|
|
354
|
+
permissions?: Nullable<Permission[]>;
|
|
355
|
+
memberships?: Nullable<Membership[]>;
|
|
356
|
+
api_credentials?: Nullable<ApiCredential[]>;
|
|
357
|
+
versions?: Nullable<Version[]>;
|
|
358
|
+
}
|
|
359
|
+
interface RoleCreate extends ResourceCreate {
|
|
360
|
+
/**
|
|
361
|
+
* The role name..
|
|
362
|
+
* @example ```"Custom role"```
|
|
363
|
+
*/
|
|
364
|
+
name: string;
|
|
365
|
+
organization: OrganizationRel$4;
|
|
366
|
+
}
|
|
367
|
+
interface RoleUpdate extends ResourceUpdate {
|
|
368
|
+
/**
|
|
369
|
+
* The role name..
|
|
370
|
+
* @example ```"Custom role"```
|
|
371
|
+
*/
|
|
372
|
+
name?: Nullable<string>;
|
|
373
|
+
}
|
|
374
|
+
declare class Roles extends ApiResource<Role> {
|
|
375
|
+
static readonly TYPE: RoleType;
|
|
376
|
+
create(resource: RoleCreate, params?: QueryParamsRetrieve, options?: ResourcesConfig): Promise<Role>;
|
|
377
|
+
update(resource: RoleUpdate, params?: QueryParamsRetrieve, options?: ResourcesConfig): Promise<Role>;
|
|
378
|
+
organization(roleId: string | Role, params?: QueryParamsRetrieve<Organization>, options?: ResourcesConfig): Promise<Organization>;
|
|
379
|
+
permissions(roleId: string | Role, params?: QueryParamsList<Permission>, options?: ResourcesConfig): Promise<ListResponse<Permission>>;
|
|
380
|
+
memberships(roleId: string | Role, params?: QueryParamsList<Membership>, options?: ResourcesConfig): Promise<ListResponse<Membership>>;
|
|
381
|
+
api_credentials(roleId: string | Role, params?: QueryParamsList<ApiCredential>, options?: ResourcesConfig): Promise<ListResponse<ApiCredential>>;
|
|
382
|
+
versions(roleId: string | Role, params?: QueryParamsList<Version>, options?: ResourcesConfig): Promise<ListResponse<Version>>;
|
|
383
|
+
isRole(resource: any): resource is Role;
|
|
384
|
+
relationship(id: string | ResourceId | null): RoleRel$3;
|
|
385
|
+
relationshipToMany(...ids: string[]): RoleRel$3[];
|
|
386
|
+
type(): RoleType;
|
|
387
|
+
}
|
|
388
|
+
|
|
389
|
+
type ApplicationMembershipType = 'application_memberships';
|
|
390
|
+
type ApplicationMembershipRel$1 = ResourceRel & {
|
|
391
|
+
type: ApplicationMembershipType;
|
|
392
|
+
};
|
|
393
|
+
type ApiCredentialRel$1 = ResourceRel & {
|
|
394
|
+
type: ApiCredentialType;
|
|
395
|
+
};
|
|
396
|
+
type MembershipRel$1 = ResourceRel & {
|
|
397
|
+
type: MembershipType;
|
|
398
|
+
};
|
|
399
|
+
type OrganizationRel$3 = ResourceRel & {
|
|
400
|
+
type: OrganizationType;
|
|
401
|
+
};
|
|
402
|
+
type RoleRel$2 = ResourceRel & {
|
|
403
|
+
type: RoleType;
|
|
404
|
+
};
|
|
405
|
+
type ApplicationMembershipSort = Pick<ApplicationMembership, 'id'> & ResourceSort;
|
|
406
|
+
interface ApplicationMembership extends Resource {
|
|
407
|
+
readonly type: ApplicationMembershipType;
|
|
408
|
+
/**
|
|
409
|
+
* Set of key-value pairs that contains restrictions and scopes of the application membership..
|
|
410
|
+
* @example ```"[object Object]"```
|
|
411
|
+
*/
|
|
412
|
+
filters?: Nullable<Record<string, any>>;
|
|
413
|
+
api_credential?: Nullable<ApiCredential>;
|
|
414
|
+
membership?: Nullable<Membership>;
|
|
415
|
+
organization?: Nullable<Organization>;
|
|
416
|
+
role?: Nullable<Role>;
|
|
417
|
+
}
|
|
418
|
+
interface ApplicationMembershipCreate extends ResourceCreate {
|
|
419
|
+
/**
|
|
420
|
+
* Set of key-value pairs that contains restrictions and scopes of the application membership..
|
|
421
|
+
* @example ```"[object Object]"```
|
|
422
|
+
*/
|
|
423
|
+
filters?: Nullable<Record<string, any>>;
|
|
424
|
+
api_credential: ApiCredentialRel$1;
|
|
425
|
+
membership: MembershipRel$1;
|
|
426
|
+
organization: OrganizationRel$3;
|
|
427
|
+
role: RoleRel$2;
|
|
428
|
+
}
|
|
429
|
+
interface ApplicationMembershipUpdate extends ResourceUpdate {
|
|
430
|
+
/**
|
|
431
|
+
* Set of key-value pairs that contains restrictions and scopes of the application membership..
|
|
432
|
+
* @example ```"[object Object]"```
|
|
433
|
+
*/
|
|
434
|
+
filters?: Nullable<Record<string, any>>;
|
|
435
|
+
role?: Nullable<RoleRel$2>;
|
|
436
|
+
}
|
|
437
|
+
declare class ApplicationMemberships extends ApiResource<ApplicationMembership> {
|
|
438
|
+
static readonly TYPE: ApplicationMembershipType;
|
|
439
|
+
create(resource: ApplicationMembershipCreate, params?: QueryParamsRetrieve, options?: ResourcesConfig): Promise<ApplicationMembership>;
|
|
440
|
+
update(resource: ApplicationMembershipUpdate, params?: QueryParamsRetrieve, options?: ResourcesConfig): Promise<ApplicationMembership>;
|
|
441
|
+
delete(id: string | ResourceId, options?: ResourcesConfig): Promise<void>;
|
|
442
|
+
api_credential(applicationMembershipId: string | ApplicationMembership, params?: QueryParamsRetrieve<ApiCredential>, options?: ResourcesConfig): Promise<ApiCredential>;
|
|
443
|
+
membership(applicationMembershipId: string | ApplicationMembership, params?: QueryParamsRetrieve<Membership>, options?: ResourcesConfig): Promise<Membership>;
|
|
444
|
+
organization(applicationMembershipId: string | ApplicationMembership, params?: QueryParamsRetrieve<Organization>, options?: ResourcesConfig): Promise<Organization>;
|
|
445
|
+
role(applicationMembershipId: string | ApplicationMembership, params?: QueryParamsRetrieve<Role>, options?: ResourcesConfig): Promise<Role>;
|
|
446
|
+
isApplicationMembership(resource: any): resource is ApplicationMembership;
|
|
447
|
+
relationship(id: string | ResourceId | null): ApplicationMembershipRel$1;
|
|
448
|
+
relationshipToMany(...ids: string[]): ApplicationMembershipRel$1[];
|
|
449
|
+
type(): ApplicationMembershipType;
|
|
450
|
+
}
|
|
451
|
+
|
|
452
|
+
type MembershipType = 'memberships';
|
|
453
|
+
type MembershipRel = ResourceRel & {
|
|
454
|
+
type: MembershipType;
|
|
455
|
+
};
|
|
456
|
+
type OrganizationRel$2 = ResourceRel & {
|
|
457
|
+
type: OrganizationType;
|
|
458
|
+
};
|
|
459
|
+
type RoleRel$1 = ResourceRel & {
|
|
460
|
+
type: RoleType;
|
|
461
|
+
};
|
|
462
|
+
type ApplicationMembershipRel = ResourceRel & {
|
|
463
|
+
type: ApplicationMembershipType;
|
|
464
|
+
};
|
|
465
|
+
type MembershipSort = Pick<Membership, 'id' | 'status'> & ResourceSort;
|
|
466
|
+
interface Membership extends Resource {
|
|
467
|
+
readonly type: MembershipType;
|
|
468
|
+
/**
|
|
469
|
+
* The user email..
|
|
470
|
+
* @example ```"commercelayer@commercelayer.io"```
|
|
471
|
+
*/
|
|
472
|
+
user_email: string;
|
|
473
|
+
/**
|
|
474
|
+
* The user first name..
|
|
475
|
+
* @example ```"John"```
|
|
476
|
+
*/
|
|
477
|
+
user_first_name: string;
|
|
478
|
+
/**
|
|
479
|
+
* The user last name..
|
|
480
|
+
* @example ```"Doe"```
|
|
481
|
+
*/
|
|
482
|
+
user_last_name: string;
|
|
483
|
+
/**
|
|
484
|
+
* The memberships status. One of `pending` (default), `active`..
|
|
485
|
+
* @example ```"pending"```
|
|
486
|
+
*/
|
|
487
|
+
status: 'pending' | 'active';
|
|
488
|
+
/**
|
|
489
|
+
* Indicates if the user it's the owner of the organization..
|
|
490
|
+
* @example ```"true"```
|
|
491
|
+
*/
|
|
492
|
+
owner: boolean;
|
|
493
|
+
organization?: Nullable<Organization>;
|
|
494
|
+
role?: Nullable<Role>;
|
|
495
|
+
application_memberships?: Nullable<ApplicationMembership[]>;
|
|
496
|
+
versions?: Nullable<Version[]>;
|
|
497
|
+
}
|
|
498
|
+
interface MembershipCreate extends ResourceCreate {
|
|
499
|
+
/**
|
|
500
|
+
* The user email..
|
|
501
|
+
* @example ```"commercelayer@commercelayer.io"```
|
|
502
|
+
*/
|
|
503
|
+
user_email: string;
|
|
504
|
+
organization: OrganizationRel$2;
|
|
505
|
+
role: RoleRel$1;
|
|
506
|
+
application_memberships?: Nullable<ApplicationMembershipRel[]>;
|
|
507
|
+
}
|
|
508
|
+
interface MembershipUpdate extends ResourceUpdate {
|
|
509
|
+
role?: Nullable<RoleRel$1>;
|
|
510
|
+
application_memberships?: Nullable<ApplicationMembershipRel[]>;
|
|
511
|
+
}
|
|
512
|
+
declare class Memberships extends ApiResource<Membership> {
|
|
513
|
+
static readonly TYPE: MembershipType;
|
|
514
|
+
create(resource: MembershipCreate, params?: QueryParamsRetrieve, options?: ResourcesConfig): Promise<Membership>;
|
|
515
|
+
update(resource: MembershipUpdate, params?: QueryParamsRetrieve, options?: ResourcesConfig): Promise<Membership>;
|
|
516
|
+
delete(id: string | ResourceId, options?: ResourcesConfig): Promise<void>;
|
|
517
|
+
resend(membershipId: string | Membership, options?: ResourcesConfig): Promise<void>;
|
|
518
|
+
organization(membershipId: string | Membership, params?: QueryParamsRetrieve<Organization>, options?: ResourcesConfig): Promise<Organization>;
|
|
519
|
+
role(membershipId: string | Membership, params?: QueryParamsRetrieve<Role>, options?: ResourcesConfig): Promise<Role>;
|
|
520
|
+
application_memberships(membershipId: string | Membership, params?: QueryParamsList<ApplicationMembership>, options?: ResourcesConfig): Promise<ListResponse<ApplicationMembership>>;
|
|
521
|
+
versions(membershipId: string | Membership, params?: QueryParamsList<Version>, options?: ResourcesConfig): Promise<ListResponse<Version>>;
|
|
522
|
+
isMembership(resource: any): resource is Membership;
|
|
523
|
+
relationship(id: string | ResourceId | null): MembershipRel;
|
|
524
|
+
relationshipToMany(...ids: string[]): MembershipRel[];
|
|
525
|
+
type(): MembershipType;
|
|
526
|
+
}
|
|
527
|
+
|
|
528
|
+
type OrganizationType = 'organizations';
|
|
529
|
+
type OrganizationRel$1 = ResourceRel & {
|
|
530
|
+
type: OrganizationType;
|
|
531
|
+
};
|
|
532
|
+
type OrganizationSort = Pick<Organization, 'id'> & ResourceSort;
|
|
533
|
+
interface Organization extends Resource {
|
|
534
|
+
readonly type: OrganizationType;
|
|
535
|
+
/**
|
|
536
|
+
* The organization's internal name..
|
|
537
|
+
* @example ```"The Blue Brand"```
|
|
538
|
+
*/
|
|
539
|
+
name: string;
|
|
540
|
+
/**
|
|
541
|
+
* The organization's slug name..
|
|
542
|
+
* @example ```"the-blue-brand"```
|
|
543
|
+
*/
|
|
544
|
+
slug: string;
|
|
545
|
+
/**
|
|
546
|
+
* The organization's domain..
|
|
547
|
+
* @example ```"the-blue-brand.commercelayer.io"```
|
|
548
|
+
*/
|
|
549
|
+
domain: string;
|
|
550
|
+
/**
|
|
551
|
+
* The organization's configuration..
|
|
552
|
+
* @example ```"[object Object]"```
|
|
553
|
+
*/
|
|
554
|
+
config?: Nullable<Record<string, any>>;
|
|
555
|
+
/**
|
|
556
|
+
* The organization's support phone..
|
|
557
|
+
* @example ```"+01 30800857"```
|
|
558
|
+
*/
|
|
559
|
+
support_phone?: Nullable<string>;
|
|
560
|
+
/**
|
|
561
|
+
* The organization's support email..
|
|
562
|
+
* @example ```"support@bluebrand.com"```
|
|
563
|
+
*/
|
|
564
|
+
support_email?: Nullable<string>;
|
|
565
|
+
/**
|
|
566
|
+
* The URL to the organization's logo..
|
|
567
|
+
* @example ```"https://bluebrand.com/img/logo.svg"```
|
|
568
|
+
*/
|
|
569
|
+
logo_url?: Nullable<string>;
|
|
570
|
+
/**
|
|
571
|
+
* The URL to the organization's favicon..
|
|
572
|
+
* @example ```"https://bluebrand.com/img/favicon.ico"```
|
|
573
|
+
*/
|
|
574
|
+
favicon_url?: Nullable<string>;
|
|
575
|
+
/**
|
|
576
|
+
* The organization's primary color. Format is HEX (starts with `#` and it's followed by six letters and/or numbers)..
|
|
577
|
+
* @example ```"#C8984E"```
|
|
578
|
+
*/
|
|
579
|
+
primary_color?: Nullable<string>;
|
|
580
|
+
/**
|
|
581
|
+
* The organization's contrast color. Format is HEX (starts with `#` and it's followed by six letters and/or numbers)..
|
|
582
|
+
* @example ```"#FFFFCC"```
|
|
583
|
+
*/
|
|
584
|
+
contrast_color?: Nullable<string>;
|
|
585
|
+
/**
|
|
586
|
+
* The organization's Google Tag Manager ID..
|
|
587
|
+
* @example ```"GTM-5FJXX6"```
|
|
588
|
+
*/
|
|
589
|
+
gtm_id?: Nullable<string>;
|
|
590
|
+
/**
|
|
591
|
+
* The organization's Google Tag Manager ID for test..
|
|
592
|
+
* @example ```"GTM-5FJXX7"```
|
|
593
|
+
*/
|
|
594
|
+
gtm_id_test?: Nullable<string>;
|
|
595
|
+
/**
|
|
596
|
+
* Indicates if organization has discount disabled..
|
|
597
|
+
*/
|
|
598
|
+
discount_disabled?: Nullable<boolean>;
|
|
599
|
+
/**
|
|
600
|
+
* Indicates if organization has account disabled..
|
|
601
|
+
*/
|
|
602
|
+
account_disabled?: Nullable<boolean>;
|
|
603
|
+
/**
|
|
604
|
+
* Indicates if organization has acceptance disabled..
|
|
605
|
+
*/
|
|
606
|
+
acceptance_disabled?: Nullable<boolean>;
|
|
607
|
+
/**
|
|
608
|
+
* The maximum number of active concurrent promotions allowed for your organization..
|
|
609
|
+
* @example ```"10"```
|
|
610
|
+
*/
|
|
611
|
+
max_concurrent_promotions: number;
|
|
612
|
+
/**
|
|
613
|
+
* The maximum number of concurrent imports allowed for your organization..
|
|
614
|
+
* @example ```"30"```
|
|
615
|
+
*/
|
|
616
|
+
max_concurrent_imports: number;
|
|
617
|
+
/**
|
|
618
|
+
* The region where the organization it's located, default value it's `eu-west-1`..
|
|
619
|
+
* @example ```"eu-west-1"```
|
|
620
|
+
*/
|
|
621
|
+
region?: Nullable<string>;
|
|
622
|
+
/**
|
|
623
|
+
* Indicates if the organization can switch to live mode..
|
|
624
|
+
*/
|
|
625
|
+
can_switch_live: boolean;
|
|
626
|
+
/**
|
|
627
|
+
* Information about the current subscription such as the plan type, limits and subscription totals counter..
|
|
628
|
+
* @example ```"[object Object]"```
|
|
629
|
+
*/
|
|
630
|
+
subscription_info: Record<string, any>;
|
|
631
|
+
memberships?: Nullable<Membership[]>;
|
|
632
|
+
roles?: Nullable<Role[]>;
|
|
633
|
+
permissions?: Nullable<Permission[]>;
|
|
634
|
+
api_credentials?: Nullable<ApiCredential[]>;
|
|
635
|
+
}
|
|
636
|
+
interface OrganizationCreate extends ResourceCreate {
|
|
637
|
+
/**
|
|
638
|
+
* The organization's internal name..
|
|
639
|
+
* @example ```"The Blue Brand"```
|
|
640
|
+
*/
|
|
641
|
+
name: string;
|
|
642
|
+
/**
|
|
643
|
+
* The organization's configuration..
|
|
644
|
+
* @example ```"[object Object]"```
|
|
645
|
+
*/
|
|
646
|
+
config?: Nullable<Record<string, any>>;
|
|
647
|
+
/**
|
|
648
|
+
* The organization's support phone..
|
|
649
|
+
* @example ```"+01 30800857"```
|
|
650
|
+
*/
|
|
651
|
+
support_phone?: Nullable<string>;
|
|
652
|
+
/**
|
|
653
|
+
* The organization's support email..
|
|
654
|
+
* @example ```"support@bluebrand.com"```
|
|
655
|
+
*/
|
|
656
|
+
support_email?: Nullable<string>;
|
|
657
|
+
/**
|
|
658
|
+
* The URL to the organization's logo..
|
|
659
|
+
* @example ```"https://bluebrand.com/img/logo.svg"```
|
|
660
|
+
*/
|
|
661
|
+
logo_url?: Nullable<string>;
|
|
662
|
+
/**
|
|
663
|
+
* The URL to the organization's favicon..
|
|
664
|
+
* @example ```"https://bluebrand.com/img/favicon.ico"```
|
|
665
|
+
*/
|
|
666
|
+
favicon_url?: Nullable<string>;
|
|
667
|
+
/**
|
|
668
|
+
* The organization's primary color. Format is HEX (starts with `#` and it's followed by six letters and/or numbers)..
|
|
669
|
+
* @example ```"#C8984E"```
|
|
670
|
+
*/
|
|
671
|
+
primary_color?: Nullable<string>;
|
|
672
|
+
/**
|
|
673
|
+
* The organization's contrast color. Format is HEX (starts with `#` and it's followed by six letters and/or numbers)..
|
|
674
|
+
* @example ```"#FFFFCC"```
|
|
675
|
+
*/
|
|
676
|
+
contrast_color?: Nullable<string>;
|
|
677
|
+
/**
|
|
678
|
+
* The organization's Google Tag Manager ID..
|
|
679
|
+
* @example ```"GTM-5FJXX6"```
|
|
680
|
+
*/
|
|
681
|
+
gtm_id?: Nullable<string>;
|
|
682
|
+
/**
|
|
683
|
+
* The organization's Google Tag Manager ID for test..
|
|
684
|
+
* @example ```"GTM-5FJXX7"```
|
|
685
|
+
*/
|
|
686
|
+
gtm_id_test?: Nullable<string>;
|
|
687
|
+
/**
|
|
688
|
+
* Indicates if organization has discount disabled..
|
|
689
|
+
*/
|
|
690
|
+
discount_disabled?: Nullable<boolean>;
|
|
691
|
+
/**
|
|
692
|
+
* Indicates if organization has account disabled..
|
|
693
|
+
*/
|
|
694
|
+
account_disabled?: Nullable<boolean>;
|
|
695
|
+
/**
|
|
696
|
+
* Indicates if organization has acceptance disabled..
|
|
697
|
+
*/
|
|
698
|
+
acceptance_disabled?: Nullable<boolean>;
|
|
699
|
+
/**
|
|
700
|
+
* The region where the organization it's located, default value it's `eu-west-1`..
|
|
701
|
+
* @example ```"eu-west-1"```
|
|
702
|
+
*/
|
|
703
|
+
region?: Nullable<string>;
|
|
704
|
+
}
|
|
705
|
+
interface OrganizationUpdate extends ResourceUpdate {
|
|
706
|
+
/**
|
|
707
|
+
* The organization's internal name..
|
|
708
|
+
* @example ```"The Blue Brand"```
|
|
709
|
+
*/
|
|
710
|
+
name?: Nullable<string>;
|
|
711
|
+
/**
|
|
712
|
+
* The organization's configuration..
|
|
713
|
+
* @example ```"[object Object]"```
|
|
714
|
+
*/
|
|
715
|
+
config?: Nullable<Record<string, any>>;
|
|
716
|
+
/**
|
|
717
|
+
* The organization's support phone..
|
|
718
|
+
* @example ```"+01 30800857"```
|
|
719
|
+
*/
|
|
720
|
+
support_phone?: Nullable<string>;
|
|
721
|
+
/**
|
|
722
|
+
* The organization's support email..
|
|
723
|
+
* @example ```"support@bluebrand.com"```
|
|
724
|
+
*/
|
|
725
|
+
support_email?: Nullable<string>;
|
|
726
|
+
/**
|
|
727
|
+
* The URL to the organization's logo..
|
|
728
|
+
* @example ```"https://bluebrand.com/img/logo.svg"```
|
|
729
|
+
*/
|
|
730
|
+
logo_url?: Nullable<string>;
|
|
731
|
+
/**
|
|
732
|
+
* The URL to the organization's favicon..
|
|
733
|
+
* @example ```"https://bluebrand.com/img/favicon.ico"```
|
|
734
|
+
*/
|
|
735
|
+
favicon_url?: Nullable<string>;
|
|
736
|
+
/**
|
|
737
|
+
* The organization's primary color. Format is HEX (starts with `#` and it's followed by six letters and/or numbers)..
|
|
738
|
+
* @example ```"#C8984E"```
|
|
739
|
+
*/
|
|
740
|
+
primary_color?: Nullable<string>;
|
|
741
|
+
/**
|
|
742
|
+
* The organization's contrast color. Format is HEX (starts with `#` and it's followed by six letters and/or numbers)..
|
|
743
|
+
* @example ```"#FFFFCC"```
|
|
744
|
+
*/
|
|
745
|
+
contrast_color?: Nullable<string>;
|
|
746
|
+
/**
|
|
747
|
+
* The organization's Google Tag Manager ID..
|
|
748
|
+
* @example ```"GTM-5FJXX6"```
|
|
749
|
+
*/
|
|
750
|
+
gtm_id?: Nullable<string>;
|
|
751
|
+
/**
|
|
752
|
+
* The organization's Google Tag Manager ID for test..
|
|
753
|
+
* @example ```"GTM-5FJXX7"```
|
|
754
|
+
*/
|
|
755
|
+
gtm_id_test?: Nullable<string>;
|
|
756
|
+
/**
|
|
757
|
+
* Indicates if organization has discount disabled..
|
|
758
|
+
*/
|
|
759
|
+
discount_disabled?: Nullable<boolean>;
|
|
760
|
+
/**
|
|
761
|
+
* Indicates if organization has account disabled..
|
|
762
|
+
*/
|
|
763
|
+
account_disabled?: Nullable<boolean>;
|
|
764
|
+
/**
|
|
765
|
+
* Indicates if organization has acceptance disabled..
|
|
766
|
+
*/
|
|
767
|
+
acceptance_disabled?: Nullable<boolean>;
|
|
768
|
+
}
|
|
769
|
+
declare class Organizations extends ApiResource<Organization> {
|
|
770
|
+
static readonly TYPE: OrganizationType;
|
|
771
|
+
create(resource: OrganizationCreate, params?: QueryParamsRetrieve, options?: ResourcesConfig): Promise<Organization>;
|
|
772
|
+
update(resource: OrganizationUpdate, params?: QueryParamsRetrieve, options?: ResourcesConfig): Promise<Organization>;
|
|
773
|
+
transfer_ownership(organizationId: string | Organization, payload: TransferOwnershipDataType, options?: ResourcesConfig): Promise<void>;
|
|
774
|
+
memberships(organizationId: string | Organization, params?: QueryParamsList<Membership>, options?: ResourcesConfig): Promise<ListResponse<Membership>>;
|
|
775
|
+
roles(organizationId: string | Organization, params?: QueryParamsList<Role>, options?: ResourcesConfig): Promise<ListResponse<Role>>;
|
|
776
|
+
permissions(organizationId: string | Organization, params?: QueryParamsList<Permission>, options?: ResourcesConfig): Promise<ListResponse<Permission>>;
|
|
777
|
+
api_credentials(organizationId: string | Organization, params?: QueryParamsList<ApiCredential>, options?: ResourcesConfig): Promise<ListResponse<ApiCredential>>;
|
|
778
|
+
isOrganization(resource: any): resource is Organization;
|
|
779
|
+
relationship(id: string | ResourceId | null): OrganizationRel$1;
|
|
780
|
+
relationshipToMany(...ids: string[]): OrganizationRel$1[];
|
|
781
|
+
type(): OrganizationType;
|
|
782
|
+
}
|
|
783
|
+
|
|
784
|
+
type TransferOwnershipDataType = {
|
|
785
|
+
type: 'organizations';
|
|
786
|
+
id: string;
|
|
787
|
+
new_owner_email: string;
|
|
788
|
+
};
|
|
789
|
+
|
|
790
|
+
type ApiCredentialType = 'api_credentials';
|
|
791
|
+
type ApiCredentialRel = ResourceRel & {
|
|
792
|
+
type: ApiCredentialType;
|
|
793
|
+
};
|
|
794
|
+
type OrganizationRel = ResourceRel & {
|
|
795
|
+
type: OrganizationType;
|
|
796
|
+
};
|
|
797
|
+
type RoleRel = ResourceRel & {
|
|
798
|
+
type: RoleType;
|
|
799
|
+
};
|
|
800
|
+
type ApiCredentialSort = Pick<ApiCredential, 'id' | 'mode'> & ResourceSort;
|
|
801
|
+
interface ApiCredential extends Resource {
|
|
802
|
+
readonly type: ApiCredentialType;
|
|
803
|
+
/**
|
|
804
|
+
* The API credential internal name..
|
|
805
|
+
* @example ```"My app"```
|
|
806
|
+
*/
|
|
807
|
+
name: string;
|
|
808
|
+
/**
|
|
809
|
+
* The API credential kind, can be one of: `webapp`, `sales_channel`, `integration` or the kind of app you want to fork (e.g. `orders`, `imports`, etc.)..
|
|
810
|
+
* @example ```"sales_channel"```
|
|
811
|
+
*/
|
|
812
|
+
kind: string;
|
|
813
|
+
/**
|
|
814
|
+
* Indicates if the API credential it's confidential..
|
|
815
|
+
* @example ```"true"```
|
|
816
|
+
*/
|
|
817
|
+
confidential: boolean;
|
|
818
|
+
/**
|
|
819
|
+
* The API credential redirect URI..
|
|
820
|
+
* @example ```"https://bluebrand.com/img/logo.svg"```
|
|
821
|
+
*/
|
|
822
|
+
redirect_uri?: Nullable<string>;
|
|
823
|
+
/**
|
|
824
|
+
* The API credential unique ID..
|
|
825
|
+
* @example ```"xxxx-yyyy-zzzz"```
|
|
826
|
+
*/
|
|
827
|
+
client_id: string;
|
|
828
|
+
/**
|
|
829
|
+
* The API credential unique secret..
|
|
830
|
+
* @example ```"xxxx-yyyy-zzzz"```
|
|
831
|
+
*/
|
|
832
|
+
client_secret: string;
|
|
833
|
+
/**
|
|
834
|
+
* The API credential scopes..
|
|
835
|
+
* @example ```"market:all market:9 market:122 market:6 stock_location:6 stock_location:33"```
|
|
836
|
+
*/
|
|
837
|
+
scopes: string;
|
|
838
|
+
/**
|
|
839
|
+
* The lifetime of the access token in seconds (min. `7200`, max. `31536000`. Default is `14400` for Sales channels and `7200` for other client types)..
|
|
840
|
+
* @example ```"7200"```
|
|
841
|
+
*/
|
|
842
|
+
expires_in?: Nullable<number>;
|
|
843
|
+
/**
|
|
844
|
+
* Indicates the environment the resource belongs to (one of `test` or `live`)..
|
|
845
|
+
* @example ```"test"```
|
|
846
|
+
*/
|
|
847
|
+
mode?: Nullable<string>;
|
|
848
|
+
/**
|
|
849
|
+
* Indicates if the API credential is used to create a custom app (e.g. fork a hosted app)..
|
|
850
|
+
*/
|
|
851
|
+
custom?: Nullable<boolean>;
|
|
852
|
+
organization?: Nullable<Organization>;
|
|
853
|
+
role?: Nullable<Role>;
|
|
854
|
+
}
|
|
855
|
+
interface ApiCredentialCreate extends ResourceCreate {
|
|
856
|
+
/**
|
|
857
|
+
* The API credential internal name..
|
|
858
|
+
* @example ```"My app"```
|
|
859
|
+
*/
|
|
860
|
+
name: string;
|
|
861
|
+
/**
|
|
862
|
+
* The API credential kind, can be one of: `webapp`, `sales_channel`, `integration` or the kind of app you want to fork (e.g. `orders`, `imports`, etc.)..
|
|
863
|
+
* @example ```"sales_channel"```
|
|
864
|
+
*/
|
|
865
|
+
kind: string;
|
|
866
|
+
/**
|
|
867
|
+
* The API credential redirect URI..
|
|
868
|
+
* @example ```"https://bluebrand.com/img/logo.svg"```
|
|
869
|
+
*/
|
|
870
|
+
redirect_uri?: Nullable<string>;
|
|
871
|
+
/**
|
|
872
|
+
* The lifetime of the access token in seconds (min. `7200`, max. `31536000`. Default is `14400` for Sales channels and `7200` for other client types)..
|
|
873
|
+
* @example ```"7200"```
|
|
874
|
+
*/
|
|
875
|
+
expires_in?: Nullable<number>;
|
|
876
|
+
/**
|
|
877
|
+
* Indicates the environment the resource belongs to (one of `test` or `live`)..
|
|
878
|
+
* @example ```"test"```
|
|
879
|
+
*/
|
|
880
|
+
mode?: Nullable<string>;
|
|
881
|
+
/**
|
|
882
|
+
* Indicates if the API credential is used to create a custom app (e.g. fork a hosted app)..
|
|
883
|
+
*/
|
|
884
|
+
custom?: Nullable<boolean>;
|
|
885
|
+
organization: OrganizationRel;
|
|
886
|
+
role?: Nullable<RoleRel>;
|
|
887
|
+
}
|
|
888
|
+
interface ApiCredentialUpdate extends ResourceUpdate {
|
|
889
|
+
/**
|
|
890
|
+
* The API credential internal name..
|
|
891
|
+
* @example ```"My app"```
|
|
892
|
+
*/
|
|
893
|
+
name?: Nullable<string>;
|
|
894
|
+
/**
|
|
895
|
+
* The API credential redirect URI..
|
|
896
|
+
* @example ```"https://bluebrand.com/img/logo.svg"```
|
|
897
|
+
*/
|
|
898
|
+
redirect_uri?: Nullable<string>;
|
|
899
|
+
/**
|
|
900
|
+
* The lifetime of the access token in seconds (min. `7200`, max. `31536000`. Default is `14400` for Sales channels and `7200` for other client types)..
|
|
901
|
+
* @example ```"7200"```
|
|
902
|
+
*/
|
|
903
|
+
expires_in?: Nullable<number>;
|
|
904
|
+
role?: Nullable<RoleRel>;
|
|
905
|
+
}
|
|
906
|
+
declare class ApiCredentials extends ApiResource<ApiCredential> {
|
|
907
|
+
static readonly TYPE: ApiCredentialType;
|
|
908
|
+
create(resource: ApiCredentialCreate, params?: QueryParamsRetrieve, options?: ResourcesConfig): Promise<ApiCredential>;
|
|
909
|
+
update(resource: ApiCredentialUpdate, params?: QueryParamsRetrieve, options?: ResourcesConfig): Promise<ApiCredential>;
|
|
910
|
+
delete(id: string | ResourceId, options?: ResourcesConfig): Promise<void>;
|
|
911
|
+
organization(apiCredentialId: string | ApiCredential, params?: QueryParamsRetrieve<Organization>, options?: ResourcesConfig): Promise<Organization>;
|
|
912
|
+
role(apiCredentialId: string | ApiCredential, params?: QueryParamsRetrieve<Role>, options?: ResourcesConfig): Promise<Role>;
|
|
913
|
+
isApiCredential(resource: any): resource is ApiCredential;
|
|
914
|
+
relationship(id: string | ResourceId | null): ApiCredentialRel;
|
|
915
|
+
relationshipToMany(...ids: string[]): ApiCredentialRel[];
|
|
916
|
+
type(): ApiCredentialType;
|
|
917
|
+
}
|
|
918
|
+
|
|
919
|
+
type UserType = 'user';
|
|
920
|
+
type UserRel = ResourceRel & {
|
|
921
|
+
type: UserType;
|
|
922
|
+
};
|
|
923
|
+
type UserSort = Pick<User, 'id'> & ResourceSort;
|
|
924
|
+
interface User extends Resource {
|
|
925
|
+
readonly type: UserType;
|
|
926
|
+
/**
|
|
927
|
+
* The user email..
|
|
928
|
+
* @example ```"user@commercelayer.io"```
|
|
929
|
+
*/
|
|
930
|
+
email: string;
|
|
931
|
+
/**
|
|
932
|
+
* The user first name..
|
|
933
|
+
* @example ```"John"```
|
|
934
|
+
*/
|
|
935
|
+
first_name: string;
|
|
936
|
+
/**
|
|
937
|
+
* The user last name..
|
|
938
|
+
* @example ```"Doe"```
|
|
939
|
+
*/
|
|
940
|
+
last_name: string;
|
|
941
|
+
/**
|
|
942
|
+
* The user preferred timezone..
|
|
943
|
+
* @example ```"UTC"```
|
|
944
|
+
*/
|
|
945
|
+
time_zone?: Nullable<string>;
|
|
946
|
+
/**
|
|
947
|
+
* The user 2FA setting..
|
|
948
|
+
*/
|
|
949
|
+
otp_required_for_login: boolean;
|
|
950
|
+
}
|
|
951
|
+
interface UserUpdate extends ResourceUpdate {
|
|
952
|
+
/**
|
|
953
|
+
* The user email..
|
|
954
|
+
* @example ```"user@commercelayer.io"```
|
|
955
|
+
*/
|
|
956
|
+
email?: Nullable<string>;
|
|
957
|
+
/**
|
|
958
|
+
* The user first name..
|
|
959
|
+
* @example ```"John"```
|
|
960
|
+
*/
|
|
961
|
+
first_name?: Nullable<string>;
|
|
962
|
+
/**
|
|
963
|
+
* The user last name..
|
|
964
|
+
* @example ```"Doe"```
|
|
965
|
+
*/
|
|
966
|
+
last_name?: Nullable<string>;
|
|
967
|
+
/**
|
|
968
|
+
* The user preferred timezone..
|
|
969
|
+
* @example ```"UTC"```
|
|
970
|
+
*/
|
|
971
|
+
time_zone?: Nullable<string>;
|
|
972
|
+
}
|
|
973
|
+
declare class Users extends ApiSingleton<User> {
|
|
974
|
+
static readonly TYPE: UserType;
|
|
975
|
+
update(resource: UserUpdate, params?: QueryParamsRetrieve, options?: ResourcesConfig): Promise<User>;
|
|
976
|
+
isUser(resource: any): resource is User;
|
|
977
|
+
relationship(id: string | ResourceId | null): UserRel;
|
|
978
|
+
relationshipToMany(...ids: string[]): UserRel[];
|
|
979
|
+
type(): UserType;
|
|
980
|
+
}
|
|
981
|
+
|
|
982
|
+
type ResourceTypeLock = 'api_credentials' | 'application_memberships' | 'memberships' | 'organizations' | 'permissions' | 'roles' | 'user' | 'versions';
|
|
983
|
+
declare const resourceList: readonly ["api_credentials", "application_memberships", "memberships", "organizations", "permissions", "roles", "user", "versions"];
|
|
984
|
+
declare const singletonList: readonly ["user"];
|
|
985
|
+
type RetrievableResourceType = ResourceTypeLock;
|
|
986
|
+
type RetrievableResource = Resource & {
|
|
987
|
+
type: RetrievableResourceType;
|
|
988
|
+
};
|
|
989
|
+
type ListableResourceType = Exclude<ResourceTypeLock, 'user'>;
|
|
990
|
+
type ListableResource = Resource & {
|
|
991
|
+
type: ListableResourceType;
|
|
992
|
+
};
|
|
993
|
+
type CreatableResourceType = 'api_credentials' | 'application_memberships' | 'memberships' | 'organizations' | 'permissions' | 'roles';
|
|
994
|
+
type CreatableResource = Resource & {
|
|
995
|
+
type: CreatableResourceType;
|
|
996
|
+
};
|
|
997
|
+
type UpdatableResourceType = 'api_credentials' | 'application_memberships' | 'memberships' | 'organizations' | 'permissions' | 'roles';
|
|
998
|
+
type UpdatableResource = Resource & {
|
|
999
|
+
type: UpdatableResourceType;
|
|
1000
|
+
};
|
|
1001
|
+
type DeletableResourceType = 'api_credentials' | 'application_memberships' | 'memberships';
|
|
1002
|
+
type DeletableResource = Resource & {
|
|
1003
|
+
type: DeletableResourceType;
|
|
1004
|
+
};
|
|
1005
|
+
type VersionableResourceType = 'memberships' | 'permissions' | 'roles';
|
|
1006
|
+
type VersionableResource = Resource & {
|
|
1007
|
+
type: VersionableResourceType;
|
|
1008
|
+
versions?: Array<ResourceRel & {
|
|
1009
|
+
type: VersionType;
|
|
1010
|
+
}> | null;
|
|
1011
|
+
};
|
|
1012
|
+
type ResourceFields = {
|
|
1013
|
+
api_credentials: ApiCredential;
|
|
1014
|
+
application_memberships: ApplicationMembership;
|
|
1015
|
+
memberships: Membership;
|
|
1016
|
+
organizations: Organization;
|
|
1017
|
+
permissions: Permission;
|
|
1018
|
+
roles: Role;
|
|
1019
|
+
user: User;
|
|
1020
|
+
versions: Version;
|
|
1021
|
+
};
|
|
1022
|
+
type ResourceSortFields = {
|
|
1023
|
+
api_credentials: ApiCredentialSort;
|
|
1024
|
+
application_memberships: ApplicationMembershipSort;
|
|
1025
|
+
memberships: MembershipSort;
|
|
1026
|
+
organizations: OrganizationSort;
|
|
1027
|
+
permissions: PermissionSort;
|
|
1028
|
+
roles: RoleSort;
|
|
1029
|
+
user: UserSort;
|
|
1030
|
+
versions: VersionSort;
|
|
1031
|
+
};
|
|
1032
|
+
|
|
1033
|
+
declare enum ErrorType {
|
|
1034
|
+
CLIENT = "client",// Generic Client error
|
|
1035
|
+
REQUEST = "request",// Error preparing API request
|
|
1036
|
+
RESPONSE = "response",// Error response from API
|
|
1037
|
+
CANCEL = "cancel",// Forced request abort using interceptor
|
|
1038
|
+
PARSE = "parse",// Error parsing API resource
|
|
1039
|
+
TIMEOUT = "timeout"
|
|
1040
|
+
}
|
|
1041
|
+
declare class SdkError extends Error {
|
|
1042
|
+
static NAME: string;
|
|
1043
|
+
static isSdkError(error: any): error is SdkError;
|
|
1044
|
+
type: ErrorType;
|
|
1045
|
+
code?: string;
|
|
1046
|
+
source?: Error;
|
|
1047
|
+
constructor(error: {
|
|
1048
|
+
message: string;
|
|
1049
|
+
type?: ErrorType;
|
|
1050
|
+
});
|
|
1051
|
+
}
|
|
1052
|
+
declare class ApiError extends SdkError {
|
|
1053
|
+
static NAME: string;
|
|
1054
|
+
static isApiError(error: any): error is ApiError;
|
|
1055
|
+
errors: any[];
|
|
1056
|
+
status?: number;
|
|
1057
|
+
statusText?: string;
|
|
1058
|
+
constructor(error: SdkError);
|
|
1059
|
+
first(): any;
|
|
1060
|
+
}
|
|
1061
|
+
|
|
1062
|
+
type SdkConfig = {};
|
|
1063
|
+
type CommerceLayerInitConfig = SdkConfig & ResourcesInitConfig;
|
|
1064
|
+
type CommerceLayerConfig = Partial<CommerceLayerInitConfig>;
|
|
1065
|
+
declare class CommerceLayerProvisioningClient {
|
|
1066
|
+
#private;
|
|
1067
|
+
readonly openApiSchemaVersion = "1.0.4";
|
|
1068
|
+
constructor(config: CommerceLayerInitConfig);
|
|
1069
|
+
get api_credentials(): ApiCredentials;
|
|
1070
|
+
get application_memberships(): ApplicationMemberships;
|
|
1071
|
+
get memberships(): Memberships;
|
|
1072
|
+
get organizations(): Organizations;
|
|
1073
|
+
get permissions(): Permissions;
|
|
1074
|
+
get roles(): Roles;
|
|
1075
|
+
get user(): Users;
|
|
1076
|
+
get versions(): Versions;
|
|
1077
|
+
private get interceptors();
|
|
1078
|
+
private localConfig;
|
|
1079
|
+
config(config: CommerceLayerConfig): this;
|
|
1080
|
+
resources(): readonly string[];
|
|
1081
|
+
singletons(): readonly string[];
|
|
1082
|
+
isSingleton(resource: ResourceTypeLock): boolean;
|
|
1083
|
+
isApiError(error: any): error is ApiError;
|
|
1084
|
+
addRequestInterceptor(onSuccess?: RequestInterceptor, onFailure?: ErrorInterceptor): number;
|
|
1085
|
+
addResponseInterceptor(onSuccess?: ResponseInterceptor, onFailure?: ErrorInterceptor): number;
|
|
1086
|
+
removeInterceptor(type: InterceptorType, id?: number): void;
|
|
1087
|
+
addRawResponseReader(options?: {
|
|
1088
|
+
headers: boolean;
|
|
1089
|
+
}): RawResponseReader;
|
|
1090
|
+
removeRawResponseReader(reader?: number | RawResponseReader): void;
|
|
1091
|
+
}
|
|
1092
|
+
declare const CommerceLayerProvisioning: (config: CommerceLayerInitConfig) => CommerceLayerProvisioningClient;
|
|
1093
|
+
|
|
1094
|
+
declare const CommerceLayerProvisioningStatic: {
|
|
1095
|
+
resources: (sort?: boolean) => readonly string[];
|
|
1096
|
+
singletons: (sort?: boolean) => readonly string[];
|
|
1097
|
+
isSingleton: (resource: ResourceTypeLock) => boolean;
|
|
1098
|
+
isSdkError: (error: unknown) => error is SdkError;
|
|
1099
|
+
isApiError: (error: unknown) => error is ApiError;
|
|
1100
|
+
init: (config: CommerceLayerInitConfig) => CommerceLayerProvisioningClient;
|
|
1101
|
+
readonly schemaVersion: string;
|
|
1102
|
+
};
|
|
1103
|
+
|
|
1104
|
+
export { type ApiCredential, type ApiCredentialCreate, type ApiCredentialSort, type ApiCredentialUpdate, ApiCredentials, ApiError, ApiResource, ApiSingleton, type ApplicationMembership, type ApplicationMembershipCreate, type ApplicationMembershipSort, type ApplicationMembershipUpdate, ApplicationMemberships, CommerceLayerProvisioning, CommerceLayerProvisioningClient, CommerceLayerProvisioningStatic, type CreatableResource, type CreatableResourceType, type DeletableResource, type DeletableResourceType, type ErrorObj, ErrorType, type HeadersObj, type ListMeta, ListResponse, type ListableResource, type ListableResourceType, type Membership, type MembershipCreate, type MembershipSort, type MembershipUpdate, Memberships, type Metadata, type Organization, type OrganizationCreate, type OrganizationSort, type OrganizationUpdate, Organizations, type Permission, type PermissionCreate, type PermissionSort, type PermissionUpdate, Permissions, type QueryFilter, type QueryPageSize, type QueryParams, type QueryParamsList, type QueryParamsRetrieve, type RequestObj, type Resource, type ResourceCreate, type ResourceFields, type ResourceFilter, type ResourceId, type ResourceRel, type ResourceSort, type ResourceSortFields, type ResourceType, type ResourceTypeLock, type ResourceUpdate, type ResourcesConfig, type ResourcesInitConfig, type ResponseObj, type RetrievableResource, type RetrievableResourceType, type Role, type RoleCreate, type RoleSort, type RoleUpdate, Roles, SdkError, type UpdatableResource, type UpdatableResourceType, type User, type UserSort, type UserUpdate, Users, type Version, type VersionSort, type VersionableResource, type VersionableResourceType, Versions, apiResourceAdapter, CommerceLayerProvisioning as default, generateQueryStringParams, generateSearchString, isParamsList, resourceList, singletonList };
|