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