@tinywork/glass 0.0.33 → 0.0.35

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.
package/dist/index.d.ts CHANGED
@@ -3,9 +3,9 @@ import fs from 'node:fs';
3
3
  import path from 'node:path';
4
4
  import http from 'node:http';
5
5
  import https from 'node:https';
6
- import querystring from 'node:querystring';
7
6
  import crypto from 'node:crypto';
8
7
  import axios from 'axios';
8
+ import qs from 'qs';
9
9
  import { BrowserWindow, type MenuItemConstructorOptions, type Session } from 'electron';
10
10
  type ResourceType = 'Fetch/XHR' | 'JS' | 'CSS' | 'Img' | 'Media' | 'Font' | 'Doc' | 'WS' | 'Wasm' | 'Other';
11
11
  export type JSONPropertySchema = {
@@ -63,6 +63,21 @@ export type NetLog = {
63
63
  resourceType?: ResourceType;
64
64
  response?: any;
65
65
  };
66
+ export type Case = {
67
+ id: string;
68
+ versionId: string;
69
+ name: string;
70
+ desc?: string;
71
+ origin: string;
72
+ pathname: string;
73
+ method: 'GET' | 'POST' | 'PUT' | 'DELETE';
74
+ params?: string;
75
+ headers?: string;
76
+ body?: string;
77
+ apiId?: string;
78
+ /** 校验结果的ts类型声明 */
79
+ response?: string;
80
+ };
66
81
  export interface IProgress {
67
82
  update: (option: {
68
83
  percent: number;
@@ -154,6 +169,20 @@ export interface IGlassExtension {
154
169
  params?: Record<string, any>;
155
170
  data?: any;
156
171
  }): Promise<void>;
172
+ /** 在用例批量执行前触发 */
173
+ beforeCasesExec?(context: IGlassContext, data: {
174
+ list: Case[];
175
+ }): Promise<void>;
176
+ /** 在单条用例执行时触发 */
177
+ onCaseExec?(context: IGlassContext, data: Case): Promise<void>;
178
+ /** 在用例批量执行后触发 */
179
+ afterCasesExec?(context: IGlassContext, data: {
180
+ list: Case[];
181
+ failCases: {
182
+ id: string;
183
+ message?: string;
184
+ }[];
185
+ }): Promise<void>;
157
186
  /** 在postMessage到页面之前 */
158
187
  onMessagePost?(context: IGlassContext, message: Partial<NetLog>): Promise<void>;
159
188
  onResponse?(context: IGlassContext, params: {
@@ -180,5 +209,7 @@ export interface IGlassExtension {
180
209
  }[];
181
210
  apiId: string;
182
211
  }>): Promise<void>;
212
+ /** 根据doc或者log来初始化case */
213
+ getDefaultCase?(context: IGlassContext, docs: DocSchema[], log?: NetLog, defaultCase?: Partial<Case>): Promise<void>;
183
214
  }
184
- export { fs, querystring, path, http, https, axios, crypto, BrowserWindow, type Session };
215
+ export { fs, qs, path, http, https, axios, crypto, BrowserWindow, type Session };
package/dist/index.js CHANGED
@@ -2,8 +2,8 @@ import fs from 'node:fs';
2
2
  import path from 'node:path';
3
3
  import http from 'node:http';
4
4
  import https from 'node:https';
5
- import querystring from 'node:querystring';
6
5
  import crypto from 'node:crypto';
7
6
  import axios from 'axios';
7
+ import qs from 'qs';
8
8
  import { BrowserWindow } from 'electron';
9
- export { fs, querystring, path, http, https, axios, crypto, BrowserWindow };
9
+ export { fs, qs, path, http, https, axios, crypto, BrowserWindow };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tinywork/glass",
3
- "version": "0.0.33",
3
+ "version": "0.0.35",
4
4
  "description": "",
5
5
  "main": "dist/index.js",
6
6
  "files": [
@@ -16,11 +16,13 @@
16
16
  "electron": "^21.0.0"
17
17
  },
18
18
  "dependencies": {
19
- "axios": "^1.2.2"
19
+ "axios": "^1.2.2",
20
+ "qs": "^6.11.2"
20
21
  },
21
22
  "devDependencies": {
22
23
  "@commitlint/cli": "^17.5.1",
23
24
  "@commitlint/config-conventional": "^17.4.4",
25
+ "@types/qs": "^6.9.8",
24
26
  "standard-version": "^9.5.0",
25
27
  "typescript": "^4.9.4"
26
28
  },