@ketrics/sdk-backend 0.4.0 → 0.7.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 +38 -10
- package/dist/context.d.ts.map +1 -1
- package/dist/index.d.ts +166 -172
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +13 -2
- 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 +3 -3
package/dist/context.d.ts
CHANGED
|
@@ -37,26 +37,47 @@ 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
|
+
* @deprecated Use RequestorContext instead for clear distinction between users and service accounts
|
|
41
42
|
*/
|
|
42
43
|
export interface UserContext {
|
|
43
|
-
/** User UUID
|
|
44
|
+
/** User UUID */
|
|
44
45
|
id: string;
|
|
45
|
-
/** User email address
|
|
46
|
+
/** User email address */
|
|
46
47
|
email: string;
|
|
47
|
-
/** User full name
|
|
48
|
+
/** User full name */
|
|
48
49
|
name: string;
|
|
49
|
-
/**
|
|
50
|
-
|
|
51
|
-
/** Whether this is a service account (non-human identity) */
|
|
52
|
-
isServiceAccount: boolean;
|
|
50
|
+
/** User's application permissions for the current app (e.g., ["read", "write"] or ["*"]) */
|
|
51
|
+
applicationPermissions: string[];
|
|
53
52
|
}
|
|
54
53
|
/**
|
|
55
|
-
*
|
|
54
|
+
* Requestor Context
|
|
55
|
+
*
|
|
56
|
+
* Information about who/what is making the request.
|
|
57
|
+
* Provides clear distinction between users and service accounts.
|
|
58
|
+
*/
|
|
59
|
+
export interface RequestorContext {
|
|
60
|
+
/** Type of requestor */
|
|
61
|
+
type: 'USER' | 'SERVICE_ACCOUNT';
|
|
62
|
+
/** User UUID (only when type is 'USER') */
|
|
63
|
+
userId?: string;
|
|
64
|
+
/** Service account UUID (only when type is 'SERVICE_ACCOUNT') */
|
|
65
|
+
serviceAccountId?: string;
|
|
66
|
+
/** Service account code (only when type is 'SERVICE_ACCOUNT') */
|
|
67
|
+
serviceAccountCode?: string;
|
|
68
|
+
/** Display name of the requestor */
|
|
69
|
+
name: string;
|
|
70
|
+
/** Email address (only when type is 'USER') */
|
|
71
|
+
email?: string;
|
|
72
|
+
/** Requestor's application permissions for the current app */
|
|
73
|
+
applicationPermissions: string[];
|
|
74
|
+
}
|
|
75
|
+
/**
|
|
76
|
+
* Runtime Context
|
|
56
77
|
*
|
|
57
78
|
* Information about the runtime environment.
|
|
58
79
|
*/
|
|
59
|
-
export interface
|
|
80
|
+
export interface RuntimeContext {
|
|
60
81
|
/** Node.js version (e.g., "18.x") */
|
|
61
82
|
nodeVersion: string;
|
|
62
83
|
/** Runtime platform */
|
|
@@ -64,4 +85,11 @@ export interface EnvironmentContext {
|
|
|
64
85
|
/** AWS region (e.g., "us-east-1") */
|
|
65
86
|
region: string;
|
|
66
87
|
}
|
|
88
|
+
/**
|
|
89
|
+
* Environment Variables
|
|
90
|
+
*
|
|
91
|
+
* Key-value map of application environment variables.
|
|
92
|
+
* Keys are uppercase with letters, numbers, and underscores only.
|
|
93
|
+
*/
|
|
94
|
+
export type EnvironmentVariables = Record<string, string>;
|
|
67
95
|
//# 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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,EAAE,MAAM,CAAC;IAEhB,iEAAiE;IACjE,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAE1B,iEAAiE;IACjE,kBAAkB,CAAC,EAAE,MAAM,CAAC;IAE5B,oCAAoC;IACpC,IAAI,EAAE,MAAM,CAAC;IAEb,+CAA+C;IAC/C,KAAK,CAAC,EAAE,MAAM,CAAC;IAEf,8DAA8D;IAC9D,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
|
@@ -14,7 +14,8 @@
|
|
|
14
14
|
* export async function handler() {
|
|
15
15
|
* // Access the global ketrics object (auto-typed)
|
|
16
16
|
* console.log(ketrics.tenant.name);
|
|
17
|
-
* console.log(ketrics.
|
|
17
|
+
* console.log(ketrics.requestor.name);
|
|
18
|
+
* console.log(ketrics.requestor.type); // 'USER' or 'SERVICE_ACCOUNT'
|
|
18
19
|
*
|
|
19
20
|
* // Use ketrics.Volume.connect() for S3 storage
|
|
20
21
|
* try {
|
|
@@ -54,7 +55,7 @@
|
|
|
54
55
|
* }
|
|
55
56
|
* ```
|
|
56
57
|
*/
|
|
57
|
-
export { TenantContext, ApplicationContext, UserContext,
|
|
58
|
+
export { TenantContext, ApplicationContext, UserContext, RequestorContext, RuntimeContext, EnvironmentVariables, } from './context';
|
|
58
59
|
export { ConsoleLogger } from './console';
|
|
59
60
|
export { HttpRequestConfig, HttpResponse, HttpClient } from './http';
|
|
60
61
|
export { DatabaseQueryResult, DatabaseExecuteResult, IDatabaseConnection, DatabaseManager, } from './databases';
|
|
@@ -67,9 +68,11 @@ export { PdfPageSize, PdfStandardFont, PdfRgbColor, PdfDrawTextOptions, PdfDrawR
|
|
|
67
68
|
export { PdfError, PdfParseError, PdfWriteError, isPdfError, isPdfErrorType, } from './pdf-errors';
|
|
68
69
|
export { JobStatusValue, RunInBackgroundOptions, RunInBackgroundParams, JobErrorDetails, JobStatus, JobListParams, JobListResult, } from './job';
|
|
69
70
|
export { JobError, JobNotFoundError, InvalidFunctionError, CrossAppPermissionError, JobExecutionError, isJobError, isJobErrorType, } from './job-errors';
|
|
71
|
+
export { MessagePriorityLevel, MessageChannelConfig, SendMessageParams, SendBulkMessageParams, SendGroupMessageParams, SendMessageResult, SendBulkMessageResult, MessagesManager, } from './messages';
|
|
72
|
+
export { MessageError, MessageValidationError, GroupNotFoundError, TenantGrantPermissionDeniedError, isMessageError, isMessageErrorType, } from './messages-errors';
|
|
70
73
|
export { PutContent, FileContent, FileMetadata, FileInfo, PutOptions, PutResult, DeleteResult, DeleteError, DeleteByPrefixResult, ListOptions, ListResult, CopyOptions, CopyResult, MoveOptions, MoveResult, DownloadUrlOptions, UploadUrlOptions, PresignedUrl, IVolume, } from './volumes';
|
|
71
74
|
export { VolumePermissionValue, VolumeError, VolumeNotFoundError, VolumeAccessDeniedError, VolumePermissionDeniedError, FileNotFoundError, FileAlreadyExistsError, InvalidPathError, FileSizeLimitError, ContentTypeNotAllowedError, isVolumeError, isVolumeErrorType, } from './errors';
|
|
72
|
-
import type { TenantContext, ApplicationContext,
|
|
75
|
+
import type { TenantContext, ApplicationContext, RequestorContext, RuntimeContext, EnvironmentVariables } from './context';
|
|
73
76
|
import type { ConsoleLogger } from './console';
|
|
74
77
|
import type { HttpClient } from './http';
|
|
75
78
|
import type { IDatabaseConnection } from './databases';
|
|
@@ -77,12 +80,21 @@ import type { IVolume } from './volumes';
|
|
|
77
80
|
import type { IExcelWorkbook } from './excel';
|
|
78
81
|
import type { IPdfDocument, PdfRgbColor } from './pdf';
|
|
79
82
|
import type { RunInBackgroundParams, JobStatus, JobListParams, JobListResult } from './job';
|
|
83
|
+
import type { MessagesManager } from './messages';
|
|
80
84
|
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
85
|
import { DatabaseError as DatabaseErrorClass, DatabaseNotFoundError as DatabaseNotFoundErrorClass, DatabaseAccessDeniedError as DatabaseAccessDeniedErrorClass, DatabaseConnectionError as DatabaseConnectionErrorClass, DatabaseQueryError as DatabaseQueryErrorClass, DatabaseTransactionError as DatabaseTransactionErrorClass } from './database-errors';
|
|
82
86
|
import { SecretError as SecretErrorClass, SecretNotFoundError as SecretNotFoundErrorClass, SecretAccessDeniedError as SecretAccessDeniedErrorClass, SecretDecryptionError as SecretDecryptionErrorClass } from './secret-errors';
|
|
83
87
|
import { ExcelError as ExcelErrorClass, ExcelParseError as ExcelParseErrorClass, ExcelWriteError as ExcelWriteErrorClass } from './excel-errors';
|
|
84
88
|
import { PdfError as PdfErrorClass, PdfParseError as PdfParseErrorClass, PdfWriteError as PdfWriteErrorClass } from './pdf-errors';
|
|
85
89
|
import { JobError as JobErrorClass, JobNotFoundError as JobNotFoundErrorClass, InvalidFunctionError as InvalidFunctionErrorClass, CrossAppPermissionError as CrossAppPermissionErrorClass, JobExecutionError as JobExecutionErrorClass } from './job-errors';
|
|
90
|
+
import { MessageError as MessageErrorClass, MessageValidationError as MessageValidationErrorClass, GroupNotFoundError as GroupNotFoundErrorClass, TenantGrantPermissionDeniedError as TenantGrantPermissionDeniedErrorClass } from './messages-errors';
|
|
91
|
+
import { isVolumeError, isVolumeErrorType } from './errors';
|
|
92
|
+
import { isDatabaseError, isDatabaseErrorType } from './database-errors';
|
|
93
|
+
import { isSecretError, isSecretErrorType } from './secret-errors';
|
|
94
|
+
import { isExcelError, isExcelErrorType } from './excel-errors';
|
|
95
|
+
import { isPdfError, isPdfErrorType } from './pdf-errors';
|
|
96
|
+
import { isJobError, isJobErrorType } from './job-errors';
|
|
97
|
+
import { isMessageError, isMessageErrorType } from './messages-errors';
|
|
86
98
|
/**
|
|
87
99
|
* Ketrics Platform SDK Interface
|
|
88
100
|
*
|
|
@@ -94,8 +106,9 @@ import { JobError as JobErrorClass, JobNotFoundError as JobNotFoundErrorClass, I
|
|
|
94
106
|
* // Access tenant context
|
|
95
107
|
* console.log(ketrics.tenant.name);
|
|
96
108
|
* console.log(ketrics.application.code);
|
|
97
|
-
* console.log(ketrics.
|
|
98
|
-
* console.log(ketrics.
|
|
109
|
+
* console.log(ketrics.requestor.name);
|
|
110
|
+
* console.log(ketrics.requestor.type); // 'USER' or 'SERVICE_ACCOUNT'
|
|
111
|
+
* console.log(ketrics.runtime.region);
|
|
99
112
|
*
|
|
100
113
|
* // Use console logging (forwarded to CloudWatch)
|
|
101
114
|
* ketrics.console.log('Processing request...');
|
|
@@ -116,6 +129,14 @@ import { JobError as JobErrorClass, JobNotFoundError as JobNotFoundErrorClass, I
|
|
|
116
129
|
* // Access volumes
|
|
117
130
|
* const volume = await ketrics.Volume.connect('uploads');
|
|
118
131
|
* const file = await volume.get('document.pdf');
|
|
132
|
+
*
|
|
133
|
+
* // Send messages to users
|
|
134
|
+
* await ketrics.Messages.send({
|
|
135
|
+
* userId: 'user-123',
|
|
136
|
+
* type: 'ORDER_SHIPPED',
|
|
137
|
+
* subject: 'Your order shipped!',
|
|
138
|
+
* body: 'Track your package...'
|
|
139
|
+
* });
|
|
119
140
|
* ```
|
|
120
141
|
*/
|
|
121
142
|
export interface KetricsSdkV1 {
|
|
@@ -123,14 +144,144 @@ export interface KetricsSdkV1 {
|
|
|
123
144
|
tenant: TenantContext;
|
|
124
145
|
/** Current application information */
|
|
125
146
|
application: ApplicationContext;
|
|
126
|
-
/** Current
|
|
127
|
-
|
|
147
|
+
/** Current requestor information (user or service account) */
|
|
148
|
+
requestor: RequestorContext;
|
|
128
149
|
/** Runtime environment information */
|
|
129
|
-
|
|
150
|
+
runtime: RuntimeContext;
|
|
151
|
+
/** Application environment variables (key-value pairs) */
|
|
152
|
+
environment: EnvironmentVariables;
|
|
130
153
|
/** Console logging (forwarded to CloudWatch) */
|
|
131
154
|
console: ConsoleLogger;
|
|
132
155
|
/** HTTP client for external API requests */
|
|
133
156
|
http: HttpClient;
|
|
157
|
+
/** Volume class with static connect() factory method */
|
|
158
|
+
Volume: {
|
|
159
|
+
connect(volumeCode: string): Promise<IVolume>;
|
|
160
|
+
};
|
|
161
|
+
/** Base error class for all Volume errors (abstract) */
|
|
162
|
+
VolumeError: typeof VolumeErrorClass;
|
|
163
|
+
/** Error thrown when volume doesn't exist */
|
|
164
|
+
VolumeNotFoundError: typeof VolumeNotFoundErrorClass;
|
|
165
|
+
/** Error thrown when application has no access grant */
|
|
166
|
+
VolumeAccessDeniedError: typeof VolumeAccessDeniedErrorClass;
|
|
167
|
+
/** Error thrown when operation requires missing permission */
|
|
168
|
+
VolumePermissionDeniedError: typeof VolumePermissionDeniedErrorClass;
|
|
169
|
+
/** Error thrown when file doesn't exist */
|
|
170
|
+
FileNotFoundError: typeof FileNotFoundErrorClass;
|
|
171
|
+
/** Error thrown when file already exists (with ifNotExists option) */
|
|
172
|
+
FileAlreadyExistsError: typeof FileAlreadyExistsErrorClass;
|
|
173
|
+
/** Error thrown for invalid path characters or traversal attempts */
|
|
174
|
+
InvalidPathError: typeof InvalidPathErrorClass;
|
|
175
|
+
/** Error thrown when file exceeds size limit */
|
|
176
|
+
FileSizeLimitError: typeof FileSizeLimitErrorClass;
|
|
177
|
+
/** Error thrown when content type is not allowed */
|
|
178
|
+
ContentTypeNotAllowedError: typeof ContentTypeNotAllowedErrorClass;
|
|
179
|
+
/** Type guard to check if error is a VolumeError */
|
|
180
|
+
isVolumeError: typeof isVolumeError;
|
|
181
|
+
/** Type guard to check if error is a specific VolumeError type */
|
|
182
|
+
isVolumeErrorType: typeof isVolumeErrorType;
|
|
183
|
+
/** DatabaseConnection class with static connect() factory method */
|
|
184
|
+
DatabaseConnection: {
|
|
185
|
+
connect(databaseCode: string): Promise<IDatabaseConnection>;
|
|
186
|
+
};
|
|
187
|
+
/** Base error class for all Database errors (abstract) */
|
|
188
|
+
DatabaseError: typeof DatabaseErrorClass;
|
|
189
|
+
/** Error thrown when database doesn't exist */
|
|
190
|
+
DatabaseNotFoundError: typeof DatabaseNotFoundErrorClass;
|
|
191
|
+
/** Error thrown when application has no access grant */
|
|
192
|
+
DatabaseAccessDeniedError: typeof DatabaseAccessDeniedErrorClass;
|
|
193
|
+
/** Error thrown when connection cannot be established */
|
|
194
|
+
DatabaseConnectionError: typeof DatabaseConnectionErrorClass;
|
|
195
|
+
/** Error thrown when query execution fails */
|
|
196
|
+
DatabaseQueryError: typeof DatabaseQueryErrorClass;
|
|
197
|
+
/** Error thrown when transaction fails */
|
|
198
|
+
DatabaseTransactionError: typeof DatabaseTransactionErrorClass;
|
|
199
|
+
/** Type guard to check if error is a DatabaseError */
|
|
200
|
+
isDatabaseError: typeof isDatabaseError;
|
|
201
|
+
/** Type guard to check if error is a specific DatabaseError type */
|
|
202
|
+
isDatabaseErrorType: typeof isDatabaseErrorType;
|
|
203
|
+
/** Secret class with static get() method */
|
|
204
|
+
Secret: {
|
|
205
|
+
get(secretCode: string): Promise<string>;
|
|
206
|
+
exists(secretCode: string): Promise<boolean>;
|
|
207
|
+
};
|
|
208
|
+
/** Base error class for all Secret errors (abstract) */
|
|
209
|
+
SecretError: typeof SecretErrorClass;
|
|
210
|
+
/** Error thrown when secret doesn't exist */
|
|
211
|
+
SecretNotFoundError: typeof SecretNotFoundErrorClass;
|
|
212
|
+
/** Error thrown when application has no access grant */
|
|
213
|
+
SecretAccessDeniedError: typeof SecretAccessDeniedErrorClass;
|
|
214
|
+
/** Error thrown when decryption fails */
|
|
215
|
+
SecretDecryptionError: typeof SecretDecryptionErrorClass;
|
|
216
|
+
/** Type guard to check if error is a SecretError */
|
|
217
|
+
isSecretError: typeof isSecretError;
|
|
218
|
+
/** Type guard to check if error is a specific SecretError type */
|
|
219
|
+
isSecretErrorType: typeof isSecretErrorType;
|
|
220
|
+
/** Excel class with static read() and create() methods */
|
|
221
|
+
Excel: {
|
|
222
|
+
read(buffer: Buffer): Promise<IExcelWorkbook>;
|
|
223
|
+
create(): IExcelWorkbook;
|
|
224
|
+
};
|
|
225
|
+
/** Base error class for all Excel errors (abstract) */
|
|
226
|
+
ExcelError: typeof ExcelErrorClass;
|
|
227
|
+
/** Error thrown when parsing Excel file fails */
|
|
228
|
+
ExcelParseError: typeof ExcelParseErrorClass;
|
|
229
|
+
/** Error thrown when writing Excel file fails */
|
|
230
|
+
ExcelWriteError: typeof ExcelWriteErrorClass;
|
|
231
|
+
/** Type guard to check if error is an ExcelError */
|
|
232
|
+
isExcelError: typeof isExcelError;
|
|
233
|
+
/** Type guard to check if error is a specific ExcelError type */
|
|
234
|
+
isExcelErrorType: typeof isExcelErrorType;
|
|
235
|
+
/** PDF class with static read() and create() methods */
|
|
236
|
+
Pdf: {
|
|
237
|
+
read(buffer: Buffer): Promise<IPdfDocument>;
|
|
238
|
+
create(): Promise<IPdfDocument>;
|
|
239
|
+
rgb(r: number, g: number, b: number): PdfRgbColor;
|
|
240
|
+
};
|
|
241
|
+
/** Base error class for all PDF errors (abstract) */
|
|
242
|
+
PdfError: typeof PdfErrorClass;
|
|
243
|
+
/** Error thrown when parsing PDF file fails */
|
|
244
|
+
PdfParseError: typeof PdfParseErrorClass;
|
|
245
|
+
/** Error thrown when writing PDF file fails */
|
|
246
|
+
PdfWriteError: typeof PdfWriteErrorClass;
|
|
247
|
+
/** Type guard to check if error is a PdfError */
|
|
248
|
+
isPdfError: typeof isPdfError;
|
|
249
|
+
/** Type guard to check if error is a specific PdfError type */
|
|
250
|
+
isPdfErrorType: typeof isPdfErrorType;
|
|
251
|
+
/** Job class with static methods for background job operations */
|
|
252
|
+
Job: {
|
|
253
|
+
runInBackground(params: RunInBackgroundParams): Promise<string>;
|
|
254
|
+
getStatus(jobId: string): Promise<JobStatus>;
|
|
255
|
+
list(params?: JobListParams): Promise<JobListResult>;
|
|
256
|
+
};
|
|
257
|
+
/** Base error class for all job errors */
|
|
258
|
+
JobError: typeof JobErrorClass;
|
|
259
|
+
/** Thrown when a job is not found */
|
|
260
|
+
JobNotFoundError: typeof JobNotFoundErrorClass;
|
|
261
|
+
/** Thrown when function name is invalid or missing */
|
|
262
|
+
InvalidFunctionError: typeof InvalidFunctionErrorClass;
|
|
263
|
+
/** Thrown when cross-app job lacks required permission */
|
|
264
|
+
CrossAppPermissionError: typeof CrossAppPermissionErrorClass;
|
|
265
|
+
/** Thrown when job execution fails */
|
|
266
|
+
JobExecutionError: typeof JobExecutionErrorClass;
|
|
267
|
+
/** Type guard to check if error is a JobError */
|
|
268
|
+
isJobError: typeof isJobError;
|
|
269
|
+
/** Type guard to check if error is a specific JobError type */
|
|
270
|
+
isJobErrorType: typeof isJobErrorType;
|
|
271
|
+
/** Messages class with static methods for sending messages to users */
|
|
272
|
+
Messages: MessagesManager;
|
|
273
|
+
/** Base error class for all message errors */
|
|
274
|
+
MessageError: typeof MessageErrorClass;
|
|
275
|
+
/** Error thrown when message validation fails */
|
|
276
|
+
MessageValidationError: typeof MessageValidationErrorClass;
|
|
277
|
+
/** Error thrown when group is not found */
|
|
278
|
+
GroupNotFoundError: typeof GroupNotFoundErrorClass;
|
|
279
|
+
/** Error thrown when TenantGrant permissions are missing */
|
|
280
|
+
TenantGrantPermissionDeniedError: typeof TenantGrantPermissionDeniedErrorClass;
|
|
281
|
+
/** Type guard to check if error is a MessageError */
|
|
282
|
+
isMessageError: typeof isMessageError;
|
|
283
|
+
/** Type guard to check if error is a specific MessageError type */
|
|
284
|
+
isMessageErrorType: typeof isMessageErrorType;
|
|
134
285
|
}
|
|
135
286
|
/**
|
|
136
287
|
* Volume - S3-backed storage for tenant applications
|
|
@@ -483,177 +634,20 @@ export declare class Job {
|
|
|
483
634
|
* Global declaration for the Ketrics VM sandbox.
|
|
484
635
|
*
|
|
485
636
|
* The `ketrics` global object provides:
|
|
486
|
-
* - Context: tenant, application,
|
|
637
|
+
* - Context: tenant, application, requestor, runtime, environment
|
|
487
638
|
* - Utilities: console, http
|
|
488
639
|
* - Volume: Static class for S3 storage
|
|
489
640
|
* - DatabaseConnection: Static class for database access
|
|
490
641
|
* - Secret: Static class for secret retrieval
|
|
642
|
+
* - Excel: Static class for Excel file operations
|
|
643
|
+
* - Pdf: Static class for PDF file operations
|
|
644
|
+
* - Job: Static class for background job execution
|
|
645
|
+
* - Messages: Static class for user messaging
|
|
491
646
|
* - Error classes: For instanceof checks
|
|
647
|
+
* - Type guards: For error type checking
|
|
492
648
|
*/
|
|
493
649
|
declare global {
|
|
494
650
|
/** 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
|
-
};
|
|
651
|
+
const ketrics: KetricsSdkV1;
|
|
658
652
|
}
|
|
659
653
|
//# 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
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAwDG;AAMH,OAAO,EACL,aAAa,EACb,kBAAkB,EAClB,WAAW,EACX,gBAAgB,EAChB,cAAc,EACd,oBAAoB,GACrB,MAAM,WAAW,CAAC;AAMnB,OAAO,EAAE,aAAa,EAAE,MAAM,WAAW,CAAC;AAM1C,OAAO,EAAE,iBAAiB,EAAE,YAAY,EAAE,UAAU,E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AAY,CAAC;IAElD;;;;OAIG;IACH,MAAM,CAAC,MAAM,IAAI,OAAO,CAAC,YAAY,CAAC;IAEtC;;;;;;;OAOG;IACH,MAAM,CAAC,GAAG,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,GAAG,WAAW;CACzD;AAMD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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
|
@@ -15,7 +15,8 @@
|
|
|
15
15
|
* export async function handler() {
|
|
16
16
|
* // Access the global ketrics object (auto-typed)
|
|
17
17
|
* console.log(ketrics.tenant.name);
|
|
18
|
-
* console.log(ketrics.
|
|
18
|
+
* console.log(ketrics.requestor.name);
|
|
19
|
+
* console.log(ketrics.requestor.type); // 'USER' or 'SERVICE_ACCOUNT'
|
|
19
20
|
*
|
|
20
21
|
* // Use ketrics.Volume.connect() for S3 storage
|
|
21
22
|
* try {
|
|
@@ -56,7 +57,7 @@
|
|
|
56
57
|
* ```
|
|
57
58
|
*/
|
|
58
59
|
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;
|
|
60
|
+
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
61
|
// ============================================================================
|
|
61
62
|
// Database Error Exports
|
|
62
63
|
// ============================================================================
|
|
@@ -109,6 +110,16 @@ Object.defineProperty(exports, "JobExecutionError", { enumerable: true, get: fun
|
|
|
109
110
|
Object.defineProperty(exports, "isJobError", { enumerable: true, get: function () { return job_errors_1.isJobError; } });
|
|
110
111
|
Object.defineProperty(exports, "isJobErrorType", { enumerable: true, get: function () { return job_errors_1.isJobErrorType; } });
|
|
111
112
|
// ============================================================================
|
|
113
|
+
// Messages Error Exports
|
|
114
|
+
// ============================================================================
|
|
115
|
+
var messages_errors_1 = require("./messages-errors");
|
|
116
|
+
Object.defineProperty(exports, "MessageError", { enumerable: true, get: function () { return messages_errors_1.MessageError; } });
|
|
117
|
+
Object.defineProperty(exports, "MessageValidationError", { enumerable: true, get: function () { return messages_errors_1.MessageValidationError; } });
|
|
118
|
+
Object.defineProperty(exports, "GroupNotFoundError", { enumerable: true, get: function () { return messages_errors_1.GroupNotFoundError; } });
|
|
119
|
+
Object.defineProperty(exports, "TenantGrantPermissionDeniedError", { enumerable: true, get: function () { return messages_errors_1.TenantGrantPermissionDeniedError; } });
|
|
120
|
+
Object.defineProperty(exports, "isMessageError", { enumerable: true, get: function () { return messages_errors_1.isMessageError; } });
|
|
121
|
+
Object.defineProperty(exports, "isMessageErrorType", { enumerable: true, get: function () { return messages_errors_1.isMessageErrorType; } });
|
|
122
|
+
// ============================================================================
|
|
112
123
|
// Volume Error Exports
|
|
113
124
|
// ============================================================================
|
|
114
125
|
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
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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HAAA,sBAAsB,OAAA;AACtB,qHAAA,kBAAkB,OAAA;AAClB,mIAAA,gCAAgC,OAAA;AAChC,iHAAA,cAAc,OAAA;AACd,qHAAA,kBAAkB,OAAA;AAqCpB,+EAA+E;AAC/E,uBAAuB;AACvB,+EAA+E;AAE/E,mCAgBkB;AAbhB,gBAAgB;AAChB,qGAAA,WAAW,OAAA;AACX,6GAAA,mBAAmB,OAAA;AACnB,iHAAA,uBAAuB,OAAA;AACvB,qHAAA,2BAA2B,OAAA;AAC3B,2GAAA,iBAAiB,OAAA;AACjB,gHAAA,sBAAsB,OAAA;AACtB,0GAAA,gBAAgB,OAAA;AAChB,4GAAA,kBAAkB,OAAA;AAClB,oHAAA,0BAA0B,OAAA;AAC1B,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,IAAa;QACxC,KAAK,CAAC,OAAO,CAAC,CAAC;QACf,IAAI,CAAC,IAAI,GAAG,cAAc,CAAC;QAC3B,IAAI,CAAC,IAAI,GAAG,IAAI,IAAI,eAAe,CAAC;IACtC,CAAC;CACF;AARD,oCAQC;AAED,+EAA+E;AAC/E,0BAA0B;AAC1B,+EAA+E;AAE/E;;GAEG;AACH,MAAa,sBAAuB,SAAQ,YAAY;IACtD,YAAY,OAAe;QACzB,KAAK,CAAC,OAAO,EAAE,kBAAkB,CAAC,CAAC;QACnC,IAAI,CAAC,IAAI,GAAG,wBAAwB,CAAC;IACvC,CAAC;CACF;AALD,wDAKC;AAED;;GAEG;AACH,MAAa,kBAAmB,SAAQ,YAAY;IAClD,YAAY,SAAiB;QAC3B,KAAK,CAAC,oBAAoB,SAAS,EAAE,EAAE,iBAAiB,CAAC,CAAC;QAC1D,IAAI,CAAC,IAAI,GAAG,oBAAoB,CAAC;IACnC,CAAC;CACF;AALD,gDAKC;AAED;;;;;;GAMG;AACH,MAAa,gCAAiC,SAAQ,YAAY;IAGhE,YAAY,OAAe,EAAE,IAAa;QACxC,KAAK,CAAC,OAAO,EAAE,IAAI,IAAI,mBAAmB,CAAC,CAAC;QAC5C,IAAI,CAAC,IAAI,GAAG,kCAAkC,CAAC;QAC/C,2EAA2E;QAC3E,MAAM,KAAK,GAAG,OAAO,CAAC,KAAK,CAAC,mBAAmB,CAAC,CAAC;QACjD,IAAI,CAAC,kBAAkB,GAAG,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC;IAC9D,CAAC;IAED;;OAEG;IACH,MAAM,CAAC,eAAe,CAAC,WAAqB;QAC1C,OAAO,IAAI,gCAAgC,CACzC,yDAAyD,WAAW,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI;YACjF,0DAA0D,CAC7D,CAAC;IACJ,CAAC;CACF;AApBD,4EAoBC;AAED,+EAA+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":"","s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
/**
|
|
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"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ketrics/sdk-backend",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.7.0",
|
|
4
4
|
"description": "Ketrics SDK for backend tenant application code (VM sandbox)",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
@@ -32,9 +32,9 @@
|
|
|
32
32
|
"typescript": "^5.0.0"
|
|
33
33
|
},
|
|
34
34
|
"peerDependencies": {
|
|
35
|
-
"@types/node": ">=
|
|
35
|
+
"@types/node": ">=24.0.0"
|
|
36
36
|
},
|
|
37
37
|
"engines": {
|
|
38
|
-
"node": ">=
|
|
38
|
+
"node": ">=24.0.0"
|
|
39
39
|
}
|
|
40
40
|
}
|