@dungarees/datasource 0.11.4

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 (39) hide show
  1. package/fake.d.ts +35 -0
  2. package/fake.js +51 -0
  3. package/fake.test.d.ts +1 -0
  4. package/fake.test.js +558 -0
  5. package/helpers.d.ts +2 -0
  6. package/helpers.js +4 -0
  7. package/migration/inmemory-migrator.d.ts +2 -0
  8. package/migration/inmemory-migrator.js +126 -0
  9. package/migration/kysely-migrator.d.ts +2 -0
  10. package/migration/kysely-migrator.js +6 -0
  11. package/migration/migration.d.ts +4 -0
  12. package/migration/migration.js +5 -0
  13. package/migration/provider.d.ts +5 -0
  14. package/migration/provider.js +39 -0
  15. package/migration/service.d.ts +2 -0
  16. package/migration/service.js +24 -0
  17. package/migration/type.d.ts +48 -0
  18. package/migration/type.js +1 -0
  19. package/package.json +510 -0
  20. package/postgres/fake.d.ts +2 -0
  21. package/postgres/fake.js +45 -0
  22. package/postgres/service.d.ts +11 -0
  23. package/postgres/service.js +23 -0
  24. package/service.d.ts +2 -0
  25. package/service.js +1 -0
  26. package/service.test.d.ts +1 -0
  27. package/service.test.js +37 -0
  28. package/test-migrations/001-test-migration.d.ts +2 -0
  29. package/test-migrations/001-test-migration.js +13 -0
  30. package/test-migrations/002-test-migration.d.ts +2 -0
  31. package/test-migrations/002-test-migration.js +9 -0
  32. package/test-migrations/003-test-migration.d.ts +2 -0
  33. package/test-migrations/003-test-migration.js +9 -0
  34. package/test-migrations-with-error/001-test-migration.d.ts +2 -0
  35. package/test-migrations-with-error/001-test-migration.js +13 -0
  36. package/test-migrations-with-error/002-test-migration.d.ts +2 -0
  37. package/test-migrations-with-error/002-test-migration.js +10 -0
  38. package/type.d.ts +5 -0
  39. package/type.js +1 -0
@@ -0,0 +1,2 @@
1
+ declare const _default: any;
2
+ export default _default;
@@ -0,0 +1,13 @@
1
+ import { createMigration } from '../migration/migration.js';
2
+ export default createMigration({
3
+ up: async (db) => {
4
+ await db.schema
5
+ .createTable('table1')
6
+ .addColumn('id', 'serial', (col) => col.primaryKey())
7
+ .addColumn('name', 'varchar', (col) => col.notNull())
8
+ .execute();
9
+ },
10
+ down: async (db) => {
11
+ await db.schema.dropTable('table1').execute();
12
+ },
13
+ });
@@ -0,0 +1,2 @@
1
+ declare const _default: any;
2
+ export default _default;
@@ -0,0 +1,9 @@
1
+ import { createMigration } from '../migration/migration.js';
2
+ export default createMigration({
3
+ up: async (db) => {
4
+ await db.insertInto('table1').values({ name: 'test1' }).execute();
5
+ },
6
+ down: async (db) => {
7
+ await db.deleteFrom('table1').where('name', '=', 'test1').execute();
8
+ },
9
+ });
@@ -0,0 +1,2 @@
1
+ declare const _default: any;
2
+ export default _default;
@@ -0,0 +1,9 @@
1
+ import { createMigration } from '../migration/migration.js';
2
+ export default createMigration({
3
+ up: async (db) => {
4
+ await db.insertInto('table1').values({ name: 'test2' }).execute();
5
+ },
6
+ down: async (db) => {
7
+ await db.deleteFrom('table1').where('name', '=', 'test2').execute();
8
+ },
9
+ });
@@ -0,0 +1,2 @@
1
+ declare const _default: any;
2
+ export default _default;
@@ -0,0 +1,13 @@
1
+ import { createMigration } from '../migration/migration.js';
2
+ export default createMigration({
3
+ up: async (db) => {
4
+ await db.schema
5
+ .createTable('table1')
6
+ .addColumn('id', 'serial', (col) => col.primaryKey())
7
+ .addColumn('name', 'varchar', (col) => col.notNull())
8
+ .execute();
9
+ },
10
+ down: async (db) => {
11
+ await db.schema.dropTable('table1').execute();
12
+ },
13
+ });
@@ -0,0 +1,2 @@
1
+ declare const _default: any;
2
+ export default _default;
@@ -0,0 +1,10 @@
1
+ import { createMigration } from '../migration/migration.js';
2
+ // Writes to a column that does not exist, so the migrator has a real failure to report.
3
+ export default createMigration({
4
+ up: async (db) => {
5
+ await db.insertInto('table1').values({ name: 'test1', missingColumn: 'boom' }).execute();
6
+ },
7
+ down: async (db) => {
8
+ await db.deleteFrom('table1').where('name', '=', 'test1').execute();
9
+ },
10
+ });
package/type.d.ts ADDED
@@ -0,0 +1,5 @@
1
+ import type { Kysely } from 'kysely';
2
+ export type { Generated, JSONColumnType, QueryResult, Transaction } from 'kysely';
3
+ export type Datasource<SCHEMA> = Kysely<SCHEMA>;
4
+ export type ConnectionBuilder = <SCHEMA>() => Datasource<SCHEMA>;
5
+ export type AnySchema = any;
package/type.js ADDED
@@ -0,0 +1 @@
1
+ export {};