@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.
Files changed (71) hide show
  1. package/dist/packages/stack/src/plugins/blog/api/mutations.cjs +170 -0
  2. package/dist/packages/stack/src/plugins/blog/api/mutations.mjs +166 -0
  3. package/dist/packages/stack/src/plugins/blog/api/plugin.cjs +34 -157
  4. package/dist/packages/stack/src/plugins/blog/api/plugin.mjs +40 -163
  5. package/dist/packages/stack/src/plugins/media/api/plugin.cjs +4 -1
  6. package/dist/packages/stack/src/plugins/media/api/plugin.mjs +5 -2
  7. package/dist/plugins/blog/api/index.cjs +4 -0
  8. package/dist/plugins/blog/api/index.d.cts +2 -2
  9. package/dist/plugins/blog/api/index.d.mts +2 -2
  10. package/dist/plugins/blog/api/index.d.ts +2 -2
  11. package/dist/plugins/blog/api/index.mjs +1 -0
  12. package/dist/plugins/blog/client/hooks/index.d.cts +2 -2
  13. package/dist/plugins/blog/client/hooks/index.d.mts +2 -2
  14. package/dist/plugins/blog/client/hooks/index.d.ts +2 -2
  15. package/dist/plugins/blog/client/index.d.cts +2 -2
  16. package/dist/plugins/blog/client/index.d.mts +2 -2
  17. package/dist/plugins/blog/client/index.d.ts +2 -2
  18. package/dist/plugins/blog/query-keys.d.cts +2 -2
  19. package/dist/plugins/blog/query-keys.d.mts +2 -2
  20. package/dist/plugins/blog/query-keys.d.ts +2 -2
  21. package/dist/plugins/kanban/api/index.d.cts +1 -1
  22. package/dist/plugins/kanban/api/index.d.mts +1 -1
  23. package/dist/plugins/kanban/api/index.d.ts +1 -1
  24. package/dist/plugins/kanban/query-keys.d.cts +1 -1
  25. package/dist/plugins/kanban/query-keys.d.mts +1 -1
  26. package/dist/plugins/kanban/query-keys.d.ts +1 -1
  27. package/dist/{packages/stack/src/plugins → plugins}/media/api/adapters/local.cjs +7 -1
  28. package/dist/plugins/media/api/adapters/local.d.cts +30 -0
  29. package/dist/plugins/media/api/adapters/local.d.mts +30 -0
  30. package/dist/plugins/media/api/adapters/local.d.ts +30 -0
  31. package/dist/{packages/stack/src/plugins → plugins}/media/api/adapters/local.mjs +7 -1
  32. package/dist/plugins/media/api/adapters/s3.d.cts +1 -1
  33. package/dist/plugins/media/api/adapters/s3.d.mts +1 -1
  34. package/dist/plugins/media/api/adapters/s3.d.ts +1 -1
  35. package/dist/plugins/media/api/adapters/vercel-blob.d.cts +1 -1
  36. package/dist/plugins/media/api/adapters/vercel-blob.d.mts +1 -1
  37. package/dist/plugins/media/api/adapters/vercel-blob.d.ts +1 -1
  38. package/dist/plugins/media/api/index.cjs +0 -2
  39. package/dist/plugins/media/api/index.d.cts +5 -102
  40. package/dist/plugins/media/api/index.d.mts +5 -102
  41. package/dist/plugins/media/api/index.d.ts +5 -102
  42. package/dist/plugins/media/api/index.mjs +0 -1
  43. package/dist/plugins/media/query-keys.d.cts +2 -2
  44. package/dist/plugins/media/query-keys.d.mts +2 -2
  45. package/dist/plugins/media/query-keys.d.ts +2 -2
  46. package/dist/shared/{stack.Bci0-plK.d.ts → stack.C5ucdatf.d.ts} +76 -3
  47. package/dist/shared/{stack.D7HSzZdG.d.ts → stack.D0p6oNme.d.ts} +90 -7
  48. package/dist/shared/{stack.6mEHS2WH.d.mts → stack.DOZ1EXjM.d.mts} +3 -3
  49. package/dist/shared/{stack.IUeyQKrm.d.mts → stack.DWipT53I.d.cts} +90 -7
  50. package/dist/shared/{stack.AJTXI7kw.d.cts → stack.DX-tQ93o.d.cts} +3 -3
  51. package/dist/shared/{stack.C_MUwwgR.d.mts → stack.DpZoZd98.d.mts} +76 -3
  52. package/dist/shared/{stack.DjgpFWq3.d.cts → stack.E17kSK1W.d.mts} +90 -7
  53. package/dist/shared/{stack.QYn-Px94.d.ts → stack.VF6FhyZw.d.ts} +3 -3
  54. package/dist/shared/{stack.DO6vOGQG.d.cts → stack.lkebw2nj.d.cts} +1 -1
  55. package/dist/shared/{stack.DO6vOGQG.d.mts → stack.lkebw2nj.d.mts} +1 -1
  56. package/dist/shared/{stack.DO6vOGQG.d.ts → stack.lkebw2nj.d.ts} +1 -1
  57. package/dist/shared/{stack.D6zyQnMo.d.cts → stack.vVFh38aS.d.cts} +76 -3
  58. package/package.json +14 -1
  59. package/src/plugins/blog/api/index.ts +7 -0
  60. package/src/plugins/blog/api/mutations.ts +287 -0
  61. package/src/plugins/blog/api/plugin.ts +43 -184
  62. package/src/plugins/media/__tests__/storage-adapters.test.ts +11 -0
  63. package/src/plugins/media/api/adapters/local.ts +10 -1
  64. package/src/plugins/media/api/index.ts +0 -5
  65. package/src/plugins/media/api/plugin.ts +6 -0
  66. package/dist/shared/{stack.eq5eg1yt.d.cts → stack.B6S3cgwN.d.cts} +6 -6
  67. package/dist/shared/{stack.BQmuNl5p.d.ts → stack.BWp0hcm9.d.cts} +3 -3
  68. package/dist/shared/{stack.BQmuNl5p.d.cts → stack.BWp0hcm9.d.mts} +3 -3
  69. package/dist/shared/{stack.BQmuNl5p.d.mts → stack.BWp0hcm9.d.ts} +3 -3
  70. package/dist/shared/{stack.Dj04W2c3.d.mts → stack.Bzfx-_lq.d.mts} +6 -6
  71. 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 filePath = path.join(uploadDir, filename);
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) {
@@ -1,4 +1,4 @@
1
- import { S as S3StorageAdapter } from '../../../../shared/stack.DO6vOGQG.cjs';
1
+ import { a as S3StorageAdapter } from '../../../../shared/stack.lkebw2nj.cjs';
2
2
 
3
3
  interface S3StorageAdapterOptions {
4
4
  /**
@@ -1,4 +1,4 @@
1
- import { S as S3StorageAdapter } from '../../../../shared/stack.DO6vOGQG.mjs';
1
+ import { a as S3StorageAdapter } from '../../../../shared/stack.lkebw2nj.mjs';
2
2
 
3
3
  interface S3StorageAdapterOptions {
4
4
  /**
@@ -1,4 +1,4 @@
1
- import { S as S3StorageAdapter } from '../../../../shared/stack.DO6vOGQG.js';
1
+ import { a as S3StorageAdapter } from '../../../../shared/stack.lkebw2nj.js';
2
2
 
3
3
  interface S3StorageAdapterOptions {
4
4
  /**
@@ -1,4 +1,4 @@
1
- import { V as VercelBlobStorageAdapter } from '../../../../shared/stack.DO6vOGQG.cjs';
1
+ import { V as VercelBlobStorageAdapter } from '../../../../shared/stack.lkebw2nj.cjs';
2
2
 
3
3
  interface VercelBlobStorageAdapterOptions {
4
4
  /**
@@ -1,4 +1,4 @@
1
- import { V as VercelBlobStorageAdapter } from '../../../../shared/stack.DO6vOGQG.mjs';
1
+ import { V as VercelBlobStorageAdapter } from '../../../../shared/stack.lkebw2nj.mjs';
2
2
 
3
3
  interface VercelBlobStorageAdapterOptions {
4
4
  /**
@@ -1,4 +1,4 @@
1
- import { V as VercelBlobStorageAdapter } from '../../../../shared/stack.DO6vOGQG.js';
1
+ import { V as VercelBlobStorageAdapter } from '../../../../shared/stack.lkebw2nj.js';
2
2
 
3
3
  interface VercelBlobStorageAdapterOptions {
4
4
  /**
@@ -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 { a as MEDIA_QUERY_KEYS, c as MediaApiContext, M as MediaApiRouter, e as MediaBackendConfig, d as MediaBackendHooks, b as assetListDiscriminator, m as mediaBackendPlugin } from '../../../shared/stack.D6zyQnMo.cjs';
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 { DBAdapter } from '@btst/db';
4
- import { A as Asset, F as Folder, S as SerializedAsset, a as SerializedFolder } from '../../../shared/stack.BMlLOMED.cjs';
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
- interface LocalStorageAdapterOptions {
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 { a as MEDIA_QUERY_KEYS, c as MediaApiContext, M as MediaApiRouter, e as MediaBackendConfig, d as MediaBackendHooks, b as assetListDiscriminator, m as mediaBackendPlugin } from '../../../shared/stack.C_MUwwgR.mjs';
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 { DBAdapter } from '@btst/db';
4
- import { A as Asset, F as Folder, S as SerializedAsset, a as SerializedFolder } from '../../../shared/stack.BMlLOMED.mjs';
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
- interface LocalStorageAdapterOptions {
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 { a as MEDIA_QUERY_KEYS, c as MediaApiContext, M as MediaApiRouter, e as MediaBackendConfig, d as MediaBackendHooks, b as assetListDiscriminator, m as mediaBackendPlugin } from '../../../shared/stack.Bci0-plK.js';
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 { DBAdapter } from '@btst/db';
4
- import { A as Asset, F as Folder, S as SerializedAsset, a as SerializedFolder } from '../../../shared/stack.BMlLOMED.js';
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
- interface LocalStorageAdapterOptions {
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 { M as MediaApiRouter, A as AssetListDiscriminator } from '../../shared/stack.D6zyQnMo.cjs';
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.DO6vOGQG.cjs';
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 { M as MediaApiRouter, A as AssetListDiscriminator } from '../../shared/stack.C_MUwwgR.mjs';
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.DO6vOGQG.mjs';
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 { M as MediaApiRouter, A as AssetListDiscriminator } from '../../shared/stack.Bci0-plK.js';
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.DO6vOGQG.js';
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 { a as StorageAdapter, b as S3UploadToken } from './stack.DO6vOGQG.js';
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, assetListDiscriminator as b, mediaBackendPlugin as m };
304
- export type { AssetListDiscriminator as A, MediaApiRouter as M, MediaApiContext as c, MediaBackendHooks as d, MediaBackendConfig as e };
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 };