@platformatic/sql-events 0.43.1 → 0.44.0
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/index.d.ts +8 -13
- package/package.json +3 -4
- package/test/types/index.test-d.ts +11 -4
package/index.d.ts
CHANGED
|
@@ -1,16 +1,13 @@
|
|
|
1
|
-
|
|
2
|
-
import { FastifyPluginAsync } from 'fastify'
|
|
1
|
+
import { FastifyInstance } from 'fastify'
|
|
3
2
|
import { Readable } from 'stream'
|
|
4
|
-
import { SQLMapperPluginInterface } from '@platformatic/sql-mapper'
|
|
3
|
+
import { SQLMapperPluginInterface, Entities } from '@platformatic/sql-mapper'
|
|
5
4
|
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
subscribe: (topic: string | string[]) => Promise<Readable>
|
|
9
|
-
}
|
|
5
|
+
export interface SQLEventsPluginInterface {
|
|
6
|
+
subscribe: (topic: string | string[]) => Promise<Readable>
|
|
10
7
|
}
|
|
11
8
|
|
|
12
|
-
export interface SQLEventsPluginOptions {
|
|
13
|
-
mapper: SQLMapperPluginInterface
|
|
9
|
+
export interface SQLEventsPluginOptions<T extends Entities> {
|
|
10
|
+
mapper: SQLMapperPluginInterface<T>
|
|
14
11
|
|
|
15
12
|
// TODO mqemitter has no types
|
|
16
13
|
mq?: any
|
|
@@ -20,8 +17,6 @@ export interface SQLEventsPluginOptions {
|
|
|
20
17
|
/**
|
|
21
18
|
* Fastify plugin that add events capabilities to registered sql-mapper
|
|
22
19
|
*/
|
|
23
|
-
|
|
20
|
+
export default function plugin<T extends Entities>(app: FastifyInstance, options: SQLEventsPluginOptions<T>): Promise<SQLEventsPluginInterface>
|
|
24
21
|
|
|
25
|
-
export
|
|
26
|
-
|
|
27
|
-
export function setupEmitter(options: SQLEventsPluginOptions): void
|
|
22
|
+
export function setupEmitter<T extends Entities>(options: SQLEventsPluginOptions<T>): void
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@platformatic/sql-events",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.44.0",
|
|
4
4
|
"description": "Emit events via MQEmitter",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"repository": {
|
|
@@ -20,14 +20,13 @@
|
|
|
20
20
|
"standard": "^17.1.0",
|
|
21
21
|
"tap": "^16.3.6",
|
|
22
22
|
"tsd": "^0.29.0",
|
|
23
|
-
"@platformatic/sql-mapper": "0.
|
|
23
|
+
"@platformatic/sql-mapper": "0.44.0"
|
|
24
24
|
},
|
|
25
25
|
"dependencies": {
|
|
26
26
|
"camelcase": "^6.3.0",
|
|
27
27
|
"fastify-plugin": "^4.5.0",
|
|
28
28
|
"mqemitter": "^5.0.0",
|
|
29
|
-
"mqemitter-redis": "^5.0.0"
|
|
30
|
-
"@platformatic/types": "0.43.1"
|
|
29
|
+
"mqemitter-redis": "^5.0.0"
|
|
31
30
|
},
|
|
32
31
|
"tsd": {
|
|
33
32
|
"directory": "test/types"
|
|
@@ -2,7 +2,14 @@ import { expectType } from 'tsd'
|
|
|
2
2
|
import { fastify, FastifyInstance } from 'fastify'
|
|
3
3
|
import plugin, { setupEmitter } from '../../index'
|
|
4
4
|
import { Readable } from 'stream'
|
|
5
|
-
import {SQLMapperPluginInterface} from '@platformatic/sql-mapper'
|
|
5
|
+
import { SQLMapperPluginInterface, Entities } from '@platformatic/sql-mapper'
|
|
6
|
+
import { SQLEventsPluginInterface } from '../../index'
|
|
7
|
+
|
|
8
|
+
declare module 'fastify' {
|
|
9
|
+
interface FastifyInstance {
|
|
10
|
+
platformatic: SQLMapperPluginInterface<Entities> & SQLEventsPluginInterface
|
|
11
|
+
}
|
|
12
|
+
}
|
|
6
13
|
|
|
7
14
|
const instance: FastifyInstance = fastify()
|
|
8
15
|
instance.register(plugin)
|
|
@@ -12,6 +19,6 @@ instance.register(async (instance) => {
|
|
|
12
19
|
expectType<Promise<Readable>>(instance.platformatic.subscribe(['/test']))
|
|
13
20
|
})
|
|
14
21
|
|
|
15
|
-
setupEmitter({ mapper: {} as SQLMapperPluginInterface })
|
|
16
|
-
setupEmitter({ mapper: {} as SQLMapperPluginInterface
|
|
17
|
-
setupEmitter({ mapper: {} as SQLMapperPluginInterface
|
|
22
|
+
setupEmitter({ mapper: {} as SQLMapperPluginInterface<Entities> })
|
|
23
|
+
setupEmitter({ mapper: {} as SQLMapperPluginInterface<Entities>, connectionString: 'redis://localhost:6379' })
|
|
24
|
+
setupEmitter({ mapper: {} as SQLMapperPluginInterface<Entities>, mq: {} })
|