@defra/forms-model 3.0.9 → 3.0.11
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/browser/components/component-types.js +201 -219
- package/dist/browser/components/component-types.js.map +1 -1
- package/dist/browser/components/conditional-component-types.js +9 -27
- package/dist/browser/components/conditional-component-types.js.map +1 -1
- package/dist/browser/components/enums.js +27 -45
- package/dist/browser/components/enums.js.map +1 -1
- package/dist/browser/components/index.js +3 -35
- package/dist/browser/components/index.js.map +1 -1
- package/dist/browser/components/types.js +1 -15
- package/dist/browser/conditions/condition-abstract.js +42 -60
- package/dist/browser/conditions/condition-abstract.js.map +1 -1
- package/dist/browser/conditions/condition-field.js +23 -41
- package/dist/browser/conditions/condition-field.js.map +1 -1
- package/dist/browser/conditions/condition-group-def.js +23 -42
- package/dist/browser/conditions/condition-group-def.js.map +1 -1
- package/dist/browser/conditions/condition-group.js +43 -61
- package/dist/browser/conditions/condition-group.js.map +1 -1
- package/dist/browser/conditions/condition-model.js +185 -196
- package/dist/browser/conditions/condition-model.js.map +1 -1
- package/dist/browser/conditions/condition-operators.js +103 -124
- package/dist/browser/conditions/condition-operators.js.map +1 -1
- package/dist/browser/conditions/condition-ref.js +29 -47
- package/dist/browser/conditions/condition-ref.js.map +1 -1
- package/dist/browser/conditions/condition-value-abstract.js +19 -37
- package/dist/browser/conditions/condition-value-abstract.js.map +1 -1
- package/dist/browser/conditions/condition-value-registration.js +15 -34
- package/dist/browser/conditions/condition-value-registration.js.map +1 -1
- package/dist/browser/conditions/condition-values.js +98 -118
- package/dist/browser/conditions/condition-values.js.map +1 -1
- package/dist/browser/conditions/condition.js +36 -51
- package/dist/browser/conditions/condition.js.map +1 -1
- package/dist/browser/conditions/enums.js +5 -23
- package/dist/browser/conditions/enums.js.map +1 -1
- package/dist/browser/conditions/helpers.js +6 -25
- package/dist/browser/conditions/helpers.js.map +1 -1
- package/dist/browser/conditions/index.js +10 -143
- package/dist/browser/conditions/index.js.map +1 -1
- package/dist/browser/conditions/inline-condition-model.js +372 -394
- package/dist/browser/conditions/inline-condition-model.js.map +1 -1
- package/dist/browser/conditions/inline-condition-operators.js +103 -124
- package/dist/browser/conditions/inline-condition-operators.js.map +1 -1
- package/dist/browser/conditions/inline-condition-values.js +123 -145
- package/dist/browser/conditions/inline-condition-values.js.map +1 -1
- package/dist/browser/conditions/types.js +1 -15
- package/dist/browser/conditions/types.js.map +1 -1
- package/dist/browser/data-model/conditions-wrapper.js +27 -45
- package/dist/browser/data-model/conditions-wrapper.js.map +1 -1
- package/dist/browser/data-model/enums.js +6 -24
- package/dist/browser/data-model/enums.js.map +1 -1
- package/dist/browser/data-model/index.js +3 -35
- package/dist/browser/data-model/index.js.map +1 -1
- package/dist/browser/data-model/input-wrapper.js +28 -46
- package/dist/browser/data-model/input-wrapper.js.map +1 -1
- package/dist/browser/data-model/types.js +7 -25
- package/dist/browser/data-model/types.js.map +1 -1
- package/dist/browser/form/form-configuration.js +16 -35
- package/dist/browser/form/form-configuration.js.map +1 -1
- package/dist/browser/form/index.js +1 -23
- package/dist/browser/form/index.js.map +1 -1
- package/dist/browser/index.js +8 -97
- package/dist/browser/index.js.map +1 -1
- package/dist/browser/migration/index.js +1 -23
- package/dist/browser/migration/index.js.map +1 -1
- package/dist/browser/migration/migration.0-2.js +42 -60
- package/dist/browser/migration/migration.0-2.js.map +1 -1
- package/dist/browser/migration/migration.1-2.js +83 -99
- package/dist/browser/migration/migration.1-2.js.map +1 -1
- package/dist/browser/migration/types.js +1 -15
- package/dist/browser/migration/whichMigrations.js +20 -36
- package/dist/browser/migration/whichMigrations.js.map +1 -1
- package/dist/browser/schema/index.js +1 -29
- package/dist/browser/schema/index.js.map +1 -1
- package/dist/browser/schema/schema.js +231 -249
- package/dist/browser/schema/schema.js.map +1 -1
- package/dist/browser/utils/helpers.js +22 -43
- package/dist/browser/utils/helpers.js.map +1 -1
- package/dist/browser/utils/logger.js +24 -43
- package/dist/browser/utils/logger.js.map +1 -1
- package/dist/module/components/component-types.js +1 -5
- package/dist/module/components/component-types.js.map +1 -1
- package/dist/module/components/conditional-component-types.js +1 -5
- package/dist/module/components/conditional-component-types.js.map +1 -1
- package/dist/module/components/enums.js +1 -5
- package/dist/module/components/enums.js.map +1 -1
- package/dist/module/components/index.js +3 -24
- package/dist/module/components/index.js.map +1 -1
- package/dist/module/components/types.js +2 -1
- package/dist/module/conditions/condition-abstract.js +3 -8
- package/dist/module/conditions/condition-abstract.js.map +1 -1
- package/dist/module/conditions/condition-field.js +3 -8
- package/dist/module/conditions/condition-field.js.map +1 -1
- package/dist/module/conditions/condition-group-def.js +1 -6
- package/dist/module/conditions/condition-group-def.js.map +1 -1
- package/dist/module/conditions/condition-group.js +4 -9
- package/dist/module/conditions/condition-group.js.map +1 -1
- package/dist/module/conditions/condition-model.js +20 -25
- package/dist/module/conditions/condition-model.js.map +1 -1
- package/dist/module/conditions/condition-operators.js +15 -23
- package/dist/module/conditions/condition-operators.js.map +1 -1
- package/dist/module/conditions/condition-ref.js +2 -7
- package/dist/module/conditions/condition-ref.js.map +1 -1
- package/dist/module/conditions/condition-value-abstract.js +3 -8
- package/dist/module/conditions/condition-value-abstract.js.map +1 -1
- package/dist/module/conditions/condition-value-registration.js +1 -6
- package/dist/module/conditions/condition-value-registration.js.map +1 -1
- package/dist/module/conditions/condition-values.js +12 -20
- package/dist/module/conditions/condition-values.js.map +1 -1
- package/dist/module/conditions/condition.js +9 -14
- package/dist/module/conditions/condition.js.map +1 -1
- package/dist/module/conditions/enums.js +1 -5
- package/dist/module/conditions/enums.js.map +1 -1
- package/dist/module/conditions/helpers.js +2 -7
- package/dist/module/conditions/helpers.js.map +1 -1
- package/dist/module/conditions/index.js +10 -139
- package/dist/module/conditions/index.js.map +1 -1
- package/dist/module/conditions/inline-condition-model.js +15 -26
- package/dist/module/conditions/inline-condition-model.js.map +1 -1
- package/dist/module/conditions/inline-condition-operators.js +15 -23
- package/dist/module/conditions/inline-condition-operators.js.map +1 -1
- package/dist/module/conditions/inline-condition-values.js +9 -17
- package/dist/module/conditions/inline-condition-values.js.map +1 -1
- package/dist/module/conditions/types.js +2 -1
- package/dist/module/conditions/types.js.map +1 -1
- package/dist/module/data-model/conditions-wrapper.js +3 -8
- package/dist/module/data-model/conditions-wrapper.js.map +1 -1
- package/dist/module/data-model/enums.js +1 -5
- package/dist/module/data-model/enums.js.map +1 -1
- package/dist/module/data-model/index.js +3 -24
- package/dist/module/data-model/index.js.map +1 -1
- package/dist/module/data-model/input-wrapper.js +3 -8
- package/dist/module/data-model/input-wrapper.js.map +1 -1
- package/dist/module/data-model/types.js +1 -5
- package/dist/module/data-model/types.js.map +1 -1
- package/dist/module/form/form-configuration.js +1 -6
- package/dist/module/form/form-configuration.js.map +1 -1
- package/dist/module/form/index.js +1 -10
- package/dist/module/form/index.js.map +1 -1
- package/dist/module/index.js +8 -91
- package/dist/module/index.js.map +1 -1
- package/dist/module/migration/index.js +1 -10
- package/dist/module/migration/index.js.map +1 -1
- package/dist/module/migration/migration.0-2.js +1 -5
- package/dist/module/migration/migration.0-2.js.map +1 -1
- package/dist/module/migration/migration.1-2.js +3 -6
- package/dist/module/migration/migration.1-2.js.map +1 -1
- package/dist/module/migration/types.js +2 -1
- package/dist/module/migration/whichMigrations.js +5 -9
- package/dist/module/migration/whichMigrations.js.map +1 -1
- package/dist/module/schema/index.js +1 -16
- package/dist/module/schema/index.js.map +1 -1
- package/dist/module/schema/schema.js +163 -167
- package/dist/module/schema/schema.js.map +1 -1
- package/dist/module/utils/helpers.js +5 -13
- package/dist/module/utils/helpers.js.map +1 -1
- package/dist/module/utils/logger.js +1 -6
- package/dist/module/utils/logger.js.map +1 -1
- package/dist/types/components/component-types.d.ts +1 -1
- package/dist/types/components/component-types.d.ts.map +1 -1
- package/dist/types/components/conditional-component-types.d.ts +1 -1
- package/dist/types/components/conditional-component-types.d.ts.map +1 -1
- package/dist/types/components/index.d.ts +3 -3
- package/dist/types/components/index.d.ts.map +1 -1
- package/dist/types/conditions/condition-abstract.d.ts +1 -1
- package/dist/types/conditions/condition-abstract.d.ts.map +1 -1
- package/dist/types/conditions/condition-field.d.ts +1 -1
- package/dist/types/conditions/condition-field.d.ts.map +1 -1
- package/dist/types/conditions/condition-group-def.d.ts +2 -2
- package/dist/types/conditions/condition-group-def.d.ts.map +1 -1
- package/dist/types/conditions/condition-group.d.ts +2 -2
- package/dist/types/conditions/condition-group.d.ts.map +1 -1
- package/dist/types/conditions/condition-model.d.ts +5 -5
- package/dist/types/conditions/condition-model.d.ts.map +1 -1
- package/dist/types/conditions/condition-operators.d.ts +2 -2
- package/dist/types/conditions/condition-operators.d.ts.map +1 -1
- package/dist/types/conditions/condition-ref.d.ts +2 -2
- package/dist/types/conditions/condition-ref.d.ts.map +1 -1
- package/dist/types/conditions/condition-value-abstract.d.ts +1 -1
- package/dist/types/conditions/condition-value-abstract.d.ts.map +1 -1
- package/dist/types/conditions/condition-values.d.ts +3 -3
- package/dist/types/conditions/condition-values.d.ts.map +1 -1
- package/dist/types/conditions/condition.d.ts +4 -4
- package/dist/types/conditions/condition.d.ts.map +1 -1
- package/dist/types/conditions/index.d.ts +10 -10
- package/dist/types/conditions/index.d.ts.map +1 -1
- package/dist/types/conditions/types.d.ts +3 -3
- package/dist/types/conditions/types.d.ts.map +1 -1
- package/dist/types/data-model/conditions-wrapper.d.ts +1 -1
- package/dist/types/data-model/conditions-wrapper.d.ts.map +1 -1
- package/dist/types/data-model/index.d.ts +3 -3
- package/dist/types/data-model/index.d.ts.map +1 -1
- package/dist/types/data-model/input-wrapper.d.ts +2 -2
- package/dist/types/data-model/input-wrapper.d.ts.map +1 -1
- package/dist/types/data-model/types.d.ts +3 -3
- package/dist/types/data-model/types.d.ts.map +1 -1
- package/dist/types/form/index.d.ts +1 -1
- package/dist/types/form/index.d.ts.map +1 -1
- package/dist/types/index.d.ts +11 -11
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/migration/index.d.ts +1 -1
- package/dist/types/migration/index.d.ts.map +1 -1
- package/dist/types/migration/migration.0-2.d.ts +1 -1
- package/dist/types/migration/migration.0-2.d.ts.map +1 -1
- package/dist/types/migration/migration.1-2.d.ts +1 -1
- package/dist/types/migration/migration.1-2.d.ts.map +1 -1
- package/dist/types/migration/whichMigrations.d.ts +1 -1
- package/dist/types/migration/whichMigrations.d.ts.map +1 -1
- package/dist/types/schema/index.d.ts +1 -1
- package/dist/types/schema/index.d.ts.map +1 -1
- package/package.json +4 -3
- package/src/components/component-types.ts +1 -1
- package/src/components/conditional-component-types.ts +1 -1
- package/src/components/index.ts +3 -3
- package/src/conditions/condition-abstract.ts +1 -1
- package/src/conditions/condition-field.ts +2 -2
- package/src/conditions/condition-group-def.ts +1 -1
- package/src/conditions/condition-group.ts +3 -3
- package/src/conditions/condition-model.ts +9 -9
- package/src/conditions/condition-operators.ts +6 -3
- package/src/conditions/condition-ref.ts +2 -2
- package/src/conditions/condition-value-abstract.ts +1 -1
- package/src/conditions/condition-values.ts +3 -3
- package/src/conditions/condition.ts +6 -6
- package/src/conditions/index.ts +10 -10
- package/src/conditions/inline-condition-model.ts +3 -3
- package/src/conditions/inline-condition-operators.ts +1 -1
- package/src/conditions/types.ts +3 -3
- package/src/data-model/conditions-wrapper.ts +2 -2
- package/src/data-model/index.ts +3 -3
- package/src/data-model/input-wrapper.ts +3 -3
- package/src/data-model/types.ts +3 -3
- package/src/form/index.ts +1 -1
- package/src/index.ts +11 -11
- package/src/migration/index.ts +1 -1
- package/src/migration/migration.0-2.ts +1 -1
- package/src/migration/migration.1-2.ts +2 -2
- package/src/migration/whichMigrations.ts +3 -3
- package/src/schema/index.ts +1 -1
|
@@ -1,108 +1,92 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
factory(mod.exports, global.helpers);
|
|
11
|
-
global.migration12 = mod.exports;
|
|
12
|
-
}
|
|
13
|
-
})(typeof globalThis !== "undefined" ? globalThis : typeof self !== "undefined" ? self : this, function (_exports, _helpers) {
|
|
14
|
-
"use strict";
|
|
1
|
+
const _excluded = ["values"];
|
|
2
|
+
function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }
|
|
3
|
+
function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
|
|
4
|
+
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
5
|
+
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
6
|
+
function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
7
|
+
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == typeof i ? i : String(i); }
|
|
8
|
+
function _toPrimitive(t, r) { if ("object" != typeof t || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != typeof i) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
|
|
9
|
+
import { nanoid } from "../utils/helpers.js";
|
|
15
10
|
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
22
|
-
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
23
|
-
function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
24
|
-
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == typeof i ? i : String(i); }
|
|
25
|
-
function _toPrimitive(t, r) { if ("object" != typeof t || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != typeof i) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
|
|
26
|
-
/**
|
|
27
|
-
* @private
|
|
28
|
-
* StaticItem is a deprecated Type.
|
|
29
|
-
* It should only be used for aiding migration scripts.
|
|
30
|
-
*/
|
|
11
|
+
/**
|
|
12
|
+
* @private
|
|
13
|
+
* StaticItem is a deprecated Type.
|
|
14
|
+
* It should only be used for aiding migration scripts.
|
|
15
|
+
*/
|
|
31
16
|
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
17
|
+
/**
|
|
18
|
+
* @private
|
|
19
|
+
* StaticComponentValues is a deprecated Type.
|
|
20
|
+
* It should only be used for aiding migration scripts.
|
|
21
|
+
*/
|
|
37
22
|
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
}
|
|
56
|
-
const {
|
|
57
|
-
values
|
|
58
|
-
} = component;
|
|
59
|
-
return _objectSpread(_objectSpread({}, component), {}, {
|
|
60
|
-
list: values.type === 'listRef' ? values.list : (0, _helpers.nanoid)()
|
|
61
|
-
});
|
|
62
|
-
}
|
|
63
|
-
function migratePage(page) {
|
|
64
|
-
return _objectSpread(_objectSpread({}, page), {}, {
|
|
65
|
-
components: page.components.map(addListId)
|
|
66
|
-
});
|
|
67
|
-
}
|
|
68
|
-
function removeValues(page) {
|
|
69
|
-
return _objectSpread(_objectSpread({}, page), {}, {
|
|
70
|
-
components: page.components.map(component => {
|
|
71
|
-
const {
|
|
72
|
-
values
|
|
73
|
-
} = component,
|
|
74
|
-
rest = _objectWithoutProperties(component, _excluded);
|
|
75
|
-
return _objectSpread({}, rest);
|
|
76
|
-
})
|
|
77
|
-
});
|
|
23
|
+
function recastItem({
|
|
24
|
+
label,
|
|
25
|
+
value,
|
|
26
|
+
condition,
|
|
27
|
+
hint
|
|
28
|
+
}) {
|
|
29
|
+
const item = {
|
|
30
|
+
title: label,
|
|
31
|
+
value
|
|
32
|
+
};
|
|
33
|
+
condition && (item.conditions = condition);
|
|
34
|
+
hint && (item.hint = hint);
|
|
35
|
+
return item;
|
|
36
|
+
}
|
|
37
|
+
function addListId(component) {
|
|
38
|
+
if (!component.values) {
|
|
39
|
+
return component;
|
|
78
40
|
}
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
41
|
+
const {
|
|
42
|
+
values
|
|
43
|
+
} = component;
|
|
44
|
+
return _objectSpread(_objectSpread({}, component), {}, {
|
|
45
|
+
list: values.type === 'listRef' ? values.list : nanoid()
|
|
46
|
+
});
|
|
47
|
+
}
|
|
48
|
+
function migratePage(page) {
|
|
49
|
+
return _objectSpread(_objectSpread({}, page), {}, {
|
|
50
|
+
components: page.components.map(addListId)
|
|
51
|
+
});
|
|
52
|
+
}
|
|
53
|
+
function removeValues(page) {
|
|
54
|
+
return _objectSpread(_objectSpread({}, page), {}, {
|
|
55
|
+
components: page.components.map(component => {
|
|
56
|
+
const {
|
|
57
|
+
values
|
|
58
|
+
} = component,
|
|
59
|
+
rest = _objectWithoutProperties(component, _excluded);
|
|
60
|
+
return _objectSpread({}, rest);
|
|
61
|
+
})
|
|
62
|
+
});
|
|
63
|
+
}
|
|
64
|
+
function needsUpgrade(data) {
|
|
65
|
+
return !!data.pages.flatMap(page => page.components).find(component => component.values);
|
|
66
|
+
}
|
|
67
|
+
export function migrate(data) {
|
|
68
|
+
var _data$lists;
|
|
69
|
+
if (!needsUpgrade(data)) {
|
|
101
70
|
return _objectSpread(_objectSpread({}, data), {}, {
|
|
102
|
-
pages: pages.map(removeValues),
|
|
103
|
-
lists: [...((_data$lists = data.lists) !== null && _data$lists !== void 0 ? _data$lists : []), ...valuesAsLists],
|
|
104
71
|
version: 2
|
|
105
72
|
});
|
|
106
73
|
}
|
|
107
|
-
|
|
74
|
+
const pages = data.pages.map(migratePage);
|
|
75
|
+
const componentsWithList = pages.flatMap(page => page.components.filter(c => {
|
|
76
|
+
var _c$values;
|
|
77
|
+
return (_c$values = c.values) === null || _c$values === void 0 ? void 0 : _c$values.items;
|
|
78
|
+
}));
|
|
79
|
+
const valuesAsLists = componentsWithList.map(component => {
|
|
80
|
+
return {
|
|
81
|
+
title: component.title,
|
|
82
|
+
name: component.list,
|
|
83
|
+
items: component.values.items.map(item => recastItem(item))
|
|
84
|
+
};
|
|
85
|
+
});
|
|
86
|
+
return _objectSpread(_objectSpread({}, data), {}, {
|
|
87
|
+
pages: pages.map(removeValues),
|
|
88
|
+
lists: [...((_data$lists = data.lists) !== null && _data$lists !== void 0 ? _data$lists : []), ...valuesAsLists],
|
|
89
|
+
version: 2
|
|
90
|
+
});
|
|
91
|
+
}
|
|
108
92
|
//# sourceMappingURL=migration.1-2.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"migration.1-2.js","names":["recastItem","label","value","condition","hint","item","title","conditions","addListId","component","values","_objectSpread","list","type","
|
|
1
|
+
{"version":3,"file":"migration.1-2.js","names":["nanoid","recastItem","label","value","condition","hint","item","title","conditions","addListId","component","values","_objectSpread","list","type","migratePage","page","components","map","removeValues","rest","_objectWithoutProperties","_excluded","needsUpgrade","data","pages","flatMap","find","migrate","_data$lists","version","componentsWithList","filter","c","_c$values","items","valuesAsLists","name","lists"],"sources":["../../../src/migration/migration.1-2.ts"],"sourcesContent":["import { nanoid } from '~/src/utils/helpers.js'\nimport { type MigrationScript } from '~/src/migration/types.js'\n\n/**\n * @private\n * StaticItem is a deprecated Type.\n * It should only be used for aiding migration scripts.\n */\ntype StaticItem = {\n label: string\n value: string | number | boolean\n hint?: string\n condition?: string\n}\n\n/**\n * @private\n * StaticComponentValues is a deprecated Type.\n * It should only be used for aiding migration scripts.\n */\ntype StaticComponentValues = {\n list: any\n type: 'static' | 'listRef'\n valueType: string | number\n items: StaticItem[]\n}\n\ntype Item = {\n title: string\n value: any\n conditions?: any\n hint?: string\n}\n\nfunction recastItem({ label, value, condition, hint }: StaticItem) {\n const item: Item = {\n title: label,\n value\n }\n\n condition && (item.conditions = condition)\n hint && (item.hint = hint)\n return item\n}\n\nfunction addListId(component: { values: StaticComponentValues }) {\n if (!component.values) {\n return component\n }\n const { values } = component\n return {\n ...component,\n list: values.type === 'listRef' ? values.list : nanoid()\n }\n}\n\nfunction migratePage(page) {\n return {\n ...page,\n components: page.components.map(addListId)\n }\n}\n\nfunction removeValues(page) {\n return {\n ...page,\n components: page.components.map((component) => {\n const { values, ...rest } = component\n return {\n ...rest\n }\n })\n }\n}\n\nfunction needsUpgrade(data) {\n return !!data.pages\n .flatMap((page) => page.components)\n .find((component) => component.values)\n}\n\nexport function migrate(data): MigrationScript {\n if (!needsUpgrade(data)) {\n return { ...data, version: 2 }\n }\n const pages = data.pages.map(migratePage)\n const componentsWithList = pages.flatMap((page) =>\n page.components.filter((c) => c.values?.items)\n )\n\n const valuesAsLists = componentsWithList.map((component) => {\n return {\n title: component.title,\n name: component.list,\n items: component.values.items.map((item) => recastItem(item))\n }\n })\n\n return {\n ...data,\n pages: pages.map(removeValues),\n lists: [...(data.lists ?? []), ...valuesAsLists],\n version: 2\n }\n}\n"],"mappings":"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"}
|
|
@@ -1,16 +1,2 @@
|
|
|
1
|
-
|
|
2
|
-
if (typeof define === "function" && define.amd) {
|
|
3
|
-
define([], factory);
|
|
4
|
-
} else if (typeof exports !== "undefined") {
|
|
5
|
-
factory();
|
|
6
|
-
} else {
|
|
7
|
-
var mod = {
|
|
8
|
-
exports: {}
|
|
9
|
-
};
|
|
10
|
-
factory();
|
|
11
|
-
global.types = mod.exports;
|
|
12
|
-
}
|
|
13
|
-
})(typeof globalThis !== "undefined" ? globalThis : typeof self !== "undefined" ? self : this, function () {
|
|
14
|
-
"use strict";
|
|
15
|
-
});
|
|
1
|
+
export {};
|
|
16
2
|
//# sourceMappingURL=types.js.map
|
|
@@ -1,38 +1,22 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
1
|
+
import { migrate as V0_TO_V2 } from "./migration.0-2.js";
|
|
2
|
+
import { migrate as V1_TO_V2 } from "./migration.1-2.js";
|
|
3
|
+
/**
|
|
4
|
+
* Returns which migrations that should be run against your Object with the given version
|
|
5
|
+
* @param version
|
|
6
|
+
*/
|
|
7
|
+
export function whichMigrations(version) {
|
|
8
|
+
const migrations = new Set();
|
|
9
|
+
switch (version) {
|
|
10
|
+
case 0:
|
|
11
|
+
migrations.add(V0_TO_V2);
|
|
12
|
+
/**
|
|
13
|
+
* we are skipping v1 entirely. If we weren't you would do migrations.add([V1_TO_V2, V2_TO_V3]) for example.
|
|
14
|
+
*/
|
|
15
|
+
break;
|
|
16
|
+
case 1:
|
|
17
|
+
migrations.add(V1_TO_V2);
|
|
18
|
+
break;
|
|
12
19
|
}
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
_exports.__esModule = true;
|
|
17
|
-
_exports.whichMigrations = whichMigrations;
|
|
18
|
-
/**
|
|
19
|
-
* Returns which migrations that should be run against your Object with the given version
|
|
20
|
-
* @param version
|
|
21
|
-
*/
|
|
22
|
-
function whichMigrations(version) {
|
|
23
|
-
const migrations = new Set();
|
|
24
|
-
switch (version) {
|
|
25
|
-
case 0:
|
|
26
|
-
migrations.add(_migration.migrate);
|
|
27
|
-
/**
|
|
28
|
-
* we are skipping v1 entirely. If we weren't you would do migrations.add([V1_TO_V2, V2_TO_V3]) for example.
|
|
29
|
-
*/
|
|
30
|
-
break;
|
|
31
|
-
case 1:
|
|
32
|
-
migrations.add(_migration2.migrate);
|
|
33
|
-
break;
|
|
34
|
-
}
|
|
35
|
-
return migrations;
|
|
36
|
-
}
|
|
37
|
-
});
|
|
20
|
+
return migrations;
|
|
21
|
+
}
|
|
38
22
|
//# sourceMappingURL=whichMigrations.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"whichMigrations.js","names":["
|
|
1
|
+
{"version":3,"file":"whichMigrations.js","names":["migrate","V0_TO_V2","V1_TO_V2","whichMigrations","version","migrations","Set","add"],"sources":["../../../src/migration/whichMigrations.ts"],"sourcesContent":["import { migrate as V0_TO_V2 } from '~/src/migration/migration.0-2.js'\nimport { migrate as V1_TO_V2 } from '~/src/migration/migration.1-2.js'\nimport { type MigrationScript } from '~/src/migration/types.js'\n\n/**\n * Returns which migrations that should be run against your Object with the given version\n * @param version\n */\nexport function whichMigrations(version: number) {\n const migrations = new Set<MigrationScript>()\n switch (version) {\n case 0:\n migrations.add(V0_TO_V2)\n /**\n * we are skipping v1 entirely. If we weren't you would do migrations.add([V1_TO_V2, V2_TO_V3]) for example.\n */\n break\n case 1:\n migrations.add(V1_TO_V2)\n break\n }\n return migrations\n}\n"],"mappings":"AAAA,SAASA,OAAO,IAAIC,QAAQ;AAC5B,SAASD,OAAO,IAAIE,QAAQ;AAG5B;AACA;AACA;AACA;AACA,OAAO,SAASC,eAAeA,CAACC,OAAe,EAAE;EAC/C,MAAMC,UAAU,GAAG,IAAIC,GAAG,CAAkB,CAAC;EAC7C,QAAQF,OAAO;IACb,KAAK,CAAC;MACJC,UAAU,CAACE,GAAG,CAACN,QAAQ,CAAC;MACxB;AACN;AACA;MACM;IACF,KAAK,CAAC;MACJI,UAAU,CAACE,GAAG,CAACL,QAAQ,CAAC;MACxB;EACJ;EACA,OAAOG,UAAU;AACnB"}
|
|
@@ -1,30 +1,2 @@
|
|
|
1
|
-
|
|
2
|
-
if (typeof define === "function" && define.amd) {
|
|
3
|
-
define(["exports", "./schema"], factory);
|
|
4
|
-
} else if (typeof exports !== "undefined") {
|
|
5
|
-
factory(exports, require("./schema"));
|
|
6
|
-
} else {
|
|
7
|
-
var mod = {
|
|
8
|
-
exports: {}
|
|
9
|
-
};
|
|
10
|
-
factory(mod.exports, global.schema);
|
|
11
|
-
global.index = mod.exports;
|
|
12
|
-
}
|
|
13
|
-
})(typeof globalThis !== "undefined" ? globalThis : typeof self !== "undefined" ? self : this, function (_exports, _schema) {
|
|
14
|
-
"use strict";
|
|
15
|
-
|
|
16
|
-
_exports.__esModule = true;
|
|
17
|
-
Object.defineProperty(_exports, "Schema", {
|
|
18
|
-
enumerable: true,
|
|
19
|
-
get: function () {
|
|
20
|
-
return _schema.Schema;
|
|
21
|
-
}
|
|
22
|
-
});
|
|
23
|
-
Object.defineProperty(_exports, "componentSchema", {
|
|
24
|
-
enumerable: true,
|
|
25
|
-
get: function () {
|
|
26
|
-
return _schema.componentSchema;
|
|
27
|
-
}
|
|
28
|
-
});
|
|
29
|
-
});
|
|
1
|
+
export { Schema, componentSchema } from "./schema.js";
|
|
30
2
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":[],"sources":["../../../src/schema/index.ts"],"sourcesContent":["export { Schema, componentSchema } from '~/src/schema/schema'\n"],"mappings":""}
|
|
1
|
+
{"version":3,"file":"index.js","names":["Schema","componentSchema"],"sources":["../../../src/schema/index.ts"],"sourcesContent":["export { Schema, componentSchema } from '~/src/schema/schema.js'\n"],"mappings":"AAAA,SAASA,MAAM,EAAEC,eAAe"}
|