@ptkl/sdk 0.8.3 → 0.8.4

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.
package/dist/index.cjs.js CHANGED
@@ -17910,7 +17910,7 @@ class Functions extends PlatformBaseClient {
17910
17910
  params: d.query,
17911
17911
  headers: d.headers
17912
17912
  });
17913
- return data.data;
17913
+ return data;
17914
17914
  }
17915
17915
  async generateSignature(ref, env) {
17916
17916
  return await this.client.get(`/v1/system/function/signature/${env}/${ref}`);
@@ -17919,25 +17919,19 @@ class Functions extends PlatformBaseClient {
17919
17919
 
17920
17920
  class Roles extends PlatformBaseClient {
17921
17921
  async create(role) {
17922
- const res = await this.client.post("/v1/user/role/create", role);
17923
- // writeFileSync(`.role.create.json`,JSON.stringify(res))
17924
- return res.data;
17922
+ return await this.client.post("/v1/user/role/create", role);
17925
17923
  }
17926
17924
  async delete(uuid) {
17927
- const { data } = await this.client.delete(`/v1/user/role/delete/${uuid}`);
17928
- return data;
17925
+ return await this.client.delete(`/v1/user/role/delete/${uuid}`);
17929
17926
  }
17930
17927
  async list() {
17931
- const { data } = await this.client.get(`/v1/user/role/list`);
17932
- return data;
17928
+ return await this.client.get(`/v1/user/role/list`);
17933
17929
  }
17934
17930
  async listPermissions() {
17935
- const { data } = await this.client.get(`/v1/user/permissions/list`);
17936
- return data;
17931
+ return await this.client.get(`/v1/user/permissions/list`);
17937
17932
  }
17938
17933
  async edit(permissions, workspaces, level, uuid) {
17939
- const { data } = await this.client.post(`/v1/user/role/edit/${uuid}`, { permissions, workspaces, level });
17940
- return data;
17934
+ return await this.client.post(`/v1/user/role/edit/${uuid}`, { permissions, workspaces, level });
17941
17935
  }
17942
17936
  }
17943
17937
 
@@ -18029,64 +18023,57 @@ class Component extends PlatformBaseClient {
18029
18023
  * }
18030
18024
  * )
18031
18025
  **/
18032
- find(filters, opts) {
18026
+ async find(filters, opts) {
18033
18027
  const { cache = false, buildttl = -1, locale = "en_US", } = opts !== null && opts !== undefined ? opts : {};
18034
- return new Promise((resolve, reject) => {
18035
- let payload = {
18036
- context: filters,
18037
- ref: this.ref,
18038
- };
18039
- let ctx = payload.context;
18040
- let offset = ctx.currentPage;
18041
- if (offset == undefined) {
18042
- offset = 0;
18043
- }
18044
- let limit = ctx.perPage;
18045
- if (limit == undefined || limit == -1) {
18046
- limit = 10;
18047
- }
18048
- let sortDesc = 1;
18049
- if (ctx.sortDesc) {
18050
- sortDesc = -1;
18051
- }
18052
- if (ctx.filterOn === undefined) {
18053
- ctx.filterOn = [];
18054
- }
18055
- let params = {
18056
- offset: offset,
18057
- sortBy: ctx.sortBy,
18058
- sortDesc: sortDesc,
18059
- filter: ctx.filter,
18060
- filterOn: ctx.filterOn.join(","),
18061
- limit: limit,
18062
- dateFrom: ctx.dateFrom,
18063
- dateTo: ctx.dateTo,
18064
- dateField: ctx.dateField,
18065
- };
18066
- if (Object.keys(ctx.$adv || []).length > 0) {
18067
- params.$adv = JSON.stringify([ctx.$adv]);
18068
- }
18069
- if (ctx.$aggregate && ctx.$aggregate.length > 0) {
18070
- params.$aggregate = JSON.stringify(ctx.$aggregate);
18071
- }
18072
- if (opts) {
18073
- Object.keys(opts).forEach(k => {
18074
- params[`_opt_${k}`] = opts ? opts[k] : null;
18075
- });
18076
- }
18077
- this.client.get(`/v3/system/component/${this.ref}/models`, {
18078
- params: params,
18079
- headers: {
18080
- 'X-Cache': cache,
18081
- 'X-Build-Ttl': buildttl,
18082
- 'Accept-Language': locale
18083
- }
18084
- }).then((resp) => {
18085
- let { data = [] } = resp || {};
18086
- resolve(data);
18087
- }).catch((err) => {
18088
- reject(err);
18028
+ let payload = {
18029
+ context: filters,
18030
+ ref: this.ref,
18031
+ };
18032
+ let ctx = payload.context;
18033
+ let offset = ctx.currentPage;
18034
+ if (offset == undefined) {
18035
+ offset = 0;
18036
+ }
18037
+ let limit = ctx.perPage;
18038
+ if (limit == undefined || limit == -1) {
18039
+ limit = 10;
18040
+ }
18041
+ let sortDesc = 1;
18042
+ if (ctx.sortDesc) {
18043
+ sortDesc = -1;
18044
+ }
18045
+ if (ctx.filterOn === undefined) {
18046
+ ctx.filterOn = [];
18047
+ }
18048
+ let params = {
18049
+ offset: offset,
18050
+ sortBy: ctx.sortBy,
18051
+ sortDesc: sortDesc,
18052
+ filter: ctx.filter,
18053
+ filterOn: ctx.filterOn.join(","),
18054
+ limit: limit,
18055
+ dateFrom: ctx.dateFrom,
18056
+ dateTo: ctx.dateTo,
18057
+ dateField: ctx.dateField,
18058
+ };
18059
+ if (Object.keys(ctx.$adv || []).length > 0) {
18060
+ params.$adv = JSON.stringify([ctx.$adv]);
18061
+ }
18062
+ if (ctx.$aggregate && ctx.$aggregate.length > 0) {
18063
+ params.$aggregate = JSON.stringify(ctx.$aggregate);
18064
+ }
18065
+ if (opts) {
18066
+ Object.keys(opts).forEach(k => {
18067
+ params[`_opt_${k}`] = opts ? opts[k] : null;
18089
18068
  });
18069
+ }
18070
+ return await this.client.get(`/v3/system/component/${this.ref}/models`, {
18071
+ params: params,
18072
+ headers: {
18073
+ 'X-Cache': cache,
18074
+ 'X-Build-Ttl': buildttl,
18075
+ 'Accept-Language': locale
18076
+ }
18090
18077
  });
18091
18078
  }
18092
18079
  /**
@@ -18118,8 +18105,7 @@ class Component extends PlatformBaseClient {
18118
18105
  * @returns (Promise<Model>)
18119
18106
  */
18120
18107
  async get(uuid) {
18121
- const { data } = await this.client.get(`/v3/system/component/${this.ref}/model/${uuid}`);
18122
- return data;
18108
+ return await this.client.get(`/v3/system/component/${this.ref}/model/${uuid}`);
18123
18109
  }
18124
18110
  /**
18125
18111
  * Update model by uuid
@@ -18129,11 +18115,10 @@ class Component extends PlatformBaseClient {
18129
18115
  * @returns
18130
18116
  */
18131
18117
  async update(uuid, data, options) {
18132
- const { data: responseData } = await this.client.post(`/v3/system/component/${this.ref}/model/${uuid}`, {
18118
+ return await this.client.post(`/v3/system/component/${this.ref}/model/${uuid}`, {
18133
18119
  data,
18134
18120
  options,
18135
18121
  });
18136
- return responseData;
18137
18122
  }
18138
18123
  /**
18139
18124
  * Update many models
@@ -18143,11 +18128,10 @@ class Component extends PlatformBaseClient {
18143
18128
  * @returns
18144
18129
  */
18145
18130
  async updateMany(data, options) {
18146
- const { data: responseData } = await this.client.post(`/v3/system/component/${this.ref}/models/bulk`, {
18131
+ return await this.client.post(`/v3/system/component/${this.ref}/models/bulk`, {
18147
18132
  data,
18148
18133
  options,
18149
18134
  });
18150
- return responseData;
18151
18135
  }
18152
18136
  /**
18153
18137
  * Modify models by filters
@@ -18157,12 +18141,11 @@ class Component extends PlatformBaseClient {
18157
18141
  * @returns
18158
18142
  */
18159
18143
  async modify(filters, data, options) {
18160
- const { data: responseData } = await this.client.patch(`/v3/system/component/${this.ref}/modify/model`, {
18144
+ return await this.client.patch(`/v3/system/component/${this.ref}/modify/model`, {
18161
18145
  filters,
18162
18146
  data,
18163
18147
  options,
18164
18148
  });
18165
- return responseData;
18166
18149
  }
18167
18150
  /**
18168
18151
  * Concurrent update model by uuid
@@ -18173,85 +18156,72 @@ class Component extends PlatformBaseClient {
18173
18156
  * @returns
18174
18157
  */
18175
18158
  async concurrentUpdate(uuid, version, data, options) {
18176
- const { data: responseData } = await this.client.post(`/v3/system/component/${this.ref}/model/${uuid}`, {
18159
+ return await this.client.post(`/v3/system/component/${this.ref}/model/${uuid}`, {
18177
18160
  version: version,
18178
18161
  data,
18179
18162
  options,
18180
18163
  });
18181
- return responseData;
18182
18164
  }
18183
18165
  async create(model) {
18184
- const { data } = await this.client.post(`/v3/system/component/${this.ref}/model`, model);
18185
- return data;
18166
+ return await this.client.post(`/v3/system/component/${this.ref}/model`, model);
18186
18167
  }
18187
18168
  async delete(uuid) {
18188
- const { data } = await this.client.delete(`/v3/system/component/${this.ref}/model/${uuid}`);
18189
- return data;
18169
+ return await this.client.delete(`/v3/system/component/${this.ref}/model/${uuid}`);
18190
18170
  }
18191
18171
  async aggregate(pipeline) {
18192
- const { data } = await this.client.post(`/v3/system/component/${this.ref}/aggregate`, pipeline);
18193
- return data;
18172
+ return await this.client.post(`/v3/system/component/${this.ref}/aggregate`, pipeline);
18194
18173
  }
18195
18174
  async settings() {
18196
- const { data } = await this.client.get(`/v3/system/component/settings/${this.ref}`);
18197
- return data;
18175
+ return await this.client.get(`/v3/system/component/settings/${this.ref}`);
18198
18176
  }
18199
18177
  async saveSettings(settings, version) {
18200
- const { data } = await this.client.post(`/v3/system/component/settings/${this.ref}/${version}`, settings);
18201
- return data;
18178
+ return await this.client.post(`/v3/system/component/settings/${this.ref}/${version}`, settings);
18202
18179
  }
18203
18180
  async saveTemplatesDist(version, sdkVersion, engine, dist) {
18204
- const { data } = await this.client.post(`/v3/system/component/templates/${this.ref}/${version}`, {
18181
+ return await this.client.post(`/v3/system/component/templates/${this.ref}/${version}`, {
18205
18182
  templates_dist: {
18206
18183
  sdk_version: sdkVersion,
18207
18184
  sdk_engine: engine,
18208
18185
  dist,
18209
18186
  }
18210
18187
  });
18211
- return data;
18212
18188
  }
18213
18189
  async workflow(event, input) {
18214
- const { data } = await this.client.post(`/v1/system/component/${this.ref}/workflow/event`, {
18190
+ return await this.client.post(`/v1/system/component/${this.ref}/workflow/event`, {
18215
18191
  event,
18216
18192
  input
18217
18193
  });
18218
- return data;
18219
18194
  }
18220
18195
  async function(name, input) {
18221
- const { data } = await this.client.post(`/v3/system/component/${this.ref}/function/${name}`, input);
18222
- return data;
18196
+ return await this.client.post(`/v3/system/component/${this.ref}/function/${name}`, input);
18223
18197
  }
18224
18198
  }
18225
18199
 
18226
18200
  class ComponentUtils extends PlatformBaseClient {
18227
18201
  async list() {
18228
- const { data } = await this.client.get("/v1/system/components");
18229
- return data;
18202
+ return await this.client.get("/v1/system/components");
18230
18203
  }
18231
18204
  async create(data) {
18232
- const { data: responseData } = await this.client.post("/v3/system/component/create", data);
18233
- return responseData;
18205
+ return await this.client.post("/v3/system/component/create", data);
18234
18206
  }
18235
18207
  }
18236
18208
 
18237
18209
  class Thunder extends PlatformBaseClient {
18238
18210
  async read(type, filters, flag, options) {
18239
- const { data } = await this.client.post("/v3/system/thunder", {
18211
+ return await this.client.post("/v3/system/thunder", {
18240
18212
  type,
18241
18213
  filters,
18242
18214
  flag,
18243
18215
  options,
18244
18216
  });
18245
- return data;
18246
18217
  }
18247
18218
  async write(type, filters, d, flag) {
18248
- const { data } = await this.client.put("/v3/system/thunder", {
18219
+ return await this.client.put("/v3/system/thunder", {
18249
18220
  type,
18250
18221
  filters,
18251
18222
  flag,
18252
18223
  data: d,
18253
18224
  });
18254
- return data;
18255
18225
  }
18256
18226
  async operation(name, filters, data) {
18257
18227
  return await this.write(name, filters, data, "Operation");
@@ -18281,11 +18251,10 @@ class Thunder extends PlatformBaseClient {
18281
18251
 
18282
18252
  class Ratchet extends PlatformBaseClient {
18283
18253
  async query(name, params) {
18284
- let res = await this.client.post('/v1/ratchet/query', {
18254
+ return await this.client.post('/v1/ratchet/query', {
18285
18255
  name: name,
18286
18256
  params: params
18287
18257
  });
18288
- return res.data;
18289
18258
  }
18290
18259
  }
18291
18260
 
@@ -18307,14 +18276,10 @@ class Sandbox extends PlatformBaseClient {
18307
18276
 
18308
18277
  class System extends PlatformBaseClient {
18309
18278
  async resourceResolver(ref, resourceName, format) {
18310
- const { data } = await this.client.post("/v3/system/resource-resolver", {
18279
+ return await this.client.post("/v3/system/resource-resolver", {
18311
18280
  type: resourceName,
18312
18281
  format,
18313
18282
  });
18314
- if (format) {
18315
- return data.format;
18316
- }
18317
- return data;
18318
18283
  }
18319
18284
  }
18320
18285
 
package/dist/index.esm.js CHANGED
@@ -100,7 +100,7 @@ class Functions extends PlatformBaseClient {
100
100
  params: d.query,
101
101
  headers: d.headers
102
102
  });
103
- return data.data;
103
+ return data;
104
104
  }
105
105
  async generateSignature(ref, env) {
106
106
  return await this.client.get(`/v1/system/function/signature/${env}/${ref}`);
@@ -109,25 +109,19 @@ class Functions extends PlatformBaseClient {
109
109
 
110
110
  class Roles extends PlatformBaseClient {
111
111
  async create(role) {
112
- const res = await this.client.post("/v1/user/role/create", role);
113
- // writeFileSync(`.role.create.json`,JSON.stringify(res))
114
- return res.data;
112
+ return await this.client.post("/v1/user/role/create", role);
115
113
  }
116
114
  async delete(uuid) {
117
- const { data } = await this.client.delete(`/v1/user/role/delete/${uuid}`);
118
- return data;
115
+ return await this.client.delete(`/v1/user/role/delete/${uuid}`);
119
116
  }
120
117
  async list() {
121
- const { data } = await this.client.get(`/v1/user/role/list`);
122
- return data;
118
+ return await this.client.get(`/v1/user/role/list`);
123
119
  }
124
120
  async listPermissions() {
125
- const { data } = await this.client.get(`/v1/user/permissions/list`);
126
- return data;
121
+ return await this.client.get(`/v1/user/permissions/list`);
127
122
  }
128
123
  async edit(permissions, workspaces, level, uuid) {
129
- const { data } = await this.client.post(`/v1/user/role/edit/${uuid}`, { permissions, workspaces, level });
130
- return data;
124
+ return await this.client.post(`/v1/user/role/edit/${uuid}`, { permissions, workspaces, level });
131
125
  }
132
126
  }
133
127
 
@@ -219,64 +213,57 @@ class Component extends PlatformBaseClient {
219
213
  * }
220
214
  * )
221
215
  **/
222
- find(filters, opts) {
216
+ async find(filters, opts) {
223
217
  const { cache = false, buildttl = -1, locale = "en_US", } = opts !== null && opts !== undefined ? opts : {};
224
- return new Promise((resolve, reject) => {
225
- let payload = {
226
- context: filters,
227
- ref: this.ref,
228
- };
229
- let ctx = payload.context;
230
- let offset = ctx.currentPage;
231
- if (offset == undefined) {
232
- offset = 0;
233
- }
234
- let limit = ctx.perPage;
235
- if (limit == undefined || limit == -1) {
236
- limit = 10;
237
- }
238
- let sortDesc = 1;
239
- if (ctx.sortDesc) {
240
- sortDesc = -1;
241
- }
242
- if (ctx.filterOn === undefined) {
243
- ctx.filterOn = [];
244
- }
245
- let params = {
246
- offset: offset,
247
- sortBy: ctx.sortBy,
248
- sortDesc: sortDesc,
249
- filter: ctx.filter,
250
- filterOn: ctx.filterOn.join(","),
251
- limit: limit,
252
- dateFrom: ctx.dateFrom,
253
- dateTo: ctx.dateTo,
254
- dateField: ctx.dateField,
255
- };
256
- if (Object.keys(ctx.$adv || []).length > 0) {
257
- params.$adv = JSON.stringify([ctx.$adv]);
258
- }
259
- if (ctx.$aggregate && ctx.$aggregate.length > 0) {
260
- params.$aggregate = JSON.stringify(ctx.$aggregate);
261
- }
262
- if (opts) {
263
- Object.keys(opts).forEach(k => {
264
- params[`_opt_${k}`] = opts ? opts[k] : null;
265
- });
266
- }
267
- this.client.get(`/v3/system/component/${this.ref}/models`, {
268
- params: params,
269
- headers: {
270
- 'X-Cache': cache,
271
- 'X-Build-Ttl': buildttl,
272
- 'Accept-Language': locale
273
- }
274
- }).then((resp) => {
275
- let { data = [] } = resp || {};
276
- resolve(data);
277
- }).catch((err) => {
278
- reject(err);
218
+ let payload = {
219
+ context: filters,
220
+ ref: this.ref,
221
+ };
222
+ let ctx = payload.context;
223
+ let offset = ctx.currentPage;
224
+ if (offset == undefined) {
225
+ offset = 0;
226
+ }
227
+ let limit = ctx.perPage;
228
+ if (limit == undefined || limit == -1) {
229
+ limit = 10;
230
+ }
231
+ let sortDesc = 1;
232
+ if (ctx.sortDesc) {
233
+ sortDesc = -1;
234
+ }
235
+ if (ctx.filterOn === undefined) {
236
+ ctx.filterOn = [];
237
+ }
238
+ let params = {
239
+ offset: offset,
240
+ sortBy: ctx.sortBy,
241
+ sortDesc: sortDesc,
242
+ filter: ctx.filter,
243
+ filterOn: ctx.filterOn.join(","),
244
+ limit: limit,
245
+ dateFrom: ctx.dateFrom,
246
+ dateTo: ctx.dateTo,
247
+ dateField: ctx.dateField,
248
+ };
249
+ if (Object.keys(ctx.$adv || []).length > 0) {
250
+ params.$adv = JSON.stringify([ctx.$adv]);
251
+ }
252
+ if (ctx.$aggregate && ctx.$aggregate.length > 0) {
253
+ params.$aggregate = JSON.stringify(ctx.$aggregate);
254
+ }
255
+ if (opts) {
256
+ Object.keys(opts).forEach(k => {
257
+ params[`_opt_${k}`] = opts ? opts[k] : null;
279
258
  });
259
+ }
260
+ return await this.client.get(`/v3/system/component/${this.ref}/models`, {
261
+ params: params,
262
+ headers: {
263
+ 'X-Cache': cache,
264
+ 'X-Build-Ttl': buildttl,
265
+ 'Accept-Language': locale
266
+ }
280
267
  });
281
268
  }
282
269
  /**
@@ -308,8 +295,7 @@ class Component extends PlatformBaseClient {
308
295
  * @returns (Promise<Model>)
309
296
  */
310
297
  async get(uuid) {
311
- const { data } = await this.client.get(`/v3/system/component/${this.ref}/model/${uuid}`);
312
- return data;
298
+ return await this.client.get(`/v3/system/component/${this.ref}/model/${uuid}`);
313
299
  }
314
300
  /**
315
301
  * Update model by uuid
@@ -319,11 +305,10 @@ class Component extends PlatformBaseClient {
319
305
  * @returns
320
306
  */
321
307
  async update(uuid, data, options) {
322
- const { data: responseData } = await this.client.post(`/v3/system/component/${this.ref}/model/${uuid}`, {
308
+ return await this.client.post(`/v3/system/component/${this.ref}/model/${uuid}`, {
323
309
  data,
324
310
  options,
325
311
  });
326
- return responseData;
327
312
  }
328
313
  /**
329
314
  * Update many models
@@ -333,11 +318,10 @@ class Component extends PlatformBaseClient {
333
318
  * @returns
334
319
  */
335
320
  async updateMany(data, options) {
336
- const { data: responseData } = await this.client.post(`/v3/system/component/${this.ref}/models/bulk`, {
321
+ return await this.client.post(`/v3/system/component/${this.ref}/models/bulk`, {
337
322
  data,
338
323
  options,
339
324
  });
340
- return responseData;
341
325
  }
342
326
  /**
343
327
  * Modify models by filters
@@ -347,12 +331,11 @@ class Component extends PlatformBaseClient {
347
331
  * @returns
348
332
  */
349
333
  async modify(filters, data, options) {
350
- const { data: responseData } = await this.client.patch(`/v3/system/component/${this.ref}/modify/model`, {
334
+ return await this.client.patch(`/v3/system/component/${this.ref}/modify/model`, {
351
335
  filters,
352
336
  data,
353
337
  options,
354
338
  });
355
- return responseData;
356
339
  }
357
340
  /**
358
341
  * Concurrent update model by uuid
@@ -363,85 +346,72 @@ class Component extends PlatformBaseClient {
363
346
  * @returns
364
347
  */
365
348
  async concurrentUpdate(uuid, version, data, options) {
366
- const { data: responseData } = await this.client.post(`/v3/system/component/${this.ref}/model/${uuid}`, {
349
+ return await this.client.post(`/v3/system/component/${this.ref}/model/${uuid}`, {
367
350
  version: version,
368
351
  data,
369
352
  options,
370
353
  });
371
- return responseData;
372
354
  }
373
355
  async create(model) {
374
- const { data } = await this.client.post(`/v3/system/component/${this.ref}/model`, model);
375
- return data;
356
+ return await this.client.post(`/v3/system/component/${this.ref}/model`, model);
376
357
  }
377
358
  async delete(uuid) {
378
- const { data } = await this.client.delete(`/v3/system/component/${this.ref}/model/${uuid}`);
379
- return data;
359
+ return await this.client.delete(`/v3/system/component/${this.ref}/model/${uuid}`);
380
360
  }
381
361
  async aggregate(pipeline) {
382
- const { data } = await this.client.post(`/v3/system/component/${this.ref}/aggregate`, pipeline);
383
- return data;
362
+ return await this.client.post(`/v3/system/component/${this.ref}/aggregate`, pipeline);
384
363
  }
385
364
  async settings() {
386
- const { data } = await this.client.get(`/v3/system/component/settings/${this.ref}`);
387
- return data;
365
+ return await this.client.get(`/v3/system/component/settings/${this.ref}`);
388
366
  }
389
367
  async saveSettings(settings, version) {
390
- const { data } = await this.client.post(`/v3/system/component/settings/${this.ref}/${version}`, settings);
391
- return data;
368
+ return await this.client.post(`/v3/system/component/settings/${this.ref}/${version}`, settings);
392
369
  }
393
370
  async saveTemplatesDist(version, sdkVersion, engine, dist) {
394
- const { data } = await this.client.post(`/v3/system/component/templates/${this.ref}/${version}`, {
371
+ return await this.client.post(`/v3/system/component/templates/${this.ref}/${version}`, {
395
372
  templates_dist: {
396
373
  sdk_version: sdkVersion,
397
374
  sdk_engine: engine,
398
375
  dist,
399
376
  }
400
377
  });
401
- return data;
402
378
  }
403
379
  async workflow(event, input) {
404
- const { data } = await this.client.post(`/v1/system/component/${this.ref}/workflow/event`, {
380
+ return await this.client.post(`/v1/system/component/${this.ref}/workflow/event`, {
405
381
  event,
406
382
  input
407
383
  });
408
- return data;
409
384
  }
410
385
  async function(name, input) {
411
- const { data } = await this.client.post(`/v3/system/component/${this.ref}/function/${name}`, input);
412
- return data;
386
+ return await this.client.post(`/v3/system/component/${this.ref}/function/${name}`, input);
413
387
  }
414
388
  }
415
389
 
416
390
  class ComponentUtils extends PlatformBaseClient {
417
391
  async list() {
418
- const { data } = await this.client.get("/v1/system/components");
419
- return data;
392
+ return await this.client.get("/v1/system/components");
420
393
  }
421
394
  async create(data) {
422
- const { data: responseData } = await this.client.post("/v3/system/component/create", data);
423
- return responseData;
395
+ return await this.client.post("/v3/system/component/create", data);
424
396
  }
425
397
  }
426
398
 
427
399
  class Thunder extends PlatformBaseClient {
428
400
  async read(type, filters, flag, options) {
429
- const { data } = await this.client.post("/v3/system/thunder", {
401
+ return await this.client.post("/v3/system/thunder", {
430
402
  type,
431
403
  filters,
432
404
  flag,
433
405
  options,
434
406
  });
435
- return data;
436
407
  }
437
408
  async write(type, filters, d, flag) {
438
- const { data } = await this.client.put("/v3/system/thunder", {
409
+ return await this.client.put("/v3/system/thunder", {
439
410
  type,
440
411
  filters,
441
412
  flag,
442
413
  data: d,
443
414
  });
444
- return data;
445
415
  }
446
416
  async operation(name, filters, data) {
447
417
  return await this.write(name, filters, data, "Operation");
@@ -471,11 +441,10 @@ class Thunder extends PlatformBaseClient {
471
441
 
472
442
  class Ratchet extends PlatformBaseClient {
473
443
  async query(name, params) {
474
- let res = await this.client.post('/v1/ratchet/query', {
444
+ return await this.client.post('/v1/ratchet/query', {
475
445
  name: name,
476
446
  params: params
477
447
  });
478
- return res.data;
479
448
  }
480
449
  }
481
450
 
@@ -497,14 +466,10 @@ class Sandbox extends PlatformBaseClient {
497
466
 
498
467
  class System extends PlatformBaseClient {
499
468
  async resourceResolver(ref, resourceName, format) {
500
- const { data } = await this.client.post("/v3/system/resource-resolver", {
469
+ return await this.client.post("/v3/system/resource-resolver", {
501
470
  type: resourceName,
502
471
  format,
503
472
  });
504
- if (format) {
505
- return data.format;
506
- }
507
- return data;
508
473
  }
509
474
  }
510
475
 
@@ -101,7 +101,7 @@ var ProtokolSDK = (function (exports, axios) {
101
101
  params: d.query,
102
102
  headers: d.headers
103
103
  });
104
- return data.data;
104
+ return data;
105
105
  }
106
106
  async generateSignature(ref, env) {
107
107
  return await this.client.get(`/v1/system/function/signature/${env}/${ref}`);
@@ -110,25 +110,19 @@ var ProtokolSDK = (function (exports, axios) {
110
110
 
111
111
  class Roles extends PlatformBaseClient {
112
112
  async create(role) {
113
- const res = await this.client.post("/v1/user/role/create", role);
114
- // writeFileSync(`.role.create.json`,JSON.stringify(res))
115
- return res.data;
113
+ return await this.client.post("/v1/user/role/create", role);
116
114
  }
117
115
  async delete(uuid) {
118
- const { data } = await this.client.delete(`/v1/user/role/delete/${uuid}`);
119
- return data;
116
+ return await this.client.delete(`/v1/user/role/delete/${uuid}`);
120
117
  }
121
118
  async list() {
122
- const { data } = await this.client.get(`/v1/user/role/list`);
123
- return data;
119
+ return await this.client.get(`/v1/user/role/list`);
124
120
  }
125
121
  async listPermissions() {
126
- const { data } = await this.client.get(`/v1/user/permissions/list`);
127
- return data;
122
+ return await this.client.get(`/v1/user/permissions/list`);
128
123
  }
129
124
  async edit(permissions, workspaces, level, uuid) {
130
- const { data } = await this.client.post(`/v1/user/role/edit/${uuid}`, { permissions, workspaces, level });
131
- return data;
125
+ return await this.client.post(`/v1/user/role/edit/${uuid}`, { permissions, workspaces, level });
132
126
  }
133
127
  }
134
128
 
@@ -220,64 +214,57 @@ var ProtokolSDK = (function (exports, axios) {
220
214
  * }
221
215
  * )
222
216
  **/
223
- find(filters, opts) {
217
+ async find(filters, opts) {
224
218
  const { cache = false, buildttl = -1, locale = "en_US", } = opts !== null && opts !== undefined ? opts : {};
225
- return new Promise((resolve, reject) => {
226
- let payload = {
227
- context: filters,
228
- ref: this.ref,
229
- };
230
- let ctx = payload.context;
231
- let offset = ctx.currentPage;
232
- if (offset == undefined) {
233
- offset = 0;
234
- }
235
- let limit = ctx.perPage;
236
- if (limit == undefined || limit == -1) {
237
- limit = 10;
238
- }
239
- let sortDesc = 1;
240
- if (ctx.sortDesc) {
241
- sortDesc = -1;
242
- }
243
- if (ctx.filterOn === undefined) {
244
- ctx.filterOn = [];
245
- }
246
- let params = {
247
- offset: offset,
248
- sortBy: ctx.sortBy,
249
- sortDesc: sortDesc,
250
- filter: ctx.filter,
251
- filterOn: ctx.filterOn.join(","),
252
- limit: limit,
253
- dateFrom: ctx.dateFrom,
254
- dateTo: ctx.dateTo,
255
- dateField: ctx.dateField,
256
- };
257
- if (Object.keys(ctx.$adv || []).length > 0) {
258
- params.$adv = JSON.stringify([ctx.$adv]);
259
- }
260
- if (ctx.$aggregate && ctx.$aggregate.length > 0) {
261
- params.$aggregate = JSON.stringify(ctx.$aggregate);
262
- }
263
- if (opts) {
264
- Object.keys(opts).forEach(k => {
265
- params[`_opt_${k}`] = opts ? opts[k] : null;
266
- });
267
- }
268
- this.client.get(`/v3/system/component/${this.ref}/models`, {
269
- params: params,
270
- headers: {
271
- 'X-Cache': cache,
272
- 'X-Build-Ttl': buildttl,
273
- 'Accept-Language': locale
274
- }
275
- }).then((resp) => {
276
- let { data = [] } = resp || {};
277
- resolve(data);
278
- }).catch((err) => {
279
- reject(err);
219
+ let payload = {
220
+ context: filters,
221
+ ref: this.ref,
222
+ };
223
+ let ctx = payload.context;
224
+ let offset = ctx.currentPage;
225
+ if (offset == undefined) {
226
+ offset = 0;
227
+ }
228
+ let limit = ctx.perPage;
229
+ if (limit == undefined || limit == -1) {
230
+ limit = 10;
231
+ }
232
+ let sortDesc = 1;
233
+ if (ctx.sortDesc) {
234
+ sortDesc = -1;
235
+ }
236
+ if (ctx.filterOn === undefined) {
237
+ ctx.filterOn = [];
238
+ }
239
+ let params = {
240
+ offset: offset,
241
+ sortBy: ctx.sortBy,
242
+ sortDesc: sortDesc,
243
+ filter: ctx.filter,
244
+ filterOn: ctx.filterOn.join(","),
245
+ limit: limit,
246
+ dateFrom: ctx.dateFrom,
247
+ dateTo: ctx.dateTo,
248
+ dateField: ctx.dateField,
249
+ };
250
+ if (Object.keys(ctx.$adv || []).length > 0) {
251
+ params.$adv = JSON.stringify([ctx.$adv]);
252
+ }
253
+ if (ctx.$aggregate && ctx.$aggregate.length > 0) {
254
+ params.$aggregate = JSON.stringify(ctx.$aggregate);
255
+ }
256
+ if (opts) {
257
+ Object.keys(opts).forEach(k => {
258
+ params[`_opt_${k}`] = opts ? opts[k] : null;
280
259
  });
260
+ }
261
+ return await this.client.get(`/v3/system/component/${this.ref}/models`, {
262
+ params: params,
263
+ headers: {
264
+ 'X-Cache': cache,
265
+ 'X-Build-Ttl': buildttl,
266
+ 'Accept-Language': locale
267
+ }
281
268
  });
282
269
  }
283
270
  /**
@@ -309,8 +296,7 @@ var ProtokolSDK = (function (exports, axios) {
309
296
  * @returns (Promise<Model>)
310
297
  */
311
298
  async get(uuid) {
312
- const { data } = await this.client.get(`/v3/system/component/${this.ref}/model/${uuid}`);
313
- return data;
299
+ return await this.client.get(`/v3/system/component/${this.ref}/model/${uuid}`);
314
300
  }
315
301
  /**
316
302
  * Update model by uuid
@@ -320,11 +306,10 @@ var ProtokolSDK = (function (exports, axios) {
320
306
  * @returns
321
307
  */
322
308
  async update(uuid, data, options) {
323
- const { data: responseData } = await this.client.post(`/v3/system/component/${this.ref}/model/${uuid}`, {
309
+ return await this.client.post(`/v3/system/component/${this.ref}/model/${uuid}`, {
324
310
  data,
325
311
  options,
326
312
  });
327
- return responseData;
328
313
  }
329
314
  /**
330
315
  * Update many models
@@ -334,11 +319,10 @@ var ProtokolSDK = (function (exports, axios) {
334
319
  * @returns
335
320
  */
336
321
  async updateMany(data, options) {
337
- const { data: responseData } = await this.client.post(`/v3/system/component/${this.ref}/models/bulk`, {
322
+ return await this.client.post(`/v3/system/component/${this.ref}/models/bulk`, {
338
323
  data,
339
324
  options,
340
325
  });
341
- return responseData;
342
326
  }
343
327
  /**
344
328
  * Modify models by filters
@@ -348,12 +332,11 @@ var ProtokolSDK = (function (exports, axios) {
348
332
  * @returns
349
333
  */
350
334
  async modify(filters, data, options) {
351
- const { data: responseData } = await this.client.patch(`/v3/system/component/${this.ref}/modify/model`, {
335
+ return await this.client.patch(`/v3/system/component/${this.ref}/modify/model`, {
352
336
  filters,
353
337
  data,
354
338
  options,
355
339
  });
356
- return responseData;
357
340
  }
358
341
  /**
359
342
  * Concurrent update model by uuid
@@ -364,85 +347,72 @@ var ProtokolSDK = (function (exports, axios) {
364
347
  * @returns
365
348
  */
366
349
  async concurrentUpdate(uuid, version, data, options) {
367
- const { data: responseData } = await this.client.post(`/v3/system/component/${this.ref}/model/${uuid}`, {
350
+ return await this.client.post(`/v3/system/component/${this.ref}/model/${uuid}`, {
368
351
  version: version,
369
352
  data,
370
353
  options,
371
354
  });
372
- return responseData;
373
355
  }
374
356
  async create(model) {
375
- const { data } = await this.client.post(`/v3/system/component/${this.ref}/model`, model);
376
- return data;
357
+ return await this.client.post(`/v3/system/component/${this.ref}/model`, model);
377
358
  }
378
359
  async delete(uuid) {
379
- const { data } = await this.client.delete(`/v3/system/component/${this.ref}/model/${uuid}`);
380
- return data;
360
+ return await this.client.delete(`/v3/system/component/${this.ref}/model/${uuid}`);
381
361
  }
382
362
  async aggregate(pipeline) {
383
- const { data } = await this.client.post(`/v3/system/component/${this.ref}/aggregate`, pipeline);
384
- return data;
363
+ return await this.client.post(`/v3/system/component/${this.ref}/aggregate`, pipeline);
385
364
  }
386
365
  async settings() {
387
- const { data } = await this.client.get(`/v3/system/component/settings/${this.ref}`);
388
- return data;
366
+ return await this.client.get(`/v3/system/component/settings/${this.ref}`);
389
367
  }
390
368
  async saveSettings(settings, version) {
391
- const { data } = await this.client.post(`/v3/system/component/settings/${this.ref}/${version}`, settings);
392
- return data;
369
+ return await this.client.post(`/v3/system/component/settings/${this.ref}/${version}`, settings);
393
370
  }
394
371
  async saveTemplatesDist(version, sdkVersion, engine, dist) {
395
- const { data } = await this.client.post(`/v3/system/component/templates/${this.ref}/${version}`, {
372
+ return await this.client.post(`/v3/system/component/templates/${this.ref}/${version}`, {
396
373
  templates_dist: {
397
374
  sdk_version: sdkVersion,
398
375
  sdk_engine: engine,
399
376
  dist,
400
377
  }
401
378
  });
402
- return data;
403
379
  }
404
380
  async workflow(event, input) {
405
- const { data } = await this.client.post(`/v1/system/component/${this.ref}/workflow/event`, {
381
+ return await this.client.post(`/v1/system/component/${this.ref}/workflow/event`, {
406
382
  event,
407
383
  input
408
384
  });
409
- return data;
410
385
  }
411
386
  async function(name, input) {
412
- const { data } = await this.client.post(`/v3/system/component/${this.ref}/function/${name}`, input);
413
- return data;
387
+ return await this.client.post(`/v3/system/component/${this.ref}/function/${name}`, input);
414
388
  }
415
389
  }
416
390
 
417
391
  class ComponentUtils extends PlatformBaseClient {
418
392
  async list() {
419
- const { data } = await this.client.get("/v1/system/components");
420
- return data;
393
+ return await this.client.get("/v1/system/components");
421
394
  }
422
395
  async create(data) {
423
- const { data: responseData } = await this.client.post("/v3/system/component/create", data);
424
- return responseData;
396
+ return await this.client.post("/v3/system/component/create", data);
425
397
  }
426
398
  }
427
399
 
428
400
  class Thunder extends PlatformBaseClient {
429
401
  async read(type, filters, flag, options) {
430
- const { data } = await this.client.post("/v3/system/thunder", {
402
+ return await this.client.post("/v3/system/thunder", {
431
403
  type,
432
404
  filters,
433
405
  flag,
434
406
  options,
435
407
  });
436
- return data;
437
408
  }
438
409
  async write(type, filters, d, flag) {
439
- const { data } = await this.client.put("/v3/system/thunder", {
410
+ return await this.client.put("/v3/system/thunder", {
440
411
  type,
441
412
  filters,
442
413
  flag,
443
414
  data: d,
444
415
  });
445
- return data;
446
416
  }
447
417
  async operation(name, filters, data) {
448
418
  return await this.write(name, filters, data, "Operation");
@@ -472,11 +442,10 @@ var ProtokolSDK = (function (exports, axios) {
472
442
 
473
443
  class Ratchet extends PlatformBaseClient {
474
444
  async query(name, params) {
475
- let res = await this.client.post('/v1/ratchet/query', {
445
+ return await this.client.post('/v1/ratchet/query', {
476
446
  name: name,
477
447
  params: params
478
448
  });
479
- return res.data;
480
449
  }
481
450
  }
482
451
 
@@ -498,14 +467,10 @@ var ProtokolSDK = (function (exports, axios) {
498
467
 
499
468
  class System extends PlatformBaseClient {
500
469
  async resourceResolver(ref, resourceName, format) {
501
- const { data } = await this.client.post("/v3/system/resource-resolver", {
470
+ return await this.client.post("/v3/system/resource-resolver", {
502
471
  type: resourceName,
503
472
  format,
504
473
  });
505
- if (format) {
506
- return data.format;
507
- }
508
- return data;
509
474
  }
510
475
  }
511
476
 
package/dist/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ptkl/sdk",
3
- "version": "0.8.2",
3
+ "version": "0.8.3",
4
4
  "scripts": {
5
5
  "build": "rollup -c",
6
6
  "docs": "typedoc"
@@ -53,7 +53,7 @@ export default class Component extends PlatformBaseClient {
53
53
  * @param data
54
54
  * @returns
55
55
  */
56
- update(uuid: string, data: Record<string, any>, options: UpdateOptions): Promise<any>;
56
+ update(uuid: string, data: Record<string, any>, options: UpdateOptions): Promise<import("axios").AxiosResponse<any, any>>;
57
57
  /**
58
58
  * Update many models
59
59
  *
@@ -61,7 +61,7 @@ export default class Component extends PlatformBaseClient {
61
61
  * @param options
62
62
  * @returns
63
63
  */
64
- updateMany(data: Record<string, any>[], options: UpdateOptions): Promise<any>;
64
+ updateMany(data: Record<string, any>[], options: UpdateOptions): Promise<import("axios").AxiosResponse<any, any>>;
65
65
  /**
66
66
  * Modify models by filters
67
67
  *
@@ -69,7 +69,7 @@ export default class Component extends PlatformBaseClient {
69
69
  * @param options
70
70
  * @returns
71
71
  */
72
- modify(filters: Record<string, any>, data: Record<string, any>, options: ModifyOptions): Promise<any>;
72
+ modify(filters: Record<string, any>, data: Record<string, any>, options: ModifyOptions): Promise<import("axios").AxiosResponse<any, any>>;
73
73
  /**
74
74
  * Concurrent update model by uuid
75
75
  *
@@ -78,14 +78,14 @@ export default class Component extends PlatformBaseClient {
78
78
  * @param data
79
79
  * @returns
80
80
  */
81
- concurrentUpdate(uuid: string, version: number, data: Record<string, any>, options: UpdateOptions): Promise<any>;
82
- create(model: Record<string, any>): Promise<any>;
83
- delete(uuid: string): Promise<any>;
84
- aggregate(pipeline: FindAggregateParams): Promise<any>;
85
- settings(): Promise<any>;
86
- saveSettings(settings: any, version: string): Promise<any>;
81
+ concurrentUpdate(uuid: string, version: number, data: Record<string, any>, options: UpdateOptions): Promise<import("axios").AxiosResponse<any, any>>;
82
+ create(model: Record<string, any>): Promise<import("axios").AxiosResponse<any, any>>;
83
+ delete(uuid: string): Promise<import("axios").AxiosResponse<any, any>>;
84
+ aggregate(pipeline: FindAggregateParams): Promise<import("axios").AxiosResponse<any, any>>;
85
+ settings(): Promise<import("axios").AxiosResponse<any, any>>;
86
+ saveSettings(settings: any, version: string): Promise<import("axios").AxiosResponse<any, any>>;
87
87
  saveTemplatesDist(version: string, sdkVersion: string, engine: string, dist: Record<string, string>): Promise<any>;
88
- workflow(event: string, input: any): Promise<any>;
89
- function(name: string, input: any): Promise<any>;
88
+ workflow(event: string, input: any): Promise<import("axios").AxiosResponse<any, any>>;
89
+ function(name: string, input: any): Promise<import("axios").AxiosResponse<any, any>>;
90
90
  }
91
91
  export { FindParams, FindOptions, FindResponse, FindAdvancedParams, FindAggregateParams, Model, UpdateOptions, };
@@ -1,5 +1,5 @@
1
1
  import PlatformBaseClient from "./platformBaseClient";
2
2
  export default class ComponentUtils extends PlatformBaseClient {
3
- list(): Promise<any>;
4
- create(data: any): Promise<any>;
3
+ list(): Promise<import("axios").AxiosResponse<any, any>>;
4
+ create(data: any): Promise<import("axios").AxiosResponse<any, any>>;
5
5
  }
@@ -16,8 +16,8 @@ export default class Functions extends PlatformBaseClient {
16
16
  */
17
17
  run(id: string, d: {
18
18
  input?: any;
19
- query: any;
20
- headers: any;
19
+ query?: any;
20
+ headers?: any;
21
21
  }): Promise<any>;
22
22
  generateSignature(ref: string, env: string): Promise<import("axios").AxiosResponse<any, any>>;
23
23
  }
@@ -1,4 +1,4 @@
1
1
  import PlatformBaseClient from "./platformBaseClient";
2
2
  export default class Ratchet extends PlatformBaseClient {
3
- query(name: string, params: any): Promise<any>;
3
+ query(name: string, params: any): Promise<import("axios").AxiosResponse<any, any>>;
4
4
  }
@@ -1,4 +1,4 @@
1
1
  import PlatformBaseClient from "./platformBaseClient";
2
2
  export default class System extends PlatformBaseClient {
3
- resourceResolver(ref: string, resourceName: string, format?: string): Promise<any>;
3
+ resourceResolver(ref: string, resourceName: string, format?: string): Promise<import("axios").AxiosResponse<any, any>>;
4
4
  }
@@ -1,13 +1,13 @@
1
1
  import PlatformBaseClient from "./platformBaseClient";
2
2
  export default class Thunder extends PlatformBaseClient {
3
- read(type: string, filters: any, flag: string, options?: any): Promise<any>;
4
- write(type: string, filters: any, d: any, flag: any): Promise<any>;
5
- operation(name: string, filters: any, data: any): Promise<any>;
6
- find(name: string, filters: any): Promise<any>;
7
- findOne(name: string, filters: any): Promise<any>;
8
- paginate(name: string, filters: any, options?: any): Promise<any>;
9
- upsert(name: string, filters: any, data: any): Promise<any>;
10
- insertOne(name: string, data: any): Promise<any>;
11
- updateOne(name: string, filters: any, data: any): Promise<any>;
12
- delete(name: string, filters: any): Promise<any>;
3
+ read(type: string, filters: any, flag: string, options?: any): Promise<import("axios").AxiosResponse<any, any>>;
4
+ write(type: string, filters: any, d: any, flag: any): Promise<import("axios").AxiosResponse<any, any>>;
5
+ operation(name: string, filters: any, data: any): Promise<import("axios").AxiosResponse<any, any>>;
6
+ find(name: string, filters: any): Promise<import("axios").AxiosResponse<any, any>>;
7
+ findOne(name: string, filters: any): Promise<import("axios").AxiosResponse<any, any>>;
8
+ paginate(name: string, filters: any, options?: any): Promise<import("axios").AxiosResponse<any, any>>;
9
+ upsert(name: string, filters: any, data: any): Promise<import("axios").AxiosResponse<any, any>>;
10
+ insertOne(name: string, data: any): Promise<import("axios").AxiosResponse<any, any>>;
11
+ updateOne(name: string, filters: any, data: any): Promise<import("axios").AxiosResponse<any, any>>;
12
+ delete(name: string, filters: any): Promise<import("axios").AxiosResponse<any, any>>;
13
13
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ptkl/sdk",
3
- "version": "0.8.3",
3
+ "version": "0.8.4",
4
4
  "scripts": {
5
5
  "build": "rollup -c",
6
6
  "docs": "typedoc"