@tinywork/glass 0.0.45 → 0.0.47

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
@@ -1,13 +1,15 @@
1
1
  /// <reference types="node" />
2
- import fs from 'node:fs';
3
- import path from 'node:path';
4
- import http from 'node:http';
5
- import https from 'node:https';
6
- import crypto from 'node:crypto';
7
- import axios from 'axios';
8
- import qs from 'qs';
9
- import { BrowserWindow, type MenuItemConstructorOptions, type Session } from 'electron';
10
- type ResourceType = 'Fetch/XHR' | 'JS' | 'CSS' | 'Img' | 'Media' | 'Font' | 'Doc' | 'WS' | 'Wasm' | 'Other';
2
+ import fs from "node:fs";
3
+ import path from "node:path";
4
+ import http from "node:http";
5
+ import https from "node:https";
6
+ import crypto from "node:crypto";
7
+ import axios from "axios";
8
+ import qs from "qs";
9
+ import { BrowserWindow, type MenuItemConstructorOptions, type Session } from "electron";
10
+ /** 1-新增,2-修改,3-删除 */
11
+ type Operation = 1 | 2 | 3;
12
+ type ResourceType = "Fetch/XHR" | "JS" | "CSS" | "Img" | "Media" | "Font" | "Doc" | "WS" | "Wasm" | "Other";
11
13
  export type JSONPropertySchema = {
12
14
  type: string;
13
15
  description?: string;
@@ -28,7 +30,7 @@ export type DocSchema = {
28
30
  name: string;
29
31
  desc?: string;
30
32
  pathname?: string;
31
- method?: 'GET' | 'POST' | 'PUT' | 'DELETE';
33
+ method?: "GET" | "POST" | "PUT" | "DELETE";
32
34
  code?: string;
33
35
  modifier?: string;
34
36
  modifyTime?: string;
@@ -78,35 +80,78 @@ export type Plan = {
78
80
  /** 校验结果的ts类型声明 */
79
81
  assert?: string;
80
82
  };
81
- export type MockMode = 'None' | 'Local' | 'Advance';
82
- export type ActionMode = 'Modify' | 'Add' | 'Remove';
83
- export type ActionTarget = 'Origin';
84
- export type ContextMenuType = 'log' | 'group' | 'doc' | 'rule' | 'project' | 'version' | 'plan' | 'case';
83
+ export type Case = {
84
+ id: string;
85
+ versionId: string;
86
+ name: string;
87
+ desc?: string;
88
+ origin: string;
89
+ pathname: string;
90
+ method: "GET" | "POST" | "PUT" | "DELETE";
91
+ params?: Record<string, any>;
92
+ headers?: Record<string, any>;
93
+ body?: any;
94
+ apiId?: string;
95
+ /** 校验结果的ts类型声明 */
96
+ assert?: string;
97
+ };
98
+ export type CaseData = Omit<Case, "params" | "headers" | "body"> & {
99
+ params?: string;
100
+ headers?: string;
101
+ body?: string;
102
+ };
103
+ export type MockMode = "None" | "Local" | "Advance";
104
+ export type ActionMode = "Modify" | "Add" | "Remove";
105
+ export type ActionTarget = "Origin";
106
+ export type ContextMenuType = "log" | "group" | "doc" | "rule" | "project" | "version" | "plan" | "case";
85
107
  export type ContextMenuParams = {
86
- type: 'log';
108
+ type: "log";
87
109
  data: NetLog;
88
110
  } | {
89
- type: 'group';
111
+ type: "group";
90
112
  data: GroupSchema;
91
113
  } | {
92
- type: 'doc';
114
+ type: "doc";
93
115
  data: DocSchema;
94
116
  } | {
95
- type: 'rule';
117
+ type: "rule";
96
118
  data: RuleSchema;
97
119
  } | {
98
- type: 'project';
120
+ type: "project";
99
121
  data: Project;
100
122
  } | {
101
- type: 'version';
123
+ type: "version";
102
124
  data: Version;
103
125
  } | {
104
- type: 'plan';
126
+ type: "plan";
105
127
  data: Plan;
106
128
  } | {
107
- type: 'case';
129
+ type: "case";
108
130
  data: Case;
109
131
  };
132
+ export type SyncDataType = "group" | "doc" | "rule" | "project" | "version" | "plan" | "case";
133
+ export type SyncDataParams = {
134
+ type: "group";
135
+ data: GroupSchema;
136
+ } | {
137
+ type: "doc";
138
+ data: DocSchema;
139
+ } | {
140
+ type: "rule";
141
+ data: RuleSchema;
142
+ } | {
143
+ type: "project";
144
+ data: Project;
145
+ } | {
146
+ type: "version";
147
+ data: Version;
148
+ } | {
149
+ type: "plan";
150
+ data: Plan;
151
+ } | {
152
+ type: "case";
153
+ data: CaseData;
154
+ };
110
155
  export type MockModelSchema = {
111
156
  id: string;
112
157
  ruleId?: string;
@@ -157,21 +202,6 @@ export type NetLog = {
157
202
  response?: any;
158
203
  rule?: RuleSchema;
159
204
  };
160
- export type Case = {
161
- id: string;
162
- versionId: string;
163
- name: string;
164
- desc?: string;
165
- origin: string;
166
- pathname: string;
167
- method: 'GET' | 'POST' | 'PUT' | 'DELETE';
168
- params?: Record<string, any>;
169
- headers?: Record<string, any>;
170
- body?: any;
171
- apiId?: string;
172
- /** 校验结果的ts类型声明 */
173
- assert?: string;
174
- };
175
205
  export interface IProgress {
176
206
  update: (option: {
177
207
  percent: number;
@@ -238,7 +268,7 @@ export interface IGlassContext {
238
268
  showMessage: (options: {
239
269
  message: string;
240
270
  title?: string;
241
- type?: 'success' | 'info' | 'error';
271
+ type?: "success" | "info" | "error";
242
272
  }) => Promise<void>;
243
273
  showProgress: () => IProgress;
244
274
  transformDocToJsonSchema: (doc: DocFullSchema) => JSONSchema;
@@ -252,7 +282,8 @@ export interface IGlassExtension {
252
282
  onItemChange?(context: IGlassContext): Promise<void>;
253
283
  /** 要修改url时,直接在params.url = new URL方式修改 */
254
284
  onRequest?(context: IGlassContext, params: {
255
- url: URL;
285
+ /** url为null时表示break了请求 */
286
+ url: URL | null;
256
287
  req: http.IncomingMessage;
257
288
  res: http.ServerResponse;
258
289
  isLocal?: boolean;
@@ -279,6 +310,10 @@ export interface IGlassExtension {
279
310
  message?: string;
280
311
  }[];
281
312
  }): Promise<void>;
313
+ /** 远程服务同步数据至本机 */
314
+ onSyncDownload?(context: IGlassContext, operation: Operation, params: SyncDataParams): Promise<void>;
315
+ /** 本机变更同步数据至远程服务 */
316
+ onSyncUpload?(context: IGlassContext, operation: Operation, params: SyncDataParams): Promise<void>;
282
317
  /** 在postMessage到页面之前 */
283
318
  onMessagePost?(context: IGlassContext, message: Partial<NetLog>): Promise<void>;
284
319
  onResponse?(context: IGlassContext, params: {
@@ -296,7 +331,7 @@ export interface IGlassExtension {
296
331
  onContextMenu?(context: IGlassContext, params: ContextMenuParams, menus?: MenuItemConstructorOptions[]): Promise<void>;
297
332
  getDefaultRule?(context: IGlassContext, docs: DocSchema[], log: NetLog, rule?: {
298
333
  id: string;
299
- mode: 'None';
334
+ mode: "None";
300
335
  } & Partial<{
301
336
  name: string;
302
337
  origin: string;
package/dist/index.js CHANGED
@@ -1,11 +1,11 @@
1
- import fs from 'node:fs';
2
- import path from 'node:path';
3
- import http from 'node:http';
4
- import https from 'node:https';
5
- import crypto from 'node:crypto';
6
- import axios from 'axios';
7
- import qs from 'qs';
8
- import { BrowserWindow, shell, clipboard, } from 'electron';
1
+ import fs from "node:fs";
2
+ import path from "node:path";
3
+ import http from "node:http";
4
+ import https from "node:https";
5
+ import crypto from "node:crypto";
6
+ import axios from "axios";
7
+ import qs from "qs";
8
+ import { BrowserWindow, shell, clipboard, } from "electron";
9
9
  const writeText = clipboard.writeText;
10
10
  const openExternal = shell.openExternal;
11
11
  export { fs, qs, path, http, https, axios, crypto, BrowserWindow, openExternal, writeText, };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tinywork/glass",
3
- "version": "0.0.45",
3
+ "version": "0.0.47",
4
4
  "description": "",
5
5
  "main": "dist/index.js",
6
6
  "files": [