@ptkl/sdk 1.3.4 → 1.4.0
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/dist/index.0.10.js +94 -20
- package/dist/index.0.9.js +73 -20
- package/dist/package.json +5 -4
- package/dist/v0.10/api/component.d.ts +30 -12
- package/dist/v0.10/api/functions.d.ts +17 -5
- package/dist/v0.10/api/index.d.ts +2 -0
- package/dist/v0.10/api/integrations/ecommerce.d.ts +42 -0
- package/dist/v0.10/api/integrations.d.ts +2 -0
- package/dist/v0.10/api/platform.d.ts +1 -1
- package/dist/v0.10/api/system.d.ts +38 -1
- package/dist/v0.10/index.cjs.js +94 -20
- package/dist/v0.10/index.esm.js +94 -21
- package/dist/v0.10/types/component.d.ts +4 -3
- package/dist/v0.10/types/functions.d.ts +81 -0
- package/dist/v0.10/types/integrations/ecommerce.d.ts +199 -0
- package/dist/v0.9/api/component.d.ts +6 -6
- package/dist/v0.9/api/functions.d.ts +17 -5
- package/dist/v0.9/api/index.d.ts +1 -0
- package/dist/v0.9/api/integrations/ecommerce.d.ts +42 -0
- package/dist/v0.9/api/integrations.d.ts +2 -0
- package/dist/v0.9/api/system.d.ts +1 -1
- package/dist/v0.9/index.cjs.js +73 -20
- package/dist/v0.9/index.esm.js +73 -21
- package/dist/v0.9/types/component.d.ts +4 -3
- package/dist/v0.9/types/functions.d.ts +41 -0
- package/dist/v0.9/types/integrations/ecommerce.d.ts +199 -0
- package/package.json +5 -4
package/dist/v0.10/index.cjs.js
CHANGED
|
@@ -19014,11 +19014,15 @@ class PlatformBaseClient extends BaseClient {
|
|
|
19014
19014
|
token = (_c = __global_env__ === null || __global_env__ === void 0 ? void 0 : __global_env__.PROJECT_API_TOKEN) !== null && _c !== void 0 ? _c : token;
|
|
19015
19015
|
project_uuid = __global_env__ === null || __global_env__ === void 0 ? void 0 : __global_env__.PROJECT_UUID;
|
|
19016
19016
|
if (isBrowser) {
|
|
19017
|
-
if (sessionStorage.getItem('protokol_context')
|
|
19018
|
-
headers['X-Project-Env'] = (_d = sessionStorage.getItem('forge_app_env')) !== null && _d !== void 0 ? _d :
|
|
19017
|
+
if (sessionStorage.getItem('protokol_context') === 'forge') {
|
|
19018
|
+
headers['X-Project-Env'] = (_d = sessionStorage.getItem('forge_app_env')) !== null && _d !== void 0 ? _d : 'dev';
|
|
19019
|
+
// pick up forge actor token — overrides any other token source
|
|
19020
|
+
const forgeToken = sessionStorage.getItem('forge_actor_token');
|
|
19021
|
+
if (forgeToken)
|
|
19022
|
+
token = forgeToken;
|
|
19019
19023
|
}
|
|
19020
19024
|
else {
|
|
19021
|
-
headers['X-Project-Env'] = (_e = localStorage.getItem('current_env')) !== null && _e !== void 0 ? _e :
|
|
19025
|
+
headers['X-Project-Env'] = (_e = localStorage.getItem('current_env')) !== null && _e !== void 0 ? _e : 'dev';
|
|
19022
19026
|
}
|
|
19023
19027
|
}
|
|
19024
19028
|
}
|
|
@@ -19054,6 +19058,11 @@ class PlatformBaseClient extends BaseClient {
|
|
|
19054
19058
|
}
|
|
19055
19059
|
|
|
19056
19060
|
class Component extends PlatformBaseClient {
|
|
19061
|
+
/**
|
|
19062
|
+
* @param ref - Component ref (e.g. "ecommerce::order"). Passing a string
|
|
19063
|
+
* literal lets TypeScript infer the generic C and type find/create/function
|
|
19064
|
+
* results accordingly.
|
|
19065
|
+
*/
|
|
19057
19066
|
constructor(ref = null) {
|
|
19058
19067
|
super();
|
|
19059
19068
|
this.ref = ref;
|
|
@@ -19199,7 +19208,7 @@ class Component extends PlatformBaseClient {
|
|
|
19199
19208
|
async updateMany(data, options) {
|
|
19200
19209
|
return await this.client.patch(`/v4/system/component/${this.ref}/models/bulk`, {
|
|
19201
19210
|
data,
|
|
19202
|
-
options
|
|
19211
|
+
options,
|
|
19203
19212
|
});
|
|
19204
19213
|
}
|
|
19205
19214
|
/**
|
|
@@ -19604,16 +19613,6 @@ class Functions extends PlatformBaseClient {
|
|
|
19604
19613
|
async update(uuid, update) {
|
|
19605
19614
|
return await this.client.patch(`/v1/system/function/${uuid}`, update);
|
|
19606
19615
|
}
|
|
19607
|
-
/**
|
|
19608
|
-
* Run platform function
|
|
19609
|
-
*
|
|
19610
|
-
* @param id - Function ID
|
|
19611
|
-
* @param d - Object containing input data, query parameters, and headers
|
|
19612
|
-
* @returns - Function result
|
|
19613
|
-
*
|
|
19614
|
-
* @example
|
|
19615
|
-
* const result = await platform.function().run("myFunction", {input: { foo: "bar" }})
|
|
19616
|
-
*/
|
|
19617
19616
|
async run(id, d) {
|
|
19618
19617
|
const { data } = await this.client.post(`/v1/system/function/run/${id}`, d.input, {
|
|
19619
19618
|
params: d.query,
|
|
@@ -20068,10 +20067,25 @@ class Sandbox extends PlatformBaseClient {
|
|
|
20068
20067
|
}
|
|
20069
20068
|
|
|
20070
20069
|
class System extends PlatformBaseClient {
|
|
20071
|
-
|
|
20070
|
+
/**
|
|
20071
|
+
* Returns all IDL definitions for the current project.
|
|
20072
|
+
* Used by `ptkl generate-types` to emit typed `.d.ts` augmentations.
|
|
20073
|
+
*/
|
|
20074
|
+
async idl() {
|
|
20075
|
+
return await this.client.get('/v1/system/idl');
|
|
20076
|
+
}
|
|
20077
|
+
/**
|
|
20078
|
+
* Validates a value against an IDL — either by ref or with an inline IDL object.
|
|
20079
|
+
* Returns `{ data: { valid: true } }` on success or
|
|
20080
|
+
* `{ data: { valid: false, errors: [...] } }` on validation failure.
|
|
20081
|
+
* Throws on HTTP errors (4xx/5xx).
|
|
20082
|
+
*/
|
|
20083
|
+
async idlValidate(req) {
|
|
20084
|
+
return await this.client.post('/v1/system/idl/validate', req);
|
|
20085
|
+
}
|
|
20086
|
+
async resourceResolver(prn, format) {
|
|
20072
20087
|
return await this.client.post("/v3/system/resource-resolver", {
|
|
20073
|
-
|
|
20074
|
-
ref,
|
|
20088
|
+
prn,
|
|
20075
20089
|
format,
|
|
20076
20090
|
});
|
|
20077
20091
|
}
|
|
@@ -20373,11 +20387,15 @@ class IntegrationsBaseClient extends BaseClient {
|
|
|
20373
20387
|
env = env !== null && env !== void 0 ? env : __global_env__ === null || __global_env__ === void 0 ? void 0 : __global_env__.PROJECT_ENV;
|
|
20374
20388
|
token = token !== null && token !== void 0 ? token : __global_env__ === null || __global_env__ === void 0 ? void 0 : __global_env__.PROJECT_API_TOKEN;
|
|
20375
20389
|
if (isBrowser) {
|
|
20376
|
-
if (sessionStorage.getItem('protokol_context')
|
|
20377
|
-
headers['X-Project-Env'] = (_b = sessionStorage.getItem('forge_app_env')) !== null && _b !== void 0 ? _b :
|
|
20390
|
+
if (sessionStorage.getItem('protokol_context') === 'forge') {
|
|
20391
|
+
headers['X-Project-Env'] = (_b = sessionStorage.getItem('forge_app_env')) !== null && _b !== void 0 ? _b : 'dev';
|
|
20392
|
+
// pick up forge actor token — overrides any other token source
|
|
20393
|
+
const forgeToken = sessionStorage.getItem('forge_actor_token');
|
|
20394
|
+
if (forgeToken)
|
|
20395
|
+
token = forgeToken;
|
|
20378
20396
|
}
|
|
20379
20397
|
else {
|
|
20380
|
-
headers['X-Project-Env'] = (_c = localStorage.getItem('current_env')) !== null && _c !== void 0 ? _c :
|
|
20398
|
+
headers['X-Project-Env'] = (_c = localStorage.getItem('current_env')) !== null && _c !== void 0 ? _c : 'dev';
|
|
20381
20399
|
}
|
|
20382
20400
|
}
|
|
20383
20401
|
}
|
|
@@ -22173,6 +22191,57 @@ class NBS extends IntegrationsBaseClient {
|
|
|
22173
22191
|
}
|
|
22174
22192
|
}
|
|
22175
22193
|
|
|
22194
|
+
class Ecommerce extends IntegrationsBaseClient {
|
|
22195
|
+
/**
|
|
22196
|
+
* Get the ecommerce integration user for the current project.
|
|
22197
|
+
*/
|
|
22198
|
+
async get() {
|
|
22199
|
+
return await this.client.get(`/v1/ecomm/user`);
|
|
22200
|
+
}
|
|
22201
|
+
/**
|
|
22202
|
+
* Update ecommerce integration settings (onboarding or partial update).
|
|
22203
|
+
*/
|
|
22204
|
+
async update(req) {
|
|
22205
|
+
return await this.client.patch(`/v1/ecomm/user`, req);
|
|
22206
|
+
}
|
|
22207
|
+
/**
|
|
22208
|
+
* Check whether a base domain subdomain is available.
|
|
22209
|
+
*/
|
|
22210
|
+
async checkBaseDomain(domain) {
|
|
22211
|
+
return await this.client.post(`/v1/ecomm/base-domain/check`, { domain });
|
|
22212
|
+
}
|
|
22213
|
+
/**
|
|
22214
|
+
* Add a custom domain (returns a verification token for DNS validation).
|
|
22215
|
+
*/
|
|
22216
|
+
async addCustomDomain(domain) {
|
|
22217
|
+
return await this.client.post(`/v1/ecomm/domains`, { domain });
|
|
22218
|
+
}
|
|
22219
|
+
/**
|
|
22220
|
+
* Validate a custom domain with its verification token.
|
|
22221
|
+
*/
|
|
22222
|
+
async validateCustomDomain(domain, token) {
|
|
22223
|
+
return await this.client.post(`/v1/ecomm/domains/validate`, { domain, token });
|
|
22224
|
+
}
|
|
22225
|
+
/**
|
|
22226
|
+
* Remove a custom domain.
|
|
22227
|
+
*/
|
|
22228
|
+
async removeCustomDomain(domain) {
|
|
22229
|
+
return await this.client.delete(`/v1/ecomm/domains`, { data: { domain } });
|
|
22230
|
+
}
|
|
22231
|
+
/**
|
|
22232
|
+
* List pending (unvalidated) custom domains.
|
|
22233
|
+
*/
|
|
22234
|
+
async getPendingDomains() {
|
|
22235
|
+
return await this.client.get(`/v1/ecomm/domains/pending`);
|
|
22236
|
+
}
|
|
22237
|
+
/**
|
|
22238
|
+
* List validated custom domains.
|
|
22239
|
+
*/
|
|
22240
|
+
async getValidatedDomains() {
|
|
22241
|
+
return await this.client.get(`/v1/ecomm/domains/validated`);
|
|
22242
|
+
}
|
|
22243
|
+
}
|
|
22244
|
+
|
|
22176
22245
|
class Integrations extends IntegrationsBaseClient {
|
|
22177
22246
|
constructor(options) {
|
|
22178
22247
|
super(options);
|
|
@@ -22183,6 +22252,7 @@ class Integrations extends IntegrationsBaseClient {
|
|
|
22183
22252
|
'nbs': new NBS().setClient(this.client),
|
|
22184
22253
|
'protokol-payments': new Payments().setClient(this.client),
|
|
22185
22254
|
'protokol-minimax': new Minimax().setClient(this.client),
|
|
22255
|
+
'protokol-ecommerce': new Ecommerce().setClient(this.client),
|
|
22186
22256
|
};
|
|
22187
22257
|
}
|
|
22188
22258
|
getDMS() {
|
|
@@ -22206,6 +22276,9 @@ class Integrations extends IntegrationsBaseClient {
|
|
|
22206
22276
|
getSerbiaMinFin() {
|
|
22207
22277
|
return this.getInterfaceOf('serbia-minfin');
|
|
22208
22278
|
}
|
|
22279
|
+
getEcommerce() {
|
|
22280
|
+
return this.getInterfaceOf('protokol-ecommerce');
|
|
22281
|
+
}
|
|
22209
22282
|
async isInstalled(id) {
|
|
22210
22283
|
const { data } = await this.client.get("/v1/integrations");
|
|
22211
22284
|
return data.find((i) => i.id == id) !== undefined;
|
|
@@ -22251,6 +22324,7 @@ exports.Component = Component;
|
|
|
22251
22324
|
exports.ComponentUtils = ComponentUtils;
|
|
22252
22325
|
exports.Config = Config;
|
|
22253
22326
|
exports.DMS = DMS;
|
|
22327
|
+
exports.Ecommerce = Ecommerce;
|
|
22254
22328
|
exports.Forge = Forge;
|
|
22255
22329
|
exports.Functions = Functions;
|
|
22256
22330
|
exports.Integration = Integrations;
|
package/dist/v0.10/index.esm.js
CHANGED
|
@@ -47,11 +47,15 @@ class PlatformBaseClient extends BaseClient {
|
|
|
47
47
|
token = (_c = __global_env__ === null || __global_env__ === void 0 ? void 0 : __global_env__.PROJECT_API_TOKEN) !== null && _c !== void 0 ? _c : token;
|
|
48
48
|
project_uuid = __global_env__ === null || __global_env__ === void 0 ? void 0 : __global_env__.PROJECT_UUID;
|
|
49
49
|
if (isBrowser) {
|
|
50
|
-
if (sessionStorage.getItem('protokol_context')
|
|
51
|
-
headers['X-Project-Env'] = (_d = sessionStorage.getItem('forge_app_env')) !== null && _d !== void 0 ? _d :
|
|
50
|
+
if (sessionStorage.getItem('protokol_context') === 'forge') {
|
|
51
|
+
headers['X-Project-Env'] = (_d = sessionStorage.getItem('forge_app_env')) !== null && _d !== void 0 ? _d : 'dev';
|
|
52
|
+
// pick up forge actor token — overrides any other token source
|
|
53
|
+
const forgeToken = sessionStorage.getItem('forge_actor_token');
|
|
54
|
+
if (forgeToken)
|
|
55
|
+
token = forgeToken;
|
|
52
56
|
}
|
|
53
57
|
else {
|
|
54
|
-
headers['X-Project-Env'] = (_e = localStorage.getItem('current_env')) !== null && _e !== void 0 ? _e :
|
|
58
|
+
headers['X-Project-Env'] = (_e = localStorage.getItem('current_env')) !== null && _e !== void 0 ? _e : 'dev';
|
|
55
59
|
}
|
|
56
60
|
}
|
|
57
61
|
}
|
|
@@ -87,6 +91,11 @@ class PlatformBaseClient extends BaseClient {
|
|
|
87
91
|
}
|
|
88
92
|
|
|
89
93
|
class Component extends PlatformBaseClient {
|
|
94
|
+
/**
|
|
95
|
+
* @param ref - Component ref (e.g. "ecommerce::order"). Passing a string
|
|
96
|
+
* literal lets TypeScript infer the generic C and type find/create/function
|
|
97
|
+
* results accordingly.
|
|
98
|
+
*/
|
|
90
99
|
constructor(ref = null) {
|
|
91
100
|
super();
|
|
92
101
|
this.ref = ref;
|
|
@@ -232,7 +241,7 @@ class Component extends PlatformBaseClient {
|
|
|
232
241
|
async updateMany(data, options) {
|
|
233
242
|
return await this.client.patch(`/v4/system/component/${this.ref}/models/bulk`, {
|
|
234
243
|
data,
|
|
235
|
-
options
|
|
244
|
+
options,
|
|
236
245
|
});
|
|
237
246
|
}
|
|
238
247
|
/**
|
|
@@ -637,16 +646,6 @@ class Functions extends PlatformBaseClient {
|
|
|
637
646
|
async update(uuid, update) {
|
|
638
647
|
return await this.client.patch(`/v1/system/function/${uuid}`, update);
|
|
639
648
|
}
|
|
640
|
-
/**
|
|
641
|
-
* Run platform function
|
|
642
|
-
*
|
|
643
|
-
* @param id - Function ID
|
|
644
|
-
* @param d - Object containing input data, query parameters, and headers
|
|
645
|
-
* @returns - Function result
|
|
646
|
-
*
|
|
647
|
-
* @example
|
|
648
|
-
* const result = await platform.function().run("myFunction", {input: { foo: "bar" }})
|
|
649
|
-
*/
|
|
650
649
|
async run(id, d) {
|
|
651
650
|
const { data } = await this.client.post(`/v1/system/function/run/${id}`, d.input, {
|
|
652
651
|
params: d.query,
|
|
@@ -1101,10 +1100,25 @@ class Sandbox extends PlatformBaseClient {
|
|
|
1101
1100
|
}
|
|
1102
1101
|
|
|
1103
1102
|
class System extends PlatformBaseClient {
|
|
1104
|
-
|
|
1103
|
+
/**
|
|
1104
|
+
* Returns all IDL definitions for the current project.
|
|
1105
|
+
* Used by `ptkl generate-types` to emit typed `.d.ts` augmentations.
|
|
1106
|
+
*/
|
|
1107
|
+
async idl() {
|
|
1108
|
+
return await this.client.get('/v1/system/idl');
|
|
1109
|
+
}
|
|
1110
|
+
/**
|
|
1111
|
+
* Validates a value against an IDL — either by ref or with an inline IDL object.
|
|
1112
|
+
* Returns `{ data: { valid: true } }` on success or
|
|
1113
|
+
* `{ data: { valid: false, errors: [...] } }` on validation failure.
|
|
1114
|
+
* Throws on HTTP errors (4xx/5xx).
|
|
1115
|
+
*/
|
|
1116
|
+
async idlValidate(req) {
|
|
1117
|
+
return await this.client.post('/v1/system/idl/validate', req);
|
|
1118
|
+
}
|
|
1119
|
+
async resourceResolver(prn, format) {
|
|
1105
1120
|
return await this.client.post("/v3/system/resource-resolver", {
|
|
1106
|
-
|
|
1107
|
-
ref,
|
|
1121
|
+
prn,
|
|
1108
1122
|
format,
|
|
1109
1123
|
});
|
|
1110
1124
|
}
|
|
@@ -1406,11 +1420,15 @@ class IntegrationsBaseClient extends BaseClient {
|
|
|
1406
1420
|
env = env !== null && env !== void 0 ? env : __global_env__ === null || __global_env__ === void 0 ? void 0 : __global_env__.PROJECT_ENV;
|
|
1407
1421
|
token = token !== null && token !== void 0 ? token : __global_env__ === null || __global_env__ === void 0 ? void 0 : __global_env__.PROJECT_API_TOKEN;
|
|
1408
1422
|
if (isBrowser) {
|
|
1409
|
-
if (sessionStorage.getItem('protokol_context')
|
|
1410
|
-
headers['X-Project-Env'] = (_b = sessionStorage.getItem('forge_app_env')) !== null && _b !== void 0 ? _b :
|
|
1423
|
+
if (sessionStorage.getItem('protokol_context') === 'forge') {
|
|
1424
|
+
headers['X-Project-Env'] = (_b = sessionStorage.getItem('forge_app_env')) !== null && _b !== void 0 ? _b : 'dev';
|
|
1425
|
+
// pick up forge actor token — overrides any other token source
|
|
1426
|
+
const forgeToken = sessionStorage.getItem('forge_actor_token');
|
|
1427
|
+
if (forgeToken)
|
|
1428
|
+
token = forgeToken;
|
|
1411
1429
|
}
|
|
1412
1430
|
else {
|
|
1413
|
-
headers['X-Project-Env'] = (_c = localStorage.getItem('current_env')) !== null && _c !== void 0 ? _c :
|
|
1431
|
+
headers['X-Project-Env'] = (_c = localStorage.getItem('current_env')) !== null && _c !== void 0 ? _c : 'dev';
|
|
1414
1432
|
}
|
|
1415
1433
|
}
|
|
1416
1434
|
}
|
|
@@ -3206,6 +3224,57 @@ class NBS extends IntegrationsBaseClient {
|
|
|
3206
3224
|
}
|
|
3207
3225
|
}
|
|
3208
3226
|
|
|
3227
|
+
class Ecommerce extends IntegrationsBaseClient {
|
|
3228
|
+
/**
|
|
3229
|
+
* Get the ecommerce integration user for the current project.
|
|
3230
|
+
*/
|
|
3231
|
+
async get() {
|
|
3232
|
+
return await this.client.get(`/v1/ecomm/user`);
|
|
3233
|
+
}
|
|
3234
|
+
/**
|
|
3235
|
+
* Update ecommerce integration settings (onboarding or partial update).
|
|
3236
|
+
*/
|
|
3237
|
+
async update(req) {
|
|
3238
|
+
return await this.client.patch(`/v1/ecomm/user`, req);
|
|
3239
|
+
}
|
|
3240
|
+
/**
|
|
3241
|
+
* Check whether a base domain subdomain is available.
|
|
3242
|
+
*/
|
|
3243
|
+
async checkBaseDomain(domain) {
|
|
3244
|
+
return await this.client.post(`/v1/ecomm/base-domain/check`, { domain });
|
|
3245
|
+
}
|
|
3246
|
+
/**
|
|
3247
|
+
* Add a custom domain (returns a verification token for DNS validation).
|
|
3248
|
+
*/
|
|
3249
|
+
async addCustomDomain(domain) {
|
|
3250
|
+
return await this.client.post(`/v1/ecomm/domains`, { domain });
|
|
3251
|
+
}
|
|
3252
|
+
/**
|
|
3253
|
+
* Validate a custom domain with its verification token.
|
|
3254
|
+
*/
|
|
3255
|
+
async validateCustomDomain(domain, token) {
|
|
3256
|
+
return await this.client.post(`/v1/ecomm/domains/validate`, { domain, token });
|
|
3257
|
+
}
|
|
3258
|
+
/**
|
|
3259
|
+
* Remove a custom domain.
|
|
3260
|
+
*/
|
|
3261
|
+
async removeCustomDomain(domain) {
|
|
3262
|
+
return await this.client.delete(`/v1/ecomm/domains`, { data: { domain } });
|
|
3263
|
+
}
|
|
3264
|
+
/**
|
|
3265
|
+
* List pending (unvalidated) custom domains.
|
|
3266
|
+
*/
|
|
3267
|
+
async getPendingDomains() {
|
|
3268
|
+
return await this.client.get(`/v1/ecomm/domains/pending`);
|
|
3269
|
+
}
|
|
3270
|
+
/**
|
|
3271
|
+
* List validated custom domains.
|
|
3272
|
+
*/
|
|
3273
|
+
async getValidatedDomains() {
|
|
3274
|
+
return await this.client.get(`/v1/ecomm/domains/validated`);
|
|
3275
|
+
}
|
|
3276
|
+
}
|
|
3277
|
+
|
|
3209
3278
|
class Integrations extends IntegrationsBaseClient {
|
|
3210
3279
|
constructor(options) {
|
|
3211
3280
|
super(options);
|
|
@@ -3216,6 +3285,7 @@ class Integrations extends IntegrationsBaseClient {
|
|
|
3216
3285
|
'nbs': new NBS().setClient(this.client),
|
|
3217
3286
|
'protokol-payments': new Payments().setClient(this.client),
|
|
3218
3287
|
'protokol-minimax': new Minimax().setClient(this.client),
|
|
3288
|
+
'protokol-ecommerce': new Ecommerce().setClient(this.client),
|
|
3219
3289
|
};
|
|
3220
3290
|
}
|
|
3221
3291
|
getDMS() {
|
|
@@ -3239,6 +3309,9 @@ class Integrations extends IntegrationsBaseClient {
|
|
|
3239
3309
|
getSerbiaMinFin() {
|
|
3240
3310
|
return this.getInterfaceOf('serbia-minfin');
|
|
3241
3311
|
}
|
|
3312
|
+
getEcommerce() {
|
|
3313
|
+
return this.getInterfaceOf('protokol-ecommerce');
|
|
3314
|
+
}
|
|
3242
3315
|
async isInstalled(id) {
|
|
3243
3316
|
const { data } = await this.client.get("/v1/integrations");
|
|
3244
3317
|
return data.find((i) => i.id == id) !== undefined;
|
|
@@ -3278,4 +3351,4 @@ class Invoicing extends PlatformBaseClient {
|
|
|
3278
3351
|
}
|
|
3279
3352
|
}
|
|
3280
3353
|
|
|
3281
|
-
export { APIUser, Apps, Component, ComponentUtils, Config, DMS, Forge, Functions, Integrations as Integration, Integrations, Invoicing, Mail, NBS, Payments, Platform, Project, Ratchet, Sandbox, MinFin as SerbiaMinFin, System, Thunder, Users, VPFR, Workflow };
|
|
3354
|
+
export { APIUser, Apps, Component, ComponentUtils, Config, DMS, Ecommerce, Forge, Functions, Integrations as Integration, Integrations, Invoicing, Mail, NBS, Payments, Platform, Project, Ratchet, Sandbox, MinFin as SerbiaMinFin, System, Thunder, Users, VPFR, Workflow };
|
|
@@ -65,16 +65,17 @@ type Model = {
|
|
|
65
65
|
[key: string]: any;
|
|
66
66
|
};
|
|
67
67
|
type UpdateOptions = {
|
|
68
|
-
|
|
68
|
+
force_update_protected_fields: boolean;
|
|
69
69
|
};
|
|
70
70
|
type UpdateManyOptions = UpdateOptions & {
|
|
71
|
-
|
|
71
|
+
rollback_on_error: boolean;
|
|
72
72
|
};
|
|
73
73
|
type CreateManyOptions = {
|
|
74
|
-
|
|
74
|
+
rollback_on_error: boolean;
|
|
75
75
|
};
|
|
76
76
|
type ModifyOptions = {
|
|
77
77
|
upsert: boolean;
|
|
78
|
+
force_update_protected_fields?: boolean;
|
|
78
79
|
};
|
|
79
80
|
/**
|
|
80
81
|
* MongoDB update operators that can be included inline in the `data` payload.
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* ComponentModels maps component/extension refs to their IDL field shapes.
|
|
3
|
+
* Keys follow the pattern "namespace::name" or "namespace::name/extensionName".
|
|
4
|
+
* Populated at runtime by Monaco via declaration merging.
|
|
5
|
+
*
|
|
6
|
+
* @example
|
|
7
|
+
* type OrderFields = ComponentModels["ecommerce::order"]
|
|
8
|
+
*/
|
|
9
|
+
export interface ComponentModels {
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* ComponentFunctions maps component/extension refs to their function signatures.
|
|
13
|
+
* Each key is a component ref ("namespace::name") and the value maps function
|
|
14
|
+
* names to their IDL-derived input/output shapes.
|
|
15
|
+
*
|
|
16
|
+
* @example
|
|
17
|
+
* type TestFn = ComponentFunctions["ecommerce::order"]["test"]
|
|
18
|
+
* // → { input: { discount?: number; items: number[] }; output: { item_count?: number; total?: number } }
|
|
19
|
+
*/
|
|
20
|
+
export interface ComponentFunctions {
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* PlatformFunctions is an open interface that serves as a registry of platform
|
|
24
|
+
* function signatures. It is empty by default and can be extended:
|
|
25
|
+
*
|
|
26
|
+
* **At build time** — run `ptkl generate-types` to fetch your project's
|
|
27
|
+
* functions and emit a `.d.ts` file with a module augmentation block:
|
|
28
|
+
* ```ts
|
|
29
|
+
* declare module "@ptkl/sdk" {
|
|
30
|
+
* interface PlatformFunctions {
|
|
31
|
+
* "send_email": { input: { body: string; to: string }; output: { status: boolean } }
|
|
32
|
+
* }
|
|
33
|
+
* }
|
|
34
|
+
* ```
|
|
35
|
+
*/
|
|
36
|
+
export interface PlatformFunctions {
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* Access a single platform function's signature type by name.
|
|
40
|
+
*
|
|
41
|
+
* @example
|
|
42
|
+
* type EmailSig = PlatformFunction<"send_email">
|
|
43
|
+
* // → { input: { body: string; to: string }; output: { status: boolean } }
|
|
44
|
+
*/
|
|
45
|
+
export type PlatformFunction<K extends keyof PlatformFunctions> = PlatformFunctions[K];
|
|
46
|
+
/** Inferred input type for a registered function, falling back to a generic record. */
|
|
47
|
+
export type FunctionInput<K extends keyof PlatformFunctions> = PlatformFunctions[K] extends {
|
|
48
|
+
input: infer I;
|
|
49
|
+
} ? I : Record<string, any>;
|
|
50
|
+
/** Inferred output type for a registered function, falling back to any. */
|
|
51
|
+
export type FunctionOutput<K extends keyof PlatformFunctions> = PlatformFunctions[K] extends {
|
|
52
|
+
output: infer O;
|
|
53
|
+
} ? O : any;
|
|
54
|
+
/** Parameters shape for a typed function call. */
|
|
55
|
+
export type FunctionCallParams<K extends keyof PlatformFunctions> = {
|
|
56
|
+
input: FunctionInput<K>;
|
|
57
|
+
query?: Record<string, string>;
|
|
58
|
+
headers?: Record<string, string>;
|
|
59
|
+
};
|
|
60
|
+
/** Resolved field shape for a known component ref. */
|
|
61
|
+
export type ComponentModel<C extends keyof ComponentModels> = ComponentModels[C];
|
|
62
|
+
/**
|
|
63
|
+
* Inferred input type for a component function.
|
|
64
|
+
*
|
|
65
|
+
* @example
|
|
66
|
+
* type TestInput = ComponentFunctionInput<"ecommerce::order", "test">
|
|
67
|
+
* // → { discount?: number; items: number[] }
|
|
68
|
+
*/
|
|
69
|
+
export type ComponentFunctionInput<C extends keyof ComponentFunctions, F extends keyof ComponentFunctions[C]> = ComponentFunctions[C][F] extends {
|
|
70
|
+
input: infer I;
|
|
71
|
+
} ? I : Record<string, any>;
|
|
72
|
+
/**
|
|
73
|
+
* Inferred output type for a component function.
|
|
74
|
+
*
|
|
75
|
+
* @example
|
|
76
|
+
* type TestOutput = ComponentFunctionOutput<"ecommerce::order", "test">
|
|
77
|
+
* // → { item_count?: number; total?: number }
|
|
78
|
+
*/
|
|
79
|
+
export type ComponentFunctionOutput<C extends keyof ComponentFunctions, F extends keyof ComponentFunctions[C]> = ComponentFunctions[C][F] extends {
|
|
80
|
+
output: infer O;
|
|
81
|
+
} ? O : any;
|
|
@@ -0,0 +1,199 @@
|
|
|
1
|
+
export type IDNamePair = {
|
|
2
|
+
id: string;
|
|
3
|
+
name: string;
|
|
4
|
+
};
|
|
5
|
+
export type ShippingMethodsConfig = {
|
|
6
|
+
methods: IDNamePair[];
|
|
7
|
+
};
|
|
8
|
+
export type PaymentMethodsConfig = {
|
|
9
|
+
methods: IDNamePair[];
|
|
10
|
+
};
|
|
11
|
+
export type PaymentProvidersConfig = {
|
|
12
|
+
options?: IDNamePair;
|
|
13
|
+
};
|
|
14
|
+
export type CartSettings = {
|
|
15
|
+
shipping_methods: ShippingMethodsConfig;
|
|
16
|
+
payment_methods: PaymentMethodsConfig;
|
|
17
|
+
payment_providers: PaymentProvidersConfig;
|
|
18
|
+
};
|
|
19
|
+
export type PriceSettings = {
|
|
20
|
+
default_currency: IDNamePair;
|
|
21
|
+
};
|
|
22
|
+
export type I18nSettings = {
|
|
23
|
+
default_locale: IDNamePair;
|
|
24
|
+
locales: IDNamePair[];
|
|
25
|
+
};
|
|
26
|
+
export type LogoConfig = {
|
|
27
|
+
position: number;
|
|
28
|
+
src: string;
|
|
29
|
+
alt: string;
|
|
30
|
+
width: number;
|
|
31
|
+
height: number;
|
|
32
|
+
};
|
|
33
|
+
export type ItemsConfig = {
|
|
34
|
+
position: number;
|
|
35
|
+
menu: IDNamePair;
|
|
36
|
+
};
|
|
37
|
+
export type ActionsConfig = {
|
|
38
|
+
position: number;
|
|
39
|
+
icons: Record<string, any>;
|
|
40
|
+
};
|
|
41
|
+
export type HeaderSettings = {
|
|
42
|
+
logo: LogoConfig;
|
|
43
|
+
items: ItemsConfig;
|
|
44
|
+
actions: ActionsConfig;
|
|
45
|
+
};
|
|
46
|
+
export type HomepageSection = {
|
|
47
|
+
id: string;
|
|
48
|
+
type: string;
|
|
49
|
+
show: boolean;
|
|
50
|
+
settings: Record<string, any>;
|
|
51
|
+
};
|
|
52
|
+
export type HomepageSettings = {
|
|
53
|
+
sections: HomepageSection[];
|
|
54
|
+
};
|
|
55
|
+
export type CategoryInfoConfig = {
|
|
56
|
+
text_position: IDNamePair;
|
|
57
|
+
show_title: boolean;
|
|
58
|
+
show_description: boolean;
|
|
59
|
+
show_image: boolean;
|
|
60
|
+
};
|
|
61
|
+
export type CategoryHeaderConfig = {
|
|
62
|
+
use_breadcrumbs: boolean;
|
|
63
|
+
category_info: CategoryInfoConfig;
|
|
64
|
+
};
|
|
65
|
+
export type CategoryFiltersConfig = {
|
|
66
|
+
show: boolean;
|
|
67
|
+
type: IDNamePair;
|
|
68
|
+
use_accordion: boolean;
|
|
69
|
+
};
|
|
70
|
+
export type CategorySettings = {
|
|
71
|
+
header: CategoryHeaderConfig;
|
|
72
|
+
filters: CategoryFiltersConfig;
|
|
73
|
+
};
|
|
74
|
+
export type DisplayConfig = {
|
|
75
|
+
show: boolean;
|
|
76
|
+
text_position: IDNamePair;
|
|
77
|
+
position: number;
|
|
78
|
+
};
|
|
79
|
+
export type SimpleDisplayConfig = {
|
|
80
|
+
show: boolean;
|
|
81
|
+
};
|
|
82
|
+
export type InventoryConfig = {
|
|
83
|
+
show: boolean;
|
|
84
|
+
text_position: IDNamePair;
|
|
85
|
+
position: number;
|
|
86
|
+
allow_backorder: boolean;
|
|
87
|
+
};
|
|
88
|
+
export type ActionButtonConfig = {
|
|
89
|
+
icon: IDNamePair;
|
|
90
|
+
button_variant: IDNamePair;
|
|
91
|
+
show: boolean;
|
|
92
|
+
};
|
|
93
|
+
export type ProductActionsConfig = {
|
|
94
|
+
position: number;
|
|
95
|
+
align: IDNamePair;
|
|
96
|
+
add_to_cart: ActionButtonConfig;
|
|
97
|
+
add_to_wishlist: ActionButtonConfig;
|
|
98
|
+
};
|
|
99
|
+
export type QuantitySelectorConfig = {
|
|
100
|
+
show: boolean;
|
|
101
|
+
text_position: IDNamePair;
|
|
102
|
+
};
|
|
103
|
+
export type ProductInfoConfig = {
|
|
104
|
+
title: DisplayConfig;
|
|
105
|
+
sku: DisplayConfig;
|
|
106
|
+
stock_status: SimpleDisplayConfig;
|
|
107
|
+
inventory: InventoryConfig;
|
|
108
|
+
description: DisplayConfig;
|
|
109
|
+
variants: DisplayConfig;
|
|
110
|
+
price: DisplayConfig;
|
|
111
|
+
actions: ProductActionsConfig;
|
|
112
|
+
discount_badge?: SimpleDisplayConfig;
|
|
113
|
+
quantity_selector?: QuantitySelectorConfig;
|
|
114
|
+
specifications?: SimpleDisplayConfig;
|
|
115
|
+
};
|
|
116
|
+
export type ProductSettings = {
|
|
117
|
+
product_info: ProductInfoConfig;
|
|
118
|
+
};
|
|
119
|
+
export type FooterLogoConfig = {
|
|
120
|
+
src: string;
|
|
121
|
+
alt: string;
|
|
122
|
+
width: number;
|
|
123
|
+
height: number;
|
|
124
|
+
};
|
|
125
|
+
export type FooterColumnOne = {
|
|
126
|
+
logo: FooterLogoConfig;
|
|
127
|
+
socials: any[];
|
|
128
|
+
};
|
|
129
|
+
export type FooterSettings = {
|
|
130
|
+
column_one: FooterColumnOne;
|
|
131
|
+
};
|
|
132
|
+
export type EcommerceSettings = {
|
|
133
|
+
maintenance: boolean;
|
|
134
|
+
cart: CartSettings;
|
|
135
|
+
price: PriceSettings;
|
|
136
|
+
i18n: I18nSettings;
|
|
137
|
+
header: HeaderSettings;
|
|
138
|
+
homepage: HomepageSettings;
|
|
139
|
+
category: CategorySettings;
|
|
140
|
+
product: ProductSettings;
|
|
141
|
+
footer: FooterSettings;
|
|
142
|
+
theme?: any;
|
|
143
|
+
};
|
|
144
|
+
export type EcommEnvSettings = {
|
|
145
|
+
dev: EcommerceSettings | null;
|
|
146
|
+
live: EcommerceSettings | null;
|
|
147
|
+
};
|
|
148
|
+
export type CompanyInfo = {
|
|
149
|
+
vat_number: string;
|
|
150
|
+
legal_name: string;
|
|
151
|
+
company_name: string;
|
|
152
|
+
address: string;
|
|
153
|
+
city: string;
|
|
154
|
+
zip_code: string;
|
|
155
|
+
phone: string;
|
|
156
|
+
email: string;
|
|
157
|
+
legal_representative: string;
|
|
158
|
+
additional_info?: Record<string, any>;
|
|
159
|
+
};
|
|
160
|
+
export type Documentation = {
|
|
161
|
+
terms_of_service: string | null;
|
|
162
|
+
privacy_policy: string | null;
|
|
163
|
+
};
|
|
164
|
+
export type EcommerceIntegrationUser = {
|
|
165
|
+
project_uuid: string;
|
|
166
|
+
base_domain: string;
|
|
167
|
+
custom_domains: string[];
|
|
168
|
+
company: CompanyInfo;
|
|
169
|
+
merchant_description: string;
|
|
170
|
+
mcc: string[];
|
|
171
|
+
documentation: Documentation;
|
|
172
|
+
product_types: string[];
|
|
173
|
+
settings: EcommEnvSettings;
|
|
174
|
+
data: Record<string, any>;
|
|
175
|
+
created_at: string;
|
|
176
|
+
updated_at: string;
|
|
177
|
+
deleted_at?: string | null;
|
|
178
|
+
};
|
|
179
|
+
export type UpdateEcommerceSettingsRequest = {
|
|
180
|
+
base_domain?: string;
|
|
181
|
+
custom_domains?: string[];
|
|
182
|
+
company?: Partial<CompanyInfo>;
|
|
183
|
+
merchant_description?: string;
|
|
184
|
+
mcc?: string[];
|
|
185
|
+
product_types?: string[];
|
|
186
|
+
documentation?: Partial<Documentation>;
|
|
187
|
+
settings?: Partial<EcommEnvSettings>;
|
|
188
|
+
};
|
|
189
|
+
export type CheckDomainResponse = {
|
|
190
|
+
domain: string;
|
|
191
|
+
available: boolean;
|
|
192
|
+
};
|
|
193
|
+
export type AddDomainResponse = {
|
|
194
|
+
integration: EcommerceIntegrationUser;
|
|
195
|
+
verification_token: string;
|
|
196
|
+
};
|
|
197
|
+
export type DomainsResponse = {
|
|
198
|
+
domains: string[];
|
|
199
|
+
};
|