@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
|
@@ -45,7 +45,7 @@ export default class Component extends PlatformBaseClient {
|
|
|
45
45
|
* name: "John Doe",
|
|
46
46
|
* })
|
|
47
47
|
**/
|
|
48
|
-
findOne(filter: FindAdvancedParams, opts
|
|
48
|
+
findOne(filter: FindAdvancedParams, opts?: FindOptions): Promise<Model | null>;
|
|
49
49
|
/**
|
|
50
50
|
* Get model by uuid
|
|
51
51
|
*
|
|
@@ -60,7 +60,7 @@ export default class Component extends PlatformBaseClient {
|
|
|
60
60
|
* @param data
|
|
61
61
|
* @returns
|
|
62
62
|
*/
|
|
63
|
-
update(uuid: string, data: Record<string, any>, options
|
|
63
|
+
update(uuid: string, data: Record<string, any>, options?: UpdateOptions): Promise<AxiosResponse<any, any>>;
|
|
64
64
|
/**
|
|
65
65
|
* Update many models
|
|
66
66
|
*
|
|
@@ -68,7 +68,7 @@ export default class Component extends PlatformBaseClient {
|
|
|
68
68
|
* @param options
|
|
69
69
|
* @returns
|
|
70
70
|
*/
|
|
71
|
-
updateMany(data: Record<string, any>[], options
|
|
71
|
+
updateMany(data: Record<string, any>[], options?: UpdateManyOptions): Promise<AxiosResponse<any, any>>;
|
|
72
72
|
/**
|
|
73
73
|
* Create many models
|
|
74
74
|
*
|
|
@@ -76,7 +76,7 @@ export default class Component extends PlatformBaseClient {
|
|
|
76
76
|
* @param options
|
|
77
77
|
* @returns
|
|
78
78
|
*/
|
|
79
|
-
createMany(data: Record<string, any>[], options
|
|
79
|
+
createMany(data: Record<string, any>[], options?: CreateManyOptions): Promise<AxiosResponse<any, any>>;
|
|
80
80
|
/**
|
|
81
81
|
* Modify models by filters
|
|
82
82
|
*
|
|
@@ -84,7 +84,7 @@ export default class Component extends PlatformBaseClient {
|
|
|
84
84
|
* @param options
|
|
85
85
|
* @returns
|
|
86
86
|
*/
|
|
87
|
-
modify(filters: Record<string, any>, data: Record<string, any>, options
|
|
87
|
+
modify(filters: Record<string, any>, data: Record<string, any>, options?: ModifyOptions): Promise<AxiosResponse<any, any>>;
|
|
88
88
|
/**
|
|
89
89
|
* Concurrent update model by uuid
|
|
90
90
|
*
|
|
@@ -93,7 +93,7 @@ export default class Component extends PlatformBaseClient {
|
|
|
93
93
|
* @param data
|
|
94
94
|
* @returns
|
|
95
95
|
*/
|
|
96
|
-
concurrentUpdate(uuid: string, version: number, data: Record<string, any>, options
|
|
96
|
+
concurrentUpdate(uuid: string, version: number, data: Record<string, any>, options?: UpdateOptions): Promise<AxiosResponse<any, any>>;
|
|
97
97
|
create(model: Record<string, any>): Promise<AxiosResponse<any, any>>;
|
|
98
98
|
delete(uuid: string): Promise<AxiosResponse<any, any>>;
|
|
99
99
|
/**
|
|
@@ -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>;
|
package/dist/v0.9/api/index.d.ts
CHANGED
|
@@ -21,5 +21,6 @@ export { default as DMS } from './integrations/dms';
|
|
|
21
21
|
export { default as SerbiaUtil } from './integrations/serbiaUtil';
|
|
22
22
|
export { default as VPFR } from './integrations/vpfr';
|
|
23
23
|
export { default as Mail } from './integrations/mail';
|
|
24
|
+
export { default as Ecommerce } from './integrations/ecommerce';
|
|
24
25
|
import Platfrom from './platform';
|
|
25
26
|
export default Platfrom;
|
|
@@ -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
|
+
}
|
|
@@ -5,6 +5,7 @@ import VPFR from "./integrations/vpfr";
|
|
|
5
5
|
import IntegrationsBaseClient from "./integrationsBaseClient";
|
|
6
6
|
import Payments from "./integrations/payments";
|
|
7
7
|
import Minimax from "./integrations/minimax";
|
|
8
|
+
import Ecommerce from "./integrations/ecommerce";
|
|
8
9
|
export default class Integrations extends IntegrationsBaseClient {
|
|
9
10
|
private integrations;
|
|
10
11
|
constructor(options?: {
|
|
@@ -19,6 +20,7 @@ export default class Integrations extends IntegrationsBaseClient {
|
|
|
19
20
|
getMail(): Mail;
|
|
20
21
|
getPayments(): Payments;
|
|
21
22
|
getMinimax(): Minimax;
|
|
23
|
+
getEcommerce(): Ecommerce;
|
|
22
24
|
isInstalled(id: string): Promise<boolean>;
|
|
23
25
|
getInterfaceOf(id: string): any;
|
|
24
26
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import PlatformBaseClient from "./platformBaseClient";
|
|
2
2
|
export default class System extends PlatformBaseClient {
|
|
3
|
-
resourceResolver(
|
|
3
|
+
resourceResolver(prn: string, format?: string): Promise<import("axios").AxiosResponse<any, any>>;
|
|
4
4
|
}
|
package/dist/v0.9/index.cjs.js
CHANGED
|
@@ -19016,11 +19016,15 @@ class PlatformBaseClient extends BaseClient {
|
|
|
19016
19016
|
token = token !== null && token !== void 0 ? token : __global_env__ === null || __global_env__ === void 0 ? void 0 : __global_env__.PROJECT_API_TOKEN;
|
|
19017
19017
|
project_uuid = __global_env__ === null || __global_env__ === void 0 ? void 0 : __global_env__.PROJECT_UUID;
|
|
19018
19018
|
if (isBrowser) {
|
|
19019
|
-
if (sessionStorage.getItem('protokol_context')
|
|
19020
|
-
headers['X-Project-Env'] = (_b = sessionStorage.getItem('forge_app_env')) !== null && _b !== void 0 ? _b :
|
|
19019
|
+
if (sessionStorage.getItem('protokol_context') === 'forge') {
|
|
19020
|
+
headers['X-Project-Env'] = (_b = sessionStorage.getItem('forge_app_env')) !== null && _b !== void 0 ? _b : 'dev';
|
|
19021
|
+
// pick up forge actor token — overrides any other token source
|
|
19022
|
+
const forgeToken = sessionStorage.getItem('forge_actor_token');
|
|
19023
|
+
if (forgeToken)
|
|
19024
|
+
token = forgeToken;
|
|
19021
19025
|
}
|
|
19022
19026
|
else {
|
|
19023
|
-
headers['X-Project-Env'] = (_c = localStorage.getItem('current_env')) !== null && _c !== void 0 ? _c :
|
|
19027
|
+
headers['X-Project-Env'] = (_c = localStorage.getItem('current_env')) !== null && _c !== void 0 ? _c : 'dev';
|
|
19024
19028
|
}
|
|
19025
19029
|
}
|
|
19026
19030
|
}
|
|
@@ -19204,7 +19208,7 @@ class Component extends PlatformBaseClient {
|
|
|
19204
19208
|
async updateMany(data, options) {
|
|
19205
19209
|
return await this.client.patch(`${this.getComponentPath()}/models/bulk`, {
|
|
19206
19210
|
data,
|
|
19207
|
-
options
|
|
19211
|
+
options,
|
|
19208
19212
|
});
|
|
19209
19213
|
}
|
|
19210
19214
|
/**
|
|
@@ -19438,16 +19442,6 @@ class Functions extends PlatformBaseClient {
|
|
|
19438
19442
|
async update(uuid, update) {
|
|
19439
19443
|
return await this.client.patch(`/v1/system/function/${uuid}`, update);
|
|
19440
19444
|
}
|
|
19441
|
-
/**
|
|
19442
|
-
* Run platform function
|
|
19443
|
-
*
|
|
19444
|
-
* @param id - Function ID
|
|
19445
|
-
* @param d - Object containing input data, query parameters, and headers
|
|
19446
|
-
* @returns - Function result
|
|
19447
|
-
*
|
|
19448
|
-
* @example
|
|
19449
|
-
* const result = await platform.function().run("myFunction", {input: { foo: "bar" }})
|
|
19450
|
-
*/
|
|
19451
19445
|
async run(id, d) {
|
|
19452
19446
|
const { data } = await this.client.post(`/v1/system/function/run/${id}`, d.input, {
|
|
19453
19447
|
params: d.query,
|
|
@@ -19891,10 +19885,9 @@ class Sandbox extends PlatformBaseClient {
|
|
|
19891
19885
|
}
|
|
19892
19886
|
|
|
19893
19887
|
class System extends PlatformBaseClient {
|
|
19894
|
-
async resourceResolver(
|
|
19888
|
+
async resourceResolver(prn, format) {
|
|
19895
19889
|
return await this.client.post("/v3/system/resource-resolver", {
|
|
19896
|
-
|
|
19897
|
-
ref,
|
|
19890
|
+
prn,
|
|
19898
19891
|
format,
|
|
19899
19892
|
});
|
|
19900
19893
|
}
|
|
@@ -20221,11 +20214,15 @@ class IntegrationsBaseClient extends BaseClient {
|
|
|
20221
20214
|
env = env !== null && env !== void 0 ? env : __global_env__ === null || __global_env__ === void 0 ? void 0 : __global_env__.PROJECT_ENV;
|
|
20222
20215
|
token = token !== null && token !== void 0 ? token : __global_env__ === null || __global_env__ === void 0 ? void 0 : __global_env__.PROJECT_API_TOKEN;
|
|
20223
20216
|
if (isBrowser) {
|
|
20224
|
-
if (sessionStorage.getItem('protokol_context')
|
|
20225
|
-
headers['X-Project-Env'] = (_b = sessionStorage.getItem('forge_app_env')) !== null && _b !== void 0 ? _b :
|
|
20217
|
+
if (sessionStorage.getItem('protokol_context') === 'forge') {
|
|
20218
|
+
headers['X-Project-Env'] = (_b = sessionStorage.getItem('forge_app_env')) !== null && _b !== void 0 ? _b : 'dev';
|
|
20219
|
+
// pick up forge actor token — overrides any other token source
|
|
20220
|
+
const forgeToken = sessionStorage.getItem('forge_actor_token');
|
|
20221
|
+
if (forgeToken)
|
|
20222
|
+
token = forgeToken;
|
|
20226
20223
|
}
|
|
20227
20224
|
else {
|
|
20228
|
-
headers['X-Project-Env'] = (_c = localStorage.getItem('current_env')) !== null && _c !== void 0 ? _c :
|
|
20225
|
+
headers['X-Project-Env'] = (_c = localStorage.getItem('current_env')) !== null && _c !== void 0 ? _c : 'dev';
|
|
20229
20226
|
}
|
|
20230
20227
|
}
|
|
20231
20228
|
}
|
|
@@ -21859,6 +21856,57 @@ class Minimax extends IntegrationsBaseClient {
|
|
|
21859
21856
|
}
|
|
21860
21857
|
}
|
|
21861
21858
|
|
|
21859
|
+
class Ecommerce extends IntegrationsBaseClient {
|
|
21860
|
+
/**
|
|
21861
|
+
* Get the ecommerce integration user for the current project.
|
|
21862
|
+
*/
|
|
21863
|
+
async get() {
|
|
21864
|
+
return await this.client.get(`/v1/ecomm/user`);
|
|
21865
|
+
}
|
|
21866
|
+
/**
|
|
21867
|
+
* Update ecommerce integration settings (onboarding or partial update).
|
|
21868
|
+
*/
|
|
21869
|
+
async update(req) {
|
|
21870
|
+
return await this.client.patch(`/v1/ecomm/user`, req);
|
|
21871
|
+
}
|
|
21872
|
+
/**
|
|
21873
|
+
* Check whether a base domain subdomain is available.
|
|
21874
|
+
*/
|
|
21875
|
+
async checkBaseDomain(domain) {
|
|
21876
|
+
return await this.client.post(`/v1/ecomm/base-domain/check`, { domain });
|
|
21877
|
+
}
|
|
21878
|
+
/**
|
|
21879
|
+
* Add a custom domain (returns a verification token for DNS validation).
|
|
21880
|
+
*/
|
|
21881
|
+
async addCustomDomain(domain) {
|
|
21882
|
+
return await this.client.post(`/v1/ecomm/domains`, { domain });
|
|
21883
|
+
}
|
|
21884
|
+
/**
|
|
21885
|
+
* Validate a custom domain with its verification token.
|
|
21886
|
+
*/
|
|
21887
|
+
async validateCustomDomain(domain, token) {
|
|
21888
|
+
return await this.client.post(`/v1/ecomm/domains/validate`, { domain, token });
|
|
21889
|
+
}
|
|
21890
|
+
/**
|
|
21891
|
+
* Remove a custom domain.
|
|
21892
|
+
*/
|
|
21893
|
+
async removeCustomDomain(domain) {
|
|
21894
|
+
return await this.client.delete(`/v1/ecomm/domains`, { data: { domain } });
|
|
21895
|
+
}
|
|
21896
|
+
/**
|
|
21897
|
+
* List pending (unvalidated) custom domains.
|
|
21898
|
+
*/
|
|
21899
|
+
async getPendingDomains() {
|
|
21900
|
+
return await this.client.get(`/v1/ecomm/domains/pending`);
|
|
21901
|
+
}
|
|
21902
|
+
/**
|
|
21903
|
+
* List validated custom domains.
|
|
21904
|
+
*/
|
|
21905
|
+
async getValidatedDomains() {
|
|
21906
|
+
return await this.client.get(`/v1/ecomm/domains/validated`);
|
|
21907
|
+
}
|
|
21908
|
+
}
|
|
21909
|
+
|
|
21862
21910
|
// import integrations
|
|
21863
21911
|
class Integrations extends IntegrationsBaseClient {
|
|
21864
21912
|
constructor(options) {
|
|
@@ -21871,6 +21919,7 @@ class Integrations extends IntegrationsBaseClient {
|
|
|
21871
21919
|
'serbia-utilities': new SerbiaUtil().setClient(this.client),
|
|
21872
21920
|
'protokol-payments': new Payments().setClient(this.client),
|
|
21873
21921
|
'protokol-minimax': new Minimax().setClient(this.client),
|
|
21922
|
+
'protokol-ecommerce': new Ecommerce().setClient(this.client),
|
|
21874
21923
|
};
|
|
21875
21924
|
}
|
|
21876
21925
|
getSerbiaUtilities() {
|
|
@@ -21894,6 +21943,9 @@ class Integrations extends IntegrationsBaseClient {
|
|
|
21894
21943
|
getMinimax() {
|
|
21895
21944
|
return this.getInterfaceOf('protokol-minimax');
|
|
21896
21945
|
}
|
|
21946
|
+
getEcommerce() {
|
|
21947
|
+
return this.getInterfaceOf('protokol-ecommerce');
|
|
21948
|
+
}
|
|
21897
21949
|
async isInstalled(id) {
|
|
21898
21950
|
const { data } = await this.client.get("/v1/integrations");
|
|
21899
21951
|
return data.find((i) => i.id == id) !== undefined;
|
|
@@ -21918,6 +21970,7 @@ exports.Component = Component;
|
|
|
21918
21970
|
exports.ComponentUtils = ComponentUtils;
|
|
21919
21971
|
exports.Config = Config;
|
|
21920
21972
|
exports.DMS = DMS;
|
|
21973
|
+
exports.Ecommerce = Ecommerce;
|
|
21921
21974
|
exports.Forge = Forge;
|
|
21922
21975
|
exports.Functions = Functions;
|
|
21923
21976
|
exports.Integration = Integrations;
|
package/dist/v0.9/index.esm.js
CHANGED
|
@@ -47,11 +47,15 @@ class PlatformBaseClient extends BaseClient {
|
|
|
47
47
|
token = token !== null && token !== void 0 ? token : __global_env__ === null || __global_env__ === void 0 ? void 0 : __global_env__.PROJECT_API_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'] = (_b = sessionStorage.getItem('forge_app_env')) !== null && _b !== void 0 ? _b :
|
|
50
|
+
if (sessionStorage.getItem('protokol_context') === 'forge') {
|
|
51
|
+
headers['X-Project-Env'] = (_b = sessionStorage.getItem('forge_app_env')) !== null && _b !== void 0 ? _b : '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'] = (_c = localStorage.getItem('current_env')) !== null && _c !== void 0 ? _c :
|
|
58
|
+
headers['X-Project-Env'] = (_c = localStorage.getItem('current_env')) !== null && _c !== void 0 ? _c : 'dev';
|
|
55
59
|
}
|
|
56
60
|
}
|
|
57
61
|
}
|
|
@@ -235,7 +239,7 @@ class Component extends PlatformBaseClient {
|
|
|
235
239
|
async updateMany(data, options) {
|
|
236
240
|
return await this.client.patch(`${this.getComponentPath()}/models/bulk`, {
|
|
237
241
|
data,
|
|
238
|
-
options
|
|
242
|
+
options,
|
|
239
243
|
});
|
|
240
244
|
}
|
|
241
245
|
/**
|
|
@@ -469,16 +473,6 @@ class Functions extends PlatformBaseClient {
|
|
|
469
473
|
async update(uuid, update) {
|
|
470
474
|
return await this.client.patch(`/v1/system/function/${uuid}`, update);
|
|
471
475
|
}
|
|
472
|
-
/**
|
|
473
|
-
* Run platform function
|
|
474
|
-
*
|
|
475
|
-
* @param id - Function ID
|
|
476
|
-
* @param d - Object containing input data, query parameters, and headers
|
|
477
|
-
* @returns - Function result
|
|
478
|
-
*
|
|
479
|
-
* @example
|
|
480
|
-
* const result = await platform.function().run("myFunction", {input: { foo: "bar" }})
|
|
481
|
-
*/
|
|
482
476
|
async run(id, d) {
|
|
483
477
|
const { data } = await this.client.post(`/v1/system/function/run/${id}`, d.input, {
|
|
484
478
|
params: d.query,
|
|
@@ -922,10 +916,9 @@ class Sandbox extends PlatformBaseClient {
|
|
|
922
916
|
}
|
|
923
917
|
|
|
924
918
|
class System extends PlatformBaseClient {
|
|
925
|
-
async resourceResolver(
|
|
919
|
+
async resourceResolver(prn, format) {
|
|
926
920
|
return await this.client.post("/v3/system/resource-resolver", {
|
|
927
|
-
|
|
928
|
-
ref,
|
|
921
|
+
prn,
|
|
929
922
|
format,
|
|
930
923
|
});
|
|
931
924
|
}
|
|
@@ -1252,11 +1245,15 @@ class IntegrationsBaseClient extends BaseClient {
|
|
|
1252
1245
|
env = env !== null && env !== void 0 ? env : __global_env__ === null || __global_env__ === void 0 ? void 0 : __global_env__.PROJECT_ENV;
|
|
1253
1246
|
token = token !== null && token !== void 0 ? token : __global_env__ === null || __global_env__ === void 0 ? void 0 : __global_env__.PROJECT_API_TOKEN;
|
|
1254
1247
|
if (isBrowser) {
|
|
1255
|
-
if (sessionStorage.getItem('protokol_context')
|
|
1256
|
-
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;
|
|
1257
1254
|
}
|
|
1258
1255
|
else {
|
|
1259
|
-
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';
|
|
1260
1257
|
}
|
|
1261
1258
|
}
|
|
1262
1259
|
}
|
|
@@ -2890,6 +2887,57 @@ class Minimax extends IntegrationsBaseClient {
|
|
|
2890
2887
|
}
|
|
2891
2888
|
}
|
|
2892
2889
|
|
|
2890
|
+
class Ecommerce extends IntegrationsBaseClient {
|
|
2891
|
+
/**
|
|
2892
|
+
* Get the ecommerce integration user for the current project.
|
|
2893
|
+
*/
|
|
2894
|
+
async get() {
|
|
2895
|
+
return await this.client.get(`/v1/ecomm/user`);
|
|
2896
|
+
}
|
|
2897
|
+
/**
|
|
2898
|
+
* Update ecommerce integration settings (onboarding or partial update).
|
|
2899
|
+
*/
|
|
2900
|
+
async update(req) {
|
|
2901
|
+
return await this.client.patch(`/v1/ecomm/user`, req);
|
|
2902
|
+
}
|
|
2903
|
+
/**
|
|
2904
|
+
* Check whether a base domain subdomain is available.
|
|
2905
|
+
*/
|
|
2906
|
+
async checkBaseDomain(domain) {
|
|
2907
|
+
return await this.client.post(`/v1/ecomm/base-domain/check`, { domain });
|
|
2908
|
+
}
|
|
2909
|
+
/**
|
|
2910
|
+
* Add a custom domain (returns a verification token for DNS validation).
|
|
2911
|
+
*/
|
|
2912
|
+
async addCustomDomain(domain) {
|
|
2913
|
+
return await this.client.post(`/v1/ecomm/domains`, { domain });
|
|
2914
|
+
}
|
|
2915
|
+
/**
|
|
2916
|
+
* Validate a custom domain with its verification token.
|
|
2917
|
+
*/
|
|
2918
|
+
async validateCustomDomain(domain, token) {
|
|
2919
|
+
return await this.client.post(`/v1/ecomm/domains/validate`, { domain, token });
|
|
2920
|
+
}
|
|
2921
|
+
/**
|
|
2922
|
+
* Remove a custom domain.
|
|
2923
|
+
*/
|
|
2924
|
+
async removeCustomDomain(domain) {
|
|
2925
|
+
return await this.client.delete(`/v1/ecomm/domains`, { data: { domain } });
|
|
2926
|
+
}
|
|
2927
|
+
/**
|
|
2928
|
+
* List pending (unvalidated) custom domains.
|
|
2929
|
+
*/
|
|
2930
|
+
async getPendingDomains() {
|
|
2931
|
+
return await this.client.get(`/v1/ecomm/domains/pending`);
|
|
2932
|
+
}
|
|
2933
|
+
/**
|
|
2934
|
+
* List validated custom domains.
|
|
2935
|
+
*/
|
|
2936
|
+
async getValidatedDomains() {
|
|
2937
|
+
return await this.client.get(`/v1/ecomm/domains/validated`);
|
|
2938
|
+
}
|
|
2939
|
+
}
|
|
2940
|
+
|
|
2893
2941
|
// import integrations
|
|
2894
2942
|
class Integrations extends IntegrationsBaseClient {
|
|
2895
2943
|
constructor(options) {
|
|
@@ -2902,6 +2950,7 @@ class Integrations extends IntegrationsBaseClient {
|
|
|
2902
2950
|
'serbia-utilities': new SerbiaUtil().setClient(this.client),
|
|
2903
2951
|
'protokol-payments': new Payments().setClient(this.client),
|
|
2904
2952
|
'protokol-minimax': new Minimax().setClient(this.client),
|
|
2953
|
+
'protokol-ecommerce': new Ecommerce().setClient(this.client),
|
|
2905
2954
|
};
|
|
2906
2955
|
}
|
|
2907
2956
|
getSerbiaUtilities() {
|
|
@@ -2925,6 +2974,9 @@ class Integrations extends IntegrationsBaseClient {
|
|
|
2925
2974
|
getMinimax() {
|
|
2926
2975
|
return this.getInterfaceOf('protokol-minimax');
|
|
2927
2976
|
}
|
|
2977
|
+
getEcommerce() {
|
|
2978
|
+
return this.getInterfaceOf('protokol-ecommerce');
|
|
2979
|
+
}
|
|
2928
2980
|
async isInstalled(id) {
|
|
2929
2981
|
const { data } = await this.client.get("/v1/integrations");
|
|
2930
2982
|
return data.find((i) => i.id == id) !== undefined;
|
|
@@ -2943,4 +2995,4 @@ class Integrations extends IntegrationsBaseClient {
|
|
|
2943
2995
|
// Export all API modules for version 0.9
|
|
2944
2996
|
// This version has specific method signatures and behaviors for v0.9
|
|
2945
2997
|
|
|
2946
|
-
export { APIUser, Apps, Component, ComponentUtils, Config, DMS, Forge, Functions, Integrations as Integration, Integrations, Invoicing, Mail, Payments, Platform, Project, Ratchet, Sandbox, SerbiaUtil, System, Thunder, Users, VPFR, Workflow, Platform as default };
|
|
2998
|
+
export { APIUser, Apps, Component, ComponentUtils, Config, DMS, Ecommerce, Forge, Functions, Integrations as Integration, Integrations, Invoicing, Mail, Payments, Platform, Project, Ratchet, Sandbox, SerbiaUtil, System, Thunder, Users, VPFR, Workflow, Platform as default };
|
|
@@ -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
|
type ComponentOptions = {
|
|
80
81
|
version?: string;
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* PlatformFunctions is an open interface that serves as a registry of platform
|
|
3
|
+
* function signatures. It is empty by default and can be extended in two ways:
|
|
4
|
+
*
|
|
5
|
+
* 1. **At build time** — run `ptkl generate-types` to fetch your project's
|
|
6
|
+
* functions and emit a `.d.ts` file with a module augmentation block:
|
|
7
|
+
* ```ts
|
|
8
|
+
* declare module "@ptkl/sdk" {
|
|
9
|
+
* interface PlatformFunctions {
|
|
10
|
+
* "send_email": { input: { body: string; to: string }; output: { status: boolean } }
|
|
11
|
+
* }
|
|
12
|
+
* }
|
|
13
|
+
* ```
|
|
14
|
+
*
|
|
15
|
+
* 2. **At runtime in Monaco editors** — the editor auto-patches the interface
|
|
16
|
+
* from your project's live function signatures.
|
|
17
|
+
*/
|
|
18
|
+
export interface PlatformFunctions {
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* Access a single platform function's signature type by name.
|
|
22
|
+
*
|
|
23
|
+
* @example
|
|
24
|
+
* type EmailSig = PlatformFunction<"send_email">
|
|
25
|
+
* // → { input: { body: string; to: string }; output: { status: boolean } }
|
|
26
|
+
*/
|
|
27
|
+
export type PlatformFunction<K extends keyof PlatformFunctions> = PlatformFunctions[K];
|
|
28
|
+
/** Inferred input type for a registered function, falling back to a generic record. */
|
|
29
|
+
export type FunctionInput<K extends keyof PlatformFunctions> = PlatformFunctions[K] extends {
|
|
30
|
+
input: infer I;
|
|
31
|
+
} ? I : Record<string, any>;
|
|
32
|
+
/** Inferred output type for a registered function, falling back to any. */
|
|
33
|
+
export type FunctionOutput<K extends keyof PlatformFunctions> = PlatformFunctions[K] extends {
|
|
34
|
+
output: infer O;
|
|
35
|
+
} ? O : any;
|
|
36
|
+
/** Parameters shape for a typed function call. */
|
|
37
|
+
export type FunctionCallParams<K extends keyof PlatformFunctions> = {
|
|
38
|
+
input: FunctionInput<K>;
|
|
39
|
+
query?: Record<string, string>;
|
|
40
|
+
headers?: Record<string, string>;
|
|
41
|
+
};
|