@spine-event-engine/storage-mysql 2.0.0-snapshot.23 → 2.0.0-snapshot.25
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 +38 -30
- package/REFERENCE.md +68 -59
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js.map +1 -1
- package/dist/mysql/agent-history.d.ts +47 -8
- package/dist/mysql/agent-history.d.ts.map +1 -1
- package/dist/mysql/agent-history.js +85 -19
- package/dist/mysql/agent-history.js.map +1 -1
- package/dist/mysql/agent-transaction.d.ts +56 -0
- package/dist/mysql/agent-transaction.d.ts.map +1 -0
- package/dist/mysql/{entity-commit.js → agent-transaction.js} +33 -45
- package/dist/mysql/agent-transaction.js.map +1 -0
- package/dist/mysql/column-mapping.d.ts +1 -0
- package/dist/mysql/column-mapping.d.ts.map +1 -1
- package/dist/mysql/column-mapping.js +26 -3
- package/dist/mysql/column-mapping.js.map +1 -1
- package/dist/mysql/entity-history.d.ts +61 -35
- package/dist/mysql/entity-history.d.ts.map +1 -1
- package/dist/mysql/entity-history.js +469 -109
- package/dist/mysql/entity-history.js.map +1 -1
- package/dist/mysql/errors.d.ts +3 -2
- package/dist/mysql/errors.d.ts.map +1 -1
- package/dist/mysql/errors.js +3 -2
- package/dist/mysql/errors.js.map +1 -1
- package/dist/mysql/id-column.d.ts +7 -0
- package/dist/mysql/id-column.d.ts.map +1 -1
- package/dist/mysql/id-column.js +27 -3
- package/dist/mysql/id-column.js.map +1 -1
- package/dist/mysql/record-storage.d.ts +242 -72
- package/dist/mysql/record-storage.d.ts.map +1 -1
- package/dist/mysql/record-storage.js +509 -291
- package/dist/mysql/record-storage.js.map +1 -1
- package/dist/mysql/storage-factory.d.ts +286 -36
- package/dist/mysql/storage-factory.d.ts.map +1 -1
- package/dist/mysql/storage-factory.js +1294 -217
- package/dist/mysql/storage-factory.js.map +1 -1
- package/dist/mysql/table-resolver.d.ts +32 -1
- package/dist/mysql/table-resolver.d.ts.map +1 -1
- package/dist/mysql/table-resolver.js +81 -23
- package/dist/mysql/table-resolver.js.map +1 -1
- package/dist/mysql/table-spec.d.ts +0 -4
- package/dist/mysql/table-spec.d.ts.map +1 -1
- package/dist/mysql/table-spec.js +1 -33
- package/dist/mysql/table-spec.js.map +1 -1
- package/dist/mysql/testing.d.ts +8 -0
- package/dist/mysql/testing.d.ts.map +1 -1
- package/dist/mysql/testing.js +23 -2
- package/dist/mysql/testing.js.map +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +5 -5
- package/dist/mysql/agent-execution.d.ts +0 -278
- package/dist/mysql/agent-execution.d.ts.map +0 -1
- package/dist/mysql/agent-execution.js +0 -638
- package/dist/mysql/agent-execution.js.map +0 -1
- package/dist/mysql/delivery-cleanup.d.ts +0 -37
- package/dist/mysql/delivery-cleanup.d.ts.map +0 -1
- package/dist/mysql/delivery-cleanup.js +0 -108
- package/dist/mysql/delivery-cleanup.js.map +0 -1
- package/dist/mysql/entity-commit.d.ts +0 -79
- package/dist/mysql/entity-commit.d.ts.map +0 -1
- package/dist/mysql/entity-commit.js.map +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"agent-history.js","sourceRoot":"","sources":["../../src/mysql/agent-history.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAEH,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;
|
|
1
|
+
{"version":3,"file":"agent-history.js","sourceRoot":"","sources":["../../src/mysql/agent-history.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAEH,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACzC,OAAO,EAAE,KAAK,EAAE,QAAQ,EAAE,MAAM,oBAAoB,CAAC;AAErD,OAAO,EACL,wBAAwB,GAEzB,MAAM,6EAA6E,CAAC;AACrF,OAAO,EACL,gBAAgB,EAChB,iBAAiB,GAMlB,MAAM,sCAAsC,CAAC;A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AAC,CAAC;YACrD,OAAO;QACT,CAAC;QACD,MAAM,CAAC,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QAC/B,OAAO,CAAC,IAAI,CAAC,gBAAgB,CAAC,CAAC;IACjC,CAAC;IAED;;;;OAIG;IACK,YAAY,CAAC,OAA6B;QAChD,MAAM,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC;QAC/B,IAAI,IAAI,KAAK,cAAc,IAAI,OAAO,CAAC,IAAI,CAAC,YAAY,CAAC,KAAK,CAAC,MAAM,KAAK,CAAC;YACzE,MAAM,IAAI,SAAS,CAAC,iDAAiD,CAAC,CAAC;QACzE,IAAI,OAAO,CAAC,KAAK,KAAK,SAAS,IAAI,IAAI,KAAK,MAAM,IAAI,OAAO,CAAC,KAAK,CAAC,QAAQ,KAAK,IAAI;YACnF,MAAM,IAAI,SAAS,CAAC,0DAA0D,CAAC,CAAC;IACpF,CAAC;IAED;;;;;OAKG;IACK,GAAG,CAAC,EAAM;QAChB,MAAM,GAAG,GAAG,IAAI,CAAC,KAAK,CAAC,EAAE,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC;QAClC,IAAI,GAAG,CAAC,MAAM,KAAK,CAAC;YAAE,MAAM,IAAI,SAAS,CAAC,sCAAsC,CAAC,CAAC;QAClF,OAAO,GAAG,CAAC;IACb,CAAC;IAED;;OAEG;IACK,WAAW;QACjB,IAAI,CAAC,IAAI,CAAC,KAAK;YAAE,MAAM,IAAI,KAAK,CAAC,yCAAyC,CAAC,CAAC;IAC9E,CAAC;CACF"}
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import type { PoolConnection } from "mysql2/promise";
|
|
2
|
+
/**
|
|
3
|
+
* Coordinates native MySQL Agent execution transactions.
|
|
4
|
+
*/
|
|
5
|
+
export declare class MysqlAgentTransaction {
|
|
6
|
+
private readonly connections;
|
|
7
|
+
/**
|
|
8
|
+
* Creates an Agent execution transaction helper.
|
|
9
|
+
*
|
|
10
|
+
* @param connections Acquires and releases MySQL connections.
|
|
11
|
+
*/
|
|
12
|
+
constructor(connections: {
|
|
13
|
+
acquire(): Promise<PoolConnection>;
|
|
14
|
+
release(connection: PoolConnection): void;
|
|
15
|
+
});
|
|
16
|
+
/**
|
|
17
|
+
* Commits one fenced Agent mutation in a native transaction.
|
|
18
|
+
*
|
|
19
|
+
* @param tables Lists participating physical tables.
|
|
20
|
+
* @param work Performs the connection-bound mutation.
|
|
21
|
+
* @typeParam T The mutation result type.
|
|
22
|
+
* @returns Returns the work result.
|
|
23
|
+
*/
|
|
24
|
+
commit<T>(tables: readonly string[], work: (connection: PoolConnection) => Promise<T>): Promise<T>;
|
|
25
|
+
/**
|
|
26
|
+
* Checks every declared live Agent table for native transaction support.
|
|
27
|
+
* @param tables Participating physical table names.
|
|
28
|
+
* @returns Completion after a read-only InnoDB inspection.
|
|
29
|
+
*/
|
|
30
|
+
check(tables: readonly string[]): Promise<void>;
|
|
31
|
+
/**
|
|
32
|
+
* Determines whether every participating table supports transactions.
|
|
33
|
+
*
|
|
34
|
+
* @param connection Provides the connection used for metadata inspection.
|
|
35
|
+
* @param tables Lists participating physical tables.
|
|
36
|
+
* @returns Resolves whether every table uses InnoDB.
|
|
37
|
+
*/
|
|
38
|
+
private allTransactional;
|
|
39
|
+
/**
|
|
40
|
+
* Commits transactional work and retries one deadlock.
|
|
41
|
+
*
|
|
42
|
+
* @param connection Provides the transaction connection.
|
|
43
|
+
* @param work Performs the connection-bound mutation.
|
|
44
|
+
* @typeParam T The mutation result type.
|
|
45
|
+
* @returns Resolves to the mutation result.
|
|
46
|
+
*/
|
|
47
|
+
private commitTransaction;
|
|
48
|
+
/**
|
|
49
|
+
* Checks whether a failed transaction may be retried once after a deadlock.
|
|
50
|
+
*
|
|
51
|
+
* @param error Native MySQL failure.
|
|
52
|
+
* @returns Whether the error identifies an InnoDB deadlock.
|
|
53
|
+
*/
|
|
54
|
+
private isDeadlock;
|
|
55
|
+
}
|
|
56
|
+
//# sourceMappingURL=agent-transaction.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"agent-transaction.d.ts","sourceRoot":"","sources":["../../src/mysql/agent-transaction.ts"],"names":[],"mappings":"AAcA,OAAO,KAAK,EAAE,cAAc,EAAiB,MAAM,gBAAgB,CAAC;AAEpE;;GAEG;AACH,qBAAa,qBAAqB;IAS9B,OAAO,CAAC,QAAQ,CAAC,WAAW;IAN9B;;;;OAIG;gBAEgB,WAAW,EAAE;QAC5B,OAAO,IAAI,OAAO,CAAC,cAAc,CAAC,CAAC;QACnC,OAAO,CAAC,UAAU,EAAE,cAAc,GAAG,IAAI,CAAC;KAC3C;IAGH;;;;;;;OAOG;IACG,MAAM,CAAC,CAAC,EACZ,MAAM,EAAE,SAAS,MAAM,EAAE,EACzB,IAAI,EAAE,CAAC,UAAU,EAAE,cAAc,KAAK,OAAO,CAAC,CAAC,CAAC,GAC/C,OAAO,CAAC,CAAC,CAAC;IAYb;;;;OAIG;IACG,KAAK,CAAC,MAAM,EAAE,SAAS,MAAM,EAAE,GAAG,OAAO,CAAC,IAAI,CAAC;IAUrD;;;;;;OAMG;YACW,gBAAgB;IAa9B;;;;;;;OAOG;YACW,iBAAiB;IAmB/B;;;;;OAKG;IACH,OAAO,CAAC,UAAU;CAOnB"}
|
|
@@ -11,26 +11,14 @@
|
|
|
11
11
|
* or implied. See the License for the specific language governing permissions and limitations under
|
|
12
12
|
* the License.
|
|
13
13
|
*/
|
|
14
|
-
import { createHash } from "node:crypto";
|
|
15
14
|
/**
|
|
16
|
-
*
|
|
17
|
-
*
|
|
18
|
-
* @param identity Identifies the Entity commit.
|
|
19
|
-
* @returns Returns the advisory-lock key.
|
|
20
|
-
*/
|
|
21
|
-
export function mysqlEntityLockKey(identity) {
|
|
22
|
-
return createHash("sha256")
|
|
23
|
-
.update([identity.databaseName, identity.sourceTypeName, identity.entityKey].join("\u0000"))
|
|
24
|
-
.digest("hex");
|
|
25
|
-
}
|
|
26
|
-
/**
|
|
27
|
-
* Coordinates one-connection Entity commits.
|
|
15
|
+
* Coordinates native MySQL Agent execution transactions.
|
|
28
16
|
*/
|
|
29
|
-
export class
|
|
17
|
+
export class MysqlAgentTransaction {
|
|
30
18
|
connections;
|
|
31
19
|
// prettier-ignore
|
|
32
20
|
/**
|
|
33
|
-
* Creates an
|
|
21
|
+
* Creates an Agent execution transaction helper.
|
|
34
22
|
*
|
|
35
23
|
* @param connections Acquires and releases MySQL connections.
|
|
36
24
|
*/
|
|
@@ -38,31 +26,37 @@ export class MysqlEntityCommitCoordinator {
|
|
|
38
26
|
this.connections = connections;
|
|
39
27
|
}
|
|
40
28
|
/**
|
|
41
|
-
* Commits one
|
|
29
|
+
* Commits one fenced Agent mutation in a native transaction.
|
|
42
30
|
*
|
|
43
31
|
* @param tables Lists participating physical tables.
|
|
44
|
-
* @param key Identifies the advisory lock.
|
|
45
32
|
* @param work Performs the connection-bound mutation.
|
|
46
|
-
* @param options Requires a transaction when the caller cannot use an advisory lock.
|
|
47
33
|
* @typeParam T The mutation result type.
|
|
48
34
|
* @returns Returns the work result.
|
|
49
35
|
*/
|
|
50
|
-
async commit(tables,
|
|
36
|
+
async commit(tables, work) {
|
|
51
37
|
const connection = await this.connections.acquire();
|
|
52
|
-
let locked = false;
|
|
53
38
|
try {
|
|
54
39
|
const transactional = await this.allTransactional(connection, tables);
|
|
55
|
-
if (!transactional
|
|
56
|
-
throw new Error("MySQL
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
40
|
+
if (!transactional)
|
|
41
|
+
throw new Error("MySQL Agent execution requires transactional record tables.");
|
|
42
|
+
return await this.commitTransaction(connection, work);
|
|
43
|
+
}
|
|
44
|
+
finally {
|
|
45
|
+
this.connections.release(connection);
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* Checks every declared live Agent table for native transaction support.
|
|
50
|
+
* @param tables Participating physical table names.
|
|
51
|
+
* @returns Completion after a read-only InnoDB inspection.
|
|
52
|
+
*/
|
|
53
|
+
async check(tables) {
|
|
54
|
+
const connection = await this.connections.acquire();
|
|
55
|
+
try {
|
|
56
|
+
if (!(await this.allTransactional(connection, tables)))
|
|
57
|
+
throw new Error("MySQL Agent execution requires transactional record tables.");
|
|
62
58
|
}
|
|
63
59
|
finally {
|
|
64
|
-
if (locked)
|
|
65
|
-
await connection.execute("SELECT RELEASE_LOCK(?)", [key]).catch(() => undefined);
|
|
66
60
|
this.connections.release(connection);
|
|
67
61
|
}
|
|
68
62
|
}
|
|
@@ -89,13 +83,13 @@ export class MysqlEntityCommitCoordinator {
|
|
|
89
83
|
for (let attempt = 0; attempt < 2; attempt += 1) {
|
|
90
84
|
try {
|
|
91
85
|
await connection.beginTransaction();
|
|
92
|
-
const result = await work(connection
|
|
86
|
+
const result = await work(connection);
|
|
93
87
|
await connection.commit();
|
|
94
88
|
return result;
|
|
95
89
|
}
|
|
96
90
|
catch (error) {
|
|
97
91
|
await connection.rollback().catch(() => undefined);
|
|
98
|
-
if (attempt === 0 && isDeadlock(error))
|
|
92
|
+
if (attempt === 0 && this.isDeadlock(error))
|
|
99
93
|
continue;
|
|
100
94
|
throw error;
|
|
101
95
|
}
|
|
@@ -103,21 +97,15 @@ export class MysqlEntityCommitCoordinator {
|
|
|
103
97
|
throw new Error("Unreachable InnoDB commit retry.");
|
|
104
98
|
}
|
|
105
99
|
/**
|
|
106
|
-
*
|
|
100
|
+
* Checks whether a failed transaction may be retried once after a deadlock.
|
|
107
101
|
*
|
|
108
|
-
* @param
|
|
109
|
-
* @
|
|
110
|
-
* @returns Resolves after the lock is acquired.
|
|
102
|
+
* @param error Native MySQL failure.
|
|
103
|
+
* @returns Whether the error identifies an InnoDB deadlock.
|
|
111
104
|
*/
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
105
|
+
isDeadlock(error) {
|
|
106
|
+
return (typeof error === "object" &&
|
|
107
|
+
error !== null &&
|
|
108
|
+
error.code === "ER_LOCK_DEADLOCK");
|
|
116
109
|
}
|
|
117
110
|
}
|
|
118
|
-
|
|
119
|
-
return (typeof error === "object" &&
|
|
120
|
-
error !== null &&
|
|
121
|
-
error.code === "ER_LOCK_DEADLOCK");
|
|
122
|
-
}
|
|
123
|
-
//# sourceMappingURL=entity-commit.js.map
|
|
111
|
+
//# sourceMappingURL=agent-transaction.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"agent-transaction.js","sourceRoot":"","sources":["../../src/mysql/agent-transaction.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAIH;;GAEG;AACH,MAAM,OAAO,qBAAqB;IASb;IARnB,kBAAkB;IAElB;;;;OAIG;IACH,YACmB,WAGhB;QAHgB,gBAAW,GAAX,WAAW,CAG3B;IACA,CAAC;IAEJ;;;;;;;OAOG;IACH,KAAK,CAAC,MAAM,CACV,MAAyB,EACzB,IAAgD;QAEhD,MAAM,UAAU,GAAG,MAAM,IAAI,CAAC,WAAW,CAAC,OAAO,EAAE,CAAC;QACpD,IAAI,CAAC;YACH,MAAM,aAAa,GAAG,MAAM,IAAI,CAAC,gBAAgB,CAAC,UAAU,EAAE,MAAM,CAAC,CAAC;YACtE,IAAI,CAAC,aAAa;gBAChB,MAAM,IAAI,KAAK,CAAC,6DAA6D,CAAC,CAAC;YACjF,OAAO,MAAM,IAAI,CAAC,iBAAiB,CAAC,UAAU,EAAE,IAAI,CAAC,CAAC;QACxD,CAAC;gBAAS,CAAC;YACT,IAAI,CAAC,WAAW,CAAC,OAAO,CAAC,UAAU,CAAC,CAAC;QACvC,CAAC;IACH,CAAC;IAED;;;;OAIG;IACH,KAAK,CAAC,KAAK,CAAC,MAAyB;QACnC,MAAM,UAAU,GAAG,MAAM,IAAI,CAAC,WAAW,CAAC,OAAO,EAAE,CAAC;QACpD,IAAI,CAAC;YACH,IAAI,CAAC,CAAC,MAAM,IAAI,CAAC,gBAAgB,CAAC,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AAkC,CAAC,CAAC;IACtD,CAAC;IAED;;;;;OAKG;IACK,UAAU,CAAC,KAAc;QAC/B,OAAO,CACL,OAAO,KAAK,KAAK,QAAQ;YACzB,KAAK,KAAK,IAAI;YACb,KAA4B,CAAC,IAAI,KAAK,kBAAkB,CAC1D,CAAC;IACJ,CAAC;CACF"}
|
|
@@ -14,6 +14,7 @@ export declare class MysqlColumnMapping implements ColumnMapping<unknown> {
|
|
|
14
14
|
/**
|
|
15
15
|
* Returns the conversion for one generated column type.
|
|
16
16
|
*
|
|
17
|
+
* @typeParam V Protobuf column value type.
|
|
17
18
|
* @param type The generated Protobuf column type.
|
|
18
19
|
* @returns The JVM-compatible MySQL parameter conversion.
|
|
19
20
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"column-mapping.d.ts","sourceRoot":"","sources":["../../src/mysql/column-mapping.ts"],"names":[],"mappings":"AAgBA,OAAO,
|
|
1
|
+
{"version":3,"file":"column-mapping.d.ts","sourceRoot":"","sources":["../../src/mysql/column-mapping.ts"],"names":[],"mappings":"AAgBA,OAAO,EAA8B,mBAAmB,EAAE,MAAM,0BAA0B,CAAC;AAC3F,OAAO,KAAK,EACV,aAAa,EACb,iBAAiB,EACjB,gBAAgB,EACjB,MAAM,6BAA6B,CAAC;AAKrC;;GAEG;AACH,qBAAa,kBAAmB,YAAW,aAAa,CAAC,OAAO,CAAC;;IAG/D;;;;OAIG;gBACS,YAAY,GAAE,mBAAgD;IAS1E;;;;;;OAMG;IACH,EAAE,CAAC,CAAC,EAAE,IAAI,EAAE,gBAAgB,CAAC,CAAC,CAAC,GAAG,iBAAiB,CAAC,CAAC,EAAE,OAAO,CAAC;IAoB/D;;;OAGG;IACH,MAAM,IAAI,iBAAiB,CAAC,IAAI,EAAE,OAAO,CAAC;CAG3C"}
|
|
@@ -12,7 +12,7 @@
|
|
|
12
12
|
* the License.
|
|
13
13
|
*/
|
|
14
14
|
import { ScalarType } from "@bufbuild/protobuf";
|
|
15
|
-
import { StringifierRegistry } from "@spine-event-engine/core";
|
|
15
|
+
import { defaultStringifierRegistry, StringifierRegistry } from "@spine-event-engine/core";
|
|
16
16
|
const timestampType = "google.protobuf.Timestamp";
|
|
17
17
|
const versionType = "spine.core.Version";
|
|
18
18
|
/**
|
|
@@ -25,13 +25,17 @@ export class MysqlColumnMapping {
|
|
|
25
25
|
*
|
|
26
26
|
* @param stringifiers The schema-bound message stringifiers.
|
|
27
27
|
*/
|
|
28
|
-
constructor(stringifiers =
|
|
29
|
-
this.#stringifiers =
|
|
28
|
+
constructor(stringifiers = defaultStringifierRegistry) {
|
|
29
|
+
this.#stringifiers =
|
|
30
|
+
stringifiers === defaultStringifierRegistry
|
|
31
|
+
? stringifiers
|
|
32
|
+
: new StringifierRegistry(stringifiers);
|
|
30
33
|
}
|
|
31
34
|
// prettier-ignore
|
|
32
35
|
/**
|
|
33
36
|
* Returns the conversion for one generated column type.
|
|
34
37
|
*
|
|
38
|
+
* @typeParam V Protobuf column value type.
|
|
35
39
|
* @param type The generated Protobuf column type.
|
|
36
40
|
* @returns The JVM-compatible MySQL parameter conversion.
|
|
37
41
|
*/
|
|
@@ -62,6 +66,13 @@ export class MysqlColumnMapping {
|
|
|
62
66
|
}
|
|
63
67
|
}
|
|
64
68
|
const MysqlMappings = Object.freeze({
|
|
69
|
+
/**
|
|
70
|
+
* Maps a scalar column to a MySQL parameter.
|
|
71
|
+
*
|
|
72
|
+
* @typeParam V Scalar value type.
|
|
73
|
+
* @param type Protobuf scalar kind.
|
|
74
|
+
* @returns The scalar conversion.
|
|
75
|
+
*/
|
|
65
76
|
scalar(type) {
|
|
66
77
|
switch (type) {
|
|
67
78
|
case ScalarType.STRING:
|
|
@@ -83,10 +94,22 @@ const MysqlMappings = Object.freeze({
|
|
|
83
94
|
throw new Error("Spine JVM JDBC does not support floating-point record columns.");
|
|
84
95
|
}
|
|
85
96
|
},
|
|
97
|
+
/**
|
|
98
|
+
* Converts a timestamp to epoch nanoseconds.
|
|
99
|
+
*
|
|
100
|
+
* @param value Protobuf timestamp value.
|
|
101
|
+
* @returns Epoch nanoseconds.
|
|
102
|
+
*/
|
|
86
103
|
timestamp(value) {
|
|
87
104
|
const timestamp = value;
|
|
88
105
|
return timestamp.seconds * 1000000000n + BigInt(timestamp.nanos);
|
|
89
106
|
},
|
|
107
|
+
/**
|
|
108
|
+
* Converts a version to its integer number.
|
|
109
|
+
*
|
|
110
|
+
* @param value Protobuf version value.
|
|
111
|
+
* @returns Version number.
|
|
112
|
+
*/
|
|
90
113
|
version(value) {
|
|
91
114
|
return value.number;
|
|
92
115
|
},
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"column-mapping.js","sourceRoot":"","sources":["../../src/mysql/column-mapping.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAEH,OAAO,EAAE,UAAU,EAAgB,MAAM,oBAAoB,CAAC;AAE9D,OAAO,EAAE,mBAAmB,EAAE,MAAM,0BAA0B,CAAC;
|
|
1
|
+
{"version":3,"file":"column-mapping.js","sourceRoot":"","sources":["../../src/mysql/column-mapping.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAEH,OAAO,EAAE,UAAU,EAAgB,MAAM,oBAAoB,CAAC;AAE9D,OAAO,EAAE,0BAA0B,EAAE,mBAAmB,EAAE,MAAM,0BAA0B,CAAC;AAO3F,MAAM,aAAa,GAAG,2BAA2B,CAAC;AAClD,MAAM,WAAW,GAAG,oBAAoB,CAAC;AAEzC;;GAEG;AACH,MAAM,OAAO,kBAAkB;IACpB,aAAa,CAAsB;IAE5C;;;;OAIG;IACH,YAAY,eAAoC,0BAA0B;QACxE,IAAI,CAAC,aAAa;YAChB,YAAY,KAAK,0BAA0B;gBACzC,CAAC,CAAC,YAAY;gBACd,CAAC,CAAC,IAAI,mBAAmB,CAAC,YAAY,CAAC,CAAC;IAC9C,CAAC;IAED,kBAAkB;IAElB;;;;;;OAMG;IACH,EAAE,CAAI,IAAyB;QAC7B,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K,UAAU,CAAC,QAAQ,CAAC;YACzB,KAAK,UAAU,CAAC,MAAM,CAAC;YACvB,KAAK,UAAU,CAAC,OAAO,CAAC;YACxB,KAAK,UAAU,CAAC,IAAI,CAAC;YACrB,KAAK,UAAU,CAAC,KAAK;gBACnB,OAAO,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,CAAC;YAC1B,KAAK,UAAU,CAAC,KAAK,CAAC;YACtB,KAAK,UAAU,CAAC,MAAM;gBACpB,MAAM,IAAI,KAAK,CAAC,gEAAgE,CAAC,CAAC;QACtF,CAAC;IACH,CAAC;IAED;;;;;OAKG;IACH,SAAS,CAAC,KAAc;QACtB,MAAM,SAAS,GAAG,KAA6D,CAAC;QAChF,OAAO,SAAS,CAAC,OAAO,GAAG,WAAc,GAAG,MAAM,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC;IACtE,CAAC;IAED;;;;;OAKG;IACH,OAAO,CAAC,KAAc;QACpB,OAAQ,KAAqC,CAAC,MAAM,CAAC;IACvD,CAAC;CACF,CAAC,CAAC"}
|
|
@@ -3,18 +3,27 @@ import type { Event } from "@spine-event-engine/proto";
|
|
|
3
3
|
import type { EntityRecord } from "@spine-event-engine/proto/generated/spine/server/entity/entity_pb.js";
|
|
4
4
|
import { RecordSpec } from "@spine-event-engine/storage";
|
|
5
5
|
import { type EntityEventHistoryPort, type EntityRecordStorage, type EntityStateHistoryPort, type EntityStorageInput } from "@spine-event-engine/storage/provider";
|
|
6
|
-
import { MysqlRecordStorage } from "./record-storage.js";
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
6
|
+
import { MysqlRecordStorage, type OnPublicOperation } from "./record-storage.js";
|
|
7
|
+
/**
|
|
8
|
+
* Opens one MySQL record family for Entity storage.
|
|
9
|
+
*/
|
|
10
|
+
interface OpenRecords {
|
|
11
|
+
/**
|
|
12
|
+
* Creates a scoped record handle.
|
|
13
|
+
*
|
|
14
|
+
* @typeParam Id Record identifier type.
|
|
15
|
+
* @typeParam R Stored record message type.
|
|
16
|
+
* @param spec Defines the record family.
|
|
17
|
+
* @param group Selects an optional history group.
|
|
18
|
+
* @returns The MySQL record handle.
|
|
19
|
+
*/
|
|
20
|
+
<Id, R extends Message>(spec: RecordSpec<Id, R>, group?: import("@spine-event-engine/storage").StorageGroup): MysqlRecordStorage<Id, R>;
|
|
15
21
|
}
|
|
16
22
|
/**
|
|
17
23
|
* Describes MySQL-backed Entity record-family handles.
|
|
24
|
+
*
|
|
25
|
+
* @typeParam I Entity identifier type.
|
|
26
|
+
* @typeParam S Entity state message type.
|
|
18
27
|
*/
|
|
19
28
|
export interface MysqlEntityStorageHandle<I, S extends Message> {
|
|
20
29
|
/**
|
|
@@ -42,10 +51,16 @@ export interface MysqlEntityStorageHandle<I, S extends Message> {
|
|
|
42
51
|
}
|
|
43
52
|
/**
|
|
44
53
|
* Provides MySQL-backed Entity current and history storage.
|
|
54
|
+
*
|
|
55
|
+
* @typeParam I Entity identifier type.
|
|
56
|
+
* @typeParam S Entity state message type.
|
|
45
57
|
*/
|
|
46
58
|
export declare class MysqlEntityStorage<I, S extends Message> implements MysqlEntityStorageHandle<I, S> {
|
|
47
59
|
#private;
|
|
60
|
+
private readonly input;
|
|
61
|
+
private readonly open;
|
|
48
62
|
private readonly onClose;
|
|
63
|
+
private readonly onAdmit;
|
|
49
64
|
/**
|
|
50
65
|
* Exposes current Entity records.
|
|
51
66
|
*/
|
|
@@ -53,26 +68,28 @@ export declare class MysqlEntityStorage<I, S extends Message> implements MysqlEn
|
|
|
53
68
|
/**
|
|
54
69
|
* Exposes Entity state history records.
|
|
55
70
|
*/
|
|
56
|
-
|
|
71
|
+
states: EntityStateHistoryPort<I, S>;
|
|
57
72
|
/**
|
|
58
73
|
* Exposes Entity event history records.
|
|
59
74
|
*/
|
|
60
|
-
|
|
75
|
+
events: EntityEventHistoryPort<I>;
|
|
61
76
|
/**
|
|
62
77
|
* Creates MySQL-backed Entity storage handles.
|
|
63
78
|
*
|
|
64
79
|
* @param input Configures the Entity storage families.
|
|
65
80
|
* @param open Opens one record-family storage handle.
|
|
66
81
|
* @param onClose Removes this Entity handle from its factory.
|
|
82
|
+
* @param lazy Whether optional families are acquired on first use.
|
|
83
|
+
* @param onAdmit Admits complete public Entity operations.
|
|
67
84
|
*/
|
|
68
|
-
constructor(input: EntityStorageInput<I, S>, open:
|
|
85
|
+
constructor(input: EntityStorageInput<I, S>, open: OpenRecords, onClose?: () => void, lazy?: boolean, onAdmit?: OnPublicOperation);
|
|
69
86
|
/**
|
|
70
|
-
*
|
|
87
|
+
* Acquires only missing requested history families, rolling back a failed upgrade.
|
|
71
88
|
*
|
|
72
|
-
* @param
|
|
73
|
-
* @
|
|
89
|
+
* @param wantEvents Whether diagnostic Event history is required.
|
|
90
|
+
* @param wantStates Whether state history is required.
|
|
74
91
|
*/
|
|
75
|
-
|
|
92
|
+
ensure(wantStates: boolean, wantEvents: boolean): void;
|
|
76
93
|
/**
|
|
77
94
|
* Returns whether this Entity storage handle accepts operations.
|
|
78
95
|
*
|
|
@@ -84,40 +101,49 @@ export declare class MysqlEntityStorage<I, S extends Message> implements MysqlEn
|
|
|
84
101
|
*/
|
|
85
102
|
close(): void;
|
|
86
103
|
/**
|
|
87
|
-
*
|
|
104
|
+
* Prepares every Entity record-family table.
|
|
88
105
|
*
|
|
89
|
-
* @
|
|
90
|
-
* @param work Performs the bound storage work.
|
|
91
|
-
* @returns Returns the work result.
|
|
106
|
+
* @returns Resolves after the tables are ready.
|
|
92
107
|
*/
|
|
93
|
-
|
|
108
|
+
prepare(): Promise<void>;
|
|
94
109
|
/**
|
|
95
|
-
* Returns
|
|
110
|
+
* Returns physical Entity-family tables for an Agent transaction.
|
|
96
111
|
*
|
|
97
|
-
* @returns
|
|
112
|
+
* @returns Current and configured history table names.
|
|
98
113
|
*/
|
|
99
114
|
tableNames(): readonly string[];
|
|
100
115
|
/**
|
|
101
|
-
*
|
|
116
|
+
* Binds Entity-family work to the Agent transaction connection.
|
|
102
117
|
*
|
|
103
|
-
* @
|
|
118
|
+
* @typeParam T Result of the bound work.
|
|
119
|
+
* @param connection Active Agent transaction connection.
|
|
120
|
+
* @param work Entity work to run on that connection.
|
|
121
|
+
* @returns Result of the work.
|
|
104
122
|
*/
|
|
105
|
-
|
|
123
|
+
withConnection<T>(connection: import("mysql2/promise").PoolConnection, work: () => Promise<T>): Promise<T>;
|
|
124
|
+
/**
|
|
125
|
+
* Reads current Entity state with the Agent transaction lock.
|
|
126
|
+
*
|
|
127
|
+
* @param id Typed Entity ID.
|
|
128
|
+
* @returns Current record when present.
|
|
129
|
+
*/
|
|
130
|
+
readCurrentLocked(id: I): Promise<EntityRecord | undefined>;
|
|
106
131
|
/**
|
|
107
|
-
*
|
|
132
|
+
* Writes current state inside an already admitted Agent transaction.
|
|
108
133
|
*
|
|
109
|
-
* @param
|
|
110
|
-
* @
|
|
111
|
-
* @returns Resolves when every record is compatible.
|
|
134
|
+
* @param record Committed current Entity state.
|
|
135
|
+
* @returns Completion after the record write.
|
|
112
136
|
*/
|
|
113
|
-
|
|
137
|
+
writeCurrentAdmitted(record: EntityRecord): Promise<void>;
|
|
114
138
|
/**
|
|
115
|
-
*
|
|
139
|
+
* Returns configured Entity history writers for the Agent transaction.
|
|
116
140
|
*
|
|
117
|
-
* @
|
|
118
|
-
* @returns Returns the private Entity-family commit capability.
|
|
141
|
+
* @returns Transaction-bound immutable history appenders.
|
|
119
142
|
*/
|
|
120
|
-
commitCapability():
|
|
143
|
+
commitCapability(): {
|
|
144
|
+
appendStateImmutable(record: EntityRecord): Promise<void>;
|
|
145
|
+
appendDiagnosticImmutable(record: Event): Promise<void>;
|
|
146
|
+
};
|
|
121
147
|
}
|
|
122
148
|
export {};
|
|
123
149
|
//# sourceMappingURL=entity-history.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"entity-history.d.ts","sourceRoot":"","sources":["../../src/mysql/entity-history.ts"],"names":[],"mappings":"AAcA,OAAO,
|
|
1
|
+
{"version":3,"file":"entity-history.d.ts","sourceRoot":"","sources":["../../src/mysql/entity-history.ts"],"names":[],"mappings":"AAcA,OAAO,EAAU,KAAK,OAAO,EAAE,MAAM,oBAAoB,CAAC;AAG1D,OAAO,KAAK,EAAE,KAAK,EAAW,MAAM,2BAA2B,CAAC;AAChE,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,sEAAsE,CAAC;AAKzG,OAAO,EAAE,UAAU,EAAE,MAAM,6BAA6B,CAAC;AACzD,OAAO,EAGL,KAAK,sBAAsB,EAC3B,KAAK,mBAAmB,EACxB,KAAK,sBAAsB,EAC3B,KAAK,kBAAkB,EACxB,MAAM,sCAAsC,CAAC;AAE9C,OAAO,EAAE,kBAAkB,EAAE,KAAK,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AAEjF;;GAEG;AACH,UAAU,WAAW;IACnB;;;;;;;;OAQG;IAEH,CAAC,EAAE,EAAE,CAAC,SAAS,OAAO,EACpB,IAAI,EAAE,UAAU,CAAC,EAAE,EAAE,CAAC,CAAC,EACvB,KAAK,CAAC,EAAE,OAAO,6BAA6B,EAAE,YAAY,GACzD,kBAAkB,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC;CAC9B;AAED;;;;;GAKG;AACH,MAAM,WAAW,wBAAwB,CAAC,CAAC,EAAE,CAAC,SAAS,OAAO;IAG5D;;OAEG;IACH,QAAQ,CAAC,OAAO,EAAE,mBAAmB,CAAC,CAAC,CAAC,CAAC;IAEzC;;OAEG;IACH,QAAQ,CAAC,MAAM,EAAE,sBAAsB,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;IAE9C;;OAEG;IACH,QAAQ,CAAC,MAAM,EAAE,sBAAsB,CAAC,CAAC,CAAC,CAAC;IAE3C;;;;OAIG;IACH,MAAM,IAAI,OAAO,CAAC;IAElB;;OAEG;IACH,KAAK,IAAI,IAAI,CAAC;CACf;AAED;;;;;GAKG;AAC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