@nascentdigital/funnel-core 4.4.4
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/app/AppConfig.d.ts +41 -0
- package/dist/app/AppConfig.js +93 -0
- package/dist/app/BrandConfig.d.ts +13 -0
- package/dist/app/BrandConfig.js +2 -0
- package/dist/app/FeaturesConfig.d.ts +6 -0
- package/dist/app/FeaturesConfig.js +2 -0
- package/dist/app/RegionsConfig.d.ts +43 -0
- package/dist/app/RegionsConfig.js +113 -0
- package/dist/app/UIConfig.d.ts +4 -0
- package/dist/app/UIConfig.js +2 -0
- package/dist/app/index.d.ts +5 -0
- package/dist/app/index.js +21 -0
- package/dist/consent/ConsentCategory.d.ts +12 -0
- package/dist/consent/ConsentCategory.js +28 -0
- package/dist/consent/ConsentService.d.ts +15 -0
- package/dist/consent/ConsentService.js +37 -0
- package/dist/consent/index.d.ts +2 -0
- package/dist/consent/index.js +18 -0
- package/dist/errors/IsometricError.d.ts +19 -0
- package/dist/errors/IsometricError.js +30 -0
- package/dist/errors/IsometricErrorModule.d.ts +11 -0
- package/dist/errors/IsometricErrorModule.js +2 -0
- package/dist/errors/IsometricErrorUtils.d.ts +9 -0
- package/dist/errors/IsometricErrorUtils.js +85 -0
- package/dist/errors/SerializedIsometricError.d.ts +10 -0
- package/dist/errors/SerializedIsometricError.js +15 -0
- package/dist/errors/api/ApiError.d.ts +15 -0
- package/dist/errors/api/ApiError.js +23 -0
- package/dist/errors/api/ApiErrors.d.ts +7 -0
- package/dist/errors/api/ApiErrors.js +67 -0
- package/dist/errors/api/ArgumentError.d.ts +7 -0
- package/dist/errors/api/ArgumentError.js +18 -0
- package/dist/errors/api/ConcurrencyError.d.ts +4 -0
- package/dist/errors/api/ConcurrencyError.js +11 -0
- package/dist/errors/api/ConflictError.d.ts +4 -0
- package/dist/errors/api/ConflictError.js +11 -0
- package/dist/errors/api/DependencyError.d.ts +4 -0
- package/dist/errors/api/DependencyError.js +11 -0
- package/dist/errors/api/IllegalStateError.d.ts +4 -0
- package/dist/errors/api/IllegalStateError.js +11 -0
- package/dist/errors/api/InvalidOperationError.d.ts +4 -0
- package/dist/errors/api/InvalidOperationError.js +11 -0
- package/dist/errors/api/NotAuthenticatedError.d.ts +4 -0
- package/dist/errors/api/NotAuthenticatedError.js +11 -0
- package/dist/errors/api/NotAuthorizedError.d.ts +4 -0
- package/dist/errors/api/NotAuthorizedError.js +11 -0
- package/dist/errors/api/NotAvailableError.d.ts +4 -0
- package/dist/errors/api/NotAvailableError.js +11 -0
- package/dist/errors/api/NotFoundError.d.ts +4 -0
- package/dist/errors/api/NotFoundError.js +11 -0
- package/dist/errors/api/NotImplementedError.d.ts +4 -0
- package/dist/errors/api/NotImplementedError.js +11 -0
- package/dist/errors/api/OfflineError.d.ts +4 -0
- package/dist/errors/api/OfflineError.js +11 -0
- package/dist/errors/api/RangeError.d.ts +4 -0
- package/dist/errors/api/RangeError.js +11 -0
- package/dist/errors/api/ServerError.d.ts +4 -0
- package/dist/errors/api/ServerError.js +11 -0
- package/dist/errors/api/TimeoutError.d.ts +4 -0
- package/dist/errors/api/TimeoutError.js +11 -0
- package/dist/errors/api/index.d.ts +16 -0
- package/dist/errors/api/index.js +32 -0
- package/dist/errors/index.d.ts +5 -0
- package/dist/errors/index.js +26 -0
- package/dist/forms/FormModel.d.ts +47 -0
- package/dist/forms/FormModel.js +149 -0
- package/dist/forms/Forms.d.ts +15 -0
- package/dist/forms/Forms.js +35 -0
- package/dist/forms/IFormService.d.ts +6 -0
- package/dist/forms/IFormService.js +2 -0
- package/dist/forms/TranslateSchema.d.ts +8 -0
- package/dist/forms/TranslateSchema.js +2 -0
- package/dist/forms/index.d.ts +4 -0
- package/dist/forms/index.js +20 -0
- package/dist/index.d.ts +10 -0
- package/dist/index.js +49 -0
- package/dist/regionalization/Country.d.ts +266 -0
- package/dist/regionalization/Country.js +338 -0
- package/dist/regionalization/Language.d.ts +199 -0
- package/dist/regionalization/Language.js +237 -0
- package/dist/regionalization/Locale.d.ts +28 -0
- package/dist/regionalization/Locale.js +49 -0
- package/dist/regionalization/Localized.d.ts +10 -0
- package/dist/regionalization/Localized.js +36 -0
- package/dist/regionalization/LocalizedCopy.d.ts +9 -0
- package/dist/regionalization/LocalizedCopy.js +26 -0
- package/dist/regionalization/Regionalization.d.ts +50 -0
- package/dist/regionalization/Regionalization.js +260 -0
- package/dist/regionalization/Regions.d.ts +2 -0
- package/dist/regionalization/Regions.js +2 -0
- package/dist/regionalization/index.d.ts +7 -0
- package/dist/regionalization/index.js +23 -0
- package/dist/schema/Asset.d.ts +23 -0
- package/dist/schema/Asset.js +36 -0
- package/dist/schema/AssetScope.d.ts +75 -0
- package/dist/schema/AssetScope.js +146 -0
- package/dist/schema/Block.d.ts +105 -0
- package/dist/schema/Block.js +122 -0
- package/dist/schema/ChangeSet.d.ts +108 -0
- package/dist/schema/ChangeSet.js +187 -0
- package/dist/schema/Collection.d.ts +197 -0
- package/dist/schema/Collection.js +165 -0
- package/dist/schema/CollectionModel.d.ts +30 -0
- package/dist/schema/CollectionModel.js +383 -0
- package/dist/schema/CollectionSnapshot.d.ts +11 -0
- package/dist/schema/CollectionSnapshot.js +12 -0
- package/dist/schema/Fields.d.ts +31 -0
- package/dist/schema/Fields.js +21 -0
- package/dist/schema/Form.d.ts +31 -0
- package/dist/schema/Form.js +23 -0
- package/dist/schema/LinkedCollectionModel.d.ts +9 -0
- package/dist/schema/LinkedCollectionModel.js +19 -0
- package/dist/schema/LinkedData.d.ts +44 -0
- package/dist/schema/LinkedData.js +288 -0
- package/dist/schema/LinkedPageModel.d.ts +11 -0
- package/dist/schema/LinkedPageModel.js +26 -0
- package/dist/schema/Optional.d.ts +23 -0
- package/dist/schema/Optional.js +34 -0
- package/dist/schema/Page.d.ts +299 -0
- package/dist/schema/Page.js +244 -0
- package/dist/schema/PageModel.d.ts +58 -0
- package/dist/schema/PageModel.js +881 -0
- package/dist/schema/PageQuery.d.ts +60 -0
- package/dist/schema/PageQuery.js +116 -0
- package/dist/schema/PageRoute.d.ts +7 -0
- package/dist/schema/PageRoute.js +48 -0
- package/dist/schema/PageSnapshot.d.ts +11 -0
- package/dist/schema/PageSnapshot.js +12 -0
- package/dist/schema/Section.d.ts +71 -0
- package/dist/schema/Section.js +35 -0
- package/dist/schema/Seo.d.ts +13 -0
- package/dist/schema/Seo.js +25 -0
- package/dist/schema/Site.d.ts +40 -0
- package/dist/schema/Site.js +87 -0
- package/dist/schema/SiteModel.d.ts +5 -0
- package/dist/schema/SiteModel.js +10 -0
- package/dist/schema/Tag.d.ts +28 -0
- package/dist/schema/Tag.js +59 -0
- package/dist/schema/TagGroup.d.ts +26 -0
- package/dist/schema/TagGroup.js +64 -0
- package/dist/schema/field/Field.d.ts +179 -0
- package/dist/schema/field/Field.js +309 -0
- package/dist/schema/field/base/AssetField.d.ts +148 -0
- package/dist/schema/field/base/AssetField.js +206 -0
- package/dist/schema/field/base/BooleanField.d.ts +21 -0
- package/dist/schema/field/base/BooleanField.js +38 -0
- package/dist/schema/field/base/CollectionField.d.ts +34 -0
- package/dist/schema/field/base/CollectionField.js +85 -0
- package/dist/schema/field/base/DateField.d.ts +21 -0
- package/dist/schema/field/base/DateField.js +37 -0
- package/dist/schema/field/base/DynamicPagesField.d.ts +36 -0
- package/dist/schema/field/base/DynamicPagesField.js +50 -0
- package/dist/schema/field/base/EmbeddedVideoField.d.ts +45 -0
- package/dist/schema/field/base/EmbeddedVideoField.js +176 -0
- package/dist/schema/field/base/EnumField.d.ts +40 -0
- package/dist/schema/field/base/EnumField.js +131 -0
- package/dist/schema/field/base/FormField.d.ts +25 -0
- package/dist/schema/field/base/FormField.js +48 -0
- package/dist/schema/field/base/LinkField.d.ts +103 -0
- package/dist/schema/field/base/LinkField.js +201 -0
- package/dist/schema/field/base/PageField.d.ts +46 -0
- package/dist/schema/field/base/PageField.js +83 -0
- package/dist/schema/field/base/RichTextField.d.ts +71 -0
- package/dist/schema/field/base/RichTextField.js +196 -0
- package/dist/schema/field/base/TextField.d.ts +33 -0
- package/dist/schema/field/base/TextField.js +86 -0
- package/dist/schema/field/base/TimestampField.d.ts +25 -0
- package/dist/schema/field/base/TimestampField.js +41 -0
- package/dist/schema/field/base/index.d.ts +13 -0
- package/dist/schema/field/base/index.js +29 -0
- package/dist/schema/field/composite/ListField.d.ts +47 -0
- package/dist/schema/field/composite/ListField.js +107 -0
- package/dist/schema/field/composite/ObjectField.d.ts +56 -0
- package/dist/schema/field/composite/ObjectField.js +19 -0
- package/dist/schema/field/composite/index.d.ts +2 -0
- package/dist/schema/field/composite/index.js +18 -0
- package/dist/schema/field/index.d.ts +3 -0
- package/dist/schema/field/index.js +19 -0
- package/dist/schema/index.d.ts +25 -0
- package/dist/schema/index.js +41 -0
- package/dist/services/EventBus.d.ts +17 -0
- package/dist/services/EventBus.js +37 -0
- package/dist/services/humanVerification/IHumanVerification.d.ts +8 -0
- package/dist/services/humanVerification/IHumanVerification.js +2 -0
- package/dist/services/humanVerification/index.d.ts +1 -0
- package/dist/services/humanVerification/index.js +17 -0
- package/dist/services/index.d.ts +3 -0
- package/dist/services/index.js +19 -0
- package/dist/services/leadGen/Contact.d.ts +40 -0
- package/dist/services/leadGen/Contact.js +38 -0
- package/dist/services/leadGen/ILeadGen.d.ts +16 -0
- package/dist/services/leadGen/ILeadGen.js +2 -0
- package/dist/services/leadGen/index.d.ts +2 -0
- package/dist/services/leadGen/index.js +18 -0
- package/dist/types/BoxedValue.d.ts +3 -0
- package/dist/types/BoxedValue.js +2 -0
- package/dist/types/Callback.d.ts +9 -0
- package/dist/types/Callback.js +2 -0
- package/dist/types/DateString.d.ts +35 -0
- package/dist/types/DateString.js +172 -0
- package/dist/types/FilterConditionally.d.ts +3 -0
- package/dist/types/FilterConditionally.js +2 -0
- package/dist/types/MaybeConditionalValue.d.ts +8 -0
- package/dist/types/MaybeConditionalValue.js +12 -0
- package/dist/types/Ordinal.d.ts +17 -0
- package/dist/types/Ordinal.js +38 -0
- package/dist/types/OverridableStringUnion.d.ts +2 -0
- package/dist/types/OverridableStringUnion.js +2 -0
- package/dist/types/PartialBy.d.ts +1 -0
- package/dist/types/PartialBy.js +2 -0
- package/dist/types/PickData.d.ts +6 -0
- package/dist/types/PickData.js +2 -0
- package/dist/types/Provider.d.ts +4 -0
- package/dist/types/Provider.js +2 -0
- package/dist/types/RequiredBy.d.ts +1 -0
- package/dist/types/RequiredBy.js +2 -0
- package/dist/types/Result.d.ts +16 -0
- package/dist/types/Result.js +2 -0
- package/dist/types/Timestamp.d.ts +17 -0
- package/dist/types/Timestamp.js +57 -0
- package/dist/types/Transform.d.ts +4 -0
- package/dist/types/Transform.js +2 -0
- package/dist/types/index.d.ts +14 -0
- package/dist/types/index.js +30 -0
- package/dist/ui/Accessible.d.ts +5 -0
- package/dist/ui/Accessible.js +15 -0
- package/dist/ui/BlockThemes.d.ts +19 -0
- package/dist/ui/BlockThemes.js +29 -0
- package/dist/ui/ColorMode.d.ts +12 -0
- package/dist/ui/ColorMode.js +49 -0
- package/dist/ui/File.d.ts +43 -0
- package/dist/ui/File.js +55 -0
- package/dist/ui/FileType.d.ts +8 -0
- package/dist/ui/FileType.js +48 -0
- package/dist/ui/ImageSource.d.ts +12 -0
- package/dist/ui/ImageSource.js +48 -0
- package/dist/ui/MimeType.d.ts +28 -0
- package/dist/ui/MimeType.js +110 -0
- package/dist/ui/Placement.d.ts +21 -0
- package/dist/ui/Placement.js +135 -0
- package/dist/ui/Position.d.ts +6 -0
- package/dist/ui/Position.js +42 -0
- package/dist/ui/Selector.d.ts +6 -0
- package/dist/ui/Selector.js +23 -0
- package/dist/ui/SemanticColor.d.ts +8 -0
- package/dist/ui/SemanticColor.js +237 -0
- package/dist/ui/Visual.d.ts +24 -0
- package/dist/ui/Visual.js +66 -0
- package/dist/ui/block-layout/BlockLayout.d.ts +99 -0
- package/dist/ui/block-layout/BlockLayout.js +286 -0
- package/dist/ui/block-layout/index.d.ts +1 -0
- package/dist/ui/block-layout/index.js +17 -0
- package/dist/ui/browser/BlurHasher.d.ts +13 -0
- package/dist/ui/browser/BlurHasher.js +76 -0
- package/dist/ui/browser/Browser.d.ts +107 -0
- package/dist/ui/browser/Browser.js +313 -0
- package/dist/ui/browser/ImageProxy.d.ts +30 -0
- package/dist/ui/browser/ImageProxy.js +132 -0
- package/dist/ui/browser/InputEvent.d.ts +13 -0
- package/dist/ui/browser/InputEvent.js +2 -0
- package/dist/ui/browser/SVGProxy.d.ts +9 -0
- package/dist/ui/browser/SVGProxy.js +59 -0
- package/dist/ui/browser/VideoProxy.d.ts +42 -0
- package/dist/ui/browser/VideoProxy.js +235 -0
- package/dist/ui/browser/index.d.ts +6 -0
- package/dist/ui/browser/index.js +22 -0
- package/dist/ui/fields/Field.d.ts +80 -0
- package/dist/ui/fields/Field.js +298 -0
- package/dist/ui/fields/FieldList.d.ts +80 -0
- package/dist/ui/fields/FieldList.js +421 -0
- package/dist/ui/fields/FieldListValidator.d.ts +9 -0
- package/dist/ui/fields/FieldListValidator.js +37 -0
- package/dist/ui/fields/FieldModel.d.ts +15 -0
- package/dist/ui/fields/FieldModel.js +28 -0
- package/dist/ui/fields/FieldSerializer.d.ts +13 -0
- package/dist/ui/fields/FieldSerializer.js +71 -0
- package/dist/ui/fields/FieldValidator.d.ts +19 -0
- package/dist/ui/fields/FieldValidator.js +98 -0
- package/dist/ui/fields/ObjectField.d.ts +75 -0
- package/dist/ui/fields/ObjectField.js +288 -0
- package/dist/ui/fields/errors.json +44 -0
- package/dist/ui/fields/index.d.ts +7 -0
- package/dist/ui/fields/index.js +23 -0
- package/dist/ui/fields/validators/AssetValidator.d.ts +9 -0
- package/dist/ui/fields/validators/AssetValidator.js +25 -0
- package/dist/ui/fields/validators/DateValidator.d.ts +9 -0
- package/dist/ui/fields/validators/DateValidator.js +41 -0
- package/dist/ui/fields/validators/EnumValidator.d.ts +10 -0
- package/dist/ui/fields/validators/EnumValidator.js +77 -0
- package/dist/ui/fields/validators/GenericValidator.d.ts +6 -0
- package/dist/ui/fields/validators/GenericValidator.js +22 -0
- package/dist/ui/fields/validators/LinkValidator.d.ts +9 -0
- package/dist/ui/fields/validators/LinkValidator.js +146 -0
- package/dist/ui/fields/validators/RichTextValidator.d.ts +6 -0
- package/dist/ui/fields/validators/RichTextValidator.js +35 -0
- package/dist/ui/fields/validators/TextValidator.d.ts +10 -0
- package/dist/ui/fields/validators/TextValidator.js +138 -0
- package/dist/ui/fields/validators/TimestampValidator.d.ts +9 -0
- package/dist/ui/fields/validators/TimestampValidator.js +41 -0
- package/dist/ui/fields/validators/ValidatorHelper.d.ts +23 -0
- package/dist/ui/fields/validators/ValidatorHelper.js +55 -0
- package/dist/ui/fields/validators/index.d.ts +8 -0
- package/dist/ui/fields/validators/index.js +24 -0
- package/dist/ui/geometry/AspectRatio.d.ts +27 -0
- package/dist/ui/geometry/AspectRatio.js +77 -0
- package/dist/ui/geometry/Bounds.d.ts +4 -0
- package/dist/ui/geometry/Bounds.js +11 -0
- package/dist/ui/geometry/Frame.d.ts +3 -0
- package/dist/ui/geometry/Frame.js +2 -0
- package/dist/ui/geometry/Insets.d.ts +14 -0
- package/dist/ui/geometry/Insets.js +14 -0
- package/dist/ui/geometry/PixelSize.d.ts +1 -0
- package/dist/ui/geometry/PixelSize.js +2 -0
- package/dist/ui/geometry/Point.d.ts +7 -0
- package/dist/ui/geometry/Point.js +15 -0
- package/dist/ui/geometry/Rect.d.ts +19 -0
- package/dist/ui/geometry/Rect.js +68 -0
- package/dist/ui/geometry/ScreenSize.d.ts +1 -0
- package/dist/ui/geometry/ScreenSize.js +2 -0
- package/dist/ui/geometry/Size.d.ts +7 -0
- package/dist/ui/geometry/Size.js +9 -0
- package/dist/ui/geometry/index.d.ts +9 -0
- package/dist/ui/geometry/index.js +25 -0
- package/dist/ui/index.d.ts +18 -0
- package/dist/ui/index.js +34 -0
- package/dist/ui/responsive/Breakpoint.d.ts +8 -0
- package/dist/ui/responsive/Breakpoint.js +24 -0
- package/dist/ui/responsive/BreakpointObserver.d.ts +16 -0
- package/dist/ui/responsive/BreakpointObserver.js +104 -0
- package/dist/ui/responsive/Breakpoints.d.ts +5 -0
- package/dist/ui/responsive/Breakpoints.js +15 -0
- package/dist/ui/responsive/ResponsiveValue.d.ts +7 -0
- package/dist/ui/responsive/ResponsiveValue.js +26 -0
- package/dist/ui/responsive/index.d.ts +4 -0
- package/dist/ui/responsive/index.js +20 -0
- package/dist/ui/richtext/LexicalUtils.d.ts +31 -0
- package/dist/ui/richtext/LexicalUtils.js +314 -0
- package/dist/ui/richtext/StyledTextNode.d.ts +33 -0
- package/dist/ui/richtext/StyledTextNode.js +101 -0
- package/dist/ui/richtext/index.d.ts +2 -0
- package/dist/ui/richtext/index.js +18 -0
- package/dist/utils/ArrayUtils.d.ts +17 -0
- package/dist/utils/ArrayUtils.js +66 -0
- package/dist/utils/ByteSize.d.ts +19 -0
- package/dist/utils/ByteSize.js +33 -0
- package/dist/utils/DateUtils.d.ts +15 -0
- package/dist/utils/DateUtils.js +100 -0
- package/dist/utils/Deferral.d.ts +28 -0
- package/dist/utils/Deferral.js +107 -0
- package/dist/utils/Duration.d.ts +7 -0
- package/dist/utils/Duration.js +35 -0
- package/dist/utils/Fn.d.ts +14 -0
- package/dist/utils/Fn.js +52 -0
- package/dist/utils/ObjectUtils.d.ts +89 -0
- package/dist/utils/ObjectUtils.js +159 -0
- package/dist/utils/Random.d.ts +15 -0
- package/dist/utils/Random.js +72 -0
- package/dist/utils/StringUtils.d.ts +10 -0
- package/dist/utils/StringUtils.js +51 -0
- package/dist/utils/UrlUtils.d.ts +22 -0
- package/dist/utils/UrlUtils.js +119 -0
- package/dist/utils/Value.d.ts +23 -0
- package/dist/utils/Value.js +122 -0
- package/dist/utils/index.d.ts +12 -0
- package/dist/utils/index.js +28 -0
- package/dist/utils/isDefined.d.ts +1 -0
- package/dist/utils/isDefined.js +6 -0
- package/package.json +64 -0
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { type Page } from '../schema/Page';
|
|
2
|
+
import { PartialBy, Timestamp } from '../types';
|
|
3
|
+
import { BrandConfig } from './BrandConfig';
|
|
4
|
+
import { UIConfig } from './UIConfig';
|
|
5
|
+
export type AppConfig<TBrand extends string = string, TBrandType extends string = string, TRegion extends string = string> = {
|
|
6
|
+
private: boolean;
|
|
7
|
+
baseUrl: string;
|
|
8
|
+
timezone: Timestamp.Timezone;
|
|
9
|
+
/**
|
|
10
|
+
* Determines the types of pages that will be fetched when pulling content (either `published` or
|
|
11
|
+
* `draft` - where `published` is the default).
|
|
12
|
+
*/
|
|
13
|
+
version: Exclude<Page.State, 'unpublished'>;
|
|
14
|
+
brands: Record<TBrand, BrandConfig<TBrandType, TRegion>>;
|
|
15
|
+
recaptcha: AppConfig.RecaptchaConfig;
|
|
16
|
+
sso: AppConfig.SsoConfig;
|
|
17
|
+
ui: UIConfig;
|
|
18
|
+
accessible: boolean;
|
|
19
|
+
nativeYoutube?: boolean;
|
|
20
|
+
};
|
|
21
|
+
export declare namespace AppConfig {
|
|
22
|
+
type RecaptchaConfig = {
|
|
23
|
+
siteKey: string;
|
|
24
|
+
};
|
|
25
|
+
type SsoConfig = {
|
|
26
|
+
mode: SsoConfig.Mode;
|
|
27
|
+
googleClientId: string;
|
|
28
|
+
};
|
|
29
|
+
namespace SsoConfig {
|
|
30
|
+
type Mode = 'email' | 'google';
|
|
31
|
+
namespace Mode {
|
|
32
|
+
function coerce(value: string | undefined, fallback: Mode): SsoConfig.Mode;
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
function get<TBrand extends string = string, TBrandType extends string = string, TRegion extends string = string>(): Readonly<AppConfig<TBrand, TBrandType, TRegion>>;
|
|
36
|
+
function set<TBrand extends string = string, TBrandType extends string = string, TRegion extends string = string>(value: PartialBy<AppConfig<TBrand, TBrandType, TRegion>, 'private' | 'accessible'>): void;
|
|
37
|
+
function brand<TBrand extends string = string>(): TBrand;
|
|
38
|
+
function brandConfig<TBrand extends string = string, TBrandType extends string = string, TRegion extends string = string>(): Readonly<BrandConfig<TBrandType, TRegion>>;
|
|
39
|
+
function ssoConfig(): SsoConfig;
|
|
40
|
+
function uiConfig(): UIConfig;
|
|
41
|
+
}
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.AppConfig = void 0;
|
|
4
|
+
const errors_1 = require("../errors");
|
|
5
|
+
// extension
|
|
6
|
+
var AppConfig;
|
|
7
|
+
(function (AppConfig) {
|
|
8
|
+
let SsoConfig;
|
|
9
|
+
(function (SsoConfig) {
|
|
10
|
+
let Mode;
|
|
11
|
+
(function (Mode) {
|
|
12
|
+
// helpers
|
|
13
|
+
function coerce(value, fallback) {
|
|
14
|
+
var _a;
|
|
15
|
+
const normalizedValue = (_a = value === null || value === void 0 ? void 0 : value.trim().toLowerCase()) !== null && _a !== void 0 ? _a : '';
|
|
16
|
+
switch (normalizedValue) {
|
|
17
|
+
case 'email':
|
|
18
|
+
case 'google':
|
|
19
|
+
return normalizedValue;
|
|
20
|
+
default:
|
|
21
|
+
return fallback;
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
Mode.coerce = coerce;
|
|
25
|
+
})(Mode = SsoConfig.Mode || (SsoConfig.Mode = {}));
|
|
26
|
+
})(SsoConfig = AppConfig.SsoConfig || (AppConfig.SsoConfig = {}));
|
|
27
|
+
// methods
|
|
28
|
+
function get() {
|
|
29
|
+
// throw if config isn't bound
|
|
30
|
+
if (!config) {
|
|
31
|
+
throw new errors_1.IllegalStateError('Attempt to access AppConfig before first call to AppConfig.set()');
|
|
32
|
+
}
|
|
33
|
+
return config;
|
|
34
|
+
}
|
|
35
|
+
AppConfig.get = get;
|
|
36
|
+
function set(value) {
|
|
37
|
+
const defaults = {
|
|
38
|
+
private: false,
|
|
39
|
+
version: 'published',
|
|
40
|
+
accessible: true
|
|
41
|
+
};
|
|
42
|
+
config = Object.assign(Object.assign(Object.assign({}, defaults), (config !== null && config !== void 0 ? config : {})), value);
|
|
43
|
+
}
|
|
44
|
+
AppConfig.set = set;
|
|
45
|
+
function brand() {
|
|
46
|
+
// throw if the brand isn't defined
|
|
47
|
+
const brand = process.env.FUNNEL_BRAND || process.env.NEXT_PUBLIC_BRAND;
|
|
48
|
+
if (!brand) {
|
|
49
|
+
throw new errors_1.IllegalStateError('Unable to resolve $FUNNEL_BRAND');
|
|
50
|
+
}
|
|
51
|
+
// return brand
|
|
52
|
+
return brand;
|
|
53
|
+
}
|
|
54
|
+
AppConfig.brand = brand;
|
|
55
|
+
function brandConfig() {
|
|
56
|
+
// throw if brands are missing
|
|
57
|
+
const { brands } = get();
|
|
58
|
+
if (!brands) {
|
|
59
|
+
throw new errors_1.IllegalStateError('No brands defined in AppConfig');
|
|
60
|
+
}
|
|
61
|
+
// throw if config is missing
|
|
62
|
+
const brandId = brand();
|
|
63
|
+
const brandConfig = brands[brandId];
|
|
64
|
+
if (!brandConfig) {
|
|
65
|
+
throw new errors_1.IllegalStateError(`No BrandConfig set for brand "${brandId}"`);
|
|
66
|
+
}
|
|
67
|
+
// return config
|
|
68
|
+
return brandConfig;
|
|
69
|
+
}
|
|
70
|
+
AppConfig.brandConfig = brandConfig;
|
|
71
|
+
function ssoConfig() {
|
|
72
|
+
// get config
|
|
73
|
+
const { sso } = get();
|
|
74
|
+
if (!sso) {
|
|
75
|
+
throw new errors_1.IllegalStateError('No SsoConfig is defined for this site');
|
|
76
|
+
}
|
|
77
|
+
// return config
|
|
78
|
+
return sso;
|
|
79
|
+
}
|
|
80
|
+
AppConfig.ssoConfig = ssoConfig;
|
|
81
|
+
function uiConfig() {
|
|
82
|
+
// get config
|
|
83
|
+
const { ui } = get();
|
|
84
|
+
if (!ui) {
|
|
85
|
+
throw new errors_1.IllegalStateError('No UIConfig is defined for this site');
|
|
86
|
+
}
|
|
87
|
+
// return config
|
|
88
|
+
return ui;
|
|
89
|
+
}
|
|
90
|
+
AppConfig.uiConfig = uiConfig;
|
|
91
|
+
})(AppConfig || (exports.AppConfig = AppConfig = {}));
|
|
92
|
+
// global context
|
|
93
|
+
let config = undefined;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { FeaturesConfig } from './FeaturesConfig';
|
|
2
|
+
import { RegionsConfig } from './RegionsConfig';
|
|
3
|
+
export type BrandConfig<TBrandType extends string = string, TRegion extends string = string> = {
|
|
4
|
+
type: TBrandType;
|
|
5
|
+
name: string;
|
|
6
|
+
regionalization: RegionsConfig<TRegion>;
|
|
7
|
+
features?: FeaturesConfig;
|
|
8
|
+
};
|
|
9
|
+
export declare namespace BrandConfig {
|
|
10
|
+
type WithId<TBrandType extends string = string, TRegion extends string = string> = BrandConfig<TBrandType, TRegion> & {
|
|
11
|
+
id: string;
|
|
12
|
+
};
|
|
13
|
+
}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { Language, Locale } from '../regionalization';
|
|
2
|
+
export type RegionsConfig<TRegion extends string = string> = {
|
|
3
|
+
regions: Record<TRegion, RegionsConfig.RegionConfig>;
|
|
4
|
+
fallback: TRegion;
|
|
5
|
+
urlTruncation: RegionsConfig.UrlTruncation;
|
|
6
|
+
mergedRoutes?: boolean;
|
|
7
|
+
};
|
|
8
|
+
export declare namespace RegionsConfig {
|
|
9
|
+
type RegionConfig = {
|
|
10
|
+
name: string;
|
|
11
|
+
languages: Language[];
|
|
12
|
+
defaultLanguage?: Language;
|
|
13
|
+
};
|
|
14
|
+
namespace RegionConfig {
|
|
15
|
+
type WithId<TRegion extends string = string> = RegionConfig & {
|
|
16
|
+
id: TRegion;
|
|
17
|
+
};
|
|
18
|
+
}
|
|
19
|
+
type UrlTruncation = 'none' | 'full' | 'partial';
|
|
20
|
+
type Type = 'language-only' | 'region-only' | 'locale-composite' | 'locale-split';
|
|
21
|
+
function getRegions<TRegion extends string = string>(config: RegionsConfig<TRegion>): RegionConfig.WithId<TRegion>[];
|
|
22
|
+
function getType(regionalization: RegionsConfig): Type;
|
|
23
|
+
function tryParse<TRegion extends string = string>(regionalization: RegionsConfig, value: string | undefined): TRegion | undefined;
|
|
24
|
+
function parse<TRegion extends string = string>(regionalization: RegionsConfig, value: string | undefined): TRegion;
|
|
25
|
+
function getRegionConfig<TRegion extends string = string>(regionalization: RegionsConfig, region: TRegion): RegionConfig;
|
|
26
|
+
function getLocales<TRegion extends string = string>(regionalization: RegionsConfig): [TRegion, Language][];
|
|
27
|
+
function getLanguages(regionalization: RegionsConfig): Language[];
|
|
28
|
+
/**
|
|
29
|
+
* Given a config for all regions, return the default region. If the default region is set through cookies, we use
|
|
30
|
+
* that. Otherwise, we use the fallback.
|
|
31
|
+
*/
|
|
32
|
+
function getDefaultRegion(regionalization: RegionsConfig, inferredLocale?: Partial<Locale>): string;
|
|
33
|
+
/**
|
|
34
|
+
* Given a config for a specific region, return the default language for that region. If the default language
|
|
35
|
+
* is set through cookies, we use hat. Otherwise, if set we use the default language for that region. Otherwise,
|
|
36
|
+
* we use the first language available.
|
|
37
|
+
*/
|
|
38
|
+
function getDefaultLanguageForRegion(config: RegionConfig, inferredLocale: Partial<Locale>): Language;
|
|
39
|
+
/**
|
|
40
|
+
* Given the config for all regions, return the default language for the default region.
|
|
41
|
+
*/
|
|
42
|
+
function getDefaultLanguage(regionalization: RegionsConfig, inferredLocale?: Partial<Locale>): Language;
|
|
43
|
+
}
|
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.RegionsConfig = void 0;
|
|
4
|
+
const errors_1 = require("../errors");
|
|
5
|
+
const utils_1 = require("../utils");
|
|
6
|
+
// extension
|
|
7
|
+
var RegionsConfig;
|
|
8
|
+
(function (RegionsConfig) {
|
|
9
|
+
// methods
|
|
10
|
+
function getRegions(config) {
|
|
11
|
+
return Object.entries(config.regions).map(([id, config]) => (Object.assign({ id: id }, config)));
|
|
12
|
+
}
|
|
13
|
+
RegionsConfig.getRegions = getRegions;
|
|
14
|
+
function getType(regionalization) {
|
|
15
|
+
const regions = Object.entries(regionalization.regions);
|
|
16
|
+
if (regions.length === 0) {
|
|
17
|
+
throw new errors_1.IllegalStateError('RegionsConfig must have at least one region');
|
|
18
|
+
}
|
|
19
|
+
// handle case where there is just a single region (languages only)
|
|
20
|
+
if (regions.length === 1) {
|
|
21
|
+
return 'language-only';
|
|
22
|
+
}
|
|
23
|
+
// or, route by regions only if there's just a single language
|
|
24
|
+
const languages = RegionsConfig.getLanguages(regionalization);
|
|
25
|
+
if (languages.length === 1) {
|
|
26
|
+
return 'region-only';
|
|
27
|
+
}
|
|
28
|
+
// or create composite local if specified
|
|
29
|
+
else if (regionalization.mergedRoutes) {
|
|
30
|
+
return 'locale-composite';
|
|
31
|
+
}
|
|
32
|
+
// otherwise, use split locale
|
|
33
|
+
else {
|
|
34
|
+
return 'locale-split';
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
RegionsConfig.getType = getType;
|
|
38
|
+
function tryParse(regionalization, value) {
|
|
39
|
+
// skip if there's no value
|
|
40
|
+
if (!value) {
|
|
41
|
+
return undefined;
|
|
42
|
+
}
|
|
43
|
+
// search for match
|
|
44
|
+
const normalizedValue = value.trim().toLowerCase();
|
|
45
|
+
return Object.keys(regionalization.regions)
|
|
46
|
+
.find(region => region.toLowerCase() === normalizedValue);
|
|
47
|
+
}
|
|
48
|
+
RegionsConfig.tryParse = tryParse;
|
|
49
|
+
function parse(regionalization, value) {
|
|
50
|
+
// throw if the value can't be parsed
|
|
51
|
+
const region = tryParse(regionalization, value);
|
|
52
|
+
if (!region) {
|
|
53
|
+
throw new errors_1.ArgumentError(`Invalid region: ${region}`, 'region');
|
|
54
|
+
}
|
|
55
|
+
// return region
|
|
56
|
+
return region;
|
|
57
|
+
}
|
|
58
|
+
RegionsConfig.parse = parse;
|
|
59
|
+
function getRegionConfig(regionalization, region) {
|
|
60
|
+
// get region config (or throw)
|
|
61
|
+
const config = regionalization.regions[region];
|
|
62
|
+
if (!config) {
|
|
63
|
+
throw new errors_1.InvalidOperationError(`Attempt to use unconfigured region: ${region}`);
|
|
64
|
+
}
|
|
65
|
+
// return config
|
|
66
|
+
return config;
|
|
67
|
+
}
|
|
68
|
+
RegionsConfig.getRegionConfig = getRegionConfig;
|
|
69
|
+
function getLocales(regionalization) {
|
|
70
|
+
return Object.entries(regionalization.regions)
|
|
71
|
+
.flatMap(([region, config]) => config === null || config === void 0 ? void 0 : config.languages.map(language => ([region, language])))
|
|
72
|
+
.filter(utils_1.Value.isDefined);
|
|
73
|
+
}
|
|
74
|
+
RegionsConfig.getLocales = getLocales;
|
|
75
|
+
function getLanguages(regionalization) {
|
|
76
|
+
return Object.values(regionalization.regions).reduce((languages, regionConfig) => {
|
|
77
|
+
// add missing languages
|
|
78
|
+
if (regionConfig) {
|
|
79
|
+
languages.push(...regionConfig.languages.filter((l) => !languages.includes(l)));
|
|
80
|
+
}
|
|
81
|
+
// keep reducing
|
|
82
|
+
return languages;
|
|
83
|
+
}, []);
|
|
84
|
+
}
|
|
85
|
+
RegionsConfig.getLanguages = getLanguages;
|
|
86
|
+
/**
|
|
87
|
+
* Given a config for all regions, return the default region. If the default region is set through cookies, we use
|
|
88
|
+
* that. Otherwise, we use the fallback.
|
|
89
|
+
*/
|
|
90
|
+
function getDefaultRegion(regionalization, inferredLocale = {}) {
|
|
91
|
+
var _a;
|
|
92
|
+
return (_a = inferredLocale.region) !== null && _a !== void 0 ? _a : regionalization.fallback;
|
|
93
|
+
}
|
|
94
|
+
RegionsConfig.getDefaultRegion = getDefaultRegion;
|
|
95
|
+
/**
|
|
96
|
+
* Given a config for a specific region, return the default language for that region. If the default language
|
|
97
|
+
* is set through cookies, we use hat. Otherwise, if set we use the default language for that region. Otherwise,
|
|
98
|
+
* we use the first language available.
|
|
99
|
+
*/
|
|
100
|
+
function getDefaultLanguageForRegion(config, inferredLocale) {
|
|
101
|
+
var _a, _b;
|
|
102
|
+
return (_b = (_a = inferredLocale.language) !== null && _a !== void 0 ? _a : config.defaultLanguage) !== null && _b !== void 0 ? _b : config.languages[0];
|
|
103
|
+
}
|
|
104
|
+
RegionsConfig.getDefaultLanguageForRegion = getDefaultLanguageForRegion;
|
|
105
|
+
/**
|
|
106
|
+
* Given the config for all regions, return the default language for the default region.
|
|
107
|
+
*/
|
|
108
|
+
function getDefaultLanguage(regionalization, inferredLocale = {}) {
|
|
109
|
+
const config = getRegionConfig(regionalization, regionalization.fallback);
|
|
110
|
+
return getDefaultLanguageForRegion(config, inferredLocale);
|
|
111
|
+
}
|
|
112
|
+
RegionsConfig.getDefaultLanguage = getDefaultLanguage;
|
|
113
|
+
})(RegionsConfig || (exports.RegionsConfig = RegionsConfig = {}));
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./AppConfig"), exports);
|
|
18
|
+
__exportStar(require("./BrandConfig"), exports);
|
|
19
|
+
__exportStar(require("./RegionsConfig"), exports);
|
|
20
|
+
__exportStar(require("./UIConfig"), exports);
|
|
21
|
+
__exportStar(require("./FeaturesConfig"), exports);
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
export type ConsentCategory = 'necessary' | 'functionality' | 'security' | 'analytics' | 'advertisement';
|
|
2
|
+
export declare namespace ConsentCategory {
|
|
3
|
+
const values: ReadonlyArray<ConsentCategory>;
|
|
4
|
+
function filter(value: any): value is ConsentCategory;
|
|
5
|
+
type Choice = {
|
|
6
|
+
category: ConsentCategory;
|
|
7
|
+
accepted: boolean;
|
|
8
|
+
};
|
|
9
|
+
namespace Choice {
|
|
10
|
+
function filter(value: any): value is Choice;
|
|
11
|
+
}
|
|
12
|
+
}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ConsentCategory = void 0;
|
|
4
|
+
// extension
|
|
5
|
+
var ConsentCategory;
|
|
6
|
+
(function (ConsentCategory) {
|
|
7
|
+
// values
|
|
8
|
+
ConsentCategory.values = [
|
|
9
|
+
'necessary', 'functionality', 'security', 'analytics', 'advertisement'
|
|
10
|
+
];
|
|
11
|
+
// helpers
|
|
12
|
+
function filter(value) {
|
|
13
|
+
return !!value
|
|
14
|
+
&& typeof value === 'string'
|
|
15
|
+
&& ConsentCategory.values.includes(value);
|
|
16
|
+
}
|
|
17
|
+
ConsentCategory.filter = filter;
|
|
18
|
+
let Choice;
|
|
19
|
+
(function (Choice) {
|
|
20
|
+
function filter(value) {
|
|
21
|
+
return !!value
|
|
22
|
+
&& typeof value === 'object'
|
|
23
|
+
&& 'category' in value && ConsentCategory.filter(value.category)
|
|
24
|
+
&& 'accepted' in value && typeof value.accepted === 'boolean';
|
|
25
|
+
}
|
|
26
|
+
Choice.filter = filter;
|
|
27
|
+
})(Choice = ConsentCategory.Choice || (ConsentCategory.Choice = {}));
|
|
28
|
+
})(ConsentCategory || (exports.ConsentCategory = ConsentCategory = {}));
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { ConsentCategory } from './ConsentCategory';
|
|
2
|
+
export type ConsentService = 'functionality_storage' | 'personalization_storage' | 'security_storage' | 'analytics_storage' | 'ad_storage' | 'ad_user_data' | 'ad_personalization';
|
|
3
|
+
export declare namespace ConsentService {
|
|
4
|
+
const groupedValues: Readonly<Record<ConsentCategory, ReadonlyArray<ConsentService>>>;
|
|
5
|
+
const values: ReadonlyArray<ConsentService>;
|
|
6
|
+
function filter(value: any): value is ConsentService;
|
|
7
|
+
type Choice = {
|
|
8
|
+
category: ConsentCategory;
|
|
9
|
+
service: ConsentService;
|
|
10
|
+
accepted: boolean;
|
|
11
|
+
};
|
|
12
|
+
namespace Choice {
|
|
13
|
+
function filter(value: any): value is Choice;
|
|
14
|
+
}
|
|
15
|
+
}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ConsentService = void 0;
|
|
4
|
+
const ConsentCategory_1 = require("./ConsentCategory");
|
|
5
|
+
// extension
|
|
6
|
+
var ConsentService;
|
|
7
|
+
(function (ConsentService) {
|
|
8
|
+
// values
|
|
9
|
+
ConsentService.groupedValues = {
|
|
10
|
+
necessary: [],
|
|
11
|
+
functionality: ['functionality_storage', 'personalization_storage'],
|
|
12
|
+
security: ['security_storage'],
|
|
13
|
+
analytics: ['analytics_storage'],
|
|
14
|
+
advertisement: ['ad_storage', 'ad_user_data', 'ad_personalization']
|
|
15
|
+
};
|
|
16
|
+
ConsentService.values = [
|
|
17
|
+
'functionality_storage', 'personalization_storage',
|
|
18
|
+
'security_storage',
|
|
19
|
+
'analytics_storage',
|
|
20
|
+
'ad_storage', 'ad_user_data', 'ad_personalization'
|
|
21
|
+
];
|
|
22
|
+
// helpers
|
|
23
|
+
function filter(value) {
|
|
24
|
+
return !!value
|
|
25
|
+
&& typeof value === 'string'
|
|
26
|
+
&& ConsentService.values.includes(value);
|
|
27
|
+
}
|
|
28
|
+
ConsentService.filter = filter;
|
|
29
|
+
let Choice;
|
|
30
|
+
(function (Choice) {
|
|
31
|
+
function filter(value) {
|
|
32
|
+
return ConsentCategory_1.ConsentCategory.Choice.filter(value)
|
|
33
|
+
&& 'service' in value && ConsentService.filter(value.service);
|
|
34
|
+
}
|
|
35
|
+
Choice.filter = filter;
|
|
36
|
+
})(Choice = ConsentService.Choice || (ConsentService.Choice = {}));
|
|
37
|
+
})(ConsentService || (exports.ConsentService = ConsentService = {}));
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./ConsentCategory"), exports);
|
|
18
|
+
__exportStar(require("./ConsentService"), exports);
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { IsometricErrorModule } from './IsometricErrorModule';
|
|
2
|
+
import { SerializedIsometricError } from './SerializedIsometricError';
|
|
3
|
+
export declare class IsometricError extends Error {
|
|
4
|
+
readonly moduleId: IsometricErrorModule.Id;
|
|
5
|
+
readonly cause?: Error | undefined;
|
|
6
|
+
constructor(args: IsometricError.ConstructorArgs);
|
|
7
|
+
serialize(): SerializedIsometricError;
|
|
8
|
+
}
|
|
9
|
+
export declare namespace IsometricError {
|
|
10
|
+
type ConstructorArgs = {
|
|
11
|
+
moduleId: IsometricErrorModule.Id;
|
|
12
|
+
message: string;
|
|
13
|
+
cause?: Error | undefined;
|
|
14
|
+
trace?: ((...args: any) => any) | undefined;
|
|
15
|
+
};
|
|
16
|
+
namespace ConstructorArgs {
|
|
17
|
+
type WithoutModuleId = Omit<ConstructorArgs, 'moduleId'>;
|
|
18
|
+
}
|
|
19
|
+
}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.IsometricError = void 0;
|
|
4
|
+
// class
|
|
5
|
+
class IsometricError extends Error {
|
|
6
|
+
constructor(args) {
|
|
7
|
+
// construct base
|
|
8
|
+
super(args.message);
|
|
9
|
+
// link prototype chain
|
|
10
|
+
Object.setPrototypeOf(this, new.target.prototype);
|
|
11
|
+
// bind properties
|
|
12
|
+
const object = this;
|
|
13
|
+
this.name = object.constructor.name;
|
|
14
|
+
this.moduleId = args.moduleId;
|
|
15
|
+
this.cause = args.cause;
|
|
16
|
+
// bind stack trace (if provided)
|
|
17
|
+
if (args.trace) {
|
|
18
|
+
Error.captureStackTrace(this, args.trace);
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
serialize() {
|
|
22
|
+
const { moduleId, name, message } = this;
|
|
23
|
+
return {
|
|
24
|
+
moduleId,
|
|
25
|
+
name,
|
|
26
|
+
message
|
|
27
|
+
};
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
exports.IsometricError = IsometricError;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { Tagged } from 'type-fest';
|
|
2
|
+
import { IsometricError } from './IsometricError';
|
|
3
|
+
import { SerializedIsometricError } from './SerializedIsometricError';
|
|
4
|
+
export interface IsometricErrorModule {
|
|
5
|
+
readonly id: IsometricErrorModule.Id;
|
|
6
|
+
deserialize(data: SerializedIsometricError): IsometricError | undefined;
|
|
7
|
+
}
|
|
8
|
+
export declare namespace IsometricErrorModule {
|
|
9
|
+
type Id = Tagged<string, 'nascent.IsometricErrorModule.Id'>;
|
|
10
|
+
type Constructor = new () => IsometricErrorModule;
|
|
11
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { Callback } from '../types';
|
|
2
|
+
import { IsometricError } from './IsometricError';
|
|
3
|
+
import { IsometricErrorModule } from './IsometricErrorModule';
|
|
4
|
+
export declare namespace IsometricErrorUtils {
|
|
5
|
+
function registerModule(ModuleClass: IsometricErrorModule.Constructor): void;
|
|
6
|
+
function coerceError(error: any): IsometricError;
|
|
7
|
+
function deserializeError(data: any): IsometricError | undefined;
|
|
8
|
+
function checkResponse(response: Response, onError?: Callback<IsometricError>): Promise<void>;
|
|
9
|
+
}
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.IsometricErrorUtils = void 0;
|
|
4
|
+
const Value_1 = require("../utils/Value");
|
|
5
|
+
const api_1 = require("./api");
|
|
6
|
+
const IsometricError_1 = require("./IsometricError");
|
|
7
|
+
const SerializedIsometricError_1 = require("./SerializedIsometricError");
|
|
8
|
+
// namespace
|
|
9
|
+
var IsometricErrorUtils;
|
|
10
|
+
(function (IsometricErrorUtils) {
|
|
11
|
+
// constants
|
|
12
|
+
const modules = new Map();
|
|
13
|
+
// methods
|
|
14
|
+
function registerModule(ModuleClass) {
|
|
15
|
+
const module = new ModuleClass();
|
|
16
|
+
modules.set(module.id, module);
|
|
17
|
+
}
|
|
18
|
+
IsometricErrorUtils.registerModule = registerModule;
|
|
19
|
+
function coerceError(error) {
|
|
20
|
+
// skip if already isometric
|
|
21
|
+
if (error instanceof IsometricError_1.IsometricError) {
|
|
22
|
+
return error;
|
|
23
|
+
}
|
|
24
|
+
// or wrap error
|
|
25
|
+
else if (error instanceof Error) {
|
|
26
|
+
return new api_1.ServerError(error.message);
|
|
27
|
+
}
|
|
28
|
+
// or create generic error
|
|
29
|
+
else {
|
|
30
|
+
return new api_1.ServerError();
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
IsometricErrorUtils.coerceError = coerceError;
|
|
34
|
+
function deserializeError(data) {
|
|
35
|
+
// skip if it's not isometric
|
|
36
|
+
if (!SerializedIsometricError_1.SerializedIsometricError.filter(data)) {
|
|
37
|
+
console.debug('[IsometricErrorUtils/deserialize] data is not an error', data);
|
|
38
|
+
return undefined;
|
|
39
|
+
}
|
|
40
|
+
// or skip if there's no registered module
|
|
41
|
+
const module = modules.get(data.moduleId);
|
|
42
|
+
if (!module) {
|
|
43
|
+
console.debug('[IsometricErrorUtils/deserialize] module not found', data.moduleId);
|
|
44
|
+
return undefined;
|
|
45
|
+
}
|
|
46
|
+
const error = module.deserialize(data);
|
|
47
|
+
console.debug('[IsometricErrorUtils/deserialize] parsed error', { module, error });
|
|
48
|
+
// deserialize
|
|
49
|
+
return error;
|
|
50
|
+
}
|
|
51
|
+
IsometricErrorUtils.deserializeError = deserializeError;
|
|
52
|
+
async function checkResponse(response, onError) {
|
|
53
|
+
var _a;
|
|
54
|
+
// skip if response is good
|
|
55
|
+
if (response.ok) {
|
|
56
|
+
return;
|
|
57
|
+
}
|
|
58
|
+
const { bodyUsed, headers, type } = response;
|
|
59
|
+
console.debug('[IsometricErrorUtils] handling error', { type, bodyUsed, headers });
|
|
60
|
+
// throw network error if the request didn't even go through
|
|
61
|
+
let error;
|
|
62
|
+
if (response.type === 'error') {
|
|
63
|
+
error = new api_1.OfflineError();
|
|
64
|
+
}
|
|
65
|
+
// or try to extract from json
|
|
66
|
+
else {
|
|
67
|
+
const json = await response.json();
|
|
68
|
+
console.debug('[IsometricErrorUtils] transforming error', {
|
|
69
|
+
json,
|
|
70
|
+
isIso: SerializedIsometricError_1.SerializedIsometricError.filter(json.error)
|
|
71
|
+
});
|
|
72
|
+
const { error: errorData } = Value_1.Value.typeOf(json) === 'object'
|
|
73
|
+
? json
|
|
74
|
+
: {};
|
|
75
|
+
error = (_a = deserializeError(errorData)) !== null && _a !== void 0 ? _a : new api_1.ServerError();
|
|
76
|
+
}
|
|
77
|
+
// perform callback (if any)
|
|
78
|
+
if (onError) {
|
|
79
|
+
onError(error);
|
|
80
|
+
}
|
|
81
|
+
// throw error
|
|
82
|
+
throw error;
|
|
83
|
+
}
|
|
84
|
+
IsometricErrorUtils.checkResponse = checkResponse;
|
|
85
|
+
})(IsometricErrorUtils || (exports.IsometricErrorUtils = IsometricErrorUtils = {}));
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { JsonObject } from 'type-fest';
|
|
2
|
+
import { IsometricErrorModule } from './IsometricErrorModule';
|
|
3
|
+
export type SerializedIsometricError = JsonObject & {
|
|
4
|
+
moduleId: IsometricErrorModule.Id;
|
|
5
|
+
name: string;
|
|
6
|
+
message: string;
|
|
7
|
+
};
|
|
8
|
+
export declare namespace SerializedIsometricError {
|
|
9
|
+
function filter(value: any): value is SerializedIsometricError;
|
|
10
|
+
}
|