tauri-kargo-tools 0.1.9 → 0.2.1
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/package.json +1 -1
- package/src/api.ts +2 -2
- package/src/test/index.ts +2 -1
- package/src/types.ts +72 -17
package/package.json
CHANGED
package/src/api.ts
CHANGED
|
@@ -185,8 +185,8 @@ async writeFileBinary(
|
|
|
185
185
|
/* =============== Routes: Explorer =============== */
|
|
186
186
|
|
|
187
187
|
/** POST /api/explorer */
|
|
188
|
-
explorer(body: T.
|
|
189
|
-
return this.postJson<T.
|
|
188
|
+
explorer(body: T.ExplorerRequest): Promise<T.ExplorerResponse> {
|
|
189
|
+
return this.postJson<T.ExplorerResponse>("/api/explorer", body);
|
|
190
190
|
}
|
|
191
191
|
|
|
192
192
|
/* =============== Routes: Servers =============== */
|
package/src/test/index.ts
CHANGED
package/src/types.ts
CHANGED
|
@@ -104,28 +104,86 @@ export interface StopAllResp {
|
|
|
104
104
|
export interface ExplorerReq {
|
|
105
105
|
path?: string;
|
|
106
106
|
}
|
|
107
|
+
// api-explorer
|
|
108
|
+
// =====================
|
|
109
|
+
// /api/explorer - types
|
|
110
|
+
// =====================
|
|
107
111
|
|
|
108
|
-
export type
|
|
112
|
+
export type ExplorerMode = "array" | "tree";
|
|
109
113
|
|
|
110
|
-
export
|
|
114
|
+
export type ExplorerRequest = {
|
|
115
|
+
/** vide => CWD côté serveur ; relatif => CWD+rel ; absolu => tel quel */
|
|
116
|
+
path?: string;
|
|
117
|
+
|
|
118
|
+
/** "array" => content = fichiers à plat ; "tree" => content = arborescence */
|
|
119
|
+
type?: ExplorerMode;
|
|
120
|
+
|
|
121
|
+
/** profondeur max (enfants directs = 1). Si absent et type absent => default serveur: 1 */
|
|
122
|
+
maxDeep?: number;
|
|
123
|
+
|
|
124
|
+
/** nombre max de fichiers retournés (limite globale) */
|
|
125
|
+
maxSize?: number;
|
|
126
|
+
};
|
|
127
|
+
|
|
128
|
+
// ---- réponses ----
|
|
129
|
+
|
|
130
|
+
export type ExplorerErrorResponse = {
|
|
131
|
+
type: "error";
|
|
132
|
+
message: string;
|
|
133
|
+
};
|
|
134
|
+
|
|
135
|
+
export type ExplorerFileResponse = {
|
|
111
136
|
type: "file";
|
|
137
|
+
/** chemin absolu (format "joli" Windows/UNC si applicable) */
|
|
112
138
|
path: string;
|
|
113
139
|
name: string;
|
|
140
|
+
/** chemin absolu du parent ou null si racine */
|
|
114
141
|
parent: string | null;
|
|
115
|
-
}
|
|
142
|
+
};
|
|
116
143
|
|
|
117
|
-
export
|
|
118
|
-
type:
|
|
144
|
+
export type ExplorerArrayFileItem = {
|
|
145
|
+
type:'file'
|
|
146
|
+
name: string;
|
|
147
|
+
/** chemin absolu du fichier */
|
|
119
148
|
path: string;
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
}
|
|
128
|
-
|
|
149
|
+
};
|
|
150
|
+
|
|
151
|
+
export type ExplorerTreeItem =
|
|
152
|
+
| {
|
|
153
|
+
type: "file";
|
|
154
|
+
name: string;
|
|
155
|
+
path: string; // absolu
|
|
156
|
+
}
|
|
157
|
+
| {
|
|
158
|
+
type: "directory";
|
|
159
|
+
name: string;
|
|
160
|
+
path: string; // absolu
|
|
161
|
+
/** peut être absent si maxDeep empêche d'expand */
|
|
162
|
+
content?: ExplorerTreeItem[];
|
|
163
|
+
};
|
|
164
|
+
|
|
165
|
+
export type ExplorerDirectoryResponse =
|
|
166
|
+
| {
|
|
167
|
+
type: "directory";
|
|
168
|
+
path: string; // absolu
|
|
169
|
+
parent: string | null;
|
|
170
|
+
/** si request.type === "array" */
|
|
171
|
+
content: ExplorerArrayFileItem[];
|
|
172
|
+
}
|
|
173
|
+
| {
|
|
174
|
+
type: "directory";
|
|
175
|
+
path: string; // absolu
|
|
176
|
+
parent: string | null;
|
|
177
|
+
/** si request.type === "tree" (ou mode absent côté compat) */
|
|
178
|
+
content: ExplorerTreeItem[];
|
|
179
|
+
};
|
|
180
|
+
|
|
181
|
+
export type ExplorerResponse =
|
|
182
|
+
| ExplorerErrorResponse
|
|
183
|
+
| ExplorerFileResponse
|
|
184
|
+
| ExplorerDirectoryResponse;
|
|
185
|
+
|
|
186
|
+
//
|
|
129
187
|
export interface NewServerReq {
|
|
130
188
|
code: string;
|
|
131
189
|
executable: string;
|
|
@@ -155,10 +213,7 @@ export interface StopServerResp {
|
|
|
155
213
|
========================= */
|
|
156
214
|
|
|
157
215
|
/** Result of /api/explorer (200) */
|
|
158
|
-
export type ExplorerResult = ExplorerFile | ExplorerDirectory;
|
|
159
216
|
|
|
160
|
-
/** Error shapes from /api/explorer (404/500) */
|
|
161
|
-
export type ExplorerErrorResult = ExplorerError;
|
|
162
217
|
|
|
163
218
|
/* =========================
|
|
164
219
|
(Optionnel) Types d’IO par route
|