@vryzel/file-next 0.4.0

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.
@@ -0,0 +1,131 @@
1
+ import { b as FileSystemConfig, C as CreateFileSystemOptions, a as FileSystem, S as S3CompatibleAdapter, c as S3Key, R as Result, M as MetadataStore } from './filesystem-BbZJLy4A.cjs';
2
+ export { d as CopyInput, e as CopyOutput, f as CreateNodeInput, g as Credentials, D as DeleteInput, h as DeleteNodeInput, i as DeleteOutput, E as ExistsInput, j as ExistsOutput, F as FileNode, G as GetMetadataInput, k as GetMetadataOutput, l as GetNodeInput, m as GetPathInput, n as GetPathOutput, o as GetPublicUrlInput, p as GetPublicUrlOutput, L as ListChildrenInput, q as ListChildrenOutput, r as ListInput, s as ListOutput, t as MoveInput, u as MoveNodeInput, v as MoveOutput, N as NodeKind, P as Path, w as Prefix, x as PresignedDownloadInput, y as PresignedDownloadOutput, z as PresignedUploadInput, A as PresignedUploadOutput, B as R2Config, H as ReadInput, I as ReadOutput, J as ReconcileResult, K as S3Config, O as SearchInput, Q as SetMetadataInput, V as SetMetadataOutput, W as StatInput, X as StatOutput, T as TenantId, Y as UpdateMetadataInput, U as UserId, Z as WriteInput, _ as WriteOutput, $ as andThen, a0 as asPath, a1 as asPrefix, a2 as asS3Key, a3 as asTenantId, a4 as asUserId, a5 as assertPath, a6 as assertPrefix, a7 as assertS3Key, a8 as assertTenantId, a9 as assertUserId, aa as err, ab as map, ac as mapErr, ad as ok, ae as parseFileSystemConfig, af as unwrap, ag as unwrapOr } from './filesystem-BbZJLy4A.cjs';
3
+ import { FileSystemError } from './errors/index.cjs';
4
+ export { FILE_SYSTEM_ERROR_CODES, FileSystemErrorCode, FileSystemErrorJson, FileSystemErrorOptions, RETRYABLE_BY_CODE, fromAws, fromPg, fromSqlite } from './errors/index.cjs';
5
+ import { ClassValue } from 'clsx';
6
+ export { A as AuthContext, w as withAuth } from './with-auth-BueIpNZ7.cjs';
7
+ import 'zod';
8
+
9
+ /**
10
+ Merge Tailwind CSS classes with conflict resolution.
11
+ Mirrors shadcn/ui's `cn` utility so consumers get a familiar DX.
12
+ */
13
+ declare function cn(...inputs: ClassValue[]): string;
14
+
15
+ declare const createFileSystem: (config: FileSystemConfig, options?: CreateFileSystemOptions) => FileSystem;
16
+ declare const createMemoryFileSystem: (options?: CreateFileSystemOptions) => FileSystem;
17
+
18
+ /**
19
+ * Tenant prefix wrapper — rewrites every key/prefix so one bucket
20
+ * can hold many tenants without the rest of the library knowing.
21
+ *
22
+ * Metadata stores the tenant-relative key (usually the node UUID).
23
+ * The wrapper prepends `t/{tenantId}/` on the way in and strips it
24
+ * on the way out.
25
+ */
26
+
27
+ declare const tenantPrefix: (tenantId: string) => string;
28
+ declare const prefixAdapter: (adapter: S3CompatibleAdapter, prefix: string) => S3CompatibleAdapter;
29
+
30
+ /**
31
+ * Return the memoized `FileSystem` for the current process, building
32
+ * it from `FILE_NEXT_*` env vars on first call.
33
+ */
34
+ declare const getFileSystem: () => FileSystem;
35
+
36
+ /** A single object stored in the in-memory backend. */
37
+ interface MemoryObject {
38
+ readonly body: Uint8Array;
39
+ readonly contentType: string;
40
+ readonly userMetadata: Readonly<Record<string, string>>;
41
+ readonly createdAt: Date;
42
+ readonly updatedAt: Date;
43
+ }
44
+ /** Public snapshot of the store. Tests use this to assert on state. */
45
+ interface MemoryStoreSnapshot {
46
+ /** Map from S3 key to the stored object. */
47
+ readonly objects: ReadonlyMap<S3Key, MemoryObject>;
48
+ /** Monotonic counter used to fabricate fake etags. */
49
+ readonly etagCounter: number;
50
+ }
51
+ /** Options for `createMemoryAdapter`. */
52
+ interface MemoryAdapterOptions {
53
+ /** Default content type when the caller doesn't supply one. Default: `application/octet-stream`. */
54
+ readonly defaultContentType?: string;
55
+ /** Whether to validate the single-PUT size cap. Default: true. */
56
+ readonly enforceSizeLimit?: boolean;
57
+ /**
58
+ * Override the single-PUT size cap. Default: `MAX_SINGLE_PUT_SIZE`
59
+ * (5 GB). Lower this in tests so you don't need to allocate 5+ GB
60
+ * of memory just to assert the cap.
61
+ */
62
+ readonly maxSinglePutSize?: number;
63
+ /**
64
+ * Optional bucket name for `getPublicUrl` fabrication. The
65
+ * default `"in-memory"` keeps the URLs short and obviously fake.
66
+ */
67
+ readonly bucket?: string;
68
+ }
69
+ /**
70
+ * Create a fresh in-memory adapter. The returned adapter is a
71
+ * closure over a private `Map`; you can read the current state
72
+ * via the `.store()` method.
73
+ */
74
+ declare function createMemoryAdapter(options?: MemoryAdapterOptions): S3CompatibleAdapter & {
75
+ readonly store: () => MemoryStoreSnapshot;
76
+ };
77
+
78
+ /**
79
+ * Display-name rules for files and folders.
80
+ *
81
+ * Metadata `path` is `parentPath + "/" + name`. A raw `/` in `name`
82
+ * would split the tree. S3 keys are UUIDs, so the bucket is unaffected;
83
+ * the store still has to keep names as a single path segment.
84
+ *
85
+ * 255 matches the common POSIX/Windows filename cap.
86
+ */
87
+
88
+ declare const NODE_NAME_MAX_LENGTH = 255;
89
+ declare function normalizeNodeName(raw: string): Result<string, FileSystemError>;
90
+
91
+ declare const createMemoryStore: () => MetadataStore;
92
+
93
+ interface SqliteStoreOptions {
94
+ /**
95
+ * SQLite file path, or ":memory:" for a private in-memory
96
+ * database. Use ":memory:" in tests; a real path in apps so
97
+ * the file tree survives restarts.
98
+ */
99
+ readonly path: string;
100
+ /**
101
+ * Run schema migrations on construction. Default: true.
102
+ * Set false when sharing a DB across multiple stores (each
103
+ * instance would otherwise re-run the idempotent CREATE).
104
+ */
105
+ readonly runMigrations?: boolean;
106
+ }
107
+ declare const createSqliteStore: (options: SqliteStoreOptions) => MetadataStore;
108
+
109
+ interface PostgresStoreOptions {
110
+ /**
111
+ * A libpq connection string. Example:
112
+ * postgres://user:pass@localhost:5432/dbname
113
+ */
114
+ readonly connectionString: string;
115
+ /**
116
+ * Postgres schema (namespace). Defaults to "public".
117
+ * Use a dedicated schema per tenant in shared clusters.
118
+ */
119
+ readonly schema?: string;
120
+ /**
121
+ * Run schema migrations on construction. Default: true.
122
+ */
123
+ readonly runMigrations?: boolean;
124
+ /**
125
+ * Max pool size. Defaults to 10.
126
+ */
127
+ readonly maxPoolSize?: number;
128
+ }
129
+ declare const createPostgresStore: (options: PostgresStoreOptions) => MetadataStore;
130
+
131
+ export { CreateFileSystemOptions, FileSystem, FileSystemConfig, FileSystemError, type MemoryAdapterOptions, type MemoryStoreSnapshot, MetadataStore, NODE_NAME_MAX_LENGTH, type PostgresStoreOptions, Result, S3CompatibleAdapter, S3Key, type SqliteStoreOptions, cn, createFileSystem, createMemoryAdapter, createMemoryFileSystem, createMemoryStore, createPostgresStore, createSqliteStore, getFileSystem, normalizeNodeName, prefixAdapter, tenantPrefix };
@@ -0,0 +1,131 @@
1
+ import { b as FileSystemConfig, C as CreateFileSystemOptions, a as FileSystem, S as S3CompatibleAdapter, c as S3Key, R as Result, M as MetadataStore } from './filesystem-D1Jjx3md.js';
2
+ export { d as CopyInput, e as CopyOutput, f as CreateNodeInput, g as Credentials, D as DeleteInput, h as DeleteNodeInput, i as DeleteOutput, E as ExistsInput, j as ExistsOutput, F as FileNode, G as GetMetadataInput, k as GetMetadataOutput, l as GetNodeInput, m as GetPathInput, n as GetPathOutput, o as GetPublicUrlInput, p as GetPublicUrlOutput, L as ListChildrenInput, q as ListChildrenOutput, r as ListInput, s as ListOutput, t as MoveInput, u as MoveNodeInput, v as MoveOutput, N as NodeKind, P as Path, w as Prefix, x as PresignedDownloadInput, y as PresignedDownloadOutput, z as PresignedUploadInput, A as PresignedUploadOutput, B as R2Config, H as ReadInput, I as ReadOutput, J as ReconcileResult, K as S3Config, O as SearchInput, Q as SetMetadataInput, V as SetMetadataOutput, W as StatInput, X as StatOutput, T as TenantId, Y as UpdateMetadataInput, U as UserId, Z as WriteInput, _ as WriteOutput, $ as andThen, a0 as asPath, a1 as asPrefix, a2 as asS3Key, a3 as asTenantId, a4 as asUserId, a5 as assertPath, a6 as assertPrefix, a7 as assertS3Key, a8 as assertTenantId, a9 as assertUserId, aa as err, ab as map, ac as mapErr, ad as ok, ae as parseFileSystemConfig, af as unwrap, ag as unwrapOr } from './filesystem-D1Jjx3md.js';
3
+ import { FileSystemError } from './errors/index.js';
4
+ export { FILE_SYSTEM_ERROR_CODES, FileSystemErrorCode, FileSystemErrorJson, FileSystemErrorOptions, RETRYABLE_BY_CODE, fromAws, fromPg, fromSqlite } from './errors/index.js';
5
+ import { ClassValue } from 'clsx';
6
+ export { A as AuthContext, w as withAuth } from './with-auth-yfezt7YS.js';
7
+ import 'zod';
8
+
9
+ /**
10
+ Merge Tailwind CSS classes with conflict resolution.
11
+ Mirrors shadcn/ui's `cn` utility so consumers get a familiar DX.
12
+ */
13
+ declare function cn(...inputs: ClassValue[]): string;
14
+
15
+ declare const createFileSystem: (config: FileSystemConfig, options?: CreateFileSystemOptions) => FileSystem;
16
+ declare const createMemoryFileSystem: (options?: CreateFileSystemOptions) => FileSystem;
17
+
18
+ /**
19
+ * Tenant prefix wrapper — rewrites every key/prefix so one bucket
20
+ * can hold many tenants without the rest of the library knowing.
21
+ *
22
+ * Metadata stores the tenant-relative key (usually the node UUID).
23
+ * The wrapper prepends `t/{tenantId}/` on the way in and strips it
24
+ * on the way out.
25
+ */
26
+
27
+ declare const tenantPrefix: (tenantId: string) => string;
28
+ declare const prefixAdapter: (adapter: S3CompatibleAdapter, prefix: string) => S3CompatibleAdapter;
29
+
30
+ /**
31
+ * Return the memoized `FileSystem` for the current process, building
32
+ * it from `FILE_NEXT_*` env vars on first call.
33
+ */
34
+ declare const getFileSystem: () => FileSystem;
35
+
36
+ /** A single object stored in the in-memory backend. */
37
+ interface MemoryObject {
38
+ readonly body: Uint8Array;
39
+ readonly contentType: string;
40
+ readonly userMetadata: Readonly<Record<string, string>>;
41
+ readonly createdAt: Date;
42
+ readonly updatedAt: Date;
43
+ }
44
+ /** Public snapshot of the store. Tests use this to assert on state. */
45
+ interface MemoryStoreSnapshot {
46
+ /** Map from S3 key to the stored object. */
47
+ readonly objects: ReadonlyMap<S3Key, MemoryObject>;
48
+ /** Monotonic counter used to fabricate fake etags. */
49
+ readonly etagCounter: number;
50
+ }
51
+ /** Options for `createMemoryAdapter`. */
52
+ interface MemoryAdapterOptions {
53
+ /** Default content type when the caller doesn't supply one. Default: `application/octet-stream`. */
54
+ readonly defaultContentType?: string;
55
+ /** Whether to validate the single-PUT size cap. Default: true. */
56
+ readonly enforceSizeLimit?: boolean;
57
+ /**
58
+ * Override the single-PUT size cap. Default: `MAX_SINGLE_PUT_SIZE`
59
+ * (5 GB). Lower this in tests so you don't need to allocate 5+ GB
60
+ * of memory just to assert the cap.
61
+ */
62
+ readonly maxSinglePutSize?: number;
63
+ /**
64
+ * Optional bucket name for `getPublicUrl` fabrication. The
65
+ * default `"in-memory"` keeps the URLs short and obviously fake.
66
+ */
67
+ readonly bucket?: string;
68
+ }
69
+ /**
70
+ * Create a fresh in-memory adapter. The returned adapter is a
71
+ * closure over a private `Map`; you can read the current state
72
+ * via the `.store()` method.
73
+ */
74
+ declare function createMemoryAdapter(options?: MemoryAdapterOptions): S3CompatibleAdapter & {
75
+ readonly store: () => MemoryStoreSnapshot;
76
+ };
77
+
78
+ /**
79
+ * Display-name rules for files and folders.
80
+ *
81
+ * Metadata `path` is `parentPath + "/" + name`. A raw `/` in `name`
82
+ * would split the tree. S3 keys are UUIDs, so the bucket is unaffected;
83
+ * the store still has to keep names as a single path segment.
84
+ *
85
+ * 255 matches the common POSIX/Windows filename cap.
86
+ */
87
+
88
+ declare const NODE_NAME_MAX_LENGTH = 255;
89
+ declare function normalizeNodeName(raw: string): Result<string, FileSystemError>;
90
+
91
+ declare const createMemoryStore: () => MetadataStore;
92
+
93
+ interface SqliteStoreOptions {
94
+ /**
95
+ * SQLite file path, or ":memory:" for a private in-memory
96
+ * database. Use ":memory:" in tests; a real path in apps so
97
+ * the file tree survives restarts.
98
+ */
99
+ readonly path: string;
100
+ /**
101
+ * Run schema migrations on construction. Default: true.
102
+ * Set false when sharing a DB across multiple stores (each
103
+ * instance would otherwise re-run the idempotent CREATE).
104
+ */
105
+ readonly runMigrations?: boolean;
106
+ }
107
+ declare const createSqliteStore: (options: SqliteStoreOptions) => MetadataStore;
108
+
109
+ interface PostgresStoreOptions {
110
+ /**
111
+ * A libpq connection string. Example:
112
+ * postgres://user:pass@localhost:5432/dbname
113
+ */
114
+ readonly connectionString: string;
115
+ /**
116
+ * Postgres schema (namespace). Defaults to "public".
117
+ * Use a dedicated schema per tenant in shared clusters.
118
+ */
119
+ readonly schema?: string;
120
+ /**
121
+ * Run schema migrations on construction. Default: true.
122
+ */
123
+ readonly runMigrations?: boolean;
124
+ /**
125
+ * Max pool size. Defaults to 10.
126
+ */
127
+ readonly maxPoolSize?: number;
128
+ }
129
+ declare const createPostgresStore: (options: PostgresStoreOptions) => MetadataStore;
130
+
131
+ export { CreateFileSystemOptions, FileSystem, FileSystemConfig, FileSystemError, type MemoryAdapterOptions, type MemoryStoreSnapshot, MetadataStore, NODE_NAME_MAX_LENGTH, type PostgresStoreOptions, Result, S3CompatibleAdapter, S3Key, type SqliteStoreOptions, cn, createFileSystem, createMemoryAdapter, createMemoryFileSystem, createMemoryStore, createPostgresStore, createSqliteStore, getFileSystem, normalizeNodeName, prefixAdapter, tenantPrefix };