scorecard-ai 1.2.0 → 2.0.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 (74) hide show
  1. package/CHANGELOG.md +33 -0
  2. package/client.d.mts +4 -2
  3. package/client.d.mts.map +1 -1
  4. package/client.d.ts +4 -2
  5. package/client.d.ts.map +1 -1
  6. package/client.js.map +1 -1
  7. package/client.mjs.map +1 -1
  8. package/internal/request-options.d.mts +42 -0
  9. package/internal/request-options.d.mts.map +1 -1
  10. package/internal/request-options.d.ts +42 -0
  11. package/internal/request-options.d.ts.map +1 -1
  12. package/internal/request-options.js.map +1 -1
  13. package/internal/request-options.mjs.map +1 -1
  14. package/internal/types.d.mts +8 -6
  15. package/internal/types.d.mts.map +1 -1
  16. package/internal/types.d.ts +8 -6
  17. package/internal/types.d.ts.map +1 -1
  18. package/internal/uploads.js +1 -1
  19. package/internal/uploads.js.map +1 -1
  20. package/internal/uploads.mjs +1 -1
  21. package/internal/uploads.mjs.map +1 -1
  22. package/internal/utils/log.js +1 -1
  23. package/internal/utils/log.js.map +1 -1
  24. package/internal/utils/log.mjs +1 -1
  25. package/internal/utils/log.mjs.map +1 -1
  26. package/internal/utils/path.d.mts.map +1 -1
  27. package/internal/utils/path.d.ts.map +1 -1
  28. package/internal/utils/path.js +26 -5
  29. package/internal/utils/path.js.map +1 -1
  30. package/internal/utils/path.mjs +26 -5
  31. package/internal/utils/path.mjs.map +1 -1
  32. package/package.json +1 -1
  33. package/resources/index.d.mts +1 -1
  34. package/resources/index.d.mts.map +1 -1
  35. package/resources/index.d.ts +1 -1
  36. package/resources/index.d.ts.map +1 -1
  37. package/resources/systems/index.d.mts +2 -2
  38. package/resources/systems/index.d.mts.map +1 -1
  39. package/resources/systems/index.d.ts +2 -2
  40. package/resources/systems/index.d.ts.map +1 -1
  41. package/resources/systems/index.js.map +1 -1
  42. package/resources/systems/index.mjs +1 -1
  43. package/resources/systems/index.mjs.map +1 -1
  44. package/resources/systems/systems.d.mts +63 -141
  45. package/resources/systems/systems.d.mts.map +1 -1
  46. package/resources/systems/systems.d.ts +63 -141
  47. package/resources/systems/systems.d.ts.map +1 -1
  48. package/resources/systems/systems.js +21 -74
  49. package/resources/systems/systems.js.map +1 -1
  50. package/resources/systems/systems.mjs +22 -75
  51. package/resources/systems/systems.mjs.map +1 -1
  52. package/resources/systems/versions.d.mts +23 -74
  53. package/resources/systems/versions.d.mts.map +1 -1
  54. package/resources/systems/versions.d.ts +23 -74
  55. package/resources/systems/versions.d.ts.map +1 -1
  56. package/resources/systems/versions.js +20 -54
  57. package/resources/systems/versions.js.map +1 -1
  58. package/resources/systems/versions.mjs +20 -54
  59. package/resources/systems/versions.mjs.map +1 -1
  60. package/src/client.ts +4 -2
  61. package/src/internal/request-options.ts +53 -0
  62. package/src/internal/types.ts +9 -6
  63. package/src/internal/uploads.ts +1 -1
  64. package/src/internal/utils/log.ts +1 -1
  65. package/src/internal/utils/path.ts +30 -7
  66. package/src/resources/index.ts +1 -1
  67. package/src/resources/systems/index.ts +2 -8
  68. package/src/resources/systems/systems.ts +68 -141
  69. package/src/resources/systems/versions.ts +25 -95
  70. package/src/version.ts +1 -1
  71. package/version.d.mts +1 -1
  72. package/version.d.ts +1 -1
  73. package/version.js +1 -1
  74. package/version.mjs +1 -1
@@ -3,79 +3,45 @@
3
3
  Object.defineProperty(exports, "__esModule", { value: true });
4
4
  exports.Versions = void 0;
5
5
  const resource_1 = require("../../core/resource.js");
6
- const pagination_1 = require("../../core/pagination.js");
7
6
  const path_1 = require("../../internal/utils/path.js");
8
7
  class Versions extends resource_1.APIResource {
9
8
  /**
10
- * Create a new version for a system.
11
- *
12
- * Each version contains specific parameter values that match the system's
13
- * `configSchema` - things like model parameters, thresholds, or processing
14
- * options. Once created, versions cannot be modified, ensuring stable reference
15
- * points for evaluations.
16
- *
17
- * When creating a system version:
18
- *
19
- * - The `config` object is validated against the parent system's `configSchema`.
20
- * - System versions with validation errors are still stored, with errors included
21
- * in the response.
22
- * - Validation errors indicate fields that don't match the schema but don't
23
- * prevent creation.
24
- * - Having validation errors may affect how some evaluation metrics are
25
- * calculated.
9
+ * Retrieve a specific system version by ID.
26
10
  *
27
11
  * @example
28
12
  * ```ts
29
- * const systemVersion = await client.systems.versions.create(
30
- * '12345678-0a8b-4f66-b6f3-2ddcfa097257',
31
- * {
32
- * config: {
33
- * temperature: 0.1,
34
- * maxTokens: 1024,
35
- * model: 'gpt-4-turbo',
36
- * },
37
- * name: 'Production (Low Temperature)',
38
- * },
13
+ * const systemVersion = await client.systems.versions.get(
14
+ * '87654321-4d3b-4ae4-8c7a-4b6e2a19ccf0',
39
15
  * );
40
16
  * ```
41
17
  */
42
- create(systemID, body, options) {
43
- return this._client.post((0, path_1.path) `/systems/${systemID}/configs`, { body, ...options });
18
+ get(systemVersionID, options) {
19
+ return this._client.get((0, path_1.path) `/systems/versions/${systemVersionID}`, options);
44
20
  }
45
21
  /**
46
- * Retrieve a paginated list of system versions for a specific system.
22
+ * Create a new system version if it does not already exist. Does **not** set the
23
+ * created version to be the system's production version.
47
24
  *
48
- * System versions provide concrete parameter values for a System Under Test,
49
- * defining exactly how the system should be configured during an evaluation run.
25
+ * If there is already a system version with the same config, its name will be
26
+ * updated.
50
27
  *
51
28
  * @example
52
29
  * ```ts
53
- * // Automatically fetches more pages as needed.
54
- * for await (const systemVersion of client.systems.versions.list(
30
+ * const systemVersion = await client.systems.versions.upsert(
55
31
  * '12345678-0a8b-4f66-b6f3-2ddcfa097257',
56
- * )) {
57
- * // ...
58
- * }
59
- * ```
60
- */
61
- list(systemID, query = {}, options) {
62
- return this._client.getAPIList((0, path_1.path) `/systems/${systemID}/configs`, (pagination_1.PaginatedResponse), {
63
- query,
64
- ...options,
65
- });
66
- }
67
- /**
68
- * Retrieve a specific system version by ID.
69
- *
70
- * @example
71
- * ```ts
72
- * const systemVersion = await client.systems.versions.get(
73
- * '87654321-4d3b-4ae4-8c7a-4b6e2a19ccf0',
32
+ * {
33
+ * config: {
34
+ * temperature: 0.5,
35
+ * maxTokens: 1024,
36
+ * model: 'gemini-2.0-flash',
37
+ * },
38
+ * name: 'Test model: Gemini',
39
+ * },
74
40
  * );
75
41
  * ```
76
42
  */
77
- get(systemVersionID, options) {
78
- return this._client.get((0, path_1.path) `/systems/configs/${systemVersionID}`, options);
43
+ upsert(systemID, body, options) {
44
+ return this._client.post((0, path_1.path) `/systems/${systemID}/versions`, { body, ...options });
79
45
  }
80
46
  }
81
47
  exports.Versions = Versions;
@@ -1 +1 @@
1
- {"version":3,"file":"versions.js","sourceRoot":"","sources":["../../src/resources/systems/versions.ts"],"names":[],"mappings":";AAAA,sFAAsF;;;AAEtF,qDAAkD;AAElD,yDAAqG;AAErG,uDAAiD;AAEjD,MAAa,QAAS,SAAQ,sBAAW;IACvC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OAgCG;IACH,MAAM,CAAC,QAAgB,EAAE,IAAyB,EAAE,OAAwB;QAC1E,OAAO,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,IAAA,WAAI,EAAA,YAAY,QAAQ,UAAU,EAAE,EAAE,IAAI,EAAE,GAAG,OAAO,EAAE,CAAC,CAAC;IACrF,CAAC;IAED;;;;;;;;;;;;;;;OAeG;IACH,IAAI,CACF,QAAgB,EAChB,QAA8C,EAAE,EAChD,OAAwB;QAExB,OAAO,IAAI,CAAC,OAAO,CAAC,UAAU,CAAC,IAAA,WAAI,EAAA,YAAY,QAAQ,UAAU,EAAE,CAAA,8BAAgC,CAAA,EAAE;YACnG,KAAK;YACL,GAAG,OAAO;SACX,CAAC,CAAC;IACL,CAAC;IAED;;;;;;;;;OASG;IACH,GAAG,CAAC,eAAuB,EAAE,OAAwB;QACnD,OAAO,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,IAAA,WAAI,EAAA,oBAAoB,eAAe,EAAE,EAAE,OAAO,CAAC,CAAC;IAC9E,CAAC;CACF;AA9ED,4BA8EC"}
1
+ {"version":3,"file":"versions.js","sourceRoot":"","sources":["../../src/resources/systems/versions.ts"],"names":[],"mappings":";AAAA,sFAAsF;;;AAEtF,qDAAkD;AAGlD,uDAAiD;AAEjD,MAAa,QAAS,SAAQ,sBAAW;IACvC;;;;;;;;;OASG;IACH,GAAG,CAAC,eAAuB,EAAE,OAAwB;QACnD,OAAO,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,IAAA,WAAI,EAAA,qBAAqB,eAAe,EAAE,EAAE,OAAO,CAAC,CAAC;IAC/E,CAAC;IAED;;;;;;;;;;;;;;;;;;;;;OAqBG;IACH,MAAM,CAAC,QAAgB,EAAE,IAAyB,EAAE,OAAwB;QAC1E,OAAO,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,IAAA,WAAI,EAAA,YAAY,QAAQ,WAAW,EAAE,EAAE,IAAI,EAAE,GAAG,OAAO,EAAE,CAAC,CAAC;IACtF,CAAC;CACF;AAxCD,4BAwCC"}
@@ -1,78 +1,44 @@
1
1
  // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
2
2
  import { APIResource } from "../../core/resource.mjs";
3
- import { PaginatedResponse } from "../../core/pagination.mjs";
4
3
  import { path } from "../../internal/utils/path.mjs";
5
4
  export class Versions extends APIResource {
6
5
  /**
7
- * Create a new version for a system.
8
- *
9
- * Each version contains specific parameter values that match the system's
10
- * `configSchema` - things like model parameters, thresholds, or processing
11
- * options. Once created, versions cannot be modified, ensuring stable reference
12
- * points for evaluations.
13
- *
14
- * When creating a system version:
15
- *
16
- * - The `config` object is validated against the parent system's `configSchema`.
17
- * - System versions with validation errors are still stored, with errors included
18
- * in the response.
19
- * - Validation errors indicate fields that don't match the schema but don't
20
- * prevent creation.
21
- * - Having validation errors may affect how some evaluation metrics are
22
- * calculated.
6
+ * Retrieve a specific system version by ID.
23
7
  *
24
8
  * @example
25
9
  * ```ts
26
- * const systemVersion = await client.systems.versions.create(
27
- * '12345678-0a8b-4f66-b6f3-2ddcfa097257',
28
- * {
29
- * config: {
30
- * temperature: 0.1,
31
- * maxTokens: 1024,
32
- * model: 'gpt-4-turbo',
33
- * },
34
- * name: 'Production (Low Temperature)',
35
- * },
10
+ * const systemVersion = await client.systems.versions.get(
11
+ * '87654321-4d3b-4ae4-8c7a-4b6e2a19ccf0',
36
12
  * );
37
13
  * ```
38
14
  */
39
- create(systemID, body, options) {
40
- return this._client.post(path `/systems/${systemID}/configs`, { body, ...options });
15
+ get(systemVersionID, options) {
16
+ return this._client.get(path `/systems/versions/${systemVersionID}`, options);
41
17
  }
42
18
  /**
43
- * Retrieve a paginated list of system versions for a specific system.
19
+ * Create a new system version if it does not already exist. Does **not** set the
20
+ * created version to be the system's production version.
44
21
  *
45
- * System versions provide concrete parameter values for a System Under Test,
46
- * defining exactly how the system should be configured during an evaluation run.
22
+ * If there is already a system version with the same config, its name will be
23
+ * updated.
47
24
  *
48
25
  * @example
49
26
  * ```ts
50
- * // Automatically fetches more pages as needed.
51
- * for await (const systemVersion of client.systems.versions.list(
27
+ * const systemVersion = await client.systems.versions.upsert(
52
28
  * '12345678-0a8b-4f66-b6f3-2ddcfa097257',
53
- * )) {
54
- * // ...
55
- * }
56
- * ```
57
- */
58
- list(systemID, query = {}, options) {
59
- return this._client.getAPIList(path `/systems/${systemID}/configs`, (PaginatedResponse), {
60
- query,
61
- ...options,
62
- });
63
- }
64
- /**
65
- * Retrieve a specific system version by ID.
66
- *
67
- * @example
68
- * ```ts
69
- * const systemVersion = await client.systems.versions.get(
70
- * '87654321-4d3b-4ae4-8c7a-4b6e2a19ccf0',
29
+ * {
30
+ * config: {
31
+ * temperature: 0.5,
32
+ * maxTokens: 1024,
33
+ * model: 'gemini-2.0-flash',
34
+ * },
35
+ * name: 'Test model: Gemini',
36
+ * },
71
37
  * );
72
38
  * ```
73
39
  */
74
- get(systemVersionID, options) {
75
- return this._client.get(path `/systems/configs/${systemVersionID}`, options);
40
+ upsert(systemID, body, options) {
41
+ return this._client.post(path `/systems/${systemID}/versions`, { body, ...options });
76
42
  }
77
43
  }
78
44
  //# sourceMappingURL=versions.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"versions.mjs","sourceRoot":"","sources":["../../src/resources/systems/versions.ts"],"names":[],"mappings":"AAAA,sFAAsF;OAE/E,EAAE,WAAW,EAAE;OAEf,EAAe,iBAAiB,EAAgC;OAEhE,EAAE,IAAI,EAAE;AAEf,MAAM,OAAO,QAAS,SAAQ,WAAW;IACvC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OAgCG;IACH,MAAM,CAAC,QAAgB,EAAE,IAAyB,EAAE,OAAwB;QAC1E,OAAO,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,IAAI,CAAA,YAAY,QAAQ,UAAU,EAAE,EAAE,IAAI,EAAE,GAAG,OAAO,EAAE,CAAC,CAAC;IACrF,CAAC;IAED;;;;;;;;;;;;;;;OAeG;IACH,IAAI,CACF,QAAgB,EAChB,QAA8C,EAAE,EAChD,OAAwB;QAExB,OAAO,IAAI,CAAC,OAAO,CAAC,UAAU,CAAC,IAAI,CAAA,YAAY,QAAQ,UAAU,EAAE,CAAA,iBAAgC,CAAA,EAAE;YACnG,KAAK;YACL,GAAG,OAAO;SACX,CAAC,CAAC;IACL,CAAC;IAED;;;;;;;;;OASG;IACH,GAAG,CAAC,eAAuB,EAAE,OAAwB;QACnD,OAAO,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,IAAI,CAAA,oBAAoB,eAAe,EAAE,EAAE,OAAO,CAAC,CAAC;IAC9E,CAAC;CACF"}
1
+ {"version":3,"file":"versions.mjs","sourceRoot":"","sources":["../../src/resources/systems/versions.ts"],"names":[],"mappings":"AAAA,sFAAsF;OAE/E,EAAE,WAAW,EAAE;OAGf,EAAE,IAAI,EAAE;AAEf,MAAM,OAAO,QAAS,SAAQ,WAAW;IACvC;;;;;;;;;OASG;IACH,GAAG,CAAC,eAAuB,EAAE,OAAwB;QACnD,OAAO,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,IAAI,CAAA,qBAAqB,eAAe,EAAE,EAAE,OAAO,CAAC,CAAC;IAC/E,CAAC;IAED;;;;;;;;;;;;;;;;;;;;;OAqBG;IACH,MAAM,CAAC,QAAgB,EAAE,IAAyB,EAAE,OAAwB;QAC1E,OAAO,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,IAAI,CAAA,YAAY,QAAQ,WAAW,EAAE,EAAE,IAAI,EAAE,GAAG,OAAO,EAAE,CAAC,CAAC;IACtF,CAAC;CACF"}
package/src/client.ts CHANGED
@@ -51,10 +51,10 @@ import {
51
51
  } from './resources/testsets';
52
52
  import {
53
53
  System,
54
- SystemCreateParams,
55
54
  SystemDeleteResponse,
56
55
  SystemListParams,
57
56
  SystemUpdateParams,
57
+ SystemUpsertParams,
58
58
  Systems,
59
59
  SystemsPaginatedResponse,
60
60
  } from './resources/systems/systems';
@@ -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
  /**
@@ -883,9 +885,9 @@ export declare namespace Scorecard {
883
885
  type System as System,
884
886
  type SystemDeleteResponse as SystemDeleteResponse,
885
887
  type SystemsPaginatedResponse as SystemsPaginatedResponse,
886
- type SystemCreateParams as SystemCreateParams,
887
888
  type SystemUpdateParams as SystemUpdateParams,
888
889
  type SystemListParams as SystemListParams,
890
+ type SystemUpsertParams as SystemUpsertParams,
889
891
  };
890
892
 
891
893
  export type APIError = API.APIError;
@@ -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
 
@@ -16,9 +16,9 @@ export {
16
16
  Systems,
17
17
  type System,
18
18
  type SystemDeleteResponse,
19
- type SystemCreateParams,
20
19
  type SystemUpdateParams,
21
20
  type SystemListParams,
21
+ type SystemUpsertParams,
22
22
  type SystemsPaginatedResponse,
23
23
  } from './systems/systems';
24
24
  export {
@@ -4,15 +4,9 @@ export {
4
4
  Systems,
5
5
  type System,
6
6
  type SystemDeleteResponse,
7
- type SystemCreateParams,
8
7
  type SystemUpdateParams,
9
8
  type SystemListParams,
9
+ type SystemUpsertParams,
10
10
  type SystemsPaginatedResponse,
11
11
  } from './systems';
12
- export {
13
- Versions,
14
- type SystemVersion,
15
- type VersionCreateParams,
16
- type VersionListParams,
17
- type SystemVersionsPaginatedResponse,
18
- } from './versions';
12
+ export { Versions, type SystemVersion, type VersionUpsertParams } from './versions';