@dataemergencia/emergency 0.2.1 → 0.4.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/README.md +16 -9
- package/dist/iife/emergency.iife.global.js +24 -24
- package/dist/index.cjs +926 -398
- package/dist/index.d.cts +22 -14
- package/dist/index.d.ts +22 -14
- package/dist/index.js +927 -399
- package/dist/styles.css +418 -3
- package/package.json +1 -1
package/dist/index.d.cts
CHANGED
|
@@ -101,6 +101,17 @@ interface EmergencyGeolocation {
|
|
|
101
101
|
readonly longitude: number;
|
|
102
102
|
readonly accuracy?: number;
|
|
103
103
|
}
|
|
104
|
+
interface EmergencyRealtimeConfig {
|
|
105
|
+
/** Public Pusher app key supplied by the host. */
|
|
106
|
+
readonly key: string;
|
|
107
|
+
/** Pusher cluster that serves the app key. */
|
|
108
|
+
readonly cluster: string;
|
|
109
|
+
/**
|
|
110
|
+
* Channel name pattern. `{phone}` is replaced with the responder phone in
|
|
111
|
+
* digits-only form. Defaults to `whatsapp.{phone}`.
|
|
112
|
+
*/
|
|
113
|
+
readonly channelPattern?: string;
|
|
114
|
+
}
|
|
104
115
|
interface EmergencyConfig {
|
|
105
116
|
/** Full BFF route prefix, for example `https://example.com/de-bff/emergency`. */
|
|
106
117
|
readonly bffBaseUrl: string;
|
|
@@ -122,6 +133,11 @@ interface EmergencyConfig {
|
|
|
122
133
|
readonly geolocationTimeoutMs?: number;
|
|
123
134
|
/** Request timeout in milliseconds. Defaults to 15000. */
|
|
124
135
|
readonly requestTimeoutMs?: number;
|
|
136
|
+
/**
|
|
137
|
+
* Public Pusher values supplied by the host. When omitted, the client stays
|
|
138
|
+
* in pull mode and never opens a realtime connection.
|
|
139
|
+
*/
|
|
140
|
+
readonly realtime?: EmergencyRealtimeConfig;
|
|
125
141
|
}
|
|
126
142
|
interface EmergencySnapshot {
|
|
127
143
|
readonly emergencyId: string;
|
|
@@ -239,18 +255,8 @@ interface EmergencyMountOptions extends EmergencyConfig {
|
|
|
239
255
|
* message, and an inert client.
|
|
240
256
|
*/
|
|
241
257
|
export declare function mount(options: EmergencyMountOptions): EmergencyClient;
|
|
242
|
-
interface RealtimePusherConfig {
|
|
243
|
-
readonly key: string;
|
|
244
|
-
readonly cluster: string;
|
|
245
|
-
readonly channel_pattern: string;
|
|
246
|
-
}
|
|
247
|
-
interface RealtimePublicConfig {
|
|
248
|
-
readonly mode: 'public';
|
|
249
|
-
readonly pusher: RealtimePusherConfig;
|
|
250
|
-
}
|
|
251
258
|
interface ConfigResponse {
|
|
252
259
|
readonly route_prefix: string;
|
|
253
|
-
readonly realtime: RealtimePublicConfig;
|
|
254
260
|
readonly csrf_token: string;
|
|
255
261
|
}
|
|
256
262
|
interface SessionResponse {
|
|
@@ -292,7 +298,6 @@ type EmergencyPayload = Readonly<Record<string, unknown>>;
|
|
|
292
298
|
interface CurrentResponse {
|
|
293
299
|
readonly active: boolean;
|
|
294
300
|
readonly emergency: EmergencyPayload | null;
|
|
295
|
-
readonly realtime: RealtimePublicConfig;
|
|
296
301
|
}
|
|
297
302
|
interface GeolocationRequest {
|
|
298
303
|
readonly latitude: number;
|
|
@@ -377,7 +382,7 @@ interface RealtimeProvider {
|
|
|
377
382
|
* Returns `null` when the realtime configuration is unusable, in which case
|
|
378
383
|
* the client keeps working in pull mode.
|
|
379
384
|
*/
|
|
380
|
-
subscribe(config:
|
|
385
|
+
subscribe(config: EmergencyRealtimeConfig, phones: readonly string[], handlers: RealtimeHandlers): RealtimeSubscription | null;
|
|
381
386
|
}
|
|
382
387
|
export declare function createPusherRealtimeProvider(): RealtimeProvider;
|
|
383
388
|
type EmergencyStore = StoreApi<EmergencyClientState>;
|
|
@@ -409,7 +414,10 @@ interface ConfigValidationResult {
|
|
|
409
414
|
readonly error: EmergencyError | null;
|
|
410
415
|
readonly config: EmergencyConfig | null;
|
|
411
416
|
}
|
|
412
|
-
|
|
417
|
+
type EmergencyConfigInput = Omit<EmergencyConfig, 'realtime'> & {
|
|
418
|
+
readonly realtime?: unknown;
|
|
419
|
+
};
|
|
420
|
+
export declare function validateConfig(config: EmergencyConfigInput): ConfigValidationResult;
|
|
413
421
|
export declare function themeToCssVariables(theme: EmergencyTheme | undefined): Record<string, string>;
|
|
414
422
|
interface EmergencyErrorOptions {
|
|
415
423
|
status?: number | null;
|
|
@@ -428,5 +436,5 @@ export declare class EmergencyClientError extends Error {
|
|
|
428
436
|
readonly error: EmergencyError;
|
|
429
437
|
constructor(error: EmergencyError);
|
|
430
438
|
}
|
|
431
|
-
export type { AbortResponse, AbortResult, ActivateRequest, BffClient, BffClientOptions, ConfigResponse, CsrfStrategy, CurrentResponse, EmergencyClient, EmergencyClientState, EmergencyConfig, EmergencyController, EmergencyControllerDeps, EmergencyError, EmergencyErrorCode, EmergencyEventEmitter, EmergencyEventMap, EmergencyEventName, EmergencyFailure, EmergencyFallback, EmergencyFontFamilyFlags, EmergencyFontLoading, EmergencyGeolocation, EmergencyMountOptions, EmergencyOperation, EmergencyPhase, EmergencyPhaseName, EmergencyResultPayload, EmergencySnapshot, EmergencyStore, EmergencyTheme, EmergencyTrigger, FailurePayload, Message, MessageKind, PanelCloseReason, PanelOpenReason, RealtimeStatus, RefreshResponse, Responder, ResponderPayload, ResponderStatus, SessionResponse, SimulationResult };
|
|
439
|
+
export type { AbortResponse, AbortResult, ActivateRequest, BffClient, BffClientOptions, ConfigResponse, CsrfStrategy, CurrentResponse, EmergencyClient, EmergencyClientState, EmergencyConfig, EmergencyConfigInput, EmergencyController, EmergencyControllerDeps, EmergencyError, EmergencyErrorCode, EmergencyEventEmitter, EmergencyEventMap, EmergencyEventName, EmergencyFailure, EmergencyFallback, EmergencyFontFamilyFlags, EmergencyFontLoading, EmergencyGeolocation, EmergencyMountOptions, EmergencyOperation, EmergencyPhase, EmergencyPhaseName, EmergencyRealtimeConfig, EmergencyResultPayload, EmergencySnapshot, EmergencyStore, EmergencyTheme, EmergencyTrigger, FailurePayload, Message, MessageKind, PanelCloseReason, PanelOpenReason, RealtimeStatus, RefreshResponse, Responder, ResponderPayload, ResponderStatus, SessionResponse, SimulationResult };
|
|
432
440
|
//# sourceMappingURL=index.d.cts.map
|
package/dist/index.d.ts
CHANGED
|
@@ -101,6 +101,17 @@ interface EmergencyGeolocation {
|
|
|
101
101
|
readonly longitude: number;
|
|
102
102
|
readonly accuracy?: number;
|
|
103
103
|
}
|
|
104
|
+
interface EmergencyRealtimeConfig {
|
|
105
|
+
/** Public Pusher app key supplied by the host. */
|
|
106
|
+
readonly key: string;
|
|
107
|
+
/** Pusher cluster that serves the app key. */
|
|
108
|
+
readonly cluster: string;
|
|
109
|
+
/**
|
|
110
|
+
* Channel name pattern. `{phone}` is replaced with the responder phone in
|
|
111
|
+
* digits-only form. Defaults to `whatsapp.{phone}`.
|
|
112
|
+
*/
|
|
113
|
+
readonly channelPattern?: string;
|
|
114
|
+
}
|
|
104
115
|
interface EmergencyConfig {
|
|
105
116
|
/** Full BFF route prefix, for example `https://example.com/de-bff/emergency`. */
|
|
106
117
|
readonly bffBaseUrl: string;
|
|
@@ -122,6 +133,11 @@ interface EmergencyConfig {
|
|
|
122
133
|
readonly geolocationTimeoutMs?: number;
|
|
123
134
|
/** Request timeout in milliseconds. Defaults to 15000. */
|
|
124
135
|
readonly requestTimeoutMs?: number;
|
|
136
|
+
/**
|
|
137
|
+
* Public Pusher values supplied by the host. When omitted, the client stays
|
|
138
|
+
* in pull mode and never opens a realtime connection.
|
|
139
|
+
*/
|
|
140
|
+
readonly realtime?: EmergencyRealtimeConfig;
|
|
125
141
|
}
|
|
126
142
|
interface EmergencySnapshot {
|
|
127
143
|
readonly emergencyId: string;
|
|
@@ -239,18 +255,8 @@ interface EmergencyMountOptions extends EmergencyConfig {
|
|
|
239
255
|
* message, and an inert client.
|
|
240
256
|
*/
|
|
241
257
|
export declare function mount(options: EmergencyMountOptions): EmergencyClient;
|
|
242
|
-
interface RealtimePusherConfig {
|
|
243
|
-
readonly key: string;
|
|
244
|
-
readonly cluster: string;
|
|
245
|
-
readonly channel_pattern: string;
|
|
246
|
-
}
|
|
247
|
-
interface RealtimePublicConfig {
|
|
248
|
-
readonly mode: 'public';
|
|
249
|
-
readonly pusher: RealtimePusherConfig;
|
|
250
|
-
}
|
|
251
258
|
interface ConfigResponse {
|
|
252
259
|
readonly route_prefix: string;
|
|
253
|
-
readonly realtime: RealtimePublicConfig;
|
|
254
260
|
readonly csrf_token: string;
|
|
255
261
|
}
|
|
256
262
|
interface SessionResponse {
|
|
@@ -292,7 +298,6 @@ type EmergencyPayload = Readonly<Record<string, unknown>>;
|
|
|
292
298
|
interface CurrentResponse {
|
|
293
299
|
readonly active: boolean;
|
|
294
300
|
readonly emergency: EmergencyPayload | null;
|
|
295
|
-
readonly realtime: RealtimePublicConfig;
|
|
296
301
|
}
|
|
297
302
|
interface GeolocationRequest {
|
|
298
303
|
readonly latitude: number;
|
|
@@ -377,7 +382,7 @@ interface RealtimeProvider {
|
|
|
377
382
|
* Returns `null` when the realtime configuration is unusable, in which case
|
|
378
383
|
* the client keeps working in pull mode.
|
|
379
384
|
*/
|
|
380
|
-
subscribe(config:
|
|
385
|
+
subscribe(config: EmergencyRealtimeConfig, phones: readonly string[], handlers: RealtimeHandlers): RealtimeSubscription | null;
|
|
381
386
|
}
|
|
382
387
|
export declare function createPusherRealtimeProvider(): RealtimeProvider;
|
|
383
388
|
type EmergencyStore = StoreApi<EmergencyClientState>;
|
|
@@ -409,7 +414,10 @@ interface ConfigValidationResult {
|
|
|
409
414
|
readonly error: EmergencyError | null;
|
|
410
415
|
readonly config: EmergencyConfig | null;
|
|
411
416
|
}
|
|
412
|
-
|
|
417
|
+
type EmergencyConfigInput = Omit<EmergencyConfig, 'realtime'> & {
|
|
418
|
+
readonly realtime?: unknown;
|
|
419
|
+
};
|
|
420
|
+
export declare function validateConfig(config: EmergencyConfigInput): ConfigValidationResult;
|
|
413
421
|
export declare function themeToCssVariables(theme: EmergencyTheme | undefined): Record<string, string>;
|
|
414
422
|
interface EmergencyErrorOptions {
|
|
415
423
|
status?: number | null;
|
|
@@ -428,5 +436,5 @@ export declare class EmergencyClientError extends Error {
|
|
|
428
436
|
readonly error: EmergencyError;
|
|
429
437
|
constructor(error: EmergencyError);
|
|
430
438
|
}
|
|
431
|
-
export type { AbortResponse, AbortResult, ActivateRequest, BffClient, BffClientOptions, ConfigResponse, CsrfStrategy, CurrentResponse, EmergencyClient, EmergencyClientState, EmergencyConfig, EmergencyController, EmergencyControllerDeps, EmergencyError, EmergencyErrorCode, EmergencyEventEmitter, EmergencyEventMap, EmergencyEventName, EmergencyFailure, EmergencyFallback, EmergencyFontFamilyFlags, EmergencyFontLoading, EmergencyGeolocation, EmergencyMountOptions, EmergencyOperation, EmergencyPhase, EmergencyPhaseName, EmergencyResultPayload, EmergencySnapshot, EmergencyStore, EmergencyTheme, EmergencyTrigger, FailurePayload, Message, MessageKind, PanelCloseReason, PanelOpenReason, RealtimeStatus, RefreshResponse, Responder, ResponderPayload, ResponderStatus, SessionResponse, SimulationResult };
|
|
439
|
+
export type { AbortResponse, AbortResult, ActivateRequest, BffClient, BffClientOptions, ConfigResponse, CsrfStrategy, CurrentResponse, EmergencyClient, EmergencyClientState, EmergencyConfig, EmergencyConfigInput, EmergencyController, EmergencyControllerDeps, EmergencyError, EmergencyErrorCode, EmergencyEventEmitter, EmergencyEventMap, EmergencyEventName, EmergencyFailure, EmergencyFallback, EmergencyFontFamilyFlags, EmergencyFontLoading, EmergencyGeolocation, EmergencyMountOptions, EmergencyOperation, EmergencyPhase, EmergencyPhaseName, EmergencyRealtimeConfig, EmergencyResultPayload, EmergencySnapshot, EmergencyStore, EmergencyTheme, EmergencyTrigger, FailurePayload, Message, MessageKind, PanelCloseReason, PanelOpenReason, RealtimeStatus, RefreshResponse, Responder, ResponderPayload, ResponderStatus, SessionResponse, SimulationResult };
|
|
432
440
|
//# sourceMappingURL=index.d.ts.map
|