@ptkl/sdk 1.3.4 → 1.5.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -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
  }
@@ -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') == "forge") {
19018
- headers['X-Project-Env'] = (_d = sessionStorage.getItem('forge_app_env')) !== null && _d !== void 0 ? _d : "dev";
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 : "dev";
19025
+ headers['X-Project-Env'] = (_e = localStorage.getItem('current_env')) !== null && _e !== void 0 ? _e : 'dev';
19022
19026
  }
19023
19027
  }
19024
19028
  }
@@ -19044,7 +19048,6 @@ class PlatformBaseClient extends BaseClient {
19044
19048
  ...headers,
19045
19049
  'Content-Type': 'application/json',
19046
19050
  },
19047
- withCredentials: true,
19048
19051
  });
19049
19052
  super(client);
19050
19053
  this.env = null;
@@ -19054,6 +19057,11 @@ class PlatformBaseClient extends BaseClient {
19054
19057
  }
19055
19058
 
19056
19059
  class Component extends PlatformBaseClient {
19060
+ /**
19061
+ * @param ref - Component ref (e.g. "ecommerce::order"). Passing a string
19062
+ * literal lets TypeScript infer the generic C and type find/create/function
19063
+ * results accordingly.
19064
+ */
19057
19065
  constructor(ref = null) {
19058
19066
  super();
19059
19067
  this.ref = ref;
@@ -19199,7 +19207,7 @@ class Component extends PlatformBaseClient {
19199
19207
  async updateMany(data, options) {
19200
19208
  return await this.client.patch(`/v4/system/component/${this.ref}/models/bulk`, {
19201
19209
  data,
19202
- options
19210
+ options,
19203
19211
  });
19204
19212
  }
19205
19213
  /**
@@ -19604,16 +19612,6 @@ class Functions extends PlatformBaseClient {
19604
19612
  async update(uuid, update) {
19605
19613
  return await this.client.patch(`/v1/system/function/${uuid}`, update);
19606
19614
  }
19607
- /**
19608
- * Run platform function
19609
- *
19610
- * @param id - Function ID
19611
- * @param d - Object containing input data, query parameters, and headers
19612
- * @returns - Function result
19613
- *
19614
- * @example
19615
- * const result = await platform.function().run("myFunction", {input: { foo: "bar" }})
19616
- */
19617
19615
  async run(id, d) {
19618
19616
  const { data } = await this.client.post(`/v1/system/function/run/${id}`, d.input, {
19619
19617
  params: d.query,
@@ -20068,10 +20066,25 @@ class Sandbox extends PlatformBaseClient {
20068
20066
  }
20069
20067
 
20070
20068
  class System extends PlatformBaseClient {
20071
- async resourceResolver(ref, resourceName, format) {
20069
+ /**
20070
+ * Returns all IDL definitions for the current project.
20071
+ * Used by `ptkl generate-types` to emit typed `.d.ts` augmentations.
20072
+ */
20073
+ async idl() {
20074
+ return await this.client.get('/v1/system/idl');
20075
+ }
20076
+ /**
20077
+ * Validates a value against an IDL — either by ref or with an inline IDL object.
20078
+ * Returns `{ data: { valid: true } }` on success or
20079
+ * `{ data: { valid: false, errors: [...] } }` on validation failure.
20080
+ * Throws on HTTP errors (4xx/5xx).
20081
+ */
20082
+ async idlValidate(req) {
20083
+ return await this.client.post('/v1/system/idl/validate', req);
20084
+ }
20085
+ async resourceResolver(prn, format) {
20072
20086
  return await this.client.post("/v3/system/resource-resolver", {
20073
- type: resourceName,
20074
- ref,
20087
+ prn,
20075
20088
  format,
20076
20089
  });
20077
20090
  }
@@ -20373,11 +20386,15 @@ class IntegrationsBaseClient extends BaseClient {
20373
20386
  env = env !== null && env !== void 0 ? env : __global_env__ === null || __global_env__ === void 0 ? void 0 : __global_env__.PROJECT_ENV;
20374
20387
  token = token !== null && token !== void 0 ? token : __global_env__ === null || __global_env__ === void 0 ? void 0 : __global_env__.PROJECT_API_TOKEN;
20375
20388
  if (isBrowser) {
20376
- if (sessionStorage.getItem('protokol_context') == "forge") {
20377
- headers['X-Project-Env'] = (_b = sessionStorage.getItem('forge_app_env')) !== null && _b !== void 0 ? _b : "dev";
20389
+ if (sessionStorage.getItem('protokol_context') === 'forge') {
20390
+ headers['X-Project-Env'] = (_b = sessionStorage.getItem('forge_app_env')) !== null && _b !== void 0 ? _b : 'dev';
20391
+ // pick up forge actor token — overrides any other token source
20392
+ const forgeToken = sessionStorage.getItem('forge_actor_token');
20393
+ if (forgeToken)
20394
+ token = forgeToken;
20378
20395
  }
20379
20396
  else {
20380
- headers['X-Project-Env'] = (_c = localStorage.getItem('current_env')) !== null && _c !== void 0 ? _c : "dev";
20397
+ headers['X-Project-Env'] = (_c = localStorage.getItem('current_env')) !== null && _c !== void 0 ? _c : 'dev';
20381
20398
  }
20382
20399
  }
20383
20400
  }
@@ -20402,7 +20419,6 @@ class IntegrationsBaseClient extends BaseClient {
20402
20419
  headers: {
20403
20420
  ...headers,
20404
20421
  },
20405
- withCredentials: true,
20406
20422
  });
20407
20423
  super(client);
20408
20424
  this.env = null;
@@ -22173,6 +22189,57 @@ class NBS extends IntegrationsBaseClient {
22173
22189
  }
22174
22190
  }
22175
22191
 
22192
+ class Ecommerce extends IntegrationsBaseClient {
22193
+ /**
22194
+ * Get the ecommerce integration user for the current project.
22195
+ */
22196
+ async get() {
22197
+ return await this.client.get(`/v1/ecomm/user`);
22198
+ }
22199
+ /**
22200
+ * Update ecommerce integration settings (onboarding or partial update).
22201
+ */
22202
+ async update(req) {
22203
+ return await this.client.patch(`/v1/ecomm/user`, req);
22204
+ }
22205
+ /**
22206
+ * Check whether a base domain subdomain is available.
22207
+ */
22208
+ async checkBaseDomain(domain) {
22209
+ return await this.client.post(`/v1/ecomm/base-domain/check`, { domain });
22210
+ }
22211
+ /**
22212
+ * Add a custom domain (returns a verification token for DNS validation).
22213
+ */
22214
+ async addCustomDomain(domain) {
22215
+ return await this.client.post(`/v1/ecomm/domains`, { domain });
22216
+ }
22217
+ /**
22218
+ * Validate a custom domain with its verification token.
22219
+ */
22220
+ async validateCustomDomain(domain, token) {
22221
+ return await this.client.post(`/v1/ecomm/domains/validate`, { domain, token });
22222
+ }
22223
+ /**
22224
+ * Remove a custom domain.
22225
+ */
22226
+ async removeCustomDomain(domain) {
22227
+ return await this.client.delete(`/v1/ecomm/domains`, { data: { domain } });
22228
+ }
22229
+ /**
22230
+ * List pending (unvalidated) custom domains.
22231
+ */
22232
+ async getPendingDomains() {
22233
+ return await this.client.get(`/v1/ecomm/domains/pending`);
22234
+ }
22235
+ /**
22236
+ * List validated custom domains.
22237
+ */
22238
+ async getValidatedDomains() {
22239
+ return await this.client.get(`/v1/ecomm/domains/validated`);
22240
+ }
22241
+ }
22242
+
22176
22243
  class Integrations extends IntegrationsBaseClient {
22177
22244
  constructor(options) {
22178
22245
  super(options);
@@ -22183,6 +22250,7 @@ class Integrations extends IntegrationsBaseClient {
22183
22250
  'nbs': new NBS().setClient(this.client),
22184
22251
  'protokol-payments': new Payments().setClient(this.client),
22185
22252
  'protokol-minimax': new Minimax().setClient(this.client),
22253
+ 'protokol-ecommerce': new Ecommerce().setClient(this.client),
22186
22254
  };
22187
22255
  }
22188
22256
  getDMS() {
@@ -22206,6 +22274,9 @@ class Integrations extends IntegrationsBaseClient {
22206
22274
  getSerbiaMinFin() {
22207
22275
  return this.getInterfaceOf('serbia-minfin');
22208
22276
  }
22277
+ getEcommerce() {
22278
+ return this.getInterfaceOf('protokol-ecommerce');
22279
+ }
22209
22280
  async isInstalled(id) {
22210
22281
  const { data } = await this.client.get("/v1/integrations");
22211
22282
  return data.find((i) => i.id == id) !== undefined;
@@ -22251,6 +22322,7 @@ exports.Component = Component;
22251
22322
  exports.ComponentUtils = ComponentUtils;
22252
22323
  exports.Config = Config;
22253
22324
  exports.DMS = DMS;
22325
+ exports.Ecommerce = Ecommerce;
22254
22326
  exports.Forge = Forge;
22255
22327
  exports.Functions = Functions;
22256
22328
  exports.Integration = Integrations;
@@ -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') == "forge") {
51
- headers['X-Project-Env'] = (_d = sessionStorage.getItem('forge_app_env')) !== null && _d !== void 0 ? _d : "dev";
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 : "dev";
58
+ headers['X-Project-Env'] = (_e = localStorage.getItem('current_env')) !== null && _e !== void 0 ? _e : 'dev';
55
59
  }
56
60
  }
57
61
  }
@@ -77,7 +81,6 @@ class PlatformBaseClient extends BaseClient {
77
81
  ...headers,
78
82
  'Content-Type': 'application/json',
79
83
  },
80
- withCredentials: true,
81
84
  });
82
85
  super(client);
83
86
  this.env = null;
@@ -87,6 +90,11 @@ class PlatformBaseClient extends BaseClient {
87
90
  }
88
91
 
89
92
  class Component extends PlatformBaseClient {
93
+ /**
94
+ * @param ref - Component ref (e.g. "ecommerce::order"). Passing a string
95
+ * literal lets TypeScript infer the generic C and type find/create/function
96
+ * results accordingly.
97
+ */
90
98
  constructor(ref = null) {
91
99
  super();
92
100
  this.ref = ref;
@@ -232,7 +240,7 @@ class Component extends PlatformBaseClient {
232
240
  async updateMany(data, options) {
233
241
  return await this.client.patch(`/v4/system/component/${this.ref}/models/bulk`, {
234
242
  data,
235
- options
243
+ options,
236
244
  });
237
245
  }
238
246
  /**
@@ -637,16 +645,6 @@ class Functions extends PlatformBaseClient {
637
645
  async update(uuid, update) {
638
646
  return await this.client.patch(`/v1/system/function/${uuid}`, update);
639
647
  }
640
- /**
641
- * Run platform function
642
- *
643
- * @param id - Function ID
644
- * @param d - Object containing input data, query parameters, and headers
645
- * @returns - Function result
646
- *
647
- * @example
648
- * const result = await platform.function().run("myFunction", {input: { foo: "bar" }})
649
- */
650
648
  async run(id, d) {
651
649
  const { data } = await this.client.post(`/v1/system/function/run/${id}`, d.input, {
652
650
  params: d.query,
@@ -1101,10 +1099,25 @@ class Sandbox extends PlatformBaseClient {
1101
1099
  }
1102
1100
 
1103
1101
  class System extends PlatformBaseClient {
1104
- async resourceResolver(ref, resourceName, format) {
1102
+ /**
1103
+ * Returns all IDL definitions for the current project.
1104
+ * Used by `ptkl generate-types` to emit typed `.d.ts` augmentations.
1105
+ */
1106
+ async idl() {
1107
+ return await this.client.get('/v1/system/idl');
1108
+ }
1109
+ /**
1110
+ * Validates a value against an IDL — either by ref or with an inline IDL object.
1111
+ * Returns `{ data: { valid: true } }` on success or
1112
+ * `{ data: { valid: false, errors: [...] } }` on validation failure.
1113
+ * Throws on HTTP errors (4xx/5xx).
1114
+ */
1115
+ async idlValidate(req) {
1116
+ return await this.client.post('/v1/system/idl/validate', req);
1117
+ }
1118
+ async resourceResolver(prn, format) {
1105
1119
  return await this.client.post("/v3/system/resource-resolver", {
1106
- type: resourceName,
1107
- ref,
1120
+ prn,
1108
1121
  format,
1109
1122
  });
1110
1123
  }
@@ -1406,11 +1419,15 @@ class IntegrationsBaseClient extends BaseClient {
1406
1419
  env = env !== null && env !== void 0 ? env : __global_env__ === null || __global_env__ === void 0 ? void 0 : __global_env__.PROJECT_ENV;
1407
1420
  token = token !== null && token !== void 0 ? token : __global_env__ === null || __global_env__ === void 0 ? void 0 : __global_env__.PROJECT_API_TOKEN;
1408
1421
  if (isBrowser) {
1409
- if (sessionStorage.getItem('protokol_context') == "forge") {
1410
- headers['X-Project-Env'] = (_b = sessionStorage.getItem('forge_app_env')) !== null && _b !== void 0 ? _b : "dev";
1422
+ if (sessionStorage.getItem('protokol_context') === 'forge') {
1423
+ headers['X-Project-Env'] = (_b = sessionStorage.getItem('forge_app_env')) !== null && _b !== void 0 ? _b : 'dev';
1424
+ // pick up forge actor token — overrides any other token source
1425
+ const forgeToken = sessionStorage.getItem('forge_actor_token');
1426
+ if (forgeToken)
1427
+ token = forgeToken;
1411
1428
  }
1412
1429
  else {
1413
- headers['X-Project-Env'] = (_c = localStorage.getItem('current_env')) !== null && _c !== void 0 ? _c : "dev";
1430
+ headers['X-Project-Env'] = (_c = localStorage.getItem('current_env')) !== null && _c !== void 0 ? _c : 'dev';
1414
1431
  }
1415
1432
  }
1416
1433
  }
@@ -1435,7 +1452,6 @@ class IntegrationsBaseClient extends BaseClient {
1435
1452
  headers: {
1436
1453
  ...headers,
1437
1454
  },
1438
- withCredentials: true,
1439
1455
  });
1440
1456
  super(client);
1441
1457
  this.env = null;
@@ -3206,6 +3222,57 @@ class NBS extends IntegrationsBaseClient {
3206
3222
  }
3207
3223
  }
3208
3224
 
3225
+ class Ecommerce extends IntegrationsBaseClient {
3226
+ /**
3227
+ * Get the ecommerce integration user for the current project.
3228
+ */
3229
+ async get() {
3230
+ return await this.client.get(`/v1/ecomm/user`);
3231
+ }
3232
+ /**
3233
+ * Update ecommerce integration settings (onboarding or partial update).
3234
+ */
3235
+ async update(req) {
3236
+ return await this.client.patch(`/v1/ecomm/user`, req);
3237
+ }
3238
+ /**
3239
+ * Check whether a base domain subdomain is available.
3240
+ */
3241
+ async checkBaseDomain(domain) {
3242
+ return await this.client.post(`/v1/ecomm/base-domain/check`, { domain });
3243
+ }
3244
+ /**
3245
+ * Add a custom domain (returns a verification token for DNS validation).
3246
+ */
3247
+ async addCustomDomain(domain) {
3248
+ return await this.client.post(`/v1/ecomm/domains`, { domain });
3249
+ }
3250
+ /**
3251
+ * Validate a custom domain with its verification token.
3252
+ */
3253
+ async validateCustomDomain(domain, token) {
3254
+ return await this.client.post(`/v1/ecomm/domains/validate`, { domain, token });
3255
+ }
3256
+ /**
3257
+ * Remove a custom domain.
3258
+ */
3259
+ async removeCustomDomain(domain) {
3260
+ return await this.client.delete(`/v1/ecomm/domains`, { data: { domain } });
3261
+ }
3262
+ /**
3263
+ * List pending (unvalidated) custom domains.
3264
+ */
3265
+ async getPendingDomains() {
3266
+ return await this.client.get(`/v1/ecomm/domains/pending`);
3267
+ }
3268
+ /**
3269
+ * List validated custom domains.
3270
+ */
3271
+ async getValidatedDomains() {
3272
+ return await this.client.get(`/v1/ecomm/domains/validated`);
3273
+ }
3274
+ }
3275
+
3209
3276
  class Integrations extends IntegrationsBaseClient {
3210
3277
  constructor(options) {
3211
3278
  super(options);
@@ -3216,6 +3283,7 @@ class Integrations extends IntegrationsBaseClient {
3216
3283
  'nbs': new NBS().setClient(this.client),
3217
3284
  'protokol-payments': new Payments().setClient(this.client),
3218
3285
  'protokol-minimax': new Minimax().setClient(this.client),
3286
+ 'protokol-ecommerce': new Ecommerce().setClient(this.client),
3219
3287
  };
3220
3288
  }
3221
3289
  getDMS() {
@@ -3239,6 +3307,9 @@ class Integrations extends IntegrationsBaseClient {
3239
3307
  getSerbiaMinFin() {
3240
3308
  return this.getInterfaceOf('serbia-minfin');
3241
3309
  }
3310
+ getEcommerce() {
3311
+ return this.getInterfaceOf('protokol-ecommerce');
3312
+ }
3242
3313
  async isInstalled(id) {
3243
3314
  const { data } = await this.client.get("/v1/integrations");
3244
3315
  return data.find((i) => i.id == id) !== undefined;
@@ -3278,4 +3349,4 @@ class Invoicing extends PlatformBaseClient {
3278
3349
  }
3279
3350
  }
3280
3351
 
3281
- 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 };
3352
+ 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
- forceUpdateProtectedFields: boolean;
68
+ force_update_protected_fields: boolean;
69
69
  };
70
70
  type UpdateManyOptions = UpdateOptions & {
71
- rollbackOnError: boolean;
71
+ rollback_on_error: boolean;
72
72
  };
73
73
  type CreateManyOptions = {
74
- rollbackOnError: boolean;
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;