@konversi/konversi-client 1.2.4 → 1.3.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.d.mts CHANGED
@@ -153,6 +153,7 @@ declare function getObjectById(entity: any, id: string): Promise<any>;
153
153
  declare function updateObject(entity: any, id: string, newData: any): Promise<any>;
154
154
  declare function createObject(entity: any, data: any): Promise<any>;
155
155
  declare function deleteObject(entity: any, id: string): Promise<any>;
156
+ declare function runScript(scriptNameOrId: string, input: any, sync?: boolean): Promise<any>;
156
157
  declare const konversiAPI: {
157
158
  setToken: (token: string) => void;
158
159
  setCompanyId: (companyId: string) => void;
@@ -167,6 +168,7 @@ declare const konversiAPI: {
167
168
  updateObject: typeof updateObject;
168
169
  createObject: typeof createObject;
169
170
  deleteObject: typeof deleteObject;
171
+ runScript: typeof runScript;
170
172
  baseUrl: string | undefined;
171
173
  token: string;
172
174
  companyId: axios.AxiosHeaderValue | undefined;
@@ -174,4 +176,4 @@ declare const konversiAPI: {
174
176
 
175
177
  declare const Entity: typeof crudEndpoints;
176
178
 
177
- export { Entity, konversiAPI as default };
179
+ export { Entity, konversiAPI as default, runScript };
package/dist/index.d.ts CHANGED
@@ -153,6 +153,7 @@ declare function getObjectById(entity: any, id: string): Promise<any>;
153
153
  declare function updateObject(entity: any, id: string, newData: any): Promise<any>;
154
154
  declare function createObject(entity: any, data: any): Promise<any>;
155
155
  declare function deleteObject(entity: any, id: string): Promise<any>;
156
+ declare function runScript(scriptNameOrId: string, input: any, sync?: boolean): Promise<any>;
156
157
  declare const konversiAPI: {
157
158
  setToken: (token: string) => void;
158
159
  setCompanyId: (companyId: string) => void;
@@ -167,6 +168,7 @@ declare const konversiAPI: {
167
168
  updateObject: typeof updateObject;
168
169
  createObject: typeof createObject;
169
170
  deleteObject: typeof deleteObject;
171
+ runScript: typeof runScript;
170
172
  baseUrl: string | undefined;
171
173
  token: string;
172
174
  companyId: axios.AxiosHeaderValue | undefined;
@@ -174,4 +176,4 @@ declare const konversiAPI: {
174
176
 
175
177
  declare const Entity: typeof crudEndpoints;
176
178
 
177
- export { Entity, konversiAPI as default };
179
+ export { Entity, konversiAPI as default, runScript };
package/dist/index.js CHANGED
@@ -51,7 +51,8 @@ var __async = (__this, __arguments, generator) => {
51
51
  var konversi_client_exports = {};
52
52
  __export(konversi_client_exports, {
53
53
  Entity: () => Entity,
54
- default: () => konversi_client_default
54
+ default: () => konversi_client_default,
55
+ runScript: () => runScript
55
56
  });
56
57
  module.exports = __toCommonJS(konversi_client_exports);
57
58
 
@@ -242,7 +243,10 @@ function updateCustomObject(schemaName, id, newData) {
242
243
  const response = yield axiosAPI_default.request({
243
244
  method: "put",
244
245
  url: `custom-entity/${schemaName}/${id}`,
245
- data: newData
246
+ headers: {
247
+ "Content-Type": "application/json"
248
+ },
249
+ data: JSON.stringify(newData)
246
250
  });
247
251
  return response.data;
248
252
  });
@@ -299,6 +303,16 @@ function deleteObject(entity, id) {
299
303
  return response.data;
300
304
  });
301
305
  }
306
+ function runScript(scriptNameOrId, input, sync = false) {
307
+ return __async(this, null, function* () {
308
+ if (sync) {
309
+ const response2 = yield axiosAPI_default.post(`/automation/script/${scriptNameOrId}/run?mode=sync`, { input });
310
+ return response2.data;
311
+ }
312
+ const response = yield axiosAPI_default.post(`/automation/script/${scriptNameOrId}/run`, { input });
313
+ return response.data;
314
+ });
315
+ }
302
316
  var _a;
303
317
  var konversiAPI = {
304
318
  setToken: setAuthToken,
@@ -314,6 +328,7 @@ var konversiAPI = {
314
328
  updateObject,
315
329
  createObject,
316
330
  deleteObject,
331
+ runScript,
317
332
  baseUrl: axiosAPI_default.defaults.baseURL,
318
333
  token: ((_a = axiosAPI_default.defaults.headers.common["Authorization"]) == null ? void 0 : _a.toString().split(" ")[1]) || "",
319
334
  companyId: axiosAPI_default.defaults.headers.common["Company"]
@@ -322,5 +337,6 @@ var konversi_client_default = konversiAPI;
322
337
  var Entity = crudEndpoints_exports;
323
338
  // Annotate the CommonJS export names for ESM import in node:
324
339
  0 && (module.exports = {
325
- Entity
340
+ Entity,
341
+ runScript
326
342
  });
package/dist/index.mjs CHANGED
@@ -211,7 +211,10 @@ function updateCustomObject(schemaName, id, newData) {
211
211
  const response = yield axiosAPI_default.request({
212
212
  method: "put",
213
213
  url: `custom-entity/${schemaName}/${id}`,
214
- data: newData
214
+ headers: {
215
+ "Content-Type": "application/json"
216
+ },
217
+ data: JSON.stringify(newData)
215
218
  });
216
219
  return response.data;
217
220
  });
@@ -268,6 +271,16 @@ function deleteObject(entity, id) {
268
271
  return response.data;
269
272
  });
270
273
  }
274
+ function runScript(scriptNameOrId, input, sync = false) {
275
+ return __async(this, null, function* () {
276
+ if (sync) {
277
+ const response2 = yield axiosAPI_default.post(`/automation/script/${scriptNameOrId}/run?mode=sync`, { input });
278
+ return response2.data;
279
+ }
280
+ const response = yield axiosAPI_default.post(`/automation/script/${scriptNameOrId}/run`, { input });
281
+ return response.data;
282
+ });
283
+ }
271
284
  var _a;
272
285
  var konversiAPI = {
273
286
  setToken: setAuthToken,
@@ -283,6 +296,7 @@ var konversiAPI = {
283
296
  updateObject,
284
297
  createObject,
285
298
  deleteObject,
299
+ runScript,
286
300
  baseUrl: axiosAPI_default.defaults.baseURL,
287
301
  token: ((_a = axiosAPI_default.defaults.headers.common["Authorization"]) == null ? void 0 : _a.toString().split(" ")[1]) || "",
288
302
  companyId: axiosAPI_default.defaults.headers.common["Company"]
@@ -291,5 +305,6 @@ var konversi_client_default = konversiAPI;
291
305
  var Entity = crudEndpoints_exports;
292
306
  export {
293
307
  Entity,
294
- konversi_client_default as default
308
+ konversi_client_default as default,
309
+ runScript
295
310
  };
package/index.ts CHANGED
@@ -23,7 +23,10 @@ async function updateCustomObject(schemaName: string, id: string, newData: any)
23
23
  const response = await axiosAPI.request({
24
24
  method: 'put',
25
25
  url: `custom-entity/${schemaName}/${id}`,
26
- data: newData
26
+ headers: {
27
+ 'Content-Type': 'application/json'
28
+ },
29
+ data: JSON.stringify(newData)
27
30
  })
28
31
  return response.data;
29
32
  }
@@ -78,6 +81,17 @@ async function deleteObject(entity: any, id: string) {
78
81
  return response.data;
79
82
  }
80
83
 
84
+
85
+ export async function runScript(scriptNameOrId: string, input: any, sync= false) {
86
+ if (sync) {
87
+ const response = await axiosAPI.post(`/automation/script/${scriptNameOrId}/run?mode=sync`, {input})
88
+ return response.data;
89
+ }
90
+ const response = await axiosAPI.post(`/automation/script/${scriptNameOrId}/run`, {input})
91
+
92
+ return response.data;
93
+ }
94
+
81
95
  const konversiAPI = {
82
96
  setToken: setAuthToken,
83
97
  setCompanyId,
@@ -95,6 +109,8 @@ const konversiAPI = {
95
109
  createObject,
96
110
  deleteObject,
97
111
 
112
+ runScript,
113
+
98
114
  baseUrl: axiosAPI.defaults.baseURL,
99
115
  token: axiosAPI.defaults.headers.common['Authorization']?.toString().split(' ')[1] || '',
100
116
  companyId: axiosAPI.defaults.headers.common['Company'],
package/package.json CHANGED
@@ -1,24 +1,24 @@
1
- {
2
- "name": "@konversi/konversi-client",
3
- "version": "1.2.4",
4
- "main": "dist/index.js",
5
- "module": "dist/index.mjs",
6
- "types": "dist/index.d.ts",
7
- "keywords": [],
8
- "author": "",
9
- "license": "ISC",
10
- "dependencies": {
11
- "axios": "^1.6.8",
12
- "ts-node": "^10.9.2"
13
- },
14
- "description": "",
15
- "devDependencies": {
16
- "tsup": "^8.2.4",
17
- "typescript": "^5.4.5"
18
- },
19
- "scripts": {
20
- "test": "echo \"Error: no test specified\" && exit 1",
21
- "build": "tsup index.ts --format cjs,esm --dts",
22
- "lint": "tsc"
23
- }
24
- }
1
+ {
2
+ "name": "@konversi/konversi-client",
3
+ "version": "1.3.0",
4
+ "main": "dist/index.js",
5
+ "module": "dist/index.mjs",
6
+ "types": "dist/index.d.ts",
7
+ "scripts": {
8
+ "test": "echo \"Error: no test specified\" && exit 1",
9
+ "build": "tsup index.ts --format cjs,esm --dts",
10
+ "lint": "tsc"
11
+ },
12
+ "keywords": [],
13
+ "author": "",
14
+ "license": "ISC",
15
+ "dependencies": {
16
+ "axios": "^1.6.8",
17
+ "ts-node": "^10.9.2"
18
+ },
19
+ "description": "",
20
+ "devDependencies": {
21
+ "tsup": "^8.2.4",
22
+ "typescript": "^5.4.5"
23
+ }
24
+ }