@shiftengineering/folio 0.1.5 → 0.1.7
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
|
@@ -26,7 +26,7 @@ This package exports three main features:
|
|
|
26
26
|
- `useFolioFiles` - Get files for a project
|
|
27
27
|
- `useAddFolioProject` - Create new projects
|
|
28
28
|
- `useAddFolioFiles` - Add files to a project
|
|
29
|
-
- `
|
|
29
|
+
- `useAddFolioDirectoriesWithFiles` - Add directories with files to a project
|
|
30
30
|
|
|
31
31
|
### Basic Setup
|
|
32
32
|
|
|
@@ -79,8 +79,9 @@ import {
|
|
|
79
79
|
useFolioFiles,
|
|
80
80
|
useAddFolioProject,
|
|
81
81
|
useAddFolioFiles,
|
|
82
|
-
|
|
82
|
+
useAddFolioDirectoriesWithFiles,
|
|
83
83
|
type DirectoryEntry,
|
|
84
|
+
type MetadataValue,
|
|
84
85
|
} from "@shiftengineering/folio";
|
|
85
86
|
import { useState } from "react";
|
|
86
87
|
|
|
@@ -105,8 +106,8 @@ function FolioProjectManager() {
|
|
|
105
106
|
useAddFolioFiles(selectedProjectId);
|
|
106
107
|
|
|
107
108
|
// Add directories with files to a project
|
|
108
|
-
const {
|
|
109
|
-
|
|
109
|
+
const { addDirectoriesWithFiles, isAdding: isAddingDirectory } =
|
|
110
|
+
useAddFolioDirectoriesWithFiles(selectedProjectId);
|
|
110
111
|
|
|
111
112
|
const handleCreateProject = () => {
|
|
112
113
|
addProject("My New Project");
|
|
@@ -117,10 +118,18 @@ function FolioProjectManager() {
|
|
|
117
118
|
};
|
|
118
119
|
|
|
119
120
|
const handleAddSingleDirectory = () => {
|
|
120
|
-
// Create metadata
|
|
121
|
+
// Create metadata with nested structure
|
|
121
122
|
const metadata = {
|
|
122
123
|
category: "reports",
|
|
123
|
-
|
|
124
|
+
details: {
|
|
125
|
+
owner: "John Doe",
|
|
126
|
+
department: "Finance",
|
|
127
|
+
tags: ["important", "quarterly"],
|
|
128
|
+
},
|
|
129
|
+
status: {
|
|
130
|
+
reviewed: true,
|
|
131
|
+
approvalDate: "2023-10-15"
|
|
132
|
+
}
|
|
124
133
|
};
|
|
125
134
|
|
|
126
135
|
const directoryEntry: DirectoryEntry = {
|
|
@@ -132,17 +141,31 @@ function FolioProjectManager() {
|
|
|
132
141
|
],
|
|
133
142
|
};
|
|
134
143
|
|
|
135
|
-
|
|
144
|
+
addDirectoriesWithFiles(directoryEntry);
|
|
136
145
|
};
|
|
137
146
|
|
|
138
147
|
const handleAddMultipleDirectories = () => {
|
|
139
|
-
// Create metadata for each directory
|
|
148
|
+
// Create metadata for each directory with nested structures
|
|
140
149
|
const metadata1 = {
|
|
141
|
-
category: "reports"
|
|
150
|
+
category: "reports",
|
|
151
|
+
details: {
|
|
152
|
+
owner: "Jane Smith",
|
|
153
|
+
department: "Accounting",
|
|
154
|
+
tags: ["quarterly", "financial"]
|
|
155
|
+
}
|
|
142
156
|
};
|
|
143
157
|
|
|
144
158
|
const metadata2 = {
|
|
145
|
-
category: "contracts"
|
|
159
|
+
category: "contracts",
|
|
160
|
+
details: {
|
|
161
|
+
owner: "Legal Team",
|
|
162
|
+
priority: "high",
|
|
163
|
+
clients: ["Acme Inc", "Globex Corp"]
|
|
164
|
+
},
|
|
165
|
+
approvalChain: {
|
|
166
|
+
legalApproved: true,
|
|
167
|
+
executiveApproved: false
|
|
168
|
+
}
|
|
146
169
|
};
|
|
147
170
|
|
|
148
171
|
const directories: DirectoryEntry[] = [
|
|
@@ -164,7 +187,7 @@ function FolioProjectManager() {
|
|
|
164
187
|
},
|
|
165
188
|
];
|
|
166
189
|
|
|
167
|
-
|
|
190
|
+
addDirectoriesWithFiles(directories);
|
|
168
191
|
};
|
|
169
192
|
|
|
170
193
|
if (isProjectsLoading) return <div>Loading projects...</div>;
|
|
@@ -297,31 +320,30 @@ Hook for adding files to a project. Files are always created at the root level (
|
|
|
297
320
|
| `error` | `Error \| null` | Error object if an error occurred |
|
|
298
321
|
| `newFiles` | `FolioFile[] \| undefined` | The newly added files if available |
|
|
299
322
|
|
|
300
|
-
#### `
|
|
323
|
+
#### `useAddFolioDirectoriesWithFiles(projectId?: number)`
|
|
301
324
|
|
|
302
325
|
Hook for adding one or more directories with files to a project. Directory names must be unique at the root level (duplicates will be silently skipped with a console warning).
|
|
303
326
|
|
|
304
|
-
| Return Property
|
|
305
|
-
|
|
|
306
|
-
| `
|
|
307
|
-
| `
|
|
308
|
-
| `isAdding`
|
|
309
|
-
| `isError`
|
|
310
|
-
| `error`
|
|
311
|
-
| `result`
|
|
327
|
+
| Return Property | Type | Description |
|
|
328
|
+
| ------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------ |
|
|
329
|
+
| `addDirectoriesWithFiles` | `(params: DirectoryEntry \| DirectoryEntry[]) => void` | Function to add one or more directories with files |
|
|
330
|
+
| `addDirectoriesWithFilesAsync` | `(params: DirectoryEntry \| DirectoryEntry[]) => Promise<{ directory: FolioFile \| null; files: FolioFile[] } \| Array<{ directory: FolioFile \| null; files: FolioFile[] }>>` | Async version returning a promise. Returns a single result when given a single directory, or an array of results when given multiple directories |
|
|
331
|
+
| `isAdding` | `boolean` | Whether the directories and files are being added |
|
|
332
|
+
| `isError` | `boolean` | Whether an error occurred |
|
|
333
|
+
| `error` | `Error \| null` | Error object if an error occurred |
|
|
334
|
+
| `result` | `{ directory: FolioFile \| null; files: FolioFile[] } \| Array<{ directory: FolioFile \| null; files: FolioFile[] }> \| undefined` | The newly added directories and files. If a directory is null in a result, it means a directory with that name already existed |
|
|
312
335
|
|
|
313
336
|
## Types
|
|
314
337
|
|
|
315
338
|
The library exports these TypeScript types:
|
|
316
339
|
|
|
317
|
-
| Type | Description
|
|
318
|
-
| -------------------- |
|
|
319
|
-
| `FolioFile` | Represents a file in Folio. Contains properties: `id`, `name`, `blobUrl`, `parentId` (null for root items), and `isDirectory` (boolean)
|
|
320
|
-
| `FolioProject` | Represents a project in Folio
|
|
321
|
-
| `
|
|
322
|
-
| `
|
|
323
|
-
| `
|
|
340
|
+
| Type | Description |
|
|
341
|
+
| -------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
342
|
+
| `FolioFile` | Represents a file in Folio. Contains properties: `id`, `name`, `blobUrl`, `parentId` (null for root items), and `isDirectory` (boolean) |
|
|
343
|
+
| `FolioProject` | Represents a project in Folio |
|
|
344
|
+
| `MetadataValue` | Represents metadata values that can be nested. Can be a string, number, boolean, null, object, or array of these types |
|
|
345
|
+
| `DirectoryEntry` | Represents a directory with metadata and files to be added to Folio. Contains properties: `directoryName`, `directoryMetadata` (now supports nested objects), and `files` |
|
|
346
|
+
| `FolioEmbedProps` | Props for the FolioEmbed component |
|
|
347
|
+
| `FolioProviderProps` | Props for the FolioProvider component |
|
|
324
348
|
|
|
325
349
|
## License
|
|
326
|
-
|
|
327
|
-
[YOUR LICENSE HERE]
|