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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "tauri-kargo-tools",
3
- "version": "0.2.0",
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,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 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";
119
- name:string;
144
+ export type ExplorerArrayFileItem = {
145
+ type:'file'
146
+ name: string;
147
+ /** chemin absolu du fichier */
120
148
  path: string;
121
- parent: string | null;
122
- content: ExplorerElement[];
123
- }
124
-
125
- export interface ExplorerError {
126
- type: "error";
127
- message: string;
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