@commercelayer/cli-core 5.6.0 → 5.6.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.
- package/lib/index.d.mts +104 -102
- package/lib/index.d.ts +104 -102
- package/lib/index.js +4 -4
- package/lib/index.mjs +5 -5
- package/package.json +1 -1
package/lib/index.d.mts
CHANGED
|
@@ -75,6 +75,105 @@ declare namespace api$1 {
|
|
|
75
75
|
export { type api$1_ApiMode as ApiMode, type api$1_ApiType as ApiType, type api$1_DelayOptions as DelayOptions, api$1_Operation as Operation, api$1_baseURL as baseURL, api$1_execMode as execMode, api$1_extractDomain as extractDomain, api$1_humanizeResource as humanizeResource, api$1_isResourceCacheable as isResourceCacheable, api$1_liveEnvironment as liveEnvironment, api$1_request as request, readDataFile as requestDataFile, api$1_requestRateLimitDelay as requestRateLimitDelay, rawRequest as requestRaw, api$1_response as response, denormalize as responseDenormalize };
|
|
76
76
|
}
|
|
77
77
|
|
|
78
|
+
type ApiConfig = {
|
|
79
|
+
default_domain: string;
|
|
80
|
+
default_app_domain: string;
|
|
81
|
+
default_stg_domain: string;
|
|
82
|
+
token_expiration_mins: number;
|
|
83
|
+
token_encoding_algorithm: string;
|
|
84
|
+
token_owner_types: string[];
|
|
85
|
+
requests_max_num_burst: number;
|
|
86
|
+
requests_max_num_burst_cacheable: number;
|
|
87
|
+
requests_max_num_burst_test: number;
|
|
88
|
+
requests_max_num_burst_test_cacheable: number;
|
|
89
|
+
requests_max_secs_burst: number;
|
|
90
|
+
requests_max_num_avg: number;
|
|
91
|
+
requests_max_num_avg_cacheable: number;
|
|
92
|
+
requests_max_num_avg_test: number;
|
|
93
|
+
requests_max_num_avg_test_cacheable: number;
|
|
94
|
+
requests_max_secs_avg: number;
|
|
95
|
+
requests_max_num_oauth: number;
|
|
96
|
+
requests_max_secs_oauth: number;
|
|
97
|
+
page_max_size: number;
|
|
98
|
+
page_default_size: number;
|
|
99
|
+
};
|
|
100
|
+
type ApplicationConfig = {
|
|
101
|
+
kinds: readonly string[];
|
|
102
|
+
login_scopes: readonly string[];
|
|
103
|
+
};
|
|
104
|
+
type ImportsConfig = {
|
|
105
|
+
max_size: number;
|
|
106
|
+
statuses: readonly string[];
|
|
107
|
+
types: readonly string[];
|
|
108
|
+
max_queue_length: number;
|
|
109
|
+
attachment_expiration: number;
|
|
110
|
+
};
|
|
111
|
+
type ExportsConfig = {
|
|
112
|
+
max_size: number;
|
|
113
|
+
statuses: readonly string[];
|
|
114
|
+
types: readonly string[];
|
|
115
|
+
max_queue_length: number;
|
|
116
|
+
attachment_expiration: number;
|
|
117
|
+
};
|
|
118
|
+
type CleanupsConfig = {
|
|
119
|
+
max_size: number;
|
|
120
|
+
statuses: readonly string[];
|
|
121
|
+
types: readonly string[];
|
|
122
|
+
max_queue_length: number;
|
|
123
|
+
};
|
|
124
|
+
type WebhooksConfig = {
|
|
125
|
+
retry_number: number;
|
|
126
|
+
};
|
|
127
|
+
type CliConfig = {
|
|
128
|
+
applications: readonly string[];
|
|
129
|
+
};
|
|
130
|
+
type DocConfig = {
|
|
131
|
+
core: string;
|
|
132
|
+
core_api_reference: string;
|
|
133
|
+
core_how_tos: string;
|
|
134
|
+
core_raste_limits: string;
|
|
135
|
+
core_filtering_data: string;
|
|
136
|
+
metrics: string;
|
|
137
|
+
metrics_api_reference: string;
|
|
138
|
+
provisioning: string;
|
|
139
|
+
provisioning_api_reference: string;
|
|
140
|
+
imports_resources: string;
|
|
141
|
+
exports_resources: string;
|
|
142
|
+
cleanups_resources: string;
|
|
143
|
+
webhooks_events: string;
|
|
144
|
+
tags_resources: string;
|
|
145
|
+
links_resources: string;
|
|
146
|
+
};
|
|
147
|
+
type TagsConfig = {
|
|
148
|
+
max_resource_tags: number;
|
|
149
|
+
taggable_resources: readonly string[];
|
|
150
|
+
tag_name_max_length: number;
|
|
151
|
+
tag_name_pattern: RegExp;
|
|
152
|
+
};
|
|
153
|
+
type ProvisioningConfig = {
|
|
154
|
+
default_subdomain: string;
|
|
155
|
+
scope: string;
|
|
156
|
+
applications: readonly string[];
|
|
157
|
+
};
|
|
158
|
+
type LinksConfig = {
|
|
159
|
+
default_domain: string;
|
|
160
|
+
linkable_resources: readonly string[];
|
|
161
|
+
};
|
|
162
|
+
type Config = {
|
|
163
|
+
api: ApiConfig;
|
|
164
|
+
application: ApplicationConfig;
|
|
165
|
+
imports: ImportsConfig;
|
|
166
|
+
exports: ExportsConfig;
|
|
167
|
+
cleanups: CleanupsConfig;
|
|
168
|
+
webhooks: WebhooksConfig;
|
|
169
|
+
cli: CliConfig;
|
|
170
|
+
doc: DocConfig;
|
|
171
|
+
tags: TagsConfig;
|
|
172
|
+
provisioning: ProvisioningConfig;
|
|
173
|
+
links: LinksConfig;
|
|
174
|
+
};
|
|
175
|
+
declare const config: Config;
|
|
176
|
+
|
|
78
177
|
/** Copy command flags excluding a subset */
|
|
79
178
|
declare const commandFlags: <T extends object>(flags: T, exclude?: string[]) => T;
|
|
80
179
|
declare const allFlags: (command: Command.Class) => FlagInput;
|
|
@@ -126,8 +225,8 @@ type AccessToken = {
|
|
|
126
225
|
error?: string;
|
|
127
226
|
errorDescription?: string;
|
|
128
227
|
};
|
|
129
|
-
|
|
130
|
-
type OwnerType = typeof
|
|
228
|
+
type ApplicationKind = typeof config.application.kinds[number];
|
|
229
|
+
type OwnerType = typeof config.api.token_owner_types[number];
|
|
131
230
|
type AccessTokenInfo = {
|
|
132
231
|
organization?: {
|
|
133
232
|
id: string;
|
|
@@ -135,7 +234,7 @@ type AccessTokenInfo = {
|
|
|
135
234
|
};
|
|
136
235
|
application: {
|
|
137
236
|
id: string;
|
|
138
|
-
kind:
|
|
237
|
+
kind: ApplicationKind;
|
|
139
238
|
public: boolean;
|
|
140
239
|
};
|
|
141
240
|
test: boolean;
|
|
@@ -175,6 +274,7 @@ declare const buildAssertionPayload: (ownerType: OwnerType, ownerId: string, cus
|
|
|
175
274
|
|
|
176
275
|
type token_AccessToken = AccessToken;
|
|
177
276
|
type token_AccessTokenInfo = AccessTokenInfo;
|
|
277
|
+
type token_ApplicationKind = ApplicationKind;
|
|
178
278
|
type token_AuthScope = AuthScope;
|
|
179
279
|
type token_CustomToken = CustomToken;
|
|
180
280
|
type token_OwnerType = OwnerType;
|
|
@@ -186,7 +286,7 @@ declare const token_getTokenEnvironment: typeof getTokenEnvironment;
|
|
|
186
286
|
declare const token_isAccessTokenExpiring: typeof isAccessTokenExpiring;
|
|
187
287
|
declare const token_revokeAccessToken: typeof revokeAccessToken;
|
|
188
288
|
declare namespace token {
|
|
189
|
-
export { type token_AccessToken as AccessToken, type token_AccessTokenInfo as AccessTokenInfo, type token_AuthScope as AuthScope, type token_CustomToken as CustomToken, type token_OwnerType as OwnerType, token_buildAssertionPayload as buildAssertionPayload, token_decodeAccessToken as decodeAccessToken, token_generateAccessToken as generateAccessToken, token_getAccessToken as getAccessToken, token_getTokenEnvironment as getTokenEnvironment, token_isAccessTokenExpiring as isAccessTokenExpiring, token_revokeAccessToken as revokeAccessToken };
|
|
289
|
+
export { type token_AccessToken as AccessToken, type token_AccessTokenInfo as AccessTokenInfo, type token_ApplicationKind as ApplicationKind, type token_AuthScope as AuthScope, type token_CustomToken as CustomToken, type token_OwnerType as OwnerType, token_buildAssertionPayload as buildAssertionPayload, token_decodeAccessToken as decodeAccessToken, token_generateAccessToken as generateAccessToken, token_getAccessToken as getAccessToken, token_getTokenEnvironment as getTokenEnvironment, token_isAccessTokenExpiring as isAccessTokenExpiring, token_revokeAccessToken as revokeAccessToken };
|
|
190
290
|
}
|
|
191
291
|
|
|
192
292
|
interface AppKey {
|
|
@@ -235,104 +335,6 @@ declare namespace application {
|
|
|
235
335
|
export { type application_AppAuth as AppAuth, type application_AppInfo as AppInfo, type application_AppKey as AppKey, application_appKey as appKey, application_appKeyMatch as appKeyMatch, application_appKeyValid as appKeyValid, application_arrayScope as arrayScope, application_isProvisioningApp as isProvisioningApp };
|
|
236
336
|
}
|
|
237
337
|
|
|
238
|
-
type ApiConfig = {
|
|
239
|
-
default_domain: string;
|
|
240
|
-
default_app_domain: string;
|
|
241
|
-
default_stg_domain: string;
|
|
242
|
-
token_expiration_mins: number;
|
|
243
|
-
token_encoding_algorithm: string;
|
|
244
|
-
requests_max_num_burst: number;
|
|
245
|
-
requests_max_num_burst_cacheable: number;
|
|
246
|
-
requests_max_num_burst_test: number;
|
|
247
|
-
requests_max_num_burst_test_cacheable: number;
|
|
248
|
-
requests_max_secs_burst: number;
|
|
249
|
-
requests_max_num_avg: number;
|
|
250
|
-
requests_max_num_avg_cacheable: number;
|
|
251
|
-
requests_max_num_avg_test: number;
|
|
252
|
-
requests_max_num_avg_test_cacheable: number;
|
|
253
|
-
requests_max_secs_avg: number;
|
|
254
|
-
requests_max_num_oauth: number;
|
|
255
|
-
requests_max_secs_oauth: number;
|
|
256
|
-
page_max_size: number;
|
|
257
|
-
page_default_size: number;
|
|
258
|
-
};
|
|
259
|
-
type ApplicationConfig = {
|
|
260
|
-
kinds: readonly string[];
|
|
261
|
-
login_scopes: readonly string[];
|
|
262
|
-
};
|
|
263
|
-
type ImportsConfig = {
|
|
264
|
-
max_size: number;
|
|
265
|
-
statuses: readonly string[];
|
|
266
|
-
types: readonly string[];
|
|
267
|
-
max_queue_length: number;
|
|
268
|
-
attachment_expiration: number;
|
|
269
|
-
};
|
|
270
|
-
type ExportsConfig = {
|
|
271
|
-
max_size: number;
|
|
272
|
-
statuses: readonly string[];
|
|
273
|
-
types: readonly string[];
|
|
274
|
-
max_queue_length: number;
|
|
275
|
-
attachment_expiration: number;
|
|
276
|
-
};
|
|
277
|
-
type CleanupsConfig = {
|
|
278
|
-
max_size: number;
|
|
279
|
-
statuses: readonly string[];
|
|
280
|
-
types: readonly string[];
|
|
281
|
-
max_queue_length: number;
|
|
282
|
-
};
|
|
283
|
-
type WebhooksConfig = {
|
|
284
|
-
retry_number: number;
|
|
285
|
-
};
|
|
286
|
-
type CliConfig = {
|
|
287
|
-
applications: readonly string[];
|
|
288
|
-
};
|
|
289
|
-
type DocConfig = {
|
|
290
|
-
core: string;
|
|
291
|
-
core_api_reference: string;
|
|
292
|
-
core_how_tos: string;
|
|
293
|
-
core_raste_limits: string;
|
|
294
|
-
core_filtering_data: string;
|
|
295
|
-
metrics: string;
|
|
296
|
-
metrics_api_reference: string;
|
|
297
|
-
provisioning: string;
|
|
298
|
-
provisioning_api_reference: string;
|
|
299
|
-
imports_resources: string;
|
|
300
|
-
exports_resources: string;
|
|
301
|
-
cleanups_resources: string;
|
|
302
|
-
webhooks_events: string;
|
|
303
|
-
tags_resources: string;
|
|
304
|
-
links_resources: string;
|
|
305
|
-
};
|
|
306
|
-
type TagsConfig = {
|
|
307
|
-
max_resource_tags: number;
|
|
308
|
-
taggable_resources: readonly string[];
|
|
309
|
-
tag_name_max_length: number;
|
|
310
|
-
tag_name_pattern: RegExp;
|
|
311
|
-
};
|
|
312
|
-
type ProvisioningConfig = {
|
|
313
|
-
default_subdomain: string;
|
|
314
|
-
scope: string;
|
|
315
|
-
applications: readonly string[];
|
|
316
|
-
};
|
|
317
|
-
type LinksConfig = {
|
|
318
|
-
default_domain: string;
|
|
319
|
-
linkable_resources: readonly string[];
|
|
320
|
-
};
|
|
321
|
-
type Config = {
|
|
322
|
-
api: ApiConfig;
|
|
323
|
-
application: ApplicationConfig;
|
|
324
|
-
imports: ImportsConfig;
|
|
325
|
-
exports: ExportsConfig;
|
|
326
|
-
cleanups: CleanupsConfig;
|
|
327
|
-
webhooks: WebhooksConfig;
|
|
328
|
-
cli: CliConfig;
|
|
329
|
-
doc: DocConfig;
|
|
330
|
-
tags: TagsConfig;
|
|
331
|
-
provisioning: ProvisioningConfig;
|
|
332
|
-
links: LinksConfig;
|
|
333
|
-
};
|
|
334
|
-
declare const config: Config;
|
|
335
|
-
|
|
336
338
|
/** Print a formatted object */
|
|
337
339
|
declare const printObject: (obj: any, options?: {
|
|
338
340
|
color?: boolean;
|
package/lib/index.d.ts
CHANGED
|
@@ -75,6 +75,105 @@ declare namespace api$1 {
|
|
|
75
75
|
export { type api$1_ApiMode as ApiMode, type api$1_ApiType as ApiType, type api$1_DelayOptions as DelayOptions, api$1_Operation as Operation, api$1_baseURL as baseURL, api$1_execMode as execMode, api$1_extractDomain as extractDomain, api$1_humanizeResource as humanizeResource, api$1_isResourceCacheable as isResourceCacheable, api$1_liveEnvironment as liveEnvironment, api$1_request as request, readDataFile as requestDataFile, api$1_requestRateLimitDelay as requestRateLimitDelay, rawRequest as requestRaw, api$1_response as response, denormalize as responseDenormalize };
|
|
76
76
|
}
|
|
77
77
|
|
|
78
|
+
type ApiConfig = {
|
|
79
|
+
default_domain: string;
|
|
80
|
+
default_app_domain: string;
|
|
81
|
+
default_stg_domain: string;
|
|
82
|
+
token_expiration_mins: number;
|
|
83
|
+
token_encoding_algorithm: string;
|
|
84
|
+
token_owner_types: string[];
|
|
85
|
+
requests_max_num_burst: number;
|
|
86
|
+
requests_max_num_burst_cacheable: number;
|
|
87
|
+
requests_max_num_burst_test: number;
|
|
88
|
+
requests_max_num_burst_test_cacheable: number;
|
|
89
|
+
requests_max_secs_burst: number;
|
|
90
|
+
requests_max_num_avg: number;
|
|
91
|
+
requests_max_num_avg_cacheable: number;
|
|
92
|
+
requests_max_num_avg_test: number;
|
|
93
|
+
requests_max_num_avg_test_cacheable: number;
|
|
94
|
+
requests_max_secs_avg: number;
|
|
95
|
+
requests_max_num_oauth: number;
|
|
96
|
+
requests_max_secs_oauth: number;
|
|
97
|
+
page_max_size: number;
|
|
98
|
+
page_default_size: number;
|
|
99
|
+
};
|
|
100
|
+
type ApplicationConfig = {
|
|
101
|
+
kinds: readonly string[];
|
|
102
|
+
login_scopes: readonly string[];
|
|
103
|
+
};
|
|
104
|
+
type ImportsConfig = {
|
|
105
|
+
max_size: number;
|
|
106
|
+
statuses: readonly string[];
|
|
107
|
+
types: readonly string[];
|
|
108
|
+
max_queue_length: number;
|
|
109
|
+
attachment_expiration: number;
|
|
110
|
+
};
|
|
111
|
+
type ExportsConfig = {
|
|
112
|
+
max_size: number;
|
|
113
|
+
statuses: readonly string[];
|
|
114
|
+
types: readonly string[];
|
|
115
|
+
max_queue_length: number;
|
|
116
|
+
attachment_expiration: number;
|
|
117
|
+
};
|
|
118
|
+
type CleanupsConfig = {
|
|
119
|
+
max_size: number;
|
|
120
|
+
statuses: readonly string[];
|
|
121
|
+
types: readonly string[];
|
|
122
|
+
max_queue_length: number;
|
|
123
|
+
};
|
|
124
|
+
type WebhooksConfig = {
|
|
125
|
+
retry_number: number;
|
|
126
|
+
};
|
|
127
|
+
type CliConfig = {
|
|
128
|
+
applications: readonly string[];
|
|
129
|
+
};
|
|
130
|
+
type DocConfig = {
|
|
131
|
+
core: string;
|
|
132
|
+
core_api_reference: string;
|
|
133
|
+
core_how_tos: string;
|
|
134
|
+
core_raste_limits: string;
|
|
135
|
+
core_filtering_data: string;
|
|
136
|
+
metrics: string;
|
|
137
|
+
metrics_api_reference: string;
|
|
138
|
+
provisioning: string;
|
|
139
|
+
provisioning_api_reference: string;
|
|
140
|
+
imports_resources: string;
|
|
141
|
+
exports_resources: string;
|
|
142
|
+
cleanups_resources: string;
|
|
143
|
+
webhooks_events: string;
|
|
144
|
+
tags_resources: string;
|
|
145
|
+
links_resources: string;
|
|
146
|
+
};
|
|
147
|
+
type TagsConfig = {
|
|
148
|
+
max_resource_tags: number;
|
|
149
|
+
taggable_resources: readonly string[];
|
|
150
|
+
tag_name_max_length: number;
|
|
151
|
+
tag_name_pattern: RegExp;
|
|
152
|
+
};
|
|
153
|
+
type ProvisioningConfig = {
|
|
154
|
+
default_subdomain: string;
|
|
155
|
+
scope: string;
|
|
156
|
+
applications: readonly string[];
|
|
157
|
+
};
|
|
158
|
+
type LinksConfig = {
|
|
159
|
+
default_domain: string;
|
|
160
|
+
linkable_resources: readonly string[];
|
|
161
|
+
};
|
|
162
|
+
type Config = {
|
|
163
|
+
api: ApiConfig;
|
|
164
|
+
application: ApplicationConfig;
|
|
165
|
+
imports: ImportsConfig;
|
|
166
|
+
exports: ExportsConfig;
|
|
167
|
+
cleanups: CleanupsConfig;
|
|
168
|
+
webhooks: WebhooksConfig;
|
|
169
|
+
cli: CliConfig;
|
|
170
|
+
doc: DocConfig;
|
|
171
|
+
tags: TagsConfig;
|
|
172
|
+
provisioning: ProvisioningConfig;
|
|
173
|
+
links: LinksConfig;
|
|
174
|
+
};
|
|
175
|
+
declare const config: Config;
|
|
176
|
+
|
|
78
177
|
/** Copy command flags excluding a subset */
|
|
79
178
|
declare const commandFlags: <T extends object>(flags: T, exclude?: string[]) => T;
|
|
80
179
|
declare const allFlags: (command: Command.Class) => FlagInput;
|
|
@@ -126,8 +225,8 @@ type AccessToken = {
|
|
|
126
225
|
error?: string;
|
|
127
226
|
errorDescription?: string;
|
|
128
227
|
};
|
|
129
|
-
|
|
130
|
-
type OwnerType = typeof
|
|
228
|
+
type ApplicationKind = typeof config.application.kinds[number];
|
|
229
|
+
type OwnerType = typeof config.api.token_owner_types[number];
|
|
131
230
|
type AccessTokenInfo = {
|
|
132
231
|
organization?: {
|
|
133
232
|
id: string;
|
|
@@ -135,7 +234,7 @@ type AccessTokenInfo = {
|
|
|
135
234
|
};
|
|
136
235
|
application: {
|
|
137
236
|
id: string;
|
|
138
|
-
kind:
|
|
237
|
+
kind: ApplicationKind;
|
|
139
238
|
public: boolean;
|
|
140
239
|
};
|
|
141
240
|
test: boolean;
|
|
@@ -175,6 +274,7 @@ declare const buildAssertionPayload: (ownerType: OwnerType, ownerId: string, cus
|
|
|
175
274
|
|
|
176
275
|
type token_AccessToken = AccessToken;
|
|
177
276
|
type token_AccessTokenInfo = AccessTokenInfo;
|
|
277
|
+
type token_ApplicationKind = ApplicationKind;
|
|
178
278
|
type token_AuthScope = AuthScope;
|
|
179
279
|
type token_CustomToken = CustomToken;
|
|
180
280
|
type token_OwnerType = OwnerType;
|
|
@@ -186,7 +286,7 @@ declare const token_getTokenEnvironment: typeof getTokenEnvironment;
|
|
|
186
286
|
declare const token_isAccessTokenExpiring: typeof isAccessTokenExpiring;
|
|
187
287
|
declare const token_revokeAccessToken: typeof revokeAccessToken;
|
|
188
288
|
declare namespace token {
|
|
189
|
-
export { type token_AccessToken as AccessToken, type token_AccessTokenInfo as AccessTokenInfo, type token_AuthScope as AuthScope, type token_CustomToken as CustomToken, type token_OwnerType as OwnerType, token_buildAssertionPayload as buildAssertionPayload, token_decodeAccessToken as decodeAccessToken, token_generateAccessToken as generateAccessToken, token_getAccessToken as getAccessToken, token_getTokenEnvironment as getTokenEnvironment, token_isAccessTokenExpiring as isAccessTokenExpiring, token_revokeAccessToken as revokeAccessToken };
|
|
289
|
+
export { type token_AccessToken as AccessToken, type token_AccessTokenInfo as AccessTokenInfo, type token_ApplicationKind as ApplicationKind, type token_AuthScope as AuthScope, type token_CustomToken as CustomToken, type token_OwnerType as OwnerType, token_buildAssertionPayload as buildAssertionPayload, token_decodeAccessToken as decodeAccessToken, token_generateAccessToken as generateAccessToken, token_getAccessToken as getAccessToken, token_getTokenEnvironment as getTokenEnvironment, token_isAccessTokenExpiring as isAccessTokenExpiring, token_revokeAccessToken as revokeAccessToken };
|
|
190
290
|
}
|
|
191
291
|
|
|
192
292
|
interface AppKey {
|
|
@@ -235,104 +335,6 @@ declare namespace application {
|
|
|
235
335
|
export { type application_AppAuth as AppAuth, type application_AppInfo as AppInfo, type application_AppKey as AppKey, application_appKey as appKey, application_appKeyMatch as appKeyMatch, application_appKeyValid as appKeyValid, application_arrayScope as arrayScope, application_isProvisioningApp as isProvisioningApp };
|
|
236
336
|
}
|
|
237
337
|
|
|
238
|
-
type ApiConfig = {
|
|
239
|
-
default_domain: string;
|
|
240
|
-
default_app_domain: string;
|
|
241
|
-
default_stg_domain: string;
|
|
242
|
-
token_expiration_mins: number;
|
|
243
|
-
token_encoding_algorithm: string;
|
|
244
|
-
requests_max_num_burst: number;
|
|
245
|
-
requests_max_num_burst_cacheable: number;
|
|
246
|
-
requests_max_num_burst_test: number;
|
|
247
|
-
requests_max_num_burst_test_cacheable: number;
|
|
248
|
-
requests_max_secs_burst: number;
|
|
249
|
-
requests_max_num_avg: number;
|
|
250
|
-
requests_max_num_avg_cacheable: number;
|
|
251
|
-
requests_max_num_avg_test: number;
|
|
252
|
-
requests_max_num_avg_test_cacheable: number;
|
|
253
|
-
requests_max_secs_avg: number;
|
|
254
|
-
requests_max_num_oauth: number;
|
|
255
|
-
requests_max_secs_oauth: number;
|
|
256
|
-
page_max_size: number;
|
|
257
|
-
page_default_size: number;
|
|
258
|
-
};
|
|
259
|
-
type ApplicationConfig = {
|
|
260
|
-
kinds: readonly string[];
|
|
261
|
-
login_scopes: readonly string[];
|
|
262
|
-
};
|
|
263
|
-
type ImportsConfig = {
|
|
264
|
-
max_size: number;
|
|
265
|
-
statuses: readonly string[];
|
|
266
|
-
types: readonly string[];
|
|
267
|
-
max_queue_length: number;
|
|
268
|
-
attachment_expiration: number;
|
|
269
|
-
};
|
|
270
|
-
type ExportsConfig = {
|
|
271
|
-
max_size: number;
|
|
272
|
-
statuses: readonly string[];
|
|
273
|
-
types: readonly string[];
|
|
274
|
-
max_queue_length: number;
|
|
275
|
-
attachment_expiration: number;
|
|
276
|
-
};
|
|
277
|
-
type CleanupsConfig = {
|
|
278
|
-
max_size: number;
|
|
279
|
-
statuses: readonly string[];
|
|
280
|
-
types: readonly string[];
|
|
281
|
-
max_queue_length: number;
|
|
282
|
-
};
|
|
283
|
-
type WebhooksConfig = {
|
|
284
|
-
retry_number: number;
|
|
285
|
-
};
|
|
286
|
-
type CliConfig = {
|
|
287
|
-
applications: readonly string[];
|
|
288
|
-
};
|
|
289
|
-
type DocConfig = {
|
|
290
|
-
core: string;
|
|
291
|
-
core_api_reference: string;
|
|
292
|
-
core_how_tos: string;
|
|
293
|
-
core_raste_limits: string;
|
|
294
|
-
core_filtering_data: string;
|
|
295
|
-
metrics: string;
|
|
296
|
-
metrics_api_reference: string;
|
|
297
|
-
provisioning: string;
|
|
298
|
-
provisioning_api_reference: string;
|
|
299
|
-
imports_resources: string;
|
|
300
|
-
exports_resources: string;
|
|
301
|
-
cleanups_resources: string;
|
|
302
|
-
webhooks_events: string;
|
|
303
|
-
tags_resources: string;
|
|
304
|
-
links_resources: string;
|
|
305
|
-
};
|
|
306
|
-
type TagsConfig = {
|
|
307
|
-
max_resource_tags: number;
|
|
308
|
-
taggable_resources: readonly string[];
|
|
309
|
-
tag_name_max_length: number;
|
|
310
|
-
tag_name_pattern: RegExp;
|
|
311
|
-
};
|
|
312
|
-
type ProvisioningConfig = {
|
|
313
|
-
default_subdomain: string;
|
|
314
|
-
scope: string;
|
|
315
|
-
applications: readonly string[];
|
|
316
|
-
};
|
|
317
|
-
type LinksConfig = {
|
|
318
|
-
default_domain: string;
|
|
319
|
-
linkable_resources: readonly string[];
|
|
320
|
-
};
|
|
321
|
-
type Config = {
|
|
322
|
-
api: ApiConfig;
|
|
323
|
-
application: ApplicationConfig;
|
|
324
|
-
imports: ImportsConfig;
|
|
325
|
-
exports: ExportsConfig;
|
|
326
|
-
cleanups: CleanupsConfig;
|
|
327
|
-
webhooks: WebhooksConfig;
|
|
328
|
-
cli: CliConfig;
|
|
329
|
-
doc: DocConfig;
|
|
330
|
-
tags: TagsConfig;
|
|
331
|
-
provisioning: ProvisioningConfig;
|
|
332
|
-
links: LinksConfig;
|
|
333
|
-
};
|
|
334
|
-
declare const config: Config;
|
|
335
|
-
|
|
336
338
|
/** Print a formatted object */
|
|
337
339
|
declare const printObject: (obj: any, options?: {
|
|
338
340
|
color?: boolean;
|
package/lib/index.js
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
"use strict";var Re=Object.create;var I=Object.defineProperty;var Ee=Object.getOwnPropertyDescriptor;var Se=Object.getOwnPropertyNames;var ze=Object.getPrototypeOf,Ie=Object.prototype.hasOwnProperty;var f=(e,t)=>{for(var r in t)I(e,r,{get:t[r],enumerable:!0})},pe=(e,t,r,s)=>{if(t&&typeof t=="object"||typeof t=="function")for(let n of Se(t))!Ie.call(e,n)&&n!==r&&I(e,n,{get:()=>t[n],enumerable:!(s=Ee(t,n))||s.enumerable});return e};var O=(e,t,r)=>(r=e!=null?Re(ze(e)):{},pe(t||!e||!e.__esModule?I(r,"default",{value:e,enumerable:!0}):r,e)),Oe=e=>pe(I({},"__esModule",{value:!0}),e);var rr={};f(rr,{clApi:()=>Y,clApplication:()=>J,clColor:()=>k,clCommand:()=>X,clConfig:()=>m,clFilter:()=>ce,clHelp:()=>S,clOutput:()=>Z,clSchema:()=>ae,clSymbol:()=>ne,clText:()=>ie,clToken:()=>te,clUpdate:()=>re,clUtil:()=>se});module.exports=Oe(rr);var Y={};f(Y,{Operation:()=>H,baseURL:()=>je,execMode:()=>We,extractDomain:()=>Ue,humanizeResource:()=>Ve,isResourceCacheable:()=>de,liveEnvironment:()=>Ne,request:()=>He,requestDataFile:()=>N,requestRateLimitDelay:()=>ge,requestRaw:()=>F,response:()=>Ge,responseDenormalize:()=>G});var V=["in_progress","pending","completed","interrupted"],Be=["addresses","bundles","coupons","customer_addresses","customer_payment_sources","customer_subscriptions","customers","gift_cards","line_items","line_item_options","orders","price_tiers","prices","shipping_categories","sku_lists","sku_list_items","sku_options","skus","stock_items","stock_transfers","tags","tax_categories"],De=["addresses","authorizations","bundles","captures","coupons","customer_addresses","customer_payment_sources","customer_subscriptions","customers","gift_cards","line_items","line_item_options","orders","payment_methods","price_tiers","prices","refunds","shipments","shipping_categories","shipping_methods","sku_lists","sku_list_items","sku_options","skus","stock_items","stock_transfers","tags","tax_categories","transactions","voids"],Me=["bundles","gift_cards","prices","promotions","sku_lists","sku_options","skus","stock_items"],Le=["addresses","bundles","customers","coupons","gift_cards","line_items","line_item_options","orders","returns","skus","sku_options","promotions","external_promotions","fixed_amount_promotions","fixed_price_promotions","free_gift_promotions","free_shipping_promotions","percentage_discount_promotions"],Ke=["orders","skus","sku_lists"],b={erl_oauth_limit_live:30,erl_average_limit_cachable_live:1e3,erl_average_limit_cachable_test:500,erl_burst_limit_cachable_live:250,erl_burst_limit_cachable_test:125,erl_average_limit_uncachable_live:200,erl_average_limit_uncachable_test:100,erl_burst_limit_uncachable_live:50,erl_burst_limit_uncachable_test:25},Pe={api:{default_domain:"commercelayer.io",default_app_domain:"commercelayer.app",default_stg_domain:"commercelayer.co",token_expiration_mins:60*4,token_encoding_algorithm:"HS512",requests_max_num_burst:b.erl_burst_limit_uncachable_live,requests_max_num_burst_cacheable:b.erl_burst_limit_cachable_live,requests_max_num_burst_test:b.erl_burst_limit_uncachable_test,requests_max_num_burst_test_cacheable:b.erl_burst_limit_cachable_test,requests_max_num_avg:b.erl_average_limit_uncachable_live,requests_max_num_avg_cacheable:b.erl_average_limit_cachable_live,requests_max_num_avg_test:b.erl_average_limit_uncachable_test,requests_max_num_avg_test_cacheable:b.erl_average_limit_cachable_test,requests_max_num_oauth:b.erl_oauth_limit_live,requests_max_secs_burst:10,requests_max_secs_oauth:60,requests_max_secs_avg:60,page_max_size:25,page_default_size:10},application:{kinds:["integration","sales_channel","webapp","user"],login_scopes:["market","stock_location","store"]},imports:{max_size:1e4,statuses:V,types:Be,max_queue_length:10,attachment_expiration:5},exports:{max_size:1e4,statuses:V,types:De,max_queue_length:10,attachment_expiration:5},cleanups:{max_size:1e4,statuses:V,types:Me,max_queue_length:10},webhooks:{retry_number:5},cli:{applications:["integration","sales_channel","user"]},doc:{core:"https://docs.commercelayer.io/core/",core_api_reference:"https://docs.commercelayer.io/developers/v/api-reference",core_how_tos:"https://docs.commercelayer.io/core/v/how-tos/",core_raste_limits:"https://docs.commercelayer.io/core/rate-limits",core_filtering_data:"https://docs.commercelayer.io/core/filtering-data#list-of-predicates",metrics:"https://docs.commercelayer.io/metrics/",metrics_api_reference:"https://docs.commercelayer.io/metrics/v/api-reference-m/",provisioning:"https://docs.commercelayer.io/provisioning/",provisioning_api_reference:"https://docs.commercelayer.io/provisioning/v/api-reference-p/",imports_resources:"https://docs.commercelayer.io/api/importing-resources#supported-resources",exports_resources:"https://docs.commercelayer.io/core/exporting-resources#supported-resources",cleanups_resources:"https://docs.commercelayer.io/core/cleaning-resources#supported-resources",webhooks_events:"https://docs.commercelayer.io/api/real-time-webhooks#supported-events",tags_resources:"https://docs.commercelayer.io/core/v/api-reference/tags#taggable-resources",links_resources:"https://docs.commercelayer.io/core/v/api-reference/links"},tags:{max_resource_tags:10,taggable_resources:Le,tag_name_max_length:25,tag_name_pattern:/^[0-9A-Za-z_-]{1,25}$/},provisioning:{default_subdomain:"provisioning",scope:"provisioning-api",applications:["user"]},links:{default_domain:"c11r.link",linkable_resources:Ke}},m=Pe;var ue=require("fs");var F=async(e,t,r)=>await(await fetch(new URL(`/api/${e.resource}`+(r?`/${r}`:""),e.baseUrl),{method:e.operation,headers:{"Content-Type":"application/vnd.api+json",Accept:"application/vnd.api+json",Authorization:`Bearer ${e.accessToken}`},body:JSON.stringify(t)}).then(n=>{if(n.ok)return n;throw new Error(n.statusText)})).json(),N=e=>{let t,r;try{t=(0,ue.readFileSync)(e,"utf-8")}catch{throw new Error(`Unable to find or open the data file ${k.msg.error(e)}`)}try{r=JSON.parse(t)}catch{throw new Error(`Unable to parse the data file ${k.msg.error(e)}: invalid JSON format`)}return r.data?r:{data:r}},H=(r=>(r.Create="POST",r.Update="PATCH",r))(H||{});var me=(e,t)=>t.find(r=>e.id===r.id&&e.type===r.type),B=(e,t)=>{let r={id:e.id,type:e.type,...e.attributes};return e.relationships&&Object.keys(e.relationships).forEach(s=>{let n=e.relationships[s].data;n?Array.isArray(n)?r[s]=n.map(i=>B(me(i,t),t)):r[s]=B(me(n,t),t):n===null&&(r[s]=null)}),r},G=e=>{let t;e.links&&delete e.links;let r=e.data,s=e.included;return Array.isArray(r)?t=r.map(n=>B(n,s)):t=B(r,s),t};var je=(e="core",t,r)=>`https://${(e==="core"&&t||e).toLowerCase()}.${r||m.api.default_domain}`,Ue=e=>{if(e)return e.substring(e.indexOf(".")+1)},We=e=>e===!0||e==="live"?"live":"test",Ve=e=>e.replace(/_/g," ");var Fe=["bundles","imports","markets","prices","price_lists","promotions","buy_x_pay_y_promotions","external_promotions","fixed_amount_promotions","fixed_price_promotions","free_gift_promotions","free_shipping_promotions","percentage_discount_promotions","skus","sku_options","stock_items","stock_locations"],de=(e,t)=>Fe.includes(e||"")&&(t||"GET").toUpperCase()==="GET",Ne=e=>e==="live",ge=e=>{let t=e?.environment||"test",r=e?.parallelRequests||1,s=de(e?.resourceType,e?.method),n,i;t==="live"?(n=s?m.api.requests_max_num_burst_cacheable:m.api.requests_max_num_burst,i=s?m.api.requests_max_num_avg_cacheable:m.api.requests_max_num_avg):(n=s?m.api.requests_max_num_burst_test_cacheable:m.api.requests_max_num_burst_test,i=s?m.api.requests_max_num_avg_test_cacheable:m.api.requests_max_num_avg_test);let c=m.api.requests_max_secs_burst/n,u=m.api.requests_max_secs_avg/i,_=r*c,y=r*u,d=e?.totalRequests,a=0;return d&&d>0?d>n&&(d>i?a=y:a=_):a=Math.max(_,y),a=a*1e3,e?.minimumDelay&&(a=Math.max(e.minimumDelay,a)),e?.securityDelay&&(a+=e.securityDelay),a=Math.ceil(a),a};var He={raw:F,readDataFile:N,rateLimitDelay:ge},Ge={denormalize:G};var J={};f(J,{appKey:()=>Ye,appKeyMatch:()=>Xe,appKeyValid:()=>Je,arrayScope:()=>_e,isProvisioningApp:()=>Ze});var Ye=()=>Date.now().toString(36),Je=e=>e.key!==void 0&&e.key!=="",Xe=(e,t)=>{let r=e!==void 0,s=t!==void 0;return!r&&!s||r&&s&&e.key===t.key},_e=e=>{if(!e)return[];if(Array.isArray(e))return e;let t=e.replace(/[ ,;]/g,"_").split("_");return Array.isArray(t)?t:[t]},Ze=e=>_e(e.scope).includes(m.provisioning.scope)||e.api==="provisioning";var X={};f(X,{allFlags:()=>et,checkISODateTimeValue:()=>nt,commandFlags:()=>Qe,findLongStringFlag:()=>rt,fixDashedFlagValue:()=>st,fixValueType:()=>tt});var Qe=(e,t)=>{let r={...e};if(t)for(let s of t)delete r[s];return r},et=e=>({...e.flags,...e.baseFlags});var tt=e=>{let t=e;return t==="null"?t=null:Number(t)==t?t=Number(t):t=t==="true"?!0:t==="false"?!1:t,t},rt=(e,t)=>{let r=t.startsWith("--")?t:`--${t}`,s,n=e.findIndex(c=>c.startsWith(r)),i=!1;if(n>-1){let c=e[n];if(c.includes("=")){let u=c.split("=");s=u.length===2?u[1]:"",i=!0}else s=e[n+1];return{value:s,index:n,single:i}}else return},st=(e,t,r,s)=>{let n="____",i=t.name||r,c=t.char;if(!i&&!c)return e;let u=i?i.startsWith("--")?i:`--${i}`:void 0,_=c?t.char.startsWith("-")?c:`-${c}`:void 0,y=e.findIndex(w=>_&&w.startsWith(_)||u&&w.startsWith(u));if(y<0)return e;let d=e[y],a="",le="";if(_&&d.startsWith(_))a=d.replace(_,"").trim(),d=_;else if(u&&d.startsWith(u))a=d.replace(u,"").trim(),d=u;else return e;if(a.startsWith("=")?(a=a.slice(1),le=d+"="):a||(a=e[++y]),a.startsWith("-")||a.startsWith(n)){let w=a.startsWith(`${n}`)?a.replace(`${n}`,""):a.replace("-",`${n}-`);if(e[y]=le+w,a.startsWith(n)&&s){let z=i?i.replace("--",""):void 0,j=Object.entries(s.flags).find(([W,qe])=>qe===a);j&&(!z||z===j[0])&&(s.flags[j[0]]=w);let U=Object.values(s.raw).find(W=>W.type==="flag"&&W.input===a);U&&(!z||z===U.flag)&&(U.input=w)}}return e},nt=e=>{if(!e)throw Error("Date is empty");try{let t=Date.parse(e);if(Number.isNaN(t))throw new Error("Invalid date");return new Date(t)}catch{throw new Error("Error parsing date: "+e)}};var Z={};f(Z,{center:()=>it,cleanDate:()=>at,formatError:()=>lt,formatOutput:()=>xe,localeDate:()=>ct,maxLength:()=>ot,printCSV:()=>be,printJSON:()=>ye,printObject:()=>he});var fe=require("util"),he=(e,t)=>(0,fe.inspect)(e,{showHidden:!1,depth:null,colors:t?.color===void 0?!0:t.color,sorted:t?.sort===void 0?!1:t?.sort,maxArrayLength:1/0,breakLength:t?.width||120}),ye=(e,t)=>JSON.stringify(e,null,t?.unformatted?void 0:t?.tabSize||4),be=(e,t)=>{if(!e||e.length===0)return"";let r=Object.keys(e[0]).filter(n=>["id","type"].includes(n)?t?.fields.includes(n):!0),s=r.map(n=>n.toUpperCase().replace(/_/g," ")).join(";")+`
|
|
1
|
+
"use strict";var Re=Object.create;var I=Object.defineProperty;var Ee=Object.getOwnPropertyDescriptor;var Se=Object.getOwnPropertyNames;var ze=Object.getPrototypeOf,Ie=Object.prototype.hasOwnProperty;var f=(e,t)=>{for(var r in t)I(e,r,{get:t[r],enumerable:!0})},pe=(e,t,r,s)=>{if(t&&typeof t=="object"||typeof t=="function")for(let n of Se(t))!Ie.call(e,n)&&n!==r&&I(e,n,{get:()=>t[n],enumerable:!(s=Ee(t,n))||s.enumerable});return e};var B=(e,t,r)=>(r=e!=null?Re(ze(e)):{},pe(t||!e||!e.__esModule?I(r,"default",{value:e,enumerable:!0}):r,e)),Be=e=>pe(I({},"__esModule",{value:!0}),e);var rr={};f(rr,{clApi:()=>J,clApplication:()=>Y,clColor:()=>k,clCommand:()=>X,clConfig:()=>m,clFilter:()=>ce,clHelp:()=>S,clOutput:()=>Z,clSchema:()=>ae,clSymbol:()=>ne,clText:()=>ie,clToken:()=>te,clUpdate:()=>re,clUtil:()=>se});module.exports=Be(rr);var J={};f(J,{Operation:()=>H,baseURL:()=>je,execMode:()=>We,extractDomain:()=>Ue,humanizeResource:()=>Ve,isResourceCacheable:()=>de,liveEnvironment:()=>Ne,request:()=>He,requestDataFile:()=>N,requestRateLimitDelay:()=>ge,requestRaw:()=>F,response:()=>Ge,responseDenormalize:()=>G});var V=["in_progress","pending","completed","interrupted"],Oe=["addresses","bundles","coupons","customer_addresses","customer_payment_sources","customer_subscriptions","customers","gift_cards","line_items","line_item_options","orders","price_tiers","prices","shipping_categories","sku_lists","sku_list_items","sku_options","skus","stock_items","stock_transfers","tags","tax_categories"],De=["addresses","authorizations","bundles","captures","coupons","customer_addresses","customer_payment_sources","customer_subscriptions","customers","gift_cards","line_items","line_item_options","orders","payment_methods","price_tiers","prices","refunds","shipments","shipping_categories","shipping_methods","sku_lists","sku_list_items","sku_options","skus","stock_items","stock_transfers","tags","tax_categories","transactions","voids"],Me=["bundles","gift_cards","prices","promotions","sku_lists","sku_options","skus","stock_items"],Ke=["addresses","bundles","customers","coupons","gift_cards","line_items","line_item_options","orders","returns","skus","sku_options","promotions","external_promotions","fixed_amount_promotions","fixed_price_promotions","free_gift_promotions","free_shipping_promotions","percentage_discount_promotions"],Le=["orders","skus","sku_lists"],b={erl_oauth_limit_live:30,erl_average_limit_cachable_live:1e3,erl_average_limit_cachable_test:500,erl_burst_limit_cachable_live:250,erl_burst_limit_cachable_test:125,erl_average_limit_uncachable_live:200,erl_average_limit_uncachable_test:100,erl_burst_limit_uncachable_live:50,erl_burst_limit_uncachable_test:25},Pe={api:{default_domain:"commercelayer.io",default_app_domain:"commercelayer.app",default_stg_domain:"commercelayer.co",token_expiration_mins:60*4,token_encoding_algorithm:"HS512",token_owner_types:["Customer","User"],requests_max_num_burst:b.erl_burst_limit_uncachable_live,requests_max_num_burst_cacheable:b.erl_burst_limit_cachable_live,requests_max_num_burst_test:b.erl_burst_limit_uncachable_test,requests_max_num_burst_test_cacheable:b.erl_burst_limit_cachable_test,requests_max_num_avg:b.erl_average_limit_uncachable_live,requests_max_num_avg_cacheable:b.erl_average_limit_cachable_live,requests_max_num_avg_test:b.erl_average_limit_uncachable_test,requests_max_num_avg_test_cacheable:b.erl_average_limit_cachable_test,requests_max_num_oauth:b.erl_oauth_limit_live,requests_max_secs_burst:10,requests_max_secs_oauth:60,requests_max_secs_avg:60,page_max_size:25,page_default_size:10},application:{kinds:["integration","sales_channel","webapp","user"],login_scopes:["market","stock_location","store"]},imports:{max_size:1e4,statuses:V,types:Oe,max_queue_length:10,attachment_expiration:5},exports:{max_size:1e4,statuses:V,types:De,max_queue_length:10,attachment_expiration:5},cleanups:{max_size:1e4,statuses:V,types:Me,max_queue_length:10},webhooks:{retry_number:5},cli:{applications:["integration","sales_channel","user"]},doc:{core:"https://docs.commercelayer.io/core/",core_api_reference:"https://docs.commercelayer.io/developers/v/api-reference",core_how_tos:"https://docs.commercelayer.io/core/v/how-tos/",core_raste_limits:"https://docs.commercelayer.io/core/rate-limits",core_filtering_data:"https://docs.commercelayer.io/core/filtering-data#list-of-predicates",metrics:"https://docs.commercelayer.io/metrics/",metrics_api_reference:"https://docs.commercelayer.io/metrics/v/api-reference-m/",provisioning:"https://docs.commercelayer.io/provisioning/",provisioning_api_reference:"https://docs.commercelayer.io/provisioning/v/api-reference-p/",imports_resources:"https://docs.commercelayer.io/api/importing-resources#supported-resources",exports_resources:"https://docs.commercelayer.io/core/exporting-resources#supported-resources",cleanups_resources:"https://docs.commercelayer.io/core/cleaning-resources#supported-resources",webhooks_events:"https://docs.commercelayer.io/api/real-time-webhooks#supported-events",tags_resources:"https://docs.commercelayer.io/core/v/api-reference/tags#taggable-resources",links_resources:"https://docs.commercelayer.io/core/v/api-reference/links"},tags:{max_resource_tags:10,taggable_resources:Ke,tag_name_max_length:25,tag_name_pattern:/^[0-9A-Za-z_-]{1,25}$/},provisioning:{default_subdomain:"provisioning",scope:"provisioning-api",applications:["user"]},links:{default_domain:"c11r.link",linkable_resources:Le}},m=Pe;var ue=require("fs");var F=async(e,t,r)=>await(await fetch(new URL(`/api/${e.resource}`+(r?`/${r}`:""),e.baseUrl),{method:e.operation,headers:{"Content-Type":"application/vnd.api+json",Accept:"application/vnd.api+json",Authorization:`Bearer ${e.accessToken}`},body:JSON.stringify(t)}).then(n=>{if(n.ok)return n;throw new Error(n.statusText)})).json(),N=e=>{let t,r;try{t=(0,ue.readFileSync)(e,"utf-8")}catch{throw new Error(`Unable to find or open the data file ${k.msg.error(e)}`)}try{r=JSON.parse(t)}catch{throw new Error(`Unable to parse the data file ${k.msg.error(e)}: invalid JSON format`)}return r.data?r:{data:r}},H=(r=>(r.Create="POST",r.Update="PATCH",r))(H||{});var me=(e,t)=>t.find(r=>e.id===r.id&&e.type===r.type),O=(e,t)=>{let r={id:e.id,type:e.type,...e.attributes};return e.relationships&&Object.keys(e.relationships).forEach(s=>{let n=e.relationships[s].data;n?Array.isArray(n)?r[s]=n.map(i=>O(me(i,t),t)):r[s]=O(me(n,t),t):n===null&&(r[s]=null)}),r},G=e=>{let t;e.links&&delete e.links;let r=e.data,s=e.included;return Array.isArray(r)?t=r.map(n=>O(n,s)):t=O(r,s),t};var je=(e="core",t,r)=>`https://${(e==="core"&&t||e).toLowerCase()}.${r||m.api.default_domain}`,Ue=e=>{if(e)return e.substring(e.indexOf(".")+1)},We=e=>e===!0||e==="live"?"live":"test",Ve=e=>e.replace(/_/g," ");var Fe=["bundles","imports","markets","prices","price_lists","promotions","buy_x_pay_y_promotions","external_promotions","fixed_amount_promotions","fixed_price_promotions","free_gift_promotions","free_shipping_promotions","percentage_discount_promotions","skus","sku_options","stock_items","stock_locations"],de=(e,t)=>Fe.includes(e||"")&&(t||"GET").toUpperCase()==="GET",Ne=e=>e==="live",ge=e=>{let t=e?.environment||"test",r=e?.parallelRequests||1,s=de(e?.resourceType,e?.method),n,i;t==="live"?(n=s?m.api.requests_max_num_burst_cacheable:m.api.requests_max_num_burst,i=s?m.api.requests_max_num_avg_cacheable:m.api.requests_max_num_avg):(n=s?m.api.requests_max_num_burst_test_cacheable:m.api.requests_max_num_burst_test,i=s?m.api.requests_max_num_avg_test_cacheable:m.api.requests_max_num_avg_test);let c=m.api.requests_max_secs_burst/n,u=m.api.requests_max_secs_avg/i,_=r*c,y=r*u,d=e?.totalRequests,a=0;return d&&d>0?d>n&&(d>i?a=y:a=_):a=Math.max(_,y),a=a*1e3,e?.minimumDelay&&(a=Math.max(e.minimumDelay,a)),e?.securityDelay&&(a+=e.securityDelay),a=Math.ceil(a),a};var He={raw:F,readDataFile:N,rateLimitDelay:ge},Ge={denormalize:G};var Y={};f(Y,{appKey:()=>Je,appKeyMatch:()=>Xe,appKeyValid:()=>Ye,arrayScope:()=>_e,isProvisioningApp:()=>Ze});var Je=()=>Date.now().toString(36),Ye=e=>e.key!==void 0&&e.key!=="",Xe=(e,t)=>{let r=e!==void 0,s=t!==void 0;return!r&&!s||r&&s&&e.key===t.key},_e=e=>{if(!e)return[];if(Array.isArray(e))return e;let t=e.replace(/[ ,;]/g,"_").split("_");return Array.isArray(t)?t:[t]},Ze=e=>_e(e.scope).includes(m.provisioning.scope)||e.api==="provisioning";var X={};f(X,{allFlags:()=>et,checkISODateTimeValue:()=>nt,commandFlags:()=>Qe,findLongStringFlag:()=>rt,fixDashedFlagValue:()=>st,fixValueType:()=>tt});var Qe=(e,t)=>{let r={...e};if(t)for(let s of t)delete r[s];return r},et=e=>({...e.flags,...e.baseFlags});var tt=e=>{let t=e;return t==="null"?t=null:Number(t)==t?t=Number(t):t=t==="true"?!0:t==="false"?!1:t,t},rt=(e,t)=>{let r=t.startsWith("--")?t:`--${t}`,s,n=e.findIndex(c=>c.startsWith(r)),i=!1;if(n>-1){let c=e[n];if(c.includes("=")){let u=c.split("=");s=u.length===2?u[1]:"",i=!0}else s=e[n+1];return{value:s,index:n,single:i}}else return},st=(e,t,r,s)=>{let n="____",i=t.name||r,c=t.char;if(!i&&!c)return e;let u=i?i.startsWith("--")?i:`--${i}`:void 0,_=c?t.char.startsWith("-")?c:`-${c}`:void 0,y=e.findIndex(T=>_&&T.startsWith(_)||u&&T.startsWith(u));if(y<0)return e;let d=e[y],a="",le="";if(_&&d.startsWith(_))a=d.replace(_,"").trim(),d=_;else if(u&&d.startsWith(u))a=d.replace(u,"").trim(),d=u;else return e;if(a.startsWith("=")?(a=a.slice(1),le=d+"="):a||(a=e[++y]),a.startsWith("-")||a.startsWith(n)){let T=a.startsWith(`${n}`)?a.replace(`${n}`,""):a.replace("-",`${n}-`);if(e[y]=le+T,a.startsWith(n)&&s){let z=i?i.replace("--",""):void 0,j=Object.entries(s.flags).find(([W,qe])=>qe===a);j&&(!z||z===j[0])&&(s.flags[j[0]]=T);let U=Object.values(s.raw).find(W=>W.type==="flag"&&W.input===a);U&&(!z||z===U.flag)&&(U.input=T)}}return e},nt=e=>{if(!e)throw Error("Date is empty");try{let t=Date.parse(e);if(Number.isNaN(t))throw new Error("Invalid date");return new Date(t)}catch{throw new Error("Error parsing date: "+e)}};var Z={};f(Z,{center:()=>it,cleanDate:()=>at,formatError:()=>lt,formatOutput:()=>xe,localeDate:()=>ct,maxLength:()=>ot,printCSV:()=>be,printJSON:()=>ye,printObject:()=>he});var fe=require("util"),he=(e,t)=>(0,fe.inspect)(e,{showHidden:!1,depth:null,colors:t?.color===void 0?!0:t.color,sorted:t?.sort===void 0?!1:t?.sort,maxArrayLength:1/0,breakLength:t?.width||120}),ye=(e,t)=>JSON.stringify(e,null,t?.unformatted?void 0:t?.tabSize||4),be=(e,t)=>{if(!e||e.length===0)return"";let r=Object.keys(e[0]).filter(n=>["id","type"].includes(n)?t?.fields.includes(n):!0),s=r.map(n=>n.toUpperCase().replace(/_/g," ")).join(";")+`
|
|
2
2
|
`;return e.forEach(n=>{s+=r.map(i=>n[i]).join(";")+`
|
|
3
|
-
`}),s},it=(e,t)=>e.padStart(e.length+Math.floor((t-e.length)/2)," ").padEnd(t," "),ot=(e,t)=>e.reduce((r,s)=>{let n=Array.isArray(s[t])?s[t].join():s[t];return Math.max(r,String(n).length)},0),at=e=>e?e.replace("T"," ").replace("Z","").substring(0,e.lastIndexOf(".")):"",ct=e=>e?new Date(Date.parse(e)).toLocaleString():"",xe=(e,t,{color:r=!0}={})=>{if(!e)return"";if(typeof e=="string")return e;if(t){if(t.csv)return be(e,t);if(t.json)return ye(e,{unformatted:t.unformatted})}return he(e,{color:r})},lt=(e,t)=>xe(e.errors||e,t);var k={};f(k,{api:()=>Rt,bg:()=>Ct,black:()=>bt,blackBright:()=>xt,blue:()=>ft,blueBright:()=>C,bold:()=>ee,cli:()=>St,cyan:()=>
|
|
3
|
+
`}),s},it=(e,t)=>e.padStart(e.length+Math.floor((t-e.length)/2)," ").padEnd(t," "),ot=(e,t)=>e.reduce((r,s)=>{let n=Array.isArray(s[t])?s[t].join():s[t];return Math.max(r,String(n).length)},0),at=e=>e?e.replace("T"," ").replace("Z","").substring(0,e.lastIndexOf(".")):"",ct=e=>e?new Date(Date.parse(e)).toLocaleString():"",xe=(e,t,{color:r=!0}={})=>{if(!e)return"";if(typeof e=="string")return e;if(t){if(t.csv)return be(e,t);if(t.json)return ye(e,{unformatted:t.unformatted})}return he(e,{color:r})},lt=(e,t)=>xe(e.errors||e,t);var k={};f(k,{api:()=>Rt,bg:()=>Ct,black:()=>bt,blackBright:()=>xt,blue:()=>ft,blueBright:()=>C,bold:()=>ee,cli:()=>St,cyan:()=>wt,cyanBright:()=>$,dim:()=>At,green:()=>gt,greenBright:()=>Q,grey:()=>vt,hidden:()=>mt,italic:()=>w,magenta:()=>Tt,magentaBright:()=>kt,msg:()=>Et,red:()=>dt,redBright:()=>ve,reset:()=>pt,style:()=>l,table:()=>zt,type:()=>qt,underline:()=>$t,visible:()=>ut,white:()=>ht,whiteBright:()=>yt,yellow:()=>_t,yellowBright:()=>v});var o=B(require("chalk")),pt=o.default.reset,ut=o.default.visible,mt=o.default.hidden,dt=o.default.red,ve=o.default.redBright,gt=o.default.green,Q=o.default.greenBright,_t=o.default.yellow,v=o.default.yellowBright,ft=o.default.blue,C=o.default.blueBright,ht=o.default.white,yt=o.default.whiteBright,bt=o.default.black,xt=o.default.blackBright,vt=o.default.grey,wt=o.default.cyan,$=o.default.cyanBright,Tt=o.default.magenta,kt=o.default.magentaBright,ee=o.default.bold,At=o.default.dim,$t=o.default.underline,w=o.default.italic,Ct={white:o.default.bgWhite,whiteBright:o.default.bgWhiteBright,black:o.default.bgBlack,blackBright:o.default.bgBlackBright,grey:o.default.bgGrey,red:o.default.bgRed,redBright:o.default.bgRedBright,green:o.default.bgGreen,greenBright:o.default.bgGreenBright,yellow:o.default.bgYellow,yellowBright:o.default.bgYellowBright,blue:o.default.bgBlue,blueBright:o.default.bgBlueBright,magenta:o.default.bgMagenta,magentaBright:o.default.bgMagentaBright,cyan:o.default.bgCyan,cyanBright:o.default.bgCyanBright},l={organization:v.bold,application:v.bold,slug:v,id:ee,token:C,resource:ee,attribute:w,trigger:$,kind:$,live:Q,test:v,execMode:e=>e==="live"?l.live:l.test,success:Q,warning:v,error:ve,arg:w,flag:w,command:w,value:w,alias:$,plugin:C,title:C,path:w,datetime:$,number:v},qt={datetime:l.datetime,number:l.number,path:l.path},Rt={organization:l.organization,application:l.application,slug:l.slug,id:l.id,token:l.token,resource:l.resource,attribute:l.attribute,trigger:l.trigger,kind:l.kind,live:l.live,test:l.test},Et={success:l.success,warning:l.warning,error:l.error},St={arg:l.arg,flag:l.flag,command:l.command,value:l.value,alias:l.alias,plugin:l.plugin},zt={header:v.bold,key:C};var te={};f(te,{buildAssertionPayload:()=>Kt,decodeAccessToken:()=>we,generateAccessToken:()=>It,getAccessToken:()=>Bt,getTokenEnvironment:()=>Mt,isAccessTokenExpiring:()=>Dt,revokeAccessToken:()=>Ot});var D=B(require("jsonwebtoken"));var A=require("@commercelayer/js-auth"),we=e=>{let t=D.default.decode(e);if(t===null)throw new Error("Error decoding access token");return t},It=(e,t,r)=>{let n={...e,exp:Math.floor(Date.now()/1e3)+r*60,rand:Math.random()},i=m.api.token_encoding_algorithm,c=D.default.sign(n,t,{algorithm:i,noTimestamp:!0}),u=D.default.verify(c,t,{algorithms:[i]});return{accessToken:c,info:u,expMinutes:r}},Bt=async e=>{let t,r=e.scope?Array.isArray(e.scope)?e.scope.map(n=>n.trim()).join(","):e.scope:"",s={clientId:e.clientId,clientSecret:e.clientSecret,slug:e.slug,domain:e.domain,scope:r};if(e.email&&e.password?(s.username=e.email,s.password=e.password,t=await(0,A.authenticate)("password",s)):e.assertion?(s.assertion=e.assertion,t=await(0,A.authenticate)("urn:ietf:params:oauth:grant-type:jwt-bearer",s)):t=await(0,A.authenticate)("client_credentials",s),t){if(t.errors)throw new Error(`Unable to get access token: ${t.errors[0].detail}`)}else throw new Error("Unable to get access token");return t},Ot=async(e,t)=>{let r=await(0,A.revoke)({...e,token:t});if(r.errors)throw new Error(r.errors[0].detail)},Dt=e=>{let r=Math.floor(Date.now()/1e3),s=Math.floor(new Date(e.expires).getTime()/1e3);return r>=s-30},Mt=e=>(typeof e=="string"?we(e):e).test?"test":"live";var Kt=(e,t,r)=>{let s="https://commercelayer.io/claims",n={[s]:{owner:{type:e,id:t}}};if(r&&Object.keys(r).length>0){let i={};Object.entries(r).forEach(([c,u])=>{let _=c.split("."),y=_[_.length-1],d=i;_.forEach(a=>{a===y?d[a]=u:d=d[a]||(d[a]={})})}),n[s].custom_claim=i}return n};var re={};f(re,{checkUpdate:()=>Pt});var q=B(require("chalk")),Te=B(require("update-notifier-cjs")),Lt=1,Pt=e=>{let t=(0,Te.default)({pkg:e,updateCheckInterval:36e5*Lt});t.update&&t.notify({isGlobal:!1,message:`-= ${q.default.bgWhite.black.bold(` ${e.description} `)} =-
|
|
4
4
|
|
|
5
5
|
New version available: ${q.default.dim("{currentVersion}")} -> ${q.default.green("{latestVersion}")}
|
|
6
|
-
Run ${q.default.cyanBright("commercelayer plugins:update")} to update`})};var se={};f(se,{generateGroupUID:()=>Ft,log:()=>Wt,resetConsole:()=>Ut,sleep:()=>jt,specialFolder:()=>Vt,userAgent:()=>Nt});var M=require("util"),
|
|
7
|
-
`)},Vt=(e,t=!1)=>{let r=["desktop","home"],s=e.toLowerCase().split(/[\\\/]/g)[0];if(r.includes(s)){let i=(0,ke.homedir)();s==="desktop"&&(i+=`${
|
|
6
|
+
Run ${q.default.cyanBright("commercelayer plugins:update")} to update`})};var se={};f(se,{generateGroupUID:()=>Ft,log:()=>Wt,resetConsole:()=>Ut,sleep:()=>jt,specialFolder:()=>Vt,userAgent:()=>Nt});var M=require("util"),K=require("path"),ke=require("os"),L=require("fs"),jt=async e=>new Promise(t=>setTimeout(t,e)),Ut=()=>{process.stdout.write("\x1B[?25h\x1B[?7h")},Wt=(e="",...t)=>{e=typeof e=="string"?e:(0,M.inspect)(e),process.stdout.write((0,M.format)(e,...t)+`
|
|
7
|
+
`)},Vt=(e,t=!1)=>{let r=["desktop","home"],s=e.toLowerCase().split(/[\\\/]/g)[0];if(r.includes(s)){let i=(0,ke.homedir)();s==="desktop"&&(i+=`${K.sep}Desktop`),e=e.replace(s,i)}let n=(0,K.dirname)(e);return t&&!(0,L.existsSync)(n)&&(0,L.mkdirSync)(n,{recursive:!0}),e},Ft=()=>{let e=Math.trunc(Math.random()*46656),t=Math.trunc(Math.random()*46656),r=("000"+e.toString(36)).slice(-3),s=("000"+t.toString(36)).slice(-3);return r+s},Nt=e=>`${e.name.replace(/@commercelayer\/cli-plugin/,"CLI")}/${e.version}`;var P=require("@oclif/core");var ie={};f(ie,{camelize:()=>Xt,capitalize:()=>E,dasherize:()=>Ht,pluralize:()=>Jt,singularize:()=>Yt,symbols:()=>x,underscorize:()=>Gt});var p={uncountableWords:["equipment","information","rice","money","species","series","fish","sheep","moose","deer","news"],pluralRules:[[/(m)an$/gi,"$1en"],[/(pe)rson$/gi,"$1ople"],[/(child)$/gi,"$1ren"],[/^(ox)$/gi,"$1en"],[/(ax|test)is$/gi,"$1es"],[/(octop|vir)us$/gi,"$1i"],[/(alias|status)$/gi,"$1es"],[/(bu)s$/gi,"$1ses"],[/(buffal|tomat|potat)o$/gi,"$1oes"],[/([ti])um$/gi,"$1a"],[/sis$/gi,"ses"],[/(?:([^f])fe|([lr])f)$/gi,"$1$2ves"],[/(hive)$/gi,"$1s"],[/([^aeiouy]|qu)y$/gi,"$1ies"],[/(x|ch|ss|sh)$/gi,"$1es"],[/(matr|vert|ind)ix|ex$/gi,"$1ices"],[/([m|l])ouse$/gi,"$1ice"],[/(quiz)$/gi,"$1zes"],[/s$/gi,"s"],[/$/gi,"s"]],singularRules:[[/(m)en$/gi,"$1an"],[/(pe)ople$/gi,"$1rson"],[/(child)ren$/gi,"$1"],[/([ti])a$/gi,"$1um"],[/((a)naly|(b)a|(d)iagno|(p)arenthe|(p)rogno|(s)ynop|(t)he)ses$/gi,"$1$2sis"],[/(hive)s$/gi,"$1"],[/(tive)s$/gi,"$1"],[/(curve)s$/gi,"$1"],[/([lr])ves$/gi,"$1f"],[/([^fo])ves$/gi,"$1fe"],[/([^aeiouy]|qu)ies$/gi,"$1y"],[/(s)eries$/gi,"$1eries"],[/(m)ovies$/gi,"$1ovie"],[/(x|ch|ss|sh)es$/gi,"$1"],[/([m|l])ice$/gi,"$1ouse"],[/(bus)es$/gi,"$1"],[/(o)es$/gi,"$1"],[/(shoe)s$/gi,"$1"],[/(cris|ax|test)es$/gi,"$1is"],[/(octop|vir)i$/gi,"$1us"],[/(alias|status)es$/gi,"$1"],[/^(ox)en/gi,"$1"],[/(vert|ind)ices$/gi,"$1ex"],[/(matr)ices$/gi,"$1ix"],[/(quiz)zes$/gi,"$1"],[/s$/gi,""]],nonTitlecasedWords:["and","or","nor","a","an","the","so","but","to","of","at","by","from","into","on","onto","off","out","in","over","with","for"],idSuffix:/(_ids|_id)$/g,underbar:/_/g,spaceOrUnderbar:/[ _]/g,uppercase:/([A-Z])/g,underbarPrefix:/^_/,applyRules:function(e,t,r,s){if(s)e=s;else if(!r.includes(e.toLowerCase())){for(let i=0;i<t.length;i++)if(e.match(t[i][0])){e=e.replace(t[i][0],t[i][1]);break}}return e},pluralize:function(e,t){return p.applyRules(e,p.pluralRules,p.uncountableWords,t)},singularize:function(e,t){return p.applyRules(e,p.singularRules,p.uncountableWords,t)},camelize:function(e,t){let r=e.split("/");for(let s=0;s<r.length;s++){let n=r[s].split("_"),i=t&&s+1===r.length?1:0;for(let c=i;c<n.length;c++)n[c]=n[c].charAt(0).toUpperCase()+n[c].substring(1);r[s]=n.join("")}if(e=r.join("::"),t){let s=e.charAt(0).toLowerCase(),n=e.slice(1);e=s+n}return e},underscore:function(e){let t=e.split("::");for(let r=0;r<t.length;r++)t[r]=t[r].replace(p.uppercase,"_$1"),t[r]=t[r].replace(p.underbarPrefix,"");return e=t.join("/").toLowerCase(),e},humanize:function(e,t){return e=e.toLowerCase(),e=e.replace(p.idSuffix,""),e=e.replace(p.underbar," "),t||(e=p.capitalize(e)),e},capitalize:function(e){return e=e.toLowerCase(),e=e.substring(0,1).toUpperCase()+e.substring(1),e},dasherize:function(e){return e=e.replace(p.spaceOrUnderbar,"-"),e},camel2words:function(e,t){t?(e=p.camelize(e),e=p.underscore(e)):e=e.toLowerCase(),e=e.replace(p.underbar," ");let r=e.split(" ");for(let s=0;s<r.length;s++){let n=r[s].split("-");for(let i=0;i<n.length;i++)p.nonTitlecasedWords.includes(n[i].toLowerCase())||(n[i]=p.capitalize(n[i]));r[s]=n.join("-")}return e=r.join(" "),e=e.substring(0,1).toUpperCase()+e.substring(1),e},demodulize:function(e){let t=e.split("::");return e=t[t.length-1],e},tableize:function(e){return e=p.pluralize(p.underscore(e)),e},classify:function(e){return e=p.singularize(p.camelize(e)),e},foreignKey:function(e,t){return e=p.underscore(p.demodulize(e))+(t?"":"_")+"id",e},ordinalize:function(e){let t=e.split(" ");for(let r=0;r<t.length;r++){let s=parseInt(t[r]);if(Number.isNaN(s)){let n=t[r].substring(t[r].length-2),i=t[r].substring(t[r].length-1),c="th";n!=="11"&&n!=="12"&&n!=="13"&&(i==="1"?c="st":i==="2"?c="nd":i==="3"&&(c="rd")),t[r]+=c}}return e=t.join(" "),e}},R=p;var ne={};f(ne,{symbols:()=>x});var x={check:{small:"\u2714",bkgGreen:"\u2705",squareRoot:"\u221A"},cross:{small:"\u2718",red:"\u274C"},clock:{stopwatch:"\u23F1"},arrow:{down:"\u2193"},selection:{fisheye:"\u25C9"}};x.check.heavy=x.check.small;x.check.whiteHeavy=x.check.bkgGreen;x.cross.heavyBallot=x.cross.small;var E=e=>e&&R.capitalize(e),Ht=e=>e&&(e=e.toLocaleLowerCase(),e.replace(/[ _]/g,"-")),Gt=e=>e&&(e=e.toLocaleLowerCase(),e.replace(/[ -]/g,"_")),Jt=(e,t)=>R.pluralize(e,t),Yt=(e,t)=>R.singularize(e,t),Xt=(e,t)=>R.camelize(e,t);var h=!1,oe=class extends P.CommandHelp{examples(t){return h&&console.log("---------- command.examples"),super.examples(t)}},S=class extends P.Help{async showHelp(t){return h&&console.log("---------- showHelp"),super.showHelp(t)}async showRootHelp(){return h&&console.log("---------- showRootHelp"),super.showRootHelp()}async showTopicHelp(t){return h&&console.log("---------- showTopicHelp"),super.showTopicHelp(t)}async showCommandHelp(t){h&&console.log("---------- showCommandHelp");let r=t.id,s=r?r.split(":").length:1,n=this.sortedTopics.filter(u=>u.name.startsWith(r+":")&&u.name.split(":").length===s+1),i=this.sortedCommands.filter(u=>u.id.startsWith(r+":")&&u.id.split(":").length===s+1),c=t.description&&this.render(t.description).split(`
|
|
8
8
|
`)[0];c&&console.log(`${E(c)}
|
|
9
9
|
`),console.log(this.formatCommand(t)),console.log(""),n.length>0&&(console.log(this.formatTopics(n)),console.log("")),i.length>0&&(console.log(this.formatCommands(i)),console.log(""))}formatRoot(){return h&&console.log("---------- formatRoot"),super.formatRoot()}formatTopic(t){return h&&console.log("---------- formatTopic"),super.formatTopic(t)}formatTopics(t){h&&console.log("---------- formatTopics");let r=t.filter(s=>!s.hidden).map(s=>(s.description=E(s.description),s));return super.formatTopics(r)}formatCommands(t){return h&&console.log("---------- formatCommands"),super.formatCommands(t).split(`
|
|
10
10
|
`).map(r=>{let s=0;return r.split(" ").map(n=>(n||"").trim()!==""&&++s===2?E(n):n).join(" ")}).join(`
|
package/lib/index.mjs
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
var be=Object.defineProperty;var h=(e,t)=>{for(var r in t)be(e,r,{get:t[r],enumerable:!0})};var X={};h(X,{Operation:()=>P,baseURL:()=>Ce,execMode:()=>Re,extractDomain:()=>qe,humanizeResource:()=>Ee,isResourceCacheable:()=>
|
|
1
|
+
var be=Object.defineProperty;var h=(e,t)=>{for(var r in t)be(e,r,{get:t[r],enumerable:!0})};var X={};h(X,{Operation:()=>P,baseURL:()=>Ce,execMode:()=>Re,extractDomain:()=>qe,humanizeResource:()=>Ee,isResourceCacheable:()=>J,liveEnvironment:()=>ze,request:()=>Ie,requestDataFile:()=>L,requestRateLimitDelay:()=>Y,requestRaw:()=>K,response:()=>Be,responseDenormalize:()=>j});var M=["in_progress","pending","completed","interrupted"],xe=["addresses","bundles","coupons","customer_addresses","customer_payment_sources","customer_subscriptions","customers","gift_cards","line_items","line_item_options","orders","price_tiers","prices","shipping_categories","sku_lists","sku_list_items","sku_options","skus","stock_items","stock_transfers","tags","tax_categories"],ve=["addresses","authorizations","bundles","captures","coupons","customer_addresses","customer_payment_sources","customer_subscriptions","customers","gift_cards","line_items","line_item_options","orders","payment_methods","price_tiers","prices","refunds","shipments","shipping_categories","shipping_methods","sku_lists","sku_list_items","sku_options","skus","stock_items","stock_transfers","tags","tax_categories","transactions","voids"],we=["bundles","gift_cards","prices","promotions","sku_lists","sku_options","skus","stock_items"],Te=["addresses","bundles","customers","coupons","gift_cards","line_items","line_item_options","orders","returns","skus","sku_options","promotions","external_promotions","fixed_amount_promotions","fixed_price_promotions","free_gift_promotions","free_shipping_promotions","percentage_discount_promotions"],ke=["orders","skus","sku_lists"],x={erl_oauth_limit_live:30,erl_average_limit_cachable_live:1e3,erl_average_limit_cachable_test:500,erl_burst_limit_cachable_live:250,erl_burst_limit_cachable_test:125,erl_average_limit_uncachable_live:200,erl_average_limit_uncachable_test:100,erl_burst_limit_uncachable_live:50,erl_burst_limit_uncachable_test:25},Ae={api:{default_domain:"commercelayer.io",default_app_domain:"commercelayer.app",default_stg_domain:"commercelayer.co",token_expiration_mins:60*4,token_encoding_algorithm:"HS512",token_owner_types:["Customer","User"],requests_max_num_burst:x.erl_burst_limit_uncachable_live,requests_max_num_burst_cacheable:x.erl_burst_limit_cachable_live,requests_max_num_burst_test:x.erl_burst_limit_uncachable_test,requests_max_num_burst_test_cacheable:x.erl_burst_limit_cachable_test,requests_max_num_avg:x.erl_average_limit_uncachable_live,requests_max_num_avg_cacheable:x.erl_average_limit_cachable_live,requests_max_num_avg_test:x.erl_average_limit_uncachable_test,requests_max_num_avg_test_cacheable:x.erl_average_limit_cachable_test,requests_max_num_oauth:x.erl_oauth_limit_live,requests_max_secs_burst:10,requests_max_secs_oauth:60,requests_max_secs_avg:60,page_max_size:25,page_default_size:10},application:{kinds:["integration","sales_channel","webapp","user"],login_scopes:["market","stock_location","store"]},imports:{max_size:1e4,statuses:M,types:xe,max_queue_length:10,attachment_expiration:5},exports:{max_size:1e4,statuses:M,types:ve,max_queue_length:10,attachment_expiration:5},cleanups:{max_size:1e4,statuses:M,types:we,max_queue_length:10},webhooks:{retry_number:5},cli:{applications:["integration","sales_channel","user"]},doc:{core:"https://docs.commercelayer.io/core/",core_api_reference:"https://docs.commercelayer.io/developers/v/api-reference",core_how_tos:"https://docs.commercelayer.io/core/v/how-tos/",core_raste_limits:"https://docs.commercelayer.io/core/rate-limits",core_filtering_data:"https://docs.commercelayer.io/core/filtering-data#list-of-predicates",metrics:"https://docs.commercelayer.io/metrics/",metrics_api_reference:"https://docs.commercelayer.io/metrics/v/api-reference-m/",provisioning:"https://docs.commercelayer.io/provisioning/",provisioning_api_reference:"https://docs.commercelayer.io/provisioning/v/api-reference-p/",imports_resources:"https://docs.commercelayer.io/api/importing-resources#supported-resources",exports_resources:"https://docs.commercelayer.io/core/exporting-resources#supported-resources",cleanups_resources:"https://docs.commercelayer.io/core/cleaning-resources#supported-resources",webhooks_events:"https://docs.commercelayer.io/api/real-time-webhooks#supported-events",tags_resources:"https://docs.commercelayer.io/core/v/api-reference/tags#taggable-resources",links_resources:"https://docs.commercelayer.io/core/v/api-reference/links"},tags:{max_resource_tags:10,taggable_resources:Te,tag_name_max_length:25,tag_name_pattern:/^[0-9A-Za-z_-]{1,25}$/},provisioning:{default_subdomain:"provisioning",scope:"provisioning-api",applications:["user"]},links:{default_domain:"c11r.link",linkable_resources:ke}},m=Ae;import{readFileSync as $e}from"fs";var K=async(e,t,r)=>await(await fetch(new URL(`/api/${e.resource}`+(r?`/${r}`:""),e.baseUrl),{method:e.operation,headers:{"Content-Type":"application/vnd.api+json",Accept:"application/vnd.api+json",Authorization:`Bearer ${e.accessToken}`},body:JSON.stringify(t)}).then(n=>{if(n.ok)return n;throw new Error(n.statusText)})).json(),L=e=>{let t,r;try{t=$e(e,"utf-8")}catch{throw new Error(`Unable to find or open the data file ${A.msg.error(e)}`)}try{r=JSON.parse(t)}catch{throw new Error(`Unable to parse the data file ${A.msg.error(e)}: invalid JSON format`)}return r.data?r:{data:r}},P=(r=>(r.Create="POST",r.Update="PATCH",r))(P||{});var G=(e,t)=>t.find(r=>e.id===r.id&&e.type===r.type),S=(e,t)=>{let r={id:e.id,type:e.type,...e.attributes};return e.relationships&&Object.keys(e.relationships).forEach(s=>{let n=e.relationships[s].data;n?Array.isArray(n)?r[s]=n.map(i=>S(G(i,t),t)):r[s]=S(G(n,t),t):n===null&&(r[s]=null)}),r},j=e=>{let t;e.links&&delete e.links;let r=e.data,s=e.included;return Array.isArray(r)?t=r.map(n=>S(n,s)):t=S(r,s),t};var Ce=(e="core",t,r)=>`https://${(e==="core"&&t||e).toLowerCase()}.${r||m.api.default_domain}`,qe=e=>{if(e)return e.substring(e.indexOf(".")+1)},Re=e=>e===!0||e==="live"?"live":"test",Ee=e=>e.replace(/_/g," ");var Se=["bundles","imports","markets","prices","price_lists","promotions","buy_x_pay_y_promotions","external_promotions","fixed_amount_promotions","fixed_price_promotions","free_gift_promotions","free_shipping_promotions","percentage_discount_promotions","skus","sku_options","stock_items","stock_locations"],J=(e,t)=>Se.includes(e||"")&&(t||"GET").toUpperCase()==="GET",ze=e=>e==="live",Y=e=>{let t=e?.environment||"test",r=e?.parallelRequests||1,s=J(e?.resourceType,e?.method),n,i;t==="live"?(n=s?m.api.requests_max_num_burst_cacheable:m.api.requests_max_num_burst,i=s?m.api.requests_max_num_avg_cacheable:m.api.requests_max_num_avg):(n=s?m.api.requests_max_num_burst_test_cacheable:m.api.requests_max_num_burst_test,i=s?m.api.requests_max_num_avg_test_cacheable:m.api.requests_max_num_avg_test);let c=m.api.requests_max_secs_burst/n,u=m.api.requests_max_secs_avg/i,f=r*c,b=r*u,d=e?.totalRequests,a=0;return d&&d>0?d>n&&(d>i?a=b:a=f):a=Math.max(f,b),a=a*1e3,e?.minimumDelay&&(a=Math.max(e.minimumDelay,a)),e?.securityDelay&&(a+=e.securityDelay),a=Math.ceil(a),a};var Ie={raw:K,readDataFile:L,rateLimitDelay:Y},Be={denormalize:j};var Q={};h(Q,{appKey:()=>Oe,appKeyMatch:()=>Me,appKeyValid:()=>De,arrayScope:()=>Z,isProvisioningApp:()=>Ke});var Oe=()=>Date.now().toString(36),De=e=>e.key!==void 0&&e.key!=="",Me=(e,t)=>{let r=e!==void 0,s=t!==void 0;return!r&&!s||r&&s&&e.key===t.key},Z=e=>{if(!e)return[];if(Array.isArray(e))return e;let t=e.replace(/[ ,;]/g,"_").split("_");return Array.isArray(t)?t:[t]},Ke=e=>Z(e.scope).includes(m.provisioning.scope)||e.api==="provisioning";var ee={};h(ee,{allFlags:()=>Pe,checkISODateTimeValue:()=>Ve,commandFlags:()=>Le,findLongStringFlag:()=>Ue,fixDashedFlagValue:()=>We,fixValueType:()=>je});var Le=(e,t)=>{let r={...e};if(t)for(let s of t)delete r[s];return r},Pe=e=>({...e.flags,...e.baseFlags});var je=e=>{let t=e;return t==="null"?t=null:Number(t)==t?t=Number(t):t=t==="true"?!0:t==="false"?!1:t,t},Ue=(e,t)=>{let r=t.startsWith("--")?t:`--${t}`,s,n=e.findIndex(c=>c.startsWith(r)),i=!1;if(n>-1){let c=e[n];if(c.includes("=")){let u=c.split("=");s=u.length===2?u[1]:"",i=!0}else s=e[n+1];return{value:s,index:n,single:i}}else return},We=(e,t,r,s)=>{let n="____",i=t.name||r,c=t.char;if(!i&&!c)return e;let u=i?i.startsWith("--")?i:`--${i}`:void 0,f=c?t.char.startsWith("-")?c:`-${c}`:void 0,b=e.findIndex(k=>f&&k.startsWith(f)||u&&k.startsWith(u));if(b<0)return e;let d=e[b],a="",H="";if(f&&d.startsWith(f))a=d.replace(f,"").trim(),d=f;else if(u&&d.startsWith(u))a=d.replace(u,"").trim(),d=u;else return e;if(a.startsWith("=")?(a=a.slice(1),H=d+"="):a||(a=e[++b]),a.startsWith("-")||a.startsWith(n)){let k=a.startsWith(`${n}`)?a.replace(`${n}`,""):a.replace("-",`${n}-`);if(e[b]=H+k,a.startsWith(n)&&s){let E=i?i.replace("--",""):void 0,B=Object.entries(s.flags).find(([D,ye])=>ye===a);B&&(!E||E===B[0])&&(s.flags[B[0]]=k);let O=Object.values(s.raw).find(D=>D.type==="flag"&&D.input===a);O&&(!E||E===O.flag)&&(O.input=k)}}return e},Ve=e=>{if(!e)throw Error("Date is empty");try{let t=Date.parse(e);if(Number.isNaN(t))throw new Error("Invalid date");return new Date(t)}catch{throw new Error("Error parsing date: "+e)}};var ie={};h(ie,{center:()=>Ne,cleanDate:()=>Ge,formatError:()=>Ye,formatOutput:()=>ne,localeDate:()=>Je,maxLength:()=>He,printCSV:()=>se,printJSON:()=>re,printObject:()=>te});import{inspect as Fe}from"node:util";var te=(e,t)=>Fe(e,{showHidden:!1,depth:null,colors:t?.color===void 0?!0:t.color,sorted:t?.sort===void 0?!1:t?.sort,maxArrayLength:1/0,breakLength:t?.width||120}),re=(e,t)=>JSON.stringify(e,null,t?.unformatted?void 0:t?.tabSize||4),se=(e,t)=>{if(!e||e.length===0)return"";let r=Object.keys(e[0]).filter(n=>["id","type"].includes(n)?t?.fields.includes(n):!0),s=r.map(n=>n.toUpperCase().replace(/_/g," ")).join(";")+`
|
|
2
2
|
`;return e.forEach(n=>{s+=r.map(i=>n[i]).join(";")+`
|
|
3
|
-
`}),s},Ne=(e,t)=>e.padStart(e.length+Math.floor((t-e.length)/2)," ").padEnd(t," "),He=(e,t)=>e.reduce((r,s)=>{let n=Array.isArray(s[t])?s[t].join():s[t];return Math.max(r,String(n).length)},0),Ge=e=>e?e.replace("T"," ").replace("Z","").substring(0,e.lastIndexOf(".")):"",
|
|
3
|
+
`}),s},Ne=(e,t)=>e.padStart(e.length+Math.floor((t-e.length)/2)," ").padEnd(t," "),He=(e,t)=>e.reduce((r,s)=>{let n=Array.isArray(s[t])?s[t].join():s[t];return Math.max(r,String(n).length)},0),Ge=e=>e?e.replace("T"," ").replace("Z","").substring(0,e.lastIndexOf(".")):"",Je=e=>e?new Date(Date.parse(e)).toLocaleString():"",ne=(e,t,{color:r=!0}={})=>{if(!e)return"";if(typeof e=="string")return e;if(t){if(t.csv)return se(e,t);if(t.json)return re(e,{unformatted:t.unformatted})}return te(e,{color:r})},Ye=(e,t)=>ne(e.errors||e,t);var A={};h(A,{api:()=>ft,bg:()=>gt,black:()=>ot,blackBright:()=>at,blue:()=>st,blueBright:()=>C,bold:()=>W,cli:()=>yt,cyan:()=>lt,cyanBright:()=>$,dim:()=>mt,green:()=>tt,greenBright:()=>U,grey:()=>ct,hidden:()=>Qe,italic:()=>T,magenta:()=>pt,magentaBright:()=>ut,msg:()=>ht,red:()=>et,redBright:()=>oe,reset:()=>Xe,style:()=>l,table:()=>bt,type:()=>_t,underline:()=>dt,visible:()=>Ze,white:()=>nt,whiteBright:()=>it,yellow:()=>rt,yellowBright:()=>w});import o from"chalk";var Xe=o.reset,Ze=o.visible,Qe=o.hidden,et=o.red,oe=o.redBright,tt=o.green,U=o.greenBright,rt=o.yellow,w=o.yellowBright,st=o.blue,C=o.blueBright,nt=o.white,it=o.whiteBright,ot=o.black,at=o.blackBright,ct=o.grey,lt=o.cyan,$=o.cyanBright,pt=o.magenta,ut=o.magentaBright,W=o.bold,mt=o.dim,dt=o.underline,T=o.italic,gt={white:o.bgWhite,whiteBright:o.bgWhiteBright,black:o.bgBlack,blackBright:o.bgBlackBright,grey:o.bgGrey,red:o.bgRed,redBright:o.bgRedBright,green:o.bgGreen,greenBright:o.bgGreenBright,yellow:o.bgYellow,yellowBright:o.bgYellowBright,blue:o.bgBlue,blueBright:o.bgBlueBright,magenta:o.bgMagenta,magentaBright:o.bgMagentaBright,cyan:o.bgCyan,cyanBright:o.bgCyanBright},l={organization:w.bold,application:w.bold,slug:w,id:W,token:C,resource:W,attribute:T,trigger:$,kind:$,live:U,test:w,execMode:e=>e==="live"?l.live:l.test,success:U,warning:w,error:oe,arg:T,flag:T,command:T,value:T,alias:$,plugin:C,title:C,path:T,datetime:$,number:w},_t={datetime:l.datetime,number:l.number,path:l.path},ft={organization:l.organization,application:l.application,slug:l.slug,id:l.id,token:l.token,resource:l.resource,attribute:l.attribute,trigger:l.trigger,kind:l.kind,live:l.live,test:l.test},ht={success:l.success,warning:l.warning,error:l.error},yt={arg:l.arg,flag:l.flag,command:l.command,value:l.value,alias:l.alias,plugin:l.plugin},bt={header:w.bold,key:C};var ce={};h(ce,{buildAssertionPayload:()=>$t,decodeAccessToken:()=>ae,generateAccessToken:()=>vt,getAccessToken:()=>wt,getTokenEnvironment:()=>At,isAccessTokenExpiring:()=>kt,revokeAccessToken:()=>Tt});import F from"jsonwebtoken";import{authenticate as V,revoke as xt}from"@commercelayer/js-auth";var ae=e=>{let t=F.decode(e);if(t===null)throw new Error("Error decoding access token");return t},vt=(e,t,r)=>{let n={...e,exp:Math.floor(Date.now()/1e3)+r*60,rand:Math.random()},i=m.api.token_encoding_algorithm,c=F.sign(n,t,{algorithm:i,noTimestamp:!0}),u=F.verify(c,t,{algorithms:[i]});return{accessToken:c,info:u,expMinutes:r}},wt=async e=>{let t,r=e.scope?Array.isArray(e.scope)?e.scope.map(n=>n.trim()).join(","):e.scope:"",s={clientId:e.clientId,clientSecret:e.clientSecret,slug:e.slug,domain:e.domain,scope:r};if(e.email&&e.password?(s.username=e.email,s.password=e.password,t=await V("password",s)):e.assertion?(s.assertion=e.assertion,t=await V("urn:ietf:params:oauth:grant-type:jwt-bearer",s)):t=await V("client_credentials",s),t){if(t.errors)throw new Error(`Unable to get access token: ${t.errors[0].detail}`)}else throw new Error("Unable to get access token");return t},Tt=async(e,t)=>{let r=await xt({...e,token:t});if(r.errors)throw new Error(r.errors[0].detail)},kt=e=>{let r=Math.floor(Date.now()/1e3),s=Math.floor(new Date(e.expires).getTime()/1e3);return r>=s-30},At=e=>(typeof e=="string"?ae(e):e).test?"test":"live";var $t=(e,t,r)=>{let s="https://commercelayer.io/claims",n={[s]:{owner:{type:e,id:t}}};if(r&&Object.keys(r).length>0){let i={};Object.entries(r).forEach(([c,u])=>{let f=c.split("."),b=f[f.length-1],d=i;f.forEach(a=>{a===b?d[a]=u:d=d[a]||(d[a]={})})}),n[s].custom_claim=i}return n};var le={};h(le,{checkUpdate:()=>Rt});import z from"chalk";import Ct from"update-notifier-cjs";var qt=1,Rt=e=>{let t=Ct({pkg:e,updateCheckInterval:36e5*qt});t.update&&t.notify({isGlobal:!1,message:`-= ${z.bgWhite.black.bold(` ${e.description} `)} =-
|
|
4
4
|
|
|
5
5
|
New version available: ${z.dim("{currentVersion}")} -> ${z.green("{latestVersion}")}
|
|
6
|
-
Run ${z.cyanBright("commercelayer plugins:update")} to update`})};var pe={};h(pe,{generateGroupUID:()=>jt,log:()=>
|
|
7
|
-
`)},Pt=(e,t=!1)=>{let r=["desktop","home"],s=e.toLowerCase().split(/[\\\/]/g)[0];if(r.includes(s)){let i=
|
|
6
|
+
Run ${z.cyanBright("commercelayer plugins:update")} to update`})};var pe={};h(pe,{generateGroupUID:()=>jt,log:()=>Lt,resetConsole:()=>Kt,sleep:()=>Mt,specialFolder:()=>Pt,userAgent:()=>Ut});import{format as Et,inspect as St}from"util";import{sep as zt,dirname as It}from"path";import{homedir as Bt}from"os";import{existsSync as Ot,mkdirSync as Dt}from"fs";var Mt=async e=>new Promise(t=>setTimeout(t,e)),Kt=()=>{process.stdout.write("\x1B[?25h\x1B[?7h")},Lt=(e="",...t)=>{e=typeof e=="string"?e:St(e),process.stdout.write(Et(e,...t)+`
|
|
7
|
+
`)},Pt=(e,t=!1)=>{let r=["desktop","home"],s=e.toLowerCase().split(/[\\\/]/g)[0];if(r.includes(s)){let i=Bt();s==="desktop"&&(i+=`${zt}Desktop`),e=e.replace(s,i)}let n=It(e);return t&&!Ot(n)&&Dt(n,{recursive:!0}),e},jt=()=>{let e=Math.trunc(Math.random()*46656),t=Math.trunc(Math.random()*46656),r=("000"+e.toString(36)).slice(-3),s=("000"+t.toString(36)).slice(-3);return r+s},Ut=e=>`${e.name.replace(/@commercelayer\/cli-plugin/,"CLI")}/${e.version}`;import{CommandHelp as Gt,Help as Jt}from"@oclif/core";var me={};h(me,{camelize:()=>Ht,capitalize:()=>R,dasherize:()=>Wt,pluralize:()=>Ft,singularize:()=>Nt,symbols:()=>v,underscorize:()=>Vt});var p={uncountableWords:["equipment","information","rice","money","species","series","fish","sheep","moose","deer","news"],pluralRules:[[/(m)an$/gi,"$1en"],[/(pe)rson$/gi,"$1ople"],[/(child)$/gi,"$1ren"],[/^(ox)$/gi,"$1en"],[/(ax|test)is$/gi,"$1es"],[/(octop|vir)us$/gi,"$1i"],[/(alias|status)$/gi,"$1es"],[/(bu)s$/gi,"$1ses"],[/(buffal|tomat|potat)o$/gi,"$1oes"],[/([ti])um$/gi,"$1a"],[/sis$/gi,"ses"],[/(?:([^f])fe|([lr])f)$/gi,"$1$2ves"],[/(hive)$/gi,"$1s"],[/([^aeiouy]|qu)y$/gi,"$1ies"],[/(x|ch|ss|sh)$/gi,"$1es"],[/(matr|vert|ind)ix|ex$/gi,"$1ices"],[/([m|l])ouse$/gi,"$1ice"],[/(quiz)$/gi,"$1zes"],[/s$/gi,"s"],[/$/gi,"s"]],singularRules:[[/(m)en$/gi,"$1an"],[/(pe)ople$/gi,"$1rson"],[/(child)ren$/gi,"$1"],[/([ti])a$/gi,"$1um"],[/((a)naly|(b)a|(d)iagno|(p)arenthe|(p)rogno|(s)ynop|(t)he)ses$/gi,"$1$2sis"],[/(hive)s$/gi,"$1"],[/(tive)s$/gi,"$1"],[/(curve)s$/gi,"$1"],[/([lr])ves$/gi,"$1f"],[/([^fo])ves$/gi,"$1fe"],[/([^aeiouy]|qu)ies$/gi,"$1y"],[/(s)eries$/gi,"$1eries"],[/(m)ovies$/gi,"$1ovie"],[/(x|ch|ss|sh)es$/gi,"$1"],[/([m|l])ice$/gi,"$1ouse"],[/(bus)es$/gi,"$1"],[/(o)es$/gi,"$1"],[/(shoe)s$/gi,"$1"],[/(cris|ax|test)es$/gi,"$1is"],[/(octop|vir)i$/gi,"$1us"],[/(alias|status)es$/gi,"$1"],[/^(ox)en/gi,"$1"],[/(vert|ind)ices$/gi,"$1ex"],[/(matr)ices$/gi,"$1ix"],[/(quiz)zes$/gi,"$1"],[/s$/gi,""]],nonTitlecasedWords:["and","or","nor","a","an","the","so","but","to","of","at","by","from","into","on","onto","off","out","in","over","with","for"],idSuffix:/(_ids|_id)$/g,underbar:/_/g,spaceOrUnderbar:/[ _]/g,uppercase:/([A-Z])/g,underbarPrefix:/^_/,applyRules:function(e,t,r,s){if(s)e=s;else if(!r.includes(e.toLowerCase())){for(let i=0;i<t.length;i++)if(e.match(t[i][0])){e=e.replace(t[i][0],t[i][1]);break}}return e},pluralize:function(e,t){return p.applyRules(e,p.pluralRules,p.uncountableWords,t)},singularize:function(e,t){return p.applyRules(e,p.singularRules,p.uncountableWords,t)},camelize:function(e,t){let r=e.split("/");for(let s=0;s<r.length;s++){let n=r[s].split("_"),i=t&&s+1===r.length?1:0;for(let c=i;c<n.length;c++)n[c]=n[c].charAt(0).toUpperCase()+n[c].substring(1);r[s]=n.join("")}if(e=r.join("::"),t){let s=e.charAt(0).toLowerCase(),n=e.slice(1);e=s+n}return e},underscore:function(e){let t=e.split("::");for(let r=0;r<t.length;r++)t[r]=t[r].replace(p.uppercase,"_$1"),t[r]=t[r].replace(p.underbarPrefix,"");return e=t.join("/").toLowerCase(),e},humanize:function(e,t){return e=e.toLowerCase(),e=e.replace(p.idSuffix,""),e=e.replace(p.underbar," "),t||(e=p.capitalize(e)),e},capitalize:function(e){return e=e.toLowerCase(),e=e.substring(0,1).toUpperCase()+e.substring(1),e},dasherize:function(e){return e=e.replace(p.spaceOrUnderbar,"-"),e},camel2words:function(e,t){t?(e=p.camelize(e),e=p.underscore(e)):e=e.toLowerCase(),e=e.replace(p.underbar," ");let r=e.split(" ");for(let s=0;s<r.length;s++){let n=r[s].split("-");for(let i=0;i<n.length;i++)p.nonTitlecasedWords.includes(n[i].toLowerCase())||(n[i]=p.capitalize(n[i]));r[s]=n.join("-")}return e=r.join(" "),e=e.substring(0,1).toUpperCase()+e.substring(1),e},demodulize:function(e){let t=e.split("::");return e=t[t.length-1],e},tableize:function(e){return e=p.pluralize(p.underscore(e)),e},classify:function(e){return e=p.singularize(p.camelize(e)),e},foreignKey:function(e,t){return e=p.underscore(p.demodulize(e))+(t?"":"_")+"id",e},ordinalize:function(e){let t=e.split(" ");for(let r=0;r<t.length;r++){let s=parseInt(t[r]);if(Number.isNaN(s)){let n=t[r].substring(t[r].length-2),i=t[r].substring(t[r].length-1),c="th";n!=="11"&&n!=="12"&&n!=="13"&&(i==="1"?c="st":i==="2"?c="nd":i==="3"&&(c="rd")),t[r]+=c}}return e=t.join(" "),e}},q=p;var ue={};h(ue,{symbols:()=>v});var v={check:{small:"\u2714",bkgGreen:"\u2705",squareRoot:"\u221A"},cross:{small:"\u2718",red:"\u274C"},clock:{stopwatch:"\u23F1"},arrow:{down:"\u2193"},selection:{fisheye:"\u25C9"}};v.check.heavy=v.check.small;v.check.whiteHeavy=v.check.bkgGreen;v.cross.heavyBallot=v.cross.small;var R=e=>e&&q.capitalize(e),Wt=e=>e&&(e=e.toLocaleLowerCase(),e.replace(/[ _]/g,"-")),Vt=e=>e&&(e=e.toLocaleLowerCase(),e.replace(/[ -]/g,"_")),Ft=(e,t)=>q.pluralize(e,t),Nt=(e,t)=>q.singularize(e,t),Ht=(e,t)=>q.camelize(e,t);var y=!1,N=class extends Gt{examples(t){return y&&console.log("---------- command.examples"),super.examples(t)}},I=class extends Jt{async showHelp(t){return y&&console.log("---------- showHelp"),super.showHelp(t)}async showRootHelp(){return y&&console.log("---------- showRootHelp"),super.showRootHelp()}async showTopicHelp(t){return y&&console.log("---------- showTopicHelp"),super.showTopicHelp(t)}async showCommandHelp(t){y&&console.log("---------- showCommandHelp");let r=t.id,s=r?r.split(":").length:1,n=this.sortedTopics.filter(u=>u.name.startsWith(r+":")&&u.name.split(":").length===s+1),i=this.sortedCommands.filter(u=>u.id.startsWith(r+":")&&u.id.split(":").length===s+1),c=t.description&&this.render(t.description).split(`
|
|
8
8
|
`)[0];c&&console.log(`${R(c)}
|
|
9
9
|
`),console.log(this.formatCommand(t)),console.log(""),n.length>0&&(console.log(this.formatTopics(n)),console.log("")),i.length>0&&(console.log(this.formatCommands(i)),console.log(""))}formatRoot(){return y&&console.log("---------- formatRoot"),super.formatRoot()}formatTopic(t){return y&&console.log("---------- formatTopic"),super.formatTopic(t)}formatTopics(t){y&&console.log("---------- formatTopics");let r=t.filter(s=>!s.hidden).map(s=>(s.description=R(s.description),s));return super.formatTopics(r)}formatCommands(t){return y&&console.log("---------- formatCommands"),super.formatCommands(t).split(`
|
|
10
10
|
`).map(r=>{let s=0;return r.split(" ").map(n=>(n||"").trim()!==""&&++s===2?R(n):n).join(" ")}).join(`
|
|
11
|
-
`)}formatCommand(t){return y&&console.log("---------- formatCommand"),super.formatCommand(t)}getCommandHelpClass(t){return y&&console.log("---------- getCommandHelpClass"),new N(t,this.config,this.opts)}};var de={};h(de,{download:()=>
|
|
11
|
+
`)}formatCommand(t){return y&&console.log("---------- formatCommand"),super.formatCommand(t)}getCommandHelpClass(t){return y&&console.log("---------- getCommandHelpClass"),new N(t,this.config,this.opts)}};var de={};h(de,{download:()=>Yt});var Yt=async e=>{let r=`https://data.${m.api.default_app_domain}/schemas/`,n=`openapi${e?"_"+e.replace(/\./g,"-"):""}.json`,i=r+n;return await(await fetch(i)).json()};var he={};h(he,{apply:()=>Qt,available:()=>_e,documentation:()=>Zt,filters:()=>fe,list:()=>ge});var Xt=[{predicate:"*_eq",description:"The attribute is equal to the filter value"},{predicate:"*_eq_or_null",description:"The attribute is equal to the filter value, including null values"},{predicate:"*_not_eq",description:"The attribute is not equal to the filter value"},{predicate:"*_not_eq_or_null",description:"The attribute is not equal to the filter value, including null values"},{predicate:"*_matches",description:'The attribute matches the filter value with "LIKE" operator'},{predicate:"*_does_not_match",description:'The attribute does not match the filter value with "LIKE" operator'},{predicate:"*_matches_any",description:'The attribute matches all of the filter values (comma-separated) with "LIKE" operator'},{predicate:"*_matches_all",description:'The attribute matches all of the filter values (comma-separated) with "LIKE" operator'},{predicate:"*_does_not_match_any",description:'The attribute does not match any of the filter values (comma-separated) with "LIKE" operator'},{predicate:"*_does_not_match_all",description:'The attribute matches none of the filter values (comma-separated) with "LIKE" operator'},{predicate:"*_lt",description:"The attribute is less than the filter value"},{predicate:"*_lteq",description:"The attribute is less than or equal to the filter value"},{predicate:"*_gt",description:"The attribute is greater than the filter value"},{predicate:"*_gteq",description:"The attribute is greater than or equal to the filter value"},{predicate:"*_present",description:"The attribute is not null and not empty"},{predicate:"*_blank",description:"The attribute is null or empty"},{predicate:"*_null",description:"The attribute is null"},{predicate:"*_not_null",description:"The attribute is not null"},{predicate:"*_in",description:"The attribute matches any of the filter values (comma-separated)"},{predicate:"*_in_or_null",description:"The attribute matches any of the filter values (comma-separated), including null values"},{predicate:"*_not_in",description:"The attribute matches none of the filter values (comma-separated)"},{predicate:"*_not_in_or_null",description:"The attribute matches none of the filter values (comma-separated), including null values"},{predicate:"*_lt_any",description:"The attribute is less than any of the filter values (comma-separated)"},{predicate:"*_lteq_any",description:"The attribute is less than or equal to any of the filter values (comma-separated)"},{predicate:"*_gt_any",description:"The attribute is greater than any of the filter values (comma-separated)"},{predicate:"*_gteq_any",description:"The attribute is greater than or qual to any of the filter values (comma-separated)"},{predicate:"*_lt_all",description:"The attribute is less than all of the filter values (comma-separated)"},{predicate:"*_lteq_all",description:"The attribute is less than or equal to all of the filter values (comma-separated)"},{predicate:"*_gt_all",description:"The attribute is greater than all of the filter values (comma-separated)"},{predicate:"*_gteq_all",description:"The attribute is greater or equal to all of the filter values (comma-separated)"},{predicate:"*_not_eq_all",description:"The attribute is equal to none of the filter values (comma-separated)"},{predicate:"*_start",description:"The attribute starts with the filter value (comma-separated)"},{predicate:"*_not_start",description:"The attribute does not start with the filter value (comma-separated)"},{predicate:"*_start_any",description:"The attribute starts with any of the filter values (comma-separated)"},{predicate:"*_start_all",description:"The attribute starts with all of the filter values (comma-separated)"},{predicate:"*_not_start_any",description:"The attribute does not start with any of the filter values (comma-separated)"},{predicate:"*_not_start_all",description:"The attribute starts with none of the filter values (comma-separated)"},{predicate:"*_end",description:"The attribute ends with the filter value"},{predicate:"*_not_end",description:"The attribute does not end with the filter value"},{predicate:"*_end_any",description:"The attribute ends with any of the filter values (comma-separated)"},{predicate:"*_end_all",description:"The attribute ends with all of the filter values (comma-separated)"},{predicate:"*_not_end_any",description:"The attribute does not end with any of the filter values (comma-separated)"},{predicate:"*_not_end_all",description:"The attribute ends with none of the filter values (comma-separated)"},{predicate:"*_cont",description:"The attribute contains the filter value"},{predicate:"*_not_cont",description:"The attribute does not contains the filter value"},{predicate:"*_cont_any",description:"The attribute contains any of the filter values (comma-separated)"},{predicate:"*_cont_all",description:"The attribute contains all of the filter values (comma-separated)"},{predicate:"*_not_cont_all",description:"The attribute contains none of the filter values (comma-separated)"},{predicate:"*_jcont",description:"The attribute contains a portion of the JSON used as filter value (works with object only)"},{predicate:"*_true",description:"The attribute is true"},{predicate:"*_false",description:"The attribute is false"}],Zt=m.doc.core_filtering_data,ge=()=>fe().map(e=>e.predicate.replace(/^\*/g,"")),_e=e=>{let t=e.startsWith("_")?e:`_${e}`;return ge().some(r=>t.endsWith(r))},Qt=(e,...t)=>{if(!_e(e))throw new Error("Unknown filter: "+e);let r="";for(let s of t)r+=(r.length===0?"":"_or_")+s;return r+=e.startsWith("_")?e:`_${e}`,r},fe=()=>[...Xt];export{X as clApi,Q as clApplication,A as clColor,ee as clCommand,m as clConfig,he as clFilter,I as clHelp,ie as clOutput,de as clSchema,ue as clSymbol,me as clText,ce as clToken,le as clUpdate,pe as clUtil};
|