@btst/stack 2.11.0 → 2.11.2
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/dist/packages/stack/src/plugins/blog/api/mutations.cjs +170 -0
- package/dist/packages/stack/src/plugins/blog/api/mutations.mjs +166 -0
- package/dist/packages/stack/src/plugins/blog/api/plugin.cjs +34 -157
- package/dist/packages/stack/src/plugins/blog/api/plugin.mjs +40 -163
- package/dist/packages/stack/src/plugins/media/api/plugin.cjs +4 -1
- package/dist/packages/stack/src/plugins/media/api/plugin.mjs +5 -2
- package/dist/plugins/blog/api/index.cjs +4 -0
- package/dist/plugins/blog/api/index.d.cts +2 -2
- package/dist/plugins/blog/api/index.d.mts +2 -2
- package/dist/plugins/blog/api/index.d.ts +2 -2
- package/dist/plugins/blog/api/index.mjs +1 -0
- package/dist/plugins/blog/client/hooks/index.d.cts +2 -2
- package/dist/plugins/blog/client/hooks/index.d.mts +2 -2
- package/dist/plugins/blog/client/hooks/index.d.ts +2 -2
- package/dist/plugins/blog/client/index.d.cts +2 -2
- package/dist/plugins/blog/client/index.d.mts +2 -2
- package/dist/plugins/blog/client/index.d.ts +2 -2
- package/dist/plugins/blog/query-keys.d.cts +2 -2
- package/dist/plugins/blog/query-keys.d.mts +2 -2
- package/dist/plugins/blog/query-keys.d.ts +2 -2
- package/dist/plugins/kanban/api/index.d.cts +1 -1
- package/dist/plugins/kanban/api/index.d.mts +1 -1
- package/dist/plugins/kanban/api/index.d.ts +1 -1
- package/dist/plugins/kanban/query-keys.d.cts +1 -1
- package/dist/plugins/kanban/query-keys.d.mts +1 -1
- package/dist/plugins/kanban/query-keys.d.ts +1 -1
- package/dist/{packages/stack/src/plugins → plugins}/media/api/adapters/local.cjs +7 -1
- package/dist/plugins/media/api/adapters/local.d.cts +30 -0
- package/dist/plugins/media/api/adapters/local.d.mts +30 -0
- package/dist/plugins/media/api/adapters/local.d.ts +30 -0
- package/dist/{packages/stack/src/plugins → plugins}/media/api/adapters/local.mjs +7 -1
- package/dist/plugins/media/api/adapters/s3.d.cts +1 -1
- package/dist/plugins/media/api/adapters/s3.d.mts +1 -1
- package/dist/plugins/media/api/adapters/s3.d.ts +1 -1
- package/dist/plugins/media/api/adapters/vercel-blob.d.cts +1 -1
- package/dist/plugins/media/api/adapters/vercel-blob.d.mts +1 -1
- package/dist/plugins/media/api/adapters/vercel-blob.d.ts +1 -1
- package/dist/plugins/media/api/index.cjs +0 -2
- package/dist/plugins/media/api/index.d.cts +5 -102
- package/dist/plugins/media/api/index.d.mts +5 -102
- package/dist/plugins/media/api/index.d.ts +5 -102
- package/dist/plugins/media/api/index.mjs +0 -1
- package/dist/plugins/media/query-keys.d.cts +2 -2
- package/dist/plugins/media/query-keys.d.mts +2 -2
- package/dist/plugins/media/query-keys.d.ts +2 -2
- package/dist/shared/{stack.Bci0-plK.d.ts → stack.C5ucdatf.d.ts} +76 -3
- package/dist/shared/{stack.D7HSzZdG.d.ts → stack.D0p6oNme.d.ts} +90 -7
- package/dist/shared/{stack.6mEHS2WH.d.mts → stack.DOZ1EXjM.d.mts} +3 -3
- package/dist/shared/{stack.IUeyQKrm.d.mts → stack.DWipT53I.d.cts} +90 -7
- package/dist/shared/{stack.AJTXI7kw.d.cts → stack.DX-tQ93o.d.cts} +3 -3
- package/dist/shared/{stack.C_MUwwgR.d.mts → stack.DpZoZd98.d.mts} +76 -3
- package/dist/shared/{stack.DjgpFWq3.d.cts → stack.E17kSK1W.d.mts} +90 -7
- package/dist/shared/{stack.QYn-Px94.d.ts → stack.VF6FhyZw.d.ts} +3 -3
- package/dist/shared/{stack.DO6vOGQG.d.cts → stack.lkebw2nj.d.cts} +1 -1
- package/dist/shared/{stack.DO6vOGQG.d.mts → stack.lkebw2nj.d.mts} +1 -1
- package/dist/shared/{stack.DO6vOGQG.d.ts → stack.lkebw2nj.d.ts} +1 -1
- package/dist/shared/{stack.D6zyQnMo.d.cts → stack.vVFh38aS.d.cts} +76 -3
- package/package.json +14 -1
- package/src/plugins/blog/api/index.ts +7 -0
- package/src/plugins/blog/api/mutations.ts +287 -0
- package/src/plugins/blog/api/plugin.ts +43 -184
- package/src/plugins/media/__tests__/storage-adapters.test.ts +11 -0
- package/src/plugins/media/api/adapters/local.ts +10 -1
- package/src/plugins/media/api/index.ts +0 -5
- package/src/plugins/media/api/plugin.ts +6 -0
- package/dist/shared/{stack.eq5eg1yt.d.cts → stack.B6S3cgwN.d.cts} +6 -6
- package/dist/shared/{stack.BQmuNl5p.d.ts → stack.BWp0hcm9.d.cts} +3 -3
- package/dist/shared/{stack.BQmuNl5p.d.cts → stack.BWp0hcm9.d.mts} +3 -3
- package/dist/shared/{stack.BQmuNl5p.d.mts → stack.BWp0hcm9.d.ts} +3 -3
- package/dist/shared/{stack.Dj04W2c3.d.mts → stack.Bzfx-_lq.d.mts} +6 -6
- package/dist/shared/{stack.CMbX8Q5C.d.ts → stack.j5SFLC1d.d.ts} +6 -6
|
@@ -22,7 +22,13 @@ function localAdapter(options = {}) {
|
|
|
22
22
|
const encodedFilename = url.split("/").pop();
|
|
23
23
|
if (!encodedFilename) return;
|
|
24
24
|
const filename = decodeURIComponent(encodedFilename);
|
|
25
|
-
const
|
|
25
|
+
const resolvedUploadDir = path.resolve(uploadDir);
|
|
26
|
+
const filePath = path.join(resolvedUploadDir, filename);
|
|
27
|
+
if (!filePath.startsWith(resolvedUploadDir + path.sep)) {
|
|
28
|
+
throw new Error(
|
|
29
|
+
`Refusing to delete file outside upload directory: ${filePath}`
|
|
30
|
+
);
|
|
31
|
+
}
|
|
26
32
|
try {
|
|
27
33
|
await fs.unlink(filePath);
|
|
28
34
|
} catch (err) {
|
|
@@ -5,7 +5,6 @@ const getters = require('../../../packages/stack/src/plugins/media/api/getters.c
|
|
|
5
5
|
const mutations = require('../../../packages/stack/src/plugins/media/api/mutations.cjs');
|
|
6
6
|
const serializers = require('../../../packages/stack/src/plugins/media/api/serializers.cjs');
|
|
7
7
|
const queryKeyDefs = require('../../../packages/stack/src/plugins/media/api/query-key-defs.cjs');
|
|
8
|
-
const local = require('../../../packages/stack/src/plugins/media/api/adapters/local.cjs');
|
|
9
8
|
|
|
10
9
|
|
|
11
10
|
|
|
@@ -24,4 +23,3 @@ exports.serializeAsset = serializers.serializeAsset;
|
|
|
24
23
|
exports.serializeFolder = serializers.serializeFolder;
|
|
25
24
|
exports.MEDIA_QUERY_KEYS = queryKeyDefs.MEDIA_QUERY_KEYS;
|
|
26
25
|
exports.assetListDiscriminator = queryKeyDefs.assetListDiscriminator;
|
|
27
|
-
exports.localAdapter = local.localAdapter;
|
|
@@ -1,81 +1,11 @@
|
|
|
1
|
-
export {
|
|
1
|
+
export { C as CreateAssetInput, e as CreateFolderInput, M as MEDIA_QUERY_KEYS, g as MediaApiContext, j as MediaApiRouter, i as MediaBackendConfig, h as MediaBackendHooks, U as UpdateAssetInput, f as assetListDiscriminator, c as createAsset, a as createFolder, d as deleteAsset, b as deleteFolder, m as mediaBackendPlugin, u as updateAsset } from '../../../shared/stack.vVFh38aS.cjs';
|
|
2
2
|
export { A as AssetListParams, d as AssetListResult, F as FolderListParams, g as getAssetById, b as getFolderById, c as getFolderByName, l as listAssets, a as listFolders } from '../../../shared/stack.jU2iG86n.cjs';
|
|
3
|
-
import {
|
|
4
|
-
|
|
5
|
-
import { D as DirectStorageAdapter } from '../../../shared/stack.DO6vOGQG.cjs';
|
|
6
|
-
export { S as S3StorageAdapter, b as S3UploadToken, a as StorageAdapter, U as UploadOptions, c as VercelBlobHandlerCallbacks, V as VercelBlobStorageAdapter } from '../../../shared/stack.DO6vOGQG.cjs';
|
|
3
|
+
import { A as Asset, S as SerializedAsset, F as Folder, a as SerializedFolder } from '../../../shared/stack.BMlLOMED.cjs';
|
|
4
|
+
export { D as DirectStorageAdapter, a as S3StorageAdapter, b as S3UploadToken, S as StorageAdapter, U as UploadOptions, c as VercelBlobHandlerCallbacks, V as VercelBlobStorageAdapter } from '../../../shared/stack.lkebw2nj.cjs';
|
|
7
5
|
import '@btst/stack/plugins/api';
|
|
8
6
|
import 'better-call';
|
|
9
7
|
import 'zod';
|
|
10
|
-
|
|
11
|
-
/**
|
|
12
|
-
* Input for creating a new asset record.
|
|
13
|
-
*/
|
|
14
|
-
interface CreateAssetInput {
|
|
15
|
-
filename: string;
|
|
16
|
-
originalName: string;
|
|
17
|
-
mimeType: string;
|
|
18
|
-
size: number;
|
|
19
|
-
url: string;
|
|
20
|
-
folderId?: string;
|
|
21
|
-
alt?: string;
|
|
22
|
-
tenantId?: string;
|
|
23
|
-
}
|
|
24
|
-
/**
|
|
25
|
-
* Input for updating an existing asset record.
|
|
26
|
-
*/
|
|
27
|
-
interface UpdateAssetInput {
|
|
28
|
-
alt?: string;
|
|
29
|
-
folderId?: string | null;
|
|
30
|
-
}
|
|
31
|
-
/**
|
|
32
|
-
* Input for creating a new folder.
|
|
33
|
-
*/
|
|
34
|
-
interface CreateFolderInput {
|
|
35
|
-
name: string;
|
|
36
|
-
parentId?: string;
|
|
37
|
-
tenantId?: string;
|
|
38
|
-
}
|
|
39
|
-
/**
|
|
40
|
-
* Create an asset record in the database.
|
|
41
|
-
* Pure DB function — no authorization hooks, no HTTP context.
|
|
42
|
-
*
|
|
43
|
-
* @remarks **Security:** No authorization hooks (e.g. `onBeforeUpload`) are called.
|
|
44
|
-
* The caller is responsible for any access-control checks before invoking this function.
|
|
45
|
-
*/
|
|
46
|
-
declare function createAsset(adapter: DBAdapter, input: CreateAssetInput): Promise<Asset>;
|
|
47
|
-
/**
|
|
48
|
-
* Update an asset's `alt` text or `folderId`.
|
|
49
|
-
* Pure DB function — no authorization hooks, no HTTP context.
|
|
50
|
-
*
|
|
51
|
-
* @remarks **Security:** No authorization hooks are called.
|
|
52
|
-
*/
|
|
53
|
-
declare function updateAsset(adapter: DBAdapter, id: string, input: UpdateAssetInput): Promise<Asset | null>;
|
|
54
|
-
/**
|
|
55
|
-
* Delete an asset record from the database by its ID.
|
|
56
|
-
* Does NOT delete the underlying file — the caller must do that via the storage adapter.
|
|
57
|
-
* Pure DB function — no authorization hooks, no HTTP context.
|
|
58
|
-
*
|
|
59
|
-
* @remarks **Security:** No authorization hooks are called.
|
|
60
|
-
*/
|
|
61
|
-
declare function deleteAsset(adapter: DBAdapter, id: string): Promise<void>;
|
|
62
|
-
/**
|
|
63
|
-
* Create a folder record in the database.
|
|
64
|
-
* Pure DB function — no authorization hooks, no HTTP context.
|
|
65
|
-
*
|
|
66
|
-
* @remarks **Security:** No authorization hooks are called.
|
|
67
|
-
*/
|
|
68
|
-
declare function createFolder(adapter: DBAdapter, input: CreateFolderInput): Promise<Folder>;
|
|
69
|
-
/**
|
|
70
|
-
* Delete a folder record from the database by its ID.
|
|
71
|
-
* Child folders are cascade-deleted automatically. Throws if the folder or
|
|
72
|
-
* any of its descendants contain assets (which have associated storage files
|
|
73
|
-
* that must be deleted via the storage adapter first).
|
|
74
|
-
* Pure DB function — no authorization hooks, no HTTP context.
|
|
75
|
-
*
|
|
76
|
-
* @remarks **Security:** No authorization hooks are called.
|
|
77
|
-
*/
|
|
78
|
-
declare function deleteFolder(adapter: DBAdapter, id: string): Promise<void>;
|
|
8
|
+
import '@btst/db';
|
|
79
9
|
|
|
80
10
|
/**
|
|
81
11
|
* Serialize an Asset for SSR/SSG use (convert dates to strings).
|
|
@@ -88,31 +18,4 @@ declare function serializeAsset(asset: Asset): SerializedAsset;
|
|
|
88
18
|
*/
|
|
89
19
|
declare function serializeFolder(folder: Folder): SerializedFolder;
|
|
90
20
|
|
|
91
|
-
|
|
92
|
-
/**
|
|
93
|
-
* Absolute path to the directory where uploaded files are stored.
|
|
94
|
-
* @default "./public/uploads"
|
|
95
|
-
*/
|
|
96
|
-
uploadDir?: string;
|
|
97
|
-
/**
|
|
98
|
-
* URL prefix used to build the public URL for uploaded files.
|
|
99
|
-
* @default "/uploads"
|
|
100
|
-
*/
|
|
101
|
-
publicPath?: string;
|
|
102
|
-
}
|
|
103
|
-
/**
|
|
104
|
-
* Create a local filesystem storage adapter.
|
|
105
|
-
* Files are written to `uploadDir` and served at `publicPath`.
|
|
106
|
-
* Suitable for development and self-hosted deployments.
|
|
107
|
-
*
|
|
108
|
-
* @example
|
|
109
|
-
* ```ts
|
|
110
|
-
* mediaBackendPlugin({
|
|
111
|
-
* storageAdapter: localAdapter({ uploadDir: "./public/uploads", publicPath: "/uploads" })
|
|
112
|
-
* })
|
|
113
|
-
* ```
|
|
114
|
-
*/
|
|
115
|
-
declare function localAdapter(options?: LocalStorageAdapterOptions): DirectStorageAdapter;
|
|
116
|
-
|
|
117
|
-
export { DirectStorageAdapter, createAsset, createFolder, deleteAsset, deleteFolder, localAdapter, serializeAsset, serializeFolder, updateAsset };
|
|
118
|
-
export type { CreateAssetInput, CreateFolderInput, LocalStorageAdapterOptions, UpdateAssetInput };
|
|
21
|
+
export { serializeAsset, serializeFolder };
|
|
@@ -1,81 +1,11 @@
|
|
|
1
|
-
export {
|
|
1
|
+
export { C as CreateAssetInput, e as CreateFolderInput, M as MEDIA_QUERY_KEYS, g as MediaApiContext, j as MediaApiRouter, i as MediaBackendConfig, h as MediaBackendHooks, U as UpdateAssetInput, f as assetListDiscriminator, c as createAsset, a as createFolder, d as deleteAsset, b as deleteFolder, m as mediaBackendPlugin, u as updateAsset } from '../../../shared/stack.DpZoZd98.mjs';
|
|
2
2
|
export { A as AssetListParams, d as AssetListResult, F as FolderListParams, g as getAssetById, b as getFolderById, c as getFolderByName, l as listAssets, a as listFolders } from '../../../shared/stack.C7u9lq9T.mjs';
|
|
3
|
-
import {
|
|
4
|
-
|
|
5
|
-
import { D as DirectStorageAdapter } from '../../../shared/stack.DO6vOGQG.mjs';
|
|
6
|
-
export { S as S3StorageAdapter, b as S3UploadToken, a as StorageAdapter, U as UploadOptions, c as VercelBlobHandlerCallbacks, V as VercelBlobStorageAdapter } from '../../../shared/stack.DO6vOGQG.mjs';
|
|
3
|
+
import { A as Asset, S as SerializedAsset, F as Folder, a as SerializedFolder } from '../../../shared/stack.BMlLOMED.mjs';
|
|
4
|
+
export { D as DirectStorageAdapter, a as S3StorageAdapter, b as S3UploadToken, S as StorageAdapter, U as UploadOptions, c as VercelBlobHandlerCallbacks, V as VercelBlobStorageAdapter } from '../../../shared/stack.lkebw2nj.mjs';
|
|
7
5
|
import '@btst/stack/plugins/api';
|
|
8
6
|
import 'better-call';
|
|
9
7
|
import 'zod';
|
|
10
|
-
|
|
11
|
-
/**
|
|
12
|
-
* Input for creating a new asset record.
|
|
13
|
-
*/
|
|
14
|
-
interface CreateAssetInput {
|
|
15
|
-
filename: string;
|
|
16
|
-
originalName: string;
|
|
17
|
-
mimeType: string;
|
|
18
|
-
size: number;
|
|
19
|
-
url: string;
|
|
20
|
-
folderId?: string;
|
|
21
|
-
alt?: string;
|
|
22
|
-
tenantId?: string;
|
|
23
|
-
}
|
|
24
|
-
/**
|
|
25
|
-
* Input for updating an existing asset record.
|
|
26
|
-
*/
|
|
27
|
-
interface UpdateAssetInput {
|
|
28
|
-
alt?: string;
|
|
29
|
-
folderId?: string | null;
|
|
30
|
-
}
|
|
31
|
-
/**
|
|
32
|
-
* Input for creating a new folder.
|
|
33
|
-
*/
|
|
34
|
-
interface CreateFolderInput {
|
|
35
|
-
name: string;
|
|
36
|
-
parentId?: string;
|
|
37
|
-
tenantId?: string;
|
|
38
|
-
}
|
|
39
|
-
/**
|
|
40
|
-
* Create an asset record in the database.
|
|
41
|
-
* Pure DB function — no authorization hooks, no HTTP context.
|
|
42
|
-
*
|
|
43
|
-
* @remarks **Security:** No authorization hooks (e.g. `onBeforeUpload`) are called.
|
|
44
|
-
* The caller is responsible for any access-control checks before invoking this function.
|
|
45
|
-
*/
|
|
46
|
-
declare function createAsset(adapter: DBAdapter, input: CreateAssetInput): Promise<Asset>;
|
|
47
|
-
/**
|
|
48
|
-
* Update an asset's `alt` text or `folderId`.
|
|
49
|
-
* Pure DB function — no authorization hooks, no HTTP context.
|
|
50
|
-
*
|
|
51
|
-
* @remarks **Security:** No authorization hooks are called.
|
|
52
|
-
*/
|
|
53
|
-
declare function updateAsset(adapter: DBAdapter, id: string, input: UpdateAssetInput): Promise<Asset | null>;
|
|
54
|
-
/**
|
|
55
|
-
* Delete an asset record from the database by its ID.
|
|
56
|
-
* Does NOT delete the underlying file — the caller must do that via the storage adapter.
|
|
57
|
-
* Pure DB function — no authorization hooks, no HTTP context.
|
|
58
|
-
*
|
|
59
|
-
* @remarks **Security:** No authorization hooks are called.
|
|
60
|
-
*/
|
|
61
|
-
declare function deleteAsset(adapter: DBAdapter, id: string): Promise<void>;
|
|
62
|
-
/**
|
|
63
|
-
* Create a folder record in the database.
|
|
64
|
-
* Pure DB function — no authorization hooks, no HTTP context.
|
|
65
|
-
*
|
|
66
|
-
* @remarks **Security:** No authorization hooks are called.
|
|
67
|
-
*/
|
|
68
|
-
declare function createFolder(adapter: DBAdapter, input: CreateFolderInput): Promise<Folder>;
|
|
69
|
-
/**
|
|
70
|
-
* Delete a folder record from the database by its ID.
|
|
71
|
-
* Child folders are cascade-deleted automatically. Throws if the folder or
|
|
72
|
-
* any of its descendants contain assets (which have associated storage files
|
|
73
|
-
* that must be deleted via the storage adapter first).
|
|
74
|
-
* Pure DB function — no authorization hooks, no HTTP context.
|
|
75
|
-
*
|
|
76
|
-
* @remarks **Security:** No authorization hooks are called.
|
|
77
|
-
*/
|
|
78
|
-
declare function deleteFolder(adapter: DBAdapter, id: string): Promise<void>;
|
|
8
|
+
import '@btst/db';
|
|
79
9
|
|
|
80
10
|
/**
|
|
81
11
|
* Serialize an Asset for SSR/SSG use (convert dates to strings).
|
|
@@ -88,31 +18,4 @@ declare function serializeAsset(asset: Asset): SerializedAsset;
|
|
|
88
18
|
*/
|
|
89
19
|
declare function serializeFolder(folder: Folder): SerializedFolder;
|
|
90
20
|
|
|
91
|
-
|
|
92
|
-
/**
|
|
93
|
-
* Absolute path to the directory where uploaded files are stored.
|
|
94
|
-
* @default "./public/uploads"
|
|
95
|
-
*/
|
|
96
|
-
uploadDir?: string;
|
|
97
|
-
/**
|
|
98
|
-
* URL prefix used to build the public URL for uploaded files.
|
|
99
|
-
* @default "/uploads"
|
|
100
|
-
*/
|
|
101
|
-
publicPath?: string;
|
|
102
|
-
}
|
|
103
|
-
/**
|
|
104
|
-
* Create a local filesystem storage adapter.
|
|
105
|
-
* Files are written to `uploadDir` and served at `publicPath`.
|
|
106
|
-
* Suitable for development and self-hosted deployments.
|
|
107
|
-
*
|
|
108
|
-
* @example
|
|
109
|
-
* ```ts
|
|
110
|
-
* mediaBackendPlugin({
|
|
111
|
-
* storageAdapter: localAdapter({ uploadDir: "./public/uploads", publicPath: "/uploads" })
|
|
112
|
-
* })
|
|
113
|
-
* ```
|
|
114
|
-
*/
|
|
115
|
-
declare function localAdapter(options?: LocalStorageAdapterOptions): DirectStorageAdapter;
|
|
116
|
-
|
|
117
|
-
export { DirectStorageAdapter, createAsset, createFolder, deleteAsset, deleteFolder, localAdapter, serializeAsset, serializeFolder, updateAsset };
|
|
118
|
-
export type { CreateAssetInput, CreateFolderInput, LocalStorageAdapterOptions, UpdateAssetInput };
|
|
21
|
+
export { serializeAsset, serializeFolder };
|
|
@@ -1,81 +1,11 @@
|
|
|
1
|
-
export {
|
|
1
|
+
export { C as CreateAssetInput, e as CreateFolderInput, M as MEDIA_QUERY_KEYS, g as MediaApiContext, j as MediaApiRouter, i as MediaBackendConfig, h as MediaBackendHooks, U as UpdateAssetInput, f as assetListDiscriminator, c as createAsset, a as createFolder, d as deleteAsset, b as deleteFolder, m as mediaBackendPlugin, u as updateAsset } from '../../../shared/stack.C5ucdatf.js';
|
|
2
2
|
export { A as AssetListParams, d as AssetListResult, F as FolderListParams, g as getAssetById, b as getFolderById, c as getFolderByName, l as listAssets, a as listFolders } from '../../../shared/stack.DD-ZORI7.js';
|
|
3
|
-
import {
|
|
4
|
-
|
|
5
|
-
import { D as DirectStorageAdapter } from '../../../shared/stack.DO6vOGQG.js';
|
|
6
|
-
export { S as S3StorageAdapter, b as S3UploadToken, a as StorageAdapter, U as UploadOptions, c as VercelBlobHandlerCallbacks, V as VercelBlobStorageAdapter } from '../../../shared/stack.DO6vOGQG.js';
|
|
3
|
+
import { A as Asset, S as SerializedAsset, F as Folder, a as SerializedFolder } from '../../../shared/stack.BMlLOMED.js';
|
|
4
|
+
export { D as DirectStorageAdapter, a as S3StorageAdapter, b as S3UploadToken, S as StorageAdapter, U as UploadOptions, c as VercelBlobHandlerCallbacks, V as VercelBlobStorageAdapter } from '../../../shared/stack.lkebw2nj.js';
|
|
7
5
|
import '@btst/stack/plugins/api';
|
|
8
6
|
import 'better-call';
|
|
9
7
|
import 'zod';
|
|
10
|
-
|
|
11
|
-
/**
|
|
12
|
-
* Input for creating a new asset record.
|
|
13
|
-
*/
|
|
14
|
-
interface CreateAssetInput {
|
|
15
|
-
filename: string;
|
|
16
|
-
originalName: string;
|
|
17
|
-
mimeType: string;
|
|
18
|
-
size: number;
|
|
19
|
-
url: string;
|
|
20
|
-
folderId?: string;
|
|
21
|
-
alt?: string;
|
|
22
|
-
tenantId?: string;
|
|
23
|
-
}
|
|
24
|
-
/**
|
|
25
|
-
* Input for updating an existing asset record.
|
|
26
|
-
*/
|
|
27
|
-
interface UpdateAssetInput {
|
|
28
|
-
alt?: string;
|
|
29
|
-
folderId?: string | null;
|
|
30
|
-
}
|
|
31
|
-
/**
|
|
32
|
-
* Input for creating a new folder.
|
|
33
|
-
*/
|
|
34
|
-
interface CreateFolderInput {
|
|
35
|
-
name: string;
|
|
36
|
-
parentId?: string;
|
|
37
|
-
tenantId?: string;
|
|
38
|
-
}
|
|
39
|
-
/**
|
|
40
|
-
* Create an asset record in the database.
|
|
41
|
-
* Pure DB function — no authorization hooks, no HTTP context.
|
|
42
|
-
*
|
|
43
|
-
* @remarks **Security:** No authorization hooks (e.g. `onBeforeUpload`) are called.
|
|
44
|
-
* The caller is responsible for any access-control checks before invoking this function.
|
|
45
|
-
*/
|
|
46
|
-
declare function createAsset(adapter: DBAdapter, input: CreateAssetInput): Promise<Asset>;
|
|
47
|
-
/**
|
|
48
|
-
* Update an asset's `alt` text or `folderId`.
|
|
49
|
-
* Pure DB function — no authorization hooks, no HTTP context.
|
|
50
|
-
*
|
|
51
|
-
* @remarks **Security:** No authorization hooks are called.
|
|
52
|
-
*/
|
|
53
|
-
declare function updateAsset(adapter: DBAdapter, id: string, input: UpdateAssetInput): Promise<Asset | null>;
|
|
54
|
-
/**
|
|
55
|
-
* Delete an asset record from the database by its ID.
|
|
56
|
-
* Does NOT delete the underlying file — the caller must do that via the storage adapter.
|
|
57
|
-
* Pure DB function — no authorization hooks, no HTTP context.
|
|
58
|
-
*
|
|
59
|
-
* @remarks **Security:** No authorization hooks are called.
|
|
60
|
-
*/
|
|
61
|
-
declare function deleteAsset(adapter: DBAdapter, id: string): Promise<void>;
|
|
62
|
-
/**
|
|
63
|
-
* Create a folder record in the database.
|
|
64
|
-
* Pure DB function — no authorization hooks, no HTTP context.
|
|
65
|
-
*
|
|
66
|
-
* @remarks **Security:** No authorization hooks are called.
|
|
67
|
-
*/
|
|
68
|
-
declare function createFolder(adapter: DBAdapter, input: CreateFolderInput): Promise<Folder>;
|
|
69
|
-
/**
|
|
70
|
-
* Delete a folder record from the database by its ID.
|
|
71
|
-
* Child folders are cascade-deleted automatically. Throws if the folder or
|
|
72
|
-
* any of its descendants contain assets (which have associated storage files
|
|
73
|
-
* that must be deleted via the storage adapter first).
|
|
74
|
-
* Pure DB function — no authorization hooks, no HTTP context.
|
|
75
|
-
*
|
|
76
|
-
* @remarks **Security:** No authorization hooks are called.
|
|
77
|
-
*/
|
|
78
|
-
declare function deleteFolder(adapter: DBAdapter, id: string): Promise<void>;
|
|
8
|
+
import '@btst/db';
|
|
79
9
|
|
|
80
10
|
/**
|
|
81
11
|
* Serialize an Asset for SSR/SSG use (convert dates to strings).
|
|
@@ -88,31 +18,4 @@ declare function serializeAsset(asset: Asset): SerializedAsset;
|
|
|
88
18
|
*/
|
|
89
19
|
declare function serializeFolder(folder: Folder): SerializedFolder;
|
|
90
20
|
|
|
91
|
-
|
|
92
|
-
/**
|
|
93
|
-
* Absolute path to the directory where uploaded files are stored.
|
|
94
|
-
* @default "./public/uploads"
|
|
95
|
-
*/
|
|
96
|
-
uploadDir?: string;
|
|
97
|
-
/**
|
|
98
|
-
* URL prefix used to build the public URL for uploaded files.
|
|
99
|
-
* @default "/uploads"
|
|
100
|
-
*/
|
|
101
|
-
publicPath?: string;
|
|
102
|
-
}
|
|
103
|
-
/**
|
|
104
|
-
* Create a local filesystem storage adapter.
|
|
105
|
-
* Files are written to `uploadDir` and served at `publicPath`.
|
|
106
|
-
* Suitable for development and self-hosted deployments.
|
|
107
|
-
*
|
|
108
|
-
* @example
|
|
109
|
-
* ```ts
|
|
110
|
-
* mediaBackendPlugin({
|
|
111
|
-
* storageAdapter: localAdapter({ uploadDir: "./public/uploads", publicPath: "/uploads" })
|
|
112
|
-
* })
|
|
113
|
-
* ```
|
|
114
|
-
*/
|
|
115
|
-
declare function localAdapter(options?: LocalStorageAdapterOptions): DirectStorageAdapter;
|
|
116
|
-
|
|
117
|
-
export { DirectStorageAdapter, createAsset, createFolder, deleteAsset, deleteFolder, localAdapter, serializeAsset, serializeFolder, updateAsset };
|
|
118
|
-
export type { CreateAssetInput, CreateFolderInput, LocalStorageAdapterOptions, UpdateAssetInput };
|
|
21
|
+
export { serializeAsset, serializeFolder };
|
|
@@ -3,4 +3,3 @@ export { getAssetById, getFolderById, getFolderByName, listAssets, listFolders }
|
|
|
3
3
|
export { createAsset, createFolder, deleteAsset, deleteFolder, updateAsset } from '../../../packages/stack/src/plugins/media/api/mutations.mjs';
|
|
4
4
|
export { serializeAsset, serializeFolder } from '../../../packages/stack/src/plugins/media/api/serializers.mjs';
|
|
5
5
|
export { MEDIA_QUERY_KEYS, assetListDiscriminator } from '../../../packages/stack/src/plugins/media/api/query-key-defs.mjs';
|
|
6
|
-
export { localAdapter } from '../../../packages/stack/src/plugins/media/api/adapters/local.mjs';
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import * as _tanstack_react_query from '@tanstack/react-query';
|
|
2
|
-
import {
|
|
2
|
+
import { j as MediaApiRouter, A as AssetListDiscriminator } from '../../shared/stack.vVFh38aS.cjs';
|
|
3
3
|
import { createApiClient } from '@btst/stack/plugins/client';
|
|
4
4
|
import { S as SerializedAsset, a as SerializedFolder } from '../../shared/stack.BMlLOMED.cjs';
|
|
5
5
|
import { A as AssetListParams } from '../../shared/stack.jU2iG86n.cjs';
|
|
6
6
|
import '@btst/stack/plugins/api';
|
|
7
|
-
import '../../shared/stack.
|
|
7
|
+
import '../../shared/stack.lkebw2nj.cjs';
|
|
8
8
|
import 'better-call';
|
|
9
9
|
import 'zod';
|
|
10
10
|
import '@btst/db';
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import * as _tanstack_react_query from '@tanstack/react-query';
|
|
2
|
-
import {
|
|
2
|
+
import { j as MediaApiRouter, A as AssetListDiscriminator } from '../../shared/stack.DpZoZd98.mjs';
|
|
3
3
|
import { createApiClient } from '@btst/stack/plugins/client';
|
|
4
4
|
import { S as SerializedAsset, a as SerializedFolder } from '../../shared/stack.BMlLOMED.mjs';
|
|
5
5
|
import { A as AssetListParams } from '../../shared/stack.C7u9lq9T.mjs';
|
|
6
6
|
import '@btst/stack/plugins/api';
|
|
7
|
-
import '../../shared/stack.
|
|
7
|
+
import '../../shared/stack.lkebw2nj.mjs';
|
|
8
8
|
import 'better-call';
|
|
9
9
|
import 'zod';
|
|
10
10
|
import '@btst/db';
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import * as _tanstack_react_query from '@tanstack/react-query';
|
|
2
|
-
import {
|
|
2
|
+
import { j as MediaApiRouter, A as AssetListDiscriminator } from '../../shared/stack.C5ucdatf.js';
|
|
3
3
|
import { createApiClient } from '@btst/stack/plugins/client';
|
|
4
4
|
import { S as SerializedAsset, a as SerializedFolder } from '../../shared/stack.BMlLOMED.js';
|
|
5
5
|
import { A as AssetListParams } from '../../shared/stack.DD-ZORI7.js';
|
|
6
6
|
import '@btst/stack/plugins/api';
|
|
7
|
-
import '../../shared/stack.
|
|
7
|
+
import '../../shared/stack.lkebw2nj.js';
|
|
8
8
|
import 'better-call';
|
|
9
9
|
import 'zod';
|
|
10
10
|
import '@btst/db';
|
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import * as _btst_stack_plugins_api from '@btst/stack/plugins/api';
|
|
2
|
-
import {
|
|
2
|
+
import { S as StorageAdapter, b as S3UploadToken } from './stack.lkebw2nj.js';
|
|
3
3
|
import { d as AssetListResult, l as listAssets, a as listFolders, A as AssetListParams } from './stack.DD-ZORI7.js';
|
|
4
4
|
import * as better_call from 'better-call';
|
|
5
5
|
import { z } from 'zod';
|
|
6
6
|
import { A as Asset, F as Folder } from './stack.BMlLOMED.js';
|
|
7
|
+
import { DBAdapter } from '@btst/db';
|
|
7
8
|
|
|
8
9
|
declare const AssetListQuerySchema: z.ZodObject<{
|
|
9
10
|
folderId: z.ZodOptional<z.ZodString>;
|
|
@@ -21,6 +22,75 @@ declare const createFolderSchema: z.ZodObject<{
|
|
|
21
22
|
parentId: z.ZodOptional<z.ZodString>;
|
|
22
23
|
}, z.core.$strip>;
|
|
23
24
|
|
|
25
|
+
/**
|
|
26
|
+
* Input for creating a new asset record.
|
|
27
|
+
*/
|
|
28
|
+
interface CreateAssetInput {
|
|
29
|
+
filename: string;
|
|
30
|
+
originalName: string;
|
|
31
|
+
mimeType: string;
|
|
32
|
+
size: number;
|
|
33
|
+
url: string;
|
|
34
|
+
folderId?: string;
|
|
35
|
+
alt?: string;
|
|
36
|
+
tenantId?: string;
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* Input for updating an existing asset record.
|
|
40
|
+
*/
|
|
41
|
+
interface UpdateAssetInput {
|
|
42
|
+
alt?: string;
|
|
43
|
+
folderId?: string | null;
|
|
44
|
+
}
|
|
45
|
+
/**
|
|
46
|
+
* Input for creating a new folder.
|
|
47
|
+
*/
|
|
48
|
+
interface CreateFolderInput {
|
|
49
|
+
name: string;
|
|
50
|
+
parentId?: string;
|
|
51
|
+
tenantId?: string;
|
|
52
|
+
}
|
|
53
|
+
/**
|
|
54
|
+
* Create an asset record in the database.
|
|
55
|
+
* Pure DB function — no authorization hooks, no HTTP context.
|
|
56
|
+
*
|
|
57
|
+
* @remarks **Security:** No authorization hooks (e.g. `onBeforeUpload`) are called.
|
|
58
|
+
* The caller is responsible for any access-control checks before invoking this function.
|
|
59
|
+
*/
|
|
60
|
+
declare function createAsset(adapter: DBAdapter, input: CreateAssetInput): Promise<Asset>;
|
|
61
|
+
/**
|
|
62
|
+
* Update an asset's `alt` text or `folderId`.
|
|
63
|
+
* Pure DB function — no authorization hooks, no HTTP context.
|
|
64
|
+
*
|
|
65
|
+
* @remarks **Security:** No authorization hooks are called.
|
|
66
|
+
*/
|
|
67
|
+
declare function updateAsset(adapter: DBAdapter, id: string, input: UpdateAssetInput): Promise<Asset | null>;
|
|
68
|
+
/**
|
|
69
|
+
* Delete an asset record from the database by its ID.
|
|
70
|
+
* Does NOT delete the underlying file — the caller must do that via the storage adapter.
|
|
71
|
+
* Pure DB function — no authorization hooks, no HTTP context.
|
|
72
|
+
*
|
|
73
|
+
* @remarks **Security:** No authorization hooks are called.
|
|
74
|
+
*/
|
|
75
|
+
declare function deleteAsset(adapter: DBAdapter, id: string): Promise<void>;
|
|
76
|
+
/**
|
|
77
|
+
* Create a folder record in the database.
|
|
78
|
+
* Pure DB function — no authorization hooks, no HTTP context.
|
|
79
|
+
*
|
|
80
|
+
* @remarks **Security:** No authorization hooks are called.
|
|
81
|
+
*/
|
|
82
|
+
declare function createFolder(adapter: DBAdapter, input: CreateFolderInput): Promise<Folder>;
|
|
83
|
+
/**
|
|
84
|
+
* Delete a folder record from the database by its ID.
|
|
85
|
+
* Child folders are cascade-deleted automatically. Throws if the folder or
|
|
86
|
+
* any of its descendants contain assets (which have associated storage files
|
|
87
|
+
* that must be deleted via the storage adapter first).
|
|
88
|
+
* Pure DB function — no authorization hooks, no HTTP context.
|
|
89
|
+
*
|
|
90
|
+
* @remarks **Security:** No authorization hooks are called.
|
|
91
|
+
*/
|
|
92
|
+
declare function deleteFolder(adapter: DBAdapter, id: string): Promise<void>;
|
|
93
|
+
|
|
24
94
|
/**
|
|
25
95
|
* Context passed to media API hooks.
|
|
26
96
|
*/
|
|
@@ -270,9 +340,12 @@ declare const mediaBackendPlugin: (config: MediaBackendConfig) => _btst_stack_pl
|
|
|
270
340
|
}, {
|
|
271
341
|
listAssets: (params?: Parameters<typeof listAssets>[1]) => Promise<AssetListResult>;
|
|
272
342
|
getAssetById: (id: string) => Promise<Asset | null>;
|
|
343
|
+
createAsset: (input: Parameters<typeof createAsset>[1]) => Promise<Asset>;
|
|
344
|
+
updateAsset: (id: string, input: Parameters<typeof updateAsset>[2]) => Promise<Asset | null>;
|
|
273
345
|
listFolders: (params?: Parameters<typeof listFolders>[1]) => Promise<Folder[]>;
|
|
274
346
|
getFolderById: (id: string) => Promise<Folder | null>;
|
|
275
347
|
getFolderByName: (name: string, parentId?: string | null, tenantId?: string) => Promise<Folder | null>;
|
|
348
|
+
createFolder: (input: Parameters<typeof createFolder>[1]) => Promise<Folder>;
|
|
276
349
|
}>;
|
|
277
350
|
type MediaApiRouter = ReturnType<ReturnType<typeof mediaBackendPlugin>["routes"]>;
|
|
278
351
|
|
|
@@ -300,5 +373,5 @@ declare const MEDIA_QUERY_KEYS: {
|
|
|
300
373
|
foldersList: (parentId?: string | null) => readonly ["media", "folders", "list", string];
|
|
301
374
|
};
|
|
302
375
|
|
|
303
|
-
export { MEDIA_QUERY_KEYS as a,
|
|
304
|
-
export type { AssetListDiscriminator as A,
|
|
376
|
+
export { MEDIA_QUERY_KEYS as M, createFolder as a, deleteFolder as b, createAsset as c, deleteAsset as d, assetListDiscriminator as f, mediaBackendPlugin as m, updateAsset as u };
|
|
377
|
+
export type { AssetListDiscriminator as A, CreateAssetInput as C, UpdateAssetInput as U, CreateFolderInput as e, MediaApiContext as g, MediaBackendHooks as h, MediaBackendConfig as i, MediaApiRouter as j };
|