scorecard-ai 2.0.0-alpha.1 → 2.1.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 (91) hide show
  1. package/CHANGELOG.md +79 -0
  2. package/client.d.mts +5 -3
  3. package/client.d.mts.map +1 -1
  4. package/client.d.ts +5 -3
  5. package/client.d.ts.map +1 -1
  6. package/client.js +14 -11
  7. package/client.js.map +1 -1
  8. package/client.mjs +14 -11
  9. package/client.mjs.map +1 -1
  10. package/internal/request-options.d.mts +42 -0
  11. package/internal/request-options.d.mts.map +1 -1
  12. package/internal/request-options.d.ts +42 -0
  13. package/internal/request-options.d.ts.map +1 -1
  14. package/internal/request-options.js.map +1 -1
  15. package/internal/request-options.mjs.map +1 -1
  16. package/internal/types.d.mts +8 -6
  17. package/internal/types.d.mts.map +1 -1
  18. package/internal/types.d.ts +8 -6
  19. package/internal/types.d.ts.map +1 -1
  20. package/internal/uploads.js +1 -1
  21. package/internal/uploads.js.map +1 -1
  22. package/internal/uploads.mjs +1 -1
  23. package/internal/uploads.mjs.map +1 -1
  24. package/internal/utils/log.js +1 -1
  25. package/internal/utils/log.js.map +1 -1
  26. package/internal/utils/log.mjs +1 -1
  27. package/internal/utils/log.mjs.map +1 -1
  28. package/internal/utils/path.d.mts.map +1 -1
  29. package/internal/utils/path.d.ts.map +1 -1
  30. package/internal/utils/path.js +26 -5
  31. package/internal/utils/path.js.map +1 -1
  32. package/internal/utils/path.mjs +26 -5
  33. package/internal/utils/path.mjs.map +1 -1
  34. package/internal/utils/values.js +3 -3
  35. package/internal/utils/values.js.map +1 -1
  36. package/internal/utils/values.mjs +3 -3
  37. package/internal/utils/values.mjs.map +1 -1
  38. package/package.json +4 -5
  39. package/resources/records.d.mts +18 -7
  40. package/resources/records.d.mts.map +1 -1
  41. package/resources/records.d.ts +18 -7
  42. package/resources/records.d.ts.map +1 -1
  43. package/resources/records.js.map +1 -1
  44. package/resources/records.mjs.map +1 -1
  45. package/resources/scores.d.mts +6 -2
  46. package/resources/scores.d.mts.map +1 -1
  47. package/resources/scores.d.ts +6 -2
  48. package/resources/scores.d.ts.map +1 -1
  49. package/resources/shared.d.mts +3 -1
  50. package/resources/shared.d.mts.map +1 -1
  51. package/resources/shared.d.ts +3 -1
  52. package/resources/shared.d.ts.map +1 -1
  53. package/resources/systems/systems.d.mts +3 -1
  54. package/resources/systems/systems.d.mts.map +1 -1
  55. package/resources/systems/systems.d.ts +3 -1
  56. package/resources/systems/systems.d.ts.map +1 -1
  57. package/resources/systems/versions.d.mts +6 -2
  58. package/resources/systems/versions.d.mts.map +1 -1
  59. package/resources/systems/versions.d.ts +6 -2
  60. package/resources/systems/versions.d.ts.map +1 -1
  61. package/resources/testcases.d.mts +15 -5
  62. package/resources/testcases.d.mts.map +1 -1
  63. package/resources/testcases.d.ts +15 -5
  64. package/resources/testcases.d.ts.map +1 -1
  65. package/resources/testsets.d.mts +9 -3
  66. package/resources/testsets.d.mts.map +1 -1
  67. package/resources/testsets.d.ts +9 -3
  68. package/resources/testsets.d.ts.map +1 -1
  69. package/src/client.ts +20 -13
  70. package/src/internal/request-options.ts +53 -0
  71. package/src/internal/types.ts +9 -6
  72. package/src/internal/uploads.ts +1 -1
  73. package/src/internal/utils/log.ts +1 -1
  74. package/src/internal/utils/path.ts +30 -7
  75. package/src/internal/utils/values.ts +3 -3
  76. package/src/resources/records.ts +6 -7
  77. package/src/resources/scores.ts +2 -2
  78. package/src/resources/shared.ts +1 -1
  79. package/src/resources/systems/systems.ts +1 -1
  80. package/src/resources/systems/versions.ts +2 -2
  81. package/src/resources/testcases.ts +5 -5
  82. package/src/resources/testsets.ts +3 -3
  83. package/src/version.ts +1 -1
  84. package/version.d.mts +1 -1
  85. package/version.d.mts.map +1 -1
  86. package/version.d.ts +1 -1
  87. package/version.d.ts.map +1 -1
  88. package/version.js +1 -1
  89. package/version.js.map +1 -1
  90. package/version.mjs +1 -1
  91. package/version.mjs.map +1 -1
@@ -1 +1 @@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B,EAC/C,KAAK,iBAAiB,IAAI,iBAAiB,GAC5C,CAAC;CACH"}
@@ -128,7 +128,9 @@ export interface Testset {
128
128
  /**
129
129
  * The JSON schema for each Testcase in the Testset.
130
130
  */
131
- jsonSchema: Record<string, unknown>;
131
+ jsonSchema: {
132
+ [key: string]: unknown;
133
+ };
132
134
  /**
133
135
  * The name of the Testset.
134
136
  */
@@ -173,7 +175,9 @@ export interface TestsetCreateParams {
173
175
  /**
174
176
  * The JSON schema for each Testcase in the Testset.
175
177
  */
176
- jsonSchema: Record<string, unknown>;
178
+ jsonSchema: {
179
+ [key: string]: unknown;
180
+ };
177
181
  /**
178
182
  * The name of the Testset.
179
183
  */
@@ -212,7 +216,9 @@ export interface TestsetUpdateParams {
212
216
  /**
213
217
  * The JSON schema for each Testcase in the Testset.
214
218
  */
215
- jsonSchema?: Record<string, unknown>;
219
+ jsonSchema?: {
220
+ [key: string]: unknown;
221
+ };
216
222
  /**
217
223
  * The name of the Testset.
218
224
  */
@@ -1 +1 @@
1
- {"version":3,"file":"testsets.d.ts","sourceRoot":"","sources":["../src/resources/testsets.ts"],"names":[],"mappings":"OAEO,EAAE,WAAW,EAAE;OACf,EAAE,UAAU,EAAE;OACd,EAAE,WAAW,EAAE,iBAAiB,EAAE,KAAK,uBAAuB,EAAE;OAChE,EAAE,cAAc,EAAE;AAGzB,qBAAa,QAAS,SAAQ,WAAW;IACvC;;;;;;;;;;;;;;;;;;;;;;;;;OAyBG;IACH,MAAM,CAAC,SAAS,EAAE,MAAM,EAAE,IAAI,EAAE,mBAAmB,EAAE,OAAO,CAAC,EAAE,cAAc,GAAG,UAAU,CAAC,OAAO,CAAC;IAInG;;;;;;;;;;;;;;;;;;;;;OAqBG;IACH,MAAM,CACJ,SAAS,EAAE,MAAM,EACjB,IAAI,GAAE,mBAAmB,GAAG,IAAI,GAAG,SAAc,EACjD,OAAO,CAAC,EAAE,cAAc,GACvB,UAAU,CAAC,OAAO,CAAC;IAItB;;;;;;;;;;OAUG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GAAG,EAAE,MAAM,GAAG,OAAO,CAAA;KAAE,CAAC;IAExC;;OAEG;IACH,IAAI,CAAC,EAAE,MAAM,CAAC;CACf;AAED,yBAAiB,mBAAmB,CAAC;IACnC;;;OAGG;IACH,UAAiB,YAAY;QAC3B;;WAEG;QACH,QAAQ,EAAE,KAAK,CAAC,MAAM,CAAC,CAAC;QAExB;;WAEG;QACH,MAAM,EAAE,KAAK,CAAC,MAAM,CAAC,CAAC;QAEtB;;WAEG;QACH,QAAQ,EAAE,KAAK,CAAC,MAAM,CAAC,CAAC;KACzB;CACF;AAED,MAAM,WAAW,iBAAkB,SAAQ,uBAAuB;CAAG;AAErE,MAAM,CAAC,OAAO,WAAW,QAAQ,CAAC;IAChC,OAAO,EACL,KAAK,OAAO,IAAI,OAAO,EACvB,KAAK,qBAAqB,IAAI,qBAAqB,EACnD,KAAK,yBAAyB,IAAI,yBAAyB,EAC3D,KAAK,mBAAmB,IAAI,mBAAmB,EAC/C,KAAK,mBAAmB,IAAI,mBAAmB,EAC/C,KAAK,iBAAiB,IAAI,iBAAiB,GAC5C,CAAC;CACH"}
package/src/client.ts CHANGED
@@ -119,6 +119,8 @@ export interface ClientOptions {
119
119
  *
120
120
  * Note that request timeouts are retried by default, so in a worst-case scenario you may wait
121
121
  * much longer than this timeout before the promise succeeds or fails.
122
+ *
123
+ * @unit milliseconds
122
124
  */
123
125
  timeout?: number | undefined;
124
126
  /**
@@ -254,7 +256,7 @@ export class Scorecard {
254
256
  * Create a new client instance re-using the same options given to the current client with optional overriding.
255
257
  */
256
258
  withOptions(options: Partial<ClientOptions>): this {
257
- return new (this.constructor as any as new (props: ClientOptions) => typeof this)({
259
+ const client = new (this.constructor as any as new (props: ClientOptions) => typeof this)({
258
260
  ...this._options,
259
261
  environment: options.environment ? options.environment : undefined,
260
262
  baseURL: options.environment ? undefined : this.baseURL,
@@ -267,6 +269,7 @@ export class Scorecard {
267
269
  apiKey: this.apiKey,
268
270
  ...options,
269
271
  });
272
+ return client;
270
273
  }
271
274
 
272
275
  /**
@@ -284,7 +287,7 @@ export class Scorecard {
284
287
  return;
285
288
  }
286
289
 
287
- protected authHeaders(opts: FinalRequestOptions): NullableHeaders | undefined {
290
+ protected async authHeaders(opts: FinalRequestOptions): Promise<NullableHeaders | undefined> {
288
291
  return buildHeaders([{ Authorization: `Bearer ${this.apiKey}` }]);
289
292
  }
290
293
 
@@ -416,7 +419,9 @@ export class Scorecard {
416
419
 
417
420
  await this.prepareOptions(options);
418
421
 
419
- const { req, url, timeout } = this.buildRequest(options, { retryCount: maxRetries - retriesRemaining });
422
+ const { req, url, timeout } = await this.buildRequest(options, {
423
+ retryCount: maxRetries - retriesRemaining,
424
+ });
420
425
 
421
426
  await this.prepareRequest(req, { url, options });
422
427
 
@@ -444,7 +449,7 @@ export class Scorecard {
444
449
  const response = await this.fetchWithTimeout(url, req, timeout, controller).catch(castToError);
445
450
  const headersTime = Date.now();
446
451
 
447
- if (response instanceof Error) {
452
+ if (response instanceof globalThis.Error) {
448
453
  const retryMessage = `retrying, ${retriesRemaining} attempts remaining`;
449
454
  if (options.signal?.aborted) {
450
455
  throw new Errors.APIUserAbortError();
@@ -494,7 +499,7 @@ export class Scorecard {
494
499
  } with status ${response.status} in ${headersTime - startTime}ms`;
495
500
 
496
501
  if (!response.ok) {
497
- const shouldRetry = this.shouldRetry(response);
502
+ const shouldRetry = await this.shouldRetry(response);
498
503
  if (retriesRemaining && shouldRetry) {
499
504
  const retryMessage = `retrying, ${retriesRemaining} attempts remaining`;
500
505
 
@@ -612,7 +617,7 @@ export class Scorecard {
612
617
  }
613
618
  }
614
619
 
615
- private shouldRetry(response: Response): boolean {
620
+ private async shouldRetry(response: Response): Promise<boolean> {
616
621
  // Note this is not a standard header.
617
622
  const shouldRetryHeader = response.headers.get('x-should-retry');
618
623
 
@@ -689,10 +694,10 @@ export class Scorecard {
689
694
  return sleepSeconds * jitter * 1000;
690
695
  }
691
696
 
692
- buildRequest(
697
+ async buildRequest(
693
698
  inputOptions: FinalRequestOptions,
694
699
  { retryCount = 0 }: { retryCount?: number } = {},
695
- ): { req: FinalizedRequestInit; url: string; timeout: number } {
700
+ ): Promise<{ req: FinalizedRequestInit; url: string; timeout: number }> {
696
701
  const options = { ...inputOptions };
697
702
  const { method, path, query, defaultBaseURL } = options;
698
703
 
@@ -700,7 +705,7 @@ export class Scorecard {
700
705
  if ('timeout' in options) validatePositiveInteger('timeout', options.timeout);
701
706
  options.timeout = options.timeout ?? this.timeout;
702
707
  const { bodyHeaders, body } = this.buildBody({ options });
703
- const reqHeaders = this.buildHeaders({ options: inputOptions, method, bodyHeaders, retryCount });
708
+ const reqHeaders = await this.buildHeaders({ options: inputOptions, method, bodyHeaders, retryCount });
704
709
 
705
710
  const req: FinalizedRequestInit = {
706
711
  method,
@@ -716,7 +721,7 @@ export class Scorecard {
716
721
  return { req, url, timeout: options.timeout };
717
722
  }
718
723
 
719
- private buildHeaders({
724
+ private async buildHeaders({
720
725
  options,
721
726
  method,
722
727
  bodyHeaders,
@@ -726,7 +731,7 @@ export class Scorecard {
726
731
  method: HTTPMethod;
727
732
  bodyHeaders: HeadersLike;
728
733
  retryCount: number;
729
- }): Headers {
734
+ }): Promise<Headers> {
730
735
  let idempotencyHeaders: HeadersLike = {};
731
736
  if (this.idempotencyHeader && method !== 'get') {
732
737
  if (!options.idempotencyKey) options.idempotencyKey = this.defaultIdempotencyKey();
@@ -742,7 +747,7 @@ export class Scorecard {
742
747
  ...(options.timeout ? { 'X-Stainless-Timeout': String(Math.trunc(options.timeout / 1000)) } : {}),
743
748
  ...getPlatformHeaders(),
744
749
  },
745
- this.authHeaders(options),
750
+ await this.authHeaders(options),
746
751
  this._options.defaultHeaders,
747
752
  bodyHeaders,
748
753
  options.headers,
@@ -770,7 +775,7 @@ export class Scorecard {
770
775
  // Preserve legacy string encoding behavior for now
771
776
  headers.values.has('content-type')) ||
772
777
  // `Blob` is superset of `File`
773
- body instanceof Blob ||
778
+ ((globalThis as any).Blob && body instanceof (globalThis as any).Blob) ||
774
779
  // `FormData` -> `multipart/form-data`
775
780
  body instanceof FormData ||
776
781
  // `URLSearchParams` -> `application/x-www-form-urlencoded`
@@ -818,6 +823,7 @@ export class Scorecard {
818
823
  scores: API.Scores = new API.Scores(this);
819
824
  systems: API.Systems = new API.Systems(this);
820
825
  }
826
+
821
827
  Scorecard.Projects = Projects;
822
828
  Scorecard.Testsets = Testsets;
823
829
  Scorecard.Testcases = Testcases;
@@ -826,6 +832,7 @@ Scorecard.Metrics = Metrics;
826
832
  Scorecard.Records = Records;
827
833
  Scorecard.Scores = Scores;
828
834
  Scorecard.Systems = Systems;
835
+
829
836
  export declare namespace Scorecard {
830
837
  export type RequestOptions = Opts.RequestOptions;
831
838
 
@@ -9,17 +9,70 @@ import { type HeadersLike } from './headers';
9
9
  export type FinalRequestOptions = RequestOptions & { method: HTTPMethod; path: string };
10
10
 
11
11
  export type RequestOptions = {
12
+ /**
13
+ * The HTTP method for the request (e.g., 'get', 'post', 'put', 'delete').
14
+ */
12
15
  method?: HTTPMethod;
16
+
17
+ /**
18
+ * The URL path for the request.
19
+ *
20
+ * @example "/v1/foo"
21
+ */
13
22
  path?: string;
23
+
24
+ /**
25
+ * Query parameters to include in the request URL.
26
+ */
14
27
  query?: object | undefined | null;
28
+
29
+ /**
30
+ * The request body. Can be a string, JSON object, FormData, or other supported types.
31
+ */
15
32
  body?: unknown;
33
+
34
+ /**
35
+ * HTTP headers to include with the request. Can be a Headers object, plain object, or array of tuples.
36
+ */
16
37
  headers?: HeadersLike;
38
+
39
+ /**
40
+ * The maximum number of times that the client will retry a request in case of a
41
+ * temporary failure, like a network error or a 5XX error from the server.
42
+ *
43
+ * @default 2
44
+ */
17
45
  maxRetries?: number;
46
+
18
47
  stream?: boolean | undefined;
48
+
49
+ /**
50
+ * The maximum amount of time (in milliseconds) that the client should wait for a response
51
+ * from the server before timing out a single request.
52
+ *
53
+ * @unit milliseconds
54
+ */
19
55
  timeout?: number;
56
+
57
+ /**
58
+ * Additional `RequestInit` options to be passed to the underlying `fetch` call.
59
+ * These options will be merged with the client's default fetch options.
60
+ */
20
61
  fetchOptions?: MergedRequestInit;
62
+
63
+ /**
64
+ * An AbortSignal that can be used to cancel the request.
65
+ */
21
66
  signal?: AbortSignal | undefined | null;
67
+
68
+ /**
69
+ * A unique key for this request to enable idempotency.
70
+ */
22
71
  idempotencyKey?: string;
72
+
73
+ /**
74
+ * Override the default base URL for this specific request.
75
+ */
23
76
  defaultBaseURL?: string | undefined;
24
77
 
25
78
  __binaryResponse?: boolean | undefined;
@@ -7,7 +7,7 @@ export type KeysEnum<T> = { [P in keyof Required<T>]: true };
7
7
 
8
8
  export type FinalizedRequestInit = RequestInit & { headers: Headers };
9
9
 
10
- type NotAny<T> = [unknown] extends [T] ? never : T;
10
+ type NotAny<T> = [0] extends [1 & T] ? never : T;
11
11
 
12
12
  /**
13
13
  * Some environments overload the global fetch function, and Parameters<T> only gets the last signature.
@@ -64,13 +64,15 @@ type OverloadedParameters<T> =
64
64
  * [1]: https://www.typescriptlang.org/tsconfig/#typeAcquisition
65
65
  */
66
66
  /** @ts-ignore For users with \@types/node */
67
- type UndiciTypesRequestInit = NotAny<import('../node_modules/undici-types').RequestInit> | NotAny<import('../../node_modules/undici-types').RequestInit> | NotAny<import('../../../node_modules/undici-types').RequestInit> | NotAny<import('../../../../node_modules/undici-types').RequestInit> | NotAny<import('../../../../../node_modules/undici-types').RequestInit> | NotAny<import('../../../../../../node_modules/undici-types').RequestInit> | NotAny<import('../../../../../../../node_modules/undici-types').RequestInit> | NotAny<import('../../../../../../../../node_modules/undici-types').RequestInit> | NotAny<import('../../../../../../../../../node_modules/undici-types').RequestInit> | NotAny<import('../../../../../../../../../../node_modules/undici-types').RequestInit>;
67
+ type UndiciTypesRequestInit = NotAny<import('../node_modules/undici-types/index.d.ts').RequestInit> | NotAny<import('../../node_modules/undici-types/index.d.ts').RequestInit> | NotAny<import('../../../node_modules/undici-types/index.d.ts').RequestInit> | NotAny<import('../../../../node_modules/undici-types/index.d.ts').RequestInit> | NotAny<import('../../../../../node_modules/undici-types/index.d.ts').RequestInit> | NotAny<import('../../../../../../node_modules/undici-types/index.d.ts').RequestInit> | NotAny<import('../../../../../../../node_modules/undici-types/index.d.ts').RequestInit> | NotAny<import('../../../../../../../../node_modules/undici-types/index.d.ts').RequestInit> | NotAny<import('../../../../../../../../../node_modules/undici-types/index.d.ts').RequestInit> | NotAny<import('../../../../../../../../../../node_modules/undici-types/index.d.ts').RequestInit>;
68
68
  /** @ts-ignore For users with undici */
69
- type UndiciRequestInit = NotAny<import('../node_modules/undici').RequestInit> | NotAny<import('../../node_modules/undici').RequestInit> | NotAny<import('../../../node_modules/undici').RequestInit> | NotAny<import('../../../../node_modules/undici').RequestInit> | NotAny<import('../../../../../node_modules/undici').RequestInit> | NotAny<import('../../../../../../node_modules/undici').RequestInit> | NotAny<import('../../../../../../../node_modules/undici').RequestInit> | NotAny<import('../../../../../../../../node_modules/undici').RequestInit> | NotAny<import('../../../../../../../../../node_modules/undici').RequestInit> | NotAny<import('../../../../../../../../../../node_modules/undici').RequestInit>;
69
+ type UndiciRequestInit = NotAny<import('../node_modules/undici/index.d.ts').RequestInit> | NotAny<import('../../node_modules/undici/index.d.ts').RequestInit> | NotAny<import('../../../node_modules/undici/index.d.ts').RequestInit> | NotAny<import('../../../../node_modules/undici/index.d.ts').RequestInit> | NotAny<import('../../../../../node_modules/undici/index.d.ts').RequestInit> | NotAny<import('../../../../../../node_modules/undici/index.d.ts').RequestInit> | NotAny<import('../../../../../../../node_modules/undici/index.d.ts').RequestInit> | NotAny<import('../../../../../../../../node_modules/undici/index.d.ts').RequestInit> | NotAny<import('../../../../../../../../../node_modules/undici/index.d.ts').RequestInit> | NotAny<import('../../../../../../../../../../node_modules/undici/index.d.ts').RequestInit>;
70
70
  /** @ts-ignore For users with \@types/bun */
71
71
  type BunRequestInit = globalThis.FetchRequestInit;
72
- /** @ts-ignore For users with node-fetch */
73
- type NodeFetchRequestInit = NotAny<import('../node_modules/node-fetch').RequestInit> | NotAny<import('../../node_modules/node-fetch').RequestInit> | NotAny<import('../../../node_modules/node-fetch').RequestInit> | NotAny<import('../../../../node_modules/node-fetch').RequestInit> | NotAny<import('../../../../../node_modules/node-fetch').RequestInit> | NotAny<import('../../../../../../node_modules/node-fetch').RequestInit> | NotAny<import('../../../../../../../node_modules/node-fetch').RequestInit> | NotAny<import('../../../../../../../../node_modules/node-fetch').RequestInit> | NotAny<import('../../../../../../../../../node_modules/node-fetch').RequestInit> | NotAny<import('../../../../../../../../../../node_modules/node-fetch').RequestInit>;
72
+ /** @ts-ignore For users with node-fetch@2 */
73
+ type NodeFetch2RequestInit = NotAny<import('../node_modules/@types/node-fetch/index.d.ts').RequestInit> | NotAny<import('../../node_modules/@types/node-fetch/index.d.ts').RequestInit> | NotAny<import('../../../node_modules/@types/node-fetch/index.d.ts').RequestInit> | NotAny<import('../../../../node_modules/@types/node-fetch/index.d.ts').RequestInit> | NotAny<import('../../../../../node_modules/@types/node-fetch/index.d.ts').RequestInit> | NotAny<import('../../../../../../node_modules/@types/node-fetch/index.d.ts').RequestInit> | NotAny<import('../../../../../../../node_modules/@types/node-fetch/index.d.ts').RequestInit> | NotAny<import('../../../../../../../../node_modules/@types/node-fetch/index.d.ts').RequestInit> | NotAny<import('../../../../../../../../../node_modules/@types/node-fetch/index.d.ts').RequestInit> | NotAny<import('../../../../../../../../../../node_modules/@types/node-fetch/index.d.ts').RequestInit>;
74
+ /** @ts-ignore For users with node-fetch@3, doesn't need file extension because types are at ./@types/index.d.ts */
75
+ type NodeFetch3RequestInit = NotAny<import('../node_modules/node-fetch').RequestInit> | NotAny<import('../../node_modules/node-fetch').RequestInit> | NotAny<import('../../../node_modules/node-fetch').RequestInit> | NotAny<import('../../../../node_modules/node-fetch').RequestInit> | NotAny<import('../../../../../node_modules/node-fetch').RequestInit> | NotAny<import('../../../../../../node_modules/node-fetch').RequestInit> | NotAny<import('../../../../../../../node_modules/node-fetch').RequestInit> | NotAny<import('../../../../../../../../node_modules/node-fetch').RequestInit> | NotAny<import('../../../../../../../../../node_modules/node-fetch').RequestInit> | NotAny<import('../../../../../../../../../../node_modules/node-fetch').RequestInit>;
74
76
  /** @ts-ignore For users who use Deno */
75
77
  type FetchRequestInit = NonNullable<OverloadedParameters<typeof fetch>[1]>;
76
78
  /* eslint-enable */
@@ -79,7 +81,8 @@ type RequestInits =
79
81
  | NotAny<UndiciTypesRequestInit>
80
82
  | NotAny<UndiciRequestInit>
81
83
  | NotAny<BunRequestInit>
82
- | NotAny<NodeFetchRequestInit>
84
+ | NotAny<NodeFetch2RequestInit>
85
+ | NotAny<NodeFetch3RequestInit>
83
86
  | NotAny<RequestInit>
84
87
  | NotAny<FetchRequestInit>;
85
88
 
@@ -90,7 +90,7 @@ export const multipartFormRequestOptions = async (
90
90
  return { ...opts, body: await createForm(opts.body, fetch) };
91
91
  };
92
92
 
93
- const supportsFormDataMap = /** @__PURE__ */ new WeakMap<Fetch, Promise<boolean>>();
93
+ const supportsFormDataMap = /* @__PURE__ */ new WeakMap<Fetch, Promise<boolean>>();
94
94
 
95
95
  /**
96
96
  * node-fetch doesn't support the global FormData object in recent node versions. Instead of sending
@@ -58,7 +58,7 @@ const noopLogger = {
58
58
  debug: noop,
59
59
  };
60
60
 
61
- let cachedLoggers = /** @__PURE__ */ new WeakMap<Logger, [LogLevel, Logger]>();
61
+ let cachedLoggers = /* @__PURE__ */ new WeakMap<Logger, [LogLevel, Logger]>();
62
62
 
63
63
  export function loggerFor(client: Scorecard): Logger {
64
64
  const logger = client.logger;
@@ -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) => {
@@ -52,7 +73,9 @@ export const createPathTagFunction = (pathEncoder = encodeURIPath) =>
52
73
  }, '');
53
74
 
54
75
  throw new ScorecardError(
55
- `Path parameters result in path with invalid segments:\n${path}\n${underline}`,
76
+ `Path parameters result in path with invalid segments:\n${invalidSegments
77
+ .map((e) => e.error)
78
+ .join('\n')}\n${path}\n${underline}`,
56
79
  );
57
80
  }
58
81
 
@@ -76,21 +76,21 @@ export const coerceBoolean = (value: unknown): boolean => {
76
76
  };
77
77
 
78
78
  export const maybeCoerceInteger = (value: unknown): number | undefined => {
79
- if (value === undefined) {
79
+ if (value == null) {
80
80
  return undefined;
81
81
  }
82
82
  return coerceInteger(value);
83
83
  };
84
84
 
85
85
  export const maybeCoerceFloat = (value: unknown): number | undefined => {
86
- if (value === undefined) {
86
+ if (value == null) {
87
87
  return undefined;
88
88
  }
89
89
  return coerceFloat(value);
90
90
  };
91
91
 
92
92
  export const maybeCoerceBoolean = (value: unknown): boolean | undefined => {
93
- if (value === undefined) {
93
+ if (value == null) {
94
94
  return undefined;
95
95
  }
96
96
  return coerceBoolean(value);
@@ -2,7 +2,6 @@
2
2
 
3
3
  import { APIResource } from '../core/resource';
4
4
  import { APIPromise } from '../core/api-promise';
5
- import { type Record as BuiltinRecord } from '../internal/builtin-types';
6
5
  import { RequestOptions } from '../internal/request-options';
7
6
  import { path } from '../internal/utils/path';
8
7
 
@@ -39,18 +38,18 @@ export interface Record {
39
38
  /**
40
39
  * The expected outputs for the Testcase.
41
40
  */
42
- expected: BuiltinRecord<string, unknown>;
41
+ expected: { [key: string]: unknown };
43
42
 
44
43
  /**
45
44
  * The actual inputs sent to the system, which should match the system's input
46
45
  * schema.
47
46
  */
48
- inputs: BuiltinRecord<string, unknown>;
47
+ inputs: { [key: string]: unknown };
49
48
 
50
49
  /**
51
50
  * The actual outputs from the system.
52
51
  */
53
- outputs: BuiltinRecord<string, unknown>;
52
+ outputs: { [key: string]: unknown };
54
53
 
55
54
  /**
56
55
  * The ID of the Run containing this Record.
@@ -67,18 +66,18 @@ export interface RecordCreateParams {
67
66
  /**
68
67
  * The expected outputs for the Testcase.
69
68
  */
70
- expected: BuiltinRecord<string, unknown>;
69
+ expected: { [key: string]: unknown };
71
70
 
72
71
  /**
73
72
  * The actual inputs sent to the system, which should match the system's input
74
73
  * schema.
75
74
  */
76
- inputs: BuiltinRecord<string, unknown>;
75
+ inputs: { [key: string]: unknown };
77
76
 
78
77
  /**
79
78
  * The actual outputs from the system.
80
79
  */
81
- outputs: BuiltinRecord<string, unknown>;
80
+ outputs: { [key: string]: unknown };
82
81
 
83
82
  /**
84
83
  * The ID of the Testcase.
@@ -56,7 +56,7 @@ export interface Score {
56
56
  * the output schema defined by the associated MetricConfig. If it doesn't,
57
57
  * validation errors will be captured in the `validationErrors` field.
58
58
  */
59
- score: Record<string, unknown>;
59
+ score: { [key: string]: unknown };
60
60
 
61
61
  /**
62
62
  * Validation errors found in the Score data. If present, the Score doesn't fully
@@ -90,7 +90,7 @@ export interface ScoreUpsertParams {
90
90
  * conform to the output schema defined by the associated MetricConfig. If it
91
91
  * doesn't, validation errors will be captured in the `validationErrors` field.
92
92
  */
93
- score: Record<string, unknown>;
93
+ score: { [key: string]: unknown };
94
94
  }
95
95
 
96
96
  export declare namespace Scores {
@@ -6,7 +6,7 @@
6
6
  export interface APIError {
7
7
  code: string;
8
8
 
9
- details: Record<string, unknown>;
9
+ details: { [key: string]: unknown };
10
10
 
11
11
  message: string;
12
12
  }
@@ -192,7 +192,7 @@ export interface SystemUpsertParams {
192
192
  /**
193
193
  * The configuration of the system.
194
194
  */
195
- config: Record<string, unknown>;
195
+ config: { [key: string]: unknown };
196
196
 
197
197
  /**
198
198
  * The description of the system.
@@ -65,7 +65,7 @@ export interface SystemVersion {
65
65
  /**
66
66
  * The configuration of the system version.
67
67
  */
68
- config: Record<string, unknown>;
68
+ config: { [key: string]: unknown };
69
69
 
70
70
  /**
71
71
  * The name of the system version.
@@ -82,7 +82,7 @@ export interface VersionUpsertParams {
82
82
  /**
83
83
  * The configuration of the system version.
84
84
  */
85
- config: Record<string, unknown>;
85
+ config: { [key: string]: unknown };
86
86
 
87
87
  /**
88
88
  * The name of the system version. If creating a new system version and the name
@@ -136,18 +136,18 @@ export interface Testcase {
136
136
  * Derived from data based on the Testset's fieldMapping. Contains all fields
137
137
  * marked as expected outputs, including those with validation errors.
138
138
  */
139
- expected: Record<string, unknown>;
139
+ expected: { [key: string]: unknown };
140
140
 
141
141
  /**
142
142
  * Derived from data based on the Testset's fieldMapping. Contains all fields
143
143
  * marked as inputs, including those with validation errors.
144
144
  */
145
- inputs: Record<string, unknown>;
145
+ inputs: { [key: string]: unknown };
146
146
 
147
147
  /**
148
148
  * The JSON data of the Testcase, which is validated against the Testset's schema.
149
149
  */
150
- jsonData: Record<string, unknown>;
150
+ jsonData: { [key: string]: unknown };
151
151
 
152
152
  /**
153
153
  * The ID of the Testset this Testcase belongs to.
@@ -198,7 +198,7 @@ export namespace TestcaseCreateParams {
198
198
  /**
199
199
  * The JSON data of the Testcase, which is validated against the Testset's schema.
200
200
  */
201
- jsonData: Record<string, unknown>;
201
+ jsonData: { [key: string]: unknown };
202
202
  }
203
203
  }
204
204
 
@@ -206,7 +206,7 @@ export interface TestcaseUpdateParams {
206
206
  /**
207
207
  * The JSON data of the Testcase, which is validated against the Testset's schema.
208
208
  */
209
- jsonData: Record<string, unknown>;
209
+ jsonData: { [key: string]: unknown };
210
210
  }
211
211
 
212
212
  export interface TestcaseListParams extends PaginatedResponseParams {}
@@ -162,7 +162,7 @@ export interface Testset {
162
162
  /**
163
163
  * The JSON schema for each Testcase in the Testset.
164
164
  */
165
- jsonSchema: Record<string, unknown>;
165
+ jsonSchema: { [key: string]: unknown };
166
166
 
167
167
  /**
168
168
  * The name of the Testset.
@@ -215,7 +215,7 @@ export interface TestsetCreateParams {
215
215
  /**
216
216
  * The JSON schema for each Testcase in the Testset.
217
217
  */
218
- jsonSchema: Record<string, unknown>;
218
+ jsonSchema: { [key: string]: unknown };
219
219
 
220
220
  /**
221
221
  * The name of the Testset.
@@ -261,7 +261,7 @@ export interface TestsetUpdateParams {
261
261
  /**
262
262
  * The JSON schema for each Testcase in the Testset.
263
263
  */
264
- jsonSchema?: Record<string, unknown>;
264
+ jsonSchema?: { [key: string]: unknown };
265
265
 
266
266
  /**
267
267
  * The name of the Testset.
package/src/version.ts CHANGED
@@ -1 +1 @@
1
- export const VERSION = '2.0.0-alpha.1'; // x-release-please-version
1
+ export const VERSION = '2.1.0'; // x-release-please-version
package/version.d.mts CHANGED
@@ -1,2 +1,2 @@
1
- export declare const VERSION = "2.0.0-alpha.1";
1
+ export declare const VERSION = "2.1.0";
2
2
  //# sourceMappingURL=version.d.mts.map
package/version.d.mts.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"version.d.mts","sourceRoot":"","sources":["src/version.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,OAAO,kBAAkB,CAAC"}
1
+ {"version":3,"file":"version.d.mts","sourceRoot":"","sources":["src/version.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,OAAO,UAAU,CAAC"}
package/version.d.ts CHANGED
@@ -1,2 +1,2 @@
1
- export declare const VERSION = "2.0.0-alpha.1";
1
+ export declare const VERSION = "2.1.0";
2
2
  //# sourceMappingURL=version.d.ts.map
package/version.d.ts.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"version.d.ts","sourceRoot":"","sources":["src/version.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,OAAO,kBAAkB,CAAC"}
1
+ {"version":3,"file":"version.d.ts","sourceRoot":"","sources":["src/version.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,OAAO,UAAU,CAAC"}