@livequery/nestjs 2.0.147 → 2.0.149
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/README.md +144 -0
- package/build/src/LivequeryDatasourceInterceptors.d.ts +5 -16
- package/build/src/LivequeryDatasourceInterceptors.js +32 -16
- package/build/src/LivequeryDatasourceInterceptors.js.map +1 -1
- package/build/src/LivequeryInterceptor.js +19 -9
- package/build/src/LivequeryInterceptor.js.map +1 -1
- package/build/src/LivequeryRequest.d.ts +1 -1
- package/build/src/helpers/createDatasourceMapper.d.ts +16 -9
- package/build/src/helpers/createDatasourceMapper.js +2 -1
- package/build/src/helpers/createDatasourceMapper.js.map +1 -1
- package/build/src/index.d.ts +1 -3
- package/build/src/index.js +0 -3
- package/build/src/index.js.map +1 -1
- package/build/tsconfig.tsbuildinfo +1 -1
- package/package.json +3 -3
- package/build/src/ApiGateway.d.ts +0 -54
- package/build/src/ApiGateway.js +0 -237
- package/build/src/ApiGateway.js.map +0 -1
- package/build/src/LivequeryWebsocketSync.d.ts +0 -2
- package/build/src/LivequeryWebsocketSync.js +0 -9
- package/build/src/LivequeryWebsocketSync.js.map +0 -1
- package/build/src/RxjsUdp.d.ts +0 -21
- package/build/src/RxjsUdp.js +0 -93
- package/build/src/RxjsUdp.js.map +0 -1
- package/build/src/SimpleApiGateway.d.ts +0 -5
- package/build/src/SimpleApiGateway.js +0 -14
- package/build/src/SimpleApiGateway.js.map +0 -1
- package/build/src/UdpDiscovery.d.ts +0 -35
- package/build/src/UdpDiscovery.js +0 -231
- package/build/src/UdpDiscovery.js.map +0 -1
- package/build/src/WebsocketGateway.d.ts +0 -29
- package/build/src/WebsocketGateway.js +0 -257
- package/build/src/WebsocketGateway.js.map +0 -1
- package/build/src/const.d.ts +0 -7
- package/build/src/const.js +0 -9
- package/build/src/const.js.map +0 -1
- package/build/src/helpers/PathHelper.d.ts +0 -11
- package/build/src/helpers/PathHelper.js +0 -41
- package/build/src/helpers/PathHelper.js.map +0 -1
- package/build/src/helpers/createHook.d.ts +0 -4
- package/build/src/helpers/createHook.js +0 -7
- package/build/src/helpers/createHook.js.map +0 -1
- package/build/src/helpers/hidePrivateFields.d.ts +0 -6
- package/build/src/helpers/hidePrivateFields.js +0 -8
- package/build/src/helpers/hidePrivateFields.js.map +0 -1
package/README.md
ADDED
|
@@ -0,0 +1,144 @@
|
|
|
1
|
+
# @livequery/nestjs
|
|
2
|
+
|
|
3
|
+
NestJS adapter for the [livequery](https://github.com/livequery) ecosystem — turns plain NestJS controllers into livequery endpoints (filterable/paginated CRUD over HTTP) with optional realtime sync over WebSocket.
|
|
4
|
+
|
|
5
|
+
```
|
|
6
|
+
HTTP request ──▶ LivequeryInterceptor ──▶ LivequeryDatasourceInterceptors ──▶ datasource.handle(ctx)
|
|
7
|
+
(parse + WS subscribe) (route metadata → engine) (@livequery/mongodb, ...)
|
|
8
|
+
│
|
|
9
|
+
WS client ◀── WebsocketGateway ◀── watcher (e.g. MongodbRealtime change streams) ◀─────┘
|
|
10
|
+
```
|
|
11
|
+
|
|
12
|
+
Datasources implement the engine contract from `@livequery/core` (`LivequeryDatasource`: `init` + `handle`). `@livequery/mongodb` is the reference implementation.
|
|
13
|
+
|
|
14
|
+
## Install
|
|
15
|
+
|
|
16
|
+
```bash
|
|
17
|
+
bun add @livequery/nestjs @livequery/core
|
|
18
|
+
# peer deps (you likely have them already in a NestJS app):
|
|
19
|
+
bun add reflect-metadata @nestjs/core @nestjs/common @nestjs/platform-ws @nestjs/websockets express
|
|
20
|
+
# the reference datasource:
|
|
21
|
+
bun add @livequery/mongodb mongodb
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+
## Quick start (MongoDB)
|
|
25
|
+
|
|
26
|
+
**1. Create the decorator + provider pair** with `createDatasourceMapper`:
|
|
27
|
+
|
|
28
|
+
```ts
|
|
29
|
+
// UseMongodbDatasource.ts
|
|
30
|
+
import { createDatasourceMapper } from '@livequery/nestjs'
|
|
31
|
+
import { MongoDatasource, MongodbRealtime, RouteOptions } from '@livequery/mongodb'
|
|
32
|
+
import type { Provider } from '@nestjs/common'
|
|
33
|
+
|
|
34
|
+
const [decorator, provider] = createDatasourceMapper({
|
|
35
|
+
querier: MongoDatasource, // class, constructed via NestJS DI
|
|
36
|
+
watcher: MongodbRealtime, // optional — change streams → realtime
|
|
37
|
+
config: {
|
|
38
|
+
connections: { default: mongoClient },
|
|
39
|
+
databases: ['main'],
|
|
40
|
+
},
|
|
41
|
+
})
|
|
42
|
+
|
|
43
|
+
export const MongodbDatasourceProvider: Provider = provider
|
|
44
|
+
export const UseMongodbDatasource = (options: RouteOptions) => decorator(options)
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
`config` can also be a factory `(...injections) => Config` resolved through DI — pass the inject tokens via `injects: [...]` (e.g. `getConnectionToken()` from `@nestjs/mongoose`).
|
|
48
|
+
|
|
49
|
+
**2. Decorate controller routes** (paths must start with `livequery/`):
|
|
50
|
+
|
|
51
|
+
```ts
|
|
52
|
+
@Controller('livequery/tasks')
|
|
53
|
+
export class TaskController {
|
|
54
|
+
@Get() @UseMongodbDatasource({ collection: 'tasks', realtime: true }) list() { }
|
|
55
|
+
@Get(':id') @UseMongodbDatasource({ collection: 'tasks' }) get() { }
|
|
56
|
+
@Post() @UseMongodbDatasource({ collection: 'tasks' }) create() { }
|
|
57
|
+
@Patch(':id') @UseMongodbDatasource({ collection: 'tasks' }) update() { }
|
|
58
|
+
@Delete(':id') @UseMongodbDatasource({ collection: 'tasks' }) remove() { }
|
|
59
|
+
}
|
|
60
|
+
```
|
|
61
|
+
|
|
62
|
+
Handlers can return nothing (the datasource result is returned as-is), a `LivequeryItemMapper` to transform items, or a function `(result) => response` for full control.
|
|
63
|
+
|
|
64
|
+
**3. Register everything in the module:**
|
|
65
|
+
|
|
66
|
+
```ts
|
|
67
|
+
import { DiscoveryModule } from '@nestjs/core'
|
|
68
|
+
import { WebsocketGateway } from '@livequery/core'
|
|
69
|
+
|
|
70
|
+
@Module({
|
|
71
|
+
imports: [DiscoveryModule], // required by route discovery
|
|
72
|
+
controllers: [TaskController],
|
|
73
|
+
providers: [
|
|
74
|
+
MongodbDatasourceProvider,
|
|
75
|
+
{ provide: WebsocketGateway, useValue: gateway }, // new WebsocketGateway(httpServer)
|
|
76
|
+
],
|
|
77
|
+
})
|
|
78
|
+
export class AppModule { }
|
|
79
|
+
```
|
|
80
|
+
|
|
81
|
+
On bootstrap the provider discovers every decorated route, calls `datasource.init(routes)`, and (if a `watcher` was given) pipes `watcher.watch(config, routes, ds)` into the gateway for realtime fan-out.
|
|
82
|
+
|
|
83
|
+
## Querying
|
|
84
|
+
|
|
85
|
+
All livequery query grammar flows through automatically:
|
|
86
|
+
|
|
87
|
+
```
|
|
88
|
+
GET /livequery/tasks?done:eq=false&seq:gte=10&seq:sort=desc&:limit=20&:after=<cursor>
|
|
89
|
+
```
|
|
90
|
+
|
|
91
|
+
Responses carry `items`/`item` plus paging (`count`, `has`, `cursor`, `page`). Underscore-prefixed fields (`_secret`, …) are stripped from `item`, `items`, and the `{ data }` envelope automatically.
|
|
92
|
+
|
|
93
|
+
Realtime: a client that sends `x-lcid`/`x-lgid` headers on a GET is subscribed on the gateway; subsequent changes (including out-of-band DB writes when using `MongodbRealtime`) are pushed as `sync` events. Use `@livequery/client` + `@livequery/rest` on the frontend.
|
|
94
|
+
|
|
95
|
+
## API surface
|
|
96
|
+
|
|
97
|
+
| Export | Purpose |
|
|
98
|
+
|---|---|
|
|
99
|
+
| `createDatasourceMapper({ querier, watcher?, injects?, config })` | Returns `[decorator, provider]` wiring a datasource class into routes + DI |
|
|
100
|
+
| `LivequeryInterceptor` / `UseLivequeryInterceptor()` | Parses the request into `req.livequery`, registers WS subscriptions, masks private fields |
|
|
101
|
+
| `LivequeryDatasourceInterceptors` | Resolves route metadata and drives `datasource.handle(ctx)` |
|
|
102
|
+
| `LivequeryItemMapper` | Per-item response mapping helper |
|
|
103
|
+
| `@LivequeryRequest()` | Param decorator exposing the parsed `LivequeryRequest` |
|
|
104
|
+
| `ApiGateway`, `ApiServiceLinker`, `listPaths` | Gateway/multi-node utilities |
|
|
105
|
+
| `WebsocketGateway`, `UdpDiscovery`, … | Re-exported from `@livequery/core` |
|
|
106
|
+
| `LivequeryDatasource`, `UpdatedData`, `QueryOption`, `FilterConditions`, `Paging`, … | Type surface re-exported from `@livequery/core` |
|
|
107
|
+
|
|
108
|
+
## Datasource & watcher contracts
|
|
109
|
+
|
|
110
|
+
```ts
|
|
111
|
+
// querier: class whose instances satisfy core's engine contract
|
|
112
|
+
type LivequeryDatasourceFactory<Config, RouteOptions> = {
|
|
113
|
+
new (...args: any[]): LivequeryDatasource<RouteOptions> & { config?: Config }
|
|
114
|
+
}
|
|
115
|
+
// LivequeryDatasource<RouteOptions> (from @livequery/core):
|
|
116
|
+
// init(routes: Array<RouteOptions & { method: string, path: string }>): Promise<void> | void
|
|
117
|
+
// handle(ctx: LivequeryContext): any
|
|
118
|
+
|
|
119
|
+
// watcher: realtime source
|
|
120
|
+
type LivequeryDatasourceWatcher<Config, RouteOptions> = {
|
|
121
|
+
watch(
|
|
122
|
+
config: Config,
|
|
123
|
+
routes: Array<{ path: string, schema: string, method: string, options: RouteOptions }>,
|
|
124
|
+
ds: LivequeryDatasource<RouteOptions>,
|
|
125
|
+
): Observable<UpdatedData<any>>
|
|
126
|
+
}
|
|
127
|
+
```
|
|
128
|
+
|
|
129
|
+
`config` is assigned onto the instance by the provider after DI construction. Route `path`/`schema` are produced by `@livequery/core`'s `LivequeryRequestParser` from the controller route patterns (the `livequery/` prefix and the document-id segment are stripped — e.g. `livequery/users/:uid/posts/:id` → `users/:uid/posts`); `method` is the HTTP verb string (`'GET'`, `'POST'`, …).
|
|
130
|
+
|
|
131
|
+
## Notes
|
|
132
|
+
|
|
133
|
+
- **Transpilers**: the interceptors use explicit `@Inject(...)` tokens, so the package works under bundlers that don't emit `design:paramtypes` (bun, esbuild, vite). Your app still needs `experimentalDecorators` (standard for NestJS); when running TS sources directly with bun, make sure a `tsconfig.json` with `experimentalDecorators` is visible from your working directory, or parameter decorators are silently dropped.
|
|
134
|
+
- **Realtime** with `MongodbRealtime` requires MongoDB change streams (replica set / mongos) and, for full delete payloads, the `collMod` privilege (pre/post images).
|
|
135
|
+
- Errors thrown by datasources are structured `{ status, code, message }` objects — add an exception filter if you want them mapped onto HTTP responses.
|
|
136
|
+
|
|
137
|
+
## Breaking changes in 2.0.148
|
|
138
|
+
|
|
139
|
+
- Depends on `@livequery/core ^2.0.148` (peer); `@livequery/types` is no longer used or re-exported. The shared type surface now comes from core.
|
|
140
|
+
- `LivequeryDatasource` exported here is now core's single-generic type (`LivequeryDatasource<RouteOptions>`); the old local two-generic `Subject`-based type was removed. Datasources must implement core's `handle(ctx)` — `@livequery/mongodb` ≥ 2.0.148 and `@livequery/mongoose` already do.
|
|
141
|
+
- The interceptor drives datasources through `handle(ctx)` (engine entry point) instead of calling `query(req, options)` directly; route options are resolved from the datasource's own route table built at `init()`.
|
|
142
|
+
- Watcher route `method` is now the verb string (`'GET'`) instead of NestJS's `RequestMethod` enum number.
|
|
143
|
+
- Client-side types (`Transporter`, `Response`, `QueryStream`, `DocumentResponse`) are no longer re-exported — import them from the client packages if you need them.
|
|
144
|
+
- Removed `LivequeryWebsocketSync` (an empty placeholder class) and `SimpleApiGateway` (a thin `@Injectable` wrapper) — use `ApiGatewayHandler` from `@livequery/core` or `ApiGateway` from this package instead.
|
|
@@ -1,22 +1,10 @@
|
|
|
1
1
|
import { CallHandler, ExecutionContext, NestInterceptor } from '@nestjs/common';
|
|
2
|
-
import { Subject } from 'rxjs';
|
|
3
2
|
import { DiscoveryService, ModuleRef, Reflector } from '@nestjs/core';
|
|
4
|
-
import { LivequeryBaseEntity
|
|
3
|
+
import type { LivequeryBaseEntity } from '@livequery/core';
|
|
5
4
|
export declare class LivequeryItemMapper<T extends LivequeryBaseEntity> {
|
|
6
5
|
readonly mapper: (item: T) => T;
|
|
7
6
|
constructor(mapper: (item: T) => T);
|
|
8
7
|
}
|
|
9
|
-
export type LivequeryDatasource<Config, RouteOptions> = Subject<WebsocketSyncPayload<LivequeryBaseEntity>> & {
|
|
10
|
-
init(config: Config, routes: Array<{
|
|
11
|
-
path: string;
|
|
12
|
-
method: number;
|
|
13
|
-
options: RouteOptions;
|
|
14
|
-
}>): Promise<void>;
|
|
15
|
-
query: (query: LivequeryRequest, options: RouteOptions) => Promise<{
|
|
16
|
-
items: any[];
|
|
17
|
-
item: any;
|
|
18
|
-
}>;
|
|
19
|
-
};
|
|
20
8
|
export type DatatasourceRouteMetadata<RouteOptions> = {
|
|
21
9
|
datasource: Symbol;
|
|
22
10
|
options: RouteOptions;
|
|
@@ -28,11 +16,12 @@ export declare class LivequeryDatasourceInterceptors implements NestInterceptor
|
|
|
28
16
|
constructor(reflector: Reflector, discovery: DiscoveryService, moduleRef: ModuleRef);
|
|
29
17
|
getRoutes<Options>(token?: Symbol): {
|
|
30
18
|
path: string;
|
|
19
|
+
schema: string;
|
|
31
20
|
options: Options;
|
|
32
|
-
method:
|
|
21
|
+
method: string;
|
|
33
22
|
}[];
|
|
34
23
|
intercept(ctx: ExecutionContext, next: CallHandler): Promise<import("rxjs").Observable<{
|
|
35
|
-
items
|
|
36
|
-
item
|
|
24
|
+
items?: any[];
|
|
25
|
+
item?: any;
|
|
37
26
|
}>>;
|
|
38
27
|
}
|
|
@@ -1,22 +1,15 @@
|
|
|
1
1
|
var LivequeryDatasourceInterceptors_1;
|
|
2
|
-
import { __decorate, __metadata } from "tslib";
|
|
3
|
-
import { Injectable } from '@nestjs/common';
|
|
2
|
+
import { __decorate, __metadata, __param } from "tslib";
|
|
3
|
+
import { Inject, Injectable, RequestMethod } from '@nestjs/common';
|
|
4
4
|
import { map, mergeMap } from 'rxjs';
|
|
5
5
|
import { DiscoveryService, ModuleRef, Reflector } from '@nestjs/core';
|
|
6
|
-
import { hidePrivateFields } from '@livequery/core';
|
|
6
|
+
import { hidePrivateFields, LivequeryRequestParser } from '@livequery/core';
|
|
7
7
|
export class LivequeryItemMapper {
|
|
8
8
|
mapper;
|
|
9
9
|
constructor(mapper) {
|
|
10
10
|
this.mapper = mapper;
|
|
11
11
|
}
|
|
12
12
|
}
|
|
13
|
-
function normalizeRouteRef(path) {
|
|
14
|
-
const pathname = path.split('?')[0].split('~')[0];
|
|
15
|
-
const segments = pathname.split('/').filter(Boolean);
|
|
16
|
-
const livequeryIndex = segments.indexOf('livequery');
|
|
17
|
-
const refSegments = livequeryIndex === -1 ? segments : segments.slice(livequeryIndex + 1);
|
|
18
|
-
return refSegments.map(segment => segment.startsWith(':') ? segment.slice(1) : segment).join('/');
|
|
19
|
-
}
|
|
20
13
|
let LivequeryDatasourceInterceptors = LivequeryDatasourceInterceptors_1 = class LivequeryDatasourceInterceptors {
|
|
21
14
|
reflector;
|
|
22
15
|
discovery;
|
|
@@ -44,11 +37,19 @@ let LivequeryDatasourceInterceptors = LivequeryDatasourceInterceptors_1 = class
|
|
|
44
37
|
const x = (a || '').trim().replace(/^\/+|\/+$/g, '');
|
|
45
38
|
const y = (b || '').trim().replace(/^\/+|\/+$/g, '');
|
|
46
39
|
const joined = (x == '' || y == '') ? `${x}${y}` : `${x}/${y}`;
|
|
47
|
-
return
|
|
40
|
+
return LivequeryRequestParser.parse({
|
|
41
|
+
ref: joined,
|
|
42
|
+
path: joined,
|
|
43
|
+
params: {},
|
|
44
|
+
query: {},
|
|
45
|
+
method: 'GET',
|
|
46
|
+
headers: new Map(),
|
|
47
|
+
})?.schema ?? '';
|
|
48
48
|
})).flat(2);
|
|
49
|
-
const method = Reflect.getMetadata('method', metatype.prototype[name]);
|
|
49
|
+
const method = RequestMethod[Reflect.getMetadata('method', metatype.prototype[name]) ?? RequestMethod.GET] ?? 'GET';
|
|
50
50
|
return paths.map(path => ({
|
|
51
51
|
path,
|
|
52
|
+
schema: path,
|
|
52
53
|
options: metadata.options,
|
|
53
54
|
method
|
|
54
55
|
}));
|
|
@@ -58,9 +59,21 @@ let LivequeryDatasourceInterceptors = LivequeryDatasourceInterceptors_1 = class
|
|
|
58
59
|
async intercept(ctx, next) {
|
|
59
60
|
return next.handle().pipe(mergeMap(async (rs) => {
|
|
60
61
|
const req = ctx.switchToHttp().getRequest();
|
|
61
|
-
const {
|
|
62
|
-
const ds =
|
|
63
|
-
const
|
|
62
|
+
const { datasource } = this.reflector.get(LivequeryDatasourceInterceptors_1, ctx.getHandler());
|
|
63
|
+
const ds = this.moduleRef.get(datasource);
|
|
64
|
+
const context = {
|
|
65
|
+
request: {
|
|
66
|
+
path: req.originalUrl ?? req.url ?? '',
|
|
67
|
+
ref: req.livequery?.schema ?? req.route?.path ?? req.path ?? '',
|
|
68
|
+
params: req.params ?? {},
|
|
69
|
+
query: req.query ?? {},
|
|
70
|
+
body: req.body,
|
|
71
|
+
method: req.method,
|
|
72
|
+
headers: new Headers(req.headers),
|
|
73
|
+
},
|
|
74
|
+
livequery: req.livequery,
|
|
75
|
+
};
|
|
76
|
+
const lrs = await ds.handle(context);
|
|
64
77
|
if (rs instanceof LivequeryItemMapper) {
|
|
65
78
|
if (lrs.item) {
|
|
66
79
|
return {
|
|
@@ -84,7 +97,7 @@ let LivequeryDatasourceInterceptors = LivequeryDatasourceInterceptors_1 = class
|
|
|
84
97
|
if (data.items) {
|
|
85
98
|
return {
|
|
86
99
|
...data,
|
|
87
|
-
items: data.items.map(item => hidePrivateFields(item))
|
|
100
|
+
items: data.items.map((item) => hidePrivateFields(item))
|
|
88
101
|
};
|
|
89
102
|
}
|
|
90
103
|
return data;
|
|
@@ -93,6 +106,9 @@ let LivequeryDatasourceInterceptors = LivequeryDatasourceInterceptors_1 = class
|
|
|
93
106
|
};
|
|
94
107
|
LivequeryDatasourceInterceptors = LivequeryDatasourceInterceptors_1 = __decorate([
|
|
95
108
|
Injectable(),
|
|
109
|
+
__param(0, Inject(Reflector)),
|
|
110
|
+
__param(1, Inject(DiscoveryService)),
|
|
111
|
+
__param(2, Inject(ModuleRef)),
|
|
96
112
|
__metadata("design:paramtypes", [Reflector,
|
|
97
113
|
DiscoveryService,
|
|
98
114
|
ModuleRef])
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"LivequeryDatasourceInterceptors.js","sourceRoot":"","sources":["../../src/LivequeryDatasourceInterceptors.ts"],"names":[],"mappings":";;AAAA,OAAO,EAAiC,UAAU,EAAmB,MAAM,gBAAgB,CAAC;
|
|
1
|
+
{"version":3,"file":"LivequeryDatasourceInterceptors.js","sourceRoot":"","sources":["../../src/LivequeryDatasourceInterceptors.ts"],"names":[],"mappings":";;AAAA,OAAO,EAAiC,MAAM,EAAE,UAAU,EAAmB,aAAa,EAAE,MAAM,gBAAgB,CAAC;AACnH,OAAO,EAAE,GAAG,EAAE,QAAQ,EAAE,MAAM,MAAM,CAAC;AACrC,OAAO,EAAE,gBAAgB,EAAE,SAAS,EAAE,SAAS,EAAE,MAAM,cAAc,CAAA;AAErE,OAAO,EAAE,iBAAiB,EAAE,sBAAsB,EAAE,MAAM,iBAAiB,CAAC;AAG5E,MAAM,OAAO,mBAAmB;IACA;IAA5B,YAA4B,MAAsB;QAAtB,WAAM,GAAN,MAAM,CAAgB;IAAI,CAAC;CAC1D;AAQM,IAAM,+BAA+B,uCAArC,MAAM,+BAA+B;IAOT;IACgB;IAChB;IAH/B,YAC+B,SAAoB,EACJ,SAA2B,EAC3C,SAAoB;QAFpB,cAAS,GAAT,SAAS,CAAW;QACJ,cAAS,GAAT,SAAS,CAAkB;QAC3C,cAAS,GAAT,SAAS,CAAW;IAC/C,CAAC;IAGL,SAAS,CAAU,KAAc;QAC7B,MAAM,WAAW,GAAG,IAAI,CAAC,SAAS,CAAC,cAAc,EAAE,CAAA;QACnD,OAAO,WAAW,CAAC,GAAG,CAAC,UAAU,CAAC,EAAE;YAChC,MAAM,QAAQ,GAAG,UAAU,CAAC,QAAQ,CAAA;YACpC,IAAI,CAAC,QAAQ;gBAAE,OAAO,EAAE,CAAA;YACxB,MAAM,KAAK,GAAG,MAAM,CAAC,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AAE,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,IAAS,EAAE,EAAE,CAAC,iBAAiB,CAAC,IAAI,CAAC,CAAC;iBAChE,CAAA;YACL,CAAC;YACD,OAAO,IAAI,CAAA;QACf,CAAC,CAAC,CACL,CAAA;IAEL,CAAC;CACJ,CAAA;AAlHY,+BAA+B;IAD3C,UAAU,EAAE;IAQJ,WAAA,MAAM,CAAC,SAAS,CAAC,CAAA;IACjB,WAAA,MAAM,CAAC,gBAAgB,CAAC,CAAA;IACxB,WAAA,MAAM,CAAC,SAAS,CAAC,CAAA;qCAFoB,SAAS;QACO,gBAAgB;QAChC,SAAS;GAT1C,+BAA+B,CAkH3C"}
|
|
@@ -37,15 +37,7 @@ let LivequeryInterceptor = class LivequeryInterceptor {
|
|
|
37
37
|
if (parsed && req.method === 'GET' && !cursor) {
|
|
38
38
|
this.WebsocketGateway?.handle(ctx);
|
|
39
39
|
}
|
|
40
|
-
return next.handle().pipe(map(response =>
|
|
41
|
-
if (response.item) {
|
|
42
|
-
return {
|
|
43
|
-
...response,
|
|
44
|
-
item: hidePrivateFields(response.item.toJSON ? response.item.toJSON() : response.item),
|
|
45
|
-
};
|
|
46
|
-
}
|
|
47
|
-
return response;
|
|
48
|
-
}));
|
|
40
|
+
return next.handle().pipe(map(response => maskLivequeryResponse(response)));
|
|
49
41
|
}
|
|
50
42
|
};
|
|
51
43
|
LivequeryInterceptor = __decorate([
|
|
@@ -55,5 +47,23 @@ LivequeryInterceptor = __decorate([
|
|
|
55
47
|
__metadata("design:paramtypes", [WebsocketGateway])
|
|
56
48
|
], LivequeryInterceptor);
|
|
57
49
|
export { LivequeryInterceptor };
|
|
50
|
+
function toPlain(item) {
|
|
51
|
+
return item && typeof item.toJSON === 'function' ? item.toJSON() : item;
|
|
52
|
+
}
|
|
53
|
+
function maskLivequeryResponse(response) {
|
|
54
|
+
if (!response || typeof response !== 'object')
|
|
55
|
+
return response;
|
|
56
|
+
let masked = response;
|
|
57
|
+
if (masked.item) {
|
|
58
|
+
masked = { ...masked, item: hidePrivateFields(toPlain(masked.item)) };
|
|
59
|
+
}
|
|
60
|
+
if (Array.isArray(masked.items)) {
|
|
61
|
+
masked = { ...masked, items: masked.items.map((item) => hidePrivateFields(toPlain(item))) };
|
|
62
|
+
}
|
|
63
|
+
if (masked.data && typeof masked.data === 'object') {
|
|
64
|
+
masked = { ...masked, data: maskLivequeryResponse(masked.data) };
|
|
65
|
+
}
|
|
66
|
+
return masked;
|
|
67
|
+
}
|
|
58
68
|
export const UseLivequeryInterceptor = () => UseInterceptors(LivequeryInterceptor);
|
|
59
69
|
//# sourceMappingURL=LivequeryInterceptor.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"LivequeryInterceptor.js","sourceRoot":"","sources":["../../src/LivequeryInterceptor.ts"],"names":[],"mappings":";AAAA,OAAO,EAAiC,MAAM,EAAE,UAAU,EAAmB,QAAQ,EAAE,eAAe,EAAE,MAAM,gBAAgB,CAAC;AAC/H,OAAO,EAAE,GAAG,EAAE,MAAM,gBAAgB,CAAC;AACrC,OAAO,EAAE,iBAAiB,EAAE,sBAAsB,EAAE,gBAAgB,EAAyB,MAAM,iBAAiB,CAAC;AAM9G,IAAM,oBAAoB,GAA1B,MAAM,oBAAoB;IAIqB;IAHzC,OAAO,GAAG,IAAI,sBAAsB,EAAE,CAAA;IAE/C,YACkD,gBAAmC;QAAnC,qBAAgB,GAAhB,gBAAgB,CAAmB;IAErF,CAAC;IAED,KAAK,CAAC,SAAS,CAAC,OAAyB,EAAE,IAAiB;QAExD,MAAM,GAAG,GAAG,OAAO,CAAC,YAAY,EAAE,CAAC,UAAU,EAAE,CAAA;QAC/C,MAAM,GAAG,GAAqB;YAC1B,OAAO,EAAE;gBACL,IAAI,EAAE,GAAG,CAAC,WAAW,IAAI,GAAG,CAAC,GAAG,IAAI,GAAG,CAAC,UAAU,EAAE,QAAQ,IAAI,EAAE;gBAClE,GAAG,EAAE,GAAG,CAAC,K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A;IACrB,IAAI,MAAM,CAAC,IAAI,EAAE,CAAC;QACd,MAAM,GAAG,EAAE,GAAG,MAAM,EAAE,IAAI,EAAE,iBAAiB,CAAC,OAAO,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,EAAE,CAAA;IACzE,CAAC;IACD,IAAI,KAAK,CAAC,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,EAAE,CAAC;QAC9B,MAAM,GAAG,EAAE,GAAG,MAAM,EAAE,KAAK,EAAE,MAAM,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,IAAS,EAAE,EAAE,CAAC,iBAAiB,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAA;IACpG,CAAC;IACD,IAAI,MAAM,CAAC,IAAI,IAAI,OAAO,MAAM,CAAC,IAAI,KAAK,QAAQ,EAAE,CAAC;QACjD,MAAM,GAAG,EAAE,GAAG,MAAM,EAAE,IAAI,EAAE,qBAAqB,CAAC,MAAM,CAAC,IAAI,CAAC,EAAE,CAAA;IACpE,CAAC;IACD,OAAO,MAAM,CAAA;AACjB,CAAC;AAGD,MAAM,CAAC,MAAM,uBAAuB,GAAG,GAAG,EAAE,CAAC,eAAe,CAAC,oBAAoB,CAAC,CAAA"}
|
|
@@ -1,22 +1,25 @@
|
|
|
1
|
-
import { LivequeryDatasource } from "../LivequeryDatasourceInterceptors.js";
|
|
2
1
|
import { RouterOptions } from "express";
|
|
3
2
|
import { Observable } from 'rxjs';
|
|
4
3
|
import { ModuleRef } from "@nestjs/core";
|
|
5
|
-
import { UpdatedData } from "@livequery/
|
|
4
|
+
import type { LivequeryDatasource, UpdatedData } from "@livequery/core";
|
|
6
5
|
import { WebsocketGateway } from "@livequery/core";
|
|
7
6
|
export type ResolverRoutes = Array<{
|
|
8
7
|
path: string;
|
|
9
8
|
options: RouterOptions;
|
|
10
9
|
}>;
|
|
11
10
|
export type LivequeryDatasourceFactory<Config, RouteOptions> = {
|
|
12
|
-
new (...args: any[]): LivequeryDatasource<
|
|
11
|
+
new (...args: any[]): LivequeryDatasource<RouteOptions> & {
|
|
12
|
+
config?: Config;
|
|
13
|
+
};
|
|
14
|
+
};
|
|
15
|
+
export type LivequeryDatasourceWatcherRoute<RouteOptions> = {
|
|
16
|
+
path: string;
|
|
17
|
+
schema: string;
|
|
18
|
+
method: string;
|
|
19
|
+
options: RouteOptions;
|
|
13
20
|
};
|
|
14
21
|
export type LivequeryDatasourceWatcher<Config, RouteOptions> = {
|
|
15
|
-
watch(config: Config, routes: Array<
|
|
16
|
-
path: string;
|
|
17
|
-
method: number;
|
|
18
|
-
options: RouteOptions;
|
|
19
|
-
}>, ds: LivequeryDatasource<Config, RouteOptions>): Observable<UpdatedData<any>>;
|
|
22
|
+
watch(config: Config, routes: Array<LivequeryDatasourceWatcherRoute<RouteOptions>>, ds: LivequeryDatasource<RouteOptions>): Observable<UpdatedData<any>>;
|
|
20
23
|
};
|
|
21
24
|
export type LivequeryDatasourceWatcherFactory<Config, RouteOptions> = {
|
|
22
25
|
new (...args: any[]): LivequeryDatasourceWatcher<Config, RouteOptions>;
|
|
@@ -30,5 +33,9 @@ export type CreateDatasourceOptions<Config, RouteOptions> = {
|
|
|
30
33
|
export declare const createDatasourceMapper: <Config, RouteOptions>({ querier, injects, config: configResolver, watcher }: CreateDatasourceOptions<Config, RouteOptions>) => [(options: RouteOptions) => <TFunction extends Function, Y>(target: TFunction | object, propertyKey?: string | symbol, descriptor?: TypedPropertyDescriptor<Y>) => void, {
|
|
31
34
|
provide: LivequeryDatasourceFactory<Config, RouteOptions>;
|
|
32
35
|
inject: any[];
|
|
33
|
-
useFactory: (moduleRef: ModuleRef, ws: WebsocketGateway, ...injections: any[]) => Promise<
|
|
36
|
+
useFactory: (moduleRef: ModuleRef, ws: WebsocketGateway, ...injections: any[]) => Promise<import("@livequery/core").LivequeryHandler & {
|
|
37
|
+
init(routes: import("@livequery/core").LivequeryDatasourceInitConfig<RouteOptions>[]): Promise<void> | void;
|
|
38
|
+
} & {
|
|
39
|
+
config?: Config;
|
|
40
|
+
}>;
|
|
34
41
|
}];
|
|
@@ -19,7 +19,8 @@ export const createDatasourceMapper = ({ querier, injects = [], config: configRe
|
|
|
19
19
|
const interceptor = await moduleRef.create(LivequeryDatasourceInterceptors);
|
|
20
20
|
const routes = interceptor.getRoutes(querier);
|
|
21
21
|
const config = configResolver instanceof Function ? await configResolver(...injections) : configResolver;
|
|
22
|
-
|
|
22
|
+
ds.config = config;
|
|
23
|
+
await ds.init(routes.map(r => ({ path: r.path, method: r.method, ...r.options })));
|
|
23
24
|
if (watcher) {
|
|
24
25
|
const w = await moduleRef.create(watcher);
|
|
25
26
|
w.watch(config, routes, ds).subscribe({
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"createDatasourceMapper.js","sourceRoot":"","sources":["../../../src/helpers/createDatasourceMapper.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,WAAW,EAAE,eAAe,EAAE,MAAM,gBAAgB,CAAC;AAC/E,OAAO,
|
|
1
|
+
{"version":3,"file":"createDatasourceMapper.js","sourceRoot":"","sources":["../../../src/helpers/createDatasourceMapper.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,WAAW,EAAE,eAAe,EAAE,MAAM,gBAAgB,CAAC;AAC/E,OAAO,EAA6B,+BAA+B,EAAE,MAAM,uCAAuC,CAAC;AACnH,OAAO,EAAE,uBAAuB,EAAE,MAAM,4BAA4B,CAAC;AAGrE,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AAEzC,OAAO,EAAE,gBAAgB,EAAE,MAAM,iBAAiB,CAAC;AAwCnD,MAAM,CAAC,MAAM,sBAAsB,GAAG,CAAuB,EACzD,OAAO,EACP,OAAO,GAAG,EAAE,EACZ,MAAM,EAAE,cAAc,EACtB,OAAO,EACqC,EAAE,EAAE;IAGhD,MAAM,SAAS,GAAG,CAAC,OAAqB,EAAE,EAAE;QACxC,MAAM,QAAQ,GAA4C;Y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AI,CAAC,KAAK,CAAC,CAAA;oBAClB,CAAC;iBACJ,CAAC,CAAA;YACN,CAAC;YACD,OAAO,EAAE,CAAA;QACb,CAAC;KACJ,CAAA;IAGD,OAAO,CAAC,SAAS,EAAE,QAAQ,CAAwC,CAAA;AACvE,CAAC,CAAA"}
|
package/build/src/index.d.ts
CHANGED
|
@@ -6,6 +6,4 @@ export { LivequeryInterceptor, UseLivequeryInterceptor } from './LivequeryInterc
|
|
|
6
6
|
export * from './helpers/createDatasourceMapper.js';
|
|
7
7
|
export * from './LivequeryDatasourceInterceptors.js';
|
|
8
8
|
export { ApiGateway, ApiGateway as ApiGatewayLinker } from './ApiGatewayLinker.js';
|
|
9
|
-
export {
|
|
10
|
-
export { LivequeryWebsocketSync } from './LivequeryWebsocketSync.js';
|
|
11
|
-
export * from '@livequery/types';
|
|
9
|
+
export type { LivequeryDatasource, LivequeryDatasourceInitConfig, LivequeryBaseEntity, UpdatedData, UpdatedDataType, WebsocketSyncPayload, DatabaseEvent, Paging, QueryOption, BasicOptions, SummaryQuery, SummaryOperator, GroupByOperator, FilterConditions, ConditionTypeBuilder, FlatObjectKeys, ChainObjectKeys, RequestMethod, Eq, Neq, NumberNotEqual, Lt, Eqn, Lte, Gt, Gte, Visible, InArray, NotInArray, Like, OrderBy, } from '@livequery/core';
|
package/build/src/index.js
CHANGED
|
@@ -6,7 +6,4 @@ export { LivequeryInterceptor, UseLivequeryInterceptor } from './LivequeryInterc
|
|
|
6
6
|
export * from './helpers/createDatasourceMapper.js';
|
|
7
7
|
export * from './LivequeryDatasourceInterceptors.js';
|
|
8
8
|
export { ApiGateway, ApiGateway as ApiGatewayLinker } from './ApiGatewayLinker.js';
|
|
9
|
-
export { SimpleApiGateway } from './SimpleApiGateway.js';
|
|
10
|
-
export { LivequeryWebsocketSync } from './LivequeryWebsocketSync.js';
|
|
11
|
-
export * from '@livequery/types';
|
|
12
9
|
//# sourceMappingURL=index.js.map
|
package/build/src/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAA;AACxD,OAAO,EAAE,SAAS,EAAE,MAAM,wBAAwB,CAAA;AAClD,OAAO,EAAE,YAAY,EAAqG,gBAAgB,EAA6B,MAAM,iBAAiB,CAAA;AAC9L,OAAO,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAA;AACxD,OAAO,EAAE,oBAAoB,EAAE,uBAAuB,EAAE,MAAM,2BAA2B,CAAA;AACzF,cAAc,qCAAqC,CAAA;AACnD,cAAc,sCAAsC,CAAA;AACpD,OAAO,EAAE,UAAU,EAAE,UAAU,IAAI,gBAAgB,EAAE,MAAM,uBAAuB,CAAA
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAA;AACxD,OAAO,EAAE,SAAS,EAAE,MAAM,wBAAwB,CAAA;AAClD,OAAO,EAAE,YAAY,EAAqG,gBAAgB,EAA6B,MAAM,iBAAiB,CAAA;AAC9L,OAAO,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAA;AACxD,OAAO,EAAE,oBAAoB,EAAE,uBAAuB,EAAE,MAAM,2BAA2B,CAAA;AACzF,cAAc,qCAAqC,CAAA;AACnD,cAAc,sCAAsC,CAAA;AACpD,OAAO,EAAE,UAAU,EAAE,UAAU,IAAI,gBAAgB,EAAE,MAAM,uBAAuB,CAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"root":["../src/apigatewaylinker.ts","../src/apiservicelinker.ts","../src/livequerydatasourceinterceptors.ts","../src/livequeryinterceptor.ts","../src/livequeryrequest.ts","../src/
|
|
1
|
+
{"root":["../src/apigatewaylinker.ts","../src/apiservicelinker.ts","../src/livequerydatasourceinterceptors.ts","../src/livequeryinterceptor.ts","../src/livequeryrequest.ts","../src/index.ts","../src/helpers/createdatasourcemapper.ts","../src/helpers/listpaths.ts"],"version":"5.9.3"}
|
package/package.json
CHANGED
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
"repository": {
|
|
6
6
|
"url": "git@github.com:livequery/nestjs.git"
|
|
7
7
|
},
|
|
8
|
-
"version": "2.0.
|
|
8
|
+
"version": "2.0.149",
|
|
9
9
|
"description": "Nestjs decorators for @livequery ecosystem",
|
|
10
10
|
"main": "./build/src/index.js",
|
|
11
11
|
"types": "./build/src/index.d.ts",
|
|
@@ -27,7 +27,7 @@
|
|
|
27
27
|
},
|
|
28
28
|
"type": "module",
|
|
29
29
|
"devDependencies": {
|
|
30
|
-
"@livequery/
|
|
30
|
+
"@livequery/core": "file:../core",
|
|
31
31
|
"@nestjs/platform-express": "^11.1.19",
|
|
32
32
|
"@types/express": "x",
|
|
33
33
|
"@types/node": "x",
|
|
@@ -38,6 +38,7 @@
|
|
|
38
38
|
},
|
|
39
39
|
"peerDependencies": {
|
|
40
40
|
"reflect-metadata": "x",
|
|
41
|
+
"@livequery/core": "^2.0.149",
|
|
41
42
|
"@nestjs/core": "*",
|
|
42
43
|
"@nestjs/common": "*",
|
|
43
44
|
"@nestjs/platform-ws": "^11.0.10",
|
|
@@ -45,7 +46,6 @@
|
|
|
45
46
|
"express": "^4.21.2"
|
|
46
47
|
},
|
|
47
48
|
"dependencies": {
|
|
48
|
-
"@livequery/core": "file:../core",
|
|
49
49
|
"msgpackr": "^1.11.9"
|
|
50
50
|
}
|
|
51
51
|
}
|
|
@@ -1,54 +0,0 @@
|
|
|
1
|
-
import { LivequeryWebsocketSync } from './LivequeryWebsocketSync.js';
|
|
2
|
-
import { NodeMetadata } from './RxjsUdp.js';
|
|
3
|
-
export type Routing = {
|
|
4
|
-
[ref: string]: {
|
|
5
|
-
dpaths: string[];
|
|
6
|
-
children?: Routing;
|
|
7
|
-
methods?: {
|
|
8
|
-
[METHOD: string]: {
|
|
9
|
-
hosts: Array<{
|
|
10
|
-
uri: string;
|
|
11
|
-
instance_id: string;
|
|
12
|
-
}>;
|
|
13
|
-
last_requested_index: number;
|
|
14
|
-
};
|
|
15
|
-
};
|
|
16
|
-
};
|
|
17
|
-
};
|
|
18
|
-
export type ServiceApiMetadata = NodeMetadata<{
|
|
19
|
-
role: 'service' | 'gateway';
|
|
20
|
-
name: string;
|
|
21
|
-
port: number;
|
|
22
|
-
paths: Array<{
|
|
23
|
-
method: string;
|
|
24
|
-
path: string;
|
|
25
|
-
}>;
|
|
26
|
-
websocket?: string;
|
|
27
|
-
wsauth?: string;
|
|
28
|
-
linked: string[];
|
|
29
|
-
target?: string;
|
|
30
|
-
}>;
|
|
31
|
-
export type ServiceApiStatus = {
|
|
32
|
-
id: string;
|
|
33
|
-
online: boolean;
|
|
34
|
-
metadata?: ServiceApiMetadata;
|
|
35
|
-
} | {
|
|
36
|
-
id: string;
|
|
37
|
-
online: false;
|
|
38
|
-
};
|
|
39
|
-
export type ApiGatewayClientOptions = {
|
|
40
|
-
id: string;
|
|
41
|
-
name: string;
|
|
42
|
-
controllers: any[];
|
|
43
|
-
port: number;
|
|
44
|
-
};
|
|
45
|
-
export declare class ApiGateway {
|
|
46
|
-
#private;
|
|
47
|
-
private lws;
|
|
48
|
-
constructor(lws: LivequeryWebsocketSync);
|
|
49
|
-
private get;
|
|
50
|
-
private post;
|
|
51
|
-
private patch;
|
|
52
|
-
private put;
|
|
53
|
-
private del;
|
|
54
|
-
}
|