@logux/server 0.12.3 → 0.12.5
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 +30 -29
- package/add-sync-map/index.js +4 -4
- package/base-server/hello.html +1 -1
- package/base-server/index.d.ts +397 -396
- package/base-server/index.js +308 -308
- package/bind-backend-proxy/index.js +77 -77
- package/bind-control-server/index.js +1 -1
- package/context/index.d.ts +34 -33
- package/context/index.js +1 -1
- package/create-http-server/index.js +4 -4
- package/create-reporter/index.js +107 -107
- 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 -25
- package/package.json +11 -11
- package/request/test.test.js +19 -19
- package/server/index.d.ts +27 -25
- package/server/index.js +56 -56
- package/server-client/index.d.ts +40 -39
- package/server-client/index.js +61 -61
- package/test-client/index.d.ts +47 -46
- package/test-client/index.js +28 -28
- package/test-server/index.d.ts +43 -42
- package/test-server/index.js +20 -20
- package/vite.config.ts +5 -5
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
|
@@ -3,28 +3,29 @@ import type {
|
|
|
3
3
|
SyncMapChangeAction,
|
|
4
4
|
SyncMapCreateAction,
|
|
5
5
|
SyncMapDeleteAction,
|
|
6
|
-
|
|
7
|
-
|
|
6
|
+
SyncMapTypes,
|
|
7
|
+
SyncMapValues
|
|
8
8
|
} from '@logux/actions'
|
|
9
|
+
|
|
9
10
|
import type { BaseServer, ServerMeta } from '../base-server/index.js'
|
|
10
11
|
import type { Context } from '../context/index.js'
|
|
11
12
|
|
|
12
13
|
declare const WITH_TIME: unique symbol
|
|
13
14
|
|
|
14
15
|
export type WithTime<Value extends SyncMapTypes | SyncMapTypes[]> = {
|
|
15
|
-
value: Value
|
|
16
16
|
time: number
|
|
17
|
+
value: Value
|
|
17
18
|
[WITH_TIME]: true
|
|
18
19
|
}
|
|
19
20
|
|
|
20
21
|
export type WithoutTime<Value extends SyncMapTypes | SyncMapTypes[]> = {
|
|
21
|
-
value: Value
|
|
22
22
|
time: undefined
|
|
23
|
+
value: Value
|
|
23
24
|
[WITH_TIME]: false
|
|
24
25
|
}
|
|
25
26
|
|
|
26
27
|
export type SyncMapData<Value extends SyncMapValues> = { id: string } & {
|
|
27
|
-
[Key in keyof Value]:
|
|
28
|
+
[Key in keyof Value]: WithoutTime<Value[Key]> | WithTime<Value[Key]>
|
|
28
29
|
}
|
|
29
30
|
|
|
30
31
|
/**
|
|
@@ -59,7 +60,7 @@ interface SyncMapActionFilter<Value extends SyncMapValues> {
|
|
|
59
60
|
ctx: Context,
|
|
60
61
|
action: SyncMapCreateAction<Value> | SyncMapDeleteAction,
|
|
61
62
|
meta: ServerMeta
|
|
62
|
-
):
|
|
63
|
+
): boolean | Promise<boolean>
|
|
63
64
|
}
|
|
64
65
|
|
|
65
66
|
interface SyncMapOperations<Value extends SyncMapValues> {
|
|
@@ -67,20 +68,21 @@ interface SyncMapOperations<Value extends SyncMapValues> {
|
|
|
67
68
|
ctx: Context,
|
|
68
69
|
id: string,
|
|
69
70
|
action:
|
|
70
|
-
|
|
|
71
|
+
| LoguxSubscribeAction
|
|
71
72
|
| SyncMapChangeAction
|
|
72
|
-
|
|
|
73
|
-
|
|
|
73
|
+
| SyncMapCreateAction
|
|
74
|
+
| SyncMapDeleteAction,
|
|
74
75
|
meta: ServerMeta
|
|
75
|
-
):
|
|
76
|
+
): boolean | Promise<boolean>
|
|
76
77
|
|
|
77
|
-
|
|
78
|
+
change?(
|
|
78
79
|
ctx: Context,
|
|
79
80
|
id: string,
|
|
80
|
-
|
|
81
|
-
|
|
81
|
+
fields: Partial<Value>,
|
|
82
|
+
time: number,
|
|
83
|
+
action: SyncMapChangeAction<Value>,
|
|
82
84
|
meta: ServerMeta
|
|
83
|
-
):
|
|
85
|
+
): boolean | Promise<boolean | void> | void
|
|
84
86
|
|
|
85
87
|
create?(
|
|
86
88
|
ctx: Context,
|
|
@@ -89,23 +91,22 @@ interface SyncMapOperations<Value extends SyncMapValues> {
|
|
|
89
91
|
time: number,
|
|
90
92
|
action: SyncMapCreateAction<Value>,
|
|
91
93
|
meta: ServerMeta
|
|
92
|
-
):
|
|
94
|
+
): boolean | Promise<boolean | void> | void
|
|
93
95
|
|
|
94
|
-
|
|
96
|
+
delete?(
|
|
95
97
|
ctx: Context,
|
|
96
98
|
id: string,
|
|
97
|
-
|
|
98
|
-
time: number,
|
|
99
|
-
action: SyncMapChangeAction<Value>,
|
|
99
|
+
action: SyncMapDeleteAction,
|
|
100
100
|
meta: ServerMeta
|
|
101
|
-
):
|
|
101
|
+
): boolean | Promise<boolean | void> | void
|
|
102
102
|
|
|
103
|
-
|
|
103
|
+
load?(
|
|
104
104
|
ctx: Context,
|
|
105
105
|
id: string,
|
|
106
|
-
|
|
106
|
+
since: number | undefined,
|
|
107
|
+
action: LoguxSubscribeAction,
|
|
107
108
|
meta: ServerMeta
|
|
108
|
-
):
|
|
109
|
+
): false | Promise<false | SyncMapData<Value>> | SyncMapData<Value>
|
|
109
110
|
}
|
|
110
111
|
|
|
111
112
|
interface SyncMapFilterOperations<Value extends SyncMapValues> {
|
|
@@ -114,22 +115,22 @@ interface SyncMapFilterOperations<Value extends SyncMapValues> {
|
|
|
114
115
|
filter: Partial<Value> | undefined,
|
|
115
116
|
action: LoguxSubscribeAction,
|
|
116
117
|
meta: ServerMeta
|
|
117
|
-
):
|
|
118
|
+
): boolean | Promise<boolean>
|
|
118
119
|
|
|
119
|
-
|
|
120
|
+
actions?(
|
|
120
121
|
ctx: Context,
|
|
121
122
|
filter: Partial<Value> | undefined,
|
|
122
|
-
since: number | undefined,
|
|
123
123
|
action: LoguxSubscribeAction,
|
|
124
124
|
meta: ServerMeta
|
|
125
|
-
): Promise<
|
|
125
|
+
): Promise<SyncMapActionFilter<Value>> | SyncMapActionFilter<Value> | void
|
|
126
126
|
|
|
127
|
-
|
|
127
|
+
initial(
|
|
128
128
|
ctx: Context,
|
|
129
129
|
filter: Partial<Value> | undefined,
|
|
130
|
+
since: number | undefined,
|
|
130
131
|
action: LoguxSubscribeAction,
|
|
131
132
|
meta: ServerMeta
|
|
132
|
-
): Promise<
|
|
133
|
+
): Promise<SyncMapData<Value>[]> | SyncMapData<Value>[]
|
|
133
134
|
}
|
|
134
135
|
|
|
135
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