@ptkl/sdk 1.3.4 → 1.5.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 -22
- package/dist/index.0.9.js +75 -24
- 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 -22
- package/dist/v0.10/index.esm.js +94 -23
- 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 +75 -24
- package/dist/v0.9/index.esm.js +75 -25
- 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/index.0.10.js
CHANGED
|
@@ -48,11 +48,15 @@ var ProtokolSDK010 = (function (exports, axios) {
|
|
|
48
48
|
token = (_c = __global_env__ === null || __global_env__ === void 0 ? void 0 : __global_env__.PROJECT_API_TOKEN) !== null && _c !== void 0 ? _c : token;
|
|
49
49
|
project_uuid = __global_env__ === null || __global_env__ === void 0 ? void 0 : __global_env__.PROJECT_UUID;
|
|
50
50
|
if (isBrowser) {
|
|
51
|
-
if (sessionStorage.getItem('protokol_context')
|
|
52
|
-
headers['X-Project-Env'] = (_d = sessionStorage.getItem('forge_app_env')) !== null && _d !== void 0 ? _d :
|
|
51
|
+
if (sessionStorage.getItem('protokol_context') === 'forge') {
|
|
52
|
+
headers['X-Project-Env'] = (_d = sessionStorage.getItem('forge_app_env')) !== null && _d !== void 0 ? _d : 'dev';
|
|
53
|
+
// pick up forge actor token — overrides any other token source
|
|
54
|
+
const forgeToken = sessionStorage.getItem('forge_actor_token');
|
|
55
|
+
if (forgeToken)
|
|
56
|
+
token = forgeToken;
|
|
53
57
|
}
|
|
54
58
|
else {
|
|
55
|
-
headers['X-Project-Env'] = (_e = localStorage.getItem('current_env')) !== null && _e !== void 0 ? _e :
|
|
59
|
+
headers['X-Project-Env'] = (_e = localStorage.getItem('current_env')) !== null && _e !== void 0 ? _e : 'dev';
|
|
56
60
|
}
|
|
57
61
|
}
|
|
58
62
|
}
|
|
@@ -78,7 +82,6 @@ var ProtokolSDK010 = (function (exports, axios) {
|
|
|
78
82
|
...headers,
|
|
79
83
|
'Content-Type': 'application/json',
|
|
80
84
|
},
|
|
81
|
-
withCredentials: true,
|
|
82
85
|
});
|
|
83
86
|
super(client);
|
|
84
87
|
this.env = null;
|
|
@@ -88,6 +91,11 @@ var ProtokolSDK010 = (function (exports, axios) {
|
|
|
88
91
|
}
|
|
89
92
|
|
|
90
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
|
+
*/
|
|
91
99
|
constructor(ref = null) {
|
|
92
100
|
super();
|
|
93
101
|
this.ref = ref;
|
|
@@ -233,7 +241,7 @@ var ProtokolSDK010 = (function (exports, axios) {
|
|
|
233
241
|
async updateMany(data, options) {
|
|
234
242
|
return await this.client.patch(`/v4/system/component/${this.ref}/models/bulk`, {
|
|
235
243
|
data,
|
|
236
|
-
options
|
|
244
|
+
options,
|
|
237
245
|
});
|
|
238
246
|
}
|
|
239
247
|
/**
|
|
@@ -638,16 +646,6 @@ var ProtokolSDK010 = (function (exports, axios) {
|
|
|
638
646
|
async update(uuid, update) {
|
|
639
647
|
return await this.client.patch(`/v1/system/function/${uuid}`, update);
|
|
640
648
|
}
|
|
641
|
-
/**
|
|
642
|
-
* Run platform function
|
|
643
|
-
*
|
|
644
|
-
* @param id - Function ID
|
|
645
|
-
* @param d - Object containing input data, query parameters, and headers
|
|
646
|
-
* @returns - Function result
|
|
647
|
-
*
|
|
648
|
-
* @example
|
|
649
|
-
* const result = await platform.function().run("myFunction", {input: { foo: "bar" }})
|
|
650
|
-
*/
|
|
651
649
|
async run(id, d) {
|
|
652
650
|
const { data } = await this.client.post(`/v1/system/function/run/${id}`, d.input, {
|
|
653
651
|
params: d.query,
|
|
@@ -1102,10 +1100,25 @@ var ProtokolSDK010 = (function (exports, axios) {
|
|
|
1102
1100
|
}
|
|
1103
1101
|
|
|
1104
1102
|
class System extends PlatformBaseClient {
|
|
1105
|
-
|
|
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) {
|
|
1106
1120
|
return await this.client.post("/v3/system/resource-resolver", {
|
|
1107
|
-
|
|
1108
|
-
ref,
|
|
1121
|
+
prn,
|
|
1109
1122
|
format,
|
|
1110
1123
|
});
|
|
1111
1124
|
}
|
|
@@ -1407,11 +1420,15 @@ var ProtokolSDK010 = (function (exports, axios) {
|
|
|
1407
1420
|
env = env !== null && env !== void 0 ? env : __global_env__ === null || __global_env__ === void 0 ? void 0 : __global_env__.PROJECT_ENV;
|
|
1408
1421
|
token = token !== null && token !== void 0 ? token : __global_env__ === null || __global_env__ === void 0 ? void 0 : __global_env__.PROJECT_API_TOKEN;
|
|
1409
1422
|
if (isBrowser) {
|
|
1410
|
-
if (sessionStorage.getItem('protokol_context')
|
|
1411
|
-
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;
|
|
1412
1429
|
}
|
|
1413
1430
|
else {
|
|
1414
|
-
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';
|
|
1415
1432
|
}
|
|
1416
1433
|
}
|
|
1417
1434
|
}
|
|
@@ -1436,7 +1453,6 @@ var ProtokolSDK010 = (function (exports, axios) {
|
|
|
1436
1453
|
headers: {
|
|
1437
1454
|
...headers,
|
|
1438
1455
|
},
|
|
1439
|
-
withCredentials: true,
|
|
1440
1456
|
});
|
|
1441
1457
|
super(client);
|
|
1442
1458
|
this.env = null;
|
|
@@ -3207,6 +3223,57 @@ var ProtokolSDK010 = (function (exports, axios) {
|
|
|
3207
3223
|
}
|
|
3208
3224
|
}
|
|
3209
3225
|
|
|
3226
|
+
class Ecommerce extends IntegrationsBaseClient {
|
|
3227
|
+
/**
|
|
3228
|
+
* Get the ecommerce integration user for the current project.
|
|
3229
|
+
*/
|
|
3230
|
+
async get() {
|
|
3231
|
+
return await this.client.get(`/v1/ecomm/user`);
|
|
3232
|
+
}
|
|
3233
|
+
/**
|
|
3234
|
+
* Update ecommerce integration settings (onboarding or partial update).
|
|
3235
|
+
*/
|
|
3236
|
+
async update(req) {
|
|
3237
|
+
return await this.client.patch(`/v1/ecomm/user`, req);
|
|
3238
|
+
}
|
|
3239
|
+
/**
|
|
3240
|
+
* Check whether a base domain subdomain is available.
|
|
3241
|
+
*/
|
|
3242
|
+
async checkBaseDomain(domain) {
|
|
3243
|
+
return await this.client.post(`/v1/ecomm/base-domain/check`, { domain });
|
|
3244
|
+
}
|
|
3245
|
+
/**
|
|
3246
|
+
* Add a custom domain (returns a verification token for DNS validation).
|
|
3247
|
+
*/
|
|
3248
|
+
async addCustomDomain(domain) {
|
|
3249
|
+
return await this.client.post(`/v1/ecomm/domains`, { domain });
|
|
3250
|
+
}
|
|
3251
|
+
/**
|
|
3252
|
+
* Validate a custom domain with its verification token.
|
|
3253
|
+
*/
|
|
3254
|
+
async validateCustomDomain(domain, token) {
|
|
3255
|
+
return await this.client.post(`/v1/ecomm/domains/validate`, { domain, token });
|
|
3256
|
+
}
|
|
3257
|
+
/**
|
|
3258
|
+
* Remove a custom domain.
|
|
3259
|
+
*/
|
|
3260
|
+
async removeCustomDomain(domain) {
|
|
3261
|
+
return await this.client.delete(`/v1/ecomm/domains`, { data: { domain } });
|
|
3262
|
+
}
|
|
3263
|
+
/**
|
|
3264
|
+
* List pending (unvalidated) custom domains.
|
|
3265
|
+
*/
|
|
3266
|
+
async getPendingDomains() {
|
|
3267
|
+
return await this.client.get(`/v1/ecomm/domains/pending`);
|
|
3268
|
+
}
|
|
3269
|
+
/**
|
|
3270
|
+
* List validated custom domains.
|
|
3271
|
+
*/
|
|
3272
|
+
async getValidatedDomains() {
|
|
3273
|
+
return await this.client.get(`/v1/ecomm/domains/validated`);
|
|
3274
|
+
}
|
|
3275
|
+
}
|
|
3276
|
+
|
|
3210
3277
|
class Integrations extends IntegrationsBaseClient {
|
|
3211
3278
|
constructor(options) {
|
|
3212
3279
|
super(options);
|
|
@@ -3217,6 +3284,7 @@ var ProtokolSDK010 = (function (exports, axios) {
|
|
|
3217
3284
|
'nbs': new NBS().setClient(this.client),
|
|
3218
3285
|
'protokol-payments': new Payments().setClient(this.client),
|
|
3219
3286
|
'protokol-minimax': new Minimax().setClient(this.client),
|
|
3287
|
+
'protokol-ecommerce': new Ecommerce().setClient(this.client),
|
|
3220
3288
|
};
|
|
3221
3289
|
}
|
|
3222
3290
|
getDMS() {
|
|
@@ -3240,6 +3308,9 @@ var ProtokolSDK010 = (function (exports, axios) {
|
|
|
3240
3308
|
getSerbiaMinFin() {
|
|
3241
3309
|
return this.getInterfaceOf('serbia-minfin');
|
|
3242
3310
|
}
|
|
3311
|
+
getEcommerce() {
|
|
3312
|
+
return this.getInterfaceOf('protokol-ecommerce');
|
|
3313
|
+
}
|
|
3243
3314
|
async isInstalled(id) {
|
|
3244
3315
|
const { data } = await this.client.get("/v1/integrations");
|
|
3245
3316
|
return data.find((i) => i.id == id) !== undefined;
|
|
@@ -3285,6 +3356,7 @@ var ProtokolSDK010 = (function (exports, axios) {
|
|
|
3285
3356
|
exports.ComponentUtils = ComponentUtils;
|
|
3286
3357
|
exports.Config = Config;
|
|
3287
3358
|
exports.DMS = DMS;
|
|
3359
|
+
exports.Ecommerce = Ecommerce;
|
|
3288
3360
|
exports.Forge = Forge;
|
|
3289
3361
|
exports.Functions = Functions;
|
|
3290
3362
|
exports.Integration = Integrations;
|
package/dist/index.0.9.js
CHANGED
|
@@ -48,11 +48,15 @@ var ProtokolSDK09 = (function (exports, axios) {
|
|
|
48
48
|
token = token !== null && token !== void 0 ? token : __global_env__ === null || __global_env__ === void 0 ? void 0 : __global_env__.PROJECT_API_TOKEN;
|
|
49
49
|
project_uuid = __global_env__ === null || __global_env__ === void 0 ? void 0 : __global_env__.PROJECT_UUID;
|
|
50
50
|
if (isBrowser) {
|
|
51
|
-
if (sessionStorage.getItem('protokol_context')
|
|
52
|
-
headers['X-Project-Env'] = (_b = sessionStorage.getItem('forge_app_env')) !== null && _b !== void 0 ? _b :
|
|
51
|
+
if (sessionStorage.getItem('protokol_context') === 'forge') {
|
|
52
|
+
headers['X-Project-Env'] = (_b = sessionStorage.getItem('forge_app_env')) !== null && _b !== void 0 ? _b : 'dev';
|
|
53
|
+
// pick up forge actor token — overrides any other token source
|
|
54
|
+
const forgeToken = sessionStorage.getItem('forge_actor_token');
|
|
55
|
+
if (forgeToken)
|
|
56
|
+
token = forgeToken;
|
|
53
57
|
}
|
|
54
58
|
else {
|
|
55
|
-
headers['X-Project-Env'] = (_c = localStorage.getItem('current_env')) !== null && _c !== void 0 ? _c :
|
|
59
|
+
headers['X-Project-Env'] = (_c = localStorage.getItem('current_env')) !== null && _c !== void 0 ? _c : 'dev';
|
|
56
60
|
}
|
|
57
61
|
}
|
|
58
62
|
}
|
|
@@ -77,8 +81,7 @@ var ProtokolSDK09 = (function (exports, axios) {
|
|
|
77
81
|
headers: {
|
|
78
82
|
...headers,
|
|
79
83
|
'Content-Type': 'application/json',
|
|
80
|
-
}
|
|
81
|
-
withCredentials: true,
|
|
84
|
+
}
|
|
82
85
|
});
|
|
83
86
|
super(client);
|
|
84
87
|
this.env = null;
|
|
@@ -236,7 +239,7 @@ var ProtokolSDK09 = (function (exports, axios) {
|
|
|
236
239
|
async updateMany(data, options) {
|
|
237
240
|
return await this.client.patch(`${this.getComponentPath()}/models/bulk`, {
|
|
238
241
|
data,
|
|
239
|
-
options
|
|
242
|
+
options,
|
|
240
243
|
});
|
|
241
244
|
}
|
|
242
245
|
/**
|
|
@@ -470,16 +473,6 @@ var ProtokolSDK09 = (function (exports, axios) {
|
|
|
470
473
|
async update(uuid, update) {
|
|
471
474
|
return await this.client.patch(`/v1/system/function/${uuid}`, update);
|
|
472
475
|
}
|
|
473
|
-
/**
|
|
474
|
-
* Run platform function
|
|
475
|
-
*
|
|
476
|
-
* @param id - Function ID
|
|
477
|
-
* @param d - Object containing input data, query parameters, and headers
|
|
478
|
-
* @returns - Function result
|
|
479
|
-
*
|
|
480
|
-
* @example
|
|
481
|
-
* const result = await platform.function().run("myFunction", {input: { foo: "bar" }})
|
|
482
|
-
*/
|
|
483
476
|
async run(id, d) {
|
|
484
477
|
const { data } = await this.client.post(`/v1/system/function/run/${id}`, d.input, {
|
|
485
478
|
params: d.query,
|
|
@@ -923,10 +916,9 @@ var ProtokolSDK09 = (function (exports, axios) {
|
|
|
923
916
|
}
|
|
924
917
|
|
|
925
918
|
class System extends PlatformBaseClient {
|
|
926
|
-
async resourceResolver(
|
|
919
|
+
async resourceResolver(prn, format) {
|
|
927
920
|
return await this.client.post("/v3/system/resource-resolver", {
|
|
928
|
-
|
|
929
|
-
ref,
|
|
921
|
+
prn,
|
|
930
922
|
format,
|
|
931
923
|
});
|
|
932
924
|
}
|
|
@@ -1253,11 +1245,15 @@ var ProtokolSDK09 = (function (exports, axios) {
|
|
|
1253
1245
|
env = env !== null && env !== void 0 ? env : __global_env__ === null || __global_env__ === void 0 ? void 0 : __global_env__.PROJECT_ENV;
|
|
1254
1246
|
token = token !== null && token !== void 0 ? token : __global_env__ === null || __global_env__ === void 0 ? void 0 : __global_env__.PROJECT_API_TOKEN;
|
|
1255
1247
|
if (isBrowser) {
|
|
1256
|
-
if (sessionStorage.getItem('protokol_context')
|
|
1257
|
-
headers['X-Project-Env'] = (_b = sessionStorage.getItem('forge_app_env')) !== null && _b !== void 0 ? _b :
|
|
1248
|
+
if (sessionStorage.getItem('protokol_context') === 'forge') {
|
|
1249
|
+
headers['X-Project-Env'] = (_b = sessionStorage.getItem('forge_app_env')) !== null && _b !== void 0 ? _b : 'dev';
|
|
1250
|
+
// pick up forge actor token — overrides any other token source
|
|
1251
|
+
const forgeToken = sessionStorage.getItem('forge_actor_token');
|
|
1252
|
+
if (forgeToken)
|
|
1253
|
+
token = forgeToken;
|
|
1258
1254
|
}
|
|
1259
1255
|
else {
|
|
1260
|
-
headers['X-Project-Env'] = (_c = localStorage.getItem('current_env')) !== null && _c !== void 0 ? _c :
|
|
1256
|
+
headers['X-Project-Env'] = (_c = localStorage.getItem('current_env')) !== null && _c !== void 0 ? _c : 'dev';
|
|
1261
1257
|
}
|
|
1262
1258
|
}
|
|
1263
1259
|
}
|
|
@@ -1281,8 +1277,7 @@ var ProtokolSDK09 = (function (exports, axios) {
|
|
|
1281
1277
|
timeout: 30000,
|
|
1282
1278
|
headers: {
|
|
1283
1279
|
...headers,
|
|
1284
|
-
}
|
|
1285
|
-
withCredentials: true,
|
|
1280
|
+
}
|
|
1286
1281
|
});
|
|
1287
1282
|
super(client);
|
|
1288
1283
|
this.env = null;
|
|
@@ -2891,6 +2886,57 @@ var ProtokolSDK09 = (function (exports, axios) {
|
|
|
2891
2886
|
}
|
|
2892
2887
|
}
|
|
2893
2888
|
|
|
2889
|
+
class Ecommerce extends IntegrationsBaseClient {
|
|
2890
|
+
/**
|
|
2891
|
+
* Get the ecommerce integration user for the current project.
|
|
2892
|
+
*/
|
|
2893
|
+
async get() {
|
|
2894
|
+
return await this.client.get(`/v1/ecomm/user`);
|
|
2895
|
+
}
|
|
2896
|
+
/**
|
|
2897
|
+
* Update ecommerce integration settings (onboarding or partial update).
|
|
2898
|
+
*/
|
|
2899
|
+
async update(req) {
|
|
2900
|
+
return await this.client.patch(`/v1/ecomm/user`, req);
|
|
2901
|
+
}
|
|
2902
|
+
/**
|
|
2903
|
+
* Check whether a base domain subdomain is available.
|
|
2904
|
+
*/
|
|
2905
|
+
async checkBaseDomain(domain) {
|
|
2906
|
+
return await this.client.post(`/v1/ecomm/base-domain/check`, { domain });
|
|
2907
|
+
}
|
|
2908
|
+
/**
|
|
2909
|
+
* Add a custom domain (returns a verification token for DNS validation).
|
|
2910
|
+
*/
|
|
2911
|
+
async addCustomDomain(domain) {
|
|
2912
|
+
return await this.client.post(`/v1/ecomm/domains`, { domain });
|
|
2913
|
+
}
|
|
2914
|
+
/**
|
|
2915
|
+
* Validate a custom domain with its verification token.
|
|
2916
|
+
*/
|
|
2917
|
+
async validateCustomDomain(domain, token) {
|
|
2918
|
+
return await this.client.post(`/v1/ecomm/domains/validate`, { domain, token });
|
|
2919
|
+
}
|
|
2920
|
+
/**
|
|
2921
|
+
* Remove a custom domain.
|
|
2922
|
+
*/
|
|
2923
|
+
async removeCustomDomain(domain) {
|
|
2924
|
+
return await this.client.delete(`/v1/ecomm/domains`, { data: { domain } });
|
|
2925
|
+
}
|
|
2926
|
+
/**
|
|
2927
|
+
* List pending (unvalidated) custom domains.
|
|
2928
|
+
*/
|
|
2929
|
+
async getPendingDomains() {
|
|
2930
|
+
return await this.client.get(`/v1/ecomm/domains/pending`);
|
|
2931
|
+
}
|
|
2932
|
+
/**
|
|
2933
|
+
* List validated custom domains.
|
|
2934
|
+
*/
|
|
2935
|
+
async getValidatedDomains() {
|
|
2936
|
+
return await this.client.get(`/v1/ecomm/domains/validated`);
|
|
2937
|
+
}
|
|
2938
|
+
}
|
|
2939
|
+
|
|
2894
2940
|
// import integrations
|
|
2895
2941
|
class Integrations extends IntegrationsBaseClient {
|
|
2896
2942
|
constructor(options) {
|
|
@@ -2903,6 +2949,7 @@ var ProtokolSDK09 = (function (exports, axios) {
|
|
|
2903
2949
|
'serbia-utilities': new SerbiaUtil().setClient(this.client),
|
|
2904
2950
|
'protokol-payments': new Payments().setClient(this.client),
|
|
2905
2951
|
'protokol-minimax': new Minimax().setClient(this.client),
|
|
2952
|
+
'protokol-ecommerce': new Ecommerce().setClient(this.client),
|
|
2906
2953
|
};
|
|
2907
2954
|
}
|
|
2908
2955
|
getSerbiaUtilities() {
|
|
@@ -2926,6 +2973,9 @@ var ProtokolSDK09 = (function (exports, axios) {
|
|
|
2926
2973
|
getMinimax() {
|
|
2927
2974
|
return this.getInterfaceOf('protokol-minimax');
|
|
2928
2975
|
}
|
|
2976
|
+
getEcommerce() {
|
|
2977
|
+
return this.getInterfaceOf('protokol-ecommerce');
|
|
2978
|
+
}
|
|
2929
2979
|
async isInstalled(id) {
|
|
2930
2980
|
const { data } = await this.client.get("/v1/integrations");
|
|
2931
2981
|
return data.find((i) => i.id == id) !== undefined;
|
|
@@ -2950,6 +3000,7 @@ var ProtokolSDK09 = (function (exports, axios) {
|
|
|
2950
3000
|
exports.ComponentUtils = ComponentUtils;
|
|
2951
3001
|
exports.Config = Config;
|
|
2952
3002
|
exports.DMS = DMS;
|
|
3003
|
+
exports.Ecommerce = Ecommerce;
|
|
2953
3004
|
exports.Forge = Forge;
|
|
2954
3005
|
exports.Functions = Functions;
|
|
2955
3006
|
exports.Integration = Integrations;
|
package/dist/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ptkl/sdk",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.5.0",
|
|
4
4
|
"scripts": {
|
|
5
5
|
"build": "rollup -c",
|
|
6
6
|
"build:monaco": "npm run build && node scripts/generate-monaco-types.cjs",
|
|
@@ -13,17 +13,17 @@
|
|
|
13
13
|
".": {
|
|
14
14
|
"import": "./dist/v0.9/index.esm.js",
|
|
15
15
|
"require": "./dist/v0.9/index.cjs.js",
|
|
16
|
-
"types": "./dist/v0.9/index.d.ts"
|
|
16
|
+
"types": "./dist/v0.9/api/index.d.ts"
|
|
17
17
|
},
|
|
18
18
|
"./beta": {
|
|
19
19
|
"import": "./dist/v0.10/index.esm.js",
|
|
20
20
|
"require": "./dist/v0.10/index.cjs.js",
|
|
21
|
-
"types": "./dist/v0.10/index.d.ts"
|
|
21
|
+
"types": "./dist/v0.10/api/index.d.ts"
|
|
22
22
|
}
|
|
23
23
|
},
|
|
24
24
|
"main": "./dist/v0.10/index.cjs.js",
|
|
25
25
|
"module": "./dist/v0.10/index.esm.js",
|
|
26
|
-
"types": "./dist/v0.10/index.d.ts",
|
|
26
|
+
"types": "./dist/v0.10/api/index.d.ts",
|
|
27
27
|
"author": "protokol.io",
|
|
28
28
|
"license": "ISC",
|
|
29
29
|
"type": "module",
|
|
@@ -44,6 +44,7 @@
|
|
|
44
44
|
"typescript": "^5.6.3"
|
|
45
45
|
},
|
|
46
46
|
"dependencies": {
|
|
47
|
+
"@ptkl/sdk": "file:",
|
|
47
48
|
"@rollup/plugin-replace": "^6.0.2",
|
|
48
49
|
"axios": "^1.7.7",
|
|
49
50
|
"dom-parser": "^1.1.5",
|
|
@@ -1,9 +1,22 @@
|
|
|
1
1
|
import { FindParams, FindOptions, FindResponse, FindAdvancedParams, FindAggregateParams, Model, UpdateOptions, ModifyOptions, StreamHandler, AggregateChainable, ComponentOptions, UpdateManyOptions, CreateManyOptions, Extension, Policy } from "../types/component";
|
|
2
2
|
import PlatformBaseClient from "./platformBaseClient";
|
|
3
3
|
import { AxiosResponse } from "axios";
|
|
4
|
-
|
|
4
|
+
import type { ComponentModels, ComponentFunctions } from "../types/functions";
|
|
5
|
+
type ComponentModel<C extends string> = C extends keyof ComponentModels ? ComponentModels[C] : Model;
|
|
6
|
+
type ComponentFnInput<C extends string, F extends string> = C extends keyof ComponentFunctions ? F extends keyof ComponentFunctions[C] ? ComponentFunctions[C][F] extends {
|
|
7
|
+
input: infer I;
|
|
8
|
+
} ? I : any : any : any;
|
|
9
|
+
type ComponentFnOutput<C extends string, F extends string> = C extends keyof ComponentFunctions ? F extends keyof ComponentFunctions[C] ? ComponentFunctions[C][F] extends {
|
|
10
|
+
output: infer O;
|
|
11
|
+
} ? O : any : any : any;
|
|
12
|
+
export default class Component<C extends string = string> extends PlatformBaseClient {
|
|
5
13
|
private ref;
|
|
6
|
-
|
|
14
|
+
/**
|
|
15
|
+
* @param ref - Component ref (e.g. "ecommerce::order"). Passing a string
|
|
16
|
+
* literal lets TypeScript infer the generic C and type find/create/function
|
|
17
|
+
* results accordingly.
|
|
18
|
+
*/
|
|
19
|
+
constructor(ref?: C | null);
|
|
7
20
|
/**
|
|
8
21
|
* Find method to search for models
|
|
9
22
|
*
|
|
@@ -25,7 +38,12 @@ export default class Component extends PlatformBaseClient {
|
|
|
25
38
|
* }
|
|
26
39
|
* )
|
|
27
40
|
**/
|
|
28
|
-
find(filters: FindParams, opts?: FindOptions): Promise<AxiosResponse<
|
|
41
|
+
find(filters: FindParams, opts?: FindOptions): Promise<AxiosResponse<{
|
|
42
|
+
items: ComponentModel<C>[];
|
|
43
|
+
total: number;
|
|
44
|
+
page: number;
|
|
45
|
+
pages: number;
|
|
46
|
+
}>>;
|
|
29
47
|
/**
|
|
30
48
|
* FindOne method to search for a single model
|
|
31
49
|
*
|
|
@@ -39,14 +57,14 @@ export default class Component extends PlatformBaseClient {
|
|
|
39
57
|
* name: "John Doe",
|
|
40
58
|
* })
|
|
41
59
|
**/
|
|
42
|
-
findOne(filter: FindAdvancedParams, opts
|
|
60
|
+
findOne(filter: FindAdvancedParams, opts?: FindOptions): Promise<ComponentModel<C> | null>;
|
|
43
61
|
/**
|
|
44
62
|
* Get model by uuid
|
|
45
63
|
*
|
|
46
64
|
* @param uuid string - The uuid of the model
|
|
47
65
|
* @returns (Promise<Model>)
|
|
48
66
|
*/
|
|
49
|
-
get(uuid: string): Promise<AxiosResponse<
|
|
67
|
+
get(uuid: string): Promise<AxiosResponse<ComponentModel<C>>>;
|
|
50
68
|
/**
|
|
51
69
|
* Update model by uuid
|
|
52
70
|
*
|
|
@@ -71,7 +89,7 @@ export default class Component extends PlatformBaseClient {
|
|
|
71
89
|
* $addToSet: { roles: "admin" }
|
|
72
90
|
* }, opts)
|
|
73
91
|
*/
|
|
74
|
-
update(uuid: string, data: Record<string, any>, options
|
|
92
|
+
update(uuid: string, data: Record<string, any>, options?: UpdateOptions): Promise<ComponentModel<C>>;
|
|
75
93
|
/**
|
|
76
94
|
* Update many models
|
|
77
95
|
*
|
|
@@ -79,7 +97,7 @@ export default class Component extends PlatformBaseClient {
|
|
|
79
97
|
* @param options
|
|
80
98
|
* @returns
|
|
81
99
|
*/
|
|
82
|
-
updateMany(data: Record<string, any>[], options
|
|
100
|
+
updateMany(data: Record<string, any>[], options?: UpdateManyOptions): Promise<AxiosResponse<any, any>>;
|
|
83
101
|
/**
|
|
84
102
|
* Create many models
|
|
85
103
|
*
|
|
@@ -87,7 +105,7 @@ export default class Component extends PlatformBaseClient {
|
|
|
87
105
|
* @param options
|
|
88
106
|
* @returns
|
|
89
107
|
*/
|
|
90
|
-
createMany(data: Record<string, any>[], options
|
|
108
|
+
createMany(data: Record<string, any>[], options?: CreateManyOptions): Promise<AxiosResponse<any, any>>;
|
|
91
109
|
/**
|
|
92
110
|
* Modify models by filters
|
|
93
111
|
*
|
|
@@ -106,7 +124,7 @@ export default class Component extends PlatformBaseClient {
|
|
|
106
124
|
* { upsert: false }
|
|
107
125
|
* )
|
|
108
126
|
*/
|
|
109
|
-
modify(filters: Record<string, any>, data: Record<string, any>, options
|
|
127
|
+
modify(filters: Record<string, any>, data: Record<string, any>, options?: ModifyOptions): Promise<AxiosResponse<any, any>>;
|
|
110
128
|
/**
|
|
111
129
|
* Concurrent update model by uuid with optimistic locking
|
|
112
130
|
*
|
|
@@ -126,8 +144,8 @@ export default class Component extends PlatformBaseClient {
|
|
|
126
144
|
* $inc: { retry_count: 1 }
|
|
127
145
|
* }, opts)
|
|
128
146
|
*/
|
|
129
|
-
concurrentUpdate(uuid: string, version: number, data: Record<string, any>, options
|
|
130
|
-
create(model: Record<string, any>): Promise<
|
|
147
|
+
concurrentUpdate(uuid: string, version: number, data: Record<string, any>, options?: UpdateOptions): Promise<AxiosResponse<any, any>>;
|
|
148
|
+
create(model: C extends keyof ComponentModels ? Partial<ComponentModels[C]> & Record<string, any> : Record<string, any>): Promise<ComponentModel<C>>;
|
|
131
149
|
delete(uuid: string): Promise<AxiosResponse<any, any>>;
|
|
132
150
|
/**
|
|
133
151
|
* Execute aggregate pipeline with optional streaming support
|
|
@@ -159,7 +177,7 @@ export default class Component extends PlatformBaseClient {
|
|
|
159
177
|
saveSettings(settings: any, version: string): Promise<AxiosResponse<any, any>>;
|
|
160
178
|
saveTemplatesDist(version: string, sdkVersion: string, engine: string, dist: Record<string, string>): Promise<any>;
|
|
161
179
|
workflow(event: string, input: any): Promise<AxiosResponse<any, any>>;
|
|
162
|
-
function(name:
|
|
180
|
+
function<F extends string>(name: F, input?: ComponentFnInput<C, F>): Promise<ComponentFnOutput<C, F>>;
|
|
163
181
|
revisions(uuid: string): Promise<AxiosResponse<any, any>>;
|
|
164
182
|
/**
|
|
165
183
|
* Get a single extension by name from the component
|
|
@@ -1,18 +1,30 @@
|
|
|
1
1
|
import PlatformBaseClient from "./platformBaseClient";
|
|
2
|
+
import type { PlatformFunctions, FunctionInput, FunctionOutput } from "../types/functions";
|
|
2
3
|
export default class Functions extends PlatformBaseClient {
|
|
3
4
|
list(): Promise<any>;
|
|
4
5
|
get(ref: string): Promise<any>;
|
|
5
6
|
update(uuid: string, update: any): Promise<any>;
|
|
6
7
|
/**
|
|
7
|
-
* Run platform function
|
|
8
|
+
* Run a platform function.
|
|
8
9
|
*
|
|
9
|
-
*
|
|
10
|
-
*
|
|
11
|
-
*
|
|
10
|
+
* When the function name is registered in `PlatformFunctions`, input and
|
|
11
|
+
* output types are inferred automatically from the IDL signature.
|
|
12
|
+
* Register signatures by running `ptkl generate-types` in your project.
|
|
12
13
|
*
|
|
13
14
|
* @example
|
|
14
|
-
*
|
|
15
|
+
* // Typed — "send_email" is registered in PlatformFunctions
|
|
16
|
+
* const result = await fn.run("send_email", { input: { body: "hi", to: "a@b.com" } })
|
|
17
|
+
* // result: { status: boolean }
|
|
18
|
+
*
|
|
19
|
+
* @example
|
|
20
|
+
* // Untyped fallback for unregistered names
|
|
21
|
+
* const result = await fn.run("unknown_func", { input: { foo: "bar" } })
|
|
15
22
|
*/
|
|
23
|
+
run<K extends keyof PlatformFunctions>(id: K, d: {
|
|
24
|
+
input?: FunctionInput<K>;
|
|
25
|
+
query?: Record<string, string>;
|
|
26
|
+
headers?: Record<string, string>;
|
|
27
|
+
}): Promise<FunctionOutput<K>>;
|
|
16
28
|
run(id: string, d: {
|
|
17
29
|
input?: Record<string, any>;
|
|
18
30
|
query?: Record<string, string>;
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
export type { PlatformFunctions, PlatformFunction, FunctionInput, FunctionOutput, FunctionCallParams, ComponentModels, ComponentFunctions, ComponentModel, ComponentFunctionInput, ComponentFunctionOutput, } from '../types/functions';
|
|
1
2
|
export { default as Component } from './component';
|
|
2
3
|
export { default as Platform } from './platform';
|
|
3
4
|
export { default as Functions } from './functions';
|
|
@@ -22,3 +23,4 @@ export { default as SerbiaMinFin } from './integrations/serbia/minfin';
|
|
|
22
23
|
export { default as NBS } from './integrations/serbia/nbs';
|
|
23
24
|
export { default as VPFR } from './integrations/serbia/minfin/vpfr';
|
|
24
25
|
export { default as Mail } from './integrations/mail';
|
|
26
|
+
export { default as Ecommerce } from './integrations/ecommerce';
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import IntegrationsBaseClient from "../integrationsBaseClient";
|
|
2
|
+
import { EcommerceIntegrationUser, UpdateEcommerceSettingsRequest, CheckDomainResponse, AddDomainResponse, DomainsResponse } from "../../types/integrations/ecommerce";
|
|
3
|
+
export default class Ecommerce extends IntegrationsBaseClient {
|
|
4
|
+
/**
|
|
5
|
+
* Get the ecommerce integration user for the current project.
|
|
6
|
+
*/
|
|
7
|
+
get(): Promise<EcommerceIntegrationUser>;
|
|
8
|
+
/**
|
|
9
|
+
* Update ecommerce integration settings (onboarding or partial update).
|
|
10
|
+
*/
|
|
11
|
+
update(req: UpdateEcommerceSettingsRequest): Promise<EcommerceIntegrationUser>;
|
|
12
|
+
/**
|
|
13
|
+
* Check whether a base domain subdomain is available.
|
|
14
|
+
*/
|
|
15
|
+
checkBaseDomain(domain: string): Promise<CheckDomainResponse>;
|
|
16
|
+
/**
|
|
17
|
+
* Add a custom domain (returns a verification token for DNS validation).
|
|
18
|
+
*/
|
|
19
|
+
addCustomDomain(domain: string): Promise<AddDomainResponse>;
|
|
20
|
+
/**
|
|
21
|
+
* Validate a custom domain with its verification token.
|
|
22
|
+
*/
|
|
23
|
+
validateCustomDomain(domain: string, token: string): Promise<{
|
|
24
|
+
integration: EcommerceIntegrationUser;
|
|
25
|
+
message: string;
|
|
26
|
+
}>;
|
|
27
|
+
/**
|
|
28
|
+
* Remove a custom domain.
|
|
29
|
+
*/
|
|
30
|
+
removeCustomDomain(domain: string): Promise<{
|
|
31
|
+
integration: EcommerceIntegrationUser;
|
|
32
|
+
message: string;
|
|
33
|
+
}>;
|
|
34
|
+
/**
|
|
35
|
+
* List pending (unvalidated) custom domains.
|
|
36
|
+
*/
|
|
37
|
+
getPendingDomains(): Promise<DomainsResponse>;
|
|
38
|
+
/**
|
|
39
|
+
* List validated custom domains.
|
|
40
|
+
*/
|
|
41
|
+
getValidatedDomains(): Promise<DomainsResponse>;
|
|
42
|
+
}
|
|
@@ -6,6 +6,7 @@ import IntegrationsBaseClient from "./integrationsBaseClient";
|
|
|
6
6
|
import Payments from "./integrations/payments";
|
|
7
7
|
import Minimax from "./integrations/minimax";
|
|
8
8
|
import NBS from "./integrations/serbia/nbs";
|
|
9
|
+
import Ecommerce from "./integrations/ecommerce";
|
|
9
10
|
export default class Integrations extends IntegrationsBaseClient {
|
|
10
11
|
private integrations;
|
|
11
12
|
constructor(options?: {
|
|
@@ -20,6 +21,7 @@ export default class Integrations extends IntegrationsBaseClient {
|
|
|
20
21
|
getMail(): Mail;
|
|
21
22
|
getNBS(): NBS;
|
|
22
23
|
getSerbiaMinFin(): MinFin;
|
|
24
|
+
getEcommerce(): Ecommerce;
|
|
23
25
|
isInstalled(id: string): Promise<boolean>;
|
|
24
26
|
getInterfaceOf(id: string): any;
|
|
25
27
|
}
|
|
@@ -22,7 +22,7 @@ export default class Platform extends PlatformBaseClient {
|
|
|
22
22
|
user(): Users;
|
|
23
23
|
app(appType: string): Apps;
|
|
24
24
|
forge(): Forge;
|
|
25
|
-
component(ref:
|
|
25
|
+
component<C extends string>(ref: C): Component<C>;
|
|
26
26
|
componentUtils(): ComponentUtils;
|
|
27
27
|
ratchet(): Ratchet;
|
|
28
28
|
sandbox(): Sandbox;
|