@logux/server 0.12.2 → 0.12.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/README.md +4 -6
- package/add-sync-map/index.d.ts +32 -32
- package/add-sync-map/index.js +4 -4
- package/base-server/hello.html +1 -1
- package/base-server/index.d.ts +401 -401
- package/base-server/index.js +332 -321
- package/bind-backend-proxy/index.js +77 -77
- package/bind-control-server/index.js +1 -1
- package/context/index.d.ts +36 -36
- package/context/index.js +1 -1
- package/create-http-server/index.js +4 -4
- package/create-reporter/index.js +107 -107
- package/filter-meta/index.d.ts +1 -1
- package/human-formatter/index.js +13 -13
- package/index.d.ts +24 -24
- package/index.js +16 -16
- package/options-loader/index.js +2 -2
- package/options-loader/index.test.js +25 -24
- package/package.json +13 -13
- package/request/index.d.ts +2 -1
- package/request/test.test.js +60 -34
- package/server/index.d.ts +27 -23
- package/server/index.js +56 -56
- package/server-client/index.d.ts +41 -41
- package/server-client/index.js +61 -61
- package/test-client/index.d.ts +50 -50
- package/test-client/index.js +28 -28
- package/test-server/index.d.ts +44 -43
- package/test-server/index.js +20 -20
- package/vite.config.ts +13 -0
package/README.md
CHANGED
|
@@ -1,17 +1,16 @@
|
|
|
1
1
|
# Logux Server [![Cult Of Martians][cult-img]][cult]
|
|
2
2
|
|
|
3
3
|
<img align="right" width="95" height="148" title="Logux logotype"
|
|
4
|
-
src="https://logux.
|
|
4
|
+
src="https://logux.org/branding/logotype.svg">
|
|
5
5
|
|
|
6
6
|
Logux is a new way to connect client and server. Instead of sending
|
|
7
7
|
HTTP requests (e.g., AJAX and GraphQL) it synchronizes log of operations
|
|
8
8
|
between client, server, and other clients.
|
|
9
9
|
|
|
10
|
-
* **[Guide, recipes, and API](https://logux.
|
|
11
|
-
* **[Chat](https://gitter.im/logux/logux)** for any questions
|
|
10
|
+
* **[Guide, recipes, and API](https://logux.org/)**
|
|
12
11
|
* **[Issues](https://github.com/logux/logux/issues)**
|
|
13
12
|
and **[roadmap](https://github.com/orgs/logux/projects/1)**
|
|
14
|
-
* **[Projects](https://logux.
|
|
13
|
+
* **[Projects](https://logux.org/guide/architecture/parts/)**
|
|
15
14
|
inside Logux ecosystem
|
|
16
15
|
|
|
17
16
|
This repository contains Logux server with:
|
|
@@ -24,7 +23,6 @@ This repository contains Logux server with:
|
|
|
24
23
|
alt="Sponsored by Evil Martians" width="236" height="54">
|
|
25
24
|
</a>
|
|
26
25
|
|
|
27
|
-
[logux.io]: https://logux.io/
|
|
28
26
|
[cult-img]: http://cultofmartians.com/assets/badges/badge.svg
|
|
29
27
|
[cult]: http://cultofmartians.com/done.html
|
|
30
28
|
|
|
@@ -96,4 +94,4 @@ server.type('CHANGE_NAME', {
|
|
|
96
94
|
server.listen()
|
|
97
95
|
```
|
|
98
96
|
|
|
99
|
-
[documentation]: https://
|
|
97
|
+
[documentation]: https://logux.org/
|
package/add-sync-map/index.d.ts
CHANGED
|
@@ -1,31 +1,31 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import type {
|
|
2
2
|
LoguxSubscribeAction,
|
|
3
3
|
SyncMapChangeAction,
|
|
4
4
|
SyncMapCreateAction,
|
|
5
5
|
SyncMapDeleteAction,
|
|
6
|
-
|
|
7
|
-
|
|
6
|
+
SyncMapTypes,
|
|
7
|
+
SyncMapValues
|
|
8
8
|
} from '@logux/actions'
|
|
9
9
|
|
|
10
|
-
import { BaseServer, ServerMeta } from '../base-server/index.js'
|
|
11
|
-
import { Context } from '../context/index.js'
|
|
10
|
+
import type { BaseServer, ServerMeta } from '../base-server/index.js'
|
|
11
|
+
import type { Context } from '../context/index.js'
|
|
12
12
|
|
|
13
13
|
declare const WITH_TIME: unique symbol
|
|
14
14
|
|
|
15
15
|
export type WithTime<Value extends SyncMapTypes | SyncMapTypes[]> = {
|
|
16
|
-
value: Value
|
|
17
16
|
time: number
|
|
17
|
+
value: Value
|
|
18
18
|
[WITH_TIME]: true
|
|
19
19
|
}
|
|
20
20
|
|
|
21
21
|
export type WithoutTime<Value extends SyncMapTypes | SyncMapTypes[]> = {
|
|
22
|
-
value: Value
|
|
23
22
|
time: undefined
|
|
23
|
+
value: Value
|
|
24
24
|
[WITH_TIME]: false
|
|
25
25
|
}
|
|
26
26
|
|
|
27
27
|
export type SyncMapData<Value extends SyncMapValues> = { id: string } & {
|
|
28
|
-
[Key in keyof Value]:
|
|
28
|
+
[Key in keyof Value]: WithoutTime<Value[Key]> | WithTime<Value[Key]>
|
|
29
29
|
}
|
|
30
30
|
|
|
31
31
|
/**
|
|
@@ -60,7 +60,7 @@ interface SyncMapActionFilter<Value extends SyncMapValues> {
|
|
|
60
60
|
ctx: Context,
|
|
61
61
|
action: SyncMapCreateAction<Value> | SyncMapDeleteAction,
|
|
62
62
|
meta: ServerMeta
|
|
63
|
-
):
|
|
63
|
+
): boolean | Promise<boolean>
|
|
64
64
|
}
|
|
65
65
|
|
|
66
66
|
interface SyncMapOperations<Value extends SyncMapValues> {
|
|
@@ -68,20 +68,21 @@ interface SyncMapOperations<Value extends SyncMapValues> {
|
|
|
68
68
|
ctx: Context,
|
|
69
69
|
id: string,
|
|
70
70
|
action:
|
|
71
|
-
|
|
|
71
|
+
| LoguxSubscribeAction
|
|
72
72
|
| SyncMapChangeAction
|
|
73
|
-
|
|
|
74
|
-
|
|
|
73
|
+
| SyncMapCreateAction
|
|
74
|
+
| SyncMapDeleteAction,
|
|
75
75
|
meta: ServerMeta
|
|
76
|
-
):
|
|
76
|
+
): boolean | Promise<boolean>
|
|
77
77
|
|
|
78
|
-
|
|
78
|
+
change?(
|
|
79
79
|
ctx: Context,
|
|
80
80
|
id: string,
|
|
81
|
-
|
|
82
|
-
|
|
81
|
+
fields: Partial<Value>,
|
|
82
|
+
time: number,
|
|
83
|
+
action: SyncMapChangeAction<Value>,
|
|
83
84
|
meta: ServerMeta
|
|
84
|
-
): Promise<
|
|
85
|
+
): boolean | Promise<boolean | void> | void
|
|
85
86
|
|
|
86
87
|
create?(
|
|
87
88
|
ctx: Context,
|
|
@@ -90,23 +91,22 @@ interface SyncMapOperations<Value extends SyncMapValues> {
|
|
|
90
91
|
time: number,
|
|
91
92
|
action: SyncMapCreateAction<Value>,
|
|
92
93
|
meta: ServerMeta
|
|
93
|
-
):
|
|
94
|
+
): boolean | Promise<boolean | void> | void
|
|
94
95
|
|
|
95
|
-
|
|
96
|
+
delete?(
|
|
96
97
|
ctx: Context,
|
|
97
98
|
id: string,
|
|
98
|
-
|
|
99
|
-
time: number,
|
|
100
|
-
action: SyncMapChangeAction<Value>,
|
|
99
|
+
action: SyncMapDeleteAction,
|
|
101
100
|
meta: ServerMeta
|
|
102
|
-
):
|
|
101
|
+
): boolean | Promise<boolean | void> | void
|
|
103
102
|
|
|
104
|
-
|
|
103
|
+
load?(
|
|
105
104
|
ctx: Context,
|
|
106
105
|
id: string,
|
|
107
|
-
|
|
106
|
+
since: number | undefined,
|
|
107
|
+
action: LoguxSubscribeAction,
|
|
108
108
|
meta: ServerMeta
|
|
109
|
-
):
|
|
109
|
+
): false | Promise<false | SyncMapData<Value>> | SyncMapData<Value>
|
|
110
110
|
}
|
|
111
111
|
|
|
112
112
|
interface SyncMapFilterOperations<Value extends SyncMapValues> {
|
|
@@ -115,22 +115,22 @@ interface SyncMapFilterOperations<Value extends SyncMapValues> {
|
|
|
115
115
|
filter: Partial<Value> | undefined,
|
|
116
116
|
action: LoguxSubscribeAction,
|
|
117
117
|
meta: ServerMeta
|
|
118
|
-
):
|
|
118
|
+
): boolean | Promise<boolean>
|
|
119
119
|
|
|
120
|
-
|
|
120
|
+
actions?(
|
|
121
121
|
ctx: Context,
|
|
122
122
|
filter: Partial<Value> | undefined,
|
|
123
|
-
since: number | undefined,
|
|
124
123
|
action: LoguxSubscribeAction,
|
|
125
124
|
meta: ServerMeta
|
|
126
|
-
): Promise<
|
|
125
|
+
): Promise<SyncMapActionFilter<Value>> | SyncMapActionFilter<Value> | void
|
|
127
126
|
|
|
128
|
-
|
|
127
|
+
initial(
|
|
129
128
|
ctx: Context,
|
|
130
129
|
filter: Partial<Value> | undefined,
|
|
130
|
+
since: number | undefined,
|
|
131
131
|
action: LoguxSubscribeAction,
|
|
132
132
|
meta: ServerMeta
|
|
133
|
-
): Promise<
|
|
133
|
+
): Promise<SyncMapData<Value>[]> | SyncMapData<Value>[]
|
|
134
134
|
}
|
|
135
135
|
|
|
136
136
|
/**
|
package/add-sync-map/index.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
const WITH_TIME = Symbol('WITH_TIME')
|
|
2
2
|
|
|
3
3
|
export function ChangedAt(value, time) {
|
|
4
|
-
return {
|
|
4
|
+
return { time, value, [WITH_TIME]: true }
|
|
5
5
|
}
|
|
6
6
|
|
|
7
7
|
export function NoConflictResolution(value) {
|
|
@@ -11,7 +11,7 @@ export function NoConflictResolution(value) {
|
|
|
11
11
|
async function addFinished(server, ctx, type, action, meta) {
|
|
12
12
|
await server.process(
|
|
13
13
|
{ ...action, type },
|
|
14
|
-
{
|
|
14
|
+
{ excludeClients: [ctx.clientId], time: meta.time }
|
|
15
15
|
)
|
|
16
16
|
}
|
|
17
17
|
|
|
@@ -71,9 +71,9 @@ async function sendMap(server, changedType, data, since) {
|
|
|
71
71
|
}
|
|
72
72
|
await server.process(
|
|
73
73
|
{
|
|
74
|
-
|
|
74
|
+
fields,
|
|
75
75
|
id,
|
|
76
|
-
|
|
76
|
+
type: changedType
|
|
77
77
|
},
|
|
78
78
|
changedMeta
|
|
79
79
|
)
|
package/base-server/hello.html
CHANGED