@furvester/upstream-sync 2.1.1 → 2.1.3
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/dist/index.d.ts +2 -2
- package/dist/index.js +8 -5
- package/package.json +3 -2
package/dist/index.d.ts
CHANGED
|
@@ -2,7 +2,7 @@ import type { EntityManager, MikroORM } from "@mikro-orm/postgresql";
|
|
|
2
2
|
import type { Logger } from "logforth";
|
|
3
3
|
import { type ConnectionOptions } from "rabbitmq-client";
|
|
4
4
|
import type { z } from "zod";
|
|
5
|
-
import {
|
|
5
|
+
import { TopLevelLinks } from "@jsonapi-serde/client";
|
|
6
6
|
export type SyncManagerConfig = {
|
|
7
7
|
rabbitmq: ConnectionOptions;
|
|
8
8
|
orm: MikroORM;
|
|
@@ -17,7 +17,7 @@ export type ResyncResource = {
|
|
|
17
17
|
};
|
|
18
18
|
export type ResyncDocument<T extends ResyncResource> = {
|
|
19
19
|
data: T[];
|
|
20
|
-
|
|
20
|
+
links?: TopLevelLinks;
|
|
21
21
|
};
|
|
22
22
|
export type MessageEventHandler<T = unknown> = (em: EntityManager, data: T) => Promise<void> | void;
|
|
23
23
|
export type MessageEvent<T extends z.ZodTypeAny> = {
|
package/dist/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Mutex } from "async-mutex";
|
|
2
2
|
import { Connection, } from "rabbitmq-client";
|
|
3
|
-
import { handleJsonApiError, injectPageParams } from "@jsonapi-serde/client";
|
|
3
|
+
import { extractPageParams, handleJsonApiError, injectPageParams } from "@jsonapi-serde/client";
|
|
4
4
|
export const createMessageEvent = (event) => event;
|
|
5
5
|
export const createResync = (preSync) => preSync;
|
|
6
6
|
export const createUpstreamEntity = (entity) => entity;
|
|
@@ -123,10 +123,13 @@ export class SyncManager {
|
|
|
123
123
|
for (const resource of document.data) {
|
|
124
124
|
await entity.resync.upsert(em, resource);
|
|
125
125
|
}
|
|
126
|
-
if (document.
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
126
|
+
if (document.links) {
|
|
127
|
+
const pageParams = extractPageParams(document.links);
|
|
128
|
+
if (pageParams.next) {
|
|
129
|
+
url = new URL(baseUrl);
|
|
130
|
+
injectPageParams(url, pageParams.next);
|
|
131
|
+
continue;
|
|
132
|
+
}
|
|
130
133
|
}
|
|
131
134
|
url = null;
|
|
132
135
|
} while (url !== null);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@furvester/upstream-sync",
|
|
3
|
-
"version": "2.1.
|
|
3
|
+
"version": "2.1.3",
|
|
4
4
|
"description": "Sync from upstream via RabbitMQ",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"author": "Ben Scholzen 'DASPRiD'",
|
|
@@ -35,6 +35,7 @@
|
|
|
35
35
|
"@biomejs/biome": "2.3.14",
|
|
36
36
|
"@commitlint/cli": "^20.4.1",
|
|
37
37
|
"@commitlint/config-conventional": "^20.4.1",
|
|
38
|
+
"@jsonapi-serde/client": "^1.2.1",
|
|
38
39
|
"@mikro-orm/postgresql": "^6.6.6",
|
|
39
40
|
"@tsconfig/node24": "^24.0.4",
|
|
40
41
|
"@types/node": "^25.2.2",
|
|
@@ -45,13 +46,13 @@
|
|
|
45
46
|
"zod": "^4.3.6"
|
|
46
47
|
},
|
|
47
48
|
"peerDependencies": {
|
|
49
|
+
"@jsonapi-serde/client": "^1.2.1",
|
|
48
50
|
"@mikro-orm/postgresql": "^6.3.13",
|
|
49
51
|
"logforth": "^1.2.2",
|
|
50
52
|
"rabbitmq-client": "^5.0.0",
|
|
51
53
|
"zod": "^4.3.6"
|
|
52
54
|
},
|
|
53
55
|
"dependencies": {
|
|
54
|
-
"@jsonapi-serde/client": "^1.2.1",
|
|
55
56
|
"async-mutex": "^0.5.0"
|
|
56
57
|
},
|
|
57
58
|
"packageManager": "pnpm@10.29.1+sha512.48dae233635a645768a3028d19545cacc1688639eeb1f3734e42d6d6b971afbf22aa1ac9af52a173d9c3a20c15857cfa400f19994d79a2f626fcc73fccda9bbc"
|