import type { components } from "../generated/api-types"; import type { BaseJob, CalculateAffectedRowsJob, CollectAccessRulesBillingDataJob, DatasetsCalculateColumnStatsJob, DatasetsCreateTableJob, DatasetsDeleteTableJob, DatasetsDeliverDataJob, DatasetsEnforceRowTtlRetentionPolicyJob, DatasetsEnforceTableTtlRetentionPolicyJob, DatasetsExecuteDmlJob, DatasetsSampleJob, DatasetsTruncateTableJob, ExplainJob, HealthCheckJob, Job, MaterializedViewJob, ModelInferenceRunJob, ModelsDeliverModelJob, ModelsTrainClassifierJob, ModelTrainingRunJob, UnknownJob } from "../jobs/types"; /** A data plane as the API returns it, owned or shared. */ export type DataPlaneResponse = components["schemas"]["DataPlaneResponse"]; /** * A data plane this company owns. Only owned planes carry an external id and * collaborators, and only they accept the default-compute-pool endpoints. */ export type DataPlaneOwnedResponse = components["schemas"]["DataPlaneOwnedResponse"]; /** * A data plane shared with this company. Same shape as the owned variant minus * `external_id` and `collaborators`, and its platform is one of the * `platform_shared_*` types rather than the owned ones. */ export type DataPlaneSharedResponse = components["schemas"]["DataPlaneSharedResponse"]; /** * The platform an owned data plane runs on — AWS or Snowflake. * * Both factories default to AWS, so a test that needs another variant passes * this as a `platform` override. Named after the root entry point's * `DataPlanePlatform` rather than the generated schema's bare `Platform`, so * the two entry points read the same way — the two are assignable in both * directions. */ export type DataPlanePlatform = components["schemas"]["Platform"]; /** * The platform a shared data plane runs on. Distinct from * {@link DataPlanePlatform}: the discriminators are the `platform_shared_*` * ones, and `region` is required on the AWS variant but optional and nullable * on the Snowflake one. */ export type DataPlaneSharedPlatform = components["schemas"]["PlatformSharedResponse"]; /** A job as the API returns it, including the one a health check enqueues. */ export type JobResponse = Job; /** * The fields every job carries, whatever its type. Exported so a test can build * a job type the fixtures do not cover without restating the envelope. */ export type JobEnvelope = BaseJob; export type MaterializeViewJobResponse = MaterializedViewJob; export type NqlForecastJobResponse = ExplainJob; export type DatasetsSampleJobResponse = DatasetsSampleJob; export type DatasetsCalculateColumnStatsJobResponse = DatasetsCalculateColumnStatsJob; export type CollectAccessRulesBillingDataJobResponse = CollectAccessRulesBillingDataJob; export type DatasetsDeliverDataJobResponse = DatasetsDeliverDataJob; export type ModelInferenceRunJobResponse = ModelInferenceRunJob; export type DatasetsDeleteTableJobResponse = DatasetsDeleteTableJob; export type DatasetsExecuteDmlJobResponse = DatasetsExecuteDmlJob; export type DatasetsCreateTableJobResponse = DatasetsCreateTableJob; export type DatasetsTruncateTableJobResponse = DatasetsTruncateTableJob; export type DatasetsEnforceTableTtlRetentionPolicyJobResponse = DatasetsEnforceTableTtlRetentionPolicyJob; export type DatasetsEnforceRowTtlRetentionPolicyJobResponse = DatasetsEnforceRowTtlRetentionPolicyJob; export type DatasetsCalculateAffectedRowsJobResponse = CalculateAffectedRowsJob; export type ModelTrainingRunJobResponse = ModelTrainingRunJob; export type ModelsDeliverModelJobResponse = ModelsDeliverModelJob; export type ModelsTrainClassifierJobResponse = ModelsTrainClassifierJob; export type HealthCheckJobResponse = HealthCheckJob; /** * A job whose type the spec does not describe a branch for. Job types are free * strings on the server, so this is what a type added after the spec was * generated decodes as, with `input` and `result` left free-form. */ export type OtherJobResponse = UnknownJob; /** * A derivation rule as the API returns it. `warnings` is populated on create * and update responses and empty on reads. */ export type DerivationResponse = components["schemas"]["DerivationResponse"]; /** * What `POST /v1/nql/execute` returns — the workflow the statement compiled to, * plus the id of its run. Named after the root entry point's * `NqlExecuteResponse` rather than the generated schema's * `CreateWorkflowResponseWithRunId`, so the two entry points read the same way. */ export type NqlExecuteResponse = components["schemas"]["CreateWorkflowResponseWithRunId"]; /** What `POST /v1/model-training/train-classifier` returns. */ export type TrainClassifierResponse = components["schemas"]["TrainClassifierResponse"]; export interface AuthGuardContext { request: Request; /** Cookies msw parsed off the request. */ cookies: Record; } /** * How handlers decide whether a request is authenticated. * * `false` accepts everything, which is what SDK tests want. A bearer or cookie * guard omitting its `token`/`value` accepts any non-empty credential, so a * test can assert that the client sends one without pinning its value. */ export type AuthGuard = false | { type: "bearer"; token?: string; } | { type: "cookie"; name: string; value?: string; } | ((context: AuthGuardContext) => boolean); export interface CreateHandlersOptions { /** * Origin the handlers match against, without a trailing slash. Note that * `BaseApi#getBaseUrl` returns one with a trailing slash, so pass the origin * rather than that value — or let this default, which matches the client's * own default environment. */ baseUrl?: string; auth?: AuthGuard; /** Seeds the in-memory data planes the handlers read and write. */ dataPlanes?: DataPlaneResponse[]; }