tauri-kargo-tools 0.2.0 → 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 -18
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,29 +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:
|
|
119
|
-
name:string;
|
|
144
|
+
export type ExplorerArrayFileItem = {
|
|
145
|
+
type:'file'
|
|
146
|
+
name: string;
|
|
147
|
+
/** chemin absolu du fichier */
|
|
120
148
|
path: string;
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
}
|
|
129
|
-
|
|
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
|
+
//
|
|
130
187
|
export interface NewServerReq {
|
|
131
188
|
code: string;
|
|
132
189
|
executable: string;
|
|
@@ -156,10 +213,7 @@ export interface StopServerResp {
|
|
|
156
213
|
========================= */
|
|
157
214
|
|
|
158
215
|
/** Result of /api/explorer (200) */
|
|
159
|
-
export type ExplorerResult = ExplorerFile | ExplorerDirectory;
|
|
160
216
|
|
|
161
|
-
/** Error shapes from /api/explorer (404/500) */
|
|
162
|
-
export type ExplorerErrorResult = ExplorerError;
|
|
163
217
|
|
|
164
218
|
/* =========================
|
|
165
219
|
(Optionnel) Types d’IO par route
|