@ptkl/sdk 1.7.1 → 1.9.1

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.
@@ -1253,6 +1253,21 @@ var ProtokolSDK010 = (function (exports, axios) {
1253
1253
  }
1254
1254
 
1255
1255
  class Workflow extends PlatformBaseClient {
1256
+ async create(data) {
1257
+ return await this.client.post(`/v1/project/workflow/workflow`, data);
1258
+ }
1259
+ async update(id, data) {
1260
+ return await this.client.patch(`/v1/project/workflow/workflow/${id}`, data);
1261
+ }
1262
+ async get(id) {
1263
+ return await this.client.get(`/v1/project/workflow/workflow/${id}`);
1264
+ }
1265
+ async list() {
1266
+ return await this.client.get(`/v1/project/workflow/workflows`);
1267
+ }
1268
+ async delete(id) {
1269
+ return await this.client.delete(`/v1/project/workflow/workflow/${id}`);
1270
+ }
1256
1271
  async trigger(id, event, data) {
1257
1272
  return await this.client.post(`/v1/project/workflow/workflow/${id}/event/${event}`, data);
1258
1273
  }
@@ -3454,10 +3469,18 @@ var ProtokolSDK010 = (function (exports, axios) {
3454
3469
  getEcommerce() {
3455
3470
  return this.getInterfaceOf('protokol-ecommerce');
3456
3471
  }
3472
+ async list() {
3473
+ const { data } = await this.client.get("/v1/integrations");
3474
+ return data;
3475
+ }
3457
3476
  async isInstalled(id) {
3458
3477
  const { data } = await this.client.get("/v1/integrations");
3459
3478
  return data.find((i) => i.id == id) !== undefined;
3460
3479
  }
3480
+ async isActive(id) {
3481
+ const { data } = await this.client.get("/v1/integrations");
3482
+ return data.find((i) => i.id == id && i.status == "active") !== undefined;
3483
+ }
3461
3484
  getInterfaceOf(id) {
3462
3485
  try {
3463
3486
  return this.integrations[id];
@@ -3468,6 +3491,133 @@ var ProtokolSDK010 = (function (exports, axios) {
3468
3491
  }
3469
3492
  }
3470
3493
 
3494
+ // PRN — Protokol Resource Name
3495
+ //
3496
+ // Format:
3497
+ // prn:<type>:<ref>[:<path>][?<query>]
3498
+ //
3499
+ // Examples:
3500
+ // prn:component:my-component:settings.api_key
3501
+ // prn:integration:protokol-ecommerce:company.legal_name?lang=en
3502
+ // prn:user:actor:forge?app=abc123&behalf=user-uuid
3503
+ /**
3504
+ * Splits s on sep into at most n parts, keeping the remainder in the last part.
3505
+ * Mirrors Go's strings.SplitN behaviour.
3506
+ */
3507
+ function splitN(s, sep, n) {
3508
+ const parts = [];
3509
+ let start = 0;
3510
+ for (let i = 1; i < n; i++) {
3511
+ const idx = s.indexOf(sep, start);
3512
+ if (idx === -1)
3513
+ break;
3514
+ parts.push(s.slice(start, idx));
3515
+ start = idx + sep.length;
3516
+ }
3517
+ parts.push(s.slice(start));
3518
+ return parts;
3519
+ }
3520
+ class PRN {
3521
+ constructor(raw) {
3522
+ this._raw = raw;
3523
+ }
3524
+ /**
3525
+ * Validates a PRN string and returns it as a PRN instance.
3526
+ * Throws if the string is not a valid PRN.
3527
+ */
3528
+ static parse(s) {
3529
+ const parts = splitN(s, ':', 4);
3530
+ if (parts.length < 3) {
3531
+ throw new Error(`invalid PRN "${s}": expected format prn:<type>:<ref>[:<path>]`);
3532
+ }
3533
+ if (parts[0] !== 'prn') {
3534
+ throw new Error(`invalid PRN "${s}": must start with 'prn'`);
3535
+ }
3536
+ if (!parts[1]) {
3537
+ throw new Error(`invalid PRN "${s}": type must not be empty`);
3538
+ }
3539
+ if (!parts[2]) {
3540
+ throw new Error(`invalid PRN "${s}": ref must not be empty`);
3541
+ }
3542
+ return new PRN(s);
3543
+ }
3544
+ /**
3545
+ * Constructs a PRN from its constituent parts.
3546
+ * Params are sorted by key for deterministic output.
3547
+ */
3548
+ static create(type, ref, path, params) {
3549
+ let s = `prn:${type}:${ref}`;
3550
+ if (path) {
3551
+ s += `:${path}`;
3552
+ }
3553
+ if (params && Object.keys(params).length > 0) {
3554
+ const sorted = Object.keys(params).sort();
3555
+ const qs = new URLSearchParams();
3556
+ for (const k of sorted) {
3557
+ qs.set(k, params[k]);
3558
+ }
3559
+ s += `?${qs.toString()}`;
3560
+ }
3561
+ return new PRN(s);
3562
+ }
3563
+ _parse() {
3564
+ var _a, _b;
3565
+ const s = this._raw;
3566
+ const parts = splitN(s, ':', 4);
3567
+ const type = (_a = parts[1]) !== null && _a !== void 0 ? _a : '';
3568
+ const ref = (_b = parts[2]) !== null && _b !== void 0 ? _b : '';
3569
+ let path = '';
3570
+ const params = {};
3571
+ if (parts.length === 4 && parts[3]) {
3572
+ const rawPath = parts[3];
3573
+ const qIdx = rawPath.indexOf('?');
3574
+ if (qIdx >= 0) {
3575
+ path = rawPath.slice(0, qIdx);
3576
+ const qs = new URLSearchParams(rawPath.slice(qIdx + 1));
3577
+ qs.forEach((v, k) => {
3578
+ params[k] = v;
3579
+ });
3580
+ }
3581
+ else {
3582
+ path = rawPath;
3583
+ }
3584
+ }
3585
+ return { type, ref, path, params };
3586
+ }
3587
+ /** The resource category — e.g. "component", "integration", "user". */
3588
+ get type() {
3589
+ return this._parse().type;
3590
+ }
3591
+ /** The resource identifier within its type — slug, UUID, name. */
3592
+ get ref() {
3593
+ return this._parse().ref;
3594
+ }
3595
+ /** The resource path segment, or empty string if absent. */
3596
+ get path() {
3597
+ return this._parse().path;
3598
+ }
3599
+ /** All query-string key-value pairs, or empty object if none. */
3600
+ get params() {
3601
+ return this._parse().params;
3602
+ }
3603
+ /** Returns the value for the given query-param key, or empty string if not present. */
3604
+ param(key) {
3605
+ var _a;
3606
+ return (_a = this._parse().params[key]) !== null && _a !== void 0 ? _a : '';
3607
+ }
3608
+ toString() {
3609
+ return this._raw;
3610
+ }
3611
+ }
3612
+ /**
3613
+ * Convenience wrapper around PRN.parse.
3614
+ * Validates a PRN string and returns a PRN instance.
3615
+ * Throws if the string is not a valid PRN.
3616
+ */
3617
+ function parsePRN(s) {
3618
+ return PRN.parse(s);
3619
+ }
3620
+
3471
3621
  class Invoicing extends PlatformBaseClient {
3472
3622
  async getSalesInvoices(provider, page) {
3473
3623
  return await this.request("GET", `invoices/${provider}/sales`, {
@@ -3507,6 +3657,7 @@ var ProtokolSDK010 = (function (exports, axios) {
3507
3657
  exports.Invoicing = Invoicing;
3508
3658
  exports.Mail = Mail;
3509
3659
  exports.NBS = NBS;
3660
+ exports.PRN = PRN;
3510
3661
  exports.Payments = Payments;
3511
3662
  exports.Platform = Platform;
3512
3663
  exports.Project = Project;
@@ -3518,6 +3669,7 @@ var ProtokolSDK010 = (function (exports, axios) {
3518
3669
  exports.Users = Users;
3519
3670
  exports.VPFR = VPFR;
3520
3671
  exports.Workflow = Workflow;
3672
+ exports.parsePRN = parsePRN;
3521
3673
 
3522
3674
  return exports;
3523
3675
 
package/dist/index.0.9.js CHANGED
@@ -940,6 +940,21 @@ var ProtokolSDK09 = (function (exports, axios) {
940
940
  }
941
941
 
942
942
  class Workflow extends PlatformBaseClient {
943
+ async create(data) {
944
+ return await this.client.post(`/v1/project/workflow/workflow`, data);
945
+ }
946
+ async update(id, data) {
947
+ return await this.client.patch(`/v1/project/workflow/workflow/${id}`, data);
948
+ }
949
+ async get(id) {
950
+ return await this.client.get(`/v1/project/workflow/workflow/${id}`);
951
+ }
952
+ async list() {
953
+ return await this.client.get(`/v1/project/workflow/workflows`);
954
+ }
955
+ async delete(id) {
956
+ return await this.client.delete(`/v1/project/workflow/workflow/${id}`);
957
+ }
943
958
  async trigger(id, event, data) {
944
959
  return await this.client.post(`/v1/project/workflow/workflow/${id}/event/${event}`, data);
945
960
  }
@@ -2991,10 +3006,18 @@ var ProtokolSDK09 = (function (exports, axios) {
2991
3006
  getEcommerce() {
2992
3007
  return this.getInterfaceOf('protokol-ecommerce');
2993
3008
  }
3009
+ async list() {
3010
+ const { data } = await this.client.get("/v1/integrations");
3011
+ return data;
3012
+ }
2994
3013
  async isInstalled(id) {
2995
3014
  const { data } = await this.client.get("/v1/integrations");
2996
3015
  return data.find((i) => i.id == id) !== undefined;
2997
3016
  }
3017
+ async isActive(id) {
3018
+ const { data } = await this.client.get("/v1/integrations");
3019
+ return data.find((i) => i.id == id && i.status == "active") !== undefined;
3020
+ }
2998
3021
  getInterfaceOf(id) {
2999
3022
  try {
3000
3023
  return this.integrations[id];
@@ -3005,6 +3028,133 @@ var ProtokolSDK09 = (function (exports, axios) {
3005
3028
  }
3006
3029
  }
3007
3030
 
3031
+ // PRN — Protokol Resource Name
3032
+ //
3033
+ // Format:
3034
+ // prn:<type>:<ref>[:<path>][?<query>]
3035
+ //
3036
+ // Examples:
3037
+ // prn:component:my-component:settings.api_key
3038
+ // prn:integration:protokol-ecommerce:company.legal_name?lang=en
3039
+ // prn:user:actor:forge?app=abc123&behalf=user-uuid
3040
+ /**
3041
+ * Splits s on sep into at most n parts, keeping the remainder in the last part.
3042
+ * Mirrors Go's strings.SplitN behaviour.
3043
+ */
3044
+ function splitN(s, sep, n) {
3045
+ const parts = [];
3046
+ let start = 0;
3047
+ for (let i = 1; i < n; i++) {
3048
+ const idx = s.indexOf(sep, start);
3049
+ if (idx === -1)
3050
+ break;
3051
+ parts.push(s.slice(start, idx));
3052
+ start = idx + sep.length;
3053
+ }
3054
+ parts.push(s.slice(start));
3055
+ return parts;
3056
+ }
3057
+ class PRN {
3058
+ constructor(raw) {
3059
+ this._raw = raw;
3060
+ }
3061
+ /**
3062
+ * Validates a PRN string and returns it as a PRN instance.
3063
+ * Throws if the string is not a valid PRN.
3064
+ */
3065
+ static parse(s) {
3066
+ const parts = splitN(s, ':', 4);
3067
+ if (parts.length < 3) {
3068
+ throw new Error(`invalid PRN "${s}": expected format prn:<type>:<ref>[:<path>]`);
3069
+ }
3070
+ if (parts[0] !== 'prn') {
3071
+ throw new Error(`invalid PRN "${s}": must start with 'prn'`);
3072
+ }
3073
+ if (!parts[1]) {
3074
+ throw new Error(`invalid PRN "${s}": type must not be empty`);
3075
+ }
3076
+ if (!parts[2]) {
3077
+ throw new Error(`invalid PRN "${s}": ref must not be empty`);
3078
+ }
3079
+ return new PRN(s);
3080
+ }
3081
+ /**
3082
+ * Constructs a PRN from its constituent parts.
3083
+ * Params are sorted by key for deterministic output.
3084
+ */
3085
+ static create(type, ref, path, params) {
3086
+ let s = `prn:${type}:${ref}`;
3087
+ if (path) {
3088
+ s += `:${path}`;
3089
+ }
3090
+ if (params && Object.keys(params).length > 0) {
3091
+ const sorted = Object.keys(params).sort();
3092
+ const qs = new URLSearchParams();
3093
+ for (const k of sorted) {
3094
+ qs.set(k, params[k]);
3095
+ }
3096
+ s += `?${qs.toString()}`;
3097
+ }
3098
+ return new PRN(s);
3099
+ }
3100
+ _parse() {
3101
+ var _a, _b;
3102
+ const s = this._raw;
3103
+ const parts = splitN(s, ':', 4);
3104
+ const type = (_a = parts[1]) !== null && _a !== void 0 ? _a : '';
3105
+ const ref = (_b = parts[2]) !== null && _b !== void 0 ? _b : '';
3106
+ let path = '';
3107
+ const params = {};
3108
+ if (parts.length === 4 && parts[3]) {
3109
+ const rawPath = parts[3];
3110
+ const qIdx = rawPath.indexOf('?');
3111
+ if (qIdx >= 0) {
3112
+ path = rawPath.slice(0, qIdx);
3113
+ const qs = new URLSearchParams(rawPath.slice(qIdx + 1));
3114
+ qs.forEach((v, k) => {
3115
+ params[k] = v;
3116
+ });
3117
+ }
3118
+ else {
3119
+ path = rawPath;
3120
+ }
3121
+ }
3122
+ return { type, ref, path, params };
3123
+ }
3124
+ /** The resource category — e.g. "component", "integration", "user". */
3125
+ get type() {
3126
+ return this._parse().type;
3127
+ }
3128
+ /** The resource identifier within its type — slug, UUID, name. */
3129
+ get ref() {
3130
+ return this._parse().ref;
3131
+ }
3132
+ /** The resource path segment, or empty string if absent. */
3133
+ get path() {
3134
+ return this._parse().path;
3135
+ }
3136
+ /** All query-string key-value pairs, or empty object if none. */
3137
+ get params() {
3138
+ return this._parse().params;
3139
+ }
3140
+ /** Returns the value for the given query-param key, or empty string if not present. */
3141
+ param(key) {
3142
+ var _a;
3143
+ return (_a = this._parse().params[key]) !== null && _a !== void 0 ? _a : '';
3144
+ }
3145
+ toString() {
3146
+ return this._raw;
3147
+ }
3148
+ }
3149
+ /**
3150
+ * Convenience wrapper around PRN.parse.
3151
+ * Validates a PRN string and returns a PRN instance.
3152
+ * Throws if the string is not a valid PRN.
3153
+ */
3154
+ function parsePRN(s) {
3155
+ return PRN.parse(s);
3156
+ }
3157
+
3008
3158
  // API v0.9
3009
3159
  // Export all API modules for version 0.9
3010
3160
  // This version has specific method signatures and behaviors for v0.9
@@ -3022,6 +3172,7 @@ var ProtokolSDK09 = (function (exports, axios) {
3022
3172
  exports.Integrations = Integrations;
3023
3173
  exports.Invoicing = Invoicing;
3024
3174
  exports.Mail = Mail;
3175
+ exports.PRN = PRN;
3025
3176
  exports.Payments = Payments;
3026
3177
  exports.Platform = Platform;
3027
3178
  exports.Project = Project;
@@ -3034,6 +3185,7 @@ var ProtokolSDK09 = (function (exports, axios) {
3034
3185
  exports.VPFR = VPFR;
3035
3186
  exports.Workflow = Workflow;
3036
3187
  exports.default = Platform;
3188
+ exports.parsePRN = parsePRN;
3037
3189
 
3038
3190
  Object.defineProperty(exports, '__esModule', { value: true });
3039
3191
 
package/dist/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ptkl/sdk",
3
- "version": "1.7.1",
3
+ "version": "1.9.1",
4
4
  "scripts": {
5
5
  "build": "rollup -c",
6
6
  "build:monaco": "npm run build && node scripts/generate-monaco-types.cjs",
@@ -1,5 +1,6 @@
1
1
  export type { PlatformFunctions, PlatformFunction, FunctionInput, FunctionOutput, FunctionCallParams, ComponentModels, ComponentFunctions, ComponentModel, ComponentFunctionInput, ComponentFunctionOutput, } from '../types/functions';
2
2
  export type { Settings, SettingsField, FieldRoles, FieldConstraints, Context, Preset, PresetContext, Filters, Extension, Policy, SetupData, Model, } from '../types/component';
3
+ export type { WorkflowModel, WorkflowSettings, WorkflowNode, WorkflowNodeConnection, WorkflowCreatePayload, WorkflowUpdatePayload, WorkflowListResponse, } from '../types/workflow';
3
4
  export { default as Component } from './component';
4
5
  export { default as Platform } from './platform';
5
6
  export { default as Functions } from './functions';
@@ -17,6 +18,8 @@ export { default as Project } from './project';
17
18
  export { default as Config } from './config';
18
19
  export { default as Integrations } from './integrations';
19
20
  export { default as Integration } from './integrations';
21
+ export { PRN, parsePRN } from '../util/prn';
22
+ export type { ParsedPRN } from '../util/prn';
20
23
  export { default as Payments } from './integrations/payments';
21
24
  export { default as Invoicing } from './integrations/invoicing';
22
25
  export { default as DMS } from './integrations/dms';
@@ -22,6 +22,8 @@ export default class Integrations extends IntegrationsBaseClient {
22
22
  getNBS(): NBS;
23
23
  getSerbiaMinFin(): MinFin;
24
24
  getEcommerce(): Ecommerce;
25
+ list(): Promise<any>;
25
26
  isInstalled(id: string): Promise<boolean>;
27
+ isActive(id: string): Promise<boolean>;
26
28
  getInterfaceOf(id: string): any;
27
29
  }
@@ -1,5 +1,12 @@
1
+ import { AxiosResponse } from 'axios';
1
2
  import PlatformBaseClient from "./platformBaseClient";
3
+ import { WorkflowModel, WorkflowCreatePayload, WorkflowUpdatePayload, WorkflowListResponse } from '../types/workflow';
2
4
  export default class Workflow extends PlatformBaseClient {
3
- trigger(id: string, event: string, data: any): Promise<import("axios").AxiosResponse<any, any>>;
4
- publish(event: string, data: any): Promise<import("axios").AxiosResponse<any, any>>;
5
+ create(data: WorkflowCreatePayload): Promise<AxiosResponse<WorkflowModel>>;
6
+ update(id: string, data: WorkflowUpdatePayload): Promise<AxiosResponse<WorkflowModel>>;
7
+ get(id: string): Promise<AxiosResponse<WorkflowModel>>;
8
+ list(): Promise<AxiosResponse<WorkflowListResponse>>;
9
+ delete(id: string): Promise<AxiosResponse<void>>;
10
+ trigger(id: string, event: string, data: any): Promise<AxiosResponse<any, any>>;
11
+ publish(event: string, data: any): Promise<AxiosResponse<any, any>>;
5
12
  }
@@ -14618,7 +14618,7 @@ var transitionalDefaults = {
14618
14618
  clarifyTimeoutError: false
14619
14619
  };
14620
14620
 
14621
- var URLSearchParams = require$$0$1.URLSearchParams;
14621
+ var URLSearchParams$1 = require$$0$1.URLSearchParams;
14622
14622
 
14623
14623
  const ALPHA = 'abcdefghijklmnopqrstuvwxyz';
14624
14624
 
@@ -14646,7 +14646,7 @@ const generateString = (size = 16, alphabet = ALPHABET.ALPHA_DIGIT) => {
14646
14646
  var platform$1 = {
14647
14647
  isNode: true,
14648
14648
  classes: {
14649
- URLSearchParams,
14649
+ URLSearchParams: URLSearchParams$1,
14650
14650
  FormData: FormData$1,
14651
14651
  Blob: typeof Blob !== 'undefined' && Blob || null
14652
14652
  },
@@ -20219,6 +20219,21 @@ class System extends PlatformBaseClient {
20219
20219
  }
20220
20220
 
20221
20221
  class Workflow extends PlatformBaseClient {
20222
+ async create(data) {
20223
+ return await this.client.post(`/v1/project/workflow/workflow`, data);
20224
+ }
20225
+ async update(id, data) {
20226
+ return await this.client.patch(`/v1/project/workflow/workflow/${id}`, data);
20227
+ }
20228
+ async get(id) {
20229
+ return await this.client.get(`/v1/project/workflow/workflow/${id}`);
20230
+ }
20231
+ async list() {
20232
+ return await this.client.get(`/v1/project/workflow/workflows`);
20233
+ }
20234
+ async delete(id) {
20235
+ return await this.client.delete(`/v1/project/workflow/workflow/${id}`);
20236
+ }
20222
20237
  async trigger(id, event, data) {
20223
20238
  return await this.client.post(`/v1/project/workflow/workflow/${id}/event/${event}`, data);
20224
20239
  }
@@ -22420,10 +22435,18 @@ class Integrations extends IntegrationsBaseClient {
22420
22435
  getEcommerce() {
22421
22436
  return this.getInterfaceOf('protokol-ecommerce');
22422
22437
  }
22438
+ async list() {
22439
+ const { data } = await this.client.get("/v1/integrations");
22440
+ return data;
22441
+ }
22423
22442
  async isInstalled(id) {
22424
22443
  const { data } = await this.client.get("/v1/integrations");
22425
22444
  return data.find((i) => i.id == id) !== undefined;
22426
22445
  }
22446
+ async isActive(id) {
22447
+ const { data } = await this.client.get("/v1/integrations");
22448
+ return data.find((i) => i.id == id && i.status == "active") !== undefined;
22449
+ }
22427
22450
  getInterfaceOf(id) {
22428
22451
  try {
22429
22452
  return this.integrations[id];
@@ -22434,6 +22457,133 @@ class Integrations extends IntegrationsBaseClient {
22434
22457
  }
22435
22458
  }
22436
22459
 
22460
+ // PRN — Protokol Resource Name
22461
+ //
22462
+ // Format:
22463
+ // prn:<type>:<ref>[:<path>][?<query>]
22464
+ //
22465
+ // Examples:
22466
+ // prn:component:my-component:settings.api_key
22467
+ // prn:integration:protokol-ecommerce:company.legal_name?lang=en
22468
+ // prn:user:actor:forge?app=abc123&behalf=user-uuid
22469
+ /**
22470
+ * Splits s on sep into at most n parts, keeping the remainder in the last part.
22471
+ * Mirrors Go's strings.SplitN behaviour.
22472
+ */
22473
+ function splitN(s, sep, n) {
22474
+ const parts = [];
22475
+ let start = 0;
22476
+ for (let i = 1; i < n; i++) {
22477
+ const idx = s.indexOf(sep, start);
22478
+ if (idx === -1)
22479
+ break;
22480
+ parts.push(s.slice(start, idx));
22481
+ start = idx + sep.length;
22482
+ }
22483
+ parts.push(s.slice(start));
22484
+ return parts;
22485
+ }
22486
+ class PRN {
22487
+ constructor(raw) {
22488
+ this._raw = raw;
22489
+ }
22490
+ /**
22491
+ * Validates a PRN string and returns it as a PRN instance.
22492
+ * Throws if the string is not a valid PRN.
22493
+ */
22494
+ static parse(s) {
22495
+ const parts = splitN(s, ':', 4);
22496
+ if (parts.length < 3) {
22497
+ throw new Error(`invalid PRN "${s}": expected format prn:<type>:<ref>[:<path>]`);
22498
+ }
22499
+ if (parts[0] !== 'prn') {
22500
+ throw new Error(`invalid PRN "${s}": must start with 'prn'`);
22501
+ }
22502
+ if (!parts[1]) {
22503
+ throw new Error(`invalid PRN "${s}": type must not be empty`);
22504
+ }
22505
+ if (!parts[2]) {
22506
+ throw new Error(`invalid PRN "${s}": ref must not be empty`);
22507
+ }
22508
+ return new PRN(s);
22509
+ }
22510
+ /**
22511
+ * Constructs a PRN from its constituent parts.
22512
+ * Params are sorted by key for deterministic output.
22513
+ */
22514
+ static create(type, ref, path, params) {
22515
+ let s = `prn:${type}:${ref}`;
22516
+ if (path) {
22517
+ s += `:${path}`;
22518
+ }
22519
+ if (params && Object.keys(params).length > 0) {
22520
+ const sorted = Object.keys(params).sort();
22521
+ const qs = new URLSearchParams();
22522
+ for (const k of sorted) {
22523
+ qs.set(k, params[k]);
22524
+ }
22525
+ s += `?${qs.toString()}`;
22526
+ }
22527
+ return new PRN(s);
22528
+ }
22529
+ _parse() {
22530
+ var _a, _b;
22531
+ const s = this._raw;
22532
+ const parts = splitN(s, ':', 4);
22533
+ const type = (_a = parts[1]) !== null && _a !== void 0 ? _a : '';
22534
+ const ref = (_b = parts[2]) !== null && _b !== void 0 ? _b : '';
22535
+ let path = '';
22536
+ const params = {};
22537
+ if (parts.length === 4 && parts[3]) {
22538
+ const rawPath = parts[3];
22539
+ const qIdx = rawPath.indexOf('?');
22540
+ if (qIdx >= 0) {
22541
+ path = rawPath.slice(0, qIdx);
22542
+ const qs = new URLSearchParams(rawPath.slice(qIdx + 1));
22543
+ qs.forEach((v, k) => {
22544
+ params[k] = v;
22545
+ });
22546
+ }
22547
+ else {
22548
+ path = rawPath;
22549
+ }
22550
+ }
22551
+ return { type, ref, path, params };
22552
+ }
22553
+ /** The resource category — e.g. "component", "integration", "user". */
22554
+ get type() {
22555
+ return this._parse().type;
22556
+ }
22557
+ /** The resource identifier within its type — slug, UUID, name. */
22558
+ get ref() {
22559
+ return this._parse().ref;
22560
+ }
22561
+ /** The resource path segment, or empty string if absent. */
22562
+ get path() {
22563
+ return this._parse().path;
22564
+ }
22565
+ /** All query-string key-value pairs, or empty object if none. */
22566
+ get params() {
22567
+ return this._parse().params;
22568
+ }
22569
+ /** Returns the value for the given query-param key, or empty string if not present. */
22570
+ param(key) {
22571
+ var _a;
22572
+ return (_a = this._parse().params[key]) !== null && _a !== void 0 ? _a : '';
22573
+ }
22574
+ toString() {
22575
+ return this._raw;
22576
+ }
22577
+ }
22578
+ /**
22579
+ * Convenience wrapper around PRN.parse.
22580
+ * Validates a PRN string and returns a PRN instance.
22581
+ * Throws if the string is not a valid PRN.
22582
+ */
22583
+ function parsePRN(s) {
22584
+ return PRN.parse(s);
22585
+ }
22586
+
22437
22587
  class Invoicing extends PlatformBaseClient {
22438
22588
  async getSalesInvoices(provider, page) {
22439
22589
  return await this.request("GET", `invoices/${provider}/sales`, {
@@ -22473,6 +22623,7 @@ exports.Integrations = Integrations;
22473
22623
  exports.Invoicing = Invoicing;
22474
22624
  exports.Mail = Mail;
22475
22625
  exports.NBS = NBS;
22626
+ exports.PRN = PRN;
22476
22627
  exports.Payments = Payments;
22477
22628
  exports.Platform = Platform;
22478
22629
  exports.Project = Project;
@@ -22484,3 +22635,4 @@ exports.Thunder = Thunder;
22484
22635
  exports.Users = Users;
22485
22636
  exports.VPFR = VPFR;
22486
22637
  exports.Workflow = Workflow;
22638
+ exports.parsePRN = parsePRN;