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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "tauri-kargo-tools",
3
- "version": "0.1.9",
3
+ "version": "0.2.1",
4
4
  "description": "",
5
5
  "files": ["src"],
6
6
  "exports": { "./*": "./src/*" },
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.ExplorerReq): Promise<T.ExplorerResult> {
189
- return this.postJson<T.ExplorerResult>("/api/explorer", body);
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
@@ -35,7 +35,8 @@ test.test("Test read file", async () => {
35
35
 
36
36
  }), false, "pas dans rep")
37
37
  }
38
-
38
+ rep = await client.explorer( { type:"array" , path:"C:/Users/david/Documents/GitHub/tauriKargoExamples/examples/test-api-file-typescript"})
39
+ console.log(rep)
39
40
 
40
41
 
41
42
 
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 ExplorerElement = ExplorerDirectory | ExplorerFile
112
+ export type ExplorerMode = "array" | "tree";
109
113
 
110
- export interface ExplorerFile {
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 interface ExplorerDirectory {
118
- type: "directory";
144
+ export type ExplorerArrayFileItem = {
145
+ type:'file'
146
+ name: string;
147
+ /** chemin absolu du fichier */
119
148
  path: string;
120
- parent: string | null;
121
- content: ExplorerElement[];
122
- }
123
-
124
- export interface ExplorerError {
125
- type: "error";
126
- message: string;
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