@usine/core 0.6.1-next.378.gf0f018d.1.1 → 0.6.1-next.379.gd0900a3.1.1
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/dist/changes.d.ts +43 -0
- package/dist/changes.d.ts.map +1 -0
- package/dist/changes.js +59 -0
- package/dist/changes.js.map +1 -0
- package/dist/item.d.ts +5 -0
- package/dist/item.d.ts.map +1 -1
- package/dist/item.js +6 -0
- package/dist/item.js.map +1 -1
- package/package.json +5 -1
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { Context, Effect, Layer, Schema, Stream, type Scope } from "effect";
|
|
2
|
+
/** Identifies a read affected by a committed write, without carrying its contents. */
|
|
3
|
+
export declare const ChangeTarget: Schema.Struct<{
|
|
4
|
+
readonly kind: Schema.Literals<readonly ["project", "item", "run", "attempt", "worker", "configuration", "attention", "activity", "navigation"]>;
|
|
5
|
+
readonly id: Schema.String;
|
|
6
|
+
}>;
|
|
7
|
+
export type ChangeTarget = typeof ChangeTarget.Type;
|
|
8
|
+
/** Repository and loop ownership are resolved from configuration when a subscriber reads a notice. */
|
|
9
|
+
export declare const ChangeAudience: Schema.Union<readonly [Schema.Union<readonly [typeof import("./access.ts").InstanceScope, typeof import("./access.ts").ProjectScope]>, Schema.Struct<{
|
|
10
|
+
readonly _tag: Schema.Literal<"Repository">;
|
|
11
|
+
readonly repository: Schema.brand<Schema.String, "RepositoryName">;
|
|
12
|
+
}>, Schema.Struct<{
|
|
13
|
+
readonly _tag: Schema.Literal<"Loop">;
|
|
14
|
+
readonly loop: Schema.brand<Schema.NonEmptyString, "LoopName">;
|
|
15
|
+
}>, Schema.Struct<{
|
|
16
|
+
readonly _tag: Schema.Literal<"Readers">;
|
|
17
|
+
}>]>;
|
|
18
|
+
export type ChangeAudience = typeof ChangeAudience.Type;
|
|
19
|
+
export interface ScopedChange {
|
|
20
|
+
readonly audience: ChangeAudience;
|
|
21
|
+
readonly target: ChangeTarget;
|
|
22
|
+
}
|
|
23
|
+
export interface CommittedChanges {
|
|
24
|
+
readonly revision: number;
|
|
25
|
+
readonly changes: ReadonlyArray<ScopedChange>;
|
|
26
|
+
}
|
|
27
|
+
interface Journal {
|
|
28
|
+
readonly revision: number;
|
|
29
|
+
readonly history: ReadonlyArray<CommittedChanges>;
|
|
30
|
+
}
|
|
31
|
+
interface ChangeBusService {
|
|
32
|
+
readonly publish: (changes: ReadonlyArray<ScopedChange>) => Effect.Effect<void>;
|
|
33
|
+
/** Subscribes before reading replay state so writes cannot fall between replay and live delivery. */
|
|
34
|
+
readonly open: Effect.Effect<Journal & {
|
|
35
|
+
readonly live: Stream.Stream<CommittedChanges>;
|
|
36
|
+
}, never, Scope.Scope>;
|
|
37
|
+
}
|
|
38
|
+
/** Optional observation for standalone blocks; the server provides one bus for its entire lifetime. */
|
|
39
|
+
export declare const ChangeBus: Context.Reference<ChangeBusService>;
|
|
40
|
+
/** Retains at most 256 committed notices and drops old messages for slow subscribers. */
|
|
41
|
+
export declare const changeBusLayer: Layer.Layer<never, never, never>;
|
|
42
|
+
export {};
|
|
43
|
+
//# sourceMappingURL=changes.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"changes.d.ts","sourceRoot":"","sources":["../src/changes.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,OAAO,EACP,MAAM,EACN,KAAK,EAEL,MAAM,EACN,MAAM,EAEN,KAAK,KAAK,EACX,MAAM,QAAQ,CAAC;AAKhB,sFAAsF;AACtF,eAAO,MAAM,YAAY;;;EAavB,CAAC;AACH,MAAM,MAAM,YAAY,GAAG,OAAO,YAAY,CAAC,IAAI,CAAC;AAEpD,sGAAsG;AACtG,eAAO,MAAM,cAAc;;;;;;;;IAKzB,CAAC;AACH,MAAM,MAAM,cAAc,GAAG,OAAO,cAAc,CAAC,IAAI,CAAC;AAExD,MAAM,WAAW,YAAY;IAC3B,QAAQ,CAAC,QAAQ,EAAE,cAAc,CAAC;IAClC,QAAQ,CAAC,MAAM,EAAE,YAAY,CAAC;CAC/B;AACD,MAAM,WAAW,gBAAgB;IAC/B,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;IAC1B,QAAQ,CAAC,OAAO,EAAE,aAAa,CAAC,YAAY,CAAC,CAAC;CAC/C;AACD,UAAU,OAAO;IACf,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;IAC1B,QAAQ,CAAC,OAAO,EAAE,aAAa,CAAC,gBAAgB,CAAC,CAAC;CACnD;AACD,UAAU,gBAAgB;IACxB,QAAQ,CAAC,OAAO,EAAE,CAAC,OAAO,EAAE,aAAa,CAAC,YAAY,CAAC,KAAK,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;IAChF,qGAAqG;IACrG,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC,MAAM,CAC1B,OAAO,GAAG;QAAE,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC,MAAM,CAAC,gBAAgB,CAAC,CAAA;KAAE,EAC5D,KAAK,EACL,KAAK,CAAC,KAAK,CACZ,CAAC;CACH;AAED,uGAAuG;AACvG,eAAO,MAAM,SAAS,qCAKpB,CAAC;AAEH,yFAAyF;AACzF,eAAO,MAAM,cAAc,kCAgC1B,CAAC"}
|
package/dist/changes.js
ADDED
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import { Context, Effect, Layer, PubSub, Schema, Stream, SynchronizedRef, } from "effect";
|
|
2
|
+
import { AccessScope } from "./access.js";
|
|
3
|
+
import { LoopName } from "./loop.js";
|
|
4
|
+
import { RepositoryName } from "./repository.js";
|
|
5
|
+
/** Identifies a read affected by a committed write, without carrying its contents. */
|
|
6
|
+
export const ChangeTarget = Schema.Struct({
|
|
7
|
+
kind: Schema.Literals([
|
|
8
|
+
"project",
|
|
9
|
+
"item",
|
|
10
|
+
"run",
|
|
11
|
+
"attempt",
|
|
12
|
+
"worker",
|
|
13
|
+
"configuration",
|
|
14
|
+
"attention",
|
|
15
|
+
"activity",
|
|
16
|
+
"navigation",
|
|
17
|
+
]),
|
|
18
|
+
id: Schema.String,
|
|
19
|
+
});
|
|
20
|
+
/** Repository and loop ownership are resolved from configuration when a subscriber reads a notice. */
|
|
21
|
+
export const ChangeAudience = Schema.Union([
|
|
22
|
+
AccessScope,
|
|
23
|
+
Schema.Struct({ _tag: Schema.Literal("Repository"), repository: RepositoryName }),
|
|
24
|
+
Schema.Struct({ _tag: Schema.Literal("Loop"), loop: LoopName }),
|
|
25
|
+
Schema.Struct({ _tag: Schema.Literal("Readers") }),
|
|
26
|
+
]);
|
|
27
|
+
/** Optional observation for standalone blocks; the server provides one bus for its entire lifetime. */
|
|
28
|
+
export const ChangeBus = Context.Reference("@usine/core/ChangeBus", {
|
|
29
|
+
defaultValue: () => ({
|
|
30
|
+
publish: () => Effect.void,
|
|
31
|
+
open: Effect.succeed({ revision: 0, history: [], live: Stream.never }),
|
|
32
|
+
}),
|
|
33
|
+
});
|
|
34
|
+
/** Retains at most 256 committed notices and drops old messages for slow subscribers. */
|
|
35
|
+
export const changeBusLayer = Layer.effect(ChangeBus, Effect.gen(function* () {
|
|
36
|
+
const messages = yield* Effect.acquireRelease(PubSub.sliding(256), PubSub.shutdown);
|
|
37
|
+
const state = yield* SynchronizedRef.make({ revision: Date.now(), history: [] });
|
|
38
|
+
const publish = Effect.fn("ChangeBus.publish")(function* (changes) {
|
|
39
|
+
if (changes.length === 0)
|
|
40
|
+
return;
|
|
41
|
+
yield* SynchronizedRef.updateEffect(state, (previous) => Effect.gen(function* () {
|
|
42
|
+
const notice = { revision: previous.revision + 1, changes };
|
|
43
|
+
yield* Effect.annotateCurrentSpan({ revision: notice.revision, targets: changes.length });
|
|
44
|
+
yield* PubSub.publish(messages, notice);
|
|
45
|
+
yield* Effect.logDebug("Committed change notice published", {
|
|
46
|
+
revision: notice.revision,
|
|
47
|
+
targets: changes.map(({ target }) => target),
|
|
48
|
+
});
|
|
49
|
+
return { revision: notice.revision, history: [...previous.history, notice].slice(-256) };
|
|
50
|
+
})).pipe(Effect.uninterruptible);
|
|
51
|
+
});
|
|
52
|
+
const open = Effect.gen(function* () {
|
|
53
|
+
const subscription = yield* PubSub.subscribe(messages);
|
|
54
|
+
const journal = yield* SynchronizedRef.get(state);
|
|
55
|
+
return { ...journal, live: Stream.fromSubscription(subscription) };
|
|
56
|
+
});
|
|
57
|
+
return { publish, open };
|
|
58
|
+
}));
|
|
59
|
+
//# sourceMappingURL=changes.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"changes.js","sourceRoot":"","sources":["../src/changes.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,OAAO,EACP,MAAM,EACN,KAAK,EACL,MAAM,EACN,MAAM,EACN,MAAM,EACN,eAAe,GAEhB,MAAM,QAAQ,CAAC;AAChB,OAAO,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAC1C,OAAO,EAAE,QAAQ,EAAE,MAAM,WAAW,CAAC;AACrC,OAAO,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAC;AAEjD,sFAAsF;AACtF,MAAM,CAAC,MAAM,YAAY,GAAG,MAAM,CAAC,MAAM,CAAC;IACxC,IAAI,EAAE,MAAM,CAAC,QAAQ,CAAC;QACpB,SAAS;QACT,MAAM;QACN,KAAK;QACL,SAAS;QACT,QAAQ;QACR,eAAe;QACf,WAAW;QACX,UAAU;QACV,YAAY;KACb,CAAC;IACF,EAAE,EAAE,MAAM,CAAC,MAAM;CAClB,CAAC,CAAC;AAGH,sGAAsG;AACtG,MAAM,CAAC,MAAM,cAAc,GAAG,MAAM,CAAC,KAAK,CAAC;IACzC,WAAW;IACX,MAAM,CAAC,MAAM,CAAC,EAAE,IAAI,EAAE,MAAM,CAAC,OAAO,CAAC,YAAY,CAAC,EAAE,UAAU,EAAE,cAAc,EAAE,CAAC;IACjF,MAAM,CAAC,MAAM,CAAC,EAAE,IAAI,EAAE,MAAM,CAAC,OAAO,CAAC,MAAM,CAAC,EAAE,IAAI,E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-5,4 +5,9 @@ export type ItemKey = typeof ItemKey.Type;
|
|
|
5
5
|
/** A positive GitHub issue or pull request number, unique within its repository. */
|
|
6
6
|
export declare const ItemNumber: Schema.brand<Schema.Int, "ItemNumber">;
|
|
7
7
|
export type ItemNumber = typeof ItemNumber.Type;
|
|
8
|
+
/**
|
|
9
|
+
* The stable key of a GitHub issue or pull request: the canonical repository name and item number.
|
|
10
|
+
* Schedule run keys contain only the repository and don't decode as an item.
|
|
11
|
+
*/
|
|
12
|
+
export declare const GitHubItemKey: Schema.compose<Schema.fromJsonString<Schema.Tuple<readonly [Schema.Literal<"github">, Schema.brand<Schema.String, "RepositoryName">, Schema.brand<Schema.Int, "ItemNumber">]>>, Schema.toType<Schema.brand<Schema.NonEmptyString, "ItemKey">>>;
|
|
8
13
|
//# sourceMappingURL=item.d.ts.map
|
package/dist/item.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"item.d.ts","sourceRoot":"","sources":["../src/item.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;
|
|
1
|
+
{"version":3,"file":"item.d.ts","sourceRoot":"","sources":["../src/item.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAGhC,iFAAiF;AACjF,eAAO,MAAM,OAAO,gDAAsD,CAAC;AAE3E,MAAM,MAAM,OAAO,GAAG,OAAO,OAAO,CAAC,IAAI,CAAC;AAE1C,oFAAoF;AACpF,eAAO,MAAM,UAAU,wCAEtB,CAAC;AACF,MAAM,MAAM,UAAU,GAAG,OAAO,UAAU,CAAC,IAAI,CAAC;AAEhD;;;GAGG;AACH,eAAO,MAAM,aAAa,gPAIzB,CAAC"}
|
package/dist/item.js
CHANGED
|
@@ -1,6 +1,12 @@
|
|
|
1
1
|
import { Schema } from "effect";
|
|
2
|
+
import { RepositoryName } from "./repository.js";
|
|
2
3
|
/** The ID of an issue or pull request; several Events can have the same Item. */
|
|
3
4
|
export const ItemKey = Schema.NonEmptyString.pipe(Schema.brand("ItemKey"));
|
|
4
5
|
/** A positive GitHub issue or pull request number, unique within its repository. */
|
|
5
6
|
export const ItemNumber = Schema.Int.check(Schema.isGreaterThanOrEqualTo(1)).pipe(Schema.brand("ItemNumber"));
|
|
7
|
+
/**
|
|
8
|
+
* The stable key of a GitHub issue or pull request: the canonical repository name and item number.
|
|
9
|
+
* Schedule run keys contain only the repository and don't decode as an item.
|
|
10
|
+
*/
|
|
11
|
+
export const GitHubItemKey = Schema.toType(ItemKey).pipe(Schema.decodeTo(Schema.fromJsonString(Schema.Tuple([Schema.Literal("github"), RepositoryName, ItemNumber]))));
|
|
6
12
|
//# sourceMappingURL=item.js.map
|
package/dist/item.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"item.js","sourceRoot":"","sources":["../src/item.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;
|
|
1
|
+
{"version":3,"file":"item.js","sourceRoot":"","sources":["../src/item.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAChC,OAAO,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAC;AAEjD,iFAAiF;AACjF,MAAM,CAAC,MAAM,OAAO,GAAG,MAAM,CAAC,cAAc,CAAC,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,SAAS,CAAC,CAAC,CAAC;AAI3E,oFAAoF;AACpF,MAAM,CAAC,MAAM,UAAU,GAAG,MAAM,CAAC,GAAG,CAAC,KAAK,CAAC,MAAM,CAAC,sBAAsB,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,CAC/E,MAAM,CAAC,KAAK,CAAC,YAAY,CAAC,CAC3B,CAAC;AAGF;;;GAGG;AACH,MAAM,CAAC,MAAM,aAAa,GAAG,MAAM,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,IAAI,CACtD,MAAM,CAAC,QAAQ,CACb,MAAM,CAAC,cAAc,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,MAAM,CAAC,OAAO,CAAC,QAAQ,CAAC,EAAE,cAAc,EAAE,UAAU,CAAC,CAAC,CAAC,CAC5F,CACF,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@usine/core",
|
|
3
|
-
"version": "0.6.1-next.
|
|
3
|
+
"version": "0.6.1-next.379.gd0900a3.1.1",
|
|
4
4
|
"description": "Domain model for usine: Event → Run → Step → Attempt, branded ids, the run state machine, and the typed attempt-failure taxonomy.",
|
|
5
5
|
"license": "AGPL-3.0-only",
|
|
6
6
|
"repository": {
|
|
@@ -130,6 +130,10 @@
|
|
|
130
130
|
"./ci": {
|
|
131
131
|
"types": "./dist/ci.d.ts",
|
|
132
132
|
"default": "./dist/ci.js"
|
|
133
|
+
},
|
|
134
|
+
"./changes": {
|
|
135
|
+
"types": "./dist/changes.d.ts",
|
|
136
|
+
"default": "./dist/changes.js"
|
|
133
137
|
}
|
|
134
138
|
},
|
|
135
139
|
"publishConfig": {
|