@nascentdigital/funnel-core 4.5.3 → 4.5.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/errors/IsometricError.d.ts +1 -0
- package/dist/errors/IsometricError.js +1 -1
- package/dist/errors/IsometricErrorUtils.js +8 -7
- package/dist/errors/SerializedIsometricError.js +3 -3
- package/dist/errors/api/ApiError.d.ts +1 -1
- package/dist/errors/api/ApiErrors.js +19 -16
- package/dist/errors/api/ArgumentError.js +1 -1
- package/dist/errors/api/ConcurrencyError.js +1 -1
- package/dist/errors/api/ConflictError.js +1 -1
- package/dist/errors/api/DependencyError.js +1 -1
- package/dist/errors/api/IllegalStateError.js +1 -1
- package/dist/errors/api/InvalidOperationError.js +1 -1
- package/dist/errors/api/NotAuthenticatedError.js +1 -1
- package/dist/errors/api/NotAuthorizedError.js +1 -1
- package/dist/errors/api/NotAvailableError.js +1 -1
- package/dist/errors/api/NotFoundError.js +1 -1
- package/dist/errors/api/NotImplementedError.js +1 -1
- package/dist/errors/api/OfflineError.js +1 -1
- package/dist/errors/api/RangeError.js +1 -1
- package/dist/errors/api/ServerError.js +1 -1
- package/dist/errors/api/TimeoutError.js +1 -1
- package/dist/errors/api/index.d.ts +1 -0
- package/dist/errors/api/index.js +1 -0
- package/dist/schema/Site.d.ts +2 -0
- package/dist/schema/Site.js +41 -1
- package/dist/schema/field/base/RichTextField.d.ts +5 -6
- package/dist/schema/field/base/RichTextField.js +3 -39
- package/dist/ui/BlockThemes.d.ts +0 -1
- package/dist/ui/BlockThemes.js +0 -8
- package/dist/ui/FileType.d.ts +1 -1
- package/package.json +2 -2
|
@@ -9,6 +9,7 @@ export declare class IsometricError extends Error {
|
|
|
9
9
|
export declare namespace IsometricError {
|
|
10
10
|
type ConstructorArgs = {
|
|
11
11
|
moduleId: IsometricErrorModule.Id;
|
|
12
|
+
name: string;
|
|
12
13
|
message: string;
|
|
13
14
|
cause?: Error | undefined;
|
|
14
15
|
trace?: ((...args: any) => any) | undefined;
|
|
@@ -10,7 +10,7 @@ class IsometricError extends Error {
|
|
|
10
10
|
Object.setPrototypeOf(this, new.target.prototype);
|
|
11
11
|
// bind properties
|
|
12
12
|
const object = this;
|
|
13
|
-
this.name = object.constructor.name;
|
|
13
|
+
this.name = args.name || object.constructor.name;
|
|
14
14
|
this.moduleId = args.moduleId;
|
|
15
15
|
this.cause = args.cause;
|
|
16
16
|
// bind stack trace (if provided)
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.IsometricErrorUtils = void 0;
|
|
4
|
-
const
|
|
4
|
+
const utils_1 = require("../utils");
|
|
5
5
|
const api_1 = require("./api");
|
|
6
6
|
const IsometricError_1 = require("./IsometricError");
|
|
7
7
|
const SerializedIsometricError_1 = require("./SerializedIsometricError");
|
|
@@ -13,6 +13,7 @@ var IsometricErrorUtils;
|
|
|
13
13
|
// methods
|
|
14
14
|
function registerModule(ModuleClass) {
|
|
15
15
|
const module = new ModuleClass();
|
|
16
|
+
console.debug('registering new module', module);
|
|
16
17
|
modules.set(module.id, module);
|
|
17
18
|
}
|
|
18
19
|
IsometricErrorUtils.registerModule = registerModule;
|
|
@@ -34,17 +35,17 @@ var IsometricErrorUtils;
|
|
|
34
35
|
function deserializeError(data) {
|
|
35
36
|
// skip if it's not isometric
|
|
36
37
|
if (!SerializedIsometricError_1.SerializedIsometricError.filter(data)) {
|
|
37
|
-
console.debug('
|
|
38
|
+
console.debug('deserializeError: data is not an error', data);
|
|
38
39
|
return undefined;
|
|
39
40
|
}
|
|
40
41
|
// or skip if there's no registered module
|
|
41
42
|
const module = modules.get(data.moduleId);
|
|
42
43
|
if (!module) {
|
|
43
|
-
console.
|
|
44
|
+
console.warn('deserializeError: module not found', data.moduleId);
|
|
44
45
|
return undefined;
|
|
45
46
|
}
|
|
46
47
|
const error = module.deserialize(data);
|
|
47
|
-
console.debug('
|
|
48
|
+
console.debug('deserializeError: parsed error', { module, error });
|
|
48
49
|
// deserialize
|
|
49
50
|
return error;
|
|
50
51
|
}
|
|
@@ -56,7 +57,7 @@ var IsometricErrorUtils;
|
|
|
56
57
|
return;
|
|
57
58
|
}
|
|
58
59
|
const { bodyUsed, headers, type } = response;
|
|
59
|
-
console.debug('
|
|
60
|
+
console.debug('checkResponse: handling error', { type, bodyUsed, headers });
|
|
60
61
|
// throw network error if the request didn't even go through
|
|
61
62
|
let error;
|
|
62
63
|
if (response.type === 'error') {
|
|
@@ -65,11 +66,11 @@ var IsometricErrorUtils;
|
|
|
65
66
|
// or try to extract from json
|
|
66
67
|
else {
|
|
67
68
|
const json = await response.json();
|
|
68
|
-
console.debug('
|
|
69
|
+
console.debug('checkResponse: transforming error', {
|
|
69
70
|
json,
|
|
70
71
|
isIso: SerializedIsometricError_1.SerializedIsometricError.filter(json.error)
|
|
71
72
|
});
|
|
72
|
-
const { error: errorData } =
|
|
73
|
+
const { error: errorData } = utils_1.Value.typeOf(json) === 'object'
|
|
73
74
|
? json
|
|
74
75
|
: {};
|
|
75
76
|
error = (_a = deserializeError(errorData)) !== null && _a !== void 0 ? _a : new api_1.ServerError();
|
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.SerializedIsometricError = void 0;
|
|
4
|
-
const
|
|
4
|
+
const utils_1 = require("../utils");
|
|
5
5
|
// extension
|
|
6
6
|
var SerializedIsometricError;
|
|
7
7
|
(function (SerializedIsometricError) {
|
|
8
8
|
// guard
|
|
9
9
|
function filter(value) {
|
|
10
|
-
return
|
|
10
|
+
return utils_1.Value.typeOf(value) === 'object'
|
|
11
11
|
&& 'moduleId' in value
|
|
12
|
-
&&
|
|
12
|
+
&& utils_1.Value.typeOf(value.moduleId) === 'string';
|
|
13
13
|
}
|
|
14
14
|
SerializedIsometricError.filter = filter;
|
|
15
15
|
})(SerializedIsometricError || (exports.SerializedIsometricError = SerializedIsometricError = {}));
|
|
@@ -11,5 +11,5 @@ export declare namespace ApiError {
|
|
|
11
11
|
type ConstructorArgs = IsometricError.ConstructorArgs.WithoutModuleId & {
|
|
12
12
|
status: number;
|
|
13
13
|
};
|
|
14
|
-
type Options = Omit<ConstructorArgs, 'status' | 'message'>;
|
|
14
|
+
type Options = Omit<ConstructorArgs, 'name' | 'status' | 'message'>;
|
|
15
15
|
}
|
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.ApiErrors = void 0;
|
|
4
|
-
const
|
|
4
|
+
const utils_1 = require("../../utils");
|
|
5
5
|
const ApiError_1 = require("./ApiError");
|
|
6
6
|
const ArgumentError_1 = require("./ArgumentError");
|
|
7
|
+
const ConcurrencyError_1 = require("./ConcurrencyError");
|
|
7
8
|
const ConflictError_1 = require("./ConflictError");
|
|
8
9
|
const DependencyError_1 = require("./DependencyError");
|
|
9
10
|
const IllegalStateError_1 = require("./IllegalStateError");
|
|
@@ -30,33 +31,35 @@ class ApiErrors {
|
|
|
30
31
|
// convert
|
|
31
32
|
switch (data.name) {
|
|
32
33
|
// re-hydrate error
|
|
33
|
-
case
|
|
34
|
-
return new ArgumentError_1.ArgumentError(data.message,
|
|
35
|
-
case
|
|
34
|
+
case 'ArgumentError':
|
|
35
|
+
return new ArgumentError_1.ArgumentError(data.message, utils_1.Value.parseString(data.argumentName));
|
|
36
|
+
case 'ConcurrencyError':
|
|
37
|
+
return new ConcurrencyError_1.ConcurrencyError(data.message);
|
|
38
|
+
case 'ConflictError':
|
|
36
39
|
return new ConflictError_1.ConflictError(data.message);
|
|
37
|
-
case
|
|
40
|
+
case 'DependencyError':
|
|
38
41
|
return new DependencyError_1.DependencyError(data.message);
|
|
39
|
-
case
|
|
42
|
+
case 'IllegalStateError':
|
|
40
43
|
return new IllegalStateError_1.IllegalStateError(data.message);
|
|
41
|
-
case
|
|
44
|
+
case 'InvalidOperationError':
|
|
42
45
|
return new InvalidOperationError_1.InvalidOperationError(data.message);
|
|
43
|
-
case
|
|
46
|
+
case 'NotAuthenticatedError':
|
|
44
47
|
return new NotAuthenticatedError_1.NotAuthenticatedError(data.message);
|
|
45
|
-
case
|
|
48
|
+
case 'NotAuthorizedError':
|
|
46
49
|
return new NotAuthorizedError_1.NotAuthorizedError(data.message);
|
|
47
|
-
case
|
|
50
|
+
case 'NotAvailableError':
|
|
48
51
|
return new NotAvailableError_1.NotAvailableError(data.message);
|
|
49
|
-
case
|
|
52
|
+
case 'NotFoundError':
|
|
50
53
|
return new NotFoundError_1.NotFoundError(data.message);
|
|
51
|
-
case
|
|
54
|
+
case 'NotImplementedError':
|
|
52
55
|
return new NotImplementedError_1.NotImplementedError(data.message);
|
|
53
|
-
case
|
|
56
|
+
case 'OfflineError':
|
|
54
57
|
return new OfflineError_1.OfflineError(data.message);
|
|
55
|
-
case
|
|
58
|
+
case 'RangeError':
|
|
56
59
|
return new RangeError_1.RangeError(data.message);
|
|
57
|
-
case
|
|
60
|
+
case 'ServerError':
|
|
58
61
|
return new ServerError_1.ServerError(data.message);
|
|
59
|
-
case
|
|
62
|
+
case 'TimeoutError':
|
|
60
63
|
return new TimeoutError_1.TimeoutError(data.message);
|
|
61
64
|
// or ignore if not matching
|
|
62
65
|
default:
|
|
@@ -6,7 +6,7 @@ const ApiError_1 = require("./ApiError");
|
|
|
6
6
|
class ArgumentError extends ApiError_1.ApiError {
|
|
7
7
|
constructor(message = 'Invalid arguments', argumentName, options = {}) {
|
|
8
8
|
// construct base
|
|
9
|
-
super(Object.assign({ status: 400, message }, options));
|
|
9
|
+
super(Object.assign({ name: 'ArgumentError', status: 400, message }, options));
|
|
10
10
|
// capture argument
|
|
11
11
|
this.argumentName = argumentName;
|
|
12
12
|
}
|
|
@@ -5,7 +5,7 @@ const ApiError_1 = require("./ApiError");
|
|
|
5
5
|
// error
|
|
6
6
|
class ConcurrencyError extends ApiError_1.ApiError {
|
|
7
7
|
constructor(message = 'Concurrency error', options = {}) {
|
|
8
|
-
super(Object.assign({ status: 423, message }, options));
|
|
8
|
+
super(Object.assign({ name: 'ConcurrencyError', status: 423, message }, options));
|
|
9
9
|
}
|
|
10
10
|
}
|
|
11
11
|
exports.ConcurrencyError = ConcurrencyError;
|
|
@@ -5,7 +5,7 @@ const ApiError_1 = require("./ApiError");
|
|
|
5
5
|
// error
|
|
6
6
|
class ConflictError extends ApiError_1.ApiError {
|
|
7
7
|
constructor(message = 'A conflict is preventing this operation from succeeding', options = {}) {
|
|
8
|
-
super(Object.assign({ status: 409, message }, options));
|
|
8
|
+
super(Object.assign({ name: 'ConflictError', status: 409, message }, options));
|
|
9
9
|
}
|
|
10
10
|
}
|
|
11
11
|
exports.ConflictError = ConflictError;
|
|
@@ -5,7 +5,7 @@ const ApiError_1 = require("./ApiError");
|
|
|
5
5
|
// error
|
|
6
6
|
class DependencyError extends ApiError_1.ApiError {
|
|
7
7
|
constructor(message = 'Upstream operation failed', options = {}) {
|
|
8
|
-
super(Object.assign({ status: 424, message }, options));
|
|
8
|
+
super(Object.assign({ name: 'DependencyError', status: 424, message }, options));
|
|
9
9
|
}
|
|
10
10
|
}
|
|
11
11
|
exports.DependencyError = DependencyError;
|
|
@@ -5,7 +5,7 @@ const ApiError_1 = require("./ApiError");
|
|
|
5
5
|
// error
|
|
6
6
|
class IllegalStateError extends ApiError_1.ApiError {
|
|
7
7
|
constructor(message = 'Preconditions not met', options = {}) {
|
|
8
|
-
super(Object.assign({ status: 412, message }, options));
|
|
8
|
+
super(Object.assign({ name: 'IllegalStateError', status: 412, message }, options));
|
|
9
9
|
}
|
|
10
10
|
}
|
|
11
11
|
exports.IllegalStateError = IllegalStateError;
|
|
@@ -5,7 +5,7 @@ const ApiError_1 = require("./ApiError");
|
|
|
5
5
|
// error
|
|
6
6
|
class InvalidOperationError extends ApiError_1.ApiError {
|
|
7
7
|
constructor(message = 'Invalid operation', options = {}) {
|
|
8
|
-
super(Object.assign({ status: 405, message }, options));
|
|
8
|
+
super(Object.assign({ name: 'InvalidOperationError', status: 405, message }, options));
|
|
9
9
|
}
|
|
10
10
|
}
|
|
11
11
|
exports.InvalidOperationError = InvalidOperationError;
|
|
@@ -5,7 +5,7 @@ const ApiError_1 = require("./ApiError");
|
|
|
5
5
|
// error
|
|
6
6
|
class NotAuthenticatedError extends ApiError_1.ApiError {
|
|
7
7
|
constructor(message = 'Authentication is invalid or missing', options = {}) {
|
|
8
|
-
super(Object.assign({ status: 401, message }, options));
|
|
8
|
+
super(Object.assign({ name: 'NotAuthenticatedError', status: 401, message }, options));
|
|
9
9
|
}
|
|
10
10
|
}
|
|
11
11
|
exports.NotAuthenticatedError = NotAuthenticatedError;
|
|
@@ -5,7 +5,7 @@ const ApiError_1 = require("./ApiError");
|
|
|
5
5
|
// error
|
|
6
6
|
class NotAuthorizedError extends ApiError_1.ApiError {
|
|
7
7
|
constructor(message = 'User does not have permissions for this method', options = {}) {
|
|
8
|
-
super(Object.assign({ status: 403, message }, options));
|
|
8
|
+
super(Object.assign({ name: 'NotAuthorizedError', status: 403, message }, options));
|
|
9
9
|
}
|
|
10
10
|
}
|
|
11
11
|
exports.NotAuthorizedError = NotAuthorizedError;
|
|
@@ -5,7 +5,7 @@ const ApiError_1 = require("./ApiError");
|
|
|
5
5
|
// error
|
|
6
6
|
class NotAvailableError extends ApiError_1.ApiError {
|
|
7
7
|
constructor(message = 'Not available', options = {}) {
|
|
8
|
-
super(Object.assign({ status: 503, message }, options));
|
|
8
|
+
super(Object.assign({ name: 'NotAvailableError', status: 503, message }, options));
|
|
9
9
|
}
|
|
10
10
|
}
|
|
11
11
|
exports.NotAvailableError = NotAvailableError;
|
|
@@ -5,7 +5,7 @@ const ApiError_1 = require("./ApiError");
|
|
|
5
5
|
// error
|
|
6
6
|
class NotFoundError extends ApiError_1.ApiError {
|
|
7
7
|
constructor(message = 'Not found', options = {}) {
|
|
8
|
-
super(Object.assign({ status: 404, message }, options));
|
|
8
|
+
super(Object.assign({ name: 'NotFoundError', status: 404, message }, options));
|
|
9
9
|
}
|
|
10
10
|
}
|
|
11
11
|
exports.NotFoundError = NotFoundError;
|
|
@@ -5,7 +5,7 @@ const ApiError_1 = require("./ApiError");
|
|
|
5
5
|
// error
|
|
6
6
|
class NotImplementedError extends ApiError_1.ApiError {
|
|
7
7
|
constructor(message = 'Not implemented', options = {}) {
|
|
8
|
-
super(Object.assign({ status: 501, message }, options));
|
|
8
|
+
super(Object.assign({ name: 'NotImplementedError', status: 501, message }, options));
|
|
9
9
|
}
|
|
10
10
|
}
|
|
11
11
|
exports.NotImplementedError = NotImplementedError;
|
|
@@ -5,7 +5,7 @@ const ApiError_1 = require("./ApiError");
|
|
|
5
5
|
// error
|
|
6
6
|
class OfflineError extends ApiError_1.ApiError {
|
|
7
7
|
constructor(message = 'Unable to connect to network', options = {}) {
|
|
8
|
-
super(Object.assign({ status: 0, message }, options));
|
|
8
|
+
super(Object.assign({ name: 'OfflineError', status: 0, message }, options));
|
|
9
9
|
}
|
|
10
10
|
}
|
|
11
11
|
exports.OfflineError = OfflineError;
|
|
@@ -5,7 +5,7 @@ const ApiError_1 = require("./ApiError");
|
|
|
5
5
|
// error
|
|
6
6
|
class RangeError extends ApiError_1.ApiError {
|
|
7
7
|
constructor(message = 'Invalid range', options = {}) {
|
|
8
|
-
super(Object.assign({ status: 416, message }, options));
|
|
8
|
+
super(Object.assign({ name: 'RangeError', status: 416, message }, options));
|
|
9
9
|
}
|
|
10
10
|
}
|
|
11
11
|
exports.RangeError = RangeError;
|
|
@@ -5,7 +5,7 @@ const ApiError_1 = require("./ApiError");
|
|
|
5
5
|
// error
|
|
6
6
|
class ServerError extends ApiError_1.ApiError {
|
|
7
7
|
constructor(message = 'Server error', options = {}) {
|
|
8
|
-
super(Object.assign({ status: 500, message }, options));
|
|
8
|
+
super(Object.assign({ name: 'ServerError', status: 500, message }, options));
|
|
9
9
|
}
|
|
10
10
|
}
|
|
11
11
|
exports.ServerError = ServerError;
|
|
@@ -5,7 +5,7 @@ const ApiError_1 = require("./ApiError");
|
|
|
5
5
|
// error
|
|
6
6
|
class TimeoutError extends ApiError_1.ApiError {
|
|
7
7
|
constructor(message = 'Timeout', options = {}) {
|
|
8
|
-
super(Object.assign({ status: 408, message }, options));
|
|
8
|
+
super(Object.assign({ name: 'TimeoutError', status: 408, message }, options));
|
|
9
9
|
}
|
|
10
10
|
}
|
|
11
11
|
exports.TimeoutError = TimeoutError;
|
package/dist/errors/api/index.js
CHANGED
|
@@ -17,6 +17,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
17
17
|
__exportStar(require("./ApiError"), exports);
|
|
18
18
|
__exportStar(require("./ApiErrors"), exports);
|
|
19
19
|
__exportStar(require("./ArgumentError"), exports);
|
|
20
|
+
__exportStar(require("./ConcurrencyError"), exports);
|
|
20
21
|
__exportStar(require("./ConflictError"), exports);
|
|
21
22
|
__exportStar(require("./DependencyError"), exports);
|
|
22
23
|
__exportStar(require("./IllegalStateError"), exports);
|
package/dist/schema/Site.d.ts
CHANGED
|
@@ -37,4 +37,6 @@ export declare namespace Site {
|
|
|
37
37
|
function forSite(site: Site): Data;
|
|
38
38
|
function toSiteModel(data: Data): SiteModel;
|
|
39
39
|
}
|
|
40
|
+
function extractCollectionsFrom<TRegions extends Regions>(regions: Site.CreateArgs<TRegions>): Collection[];
|
|
41
|
+
function uniqueCollections(collections: ReadonlyArray<Collection>): Collection[];
|
|
40
42
|
}
|
package/dist/schema/Site.js
CHANGED
|
@@ -2,6 +2,8 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.Site = void 0;
|
|
4
4
|
const errors_1 = require("../errors");
|
|
5
|
+
const utils_1 = require("../utils");
|
|
6
|
+
const field_1 = require("./field");
|
|
5
7
|
const SiteModel_1 = require("./SiteModel");
|
|
6
8
|
// class
|
|
7
9
|
class Site {
|
|
@@ -16,8 +18,13 @@ class Site {
|
|
|
16
18
|
return Site.Data.forSite(this);
|
|
17
19
|
}
|
|
18
20
|
static create(regions, collections = []) {
|
|
21
|
+
// extract collections from regions schema
|
|
22
|
+
const collectionsFromSchema = Site.extractCollectionsFrom(regions);
|
|
19
23
|
// create new Site
|
|
20
|
-
const site = new Site({
|
|
24
|
+
const site = new Site({
|
|
25
|
+
regions,
|
|
26
|
+
collections: Site.uniqueCollections([...collections, ...collectionsFromSchema])
|
|
27
|
+
});
|
|
21
28
|
// bind site
|
|
22
29
|
this._site = site;
|
|
23
30
|
// return site
|
|
@@ -84,4 +91,37 @@ exports.Site = Site;
|
|
|
84
91
|
}
|
|
85
92
|
Data.toSiteModel = toSiteModel;
|
|
86
93
|
})(Data = Site.Data || (Site.Data = {}));
|
|
94
|
+
// helpers
|
|
95
|
+
function extractCollectionsFrom(regions) {
|
|
96
|
+
// extract collections from regions schema
|
|
97
|
+
const collections = [];
|
|
98
|
+
utils_1.ObjectUtils.walk(regions, ({ value }) => {
|
|
99
|
+
// look for collection fields
|
|
100
|
+
if (value instanceof field_1.CollectionField) {
|
|
101
|
+
collections.push(...value.collections);
|
|
102
|
+
// don't recurse
|
|
103
|
+
return false;
|
|
104
|
+
}
|
|
105
|
+
// otherwise keep recursing
|
|
106
|
+
return true;
|
|
107
|
+
});
|
|
108
|
+
// return
|
|
109
|
+
return collections;
|
|
110
|
+
}
|
|
111
|
+
Site.extractCollectionsFrom = extractCollectionsFrom;
|
|
112
|
+
function uniqueCollections(collections) {
|
|
113
|
+
// setup
|
|
114
|
+
const uniqueCollections = [];
|
|
115
|
+
const collectionTypes = new Set();
|
|
116
|
+
collections.forEach(collection => {
|
|
117
|
+
// add to unique collections if type doesn't exist in set
|
|
118
|
+
if (!collectionTypes.has(collection.type)) {
|
|
119
|
+
uniqueCollections.push(collection);
|
|
120
|
+
collectionTypes.add(collection.type);
|
|
121
|
+
}
|
|
122
|
+
});
|
|
123
|
+
// return unique collections
|
|
124
|
+
return uniqueCollections;
|
|
125
|
+
}
|
|
126
|
+
Site.uniqueCollections = uniqueCollections;
|
|
87
127
|
})(Site || (exports.Site = Site = {}));
|
|
@@ -3,10 +3,10 @@ import { Tagged } from 'type-fest';
|
|
|
3
3
|
import { Field } from '../index';
|
|
4
4
|
export declare class RichTextField extends Field<RichTextField> {
|
|
5
5
|
readonly type: "richtext";
|
|
6
|
+
readonly semantics: RichTextField.Semantics;
|
|
6
7
|
readonly capabilities: Readonly<RichTextField.Capabilities.Options>;
|
|
7
8
|
readonly minLength?: number;
|
|
8
9
|
readonly maxLength?: number;
|
|
9
|
-
readonly size: RichTextField.Size;
|
|
10
10
|
constructor(args: RichTextField.ConstructorArgs);
|
|
11
11
|
modify({ capabilities, ...args }: RichTextField.ModifyArgs): RichTextField;
|
|
12
12
|
}
|
|
@@ -20,9 +20,9 @@ export declare namespace RichTextField {
|
|
|
20
20
|
function toData(value: Value): Field.Data<RichTextField>;
|
|
21
21
|
function isEmpty(value: Value | undefined): boolean;
|
|
22
22
|
}
|
|
23
|
-
type
|
|
23
|
+
type Semantics = 'field' | 'area' | 'mini-editor' | 'full-editor';
|
|
24
|
+
type Capabilities = Partial<Capabilities.Options>;
|
|
24
25
|
namespace Capabilities {
|
|
25
|
-
type Preset = 'l1' | 'l2' | 'l3';
|
|
26
26
|
type Headings = Partial<Record<Heading, string>>;
|
|
27
27
|
namespace Headings {
|
|
28
28
|
const defaults: Readonly<Headings>;
|
|
@@ -58,14 +58,13 @@ export declare namespace RichTextField {
|
|
|
58
58
|
const article: Options;
|
|
59
59
|
const full: Options;
|
|
60
60
|
}
|
|
61
|
-
function parse(options:
|
|
61
|
+
function parse(options: Partial<Options>): Options;
|
|
62
62
|
}
|
|
63
63
|
type ConstructorArgs = Field.ConstructorArgs & {
|
|
64
|
+
semantics: Semantics;
|
|
64
65
|
capabilities: Capabilities;
|
|
65
66
|
minLength?: number;
|
|
66
67
|
maxLength?: number;
|
|
67
|
-
size?: Size;
|
|
68
68
|
};
|
|
69
|
-
type Size = 'sm' | 'md' | 'lg';
|
|
70
69
|
type ModifyArgs = Omit<Partial<ConstructorArgs>, 'required'>;
|
|
71
70
|
}
|
|
@@ -20,19 +20,14 @@ class RichTextField extends index_1.Field {
|
|
|
20
20
|
super(args);
|
|
21
21
|
this.type = 'richtext';
|
|
22
22
|
// initialize instance variables
|
|
23
|
+
this.semantics = args.semantics;
|
|
23
24
|
this.capabilities = RichTextField.Capabilities.parse(args.capabilities);
|
|
24
25
|
this.minLength = args.minLength;
|
|
25
26
|
this.maxLength = args.maxLength;
|
|
26
|
-
const intrinsicSize = getSize(args.capabilities);
|
|
27
|
-
this.size = !args.size || intrinsicSize === 'lg'
|
|
28
|
-
? intrinsicSize
|
|
29
|
-
: args.size;
|
|
30
27
|
}
|
|
31
28
|
modify(_a) {
|
|
32
29
|
var { capabilities = {} } = _a, args = __rest(_a, ["capabilities"]);
|
|
33
|
-
return new RichTextField(Object.assign(
|
|
34
|
-
? RichTextField.Capabilities.parse(capabilities)
|
|
35
|
-
: Object.assign(Object.assign({}, this.capabilities), capabilities) }));
|
|
30
|
+
return new RichTextField(Object.assign({ name: this.name, hint: this.hint, description: this.description, semantics: this.semantics, capabilities: Object.assign(Object.assign({}, this.capabilities), capabilities), required: this.required, minLength: this.minLength, maxLength: this.maxLength }, args));
|
|
36
31
|
}
|
|
37
32
|
}
|
|
38
33
|
exports.RichTextField = RichTextField;
|
|
@@ -158,39 +153,8 @@ exports.RichTextField = RichTextField;
|
|
|
158
153
|
})(Options = Capabilities.Options || (Capabilities.Options = {}));
|
|
159
154
|
// helpers
|
|
160
155
|
function parse(options) {
|
|
161
|
-
|
|
162
|
-
case 'l1':
|
|
163
|
-
return Object.assign(Object.assign({}, Options.minimal), { bold: true, italics: true, underline: true, superscript: true, subscript: true });
|
|
164
|
-
case 'l2':
|
|
165
|
-
return Object.assign(Object.assign({}, Options.minimal), { bold: true, italics: true, underline: true, superscript: true, subscript: true, links: true });
|
|
166
|
-
case 'l3':
|
|
167
|
-
return Object.assign(Object.assign({}, Options.minimal), { bold: true, italics: true, underline: true, strikethrough: true, superscript: true, subscript: true, links: true, headings: Headings.defaults, lists: true, quotes: true, hr: true });
|
|
168
|
-
default:
|
|
169
|
-
return Object.assign(Object.assign({}, Options.minimal), options);
|
|
170
|
-
}
|
|
156
|
+
return Object.assign(Object.assign({}, Options.minimal), options);
|
|
171
157
|
}
|
|
172
158
|
Capabilities.parse = parse;
|
|
173
159
|
})(Capabilities = RichTextField.Capabilities || (RichTextField.Capabilities = {}));
|
|
174
160
|
})(RichTextField || (exports.RichTextField = RichTextField = {}));
|
|
175
|
-
// helpers
|
|
176
|
-
function getSize(capabilities) {
|
|
177
|
-
// go with default scaling (if applicable)
|
|
178
|
-
if (capabilities === 'l1') {
|
|
179
|
-
return 'sm';
|
|
180
|
-
}
|
|
181
|
-
else if (capabilities === 'l2') {
|
|
182
|
-
return 'md';
|
|
183
|
-
}
|
|
184
|
-
else if (capabilities === 'l3') {
|
|
185
|
-
return 'lg';
|
|
186
|
-
}
|
|
187
|
-
// or large if there are lists/breaks
|
|
188
|
-
const { headings, lists, quotes, hr } = capabilities;
|
|
189
|
-
if (headings || lists || quotes || hr) {
|
|
190
|
-
return 'lg';
|
|
191
|
-
}
|
|
192
|
-
// otherwise, small
|
|
193
|
-
else {
|
|
194
|
-
return 'sm';
|
|
195
|
-
}
|
|
196
|
-
}
|
package/dist/ui/BlockThemes.d.ts
CHANGED
|
@@ -15,5 +15,4 @@ export declare namespace BlockThemes {
|
|
|
15
15
|
type Options = Record<Theme.Extended, Option>;
|
|
16
16
|
function current(): Readonly<Options>;
|
|
17
17
|
function set<TTheme extends string = string>(themes: PartialBy<BlockThemes, 'default'>): void;
|
|
18
|
-
function getClassName(theme: Theme): string;
|
|
19
18
|
}
|
package/dist/ui/BlockThemes.js
CHANGED
|
@@ -13,14 +13,6 @@ var BlockThemes;
|
|
|
13
13
|
_themes = Object.assign(Object.assign({}, _default), themes);
|
|
14
14
|
}
|
|
15
15
|
BlockThemes.set = set;
|
|
16
|
-
function getClassName(theme) {
|
|
17
|
-
var _a;
|
|
18
|
-
// get entry
|
|
19
|
-
const { group = 'default' } = (_a = _themes[theme]) !== null && _a !== void 0 ? _a : {};
|
|
20
|
-
// render
|
|
21
|
-
return `nd-theme-${theme} nd-themeGroup-${group}`;
|
|
22
|
-
}
|
|
23
|
-
BlockThemes.getClassName = getClassName;
|
|
24
16
|
})(BlockThemes || (exports.BlockThemes = BlockThemes = {}));
|
|
25
17
|
// constants
|
|
26
18
|
const _default = {
|
package/dist/ui/FileType.d.ts
CHANGED
|
@@ -3,6 +3,6 @@ export type FileType = 'image' | 'video' | 'icon' | 'audio' | 'document' | 'othe
|
|
|
3
3
|
export declare namespace FileType {
|
|
4
4
|
const values: ReadonlyArray<FileType>;
|
|
5
5
|
function coerce(mimeType: MimeType): FileType;
|
|
6
|
-
function compare(lhs: FileType, rhs: FileType):
|
|
6
|
+
function compare(lhs: FileType, rhs: FileType): 1 | 0 | -1;
|
|
7
7
|
function filter(value: any): value is FileType;
|
|
8
8
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nascentdigital/funnel-core",
|
|
3
|
-
"version": "4.5.
|
|
3
|
+
"version": "4.5.4",
|
|
4
4
|
"repository": {
|
|
5
5
|
"url": "git+https://github.com/nascentdigital/funnel.git",
|
|
6
6
|
"directory": "libs/core"
|
|
@@ -65,5 +65,5 @@
|
|
|
65
65
|
"jest-tsd": "^0.2.2",
|
|
66
66
|
"ts-jest": "^29.3.2"
|
|
67
67
|
},
|
|
68
|
-
"gitHead": "
|
|
68
|
+
"gitHead": "d3d65564e0935e40c8b1e441316b63a126516bca"
|
|
69
69
|
}
|