@platformatic/sql-mapper 0.30.1 → 0.31.1
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/mapper.d.ts +6 -5
- package/package.json +2 -2
- package/test/types/mapper.test-d.ts +5 -5
package/mapper.d.ts
CHANGED
|
@@ -242,13 +242,14 @@ export interface Entity<EntityFields = any> {
|
|
|
242
242
|
count: Count,
|
|
243
243
|
}
|
|
244
244
|
|
|
245
|
+
type EntityHook<T extends (...args: any) => any> = (original: T, ...options: Parameters<T>) => ReturnType<T>;
|
|
245
246
|
|
|
246
247
|
export interface EntityHooks<EntityFields = any> {
|
|
247
|
-
find?: Find<EntityFields
|
|
248
|
-
insert?: Insert<EntityFields
|
|
249
|
-
save?: Save<EntityFields
|
|
250
|
-
delete?: Delete<EntityFields
|
|
251
|
-
count?: Count
|
|
248
|
+
find?: EntityHook<Find<EntityFields>>,
|
|
249
|
+
insert?: EntityHook<Insert<EntityFields>>,
|
|
250
|
+
save?: EntityHook<Save<EntityFields>>,
|
|
251
|
+
delete?: EntityHook<Delete<EntityFields>>,
|
|
252
|
+
count?: EntityHook<Count>,
|
|
252
253
|
}
|
|
253
254
|
|
|
254
255
|
export interface SQLMapperPluginOptions {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@platformatic/sql-mapper",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.31.1",
|
|
4
4
|
"description": "A data mapper utility for SQL databases",
|
|
5
5
|
"main": "mapper.js",
|
|
6
6
|
"types": "mapper.d.ts",
|
|
@@ -29,7 +29,7 @@
|
|
|
29
29
|
"camelcase": "^6.3.0",
|
|
30
30
|
"fastify-plugin": "^4.5.0",
|
|
31
31
|
"inflected": "^2.1.0",
|
|
32
|
-
"@platformatic/types": "0.
|
|
32
|
+
"@platformatic/types": "0.31.1"
|
|
33
33
|
},
|
|
34
34
|
"tsd": {
|
|
35
35
|
"directory": "test/types"
|
|
@@ -42,11 +42,11 @@ expectType<Partial<EntityFields>[]>(await entity.delete())
|
|
|
42
42
|
expectType<number>(await entity.count())
|
|
43
43
|
|
|
44
44
|
const entityHooks: EntityHooks = {
|
|
45
|
-
async find(options:
|
|
46
|
-
async insert(
|
|
47
|
-
async save(
|
|
48
|
-
async delete(
|
|
49
|
-
async count(
|
|
45
|
+
async find(originalFind: typeof entity.find, ...options: Parameters<typeof entity.find>): ReturnType<typeof entity.find> { return [] },
|
|
46
|
+
async insert(originalInsert: typeof entity.insert, ...options: Parameters<typeof entity.insert>): ReturnType<typeof entity.insert> { return [] },
|
|
47
|
+
async save(originalSave: typeof entity.save, ...options: Parameters<typeof entity.save>): ReturnType<typeof entity.save> { return {} },
|
|
48
|
+
async delete(originalDelete: typeof entity.delete, ...options: Parameters<typeof entity.delete>): ReturnType<typeof entity.delete> { return [] },
|
|
49
|
+
async count(originalCount: typeof entity.count, ...options: Parameters<typeof entity.count>): ReturnType<typeof entity.count> { return 0 },
|
|
50
50
|
}
|
|
51
51
|
expectType<EntityHooks>(entityHooks)
|
|
52
52
|
expectType<SQLMapperPluginInterface>(await connect({ connectionString: '' }))
|