@holo-js/db 0.2.5 → 0.3.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.
- package/dist/chunk-2URJWY4D.mjs +35 -0
- package/dist/config.d.ts +18 -0
- package/dist/config.mjs +10 -0
- package/dist/index.d.ts +340 -207
- package/dist/index.mjs +4874 -2589
- package/package.json +11 -20
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
// src/databaseConfig.ts
|
|
2
|
+
import { registerConfigNormalizer } from "@holo-js/config/registry";
|
|
3
|
+
var holoDatabaseDefaults = Object.freeze({
|
|
4
|
+
defaultConnection: "default",
|
|
5
|
+
connections: Object.freeze({
|
|
6
|
+
default: Object.freeze({
|
|
7
|
+
driver: "sqlite",
|
|
8
|
+
url: "./data/database.sqlite",
|
|
9
|
+
schema: "public",
|
|
10
|
+
logging: false
|
|
11
|
+
})
|
|
12
|
+
})
|
|
13
|
+
});
|
|
14
|
+
function defineDatabaseConfig(config) {
|
|
15
|
+
return Object.freeze({ ...config });
|
|
16
|
+
}
|
|
17
|
+
function normalizeDatabaseConfig(config = {}) {
|
|
18
|
+
const configuredConnections = config.connections;
|
|
19
|
+
const connections = configuredConnections && Object.keys(configuredConnections).length > 0 ? Object.freeze({ ...configuredConnections }) : holoDatabaseDefaults.connections;
|
|
20
|
+
const defaultConnection = config.defaultConnection ?? Object.keys(connections)[0];
|
|
21
|
+
return Object.freeze({
|
|
22
|
+
defaultConnection,
|
|
23
|
+
connections
|
|
24
|
+
});
|
|
25
|
+
}
|
|
26
|
+
registerConfigNormalizer({
|
|
27
|
+
name: "database",
|
|
28
|
+
normalize: normalizeDatabaseConfig
|
|
29
|
+
});
|
|
30
|
+
|
|
31
|
+
export {
|
|
32
|
+
holoDatabaseDefaults,
|
|
33
|
+
defineDatabaseConfig,
|
|
34
|
+
normalizeDatabaseConfig
|
|
35
|
+
};
|
package/dist/config.d.ts
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { HoloProjectConnectionConfig, HoloProjectDatabaseConfig } from '@holo-js/kernel';
|
|
2
|
+
|
|
3
|
+
type HoloDatabaseConnectionConfig = HoloProjectConnectionConfig;
|
|
4
|
+
type HoloDatabaseConfig = HoloProjectDatabaseConfig;
|
|
5
|
+
interface NormalizedHoloDatabaseConfig {
|
|
6
|
+
readonly defaultConnection?: string;
|
|
7
|
+
readonly connections: Readonly<Record<string, HoloDatabaseConnectionConfig | string>>;
|
|
8
|
+
}
|
|
9
|
+
declare module '@holo-js/config' {
|
|
10
|
+
interface HoloConfigRegistry {
|
|
11
|
+
database: NormalizedHoloDatabaseConfig;
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
declare const holoDatabaseDefaults: Readonly<NormalizedHoloDatabaseConfig>;
|
|
15
|
+
declare function defineDatabaseConfig<TConfig extends HoloDatabaseConfig>(config: TConfig): Readonly<TConfig>;
|
|
16
|
+
declare function normalizeDatabaseConfig(config?: HoloDatabaseConfig): NormalizedHoloDatabaseConfig;
|
|
17
|
+
|
|
18
|
+
export { type HoloDatabaseConfig, type HoloDatabaseConnectionConfig, type NormalizedHoloDatabaseConfig, defineDatabaseConfig, holoDatabaseDefaults, normalizeDatabaseConfig };
|