@jazim/test 2.0.3 → 2.0.5

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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@jazim/test",
3
- "version": "2.0.3",
3
+ "version": "2.0.5",
4
4
  "description": "TypeORM adapter for Better-Auth",
5
5
  "main": "./dist/index.js",
6
6
  "module": "./dist/index.mjs",
@@ -13,19 +13,15 @@
13
13
  }
14
14
  },
15
15
  "files": [
16
- "dist"
16
+ "dist",
17
+ "templates"
17
18
  ],
18
19
  "scripts": {
19
20
  "build": "tsup",
20
21
  "dev": "tsup --watch",
21
22
  "test": "vitest",
22
23
  "prepublishOnly": "pnpm run build",
23
- "typeorm": "typeorm-ts-node-commonjs",
24
- "migration:generate": "npm run typeorm -- migration:generate -d ./typeorm.config.ts",
25
- "migration:create": "npm run typeorm -- migration:create",
26
- "migration:up": "npm run typeorm -- migration:run -d ./typeorm.config.ts",
27
- "migration:undo": "npm run typeorm -- migration:revert -d ./typeorm.config.ts",
28
- "migration:show": "npm run typeorm -- migration:show -d ./typeorm.config.ts"
24
+ "local:run": "env-cmd tsx tests/local.ts"
29
25
  },
30
26
  "keywords": [
31
27
  "better-auth",
@@ -41,16 +37,19 @@
41
37
  "typeorm": ">=0.3.2"
42
38
  },
43
39
  "devDependencies": {
40
+ "@types/ejs": "^3.1.5",
44
41
  "@types/node": "^25.0.3",
42
+ "better-sqlite3": "^12.5.0",
43
+ "env-cmd": "^11.0.0",
45
44
  "prettier": "^3.7.4",
46
45
  "ts-node": "^10.9.2",
47
46
  "tsup": "^8.0.1",
48
47
  "tsx": "^4.21.0",
49
48
  "typescript": "^5.3.3",
50
- "vitest": "^4.0.16",
51
- "better-sqlite3": "^12.5.0"
49
+ "vitest": "^4.0.16"
52
50
  },
53
51
  "dependencies": {
52
+ "ejs": "^3.1.9",
54
53
  "handlebars": "^4.7.8"
55
54
  }
56
55
  }
@@ -0,0 +1,19 @@
1
+ import { Entity, PrimaryGeneratedColumn, Column, Index } from "typeorm";
2
+
3
+ <% tables.forEach(function(table){ %>
4
+ @Entity("<%= table.name %>")
5
+ export class <%= table.entityName %> {
6
+ @PrimaryGeneratedColumn("uuid")
7
+ id!: string;
8
+ <% table.columns.forEach(function(column){ %>
9
+ <% if (column.isUnique) { %>
10
+ @Index({ unique: true })
11
+ <% } else if (column.isIndexed) { %>
12
+ @Index()
13
+ <% } %>
14
+ @Column("<%= column.type %>"<% if (column.isNullable) { %>, { nullable: true }<% } %>)
15
+ <%= column.name %><% if (column.isNullable) { %>?: <%= column.tsType %><% } else { %>!: <%= column.tsType %><% } %>;
16
+ <% }) %>
17
+ }
18
+
19
+ <% }) %>
@@ -0,0 +1,49 @@
1
+ import { MigrationInterface, QueryRunner, Table } from "typeorm";
2
+
3
+ export class BetterAuthMigration<%= timestamp %> implements MigrationInterface {
4
+ public async up(queryRunner: QueryRunner): Promise<void> {
5
+ <% tables.forEach(function(table){ %>
6
+ await queryRunner.createTable(
7
+ new Table({
8
+ name: "<%= table.name %>",
9
+ columns: [
10
+ <% (table.columns || []).forEach(function(col){ %>
11
+ {
12
+ name: "<%= col.name %>",
13
+ type: "<%= col.isPrimary ? 'varchar' : col.type %>",
14
+ <% if (col.isPrimary) { %>isPrimary: true,<% } %>
15
+ <% if (typeof col.isNullable !== 'undefined' && col.isNullable !== null) { %>isNullable: <%= col.isNullable %>,<% } %>
16
+ <% if (col.length) { %>length: "<%= col.length %>",<% } %>
17
+ <% if (col.default !== undefined) { %>default: <%= col.default %>,<% } %>
18
+ },
19
+ <% }) %>
20
+ ]<% if (table.indices && table.indices.length) { %>,
21
+ indices: [
22
+ <% table.indices.forEach(function(index){ %>
23
+ {
24
+ columnNames: [<%- index.columnNames.map(function(n){ return '"'+n+'"'; }).join(', ') %>],
25
+ isUnique: <%= index.isUnique %>
26
+ },
27
+ <% }) %>
28
+ ]<% } %><% if (table.fkConstraints && table.fkConstraints.length) { %>,
29
+ foreignKeys: [
30
+ <% table.fkConstraints.forEach(function(fk){ %>
31
+ {
32
+ columnNames: [<%- fk.columnNames.map(function(n){ return '"'+n+'"'; }).join(', ') %>],
33
+ referencedTableName: "<%= fk.referencedTableName %>",
34
+ referencedColumnNames: [<%- fk.referencedColumnNames.map(function(n){ return '"'+n+'"'; }).join(', ') %>],
35
+ onDelete: "<%= fk.onDelete %>"
36
+ },
37
+ <% }) %>
38
+ ]<% } %>
39
+ })
40
+ );
41
+ <% }) %>
42
+ }
43
+
44
+ public async down(queryRunner: QueryRunner): Promise<void> {
45
+ <% tablesReversed.forEach(function(table){ %>
46
+ await queryRunner.dropTable("<%= table.name %>");
47
+ <% }) %>
48
+ }
49
+ }