@documedis/react-components 1.0.0-RC.5 → 1.0.0-RC.6
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/index.d.ts +602 -3
- package/index.mjs +32975 -26521
- package/package.json +2 -2
- package/components/PharmacySelector/PharmacySelector.d.ts +0 -9
- package/components/PharmacySelector/index.d.ts +0 -4
- package/components/PharmacySelector/usePharmacySelector.d.ts +0 -14
- package/components/PrescriptionSign/PrescriptionSign.d.ts +0 -2
- package/components/PrescriptionSign/index.d.ts +0 -4
- package/components/PrescriptionSign/types.d.ts +0 -75
- package/components/PrescriptionSign/useDocumentEvent.d.ts +0 -1
- package/components/PrescriptionSign/usePrescriptionSign.d.ts +0 -46
package/index.d.ts
CHANGED
|
@@ -1,3 +1,602 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
export
|
|
1
|
+
// Generated by dts-bundle-generator v9.5.1
|
|
2
|
+
|
|
3
|
+
export interface Pharmacy {
|
|
4
|
+
id: string;
|
|
5
|
+
gln: string;
|
|
6
|
+
name: string;
|
|
7
|
+
hinEmail?: string;
|
|
8
|
+
galenicaChain?: string;
|
|
9
|
+
}
|
|
10
|
+
/**
|
|
11
|
+
* Environment configuration for Documedis components
|
|
12
|
+
*
|
|
13
|
+
* Architecture:
|
|
14
|
+
* - 'local': Local development (localhost:52247)
|
|
15
|
+
* - 'int': Integration/testing environment (int.apps.documedis.ch)
|
|
16
|
+
* - 'demo': Demo environment with non-prod data (demo.apps.documedis.ch)
|
|
17
|
+
* - 'prod': Production environment (apps.documedis.ch)
|
|
18
|
+
*
|
|
19
|
+
* URLs are predefined for each environment and should be updated in this file
|
|
20
|
+
* when deployment URLs change.
|
|
21
|
+
*/
|
|
22
|
+
export type Environment = "local" | "int" | "demo" | "prod";
|
|
23
|
+
declare const ErrorCodes: {
|
|
24
|
+
/** Current section is expired and the user needs to re-authenticate */
|
|
25
|
+
readonly SESSION_EXPIRED: "SESSION_EXPIRED";
|
|
26
|
+
/** Provided token is invalid or malformed */
|
|
27
|
+
readonly INVALID_TOKEN: "INVALID_TOKEN";
|
|
28
|
+
/** User is not authenticated */
|
|
29
|
+
readonly NOT_AUTHENTICATED: "NOT_AUTHENTICATED";
|
|
30
|
+
/** The action is forbidden */
|
|
31
|
+
readonly FORBIDDEN: "FORBIDDEN";
|
|
32
|
+
/** The action is allowed but the user does not have sufficient permissions */
|
|
33
|
+
readonly INSUFFICIENT_PERMISSIONS: "INSUFFICIENT_PERMISSIONS";
|
|
34
|
+
/** Input is invalid (e.g., missing required fields, wrong data types) */
|
|
35
|
+
readonly INVALID_INPUT: "INVALID_INPUT";
|
|
36
|
+
/** Header is invalid (e.g., missing required fields, wrong format) */
|
|
37
|
+
readonly INVALID_HEADER: "INVALID_HEADER";
|
|
38
|
+
/** Operation could not be completed due to conflicting state */
|
|
39
|
+
readonly INVALID_STATE: "INVALID_STATE";
|
|
40
|
+
/** User closed the popup window before completing the action */
|
|
41
|
+
readonly POPUP_CLOSED: "POPUP_CLOSED";
|
|
42
|
+
/** User cancelled the action */
|
|
43
|
+
readonly USER_CANCELLED: "USER_CANCELLED";
|
|
44
|
+
/** User denied the required permissions */
|
|
45
|
+
readonly PERMISSION_DENIED_BY_USER: "PERMISSION_DENIED_BY_USER";
|
|
46
|
+
/** Required configuration is missing */
|
|
47
|
+
readonly MISSING_CONFIG: "MISSING_CONFIG";
|
|
48
|
+
/** Provided configuration is invalid or malformed */
|
|
49
|
+
readonly INVALID_CONFIG: "INVALID_CONFIG";
|
|
50
|
+
/** Popup window could not be opened because it was blocked by the browser */
|
|
51
|
+
readonly POPUP_BLOCKED: "POPUP_BLOCKED";
|
|
52
|
+
/** Browser is not compatible with the required features */
|
|
53
|
+
readonly BROWSER_INCOMPATIBLE: "BROWSER_INCOMPATIBLE";
|
|
54
|
+
/** Error during component initialization */
|
|
55
|
+
readonly COMPONENT_INITIALIZATION_ERROR: "COMPONENT_INITIALIZATION_ERROR";
|
|
56
|
+
/** Error related to database operations */
|
|
57
|
+
readonly DATABASE_ERROR: "DATABASE_ERROR";
|
|
58
|
+
/** Error related to cache operations */
|
|
59
|
+
readonly CACHE_ERROR: "CACHE_ERROR";
|
|
60
|
+
/** Service is not reachable because of network issues (no connection, CORS, etc.) */
|
|
61
|
+
readonly NETWORK_ERROR: "NETWORK_ERROR";
|
|
62
|
+
/** Service did not respond within the expected time frame */
|
|
63
|
+
readonly SERVICE_TIMEOUT: "SERVICE_TIMEOUT";
|
|
64
|
+
/** Service is reachable but returned a 503 Service Unavailable */
|
|
65
|
+
readonly SERVICE_UNAVAILABLE: "SERVICE_UNAVAILABLE";
|
|
66
|
+
/** Access to the service is blocked by a firewall */
|
|
67
|
+
readonly FIREWALL_BLOCKED: "FIREWALL_BLOCKED";
|
|
68
|
+
/** Unknown error from internal service */
|
|
69
|
+
readonly INTERNAL_ERROR: "INTERNAL_ERROR";
|
|
70
|
+
/** Unknown error from an external service */
|
|
71
|
+
readonly EXT_UNKNOWN_ERROR: "EXT_UNKNOWN_ERROR";
|
|
72
|
+
/** Too many requests sent in a given amount of time */
|
|
73
|
+
readonly RATE_LIMITED: "RATE_LIMITED";
|
|
74
|
+
/** Failures to complete the OAuth process */
|
|
75
|
+
readonly OAUTH_ERROR: "OAUTH_ERROR";
|
|
76
|
+
/** Failure to set up a service */
|
|
77
|
+
readonly SETUP_ERROR: "SETUP_ERROR";
|
|
78
|
+
/** Invalid response structure (unexpected format, fields, etc.) */
|
|
79
|
+
readonly INVALID_RESPONSE: "INVALID_RESPONSE";
|
|
80
|
+
/** The state in which an action is executed is invalid (e.g., wrong context, missing prerequisites) */
|
|
81
|
+
readonly INVALID_CONTEXT: "INVALID_CONTEXT";
|
|
82
|
+
/** Origin of the request is not trusted */
|
|
83
|
+
readonly UNTRUSTED_ORIGIN: "UNTRUSTED_ORIGIN";
|
|
84
|
+
/** Signature verification failed */
|
|
85
|
+
readonly INVALID_SIGNATURE: "INVALID_SIGNATURE";
|
|
86
|
+
/** Cross-Site Request Forgery violation */
|
|
87
|
+
readonly CSRF_VIOLATION: "CSRF_VIOLATION";
|
|
88
|
+
/** Cross-Origin Resource Sharing violation */
|
|
89
|
+
readonly CORS_VIOLATION: "CORS_VIOLATION";
|
|
90
|
+
/** Certificate error (e.g., invalid, expired, untrusted) */
|
|
91
|
+
readonly CERTIFICATE_ERROR: "CERTIFICATE_ERROR";
|
|
92
|
+
};
|
|
93
|
+
/**
|
|
94
|
+
* Type representing all possible error codes
|
|
95
|
+
*/
|
|
96
|
+
export type ErrorCode = (typeof ErrorCodes)[keyof typeof ErrorCodes];
|
|
97
|
+
declare namespace ErrorCode {
|
|
98
|
+
/** @see {@link ErrorCodes.SESSION_EXPIRED} */
|
|
99
|
+
type SESSION_EXPIRED = typeof ErrorCodes.SESSION_EXPIRED;
|
|
100
|
+
/** @see {@link ErrorCodes.INVALID_TOKEN} */
|
|
101
|
+
type INVALID_TOKEN = typeof ErrorCodes.INVALID_TOKEN;
|
|
102
|
+
/** @see {@link ErrorCodes.NOT_AUTHENTICATED} */
|
|
103
|
+
type NOT_AUTHENTICATED = typeof ErrorCodes.NOT_AUTHENTICATED;
|
|
104
|
+
/** @see {@link ErrorCodes.FORBIDDEN} */
|
|
105
|
+
type FORBIDDEN = typeof ErrorCodes.FORBIDDEN;
|
|
106
|
+
/** @see {@link ErrorCodes.INSUFFICIENT_PERMISSIONS} */
|
|
107
|
+
type INSUFFICIENT_PERMISSIONS = typeof ErrorCodes.INSUFFICIENT_PERMISSIONS;
|
|
108
|
+
/** @see {@link ErrorCodes.INVALID_INPUT} */
|
|
109
|
+
type INVALID_INPUT = typeof ErrorCodes.INVALID_INPUT;
|
|
110
|
+
/** @see {@link ErrorCodes.INVALID_HEADER} */
|
|
111
|
+
type INVALID_HEADER = typeof ErrorCodes.INVALID_HEADER;
|
|
112
|
+
/** @see {@link ErrorCodes.INVALID_STATE} */
|
|
113
|
+
type INVALID_STATE = typeof ErrorCodes.INVALID_STATE;
|
|
114
|
+
/** @see {@link ErrorCodes.POPUP_CLOSED} */
|
|
115
|
+
type POPUP_CLOSED = typeof ErrorCodes.POPUP_CLOSED;
|
|
116
|
+
/** @see {@link ErrorCodes.USER_CANCELLED} */
|
|
117
|
+
type USER_CANCELLED = typeof ErrorCodes.USER_CANCELLED;
|
|
118
|
+
/** @see {@link ErrorCodes.PERMISSION_DENIED_BY_USER} */
|
|
119
|
+
type PERMISSION_DENIED_BY_USER = typeof ErrorCodes.PERMISSION_DENIED_BY_USER;
|
|
120
|
+
/** @see {@link ErrorCodes.MISSING_CONFIG} */
|
|
121
|
+
type MISSING_CONFIG = typeof ErrorCodes.MISSING_CONFIG;
|
|
122
|
+
/** @see {@link ErrorCodes.INVALID_CONFIG} */
|
|
123
|
+
type INVALID_CONFIG = typeof ErrorCodes.INVALID_CONFIG;
|
|
124
|
+
/** @see {@link ErrorCodes.POPUP_BLOCKED} */
|
|
125
|
+
type POPUP_BLOCKED = typeof ErrorCodes.POPUP_BLOCKED;
|
|
126
|
+
/** @see {@link ErrorCodes.BROWSER_INCOMPATIBLE} */
|
|
127
|
+
type BROWSER_INCOMPATIBLE = typeof ErrorCodes.BROWSER_INCOMPATIBLE;
|
|
128
|
+
/** @see {@link ErrorCodes.COMPONENT_INITIALIZATION_ERROR} */
|
|
129
|
+
type COMPONENT_INITIALIZATION_ERROR = typeof ErrorCodes.COMPONENT_INITIALIZATION_ERROR;
|
|
130
|
+
/** @see {@link ErrorCodes.DATABASE_ERROR} */
|
|
131
|
+
type DATABASE_ERROR = typeof ErrorCodes.DATABASE_ERROR;
|
|
132
|
+
/** @see {@link ErrorCodes.CACHE_ERROR} */
|
|
133
|
+
type CACHE_ERROR = typeof ErrorCodes.CACHE_ERROR;
|
|
134
|
+
/** @see {@link ErrorCodes.NETWORK_ERROR} */
|
|
135
|
+
type NETWORK_ERROR = typeof ErrorCodes.NETWORK_ERROR;
|
|
136
|
+
/** @see {@link ErrorCodes.SERVICE_TIMEOUT} */
|
|
137
|
+
type SERVICE_TIMEOUT = typeof ErrorCodes.SERVICE_TIMEOUT;
|
|
138
|
+
/** @see {@link ErrorCodes.SERVICE_UNAVAILABLE} */
|
|
139
|
+
type SERVICE_UNAVAILABLE = typeof ErrorCodes.SERVICE_UNAVAILABLE;
|
|
140
|
+
/** @see {@link ErrorCodes.FIREWALL_BLOCKED} */
|
|
141
|
+
type FIREWALL_BLOCKED = typeof ErrorCodes.FIREWALL_BLOCKED;
|
|
142
|
+
/** @see {@link ErrorCodes.INTERNAL_ERROR} */
|
|
143
|
+
type INTERNAL_ERROR = typeof ErrorCodes.INTERNAL_ERROR;
|
|
144
|
+
/** @see {@link ErrorCodes.EXT_UNKNOWN_ERROR} */
|
|
145
|
+
type EXT_UNKNOWN_ERROR = typeof ErrorCodes.EXT_UNKNOWN_ERROR;
|
|
146
|
+
/** @see {@link ErrorCodes.RATE_LIMITED} */
|
|
147
|
+
type RATE_LIMITED = typeof ErrorCodes.RATE_LIMITED;
|
|
148
|
+
/** @see {@link ErrorCodes.OAUTH_ERROR} */
|
|
149
|
+
type OAUTH_ERROR = typeof ErrorCodes.OAUTH_ERROR;
|
|
150
|
+
/** @see {@link ErrorCodes.SETUP_ERROR} */
|
|
151
|
+
type SETUP_ERROR = typeof ErrorCodes.SETUP_ERROR;
|
|
152
|
+
/** @see {@link ErrorCodes.INVALID_RESPONSE} */
|
|
153
|
+
type INVALID_RESPONSE = typeof ErrorCodes.INVALID_RESPONSE;
|
|
154
|
+
/** @see {@link ErrorCodes.INVALID_CONTEXT} */
|
|
155
|
+
type INVALID_CONTEXT = typeof ErrorCodes.INVALID_CONTEXT;
|
|
156
|
+
/** @see {@link ErrorCodes.UNTRUSTED_ORIGIN} */
|
|
157
|
+
type UNTRUSTED_ORIGIN = typeof ErrorCodes.UNTRUSTED_ORIGIN;
|
|
158
|
+
/** @see {@link ErrorCodes.INVALID_SIGNATURE} */
|
|
159
|
+
type INVALID_SIGNATURE = typeof ErrorCodes.INVALID_SIGNATURE;
|
|
160
|
+
/** @see {@link ErrorCodes.CSRF_VIOLATION} */
|
|
161
|
+
type CSRF_VIOLATION = typeof ErrorCodes.CSRF_VIOLATION;
|
|
162
|
+
/** @see {@link ErrorCodes.CORS_VIOLATION} */
|
|
163
|
+
type CORS_VIOLATION = typeof ErrorCodes.CORS_VIOLATION;
|
|
164
|
+
/** @see {@link ErrorCodes.CERTIFICATE_ERROR} */
|
|
165
|
+
type CERTIFICATE_ERROR = typeof ErrorCodes.CERTIFICATE_ERROR;
|
|
166
|
+
}
|
|
167
|
+
/**
|
|
168
|
+
* Authentication errors define when authentication
|
|
169
|
+
* fails due to errors caused by factors controlled by
|
|
170
|
+
* this application.
|
|
171
|
+
*/
|
|
172
|
+
export interface AuthenticationError {
|
|
173
|
+
/** Error type discriminator for deserialization */
|
|
174
|
+
type: "Authentication";
|
|
175
|
+
/** Subset of error codes valid for Authentication errors */
|
|
176
|
+
code: ErrorCode.INVALID_TOKEN | ErrorCode.NOT_AUTHENTICATED | ErrorCode.SESSION_EXPIRED | ErrorCode.INVALID_SIGNATURE | ErrorCode.CERTIFICATE_ERROR | ErrorCode.SERVICE_TIMEOUT | ErrorCode.EXT_UNKNOWN_ERROR;
|
|
177
|
+
/** Error-specific data */
|
|
178
|
+
data: {
|
|
179
|
+
/** Authentication realm/system (e.g., 'hin', 'oauth') */
|
|
180
|
+
service?: string;
|
|
181
|
+
};
|
|
182
|
+
}
|
|
183
|
+
/**
|
|
184
|
+
* Authorization errors define when authorization
|
|
185
|
+
* fails due to insufficient permissions or access rights.
|
|
186
|
+
*/
|
|
187
|
+
export interface AuthorizationError {
|
|
188
|
+
/** Error type discriminator for deserialization */
|
|
189
|
+
type: "Authorization";
|
|
190
|
+
/** Subset of error codes valid for Authorization errors */
|
|
191
|
+
code: ErrorCode.INSUFFICIENT_PERMISSIONS | ErrorCode.FORBIDDEN | ErrorCode.UNTRUSTED_ORIGIN;
|
|
192
|
+
/** Error-specific data */
|
|
193
|
+
data: {
|
|
194
|
+
/** Action being attempted (e.g., 'sign-prescription') */
|
|
195
|
+
action: string;
|
|
196
|
+
/** Resource over which the action is being attempted (e.g., 'hin-prescription') */
|
|
197
|
+
resource?: string;
|
|
198
|
+
/** Permission required (e.g., 'practitioner-role') */
|
|
199
|
+
permission?: string;
|
|
200
|
+
/** Additional reason or context for the authorization failure */
|
|
201
|
+
reason?: string;
|
|
202
|
+
};
|
|
203
|
+
}
|
|
204
|
+
export type FieldIssue = "FIELD_MISSING" | "INVALID_FORMAT" | "OUT_OF_RANGE" | "INVALID_VALUE";
|
|
205
|
+
export interface FieldValidationData {
|
|
206
|
+
/** Name of the invalid field */
|
|
207
|
+
field: string;
|
|
208
|
+
/** How the field is invalid */
|
|
209
|
+
reason?: FieldIssue;
|
|
210
|
+
/** Invalid value provided */
|
|
211
|
+
invalidValue?: unknown;
|
|
212
|
+
/** Additional details about the validation error */
|
|
213
|
+
details?: unknown;
|
|
214
|
+
}
|
|
215
|
+
/**
|
|
216
|
+
* Validation errors indicate that input data provided by
|
|
217
|
+
* this application to a service is invalid or inconsistent.
|
|
218
|
+
*/
|
|
219
|
+
export type ValidationError = {
|
|
220
|
+
/** Error type discriminator for deserialization */
|
|
221
|
+
type: "Validation";
|
|
222
|
+
} & ({
|
|
223
|
+
/** Subset of error codes valid for Validation errors */
|
|
224
|
+
code: ErrorCode.INVALID_INPUT | ErrorCode.INVALID_HEADER;
|
|
225
|
+
/** Error-specific data */
|
|
226
|
+
data: {
|
|
227
|
+
/** List of fields that failed validation */
|
|
228
|
+
invalidFields: FieldValidationData[];
|
|
229
|
+
};
|
|
230
|
+
} | {
|
|
231
|
+
/** Subset of error codes valid for Validation errors */
|
|
232
|
+
code: ErrorCode.INVALID_STATE;
|
|
233
|
+
/** Error-specific data */
|
|
234
|
+
data: {
|
|
235
|
+
/** Name of the entity in invalid state */
|
|
236
|
+
entity?: string;
|
|
237
|
+
/** Additional details on the reason */
|
|
238
|
+
details?: unknown;
|
|
239
|
+
};
|
|
240
|
+
});
|
|
241
|
+
/**
|
|
242
|
+
* User interaction errors indicate that an operation
|
|
243
|
+
* could not be completed due to user actions or decisions.
|
|
244
|
+
*/
|
|
245
|
+
export interface UserInteractionError {
|
|
246
|
+
type: "UserInteraction";
|
|
247
|
+
code: ErrorCode.USER_CANCELLED | ErrorCode.POPUP_CLOSED | ErrorCode.PERMISSION_DENIED_BY_USER;
|
|
248
|
+
data?: {
|
|
249
|
+
cause?: unknown;
|
|
250
|
+
duringOperation?: string;
|
|
251
|
+
};
|
|
252
|
+
}
|
|
253
|
+
/**
|
|
254
|
+
* Configuration errors indicate issues with application
|
|
255
|
+
* configuration that prevent normal operation.
|
|
256
|
+
*/
|
|
257
|
+
export interface ConfigurationError {
|
|
258
|
+
/** Error type discriminator for deserialization */
|
|
259
|
+
type: "Configuration";
|
|
260
|
+
/** Subset of error codes valid for Configuration errors */
|
|
261
|
+
code: ErrorCode.MISSING_CONFIG | ErrorCode.POPUP_BLOCKED | ErrorCode.INVALID_CONFIG | ErrorCode.FORBIDDEN | ErrorCode.COMPONENT_INITIALIZATION_ERROR;
|
|
262
|
+
/** Error-specific data */
|
|
263
|
+
data: {
|
|
264
|
+
/** Name of the missing or invalid configuration */
|
|
265
|
+
configName?: string;
|
|
266
|
+
/** Source of the configuration (e.g., 'azure keyvault', 'file') */
|
|
267
|
+
source?: string;
|
|
268
|
+
/** Additional details about the configuration error */
|
|
269
|
+
details?: unknown;
|
|
270
|
+
};
|
|
271
|
+
}
|
|
272
|
+
/**
|
|
273
|
+
* Security errors indicate violations of security policies,
|
|
274
|
+
* invalid signatures, untrusted origins, or other security threats.
|
|
275
|
+
*/
|
|
276
|
+
export interface SecurityError {
|
|
277
|
+
/** Error type discriminator for deserialization */
|
|
278
|
+
type: "Security";
|
|
279
|
+
/** Subset of error codes valid for Security errors */
|
|
280
|
+
code: ErrorCode.UNTRUSTED_ORIGIN | ErrorCode.INVALID_SIGNATURE | ErrorCode.CSRF_VIOLATION | ErrorCode.CORS_VIOLATION | ErrorCode.CERTIFICATE_ERROR;
|
|
281
|
+
/** Error-specific data */
|
|
282
|
+
data: {
|
|
283
|
+
/** Security context or domain (e.g., 'hin-saml', 'oauth') */
|
|
284
|
+
context?: string;
|
|
285
|
+
/** The operation that was blocked (e.g., 'authentication', 'api-call') */
|
|
286
|
+
operation?: string;
|
|
287
|
+
/** Additional security-related details (sanitized for logging) */
|
|
288
|
+
details?: unknown;
|
|
289
|
+
};
|
|
290
|
+
}
|
|
291
|
+
/**
|
|
292
|
+
* Service errors indicate failures in external or internal
|
|
293
|
+
* services that this application depends on.
|
|
294
|
+
*/
|
|
295
|
+
export interface ServiceError {
|
|
296
|
+
/** Error type discriminator for deserialization */
|
|
297
|
+
type: "Service";
|
|
298
|
+
/** Subset of error codes valid for Infrastructure errors */
|
|
299
|
+
code: ErrorCode.NETWORK_ERROR | ErrorCode.SERVICE_UNAVAILABLE | ErrorCode.INTERNAL_ERROR | ErrorCode.OAUTH_ERROR | ErrorCode.RATE_LIMITED | ErrorCode.SETUP_ERROR | ErrorCode.FIREWALL_BLOCKED | ErrorCode.DATABASE_ERROR | ErrorCode.CACHE_ERROR | ErrorCode.SERVICE_TIMEOUT | ErrorCode.INVALID_RESPONSE | ErrorCode.INVALID_CONTEXT | ErrorCode.EXT_UNKNOWN_ERROR;
|
|
300
|
+
/** Error-specific data */
|
|
301
|
+
data: {
|
|
302
|
+
/** Infrastructure service name (e.g., 'azure-keyvault') */
|
|
303
|
+
service: string;
|
|
304
|
+
/** Operation that failed (e.g., 'get-secret') */
|
|
305
|
+
operation: string;
|
|
306
|
+
/** Whether the error originated from an external system */
|
|
307
|
+
isExternal?: boolean;
|
|
308
|
+
/** List of invalid fields related to the error */
|
|
309
|
+
invalidFields?: FieldValidationData[];
|
|
310
|
+
/** Additional details about the infrastructure error */
|
|
311
|
+
details?: unknown;
|
|
312
|
+
};
|
|
313
|
+
}
|
|
314
|
+
export type ErrorType = AuthenticationError | AuthorizationError | ValidationError | UserInteractionError | ConfigurationError | SecurityError | ServiceError;
|
|
315
|
+
/**
|
|
316
|
+
* @fileoverview Base error classes for the Documedis error handling system.
|
|
317
|
+
*
|
|
318
|
+
* Core principles:
|
|
319
|
+
* - Domain-driven errors (describe WHAT went wrong)
|
|
320
|
+
* - Three-message pattern (technical, code, user-friendly)
|
|
321
|
+
* - Safe serialization for cross-boundary communication
|
|
322
|
+
*
|
|
323
|
+
* @module @documedis/errors
|
|
324
|
+
*/
|
|
325
|
+
/**
|
|
326
|
+
* Serialized error format for API responses and postMessage communication.
|
|
327
|
+
* Contains only safe data for cross-boundary communication.
|
|
328
|
+
*
|
|
329
|
+
* Note: Error types extend this with their specific properties:
|
|
330
|
+
* - TimeoutError: adds `operation`, `timeoutMs`
|
|
331
|
+
* - ExternalServiceError: adds `statusCode` (if present)
|
|
332
|
+
* - AuthenticationError: adds `realm` (if present)
|
|
333
|
+
* - AuthorizationError: adds `resource`, `permission` (if present)
|
|
334
|
+
* - ValidationError: adds `validations`
|
|
335
|
+
* - BusinessRuleError: adds `rule`
|
|
336
|
+
* - UserInteractionError: adds `interactionType`
|
|
337
|
+
* - ConfigurationError: adds `configKey`, `source`
|
|
338
|
+
* - InfrastructureError: adds `service`, `operation`
|
|
339
|
+
*/
|
|
340
|
+
export interface SerializedError<T extends ErrorType> {
|
|
341
|
+
/** Error type discriminator for deserialization */
|
|
342
|
+
type: T["type"];
|
|
343
|
+
/** Stable error code for programmatic handling (e.g., 'SESSION_EXPIRED', 'INVALID_INPUT') */
|
|
344
|
+
code: T["code"];
|
|
345
|
+
/** User-friendly message safe for end users */
|
|
346
|
+
message: string;
|
|
347
|
+
/** Error-specific data */
|
|
348
|
+
data?: T["data"];
|
|
349
|
+
}
|
|
350
|
+
/**
|
|
351
|
+
* Base class for all domain errors.
|
|
352
|
+
*
|
|
353
|
+
* Features:
|
|
354
|
+
* - Three-message pattern (technical, code, user-friendly)
|
|
355
|
+
* - Unique error IDs for tracking
|
|
356
|
+
* - Safe serialization via toJSON()
|
|
357
|
+
*
|
|
358
|
+
* @abstract
|
|
359
|
+
*/
|
|
360
|
+
export declare class DomainError<T extends ErrorType = ErrorType> extends Error {
|
|
361
|
+
readonly type: T["type"];
|
|
362
|
+
readonly code: T["code"];
|
|
363
|
+
readonly userMessage: string;
|
|
364
|
+
readonly data?: T["data"] | undefined;
|
|
365
|
+
readonly cause?: unknown | undefined;
|
|
366
|
+
/** Unique error instance ID (format: err_timestamp_random) */
|
|
367
|
+
readonly id: string;
|
|
368
|
+
/** Timestamp of when the error occurred */
|
|
369
|
+
readonly timestamp: Date;
|
|
370
|
+
/**
|
|
371
|
+
* Creates a new domain error.
|
|
372
|
+
*
|
|
373
|
+
* @param message - Technical message for developers (included in logs, not sent to users)
|
|
374
|
+
* @param code - Stable error code for programmatic handling from ErrorCodes constants
|
|
375
|
+
* @param userMessage - Safe, user-friendly message for end users
|
|
376
|
+
* @param cause - Original error for debugging (included in logs, not serialized)
|
|
377
|
+
*/
|
|
378
|
+
constructor(type: T["type"], code: T["code"], message: string, userMessage: string, data?: T["data"] | undefined, cause?: unknown | undefined);
|
|
379
|
+
/**
|
|
380
|
+
* Determines if errors should be logged to console in current environment.
|
|
381
|
+
* Only logs in dev/int/demo, not in production.
|
|
382
|
+
* Returns false if environment cannot be determined (safe default).
|
|
383
|
+
*
|
|
384
|
+
* @private
|
|
385
|
+
* @returns true if should log to console
|
|
386
|
+
*/
|
|
387
|
+
private shouldLogInDevelopment;
|
|
388
|
+
/**
|
|
389
|
+
* Generates a unique error ID for this error instance.
|
|
390
|
+
* Format: err_timestamp_random
|
|
391
|
+
*
|
|
392
|
+
* @private
|
|
393
|
+
* @returns Unique error ID
|
|
394
|
+
*/
|
|
395
|
+
private generateErrorId;
|
|
396
|
+
/**
|
|
397
|
+
* Serializes the error for API responses or cross-boundary communication.
|
|
398
|
+
*
|
|
399
|
+
* Only includes safe data:
|
|
400
|
+
* - User-friendly message (not technical details)
|
|
401
|
+
* - Stable error code
|
|
402
|
+
* - IDs for tracking
|
|
403
|
+
*
|
|
404
|
+
* Excludes:
|
|
405
|
+
* - Stack traces
|
|
406
|
+
* - Technical error messages
|
|
407
|
+
* - Original cause
|
|
408
|
+
* - Any sensitive information
|
|
409
|
+
*
|
|
410
|
+
* @returns Serialized error safe for external consumption
|
|
411
|
+
*/
|
|
412
|
+
toJSON(): SerializedError<T>;
|
|
413
|
+
/**
|
|
414
|
+
* Maps this domain error to an appropriate HTTP status code.
|
|
415
|
+
*
|
|
416
|
+
* @returns HTTP status code for this error
|
|
417
|
+
*/
|
|
418
|
+
toHttpStatus(): number;
|
|
419
|
+
/**
|
|
420
|
+
* Deserializes a JSON error back into the appropriate domain error instance.
|
|
421
|
+
*
|
|
422
|
+
* @param data - Serialized error data
|
|
423
|
+
* @returns A domain error instance
|
|
424
|
+
*/
|
|
425
|
+
static fromJSON(data: any): DomainError;
|
|
426
|
+
}
|
|
427
|
+
export interface ComboBoxStyleProps {
|
|
428
|
+
color?: string;
|
|
429
|
+
}
|
|
430
|
+
export type KeyOf<T extends object> = keyof T extends string ? keyof T : never;
|
|
431
|
+
export type OmitFunctionsKeys<T> = Omit<T, {
|
|
432
|
+
[K in keyof T]: T[K] extends (...args: any[]) => any ? K : never;
|
|
433
|
+
}[keyof T]>;
|
|
434
|
+
export type OptionalNullableKeys<T> = {
|
|
435
|
+
[K in keyof T as undefined extends T[K] ? K : null extends T[K] ? K : never]?: T[K];
|
|
436
|
+
} & {
|
|
437
|
+
[K in keyof T as undefined extends T[K] ? never : null extends T[K] ? never : K]: T[K];
|
|
438
|
+
};
|
|
439
|
+
export type PropKey<T extends object> = KeyOf<OmitFunctionsKeys<T>>;
|
|
440
|
+
export type Props<T extends object> = OptionalNullableKeys<{
|
|
441
|
+
[K in PropKey<T>]: T[K];
|
|
442
|
+
}>;
|
|
443
|
+
export interface PharmacySelectorWebComponentProps extends ComboBoxStyleProps {
|
|
444
|
+
accessToken: string;
|
|
445
|
+
environment: Environment;
|
|
446
|
+
eRxEnableOnly?: boolean;
|
|
447
|
+
resultWindowSize?: number;
|
|
448
|
+
}
|
|
449
|
+
export interface PrescriptionSignWebComponentProps {
|
|
450
|
+
environment?: Environment;
|
|
451
|
+
chmed?: string;
|
|
452
|
+
accessToken?: string;
|
|
453
|
+
sessionToken?: string;
|
|
454
|
+
generatePdf?: boolean;
|
|
455
|
+
color?: string;
|
|
456
|
+
}
|
|
457
|
+
export interface PharmacySelectorProps extends Props<PharmacySelectorWebComponentProps> {
|
|
458
|
+
className?: string;
|
|
459
|
+
onPharmacySelected: (pharmacy: Pharmacy | null) => void;
|
|
460
|
+
onError?: (error: DomainError) => void;
|
|
461
|
+
}
|
|
462
|
+
export declare const PharmacySelector: ({ onPharmacySelected, onError, className, ...props }: PharmacySelectorProps) => import("react/jsx-runtime").JSX.Element;
|
|
463
|
+
export interface UsePharmacySelectorConfig {
|
|
464
|
+
accessToken: string;
|
|
465
|
+
environment: Environment;
|
|
466
|
+
eRxEnableOnly?: boolean;
|
|
467
|
+
resultWindowSize?: number;
|
|
468
|
+
}
|
|
469
|
+
export interface UsePharmacySelectorReturn {
|
|
470
|
+
onQueryChange: (input: string) => void;
|
|
471
|
+
queriedPharmacies: Pharmacy[];
|
|
472
|
+
selectPharmacy: (pharmacy: Pharmacy) => void;
|
|
473
|
+
selectedPharmacy: Pharmacy | null;
|
|
474
|
+
isLoading: boolean;
|
|
475
|
+
}
|
|
476
|
+
export declare const usePharmacySelector: (config: UsePharmacySelectorConfig) => UsePharmacySelectorReturn;
|
|
477
|
+
/**
|
|
478
|
+
* Props for the usePrescriptionSign hook
|
|
479
|
+
* Note: chmed is NOT included here because it's passed via the start() method
|
|
480
|
+
*/
|
|
481
|
+
export type UsePrescriptionSigningProps = {
|
|
482
|
+
/**
|
|
483
|
+
* Environment configuration for the prescription service
|
|
484
|
+
* - 'local': Development environment (localhost:52247)
|
|
485
|
+
* - 'int': Integration Azure Container Apps
|
|
486
|
+
* - 'demo': Demo Azure Container Apps
|
|
487
|
+
* - 'prod': Production Azure Container Apps
|
|
488
|
+
*/
|
|
489
|
+
environment: Environment;
|
|
490
|
+
/** Access token for authenticating with the backend service */
|
|
491
|
+
accessToken: string;
|
|
492
|
+
/**
|
|
493
|
+
* Optional existing session token to reuse authentication state.
|
|
494
|
+
* If provided, the hook will attempt to use existing authentication.
|
|
495
|
+
*/
|
|
496
|
+
sessionToken?: string;
|
|
497
|
+
/**
|
|
498
|
+
* Optional callback invoked when the session token is updated.
|
|
499
|
+
* Use this to persist the session token for reuse across hook instances.
|
|
500
|
+
*/
|
|
501
|
+
onSessionTokenUpdate?: (token: string) => void;
|
|
502
|
+
/**
|
|
503
|
+
* Optional callback invoked when prescription signing succeeds.
|
|
504
|
+
* Receives the signed CHMED data as a base64-encoded string.
|
|
505
|
+
* Optionally receives the generatedPdf if the option
|
|
506
|
+
* generatePdf is set to true.
|
|
507
|
+
*
|
|
508
|
+
* @see generatePdf
|
|
509
|
+
*/
|
|
510
|
+
onSuccess?: (signedCHMED: string, generatedPdf?: string) => void;
|
|
511
|
+
/**
|
|
512
|
+
* Optional callback invoked when prescription signing fails.
|
|
513
|
+
* Receives a specific error type indicating what went wrong.
|
|
514
|
+
*/
|
|
515
|
+
onError?: (error: DomainError) => void;
|
|
516
|
+
/**
|
|
517
|
+
* Optional flag to generate PDF after signing.
|
|
518
|
+
* Defaults to false if not specified.
|
|
519
|
+
*/
|
|
520
|
+
generatePdf?: boolean;
|
|
521
|
+
};
|
|
522
|
+
/**
|
|
523
|
+
* Props for the PrescriptionSign React component
|
|
524
|
+
* Uses camelCase (React convention) - internally converted to kebab-case for web component
|
|
525
|
+
*/
|
|
526
|
+
export interface PrescriptionSignProps extends Props<PrescriptionSignWebComponentProps> {
|
|
527
|
+
className?: string;
|
|
528
|
+
/**
|
|
529
|
+
* Optional callback invoked when the session token is updated.
|
|
530
|
+
* Use this to persist the session token for reuse across components.
|
|
531
|
+
*/
|
|
532
|
+
onSessionTokenUpdate?: (sessionToken: string) => void;
|
|
533
|
+
/**
|
|
534
|
+
* Optional callback invoked when prescription signing succeeds.
|
|
535
|
+
* Receives the signed CHMED data as a base64-encoded string.
|
|
536
|
+
* Optionally receives the generatedPdf if the option
|
|
537
|
+
* generatePdf is set to true.
|
|
538
|
+
*/
|
|
539
|
+
onSuccess?: (signedCHMED: string, generatedPdf?: string) => void;
|
|
540
|
+
/**
|
|
541
|
+
* Optional callback invoked when prescription signing fails.
|
|
542
|
+
* Receives a specific error type indicating what went wrong.
|
|
543
|
+
*/
|
|
544
|
+
onError?: (error: DomainError) => void;
|
|
545
|
+
}
|
|
546
|
+
export declare const PrescriptionSign: ({ onSuccess, onError, onSessionTokenUpdate, className, ...props }: PrescriptionSignProps) => import("react/jsx-runtime").JSX.Element;
|
|
547
|
+
/**
|
|
548
|
+
* Return type for the usePrescriptionSign hook
|
|
549
|
+
*/
|
|
550
|
+
export interface UsePrescriptionSignReturn {
|
|
551
|
+
/** Function to initiate the signing process with CHMED data */
|
|
552
|
+
start: (encodedCHMED: string, generatePdf?: boolean) => void;
|
|
553
|
+
/** Function to terminate the signing process at any time */
|
|
554
|
+
interrupt: () => void;
|
|
555
|
+
/** Raw XState machine state (for advanced usage) */
|
|
556
|
+
state: any;
|
|
557
|
+
/** True when ready to start signing (initial state) */
|
|
558
|
+
isIdle: boolean;
|
|
559
|
+
/** True when actively processing (excludes error/success states) */
|
|
560
|
+
isActive: boolean;
|
|
561
|
+
/** True when in error state (persists until retry) */
|
|
562
|
+
isError: boolean;
|
|
563
|
+
/** True when signing completed successfully */
|
|
564
|
+
isSuccess: boolean;
|
|
565
|
+
/** True during the actual signature operation */
|
|
566
|
+
isSigning: boolean;
|
|
567
|
+
/** The signed prescription data (available after success) */
|
|
568
|
+
signedCHMED: string | undefined;
|
|
569
|
+
}
|
|
570
|
+
/**
|
|
571
|
+
* Hook to manage the ePrescription signature process
|
|
572
|
+
*
|
|
573
|
+
* This is a standalone hook that can be shipped in a library.
|
|
574
|
+
* It handles the complete HIN authentication and signing flow.
|
|
575
|
+
*
|
|
576
|
+
* Required peer dependencies:
|
|
577
|
+
* - next-auth/react (for session management)
|
|
578
|
+
* - xstate and @xstate/react
|
|
579
|
+
*
|
|
580
|
+
* @returns Object containing:
|
|
581
|
+
* - start: Function to initiate the signing process with CHMED data
|
|
582
|
+
* - interrupt: Function to terminate the signing process at any time
|
|
583
|
+
* - state: Raw XState machine state (for advanced usage)
|
|
584
|
+
* - isIdle: true when ready to start signing (initial state)
|
|
585
|
+
* - isActive: true when actively processing (excludes error/success states)
|
|
586
|
+
* - isError: true when in error state (persists until retry)
|
|
587
|
+
* - isSuccess: true when signing completed successfully
|
|
588
|
+
* - isSigning: true during the actual signature operation
|
|
589
|
+
* - signedCHMED: The signed prescription data (available after success)
|
|
590
|
+
*/
|
|
591
|
+
export declare function usePrescriptionSign(props: UsePrescriptionSigningProps): UsePrescriptionSignReturn;
|
|
592
|
+
export interface ProductDetailsProps {
|
|
593
|
+
accessToken: string;
|
|
594
|
+
environment: Environment;
|
|
595
|
+
language?: string;
|
|
596
|
+
productNumber?: number;
|
|
597
|
+
className?: string;
|
|
598
|
+
onError?: (error: DomainError) => void;
|
|
599
|
+
}
|
|
600
|
+
export declare const ProductDetails: ({ onError, className, ...props }: ProductDetailsProps) => import("react/jsx-runtime").JSX.Element;
|
|
601
|
+
|
|
602
|
+
export {};
|