@ptkl/sdk 1.3.2 → 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 +101 -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 +101 -20
- package/dist/v0.10/index.esm.js +101 -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
|
@@ -1,4 +1,41 @@
|
|
|
1
1
|
import PlatformBaseClient from "./platformBaseClient";
|
|
2
|
+
export type IDLAllResponse = {
|
|
3
|
+
components: Record<string, unknown>;
|
|
4
|
+
functions: Record<string, unknown>;
|
|
5
|
+
};
|
|
6
|
+
export type IDLValidateRequest = {
|
|
7
|
+
/** Compound ref, e.g. "component:ns::name", "pfn:fnName". Mutually exclusive with `idl`. */
|
|
8
|
+
ref?: string;
|
|
9
|
+
/** Inline IDL to validate against. Mutually exclusive with `ref`. */
|
|
10
|
+
idl?: Record<string, unknown>;
|
|
11
|
+
/** Field key to validate (required for component/extension refs, ignored for pfn). */
|
|
12
|
+
field?: string;
|
|
13
|
+
/** The value to validate. */
|
|
14
|
+
value: unknown;
|
|
15
|
+
};
|
|
16
|
+
export type IDLValidateResponse = {
|
|
17
|
+
valid: boolean;
|
|
18
|
+
errors?: Array<{
|
|
19
|
+
field?: string;
|
|
20
|
+
message: string;
|
|
21
|
+
}>;
|
|
22
|
+
};
|
|
2
23
|
export default class System extends PlatformBaseClient {
|
|
3
|
-
|
|
24
|
+
/**
|
|
25
|
+
* Returns all IDL definitions for the current project.
|
|
26
|
+
* Used by `ptkl generate-types` to emit typed `.d.ts` augmentations.
|
|
27
|
+
*/
|
|
28
|
+
idl(): Promise<{
|
|
29
|
+
data: IDLAllResponse;
|
|
30
|
+
}>;
|
|
31
|
+
/**
|
|
32
|
+
* Validates a value against an IDL — either by ref or with an inline IDL object.
|
|
33
|
+
* Returns `{ data: { valid: true } }` on success or
|
|
34
|
+
* `{ data: { valid: false, errors: [...] } }` on validation failure.
|
|
35
|
+
* Throws on HTTP errors (4xx/5xx).
|
|
36
|
+
*/
|
|
37
|
+
idlValidate(req: IDLValidateRequest): Promise<{
|
|
38
|
+
data: IDLValidateResponse;
|
|
39
|
+
}>;
|
|
40
|
+
resourceResolver(prn: string, format?: string): Promise<import("axios").AxiosResponse<any, any>>;
|
|
4
41
|
}
|
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;
|
|
@@ -19080,6 +19089,7 @@ class Component extends PlatformBaseClient {
|
|
|
19080
19089
|
* )
|
|
19081
19090
|
**/
|
|
19082
19091
|
async find(filters, opts) {
|
|
19092
|
+
var _a;
|
|
19083
19093
|
let payload = {
|
|
19084
19094
|
context: filters,
|
|
19085
19095
|
ref: this.ref,
|
|
@@ -19111,6 +19121,12 @@ class Component extends PlatformBaseClient {
|
|
|
19111
19121
|
dateTo: ctx.dateTo,
|
|
19112
19122
|
dateField: ctx.dateField,
|
|
19113
19123
|
};
|
|
19124
|
+
if (Object.keys(ctx.$adv || []).length > 0) {
|
|
19125
|
+
params.$adv = [(_a = ctx.$adv) !== null && _a !== void 0 ? _a : {}];
|
|
19126
|
+
}
|
|
19127
|
+
if (ctx.$aggregate && ctx.$aggregate.length > 0) {
|
|
19128
|
+
params.$aggregate = ctx.$aggregate;
|
|
19129
|
+
}
|
|
19114
19130
|
return await this.client.post(`/v4/system/component/${this.ref}/models`, {
|
|
19115
19131
|
...params,
|
|
19116
19132
|
options: opts
|
|
@@ -19192,7 +19208,7 @@ class Component extends PlatformBaseClient {
|
|
|
19192
19208
|
async updateMany(data, options) {
|
|
19193
19209
|
return await this.client.patch(`/v4/system/component/${this.ref}/models/bulk`, {
|
|
19194
19210
|
data,
|
|
19195
|
-
options
|
|
19211
|
+
options,
|
|
19196
19212
|
});
|
|
19197
19213
|
}
|
|
19198
19214
|
/**
|
|
@@ -19597,16 +19613,6 @@ class Functions extends PlatformBaseClient {
|
|
|
19597
19613
|
async update(uuid, update) {
|
|
19598
19614
|
return await this.client.patch(`/v1/system/function/${uuid}`, update);
|
|
19599
19615
|
}
|
|
19600
|
-
/**
|
|
19601
|
-
* Run platform function
|
|
19602
|
-
*
|
|
19603
|
-
* @param id - Function ID
|
|
19604
|
-
* @param d - Object containing input data, query parameters, and headers
|
|
19605
|
-
* @returns - Function result
|
|
19606
|
-
*
|
|
19607
|
-
* @example
|
|
19608
|
-
* const result = await platform.function().run("myFunction", {input: { foo: "bar" }})
|
|
19609
|
-
*/
|
|
19610
19616
|
async run(id, d) {
|
|
19611
19617
|
const { data } = await this.client.post(`/v1/system/function/run/${id}`, d.input, {
|
|
19612
19618
|
params: d.query,
|
|
@@ -20061,10 +20067,25 @@ class Sandbox extends PlatformBaseClient {
|
|
|
20061
20067
|
}
|
|
20062
20068
|
|
|
20063
20069
|
class System extends PlatformBaseClient {
|
|
20064
|
-
|
|
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) {
|
|
20065
20087
|
return await this.client.post("/v3/system/resource-resolver", {
|
|
20066
|
-
|
|
20067
|
-
ref,
|
|
20088
|
+
prn,
|
|
20068
20089
|
format,
|
|
20069
20090
|
});
|
|
20070
20091
|
}
|
|
@@ -20366,11 +20387,15 @@ class IntegrationsBaseClient extends BaseClient {
|
|
|
20366
20387
|
env = env !== null && env !== void 0 ? env : __global_env__ === null || __global_env__ === void 0 ? void 0 : __global_env__.PROJECT_ENV;
|
|
20367
20388
|
token = token !== null && token !== void 0 ? token : __global_env__ === null || __global_env__ === void 0 ? void 0 : __global_env__.PROJECT_API_TOKEN;
|
|
20368
20389
|
if (isBrowser) {
|
|
20369
|
-
if (sessionStorage.getItem('protokol_context')
|
|
20370
|
-
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;
|
|
20371
20396
|
}
|
|
20372
20397
|
else {
|
|
20373
|
-
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';
|
|
20374
20399
|
}
|
|
20375
20400
|
}
|
|
20376
20401
|
}
|
|
@@ -22166,6 +22191,57 @@ class NBS extends IntegrationsBaseClient {
|
|
|
22166
22191
|
}
|
|
22167
22192
|
}
|
|
22168
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
|
+
|
|
22169
22245
|
class Integrations extends IntegrationsBaseClient {
|
|
22170
22246
|
constructor(options) {
|
|
22171
22247
|
super(options);
|
|
@@ -22176,6 +22252,7 @@ class Integrations extends IntegrationsBaseClient {
|
|
|
22176
22252
|
'nbs': new NBS().setClient(this.client),
|
|
22177
22253
|
'protokol-payments': new Payments().setClient(this.client),
|
|
22178
22254
|
'protokol-minimax': new Minimax().setClient(this.client),
|
|
22255
|
+
'protokol-ecommerce': new Ecommerce().setClient(this.client),
|
|
22179
22256
|
};
|
|
22180
22257
|
}
|
|
22181
22258
|
getDMS() {
|
|
@@ -22199,6 +22276,9 @@ class Integrations extends IntegrationsBaseClient {
|
|
|
22199
22276
|
getSerbiaMinFin() {
|
|
22200
22277
|
return this.getInterfaceOf('serbia-minfin');
|
|
22201
22278
|
}
|
|
22279
|
+
getEcommerce() {
|
|
22280
|
+
return this.getInterfaceOf('protokol-ecommerce');
|
|
22281
|
+
}
|
|
22202
22282
|
async isInstalled(id) {
|
|
22203
22283
|
const { data } = await this.client.get("/v1/integrations");
|
|
22204
22284
|
return data.find((i) => i.id == id) !== undefined;
|
|
@@ -22244,6 +22324,7 @@ exports.Component = Component;
|
|
|
22244
22324
|
exports.ComponentUtils = ComponentUtils;
|
|
22245
22325
|
exports.Config = Config;
|
|
22246
22326
|
exports.DMS = DMS;
|
|
22327
|
+
exports.Ecommerce = Ecommerce;
|
|
22247
22328
|
exports.Forge = Forge;
|
|
22248
22329
|
exports.Functions = Functions;
|
|
22249
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;
|
|
@@ -113,6 +122,7 @@ class Component extends PlatformBaseClient {
|
|
|
113
122
|
* )
|
|
114
123
|
**/
|
|
115
124
|
async find(filters, opts) {
|
|
125
|
+
var _a;
|
|
116
126
|
let payload = {
|
|
117
127
|
context: filters,
|
|
118
128
|
ref: this.ref,
|
|
@@ -144,6 +154,12 @@ class Component extends PlatformBaseClient {
|
|
|
144
154
|
dateTo: ctx.dateTo,
|
|
145
155
|
dateField: ctx.dateField,
|
|
146
156
|
};
|
|
157
|
+
if (Object.keys(ctx.$adv || []).length > 0) {
|
|
158
|
+
params.$adv = [(_a = ctx.$adv) !== null && _a !== void 0 ? _a : {}];
|
|
159
|
+
}
|
|
160
|
+
if (ctx.$aggregate && ctx.$aggregate.length > 0) {
|
|
161
|
+
params.$aggregate = ctx.$aggregate;
|
|
162
|
+
}
|
|
147
163
|
return await this.client.post(`/v4/system/component/${this.ref}/models`, {
|
|
148
164
|
...params,
|
|
149
165
|
options: opts
|
|
@@ -225,7 +241,7 @@ class Component extends PlatformBaseClient {
|
|
|
225
241
|
async updateMany(data, options) {
|
|
226
242
|
return await this.client.patch(`/v4/system/component/${this.ref}/models/bulk`, {
|
|
227
243
|
data,
|
|
228
|
-
options
|
|
244
|
+
options,
|
|
229
245
|
});
|
|
230
246
|
}
|
|
231
247
|
/**
|
|
@@ -630,16 +646,6 @@ class Functions extends PlatformBaseClient {
|
|
|
630
646
|
async update(uuid, update) {
|
|
631
647
|
return await this.client.patch(`/v1/system/function/${uuid}`, update);
|
|
632
648
|
}
|
|
633
|
-
/**
|
|
634
|
-
* Run platform function
|
|
635
|
-
*
|
|
636
|
-
* @param id - Function ID
|
|
637
|
-
* @param d - Object containing input data, query parameters, and headers
|
|
638
|
-
* @returns - Function result
|
|
639
|
-
*
|
|
640
|
-
* @example
|
|
641
|
-
* const result = await platform.function().run("myFunction", {input: { foo: "bar" }})
|
|
642
|
-
*/
|
|
643
649
|
async run(id, d) {
|
|
644
650
|
const { data } = await this.client.post(`/v1/system/function/run/${id}`, d.input, {
|
|
645
651
|
params: d.query,
|
|
@@ -1094,10 +1100,25 @@ class Sandbox extends PlatformBaseClient {
|
|
|
1094
1100
|
}
|
|
1095
1101
|
|
|
1096
1102
|
class System extends PlatformBaseClient {
|
|
1097
|
-
|
|
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) {
|
|
1098
1120
|
return await this.client.post("/v3/system/resource-resolver", {
|
|
1099
|
-
|
|
1100
|
-
ref,
|
|
1121
|
+
prn,
|
|
1101
1122
|
format,
|
|
1102
1123
|
});
|
|
1103
1124
|
}
|
|
@@ -1399,11 +1420,15 @@ class IntegrationsBaseClient extends BaseClient {
|
|
|
1399
1420
|
env = env !== null && env !== void 0 ? env : __global_env__ === null || __global_env__ === void 0 ? void 0 : __global_env__.PROJECT_ENV;
|
|
1400
1421
|
token = token !== null && token !== void 0 ? token : __global_env__ === null || __global_env__ === void 0 ? void 0 : __global_env__.PROJECT_API_TOKEN;
|
|
1401
1422
|
if (isBrowser) {
|
|
1402
|
-
if (sessionStorage.getItem('protokol_context')
|
|
1403
|
-
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;
|
|
1404
1429
|
}
|
|
1405
1430
|
else {
|
|
1406
|
-
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';
|
|
1407
1432
|
}
|
|
1408
1433
|
}
|
|
1409
1434
|
}
|
|
@@ -3199,6 +3224,57 @@ class NBS extends IntegrationsBaseClient {
|
|
|
3199
3224
|
}
|
|
3200
3225
|
}
|
|
3201
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
|
+
|
|
3202
3278
|
class Integrations extends IntegrationsBaseClient {
|
|
3203
3279
|
constructor(options) {
|
|
3204
3280
|
super(options);
|
|
@@ -3209,6 +3285,7 @@ class Integrations extends IntegrationsBaseClient {
|
|
|
3209
3285
|
'nbs': new NBS().setClient(this.client),
|
|
3210
3286
|
'protokol-payments': new Payments().setClient(this.client),
|
|
3211
3287
|
'protokol-minimax': new Minimax().setClient(this.client),
|
|
3288
|
+
'protokol-ecommerce': new Ecommerce().setClient(this.client),
|
|
3212
3289
|
};
|
|
3213
3290
|
}
|
|
3214
3291
|
getDMS() {
|
|
@@ -3232,6 +3309,9 @@ class Integrations extends IntegrationsBaseClient {
|
|
|
3232
3309
|
getSerbiaMinFin() {
|
|
3233
3310
|
return this.getInterfaceOf('serbia-minfin');
|
|
3234
3311
|
}
|
|
3312
|
+
getEcommerce() {
|
|
3313
|
+
return this.getInterfaceOf('protokol-ecommerce');
|
|
3314
|
+
}
|
|
3235
3315
|
async isInstalled(id) {
|
|
3236
3316
|
const { data } = await this.client.get("/v1/integrations");
|
|
3237
3317
|
return data.find((i) => i.id == id) !== undefined;
|
|
@@ -3271,4 +3351,4 @@ class Invoicing extends PlatformBaseClient {
|
|
|
3271
3351
|
}
|
|
3272
3352
|
}
|
|
3273
3353
|
|
|
3274
|
-
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;
|