@socotra/ec-react-utils 0.0.0-alpha.0 → 0.0.0-alpha.3
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/index.d.ts +4 -3
- package/dist/index.es.js +71 -71
- package/dist/index.es.js.map +1 -1
- package/dist/index.umd.js +1 -1
- package/dist/index.umd.js.map +1 -1
- package/package.json +5 -4
package/dist/index.d.ts
CHANGED
|
@@ -3,12 +3,13 @@ import { AccountResponse } from '@socotra/ec-react-schemas';
|
|
|
3
3
|
import { DataModel } from '@socotra/ec-react-schemas';
|
|
4
4
|
import { DataTypeConfigRecord } from '@socotra/ec-react-schemas';
|
|
5
5
|
import { ElementResponse } from '@socotra/ec-react-schemas';
|
|
6
|
+
import { ErrorObject } from 'ajv';
|
|
6
7
|
import { FieldConfigRecord } from '@socotra/ec-react-schemas';
|
|
8
|
+
import { JsonSchema7 } from '@jsonforms/core';
|
|
7
9
|
import { QuoteRequest } from '@socotra/ec-react-schemas';
|
|
8
10
|
import { QuoteResponse } from '@socotra/ec-react-schemas';
|
|
9
|
-
import { RJSFValidationError } from '@rjsf/utils';
|
|
10
11
|
|
|
11
|
-
export declare const dataModelToJSONSchema: (args: DataModelToJsonSchemaProps) =>
|
|
12
|
+
export declare const dataModelToJSONSchema: (args: DataModelToJsonSchemaProps) => JsonSchema7;
|
|
12
13
|
|
|
13
14
|
declare interface DataModelToJsonSchemaProps {
|
|
14
15
|
data: FieldConfigRecord;
|
|
@@ -105,6 +106,6 @@ export declare function retrieveDataModelFromElement(element: ElementResponse, d
|
|
|
105
106
|
*/
|
|
106
107
|
export declare function retrieveElementFromQuoteByLocator(quoteElement: ElementResponse, locator: string): ElementResponse | undefined;
|
|
107
108
|
|
|
108
|
-
export declare function transformErrors(errors:
|
|
109
|
+
export declare function transformErrors(errors: ErrorObject<string, Record<string, any>, unknown>[] | null | undefined): ErrorObject<string, Record<string, any>, unknown>[] | undefined;
|
|
109
110
|
|
|
110
111
|
export { }
|
package/dist/index.es.js
CHANGED
|
@@ -1,17 +1,17 @@
|
|
|
1
|
-
const
|
|
2
|
-
const { data: e, scope: a, dataTypes: n, rootDisplayName: c, account:
|
|
3
|
-
let
|
|
4
|
-
const
|
|
1
|
+
const W = (s) => {
|
|
2
|
+
const { data: e, scope: a, dataTypes: n, rootDisplayName: c, account: l, quote: r, element: u } = s, T = [];
|
|
3
|
+
let $ = {};
|
|
4
|
+
const J = Object.fromEntries(
|
|
5
5
|
Object.entries(e ?? {}).filter(([, m]) => {
|
|
6
6
|
var o;
|
|
7
|
-
const
|
|
8
|
-
return !!(!
|
|
9
|
-
}).map(([m,
|
|
10
|
-
var I, O, P, j, F, A, N, R, B, C, D,
|
|
11
|
-
let o = !1, f = !1,
|
|
12
|
-
const
|
|
13
|
-
let t =
|
|
14
|
-
switch (
|
|
7
|
+
const i = (o = m.scope) == null ? void 0 : o.split(",").map((f) => f.trim());
|
|
8
|
+
return !!(!i || a === "P" && (i != null && i.includes("P")) || i != null && i.includes("Q") || a === "Q" && (i != null && i.includes("Q")));
|
|
9
|
+
}).map(([m, i]) => {
|
|
10
|
+
var E, I, O, P, j, F, A, N, R, B, C, D, k, G, z, U, Z;
|
|
11
|
+
let o = !1, f = !1, Q = !1;
|
|
12
|
+
const L = i.displayName ?? m, K = (E = i.type) == null ? void 0 : E.slice(-1), h = i.maxLength, x = i.minLength, q = i.max, y = i.min, V = i.regex;
|
|
13
|
+
let t = i.type ?? "", p;
|
|
14
|
+
switch (K) {
|
|
15
15
|
case "*":
|
|
16
16
|
f = !0, o = !0, t = t == null ? void 0 : t.split("*")[0];
|
|
17
17
|
break;
|
|
@@ -47,27 +47,27 @@ const X = (i) => {
|
|
|
47
47
|
t = "boolean";
|
|
48
48
|
break;
|
|
49
49
|
default:
|
|
50
|
-
|
|
50
|
+
Q = !0;
|
|
51
51
|
break;
|
|
52
52
|
}
|
|
53
|
-
if (!o && !
|
|
53
|
+
if (!o && !Q && !f && T.push(m), Q) {
|
|
54
54
|
const g = n == null ? void 0 : n[t];
|
|
55
55
|
if (g) {
|
|
56
56
|
let b = f ? [] : {};
|
|
57
|
-
const
|
|
57
|
+
const H = W({
|
|
58
58
|
data: g.data ?? {},
|
|
59
59
|
scope: a,
|
|
60
60
|
dataTypes: n,
|
|
61
61
|
rootDisplayName: m
|
|
62
62
|
});
|
|
63
|
-
return
|
|
64
|
-
|
|
65
|
-
[`${t}`]:
|
|
63
|
+
return r && (O = (I = r.element) == null ? void 0 : I.data) != null && O[m] && (b = (j = (P = r.element) == null ? void 0 : P.data) == null ? void 0 : j[m]), u && (F = u == null ? void 0 : u.data) != null && F[m] && (b = (A = u == null ? void 0 : u.data) == null ? void 0 : A[m]), l && (N = l == null ? void 0 : l.data) != null && N[m] && (b = (R = l == null ? void 0 : l.data) == null ? void 0 : R[m]), $ = {
|
|
64
|
+
...$,
|
|
65
|
+
[`${t}`]: H
|
|
66
66
|
}, f ? [
|
|
67
67
|
m,
|
|
68
68
|
{
|
|
69
|
-
title: m.replace(/([A-Z])/g, " $1").replace(/^./, function(
|
|
70
|
-
return
|
|
69
|
+
title: m.replace(/([A-Z])/g, " $1").replace(/^./, function(w) {
|
|
70
|
+
return w.toUpperCase();
|
|
71
71
|
}),
|
|
72
72
|
type: "array",
|
|
73
73
|
default: b,
|
|
@@ -79,8 +79,8 @@ const X = (i) => {
|
|
|
79
79
|
] : [
|
|
80
80
|
m,
|
|
81
81
|
{
|
|
82
|
-
title: m.replace(/([A-Z])/g, " $1").replace(/^./, function(
|
|
83
|
-
return
|
|
82
|
+
title: m.replace(/([A-Z])/g, " $1").replace(/^./, function(w) {
|
|
83
|
+
return w.toUpperCase();
|
|
84
84
|
}),
|
|
85
85
|
default: b,
|
|
86
86
|
$ref: `#/definitions/${t}`
|
|
@@ -89,40 +89,40 @@ const X = (i) => {
|
|
|
89
89
|
}
|
|
90
90
|
}
|
|
91
91
|
let d = "";
|
|
92
|
-
if (
|
|
93
|
-
const g = (
|
|
94
|
-
d = (
|
|
92
|
+
if (l) {
|
|
93
|
+
const g = (l == null ? void 0 : l.state) === "validated" ? m.charAt(0).toLowerCase() + m.slice(1) : m;
|
|
94
|
+
d = (B = l == null ? void 0 : l.data) != null && B[g] ? (C = l == null ? void 0 : l.data) == null ? void 0 : C[g] : t === "boolean" ? !!i.defaultValue : i.defaultValue;
|
|
95
95
|
}
|
|
96
|
-
return
|
|
96
|
+
return r && (d = (k = (D = r.element) == null ? void 0 : D.data) != null && k[m] ? (z = (G = r.element) == null ? void 0 : G.data) == null ? void 0 : z[m] : t === "boolean" ? !!i.defaultValue : i.defaultValue), u && (d = (U = u == null ? void 0 : u.data) != null && U[m] ? (Z = u == null ? void 0 : u.data) == null ? void 0 : Z[m] : t === "boolean" ? !!i.defaultValue : i.defaultValue), f ? [
|
|
97
97
|
m,
|
|
98
98
|
{
|
|
99
|
-
title:
|
|
99
|
+
title: L,
|
|
100
100
|
type: "array",
|
|
101
101
|
default: d,
|
|
102
102
|
items: {
|
|
103
103
|
type: t,
|
|
104
104
|
...h && { maxLength: h },
|
|
105
105
|
...x && { minLength: x },
|
|
106
|
-
|
|
106
|
+
...y && { min: y },
|
|
107
107
|
...q && { max: q },
|
|
108
108
|
...p && { format: p },
|
|
109
|
-
...
|
|
109
|
+
...V && { pattern: i.regex }
|
|
110
110
|
},
|
|
111
111
|
...!o && { minItems: 1 }
|
|
112
112
|
}
|
|
113
113
|
] : [
|
|
114
114
|
m,
|
|
115
115
|
{
|
|
116
|
-
title:
|
|
116
|
+
title: L,
|
|
117
117
|
type: t,
|
|
118
118
|
...d && { default: d },
|
|
119
119
|
...x && { minLength: x },
|
|
120
120
|
...h && { maxLength: h },
|
|
121
|
-
|
|
121
|
+
...y && { minimum: parseInt(y) },
|
|
122
122
|
...q && { maximum: parseInt(q) },
|
|
123
123
|
...p && { format: p },
|
|
124
|
-
...
|
|
125
|
-
...
|
|
124
|
+
...i.options && { enum: i.options },
|
|
125
|
+
...V && { pattern: i.regex }
|
|
126
126
|
}
|
|
127
127
|
];
|
|
128
128
|
})
|
|
@@ -130,13 +130,13 @@ const X = (i) => {
|
|
|
130
130
|
return {
|
|
131
131
|
title: c,
|
|
132
132
|
type: "object",
|
|
133
|
-
definitions:
|
|
134
|
-
required:
|
|
135
|
-
properties:
|
|
133
|
+
definitions: $,
|
|
134
|
+
required: T,
|
|
135
|
+
properties: J
|
|
136
136
|
};
|
|
137
|
-
}, ee = (
|
|
138
|
-
const e =
|
|
139
|
-
(
|
|
137
|
+
}, ee = (s) => {
|
|
138
|
+
const e = s.autoValidate, a = s.delinquencyPlanName, n = s.accountType, c = Object.keys(s).reduce(
|
|
139
|
+
(r, u) => (u !== "accountType" && u !== "autoValidate" && u !== "delinquencyPlanName" && (r[u] = s[u]), r),
|
|
140
140
|
{}
|
|
141
141
|
);
|
|
142
142
|
return {
|
|
@@ -146,77 +146,77 @@ const X = (i) => {
|
|
|
146
146
|
data: c
|
|
147
147
|
};
|
|
148
148
|
}, te = ({
|
|
149
|
-
formData:
|
|
149
|
+
formData: s,
|
|
150
150
|
locator: e
|
|
151
151
|
}) => ({
|
|
152
152
|
elements: [{
|
|
153
153
|
locator: e,
|
|
154
|
-
setData:
|
|
154
|
+
setData: s
|
|
155
155
|
}]
|
|
156
156
|
});
|
|
157
|
-
function
|
|
157
|
+
function X(s) {
|
|
158
158
|
const {
|
|
159
159
|
delinquencyPlanName: e,
|
|
160
160
|
startTime: a,
|
|
161
161
|
endTime: n,
|
|
162
162
|
currency: c,
|
|
163
|
-
expirationTime:
|
|
164
|
-
timezone:
|
|
163
|
+
expirationTime: l,
|
|
164
|
+
timezone: r,
|
|
165
165
|
...u
|
|
166
|
-
} =
|
|
166
|
+
} = s;
|
|
167
167
|
return u;
|
|
168
168
|
}
|
|
169
|
-
function
|
|
169
|
+
function Y(s) {
|
|
170
170
|
const {
|
|
171
171
|
delinquencyPlanName: e,
|
|
172
172
|
startTime: a,
|
|
173
173
|
endTime: n,
|
|
174
174
|
currency: c,
|
|
175
|
-
expirationTime:
|
|
176
|
-
timezone:
|
|
177
|
-
} =
|
|
175
|
+
expirationTime: l,
|
|
176
|
+
timezone: r
|
|
177
|
+
} = s;
|
|
178
178
|
return {
|
|
179
179
|
delinquencyPlanName: e,
|
|
180
180
|
startTime: a,
|
|
181
181
|
endTime: n,
|
|
182
182
|
currency: c,
|
|
183
|
-
expirationTime:
|
|
184
|
-
timezone:
|
|
183
|
+
expirationTime: l,
|
|
184
|
+
timezone: r
|
|
185
185
|
};
|
|
186
186
|
}
|
|
187
187
|
const se = ({
|
|
188
|
-
formData:
|
|
188
|
+
formData: s,
|
|
189
189
|
hideDefaultFields: e,
|
|
190
190
|
hideConfiguredFields: a
|
|
191
191
|
}) => {
|
|
192
192
|
let n = {};
|
|
193
193
|
if (e || (n = {
|
|
194
|
-
...
|
|
194
|
+
...Y(s)
|
|
195
195
|
}), !a) {
|
|
196
|
-
const c =
|
|
196
|
+
const c = X(s);
|
|
197
197
|
n = {
|
|
198
198
|
...n,
|
|
199
199
|
setData: c
|
|
200
200
|
};
|
|
201
201
|
}
|
|
202
202
|
return n;
|
|
203
|
-
},
|
|
204
|
-
const e = /^(.*?)(Quote|QuickQuote|Policy)$/, a =
|
|
205
|
-
return a && (a[2] === "Quote" || a[2] === "QuickQuote" || a[2] === "Policy") ? [a[1], a[2]] : [
|
|
203
|
+
}, _ = (s) => {
|
|
204
|
+
const e = /^(.*?)(Quote|QuickQuote|Policy)$/, a = s.match(e);
|
|
205
|
+
return a && (a[2] === "Quote" || a[2] === "QuickQuote" || a[2] === "Policy") ? [a[1], a[2]] : [s, null];
|
|
206
206
|
};
|
|
207
|
-
function
|
|
208
|
-
if (
|
|
209
|
-
return
|
|
210
|
-
if (
|
|
211
|
-
for (const a of
|
|
212
|
-
const n =
|
|
207
|
+
function S(s, e) {
|
|
208
|
+
if (s.locator === e)
|
|
209
|
+
return s;
|
|
210
|
+
if (s.elements)
|
|
211
|
+
for (const a of s.elements) {
|
|
212
|
+
const n = S(a, e);
|
|
213
213
|
if (n)
|
|
214
214
|
return n;
|
|
215
215
|
}
|
|
216
216
|
}
|
|
217
|
-
function ie(
|
|
218
|
-
const [a] =
|
|
219
|
-
|
|
217
|
+
function ie(s, e) {
|
|
218
|
+
const [a] = _(
|
|
219
|
+
s.type ?? ""
|
|
220
220
|
);
|
|
221
221
|
let n = {};
|
|
222
222
|
return e.exposures && Object.keys(e.exposures).forEach((c) => {
|
|
@@ -229,17 +229,17 @@ function ie(i, e) {
|
|
|
229
229
|
c === a && e.exposureGroups && (n = e.exposureGroups[c]);
|
|
230
230
|
}), n;
|
|
231
231
|
}
|
|
232
|
-
function ae(
|
|
233
|
-
return
|
|
232
|
+
function ae(s) {
|
|
233
|
+
return s == null ? void 0 : s.map((e) => (e.keyword === "pattern" && (e.message = `Invalid format, must match pattern ${e.params.pattern}`), e.keyword === "format" && (e.message = "Invalid format"), e.keyword === "required" && (e.message = "Required"), e.keyword === "minItems" && (e.message = `Must have at least ${e.params.limit} item${e.params.limit !== 1 ? "s" : ""}`), e.keyword === "maxItems" && (e.message = `Must have at most ${e.params.limit} item${e.params.limit !== 1 ? "s" : ""}`), e.keyword === "type" && (e.message = "Invalid format"), e.keyword === "maxLength" && (e.message = `Must be at most ${e.params.limit} character${e.params.limit !== 1 ? "s" : ""}`), e.keyword === "minLength" && (e.message = `Must be at least ${e.params.limit} character${e.params.limit !== 1 ? "s" : ""}`), e.keyword === "minimum" && (e.message = `Must be greater than or equal to ${e.params.limit}`), e.keyword === "maximum" && (e.message = `Must be less than or equal to ${e.params.limit}`), e));
|
|
234
234
|
}
|
|
235
235
|
export {
|
|
236
|
-
|
|
236
|
+
W as dataModelToJSONSchema,
|
|
237
237
|
ee as getAccountRequest,
|
|
238
238
|
te as getQuoteElementRequest,
|
|
239
239
|
se as getQuoteRequest,
|
|
240
|
-
|
|
240
|
+
_ as parseElementTypeAndScopeByElementType,
|
|
241
241
|
ie as retrieveDataModelFromElement,
|
|
242
|
-
|
|
242
|
+
S as retrieveElementFromQuoteByLocator,
|
|
243
243
|
ae as transformErrors
|
|
244
244
|
};
|
|
245
245
|
//# sourceMappingURL=index.es.js.map
|
package/dist/index.es.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.es.js","sources":["../lib/utils/data-model-to-JSON-schema.ts","../lib/utils/get-account-request.ts","../lib/utils/get-quote-element-request.ts","../lib/utils/get-quote-request.ts","../lib/utils/parse-element-type-and-scope-by-element-type.ts","../lib/utils/retrieve-element-from-quote-by-locator.ts","../lib/utils/retrieve-data-model-from-element.ts","../lib/utils/transform-errors.ts"],"sourcesContent":["import type { RJSFSchema } from '@rjsf/utils';\nimport {\n\tAccountResponse,\n\tDataTypeConfigRecord,\n\tElementResponse,\n\tFieldConfigRecord,\n\tQuoteResponse,\n} from '@socotra/ec-react-schemas';\n\ninterface DataModelToJsonSchemaProps {\n\tdata: FieldConfigRecord;\n\tdataTypes?: DataTypeConfigRecord;\n\tscope: 'P' | 'Q';\n\trootDisplayName: string;\n\taccount?: AccountResponse;\n\tquote?: QuoteResponse;\n\telement?: ElementResponse;\n}\n\nexport const dataModelToJSONSchema = (args: DataModelToJsonSchemaProps) => {\n\tconst { data, scope, dataTypes, rootDisplayName, account, quote, element } =\n\t\targs;\n\n\tconst requiredFields: string[] = [];\n\tlet definitions = {};\n\tconst properties = Object.fromEntries(\n\t\tObject.entries(data ?? {})\n\t\t\t.filter(([, value]) => {\n\t\t\t\tconst dataScope = value.scope?.split(',').map((s) => s.trim());\n\n\t\t\t\tif (!dataScope) {\n\t\t\t\t\treturn true;\n\t\t\t\t}\n\t\t\t\tif (\n\t\t\t\t\t(scope === 'P' && dataScope?.includes('P')) ||\n\t\t\t\t\tdataScope?.includes('Q')\n\t\t\t\t) {\n\t\t\t\t\treturn true;\n\t\t\t\t}\n\t\t\t\tif (scope === 'Q' && dataScope?.includes('Q')) {\n\t\t\t\t\treturn true;\n\t\t\t\t}\n\t\t\t\treturn false;\n\t\t\t})\n\t\t\t.map(([key, value]) => {\n\t\t\t\tlet isOptional = false;\n\t\t\t\tlet isArray = false;\n\t\t\t\tlet isCustomDataType = false;\n\t\t\t\tconst displayName = value.displayName ?? key;\n\t\t\t\tconst quantifier = value.type?.slice(-1);\n\t\t\t\tconst maxLength = value.maxLength;\n\t\t\t\tconst minLength = value.minLength;\n\t\t\t\tconst max = value.max;\n\t\t\t\tconst min = value.min;\n\t\t\t\tconst regex = value.regex;\n\t\t\t\tlet type: string = value.type ?? '';\n\t\t\t\tlet format: string | undefined;\n\n\t\t\t\tswitch (quantifier) {\n\t\t\t\t\tcase '*':\n\t\t\t\t\t\tisArray = true;\n\t\t\t\t\t\tisOptional = true;\n\t\t\t\t\t\ttype = type?.split('*')[0];\n\t\t\t\t\t\tbreak;\n\t\t\t\t\tcase '?':\n\t\t\t\t\t\ttype = type?.split('?')[0];\n\t\t\t\t\t\tisOptional = true;\n\t\t\t\t\t\tbreak;\n\t\t\t\t\tcase '+':\n\t\t\t\t\t\tisArray = true;\n\t\t\t\t\t\ttype = type?.split('+')[0];\n\t\t\t\t\t\tbreak;\n\t\t\t\t\tcase '!':\n\t\t\t\t\t\ttype = type?.split('!')[0];\n\t\t\t\t\t\tbreak;\n\t\t\t\t\tdefault:\n\t\t\t\t\t\tbreak;\n\t\t\t\t}\n\n\t\t\t\tswitch (type) {\n\t\t\t\t\t// fields can be either 'string', 'int', 'long', 'decimal', 'dateTime', 'date', 'boolean' in kernel\n\t\t\t\t\t// JSON schema supports 'string', 'integer', 'number', 'boolean', 'null'\n\t\t\t\t\tcase 'string':\n\t\t\t\t\t\ttype = 'string';\n\t\t\t\t\t\tbreak;\n\t\t\t\t\tcase 'int':\n\t\t\t\t\tcase 'long':\n\t\t\t\t\t\ttype = 'integer';\n\t\t\t\t\t\tbreak;\n\t\t\t\t\tcase 'decimal':\n\t\t\t\t\t\ttype = 'number';\n\t\t\t\t\t\tbreak;\n\t\t\t\t\tcase 'dateTime':\n\t\t\t\t\t\ttype = 'string';\n\t\t\t\t\t\tformat = 'date-time';\n\t\t\t\t\t\tbreak;\n\t\t\t\t\tcase 'date':\n\t\t\t\t\t\ttype = 'string';\n\t\t\t\t\t\tformat = 'date';\n\t\t\t\t\t\tbreak;\n\t\t\t\t\tcase 'boolean':\n\t\t\t\t\tcase 'bool':\n\t\t\t\t\t\ttype = 'boolean';\n\t\t\t\t\t\tbreak;\n\t\t\t\t\tdefault:\n\t\t\t\t\t\tisCustomDataType = true;\n\t\t\t\t\t\tbreak;\n\t\t\t\t}\n\n\t\t\t\tif (!isOptional && !isCustomDataType && !isArray) {\n\t\t\t\t\trequiredFields.push(key);\n\t\t\t\t}\n\n\t\t\t\tif (isCustomDataType) {\n\t\t\t\t\tconst customDataType = dataTypes?.[type];\n\t\t\t\t\tif (customDataType) {\n\t\t\t\t\t\tlet defaultValues = isArray ? [] : {};\n\t\t\t\t\t\tconst referenceSchema = dataModelToJSONSchema({\n\t\t\t\t\t\t\tdata: customDataType.data ?? {},\n\t\t\t\t\t\t\tscope,\n\t\t\t\t\t\t\tdataTypes,\n\t\t\t\t\t\t\trootDisplayName: key,\n\t\t\t\t\t\t});\n\n\t\t\t\t\t\t// find any preset quote or account data for this custom data type\n\t\t\t\t\t\tif (quote) {\n\t\t\t\t\t\t\tif (quote.element?.data?.[key]) {\n\t\t\t\t\t\t\t\tdefaultValues = quote.element?.data?.[key];\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t\tif (element) {\n\t\t\t\t\t\t\tif (element?.data?.[key]) {\n\t\t\t\t\t\t\t\tdefaultValues = element?.data?.[key];\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t\tif (account) {\n\t\t\t\t\t\t\tif (account?.data?.[key]) {\n\t\t\t\t\t\t\t\tdefaultValues = account?.data?.[key];\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t\tdefinitions = {\n\t\t\t\t\t\t\t...definitions,\n\t\t\t\t\t\t\t[`${type}`]: referenceSchema,\n\t\t\t\t\t\t};\n\t\t\t\t\t\tif (isArray) {\n\t\t\t\t\t\t\treturn [\n\t\t\t\t\t\t\t\tkey,\n\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\ttitle: key\n\t\t\t\t\t\t\t\t\t\t.replace(/([A-Z])/g, ' $1')\n\t\t\t\t\t\t\t\t\t\t// uppercase the first character\n\t\t\t\t\t\t\t\t\t\t.replace(/^./, function (str) {\n\t\t\t\t\t\t\t\t\t\t\treturn str.toUpperCase();\n\t\t\t\t\t\t\t\t\t\t}),\n\t\t\t\t\t\t\t\t\ttype: 'array',\n\t\t\t\t\t\t\t\t\tdefault: defaultValues,\n\t\t\t\t\t\t\t\t\titems: {\n\t\t\t\t\t\t\t\t\t\t['$ref']: `#/definitions/${type}`,\n\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t\t...(!isOptional && { minItems: 1 }),\n\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t];\n\t\t\t\t\t\t}\n\t\t\t\t\t\treturn [\n\t\t\t\t\t\t\tkey,\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\ttitle: key\n\t\t\t\t\t\t\t\t\t.replace(/([A-Z])/g, ' $1')\n\t\t\t\t\t\t\t\t\t// uppercase the first character\n\t\t\t\t\t\t\t\t\t.replace(/^./, function (str) {\n\t\t\t\t\t\t\t\t\t\treturn str.toUpperCase();\n\t\t\t\t\t\t\t\t\t}),\n\t\t\t\t\t\t\t\tdefault: defaultValues,\n\t\t\t\t\t\t\t\t['$ref']: `#/definitions/${type}`,\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t];\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\tlet defaultValue: string | boolean | object | undefined = '';\n\n\t\t\t\tif (account) {\n\t\t\t\t\t// An account in draft state will always have keys in the same casing as the data model\n\t\t\t\t\t// An account in validated state will have keys in camelCase, so we need to convert the keys to match the way the kernel sets them\n\t\t\t\t\tconst dataKey =\n\t\t\t\t\t\taccount?.state === 'validated'\n\t\t\t\t\t\t\t? key.charAt(0).toLowerCase() + key.slice(1)\n\t\t\t\t\t\t\t: key;\n\n\t\t\t\t\tdefaultValue = account?.data?.[dataKey]\n\t\t\t\t\t\t? account?.data?.[dataKey]\n\t\t\t\t\t\t: type === 'boolean'\n\t\t\t\t\t\t\t? Boolean(value.defaultValue)\n\t\t\t\t\t\t\t: value.defaultValue;\n\t\t\t\t}\n\n\t\t\t\tif (quote) {\n\t\t\t\t\tdefaultValue = quote.element?.data?.[key]\n\t\t\t\t\t\t? quote.element?.data?.[key]\n\t\t\t\t\t\t: type === 'boolean'\n\t\t\t\t\t\t\t? Boolean(value.defaultValue)\n\t\t\t\t\t\t\t: value.defaultValue;\n\t\t\t\t}\n\n\t\t\t\tif (element) {\n\t\t\t\t\tdefaultValue = element?.data?.[key]\n\t\t\t\t\t\t? element?.data?.[key]\n\t\t\t\t\t\t: type === 'boolean'\n\t\t\t\t\t\t\t? Boolean(value.defaultValue)\n\t\t\t\t\t\t\t: value.defaultValue;\n\t\t\t\t}\n\n\t\t\t\tif (isArray) {\n\t\t\t\t\t// if the field is an array, we need to set the type to 'array' and set the items to the type of the array\n\t\t\t\t\treturn [\n\t\t\t\t\t\tkey,\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\ttitle: displayName,\n\t\t\t\t\t\t\ttype: 'array',\n\t\t\t\t\t\t\tdefault: defaultValue,\n\t\t\t\t\t\t\titems: {\n\t\t\t\t\t\t\t\ttype,\n\t\t\t\t\t\t\t\t...(maxLength && { maxLength }),\n\t\t\t\t\t\t\t\t...(minLength && { minLength }),\n\t\t\t\t\t\t\t\t...(min && { min }),\n\t\t\t\t\t\t\t\t...(max && { max }),\n\t\t\t\t\t\t\t\t...(format && { format }),\n\t\t\t\t\t\t\t\t...(regex && { pattern: value.regex }),\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t...(!isOptional && { minItems: 1 }),\n\t\t\t\t\t\t},\n\t\t\t\t\t];\n\t\t\t\t}\n\n\t\t\t\tconst property = [\n\t\t\t\t\tkey,\n\t\t\t\t\t{\n\t\t\t\t\t\ttitle: displayName,\n\t\t\t\t\t\ttype,\n\t\t\t\t\t\t...(defaultValue && { default: defaultValue }),\n\t\t\t\t\t\t...(minLength && { minLength }),\n\t\t\t\t\t\t...(maxLength && { maxLength }),\n\t\t\t\t\t\t...(min && { minimum: parseInt(min) }),\n\t\t\t\t\t\t...(max && { maximum: parseInt(max) }),\n\t\t\t\t\t\t...(format && { format }),\n\t\t\t\t\t\t...(value.options && { enum: value.options }),\n\t\t\t\t\t\t...(regex && { pattern: value.regex }),\n\t\t\t\t\t},\n\t\t\t\t];\n\t\t\t\treturn property;\n\t\t\t}),\n\t);\n\n\tconst schema: RJSFSchema = {\n\t\ttitle: rootDisplayName,\n\t\ttype: 'object',\n\t\tdefinitions,\n\t\trequired: requiredFields,\n\t\tproperties,\n\t};\n\n\treturn schema;\n};\n","import { AccountRequest } from '@socotra/ec-react-schemas';\n\nexport const getAccountRequest = (formData: TODO): AccountRequest => {\n\tconst autoValidate = formData.autoValidate;\n\tconst delinquencyPlanName = formData.delinquencyPlanName;\n\tconst type = formData.accountType;\n\n\t// filter out the accountType, autoValidate, and delinquencyPlanName\n\tconst data = Object.keys(formData).reduce(\n\t\t(acc, key) => {\n\t\t\tif (\n\t\t\t\tkey !== 'accountType' &&\n\t\t\t\tkey !== 'autoValidate' &&\n\t\t\t\tkey !== 'delinquencyPlanName'\n\t\t\t) {\n\t\t\t\tacc[key] = formData[key];\n\t\t\t}\n\t\t\treturn acc;\n\t\t},\n\t\t{} as { [key: string]: object },\n\t);\n\n\tconst request = {\n\t\tautoValidate,\n\t\tdelinquencyPlanName,\n\t\ttype,\n\t\tdata,\n\t};\n\n\treturn request;\n};\n","import { ElementRequest, QuoteRequest } from '@socotra/ec-react-schemas';\n\ntype GetQuoteElementRequestAttributes = {\n\tformData: { [key: string]: unknown };\n\tlocator: string;\n};\n\nexport const getQuoteElementRequest = ({\n\tformData,\n\tlocator,\n}: GetQuoteElementRequestAttributes): QuoteRequest => {\n\tconst elementRequest: ElementRequest = {\n\t\tlocator,\n\t\tsetData: formData,\n\t};\n\n\tconst request: QuoteRequest = {\n\t\telements: [elementRequest],\n\t};\n\n\treturn request;\n};\n","import { AccountRequest, QuoteRequest } from '@socotra/ec-react-schemas';\n\ninterface QuoteDefaultFields {\n\tdelinquencyPlanName: string;\n\tstartTime: string;\n\tendTime: string;\n\tcurrency: string;\n\texpirationTime: string;\n\ttimezone: string;\n}\n\ntype GetQuoteRequestAttributes =\n\t| {\n\t\t\tformData: object;\n\t\t\thideDefaultFields: true;\n\t\t\thideConfiguredFields: true;\n\t }\n\t| {\n\t\t\tformData: QuoteDefaultFields;\n\t\t\thideDefaultFields: false;\n\t\t\thideConfiguredFields: true;\n\t }\n\t| {\n\t\t\tformData: TODO;\n\t\t\thideDefaultFields: true;\n\t\t\thideConfiguredFields: false;\n\t }\n\t| {\n\t\t\tformData: QuoteDefaultFields & TODO;\n\t\t\thideDefaultFields: false;\n\t\t\thideConfiguredFields: false;\n\t };\n\nfunction removeQuoteDefaultFields(formData: QuoteDefaultFields & TODO): TODO {\n\tconst {\n\t\tdelinquencyPlanName,\n\t\tstartTime,\n\t\tendTime,\n\t\tcurrency,\n\t\texpirationTime,\n\t\ttimezone,\n\t\t...rest\n\t} = formData;\n\n\treturn rest;\n}\n\nfunction getQuoteDefaultFields(formData: TODO): QuoteDefaultFields {\n\tconst {\n\t\tdelinquencyPlanName,\n\t\tstartTime,\n\t\tendTime,\n\t\tcurrency,\n\t\texpirationTime,\n\t\ttimezone,\n\t} = formData;\n\n\treturn {\n\t\tdelinquencyPlanName,\n\t\tstartTime,\n\t\tendTime,\n\t\tcurrency,\n\t\texpirationTime,\n\t\ttimezone,\n\t};\n}\n\nexport const getQuoteRequest = ({\n\tformData,\n\thideDefaultFields,\n\thideConfiguredFields,\n}: GetQuoteRequestAttributes): AccountRequest => {\n\tlet request: QuoteRequest = {};\n\n\tif (!hideDefaultFields) {\n\t\tconst defaultFields = getQuoteDefaultFields(formData);\n\t\trequest = {\n\t\t\t...defaultFields,\n\t\t};\n\t}\n\n\tif (!hideConfiguredFields) {\n\t\tconst quoteFields = removeQuoteDefaultFields(formData);\n\t\trequest = {\n\t\t\t...request,\n\t\t\tsetData: quoteFields,\n\t\t};\n\t}\n\n\treturn request;\n};\n","/**\n * Takes an element type and splits the postfix scope from the base model name. E.g., 'PersonalAutoQuote' becomes ['PersonalAuto', 'Quote']\n * @param elementType The element type to parse, e.g. `element.type` from an `ElementResponse`\n * @returns [elementName: string, scope: 'Quote' | 'QuickQuote' | 'Policy' | null]\n */\nexport const parseElementTypeAndScopeByElementType = (\n\telementType: string,\n): [elementName: string, scope: 'Quote' | 'QuickQuote' | 'Policy' | null] => {\n\tconst regex = /^(.*?)(Quote|QuickQuote|Policy)$/;\n\tconst match = elementType.match(regex);\n\tif (\n\t\tmatch &&\n\t\t(match[2] === 'Quote' || match[2] === 'QuickQuote' || match[2] === 'Policy')\n\t) {\n\t\treturn [match[1], match[2]]; // match[1] is the base model name, match[2] is the scope\n\t}\n\n\t// Return the original key and null for the scope if no match found\n\treturn [elementType, null];\n};\n","import { ElementResponse } from '@socotra/ec-react-schemas';\n\n/**\n * Takes the root element of a quote and a locator and returns the element with the matching locator\n * @param quoteElement The root element from the QuoteResponse\n * @param locator The locator of the element to retrieve\n * @returns ElementResponse | undefined\n */\nexport function retrieveElementFromQuoteByLocator(\n\tquoteElement: ElementResponse,\n\tlocator: string,\n): ElementResponse | undefined {\n\tif (quoteElement.locator === locator) {\n\t\treturn quoteElement;\n\t}\n\n\tif (quoteElement.elements) {\n\t\tfor (const element of quoteElement.elements) {\n\t\t\tconst foundElement = retrieveElementFromQuoteByLocator(element, locator);\n\t\t\tif (foundElement) {\n\t\t\t\treturn foundElement;\n\t\t\t}\n\t\t}\n\t}\n\n\treturn undefined;\n}\n","import {\n\tDataModel,\n\tElementConfig,\n\tElementResponse,\n} from '@socotra/ec-react-schemas';\n\nimport { parseElementTypeAndScopeByElementType } from './parse-element-type-and-scope-by-element-type';\n\n/**\n * Looks through a data model for a matching element type and returns the element model\n * @param element The element to retrieve the data model for\n * @param dataModel The full resolved data model to search\n * @returns ElementConfig\n */\nexport function retrieveDataModelFromElement(\n\telement: ElementResponse,\n\tdataModel: DataModel,\n) {\n\tconst [elementType] = parseElementTypeAndScopeByElementType(\n\t\telement.type ?? '',\n\t);\n\n\tlet elementModel: ElementConfig = {};\n\n\t// Look in exposures\n\tif (dataModel.exposures) {\n\t\tObject.keys(dataModel.exposures).forEach((exposureName) => {\n\t\t\tif (exposureName === elementType && dataModel.exposures) {\n\t\t\t\telementModel = dataModel.exposures[exposureName];\n\t\t\t}\n\t\t});\n\t}\n\n\t// Look in coverages\n\tif (dataModel.coverages) {\n\t\tObject.keys(dataModel.coverages).forEach((coverageName) => {\n\t\t\tif (coverageName === elementType && dataModel.coverages) {\n\t\t\t\telementModel = dataModel.coverages[coverageName];\n\t\t\t}\n\t\t});\n\t}\n\n\t// Look in policyLines\n\tif (dataModel.policyLines) {\n\t\tObject.keys(dataModel.policyLines).forEach((policyLineName) => {\n\t\t\tif (policyLineName === elementType && dataModel.policyLines) {\n\t\t\t\telementModel = dataModel.policyLines[policyLineName];\n\t\t\t}\n\t\t});\n\t}\n\n\t// look in ExposureGroups\n\tif (dataModel.exposureGroups) {\n\t\tObject.keys(dataModel.exposureGroups).forEach((exposureGroupName) => {\n\t\t\tif (exposureGroupName === elementType && dataModel.exposureGroups) {\n\t\t\t\telementModel = dataModel.exposureGroups[exposureGroupName];\n\t\t\t}\n\t\t});\n\t}\n\n\treturn elementModel;\n}\n","import { type RJSFValidationError } from '@rjsf/utils';\n\nexport function transformErrors(errors: RJSFValidationError[]) {\n\treturn errors.map((error) => {\n\t\tif (error.name === 'pattern') {\n\t\t\terror.message = `Invalid format, must match pattern ${error.params.pattern}`;\n\t\t}\n\t\tif (error.name === 'format') {\n\t\t\terror.message = 'Invalid format';\n\t\t}\n\t\tif (error.name === 'required') {\n\t\t\terror.message = 'Required';\n\t\t}\n\t\tif (error.name === 'minItems') {\n\t\t\terror.message = `Must have at least ${error.params.limit} item${\n\t\t\t\terror.params.limit !== 1 ? 's' : ''\n\t\t\t}`;\n\t\t}\n\t\tif (error.name === 'maxItems') {\n\t\t\terror.message = `Must have at most ${error.params.limit} item${\n\t\t\t\terror.params.limit !== 1 ? 's' : ''\n\t\t\t}`;\n\t\t}\n\t\tif (error.name === 'type') {\n\t\t\terror.message = 'Invalid format';\n\t\t}\n\t\tif (error.name === 'maxLength') {\n\t\t\terror.message = `Must be at most ${error.params.limit} character${\n\t\t\t\terror.params.limit !== 1 ? 's' : ''\n\t\t\t}`;\n\t\t}\n\t\tif (error.name === 'minLength') {\n\t\t\terror.message = `Must be at least ${error.params.limit} character${\n\t\t\t\terror.params.limit !== 1 ? 's' : ''\n\t\t\t}`;\n\t\t}\n\t\tif (error.name === 'minimum') {\n\t\t\terror.message = `Must be greater than or equal to ${error.params.limit}`;\n\t\t}\n\t\tif (error.name === 'maximum') {\n\t\t\terror.message = `Must be less than or equal to ${error.params.limit}`;\n\t\t}\n\t\treturn error;\n\t});\n}\n"],"names":["dataModelToJSONSchema","args","data","scope","dataTypes","rootDisplayName","account","quote","element","requiredFields","definitions","properties","value","_a","dataScope","s","key","_b","_c","_d","_e","_f","_g","_h","_i","_j","_k","_l","_m","_n","_o","_p","_q","isOptional","isArray","isCustomDataType","displayName","quantifier","maxLength","minLength","max","min","regex","type","format","customDataType","defaultValues","referenceSchema","str","defaultValue","dataKey","getAccountRequest","formData","autoValidate","delinquencyPlanName","acc","getQuoteElementRequest","locator","removeQuoteDefaultFields","startTime","endTime","currency","expirationTime","timezone","rest","getQuoteDefaultFields","getQuoteRequest","hideDefaultFields","hideConfiguredFields","request","quoteFields","parseElementTypeAndScopeByElementType","elementType","match","retrieveElementFromQuoteByLocator","quoteElement","foundElement","retrieveDataModelFromElement","dataModel","elementModel","exposureName","coverageName","policyLineName","exposureGroupName","transformErrors","errors","error"],"mappings":"AAmBa,MAAAA,IAAwB,CAACC,MAAqC;AACpE,QAAA,EAAE,MAAAC,GAAM,OAAAC,GAAO,WAAAC,GAAW,iBAAAC,GAAiB,SAAAC,GAAS,OAAAC,GAAO,SAAAC,EAChE,IAAAP,GAEKQ,IAA2B,CAAA;AACjC,MAAIC,IAAc,CAAA;AAClB,QAAMC,IAAa,OAAO;AAAA,IACzB,OAAO,QAAQT,KAAQ,CAAA,CAAE,EACvB,OAAO,CAAC,CAAG,EAAAU,CAAK,MAAM;AARb,UAAAC;AASH,YAAAC,KAAYD,IAAAD,EAAM,UAAN,gBAAAC,EAAa,MAAM,KAAK,IAAI,CAACE,MAAMA,EAAE,KAAM;AAW7D,aATI,IAACD,KAIHX,MAAU,QAAOW,KAAA,QAAAA,EAAW,SAAS,SACtCA,KAAA,QAAAA,EAAW,SAAS,QAIjBX,MAAU,QAAOW,KAAA,QAAAA,EAAW,SAAS;AAAA,IAIzC,CAAA,EACA,IAAI,CAAC,CAACE,GAAKJ,CAAK,MAAM;AAzBb,UAAAC,GAAAI,GAAAC,GAAAC,GAAAC,GAAAC,GAAAC,GAAAC,GAAAC,GAAAC,GAAAC,GAAAC,GAAAC,GAAAC,GAAAC,GAAAC,GAAAC;AA0BT,UAAIC,IAAa,IACbC,IAAU,IACVC,IAAmB;AACjB,YAAAC,IAAcxB,EAAM,eAAeI,GACnCqB,KAAaxB,IAAAD,EAAM,SAAN,gBAAAC,EAAY,MAAM,KAC/ByB,IAAY1B,EAAM,WAClB2B,IAAY3B,EAAM,WAClB4B,IAAM5B,EAAM,KACZ6B,IAAM7B,EAAM,KACZ8B,IAAQ9B,EAAM;AAChB,UAAA+B,IAAe/B,EAAM,QAAQ,IAC7BgC;AAEJ,cAAQP,GAAY;AAAA,QACnB,KAAK;AACM,UAAAH,IAAA,IACGD,IAAA,IACbU,IAAOA,KAAA,gBAAAA,EAAM,MAAM,KAAK;A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,cAClBA,EAAM,UAAU,iCAAiCA,EAAM,OAAO,KAAK,KAE7DA,EACP;AACF;"}
|
|
1
|
+
{"version":3,"file":"index.es.js","sources":["../lib/utils/data-model-to-JSON-schema.ts","../lib/utils/get-account-request.ts","../lib/utils/get-quote-element-request.ts","../lib/utils/get-quote-request.ts","../lib/utils/parse-element-type-and-scope-by-element-type.ts","../lib/utils/retrieve-element-from-quote-by-locator.ts","../lib/utils/retrieve-data-model-from-element.ts","../lib/utils/transform-errors.ts"],"sourcesContent":["import { JsonSchema7 } from '@jsonforms/core';\nimport {\n\tAccountResponse,\n\tDataTypeConfigRecord,\n\tElementResponse,\n\tFieldConfigRecord,\n\tQuoteResponse,\n} from '@socotra/ec-react-schemas';\n\ninterface DataModelToJsonSchemaProps {\n\tdata: FieldConfigRecord;\n\tdataTypes?: DataTypeConfigRecord;\n\tscope: 'P' | 'Q';\n\trootDisplayName: string;\n\taccount?: AccountResponse;\n\tquote?: QuoteResponse;\n\telement?: ElementResponse;\n}\n\nexport const dataModelToJSONSchema = (args: DataModelToJsonSchemaProps) => {\n\tconst { data, scope, dataTypes, rootDisplayName, account, quote, element } =\n\t\targs;\n\n\tconst requiredFields: string[] = [];\n\tlet definitions = {};\n\tconst properties = Object.fromEntries(\n\t\tObject.entries(data ?? {})\n\t\t\t.filter(([, value]) => {\n\t\t\t\tconst dataScope = value.scope?.split(',').map((s) => s.trim());\n\n\t\t\t\tif (!dataScope) {\n\t\t\t\t\treturn true;\n\t\t\t\t}\n\t\t\t\tif (\n\t\t\t\t\t(scope === 'P' && dataScope?.includes('P')) ||\n\t\t\t\t\tdataScope?.includes('Q')\n\t\t\t\t) {\n\t\t\t\t\treturn true;\n\t\t\t\t}\n\t\t\t\tif (scope === 'Q' && dataScope?.includes('Q')) {\n\t\t\t\t\treturn true;\n\t\t\t\t}\n\t\t\t\treturn false;\n\t\t\t})\n\t\t\t.map(([key, value]) => {\n\t\t\t\tlet isOptional = false;\n\t\t\t\tlet isArray = false;\n\t\t\t\tlet isCustomDataType = false;\n\t\t\t\tconst displayName = value.displayName ?? key;\n\t\t\t\tconst quantifier = value.type?.slice(-1);\n\t\t\t\tconst maxLength = value.maxLength;\n\t\t\t\tconst minLength = value.minLength;\n\t\t\t\tconst max = value.max;\n\t\t\t\tconst min = value.min;\n\t\t\t\tconst regex = value.regex;\n\t\t\t\tlet type: string = value.type ?? '';\n\t\t\t\tlet format: string | undefined;\n\n\t\t\t\tswitch (quantifier) {\n\t\t\t\t\tcase '*':\n\t\t\t\t\t\tisArray = true;\n\t\t\t\t\t\tisOptional = true;\n\t\t\t\t\t\ttype = type?.split('*')[0];\n\t\t\t\t\t\tbreak;\n\t\t\t\t\tcase '?':\n\t\t\t\t\t\ttype = type?.split('?')[0];\n\t\t\t\t\t\tisOptional = true;\n\t\t\t\t\t\tbreak;\n\t\t\t\t\tcase '+':\n\t\t\t\t\t\tisArray = true;\n\t\t\t\t\t\ttype = type?.split('+')[0];\n\t\t\t\t\t\tbreak;\n\t\t\t\t\tcase '!':\n\t\t\t\t\t\ttype = type?.split('!')[0];\n\t\t\t\t\t\tbreak;\n\t\t\t\t\tdefault:\n\t\t\t\t\t\tbreak;\n\t\t\t\t}\n\n\t\t\t\tswitch (type) {\n\t\t\t\t\t// fields can be either 'string', 'int', 'long', 'decimal', 'dateTime', 'date', 'boolean' in kernel\n\t\t\t\t\t// JSON schema supports 'string', 'integer', 'number', 'boolean', 'null'\n\t\t\t\t\tcase 'string':\n\t\t\t\t\t\ttype = 'string';\n\t\t\t\t\t\tbreak;\n\t\t\t\t\tcase 'int':\n\t\t\t\t\tcase 'long':\n\t\t\t\t\t\ttype = 'integer';\n\t\t\t\t\t\tbreak;\n\t\t\t\t\tcase 'decimal':\n\t\t\t\t\t\ttype = 'number';\n\t\t\t\t\t\tbreak;\n\t\t\t\t\tcase 'dateTime':\n\t\t\t\t\t\ttype = 'string';\n\t\t\t\t\t\tformat = 'date-time';\n\t\t\t\t\t\tbreak;\n\t\t\t\t\tcase 'date':\n\t\t\t\t\t\ttype = 'string';\n\t\t\t\t\t\tformat = 'date';\n\t\t\t\t\t\tbreak;\n\t\t\t\t\tcase 'boolean':\n\t\t\t\t\tcase 'bool':\n\t\t\t\t\t\ttype = 'boolean';\n\t\t\t\t\t\tbreak;\n\t\t\t\t\tdefault:\n\t\t\t\t\t\tisCustomDataType = true;\n\t\t\t\t\t\tbreak;\n\t\t\t\t}\n\n\t\t\t\tif (!isOptional && !isCustomDataType && !isArray) {\n\t\t\t\t\trequiredFields.push(key);\n\t\t\t\t}\n\n\t\t\t\tif (isCustomDataType) {\n\t\t\t\t\tconst customDataType = dataTypes?.[type];\n\t\t\t\t\tif (customDataType) {\n\t\t\t\t\t\tlet defaultValues = isArray ? [] : {};\n\t\t\t\t\t\tconst referenceSchema = dataModelToJSONSchema({\n\t\t\t\t\t\t\tdata: customDataType.data ?? {},\n\t\t\t\t\t\t\tscope,\n\t\t\t\t\t\t\tdataTypes,\n\t\t\t\t\t\t\trootDisplayName: key,\n\t\t\t\t\t\t});\n\n\t\t\t\t\t\t// find any preset quote or account data for this custom data type\n\t\t\t\t\t\tif (quote) {\n\t\t\t\t\t\t\tif (quote.element?.data?.[key]) {\n\t\t\t\t\t\t\t\tdefaultValues = quote.element?.data?.[key];\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t\tif (element) {\n\t\t\t\t\t\t\tif (element?.data?.[key]) {\n\t\t\t\t\t\t\t\tdefaultValues = element?.data?.[key];\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t\tif (account) {\n\t\t\t\t\t\t\tif (account?.data?.[key]) {\n\t\t\t\t\t\t\t\tdefaultValues = account?.data?.[key];\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t\tdefinitions = {\n\t\t\t\t\t\t\t...definitions,\n\t\t\t\t\t\t\t[`${type}`]: referenceSchema,\n\t\t\t\t\t\t};\n\t\t\t\t\t\tif (isArray) {\n\t\t\t\t\t\t\treturn [\n\t\t\t\t\t\t\t\tkey,\n\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\ttitle: key\n\t\t\t\t\t\t\t\t\t\t.replace(/([A-Z])/g, ' $1')\n\t\t\t\t\t\t\t\t\t\t// uppercase the first character\n\t\t\t\t\t\t\t\t\t\t.replace(/^./, function (str) {\n\t\t\t\t\t\t\t\t\t\t\treturn str.toUpperCase();\n\t\t\t\t\t\t\t\t\t\t}),\n\t\t\t\t\t\t\t\t\ttype: 'array',\n\t\t\t\t\t\t\t\t\tdefault: defaultValues,\n\t\t\t\t\t\t\t\t\titems: {\n\t\t\t\t\t\t\t\t\t\t['$ref']: `#/definitions/${type}`,\n\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t\t...(!isOptional && { minItems: 1 }),\n\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t];\n\t\t\t\t\t\t}\n\t\t\t\t\t\treturn [\n\t\t\t\t\t\t\tkey,\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\ttitle: key\n\t\t\t\t\t\t\t\t\t.replace(/([A-Z])/g, ' $1')\n\t\t\t\t\t\t\t\t\t// uppercase the first character\n\t\t\t\t\t\t\t\t\t.replace(/^./, function (str) {\n\t\t\t\t\t\t\t\t\t\treturn str.toUpperCase();\n\t\t\t\t\t\t\t\t\t}),\n\t\t\t\t\t\t\t\tdefault: defaultValues,\n\t\t\t\t\t\t\t\t['$ref']: `#/definitions/${type}`,\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t];\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\tlet defaultValue: string | boolean | object | undefined = '';\n\n\t\t\t\tif (account) {\n\t\t\t\t\t// An account in draft state will always have keys in the same casing as the data model\n\t\t\t\t\t// An account in validated state will have keys in camelCase, so we need to convert the keys to match the way the kernel sets them\n\t\t\t\t\tconst dataKey =\n\t\t\t\t\t\taccount?.state === 'validated'\n\t\t\t\t\t\t\t? key.charAt(0).toLowerCase() + key.slice(1)\n\t\t\t\t\t\t\t: key;\n\n\t\t\t\t\tdefaultValue = account?.data?.[dataKey]\n\t\t\t\t\t\t? account?.data?.[dataKey]\n\t\t\t\t\t\t: type === 'boolean'\n\t\t\t\t\t\t\t? Boolean(value.defaultValue)\n\t\t\t\t\t\t\t: value.defaultValue;\n\t\t\t\t}\n\n\t\t\t\tif (quote) {\n\t\t\t\t\tdefaultValue = quote.element?.data?.[key]\n\t\t\t\t\t\t? quote.element?.data?.[key]\n\t\t\t\t\t\t: type === 'boolean'\n\t\t\t\t\t\t\t? Boolean(value.defaultValue)\n\t\t\t\t\t\t\t: value.defaultValue;\n\t\t\t\t}\n\n\t\t\t\tif (element) {\n\t\t\t\t\tdefaultValue = element?.data?.[key]\n\t\t\t\t\t\t? element?.data?.[key]\n\t\t\t\t\t\t: type === 'boolean'\n\t\t\t\t\t\t\t? Boolean(value.defaultValue)\n\t\t\t\t\t\t\t: value.defaultValue;\n\t\t\t\t}\n\n\t\t\t\tif (isArray) {\n\t\t\t\t\t// if the field is an array, we need to set the type to 'array' and set the items to the type of the array\n\t\t\t\t\treturn [\n\t\t\t\t\t\tkey,\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\ttitle: displayName,\n\t\t\t\t\t\t\ttype: 'array',\n\t\t\t\t\t\t\tdefault: defaultValue,\n\t\t\t\t\t\t\titems: {\n\t\t\t\t\t\t\t\ttype,\n\t\t\t\t\t\t\t\t...(maxLength && { maxLength }),\n\t\t\t\t\t\t\t\t...(minLength && { minLength }),\n\t\t\t\t\t\t\t\t...(min && { min }),\n\t\t\t\t\t\t\t\t...(max && { max }),\n\t\t\t\t\t\t\t\t...(format && { format }),\n\t\t\t\t\t\t\t\t...(regex && { pattern: value.regex }),\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t...(!isOptional && { minItems: 1 }),\n\t\t\t\t\t\t},\n\t\t\t\t\t];\n\t\t\t\t}\n\n\t\t\t\tconst property = [\n\t\t\t\t\tkey,\n\t\t\t\t\t{\n\t\t\t\t\t\ttitle: displayName,\n\t\t\t\t\t\ttype,\n\t\t\t\t\t\t...(defaultValue && { default: defaultValue }),\n\t\t\t\t\t\t...(minLength && { minLength }),\n\t\t\t\t\t\t...(maxLength && { maxLength }),\n\t\t\t\t\t\t...(min && { minimum: parseInt(min) }),\n\t\t\t\t\t\t...(max && { maximum: parseInt(max) }),\n\t\t\t\t\t\t...(format && { format }),\n\t\t\t\t\t\t...(value.options && { enum: value.options }),\n\t\t\t\t\t\t...(regex && { pattern: value.regex }),\n\t\t\t\t\t},\n\t\t\t\t];\n\t\t\t\treturn property;\n\t\t\t}),\n\t);\n\n\tconst schema: JsonSchema7 = {\n\t\ttitle: rootDisplayName,\n\t\ttype: 'object',\n\t\tdefinitions,\n\t\trequired: requiredFields,\n\t\tproperties,\n\t};\n\n\treturn schema;\n};\n","import { AccountRequest } from '@socotra/ec-react-schemas';\n\nexport const getAccountRequest = (formData: TODO): AccountRequest => {\n\tconst autoValidate = formData.autoValidate;\n\tconst delinquencyPlanName = formData.delinquencyPlanName;\n\tconst type = formData.accountType;\n\n\t// filter out the accountType, autoValidate, and delinquencyPlanName\n\tconst data = Object.keys(formData).reduce(\n\t\t(acc, key) => {\n\t\t\tif (\n\t\t\t\tkey !== 'accountType' &&\n\t\t\t\tkey !== 'autoValidate' &&\n\t\t\t\tkey !== 'delinquencyPlanName'\n\t\t\t) {\n\t\t\t\tacc[key] = formData[key];\n\t\t\t}\n\t\t\treturn acc;\n\t\t},\n\t\t{} as { [key: string]: object },\n\t);\n\n\tconst request = {\n\t\tautoValidate,\n\t\tdelinquencyPlanName,\n\t\ttype,\n\t\tdata,\n\t};\n\n\treturn request;\n};\n","import { ElementRequest, QuoteRequest } from '@socotra/ec-react-schemas';\n\ntype GetQuoteElementRequestAttributes = {\n\tformData: { [key: string]: unknown };\n\tlocator: string;\n};\n\nexport const getQuoteElementRequest = ({\n\tformData,\n\tlocator,\n}: GetQuoteElementRequestAttributes): QuoteRequest => {\n\tconst elementRequest: ElementRequest = {\n\t\tlocator,\n\t\tsetData: formData,\n\t};\n\n\tconst request: QuoteRequest = {\n\t\telements: [elementRequest],\n\t};\n\n\treturn request;\n};\n","import { AccountRequest, QuoteRequest } from '@socotra/ec-react-schemas';\n\ninterface QuoteDefaultFields {\n\tdelinquencyPlanName: string;\n\tstartTime: string;\n\tendTime: string;\n\tcurrency: string;\n\texpirationTime: string;\n\ttimezone: string;\n}\n\ntype GetQuoteRequestAttributes =\n\t| {\n\t\t\tformData: object;\n\t\t\thideDefaultFields: true;\n\t\t\thideConfiguredFields: true;\n\t }\n\t| {\n\t\t\tformData: QuoteDefaultFields;\n\t\t\thideDefaultFields: false;\n\t\t\thideConfiguredFields: true;\n\t }\n\t| {\n\t\t\tformData: TODO;\n\t\t\thideDefaultFields: true;\n\t\t\thideConfiguredFields: false;\n\t }\n\t| {\n\t\t\tformData: QuoteDefaultFields & TODO;\n\t\t\thideDefaultFields: false;\n\t\t\thideConfiguredFields: false;\n\t };\n\nfunction removeQuoteDefaultFields(formData: QuoteDefaultFields & TODO): TODO {\n\tconst {\n\t\tdelinquencyPlanName,\n\t\tstartTime,\n\t\tendTime,\n\t\tcurrency,\n\t\texpirationTime,\n\t\ttimezone,\n\t\t...rest\n\t} = formData;\n\n\treturn rest;\n}\n\nfunction getQuoteDefaultFields(formData: TODO): QuoteDefaultFields {\n\tconst {\n\t\tdelinquencyPlanName,\n\t\tstartTime,\n\t\tendTime,\n\t\tcurrency,\n\t\texpirationTime,\n\t\ttimezone,\n\t} = formData;\n\n\treturn {\n\t\tdelinquencyPlanName,\n\t\tstartTime,\n\t\tendTime,\n\t\tcurrency,\n\t\texpirationTime,\n\t\ttimezone,\n\t};\n}\n\nexport const getQuoteRequest = ({\n\tformData,\n\thideDefaultFields,\n\thideConfiguredFields,\n}: GetQuoteRequestAttributes): AccountRequest => {\n\tlet request: QuoteRequest = {};\n\n\tif (!hideDefaultFields) {\n\t\tconst defaultFields = getQuoteDefaultFields(formData);\n\t\trequest = {\n\t\t\t...defaultFields,\n\t\t};\n\t}\n\n\tif (!hideConfiguredFields) {\n\t\tconst quoteFields = removeQuoteDefaultFields(formData);\n\t\trequest = {\n\t\t\t...request,\n\t\t\tsetData: quoteFields,\n\t\t};\n\t}\n\n\treturn request;\n};\n","/**\n * Takes an element type and splits the postfix scope from the base model name. E.g., 'PersonalAutoQuote' becomes ['PersonalAuto', 'Quote']\n * @param elementType The element type to parse, e.g. `element.type` from an `ElementResponse`\n * @returns [elementName: string, scope: 'Quote' | 'QuickQuote' | 'Policy' | null]\n */\nexport const parseElementTypeAndScopeByElementType = (\n\telementType: string,\n): [elementName: string, scope: 'Quote' | 'QuickQuote' | 'Policy' | null] => {\n\tconst regex = /^(.*?)(Quote|QuickQuote|Policy)$/;\n\tconst match = elementType.match(regex);\n\tif (\n\t\tmatch &&\n\t\t(match[2] === 'Quote' || match[2] === 'QuickQuote' || match[2] === 'Policy')\n\t) {\n\t\treturn [match[1], match[2]]; // match[1] is the base model name, match[2] is the scope\n\t}\n\n\t// Return the original key and null for the scope if no match found\n\treturn [elementType, null];\n};\n","import { ElementResponse } from '@socotra/ec-react-schemas';\n\n/**\n * Takes the root element of a quote and a locator and returns the element with the matching locator\n * @param quoteElement The root element from the QuoteResponse\n * @param locator The locator of the element to retrieve\n * @returns ElementResponse | undefined\n */\nexport function retrieveElementFromQuoteByLocator(\n\tquoteElement: ElementResponse,\n\tlocator: string,\n): ElementResponse | undefined {\n\tif (quoteElement.locator === locator) {\n\t\treturn quoteElement;\n\t}\n\n\tif (quoteElement.elements) {\n\t\tfor (const element of quoteElement.elements) {\n\t\t\tconst foundElement = retrieveElementFromQuoteByLocator(element, locator);\n\t\t\tif (foundElement) {\n\t\t\t\treturn foundElement;\n\t\t\t}\n\t\t}\n\t}\n\n\treturn undefined;\n}\n","import {\n\tDataModel,\n\tElementConfig,\n\tElementResponse,\n} from '@socotra/ec-react-schemas';\n\nimport { parseElementTypeAndScopeByElementType } from './parse-element-type-and-scope-by-element-type';\n\n/**\n * Looks through a data model for a matching element type and returns the element model\n * @param element The element to retrieve the data model for\n * @param dataModel The full resolved data model to search\n * @returns ElementConfig\n */\nexport function retrieveDataModelFromElement(\n\telement: ElementResponse,\n\tdataModel: DataModel,\n) {\n\tconst [elementType] = parseElementTypeAndScopeByElementType(\n\t\telement.type ?? '',\n\t);\n\n\tlet elementModel: ElementConfig = {};\n\n\t// Look in exposures\n\tif (dataModel.exposures) {\n\t\tObject.keys(dataModel.exposures).forEach((exposureName) => {\n\t\t\tif (exposureName === elementType && dataModel.exposures) {\n\t\t\t\telementModel = dataModel.exposures[exposureName];\n\t\t\t}\n\t\t});\n\t}\n\n\t// Look in coverages\n\tif (dataModel.coverages) {\n\t\tObject.keys(dataModel.coverages).forEach((coverageName) => {\n\t\t\tif (coverageName === elementType && dataModel.coverages) {\n\t\t\t\telementModel = dataModel.coverages[coverageName];\n\t\t\t}\n\t\t});\n\t}\n\n\t// Look in policyLines\n\tif (dataModel.policyLines) {\n\t\tObject.keys(dataModel.policyLines).forEach((policyLineName) => {\n\t\t\tif (policyLineName === elementType && dataModel.policyLines) {\n\t\t\t\telementModel = dataModel.policyLines[policyLineName];\n\t\t\t}\n\t\t});\n\t}\n\n\t// look in ExposureGroups\n\tif (dataModel.exposureGroups) {\n\t\tObject.keys(dataModel.exposureGroups).forEach((exposureGroupName) => {\n\t\t\tif (exposureGroupName === elementType && dataModel.exposureGroups) {\n\t\t\t\telementModel = dataModel.exposureGroups[exposureGroupName];\n\t\t\t}\n\t\t});\n\t}\n\n\treturn elementModel;\n}\n","import { ErrorObject } from 'ajv';\n\nexport function transformErrors(\n\terrors:\n\t\t| ErrorObject<string, Record<string, any>, unknown>[]\n\t\t| null\n\t\t| undefined,\n) {\n\treturn errors?.map((error) => {\n\t\tif (error.keyword === 'pattern') {\n\t\t\terror.message = `Invalid format, must match pattern ${error.params.pattern}`;\n\t\t}\n\t\tif (error.keyword === 'format') {\n\t\t\terror.message = 'Invalid format';\n\t\t}\n\t\tif (error.keyword === 'required') {\n\t\t\terror.message = 'Required';\n\t\t}\n\t\tif (error.keyword === 'minItems') {\n\t\t\terror.message = `Must have at least ${error.params.limit} item${\n\t\t\t\terror.params.limit !== 1 ? 's' : ''\n\t\t\t}`;\n\t\t}\n\t\tif (error.keyword === 'maxItems') {\n\t\t\terror.message = `Must have at most ${error.params.limit} item${\n\t\t\t\terror.params.limit !== 1 ? 's' : ''\n\t\t\t}`;\n\t\t}\n\t\tif (error.keyword === 'type') {\n\t\t\terror.message = 'Invalid format';\n\t\t}\n\t\tif (error.keyword === 'maxLength') {\n\t\t\terror.message = `Must be at most ${error.params.limit} character${\n\t\t\t\terror.params.limit !== 1 ? 's' : ''\n\t\t\t}`;\n\t\t}\n\t\tif (error.keyword === 'minLength') {\n\t\t\terror.message = `Must be at least ${error.params.limit} character${\n\t\t\t\terror.params.limit !== 1 ? 's' : ''\n\t\t\t}`;\n\t\t}\n\t\tif (error.keyword === 'minimum') {\n\t\t\terror.message = `Must be greater than or equal to ${error.params.limit}`;\n\t\t}\n\t\tif (error.keyword === 'maximum') {\n\t\t\terror.message = `Must be less than or equal to ${error.params.limit}`;\n\t\t}\n\t\treturn error;\n\t});\n}\n"],"names":["dataModelToJSONSchema","args","data","scope","dataTypes","rootDisplayName","account","quote","element","requiredFields","definitions","properties","value","_a","dataScope","s","key","_b","_c","_d","_e","_f","_g","_h","_i","_j","_k","_l","_m","_n","_o","_p","_q","isOptional","isArray","isCustomDataType","displayName","quantifier","maxLength","minLength","max","min","regex","type","format","customDataType","defaultValues","referenceSchema","str","defaultValue","dataKey","getAccountRequest","formData","autoValidate","delinquencyPlanName","acc","getQuoteElementRequest","locator","removeQuoteDefaultFields","startTime","endTime","currency","expirationTime","timezone","rest","getQuoteDefaultFields","getQuoteRequest","hideDefaultFields","hideConfiguredFields","request","quoteFields","parseElementTypeAndScopeByElementType","elementType","match","retrieveElementFromQuoteByLocator","quoteElement","foundElement","retrieveDataModelFromElement","dataModel","elementModel","exposureName","coverageName","policyLineName","exposureGroupName","transformErrors","errors","error"],"mappings":"AAmBa,MAAAA,IAAwB,CAACC,MAAqC;AACpE,QAAA,EAAE,MAAAC,GAAM,OAAAC,GAAO,WAAAC,GAAW,iBAAAC,GAAiB,SAAAC,GAAS,OAAAC,GAAO,SAAAC,EAChE,IAAAP,GAEKQ,IAA2B,CAAA;AACjC,MAAIC,IAAc,CAAA;AAClB,QAAMC,IAAa,OAAO;AAAA,IACzB,OAAO,QAAQT,KAAQ,CAAA,CAAE,EACvB,OAAO,CAAC,CAAG,EAAAU,CAAK,MAAM;AARb,UAAAC;AASH,YAAAC,KAAYD,IAAAD,EAAM,UAAN,gBAAAC,EAAa,MAAM,KAAK,IAAI,CAACE,MAAMA,EAAE,KAAM;AAW7D,aATI,IAACD,KAIHX,MAAU,QAAOW,KAAA,QAAAA,EAAW,SAAS,SACtCA,KAAA,QAAAA,EAAW,SAAS,QAIjBX,MAAU,QAAOW,KAAA,QAAAA,EAAW,SAAS;AAAA,IAIzC,CAAA,EACA,IAAI,CAAC,CAACE,GAAKJ,CAAK,MAAM;AAzBb,UAAAC,GAAAI,GAAAC,GAAAC,GAAAC,GAAAC,GAAAC,GAAAC,GAAAC,GAAAC,GAAAC,GAAAC,GAAAC,GAAAC,GAAAC,GAAAC,GAAAC;AA0BT,UAAIC,IAAa,IACbC,IAAU,IACVC,IAAmB;AACjB,YAAAC,IAAcxB,EAAM,eAAeI,GACnCqB,KAAaxB,IAAAD,EAAM,SAAN,gBAAAC,EAAY,MAAM,KAC/ByB,IAAY1B,EAAM,WAClB2B,IAAY3B,EAAM,WAClB4B,IAAM5B,EAAM,KACZ6B,IAAM7B,EAAM,KACZ8B,IAAQ9B,EAAM;AAChB,UAAA+B,IAAe/B,EAAM,QAAQ,IAC7BgC;AAEJ,cAAQP,GAAY;AAAA,QACnB,KAAK;AACM,UAAAH,IAAA,IACGD,IAAA,IACbU,IAAOA,KAAA,gBAAAA,EAAM,MAAM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KAEnEA,EAAM,YAAY,cACrBA,EAAM,UAAU,iCAAiCA,EAAM,OAAO,KAAK,KAE7DA;AAET;"}
|
package/dist/index.umd.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
(function(
|
|
1
|
+
(function(c,d){typeof exports=="object"&&typeof module<"u"?d(exports):typeof define=="function"&&define.amd?define(["exports"],d):(c=typeof globalThis<"u"?globalThis:c||self,d(c.schemas={}))})(this,function(c){"use strict";const d=s=>{const{data:e,scope:n,dataTypes:a,rootDisplayName:o,account:l,quote:r,element:m}=s,V=[];let x={};const te=Object.fromEntries(Object.entries(e??{}).filter(([,u])=>{var f;const i=(f=u.scope)==null?void 0:f.split(",").map(p=>p.trim());return!!(!i||n==="P"&&(i!=null&&i.includes("P"))||i!=null&&i.includes("Q")||n==="Q"&&(i!=null&&i.includes("Q")))}).map(([u,i])=>{var P,I,R,A,B,N,D,C,S,k,G,z,J,U,Z,K,H;let f=!1,p=!1,E=!1;const j=i.displayName??u,se=(P=i.type)==null?void 0:P.slice(-1),q=i.maxLength,T=i.minLength,$=i.max,Q=i.min,F=i.regex;let t=i.type??"",g;switch(se){case"*":p=!0,f=!0,t=t==null?void 0:t.split("*")[0];break;case"?":t=t==null?void 0:t.split("?")[0],f=!0;break;case"+":p=!0,t=t==null?void 0:t.split("+")[0];break;case"!":t=t==null?void 0:t.split("!")[0];break}switch(t){case"string":t="string";break;case"int":case"long":t="integer";break;case"decimal":t="number";break;case"dateTime":t="string",g="date-time";break;case"date":t="string",g="date";break;case"boolean":case"bool":t="boolean";break;default:E=!0;break}if(!f&&!E&&!p&&V.push(u),E){const h=a==null?void 0:a[t];if(h){let y=p?[]:{};const ie=d({data:h.data??{},scope:n,dataTypes:a,rootDisplayName:u});return r&&(R=(I=r.element)==null?void 0:I.data)!=null&&R[u]&&(y=(B=(A=r.element)==null?void 0:A.data)==null?void 0:B[u]),m&&(N=m==null?void 0:m.data)!=null&&N[u]&&(y=(D=m==null?void 0:m.data)==null?void 0:D[u]),l&&(C=l==null?void 0:l.data)!=null&&C[u]&&(y=(S=l==null?void 0:l.data)==null?void 0:S[u]),x={...x,[`${t}`]:ie},p?[u,{title:u.replace(/([A-Z])/g," $1").replace(/^./,function(w){return w.toUpperCase()}),type:"array",default:y,items:{$ref:`#/definitions/${t}`},...!f&&{minItems:1}}]:[u,{title:u.replace(/([A-Z])/g," $1").replace(/^./,function(w){return w.toUpperCase()}),default:y,$ref:`#/definitions/${t}`}]}}let b="";if(l){const h=(l==null?void 0:l.state)==="validated"?u.charAt(0).toLowerCase()+u.slice(1):u;b=(k=l==null?void 0:l.data)!=null&&k[h]?(G=l==null?void 0:l.data)==null?void 0:G[h]:t==="boolean"?!!i.defaultValue:i.defaultValue}return r&&(b=(J=(z=r.element)==null?void 0:z.data)!=null&&J[u]?(Z=(U=r.element)==null?void 0:U.data)==null?void 0:Z[u]:t==="boolean"?!!i.defaultValue:i.defaultValue),m&&(b=(K=m==null?void 0:m.data)!=null&&K[u]?(H=m==null?void 0:m.data)==null?void 0:H[u]:t==="boolean"?!!i.defaultValue:i.defaultValue),p?[u,{title:j,type:"array",default:b,items:{type:t,...q&&{maxLength:q},...T&&{minLength:T},...Q&&{min:Q},...$&&{max:$},...g&&{format:g},...F&&{pattern:i.regex}},...!f&&{minItems:1}}]:[u,{title:j,type:t,...b&&{default:b},...T&&{minLength:T},...q&&{maxLength:q},...Q&&{minimum:parseInt(Q)},...$&&{maximum:parseInt($)},...g&&{format:g},...i.options&&{enum:i.options},...F&&{pattern:i.regex}}]}));return{title:o,type:"object",definitions:x,required:V,properties:te}},W=s=>{const e=s.autoValidate,n=s.delinquencyPlanName,a=s.accountType,o=Object.keys(s).reduce((r,m)=>(m!=="accountType"&&m!=="autoValidate"&&m!=="delinquencyPlanName"&&(r[m]=s[m]),r),{});return{autoValidate:e,delinquencyPlanName:n,type:a,data:o}},X=({formData:s,locator:e})=>({elements:[{locator:e,setData:s}]});function Y(s){const{delinquencyPlanName:e,startTime:n,endTime:a,currency:o,expirationTime:l,timezone:r,...m}=s;return m}function _(s){const{delinquencyPlanName:e,startTime:n,endTime:a,currency:o,expirationTime:l,timezone:r}=s;return{delinquencyPlanName:e,startTime:n,endTime:a,currency:o,expirationTime:l,timezone:r}}const v=({formData:s,hideDefaultFields:e,hideConfiguredFields:n})=>{let a={};if(e||(a={..._(s)}),!n){const o=Y(s);a={...a,setData:o}}return a},L=s=>{const e=/^(.*?)(Quote|QuickQuote|Policy)$/,n=s.match(e);return n&&(n[2]==="Quote"||n[2]==="QuickQuote"||n[2]==="Policy")?[n[1],n[2]]:[s,null]};function O(s,e){if(s.locator===e)return s;if(s.elements)for(const n of s.elements){const a=O(n,e);if(a)return a}}function M(s,e){const[n]=L(s.type??"");let a={};return e.exposures&&Object.keys(e.exposures).forEach(o=>{o===n&&e.exposures&&(a=e.exposures[o])}),e.coverages&&Object.keys(e.coverages).forEach(o=>{o===n&&e.coverages&&(a=e.coverages[o])}),e.policyLines&&Object.keys(e.policyLines).forEach(o=>{o===n&&e.policyLines&&(a=e.policyLines[o])}),e.exposureGroups&&Object.keys(e.exposureGroups).forEach(o=>{o===n&&e.exposureGroups&&(a=e.exposureGroups[o])}),a}function ee(s){return s==null?void 0:s.map(e=>(e.keyword==="pattern"&&(e.message=`Invalid format, must match pattern ${e.params.pattern}`),e.keyword==="format"&&(e.message="Invalid format"),e.keyword==="required"&&(e.message="Required"),e.keyword==="minItems"&&(e.message=`Must have at least ${e.params.limit} item${e.params.limit!==1?"s":""}`),e.keyword==="maxItems"&&(e.message=`Must have at most ${e.params.limit} item${e.params.limit!==1?"s":""}`),e.keyword==="type"&&(e.message="Invalid format"),e.keyword==="maxLength"&&(e.message=`Must be at most ${e.params.limit} character${e.params.limit!==1?"s":""}`),e.keyword==="minLength"&&(e.message=`Must be at least ${e.params.limit} character${e.params.limit!==1?"s":""}`),e.keyword==="minimum"&&(e.message=`Must be greater than or equal to ${e.params.limit}`),e.keyword==="maximum"&&(e.message=`Must be less than or equal to ${e.params.limit}`),e))}c.dataModelToJSONSchema=d,c.getAccountRequest=W,c.getQuoteElementRequest=X,c.getQuoteRequest=v,c.parseElementTypeAndScopeByElementType=L,c.retrieveDataModelFromElement=M,c.retrieveElementFromQuoteByLocator=O,c.transformErrors=ee,Object.defineProperty(c,Symbol.toStringTag,{value:"Module"})});
|
|
2
2
|
//# sourceMappingURL=index.umd.js.map
|
package/dist/index.umd.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.umd.js","sources":["../lib/utils/data-model-to-JSON-schema.ts","../lib/utils/get-account-request.ts","../lib/utils/get-quote-element-request.ts","../lib/utils/get-quote-request.ts","../lib/utils/parse-element-type-and-scope-by-element-type.ts","../lib/utils/retrieve-element-from-quote-by-locator.ts","../lib/utils/retrieve-data-model-from-element.ts","../lib/utils/transform-errors.ts"],"sourcesContent":["import type { RJSFSchema } from '@rjsf/utils';\nimport {\n\tAccountResponse,\n\tDataTypeConfigRecord,\n\tElementResponse,\n\tFieldConfigRecord,\n\tQuoteResponse,\n} from '@socotra/ec-react-schemas';\n\ninterface DataModelToJsonSchemaProps {\n\tdata: FieldConfigRecord;\n\tdataTypes?: DataTypeConfigRecord;\n\tscope: 'P' | 'Q';\n\trootDisplayName: string;\n\taccount?: AccountResponse;\n\tquote?: QuoteResponse;\n\telement?: ElementResponse;\n}\n\nexport const dataModelToJSONSchema = (args: DataModelToJsonSchemaProps) => {\n\tconst { data, scope, dataTypes, rootDisplayName, account, quote, element } =\n\t\targs;\n\n\tconst requiredFields: string[] = [];\n\tlet definitions = {};\n\tconst properties = Object.fromEntries(\n\t\tObject.entries(data ?? {})\n\t\t\t.filter(([, value]) => {\n\t\t\t\tconst dataScope = value.scope?.split(',').map((s) => s.trim());\n\n\t\t\t\tif (!dataScope) {\n\t\t\t\t\treturn true;\n\t\t\t\t}\n\t\t\t\tif (\n\t\t\t\t\t(scope === 'P' && dataScope?.includes('P')) ||\n\t\t\t\t\tdataScope?.includes('Q')\n\t\t\t\t) {\n\t\t\t\t\treturn true;\n\t\t\t\t}\n\t\t\t\tif (scope === 'Q' && dataScope?.includes('Q')) {\n\t\t\t\t\treturn true;\n\t\t\t\t}\n\t\t\t\treturn false;\n\t\t\t})\n\t\t\t.map(([key, value]) => {\n\t\t\t\tlet isOptional = false;\n\t\t\t\tlet isArray = false;\n\t\t\t\tlet isCustomDataType = false;\n\t\t\t\tconst displayName = value.displayName ?? key;\n\t\t\t\tconst quantifier = value.type?.slice(-1);\n\t\t\t\tconst maxLength = value.maxLength;\n\t\t\t\tconst minLength = value.minLength;\n\t\t\t\tconst max = value.max;\n\t\t\t\tconst min = value.min;\n\t\t\t\tconst regex = value.regex;\n\t\t\t\tlet type: string = value.type ?? '';\n\t\t\t\tlet format: string | undefined;\n\n\t\t\t\tswitch (quantifier) {\n\t\t\t\t\tcase '*':\n\t\t\t\t\t\tisArray = true;\n\t\t\t\t\t\tisOptional = true;\n\t\t\t\t\t\ttype = type?.split('*')[0];\n\t\t\t\t\t\tbreak;\n\t\t\t\t\tcase '?':\n\t\t\t\t\t\ttype = type?.split('?')[0];\n\t\t\t\t\t\tisOptional = true;\n\t\t\t\t\t\tbreak;\n\t\t\t\t\tcase '+':\n\t\t\t\t\t\tisArray = true;\n\t\t\t\t\t\ttype = type?.split('+')[0];\n\t\t\t\t\t\tbreak;\n\t\t\t\t\tcase '!':\n\t\t\t\t\t\ttype = type?.split('!')[0];\n\t\t\t\t\t\tbreak;\n\t\t\t\t\tdefault:\n\t\t\t\t\t\tbreak;\n\t\t\t\t}\n\n\t\t\t\tswitch (type) {\n\t\t\t\t\t// fields can be either 'string', 'int', 'long', 'decimal', 'dateTime', 'date', 'boolean' in kernel\n\t\t\t\t\t// JSON schema supports 'string', 'integer', 'number', 'boolean', 'null'\n\t\t\t\t\tcase 'string':\n\t\t\t\t\t\ttype = 'string';\n\t\t\t\t\t\tbreak;\n\t\t\t\t\tcase 'int':\n\t\t\t\t\tcase 'long':\n\t\t\t\t\t\ttype = 'integer';\n\t\t\t\t\t\tbreak;\n\t\t\t\t\tcase 'decimal':\n\t\t\t\t\t\ttype = 'number';\n\t\t\t\t\t\tbreak;\n\t\t\t\t\tcase 'dateTime':\n\t\t\t\t\t\ttype = 'string';\n\t\t\t\t\t\tformat = 'date-time';\n\t\t\t\t\t\tbreak;\n\t\t\t\t\tcase 'date':\n\t\t\t\t\t\ttype = 'string';\n\t\t\t\t\t\tformat = 'date';\n\t\t\t\t\t\tbreak;\n\t\t\t\t\tcase 'boolean':\n\t\t\t\t\tcase 'bool':\n\t\t\t\t\t\ttype = 'boolean';\n\t\t\t\t\t\tbreak;\n\t\t\t\t\tdefault:\n\t\t\t\t\t\tisCustomDataType = true;\n\t\t\t\t\t\tbreak;\n\t\t\t\t}\n\n\t\t\t\tif (!isOptional && !isCustomDataType && !isArray) {\n\t\t\t\t\trequiredFields.push(key);\n\t\t\t\t}\n\n\t\t\t\tif (isCustomDataType) {\n\t\t\t\t\tconst customDataType = dataTypes?.[type];\n\t\t\t\t\tif (customDataType) {\n\t\t\t\t\t\tlet defaultValues = isArray ? [] : {};\n\t\t\t\t\t\tconst referenceSchema = dataModelToJSONSchema({\n\t\t\t\t\t\t\tdata: customDataType.data ?? {},\n\t\t\t\t\t\t\tscope,\n\t\t\t\t\t\t\tdataTypes,\n\t\t\t\t\t\t\trootDisplayName: key,\n\t\t\t\t\t\t});\n\n\t\t\t\t\t\t// find any preset quote or account data for this custom data type\n\t\t\t\t\t\tif (quote) {\n\t\t\t\t\t\t\tif (quote.element?.data?.[key]) {\n\t\t\t\t\t\t\t\tdefaultValues = quote.element?.data?.[key];\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t\tif (element) {\n\t\t\t\t\t\t\tif (element?.data?.[key]) {\n\t\t\t\t\t\t\t\tdefaultValues = element?.data?.[key];\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t\tif (account) {\n\t\t\t\t\t\t\tif (account?.data?.[key]) {\n\t\t\t\t\t\t\t\tdefaultValues = account?.data?.[key];\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t\tdefinitions = {\n\t\t\t\t\t\t\t...definitions,\n\t\t\t\t\t\t\t[`${type}`]: referenceSchema,\n\t\t\t\t\t\t};\n\t\t\t\t\t\tif (isArray) {\n\t\t\t\t\t\t\treturn [\n\t\t\t\t\t\t\t\tkey,\n\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\ttitle: key\n\t\t\t\t\t\t\t\t\t\t.replace(/([A-Z])/g, ' $1')\n\t\t\t\t\t\t\t\t\t\t// uppercase the first character\n\t\t\t\t\t\t\t\t\t\t.replace(/^./, function (str) {\n\t\t\t\t\t\t\t\t\t\t\treturn str.toUpperCase();\n\t\t\t\t\t\t\t\t\t\t}),\n\t\t\t\t\t\t\t\t\ttype: 'array',\n\t\t\t\t\t\t\t\t\tdefault: defaultValues,\n\t\t\t\t\t\t\t\t\titems: {\n\t\t\t\t\t\t\t\t\t\t['$ref']: `#/definitions/${type}`,\n\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t\t...(!isOptional && { minItems: 1 }),\n\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t];\n\t\t\t\t\t\t}\n\t\t\t\t\t\treturn [\n\t\t\t\t\t\t\tkey,\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\ttitle: key\n\t\t\t\t\t\t\t\t\t.replace(/([A-Z])/g, ' $1')\n\t\t\t\t\t\t\t\t\t// uppercase the first character\n\t\t\t\t\t\t\t\t\t.replace(/^./, function (str) {\n\t\t\t\t\t\t\t\t\t\treturn str.toUpperCase();\n\t\t\t\t\t\t\t\t\t}),\n\t\t\t\t\t\t\t\tdefault: defaultValues,\n\t\t\t\t\t\t\t\t['$ref']: `#/definitions/${type}`,\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t];\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\tlet defaultValue: string | boolean | object | undefined = '';\n\n\t\t\t\tif (account) {\n\t\t\t\t\t// An account in draft state will always have keys in the same casing as the data model\n\t\t\t\t\t// An account in validated state will have keys in camelCase, so we need to convert the keys to match the way the kernel sets them\n\t\t\t\t\tconst dataKey =\n\t\t\t\t\t\taccount?.state === 'validated'\n\t\t\t\t\t\t\t? key.charAt(0).toLowerCase() + key.slice(1)\n\t\t\t\t\t\t\t: key;\n\n\t\t\t\t\tdefaultValue = account?.data?.[dataKey]\n\t\t\t\t\t\t? account?.data?.[dataKey]\n\t\t\t\t\t\t: type === 'boolean'\n\t\t\t\t\t\t\t? Boolean(value.defaultValue)\n\t\t\t\t\t\t\t: value.defaultValue;\n\t\t\t\t}\n\n\t\t\t\tif (quote) {\n\t\t\t\t\tdefaultValue = quote.element?.data?.[key]\n\t\t\t\t\t\t? quote.element?.data?.[key]\n\t\t\t\t\t\t: type === 'boolean'\n\t\t\t\t\t\t\t? Boolean(value.defaultValue)\n\t\t\t\t\t\t\t: value.defaultValue;\n\t\t\t\t}\n\n\t\t\t\tif (element) {\n\t\t\t\t\tdefaultValue = element?.data?.[key]\n\t\t\t\t\t\t? element?.data?.[key]\n\t\t\t\t\t\t: type === 'boolean'\n\t\t\t\t\t\t\t? Boolean(value.defaultValue)\n\t\t\t\t\t\t\t: value.defaultValue;\n\t\t\t\t}\n\n\t\t\t\tif (isArray) {\n\t\t\t\t\t// if the field is an array, we need to set the type to 'array' and set the items to the type of the array\n\t\t\t\t\treturn [\n\t\t\t\t\t\tkey,\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\ttitle: displayName,\n\t\t\t\t\t\t\ttype: 'array',\n\t\t\t\t\t\t\tdefault: defaultValue,\n\t\t\t\t\t\t\titems: {\n\t\t\t\t\t\t\t\ttype,\n\t\t\t\t\t\t\t\t...(maxLength && { maxLength }),\n\t\t\t\t\t\t\t\t...(minLength && { minLength }),\n\t\t\t\t\t\t\t\t...(min && { min }),\n\t\t\t\t\t\t\t\t...(max && { max }),\n\t\t\t\t\t\t\t\t...(format && { format }),\n\t\t\t\t\t\t\t\t...(regex && { pattern: value.regex }),\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t...(!isOptional && { minItems: 1 }),\n\t\t\t\t\t\t},\n\t\t\t\t\t];\n\t\t\t\t}\n\n\t\t\t\tconst property = [\n\t\t\t\t\tkey,\n\t\t\t\t\t{\n\t\t\t\t\t\ttitle: displayName,\n\t\t\t\t\t\ttype,\n\t\t\t\t\t\t...(defaultValue && { default: defaultValue }),\n\t\t\t\t\t\t...(minLength && { minLength }),\n\t\t\t\t\t\t...(maxLength && { maxLength }),\n\t\t\t\t\t\t...(min && { minimum: parseInt(min) }),\n\t\t\t\t\t\t...(max && { maximum: parseInt(max) }),\n\t\t\t\t\t\t...(format && { format }),\n\t\t\t\t\t\t...(value.options && { enum: value.options }),\n\t\t\t\t\t\t...(regex && { pattern: value.regex }),\n\t\t\t\t\t},\n\t\t\t\t];\n\t\t\t\treturn property;\n\t\t\t}),\n\t);\n\n\tconst schema: RJSFSchema = {\n\t\ttitle: rootDisplayName,\n\t\ttype: 'object',\n\t\tdefinitions,\n\t\trequired: requiredFields,\n\t\tproperties,\n\t};\n\n\treturn schema;\n};\n","import { AccountRequest } from '@socotra/ec-react-schemas';\n\nexport const getAccountRequest = (formData: TODO): AccountRequest => {\n\tconst autoValidate = formData.autoValidate;\n\tconst delinquencyPlanName = formData.delinquencyPlanName;\n\tconst type = formData.accountType;\n\n\t// filter out the accountType, autoValidate, and delinquencyPlanName\n\tconst data = Object.keys(formData).reduce(\n\t\t(acc, key) => {\n\t\t\tif (\n\t\t\t\tkey !== 'accountType' &&\n\t\t\t\tkey !== 'autoValidate' &&\n\t\t\t\tkey !== 'delinquencyPlanName'\n\t\t\t) {\n\t\t\t\tacc[key] = formData[key];\n\t\t\t}\n\t\t\treturn acc;\n\t\t},\n\t\t{} as { [key: string]: object },\n\t);\n\n\tconst request = {\n\t\tautoValidate,\n\t\tdelinquencyPlanName,\n\t\ttype,\n\t\tdata,\n\t};\n\n\treturn request;\n};\n","import { ElementRequest, QuoteRequest } from '@socotra/ec-react-schemas';\n\ntype GetQuoteElementRequestAttributes = {\n\tformData: { [key: string]: unknown };\n\tlocator: string;\n};\n\nexport const getQuoteElementRequest = ({\n\tformData,\n\tlocator,\n}: GetQuoteElementRequestAttributes): QuoteRequest => {\n\tconst elementRequest: ElementRequest = {\n\t\tlocator,\n\t\tsetData: formData,\n\t};\n\n\tconst request: QuoteRequest = {\n\t\telements: [elementRequest],\n\t};\n\n\treturn request;\n};\n","import { AccountRequest, QuoteRequest } from '@socotra/ec-react-schemas';\n\ninterface QuoteDefaultFields {\n\tdelinquencyPlanName: string;\n\tstartTime: string;\n\tendTime: string;\n\tcurrency: string;\n\texpirationTime: string;\n\ttimezone: string;\n}\n\ntype GetQuoteRequestAttributes =\n\t| {\n\t\t\tformData: object;\n\t\t\thideDefaultFields: true;\n\t\t\thideConfiguredFields: true;\n\t }\n\t| {\n\t\t\tformData: QuoteDefaultFields;\n\t\t\thideDefaultFields: false;\n\t\t\thideConfiguredFields: true;\n\t }\n\t| {\n\t\t\tformData: TODO;\n\t\t\thideDefaultFields: true;\n\t\t\thideConfiguredFields: false;\n\t }\n\t| {\n\t\t\tformData: QuoteDefaultFields & TODO;\n\t\t\thideDefaultFields: false;\n\t\t\thideConfiguredFields: false;\n\t };\n\nfunction removeQuoteDefaultFields(formData: QuoteDefaultFields & TODO): TODO {\n\tconst {\n\t\tdelinquencyPlanName,\n\t\tstartTime,\n\t\tendTime,\n\t\tcurrency,\n\t\texpirationTime,\n\t\ttimezone,\n\t\t...rest\n\t} = formData;\n\n\treturn rest;\n}\n\nfunction getQuoteDefaultFields(formData: TODO): QuoteDefaultFields {\n\tconst {\n\t\tdelinquencyPlanName,\n\t\tstartTime,\n\t\tendTime,\n\t\tcurrency,\n\t\texpirationTime,\n\t\ttimezone,\n\t} = formData;\n\n\treturn {\n\t\tdelinquencyPlanName,\n\t\tstartTime,\n\t\tendTime,\n\t\tcurrency,\n\t\texpirationTime,\n\t\ttimezone,\n\t};\n}\n\nexport const getQuoteRequest = ({\n\tformData,\n\thideDefaultFields,\n\thideConfiguredFields,\n}: GetQuoteRequestAttributes): AccountRequest => {\n\tlet request: QuoteRequest = {};\n\n\tif (!hideDefaultFields) {\n\t\tconst defaultFields = getQuoteDefaultFields(formData);\n\t\trequest = {\n\t\t\t...defaultFields,\n\t\t};\n\t}\n\n\tif (!hideConfiguredFields) {\n\t\tconst quoteFields = removeQuoteDefaultFields(formData);\n\t\trequest = {\n\t\t\t...request,\n\t\t\tsetData: quoteFields,\n\t\t};\n\t}\n\n\treturn request;\n};\n","/**\n * Takes an element type and splits the postfix scope from the base model name. E.g., 'PersonalAutoQuote' becomes ['PersonalAuto', 'Quote']\n * @param elementType The element type to parse, e.g. `element.type` from an `ElementResponse`\n * @returns [elementName: string, scope: 'Quote' | 'QuickQuote' | 'Policy' | null]\n */\nexport const parseElementTypeAndScopeByElementType = (\n\telementType: string,\n): [elementName: string, scope: 'Quote' | 'QuickQuote' | 'Policy' | null] => {\n\tconst regex = /^(.*?)(Quote|QuickQuote|Policy)$/;\n\tconst match = elementType.match(regex);\n\tif (\n\t\tmatch &&\n\t\t(match[2] === 'Quote' || match[2] === 'QuickQuote' || match[2] === 'Policy')\n\t) {\n\t\treturn [match[1], match[2]]; // match[1] is the base model name, match[2] is the scope\n\t}\n\n\t// Return the original key and null for the scope if no match found\n\treturn [elementType, null];\n};\n","import { ElementResponse } from '@socotra/ec-react-schemas';\n\n/**\n * Takes the root element of a quote and a locator and returns the element with the matching locator\n * @param quoteElement The root element from the QuoteResponse\n * @param locator The locator of the element to retrieve\n * @returns ElementResponse | undefined\n */\nexport function retrieveElementFromQuoteByLocator(\n\tquoteElement: ElementResponse,\n\tlocator: string,\n): ElementResponse | undefined {\n\tif (quoteElement.locator === locator) {\n\t\treturn quoteElement;\n\t}\n\n\tif (quoteElement.elements) {\n\t\tfor (const element of quoteElement.elements) {\n\t\t\tconst foundElement = retrieveElementFromQuoteByLocator(element, locator);\n\t\t\tif (foundElement) {\n\t\t\t\treturn foundElement;\n\t\t\t}\n\t\t}\n\t}\n\n\treturn undefined;\n}\n","import {\n\tDataModel,\n\tElementConfig,\n\tElementResponse,\n} from '@socotra/ec-react-schemas';\n\nimport { parseElementTypeAndScopeByElementType } from './parse-element-type-and-scope-by-element-type';\n\n/**\n * Looks through a data model for a matching element type and returns the element model\n * @param element The element to retrieve the data model for\n * @param dataModel The full resolved data model to search\n * @returns ElementConfig\n */\nexport function retrieveDataModelFromElement(\n\telement: ElementResponse,\n\tdataModel: DataModel,\n) {\n\tconst [elementType] = parseElementTypeAndScopeByElementType(\n\t\telement.type ?? '',\n\t);\n\n\tlet elementModel: ElementConfig = {};\n\n\t// Look in exposures\n\tif (dataModel.exposures) {\n\t\tObject.keys(dataModel.exposures).forEach((exposureName) => {\n\t\t\tif (exposureName === elementType && dataModel.exposures) {\n\t\t\t\telementModel = dataModel.exposures[exposureName];\n\t\t\t}\n\t\t});\n\t}\n\n\t// Look in coverages\n\tif (dataModel.coverages) {\n\t\tObject.keys(dataModel.coverages).forEach((coverageName) => {\n\t\t\tif (coverageName === elementType && dataModel.coverages) {\n\t\t\t\telementModel = dataModel.coverages[coverageName];\n\t\t\t}\n\t\t});\n\t}\n\n\t// Look in policyLines\n\tif (dataModel.policyLines) {\n\t\tObject.keys(dataModel.policyLines).forEach((policyLineName) => {\n\t\t\tif (policyLineName === elementType && dataModel.policyLines) {\n\t\t\t\telementModel = dataModel.policyLines[policyLineName];\n\t\t\t}\n\t\t});\n\t}\n\n\t// look in ExposureGroups\n\tif (dataModel.exposureGroups) {\n\t\tObject.keys(dataModel.exposureGroups).forEach((exposureGroupName) => {\n\t\t\tif (exposureGroupName === elementType && dataModel.exposureGroups) {\n\t\t\t\telementModel = dataModel.exposureGroups[exposureGroupName];\n\t\t\t}\n\t\t});\n\t}\n\n\treturn elementModel;\n}\n","import { type RJSFValidationError } from '@rjsf/utils';\n\nexport function transformErrors(errors: RJSFValidationError[]) {\n\treturn errors.map((error) => {\n\t\tif (error.name === 'pattern') {\n\t\t\terror.message = `Invalid format, must match pattern ${error.params.pattern}`;\n\t\t}\n\t\tif (error.name === 'format') {\n\t\t\terror.message = 'Invalid format';\n\t\t}\n\t\tif (error.name === 'required') {\n\t\t\terror.message = 'Required';\n\t\t}\n\t\tif (error.name === 'minItems') {\n\t\t\terror.message = `Must have at least ${error.params.limit} item${\n\t\t\t\terror.params.limit !== 1 ? 's' : ''\n\t\t\t}`;\n\t\t}\n\t\tif (error.name === 'maxItems') {\n\t\t\terror.message = `Must have at most ${error.params.limit} item${\n\t\t\t\terror.params.limit !== 1 ? 's' : ''\n\t\t\t}`;\n\t\t}\n\t\tif (error.name === 'type') {\n\t\t\terror.message = 'Invalid format';\n\t\t}\n\t\tif (error.name === 'maxLength') {\n\t\t\terror.message = `Must be at most ${error.params.limit} character${\n\t\t\t\terror.params.limit !== 1 ? 's' : ''\n\t\t\t}`;\n\t\t}\n\t\tif (error.name === 'minLength') {\n\t\t\terror.message = `Must be at least ${error.params.limit} character${\n\t\t\t\terror.params.limit !== 1 ? 's' : ''\n\t\t\t}`;\n\t\t}\n\t\tif (error.name === 'minimum') {\n\t\t\terror.message = `Must be greater than or equal to ${error.params.limit}`;\n\t\t}\n\t\tif (error.name === 'maximum') {\n\t\t\terror.message = `Must be less than or equal to ${error.params.limit}`;\n\t\t}\n\t\treturn error;\n\t});\n}\n"],"names":["dataModelToJSONSchema","args","data","scope","dataTypes","rootDisplayName","account","quote","element","requiredFields","definitions","properties","value","dataScope","_a","s","key","isOptional","isArray","isCustomDataType","displayName","quantifier","maxLength","minLength","max","min","regex","type","format","customDataType","defaultValues","referenceSchema","_c","_b","_e","_d","_f","_g","_h","_i","str","defaultValue","dataKey","_j","_k","_m","_l","_o","_n","_p","_q","getAccountRequest","formData","autoValidate","delinquencyPlanName","acc","getQuoteElementRequest","locator","removeQuoteDefaultFields","startTime","endTime","currency","expirationTime","timezone","rest","getQuoteDefaultFields","getQuoteRequest","hideDefaultFields","hideConfiguredFields","request","quoteFields","parseElementTypeAndScopeByElementType","elementType","match","retrieveElementFromQuoteByLocator","quoteElement","foundElement","retrieveDataModelFromElement","dataModel","elementModel","exposureName","coverageName","policyLineName","exposureGroupName","transformErrors","errors","error"],"mappings":"+NAmBa,MAAAA,EAAyBC,GAAqC,CACpE,KAAA,CAAE,KAAAC,EAAM,MAAAC,EAAO,UAAAC,EAAW,gBAAAC,EAAiB,QAAAC,EAAS,MAAAC,EAAO,QAAAC,CAChE,EAAAP,EAEKQ,EAA2B,CAAA,EACjC,IAAIC,EAAc,CAAA,EAClB,MAAMC,GAAa,OAAO,YACzB,OAAO,QAAQT,GAAQ,CAAA,CAAE,EACvB,OAAO,CAAC,CAAG,CAAAU,CAAK,IAAM,OAChB,MAAAC,GAAYC,EAAAF,EAAM,QAAN,YAAAE,EAAa,MAAM,KAAK,IAAKC,GAAMA,EAAE,KAAM,GAW7D,MATI,IAACF,GAIHV,IAAU,MAAOU,GAAA,MAAAA,EAAW,SAAS,OACtCA,GAAA,MAAAA,EAAW,SAAS,MAIjBV,IAAU,MAAOU,GAAA,MAAAA,EAAW,SAAS,MAIzC,CAAA,EACA,IAAI,CAAC,CAACG,EAAKJ,CAAK,IAAM,uCACtB,IAAIK,EAAa,GACbC,EAAU,GACVC,EAAmB,GACjB,MAAAC,EAAcR,EAAM,aAAeI,EACnCK,IAAaP,EAAAF,EAAM,OAAN,YAAAE,EAAY,MAAM,IAC/BQ,EAAYV,EAAM,UAClBW,EAAYX,EAAM,UAClBY,EAAMZ,EAAM,IACZa,EAAMb,EAAM,IACZc,EAAQd,EAAM,MAChB,IAAAe,EAAef,EAAM,MAAQ,GAC7BgB,EAEJ,OAAQP,GAAY,CACnB,IAAK,IACMH,EAAA,GACGD,EAAA,GACbU,EAAOA,GAAA,YAAAA,EAAM,MAAM,KAAK,GACxB,MACD,IAAK,IACJA,EAAOA,GAAA,YAAAA,EAA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AAS,cACZA,EAAA,QAAU,oBAAoBA,EAAM,OAAO,KAAK,aACrDA,EAAM,OAAO,QAAU,EAAI,IAAM,EAClC,IAEGA,EAAM,OAAS,YAClBA,EAAM,QAAU,oCAAoCA,EAAM,OAAO,KAAK,IAEnEA,EAAM,OAAS,YAClBA,EAAM,QAAU,iCAAiCA,EAAM,OAAO,KAAK,IAE7DA,EACP,CACF"}
|
|
1
|
+
{"version":3,"file":"index.umd.js","sources":["../lib/utils/data-model-to-JSON-schema.ts","../lib/utils/get-account-request.ts","../lib/utils/get-quote-element-request.ts","../lib/utils/get-quote-request.ts","../lib/utils/parse-element-type-and-scope-by-element-type.ts","../lib/utils/retrieve-element-from-quote-by-locator.ts","../lib/utils/retrieve-data-model-from-element.ts","../lib/utils/transform-errors.ts"],"sourcesContent":["import { JsonSchema7 } from '@jsonforms/core';\nimport {\n\tAccountResponse,\n\tDataTypeConfigRecord,\n\tElementResponse,\n\tFieldConfigRecord,\n\tQuoteResponse,\n} from '@socotra/ec-react-schemas';\n\ninterface DataModelToJsonSchemaProps {\n\tdata: FieldConfigRecord;\n\tdataTypes?: DataTypeConfigRecord;\n\tscope: 'P' | 'Q';\n\trootDisplayName: string;\n\taccount?: AccountResponse;\n\tquote?: QuoteResponse;\n\telement?: ElementResponse;\n}\n\nexport const dataModelToJSONSchema = (args: DataModelToJsonSchemaProps) => {\n\tconst { data, scope, dataTypes, rootDisplayName, account, quote, element } =\n\t\targs;\n\n\tconst requiredFields: string[] = [];\n\tlet definitions = {};\n\tconst properties = Object.fromEntries(\n\t\tObject.entries(data ?? {})\n\t\t\t.filter(([, value]) => {\n\t\t\t\tconst dataScope = value.scope?.split(',').map((s) => s.trim());\n\n\t\t\t\tif (!dataScope) {\n\t\t\t\t\treturn true;\n\t\t\t\t}\n\t\t\t\tif (\n\t\t\t\t\t(scope === 'P' && dataScope?.includes('P')) ||\n\t\t\t\t\tdataScope?.includes('Q')\n\t\t\t\t) {\n\t\t\t\t\treturn true;\n\t\t\t\t}\n\t\t\t\tif (scope === 'Q' && dataScope?.includes('Q')) {\n\t\t\t\t\treturn true;\n\t\t\t\t}\n\t\t\t\treturn false;\n\t\t\t})\n\t\t\t.map(([key, value]) => {\n\t\t\t\tlet isOptional = false;\n\t\t\t\tlet isArray = false;\n\t\t\t\tlet isCustomDataType = false;\n\t\t\t\tconst displayName = value.displayName ?? key;\n\t\t\t\tconst quantifier = value.type?.slice(-1);\n\t\t\t\tconst maxLength = value.maxLength;\n\t\t\t\tconst minLength = value.minLength;\n\t\t\t\tconst max = value.max;\n\t\t\t\tconst min = value.min;\n\t\t\t\tconst regex = value.regex;\n\t\t\t\tlet type: string = value.type ?? '';\n\t\t\t\tlet format: string | undefined;\n\n\t\t\t\tswitch (quantifier) {\n\t\t\t\t\tcase '*':\n\t\t\t\t\t\tisArray = true;\n\t\t\t\t\t\tisOptional = true;\n\t\t\t\t\t\ttype = type?.split('*')[0];\n\t\t\t\t\t\tbreak;\n\t\t\t\t\tcase '?':\n\t\t\t\t\t\ttype = type?.split('?')[0];\n\t\t\t\t\t\tisOptional = true;\n\t\t\t\t\t\tbreak;\n\t\t\t\t\tcase '+':\n\t\t\t\t\t\tisArray = true;\n\t\t\t\t\t\ttype = type?.split('+')[0];\n\t\t\t\t\t\tbreak;\n\t\t\t\t\tcase '!':\n\t\t\t\t\t\ttype = type?.split('!')[0];\n\t\t\t\t\t\tbreak;\n\t\t\t\t\tdefault:\n\t\t\t\t\t\tbreak;\n\t\t\t\t}\n\n\t\t\t\tswitch (type) {\n\t\t\t\t\t// fields can be either 'string', 'int', 'long', 'decimal', 'dateTime', 'date', 'boolean' in kernel\n\t\t\t\t\t// JSON schema supports 'string', 'integer', 'number', 'boolean', 'null'\n\t\t\t\t\tcase 'string':\n\t\t\t\t\t\ttype = 'string';\n\t\t\t\t\t\tbreak;\n\t\t\t\t\tcase 'int':\n\t\t\t\t\tcase 'long':\n\t\t\t\t\t\ttype = 'integer';\n\t\t\t\t\t\tbreak;\n\t\t\t\t\tcase 'decimal':\n\t\t\t\t\t\ttype = 'number';\n\t\t\t\t\t\tbreak;\n\t\t\t\t\tcase 'dateTime':\n\t\t\t\t\t\ttype = 'string';\n\t\t\t\t\t\tformat = 'date-time';\n\t\t\t\t\t\tbreak;\n\t\t\t\t\tcase 'date':\n\t\t\t\t\t\ttype = 'string';\n\t\t\t\t\t\tformat = 'date';\n\t\t\t\t\t\tbreak;\n\t\t\t\t\tcase 'boolean':\n\t\t\t\t\tcase 'bool':\n\t\t\t\t\t\ttype = 'boolean';\n\t\t\t\t\t\tbreak;\n\t\t\t\t\tdefault:\n\t\t\t\t\t\tisCustomDataType = true;\n\t\t\t\t\t\tbreak;\n\t\t\t\t}\n\n\t\t\t\tif (!isOptional && !isCustomDataType && !isArray) {\n\t\t\t\t\trequiredFields.push(key);\n\t\t\t\t}\n\n\t\t\t\tif (isCustomDataType) {\n\t\t\t\t\tconst customDataType = dataTypes?.[type];\n\t\t\t\t\tif (customDataType) {\n\t\t\t\t\t\tlet defaultValues = isArray ? [] : {};\n\t\t\t\t\t\tconst referenceSchema = dataModelToJSONSchema({\n\t\t\t\t\t\t\tdata: customDataType.data ?? {},\n\t\t\t\t\t\t\tscope,\n\t\t\t\t\t\t\tdataTypes,\n\t\t\t\t\t\t\trootDisplayName: key,\n\t\t\t\t\t\t});\n\n\t\t\t\t\t\t// find any preset quote or account data for this custom data type\n\t\t\t\t\t\tif (quote) {\n\t\t\t\t\t\t\tif (quote.element?.data?.[key]) {\n\t\t\t\t\t\t\t\tdefaultValues = quote.element?.data?.[key];\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t\tif (element) {\n\t\t\t\t\t\t\tif (element?.data?.[key]) {\n\t\t\t\t\t\t\t\tdefaultValues = element?.data?.[key];\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t\tif (account) {\n\t\t\t\t\t\t\tif (account?.data?.[key]) {\n\t\t\t\t\t\t\t\tdefaultValues = account?.data?.[key];\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t\tdefinitions = {\n\t\t\t\t\t\t\t...definitions,\n\t\t\t\t\t\t\t[`${type}`]: referenceSchema,\n\t\t\t\t\t\t};\n\t\t\t\t\t\tif (isArray) {\n\t\t\t\t\t\t\treturn [\n\t\t\t\t\t\t\t\tkey,\n\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\ttitle: key\n\t\t\t\t\t\t\t\t\t\t.replace(/([A-Z])/g, ' $1')\n\t\t\t\t\t\t\t\t\t\t// uppercase the first character\n\t\t\t\t\t\t\t\t\t\t.replace(/^./, function (str) {\n\t\t\t\t\t\t\t\t\t\t\treturn str.toUpperCase();\n\t\t\t\t\t\t\t\t\t\t}),\n\t\t\t\t\t\t\t\t\ttype: 'array',\n\t\t\t\t\t\t\t\t\tdefault: defaultValues,\n\t\t\t\t\t\t\t\t\titems: {\n\t\t\t\t\t\t\t\t\t\t['$ref']: `#/definitions/${type}`,\n\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t\t...(!isOptional && { minItems: 1 }),\n\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t];\n\t\t\t\t\t\t}\n\t\t\t\t\t\treturn [\n\t\t\t\t\t\t\tkey,\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\ttitle: key\n\t\t\t\t\t\t\t\t\t.replace(/([A-Z])/g, ' $1')\n\t\t\t\t\t\t\t\t\t// uppercase the first character\n\t\t\t\t\t\t\t\t\t.replace(/^./, function (str) {\n\t\t\t\t\t\t\t\t\t\treturn str.toUpperCase();\n\t\t\t\t\t\t\t\t\t}),\n\t\t\t\t\t\t\t\tdefault: defaultValues,\n\t\t\t\t\t\t\t\t['$ref']: `#/definitions/${type}`,\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t];\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\tlet defaultValue: string | boolean | object | undefined = '';\n\n\t\t\t\tif (account) {\n\t\t\t\t\t// An account in draft state will always have keys in the same casing as the data model\n\t\t\t\t\t// An account in validated state will have keys in camelCase, so we need to convert the keys to match the way the kernel sets them\n\t\t\t\t\tconst dataKey =\n\t\t\t\t\t\taccount?.state === 'validated'\n\t\t\t\t\t\t\t? key.charAt(0).toLowerCase() + key.slice(1)\n\t\t\t\t\t\t\t: key;\n\n\t\t\t\t\tdefaultValue = account?.data?.[dataKey]\n\t\t\t\t\t\t? account?.data?.[dataKey]\n\t\t\t\t\t\t: type === 'boolean'\n\t\t\t\t\t\t\t? Boolean(value.defaultValue)\n\t\t\t\t\t\t\t: value.defaultValue;\n\t\t\t\t}\n\n\t\t\t\tif (quote) {\n\t\t\t\t\tdefaultValue = quote.element?.data?.[key]\n\t\t\t\t\t\t? quote.element?.data?.[key]\n\t\t\t\t\t\t: type === 'boolean'\n\t\t\t\t\t\t\t? Boolean(value.defaultValue)\n\t\t\t\t\t\t\t: value.defaultValue;\n\t\t\t\t}\n\n\t\t\t\tif (element) {\n\t\t\t\t\tdefaultValue = element?.data?.[key]\n\t\t\t\t\t\t? element?.data?.[key]\n\t\t\t\t\t\t: type === 'boolean'\n\t\t\t\t\t\t\t? Boolean(value.defaultValue)\n\t\t\t\t\t\t\t: value.defaultValue;\n\t\t\t\t}\n\n\t\t\t\tif (isArray) {\n\t\t\t\t\t// if the field is an array, we need to set the type to 'array' and set the items to the type of the array\n\t\t\t\t\treturn [\n\t\t\t\t\t\tkey,\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\ttitle: displayName,\n\t\t\t\t\t\t\ttype: 'array',\n\t\t\t\t\t\t\tdefault: defaultValue,\n\t\t\t\t\t\t\titems: {\n\t\t\t\t\t\t\t\ttype,\n\t\t\t\t\t\t\t\t...(maxLength && { maxLength }),\n\t\t\t\t\t\t\t\t...(minLength && { minLength }),\n\t\t\t\t\t\t\t\t...(min && { min }),\n\t\t\t\t\t\t\t\t...(max && { max }),\n\t\t\t\t\t\t\t\t...(format && { format }),\n\t\t\t\t\t\t\t\t...(regex && { pattern: value.regex }),\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t...(!isOptional && { minItems: 1 }),\n\t\t\t\t\t\t},\n\t\t\t\t\t];\n\t\t\t\t}\n\n\t\t\t\tconst property = [\n\t\t\t\t\tkey,\n\t\t\t\t\t{\n\t\t\t\t\t\ttitle: displayName,\n\t\t\t\t\t\ttype,\n\t\t\t\t\t\t...(defaultValue && { default: defaultValue }),\n\t\t\t\t\t\t...(minLength && { minLength }),\n\t\t\t\t\t\t...(maxLength && { maxLength }),\n\t\t\t\t\t\t...(min && { minimum: parseInt(min) }),\n\t\t\t\t\t\t...(max && { maximum: parseInt(max) }),\n\t\t\t\t\t\t...(format && { format }),\n\t\t\t\t\t\t...(value.options && { enum: value.options }),\n\t\t\t\t\t\t...(regex && { pattern: value.regex }),\n\t\t\t\t\t},\n\t\t\t\t];\n\t\t\t\treturn property;\n\t\t\t}),\n\t);\n\n\tconst schema: JsonSchema7 = {\n\t\ttitle: rootDisplayName,\n\t\ttype: 'object',\n\t\tdefinitions,\n\t\trequired: requiredFields,\n\t\tproperties,\n\t};\n\n\treturn schema;\n};\n","import { AccountRequest } from '@socotra/ec-react-schemas';\n\nexport const getAccountRequest = (formData: TODO): AccountRequest => {\n\tconst autoValidate = formData.autoValidate;\n\tconst delinquencyPlanName = formData.delinquencyPlanName;\n\tconst type = formData.accountType;\n\n\t// filter out the accountType, autoValidate, and delinquencyPlanName\n\tconst data = Object.keys(formData).reduce(\n\t\t(acc, key) => {\n\t\t\tif (\n\t\t\t\tkey !== 'accountType' &&\n\t\t\t\tkey !== 'autoValidate' &&\n\t\t\t\tkey !== 'delinquencyPlanName'\n\t\t\t) {\n\t\t\t\tacc[key] = formData[key];\n\t\t\t}\n\t\t\treturn acc;\n\t\t},\n\t\t{} as { [key: string]: object },\n\t);\n\n\tconst request = {\n\t\tautoValidate,\n\t\tdelinquencyPlanName,\n\t\ttype,\n\t\tdata,\n\t};\n\n\treturn request;\n};\n","import { ElementRequest, QuoteRequest } from '@socotra/ec-react-schemas';\n\ntype GetQuoteElementRequestAttributes = {\n\tformData: { [key: string]: unknown };\n\tlocator: string;\n};\n\nexport const getQuoteElementRequest = ({\n\tformData,\n\tlocator,\n}: GetQuoteElementRequestAttributes): QuoteRequest => {\n\tconst elementRequest: ElementRequest = {\n\t\tlocator,\n\t\tsetData: formData,\n\t};\n\n\tconst request: QuoteRequest = {\n\t\telements: [elementRequest],\n\t};\n\n\treturn request;\n};\n","import { AccountRequest, QuoteRequest } from '@socotra/ec-react-schemas';\n\ninterface QuoteDefaultFields {\n\tdelinquencyPlanName: string;\n\tstartTime: string;\n\tendTime: string;\n\tcurrency: string;\n\texpirationTime: string;\n\ttimezone: string;\n}\n\ntype GetQuoteRequestAttributes =\n\t| {\n\t\t\tformData: object;\n\t\t\thideDefaultFields: true;\n\t\t\thideConfiguredFields: true;\n\t }\n\t| {\n\t\t\tformData: QuoteDefaultFields;\n\t\t\thideDefaultFields: false;\n\t\t\thideConfiguredFields: true;\n\t }\n\t| {\n\t\t\tformData: TODO;\n\t\t\thideDefaultFields: true;\n\t\t\thideConfiguredFields: false;\n\t }\n\t| {\n\t\t\tformData: QuoteDefaultFields & TODO;\n\t\t\thideDefaultFields: false;\n\t\t\thideConfiguredFields: false;\n\t };\n\nfunction removeQuoteDefaultFields(formData: QuoteDefaultFields & TODO): TODO {\n\tconst {\n\t\tdelinquencyPlanName,\n\t\tstartTime,\n\t\tendTime,\n\t\tcurrency,\n\t\texpirationTime,\n\t\ttimezone,\n\t\t...rest\n\t} = formData;\n\n\treturn rest;\n}\n\nfunction getQuoteDefaultFields(formData: TODO): QuoteDefaultFields {\n\tconst {\n\t\tdelinquencyPlanName,\n\t\tstartTime,\n\t\tendTime,\n\t\tcurrency,\n\t\texpirationTime,\n\t\ttimezone,\n\t} = formData;\n\n\treturn {\n\t\tdelinquencyPlanName,\n\t\tstartTime,\n\t\tendTime,\n\t\tcurrency,\n\t\texpirationTime,\n\t\ttimezone,\n\t};\n}\n\nexport const getQuoteRequest = ({\n\tformData,\n\thideDefaultFields,\n\thideConfiguredFields,\n}: GetQuoteRequestAttributes): AccountRequest => {\n\tlet request: QuoteRequest = {};\n\n\tif (!hideDefaultFields) {\n\t\tconst defaultFields = getQuoteDefaultFields(formData);\n\t\trequest = {\n\t\t\t...defaultFields,\n\t\t};\n\t}\n\n\tif (!hideConfiguredFields) {\n\t\tconst quoteFields = removeQuoteDefaultFields(formData);\n\t\trequest = {\n\t\t\t...request,\n\t\t\tsetData: quoteFields,\n\t\t};\n\t}\n\n\treturn request;\n};\n","/**\n * Takes an element type and splits the postfix scope from the base model name. E.g., 'PersonalAutoQuote' becomes ['PersonalAuto', 'Quote']\n * @param elementType The element type to parse, e.g. `element.type` from an `ElementResponse`\n * @returns [elementName: string, scope: 'Quote' | 'QuickQuote' | 'Policy' | null]\n */\nexport const parseElementTypeAndScopeByElementType = (\n\telementType: string,\n): [elementName: string, scope: 'Quote' | 'QuickQuote' | 'Policy' | null] => {\n\tconst regex = /^(.*?)(Quote|QuickQuote|Policy)$/;\n\tconst match = elementType.match(regex);\n\tif (\n\t\tmatch &&\n\t\t(match[2] === 'Quote' || match[2] === 'QuickQuote' || match[2] === 'Policy')\n\t) {\n\t\treturn [match[1], match[2]]; // match[1] is the base model name, match[2] is the scope\n\t}\n\n\t// Return the original key and null for the scope if no match found\n\treturn [elementType, null];\n};\n","import { ElementResponse } from '@socotra/ec-react-schemas';\n\n/**\n * Takes the root element of a quote and a locator and returns the element with the matching locator\n * @param quoteElement The root element from the QuoteResponse\n * @param locator The locator of the element to retrieve\n * @returns ElementResponse | undefined\n */\nexport function retrieveElementFromQuoteByLocator(\n\tquoteElement: ElementResponse,\n\tlocator: string,\n): ElementResponse | undefined {\n\tif (quoteElement.locator === locator) {\n\t\treturn quoteElement;\n\t}\n\n\tif (quoteElement.elements) {\n\t\tfor (const element of quoteElement.elements) {\n\t\t\tconst foundElement = retrieveElementFromQuoteByLocator(element, locator);\n\t\t\tif (foundElement) {\n\t\t\t\treturn foundElement;\n\t\t\t}\n\t\t}\n\t}\n\n\treturn undefined;\n}\n","import {\n\tDataModel,\n\tElementConfig,\n\tElementResponse,\n} from '@socotra/ec-react-schemas';\n\nimport { parseElementTypeAndScopeByElementType } from './parse-element-type-and-scope-by-element-type';\n\n/**\n * Looks through a data model for a matching element type and returns the element model\n * @param element The element to retrieve the data model for\n * @param dataModel The full resolved data model to search\n * @returns ElementConfig\n */\nexport function retrieveDataModelFromElement(\n\telement: ElementResponse,\n\tdataModel: DataModel,\n) {\n\tconst [elementType] = parseElementTypeAndScopeByElementType(\n\t\telement.type ?? '',\n\t);\n\n\tlet elementModel: ElementConfig = {};\n\n\t// Look in exposures\n\tif (dataModel.exposures) {\n\t\tObject.keys(dataModel.exposures).forEach((exposureName) => {\n\t\t\tif (exposureName === elementType && dataModel.exposures) {\n\t\t\t\telementModel = dataModel.exposures[exposureName];\n\t\t\t}\n\t\t});\n\t}\n\n\t// Look in coverages\n\tif (dataModel.coverages) {\n\t\tObject.keys(dataModel.coverages).forEach((coverageName) => {\n\t\t\tif (coverageName === elementType && dataModel.coverages) {\n\t\t\t\telementModel = dataModel.coverages[coverageName];\n\t\t\t}\n\t\t});\n\t}\n\n\t// Look in policyLines\n\tif (dataModel.policyLines) {\n\t\tObject.keys(dataModel.policyLines).forEach((policyLineName) => {\n\t\t\tif (policyLineName === elementType && dataModel.policyLines) {\n\t\t\t\telementModel = dataModel.policyLines[policyLineName];\n\t\t\t}\n\t\t});\n\t}\n\n\t// look in ExposureGroups\n\tif (dataModel.exposureGroups) {\n\t\tObject.keys(dataModel.exposureGroups).forEach((exposureGroupName) => {\n\t\t\tif (exposureGroupName === elementType && dataModel.exposureGroups) {\n\t\t\t\telementModel = dataModel.exposureGroups[exposureGroupName];\n\t\t\t}\n\t\t});\n\t}\n\n\treturn elementModel;\n}\n","import { ErrorObject } from 'ajv';\n\nexport function transformErrors(\n\terrors:\n\t\t| ErrorObject<string, Record<string, any>, unknown>[]\n\t\t| null\n\t\t| undefined,\n) {\n\treturn errors?.map((error) => {\n\t\tif (error.keyword === 'pattern') {\n\t\t\terror.message = `Invalid format, must match pattern ${error.params.pattern}`;\n\t\t}\n\t\tif (error.keyword === 'format') {\n\t\t\terror.message = 'Invalid format';\n\t\t}\n\t\tif (error.keyword === 'required') {\n\t\t\terror.message = 'Required';\n\t\t}\n\t\tif (error.keyword === 'minItems') {\n\t\t\terror.message = `Must have at least ${error.params.limit} item${\n\t\t\t\terror.params.limit !== 1 ? 's' : ''\n\t\t\t}`;\n\t\t}\n\t\tif (error.keyword === 'maxItems') {\n\t\t\terror.message = `Must have at most ${error.params.limit} item${\n\t\t\t\terror.params.limit !== 1 ? 's' : ''\n\t\t\t}`;\n\t\t}\n\t\tif (error.keyword === 'type') {\n\t\t\terror.message = 'Invalid format';\n\t\t}\n\t\tif (error.keyword === 'maxLength') {\n\t\t\terror.message = `Must be at most ${error.params.limit} character${\n\t\t\t\terror.params.limit !== 1 ? 's' : ''\n\t\t\t}`;\n\t\t}\n\t\tif (error.keyword === 'minLength') {\n\t\t\terror.message = `Must be at least ${error.params.limit} character${\n\t\t\t\terror.params.limit !== 1 ? 's' : ''\n\t\t\t}`;\n\t\t}\n\t\tif (error.keyword === 'minimum') {\n\t\t\terror.message = `Must be greater than or equal to ${error.params.limit}`;\n\t\t}\n\t\tif (error.keyword === 'maximum') {\n\t\t\terror.message = `Must be less than or equal to ${error.params.limit}`;\n\t\t}\n\t\treturn error;\n\t});\n}\n"],"names":["dataModelToJSONSchema","args","data","scope","dataTypes","rootDisplayName","account","quote","element","requiredFields","definitions","properties","value","dataScope","_a","s","key","isOptional","isArray","isCustomDataType","displayName","quantifier","maxLength","minLength","max","min","regex","type","format","customDataType","defaultValues","referenceSchema","_c","_b","_e","_d","_f","_g","_h","_i","str","defaultValue","dataKey","_j","_k","_m","_l","_o","_n","_p","_q","getAccountRequest","formData","autoValidate","delinquencyPlanName","acc","getQuoteElementRequest","locator","removeQuoteDefaultFields","startTime","endTime","currency","expirationTime","timezone","rest","getQuoteDefaultFields","getQuoteRequest","hideDefaultFields","hideConfiguredFields","request","quoteFields","parseElementTypeAndScopeByElementType","elementType","match","retrieveElementFromQuoteByLocator","quoteElement","foundElement","retrieveDataModelFromElement","dataModel","elementModel","exposureName","coverageName","policyLineName","exposureGroupName","transformErrors","errors","error"],"mappings":"+NAmBa,MAAAA,EAAyBC,GAAqC,CACpE,KAAA,CAAE,KAAAC,EAAM,MAAAC,EAAO,UAAAC,EAAW,gBAAAC,EAAiB,QAAAC,EAAS,MAAAC,EAAO,QAAAC,CAChE,EAAAP,EAEKQ,EAA2B,CAAA,EACjC,IAAIC,EAAc,CAAA,EAClB,MAAMC,GAAa,OAAO,YACzB,OAAO,QAAQT,GAAQ,CAAA,CAAE,EACvB,OAAO,CAAC,CAAG,CAAAU,CAAK,IAAM,OAChB,MAAAC,GAAYC,EAAAF,EAAM,QAAN,YAAAE,EAAa,MAAM,KAAK,IAAKC,GAAMA,EAAE,KAAM,GAW7D,MATI,IAACF,GAIHV,IAAU,MAAOU,GAAA,MAAAA,EAAW,SAAS,OACtCA,GAAA,MAAAA,EAAW,SAAS,MAIjBV,IAAU,MAAOU,GAAA,MAAAA,EAAW,SAAS,MAIzC,CAAA,EACA,IAAI,CAAC,CAACG,EAAKJ,CAAK,IAAM,uCACtB,IAAIK,EAAa,GACbC,EAAU,GACVC,EAAmB,GACjB,MAAAC,EAAcR,EAAM,aAAeI,EACnCK,IAAaP,EAAAF,EAAM,OAAN,YAAAE,EAAY,MAAM,IAC/BQ,EAAYV,EAAM,UAClBW,EAAYX,EAAM,UAClBY,EAAMZ,EAAM,IACZa,EAAMb,EAAM,IACZc,EAAQd,EAAM,MAChB,IAAAe,EAAef,EAAM,MAAQ,GAC7BgB,EAEJ,OAAQP,GAAY,CACnB,IAAK,IACMH,EAAA,GACGD,EAAA,GACbU,EAAOA,GAAA,YAAAA,EAAM,MAAM,KAAK,GACxB,MACD,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,OAAO,QAAU,EAAI,IAAM,EAClC,IAEGA,EAAM,UAAY,cACfA,EAAA,QAAU,oBAAoBA,EAAM,OAAO,KAAK,aACrDA,EAAM,OAAO,QAAU,EAAI,IAAM,EAClC,IAEGA,EAAM,UAAY,YACrBA,EAAM,QAAU,oCAAoCA,EAAM,OAAO,KAAK,IAEnEA,EAAM,UAAY,YACrBA,EAAM,QAAU,iCAAiCA,EAAM,OAAO,KAAK,IAE7DA,GAET"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@socotra/ec-react-utils",
|
|
3
|
-
"version": "0.0.0-alpha.
|
|
3
|
+
"version": "0.0.0-alpha.3",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"main": "./dist/index.umd.js",
|
|
6
6
|
"module": "./dist/index.es.js",
|
|
@@ -21,8 +21,9 @@
|
|
|
21
21
|
"preview": "vite preview"
|
|
22
22
|
},
|
|
23
23
|
"dependencies": {
|
|
24
|
-
"@
|
|
25
|
-
"@socotra/ec-react-schemas": "^0.0.0-alpha.
|
|
24
|
+
"@jsonforms/core": "^3.3.0",
|
|
25
|
+
"@socotra/ec-react-schemas": "^0.0.0-alpha.3",
|
|
26
|
+
"ajv": "^8.14.0"
|
|
26
27
|
},
|
|
27
|
-
"gitHead": "
|
|
28
|
+
"gitHead": "8e7faaf5ff9a4f7593a3b68a6114e742aa52c443"
|
|
28
29
|
}
|