@deessejs/collections 0.0.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 +60 -0
- package/src/adapter.ts +38 -0
- package/src/collection.ts +138 -0
- package/src/config.ts +134 -0
- package/src/field-type.ts +40 -0
- package/src/field.ts +46 -0
- package/src/fields/f.ts +192 -0
- package/src/fields/index.ts +1 -0
- package/src/index.ts +27 -0
- package/src/migrations.ts +49 -0
- package/src/operations/collection-operations.ts +808 -0
- package/src/operations/index.ts +2 -0
- package/src/operations/types.ts +141 -0
- package/src/schema.ts +62 -0
- package/tests/adapter.test.ts +35 -0
- package/tests/collection.test.ts +205 -0
- package/tests/config.test.ts +58 -0
- package/tests/field-type.test.ts +181 -0
- package/tests/field.test.ts +201 -0
- package/tests/fixtures.ts +44 -0
- package/tests/hooks.test.ts +1076 -0
- package/tests/integration/hooks.test.ts +329 -0
- package/tests/metadata.test.ts +200 -0
- package/tests/schema.test.ts +58 -0
- package/tests/type-inference.test.ts +108 -0
- package/tsconfig.json +32 -0
- package/tsup.config.ts +11 -0
- package/vitest.config.ts +29 -0
- package/vitest.integration.config.ts +9 -0
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import type { PgAdapter } from './adapter'
|
|
2
|
+
import type { Collection } from './collection'
|
|
3
|
+
import { buildSchema } from './schema'
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Push schema to database (development mode)
|
|
7
|
+
*
|
|
8
|
+
* Uses drizzle-kit's pushSchema to push schema changes to the database
|
|
9
|
+
*/
|
|
10
|
+
export const push = async (_adapter: PgAdapter, collections: Collection[]) => {
|
|
11
|
+
const schema = buildSchema(collections)
|
|
12
|
+
|
|
13
|
+
// TODO: Implement actual push using drizzle-kit/api
|
|
14
|
+
// import { pushSchema } from 'drizzle-kit/api'
|
|
15
|
+
// const result = await pushSchema(schema, drizzleInstance)
|
|
16
|
+
// await result.apply()
|
|
17
|
+
|
|
18
|
+
console.log('[TODO] Push schema with collections:', Object.keys(schema))
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* Generate migration files
|
|
23
|
+
*
|
|
24
|
+
* Uses drizzle-kit's generateMigration to create migration files
|
|
25
|
+
*/
|
|
26
|
+
export const generate = async (_adapter: PgAdapter, collections: Collection[]) => {
|
|
27
|
+
const schema = buildSchema(collections)
|
|
28
|
+
|
|
29
|
+
// TODO: Implement actual migration generation
|
|
30
|
+
// import { generateMigration, generateDrizzleJson } from 'drizzle-kit/api'
|
|
31
|
+
// const currentSnapshot = generateDrizzleJson(schema)
|
|
32
|
+
// const previousSnapshot = loadPreviousSnapshot()
|
|
33
|
+
// const migration = await generateMigration(previousSnapshot, currentSnapshot)
|
|
34
|
+
// writeMigrationFile(migration)
|
|
35
|
+
|
|
36
|
+
console.log('[TODO] Generate migration with collections:', Object.keys(schema))
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
/**
|
|
40
|
+
* Apply migrations
|
|
41
|
+
*
|
|
42
|
+
* Runs pending migration files against the database
|
|
43
|
+
*/
|
|
44
|
+
export const migrate = async (adapter: PgAdapter) => {
|
|
45
|
+
// TODO: Implement actual migration application
|
|
46
|
+
// Run migration files against the database
|
|
47
|
+
|
|
48
|
+
console.log('[TODO] Apply migrations from:', adapter.config.migrationsPath)
|
|
49
|
+
}
|