@naturalcycles/nodejs-lib 15.72.1 → 15.73.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.
|
@@ -50,6 +50,13 @@ export declare const j: {
|
|
|
50
50
|
buffer(): JsonSchemaBufferBuilder;
|
|
51
51
|
enum<const T extends readonly (string | number | boolean | null)[] | StringEnum | NumberEnum>(input: T, opt?: JsonBuilderRuleOpt): JsonSchemaEnumBuilder<T extends readonly (infer U)[] ? U : T extends StringEnum ? T[keyof T] : T extends NumberEnum ? T[keyof T] : never>;
|
|
52
52
|
oneOf<B extends readonly JsonSchemaAnyBuilder<any, any, boolean>[], IN = BuilderInUnion<B>, OUT = BuilderOutUnion<B>>(items: [...B]): JsonSchemaAnyBuilder<IN, OUT, false>;
|
|
53
|
+
/**
|
|
54
|
+
* Value must match at least one of the provided schemas.
|
|
55
|
+
*
|
|
56
|
+
* Use `anyOf` when schemas may overlap (e.g., AccountId | PartnerId with same format).
|
|
57
|
+
* Use `oneOf` when schemas are mutually exclusive.
|
|
58
|
+
*/
|
|
59
|
+
anyOf<B extends readonly JsonSchemaAnyBuilder<any, any, boolean>[], IN = BuilderInUnion<B>, OUT = BuilderOutUnion<B>>(items: [...B]): JsonSchemaAnyBuilder<IN, OUT, false>;
|
|
53
60
|
and(): {
|
|
54
61
|
silentBob: () => never;
|
|
55
62
|
};
|
|
@@ -112,6 +112,18 @@ export const j = {
|
|
|
112
112
|
oneOf: schemas,
|
|
113
113
|
});
|
|
114
114
|
},
|
|
115
|
+
/**
|
|
116
|
+
* Value must match at least one of the provided schemas.
|
|
117
|
+
*
|
|
118
|
+
* Use `anyOf` when schemas may overlap (e.g., AccountId | PartnerId with same format).
|
|
119
|
+
* Use `oneOf` when schemas are mutually exclusive.
|
|
120
|
+
*/
|
|
121
|
+
anyOf(items) {
|
|
122
|
+
const schemas = items.map(b => b.build());
|
|
123
|
+
return new JsonSchemaAnyBuilder({
|
|
124
|
+
anyOf: schemas,
|
|
125
|
+
});
|
|
126
|
+
},
|
|
115
127
|
and() {
|
|
116
128
|
return {
|
|
117
129
|
silentBob: () => {
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
export const BASE62_REGEX = /^[a-zA-Z0-9]+$/;
|
|
2
2
|
export const BASE64_REGEX = /^[a-zA-Z0-9+/]+={0,2}$/;
|
|
3
3
|
export const BASE64URL_REGEX = /^[a-zA-Z0-9_-]+$/;
|
|
4
|
-
// from `ajv-formats
|
|
5
|
-
export const UUID_REGEX = /^(?:urn:uuid:)?[0-9a-
|
|
4
|
+
// from `ajv-formats`, case-insensitive via character class (not flag) for JSON Schema compatibility
|
|
5
|
+
export const UUID_REGEX = /^(?:urn:uuid:)?[0-9a-fA-F]{8}-(?:[0-9a-fA-F]{4}-){3}[0-9a-fA-F]{12}$/;
|
|
6
6
|
export const COUNTRY_CODE_REGEX = /^[A-Z]{2}$/;
|
|
7
7
|
export const CURRENCY_REGEX = /^[A-Z]{3}$/;
|
|
8
8
|
/**
|
|
@@ -16,8 +16,8 @@ export const ID_REGEX = /^[a-zA-Z0-9_]{6,64}$/;
|
|
|
16
16
|
export const IPV4_REGEX =
|
|
17
17
|
// from `ajv-formats`
|
|
18
18
|
/^(?:(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)\.){3}(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)$/;
|
|
19
|
-
// from `ajv-formats
|
|
20
|
-
export const IPV6_REGEX = /^((([0-9a-
|
|
19
|
+
// from `ajv-formats`, case-insensitive via character class (not flag) for JSON Schema compatibility
|
|
20
|
+
export const IPV6_REGEX = /^((([0-9a-fA-F]{1,4}:){7}([0-9a-fA-F]{1,4}|:))|(([0-9a-fA-F]{1,4}:){6}(:[0-9a-fA-F]{1,4}|((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3})|:))|(([0-9a-fA-F]{1,4}:){5}(((:[0-9a-fA-F]{1,4}){1,2})|:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3})|:))|(([0-9a-fA-F]{1,4}:){4}(((:[0-9a-fA-F]{1,4}){1,3})|((:[0-9a-fA-F]{1,4})?:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(([0-9a-fA-F]{1,4}:){3}(((:[0-9a-fA-F]{1,4}){1,4})|((:[0-9a-fA-F]{1,4}){0,2}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(([0-9a-fA-F]{1,4}:){2}(((:[0-9a-fA-F]{1,4}){1,5})|((:[0-9a-fA-F]{1,4}){0,3}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(([0-9a-fA-F]{1,4}:){1}(((:[0-9a-fA-F]{1,4}){1,6})|((:[0-9a-fA-F]{1,4}){0,4}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(:(((:[0-9a-fA-F]{1,4}){1,7})|((:[0-9a-fA-F]{1,4}){0,5}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:)))$/;
|
|
21
21
|
// IETF language tag (https://en.wikipedia.org/wiki/IETF_language_tag)
|
|
22
22
|
export const LANGUAGE_TAG_REGEX = /^[a-z]{2}(-[A-Z]{2})?$/;
|
|
23
23
|
export const MAC_ADDRESS_REGEX = /^([0-9A-Fa-f]{2}[:-]){5}([0-9A-Fa-f]{2})$/;
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@naturalcycles/nodejs-lib",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "15.
|
|
4
|
+
"version": "15.73.0",
|
|
5
5
|
"dependencies": {
|
|
6
6
|
"@naturalcycles/js-lib": "^15",
|
|
7
7
|
"@types/js-yaml": "^4",
|
|
@@ -19,7 +19,7 @@
|
|
|
19
19
|
"yargs": "^18"
|
|
20
20
|
},
|
|
21
21
|
"devDependencies": {
|
|
22
|
-
"@naturalcycles/dev-lib": "
|
|
22
|
+
"@naturalcycles/dev-lib": "18.4.2"
|
|
23
23
|
},
|
|
24
24
|
"exports": {
|
|
25
25
|
".": "./dist/index.js",
|
|
@@ -190,6 +190,23 @@ export const j = {
|
|
|
190
190
|
})
|
|
191
191
|
},
|
|
192
192
|
|
|
193
|
+
/**
|
|
194
|
+
* Value must match at least one of the provided schemas.
|
|
195
|
+
*
|
|
196
|
+
* Use `anyOf` when schemas may overlap (e.g., AccountId | PartnerId with same format).
|
|
197
|
+
* Use `oneOf` when schemas are mutually exclusive.
|
|
198
|
+
*/
|
|
199
|
+
anyOf<
|
|
200
|
+
B extends readonly JsonSchemaAnyBuilder<any, any, boolean>[],
|
|
201
|
+
IN = BuilderInUnion<B>,
|
|
202
|
+
OUT = BuilderOutUnion<B>,
|
|
203
|
+
>(items: [...B]): JsonSchemaAnyBuilder<IN, OUT, false> {
|
|
204
|
+
const schemas = items.map(b => b.build())
|
|
205
|
+
return new JsonSchemaAnyBuilder<IN, OUT, false>({
|
|
206
|
+
anyOf: schemas,
|
|
207
|
+
})
|
|
208
|
+
},
|
|
209
|
+
|
|
193
210
|
and() {
|
|
194
211
|
return {
|
|
195
212
|
silentBob: () => {
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
export const BASE62_REGEX = /^[a-zA-Z0-9]+$/
|
|
2
2
|
export const BASE64_REGEX = /^[a-zA-Z0-9+/]+={0,2}$/
|
|
3
3
|
export const BASE64URL_REGEX = /^[a-zA-Z0-9_-]+$/
|
|
4
|
-
// from `ajv-formats
|
|
5
|
-
export const UUID_REGEX = /^(?:urn:uuid:)?[0-9a-
|
|
4
|
+
// from `ajv-formats`, case-insensitive via character class (not flag) for JSON Schema compatibility
|
|
5
|
+
export const UUID_REGEX = /^(?:urn:uuid:)?[0-9a-fA-F]{8}-(?:[0-9a-fA-F]{4}-){3}[0-9a-fA-F]{12}$/
|
|
6
6
|
export const COUNTRY_CODE_REGEX = /^[A-Z]{2}$/
|
|
7
7
|
export const CURRENCY_REGEX = /^[A-Z]{3}$/
|
|
8
8
|
/**
|
|
@@ -16,9 +16,9 @@ export const ID_REGEX = /^[a-zA-Z0-9_]{6,64}$/
|
|
|
16
16
|
export const IPV4_REGEX =
|
|
17
17
|
// from `ajv-formats`
|
|
18
18
|
/^(?:(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)\.){3}(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)$/
|
|
19
|
-
// from `ajv-formats
|
|
19
|
+
// from `ajv-formats`, case-insensitive via character class (not flag) for JSON Schema compatibility
|
|
20
20
|
export const IPV6_REGEX =
|
|
21
|
-
/^((([0-9a-
|
|
21
|
+
/^((([0-9a-fA-F]{1,4}:){7}([0-9a-fA-F]{1,4}|:))|(([0-9a-fA-F]{1,4}:){6}(:[0-9a-fA-F]{1,4}|((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3})|:))|(([0-9a-fA-F]{1,4}:){5}(((:[0-9a-fA-F]{1,4}){1,2})|:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3})|:))|(([0-9a-fA-F]{1,4}:){4}(((:[0-9a-fA-F]{1,4}){1,3})|((:[0-9a-fA-F]{1,4})?:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(([0-9a-fA-F]{1,4}:){3}(((:[0-9a-fA-F]{1,4}){1,4})|((:[0-9a-fA-F]{1,4}){0,2}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(([0-9a-fA-F]{1,4}:){2}(((:[0-9a-fA-F]{1,4}){1,5})|((:[0-9a-fA-F]{1,4}){0,3}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(([0-9a-fA-F]{1,4}:){1}(((:[0-9a-fA-F]{1,4}){1,6})|((:[0-9a-fA-F]{1,4}){0,4}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(:(((:[0-9a-fA-F]{1,4}){1,7})|((:[0-9a-fA-F]{1,4}){0,5}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:)))$/
|
|
22
22
|
// IETF language tag (https://en.wikipedia.org/wiki/IETF_language_tag)
|
|
23
23
|
export const LANGUAGE_TAG_REGEX = /^[a-z]{2}(-[A-Z]{2})?$/
|
|
24
24
|
export const MAC_ADDRESS_REGEX = /^([0-9A-Fa-f]{2}[:-]){5}([0-9A-Fa-f]{2})$/
|