@ptkl/sdk 0.10.2 → 1.0.0

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