@ptkl/sdk 1.6.1 → 1.6.3

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.
@@ -927,9 +927,6 @@ var ProtokolSDK010 = (function (exports, axios) {
927
927
  async list() {
928
928
  return await this.client.get("/v1/system/components");
929
929
  }
930
- async create(data) {
931
- return await this.client.post("/v3/system/component/create", data);
932
- }
933
930
  async delete(ref) {
934
931
  return await this.client.delete(`/v3/system/component/${ref}`);
935
932
  }
package/dist/index.0.9.js CHANGED
@@ -645,12 +645,12 @@ var ProtokolSDK09 = (function (exports, axios) {
645
645
  async list() {
646
646
  return await this.client.get("/v1/system/components");
647
647
  }
648
- async create(data) {
649
- return await this.client.post("/v3/system/component/create", data);
650
- }
651
648
  async delete(ref) {
652
649
  return await this.client.delete(`/v3/system/component/${ref}`);
653
650
  }
651
+ async setup(data) {
652
+ return await this.client.post("/v3/system/component/setup", data);
653
+ }
654
654
  }
655
655
 
656
656
  class Thunder extends PlatformBaseClient {
package/dist/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ptkl/sdk",
3
- "version": "1.6.1",
3
+ "version": "1.6.3",
4
4
  "scripts": {
5
5
  "build": "rollup -c",
6
6
  "build:monaco": "npm run build && node scripts/generate-monaco-types.cjs",
@@ -3,7 +3,6 @@ import { ComponentListResponse, SetupData, ComponentCreateResponse } from "../ty
3
3
  import PlatformBaseClient from "./platformBaseClient";
4
4
  export default class ComponentUtils extends PlatformBaseClient {
5
5
  list(): Promise<AxiosResponse<ComponentListResponse>>;
6
- create(data: any): Promise<AxiosResponse<any, any>>;
7
6
  delete(ref: string): Promise<AxiosResponse<any, any>>;
8
7
  /**
9
8
  * Setup a component with settings in a single atomic operation.
@@ -1,4 +1,5 @@
1
1
  export type { PlatformFunctions, PlatformFunction, FunctionInput, FunctionOutput, FunctionCallParams, ComponentModels, ComponentFunctions, ComponentModel, ComponentFunctionInput, ComponentFunctionOutput, } from '../types/functions';
2
+ export type { Settings, SettingsField, FieldRoles, FieldConstraints, Context, Preset, PresetContext, Filters, Extension, Policy, SetupData, Model, } from '../types/component';
2
3
  export { default as Component } from './component';
3
4
  export { default as Platform } from './platform';
4
5
  export { default as Functions } from './functions';
@@ -19893,9 +19893,6 @@ class ComponentUtils extends PlatformBaseClient {
19893
19893
  async list() {
19894
19894
  return await this.client.get("/v1/system/components");
19895
19895
  }
19896
- async create(data) {
19897
- return await this.client.post("/v3/system/component/create", data);
19898
- }
19899
19896
  async delete(ref) {
19900
19897
  return await this.client.delete(`/v3/system/component/${ref}`);
19901
19898
  }
@@ -926,9 +926,6 @@ class ComponentUtils extends PlatformBaseClient {
926
926
  async list() {
927
927
  return await this.client.get("/v1/system/components");
928
928
  }
929
- async create(data) {
930
- return await this.client.post("/v3/system/component/create", data);
931
- }
932
929
  async delete(ref) {
933
930
  return await this.client.delete(`/v3/system/component/${ref}`);
934
931
  }
@@ -272,22 +272,22 @@ type FieldConstraints = {
272
272
  };
273
273
  relation?: {
274
274
  label?: string;
275
- searchOn?: string[];
275
+ searchOn?: string[] | null;
276
276
  };
277
277
  };
278
278
  type SettingsField = {
279
279
  name: string;
280
- label: Record<string, any>;
280
+ label: Record<string, any> | null;
281
281
  key: string;
282
282
  type: string;
283
- description?: Record<string, any>;
283
+ description?: Record<string, any> | null;
284
284
  module?: string;
285
285
  group?: string;
286
286
  sortOrder?: number;
287
287
  visible?: boolean;
288
288
  protected?: boolean;
289
- roles?: FieldRoles;
290
- context?: Context[];
289
+ roles?: FieldRoles | null;
290
+ context?: Context[] | null;
291
291
  constraints?: FieldConstraints;
292
292
  relation?: {
293
293
  foreign?: string;
@@ -303,14 +303,14 @@ type SettingsField = {
303
303
  provided_template_component?: string;
304
304
  component_template?: string;
305
305
  template?: string;
306
- permissions?: string[];
306
+ permissions?: string[] | null;
307
307
  };
308
308
  type Filters = {
309
309
  filter?: string;
310
- filterOn?: string[];
310
+ filterOn?: string[] | null;
311
311
  dateField?: string;
312
- dateFrom?: string;
313
- dateTo?: string;
312
+ dateFrom?: string | null;
313
+ dateTo?: string | null;
314
314
  $adv?: Record<string, any>;
315
315
  };
316
316
  type PresetContext = {
@@ -321,7 +321,7 @@ type PresetContext = {
321
321
  };
322
322
  type Preset = {
323
323
  name: string;
324
- roles: string[];
324
+ roles?: string[];
325
325
  context: PresetContext;
326
326
  };
327
327
  type Function = {
@@ -367,7 +367,7 @@ type Settings = {
367
367
  list?: {
368
368
  quick_actions?: boolean;
369
369
  perPage?: number;
370
- fields?: Array<{
370
+ fields: Array<{
371
371
  key: string;
372
372
  label: Record<string, any>;
373
373
  name?: string;
@@ -382,38 +382,33 @@ type Settings = {
382
382
  formatter?: string;
383
383
  provided_template_component?: string;
384
384
  component_template?: string;
385
- }>;
385
+ }> | null;
386
386
  };
387
387
  fields?: SettingsField[];
388
388
  model?: {
389
- events?: Record<string, any>[];
390
- unique_indexes_combinations?: string[][];
389
+ events?: Record<string, any>[] | null;
390
+ unique_indexes_combinations?: string[][] | null;
391
391
  };
392
- presets?: Preset[];
393
- templates?: Record<string, any>[];
392
+ presets?: Preset[] | null;
393
+ templates?: Record<string, any>[] | null;
394
394
  templates_dist?: TemplatesDist;
395
- config?: Record<string, any>;
396
- functions?: Function[];
397
- extensions?: Extension[];
398
- policies?: Policy[];
395
+ config?: Record<string, any> | null;
396
+ functions?: Function[] | null;
397
+ extensions?: Extension[] | null;
398
+ policies?: Policy[] | null;
399
399
  };
400
400
  type SetupData = {
401
401
  name: string;
402
402
  label?: Record<string, any>;
403
- tag: string;
403
+ tag?: string;
404
404
  scope?: string;
405
- public_version?: string;
406
- dev_version?: string;
407
- project_uuid?: string;
405
+ public_version: string;
406
+ dev_version: string;
408
407
  workspaces?: string[];
409
- roles?: string[];
410
- settings?: Settings;
411
- env?: string;
412
408
  is_active?: boolean;
413
409
  is_public?: boolean;
414
410
  icon?: string;
415
- template_component_id?: string;
416
- integrator?: string;
411
+ settings?: Settings;
417
412
  };
418
413
  type ComponentCreateResponse = ComponentListItem;
419
414
  export { FindParams, FindOptions, FindResponse, FindAdvancedParams, FindAggregateParams, Model, UpdateOptions, ModifyOptions, UpdateOperators, UpdateAggregate, ModelUpdateData, ComponentOptions, ComponentListResponse, ComponentListItem, ComponentLabel, ComponentWorkspace, StreamCallback, StreamHandler, AggregateChainable, UpdateManyOptions, CreateManyOptions, Settings, SettingsField, FieldRoles, FieldConstraints, Context, Preset, PresetContext, Filters, Function, Extension, Policy, FieldAccessConfig, TemplatesDist, SetupData, ComponentCreateResponse, };
@@ -1,8 +1,8 @@
1
1
  import { AxiosResponse } from "axios";
2
- import { ComponentListResponse } from "../types/component";
2
+ import { ComponentListResponse, SetupData, ComponentCreateResponse } from "../types/component";
3
3
  import PlatformBaseClient from "./platformBaseClient";
4
4
  export default class ComponentUtils extends PlatformBaseClient {
5
5
  list(): Promise<AxiosResponse<ComponentListResponse>>;
6
- create(data: any): Promise<AxiosResponse<any, any>>;
7
6
  delete(ref: string): Promise<AxiosResponse<any, any>>;
7
+ setup(data: SetupData): Promise<AxiosResponse<ComponentCreateResponse>>;
8
8
  }
@@ -1,3 +1,4 @@
1
+ export type { Settings, SettingsField, FieldRoles, FieldConstraints, Context, Preset, PresetContext, Filters, Extension, Policy, SetupData, Model, } from '../types/component';
1
2
  export { default as Component } from './component';
2
3
  export { default as Platform } from './platform';
3
4
  export { default as Functions } from './functions';
@@ -19613,12 +19613,12 @@ class ComponentUtils extends PlatformBaseClient {
19613
19613
  async list() {
19614
19614
  return await this.client.get("/v1/system/components");
19615
19615
  }
19616
- async create(data) {
19617
- return await this.client.post("/v3/system/component/create", data);
19618
- }
19619
19616
  async delete(ref) {
19620
19617
  return await this.client.delete(`/v3/system/component/${ref}`);
19621
19618
  }
19619
+ async setup(data) {
19620
+ return await this.client.post("/v3/system/component/setup", data);
19621
+ }
19622
19622
  }
19623
19623
 
19624
19624
  class Thunder extends PlatformBaseClient {
@@ -644,12 +644,12 @@ class ComponentUtils extends PlatformBaseClient {
644
644
  async list() {
645
645
  return await this.client.get("/v1/system/components");
646
646
  }
647
- async create(data) {
648
- return await this.client.post("/v3/system/component/create", data);
649
- }
650
647
  async delete(ref) {
651
648
  return await this.client.delete(`/v3/system/component/${ref}`);
652
649
  }
650
+ async setup(data) {
651
+ return await this.client.post("/v3/system/component/setup", data);
652
+ }
653
653
  }
654
654
 
655
655
  class Thunder extends PlatformBaseClient {
@@ -9,12 +9,14 @@ type FindParams = {
9
9
  dateFrom?: string;
10
10
  dateTo?: string;
11
11
  dateField?: string;
12
+ only?: string[];
13
+ includeFields?: string[];
12
14
  $adv?: FindAdvancedParams;
13
15
  $aggregate?: FindAggregateParams[];
14
16
  };
15
17
  type FindOptions = {
16
- cache?: boolean;
17
- buildttl?: number;
18
+ cacheTTL?: number;
19
+ buildTTL?: number;
18
20
  locale?: string;
19
21
  unmaskPasswords?: boolean;
20
22
  };
@@ -77,6 +79,98 @@ type ModifyOptions = {
77
79
  upsert: boolean;
78
80
  force_update_protected_fields?: boolean;
79
81
  };
82
+ /**
83
+ * MongoDB update operators that can be included inline in the `data` payload.
84
+ *
85
+ * Any key starting with `$` in the data object is automatically detected as an
86
+ * update operator and applied with MongoDB semantics instead of the default `$set`.
87
+ *
88
+ * Supported operators:
89
+ * - `$inc` — Increment a numeric field
90
+ * - `$push` — Append to an array
91
+ * - `$pull` — Remove from an array by condition
92
+ * - `$addToSet` — Add to array only if not present
93
+ * - `$pop` — Remove first (-1) or last (1) element from array
94
+ * - `$min` — Update only if new value is less than current
95
+ * - `$max` — Update only if new value is greater than current
96
+ * - `$mul` — Multiply a numeric field
97
+ *
98
+ * @example
99
+ * ```ts
100
+ * // Data with inline operators
101
+ * const data = {
102
+ * name: "John", // → $set
103
+ * $inc: { views: 1 }, // → $inc
104
+ * $push: { tags: "vip" } // → $push
105
+ * }
106
+ * ```
107
+ */
108
+ type UpdateOperators = {
109
+ $inc?: Record<string, number>;
110
+ $push?: Record<string, any>;
111
+ $pull?: Record<string, any>;
112
+ $addToSet?: Record<string, any>;
113
+ $pop?: Record<string, 1 | -1>;
114
+ $min?: Record<string, any>;
115
+ $max?: Record<string, any>;
116
+ $mul?: Record<string, number>;
117
+ };
118
+ /**
119
+ * A single element in an `$aggregate` update array. Each element is a plain
120
+ * object mapping field names to MongoDB aggregation expressions. You do **not**
121
+ * need to wrap the object in a `$set` — the API does that automatically.
122
+ *
123
+ * @example
124
+ * ```ts
125
+ * const update: UpdateAggregate = [
126
+ * {
127
+ * avg_rating: { $avg: "$ratings" },
128
+ * tier: { $cond: { if: { $gte: ["$avg_rating", 4.5] }, then: "platinum", else: "standard" } }
129
+ * }
130
+ * ]
131
+ * ```
132
+ */
133
+ type UpdateAggregate = Record<string, any>[];
134
+ /**
135
+ * Aggregation-expression update (v4 only). An array of field→expression objects.
136
+ * Each element is automatically applied as a `$set` stage, so you can compute
137
+ * new field values from the existing document using MongoDB aggregation
138
+ * expressions (`$cond`, `$avg`, `$map`, `$ifNull`, etc.).
139
+ *
140
+ * The write always runs in a transaction and is rolled back if the resulting
141
+ * document fails IDL validation. Cannot be combined with regular update
142
+ * operators (`$inc`, `$push`, etc.) in the same request.
143
+ *
144
+ * @example
145
+ * ```ts
146
+ * await product.update(uuid, {
147
+ * $aggregate: [
148
+ * {
149
+ * avg_rating: { $avg: "$ratings" },
150
+ * tier: {
151
+ * $cond: {
152
+ * if: { $gte: ["$avg_rating", 4.5] },
153
+ * then: "platinum",
154
+ * else: "standard",
155
+ * },
156
+ * },
157
+ * },
158
+ * ],
159
+ * })
160
+ * ```
161
+ */
162
+ /**
163
+ * Model data payload that supports inline update operators.
164
+ * Regular fields are applied via `$set`, operator keys are applied with their
165
+ * respective MongoDB semantics.
166
+ *
167
+ * Pass `$aggregate` (v4 only) to use an aggregation-expression update instead
168
+ * of plain operators. `$aggregate` and regular operators are mutually exclusive.
169
+ */
170
+ type ModelUpdateData = Record<string, any> & UpdateOperators & {
171
+ /** Aggregation-expression update (v4 only). Mutually exclusive with operator keys. */
172
+ $aggregate?: UpdateAggregate;
173
+ };
80
174
  type ComponentOptions = {
81
175
  version?: string;
82
176
  };
@@ -114,4 +208,207 @@ type ComponentListItem = {
114
208
  storage_size: number;
115
209
  };
116
210
  type ComponentListResponse = ComponentListItem[];
117
- export { FindParams, FindOptions, FindResponse, FindAdvancedParams, FindAggregateParams, Model, UpdateOptions, ModifyOptions, ComponentOptions, ComponentListResponse, ComponentListItem, ComponentLabel, ComponentWorkspace, StreamCallback, StreamHandler, AggregateChainable, UpdateManyOptions, CreateManyOptions, };
211
+ type FieldRoles = {
212
+ see: string[];
213
+ edit: string[];
214
+ };
215
+ type Context = {
216
+ key: string;
217
+ value: any;
218
+ };
219
+ type FieldConstraints = {
220
+ required?: boolean;
221
+ unique?: boolean;
222
+ placeholder?: string;
223
+ default?: string;
224
+ length?: {
225
+ min?: number | null;
226
+ max?: number | null;
227
+ };
228
+ not_allowed_words?: string;
229
+ regex?: string;
230
+ date?: {
231
+ pattern?: string;
232
+ disable_past_dates?: boolean;
233
+ disable_future_dates?: boolean;
234
+ disabled_dates?: {
235
+ dates?: string[];
236
+ to?: string;
237
+ from?: string;
238
+ days?: number[];
239
+ days_of_month?: number[];
240
+ ranges?: Array<{
241
+ from: string;
242
+ to: string;
243
+ }>;
244
+ };
245
+ highlighted_dates?: {
246
+ dates?: string[];
247
+ to?: string;
248
+ from?: string;
249
+ days?: number[];
250
+ days_of_month?: number[];
251
+ ranges?: Array<{
252
+ from: string;
253
+ to: string;
254
+ }>;
255
+ include_disabled?: boolean;
256
+ };
257
+ };
258
+ selectables?: {
259
+ items?: any[];
260
+ multiple?: boolean;
261
+ range?: {
262
+ from: number;
263
+ to: number;
264
+ };
265
+ custom?: boolean;
266
+ };
267
+ table?: {
268
+ search?: boolean;
269
+ per_page?: number;
270
+ save_on_create?: boolean;
271
+ fields?: SettingsField[];
272
+ };
273
+ relation?: {
274
+ label?: string;
275
+ searchOn?: string[] | null;
276
+ };
277
+ };
278
+ type SettingsField = {
279
+ name: string;
280
+ label: Record<string, any> | null;
281
+ key: string;
282
+ type: string;
283
+ description?: Record<string, any> | null;
284
+ module?: string;
285
+ group?: string;
286
+ sortOrder?: number;
287
+ visible?: boolean;
288
+ protected?: boolean;
289
+ roles?: FieldRoles | null;
290
+ context?: Context[] | null;
291
+ constraints?: FieldConstraints;
292
+ relation?: {
293
+ foreign?: string;
294
+ key?: string[];
295
+ type?: string;
296
+ foreign_uuid?: string | null;
297
+ };
298
+ mutators?: {
299
+ get?: string;
300
+ set?: string;
301
+ };
302
+ provided_template?: boolean;
303
+ provided_template_component?: string;
304
+ component_template?: string;
305
+ template?: string;
306
+ permissions?: string[] | null;
307
+ };
308
+ type Filters = {
309
+ filter?: string;
310
+ filterOn?: string[] | null;
311
+ dateField?: string;
312
+ dateFrom?: string | null;
313
+ dateTo?: string | null;
314
+ $adv?: Record<string, any>;
315
+ };
316
+ type PresetContext = {
317
+ filters?: Filters;
318
+ default?: boolean;
319
+ locked?: boolean;
320
+ expr?: string;
321
+ };
322
+ type Preset = {
323
+ name: string;
324
+ roles?: string[];
325
+ context: PresetContext;
326
+ };
327
+ type Function = {
328
+ name: string;
329
+ expr: string;
330
+ };
331
+ type Extension = {
332
+ name: string;
333
+ is_active: boolean;
334
+ fields?: SettingsField[];
335
+ functions?: Function[];
336
+ workflows?: Record<string, any>[];
337
+ templates?: Record<string, any>;
338
+ templates_dist?: TemplatesDist;
339
+ config?: Record<string, any>;
340
+ version?: string;
341
+ };
342
+ type FieldAccessConfig = {
343
+ fields: string[];
344
+ actions: string[];
345
+ roles: string[];
346
+ };
347
+ type Policy<T = Record<string, any>> = {
348
+ type: string;
349
+ name: string;
350
+ description?: string;
351
+ enabled: boolean;
352
+ priority: number;
353
+ config?: T;
354
+ };
355
+ type TemplatesDist = {
356
+ sdk_version: number;
357
+ sdk_engine: string;
358
+ dist: Record<string, any>;
359
+ };
360
+ type Settings = {
361
+ version?: string;
362
+ appearance?: {
363
+ list_entrypoint?: string;
364
+ create_entrypoint?: string;
365
+ edit_entrypoint?: string;
366
+ };
367
+ list?: {
368
+ quick_actions?: boolean;
369
+ perPage?: number;
370
+ fields: Array<{
371
+ key: string;
372
+ label: Record<string, any>;
373
+ name?: string;
374
+ sortOrder?: number;
375
+ sortable?: boolean;
376
+ filterable?: boolean;
377
+ sortDirection?: string;
378
+ sortByFormatted?: boolean;
379
+ filterByFormatted?: boolean;
380
+ formatterEditor?: string;
381
+ variant?: string;
382
+ formatter?: string;
383
+ provided_template_component?: string;
384
+ component_template?: string;
385
+ }> | null;
386
+ };
387
+ fields?: SettingsField[];
388
+ model?: {
389
+ events?: Record<string, any>[] | null;
390
+ unique_indexes_combinations?: string[][] | null;
391
+ };
392
+ presets?: Preset[] | null;
393
+ templates?: Record<string, any>[] | null;
394
+ templates_dist?: TemplatesDist;
395
+ config?: Record<string, any> | null;
396
+ functions?: Function[] | null;
397
+ extensions?: Extension[] | null;
398
+ policies?: Policy[] | null;
399
+ };
400
+ type SetupData = {
401
+ name: string;
402
+ label?: Record<string, any>;
403
+ tag?: string;
404
+ scope?: string;
405
+ public_version: string;
406
+ dev_version: string;
407
+ workspaces?: string[];
408
+ is_active?: boolean;
409
+ is_public?: boolean;
410
+ icon?: string;
411
+ settings?: Settings;
412
+ };
413
+ type ComponentCreateResponse = ComponentListItem;
414
+ export { FindParams, FindOptions, FindResponse, FindAdvancedParams, FindAggregateParams, Model, UpdateOptions, ModifyOptions, UpdateOperators, UpdateAggregate, ModelUpdateData, ComponentOptions, ComponentListResponse, ComponentListItem, ComponentLabel, ComponentWorkspace, StreamCallback, StreamHandler, AggregateChainable, UpdateManyOptions, CreateManyOptions, Settings, SettingsField, FieldRoles, FieldConstraints, Context, Preset, PresetContext, Filters, Function, Extension, Policy, FieldAccessConfig, TemplatesDist, SetupData, ComponentCreateResponse, };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ptkl/sdk",
3
- "version": "1.6.1",
3
+ "version": "1.6.3",
4
4
  "scripts": {
5
5
  "build": "rollup -c",
6
6
  "build:monaco": "npm run build && node scripts/generate-monaco-types.cjs",