grm-shared-library 1.1.181 → 1.1.183
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 +72 -2
- package/dist/cjs/index.js +2 -0
- package/dist/cjs/index.js.map +1 -1
- package/dist/cjs/modules/country/constants/country-defaults.const.js +20 -0
- package/dist/cjs/modules/country/constants/country-defaults.const.js.map +1 -0
- package/dist/cjs/modules/country/constants/supported-countries.const.js +64 -0
- package/dist/cjs/modules/country/constants/supported-countries.const.js.map +1 -0
- package/dist/cjs/modules/country/constants/supported-currencies.const.js +36 -0
- package/dist/cjs/modules/country/constants/supported-currencies.const.js.map +1 -0
- package/dist/cjs/modules/country/dtos/country-scope.dto.js +47 -0
- package/dist/cjs/modules/country/dtos/country-scope.dto.js.map +1 -0
- package/dist/cjs/modules/country/enums/calling-code.enum.js +19 -0
- package/dist/cjs/modules/country/enums/calling-code.enum.js.map +1 -0
- package/dist/cjs/modules/country/enums/country-code.enum.js +21 -0
- package/dist/cjs/modules/country/enums/country-code.enum.js.map +1 -0
- package/dist/cjs/modules/country/enums/currency-code.enum.js +20 -0
- package/dist/cjs/modules/country/enums/currency-code.enum.js.map +1 -0
- package/dist/cjs/modules/country/index.js +34 -0
- package/dist/cjs/modules/country/index.js.map +1 -0
- package/dist/cjs/modules/country/interfaces/geo-coordinates.js +3 -0
- package/dist/cjs/modules/country/interfaces/geo-coordinates.js.map +1 -0
- package/dist/cjs/modules/country/interfaces/map-bounds.js +3 -0
- package/dist/cjs/modules/country/interfaces/map-bounds.js.map +1 -0
- package/dist/cjs/modules/country/interfaces/supported-country-config.js +3 -0
- package/dist/cjs/modules/country/interfaces/supported-country-config.js.map +1 -0
- package/dist/cjs/modules/country/interfaces/supported-currency-config.js +3 -0
- package/dist/cjs/modules/country/interfaces/supported-currency-config.js.map +1 -0
- package/dist/cjs/modules/country/utils/country.util.js +60 -0
- package/dist/cjs/modules/country/utils/country.util.js.map +1 -0
- package/dist/cjs/modules/notification/enums/email-provider-name.enum.js +15 -0
- package/dist/cjs/modules/notification/enums/email-provider-name.enum.js.map +1 -0
- package/dist/cjs/modules/notification/enums/notification-channel.enum.js +15 -0
- package/dist/cjs/modules/notification/enums/notification-channel.enum.js.map +1 -0
- package/dist/cjs/modules/notification/enums/notification-overall-status.enum.js +16 -0
- package/dist/cjs/modules/notification/enums/notification-overall-status.enum.js.map +1 -0
- package/dist/cjs/modules/notification/enums/provider-failure-reason.enum.js +28 -0
- package/dist/cjs/modules/notification/enums/provider-failure-reason.enum.js.map +1 -0
- package/dist/cjs/modules/notification/enums/sms-provider-name.enum.js +14 -0
- package/dist/cjs/modules/notification/enums/sms-provider-name.enum.js.map +1 -0
- package/dist/cjs/modules/notification/index.js +32 -0
- package/dist/cjs/modules/notification/index.js.map +1 -0
- package/dist/cjs/modules/notification/interfaces/email-send-request.js +3 -0
- package/dist/cjs/modules/notification/interfaces/email-send-request.js.map +1 -0
- package/dist/cjs/modules/notification/interfaces/email-send-result.js +3 -0
- package/dist/cjs/modules/notification/interfaces/email-send-result.js.map +1 -0
- package/dist/cjs/modules/notification/interfaces/notification-dispatch-result.js +3 -0
- package/dist/cjs/modules/notification/interfaces/notification-dispatch-result.js.map +1 -0
- package/dist/cjs/modules/notification/interfaces/per-channel-result.js +3 -0
- package/dist/cjs/modules/notification/interfaces/per-channel-result.js.map +1 -0
- package/dist/cjs/modules/notification/interfaces/provider-attempt.js +3 -0
- package/dist/cjs/modules/notification/interfaces/provider-attempt.js.map +1 -0
- package/dist/cjs/modules/notification/interfaces/sms-send-request.js +3 -0
- package/dist/cjs/modules/notification/interfaces/sms-send-request.js.map +1 -0
- package/dist/cjs/modules/notification/interfaces/sms-send-result.js +3 -0
- package/dist/cjs/modules/notification/interfaces/sms-send-result.js.map +1 -0
- package/dist/cjs/modules/permission/data/permissions.data.js +66 -0
- package/dist/cjs/modules/permission/data/permissions.data.js.map +1 -1
- package/dist/cjs/modules/permission/enums/permission-actions.enum.js +58 -0
- package/dist/cjs/modules/permission/enums/permission-actions.enum.js.map +1 -1
- package/dist/cjs/modules/permission/enums/permissions-module.enum.js +2 -0
- package/dist/cjs/modules/permission/enums/permissions-module.enum.js.map +1 -1
- package/dist/cjs/modules/role/constants/roles-by-scope.js +3 -1
- package/dist/cjs/modules/role/constants/roles-by-scope.js.map +1 -1
- package/dist/cjs/modules/role/enums/role.enum.js +2 -0
- package/dist/cjs/modules/role/enums/role.enum.js.map +1 -1
- package/dist/esm/index.js +2 -0
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/modules/country/constants/country-defaults.const.js +17 -0
- package/dist/esm/modules/country/constants/country-defaults.const.js.map +1 -0
- package/dist/esm/modules/country/constants/supported-countries.const.js +61 -0
- package/dist/esm/modules/country/constants/supported-countries.const.js.map +1 -0
- package/dist/esm/modules/country/constants/supported-currencies.const.js +33 -0
- package/dist/esm/modules/country/constants/supported-currencies.const.js.map +1 -0
- package/dist/esm/modules/country/dtos/country-scope.dto.js +43 -0
- package/dist/esm/modules/country/dtos/country-scope.dto.js.map +1 -0
- package/dist/esm/modules/country/enums/calling-code.enum.js +16 -0
- package/dist/esm/modules/country/enums/calling-code.enum.js.map +1 -0
- package/dist/esm/modules/country/enums/country-code.enum.js +18 -0
- package/dist/esm/modules/country/enums/country-code.enum.js.map +1 -0
- package/dist/esm/modules/country/enums/currency-code.enum.js +17 -0
- package/dist/esm/modules/country/enums/currency-code.enum.js.map +1 -0
- package/dist/esm/modules/country/index.js +18 -0
- package/dist/esm/modules/country/index.js.map +1 -0
- package/dist/esm/modules/country/interfaces/geo-coordinates.js +2 -0
- package/dist/esm/modules/country/interfaces/geo-coordinates.js.map +1 -0
- package/dist/esm/modules/country/interfaces/map-bounds.js +2 -0
- package/dist/esm/modules/country/interfaces/map-bounds.js.map +1 -0
- package/dist/esm/modules/country/interfaces/supported-country-config.js +2 -0
- package/dist/esm/modules/country/interfaces/supported-country-config.js.map +1 -0
- package/dist/esm/modules/country/interfaces/supported-currency-config.js +2 -0
- package/dist/esm/modules/country/interfaces/supported-currency-config.js.map +1 -0
- package/dist/esm/modules/country/utils/country.util.js +51 -0
- package/dist/esm/modules/country/utils/country.util.js.map +1 -0
- package/dist/esm/modules/notification/enums/email-provider-name.enum.js +12 -0
- package/dist/esm/modules/notification/enums/email-provider-name.enum.js.map +1 -0
- package/dist/esm/modules/notification/enums/notification-channel.enum.js +12 -0
- package/dist/esm/modules/notification/enums/notification-channel.enum.js.map +1 -0
- package/dist/esm/modules/notification/enums/notification-overall-status.enum.js +13 -0
- package/dist/esm/modules/notification/enums/notification-overall-status.enum.js.map +1 -0
- package/dist/esm/modules/notification/enums/provider-failure-reason.enum.js +25 -0
- package/dist/esm/modules/notification/enums/provider-failure-reason.enum.js.map +1 -0
- package/dist/esm/modules/notification/enums/sms-provider-name.enum.js +11 -0
- package/dist/esm/modules/notification/enums/sms-provider-name.enum.js.map +1 -0
- package/dist/esm/modules/notification/index.js +16 -0
- package/dist/esm/modules/notification/index.js.map +1 -0
- package/dist/esm/modules/notification/interfaces/email-send-request.js +2 -0
- package/dist/esm/modules/notification/interfaces/email-send-request.js.map +1 -0
- package/dist/esm/modules/notification/interfaces/email-send-result.js +2 -0
- package/dist/esm/modules/notification/interfaces/email-send-result.js.map +1 -0
- package/dist/esm/modules/notification/interfaces/notification-dispatch-result.js +2 -0
- package/dist/esm/modules/notification/interfaces/notification-dispatch-result.js.map +1 -0
- package/dist/esm/modules/notification/interfaces/per-channel-result.js +2 -0
- package/dist/esm/modules/notification/interfaces/per-channel-result.js.map +1 -0
- package/dist/esm/modules/notification/interfaces/provider-attempt.js +2 -0
- package/dist/esm/modules/notification/interfaces/provider-attempt.js.map +1 -0
- package/dist/esm/modules/notification/interfaces/sms-send-request.js +2 -0
- package/dist/esm/modules/notification/interfaces/sms-send-request.js.map +1 -0
- package/dist/esm/modules/notification/interfaces/sms-send-result.js +2 -0
- package/dist/esm/modules/notification/interfaces/sms-send-result.js.map +1 -0
- package/dist/esm/modules/permission/data/permissions.data.js +66 -0
- package/dist/esm/modules/permission/data/permissions.data.js.map +1 -1
- package/dist/esm/modules/permission/enums/permission-actions.enum.js +58 -0
- package/dist/esm/modules/permission/enums/permission-actions.enum.js.map +1 -1
- package/dist/esm/modules/permission/enums/permissions-module.enum.js +2 -0
- package/dist/esm/modules/permission/enums/permissions-module.enum.js.map +1 -1
- package/dist/esm/modules/role/constants/roles-by-scope.js +3 -1
- package/dist/esm/modules/role/constants/roles-by-scope.js.map +1 -1
- package/dist/esm/modules/role/enums/role.enum.js +2 -0
- package/dist/esm/modules/role/enums/role.enum.js.map +1 -1
- package/dist/types/index.d.ts +2 -0
- package/dist/types/modules/country/constants/country-defaults.const.d.ts +15 -0
- package/dist/types/modules/country/constants/supported-countries.const.d.ts +13 -0
- package/dist/types/modules/country/constants/supported-currencies.const.d.ts +11 -0
- package/dist/types/modules/country/dtos/country-scope.dto.d.ts +13 -0
- package/dist/types/modules/country/enums/calling-code.enum.d.ts +14 -0
- package/dist/types/modules/country/enums/country-code.enum.d.ts +16 -0
- package/dist/types/modules/country/enums/currency-code.enum.d.ts +15 -0
- package/dist/types/modules/country/index.d.ts +12 -0
- package/dist/types/modules/country/interfaces/geo-coordinates.d.ts +12 -0
- package/dist/types/modules/country/interfaces/map-bounds.d.ts +16 -0
- package/dist/types/modules/country/interfaces/supported-country-config.d.ts +39 -0
- package/dist/types/modules/country/interfaces/supported-currency-config.d.ts +19 -0
- package/dist/types/modules/country/utils/country.util.d.ts +27 -0
- package/dist/types/modules/notification/enums/email-provider-name.enum.d.ts +10 -0
- package/dist/types/modules/notification/enums/notification-channel.enum.d.ts +10 -0
- package/dist/types/modules/notification/enums/notification-overall-status.enum.d.ts +11 -0
- package/dist/types/modules/notification/enums/provider-failure-reason.enum.d.ts +23 -0
- package/dist/types/modules/notification/enums/sms-provider-name.enum.d.ts +9 -0
- package/dist/types/modules/notification/index.d.ts +12 -0
- package/dist/types/modules/notification/interfaces/email-send-request.d.ts +35 -0
- package/dist/types/modules/notification/interfaces/email-send-result.d.ts +22 -0
- package/dist/types/modules/notification/interfaces/notification-dispatch-result.d.ts +26 -0
- package/dist/types/modules/notification/interfaces/per-channel-result.d.ts +22 -0
- package/dist/types/modules/notification/interfaces/provider-attempt.d.ts +25 -0
- package/dist/types/modules/notification/interfaces/sms-send-request.d.ts +18 -0
- package/dist/types/modules/notification/interfaces/sms-send-result.d.ts +22 -0
- package/dist/types/modules/permission/enums/permission-actions.enum.d.ts +57 -1
- package/dist/types/modules/permission/enums/permissions-module.enum.d.ts +3 -1
- package/dist/types/modules/role/enums/role.enum.d.ts +2 -0
- package/package.json +4 -3
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A simple latitude/longitude pair (WGS84 decimal degrees).
|
|
3
|
+
*
|
|
4
|
+
* Used for country-level map defaults (e.g. the default map center). Kept
|
|
5
|
+
* dependency-free so it is reusable across backend, admin and mobile.
|
|
6
|
+
*/
|
|
7
|
+
export interface GeoCoordinates {
|
|
8
|
+
/** Latitude in decimal degrees, range -90..90. */
|
|
9
|
+
lat: number;
|
|
10
|
+
/** Longitude in decimal degrees, range -180..180. */
|
|
11
|
+
lng: number;
|
|
12
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A rectangular geographic bounding box.
|
|
3
|
+
*
|
|
4
|
+
* Field names match the Google Maps `LatLngBoundsLiteral` shape so the value
|
|
5
|
+
* can be passed straight to the Maps JS SDK / Flutter map bounds restriction.
|
|
6
|
+
*/
|
|
7
|
+
export interface MapBounds {
|
|
8
|
+
/** Northernmost latitude (max lat). */
|
|
9
|
+
north: number;
|
|
10
|
+
/** Southernmost latitude (min lat). */
|
|
11
|
+
south: number;
|
|
12
|
+
/** Easternmost longitude (max lng). */
|
|
13
|
+
east: number;
|
|
14
|
+
/** Westernmost longitude (min lng). */
|
|
15
|
+
west: number;
|
|
16
|
+
}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { CountryCode } from '../enums/country-code.enum';
|
|
2
|
+
import { CurrencyCode } from '../enums/currency-code.enum';
|
|
3
|
+
import { GeoCoordinates } from './geo-coordinates';
|
|
4
|
+
import { MapBounds } from './map-bounds';
|
|
5
|
+
/**
|
|
6
|
+
* Full platform configuration for a supported country/market.
|
|
7
|
+
*
|
|
8
|
+
* This is the single source of truth that country-aware features (billing,
|
|
9
|
+
* newsfeed, notifications, maps, admin, mobile) should read from instead of
|
|
10
|
+
* hard-coding Kenya-specific values.
|
|
11
|
+
*/
|
|
12
|
+
export interface SupportedCountryConfig {
|
|
13
|
+
/** ISO 3166-1 alpha-2 country code, e.g. 'KE'. */
|
|
14
|
+
code: CountryCode;
|
|
15
|
+
/** Human-readable country name, e.g. 'Kenya'. */
|
|
16
|
+
name: string;
|
|
17
|
+
/** E.164 calling code, e.g. '+254'. */
|
|
18
|
+
callingCode: string;
|
|
19
|
+
/** ISO 4217 currency code used in this country. */
|
|
20
|
+
currencyCode: CurrencyCode;
|
|
21
|
+
/** Currency display symbol, e.g. 'KSh'. */
|
|
22
|
+
currencySymbol: string;
|
|
23
|
+
/** Number of minor-unit decimal digits for the currency. */
|
|
24
|
+
currencyDecimalPlaces: number;
|
|
25
|
+
/** IANA timezone identifier, e.g. 'Africa/Nairobi'. */
|
|
26
|
+
timezone: string;
|
|
27
|
+
/** BCP-47 default locale, e.g. 'en-KE'. */
|
|
28
|
+
defaultLocale: string;
|
|
29
|
+
/** Google Maps region bias (ccTLD), e.g. 'KE'. */
|
|
30
|
+
googleMapsRegion: string;
|
|
31
|
+
/** Default map center (typically the capital city). */
|
|
32
|
+
defaultMapCenter: GeoCoordinates;
|
|
33
|
+
/** Default map zoom level for a country-wide view. */
|
|
34
|
+
defaultMapZoom: number;
|
|
35
|
+
/** Approximate geographic bounding box for the country. */
|
|
36
|
+
mapBounds: MapBounds;
|
|
37
|
+
/** Whether the country is currently enabled for use. */
|
|
38
|
+
enabled: boolean;
|
|
39
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { CurrencyCode } from '../enums/currency-code.enum';
|
|
2
|
+
/**
|
|
3
|
+
* Configuration describing a currency the platform supports.
|
|
4
|
+
*
|
|
5
|
+
* `decimalPlaces` is the number of minor-unit digits (e.g. KES has 2, UGX/TZS
|
|
6
|
+
* have 0) and should drive money formatting and minor-unit conversions.
|
|
7
|
+
*/
|
|
8
|
+
export interface SupportedCurrencyConfig {
|
|
9
|
+
/** ISO 4217 currency code. */
|
|
10
|
+
code: CurrencyCode;
|
|
11
|
+
/** Human-readable currency name, e.g. 'Kenyan Shilling'. */
|
|
12
|
+
name: string;
|
|
13
|
+
/** Display symbol, e.g. 'KSh'. */
|
|
14
|
+
symbol: string;
|
|
15
|
+
/** Number of minor-unit decimal digits, e.g. 2 for KES, 0 for UGX/TZS. */
|
|
16
|
+
decimalPlaces: number;
|
|
17
|
+
/** Whether the currency is currently enabled for use. */
|
|
18
|
+
enabled: boolean;
|
|
19
|
+
}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { CountryCode } from '../enums/country-code.enum';
|
|
2
|
+
import { CurrencyCode } from '../enums/currency-code.enum';
|
|
3
|
+
import { SupportedCountryConfig } from '../interfaces/supported-country-config';
|
|
4
|
+
import { SupportedCurrencyConfig } from '../interfaces/supported-currency-config';
|
|
5
|
+
/**
|
|
6
|
+
* Country / currency helper utilities.
|
|
7
|
+
*
|
|
8
|
+
* These are intentionally simple, synchronous and dependency-free so they can
|
|
9
|
+
* be reused across every backend microservice without pulling in extra deps.
|
|
10
|
+
*/
|
|
11
|
+
/** Type guard: is `value` a supported ISO 3166-1 alpha-2 country code? */
|
|
12
|
+
export declare function isSupportedCountryCode(value: unknown): value is CountryCode;
|
|
13
|
+
/** Type guard: is `value` a supported ISO 4217 currency code? */
|
|
14
|
+
export declare function isSupportedCurrencyCode(value: unknown): value is CurrencyCode;
|
|
15
|
+
/** Get the full config for a supported country, or `undefined` if unsupported. */
|
|
16
|
+
export declare function getSupportedCountryConfig(countryCode: string | null | undefined): SupportedCountryConfig | undefined;
|
|
17
|
+
/** Get the full config for a supported currency, or `undefined` if unsupported. */
|
|
18
|
+
export declare function getSupportedCurrencyConfig(currencyCode: string | null | undefined): SupportedCurrencyConfig | undefined;
|
|
19
|
+
/** Resolve the currency used by a supported country, or `undefined`. */
|
|
20
|
+
export declare function getCurrencyForCountry(countryCode: string | null | undefined): CurrencyCode | undefined;
|
|
21
|
+
/** Resolve the E.164 calling code (e.g. '+254') for a supported country, or `undefined`. */
|
|
22
|
+
export declare function getCallingCodeForCountry(countryCode: string | null | undefined): string | undefined;
|
|
23
|
+
/**
|
|
24
|
+
* Reverse lookup: find the supported country whose E.164 calling code matches
|
|
25
|
+
* `callingCode` (e.g. '+254' -> Kenya), or `undefined` if none match.
|
|
26
|
+
*/
|
|
27
|
+
export declare function getCountryByCallingCode(callingCode: string | null | undefined): SupportedCountryConfig | undefined;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Identifiers for the email providers the notification service can dispatch through.
|
|
3
|
+
* TWILIO_SENDGRID is the Twilio email provider (SendGrid API).
|
|
4
|
+
* Provider order/fallback is configuration-driven; new providers can be appended.
|
|
5
|
+
*/
|
|
6
|
+
export declare enum EmailProviderName {
|
|
7
|
+
TWILIO_SENDGRID = "twilio_sendgrid",
|
|
8
|
+
MAILGUN = "mailgun",
|
|
9
|
+
SES = "ses"
|
|
10
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Aggregate status for a multi-channel notification dispatch.
|
|
3
|
+
* - SUCCESS: every attempted channel succeeded.
|
|
4
|
+
* - PARTIAL_SUCCESS: at least one channel succeeded and at least one failed.
|
|
5
|
+
* - FAILED: no attempted channel succeeded.
|
|
6
|
+
*/
|
|
7
|
+
export declare enum NotificationOverallStatus {
|
|
8
|
+
SUCCESS = "SUCCESS",
|
|
9
|
+
PARTIAL_SUCCESS = "PARTIAL_SUCCESS",
|
|
10
|
+
FAILED = "FAILED"
|
|
11
|
+
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Normalized classification of why a provider attempt failed.
|
|
3
|
+
* Drives fallback behaviour: VALIDATION / CONFIG_MISSING are non-retryable
|
|
4
|
+
* (no fallback), the remainder are provider-level failures that trigger fallback.
|
|
5
|
+
*/
|
|
6
|
+
export declare enum ProviderFailureReason {
|
|
7
|
+
/** Malformed/invalid request (bad recipient, missing body/subject). Do not fall back. */
|
|
8
|
+
VALIDATION = "VALIDATION",
|
|
9
|
+
/** Provider is not configured/enabled. Skip provider (try next), not a send failure. */
|
|
10
|
+
CONFIG_MISSING = "CONFIG_MISSING",
|
|
11
|
+
/** Authentication/authorization failure with the provider. */
|
|
12
|
+
AUTH = "AUTH",
|
|
13
|
+
/** Provider rate limited the request. */
|
|
14
|
+
RATE_LIMIT = "RATE_LIMIT",
|
|
15
|
+
/** Request timed out. */
|
|
16
|
+
TIMEOUT = "TIMEOUT",
|
|
17
|
+
/** Network/connection error reaching the provider. */
|
|
18
|
+
NETWORK = "NETWORK",
|
|
19
|
+
/** Provider returned a server-side/processing error. */
|
|
20
|
+
PROVIDER_ERROR = "PROVIDER_ERROR",
|
|
21
|
+
/** Unclassified failure. */
|
|
22
|
+
UNKNOWN = "UNKNOWN"
|
|
23
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Identifiers for the SMS providers the notification service can dispatch through.
|
|
3
|
+
* Provider order/fallback is configuration-driven; new providers can be appended.
|
|
4
|
+
*/
|
|
5
|
+
export declare enum SmsProviderName {
|
|
6
|
+
TWILIO = "twilio",
|
|
7
|
+
UWAZII = "uwazii",
|
|
8
|
+
AFRICASTALKING = "africastalking"
|
|
9
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
export * from './enums/notification-channel.enum';
|
|
2
|
+
export * from './enums/sms-provider-name.enum';
|
|
3
|
+
export * from './enums/email-provider-name.enum';
|
|
4
|
+
export * from './enums/notification-overall-status.enum';
|
|
5
|
+
export * from './enums/provider-failure-reason.enum';
|
|
6
|
+
export * from './interfaces/provider-attempt';
|
|
7
|
+
export * from './interfaces/per-channel-result';
|
|
8
|
+
export * from './interfaces/sms-send-result';
|
|
9
|
+
export * from './interfaces/email-send-result';
|
|
10
|
+
export * from './interfaces/notification-dispatch-result';
|
|
11
|
+
export * from './interfaces/sms-send-request';
|
|
12
|
+
export * from './interfaces/email-send-request';
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Provider-agnostic email attachment. `content` is base64-encoded; `path` points to
|
|
3
|
+
* a file on disk. `cid` marks an inline attachment referenced from the HTML body.
|
|
4
|
+
*/
|
|
5
|
+
export interface EmailAttachment {
|
|
6
|
+
filename: string;
|
|
7
|
+
content?: string;
|
|
8
|
+
path?: string;
|
|
9
|
+
contentType?: string;
|
|
10
|
+
/** Content-ID for inline images referenced via cid: in the HTML body. */
|
|
11
|
+
cid?: string;
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* Provider-agnostic email send request handed to an EmailProvider implementation.
|
|
15
|
+
* Templating/rendering happens upstream; providers receive final subject/html/text.
|
|
16
|
+
* Backend/service-level contract (not consumed by the web admin).
|
|
17
|
+
*/
|
|
18
|
+
export interface EmailSendRequest {
|
|
19
|
+
to: string[];
|
|
20
|
+
subject: string;
|
|
21
|
+
/** Rendered HTML body. */
|
|
22
|
+
html: string;
|
|
23
|
+
/** Optional rendered plain-text body. */
|
|
24
|
+
text?: string;
|
|
25
|
+
/** From email address. Provider falls back to its configured default when absent. */
|
|
26
|
+
from?: string;
|
|
27
|
+
fromName?: string;
|
|
28
|
+
replyTo?: string;
|
|
29
|
+
cc?: string[];
|
|
30
|
+
bcc?: string[];
|
|
31
|
+
attachments?: EmailAttachment[];
|
|
32
|
+
/** Provider-level categorization tags. */
|
|
33
|
+
tags?: string[];
|
|
34
|
+
metadata?: Record<string, any>;
|
|
35
|
+
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { NotificationChannel } from '../enums/notification-channel.enum';
|
|
2
|
+
import { EmailProviderName } from '../enums/email-provider-name.enum';
|
|
3
|
+
import { ProviderFailureReason } from '../enums/provider-failure-reason.enum';
|
|
4
|
+
import { ProviderAttempt } from './provider-attempt';
|
|
5
|
+
/**
|
|
6
|
+
* Normalized result of an email send across the configured provider chain.
|
|
7
|
+
*/
|
|
8
|
+
export interface EmailSendResult {
|
|
9
|
+
channel: NotificationChannel.EMAIL;
|
|
10
|
+
success: boolean;
|
|
11
|
+
/** Provider that ultimately succeeded. */
|
|
12
|
+
provider?: EmailProviderName | string;
|
|
13
|
+
/** Normalized provider message/reference id. */
|
|
14
|
+
messageId?: string;
|
|
15
|
+
/** Recipients targeted. */
|
|
16
|
+
to?: string[];
|
|
17
|
+
/** Ordered attempts (primary first, then fallbacks). */
|
|
18
|
+
attempts: ProviderAttempt[];
|
|
19
|
+
failureReason?: ProviderFailureReason;
|
|
20
|
+
/** Internal, safe-to-log error summary. */
|
|
21
|
+
errorMessage?: string;
|
|
22
|
+
}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { NotificationChannel } from '../enums/notification-channel.enum';
|
|
2
|
+
import { NotificationOverallStatus } from '../enums/notification-overall-status.enum';
|
|
3
|
+
import { PerChannelResult } from './per-channel-result';
|
|
4
|
+
import { ProviderAttempt } from './provider-attempt';
|
|
5
|
+
/**
|
|
6
|
+
* Aggregate outcome of a multi-channel notification dispatch.
|
|
7
|
+
*
|
|
8
|
+
* NOTE: In the current architecture most dispatches are triggered by fire-and-forget
|
|
9
|
+
* Kafka events, so this object is produced for internal logging/persistence and
|
|
10
|
+
* observability rather than being returned synchronously to the original API caller.
|
|
11
|
+
* It is display-safe (no secrets) and can back a future synchronous notification
|
|
12
|
+
* endpoint or an admin-facing view.
|
|
13
|
+
*/
|
|
14
|
+
export interface NotificationDispatchResult {
|
|
15
|
+
overallStatus: NotificationOverallStatus;
|
|
16
|
+
successfulChannels: NotificationChannel[];
|
|
17
|
+
failedChannels: NotificationChannel[];
|
|
18
|
+
/** Per-channel outcomes including provider attempts. */
|
|
19
|
+
perChannelResults: PerChannelResult[];
|
|
20
|
+
/** Flattened list of every provider attempt across all channels. */
|
|
21
|
+
providerAttempts: ProviderAttempt[];
|
|
22
|
+
/** Internal, safe-to-log error summaries. */
|
|
23
|
+
errors: string[];
|
|
24
|
+
/** Correlation/trace id linking this dispatch to the originating event. */
|
|
25
|
+
correlationId?: string;
|
|
26
|
+
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { NotificationChannel } from '../enums/notification-channel.enum';
|
|
2
|
+
import { ProviderFailureReason } from '../enums/provider-failure-reason.enum';
|
|
3
|
+
import { ProviderAttempt } from './provider-attempt';
|
|
4
|
+
/**
|
|
5
|
+
* Normalized outcome for a single notification channel, including every provider
|
|
6
|
+
* attempt made (primary and fallbacks) and which provider ultimately succeeded.
|
|
7
|
+
*/
|
|
8
|
+
export interface PerChannelResult {
|
|
9
|
+
channel: NotificationChannel;
|
|
10
|
+
success: boolean;
|
|
11
|
+
/** Provider that ultimately succeeded (undefined when the channel failed). */
|
|
12
|
+
provider?: string;
|
|
13
|
+
/** Normalized provider reference id from the successful provider. */
|
|
14
|
+
messageId?: string;
|
|
15
|
+
/** Ordered attempts (primary first, then fallbacks). */
|
|
16
|
+
attempts: ProviderAttempt[];
|
|
17
|
+
/** True when the channel was intentionally not attempted (e.g. no recipient). */
|
|
18
|
+
skipped?: boolean;
|
|
19
|
+
failureReason?: ProviderFailureReason;
|
|
20
|
+
/** Internal, safe-to-log error summary. */
|
|
21
|
+
errorMessage?: string;
|
|
22
|
+
}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { NotificationChannel } from '../enums/notification-channel.enum';
|
|
2
|
+
import { ProviderFailureReason } from '../enums/provider-failure-reason.enum';
|
|
3
|
+
/**
|
|
4
|
+
* Record of a single provider send attempt within a channel.
|
|
5
|
+
* One channel may produce several attempts (primary + fallbacks).
|
|
6
|
+
* Error details here are intended for internal logging/observability, not for
|
|
7
|
+
* public API clients.
|
|
8
|
+
*/
|
|
9
|
+
export interface ProviderAttempt {
|
|
10
|
+
/** Provider identifier (SmsProviderName | EmailProviderName value). */
|
|
11
|
+
provider: string;
|
|
12
|
+
channel: NotificationChannel;
|
|
13
|
+
success: boolean;
|
|
14
|
+
/** Whether the failure was provider-level and eligible for fallback. */
|
|
15
|
+
retryable?: boolean;
|
|
16
|
+
failureReason?: ProviderFailureReason;
|
|
17
|
+
/** Normalized provider message/reference id when the send succeeded. */
|
|
18
|
+
messageId?: string;
|
|
19
|
+
/** Internal, safe-to-log error summary (never surfaced to public clients). */
|
|
20
|
+
errorMessage?: string;
|
|
21
|
+
/** Provider HTTP/status code when available. */
|
|
22
|
+
statusCode?: number;
|
|
23
|
+
startedAt?: string;
|
|
24
|
+
durationMs?: number;
|
|
25
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Provider-agnostic SMS send request handed to an SmsProvider implementation.
|
|
3
|
+
* Backend/service-level contract (not consumed by the web admin).
|
|
4
|
+
*/
|
|
5
|
+
export interface SmsSendRequest {
|
|
6
|
+
/** Recipients in E.164 format. */
|
|
7
|
+
to: string[];
|
|
8
|
+
/** Message body. */
|
|
9
|
+
body: string;
|
|
10
|
+
/** Sender id / from (alphanumeric sender name or number). Provider may override. */
|
|
11
|
+
senderId?: string;
|
|
12
|
+
/** Optional provider message type hint. */
|
|
13
|
+
type?: string;
|
|
14
|
+
metadata?: Record<string, any>;
|
|
15
|
+
incidentId?: number;
|
|
16
|
+
userId?: number;
|
|
17
|
+
organizationId?: number;
|
|
18
|
+
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { NotificationChannel } from '../enums/notification-channel.enum';
|
|
2
|
+
import { ProviderFailureReason } from '../enums/provider-failure-reason.enum';
|
|
3
|
+
import { SmsProviderName } from '../enums/sms-provider-name.enum';
|
|
4
|
+
import { ProviderAttempt } from './provider-attempt';
|
|
5
|
+
/**
|
|
6
|
+
* Normalized result of an SMS send across the configured provider chain.
|
|
7
|
+
*/
|
|
8
|
+
export interface SmsSendResult {
|
|
9
|
+
channel: NotificationChannel.SMS;
|
|
10
|
+
success: boolean;
|
|
11
|
+
/** Provider that ultimately succeeded. */
|
|
12
|
+
provider?: SmsProviderName | string;
|
|
13
|
+
/** Normalized provider message/reference id. */
|
|
14
|
+
messageId?: string;
|
|
15
|
+
/** Recipients targeted (E.164). */
|
|
16
|
+
to?: string[];
|
|
17
|
+
/** Ordered attempts (primary first, then fallbacks). */
|
|
18
|
+
attempts: ProviderAttempt[];
|
|
19
|
+
failureReason?: ProviderFailureReason;
|
|
20
|
+
/** Internal, safe-to-log error summary. */
|
|
21
|
+
errorMessage?: string;
|
|
22
|
+
}
|
|
@@ -34,5 +34,61 @@ export declare enum PermissionActions {
|
|
|
34
34
|
CREATE_RESPONSE_UNIT = "create:response-unit",
|
|
35
35
|
READ_RESPONSE_UNIT = "read:response-unit",
|
|
36
36
|
UPDATE_RESPONSE_UNIT = "update:response-unit",
|
|
37
|
-
DELETE_RESPONSE_UNIT = "delete:response-unit"
|
|
37
|
+
DELETE_RESPONSE_UNIT = "delete:response-unit",
|
|
38
|
+
CREATE_BENEFICIARY = "create:beneficiary",
|
|
39
|
+
READ_BENEFICIARY = "read:beneficiary",
|
|
40
|
+
UPDATE_BENEFICIARY = "update:beneficiary",
|
|
41
|
+
DELETE_BENEFICIARY = "delete:beneficiary",
|
|
42
|
+
CREATE_BILLING_CONFIG = "create:billing-config",
|
|
43
|
+
READ_BILLING_CONFIG = "read:billing-config",
|
|
44
|
+
UPDATE_BILLING_CONFIG = "update:billing-config",
|
|
45
|
+
DELETE_BILLING_CONFIG = "delete:billing-config",
|
|
46
|
+
CREATE_CORPORATE_CLIENT = "create:corporate-client",
|
|
47
|
+
READ_CORPORATE_CLIENT = "read:corporate-client",
|
|
48
|
+
UPDATE_CORPORATE_CLIENT = "update:corporate-client",
|
|
49
|
+
DELETE_CORPORATE_CLIENT = "delete:corporate-client",
|
|
50
|
+
CREATE_CORPORATE_CLIENT_MEMBER = "create:corporate-client-member",
|
|
51
|
+
READ_CORPORATE_CLIENT_MEMBER = "read:corporate-client-member",
|
|
52
|
+
UPDATE_CORPORATE_CLIENT_MEMBER = "update:corporate-client-member",
|
|
53
|
+
DELETE_CORPORATE_CLIENT_MEMBER = "delete:corporate-client-member",
|
|
54
|
+
CREATE_INDIVIDUAL_CLIENT = "create:individual-client",
|
|
55
|
+
READ_INDIVIDUAL_CLIENT = "read:individual-client",
|
|
56
|
+
UPDATE_INDIVIDUAL_CLIENT = "update:individual-client",
|
|
57
|
+
DELETE_INDIVIDUAL_CLIENT = "delete:individual-client",
|
|
58
|
+
READ_ENTITLEMENT = "read:entitlement",
|
|
59
|
+
CREATE_INVOICE = "create:invoice",
|
|
60
|
+
READ_INVOICE = "read:invoice",
|
|
61
|
+
MARK_INVOICE_PAID = "mark:invoice-paid",
|
|
62
|
+
CREATE_ORDER = "create:order",
|
|
63
|
+
READ_ORDER = "read:order",
|
|
64
|
+
CONFIRM_ORDER = "confirm:order",
|
|
65
|
+
CREATE_RECEIPT = "create:receipt",
|
|
66
|
+
READ_RECEIPT = "read:receipt",
|
|
67
|
+
CREATE_PACKAGE = "create:package",
|
|
68
|
+
READ_PACKAGE = "read:package",
|
|
69
|
+
UPDATE_PACKAGE = "update:package",
|
|
70
|
+
ACTIVATE_PACKAGE = "activate:package",
|
|
71
|
+
DEACTIVATE_PACKAGE = "deactivate:package",
|
|
72
|
+
DELETE_PACKAGE = "delete:package",
|
|
73
|
+
INITIALIZE_PAYMENT = "initialize:payment",
|
|
74
|
+
VERIFY_PAYMENT = "verify:payment",
|
|
75
|
+
READ_PAYMENT = "read:payment",
|
|
76
|
+
INITIALIZE_INDIVIDUAL_SUBSCRIPTION = "initialize:individual-subscription",
|
|
77
|
+
READ_INDIVIDUAL_SUBSCRIPTION = "read:individual-subscription",
|
|
78
|
+
APPROVE_INDIVIDUAL_SUBSCRIPTION_MANUALLY = "approve:individual-subscription-manually",
|
|
79
|
+
CANCEL_INDIVIDUAL_SUBSCRIPTION = "cancel:individual-subscription",
|
|
80
|
+
INITIALIZE_CORPORATE_SUBSCRIPTION = "initialize:corporate-subscription",
|
|
81
|
+
READ_CORPORATE_SUBSCRIPTION = "read:corporate-subscription",
|
|
82
|
+
APPROVE_CORPORATE_SUBSCRIPTION_MANUALLY = "approve:corporate-subscription-manually",
|
|
83
|
+
CANCEL_CORPORATE_SUBSCRIPTION = "cancel:corporate-subscription",
|
|
84
|
+
CREATE_SETTLEMENT = "create:settlement",
|
|
85
|
+
READ_SETTLEMENT = "read:settlement",
|
|
86
|
+
SEND_SETTLEMENT_INVOICE = "send:settlement-invoice",
|
|
87
|
+
MARK_SETTLEMENT_PAID = "mark:settlement-paid",
|
|
88
|
+
CREATE_NEWSFEED_POST = "create:newsfeed-post",
|
|
89
|
+
READ_NEWSFEED_POST = "read:newsfeed-post",
|
|
90
|
+
UPDATE_NEWSFEED_POST = "update:newsfeed-post",
|
|
91
|
+
PUBLISH_NEWSFEED_POST = "publish:newsfeed-post",
|
|
92
|
+
ARCHIVE_NEWSFEED_POST = "archive:newsfeed-post",
|
|
93
|
+
DELETE_NEWSFEED_POST = "delete:newsfeed-post"
|
|
38
94
|
}
|
|
@@ -3,6 +3,8 @@ export declare enum Roles {
|
|
|
3
3
|
ORGANIZATION_OWNER = "Organization:Owner",
|
|
4
4
|
ORGANIZATION_ADMIN = "Organization:Admin",
|
|
5
5
|
ORGANIZATION_USER = "Organization:User",
|
|
6
|
+
ORGANIZATION_BILLING_ADMIN = "Organization:Billing-Admin",
|
|
7
|
+
ORGANIZATION_NEWSFEED_ADMIN = "Organization:Newsfeed-Admin",
|
|
6
8
|
CONTROL_CENTRE_ADMIN = "Control-Centre:Admin",
|
|
7
9
|
CONTROL_CENTRE_USER = "Control-Centre:User",
|
|
8
10
|
RESPONDER = "Responder",
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "grm-shared-library",
|
|
3
|
-
"version": "1.1.
|
|
3
|
+
"version": "1.1.183",
|
|
4
4
|
"main": "dist/cjs/index.js",
|
|
5
5
|
"module": "dist/esm/index.js",
|
|
6
6
|
"types": "dist/types/index.d.ts",
|
|
@@ -20,13 +20,14 @@
|
|
|
20
20
|
"dist/**/*"
|
|
21
21
|
],
|
|
22
22
|
"scripts": {
|
|
23
|
-
"clean": "rimraf dist",
|
|
23
|
+
"clean": "rimraf dist dist-test",
|
|
24
24
|
"build:cjs": "tsc -p tsconfig.cjs.json",
|
|
25
25
|
"build:esm": "tsc -p tsconfig.esm.json",
|
|
26
26
|
"build:types": "tsc -p tsconfig.types.json",
|
|
27
27
|
"build": "npm run clean && npm run build:types && npm run build:cjs && npm run build:esm",
|
|
28
28
|
"prepublishOnly": "npm run build",
|
|
29
|
-
"
|
|
29
|
+
"pretest": "rimraf dist-test",
|
|
30
|
+
"test": "tsc -p tsconfig.spec.json && node dist-test/modules/country/__tests__/country.spec.js"
|
|
30
31
|
},
|
|
31
32
|
"keywords": [],
|
|
32
33
|
"author": "",
|