diff --git a/generation-provenance.json b/generation-provenance.json index eb509c0c..cabd4c07 100644 --- a/generation-provenance.json +++ b/generation-provenance.json @@ -1,11 +1,11 @@ { - "source_spec_sha": "9f8d54f123e81b8bc7252f855c52ecbf7cc8ae42", - "source_spec_sha256": "c0b2db893e3017c5c83c14375e6085581584641f617ee7ea1305ab80e9b50421", + "source_spec_sha": "f5b640b324aafb001a8da6facd807f13197630bb", + "source_spec_sha256": "a717ed108ea8bbb6b9c0b70255a07da7e9a01224c6941546089084e02097a632", "generator_version": "0.38.0", - "build_version": "0.1.16", - "configuration_sha256": "10d2f59b8a69dce627060e1104eac425cec104dd90d3177c08a29a902cb48875", + "build_version": "0.1.19", + "configuration_sha256": "477d944077da8e1163423c505fe3f773cce14eda953aa934fe91582d04e4e915", "operation_count": 31, - "generated_commit": "3a034582d4d7ca55b23c7d91494acff4ed16439f", + "generated_commit": "f92eb32ac021fbd472a09146c1c25ecba93bd818", "download_sha256": null, "integration_base": "scalar-next", "published_package": false diff --git a/scalar-sdk.manifest.json b/scalar-sdk.manifest.json index 6896011f..affc8a1a 100644 --- a/scalar-sdk.manifest.json +++ b/scalar-sdk.manifest.json @@ -198,19 +198,8 @@ "required": true, "deprecated": false, "type": { - "kind": "enum", - "values": [ - "on", - "off" - ], - "names": [ - "On", - "Off" - ], - "deprecations": [ - false, - false - ] + "kind": "ref", + "name": "autoresizing_switch" } }, { @@ -294,19 +283,8 @@ "required": true, "deprecated": false, "type": { - "kind": "enum", - "values": [ - "on", - "off" - ], - "names": [ - "On", - "Off" - ], - "deprecations": [ - false, - false - ] + "kind": "ref", + "name": "autoresizing_switch" } }, { @@ -370,19 +348,8 @@ "required": false, "deprecated": false, "type": { - "kind": "enum", - "values": [ - "on", - "off" - ], - "names": [ - "On", - "Off" - ], - "deprecations": [ - false, - false - ] + "kind": "ref", + "name": "autoresizing_switch" } }, { @@ -414,19 +381,8 @@ "required": false, "deprecated": false, "type": { - "kind": "enum", - "values": [ - "on", - "off" - ], - "names": [ - "On", - "Off" - ], - "deprecations": [ - false, - false - ] + "kind": "ref", + "name": "autoresizing_switch" } }, { @@ -3180,6 +3136,27 @@ "additionalProperties": false } }, + { + "name": "autoresizing_switch", + "source": "autoresizing_switch", + "publicAliases": [], + "deprecated": false, + "type": { + "kind": "enum", + "values": [ + "on", + "off" + ], + "names": [ + "On", + "Off" + ], + "deprecations": [ + false, + false + ] + } + }, { "name": "CreateResponseHeaders", "source": "CreateResponseHeaders", diff --git a/src/client.ts b/src/client.ts index 75c4e23e..0ea072b8 100644 --- a/src/client.ts +++ b/src/client.ts @@ -4,7 +4,7 @@ import { APIPromise, type APIResponseProps } from './api-promise'; import { PagePromise, type AbstractPage, type CursorPageParams, CursorPageResponse } from './core/pagination'; import * as Pagination from './core/pagination'; import * as Errors from './error'; -import { uuid4 } from './internal/utils/uuid'; +import { uuid7 } from './internal/utils/uuid7'; import { validatePositiveInteger, isAbsoluteURL, safeJSON, isEmptyObj } from './internal/utils/values'; import { sleep } from './internal/utils/sleep'; import { castToError, isAbortError } from './internal/errors'; @@ -38,6 +38,7 @@ import { type CreateParams, type UpdateParams, type LifecycleStatus, + type AutoresizingSwitch, type MachineListItemsCursorPage, type MachineRetrieveResponse, type MachineResizeResponse, @@ -337,10 +338,7 @@ export class Dedalus { } protected defaultIdempotencyKey(): string { - // @custom start - // Use the API's UUIDv7 format. Automatic retries reuse this value. - return `${Date.now().toString(16).padStart(12, '0')}7${uuid4().replace(/-/g, '').slice(13)}`; - // @custom end + return uuid7().replace(/-/g, ''); } protected makeStatusError( @@ -1200,6 +1198,7 @@ export declare namespace Dedalus { type CreateParams as CreateParams, type UpdateParams as UpdateParams, type LifecycleStatus as LifecycleStatus, + type AutoresizingSwitch as AutoresizingSwitch, type MachineListItemsCursorPage as MachineListItemsCursorPage, type MachineRetrieveResponse as MachineRetrieveResponse, type MachineResizeResponse as MachineResizeResponse, diff --git a/src/internal/utils/uuid7.ts b/src/internal/utils/uuid7.ts new file mode 100644 index 00000000..b6b1bbcc --- /dev/null +++ b/src/internal/utils/uuid7.ts @@ -0,0 +1,29 @@ +// File generated from our OpenAPI spec by Scalar. See README.md for details. + +/** + * A time-ordered (version 7) UUID per RFC 9562: a 48-bit Unix millisecond timestamp, then the + * version and variant bits, with every other bit random. + */ +export const uuid7 = function (): string { + const { crypto } = globalThis as any; + const bytes = new Uint8Array(16); + if (crypto?.getRandomValues) { + crypto.getRandomValues(bytes); + } else { + for (let i = 0; i < bytes.length; i++) bytes[i] = (Math.random() * 0x100) & 0xff; + } + // A clock set before 1970 writes a zero timestamp rather than wrapping to the far future. + const ms = Math.max(0, Date.now()); + // Bitwise operators work on 32 bits, so the timestamp's top 16 bits are split off arithmetically. + const high = Math.floor(ms / 0x100000000); + bytes[0] = (high >>> 8) & 0xff; + bytes[1] = high & 0xff; + bytes[2] = (ms >>> 24) & 0xff; + bytes[3] = (ms >>> 16) & 0xff; + bytes[4] = (ms >>> 8) & 0xff; + bytes[5] = ms & 0xff; + bytes[6] = (bytes[6]! & 0x0f) | 0x70; + bytes[8] = (bytes[8]! & 0x3f) | 0x80; + const hex = Array.from(bytes, (byte) => byte.toString(16).padStart(2, '0')).join(''); + return `${hex.slice(0, 8)}-${hex.slice(8, 12)}-${hex.slice(12, 16)}-${hex.slice(16, 20)}-${hex.slice(20)}`; +}; diff --git a/src/resources.ts b/src/resources.ts index 19daf389..b6221b7b 100644 --- a/src/resources.ts +++ b/src/resources.ts @@ -8,6 +8,7 @@ export type { CreateParams, UpdateParams, LifecycleStatus, + AutoresizingSwitch, MachineListParams, MachineListItemsCursorPage, MachineCreateParams, diff --git a/src/resources/index.ts b/src/resources/index.ts index 283f989e..dbb55489 100644 --- a/src/resources/index.ts +++ b/src/resources/index.ts @@ -8,6 +8,7 @@ export type { CreateParams, UpdateParams, LifecycleStatus, + AutoresizingSwitch, MachineListParams, MachineListItemsCursorPage, MachineCreateParams, diff --git a/src/resources/machines/autoresizing.ts b/src/resources/machines/autoresizing.ts index 07c4a90b..1d432963 100644 --- a/src/resources/machines/autoresizing.ts +++ b/src/resources/machines/autoresizing.ts @@ -4,6 +4,7 @@ import { APIResource } from '../../resource'; import { APIPromise } from '../../api-promise'; import type { RequestOptions } from '../../internal/request-options'; import { path as __scalarPath } from '../../internal/utils/path'; +import type * as MachinesAPI from './machines'; export class Autoresizing extends APIResource { /** @@ -49,7 +50,7 @@ export interface Policy { /** * Permit automatic CPU growth independently of RAM. */ - cpu: 'on' | 'off'; + cpu: MachinesAPI.AutoresizingSwitch; cpu_limit_source: 'plan' | 'configured' | 'platform'; /** * Configured CPU growth limit in 0.25-vCPU steps. Null uses the plan limit. @@ -74,7 +75,7 @@ export interface Policy { /** * Permit automatic RAM growth. Automatic shrink remains internal. */ - memory: 'on' | 'off'; + memory: MachinesAPI.AutoresizingSwitch; memory_limit_source: 'plan' | 'configured' | 'platform'; /** * Configured RAM growth limit in MiB. Null uses the plan limit. @@ -104,7 +105,7 @@ export interface AutoresizingUpdateParams { /** * Body param */ - cpu?: 'on' | 'off'; + cpu?: MachinesAPI.AutoresizingSwitch; /** * Body param * @format double @@ -115,7 +116,7 @@ export interface AutoresizingUpdateParams { /** * Body param */ - memory?: 'on' | 'off'; + memory?: MachinesAPI.AutoresizingSwitch; /** * Body param * @format int64 diff --git a/src/resources/machines/index.ts b/src/resources/machines/index.ts index 32a54502..9c753ebb 100644 --- a/src/resources/machines/index.ts +++ b/src/resources/machines/index.ts @@ -8,6 +8,7 @@ export type { CreateParams, UpdateParams, LifecycleStatus, + AutoresizingSwitch, MachineListParams, MachineListItemsCursorPage, MachineCreateParams, diff --git a/src/resources/machines/machines.ts b/src/resources/machines/machines.ts index e6978c73..fe68a210 100644 --- a/src/resources/machines/machines.ts +++ b/src/resources/machines/machines.ts @@ -433,6 +433,8 @@ export namespace LifecycleStatus { } } +export type AutoresizingSwitch = 'on' | 'off'; + export interface MachineListParams extends CursorPageParams {} export type MachineListItemsCursorPage = CursorPage; @@ -640,6 +642,7 @@ export declare namespace Machines { type CreateParams as CreateParams, type UpdateParams as UpdateParams, type LifecycleStatus as LifecycleStatus, + type AutoresizingSwitch as AutoresizingSwitch, type MachineListItemsCursorPage as MachineListItemsCursorPage, type MachineRetrieveResponse as MachineRetrieveResponse, type MachineResizeResponse as MachineResizeResponse, diff --git a/src/resources/organization/autoresizing.ts b/src/resources/organization/autoresizing.ts index 9bef8172..a90d4754 100644 --- a/src/resources/organization/autoresizing.ts +++ b/src/resources/organization/autoresizing.ts @@ -3,6 +3,7 @@ import { APIResource } from '../../resource'; import { APIPromise } from '../../api-promise'; import type { RequestOptions } from '../../internal/request-options'; +import type * as MachinesAPI from '../machines/machines'; export class Autoresizing extends APIResource { /** @@ -41,7 +42,7 @@ export interface Policy { /** * Permit automatic CPU growth independently of RAM. */ - cpu: 'on' | 'off'; + cpu: MachinesAPI.AutoresizingSwitch; cpu_limit_source: 'plan' | 'configured' | 'platform'; /** * Configured CPU growth limit in 0.25-vCPU steps. Null uses the plan limit. @@ -66,7 +67,7 @@ export interface Policy { /** * Permit automatic RAM growth. Automatic shrink remains internal. */ - memory: 'on' | 'off'; + memory: MachinesAPI.AutoresizingSwitch; memory_limit_source: 'plan' | 'configured' | 'platform'; /** * Configured RAM growth limit in MiB. Null uses the plan limit. @@ -76,14 +77,14 @@ export interface Policy { } export interface AutoresizingUpdateParams { - cpu?: 'on' | 'off'; + cpu?: MachinesAPI.AutoresizingSwitch; /** * @format double * @minimum 0.25 * @multipleOf 0.25 */ cpu_max_vcpu?: number | null; - memory?: 'on' | 'off'; + memory?: MachinesAPI.AutoresizingSwitch; /** * @format int64 * @minimum 256