@ptkl/sdk 0.10.2 → 1.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (132) hide show
  1. package/dist/{index.iife.js → index.0.10.js} +417 -230
  2. package/dist/index.0.9.js +2849 -0
  3. package/dist/package.json +12 -7
  4. package/dist/v0.10/api/component.d.ts +136 -0
  5. package/dist/v0.10/api/componentUtils.d.ts +16 -0
  6. package/dist/v0.10/api/index.d.ts +22 -0
  7. package/dist/{types → v0.10}/api/integrationsBaseClient.d.ts +3 -0
  8. package/dist/{types → v0.10}/api/platform.d.ts +2 -2
  9. package/dist/v0.10/apiUser.d.ts +9 -0
  10. package/dist/v0.10/apps.d.ts +8 -0
  11. package/dist/v0.10/baseClient.d.ts +6 -0
  12. package/dist/{types/api → v0.10}/component.d.ts +39 -4
  13. package/dist/v0.10/componentUtils.d.ts +7 -0
  14. package/dist/v0.10/config.d.ts +14 -0
  15. package/dist/v0.10/forge.d.ts +7 -0
  16. package/dist/v0.10/functions.d.ts +23 -0
  17. package/dist/{index.cjs.js → v0.10/index.cjs.js} +417 -230
  18. package/dist/v0.10/index.d.ts +21 -0
  19. package/dist/{index.esm.js → v0.10/index.esm.js} +416 -227
  20. package/dist/v0.10/integrations/dms.d.ts +469 -0
  21. package/dist/v0.10/integrations/invoicing.d.ts +6 -0
  22. package/dist/v0.10/integrations/minimax.d.ts +289 -0
  23. package/dist/v0.10/integrations/payments.d.ts +40 -0
  24. package/dist/v0.10/integrations/serbiaUtil.d.ts +10 -0
  25. package/dist/v0.10/integrations/vpfr.d.ts +4 -0
  26. package/dist/v0.10/integrations.d.ts +22 -0
  27. package/dist/v0.10/integrationsBaseClient.d.ts +11 -0
  28. package/dist/v0.10/platform.d.ts +34 -0
  29. package/dist/v0.10/platformBaseClient.d.ts +27 -0
  30. package/dist/v0.10/project.d.ts +146 -0
  31. package/dist/v0.10/ratchet.d.ts +196 -0
  32. package/dist/v0.10/sandbox.d.ts +14 -0
  33. package/dist/v0.10/system.d.ts +4 -0
  34. package/dist/v0.10/thunder.d.ts +13 -0
  35. package/dist/v0.10/types/component.d.ts +298 -0
  36. package/dist/v0.10/users.d.ts +69 -0
  37. package/dist/v0.10/workflow.d.ts +5 -0
  38. package/dist/v0.9/api/apiUser.d.ts +9 -0
  39. package/dist/v0.9/api/apps.d.ts +8 -0
  40. package/dist/v0.9/api/baseClient.d.ts +6 -0
  41. package/dist/v0.9/api/component.d.ts +136 -0
  42. package/dist/v0.9/api/config.d.ts +14 -0
  43. package/dist/v0.9/api/forge.d.ts +7 -0
  44. package/dist/v0.9/api/functions.d.ts +23 -0
  45. package/dist/v0.9/api/index.d.ts +24 -0
  46. package/dist/v0.9/api/integrations/dms.d.ts +419 -0
  47. package/dist/v0.9/api/integrations/invoicing.d.ts +6 -0
  48. package/dist/v0.9/api/integrations/minimax.d.ts +289 -0
  49. package/dist/v0.9/api/integrations/payments.d.ts +40 -0
  50. package/dist/v0.9/api/integrations/serbiaUtil.d.ts +10 -0
  51. package/dist/v0.9/api/integrations/vpfr.d.ts +4 -0
  52. package/dist/v0.9/api/integrations.d.ts +22 -0
  53. package/dist/v0.9/api/integrationsBaseClient.d.ts +11 -0
  54. package/dist/v0.9/api/platform.d.ts +34 -0
  55. package/dist/v0.9/api/platformBaseClient.d.ts +27 -0
  56. package/dist/v0.9/api/project.d.ts +146 -0
  57. package/dist/v0.9/api/ratchet.d.ts +196 -0
  58. package/dist/v0.9/api/sandbox.d.ts +14 -0
  59. package/dist/v0.9/api/system.d.ts +4 -0
  60. package/dist/v0.9/api/thunder.d.ts +13 -0
  61. package/dist/v0.9/api/users.d.ts +69 -0
  62. package/dist/v0.9/api/workflow.d.ts +5 -0
  63. package/dist/v0.9/apiUser.d.ts +9 -0
  64. package/dist/v0.9/apps.d.ts +8 -0
  65. package/dist/v0.9/baseClient.d.ts +6 -0
  66. package/dist/v0.9/component.d.ts +128 -0
  67. package/dist/v0.9/componentUtils.d.ts +7 -0
  68. package/dist/v0.9/config.d.ts +14 -0
  69. package/dist/v0.9/forge.d.ts +7 -0
  70. package/dist/v0.9/functions.d.ts +23 -0
  71. package/dist/v0.9/index.cjs.js +21811 -0
  72. package/dist/v0.9/index.d.ts +21 -0
  73. package/dist/v0.9/index.esm.js +2820 -0
  74. package/dist/v0.9/integrations/dms.d.ts +469 -0
  75. package/dist/v0.9/integrations/invoicing.d.ts +6 -0
  76. package/dist/v0.9/integrations/minimax.d.ts +289 -0
  77. package/dist/v0.9/integrations/payments.d.ts +40 -0
  78. package/dist/v0.9/integrations/serbiaUtil.d.ts +10 -0
  79. package/dist/v0.9/integrations/vpfr.d.ts +4 -0
  80. package/dist/v0.9/integrations.d.ts +22 -0
  81. package/dist/v0.9/integrationsBaseClient.d.ts +11 -0
  82. package/dist/v0.9/platform.d.ts +34 -0
  83. package/dist/v0.9/platformBaseClient.d.ts +27 -0
  84. package/dist/v0.9/project.d.ts +146 -0
  85. package/dist/v0.9/ratchet.d.ts +196 -0
  86. package/dist/v0.9/sandbox.d.ts +14 -0
  87. package/dist/v0.9/system.d.ts +4 -0
  88. package/dist/v0.9/thunder.d.ts +13 -0
  89. package/dist/{types → v0.9}/types/component.d.ts +34 -2
  90. package/dist/v0.9/types/config.d.ts +11 -0
  91. package/dist/v0.9/types/integrations.d.ts +321 -0
  92. package/dist/v0.9/types/project.d.ts +64 -0
  93. package/dist/v0.9/types/ratchet.d.ts +38 -0
  94. package/dist/v0.9/types/users.d.ts +66 -0
  95. package/dist/v0.9/users.d.ts +69 -0
  96. package/dist/v0.9/util/detectEnv.d.ts +4 -0
  97. package/dist/v0.9/workflow.d.ts +5 -0
  98. package/package.json +12 -7
  99. package/dist/monaco.d.ts +0 -887
  100. package/dist/types/api/index.d.ts +0 -13
  101. package/dist/types/api/integrations/media.d.ts +0 -17
  102. package/dist/types/api/roles.d.ts +0 -9
  103. package/dist/types/index.d.ts +0 -29
  104. package/dist/types/types/media.d.ts +0 -103
  105. /package/dist/{types → v0.10}/api/apiUser.d.ts +0 -0
  106. /package/dist/{types → v0.10}/api/apps.d.ts +0 -0
  107. /package/dist/{types → v0.10}/api/baseClient.d.ts +0 -0
  108. /package/dist/{types → v0.10}/api/config.d.ts +0 -0
  109. /package/dist/{types → v0.10}/api/forge.d.ts +0 -0
  110. /package/dist/{types → v0.10}/api/functions.d.ts +0 -0
  111. /package/dist/{types → v0.10}/api/integrations/dms.d.ts +0 -0
  112. /package/dist/{types → v0.10}/api/integrations/invoicing.d.ts +0 -0
  113. /package/dist/{types → v0.10}/api/integrations/minimax.d.ts +0 -0
  114. /package/dist/{types → v0.10}/api/integrations/payments.d.ts +0 -0
  115. /package/dist/{types → v0.10}/api/integrations/serbiaUtil.d.ts +0 -0
  116. /package/dist/{types → v0.10}/api/integrations/vpfr.d.ts +0 -0
  117. /package/dist/{types → v0.10}/api/integrations.d.ts +0 -0
  118. /package/dist/{types → v0.10}/api/platformBaseClient.d.ts +0 -0
  119. /package/dist/{types → v0.10}/api/project.d.ts +0 -0
  120. /package/dist/{types → v0.10}/api/ratchet.d.ts +0 -0
  121. /package/dist/{types → v0.10}/api/sandbox.d.ts +0 -0
  122. /package/dist/{types → v0.10}/api/system.d.ts +0 -0
  123. /package/dist/{types → v0.10}/api/thunder.d.ts +0 -0
  124. /package/dist/{types → v0.10}/api/users.d.ts +0 -0
  125. /package/dist/{types → v0.10}/api/workflow.d.ts +0 -0
  126. /package/dist/{types → v0.10}/types/config.d.ts +0 -0
  127. /package/dist/{types → v0.10}/types/integrations.d.ts +0 -0
  128. /package/dist/{types → v0.10}/types/project.d.ts +0 -0
  129. /package/dist/{types → v0.10}/types/ratchet.d.ts +0 -0
  130. /package/dist/{types → v0.10}/types/users.d.ts +0 -0
  131. /package/dist/{types → v0.10}/util/detectEnv.d.ts +0 -0
  132. /package/dist/{types → v0.9}/api/componentUtils.d.ts +0 -0
@@ -0,0 +1,2849 @@
1
+ var ProtokolSDK09 = (function (exports, axios) {
2
+ 'use strict';
3
+
4
+ class BaseClient {
5
+ constructor(client) {
6
+ this.client = client;
7
+ }
8
+ setClient(client) {
9
+ this.client = client;
10
+ return this;
11
+ }
12
+ }
13
+
14
+ const isNode = typeof process !== "undefined" &&
15
+ process.versions != null &&
16
+ process.versions.node != null;
17
+ const isBrowser = typeof window !== "undefined" &&
18
+ typeof document !== "undefined";
19
+ const isSandbox = typeof window !== "undefined";
20
+
21
+ /**
22
+ * Base client for the platform API
23
+ * Classes that extend PlatformBaseClient have intentins of only working in platform context
24
+ *
25
+ *
26
+ * @class PlatformBaseClient
27
+ * @extends BaseClient
28
+ * @constructor
29
+ * @param {AxiosInstance} [client] - The axios instance to use for the client
30
+ *
31
+ * @example
32
+ * // if sdk is used in the forge app that is running in the platform context
33
+ * const utils = new ComponentUtils()
34
+ * // this won't work outside of platform context because client needs authtorization to communicate with the API.
35
+ *
36
+ */
37
+ class PlatformBaseClient extends BaseClient {
38
+ constructor(options) {
39
+ var _a, _b, _c, _d, _e, _f, _g;
40
+ let { env = null, token = null, host = null, } = options !== null && options !== void 0 ? options : {};
41
+ let headers = {};
42
+ var project_uuid = null;
43
+ if (isBrowser) {
44
+ if (sessionStorage.getItem('protokol_context') == "forge") {
45
+ headers['X-Project-Env'] = (_a = sessionStorage.getItem('forge_app_env')) !== null && _a !== void 0 ? _a : "dev";
46
+ }
47
+ else {
48
+ headers['X-Project-Env'] = (_b = localStorage.getItem('current_env')) !== null && _b !== void 0 ? _b : "dev";
49
+ }
50
+ }
51
+ else if (isNode) {
52
+ host = (_c = host !== null && host !== void 0 ? host : process.env.API_HOST) !== null && _c !== void 0 ? _c : null;
53
+ env = (_d = env !== null && env !== void 0 ? env : process.env.PROJECT_ENV) !== null && _d !== void 0 ? _d : null;
54
+ token = (_e = token !== null && token !== void 0 ? token : process.env.PROJECT_API_TOKEN) !== null && _e !== void 0 ? _e : null;
55
+ project_uuid = (_f = process.env.PROJECT_UUID) !== null && _f !== void 0 ? _f : null;
56
+ }
57
+ else if (isSandbox) {
58
+ // @ts-ignore
59
+ const __global_env__ = window === null || window === void 0 ? void 0 : window.__ENV_VARIABLES__;
60
+ host = (_g = __global_env__ === null || __global_env__ === void 0 ? void 0 : __global_env__.API_HOST) !== null && _g !== void 0 ? _g : host;
61
+ // @ts-ignore
62
+ env = env !== null && env !== void 0 ? env : __global_env__ === null || __global_env__ === void 0 ? void 0 : __global_env__.PROJECT_ENV;
63
+ token = token !== null && token !== void 0 ? token : __global_env__ === null || __global_env__ === void 0 ? void 0 : __global_env__.PROJECT_API_TOKEN;
64
+ project_uuid = __global_env__ === null || __global_env__ === void 0 ? void 0 : __global_env__.PROJECT_UUID;
65
+ }
66
+ if (token) {
67
+ headers['Authorization'] = `Bearer ${token}`;
68
+ }
69
+ if (env) {
70
+ headers['X-Project-Env'] = env;
71
+ }
72
+ if (project_uuid) {
73
+ headers['X-Project-Uuid'] = project_uuid;
74
+ }
75
+ const client = axios.create({
76
+ baseURL: host !== null && host !== void 0 ? host : "https://lemon.protokol.io",
77
+ timeout: 30000,
78
+ headers: {
79
+ ...headers,
80
+ 'Content-Type': 'application/json',
81
+ },
82
+ withCredentials: true,
83
+ });
84
+ super(client);
85
+ this.env = null;
86
+ this.token = null;
87
+ this.host = null;
88
+ }
89
+ }
90
+
91
+ class Component extends PlatformBaseClient {
92
+ constructor(ref = null, options) {
93
+ var _a;
94
+ super();
95
+ this.ref = ref;
96
+ this.version = (_a = options === null || options === void 0 ? void 0 : options.version) !== null && _a !== void 0 ? _a : null;
97
+ }
98
+ /**
99
+ * Get the base path for component API calls
100
+ * @private
101
+ */
102
+ getComponentPath() {
103
+ if (this.version) {
104
+ return `/v3/system/component/${this.ref}/v/${this.version}`;
105
+ }
106
+ return `/v3/system/component/${this.ref}`;
107
+ }
108
+ /**
109
+ * Find method to search for models
110
+ *
111
+ * @param {FindParams} filters - The filters to apply to the search
112
+ * @param {FindOptions} opts - The options to apply to the search
113
+ *
114
+ * @returns {Promise<FindResponse>} - The result of the search
115
+ *
116
+ * @example
117
+ * platform.component(name).find({
118
+ * currentPage: 1,
119
+ * perPage: 10,
120
+ * })
121
+ *
122
+ * // advanced search
123
+ * platform.component(name).find({
124
+ * $adv: {
125
+ * name: "John Doe",
126
+ * }
127
+ * )
128
+ **/
129
+ async find(filters, opts) {
130
+ const { cache = false, buildttl = -1, locale = "en_US", } = opts !== null && opts !== void 0 ? opts : {};
131
+ let payload = {
132
+ context: filters,
133
+ ref: this.ref,
134
+ };
135
+ let ctx = payload.context;
136
+ let offset = ctx.currentPage;
137
+ if (offset == undefined) {
138
+ offset = 0;
139
+ }
140
+ let limit = ctx.perPage;
141
+ if (limit == undefined || limit == -1) {
142
+ limit = 10;
143
+ }
144
+ let sortDesc = 1;
145
+ if (ctx.sortDesc) {
146
+ sortDesc = -1;
147
+ }
148
+ if (ctx.filterOn === undefined) {
149
+ ctx.filterOn = [];
150
+ }
151
+ let params = {
152
+ offset: offset,
153
+ sortBy: ctx.sortBy,
154
+ sortDesc: sortDesc,
155
+ filter: ctx.filter,
156
+ filterOn: ctx.filterOn.join(","),
157
+ limit: limit,
158
+ dateFrom: ctx.dateFrom,
159
+ dateTo: ctx.dateTo,
160
+ dateField: ctx.dateField,
161
+ };
162
+ if (Object.keys(ctx.$adv || []).length > 0) {
163
+ params.$adv = JSON.stringify([ctx.$adv]);
164
+ }
165
+ if (ctx.$aggregate && ctx.$aggregate.length > 0) {
166
+ params.$aggregate = JSON.stringify(ctx.$aggregate);
167
+ }
168
+ if (opts) {
169
+ Object.keys(opts).forEach(k => {
170
+ if (['cache', 'buildttl', 'locale'].includes(k)) {
171
+ return;
172
+ }
173
+ params[`_opt_${k}`] = opts ? opts[k] : null;
174
+ });
175
+ }
176
+ return await this.client.get(`${this.getComponentPath()}/models`, {
177
+ params: params,
178
+ headers: {
179
+ 'X-Cache': cache,
180
+ 'X-Build-Ttl': buildttl,
181
+ 'Accept-Language': locale
182
+ }
183
+ });
184
+ }
185
+ /**
186
+ * FindOne method to search for a single model
187
+ *
188
+ * @param {FindAdvancedParams} filter - The filters to apply to the search
189
+ * @param {FindOptions} opts - The options to apply to the search
190
+ *
191
+ * @returns {Promise<?Model>} - The result of the search
192
+ *
193
+ * @example
194
+ * platform.component(name).findOne({
195
+ * name: "John Doe",
196
+ * })
197
+ **/
198
+ async findOne(filter, opts) {
199
+ const { data } = await this.find({
200
+ $adv: filter
201
+ }, opts);
202
+ const { items } = data || {};
203
+ if (items && items.length > 0) {
204
+ return items[0];
205
+ }
206
+ return null;
207
+ }
208
+ /**
209
+ * Get model by uuid
210
+ *
211
+ * @param uuid string - The uuid of the model
212
+ * @returns (Promise<Model>)
213
+ */
214
+ async get(uuid) {
215
+ return await this.client.get(`${this.getComponentPath()}/model/${uuid}`);
216
+ }
217
+ /**
218
+ * Update model by uuid
219
+ *
220
+ * @param uuid string - The uuid of the model
221
+ * @param data
222
+ * @returns
223
+ */
224
+ async update(uuid, data, options) {
225
+ return await this.client.post(`${this.getComponentPath()}/model/${uuid}`, {
226
+ data,
227
+ options,
228
+ });
229
+ }
230
+ /**
231
+ * Update many models
232
+ *
233
+ * @param data
234
+ * @param options
235
+ * @returns
236
+ */
237
+ async updateMany(data, options) {
238
+ return await this.client.patch(`${this.getComponentPath()}/models/bulk`, {
239
+ data,
240
+ options
241
+ });
242
+ }
243
+ /**
244
+ * Create many models
245
+ *
246
+ * @param data
247
+ * @param options
248
+ * @returns
249
+ */
250
+ async createMany(data, options) {
251
+ return await this.client.post(`${this.getComponentPath()}/models/bulk`, {
252
+ data,
253
+ options
254
+ });
255
+ }
256
+ /**
257
+ * Modify models by filters
258
+ *
259
+ * @param data
260
+ * @param options
261
+ * @returns
262
+ */
263
+ async modify(filters, data, options) {
264
+ return await this.client.patch(`${this.getComponentPath()}/modify/model`, {
265
+ filters,
266
+ data,
267
+ options,
268
+ });
269
+ }
270
+ /**
271
+ * Concurrent update model by uuid
272
+ *
273
+ * @param uuid string - The uuid of the model
274
+ * @param version number - The version of the model
275
+ * @param data
276
+ * @returns
277
+ */
278
+ async concurrentUpdate(uuid, version, data, options) {
279
+ return await this.client.post(`${this.getComponentPath()}/model/${uuid}`, {
280
+ version: version,
281
+ data,
282
+ options,
283
+ });
284
+ }
285
+ async create(model) {
286
+ return await this.client.post(`${this.getComponentPath()}/model`, model);
287
+ }
288
+ async delete(uuid) {
289
+ return await this.client.delete(`${this.getComponentPath()}/model/${uuid}`);
290
+ }
291
+ /**
292
+ * Execute aggregate pipeline with optional streaming support
293
+ *
294
+ * Returns a chainable object that allows both buffered and streaming modes.
295
+ * Call .onData() to enable streaming mode, or await directly for buffered mode.
296
+ *
297
+ * @param {FindAggregateParams} pipeline - MongoDB aggregation pipeline
298
+ *
299
+ * @returns {AggregateChainable} Chainable object with streaming methods and Promise interface
300
+ *
301
+ * @example
302
+ * ```typescript
303
+ * // Buffered response (default, up to 5K documents)
304
+ * const result = await component.aggregate([{ $match: { status: 'active' } }]);
305
+ * console.log(result.data); // All results at once
306
+ *
307
+ * // Streaming response (up to 25K documents)
308
+ * await component.aggregate([{ $match: { status: 'active' } }])
309
+ * .onData((doc) => console.log('Received:', doc))
310
+ * .onError((err) => console.error('Error:', err))
311
+ * .onEnd(() => console.log('Stream complete'));
312
+ * ```
313
+ */
314
+ aggregate(pipeline) {
315
+ let onDataCallback = () => { };
316
+ let onErrorCallback;
317
+ let onEndCallback;
318
+ let isStreaming = false;
319
+ let streamPromise = null;
320
+ const chainable = {
321
+ onData: (callback) => {
322
+ onDataCallback = callback;
323
+ isStreaming = true;
324
+ return chainable;
325
+ },
326
+ onError: (callback) => {
327
+ onErrorCallback = callback;
328
+ return chainable;
329
+ },
330
+ onEnd: (callback) => {
331
+ onEndCallback = callback;
332
+ return chainable;
333
+ },
334
+ then: (resolve, reject) => {
335
+ if (isStreaming) {
336
+ if (!streamPromise) {
337
+ const handler = {
338
+ onData: onDataCallback,
339
+ onError: onErrorCallback,
340
+ onEnd: onEndCallback
341
+ };
342
+ streamPromise = this._streamNDJSON(`${this.getComponentPath()}/aggregate`, {
343
+ 'Accept': 'application/x-ndjson',
344
+ 'Content-Type': 'application/json'
345
+ }, handler, pipeline);
346
+ }
347
+ return streamPromise.then(resolve, reject);
348
+ }
349
+ return this.client.post(`${this.getComponentPath()}/aggregate`, pipeline)
350
+ .then(resolve, reject);
351
+ },
352
+ catch: (reject) => {
353
+ return chainable.then(undefined, reject);
354
+ }
355
+ };
356
+ return chainable;
357
+ }
358
+ async settings() {
359
+ return await this.client.get(`/v3/system/component/settings/${this.ref}`);
360
+ }
361
+ async saveSettings(settings, version) {
362
+ return await this.client.post(`/v3/system/component/settings/${this.ref}/${version}`, settings);
363
+ }
364
+ async saveTemplatesDist(version, sdkVersion, engine, dist) {
365
+ return await this.client.post(`/v3/system/component/templates/${this.ref}/${version}`, {
366
+ templates_dist: {
367
+ sdk_version: sdkVersion,
368
+ sdk_engine: engine,
369
+ dist,
370
+ }
371
+ });
372
+ }
373
+ async workflow(event, input) {
374
+ return await this.client.post(`${this.getComponentPath()}/workflow/event`, {
375
+ event,
376
+ input
377
+ });
378
+ }
379
+ async function(name, input) {
380
+ return await this.client.post(`${this.getComponentPath()}/function/${name}`, {
381
+ data: input
382
+ });
383
+ }
384
+ async revisions(uuid) {
385
+ return await this.client.get(`${this.getComponentPath()}/model/${uuid}/revisions`);
386
+ }
387
+ /**
388
+ * Internal method to handle NDJSON streaming responses
389
+ *
390
+ * @private
391
+ */
392
+ async _streamNDJSON(url, headers, handler, body) {
393
+ try {
394
+ const config = {
395
+ headers,
396
+ responseType: 'stream'
397
+ };
398
+ const response = await this.client.post(url, body, config);
399
+ const stream = response.data;
400
+ let buffer = '';
401
+ return new Promise((resolve, reject) => {
402
+ stream.on('data', (chunk) => {
403
+ buffer += chunk.toString();
404
+ // Process complete lines (separated by newlines)
405
+ const lines = buffer.split('\n');
406
+ buffer = lines.pop() || ''; // Keep incomplete line in buffer
407
+ for (const line of lines) {
408
+ if (line.trim()) {
409
+ try {
410
+ const document = JSON.parse(line);
411
+ const result = handler.onData(document);
412
+ // Support async callbacks
413
+ if (result instanceof Promise) {
414
+ result.catch((err) => {
415
+ if (handler.onError) {
416
+ handler.onError(err);
417
+ }
418
+ });
419
+ }
420
+ }
421
+ catch (err) {
422
+ if (handler.onError) {
423
+ handler.onError(err);
424
+ }
425
+ }
426
+ }
427
+ }
428
+ });
429
+ stream.on('end', () => {
430
+ // Process any remaining data in buffer
431
+ if (buffer.trim()) {
432
+ try {
433
+ const document = JSON.parse(buffer);
434
+ handler.onData(document);
435
+ }
436
+ catch (err) {
437
+ if (handler.onError) {
438
+ handler.onError(err);
439
+ }
440
+ }
441
+ }
442
+ if (handler.onEnd) {
443
+ handler.onEnd();
444
+ }
445
+ resolve();
446
+ });
447
+ stream.on('error', (err) => {
448
+ if (handler.onError) {
449
+ handler.onError(err);
450
+ }
451
+ reject(err);
452
+ });
453
+ });
454
+ }
455
+ catch (err) {
456
+ if (handler.onError) {
457
+ handler.onError(err);
458
+ }
459
+ throw err;
460
+ }
461
+ }
462
+ }
463
+
464
+ class Functions extends PlatformBaseClient {
465
+ async list() {
466
+ return await this.client.get("/v1/system/function");
467
+ }
468
+ async get(ref) {
469
+ return await this.client.get(`/v1/system/function/${ref}`);
470
+ }
471
+ async update(uuid, update) {
472
+ return await this.client.patch(`/v1/system/function/${uuid}`, update);
473
+ }
474
+ /**
475
+ * Run platform function
476
+ *
477
+ * @param id - Function ID
478
+ * @param input - Input data
479
+ * @param query - Query parameters
480
+ * @returns - Function result
481
+ *
482
+ * @example
483
+ * const result = await platform.function().run("myFunction", {input: { foo: "bar" }})
484
+ */
485
+ async run(id, d) {
486
+ const { data } = await this.client.post(`/v1/system/function/run/${id}`, d.input, {
487
+ params: d.query,
488
+ headers: d.headers
489
+ });
490
+ return data;
491
+ }
492
+ async generateSignature(ref, env) {
493
+ return await this.client.get(`/v1/system/function/signature/${env}/${ref}`);
494
+ }
495
+ }
496
+
497
+ class APIUser extends PlatformBaseClient {
498
+ async auth(username, password, project) {
499
+ return this.client.post("/v1/user/api/auth", {
500
+ username,
501
+ password
502
+ }, {
503
+ headers: {
504
+ "X-Project-Uuid": project
505
+ }
506
+ });
507
+ }
508
+ async newSecret(uuid) {
509
+ return await this.client.post(`/v1/user/api-user/secret/${uuid}`, {});
510
+ }
511
+ async revokeSecret(uuid) {
512
+ return await this.client.delete(`/v1/user/api-user/secret/${uuid}`);
513
+ }
514
+ async edit(uuid, roles) {
515
+ return await this.client.patch(`/v1/user/api-user/${uuid}`, { roles });
516
+ }
517
+ async list() {
518
+ return await this.client.get(`/v1/user/api-user`);
519
+ }
520
+ async get(uuid) {
521
+ return await this.client.get(`/v1/user/api-user/${uuid}`);
522
+ }
523
+ }
524
+
525
+ class Users extends PlatformBaseClient {
526
+ async auth(username, password, project) {
527
+ return await this.client.post("/v1/user/login", {
528
+ username,
529
+ password,
530
+ response_type: 'token',
531
+ }, {
532
+ headers: {
533
+ 'X-Project-Uuid': project
534
+ }
535
+ });
536
+ }
537
+ /**
538
+ * Resend confirmation email
539
+ * @param email User email
540
+ */
541
+ async resendConfirmationEmail(email) {
542
+ return await this.client.post("/v1/user/send/confirmation/email", {
543
+ email,
544
+ });
545
+ }
546
+ // Password Reset (Request Only)
547
+ // Note: Only the REQUEST is exposed, not the password reset completion
548
+ // The actual password reset should be done through the official web interface
549
+ /**
550
+ * Request password reset email
551
+ * This only sends an email with a reset link, does not expose or change passwords
552
+ * @param email User email
553
+ */
554
+ async requestPasswordReset(email) {
555
+ return await this.client.post("/v1/user/resetpassword", { email });
556
+ }
557
+ // User Profile & Management
558
+ /**
559
+ * Get current user's model
560
+ */
561
+ async getUser() {
562
+ return await this.client.get("/v1/user/model");
563
+ }
564
+ /**
565
+ * Get current user's claims
566
+ */
567
+ async getClaims() {
568
+ return await this.client.get("/v1/user/claims");
569
+ }
570
+ /**
571
+ * Edit user profile
572
+ * @param data Profile update data
573
+ */
574
+ async editProfile(data) {
575
+ return await this.client.post("/v1/user/profile/edit", data);
576
+ }
577
+ // Permissions & Roles
578
+ /**
579
+ * Get user permissions
580
+ */
581
+ async getPermissions() {
582
+ return await this.client.get("/v1/user/role/permissions");
583
+ }
584
+ /**
585
+ * Get list of available permissions
586
+ */
587
+ async listPermissions() {
588
+ return await this.client.get("/v1/user/permissions/list");
589
+ }
590
+ /**
591
+ * Create a new role
592
+ * @param role Role data including name, permissions, workspaces, and level
593
+ */
594
+ async createRole(role) {
595
+ return await this.client.post("/v1/user/role/create", role);
596
+ }
597
+ /**
598
+ * Delete a role
599
+ * @param uuid Role UUID
600
+ */
601
+ async deleteRole(uuid) {
602
+ return await this.client.delete(`/v1/user/role/delete/${uuid}`);
603
+ }
604
+ /**
605
+ * List all roles
606
+ */
607
+ async listRoles() {
608
+ return await this.client.get(`/v1/user/role/list`);
609
+ }
610
+ /**
611
+ * Get role details by UUID
612
+ * @param uuid Role UUID
613
+ */
614
+ async getRoleModel(uuid) {
615
+ return await this.client.get(`/v1/user/role/edit/${uuid}`);
616
+ }
617
+ /**
618
+ * Edit a role
619
+ * @param uuid Role UUID
620
+ * @param data Role update data including permissions, workspaces, and level
621
+ */
622
+ async editRole(uuid, data) {
623
+ return await this.client.post(`/v1/user/role/edit/${uuid}`, data);
624
+ }
625
+ /**
626
+ * @deprecated Use getPermissions() instead
627
+ */
628
+ async permissions() {
629
+ return await this.client.get(`/v1/user/role/permissions`);
630
+ }
631
+ }
632
+
633
+ class Apps extends PlatformBaseClient {
634
+ constructor(appType) {
635
+ super();
636
+ this.appType = appType;
637
+ }
638
+ async updateSettings(updateValues, ref) {
639
+ const payload = { ...updateValues };
640
+ return await this.client.put(`/v3/system/gateway/app-service/${this.appType}/${ref}/settings`, payload);
641
+ }
642
+ async download(ref, version) {
643
+ return await this.client.post(`/v3/system/gateway/app-service/${this.appType}/download`, { version, uuid: ref }, { responseType: "arraybuffer" });
644
+ }
645
+ async upload(formData) {
646
+ return await this.client.post(`/v3/system/gateway/app-service/${this.appType}/upload`, formData, {
647
+ timeout: 60000
648
+ });
649
+ }
650
+ }
651
+
652
+ class ComponentUtils extends PlatformBaseClient {
653
+ async list() {
654
+ return await this.client.get("/v1/system/components");
655
+ }
656
+ async create(data) {
657
+ return await this.client.post("/v3/system/component/create", data);
658
+ }
659
+ }
660
+
661
+ class Thunder extends PlatformBaseClient {
662
+ async read(type, filters, flag, options) {
663
+ return await this.client.post("/v3/system/thunder", {
664
+ type,
665
+ filters,
666
+ flag,
667
+ options,
668
+ });
669
+ }
670
+ async write(type, filters, d, flag) {
671
+ return await this.client.put("/v3/system/thunder", {
672
+ type,
673
+ filters,
674
+ flag,
675
+ data: d,
676
+ });
677
+ }
678
+ async operation(name, filters, data) {
679
+ return await this.write(name, filters, data, "Operation");
680
+ }
681
+ async find(name, filters) {
682
+ return await this.read(name, filters, "Find");
683
+ }
684
+ async findOne(name, filters) {
685
+ return await this.read(name, filters, "FindOne");
686
+ }
687
+ async paginate(name, filters, options) {
688
+ return await this.read(name, filters, "Paginate", options);
689
+ }
690
+ async upsert(name, filters, data) {
691
+ return await this.write(name, filters, data, "Upsert");
692
+ }
693
+ async insertOne(name, data) {
694
+ return await this.write(name, {}, data, "InsertOne");
695
+ }
696
+ async updateOne(name, filters, data) {
697
+ return await this.write(name, filters, data, "UpdateOne");
698
+ }
699
+ async delete(name, filters) {
700
+ return await this.write(name, filters, {}, "Delete");
701
+ }
702
+ }
703
+
704
+ class Ratchet extends PlatformBaseClient {
705
+ /**
706
+ * Get all database connections for the current project
707
+ *
708
+ * @returns List of all configured ratchet connections
709
+ *
710
+ * @example
711
+ * ```typescript
712
+ * const ratchet = new Ratchet();
713
+ * const connections = await ratchet.getConnections();
714
+ * console.log(connections.data); // Array of connections
715
+ * ```
716
+ */
717
+ async getConnections() {
718
+ return await this.client.get("/v1/ratchet/connection");
719
+ }
720
+ /**
721
+ * Get a specific database connection by ID
722
+ *
723
+ * @param id - Connection ID
724
+ * @returns Connection details including queries
725
+ *
726
+ * @example
727
+ * ```typescript
728
+ * const ratchet = new Ratchet();
729
+ * const connection = await ratchet.getConnection('users_db');
730
+ * console.log(connection.data.queries); // Available queries for this connection
731
+ * ```
732
+ */
733
+ async getConnection(id) {
734
+ return await this.client.get(`/v1/ratchet/connection/${id}`);
735
+ }
736
+ /**
737
+ * Create a new database connection
738
+ *
739
+ * Supports multiple database types:
740
+ * - MySQL: Use credentials with host, dbname, user, password
741
+ * - PostgreSQL: Use credentials with host, dbname, user, password
742
+ * - MongoDB: Use DSN connection string
743
+ * - BigQuery: Use service_account_json and project_id
744
+ *
745
+ * @param connection - Connection configuration
746
+ * @returns Created connection details
747
+ *
748
+ * @example
749
+ * ```typescript
750
+ * const ratchet = new Ratchet();
751
+ *
752
+ * // MySQL/PostgreSQL connection
753
+ * await ratchet.createConnection({
754
+ * id: 'users_db',
755
+ * type: 'MySQL',
756
+ * credentials: {
757
+ * type: 'Credentials',
758
+ * host: 'localhost',
759
+ * dbname: 'users',
760
+ * user: 'admin',
761
+ * password: 'secret'
762
+ * }
763
+ * });
764
+ *
765
+ * // MongoDB connection
766
+ * await ratchet.createConnection({
767
+ * id: 'mongo_db',
768
+ * type: 'MongoDB',
769
+ * credentials: {
770
+ * type: 'DSN',
771
+ * dsn: 'mongodb://localhost:27017/mydb'
772
+ * }
773
+ * });
774
+ *
775
+ * // BigQuery connection
776
+ * await ratchet.createConnection({
777
+ * id: 'analytics_bq',
778
+ * type: 'BigQuery',
779
+ * credentials: {
780
+ * type: 'ServiceAccount',
781
+ * service_account_json: '{"type":"service_account",...}',
782
+ * project_id: 'my-project-id'
783
+ * }
784
+ * });
785
+ * ```
786
+ */
787
+ async createConnection(connection) {
788
+ return await this.client.post("/v1/ratchet/connection", connection);
789
+ }
790
+ /**
791
+ * Update an existing database connection
792
+ *
793
+ * @param connection - Updated connection configuration
794
+ * @returns Success status
795
+ *
796
+ * @example
797
+ * ```typescript
798
+ * const ratchet = new Ratchet();
799
+ * await ratchet.updateConnection({
800
+ * id: 'users_db',
801
+ * type: 'postgres',
802
+ * credentials: {
803
+ * type: 'postgres',
804
+ * host: 'localhost',
805
+ * dbname: 'users',
806
+ * user: 'admin',
807
+ * password: 'new_secret'
808
+ * },
809
+ * queries: [
810
+ * { id: 'get_user', expression: 'SELECT * FROM users WHERE id = $1' }
811
+ * ]
812
+ * });
813
+ * ```
814
+ */
815
+ async updateConnection(connection) {
816
+ return await this.client.put("/v1/ratchet/connection", connection);
817
+ }
818
+ /**
819
+ * Delete a database connection
820
+ *
821
+ * @param id - Connection ID to delete
822
+ * @returns Success status
823
+ *
824
+ * @example
825
+ * ```typescript
826
+ * const ratchet = new Ratchet();
827
+ * await ratchet.deleteConnection('users_db');
828
+ * ```
829
+ */
830
+ async deleteConnection(id) {
831
+ return await this.client.delete(`/v1/ratchet/connection/${id}`);
832
+ }
833
+ /**
834
+ * Test a database connection without saving it
835
+ *
836
+ * @param connection - Connection configuration to test
837
+ * @returns Success status if connection is valid
838
+ *
839
+ * @example
840
+ * ```typescript
841
+ * const ratchet = new Ratchet();
842
+ * const isValid = await ratchet.testConnection({
843
+ * id: 'test_db',
844
+ * type: 'postgres',
845
+ * credentials: {
846
+ * type: 'postgres',
847
+ * host: 'localhost',
848
+ * dbname: 'test',
849
+ * user: 'admin',
850
+ * password: 'secret'
851
+ * }
852
+ * });
853
+ * ```
854
+ */
855
+ async testConnection(connection) {
856
+ return await this.client.post("/v1/ratchet/test/connection", connection);
857
+ }
858
+ /**
859
+ * Execute a predefined database query
860
+ *
861
+ * Runs a query that has been previously configured in a ratchet connection.
862
+ * The query is identified by a qualified name in the format: `connectionId.queryId`
863
+ *
864
+ * @param name - Qualified name of the query (format: `connectionId.queryId`)
865
+ * @param params - Array of parameters to pass to the query
866
+ * @returns Query execution results
867
+ *
868
+ * @example
869
+ * ```typescript
870
+ * const ratchet = new Ratchet();
871
+ *
872
+ * // Execute a query with parameters
873
+ * const result = await ratchet.query('users_db.get_user_by_id', [123]);
874
+ *
875
+ * // Execute a query without parameters
876
+ * const allUsers = await ratchet.query('users_db.get_all_users', []);
877
+ * ```
878
+ */
879
+ async query(name, params) {
880
+ return await this.client.post("/v1/ratchet/query", {
881
+ name: name,
882
+ params: params,
883
+ });
884
+ }
885
+ /**
886
+ * Inspect and execute a custom query without saving it
887
+ *
888
+ * This allows you to test queries before saving them to a connection.
889
+ *
890
+ * @param request - Query inspection request with connection name, query, and params
891
+ * @returns Query execution results
892
+ *
893
+ * @example
894
+ * ```typescript
895
+ * const ratchet = new Ratchet();
896
+ * const result = await ratchet.inspectQuery({
897
+ * name: 'users_db.test_query',
898
+ * query: {
899
+ * id: 'test_query',
900
+ * expression: 'SELECT * FROM users WHERE email = $1'
901
+ * },
902
+ * params: ['user@example.com']
903
+ * });
904
+ * ```
905
+ */
906
+ async inspectQuery(request) {
907
+ return await this.client.post("/v1/ratchet/query/inspect", request);
908
+ }
909
+ }
910
+
911
+ class Sandbox extends PlatformBaseClient {
912
+ /**
913
+ * Call the sandbox service to execute a serverless function
914
+ *
915
+ * @param name
916
+ * @param data
917
+ * @returns
918
+ *
919
+ * @example
920
+ * const result = await platform.sandbox().spark("myFunction", { foo: "bar" })
921
+ */
922
+ async spark(name, data) {
923
+ return await this.client.post(`/v1/project/sandbox/spark/exec/${name}`, data);
924
+ }
925
+ }
926
+
927
+ class System extends PlatformBaseClient {
928
+ async resourceResolver(ref, resourceName, format) {
929
+ return await this.client.post("/v3/system/resource-resolver", {
930
+ type: resourceName,
931
+ ref,
932
+ format,
933
+ });
934
+ }
935
+ }
936
+
937
+ class Workflow extends PlatformBaseClient {
938
+ async trigger(id, event, data) {
939
+ return await this.client.post(`/v1/project/workflow/workflow/${id}/event/${event}`, data);
940
+ }
941
+ async publish(event, data) {
942
+ return await this.client.post(`/v1/project/workflow/workflow/event/${event}`, data);
943
+ }
944
+ }
945
+
946
+ class Forge extends PlatformBaseClient {
947
+ async bundleUpload(buffer) {
948
+ return await this.client.post(`/luma/appservice/v1/forge/upload`, buffer, {
949
+ headers: {
950
+ 'Content-Type': 'application/octet-stream',
951
+ 'Content-Length': buffer.length
952
+ }
953
+ });
954
+ }
955
+ async getWorkspaceApps() {
956
+ return await this.client.get(`/luma/appservice/v1/forge/workspace`);
957
+ }
958
+ async removeVersion(ref, version) {
959
+ return await this.client.delete(`/luma/appservice/v1/forge/${ref}/version/${version}`);
960
+ }
961
+ async list() {
962
+ return await this.client.get(`/luma/appservice/v1/forge`);
963
+ }
964
+ }
965
+
966
+ class Project extends PlatformBaseClient {
967
+ /**
968
+ * Get list of all projects for the current user
969
+ */
970
+ async list() {
971
+ return await this.client.get("/v1/project/list");
972
+ }
973
+ /**
974
+ * Create a new project
975
+ * @param data Project creation data
976
+ */
977
+ async create(data) {
978
+ return await this.client.post("/v1/project/create", data);
979
+ }
980
+ /**
981
+ * Get information about a specific project
982
+ */
983
+ async info() {
984
+ return await this.client.get("/v1/project/info");
985
+ }
986
+ /**
987
+ * Archive a project
988
+ */
989
+ async archive() {
990
+ return await this.client.patch("/v1/project/archive");
991
+ }
992
+ /**
993
+ * Invite a user to the project
994
+ * @param email Array of emails
995
+ * @param roles Array of role UUIDs
996
+ */
997
+ async invite(emails, roles) {
998
+ return await this.client.post("/v1/project/invite", { emails: emails.join(","), roles });
999
+ }
1000
+ /**
1001
+ * Get list of project invites
1002
+ */
1003
+ async getInvites() {
1004
+ return await this.client.get("/v1/project/invites");
1005
+ }
1006
+ /**
1007
+ * Get a specific invite by UUID
1008
+ * @param uuid Invite UUID
1009
+ */
1010
+ async getInvite(uuid) {
1011
+ return await this.client.get(`/v1/project/invite/${uuid}`);
1012
+ }
1013
+ /**
1014
+ * Accept an invite
1015
+ * @param uuid Invite UUID
1016
+ */
1017
+ async acceptInvite(uuid) {
1018
+ return await this.client.get(`/v1/project/invite/accept/${uuid}`);
1019
+ }
1020
+ /**
1021
+ * Register through an invite
1022
+ * @param uuid Invite UUID
1023
+ * @param data Registration data
1024
+ */
1025
+ async registerWithInvite(uuid, data) {
1026
+ return await this.client.post(`/v1/project/invite/register/${uuid}`, data);
1027
+ }
1028
+ /**
1029
+ * Get list of project users
1030
+ */
1031
+ async getUsers() {
1032
+ return await this.client.get("/v1/project/users");
1033
+ }
1034
+ /**
1035
+ * Get a specific project user
1036
+ * @param uuid User UUID
1037
+ */
1038
+ async getUser(uuid) {
1039
+ return await this.client.get(`/v1/project/user/${uuid}`);
1040
+ }
1041
+ /**
1042
+ * Update a project user
1043
+ * @param uuid User UUID
1044
+ * @param data Update data
1045
+ */
1046
+ async updateUser(uuid, data) {
1047
+ return await this.client.put(`/v1/project/user/${uuid}`, data);
1048
+ }
1049
+ /**
1050
+ * Delete a user from the project
1051
+ * @param uuid User UUID
1052
+ */
1053
+ async deleteUser(uuid) {
1054
+ return await this.client.delete(`/v1/project/user/${uuid}`);
1055
+ }
1056
+ /**
1057
+ * Update project settings
1058
+ * @param settings Settings data
1059
+ */
1060
+ async updateSettings(settings) {
1061
+ return await this.client.post("/v1/project/settings", settings);
1062
+ }
1063
+ // Workspace Methods
1064
+ /**
1065
+ * Create a new workspace
1066
+ * @param data Workspace data
1067
+ */
1068
+ async createWorkspace(data) {
1069
+ return await this.client.post("/v1/project/workspace", data);
1070
+ }
1071
+ /**
1072
+ * Update a workspace
1073
+ * @param uuid Workspace UUID
1074
+ * @param data Update data
1075
+ */
1076
+ async updateWorkspace(uuid, data) {
1077
+ return await this.client.put(`/v1/project/workspace/${uuid}`, data);
1078
+ }
1079
+ /**
1080
+ * Delete a workspace
1081
+ * @param uuid Workspace UUID
1082
+ */
1083
+ async deleteWorkspace(uuid) {
1084
+ return await this.client.delete(`/v1/project/workspace/${uuid}`);
1085
+ }
1086
+ // Template Methods
1087
+ /**
1088
+ * Get available templates
1089
+ */
1090
+ async getAvailableTemplates() {
1091
+ return await this.client.get("/v1/project/template/available");
1092
+ }
1093
+ /**
1094
+ * Search for templates
1095
+ * @param query Search query
1096
+ */
1097
+ async searchTemplates(query) {
1098
+ return await this.client.post("/v1/project/template/search", query);
1099
+ }
1100
+ /**
1101
+ * Get template by ID
1102
+ * @param id Template ID
1103
+ */
1104
+ async getTemplate(id) {
1105
+ return await this.client.get(`/v1/project/template/${id}`);
1106
+ }
1107
+ /**
1108
+ * Get template by activation code
1109
+ * @param code Activation code
1110
+ */
1111
+ async getTemplateByCode(code) {
1112
+ return await this.client.get(`/v1/project/template/activationCode/${code}`);
1113
+ }
1114
+ /**
1115
+ * Get templates for a workspace
1116
+ */
1117
+ async getWorkspaceTemplates() {
1118
+ return await this.client.get("/v1/project/template/workspace");
1119
+ }
1120
+ /**
1121
+ * Install a template
1122
+ * @param data Installation data
1123
+ */
1124
+ async installTemplate(data) {
1125
+ return await this.client.post("/v1/project/template/install", data);
1126
+ }
1127
+ /**
1128
+ * Uninstall a template
1129
+ * @param data Uninstallation data
1130
+ */
1131
+ async uninstallTemplate(data) {
1132
+ return await this.client.post("/v1/project/template/uninstall", data);
1133
+ }
1134
+ /**
1135
+ * Upgrade a template
1136
+ * @param data Upgrade data
1137
+ */
1138
+ async upgradeTemplate(data) {
1139
+ return await this.client.post("/v1/project/template/upgrade", data);
1140
+ }
1141
+ }
1142
+
1143
+ class Config extends PlatformBaseClient {
1144
+ /**
1145
+ * Get user configuration
1146
+ */
1147
+ async getUserConfig() {
1148
+ return await this.client.get("/v1/config/user");
1149
+ }
1150
+ /**
1151
+ * Update user configuration
1152
+ * @param config Configuration data
1153
+ */
1154
+ async updateUserConfig(config) {
1155
+ return await this.client.put("/v1/config/user", config);
1156
+ }
1157
+ }
1158
+
1159
+ // apis
1160
+ class Platform extends PlatformBaseClient {
1161
+ getPlatformClient() {
1162
+ return this.client;
1163
+ }
1164
+ getPlatformBaseURL() {
1165
+ var _a;
1166
+ return (_a = this.client.defaults.baseURL) !== null && _a !== void 0 ? _a : "";
1167
+ }
1168
+ apiUser() {
1169
+ return (new APIUser()).setClient(this.client);
1170
+ }
1171
+ function() {
1172
+ return (new Functions()).setClient(this.client);
1173
+ }
1174
+ user() {
1175
+ return (new Users()).setClient(this.client);
1176
+ }
1177
+ app(appType) {
1178
+ return (new Apps(appType)).setClient(this.client);
1179
+ }
1180
+ forge() {
1181
+ return (new Forge()).setClient(this.client);
1182
+ }
1183
+ component(ref, options) {
1184
+ return (new Component(ref, options)).setClient(this.client);
1185
+ }
1186
+ componentUtils() {
1187
+ return (new ComponentUtils()).setClient(this.client);
1188
+ }
1189
+ ratchet() {
1190
+ return (new Ratchet()).setClient(this.client);
1191
+ }
1192
+ sandbox() {
1193
+ return (new Sandbox()).setClient(this.client);
1194
+ }
1195
+ system() {
1196
+ return (new System()).setClient(this.client);
1197
+ }
1198
+ workflow() {
1199
+ return (new Workflow()).setClient(this.client);
1200
+ }
1201
+ thunder() {
1202
+ return (new Thunder()).setClient(this.client);
1203
+ }
1204
+ project() {
1205
+ return (new Project()).setClient(this.client);
1206
+ }
1207
+ config() {
1208
+ return (new Config()).setClient(this.client);
1209
+ }
1210
+ }
1211
+
1212
+ class Invoicing extends PlatformBaseClient {
1213
+ async getSalesInvoices(provider, page) {
1214
+ return await this.request("GET", `invoices/${provider}/sales`, {
1215
+ params: {
1216
+ page: page || 1
1217
+ }
1218
+ });
1219
+ }
1220
+ async acceptPurchaseInvoice(provider, id, comment) {
1221
+ return await this.request('POST', `invoices/${provider}/purchase/acceptReject/${id}`, {
1222
+ data: {
1223
+ accepted: true,
1224
+ comment: comment
1225
+ }
1226
+ });
1227
+ }
1228
+ async request(method, endpoint, params) {
1229
+ return await this.client.request({
1230
+ method: method,
1231
+ url: `/karadjordje/v1/${endpoint}`,
1232
+ ...params
1233
+ });
1234
+ }
1235
+ }
1236
+
1237
+ class IntegrationsBaseClient extends BaseClient {
1238
+ constructor(options) {
1239
+ var _a, _b, _c, _d, _e, _f, _g;
1240
+ let { env = null, token = null, host = null, } = options !== null && options !== void 0 ? options : {};
1241
+ let headers = {};
1242
+ var project_uuid = null;
1243
+ if (isBrowser) {
1244
+ if (sessionStorage.getItem('protokol_context') == "forge") {
1245
+ headers['X-Project-Env'] = (_a = sessionStorage.getItem('forge_app_env')) !== null && _a !== void 0 ? _a : "dev";
1246
+ }
1247
+ else {
1248
+ headers['X-Project-Env'] = (_b = localStorage.getItem('current_env')) !== null && _b !== void 0 ? _b : "dev";
1249
+ }
1250
+ }
1251
+ else if (isNode) {
1252
+ host = (_c = host !== null && host !== void 0 ? host : process.env.INTEGRATION_API) !== null && _c !== void 0 ? _c : null;
1253
+ env = (_d = env !== null && env !== void 0 ? env : process.env.PROJECT_ENV) !== null && _d !== void 0 ? _d : null;
1254
+ token = (_e = token !== null && token !== void 0 ? token : process.env.PROJECT_API_TOKEN) !== null && _e !== void 0 ? _e : null;
1255
+ project_uuid = (_f = process.env.PROJECT_UUID) !== null && _f !== void 0 ? _f : null;
1256
+ }
1257
+ else if (isSandbox) {
1258
+ // @ts-ignore
1259
+ const __global_env__ = window === null || window === void 0 ? void 0 : window.__ENV_VARIABLES__;
1260
+ host = (_g = __global_env__ === null || __global_env__ === void 0 ? void 0 : __global_env__.INTEGRATION_API) !== null && _g !== void 0 ? _g : host;
1261
+ // @ts-ignore
1262
+ env = env !== null && env !== void 0 ? env : __global_env__ === null || __global_env__ === void 0 ? void 0 : __global_env__.PROJECT_ENV;
1263
+ token = token !== null && token !== void 0 ? token : __global_env__ === null || __global_env__ === void 0 ? void 0 : __global_env__.PROJECT_API_TOKEN;
1264
+ }
1265
+ if (token) {
1266
+ headers['Authorization'] = `Bearer ${token}`;
1267
+ }
1268
+ if (env) {
1269
+ headers['X-Project-Env'] = env;
1270
+ }
1271
+ if (project_uuid) {
1272
+ headers['X-Project-Uuid'] = project_uuid;
1273
+ }
1274
+ const client = axios.create({
1275
+ baseURL: host !== null && host !== void 0 ? host : "https://lemon.protokol.io/luma/integrations",
1276
+ timeout: 30000,
1277
+ headers: {
1278
+ ...headers,
1279
+ },
1280
+ withCredentials: true,
1281
+ });
1282
+ super(client);
1283
+ this.env = null;
1284
+ this.token = null;
1285
+ this.host = null;
1286
+ }
1287
+ }
1288
+
1289
+ /**
1290
+ * Document Management System (DMS) API client
1291
+ *
1292
+ * Provides comprehensive document and media management capabilities including:
1293
+ * - File upload, download, and management
1294
+ * - PDF generation and form filling
1295
+ * - Data conversion between JSON, CSV, and Excel formats
1296
+ * - Media processing and EXIF data extraction
1297
+ *
1298
+ * ## Data Conversion Features
1299
+ *
1300
+ * The DMS class includes powerful data conversion capabilities that allow you to:
1301
+ * - Convert between JSON, CSV, and Excel (.xlsx) formats
1302
+ * - Handle structured data with header, items, and footer sections
1303
+ * - Auto-detect structured patterns in JSON arrays
1304
+ * - Validate data format integrity
1305
+ * - Analyze data structure and metadata
1306
+ * - Handle large datasets with memory-efficient processing
1307
+ *
1308
+ * ### Supported Formats
1309
+ * - **JSON**: Array of objects (recommended for tabular data) or structured objects
1310
+ * - **CSV**: Comma-separated values with headers and optional comments
1311
+ * - **Excel**: .xlsx format with optional sheet specification
1312
+ *
1313
+ * ### Structured Data Support
1314
+ * When converting from JSON, the API supports:
1315
+ *
1316
+ * **Explicit Structure**: JSON with dedicated sections
1317
+ * ```json
1318
+ * {
1319
+ * "header": { "content": { "title": "Report" } },
1320
+ * "items": [{ "name": "Data" }],
1321
+ * "footer": { "content": { "total": 100 } }
1322
+ * }
1323
+ * ```
1324
+ *
1325
+ * **Auto-Detection**: Mixed arrays with metadata and summary objects
1326
+ * ```json
1327
+ * [
1328
+ * { "metadata": "Header info" },
1329
+ * { "name": "John", "age": 30 },
1330
+ * { "summary": "Footer info" }
1331
+ * ]
1332
+ * ```
1333
+ *
1334
+ * ### Error Handling
1335
+ * All conversion methods may throw errors with code 3003 for conversion failures.
1336
+ * Always wrap calls in try-catch blocks for production use.
1337
+ *
1338
+ * @example
1339
+ * ```typescript
1340
+ * import { DMS } from 'protokol-sdk';
1341
+ *
1342
+ * const dms = new DMS({
1343
+ * token: 'your-bearer-token',
1344
+ * host: 'http://localhost:8086'
1345
+ * });
1346
+ *
1347
+ * const libraryRef = 'your-library-uuid';
1348
+ *
1349
+ * // Convert structured JSON to CSV with comments
1350
+ * const structuredData = {
1351
+ * header: { content: { title: "Sales Report" } },
1352
+ * items: [{ product: "Widget", sales: 100 }],
1353
+ * footer: { content: { total: 100 } }
1354
+ * };
1355
+ *
1356
+ * try {
1357
+ * const csvResult = await dms.convertData(libraryRef, structuredData, {
1358
+ * from: 'json',
1359
+ * to: 'csv',
1360
+ * header_as_comment: true
1361
+ * });
1362
+ * console.log(csvResult.data); // CSV with header as comments
1363
+ * } catch (error) {
1364
+ * console.error('Conversion failed:', error.message);
1365
+ * }
1366
+ * ```
1367
+ */
1368
+ class DMS extends IntegrationsBaseClient {
1369
+ async list(data) {
1370
+ return this.request('POST', 'media/list', { data });
1371
+ }
1372
+ async libraries() {
1373
+ return await this.requestv1("GET", "media/library/list");
1374
+ }
1375
+ async upload(payload) {
1376
+ let files = payload.files;
1377
+ let formData = new FormData();
1378
+ let count = 0;
1379
+ files.forEach((file, index) => {
1380
+ let rename = file.rename || file.name;
1381
+ let orgExt = file.name.split('.');
1382
+ rename = `${rename}.${orgExt[orgExt.length - 1]}`;
1383
+ formData.append('file', file, rename);
1384
+ count++;
1385
+ });
1386
+ if (count == files.length) {
1387
+ formData.append('path', payload.uploadDir);
1388
+ formData.append('ref', payload.uuid);
1389
+ if (payload.public) {
1390
+ formData.append('is_public', "true");
1391
+ }
1392
+ if (payload.expiresAt)
1393
+ formData.append('expiresAt', new Date(payload.expiresAt).toISOString());
1394
+ if (Object.keys(payload.metadata).length > 0)
1395
+ formData.append('metadata', JSON.stringify(payload.metadata));
1396
+ return await this.request("POST", "media/upload", {
1397
+ data: formData,
1398
+ headers: {
1399
+ 'Content-Type': 'multipart/form-data'
1400
+ }
1401
+ });
1402
+ }
1403
+ }
1404
+ async delete(data) {
1405
+ return this.request('POST', 'media/delete', data);
1406
+ }
1407
+ async uploadBase64(data) {
1408
+ return this.request('POST', `media/upload`, {
1409
+ data,
1410
+ headers: {
1411
+ 'Content-Type': 'application/json'
1412
+ }
1413
+ });
1414
+ }
1415
+ async getMedia(lib, key, encoding) {
1416
+ return this.request('GET', `media/library/${lib}/get/${key}`, {
1417
+ params: {
1418
+ encoding
1419
+ },
1420
+ responseType: (!encoding) ? 'blob' : null
1421
+ });
1422
+ }
1423
+ async download(lib, key) {
1424
+ return this.request('POST', `media/library/${lib}/download`, {
1425
+ data: {
1426
+ key
1427
+ },
1428
+ responseType: 'blob'
1429
+ });
1430
+ }
1431
+ async getExifData(lib, key) {
1432
+ return this.request('GET', `media/library/${lib}/exif/${key}`);
1433
+ }
1434
+ async html2pdf(lib, data) {
1435
+ const { output_pdf = false, input_path, input_html, output_path, output_file_name, output_type, data: templateData } = data;
1436
+ const type = output_pdf ? 'arraybuffer' : 'json';
1437
+ const contentType = output_pdf ? 'application/pdf' : 'application/json';
1438
+ return this.request('POST', `media/library/${lib}/html2pdf`, {
1439
+ data: {
1440
+ output_pdf,
1441
+ input_path,
1442
+ output_path,
1443
+ input_html,
1444
+ output_file_name,
1445
+ output_type,
1446
+ data: templateData
1447
+ },
1448
+ headers: {
1449
+ 'Content-Type': contentType
1450
+ },
1451
+ responseType: type
1452
+ });
1453
+ }
1454
+ async createDir(lib, path) {
1455
+ return this.request('POST', `media/library/${lib}/dir`, { data: { path } });
1456
+ }
1457
+ async deleteDir(lib, path) {
1458
+ return this.request('POST', `media/library/${lib}/delete/dir`, { data: { path } });
1459
+ }
1460
+ async dirs(lib, data) {
1461
+ return await this.request("POST", `media/library/${lib}/dirs`, { data });
1462
+ }
1463
+ async fillPdf(lib, data) {
1464
+ const { input_path, output_path, output_pdf = false, output_type, output_file_name, form_data, forms } = data;
1465
+ const responseType = output_pdf ? 'arraybuffer' : 'json';
1466
+ const contentType = output_pdf ? 'application/pdf' : 'application/json';
1467
+ return this.request('POST', `media/library/${lib}/pdf/fill`, {
1468
+ data: {
1469
+ input_path,
1470
+ output_path,
1471
+ output_pdf,
1472
+ output_type,
1473
+ output_file_name,
1474
+ form_data,
1475
+ forms
1476
+ },
1477
+ headers: {
1478
+ 'Content-Type': contentType
1479
+ },
1480
+ responseType
1481
+ });
1482
+ }
1483
+ // ===================================================================
1484
+ // Data Converter Methods
1485
+ // ===================================================================
1486
+ //
1487
+ // The following methods provide comprehensive data conversion capabilities
1488
+ // between JSON, CSV, and Excel formats, along with validation and analysis tools.
1489
+ // All methods require a valid library reference UUID and return AxiosResponse objects.
1490
+ //
1491
+ /**
1492
+ * Convert data between different formats (JSON, CSV, Excel)
1493
+ *
1494
+ * Supports structured data when converting from JSON format with:
1495
+ * - Explicit structure: JSON with `header`, `items`, and `footer` properties
1496
+ * - Auto-detection: Mixed JSON arrays with metadata objects and summary rows
1497
+ *
1498
+ * @param lib - Library reference UUID
1499
+ * @param data - Raw data to convert
1500
+ * @param params - Conversion parameters including structured data options
1501
+ * @returns Promise resolving to converted data
1502
+ *
1503
+ * @example
1504
+ * ```typescript
1505
+ * // Convert JSON to CSV
1506
+ * const jsonData = [
1507
+ * { name: "John Doe", age: 30, email: "john@example.com" },
1508
+ * { name: "Jane Smith", age: 25, email: "jane@example.com" }
1509
+ * ];
1510
+ *
1511
+ * const csvResult = await dms.convertData(libraryRef, jsonData, {
1512
+ * from: 'json',
1513
+ * to: 'csv'
1514
+ * });
1515
+ * console.log(csvResult.data); // CSV string
1516
+ *
1517
+ * // Convert structured JSON with header as comments
1518
+ * const structuredData = {
1519
+ * header: {
1520
+ * content: {
1521
+ * report_title: "Monthly Sales Report",
1522
+ * generated_by: "Sales System"
1523
+ * }
1524
+ * },
1525
+ * items: [
1526
+ * { product: "Widget A", sales: 100 },
1527
+ * { product: "Widget B", sales: 150 }
1528
+ * ],
1529
+ * footer: {
1530
+ * content: {
1531
+ * total_sales: 250
1532
+ * }
1533
+ * }
1534
+ * };
1535
+ *
1536
+ * const csvWithComments = await dms.convertData(libraryRef, structuredData, {
1537
+ * from: 'json',
1538
+ * to: 'csv',
1539
+ * header_as_comment: true,
1540
+ * separator_rows: 2
1541
+ * });
1542
+ *
1543
+ * // Convert JSON to Excel with custom sheet name
1544
+ * const excelResult = await dms.convertData(libraryRef, jsonData, {
1545
+ * from: 'json',
1546
+ * to: 'excel',
1547
+ * sheet_name: 'Customer Data'
1548
+ * });
1549
+ * // excelResult.data is a Blob
1550
+ * ```
1551
+ */
1552
+ async convertData(lib, data, params) {
1553
+ const { from, to, sheet_name, include_header, include_footer, header_as_comment, footer_as_comment, separator_rows, field_order, } = params;
1554
+ const queryParams = { from, to };
1555
+ // Add optional parameters if provided
1556
+ if (sheet_name)
1557
+ queryParams.sheet_name = sheet_name;
1558
+ if (include_header !== undefined)
1559
+ queryParams.include_header = include_header;
1560
+ if (include_footer !== undefined)
1561
+ queryParams.include_footer = include_footer;
1562
+ if (header_as_comment !== undefined)
1563
+ queryParams.header_as_comment = header_as_comment;
1564
+ if (footer_as_comment !== undefined)
1565
+ queryParams.footer_as_comment = footer_as_comment;
1566
+ if (separator_rows !== undefined)
1567
+ queryParams.separator_rows = separator_rows;
1568
+ if (field_order !== undefined)
1569
+ queryParams.field_order = field_order.join(',');
1570
+ console.log('Conversion Query Params:', queryParams);
1571
+ // Determine content type based on target format
1572
+ let responseType = 'text';
1573
+ if (to === 'json') {
1574
+ responseType = 'json';
1575
+ }
1576
+ else if (to === 'excel' || to === 'xlsx') {
1577
+ responseType = 'blob';
1578
+ }
1579
+ return this.request('POST', `media/library/${lib}/convert/data`, {
1580
+ data,
1581
+ params: queryParams,
1582
+ responseType,
1583
+ headers: {
1584
+ 'Content-Type': 'application/json'
1585
+ }
1586
+ });
1587
+ }
1588
+ /**
1589
+ * Get information about data format and structure
1590
+ *
1591
+ * @param lib - Library reference UUID
1592
+ * @param data - Raw data to analyze
1593
+ * @param params - Analysis parameters
1594
+ * @returns Promise resolving to data information
1595
+ *
1596
+ * @example
1597
+ * ```typescript
1598
+ * const jsonData = [
1599
+ * { name: "John", age: 30, email: "john@example.com" },
1600
+ * { name: "Jane", age: 25, email: "jane@example.com" }
1601
+ * ];
1602
+ *
1603
+ * const dataInfo = await dms.getDataInfo(libraryRef, jsonData, {
1604
+ * format: 'json'
1605
+ * });
1606
+ *
1607
+ * console.log(dataInfo.data);
1608
+ * // Output:
1609
+ * // {
1610
+ * // format: "json",
1611
+ * // size_bytes: 245,
1612
+ * // record_count: 2,
1613
+ * // field_count: 3,
1614
+ * // fields: ["name", "age", "email"],
1615
+ * // library_ref: "98bee1cb-0f21-4582-a832-7c32b4b61831"
1616
+ * // }
1617
+ * ```
1618
+ */
1619
+ async getDataInfo(lib, data, params) {
1620
+ const { format } = params;
1621
+ return this.request('POST', `media/library/${lib}/convert/info`, {
1622
+ data,
1623
+ params: { format },
1624
+ headers: {
1625
+ 'Content-Type': 'application/json'
1626
+ }
1627
+ });
1628
+ }
1629
+ /**
1630
+ * Validate data format without performing conversion
1631
+ *
1632
+ * @param lib - Library reference UUID
1633
+ * @param data - Raw data to validate
1634
+ * @param params - Validation parameters
1635
+ * @returns Promise resolving to validation result
1636
+ *
1637
+ * @example
1638
+ * ```typescript
1639
+ * const jsonData = [{ name: "John", age: 30 }];
1640
+ *
1641
+ * const validation = await dms.validateData(libraryRef, jsonData, {
1642
+ * format: 'json'
1643
+ * });
1644
+ *
1645
+ * console.log(validation.data);
1646
+ * // Output:
1647
+ * // {
1648
+ * // valid: true,
1649
+ * // message: "Data is valid JSON format",
1650
+ * // library_ref: "98bee1cb-0f21-4582-a832-7c32b4b61831"
1651
+ * // }
1652
+ *
1653
+ * // Handle invalid data
1654
+ * try {
1655
+ * const invalidValidation = await dms.validateData(libraryRef, "invalid json", {
1656
+ * format: 'json'
1657
+ * });
1658
+ * } catch (error) {
1659
+ * console.error('Validation failed:', error.response?.data?.message);
1660
+ * }
1661
+ * ```
1662
+ */
1663
+ async validateData(lib, data, params) {
1664
+ const { format } = params;
1665
+ return this.request('POST', `media/library/${lib}/convert/validate`, {
1666
+ data,
1667
+ params: { format },
1668
+ headers: {
1669
+ 'Content-Type': 'application/json'
1670
+ }
1671
+ });
1672
+ }
1673
+ /**
1674
+ * Convert JSON data to CSV format
1675
+ *
1676
+ * This method supports both regular JSON arrays and structured data with auto-detection:
1677
+ * - Regular arrays are converted directly to CSV
1678
+ * - Structured data (with metadata objects) is automatically detected and formatted
1679
+ *
1680
+ * @param lib - Library reference UUID
1681
+ * @param jsonData - JSON data (array of objects or structured data)
1682
+ * @returns Promise resolving to CSV string
1683
+ *
1684
+ * @example
1685
+ * ```typescript
1686
+ * // Regular JSON to CSV
1687
+ * const jsonData = [
1688
+ * { name: "John Doe", age: 30, email: "john@example.com" },
1689
+ * { name: "Jane Smith", age: 25, email: "jane@example.com" }
1690
+ * ];
1691
+ *
1692
+ * const csvResponse = await dms.jsonToCsv(libraryRef, jsonData);
1693
+ * console.log(csvResponse.data);
1694
+ * // Output:
1695
+ * // name,age,email
1696
+ * // John Doe,30,john@example.com
1697
+ * // Jane Smith,25,jane@example.com
1698
+ *
1699
+ * // Structured JSON with auto-detection
1700
+ * const structuredData = [
1701
+ * { metadata: "EMPLOYEE REPORT\nGenerated: 2025-10-08" },
1702
+ * { name: "John Doe", age: 30, position: "Developer" },
1703
+ * { name: "Jane Smith", age: 25, position: "Designer" },
1704
+ * { name: "Total Employees:", age: null, position: "2 people" }
1705
+ * ];
1706
+ *
1707
+ * const structuredCsv = await dms.jsonToCsv(libraryRef, structuredData);
1708
+ * // Auto-detects header, items, and footer sections
1709
+ * ```
1710
+ */
1711
+ async jsonToCsv(lib, jsonData, options) {
1712
+ let params = {};
1713
+ if (options === null || options === void 0 ? void 0 : options.field_order) {
1714
+ params.field_order = options.field_order.join(',');
1715
+ }
1716
+ return this.request('POST', `media/library/${lib}/convert/json-to-csv`, {
1717
+ params,
1718
+ data: jsonData,
1719
+ responseType: 'text',
1720
+ headers: {
1721
+ 'Content-Type': 'application/json'
1722
+ }
1723
+ });
1724
+ }
1725
+ /**
1726
+ * Convert JSON data to Excel (.xlsx) format
1727
+ *
1728
+ * Supports both regular JSON arrays and structured data patterns.
1729
+ * Excel files are always generated with .xlsx extension.
1730
+ *
1731
+ * @param lib - Library reference UUID
1732
+ * @param jsonData - JSON data (array of objects or structured data)
1733
+ * @param options - Optional conversion options
1734
+ * @returns Promise resolving to Excel file as Blob
1735
+ *
1736
+ * @example
1737
+ * ```typescript
1738
+ * // Regular JSON to Excel
1739
+ * const jsonData = [
1740
+ * { name: "John Doe", age: 30, email: "john@example.com" },
1741
+ * { name: "Jane Smith", age: 25, email: "jane@example.com" }
1742
+ * ];
1743
+ *
1744
+ * // Basic conversion
1745
+ * const excelResponse = await dms.jsonToExcel(libraryRef, jsonData);
1746
+ * const blob = excelResponse.data; // Blob for download
1747
+ *
1748
+ * // With custom sheet name
1749
+ * const excelWithOptions = await dms.jsonToExcel(libraryRef, jsonData, {
1750
+ * sheet_name: 'Customer Data'
1751
+ * });
1752
+ *
1753
+ * // Structured data with explicit sections
1754
+ * const structuredData = {
1755
+ * header: { content: { title: "Monthly Report" } },
1756
+ * items: [{ product: "Widget A", sales: 100 }],
1757
+ * footer: { content: { total_sales: 100 } }
1758
+ * };
1759
+ *
1760
+ * const structuredExcel = await dms.jsonToExcel(libraryRef, structuredData);
1761
+ *
1762
+ * // Create download link
1763
+ * const url = URL.createObjectURL(structuredExcel.data);
1764
+ * const link = document.createElement('a');
1765
+ * link.href = url;
1766
+ * link.download = 'report.xlsx'; // Always .xlsx extension
1767
+ * link.click();
1768
+ * ```
1769
+ */
1770
+ async jsonToExcel(lib, jsonData, options) {
1771
+ const params = {};
1772
+ if (options === null || options === void 0 ? void 0 : options.sheet_name) {
1773
+ params.sheet_name = options.sheet_name;
1774
+ }
1775
+ if (options === null || options === void 0 ? void 0 : options.field_order) {
1776
+ params.field_order = options.field_order.join(',');
1777
+ }
1778
+ return this.request('POST', `media/library/${lib}/convert/json-to-excel`, {
1779
+ data: jsonData,
1780
+ params,
1781
+ responseType: 'blob',
1782
+ headers: {
1783
+ 'Content-Type': 'application/json'
1784
+ }
1785
+ });
1786
+ }
1787
+ /**
1788
+ * Convert CSV data to JSON format
1789
+ *
1790
+ * @param lib - Library reference UUID
1791
+ * @param csvData - CSV data string (with headers in first row)
1792
+ * @returns Promise resolving to JSON array
1793
+ *
1794
+ * @example
1795
+ * ```typescript
1796
+ * const csvString = `name,age,email
1797
+ * John Doe,30,john@example.com
1798
+ * Jane Smith,25,jane@example.com`;
1799
+ *
1800
+ * const jsonResponse = await dms.csvToJson(libraryRef, csvString);
1801
+ * console.log(jsonResponse.data);
1802
+ * // Output:
1803
+ * // [
1804
+ * // { name: "John Doe", age: "30", email: "john@example.com" },
1805
+ * // { name: "Jane Smith", age: "25", email: "jane@example.com" }
1806
+ * // ]
1807
+ * ```
1808
+ */
1809
+ async csvToJson(lib, csvData) {
1810
+ return this.request('POST', `media/library/${lib}/convert/csv-to-json`, {
1811
+ data: csvData,
1812
+ responseType: 'json',
1813
+ headers: {
1814
+ 'Content-Type': 'text/csv'
1815
+ }
1816
+ });
1817
+ }
1818
+ /**
1819
+ * Convert CSV data to Excel (.xlsx) format
1820
+ *
1821
+ * @param lib - Library reference UUID
1822
+ * @param csvData - CSV data string (with headers in first row)
1823
+ * @param options - Optional conversion options
1824
+ * @returns Promise resolving to Excel file as Blob
1825
+ *
1826
+ * @example
1827
+ * ```typescript
1828
+ * const csvString = `name,age,email
1829
+ * John Doe,30,john@example.com
1830
+ * Jane Smith,25,jane@example.com`;
1831
+ *
1832
+ * const excelResponse = await dms.csvToExcel(libraryRef, csvString, {
1833
+ * sheet_name: 'Imported Data'
1834
+ * });
1835
+ *
1836
+ * // Handle the Excel blob
1837
+ * const blob = excelResponse.data;
1838
+ * const url = URL.createObjectURL(blob);
1839
+ * // Use url for download or further processing
1840
+ * ```
1841
+ */
1842
+ async csvToExcel(lib, csvData, options) {
1843
+ const params = {};
1844
+ if (options === null || options === void 0 ? void 0 : options.sheet_name) {
1845
+ params.sheet_name = options.sheet_name;
1846
+ }
1847
+ return this.request('POST', `media/library/${lib}/convert/csv-to-excel`, {
1848
+ data: csvData,
1849
+ params,
1850
+ responseType: 'blob',
1851
+ headers: {
1852
+ 'Content-Type': 'text/csv'
1853
+ }
1854
+ });
1855
+ }
1856
+ /**
1857
+ * Convert Excel (.xlsx) data to JSON format
1858
+ *
1859
+ * @param lib - Library reference UUID
1860
+ * @param excelData - Excel file data as Blob or ArrayBuffer
1861
+ * @param options - Optional conversion options
1862
+ * @returns Promise resolving to JSON array
1863
+ *
1864
+ * @example
1865
+ * ```typescript
1866
+ * // From file input
1867
+ * const fileInput = document.querySelector('input[type="file"]');
1868
+ * const file = fileInput.files[0]; // Excel file
1869
+ *
1870
+ * const jsonResponse = await dms.excelToJson(libraryRef, file, {
1871
+ * sheet_name: 'Sheet1' // optional, defaults to first sheet
1872
+ * });
1873
+ *
1874
+ * console.log(jsonResponse.data);
1875
+ * // Output: JSON array with data from Excel sheet
1876
+ *
1877
+ * // From ArrayBuffer
1878
+ * const arrayBuffer = await file.arrayBuffer();
1879
+ * const jsonFromBuffer = await dms.excelToJson(libraryRef, arrayBuffer);
1880
+ * ```
1881
+ */
1882
+ async excelToJson(lib, excelData, options) {
1883
+ const params = {};
1884
+ if (options === null || options === void 0 ? void 0 : options.sheet_name) {
1885
+ params.sheet_name = options.sheet_name;
1886
+ }
1887
+ return this.request('POST', `media/library/${lib}/convert/excel-to-json`, {
1888
+ data: excelData,
1889
+ params,
1890
+ responseType: 'json',
1891
+ headers: {
1892
+ 'Content-Type': 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet'
1893
+ }
1894
+ });
1895
+ }
1896
+ /**
1897
+ * Convert Excel (.xlsx) data to CSV format
1898
+ *
1899
+ * @param lib - Library reference UUID
1900
+ * @param excelData - Excel file data as Blob or ArrayBuffer
1901
+ * @param options - Optional conversion options
1902
+ * @returns Promise resolving to CSV string
1903
+ *
1904
+ * @example
1905
+ * ```typescript
1906
+ * // From file input
1907
+ * const fileInput = document.querySelector('input[type="file"]');
1908
+ * const file = fileInput.files[0]; // Excel file
1909
+ *
1910
+ * const csvResponse = await dms.excelToCsv(libraryRef, file, {
1911
+ * sheet_name: 'Data' // optional, defaults to first sheet
1912
+ * });
1913
+ *
1914
+ * console.log(csvResponse.data);
1915
+ * // Output: CSV string with data from Excel sheet
1916
+ *
1917
+ * // Save as CSV file
1918
+ * const csvBlob = new Blob([csvResponse.data], { type: 'text/csv' });
1919
+ * const url = URL.createObjectURL(csvBlob);
1920
+ * const link = document.createElement('a');
1921
+ * link.href = url;
1922
+ * link.download = 'converted.csv';
1923
+ * link.click();
1924
+ * ```
1925
+ */
1926
+ async excelToCsv(lib, excelData, options) {
1927
+ const params = {};
1928
+ if (options === null || options === void 0 ? void 0 : options.sheet_name) {
1929
+ params.sheet_name = options.sheet_name;
1930
+ }
1931
+ return this.request('POST', `media/library/${lib}/convert/excel-to-csv`, {
1932
+ data: excelData,
1933
+ params,
1934
+ responseType: 'text',
1935
+ headers: {
1936
+ 'Content-Type': 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet'
1937
+ }
1938
+ });
1939
+ }
1940
+ async request(method, endpoint, params) {
1941
+ return await this.client.request({
1942
+ method: method,
1943
+ url: `/v2/dms/${endpoint}`,
1944
+ ...params
1945
+ });
1946
+ }
1947
+ async requestv1(method, endpoint, params) {
1948
+ return await this.client.request({
1949
+ method: method,
1950
+ url: `/v1/dms/${endpoint}`,
1951
+ ...params
1952
+ });
1953
+ }
1954
+ }
1955
+
1956
+ class SerbiaUtil extends IntegrationsBaseClient {
1957
+ async nbsSearch(params) {
1958
+ return await this.services("GET", "nbs/search", { params });
1959
+ }
1960
+ async getReceiptFromUrl(url, source) {
1961
+ return await this.services("POST", "receipt/crawl", {
1962
+ data: {
1963
+ url,
1964
+ source
1965
+ }
1966
+ });
1967
+ }
1968
+ async getContoList() {
1969
+ return await this.services("GET", "conto");
1970
+ }
1971
+ async services(method, endpoint, params) {
1972
+ return this.request(method, `services/${endpoint}`, params);
1973
+ }
1974
+ async request(method, endpoint, params) {
1975
+ return await this.client.request({
1976
+ method: method,
1977
+ url: `/v1/karadjordje/${endpoint}`,
1978
+ ...params
1979
+ });
1980
+ }
1981
+ }
1982
+
1983
+ class VPFR extends IntegrationsBaseClient {
1984
+ async request(method, endpoint, params) {
1985
+ return await this.client.request({
1986
+ method: method,
1987
+ url: `/v1/karadjordje/vpfr/${endpoint}`,
1988
+ ...params
1989
+ });
1990
+ }
1991
+ }
1992
+
1993
+ class Payments extends IntegrationsBaseClient {
1994
+ async getTransactions(userId, params) {
1995
+ return await this.client.get(`/karadjordje/v1/payment/${userId}/list`, {
1996
+ params,
1997
+ });
1998
+ }
1999
+ async getTransaction(provider, userId, transactionId) {
2000
+ return await this.client.get(`/karadjordje/v1/payment/${provider}/${userId}/getTransaction`, {
2001
+ params: { transactionId },
2002
+ });
2003
+ }
2004
+ async settings(provider) {
2005
+ return await this.client.get(`/karadjordje/v1/payment/${provider}/settings`);
2006
+ }
2007
+ async deactivatePaymentLink(provider, user, transactionId) {
2008
+ return await this.client.post(`/karadjordje/v1/payment/${provider}/${user}/deactivate/${transactionId}`);
2009
+ }
2010
+ async voidTransaction(provider, user, transactionId) {
2011
+ return await this.client.post(`/karadjordje/v1/payment/${provider}/${user}/void/${transactionId}`);
2012
+ }
2013
+ async refund(provider, user, transactionId) {
2014
+ return await this.client.post(`/karadjordje/v1/payment/${provider}/${user}/refund/${transactionId}`);
2015
+ }
2016
+ async getPaymentLink(provider, user, options) {
2017
+ return await this.client.post(`/karadjordje/v1/payment/${provider}/${user}/getPaymentLink`, options);
2018
+ }
2019
+ async getTokenRequestLink(provider, user, options) {
2020
+ return await this.client.post(`/karadjordje/v1/payment/${provider}/${user}/getTokenRequestLink`, options);
2021
+ }
2022
+ async directPayUsingToken(provider, user, options) {
2023
+ return await this.client.post(`/karadjordje/v1/payment/${provider}/${user}/directPayUsingToken`, options);
2024
+ }
2025
+ }
2026
+
2027
+ class Minimax extends IntegrationsBaseClient {
2028
+ async settings() {
2029
+ return await this.client.get(`/karadjordje/v1/minimax/settings`);
2030
+ }
2031
+ async getAccounts(userId, organisationId, params) {
2032
+ const path = `/karadjordje/v1/minimax/${userId}/api/orgs/${organisationId}/accounts`;
2033
+ return await this.client.get(path, { params });
2034
+ }
2035
+ async getAccount(userId, organisationId, accountId) {
2036
+ const path = `/karadjordje/v1/minimax/${userId}/api/orgs/${organisationId}/accounts/${accountId}`;
2037
+ return await this.client.get(path);
2038
+ }
2039
+ async getAccountByCode(userId, organisationId, code) {
2040
+ const path = `/karadjordje/v1/minimax/${userId}/api/orgs/${organisationId}/accounts/code(${code})`;
2041
+ return await this.client.get(path);
2042
+ }
2043
+ async getAccountByContent(userId, organisationId, content) {
2044
+ const path = `/karadjordje/v1/minimax/${userId}/api/orgs/${organisationId}/accounts/content(${content})`;
2045
+ return await this.client.get(path);
2046
+ }
2047
+ async getAccountsForSync(userId, organisationId, params) {
2048
+ const path = `/karadjordje/v1/minimax/${userId}/api/orgs/${organisationId}/accounts/synccandidates`;
2049
+ return await this.client.get(path, { params });
2050
+ }
2051
+ /** ADDRESSES */
2052
+ async getAddresses(userId, organisationId, customerId, params) {
2053
+ const path = `/karadjordje/v1/minimax/${userId}/api/orgs/${organisationId}/customers/${customerId}/addresses`;
2054
+ return await this.client.get(path, { params });
2055
+ }
2056
+ async newAddress(userId, organisationId, customerId, address) {
2057
+ const path = `/karadjordje/v1/minimax/${userId}/api/orgs/${organisationId}/customers/${customerId}/addresses`;
2058
+ return await this.client.post(path, address);
2059
+ }
2060
+ async deleteAddress(userId, organisationId, customerId, addressId) {
2061
+ const path = `/karadjordje/v1/minimax/${userId}/api/orgs/${organisationId}/customers/${customerId}/addresses/${addressId}`;
2062
+ return await this.client.delete(path);
2063
+ }
2064
+ async getAddress(userId, organisationId, customerId, addressId) {
2065
+ const path = `/karadjordje/v1/minimax/${userId}/api/orgs/${organisationId}/customers/${customerId}/addresses/${addressId}`;
2066
+ return await this.client.get(path);
2067
+ }
2068
+ async updateAddress(userId, organisationId, customerId, address) {
2069
+ const path = `/karadjordje/v1/minimax/${userId}/api/orgs/${organisationId}/customers/${customerId}/addresses/${address.AddressId}`;
2070
+ return await this.client.put(path, address);
2071
+ }
2072
+ async getAddressesForSync(userId, organisationId, customerId, params) {
2073
+ const path = `/karadjordje/v1/minimax/${userId}/api/orgs/${organisationId}/customers/${customerId}/addresses/synccandidates`;
2074
+ return await this.client.get(path, { params });
2075
+ }
2076
+ /** ANALYTICS */
2077
+ async getAnalytics(userId, organisationId, params) {
2078
+ const path = `/karadjordje/v1/minimax/${userId}/api/orgs/${organisationId}/analytics`;
2079
+ return await this.client.get(path, { params });
2080
+ }
2081
+ async newAnalytic(userId, organisationId, analytic) {
2082
+ const path = `/karadjordje/v1/minimax/${userId}/api/orgs/${organisationId}/analytics`;
2083
+ return await this.client.post(path, analytic);
2084
+ }
2085
+ async deleteAnalytic(userId, organisationId, analyticId) {
2086
+ const path = `/karadjordje/v1/minimax/${userId}/api/orgs/${organisationId}/analytics/${analyticId}`;
2087
+ return await this.client.delete(path);
2088
+ }
2089
+ async getAnalytic(userId, organisationId, analyticId) {
2090
+ const path = `/karadjordje/v1/minimax/${userId}/api/orgs/${organisationId}/analytics/${analyticId}`;
2091
+ return await this.client.get(path);
2092
+ }
2093
+ async updateAnalytic(userId, organisationId, analytic) {
2094
+ const path = `/karadjordje/v1/minimax/${userId}/api/orgs/${organisationId}/analytics/${analytic.AnalyticId}`;
2095
+ return await this.client.put(path, analytic);
2096
+ }
2097
+ async getAnalyticsForSync(userId, organisationId, params) {
2098
+ const path = `/karadjordje/v1/minimax/${userId}/api/orgs/${organisationId}/analytics/synccandidates`;
2099
+ return await this.client.get(path, { params });
2100
+ }
2101
+ /** BANK ACCOUNTS */
2102
+ async getBankAccounts(userId, organisationId, customerId, params) {
2103
+ const path = `/karadjordje/v1/minimax/${userId}/api/orgs/${organisationId}/customers/${customerId}/bankAccounts`;
2104
+ return await this.client.get(path, { params });
2105
+ }
2106
+ async newBankAccount(userId, organisationId, customerId, bankAccount) {
2107
+ const path = `/karadjordje/v1/minimax/${userId}/api/orgs/${organisationId}/customers/${customerId}/bankAccounts`;
2108
+ return await this.client.post(path, bankAccount);
2109
+ }
2110
+ async deleteBankAccount(userId, organisationId, customerId, bankAccountId) {
2111
+ const path = `/karadjordje/v1/minimax/${userId}/api/orgs/${organisationId}/customers/${customerId}/bankAccounts/${bankAccountId}`;
2112
+ return await this.client.delete(path);
2113
+ }
2114
+ async getBankAccount(userId, organisationId, customerId, bankAccountId) {
2115
+ const path = `/karadjordje/v1/minimax/${userId}/api/orgs/${organisationId}/customers/${customerId}/bankAccounts/${bankAccountId}`;
2116
+ return await this.client.get(path);
2117
+ }
2118
+ async updateBankAccount(userId, organisationId, customerId, bankAccount) {
2119
+ const path = `/karadjordje/v1/minimax/${userId}/api/orgs/${organisationId}/customers/${customerId}/addresses/${bankAccount.BankAccountId}`;
2120
+ return await this.client.put(path, bankAccount);
2121
+ }
2122
+ async getBankAccountsForSync(userId, organisationId, customerId, params) {
2123
+ const path = `/karadjordje/v1/minimax/${userId}/api/orgs/${organisationId}/customers/${customerId}/bankAccounts/synccandidates`;
2124
+ return await this.client.get(path, { params });
2125
+ }
2126
+ /** CONTACTS */
2127
+ async getCustomerContacts(userId, organisationId, customerId, params) {
2128
+ const path = `/karadjordje/v1/minimax/${userId}/api/orgs/${organisationId}/customers/${customerId}/contacts`;
2129
+ return await this.client.get(path, { params });
2130
+ }
2131
+ async newContact(userId, organisationId, customerId, contact) {
2132
+ const path = `/karadjordje/v1/minimax/${userId}/api/orgs/${organisationId}/customers/${customerId}/contacts`;
2133
+ return await this.client.post(path, contact);
2134
+ }
2135
+ async deleteContact(userId, organisationId, customerId, contactId) {
2136
+ const path = `/karadjordje/v1/minimax/${userId}/api/orgs/${organisationId}/customers/${customerId}/contacts/${contactId}`;
2137
+ return await this.client.delete(path);
2138
+ }
2139
+ async getContact(userId, organisationId, customerId, contactId) {
2140
+ const path = `/karadjordje/v1/minimax/${userId}/api/orgs/${organisationId}/customers/${customerId}/contacts/${contactId}`;
2141
+ return await this.client.get(path);
2142
+ }
2143
+ async updateContact(userId, organisationId, customerId, contact) {
2144
+ const path = `/karadjordje/v1/minimax/${userId}/api/orgs/${organisationId}/customers/${customerId}/addresses/${contact.ContactId}`;
2145
+ return await this.client.put(path, contact);
2146
+ }
2147
+ async getContacts(userId, organisationId, params) {
2148
+ const path = `/karadjordje/v1/minimax/${userId}/api/orgs/${organisationId}/contacts`;
2149
+ return await this.client.get(path, { params });
2150
+ }
2151
+ async getContactForSync(userId, organisationId, customerId, params) {
2152
+ const path = `/karadjordje/v1/minimax/${userId}/api/orgs/${organisationId}/customers/${customerId}/contacts/synccandidates`;
2153
+ return await this.client.get(path, { params });
2154
+ }
2155
+ /** COUNTRIES */
2156
+ async getCountries(userId, organisationId, params) {
2157
+ const path = `/karadjordje/v1/minimax/${userId}/api/orgs/${organisationId}/countries`;
2158
+ return await this.client.get(path, { params });
2159
+ }
2160
+ async getCountry(userId, organisationId, countryId) {
2161
+ const path = `/karadjordje/v1/minimax/${userId}/api/orgs/${organisationId}/countries/${countryId}`;
2162
+ return await this.client.get(path);
2163
+ }
2164
+ async getCountryByCode(userId, organisationId, code) {
2165
+ const path = `/karadjordje/v1/minimax/${userId}/api/orgs/${organisationId}/countries/code(${code})`;
2166
+ return await this.client.get(path);
2167
+ }
2168
+ async getCountriesForSync(userId, organisationId, params) {
2169
+ const path = `/karadjordje/v1/minimax/${userId}/api/orgs/${organisationId}/countries/synccandidates`;
2170
+ return await this.client.get(path, { params });
2171
+ }
2172
+ /** CURRENCIES */
2173
+ async getCurrencies(userId, organisationId, params) {
2174
+ const path = `/karadjordje/v1/minimax/${userId}/api/orgs/${organisationId}/currencies`;
2175
+ return await this.client.get(path, { params });
2176
+ }
2177
+ async getCurrency(userId, organisationId, currencyId) {
2178
+ const path = `/karadjordje/v1/minimax/${userId}/api/orgs/${organisationId}/currencies/${currencyId}`;
2179
+ return await this.client.get(path);
2180
+ }
2181
+ async getCurrencyByDate(userId, organisationId, date) {
2182
+ const path = `/karadjordje/v1/minimax/${userId}/api/orgs/${organisationId}/currencies/date(${date.toISOString()})`;
2183
+ return await this.client.get(path);
2184
+ }
2185
+ async getCurrencyByCode(userId, organisationId, code) {
2186
+ const path = `/karadjordje/v1/minimax/${userId}/api/orgs/${organisationId}/currencies/code(${code})`;
2187
+ return await this.client.get(path);
2188
+ }
2189
+ async getCurrenciesForSync(userId, organisationId, params) {
2190
+ const path = `/karadjordje/v1/minimax/${userId}/api/orgs/${organisationId}/currencies/synccandidates`;
2191
+ return await this.client.get(path, { params });
2192
+ }
2193
+ /** CUSTOMERS */
2194
+ async getCustomers(userId, organisationId, params) {
2195
+ const path = `/karadjordje/v1/minimax/${userId}/api/orgs/${organisationId}/customers`;
2196
+ return await this.client.get(path, { params });
2197
+ }
2198
+ async newCustomer(userId, organisationId, customer) {
2199
+ const path = `/karadjordje/v1/minimax/${userId}/api/orgs/${organisationId}/customers`;
2200
+ return await this.client.post(path, customer);
2201
+ }
2202
+ async deleteCusomter(userId, organisationId, customerId) {
2203
+ const path = `/karadjordje/v1/minimax/${userId}/api/orgs/${organisationId}/customers/${customerId}`;
2204
+ return await this.client.delete(path);
2205
+ }
2206
+ async getCustomer(userId, organisationId, customerId) {
2207
+ const path = `/karadjordje/v1/minimax/${userId}/api/orgs/${organisationId}/customers/${customerId}`;
2208
+ return await this.client.get(path);
2209
+ }
2210
+ async updateCustomer(userId, organisationId, customer) {
2211
+ const path = `/karadjordje/v1/minimax/${userId}/api/orgs/${organisationId}/customers/${customer.CustomerId}`;
2212
+ return await this.client.put(path, customer);
2213
+ }
2214
+ async getCustomerByCode(userId, organisationId, code) {
2215
+ const path = `/karadjordje/v1/minimax/${userId}/api/orgs/${organisationId}/customers/code(${code})`;
2216
+ return await this.client.get(path);
2217
+ }
2218
+ async newCustomerByTaxNumber(userId, organisationId, taxNumber) {
2219
+ const path = `/karadjordje/v1/minimax/${userId}/api/orgs/${organisationId}/customers/addbytaxnumber(${taxNumber})`;
2220
+ return await this.client.post(path, {});
2221
+ }
2222
+ async getCustomersForSync(userId, organisationId, params) {
2223
+ const path = `/karadjordje/v1/minimax/${userId}/api/orgs/${organisationId}/customers/synccandidates`;
2224
+ return await this.client.get(path, { params });
2225
+ }
2226
+ /** DASHBOARDS */
2227
+ async getDashboardsData(userId, organisationId) {
2228
+ const path = `/karadjordje/v1/minimax/${userId}/api/orgs/${organisationId}/dashboards`;
2229
+ return await this.client.get(path);
2230
+ }
2231
+ /** DOCUMENTS */
2232
+ async getDocuments(userId, organisationId, params) {
2233
+ const path = `/karadjordje/v1/minimax/${userId}/api/orgs/${organisationId}/documents`;
2234
+ return await this.client.get(path, { params });
2235
+ }
2236
+ async newDocument(userId, organisationId, document) {
2237
+ const path = `/karadjordje/v1/minimax/${userId}/api/orgs/${organisationId}/documents`;
2238
+ return await this.client.post(path, document);
2239
+ }
2240
+ async deleteDocument(userId, organisationId, documentId) {
2241
+ const path = `/karadjordje/v1/minimax/${userId}/api/orgs/${organisationId}/documents/${documentId}`;
2242
+ return await this.client.delete(path);
2243
+ }
2244
+ async getDocument(userId, organisationId, documentId) {
2245
+ const path = `/karadjordje/v1/minimax/${userId}/api/orgs/${organisationId}/documents/${documentId}`;
2246
+ return await this.client.get(path);
2247
+ }
2248
+ async updateDocument(userId, organisationId, document) {
2249
+ const path = `/karadjordje/v1/minimax/${userId}/api/orgs/${organisationId}/documents/${document.DocumentId}`;
2250
+ return await this.client.put(path, document);
2251
+ }
2252
+ async deleteDocumentAttachment(userId, organisationId, documentId, documentAttachmentId) {
2253
+ const path = `/karadjordje/v1/minimax/${userId}/api/orgs/${organisationId}/documents/${documentId}/attachments/${documentAttachmentId}`;
2254
+ return await this.client.delete(path);
2255
+ }
2256
+ async getDocumentAttachment(userId, organisationId, documentId, documentAttachmentId) {
2257
+ const path = `/karadjordje/v1/minimax/${userId}/api/orgs/${organisationId}/documents/${documentId}/attachments/${documentAttachmentId}`;
2258
+ return await this.client.get(path);
2259
+ }
2260
+ async updateDocumentAttachment(userId, organisationId, documentId, documentAttachment) {
2261
+ const path = `/karadjordje/v1/minimax/${userId}/api/orgs/${organisationId}/documents/${documentId}/attachments/${documentAttachment.DocumentAttachmentId}`;
2262
+ return await this.client.put(path, documentAttachment);
2263
+ }
2264
+ async newDocumentAttachment(userId, organisationId, documentId, documentAttachment) {
2265
+ const path = `/karadjordje/v1/minimax/${userId}/api/orgs/${organisationId}/documents/${documentId}/attachments`;
2266
+ return await this.client.post(path, documentAttachment);
2267
+ }
2268
+ async getDocumentsForSync(userId, organisationId, params) {
2269
+ const path = `/karadjordje/v1/minimax/${userId}/api/orgs/${organisationId}/documents/synccandidates`;
2270
+ return await this.client.get(path, { params });
2271
+ }
2272
+ /** DOCUMENT NUMBERINGS */
2273
+ async getDocumentNumberings(userId, organisationId, params) {
2274
+ const path = `/karadjordje/v1/minimax/${userId}/api/orgs/${organisationId}/document-numbering`;
2275
+ return await this.client.get(path, { params });
2276
+ }
2277
+ async getDocumentNumbering(userId, organisationId, documentNumberingId) {
2278
+ const path = `/karadjordje/v1/minimax/${userId}/api/orgs/${organisationId}/document-numbering/${documentNumberingId}`;
2279
+ return await this.client.get(path);
2280
+ }
2281
+ /** EFAKTURA */
2282
+ async getEFakturaList(userId, params) {
2283
+ const path = `/karadjordje/v1/minimax/${userId}/api/efaktura/list`;
2284
+ return await this.client.get(path, { params });
2285
+ }
2286
+ /** EMPLOYEES */
2287
+ async getEmployees(userId, organisationId, params) {
2288
+ const path = `/karadjordje/v1/minimax/${userId}/api/orgs/${organisationId}/employees`;
2289
+ return await this.client.get(path, { params });
2290
+ }
2291
+ async newEmployee(userId, organisationId, employee) {
2292
+ const path = `/karadjordje/v1/minimax/${userId}/api/orgs/${organisationId}/employees`;
2293
+ return await this.client.post(path, employee);
2294
+ }
2295
+ async deleteEmployee(userId, organisationId, employeeId) {
2296
+ const path = `/karadjordje/v1/minimax/${userId}/api/orgs/${organisationId}/employees/${employeeId}`;
2297
+ return await this.client.delete(path);
2298
+ }
2299
+ async getEmployee(userId, organisationId, employeeId) {
2300
+ const path = `/karadjordje/v1/minimax/${userId}/api/orgs/${organisationId}/employees/${employeeId}`;
2301
+ return await this.client.get(path);
2302
+ }
2303
+ async updateEmployee(userId, organisationId, employee) {
2304
+ const path = `/karadjordje/v1/minimax/${userId}/api/orgs/${organisationId}/employees/${employee.EmployeeId}`;
2305
+ return await this.client.put(path, employee);
2306
+ }
2307
+ async getEmployeesForSync(userId, organisationId, params) {
2308
+ const path = `/karadjordje/v1/minimax/${userId}/api/orgs/${organisationId}/employees/synccandidates`;
2309
+ return await this.client.get(path, { params });
2310
+ }
2311
+ /** EXCHANGE RATES */
2312
+ async getExchangeRate(userId, organisationId, currencyId) {
2313
+ const path = `/karadjordje/v1/minimax/${userId}/api/orgs/${organisationId}/exchange-rates/${currencyId}`;
2314
+ return await this.client.get(path);
2315
+ }
2316
+ async getExchangeRateByCode(userId, organisationId, currencyCode) {
2317
+ const path = `/karadjordje/v1/minimax/${userId}/api/orgs/${organisationId}/exchange-rates/code(${currencyCode})`;
2318
+ return await this.client.get(path);
2319
+ }
2320
+ /** INBOX */
2321
+ async getInboxes(userId, organisationId, params) {
2322
+ const path = `/karadjordje/v1/minimax/${userId}/api/orgs/${organisationId}/inbox`;
2323
+ return await this.client.get(path, { params });
2324
+ }
2325
+ async newInbox(userId, organisationId, inbox) {
2326
+ const path = `/karadjordje/v1/minimax/${userId}/api/orgs/${organisationId}/inbox`;
2327
+ return await this.client.post(path, inbox);
2328
+ }
2329
+ async deleteInbox(userId, organisationId, inboxId) {
2330
+ const path = `/karadjordje/v1/minimax/${userId}/api/orgs/${organisationId}/inbox/${inboxId}`;
2331
+ return await this.client.delete(path);
2332
+ }
2333
+ async getInbox(userId, organisationId, inboxId) {
2334
+ const path = `/karadjordje/v1/minimax/${userId}/api/orgs/${organisationId}/inbox/${inboxId}`;
2335
+ return await this.client.get(path);
2336
+ }
2337
+ async newInboxAttachment(userId, organisationId, inboxId, inboxAttachment) {
2338
+ const path = `/karadjordje/v1/minimax/${userId}/api/orgs/${organisationId}/inbox/${inboxId}`;
2339
+ return await this.client.post(path, inboxAttachment);
2340
+ }
2341
+ async deleteInboxAttachment(userId, organisationId, inboxId, inboxAttachmentId) {
2342
+ const path = `/karadjordje/v1/minimax/${userId}/api/orgs/${organisationId}/inbox/${inboxId}/attachments/${inboxAttachmentId}`;
2343
+ return await this.client.delete(path);
2344
+ }
2345
+ async actionOnInbox(userId, organisationId, inboxId, action) {
2346
+ const path = `/karadjordje/v1/minimax/${userId}/api/orgs/${organisationId}/inbox/${inboxId}/actions/${action}`;
2347
+ return await this.client.put(path, {});
2348
+ }
2349
+ /** ISSUED INVOICE */
2350
+ async getIssuedInvoices(userId, organisationId, params) {
2351
+ const path = `/karadjordje/v1/minimax/${userId}/api/orgs/${organisationId}/issuedinvoices`;
2352
+ return await this.client.get(path, { params });
2353
+ }
2354
+ async newIssuedInvoice(userId, organisationId, issuedInvoice) {
2355
+ const path = `/karadjordje/v1/minimax/${userId}/api/orgs/${organisationId}/issuedinvoices`;
2356
+ return await this.client.post(path, issuedInvoice);
2357
+ }
2358
+ async deleteIssuedInvoice(userId, organisationId, issuedInvoiceId) {
2359
+ const path = `/karadjordje/v1/minimax/${userId}/api/orgs/${organisationId}/issuedinvoices/${issuedInvoiceId}`;
2360
+ return await this.client.delete(path);
2361
+ }
2362
+ async getIssuedInvoice(userId, organisationId, issuedInvoiceId) {
2363
+ const path = `/karadjordje/v1/minimax/${userId}/api/orgs/${organisationId}/issuedinvoices/${issuedInvoiceId}`;
2364
+ return await this.client.get(path);
2365
+ }
2366
+ async updateIssuedInvoice(userId, organisationId, issuedInvoice) {
2367
+ const path = `/karadjordje/v1/minimax/${userId}/api/orgs/${organisationId}/issuedinvoices/${issuedInvoice.IssuedInvoiceId}`;
2368
+ return await this.client.put(path, issuedInvoice);
2369
+ }
2370
+ async actionOnIssuedInvoice(userId, organisationId, issuedInvoiceId, action) {
2371
+ const path = `/karadjordje/v1/minimax/${userId}/api/orgs/${organisationId}/issuedinvoices/${issuedInvoiceId}/actions/${action}`;
2372
+ return await this.client.put(path, {});
2373
+ }
2374
+ async getIssuedInvoicesForSync(userId, organisationId, params) {
2375
+ const path = `/karadjordje/v1/minimax/${userId}/api/orgs/${organisationId}/issuedinvoices/synccandidates`;
2376
+ return await this.client.get(path, { params });
2377
+ }
2378
+ async getPaymentMethodsOnIssuedInvoices(userId, organisationId, params) {
2379
+ const path = `/karadjordje/v1/minimax/${userId}/api/orgs/${organisationId}/issuedinvoices/paymentmethods`;
2380
+ return await this.client.get(path, { params });
2381
+ }
2382
+ /** ISSUED INVOICE POSTING */
2383
+ async getIssuedInvoicePostings(userId, organisationId, params) {
2384
+ const path = `/karadjordje/v1/minimax/${userId}/api/orgs/${organisationId}/issuedinvoicepostings`;
2385
+ return await this.client.get(path, { params });
2386
+ }
2387
+ async newIssuedInvoicePosting(userId, organisationId, issuedInvoicePosting) {
2388
+ const path = `/karadjordje/v1/minimax/${userId}/api/orgs/${organisationId}/issuedinvoicepostings`;
2389
+ return await this.client.post(path, issuedInvoicePosting);
2390
+ }
2391
+ async deleteIssuedInvoicePosting(userId, organisationId, issuedInvoicePostingId) {
2392
+ const path = `/karadjordje/v1/minimax/${userId}/api/orgs/${organisationId}/issuedinvoicepostings/${issuedInvoicePostingId}`;
2393
+ return await this.client.delete(path);
2394
+ }
2395
+ async getIssuedInvoicePosting(userId, organisationId, issuedInvoicePostingId) {
2396
+ const path = `/karadjordje/v1/minimax/${userId}/api/orgs/${organisationId}/issuedinvoicepostings/${issuedInvoicePostingId}`;
2397
+ return await this.client.get(path);
2398
+ }
2399
+ async getPaymentMethodsOnIssuedInvoicePostings(userId, organisationId, params) {
2400
+ const path = `/karadjordje/v1/minimax/${userId}/api/orgs/${organisationId}/issuedinvoicepostings/paymentmethods`;
2401
+ return await this.client.get(path, { params });
2402
+ }
2403
+ async actionOnIssuedInvoicePosting(userId, organisationId, issuedInvoicePostingId, action) {
2404
+ const path = `/karadjordje/v1/minimax/${userId}/api/orgs/${organisationId}/issuedinvoicepostings/${issuedInvoicePostingId}/actions/${action}`;
2405
+ return await this.client.put(path, {});
2406
+ }
2407
+ /** ITEMS */
2408
+ async getItems(userId, organisationId, params) {
2409
+ const path = `/karadjordje/v1/minimax/${userId}/api/orgs/${organisationId}/items`;
2410
+ return await this.client.get(path, { params });
2411
+ }
2412
+ async newItem(userId, organisationId, item) {
2413
+ const path = `/karadjordje/v1/minimax/${userId}/api/orgs/${organisationId}/items`;
2414
+ return await this.client.post(path, item);
2415
+ }
2416
+ async deleteItem(userId, organisationId, itemId) {
2417
+ const path = `/karadjordje/v1/minimax/${userId}/api/orgs/${organisationId}/items/${itemId}`;
2418
+ return await this.client.delete(path);
2419
+ }
2420
+ async getItem(userId, organisationId, itemId) {
2421
+ const path = `/karadjordje/v1/minimax/${userId}/api/orgs/${organisationId}/items/${itemId}`;
2422
+ return await this.client.get(path);
2423
+ }
2424
+ async updateItem(userId, organisationId, item) {
2425
+ const path = `/karadjordje/v1/minimax/${userId}/api/orgs/${organisationId}/items/${item.ItemId}`;
2426
+ return await this.client.put(path, item);
2427
+ }
2428
+ async getItemByCode(userId, organisationId, code) {
2429
+ const path = `/karadjordje/v1/minimax/${userId}/api/orgs/${organisationId}/items/code(${code})`;
2430
+ return await this.client.get(path);
2431
+ }
2432
+ async getItemSettings(userId, organisationId, code) {
2433
+ const path = `/karadjordje/v1/minimax/${userId}/api/orgs/${organisationId}/items/settings`;
2434
+ return await this.client.get(path);
2435
+ }
2436
+ async getItemData(userId, organisationId, params) {
2437
+ const path = `/karadjordje/v1/minimax/${userId}/api/orgs/${organisationId}/items/itemsdata`;
2438
+ return await this.client.get(path, { params });
2439
+ }
2440
+ async getItemPricelist(userId, organisationId, params) {
2441
+ const path = `/karadjordje/v1/minimax/${userId}/api/orgs/${organisationId}/items/pricelists`;
2442
+ return await this.client.get(path, { params });
2443
+ }
2444
+ async getItemsForSync(userId, organisationId, params) {
2445
+ const path = `/karadjordje/v1/minimax/${userId}/api/orgs/${organisationId}/items/synccandidates`;
2446
+ return await this.client.get(path, { params });
2447
+ }
2448
+ /** JOURNALS */
2449
+ async getJournals(userId, organisationId, params) {
2450
+ const path = `/karadjordje/v1/minimax/${userId}/api/orgs/${organisationId}/journals`;
2451
+ return await this.client.get(path, { params });
2452
+ }
2453
+ async newJournal(userId, organisationId, journal) {
2454
+ const path = `/karadjordje/v1/minimax/${userId}/api/orgs/${organisationId}/journals`;
2455
+ return await this.client.post(path, journal);
2456
+ }
2457
+ async deleteJournal(userId, organisationId, journalId) {
2458
+ const path = `/karadjordje/v1/minimax/${userId}/api/orgs/${organisationId}/journals/${journalId}`;
2459
+ return await this.client.delete(path);
2460
+ }
2461
+ async getJournal(userId, organisationId, journalId) {
2462
+ const path = `/karadjordje/v1/minimax/${userId}/api/orgs/${organisationId}/journals/${journalId}`;
2463
+ return await this.client.get(path);
2464
+ }
2465
+ async updateJournal(userId, organisationId, journal) {
2466
+ const path = `/karadjordje/v1/minimax/${userId}/api/orgs/${organisationId}/journals/${journal.JournalId}`;
2467
+ return await this.client.put(path, journal);
2468
+ }
2469
+ async deleteJournalVatEntry(userId, organisationId, journalId, vatId) {
2470
+ const path = `/karadjordje/v1/minimax/${userId}/api/orgs/${organisationId}/journals/${journalId}/vat/${vatId}`;
2471
+ return await this.client.delete(path);
2472
+ }
2473
+ async getJournalVatEntry(userId, organisationId, journalId, vatId) {
2474
+ const path = `/karadjordje/v1/minimax/${userId}/api/orgs/${organisationId}/journals/${journalId}/vat/${vatId}`;
2475
+ return await this.client.get(path);
2476
+ }
2477
+ async updateJournalVatEntry(userId, organisationId, journalId, vatEntry) {
2478
+ const path = `/karadjordje/v1/minimax/${userId}/api/orgs/${organisationId}/journals/${journalId}/vat/${vatEntry.VatEntryId}`;
2479
+ return await this.client.put(path, vatEntry);
2480
+ }
2481
+ async newJournalVatEntry(userId, organisationId, journalId, vatEntry) {
2482
+ const path = `/karadjordje/v1/minimax/${userId}/api/orgs/${organisationId}/journals/${journalId}/vat`;
2483
+ return await this.client.post(path, vatEntry);
2484
+ }
2485
+ async getJournalsForSync(userId, organisationId, params) {
2486
+ const path = `/karadjordje/v1/minimax/${userId}/api/orgs/${organisationId}/journals/synccandidates`;
2487
+ return await this.client.get(path, { params });
2488
+ }
2489
+ async getJournalsInVODStandard(userId, organisationId, params) {
2490
+ const path = `/karadjordje/v1/minimax/${userId}/api/orgs/${organisationId}/journals/vodstandard`;
2491
+ return await this.client.get(path, { params });
2492
+ }
2493
+ async getJournalEntries(userId, organisationId, params) {
2494
+ const path = `/karadjordje/v1/minimax/${userId}/api/orgs/${organisationId}/journals/journal-entries`;
2495
+ return await this.client.get(path, { params });
2496
+ }
2497
+ /** JOURNAL TYPES */
2498
+ async getJournalTypes(userId, organisationId, params) {
2499
+ const path = `/karadjordje/v1/minimax/${userId}/api/orgs/${organisationId}/journaltypes`;
2500
+ return await this.client.get(path, { params });
2501
+ }
2502
+ async getJournalType(userId, organisationId, journalTypeId) {
2503
+ const path = `/karadjordje/v1/minimax/${userId}/api/orgs/${organisationId}/journaltypes/${journalTypeId}`;
2504
+ return await this.client.get(path);
2505
+ }
2506
+ async getJournalTypeByCode(userId, organisationId, code) {
2507
+ const path = `/karadjordje/v1/minimax/${userId}/api/orgs/${organisationId}/journaltypes/code(${code})`;
2508
+ return await this.client.get(path);
2509
+ }
2510
+ async getJournalTypesForSync(userId, organisationId, params) {
2511
+ const path = `/karadjordje/v1/minimax/${userId}/api/orgs/${organisationId}/journaltypes/synccandidates`;
2512
+ return await this.client.get(path, { params });
2513
+ }
2514
+ /** ORDERS */
2515
+ async getOrders(userId, organisationId, params) {
2516
+ const path = `/karadjordje/v1/minimax/${userId}/api/orgs/${organisationId}/orders`;
2517
+ return await this.client.get(path, { params });
2518
+ }
2519
+ async newOrder(userId, organisationId, order) {
2520
+ const path = `/karadjordje/v1/minimax/${userId}/api/orgs/${organisationId}/orders`;
2521
+ return await this.client.post(path, order);
2522
+ }
2523
+ async deleteOrder(userId, organisationId, orderId) {
2524
+ const path = `/karadjordje/v1/minimax/${userId}/api/orgs/${organisationId}/orders/${orderId}`;
2525
+ return await this.client.delete(path);
2526
+ }
2527
+ async getOrder(userId, organisationId, orderId) {
2528
+ const path = `/karadjordje/v1/minimax/${userId}/api/orgs/${organisationId}/orders/${orderId}`;
2529
+ return await this.client.get(path);
2530
+ }
2531
+ async updateOrder(userId, organisationId, order) {
2532
+ const path = `/karadjordje/v1/minimax/${userId}/api/orgs/${organisationId}/orders/${order.OrderId}`;
2533
+ return await this.client.put(path, order);
2534
+ }
2535
+ async actionGetOnOrder(userId, organisationId, orderId, action, params) {
2536
+ const path = `/karadjordje/v1/minimax/${userId}/api/orgs/${organisationId}/orders/${orderId}/actions/${action}`;
2537
+ return await this.client.get(path, { params });
2538
+ }
2539
+ async actionPutOnOrder(userId, organisationId, orderId, action, params) {
2540
+ const path = `/karadjordje/v1/minimax/${userId}/api/orgs/${organisationId}/orders/${orderId}/actions/${action}`;
2541
+ return await this.client.put(path, {}, { params });
2542
+ }
2543
+ async getOrdersForSync(userId, organisationId, params) {
2544
+ const path = `/karadjordje/v1/minimax/${userId}/api/orgs/${organisationId}/orders/synccandidates`;
2545
+ return await this.client.get(path, { params });
2546
+ }
2547
+ /** ORGANISATIONS */
2548
+ async getOrganisation(userId, organisationId) {
2549
+ const path = `/karadjordje/v1/minimax/${userId}/api/orgs/${organisationId}`;
2550
+ return await this.client.get(path);
2551
+ }
2552
+ async getAllOrganisations(userId, params) {
2553
+ const path = `/karadjordje/v1/minimax/${userId}/api/orgs/allOrgs`;
2554
+ return await this.client.get(path, { params });
2555
+ }
2556
+ /** OUTBOX */
2557
+ async getAllOuboxes(userId, organisationId, params) {
2558
+ const path = `/karadjordje/v1/minimax/${userId}/api/orgs/${organisationId}/outbox`;
2559
+ return await this.client.get(path, { params });
2560
+ }
2561
+ async getOutbox(userId, organisationId, outboxId) {
2562
+ const path = `/karadjordje/v1/minimax/${userId}/api/orgs/${organisationId}/outbox/${outboxId}`;
2563
+ return await this.client.get(path);
2564
+ }
2565
+ /** PAYMENT METHODS */
2566
+ async getPaymentMethods(userId, organisationId, params) {
2567
+ const path = `/karadjordje/v1/minimax/${userId}/api/orgs/${organisationId}/paymentmethods`;
2568
+ return await this.client.get(path, { params });
2569
+ }
2570
+ /** PAYROLL SETTINGS */
2571
+ async getPayrollSettingsByCode(userId, code) {
2572
+ const path = `/karadjordje/v1/minimax/${userId}/api/payrollsettings/${code}`;
2573
+ return await this.client.get(path);
2574
+ }
2575
+ /** POSTAL CODE */
2576
+ async getPostalCodesByCountry(userId, organisationId, countryId, params) {
2577
+ const path = `/karadjordje/v1/minimax/${userId}/api/orgs/${organisationId}/postalcodes/countries/${countryId}`;
2578
+ return await this.client.get(path, { params });
2579
+ }
2580
+ async getPostalCode(userId, organisationId, postalCodeId) {
2581
+ const path = `/karadjordje/v1/minimax/${userId}/api/orgs/${organisationId}/postalcodes/${postalCodeId}`;
2582
+ return await this.client.get(path);
2583
+ }
2584
+ async getPostalCodesForSync(userId, organisationId, params) {
2585
+ const path = `/karadjordje/v1/minimax/${userId}/api/orgs/${organisationId}/postalcodes/synccandidates`;
2586
+ return await this.client.get(path, { params });
2587
+ }
2588
+ /** PRODUCT GROUPS */
2589
+ async getProductGroups(userId, organisationId, params) {
2590
+ const path = `/karadjordje/v1/minimax/${userId}/api/orgs/${organisationId}/productGroups`;
2591
+ return await this.client.get(path, { params });
2592
+ }
2593
+ async newProductGroup(userId, organisationId, productGroup) {
2594
+ const path = `/karadjordje/v1/minimax/${userId}/api/orgs/${organisationId}/productGroups`;
2595
+ return await this.client.post(path, productGroup);
2596
+ }
2597
+ async deleteProductGroup(userId, organisationId, productGroupId) {
2598
+ const path = `/karadjordje/v1/minimax/${userId}/api/orgs/${organisationId}/productGroups/${productGroupId}`;
2599
+ return await this.client.delete(path);
2600
+ }
2601
+ async getProductGroup(userId, organisationId, productGroupId) {
2602
+ const path = `/karadjordje/v1/minimax/${userId}/api/orgs/${organisationId}/productGroups/${productGroupId}`;
2603
+ return await this.client.get(path);
2604
+ }
2605
+ async updateProductGroup(userId, organisationId, productGroup) {
2606
+ const path = `/karadjordje/v1/minimax/${userId}/api/orgs/${organisationId}/productGroups/${productGroup.ProductGroupId}`;
2607
+ return await this.client.put(path, productGroup);
2608
+ }
2609
+ async getProductGroupsForSync(userId, organisationId, params) {
2610
+ const path = `/karadjordje/v1/minimax/${userId}/api/orgs/${organisationId}/productGroups/synccandidates`;
2611
+ return await this.client.get(path, { params });
2612
+ }
2613
+ /** PURPOSE CODE */
2614
+ async getPurposeCodes(userId, organisationId, params) {
2615
+ const path = `/karadjordje/v1/minimax/${userId}/api/orgs/${organisationId}/purpose-codes`;
2616
+ return await this.client.get(path, { params });
2617
+ }
2618
+ async getPurposeCode(userId, organisationId, purposeCodeId) {
2619
+ const path = `/karadjordje/v1/minimax/${userId}/api/orgs/${organisationId}/purpose-codes/${purposeCodeId}`;
2620
+ return await this.client.get(path);
2621
+ }
2622
+ async getPurposeCodeByCode(userId, organisationId, code) {
2623
+ const path = `/karadjordje/v1/minimax/${userId}/api/orgs/${organisationId}/purpose-codes/code(${code})`;
2624
+ return await this.client.get(path);
2625
+ }
2626
+ async getPurposeCodesForSync(userId, organisationId, params) {
2627
+ const path = `/karadjordje/v1/minimax/${userId}/api/orgs/${organisationId}/purpose-codes/synccandidates`;
2628
+ return await this.client.get(path, { params });
2629
+ }
2630
+ /** RECEIVED INVOICES */
2631
+ async deleteReceivedInvoice(userId, organisationId, receivedInvoiceId) {
2632
+ const path = `/karadjordje/v1/minimax/${userId}/api/orgs/${organisationId}/receivedinvoices/${receivedInvoiceId}`;
2633
+ return await this.client.delete(path);
2634
+ }
2635
+ async getReceivedInvoice(userId, organisationId, receivedInvoiceId) {
2636
+ const path = `/karadjordje/v1/minimax/${userId}/api/orgs/${organisationId}/receivedinvoices/${receivedInvoiceId}`;
2637
+ return await this.client.get(path);
2638
+ }
2639
+ async updateReceivedInvoice(userId, organisationId, receivedInvoice) {
2640
+ const path = `/karadjordje/v1/minimax/${userId}/api/orgs/${organisationId}/receivedinvoices/${receivedInvoice.ReceivedInvoiceId}`;
2641
+ return await this.client.put(path, receivedInvoice);
2642
+ }
2643
+ async getReceivedInvoices(userId, organisationId, params) {
2644
+ const path = `/karadjordje/v1/minimax/${userId}/api/orgs/${organisationId}/receivedinvoices`;
2645
+ return await this.client.get(path, { params });
2646
+ }
2647
+ async newReceivedInvoice(userId, organisationId, receivedInvoice) {
2648
+ const path = `/karadjordje/v1/minimax/${userId}/api/orgs/${organisationId}/receivedinvoices`;
2649
+ return await this.client.post(path, receivedInvoice);
2650
+ }
2651
+ async getReceivedInvoicesAttachments(userId, organisationId, receivedInvoiceId, params) {
2652
+ const path = `/karadjordje/v1/minimax/${userId}/api/orgs/${organisationId}/receivedinvoices/${receivedInvoiceId}/attachments`;
2653
+ return await this.client.get(path, { params });
2654
+ }
2655
+ async newReceivedInvoiceAttachment(userId, organisationId, receivedInvoiceId, attachment) {
2656
+ const path = `/karadjordje/v1/minimax/${userId}/api/orgs/${organisationId}/receivedinvoices/${receivedInvoiceId}/attachments`;
2657
+ return await this.client.post(path, attachment);
2658
+ }
2659
+ /** REPORT TEMPLATES */
2660
+ async getReportTemplates(userId, organisationId, params) {
2661
+ const path = `/karadjordje/v1/minimax/${userId}/api/orgs/${organisationId}/report-templates`;
2662
+ return await this.client.get(path, { params });
2663
+ }
2664
+ async getReportTemplate(userId, organisationId, reportTemplateId) {
2665
+ const path = `/karadjordje/v1/minimax/${userId}/api/orgs/${organisationId}/report-templates/${reportTemplateId}`;
2666
+ return await this.client.get(path);
2667
+ }
2668
+ async getReportTemplatesForSync(userId, organisationId, params) {
2669
+ const path = `/karadjordje/v1/minimax/${userId}/api/orgs/${organisationId}/report-templates/synccandidates`;
2670
+ return await this.client.get(path, { params });
2671
+ }
2672
+ /** STOCK */
2673
+ async getStock(userId, organisationId, params) {
2674
+ const path = `/karadjordje/v1/minimax/${userId}/api/orgs/${organisationId}/stocks`;
2675
+ return await this.client.get(path, { params });
2676
+ }
2677
+ async getStockForItem(userId, organisationId, itemId) {
2678
+ const path = `/karadjordje/v1/minimax/${userId}/api/orgs/${organisationId}/stocks/${itemId}`;
2679
+ return await this.client.get(path);
2680
+ }
2681
+ /** STOCK ENTRIES */
2682
+ async getStockEntries(userId, organisationId, params) {
2683
+ const path = `/karadjordje/v1/minimax/${userId}/api/orgs/${organisationId}/stockentry`;
2684
+ return await this.client.get(path, { params });
2685
+ }
2686
+ async newStockEntry(userId, organisationId, stockEntry) {
2687
+ const path = `/karadjordje/v1/minimax/${userId}/api/orgs/${organisationId}/stockentry`;
2688
+ return await this.client.post(path, stockEntry);
2689
+ }
2690
+ async deleteStockEntry(userId, organisationId, stockEntryId) {
2691
+ const path = `/karadjordje/v1/minimax/${userId}/api/orgs/${organisationId}/stockentry/${stockEntryId}`;
2692
+ return await this.client.delete(path);
2693
+ }
2694
+ async getStockEntry(userId, organisationId, stockEntryId) {
2695
+ const path = `/karadjordje/v1/minimax/${userId}/api/orgs/${organisationId}/stockentry/${stockEntryId}`;
2696
+ return await this.client.get(path);
2697
+ }
2698
+ async updateStockEntry(userId, organisationId, stockEntry) {
2699
+ const path = `/karadjordje/v1/minimax/${userId}/api/orgs/${organisationId}/stockentry/${stockEntry.StockEntryId}`;
2700
+ return await this.client.post(path, stockEntry);
2701
+ }
2702
+ async actionGetOnStockEntry(userId, organisationId, stockEntryId, action, params) {
2703
+ const path = `/karadjordje/v1/minimax/${userId}/api/orgs/${organisationId}/stockentry/${stockEntryId}/actions/${action}`;
2704
+ return await this.client.get(path, { params });
2705
+ }
2706
+ async actionPutOnStockEntry(userId, organisationId, stockEntryId, action, params) {
2707
+ const path = `/karadjordje/v1/minimax/${userId}/api/orgs/${organisationId}/stockentry/${stockEntryId}/actions/${action}`;
2708
+ return await this.client.put(path, {}, { params });
2709
+ }
2710
+ /** USERS */
2711
+ async getCurrentUser(userId) {
2712
+ const path = `/karadjordje/v1/minimax/${userId}/api/currentuser/profile`;
2713
+ return await this.client.get(path);
2714
+ }
2715
+ async getCurrentUserOrgs(userId) {
2716
+ const path = `/karadjordje/v1/minimax/${userId}/api/currentuser/orgs`;
2717
+ return await this.client.get(path);
2718
+ }
2719
+ /** VAT ACCOUNTING TYPES */
2720
+ async getVatAccountingTypes(userId, organisationId, params) {
2721
+ const path = `/karadjordje/v1/minimax/${userId}/api/orgs/${organisationId}/vataccountingtypes`;
2722
+ return await this.client.get(path, { params });
2723
+ }
2724
+ async getVatAccountingTypesForSync(userId, organisationId, params) {
2725
+ const path = `/karadjordje/v1/minimax/${userId}/api/orgs/${organisationId}/vataccountingtypes/synccandidates`;
2726
+ return await this.client.get(path, { params });
2727
+ }
2728
+ /** VAT RATES */
2729
+ async getVatRates(userId, organisationId, params) {
2730
+ const path = `/karadjordje/v1/minimax/${userId}/api/orgs/${organisationId}/vatrates`;
2731
+ return await this.client.get(path, { params });
2732
+ }
2733
+ async getVatRate(userId, organisationId, vatRateId) {
2734
+ const path = `/karadjordje/v1/minimax/${userId}/api/orgs/${organisationId}/vatrates/${vatRateId}`;
2735
+ return await this.client.get(path);
2736
+ }
2737
+ async getVatRateByCode(userId, organisationId, code) {
2738
+ const path = `/karadjordje/v1/minimax/${userId}/api/orgs/${organisationId}/vatrates/code(${code})`;
2739
+ return await this.client.get(path);
2740
+ }
2741
+ async getVatRatesForSync(userId, organisationId, params) {
2742
+ const path = `/karadjordje/v1/minimax/${userId}/api/orgs/${organisationId}/vatrates/synccandidates`;
2743
+ return await this.client.get(path, { params });
2744
+ }
2745
+ /** WAREHOUSES */
2746
+ async getWarehouses(userId, organisationId, params) {
2747
+ const path = `/karadjordje/v1/minimax/${userId}/api/orgs/${organisationId}/warehouses`;
2748
+ return await this.client.get(path, { params });
2749
+ }
2750
+ async newWarehouse(userId, organisationId, warehouse) {
2751
+ const path = `/karadjordje/v1/minimax/${userId}/api/orgs/${organisationId}/warehouses`;
2752
+ return await this.client.post(path, warehouse);
2753
+ }
2754
+ async deleteWarehouse(userId, organisationId, warehouseId) {
2755
+ const path = `/karadjordje/v1/minimax/${userId}/api/orgs/${organisationId}/warehouses/${warehouseId}`;
2756
+ return await this.client.delete(path);
2757
+ }
2758
+ async getWarehouse(userId, organisationId, warehouseId) {
2759
+ const path = `/karadjordje/v1/minimax/${userId}/api/orgs/${organisationId}/warehouses/${warehouseId}`;
2760
+ return await this.client.get(path);
2761
+ }
2762
+ async updateWarehouse(userId, organisationId, warehouse) {
2763
+ const path = `/karadjordje/v1/minimax/${userId}/api/orgs/${organisationId}/warehouses/${warehouse.WarehouseId}`;
2764
+ return await this.client.put(path, warehouse);
2765
+ }
2766
+ async getWarehousesForSync(userId, organisationId, params) {
2767
+ const path = `/karadjordje/v1/minimax/${userId}/api/orgs/${organisationId}/warehouses/synccandidates`;
2768
+ return await this.client.get(path, { params });
2769
+ }
2770
+ }
2771
+
2772
+ // import integrations
2773
+ class Integrations extends IntegrationsBaseClient {
2774
+ constructor(options) {
2775
+ super(options);
2776
+ this.integrations = {
2777
+ 'protokol-invoicing': new Invoicing().setClient(this.client),
2778
+ 'protokol-vpfr': new VPFR().setClient(this.client),
2779
+ 'protokol-dms': new DMS().setClient(this.client),
2780
+ 'serbia-utilities': new SerbiaUtil().setClient(this.client),
2781
+ 'protokol-payments': new Payments().setClient(this.client),
2782
+ 'protokol-minimax': new Minimax().setClient(this.client),
2783
+ };
2784
+ }
2785
+ getSerbiaUtilities() {
2786
+ return this.getInterfaceOf('serbia-utilities');
2787
+ }
2788
+ getDMS() {
2789
+ return this.getInterfaceOf('protokol-dms');
2790
+ }
2791
+ getVPFR() {
2792
+ return this.getInterfaceOf('protokol-vpfr');
2793
+ }
2794
+ getInvoicing() {
2795
+ return this.getInterfaceOf('protokol-invoicing');
2796
+ }
2797
+ getPayments() {
2798
+ return this.getInterfaceOf('protokol-payments');
2799
+ }
2800
+ getMinimax() {
2801
+ return this.getInterfaceOf('protokol-minimax');
2802
+ }
2803
+ async isInstalled(id) {
2804
+ const { data } = await this.client.get("/v1/integrations");
2805
+ return data.find((i) => i.id == id) !== undefined;
2806
+ }
2807
+ getInterfaceOf(id) {
2808
+ try {
2809
+ return this.integrations[id];
2810
+ }
2811
+ catch {
2812
+ throw new Error(`Interface ${id} not provided`);
2813
+ }
2814
+ }
2815
+ }
2816
+
2817
+ // API v0.9
2818
+ // Export all API modules for version 0.9
2819
+ // This version has specific method signatures and behaviors for v0.9
2820
+
2821
+ exports.APIUser = APIUser;
2822
+ exports.Apps = Apps;
2823
+ exports.Component = Component;
2824
+ exports.ComponentUtils = ComponentUtils;
2825
+ exports.Config = Config;
2826
+ exports.DMS = DMS;
2827
+ exports.Forge = Forge;
2828
+ exports.Functions = Functions;
2829
+ exports.Integration = Integrations;
2830
+ exports.Integrations = Integrations;
2831
+ exports.Invoicing = Invoicing;
2832
+ exports.Payments = Payments;
2833
+ exports.Platform = Platform;
2834
+ exports.Project = Project;
2835
+ exports.Ratchet = Ratchet;
2836
+ exports.Sandbox = Sandbox;
2837
+ exports.SerbiaUtil = SerbiaUtil;
2838
+ exports.System = System;
2839
+ exports.Thunder = Thunder;
2840
+ exports.Users = Users;
2841
+ exports.VPFR = VPFR;
2842
+ exports.Workflow = Workflow;
2843
+ exports.default = Platform;
2844
+
2845
+ Object.defineProperty(exports, '__esModule', { value: true });
2846
+
2847
+ return exports;
2848
+
2849
+ })({}, axiosAdapter);