langchain 0.0.194 → 0.0.196

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 (241) hide show
  1. package/dist/agents/toolkits/conversational_retrieval/token_buffer_memory.d.ts +1 -1
  2. package/dist/base_language/count_tokens.cjs +5 -70
  3. package/dist/base_language/count_tokens.d.ts +1 -10
  4. package/dist/base_language/count_tokens.js +1 -65
  5. package/dist/base_language/index.cjs +6 -196
  6. package/dist/base_language/index.d.ts +1 -111
  7. package/dist/base_language/index.js +1 -191
  8. package/dist/cache/base.cjs +15 -37
  9. package/dist/cache/base.d.ts +1 -20
  10. package/dist/cache/base.js +1 -33
  11. package/dist/cache/index.cjs +2 -46
  12. package/dist/cache/index.d.ts +1 -29
  13. package/dist/cache/index.js +1 -45
  14. package/dist/callbacks/base.cjs +3 -139
  15. package/dist/callbacks/base.d.ts +1 -266
  16. package/dist/callbacks/base.js +1 -126
  17. package/dist/callbacks/handlers/console.cjs +14 -221
  18. package/dist/callbacks/handlers/console.d.ts +1 -117
  19. package/dist/callbacks/handlers/console.js +1 -217
  20. package/dist/callbacks/handlers/initialize.cjs +15 -30
  21. package/dist/callbacks/handlers/initialize.d.ts +1 -16
  22. package/dist/callbacks/handlers/initialize.js +1 -27
  23. package/dist/callbacks/handlers/log_stream.cjs +15 -293
  24. package/dist/callbacks/handlers/log_stream.d.ts +1 -100
  25. package/dist/callbacks/handlers/log_stream.js +1 -289
  26. package/dist/callbacks/handlers/run_collector.cjs +15 -48
  27. package/dist/callbacks/handlers/run_collector.d.ts +1 -26
  28. package/dist/callbacks/handlers/run_collector.js +1 -46
  29. package/dist/callbacks/handlers/tracer.cjs +15 -375
  30. package/dist/callbacks/handlers/tracer.d.ts +1 -70
  31. package/dist/callbacks/handlers/tracer.js +1 -373
  32. package/dist/callbacks/handlers/tracer_langchain.cjs +15 -104
  33. package/dist/callbacks/handlers/tracer_langchain.d.ts +1 -41
  34. package/dist/callbacks/handlers/tracer_langchain.js +1 -102
  35. package/dist/callbacks/handlers/tracer_langchain_v1.cjs +15 -197
  36. package/dist/callbacks/handlers/tracer_langchain_v1.d.ts +1 -57
  37. package/dist/callbacks/handlers/tracer_langchain_v1.js +1 -195
  38. package/dist/callbacks/manager.cjs +15 -676
  39. package/dist/callbacks/manager.d.ts +1 -180
  40. package/dist/callbacks/manager.js +1 -666
  41. package/dist/callbacks/promises.cjs +14 -42
  42. package/dist/callbacks/promises.d.ts +1 -11
  43. package/dist/callbacks/promises.js +1 -37
  44. package/dist/chains/graph_qa/prompts.d.ts +1 -1
  45. package/dist/chains/openai_functions/structured_output.cjs +2 -2
  46. package/dist/chains/openai_functions/structured_output.d.ts +1 -1
  47. package/dist/chains/openai_functions/structured_output.js +1 -1
  48. package/dist/chat_models/baiduwenxin.d.ts +1 -1
  49. package/dist/chat_models/base.cjs +15 -296
  50. package/dist/chat_models/base.d.ts +1 -122
  51. package/dist/chat_models/base.js +1 -292
  52. package/dist/chat_models/bedrock/web.d.ts +1 -1
  53. package/dist/chat_models/fireworks.d.ts +1 -1
  54. package/dist/document.cjs +2 -24
  55. package/dist/document.d.ts +1 -12
  56. package/dist/document.js +1 -23
  57. package/dist/document_loaders/web/azure_blob_storage_file.d.ts +1 -1
  58. package/dist/document_loaders/web/s3.d.ts +1 -1
  59. package/dist/embeddings/base.cjs +15 -22
  60. package/dist/embeddings/base.d.ts +1 -33
  61. package/dist/embeddings/base.js +1 -20
  62. package/dist/embeddings/cache_backed.cjs +2 -2
  63. package/dist/embeddings/cache_backed.js +1 -1
  64. package/dist/embeddings/hf.cjs +1 -2
  65. package/dist/embeddings/hf.js +1 -2
  66. package/dist/evaluation/agents/trajectory.d.ts +1 -1
  67. package/dist/evaluation/criteria/prompt.d.ts +2 -2
  68. package/dist/evaluation/qa/prompt.d.ts +2 -2
  69. package/dist/experimental/hubs/makersuite/googlemakersuitehub.d.ts +1 -1
  70. package/dist/experimental/openai_assistant/index.cjs +2 -1
  71. package/dist/experimental/openai_assistant/index.d.ts +2 -1
  72. package/dist/experimental/openai_assistant/index.js +2 -1
  73. package/dist/experimental/openai_files/index.cjs +88 -0
  74. package/dist/experimental/openai_files/index.d.ts +79 -0
  75. package/dist/experimental/openai_files/index.js +84 -0
  76. package/dist/experimental/plan_and_execute/prompt.d.ts +1 -1
  77. package/dist/llms/base.cjs +15 -278
  78. package/dist/llms/base.d.ts +1 -115
  79. package/dist/llms/base.js +1 -275
  80. package/dist/llms/bedrock/web.d.ts +1 -1
  81. package/dist/llms/fireworks.d.ts +1 -1
  82. package/dist/load/import_constants.cjs +1 -0
  83. package/dist/load/import_constants.js +1 -0
  84. package/dist/load/import_map.cjs +4 -2
  85. package/dist/load/import_map.d.ts +2 -0
  86. package/dist/load/import_map.js +2 -0
  87. package/dist/load/index.cjs +7 -148
  88. package/dist/load/index.js +7 -148
  89. package/dist/load/map_keys.cjs +0 -24
  90. package/dist/load/map_keys.d.ts +0 -6
  91. package/dist/load/map_keys.js +1 -17
  92. package/dist/load/serializable.cjs +15 -178
  93. package/dist/load/serializable.d.ts +1 -66
  94. package/dist/load/serializable.js +1 -175
  95. package/dist/memory/base.cjs +17 -92
  96. package/dist/memory/base.d.ts +2 -68
  97. package/dist/memory/base.js +2 -87
  98. package/dist/output_parsers/openai_functions.cjs +2 -2
  99. package/dist/output_parsers/openai_functions.d.ts +1 -1
  100. package/dist/output_parsers/openai_functions.js +1 -1
  101. package/dist/output_parsers/regex.d.ts +1 -1
  102. package/dist/output_parsers/structured.d.ts +1 -1
  103. package/dist/prompts/base.cjs +8 -183
  104. package/dist/prompts/base.d.ts +3 -132
  105. package/dist/prompts/base.js +3 -178
  106. package/dist/prompts/chat.cjs +15 -477
  107. package/dist/prompts/chat.d.ts +1 -219
  108. package/dist/prompts/chat.js +1 -466
  109. package/dist/prompts/few_shot.cjs +15 -353
  110. package/dist/prompts/few_shot.d.ts +1 -192
  111. package/dist/prompts/few_shot.js +1 -350
  112. package/dist/prompts/index.cjs +3 -2
  113. package/dist/prompts/index.d.ts +2 -1
  114. package/dist/prompts/index.js +2 -1
  115. package/dist/prompts/pipeline.cjs +15 -142
  116. package/dist/prompts/pipeline.d.ts +1 -98
  117. package/dist/prompts/pipeline.js +1 -140
  118. package/dist/prompts/prompt.cjs +15 -146
  119. package/dist/prompts/prompt.d.ts +1 -92
  120. package/dist/prompts/prompt.js +1 -144
  121. package/dist/prompts/selectors/LengthBasedExampleSelector.cjs +15 -148
  122. package/dist/prompts/selectors/LengthBasedExampleSelector.d.ts +1 -89
  123. package/dist/prompts/selectors/LengthBasedExampleSelector.js +1 -146
  124. package/dist/prompts/selectors/SemanticSimilarityExampleSelector.cjs +15 -137
  125. package/dist/prompts/selectors/SemanticSimilarityExampleSelector.d.ts +1 -91
  126. package/dist/prompts/selectors/SemanticSimilarityExampleSelector.js +1 -135
  127. package/dist/prompts/selectors/conditional.cjs +15 -74
  128. package/dist/prompts/selectors/conditional.d.ts +1 -63
  129. package/dist/prompts/selectors/conditional.js +1 -69
  130. package/dist/prompts/serde.cjs +15 -0
  131. package/dist/prompts/serde.d.ts +1 -43
  132. package/dist/prompts/serde.js +1 -1
  133. package/dist/prompts/template.cjs +14 -88
  134. package/dist/prompts/template.d.ts +1 -36
  135. package/dist/prompts/template.js +1 -83
  136. package/dist/retrievers/chaindesk.cjs +9 -1
  137. package/dist/retrievers/chaindesk.d.ts +3 -1
  138. package/dist/retrievers/chaindesk.js +9 -1
  139. package/dist/retrievers/self_query/vectara.cjs +138 -0
  140. package/dist/retrievers/self_query/vectara.d.ts +41 -0
  141. package/dist/retrievers/self_query/vectara.js +134 -0
  142. package/dist/{util/@cfworker/json-schema → runnables}/index.cjs +1 -1
  143. package/dist/runnables/index.d.ts +1 -0
  144. package/dist/runnables/index.js +1 -0
  145. package/dist/schema/document.cjs +3 -34
  146. package/dist/schema/document.d.ts +2 -29
  147. package/dist/schema/document.js +2 -32
  148. package/dist/schema/index.cjs +37 -612
  149. package/dist/schema/index.d.ts +11 -311
  150. package/dist/schema/index.js +8 -583
  151. package/dist/schema/output_parser.cjs +15 -309
  152. package/dist/schema/output_parser.d.ts +1 -173
  153. package/dist/schema/output_parser.js +1 -301
  154. package/dist/schema/retriever.cjs +15 -77
  155. package/dist/schema/retriever.d.ts +1 -43
  156. package/dist/schema/retriever.js +1 -75
  157. package/dist/schema/runnable/base.cjs +10 -1072
  158. package/dist/schema/runnable/base.d.ts +1 -356
  159. package/dist/schema/runnable/base.js +1 -1060
  160. package/dist/schema/runnable/branch.cjs +2 -131
  161. package/dist/schema/runnable/branch.d.ts +1 -94
  162. package/dist/schema/runnable/branch.js +1 -130
  163. package/dist/schema/runnable/config.cjs +0 -6
  164. package/dist/schema/runnable/config.d.ts +1 -3
  165. package/dist/schema/runnable/config.js +1 -4
  166. package/dist/schema/runnable/index.cjs +15 -16
  167. package/dist/schema/runnable/index.d.ts +1 -5
  168. package/dist/schema/runnable/index.js +1 -4
  169. package/dist/schema/runnable/passthrough.cjs +3 -113
  170. package/dist/schema/runnable/passthrough.d.ts +1 -72
  171. package/dist/schema/runnable/passthrough.js +1 -111
  172. package/dist/schema/runnable/router.cjs +2 -71
  173. package/dist/schema/runnable/router.d.ts +1 -29
  174. package/dist/schema/runnable/router.js +1 -70
  175. package/dist/schema/storage.cjs +15 -8
  176. package/dist/schema/storage.d.ts +1 -57
  177. package/dist/schema/storage.js +1 -6
  178. package/dist/tools/bingserpapi.d.ts +1 -1
  179. package/dist/tools/searchapi.d.ts +1 -1
  180. package/dist/tools/serpapi.d.ts +1 -1
  181. package/dist/tools/serper.d.ts +1 -1
  182. package/dist/util/async_caller.cjs +14 -128
  183. package/dist/util/async_caller.d.ts +1 -45
  184. package/dist/util/async_caller.js +1 -124
  185. package/dist/vectorstores/vectara.cjs +77 -7
  186. package/dist/vectorstores/vectara.d.ts +9 -3
  187. package/dist/vectorstores/vectara.js +54 -7
  188. package/experimental/openai_files.cjs +1 -0
  189. package/experimental/openai_files.d.ts +1 -0
  190. package/experimental/openai_files.js +1 -0
  191. package/package.json +27 -5
  192. package/retrievers/self_query/vectara.cjs +1 -0
  193. package/retrievers/self_query/vectara.d.ts +1 -0
  194. package/retrievers/self_query/vectara.js +1 -0
  195. package/runnables.cjs +1 -0
  196. package/runnables.d.ts +1 -0
  197. package/runnables.js +1 -0
  198. package/dist/util/@cfworker/json-schema/index.d.ts +0 -1
  199. package/dist/util/@cfworker/json-schema/index.js +0 -1
  200. package/dist/util/@cfworker/json-schema/src/deep-compare-strict.cjs +0 -43
  201. package/dist/util/@cfworker/json-schema/src/deep-compare-strict.d.ts +0 -1
  202. package/dist/util/@cfworker/json-schema/src/deep-compare-strict.js +0 -39
  203. package/dist/util/@cfworker/json-schema/src/dereference.cjs +0 -169
  204. package/dist/util/@cfworker/json-schema/src/dereference.d.ts +0 -12
  205. package/dist/util/@cfworker/json-schema/src/dereference.js +0 -165
  206. package/dist/util/@cfworker/json-schema/src/format.cjs +0 -139
  207. package/dist/util/@cfworker/json-schema/src/format.d.ts +0 -2
  208. package/dist/util/@cfworker/json-schema/src/format.js +0 -136
  209. package/dist/util/@cfworker/json-schema/src/index.cjs +0 -24
  210. package/dist/util/@cfworker/json-schema/src/index.d.ts +0 -8
  211. package/dist/util/@cfworker/json-schema/src/index.js +0 -8
  212. package/dist/util/@cfworker/json-schema/src/pointer.cjs +0 -11
  213. package/dist/util/@cfworker/json-schema/src/pointer.d.ts +0 -2
  214. package/dist/util/@cfworker/json-schema/src/pointer.js +0 -6
  215. package/dist/util/@cfworker/json-schema/src/types.cjs +0 -2
  216. package/dist/util/@cfworker/json-schema/src/types.d.ts +0 -72
  217. package/dist/util/@cfworker/json-schema/src/types.js +0 -1
  218. package/dist/util/@cfworker/json-schema/src/ucs2-length.cjs +0 -28
  219. package/dist/util/@cfworker/json-schema/src/ucs2-length.d.ts +0 -6
  220. package/dist/util/@cfworker/json-schema/src/ucs2-length.js +0 -24
  221. package/dist/util/@cfworker/json-schema/src/validate.cjs +0 -808
  222. package/dist/util/@cfworker/json-schema/src/validate.d.ts +0 -3
  223. package/dist/util/@cfworker/json-schema/src/validate.js +0 -804
  224. package/dist/util/@cfworker/json-schema/src/validator.cjs +0 -44
  225. package/dist/util/@cfworker/json-schema/src/validator.d.ts +0 -10
  226. package/dist/util/@cfworker/json-schema/src/validator.js +0 -40
  227. package/dist/util/fast-json-patch/index.cjs +0 -49
  228. package/dist/util/fast-json-patch/index.d.ts +0 -22
  229. package/dist/util/fast-json-patch/index.js +0 -16
  230. package/dist/util/fast-json-patch/src/core.cjs +0 -469
  231. package/dist/util/fast-json-patch/src/core.d.ts +0 -111
  232. package/dist/util/fast-json-patch/src/core.js +0 -459
  233. package/dist/util/fast-json-patch/src/duplex.cjs +0 -237
  234. package/dist/util/fast-json-patch/src/duplex.d.ts +0 -23
  235. package/dist/util/fast-json-patch/src/duplex.js +0 -230
  236. package/dist/util/fast-json-patch/src/helpers.cjs +0 -194
  237. package/dist/util/fast-json-patch/src/helpers.d.ts +0 -36
  238. package/dist/util/fast-json-patch/src/helpers.js +0 -181
  239. package/dist/util/js-sha1/hash.cjs +0 -358
  240. package/dist/util/js-sha1/hash.d.ts +0 -1
  241. package/dist/util/js-sha1/hash.js +0 -355
@@ -1,169 +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" && self.location
68
- ? //@ts-ignore
69
- /* #__PURE__ */ new URL(self.location.origin + self.location.pathname + location.search)
70
- : /* #__PURE__ */ new URL("https://github.com/cfworker");
71
- function dereference(schema, lookup = Object.create(null), baseURI = exports.initialBaseURI, basePointer = "") {
72
- if (schema && typeof schema === "object" && !Array.isArray(schema)) {
73
- const id = schema.$id || schema.id;
74
- if (id) {
75
- const url = new URL(id, baseURI.href);
76
- if (url.hash.length > 1) {
77
- lookup[url.href] = schema;
78
- }
79
- else {
80
- url.hash = ""; // normalize hash https://url.spec.whatwg.org/#dom-url-hash
81
- if (basePointer === "") {
82
- baseURI = url;
83
- }
84
- else {
85
- dereference(schema, lookup, baseURI);
86
- }
87
- }
88
- }
89
- }
90
- else if (schema !== true && schema !== false) {
91
- return lookup;
92
- }
93
- // compute the schema's URI and add it to the mapping.
94
- const schemaURI = baseURI.href + (basePointer ? "#" + basePointer : "");
95
- if (lookup[schemaURI] !== undefined) {
96
- throw new Error(`Duplicate schema URI "${schemaURI}".`);
97
- }
98
- lookup[schemaURI] = schema;
99
- // exit early if this is a boolean schema.
100
- if (schema === true || schema === false) {
101
- return lookup;
102
- }
103
- // set the schema's absolute URI.
104
- if (schema.__absolute_uri__ === undefined) {
105
- Object.defineProperty(schema, "__absolute_uri__", {
106
- enumerable: false,
107
- value: schemaURI,
108
- });
109
- }
110
- // if a $ref is found, resolve it's absolute URI.
111
- if (schema.$ref && schema.__absolute_ref__ === undefined) {
112
- const url = new URL(schema.$ref, baseURI.href);
113
- url.hash = url.hash; // normalize hash https://url.spec.whatwg.org/#dom-url-hash
114
- Object.defineProperty(schema, "__absolute_ref__", {
115
- enumerable: false,
116
- value: url.href,
117
- });
118
- }
119
- // if a $recursiveRef is found, resolve it's absolute URI.
120
- if (schema.$recursiveRef && schema.__absolute_recursive_ref__ === undefined) {
121
- const url = new URL(schema.$recursiveRef, baseURI.href);
122
- url.hash = url.hash; // normalize hash https://url.spec.whatwg.org/#dom-url-hash
123
- Object.defineProperty(schema, "__absolute_recursive_ref__", {
124
- enumerable: false,
125
- value: url.href,
126
- });
127
- }
128
- // if an $anchor is found, compute it's URI and add it to the mapping.
129
- if (schema.$anchor) {
130
- const url = new URL("#" + schema.$anchor, baseURI.href);
131
- lookup[url.href] = schema;
132
- }
133
- // process subschemas.
134
- for (let key in schema) {
135
- if (exports.ignoredKeyword[key]) {
136
- continue;
137
- }
138
- const keyBase = `${basePointer}/${(0, pointer_js_1.encodePointer)(key)}`;
139
- const subSchema = schema[key];
140
- if (Array.isArray(subSchema)) {
141
- if (exports.schemaArrayKeyword[key]) {
142
- const length = subSchema.length;
143
- for (let i = 0; i < length; i++) {
144
- dereference(subSchema[i], lookup, baseURI, `${keyBase}/${i}`);
145
- }
146
- }
147
- }
148
- else if (exports.schemaMapKeyword[key]) {
149
- for (let subKey in subSchema) {
150
- dereference(subSchema[subKey], lookup, baseURI, `${keyBase}/${(0, pointer_js_1.encodePointer)(subKey)}`);
151
- }
152
- }
153
- else {
154
- dereference(subSchema, lookup, baseURI, keyBase);
155
- }
156
- }
157
- return lookup;
158
- }
159
- exports.dereference = dereference;
160
- // schema identification examples
161
- // https://json-schema.org/draft/2019-09/json-schema-core.html#rfc.appendix.A
162
- // $ref delegation
163
- // https://github.com/json-schema-org/json-schema-spec/issues/514
164
- // output format
165
- // https://json-schema.org/draft/2019-09/json-schema-core.html#output
166
- // JSON pointer
167
- // https://tools.ietf.org/html/rfc6901
168
- // JSON relative pointer
169
- // 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,165 +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" && self.location
65
- ? //@ts-ignore
66
- /* #__PURE__ */ new URL(self.location.origin + self.location.pathname + location.search)
67
- : /* #__PURE__ */ new URL("https://github.com/cfworker");
68
- export function dereference(schema, lookup = Object.create(null), baseURI = initialBaseURI, basePointer = "") {
69
- if (schema && typeof schema === "object" && !Array.isArray(schema)) {
70
- const id = schema.$id || schema.id;
71
- if (id) {
72
- const url = new URL(id, baseURI.href);
73
- if (url.hash.length > 1) {
74
- lookup[url.href] = schema;
75
- }
76
- else {
77
- url.hash = ""; // normalize hash https://url.spec.whatwg.org/#dom-url-hash
78
- if (basePointer === "") {
79
- baseURI = url;
80
- }
81
- else {
82
- dereference(schema, lookup, baseURI);
83
- }
84
- }
85
- }
86
- }
87
- else if (schema !== true && schema !== false) {
88
- return lookup;
89
- }
90
- // compute the schema's URI and add it to the mapping.
91
- const schemaURI = baseURI.href + (basePointer ? "#" + basePointer : "");
92
- if (lookup[schemaURI] !== undefined) {
93
- throw new Error(`Duplicate schema URI "${schemaURI}".`);
94
- }
95
- lookup[schemaURI] = schema;
96
- // exit early if this is a boolean schema.
97
- if (schema === true || schema === false) {
98
- return lookup;
99
- }
100
- // set the schema's absolute URI.
101
- if (schema.__absolute_uri__ === undefined) {
102
- Object.defineProperty(schema, "__absolute_uri__", {
103
- enumerable: false,
104
- value: schemaURI,
105
- });
106
- }
107
- // if a $ref is found, resolve it's absolute URI.
108
- if (schema.$ref && schema.__absolute_ref__ === undefined) {
109
- const url = new URL(schema.$ref, baseURI.href);
110
- url.hash = url.hash; // normalize hash https://url.spec.whatwg.org/#dom-url-hash
111
- Object.defineProperty(schema, "__absolute_ref__", {
112
- enumerable: false,
113
- value: url.href,
114
- });
115
- }
116
- // if a $recursiveRef is found, resolve it's absolute URI.
117
- if (schema.$recursiveRef && schema.__absolute_recursive_ref__ === undefined) {
118
- const url = new URL(schema.$recursiveRef, baseURI.href);
119
- url.hash = url.hash; // normalize hash https://url.spec.whatwg.org/#dom-url-hash
120
- Object.defineProperty(schema, "__absolute_recursive_ref__", {
121
- enumerable: false,
122
- value: url.href,
123
- });
124
- }
125
- // if an $anchor is found, compute it's URI and add it to the mapping.
126
- if (schema.$anchor) {
127
- const url = new URL("#" + schema.$anchor, baseURI.href);
128
- lookup[url.href] = schema;
129
- }
130
- // process subschemas.
131
- for (let key in schema) {
132
- if (ignoredKeyword[key]) {
133
- continue;
134
- }
135
- const keyBase = `${basePointer}/${encodePointer(key)}`;
136
- const subSchema = schema[key];
137
- if (Array.isArray(subSchema)) {
138
- if (schemaArrayKeyword[key]) {
139
- const length = subSchema.length;
140
- for (let i = 0; i < length; i++) {
141
- dereference(subSchema[i], lookup, baseURI, `${keyBase}/${i}`);
142
- }
143
- }
144
- }
145
- else if (schemaMapKeyword[key]) {
146
- for (let subKey in subSchema) {
147
- dereference(subSchema[subKey], lookup, baseURI, `${keyBase}/${encodePointer(subKey)}`);
148
- }
149
- }
150
- else {
151
- dereference(subSchema, lookup, baseURI, keyBase);
152
- }
153
- }
154
- return lookup;
155
- }
156
- // schema identification examples
157
- // https://json-schema.org/draft/2019-09/json-schema-core.html#rfc.appendix.A
158
- // $ref delegation
159
- // https://github.com/json-schema-org/json-schema-spec/issues/514
160
- // output format
161
- // https://json-schema.org/draft/2019-09/json-schema-core.html#output
162
- // JSON pointer
163
- // https://tools.ietf.org/html/rfc6901
164
- // JSON relative pointer
165
- // 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]?\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[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>;
@@ -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}[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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+\-.]*:)(?:\/?\/(?:(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/?]|%[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);