@ptkl/sdk 1.1.0 → 1.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.0.10.js +308 -30
- package/dist/index.0.9.js +93 -4
- package/dist/package.json +1 -1
- package/dist/v0.10/api/component.d.ts +149 -13
- package/dist/v0.10/api/functions.d.ts +1 -2
- package/dist/v0.10/api/index.d.ts +1 -0
- package/dist/v0.10/api/integrations/dms.d.ts +0 -9
- package/dist/v0.10/api/integrations/mail.d.ts +125 -0
- package/dist/v0.10/api/integrations.d.ts +2 -0
- package/dist/v0.10/api/platformBaseClient.d.ts +0 -1
- package/dist/v0.10/api/project.d.ts +1 -1
- package/dist/v0.10/index.cjs.js +308 -30
- package/dist/v0.10/index.esm.js +308 -31
- package/dist/v0.10/types/component.d.ts +71 -1
- package/dist/v0.10/types/integrations/mail.d.ts +156 -0
- package/dist/v0.9/api/functions.d.ts +1 -2
- package/dist/v0.9/api/index.d.ts +1 -0
- package/dist/v0.9/api/integrations/mail.d.ts +69 -0
- package/dist/v0.9/api/integrations.d.ts +2 -0
- package/dist/v0.9/api/platformBaseClient.d.ts +0 -1
- package/dist/v0.9/api/project.d.ts +1 -1
- package/dist/v0.9/index.cjs.js +93 -4
- package/dist/v0.9/index.esm.js +93 -5
- package/dist/v0.9/types/integrations/mail.d.ts +155 -0
- package/package.json +1 -1
package/dist/v0.10/index.esm.js
CHANGED
|
@@ -24,7 +24,6 @@ const isSandbox = typeof window !== "undefined";
|
|
|
24
24
|
*
|
|
25
25
|
* @class PlatformBaseClient
|
|
26
26
|
* @extends BaseClient
|
|
27
|
-
* @constructor
|
|
28
27
|
* @param {AxiosInstance} [client] - The axios instance to use for the client
|
|
29
28
|
*
|
|
30
29
|
* @example
|
|
@@ -145,12 +144,6 @@ class Component extends PlatformBaseClient {
|
|
|
145
144
|
dateTo: ctx.dateTo,
|
|
146
145
|
dateField: ctx.dateField,
|
|
147
146
|
};
|
|
148
|
-
if (Object.keys(ctx.$adv || []).length > 0) {
|
|
149
|
-
params.$adv = JSON.stringify([ctx.$adv]);
|
|
150
|
-
}
|
|
151
|
-
if (ctx.$aggregate && ctx.$aggregate.length > 0) {
|
|
152
|
-
params.$aggregate = JSON.stringify(ctx.$aggregate);
|
|
153
|
-
}
|
|
154
147
|
return await this.client.post(`/v4/system/component/${this.ref}/models`, {
|
|
155
148
|
...params,
|
|
156
149
|
options: opts
|
|
@@ -195,9 +188,26 @@ class Component extends PlatformBaseClient {
|
|
|
195
188
|
/**
|
|
196
189
|
* Update model by uuid
|
|
197
190
|
*
|
|
198
|
-
*
|
|
199
|
-
*
|
|
200
|
-
*
|
|
191
|
+
* Regular fields in `data` are applied via `$set`. You can include MongoDB
|
|
192
|
+
* update operators (prefixed with `$`) directly in the data object for
|
|
193
|
+
* granular updates like incrementing, pushing to arrays, etc.
|
|
194
|
+
*
|
|
195
|
+
* @param uuid - The uuid of the model to update
|
|
196
|
+
* @param data - Fields to update, optionally including update operators
|
|
197
|
+
* @param options - Update options
|
|
198
|
+
* @returns The updated model
|
|
199
|
+
*
|
|
200
|
+
* @example
|
|
201
|
+
* // Simple update (backwards compatible)
|
|
202
|
+
* await component.update(uuid, { name: "John" }, opts)
|
|
203
|
+
*
|
|
204
|
+
* // With update operators
|
|
205
|
+
* await component.update(uuid, {
|
|
206
|
+
* name: "John",
|
|
207
|
+
* $inc: { login_count: 1 },
|
|
208
|
+
* $push: { tags: "verified" },
|
|
209
|
+
* $addToSet: { roles: "admin" }
|
|
210
|
+
* }, opts)
|
|
201
211
|
*/
|
|
202
212
|
async update(uuid, data, options) {
|
|
203
213
|
return await this.client.post(`/v4/system/component/${this.ref}/model/${uuid}`, {
|
|
@@ -234,9 +244,20 @@ class Component extends PlatformBaseClient {
|
|
|
234
244
|
/**
|
|
235
245
|
* Modify models by filters
|
|
236
246
|
*
|
|
237
|
-
*
|
|
238
|
-
*
|
|
239
|
-
*
|
|
247
|
+
* Updates all models matching the given filters. Supports inline update
|
|
248
|
+
* operators in the data payload for granular operations.
|
|
249
|
+
*
|
|
250
|
+
* @param filters - Query filters to match models
|
|
251
|
+
* @param data - Fields to update, optionally including update operators
|
|
252
|
+
* @param options - Modify options (e.g. upsert)
|
|
253
|
+
* @returns The modified models
|
|
254
|
+
*
|
|
255
|
+
* @example
|
|
256
|
+
* await component.modify(
|
|
257
|
+
* { status: "active" },
|
|
258
|
+
* { $inc: { impression_count: 1 }, $addToSet: { viewers: "user-1" } },
|
|
259
|
+
* { upsert: false }
|
|
260
|
+
* )
|
|
240
261
|
*/
|
|
241
262
|
async modify(filters, data, options) {
|
|
242
263
|
return await this.client.patch(`/v4/system/component/${this.ref}/modify/model`, {
|
|
@@ -246,12 +267,23 @@ class Component extends PlatformBaseClient {
|
|
|
246
267
|
});
|
|
247
268
|
}
|
|
248
269
|
/**
|
|
249
|
-
* Concurrent update model by uuid
|
|
270
|
+
* Concurrent update model by uuid with optimistic locking
|
|
250
271
|
*
|
|
251
|
-
*
|
|
252
|
-
*
|
|
253
|
-
*
|
|
254
|
-
*
|
|
272
|
+
* Uses version-based concurrency control — the update will fail with a
|
|
273
|
+
* conflict error if the document has been modified since the provided version.
|
|
274
|
+
* Supports inline update operators in the data payload.
|
|
275
|
+
*
|
|
276
|
+
* @param uuid - The uuid of the model
|
|
277
|
+
* @param version - The expected __version__ of the model
|
|
278
|
+
* @param data - Fields to update, optionally including update operators
|
|
279
|
+
* @param options - Update options
|
|
280
|
+
* @returns The updated model
|
|
281
|
+
*
|
|
282
|
+
* @example
|
|
283
|
+
* await component.concurrentUpdate(uuid, model.__version__, {
|
|
284
|
+
* status: "processed",
|
|
285
|
+
* $inc: { retry_count: 1 }
|
|
286
|
+
* }, opts)
|
|
255
287
|
*/
|
|
256
288
|
async concurrentUpdate(uuid, version, data, options) {
|
|
257
289
|
return await this.client.post(`/v4/system/component/${this.ref}/model/${uuid}`, {
|
|
@@ -372,6 +404,115 @@ class Component extends PlatformBaseClient {
|
|
|
372
404
|
async revisions(uuid) {
|
|
373
405
|
return await this.client.get(`/v3/system/component/${this.ref}/model/${uuid}/revisions`);
|
|
374
406
|
}
|
|
407
|
+
/**
|
|
408
|
+
* Install a new extension on the component
|
|
409
|
+
*
|
|
410
|
+
* @param extension - The extension definition to install
|
|
411
|
+
* @param version - The component version to install the extension on
|
|
412
|
+
* @returns Updated component settings
|
|
413
|
+
*
|
|
414
|
+
* @example
|
|
415
|
+
* ```typescript
|
|
416
|
+
* await component.installExtension({
|
|
417
|
+
* name: 'shipping_tracker',
|
|
418
|
+
* is_active: true,
|
|
419
|
+
* fields: [...],
|
|
420
|
+
* config: { api_key: 'key' }
|
|
421
|
+
* }, '0.1.0')
|
|
422
|
+
* ```
|
|
423
|
+
*/
|
|
424
|
+
async installExtension(extension, version) {
|
|
425
|
+
return await this.client.post(`/v4/system/component/${this.ref}/${version}/extensions`, extension);
|
|
426
|
+
}
|
|
427
|
+
/**
|
|
428
|
+
* Update an existing extension on the component
|
|
429
|
+
*
|
|
430
|
+
* @param name - The name of the extension to update
|
|
431
|
+
* @param version - The component version
|
|
432
|
+
* @param data - Partial extension data to update
|
|
433
|
+
* @returns Updated component settings
|
|
434
|
+
*
|
|
435
|
+
* @example
|
|
436
|
+
* ```typescript
|
|
437
|
+
* await component.updateExtension('shipping_tracker', '0.1.0', {
|
|
438
|
+
* is_active: false,
|
|
439
|
+
* config: { api_key: 'new-key' }
|
|
440
|
+
* })
|
|
441
|
+
* ```
|
|
442
|
+
*/
|
|
443
|
+
async updateExtension(name, version, data) {
|
|
444
|
+
return await this.client.patch(`/v4/system/component/${this.ref}/${version}/extensions/${name}`, data);
|
|
445
|
+
}
|
|
446
|
+
/**
|
|
447
|
+
* Delete an extension from the component
|
|
448
|
+
*
|
|
449
|
+
* @param name - The name of the extension to delete
|
|
450
|
+
* @param version - The component version
|
|
451
|
+
* @returns Updated component settings
|
|
452
|
+
*
|
|
453
|
+
* @example
|
|
454
|
+
* ```typescript
|
|
455
|
+
* await component.deleteExtension('shipping_tracker', '0.1.0')
|
|
456
|
+
* ```
|
|
457
|
+
*/
|
|
458
|
+
async deleteExtension(name, version) {
|
|
459
|
+
return await this.client.delete(`/v4/system/component/${this.ref}/${version}/extensions/${name}`);
|
|
460
|
+
}
|
|
461
|
+
/**
|
|
462
|
+
* Install a new policy on the component
|
|
463
|
+
*
|
|
464
|
+
* @param policy - The policy definition to install
|
|
465
|
+
* @param version - The component version to install the policy on
|
|
466
|
+
* @returns Updated component settings
|
|
467
|
+
*
|
|
468
|
+
* @example
|
|
469
|
+
* ```typescript
|
|
470
|
+
* await component.installPolicy({
|
|
471
|
+
* type: 'field_access',
|
|
472
|
+
* name: 'restrict_email',
|
|
473
|
+
* enabled: true,
|
|
474
|
+
* priority: 1,
|
|
475
|
+
* config: { fields: ['email'], actions: ['see'], roles: ['role-uuid'] }
|
|
476
|
+
* }, '0.1.0')
|
|
477
|
+
* ```
|
|
478
|
+
*/
|
|
479
|
+
async installPolicy(policy, version) {
|
|
480
|
+
return await this.client.post(`/v4/system/component/${this.ref}/${version}/policies`, policy);
|
|
481
|
+
}
|
|
482
|
+
/**
|
|
483
|
+
* Update an existing policy on the component
|
|
484
|
+
*
|
|
485
|
+
* @param name - The name of the policy to update
|
|
486
|
+
* @param version - The component version
|
|
487
|
+
* @param data - Partial policy data to update
|
|
488
|
+
* @returns Updated component settings
|
|
489
|
+
*
|
|
490
|
+
* @example
|
|
491
|
+
* ```typescript
|
|
492
|
+
* await component.updatePolicy('restrict_email', '0.1.0', {
|
|
493
|
+
* enabled: false,
|
|
494
|
+
* priority: 2
|
|
495
|
+
* })
|
|
496
|
+
* ```
|
|
497
|
+
*/
|
|
498
|
+
async updatePolicy(name, version, data) {
|
|
499
|
+
return await this.client.patch(`/v4/system/component/${this.ref}/${version}/policies/${name}`, data);
|
|
500
|
+
}
|
|
501
|
+
/**
|
|
502
|
+
* Delete a policy from the component
|
|
503
|
+
*
|
|
504
|
+
* @param name - The name of the policy to delete
|
|
505
|
+
* @param version - The component version
|
|
506
|
+
* @returns Updated component settings
|
|
507
|
+
*
|
|
508
|
+
* @example
|
|
509
|
+
* ```typescript
|
|
510
|
+
* await component.deletePolicy('restrict_email', '0.1.0')
|
|
511
|
+
* ```
|
|
512
|
+
*/
|
|
513
|
+
async deletePolicy(name, version) {
|
|
514
|
+
return await this.client.delete(`/v4/system/component/${this.ref}/${version}/policies/${name}`);
|
|
515
|
+
}
|
|
375
516
|
/**
|
|
376
517
|
* Internal method to handle NDJSON streaming responses
|
|
377
518
|
*
|
|
@@ -463,8 +604,7 @@ class Functions extends PlatformBaseClient {
|
|
|
463
604
|
* Run platform function
|
|
464
605
|
*
|
|
465
606
|
* @param id - Function ID
|
|
466
|
-
* @param
|
|
467
|
-
* @param query - Query parameters
|
|
607
|
+
* @param d - Object containing input data, query parameters, and headers
|
|
468
608
|
* @returns - Function result
|
|
469
609
|
*
|
|
470
610
|
* @example
|
|
@@ -990,7 +1130,7 @@ class Project extends PlatformBaseClient {
|
|
|
990
1130
|
}
|
|
991
1131
|
/**
|
|
992
1132
|
* Invite a user to the project
|
|
993
|
-
* @param
|
|
1133
|
+
* @param emails Array of emails
|
|
994
1134
|
* @param roles Array of role UUIDs
|
|
995
1135
|
*/
|
|
996
1136
|
async invite(emails, roles) {
|
|
@@ -1570,7 +1710,6 @@ class DMS extends IntegrationsBaseClient {
|
|
|
1570
1710
|
* - Explicit structure: JSON with `header`, `items`, and `footer` properties
|
|
1571
1711
|
* - Auto-detection: Mixed JSON arrays with metadata objects and summary rows
|
|
1572
1712
|
*
|
|
1573
|
-
* @param lib - Library reference UUID
|
|
1574
1713
|
* @param data - Raw data to convert
|
|
1575
1714
|
* @param params - Conversion parameters including structured data options
|
|
1576
1715
|
* @returns Promise resolving to converted data
|
|
@@ -1663,7 +1802,6 @@ class DMS extends IntegrationsBaseClient {
|
|
|
1663
1802
|
/**
|
|
1664
1803
|
* Get information about data format and structure
|
|
1665
1804
|
*
|
|
1666
|
-
* @param lib - Library reference UUID
|
|
1667
1805
|
* @param data - Raw data to analyze
|
|
1668
1806
|
* @param params - Analysis parameters
|
|
1669
1807
|
* @returns Promise resolving to data information
|
|
@@ -1704,7 +1842,6 @@ class DMS extends IntegrationsBaseClient {
|
|
|
1704
1842
|
/**
|
|
1705
1843
|
* Validate data format without performing conversion
|
|
1706
1844
|
*
|
|
1707
|
-
* @param lib - Library reference UUID
|
|
1708
1845
|
* @param data - Raw data to validate
|
|
1709
1846
|
* @param params - Validation parameters
|
|
1710
1847
|
* @returns Promise resolving to validation result
|
|
@@ -1752,7 +1889,6 @@ class DMS extends IntegrationsBaseClient {
|
|
|
1752
1889
|
* - Regular arrays are converted directly to CSV
|
|
1753
1890
|
* - Structured data (with metadata objects) is automatically detected and formatted
|
|
1754
1891
|
*
|
|
1755
|
-
* @param lib - Library reference UUID
|
|
1756
1892
|
* @param jsonData - JSON data (array of objects or structured data)
|
|
1757
1893
|
* @returns Promise resolving to CSV string
|
|
1758
1894
|
*
|
|
@@ -1803,7 +1939,6 @@ class DMS extends IntegrationsBaseClient {
|
|
|
1803
1939
|
* Supports both regular JSON arrays and structured data patterns.
|
|
1804
1940
|
* Excel files are always generated with .xlsx extension.
|
|
1805
1941
|
*
|
|
1806
|
-
* @param lib - Library reference UUID
|
|
1807
1942
|
* @param jsonData - JSON data (array of objects or structured data)
|
|
1808
1943
|
* @param options - Optional conversion options
|
|
1809
1944
|
* @returns Promise resolving to Excel file as Blob
|
|
@@ -1862,7 +1997,6 @@ class DMS extends IntegrationsBaseClient {
|
|
|
1862
1997
|
/**
|
|
1863
1998
|
* Convert CSV data to JSON format
|
|
1864
1999
|
*
|
|
1865
|
-
* @param lib - Library reference UUID
|
|
1866
2000
|
* @param csvData - CSV data string (with headers in first row)
|
|
1867
2001
|
* @returns Promise resolving to JSON array
|
|
1868
2002
|
*
|
|
@@ -1893,7 +2027,6 @@ class DMS extends IntegrationsBaseClient {
|
|
|
1893
2027
|
/**
|
|
1894
2028
|
* Convert CSV data to Excel (.xlsx) format
|
|
1895
2029
|
*
|
|
1896
|
-
* @param lib - Library reference UUID
|
|
1897
2030
|
* @param csvData - CSV data string (with headers in first row)
|
|
1898
2031
|
* @param options - Optional conversion options
|
|
1899
2032
|
* @returns Promise resolving to Excel file as Blob
|
|
@@ -1931,7 +2064,6 @@ class DMS extends IntegrationsBaseClient {
|
|
|
1931
2064
|
/**
|
|
1932
2065
|
* Convert Excel (.xlsx) data to JSON format
|
|
1933
2066
|
*
|
|
1934
|
-
* @param lib - Library reference UUID
|
|
1935
2067
|
* @param excelData - Excel file data as Blob or ArrayBuffer
|
|
1936
2068
|
* @param options - Optional conversion options
|
|
1937
2069
|
* @returns Promise resolving to JSON array
|
|
@@ -1971,7 +2103,6 @@ class DMS extends IntegrationsBaseClient {
|
|
|
1971
2103
|
/**
|
|
1972
2104
|
* Convert Excel (.xlsx) data to CSV format
|
|
1973
2105
|
*
|
|
1974
|
-
* @param lib - Library reference UUID
|
|
1975
2106
|
* @param excelData - Excel file data as Blob or ArrayBuffer
|
|
1976
2107
|
* @param options - Optional conversion options
|
|
1977
2108
|
* @returns Promise resolving to CSV string
|
|
@@ -2035,6 +2166,148 @@ class DMS extends IntegrationsBaseClient {
|
|
|
2035
2166
|
}
|
|
2036
2167
|
}
|
|
2037
2168
|
|
|
2169
|
+
/**
|
|
2170
|
+
* SDK client for the Protokol Mail integration.
|
|
2171
|
+
*
|
|
2172
|
+
* Provides methods to send emails, list email logs, resend failed emails,
|
|
2173
|
+
* and manage attachments through the Protokol Mail API.
|
|
2174
|
+
*
|
|
2175
|
+
* @example
|
|
2176
|
+
* ```typescript
|
|
2177
|
+
* import { Mail } from "@ptkl/sdk/beta"
|
|
2178
|
+
*
|
|
2179
|
+
* const mail = new Mail()
|
|
2180
|
+
*
|
|
2181
|
+
* // Send an email
|
|
2182
|
+
* const result = await mail.send({
|
|
2183
|
+
* to: ["user@example.com"],
|
|
2184
|
+
* subject: "Hello",
|
|
2185
|
+
* body: "<h1>Welcome!</h1>"
|
|
2186
|
+
* })
|
|
2187
|
+
*
|
|
2188
|
+
* console.log(result.message_id)
|
|
2189
|
+
* ```
|
|
2190
|
+
*/
|
|
2191
|
+
class Mail extends IntegrationsBaseClient {
|
|
2192
|
+
/**
|
|
2193
|
+
* Send an email. The email is queued for async delivery.
|
|
2194
|
+
*
|
|
2195
|
+
* Supports both JSON body (with base64-encoded attachments) and
|
|
2196
|
+
* multipart/form-data (with file uploads).
|
|
2197
|
+
*
|
|
2198
|
+
* @param input - The email content and recipients
|
|
2199
|
+
* @returns The queued email's message ID and status
|
|
2200
|
+
*
|
|
2201
|
+
* @example
|
|
2202
|
+
* ```typescript
|
|
2203
|
+
* const result = await mail.send({
|
|
2204
|
+
* to: ["recipient@example.com"],
|
|
2205
|
+
* cc: ["cc@example.com"],
|
|
2206
|
+
* subject: "Invoice #123",
|
|
2207
|
+
* body: "<p>Please find your invoice attached.</p>",
|
|
2208
|
+
* reply_to: "billing@company.com",
|
|
2209
|
+
* sender_name: "Billing Department",
|
|
2210
|
+
* attachments: [{
|
|
2211
|
+
* file_name: "invoice.pdf",
|
|
2212
|
+
* mime_type: "application/pdf",
|
|
2213
|
+
* content: "base64encodedcontent...",
|
|
2214
|
+
* size: 12345
|
|
2215
|
+
* }]
|
|
2216
|
+
* })
|
|
2217
|
+
* ```
|
|
2218
|
+
*/
|
|
2219
|
+
async send(input) {
|
|
2220
|
+
const { data } = await this.client.post("/protokol-mail/v1/emails", input);
|
|
2221
|
+
return data;
|
|
2222
|
+
}
|
|
2223
|
+
/**
|
|
2224
|
+
* List emails for the current project with optional filtering and pagination.
|
|
2225
|
+
*
|
|
2226
|
+
* @param params - Optional query parameters for filtering and pagination
|
|
2227
|
+
* @returns Paginated list of email log entries
|
|
2228
|
+
*
|
|
2229
|
+
* @example
|
|
2230
|
+
* ```typescript
|
|
2231
|
+
* // List all emails
|
|
2232
|
+
* const emails = await mail.list()
|
|
2233
|
+
*
|
|
2234
|
+
* // List failed emails, page 2
|
|
2235
|
+
* const failed = await mail.list({ status: "failed", page: 2, limit: 10 })
|
|
2236
|
+
* ```
|
|
2237
|
+
*/
|
|
2238
|
+
async list(params) {
|
|
2239
|
+
const { data } = await this.client.get("/protokol-mail/v1/emails", { params });
|
|
2240
|
+
return data;
|
|
2241
|
+
}
|
|
2242
|
+
/**
|
|
2243
|
+
* Get a single email by its message ID.
|
|
2244
|
+
*
|
|
2245
|
+
* @param messageId - The UUID of the email message
|
|
2246
|
+
* @returns The full email log entry
|
|
2247
|
+
*
|
|
2248
|
+
* @example
|
|
2249
|
+
* ```typescript
|
|
2250
|
+
* const email = await mail.get("550e8400-e29b-41d4-a716-446655440000")
|
|
2251
|
+
* console.log(email.status, email.subject)
|
|
2252
|
+
* ```
|
|
2253
|
+
*/
|
|
2254
|
+
async get(messageId) {
|
|
2255
|
+
const { data } = await this.client.get(`/protokol-mail/v1/emails/${messageId}`);
|
|
2256
|
+
return data;
|
|
2257
|
+
}
|
|
2258
|
+
/**
|
|
2259
|
+
* Resend a previously failed email. Resets the retry counter and
|
|
2260
|
+
* re-queues the email for delivery.
|
|
2261
|
+
*
|
|
2262
|
+
* @param messageId - The UUID of the email to resend
|
|
2263
|
+
* @returns Confirmation with the message ID
|
|
2264
|
+
*
|
|
2265
|
+
* @example
|
|
2266
|
+
* ```typescript
|
|
2267
|
+
* await mail.resend("550e8400-e29b-41d4-a716-446655440000")
|
|
2268
|
+
* ```
|
|
2269
|
+
*/
|
|
2270
|
+
async resend(messageId) {
|
|
2271
|
+
const { data } = await this.client.post(`/protokol-mail/v1/emails/${messageId}/resend`);
|
|
2272
|
+
return data;
|
|
2273
|
+
}
|
|
2274
|
+
/**
|
|
2275
|
+
* List attachment metadata for a specific email.
|
|
2276
|
+
*
|
|
2277
|
+
* @param messageId - The UUID of the email message
|
|
2278
|
+
* @returns Array of attachment metadata entries
|
|
2279
|
+
*
|
|
2280
|
+
* @example
|
|
2281
|
+
* ```typescript
|
|
2282
|
+
* const attachments = await mail.listAttachments("550e8400-e29b-41d4-a716-446655440000")
|
|
2283
|
+
* attachments.forEach(att => console.log(att.file_name, att.file_size))
|
|
2284
|
+
* ```
|
|
2285
|
+
*/
|
|
2286
|
+
async listAttachments(messageId) {
|
|
2287
|
+
const { data } = await this.client.get(`/protokol-mail/v1/emails/${messageId}/attachments`);
|
|
2288
|
+
return data;
|
|
2289
|
+
}
|
|
2290
|
+
/**
|
|
2291
|
+
* Download an attachment's binary content.
|
|
2292
|
+
*
|
|
2293
|
+
* @param messageId - The UUID of the email message
|
|
2294
|
+
* @param attachmentId - The UUID of the attachment
|
|
2295
|
+
* @returns The raw binary data as an ArrayBuffer
|
|
2296
|
+
*
|
|
2297
|
+
* @example
|
|
2298
|
+
* ```typescript
|
|
2299
|
+
* const content = await mail.downloadAttachment(
|
|
2300
|
+
* "550e8400-e29b-41d4-a716-446655440000",
|
|
2301
|
+
* "660e8400-e29b-41d4-a716-446655440000"
|
|
2302
|
+
* )
|
|
2303
|
+
* ```
|
|
2304
|
+
*/
|
|
2305
|
+
async downloadAttachment(messageId, attachmentId) {
|
|
2306
|
+
const { data } = await this.client.get(`/protokol-mail/v1/emails/${messageId}/attachments/${attachmentId}`, { responseType: "arraybuffer" });
|
|
2307
|
+
return data;
|
|
2308
|
+
}
|
|
2309
|
+
}
|
|
2310
|
+
|
|
2038
2311
|
class VPFR extends IntegrationsBaseClient {
|
|
2039
2312
|
async request(method, endpoint, params) {
|
|
2040
2313
|
return await this.client.request({
|
|
@@ -2902,6 +3175,7 @@ class Integrations extends IntegrationsBaseClient {
|
|
|
2902
3175
|
this.integrations = {
|
|
2903
3176
|
'serbia-minfin': new MinFin().setClient(this.client),
|
|
2904
3177
|
'protokol-dms': new DMS().setClient(this.client),
|
|
3178
|
+
'protokol-mail': new Mail().setClient(this.client),
|
|
2905
3179
|
'nbs': new NBS().setClient(this.client),
|
|
2906
3180
|
'protokol-payments': new Payments().setClient(this.client),
|
|
2907
3181
|
'protokol-minimax': new Minimax().setClient(this.client),
|
|
@@ -2919,6 +3193,9 @@ class Integrations extends IntegrationsBaseClient {
|
|
|
2919
3193
|
getMinimax() {
|
|
2920
3194
|
return this.getInterfaceOf('protokol-minimax');
|
|
2921
3195
|
}
|
|
3196
|
+
getMail() {
|
|
3197
|
+
return this.getInterfaceOf('protokol-mail');
|
|
3198
|
+
}
|
|
2922
3199
|
getNBS() {
|
|
2923
3200
|
return this.getInterfaceOf('nbs');
|
|
2924
3201
|
}
|
|
@@ -2964,4 +3241,4 @@ class Invoicing extends PlatformBaseClient {
|
|
|
2964
3241
|
}
|
|
2965
3242
|
}
|
|
2966
3243
|
|
|
2967
|
-
export { APIUser, Apps, Component, ComponentUtils, Config, DMS, Forge, Functions, Integrations as Integration, Integrations, Invoicing, NBS, Payments, Platform, Project, Ratchet, Sandbox, MinFin as SerbiaMinFin, System, Thunder, Users, VPFR, Workflow };
|
|
3244
|
+
export { APIUser, Apps, Component, ComponentUtils, Config, DMS, Forge, Functions, Integrations as Integration, Integrations, Invoicing, Mail, NBS, Payments, Platform, Project, Ratchet, Sandbox, MinFin as SerbiaMinFin, System, Thunder, Users, VPFR, Workflow };
|
|
@@ -76,6 +76,50 @@ type CreateManyOptions = {
|
|
|
76
76
|
type ModifyOptions = {
|
|
77
77
|
upsert: boolean;
|
|
78
78
|
};
|
|
79
|
+
/**
|
|
80
|
+
* MongoDB update operators that can be included inline in the `data` payload.
|
|
81
|
+
*
|
|
82
|
+
* Any key starting with `$` in the data object is automatically detected as an
|
|
83
|
+
* update operator and applied with MongoDB semantics instead of the default `$set`.
|
|
84
|
+
*
|
|
85
|
+
* Supported operators:
|
|
86
|
+
* - `$inc` — Increment a numeric field
|
|
87
|
+
* - `$push` — Append to an array
|
|
88
|
+
* - `$pull` — Remove from an array by condition
|
|
89
|
+
* - `$addToSet` — Add to array only if not present
|
|
90
|
+
* - `$pop` — Remove first (-1) or last (1) element from array
|
|
91
|
+
* - `$unset` — Remove a field from the document
|
|
92
|
+
* - `$min` — Update only if new value is less than current
|
|
93
|
+
* - `$max` — Update only if new value is greater than current
|
|
94
|
+
* - `$mul` — Multiply a numeric field
|
|
95
|
+
*
|
|
96
|
+
* @example
|
|
97
|
+
* ```ts
|
|
98
|
+
* // Data with inline operators
|
|
99
|
+
* const data = {
|
|
100
|
+
* name: "John", // → $set
|
|
101
|
+
* $inc: { views: 1 }, // → $inc
|
|
102
|
+
* $push: { tags: "vip" } // → $push
|
|
103
|
+
* }
|
|
104
|
+
* ```
|
|
105
|
+
*/
|
|
106
|
+
type UpdateOperators = {
|
|
107
|
+
$inc?: Record<string, number>;
|
|
108
|
+
$push?: Record<string, any>;
|
|
109
|
+
$pull?: Record<string, any>;
|
|
110
|
+
$addToSet?: Record<string, any>;
|
|
111
|
+
$pop?: Record<string, 1 | -1>;
|
|
112
|
+
$unset?: Record<string, "">;
|
|
113
|
+
$min?: Record<string, any>;
|
|
114
|
+
$max?: Record<string, any>;
|
|
115
|
+
$mul?: Record<string, number>;
|
|
116
|
+
};
|
|
117
|
+
/**
|
|
118
|
+
* Model data payload that supports inline update operators.
|
|
119
|
+
* Regular fields are applied via `$set`, operator keys are applied with their
|
|
120
|
+
* respective MongoDB semantics.
|
|
121
|
+
*/
|
|
122
|
+
type ModelUpdateData = Record<string, any> & UpdateOperators;
|
|
79
123
|
type ComponentOptions = {
|
|
80
124
|
version?: string;
|
|
81
125
|
};
|
|
@@ -233,6 +277,30 @@ type Function = {
|
|
|
233
277
|
name: string;
|
|
234
278
|
expr: string;
|
|
235
279
|
};
|
|
280
|
+
type Extension = {
|
|
281
|
+
name: string;
|
|
282
|
+
is_active: boolean;
|
|
283
|
+
fields?: SettingsField[];
|
|
284
|
+
functions?: Function[];
|
|
285
|
+
workflows?: Record<string, any>[];
|
|
286
|
+
templates?: Record<string, any>;
|
|
287
|
+
templates_dist?: TemplatesDist;
|
|
288
|
+
config?: Record<string, any>;
|
|
289
|
+
version?: string;
|
|
290
|
+
};
|
|
291
|
+
type FieldAccessConfig = {
|
|
292
|
+
fields: string[];
|
|
293
|
+
actions: string[];
|
|
294
|
+
roles: string[];
|
|
295
|
+
};
|
|
296
|
+
type Policy<T = Record<string, any>> = {
|
|
297
|
+
type: string;
|
|
298
|
+
name: string;
|
|
299
|
+
description?: string;
|
|
300
|
+
enabled: boolean;
|
|
301
|
+
priority: number;
|
|
302
|
+
config?: T;
|
|
303
|
+
};
|
|
236
304
|
type TemplatesDist = {
|
|
237
305
|
sdk_version: number;
|
|
238
306
|
sdk_engine: string;
|
|
@@ -275,6 +343,8 @@ type Settings = {
|
|
|
275
343
|
templates_dist?: TemplatesDist;
|
|
276
344
|
config?: Record<string, any>;
|
|
277
345
|
functions?: Function[];
|
|
346
|
+
extensions?: Extension[];
|
|
347
|
+
policies?: Policy[];
|
|
278
348
|
};
|
|
279
349
|
type SetupData = {
|
|
280
350
|
name: string;
|
|
@@ -295,4 +365,4 @@ type SetupData = {
|
|
|
295
365
|
integrator?: string;
|
|
296
366
|
};
|
|
297
367
|
type ComponentCreateResponse = ComponentListItem;
|
|
298
|
-
export { FindParams, FindOptions, FindResponse, FindAdvancedParams, FindAggregateParams, Model, UpdateOptions, ModifyOptions, ComponentOptions, ComponentListResponse, ComponentListItem, ComponentLabel, ComponentWorkspace, StreamCallback, StreamHandler, AggregateChainable, UpdateManyOptions, CreateManyOptions, Settings, SettingsField, FieldRoles, FieldConstraints, Context, Preset, PresetContext, Filters, Function, TemplatesDist, SetupData, ComponentCreateResponse, };
|
|
368
|
+
export { FindParams, FindOptions, FindResponse, FindAdvancedParams, FindAggregateParams, Model, UpdateOptions, ModifyOptions, UpdateOperators, ModelUpdateData, ComponentOptions, ComponentListResponse, ComponentListItem, ComponentLabel, ComponentWorkspace, StreamCallback, StreamHandler, AggregateChainable, UpdateManyOptions, CreateManyOptions, Settings, SettingsField, FieldRoles, FieldConstraints, Context, Preset, PresetContext, Filters, Function, Extension, Policy, FieldAccessConfig, TemplatesDist, SetupData, ComponentCreateResponse, };
|