@nimbus-cqrs/eventsourcingdb 2.4.0 → 3.0.0-beta.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/README.md +82 -46
- package/dist/index.d.ts +8 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +8 -0
- package/dist/index.js.map +1 -0
- package/{esm → dist}/lib/client.d.ts +28 -17
- package/{esm → dist}/lib/client.d.ts.map +1 -1
- package/{esm → dist}/lib/client.js +25 -19
- package/dist/lib/client.js.map +1 -0
- package/dist/lib/consumerRunner.d.ts +62 -0
- package/dist/lib/consumerRunner.d.ts.map +1 -0
- package/dist/lib/consumerRunner.js +386 -0
- package/dist/lib/consumerRunner.js.map +1 -0
- package/dist/lib/eventConsumer.d.ts +94 -0
- package/dist/lib/eventConsumer.d.ts.map +1 -0
- package/dist/lib/eventConsumer.js +2 -0
- package/dist/lib/eventConsumer.js.map +1 -0
- package/{esm → dist}/lib/eventMapping.d.ts +1 -1
- package/dist/lib/eventMapping.d.ts.map +1 -0
- package/{esm → dist}/lib/eventMapping.js +2 -1
- package/dist/lib/eventMapping.js.map +1 -0
- package/dist/lib/eventObserver.d.ts +158 -0
- package/dist/lib/eventObserver.d.ts.map +1 -0
- package/dist/lib/eventObserver.js +339 -0
- package/dist/lib/eventObserver.js.map +1 -0
- package/dist/lib/observerRegistry.d.ts +39 -0
- package/dist/lib/observerRegistry.d.ts.map +1 -0
- package/dist/lib/observerRegistry.js +56 -0
- package/dist/lib/observerRegistry.js.map +1 -0
- package/{esm → dist}/lib/readEvents.d.ts.map +1 -1
- package/{esm → dist}/lib/readEvents.js +3 -2
- package/dist/lib/readEvents.js.map +1 -0
- package/{esm → dist}/lib/tracing.d.ts +3 -0
- package/dist/lib/tracing.d.ts.map +1 -0
- package/{esm → dist}/lib/tracing.js +5 -1
- package/dist/lib/tracing.js.map +1 -0
- package/dist/lib/writeEvents.d.ts +29 -0
- package/dist/lib/writeEvents.d.ts.map +1 -0
- package/dist/lib/writeEvents.js +47 -0
- package/dist/lib/writeEvents.js.map +1 -0
- package/package.json +32 -13
- package/src/index.ts +7 -0
- package/src/lib/client.ts +166 -0
- package/src/lib/consumerRunner.ts +592 -0
- package/src/lib/eventConsumer.ts +95 -0
- package/src/lib/eventMapping.ts +115 -0
- package/src/lib/eventObserver.ts +620 -0
- package/src/lib/observerRegistry.ts +69 -0
- package/src/lib/readEvents.ts +28 -0
- package/src/lib/tracing.ts +295 -0
- package/src/lib/writeEvents.ts +72 -0
- package/esm/_dnt.polyfills.d.ts +0 -7
- package/esm/_dnt.polyfills.d.ts.map +0 -1
- package/esm/_dnt.polyfills.js +0 -1
- package/esm/_dnt.shims.d.ts +0 -2
- package/esm/_dnt.shims.d.ts.map +0 -1
- package/esm/_dnt.shims.js +0 -57
- package/esm/deps/jsr.io/@std/fmt/1.0.10/colors.d.ts +0 -700
- package/esm/deps/jsr.io/@std/fmt/1.0.10/colors.d.ts.map +0 -1
- package/esm/deps/jsr.io/@std/fmt/1.0.10/colors.js +0 -903
- package/esm/deps/jsr.io/@std/ulid/1.0.0/_util.d.ts +0 -14
- package/esm/deps/jsr.io/@std/ulid/1.0.0/_util.d.ts.map +0 -1
- package/esm/deps/jsr.io/@std/ulid/1.0.0/_util.js +0 -65
- package/esm/deps/jsr.io/@std/ulid/1.0.0/decode_time.d.ts +0 -20
- package/esm/deps/jsr.io/@std/ulid/1.0.0/decode_time.d.ts.map +0 -1
- package/esm/deps/jsr.io/@std/ulid/1.0.0/decode_time.js +0 -43
- package/esm/deps/jsr.io/@std/ulid/1.0.0/mod.d.ts +0 -44
- package/esm/deps/jsr.io/@std/ulid/1.0.0/mod.d.ts.map +0 -1
- package/esm/deps/jsr.io/@std/ulid/1.0.0/mod.js +0 -47
- package/esm/deps/jsr.io/@std/ulid/1.0.0/monotonic_ulid.d.ts +0 -44
- package/esm/deps/jsr.io/@std/ulid/1.0.0/monotonic_ulid.d.ts.map +0 -1
- package/esm/deps/jsr.io/@std/ulid/1.0.0/monotonic_ulid.js +0 -51
- package/esm/deps/jsr.io/@std/ulid/1.0.0/ulid.d.ts +0 -31
- package/esm/deps/jsr.io/@std/ulid/1.0.0/ulid.d.ts.map +0 -1
- package/esm/deps/jsr.io/@std/ulid/1.0.0/ulid.js +0 -37
- package/esm/index.d.ts +0 -7
- package/esm/index.d.ts.map +0 -1
- package/esm/index.js +0 -6
- package/esm/lib/eventMapping.d.ts.map +0 -1
- package/esm/lib/eventObserver.d.ts +0 -133
- package/esm/lib/eventObserver.d.ts.map +0 -1
- package/esm/lib/eventObserver.js +0 -291
- package/esm/lib/tracing.d.ts.map +0 -1
- package/esm/lib/writeEvents.d.ts +0 -11
- package/esm/lib/writeEvents.d.ts.map +0 -1
- package/esm/lib/writeEvents.js +0 -31
- package/esm/package.json +0 -3
- /package/{esm → dist}/lib/readEvents.d.ts +0 -0
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
/** Type for a ULID generator function. */
|
|
2
|
-
export type ULID = (seedTime?: number) => string;
|
|
3
|
-
export declare const ENCODING = "0123456789ABCDEFGHJKMNPQRSTVWXYZ";
|
|
4
|
-
export declare const ENCODING_LEN: number;
|
|
5
|
-
export declare const TIME_MAX: number;
|
|
6
|
-
export declare const TIME_LEN = 10;
|
|
7
|
-
export declare const RANDOM_LEN = 16;
|
|
8
|
-
export declare const ULID_LEN: number;
|
|
9
|
-
export declare function encodeTime(timestamp: number): string;
|
|
10
|
-
export declare function encodeRandom(): string;
|
|
11
|
-
export declare function incrementBase32(str: string): string;
|
|
12
|
-
/** Generates a monotonically increasing ULID. */
|
|
13
|
-
export declare function monotonicFactory(encodeRand?: typeof encodeRandom): ULID;
|
|
14
|
-
//# sourceMappingURL=_util.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"_util.d.ts","sourceRoot":"","sources":["../../../../../../src/deps/jsr.io/@std/ulid/1.0.0/_util.ts"],"names":[],"mappings":"AAEA,0CAA0C;AAC1C,MAAM,MAAM,IAAI,GAAG,CAAC,QAAQ,CAAC,EAAE,MAAM,KAAK,MAAM,CAAC;AAIjD,eAAO,MAAM,QAAQ,qCAAqC,CAAC;AAC3D,eAAO,MAAM,YAAY,QAAkB,CAAC;AAC5C,eAAO,MAAM,QAAQ,QAAsB,CAAC;AAC5C,eAAO,MAAM,QAAQ,KAAK,CAAC;AAC3B,eAAO,MAAM,UAAU,KAAK,CAAC;AAC7B,eAAO,MAAM,QAAQ,QAAwB,CAAC;AAM9C,wBAAgB,UAAU,CAAC,SAAS,EAAE,MAAM,GAAG,MAAM,CAapD;AAED,wBAAgB,YAAY,IAAI,MAAM,CAOrC;AAED,wBAAgB,eAAe,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAkBnD;AAED,iDAAiD;AACjD,wBAAgB,gBAAgB,CAAC,UAAU,sBAAe,GAAG,IAAI,CAYhE"}
|
|
@@ -1,65 +0,0 @@
|
|
|
1
|
-
// Copyright 2018-2024 the Deno authors. All rights reserved. MIT license.
|
|
2
|
-
// These values should NEVER change. If
|
|
3
|
-
// they do, we're no longer making ulids!
|
|
4
|
-
export const ENCODING = "0123456789ABCDEFGHJKMNPQRSTVWXYZ"; // Crockford's Base32
|
|
5
|
-
export const ENCODING_LEN = ENCODING.length;
|
|
6
|
-
export const TIME_MAX = Math.pow(2, 48) - 1;
|
|
7
|
-
export const TIME_LEN = 10;
|
|
8
|
-
export const RANDOM_LEN = 16;
|
|
9
|
-
export const ULID_LEN = TIME_LEN + RANDOM_LEN;
|
|
10
|
-
function replaceCharAt(str, index, char) {
|
|
11
|
-
return str.substring(0, index) + char + str.substring(index + 1);
|
|
12
|
-
}
|
|
13
|
-
export function encodeTime(timestamp) {
|
|
14
|
-
if (!Number.isInteger(timestamp) || timestamp < 0 || timestamp > TIME_MAX) {
|
|
15
|
-
throw new RangeError(`Time must be a positive integer less than ${TIME_MAX}`);
|
|
16
|
-
}
|
|
17
|
-
let str = "";
|
|
18
|
-
for (let len = TIME_LEN; len > 0; len--) {
|
|
19
|
-
const mod = timestamp % ENCODING_LEN;
|
|
20
|
-
str = ENCODING[mod] + str;
|
|
21
|
-
timestamp = Math.floor(timestamp / ENCODING_LEN);
|
|
22
|
-
}
|
|
23
|
-
return str;
|
|
24
|
-
}
|
|
25
|
-
export function encodeRandom() {
|
|
26
|
-
let str = "";
|
|
27
|
-
const bytes = crypto.getRandomValues(new Uint8Array(RANDOM_LEN));
|
|
28
|
-
for (const byte of bytes) {
|
|
29
|
-
str += ENCODING[byte % ENCODING_LEN];
|
|
30
|
-
}
|
|
31
|
-
return str;
|
|
32
|
-
}
|
|
33
|
-
export function incrementBase32(str) {
|
|
34
|
-
let index = str.length;
|
|
35
|
-
let char;
|
|
36
|
-
let charIndex;
|
|
37
|
-
const maxCharIndex = ENCODING_LEN - 1;
|
|
38
|
-
while (--index >= 0) {
|
|
39
|
-
char = str[index];
|
|
40
|
-
charIndex = ENCODING.indexOf(char);
|
|
41
|
-
if (charIndex === -1) {
|
|
42
|
-
throw new TypeError("Incorrectly encoded string");
|
|
43
|
-
}
|
|
44
|
-
if (charIndex === maxCharIndex) {
|
|
45
|
-
str = replaceCharAt(str, index, ENCODING[0]);
|
|
46
|
-
continue;
|
|
47
|
-
}
|
|
48
|
-
return replaceCharAt(str, index, ENCODING[charIndex + 1]);
|
|
49
|
-
}
|
|
50
|
-
throw new Error("Cannot increment this string");
|
|
51
|
-
}
|
|
52
|
-
/** Generates a monotonically increasing ULID. */
|
|
53
|
-
export function monotonicFactory(encodeRand = encodeRandom) {
|
|
54
|
-
let lastTime = 0;
|
|
55
|
-
let lastRandom;
|
|
56
|
-
return function ulid(seedTime = Date.now()) {
|
|
57
|
-
if (seedTime <= lastTime) {
|
|
58
|
-
const incrementedRandom = (lastRandom = incrementBase32(lastRandom));
|
|
59
|
-
return encodeTime(lastTime) + incrementedRandom;
|
|
60
|
-
}
|
|
61
|
-
lastTime = seedTime;
|
|
62
|
-
const newRandom = (lastRandom = encodeRand());
|
|
63
|
-
return encodeTime(seedTime) + newRandom;
|
|
64
|
-
};
|
|
65
|
-
}
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Extracts the number of milliseconds since the Unix epoch that had passed when
|
|
3
|
-
* the ULID was generated. If the ULID is malformed, an error will be thrown.
|
|
4
|
-
*
|
|
5
|
-
* @example Decode the time from a ULID
|
|
6
|
-
* ```ts
|
|
7
|
-
* import { decodeTime, ulid } from "@std/ulid";
|
|
8
|
-
* import { assertEquals } from "@std/assert";
|
|
9
|
-
*
|
|
10
|
-
* const timestamp = 150_000;
|
|
11
|
-
* const ulidString = ulid(timestamp);
|
|
12
|
-
*
|
|
13
|
-
* assertEquals(decodeTime(ulidString), timestamp);
|
|
14
|
-
* ```
|
|
15
|
-
*
|
|
16
|
-
* @param ulid The ULID to extract the timestamp from.
|
|
17
|
-
* @returns The number of milliseconds since the Unix epoch that had passed when the ULID was generated.
|
|
18
|
-
*/
|
|
19
|
-
export declare function decodeTime(ulid: string): number;
|
|
20
|
-
//# sourceMappingURL=decode_time.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"decode_time.d.ts","sourceRoot":"","sources":["../../../../../../src/deps/jsr.io/@std/ulid/1.0.0/decode_time.ts"],"names":[],"mappings":"AAaA;;;;;;;;;;;;;;;;;GAiBG;AACH,wBAAgB,UAAU,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAqB/C"}
|
|
@@ -1,43 +0,0 @@
|
|
|
1
|
-
// Copyright 2018-2024 the Deno authors. All rights reserved. MIT license.
|
|
2
|
-
// Copyright 2023 Yoshiya Hinosawa. All rights reserved. MIT license.
|
|
3
|
-
// Copyright 2017 Alizain Feerasta. All rights reserved. MIT license.
|
|
4
|
-
// This module is browser compatible.
|
|
5
|
-
import { ENCODING, ENCODING_LEN, TIME_LEN, TIME_MAX, ULID_LEN, } from "./_util.js";
|
|
6
|
-
/**
|
|
7
|
-
* Extracts the number of milliseconds since the Unix epoch that had passed when
|
|
8
|
-
* the ULID was generated. If the ULID is malformed, an error will be thrown.
|
|
9
|
-
*
|
|
10
|
-
* @example Decode the time from a ULID
|
|
11
|
-
* ```ts
|
|
12
|
-
* import { decodeTime, ulid } from "@std/ulid";
|
|
13
|
-
* import { assertEquals } from "@std/assert";
|
|
14
|
-
*
|
|
15
|
-
* const timestamp = 150_000;
|
|
16
|
-
* const ulidString = ulid(timestamp);
|
|
17
|
-
*
|
|
18
|
-
* assertEquals(decodeTime(ulidString), timestamp);
|
|
19
|
-
* ```
|
|
20
|
-
*
|
|
21
|
-
* @param ulid The ULID to extract the timestamp from.
|
|
22
|
-
* @returns The number of milliseconds since the Unix epoch that had passed when the ULID was generated.
|
|
23
|
-
*/
|
|
24
|
-
export function decodeTime(ulid) {
|
|
25
|
-
if (ulid.length !== ULID_LEN) {
|
|
26
|
-
throw new Error(`ULID must be exactly ${ULID_LEN} characters long`);
|
|
27
|
-
}
|
|
28
|
-
const time = ulid
|
|
29
|
-
.substring(0, TIME_LEN)
|
|
30
|
-
.split("")
|
|
31
|
-
.reverse()
|
|
32
|
-
.reduce((carry, char, index) => {
|
|
33
|
-
const encodingIndex = ENCODING.indexOf(char);
|
|
34
|
-
if (encodingIndex === -1) {
|
|
35
|
-
throw new Error(`Invalid ULID character found: ${char}`);
|
|
36
|
-
}
|
|
37
|
-
return (carry += encodingIndex * Math.pow(ENCODING_LEN, index));
|
|
38
|
-
}, 0);
|
|
39
|
-
if (time > TIME_MAX) {
|
|
40
|
-
throw new RangeError(`ULID timestamp component exceeds maximum value of ${TIME_MAX}`);
|
|
41
|
-
}
|
|
42
|
-
return time;
|
|
43
|
-
}
|
|
@@ -1,44 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Utilities for generating and working with
|
|
3
|
-
* {@link https://github.com/ulid/spec | Universally Unique Lexicographically Sortable Identifiers (ULIDs)}.
|
|
4
|
-
*
|
|
5
|
-
* To generate a ULID use the {@linkcode ulid} function. This will generate a
|
|
6
|
-
* ULID based on the current time.
|
|
7
|
-
*
|
|
8
|
-
* ```ts no-assert
|
|
9
|
-
* import { ulid } from "@std/ulid";
|
|
10
|
-
*
|
|
11
|
-
* ulid(); // 01HYFKMDF3HVJ4J3JZW8KXPVTY
|
|
12
|
-
* ```
|
|
13
|
-
*
|
|
14
|
-
* {@linkcode ulid} does not guarantee that the ULIDs will be strictly
|
|
15
|
-
* increasing for the same current time. If you need to guarantee that the ULIDs
|
|
16
|
-
* will be strictly increasing, even for the same current time, use the
|
|
17
|
-
* {@linkcode monotonicUlid} function.
|
|
18
|
-
*
|
|
19
|
-
* ```ts no-assert
|
|
20
|
-
* import { monotonicUlid } from "@std/ulid";
|
|
21
|
-
*
|
|
22
|
-
* monotonicUlid(); // 01HYFKHG5F8RHM2PM3D7NSTDAS
|
|
23
|
-
* monotonicUlid(); // 01HYFKHG5F8RHM2PM3D7NSTDAT
|
|
24
|
-
* ```
|
|
25
|
-
*
|
|
26
|
-
* Because each ULID encodes the time it was generated, you can extract the
|
|
27
|
-
* timestamp from a ULID using the {@linkcode decodeTime} function.
|
|
28
|
-
*
|
|
29
|
-
* ```ts
|
|
30
|
-
* import { decodeTime, ulid } from "@std/ulid";
|
|
31
|
-
* import { assertEquals } from "@std/assert";
|
|
32
|
-
*
|
|
33
|
-
* const timestamp = 150_000;
|
|
34
|
-
* const ulidString = ulid(timestamp);
|
|
35
|
-
*
|
|
36
|
-
* assertEquals(decodeTime(ulidString), timestamp);
|
|
37
|
-
* ```
|
|
38
|
-
*
|
|
39
|
-
* @module
|
|
40
|
-
*/
|
|
41
|
-
export * from "./decode_time.js";
|
|
42
|
-
export * from "./monotonic_ulid.js";
|
|
43
|
-
export * from "./ulid.js";
|
|
44
|
-
//# sourceMappingURL=mod.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"mod.d.ts","sourceRoot":"","sources":["../../../../../../src/deps/jsr.io/@std/ulid/1.0.0/mod.ts"],"names":[],"mappings":"AAKA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAuCG;AAEH,cAAc,kBAAkB,CAAC;AACjC,cAAc,qBAAqB,CAAC;AACpC,cAAc,WAAW,CAAC"}
|
|
@@ -1,47 +0,0 @@
|
|
|
1
|
-
// Copyright 2018-2024 the Deno authors. All rights reserved. MIT license.
|
|
2
|
-
// Copyright 2023 Yoshiya Hinosawa. All rights reserved. MIT license.
|
|
3
|
-
// Copyright 2017 Alizain Feerasta. All rights reserved. MIT license.
|
|
4
|
-
// This module is browser compatible.
|
|
5
|
-
/**
|
|
6
|
-
* Utilities for generating and working with
|
|
7
|
-
* {@link https://github.com/ulid/spec | Universally Unique Lexicographically Sortable Identifiers (ULIDs)}.
|
|
8
|
-
*
|
|
9
|
-
* To generate a ULID use the {@linkcode ulid} function. This will generate a
|
|
10
|
-
* ULID based on the current time.
|
|
11
|
-
*
|
|
12
|
-
* ```ts no-assert
|
|
13
|
-
* import { ulid } from "@std/ulid";
|
|
14
|
-
*
|
|
15
|
-
* ulid(); // 01HYFKMDF3HVJ4J3JZW8KXPVTY
|
|
16
|
-
* ```
|
|
17
|
-
*
|
|
18
|
-
* {@linkcode ulid} does not guarantee that the ULIDs will be strictly
|
|
19
|
-
* increasing for the same current time. If you need to guarantee that the ULIDs
|
|
20
|
-
* will be strictly increasing, even for the same current time, use the
|
|
21
|
-
* {@linkcode monotonicUlid} function.
|
|
22
|
-
*
|
|
23
|
-
* ```ts no-assert
|
|
24
|
-
* import { monotonicUlid } from "@std/ulid";
|
|
25
|
-
*
|
|
26
|
-
* monotonicUlid(); // 01HYFKHG5F8RHM2PM3D7NSTDAS
|
|
27
|
-
* monotonicUlid(); // 01HYFKHG5F8RHM2PM3D7NSTDAT
|
|
28
|
-
* ```
|
|
29
|
-
*
|
|
30
|
-
* Because each ULID encodes the time it was generated, you can extract the
|
|
31
|
-
* timestamp from a ULID using the {@linkcode decodeTime} function.
|
|
32
|
-
*
|
|
33
|
-
* ```ts
|
|
34
|
-
* import { decodeTime, ulid } from "@std/ulid";
|
|
35
|
-
* import { assertEquals } from "@std/assert";
|
|
36
|
-
*
|
|
37
|
-
* const timestamp = 150_000;
|
|
38
|
-
* const ulidString = ulid(timestamp);
|
|
39
|
-
*
|
|
40
|
-
* assertEquals(decodeTime(ulidString), timestamp);
|
|
41
|
-
* ```
|
|
42
|
-
*
|
|
43
|
-
* @module
|
|
44
|
-
*/
|
|
45
|
-
export * from "./decode_time.js";
|
|
46
|
-
export * from "./monotonic_ulid.js";
|
|
47
|
-
export * from "./ulid.js";
|
|
@@ -1,44 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Generate a ULID that monotonically increases even for the same millisecond,
|
|
3
|
-
* optionally passing the current time. If the current time is not passed, it
|
|
4
|
-
* will default to `Date.now()`.
|
|
5
|
-
*
|
|
6
|
-
* Unlike the {@linkcode ulid} function, this function is guaranteed to return
|
|
7
|
-
* strictly increasing ULIDs, even for the same seed time, but only if the seed
|
|
8
|
-
* time only ever increases. If the seed time ever goes backwards, the ULID will
|
|
9
|
-
* still be generated, but it will not be guaranteed to be monotonic with
|
|
10
|
-
* previous ULIDs for that same seed time.
|
|
11
|
-
*
|
|
12
|
-
* @example Generate a monotonic ULID
|
|
13
|
-
* ```ts no-assert
|
|
14
|
-
* import { monotonicUlid } from "@std/ulid";
|
|
15
|
-
*
|
|
16
|
-
* monotonicUlid(); // 01HYFKHG5F8RHM2PM3D7NSTDAS
|
|
17
|
-
* monotonicUlid(); // 01HYFKHG5F8RHM2PM3D7NSTDAT
|
|
18
|
-
* monotonicUlid(); // 01HYFKHHX8H4BRY8BYHAV1BZ2T
|
|
19
|
-
* ```
|
|
20
|
-
*
|
|
21
|
-
* @example Generate a monotonic ULID with a seed time
|
|
22
|
-
* ```ts no-assert
|
|
23
|
-
* import { monotonicUlid } from "@std/ulid";
|
|
24
|
-
*
|
|
25
|
-
* // Strict ordering for the same timestamp, by incrementing the least-significant random bit by 1
|
|
26
|
-
* monotonicUlid(150000); // 0000004JFHJJ2Z7X64FN2B4F1Q
|
|
27
|
-
* monotonicUlid(150000); // 0000004JFHJJ2Z7X64FN2B4F1R
|
|
28
|
-
* monotonicUlid(150000); // 0000004JFHJJ2Z7X64FN2B4F1S
|
|
29
|
-
* monotonicUlid(150000); // 0000004JFHJJ2Z7X64FN2B4F1T
|
|
30
|
-
* monotonicUlid(150000); // 0000004JFHJJ2Z7X64FN2B4F1U
|
|
31
|
-
*
|
|
32
|
-
* // A different timestamp will reset the random bits
|
|
33
|
-
* monotonicUlid(150001); // 0000004JFHJJ2Z7X64FN2B4F1P
|
|
34
|
-
*
|
|
35
|
-
* // A previous seed time will not guarantee ordering, and may result in a
|
|
36
|
-
* // ULID lower than one with the same seed time generated previously
|
|
37
|
-
* monotonicUlid(150000); // 0000004JFJ7XF6D76ES95SZR0X
|
|
38
|
-
* ```
|
|
39
|
-
*
|
|
40
|
-
* @param seedTime The time to base the ULID on, in milliseconds since the Unix epoch. Defaults to `Date.now()`.
|
|
41
|
-
* @returns A ULID that is guaranteed to be strictly increasing for the same seed time.
|
|
42
|
-
*/
|
|
43
|
-
export declare function monotonicUlid(seedTime?: number): string;
|
|
44
|
-
//# sourceMappingURL=monotonic_ulid.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"monotonic_ulid.d.ts","sourceRoot":"","sources":["../../../../../../src/deps/jsr.io/@std/ulid/1.0.0/monotonic_ulid.ts"],"names":[],"mappings":"AASA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAyCG;AACH,wBAAgB,aAAa,CAAC,QAAQ,GAAE,MAAmB,GAAG,MAAM,CAEnE"}
|
|
@@ -1,51 +0,0 @@
|
|
|
1
|
-
// Copyright 2018-2024 the Deno authors. All rights reserved. MIT license.
|
|
2
|
-
// Copyright 2023 Yoshiya Hinosawa. All rights reserved. MIT license.
|
|
3
|
-
// Copyright 2017 Alizain Feerasta. All rights reserved. MIT license.
|
|
4
|
-
// This module is browser compatible.
|
|
5
|
-
import { monotonicFactory } from "./_util.js";
|
|
6
|
-
const defaultMonotonicUlid = monotonicFactory();
|
|
7
|
-
/**
|
|
8
|
-
* Generate a ULID that monotonically increases even for the same millisecond,
|
|
9
|
-
* optionally passing the current time. If the current time is not passed, it
|
|
10
|
-
* will default to `Date.now()`.
|
|
11
|
-
*
|
|
12
|
-
* Unlike the {@linkcode ulid} function, this function is guaranteed to return
|
|
13
|
-
* strictly increasing ULIDs, even for the same seed time, but only if the seed
|
|
14
|
-
* time only ever increases. If the seed time ever goes backwards, the ULID will
|
|
15
|
-
* still be generated, but it will not be guaranteed to be monotonic with
|
|
16
|
-
* previous ULIDs for that same seed time.
|
|
17
|
-
*
|
|
18
|
-
* @example Generate a monotonic ULID
|
|
19
|
-
* ```ts no-assert
|
|
20
|
-
* import { monotonicUlid } from "@std/ulid";
|
|
21
|
-
*
|
|
22
|
-
* monotonicUlid(); // 01HYFKHG5F8RHM2PM3D7NSTDAS
|
|
23
|
-
* monotonicUlid(); // 01HYFKHG5F8RHM2PM3D7NSTDAT
|
|
24
|
-
* monotonicUlid(); // 01HYFKHHX8H4BRY8BYHAV1BZ2T
|
|
25
|
-
* ```
|
|
26
|
-
*
|
|
27
|
-
* @example Generate a monotonic ULID with a seed time
|
|
28
|
-
* ```ts no-assert
|
|
29
|
-
* import { monotonicUlid } from "@std/ulid";
|
|
30
|
-
*
|
|
31
|
-
* // Strict ordering for the same timestamp, by incrementing the least-significant random bit by 1
|
|
32
|
-
* monotonicUlid(150000); // 0000004JFHJJ2Z7X64FN2B4F1Q
|
|
33
|
-
* monotonicUlid(150000); // 0000004JFHJJ2Z7X64FN2B4F1R
|
|
34
|
-
* monotonicUlid(150000); // 0000004JFHJJ2Z7X64FN2B4F1S
|
|
35
|
-
* monotonicUlid(150000); // 0000004JFHJJ2Z7X64FN2B4F1T
|
|
36
|
-
* monotonicUlid(150000); // 0000004JFHJJ2Z7X64FN2B4F1U
|
|
37
|
-
*
|
|
38
|
-
* // A different timestamp will reset the random bits
|
|
39
|
-
* monotonicUlid(150001); // 0000004JFHJJ2Z7X64FN2B4F1P
|
|
40
|
-
*
|
|
41
|
-
* // A previous seed time will not guarantee ordering, and may result in a
|
|
42
|
-
* // ULID lower than one with the same seed time generated previously
|
|
43
|
-
* monotonicUlid(150000); // 0000004JFJ7XF6D76ES95SZR0X
|
|
44
|
-
* ```
|
|
45
|
-
*
|
|
46
|
-
* @param seedTime The time to base the ULID on, in milliseconds since the Unix epoch. Defaults to `Date.now()`.
|
|
47
|
-
* @returns A ULID that is guaranteed to be strictly increasing for the same seed time.
|
|
48
|
-
*/
|
|
49
|
-
export function monotonicUlid(seedTime = Date.now()) {
|
|
50
|
-
return defaultMonotonicUlid(seedTime);
|
|
51
|
-
}
|
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Generate a ULID, optionally based on a given timestamp. If the timestamp is
|
|
3
|
-
* not passed, it will default to `Date.now()`.
|
|
4
|
-
*
|
|
5
|
-
* Multiple calls to this function with the same seed time will not guarantee
|
|
6
|
-
* that the ULIDs will be strictly increasing, even if the seed time is the
|
|
7
|
-
* same. For that, use the {@linkcode monotonicUlid} function.
|
|
8
|
-
*
|
|
9
|
-
* @example Generate a ULID
|
|
10
|
-
* ```ts no-assert
|
|
11
|
-
* import { ulid } from "@std/ulid";
|
|
12
|
-
*
|
|
13
|
-
* ulid(); // 01HYFKMDF3HVJ4J3JZW8KXPVTY
|
|
14
|
-
* ulid(); // 01HYFKMDF3D2P7G502B9Z2VKV0
|
|
15
|
-
* ulid(); // 01HYFKMDZQ7JD17CRKDXQSZ3Z4
|
|
16
|
-
* ```
|
|
17
|
-
*
|
|
18
|
-
* @example Generate a ULID with a seed time
|
|
19
|
-
* ```ts no-assert
|
|
20
|
-
* import { ulid } from "@std/ulid";
|
|
21
|
-
*
|
|
22
|
-
* ulid(150000); // 0000004JFG3EKDRE04TVVDJW7K
|
|
23
|
-
* ulid(150000); // 0000004JFGN0KHBH0447AK895X
|
|
24
|
-
* ulid(150000); // 0000004JFGMRDH0PN7SM8BZN06
|
|
25
|
-
* ```
|
|
26
|
-
*
|
|
27
|
-
* @param seedTime The time to base the ULID on, in milliseconds since the Unix epoch. Defaults to `Date.now()`.
|
|
28
|
-
* @returns A ULID.
|
|
29
|
-
*/
|
|
30
|
-
export declare function ulid(seedTime?: number): string;
|
|
31
|
-
//# sourceMappingURL=ulid.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"ulid.d.ts","sourceRoot":"","sources":["../../../../../../src/deps/jsr.io/@std/ulid/1.0.0/ulid.ts"],"names":[],"mappings":"AAOA;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;AACH,wBAAgB,IAAI,CAAC,QAAQ,GAAE,MAAmB,GAAG,MAAM,CAE1D"}
|
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
// Copyright 2018-2024 the Deno authors. All rights reserved. MIT license.
|
|
2
|
-
// Copyright 2023 Yoshiya Hinosawa. All rights reserved. MIT license.
|
|
3
|
-
// Copyright 2017 Alizain Feerasta. All rights reserved. MIT license.
|
|
4
|
-
// This module is browser compatible.
|
|
5
|
-
import { encodeRandom, encodeTime } from "./_util.js";
|
|
6
|
-
/**
|
|
7
|
-
* Generate a ULID, optionally based on a given timestamp. If the timestamp is
|
|
8
|
-
* not passed, it will default to `Date.now()`.
|
|
9
|
-
*
|
|
10
|
-
* Multiple calls to this function with the same seed time will not guarantee
|
|
11
|
-
* that the ULIDs will be strictly increasing, even if the seed time is the
|
|
12
|
-
* same. For that, use the {@linkcode monotonicUlid} function.
|
|
13
|
-
*
|
|
14
|
-
* @example Generate a ULID
|
|
15
|
-
* ```ts no-assert
|
|
16
|
-
* import { ulid } from "@std/ulid";
|
|
17
|
-
*
|
|
18
|
-
* ulid(); // 01HYFKMDF3HVJ4J3JZW8KXPVTY
|
|
19
|
-
* ulid(); // 01HYFKMDF3D2P7G502B9Z2VKV0
|
|
20
|
-
* ulid(); // 01HYFKMDZQ7JD17CRKDXQSZ3Z4
|
|
21
|
-
* ```
|
|
22
|
-
*
|
|
23
|
-
* @example Generate a ULID with a seed time
|
|
24
|
-
* ```ts no-assert
|
|
25
|
-
* import { ulid } from "@std/ulid";
|
|
26
|
-
*
|
|
27
|
-
* ulid(150000); // 0000004JFG3EKDRE04TVVDJW7K
|
|
28
|
-
* ulid(150000); // 0000004JFGN0KHBH0447AK895X
|
|
29
|
-
* ulid(150000); // 0000004JFGMRDH0PN7SM8BZN06
|
|
30
|
-
* ```
|
|
31
|
-
*
|
|
32
|
-
* @param seedTime The time to base the ULID on, in milliseconds since the Unix epoch. Defaults to `Date.now()`.
|
|
33
|
-
* @returns A ULID.
|
|
34
|
-
*/
|
|
35
|
-
export function ulid(seedTime = Date.now()) {
|
|
36
|
-
return encodeTime(seedTime) + encodeRandom();
|
|
37
|
-
}
|
package/esm/index.d.ts
DELETED
package/esm/index.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,qBAAqB,CAAC;AAC7B,cAAc,iBAAiB,CAAC;AAChC,cAAc,uBAAuB,CAAC;AACtC,cAAc,wBAAwB,CAAC;AACvC,cAAc,qBAAqB,CAAC;AACpC,cAAc,sBAAsB,CAAC"}
|
package/esm/index.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"eventMapping.d.ts","sourceRoot":"","sources":["../../src/lib/eventMapping.ts"],"names":[],"mappings":"AAAA,OAAO,EAGH,KAAK,KAAK,EACb,MAAM,qDAAqD,CAAC;AAE7D,OAAO,KAAK,EACR,KAAK,IAAI,oBAAoB,EAC7B,cAAc,EACjB,MAAM,iBAAiB,CAAC;AAEzB;;;;;;GAMG;AACH,MAAM,MAAM,mBAAmB,GAAG;IAC9B,aAAa,EAAE,MAAM,CAAC;IACtB,UAAU,CAAC,EAAE,MAAM,CAAC;CACvB,CAAC;AAEF;;;;;;GAMG;AACH,MAAM,MAAM,SAAS,GAAG;IACpB,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IACjC,UAAU,EAAE,mBAAmB,CAAC;CACnC,CAAC;AAEF;;;;;;GAMG;AACH,eAAO,MAAM,WAAW,GAAI,MAAM,OAAO,KAAG,IAAI,IAAI,SAOnD,CAAC;AAEF;;;;;;GAMG;AACH,eAAO,MAAM,0CAA0C,GACnD,OAAO,KAAK,EACZ,cAAc,MAAM,EACpB,aAAa,MAAM,KACpB,cAeF,CAAC;AAEF;;;;;;;;GAQG;AACH,eAAO,MAAM,iCAAiC,GAAI,MAAM,SAAS,KAAK,EAClE,sBAAsB,oBAAoB,KAC3C,MAwBF,CAAC"}
|
|
@@ -1,133 +0,0 @@
|
|
|
1
|
-
import type { Event as EventSourcingDBEvent } from 'eventsourcingdb';
|
|
2
|
-
type Bound = {
|
|
3
|
-
id: string;
|
|
4
|
-
type: 'inclusive' | 'exclusive';
|
|
5
|
-
};
|
|
6
|
-
type ObserveFromLatestEvent = {
|
|
7
|
-
subject: string;
|
|
8
|
-
type: string;
|
|
9
|
-
ifEventIsMissing: 'read-everything' | 'wait-for-event';
|
|
10
|
-
};
|
|
11
|
-
export type RetryOptions = {
|
|
12
|
-
/**
|
|
13
|
-
* The maximum number of retries after the initial attempt
|
|
14
|
-
* before giving up. Defaults to 3 (4 failed attempts total).
|
|
15
|
-
*/
|
|
16
|
-
maxRetries: number;
|
|
17
|
-
/**
|
|
18
|
-
* The initial delay in milliseconds before the first retry.
|
|
19
|
-
* Subsequent retries will use exponential backoff with jitter.
|
|
20
|
-
* Defaults to 3000ms.
|
|
21
|
-
*/
|
|
22
|
-
initialRetryDelayMs: number;
|
|
23
|
-
};
|
|
24
|
-
/**
|
|
25
|
-
* An event observer defines a handler function which will be applied to each event
|
|
26
|
-
* and the options to observe the events according to the EventSourcingDB API.
|
|
27
|
-
*
|
|
28
|
-
* See https://docs.eventsourcingdb.io/getting-started/observing-events for more information.
|
|
29
|
-
*/
|
|
30
|
-
export type EventObserver = {
|
|
31
|
-
/**
|
|
32
|
-
* The subject of the events to observe.
|
|
33
|
-
*/
|
|
34
|
-
subject: string;
|
|
35
|
-
/**
|
|
36
|
-
* Whether to observe events recursively.
|
|
37
|
-
* Defaults to false.
|
|
38
|
-
*/
|
|
39
|
-
recursive?: boolean;
|
|
40
|
-
/**
|
|
41
|
-
* The lower bound of the events to observe.
|
|
42
|
-
* Defaults to undefined.
|
|
43
|
-
*/
|
|
44
|
-
lowerBound?: Bound;
|
|
45
|
-
/**
|
|
46
|
-
* The from latest event to observe.
|
|
47
|
-
* Defaults to undefined.
|
|
48
|
-
*/
|
|
49
|
-
fromLatestEvent?: ObserveFromLatestEvent;
|
|
50
|
-
/**
|
|
51
|
-
* The event handler which will be called when an event is observed.
|
|
52
|
-
*
|
|
53
|
-
* @param event - The EventSourcingDB event that was observed.
|
|
54
|
-
* @returns A promise that resolves when the event has been handled.
|
|
55
|
-
*/
|
|
56
|
-
eventHandler: (event: EventSourcingDBEvent) => Promise<void> | void;
|
|
57
|
-
/**
|
|
58
|
-
* Options for retry behavior when the observe stream / connection fails.
|
|
59
|
-
* Uses exponential backoff with jitter between reconnects.
|
|
60
|
-
* Defaults to { maxRetries: 3, initialRetryDelayMs: 3000 }.
|
|
61
|
-
*/
|
|
62
|
-
connectionRetryOptions?: RetryOptions;
|
|
63
|
-
/**
|
|
64
|
-
* Options for retry behavior when {@link eventHandler} throws.
|
|
65
|
-
* Handler retries happen in-place without reconnecting the stream.
|
|
66
|
-
* Defaults to { maxRetries: 3, initialRetryDelayMs: 3000 }.
|
|
67
|
-
*/
|
|
68
|
-
handlerRetryOptions?: RetryOptions;
|
|
69
|
-
/**
|
|
70
|
-
* @deprecated Use {@link connectionRetryOptions} instead.
|
|
71
|
-
*
|
|
72
|
-
* Options for retry behavior when the observe stream / connection fails.
|
|
73
|
-
* Ignored when {@link connectionRetryOptions} is set.
|
|
74
|
-
*/
|
|
75
|
-
retryOptions?: RetryOptions;
|
|
76
|
-
/**
|
|
77
|
-
* Called when {@link eventHandler} keeps failing after all handler
|
|
78
|
-
* retries are exhausted. The event is then skipped and observation
|
|
79
|
-
* continues. When omitted, a critical log entry is emitted instead.
|
|
80
|
-
*
|
|
81
|
-
* @param error - The last error thrown by the handler.
|
|
82
|
-
* @param event - The event that could not be handled.
|
|
83
|
-
*/
|
|
84
|
-
onHandlerError?: (error: Error, event: EventSourcingDBEvent) => Promise<void> | void;
|
|
85
|
-
};
|
|
86
|
-
/**
|
|
87
|
-
* Calculates an exponential backoff delay with jitter for a given
|
|
88
|
-
* retry attempt. The jitter adds up to 30% of the base delay to
|
|
89
|
-
* avoid thundering-herd effects.
|
|
90
|
-
*
|
|
91
|
-
* @param initialDelayMs - The base delay in milliseconds before
|
|
92
|
-
* exponential scaling.
|
|
93
|
-
* @param attempt - The zero-based retry attempt number.
|
|
94
|
-
* @returns The backoff delay in milliseconds.
|
|
95
|
-
*
|
|
96
|
-
* @deprecated Import {@link calculateBackoffDelay} from
|
|
97
|
-
* `@nimbus-cqrs/core` instead. This wrapper keeps the historical
|
|
98
|
-
* 30% jitter default used by EventSourcingDB observers.
|
|
99
|
-
*/
|
|
100
|
-
export declare const calculateBackoffDelay: (initialDelayMs: number, attempt: number) => number;
|
|
101
|
-
/**
|
|
102
|
-
* Starts observing events for the given {@link EventObserver} with
|
|
103
|
-
* automatic reconnection on stream failure and separate in-place
|
|
104
|
-
* retries for handler failures.
|
|
105
|
-
*
|
|
106
|
-
* Events are consumed from the stream and each one is passed to the
|
|
107
|
-
* observer's event handler inside an OpenTelemetry span. If the event
|
|
108
|
-
* carries a `traceparent`, the span is linked to the original writer's
|
|
109
|
-
* trace for end-to-end distributed tracing.
|
|
110
|
-
*
|
|
111
|
-
* Handler failures are retried without reconnecting. After handler
|
|
112
|
-
* retries are exhausted the event is skipped (lower bound advanced)
|
|
113
|
-
* so observation can continue. When the connection drops, exponential
|
|
114
|
-
* backoff with jitter is applied up to the configured maximum number
|
|
115
|
-
* of connection retries.
|
|
116
|
-
*
|
|
117
|
-
* @param eventObserver - The event observer configuration.
|
|
118
|
-
* @returns A promise that resolves when the observe stream ends or
|
|
119
|
-
* connection retries are exhausted.
|
|
120
|
-
*/
|
|
121
|
-
export declare const observeWithRetry: (eventObserver: EventObserver) => Promise<void>;
|
|
122
|
-
/**
|
|
123
|
-
* Initializes an event observer by starting the observation loop in
|
|
124
|
-
* the background (non-blocking). The observer will keep running and
|
|
125
|
-
* reconnecting according to its connection retry options until the
|
|
126
|
-
* stream ends or connection retries are exhausted. Handler failures
|
|
127
|
-
* are retried separately and do not stop the observer.
|
|
128
|
-
*
|
|
129
|
-
* @param eventObserver - The event observer configuration.
|
|
130
|
-
*/
|
|
131
|
-
export declare const initEventObserver: (eventObserver: EventObserver) => void;
|
|
132
|
-
export {};
|
|
133
|
-
//# sourceMappingURL=eventObserver.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"eventObserver.d.ts","sourceRoot":"","sources":["../../src/lib/eventObserver.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAAE,KAAK,IAAI,oBAAoB,EAAE,MAAM,iBAAiB,CAAC;AAarE,KAAK,KAAK,GAAG;IACT,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,WAAW,GAAG,WAAW,CAAC;CACnC,CAAC;AAEF,KAAK,sBAAsB,GAAG;IAC1B,OAAO,EAAE,MAAM,CAAC;IAChB,IAAI,EAAE,MAAM,CAAC;IACb,gBAAgB,EAAE,iBAAiB,GAAG,gBAAgB,CAAC;CAC1D,CAAC;AAEF,MAAM,MAAM,YAAY,GAAG;IACvB;;;OAGG;IACH,UAAU,EAAE,MAAM,CAAC;IACnB;;;;OAIG;IACH,mBAAmB,EAAE,MAAM,CAAC;CAC/B,CAAC;AAOF;;;;;GAKG;AACH,MAAM,MAAM,aAAa,GAAG;IACxB;;OAEG;IACH,OAAO,EAAE,MAAM,CAAC;IAChB;;;OAGG;IACH,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB;;;OAGG;IACH,UAAU,CAAC,EAAE,KAAK,CAAC;IACnB;;;OAGG;IACH,eAAe,CAAC,EAAE,sBAAsB,CAAC;IACzC;;;;;OAKG;IACH,YAAY,EAAE,CAAC,KAAK,EAAE,oBAAoB,KAAK,OAAO,CAAC,IAAI,CAAC,GAAG,IAAI,CAAC;IACpE;;;;OAIG;IACH,sBAAsB,CAAC,EAAE,YAAY,CAAC;IACtC;;;;OAIG;IACH,mBAAmB,CAAC,EAAE,YAAY,CAAC;IACnC;;;;;OAKG;IACH,YAAY,CAAC,EAAE,YAAY,CAAC;IAC5B;;;;;;;OAOG;IACH,cAAc,CAAC,EAAE,CACb,KAAK,EAAE,KAAK,EACZ,KAAK,EAAE,oBAAoB,KAC1B,OAAO,CAAC,IAAI,CAAC,GAAG,IAAI,CAAC;CAC7B,CAAC;AAQF;;;;;;;;;;;;;GAaG;AACH,eAAO,MAAM,qBAAqB,GAC9B,gBAAgB,MAAM,EACtB,SAAS,MAAM,KAChB,MAIG,CAAC;AAgPP;;;;;;;;;;;;;;;;;;;GAmBG;AACH,eAAO,MAAM,gBAAgB,GACzB,eAAe,aAAa,KAC7B,OAAO,CAAC,IAAI,CAiGd,CAAC;AAEF;;;;;;;;GAQG;AACH,eAAO,MAAM,iBAAiB,GAAI,eAAe,aAAa,KAAG,IAEhE,CAAC"}
|