duckpond 0.3.0 → 0.4.1
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/DuckPond.d.ts +76 -79
- package/dist/DuckPond.js +29 -1
- package/dist/DuckPond.js.map +1 -1
- package/dist/LRUCache-Bg_8n4IH.js +2 -0
- package/dist/LRUCache-Bg_8n4IH.js.map +1 -0
- package/dist/cache/LRUCache.d.ts +107 -69
- package/dist/cache/LRUCache.js +1 -2
- package/dist/index.d.ts +10 -12
- package/dist/index.js +1 -2
- package/dist/types.d.ts +117 -114
- package/dist/types.js +1 -1
- package/dist/types.js.map +1 -1
- package/dist/utils/errors.d.ts +18 -18
- package/dist/utils/errors.js +2 -1
- package/dist/utils/errors.js.map +1 -1
- package/dist/utils/logger.d.ts +11 -8
- package/dist/utils/logger.js +1 -1
- package/dist/utils/logger.js.map +1 -1
- package/package.json +33 -46
- package/dist/DuckPond.d.mts +0 -83
- package/dist/DuckPond.mjs +0 -2
- package/dist/DuckPond.mjs.map +0 -1
- package/dist/cache/LRUCache.d.mts +0 -75
- package/dist/cache/LRUCache.js.map +0 -1
- package/dist/cache/LRUCache.mjs +0 -2
- package/dist/cache/LRUCache.mjs.map +0 -1
- package/dist/chunk-24M54WUC.mjs +0 -2
- package/dist/chunk-24M54WUC.mjs.map +0 -1
- package/dist/chunk-5XGN7UAV.js +0 -2
- package/dist/chunk-5XGN7UAV.js.map +0 -1
- package/dist/chunk-BA7KCST7.mjs +0 -30
- package/dist/chunk-BA7KCST7.mjs.map +0 -1
- package/dist/chunk-GXQJHTJW.mjs +0 -2
- package/dist/chunk-GXQJHTJW.mjs.map +0 -1
- package/dist/chunk-HFWFDMZL.js +0 -30
- package/dist/chunk-HFWFDMZL.js.map +0 -1
- package/dist/chunk-J2OQ62DV.js +0 -2
- package/dist/chunk-J2OQ62DV.js.map +0 -1
- package/dist/chunk-LG2XWWAP.js +0 -2
- package/dist/chunk-LG2XWWAP.js.map +0 -1
- package/dist/chunk-MZTKR3LR.js +0 -3
- package/dist/chunk-MZTKR3LR.js.map +0 -1
- package/dist/chunk-PCQEPXO3.mjs +0 -3
- package/dist/chunk-PCQEPXO3.mjs.map +0 -1
- package/dist/chunk-Q6UFPTQC.js +0 -2
- package/dist/chunk-Q6UFPTQC.js.map +0 -1
- package/dist/chunk-SZJXSB7U.mjs +0 -2
- package/dist/chunk-SZJXSB7U.mjs.map +0 -1
- package/dist/chunk-V57JCP3U.mjs +0 -2
- package/dist/chunk-V57JCP3U.mjs.map +0 -1
- package/dist/index.d.mts +0 -12
- package/dist/index.js.map +0 -1
- package/dist/index.mjs +0 -2
- package/dist/index.mjs.map +0 -1
- package/dist/types.d.mts +0 -194
- package/dist/types.mjs +0 -2
- package/dist/types.mjs.map +0 -1
- package/dist/utils/errors.d.mts +0 -41
- package/dist/utils/errors.mjs +0 -2
- package/dist/utils/errors.mjs.map +0 -1
- package/dist/utils/logger.d.mts +0 -25
- package/dist/utils/logger.mjs +0 -2
- package/dist/utils/logger.mjs.map +0 -1
package/dist/types.d.mts
DELETED
|
@@ -1,194 +0,0 @@
|
|
|
1
|
-
import { DuckDBConnection } from '@duckdb/node-api';
|
|
2
|
-
import { Either } from 'functype/either';
|
|
3
|
-
import { List } from 'functype/list';
|
|
4
|
-
|
|
5
|
-
/**
|
|
6
|
-
* Configuration for DuckPond manager
|
|
7
|
-
*/
|
|
8
|
-
interface DuckPondConfig {
|
|
9
|
-
r2?: {
|
|
10
|
-
accountId: string;
|
|
11
|
-
accessKeyId: string;
|
|
12
|
-
secretAccessKey: string;
|
|
13
|
-
bucket: string;
|
|
14
|
-
};
|
|
15
|
-
s3?: {
|
|
16
|
-
region: string;
|
|
17
|
-
accessKeyId: string;
|
|
18
|
-
secretAccessKey: string;
|
|
19
|
-
bucket: string;
|
|
20
|
-
endpoint?: string;
|
|
21
|
-
};
|
|
22
|
-
memoryLimit?: string;
|
|
23
|
-
threads?: number;
|
|
24
|
-
tempDir?: string;
|
|
25
|
-
dataDir?: string;
|
|
26
|
-
maxActiveUsers?: number;
|
|
27
|
-
evictionTimeout?: number;
|
|
28
|
-
cacheType?: "disk" | "memory" | "noop";
|
|
29
|
-
cacheDir?: string;
|
|
30
|
-
strategy?: "parquet" | "duckdb" | "hybrid";
|
|
31
|
-
}
|
|
32
|
-
/**
|
|
33
|
-
* Represents an active user database connection
|
|
34
|
-
*/
|
|
35
|
-
interface UserDatabase {
|
|
36
|
-
userId: string;
|
|
37
|
-
connection: DuckDBConnection;
|
|
38
|
-
lastAccess: Date;
|
|
39
|
-
attached: boolean;
|
|
40
|
-
memoryUsage?: number;
|
|
41
|
-
}
|
|
42
|
-
/**
|
|
43
|
-
* Statistics about a user's database
|
|
44
|
-
*/
|
|
45
|
-
interface UserStats {
|
|
46
|
-
userId: string;
|
|
47
|
-
attached: boolean;
|
|
48
|
-
lastAccess: Date;
|
|
49
|
-
memoryUsage: number;
|
|
50
|
-
storageUsage: number;
|
|
51
|
-
queryCount: number;
|
|
52
|
-
}
|
|
53
|
-
/**
|
|
54
|
-
* Database schema information
|
|
55
|
-
*/
|
|
56
|
-
interface Schema {
|
|
57
|
-
tables: TableSchema[];
|
|
58
|
-
}
|
|
59
|
-
interface TableSchema {
|
|
60
|
-
name: string;
|
|
61
|
-
columns: ColumnSchema[];
|
|
62
|
-
rowCount?: number;
|
|
63
|
-
}
|
|
64
|
-
interface ColumnSchema {
|
|
65
|
-
name: string;
|
|
66
|
-
type: string;
|
|
67
|
-
nullable: boolean;
|
|
68
|
-
}
|
|
69
|
-
/**
|
|
70
|
-
* Options for creating a new user
|
|
71
|
-
*/
|
|
72
|
-
interface CreateUserOptions {
|
|
73
|
-
template?: string;
|
|
74
|
-
initialData?: Record<string, unknown[]>;
|
|
75
|
-
metadata?: Record<string, unknown>;
|
|
76
|
-
}
|
|
77
|
-
/**
|
|
78
|
-
* Storage usage statistics
|
|
79
|
-
*/
|
|
80
|
-
interface StorageStats {
|
|
81
|
-
totalSize: number;
|
|
82
|
-
fileCount: number;
|
|
83
|
-
lastModified: Date;
|
|
84
|
-
files?: FileInfo[];
|
|
85
|
-
}
|
|
86
|
-
interface FileInfo {
|
|
87
|
-
path: string;
|
|
88
|
-
size: number;
|
|
89
|
-
modified: Date;
|
|
90
|
-
}
|
|
91
|
-
/**
|
|
92
|
-
* Query result with metadata
|
|
93
|
-
*/
|
|
94
|
-
interface QueryResult<T = unknown> {
|
|
95
|
-
rows: T[];
|
|
96
|
-
rowCount: number;
|
|
97
|
-
executionTime: number;
|
|
98
|
-
columns: string[];
|
|
99
|
-
}
|
|
100
|
-
/**
|
|
101
|
-
* Metrics for monitoring
|
|
102
|
-
*/
|
|
103
|
-
interface DuckPondMetrics {
|
|
104
|
-
activeUsers: number;
|
|
105
|
-
totalQueries: number;
|
|
106
|
-
avgQueryTime: number;
|
|
107
|
-
cacheHitRate: number;
|
|
108
|
-
memoryUsage: number;
|
|
109
|
-
storageUsage: number;
|
|
110
|
-
}
|
|
111
|
-
/**
|
|
112
|
-
* Events emitted by DuckPond
|
|
113
|
-
*/
|
|
114
|
-
type DuckPondEvent = {
|
|
115
|
-
type: "user:attached";
|
|
116
|
-
userId: string;
|
|
117
|
-
timestamp: Date;
|
|
118
|
-
} | {
|
|
119
|
-
type: "user:detached";
|
|
120
|
-
userId: string;
|
|
121
|
-
reason: "eviction" | "manual";
|
|
122
|
-
timestamp: Date;
|
|
123
|
-
} | {
|
|
124
|
-
type: "query:executed";
|
|
125
|
-
userId: string;
|
|
126
|
-
duration: number;
|
|
127
|
-
timestamp: Date;
|
|
128
|
-
} | {
|
|
129
|
-
type: "query:failed";
|
|
130
|
-
userId: string;
|
|
131
|
-
error: string;
|
|
132
|
-
timestamp: Date;
|
|
133
|
-
} | {
|
|
134
|
-
type: "cache:hit";
|
|
135
|
-
userId: string;
|
|
136
|
-
} | {
|
|
137
|
-
type: "cache:miss";
|
|
138
|
-
userId: string;
|
|
139
|
-
} | {
|
|
140
|
-
type: "error";
|
|
141
|
-
error: Error;
|
|
142
|
-
timestamp: Date;
|
|
143
|
-
};
|
|
144
|
-
/**
|
|
145
|
-
* Type-safe result types using functype Either
|
|
146
|
-
*/
|
|
147
|
-
type DuckPondResult<T> = Either<DuckPondError, T>;
|
|
148
|
-
type AsyncDuckPondResult<T> = Promise<Either<DuckPondError, T>>;
|
|
149
|
-
/**
|
|
150
|
-
* Error types
|
|
151
|
-
*/
|
|
152
|
-
interface DuckPondError {
|
|
153
|
-
code: ErrorCode;
|
|
154
|
-
message: string;
|
|
155
|
-
cause?: Error;
|
|
156
|
-
context?: Record<string, unknown>;
|
|
157
|
-
}
|
|
158
|
-
declare enum ErrorCode {
|
|
159
|
-
CONNECTION_FAILED = "CONNECTION_FAILED",
|
|
160
|
-
CONNECTION_TIMEOUT = "CONNECTION_TIMEOUT",
|
|
161
|
-
R2_CONNECTION_ERROR = "R2_CONNECTION_ERROR",
|
|
162
|
-
S3_CONNECTION_ERROR = "S3_CONNECTION_ERROR",
|
|
163
|
-
USER_NOT_FOUND = "USER_NOT_FOUND",
|
|
164
|
-
USER_ALREADY_EXISTS = "USER_ALREADY_EXISTS",
|
|
165
|
-
USER_NOT_ATTACHED = "USER_NOT_ATTACHED",
|
|
166
|
-
QUERY_EXECUTION_ERROR = "QUERY_EXECUTION_ERROR",
|
|
167
|
-
QUERY_TIMEOUT = "QUERY_TIMEOUT",
|
|
168
|
-
INVALID_SQL = "INVALID_SQL",
|
|
169
|
-
MEMORY_LIMIT_EXCEEDED = "MEMORY_LIMIT_EXCEEDED",
|
|
170
|
-
STORAGE_ERROR = "STORAGE_ERROR",
|
|
171
|
-
STORAGE_QUOTA_EXCEEDED = "STORAGE_QUOTA_EXCEEDED",
|
|
172
|
-
INVALID_CONFIG = "INVALID_CONFIG",
|
|
173
|
-
NOT_INITIALIZED = "NOT_INITIALIZED",
|
|
174
|
-
UNKNOWN_ERROR = "UNKNOWN_ERROR"
|
|
175
|
-
}
|
|
176
|
-
/**
|
|
177
|
-
* Configuration with defaults applied
|
|
178
|
-
*/
|
|
179
|
-
type ResolvedConfig = Required<Omit<DuckPondConfig, "r2" | "s3" | "dataDir"> & {
|
|
180
|
-
r2: DuckPondConfig["r2"];
|
|
181
|
-
s3: DuckPondConfig["s3"];
|
|
182
|
-
dataDir: DuckPondConfig["dataDir"];
|
|
183
|
-
}>;
|
|
184
|
-
/**
|
|
185
|
-
* Result of listUsers operation
|
|
186
|
-
*/
|
|
187
|
-
interface ListUsersResult {
|
|
188
|
-
users: List<string>;
|
|
189
|
-
count: number;
|
|
190
|
-
maxActiveUsers: number;
|
|
191
|
-
utilizationPercent: number;
|
|
192
|
-
}
|
|
193
|
-
|
|
194
|
-
export { type AsyncDuckPondResult, type ColumnSchema, type CreateUserOptions, type DuckPondConfig, type DuckPondError, type DuckPondEvent, type DuckPondMetrics, type DuckPondResult, ErrorCode, type FileInfo, type ListUsersResult, type QueryResult, type ResolvedConfig, type Schema, type StorageStats, type TableSchema, type UserDatabase, type UserStats };
|
package/dist/types.mjs
DELETED
package/dist/types.mjs.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
|
package/dist/utils/errors.d.mts
DELETED
|
@@ -1,41 +0,0 @@
|
|
|
1
|
-
import { Either } from 'functype';
|
|
2
|
-
import { ErrorCode, DuckPondError } from '../types.mjs';
|
|
3
|
-
import '@duckdb/node-api';
|
|
4
|
-
import 'functype/either';
|
|
5
|
-
import 'functype/list';
|
|
6
|
-
|
|
7
|
-
/**
|
|
8
|
-
* Create a DuckPondError as a Left Either
|
|
9
|
-
*/
|
|
10
|
-
declare function createError(code: ErrorCode, message: string, cause?: Error, context?: Record<string, unknown>): Either<DuckPondError, never>;
|
|
11
|
-
/**
|
|
12
|
-
* Wrap a value in a Right Either
|
|
13
|
-
*/
|
|
14
|
-
declare function success<T = void>(value?: T): Either<DuckPondError, T extends void ? void : T>;
|
|
15
|
-
/**
|
|
16
|
-
* Convert an unknown error to a DuckPondError
|
|
17
|
-
*/
|
|
18
|
-
declare function toDuckPondError(error: unknown, defaultCode?: ErrorCode): DuckPondError;
|
|
19
|
-
/**
|
|
20
|
-
* Error factory functions for common errors
|
|
21
|
-
*/
|
|
22
|
-
declare const Errors: {
|
|
23
|
-
connectionFailed: (message: string, cause?: Error) => Either<DuckPondError, never>;
|
|
24
|
-
r2ConnectionError: (message: string, cause?: Error) => Either<DuckPondError, never>;
|
|
25
|
-
s3ConnectionError: (message: string, cause?: Error) => Either<DuckPondError, never>;
|
|
26
|
-
userNotFound: (userId: string) => Either<DuckPondError, never>;
|
|
27
|
-
userAlreadyExists: (userId: string) => Either<DuckPondError, never>;
|
|
28
|
-
userNotAttached: (userId: string) => Either<DuckPondError, never>;
|
|
29
|
-
queryExecutionError: (message: string, sql?: string, cause?: Error) => Either<DuckPondError, never>;
|
|
30
|
-
queryTimeout: (timeoutMs: number) => Either<DuckPondError, never>;
|
|
31
|
-
memoryLimitExceeded: (limit: string) => Either<DuckPondError, never>;
|
|
32
|
-
storageError: (message: string, cause?: Error) => Either<DuckPondError, never>;
|
|
33
|
-
invalidConfig: (message: string) => Either<DuckPondError, never>;
|
|
34
|
-
notInitialized: () => Either<DuckPondError, never>;
|
|
35
|
-
};
|
|
36
|
-
/**
|
|
37
|
-
* Format an error for logging
|
|
38
|
-
*/
|
|
39
|
-
declare function formatError(error: DuckPondError): string;
|
|
40
|
-
|
|
41
|
-
export { Errors, createError, formatError, success, toDuckPondError };
|
package/dist/utils/errors.mjs
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
|
package/dist/utils/logger.d.mts
DELETED
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
import debug from 'debug';
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* Create a namespaced logger for DuckPond
|
|
5
|
-
*
|
|
6
|
-
* Usage:
|
|
7
|
-
* const log = createLogger('DuckPond')
|
|
8
|
-
* log('Initializing...')
|
|
9
|
-
*
|
|
10
|
-
* Enable with: DEBUG=duckpond:* node app.js
|
|
11
|
-
*/
|
|
12
|
-
declare function createLogger(namespace: string): debug.Debugger;
|
|
13
|
-
/**
|
|
14
|
-
* Pre-configured loggers for different modules
|
|
15
|
-
*/
|
|
16
|
-
declare const loggers: {
|
|
17
|
-
main: debug.Debugger;
|
|
18
|
-
cache: debug.Debugger;
|
|
19
|
-
connection: debug.Debugger;
|
|
20
|
-
query: debug.Debugger;
|
|
21
|
-
storage: debug.Debugger;
|
|
22
|
-
metrics: debug.Debugger;
|
|
23
|
-
};
|
|
24
|
-
|
|
25
|
-
export { createLogger, loggers };
|
package/dist/utils/logger.mjs
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
|