@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 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/
@@ -3,28 +3,29 @@ import type {
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 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]: WithTime<Value[Key]> | WithoutTime<Value[Key]>
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
- ): Promise<boolean> | boolean
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
- | SyncMapCreateAction
71
+ | LoguxSubscribeAction
71
72
  | SyncMapChangeAction
72
- | SyncMapDeleteAction
73
- | LoguxSubscribeAction,
73
+ | SyncMapCreateAction
74
+ | SyncMapDeleteAction,
74
75
  meta: ServerMeta
75
- ): Promise<boolean> | boolean
76
+ ): boolean | Promise<boolean>
76
77
 
77
- load?(
78
+ change?(
78
79
  ctx: Context,
79
80
  id: string,
80
- since: number | undefined,
81
- action: LoguxSubscribeAction,
81
+ fields: Partial<Value>,
82
+ time: number,
83
+ action: SyncMapChangeAction<Value>,
82
84
  meta: ServerMeta
83
- ): Promise<SyncMapData<Value> | false> | SyncMapData<Value> | false
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
- ): Promise<void | boolean> | void | boolean
94
+ ): boolean | Promise<boolean | void> | void
93
95
 
94
- change?(
96
+ delete?(
95
97
  ctx: Context,
96
98
  id: string,
97
- fields: Partial<Value>,
98
- time: number,
99
- action: SyncMapChangeAction<Value>,
99
+ action: SyncMapDeleteAction,
100
100
  meta: ServerMeta
101
- ): Promise<void | boolean> | void | boolean
101
+ ): boolean | Promise<boolean | void> | void
102
102
 
103
- delete?(
103
+ load?(
104
104
  ctx: Context,
105
105
  id: string,
106
- action: SyncMapDeleteAction,
106
+ since: number | undefined,
107
+ action: LoguxSubscribeAction,
107
108
  meta: ServerMeta
108
- ): Promise<void | boolean> | void | boolean
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
- ): Promise<boolean> | boolean
118
+ ): boolean | Promise<boolean>
118
119
 
119
- initial(
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<SyncMapData<Value>[]> | SyncMapData<Value>[]
125
+ ): Promise<SyncMapActionFilter<Value>> | SyncMapActionFilter<Value> | void
126
126
 
127
- actions?(
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<SyncMapActionFilter<Value>> | SyncMapActionFilter<Value> | void
133
+ ): Promise<SyncMapData<Value>[]> | SyncMapData<Value>[]
133
134
  }
134
135
 
135
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" />