@langchain/core 0.3.21 → 0.3.23

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (81) hide show
  1. package/dist/callbacks/base.cjs +9 -1
  2. package/dist/callbacks/base.d.ts +1 -0
  3. package/dist/callbacks/base.js +7 -0
  4. package/dist/callbacks/manager.cjs +18 -0
  5. package/dist/callbacks/manager.js +19 -1
  6. package/dist/context.cjs +13 -123
  7. package/dist/context.d.ts +2 -101
  8. package/dist/context.js +9 -119
  9. package/dist/messages/tool.cjs +14 -1
  10. package/dist/messages/tool.d.ts +13 -1
  11. package/dist/messages/tool.js +12 -0
  12. package/dist/output_parsers/transform.cjs +2 -2
  13. package/dist/output_parsers/transform.js +1 -1
  14. package/dist/runnables/base.cjs +2 -2
  15. package/dist/runnables/base.d.ts +1 -2
  16. package/dist/runnables/base.js +3 -3
  17. package/dist/runnables/config.cjs +17 -1
  18. package/dist/runnables/config.d.ts +1 -0
  19. package/dist/runnables/config.js +15 -0
  20. package/dist/runnables/index.cjs +2 -1
  21. package/dist/runnables/index.d.ts +1 -1
  22. package/dist/runnables/index.js +1 -1
  23. package/dist/runnables/iter.cjs +3 -2
  24. package/dist/runnables/iter.d.ts +1 -1
  25. package/dist/runnables/iter.js +3 -2
  26. package/dist/runnables/types.d.ts +1 -1
  27. package/dist/singletons/async_local_storage/context.cjs +189 -0
  28. package/dist/singletons/async_local_storage/context.d.ts +155 -0
  29. package/dist/singletons/async_local_storage/context.js +182 -0
  30. package/dist/singletons/async_local_storage/globals.cjs +2 -1
  31. package/dist/singletons/async_local_storage/globals.d.ts +2 -1
  32. package/dist/singletons/async_local_storage/globals.js +1 -0
  33. package/dist/singletons/async_local_storage/index.cjs +4 -5
  34. package/dist/singletons/async_local_storage/index.d.ts +0 -1
  35. package/dist/singletons/async_local_storage/index.js +1 -2
  36. package/dist/singletons/callbacks.cjs +6 -4
  37. package/dist/singletons/callbacks.js +6 -4
  38. package/dist/singletons/index.cjs +3 -3
  39. package/dist/singletons/index.d.ts +4 -2
  40. package/dist/singletons/index.js +4 -3
  41. package/dist/tools/index.cjs +14 -12
  42. package/dist/tools/index.d.ts +11 -8
  43. package/dist/tools/index.js +16 -14
  44. package/dist/types/stream.d.ts +1 -0
  45. package/dist/utils/json_schema.cjs +3 -3
  46. package/dist/utils/json_schema.d.ts +1 -1
  47. package/dist/utils/json_schema.js +1 -1
  48. package/dist/utils/stream.cjs +3 -2
  49. package/dist/utils/stream.d.ts +2 -1
  50. package/dist/utils/stream.js +3 -2
  51. package/package.json +2 -1
  52. package/dist/utils/@cfworker/json-schema/index.cjs +0 -17
  53. package/dist/utils/@cfworker/json-schema/index.d.ts +0 -1
  54. package/dist/utils/@cfworker/json-schema/index.js +0 -1
  55. package/dist/utils/@cfworker/json-schema/src/deep-compare-strict.cjs +0 -43
  56. package/dist/utils/@cfworker/json-schema/src/deep-compare-strict.d.ts +0 -1
  57. package/dist/utils/@cfworker/json-schema/src/deep-compare-strict.js +0 -39
  58. package/dist/utils/@cfworker/json-schema/src/dereference.cjs +0 -171
  59. package/dist/utils/@cfworker/json-schema/src/dereference.d.ts +0 -12
  60. package/dist/utils/@cfworker/json-schema/src/dereference.js +0 -167
  61. package/dist/utils/@cfworker/json-schema/src/format.cjs +0 -139
  62. package/dist/utils/@cfworker/json-schema/src/format.d.ts +0 -2
  63. package/dist/utils/@cfworker/json-schema/src/format.js +0 -136
  64. package/dist/utils/@cfworker/json-schema/src/index.cjs +0 -24
  65. package/dist/utils/@cfworker/json-schema/src/index.d.ts +0 -8
  66. package/dist/utils/@cfworker/json-schema/src/index.js +0 -8
  67. package/dist/utils/@cfworker/json-schema/src/pointer.cjs +0 -11
  68. package/dist/utils/@cfworker/json-schema/src/pointer.d.ts +0 -2
  69. package/dist/utils/@cfworker/json-schema/src/pointer.js +0 -6
  70. package/dist/utils/@cfworker/json-schema/src/types.d.ts +0 -72
  71. package/dist/utils/@cfworker/json-schema/src/ucs2-length.cjs +0 -28
  72. package/dist/utils/@cfworker/json-schema/src/ucs2-length.d.ts +0 -6
  73. package/dist/utils/@cfworker/json-schema/src/ucs2-length.js +0 -24
  74. package/dist/utils/@cfworker/json-schema/src/validate.cjs +0 -808
  75. package/dist/utils/@cfworker/json-schema/src/validate.d.ts +0 -3
  76. package/dist/utils/@cfworker/json-schema/src/validate.js +0 -804
  77. package/dist/utils/@cfworker/json-schema/src/validator.cjs +0 -44
  78. package/dist/utils/@cfworker/json-schema/src/validator.d.ts +0 -10
  79. package/dist/utils/@cfworker/json-schema/src/validator.js +0 -40
  80. /package/dist/{utils/@cfworker/json-schema/src/types.cjs → types/stream.cjs} +0 -0
  81. /package/dist/{utils/@cfworker/json-schema/src/types.js → types/stream.js} +0 -0
@@ -1,17 +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("./src/index.cjs"), exports);
@@ -1 +0,0 @@
1
- export * from "./src/index.js";
@@ -1 +0,0 @@
1
- export * from "./src/index.js";
@@ -1,43 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.deepCompareStrict = void 0;
4
- function deepCompareStrict(a, b) {
5
- const typeofa = typeof a;
6
- if (typeofa !== typeof b) {
7
- return false;
8
- }
9
- if (Array.isArray(a)) {
10
- if (!Array.isArray(b)) {
11
- return false;
12
- }
13
- const length = a.length;
14
- if (length !== b.length) {
15
- return false;
16
- }
17
- for (let i = 0; i < length; i++) {
18
- if (!deepCompareStrict(a[i], b[i])) {
19
- return false;
20
- }
21
- }
22
- return true;
23
- }
24
- if (typeofa === "object") {
25
- if (!a || !b) {
26
- return a === b;
27
- }
28
- const aKeys = Object.keys(a);
29
- const bKeys = Object.keys(b);
30
- const length = aKeys.length;
31
- if (length !== bKeys.length) {
32
- return false;
33
- }
34
- for (const k of aKeys) {
35
- if (!deepCompareStrict(a[k], b[k])) {
36
- return false;
37
- }
38
- }
39
- return true;
40
- }
41
- return a === b;
42
- }
43
- exports.deepCompareStrict = deepCompareStrict;
@@ -1 +0,0 @@
1
- export declare function deepCompareStrict(a: any, b: any): boolean;
@@ -1,39 +0,0 @@
1
- export function deepCompareStrict(a, b) {
2
- const typeofa = typeof a;
3
- if (typeofa !== typeof b) {
4
- return false;
5
- }
6
- if (Array.isArray(a)) {
7
- if (!Array.isArray(b)) {
8
- return false;
9
- }
10
- const length = a.length;
11
- if (length !== b.length) {
12
- return false;
13
- }
14
- for (let i = 0; i < length; i++) {
15
- if (!deepCompareStrict(a[i], b[i])) {
16
- return false;
17
- }
18
- }
19
- return true;
20
- }
21
- if (typeofa === "object") {
22
- if (!a || !b) {
23
- return a === b;
24
- }
25
- const aKeys = Object.keys(a);
26
- const bKeys = Object.keys(b);
27
- const length = aKeys.length;
28
- if (length !== bKeys.length) {
29
- return false;
30
- }
31
- for (const k of aKeys) {
32
- if (!deepCompareStrict(a[k], b[k])) {
33
- return false;
34
- }
35
- }
36
- return true;
37
- }
38
- return a === b;
39
- }
@@ -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,2 +0,0 @@
1
- export declare const fullFormat: Record<string, (s: string) => boolean>;
2
- export declare const fastFormat: Record<string, (s: string) => boolean>;