@appweaver/cli 1.0.14 → 1.0.16
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
|
@@ -445,14 +445,15 @@ const config = {
|
|
|
445
445
|
};
|
|
446
446
|
```
|
|
447
447
|
|
|
448
|
-
| Property
|
|
449
|
-
|
|
450
|
-
| `mimeType`
|
|
451
|
-
| `namePattern`
|
|
452
|
-
| `array`
|
|
453
|
-
| `maxSize`
|
|
454
|
-
| `maxCount`
|
|
455
|
-
| `output`
|
|
448
|
+
| Property | Type | Description |
|
|
449
|
+
|---------------------|------------------------|-------------------------------------------------------------------------------------------------------------|
|
|
450
|
+
| `mimeType` | string \| RegExp | Allowed MIME types (glob patterns like `'image/*'` supported). |
|
|
451
|
+
| `namePattern` | string \| function | File naming pattern or function (available variables are listed below). |
|
|
452
|
+
| `array` | boolean | Allow multiple files. |
|
|
453
|
+
| `maxSize` | number \| string | Maximum file size (e.g. `'2 MB'`, `5242880`). |
|
|
454
|
+
| `maxCount` | number | Maximum number of files (for array fields). |
|
|
455
|
+
| `output` | RelationOutput | When to include file info in output. |
|
|
456
|
+
| `onResourceDeleted` | `'delete'` \| `'keep'` | When the owning resource is deleted. `'delete'` (default) removes files from storage, `'keep'` leaves them. |
|
|
456
457
|
|
|
457
458
|
#### Available namePattern variables
|
|
458
459
|
|
|
@@ -249,3 +249,32 @@ await fileService.deleteFile(
|
|
|
249
249
|
postClient // ResourceClient
|
|
250
250
|
);
|
|
251
251
|
```
|
|
252
|
+
|
|
253
|
+
### Deleting all files on resource deletion
|
|
254
|
+
|
|
255
|
+
When a resource is deleted, files belonging to file fields configured with `onResourceDeleted: 'delete'` can be
|
|
256
|
+
automatically cleaned up. This is handled by `deleteResourceFiles()`, which is called automatically by the framework's
|
|
257
|
+
delete route handler.
|
|
258
|
+
|
|
259
|
+
To enable automatic file cleanup, set `onResourceDeleted: 'delete'` on the file field in your model config:
|
|
260
|
+
|
|
261
|
+
```ts
|
|
262
|
+
const config = {
|
|
263
|
+
files: {
|
|
264
|
+
coverImage: {
|
|
265
|
+
mimeType: 'image/*',
|
|
266
|
+
onResourceDeleted: 'delete' // default: files removed when resource is deleted
|
|
267
|
+
},
|
|
268
|
+
documents: {
|
|
269
|
+
array: true,
|
|
270
|
+
onResourceDeleted: 'keep' // opt out: files are kept
|
|
271
|
+
}
|
|
272
|
+
}
|
|
273
|
+
};
|
|
274
|
+
```
|
|
275
|
+
|
|
276
|
+
You can also call `deleteResourceFiles` manually if needed:
|
|
277
|
+
|
|
278
|
+
```ts
|
|
279
|
+
await fileService.deleteResourceFiles('Post', postId);
|
|
280
|
+
```
|
package/start/start-project.js
CHANGED
|
@@ -114,12 +114,15 @@ async function watchNodeProject(mainFilePath, projectFile) {
|
|
|
114
114
|
*/
|
|
115
115
|
async function watchBunProcess() {
|
|
116
116
|
let abortController;
|
|
117
|
+
let runningProcess;
|
|
117
118
|
let debounceTimer;
|
|
118
119
|
// Starts a new process and aborts the previous one
|
|
119
120
|
async function start() {
|
|
120
121
|
abortController?.abort();
|
|
122
|
+
// Wait for the previous process to fully terminate before starting a new one
|
|
123
|
+
await runningProcess;
|
|
121
124
|
abortController = new AbortController();
|
|
122
|
-
|
|
125
|
+
runningProcess = (0, utils_1.runProcess)('bun', [common_1.config.APP_MAIN_FILE_PATH], {
|
|
123
126
|
signal: abortController.signal
|
|
124
127
|
});
|
|
125
128
|
}
|