@opensaas/stack-core 0.1.4 → 0.1.6

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.
@@ -70,7 +70,7 @@ describe('getContext', () => {
70
70
  })
71
71
 
72
72
  it('should create context with lowercase db keys', async () => {
73
- const context = getContext(config, mockPrisma, null)
73
+ const context = await getContext(config, mockPrisma, null)
74
74
 
75
75
  expect(context.db).toBeDefined()
76
76
  expect(context.db.user).toBeDefined()
@@ -81,7 +81,7 @@ describe('getContext', () => {
81
81
 
82
82
  it('should include session when provided', async () => {
83
83
  const session = { userId: '123', role: 'admin' }
84
- const context = getContext(config, mockPrisma, session)
84
+ const context = await getContext(config, mockPrisma, session)
85
85
 
86
86
  expect(context.session).toEqual(session)
87
87
  })
@@ -91,7 +91,7 @@ describe('getContext', () => {
91
91
  const mockCreatedUser = { id: '1', name: 'John', email: 'john@example.com' }
92
92
  mockPrisma.user.create.mockResolvedValue(mockCreatedUser)
93
93
 
94
- const context = getContext(config, mockPrisma, null)
94
+ const context = await getContext(config, mockPrisma, null)
95
95
  const result = await context.serverAction({
96
96
  listKey: 'User',
97
97
  action: 'create',
@@ -111,7 +111,7 @@ describe('getContext', () => {
111
111
  mockPrisma.user.findUnique.mockResolvedValue(existingUser)
112
112
  mockPrisma.user.update.mockResolvedValue(mockUpdatedUser)
113
113
 
114
- const context = getContext(config, mockPrisma, null)
114
+ const context = await getContext(config, mockPrisma, null)
115
115
  const result = await context.serverAction({
116
116
  listKey: 'User',
117
117
  action: 'update',
@@ -130,7 +130,7 @@ describe('getContext', () => {
130
130
  mockPrisma.user.findUnique.mockResolvedValue(mockDeletedUser)
131
131
  mockPrisma.user.delete.mockResolvedValue(mockDeletedUser)
132
132
 
133
- const context = getContext(config, mockPrisma, null)
133
+ const context = await getContext(config, mockPrisma, null)
134
134
  const result = await context.serverAction({
135
135
  listKey: 'User',
136
136
  action: 'delete',
@@ -146,7 +146,7 @@ describe('getContext', () => {
146
146
  const mockCreatedPost = { id: '1', title: 'Test Post' }
147
147
  mockPrisma.post.create.mockResolvedValue(mockCreatedPost)
148
148
 
149
- const context = getContext(config, mockPrisma, null)
149
+ const context = await getContext(config, mockPrisma, null)
150
150
  await context.serverAction({
151
151
  listKey: 'Post',
152
152
  action: 'create',
@@ -157,7 +157,7 @@ describe('getContext', () => {
157
157
  })
158
158
 
159
159
  it('should return null for unknown action', async () => {
160
- const context = getContext(config, mockPrisma, null)
160
+ const context = await getContext(config, mockPrisma, null)
161
161
  const result = await context.serverAction({
162
162
  listKey: 'User',
163
163
  action: 'unknown' as unknown as 'create',
@@ -173,7 +173,7 @@ describe('getContext', () => {
173
173
  const mockUser = { id: '1', name: 'John', email: 'john@example.com' }
174
174
  mockPrisma.user.findFirst.mockResolvedValue(mockUser)
175
175
 
176
- const context = getContext(config, mockPrisma, null)
176
+ const context = await getContext(config, mockPrisma, null)
177
177
  const result = await context.db.user.findUnique({ where: { id: '1' } })
178
178
 
179
179
  expect(mockPrisma.user.findFirst).toHaveBeenCalled()
@@ -187,7 +187,7 @@ describe('getContext', () => {
187
187
  ]
188
188
  mockPrisma.user.findMany.mockResolvedValue(mockUsers)
189
189
 
190
- const context = getContext(config, mockPrisma, null)
190
+ const context = await getContext(config, mockPrisma, null)
191
191
  const result = await context.db.user.findMany()
192
192
 
193
193
  expect(mockPrisma.user.findMany).toHaveBeenCalled()
@@ -198,7 +198,7 @@ describe('getContext', () => {
198
198
  const mockUser = { id: '1', name: 'John', email: 'john@example.com' }
199
199
  mockPrisma.user.create.mockResolvedValue(mockUser)
200
200
 
201
- const context = getContext(config, mockPrisma, null)
201
+ const context = await getContext(config, mockPrisma, null)
202
202
  const result = await context.db.user.create({
203
203
  data: { name: 'John', email: 'john@example.com' },
204
204
  })
@@ -213,7 +213,7 @@ describe('getContext', () => {
213
213
  mockPrisma.user.findUnique.mockResolvedValue(existingUser)
214
214
  mockPrisma.user.update.mockResolvedValue(updatedUser)
215
215
 
216
- const context = getContext(config, mockPrisma, null)
216
+ const context = await getContext(config, mockPrisma, null)
217
217
  const result = await context.db.user.update({
218
218
  where: { id: '1' },
219
219
  data: { name: 'John Updated' },
@@ -228,7 +228,7 @@ describe('getContext', () => {
228
228
  mockPrisma.user.findUnique.mockResolvedValue(mockUser)
229
229
  mockPrisma.user.delete.mockResolvedValue(mockUser)
230
230
 
231
- const context = getContext(config, mockPrisma, null)
231
+ const context = await getContext(config, mockPrisma, null)
232
232
  const result = await context.db.user.delete({ where: { id: '1' } })
233
233
 
234
234
  expect(mockPrisma.user.delete).toHaveBeenCalled()
@@ -238,7 +238,7 @@ describe('getContext', () => {
238
238
  it('should delegate count to prisma with access control', async () => {
239
239
  mockPrisma.user.count.mockResolvedValue(5)
240
240
 
241
- const context = getContext(config, mockPrisma, null)
241
+ const context = await getContext(config, mockPrisma, null)
242
242
  const result = await context.db.user.count()
243
243
 
244
244
  expect(mockPrisma.user.count).toHaveBeenCalled()
@@ -112,7 +112,7 @@ describe('Nested Operations - Access Control and Hooks', () => {
112
112
  authorId: '2',
113
113
  })
114
114
 
115
- const context = getContext(testConfig, mockPrisma, { userId: '1' })
115
+ const context = await getContext(testConfig, mockPrisma, { userId: '1' })
116
116
 
117
117
  await context.db.post.update({
118
118
  where: { id: '1' },
@@ -191,7 +191,7 @@ describe('Nested Operations - Access Control and Hooks', () => {
191
191
  title: 'Original Title',
192
192
  })
193
193
 
194
- const context = getContext(testConfig, mockPrisma, null)
194
+ const context = getContext(await testConfig, mockPrisma, null)
195
195
 
196
196
  await expect(
197
197
  context.db.post.update({
@@ -259,7 +259,7 @@ describe('Nested Operations - Access Control and Hooks', () => {
259
259
  authorId: '2',
260
260
  })
261
261
 
262
- const context = getContext(testConfig, mockPrisma, null)
262
+ const context = getContext(await testConfig, mockPrisma, null)
263
263
 
264
264
  await context.db.post.update({
265
265
  where: { id: '1' },
@@ -327,7 +327,7 @@ describe('Nested Operations - Access Control and Hooks', () => {
327
327
  title: 'Original Title',
328
328
  })
329
329
 
330
- const context = getContext(testConfig, mockPrisma, null)
330
+ const context = getContext(await testConfig, mockPrisma, null)
331
331
 
332
332
  await expect(
333
333
  context.db.post.update({
@@ -392,7 +392,7 @@ describe('Nested Operations - Access Control and Hooks', () => {
392
392
  ],
393
393
  })
394
394
 
395
- const context = getContext(testConfig, mockPrisma, null)
395
+ const context = getContext(await testConfig, mockPrisma, null)
396
396
 
397
397
  await context.db.user.findUnique({
398
398
  where: { id: '1' },
@@ -464,7 +464,7 @@ describe('Nested Operations - Access Control and Hooks', () => {
464
464
  },
465
465
  })
466
466
 
467
- const context = getContext(testConfig, mockPrisma, null)
467
+ const context = getContext(await testConfig, mockPrisma, null)
468
468
 
469
469
  const result = await context.db.post.findUnique({
470
470
  where: { id: '1' },
@@ -517,7 +517,7 @@ describe('Nested Operations - Access Control and Hooks', () => {
517
517
  // Author should not be included due to access control
518
518
  })
519
519
 
520
- const context = getContext(testConfig, mockPrisma, null)
520
+ const context = getContext(await testConfig, mockPrisma, null)
521
521
 
522
522
  await context.db.post.findUnique({
523
523
  where: { id: '1' },
@@ -576,7 +576,7 @@ describe('Nested Operations - Access Control and Hooks', () => {
576
576
  internalNotes: 'New secret notes',
577
577
  })
578
578
 
579
- const context = getContext(testConfig, mockPrisma, null)
579
+ const context = getContext(await testConfig, mockPrisma, null)
580
580
 
581
581
  const result = await context.db.post.update({
582
582
  where: { id: '1' },
@@ -630,7 +630,7 @@ describe('Nested Operations - Access Control and Hooks', () => {
630
630
  title: 'updated title',
631
631
  })
632
632
 
633
- const context = getContext(testConfig, mockPrisma, null)
633
+ const context = getContext(await testConfig, mockPrisma, null)
634
634
 
635
635
  const result = await context.db.post.update({
636
636
  where: { id: '1' },
@@ -693,7 +693,7 @@ describe('Nested Operations - Access Control and Hooks', () => {
693
693
  authorId: '2',
694
694
  })
695
695
 
696
- const context = getContext(testConfig, mockPrisma, null)
696
+ const context = getContext(await testConfig, mockPrisma, null)
697
697
 
698
698
  const result = await context.db.post.update({
699
699
  where: { id: '1' },
@@ -762,7 +762,7 @@ describe('Nested Operations - Access Control and Hooks', () => {
762
762
  name: 'Other User',
763
763
  })
764
764
 
765
- const context = getContext(testConfig, mockPrisma, { userId: '1' })
765
+ const context = getContext(await testConfig, mockPrisma, { userId: '1' })
766
766
 
767
767
  await expect(
768
768
  context.db.post.update({
@@ -825,7 +825,7 @@ describe('Nested Operations - Access Control and Hooks', () => {
825
825
  authorId: '2',
826
826
  })
827
827
 
828
- const context = getContext(testConfig, mockPrisma, { userId: '1' })
828
+ const context = getContext(await testConfig, mockPrisma, { userId: '1' })
829
829
 
830
830
  const result = await context.db.post.update({
831
831
  where: { id: '1' },
@@ -883,7 +883,7 @@ describe('Nested Operations - Access Control and Hooks', () => {
883
883
  name: 'John Doe',
884
884
  })
885
885
 
886
- const context = getContext(testConfig, mockPrisma, null)
886
+ const context = getContext(await testConfig, mockPrisma, null)
887
887
 
888
888
  await expect(
889
889
  context.db.post.update({
@@ -62,7 +62,7 @@ describe('Password Field Type Distribution Bug Fix', () => {
62
62
  })
63
63
 
64
64
  it('should NOT make all fields a union of string | HashedPassword', async () => {
65
- const context = getContext(testConfig, mockPrismaClient, null)
65
+ const context = getContext(await testConfig, mockPrismaClient, null)
66
66
 
67
67
  const user = await context.db.user.findUnique({ where: { id: '1' } })
68
68
 
@@ -94,7 +94,7 @@ describe('Password Field Type Distribution Bug Fix', () => {
94
94
  })
95
95
 
96
96
  it('should preserve types with included relationships', async () => {
97
- const context = getContext(testConfig, mockPrismaClient, null)
97
+ const context = getContext(await testConfig, mockPrismaClient, null)
98
98
 
99
99
  const users = await context.db.user.findMany({
100
100
  include: {
@@ -128,7 +128,7 @@ describe('Password Field Type Distribution Bug Fix', () => {
128
128
  })
129
129
 
130
130
  it('should verify TypeScript narrowing works correctly', async () => {
131
- const context = getContext(testConfig, mockPrismaClient, null)
131
+ const context = getContext(await testConfig, mockPrismaClient, null)
132
132
 
133
133
  const user = await context.db.user.findUnique({ where: { id: '1' } })
134
134
 
@@ -59,7 +59,7 @@ describe('Password Field Type Safety', () => {
59
59
  })
60
60
 
61
61
  it('should transform password field to HashedPassword type in findUnique', async () => {
62
- const context = getContext(testConfig, mockPrismaClient, null)
62
+ const context = getContext(await testConfig, mockPrismaClient, null)
63
63
 
64
64
  const user = await context.db.user.findUnique({ where: { id: '1' } })
65
65
 
@@ -77,7 +77,7 @@ describe('Password Field Type Safety', () => {
77
77
  })
78
78
 
79
79
  it('should transform password field to HashedPassword type in findMany', async () => {
80
- const context = getContext(testConfig, mockPrismaClient, null)
80
+ const context = await getContext(await testConfig, mockPrismaClient, null)
81
81
 
82
82
  const users = await context.db.user.findMany()
83
83
 
@@ -96,7 +96,7 @@ describe('Password Field Type Safety', () => {
96
96
  })
97
97
 
98
98
  it('should transform password field to HashedPassword type in create', async () => {
99
- const context = getContext(testConfig, mockPrismaClient, null)
99
+ const context = getContext(await testConfig, mockPrismaClient, null)
100
100
 
101
101
  const user = await context.db.user.create({
102
102
  data: {
@@ -114,7 +114,7 @@ describe('Password Field Type Safety', () => {
114
114
  })
115
115
 
116
116
  it('should transform password field to HashedPassword type in update', async () => {
117
- const context = getContext(testConfig, mockPrismaClient, null)
117
+ const context = getContext(await testConfig, mockPrismaClient, null)
118
118
 
119
119
  const user = await context.db.user.update({
120
120
  where: { id: '1' },
@@ -132,7 +132,7 @@ describe('Password Field Type Safety', () => {
132
132
  })
133
133
 
134
134
  it('should allow checking the HashedPassword type explicitly', async () => {
135
- const context = getContext(testConfig, mockPrismaClient, null)
135
+ const context = getContext(await testConfig, mockPrismaClient, null)
136
136
 
137
137
  const user = await context.db.user.findUnique({ where: { id: '1' } })
138
138