@langchain/core 0.3.59-rc.2 → 0.3.60

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 (100) hide show
  1. package/dist/caches/base.cjs +28 -5
  2. package/dist/caches/base.d.ts +13 -1
  3. package/dist/caches/base.js +25 -2
  4. package/dist/callbacks/base.cjs +19 -9
  5. package/dist/callbacks/base.d.ts +37 -22
  6. package/dist/callbacks/dispatch/index.cjs +1 -2
  7. package/dist/callbacks/dispatch/web.cjs +1 -2
  8. package/dist/callbacks/manager.cjs +4 -4
  9. package/dist/callbacks/manager.d.ts +2 -2
  10. package/dist/errors/index.cjs +1 -2
  11. package/dist/example_selectors/conditional.cjs +3 -3
  12. package/dist/indexing/base.cjs +19 -7
  13. package/dist/indexing/base.d.ts +3 -0
  14. package/dist/indexing/base.js +14 -2
  15. package/dist/language_models/base.cjs +31 -7
  16. package/dist/language_models/base.d.ts +5 -0
  17. package/dist/language_models/base.js +29 -5
  18. package/dist/language_models/chat_models.cjs +2 -2
  19. package/dist/load/import_map.cjs +17 -7
  20. package/dist/load/index.cjs +18 -9
  21. package/dist/load/map_keys.cjs +3 -4
  22. package/dist/load/serializable.cjs +2 -2
  23. package/dist/memory.cjs +2 -2
  24. package/dist/messages/ai.cjs +3 -3
  25. package/dist/messages/base.cjs +10 -10
  26. package/dist/messages/chat.cjs +3 -3
  27. package/dist/messages/content_blocks.cjs +9 -10
  28. package/dist/messages/function.cjs +3 -3
  29. package/dist/messages/human.cjs +3 -3
  30. package/dist/messages/system.cjs +3 -3
  31. package/dist/messages/tool.cjs +5 -5
  32. package/dist/messages/transformers.cjs +4 -5
  33. package/dist/messages/utils.cjs +6 -7
  34. package/dist/output_parsers/openai_tools/json_output_tools_parsers.cjs +4 -4
  35. package/dist/output_parsers/xml.cjs +2 -2
  36. package/dist/prompts/base.cjs +36 -3
  37. package/dist/runnables/base.cjs +7 -5
  38. package/dist/runnables/base.d.ts +1 -1
  39. package/dist/runnables/base.js +3 -1
  40. package/dist/runnables/config.cjs +6 -6
  41. package/dist/runnables/graph_mermaid.cjs +2 -3
  42. package/dist/runnables/iter.cjs +5 -5
  43. package/dist/runnables/iter.d.ts +1 -1
  44. package/dist/runnables/utils.cjs +2 -2
  45. package/dist/runnables/wrappers.cjs +1 -2
  46. package/dist/runnables/wrappers.d.ts +1 -1
  47. package/dist/singletons/async_local_storage/context.cjs +3 -3
  48. package/dist/singletons/callbacks.cjs +3 -4
  49. package/dist/singletons/callbacks.d.ts +1 -1
  50. package/dist/structured_query/utils.cjs +7 -8
  51. package/dist/tools/index.cjs +2 -2
  52. package/dist/tools/types.cjs +4 -5
  53. package/dist/tools/utils.cjs +3 -3
  54. package/dist/tracers/base.cjs +2 -2
  55. package/dist/tracers/base.d.ts +84 -84
  56. package/dist/tracers/initialize.cjs +2 -3
  57. package/dist/utils/async_caller.cjs +9 -9
  58. package/dist/utils/async_caller.js +9 -9
  59. package/dist/utils/env.cjs +4 -4
  60. package/dist/utils/event_source_parse.cjs +5 -5
  61. package/dist/utils/fast-json-patch/index.cjs +17 -7
  62. package/dist/utils/fast-json-patch/index.d.ts +4 -4
  63. package/dist/utils/fast-json-patch/src/core.cjs +8 -8
  64. package/dist/utils/fast-json-patch/src/duplex.cjs +4 -5
  65. package/dist/utils/fast-json-patch/src/helpers.cjs +10 -10
  66. package/dist/utils/fast-json-patch/src/helpers.d.ts +3 -3
  67. package/dist/utils/function_calling.cjs +3 -3
  68. package/dist/utils/hash.cjs +3 -1
  69. package/dist/utils/hash.d.ts +7 -0
  70. package/dist/utils/hash.js +1 -0
  71. package/dist/utils/js-sha1/hash.cjs +17 -0
  72. package/dist/utils/js-sha1/hash.d.ts +4 -0
  73. package/dist/utils/js-sha1/hash.js +17 -0
  74. package/dist/utils/js-sha256/hash.cjs +448 -0
  75. package/dist/utils/js-sha256/hash.d.ts +1 -0
  76. package/dist/utils/js-sha256/hash.js +445 -0
  77. package/dist/utils/json.cjs +2 -3
  78. package/dist/utils/json_schema.cjs +11 -4
  79. package/dist/utils/json_schema.js +9 -2
  80. package/dist/utils/math.cjs +6 -7
  81. package/dist/utils/ml-distance/distances.cjs +1 -2
  82. package/dist/utils/ml-distance/similarities.cjs +1 -2
  83. package/dist/utils/ml-distance-euclidean/euclidean.cjs +2 -3
  84. package/dist/utils/sax-js/sax.cjs +35 -35
  85. package/dist/utils/sax-js/sax.js +35 -35
  86. package/dist/utils/signal.cjs +1 -2
  87. package/dist/utils/stream.cjs +4 -4
  88. package/dist/utils/tiktoken.cjs +2 -3
  89. package/dist/utils/types/zod.cjs +223 -56
  90. package/dist/utils/types/zod.d.ts +38 -1
  91. package/dist/utils/types/zod.js +202 -39
  92. package/package.json +30 -4
  93. package/utils/hash/insecure.cjs +1 -0
  94. package/utils/hash/insecure.d.cts +1 -0
  95. package/utils/hash/insecure.d.ts +1 -0
  96. package/utils/hash/insecure.js +1 -0
  97. package/utils/hash/sha256.cjs +1 -0
  98. package/utils/hash/sha256.d.cts +1 -0
  99. package/utils/hash/sha256.d.ts +1 -0
  100. package/utils/hash/sha256.js +1 -0
@@ -43,25 +43,25 @@ export declare abstract class BaseTracer extends BaseCallbackHandler {
43
43
  execution_order: number;
44
44
  child_runs: Run[];
45
45
  child_execution_order: number;
46
- events: {
46
+ events: Array<{
47
47
  name: string;
48
48
  time: string;
49
- kwargs?: Record<string, unknown> | undefined;
50
- }[];
51
- trace_id?: string | undefined;
52
- dotted_order?: string | undefined;
49
+ kwargs?: Record<string, unknown>;
50
+ }>;
51
+ trace_id?: string;
52
+ dotted_order?: string;
53
53
  name: string;
54
54
  run_type: string;
55
- end_time?: number | undefined;
56
- extra?: KVMap | undefined;
57
- error?: string | undefined;
58
- serialized?: object | undefined;
55
+ end_time?: number;
56
+ extra?: KVMap;
57
+ error?: string;
58
+ serialized?: object;
59
59
  inputs: KVMap;
60
- outputs?: KVMap | undefined;
61
- reference_example_id?: string | undefined;
62
- parent_run_id?: string | undefined;
63
- tags?: string[] | undefined;
64
- attachments?: import("langsmith/schemas").Attachments | undefined;
60
+ outputs?: KVMap;
61
+ reference_example_id?: string;
62
+ parent_run_id?: string;
63
+ tags?: string[];
64
+ attachments?: import("langsmith/schemas").Attachments;
65
65
  };
66
66
  protected _endTrace(run: Run): Promise<void>;
67
67
  protected _getExecutionOrder(parentRunId: string | undefined): number;
@@ -76,25 +76,25 @@ export declare abstract class BaseTracer extends BaseCallbackHandler {
76
76
  execution_order: number;
77
77
  child_runs: Run[];
78
78
  child_execution_order: number;
79
- events: {
79
+ events: Array<{
80
80
  name: string;
81
81
  time: string;
82
- kwargs?: Record<string, unknown> | undefined;
83
- }[];
84
- trace_id?: string | undefined;
85
- dotted_order?: string | undefined;
82
+ kwargs?: Record<string, unknown>;
83
+ }>;
84
+ trace_id?: string;
85
+ dotted_order?: string;
86
86
  name: string;
87
87
  run_type: string;
88
- end_time?: number | undefined;
89
- extra?: KVMap | undefined;
90
- error?: string | undefined;
91
- serialized?: object | undefined;
88
+ end_time?: number;
89
+ extra?: KVMap;
90
+ error?: string;
91
+ serialized?: object;
92
92
  inputs: KVMap;
93
- outputs?: KVMap | undefined;
94
- reference_example_id?: string | undefined;
95
- parent_run_id?: string | undefined;
96
- tags?: string[] | undefined;
97
- attachments?: import("langsmith/schemas").Attachments | undefined;
93
+ outputs?: KVMap;
94
+ reference_example_id?: string;
95
+ parent_run_id?: string;
96
+ tags?: string[];
97
+ attachments?: import("langsmith/schemas").Attachments;
98
98
  };
99
99
  handleLLMStart(llm: Serialized, prompts: string[], runId: string, parentRunId?: string, extraParams?: KVMap, tags?: string[], metadata?: KVMap, name?: string): Promise<Run>;
100
100
  /**
@@ -108,25 +108,25 @@ export declare abstract class BaseTracer extends BaseCallbackHandler {
108
108
  execution_order: number;
109
109
  child_runs: Run[];
110
110
  child_execution_order: number;
111
- events: {
111
+ events: Array<{
112
112
  name: string;
113
113
  time: string;
114
- kwargs?: Record<string, unknown> | undefined;
115
- }[];
116
- trace_id?: string | undefined;
117
- dotted_order?: string | undefined;
114
+ kwargs?: Record<string, unknown>;
115
+ }>;
116
+ trace_id?: string;
117
+ dotted_order?: string;
118
118
  name: string;
119
119
  run_type: string;
120
- end_time?: number | undefined;
121
- extra?: KVMap | undefined;
122
- error?: string | undefined;
123
- serialized?: object | undefined;
120
+ end_time?: number;
121
+ extra?: KVMap;
122
+ error?: string;
123
+ serialized?: object;
124
124
  inputs: KVMap;
125
- outputs?: KVMap | undefined;
126
- reference_example_id?: string | undefined;
127
- parent_run_id?: string | undefined;
128
- tags?: string[] | undefined;
129
- attachments?: import("langsmith/schemas").Attachments | undefined;
125
+ outputs?: KVMap;
126
+ reference_example_id?: string;
127
+ parent_run_id?: string;
128
+ tags?: string[];
129
+ attachments?: import("langsmith/schemas").Attachments;
130
130
  };
131
131
  handleChatModelStart(llm: Serialized, messages: BaseMessage[][], runId: string, parentRunId?: string, extraParams?: KVMap, tags?: string[], metadata?: KVMap, name?: string): Promise<Run>;
132
132
  handleLLMEnd(output: LLMResult, runId: string, _parentRunId?: string, _tags?: string[], extraParams?: Record<string, unknown>): Promise<Run>;
@@ -142,25 +142,25 @@ export declare abstract class BaseTracer extends BaseCallbackHandler {
142
142
  execution_order: number;
143
143
  child_runs: Run[];
144
144
  child_execution_order: number;
145
- events: {
145
+ events: Array<{
146
146
  name: string;
147
147
  time: string;
148
- kwargs?: Record<string, unknown> | undefined;
149
- }[];
150
- trace_id?: string | undefined;
151
- dotted_order?: string | undefined;
148
+ kwargs?: Record<string, unknown>;
149
+ }>;
150
+ trace_id?: string;
151
+ dotted_order?: string;
152
152
  name: string;
153
153
  run_type: string;
154
- end_time?: number | undefined;
155
- extra?: KVMap | undefined;
156
- error?: string | undefined;
157
- serialized?: object | undefined;
154
+ end_time?: number;
155
+ extra?: KVMap;
156
+ error?: string;
157
+ serialized?: object;
158
158
  inputs: KVMap;
159
- outputs?: KVMap | undefined;
160
- reference_example_id?: string | undefined;
161
- parent_run_id?: string | undefined;
162
- tags?: string[] | undefined;
163
- attachments?: import("langsmith/schemas").Attachments | undefined;
159
+ outputs?: KVMap;
160
+ reference_example_id?: string;
161
+ parent_run_id?: string;
162
+ tags?: string[];
163
+ attachments?: import("langsmith/schemas").Attachments;
164
164
  };
165
165
  handleChainStart(chain: Serialized, inputs: ChainValues, runId: string, parentRunId?: string, tags?: string[], metadata?: KVMap, runType?: string, name?: string): Promise<Run>;
166
166
  handleChainEnd(outputs: ChainValues, runId: string, _parentRunId?: string, _tags?: string[], kwargs?: {
@@ -180,25 +180,25 @@ export declare abstract class BaseTracer extends BaseCallbackHandler {
180
180
  execution_order: number;
181
181
  child_runs: Run[];
182
182
  child_execution_order: number;
183
- events: {
183
+ events: Array<{
184
184
  name: string;
185
185
  time: string;
186
- kwargs?: Record<string, unknown> | undefined;
187
- }[];
188
- trace_id?: string | undefined;
189
- dotted_order?: string | undefined;
186
+ kwargs?: Record<string, unknown>;
187
+ }>;
188
+ trace_id?: string;
189
+ dotted_order?: string;
190
190
  name: string;
191
191
  run_type: string;
192
- end_time?: number | undefined;
193
- extra?: KVMap | undefined;
194
- error?: string | undefined;
195
- serialized?: object | undefined;
192
+ end_time?: number;
193
+ extra?: KVMap;
194
+ error?: string;
195
+ serialized?: object;
196
196
  inputs: KVMap;
197
- outputs?: KVMap | undefined;
198
- reference_example_id?: string | undefined;
199
- parent_run_id?: string | undefined;
200
- tags?: string[] | undefined;
201
- attachments?: import("langsmith/schemas").Attachments | undefined;
197
+ outputs?: KVMap;
198
+ reference_example_id?: string;
199
+ parent_run_id?: string;
200
+ tags?: string[];
201
+ attachments?: import("langsmith/schemas").Attachments;
202
202
  };
203
203
  handleToolStart(tool: Serialized, input: string, runId: string, parentRunId?: string, tags?: string[], metadata?: KVMap, name?: string): Promise<Run>;
204
204
  handleToolEnd(output: any, runId: string): Promise<Run>;
@@ -216,25 +216,25 @@ export declare abstract class BaseTracer extends BaseCallbackHandler {
216
216
  execution_order: number;
217
217
  child_runs: Run[];
218
218
  child_execution_order: number;
219
- events: {
219
+ events: Array<{
220
220
  name: string;
221
221
  time: string;
222
- kwargs?: Record<string, unknown> | undefined;
223
- }[];
224
- trace_id?: string | undefined;
225
- dotted_order?: string | undefined;
222
+ kwargs?: Record<string, unknown>;
223
+ }>;
224
+ trace_id?: string;
225
+ dotted_order?: string;
226
226
  name: string;
227
227
  run_type: string;
228
- end_time?: number | undefined;
229
- extra?: KVMap | undefined;
230
- error?: string | undefined;
231
- serialized?: object | undefined;
228
+ end_time?: number;
229
+ extra?: KVMap;
230
+ error?: string;
231
+ serialized?: object;
232
232
  inputs: KVMap;
233
- outputs?: KVMap | undefined;
234
- reference_example_id?: string | undefined;
235
- parent_run_id?: string | undefined;
236
- tags?: string[] | undefined;
237
- attachments?: import("langsmith/schemas").Attachments | undefined;
233
+ outputs?: KVMap;
234
+ reference_example_id?: string;
235
+ parent_run_id?: string;
236
+ tags?: string[];
237
+ attachments?: import("langsmith/schemas").Attachments;
238
238
  };
239
239
  handleRetrieverStart(retriever: Serialized, query: string, runId: string, parentRunId?: string, tags?: string[], metadata?: KVMap, name?: string): Promise<Run>;
240
240
  handleRetrieverEnd(documents: Document<Record<string, unknown>>[], runId: string): Promise<Run>;
@@ -1,6 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.getTracingV2CallbackHandler = exports.getTracingCallbackHandler = void 0;
3
+ exports.getTracingCallbackHandler = getTracingCallbackHandler;
4
+ exports.getTracingV2CallbackHandler = getTracingV2CallbackHandler;
4
5
  const tracer_langchain_js_1 = require("./tracer_langchain.cjs");
5
6
  const tracer_langchain_v1_js_1 = require("./tracer_langchain_v1.cjs");
6
7
  /**
@@ -22,7 +23,6 @@ async function getTracingCallbackHandler(session) {
22
23
  }
23
24
  return tracer;
24
25
  }
25
- exports.getTracingCallbackHandler = getTracingCallbackHandler;
26
26
  /**
27
27
  * @deprecated Instantiate directly using the LangChainTracer constructor.
28
28
  *
@@ -33,4 +33,3 @@ exports.getTracingCallbackHandler = getTracingCallbackHandler;
33
33
  async function getTracingV2CallbackHandler() {
34
34
  return new tracer_langchain_js_1.LangChainTracer();
35
35
  }
36
- exports.getTracingV2CallbackHandler = getTracingV2CallbackHandler;
@@ -7,14 +7,14 @@ exports.AsyncCaller = void 0;
7
7
  const p_retry_1 = __importDefault(require("p-retry"));
8
8
  const p_queue_1 = __importDefault(require("p-queue"));
9
9
  const STATUS_NO_RETRY = [
10
- 400,
11
- 401,
12
- 402,
13
- 403,
14
- 404,
15
- 405,
16
- 406,
17
- 407,
10
+ 400, // Bad Request
11
+ 401, // Unauthorized
12
+ 402, // Payment Required
13
+ 403, // Forbidden
14
+ 404, // Not Found
15
+ 405, // Method Not Allowed
16
+ 406, // Not Acceptable
17
+ 407, // Proxy Authentication Required
18
18
  409, // Conflict
19
19
  ];
20
20
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
@@ -84,7 +84,7 @@ class AsyncCaller {
84
84
  this.maxRetries = params.maxRetries ?? 6;
85
85
  this.onFailedAttempt =
86
86
  params.onFailedAttempt ?? defaultFailedAttemptHandler;
87
- const PQueue = "default" in p_queue_1.default ? p_queue_1.default.default : p_queue_1.default;
87
+ const PQueue = ("default" in p_queue_1.default ? p_queue_1.default.default : p_queue_1.default);
88
88
  this.queue = new PQueue({ concurrency: this.maxConcurrency });
89
89
  }
90
90
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
@@ -1,14 +1,14 @@
1
1
  import pRetry from "p-retry";
2
2
  import PQueueMod from "p-queue";
3
3
  const STATUS_NO_RETRY = [
4
- 400,
5
- 401,
6
- 402,
7
- 403,
8
- 404,
9
- 405,
10
- 406,
11
- 407,
4
+ 400, // Bad Request
5
+ 401, // Unauthorized
6
+ 402, // Payment Required
7
+ 403, // Forbidden
8
+ 404, // Not Found
9
+ 405, // Method Not Allowed
10
+ 406, // Not Acceptable
11
+ 407, // Proxy Authentication Required
12
12
  409, // Conflict
13
13
  ];
14
14
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
@@ -78,7 +78,7 @@ export class AsyncCaller {
78
78
  this.maxRetries = params.maxRetries ?? 6;
79
79
  this.onFailedAttempt =
80
80
  params.onFailedAttempt ?? defaultFailedAttemptHandler;
81
- const PQueue = "default" in PQueueMod ? PQueueMod.default : PQueueMod;
81
+ const PQueue = ("default" in PQueueMod ? PQueueMod.default : PQueueMod);
82
82
  this.queue = new PQueue({ concurrency: this.maxConcurrency });
83
83
  }
84
84
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
@@ -1,6 +1,9 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.getEnvironmentVariable = exports.getRuntimeEnvironmentSync = exports.getRuntimeEnvironment = exports.getEnv = exports.isNode = exports.isDeno = exports.isJsDom = exports.isWebWorker = exports.isBrowser = void 0;
3
+ exports.getEnv = exports.isNode = exports.isDeno = exports.isJsDom = exports.isWebWorker = exports.isBrowser = void 0;
4
+ exports.getRuntimeEnvironment = getRuntimeEnvironment;
5
+ exports.getRuntimeEnvironmentSync = getRuntimeEnvironmentSync;
6
+ exports.getEnvironmentVariable = getEnvironmentVariable;
4
7
  const isBrowser = () => typeof window !== "undefined" && typeof window.document !== "undefined";
5
8
  exports.isBrowser = isBrowser;
6
9
  const isWebWorker = () => typeof globalThis === "object" &&
@@ -50,7 +53,6 @@ let runtimeEnvironment;
50
53
  async function getRuntimeEnvironment() {
51
54
  return getRuntimeEnvironmentSync();
52
55
  }
53
- exports.getRuntimeEnvironment = getRuntimeEnvironment;
54
56
  function getRuntimeEnvironmentSync() {
55
57
  if (runtimeEnvironment === undefined) {
56
58
  const env = (0, exports.getEnv)();
@@ -61,7 +63,6 @@ function getRuntimeEnvironmentSync() {
61
63
  }
62
64
  return runtimeEnvironment;
63
65
  }
64
- exports.getRuntimeEnvironmentSync = getRuntimeEnvironmentSync;
65
66
  function getEnvironmentVariable(name) {
66
67
  // Certain Deno setups will throw an error if you try to access environment variables
67
68
  // https://github.com/langchain-ai/langchainjs/issues/1412
@@ -81,4 +82,3 @@ function getEnvironmentVariable(name) {
81
82
  return undefined;
82
83
  }
83
84
  }
84
- exports.getEnvironmentVariable = getEnvironmentVariable;
@@ -1,6 +1,10 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.convertEventStreamToIterableReadableDataStream = exports.getMessages = exports.getLines = exports.getBytes = exports.EventStreamContentType = void 0;
3
+ exports.EventStreamContentType = void 0;
4
+ exports.getBytes = getBytes;
5
+ exports.getLines = getLines;
6
+ exports.getMessages = getMessages;
7
+ exports.convertEventStreamToIterableReadableDataStream = convertEventStreamToIterableReadableDataStream;
4
8
  /* eslint-disable prefer-template */
5
9
  /* eslint-disable default-case */
6
10
  /* eslint-disable no-plusplus */
@@ -55,7 +59,6 @@ stream, onChunk) {
55
59
  }
56
60
  }
57
61
  }
58
- exports.getBytes = getBytes;
59
62
  /**
60
63
  * Parses arbitary byte chunks into EventSource line buffers.
61
64
  * Each line should be of the format "field: value" and ends with \r, \n, or \r\n.
@@ -132,7 +135,6 @@ function getLines(onLine) {
132
135
  }
133
136
  };
134
137
  }
135
- exports.getLines = getLines;
136
138
  /**
137
139
  * Parses line buffers into EventSourceMessages.
138
140
  * @param onId A function that will be called on each `id` field.
@@ -188,7 +190,6 @@ function getMessages(onMessage, onId, onRetry) {
188
190
  }
189
191
  };
190
192
  }
191
- exports.getMessages = getMessages;
192
193
  function concat(a, b) {
193
194
  const res = new Uint8Array(a.length + b.length);
194
195
  res.set(a);
@@ -232,7 +233,6 @@ function convertEventStreamToIterableReadableDataStream(stream, onMetadataEvent)
232
233
  });
233
234
  return stream_js_1.IterableReadableStream.fromReadableStream(dataStream);
234
235
  }
235
- exports.convertEventStreamToIterableReadableDataStream = convertEventStreamToIterableReadableDataStream;
236
236
  function isEmpty(message) {
237
237
  return (message.data === "" &&
238
238
  message.event === "" &&
@@ -18,13 +18,23 @@ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (
18
18
  var __exportStar = (this && this.__exportStar) || function(m, exports) {
19
19
  for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
20
20
  };
21
- var __importStar = (this && this.__importStar) || function (mod) {
22
- if (mod && mod.__esModule) return mod;
23
- var result = {};
24
- if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
25
- __setModuleDefault(result, mod);
26
- return result;
27
- };
21
+ var __importStar = (this && this.__importStar) || (function () {
22
+ var ownKeys = function(o) {
23
+ ownKeys = Object.getOwnPropertyNames || function (o) {
24
+ var ar = [];
25
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
26
+ return ar;
27
+ };
28
+ return ownKeys(o);
29
+ };
30
+ return function (mod) {
31
+ if (mod && mod.__esModule) return mod;
32
+ var result = {};
33
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
34
+ __setModuleDefault(result, mod);
35
+ return result;
36
+ };
37
+ })();
28
38
  Object.defineProperty(exports, "__esModule", { value: true });
29
39
  exports.unescapePathComponent = exports.escapePathComponent = exports.deepClone = exports.JsonPatchError = void 0;
30
40
  __exportStar(require("./src/core.cjs"), exports);
@@ -13,10 +13,10 @@ declare const _default: {
13
13
  unescapePathComponent: typeof unescapePathComponent;
14
14
  getValueByPointer(document: any, pointer: string): any;
15
15
  applyOperation<T>(document: T, operation: core.Operation, validateOperation?: boolean | core.Validator<T>, mutateDocument?: boolean, banPrototypeModifications?: boolean, index?: number): core.OperationResult<T>;
16
- applyPatch<T_1>(document: T_1, patch: readonly core.Operation[], validateOperation?: boolean | core.Validator<T_1> | undefined, mutateDocument?: boolean, banPrototypeModifications?: boolean): core.PatchResult<T_1>;
17
- applyReducer<T_2>(document: T_2, operation: core.Operation, index: number): T_2;
18
- validator(operation: core.Operation, index: number, document?: any, existingPathFragment?: string | undefined): void;
19
- validate<T_3>(sequence: readonly core.Operation[], document?: T_3 | undefined, externalValidator?: core.Validator<T_3> | undefined): JsonPatchError;
16
+ applyPatch<T>(document: T, patch: ReadonlyArray<core.Operation>, validateOperation?: boolean | core.Validator<T>, mutateDocument?: boolean, banPrototypeModifications?: boolean): core.PatchResult<T>;
17
+ applyReducer<T>(document: T, operation: core.Operation, index: number): T;
18
+ validator(operation: core.Operation, index: number, document?: any, existingPathFragment?: string): void;
19
+ validate<T>(sequence: ReadonlyArray<core.Operation>, document?: T, externalValidator?: core.Validator<T>): JsonPatchError;
20
20
  _areEquals(a: any, b: any): boolean;
21
21
  };
22
22
  export default _default;
@@ -1,7 +1,14 @@
1
1
  "use strict";
2
2
  // @ts-nocheck
3
3
  Object.defineProperty(exports, "__esModule", { value: true });
4
- exports._areEquals = exports.validate = exports.validator = exports.applyReducer = exports.applyPatch = exports.applyOperation = exports.getValueByPointer = exports.deepClone = exports.JsonPatchError = void 0;
4
+ exports.deepClone = exports.JsonPatchError = void 0;
5
+ exports.getValueByPointer = getValueByPointer;
6
+ exports.applyOperation = applyOperation;
7
+ exports.applyPatch = applyPatch;
8
+ exports.applyReducer = applyReducer;
9
+ exports.validator = validator;
10
+ exports.validate = validate;
11
+ exports._areEquals = _areEquals;
5
12
  const helpers_js_1 = require("./helpers.cjs");
6
13
  exports.JsonPatchError = helpers_js_1.PatchError;
7
14
  exports.deepClone = helpers_js_1._deepClone;
@@ -107,7 +114,6 @@ function getValueByPointer(document, pointer) {
107
114
  applyOperation(document, getOriginalDestination);
108
115
  return getOriginalDestination.value;
109
116
  }
110
- exports.getValueByPointer = getValueByPointer;
111
117
  /**
112
118
  * Apply a single JSON Patch Operation on a JSON document.
113
119
  * Returns the {newDocument, result} of the operation.
@@ -263,7 +269,6 @@ function applyOperation(document, operation, validateOperation = false, mutateDo
263
269
  }
264
270
  }
265
271
  }
266
- exports.applyOperation = applyOperation;
267
272
  /**
268
273
  * Apply a full JSON Patch array on a JSON document.
269
274
  * Returns the {newDocument, result} of the patch.
@@ -296,7 +301,6 @@ function applyPatch(document, patch, validateOperation, mutateDocument = true, b
296
301
  results.newDocument = document;
297
302
  return results;
298
303
  }
299
- exports.applyPatch = applyPatch;
300
304
  /**
301
305
  * Apply a single JSON Patch Operation on a JSON document.
302
306
  * Returns the updated document.
@@ -314,7 +318,6 @@ function applyReducer(document, operation, index) {
314
318
  }
315
319
  return operationResult.newDocument;
316
320
  }
317
- exports.applyReducer = applyReducer;
318
321
  /**
319
322
  * Validates a single operation. Called from `jsonpatch.validate`. Throws `JsonPatchError` in case of an error.
320
323
  * @param {object} operation - operation object (patch)
@@ -382,7 +385,6 @@ function validator(operation, index, document, existingPathFragment) {
382
385
  }
383
386
  }
384
387
  }
385
- exports.validator = validator;
386
388
  /**
387
389
  * Validates a sequence of operations. If `document` parameter is provided, the sequence is additionally validated against the object document.
388
390
  * If error is encountered, returns a JsonPatchError object
@@ -415,7 +417,6 @@ function validate(sequence, document, externalValidator) {
415
417
  }
416
418
  }
417
419
  }
418
- exports.validate = validate;
419
420
  // based on https://github.com/epoberezkin/fast-deep-equal
420
421
  // MIT License
421
422
  // Copyright (c) 2017 Evgeny Poberezkin
@@ -466,4 +467,3 @@ function _areEquals(a, b) {
466
467
  }
467
468
  return a !== a && b !== b;
468
469
  }
469
- exports._areEquals = _areEquals;
@@ -1,7 +1,10 @@
1
1
  "use strict";
2
2
  // @ts-nocheck
3
3
  Object.defineProperty(exports, "__esModule", { value: true });
4
- exports.compare = exports.generate = exports.observe = exports.unobserve = void 0;
4
+ exports.unobserve = unobserve;
5
+ exports.observe = observe;
6
+ exports.generate = generate;
7
+ exports.compare = compare;
5
8
  // Inlined because of ESM import issues
6
9
  /*!
7
10
  * https://github.com/Starcounter-Jack/JSON-Patch
@@ -67,7 +70,6 @@ function removeObserverFromMirror(mirror, observer) {
67
70
  function unobserve(root, observer) {
68
71
  observer.unobserve();
69
72
  }
70
- exports.unobserve = unobserve;
71
73
  /**
72
74
  * Observes changes made to an object, which can then be retrieved using generate
73
75
  */
@@ -124,7 +126,6 @@ function observe(obj, callback) {
124
126
  mirror.observers.set(callback, new ObserverInfo(callback, observer));
125
127
  return observer;
126
128
  }
127
- exports.observe = observe;
128
129
  /**
129
130
  * Generate an array of patches from an observer
130
131
  */
@@ -143,7 +144,6 @@ function generate(observer, invertible = false) {
143
144
  }
144
145
  return temp;
145
146
  }
146
- exports.generate = generate;
147
147
  // Dirty check if obj is different from mirror, generate patches and update mirror
148
148
  function _generate(mirror, obj, patches, path, invertible) {
149
149
  if (obj === mirror) {
@@ -234,4 +234,3 @@ function compare(tree1, tree2, invertible = false) {
234
234
  _generate(tree1, tree2, patches, "", invertible);
235
235
  return patches;
236
236
  }
237
- exports.compare = compare;
@@ -1,7 +1,16 @@
1
1
  "use strict";
2
2
  // @ts-nocheck
3
3
  Object.defineProperty(exports, "__esModule", { value: true });
4
- exports.PatchError = exports.hasUndefined = exports.getPath = exports._getPathRecursive = exports.unescapePathComponent = exports.escapePathComponent = exports.isInteger = exports._deepClone = exports._objectKeys = exports.hasOwnProperty = void 0;
4
+ exports.PatchError = void 0;
5
+ exports.hasOwnProperty = hasOwnProperty;
6
+ exports._objectKeys = _objectKeys;
7
+ exports._deepClone = _deepClone;
8
+ exports.isInteger = isInteger;
9
+ exports.escapePathComponent = escapePathComponent;
10
+ exports.unescapePathComponent = unescapePathComponent;
11
+ exports._getPathRecursive = _getPathRecursive;
12
+ exports.getPath = getPath;
13
+ exports.hasUndefined = hasUndefined;
5
14
  // Inlined because of ESM import issues
6
15
  /*!
7
16
  * https://github.com/Starcounter-Jack/JSON-Patch
@@ -12,7 +21,6 @@ const _hasOwnProperty = Object.prototype.hasOwnProperty;
12
21
  function hasOwnProperty(obj, key) {
13
22
  return _hasOwnProperty.call(obj, key);
14
23
  }
15
- exports.hasOwnProperty = hasOwnProperty;
16
24
  function _objectKeys(obj) {
17
25
  if (Array.isArray(obj)) {
18
26
  const keys = new Array(obj.length);
@@ -32,7 +40,6 @@ function _objectKeys(obj) {
32
40
  }
33
41
  return keys;
34
42
  }
35
- exports._objectKeys = _objectKeys;
36
43
  /**
37
44
  * Deeply clone the object.
38
45
  * https://jsperf.com/deep-copy-vs-json-stringify-json-parse/25 (recursiveDeepCopy)
@@ -49,7 +56,6 @@ function _deepClone(obj) {
49
56
  return obj; //no need to clone primitives
50
57
  }
51
58
  }
52
- exports._deepClone = _deepClone;
53
59
  //3x faster than cached /^\d+$/.test(str)
54
60
  function isInteger(str) {
55
61
  let i = 0;
@@ -65,7 +71,6 @@ function isInteger(str) {
65
71
  }
66
72
  return true;
67
73
  }
68
- exports.isInteger = isInteger;
69
74
  /**
70
75
  * Escapes a json pointer path
71
76
  * @param path The raw pointer
@@ -76,7 +81,6 @@ function escapePathComponent(path) {
76
81
  return path;
77
82
  return path.replace(/~/g, "~0").replace(/\//g, "~1");
78
83
  }
79
- exports.escapePathComponent = escapePathComponent;
80
84
  /**
81
85
  * Unescapes a json pointer path
82
86
  * @param path The escaped pointer
@@ -85,7 +89,6 @@ exports.escapePathComponent = escapePathComponent;
85
89
  function unescapePathComponent(path) {
86
90
  return path.replace(/~1/g, "/").replace(/~0/g, "~");
87
91
  }
88
- exports.unescapePathComponent = unescapePathComponent;
89
92
  function _getPathRecursive(root, obj) {
90
93
  let found;
91
94
  for (let key in root) {
@@ -103,7 +106,6 @@ function _getPathRecursive(root, obj) {
103
106
  }
104
107
  return "";
105
108
  }
106
- exports._getPathRecursive = _getPathRecursive;
107
109
  function getPath(root, obj) {
108
110
  if (root === obj) {
109
111
  return "/";
@@ -114,7 +116,6 @@ function getPath(root, obj) {
114
116
  }
115
117
  return `/${path}`;
116
118
  }
117
- exports.getPath = getPath;
118
119
  /**
119
120
  * Recursively checks whether an object has any undefined values inside.
120
121
  */
@@ -142,7 +143,6 @@ function hasUndefined(obj) {
142
143
  }
143
144
  return false;
144
145
  }
145
- exports.hasUndefined = hasUndefined;
146
146
  function patchErrorMessageFormatter(message, args) {
147
147
  const messageParts = [message];
148
148
  for (const key in args) {
@@ -30,7 +30,7 @@ export type JsonPatchErrorName = "SEQUENCE_NOT_AN_ARRAY" | "OPERATION_NOT_AN_OBJ
30
30
  export declare class PatchError extends Error {
31
31
  name: JsonPatchErrorName;
32
32
  index?: number | undefined;
33
- operation?: any;
34
- tree?: any;
35
- constructor(message: string, name: JsonPatchErrorName, index?: number | undefined, operation?: any, tree?: any);
33
+ operation?: any | undefined;
34
+ tree?: any | undefined;
35
+ constructor(message: string, name: JsonPatchErrorName, index?: number | undefined, operation?: any | undefined, tree?: any | undefined);
36
36
  }