@tinywork/glass 0.0.46 → 0.0.48

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
@@ -7,7 +7,13 @@ import crypto from "node:crypto";
7
7
  import axios from "axios";
8
8
  import qs from "qs";
9
9
  import { BrowserWindow, type MenuItemConstructorOptions, type Session } from "electron";
10
- type ResourceType = "Fetch/XHR" | "JS" | "CSS" | "Img" | "Media" | "Font" | "Doc" | "WS" | "Wasm" | "Other";
10
+ /** 1-新增,2-修改,3-删除 */
11
+ export declare enum Operation {
12
+ ADD = 1,
13
+ MODIFY = 2,
14
+ DELETE = 3
15
+ }
16
+ export type ResourceType = "Fetch/XHR" | "JS" | "CSS" | "Img" | "Media" | "Font" | "Doc" | "WS" | "Wasm" | "Other";
11
17
  export type JSONPropertySchema = {
12
18
  type: string;
13
19
  description?: string;
@@ -78,6 +84,26 @@ export type Plan = {
78
84
  /** 校验结果的ts类型声明 */
79
85
  assert?: string;
80
86
  };
87
+ export type Case = {
88
+ id: string;
89
+ versionId: string;
90
+ name: string;
91
+ desc?: string;
92
+ origin: string;
93
+ pathname: string;
94
+ method: "GET" | "POST" | "PUT" | "DELETE";
95
+ params?: Record<string, any>;
96
+ headers?: Record<string, any>;
97
+ body?: any;
98
+ apiId?: string;
99
+ /** 校验结果的ts类型声明 */
100
+ assert?: string;
101
+ };
102
+ export type CaseData = Omit<Case, "params" | "headers" | "body"> & {
103
+ params?: string;
104
+ headers?: string;
105
+ body?: string;
106
+ };
81
107
  export type MockMode = "None" | "Local" | "Advance";
82
108
  export type ActionMode = "Modify" | "Add" | "Remove";
83
109
  export type ActionTarget = "Origin";
@@ -107,6 +133,29 @@ export type ContextMenuParams = {
107
133
  type: "case";
108
134
  data: Case;
109
135
  };
136
+ export type SyncDataType = "group" | "doc" | "rule" | "project" | "version" | "plan" | "case";
137
+ export type SyncDataParams = {
138
+ type: "group";
139
+ data: GroupSchema;
140
+ } | {
141
+ type: "doc";
142
+ data: DocSchema;
143
+ } | {
144
+ type: "rule";
145
+ data: RuleSchema;
146
+ } | {
147
+ type: "project";
148
+ data: Project;
149
+ } | {
150
+ type: "version";
151
+ data: Version;
152
+ } | {
153
+ type: "plan";
154
+ data: Plan;
155
+ } | {
156
+ type: "case";
157
+ data: CaseData;
158
+ };
110
159
  export type MockModelSchema = {
111
160
  id: string;
112
161
  ruleId?: string;
@@ -157,21 +206,6 @@ export type NetLog = {
157
206
  response?: any;
158
207
  rule?: RuleSchema;
159
208
  };
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
209
  export interface IProgress {
176
210
  update: (option: {
177
211
  percent: number;
@@ -280,6 +314,10 @@ export interface IGlassExtension {
280
314
  message?: string;
281
315
  }[];
282
316
  }): Promise<void>;
317
+ /** 远程服务同步数据至本机 */
318
+ onSyncDownload?(context: IGlassContext, operation: Operation, params: SyncDataParams): Promise<void>;
319
+ /** 本机变更同步数据至远程服务 */
320
+ onSyncUpload?(context: IGlassContext, operation: Operation, params: SyncDataParams): Promise<void>;
283
321
  /** 在postMessage到页面之前 */
284
322
  onMessagePost?(context: IGlassContext, message: Partial<NetLog>): Promise<void>;
285
323
  onResponse?(context: IGlassContext, params: {
package/dist/index.js CHANGED
@@ -6,6 +6,13 @@ import crypto from "node:crypto";
6
6
  import axios from "axios";
7
7
  import qs from "qs";
8
8
  import { BrowserWindow, shell, clipboard, } from "electron";
9
+ /** 1-新增,2-修改,3-删除 */
10
+ export var Operation;
11
+ (function (Operation) {
12
+ Operation[Operation["ADD"] = 1] = "ADD";
13
+ Operation[Operation["MODIFY"] = 2] = "MODIFY";
14
+ Operation[Operation["DELETE"] = 3] = "DELETE";
15
+ })(Operation || (Operation = {}));
9
16
  const writeText = clipboard.writeText;
10
17
  const openExternal = shell.openExternal;
11
18
  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.46",
3
+ "version": "0.0.48",
4
4
  "description": "",
5
5
  "main": "dist/index.js",
6
6
  "files": [