@pdfvector/client 0.1.0 → 0.1.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.mjs CHANGED
@@ -1,14 +1,20 @@
1
1
  Array.isArray;
2
- // ../../node_modules/.bun/@orpc+shared@1.15.2+e40b0dfdd726a224/node_modules/@orpc/shared/dist/index.mjs
2
+ // ../../node_modules/.bun/@orpc+shared@1.16.2+e40b0dfdd726a224/node_modules/@orpc/shared/dist/index.mjs
3
3
  function resolveMaybeOptionalOptions(rest) {
4
4
  return rest[0] ?? {};
5
5
  }
6
6
  function toArray(value) {
7
7
  return Array.isArray(value) ? value : value === void 0 || value === null ? [] : [value];
8
8
  }
9
+ const DEFAULT_MAX_BIGINT_DIGITS = 4300;
10
+ const BIGINT_PATTERN = /^-?(?:0|[1-9]\d*)$/;
11
+ function parseBigIntString(value, maxDigits) {
12
+ if ((value.startsWith("-") ? value.length - 1 : value.length) > maxDigits || !BIGINT_PATTERN.test(value)) return;
13
+ return BigInt(value);
14
+ }
9
15
  const ORPC_NAME = "orpc";
10
16
  const ORPC_SHARED_PACKAGE_NAME = "@orpc/shared";
11
- const ORPC_SHARED_PACKAGE_VERSION = "1.15.2";
17
+ const ORPC_SHARED_PACKAGE_VERSION = "1.16.2";
12
18
  var AbortError = class extends Error {
13
19
  constructor(...rest) {
14
20
  super(...rest);
@@ -214,6 +220,25 @@ function isObject(value) {
214
220
  function isTypescriptObject(value) {
215
221
  return !!value && (typeof value === "object" || typeof value === "function");
216
222
  }
223
+ function setOwn(object, key, value) {
224
+ if (key === "__proto__") Object.defineProperty(object, key, {
225
+ value,
226
+ writable: true,
227
+ enumerable: true,
228
+ configurable: true
229
+ });
230
+ else object[key] = value;
231
+ }
232
+ function copyOnWrite(parent, key, original) {
233
+ const value = parent[key];
234
+ if (value !== original) return value;
235
+ let copy;
236
+ if (Array.isArray(value)) copy = value.slice();
237
+ else if (isObject(value)) copy = { ...value };
238
+ else return value;
239
+ setOwn(parent, key, copy);
240
+ return copy;
241
+ }
217
242
  function value(value2, ...args) {
218
243
  if (typeof value2 === "function") return value2(...args);
219
244
  return value2;
@@ -285,9 +310,9 @@ function tryDecodeURIComponent(value) {
285
310
  return value;
286
311
  }
287
312
  }
288
- // ../../node_modules/.bun/@orpc+client@1.15.2+e40b0dfdd726a224/node_modules/@orpc/client/dist/shared/client.t2tsjbV-.mjs
313
+ // ../../node_modules/.bun/@orpc+client@1.16.2+e40b0dfdd726a224/node_modules/@orpc/client/dist/shared/client.DeR0HTYb.mjs
289
314
  const ORPC_CLIENT_PACKAGE_NAME = "@orpc/client";
290
- const ORPC_CLIENT_PACKAGE_VERSION = "1.15.2";
315
+ const ORPC_CLIENT_PACKAGE_VERSION = "1.16.2";
291
316
  const RECURSIVE_CLIENT_UNWRAP_KEYS = /* @__PURE__ */ new Set([
292
317
  "bind",
293
318
  "valueOf",
@@ -456,7 +481,7 @@ function createORPCErrorFromJson(json, options = {}) {
456
481
  ...json
457
482
  });
458
483
  }
459
- // ../../node_modules/.bun/@orpc+standard-server@1.15.2+e40b0dfdd726a224/node_modules/@orpc/standard-server/dist/index.mjs
484
+ // ../../node_modules/.bun/@orpc+standard-server@1.16.2+e40b0dfdd726a224/node_modules/@orpc/standard-server/dist/index.mjs
460
485
  var EventEncoderError = class extends TypeError {};
461
486
  var EventDecoderError = class extends TypeError {};
462
487
  var ErrorEvent = class extends Error {
@@ -657,7 +682,7 @@ function mergeStandardHeaders(a, b) {
657
682
  }
658
683
  return merged;
659
684
  }
660
- // ../../node_modules/.bun/@orpc+client@1.15.2+e40b0dfdd726a224/node_modules/@orpc/client/dist/shared/client.BLtwTQUg.mjs
685
+ // ../../node_modules/.bun/@orpc+client@1.16.2+e40b0dfdd726a224/node_modules/@orpc/client/dist/shared/client.BLtwTQUg.mjs
661
686
  function mapEventIterator(iterator, maps) {
662
687
  const mapError = async (error) => {
663
688
  let mappedError = await maps.error(error);
@@ -692,7 +717,7 @@ function mapEventIterator(iterator, maps) {
692
717
  }
693
718
  });
694
719
  }
695
- // ../../node_modules/.bun/@orpc+client@1.15.2+e40b0dfdd726a224/node_modules/@orpc/client/dist/index.mjs
720
+ // ../../node_modules/.bun/@orpc+client@1.16.2+e40b0dfdd726a224/node_modules/@orpc/client/dist/index.mjs
696
721
  function resolveFriendlyClientOptions(options) {
697
722
  return {
698
723
  ...options,
@@ -712,7 +737,7 @@ function createORPCClient(link, options = {}) {
712
737
  });
713
738
  } }));
714
739
  }
715
- // ../../node_modules/.bun/@orpc+standard-server-fetch@1.15.2+e40b0dfdd726a224/node_modules/@orpc/standard-server-fetch/dist/index.mjs
740
+ // ../../node_modules/.bun/@orpc+standard-server-fetch@1.16.2+e40b0dfdd726a224/node_modules/@orpc/standard-server-fetch/dist/index.mjs
716
741
  function toEventIterator(stream, options = {}) {
717
742
  const reader = (stream?.pipeThrough(new TextDecoderStream()).pipeThrough(new EventDecoderStream()))?.getReader();
718
743
  let span;
@@ -733,7 +758,7 @@ function toEventIterator(stream, options = {}) {
733
758
  value: void 0
734
759
  };
735
760
  }
736
- switch (value.event) {
761
+ switch (value.event ?? (value.data !== void 0 ? "message" : void 0)) {
737
762
  case "message": {
738
763
  let message = parseEmptyableJSON(value.data);
739
764
  if (isTypescriptObject(message)) message = withEventMeta(message, value);
@@ -749,7 +774,8 @@ function toEventIterator(stream, options = {}) {
749
774
  span?.addEvent("error");
750
775
  throw error;
751
776
  }
752
- case "done": {
777
+ case "done":
778
+ case "close": {
753
779
  let done2 = parseEmptyableJSON(value.data);
754
780
  if (isTypescriptObject(done2)) done2 = withEventMeta(done2, value);
755
781
  span?.addEvent("done");
@@ -938,7 +964,7 @@ function toStandardLazyResponse(response, options = {}) {
938
964
  }
939
965
  };
940
966
  }
941
- // ../../node_modules/.bun/@orpc+client@1.15.2+e40b0dfdd726a224/node_modules/@orpc/client/dist/shared/client.BKdRDdCe.mjs
967
+ // ../../node_modules/.bun/@orpc+client@1.16.2+e40b0dfdd726a224/node_modules/@orpc/client/dist/shared/client.BmCiDGqJ.mjs
942
968
  var CompositeStandardLinkPlugin = class {
943
969
  plugins;
944
970
  constructor(plugins = []) {
@@ -1146,24 +1172,31 @@ var StandardRPCJsonSerializer = class {
1146
1172
  }
1147
1173
  deserialize(json, meta, maps, getBlob) {
1148
1174
  const ref = { data: json };
1175
+ const input = { data: json };
1149
1176
  if (maps && getBlob) maps.forEach((segments, i) => {
1177
+ const blob = getBlob(i);
1178
+ if (!(blob instanceof Blob)) throw invalidSerializedData(`blob ${i} is not a Blob.`);
1179
+ let original = input;
1150
1180
  let currentRef = ref;
1151
1181
  let preSegment = "data";
1152
1182
  segments.forEach((segment) => {
1153
- currentRef = currentRef[preSegment];
1183
+ original = original[preSegment];
1184
+ currentRef = copyOnWrite(currentRef, preSegment, original);
1154
1185
  preSegment = segment;
1155
1186
  if (!Object.hasOwn(currentRef, preSegment)) throw invalidSerializedData(`segment "${preSegment}" does not exist.`);
1156
1187
  });
1157
- currentRef[preSegment] = getBlob(i);
1188
+ currentRef[preSegment] = blob;
1158
1189
  });
1159
1190
  for (const item of meta) {
1160
1191
  const type = item[0];
1161
1192
  const custom = this.customSerializers.find((custom2) => custom2.type === type);
1162
1193
  if (custom === void 0 && !BUILT_IN_TYPES.has(type)) continue;
1194
+ let original = input;
1163
1195
  let currentRef = ref;
1164
1196
  let preSegment = "data";
1165
1197
  for (let i = 1; i < item.length; i++) {
1166
- currentRef = currentRef[preSegment];
1198
+ original = original[preSegment];
1199
+ currentRef = copyOnWrite(currentRef, preSegment, original);
1167
1200
  preSegment = item[i];
1168
1201
  if (!Object.hasOwn(currentRef, preSegment)) throw invalidSerializedData(`segment "${preSegment}" does not exist.`);
1169
1202
  }
@@ -1173,10 +1206,13 @@ var StandardRPCJsonSerializer = class {
1173
1206
  }
1174
1207
  const serialized = currentRef[preSegment];
1175
1208
  switch (type) {
1176
- case STANDARD_RPC_JSON_SERIALIZER_BUILT_IN_TYPES.BIGINT:
1209
+ case STANDARD_RPC_JSON_SERIALIZER_BUILT_IN_TYPES.BIGINT: {
1177
1210
  if (typeof serialized !== "string") throw invalidSerializedType(type, "bigint", "a string");
1178
- currentRef[preSegment] = BigInt(serialized);
1211
+ const value = parseBigIntString(serialized, DEFAULT_MAX_BIGINT_DIGITS);
1212
+ if (value === void 0) throw invalidSerializedType(type, "bigint", `a decimal integer string of at most ${DEFAULT_MAX_BIGINT_DIGITS} digits`);
1213
+ currentRef[preSegment] = value;
1179
1214
  break;
1215
+ }
1180
1216
  case STANDARD_RPC_JSON_SERIALIZER_BUILT_IN_TYPES.DATE:
1181
1217
  if (typeof serialized !== "string" && serialized !== null) throw invalidSerializedType(type, "date", "a string or null");
1182
1218
  currentRef[preSegment] = new Date(serialized ?? NaN);
@@ -1265,6 +1301,7 @@ var StandardRPCLinkCodec = class {
1265
1301
  };
1266
1302
  }
1267
1303
  async decode(response) {
1304
+ if (response.status >= 300 && response.status < 400) throw new Error(`Unexpected redirect response (status ${response.status}): RPCLink does not follow redirects.`);
1268
1305
  const isOk = !isORPCErrorStatus(response.status);
1269
1306
  const deserialized = await (async () => {
1270
1307
  let isBodyOk = false;
@@ -1352,7 +1389,7 @@ var StandardRPCLink = class extends StandardLink {
1352
1389
  super(linkCodec, linkClient, options);
1353
1390
  }
1354
1391
  };
1355
- // ../../node_modules/.bun/@orpc+client@1.15.2+e40b0dfdd726a224/node_modules/@orpc/client/dist/adapters/fetch/index.mjs
1392
+ // ../../node_modules/.bun/@orpc+client@1.16.2+e40b0dfdd726a224/node_modules/@orpc/client/dist/adapters/fetch/index.mjs
1356
1393
  var CompositeLinkFetchPlugin = class extends CompositeStandardLinkPlugin {
1357
1394
  initRuntimeAdapter(options) {
1358
1395
  for (const plugin of this.plugins) plugin.initRuntimeAdapter?.(options);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pdfvector/client",
3
- "version": "0.1.0",
3
+ "version": "0.1.2",
4
4
  "type": "module",
5
5
  "description": "Official TypeScript/JavaScript SDK for PDF Vector API",
6
6
  "license": "MIT",
@@ -50,7 +50,7 @@
50
50
  "node": ">=18"
51
51
  },
52
52
  "dependencies": {
53
- "zod": "^4.6.5"
53
+ "zod": "^4.6.7"
54
54
  },
55
55
  "module": "./dist/index.mjs",
56
56
  "types": "./dist/index.d.cts",