langchain 0.0.195 → 0.0.197-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.
Files changed (236) hide show
  1. package/LICENSE +21 -0
  2. package/dist/agents/openai/index.cjs +6 -2
  3. package/dist/agents/openai/index.js +6 -2
  4. package/dist/agents/toolkits/conversational_retrieval/token_buffer_memory.d.ts +1 -1
  5. package/dist/base_language/count_tokens.cjs +5 -70
  6. package/dist/base_language/count_tokens.d.ts +1 -10
  7. package/dist/base_language/count_tokens.js +1 -65
  8. package/dist/base_language/index.cjs +6 -196
  9. package/dist/base_language/index.d.ts +1 -111
  10. package/dist/base_language/index.js +1 -191
  11. package/dist/cache/base.cjs +15 -37
  12. package/dist/cache/base.d.ts +1 -20
  13. package/dist/cache/base.js +1 -33
  14. package/dist/cache/index.cjs +2 -46
  15. package/dist/cache/index.d.ts +1 -29
  16. package/dist/cache/index.js +1 -45
  17. package/dist/callbacks/base.cjs +3 -139
  18. package/dist/callbacks/base.d.ts +1 -266
  19. package/dist/callbacks/base.js +1 -126
  20. package/dist/callbacks/handlers/console.cjs +14 -221
  21. package/dist/callbacks/handlers/console.d.ts +1 -117
  22. package/dist/callbacks/handlers/console.js +1 -217
  23. package/dist/callbacks/handlers/initialize.cjs +15 -30
  24. package/dist/callbacks/handlers/initialize.d.ts +1 -16
  25. package/dist/callbacks/handlers/initialize.js +1 -27
  26. package/dist/callbacks/handlers/log_stream.cjs +15 -293
  27. package/dist/callbacks/handlers/log_stream.d.ts +1 -100
  28. package/dist/callbacks/handlers/log_stream.js +1 -289
  29. package/dist/callbacks/handlers/run_collector.cjs +15 -48
  30. package/dist/callbacks/handlers/run_collector.d.ts +1 -26
  31. package/dist/callbacks/handlers/run_collector.js +1 -46
  32. package/dist/callbacks/handlers/tracer.cjs +15 -375
  33. package/dist/callbacks/handlers/tracer.d.ts +1 -70
  34. package/dist/callbacks/handlers/tracer.js +1 -373
  35. package/dist/callbacks/handlers/tracer_langchain.cjs +15 -104
  36. package/dist/callbacks/handlers/tracer_langchain.d.ts +1 -41
  37. package/dist/callbacks/handlers/tracer_langchain.js +1 -102
  38. package/dist/callbacks/handlers/tracer_langchain_v1.cjs +15 -197
  39. package/dist/callbacks/handlers/tracer_langchain_v1.d.ts +1 -57
  40. package/dist/callbacks/handlers/tracer_langchain_v1.js +1 -195
  41. package/dist/callbacks/manager.cjs +15 -676
  42. package/dist/callbacks/manager.d.ts +1 -180
  43. package/dist/callbacks/manager.js +1 -666
  44. package/dist/callbacks/promises.cjs +14 -42
  45. package/dist/callbacks/promises.d.ts +1 -11
  46. package/dist/callbacks/promises.js +1 -37
  47. package/dist/chains/graph_qa/prompts.d.ts +1 -1
  48. package/dist/chains/openai_functions/structured_output.cjs +2 -2
  49. package/dist/chains/openai_functions/structured_output.d.ts +1 -1
  50. package/dist/chains/openai_functions/structured_output.js +1 -1
  51. package/dist/chat_models/anthropic.cjs +15 -348
  52. package/dist/chat_models/anthropic.d.ts +1 -156
  53. package/dist/chat_models/anthropic.js +1 -346
  54. package/dist/chat_models/baiduwenxin.d.ts +1 -1
  55. package/dist/chat_models/base.cjs +15 -296
  56. package/dist/chat_models/base.d.ts +1 -122
  57. package/dist/chat_models/base.js +1 -292
  58. package/dist/chat_models/bedrock/web.cjs +21 -1
  59. package/dist/chat_models/bedrock/web.d.ts +2 -2
  60. package/dist/chat_models/bedrock/web.js +21 -1
  61. package/dist/chat_models/fireworks.d.ts +1 -1
  62. package/dist/document.cjs +2 -24
  63. package/dist/document.d.ts +1 -12
  64. package/dist/document.js +1 -23
  65. package/dist/document_loaders/web/azure_blob_storage_file.d.ts +1 -1
  66. package/dist/document_loaders/web/github.cjs +105 -0
  67. package/dist/document_loaders/web/github.d.ts +26 -0
  68. package/dist/document_loaders/web/github.js +105 -0
  69. package/dist/document_loaders/web/s3.d.ts +1 -1
  70. package/dist/embeddings/base.cjs +15 -22
  71. package/dist/embeddings/base.d.ts +1 -33
  72. package/dist/embeddings/base.js +1 -20
  73. package/dist/embeddings/cache_backed.cjs +2 -2
  74. package/dist/embeddings/cache_backed.js +1 -1
  75. package/dist/evaluation/agents/trajectory.d.ts +1 -1
  76. package/dist/evaluation/criteria/prompt.d.ts +2 -2
  77. package/dist/evaluation/qa/prompt.d.ts +2 -2
  78. package/dist/experimental/hubs/makersuite/googlemakersuitehub.d.ts +1 -1
  79. package/dist/experimental/plan_and_execute/prompt.d.ts +1 -1
  80. package/dist/llms/base.cjs +15 -278
  81. package/dist/llms/base.d.ts +1 -115
  82. package/dist/llms/base.js +1 -275
  83. package/dist/llms/bedrock/web.cjs +21 -1
  84. package/dist/llms/bedrock/web.d.ts +2 -2
  85. package/dist/llms/bedrock/web.js +21 -1
  86. package/dist/llms/fireworks.d.ts +1 -1
  87. package/dist/load/import_map.cjs +2 -1
  88. package/dist/load/import_map.d.ts +1 -0
  89. package/dist/load/import_map.js +1 -0
  90. package/dist/load/index.cjs +7 -148
  91. package/dist/load/index.js +7 -148
  92. package/dist/load/map_keys.cjs +0 -24
  93. package/dist/load/map_keys.d.ts +0 -6
  94. package/dist/load/map_keys.js +1 -17
  95. package/dist/load/serializable.cjs +15 -178
  96. package/dist/load/serializable.d.ts +1 -66
  97. package/dist/load/serializable.js +1 -175
  98. package/dist/memory/base.cjs +17 -92
  99. package/dist/memory/base.d.ts +2 -68
  100. package/dist/memory/base.js +2 -87
  101. package/dist/output_parsers/list.cjs +4 -122
  102. package/dist/output_parsers/list.d.ts +1 -57
  103. package/dist/output_parsers/list.js +1 -119
  104. package/dist/output_parsers/openai_functions.cjs +2 -2
  105. package/dist/output_parsers/openai_functions.d.ts +1 -1
  106. package/dist/output_parsers/openai_functions.js +1 -1
  107. package/dist/output_parsers/regex.d.ts +1 -1
  108. package/dist/output_parsers/structured.d.ts +1 -1
  109. package/dist/prompts/base.cjs +8 -183
  110. package/dist/prompts/base.d.ts +3 -132
  111. package/dist/prompts/base.js +3 -178
  112. package/dist/prompts/chat.cjs +13 -477
  113. package/dist/prompts/chat.d.ts +2 -219
  114. package/dist/prompts/chat.js +2 -466
  115. package/dist/prompts/few_shot.cjs +3 -352
  116. package/dist/prompts/few_shot.d.ts +1 -192
  117. package/dist/prompts/few_shot.js +1 -350
  118. package/dist/prompts/index.cjs +3 -2
  119. package/dist/prompts/index.d.ts +2 -1
  120. package/dist/prompts/index.js +2 -1
  121. package/dist/prompts/pipeline.cjs +2 -141
  122. package/dist/prompts/pipeline.d.ts +1 -98
  123. package/dist/prompts/pipeline.js +1 -140
  124. package/dist/prompts/prompt.cjs +2 -145
  125. package/dist/prompts/prompt.d.ts +1 -92
  126. package/dist/prompts/prompt.js +1 -144
  127. package/dist/prompts/selectors/LengthBasedExampleSelector.cjs +2 -147
  128. package/dist/prompts/selectors/LengthBasedExampleSelector.d.ts +1 -89
  129. package/dist/prompts/selectors/LengthBasedExampleSelector.js +1 -146
  130. package/dist/prompts/selectors/SemanticSimilarityExampleSelector.cjs +15 -137
  131. package/dist/prompts/selectors/SemanticSimilarityExampleSelector.d.ts +1 -91
  132. package/dist/prompts/selectors/SemanticSimilarityExampleSelector.js +1 -135
  133. package/dist/prompts/selectors/conditional.cjs +5 -73
  134. package/dist/prompts/selectors/conditional.d.ts +1 -63
  135. package/dist/prompts/selectors/conditional.js +1 -69
  136. package/dist/prompts/serde.d.ts +1 -43
  137. package/dist/prompts/template.cjs +8 -88
  138. package/dist/prompts/template.d.ts +1 -36
  139. package/dist/prompts/template.js +1 -83
  140. package/dist/{util/@cfworker/json-schema → runnables}/index.cjs +1 -1
  141. package/dist/runnables/index.d.ts +1 -0
  142. package/dist/runnables/index.js +1 -0
  143. package/dist/schema/document.cjs +3 -34
  144. package/dist/schema/document.d.ts +2 -29
  145. package/dist/schema/document.js +2 -32
  146. package/dist/schema/index.cjs +37 -612
  147. package/dist/schema/index.d.ts +11 -311
  148. package/dist/schema/index.js +8 -583
  149. package/dist/schema/output_parser.cjs +15 -309
  150. package/dist/schema/output_parser.d.ts +1 -173
  151. package/dist/schema/output_parser.js +1 -301
  152. package/dist/schema/retriever.cjs +15 -77
  153. package/dist/schema/retriever.d.ts +1 -43
  154. package/dist/schema/retriever.js +1 -75
  155. package/dist/schema/runnable/base.cjs +10 -1072
  156. package/dist/schema/runnable/base.d.ts +1 -356
  157. package/dist/schema/runnable/base.js +1 -1060
  158. package/dist/schema/runnable/branch.cjs +2 -131
  159. package/dist/schema/runnable/branch.d.ts +1 -94
  160. package/dist/schema/runnable/branch.js +1 -130
  161. package/dist/schema/runnable/config.cjs +0 -6
  162. package/dist/schema/runnable/config.d.ts +1 -3
  163. package/dist/schema/runnable/config.js +1 -4
  164. package/dist/schema/runnable/index.cjs +15 -16
  165. package/dist/schema/runnable/index.d.ts +1 -5
  166. package/dist/schema/runnable/index.js +1 -4
  167. package/dist/schema/runnable/passthrough.cjs +3 -113
  168. package/dist/schema/runnable/passthrough.d.ts +1 -72
  169. package/dist/schema/runnable/passthrough.js +1 -111
  170. package/dist/schema/runnable/router.cjs +2 -71
  171. package/dist/schema/runnable/router.d.ts +1 -29
  172. package/dist/schema/runnable/router.js +1 -70
  173. package/dist/schema/storage.cjs +15 -8
  174. package/dist/schema/storage.d.ts +1 -57
  175. package/dist/schema/storage.js +1 -6
  176. package/dist/tools/bingserpapi.d.ts +1 -1
  177. package/dist/tools/searchapi.d.ts +1 -1
  178. package/dist/tools/serpapi.d.ts +1 -1
  179. package/dist/tools/serper.d.ts +1 -1
  180. package/dist/util/async_caller.cjs +14 -128
  181. package/dist/util/async_caller.d.ts +1 -45
  182. package/dist/util/async_caller.js +1 -124
  183. package/dist/vectorstores/momento_vector_index.cjs +39 -0
  184. package/dist/vectorstores/momento_vector_index.d.ts +17 -1
  185. package/dist/vectorstores/momento_vector_index.js +40 -1
  186. package/dist/vectorstores/mongodb_atlas.cjs +22 -2
  187. package/dist/vectorstores/mongodb_atlas.d.ts +13 -0
  188. package/dist/vectorstores/mongodb_atlas.js +22 -2
  189. package/package.json +18 -11
  190. package/runnables.cjs +1 -0
  191. package/runnables.d.ts +1 -0
  192. package/runnables.js +1 -0
  193. package/dist/util/@cfworker/json-schema/index.d.ts +0 -1
  194. package/dist/util/@cfworker/json-schema/index.js +0 -1
  195. package/dist/util/@cfworker/json-schema/src/deep-compare-strict.cjs +0 -43
  196. package/dist/util/@cfworker/json-schema/src/deep-compare-strict.d.ts +0 -1
  197. package/dist/util/@cfworker/json-schema/src/deep-compare-strict.js +0 -39
  198. package/dist/util/@cfworker/json-schema/src/dereference.cjs +0 -169
  199. package/dist/util/@cfworker/json-schema/src/dereference.d.ts +0 -12
  200. package/dist/util/@cfworker/json-schema/src/dereference.js +0 -165
  201. package/dist/util/@cfworker/json-schema/src/format.cjs +0 -139
  202. package/dist/util/@cfworker/json-schema/src/format.d.ts +0 -2
  203. package/dist/util/@cfworker/json-schema/src/format.js +0 -136
  204. package/dist/util/@cfworker/json-schema/src/index.cjs +0 -24
  205. package/dist/util/@cfworker/json-schema/src/index.d.ts +0 -8
  206. package/dist/util/@cfworker/json-schema/src/index.js +0 -8
  207. package/dist/util/@cfworker/json-schema/src/pointer.cjs +0 -11
  208. package/dist/util/@cfworker/json-schema/src/pointer.d.ts +0 -2
  209. package/dist/util/@cfworker/json-schema/src/pointer.js +0 -6
  210. package/dist/util/@cfworker/json-schema/src/types.cjs +0 -2
  211. package/dist/util/@cfworker/json-schema/src/types.d.ts +0 -72
  212. package/dist/util/@cfworker/json-schema/src/types.js +0 -1
  213. package/dist/util/@cfworker/json-schema/src/ucs2-length.cjs +0 -28
  214. package/dist/util/@cfworker/json-schema/src/ucs2-length.d.ts +0 -6
  215. package/dist/util/@cfworker/json-schema/src/ucs2-length.js +0 -24
  216. package/dist/util/@cfworker/json-schema/src/validate.cjs +0 -808
  217. package/dist/util/@cfworker/json-schema/src/validate.d.ts +0 -3
  218. package/dist/util/@cfworker/json-schema/src/validate.js +0 -804
  219. package/dist/util/@cfworker/json-schema/src/validator.cjs +0 -44
  220. package/dist/util/@cfworker/json-schema/src/validator.d.ts +0 -10
  221. package/dist/util/@cfworker/json-schema/src/validator.js +0 -40
  222. package/dist/util/fast-json-patch/index.cjs +0 -49
  223. package/dist/util/fast-json-patch/index.d.ts +0 -22
  224. package/dist/util/fast-json-patch/index.js +0 -16
  225. package/dist/util/fast-json-patch/src/core.cjs +0 -469
  226. package/dist/util/fast-json-patch/src/core.d.ts +0 -111
  227. package/dist/util/fast-json-patch/src/core.js +0 -459
  228. package/dist/util/fast-json-patch/src/duplex.cjs +0 -237
  229. package/dist/util/fast-json-patch/src/duplex.d.ts +0 -23
  230. package/dist/util/fast-json-patch/src/duplex.js +0 -230
  231. package/dist/util/fast-json-patch/src/helpers.cjs +0 -194
  232. package/dist/util/fast-json-patch/src/helpers.d.ts +0 -36
  233. package/dist/util/fast-json-patch/src/helpers.js +0 -181
  234. package/dist/util/js-sha1/hash.cjs +0 -358
  235. package/dist/util/js-sha1/hash.d.ts +0 -1
  236. 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]?\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>;
@@ -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);