@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/index.0.10.js
CHANGED
|
@@ -25,7 +25,6 @@ var ProtokolSDK010 = (function (exports, axios) {
|
|
|
25
25
|
*
|
|
26
26
|
* @class PlatformBaseClient
|
|
27
27
|
* @extends BaseClient
|
|
28
|
-
* @constructor
|
|
29
28
|
* @param {AxiosInstance} [client] - The axios instance to use for the client
|
|
30
29
|
*
|
|
31
30
|
* @example
|
|
@@ -146,12 +145,6 @@ var ProtokolSDK010 = (function (exports, axios) {
|
|
|
146
145
|
dateTo: ctx.dateTo,
|
|
147
146
|
dateField: ctx.dateField,
|
|
148
147
|
};
|
|
149
|
-
if (Object.keys(ctx.$adv || []).length > 0) {
|
|
150
|
-
params.$adv = JSON.stringify([ctx.$adv]);
|
|
151
|
-
}
|
|
152
|
-
if (ctx.$aggregate && ctx.$aggregate.length > 0) {
|
|
153
|
-
params.$aggregate = JSON.stringify(ctx.$aggregate);
|
|
154
|
-
}
|
|
155
148
|
return await this.client.post(`/v4/system/component/${this.ref}/models`, {
|
|
156
149
|
...params,
|
|
157
150
|
options: opts
|
|
@@ -196,9 +189,26 @@ var ProtokolSDK010 = (function (exports, axios) {
|
|
|
196
189
|
/**
|
|
197
190
|
* Update model by uuid
|
|
198
191
|
*
|
|
199
|
-
*
|
|
200
|
-
*
|
|
201
|
-
*
|
|
192
|
+
* Regular fields in `data` are applied via `$set`. You can include MongoDB
|
|
193
|
+
* update operators (prefixed with `$`) directly in the data object for
|
|
194
|
+
* granular updates like incrementing, pushing to arrays, etc.
|
|
195
|
+
*
|
|
196
|
+
* @param uuid - The uuid of the model to update
|
|
197
|
+
* @param data - Fields to update, optionally including update operators
|
|
198
|
+
* @param options - Update options
|
|
199
|
+
* @returns The updated model
|
|
200
|
+
*
|
|
201
|
+
* @example
|
|
202
|
+
* // Simple update (backwards compatible)
|
|
203
|
+
* await component.update(uuid, { name: "John" }, opts)
|
|
204
|
+
*
|
|
205
|
+
* // With update operators
|
|
206
|
+
* await component.update(uuid, {
|
|
207
|
+
* name: "John",
|
|
208
|
+
* $inc: { login_count: 1 },
|
|
209
|
+
* $push: { tags: "verified" },
|
|
210
|
+
* $addToSet: { roles: "admin" }
|
|
211
|
+
* }, opts)
|
|
202
212
|
*/
|
|
203
213
|
async update(uuid, data, options) {
|
|
204
214
|
return await this.client.post(`/v4/system/component/${this.ref}/model/${uuid}`, {
|
|
@@ -235,9 +245,20 @@ var ProtokolSDK010 = (function (exports, axios) {
|
|
|
235
245
|
/**
|
|
236
246
|
* Modify models by filters
|
|
237
247
|
*
|
|
238
|
-
*
|
|
239
|
-
*
|
|
240
|
-
*
|
|
248
|
+
* Updates all models matching the given filters. Supports inline update
|
|
249
|
+
* operators in the data payload for granular operations.
|
|
250
|
+
*
|
|
251
|
+
* @param filters - Query filters to match models
|
|
252
|
+
* @param data - Fields to update, optionally including update operators
|
|
253
|
+
* @param options - Modify options (e.g. upsert)
|
|
254
|
+
* @returns The modified models
|
|
255
|
+
*
|
|
256
|
+
* @example
|
|
257
|
+
* await component.modify(
|
|
258
|
+
* { status: "active" },
|
|
259
|
+
* { $inc: { impression_count: 1 }, $addToSet: { viewers: "user-1" } },
|
|
260
|
+
* { upsert: false }
|
|
261
|
+
* )
|
|
241
262
|
*/
|
|
242
263
|
async modify(filters, data, options) {
|
|
243
264
|
return await this.client.patch(`/v4/system/component/${this.ref}/modify/model`, {
|
|
@@ -247,12 +268,23 @@ var ProtokolSDK010 = (function (exports, axios) {
|
|
|
247
268
|
});
|
|
248
269
|
}
|
|
249
270
|
/**
|
|
250
|
-
* Concurrent update model by uuid
|
|
271
|
+
* Concurrent update model by uuid with optimistic locking
|
|
251
272
|
*
|
|
252
|
-
*
|
|
253
|
-
*
|
|
254
|
-
*
|
|
255
|
-
*
|
|
273
|
+
* Uses version-based concurrency control — the update will fail with a
|
|
274
|
+
* conflict error if the document has been modified since the provided version.
|
|
275
|
+
* Supports inline update operators in the data payload.
|
|
276
|
+
*
|
|
277
|
+
* @param uuid - The uuid of the model
|
|
278
|
+
* @param version - The expected __version__ of the model
|
|
279
|
+
* @param data - Fields to update, optionally including update operators
|
|
280
|
+
* @param options - Update options
|
|
281
|
+
* @returns The updated model
|
|
282
|
+
*
|
|
283
|
+
* @example
|
|
284
|
+
* await component.concurrentUpdate(uuid, model.__version__, {
|
|
285
|
+
* status: "processed",
|
|
286
|
+
* $inc: { retry_count: 1 }
|
|
287
|
+
* }, opts)
|
|
256
288
|
*/
|
|
257
289
|
async concurrentUpdate(uuid, version, data, options) {
|
|
258
290
|
return await this.client.post(`/v4/system/component/${this.ref}/model/${uuid}`, {
|
|
@@ -373,6 +405,115 @@ var ProtokolSDK010 = (function (exports, axios) {
|
|
|
373
405
|
async revisions(uuid) {
|
|
374
406
|
return await this.client.get(`/v3/system/component/${this.ref}/model/${uuid}/revisions`);
|
|
375
407
|
}
|
|
408
|
+
/**
|
|
409
|
+
* Install a new extension on the component
|
|
410
|
+
*
|
|
411
|
+
* @param extension - The extension definition to install
|
|
412
|
+
* @param version - The component version to install the extension on
|
|
413
|
+
* @returns Updated component settings
|
|
414
|
+
*
|
|
415
|
+
* @example
|
|
416
|
+
* ```typescript
|
|
417
|
+
* await component.installExtension({
|
|
418
|
+
* name: 'shipping_tracker',
|
|
419
|
+
* is_active: true,
|
|
420
|
+
* fields: [...],
|
|
421
|
+
* config: { api_key: 'key' }
|
|
422
|
+
* }, '0.1.0')
|
|
423
|
+
* ```
|
|
424
|
+
*/
|
|
425
|
+
async installExtension(extension, version) {
|
|
426
|
+
return await this.client.post(`/v4/system/component/${this.ref}/${version}/extensions`, extension);
|
|
427
|
+
}
|
|
428
|
+
/**
|
|
429
|
+
* Update an existing extension on the component
|
|
430
|
+
*
|
|
431
|
+
* @param name - The name of the extension to update
|
|
432
|
+
* @param version - The component version
|
|
433
|
+
* @param data - Partial extension data to update
|
|
434
|
+
* @returns Updated component settings
|
|
435
|
+
*
|
|
436
|
+
* @example
|
|
437
|
+
* ```typescript
|
|
438
|
+
* await component.updateExtension('shipping_tracker', '0.1.0', {
|
|
439
|
+
* is_active: false,
|
|
440
|
+
* config: { api_key: 'new-key' }
|
|
441
|
+
* })
|
|
442
|
+
* ```
|
|
443
|
+
*/
|
|
444
|
+
async updateExtension(name, version, data) {
|
|
445
|
+
return await this.client.patch(`/v4/system/component/${this.ref}/${version}/extensions/${name}`, data);
|
|
446
|
+
}
|
|
447
|
+
/**
|
|
448
|
+
* Delete an extension from the component
|
|
449
|
+
*
|
|
450
|
+
* @param name - The name of the extension to delete
|
|
451
|
+
* @param version - The component version
|
|
452
|
+
* @returns Updated component settings
|
|
453
|
+
*
|
|
454
|
+
* @example
|
|
455
|
+
* ```typescript
|
|
456
|
+
* await component.deleteExtension('shipping_tracker', '0.1.0')
|
|
457
|
+
* ```
|
|
458
|
+
*/
|
|
459
|
+
async deleteExtension(name, version) {
|
|
460
|
+
return await this.client.delete(`/v4/system/component/${this.ref}/${version}/extensions/${name}`);
|
|
461
|
+
}
|
|
462
|
+
/**
|
|
463
|
+
* Install a new policy on the component
|
|
464
|
+
*
|
|
465
|
+
* @param policy - The policy definition to install
|
|
466
|
+
* @param version - The component version to install the policy on
|
|
467
|
+
* @returns Updated component settings
|
|
468
|
+
*
|
|
469
|
+
* @example
|
|
470
|
+
* ```typescript
|
|
471
|
+
* await component.installPolicy({
|
|
472
|
+
* type: 'field_access',
|
|
473
|
+
* name: 'restrict_email',
|
|
474
|
+
* enabled: true,
|
|
475
|
+
* priority: 1,
|
|
476
|
+
* config: { fields: ['email'], actions: ['see'], roles: ['role-uuid'] }
|
|
477
|
+
* }, '0.1.0')
|
|
478
|
+
* ```
|
|
479
|
+
*/
|
|
480
|
+
async installPolicy(policy, version) {
|
|
481
|
+
return await this.client.post(`/v4/system/component/${this.ref}/${version}/policies`, policy);
|
|
482
|
+
}
|
|
483
|
+
/**
|
|
484
|
+
* Update an existing policy on the component
|
|
485
|
+
*
|
|
486
|
+
* @param name - The name of the policy to update
|
|
487
|
+
* @param version - The component version
|
|
488
|
+
* @param data - Partial policy data to update
|
|
489
|
+
* @returns Updated component settings
|
|
490
|
+
*
|
|
491
|
+
* @example
|
|
492
|
+
* ```typescript
|
|
493
|
+
* await component.updatePolicy('restrict_email', '0.1.0', {
|
|
494
|
+
* enabled: false,
|
|
495
|
+
* priority: 2
|
|
496
|
+
* })
|
|
497
|
+
* ```
|
|
498
|
+
*/
|
|
499
|
+
async updatePolicy(name, version, data) {
|
|
500
|
+
return await this.client.patch(`/v4/system/component/${this.ref}/${version}/policies/${name}`, data);
|
|
501
|
+
}
|
|
502
|
+
/**
|
|
503
|
+
* Delete a policy from the component
|
|
504
|
+
*
|
|
505
|
+
* @param name - The name of the policy to delete
|
|
506
|
+
* @param version - The component version
|
|
507
|
+
* @returns Updated component settings
|
|
508
|
+
*
|
|
509
|
+
* @example
|
|
510
|
+
* ```typescript
|
|
511
|
+
* await component.deletePolicy('restrict_email', '0.1.0')
|
|
512
|
+
* ```
|
|
513
|
+
*/
|
|
514
|
+
async deletePolicy(name, version) {
|
|
515
|
+
return await this.client.delete(`/v4/system/component/${this.ref}/${version}/policies/${name}`);
|
|
516
|
+
}
|
|
376
517
|
/**
|
|
377
518
|
* Internal method to handle NDJSON streaming responses
|
|
378
519
|
*
|
|
@@ -464,8 +605,7 @@ var ProtokolSDK010 = (function (exports, axios) {
|
|
|
464
605
|
* Run platform function
|
|
465
606
|
*
|
|
466
607
|
* @param id - Function ID
|
|
467
|
-
* @param
|
|
468
|
-
* @param query - Query parameters
|
|
608
|
+
* @param d - Object containing input data, query parameters, and headers
|
|
469
609
|
* @returns - Function result
|
|
470
610
|
*
|
|
471
611
|
* @example
|
|
@@ -991,7 +1131,7 @@ var ProtokolSDK010 = (function (exports, axios) {
|
|
|
991
1131
|
}
|
|
992
1132
|
/**
|
|
993
1133
|
* Invite a user to the project
|
|
994
|
-
* @param
|
|
1134
|
+
* @param emails Array of emails
|
|
995
1135
|
* @param roles Array of role UUIDs
|
|
996
1136
|
*/
|
|
997
1137
|
async invite(emails, roles) {
|
|
@@ -1571,7 +1711,6 @@ var ProtokolSDK010 = (function (exports, axios) {
|
|
|
1571
1711
|
* - Explicit structure: JSON with `header`, `items`, and `footer` properties
|
|
1572
1712
|
* - Auto-detection: Mixed JSON arrays with metadata objects and summary rows
|
|
1573
1713
|
*
|
|
1574
|
-
* @param lib - Library reference UUID
|
|
1575
1714
|
* @param data - Raw data to convert
|
|
1576
1715
|
* @param params - Conversion parameters including structured data options
|
|
1577
1716
|
* @returns Promise resolving to converted data
|
|
@@ -1664,7 +1803,6 @@ var ProtokolSDK010 = (function (exports, axios) {
|
|
|
1664
1803
|
/**
|
|
1665
1804
|
* Get information about data format and structure
|
|
1666
1805
|
*
|
|
1667
|
-
* @param lib - Library reference UUID
|
|
1668
1806
|
* @param data - Raw data to analyze
|
|
1669
1807
|
* @param params - Analysis parameters
|
|
1670
1808
|
* @returns Promise resolving to data information
|
|
@@ -1705,7 +1843,6 @@ var ProtokolSDK010 = (function (exports, axios) {
|
|
|
1705
1843
|
/**
|
|
1706
1844
|
* Validate data format without performing conversion
|
|
1707
1845
|
*
|
|
1708
|
-
* @param lib - Library reference UUID
|
|
1709
1846
|
* @param data - Raw data to validate
|
|
1710
1847
|
* @param params - Validation parameters
|
|
1711
1848
|
* @returns Promise resolving to validation result
|
|
@@ -1753,7 +1890,6 @@ var ProtokolSDK010 = (function (exports, axios) {
|
|
|
1753
1890
|
* - Regular arrays are converted directly to CSV
|
|
1754
1891
|
* - Structured data (with metadata objects) is automatically detected and formatted
|
|
1755
1892
|
*
|
|
1756
|
-
* @param lib - Library reference UUID
|
|
1757
1893
|
* @param jsonData - JSON data (array of objects or structured data)
|
|
1758
1894
|
* @returns Promise resolving to CSV string
|
|
1759
1895
|
*
|
|
@@ -1804,7 +1940,6 @@ var ProtokolSDK010 = (function (exports, axios) {
|
|
|
1804
1940
|
* Supports both regular JSON arrays and structured data patterns.
|
|
1805
1941
|
* Excel files are always generated with .xlsx extension.
|
|
1806
1942
|
*
|
|
1807
|
-
* @param lib - Library reference UUID
|
|
1808
1943
|
* @param jsonData - JSON data (array of objects or structured data)
|
|
1809
1944
|
* @param options - Optional conversion options
|
|
1810
1945
|
* @returns Promise resolving to Excel file as Blob
|
|
@@ -1863,7 +1998,6 @@ var ProtokolSDK010 = (function (exports, axios) {
|
|
|
1863
1998
|
/**
|
|
1864
1999
|
* Convert CSV data to JSON format
|
|
1865
2000
|
*
|
|
1866
|
-
* @param lib - Library reference UUID
|
|
1867
2001
|
* @param csvData - CSV data string (with headers in first row)
|
|
1868
2002
|
* @returns Promise resolving to JSON array
|
|
1869
2003
|
*
|
|
@@ -1894,7 +2028,6 @@ var ProtokolSDK010 = (function (exports, axios) {
|
|
|
1894
2028
|
/**
|
|
1895
2029
|
* Convert CSV data to Excel (.xlsx) format
|
|
1896
2030
|
*
|
|
1897
|
-
* @param lib - Library reference UUID
|
|
1898
2031
|
* @param csvData - CSV data string (with headers in first row)
|
|
1899
2032
|
* @param options - Optional conversion options
|
|
1900
2033
|
* @returns Promise resolving to Excel file as Blob
|
|
@@ -1932,7 +2065,6 @@ var ProtokolSDK010 = (function (exports, axios) {
|
|
|
1932
2065
|
/**
|
|
1933
2066
|
* Convert Excel (.xlsx) data to JSON format
|
|
1934
2067
|
*
|
|
1935
|
-
* @param lib - Library reference UUID
|
|
1936
2068
|
* @param excelData - Excel file data as Blob or ArrayBuffer
|
|
1937
2069
|
* @param options - Optional conversion options
|
|
1938
2070
|
* @returns Promise resolving to JSON array
|
|
@@ -1972,7 +2104,6 @@ var ProtokolSDK010 = (function (exports, axios) {
|
|
|
1972
2104
|
/**
|
|
1973
2105
|
* Convert Excel (.xlsx) data to CSV format
|
|
1974
2106
|
*
|
|
1975
|
-
* @param lib - Library reference UUID
|
|
1976
2107
|
* @param excelData - Excel file data as Blob or ArrayBuffer
|
|
1977
2108
|
* @param options - Optional conversion options
|
|
1978
2109
|
* @returns Promise resolving to CSV string
|
|
@@ -2036,6 +2167,148 @@ var ProtokolSDK010 = (function (exports, axios) {
|
|
|
2036
2167
|
}
|
|
2037
2168
|
}
|
|
2038
2169
|
|
|
2170
|
+
/**
|
|
2171
|
+
* SDK client for the Protokol Mail integration.
|
|
2172
|
+
*
|
|
2173
|
+
* Provides methods to send emails, list email logs, resend failed emails,
|
|
2174
|
+
* and manage attachments through the Protokol Mail API.
|
|
2175
|
+
*
|
|
2176
|
+
* @example
|
|
2177
|
+
* ```typescript
|
|
2178
|
+
* import { Mail } from "@ptkl/sdk/beta"
|
|
2179
|
+
*
|
|
2180
|
+
* const mail = new Mail()
|
|
2181
|
+
*
|
|
2182
|
+
* // Send an email
|
|
2183
|
+
* const result = await mail.send({
|
|
2184
|
+
* to: ["user@example.com"],
|
|
2185
|
+
* subject: "Hello",
|
|
2186
|
+
* body: "<h1>Welcome!</h1>"
|
|
2187
|
+
* })
|
|
2188
|
+
*
|
|
2189
|
+
* console.log(result.message_id)
|
|
2190
|
+
* ```
|
|
2191
|
+
*/
|
|
2192
|
+
class Mail extends IntegrationsBaseClient {
|
|
2193
|
+
/**
|
|
2194
|
+
* Send an email. The email is queued for async delivery.
|
|
2195
|
+
*
|
|
2196
|
+
* Supports both JSON body (with base64-encoded attachments) and
|
|
2197
|
+
* multipart/form-data (with file uploads).
|
|
2198
|
+
*
|
|
2199
|
+
* @param input - The email content and recipients
|
|
2200
|
+
* @returns The queued email's message ID and status
|
|
2201
|
+
*
|
|
2202
|
+
* @example
|
|
2203
|
+
* ```typescript
|
|
2204
|
+
* const result = await mail.send({
|
|
2205
|
+
* to: ["recipient@example.com"],
|
|
2206
|
+
* cc: ["cc@example.com"],
|
|
2207
|
+
* subject: "Invoice #123",
|
|
2208
|
+
* body: "<p>Please find your invoice attached.</p>",
|
|
2209
|
+
* reply_to: "billing@company.com",
|
|
2210
|
+
* sender_name: "Billing Department",
|
|
2211
|
+
* attachments: [{
|
|
2212
|
+
* file_name: "invoice.pdf",
|
|
2213
|
+
* mime_type: "application/pdf",
|
|
2214
|
+
* content: "base64encodedcontent...",
|
|
2215
|
+
* size: 12345
|
|
2216
|
+
* }]
|
|
2217
|
+
* })
|
|
2218
|
+
* ```
|
|
2219
|
+
*/
|
|
2220
|
+
async send(input) {
|
|
2221
|
+
const { data } = await this.client.post("/protokol-mail/v1/emails", input);
|
|
2222
|
+
return data;
|
|
2223
|
+
}
|
|
2224
|
+
/**
|
|
2225
|
+
* List emails for the current project with optional filtering and pagination.
|
|
2226
|
+
*
|
|
2227
|
+
* @param params - Optional query parameters for filtering and pagination
|
|
2228
|
+
* @returns Paginated list of email log entries
|
|
2229
|
+
*
|
|
2230
|
+
* @example
|
|
2231
|
+
* ```typescript
|
|
2232
|
+
* // List all emails
|
|
2233
|
+
* const emails = await mail.list()
|
|
2234
|
+
*
|
|
2235
|
+
* // List failed emails, page 2
|
|
2236
|
+
* const failed = await mail.list({ status: "failed", page: 2, limit: 10 })
|
|
2237
|
+
* ```
|
|
2238
|
+
*/
|
|
2239
|
+
async list(params) {
|
|
2240
|
+
const { data } = await this.client.get("/protokol-mail/v1/emails", { params });
|
|
2241
|
+
return data;
|
|
2242
|
+
}
|
|
2243
|
+
/**
|
|
2244
|
+
* Get a single email by its message ID.
|
|
2245
|
+
*
|
|
2246
|
+
* @param messageId - The UUID of the email message
|
|
2247
|
+
* @returns The full email log entry
|
|
2248
|
+
*
|
|
2249
|
+
* @example
|
|
2250
|
+
* ```typescript
|
|
2251
|
+
* const email = await mail.get("550e8400-e29b-41d4-a716-446655440000")
|
|
2252
|
+
* console.log(email.status, email.subject)
|
|
2253
|
+
* ```
|
|
2254
|
+
*/
|
|
2255
|
+
async get(messageId) {
|
|
2256
|
+
const { data } = await this.client.get(`/protokol-mail/v1/emails/${messageId}`);
|
|
2257
|
+
return data;
|
|
2258
|
+
}
|
|
2259
|
+
/**
|
|
2260
|
+
* Resend a previously failed email. Resets the retry counter and
|
|
2261
|
+
* re-queues the email for delivery.
|
|
2262
|
+
*
|
|
2263
|
+
* @param messageId - The UUID of the email to resend
|
|
2264
|
+
* @returns Confirmation with the message ID
|
|
2265
|
+
*
|
|
2266
|
+
* @example
|
|
2267
|
+
* ```typescript
|
|
2268
|
+
* await mail.resend("550e8400-e29b-41d4-a716-446655440000")
|
|
2269
|
+
* ```
|
|
2270
|
+
*/
|
|
2271
|
+
async resend(messageId) {
|
|
2272
|
+
const { data } = await this.client.post(`/protokol-mail/v1/emails/${messageId}/resend`);
|
|
2273
|
+
return data;
|
|
2274
|
+
}
|
|
2275
|
+
/**
|
|
2276
|
+
* List attachment metadata for a specific email.
|
|
2277
|
+
*
|
|
2278
|
+
* @param messageId - The UUID of the email message
|
|
2279
|
+
* @returns Array of attachment metadata entries
|
|
2280
|
+
*
|
|
2281
|
+
* @example
|
|
2282
|
+
* ```typescript
|
|
2283
|
+
* const attachments = await mail.listAttachments("550e8400-e29b-41d4-a716-446655440000")
|
|
2284
|
+
* attachments.forEach(att => console.log(att.file_name, att.file_size))
|
|
2285
|
+
* ```
|
|
2286
|
+
*/
|
|
2287
|
+
async listAttachments(messageId) {
|
|
2288
|
+
const { data } = await this.client.get(`/protokol-mail/v1/emails/${messageId}/attachments`);
|
|
2289
|
+
return data;
|
|
2290
|
+
}
|
|
2291
|
+
/**
|
|
2292
|
+
* Download an attachment's binary content.
|
|
2293
|
+
*
|
|
2294
|
+
* @param messageId - The UUID of the email message
|
|
2295
|
+
* @param attachmentId - The UUID of the attachment
|
|
2296
|
+
* @returns The raw binary data as an ArrayBuffer
|
|
2297
|
+
*
|
|
2298
|
+
* @example
|
|
2299
|
+
* ```typescript
|
|
2300
|
+
* const content = await mail.downloadAttachment(
|
|
2301
|
+
* "550e8400-e29b-41d4-a716-446655440000",
|
|
2302
|
+
* "660e8400-e29b-41d4-a716-446655440000"
|
|
2303
|
+
* )
|
|
2304
|
+
* ```
|
|
2305
|
+
*/
|
|
2306
|
+
async downloadAttachment(messageId, attachmentId) {
|
|
2307
|
+
const { data } = await this.client.get(`/protokol-mail/v1/emails/${messageId}/attachments/${attachmentId}`, { responseType: "arraybuffer" });
|
|
2308
|
+
return data;
|
|
2309
|
+
}
|
|
2310
|
+
}
|
|
2311
|
+
|
|
2039
2312
|
class VPFR extends IntegrationsBaseClient {
|
|
2040
2313
|
async request(method, endpoint, params) {
|
|
2041
2314
|
return await this.client.request({
|
|
@@ -2903,6 +3176,7 @@ var ProtokolSDK010 = (function (exports, axios) {
|
|
|
2903
3176
|
this.integrations = {
|
|
2904
3177
|
'serbia-minfin': new MinFin().setClient(this.client),
|
|
2905
3178
|
'protokol-dms': new DMS().setClient(this.client),
|
|
3179
|
+
'protokol-mail': new Mail().setClient(this.client),
|
|
2906
3180
|
'nbs': new NBS().setClient(this.client),
|
|
2907
3181
|
'protokol-payments': new Payments().setClient(this.client),
|
|
2908
3182
|
'protokol-minimax': new Minimax().setClient(this.client),
|
|
@@ -2920,6 +3194,9 @@ var ProtokolSDK010 = (function (exports, axios) {
|
|
|
2920
3194
|
getMinimax() {
|
|
2921
3195
|
return this.getInterfaceOf('protokol-minimax');
|
|
2922
3196
|
}
|
|
3197
|
+
getMail() {
|
|
3198
|
+
return this.getInterfaceOf('protokol-mail');
|
|
3199
|
+
}
|
|
2923
3200
|
getNBS() {
|
|
2924
3201
|
return this.getInterfaceOf('nbs');
|
|
2925
3202
|
}
|
|
@@ -2976,6 +3253,7 @@ var ProtokolSDK010 = (function (exports, axios) {
|
|
|
2976
3253
|
exports.Integration = Integrations;
|
|
2977
3254
|
exports.Integrations = Integrations;
|
|
2978
3255
|
exports.Invoicing = Invoicing;
|
|
3256
|
+
exports.Mail = Mail;
|
|
2979
3257
|
exports.NBS = NBS;
|
|
2980
3258
|
exports.Payments = Payments;
|
|
2981
3259
|
exports.Platform = Platform;
|
package/dist/index.0.9.js
CHANGED
|
@@ -25,7 +25,6 @@ var ProtokolSDK09 = (function (exports, axios) {
|
|
|
25
25
|
*
|
|
26
26
|
* @class PlatformBaseClient
|
|
27
27
|
* @extends BaseClient
|
|
28
|
-
* @constructor
|
|
29
28
|
* @param {AxiosInstance} [client] - The axios instance to use for the client
|
|
30
29
|
*
|
|
31
30
|
* @example
|
|
@@ -475,8 +474,7 @@ var ProtokolSDK09 = (function (exports, axios) {
|
|
|
475
474
|
* Run platform function
|
|
476
475
|
*
|
|
477
476
|
* @param id - Function ID
|
|
478
|
-
* @param
|
|
479
|
-
* @param query - Query parameters
|
|
477
|
+
* @param d - Object containing input data, query parameters, and headers
|
|
480
478
|
* @returns - Function result
|
|
481
479
|
*
|
|
482
480
|
* @example
|
|
@@ -991,7 +989,7 @@ var ProtokolSDK09 = (function (exports, axios) {
|
|
|
991
989
|
}
|
|
992
990
|
/**
|
|
993
991
|
* Invite a user to the project
|
|
994
|
-
* @param
|
|
992
|
+
* @param emails Array of emails
|
|
995
993
|
* @param roles Array of role UUIDs
|
|
996
994
|
*/
|
|
997
995
|
async invite(emails, roles) {
|
|
@@ -1960,6 +1958,92 @@ var ProtokolSDK09 = (function (exports, axios) {
|
|
|
1960
1958
|
}
|
|
1961
1959
|
}
|
|
1962
1960
|
|
|
1961
|
+
/**
|
|
1962
|
+
* SDK client for the Protokol Mail integration.
|
|
1963
|
+
*
|
|
1964
|
+
* Provides methods to send emails, list email logs, resend failed emails,
|
|
1965
|
+
* and manage attachments through the Protokol Mail API.
|
|
1966
|
+
*
|
|
1967
|
+
* @example
|
|
1968
|
+
* ```typescript
|
|
1969
|
+
* import { Mail } from "@ptkl/sdk"
|
|
1970
|
+
*
|
|
1971
|
+
* const mail = new Mail()
|
|
1972
|
+
*
|
|
1973
|
+
* // Send an email
|
|
1974
|
+
* const result = await mail.send({
|
|
1975
|
+
* to: ["user@example.com"],
|
|
1976
|
+
* subject: "Hello",
|
|
1977
|
+
* body: "<h1>Welcome!</h1>"
|
|
1978
|
+
* })
|
|
1979
|
+
*
|
|
1980
|
+
* console.log(result.message_id)
|
|
1981
|
+
* ```
|
|
1982
|
+
*/
|
|
1983
|
+
class Mail extends IntegrationsBaseClient {
|
|
1984
|
+
/**
|
|
1985
|
+
* Send an email. The email is queued for async delivery.
|
|
1986
|
+
*
|
|
1987
|
+
* @param input - The email content and recipients
|
|
1988
|
+
* @returns The queued email's message ID and status
|
|
1989
|
+
*/
|
|
1990
|
+
async send(input) {
|
|
1991
|
+
const { data } = await this.client.post("/protokol-mail/v1/emails", input);
|
|
1992
|
+
return data;
|
|
1993
|
+
}
|
|
1994
|
+
/**
|
|
1995
|
+
* List emails for the current project with optional filtering and pagination.
|
|
1996
|
+
*
|
|
1997
|
+
* @param params - Optional query parameters for filtering and pagination
|
|
1998
|
+
* @returns Paginated list of email log entries
|
|
1999
|
+
*/
|
|
2000
|
+
async list(params) {
|
|
2001
|
+
const { data } = await this.client.get("/protokol-mail/v1/emails", { params });
|
|
2002
|
+
return data;
|
|
2003
|
+
}
|
|
2004
|
+
/**
|
|
2005
|
+
* Get a single email by its message ID.
|
|
2006
|
+
*
|
|
2007
|
+
* @param messageId - The UUID of the email message
|
|
2008
|
+
* @returns The full email log entry
|
|
2009
|
+
*/
|
|
2010
|
+
async get(messageId) {
|
|
2011
|
+
const { data } = await this.client.get(`/protokol-mail/v1/emails/${messageId}`);
|
|
2012
|
+
return data;
|
|
2013
|
+
}
|
|
2014
|
+
/**
|
|
2015
|
+
* Resend a previously failed email.
|
|
2016
|
+
*
|
|
2017
|
+
* @param messageId - The UUID of the email to resend
|
|
2018
|
+
* @returns Confirmation with the message ID
|
|
2019
|
+
*/
|
|
2020
|
+
async resend(messageId) {
|
|
2021
|
+
const { data } = await this.client.post(`/protokol-mail/v1/emails/${messageId}/resend`);
|
|
2022
|
+
return data;
|
|
2023
|
+
}
|
|
2024
|
+
/**
|
|
2025
|
+
* List attachment metadata for a specific email.
|
|
2026
|
+
*
|
|
2027
|
+
* @param messageId - The UUID of the email message
|
|
2028
|
+
* @returns Array of attachment metadata entries
|
|
2029
|
+
*/
|
|
2030
|
+
async listAttachments(messageId) {
|
|
2031
|
+
const { data } = await this.client.get(`/protokol-mail/v1/emails/${messageId}/attachments`);
|
|
2032
|
+
return data;
|
|
2033
|
+
}
|
|
2034
|
+
/**
|
|
2035
|
+
* Download an attachment's binary content.
|
|
2036
|
+
*
|
|
2037
|
+
* @param messageId - The UUID of the email message
|
|
2038
|
+
* @param attachmentId - The UUID of the attachment
|
|
2039
|
+
* @returns The raw binary data as an ArrayBuffer
|
|
2040
|
+
*/
|
|
2041
|
+
async downloadAttachment(messageId, attachmentId) {
|
|
2042
|
+
const { data } = await this.client.get(`/protokol-mail/v1/emails/${messageId}/attachments/${attachmentId}`, { responseType: "arraybuffer" });
|
|
2043
|
+
return data;
|
|
2044
|
+
}
|
|
2045
|
+
}
|
|
2046
|
+
|
|
1963
2047
|
class SerbiaUtil extends IntegrationsBaseClient {
|
|
1964
2048
|
async nbsSearch(params) {
|
|
1965
2049
|
return await this.services("GET", "nbs/search", {
|
|
@@ -2815,6 +2899,7 @@ var ProtokolSDK09 = (function (exports, axios) {
|
|
|
2815
2899
|
'protokol-invoicing': new Invoicing().setClient(this.client),
|
|
2816
2900
|
'protokol-vpfr': new VPFR().setClient(this.client),
|
|
2817
2901
|
'protokol-dms': new DMS().setClient(this.client),
|
|
2902
|
+
'protokol-mail': new Mail().setClient(this.client),
|
|
2818
2903
|
'serbia-utilities': new SerbiaUtil().setClient(this.client),
|
|
2819
2904
|
'protokol-payments': new Payments().setClient(this.client),
|
|
2820
2905
|
'protokol-minimax': new Minimax().setClient(this.client),
|
|
@@ -2832,6 +2917,9 @@ var ProtokolSDK09 = (function (exports, axios) {
|
|
|
2832
2917
|
getInvoicing() {
|
|
2833
2918
|
return this.getInterfaceOf('protokol-invoicing');
|
|
2834
2919
|
}
|
|
2920
|
+
getMail() {
|
|
2921
|
+
return this.getInterfaceOf('protokol-mail');
|
|
2922
|
+
}
|
|
2835
2923
|
getPayments() {
|
|
2836
2924
|
return this.getInterfaceOf('protokol-payments');
|
|
2837
2925
|
}
|
|
@@ -2867,6 +2955,7 @@ var ProtokolSDK09 = (function (exports, axios) {
|
|
|
2867
2955
|
exports.Integration = Integrations;
|
|
2868
2956
|
exports.Integrations = Integrations;
|
|
2869
2957
|
exports.Invoicing = Invoicing;
|
|
2958
|
+
exports.Mail = Mail;
|
|
2870
2959
|
exports.Payments = Payments;
|
|
2871
2960
|
exports.Platform = Platform;
|
|
2872
2961
|
exports.Project = Project;
|