@xandreed/plugin-session-files 0.17.1 → 0.19.0
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 +1 -1
- package/dist/plugin.adapter.js +2 -2
- package/dist/session-log.adapter.js +8 -5
- package/package.json +3 -3
package/README.md
CHANGED
package/dist/plugin.adapter.js
CHANGED
|
@@ -4,7 +4,7 @@ import { SessionLogFilesLive } from "./session-log.adapter.js";
|
|
|
4
4
|
import { SessionFilesConfig, sessionFilesDefaults } from "./session-files.entity.js";
|
|
5
5
|
export const sessionLogFilesPlugin = definePlugin({
|
|
6
6
|
id: "@xandreed/plugin-session-files/log",
|
|
7
|
-
version: "0.
|
|
7
|
+
version: "0.19.0",
|
|
8
8
|
scope: "runtime",
|
|
9
9
|
config: SessionFilesConfig,
|
|
10
10
|
defaults: sessionFilesDefaults,
|
|
@@ -12,7 +12,7 @@ export const sessionLogFilesPlugin = definePlugin({
|
|
|
12
12
|
layer: ({ path, stallMs }) => SessionLogFilesLive(path, { stallMs })
|
|
13
13
|
}), sessionFilesPlugin = definePlugin({
|
|
14
14
|
id: "@xandreed/plugin-session-files",
|
|
15
|
-
version: "0.
|
|
15
|
+
version: "0.19.0",
|
|
16
16
|
scope: "runtime",
|
|
17
17
|
config: SessionFilesConfig,
|
|
18
18
|
defaults: sessionFilesDefaults,
|
|
@@ -207,7 +207,7 @@ export const makeSessionLogFiles = Effect.fnUntraced(function* (root, options) {
|
|
|
207
207
|
return page(heads.flatMap(Option.toArray), query);
|
|
208
208
|
}),
|
|
209
209
|
read: Effect.fn("session_log.read")(function* (id, query) {
|
|
210
|
-
const { header, tail } = yield* current(id), limit = Option.match(query.limit, { onNone: () => Number.POSITIVE_INFINITY, onSome: (value) => Math.max(0, value) }), wanted = (kind) => query.kinds.length === 0 || query.kinds.includes(kind), revisions = Array.from({ length: tail.revision }, (_, index) => index + 1), cached = Option.match(Option.filter(Option.fromNullishOr((yield* Ref.get(known)).get(id)), (entry) => entry.nonce === header.nonce), {
|
|
210
|
+
const { header, tail } = yield* current(id), limit = Option.match(query.limit, { onNone: () => Number.POSITIVE_INFINITY, onSome: (value) => Math.max(0, value) }), wanted = (kind) => query.kinds.length === 0 || query.kinds.includes(kind), latest = query.from === "end", revisions = Array.from({ length: tail.revision }, (_, index) => latest ? tail.revision - index : index + 1), cached = Option.match(Option.filter(Option.fromNullishOr((yield* Ref.get(known)).get(id)), (entry) => entry.nonce === header.nonce), {
|
|
211
211
|
onNone: () => new Map,
|
|
212
212
|
onSome: (entry) => entry.metas
|
|
213
213
|
}), fresh = new Map, metaAt = (revision) => Option.match(Option.fromNullishOr(cached.get(revision)), {
|
|
@@ -216,10 +216,13 @@ export const makeSessionLogFiles = Effect.fnUntraced(function* (root, options) {
|
|
|
216
216
|
}), events = yield* Effect.reduce(revisions, () => [], (events, revision) => {
|
|
217
217
|
if (events.length >= limit)
|
|
218
218
|
return Effect.succeed(events);
|
|
219
|
-
return metaAt(revision).pipe(Effect.flatMap((meta) => meta.last <= query.after || query.through !== void 0 && meta.first > query.through || meta.first > meta.last || !meta.kinds.some(wanted) ? Effect.succeed(events) : wholeCommit(id, revision).pipe(Effect.map((record) =>
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
219
|
+
return metaAt(revision).pipe(Effect.flatMap((meta) => meta.last <= query.after || query.through !== void 0 && meta.first > query.through || meta.first > meta.last || !meta.kinds.some(wanted) ? Effect.succeed(events) : wholeCommit(id, revision).pipe(Effect.map((record) => {
|
|
220
|
+
const matched = record.events.filter((event) => event.seq > query.after && (query.through === void 0 || event.seq <= query.through) && wanted(event.kind)).map(eventOf(id, record.meta.at));
|
|
221
|
+
if (!latest)
|
|
222
|
+
return [...events, ...matched].slice(0, limit);
|
|
223
|
+
const joined = [...matched, ...events];
|
|
224
|
+
return joined.slice(Math.max(0, joined.length - limit));
|
|
225
|
+
}))));
|
|
223
226
|
});
|
|
224
227
|
if (fresh.size > 0)
|
|
225
228
|
yield* Ref.update(known, (all) => Option.match(Option.filter(Option.fromNullishOr(all.get(id)), (entry) => entry.nonce === header.nonce), {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@xandreed/plugin-session-files",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.19.0",
|
|
4
4
|
"engines": {
|
|
5
5
|
"node": ">=24",
|
|
6
6
|
"bun": ">=1.3.0"
|
|
@@ -14,7 +14,7 @@
|
|
|
14
14
|
}
|
|
15
15
|
},
|
|
16
16
|
"dependencies": {},
|
|
17
|
-
"gitHead": "
|
|
17
|
+
"gitHead": "4f1b630a83d41da51ec42bbe978333a045297038",
|
|
18
18
|
"repository": {
|
|
19
19
|
"type": "git",
|
|
20
20
|
"url": "git+https://github.com/xandreeddev/efferent.git",
|
|
@@ -23,7 +23,7 @@
|
|
|
23
23
|
"private": false,
|
|
24
24
|
"types": "./dist/index.d.ts",
|
|
25
25
|
"peerDependencies": {
|
|
26
|
-
"@xandreed/core": "^0.
|
|
26
|
+
"@xandreed/core": "^0.19.0",
|
|
27
27
|
"effect": "^4.0.7"
|
|
28
28
|
},
|
|
29
29
|
"files": [
|