@nattyjs/entity 0.0.1-beta.0

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/README.md ADDED
@@ -0,0 +1,11 @@
1
+ # `entity`
2
+
3
+ > TODO: description
4
+
5
+ ## Usage
6
+
7
+ ```
8
+ const entity = require('entity');
9
+
10
+ // TODO: DEMONSTRATE API
11
+ ```
package/dist/index.cjs ADDED
@@ -0,0 +1,478 @@
1
+ 'use strict';
2
+
3
+ const core = require('@nattyjs/core');
4
+ const common = require('@nattyjs/common');
5
+
6
+ function model(config) {
7
+ return function(target, parameterIndex) {
8
+ core.registerDecorator({
9
+ decoratorParams: {
10
+ target,
11
+ propertyKey: void 0,
12
+ descriptor: parameterIndex
13
+ },
14
+ modelConfig: config
15
+ });
16
+ };
17
+ }
18
+
19
+ function prop(config) {
20
+ return function(target, propertyKey, parameterIndex) {
21
+ core.registerDecorator({
22
+ decoratorParams: {
23
+ target,
24
+ propertyKey,
25
+ descriptor: parameterIndex
26
+ },
27
+ propConfig: config
28
+ });
29
+ };
30
+ }
31
+
32
+ function columnName(name) {
33
+ return function(target, propertyKey, parameterIndex) {
34
+ core.registerDecorator({
35
+ decoratorParams: {
36
+ target,
37
+ propertyKey,
38
+ descriptor: parameterIndex
39
+ },
40
+ propConfig: {
41
+ db: {
42
+ name
43
+ }
44
+ }
45
+ });
46
+ };
47
+ }
48
+
49
+ function key() {
50
+ return function(target, propertyKey, parameterIndex) {
51
+ core.registerDecorator({
52
+ decoratorParams: {
53
+ target,
54
+ propertyKey,
55
+ descriptor: parameterIndex
56
+ },
57
+ propConfig: {
58
+ db: {
59
+ isPrimaryKey: true
60
+ }
61
+ }
62
+ });
63
+ };
64
+ }
65
+
66
+ function oneToMany(model, foreignKey) {
67
+ return function(target, propertyKey, parameterIndex) {
68
+ core.registerDecorator({
69
+ decoratorParams: {
70
+ target,
71
+ propertyKey,
72
+ descriptor: parameterIndex
73
+ },
74
+ propConfig: {
75
+ db: {
76
+ oneToMany: { model, foreignKey }
77
+ }
78
+ }
79
+ });
80
+ };
81
+ }
82
+
83
+ function oneToOne(model, foreignKey) {
84
+ return function(target, propertyKey, parameterIndex) {
85
+ core.registerDecorator({
86
+ decoratorParams: {
87
+ target,
88
+ propertyKey,
89
+ descriptor: parameterIndex
90
+ },
91
+ propConfig: {
92
+ db: {
93
+ oneToOne: { model, foreignKey }
94
+ }
95
+ }
96
+ });
97
+ };
98
+ }
99
+
100
+ const ValidatorNames = {
101
+ required: "required",
102
+ allOf: "allOf",
103
+ alpha: "alpha",
104
+ alphaNumeric: "alphaNumeric",
105
+ ascii: "ascii",
106
+ contains: "contains",
107
+ creditCard: "creditCard",
108
+ cusip: "cusip",
109
+ dataUri: "dataUri",
110
+ date: "date",
111
+ different: "different",
112
+ digit: "digit",
113
+ email: "email",
114
+ endsWith: "endsWith",
115
+ even: "even",
116
+ extension: "extension",
117
+ factor: "factor",
118
+ file: "file",
119
+ fileSize: "fileSize",
120
+ greaterThan: "greaterThan",
121
+ greaterThanEqualTo: "greaterThanEqualTo",
122
+ grid: "grid",
123
+ hexColor: "hexColor",
124
+ iban: "iban",
125
+ ip: "ip",
126
+ json: "json",
127
+ latitude: "latitude",
128
+ latLong: "latLong",
129
+ leapYear: "leapYear",
130
+ lessThanEqualTo: "lessThanEqualTo",
131
+ lessThan: "lessThan",
132
+ longitude: "longitude",
133
+ lowercase: "lowercase",
134
+ mac: "mac",
135
+ mask: "mask",
136
+ maxDate: "maxDate",
137
+ maxLength: "maxLength",
138
+ maxNumber: "maxNumber",
139
+ maxTime: "maxTime",
140
+ minDate: "minDate",
141
+ minLength: "minLength",
142
+ minNumber: "minNumber",
143
+ minTime: "minTime",
144
+ noneOf: "noneOf",
145
+ notEmpty: "notEmpty",
146
+ numeric: "numeric",
147
+ odd: "odd",
148
+ oneOf: "oneOf",
149
+ password: "password",
150
+ pattern: "pattern",
151
+ port: "port",
152
+ primeNumber: "primeNumber",
153
+ range: "range",
154
+ requiredTrue: "requiredTrue",
155
+ startsWith: "startsWith",
156
+ time: "time",
157
+ uppercase: "uppercase",
158
+ url: "url"
159
+ };
160
+
161
+ class ValidationMessage {
162
+ static getValidatorErrorMessage(name) {
163
+ const message = common.commonContainer.nattyConfig.modelBinding?.errorMessage?.validator[name];
164
+ return message;
165
+ }
166
+ static toJson(key, config, values) {
167
+ let message = config ? config.message : null;
168
+ if (!message && config && config.messageKey)
169
+ config.messageKey;
170
+ let messageText = message ? message : config.messagekey ? ValidationMessage.getValidatorErrorMessage(config.messageKey) : ValidationMessage.getValidatorErrorMessage(key);
171
+ messageText = messageText || common.BLANK;
172
+ values.forEach((t, index) => {
173
+ messageText = messageText.replace(`{{${index}}}`, t);
174
+ });
175
+ let jObject = {};
176
+ jObject[key] = {
177
+ message: messageText,
178
+ refValues: values
179
+ };
180
+ return jObject;
181
+ }
182
+ static null() {
183
+ return null;
184
+ }
185
+ }
186
+
187
+ function getConfigObject(config) {
188
+ return config || {};
189
+ }
190
+
191
+ const RegExRule = {
192
+ alpha: /^[a-zA-Z]+$/,
193
+ alphaExits: /[a-zA-Z]/,
194
+ alphaWithSpace: /^[a-zA-Z\s]+$/,
195
+ macId: /^([0-9a-fA-F][0-9a-fA-F]:){5}([0-9a-fA-F][0-9a-fA-F])$/,
196
+ onlyDigit: /^[0-9]+$/,
197
+ isDigitExits: /[0-9]/,
198
+ lowerCase: /[a-z]/,
199
+ upperCase: /[A-Z]/,
200
+ specialCharacter: /[!@#$%^&*(),.?":{}|<>]/,
201
+ advancedEmail: /^[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+@[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)*$/,
202
+ basicEmail: /^(([^<>()\[\]\\.,,:\s@"]+(\.[^<>()\[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/,
203
+ alphaNumeric: /^[0-9a-zA-Z]+$/,
204
+ alphaNumericWithSpace: /^[0-9a-zA-Z\s]+$/,
205
+ hexColor: /^#?([0-9A-F]{3}|[0-9A-F]{6})$/i,
206
+ strictHexColor: /^#?([0-9A-F]{3}|[0-9A-F]{6})$/i,
207
+ float: /^(?:[-+]?(?:[0-9]+))?(?:\.[0-9]*)?(?:[eE][\+\-]?(?:[0-9]+))?$/,
208
+ decimal: /^[-+]?([0-9]+|\.[0-9]+|[0-9]+\.[0-9]+)$/,
209
+ hexaDecimal: /^[0-9A-F]+$/i,
210
+ date: /^(?:(?:31(\/|-|\.)(?:0?[13578]|1[02]))\1|(?:(?:29|30)(\/|-|\.)(?:0?[1,3-9]|1[0-2])\2))(?:(?:1[6-9]|[2-9]\d)?\d{2})$|^(?:29(\/|-|\.)0?2\3(?:(?:(?:1[6-9]|[2-9]\d)?(?:0[48]|[2468][048]|[13579][26])|(?:(?:16|[2468][048]|[3579][26])00))))$|^(?:0?[1-9]|1\d|2[0-8])(\/|-|\.)(?:(?:0?[1-9])|(?:1[0-2]))\4(?:(?:1[6-9]|[2-9]\d)?\d{2})$/,
211
+ time: /^([01]?[0-9]|2[0-3]):[0-5][0-9]$/,
212
+ timeWithSeconds: /^([01]?[0-9]|2[0-3]):[0-5][0-9]:[0-5][0-9]$/,
213
+ url: /^(https?:\/\/(?:www\.|(?!www))[a-zA-Z0-9][a-zA-Z0-9-]+[a-zA-Z0-9]\.[^\s]{2,}|www\.[a-zA-Z0-9][a-zA-Z0-9-]+[a-zA-Z0-9]\.[^\s]{2,}|https?:\/\/(?:www\.|(?!www))[a-zA-Z0-9]\.[^\s]{2,}|www\.[a-zA-Z0-9]\.[^\s]{2,})$/,
214
+ ascii: /^[\x00-\x7F]+$/,
215
+ dataUri: /^data:([a-z]+\/[a-z0-9-+.]+(;[a-z0-9-.!#$%*+.{}|~`]+=[a-z0-9-.!#$%*+.{}|~`]+)*)?(;base64)?,([a-z0-9!$&',()*+;=\-._~:@\/?%\s]*?)$/i,
216
+ lat: /^\(?[+-]?(90(\.0+)?|[1-8]?\d(\.\d+)?)$/,
217
+ long: /^\s?[+-]?(180(\.0+)?|1[0-7]\d(\.\d+)?|\d{1,2}(\.\d+)?)\)?$/,
218
+ ipV4: /^(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})$/,
219
+ ipV6: /^((?:[a-fA-F\d]{1,4}:){7}(?:[a-fA-F\d]{1,4}|:)|(?:[a-fA-F\d]{1,4}:){6}(?:(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]\d|\d)(?:\.(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]\d|\d)){3}|:[a-fA-F\d]{1,4}|:)|(?:[a-fA-F\d]{1,4}:){5}(?::(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]\d|\d)(?:\.(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]\d|\d)){3}|(:[a-fA-F\d]{1,4}){1,2}|:)|(?:[a-fA-F\d]{1,4}:){4}(?:(:[a-fA-F\d]{1,4}){0,1}:(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]\d|\d)(?:\.(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]\d|\d)){3}|(:[a-fA-F\d]{1,4}){1,3}|:)|(?:[a-fA-F\d]{1,4}:){3}(?:(:[a-fA-F\d]{1,4}){0,2}:(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]\d|\d)(?:\.(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]\d|\d)){3}|(:[a-fA-F\d]{1,4}){1,4}|:)|(?:[a-fA-F\d]{1,4}:){2}(?:(:[a-fA-F\d]{1,4}){0,3}:(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]\d|\d)(?:\.(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]\d|\d)){3}|(:[a-fA-F\d]{1,4}){1,5}|:)|(?:[a-fA-F\d]{1,4}:){1}(?:(:[a-fA-F\d]{1,4}){0,4}:(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]\d|\d)(?:\.(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]\d|\d)){3}|(:[a-fA-F\d]{1,4}){1,6}|:)|(?::((?::[a-fA-F\d]{1,4}){0,5}:(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]\d|\d)(?:\.(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]\d|\d)){3}|(?::[a-fA-F\d]{1,4}){1,7}|:)))(%[0-9a-zA-Z]{1,})?$/,
220
+ cidrV4: /^(3[0-2]|[12]?[0-9])$/,
221
+ cidrV6: /^(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/,
222
+ cusip: /^[0-9A-Z]{9}$/,
223
+ grid: /^[GRID:]*([0-9A-Z]{2})[-\s]*([0-9A-Z]{5})[-\s]*([0-9A-Z]{10})[-\s]*([0-9A-Z]{1})$/g
224
+ };
225
+
226
+ const ALPHABET = "alphabet";
227
+ const DIGIT = "digit";
228
+ const CONTAINS = "contains";
229
+ const LOWERCASE = "lowerCase";
230
+ const UPPERCASE = "upperCase";
231
+ const SPECIAL_CHARACTER = "specialCharacter";
232
+ const MIN_LENGTH = "minLength";
233
+ const MAX_LENGTH = "maxLength";
234
+ class RegexValidator {
235
+ static isExits(value, regex) {
236
+ return value.match(regex) != null;
237
+ }
238
+ static isValid(value, regex) {
239
+ return regex.test(value);
240
+ }
241
+ static isNotBlank(value, isRemoveSpace = false) {
242
+ return !isRemoveSpace ? value === 0 || value !== void 0 && value !== null && value !== "" : value === 0 || value !== void 0 && value !== null && String(value).trim() !== "";
243
+ }
244
+ static isValidPassword(passwordValidation, value) {
245
+ let isValid = false;
246
+ let keyName = "status";
247
+ let objectProperties = Object.getOwnPropertyNames(passwordValidation);
248
+ for (let propertyName of objectProperties) {
249
+ switch (propertyName) {
250
+ case ALPHABET:
251
+ isValid = RegexValidator.isExits(value, RegExRule.alphaExits);
252
+ keyName = ALPHABET;
253
+ break;
254
+ case DIGIT:
255
+ isValid = RegexValidator.isValid(value, RegExRule.isDigitExits);
256
+ keyName = DIGIT;
257
+ break;
258
+ case CONTAINS:
259
+ isValid = value.indexOf(passwordValidation[CONTAINS]) != -1;
260
+ keyName = CONTAINS;
261
+ break;
262
+ case LOWERCASE:
263
+ isValid = RegexValidator.isValid(value, RegExRule.lowerCase);
264
+ keyName = LOWERCASE;
265
+ break;
266
+ case UPPERCASE:
267
+ isValid = RegexValidator.isValid(value, RegExRule.upperCase);
268
+ keyName = UPPERCASE;
269
+ break;
270
+ case SPECIAL_CHARACTER:
271
+ isValid = RegexValidator.isExits(value, RegExRule.specialCharacter);
272
+ keyName = SPECIAL_CHARACTER;
273
+ break;
274
+ case MIN_LENGTH:
275
+ isValid = value.length >= passwordValidation[propertyName];
276
+ keyName = MIN_LENGTH;
277
+ break;
278
+ case MAX_LENGTH:
279
+ isValid = value.length <= passwordValidation[propertyName];
280
+ keyName = MAX_LENGTH;
281
+ break;
282
+ }
283
+ if (!isValid)
284
+ break;
285
+ }
286
+ return { isValid, keyName };
287
+ }
288
+ static isZero(value) {
289
+ return value == 0;
290
+ }
291
+ static commaRegex() {
292
+ return new RegExp(",", "g");
293
+ }
294
+ }
295
+
296
+ class Linq {
297
+ static execute(config, params) {
298
+ if (config.conditionalExpression) {
299
+ return config.conditionalExpression.bind(params.current).call(params.current, params.current, params.root);
300
+ }
301
+ return true;
302
+ }
303
+ }
304
+
305
+ class ValidatorValueChecker {
306
+ static pass(params, config) {
307
+ if (Linq.execute(config, params))
308
+ return RegexValidator.isNotBlank(params.value);
309
+ else
310
+ return false;
311
+ }
312
+ static passArrayValue(params, config) {
313
+ if (Linq.execute(config, params))
314
+ return params.value instanceof Array;
315
+ else
316
+ return false;
317
+ }
318
+ }
319
+
320
+ class Utils {
321
+ static isNotBlank(value, isRemoveSpace = false) {
322
+ return !isRemoveSpace ? value === 0 || value !== void 0 && value !== null && value !== "" : value === 0 || value !== void 0 && value !== null && String(value).trim() !== "";
323
+ }
324
+ }
325
+
326
+ function requiredValidator(config, params) {
327
+ if (Linq.execute(config, params)) {
328
+ if (!Utils.isNotBlank(params.value))
329
+ return ValidationMessage.toJson(ValidatorNames.required, config, []);
330
+ }
331
+ return ValidationMessage.null();
332
+ }
333
+
334
+ var NumericValueType = /* @__PURE__ */ ((NumericValueType2) => {
335
+ NumericValueType2[NumericValueType2["PositiveNumber"] = 1] = "PositiveNumber";
336
+ NumericValueType2[NumericValueType2["NegativeNumber"] = 2] = "NegativeNumber";
337
+ NumericValueType2[NumericValueType2["Both"] = 3] = "Both";
338
+ return NumericValueType2;
339
+ })(NumericValueType || {});
340
+
341
+ class ApplicationUtil {
342
+ static toLower(value) {
343
+ if (value)
344
+ return String(value).toLowerCase().trim();
345
+ return value;
346
+ }
347
+ static isNumeric(value) {
348
+ return value - parseFloat(value) + 1 >= 0;
349
+ }
350
+ static notEqualTo(primaryValue, secondaryValue) {
351
+ let firstValue = primaryValue === void 0 || primaryValue === null ? "" : primaryValue;
352
+ let secondValue = secondaryValue === void 0 || secondaryValue === null ? "" : secondaryValue;
353
+ if (firstValue instanceof Date && secondValue instanceof Date)
354
+ return +firstValue != +secondValue;
355
+ return firstValue != secondValue;
356
+ }
357
+ static numericValidation(allowDecimal, acceptValue) {
358
+ acceptValue = acceptValue == void 0 ? NumericValueType.PositiveNumber : acceptValue;
359
+ let regex = /^[0-9]+$/;
360
+ switch (acceptValue) {
361
+ case NumericValueType.PositiveNumber:
362
+ regex = !allowDecimal ? /^[0-9]+$/ : /^[0-9\.]+$/ ;
363
+ break;
364
+ case NumericValueType.NegativeNumber:
365
+ regex = !allowDecimal ? /^[-][0-9]+$/ : /^[-][0-9\.]+$/ ;
366
+ break;
367
+ case NumericValueType.Both:
368
+ regex = !allowDecimal ? /^[-|+]?[0-9]+$/ : /^[-|+]?[0-9\.]+$/ ;
369
+ break;
370
+ }
371
+ return regex;
372
+ }
373
+ static lowerCaseWithTrim(value) {
374
+ return typeof value === "string" ? value.toLowerCase().trim() : String(value).toLowerCase().trim();
375
+ }
376
+ /** Check if a value is an object */
377
+ static isObject(value) {
378
+ return Object.prototype.toString.call(value) === "[object Object]";
379
+ }
380
+ /** Check if a value is an object */
381
+ static isArray(value) {
382
+ return Array.isArray(value);
383
+ }
384
+ static cloneValue(value) {
385
+ return ApplicationUtil.isObject(value) ? ApplicationUtil.isArray(value) ? [...value] : { ...value } : value;
386
+ }
387
+ }
388
+
389
+ function numericValidator(configModel, control) {
390
+ let config = getConfigObject(configModel);
391
+ if (ValidatorValueChecker.pass(control, config)) {
392
+ if (!RegexValidator.isValid(control.value, ApplicationUtil.numericValidation(config.allowDecimal, config.acceptValue)))
393
+ return ValidationMessage.toJson(ValidatorNames.numeric, config, [control.value]);
394
+ }
395
+ return ValidationMessage.null();
396
+ }
397
+
398
+ function allOfValidator(configModel, params) {
399
+ let config = getConfigObject(configModel);
400
+ if (ValidatorValueChecker.passArrayValue(params, configModel)) {
401
+ var testResult = false;
402
+ for (let value of config.matchValues) {
403
+ testResult = params.value.some((y) => y == value);
404
+ if (!testResult)
405
+ break;
406
+ }
407
+ if (!testResult)
408
+ return ValidationMessage.toJson(ValidatorNames.allOf, config, [params.value]);
409
+ }
410
+ return ValidationMessage.null();
411
+ }
412
+
413
+ function baseDecoratorFunction(validatorName, config, validator) {
414
+ return function(target, propertyKey, parameterIndex) {
415
+ core.registerDecorator({
416
+ decoratorParams: {
417
+ target,
418
+ propertyKey,
419
+ descriptor: parameterIndex
420
+ },
421
+ validatorConfig: {
422
+ name: validatorName,
423
+ config,
424
+ validator
425
+ }
426
+ });
427
+ };
428
+ }
429
+
430
+ function allOf(config) {
431
+ return baseDecoratorFunction(ValidatorNames.allOf, config || {}, allOfValidator);
432
+ }
433
+
434
+ function required(config) {
435
+ return baseDecoratorFunction(ValidatorNames.required, config || {}, requiredValidator);
436
+ }
437
+
438
+ function numeric(config) {
439
+ return baseDecoratorFunction(ValidatorNames.numeric, config || {}, numericValidator);
440
+ }
441
+
442
+ function getProperties(type) {
443
+ if (type) {
444
+ const props = core.entityContainer.getProperties(type.name);
445
+ const jProps = {};
446
+ if (props)
447
+ props.forEach((property) => jProps[property.name.toLowerCase()] = property.name);
448
+ return jProps;
449
+ }
450
+ return;
451
+ }
452
+ function jsonStringToList(model) {
453
+ return function(target, propertyKey) {
454
+ let value;
455
+ const getter = function() {
456
+ return new common.List(JSON.parse(value), model, getProperties(model));
457
+ };
458
+ const setter = function(newVal) {
459
+ value = newVal;
460
+ };
461
+ Object.defineProperty(target, propertyKey, {
462
+ get: getter,
463
+ set: setter
464
+ });
465
+ };
466
+ }
467
+
468
+ exports.NumericValueType = NumericValueType;
469
+ exports.allOf = allOf;
470
+ exports.columnName = columnName;
471
+ exports.jsonStringToList = jsonStringToList;
472
+ exports.key = key;
473
+ exports.model = model;
474
+ exports.numeric = numeric;
475
+ exports.oneToMany = oneToMany;
476
+ exports.oneToOne = oneToOne;
477
+ exports.prop = prop;
478
+ exports.required = required;
@@ -0,0 +1,72 @@
1
+ import { ClassType } from '@nattyjs/common';
2
+
3
+ interface ModelConfig {
4
+ tableName?: string;
5
+ }
6
+
7
+ interface DbFieldConfig {
8
+ name?: string;
9
+ type?: number;
10
+ defaultValue?: any;
11
+ isPrimaryKey?: boolean;
12
+ foreignKey?: any;
13
+ oneToMany?: FieldRelationConfig;
14
+ oneToOne?: FieldRelationConfig;
15
+ }
16
+ interface FieldRelationConfig {
17
+ model: any;
18
+ foreignKey: string;
19
+ }
20
+
21
+ interface PropConfig {
22
+ db?: DbFieldConfig;
23
+ }
24
+
25
+ declare function model(config: ModelConfig): (target: any, parameterIndex?: any) => void;
26
+
27
+ declare function prop(config?: PropConfig): (target: any, propertyKey: string, parameterIndex?: any) => void;
28
+
29
+ declare function columnName(name: string): (target: any, propertyKey: string, parameterIndex?: any) => void;
30
+
31
+ declare function key(): (target: any, propertyKey: string, parameterIndex?: any) => void;
32
+
33
+ declare function oneToMany<T>(model: ClassType<T>, foreignKey: string): (target: any, propertyKey: string, parameterIndex?: any) => void;
34
+
35
+ declare function oneToOne<T>(model: ClassType<T>, foreignKey: string): (target: any, propertyKey: string, parameterIndex?: any) => void;
36
+
37
+ interface BaseValidatorConfig {
38
+ message?: string;
39
+ conditionalExpression?: Function;
40
+ messageKey?: string;
41
+ }
42
+
43
+ interface ArrayConfig extends BaseValidatorConfig {
44
+ matchValues?: any[];
45
+ }
46
+
47
+ declare function allOf(config?: ArrayConfig): (target: any, propertyKey: string, parameterIndex?: any) => void;
48
+
49
+ interface RequiredConfig extends BaseValidatorConfig {
50
+ }
51
+
52
+ declare function required(config?: RequiredConfig): (target: any, propertyKey: string, parameterIndex?: any) => void;
53
+
54
+ declare enum NumericValueType {
55
+ PositiveNumber = 1,
56
+ NegativeNumber = 2,
57
+ Both = 3
58
+ }
59
+
60
+ interface NumericConfig extends BaseValidatorConfig {
61
+ allowDecimal?: boolean;
62
+ acceptValue?: NumericValueType;
63
+ isFormat?: boolean;
64
+ digitsInfo?: string;
65
+ persistZero?: boolean;
66
+ }
67
+
68
+ declare function numeric(config?: NumericConfig): (target: any, propertyKey: string, parameterIndex?: any) => void;
69
+
70
+ declare function jsonStringToList<T>(model: ClassType<T>): (target: Object, propertyKey: string) => void;
71
+
72
+ export { NumericValueType, allOf, columnName, jsonStringToList, key, model, numeric, oneToMany, oneToOne, prop, required };
package/dist/index.mjs ADDED
@@ -0,0 +1,466 @@
1
+ import { registerDecorator, entityContainer } from '@nattyjs/core';
2
+ import { commonContainer, BLANK, List } from '@nattyjs/common';
3
+
4
+ function model(config) {
5
+ return function(target, parameterIndex) {
6
+ registerDecorator({
7
+ decoratorParams: {
8
+ target,
9
+ propertyKey: void 0,
10
+ descriptor: parameterIndex
11
+ },
12
+ modelConfig: config
13
+ });
14
+ };
15
+ }
16
+
17
+ function prop(config) {
18
+ return function(target, propertyKey, parameterIndex) {
19
+ registerDecorator({
20
+ decoratorParams: {
21
+ target,
22
+ propertyKey,
23
+ descriptor: parameterIndex
24
+ },
25
+ propConfig: config
26
+ });
27
+ };
28
+ }
29
+
30
+ function columnName(name) {
31
+ return function(target, propertyKey, parameterIndex) {
32
+ registerDecorator({
33
+ decoratorParams: {
34
+ target,
35
+ propertyKey,
36
+ descriptor: parameterIndex
37
+ },
38
+ propConfig: {
39
+ db: {
40
+ name
41
+ }
42
+ }
43
+ });
44
+ };
45
+ }
46
+
47
+ function key() {
48
+ return function(target, propertyKey, parameterIndex) {
49
+ registerDecorator({
50
+ decoratorParams: {
51
+ target,
52
+ propertyKey,
53
+ descriptor: parameterIndex
54
+ },
55
+ propConfig: {
56
+ db: {
57
+ isPrimaryKey: true
58
+ }
59
+ }
60
+ });
61
+ };
62
+ }
63
+
64
+ function oneToMany(model, foreignKey) {
65
+ return function(target, propertyKey, parameterIndex) {
66
+ registerDecorator({
67
+ decoratorParams: {
68
+ target,
69
+ propertyKey,
70
+ descriptor: parameterIndex
71
+ },
72
+ propConfig: {
73
+ db: {
74
+ oneToMany: { model, foreignKey }
75
+ }
76
+ }
77
+ });
78
+ };
79
+ }
80
+
81
+ function oneToOne(model, foreignKey) {
82
+ return function(target, propertyKey, parameterIndex) {
83
+ registerDecorator({
84
+ decoratorParams: {
85
+ target,
86
+ propertyKey,
87
+ descriptor: parameterIndex
88
+ },
89
+ propConfig: {
90
+ db: {
91
+ oneToOne: { model, foreignKey }
92
+ }
93
+ }
94
+ });
95
+ };
96
+ }
97
+
98
+ const ValidatorNames = {
99
+ required: "required",
100
+ allOf: "allOf",
101
+ alpha: "alpha",
102
+ alphaNumeric: "alphaNumeric",
103
+ ascii: "ascii",
104
+ contains: "contains",
105
+ creditCard: "creditCard",
106
+ cusip: "cusip",
107
+ dataUri: "dataUri",
108
+ date: "date",
109
+ different: "different",
110
+ digit: "digit",
111
+ email: "email",
112
+ endsWith: "endsWith",
113
+ even: "even",
114
+ extension: "extension",
115
+ factor: "factor",
116
+ file: "file",
117
+ fileSize: "fileSize",
118
+ greaterThan: "greaterThan",
119
+ greaterThanEqualTo: "greaterThanEqualTo",
120
+ grid: "grid",
121
+ hexColor: "hexColor",
122
+ iban: "iban",
123
+ ip: "ip",
124
+ json: "json",
125
+ latitude: "latitude",
126
+ latLong: "latLong",
127
+ leapYear: "leapYear",
128
+ lessThanEqualTo: "lessThanEqualTo",
129
+ lessThan: "lessThan",
130
+ longitude: "longitude",
131
+ lowercase: "lowercase",
132
+ mac: "mac",
133
+ mask: "mask",
134
+ maxDate: "maxDate",
135
+ maxLength: "maxLength",
136
+ maxNumber: "maxNumber",
137
+ maxTime: "maxTime",
138
+ minDate: "minDate",
139
+ minLength: "minLength",
140
+ minNumber: "minNumber",
141
+ minTime: "minTime",
142
+ noneOf: "noneOf",
143
+ notEmpty: "notEmpty",
144
+ numeric: "numeric",
145
+ odd: "odd",
146
+ oneOf: "oneOf",
147
+ password: "password",
148
+ pattern: "pattern",
149
+ port: "port",
150
+ primeNumber: "primeNumber",
151
+ range: "range",
152
+ requiredTrue: "requiredTrue",
153
+ startsWith: "startsWith",
154
+ time: "time",
155
+ uppercase: "uppercase",
156
+ url: "url"
157
+ };
158
+
159
+ class ValidationMessage {
160
+ static getValidatorErrorMessage(name) {
161
+ const message = commonContainer.nattyConfig.modelBinding?.errorMessage?.validator[name];
162
+ return message;
163
+ }
164
+ static toJson(key, config, values) {
165
+ let message = config ? config.message : null;
166
+ if (!message && config && config.messageKey)
167
+ config.messageKey;
168
+ let messageText = message ? message : config.messagekey ? ValidationMessage.getValidatorErrorMessage(config.messageKey) : ValidationMessage.getValidatorErrorMessage(key);
169
+ messageText = messageText || BLANK;
170
+ values.forEach((t, index) => {
171
+ messageText = messageText.replace(`{{${index}}}`, t);
172
+ });
173
+ let jObject = {};
174
+ jObject[key] = {
175
+ message: messageText,
176
+ refValues: values
177
+ };
178
+ return jObject;
179
+ }
180
+ static null() {
181
+ return null;
182
+ }
183
+ }
184
+
185
+ function getConfigObject(config) {
186
+ return config || {};
187
+ }
188
+
189
+ const RegExRule = {
190
+ alpha: /^[a-zA-Z]+$/,
191
+ alphaExits: /[a-zA-Z]/,
192
+ alphaWithSpace: /^[a-zA-Z\s]+$/,
193
+ macId: /^([0-9a-fA-F][0-9a-fA-F]:){5}([0-9a-fA-F][0-9a-fA-F])$/,
194
+ onlyDigit: /^[0-9]+$/,
195
+ isDigitExits: /[0-9]/,
196
+ lowerCase: /[a-z]/,
197
+ upperCase: /[A-Z]/,
198
+ specialCharacter: /[!@#$%^&*(),.?":{}|<>]/,
199
+ advancedEmail: /^[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+@[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)*$/,
200
+ basicEmail: /^(([^<>()\[\]\\.,,:\s@"]+(\.[^<>()\[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/,
201
+ alphaNumeric: /^[0-9a-zA-Z]+$/,
202
+ alphaNumericWithSpace: /^[0-9a-zA-Z\s]+$/,
203
+ hexColor: /^#?([0-9A-F]{3}|[0-9A-F]{6})$/i,
204
+ strictHexColor: /^#?([0-9A-F]{3}|[0-9A-F]{6})$/i,
205
+ float: /^(?:[-+]?(?:[0-9]+))?(?:\.[0-9]*)?(?:[eE][\+\-]?(?:[0-9]+))?$/,
206
+ decimal: /^[-+]?([0-9]+|\.[0-9]+|[0-9]+\.[0-9]+)$/,
207
+ hexaDecimal: /^[0-9A-F]+$/i,
208
+ date: /^(?:(?:31(\/|-|\.)(?:0?[13578]|1[02]))\1|(?:(?:29|30)(\/|-|\.)(?:0?[1,3-9]|1[0-2])\2))(?:(?:1[6-9]|[2-9]\d)?\d{2})$|^(?:29(\/|-|\.)0?2\3(?:(?:(?:1[6-9]|[2-9]\d)?(?:0[48]|[2468][048]|[13579][26])|(?:(?:16|[2468][048]|[3579][26])00))))$|^(?:0?[1-9]|1\d|2[0-8])(\/|-|\.)(?:(?:0?[1-9])|(?:1[0-2]))\4(?:(?:1[6-9]|[2-9]\d)?\d{2})$/,
209
+ time: /^([01]?[0-9]|2[0-3]):[0-5][0-9]$/,
210
+ timeWithSeconds: /^([01]?[0-9]|2[0-3]):[0-5][0-9]:[0-5][0-9]$/,
211
+ url: /^(https?:\/\/(?:www\.|(?!www))[a-zA-Z0-9][a-zA-Z0-9-]+[a-zA-Z0-9]\.[^\s]{2,}|www\.[a-zA-Z0-9][a-zA-Z0-9-]+[a-zA-Z0-9]\.[^\s]{2,}|https?:\/\/(?:www\.|(?!www))[a-zA-Z0-9]\.[^\s]{2,}|www\.[a-zA-Z0-9]\.[^\s]{2,})$/,
212
+ ascii: /^[\x00-\x7F]+$/,
213
+ dataUri: /^data:([a-z]+\/[a-z0-9-+.]+(;[a-z0-9-.!#$%*+.{}|~`]+=[a-z0-9-.!#$%*+.{}|~`]+)*)?(;base64)?,([a-z0-9!$&',()*+;=\-._~:@\/?%\s]*?)$/i,
214
+ lat: /^\(?[+-]?(90(\.0+)?|[1-8]?\d(\.\d+)?)$/,
215
+ long: /^\s?[+-]?(180(\.0+)?|1[0-7]\d(\.\d+)?|\d{1,2}(\.\d+)?)\)?$/,
216
+ ipV4: /^(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})$/,
217
+ ipV6: /^((?:[a-fA-F\d]{1,4}:){7}(?:[a-fA-F\d]{1,4}|:)|(?:[a-fA-F\d]{1,4}:){6}(?:(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]\d|\d)(?:\.(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]\d|\d)){3}|:[a-fA-F\d]{1,4}|:)|(?:[a-fA-F\d]{1,4}:){5}(?::(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]\d|\d)(?:\.(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]\d|\d)){3}|(:[a-fA-F\d]{1,4}){1,2}|:)|(?:[a-fA-F\d]{1,4}:){4}(?:(:[a-fA-F\d]{1,4}){0,1}:(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]\d|\d)(?:\.(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]\d|\d)){3}|(:[a-fA-F\d]{1,4}){1,3}|:)|(?:[a-fA-F\d]{1,4}:){3}(?:(:[a-fA-F\d]{1,4}){0,2}:(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]\d|\d)(?:\.(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]\d|\d)){3}|(:[a-fA-F\d]{1,4}){1,4}|:)|(?:[a-fA-F\d]{1,4}:){2}(?:(:[a-fA-F\d]{1,4}){0,3}:(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]\d|\d)(?:\.(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]\d|\d)){3}|(:[a-fA-F\d]{1,4}){1,5}|:)|(?:[a-fA-F\d]{1,4}:){1}(?:(:[a-fA-F\d]{1,4}){0,4}:(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]\d|\d)(?:\.(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]\d|\d)){3}|(:[a-fA-F\d]{1,4}){1,6}|:)|(?::((?::[a-fA-F\d]{1,4}){0,5}:(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]\d|\d)(?:\.(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]\d|\d)){3}|(?::[a-fA-F\d]{1,4}){1,7}|:)))(%[0-9a-zA-Z]{1,})?$/,
218
+ cidrV4: /^(3[0-2]|[12]?[0-9])$/,
219
+ cidrV6: /^(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/,
220
+ cusip: /^[0-9A-Z]{9}$/,
221
+ grid: /^[GRID:]*([0-9A-Z]{2})[-\s]*([0-9A-Z]{5})[-\s]*([0-9A-Z]{10})[-\s]*([0-9A-Z]{1})$/g
222
+ };
223
+
224
+ const ALPHABET = "alphabet";
225
+ const DIGIT = "digit";
226
+ const CONTAINS = "contains";
227
+ const LOWERCASE = "lowerCase";
228
+ const UPPERCASE = "upperCase";
229
+ const SPECIAL_CHARACTER = "specialCharacter";
230
+ const MIN_LENGTH = "minLength";
231
+ const MAX_LENGTH = "maxLength";
232
+ class RegexValidator {
233
+ static isExits(value, regex) {
234
+ return value.match(regex) != null;
235
+ }
236
+ static isValid(value, regex) {
237
+ return regex.test(value);
238
+ }
239
+ static isNotBlank(value, isRemoveSpace = false) {
240
+ return !isRemoveSpace ? value === 0 || value !== void 0 && value !== null && value !== "" : value === 0 || value !== void 0 && value !== null && String(value).trim() !== "";
241
+ }
242
+ static isValidPassword(passwordValidation, value) {
243
+ let isValid = false;
244
+ let keyName = "status";
245
+ let objectProperties = Object.getOwnPropertyNames(passwordValidation);
246
+ for (let propertyName of objectProperties) {
247
+ switch (propertyName) {
248
+ case ALPHABET:
249
+ isValid = RegexValidator.isExits(value, RegExRule.alphaExits);
250
+ keyName = ALPHABET;
251
+ break;
252
+ case DIGIT:
253
+ isValid = RegexValidator.isValid(value, RegExRule.isDigitExits);
254
+ keyName = DIGIT;
255
+ break;
256
+ case CONTAINS:
257
+ isValid = value.indexOf(passwordValidation[CONTAINS]) != -1;
258
+ keyName = CONTAINS;
259
+ break;
260
+ case LOWERCASE:
261
+ isValid = RegexValidator.isValid(value, RegExRule.lowerCase);
262
+ keyName = LOWERCASE;
263
+ break;
264
+ case UPPERCASE:
265
+ isValid = RegexValidator.isValid(value, RegExRule.upperCase);
266
+ keyName = UPPERCASE;
267
+ break;
268
+ case SPECIAL_CHARACTER:
269
+ isValid = RegexValidator.isExits(value, RegExRule.specialCharacter);
270
+ keyName = SPECIAL_CHARACTER;
271
+ break;
272
+ case MIN_LENGTH:
273
+ isValid = value.length >= passwordValidation[propertyName];
274
+ keyName = MIN_LENGTH;
275
+ break;
276
+ case MAX_LENGTH:
277
+ isValid = value.length <= passwordValidation[propertyName];
278
+ keyName = MAX_LENGTH;
279
+ break;
280
+ }
281
+ if (!isValid)
282
+ break;
283
+ }
284
+ return { isValid, keyName };
285
+ }
286
+ static isZero(value) {
287
+ return value == 0;
288
+ }
289
+ static commaRegex() {
290
+ return new RegExp(",", "g");
291
+ }
292
+ }
293
+
294
+ class Linq {
295
+ static execute(config, params) {
296
+ if (config.conditionalExpression) {
297
+ return config.conditionalExpression.bind(params.current).call(params.current, params.current, params.root);
298
+ }
299
+ return true;
300
+ }
301
+ }
302
+
303
+ class ValidatorValueChecker {
304
+ static pass(params, config) {
305
+ if (Linq.execute(config, params))
306
+ return RegexValidator.isNotBlank(params.value);
307
+ else
308
+ return false;
309
+ }
310
+ static passArrayValue(params, config) {
311
+ if (Linq.execute(config, params))
312
+ return params.value instanceof Array;
313
+ else
314
+ return false;
315
+ }
316
+ }
317
+
318
+ class Utils {
319
+ static isNotBlank(value, isRemoveSpace = false) {
320
+ return !isRemoveSpace ? value === 0 || value !== void 0 && value !== null && value !== "" : value === 0 || value !== void 0 && value !== null && String(value).trim() !== "";
321
+ }
322
+ }
323
+
324
+ function requiredValidator(config, params) {
325
+ if (Linq.execute(config, params)) {
326
+ if (!Utils.isNotBlank(params.value))
327
+ return ValidationMessage.toJson(ValidatorNames.required, config, []);
328
+ }
329
+ return ValidationMessage.null();
330
+ }
331
+
332
+ var NumericValueType = /* @__PURE__ */ ((NumericValueType2) => {
333
+ NumericValueType2[NumericValueType2["PositiveNumber"] = 1] = "PositiveNumber";
334
+ NumericValueType2[NumericValueType2["NegativeNumber"] = 2] = "NegativeNumber";
335
+ NumericValueType2[NumericValueType2["Both"] = 3] = "Both";
336
+ return NumericValueType2;
337
+ })(NumericValueType || {});
338
+
339
+ class ApplicationUtil {
340
+ static toLower(value) {
341
+ if (value)
342
+ return String(value).toLowerCase().trim();
343
+ return value;
344
+ }
345
+ static isNumeric(value) {
346
+ return value - parseFloat(value) + 1 >= 0;
347
+ }
348
+ static notEqualTo(primaryValue, secondaryValue) {
349
+ let firstValue = primaryValue === void 0 || primaryValue === null ? "" : primaryValue;
350
+ let secondValue = secondaryValue === void 0 || secondaryValue === null ? "" : secondaryValue;
351
+ if (firstValue instanceof Date && secondValue instanceof Date)
352
+ return +firstValue != +secondValue;
353
+ return firstValue != secondValue;
354
+ }
355
+ static numericValidation(allowDecimal, acceptValue) {
356
+ acceptValue = acceptValue == void 0 ? NumericValueType.PositiveNumber : acceptValue;
357
+ let regex = /^[0-9]+$/;
358
+ switch (acceptValue) {
359
+ case NumericValueType.PositiveNumber:
360
+ regex = !allowDecimal ? /^[0-9]+$/ : /^[0-9\.]+$/ ;
361
+ break;
362
+ case NumericValueType.NegativeNumber:
363
+ regex = !allowDecimal ? /^[-][0-9]+$/ : /^[-][0-9\.]+$/ ;
364
+ break;
365
+ case NumericValueType.Both:
366
+ regex = !allowDecimal ? /^[-|+]?[0-9]+$/ : /^[-|+]?[0-9\.]+$/ ;
367
+ break;
368
+ }
369
+ return regex;
370
+ }
371
+ static lowerCaseWithTrim(value) {
372
+ return typeof value === "string" ? value.toLowerCase().trim() : String(value).toLowerCase().trim();
373
+ }
374
+ /** Check if a value is an object */
375
+ static isObject(value) {
376
+ return Object.prototype.toString.call(value) === "[object Object]";
377
+ }
378
+ /** Check if a value is an object */
379
+ static isArray(value) {
380
+ return Array.isArray(value);
381
+ }
382
+ static cloneValue(value) {
383
+ return ApplicationUtil.isObject(value) ? ApplicationUtil.isArray(value) ? [...value] : { ...value } : value;
384
+ }
385
+ }
386
+
387
+ function numericValidator(configModel, control) {
388
+ let config = getConfigObject(configModel);
389
+ if (ValidatorValueChecker.pass(control, config)) {
390
+ if (!RegexValidator.isValid(control.value, ApplicationUtil.numericValidation(config.allowDecimal, config.acceptValue)))
391
+ return ValidationMessage.toJson(ValidatorNames.numeric, config, [control.value]);
392
+ }
393
+ return ValidationMessage.null();
394
+ }
395
+
396
+ function allOfValidator(configModel, params) {
397
+ let config = getConfigObject(configModel);
398
+ if (ValidatorValueChecker.passArrayValue(params, configModel)) {
399
+ var testResult = false;
400
+ for (let value of config.matchValues) {
401
+ testResult = params.value.some((y) => y == value);
402
+ if (!testResult)
403
+ break;
404
+ }
405
+ if (!testResult)
406
+ return ValidationMessage.toJson(ValidatorNames.allOf, config, [params.value]);
407
+ }
408
+ return ValidationMessage.null();
409
+ }
410
+
411
+ function baseDecoratorFunction(validatorName, config, validator) {
412
+ return function(target, propertyKey, parameterIndex) {
413
+ registerDecorator({
414
+ decoratorParams: {
415
+ target,
416
+ propertyKey,
417
+ descriptor: parameterIndex
418
+ },
419
+ validatorConfig: {
420
+ name: validatorName,
421
+ config,
422
+ validator
423
+ }
424
+ });
425
+ };
426
+ }
427
+
428
+ function allOf(config) {
429
+ return baseDecoratorFunction(ValidatorNames.allOf, config || {}, allOfValidator);
430
+ }
431
+
432
+ function required(config) {
433
+ return baseDecoratorFunction(ValidatorNames.required, config || {}, requiredValidator);
434
+ }
435
+
436
+ function numeric(config) {
437
+ return baseDecoratorFunction(ValidatorNames.numeric, config || {}, numericValidator);
438
+ }
439
+
440
+ function getProperties(type) {
441
+ if (type) {
442
+ const props = entityContainer.getProperties(type.name);
443
+ const jProps = {};
444
+ if (props)
445
+ props.forEach((property) => jProps[property.name.toLowerCase()] = property.name);
446
+ return jProps;
447
+ }
448
+ return;
449
+ }
450
+ function jsonStringToList(model) {
451
+ return function(target, propertyKey) {
452
+ let value;
453
+ const getter = function() {
454
+ return new List(JSON.parse(value), model, getProperties(model));
455
+ };
456
+ const setter = function(newVal) {
457
+ value = newVal;
458
+ };
459
+ Object.defineProperty(target, propertyKey, {
460
+ get: getter,
461
+ set: setter
462
+ });
463
+ };
464
+ }
465
+
466
+ export { NumericValueType, allOf, columnName, jsonStringToList, key, model, numeric, oneToMany, oneToOne, prop, required };
package/package.json ADDED
@@ -0,0 +1,20 @@
1
+ {
2
+ "name": "@nattyjs/entity",
3
+ "version": "0.0.1-beta.0",
4
+ "description": "",
5
+ "keywords": [],
6
+ "author": "ajayojha",
7
+ "license": "MIT",
8
+ "module": "./dist/index.mjs",
9
+ "main": "./dist/index.cjs",
10
+ "types": "./dist/index.d.ts",
11
+ "files": [
12
+ "dist"
13
+ ],
14
+ "scripts": {
15
+ "build": "unbuild"
16
+ },
17
+ "devDependencies": {
18
+ "unbuild": "1.2.1"
19
+ }
20
+ }