Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion packages/mock-addon/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
},
"main": "dist/cjs/index.js",
"module": "dist/esm/index.js",
"types": "dist/ts/index.d.ts",
"types": "typings.d.ts",
"files": [
"dist/**/*",
"README.md",
Expand Down
1 change: 0 additions & 1 deletion packages/mock-addon/src/typings.d.ts

This file was deleted.

41 changes: 41 additions & 0 deletions packages/mock-addon/typings.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
type JSONValue = string | number | boolean | JSONObject | JSONArray
type JSONArray = Array<JSONValue>
interface JSONObject {
[x: string]: JSONValue
}

export type Method = 'GET' | 'PUT' | 'POST' | 'DELETE' | 'PATCH' | 'OPTIONS'

export type Request = {
body: string | null
method: Method
signal: AbortSignal | null
url: string
searchParams?: string
}

export type ResponseObj = JSONObject | JSONArray
export type ResponseFn = (request: Request) => JSONValue
export type Response = ResponseObj | ResponseFn

export type StorybookAddonMockData = {
url: string
method: Method
/** @default 0 */
delay?: number
status: number
response: Response
}

declare module '@storybook/csf' {
interface Parameters {
mockAddonConfigs?: {
globalMockData?: StorybookAddonMockData[]
ignoreQueryParams?: boolean
refreshStoryOnUpdate?: boolean
disableUsingOriginal?: boolean
disable?: boolean
}
mockData?: StorybookAddonMockData[]
}
}