@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.
@@ -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') == "forge") {
52
- headers['X-Project-Env'] = (_d = sessionStorage.getItem('forge_app_env')) !== null && _d !== void 0 ? _d : "dev";
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 : "dev";
59
+ headers['X-Project-Env'] = (_e = localStorage.getItem('current_env')) !== null && _e !== void 0 ? _e : 'dev';
56
60
  }
57
61
  }
58
62
  }
@@ -88,6 +92,11 @@ var ProtokolSDK010 = (function (exports, axios) {
88
92
  }
89
93
 
90
94
  class Component extends PlatformBaseClient {
95
+ /**
96
+ * @param ref - Component ref (e.g. "ecommerce::order"). Passing a string
97
+ * literal lets TypeScript infer the generic C and type find/create/function
98
+ * results accordingly.
99
+ */
91
100
  constructor(ref = null) {
92
101
  super();
93
102
  this.ref = ref;
@@ -233,7 +242,7 @@ var ProtokolSDK010 = (function (exports, axios) {
233
242
  async updateMany(data, options) {
234
243
  return await this.client.patch(`/v4/system/component/${this.ref}/models/bulk`, {
235
244
  data,
236
- options
245
+ options,
237
246
  });
238
247
  }
239
248
  /**
@@ -638,16 +647,6 @@ var ProtokolSDK010 = (function (exports, axios) {
638
647
  async update(uuid, update) {
639
648
  return await this.client.patch(`/v1/system/function/${uuid}`, update);
640
649
  }
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
650
  async run(id, d) {
652
651
  const { data } = await this.client.post(`/v1/system/function/run/${id}`, d.input, {
653
652
  params: d.query,
@@ -1102,10 +1101,25 @@ var ProtokolSDK010 = (function (exports, axios) {
1102
1101
  }
1103
1102
 
1104
1103
  class System extends PlatformBaseClient {
1105
- async resourceResolver(ref, resourceName, format) {
1104
+ /**
1105
+ * Returns all IDL definitions for the current project.
1106
+ * Used by `ptkl generate-types` to emit typed `.d.ts` augmentations.
1107
+ */
1108
+ async idl() {
1109
+ return await this.client.get('/v1/system/idl');
1110
+ }
1111
+ /**
1112
+ * Validates a value against an IDL — either by ref or with an inline IDL object.
1113
+ * Returns `{ data: { valid: true } }` on success or
1114
+ * `{ data: { valid: false, errors: [...] } }` on validation failure.
1115
+ * Throws on HTTP errors (4xx/5xx).
1116
+ */
1117
+ async idlValidate(req) {
1118
+ return await this.client.post('/v1/system/idl/validate', req);
1119
+ }
1120
+ async resourceResolver(prn, format) {
1106
1121
  return await this.client.post("/v3/system/resource-resolver", {
1107
- type: resourceName,
1108
- ref,
1122
+ prn,
1109
1123
  format,
1110
1124
  });
1111
1125
  }
@@ -1407,11 +1421,15 @@ var ProtokolSDK010 = (function (exports, axios) {
1407
1421
  env = env !== null && env !== void 0 ? env : __global_env__ === null || __global_env__ === void 0 ? void 0 : __global_env__.PROJECT_ENV;
1408
1422
  token = token !== null && token !== void 0 ? token : __global_env__ === null || __global_env__ === void 0 ? void 0 : __global_env__.PROJECT_API_TOKEN;
1409
1423
  if (isBrowser) {
1410
- if (sessionStorage.getItem('protokol_context') == "forge") {
1411
- headers['X-Project-Env'] = (_b = sessionStorage.getItem('forge_app_env')) !== null && _b !== void 0 ? _b : "dev";
1424
+ if (sessionStorage.getItem('protokol_context') === 'forge') {
1425
+ headers['X-Project-Env'] = (_b = sessionStorage.getItem('forge_app_env')) !== null && _b !== void 0 ? _b : 'dev';
1426
+ // pick up forge actor token — overrides any other token source
1427
+ const forgeToken = sessionStorage.getItem('forge_actor_token');
1428
+ if (forgeToken)
1429
+ token = forgeToken;
1412
1430
  }
1413
1431
  else {
1414
- headers['X-Project-Env'] = (_c = localStorage.getItem('current_env')) !== null && _c !== void 0 ? _c : "dev";
1432
+ headers['X-Project-Env'] = (_c = localStorage.getItem('current_env')) !== null && _c !== void 0 ? _c : 'dev';
1415
1433
  }
1416
1434
  }
1417
1435
  }
@@ -3207,6 +3225,57 @@ var ProtokolSDK010 = (function (exports, axios) {
3207
3225
  }
3208
3226
  }
3209
3227
 
3228
+ class Ecommerce extends IntegrationsBaseClient {
3229
+ /**
3230
+ * Get the ecommerce integration user for the current project.
3231
+ */
3232
+ async get() {
3233
+ return await this.client.get(`/v1/ecomm/user`);
3234
+ }
3235
+ /**
3236
+ * Update ecommerce integration settings (onboarding or partial update).
3237
+ */
3238
+ async update(req) {
3239
+ return await this.client.patch(`/v1/ecomm/user`, req);
3240
+ }
3241
+ /**
3242
+ * Check whether a base domain subdomain is available.
3243
+ */
3244
+ async checkBaseDomain(domain) {
3245
+ return await this.client.post(`/v1/ecomm/base-domain/check`, { domain });
3246
+ }
3247
+ /**
3248
+ * Add a custom domain (returns a verification token for DNS validation).
3249
+ */
3250
+ async addCustomDomain(domain) {
3251
+ return await this.client.post(`/v1/ecomm/domains`, { domain });
3252
+ }
3253
+ /**
3254
+ * Validate a custom domain with its verification token.
3255
+ */
3256
+ async validateCustomDomain(domain, token) {
3257
+ return await this.client.post(`/v1/ecomm/domains/validate`, { domain, token });
3258
+ }
3259
+ /**
3260
+ * Remove a custom domain.
3261
+ */
3262
+ async removeCustomDomain(domain) {
3263
+ return await this.client.delete(`/v1/ecomm/domains`, { data: { domain } });
3264
+ }
3265
+ /**
3266
+ * List pending (unvalidated) custom domains.
3267
+ */
3268
+ async getPendingDomains() {
3269
+ return await this.client.get(`/v1/ecomm/domains/pending`);
3270
+ }
3271
+ /**
3272
+ * List validated custom domains.
3273
+ */
3274
+ async getValidatedDomains() {
3275
+ return await this.client.get(`/v1/ecomm/domains/validated`);
3276
+ }
3277
+ }
3278
+
3210
3279
  class Integrations extends IntegrationsBaseClient {
3211
3280
  constructor(options) {
3212
3281
  super(options);
@@ -3217,6 +3286,7 @@ var ProtokolSDK010 = (function (exports, axios) {
3217
3286
  'nbs': new NBS().setClient(this.client),
3218
3287
  'protokol-payments': new Payments().setClient(this.client),
3219
3288
  'protokol-minimax': new Minimax().setClient(this.client),
3289
+ 'protokol-ecommerce': new Ecommerce().setClient(this.client),
3220
3290
  };
3221
3291
  }
3222
3292
  getDMS() {
@@ -3240,6 +3310,9 @@ var ProtokolSDK010 = (function (exports, axios) {
3240
3310
  getSerbiaMinFin() {
3241
3311
  return this.getInterfaceOf('serbia-minfin');
3242
3312
  }
3313
+ getEcommerce() {
3314
+ return this.getInterfaceOf('protokol-ecommerce');
3315
+ }
3243
3316
  async isInstalled(id) {
3244
3317
  const { data } = await this.client.get("/v1/integrations");
3245
3318
  return data.find((i) => i.id == id) !== undefined;
@@ -3285,6 +3358,7 @@ var ProtokolSDK010 = (function (exports, axios) {
3285
3358
  exports.ComponentUtils = ComponentUtils;
3286
3359
  exports.Config = Config;
3287
3360
  exports.DMS = DMS;
3361
+ exports.Ecommerce = Ecommerce;
3288
3362
  exports.Forge = Forge;
3289
3363
  exports.Functions = Functions;
3290
3364
  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') == "forge") {
52
- headers['X-Project-Env'] = (_b = sessionStorage.getItem('forge_app_env')) !== null && _b !== void 0 ? _b : "dev";
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 : "dev";
59
+ headers['X-Project-Env'] = (_c = localStorage.getItem('current_env')) !== null && _c !== void 0 ? _c : 'dev';
56
60
  }
57
61
  }
58
62
  }
@@ -236,7 +240,7 @@ var ProtokolSDK09 = (function (exports, axios) {
236
240
  async updateMany(data, options) {
237
241
  return await this.client.patch(`${this.getComponentPath()}/models/bulk`, {
238
242
  data,
239
- options
243
+ options,
240
244
  });
241
245
  }
242
246
  /**
@@ -470,16 +474,6 @@ var ProtokolSDK09 = (function (exports, axios) {
470
474
  async update(uuid, update) {
471
475
  return await this.client.patch(`/v1/system/function/${uuid}`, update);
472
476
  }
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
477
  async run(id, d) {
484
478
  const { data } = await this.client.post(`/v1/system/function/run/${id}`, d.input, {
485
479
  params: d.query,
@@ -923,10 +917,9 @@ var ProtokolSDK09 = (function (exports, axios) {
923
917
  }
924
918
 
925
919
  class System extends PlatformBaseClient {
926
- async resourceResolver(ref, resourceName, format) {
920
+ async resourceResolver(prn, format) {
927
921
  return await this.client.post("/v3/system/resource-resolver", {
928
- type: resourceName,
929
- ref,
922
+ prn,
930
923
  format,
931
924
  });
932
925
  }
@@ -1253,11 +1246,15 @@ var ProtokolSDK09 = (function (exports, axios) {
1253
1246
  env = env !== null && env !== void 0 ? env : __global_env__ === null || __global_env__ === void 0 ? void 0 : __global_env__.PROJECT_ENV;
1254
1247
  token = token !== null && token !== void 0 ? token : __global_env__ === null || __global_env__ === void 0 ? void 0 : __global_env__.PROJECT_API_TOKEN;
1255
1248
  if (isBrowser) {
1256
- if (sessionStorage.getItem('protokol_context') == "forge") {
1257
- headers['X-Project-Env'] = (_b = sessionStorage.getItem('forge_app_env')) !== null && _b !== void 0 ? _b : "dev";
1249
+ if (sessionStorage.getItem('protokol_context') === 'forge') {
1250
+ headers['X-Project-Env'] = (_b = sessionStorage.getItem('forge_app_env')) !== null && _b !== void 0 ? _b : 'dev';
1251
+ // pick up forge actor token — overrides any other token source
1252
+ const forgeToken = sessionStorage.getItem('forge_actor_token');
1253
+ if (forgeToken)
1254
+ token = forgeToken;
1258
1255
  }
1259
1256
  else {
1260
- headers['X-Project-Env'] = (_c = localStorage.getItem('current_env')) !== null && _c !== void 0 ? _c : "dev";
1257
+ headers['X-Project-Env'] = (_c = localStorage.getItem('current_env')) !== null && _c !== void 0 ? _c : 'dev';
1261
1258
  }
1262
1259
  }
1263
1260
  }
@@ -2891,6 +2888,57 @@ var ProtokolSDK09 = (function (exports, axios) {
2891
2888
  }
2892
2889
  }
2893
2890
 
2891
+ class Ecommerce extends IntegrationsBaseClient {
2892
+ /**
2893
+ * Get the ecommerce integration user for the current project.
2894
+ */
2895
+ async get() {
2896
+ return await this.client.get(`/v1/ecomm/user`);
2897
+ }
2898
+ /**
2899
+ * Update ecommerce integration settings (onboarding or partial update).
2900
+ */
2901
+ async update(req) {
2902
+ return await this.client.patch(`/v1/ecomm/user`, req);
2903
+ }
2904
+ /**
2905
+ * Check whether a base domain subdomain is available.
2906
+ */
2907
+ async checkBaseDomain(domain) {
2908
+ return await this.client.post(`/v1/ecomm/base-domain/check`, { domain });
2909
+ }
2910
+ /**
2911
+ * Add a custom domain (returns a verification token for DNS validation).
2912
+ */
2913
+ async addCustomDomain(domain) {
2914
+ return await this.client.post(`/v1/ecomm/domains`, { domain });
2915
+ }
2916
+ /**
2917
+ * Validate a custom domain with its verification token.
2918
+ */
2919
+ async validateCustomDomain(domain, token) {
2920
+ return await this.client.post(`/v1/ecomm/domains/validate`, { domain, token });
2921
+ }
2922
+ /**
2923
+ * Remove a custom domain.
2924
+ */
2925
+ async removeCustomDomain(domain) {
2926
+ return await this.client.delete(`/v1/ecomm/domains`, { data: { domain } });
2927
+ }
2928
+ /**
2929
+ * List pending (unvalidated) custom domains.
2930
+ */
2931
+ async getPendingDomains() {
2932
+ return await this.client.get(`/v1/ecomm/domains/pending`);
2933
+ }
2934
+ /**
2935
+ * List validated custom domains.
2936
+ */
2937
+ async getValidatedDomains() {
2938
+ return await this.client.get(`/v1/ecomm/domains/validated`);
2939
+ }
2940
+ }
2941
+
2894
2942
  // import integrations
2895
2943
  class Integrations extends IntegrationsBaseClient {
2896
2944
  constructor(options) {
@@ -2903,6 +2951,7 @@ var ProtokolSDK09 = (function (exports, axios) {
2903
2951
  'serbia-utilities': new SerbiaUtil().setClient(this.client),
2904
2952
  'protokol-payments': new Payments().setClient(this.client),
2905
2953
  'protokol-minimax': new Minimax().setClient(this.client),
2954
+ 'protokol-ecommerce': new Ecommerce().setClient(this.client),
2906
2955
  };
2907
2956
  }
2908
2957
  getSerbiaUtilities() {
@@ -2926,6 +2975,9 @@ var ProtokolSDK09 = (function (exports, axios) {
2926
2975
  getMinimax() {
2927
2976
  return this.getInterfaceOf('protokol-minimax');
2928
2977
  }
2978
+ getEcommerce() {
2979
+ return this.getInterfaceOf('protokol-ecommerce');
2980
+ }
2929
2981
  async isInstalled(id) {
2930
2982
  const { data } = await this.client.get("/v1/integrations");
2931
2983
  return data.find((i) => i.id == id) !== undefined;
@@ -2950,6 +3002,7 @@ var ProtokolSDK09 = (function (exports, axios) {
2950
3002
  exports.ComponentUtils = ComponentUtils;
2951
3003
  exports.Config = Config;
2952
3004
  exports.DMS = DMS;
3005
+ exports.Ecommerce = Ecommerce;
2953
3006
  exports.Forge = Forge;
2954
3007
  exports.Functions = Functions;
2955
3008
  exports.Integration = Integrations;
package/dist/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ptkl/sdk",
3
- "version": "1.3.4",
3
+ "version": "1.4.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
- export default class Component extends PlatformBaseClient {
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
- constructor(ref?: string | null);
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<FindResponse>>;
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: FindOptions): Promise<Model | null>;
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<Model>>;
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: UpdateOptions): Promise<AxiosResponse<any, any>>;
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: UpdateManyOptions): Promise<AxiosResponse<any, any>>;
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: CreateManyOptions): Promise<AxiosResponse<any, any>>;
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: ModifyOptions): Promise<AxiosResponse<any, any>>;
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: UpdateOptions): Promise<AxiosResponse<any, any>>;
130
- create(model: Record<string, any>): Promise<AxiosResponse<any, any>>;
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: string, input: any): Promise<AxiosResponse<any, any>>;
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
- * @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>;
@@ -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: string): Component;
25
+ component<C extends string>(ref: C): Component<C>;
26
26
  componentUtils(): ComponentUtils;
27
27
  ratchet(): Ratchet;
28
28
  sandbox(): Sandbox;
@@ -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
- resourceResolver(ref: string, resourceName: string, format?: string): Promise<import("axios").AxiosResponse<any, any>>;
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
  }