@kubun/db-provider 0.9.0 → 0.11.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.
Files changed (2) hide show
  1. package/lib/index.js +29 -1
  2. package/package.json +6 -6
package/lib/index.js CHANGED
@@ -1 +1,29 @@
1
- import{KubunDB as e}from"@kubun/db";import{NodeSQLiteAdapter as r}from"@kubun/db-node-sqlite";import{PostgresAdapter as t}from"@kubun/db-postgres";export function resolveAdapter(e){return"string"!=typeof e?e:":memory:"===e?new r({database:":memory:"}):e.startsWith("postgres://")||e.startsWith("postgresql://")?new t({url:e}):new r({database:e})}export function resolveKubunDB(r){return r instanceof e?r:new e({adapter:resolveAdapter(r)})}
1
+ import { KubunDB } from '@kubun/db';
2
+ import { NodeSQLiteAdapter } from '@kubun/db-node-sqlite';
3
+ import { PostgresAdapter } from '@kubun/db-postgres';
4
+ export function resolveAdapter(input) {
5
+ if (typeof input !== 'string') {
6
+ return input;
7
+ }
8
+ if (input === ':memory:') {
9
+ return new NodeSQLiteAdapter({
10
+ database: ':memory:'
11
+ });
12
+ }
13
+ if (input.startsWith('postgres://') || input.startsWith('postgresql://')) {
14
+ return new PostgresAdapter({
15
+ url: input
16
+ });
17
+ }
18
+ return new NodeSQLiteAdapter({
19
+ database: input
20
+ });
21
+ }
22
+ export function resolveKubunDB(input) {
23
+ if (input instanceof KubunDB) {
24
+ return input;
25
+ }
26
+ return new KubunDB({
27
+ adapter: resolveAdapter(input)
28
+ });
29
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kubun/db-provider",
3
- "version": "0.9.0",
3
+ "version": "0.11.0",
4
4
  "license": "see LICENSE.md",
5
5
  "keywords": [],
6
6
  "type": "module",
@@ -15,14 +15,14 @@
15
15
  ],
16
16
  "sideEffects": false,
17
17
  "dependencies": {
18
- "@kubun/db-node-sqlite": "^0.9.0",
19
- "@kubun/db": "^0.9.0",
20
- "@kubun/db-postgres": "^0.9.0",
21
- "@kubun/db-adapter": "^0.9.0"
18
+ "@kubun/db": "^0.11.0",
19
+ "@kubun/db-postgres": "^0.11.0",
20
+ "@kubun/db-node-sqlite": "^0.11.0",
21
+ "@kubun/db-adapter": "^0.11.0"
22
22
  },
23
23
  "scripts": {
24
24
  "build:clean": "del lib",
25
- "build:js": "swc src -d ./lib --config-file ../../swc.json --strip-leading-paths",
25
+ "build:js": "swc src -d ./lib --config-file ../../node_modules/@kigu/dev/swc.json --strip-leading-paths",
26
26
  "build:types": "tsc --emitDeclarationOnly --skipLibCheck",
27
27
  "build:types:ci": "tsc --emitDeclarationOnly --declarationMap false",
28
28
  "build": "pnpm run build:clean && pnpm run build:js && pnpm run build:types",