@sidekick-coder/zenith-kit 0.4.0 → 0.4.2

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": "@sidekick-coder/zenith-kit",
3
- "version": "0.4.0",
3
+ "version": "0.4.2",
4
4
  "license": "MIT",
5
5
  "description": "Package to use with zenith framework",
6
6
  "author": "Henrique Oliveira <henriqueoliwork@gmail.com>",
@@ -67,18 +67,16 @@
67
67
  "build:server": "tsdown",
68
68
  "build:client": "vite build --config vite.client.config.ts",
69
69
  "build:components": "vite build --config vite.components.config.ts",
70
- "build": "npm-run-all -p build:*",
70
+ "build": "npm-run-all build:*",
71
71
  "test:unit": "vitest --project unit",
72
- "test:int": "vitest -p integration",
73
- "test": "npm-run-all -p test:*",
72
+ "test:int": "vitest --project int",
73
+ "test": "npm run test:unit",
74
74
  "release": "node artisan.js release"
75
75
  },
76
76
  "peerDependencies": {
77
- "vue": "^3.5.41",
78
- "vue-router": "^5.0.6",
79
77
  "vee-validate": "^4.15.1",
80
- "reka-ui": "^2.10.3",
81
- "@vueuse/core": "^10.0.0"
78
+ "vue": "^3.5.41",
79
+ "vue-router": "^5.0.6"
82
80
  },
83
81
  "devDependencies": {
84
82
  "@eslint/js": "^9.39.4",
@@ -86,6 +84,7 @@
86
84
  "@faker-js/faker": "^10.4.0",
87
85
  "@microsoft/api-extractor": "^7.58.7",
88
86
  "@types/bcrypt": "^6.0.0",
87
+ "@types/better-sqlite3": "^9.6.0",
89
88
  "@types/cookie-parser": "^1.4.10",
90
89
  "@types/cors": "^2.8.19",
91
90
  "@types/supertest": "^7.2.0",
@@ -3,7 +3,7 @@ import Database from 'better-sqlite3'
3
3
  import { Kysely, SqliteDialect } from 'kysely'
4
4
  import { createTestMigrator } from './createTestMigrator'
5
5
  import container from '#server/facades/container.ts'
6
- import { key } from '#server/facades/database.ts'
6
+ import DatabaseGateway from '#server/gateways/DatabaseGateway.ts'
7
7
 
8
8
  export class TestDb extends Kysely<any> {
9
9
  public migrator: MigratorService
@@ -19,13 +19,13 @@ export class TestDb extends Kysely<any> {
19
19
  }
20
20
 
21
21
  public provide() {
22
- container.set(key, this)
22
+ container.set(DatabaseGateway, this)
23
23
  }
24
24
 
25
25
  public dispose() {
26
26
  this.destroy()
27
27
 
28
- container.unset(key)
28
+ container.unset(DatabaseGateway)
29
29
  }
30
30
 
31
31
  public async setup() {
@@ -2,4 +2,6 @@ import { Kysely } from "kysely";
2
2
 
3
3
  export default class DatabaseGateway<DB> extends Kysely<DB> {
4
4
  public static __container_entry_key = 'DatabaseGateway'
5
+
6
+ public _dialect_identifier: string
5
7
  }
@@ -13,7 +13,7 @@ import { createUser } from '#server/__tests__/helpers/createUser.ts'
13
13
 
14
14
  describe('permissionLoader', () => {
15
15
  const db = createTestDb()
16
-
16
+
17
17
  beforeAll(() => db.setup())
18
18
  afterAll(() => db.teardown())
19
19
 
@@ -21,9 +21,9 @@ describe('permissionLoader', () => {
21
21
  const user = await createUser()
22
22
 
23
23
  const permissions = await permissionRepository.createMany([
24
- { name: 'permission 1', subject: 'user', action: 'read' },
25
- { name: 'permission 2', subject: 'user', action: 'write' },
26
- { name: 'permission 3', subject: 'post', action: 'read' },
24
+ { name: 'permission 1', subject: 'user', action: 'read' },
25
+ { name: 'permission 2', subject: 'user', action: 'write' },
26
+ { name: 'permission 3', subject: 'post', action: 'read' },
27
27
  ])
28
28
 
29
29
  await permissionAssignmentRepository.createMany(permissions.map(permission => ({
@@ -62,9 +62,9 @@ export async function create<T extends keyof Database, O extends CreateOptions<T
62
62
  values
63
63
  }
64
64
 
65
- if (db.driver === 'mysql') {
65
+ if (db._dialect_identifier === 'mysql') {
66
66
  return createMysql(table, parsedOptions)
67
67
  }
68
68
 
69
69
  return createDefault(table, parsedOptions)
70
- }
70
+ }
@@ -2,24 +2,24 @@ import { CreateTableBuilder } from 'kysely'
2
2
  import db from '#server/facades/database.ts'
3
3
 
4
4
  declare module 'kysely' {
5
- interface CreateTableBuilder<TB extends string, C extends string = never> {
6
- addIdColumn<CN extends string = 'id'>(
7
- col?: CN
8
- ): CreateTableBuilder<TB, C | CN>
9
- }
5
+ interface CreateTableBuilder<TB extends string, C extends string = never> {
6
+ addIdColumn<CN extends string = 'id'>(
7
+ col?: CN
8
+ ): CreateTableBuilder<TB, C | CN>
9
+ }
10
10
  }
11
11
 
12
- CreateTableBuilder.prototype.addIdColumn = function (
12
+ CreateTableBuilder.prototype.addIdColumn = function(
13
13
  this: CreateTableBuilder<any, any>,
14
14
  col: string = 'id'
15
15
  ) {
16
- if (db.driver === 'postgresql') {
16
+ if (db._dialect_identifier === 'postgresql') {
17
17
  return this.addColumn(col, 'serial', col => col.primaryKey())
18
18
  }
19
19
 
20
- if (db.driver === 'mysql') {
20
+ if (db._dialect_identifier === 'mysql') {
21
21
  return this.addColumn(col, 'integer', col => col.primaryKey().autoIncrement())
22
22
  }
23
23
 
24
24
  return this.addColumn(col, 'integer', col => col.primaryKey())
25
- }
25
+ }
@@ -82,9 +82,9 @@ export async function update<T extends keyof Database, O extends UpdateOptions<T
82
82
  values
83
83
  }
84
84
 
85
- if (db.driver === 'mysql') {
85
+ if (db._dialect_identifier === 'mysql') {
86
86
  return updateMysql(table, parsedOptions)
87
87
  }
88
88
 
89
89
  return updateDefault(table, parsedOptions)
90
- }
90
+ }
@@ -3,13 +3,13 @@ import {
3
3
  it,
4
4
  expect
5
5
  } from 'vitest'
6
- import EncryptService from './encrypt.service.ts'
6
+ import EncryptService from './EncryptService.ts'
7
7
 
8
8
  describe('EncryptService', () => {
9
9
  it('should encrypt and decrypt text correctly', () => {
10
- const service = new EncryptService()
11
-
12
- service.load('test-secret-key')
10
+ const service = EncryptService.create({
11
+ key: 'test-secret-key',
12
+ })
13
13
 
14
14
  const originalText = 'Hello, World!'
15
15
 
@@ -21,4 +21,4 @@ describe('EncryptService', () => {
21
21
 
22
22
  expect(decrypted).toBe(originalText)
23
23
  })
24
- })
24
+ })
@@ -31,39 +31,6 @@ describe('Router', () => {
31
31
  expect(route).toBeNull()
32
32
  })
33
33
 
34
-
35
- it('should match path with params', () => {
36
- const router = new Router()
37
- const match = router.matchPath('/user/:id', '/user/123')
38
- expect(match).toBe(true)
39
- })
40
-
41
- it('should not match path with different segments', () => {
42
- const router = new Router()
43
- const match = router.matchPath('/user/:id', '/profile/123')
44
- expect(match).toBe(false)
45
- })
46
-
47
- it('should match path with wildcard spread parameter', () => {
48
- const router = new Router()
49
- const match = router.matchPath('/files/*', '/files/documents/folder/file.txt')
50
- expect(match).toBe(true)
51
- })
52
-
53
-
54
- it('should match wildcard at root level', () => {
55
- const router = new Router()
56
- const match = router.matchPath('*', '/any/path/here')
57
- expect(match).toBe(true)
58
- })
59
-
60
-
61
- it('should match empty path with wildcard', () => {
62
- const router = new Router()
63
- const match = router.matchPath('*', '/')
64
- expect(match).toBe(true)
65
- })
66
-
67
34
  it('should add and resolve wildcard route', () => {
68
35
  const router = new Router()
69
36
  const handler = vi.fn()
@@ -32,11 +32,11 @@ export default class ContainerService {
32
32
 
33
33
  const isConstructor = typeof payload !== 'string' && typeof payload !== 'symbol'
34
34
 
35
- if (isConstructor && !(payload as any).__container_entry_key) {
36
- console.warn(`Warning: The constructor ${payload.name} does not have a unique identifier. Consider adding a static property __container_entry_key to avoid potential conflicts.`)
35
+ if (isConstructor && !(payload as any)?.__container_entry_key) {
36
+ console.warn(`Warning: The constructor ${payload?.name || payload} does not have a unique identifier. Consider adding a static property __container_entry_key to avoid potential conflicts.`)
37
37
  }
38
38
 
39
- if (isConstructor && (payload as any).__container_entry_key) {
39
+ if (isConstructor && (payload as any)?.__container_entry_key) {
40
40
  key = (payload as any).__container_entry_key
41
41
  }
42
42
 
package/vitest.config.ts CHANGED
@@ -17,15 +17,13 @@ export default defineConfig({
17
17
  test: {
18
18
  name: 'unit',
19
19
  include: ['**/*.unit.test.ts'],
20
- exclude: ['**/modules/**'],
21
20
  setupFiles: ['src/server/__tests__/setup.ts'],
22
21
  }
23
22
  },
24
23
  {
25
24
  test: {
26
- name: 'integration',
25
+ name: 'int',
27
26
  include: ['**/*.int.test.ts'],
28
- exclude: ['**/modules/**'],
29
27
  testTimeout: 60000, // Increase timeout for integration tests
30
28
  hookTimeout: 60000, // Increase hook timeout for integration tests
31
29
  }