chore: merge dev into v2 (#34317)
Co-authored-by: Brendan Allan <14191578+Brendonovich@users.noreply.github.com> Co-authored-by: opencode-agent[bot] <opencode-agent[bot]@users.noreply.github.com> Co-authored-by: Affan Ali <93028901+affanali2k3@users.noreply.github.com> Co-authored-by: affanali2k3 <affanalikhanxx@gmail.com> Co-authored-by: Frank <frank@anoma.ly> Co-authored-by: opencode-agent[bot] <219766164+opencode-agent[bot]@users.noreply.github.com> Co-authored-by: James Long <longster@gmail.com> Co-authored-by: Aiden Cline <63023139+rekram1-node@users.noreply.github.com> Co-authored-by: Jay V <air@live.ca> Co-authored-by: Dax Raad <d@ironbay.co> Co-authored-by: Aarav Sareen <96787824+arvsrn@users.noreply.github.com> Co-authored-by: OpeOginni <107570612+OpeOginni@users.noreply.github.com> Co-authored-by: Luke Parker <10430890+Hona@users.noreply.github.com> Co-authored-by: Ben Guthrie <benjee.012@gmail.com> Co-authored-by: Dax <mail@thdxr.com> Co-authored-by: Filip <34747899+neriousy@users.noreply.github.com>
This commit is contained in:
parent
11bf8d8a42
commit
41283933ff
208 changed files with 9815 additions and 6651 deletions
|
|
@ -4,6 +4,11 @@ import { Event } from "./event"
|
|||
import { SessionEvent } from "./session-event"
|
||||
import { SessionV1 } from "./session-v1"
|
||||
|
||||
export const SessionDurable = {
|
||||
definitions: Event.durable(SessionEvent.DurableDefinitions),
|
||||
schema: SessionEvent.Durable,
|
||||
} as const
|
||||
|
||||
export const Durable = Event.durable([
|
||||
...SessionV1.Event.Definitions.filter((definition) => definition.durable !== undefined),
|
||||
...SessionEvent.DurableDefinitions,
|
||||
|
|
|
|||
|
|
@ -55,7 +55,7 @@ export function define<
|
|||
id: ID,
|
||||
metadata: optional(Schema.Record(Schema.String, Schema.Unknown)),
|
||||
type: Schema.Literal(input.type),
|
||||
durable: optional(Schema.Struct({ aggregateID: Schema.String, seq: Schema.Number, version: Schema.Number })),
|
||||
durable: optional(Schema.Struct({ aggregateID: Schema.String, seq: Schema.Int, version: Schema.Int })),
|
||||
location: optional(Location.Ref),
|
||||
data,
|
||||
})
|
||||
|
|
@ -95,7 +95,7 @@ export function versionedType(type: string, version: number) {
|
|||
return `${type}.${version}`
|
||||
}
|
||||
|
||||
export function durable(definitions: ReadonlyArray<Definition>) {
|
||||
export function durable<const Definitions extends ReadonlyArray<Definition>>(definitions: Definitions) {
|
||||
return readonlyMap(
|
||||
definitions.reduce((result, definition) => {
|
||||
if (!definition.durable) return result
|
||||
|
|
@ -103,7 +103,7 @@ export function durable(definitions: ReadonlyArray<Definition>) {
|
|||
if (result.has(key)) throw new Error(`Duplicate durable event definition for ${key}`)
|
||||
result.set(key, definition)
|
||||
return result
|
||||
}, new Map<string, Definition>()),
|
||||
}, new Map<string, Definitions[number]>()),
|
||||
)
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -523,7 +523,9 @@ export const Definitions = Event.inventory(
|
|||
RevertEvent.Committed,
|
||||
)
|
||||
|
||||
export const Durable = Schema.Union(DurableDefinitions, { mode: "oneOf" }).pipe(Schema.toTaggedUnion("type"))
|
||||
export const Durable = Schema.Union(DurableDefinitions, { mode: "oneOf" })
|
||||
.pipe(Schema.toTaggedUnion("type"))
|
||||
.annotate({ identifier: "SessionDurableEvent" })
|
||||
export type DurableEvent = typeof Durable.Type
|
||||
|
||||
export const All = Schema.Union(Definitions, { mode: "oneOf" }).pipe(Schema.toTaggedUnion("type"))
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue