vite-plugin-automock 1.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.
@@ -0,0 +1,19 @@
1
+ import {
2
+ createMockInterceptor,
3
+ initMockInterceptor,
4
+ initMockInterceptorForPureHttp,
5
+ isMockEnabled,
6
+ loadMockData,
7
+ registerHttpInstance,
8
+ setMockEnabled
9
+ } from "../chunk-NWIN2A3G.mjs";
10
+ export {
11
+ createMockInterceptor,
12
+ initMockInterceptor,
13
+ initMockInterceptorForPureHttp,
14
+ isMockEnabled,
15
+ loadMockData,
16
+ registerHttpInstance,
17
+ setMockEnabled
18
+ };
19
+ //# sourceMappingURL=index.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
@@ -0,0 +1,63 @@
1
+ import { Plugin } from 'vite';
2
+ export { MockBundleData as ClientMockBundleData, MockInterceptorOptions, createMockInterceptor, initMockInterceptor, initMockInterceptorForPureHttp, isMockEnabled, loadMockData, registerHttpInstance, setMockEnabled } from './client/index.mjs';
3
+ import 'axios';
4
+
5
+ interface InspectorOptions {
6
+ route?: string;
7
+ enableToggle?: boolean;
8
+ }
9
+ interface AutomockPluginOptions {
10
+ mockDir?: string;
11
+ apiPrefix?: string;
12
+ pathRewrite?: (path: string) => string;
13
+ proxyBaseUrl?: string;
14
+ inspector?: boolean | InspectorOptions;
15
+ productionMock?: boolean | 'auto';
16
+ }
17
+
18
+ interface MockFileConfig {
19
+ enable: boolean;
20
+ data: unknown;
21
+ delay: number;
22
+ status: number;
23
+ [key: string]: unknown;
24
+ }
25
+ interface MockFileInfo {
26
+ config: MockFileConfig;
27
+ serializable: boolean;
28
+ hasDynamicData: boolean;
29
+ headerComment?: string;
30
+ description?: string;
31
+ dataText: string;
32
+ isBinary?: boolean;
33
+ }
34
+ declare const saveMockData: (url: string, method: string, data: Buffer | string, rootDir: string, statusCode?: number, contentType?: string) => Promise<string | null>;
35
+ declare const buildMockIndex: (mockDir: string) => Map<string, string>;
36
+ declare const parseMockModule: (filePath: string) => Promise<MockFileInfo>;
37
+ declare const writeMockFile: (filePath: string, mockInfo: Pick<MockFileInfo, "config" | "headerComment" | "description">) => Promise<void>;
38
+
39
+ interface MockBundleData {
40
+ enable: boolean;
41
+ data: unknown;
42
+ delay: number;
43
+ status: number;
44
+ isBinary?: boolean;
45
+ }
46
+ interface MockBundle {
47
+ [key: string]: MockBundleData;
48
+ }
49
+ interface BundleOptions {
50
+ mockDir: string;
51
+ includeDisabled?: boolean;
52
+ log?: boolean;
53
+ }
54
+ declare function bundleMockFiles(options: BundleOptions): Promise<MockBundle>;
55
+ declare function writeMockBundle(bundle: MockBundle, outputPath: string): void;
56
+
57
+ interface AutomockWithBundleOptions extends AutomockPluginOptions {
58
+ bundleMockData?: boolean;
59
+ bundleOutputPath?: string;
60
+ }
61
+ declare function automock(options?: AutomockWithBundleOptions): Plugin;
62
+
63
+ export { type AutomockPluginOptions, type AutomockWithBundleOptions, type InspectorOptions, type MockBundle, type MockBundleData, automock, buildMockIndex, bundleMockFiles, parseMockModule, saveMockData, writeMockBundle, writeMockFile };
@@ -0,0 +1,63 @@
1
+ import { Plugin } from 'vite';
2
+ export { MockBundleData as ClientMockBundleData, MockInterceptorOptions, createMockInterceptor, initMockInterceptor, initMockInterceptorForPureHttp, isMockEnabled, loadMockData, registerHttpInstance, setMockEnabled } from './client/index.js';
3
+ import 'axios';
4
+
5
+ interface InspectorOptions {
6
+ route?: string;
7
+ enableToggle?: boolean;
8
+ }
9
+ interface AutomockPluginOptions {
10
+ mockDir?: string;
11
+ apiPrefix?: string;
12
+ pathRewrite?: (path: string) => string;
13
+ proxyBaseUrl?: string;
14
+ inspector?: boolean | InspectorOptions;
15
+ productionMock?: boolean | 'auto';
16
+ }
17
+
18
+ interface MockFileConfig {
19
+ enable: boolean;
20
+ data: unknown;
21
+ delay: number;
22
+ status: number;
23
+ [key: string]: unknown;
24
+ }
25
+ interface MockFileInfo {
26
+ config: MockFileConfig;
27
+ serializable: boolean;
28
+ hasDynamicData: boolean;
29
+ headerComment?: string;
30
+ description?: string;
31
+ dataText: string;
32
+ isBinary?: boolean;
33
+ }
34
+ declare const saveMockData: (url: string, method: string, data: Buffer | string, rootDir: string, statusCode?: number, contentType?: string) => Promise<string | null>;
35
+ declare const buildMockIndex: (mockDir: string) => Map<string, string>;
36
+ declare const parseMockModule: (filePath: string) => Promise<MockFileInfo>;
37
+ declare const writeMockFile: (filePath: string, mockInfo: Pick<MockFileInfo, "config" | "headerComment" | "description">) => Promise<void>;
38
+
39
+ interface MockBundleData {
40
+ enable: boolean;
41
+ data: unknown;
42
+ delay: number;
43
+ status: number;
44
+ isBinary?: boolean;
45
+ }
46
+ interface MockBundle {
47
+ [key: string]: MockBundleData;
48
+ }
49
+ interface BundleOptions {
50
+ mockDir: string;
51
+ includeDisabled?: boolean;
52
+ log?: boolean;
53
+ }
54
+ declare function bundleMockFiles(options: BundleOptions): Promise<MockBundle>;
55
+ declare function writeMockBundle(bundle: MockBundle, outputPath: string): void;
56
+
57
+ interface AutomockWithBundleOptions extends AutomockPluginOptions {
58
+ bundleMockData?: boolean;
59
+ bundleOutputPath?: string;
60
+ }
61
+ declare function automock(options?: AutomockWithBundleOptions): Plugin;
62
+
63
+ export { type AutomockPluginOptions, type AutomockWithBundleOptions, type InspectorOptions, type MockBundle, type MockBundleData, automock, buildMockIndex, bundleMockFiles, parseMockModule, saveMockData, writeMockBundle, writeMockFile };