diff --git a/client/msw-handlers.ts b/client/msw-handlers.ts index 9e53893..2bbdb68 100644 --- a/client/msw-handlers.ts +++ b/client/msw-handlers.ts @@ -13,11 +13,12 @@ import { HttpHandler, HttpResponse, StrictResponse, - delay as doDelay, - DefaultBodyType, PathParams, } from "msw"; -import type { SnakeCasedPropertiesDeep as Snakify } from "type-fest"; +import type { + SnakeCasedPropertiesDeep as Snakify, + Promisable, +} from "type-fest"; import { z, ZodSchema } from "zod"; import type * as Api from "./Api"; import { snakeify } from "./util"; @@ -43,80 +44,83 @@ type StringifyDates = T extends Date */ export type Json = Snakify>; +// Shortcut to reduce number of imports required in consumers +export { HttpResponse }; + export interface MSWHandlers { /** `POST /device/auth` */ deviceAuthRequest: (params: { req: Request; cookies: Record; - }) => StatusCode; + }) => Promisable; /** `POST /device/confirm` */ deviceAuthConfirm: (params: { body: Json; req: Request; cookies: Record; - }) => StatusCode; + }) => Promisable; /** `POST /device/token` */ deviceAccessToken: (params: { req: Request; cookies: Record; - }) => StatusCode; + }) => Promisable; /** `POST /login/:siloName/saml/:providerName` */ loginSaml: (params: { path: Api.LoginSamlPathParams; req: Request; cookies: Record; - }) => StatusCode; + }) => Promisable; /** `GET /v1/certificates` */ certificateList: (params: { query: Api.CertificateListQueryParams; req: Request; cookies: Record; - }) => HandlerResult; + }) => Promisable>; /** `POST /v1/certificates` */ certificateCreate: (params: { body: Json; req: Request; cookies: Record; - }) => HandlerResult; + }) => Promisable>; /** `GET /v1/certificates/:certificate` */ certificateView: (params: { path: Api.CertificateViewPathParams; req: Request; cookies: Record; - }) => HandlerResult; + }) => Promisable>; /** `DELETE /v1/certificates/:certificate` */ certificateDelete: (params: { path: Api.CertificateDeletePathParams; req: Request; cookies: Record; - }) => StatusCode; + }) => Promisable; /** `GET /v1/disks` */ diskList: (params: { query: Api.DiskListQueryParams; req: Request; cookies: Record; - }) => HandlerResult; + }) => Promisable>; /** `POST /v1/disks` */ diskCreate: (params: { query: Api.DiskCreateQueryParams; body: Json; req: Request; cookies: Record; - }) => HandlerResult; + }) => Promisable>; /** `GET /v1/disks/:disk` */ diskView: (params: { path: Api.DiskViewPathParams; query: Api.DiskViewQueryParams; req: Request; cookies: Record; - }) => HandlerResult; + }) => Promisable>; /** `DELETE /v1/disks/:disk` */ diskDelete: (params: { path: Api.DiskDeletePathParams; query: Api.DiskDeleteQueryParams; req: Request; cookies: Record; - }) => StatusCode; + }) => Promisable; /** `POST /v1/disks/:disk/bulk-write` */ diskBulkWriteImport: (params: { path: Api.DiskBulkWriteImportPathParams; @@ -124,21 +128,21 @@ export interface MSWHandlers { body: Json; req: Request; cookies: Record; - }) => StatusCode; + }) => Promisable; /** `POST /v1/disks/:disk/bulk-write-start` */ diskBulkWriteImportStart: (params: { path: Api.DiskBulkWriteImportStartPathParams; query: Api.DiskBulkWriteImportStartQueryParams; req: Request; cookies: Record; - }) => StatusCode; + }) => Promisable; /** `POST /v1/disks/:disk/bulk-write-stop` */ diskBulkWriteImportStop: (params: { path: Api.DiskBulkWriteImportStopPathParams; query: Api.DiskBulkWriteImportStopQueryParams; req: Request; cookies: Record; - }) => StatusCode; + }) => Promisable; /** `POST /v1/disks/:disk/finalize` */ diskFinalizeImport: (params: { path: Api.DiskFinalizeImportPathParams; @@ -146,7 +150,7 @@ export interface MSWHandlers { body: Json; req: Request; cookies: Record; - }) => StatusCode; + }) => Promisable; /** `POST /v1/disks/:disk/import` */ diskImportBlocksFromUrl: (params: { path: Api.DiskImportBlocksFromUrlPathParams; @@ -154,101 +158,101 @@ export interface MSWHandlers { body: Json; req: Request; cookies: Record; - }) => StatusCode; + }) => Promisable; /** `GET /v1/disks/:disk/metrics/:metric` */ diskMetricsList: (params: { path: Api.DiskMetricsListPathParams; query: Api.DiskMetricsListQueryParams; req: Request; cookies: Record; - }) => HandlerResult; + }) => Promisable>; /** `GET /v1/groups` */ groupList: (params: { query: Api.GroupListQueryParams; req: Request; cookies: Record; - }) => HandlerResult; + }) => Promisable>; /** `GET /v1/groups/:groupId` */ groupView: (params: { path: Api.GroupViewPathParams; req: Request; cookies: Record; - }) => HandlerResult; + }) => Promisable>; /** `GET /v1/images` */ imageList: (params: { query: Api.ImageListQueryParams; req: Request; cookies: Record; - }) => HandlerResult; + }) => Promisable>; /** `POST /v1/images` */ imageCreate: (params: { query: Api.ImageCreateQueryParams; body: Json; req: Request; cookies: Record; - }) => HandlerResult; + }) => Promisable>; /** `GET /v1/images/:image` */ imageView: (params: { path: Api.ImageViewPathParams; query: Api.ImageViewQueryParams; req: Request; cookies: Record; - }) => HandlerResult; + }) => Promisable>; /** `DELETE /v1/images/:image` */ imageDelete: (params: { path: Api.ImageDeletePathParams; query: Api.ImageDeleteQueryParams; req: Request; cookies: Record; - }) => StatusCode; + }) => Promisable; /** `POST /v1/images/:image/demote` */ imageDemote: (params: { path: Api.ImageDemotePathParams; query: Api.ImageDemoteQueryParams; req: Request; cookies: Record; - }) => HandlerResult; + }) => Promisable>; /** `POST /v1/images/:image/promote` */ imagePromote: (params: { path: Api.ImagePromotePathParams; query: Api.ImagePromoteQueryParams; req: Request; cookies: Record; - }) => HandlerResult; + }) => Promisable>; /** `GET /v1/instances` */ instanceList: (params: { query: Api.InstanceListQueryParams; req: Request; cookies: Record; - }) => HandlerResult; + }) => Promisable>; /** `POST /v1/instances` */ instanceCreate: (params: { query: Api.InstanceCreateQueryParams; body: Json; req: Request; cookies: Record; - }) => HandlerResult; + }) => Promisable>; /** `GET /v1/instances/:instance` */ instanceView: (params: { path: Api.InstanceViewPathParams; query: Api.InstanceViewQueryParams; req: Request; cookies: Record; - }) => HandlerResult; + }) => Promisable>; /** `DELETE /v1/instances/:instance` */ instanceDelete: (params: { path: Api.InstanceDeletePathParams; query: Api.InstanceDeleteQueryParams; req: Request; cookies: Record; - }) => StatusCode; + }) => Promisable; /** `GET /v1/instances/:instance/disks` */ instanceDiskList: (params: { path: Api.InstanceDiskListPathParams; query: Api.InstanceDiskListQueryParams; req: Request; cookies: Record; - }) => HandlerResult; + }) => Promisable>; /** `POST /v1/instances/:instance/disks/attach` */ instanceDiskAttach: (params: { path: Api.InstanceDiskAttachPathParams; @@ -256,7 +260,7 @@ export interface MSWHandlers { body: Json; req: Request; cookies: Record; - }) => HandlerResult; + }) => Promisable>; /** `POST /v1/instances/:instance/disks/detach` */ instanceDiskDetach: (params: { path: Api.InstanceDiskDetachPathParams; @@ -264,14 +268,14 @@ export interface MSWHandlers { body: Json; req: Request; cookies: Record; - }) => HandlerResult; + }) => Promisable>; /** `GET /v1/instances/:instance/external-ips` */ instanceExternalIpList: (params: { path: Api.InstanceExternalIpListPathParams; query: Api.InstanceExternalIpListQueryParams; req: Request; cookies: Record; - }) => HandlerResult; + }) => Promisable>; /** `POST /v1/instances/:instance/migrate` */ instanceMigrate: (params: { path: Api.InstanceMigratePathParams; @@ -279,129 +283,129 @@ export interface MSWHandlers { body: Json; req: Request; cookies: Record; - }) => HandlerResult; + }) => Promisable>; /** `POST /v1/instances/:instance/reboot` */ instanceReboot: (params: { path: Api.InstanceRebootPathParams; query: Api.InstanceRebootQueryParams; req: Request; cookies: Record; - }) => HandlerResult; + }) => Promisable>; /** `GET /v1/instances/:instance/serial-console` */ instanceSerialConsole: (params: { path: Api.InstanceSerialConsolePathParams; query: Api.InstanceSerialConsoleQueryParams; req: Request; cookies: Record; - }) => HandlerResult; + }) => Promisable>; /** `GET /v1/instances/:instance/serial-console/stream` */ instanceSerialConsoleStream: (params: { path: Api.InstanceSerialConsoleStreamPathParams; query: Api.InstanceSerialConsoleStreamQueryParams; req: Request; cookies: Record; - }) => StatusCode; + }) => Promisable; /** `POST /v1/instances/:instance/start` */ instanceStart: (params: { path: Api.InstanceStartPathParams; query: Api.InstanceStartQueryParams; req: Request; cookies: Record; - }) => HandlerResult; + }) => Promisable>; /** `POST /v1/instances/:instance/stop` */ instanceStop: (params: { path: Api.InstanceStopPathParams; query: Api.InstanceStopQueryParams; req: Request; cookies: Record; - }) => HandlerResult; + }) => Promisable>; /** `GET /v1/ip-pools` */ projectIpPoolList: (params: { query: Api.ProjectIpPoolListQueryParams; req: Request; cookies: Record; - }) => HandlerResult; + }) => Promisable>; /** `GET /v1/ip-pools/:pool` */ projectIpPoolView: (params: { path: Api.ProjectIpPoolViewPathParams; query: Api.ProjectIpPoolViewQueryParams; req: Request; cookies: Record; - }) => HandlerResult; + }) => Promisable>; /** `POST /v1/login/:siloName/local` */ loginLocal: (params: { path: Api.LoginLocalPathParams; body: Json; req: Request; cookies: Record; - }) => StatusCode; + }) => Promisable; /** `POST /v1/logout` */ logout: (params: { req: Request; cookies: Record; - }) => StatusCode; + }) => Promisable; /** `GET /v1/me` */ currentUserView: (params: { req: Request; cookies: Record; - }) => HandlerResult; + }) => Promisable>; /** `GET /v1/me/groups` */ currentUserGroups: (params: { query: Api.CurrentUserGroupsQueryParams; req: Request; cookies: Record; - }) => HandlerResult; + }) => Promisable>; /** `GET /v1/me/ssh-keys` */ currentUserSshKeyList: (params: { query: Api.CurrentUserSshKeyListQueryParams; req: Request; cookies: Record; - }) => HandlerResult; + }) => Promisable>; /** `POST /v1/me/ssh-keys` */ currentUserSshKeyCreate: (params: { body: Json; req: Request; cookies: Record; - }) => HandlerResult; + }) => Promisable>; /** `GET /v1/me/ssh-keys/:sshKey` */ currentUserSshKeyView: (params: { path: Api.CurrentUserSshKeyViewPathParams; req: Request; cookies: Record; - }) => HandlerResult; + }) => Promisable>; /** `DELETE /v1/me/ssh-keys/:sshKey` */ currentUserSshKeyDelete: (params: { path: Api.CurrentUserSshKeyDeletePathParams; req: Request; cookies: Record; - }) => StatusCode; + }) => Promisable; /** `GET /v1/metrics/:metricName` */ siloMetric: (params: { path: Api.SiloMetricPathParams; query: Api.SiloMetricQueryParams; req: Request; cookies: Record; - }) => HandlerResult; + }) => Promisable>; /** `GET /v1/network-interfaces` */ instanceNetworkInterfaceList: (params: { query: Api.InstanceNetworkInterfaceListQueryParams; req: Request; cookies: Record; - }) => HandlerResult; + }) => Promisable>; /** `POST /v1/network-interfaces` */ instanceNetworkInterfaceCreate: (params: { query: Api.InstanceNetworkInterfaceCreateQueryParams; body: Json; req: Request; cookies: Record; - }) => HandlerResult; + }) => Promisable>; /** `GET /v1/network-interfaces/:interface` */ instanceNetworkInterfaceView: (params: { path: Api.InstanceNetworkInterfaceViewPathParams; query: Api.InstanceNetworkInterfaceViewQueryParams; req: Request; cookies: Record; - }) => HandlerResult; + }) => Promisable>; /** `PUT /v1/network-interfaces/:interface` */ instanceNetworkInterfaceUpdate: (params: { path: Api.InstanceNetworkInterfaceUpdatePathParams; @@ -409,146 +413,146 @@ export interface MSWHandlers { body: Json; req: Request; cookies: Record; - }) => HandlerResult; + }) => Promisable>; /** `DELETE /v1/network-interfaces/:interface` */ instanceNetworkInterfaceDelete: (params: { path: Api.InstanceNetworkInterfaceDeletePathParams; query: Api.InstanceNetworkInterfaceDeleteQueryParams; req: Request; cookies: Record; - }) => StatusCode; + }) => Promisable; /** `GET /v1/policy` */ policyView: (params: { req: Request; cookies: Record; - }) => HandlerResult; + }) => Promisable>; /** `PUT /v1/policy` */ policyUpdate: (params: { body: Json; req: Request; cookies: Record; - }) => HandlerResult; + }) => Promisable>; /** `GET /v1/projects` */ projectList: (params: { query: Api.ProjectListQueryParams; req: Request; cookies: Record; - }) => HandlerResult; + }) => Promisable>; /** `POST /v1/projects` */ projectCreate: (params: { body: Json; req: Request; cookies: Record; - }) => HandlerResult; + }) => Promisable>; /** `GET /v1/projects/:project` */ projectView: (params: { path: Api.ProjectViewPathParams; req: Request; cookies: Record; - }) => HandlerResult; + }) => Promisable>; /** `PUT /v1/projects/:project` */ projectUpdate: (params: { path: Api.ProjectUpdatePathParams; body: Json; req: Request; cookies: Record; - }) => HandlerResult; + }) => Promisable>; /** `DELETE /v1/projects/:project` */ projectDelete: (params: { path: Api.ProjectDeletePathParams; req: Request; cookies: Record; - }) => StatusCode; + }) => Promisable; /** `GET /v1/projects/:project/policy` */ projectPolicyView: (params: { path: Api.ProjectPolicyViewPathParams; req: Request; cookies: Record; - }) => HandlerResult; + }) => Promisable>; /** `PUT /v1/projects/:project/policy` */ projectPolicyUpdate: (params: { path: Api.ProjectPolicyUpdatePathParams; body: Json; req: Request; cookies: Record; - }) => HandlerResult; + }) => Promisable>; /** `GET /v1/snapshots` */ snapshotList: (params: { query: Api.SnapshotListQueryParams; req: Request; cookies: Record; - }) => HandlerResult; + }) => Promisable>; /** `POST /v1/snapshots` */ snapshotCreate: (params: { query: Api.SnapshotCreateQueryParams; body: Json; req: Request; cookies: Record; - }) => HandlerResult; + }) => Promisable>; /** `GET /v1/snapshots/:snapshot` */ snapshotView: (params: { path: Api.SnapshotViewPathParams; query: Api.SnapshotViewQueryParams; req: Request; cookies: Record; - }) => HandlerResult; + }) => Promisable>; /** `DELETE /v1/snapshots/:snapshot` */ snapshotDelete: (params: { path: Api.SnapshotDeletePathParams; query: Api.SnapshotDeleteQueryParams; req: Request; cookies: Record; - }) => StatusCode; + }) => Promisable; /** `GET /v1/system/hardware/disks` */ physicalDiskList: (params: { query: Api.PhysicalDiskListQueryParams; req: Request; cookies: Record; - }) => HandlerResult; + }) => Promisable>; /** `GET /v1/system/hardware/racks` */ rackList: (params: { query: Api.RackListQueryParams; req: Request; cookies: Record; - }) => HandlerResult; + }) => Promisable>; /** `GET /v1/system/hardware/racks/:rackId` */ rackView: (params: { path: Api.RackViewPathParams; req: Request; cookies: Record; - }) => HandlerResult; + }) => Promisable>; /** `GET /v1/system/hardware/sleds` */ sledList: (params: { query: Api.SledListQueryParams; req: Request; cookies: Record; - }) => HandlerResult; + }) => Promisable>; /** `GET /v1/system/hardware/sleds/:sledId` */ sledView: (params: { path: Api.SledViewPathParams; req: Request; cookies: Record; - }) => HandlerResult; + }) => Promisable>; /** `GET /v1/system/hardware/sleds/:sledId/disks` */ sledPhysicalDiskList: (params: { path: Api.SledPhysicalDiskListPathParams; query: Api.SledPhysicalDiskListQueryParams; req: Request; cookies: Record; - }) => HandlerResult; + }) => Promisable>; /** `GET /v1/system/hardware/sleds/:sledId/instances` */ sledInstanceList: (params: { path: Api.SledInstanceListPathParams; query: Api.SledInstanceListQueryParams; req: Request; cookies: Record; - }) => HandlerResult; + }) => Promisable>; /** `GET /v1/system/hardware/switch-port` */ networkingSwitchPortList: (params: { query: Api.NetworkingSwitchPortListQueryParams; req: Request; cookies: Record; - }) => HandlerResult; + }) => Promisable>; /** `POST /v1/system/hardware/switch-port/:port/settings` */ networkingSwitchPortApplySettings: (params: { path: Api.NetworkingSwitchPortApplySettingsPathParams; @@ -556,46 +560,46 @@ export interface MSWHandlers { body: Json; req: Request; cookies: Record; - }) => StatusCode; + }) => Promisable; /** `DELETE /v1/system/hardware/switch-port/:port/settings` */ networkingSwitchPortClearSettings: (params: { path: Api.NetworkingSwitchPortClearSettingsPathParams; query: Api.NetworkingSwitchPortClearSettingsQueryParams; req: Request; cookies: Record; - }) => StatusCode; + }) => Promisable; /** `GET /v1/system/hardware/switches` */ switchList: (params: { query: Api.SwitchListQueryParams; req: Request; cookies: Record; - }) => HandlerResult; + }) => Promisable>; /** `GET /v1/system/hardware/switches/:switchId` */ switchView: (params: { path: Api.SwitchViewPathParams; req: Request; cookies: Record; - }) => HandlerResult; + }) => Promisable>; /** `GET /v1/system/identity-providers` */ siloIdentityProviderList: (params: { query: Api.SiloIdentityProviderListQueryParams; req: Request; cookies: Record; - }) => HandlerResult; + }) => Promisable>; /** `POST /v1/system/identity-providers/local/users` */ localIdpUserCreate: (params: { query: Api.LocalIdpUserCreateQueryParams; body: Json; req: Request; cookies: Record; - }) => HandlerResult; + }) => Promisable>; /** `DELETE /v1/system/identity-providers/local/users/:userId` */ localIdpUserDelete: (params: { path: Api.LocalIdpUserDeletePathParams; query: Api.LocalIdpUserDeleteQueryParams; req: Request; cookies: Record; - }) => StatusCode; + }) => Promisable; /** `POST /v1/system/identity-providers/local/users/:userId/set-password` */ localIdpUserSetPassword: (params: { path: Api.LocalIdpUserSetPasswordPathParams; @@ -603,294 +607,294 @@ export interface MSWHandlers { body: Json; req: Request; cookies: Record; - }) => StatusCode; + }) => Promisable; /** `POST /v1/system/identity-providers/saml` */ samlIdentityProviderCreate: (params: { query: Api.SamlIdentityProviderCreateQueryParams; body: Json; req: Request; cookies: Record; - }) => HandlerResult; + }) => Promisable>; /** `GET /v1/system/identity-providers/saml/:provider` */ samlIdentityProviderView: (params: { path: Api.SamlIdentityProviderViewPathParams; query: Api.SamlIdentityProviderViewQueryParams; req: Request; cookies: Record; - }) => HandlerResult; + }) => Promisable>; /** `GET /v1/system/ip-pools` */ ipPoolList: (params: { query: Api.IpPoolListQueryParams; req: Request; cookies: Record; - }) => HandlerResult; + }) => Promisable>; /** `POST /v1/system/ip-pools` */ ipPoolCreate: (params: { body: Json; req: Request; cookies: Record; - }) => HandlerResult; + }) => Promisable>; /** `GET /v1/system/ip-pools/:pool` */ ipPoolView: (params: { path: Api.IpPoolViewPathParams; req: Request; cookies: Record; - }) => HandlerResult; + }) => Promisable>; /** `PUT /v1/system/ip-pools/:pool` */ ipPoolUpdate: (params: { path: Api.IpPoolUpdatePathParams; body: Json; req: Request; cookies: Record; - }) => HandlerResult; + }) => Promisable>; /** `DELETE /v1/system/ip-pools/:pool` */ ipPoolDelete: (params: { path: Api.IpPoolDeletePathParams; req: Request; cookies: Record; - }) => StatusCode; + }) => Promisable; /** `GET /v1/system/ip-pools/:pool/ranges` */ ipPoolRangeList: (params: { path: Api.IpPoolRangeListPathParams; query: Api.IpPoolRangeListQueryParams; req: Request; cookies: Record; - }) => HandlerResult; + }) => Promisable>; /** `POST /v1/system/ip-pools/:pool/ranges/add` */ ipPoolRangeAdd: (params: { path: Api.IpPoolRangeAddPathParams; body: Json; req: Request; cookies: Record; - }) => HandlerResult; + }) => Promisable>; /** `POST /v1/system/ip-pools/:pool/ranges/remove` */ ipPoolRangeRemove: (params: { path: Api.IpPoolRangeRemovePathParams; body: Json; req: Request; cookies: Record; - }) => StatusCode; + }) => Promisable; /** `GET /v1/system/ip-pools-service` */ ipPoolServiceView: (params: { req: Request; cookies: Record; - }) => HandlerResult; + }) => Promisable>; /** `GET /v1/system/ip-pools-service/ranges` */ ipPoolServiceRangeList: (params: { query: Api.IpPoolServiceRangeListQueryParams; req: Request; cookies: Record; - }) => HandlerResult; + }) => Promisable>; /** `POST /v1/system/ip-pools-service/ranges/add` */ ipPoolServiceRangeAdd: (params: { body: Json; req: Request; cookies: Record; - }) => HandlerResult; + }) => Promisable>; /** `POST /v1/system/ip-pools-service/ranges/remove` */ ipPoolServiceRangeRemove: (params: { body: Json; req: Request; cookies: Record; - }) => StatusCode; + }) => Promisable; /** `GET /v1/system/metrics/:metricName` */ systemMetric: (params: { path: Api.SystemMetricPathParams; query: Api.SystemMetricQueryParams; req: Request; cookies: Record; - }) => HandlerResult; + }) => Promisable>; /** `GET /v1/system/networking/address-lot` */ networkingAddressLotList: (params: { query: Api.NetworkingAddressLotListQueryParams; req: Request; cookies: Record; - }) => HandlerResult; + }) => Promisable>; /** `POST /v1/system/networking/address-lot` */ networkingAddressLotCreate: (params: { body: Json; req: Request; cookies: Record; - }) => HandlerResult; + }) => Promisable>; /** `DELETE /v1/system/networking/address-lot/:addressLot` */ networkingAddressLotDelete: (params: { path: Api.NetworkingAddressLotDeletePathParams; req: Request; cookies: Record; - }) => StatusCode; + }) => Promisable; /** `GET /v1/system/networking/address-lot/:addressLot/blocks` */ networkingAddressLotBlockList: (params: { path: Api.NetworkingAddressLotBlockListPathParams; query: Api.NetworkingAddressLotBlockListQueryParams; req: Request; cookies: Record; - }) => HandlerResult; + }) => Promisable>; /** `GET /v1/system/networking/loopback-address` */ networkingLoopbackAddressList: (params: { query: Api.NetworkingLoopbackAddressListQueryParams; req: Request; cookies: Record; - }) => HandlerResult; + }) => Promisable>; /** `POST /v1/system/networking/loopback-address` */ networkingLoopbackAddressCreate: (params: { body: Json; req: Request; cookies: Record; - }) => HandlerResult; + }) => Promisable>; /** `DELETE /v1/system/networking/loopback-address/:rackId/:switchLocation/:address/:subnetMask` */ networkingLoopbackAddressDelete: (params: { path: Api.NetworkingLoopbackAddressDeletePathParams; req: Request; cookies: Record; - }) => StatusCode; + }) => Promisable; /** `GET /v1/system/networking/switch-port-settings` */ networkingSwitchPortSettingsList: (params: { query: Api.NetworkingSwitchPortSettingsListQueryParams; req: Request; cookies: Record; - }) => HandlerResult; + }) => Promisable>; /** `POST /v1/system/networking/switch-port-settings` */ networkingSwitchPortSettingsCreate: (params: { body: Json; req: Request; cookies: Record; - }) => HandlerResult; + }) => Promisable>; /** `DELETE /v1/system/networking/switch-port-settings` */ networkingSwitchPortSettingsDelete: (params: { query: Api.NetworkingSwitchPortSettingsDeleteQueryParams; req: Request; cookies: Record; - }) => StatusCode; + }) => Promisable; /** `GET /v1/system/networking/switch-port-settings/:port` */ networkingSwitchPortSettingsView: (params: { path: Api.NetworkingSwitchPortSettingsViewPathParams; req: Request; cookies: Record; - }) => HandlerResult; + }) => Promisable>; /** `GET /v1/system/policy` */ systemPolicyView: (params: { req: Request; cookies: Record; - }) => HandlerResult; + }) => Promisable>; /** `PUT /v1/system/policy` */ systemPolicyUpdate: (params: { body: Json; req: Request; cookies: Record; - }) => HandlerResult; + }) => Promisable>; /** `GET /v1/system/roles` */ roleList: (params: { query: Api.RoleListQueryParams; req: Request; cookies: Record; - }) => HandlerResult; + }) => Promisable>; /** `GET /v1/system/roles/:roleName` */ roleView: (params: { path: Api.RoleViewPathParams; req: Request; cookies: Record; - }) => HandlerResult; + }) => Promisable>; /** `GET /v1/system/silos` */ siloList: (params: { query: Api.SiloListQueryParams; req: Request; cookies: Record; - }) => HandlerResult; + }) => Promisable>; /** `POST /v1/system/silos` */ siloCreate: (params: { body: Json; req: Request; cookies: Record; - }) => HandlerResult; + }) => Promisable>; /** `GET /v1/system/silos/:silo` */ siloView: (params: { path: Api.SiloViewPathParams; req: Request; cookies: Record; - }) => HandlerResult; + }) => Promisable>; /** `DELETE /v1/system/silos/:silo` */ siloDelete: (params: { path: Api.SiloDeletePathParams; req: Request; cookies: Record; - }) => StatusCode; + }) => Promisable; /** `GET /v1/system/silos/:silo/policy` */ siloPolicyView: (params: { path: Api.SiloPolicyViewPathParams; req: Request; cookies: Record; - }) => HandlerResult; + }) => Promisable>; /** `PUT /v1/system/silos/:silo/policy` */ siloPolicyUpdate: (params: { path: Api.SiloPolicyUpdatePathParams; body: Json; req: Request; cookies: Record; - }) => HandlerResult; + }) => Promisable>; /** `GET /v1/system/users` */ siloUserList: (params: { query: Api.SiloUserListQueryParams; req: Request; cookies: Record; - }) => HandlerResult; + }) => Promisable>; /** `GET /v1/system/users/:userId` */ siloUserView: (params: { path: Api.SiloUserViewPathParams; query: Api.SiloUserViewQueryParams; req: Request; cookies: Record; - }) => HandlerResult; + }) => Promisable>; /** `GET /v1/system/users-builtin` */ userBuiltinList: (params: { query: Api.UserBuiltinListQueryParams; req: Request; cookies: Record; - }) => HandlerResult; + }) => Promisable>; /** `GET /v1/system/users-builtin/:user` */ userBuiltinView: (params: { path: Api.UserBuiltinViewPathParams; req: Request; cookies: Record; - }) => HandlerResult; + }) => Promisable>; /** `GET /v1/users` */ userList: (params: { query: Api.UserListQueryParams; req: Request; cookies: Record; - }) => HandlerResult; + }) => Promisable>; /** `GET /v1/vpc-firewall-rules` */ vpcFirewallRulesView: (params: { query: Api.VpcFirewallRulesViewQueryParams; req: Request; cookies: Record; - }) => HandlerResult; + }) => Promisable>; /** `PUT /v1/vpc-firewall-rules` */ vpcFirewallRulesUpdate: (params: { query: Api.VpcFirewallRulesUpdateQueryParams; body: Json; req: Request; cookies: Record; - }) => HandlerResult; + }) => Promisable>; /** `GET /v1/vpc-router-routes` */ vpcRouterRouteList: (params: { query: Api.VpcRouterRouteListQueryParams; req: Request; cookies: Record; - }) => HandlerResult; + }) => Promisable>; /** `POST /v1/vpc-router-routes` */ vpcRouterRouteCreate: (params: { query: Api.VpcRouterRouteCreateQueryParams; body: Json; req: Request; cookies: Record; - }) => HandlerResult; + }) => Promisable>; /** `GET /v1/vpc-router-routes/:route` */ vpcRouterRouteView: (params: { path: Api.VpcRouterRouteViewPathParams; query: Api.VpcRouterRouteViewQueryParams; req: Request; cookies: Record; - }) => HandlerResult; + }) => Promisable>; /** `PUT /v1/vpc-router-routes/:route` */ vpcRouterRouteUpdate: (params: { path: Api.VpcRouterRouteUpdatePathParams; @@ -898,34 +902,34 @@ export interface MSWHandlers { body: Json; req: Request; cookies: Record; - }) => HandlerResult; + }) => Promisable>; /** `DELETE /v1/vpc-router-routes/:route` */ vpcRouterRouteDelete: (params: { path: Api.VpcRouterRouteDeletePathParams; query: Api.VpcRouterRouteDeleteQueryParams; req: Request; cookies: Record; - }) => StatusCode; + }) => Promisable; /** `GET /v1/vpc-routers` */ vpcRouterList: (params: { query: Api.VpcRouterListQueryParams; req: Request; cookies: Record; - }) => HandlerResult; + }) => Promisable>; /** `POST /v1/vpc-routers` */ vpcRouterCreate: (params: { query: Api.VpcRouterCreateQueryParams; body: Json; req: Request; cookies: Record; - }) => HandlerResult; + }) => Promisable>; /** `GET /v1/vpc-routers/:router` */ vpcRouterView: (params: { path: Api.VpcRouterViewPathParams; query: Api.VpcRouterViewQueryParams; req: Request; cookies: Record; - }) => HandlerResult; + }) => Promisable>; /** `PUT /v1/vpc-routers/:router` */ vpcRouterUpdate: (params: { path: Api.VpcRouterUpdatePathParams; @@ -933,34 +937,34 @@ export interface MSWHandlers { body: Json; req: Request; cookies: Record; - }) => HandlerResult; + }) => Promisable>; /** `DELETE /v1/vpc-routers/:router` */ vpcRouterDelete: (params: { path: Api.VpcRouterDeletePathParams; query: Api.VpcRouterDeleteQueryParams; req: Request; cookies: Record; - }) => StatusCode; + }) => Promisable; /** `GET /v1/vpc-subnets` */ vpcSubnetList: (params: { query: Api.VpcSubnetListQueryParams; req: Request; cookies: Record; - }) => HandlerResult; + }) => Promisable>; /** `POST /v1/vpc-subnets` */ vpcSubnetCreate: (params: { query: Api.VpcSubnetCreateQueryParams; body: Json; req: Request; cookies: Record; - }) => HandlerResult; + }) => Promisable>; /** `GET /v1/vpc-subnets/:subnet` */ vpcSubnetView: (params: { path: Api.VpcSubnetViewPathParams; query: Api.VpcSubnetViewQueryParams; req: Request; cookies: Record; - }) => HandlerResult; + }) => Promisable>; /** `PUT /v1/vpc-subnets/:subnet` */ vpcSubnetUpdate: (params: { path: Api.VpcSubnetUpdatePathParams; @@ -968,41 +972,41 @@ export interface MSWHandlers { body: Json; req: Request; cookies: Record; - }) => HandlerResult; + }) => Promisable>; /** `DELETE /v1/vpc-subnets/:subnet` */ vpcSubnetDelete: (params: { path: Api.VpcSubnetDeletePathParams; query: Api.VpcSubnetDeleteQueryParams; req: Request; cookies: Record; - }) => StatusCode; + }) => Promisable; /** `GET /v1/vpc-subnets/:subnet/network-interfaces` */ vpcSubnetListNetworkInterfaces: (params: { path: Api.VpcSubnetListNetworkInterfacesPathParams; query: Api.VpcSubnetListNetworkInterfacesQueryParams; req: Request; cookies: Record; - }) => HandlerResult; + }) => Promisable>; /** `GET /v1/vpcs` */ vpcList: (params: { query: Api.VpcListQueryParams; req: Request; cookies: Record; - }) => HandlerResult; + }) => Promisable>; /** `POST /v1/vpcs` */ vpcCreate: (params: { query: Api.VpcCreateQueryParams; body: Json; req: Request; cookies: Record; - }) => HandlerResult; + }) => Promisable>; /** `GET /v1/vpcs/:vpc` */ vpcView: (params: { path: Api.VpcViewPathParams; query: Api.VpcViewQueryParams; req: Request; cookies: Record; - }) => HandlerResult; + }) => Promisable>; /** `PUT /v1/vpcs/:vpc` */ vpcUpdate: (params: { path: Api.VpcUpdatePathParams; @@ -1010,14 +1014,14 @@ export interface MSWHandlers { body: Json; req: Request; cookies: Record; - }) => HandlerResult; + }) => Promisable>; /** `DELETE /v1/vpcs/:vpc` */ vpcDelete: (params: { path: Api.VpcDeletePathParams; query: Api.VpcDeleteQueryParams; req: Request; cookies: Record; - }) => StatusCode; + }) => Promisable; } function validateBody(schema: S, body: unknown) { diff --git a/generator/client/msw-handlers.ts b/generator/client/msw-handlers.ts index 7ff256e..13634fc 100644 --- a/generator/client/msw-handlers.ts +++ b/generator/client/msw-handlers.ts @@ -39,11 +39,9 @@ export function generateMSWHandlers(spec: OpenAPIV3.Document) { HttpHandler, HttpResponse, StrictResponse, - delay as doDelay, - DefaultBodyType, PathParams, } from "msw"; - import type { SnakeCasedPropertiesDeep as Snakify } from "type-fest"; + import type { SnakeCasedPropertiesDeep as Snakify, Promisable } from "type-fest"; import { z, ZodSchema } from "zod"; import type * as Api from "./Api"; import { snakeify } from "./util"; @@ -68,6 +66,10 @@ export function generateMSWHandlers(spec: OpenAPIV3.Document) { * purpose JSON type! */ export type Json = Snakify> + + + // Shortcut to reduce number of imports required in consumers + export { HttpResponse } `); w(`export interface MSWHandlers {`); @@ -106,7 +108,9 @@ export function generateMSWHandlers(spec: OpenAPIV3.Document) { const params = `params: { ${pathParamsType} ${queryParamsType} ${body} req: Request, cookies: Record }`; const resultType = - successType === "void" ? "StatusCode" : `HandlerResult<${successType}>`; + successType === "void" + ? "Promisable" + : `Promisable>`; w(`/** \`${method.toUpperCase()} ${formatPath(path)}\` */`); w(` ${opName}: (${params}) => ${resultType},`);