@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 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.io/branding/logotype.svg">
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.io/)**
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.io/guide/architecture/parts/)**
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://github.com/logux/logux
97
+ [documentation]: https://logux.org/
@@ -1,31 +1,31 @@
1
- import {
1
+ import type {
2
2
  LoguxSubscribeAction,
3
3
  SyncMapChangeAction,
4
4
  SyncMapCreateAction,
5
5
  SyncMapDeleteAction,
6
- SyncMapValues,
7
- SyncMapTypes
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]: WithTime<Value[Key]> | WithoutTime<Value[Key]>
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
- ): Promise<boolean> | boolean
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
- | SyncMapCreateAction
71
+ | LoguxSubscribeAction
72
72
  | SyncMapChangeAction
73
- | SyncMapDeleteAction
74
- | LoguxSubscribeAction,
73
+ | SyncMapCreateAction
74
+ | SyncMapDeleteAction,
75
75
  meta: ServerMeta
76
- ): Promise<boolean> | boolean
76
+ ): boolean | Promise<boolean>
77
77
 
78
- load?(
78
+ change?(
79
79
  ctx: Context,
80
80
  id: string,
81
- since: number | undefined,
82
- action: LoguxSubscribeAction,
81
+ fields: Partial<Value>,
82
+ time: number,
83
+ action: SyncMapChangeAction<Value>,
83
84
  meta: ServerMeta
84
- ): Promise<SyncMapData<Value>> | SyncMapData<Value> | false | Promise<false>
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
- ): Promise<void | boolean> | void | boolean
94
+ ): boolean | Promise<boolean | void> | void
94
95
 
95
- change?(
96
+ delete?(
96
97
  ctx: Context,
97
98
  id: string,
98
- fields: Partial<Value>,
99
- time: number,
100
- action: SyncMapChangeAction<Value>,
99
+ action: SyncMapDeleteAction,
101
100
  meta: ServerMeta
102
- ): Promise<void | boolean> | void | boolean
101
+ ): boolean | Promise<boolean | void> | void
103
102
 
104
- delete?(
103
+ load?(
105
104
  ctx: Context,
106
105
  id: string,
107
- action: SyncMapDeleteAction,
106
+ since: number | undefined,
107
+ action: LoguxSubscribeAction,
108
108
  meta: ServerMeta
109
- ): Promise<void | boolean> | void | boolean
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
- ): Promise<boolean> | boolean
118
+ ): boolean | Promise<boolean>
119
119
 
120
- initial(
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<SyncMapData<Value>[]> | SyncMapData<Value>[]
125
+ ): Promise<SyncMapActionFilter<Value>> | SyncMapActionFilter<Value> | void
127
126
 
128
- actions?(
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<SyncMapActionFilter<Value>> | SyncMapActionFilter<Value> | void
133
+ ): Promise<SyncMapData<Value>[]> | SyncMapData<Value>[]
134
134
  }
135
135
 
136
136
  /**
@@ -1,7 +1,7 @@
1
1
  const WITH_TIME = Symbol('WITH_TIME')
2
2
 
3
3
  export function ChangedAt(value, time) {
4
- return { value, time, [WITH_TIME]: true }
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
- { time: meta.time, excludeClients: [ctx.clientId] }
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
- type: changedType,
74
+ fields,
75
75
  id,
76
- fields
76
+ type: changedType
77
77
  },
78
78
  changedMeta
79
79
  )
@@ -19,7 +19,7 @@
19
19
  </style>
20
20
  </head>
21
21
  <body>
22
- <a href="https://logux.io/">
22
+ <a href="https://logux.org/">
23
23
  <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 75 117">
24
24
  <g fill="none" fill-rule="evenodd">
25
25
  <path d="M-1 0h78v117H-1z" />