@platformatic/sql-events 2.0.0-alpha.2 → 2.0.0-alpha.4
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/errors.js +1 -1
- package/eslint.config.js +3 -0
- package/index.d.ts +3 -3
- package/index.js +5 -5
- package/package.json +14 -13
package/errors.js
CHANGED
|
@@ -7,6 +7,6 @@ const ERROR_PREFIX = 'PLT_SQL_EVENTS'
|
|
|
7
7
|
module.exports = {
|
|
8
8
|
ObjectRequiredUnderTheDataProperty: createError(`${ERROR_PREFIX}_OBJECT_IS_REQUIRED_UNDER_THE_DATA_PROPERTY`, 'The object that will be published is required under the data property'),
|
|
9
9
|
PrimaryKeyIsNecessaryInsideData: createError(`${ERROR_PREFIX}_PRIMARY_KEY_IS_NECESSARY_INSIDE_DATA`, 'The primaryKey is necessary inside data'),
|
|
10
|
-
NoSuchActionError: createError(`${ERROR_PREFIX}_NO_SUCH_ACTION`, 'No such action %s')
|
|
10
|
+
NoSuchActionError: createError(`${ERROR_PREFIX}_NO_SUCH_ACTION`, 'No such action %s'),
|
|
11
11
|
|
|
12
12
|
}
|
package/eslint.config.js
ADDED
package/index.d.ts
CHANGED
|
@@ -16,11 +16,11 @@ export interface SQLEventsPluginOptions<T extends Entities> {
|
|
|
16
16
|
}
|
|
17
17
|
|
|
18
18
|
/**
|
|
19
|
-
* Fastify plugin that add events capabilities to registered sql-mapper
|
|
19
|
+
* Fastify plugin that add events capabilities to registered sql-mapper
|
|
20
20
|
*/
|
|
21
|
-
export default function plugin<T extends Entities>(app: FastifyInstance, options: SQLEventsPluginOptions<T>): Promise<SQLEventsPluginInterface>
|
|
21
|
+
export default function plugin<T extends Entities> (app: FastifyInstance, options: SQLEventsPluginOptions<T>): Promise<SQLEventsPluginInterface>
|
|
22
22
|
|
|
23
|
-
export function setupEmitter<T extends Entities>(options: SQLEventsPluginOptions<T>): void
|
|
23
|
+
export function setupEmitter<T extends Entities> (options: SQLEventsPluginOptions<T>): void
|
|
24
24
|
|
|
25
25
|
/**
|
|
26
26
|
* All the errors thrown by the plugin.
|
package/index.js
CHANGED
|
@@ -38,13 +38,13 @@ function setupEmitter ({ log, mq, mapper, connectionString }) {
|
|
|
38
38
|
const topic = await entity.getPublishTopic({ action: 'save', data: res, ctx })
|
|
39
39
|
if (topic) {
|
|
40
40
|
const payload = {
|
|
41
|
-
[primaryKey]: res[primaryKey]
|
|
41
|
+
[primaryKey]: res[primaryKey],
|
|
42
42
|
}
|
|
43
43
|
_log.trace({ topic, payload }, 'publishing event')
|
|
44
44
|
await new Promise((resolve) => {
|
|
45
45
|
mq.emit({
|
|
46
46
|
topic,
|
|
47
|
-
payload
|
|
47
|
+
payload,
|
|
48
48
|
}, resolve)
|
|
49
49
|
})
|
|
50
50
|
}
|
|
@@ -52,7 +52,7 @@ function setupEmitter ({ log, mq, mapper, connectionString }) {
|
|
|
52
52
|
},
|
|
53
53
|
|
|
54
54
|
delete: multiElement('delete'),
|
|
55
|
-
insert: multiElement('save')
|
|
55
|
+
insert: multiElement('save'),
|
|
56
56
|
})
|
|
57
57
|
|
|
58
58
|
function multiElement (action) {
|
|
@@ -70,8 +70,8 @@ function setupEmitter ({ log, mq, mapper, connectionString }) {
|
|
|
70
70
|
mq.emit({
|
|
71
71
|
topic,
|
|
72
72
|
payload: {
|
|
73
|
-
[primaryKey]: payload[primaryKey]
|
|
74
|
-
}
|
|
73
|
+
[primaryKey]: payload[primaryKey],
|
|
74
|
+
},
|
|
75
75
|
}, resolve)
|
|
76
76
|
})
|
|
77
77
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@platformatic/sql-events",
|
|
3
|
-
"version": "2.0.0-alpha.
|
|
3
|
+
"version": "2.0.0-alpha.4",
|
|
4
4
|
"description": "Emit events via MQEmitter",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"repository": {
|
|
@@ -15,32 +15,33 @@
|
|
|
15
15
|
"homepage": "https://github.com/platformatic/platformatic#readme",
|
|
16
16
|
"devDependencies": {
|
|
17
17
|
"@matteo.collina/tspl": "^0.1.1",
|
|
18
|
-
"borp": "^0.
|
|
18
|
+
"borp": "^0.17.0",
|
|
19
|
+
"eslint": "9",
|
|
19
20
|
"fastify": "^4.26.2",
|
|
20
21
|
"ioredis": "^5.3.2",
|
|
21
|
-
"
|
|
22
|
-
"standard": "^17.1.0",
|
|
22
|
+
"neostandard": "^0.11.1",
|
|
23
23
|
"tsd": "^0.31.0",
|
|
24
|
-
"
|
|
24
|
+
"typescript": "^5.5.4",
|
|
25
|
+
"@platformatic/sql-mapper": "2.0.0-alpha.4"
|
|
25
26
|
},
|
|
26
27
|
"dependencies": {
|
|
27
28
|
"@fastify/error": "^3.4.1",
|
|
28
29
|
"camelcase": "^6.3.0",
|
|
29
30
|
"fastify-plugin": "^4.5.1",
|
|
30
|
-
"mqemitter": "^
|
|
31
|
-
"mqemitter-redis": "^
|
|
31
|
+
"mqemitter": "^6.0.0",
|
|
32
|
+
"mqemitter-redis": "^6.0.0"
|
|
32
33
|
},
|
|
33
34
|
"tsd": {
|
|
34
35
|
"directory": "test/types"
|
|
35
36
|
},
|
|
36
37
|
"scripts": {
|
|
37
38
|
"test": "npm run lint && npm run test:typescript && npm run test:postgresql && npm run test:mariadb && npm run test:mysql && npm run test:mysql8 && npm run test:sqlite",
|
|
38
|
-
"test:postgresql": "DB=postgresql borp --concurrency=1 test/*.test.js",
|
|
39
|
-
"test:mariadb": "DB=mariadb borp --concurrency=1 test/*.test.js",
|
|
40
|
-
"test:mysql": "DB=mysql borp --concurrency=1 test/*.test.js",
|
|
41
|
-
"test:mysql8": "DB=mysql8 borp --concurrency=1 test/*.test.js",
|
|
42
|
-
"test:sqlite": "DB=sqlite borp --concurrency=1 test/*.test.js",
|
|
39
|
+
"test:postgresql": "DB=postgresql borp --timeout=180000 --concurrency=1 test/*.test.js",
|
|
40
|
+
"test:mariadb": "DB=mariadb borp --timeout=180000 --concurrency=1 test/*.test.js",
|
|
41
|
+
"test:mysql": "DB=mysql borp --timeout=180000 --concurrency=1 test/*.test.js",
|
|
42
|
+
"test:mysql8": "DB=mysql8 borp --timeout=180000 --concurrency=1 test/*.test.js",
|
|
43
|
+
"test:sqlite": "DB=sqlite borp --timeout=180000 --concurrency=1 test/*.test.js",
|
|
43
44
|
"test:typescript": "tsd",
|
|
44
|
-
"lint": "
|
|
45
|
+
"lint": "eslint"
|
|
45
46
|
}
|
|
46
47
|
}
|