@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,260 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.Regionalization = void 0;
|
|
4
|
+
const app_1 = require("../app");
|
|
5
|
+
const Language_1 = require("./Language");
|
|
6
|
+
var Regionalization;
|
|
7
|
+
(function (Regionalization) {
|
|
8
|
+
/**
|
|
9
|
+
* A function that parses out the locale used within the server, a partial locale hat was provide by the user through the URL, and the non-regional path.
|
|
10
|
+
*
|
|
11
|
+
* @param source source URL or path
|
|
12
|
+
* @param regionalization regions config that determines our server locale
|
|
13
|
+
* @param userLocale a optional locale that is used to infer any missing region/locale in the returned server locale.
|
|
14
|
+
*/
|
|
15
|
+
function parseBrowserUrl(source, regionalization, userLocale) {
|
|
16
|
+
var _a, _b;
|
|
17
|
+
// get Regionalization Type so we can properly assess source locale
|
|
18
|
+
const regionalizationType = app_1.RegionsConfig.getType(regionalization);
|
|
19
|
+
// set up
|
|
20
|
+
const sourceLocale = {};
|
|
21
|
+
let potentialRegion;
|
|
22
|
+
let potentialLanguage;
|
|
23
|
+
let pagePathComponents = [];
|
|
24
|
+
const sourcePath = typeof source === 'string'
|
|
25
|
+
? source
|
|
26
|
+
: source.pathname;
|
|
27
|
+
// page path components that were initially removed that we want to add back
|
|
28
|
+
const addBacks = [''];
|
|
29
|
+
// determine potential source locale
|
|
30
|
+
switch (regionalizationType) {
|
|
31
|
+
case 'language-only': {
|
|
32
|
+
// don't support having regions in our paths
|
|
33
|
+
const [, language, ...pagePath] = sourcePath.split('/');
|
|
34
|
+
potentialLanguage = language;
|
|
35
|
+
// build the page path components without the potential language
|
|
36
|
+
pagePathComponents = pagePath;
|
|
37
|
+
break;
|
|
38
|
+
}
|
|
39
|
+
case 'region-only': {
|
|
40
|
+
// dont support languages in path
|
|
41
|
+
const [, region, ...pagePath] = sourcePath.split('/');
|
|
42
|
+
potentialRegion = region;
|
|
43
|
+
// build the page path components without the potential region
|
|
44
|
+
pagePathComponents = pagePath;
|
|
45
|
+
break;
|
|
46
|
+
}
|
|
47
|
+
case 'locale-composite': {
|
|
48
|
+
// could have both language and region in path
|
|
49
|
+
const [, rawLocale, ...pagePath] = sourcePath.split('/');
|
|
50
|
+
const [region, language] = rawLocale.split('-');
|
|
51
|
+
potentialRegion = region;
|
|
52
|
+
potentialLanguage = language;
|
|
53
|
+
// build the page path components without the potential language and region
|
|
54
|
+
pagePathComponents = pagePath;
|
|
55
|
+
break;
|
|
56
|
+
}
|
|
57
|
+
case 'locale-split': {
|
|
58
|
+
// could have both language and region in path
|
|
59
|
+
const [, region, language, ...pagePath] = sourcePath.split('/');
|
|
60
|
+
potentialRegion = region;
|
|
61
|
+
potentialLanguage = language;
|
|
62
|
+
// build the page path components without the potential language and region
|
|
63
|
+
pagePathComponents = pagePath;
|
|
64
|
+
break;
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
// validate potential source region
|
|
68
|
+
const sourceRegion = app_1.RegionsConfig.tryParse(regionalization, potentialRegion);
|
|
69
|
+
if (sourceRegion) {
|
|
70
|
+
// assign it to source locale
|
|
71
|
+
sourceLocale.region = sourceRegion;
|
|
72
|
+
}
|
|
73
|
+
// otherwise add it to the list of 'addBacks' that will be later added back to 'pagePathComponents'
|
|
74
|
+
else if (potentialRegion) {
|
|
75
|
+
addBacks.push(potentialRegion);
|
|
76
|
+
}
|
|
77
|
+
// validate potential source language
|
|
78
|
+
const sourceLanguage = Language_1.Language.tryParse(potentialLanguage);
|
|
79
|
+
if (sourceLanguage) {
|
|
80
|
+
// assign it to source locale
|
|
81
|
+
sourceLocale.language = sourceLanguage;
|
|
82
|
+
}
|
|
83
|
+
// otherwise add it to the list of 'addBacks' that will be later added back to 'pagePathComponents'
|
|
84
|
+
else if (potentialLanguage) {
|
|
85
|
+
addBacks.push(potentialLanguage);
|
|
86
|
+
}
|
|
87
|
+
// determine the server region
|
|
88
|
+
const serverRegion = (_a = sourceLocale.region) !== null && _a !== void 0 ? _a : userLocale.region;
|
|
89
|
+
const regionConfig = app_1.RegionsConfig.getRegionConfig(regionalization, serverRegion);
|
|
90
|
+
// if source language is part of server region then use it, otherwise if user language is part of server region then use it, otherwise fall back to server region's default language
|
|
91
|
+
const serverLanguage = sourceLocale.language && regionConfig.languages.includes(sourceLocale.language)
|
|
92
|
+
? sourceLocale.language
|
|
93
|
+
: regionConfig.languages.includes(userLocale.language)
|
|
94
|
+
? userLocale.language
|
|
95
|
+
: (_b = regionConfig.defaultLanguage) !== null && _b !== void 0 ? _b : regionConfig.languages[0];
|
|
96
|
+
// return
|
|
97
|
+
return {
|
|
98
|
+
sourceLocale,
|
|
99
|
+
serverLocale: {
|
|
100
|
+
region: serverRegion,
|
|
101
|
+
language: serverLanguage
|
|
102
|
+
},
|
|
103
|
+
// if both the potential region and language were not valid, fall back to the original path otherwise use the add backs to get the page path
|
|
104
|
+
pagePath: addBacks.length === 3
|
|
105
|
+
? sourcePath
|
|
106
|
+
: addBacks.concat(pagePathComponents).join('/')
|
|
107
|
+
};
|
|
108
|
+
}
|
|
109
|
+
Regionalization.parseBrowserUrl = parseBrowserUrl;
|
|
110
|
+
/**
|
|
111
|
+
* A function that gets the URL and Locale visible to a browser, based on the UrlTruncation in the RegionsConfig.
|
|
112
|
+
* @param sourceLocale
|
|
113
|
+
* @param pagePath
|
|
114
|
+
* @param regionalization
|
|
115
|
+
* @param sourceUrl
|
|
116
|
+
* @private
|
|
117
|
+
*/
|
|
118
|
+
function targetUrlFor(sourceLocale, pagePath, regionalization, sourceUrl) {
|
|
119
|
+
// determine the target path/locale
|
|
120
|
+
const { targetLocale, targetPath } = getTargetPath({ sourceLocale, pagePath, regionalization });
|
|
121
|
+
// create a URL from the path (preserves query params, etc.)
|
|
122
|
+
const targetUrl = new URL(sourceUrl);
|
|
123
|
+
targetUrl.pathname = targetPath;
|
|
124
|
+
// return result
|
|
125
|
+
return { targetLocale, targetUrl };
|
|
126
|
+
}
|
|
127
|
+
Regionalization.targetUrlFor = targetUrlFor;
|
|
128
|
+
function getTargetPath({ sourceLocale, pagePath, regionalization }) {
|
|
129
|
+
// get target locale based on url truncation
|
|
130
|
+
const targetLocale = {};
|
|
131
|
+
switch (regionalization.urlTruncation) {
|
|
132
|
+
case 'none': {
|
|
133
|
+
// Always return region and language
|
|
134
|
+
targetLocale.region = sourceLocale.region;
|
|
135
|
+
targetLocale.language = sourceLocale.language;
|
|
136
|
+
break;
|
|
137
|
+
}
|
|
138
|
+
case 'partial':
|
|
139
|
+
{
|
|
140
|
+
// if both region and language are default omit them both
|
|
141
|
+
if (sourceLocale.region === regionalization.fallback && app_1.RegionsConfig.getDefaultLanguageForRegion(regionalization.regions[regionalization.fallback], {}) === sourceLocale.language) {
|
|
142
|
+
// do nothing
|
|
143
|
+
}
|
|
144
|
+
// if region is default region but language is not default, show language and region
|
|
145
|
+
else if (sourceLocale.region === regionalization.fallback && app_1.RegionsConfig.getDefaultLanguageForRegion(regionalization.regions[regionalization.fallback], {}) !== sourceLocale.language) {
|
|
146
|
+
targetLocale.region = sourceLocale.region;
|
|
147
|
+
targetLocale.language = sourceLocale.language;
|
|
148
|
+
}
|
|
149
|
+
// if for given region, the language is default, omit the language
|
|
150
|
+
else if (app_1.RegionsConfig.getDefaultLanguageForRegion(regionalization.regions[sourceLocale.region], {}) === sourceLocale.language) {
|
|
151
|
+
targetLocale.region = sourceLocale.region;
|
|
152
|
+
}
|
|
153
|
+
// otherwise include both of them
|
|
154
|
+
else {
|
|
155
|
+
targetLocale.region = sourceLocale.region;
|
|
156
|
+
targetLocale.language = sourceLocale.language;
|
|
157
|
+
}
|
|
158
|
+
break;
|
|
159
|
+
}
|
|
160
|
+
case 'full':
|
|
161
|
+
{
|
|
162
|
+
// omit region and language if both are default
|
|
163
|
+
if (regionalization.fallback === sourceLocale.region && app_1.RegionsConfig.getDefaultLanguage(regionalization, {}) === sourceLocale.language) {
|
|
164
|
+
// do nothing
|
|
165
|
+
}
|
|
166
|
+
// otherwise include both of them
|
|
167
|
+
else {
|
|
168
|
+
targetLocale.region = sourceLocale.region;
|
|
169
|
+
targetLocale.language = sourceLocale.language;
|
|
170
|
+
}
|
|
171
|
+
break;
|
|
172
|
+
}
|
|
173
|
+
}
|
|
174
|
+
// clear any values based on type
|
|
175
|
+
const regionType = app_1.RegionsConfig.getType(regionalization);
|
|
176
|
+
switch (regionType) {
|
|
177
|
+
case 'language-only':
|
|
178
|
+
targetLocale.region = undefined;
|
|
179
|
+
// if there is only a single language, also hide the language
|
|
180
|
+
if (app_1.RegionsConfig.getLanguages(regionalization).length === 1) {
|
|
181
|
+
targetLocale.language = undefined;
|
|
182
|
+
}
|
|
183
|
+
break;
|
|
184
|
+
case 'region-only':
|
|
185
|
+
targetLocale.language = undefined;
|
|
186
|
+
break;
|
|
187
|
+
}
|
|
188
|
+
// if merged routes and both region and language exist append with '-'
|
|
189
|
+
let targetPath;
|
|
190
|
+
if (regionalization.mergedRoutes && targetLocale.region && targetLocale.language) {
|
|
191
|
+
targetPath = `/${targetLocale.region}-${targetLocale.language}`;
|
|
192
|
+
}
|
|
193
|
+
// or build segments based on region/language existing in target
|
|
194
|
+
else {
|
|
195
|
+
// start with nothing
|
|
196
|
+
targetPath = '';
|
|
197
|
+
// add region, if we have one
|
|
198
|
+
if (targetLocale.region) {
|
|
199
|
+
targetPath += `/${targetLocale.region}`;
|
|
200
|
+
}
|
|
201
|
+
// add language if we have one
|
|
202
|
+
if (targetLocale.language) {
|
|
203
|
+
targetPath += `/${targetLocale.language}`;
|
|
204
|
+
}
|
|
205
|
+
}
|
|
206
|
+
// add page path
|
|
207
|
+
const normalizedPagePath = pagePath.startsWith('/')
|
|
208
|
+
? pagePath
|
|
209
|
+
: `/${pagePath}`;
|
|
210
|
+
if (normalizedPagePath.length > 1) {
|
|
211
|
+
targetPath += normalizedPagePath;
|
|
212
|
+
}
|
|
213
|
+
// return result
|
|
214
|
+
return { targetLocale, targetPath };
|
|
215
|
+
}
|
|
216
|
+
Regionalization.getTargetPath = getTargetPath;
|
|
217
|
+
function mergedPathFor(locale, path) {
|
|
218
|
+
// if both region/lang concatenate with -
|
|
219
|
+
if (locale.region && locale.language) {
|
|
220
|
+
return `/${locale.region}-${locale.language}${path}`;
|
|
221
|
+
}
|
|
222
|
+
// if only region omit lang and concatenation
|
|
223
|
+
else if (locale.region) {
|
|
224
|
+
return `/${locale.region}${path}`;
|
|
225
|
+
}
|
|
226
|
+
// if only lang omit region and concatenation
|
|
227
|
+
else if (locale.language) {
|
|
228
|
+
return `/${locale.language}${path}`;
|
|
229
|
+
}
|
|
230
|
+
return path;
|
|
231
|
+
}
|
|
232
|
+
Regionalization.mergedPathFor = mergedPathFor;
|
|
233
|
+
function splitPathFor(locale, path) {
|
|
234
|
+
// if both region/lang concatenate with -
|
|
235
|
+
if (locale.region && locale.language) {
|
|
236
|
+
return `/${locale.region}/${locale.language}${path}`;
|
|
237
|
+
}
|
|
238
|
+
// if only region omit lang and concatenation
|
|
239
|
+
else if (locale.region) {
|
|
240
|
+
return `/${locale.region}${path}`;
|
|
241
|
+
}
|
|
242
|
+
// if only lang omit region and concatenation
|
|
243
|
+
else if (locale.language) {
|
|
244
|
+
return `/${locale.language}${path}`;
|
|
245
|
+
}
|
|
246
|
+
return path;
|
|
247
|
+
}
|
|
248
|
+
Regionalization.splitPathFor = splitPathFor;
|
|
249
|
+
/**
|
|
250
|
+
* A function that returns the intended URL for the server given a full locale and a non-regional path.
|
|
251
|
+
*
|
|
252
|
+
* @param locale
|
|
253
|
+
* @param path
|
|
254
|
+
* @param baseUrl
|
|
255
|
+
*/
|
|
256
|
+
function serverUrlFor(locale, path, baseUrl) {
|
|
257
|
+
return new URL(splitPathFor(locale, path), baseUrl);
|
|
258
|
+
}
|
|
259
|
+
Regionalization.serverUrlFor = serverUrlFor;
|
|
260
|
+
})(Regionalization || (exports.Regionalization = Regionalization = {}));
|
|
@@ -0,0 +1,23 @@
|
|
|
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("./Language"), exports);
|
|
18
|
+
__exportStar(require("./Localized"), exports);
|
|
19
|
+
__exportStar(require("./LocalizedCopy"), exports);
|
|
20
|
+
__exportStar(require("./Country"), exports);
|
|
21
|
+
__exportStar(require("./Locale"), exports);
|
|
22
|
+
__exportStar(require("./Regionalization"), exports);
|
|
23
|
+
__exportStar(require("./Regions"), exports);
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { Tagged } from 'type-fest';
|
|
2
|
+
import { AssetField, Field } from './field';
|
|
3
|
+
export type Asset<TValue extends AssetField.LinkedValue = AssetField.LinkedValue> = Field.Data<AssetField<TValue>>;
|
|
4
|
+
export declare namespace Asset {
|
|
5
|
+
type Id = Tagged<string, 'Asset.Id'>;
|
|
6
|
+
type Image = Asset<AssetField.LinkedValue.Image>;
|
|
7
|
+
type Video = Asset<AssetField.LinkedValue.Video>;
|
|
8
|
+
type Audio = Asset<AssetField.LinkedValue.Audio>;
|
|
9
|
+
type Document = Asset<AssetField.LinkedValue.Document>;
|
|
10
|
+
function filter(value: any): value is Asset;
|
|
11
|
+
function getId(asset: Asset | Asset.Linked): Id;
|
|
12
|
+
type Linked<TValue extends AssetField.LinkedValue = AssetField.LinkedValue> = Field.LinkedData<AssetField<TValue>> & {
|
|
13
|
+
__root: 'asset';
|
|
14
|
+
};
|
|
15
|
+
namespace Linked {
|
|
16
|
+
type Visual = Linked<AssetField.LinkedValue.Image | AssetField.LinkedValue.Video>;
|
|
17
|
+
type Image = Linked<AssetField.LinkedValue.Image>;
|
|
18
|
+
type Video = Linked<AssetField.LinkedValue.Video>;
|
|
19
|
+
type Audio = Linked<AssetField.LinkedValue.Audio>;
|
|
20
|
+
type Document = Linked<AssetField.LinkedValue.Document>;
|
|
21
|
+
function filter(value: any): value is Linked;
|
|
22
|
+
}
|
|
23
|
+
}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.Asset = void 0;
|
|
4
|
+
const utils_1 = require("../utils");
|
|
5
|
+
const field_1 = require("./field");
|
|
6
|
+
var Asset;
|
|
7
|
+
(function (Asset) {
|
|
8
|
+
// guard
|
|
9
|
+
function filter(value) {
|
|
10
|
+
return !!value
|
|
11
|
+
&& utils_1.Value.typeOf(value) === 'object'
|
|
12
|
+
&& value.type === 'asset'
|
|
13
|
+
&& '__ref' in value
|
|
14
|
+
&& value.__ref === 'asset'
|
|
15
|
+
&& 'value' in value
|
|
16
|
+
&& field_1.AssetField.Value.filter(value.value);
|
|
17
|
+
}
|
|
18
|
+
Asset.filter = filter;
|
|
19
|
+
// helpers
|
|
20
|
+
function getId(asset) {
|
|
21
|
+
return asset.value.id;
|
|
22
|
+
}
|
|
23
|
+
Asset.getId = getId;
|
|
24
|
+
let Linked;
|
|
25
|
+
(function (Linked) {
|
|
26
|
+
// guard
|
|
27
|
+
function filter(value) {
|
|
28
|
+
return !!value
|
|
29
|
+
&& utils_1.Value.typeOf(value) === 'object'
|
|
30
|
+
&& value.type === 'asset'
|
|
31
|
+
&& '__root' in value
|
|
32
|
+
&& value.__root === 'asset';
|
|
33
|
+
}
|
|
34
|
+
Linked.filter = filter;
|
|
35
|
+
})(Linked = Asset.Linked || (Asset.Linked = {}));
|
|
36
|
+
})(Asset || (exports.Asset = Asset = {}));
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
import { Collection as CollectionType } from './Collection';
|
|
2
|
+
import { Page as PageType } from './Page';
|
|
3
|
+
export declare abstract class AbstractAssetScope {
|
|
4
|
+
abstract get data(): AssetScope.Data;
|
|
5
|
+
}
|
|
6
|
+
export declare class GlobalAssetScope extends AbstractAssetScope {
|
|
7
|
+
static readonly instance: GlobalAssetScope;
|
|
8
|
+
readonly range: AssetScope.Range;
|
|
9
|
+
private constructor();
|
|
10
|
+
get data(): AssetScope.Data.Global;
|
|
11
|
+
}
|
|
12
|
+
export declare abstract class TypeAssetScope extends AbstractAssetScope {
|
|
13
|
+
readonly range: AssetScope.Range;
|
|
14
|
+
}
|
|
15
|
+
export declare class PageTypeAssetScope extends TypeAssetScope {
|
|
16
|
+
readonly type: PageType.Type;
|
|
17
|
+
readonly target: AssetScope.Target;
|
|
18
|
+
constructor(type: PageType.Type);
|
|
19
|
+
get data(): AssetScope.Data.Type.Page;
|
|
20
|
+
}
|
|
21
|
+
export declare class CollectionTypeAssetScope extends TypeAssetScope {
|
|
22
|
+
readonly type: CollectionType.Type;
|
|
23
|
+
readonly target: AssetScope.Target;
|
|
24
|
+
constructor(type: CollectionType.Type);
|
|
25
|
+
get data(): AssetScope.Data.Type.Collection;
|
|
26
|
+
}
|
|
27
|
+
export declare abstract class InstanceAssetScope extends AbstractAssetScope {
|
|
28
|
+
readonly range: AssetScope.Range;
|
|
29
|
+
}
|
|
30
|
+
export declare class PageInstanceAssetScope extends InstanceAssetScope {
|
|
31
|
+
readonly groupId: PageType.GroupId;
|
|
32
|
+
readonly target: AssetScope.Target;
|
|
33
|
+
constructor(groupId: PageType.GroupId);
|
|
34
|
+
get data(): AssetScope.Data.Instance.Page;
|
|
35
|
+
}
|
|
36
|
+
export declare class CollectionInstanceAssetScope extends InstanceAssetScope {
|
|
37
|
+
readonly groupId: CollectionType.GroupId;
|
|
38
|
+
readonly target: AssetScope.Target;
|
|
39
|
+
constructor(groupId: CollectionType.GroupId);
|
|
40
|
+
get data(): AssetScope.Data.Instance.Collection;
|
|
41
|
+
}
|
|
42
|
+
export type AssetScope = GlobalAssetScope | PageTypeAssetScope | CollectionTypeAssetScope | PageInstanceAssetScope | CollectionInstanceAssetScope;
|
|
43
|
+
export declare namespace AssetScope {
|
|
44
|
+
const global: GlobalAssetScope;
|
|
45
|
+
type Range = 'global' | 'type' | 'instance';
|
|
46
|
+
type Target = 'page' | 'collection';
|
|
47
|
+
type Data = Data.Global | Data.Type | Data.Instance;
|
|
48
|
+
namespace Data {
|
|
49
|
+
const PagePrefix = "page/";
|
|
50
|
+
type PagePrefix = typeof PagePrefix;
|
|
51
|
+
const CollectionPrefix = "collection/";
|
|
52
|
+
type CollectionPrefix = typeof CollectionPrefix;
|
|
53
|
+
const TypePrefix = "type/";
|
|
54
|
+
type TypePrefix = typeof TypePrefix;
|
|
55
|
+
const InstancePrefix = "instance/";
|
|
56
|
+
type InstancePrefix = typeof InstancePrefix;
|
|
57
|
+
const global = "global";
|
|
58
|
+
type Global = typeof global;
|
|
59
|
+
type Type = Type.Page | Type.Collection;
|
|
60
|
+
namespace Type {
|
|
61
|
+
type Page = `${TypePrefix}${PagePrefix}${PageType.Type}`;
|
|
62
|
+
type Collection = `${TypePrefix}${CollectionPrefix}${CollectionType.Type}`;
|
|
63
|
+
function forPage(type: PageType.Type): Page;
|
|
64
|
+
function forCollection(type: CollectionType.Type): Collection;
|
|
65
|
+
}
|
|
66
|
+
type Instance = Instance.Page | Instance.Collection;
|
|
67
|
+
namespace Instance {
|
|
68
|
+
type Page = `${InstancePrefix}${PagePrefix}${PageType.GroupId}`;
|
|
69
|
+
type Collection = `${InstancePrefix}${CollectionPrefix}${CollectionType.GroupId}`;
|
|
70
|
+
function forPage(groupId: PageType.GroupId): Page;
|
|
71
|
+
function forCollection(groupId: CollectionType.GroupId): Collection;
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
function fromData(data: string): AssetScope | undefined;
|
|
75
|
+
}
|
|
@@ -0,0 +1,146 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.AssetScope = exports.CollectionInstanceAssetScope = exports.PageInstanceAssetScope = exports.InstanceAssetScope = exports.CollectionTypeAssetScope = exports.PageTypeAssetScope = exports.TypeAssetScope = exports.GlobalAssetScope = exports.AbstractAssetScope = void 0;
|
|
4
|
+
// classes
|
|
5
|
+
class AbstractAssetScope {
|
|
6
|
+
}
|
|
7
|
+
exports.AbstractAssetScope = AbstractAssetScope;
|
|
8
|
+
// global-scoped
|
|
9
|
+
class GlobalAssetScope extends AbstractAssetScope {
|
|
10
|
+
constructor() {
|
|
11
|
+
super();
|
|
12
|
+
this.range = 'global';
|
|
13
|
+
}
|
|
14
|
+
get data() {
|
|
15
|
+
return 'global';
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
exports.GlobalAssetScope = GlobalAssetScope;
|
|
19
|
+
GlobalAssetScope.instance = new GlobalAssetScope();
|
|
20
|
+
// type-scoped
|
|
21
|
+
class TypeAssetScope extends AbstractAssetScope {
|
|
22
|
+
constructor() {
|
|
23
|
+
super(...arguments);
|
|
24
|
+
this.range = 'type';
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
exports.TypeAssetScope = TypeAssetScope;
|
|
28
|
+
class PageTypeAssetScope extends TypeAssetScope {
|
|
29
|
+
constructor(type) {
|
|
30
|
+
super();
|
|
31
|
+
this.type = type;
|
|
32
|
+
this.target = 'page';
|
|
33
|
+
}
|
|
34
|
+
get data() {
|
|
35
|
+
return `${AssetScope.Data.TypePrefix}${AssetScope.Data.PagePrefix}${this.type}`;
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
exports.PageTypeAssetScope = PageTypeAssetScope;
|
|
39
|
+
class CollectionTypeAssetScope extends TypeAssetScope {
|
|
40
|
+
constructor(type) {
|
|
41
|
+
super();
|
|
42
|
+
this.type = type;
|
|
43
|
+
this.target = 'collection';
|
|
44
|
+
}
|
|
45
|
+
get data() {
|
|
46
|
+
return `${AssetScope.Data.TypePrefix}${AssetScope.Data.CollectionPrefix}${this.type}`;
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
exports.CollectionTypeAssetScope = CollectionTypeAssetScope;
|
|
50
|
+
// type-scoped
|
|
51
|
+
class InstanceAssetScope extends AbstractAssetScope {
|
|
52
|
+
constructor() {
|
|
53
|
+
super(...arguments);
|
|
54
|
+
this.range = 'instance';
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
exports.InstanceAssetScope = InstanceAssetScope;
|
|
58
|
+
class PageInstanceAssetScope extends InstanceAssetScope {
|
|
59
|
+
constructor(groupId) {
|
|
60
|
+
super();
|
|
61
|
+
this.groupId = groupId;
|
|
62
|
+
this.target = 'page';
|
|
63
|
+
}
|
|
64
|
+
get data() {
|
|
65
|
+
return `${AssetScope.Data.InstancePrefix}${AssetScope.Data.PagePrefix}${this.groupId}`;
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
exports.PageInstanceAssetScope = PageInstanceAssetScope;
|
|
69
|
+
class CollectionInstanceAssetScope extends InstanceAssetScope {
|
|
70
|
+
constructor(groupId) {
|
|
71
|
+
super();
|
|
72
|
+
this.groupId = groupId;
|
|
73
|
+
this.target = 'collection';
|
|
74
|
+
}
|
|
75
|
+
get data() {
|
|
76
|
+
return `${AssetScope.Data.InstancePrefix}${AssetScope.Data.CollectionPrefix}${this.groupId}`;
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
exports.CollectionInstanceAssetScope = CollectionInstanceAssetScope;
|
|
80
|
+
var AssetScope;
|
|
81
|
+
(function (AssetScope) {
|
|
82
|
+
// constants
|
|
83
|
+
AssetScope.global = GlobalAssetScope.instance;
|
|
84
|
+
let Data;
|
|
85
|
+
(function (Data) {
|
|
86
|
+
// prefixes
|
|
87
|
+
Data.PagePrefix = 'page/';
|
|
88
|
+
Data.CollectionPrefix = 'collection/';
|
|
89
|
+
Data.TypePrefix = 'type/';
|
|
90
|
+
Data.InstancePrefix = 'instance/';
|
|
91
|
+
// global scoping
|
|
92
|
+
Data.global = 'global';
|
|
93
|
+
let Type;
|
|
94
|
+
(function (Type) {
|
|
95
|
+
function forPage(type) {
|
|
96
|
+
return `${Data.TypePrefix}${Data.PagePrefix}${type}`;
|
|
97
|
+
}
|
|
98
|
+
Type.forPage = forPage;
|
|
99
|
+
function forCollection(type) {
|
|
100
|
+
return `${Data.TypePrefix}${Data.CollectionPrefix}${type}`;
|
|
101
|
+
}
|
|
102
|
+
Type.forCollection = forCollection;
|
|
103
|
+
})(Type = Data.Type || (Data.Type = {}));
|
|
104
|
+
let Instance;
|
|
105
|
+
(function (Instance) {
|
|
106
|
+
function forPage(groupId) {
|
|
107
|
+
return `${Data.InstancePrefix}${Data.PagePrefix}${groupId}`;
|
|
108
|
+
}
|
|
109
|
+
Instance.forPage = forPage;
|
|
110
|
+
function forCollection(groupId) {
|
|
111
|
+
return `${Data.InstancePrefix}${Data.CollectionPrefix}${groupId}`;
|
|
112
|
+
}
|
|
113
|
+
Instance.forCollection = forCollection;
|
|
114
|
+
})(Instance = Data.Instance || (Data.Instance = {}));
|
|
115
|
+
})(Data = AssetScope.Data || (AssetScope.Data = {}));
|
|
116
|
+
// parsing
|
|
117
|
+
function fromData(data) {
|
|
118
|
+
// handle global scope
|
|
119
|
+
if (data === 'global') {
|
|
120
|
+
return AssetScope.global;
|
|
121
|
+
}
|
|
122
|
+
// or type scope
|
|
123
|
+
else if (data.startsWith(Data.TypePrefix)) {
|
|
124
|
+
const subvalue = data.substring(Data.TypePrefix.length);
|
|
125
|
+
if (subvalue.startsWith(Data.PagePrefix)) {
|
|
126
|
+
return new PageTypeAssetScope(subvalue.substring(Data.PagePrefix.length));
|
|
127
|
+
}
|
|
128
|
+
else if (subvalue.startsWith(Data.CollectionPrefix)) {
|
|
129
|
+
return new CollectionTypeAssetScope(subvalue.substring(Data.CollectionPrefix.length));
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
// or instance scope
|
|
133
|
+
else if (data.startsWith(Data.InstancePrefix)) {
|
|
134
|
+
const subvalue = data.substring(Data.InstancePrefix.length);
|
|
135
|
+
if (subvalue.startsWith(Data.PagePrefix)) {
|
|
136
|
+
return new PageInstanceAssetScope(subvalue.substring(Data.PagePrefix.length));
|
|
137
|
+
}
|
|
138
|
+
else if (subvalue.startsWith(Data.CollectionPrefix)) {
|
|
139
|
+
return new CollectionInstanceAssetScope(subvalue.substring(Data.CollectionPrefix.length));
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
// otherwise, it didn't parse
|
|
143
|
+
return undefined;
|
|
144
|
+
}
|
|
145
|
+
AssetScope.fromData = fromData;
|
|
146
|
+
})(AssetScope || (exports.AssetScope = AssetScope = {}));
|