@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.
Files changed (36) hide show
  1. package/dist/CommonTypesPlugin.native.js +8292 -0
  2. package/dist/CommonTypesPlugin.native.js.map +1 -0
  3. package/dist/{index.cjs.js → cjs/index.cjs} +273 -233
  4. package/dist/cjs/index.cjs.map +1 -0
  5. package/dist/{index.esm.js → index.legacy-esm.js} +246 -220
  6. package/dist/index.mjs +782 -0
  7. package/dist/index.mjs.map +1 -0
  8. package/package.json +26 -58
  9. package/src/__tests__/index.test.ts +198 -0
  10. package/src/data-types/types.ts +27 -37
  11. package/src/formats/__tests__/formats.test.ts +264 -0
  12. package/src/formats/__tests__/utils.test.ts +44 -0
  13. package/src/formats/index.ts +71 -69
  14. package/src/formats/utils.ts +16 -16
  15. package/src/index.ts +12 -12
  16. package/src/validators/__tests__/index.test.ts +472 -0
  17. package/src/validators/index.ts +67 -68
  18. package/types/data-types/types.d.ts +10 -0
  19. package/types/formats/index.d.ts +24 -0
  20. package/types/formats/utils.d.ts +41 -0
  21. package/types/index.d.ts +27 -0
  22. package/types/validators/index.d.ts +68 -0
  23. package/dist/common-types-plugin.dev.js +0 -11388
  24. package/dist/common-types-plugin.prod.js +0 -2
  25. package/dist/index.d.ts +0 -260
  26. package/dist/xlr/BooleanType.json +0 -72
  27. package/dist/xlr/CollectionType.json +0 -39
  28. package/dist/xlr/DateType.json +0 -55
  29. package/dist/xlr/IntegerNNType.json +0 -75
  30. package/dist/xlr/IntegerPosType.json +0 -75
  31. package/dist/xlr/IntegerType.json +0 -55
  32. package/dist/xlr/PhoneType.json +0 -55
  33. package/dist/xlr/StringType.json +0 -62
  34. package/dist/xlr/manifest.js +0 -21
  35. package/dist/xlr/manifest.json +0 -26
  36. package/src/data-types/refs.ts +0 -33
@@ -1,9 +1,34 @@
1
- import { TypesProviderPlugin } from '@player-ui/types-provider-plugin';
2
- import { resolveDataRefs } from '@player-ui/player';
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
- const 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;
5
- const PHONE_REGEX = /^\+?[1]?[- ]?\(?\d{3}[)\- ]?\s?\d{3}[ -]?\d{4}$/;
6
- const ZIP_REGEX = /^\d{5}(-\d{4})?$/;
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
- const string = skipNullish((context, value) => {
40
+ var string = skipNullish((context, value) => {
16
41
  if (typeof value !== "string") {
17
- const message = context.constants.getConstants("validation.string", "constants", "Value must be a string");
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
- const readonly = (context) => {
27
- const message = context.constants.getConstants("validation.readonly", "constants", "Value cannot be modified");
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
- const collection = skipNullish((context, value) => {
63
+ var collection = skipNullish((context, value) => {
31
64
  if (!Array.isArray(value)) {
32
- const message = context.constants.getConstants("validation.collection", "constants", "Cannot set collection to non-array");
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
- const integer$1 = skipNullish((context, value) => {
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("validation.integer", "constants", "Value must be an integer");
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
- const oneOf = skipNullish((context, value, options) => {
49
- var _a;
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("validation.oneOf", "constants", "Invalid entry");
93
+ const message = context.constants.getConstants(
94
+ "validation.oneOf",
95
+ "constants",
96
+ "Invalid entry"
97
+ );
54
98
  return { message };
55
99
  });
56
- const expression = (context, value, options) => {
57
- if ((options == null ? void 0 : options.exp) === void 0) {
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("validation.expression", "constants", "Expression evaluation failed");
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
- const required = (context, value, options) => {
68
- if ((options == null ? void 0 : options.if) && !context.evaluate(options.if) || (options == null ? void 0 : options.ifNot) && context.evaluate(options.ifNot)) {
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("validation.required", "constants", "A value is required");
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
- const regex = skipNullish((context, value, options) => {
77
- if (value === void 0 || value === null || value === "" || typeof (options == null ? void 0 : options.regex) !== "string") {
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("validation.regex", "constants", "Invalid entry");
136
+ const message = context.constants.getConstants(
137
+ "validation.regex",
138
+ "constants",
139
+ "Invalid entry"
140
+ );
85
141
  return { message };
86
142
  }
87
143
  });
88
- const length = skipNullish((context, value, options) => {
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(`Unable to determine a length for value of type: ${value}`);
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("validation.length.minimum", "constants", `At least ${options.min} ${itemName} needed`);
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("validation.length.maximum", "constants", `Up to ${options.max} ${itemName} allowed`);
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
- const min = skipNullish((context, value, options) => {
136
- if (typeof value !== "number" || (options == null ? void 0 : options.value) === void 0) {
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("validation.min", "constants", `Must be at least ${options.value}`);
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
- const max = skipNullish((context, value, options) => {
145
- if (typeof value !== "number" || (options == null ? void 0 : options.value) === void 0) {
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("validation.max", "constants", `Cannot exceed ${options.value}`);
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
- const stringRegexValidator = (test, messagePath, invalidMessage) => {
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(messagePath, "constants", invalidMessage);
233
+ const message = context.constants.getConstants(
234
+ messagePath,
235
+ "constants",
236
+ invalidMessage
237
+ );
160
238
  return { message };
161
239
  }
162
240
  });
163
241
  };
164
- const email = stringRegexValidator(EMAIL_REGEX, "validation.email", "Improper email format");
165
- const phone$1 = stringRegexValidator(PHONE_REGEX, "validation.phone", "Invalid phone number");
166
- const zip = stringRegexValidator(ZIP_REGEX, "validation.regex", "Invalid zip code");
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
- var validators = /*#__PURE__*/Object.freeze({
169
- __proto__: null,
170
- string: string,
171
- readonly: readonly,
172
- collection: collection,
173
- integer: integer$1,
174
- oneOf: oneOf,
175
- expression: expression,
176
- required: required,
177
- regex: regex,
178
- length: length,
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
- const BooleanTypeRef = {
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
- const IntegerType = __spreadProps$1(__spreadValues$1({}, IntegerTypeRef), {
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
- const IntegerPosType = __spreadProps$1(__spreadValues$1({}, IntegerPosTypeRef), {
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
- const IntegerNNType = __spreadProps$1(__spreadValues$1({}, IntegerNNTypeRef), {
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
- const StringType = __spreadProps$1(__spreadValues$1({}, StringTypeRef), {
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
- const CollectionType = __spreadProps$1(__spreadValues$1({}, CollectionTypeRef), {
333
+ };
334
+ var CollectionType = {
335
+ type: "CollectionType",
302
336
  validation: [
303
337
  {
304
338
  type: "collection"
305
339
  }
306
340
  ]
307
- });
308
- const DateType = __spreadProps$1(__spreadValues$1({}, DateTypeRef), {
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
- const PhoneType = __spreadProps$1(__spreadValues$1({}, PhoneTypeRef), {
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
- var dataTypes = /*#__PURE__*/Object.freeze({
330
- __proto__: null,
331
- BooleanType: BooleanType,
332
- IntegerType: IntegerType,
333
- IntegerPosType: IntegerPosType,
334
- IntegerNNType: IntegerNNType,
335
- StringType: StringType,
336
- CollectionType: CollectionType,
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
- const PLACEHOLDER = "#";
342
- const removeFormatCharactersFromMaskedString = (value, mask, reserved = [PLACEHOLDER]) => {
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
- const formatAsEnum = (value, acceptedValues, options) => {
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 = (options == null ? void 0 : options.ignoreCase) ? validValue[charIndex].toLowerCase() : validValue[charIndex];
369
- const actualChar = (options == null ? void 0 : options.ignoreCase) ? value[charIndex].toLowerCase() : value[charIndex];
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 && (options == null ? void 0 : options.autocomplete)) {
422
+ if (autoCompletionsByOverlapCount.length === 1 && options?.autocomplete) {
388
423
  return autoCompletionsByOverlapCount[0].target;
389
424
  }
390
- return autoCompletionsByOverlapCount[0].target.substr(0, autoCompletionsByOverlapCount[0].count);
425
+ return autoCompletionsByOverlapCount[0].target.substr(
426
+ 0,
427
+ autoCompletionsByOverlapCount[0].count
428
+ );
391
429
  };
392
- const formatAsMasked = (value, valueCharMaskMatch, mask) => {
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
- const createMaskedNumericFormatter = (name, mask) => {
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 ((options == null ? void 0 : options.exceptions) && options.exceptions.length > 0) {
412
- const formattedUsingExceptions = formatAsEnum(value, options.exceptions, {
413
- autocomplete: true,
414
- ignoreCase: true
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 ((options == null ? void 0 : options.exceptions) && options.exceptions.length > 0) {
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
- var __defProp = Object.defineProperty;
441
- var __defProps = Object.defineProperties;
442
- var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
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 = (_b = (_a = integer.deformat) == null ? void 0 : _a.call(integer, value)) != null ? _b : value;
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
- const commaNumber = {
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 ((options == null ? void 0 : options.precision) !== void 0) {
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 || (options == null ? void 0 : options.precision) !== void 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
- const date = {
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 = (_b = (_a = options == null ? void 0 : options.mask) == null ? void 0 : _a.toUpperCase()) != null ? _b : "MM/DD/YYYY";
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
- const currency = {
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 != null ? 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 == null ? void 0 : options.currencySymbol) {
740
+ if (options?.currencySymbol) {
716
741
  deformatted = value.replace(options.currencySymbol, "");
717
742
  }
718
- return (_a = commaNumber.deformat) == null ? void 0 : _a.call(commaNumber, deformatted);
743
+ return commaNumber.deformat?.(deformatted);
719
744
  }
720
745
  };
721
- const basePhoneFormatter = createMaskedNumericFormatter("phone", "(###) ###-####");
722
- const phone = __spreadProps(__spreadValues({}, basePhoneFormatter), {
723
- deformat: (value) => {
724
- var _a;
725
- return (_a = basePhoneFormatter.deformat) == null ? void 0 : _a.call(basePhoneFormatter, value);
726
- },
727
- format: (value) => {
728
- var _a, _b;
729
- return (_b = (_a = basePhoneFormatter.format) == null ? void 0 : _a.call(basePhoneFormatter, value === "(" ? "" : value)) != null ? _b : value;
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
- class CommonTypesPlugin {
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(new TypesProviderPlugin({
748
- types: Object.values(dataTypes),
749
- formats: Object.values(formats),
750
- validators: Object.entries(validators)
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
- export { CommonTypesPlugin, PLACEHOLDER, createMaskedNumericFormatter, refs as dataRefs, dataTypes, formatAsEnum, formatAsMasked, formats, removeFormatCharactersFromMaskedString, validators };
756
- //# sourceMappingURL=index.esm.js.map
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