openai 5.8.2 → 5.8.4

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 (63) hide show
  1. package/CHANGELOG.md +25 -0
  2. package/azure.d.mts +3 -3
  3. package/azure.d.mts.map +1 -1
  4. package/azure.d.ts +3 -3
  5. package/azure.d.ts.map +1 -1
  6. package/azure.js +2 -2
  7. package/azure.js.map +1 -1
  8. package/azure.mjs +2 -2
  9. package/azure.mjs.map +1 -1
  10. package/client.d.mts +5 -3
  11. package/client.d.mts.map +1 -1
  12. package/client.d.ts +5 -3
  13. package/client.d.ts.map +1 -1
  14. package/client.js +12 -9
  15. package/client.js.map +1 -1
  16. package/client.mjs +12 -9
  17. package/client.mjs.map +1 -1
  18. package/core/streaming.d.mts +5 -3
  19. package/core/streaming.d.mts.map +1 -1
  20. package/core/streaming.d.ts +5 -3
  21. package/core/streaming.d.ts.map +1 -1
  22. package/core/streaming.js +16 -10
  23. package/core/streaming.js.map +1 -1
  24. package/core/streaming.mjs +16 -10
  25. package/core/streaming.mjs.map +1 -1
  26. package/internal/parse.js +2 -2
  27. package/internal/parse.js.map +1 -1
  28. package/internal/parse.mjs +2 -2
  29. package/internal/parse.mjs.map +1 -1
  30. package/internal/request-options.d.mts +42 -0
  31. package/internal/request-options.d.mts.map +1 -1
  32. package/internal/request-options.d.ts +42 -0
  33. package/internal/request-options.d.ts.map +1 -1
  34. package/internal/request-options.js.map +1 -1
  35. package/internal/request-options.mjs.map +1 -1
  36. package/internal/uploads.js +1 -1
  37. package/internal/uploads.js.map +1 -1
  38. package/internal/uploads.mjs +1 -1
  39. package/internal/uploads.mjs.map +1 -1
  40. package/internal/utils/log.js +1 -1
  41. package/internal/utils/log.js.map +1 -1
  42. package/internal/utils/log.mjs +1 -1
  43. package/internal/utils/log.mjs.map +1 -1
  44. package/internal/utils/path.d.mts.map +1 -1
  45. package/internal/utils/path.d.ts.map +1 -1
  46. package/internal/utils/path.js +26 -5
  47. package/internal/utils/path.js.map +1 -1
  48. package/internal/utils/path.mjs +26 -5
  49. package/internal/utils/path.mjs.map +1 -1
  50. package/package.json +1 -1
  51. package/src/azure.ts +3 -3
  52. package/src/client.ts +16 -11
  53. package/src/core/streaming.ts +22 -8
  54. package/src/internal/parse.ts +2 -2
  55. package/src/internal/request-options.ts +53 -0
  56. package/src/internal/uploads.ts +1 -1
  57. package/src/internal/utils/log.ts +1 -1
  58. package/src/internal/utils/path.ts +32 -7
  59. package/src/version.ts +1 -1
  60. package/version.d.mts +1 -1
  61. package/version.d.ts +1 -1
  62. package/version.js +1 -1
  63. package/version.mjs +1 -1
@@ -12,25 +12,43 @@ export function encodeURIPath(str: string) {
12
12
  return str.replace(/[^A-Za-z0-9\-._~!$&'()*+,;=:@]+/g, encodeURIComponent);
13
13
  }
14
14
 
15
+ const EMPTY = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.create(null));
16
+
15
17
  export const createPathTagFunction = (pathEncoder = encodeURIPath) =>
16
18
  function path(statics: readonly string[], ...params: readonly unknown[]): string {
17
19
  // If there are no params, no processing is needed.
18
20
  if (statics.length === 1) return statics[0]!;
19
21
 
20
22
  let postPath = false;
23
+ const invalidSegments = [];
21
24
  const path = statics.reduce((previousValue, currentValue, index) => {
22
25
  if (/[?#]/.test(currentValue)) {
23
26
  postPath = true;
24
27
  }
25
- return (
26
- previousValue +
27
- currentValue +
28
- (index === params.length ? '' : (postPath ? encodeURIComponent : pathEncoder)(String(params[index])))
29
- );
28
+ const value = params[index];
29
+ let encoded = (postPath ? encodeURIComponent : pathEncoder)('' + value);
30
+ if (
31
+ index !== params.length &&
32
+ (value == null ||
33
+ (typeof value === 'object' &&
34
+ // handle values from other realms
35
+ value.toString ===
36
+ Object.getPrototypeOf(Object.getPrototypeOf((value as any).hasOwnProperty ?? EMPTY) ?? EMPTY)
37
+ ?.toString))
38
+ ) {
39
+ encoded = value + '';
40
+ invalidSegments.push({
41
+ start: previousValue.length + currentValue.length,
42
+ length: encoded.length,
43
+ error: `Value of type ${Object.prototype.toString
44
+ .call(value)
45
+ .slice(8, -1)} is not a valid path parameter`,
46
+ });
47
+ }
48
+ return previousValue + currentValue + (index === params.length ? '' : encoded);
30
49
  }, '');
31
50
 
32
51
  const pathOnly = path.split(/[?#]/, 1)[0]!;
33
- const invalidSegments = [];
34
52
  const invalidSegmentPattern = /(?<=^|\/)(?:\.|%2e){1,2}(?=\/|$)/gi;
35
53
  let match;
36
54
 
@@ -39,9 +57,12 @@ export const createPathTagFunction = (pathEncoder = encodeURIPath) =>
39
57
  invalidSegments.push({
40
58
  start: match.index,
41
59
  length: match[0].length,
60
+ error: `Value "${match[0]}" can\'t be safely passed as a path parameter`,
42
61
  });
43
62
  }
44
63
 
64
+ invalidSegments.sort((a, b) => a.start - b.start);
65
+
45
66
  if (invalidSegments.length > 0) {
46
67
  let lastEnd = 0;
47
68
  const underline = invalidSegments.reduce((acc, segment) => {
@@ -51,7 +72,11 @@ export const createPathTagFunction = (pathEncoder = encodeURIPath) =>
51
72
  return acc + spaces + arrows;
52
73
  }, '');
53
74
 
54
- throw new OpenAIError(`Path parameters result in path with invalid segments:\n${path}\n${underline}`);
75
+ throw new OpenAIError(
76
+ `Path parameters result in path with invalid segments:\n${invalidSegments
77
+ .map((e) => e.error)
78
+ .join('\n')}\n${path}\n${underline}`,
79
+ );
55
80
  }
56
81
 
57
82
  return path;
package/src/version.ts CHANGED
@@ -1 +1 @@
1
- export const VERSION = '5.8.2'; // x-release-please-version
1
+ export const VERSION = '5.8.4'; // x-release-please-version
package/version.d.mts CHANGED
@@ -1,2 +1,2 @@
1
- export declare const VERSION = "5.8.2";
1
+ export declare const VERSION = "5.8.4";
2
2
  //# sourceMappingURL=version.d.mts.map
package/version.d.ts CHANGED
@@ -1,2 +1,2 @@
1
- export declare const VERSION = "5.8.2";
1
+ export declare const VERSION = "5.8.4";
2
2
  //# sourceMappingURL=version.d.ts.map
package/version.js CHANGED
@@ -1,5 +1,5 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.VERSION = void 0;
4
- exports.VERSION = '5.8.2'; // x-release-please-version
4
+ exports.VERSION = '5.8.4'; // x-release-please-version
5
5
  //# sourceMappingURL=version.js.map
package/version.mjs CHANGED
@@ -1,2 +1,2 @@
1
- export const VERSION = '5.8.2'; // x-release-please-version
1
+ export const VERSION = '5.8.4'; // x-release-please-version
2
2
  //# sourceMappingURL=version.mjs.map