Skip to content

Commit ebd0230

Browse files
committed
chore: wip
chore: wip
1 parent b2a0ee8 commit ebd0230

File tree

17 files changed

+2309
-3135
lines changed

17 files changed

+2309
-3135
lines changed

bun.lockb

752 Bytes
Binary file not shown.

resources/modules/i18n.ts

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,6 @@ import type { UserModule } from '@stacksjs/types'
44

55
// Import i18n resources
66
// https://vitejs.dev/guide/features.html#glob-import
7-
//
8-
// Don't need this? Try vitesse-lite: https://github.com/antfu/vitesse-lite
97
const i18n = createI18n({
108
legacy: false,
119
locale: '',
@@ -38,7 +36,7 @@ export async function loadLanguageAsync(lang: string): Promise<Locale> {
3836
return setI18nLanguage(lang)
3937

4038
// If the language hasn't been loaded yet
41-
const messages = await localesMap[lang]()
39+
const messages = await localesMap[lang]!()
4240
i18n.global.setLocaleMessage(lang, messages.default)
4341
loadedLanguages.push(lang)
4442
return setI18nLanguage(lang)

storage/framework/core/actions/src/copy-types.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,5 +18,5 @@ destinations.forEach(([src, dest]) => {
1818
// const srcPath = resolve(__filename, '..', src)
1919
// const destPath = resolve(__filename, '..', dest)
2020

21-
copyFolder(src, dest)
21+
copyFolder(src!, dest!)
2222
})

storage/framework/core/arrays/src/helpers.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -74,12 +74,12 @@ export function partition<T>(array: readonly T[], ...filters: PartitionFilter<T>
7474
let i = 0
7575
for (const filter of filters) {
7676
if (filter(e, idx, arr)) {
77-
result[i].push(e)
77+
result[i]!.push(e)
7878
return
7979
}
8080
i += 1
8181
}
82-
result[i].push(e)
82+
result[i]!.push(e)
8383
})
8484
return result
8585
}
Lines changed: 125 additions & 125 deletions
Original file line numberDiff line numberDiff line change
@@ -1,127 +1,113 @@
1-
import { DynamoDB, ListTablesCommand } from '@aws-sdk/client-dynamodb'
2-
import { expect, it } from '@stacksjs/testing'
3-
4-
const dynamodb = new DynamoDB({ region: 'us-east-1' })
5-
6-
describe('dynamoDB test', () => {
7-
it('it should create a table for dynamodb cache', async () => {
8-
await createTable()
9-
})
10-
11-
it('it should set dynamodb cache', async () => {
12-
await set('foo', 'bar')
13-
const value = await get('foo')
14-
expect(value).toBe('bar')
15-
})
16-
17-
it('it should get dynamodb cache', async () => {
18-
await set('foo', 'bar')
19-
const value = await get('foo')
20-
expect(value).toBe('bar')
21-
})
22-
23-
it('it should delete dynamodb cache', async () => {
24-
await set('foo', 'bar')
25-
await remove('foo')
26-
const value = await get('foo')
27-
expect(value).toBe(null)
28-
})
29-
})
30-
31-
async function createTable() {
32-
const tables = await dynamodb.send(new ListTablesCommand({}))
33-
34-
const tableExists = tables.TableNames?.includes('cache')
35-
36-
if (tableExists)
37-
return
38-
39-
const params = {
40-
AttributeDefinitions: [
41-
{
42-
AttributeName: 'key',
43-
AttributeType: 'S',
44-
},
45-
],
46-
KeySchema: [
47-
{
48-
AttributeName: 'key',
49-
KeyType: 'HASH',
50-
},
51-
],
52-
ProvisionedThroughput: {
53-
ReadCapacityUnits: 5,
54-
WriteCapacityUnits: 5,
55-
},
56-
TableName: 'cache',
57-
}
58-
59-
await dynamodb.createTable(params)
60-
}
61-
62-
// TODO: needs to be imported to cache package
63-
async function set(key: string, value: string | number): Promise<void> {
64-
// eslint-disable-next-line no-console
65-
console.log('set', key, value)
66-
return Promise.resolve()
67-
// const valueAttribute = 'value'
68-
// const keyAttribute = 'key'
69-
//
70-
// const params: PutItemCommandInput = {
71-
// TableName: 'cache',
72-
// Item: {
73-
// [keyAttribute]: {
74-
// S: key,
75-
// },
76-
// [valueAttribute]: {
77-
// [getValueType(value)]: serialize(value),
78-
// },
79-
// },
80-
// }
81-
//
82-
// await dynamodb.putItem(params)
83-
}
84-
85-
// TODO: needs to be imported to cache package
86-
async function get(key: string): Promise<string | undefined | null> {
87-
const valueAttribute = 'value'
88-
const keyAttribute = 'key'
89-
90-
const params = {
91-
TableName: 'cache',
92-
Key: {
93-
[keyAttribute]: {
94-
S: key,
95-
},
96-
},
97-
}
98-
99-
const response = await dynamodb.getItem(params)
100-
101-
if (!response.Item)
102-
return null
103-
104-
return response.Item[valueAttribute].S ?? response.Item[valueAttribute].N
105-
}
106-
107-
// TODO: needs to be imported to cache package
108-
async function remove(key: string): Promise<void> {
109-
const keyAttribute = 'key'
110-
111-
const params = {
112-
TableName: 'cache',
113-
Key: {
114-
[keyAttribute]: {
115-
S: key,
116-
},
117-
},
118-
}
119-
120-
await dynamodb.deleteItem(params)
121-
}
122-
123-
// TODO: needs to be imported to cache package
124-
// async function del(key: string): Promise<void> {
1+
// import { DynamoDB, ListTablesCommand } from '@aws-sdk/client-dynamodb'
2+
// import { expect, it } from '@stacksjs/testing'
3+
//
4+
// const dynamodb = new DynamoDB({ region: 'us-east-1' })
5+
//
6+
// describe('dynamoDB test', () => {
7+
// it('it should create a table for dynamodb cache', async () => {
8+
// await createTable()
9+
// })
10+
//
11+
// it('it should set dynamodb cache', async () => {
12+
// await set('foo', 'bar')
13+
// const value = await get('foo')
14+
// expect(value).toBe('bar')
15+
// })
16+
//
17+
// it('it should get dynamodb cache', async () => {
18+
// await set('foo', 'bar')
19+
// const value = await get('foo')
20+
// expect(value).toBe('bar')
21+
// })
22+
//
23+
// it('it should delete dynamodb cache', async () => {
24+
// await set('foo', 'bar')
25+
// await remove('foo')
26+
// const value = await get('foo')
27+
// expect(value).toBe(null)
28+
// })
29+
// })
30+
//
31+
// async function createTable() {
32+
// const tables = await dynamodb.send(new ListTablesCommand({}))
33+
//
34+
// const tableExists = tables.TableNames?.includes('cache')
35+
//
36+
// if (tableExists)
37+
// return
38+
//
39+
// const params = {
40+
// AttributeDefinitions: [
41+
// {
42+
// AttributeName: 'key',
43+
// AttributeType: 'S',
44+
// },
45+
// ],
46+
// KeySchema: [
47+
// {
48+
// AttributeName: 'key',
49+
// KeyType: 'HASH',
50+
// },
51+
// ],
52+
// ProvisionedThroughput: {
53+
// ReadCapacityUnits: 5,
54+
// WriteCapacityUnits: 5,
55+
// },
56+
// TableName: 'cache',
57+
// }
58+
//
59+
// await dynamodb.createTable(params)
60+
// }
61+
//
62+
// // TODO: needs to be imported to cache package
63+
// async function set(key: string, value: string | number): Promise<void> {
64+
// // eslint-disable-next-line no-console
65+
// console.log('set', key, value)
66+
// return Promise.resolve()
67+
// // const valueAttribute = 'value'
68+
// // const keyAttribute = 'key'
69+
// //
70+
// // const params: PutItemCommandInput = {
71+
// // TableName: 'cache',
72+
// // Item: {
73+
// // [keyAttribute]: {
74+
// // S: key,
75+
// // },
76+
// // [valueAttribute]: {
77+
// // [getValueType(value)]: serialize(value),
78+
// // },
79+
// // },
80+
// // }
81+
// //
82+
// // await dynamodb.putItem(params)
83+
// }
84+
//
85+
// // TODO: needs to be imported to cache package
86+
// async function get(key: string): Promise<string | undefined | null> {
87+
// const valueAttribute = 'value'
88+
// const keyAttribute = 'key'
89+
//
90+
// const params = {
91+
// TableName: 'cache',
92+
// Key: {
93+
// [keyAttribute]: {
94+
// S: key,
95+
// },
96+
// },
97+
// }
98+
//
99+
// const response = await dynamodb.getItem(params)
100+
//
101+
// if (!response.Item)
102+
// return null
103+
//
104+
// return response.Item[valueAttribute].S ?? response.Item[valueAttribute].N
105+
// }
106+
//
107+
// // TODO: needs to be imported to cache package
108+
// async function remove(key: string): Promise<void> {
109+
// const keyAttribute = 'key'
110+
//
125111
// const params = {
126112
// TableName: 'cache',
127113
// Key: {
@@ -130,6 +116,20 @@ async function remove(key: string): Promise<void> {
130116
// },
131117
// },
132118
// }
133-
119+
//
134120
// await dynamodb.deleteItem(params)
135121
// }
122+
//
123+
// // TODO: needs to be imported to cache package
124+
// // async function del(key: string): Promise<void> {
125+
// // const params = {
126+
// // TableName: 'cache',
127+
// // Key: {
128+
// // [keyAttribute]: {
129+
// // S: key,
130+
// // },
131+
// // },
132+
// // }
133+
//
134+
// // await dynamodb.deleteItem(params)
135+
// // }

0 commit comments

Comments
 (0)