@ketrics/sdk-backend 0.4.0 → 0.5.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/context.d.ts +15 -10
- package/dist/context.d.ts.map +1 -1
- package/dist/index.d.ts +160 -168
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +11 -1
- package/dist/index.js.map +1 -1
- package/dist/messages-errors.d.ts +69 -0
- package/dist/messages-errors.d.ts.map +1 -0
- package/dist/messages-errors.js +110 -0
- package/dist/messages-errors.js.map +1 -0
- package/dist/messages.d.ts +163 -0
- package/dist/messages.d.ts.map +1 -0
- package/dist/messages.js +41 -0
- package/dist/messages.js.map +1 -0
- package/package.json +1 -1
package/dist/context.d.ts
CHANGED
|
@@ -37,26 +37,24 @@ export interface ApplicationContext {
|
|
|
37
37
|
/**
|
|
38
38
|
* User Context
|
|
39
39
|
*
|
|
40
|
-
* Information about the user
|
|
40
|
+
* Information about the user making the request.
|
|
41
41
|
*/
|
|
42
42
|
export interface UserContext {
|
|
43
|
-
/** User UUID
|
|
43
|
+
/** User UUID */
|
|
44
44
|
id: string;
|
|
45
|
-
/** User email address
|
|
45
|
+
/** User email address */
|
|
46
46
|
email: string;
|
|
47
|
-
/** User full name
|
|
47
|
+
/** User full name */
|
|
48
48
|
name: string;
|
|
49
|
-
/**
|
|
50
|
-
|
|
51
|
-
/** Whether this is a service account (non-human identity) */
|
|
52
|
-
isServiceAccount: boolean;
|
|
49
|
+
/** User's application permissions for the current app (e.g., ["read", "write"] or ["*"]) */
|
|
50
|
+
applicationPermissions: string[];
|
|
53
51
|
}
|
|
54
52
|
/**
|
|
55
|
-
*
|
|
53
|
+
* Runtime Context
|
|
56
54
|
*
|
|
57
55
|
* Information about the runtime environment.
|
|
58
56
|
*/
|
|
59
|
-
export interface
|
|
57
|
+
export interface RuntimeContext {
|
|
60
58
|
/** Node.js version (e.g., "18.x") */
|
|
61
59
|
nodeVersion: string;
|
|
62
60
|
/** Runtime platform */
|
|
@@ -64,4 +62,11 @@ export interface EnvironmentContext {
|
|
|
64
62
|
/** AWS region (e.g., "us-east-1") */
|
|
65
63
|
region: string;
|
|
66
64
|
}
|
|
65
|
+
/**
|
|
66
|
+
* Environment Variables
|
|
67
|
+
*
|
|
68
|
+
* Key-value map of application environment variables.
|
|
69
|
+
* Keys are uppercase with letters, numbers, and underscores only.
|
|
70
|
+
*/
|
|
71
|
+
export type EnvironmentVariables = Record<string, string>;
|
|
67
72
|
//# sourceMappingURL=context.d.ts.map
|
package/dist/context.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"context.d.ts","sourceRoot":"","sources":["../src/context.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH;;;;GAIG;AACH,MAAM,WAAW,aAAa;IAC5B,kBAAkB;IAClB,EAAE,EAAE,MAAM,CAAC;IACX,sCAAsC;IACtC,IAAI,EAAE,MAAM,CAAC;IACb,0BAA0B;IAC1B,IAAI,EAAE,MAAM,CAAC;CACd;AAED;;;;GAIG;AACH,MAAM,WAAW,kBAAkB;IACjC,uBAAuB;IACvB,EAAE,EAAE,MAAM,CAAC;IACX,kDAAkD;IAClD,IAAI,EAAE,MAAM,CAAC;IACb,+BAA+B;IAC/B,IAAI,EAAE,MAAM,CAAC;IACb,qCAAqC;IACrC,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,4BAA4B;IAC5B,YAAY,EAAE,MAAM,CAAC;CACtB;AAED;;;;GAIG;AACH,MAAM,WAAW,WAAW;IAC1B,
|
|
1
|
+
{"version":3,"file":"context.d.ts","sourceRoot":"","sources":["../src/context.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH;;;;GAIG;AACH,MAAM,WAAW,aAAa;IAC5B,kBAAkB;IAClB,EAAE,EAAE,MAAM,CAAC;IACX,sCAAsC;IACtC,IAAI,EAAE,MAAM,CAAC;IACb,0BAA0B;IAC1B,IAAI,EAAE,MAAM,CAAC;CACd;AAED;;;;GAIG;AACH,MAAM,WAAW,kBAAkB;IACjC,uBAAuB;IACvB,EAAE,EAAE,MAAM,CAAC;IACX,kDAAkD;IAClD,IAAI,EAAE,MAAM,CAAC;IACb,+BAA+B;IAC/B,IAAI,EAAE,MAAM,CAAC;IACb,qCAAqC;IACrC,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,4BAA4B;IAC5B,YAAY,EAAE,MAAM,CAAC;CACtB;AAED;;;;GAIG;AACH,MAAM,WAAW,WAAW;IAC1B,gBAAgB;IAChB,EAAE,EAAE,MAAM,CAAC;IACX,yBAAyB;IACzB,KAAK,EAAE,MAAM,CAAC;IACd,qBAAqB;IACrB,IAAI,EAAE,MAAM,CAAC;IACb,4FAA4F;IAC5F,sBAAsB,EAAE,MAAM,EAAE,CAAC;CAClC;AAED;;;;GAIG;AACH,MAAM,WAAW,cAAc;IAC7B,qCAAqC;IACrC,WAAW,EAAE,MAAM,CAAC;IACpB,uBAAuB;IACvB,OAAO,EAAE,aAAa,CAAC;IACvB,qCAAqC;IACrC,MAAM,EAAE,MAAM,CAAC;CAChB;AAED;;;;;GAKG;AACH,MAAM,MAAM,oBAAoB,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC"}
|
package/dist/index.d.ts
CHANGED
|
@@ -54,7 +54,7 @@
|
|
|
54
54
|
* }
|
|
55
55
|
* ```
|
|
56
56
|
*/
|
|
57
|
-
export { TenantContext, ApplicationContext, UserContext,
|
|
57
|
+
export { TenantContext, ApplicationContext, UserContext, RuntimeContext, EnvironmentVariables, } from './context';
|
|
58
58
|
export { ConsoleLogger } from './console';
|
|
59
59
|
export { HttpRequestConfig, HttpResponse, HttpClient } from './http';
|
|
60
60
|
export { DatabaseQueryResult, DatabaseExecuteResult, IDatabaseConnection, DatabaseManager, } from './databases';
|
|
@@ -67,9 +67,11 @@ export { PdfPageSize, PdfStandardFont, PdfRgbColor, PdfDrawTextOptions, PdfDrawR
|
|
|
67
67
|
export { PdfError, PdfParseError, PdfWriteError, isPdfError, isPdfErrorType, } from './pdf-errors';
|
|
68
68
|
export { JobStatusValue, RunInBackgroundOptions, RunInBackgroundParams, JobErrorDetails, JobStatus, JobListParams, JobListResult, } from './job';
|
|
69
69
|
export { JobError, JobNotFoundError, InvalidFunctionError, CrossAppPermissionError, JobExecutionError, isJobError, isJobErrorType, } from './job-errors';
|
|
70
|
+
export { MessagePriorityLevel, MessageChannelConfig, SendMessageParams, SendBulkMessageParams, SendGroupMessageParams, SendMessageResult, SendBulkMessageResult, MessagesManager, } from './messages';
|
|
71
|
+
export { MessageError, MessageValidationError, GroupNotFoundError, TenantGrantPermissionDeniedError, isMessageError, isMessageErrorType, } from './messages-errors';
|
|
70
72
|
export { PutContent, FileContent, FileMetadata, FileInfo, PutOptions, PutResult, DeleteResult, DeleteError, DeleteByPrefixResult, ListOptions, ListResult, CopyOptions, CopyResult, MoveOptions, MoveResult, DownloadUrlOptions, UploadUrlOptions, PresignedUrl, IVolume, } from './volumes';
|
|
71
73
|
export { VolumePermissionValue, VolumeError, VolumeNotFoundError, VolumeAccessDeniedError, VolumePermissionDeniedError, FileNotFoundError, FileAlreadyExistsError, InvalidPathError, FileSizeLimitError, ContentTypeNotAllowedError, isVolumeError, isVolumeErrorType, } from './errors';
|
|
72
|
-
import type { TenantContext, ApplicationContext, UserContext,
|
|
74
|
+
import type { TenantContext, ApplicationContext, UserContext, RuntimeContext, EnvironmentVariables } from './context';
|
|
73
75
|
import type { ConsoleLogger } from './console';
|
|
74
76
|
import type { HttpClient } from './http';
|
|
75
77
|
import type { IDatabaseConnection } from './databases';
|
|
@@ -77,12 +79,21 @@ import type { IVolume } from './volumes';
|
|
|
77
79
|
import type { IExcelWorkbook } from './excel';
|
|
78
80
|
import type { IPdfDocument, PdfRgbColor } from './pdf';
|
|
79
81
|
import type { RunInBackgroundParams, JobStatus, JobListParams, JobListResult } from './job';
|
|
82
|
+
import type { MessagesManager } from './messages';
|
|
80
83
|
import { VolumeError as VolumeErrorClass, VolumeNotFoundError as VolumeNotFoundErrorClass, VolumeAccessDeniedError as VolumeAccessDeniedErrorClass, VolumePermissionDeniedError as VolumePermissionDeniedErrorClass, FileNotFoundError as FileNotFoundErrorClass, FileAlreadyExistsError as FileAlreadyExistsErrorClass, InvalidPathError as InvalidPathErrorClass, FileSizeLimitError as FileSizeLimitErrorClass, ContentTypeNotAllowedError as ContentTypeNotAllowedErrorClass } from './errors';
|
|
81
84
|
import { DatabaseError as DatabaseErrorClass, DatabaseNotFoundError as DatabaseNotFoundErrorClass, DatabaseAccessDeniedError as DatabaseAccessDeniedErrorClass, DatabaseConnectionError as DatabaseConnectionErrorClass, DatabaseQueryError as DatabaseQueryErrorClass, DatabaseTransactionError as DatabaseTransactionErrorClass } from './database-errors';
|
|
82
85
|
import { SecretError as SecretErrorClass, SecretNotFoundError as SecretNotFoundErrorClass, SecretAccessDeniedError as SecretAccessDeniedErrorClass, SecretDecryptionError as SecretDecryptionErrorClass } from './secret-errors';
|
|
83
86
|
import { ExcelError as ExcelErrorClass, ExcelParseError as ExcelParseErrorClass, ExcelWriteError as ExcelWriteErrorClass } from './excel-errors';
|
|
84
87
|
import { PdfError as PdfErrorClass, PdfParseError as PdfParseErrorClass, PdfWriteError as PdfWriteErrorClass } from './pdf-errors';
|
|
85
88
|
import { JobError as JobErrorClass, JobNotFoundError as JobNotFoundErrorClass, InvalidFunctionError as InvalidFunctionErrorClass, CrossAppPermissionError as CrossAppPermissionErrorClass, JobExecutionError as JobExecutionErrorClass } from './job-errors';
|
|
89
|
+
import { MessageError as MessageErrorClass, MessageValidationError as MessageValidationErrorClass, GroupNotFoundError as GroupNotFoundErrorClass, TenantGrantPermissionDeniedError as TenantGrantPermissionDeniedErrorClass } from './messages-errors';
|
|
90
|
+
import { isVolumeError, isVolumeErrorType } from './errors';
|
|
91
|
+
import { isDatabaseError, isDatabaseErrorType } from './database-errors';
|
|
92
|
+
import { isSecretError, isSecretErrorType } from './secret-errors';
|
|
93
|
+
import { isExcelError, isExcelErrorType } from './excel-errors';
|
|
94
|
+
import { isPdfError, isPdfErrorType } from './pdf-errors';
|
|
95
|
+
import { isJobError, isJobErrorType } from './job-errors';
|
|
96
|
+
import { isMessageError, isMessageErrorType } from './messages-errors';
|
|
86
97
|
/**
|
|
87
98
|
* Ketrics Platform SDK Interface
|
|
88
99
|
*
|
|
@@ -95,7 +106,7 @@ import { JobError as JobErrorClass, JobNotFoundError as JobNotFoundErrorClass, I
|
|
|
95
106
|
* console.log(ketrics.tenant.name);
|
|
96
107
|
* console.log(ketrics.application.code);
|
|
97
108
|
* console.log(ketrics.user.email);
|
|
98
|
-
* console.log(ketrics.
|
|
109
|
+
* console.log(ketrics.runtime.region);
|
|
99
110
|
*
|
|
100
111
|
* // Use console logging (forwarded to CloudWatch)
|
|
101
112
|
* ketrics.console.log('Processing request...');
|
|
@@ -116,6 +127,14 @@ import { JobError as JobErrorClass, JobNotFoundError as JobNotFoundErrorClass, I
|
|
|
116
127
|
* // Access volumes
|
|
117
128
|
* const volume = await ketrics.Volume.connect('uploads');
|
|
118
129
|
* const file = await volume.get('document.pdf');
|
|
130
|
+
*
|
|
131
|
+
* // Send messages to users
|
|
132
|
+
* await ketrics.Messages.send({
|
|
133
|
+
* userId: 'user-123',
|
|
134
|
+
* type: 'ORDER_SHIPPED',
|
|
135
|
+
* subject: 'Your order shipped!',
|
|
136
|
+
* body: 'Track your package...'
|
|
137
|
+
* });
|
|
119
138
|
* ```
|
|
120
139
|
*/
|
|
121
140
|
export interface KetricsSdkV1 {
|
|
@@ -126,11 +145,141 @@ export interface KetricsSdkV1 {
|
|
|
126
145
|
/** Current user information */
|
|
127
146
|
user: UserContext;
|
|
128
147
|
/** Runtime environment information */
|
|
129
|
-
|
|
148
|
+
runtime: RuntimeContext;
|
|
149
|
+
/** Application environment variables (key-value pairs) */
|
|
150
|
+
environment: EnvironmentVariables;
|
|
130
151
|
/** Console logging (forwarded to CloudWatch) */
|
|
131
152
|
console: ConsoleLogger;
|
|
132
153
|
/** HTTP client for external API requests */
|
|
133
154
|
http: HttpClient;
|
|
155
|
+
/** Volume class with static connect() factory method */
|
|
156
|
+
Volume: {
|
|
157
|
+
connect(volumeCode: string): Promise<IVolume>;
|
|
158
|
+
};
|
|
159
|
+
/** Base error class for all Volume errors (abstract) */
|
|
160
|
+
VolumeError: typeof VolumeErrorClass;
|
|
161
|
+
/** Error thrown when volume doesn't exist */
|
|
162
|
+
VolumeNotFoundError: typeof VolumeNotFoundErrorClass;
|
|
163
|
+
/** Error thrown when application has no access grant */
|
|
164
|
+
VolumeAccessDeniedError: typeof VolumeAccessDeniedErrorClass;
|
|
165
|
+
/** Error thrown when operation requires missing permission */
|
|
166
|
+
VolumePermissionDeniedError: typeof VolumePermissionDeniedErrorClass;
|
|
167
|
+
/** Error thrown when file doesn't exist */
|
|
168
|
+
FileNotFoundError: typeof FileNotFoundErrorClass;
|
|
169
|
+
/** Error thrown when file already exists (with ifNotExists option) */
|
|
170
|
+
FileAlreadyExistsError: typeof FileAlreadyExistsErrorClass;
|
|
171
|
+
/** Error thrown for invalid path characters or traversal attempts */
|
|
172
|
+
InvalidPathError: typeof InvalidPathErrorClass;
|
|
173
|
+
/** Error thrown when file exceeds size limit */
|
|
174
|
+
FileSizeLimitError: typeof FileSizeLimitErrorClass;
|
|
175
|
+
/** Error thrown when content type is not allowed */
|
|
176
|
+
ContentTypeNotAllowedError: typeof ContentTypeNotAllowedErrorClass;
|
|
177
|
+
/** Type guard to check if error is a VolumeError */
|
|
178
|
+
isVolumeError: typeof isVolumeError;
|
|
179
|
+
/** Type guard to check if error is a specific VolumeError type */
|
|
180
|
+
isVolumeErrorType: typeof isVolumeErrorType;
|
|
181
|
+
/** DatabaseConnection class with static connect() factory method */
|
|
182
|
+
DatabaseConnection: {
|
|
183
|
+
connect(databaseCode: string): Promise<IDatabaseConnection>;
|
|
184
|
+
};
|
|
185
|
+
/** Base error class for all Database errors (abstract) */
|
|
186
|
+
DatabaseError: typeof DatabaseErrorClass;
|
|
187
|
+
/** Error thrown when database doesn't exist */
|
|
188
|
+
DatabaseNotFoundError: typeof DatabaseNotFoundErrorClass;
|
|
189
|
+
/** Error thrown when application has no access grant */
|
|
190
|
+
DatabaseAccessDeniedError: typeof DatabaseAccessDeniedErrorClass;
|
|
191
|
+
/** Error thrown when connection cannot be established */
|
|
192
|
+
DatabaseConnectionError: typeof DatabaseConnectionErrorClass;
|
|
193
|
+
/** Error thrown when query execution fails */
|
|
194
|
+
DatabaseQueryError: typeof DatabaseQueryErrorClass;
|
|
195
|
+
/** Error thrown when transaction fails */
|
|
196
|
+
DatabaseTransactionError: typeof DatabaseTransactionErrorClass;
|
|
197
|
+
/** Type guard to check if error is a DatabaseError */
|
|
198
|
+
isDatabaseError: typeof isDatabaseError;
|
|
199
|
+
/** Type guard to check if error is a specific DatabaseError type */
|
|
200
|
+
isDatabaseErrorType: typeof isDatabaseErrorType;
|
|
201
|
+
/** Secret class with static get() method */
|
|
202
|
+
Secret: {
|
|
203
|
+
get(secretCode: string): Promise<string>;
|
|
204
|
+
exists(secretCode: string): Promise<boolean>;
|
|
205
|
+
};
|
|
206
|
+
/** Base error class for all Secret errors (abstract) */
|
|
207
|
+
SecretError: typeof SecretErrorClass;
|
|
208
|
+
/** Error thrown when secret doesn't exist */
|
|
209
|
+
SecretNotFoundError: typeof SecretNotFoundErrorClass;
|
|
210
|
+
/** Error thrown when application has no access grant */
|
|
211
|
+
SecretAccessDeniedError: typeof SecretAccessDeniedErrorClass;
|
|
212
|
+
/** Error thrown when decryption fails */
|
|
213
|
+
SecretDecryptionError: typeof SecretDecryptionErrorClass;
|
|
214
|
+
/** Type guard to check if error is a SecretError */
|
|
215
|
+
isSecretError: typeof isSecretError;
|
|
216
|
+
/** Type guard to check if error is a specific SecretError type */
|
|
217
|
+
isSecretErrorType: typeof isSecretErrorType;
|
|
218
|
+
/** Excel class with static read() and create() methods */
|
|
219
|
+
Excel: {
|
|
220
|
+
read(buffer: Buffer): Promise<IExcelWorkbook>;
|
|
221
|
+
create(): IExcelWorkbook;
|
|
222
|
+
};
|
|
223
|
+
/** Base error class for all Excel errors (abstract) */
|
|
224
|
+
ExcelError: typeof ExcelErrorClass;
|
|
225
|
+
/** Error thrown when parsing Excel file fails */
|
|
226
|
+
ExcelParseError: typeof ExcelParseErrorClass;
|
|
227
|
+
/** Error thrown when writing Excel file fails */
|
|
228
|
+
ExcelWriteError: typeof ExcelWriteErrorClass;
|
|
229
|
+
/** Type guard to check if error is an ExcelError */
|
|
230
|
+
isExcelError: typeof isExcelError;
|
|
231
|
+
/** Type guard to check if error is a specific ExcelError type */
|
|
232
|
+
isExcelErrorType: typeof isExcelErrorType;
|
|
233
|
+
/** PDF class with static read() and create() methods */
|
|
234
|
+
Pdf: {
|
|
235
|
+
read(buffer: Buffer): Promise<IPdfDocument>;
|
|
236
|
+
create(): Promise<IPdfDocument>;
|
|
237
|
+
rgb(r: number, g: number, b: number): PdfRgbColor;
|
|
238
|
+
};
|
|
239
|
+
/** Base error class for all PDF errors (abstract) */
|
|
240
|
+
PdfError: typeof PdfErrorClass;
|
|
241
|
+
/** Error thrown when parsing PDF file fails */
|
|
242
|
+
PdfParseError: typeof PdfParseErrorClass;
|
|
243
|
+
/** Error thrown when writing PDF file fails */
|
|
244
|
+
PdfWriteError: typeof PdfWriteErrorClass;
|
|
245
|
+
/** Type guard to check if error is a PdfError */
|
|
246
|
+
isPdfError: typeof isPdfError;
|
|
247
|
+
/** Type guard to check if error is a specific PdfError type */
|
|
248
|
+
isPdfErrorType: typeof isPdfErrorType;
|
|
249
|
+
/** Job class with static methods for background job operations */
|
|
250
|
+
Job: {
|
|
251
|
+
runInBackground(params: RunInBackgroundParams): Promise<string>;
|
|
252
|
+
getStatus(jobId: string): Promise<JobStatus>;
|
|
253
|
+
list(params?: JobListParams): Promise<JobListResult>;
|
|
254
|
+
};
|
|
255
|
+
/** Base error class for all job errors */
|
|
256
|
+
JobError: typeof JobErrorClass;
|
|
257
|
+
/** Thrown when a job is not found */
|
|
258
|
+
JobNotFoundError: typeof JobNotFoundErrorClass;
|
|
259
|
+
/** Thrown when function name is invalid or missing */
|
|
260
|
+
InvalidFunctionError: typeof InvalidFunctionErrorClass;
|
|
261
|
+
/** Thrown when cross-app job lacks required permission */
|
|
262
|
+
CrossAppPermissionError: typeof CrossAppPermissionErrorClass;
|
|
263
|
+
/** Thrown when job execution fails */
|
|
264
|
+
JobExecutionError: typeof JobExecutionErrorClass;
|
|
265
|
+
/** Type guard to check if error is a JobError */
|
|
266
|
+
isJobError: typeof isJobError;
|
|
267
|
+
/** Type guard to check if error is a specific JobError type */
|
|
268
|
+
isJobErrorType: typeof isJobErrorType;
|
|
269
|
+
/** Messages class with static methods for sending messages to users */
|
|
270
|
+
Messages: MessagesManager;
|
|
271
|
+
/** Base error class for all message errors */
|
|
272
|
+
MessageError: typeof MessageErrorClass;
|
|
273
|
+
/** Error thrown when message validation fails */
|
|
274
|
+
MessageValidationError: typeof MessageValidationErrorClass;
|
|
275
|
+
/** Error thrown when group is not found */
|
|
276
|
+
GroupNotFoundError: typeof GroupNotFoundErrorClass;
|
|
277
|
+
/** Error thrown when TenantGrant permissions are missing */
|
|
278
|
+
TenantGrantPermissionDeniedError: typeof TenantGrantPermissionDeniedErrorClass;
|
|
279
|
+
/** Type guard to check if error is a MessageError */
|
|
280
|
+
isMessageError: typeof isMessageError;
|
|
281
|
+
/** Type guard to check if error is a specific MessageError type */
|
|
282
|
+
isMessageErrorType: typeof isMessageErrorType;
|
|
134
283
|
}
|
|
135
284
|
/**
|
|
136
285
|
* Volume - S3-backed storage for tenant applications
|
|
@@ -483,177 +632,20 @@ export declare class Job {
|
|
|
483
632
|
* Global declaration for the Ketrics VM sandbox.
|
|
484
633
|
*
|
|
485
634
|
* The `ketrics` global object provides:
|
|
486
|
-
* - Context: tenant, application, user,
|
|
635
|
+
* - Context: tenant, application, user, runtime, environment
|
|
487
636
|
* - Utilities: console, http
|
|
488
637
|
* - Volume: Static class for S3 storage
|
|
489
638
|
* - DatabaseConnection: Static class for database access
|
|
490
639
|
* - Secret: Static class for secret retrieval
|
|
640
|
+
* - Excel: Static class for Excel file operations
|
|
641
|
+
* - Pdf: Static class for PDF file operations
|
|
642
|
+
* - Job: Static class for background job execution
|
|
643
|
+
* - Messages: Static class for user messaging
|
|
491
644
|
* - Error classes: For instanceof checks
|
|
645
|
+
* - Type guards: For error type checking
|
|
492
646
|
*/
|
|
493
647
|
declare global {
|
|
494
648
|
/** Ketrics SDK global object - available in all tenant application code */
|
|
495
|
-
const ketrics: KetricsSdkV1
|
|
496
|
-
/**
|
|
497
|
-
* Volume class for S3-backed storage
|
|
498
|
-
*
|
|
499
|
-
* Use `ketrics.Volume.connect()` to get a connected volume instance.
|
|
500
|
-
*
|
|
501
|
-
* @example
|
|
502
|
-
* ```typescript
|
|
503
|
-
* const volume = await ketrics.Volume.connect('uploads');
|
|
504
|
-
* const file = await volume.get('document.pdf');
|
|
505
|
-
* ```
|
|
506
|
-
*/
|
|
507
|
-
Volume: {
|
|
508
|
-
connect(volumeCode: string): Promise<IVolume>;
|
|
509
|
-
};
|
|
510
|
-
/**
|
|
511
|
-
* DatabaseConnection class for external database access
|
|
512
|
-
*
|
|
513
|
-
* Use `ketrics.DatabaseConnection.connect()` to get a connected database instance.
|
|
514
|
-
*
|
|
515
|
-
* @example
|
|
516
|
-
* ```typescript
|
|
517
|
-
* const db = await ketrics.DatabaseConnection.connect('main-db');
|
|
518
|
-
* const result = await db.query('SELECT * FROM users');
|
|
519
|
-
* await db.close();
|
|
520
|
-
* ```
|
|
521
|
-
*/
|
|
522
|
-
DatabaseConnection: {
|
|
523
|
-
connect(databaseCode: string): Promise<IDatabaseConnection>;
|
|
524
|
-
};
|
|
525
|
-
/**
|
|
526
|
-
* Secret class for encrypted secret retrieval
|
|
527
|
-
*
|
|
528
|
-
* Use `ketrics.Secret.get()` to retrieve a secret value.
|
|
529
|
-
*
|
|
530
|
-
* @example
|
|
531
|
-
* ```typescript
|
|
532
|
-
* const apiKey = await ketrics.Secret.get('stripe-api-key');
|
|
533
|
-
* ```
|
|
534
|
-
*/
|
|
535
|
-
Secret: {
|
|
536
|
-
get(secretCode: string): Promise<string>;
|
|
537
|
-
exists(secretCode: string): Promise<boolean>;
|
|
538
|
-
};
|
|
539
|
-
/**
|
|
540
|
-
* Excel class for reading and writing Excel files
|
|
541
|
-
*
|
|
542
|
-
* Use `ketrics.Excel.read()` to parse an Excel file or
|
|
543
|
-
* `ketrics.Excel.create()` to create a new workbook.
|
|
544
|
-
*
|
|
545
|
-
* @example
|
|
546
|
-
* ```typescript
|
|
547
|
-
* const workbook = await ketrics.Excel.read(file.content);
|
|
548
|
-
* const sheet = workbook.getWorksheet('Sheet1');
|
|
549
|
-
* ```
|
|
550
|
-
*/
|
|
551
|
-
Excel: {
|
|
552
|
-
read(buffer: Buffer): Promise<IExcelWorkbook>;
|
|
553
|
-
create(): IExcelWorkbook;
|
|
554
|
-
};
|
|
555
|
-
/**
|
|
556
|
-
* Pdf class for reading, creating, and modifying PDF files
|
|
557
|
-
*
|
|
558
|
-
* Use `ketrics.Pdf.read()` to parse a PDF file or
|
|
559
|
-
* `ketrics.Pdf.create()` to create a new document.
|
|
560
|
-
*
|
|
561
|
-
* @example
|
|
562
|
-
* ```typescript
|
|
563
|
-
* const doc = await ketrics.Pdf.read(file.content);
|
|
564
|
-
* console.log('Pages:', doc.getPageCount());
|
|
565
|
-
*
|
|
566
|
-
* const newDoc = await ketrics.Pdf.create();
|
|
567
|
-
* const page = newDoc.addPage('A4');
|
|
568
|
-
* await page.drawText('Hello!', { x: 50, y: 700, size: 24 });
|
|
569
|
-
* ```
|
|
570
|
-
*/
|
|
571
|
-
Pdf: {
|
|
572
|
-
read(buffer: Buffer): Promise<IPdfDocument>;
|
|
573
|
-
create(): Promise<IPdfDocument>;
|
|
574
|
-
rgb(r: number, g: number, b: number): PdfRgbColor;
|
|
575
|
-
};
|
|
576
|
-
/**
|
|
577
|
-
* Job class for background job execution
|
|
578
|
-
*
|
|
579
|
-
* Use `ketrics.Job.runInBackground()` to queue a background job,
|
|
580
|
-
* `ketrics.Job.getStatus()` to check job status, or
|
|
581
|
-
* `ketrics.Job.list()` to list jobs.
|
|
582
|
-
*
|
|
583
|
-
* @example
|
|
584
|
-
* ```typescript
|
|
585
|
-
* const jobId = await ketrics.Job.runInBackground({
|
|
586
|
-
* function: 'generateReport',
|
|
587
|
-
* payload: { year: 2024 }
|
|
588
|
-
* });
|
|
589
|
-
* const status = await ketrics.Job.getStatus(jobId);
|
|
590
|
-
* ```
|
|
591
|
-
*/
|
|
592
|
-
Job: {
|
|
593
|
-
runInBackground(params: RunInBackgroundParams): Promise<string>;
|
|
594
|
-
getStatus(jobId: string): Promise<JobStatus>;
|
|
595
|
-
list(params?: JobListParams): Promise<JobListResult>;
|
|
596
|
-
};
|
|
597
|
-
/** Base class for all volume errors */
|
|
598
|
-
VolumeError: typeof VolumeErrorClass;
|
|
599
|
-
/** Thrown when a volume does not exist */
|
|
600
|
-
VolumeNotFoundError: typeof VolumeNotFoundErrorClass;
|
|
601
|
-
/** Thrown when application has no access grant to volume */
|
|
602
|
-
VolumeAccessDeniedError: typeof VolumeAccessDeniedErrorClass;
|
|
603
|
-
/** Thrown when operation requires a permission not granted */
|
|
604
|
-
VolumePermissionDeniedError: typeof VolumePermissionDeniedErrorClass;
|
|
605
|
-
/** Thrown when a file does not exist */
|
|
606
|
-
FileNotFoundError: typeof FileNotFoundErrorClass;
|
|
607
|
-
/** Thrown when file already exists (with ifNotExists option) */
|
|
608
|
-
FileAlreadyExistsError: typeof FileAlreadyExistsErrorClass;
|
|
609
|
-
/** Thrown when file path is invalid */
|
|
610
|
-
InvalidPathError: typeof InvalidPathErrorClass;
|
|
611
|
-
/** Thrown when file exceeds size limit */
|
|
612
|
-
FileSizeLimitError: typeof FileSizeLimitErrorClass;
|
|
613
|
-
/** Thrown when content type is not allowed */
|
|
614
|
-
ContentTypeNotAllowedError: typeof ContentTypeNotAllowedErrorClass;
|
|
615
|
-
/** Base class for all database errors */
|
|
616
|
-
DatabaseError: typeof DatabaseErrorClass;
|
|
617
|
-
/** Thrown when a database does not exist */
|
|
618
|
-
DatabaseNotFoundError: typeof DatabaseNotFoundErrorClass;
|
|
619
|
-
/** Thrown when application has no access grant to database */
|
|
620
|
-
DatabaseAccessDeniedError: typeof DatabaseAccessDeniedErrorClass;
|
|
621
|
-
/** Thrown when database connection cannot be established */
|
|
622
|
-
DatabaseConnectionError: typeof DatabaseConnectionErrorClass;
|
|
623
|
-
/** Thrown when a database query fails */
|
|
624
|
-
DatabaseQueryError: typeof DatabaseQueryErrorClass;
|
|
625
|
-
/** Thrown when a database transaction fails */
|
|
626
|
-
DatabaseTransactionError: typeof DatabaseTransactionErrorClass;
|
|
627
|
-
/** Base class for all secret errors */
|
|
628
|
-
SecretError: typeof SecretErrorClass;
|
|
629
|
-
/** Thrown when a secret does not exist */
|
|
630
|
-
SecretNotFoundError: typeof SecretNotFoundErrorClass;
|
|
631
|
-
/** Thrown when application has no access grant to secret */
|
|
632
|
-
SecretAccessDeniedError: typeof SecretAccessDeniedErrorClass;
|
|
633
|
-
/** Thrown when secret decryption fails */
|
|
634
|
-
SecretDecryptionError: typeof SecretDecryptionErrorClass;
|
|
635
|
-
/** Base class for all Excel errors */
|
|
636
|
-
ExcelError: typeof ExcelErrorClass;
|
|
637
|
-
/** Thrown when an Excel file cannot be parsed */
|
|
638
|
-
ExcelParseError: typeof ExcelParseErrorClass;
|
|
639
|
-
/** Thrown when an Excel file cannot be written */
|
|
640
|
-
ExcelWriteError: typeof ExcelWriteErrorClass;
|
|
641
|
-
/** Base class for all PDF errors */
|
|
642
|
-
PdfError: typeof PdfErrorClass;
|
|
643
|
-
/** Thrown when a PDF file cannot be parsed */
|
|
644
|
-
PdfParseError: typeof PdfParseErrorClass;
|
|
645
|
-
/** Thrown when a PDF file cannot be written */
|
|
646
|
-
PdfWriteError: typeof PdfWriteErrorClass;
|
|
647
|
-
/** Base class for all job errors */
|
|
648
|
-
JobError: typeof JobErrorClass;
|
|
649
|
-
/** Thrown when a job is not found */
|
|
650
|
-
JobNotFoundError: typeof JobNotFoundErrorClass;
|
|
651
|
-
/** Thrown when function name is invalid or missing */
|
|
652
|
-
InvalidFunctionError: typeof InvalidFunctionErrorClass;
|
|
653
|
-
/** Thrown when cross-app job lacks required permission */
|
|
654
|
-
CrossAppPermissionError: typeof CrossAppPermissionErrorClass;
|
|
655
|
-
/** Thrown when job execution fails */
|
|
656
|
-
JobExecutionError: typeof JobExecutionErrorClass;
|
|
657
|
-
};
|
|
649
|
+
const ketrics: KetricsSdkV1;
|
|
658
650
|
}
|
|
659
651
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAuDG;AAMH,OAAO,EACL,aAAa,EACb,kBAAkB,EAClB,WAAW,EACX,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAuDG;AAMH,OAAO,EACL,aAAa,EACb,kBAAkB,EAClB,WAAW,EACX,cAAc,EACd,oBAAoB,GACrB,MAAM,WAAW,CAAC;AAMnB,OAAO,EAAE,aAAa,EAAE,MAAM,WAAW,CAAC;AAM1C,OAAO,EAAE,iBAAiB,EAAE,YAAY,EAAE,UAAU,EAAE,MAAM,QAAQ,CAAC;AAMrE,OAAO,EACL,mBAAmB,EACnB,qBAAqB,EACrB,mBAAmB,EACnB,eAAe,GAChB,MAAM,aAAa,CAAC;AAMrB,OAAO,EACL,aAAa,EACb,qBAAqB,EACrB,yBAAyB,EACzB,uBAAuB,EACvB,kBAAkB,EAClB,wBAAwB,EACxB,e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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAsCG;AACH,MAAM,CAAC,OAAO,OAAO,GAAG;IACtB,OAAO;IAEP;;;;;;;OAOG;IACH,MAAM,CAAC,eAAe,CAAC,MAAM,EAAE,qBAAqB,GAAG,OAAO,CAAC,MAAM,CAAC;IAEtE;;;;;;OAMG;IACH,MAAM,CAAC,SAAS,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC,SAAS,CAAC;IAEnD;;;;;OAKG;IACH,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,EAAE,aAAa,GAAG,OAAO,CAAC,aAAa,CAAC;CAC5D;AAMD;;;;;;;;;;;;;;;GAeG;AACH,OAAO,CAAC,MAAM,CAAC;IACb,2EAA2E;IAC3E,MAAM,OAAO,EAAE,YAAY,CAAC;CAC7B"}
|
package/dist/index.js
CHANGED
|
@@ -56,7 +56,7 @@
|
|
|
56
56
|
* ```
|
|
57
57
|
*/
|
|
58
58
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
59
|
-
exports.isVolumeErrorType = exports.isVolumeError = exports.ContentTypeNotAllowedError = exports.FileSizeLimitError = exports.InvalidPathError = exports.FileAlreadyExistsError = exports.FileNotFoundError = exports.VolumePermissionDeniedError = exports.VolumeAccessDeniedError = exports.VolumeNotFoundError = exports.VolumeError = exports.isJobErrorType = exports.isJobError = exports.JobExecutionError = exports.CrossAppPermissionError = exports.InvalidFunctionError = exports.JobNotFoundError = exports.JobError = exports.isPdfErrorType = exports.isPdfError = exports.PdfWriteError = exports.PdfParseError = exports.PdfError = exports.isExcelErrorType = exports.isExcelError = exports.ExcelWriteError = exports.ExcelParseError = exports.ExcelError = exports.isSecretErrorType = exports.isSecretError = exports.SecretDecryptionError = exports.SecretAccessDeniedError = exports.SecretNotFoundError = exports.SecretError = exports.isDatabaseErrorType = exports.isDatabaseError = exports.DatabaseTransactionError = exports.DatabaseQueryError = exports.DatabaseConnectionError = exports.DatabaseAccessDeniedError = exports.DatabaseNotFoundError = exports.DatabaseError = void 0;
|
|
59
|
+
exports.isVolumeErrorType = exports.isVolumeError = exports.ContentTypeNotAllowedError = exports.FileSizeLimitError = exports.InvalidPathError = exports.FileAlreadyExistsError = exports.FileNotFoundError = exports.VolumePermissionDeniedError = exports.VolumeAccessDeniedError = exports.VolumeNotFoundError = exports.VolumeError = exports.isMessageErrorType = exports.isMessageError = exports.TenantGrantPermissionDeniedError = exports.GroupNotFoundError = exports.MessageValidationError = exports.MessageError = exports.isJobErrorType = exports.isJobError = exports.JobExecutionError = exports.CrossAppPermissionError = exports.InvalidFunctionError = exports.JobNotFoundError = exports.JobError = exports.isPdfErrorType = exports.isPdfError = exports.PdfWriteError = exports.PdfParseError = exports.PdfError = exports.isExcelErrorType = exports.isExcelError = exports.ExcelWriteError = exports.ExcelParseError = exports.ExcelError = exports.isSecretErrorType = exports.isSecretError = exports.SecretDecryptionError = exports.SecretAccessDeniedError = exports.SecretNotFoundError = exports.SecretError = exports.isDatabaseErrorType = exports.isDatabaseError = exports.DatabaseTransactionError = exports.DatabaseQueryError = exports.DatabaseConnectionError = exports.DatabaseAccessDeniedError = exports.DatabaseNotFoundError = exports.DatabaseError = void 0;
|
|
60
60
|
// ============================================================================
|
|
61
61
|
// Database Error Exports
|
|
62
62
|
// ============================================================================
|
|
@@ -109,6 +109,16 @@ Object.defineProperty(exports, "JobExecutionError", { enumerable: true, get: fun
|
|
|
109
109
|
Object.defineProperty(exports, "isJobError", { enumerable: true, get: function () { return job_errors_1.isJobError; } });
|
|
110
110
|
Object.defineProperty(exports, "isJobErrorType", { enumerable: true, get: function () { return job_errors_1.isJobErrorType; } });
|
|
111
111
|
// ============================================================================
|
|
112
|
+
// Messages Error Exports
|
|
113
|
+
// ============================================================================
|
|
114
|
+
var messages_errors_1 = require("./messages-errors");
|
|
115
|
+
Object.defineProperty(exports, "MessageError", { enumerable: true, get: function () { return messages_errors_1.MessageError; } });
|
|
116
|
+
Object.defineProperty(exports, "MessageValidationError", { enumerable: true, get: function () { return messages_errors_1.MessageValidationError; } });
|
|
117
|
+
Object.defineProperty(exports, "GroupNotFoundError", { enumerable: true, get: function () { return messages_errors_1.GroupNotFoundError; } });
|
|
118
|
+
Object.defineProperty(exports, "TenantGrantPermissionDeniedError", { enumerable: true, get: function () { return messages_errors_1.TenantGrantPermissionDeniedError; } });
|
|
119
|
+
Object.defineProperty(exports, "isMessageError", { enumerable: true, get: function () { return messages_errors_1.isMessageError; } });
|
|
120
|
+
Object.defineProperty(exports, "isMessageErrorType", { enumerable: true, get: function () { return messages_errors_1.isMessageErrorType; } });
|
|
121
|
+
// ============================================================================
|
|
112
122
|
// Volume Error Exports
|
|
113
123
|
// ============================================================================
|
|
114
124
|
var errors_1 = require("./errors");
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAuDG;;;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAuDG;;;AAqCH,+EAA+E;AAC/E,yBAAyB;AACzB,+EAA+E;AAE/E,qDAS2B;AARzB,gHAAA,aAAa,OAAA;AACb,wHAAA,qBAAqB,OAAA;AACrB,4HAAA,yBAAyB,OAAA;AACzB,0HAAA,uBAAuB,OAAA;AACvB,qHAAA,kBAAkB,OAAA;AAClB,2HAAA,wBAAwB,OAAA;AACxB,kHAAA,eAAe,OAAA;AACf,sHAAA,mBAAmB,OAAA;AASrB,+EAA+E;AAC/E,uBAAuB;AACvB,+EAA+E;AAE/E,iDAOyB;AANvB,4GAAA,WAAW,OAAA;AACX,oHAAA,mBAAmB,OAAA;AACnB,wHAAA,uBAAuB,OAAA;AACvB,sHAAA,qBAAqB,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1B,cAAc;AACd,uGAAA,aAAa,OAAA;AACb,2GAAA,iBAAiB,OAAA"}
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Ketrics SDK - Messages Error Classes
|
|
3
|
+
*
|
|
4
|
+
* Provides error class definitions for the Messages SDK.
|
|
5
|
+
* These classes are used for error handling in tenant applications.
|
|
6
|
+
*
|
|
7
|
+
* Usage in tenant code:
|
|
8
|
+
* ```typescript
|
|
9
|
+
* try {
|
|
10
|
+
* await ketrics.Messages.sendToGroup({
|
|
11
|
+
* groupCode: 'engineering-team',
|
|
12
|
+
* type: 'TEAM_UPDATE',
|
|
13
|
+
* subject: 'Sprint planning',
|
|
14
|
+
* body: '...'
|
|
15
|
+
* });
|
|
16
|
+
* } catch (error) {
|
|
17
|
+
* if (error instanceof ketrics.MessageValidationError) {
|
|
18
|
+
* console.log('Invalid message parameters:', error.message);
|
|
19
|
+
* } else if (error instanceof ketrics.GroupNotFoundError) {
|
|
20
|
+
* console.log('Group not found:', error.message);
|
|
21
|
+
* } else if (error instanceof ketrics.TenantGrantPermissionDeniedError) {
|
|
22
|
+
* console.log('Missing permissions:', error.missingPermissions);
|
|
23
|
+
* }
|
|
24
|
+
* }
|
|
25
|
+
* ```
|
|
26
|
+
*/
|
|
27
|
+
/**
|
|
28
|
+
* Base error class for message-related errors
|
|
29
|
+
*/
|
|
30
|
+
export declare class MessageError extends Error {
|
|
31
|
+
readonly code: string;
|
|
32
|
+
constructor(message: string, code?: string);
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* Error thrown when message validation fails
|
|
36
|
+
*/
|
|
37
|
+
export declare class MessageValidationError extends MessageError {
|
|
38
|
+
constructor(message: string);
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* Error thrown when group is not found
|
|
42
|
+
*/
|
|
43
|
+
export declare class GroupNotFoundError extends MessageError {
|
|
44
|
+
constructor(groupCode: string);
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* Error thrown when application IAM-data permission is missing
|
|
48
|
+
*
|
|
49
|
+
* This error is thrown when an application tries to access tenant data
|
|
50
|
+
* (users, groups, group memberships) without having the required
|
|
51
|
+
* IAM-data permissions assigned via its role.
|
|
52
|
+
*/
|
|
53
|
+
export declare class TenantGrantPermissionDeniedError extends MessageError {
|
|
54
|
+
readonly missingPermissions: string[];
|
|
55
|
+
constructor(message: string, code?: string);
|
|
56
|
+
/**
|
|
57
|
+
* Factory method to create error with permissions list
|
|
58
|
+
*/
|
|
59
|
+
static withPermissions(permissions: string[]): TenantGrantPermissionDeniedError;
|
|
60
|
+
}
|
|
61
|
+
/**
|
|
62
|
+
* Type guard to check if an error is a MessageError
|
|
63
|
+
*/
|
|
64
|
+
export declare function isMessageError(error: unknown): error is MessageError;
|
|
65
|
+
/**
|
|
66
|
+
* Type guard to check if an error is a specific MessageError type
|
|
67
|
+
*/
|
|
68
|
+
export declare function isMessageErrorType<T extends MessageError>(error: unknown, errorClass: new (...args: any[]) => T): error is T;
|
|
69
|
+
//# sourceMappingURL=messages-errors.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"messages-errors.d.ts","sourceRoot":"","sources":["../src/messages-errors.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AAMH;;GAEG;AACH,qBAAa,YAAa,SAAQ,KAAK;IACrC,SAAgB,IAAI,EAAE,MAAM,CAAC;gBAEjB,OAAO,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,MAAM;CAK3C;AAMD;;GAEG;AACH,qBAAa,sBAAuB,SAAQ,YAAY;gBAC1C,OAAO,EAAE,MAAM;CAI5B;AAED;;GAEG;AACH,qBAAa,kBAAmB,SAAQ,YAAY;gBACtC,SAAS,EAAE,MAAM;CAI9B;AAED;;;;;;GAMG;AACH,qBAAa,gCAAiC,SAAQ,YAAY;IAChE,SAAgB,kBAAkB,EAAE,MAAM,EAAE,CAAC;gBAEjC,OAAO,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,MAAM;IAQ1C;;OAEG;IACH,MAAM,CAAC,eAAe,CAAC,WAAW,EAAE,MAAM,EAAE,GAAG,gCAAgC;CAMhF;AAMD;;GAEG;AACH,wBAAgB,cAAc,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,YAAY,CAEpE;AAED;;GAEG;AACH,wBAAgB,kBAAkB,CAAC,CAAC,SAAS,YAAY,EACvD,KAAK,EAAE,OAAO,EAEd,UAAU,EAAE,KAAK,GAAG,IAAI,EAAE,GAAG,EAAE,KAAK,CAAC,GACpC,KAAK,IAAI,CAAC,CAEZ"}
|
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Ketrics SDK - Messages Error Classes
|
|
4
|
+
*
|
|
5
|
+
* Provides error class definitions for the Messages SDK.
|
|
6
|
+
* These classes are used for error handling in tenant applications.
|
|
7
|
+
*
|
|
8
|
+
* Usage in tenant code:
|
|
9
|
+
* ```typescript
|
|
10
|
+
* try {
|
|
11
|
+
* await ketrics.Messages.sendToGroup({
|
|
12
|
+
* groupCode: 'engineering-team',
|
|
13
|
+
* type: 'TEAM_UPDATE',
|
|
14
|
+
* subject: 'Sprint planning',
|
|
15
|
+
* body: '...'
|
|
16
|
+
* });
|
|
17
|
+
* } catch (error) {
|
|
18
|
+
* if (error instanceof ketrics.MessageValidationError) {
|
|
19
|
+
* console.log('Invalid message parameters:', error.message);
|
|
20
|
+
* } else if (error instanceof ketrics.GroupNotFoundError) {
|
|
21
|
+
* console.log('Group not found:', error.message);
|
|
22
|
+
* } else if (error instanceof ketrics.TenantGrantPermissionDeniedError) {
|
|
23
|
+
* console.log('Missing permissions:', error.missingPermissions);
|
|
24
|
+
* }
|
|
25
|
+
* }
|
|
26
|
+
* ```
|
|
27
|
+
*/
|
|
28
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
29
|
+
exports.TenantGrantPermissionDeniedError = exports.GroupNotFoundError = exports.MessageValidationError = exports.MessageError = void 0;
|
|
30
|
+
exports.isMessageError = isMessageError;
|
|
31
|
+
exports.isMessageErrorType = isMessageErrorType;
|
|
32
|
+
// ============================================================================
|
|
33
|
+
// Base Message Error
|
|
34
|
+
// ============================================================================
|
|
35
|
+
/**
|
|
36
|
+
* Base error class for message-related errors
|
|
37
|
+
*/
|
|
38
|
+
class MessageError extends Error {
|
|
39
|
+
constructor(message, code) {
|
|
40
|
+
super(message);
|
|
41
|
+
this.name = 'MessageError';
|
|
42
|
+
this.code = code ?? 'MESSAGE_ERROR';
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
exports.MessageError = MessageError;
|
|
46
|
+
// ============================================================================
|
|
47
|
+
// Specific Message Errors
|
|
48
|
+
// ============================================================================
|
|
49
|
+
/**
|
|
50
|
+
* Error thrown when message validation fails
|
|
51
|
+
*/
|
|
52
|
+
class MessageValidationError extends MessageError {
|
|
53
|
+
constructor(message) {
|
|
54
|
+
super(message, 'VALIDATION_ERROR');
|
|
55
|
+
this.name = 'MessageValidationError';
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
exports.MessageValidationError = MessageValidationError;
|
|
59
|
+
/**
|
|
60
|
+
* Error thrown when group is not found
|
|
61
|
+
*/
|
|
62
|
+
class GroupNotFoundError extends MessageError {
|
|
63
|
+
constructor(groupCode) {
|
|
64
|
+
super(`Group not found: ${groupCode}`, 'GROUP_NOT_FOUND');
|
|
65
|
+
this.name = 'GroupNotFoundError';
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
exports.GroupNotFoundError = GroupNotFoundError;
|
|
69
|
+
/**
|
|
70
|
+
* Error thrown when application IAM-data permission is missing
|
|
71
|
+
*
|
|
72
|
+
* This error is thrown when an application tries to access tenant data
|
|
73
|
+
* (users, groups, group memberships) without having the required
|
|
74
|
+
* IAM-data permissions assigned via its role.
|
|
75
|
+
*/
|
|
76
|
+
class TenantGrantPermissionDeniedError extends MessageError {
|
|
77
|
+
constructor(message, code) {
|
|
78
|
+
super(message, code ?? 'PERMISSION_DENIED');
|
|
79
|
+
this.name = 'TenantGrantPermissionDeniedError';
|
|
80
|
+
// Parse missing permissions from message if it follows the standard format
|
|
81
|
+
const match = message.match(/permissions: (.+)/);
|
|
82
|
+
this.missingPermissions = match ? match[1].split(', ') : [];
|
|
83
|
+
}
|
|
84
|
+
/**
|
|
85
|
+
* Factory method to create error with permissions list
|
|
86
|
+
*/
|
|
87
|
+
static withPermissions(permissions) {
|
|
88
|
+
return new TenantGrantPermissionDeniedError(`Application is missing required IAM-data permissions: ${permissions.join(', ')}. ` +
|
|
89
|
+
`Assign a role with these permissions to the application.`);
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
exports.TenantGrantPermissionDeniedError = TenantGrantPermissionDeniedError;
|
|
93
|
+
// ============================================================================
|
|
94
|
+
// Type Guards
|
|
95
|
+
// ============================================================================
|
|
96
|
+
/**
|
|
97
|
+
* Type guard to check if an error is a MessageError
|
|
98
|
+
*/
|
|
99
|
+
function isMessageError(error) {
|
|
100
|
+
return error instanceof MessageError;
|
|
101
|
+
}
|
|
102
|
+
/**
|
|
103
|
+
* Type guard to check if an error is a specific MessageError type
|
|
104
|
+
*/
|
|
105
|
+
function isMessageErrorType(error,
|
|
106
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
107
|
+
errorClass) {
|
|
108
|
+
return error instanceof errorClass;
|
|
109
|
+
}
|
|
110
|
+
//# sourceMappingURL=messages-errors.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"messages-errors.js","sourceRoot":"","sources":["../src/messages-errors.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;;;AA+EH,wCAEC;AAKD,gDAMC;AA1FD,+EAA+E;AAC/E,qBAAqB;AACrB,+EAA+E;AAE/E;;GAEG;AACH,MAAa,YAAa,SAAQ,KAAK;IAGrC,YAAY,OAAe,EAAE,IAA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E;AAC/E,cAAc;AACd,+EAA+E;AAE/E;;GAEG;AACH,SAAgB,cAAc,CAAC,KAAc;IAC3C,OAAO,KAAK,YAAY,YAAY,CAAC;AACvC,CAAC;AAED;;GAEG;AACH,SAAgB,kBAAkB,CAChC,KAAc;AACd,8DAA8D;AAC9D,UAAqC;IAErC,OAAO,KAAK,YAAY,UAAU,CAAC;AACrC,CAAC"}
|
|
@@ -0,0 +1,163 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Ketrics SDK - Messages Interfaces and Types
|
|
3
|
+
*
|
|
4
|
+
* Provides type definitions for the Messages SDK that allows
|
|
5
|
+
* tenant applications to send messages to users.
|
|
6
|
+
*
|
|
7
|
+
* Usage in tenant code:
|
|
8
|
+
* ```typescript
|
|
9
|
+
* // Send single message
|
|
10
|
+
* const result = await ketrics.Messages.send({
|
|
11
|
+
* userId: 'user-123',
|
|
12
|
+
* type: 'ORDER_SHIPPED',
|
|
13
|
+
* subject: 'Your order has shipped!',
|
|
14
|
+
* body: 'Track your package...',
|
|
15
|
+
* priority: 'HIGH'
|
|
16
|
+
* });
|
|
17
|
+
*
|
|
18
|
+
* // Send to multiple users
|
|
19
|
+
* const bulk = await ketrics.Messages.sendBulk({
|
|
20
|
+
* userIds: ['user-1', 'user-2'],
|
|
21
|
+
* type: 'ANNOUNCEMENT',
|
|
22
|
+
* subject: 'Important update',
|
|
23
|
+
* body: '...'
|
|
24
|
+
* });
|
|
25
|
+
*
|
|
26
|
+
* // Send to a group (requires IAM-data permissions via application role)
|
|
27
|
+
* const group = await ketrics.Messages.sendToGroup({
|
|
28
|
+
* groupCode: 'engineering-team',
|
|
29
|
+
* type: 'TEAM_UPDATE',
|
|
30
|
+
* subject: 'Sprint planning tomorrow',
|
|
31
|
+
* body: '...'
|
|
32
|
+
* });
|
|
33
|
+
* ```
|
|
34
|
+
*
|
|
35
|
+
* Key Distinction:
|
|
36
|
+
* - Messages: Content sent by apps to users, stored in their inbox
|
|
37
|
+
* - Notifications: Alerts (push) that tell users about new messages
|
|
38
|
+
*/
|
|
39
|
+
/**
|
|
40
|
+
* Message priority level
|
|
41
|
+
*/
|
|
42
|
+
export type MessagePriorityLevel = 'LOW' | 'MEDIUM' | 'HIGH';
|
|
43
|
+
/**
|
|
44
|
+
* Channel configuration for message delivery
|
|
45
|
+
*/
|
|
46
|
+
export interface MessageChannelConfig {
|
|
47
|
+
/** Store in user's inbox (always enabled) */
|
|
48
|
+
inbox: boolean;
|
|
49
|
+
/** Send push notification alert */
|
|
50
|
+
push: boolean;
|
|
51
|
+
}
|
|
52
|
+
/**
|
|
53
|
+
* Parameters for Messages.send()
|
|
54
|
+
*/
|
|
55
|
+
export interface SendMessageParams {
|
|
56
|
+
/** Recipient user ID */
|
|
57
|
+
userId: string;
|
|
58
|
+
/** Application-defined message type */
|
|
59
|
+
type: string;
|
|
60
|
+
/** Message subject/title (max 200 chars) */
|
|
61
|
+
subject: string;
|
|
62
|
+
/** Message body (max 10,000 chars, markdown supported) */
|
|
63
|
+
body: string;
|
|
64
|
+
/** Priority level (default: MEDIUM) */
|
|
65
|
+
priority?: MessagePriorityLevel;
|
|
66
|
+
/** Optional channel overrides */
|
|
67
|
+
channels?: Partial<MessageChannelConfig>;
|
|
68
|
+
/** Optional action URL for deep linking */
|
|
69
|
+
actionUrl?: string;
|
|
70
|
+
/** Optional custom data for app use */
|
|
71
|
+
data?: Record<string, unknown>;
|
|
72
|
+
/** Optional expiration timestamp (ISO) */
|
|
73
|
+
expiresAt?: string;
|
|
74
|
+
}
|
|
75
|
+
/**
|
|
76
|
+
* Parameters for Messages.sendBulk()
|
|
77
|
+
*/
|
|
78
|
+
export interface SendBulkMessageParams {
|
|
79
|
+
/** Array of user IDs to message */
|
|
80
|
+
userIds: string[];
|
|
81
|
+
/** Message content (same for all recipients) */
|
|
82
|
+
type: string;
|
|
83
|
+
subject: string;
|
|
84
|
+
body: string;
|
|
85
|
+
priority?: MessagePriorityLevel;
|
|
86
|
+
channels?: Partial<MessageChannelConfig>;
|
|
87
|
+
actionUrl?: string;
|
|
88
|
+
data?: Record<string, unknown>;
|
|
89
|
+
expiresAt?: string;
|
|
90
|
+
}
|
|
91
|
+
/**
|
|
92
|
+
* Parameters for Messages.sendToGroup()
|
|
93
|
+
*/
|
|
94
|
+
export interface SendGroupMessageParams {
|
|
95
|
+
/** Group code to send message to */
|
|
96
|
+
groupCode: string;
|
|
97
|
+
/** Message content (same for all group members) */
|
|
98
|
+
type: string;
|
|
99
|
+
subject: string;
|
|
100
|
+
body: string;
|
|
101
|
+
priority?: MessagePriorityLevel;
|
|
102
|
+
channels?: Partial<MessageChannelConfig>;
|
|
103
|
+
actionUrl?: string;
|
|
104
|
+
data?: Record<string, unknown>;
|
|
105
|
+
expiresAt?: string;
|
|
106
|
+
}
|
|
107
|
+
/**
|
|
108
|
+
* Result of sending a single message
|
|
109
|
+
*/
|
|
110
|
+
export interface SendMessageResult {
|
|
111
|
+
messageId: string;
|
|
112
|
+
userId: string;
|
|
113
|
+
status: 'sent' | 'failed';
|
|
114
|
+
error?: string;
|
|
115
|
+
}
|
|
116
|
+
/**
|
|
117
|
+
* Result of sending bulk messages
|
|
118
|
+
*/
|
|
119
|
+
export interface SendBulkMessageResult {
|
|
120
|
+
total: number;
|
|
121
|
+
sent: number;
|
|
122
|
+
failed: number;
|
|
123
|
+
results: SendMessageResult[];
|
|
124
|
+
}
|
|
125
|
+
/**
|
|
126
|
+
* Messages SDK module interface
|
|
127
|
+
*
|
|
128
|
+
* Provides methods for sending messages to users in tenant applications.
|
|
129
|
+
*/
|
|
130
|
+
export interface MessagesManager {
|
|
131
|
+
/**
|
|
132
|
+
* Send message to a single user
|
|
133
|
+
* No TenantGrant required (userId is explicit)
|
|
134
|
+
*
|
|
135
|
+
* @param params - Message parameters
|
|
136
|
+
* @returns Result with messageId and status
|
|
137
|
+
* @throws MessageValidationError if parameters are invalid
|
|
138
|
+
*/
|
|
139
|
+
send(params: SendMessageParams): Promise<SendMessageResult>;
|
|
140
|
+
/**
|
|
141
|
+
* Send message to multiple users
|
|
142
|
+
* No TenantGrant required (userIds are explicit)
|
|
143
|
+
*
|
|
144
|
+
* @param params - Bulk message parameters
|
|
145
|
+
* @returns Results with counts and individual statuses
|
|
146
|
+
* @throws MessageValidationError if parameters are invalid
|
|
147
|
+
*/
|
|
148
|
+
sendBulk(params: SendBulkMessageParams): Promise<SendBulkMessageResult>;
|
|
149
|
+
/**
|
|
150
|
+
* Send message to all members of a group
|
|
151
|
+
*
|
|
152
|
+
* Requires IAM-data permissions: iam:GetGroupData + iam:GetMembershipData
|
|
153
|
+
* These permissions must be assigned to the application via its role.
|
|
154
|
+
*
|
|
155
|
+
* @param params - Group message parameters
|
|
156
|
+
* @returns Results with counts and individual statuses
|
|
157
|
+
* @throws MessageValidationError if parameters are invalid
|
|
158
|
+
* @throws GroupNotFoundError if group doesn't exist
|
|
159
|
+
* @throws TenantGrantPermissionDeniedError if IAM-data permissions are missing
|
|
160
|
+
*/
|
|
161
|
+
sendToGroup(params: SendGroupMessageParams): Promise<SendBulkMessageResult>;
|
|
162
|
+
}
|
|
163
|
+
//# sourceMappingURL=messages.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"messages.d.ts","sourceRoot":"","sources":["../src/messages.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAqCG;AAMH;;GAEG;AACH,MAAM,MAAM,oBAAoB,GAAG,KAAK,GAAG,QAAQ,GAAG,MAAM,CAAC;AAM7D;;GAEG;AACH,MAAM,WAAW,oBAAoB;IACnC,6CAA6C;IAC7C,KAAK,EAAE,OAAO,CAAC;IACf,mCAAmC;IACnC,IAAI,EAAE,OAAO,CAAC;CACf;AAMD;;GAEG;AACH,MAAM,WAAW,iBAAiB;IAChC,wBAAwB;IACxB,MAAM,EAAE,MAAM,CAAC;IACf,uCAAuC;IACvC,IAAI,EAAE,MAAM,CAAC;IACb,4CAA4C;IAC5C,OAAO,EAA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ACpB;AAMD;;GAEG;AACH,MAAM,WAAW,iBAAiB;IAChC,SAAS,EAAE,MAAM,CAAC;IAClB,MAAM,EAAE,MAAM,CAAC;IACf,MAAM,EAAE,MAAM,GAAG,QAAQ,CAAC;IAC1B,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB;AAED;;GAEG;AACH,MAAM,WAAW,qBAAqB;IACpC,KAAK,EAAE,MAAM,CAAC;IACd,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,EAAE,MAAM,CAAC;IACf,OAAO,EAAE,iBAAiB,EAAE,CAAC;CAC9B;AAMD;;;;GAIG;AACH,MAAM,WAAW,eAAe;IAC9B;;;;;;;OAOG;IACH,IAAI,CAAC,MAAM,EAAE,iBAAiB,GAAG,OAAO,CAAC,iBAAiB,CAAC,CAAC;IAE5D;;;;;;;OAOG;IACH,QAAQ,CAAC,MAAM,EAAE,qBAAqB,GAAG,OAAO,CAAC,qBAAqB,CAAC,CAAC;IAExE;;;;;;;;;;;OAWG;IACH,WAAW,CAAC,MAAM,EAAE,sBAAsB,GAAG,OAAO,CAAC,qBAAqB,CAAC,CAAC;CAC7E"}
|
package/dist/messages.js
ADDED
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Ketrics SDK - Messages Interfaces and Types
|
|
4
|
+
*
|
|
5
|
+
* Provides type definitions for the Messages SDK that allows
|
|
6
|
+
* tenant applications to send messages to users.
|
|
7
|
+
*
|
|
8
|
+
* Usage in tenant code:
|
|
9
|
+
* ```typescript
|
|
10
|
+
* // Send single message
|
|
11
|
+
* const result = await ketrics.Messages.send({
|
|
12
|
+
* userId: 'user-123',
|
|
13
|
+
* type: 'ORDER_SHIPPED',
|
|
14
|
+
* subject: 'Your order has shipped!',
|
|
15
|
+
* body: 'Track your package...',
|
|
16
|
+
* priority: 'HIGH'
|
|
17
|
+
* });
|
|
18
|
+
*
|
|
19
|
+
* // Send to multiple users
|
|
20
|
+
* const bulk = await ketrics.Messages.sendBulk({
|
|
21
|
+
* userIds: ['user-1', 'user-2'],
|
|
22
|
+
* type: 'ANNOUNCEMENT',
|
|
23
|
+
* subject: 'Important update',
|
|
24
|
+
* body: '...'
|
|
25
|
+
* });
|
|
26
|
+
*
|
|
27
|
+
* // Send to a group (requires IAM-data permissions via application role)
|
|
28
|
+
* const group = await ketrics.Messages.sendToGroup({
|
|
29
|
+
* groupCode: 'engineering-team',
|
|
30
|
+
* type: 'TEAM_UPDATE',
|
|
31
|
+
* subject: 'Sprint planning tomorrow',
|
|
32
|
+
* body: '...'
|
|
33
|
+
* });
|
|
34
|
+
* ```
|
|
35
|
+
*
|
|
36
|
+
* Key Distinction:
|
|
37
|
+
* - Messages: Content sent by apps to users, stored in their inbox
|
|
38
|
+
* - Notifications: Alerts (push) that tell users about new messages
|
|
39
|
+
*/
|
|
40
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
41
|
+
//# sourceMappingURL=messages.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"messages.js","sourceRoot":"","sources":["../src/messages.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAqCG"}
|