@streamsy/core 0.14.0 → 0.16.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.
@@ -1,7 +1,8 @@
1
- import { L as Storage, Q as ProducerId, R as ZERO_OFFSET, V as next, W as StorageFault, rt as StreamId } from "../streamsy-HKC10a_V.js";
2
- import { a as CommitHooks, c as OwnerRecords, i as ProjectionMarks, p as CommitBoundary } from "../boundary-f1biibJ1.js";
3
- import { a as MutationRejected, t as layer } from "../layer-DjKTdIY5.js";
4
- import { t as layer$1 } from "../layer-J6sV3UXD.js";
1
+ import { G as ProducerId, L as Storage, R as ZERO_OFFSET, V as next, X as StreamId } from "../streamsy-IBFULoEr.js";
2
+ import { _ as StorageFault } from "../read-message-CGHhOCMc.js";
3
+ import { a as CommitHooks, c as OwnerRecords, i as ProjectionMarks, p as CommitBoundary } from "../boundary-BTrhL8De.js";
4
+ import { a as MutationRejected, t as layer } from "../layer-pomDIajD.js";
5
+ import { t as layer$1 } from "../layer-C-8GAL_W.js";
5
6
  import { Array, Cause, Context, Deferred, Effect, Exit, Fiber, Layer, Match, Option, Order, Predicate, PubSub, Queue, Record, Ref, Scope, Stream } from "effect";
6
7
  import { SqlError } from "effect/sql";
7
8
  import { describe, expect, it } from "vitest";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@streamsy/core",
3
- "version": "0.14.0",
3
+ "version": "0.16.0",
4
4
  "description": "Effect-first Durable Streams protocol, storage contract, memory layer and toolkit.",
5
5
  "license": "MIT",
6
6
  "repository": {
@@ -56,14 +56,14 @@
56
56
  "test:unit": "bun --bun vitest run --dir test"
57
57
  },
58
58
  "devDependencies": {
59
- "@effect/vitest": "4.1.2",
59
+ "@effect/vitest": "4.1.5",
60
60
  "@types/bun": "^1.4.3",
61
- "effect": "4.1.2",
61
+ "effect": "4.1.5",
62
62
  "typescript": "^7.0.2",
63
63
  "vitest": "5.0.5"
64
64
  },
65
65
  "peerDependencies": {
66
- "effect": "^4.1.2",
66
+ "effect": "^4.1.5",
67
67
  "vitest": "^5.0.0"
68
68
  },
69
69
  "peerDependenciesMeta": {
@@ -1,93 +0,0 @@
1
- import { Context, Data, Effect, Predicate } from "effect";
2
- // src/internal/owner.ts
3
- /** Private bridge: a stream guard dies with this sentinel; the atomic runner translates it. */
4
- const ForeignOwnerType = Symbol.for("@streamsy/core/internal/ForeignOwner");
5
- var ForeignOwner = class extends Data.TaggedError("ForeignOwner") {
6
- stream;
7
- [ForeignOwnerType] = true;
8
- constructor(stream, knownOwner) {
9
- super({ message: knownOwner ? `Stream write to ${stream} does not share the checkpoint owner` : `Cannot establish a storage owner for ${stream}; the exposed Storage does not own the protocol wires` });
10
- this.stream = stream;
11
- }
12
- };
13
- const isForeignOwner = (value) => Predicate.hasProperty(value, ForeignOwnerType) && value[ForeignOwnerType] === true;
14
- const OwnerMetadata = Symbol.for("@streamsy/core/internal/CommitOwner");
15
- const attachOwner = (value, owner) => Object.defineProperty(value, OwnerMetadata, {
16
- value: owner,
17
- enumerable: false
18
- });
19
- const ownerOf = (value) => {
20
- if (!(OwnerMetadata in value)) return value;
21
- const owner = value[OwnerMetadata];
22
- return Predicate.isObjectKeyword(owner) ? owner : value;
23
- };
24
- const CurrentOwner = Context.Reference("@streamsy/core/internal/CurrentOwner", { defaultValue: () => void 0 });
25
- const checkWriteOwner = (owner, id, knownOwner) => Effect.flatMap(CurrentOwner, (expected) => expected === void 0 || expected === owner ? Effect.void : Effect.die(new ForeignOwner(id, knownOwner)));
26
- const Metadata = Symbol.for("@streamsy/core/internal/StorageOwner");
27
- const attachStorage = (wire, storage) => Object.defineProperty(wire, Metadata, {
28
- value: storage,
29
- enumerable: false
30
- });
31
- const storageOf = (wire) => {
32
- if (!(Metadata in wire)) return void 0;
33
- return wire[Metadata];
34
- };
35
- // src/toolkit/route-internal.ts
36
- /** Ids are canonical relative paths, the same rule the remote Layer enforces. */
37
- function isCanonicalIdSegment(value) {
38
- if (value.length === 0 || value === "." || value === "..") return false;
39
- return !/[%?#/\\]/.test(value);
40
- }
41
- function compileSegments(template) {
42
- if (template.length === 0) throw new RangeError("a stream route template must name at least one segment");
43
- if (template.startsWith("/")) throw new RangeError("a stream route template is relative and cannot start with a slash");
44
- if (/[?#*]/.test(template)) throw new RangeError("a stream route template cannot contain a query, fragment, or wildcard");
45
- const names = [];
46
- const segments = [];
47
- for (const part of template.split("/")) {
48
- if (part.length === 0) throw new RangeError("a stream route template cannot contain an empty segment");
49
- if (!part.startsWith(":")) {
50
- if (!isCanonicalIdSegment(part)) throw new RangeError(`a stream route literal segment is not a canonical id segment: ${part}`);
51
- segments.push({
52
- kind: "literal",
53
- value: part
54
- });
55
- continue;
56
- }
57
- const name = part.slice(1);
58
- if (name.length === 0) throw new RangeError("a stream route parameter needs a name");
59
- if (names.includes(name)) throw new RangeError(`duplicate stream route parameter: ${name}`);
60
- names.push(name);
61
- segments.push({
62
- kind: "parameter",
63
- name
64
- });
65
- }
66
- return {
67
- template,
68
- segments: Object.freeze(segments),
69
- names: Object.freeze(names)
70
- };
71
- }
72
- /**
73
- * True when two template routes can both match one id.
74
- *
75
- * Lengths must agree, and every position must be either an equal literal pair
76
- * or a parameter on at least one side. A parameter is treated as matching any
77
- * segment, so a codec-constrained parameter can report an overlap it would
78
- * never actually match. A custom route carries no template and is never
79
- * checked; HTTP dispatch uses declaration order and the first match wins.
80
- */
81
- function templatesOverlap(left, right) {
82
- if (left.length === 0 || right.length === 0) return false;
83
- const a = compileSegments(left).segments;
84
- const b = compileSegments(right).segments;
85
- if (a.length !== b.length) return false;
86
- for (const [index, segment] of a.entries()) {
87
- const other = b[index];
88
- if (!other || segment.kind === "parameter" || other.kind === "parameter") continue;
89
- if (segment.value !== other.value) return false;
90
- }
91
- return true;
92
- }
93
- export { attachOwner as a, isForeignOwner as c, CurrentOwner as i, ownerOf as l, isCanonicalIdSegment as n, attachStorage as o, templatesOverlap as r, checkWriteOwner as s, compileSegments as t, storageOf as u };