@langchain/core 0.3.22 → 0.3.24-rc.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/dist/callbacks/base.cjs +13 -1
- package/dist/callbacks/base.d.ts +10 -0
- package/dist/callbacks/base.js +10 -0
- package/dist/callbacks/manager.cjs +21 -0
- package/dist/callbacks/manager.js +22 -1
- package/dist/context.cjs +13 -123
- package/dist/context.d.ts +2 -101
- package/dist/context.js +9 -119
- package/dist/language_models/chat_models.cjs +2 -5
- package/dist/language_models/chat_models.js +2 -5
- package/dist/language_models/llms.cjs +2 -5
- package/dist/language_models/llms.js +2 -5
- package/dist/messages/tool.cjs +14 -1
- package/dist/messages/tool.d.ts +13 -1
- package/dist/messages/tool.js +12 -0
- package/dist/output_parsers/transform.cjs +2 -2
- package/dist/output_parsers/transform.js +1 -1
- package/dist/singletons/async_local_storage/context.cjs +189 -0
- package/dist/singletons/async_local_storage/context.d.ts +155 -0
- package/dist/singletons/async_local_storage/context.js +182 -0
- package/dist/singletons/async_local_storage/globals.cjs +2 -1
- package/dist/singletons/async_local_storage/globals.d.ts +2 -1
- package/dist/singletons/async_local_storage/globals.js +1 -0
- package/dist/singletons/async_local_storage/index.cjs +4 -5
- package/dist/singletons/async_local_storage/index.d.ts +0 -1
- package/dist/singletons/async_local_storage/index.js +1 -2
- package/dist/singletons/callbacks.cjs +6 -4
- package/dist/singletons/callbacks.js +6 -4
- package/dist/singletons/index.cjs +3 -3
- package/dist/singletons/index.d.ts +4 -2
- package/dist/singletons/index.js +4 -3
- package/dist/tools/index.cjs +12 -10
- package/dist/tools/index.d.ts +11 -8
- package/dist/tools/index.js +13 -11
- package/dist/tracers/event_stream.cjs +6 -0
- package/dist/tracers/event_stream.d.ts +3 -2
- package/dist/tracers/event_stream.js +6 -0
- package/dist/tracers/log_stream.cjs +6 -0
- package/dist/tracers/log_stream.d.ts +3 -2
- package/dist/tracers/log_stream.js +6 -0
- package/dist/utils/json_schema.cjs +3 -3
- package/dist/utils/json_schema.d.ts +1 -1
- package/dist/utils/json_schema.js +1 -1
- package/package.json +2 -1
- package/dist/utils/@cfworker/json-schema/index.cjs +0 -17
- package/dist/utils/@cfworker/json-schema/index.d.ts +0 -1
- package/dist/utils/@cfworker/json-schema/index.js +0 -1
- package/dist/utils/@cfworker/json-schema/src/deep-compare-strict.cjs +0 -43
- package/dist/utils/@cfworker/json-schema/src/deep-compare-strict.d.ts +0 -1
- package/dist/utils/@cfworker/json-schema/src/deep-compare-strict.js +0 -39
- package/dist/utils/@cfworker/json-schema/src/dereference.cjs +0 -171
- package/dist/utils/@cfworker/json-schema/src/dereference.d.ts +0 -12
- package/dist/utils/@cfworker/json-schema/src/dereference.js +0 -167
- package/dist/utils/@cfworker/json-schema/src/format.cjs +0 -139
- package/dist/utils/@cfworker/json-schema/src/format.d.ts +0 -2
- package/dist/utils/@cfworker/json-schema/src/format.js +0 -136
- package/dist/utils/@cfworker/json-schema/src/index.cjs +0 -24
- package/dist/utils/@cfworker/json-schema/src/index.d.ts +0 -8
- package/dist/utils/@cfworker/json-schema/src/index.js +0 -8
- package/dist/utils/@cfworker/json-schema/src/pointer.cjs +0 -11
- package/dist/utils/@cfworker/json-schema/src/pointer.d.ts +0 -2
- package/dist/utils/@cfworker/json-schema/src/pointer.js +0 -6
- package/dist/utils/@cfworker/json-schema/src/types.cjs +0 -2
- package/dist/utils/@cfworker/json-schema/src/types.d.ts +0 -72
- package/dist/utils/@cfworker/json-schema/src/types.js +0 -1
- package/dist/utils/@cfworker/json-schema/src/ucs2-length.cjs +0 -28
- package/dist/utils/@cfworker/json-schema/src/ucs2-length.d.ts +0 -6
- package/dist/utils/@cfworker/json-schema/src/ucs2-length.js +0 -24
- package/dist/utils/@cfworker/json-schema/src/validate.cjs +0 -808
- package/dist/utils/@cfworker/json-schema/src/validate.d.ts +0 -3
- package/dist/utils/@cfworker/json-schema/src/validate.js +0 -804
- package/dist/utils/@cfworker/json-schema/src/validator.cjs +0 -44
- package/dist/utils/@cfworker/json-schema/src/validator.d.ts +0 -10
- package/dist/utils/@cfworker/json-schema/src/validator.js +0 -40
|
@@ -1,171 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.dereference = exports.initialBaseURI = exports.ignoredKeyword = exports.schemaMapKeyword = exports.schemaArrayKeyword = exports.schemaKeyword = void 0;
|
|
4
|
-
const pointer_js_1 = require("./pointer.cjs");
|
|
5
|
-
exports.schemaKeyword = {
|
|
6
|
-
additionalItems: true,
|
|
7
|
-
unevaluatedItems: true,
|
|
8
|
-
items: true,
|
|
9
|
-
contains: true,
|
|
10
|
-
additionalProperties: true,
|
|
11
|
-
unevaluatedProperties: true,
|
|
12
|
-
propertyNames: true,
|
|
13
|
-
not: true,
|
|
14
|
-
if: true,
|
|
15
|
-
then: true,
|
|
16
|
-
else: true,
|
|
17
|
-
};
|
|
18
|
-
exports.schemaArrayKeyword = {
|
|
19
|
-
prefixItems: true,
|
|
20
|
-
items: true,
|
|
21
|
-
allOf: true,
|
|
22
|
-
anyOf: true,
|
|
23
|
-
oneOf: true,
|
|
24
|
-
};
|
|
25
|
-
exports.schemaMapKeyword = {
|
|
26
|
-
$defs: true,
|
|
27
|
-
definitions: true,
|
|
28
|
-
properties: true,
|
|
29
|
-
patternProperties: true,
|
|
30
|
-
dependentSchemas: true,
|
|
31
|
-
};
|
|
32
|
-
exports.ignoredKeyword = {
|
|
33
|
-
id: true,
|
|
34
|
-
$id: true,
|
|
35
|
-
$ref: true,
|
|
36
|
-
$schema: true,
|
|
37
|
-
$anchor: true,
|
|
38
|
-
$vocabulary: true,
|
|
39
|
-
$comment: true,
|
|
40
|
-
default: true,
|
|
41
|
-
enum: true,
|
|
42
|
-
const: true,
|
|
43
|
-
required: true,
|
|
44
|
-
type: true,
|
|
45
|
-
maximum: true,
|
|
46
|
-
minimum: true,
|
|
47
|
-
exclusiveMaximum: true,
|
|
48
|
-
exclusiveMinimum: true,
|
|
49
|
-
multipleOf: true,
|
|
50
|
-
maxLength: true,
|
|
51
|
-
minLength: true,
|
|
52
|
-
pattern: true,
|
|
53
|
-
format: true,
|
|
54
|
-
maxItems: true,
|
|
55
|
-
minItems: true,
|
|
56
|
-
uniqueItems: true,
|
|
57
|
-
maxProperties: true,
|
|
58
|
-
minProperties: true,
|
|
59
|
-
};
|
|
60
|
-
/**
|
|
61
|
-
* Default base URI for schemas without an $id.
|
|
62
|
-
* https://json-schema.org/draft/2019-09/json-schema-core.html#initial-base
|
|
63
|
-
* https://tools.ietf.org/html/rfc3986#section-5.1
|
|
64
|
-
*/
|
|
65
|
-
exports.initialBaseURI =
|
|
66
|
-
// @ts-ignore
|
|
67
|
-
typeof self !== "undefined" &&
|
|
68
|
-
self.location &&
|
|
69
|
-
self.location.origin !== "null"
|
|
70
|
-
? //@ts-ignore
|
|
71
|
-
/* #__PURE__ */ new URL(self.location.origin + self.location.pathname + location.search)
|
|
72
|
-
: /* #__PURE__ */ new URL("https://github.com/cfworker");
|
|
73
|
-
function dereference(schema, lookup = Object.create(null), baseURI = exports.initialBaseURI, basePointer = "") {
|
|
74
|
-
if (schema && typeof schema === "object" && !Array.isArray(schema)) {
|
|
75
|
-
const id = schema.$id || schema.id;
|
|
76
|
-
if (id) {
|
|
77
|
-
const url = new URL(id, baseURI.href);
|
|
78
|
-
if (url.hash.length > 1) {
|
|
79
|
-
lookup[url.href] = schema;
|
|
80
|
-
}
|
|
81
|
-
else {
|
|
82
|
-
url.hash = ""; // normalize hash https://url.spec.whatwg.org/#dom-url-hash
|
|
83
|
-
if (basePointer === "") {
|
|
84
|
-
baseURI = url;
|
|
85
|
-
}
|
|
86
|
-
else {
|
|
87
|
-
dereference(schema, lookup, baseURI);
|
|
88
|
-
}
|
|
89
|
-
}
|
|
90
|
-
}
|
|
91
|
-
}
|
|
92
|
-
else if (schema !== true && schema !== false) {
|
|
93
|
-
return lookup;
|
|
94
|
-
}
|
|
95
|
-
// compute the schema's URI and add it to the mapping.
|
|
96
|
-
const schemaURI = baseURI.href + (basePointer ? "#" + basePointer : "");
|
|
97
|
-
if (lookup[schemaURI] !== undefined) {
|
|
98
|
-
throw new Error(`Duplicate schema URI "${schemaURI}".`);
|
|
99
|
-
}
|
|
100
|
-
lookup[schemaURI] = schema;
|
|
101
|
-
// exit early if this is a boolean schema.
|
|
102
|
-
if (schema === true || schema === false) {
|
|
103
|
-
return lookup;
|
|
104
|
-
}
|
|
105
|
-
// set the schema's absolute URI.
|
|
106
|
-
if (schema.__absolute_uri__ === undefined) {
|
|
107
|
-
Object.defineProperty(schema, "__absolute_uri__", {
|
|
108
|
-
enumerable: false,
|
|
109
|
-
value: schemaURI,
|
|
110
|
-
});
|
|
111
|
-
}
|
|
112
|
-
// if a $ref is found, resolve it's absolute URI.
|
|
113
|
-
if (schema.$ref && schema.__absolute_ref__ === undefined) {
|
|
114
|
-
const url = new URL(schema.$ref, baseURI.href);
|
|
115
|
-
url.hash = url.hash; // normalize hash https://url.spec.whatwg.org/#dom-url-hash
|
|
116
|
-
Object.defineProperty(schema, "__absolute_ref__", {
|
|
117
|
-
enumerable: false,
|
|
118
|
-
value: url.href,
|
|
119
|
-
});
|
|
120
|
-
}
|
|
121
|
-
// if a $recursiveRef is found, resolve it's absolute URI.
|
|
122
|
-
if (schema.$recursiveRef && schema.__absolute_recursive_ref__ === undefined) {
|
|
123
|
-
const url = new URL(schema.$recursiveRef, baseURI.href);
|
|
124
|
-
url.hash = url.hash; // normalize hash https://url.spec.whatwg.org/#dom-url-hash
|
|
125
|
-
Object.defineProperty(schema, "__absolute_recursive_ref__", {
|
|
126
|
-
enumerable: false,
|
|
127
|
-
value: url.href,
|
|
128
|
-
});
|
|
129
|
-
}
|
|
130
|
-
// if an $anchor is found, compute it's URI and add it to the mapping.
|
|
131
|
-
if (schema.$anchor) {
|
|
132
|
-
const url = new URL("#" + schema.$anchor, baseURI.href);
|
|
133
|
-
lookup[url.href] = schema;
|
|
134
|
-
}
|
|
135
|
-
// process subschemas.
|
|
136
|
-
for (let key in schema) {
|
|
137
|
-
if (exports.ignoredKeyword[key]) {
|
|
138
|
-
continue;
|
|
139
|
-
}
|
|
140
|
-
const keyBase = `${basePointer}/${(0, pointer_js_1.encodePointer)(key)}`;
|
|
141
|
-
const subSchema = schema[key];
|
|
142
|
-
if (Array.isArray(subSchema)) {
|
|
143
|
-
if (exports.schemaArrayKeyword[key]) {
|
|
144
|
-
const length = subSchema.length;
|
|
145
|
-
for (let i = 0; i < length; i++) {
|
|
146
|
-
dereference(subSchema[i], lookup, baseURI, `${keyBase}/${i}`);
|
|
147
|
-
}
|
|
148
|
-
}
|
|
149
|
-
}
|
|
150
|
-
else if (exports.schemaMapKeyword[key]) {
|
|
151
|
-
for (let subKey in subSchema) {
|
|
152
|
-
dereference(subSchema[subKey], lookup, baseURI, `${keyBase}/${(0, pointer_js_1.encodePointer)(subKey)}`);
|
|
153
|
-
}
|
|
154
|
-
}
|
|
155
|
-
else {
|
|
156
|
-
dereference(subSchema, lookup, baseURI, keyBase);
|
|
157
|
-
}
|
|
158
|
-
}
|
|
159
|
-
return lookup;
|
|
160
|
-
}
|
|
161
|
-
exports.dereference = dereference;
|
|
162
|
-
// schema identification examples
|
|
163
|
-
// https://json-schema.org/draft/2019-09/json-schema-core.html#rfc.appendix.A
|
|
164
|
-
// $ref delegation
|
|
165
|
-
// https://github.com/json-schema-org/json-schema-spec/issues/514
|
|
166
|
-
// output format
|
|
167
|
-
// https://json-schema.org/draft/2019-09/json-schema-core.html#output
|
|
168
|
-
// JSON pointer
|
|
169
|
-
// https://tools.ietf.org/html/rfc6901
|
|
170
|
-
// JSON relative pointer
|
|
171
|
-
// https://tools.ietf.org/html/draft-handrews-relative-json-pointer-01
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import { Schema } from "./types.js";
|
|
2
|
-
export declare const schemaKeyword: Record<string, boolean>;
|
|
3
|
-
export declare const schemaArrayKeyword: Record<string, boolean>;
|
|
4
|
-
export declare const schemaMapKeyword: Record<string, boolean>;
|
|
5
|
-
export declare const ignoredKeyword: Record<string, boolean>;
|
|
6
|
-
/**
|
|
7
|
-
* Default base URI for schemas without an $id.
|
|
8
|
-
* https://json-schema.org/draft/2019-09/json-schema-core.html#initial-base
|
|
9
|
-
* https://tools.ietf.org/html/rfc3986#section-5.1
|
|
10
|
-
*/
|
|
11
|
-
export declare let initialBaseURI: URL;
|
|
12
|
-
export declare function dereference(schema: Schema | boolean, lookup?: Record<string, Schema | boolean>, baseURI?: URL, basePointer?: string): Record<string, boolean | Schema>;
|
|
@@ -1,167 +0,0 @@
|
|
|
1
|
-
import { encodePointer } from "./pointer.js";
|
|
2
|
-
export const schemaKeyword = {
|
|
3
|
-
additionalItems: true,
|
|
4
|
-
unevaluatedItems: true,
|
|
5
|
-
items: true,
|
|
6
|
-
contains: true,
|
|
7
|
-
additionalProperties: true,
|
|
8
|
-
unevaluatedProperties: true,
|
|
9
|
-
propertyNames: true,
|
|
10
|
-
not: true,
|
|
11
|
-
if: true,
|
|
12
|
-
then: true,
|
|
13
|
-
else: true,
|
|
14
|
-
};
|
|
15
|
-
export const schemaArrayKeyword = {
|
|
16
|
-
prefixItems: true,
|
|
17
|
-
items: true,
|
|
18
|
-
allOf: true,
|
|
19
|
-
anyOf: true,
|
|
20
|
-
oneOf: true,
|
|
21
|
-
};
|
|
22
|
-
export const schemaMapKeyword = {
|
|
23
|
-
$defs: true,
|
|
24
|
-
definitions: true,
|
|
25
|
-
properties: true,
|
|
26
|
-
patternProperties: true,
|
|
27
|
-
dependentSchemas: true,
|
|
28
|
-
};
|
|
29
|
-
export const ignoredKeyword = {
|
|
30
|
-
id: true,
|
|
31
|
-
$id: true,
|
|
32
|
-
$ref: true,
|
|
33
|
-
$schema: true,
|
|
34
|
-
$anchor: true,
|
|
35
|
-
$vocabulary: true,
|
|
36
|
-
$comment: true,
|
|
37
|
-
default: true,
|
|
38
|
-
enum: true,
|
|
39
|
-
const: true,
|
|
40
|
-
required: true,
|
|
41
|
-
type: true,
|
|
42
|
-
maximum: true,
|
|
43
|
-
minimum: true,
|
|
44
|
-
exclusiveMaximum: true,
|
|
45
|
-
exclusiveMinimum: true,
|
|
46
|
-
multipleOf: true,
|
|
47
|
-
maxLength: true,
|
|
48
|
-
minLength: true,
|
|
49
|
-
pattern: true,
|
|
50
|
-
format: true,
|
|
51
|
-
maxItems: true,
|
|
52
|
-
minItems: true,
|
|
53
|
-
uniqueItems: true,
|
|
54
|
-
maxProperties: true,
|
|
55
|
-
minProperties: true,
|
|
56
|
-
};
|
|
57
|
-
/**
|
|
58
|
-
* Default base URI for schemas without an $id.
|
|
59
|
-
* https://json-schema.org/draft/2019-09/json-schema-core.html#initial-base
|
|
60
|
-
* https://tools.ietf.org/html/rfc3986#section-5.1
|
|
61
|
-
*/
|
|
62
|
-
export let initialBaseURI =
|
|
63
|
-
// @ts-ignore
|
|
64
|
-
typeof self !== "undefined" &&
|
|
65
|
-
self.location &&
|
|
66
|
-
self.location.origin !== "null"
|
|
67
|
-
? //@ts-ignore
|
|
68
|
-
/* #__PURE__ */ new URL(self.location.origin + self.location.pathname + location.search)
|
|
69
|
-
: /* #__PURE__ */ new URL("https://github.com/cfworker");
|
|
70
|
-
export function dereference(schema, lookup = Object.create(null), baseURI = initialBaseURI, basePointer = "") {
|
|
71
|
-
if (schema && typeof schema === "object" && !Array.isArray(schema)) {
|
|
72
|
-
const id = schema.$id || schema.id;
|
|
73
|
-
if (id) {
|
|
74
|
-
const url = new URL(id, baseURI.href);
|
|
75
|
-
if (url.hash.length > 1) {
|
|
76
|
-
lookup[url.href] = schema;
|
|
77
|
-
}
|
|
78
|
-
else {
|
|
79
|
-
url.hash = ""; // normalize hash https://url.spec.whatwg.org/#dom-url-hash
|
|
80
|
-
if (basePointer === "") {
|
|
81
|
-
baseURI = url;
|
|
82
|
-
}
|
|
83
|
-
else {
|
|
84
|
-
dereference(schema, lookup, baseURI);
|
|
85
|
-
}
|
|
86
|
-
}
|
|
87
|
-
}
|
|
88
|
-
}
|
|
89
|
-
else if (schema !== true && schema !== false) {
|
|
90
|
-
return lookup;
|
|
91
|
-
}
|
|
92
|
-
// compute the schema's URI and add it to the mapping.
|
|
93
|
-
const schemaURI = baseURI.href + (basePointer ? "#" + basePointer : "");
|
|
94
|
-
if (lookup[schemaURI] !== undefined) {
|
|
95
|
-
throw new Error(`Duplicate schema URI "${schemaURI}".`);
|
|
96
|
-
}
|
|
97
|
-
lookup[schemaURI] = schema;
|
|
98
|
-
// exit early if this is a boolean schema.
|
|
99
|
-
if (schema === true || schema === false) {
|
|
100
|
-
return lookup;
|
|
101
|
-
}
|
|
102
|
-
// set the schema's absolute URI.
|
|
103
|
-
if (schema.__absolute_uri__ === undefined) {
|
|
104
|
-
Object.defineProperty(schema, "__absolute_uri__", {
|
|
105
|
-
enumerable: false,
|
|
106
|
-
value: schemaURI,
|
|
107
|
-
});
|
|
108
|
-
}
|
|
109
|
-
// if a $ref is found, resolve it's absolute URI.
|
|
110
|
-
if (schema.$ref && schema.__absolute_ref__ === undefined) {
|
|
111
|
-
const url = new URL(schema.$ref, baseURI.href);
|
|
112
|
-
url.hash = url.hash; // normalize hash https://url.spec.whatwg.org/#dom-url-hash
|
|
113
|
-
Object.defineProperty(schema, "__absolute_ref__", {
|
|
114
|
-
enumerable: false,
|
|
115
|
-
value: url.href,
|
|
116
|
-
});
|
|
117
|
-
}
|
|
118
|
-
// if a $recursiveRef is found, resolve it's absolute URI.
|
|
119
|
-
if (schema.$recursiveRef && schema.__absolute_recursive_ref__ === undefined) {
|
|
120
|
-
const url = new URL(schema.$recursiveRef, baseURI.href);
|
|
121
|
-
url.hash = url.hash; // normalize hash https://url.spec.whatwg.org/#dom-url-hash
|
|
122
|
-
Object.defineProperty(schema, "__absolute_recursive_ref__", {
|
|
123
|
-
enumerable: false,
|
|
124
|
-
value: url.href,
|
|
125
|
-
});
|
|
126
|
-
}
|
|
127
|
-
// if an $anchor is found, compute it's URI and add it to the mapping.
|
|
128
|
-
if (schema.$anchor) {
|
|
129
|
-
const url = new URL("#" + schema.$anchor, baseURI.href);
|
|
130
|
-
lookup[url.href] = schema;
|
|
131
|
-
}
|
|
132
|
-
// process subschemas.
|
|
133
|
-
for (let key in schema) {
|
|
134
|
-
if (ignoredKeyword[key]) {
|
|
135
|
-
continue;
|
|
136
|
-
}
|
|
137
|
-
const keyBase = `${basePointer}/${encodePointer(key)}`;
|
|
138
|
-
const subSchema = schema[key];
|
|
139
|
-
if (Array.isArray(subSchema)) {
|
|
140
|
-
if (schemaArrayKeyword[key]) {
|
|
141
|
-
const length = subSchema.length;
|
|
142
|
-
for (let i = 0; i < length; i++) {
|
|
143
|
-
dereference(subSchema[i], lookup, baseURI, `${keyBase}/${i}`);
|
|
144
|
-
}
|
|
145
|
-
}
|
|
146
|
-
}
|
|
147
|
-
else if (schemaMapKeyword[key]) {
|
|
148
|
-
for (let subKey in subSchema) {
|
|
149
|
-
dereference(subSchema[subKey], lookup, baseURI, `${keyBase}/${encodePointer(subKey)}`);
|
|
150
|
-
}
|
|
151
|
-
}
|
|
152
|
-
else {
|
|
153
|
-
dereference(subSchema, lookup, baseURI, keyBase);
|
|
154
|
-
}
|
|
155
|
-
}
|
|
156
|
-
return lookup;
|
|
157
|
-
}
|
|
158
|
-
// schema identification examples
|
|
159
|
-
// https://json-schema.org/draft/2019-09/json-schema-core.html#rfc.appendix.A
|
|
160
|
-
// $ref delegation
|
|
161
|
-
// https://github.com/json-schema-org/json-schema-spec/issues/514
|
|
162
|
-
// output format
|
|
163
|
-
// https://json-schema.org/draft/2019-09/json-schema-core.html#output
|
|
164
|
-
// JSON pointer
|
|
165
|
-
// https://tools.ietf.org/html/rfc6901
|
|
166
|
-
// JSON relative pointer
|
|
167
|
-
// https://tools.ietf.org/html/draft-handrews-relative-json-pointer-01
|
|
@@ -1,139 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
// based on https://github.com/epoberezkin/ajv/blob/master/lib/compile/formats.js
|
|
3
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
-
exports.fastFormat = exports.fullFormat = void 0;
|
|
5
|
-
const DATE = /^(\d\d\d\d)-(\d\d)-(\d\d)$/;
|
|
6
|
-
const DAYS = [0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31];
|
|
7
|
-
const TIME = /^(\d\d):(\d\d):(\d\d)(\.\d+)?(z|[+-]\d\d(?::?\d\d)?)?$/i;
|
|
8
|
-
const HOSTNAME = /^(?=.{1,253}\.?$)[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?(?:\.[a-z0-9](?:[-0-9a-z]{0,61}[0-9a-z])?)*\.?$/i;
|
|
9
|
-
// const URI = /^(?:[a-z][a-z0-9+\-.]*:)(?:\/?\/(?:(?:[a-z0-9\-._~!$&'()*+,;=:]|%[0-9a-f]{2})*@)?(?:\[(?:(?:(?:(?:[0-9a-f]{1,4}:){6}|::(?:[0-9a-f]{1,4}:){5}|(?:[0-9a-f]{1,4})?::(?:[0-9a-f]{1,4}:){4}|(?:(?:[0-9a-f]{1,4}:){0,1}[0-9a-f]{1,4})?::(?:[0-9a-f]{1,4}:){3}|(?:(?:[0-9a-f]{1,4}:){0,2}[0-9a-f]{1,4})?::(?:[0-9a-f]{1,4}:){2}|(?:(?:[0-9a-f]{1,4}:){0,3}[0-9a-f]{1,4})?::[0-9a-f]{1,4}:|(?:(?:[0-9a-f]{1,4}:){0,4}[0-9a-f]{1,4})?::)(?:[0-9a-f]{1,4}:[0-9a-f]{1,4}|(?:(?:25[0-5]|2[0-4]\d|[01]?\d\d?)\.){3}(?:25[0-5]|2[0-4]\d|[01]?\d\d?))|(?:(?:[0-9a-f]{1,4}:){0,5}[0-9a-f]{1,4})?::[0-9a-f]{1,4}|(?:(?:[0-9a-f]{1,4}:){0,6}[0-9a-f]{1,4})?::)|[Vv][0-9a-f]+\.[a-z0-9\-._~!$&'()*+,;=:]+)\]|(?:(?:25[0-5]|2[0-4]\d|[01]?\d\d?)\.){3}(?:25[0-5]|2[0-4]\d|[01]?\d\d?)|(?:[a-z0-9\-._~!$&'()*+,;=]|%[0-9a-f]{2})*)(?::\d*)?(?:\/(?:[a-z0-9\-._~!$&'()*+,;=:@]|%[0-9a-f]{2})*)*|\/(?:(?:[a-z0-9\-._~!$&'()*+,;=:@]|%[0-9a-f]{2})+(?:\/(?:[a-z0-9\-._~!$&'()*+,;=:@]|%[0-9a-f]{2})*)*)?|(?:[a-z0-9\-._~!$&'()*+,;=:@]|%[0-9a-f]{2})+(?:\/(?:[a-z0-9\-._~!$&'()*+,;=:@]|%[0-9a-f]{2})*)*)(?:\?(?:[a-z0-9\-._~!$&'()*+,;=:@/?]|%[0-9a-f]{2})*)?(?:#(?:[a-z0-9\-._~!$&'()*+,;=:@/?]|%[0-9a-f]{2})*)?$/i;
|
|
10
|
-
const URIREF = /^(?:[a-z][a-z0-9+\-.]*:)?(?:\/?\/(?:(?:[a-z0-9\-._~!$&'()*+,;=:]|%[0-9a-f]{2})*@)?(?:\[(?:(?:(?:(?:[0-9a-f]{1,4}:){6}|::(?:[0-9a-f]{1,4}:){5}|(?:[0-9a-f]{1,4})?::(?:[0-9a-f]{1,4}:){4}|(?:(?:[0-9a-f]{1,4}:){0,1}[0-9a-f]{1,4})?::(?:[0-9a-f]{1,4}:){3}|(?:(?:[0-9a-f]{1,4}:){0,2}[0-9a-f]{1,4})?::(?:[0-9a-f]{1,4}:){2}|(?:(?:[0-9a-f]{1,4}:){0,3}[0-9a-f]{1,4})?::[0-9a-f]{1,4}:|(?:(?:[0-9a-f]{1,4}:){0,4}[0-9a-f]{1,4})?::)(?:[0-9a-f]{1,4}:[0-9a-f]{1,4}|(?:(?:25[0-5]|2[0-4]\d|[01]?\d\d?)\.){3}(?:25[0-5]|2[0-4]\d|[01]?\d\d?))|(?:(?:[0-9a-f]{1,4}:){0,5}[0-9a-f]{1,4})?::[0-9a-f]{1,4}|(?:(?:[0-9a-f]{1,4}:){0,6}[0-9a-f]{1,4})?::)|[Vv][0-9a-f]+\.[a-z0-9\-._~!$&'()*+,;=:]+)\]|(?:(?:25[0-5]|2[0-4]\d|[01]?\d\d?)\.){3}(?:25[0-5]|2[0-4]\d|[01]?\d\d?)|(?:[a-z0-9\-._~!$&'"()*+,;=]|%[0-9a-f]{2})*)(?::\d*)?(?:\/(?:[a-z0-9\-._~!$&'"()*+,;=:@]|%[0-9a-f]{2})*)*|\/(?:(?:[a-z0-9\-._~!$&'"()*+,;=:@]|%[0-9a-f]{2})+(?:\/(?:[a-z0-9\-._~!$&'"()*+,;=:@]|%[0-9a-f]{2})*)*)?|(?:[a-z0-9\-._~!$&'"()*+,;=:@]|%[0-9a-f]{2})+(?:\/(?:[a-z0-9\-._~!$&'"()*+,;=:@]|%[0-9a-f]{2})*)*)?(?:\?(?:[a-z0-9\-._~!$&'"()*+,;=:@/?]|%[0-9a-f]{2})*)?(?:#(?:[a-z0-9\-._~!$&'"()*+,;=:@/?]|%[0-9a-f]{2})*)?$/i;
|
|
11
|
-
// uri-template: https://tools.ietf.org/html/rfc6570
|
|
12
|
-
const URITEMPLATE = /^(?:(?:[^\x00-\x20"'<>%\\^`{|}]|%[0-9a-f]{2})|\{[+#./;?&=,!@|]?(?:[a-z0-9_]|%[0-9a-f]{2})+(?::[1-9][0-9]{0,3}|\*)?(?:,(?:[a-z0-9_]|%[0-9a-f]{2})+(?::[1-9][0-9]{0,3}|\*)?)*\})*$/i;
|
|
13
|
-
// For the source: https://gist.github.com/dperini/729294
|
|
14
|
-
// For test cases: https://mathiasbynens.be/demo/url-regex
|
|
15
|
-
const URL_ = /^(?:(?:https?|ftp):\/\/)(?:\S+(?::\S*)?@)?(?:(?!10(?:\.\d{1,3}){3})(?!127(?:\.\d{1,3}){3})(?!169\.254(?:\.\d{1,3}){2})(?!192\.168(?:\.\d{1,3}){2})(?!172\.(?:1[6-9]|2\d|3[0-1])(?:\.\d{1,3}){2})(?:[1-9]\d?|1\d\d|2[01]\d|22[0-3])(?:\.(?:1?\d{1,2}|2[0-4]\d|25[0-5])){2}(?:\.(?:[1-9]\d?|1\d\d|2[0-4]\d|25[0-4]))|(?:(?:[a-z\u{00a1}-\u{ffff}0-9]+-?)*[a-z\u{00a1}-\u{ffff}0-9]+)(?:\.(?:[a-z\u{00a1}-\u{ffff}0-9]+-?)*[a-z\u{00a1}-\u{ffff}0-9]+)*(?:\.(?:[a-z\u{00a1}-\u{ffff}]{2,})))(?::\d{2,5})?(?:\/[^\s]*)?$/iu;
|
|
16
|
-
const UUID = /^(?:urn:uuid:)?[0-9a-f]{8}-(?:[0-9a-f]{4}-){3}[0-9a-f]{12}$/i;
|
|
17
|
-
const JSON_POINTER = /^(?:\/(?:[^~/]|~0|~1)*)*$/;
|
|
18
|
-
const JSON_POINTER_URI_FRAGMENT = /^#(?:\/(?:[a-z0-9_\-.!$&'()*+,;:=@]|%[0-9a-f]{2}|~0|~1)*)*$/i;
|
|
19
|
-
const RELATIVE_JSON_POINTER = /^(?:0|[1-9][0-9]*)(?:#|(?:\/(?:[^~/]|~0|~1)*)*)$/;
|
|
20
|
-
// date: http://tools.ietf.org/html/rfc3339#section-5.6
|
|
21
|
-
const FASTDATE = /^\d\d\d\d-[0-1]\d-[0-3]\d$/;
|
|
22
|
-
// date-time: http://tools.ietf.org/html/rfc3339#section-5.6
|
|
23
|
-
const FASTTIME = /^(?:[0-2]\d:[0-5]\d:[0-5]\d|23:59:60)(?:\.\d+)?(?:z|[+-]\d\d(?::?\d\d)?)?$/i;
|
|
24
|
-
const FASTDATETIME = /^\d\d\d\d-[0-1]\d-[0-3]\d[t\s](?:[0-2]\d:[0-5]\d:[0-5]\d|23:59:60)(?:\.\d+)?(?:z|[+-]\d\d(?::?\d\d)?)$/i;
|
|
25
|
-
// uri: https://github.com/mafintosh/is-my-json-valid/blob/master/formats.js
|
|
26
|
-
// const FASTURI = /^(?:[a-z][a-z0-9+-.]*:)(?:\/?\/)?[^\s]*$/i;
|
|
27
|
-
const FASTURIREFERENCE = /^(?:(?:[a-z][a-z0-9+-.]*:)?\/?\/)?(?:[^\\\s#][^\s#]*)?(?:#[^\\\s]*)?$/i;
|
|
28
|
-
// https://github.com/ExodusMovement/schemasafe/blob/master/src/formats.js
|
|
29
|
-
const EMAIL = (input) => {
|
|
30
|
-
if (input[0] === '"')
|
|
31
|
-
return false;
|
|
32
|
-
const [name, host, ...rest] = input.split("@");
|
|
33
|
-
if (!name ||
|
|
34
|
-
!host ||
|
|
35
|
-
rest.length !== 0 ||
|
|
36
|
-
name.length > 64 ||
|
|
37
|
-
host.length > 253)
|
|
38
|
-
return false;
|
|
39
|
-
if (name[0] === "." || name.endsWith(".") || name.includes(".."))
|
|
40
|
-
return false;
|
|
41
|
-
if (!/^[a-z0-9.-]+$/i.test(host) ||
|
|
42
|
-
!/^[a-z0-9.!#$%&'*+/=?^_`{|}~-]+$/i.test(name))
|
|
43
|
-
return false;
|
|
44
|
-
return host
|
|
45
|
-
.split(".")
|
|
46
|
-
.every((part) => /^[a-z0-9]([a-z0-9-]{0,61}[a-z0-9])?$/i.test(part));
|
|
47
|
-
};
|
|
48
|
-
// optimized https://www.safaribooksonline.com/library/view/regular-expressions-cookbook/9780596802837/ch07s16.html
|
|
49
|
-
const IPV4 = /^(?:(?:25[0-5]|2[0-4]\d|[01]?\d\d?)\.){3}(?:25[0-5]|2[0-4]\d|[01]?\d\d?)$/;
|
|
50
|
-
// optimized http://stackoverflow.com/questions/53497/regular-expression-that-matches-valid-ipv6-addresses
|
|
51
|
-
const IPV6 = /^((([0-9a-f]{1,4}:){7}([0-9a-f]{1,4}|:))|(([0-9a-f]{1,4}:){6}(:[0-9a-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-f]{1,4}:){5}(((:[0-9a-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-f]{1,4}:){4}(((:[0-9a-f]{1,4}){1,3})|((:[0-9a-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-f]{1,4}:){3}(((:[0-9a-f]{1,4}){1,4})|((:[0-9a-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-f]{1,4}:){2}(((:[0-9a-f]{1,4}){1,5})|((:[0-9a-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-f]{1,4}:){1}(((:[0-9a-f]{1,4}){1,6})|((:[0-9a-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-f]{1,4}){1,7})|((:[0-9a-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}))|:)))$/i;
|
|
52
|
-
// https://github.com/ExodusMovement/schemasafe/blob/master/src/formats.js
|
|
53
|
-
const DURATION = (input) => input.length > 1 &&
|
|
54
|
-
input.length < 80 &&
|
|
55
|
-
(/^P\d+([.,]\d+)?W$/.test(input) ||
|
|
56
|
-
(/^P[\dYMDTHS]*(\d[.,]\d+)?[YMDHS]$/.test(input) &&
|
|
57
|
-
/^P([.,\d]+Y)?([.,\d]+M)?([.,\d]+D)?(T([.,\d]+H)?([.,\d]+M)?([.,\d]+S)?)?$/.test(input)));
|
|
58
|
-
function bind(r) {
|
|
59
|
-
return r.test.bind(r);
|
|
60
|
-
}
|
|
61
|
-
exports.fullFormat = {
|
|
62
|
-
date,
|
|
63
|
-
time: /* #__PURE__ */ time.bind(undefined, false),
|
|
64
|
-
"date-time": date_time,
|
|
65
|
-
duration: DURATION,
|
|
66
|
-
uri,
|
|
67
|
-
"uri-reference": /* #__PURE__ */ bind(URIREF),
|
|
68
|
-
"uri-template": /* #__PURE__ */ bind(URITEMPLATE),
|
|
69
|
-
url: /* #__PURE__ */ bind(URL_),
|
|
70
|
-
email: EMAIL,
|
|
71
|
-
hostname: /* #__PURE__ */ bind(HOSTNAME),
|
|
72
|
-
ipv4: /* #__PURE__ */ bind(IPV4),
|
|
73
|
-
ipv6: /* #__PURE__ */ bind(IPV6),
|
|
74
|
-
regex: regex,
|
|
75
|
-
uuid: /* #__PURE__ */ bind(UUID),
|
|
76
|
-
"json-pointer": /* #__PURE__ */ bind(JSON_POINTER),
|
|
77
|
-
"json-pointer-uri-fragment": /* #__PURE__ */ bind(JSON_POINTER_URI_FRAGMENT),
|
|
78
|
-
"relative-json-pointer": /* #__PURE__ */ bind(RELATIVE_JSON_POINTER),
|
|
79
|
-
};
|
|
80
|
-
exports.fastFormat = {
|
|
81
|
-
...exports.fullFormat,
|
|
82
|
-
date: /* #__PURE__ */ bind(FASTDATE),
|
|
83
|
-
time: /* #__PURE__ */ bind(FASTTIME),
|
|
84
|
-
"date-time": /* #__PURE__ */ bind(FASTDATETIME),
|
|
85
|
-
"uri-reference": /* #__PURE__ */ bind(FASTURIREFERENCE),
|
|
86
|
-
};
|
|
87
|
-
function isLeapYear(year) {
|
|
88
|
-
// https://tools.ietf.org/html/rfc3339#appendix-C
|
|
89
|
-
return year % 4 === 0 && (year % 100 !== 0 || year % 400 === 0);
|
|
90
|
-
}
|
|
91
|
-
function date(str) {
|
|
92
|
-
// full-date from http://tools.ietf.org/html/rfc3339#section-5.6
|
|
93
|
-
const matches = str.match(DATE);
|
|
94
|
-
if (!matches)
|
|
95
|
-
return false;
|
|
96
|
-
const year = +matches[1];
|
|
97
|
-
const month = +matches[2];
|
|
98
|
-
const day = +matches[3];
|
|
99
|
-
return (month >= 1 &&
|
|
100
|
-
month <= 12 &&
|
|
101
|
-
day >= 1 &&
|
|
102
|
-
day <= (month == 2 && isLeapYear(year) ? 29 : DAYS[month]));
|
|
103
|
-
}
|
|
104
|
-
function time(full, str) {
|
|
105
|
-
const matches = str.match(TIME);
|
|
106
|
-
if (!matches)
|
|
107
|
-
return false;
|
|
108
|
-
const hour = +matches[1];
|
|
109
|
-
const minute = +matches[2];
|
|
110
|
-
const second = +matches[3];
|
|
111
|
-
const timeZone = !!matches[5];
|
|
112
|
-
return (((hour <= 23 && minute <= 59 && second <= 59) ||
|
|
113
|
-
(hour == 23 && minute == 59 && second == 60)) &&
|
|
114
|
-
(!full || timeZone));
|
|
115
|
-
}
|
|
116
|
-
const DATE_TIME_SEPARATOR = /t|\s/i;
|
|
117
|
-
function date_time(str) {
|
|
118
|
-
// http://tools.ietf.org/html/rfc3339#section-5.6
|
|
119
|
-
const dateTime = str.split(DATE_TIME_SEPARATOR);
|
|
120
|
-
return dateTime.length == 2 && date(dateTime[0]) && time(true, dateTime[1]);
|
|
121
|
-
}
|
|
122
|
-
const NOT_URI_FRAGMENT = /\/|:/;
|
|
123
|
-
const URI_PATTERN = /^(?:[a-z][a-z0-9+\-.]*:)(?:\/?\/(?:(?:[a-z0-9\-._~!$&'()*+,;=:]|%[0-9a-f]{2})*@)?(?:\[(?:(?:(?:(?:[0-9a-f]{1,4}:){6}|::(?:[0-9a-f]{1,4}:){5}|(?:[0-9a-f]{1,4})?::(?:[0-9a-f]{1,4}:){4}|(?:(?:[0-9a-f]{1,4}:){0,1}[0-9a-f]{1,4})?::(?:[0-9a-f]{1,4}:){3}|(?:(?:[0-9a-f]{1,4}:){0,2}[0-9a-f]{1,4})?::(?:[0-9a-f]{1,4}:){2}|(?:(?:[0-9a-f]{1,4}:){0,3}[0-9a-f]{1,4})?::[0-9a-f]{1,4}:|(?:(?:[0-9a-f]{1,4}:){0,4}[0-9a-f]{1,4})?::)(?:[0-9a-f]{1,4}:[0-9a-f]{1,4}|(?:(?:25[0-5]|2[0-4]\d|[01]?\d\d?)\.){3}(?:25[0-5]|2[0-4]\d|[01]?\d\d?))|(?:(?:[0-9a-f]{1,4}:){0,5}[0-9a-f]{1,4})?::[0-9a-f]{1,4}|(?:(?:[0-9a-f]{1,4}:){0,6}[0-9a-f]{1,4})?::)|[Vv][0-9a-f]+\.[a-z0-9\-._~!$&'()*+,;=:]+)\]|(?:(?:25[0-5]|2[0-4]\d|[01]?\d\d?)\.){3}(?:25[0-5]|2[0-4]\d|[01]?\d\d?)|(?:[a-z0-9\-._~!$&'()*+,;=]|%[0-9a-f]{2})*)(?::\d*)?(?:\/(?:[a-z0-9\-._~!$&'()*+,;=:@]|%[0-9a-f]{2})*)*|\/(?:(?:[a-z0-9\-._~!$&'()*+,;=:@]|%[0-9a-f]{2})+(?:\/(?:[a-z0-9\-._~!$&'()*+,;=:@]|%[0-9a-f]{2})*)*)?|(?:[a-z0-9\-._~!$&'()*+,;=:@]|%[0-9a-f]{2})+(?:\/(?:[a-z0-9\-._~!$&'()*+,;=:@]|%[0-9a-f]{2})*)*)(?:\?(?:[a-z0-9\-._~!$&'()*+,;=:@/?]|%[0-9a-f]{2})*)?(?:#(?:[a-z0-9\-._~!$&'()*+,;=:@/?]|%[0-9a-f]{2})*)?$/i;
|
|
124
|
-
function uri(str) {
|
|
125
|
-
// http://jmrware.com/articles/2009/uri_regexp/URI_regex.html + optional protocol + required "."
|
|
126
|
-
return NOT_URI_FRAGMENT.test(str) && URI_PATTERN.test(str);
|
|
127
|
-
}
|
|
128
|
-
const Z_ANCHOR = /[^\\]\\Z/;
|
|
129
|
-
function regex(str) {
|
|
130
|
-
if (Z_ANCHOR.test(str))
|
|
131
|
-
return false;
|
|
132
|
-
try {
|
|
133
|
-
new RegExp(str);
|
|
134
|
-
return true;
|
|
135
|
-
}
|
|
136
|
-
catch (e) {
|
|
137
|
-
return false;
|
|
138
|
-
}
|
|
139
|
-
}
|
|
@@ -1,136 +0,0 @@
|
|
|
1
|
-
// based on https://github.com/epoberezkin/ajv/blob/master/lib/compile/formats.js
|
|
2
|
-
const DATE = /^(\d\d\d\d)-(\d\d)-(\d\d)$/;
|
|
3
|
-
const DAYS = [0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31];
|
|
4
|
-
const TIME = /^(\d\d):(\d\d):(\d\d)(\.\d+)?(z|[+-]\d\d(?::?\d\d)?)?$/i;
|
|
5
|
-
const HOSTNAME = /^(?=.{1,253}\.?$)[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?(?:\.[a-z0-9](?:[-0-9a-z]{0,61}[0-9a-z])?)*\.?$/i;
|
|
6
|
-
// const URI = /^(?:[a-z][a-z0-9+\-.]*:)(?:\/?\/(?:(?:[a-z0-9\-._~!$&'()*+,;=:]|%[0-9a-f]{2})*@)?(?:\[(?:(?:(?:(?:[0-9a-f]{1,4}:){6}|::(?:[0-9a-f]{1,4}:){5}|(?:[0-9a-f]{1,4})?::(?:[0-9a-f]{1,4}:){4}|(?:(?:[0-9a-f]{1,4}:){0,1}[0-9a-f]{1,4})?::(?:[0-9a-f]{1,4}:){3}|(?:(?:[0-9a-f]{1,4}:){0,2}[0-9a-f]{1,4})?::(?:[0-9a-f]{1,4}:){2}|(?:(?:[0-9a-f]{1,4}:){0,3}[0-9a-f]{1,4})?::[0-9a-f]{1,4}:|(?:(?:[0-9a-f]{1,4}:){0,4}[0-9a-f]{1,4})?::)(?:[0-9a-f]{1,4}:[0-9a-f]{1,4}|(?:(?:25[0-5]|2[0-4]\d|[01]?\d\d?)\.){3}(?:25[0-5]|2[0-4]\d|[01]?\d\d?))|(?:(?:[0-9a-f]{1,4}:){0,5}[0-9a-f]{1,4})?::[0-9a-f]{1,4}|(?:(?:[0-9a-f]{1,4}:){0,6}[0-9a-f]{1,4})?::)|[Vv][0-9a-f]+\.[a-z0-9\-._~!$&'()*+,;=:]+)\]|(?:(?:25[0-5]|2[0-4]\d|[01]?\d\d?)\.){3}(?:25[0-5]|2[0-4]\d|[01]?\d\d?)|(?:[a-z0-9\-._~!$&'()*+,;=]|%[0-9a-f]{2})*)(?::\d*)?(?:\/(?:[a-z0-9\-._~!$&'()*+,;=:@]|%[0-9a-f]{2})*)*|\/(?:(?:[a-z0-9\-._~!$&'()*+,;=:@]|%[0-9a-f]{2})+(?:\/(?:[a-z0-9\-._~!$&'()*+,;=:@]|%[0-9a-f]{2})*)*)?|(?:[a-z0-9\-._~!$&'()*+,;=:@]|%[0-9a-f]{2})+(?:\/(?:[a-z0-9\-._~!$&'()*+,;=:@]|%[0-9a-f]{2})*)*)(?:\?(?:[a-z0-9\-._~!$&'()*+,;=:@/?]|%[0-9a-f]{2})*)?(?:#(?:[a-z0-9\-._~!$&'()*+,;=:@/?]|%[0-9a-f]{2})*)?$/i;
|
|
7
|
-
const URIREF = /^(?:[a-z][a-z0-9+\-.]*:)?(?:\/?\/(?:(?:[a-z0-9\-._~!$&'()*+,;=:]|%[0-9a-f]{2})*@)?(?:\[(?:(?:(?:(?:[0-9a-f]{1,4}:){6}|::(?:[0-9a-f]{1,4}:){5}|(?:[0-9a-f]{1,4})?::(?:[0-9a-f]{1,4}:){4}|(?:(?:[0-9a-f]{1,4}:){0,1}[0-9a-f]{1,4})?::(?:[0-9a-f]{1,4}:){3}|(?:(?:[0-9a-f]{1,4}:){0,2}[0-9a-f]{1,4})?::(?:[0-9a-f]{1,4}:){2}|(?:(?:[0-9a-f]{1,4}:){0,3}[0-9a-f]{1,4})?::[0-9a-f]{1,4}:|(?:(?:[0-9a-f]{1,4}:){0,4}[0-9a-f]{1,4})?::)(?:[0-9a-f]{1,4}:[0-9a-f]{1,4}|(?:(?:25[0-5]|2[0-4]\d|[01]?\d\d?)\.){3}(?:25[0-5]|2[0-4]\d|[01]?\d\d?))|(?:(?:[0-9a-f]{1,4}:){0,5}[0-9a-f]{1,4})?::[0-9a-f]{1,4}|(?:(?:[0-9a-f]{1,4}:){0,6}[0-9a-f]{1,4})?::)|[Vv][0-9a-f]+\.[a-z0-9\-._~!$&'()*+,;=:]+)\]|(?:(?:25[0-5]|2[0-4]\d|[01]?\d\d?)\.){3}(?:25[0-5]|2[0-4]\d|[01]?\d\d?)|(?:[a-z0-9\-._~!$&'"()*+,;=]|%[0-9a-f]{2})*)(?::\d*)?(?:\/(?:[a-z0-9\-._~!$&'"()*+,;=:@]|%[0-9a-f]{2})*)*|\/(?:(?:[a-z0-9\-._~!$&'"()*+,;=:@]|%[0-9a-f]{2})+(?:\/(?:[a-z0-9\-._~!$&'"()*+,;=:@]|%[0-9a-f]{2})*)*)?|(?:[a-z0-9\-._~!$&'"()*+,;=:@]|%[0-9a-f]{2})+(?:\/(?:[a-z0-9\-._~!$&'"()*+,;=:@]|%[0-9a-f]{2})*)*)?(?:\?(?:[a-z0-9\-._~!$&'"()*+,;=:@/?]|%[0-9a-f]{2})*)?(?:#(?:[a-z0-9\-._~!$&'"()*+,;=:@/?]|%[0-9a-f]{2})*)?$/i;
|
|
8
|
-
// uri-template: https://tools.ietf.org/html/rfc6570
|
|
9
|
-
const URITEMPLATE = /^(?:(?:[^\x00-\x20"'<>%\\^`{|}]|%[0-9a-f]{2})|\{[+#./;?&=,!@|]?(?:[a-z0-9_]|%[0-9a-f]{2})+(?::[1-9][0-9]{0,3}|\*)?(?:,(?:[a-z0-9_]|%[0-9a-f]{2})+(?::[1-9][0-9]{0,3}|\*)?)*\})*$/i;
|
|
10
|
-
// For the source: https://gist.github.com/dperini/729294
|
|
11
|
-
// For test cases: https://mathiasbynens.be/demo/url-regex
|
|
12
|
-
const URL_ = /^(?:(?:https?|ftp):\/\/)(?:\S+(?::\S*)?@)?(?:(?!10(?:\.\d{1,3}){3})(?!127(?:\.\d{1,3}){3})(?!169\.254(?:\.\d{1,3}){2})(?!192\.168(?:\.\d{1,3}){2})(?!172\.(?:1[6-9]|2\d|3[0-1])(?:\.\d{1,3}){2})(?:[1-9]\d?|1\d\d|2[01]\d|22[0-3])(?:\.(?:1?\d{1,2}|2[0-4]\d|25[0-5])){2}(?:\.(?:[1-9]\d?|1\d\d|2[0-4]\d|25[0-4]))|(?:(?:[a-z\u{00a1}-\u{ffff}0-9]+-?)*[a-z\u{00a1}-\u{ffff}0-9]+)(?:\.(?:[a-z\u{00a1}-\u{ffff}0-9]+-?)*[a-z\u{00a1}-\u{ffff}0-9]+)*(?:\.(?:[a-z\u{00a1}-\u{ffff}]{2,})))(?::\d{2,5})?(?:\/[^\s]*)?$/iu;
|
|
13
|
-
const UUID = /^(?:urn:uuid:)?[0-9a-f]{8}-(?:[0-9a-f]{4}-){3}[0-9a-f]{12}$/i;
|
|
14
|
-
const JSON_POINTER = /^(?:\/(?:[^~/]|~0|~1)*)*$/;
|
|
15
|
-
const JSON_POINTER_URI_FRAGMENT = /^#(?:\/(?:[a-z0-9_\-.!$&'()*+,;:=@]|%[0-9a-f]{2}|~0|~1)*)*$/i;
|
|
16
|
-
const RELATIVE_JSON_POINTER = /^(?:0|[1-9][0-9]*)(?:#|(?:\/(?:[^~/]|~0|~1)*)*)$/;
|
|
17
|
-
// date: http://tools.ietf.org/html/rfc3339#section-5.6
|
|
18
|
-
const FASTDATE = /^\d\d\d\d-[0-1]\d-[0-3]\d$/;
|
|
19
|
-
// date-time: http://tools.ietf.org/html/rfc3339#section-5.6
|
|
20
|
-
const FASTTIME = /^(?:[0-2]\d:[0-5]\d:[0-5]\d|23:59:60)(?:\.\d+)?(?:z|[+-]\d\d(?::?\d\d)?)?$/i;
|
|
21
|
-
const FASTDATETIME = /^\d\d\d\d-[0-1]\d-[0-3]\d[t\s](?:[0-2]\d:[0-5]\d:[0-5]\d|23:59:60)(?:\.\d+)?(?:z|[+-]\d\d(?::?\d\d)?)$/i;
|
|
22
|
-
// uri: https://github.com/mafintosh/is-my-json-valid/blob/master/formats.js
|
|
23
|
-
// const FASTURI = /^(?:[a-z][a-z0-9+-.]*:)(?:\/?\/)?[^\s]*$/i;
|
|
24
|
-
const FASTURIREFERENCE = /^(?:(?:[a-z][a-z0-9+-.]*:)?\/?\/)?(?:[^\\\s#][^\s#]*)?(?:#[^\\\s]*)?$/i;
|
|
25
|
-
// https://github.com/ExodusMovement/schemasafe/blob/master/src/formats.js
|
|
26
|
-
const EMAIL = (input) => {
|
|
27
|
-
if (input[0] === '"')
|
|
28
|
-
return false;
|
|
29
|
-
const [name, host, ...rest] = input.split("@");
|
|
30
|
-
if (!name ||
|
|
31
|
-
!host ||
|
|
32
|
-
rest.length !== 0 ||
|
|
33
|
-
name.length > 64 ||
|
|
34
|
-
host.length > 253)
|
|
35
|
-
return false;
|
|
36
|
-
if (name[0] === "." || name.endsWith(".") || name.includes(".."))
|
|
37
|
-
return false;
|
|
38
|
-
if (!/^[a-z0-9.-]+$/i.test(host) ||
|
|
39
|
-
!/^[a-z0-9.!#$%&'*+/=?^_`{|}~-]+$/i.test(name))
|
|
40
|
-
return false;
|
|
41
|
-
return host
|
|
42
|
-
.split(".")
|
|
43
|
-
.every((part) => /^[a-z0-9]([a-z0-9-]{0,61}[a-z0-9])?$/i.test(part));
|
|
44
|
-
};
|
|
45
|
-
// optimized https://www.safaribooksonline.com/library/view/regular-expressions-cookbook/9780596802837/ch07s16.html
|
|
46
|
-
const IPV4 = /^(?:(?:25[0-5]|2[0-4]\d|[01]?\d\d?)\.){3}(?:25[0-5]|2[0-4]\d|[01]?\d\d?)$/;
|
|
47
|
-
// optimized http://stackoverflow.com/questions/53497/regular-expression-that-matches-valid-ipv6-addresses
|
|
48
|
-
const IPV6 = /^((([0-9a-f]{1,4}:){7}([0-9a-f]{1,4}|:))|(([0-9a-f]{1,4}:){6}(:[0-9a-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-f]{1,4}:){5}(((:[0-9a-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-f]{1,4}:){4}(((:[0-9a-f]{1,4}){1,3})|((:[0-9a-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-f]{1,4}:){3}(((:[0-9a-f]{1,4}){1,4})|((:[0-9a-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-f]{1,4}:){2}(((:[0-9a-f]{1,4}){1,5})|((:[0-9a-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-f]{1,4}:){1}(((:[0-9a-f]{1,4}){1,6})|((:[0-9a-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-f]{1,4}){1,7})|((:[0-9a-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}))|:)))$/i;
|
|
49
|
-
// https://github.com/ExodusMovement/schemasafe/blob/master/src/formats.js
|
|
50
|
-
const DURATION = (input) => input.length > 1 &&
|
|
51
|
-
input.length < 80 &&
|
|
52
|
-
(/^P\d+([.,]\d+)?W$/.test(input) ||
|
|
53
|
-
(/^P[\dYMDTHS]*(\d[.,]\d+)?[YMDHS]$/.test(input) &&
|
|
54
|
-
/^P([.,\d]+Y)?([.,\d]+M)?([.,\d]+D)?(T([.,\d]+H)?([.,\d]+M)?([.,\d]+S)?)?$/.test(input)));
|
|
55
|
-
function bind(r) {
|
|
56
|
-
return r.test.bind(r);
|
|
57
|
-
}
|
|
58
|
-
export const fullFormat = {
|
|
59
|
-
date,
|
|
60
|
-
time: /* #__PURE__ */ time.bind(undefined, false),
|
|
61
|
-
"date-time": date_time,
|
|
62
|
-
duration: DURATION,
|
|
63
|
-
uri,
|
|
64
|
-
"uri-reference": /* #__PURE__ */ bind(URIREF),
|
|
65
|
-
"uri-template": /* #__PURE__ */ bind(URITEMPLATE),
|
|
66
|
-
url: /* #__PURE__ */ bind(URL_),
|
|
67
|
-
email: EMAIL,
|
|
68
|
-
hostname: /* #__PURE__ */ bind(HOSTNAME),
|
|
69
|
-
ipv4: /* #__PURE__ */ bind(IPV4),
|
|
70
|
-
ipv6: /* #__PURE__ */ bind(IPV6),
|
|
71
|
-
regex: regex,
|
|
72
|
-
uuid: /* #__PURE__ */ bind(UUID),
|
|
73
|
-
"json-pointer": /* #__PURE__ */ bind(JSON_POINTER),
|
|
74
|
-
"json-pointer-uri-fragment": /* #__PURE__ */ bind(JSON_POINTER_URI_FRAGMENT),
|
|
75
|
-
"relative-json-pointer": /* #__PURE__ */ bind(RELATIVE_JSON_POINTER),
|
|
76
|
-
};
|
|
77
|
-
export const fastFormat = {
|
|
78
|
-
...fullFormat,
|
|
79
|
-
date: /* #__PURE__ */ bind(FASTDATE),
|
|
80
|
-
time: /* #__PURE__ */ bind(FASTTIME),
|
|
81
|
-
"date-time": /* #__PURE__ */ bind(FASTDATETIME),
|
|
82
|
-
"uri-reference": /* #__PURE__ */ bind(FASTURIREFERENCE),
|
|
83
|
-
};
|
|
84
|
-
function isLeapYear(year) {
|
|
85
|
-
// https://tools.ietf.org/html/rfc3339#appendix-C
|
|
86
|
-
return year % 4 === 0 && (year % 100 !== 0 || year % 400 === 0);
|
|
87
|
-
}
|
|
88
|
-
function date(str) {
|
|
89
|
-
// full-date from http://tools.ietf.org/html/rfc3339#section-5.6
|
|
90
|
-
const matches = str.match(DATE);
|
|
91
|
-
if (!matches)
|
|
92
|
-
return false;
|
|
93
|
-
const year = +matches[1];
|
|
94
|
-
const month = +matches[2];
|
|
95
|
-
const day = +matches[3];
|
|
96
|
-
return (month >= 1 &&
|
|
97
|
-
month <= 12 &&
|
|
98
|
-
day >= 1 &&
|
|
99
|
-
day <= (month == 2 && isLeapYear(year) ? 29 : DAYS[month]));
|
|
100
|
-
}
|
|
101
|
-
function time(full, str) {
|
|
102
|
-
const matches = str.match(TIME);
|
|
103
|
-
if (!matches)
|
|
104
|
-
return false;
|
|
105
|
-
const hour = +matches[1];
|
|
106
|
-
const minute = +matches[2];
|
|
107
|
-
const second = +matches[3];
|
|
108
|
-
const timeZone = !!matches[5];
|
|
109
|
-
return (((hour <= 23 && minute <= 59 && second <= 59) ||
|
|
110
|
-
(hour == 23 && minute == 59 && second == 60)) &&
|
|
111
|
-
(!full || timeZone));
|
|
112
|
-
}
|
|
113
|
-
const DATE_TIME_SEPARATOR = /t|\s/i;
|
|
114
|
-
function date_time(str) {
|
|
115
|
-
// http://tools.ietf.org/html/rfc3339#section-5.6
|
|
116
|
-
const dateTime = str.split(DATE_TIME_SEPARATOR);
|
|
117
|
-
return dateTime.length == 2 && date(dateTime[0]) && time(true, dateTime[1]);
|
|
118
|
-
}
|
|
119
|
-
const NOT_URI_FRAGMENT = /\/|:/;
|
|
120
|
-
const URI_PATTERN = /^(?:[a-z][a-z0-9+\-.]*:)(?:\/?\/(?:(?:[a-z0-9\-._~!$&'()*+,;=:]|%[0-9a-f]{2})*@)?(?:\[(?:(?:(?:(?:[0-9a-f]{1,4}:){6}|::(?:[0-9a-f]{1,4}:){5}|(?:[0-9a-f]{1,4})?::(?:[0-9a-f]{1,4}:){4}|(?:(?:[0-9a-f]{1,4}:){0,1}[0-9a-f]{1,4})?::(?:[0-9a-f]{1,4}:){3}|(?:(?:[0-9a-f]{1,4}:){0,2}[0-9a-f]{1,4})?::(?:[0-9a-f]{1,4}:){2}|(?:(?:[0-9a-f]{1,4}:){0,3}[0-9a-f]{1,4})?::[0-9a-f]{1,4}:|(?:(?:[0-9a-f]{1,4}:){0,4}[0-9a-f]{1,4})?::)(?:[0-9a-f]{1,4}:[0-9a-f]{1,4}|(?:(?:25[0-5]|2[0-4]\d|[01]?\d\d?)\.){3}(?:25[0-5]|2[0-4]\d|[01]?\d\d?))|(?:(?:[0-9a-f]{1,4}:){0,5}[0-9a-f]{1,4})?::[0-9a-f]{1,4}|(?:(?:[0-9a-f]{1,4}:){0,6}[0-9a-f]{1,4})?::)|[Vv][0-9a-f]+\.[a-z0-9\-._~!$&'()*+,;=:]+)\]|(?:(?:25[0-5]|2[0-4]\d|[01]?\d\d?)\.){3}(?:25[0-5]|2[0-4]\d|[01]?\d\d?)|(?:[a-z0-9\-._~!$&'()*+,;=]|%[0-9a-f]{2})*)(?::\d*)?(?:\/(?:[a-z0-9\-._~!$&'()*+,;=:@]|%[0-9a-f]{2})*)*|\/(?:(?:[a-z0-9\-._~!$&'()*+,;=:@]|%[0-9a-f]{2})+(?:\/(?:[a-z0-9\-._~!$&'()*+,;=:@]|%[0-9a-f]{2})*)*)?|(?:[a-z0-9\-._~!$&'()*+,;=:@]|%[0-9a-f]{2})+(?:\/(?:[a-z0-9\-._~!$&'()*+,;=:@]|%[0-9a-f]{2})*)*)(?:\?(?:[a-z0-9\-._~!$&'()*+,;=:@/?]|%[0-9a-f]{2})*)?(?:#(?:[a-z0-9\-._~!$&'()*+,;=:@/?]|%[0-9a-f]{2})*)?$/i;
|
|
121
|
-
function uri(str) {
|
|
122
|
-
// http://jmrware.com/articles/2009/uri_regexp/URI_regex.html + optional protocol + required "."
|
|
123
|
-
return NOT_URI_FRAGMENT.test(str) && URI_PATTERN.test(str);
|
|
124
|
-
}
|
|
125
|
-
const Z_ANCHOR = /[^\\]\\Z/;
|
|
126
|
-
function regex(str) {
|
|
127
|
-
if (Z_ANCHOR.test(str))
|
|
128
|
-
return false;
|
|
129
|
-
try {
|
|
130
|
-
new RegExp(str);
|
|
131
|
-
return true;
|
|
132
|
-
}
|
|
133
|
-
catch (e) {
|
|
134
|
-
return false;
|
|
135
|
-
}
|
|
136
|
-
}
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
-
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
-
};
|
|
16
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
__exportStar(require("./deep-compare-strict.cjs"), exports);
|
|
18
|
-
__exportStar(require("./dereference.cjs"), exports);
|
|
19
|
-
__exportStar(require("./format.cjs"), exports);
|
|
20
|
-
__exportStar(require("./pointer.cjs"), exports);
|
|
21
|
-
__exportStar(require("./types.cjs"), exports);
|
|
22
|
-
__exportStar(require("./ucs2-length.cjs"), exports);
|
|
23
|
-
__exportStar(require("./validate.cjs"), exports);
|
|
24
|
-
__exportStar(require("./validator.cjs"), exports);
|