@strav/database 0.1.0 → 0.1.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/package.json +1 -1
- package/src/database/database.ts +4 -4
- package/src/database/domain/manager.ts +1 -1
- package/src/database/index.ts +1 -1
- package/src/database/migration/runner.ts +1 -1
- package/src/database/query_builder.ts +2 -2
- package/src/database/seeder.ts +1 -1
- package/src/orm/base_model.ts +4 -4
- package/src/orm/decorators.ts +1 -1
- package/src/providers/database_provider.ts +2 -2
- package/src/schema/naming.ts +1 -1
- package/src/schema/type_builder.ts +1 -1
package/package.json
CHANGED
package/src/database/database.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { SQL } from 'bun'
|
|
2
|
-
import Configuration from '@
|
|
3
|
-
import { inject } from '@
|
|
4
|
-
import { ConfigurationError } from '@
|
|
5
|
-
import { env } from '@
|
|
2
|
+
import Configuration from '@strav/kernel/config/configuration'
|
|
3
|
+
import { inject } from '@strav/kernel/core/inject'
|
|
4
|
+
import { ConfigurationError } from '@strav/kernel/exceptions/errors'
|
|
5
|
+
import { env } from '@strav/kernel/helpers/env'
|
|
6
6
|
import { createSchemaAwareSQL } from './domain/wrapper'
|
|
7
7
|
import { getCurrentSchema, hasSchemaContext } from './domain/context'
|
|
8
8
|
|
|
@@ -3,7 +3,7 @@ import Database from '../database'
|
|
|
3
3
|
import MigrationRunner from '../migration/runner'
|
|
4
4
|
import MigrationTracker from '../migration/tracker'
|
|
5
5
|
import { withSchema, withoutSchema } from './context'
|
|
6
|
-
import { inject } from '@
|
|
6
|
+
import { inject } from '@strav/kernel/core/inject'
|
|
7
7
|
|
|
8
8
|
/**
|
|
9
9
|
* Schema manager for multi-domain database operations.
|
package/src/database/index.ts
CHANGED
|
@@ -16,7 +16,7 @@ export * from './domain/index'
|
|
|
16
16
|
* Available after the Database is resolved through the DI container.
|
|
17
17
|
*
|
|
18
18
|
* @example
|
|
19
|
-
* import { sql } from '@
|
|
19
|
+
* import { sql } from '@strav/database/database'
|
|
20
20
|
* const rows = await sql`SELECT * FROM "user" WHERE "id" = ${id}`
|
|
21
21
|
* await sql.begin(async (tx) => { ... })
|
|
22
22
|
*/
|
|
@@ -3,7 +3,7 @@ import { readdirSync } from 'node:fs'
|
|
|
3
3
|
import type Database from '../database'
|
|
4
4
|
import type MigrationTracker from './tracker'
|
|
5
5
|
import type { MigrationManifest } from './types'
|
|
6
|
-
import { DatabaseError } from '@
|
|
6
|
+
import { DatabaseError } from '@strav/kernel/exceptions/errors'
|
|
7
7
|
import { getMigrationTableName } from '../../schema/domain_discovery'
|
|
8
8
|
|
|
9
9
|
export interface RunResult {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { DateTime } from 'luxon'
|
|
2
|
-
import { toSnakeCase } from '@
|
|
2
|
+
import { toSnakeCase } from '@strav/kernel/helpers/strings'
|
|
3
3
|
import type BaseModel from '../orm/base_model'
|
|
4
|
-
import { ModelNotFoundError } from '@
|
|
4
|
+
import { ModelNotFoundError } from '@strav/kernel/exceptions/errors'
|
|
5
5
|
import { getReferenceMeta, getAssociates, getCasts } from '../orm/decorators'
|
|
6
6
|
import type { ReferenceMetadata, AssociateMetadata, CastDefinition } from '../orm/decorators'
|
|
7
7
|
import { hydrateRow } from '../orm/base_model'
|
package/src/database/seeder.ts
CHANGED
|
@@ -8,7 +8,7 @@ import Database from './database'
|
|
|
8
8
|
* main `DatabaseSeeder`.
|
|
9
9
|
*
|
|
10
10
|
* @example
|
|
11
|
-
* import { Seeder } from '@
|
|
11
|
+
* import { Seeder } from '@strav/database/database'
|
|
12
12
|
*
|
|
13
13
|
* export default class DatabaseSeeder extends Seeder {
|
|
14
14
|
* async run(): Promise<void> {
|
package/src/orm/base_model.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { DateTime } from 'luxon'
|
|
2
|
-
import { toSnakeCase, toCamelCase } from '@
|
|
3
|
-
import { ulid as generateUlid } from '@
|
|
4
|
-
import { inject } from '@
|
|
2
|
+
import { toSnakeCase, toCamelCase } from '@strav/kernel/helpers/strings'
|
|
3
|
+
import { ulid as generateUlid } from '@strav/kernel/helpers'
|
|
4
|
+
import { inject } from '@strav/kernel/core/inject'
|
|
5
5
|
import {
|
|
6
6
|
getPrimaryKey,
|
|
7
7
|
getReferences,
|
|
@@ -13,7 +13,7 @@ import {
|
|
|
13
13
|
} from './decorators'
|
|
14
14
|
import type { ReferenceMetadata, AssociateMetadata } from './decorators'
|
|
15
15
|
import Database from '../database/database'
|
|
16
|
-
import { ConfigurationError, ModelNotFoundError } from '@
|
|
16
|
+
import { ConfigurationError, ModelNotFoundError } from '@strav/kernel/exceptions/errors'
|
|
17
17
|
|
|
18
18
|
type ModelStatic<T extends BaseModel> = (new (...args: any[]) => T) & typeof BaseModel
|
|
19
19
|
|
package/src/orm/decorators.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import 'reflect-metadata'
|
|
2
|
-
import EncryptionManager from '@
|
|
2
|
+
import EncryptionManager from '@strav/kernel/encryption/encryption_manager'
|
|
3
3
|
|
|
4
4
|
const PRIMARY_KEY = Symbol('orm:primary')
|
|
5
5
|
const REFERENCE_KEY = Symbol('orm:references')
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import ServiceProvider from '@
|
|
2
|
-
import type Application from '@
|
|
1
|
+
import ServiceProvider from '@strav/kernel/core/service_provider'
|
|
2
|
+
import type Application from '@strav/kernel/core/application'
|
|
3
3
|
import Database from '../database/database'
|
|
4
4
|
|
|
5
5
|
export default class DatabaseProvider extends ServiceProvider {
|
package/src/schema/naming.ts
CHANGED
|
@@ -8,7 +8,7 @@ import FieldBuilder from './field_builder'
|
|
|
8
8
|
* Each method returns a {@link FieldBuilder} with the correct pgType pre-configured.
|
|
9
9
|
*
|
|
10
10
|
* @example
|
|
11
|
-
* import { t } from '@
|
|
11
|
+
* import { t } from '@strav/database/schema'
|
|
12
12
|
* t.varchar(255).email().unique().required()
|
|
13
13
|
* t.integer().default(0)
|
|
14
14
|
* t.jsonb().nullable()
|