@arronqzy/react-blueprint 1.0.22 → 1.0.23

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/README.md CHANGED
@@ -104,6 +104,19 @@ useBlueprintPageLifecycle({
104
104
  | `BlueprintPanelToolbar` | 库、保存、同步、调试按钮 |
105
105
  | `BlueprintExecutionLogPanel` | 执行日志 |
106
106
 
107
+ ## 本地存储
108
+
109
+ 蓝图库、执行日志、接口集合存在 IndexedDB,函数最后一个参数都是 `nameSpace`:
110
+
111
+ | 数据 | 函数 |
112
+ |------|------|
113
+ | 蓝图库 | `listBlueprintLibrary` / `getBlueprintLibraryRecord` / `putBlueprintLibraryRecord` / `deleteBlueprintLibraryRecord` / `clearBlueprintLibrary` |
114
+ | 执行日志 | `listExecutionRunRecords` / `getExecutionRunRecord` / `putExecutionRunRecord` / `deleteExecutionRunRecord` / `clearAllExecutionRunRecords` / `purgeExecutionRunsOlderThan` / `trimExecutionRunRecordsToMax` / `downloadExecutionRunExport` |
115
+ | 执行日志保留策略 | `readExecutionLogSettings` / `writeExecutionLogSettings` / `DEFAULT_EXECUTION_LOG_SETTINGS` |
116
+ | 接口集合 | `listApiCollectionRecords` / `deleteApiCollection` / `clearApiCollections`(同时更新内存中的接口列表) |
117
+
118
+ 这一层不负责通知已挂载的视图面板。宿主清理数据请用 `@arronqzy/abuilder` / `@arronqzy/abuilder-vue` 导出的同名函数,删除蓝图库后面板会自动刷新。
119
+
107
120
  ## 依赖
108
121
 
109
122
  `@arronqzy/blueprint-dsl`、`@arronqzy/i18n`、`@arronqzy/react-rx-store`、`@arronqzy/ui`、`@xyflow/react`。
package/index.ts CHANGED
@@ -22,12 +22,19 @@ export type {
22
22
  } from "./src/hooks/useBlueprintDebugSession";
23
23
  export {
24
24
  listExecutionRunRecords,
25
+ getExecutionRunRecord,
25
26
  putExecutionRunRecord,
27
+ deleteExecutionRunRecord,
26
28
  purgeExecutionRunsOlderThan,
27
29
  clearAllExecutionRunRecords,
28
30
  trimExecutionRunRecordsToMax,
29
31
  downloadExecutionRunExport,
30
32
  } from "./src/library/execution-log-db";
33
+ export {
34
+ DEFAULT_EXECUTION_LOG_SETTINGS,
35
+ readExecutionLogSettings,
36
+ writeExecutionLogSettings,
37
+ } from "./src/library/execution-log-settings";
31
38
  export type { UseBlueprintPageLifecycleOptions } from "./src/hooks/useBlueprintPageLifecycle";
32
39
  export { useBlueprintPageLifecycle } from "./src/hooks/useBlueprintPageLifecycle";
33
40
  export { stopAllClockSchedules } from "@arronqzy/blueprint-dsl";
@@ -50,15 +57,22 @@ export {
50
57
  getApiCollectionListItems,
51
58
  upsertApiCollectionFromJson,
52
59
  removeApiCollection,
60
+ deleteApiCollection,
61
+ clearApiCollections,
53
62
  subscribeApiCollections,
54
63
  useApiCollections,
55
64
  useApiCollectionListItems,
56
65
  } from "./src/library/api-collection-store";
66
+ export type {
67
+ UpsertApiCollectionInput,
68
+ UpsertApiCollectionResult,
69
+ } from "./src/library/api-collection-store";
57
70
  export {
58
71
  listApiCollectionRecords,
59
72
  getApiCollectionRecord,
60
73
  putApiCollectionRecord,
61
74
  deleteApiCollectionRecord,
75
+ clearApiCollectionRecords,
62
76
  } from "./src/library/api-collection-db";
63
77
  export { BlueprintLibrarySelect } from "./src/components/BlueprintLibrarySelect";
64
78
  export type { BlueprintLibrarySelectProps } from "./src/components/BlueprintLibrarySelect";
@@ -87,6 +101,7 @@ export {
87
101
  parseBlueprintImportFile,
88
102
  } from "./src/library/blueprint-io";
89
103
  export {
104
+ clearBlueprintLibrary,
90
105
  deleteBlueprintLibraryRecord,
91
106
  getBlueprintLibraryRecord,
92
107
  listBlueprintLibrary,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@arronqzy/react-blueprint",
3
- "version": "1.0.22",
3
+ "version": "1.0.23",
4
4
  "description": "",
5
5
  "files": [
6
6
  "index.ts",
@@ -19,9 +19,9 @@
19
19
  "react-dom": "^19",
20
20
  "@xyflow/react": "^12.9.3",
21
21
  "@arronqzy/blueprint-dsl": "1.0.17",
22
+ "@arronqzy/i18n": "0.1.17",
22
23
  "@arronqzy/react-rx-store": "1.1.8",
23
- "@arronqzy/ui": "1.0.10",
24
- "@arronqzy/i18n": "0.1.17"
24
+ "@arronqzy/ui": "1.0.10"
25
25
  },
26
26
  "devDependencies": {
27
27
  "@types/react": "^19.0.1",
@@ -96,3 +96,7 @@ export async function deleteApiCollectionRecord(
96
96
  nameSpace
97
97
  );
98
98
  }
99
+
100
+ export async function clearApiCollectionRecords(nameSpace?: string | null): Promise<void> {
101
+ await runTransaction<undefined>("readwrite", (store) => store.clear(), nameSpace);
102
+ }
@@ -6,9 +6,11 @@ import {
6
6
  type ApiCollectionDocument,
7
7
  type ApiCollectionListItem,
8
8
  type ApiCollectionRecord,
9
+ normalizeAppNameSpace,
9
10
  } from "@arronqzy/blueprint-dsl";
10
11
 
11
12
  import {
13
+ clearApiCollectionRecords,
12
14
  deleteApiCollectionRecord,
13
15
  listApiCollectionRecords,
14
16
  putApiCollectionRecord,
@@ -127,6 +129,34 @@ export async function removeApiCollection(id: string): Promise<void> {
127
129
  emit();
128
130
  }
129
131
 
132
+ function isCurrentNameSpace(nameSpace?: string | null): boolean {
133
+ return normalizeAppNameSpace(nameSpace) === normalizeAppNameSpace(nameSpaceRef);
134
+ }
135
+
136
+ /** 按 nameSpace 删除接口集合;若该 nameSpace 正在被编辑器使用,内存列表同步移除 */
137
+ export async function deleteApiCollection(
138
+ id: string,
139
+ nameSpace?: string | null
140
+ ): Promise<void> {
141
+ await deleteApiCollectionRecord(id, nameSpace);
142
+ if (!isCurrentNameSpace(nameSpace)) return;
143
+ records = records.filter((item) => item.id !== id);
144
+ emit();
145
+ }
146
+
147
+ /** 清空该 nameSpace 下的接口集合(含仅存内存的集合),返回删除数量 */
148
+ export async function clearApiCollections(nameSpace?: string | null): Promise<number> {
149
+ const persisted = await listApiCollectionRecords(nameSpace);
150
+ await clearApiCollectionRecords(nameSpace);
151
+ const removedIds = new Set(persisted.map((item) => item.id));
152
+ if (isCurrentNameSpace(nameSpace)) {
153
+ records.forEach((item) => removedIds.add(item.id));
154
+ records = [];
155
+ emit();
156
+ }
157
+ return removedIds.size;
158
+ }
159
+
130
160
  export function useApiCollections(): ApiCollectionRecord[] {
131
161
  const [list, setList] = useState<ApiCollectionRecord[]>(() => records);
132
162
  useEffect(() => subscribeApiCollections(() => setList([...records])), []);
@@ -124,3 +124,10 @@ export async function deleteBlueprintLibraryRecord(
124
124
  ): Promise<void> {
125
125
  await runTransaction<undefined>("readwrite", (store) => store.delete(id), nameSpace);
126
126
  }
127
+
128
+ /** 清空该 nameSpace 下的蓝图库,返回删除数量 */
129
+ export async function clearBlueprintLibrary(nameSpace?: string | null): Promise<number> {
130
+ const count = await runTransaction<number>("readonly", (store) => store.count(), nameSpace);
131
+ await runTransaction<undefined>("readwrite", (store) => store.clear(), nameSpace);
132
+ return count;
133
+ }