@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.
@@ -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
+ };
@@ -45,7 +45,7 @@ export default class Component extends PlatformBaseClient {
45
45
  * name: "John Doe",
46
46
  * })
47
47
  **/
48
- findOne(filter: FindAdvancedParams, opts: FindOptions): Promise<Model | null>;
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: UpdateOptions): Promise<AxiosResponse<any, any>>;
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: UpdateManyOptions): Promise<AxiosResponse<any, any>>;
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: CreateManyOptions): Promise<AxiosResponse<any, any>>;
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: ModifyOptions): Promise<AxiosResponse<any, any>>;
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: UpdateOptions): Promise<AxiosResponse<any, any>>;
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
- * @param id - Function ID
10
- * @param d - Object containing input data, query parameters, and headers
11
- * @returns - Function result
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
- * const result = await platform.function().run("myFunction", {input: { foo: "bar" }})
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>;
@@ -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(ref: string, resourceName: string, format?: string): Promise<import("axios").AxiosResponse<any, any>>;
3
+ resourceResolver(prn: string, format?: string): Promise<import("axios").AxiosResponse<any, any>>;
4
4
  }
@@ -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') == "forge") {
19020
- headers['X-Project-Env'] = (_b = sessionStorage.getItem('forge_app_env')) !== null && _b !== void 0 ? _b : "dev";
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 : "dev";
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(ref, resourceName, format) {
19888
+ async resourceResolver(prn, format) {
19895
19889
  return await this.client.post("/v3/system/resource-resolver", {
19896
- type: resourceName,
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') == "forge") {
20225
- headers['X-Project-Env'] = (_b = sessionStorage.getItem('forge_app_env')) !== null && _b !== void 0 ? _b : "dev";
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 : "dev";
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;
@@ -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') == "forge") {
51
- headers['X-Project-Env'] = (_b = sessionStorage.getItem('forge_app_env')) !== null && _b !== void 0 ? _b : "dev";
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 : "dev";
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(ref, resourceName, format) {
919
+ async resourceResolver(prn, format) {
926
920
  return await this.client.post("/v3/system/resource-resolver", {
927
- type: resourceName,
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') == "forge") {
1256
- headers['X-Project-Env'] = (_b = sessionStorage.getItem('forge_app_env')) !== null && _b !== void 0 ? _b : "dev";
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 : "dev";
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 };