@player-ui/common-types-plugin 0.8.0--canary.307.9621 → 0.8.0--canary.410.15865
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/CommonTypesPlugin.native.js +8292 -0
- package/dist/CommonTypesPlugin.native.js.map +1 -0
- package/dist/{index.cjs.js → cjs/index.cjs} +273 -233
- package/dist/cjs/index.cjs.map +1 -0
- package/dist/{index.esm.js → index.legacy-esm.js} +246 -220
- package/dist/index.mjs +782 -0
- package/dist/index.mjs.map +1 -0
- package/package.json +26 -58
- package/src/__tests__/index.test.ts +198 -0
- package/src/data-types/types.ts +27 -37
- package/src/formats/__tests__/formats.test.ts +264 -0
- package/src/formats/__tests__/utils.test.ts +44 -0
- package/src/formats/index.ts +71 -69
- package/src/formats/utils.ts +16 -16
- package/src/index.ts +12 -12
- package/src/validators/__tests__/index.test.ts +472 -0
- package/src/validators/index.ts +67 -68
- package/types/data-types/types.d.ts +10 -0
- package/types/formats/index.d.ts +24 -0
- package/types/formats/utils.d.ts +41 -0
- package/types/index.d.ts +27 -0
- package/types/validators/index.d.ts +68 -0
- package/dist/common-types-plugin.dev.js +0 -11388
- package/dist/common-types-plugin.prod.js +0 -2
- package/dist/index.d.ts +0 -260
- package/dist/xlr/BooleanType.json +0 -72
- package/dist/xlr/CollectionType.json +0 -39
- package/dist/xlr/DateType.json +0 -55
- package/dist/xlr/IntegerNNType.json +0 -75
- package/dist/xlr/IntegerPosType.json +0 -75
- package/dist/xlr/IntegerType.json +0 -55
- package/dist/xlr/PhoneType.json +0 -55
- package/dist/xlr/StringType.json +0 -62
- package/dist/xlr/manifest.js +0 -21
- package/dist/xlr/manifest.json +0 -26
- package/src/data-types/refs.ts +0 -33
|
@@ -1,9 +1,34 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __export = (target, all) => {
|
|
3
|
+
for (var name in all)
|
|
4
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
5
|
+
};
|
|
3
6
|
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
+
// ../../../../../../../../../../../execroot/_main/bazel-out/k8-fastbuild/bin/plugins/common-types/core/src/index.ts
|
|
8
|
+
import { TypesProviderPlugin } from "@player-ui/types-provider-plugin";
|
|
9
|
+
|
|
10
|
+
// ../../../../../../../../../../../execroot/_main/bazel-out/k8-fastbuild/bin/plugins/common-types/core/src/validators/index.ts
|
|
11
|
+
var validators_exports = {};
|
|
12
|
+
__export(validators_exports, {
|
|
13
|
+
collection: () => collection,
|
|
14
|
+
email: () => email,
|
|
15
|
+
expression: () => expression,
|
|
16
|
+
integer: () => integer,
|
|
17
|
+
length: () => length,
|
|
18
|
+
max: () => max,
|
|
19
|
+
min: () => min,
|
|
20
|
+
oneOf: () => oneOf,
|
|
21
|
+
phone: () => phone,
|
|
22
|
+
readonly: () => readonly,
|
|
23
|
+
regex: () => regex,
|
|
24
|
+
required: () => required,
|
|
25
|
+
string: () => string,
|
|
26
|
+
zip: () => zip
|
|
27
|
+
});
|
|
28
|
+
import { resolveDataRefs } from "@player-ui/player";
|
|
29
|
+
var EMAIL_REGEX = /^((([a-z]|\d|[!#$%&'*+\-/=?^_`{|}~]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])+(\.([a-z]|\d|[!#$%&'*+-/=?^_`{|}~]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])+)*)|((\x22)((((\x20|\x09)*(\x0d\x0a))?(\x20|\x09)+)?(([\x01-\x08\x0b\x0c\x0e-\x1f\x7f]|\x21|[\x23-\x5b]|[\x5d-\x7e]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(\\([\x01-\x09\x0b\x0c\x0d-\x7f]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]))))*(((\x20|\x09)*(\x0d\x0a))?(\x20|\x09)+)?(\x22)))@((([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))\.)+(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))\.?$/i;
|
|
30
|
+
var PHONE_REGEX = /^\+?[1]?[- ]?\(?\d{3}[)\- ]?\s?\d{3}[ -]?\d{4}$/;
|
|
31
|
+
var ZIP_REGEX = /^\d{5}(-\d{4})?$/;
|
|
7
32
|
function skipNullish(validationFn) {
|
|
8
33
|
return (context, value, options) => {
|
|
9
34
|
if (value === null || value === void 0) {
|
|
@@ -12,9 +37,13 @@ function skipNullish(validationFn) {
|
|
|
12
37
|
return validationFn(context, value, options);
|
|
13
38
|
};
|
|
14
39
|
}
|
|
15
|
-
|
|
40
|
+
var string = skipNullish((context, value) => {
|
|
16
41
|
if (typeof value !== "string") {
|
|
17
|
-
const message = context.constants.getConstants(
|
|
42
|
+
const message = context.constants.getConstants(
|
|
43
|
+
"validation.string",
|
|
44
|
+
"constants",
|
|
45
|
+
"Value must be a string"
|
|
46
|
+
);
|
|
18
47
|
return {
|
|
19
48
|
message,
|
|
20
49
|
parameters: {
|
|
@@ -23,19 +52,31 @@ const string = skipNullish((context, value) => {
|
|
|
23
52
|
};
|
|
24
53
|
}
|
|
25
54
|
});
|
|
26
|
-
|
|
27
|
-
const message = context.constants.getConstants(
|
|
55
|
+
var readonly = (context) => {
|
|
56
|
+
const message = context.constants.getConstants(
|
|
57
|
+
"validation.readonly",
|
|
58
|
+
"constants",
|
|
59
|
+
"Value cannot be modified"
|
|
60
|
+
);
|
|
28
61
|
return { message };
|
|
29
62
|
};
|
|
30
|
-
|
|
63
|
+
var collection = skipNullish((context, value) => {
|
|
31
64
|
if (!Array.isArray(value)) {
|
|
32
|
-
const message = context.constants.getConstants(
|
|
65
|
+
const message = context.constants.getConstants(
|
|
66
|
+
"validation.collection",
|
|
67
|
+
"constants",
|
|
68
|
+
"Cannot set collection to non-array"
|
|
69
|
+
);
|
|
33
70
|
return { message };
|
|
34
71
|
}
|
|
35
72
|
});
|
|
36
|
-
|
|
73
|
+
var integer = skipNullish((context, value) => {
|
|
37
74
|
if (value && (typeof value !== "number" || Math.floor(value) !== value || Number(value) > Number.MAX_SAFE_INTEGER || Number(value) < Number.MIN_SAFE_INTEGER)) {
|
|
38
|
-
const message = context.constants.getConstants(
|
|
75
|
+
const message = context.constants.getConstants(
|
|
76
|
+
"validation.integer",
|
|
77
|
+
"constants",
|
|
78
|
+
"Value must be an integer"
|
|
79
|
+
);
|
|
39
80
|
return {
|
|
40
81
|
message,
|
|
41
82
|
parameters: {
|
|
@@ -45,47 +86,62 @@ const integer$1 = skipNullish((context, value) => {
|
|
|
45
86
|
};
|
|
46
87
|
}
|
|
47
88
|
});
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
if ((options == null ? void 0 : options.options) === void 0 || ((_a = options.options) == null ? void 0 : _a.includes(value))) {
|
|
89
|
+
var oneOf = skipNullish((context, value, options) => {
|
|
90
|
+
if (options?.options === void 0 || options.options?.includes(value)) {
|
|
51
91
|
return;
|
|
52
92
|
}
|
|
53
|
-
const message = context.constants.getConstants(
|
|
93
|
+
const message = context.constants.getConstants(
|
|
94
|
+
"validation.oneOf",
|
|
95
|
+
"constants",
|
|
96
|
+
"Invalid entry"
|
|
97
|
+
);
|
|
54
98
|
return { message };
|
|
55
99
|
});
|
|
56
|
-
|
|
57
|
-
if (
|
|
100
|
+
var expression = (context, value, options) => {
|
|
101
|
+
if (options?.exp === void 0) {
|
|
58
102
|
context.logger.warn("No expression defined for validation");
|
|
59
103
|
return;
|
|
60
104
|
}
|
|
61
105
|
const result = context.evaluate(options.exp);
|
|
62
106
|
if (!result) {
|
|
63
|
-
const message = context.constants.getConstants(
|
|
107
|
+
const message = context.constants.getConstants(
|
|
108
|
+
"validation.expression",
|
|
109
|
+
"constants",
|
|
110
|
+
"Expression evaluation failed"
|
|
111
|
+
);
|
|
64
112
|
return { message };
|
|
65
113
|
}
|
|
66
114
|
};
|
|
67
|
-
|
|
68
|
-
if (
|
|
115
|
+
var required = (context, value, options) => {
|
|
116
|
+
if (options?.if && !context.evaluate(options.if) || options?.ifNot && context.evaluate(options.ifNot)) {
|
|
69
117
|
return;
|
|
70
118
|
}
|
|
71
119
|
if (value === void 0 || value === null || value === "") {
|
|
72
|
-
const message = context.constants.getConstants(
|
|
120
|
+
const message = context.constants.getConstants(
|
|
121
|
+
"validation.required",
|
|
122
|
+
"constants",
|
|
123
|
+
"A value is required"
|
|
124
|
+
);
|
|
73
125
|
return { message, severity: "error" };
|
|
74
126
|
}
|
|
75
127
|
};
|
|
76
|
-
|
|
77
|
-
if (value === void 0 || value === null || value === "" || typeof
|
|
128
|
+
var regex = skipNullish((context, value, options) => {
|
|
129
|
+
if (value === void 0 || value === null || value === "" || typeof options?.regex !== "string") {
|
|
78
130
|
return;
|
|
79
131
|
}
|
|
80
132
|
const resolvedRegex = resolveDataRefs(options.regex, context);
|
|
81
133
|
const patternMatch = resolvedRegex.match(/^\/(.*)\/(\w)*$/);
|
|
82
134
|
const regexp = patternMatch ? new RegExp(patternMatch[1], patternMatch[2]) : new RegExp(resolvedRegex);
|
|
83
135
|
if (!regexp.test(value)) {
|
|
84
|
-
const message = context.constants.getConstants(
|
|
136
|
+
const message = context.constants.getConstants(
|
|
137
|
+
"validation.regex",
|
|
138
|
+
"constants",
|
|
139
|
+
"Invalid entry"
|
|
140
|
+
);
|
|
85
141
|
return { message };
|
|
86
142
|
}
|
|
87
143
|
});
|
|
88
|
-
|
|
144
|
+
var length = skipNullish((context, value, options) => {
|
|
89
145
|
if (typeof options !== "object") {
|
|
90
146
|
context.logger.warn("Missing comparison in length validation");
|
|
91
147
|
return;
|
|
@@ -99,7 +155,9 @@ const length = skipNullish((context, value, options) => {
|
|
|
99
155
|
valLength = Object.keys(value).length;
|
|
100
156
|
}
|
|
101
157
|
if (valLength === void 0) {
|
|
102
|
-
context.logger.warn(
|
|
158
|
+
context.logger.warn(
|
|
159
|
+
`Unable to determine a length for value of type: ${value}`
|
|
160
|
+
);
|
|
103
161
|
return;
|
|
104
162
|
}
|
|
105
163
|
if ("exact" in options) {
|
|
@@ -114,7 +172,11 @@ const length = skipNullish((context, value, options) => {
|
|
|
114
172
|
return;
|
|
115
173
|
}
|
|
116
174
|
if (options.min !== void 0 && valLength < options.min) {
|
|
117
|
-
const message = context.constants.getConstants(
|
|
175
|
+
const message = context.constants.getConstants(
|
|
176
|
+
"validation.length.minimum",
|
|
177
|
+
"constants",
|
|
178
|
+
`At least ${options.min} ${itemName} needed`
|
|
179
|
+
);
|
|
118
180
|
return {
|
|
119
181
|
message,
|
|
120
182
|
parameters: {
|
|
@@ -123,7 +185,11 @@ const length = skipNullish((context, value, options) => {
|
|
|
123
185
|
};
|
|
124
186
|
}
|
|
125
187
|
if (options.max !== void 0 && valLength > options.max) {
|
|
126
|
-
const message = context.constants.getConstants(
|
|
188
|
+
const message = context.constants.getConstants(
|
|
189
|
+
"validation.length.maximum",
|
|
190
|
+
"constants",
|
|
191
|
+
`Up to ${options.max} ${itemName} allowed`
|
|
192
|
+
);
|
|
127
193
|
return {
|
|
128
194
|
message,
|
|
129
195
|
parameters: {
|
|
@@ -132,114 +198,77 @@ const length = skipNullish((context, value, options) => {
|
|
|
132
198
|
};
|
|
133
199
|
}
|
|
134
200
|
});
|
|
135
|
-
|
|
136
|
-
if (typeof value !== "number" ||
|
|
201
|
+
var min = skipNullish((context, value, options) => {
|
|
202
|
+
if (typeof value !== "number" || options?.value === void 0) {
|
|
137
203
|
return;
|
|
138
204
|
}
|
|
139
205
|
if (value < options.value) {
|
|
140
|
-
const message = context.constants.getConstants(
|
|
206
|
+
const message = context.constants.getConstants(
|
|
207
|
+
"validation.min",
|
|
208
|
+
"constants",
|
|
209
|
+
`Must be at least ${options.value}`
|
|
210
|
+
);
|
|
141
211
|
return { message };
|
|
142
212
|
}
|
|
143
213
|
});
|
|
144
|
-
|
|
145
|
-
if (typeof value !== "number" ||
|
|
214
|
+
var max = skipNullish((context, value, options) => {
|
|
215
|
+
if (typeof value !== "number" || options?.value === void 0) {
|
|
146
216
|
return;
|
|
147
217
|
}
|
|
148
218
|
if (value > options.value) {
|
|
149
|
-
const message = context.constants.getConstants(
|
|
219
|
+
const message = context.constants.getConstants(
|
|
220
|
+
"validation.max",
|
|
221
|
+
"constants",
|
|
222
|
+
`Cannot exceed ${options.value}`
|
|
223
|
+
);
|
|
150
224
|
return { message };
|
|
151
225
|
}
|
|
152
226
|
});
|
|
153
|
-
|
|
227
|
+
var stringRegexValidator = (test, messagePath, invalidMessage) => {
|
|
154
228
|
return skipNullish((context, value) => {
|
|
155
229
|
if (typeof value === "string" && value === "") {
|
|
156
230
|
return;
|
|
157
231
|
}
|
|
158
232
|
if (typeof value !== "string" || !test.test(value)) {
|
|
159
|
-
const message = context.constants.getConstants(
|
|
233
|
+
const message = context.constants.getConstants(
|
|
234
|
+
messagePath,
|
|
235
|
+
"constants",
|
|
236
|
+
invalidMessage
|
|
237
|
+
);
|
|
160
238
|
return { message };
|
|
161
239
|
}
|
|
162
240
|
});
|
|
163
241
|
};
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
242
|
+
var email = stringRegexValidator(
|
|
243
|
+
EMAIL_REGEX,
|
|
244
|
+
"validation.email",
|
|
245
|
+
"Improper email format"
|
|
246
|
+
);
|
|
247
|
+
var phone = stringRegexValidator(
|
|
248
|
+
PHONE_REGEX,
|
|
249
|
+
"validation.phone",
|
|
250
|
+
"Invalid phone number"
|
|
251
|
+
);
|
|
252
|
+
var zip = stringRegexValidator(
|
|
253
|
+
ZIP_REGEX,
|
|
254
|
+
"validation.regex",
|
|
255
|
+
"Invalid zip code"
|
|
256
|
+
);
|
|
167
257
|
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
min: min,
|
|
180
|
-
max: max,
|
|
181
|
-
email: email,
|
|
182
|
-
phone: phone$1,
|
|
183
|
-
zip: zip
|
|
258
|
+
// ../../../../../../../../../../../execroot/_main/bazel-out/k8-fastbuild/bin/plugins/common-types/core/src/data-types/types.ts
|
|
259
|
+
var types_exports = {};
|
|
260
|
+
__export(types_exports, {
|
|
261
|
+
BooleanType: () => BooleanType,
|
|
262
|
+
CollectionType: () => CollectionType,
|
|
263
|
+
DateType: () => DateType,
|
|
264
|
+
IntegerNNType: () => IntegerNNType,
|
|
265
|
+
IntegerPosType: () => IntegerPosType,
|
|
266
|
+
IntegerType: () => IntegerType,
|
|
267
|
+
PhoneType: () => PhoneType,
|
|
268
|
+
StringType: () => StringType
|
|
184
269
|
});
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
type: "BooleanType"
|
|
188
|
-
};
|
|
189
|
-
const IntegerTypeRef = {
|
|
190
|
-
type: "IntegerType"
|
|
191
|
-
};
|
|
192
|
-
const IntegerPosTypeRef = {
|
|
193
|
-
type: "IntegerPosType"
|
|
194
|
-
};
|
|
195
|
-
const IntegerNNTypeRef = {
|
|
196
|
-
type: "IntegerNNType"
|
|
197
|
-
};
|
|
198
|
-
const StringTypeRef = {
|
|
199
|
-
type: "StringType"
|
|
200
|
-
};
|
|
201
|
-
const CollectionTypeRef = {
|
|
202
|
-
type: "CollectionType"
|
|
203
|
-
};
|
|
204
|
-
const DateTypeRef = {
|
|
205
|
-
type: "DateType"
|
|
206
|
-
};
|
|
207
|
-
const PhoneTypeRef = {
|
|
208
|
-
type: "PhoneType"
|
|
209
|
-
};
|
|
210
|
-
|
|
211
|
-
var refs = /*#__PURE__*/Object.freeze({
|
|
212
|
-
__proto__: null,
|
|
213
|
-
BooleanTypeRef: BooleanTypeRef,
|
|
214
|
-
IntegerTypeRef: IntegerTypeRef,
|
|
215
|
-
IntegerPosTypeRef: IntegerPosTypeRef,
|
|
216
|
-
IntegerNNTypeRef: IntegerNNTypeRef,
|
|
217
|
-
StringTypeRef: StringTypeRef,
|
|
218
|
-
CollectionTypeRef: CollectionTypeRef,
|
|
219
|
-
DateTypeRef: DateTypeRef,
|
|
220
|
-
PhoneTypeRef: PhoneTypeRef
|
|
221
|
-
});
|
|
222
|
-
|
|
223
|
-
var __defProp$1 = Object.defineProperty;
|
|
224
|
-
var __defProps$1 = Object.defineProperties;
|
|
225
|
-
var __getOwnPropDescs$1 = Object.getOwnPropertyDescriptors;
|
|
226
|
-
var __getOwnPropSymbols$1 = Object.getOwnPropertySymbols;
|
|
227
|
-
var __hasOwnProp$1 = Object.prototype.hasOwnProperty;
|
|
228
|
-
var __propIsEnum$1 = Object.prototype.propertyIsEnumerable;
|
|
229
|
-
var __defNormalProp$1 = (obj, key, value) => key in obj ? __defProp$1(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
230
|
-
var __spreadValues$1 = (a, b) => {
|
|
231
|
-
for (var prop in b || (b = {}))
|
|
232
|
-
if (__hasOwnProp$1.call(b, prop))
|
|
233
|
-
__defNormalProp$1(a, prop, b[prop]);
|
|
234
|
-
if (__getOwnPropSymbols$1)
|
|
235
|
-
for (var prop of __getOwnPropSymbols$1(b)) {
|
|
236
|
-
if (__propIsEnum$1.call(b, prop))
|
|
237
|
-
__defNormalProp$1(a, prop, b[prop]);
|
|
238
|
-
}
|
|
239
|
-
return a;
|
|
240
|
-
};
|
|
241
|
-
var __spreadProps$1 = (a, b) => __defProps$1(a, __getOwnPropDescs$1(b));
|
|
242
|
-
const BooleanType = __spreadProps$1(__spreadValues$1({}, BooleanTypeRef), {
|
|
270
|
+
var BooleanType = {
|
|
271
|
+
type: "BooleanType",
|
|
243
272
|
default: false,
|
|
244
273
|
validation: [
|
|
245
274
|
{
|
|
@@ -248,8 +277,9 @@ const BooleanType = __spreadProps$1(__spreadValues$1({}, BooleanTypeRef), {
|
|
|
248
277
|
options: [true, false]
|
|
249
278
|
}
|
|
250
279
|
]
|
|
251
|
-
}
|
|
252
|
-
|
|
280
|
+
};
|
|
281
|
+
var IntegerType = {
|
|
282
|
+
type: "IntegerType",
|
|
253
283
|
validation: [
|
|
254
284
|
{
|
|
255
285
|
type: "integer"
|
|
@@ -258,8 +288,9 @@ const IntegerType = __spreadProps$1(__spreadValues$1({}, IntegerTypeRef), {
|
|
|
258
288
|
format: {
|
|
259
289
|
type: "integer"
|
|
260
290
|
}
|
|
261
|
-
}
|
|
262
|
-
|
|
291
|
+
};
|
|
292
|
+
var IntegerPosType = {
|
|
293
|
+
type: "IntegerPosType",
|
|
263
294
|
validation: [
|
|
264
295
|
{
|
|
265
296
|
type: "integer"
|
|
@@ -272,8 +303,9 @@ const IntegerPosType = __spreadProps$1(__spreadValues$1({}, IntegerPosTypeRef),
|
|
|
272
303
|
format: {
|
|
273
304
|
type: "integer"
|
|
274
305
|
}
|
|
275
|
-
}
|
|
276
|
-
|
|
306
|
+
};
|
|
307
|
+
var IntegerNNType = {
|
|
308
|
+
type: "IntegerNNType",
|
|
277
309
|
validation: [
|
|
278
310
|
{
|
|
279
311
|
type: "integer"
|
|
@@ -286,8 +318,9 @@ const IntegerNNType = __spreadProps$1(__spreadValues$1({}, IntegerNNTypeRef), {
|
|
|
286
318
|
format: {
|
|
287
319
|
type: "integer"
|
|
288
320
|
}
|
|
289
|
-
}
|
|
290
|
-
|
|
321
|
+
};
|
|
322
|
+
var StringType = {
|
|
323
|
+
type: "StringType",
|
|
291
324
|
default: "",
|
|
292
325
|
validation: [
|
|
293
326
|
{
|
|
@@ -297,15 +330,17 @@ const StringType = __spreadProps$1(__spreadValues$1({}, StringTypeRef), {
|
|
|
297
330
|
format: {
|
|
298
331
|
type: "string"
|
|
299
332
|
}
|
|
300
|
-
}
|
|
301
|
-
|
|
333
|
+
};
|
|
334
|
+
var CollectionType = {
|
|
335
|
+
type: "CollectionType",
|
|
302
336
|
validation: [
|
|
303
337
|
{
|
|
304
338
|
type: "collection"
|
|
305
339
|
}
|
|
306
340
|
]
|
|
307
|
-
}
|
|
308
|
-
|
|
341
|
+
};
|
|
342
|
+
var DateType = {
|
|
343
|
+
type: "DateType",
|
|
309
344
|
validation: [
|
|
310
345
|
{
|
|
311
346
|
type: "string"
|
|
@@ -314,8 +349,9 @@ const DateType = __spreadProps$1(__spreadValues$1({}, DateTypeRef), {
|
|
|
314
349
|
format: {
|
|
315
350
|
type: "date"
|
|
316
351
|
}
|
|
317
|
-
}
|
|
318
|
-
|
|
352
|
+
};
|
|
353
|
+
var PhoneType = {
|
|
354
|
+
type: "PhoneType",
|
|
319
355
|
validation: [
|
|
320
356
|
{
|
|
321
357
|
type: "phone"
|
|
@@ -324,22 +360,21 @@ const PhoneType = __spreadProps$1(__spreadValues$1({}, PhoneTypeRef), {
|
|
|
324
360
|
format: {
|
|
325
361
|
type: "phone"
|
|
326
362
|
}
|
|
327
|
-
}
|
|
363
|
+
};
|
|
328
364
|
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
DateType: DateType,
|
|
338
|
-
PhoneType: PhoneType
|
|
365
|
+
// ../../../../../../../../../../../execroot/_main/bazel-out/k8-fastbuild/bin/plugins/common-types/core/src/formats/index.ts
|
|
366
|
+
var formats_exports = {};
|
|
367
|
+
__export(formats_exports, {
|
|
368
|
+
commaNumber: () => commaNumber,
|
|
369
|
+
currency: () => currency,
|
|
370
|
+
date: () => date,
|
|
371
|
+
integer: () => integer2,
|
|
372
|
+
phone: () => phone2
|
|
339
373
|
});
|
|
340
374
|
|
|
341
|
-
|
|
342
|
-
|
|
375
|
+
// ../../../../../../../../../../../execroot/_main/bazel-out/k8-fastbuild/bin/plugins/common-types/core/src/formats/utils.ts
|
|
376
|
+
var PLACEHOLDER = "#";
|
|
377
|
+
var removeFormatCharactersFromMaskedString = (value, mask, reserved = [PLACEHOLDER]) => {
|
|
343
378
|
const reservedMatchesLength = mask.split("").filter((val) => reserved.includes(val)).length;
|
|
344
379
|
let replacements = 0;
|
|
345
380
|
return value.split("").reduce((newString, nextChar, nextIndex) => {
|
|
@@ -361,12 +396,12 @@ const removeFormatCharactersFromMaskedString = (value, mask, reserved = [PLACEHO
|
|
|
361
396
|
return newString;
|
|
362
397
|
}, "");
|
|
363
398
|
};
|
|
364
|
-
|
|
399
|
+
var formatAsEnum = (value, acceptedValues, options) => {
|
|
365
400
|
const autoCompletionsByOverlapCount = acceptedValues.reduce((validCompletions, validValue) => {
|
|
366
401
|
let overlap = 0;
|
|
367
402
|
for (let charIndex = 0; charIndex < Math.min(validValue.length, value.length); charIndex++) {
|
|
368
|
-
const validChar =
|
|
369
|
-
const actualChar =
|
|
403
|
+
const validChar = options?.ignoreCase ? validValue[charIndex].toLowerCase() : validValue[charIndex];
|
|
404
|
+
const actualChar = options?.ignoreCase ? value[charIndex].toLowerCase() : value[charIndex];
|
|
370
405
|
if (validChar !== actualChar) {
|
|
371
406
|
break;
|
|
372
407
|
}
|
|
@@ -384,12 +419,15 @@ const formatAsEnum = (value, acceptedValues, options) => {
|
|
|
384
419
|
if (autoCompletionsByOverlapCount.length === 0) {
|
|
385
420
|
return void 0;
|
|
386
421
|
}
|
|
387
|
-
if (autoCompletionsByOverlapCount.length === 1 &&
|
|
422
|
+
if (autoCompletionsByOverlapCount.length === 1 && options?.autocomplete) {
|
|
388
423
|
return autoCompletionsByOverlapCount[0].target;
|
|
389
424
|
}
|
|
390
|
-
return autoCompletionsByOverlapCount[0].target.substr(
|
|
425
|
+
return autoCompletionsByOverlapCount[0].target.substr(
|
|
426
|
+
0,
|
|
427
|
+
autoCompletionsByOverlapCount[0].count
|
|
428
|
+
);
|
|
391
429
|
};
|
|
392
|
-
|
|
430
|
+
var formatAsMasked = (value, valueCharMaskMatch, mask) => {
|
|
393
431
|
const valStr = String(value);
|
|
394
432
|
let withMask = mask;
|
|
395
433
|
if (valStr.trim() === "") {
|
|
@@ -401,18 +439,22 @@ const formatAsMasked = (value, valueCharMaskMatch, mask) => {
|
|
|
401
439
|
});
|
|
402
440
|
return withMask.split(PLACEHOLDER)[0];
|
|
403
441
|
};
|
|
404
|
-
|
|
442
|
+
var createMaskedNumericFormatter = (name, mask) => {
|
|
405
443
|
return {
|
|
406
444
|
name,
|
|
407
445
|
format: (value, options) => {
|
|
408
446
|
if (typeof value !== "string") {
|
|
409
447
|
return value;
|
|
410
448
|
}
|
|
411
|
-
if (
|
|
412
|
-
const formattedUsingExceptions = formatAsEnum(
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
449
|
+
if (options?.exceptions && options.exceptions.length > 0) {
|
|
450
|
+
const formattedUsingExceptions = formatAsEnum(
|
|
451
|
+
value,
|
|
452
|
+
options.exceptions,
|
|
453
|
+
{
|
|
454
|
+
autocomplete: true,
|
|
455
|
+
ignoreCase: true
|
|
456
|
+
}
|
|
457
|
+
);
|
|
416
458
|
if (formattedUsingExceptions !== void 0) {
|
|
417
459
|
return formattedUsingExceptions;
|
|
418
460
|
}
|
|
@@ -423,7 +465,7 @@ const createMaskedNumericFormatter = (name, mask) => {
|
|
|
423
465
|
if (typeof value !== "string") {
|
|
424
466
|
return value;
|
|
425
467
|
}
|
|
426
|
-
if (
|
|
468
|
+
if (options?.exceptions && options.exceptions.length > 0) {
|
|
427
469
|
const usingExceptions = formatAsEnum(value, options.exceptions, {
|
|
428
470
|
autocomplete: false,
|
|
429
471
|
ignoreCase: false
|
|
@@ -437,39 +479,22 @@ const createMaskedNumericFormatter = (name, mask) => {
|
|
|
437
479
|
};
|
|
438
480
|
};
|
|
439
481
|
|
|
440
|
-
|
|
441
|
-
var
|
|
442
|
-
var
|
|
443
|
-
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
|
444
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
445
|
-
var __propIsEnum = Object.prototype.propertyIsEnumerable;
|
|
446
|
-
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
447
|
-
var __spreadValues = (a, b) => {
|
|
448
|
-
for (var prop in b || (b = {}))
|
|
449
|
-
if (__hasOwnProp.call(b, prop))
|
|
450
|
-
__defNormalProp(a, prop, b[prop]);
|
|
451
|
-
if (__getOwnPropSymbols)
|
|
452
|
-
for (var prop of __getOwnPropSymbols(b)) {
|
|
453
|
-
if (__propIsEnum.call(b, prop))
|
|
454
|
-
__defNormalProp(a, prop, b[prop]);
|
|
455
|
-
}
|
|
456
|
-
return a;
|
|
457
|
-
};
|
|
458
|
-
var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
|
|
459
|
-
const LENGTH_OF_MAX_INT = String(Number.MAX_SAFE_INTEGER).split("").length;
|
|
460
|
-
const integer = {
|
|
482
|
+
// ../../../../../../../../../../../execroot/_main/bazel-out/k8-fastbuild/bin/plugins/common-types/core/src/formats/index.ts
|
|
483
|
+
var LENGTH_OF_MAX_INT = String(Number.MAX_SAFE_INTEGER).split("").length;
|
|
484
|
+
var integer2 = {
|
|
461
485
|
name: "integer",
|
|
486
|
+
/** Converts any integer to a string */
|
|
462
487
|
format: (value) => {
|
|
463
|
-
var _a, _b;
|
|
464
488
|
if (value === "-") {
|
|
465
489
|
return value;
|
|
466
490
|
}
|
|
467
|
-
const formatted =
|
|
491
|
+
const formatted = integer2.deformat?.(value) ?? value;
|
|
468
492
|
if (typeof formatted === "number") {
|
|
469
493
|
return String(formatted);
|
|
470
494
|
}
|
|
471
495
|
return "";
|
|
472
496
|
},
|
|
497
|
+
/** Converts any string or number to an integer */
|
|
473
498
|
deformat: (value) => {
|
|
474
499
|
if (typeof value === "number") {
|
|
475
500
|
return Math.floor(value) + 0;
|
|
@@ -491,8 +516,9 @@ const integer = {
|
|
|
491
516
|
return Math.floor(num) + 0;
|
|
492
517
|
}
|
|
493
518
|
};
|
|
494
|
-
|
|
519
|
+
var commaNumber = {
|
|
495
520
|
name: "commaNumber",
|
|
521
|
+
/** Go from number to number w/ commas */
|
|
496
522
|
format: (_value, options) => {
|
|
497
523
|
if (_value === void 0 || _value === "") {
|
|
498
524
|
return _value;
|
|
@@ -514,7 +540,7 @@ const commaNumber = {
|
|
|
514
540
|
} else {
|
|
515
541
|
preDecDigits = preDecDigits.substr(0, LENGTH_OF_MAX_INT);
|
|
516
542
|
}
|
|
517
|
-
if (
|
|
543
|
+
if (options?.precision !== void 0) {
|
|
518
544
|
postDecDigits = postDecDigits.substring(0, options.precision).padEnd(options.precision, "0");
|
|
519
545
|
}
|
|
520
546
|
preDecDigits = preDecDigits.replace(/\B(?=(\d{3})+(?!\d))/g, ",");
|
|
@@ -525,11 +551,12 @@ const commaNumber = {
|
|
|
525
551
|
if (isNeg) {
|
|
526
552
|
retVal = `-${retVal}`;
|
|
527
553
|
}
|
|
528
|
-
if (firstDecimal >= 0 ||
|
|
554
|
+
if ((firstDecimal >= 0 || options?.precision !== void 0) && postDecDigits !== "") {
|
|
529
555
|
retVal += `.${postDecDigits}`;
|
|
530
556
|
}
|
|
531
557
|
return retVal;
|
|
532
558
|
},
|
|
559
|
+
/** Go from string with comma's to numbers */
|
|
533
560
|
deformat: (value) => {
|
|
534
561
|
if (typeof value !== "string") {
|
|
535
562
|
return value;
|
|
@@ -542,10 +569,9 @@ const commaNumber = {
|
|
|
542
569
|
return isNaN(number) || number > Number.MAX_SAFE_INTEGER || number < Number.MIN_SAFE_INTEGER ? void 0 : number;
|
|
543
570
|
}
|
|
544
571
|
};
|
|
545
|
-
|
|
572
|
+
var date = {
|
|
546
573
|
name: "date",
|
|
547
574
|
format: (_value, options) => {
|
|
548
|
-
var _a, _b;
|
|
549
575
|
let value = typeof _value === "number" ? String(_value) : _value;
|
|
550
576
|
if (_value === void 0) {
|
|
551
577
|
return void 0;
|
|
@@ -557,7 +583,7 @@ const date = {
|
|
|
557
583
|
const tempVal = value.split("-");
|
|
558
584
|
value = `${tempVal[1]}/${tempVal[2]}/${tempVal[0]}`;
|
|
559
585
|
}
|
|
560
|
-
const dateFormat =
|
|
586
|
+
const dateFormat = options?.mask?.toUpperCase() ?? "MM/DD/YYYY";
|
|
561
587
|
const delimiter = dateFormat.replace(/[^/.-]/g, "").charAt(0);
|
|
562
588
|
const formatParts = dateFormat.split(delimiter);
|
|
563
589
|
const valueParts = value.split(delimiter);
|
|
@@ -596,7 +622,7 @@ const date = {
|
|
|
596
622
|
let autocomplete;
|
|
597
623
|
if (part.length === 2 && (hasDelimiterAfter || isLastExpectedField && part !== "19" && part !== "20")) {
|
|
598
624
|
autocomplete = `20${part}`;
|
|
599
|
-
if (part > (new Date().getFullYear() + 5).toString().substring(2)) {
|
|
625
|
+
if (part > ((/* @__PURE__ */ new Date()).getFullYear() + 5).toString().substring(2)) {
|
|
600
626
|
autocomplete = `19${part}`;
|
|
601
627
|
}
|
|
602
628
|
}
|
|
@@ -666,7 +692,7 @@ const date = {
|
|
|
666
692
|
return processedValueParts.join(delimiter);
|
|
667
693
|
}
|
|
668
694
|
};
|
|
669
|
-
|
|
695
|
+
var currency = {
|
|
670
696
|
name: "currency",
|
|
671
697
|
format: (_value, options) => {
|
|
672
698
|
const value = typeof _value === "number" ? String(_value) : _value;
|
|
@@ -674,7 +700,7 @@ const currency = {
|
|
|
674
700
|
currencySymbol = "",
|
|
675
701
|
useParensForNeg = false,
|
|
676
702
|
precision = 2
|
|
677
|
-
} = options
|
|
703
|
+
} = options ?? {};
|
|
678
704
|
if (value === void 0 || value === "") {
|
|
679
705
|
return value;
|
|
680
706
|
}
|
|
@@ -704,7 +730,6 @@ const currency = {
|
|
|
704
730
|
return currencySymbol + prettyString;
|
|
705
731
|
},
|
|
706
732
|
deformat: (value, options) => {
|
|
707
|
-
var _a;
|
|
708
733
|
if (typeof value === "number") {
|
|
709
734
|
return value;
|
|
710
735
|
}
|
|
@@ -712,45 +737,46 @@ const currency = {
|
|
|
712
737
|
return void 0;
|
|
713
738
|
}
|
|
714
739
|
let deformatted = value;
|
|
715
|
-
if (options
|
|
740
|
+
if (options?.currencySymbol) {
|
|
716
741
|
deformatted = value.replace(options.currencySymbol, "");
|
|
717
742
|
}
|
|
718
|
-
return
|
|
743
|
+
return commaNumber.deformat?.(deformatted);
|
|
719
744
|
}
|
|
720
745
|
};
|
|
721
|
-
|
|
722
|
-
|
|
723
|
-
|
|
724
|
-
|
|
725
|
-
|
|
726
|
-
|
|
727
|
-
|
|
728
|
-
|
|
729
|
-
|
|
730
|
-
}
|
|
731
|
-
});
|
|
732
|
-
|
|
733
|
-
var formats = /*#__PURE__*/Object.freeze({
|
|
734
|
-
__proto__: null,
|
|
735
|
-
integer: integer,
|
|
736
|
-
commaNumber: commaNumber,
|
|
737
|
-
date: date,
|
|
738
|
-
currency: currency,
|
|
739
|
-
phone: phone
|
|
740
|
-
});
|
|
746
|
+
var basePhoneFormatter = createMaskedNumericFormatter(
|
|
747
|
+
"phone",
|
|
748
|
+
"(###) ###-####"
|
|
749
|
+
);
|
|
750
|
+
var phone2 = {
|
|
751
|
+
...basePhoneFormatter,
|
|
752
|
+
deformat: (value) => basePhoneFormatter.deformat?.(value),
|
|
753
|
+
format: (value) => basePhoneFormatter.format?.(value === "(" ? "" : value) ?? value
|
|
754
|
+
};
|
|
741
755
|
|
|
742
|
-
|
|
756
|
+
// ../../../../../../../../../../../execroot/_main/bazel-out/k8-fastbuild/bin/plugins/common-types/core/src/index.ts
|
|
757
|
+
var CommonTypesPlugin = class {
|
|
743
758
|
constructor() {
|
|
744
759
|
this.name = "CommonTypes";
|
|
745
760
|
}
|
|
746
761
|
apply(player) {
|
|
747
|
-
player.registerPlugin(
|
|
748
|
-
|
|
749
|
-
|
|
750
|
-
|
|
751
|
-
|
|
762
|
+
player.registerPlugin(
|
|
763
|
+
new TypesProviderPlugin({
|
|
764
|
+
types: Object.values(types_exports),
|
|
765
|
+
formats: Object.values(formats_exports),
|
|
766
|
+
validators: Object.entries(validators_exports)
|
|
767
|
+
})
|
|
768
|
+
);
|
|
752
769
|
}
|
|
753
|
-
}
|
|
754
|
-
|
|
755
|
-
|
|
756
|
-
|
|
770
|
+
};
|
|
771
|
+
export {
|
|
772
|
+
CommonTypesPlugin,
|
|
773
|
+
PLACEHOLDER,
|
|
774
|
+
createMaskedNumericFormatter,
|
|
775
|
+
types_exports as dataTypes,
|
|
776
|
+
formatAsEnum,
|
|
777
|
+
formatAsMasked,
|
|
778
|
+
formats_exports as formats,
|
|
779
|
+
removeFormatCharactersFromMaskedString,
|
|
780
|
+
validators_exports as validators
|
|
781
|
+
};
|
|
782
|
+
//# sourceMappingURL=index.mjs.map
|