@based/schema 2.4.0 → 2.5.1
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.
|
@@ -66,5 +66,20 @@ export const fields = {
|
|
|
66
66
|
}
|
|
67
67
|
args.error(ParseError.incorrectFormat);
|
|
68
68
|
},
|
|
69
|
+
any: async (args) => {
|
|
70
|
+
args.stop();
|
|
71
|
+
if (typeof args.value !== 'object') {
|
|
72
|
+
args.collect(args.value);
|
|
73
|
+
return;
|
|
74
|
+
}
|
|
75
|
+
const q = [];
|
|
76
|
+
for (const key in args.value) {
|
|
77
|
+
q.push(args.parse({
|
|
78
|
+
key: key,
|
|
79
|
+
value: args.value[key],
|
|
80
|
+
fieldSchema: { type: 'any' },
|
|
81
|
+
}));
|
|
82
|
+
}
|
|
83
|
+
},
|
|
69
84
|
};
|
|
70
85
|
//# sourceMappingURL=index.js.map
|
|
@@ -72,6 +72,8 @@ const formatPatterns = {
|
|
|
72
72
|
json: () => true,
|
|
73
73
|
markdown: () => true,
|
|
74
74
|
clike: () => true,
|
|
75
|
+
// Can add some more checks for this...
|
|
76
|
+
basedId: (value) => typeof value === 'string' && value.length < 16,
|
|
75
77
|
};
|
|
76
78
|
const validateString = (args, value) => {
|
|
77
79
|
if (typeof value !== 'string') {
|
package/dist/src/types.d.ts
CHANGED
|
@@ -9,7 +9,7 @@ export type AllowedTypes = (string | {
|
|
|
9
9
|
type?: string;
|
|
10
10
|
$filter: any | any[];
|
|
11
11
|
})[];
|
|
12
|
-
export declare const basedSchemaFieldTypes: readonly ["array", "object", "record", "set", "string", "boolean", "number", "json", "integer", "timestamp", "reference", "references", "text", "enum", "cardinality"];
|
|
12
|
+
export declare const basedSchemaFieldTypes: readonly ["array", "object", "record", "set", "string", "boolean", "number", "json", "integer", "timestamp", "reference", "references", "text", "enum", "cardinality", "any"];
|
|
13
13
|
export type BasedSchemaFieldType = (typeof basedSchemaFieldTypes)[number];
|
|
14
14
|
export declare const isCollection: (type: string) => boolean;
|
|
15
15
|
export type BasedSchemaPattern = string;
|
|
@@ -49,7 +49,7 @@ export type BasedSchemaStringShared = {
|
|
|
49
49
|
contentMediaEncoding?: string;
|
|
50
50
|
contentMediaType?: BasedSchemaContentMediaType;
|
|
51
51
|
pattern?: BasedSchemaPattern;
|
|
52
|
-
format?: 'email' | 'URL' | 'MACAddress' | 'IP' | 'IPRange' | 'FQDN' | 'IBAN' | 'BIC' | 'alpha' | 'alphaLocales' | 'alphanumeric' | 'alphanumericLocales' | 'passportNumber' | 'port' | 'lowercase' | 'uppercase' | 'ascii' | 'semVer' | 'surrogatePair' | 'IMEI' | 'hexadecimal' | 'octal' | 'hexColor' | 'rgbColor' | 'HSL' | 'ISRC' | 'MD5' | 'JWT' | 'UUID' | 'luhnNumber' | 'creditCard' | 'identityCard' | 'EAN' | 'ISIN' | 'ISBN' | 'ISSN' | 'mobilePhone' | 'mobilePhoneLocales' | 'postalCode' | 'postalCodeLocales' | 'ethereumAddress' | 'currency' | 'btcAddress' | 'ISO6391' | 'ISO8601' | 'RFC3339' | 'ISO31661Alpha2' | 'ISO31661Alpha3' | 'ISO4217' | 'base32' | 'base58' | 'base64' | 'dataURI' | 'magnetURI' | 'mimeType' | 'latLong' | 'slug' | 'strongPassword' | 'taxID' | 'licensePlate' | 'VAT' | 'code' | 'typescript' | 'javascript' | 'python' | 'rust' | 'css' | 'html' | 'json' | 'markdown' | 'clike';
|
|
52
|
+
format?: 'email' | 'URL' | 'MACAddress' | 'IP' | 'IPRange' | 'FQDN' | 'IBAN' | 'BIC' | 'alpha' | 'alphaLocales' | 'alphanumeric' | 'alphanumericLocales' | 'passportNumber' | 'port' | 'lowercase' | 'uppercase' | 'ascii' | 'semVer' | 'surrogatePair' | 'IMEI' | 'hexadecimal' | 'octal' | 'hexColor' | 'rgbColor' | 'HSL' | 'ISRC' | 'MD5' | 'JWT' | 'UUID' | 'luhnNumber' | 'creditCard' | 'identityCard' | 'EAN' | 'ISIN' | 'ISBN' | 'ISSN' | 'mobilePhone' | 'mobilePhoneLocales' | 'postalCode' | 'postalCodeLocales' | 'ethereumAddress' | 'currency' | 'btcAddress' | 'ISO6391' | 'ISO8601' | 'RFC3339' | 'ISO31661Alpha2' | 'ISO31661Alpha3' | 'ISO4217' | 'base32' | 'base58' | 'base64' | 'dataURI' | 'magnetURI' | 'mimeType' | 'latLong' | 'slug' | 'strongPassword' | 'taxID' | 'licensePlate' | 'VAT' | 'code' | 'typescript' | 'javascript' | 'python' | 'rust' | 'css' | 'html' | 'json' | 'markdown' | 'clike' | 'basedId';
|
|
53
53
|
display?: StringFormat;
|
|
54
54
|
multiline?: boolean;
|
|
55
55
|
};
|
|
@@ -91,6 +91,9 @@ export type BasedSchemaFieldJSON = {
|
|
|
91
91
|
type: 'json';
|
|
92
92
|
format?: 'rich-text';
|
|
93
93
|
} & BasedSchemaFieldShared;
|
|
94
|
+
export type BasedSchemaFieldAny = {
|
|
95
|
+
type: 'any';
|
|
96
|
+
} & BasedSchemaFieldShared;
|
|
94
97
|
export type BasedSchemaFieldPrimitive = BasedSchemaFieldString | BasedSchemaFieldNumber | BasedSchemaFieldInteger | BasedSchemaFieldTimeStamp | BasedSchemaFieldJSON | BasedSchemaFieldBoolean | BasedSchemaFieldEnum;
|
|
95
98
|
export type BasedSchemaFieldText = {
|
|
96
99
|
type: 'text';
|
|
@@ -147,6 +150,7 @@ export type BasedSchemaFields = {
|
|
|
147
150
|
references: BasedSchemaFieldReferences;
|
|
148
151
|
text: BasedSchemaFieldText;
|
|
149
152
|
cardinality: BasedSchemaFieldCardinality;
|
|
153
|
+
any: BasedSchemaFieldAny;
|
|
150
154
|
};
|
|
151
155
|
export type BasedSchemaField = BasedSchemaFields[keyof BasedSchemaFields] | (BasedSchemaFieldShared & {
|
|
152
156
|
type?: '';
|
package/dist/src/types.js
CHANGED