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