@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,383 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __rest = (this && this.__rest) || function (s, e) {
|
|
3
|
+
var t = {};
|
|
4
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
5
|
+
t[p] = s[p];
|
|
6
|
+
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
7
|
+
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
8
|
+
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
9
|
+
t[p[i]] = s[p[i]];
|
|
10
|
+
}
|
|
11
|
+
return t;
|
|
12
|
+
};
|
|
13
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
14
|
+
exports.CollectionModel = void 0;
|
|
15
|
+
const errors_1 = require("../errors");
|
|
16
|
+
const Collection_1 = require("./Collection");
|
|
17
|
+
// class
|
|
18
|
+
class CollectionModel {
|
|
19
|
+
constructor(data) {
|
|
20
|
+
this.data = data;
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* Synchronizes computed properties with the latest `CollectionModel` data (e.g. updating `name`)
|
|
24
|
+
*/
|
|
25
|
+
sync() {
|
|
26
|
+
// TODO: add something when we need to sync
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* Applies updates *in place* to the underlying `Collection.Data`.
|
|
30
|
+
*
|
|
31
|
+
* @param updates - a collection of updates to be applied to this collection.
|
|
32
|
+
*/
|
|
33
|
+
update(updates) {
|
|
34
|
+
// apply updates
|
|
35
|
+
updates.forEach(update => {
|
|
36
|
+
switch (update.type) {
|
|
37
|
+
case 'name':
|
|
38
|
+
this.updateName(update);
|
|
39
|
+
break;
|
|
40
|
+
case 'tags':
|
|
41
|
+
this.updateTags(update);
|
|
42
|
+
break;
|
|
43
|
+
case 'object.insert':
|
|
44
|
+
this.updateObjectInsert(update);
|
|
45
|
+
break;
|
|
46
|
+
case 'array.insert':
|
|
47
|
+
this.updateArrayInsert(update);
|
|
48
|
+
break;
|
|
49
|
+
case 'array.delete':
|
|
50
|
+
this.updateArrayDelete(update);
|
|
51
|
+
break;
|
|
52
|
+
case 'array.reorder':
|
|
53
|
+
this.updateArrayReorder(update);
|
|
54
|
+
break;
|
|
55
|
+
case 'value':
|
|
56
|
+
this.updateValue(update);
|
|
57
|
+
break;
|
|
58
|
+
}
|
|
59
|
+
});
|
|
60
|
+
// finally, sync the model
|
|
61
|
+
this.sync();
|
|
62
|
+
}
|
|
63
|
+
updateName(update) {
|
|
64
|
+
// replace name
|
|
65
|
+
const { data: collection } = this;
|
|
66
|
+
collection.name = update.name;
|
|
67
|
+
}
|
|
68
|
+
updateTags(update) {
|
|
69
|
+
// replace tags
|
|
70
|
+
const { data: collection } = this;
|
|
71
|
+
collection.tags = update.tags;
|
|
72
|
+
}
|
|
73
|
+
updateObjectInsert(_a) {
|
|
74
|
+
var { value } = _a, update = __rest(_a, ["value"]);
|
|
75
|
+
// resolve target (if required)
|
|
76
|
+
const { data: collection } = this;
|
|
77
|
+
const { root, path } = splitRoot(collection, update.path);
|
|
78
|
+
const [key] = path.splice(-1, 1);
|
|
79
|
+
const target = this.find(root, {
|
|
80
|
+
path,
|
|
81
|
+
parentPath: [],
|
|
82
|
+
issues: []
|
|
83
|
+
});
|
|
84
|
+
// fail if there's no target (shouldn't happen)
|
|
85
|
+
if (!target || typeof target !== 'object' || Array.isArray(target)) {
|
|
86
|
+
console.warn(`[CollectionModel/updateObjectInsert] could not find object parent at path "${path.join('.')}"`);
|
|
87
|
+
}
|
|
88
|
+
// fail if key is already set on parent
|
|
89
|
+
else if (key in target) {
|
|
90
|
+
console.warn(`[CollectionModel/updateObjectInsert] object already exists in "${target.type}" for key "${key}"`);
|
|
91
|
+
}
|
|
92
|
+
// or just add object
|
|
93
|
+
else {
|
|
94
|
+
console.debug(`[CollectionModel/updateObjectInsert] setting object at "${key}"`);
|
|
95
|
+
const parent = target;
|
|
96
|
+
parent[key] = value;
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
updateArrayInsert(_a) {
|
|
100
|
+
var { index, id, value } = _a, update = __rest(_a, ["index", "id", "value"]);
|
|
101
|
+
// resolve target
|
|
102
|
+
const { data: collection } = this;
|
|
103
|
+
const { root, path } = splitRoot(collection, update.path);
|
|
104
|
+
let target = this.find(root, {
|
|
105
|
+
path,
|
|
106
|
+
parentPath: [],
|
|
107
|
+
issues: []
|
|
108
|
+
});
|
|
109
|
+
// simply create the array if it doesn't exist
|
|
110
|
+
if (target === undefined || target === null) {
|
|
111
|
+
// resolve parent
|
|
112
|
+
const { parentPath, childKey } = splitPath(path);
|
|
113
|
+
target = this.find(root, {
|
|
114
|
+
path: parentPath,
|
|
115
|
+
parentPath: [],
|
|
116
|
+
issues: []
|
|
117
|
+
});
|
|
118
|
+
// fail if item's parent isn't found
|
|
119
|
+
if (!target) {
|
|
120
|
+
console.warn(`[CollectionModel/updateArrayInsert] could not find array parent at path "${path.join('.')}"`);
|
|
121
|
+
}
|
|
122
|
+
// or set value
|
|
123
|
+
else {
|
|
124
|
+
this.setValue(target, childKey, { type: 'list', value: [value] });
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
// or fail if target isn't an array
|
|
128
|
+
else if (target.type !== 'list') {
|
|
129
|
+
console.warn(`[CollectionModel/updateArrayInsert] could not find array at path "${path.join('.')}"`);
|
|
130
|
+
}
|
|
131
|
+
// or fail if item is already in list
|
|
132
|
+
else if (target.value.some(item => item.id === id)) {
|
|
133
|
+
console.warn(`[CollectionModel/updateArrayInsert] item is already in list at "${path.join('.')}" - ignoring`);
|
|
134
|
+
}
|
|
135
|
+
// or insert at end if index is out-of-bounds
|
|
136
|
+
else if (index < 0 || target.value.length < index) {
|
|
137
|
+
console.debug(`[CollectionModel/updateArrayInsert] item "${id}" index "${index}" is out of bounds (0, ${target.value.length} at "${path.join('.')}" - adding to end:`, value);
|
|
138
|
+
target.value.push(value);
|
|
139
|
+
}
|
|
140
|
+
// or insert item at index
|
|
141
|
+
else {
|
|
142
|
+
console.debug(`[CollectionModel/updateArrayInsert] inserting item "${id}" to "${index}" in list at "${path.join('.')}":`, value);
|
|
143
|
+
target.value.splice(index, 0, value);
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
updateArrayDelete(_a) {
|
|
147
|
+
var { id } = _a, update = __rest(_a, ["id"]);
|
|
148
|
+
// resolve target
|
|
149
|
+
const { data: collection } = this;
|
|
150
|
+
const { root, path } = splitRoot(collection, update.path);
|
|
151
|
+
const target = this.find(root, {
|
|
152
|
+
path,
|
|
153
|
+
parentPath: [],
|
|
154
|
+
issues: []
|
|
155
|
+
});
|
|
156
|
+
// skip if target isn't an array
|
|
157
|
+
if ((target === null || target === void 0 ? void 0 : target.type) !== 'list') {
|
|
158
|
+
console.warn(`[CollectionModel/updateArrayDelete] could not find array at path "${path.join('.')}"`);
|
|
159
|
+
}
|
|
160
|
+
// or remove target
|
|
161
|
+
else {
|
|
162
|
+
// find target index (fail if it's not there)
|
|
163
|
+
const list = target.value;
|
|
164
|
+
const index = list.findIndex(item => item.id === id);
|
|
165
|
+
if (index < 0) {
|
|
166
|
+
console.warn(`[CollectionModel/updateArrayDelete] no item with ID "${id}" in list at "${path.join('.')}"`);
|
|
167
|
+
}
|
|
168
|
+
// or splice it out
|
|
169
|
+
else {
|
|
170
|
+
console.warn(`[CollectionModel/updateArrayDelete] removed item "${id}" from list at "${path.join('.')}"`);
|
|
171
|
+
list.splice(index, 1);
|
|
172
|
+
}
|
|
173
|
+
}
|
|
174
|
+
}
|
|
175
|
+
updateArrayReorder(_a) {
|
|
176
|
+
var { ids } = _a, update = __rest(_a, ["ids"]);
|
|
177
|
+
// resolve target
|
|
178
|
+
const { data: collection } = this;
|
|
179
|
+
const { root, path } = splitRoot(collection, update.path);
|
|
180
|
+
const target = this.find(root, {
|
|
181
|
+
path,
|
|
182
|
+
parentPath: [],
|
|
183
|
+
issues: []
|
|
184
|
+
});
|
|
185
|
+
// fail if target isn't an array
|
|
186
|
+
if ((target === null || target === void 0 ? void 0 : target.type) !== 'list') {
|
|
187
|
+
console.warn(`[CollectionModel/updateArrayReorder] could not find array at path "${path.join('.')}"`);
|
|
188
|
+
return;
|
|
189
|
+
}
|
|
190
|
+
// create new array with the correct order - this drops item's that aren't in the intersection
|
|
191
|
+
const updatedValue = [];
|
|
192
|
+
ids.forEach(id => {
|
|
193
|
+
// add item if it's in the original
|
|
194
|
+
const item = target.value.find(item => item.id === id);
|
|
195
|
+
if (item) {
|
|
196
|
+
updatedValue.push(item);
|
|
197
|
+
}
|
|
198
|
+
});
|
|
199
|
+
// replace the value
|
|
200
|
+
target.value = updatedValue;
|
|
201
|
+
}
|
|
202
|
+
updateValue(_a) {
|
|
203
|
+
var { value } = _a, update = __rest(_a, ["value"]);
|
|
204
|
+
console.debug(`[CollectionModel/updateValue] executing value update`, { update, value });
|
|
205
|
+
// insert field if it's new
|
|
206
|
+
const { data: collection } = this;
|
|
207
|
+
const { root, path } = splitRoot(collection, update.path);
|
|
208
|
+
const { parentPath, childKey } = splitPath(path);
|
|
209
|
+
const target = this.find(root, {
|
|
210
|
+
path: parentPath,
|
|
211
|
+
parentPath: [],
|
|
212
|
+
issues: []
|
|
213
|
+
});
|
|
214
|
+
// skip if target can't be resolved (track issue)
|
|
215
|
+
if (!target) {
|
|
216
|
+
// TODO: track issue
|
|
217
|
+
console.warn(`[CollectionModel/updateValue] no target to update`);
|
|
218
|
+
// stop processing
|
|
219
|
+
return;
|
|
220
|
+
}
|
|
221
|
+
console.warn(`[CollectionModel/updateValue] updating target`, { target, childKey });
|
|
222
|
+
// set value
|
|
223
|
+
this.setValue(target, childKey, value);
|
|
224
|
+
console.warn(`[CollectionModel/updateValue] updated value for "${path.join('.')}" to:`, value);
|
|
225
|
+
}
|
|
226
|
+
setValue(target, key, data) {
|
|
227
|
+
// update root value
|
|
228
|
+
if (target === this.data.fields) {
|
|
229
|
+
console.debug(`[CollectionModel/setValue] updating "fields" at "${key}" to:`, data);
|
|
230
|
+
// delete entry if there's no data
|
|
231
|
+
if (data === null || data === undefined) {
|
|
232
|
+
console.debug(`[CollectionModel/setValue] deleting "fields" at "${key}"`);
|
|
233
|
+
delete target[key];
|
|
234
|
+
}
|
|
235
|
+
// or pave over if entry
|
|
236
|
+
else {
|
|
237
|
+
console.debug(`[CollectionModel/setValue] setting "fields" at "${key}" to:`, data);
|
|
238
|
+
target[key] = data;
|
|
239
|
+
}
|
|
240
|
+
}
|
|
241
|
+
// update list value
|
|
242
|
+
else if (target.type === 'list') {
|
|
243
|
+
// add back item if it's gone
|
|
244
|
+
const items = target.value;
|
|
245
|
+
const itemIndex = items.findIndex(item => item.id === key);
|
|
246
|
+
if (itemIndex < 0) {
|
|
247
|
+
items.push(data);
|
|
248
|
+
}
|
|
249
|
+
// or pave over value
|
|
250
|
+
else {
|
|
251
|
+
console.debug(`[CollectionModel/setValue] updating ListField at "${key}" to:`, data);
|
|
252
|
+
items[itemIndex] = data;
|
|
253
|
+
}
|
|
254
|
+
}
|
|
255
|
+
// or update object value
|
|
256
|
+
else if (target.type === 'object') {
|
|
257
|
+
console.debug(`[CollectionModel/setValue] updating ObjectField at "${key}" to:`, data);
|
|
258
|
+
// delete entry if there's no data
|
|
259
|
+
if (data === null || data === undefined) {
|
|
260
|
+
console.debug(`[CollectionModel/setValue] deleting ObjectField at "${key}"`);
|
|
261
|
+
delete target.value[key];
|
|
262
|
+
}
|
|
263
|
+
// or pave over with update
|
|
264
|
+
else {
|
|
265
|
+
console.debug(`[CollectionModel/setValue] updating ObjectField at "${key}" to:`, data);
|
|
266
|
+
target.value[key] = data;
|
|
267
|
+
}
|
|
268
|
+
}
|
|
269
|
+
// or ignore (this should never happen)
|
|
270
|
+
else {
|
|
271
|
+
console.warn(`[CollectionModel/setValue] invalid parent found at path "${key}"`, target);
|
|
272
|
+
}
|
|
273
|
+
}
|
|
274
|
+
find(fields, context) {
|
|
275
|
+
// return fields if there's no path
|
|
276
|
+
const { path, parentPath } = context;
|
|
277
|
+
if (path.length === 0) {
|
|
278
|
+
console.debug(`[CollectionModel/find] returning Collection.fields for: ${parentPath.join('.')}`);
|
|
279
|
+
return fields;
|
|
280
|
+
}
|
|
281
|
+
console.debug(`[CollectionModel/find] resolving content target: ${path.join('.')}`, { path, parentPath, fields, context });
|
|
282
|
+
// add item (if required)
|
|
283
|
+
const [key, ...remainingPath] = path;
|
|
284
|
+
const fieldValue = fields[key];
|
|
285
|
+
if (!fieldValue) {
|
|
286
|
+
console.warn(`[CollectionModel/find] unable to resolve top-level field "${key}" in "${parentPath.join('.')}"`);
|
|
287
|
+
return undefined;
|
|
288
|
+
}
|
|
289
|
+
// return item if there are no more components
|
|
290
|
+
if (remainingPath.length === 0) {
|
|
291
|
+
console.debug(`[CollectionModel/find] no more components - returning field value "${key}" at: ${path.join('.')}`);
|
|
292
|
+
return fieldValue;
|
|
293
|
+
}
|
|
294
|
+
// resolve value
|
|
295
|
+
else {
|
|
296
|
+
console.debug(`[CollectionModel/find] drilling into top-level value for "${key}": ${remainingPath.join('.')}`);
|
|
297
|
+
return this.findInValue(fieldValue, Object.assign(Object.assign({}, context), { path: remainingPath, parentPath: [...parentPath, key] }));
|
|
298
|
+
}
|
|
299
|
+
}
|
|
300
|
+
findInValue(data, context) {
|
|
301
|
+
// return item if there's no more path components
|
|
302
|
+
const { path, parentPath } = context;
|
|
303
|
+
if (path.length === 0) {
|
|
304
|
+
console.debug(`[CollectionModel/findInValue] return leaf value "${parentPath.join('.')}":`, data);
|
|
305
|
+
return data;
|
|
306
|
+
}
|
|
307
|
+
// or return undefined if there's nothing here
|
|
308
|
+
else if (data === undefined || data === null) {
|
|
309
|
+
console.warn(`[CollectionModel/findInValue] encountered empty Value while navigating "${path.join('.')}" at "${parentPath.join('.')}"`);
|
|
310
|
+
return data;
|
|
311
|
+
}
|
|
312
|
+
// or recurse into an array
|
|
313
|
+
else if (data.type === 'list') {
|
|
314
|
+
// skip if entry isn't found
|
|
315
|
+
const value = data.value;
|
|
316
|
+
const [itemId, ...remainingPath] = path;
|
|
317
|
+
const item = value.find(item => item.id === itemId);
|
|
318
|
+
if (!item) {
|
|
319
|
+
console.warn(`[CollectionModel/findInValue] unable to find array item with ID "${itemId}" at "${parentPath.join('.')}"`);
|
|
320
|
+
return undefined;
|
|
321
|
+
}
|
|
322
|
+
// or recurse
|
|
323
|
+
else {
|
|
324
|
+
console.debug(`[CollectionModel/findInValue] drilling into item with ID "${itemId}" at "${remainingPath.join('.')}"`, item);
|
|
325
|
+
return this.findInValue(item, Object.assign(Object.assign({}, context), { path: remainingPath, parentPath: [...parentPath, itemId] }));
|
|
326
|
+
}
|
|
327
|
+
}
|
|
328
|
+
// or recurse into an object
|
|
329
|
+
else if (data.type === 'object') {
|
|
330
|
+
// skip if there's no value for the key
|
|
331
|
+
const [entryKey, ...remainingPath] = path;
|
|
332
|
+
const entry = data.value[entryKey];
|
|
333
|
+
if (!entry) {
|
|
334
|
+
console.warn(`[CollectionModel/findInValue] unable to find object entry for key "${entryKey}" at "${parentPath.join('.')}"`);
|
|
335
|
+
return undefined;
|
|
336
|
+
}
|
|
337
|
+
// or recurse
|
|
338
|
+
else {
|
|
339
|
+
return this.findInValue(entry, Object.assign(Object.assign({}, context), { path: remainingPath, parentPath: [...parentPath, entryKey] }));
|
|
340
|
+
}
|
|
341
|
+
}
|
|
342
|
+
// or blow up
|
|
343
|
+
else {
|
|
344
|
+
throw new errors_1.IllegalStateError(`Unable to recurse into value at "${parentPath.join('.')}" for type "${data.type}"`);
|
|
345
|
+
}
|
|
346
|
+
}
|
|
347
|
+
static from(data) {
|
|
348
|
+
return new CollectionModel(data);
|
|
349
|
+
}
|
|
350
|
+
static fromDraft(data) {
|
|
351
|
+
const now = Date.now();
|
|
352
|
+
return new CollectionModel(Object.assign(Object.assign({}, data), { __root: 'collection', id: Collection_1.Collection.Id.draft, fields: {}, files: [], collections: [], errors: true, state: 'draft', createdOn: now, updatedOn: now }));
|
|
353
|
+
}
|
|
354
|
+
}
|
|
355
|
+
exports.CollectionModel = CollectionModel;
|
|
356
|
+
function splitRoot(collection, rootPath) {
|
|
357
|
+
// fail if there are no path elements
|
|
358
|
+
if (rootPath.length === 0) {
|
|
359
|
+
throw new errors_1.ArgumentError('Path elements must have a list one segment');
|
|
360
|
+
}
|
|
361
|
+
// blow up if the root's not the fields (for now - we'll expand later)
|
|
362
|
+
const [rootComponent, ...path] = rootPath;
|
|
363
|
+
if (rootComponent !== 'fields') {
|
|
364
|
+
throw new errors_1.ArgumentError(`Unrecognized Collection root "${rootComponent}"`);
|
|
365
|
+
}
|
|
366
|
+
// return split root
|
|
367
|
+
return {
|
|
368
|
+
root: collection[rootComponent],
|
|
369
|
+
path
|
|
370
|
+
};
|
|
371
|
+
}
|
|
372
|
+
function splitPath(path) {
|
|
373
|
+
// fail if there are no path elements
|
|
374
|
+
if (path.length === 0) {
|
|
375
|
+
throw new errors_1.ArgumentError('Path elements must have a list one segment');
|
|
376
|
+
}
|
|
377
|
+
// split
|
|
378
|
+
const childIndex = path.length - 1;
|
|
379
|
+
return {
|
|
380
|
+
parentPath: path.slice(0, childIndex),
|
|
381
|
+
childKey: path[childIndex]
|
|
382
|
+
};
|
|
383
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { Tagged } from 'type-fest';
|
|
2
|
+
import { RequiredBy } from '../types';
|
|
3
|
+
import type { Collection } from './Collection';
|
|
4
|
+
export type CollectionSnapshot = RequiredBy<Pick<Collection.Data, Exclude<Collection.Data.Props.Id, 'id'> | Collection.Data.Props.Content | 'createdOn' | 'updatedOn' | 'changeSetId'>, 'changeSetId'> & {
|
|
5
|
+
id: CollectionSnapshot.Id;
|
|
6
|
+
};
|
|
7
|
+
export declare namespace CollectionSnapshot {
|
|
8
|
+
type Id = Tagged<string, 'CollectionSnapshot.Id'>;
|
|
9
|
+
type Prop = keyof CollectionSnapshot;
|
|
10
|
+
const props: ReadonlyArray<Prop>;
|
|
11
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.CollectionSnapshot = void 0;
|
|
4
|
+
// extension
|
|
5
|
+
var CollectionSnapshot;
|
|
6
|
+
(function (CollectionSnapshot) {
|
|
7
|
+
CollectionSnapshot.props = [
|
|
8
|
+
'id', 'groupId', 'type', 'brand', 'language', 'version', 'name', 'tags',
|
|
9
|
+
'fields',
|
|
10
|
+
'changeSetId', 'createdOn', 'updatedOn'
|
|
11
|
+
];
|
|
12
|
+
})(CollectionSnapshot || (exports.CollectionSnapshot = CollectionSnapshot = {}));
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { Transform } from '../types';
|
|
2
|
+
import { EnumField, Field, RichTextField, TextField } from './field';
|
|
3
|
+
import { Optional } from './Optional';
|
|
4
|
+
export type Fields = Record<string, Optional.Maybe<Field.Type>>;
|
|
5
|
+
export declare namespace Fields {
|
|
6
|
+
type Required<TFields extends Fields> = {
|
|
7
|
+
[key in keyof TFields as TFields[key] extends _Optional<Field.Type> ? never : key]: TFields[key];
|
|
8
|
+
};
|
|
9
|
+
type Optional<TFields extends Fields> = {
|
|
10
|
+
[key in keyof TFields as TFields[key] extends _Optional<Field.Type> ? key : never]: TFields[key];
|
|
11
|
+
};
|
|
12
|
+
type OptionalKeys<TFields extends Fields> = keyof Optional<TFields>;
|
|
13
|
+
type UnwrapOptional<TFields extends Fields> = {
|
|
14
|
+
[key in keyof TFields]: Optional.InnerType<TFields[key]>;
|
|
15
|
+
};
|
|
16
|
+
type Override<TFields extends Fields> = Transform<TFields, Partial<TFields>>;
|
|
17
|
+
type TextFields<TFields extends Fields> = {
|
|
18
|
+
[key in keyof TFields as TFields[key] extends TextField ? key : TFields[key] extends _Optional<TextField> ? key : never]: TFields[key];
|
|
19
|
+
};
|
|
20
|
+
type StringField = TextField | EnumField;
|
|
21
|
+
type StringFields<TFields extends Fields> = {
|
|
22
|
+
[key in keyof TFields as TFields[key] extends StringField ? key : TFields[key] extends _Optional<StringField> ? key : never]: TFields[key];
|
|
23
|
+
};
|
|
24
|
+
type TextLikeField = TextField | RichTextField | EnumField;
|
|
25
|
+
type TextLikeFields<TFields extends Fields> = {
|
|
26
|
+
[key in keyof TFields as TFields[key] extends TextLikeField ? key : TFields[key] extends _Optional<TextLikeField> ? key : never]: TFields[key];
|
|
27
|
+
};
|
|
28
|
+
function unwrap<TFields extends Fields>(fields: TFields): UnwrapOptional<TFields>;
|
|
29
|
+
}
|
|
30
|
+
type _Optional<T extends Optional.Content> = Optional<T>;
|
|
31
|
+
export {};
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.Fields = void 0;
|
|
4
|
+
const Optional_1 = require("./Optional");
|
|
5
|
+
// extension
|
|
6
|
+
var Fields;
|
|
7
|
+
(function (Fields) {
|
|
8
|
+
// helpers
|
|
9
|
+
function unwrap(fields) {
|
|
10
|
+
return Object.entries(fields).reduce((fields, [key, field]) => {
|
|
11
|
+
// unwrap field
|
|
12
|
+
const { schema } = Optional_1.Optional.unwrap(field);
|
|
13
|
+
// bind it
|
|
14
|
+
const data = fields;
|
|
15
|
+
data[key] = schema;
|
|
16
|
+
// keep reducing
|
|
17
|
+
return fields;
|
|
18
|
+
}, {});
|
|
19
|
+
}
|
|
20
|
+
Fields.unwrap = unwrap;
|
|
21
|
+
})(Fields || (exports.Fields = Fields = {}));
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { BooleanField } from './field';
|
|
2
|
+
import { Fields } from './Fields';
|
|
3
|
+
import { Optional } from './Optional';
|
|
4
|
+
export declare class Form<TFields extends Fields = Fields> {
|
|
5
|
+
readonly name: string;
|
|
6
|
+
readonly description?: string;
|
|
7
|
+
readonly version: number;
|
|
8
|
+
readonly fields: TFields;
|
|
9
|
+
readonly editableFields: Fields.UnwrapOptional<TFields>;
|
|
10
|
+
readonly consentFields?: Fields.UnwrapOptional<Form.ConsentFields>;
|
|
11
|
+
private constructor();
|
|
12
|
+
static create<TFields extends Fields>(args: Form.FactoryArgs<TFields>): Form<TFields>;
|
|
13
|
+
}
|
|
14
|
+
export declare namespace Form {
|
|
15
|
+
type BaseArgs = {
|
|
16
|
+
name: string;
|
|
17
|
+
description?: string;
|
|
18
|
+
version: number;
|
|
19
|
+
};
|
|
20
|
+
export type FactoryArgs<TFields extends Fields> = BaseArgs & {
|
|
21
|
+
fields: TFields;
|
|
22
|
+
consentFields?: ConsentFields;
|
|
23
|
+
};
|
|
24
|
+
export type ConstructorArgs<TFields extends Fields> = BaseArgs & {
|
|
25
|
+
fields: TFields;
|
|
26
|
+
editableFields: Fields.UnwrapOptional<TFields>;
|
|
27
|
+
consentFields?: Fields.UnwrapOptional<ConsentFields>;
|
|
28
|
+
};
|
|
29
|
+
export type ConsentFields = Record<string, Optional.Maybe<BooleanField>>;
|
|
30
|
+
export {};
|
|
31
|
+
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.Form = void 0;
|
|
4
|
+
const Fields_1 = require("./Fields");
|
|
5
|
+
// class
|
|
6
|
+
class Form {
|
|
7
|
+
constructor(args) {
|
|
8
|
+
// initialize instance variables
|
|
9
|
+
this.name = args.name;
|
|
10
|
+
this.description = args.description;
|
|
11
|
+
this.version = args.version;
|
|
12
|
+
this.fields = args.fields;
|
|
13
|
+
this.editableFields = args.editableFields;
|
|
14
|
+
this.consentFields = args.consentFields;
|
|
15
|
+
}
|
|
16
|
+
static create(args) {
|
|
17
|
+
// create new form
|
|
18
|
+
return new Form(Object.assign(Object.assign({}, args), { editableFields: Fields_1.Fields.unwrap(args.fields), consentFields: args.consentFields
|
|
19
|
+
? Fields_1.Fields.unwrap(args.consentFields)
|
|
20
|
+
: undefined }));
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
exports.Form = Form;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { Collection } from './Collection';
|
|
2
|
+
/**
|
|
3
|
+
* Collection model with refs resolved to values
|
|
4
|
+
*/
|
|
5
|
+
export declare class LinkedCollectionModel<TCollection extends Collection> {
|
|
6
|
+
readonly data: Collection.LinkedData<TCollection>;
|
|
7
|
+
constructor(data: Collection.LinkedData<TCollection>);
|
|
8
|
+
static fromCollectionData<TCollection extends Collection>(unlinkedData: Collection.Data<TCollection>): LinkedCollectionModel<TCollection>;
|
|
9
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.LinkedCollectionModel = void 0;
|
|
4
|
+
const LinkedData_1 = require("./LinkedData");
|
|
5
|
+
/**
|
|
6
|
+
* Collection model with refs resolved to values
|
|
7
|
+
*/
|
|
8
|
+
class LinkedCollectionModel {
|
|
9
|
+
constructor(data) {
|
|
10
|
+
this.data = data;
|
|
11
|
+
}
|
|
12
|
+
static fromCollectionData(unlinkedData) {
|
|
13
|
+
// transform
|
|
14
|
+
const linkedData = LinkedData_1.LinkedData.resolveStatic({ unlinkedData });
|
|
15
|
+
// return linked page model
|
|
16
|
+
return new LinkedCollectionModel(linkedData);
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
exports.LinkedCollectionModel = LinkedCollectionModel;
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { Tagged } from 'type-fest';
|
|
2
|
+
import { ReadonlyObjectDeep } from 'type-fest/source/readonly-deep';
|
|
3
|
+
import { Asset } from './Asset';
|
|
4
|
+
import { Collection } from './Collection';
|
|
5
|
+
import { DynamicPagesField, Field } from './field';
|
|
6
|
+
import { Page } from './Page';
|
|
7
|
+
export declare namespace LinkedData {
|
|
8
|
+
/**
|
|
9
|
+
* Link data, only resolving static links
|
|
10
|
+
*/
|
|
11
|
+
function resolveStatic<TLinked>(args: Omit<LinkArgs, 'resolvers'>): TLinked;
|
|
12
|
+
/**
|
|
13
|
+
* Link data, resolving static and dynamic links
|
|
14
|
+
*/
|
|
15
|
+
function resolve<TLinked>(args: LinkArgs): Promise<TLinked>;
|
|
16
|
+
type LinkArgs = {
|
|
17
|
+
unlinkedData: UnlinkedData;
|
|
18
|
+
resolvers: DynamicResolvers;
|
|
19
|
+
persona?: string;
|
|
20
|
+
stores?: TransformFromStores;
|
|
21
|
+
};
|
|
22
|
+
type UnlinkedData = ReadonlyObjectDeep<any>;
|
|
23
|
+
type StaticallyLinkedData = Tagged<UnlinkedData, 'linked.statically'>;
|
|
24
|
+
type TransformFromStores = {
|
|
25
|
+
assets?: ReadonlyArray<Asset.Linked>;
|
|
26
|
+
collections?: ReadonlyArray<Collection.Data.AsLink>;
|
|
27
|
+
};
|
|
28
|
+
type References = {
|
|
29
|
+
pages: Map<Page.Id, Page.Data>;
|
|
30
|
+
collections: Map<Collection.Id, Collection.Data.AsLink>;
|
|
31
|
+
assets: Map<Asset.Id, Asset.Linked>;
|
|
32
|
+
};
|
|
33
|
+
type UnlinkedReferences = {
|
|
34
|
+
pageRefs: Map<Page.Id, Field.Data.Page[]>;
|
|
35
|
+
collectionRefs: Map<Collection.Id, Field.Data.Collection.Ref[]>;
|
|
36
|
+
assetRefs: Map<Asset.Id, Asset[]>;
|
|
37
|
+
dynamicPages: Field.Data.DynamicPages[];
|
|
38
|
+
};
|
|
39
|
+
type PageQuery = DynamicPagesField.Query;
|
|
40
|
+
type PageResolver = (value: PageQuery) => Promise<Page.Data.AsPreview[]>;
|
|
41
|
+
type DynamicResolvers = {
|
|
42
|
+
page: PageResolver;
|
|
43
|
+
};
|
|
44
|
+
}
|