@kurrent/kurrentdb-client 1.2.0-alpha.0 → 1.2.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.
- package/dist/Client/http.d.ts +7 -1
- package/dist/Client/http.js +50 -48
- package/dist/Client/http.js.map +1 -1
- package/dist/Client/index.d.ts +30 -6
- package/dist/Client/index.js +77 -11
- package/dist/Client/index.js.map +1 -1
- package/dist/Client/parseConnectionString.d.ts +2 -2
- package/dist/constants.d.ts +3 -0
- package/dist/constants.js +6 -1
- package/dist/constants.js.map +1 -1
- package/dist/events/binaryEvent.js +2 -2
- package/dist/events/binaryEvent.js.map +1 -1
- package/dist/events/jsonEvent.js +2 -2
- package/dist/events/jsonEvent.js.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +4 -2
- package/dist/index.js.map +1 -1
- package/dist/projections/createProjection.d.ts +10 -1
- package/dist/projections/createProjection.js +13 -2
- package/dist/projections/createProjection.js.map +1 -1
- package/dist/streams/appendToStream/appendRecords.d.ts +3 -0
- package/dist/streams/appendToStream/appendRecords.js +132 -0
- package/dist/streams/appendToStream/appendRecords.js.map +1 -0
- package/dist/streams/appendToStream/batchAppend.js +2 -2
- package/dist/streams/appendToStream/batchAppend.js.map +1 -1
- package/dist/streams/appendToStream/index.d.ts +9 -1
- package/dist/streams/appendToStream/index.js +8 -0
- package/dist/streams/appendToStream/index.js.map +1 -1
- package/dist/streams/readAll.js +18 -18
- package/dist/streams/readAll.js.map +1 -1
- package/dist/streams/readStream.js +26 -34
- package/dist/streams/readStream.js.map +1 -1
- package/dist/types/index.d.ts +88 -2
- package/dist/types/index.js.map +1 -1
- package/dist/utils/CommandError.d.ts +9 -3
- package/dist/utils/CommandError.js +50 -1
- package/dist/utils/CommandError.js.map +1 -1
- package/dist/utils/convertBridgeError.d.ts +2 -1
- package/dist/utils/convertBridgeError.js +14 -24
- package/dist/utils/convertBridgeError.js.map +1 -1
- package/dist/utils/credentials.d.ts +19 -0
- package/dist/utils/credentials.js +31 -0
- package/dist/utils/credentials.js.map +1 -0
- package/dist/utils/grpcUUID.d.ts +1 -0
- package/dist/utils/grpcUUID.js +12 -12
- package/dist/utils/grpcUUID.js.map +1 -1
- package/generated/kurrentdb/protocols/v1/projectionmanagement_pb.d.ts +3 -0
- package/generated/kurrentdb/protocols/v1/projectionmanagement_pb.js +31 -1
- package/generated/kurrentdb/protocols/v2/core_pb.d.ts +188 -188
- package/generated/kurrentdb/protocols/v2/core_pb.js +1301 -1301
- package/generated/kurrentdb/protocols/v2/features/service_grpc_pb.d.ts +43 -43
- package/generated/kurrentdb/protocols/v2/features/service_grpc_pb.js +50 -50
- package/generated/kurrentdb/protocols/v2/features/service_pb.d.ts +227 -227
- package/generated/kurrentdb/protocols/v2/features/service_pb.js +1753 -1753
- package/generated/kurrentdb/protocols/v2/streams/errors_pb.d.ts +85 -0
- package/generated/kurrentdb/protocols/v2/streams/errors_pb.js +625 -1
- package/generated/kurrentdb/protocols/v2/streams/shared_pb.d.ts +218 -218
- package/generated/kurrentdb/protocols/v2/streams/shared_pb.js +1561 -1561
- package/generated/kurrentdb/protocols/v2/streams/streams_grpc_pb.d.ts +17 -0
- package/generated/kurrentdb/protocols/v2/streams/streams_grpc_pb.js +53 -0
- package/generated/kurrentdb/protocols/v2/streams/streams_pb.d.ts +134 -0
- package/generated/kurrentdb/protocols/v2/streams/streams_pb.js +1041 -1
- package/package.json +64 -66
- package/dist/schemaRegistry/checkSchemaCompatibility.d.ts +0 -12
- package/dist/schemaRegistry/checkSchemaCompatibility.js +0 -60
- package/dist/schemaRegistry/checkSchemaCompatibility.js.map +0 -1
- package/dist/schemaRegistry/createSchema.d.ts +0 -13
- package/dist/schemaRegistry/createSchema.js +0 -36
- package/dist/schemaRegistry/createSchema.js.map +0 -1
- package/dist/schemaRegistry/deleteSchema.d.ts +0 -11
- package/dist/schemaRegistry/deleteSchema.js +0 -23
- package/dist/schemaRegistry/deleteSchema.js.map +0 -1
- package/dist/schemaRegistry/deleteSchemaVersions.d.ts +0 -13
- package/dist/schemaRegistry/deleteSchemaVersions.js +0 -29
- package/dist/schemaRegistry/deleteSchemaVersions.js.map +0 -1
- package/dist/schemaRegistry/getSchema.d.ts +0 -12
- package/dist/schemaRegistry/getSchema.js +0 -28
- package/dist/schemaRegistry/getSchema.js.map +0 -1
- package/dist/schemaRegistry/getSchemaVersion.d.ts +0 -12
- package/dist/schemaRegistry/getSchemaVersion.js +0 -33
- package/dist/schemaRegistry/getSchemaVersion.js.map +0 -1
- package/dist/schemaRegistry/getSchemaVersionById.d.ts +0 -12
- package/dist/schemaRegistry/getSchemaVersionById.js +0 -28
- package/dist/schemaRegistry/getSchemaVersionById.js.map +0 -1
- package/dist/schemaRegistry/index.d.ts +0 -14
- package/dist/schemaRegistry/index.js +0 -35
- package/dist/schemaRegistry/index.js.map +0 -1
- package/dist/schemaRegistry/listRegisteredSchemas.d.ts +0 -11
- package/dist/schemaRegistry/listRegisteredSchemas.js +0 -41
- package/dist/schemaRegistry/listRegisteredSchemas.js.map +0 -1
- package/dist/schemaRegistry/listSchemaVersions.d.ts +0 -12
- package/dist/schemaRegistry/listSchemaVersions.js +0 -28
- package/dist/schemaRegistry/listSchemaVersions.js.map +0 -1
- package/dist/schemaRegistry/listSchemas.d.ts +0 -11
- package/dist/schemaRegistry/listSchemas.js +0 -35
- package/dist/schemaRegistry/listSchemas.js.map +0 -1
- package/dist/schemaRegistry/lookupSchemaName.d.ts +0 -12
- package/dist/schemaRegistry/lookupSchemaName.js +0 -23
- package/dist/schemaRegistry/lookupSchemaName.js.map +0 -1
- package/dist/schemaRegistry/registerSchemaVersion.d.ts +0 -13
- package/dist/schemaRegistry/registerSchemaVersion.js +0 -31
- package/dist/schemaRegistry/registerSchemaVersion.js.map +0 -1
- package/dist/schemaRegistry/types.d.ts +0 -347
- package/dist/schemaRegistry/types.js +0 -3
- package/dist/schemaRegistry/types.js.map +0 -1
- package/dist/schemaRegistry/updateSchema.d.ts +0 -11
- package/dist/schemaRegistry/updateSchema.js +0 -51
- package/dist/schemaRegistry/updateSchema.js.map +0 -1
- package/dist/schemaRegistry/utils/index.d.ts +0 -1
- package/dist/schemaRegistry/utils/index.js +0 -18
- package/dist/schemaRegistry/utils/index.js.map +0 -1
- package/dist/schemaRegistry/utils/mappers.d.ts +0 -24
- package/dist/schemaRegistry/utils/mappers.js +0 -198
- package/dist/schemaRegistry/utils/mappers.js.map +0 -1
- package/generated/kurrentdb/protocols/v2/registry/errors_grpc_pb.js +0 -1
- package/generated/kurrentdb/protocols/v2/registry/errors_pb.d.ts +0 -75
- package/generated/kurrentdb/protocols/v2/registry/errors_pb.js +0 -493
- package/generated/kurrentdb/protocols/v2/registry/events_grpc_pb.js +0 -1
- package/generated/kurrentdb/protocols/v2/registry/events_pb.d.ts +0 -255
- package/generated/kurrentdb/protocols/v2/registry/events_pb.js +0 -2057
- package/generated/kurrentdb/protocols/v2/registry/groups_grpc_pb.js +0 -1
- package/generated/kurrentdb/protocols/v2/registry/groups_pb.d.ts +0 -474
- package/generated/kurrentdb/protocols/v2/registry/groups_pb.js +0 -3593
- package/generated/kurrentdb/protocols/v2/registry/schemas_grpc_pb.js +0 -1
- package/generated/kurrentdb/protocols/v2/registry/schemas_pb.d.ts +0 -825
- package/generated/kurrentdb/protocols/v2/registry/schemas_pb.js +0 -6500
- package/generated/kurrentdb/protocols/v2/registry/service_grpc_pb.d.ts +0 -350
- package/generated/kurrentdb/protocols/v2/registry/service_grpc_pb.js +0 -654
- package/generated/kurrentdb/protocols/v2/registry/service_pb.d.ts +0 -10
- package/generated/kurrentdb/protocols/v2/registry/service_pb.js +0 -29
- package/generated/kurrentdb/protocols/v2/registry/shared_grpc_pb.js +0 -1
- package/generated/kurrentdb/protocols/v2/registry/shared_pb.d.ts +0 -26
- package/generated/kurrentdb/protocols/v2/registry/shared_pb.js +0 -51
- package/generated/kurrentdb/protocols/v2/registry/validation_grpc_pb.js +0 -1
- package/generated/kurrentdb/protocols/v2/registry/validation_pb.d.ts +0 -247
- package/generated/kurrentdb/protocols/v2/registry/validation_pb.js +0 -1789
|
@@ -3,7 +3,12 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
const projectionmanagement_grpc_pb_1 = require("../../generated/kurrentdb/protocols/v1/projectionmanagement_grpc_pb");
|
|
4
4
|
const projectionmanagement_pb_1 = require("../../generated/kurrentdb/protocols/v1/projectionmanagement_pb");
|
|
5
5
|
const Client_1 = require("../Client");
|
|
6
|
+
const constants_1 = require("../constants");
|
|
6
7
|
const utils_1 = require("../utils");
|
|
8
|
+
const ENGINE_VERSION_WIRE = {
|
|
9
|
+
[constants_1.PROJECTION_ENGINE_V1]: 1,
|
|
10
|
+
[constants_1.PROJECTION_ENGINE_V2]: 2,
|
|
11
|
+
};
|
|
7
12
|
Client_1.Client.prototype.createProjection = async function (projectionName, query, options = {}) {
|
|
8
13
|
utils_1.debug.command("createProjection: %O", {
|
|
9
14
|
projectionName,
|
|
@@ -16,7 +21,7 @@ Client_1.Client.prototype.createProjection = async function (projectionName, que
|
|
|
16
21
|
}
|
|
17
22
|
return createProjectionGRPC.call(this, projectionName, query, options);
|
|
18
23
|
};
|
|
19
|
-
const createProjectionGRPC = async function (projectionName, query, { emitEnabled = false, trackEmittedStreams = false, ...baseOptions } = {}) {
|
|
24
|
+
const createProjectionGRPC = async function (projectionName, query, { emitEnabled = false, trackEmittedStreams = false, engineVersion = constants_1.PROJECTION_ENGINE_V1, ...baseOptions } = {}) {
|
|
20
25
|
const req = new projectionmanagement_pb_1.CreateReq();
|
|
21
26
|
const options = new projectionmanagement_pb_1.CreateReq.Options();
|
|
22
27
|
const continuous = new projectionmanagement_pb_1.CreateReq.Options.Continuous();
|
|
@@ -25,6 +30,9 @@ const createProjectionGRPC = async function (projectionName, query, { emitEnable
|
|
|
25
30
|
continuous.setTrackEmittedStreams(trackEmittedStreams);
|
|
26
31
|
options.setContinuous(continuous);
|
|
27
32
|
options.setQuery(query);
|
|
33
|
+
if (engineVersion === constants_1.PROJECTION_ENGINE_V2) {
|
|
34
|
+
options.setEngineVersion(ENGINE_VERSION_WIRE[engineVersion]);
|
|
35
|
+
}
|
|
28
36
|
req.setOptions(options);
|
|
29
37
|
utils_1.debug.command_grpc("createProjection: %g", req);
|
|
30
38
|
return this.execute(projectionmanagement_grpc_pb_1.ProjectionsClient, "createProjection", (client) => new Promise((resolve, reject) => {
|
|
@@ -35,13 +43,16 @@ const createProjectionGRPC = async function (projectionName, query, { emitEnable
|
|
|
35
43
|
});
|
|
36
44
|
}));
|
|
37
45
|
};
|
|
38
|
-
const createProjectionHTTP = async function (projectionName, query, { emitEnabled = false, trackEmittedStreams = false, ...baseOptions } = {}) {
|
|
46
|
+
const createProjectionHTTP = async function (projectionName, query, { emitEnabled = false, trackEmittedStreams = false, engineVersion = constants_1.PROJECTION_ENGINE_V1, ...baseOptions } = {}) {
|
|
39
47
|
await this.HTTPRequest("POST", `/projections/continuous`, {
|
|
40
48
|
...baseOptions,
|
|
41
49
|
searchParams: {
|
|
42
50
|
name: projectionName,
|
|
43
51
|
emit: emitEnabled.toString(),
|
|
44
52
|
trackemittedstreams: trackEmittedStreams.toString(),
|
|
53
|
+
...(engineVersion === constants_1.PROJECTION_ENGINE_V2 && {
|
|
54
|
+
engineversion: ENGINE_VERSION_WIRE[engineVersion].toString(),
|
|
55
|
+
}),
|
|
45
56
|
},
|
|
46
57
|
}, query);
|
|
47
58
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"createProjection.js","sourceRoot":"","sources":["../../src/projections/createProjection.ts"],"names":[],"mappings":";;AAAA,sHAG6E;AAC7E,4GAA2F;AAE3F,sCAAmC;
|
|
1
|
+
{"version":3,"file":"createProjection.js","sourceRoot":"","sources":["../../src/projections/createProjection.ts"],"names":[],"mappings":";;AAAA,sHAG6E;AAC7E,4GAA2F;AAE3F,sCAAmC;AACnC,4CAA0E;AAE1E,oCAAwD;AAExD,MAAM,mBAAmB,GAA4C;IACnE,CA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ACJ,CAAC,CAAC"}
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import type { AppendRecordInput, AppendRecordsResult, ConsistencyCheck } from "../../types";
|
|
2
|
+
import type { Client } from "../../Client";
|
|
3
|
+
export declare const appendRecords: (this: Client, records: AppendRecordInput[], checks?: ConsistencyCheck[]) => Promise<AppendRecordsResult>;
|
|
@@ -0,0 +1,132 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
35
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
36
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
37
|
+
};
|
|
38
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
39
|
+
exports.appendRecords = void 0;
|
|
40
|
+
const streams_grpc_pb_1 = __importDefault(require("../../../generated/kurrentdb/protocols/v2/streams/streams_grpc_pb"));
|
|
41
|
+
const streams_pb_1 = __importStar(require("../../../generated/kurrentdb/protocols/v2/streams/streams_pb"));
|
|
42
|
+
const utils_1 = require("../../utils");
|
|
43
|
+
const appendRecords = async function (records, checks) {
|
|
44
|
+
for (const record of records) {
|
|
45
|
+
const { metadata } = record.record;
|
|
46
|
+
if (metadata == null)
|
|
47
|
+
continue;
|
|
48
|
+
if (metadata.constructor === Uint8Array ||
|
|
49
|
+
typeof metadata !== "object" ||
|
|
50
|
+
Array.isArray(metadata) ||
|
|
51
|
+
Object.values(metadata).some((value) => typeof value !== "string")) {
|
|
52
|
+
throw new Error("appendRecords requires metadata to be a plain object with string keys and string values.");
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
return this.execute(streams_grpc_pb_1.default.StreamsServiceClient, "appendRecords", (client) => new Promise((resolve, reject) => {
|
|
56
|
+
const request = new streams_pb_1.default.AppendRecordsRequest();
|
|
57
|
+
for (const record of records) {
|
|
58
|
+
const appendRecord = new streams_pb_1.default.AppendRecord();
|
|
59
|
+
appendRecord.setStream(record.streamName);
|
|
60
|
+
appendRecord.setRecordId(record.record.id);
|
|
61
|
+
const schemaInfo = new streams_pb_1.SchemaInfo();
|
|
62
|
+
schemaInfo.setFormat((0, utils_1.convertToSchemaDataFormat)(record.record.contentType));
|
|
63
|
+
schemaInfo.setName(record.record.type);
|
|
64
|
+
appendRecord.setSchema(schemaInfo);
|
|
65
|
+
if (record.record.metadata) {
|
|
66
|
+
const metadataMap = (0, utils_1.mapToValueMap)(record.record.metadata);
|
|
67
|
+
for (const [key, value] of metadataMap) {
|
|
68
|
+
appendRecord.getPropertiesMap().set(key, value);
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
switch (record.record.contentType) {
|
|
72
|
+
case "application/json": {
|
|
73
|
+
const data = JSON.stringify(record.record.data);
|
|
74
|
+
appendRecord.setData(Buffer.from(data, "utf8").toString("base64"));
|
|
75
|
+
break;
|
|
76
|
+
}
|
|
77
|
+
case "application/octet-stream": {
|
|
78
|
+
appendRecord.setData(record.record.data);
|
|
79
|
+
break;
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
request.addRecords(appendRecord);
|
|
83
|
+
}
|
|
84
|
+
if (checks) {
|
|
85
|
+
for (const check of checks) {
|
|
86
|
+
const consistencyCheck = new streams_pb_1.default.ConsistencyCheck();
|
|
87
|
+
const streamStateCheck = new streams_pb_1.default.ConsistencyCheck.StreamStateCheck();
|
|
88
|
+
streamStateCheck.setStream(check.streamName);
|
|
89
|
+
switch (check.expectedState) {
|
|
90
|
+
case "any": {
|
|
91
|
+
streamStateCheck.setExpectedState((-2).toString(10));
|
|
92
|
+
break;
|
|
93
|
+
}
|
|
94
|
+
case "no_stream": {
|
|
95
|
+
streamStateCheck.setExpectedState((-1).toString(10));
|
|
96
|
+
break;
|
|
97
|
+
}
|
|
98
|
+
case "stream_exists": {
|
|
99
|
+
streamStateCheck.setExpectedState((-4).toString(10));
|
|
100
|
+
break;
|
|
101
|
+
}
|
|
102
|
+
default: {
|
|
103
|
+
streamStateCheck.setExpectedState(check.expectedState.toString(10));
|
|
104
|
+
break;
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
consistencyCheck.setStreamState(streamStateCheck);
|
|
108
|
+
request.addChecks(consistencyCheck);
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
client.appendRecords(request, ...this.callArguments({
|
|
112
|
+
requiresLeader: false,
|
|
113
|
+
}), (error, response) => {
|
|
114
|
+
if (error != null) {
|
|
115
|
+
return reject((0, utils_1.convertToCommandError)(error));
|
|
116
|
+
}
|
|
117
|
+
const successes = [];
|
|
118
|
+
for (const revision of response.getRevisionsList()) {
|
|
119
|
+
successes.push({
|
|
120
|
+
streamName: revision.getStream(),
|
|
121
|
+
revision: BigInt(revision.getRevision()),
|
|
122
|
+
});
|
|
123
|
+
}
|
|
124
|
+
return resolve({
|
|
125
|
+
position: BigInt(response.getPosition()),
|
|
126
|
+
responses: successes,
|
|
127
|
+
});
|
|
128
|
+
});
|
|
129
|
+
}));
|
|
130
|
+
};
|
|
131
|
+
exports.appendRecords = appendRecords;
|
|
132
|
+
//# sourceMappingURL=appendRecords.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"appendRecords.js","sourceRoot":"","sources":["../../../src/streams/appendToStream/appendRecords.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAOA,wHAAqF;AACrF,2GAEsE;AACtE,uCAIqB;AAEd,MAAM,aAAa,GAAG,KAAK,WAEhC,OAA4B,EAC5B,MAA2B;IAE3B,KAAK,MAAM,MAAM,IAAI,OAAO,EAAE,CAAC;QAC7B,MAAM,EAAE,QAAQ,EAAE,GAAG,MAAM,CAAC,MAAM,CAAC;QACnC,IAAI,QAAQ,IAAI,IAAI;YAAE,SAAS;QAC/B,IACE,QAAQ,CAAC,WAAW,KAAK,UAAU;YACnC,OAAO,QAAQ,KAAK,QAAQ;YAC5B,KAAK,CAAC,OAAO,CAAC,QAAQ,CAAC;YACvB,MAAM,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC,IAAI,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,OAAO,KAAK,KAAK,QAAQ,CAAC,EAClE,CAAC;YACD,MAAM,IAAI,KAAK,CACb,0FAA0F,CAC3F,CAAC;QACJ,CAAC;IACH,CAAC;IAED,OAAO,IAAI,CAAC,O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gBAAgB,CAC/B,KAAK,CAAC,aAAa,CAAC,QAAQ,CAAC,EAAE,CAAC,CACjC,CAAC;wBACF,MAAM;oBACR,CAAC;gBACH,CAAC;gBAED,gBAAgB,CAAC,cAAc,CAAC,gBAAgB,CAAC,CAAC;gBAClD,OAAO,CAAC,SAAS,CAAC,gBAAgB,CAAC,CAAC;YACtC,CAAC;QACH,CAAC;QAED,MAAM,CAAC,aAAa,CAClB,OAAO,EACP,GAAG,IAAI,CAAC,aAAa,CAAC;YACpB,cAAc,EAAE,KAAK;SACtB,CAAC,EACF,CAAC,KAAK,EAAE,QAAQ,EAAE,EAAE;YAClB,IAAI,KAAK,IAAI,IAAI,EAAE,CAAC;gBAClB,OAAO,MAAM,CAAC,IAAA,6BAAqB,EAAC,KAAK,CAAC,CAAC,CAAC;YAC9C,CAAC;YAED,MAAM,SAAS,GAAqB,EAAE,CAAC;YACvC,KAAK,MAAM,QAAQ,IAAI,QAAQ,CAAC,gBAAgB,EAAE,EAAE,CAAC;gBACnD,SAAS,CAAC,IAAI,CAAC;oBACb,UAAU,EAAE,QAAQ,CAAC,SAAS,EAAE;oBAChC,QAAQ,EAAE,MAAM,CAAC,QAAQ,CAAC,WAAW,EAAE,CAAC;iBACzC,CAAC,CAAC;YACL,CAAC;YAED,OAAO,OAAO,CAAC;gBACb,QAAQ,EAAE,MAAM,CAAC,QAAQ,CAAC,WAAW,EAAE,CAAC;gBACxC,SAAS,EAAE,SAAS;aACrB,CAAC,CAAC;QACL,CAAC,CACF,CAAC;IACJ,CAAC,CAAC,CACL,CAAC;AACJ,CAAC,CAAC;AA7HW,QAAA,aAAa,iBA6HxB"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.batchAppend = void 0;
|
|
4
|
-
const
|
|
4
|
+
const crypto_1 = require("crypto");
|
|
5
5
|
const timestamp_pb_1 = require("google-protobuf/google/protobuf/timestamp_pb");
|
|
6
6
|
const streams_grpc_pb_1 = require("../../../generated/kurrentdb/protocols/v1/streams_grpc_pb");
|
|
7
7
|
const streams_pb_1 = require("../../../generated/kurrentdb/protocols/v1/streams_pb");
|
|
@@ -11,7 +11,7 @@ const unpackError_1 = require("./unpackError");
|
|
|
11
11
|
const streamCache = new WeakMap();
|
|
12
12
|
const promiseBank = new Map();
|
|
13
13
|
const batchAppend = async function (streamName, events, { streamState, batchAppendSize, ...baseOptions }) {
|
|
14
|
-
const correlationId = (0,
|
|
14
|
+
const correlationId = (0, crypto_1.randomUUID)();
|
|
15
15
|
const stream = await this.GRPCStreamCreator(streams_grpc_pb_1.StreamsClient, "appendToStream", (client) => client
|
|
16
16
|
.batchAppend(...this.callArguments(baseOptions, {
|
|
17
17
|
deadline: Infinity,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"batchAppend.js","sourceRoot":"","sources":["../../../src/streams/appendToStream/batchAppend.ts"],"names":[],"mappings":";;;AAAA
|
|
1
|
+
{"version":3,"file":"batchAppend.js","sourceRoot":"","sources":["../../../src/streams/appendToStream/batchAppend.ts"],"names":[],"mappings":";;;AAAA,mCAAoC;AACpC,+EAAyE;AAEzE,+FAA0F;AAC1F,qFAG8D;AAC9D,mFAG6D;AAI7D,uCAQqB;AAErB,+CAGuB;AAIvB,MAAM,WAAW,GAAG,IAAI,OAAO,EAG5B,CAAC;AAEJ,MAAM,WAAW,GAAG,IAAI,GAAG,EAGxB,CAAC;AAEG,MAAM,WAAW,GAAG,KAAK,WAE9B,UAAkB,EAClB,MAAmB,EACnB,EACE,WAAW,EACX,eAAe,EACf,GAAG,WAAW,EACyB;IAEzC,MAAM,aAAa,GAAG,IAAA,mBAAU,GAAE,CAAC;IAEnC,MAAM,MAAM,GAAG,MAAM,IAAI,CAAC,iBAAiB,CACzC,+BAAa,EACb,gBAAgB,EAChB,CAAC,MAAM,EAAE,EAAE,CACT,MAAM;SACH,WAAW,CACV,GAAG,IAAI,CAAC,aAAa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,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAC;gBAChD,OAAO,CAAC,iBAAiB,CACvB,MAAM,CAAC,IAAI,CAAC,QAAQ,EAAE,MAAM,CAAC,CAAC,QAAQ,CAAC,QAAQ,CAAC,CACjD,CAAC;YACJ,CAAC;QACH,CAAC;QAED,MAAM,WAAW,GAAG,OAAO,CAAC,eAAe,EAAE,CAAC,MAAM,CAAC;QAErD,IAAI,SAAS,GAAG,WAAW,IAAI,YAAY,EAAE,CAAC;YAC5C,MAAM,aAAa,CAAC;YACpB,aAAa,GAAG,mBAAmB,CAAC,KAAK,CAAC,CAAC;YAC3C,SAAS,GAAG,CAAC,CAAC;QAChB,CAAC;QAED,SAAS,IAAI,WAAW,CAAC;QACzB,aAAa,CAAC,mBAAmB,CAAC,OAAO,CAAC,CAAC;IAC7C,CAAC;IAED,aAAa,CAAC,UAAU,CAAC,IAAI,CAAC,CAAC;IAE/B,MAAM,aAAa,CAAC;AACtB,CAAC"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { BaseOptions, AppendResult, AppendStreamState, EventData, EventType, MultiAppendResult, AppendStreamRequest } from "../../types";
|
|
1
|
+
import type { BaseOptions, AppendResult, AppendStreamState, EventData, EventType, MultiAppendResult, AppendStreamRequest, AppendRecordInput, AppendRecordsResult, ConsistencyCheck } from "../../types";
|
|
2
2
|
export interface AppendToStreamOptions extends BaseOptions {
|
|
3
3
|
/**
|
|
4
4
|
* Asks the server to check the stream is at specific revision before writing events.
|
|
@@ -21,5 +21,13 @@ declare module "../../Client" {
|
|
|
21
21
|
*/
|
|
22
22
|
appendToStream<KnownEventType extends EventType = EventType>(streamName: string, events: EventData<KnownEventType> | EventData<KnownEventType>[], options?: AppendToStreamOptions): Promise<AppendResult>;
|
|
23
23
|
multiStreamAppend<KnownEventType extends EventType = EventType>(requests: AppendStreamRequest<KnownEventType>[]): Promise<MultiAppendResult>;
|
|
24
|
+
/**
|
|
25
|
+
* Appends records to one or more streams atomically with cross-stream consistency checks.
|
|
26
|
+
* Records can be interleaved across streams in any order and the global log preserves
|
|
27
|
+
* the exact sequence from the request.
|
|
28
|
+
* @param records - The records to append. Each record specifies its target stream.
|
|
29
|
+
* @param checks - Optional consistency checks evaluated before commit.
|
|
30
|
+
*/
|
|
31
|
+
appendRecords<KnownEventType extends EventType = EventType>(records: AppendRecordInput<KnownEventType>[], checks?: ConsistencyCheck[]): Promise<AppendRecordsResult>;
|
|
24
32
|
}
|
|
25
33
|
}
|
|
@@ -8,9 +8,11 @@ const utils_1 = require("../../utils");
|
|
|
8
8
|
const append_1 = require("./append");
|
|
9
9
|
const batchAppend_1 = require("./batchAppend");
|
|
10
10
|
const multiStreamAppend_1 = require("./multiStreamAppend");
|
|
11
|
+
const appendRecords_1 = require("./appendRecords");
|
|
11
12
|
Client_1.Client.prototype.appendToStream = async function (streamName, event, { streamState = constants_1.ANY, batchAppendSize = 3 * 1024 * 1024, ...baseOptions } = {}) {
|
|
12
13
|
const events = Array.isArray(event) ? event : [event];
|
|
13
14
|
if (!baseOptions.credentials &&
|
|
15
|
+
!this.credentialsProvider &&
|
|
14
16
|
(await this.supports(streams_grpc_pb_1.StreamsService.batchAppend))) {
|
|
15
17
|
return batchAppend_1.batchAppend.call(this, streamName, events, {
|
|
16
18
|
streamState: streamState,
|
|
@@ -30,4 +32,10 @@ Client_1.Client.prototype.multiStreamAppend = async function (requests) {
|
|
|
30
32
|
}
|
|
31
33
|
return multiStreamAppend_1.multiStreamAppend.call(this, requests);
|
|
32
34
|
};
|
|
35
|
+
Client_1.Client.prototype.appendRecords = async function (records, checks) {
|
|
36
|
+
if (!(await this.supports(streams_grpc_pb_2.StreamsServiceService.appendRecords))) {
|
|
37
|
+
throw new utils_1.UnsupportedError("appendRecords", "26.1");
|
|
38
|
+
}
|
|
39
|
+
return appendRecords_1.appendRecords.call(this, records, checks);
|
|
40
|
+
};
|
|
33
41
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/streams/appendToStream/index.ts"],"names":[],"mappings":";;AAAA,+FAA2F;AAC3F,uGAA0G;AAC1G,yCAAsC;AACtC,+CAAsC;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/streams/appendToStream/index.ts"],"names":[],"mappings":";;AAAA,+FAA2F;AAC3F,uGAA0G;AAC1G,yCAAsC;AACtC,+CAAsC;AAatC,uCAA+C;AAE/C,qCAAkC;AAClC,+CAA4C;AAC5C,2DAAwD;AACxD,mDAAgD;AA+ChD,eAAM,CAAC,SAAS,CAAC,cAAc,GAAG,KAAK,WAIrC,UAAkB,EAClB,KAA8D,EAC9D,EACE,WAAW,GAAG,eAAG,EACjB,eAAe,GAAG,CAAC,GAAG,IAAI,GAAG,IAAI,EACjC,GAAG,WAAW,KACW,EAAE;IAE7B,MAAM,MAAM,GAAG,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC;IAEtD,IACE,CAAC,WAAW,CAAC,WAAW;QACxB,CAAC,IAAI,CAAC,mBAAmB;QACzB,CAAC,MAAM,IAAI,CAAC,QAAQ,CAAC,gCAAc,CAAC,WAAW,CAAC,CAAC,EACjD,CAAC;QACD,OAAO,yBAAW,CAAC,IAAI,CAAC,IAAI,EAAE,UAAU,EAAE,MAAM,EAAE;YAChD,WAAW,EAAE,WAAW;YACxB,eAAe;YACf,GAAG,WAAW;SACf,CAAC,CAAC;IACL,CAAC;IAED,OAAO,eAAM,CAAC,IAAI,CAAC,IAAI,EAAE,UAAU,EAAE,MAAM,EAAE;QAC3C,WAAW,EAAE,WAAW;QACxB,eAAe;QACf,GAAG,WAAW;KACf,CAAC,CAAC;AACL,CAAC,CAAC;AAEF,eAAM,CAAC,SAAS,CAAC,iBAAiB,GAAG,KAAK,WAExC,QAA+B;IAE/B,IAAI,CAAC,CAAC,MAAM,IAAI,CAAC,QAAQ,CAAC,uCAAqB,CAAC,aAAa,CAAC,CAAC,EAAE,CAAC;QAChE,MAAM,IAAI,wBAAgB,CAAC,mBAAmB,EAAE,MAAM,CAAC,CAAC;IAC1D,CAAC;IACD,OAAO,qCAAiB,CAAC,IAAI,CAAC,IAAI,EAAE,QAAQ,CAAC,CAAC;AAChD,CAAC,CAAC;AAEF,eAAM,CAAC,SAAS,CAAC,aAAa,GAAG,KAAK,WAEpC,OAA4B,EAC5B,MAA2B;IAE3B,IAAI,CAAC,CAAC,MAAM,IAAI,CAAC,QAAQ,CAAC,uCAAqB,CAAC,aAAa,CAAC,CAAC,EAAE,CAAC;QAChE,MAAM,IAAI,wBAAgB,CAAC,eAAe,EAAE,MAAM,CAAC,CAAC;IACtD,CAAC;IACD,OAAO,6BAAa,CAAC,IAAI,CAAC,IAAI,EAAE,OAAO,EAAE,MAAM,CAAC,CAAC;AACnD,CAAC,CAAC"}
|
package/dist/streams/readAll.js
CHANGED
|
@@ -5,23 +5,23 @@ const Client_1 = require("../Client");
|
|
|
5
5
|
const convertRustEvent_1 = require("../utils/convertRustEvent");
|
|
6
6
|
const convertBridgeError_1 = require("../utils/convertBridgeError");
|
|
7
7
|
Client_1.Client.prototype.readAll = function ({ maxCount = Number.MAX_SAFE_INTEGER, fromPosition = constants_1.START, resolveLinkTos = false, direction = constants_1.FORWARDS, ...baseOptions } = {}) {
|
|
8
|
-
const
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
8
|
+
const convert = async function* () {
|
|
9
|
+
const credentials = await this.resolveBridgeCredentials(baseOptions.credentials);
|
|
10
|
+
let stream;
|
|
11
|
+
try {
|
|
12
|
+
stream = this.rustClient.readAll({
|
|
13
|
+
credentials,
|
|
14
|
+
direction,
|
|
15
|
+
fromPosition,
|
|
16
|
+
filter: baseOptions.filter,
|
|
17
|
+
maxCount: BigInt(maxCount),
|
|
18
|
+
requiresLeader: baseOptions.requiresLeader ?? false,
|
|
19
|
+
resolvesLink: resolveLinkTos,
|
|
20
|
+
});
|
|
21
|
+
}
|
|
22
|
+
catch (error) {
|
|
23
|
+
throw (0, convertBridgeError_1.convertBridgeError)(error);
|
|
24
|
+
}
|
|
25
25
|
try {
|
|
26
26
|
for await (const events of stream) {
|
|
27
27
|
for (const event of events) {
|
|
@@ -33,6 +33,6 @@ Client_1.Client.prototype.readAll = function ({ maxCount = Number.MAX_SAFE_INTEG
|
|
|
33
33
|
throw (0, convertBridgeError_1.convertBridgeError)(error);
|
|
34
34
|
}
|
|
35
35
|
};
|
|
36
|
-
return convert(
|
|
36
|
+
return convert.call(this);
|
|
37
37
|
};
|
|
38
38
|
//# sourceMappingURL=readAll.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"readAll.js","sourceRoot":"","sources":["../../src/streams/readAll.ts"],"names":[],"mappings":";;AAOA,4CAA+C;AAC/C,sCAAmC;
|
|
1
|
+
{"version":3,"file":"readAll.js","sourceRoot":"","sources":["../../src/streams/readAll.ts"],"names":[],"mappings":";;AAOA,4CAA+C;AAC/C,sCAAmC;AAEnC,gEAA6D;AAC7D,oEAAiE;AA4CjE,eAAM,CAAC,SAAS,CAAC,OAAO,GAAG,UAEzB,EACE,QAAQ,GAAG,MAAM,CAAC,gBAAgB,EAClC,YAAY,GAAG,iBAAK,EACpB,cAAc,GAAG,KAAK,EACtB,SAAS,GAAG,oBAAQ,EACpB,GAAG,WAAW,KACI,EAAE;IAEtB,MAAM,OAAO,GAAG,KAAK,SAAS,CAAC;QAG7B,MAAM,WAAW,GAAG,MAAM,IAAI,CAAC,wBAAwB,CACrD,WAAW,CAAC,WAAW,CACxB,CAAC;QAEF,IAAI,MAAM,CAAC;QACX,IAAI,CAAC;YACH,MAAM,GAAG,IAAI,CAAC,UAAU,CAAC,OAAO,CAAC;gBAC/B,WAAW;gBACX,SAAS;gBACT,YAAY;gBACZ,MAAM,EAAE,WAAW,CAAC,MAAM;gBAC1B,QAAQ,EAAE,MAAM,CAAC,QAAQ,CAAC;gBAC1B,cAAc,EAAE,WAAW,CAAC,cAAc,IAAI,KAAK;gBACnD,YAAY,EAAE,cAAc;aAC7B,CAAC,CAAC;QACL,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,MAAM,IAAA,uCAAkB,EAAC,KAAK,CAAC,CAAC;QAClC,CAAC;QAED,IAAI,CAAC;YACH,IAAI,KAAK,EAAE,MAAM,MAAM,IAAI,MAAM,EAAE,CAAC;gBAClC,KAAK,MAAM,KAAK,IAAI,MAAM,EAAE,CAAC;oBAC3B,MAAM,IAAA,mCAAgB,EAAyB,KAAK,CAAC,CAAC;gBACxD,CAAC;YACH,CAAC;QACH,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,MAAM,IAAA,uCAAkB,EAAC,KAAK,CAAC,CAAC;QAClC,CAAC;IACH,CAAC,CAAC;IAEF,OAAO,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;AAC5B,CAAC,CAAC"}
|
|
@@ -6,42 +6,34 @@ const utils_1 = require("../utils");
|
|
|
6
6
|
const convertRustEvent_1 = require("../utils/convertRustEvent");
|
|
7
7
|
const convertBridgeError_1 = require("../utils/convertBridgeError");
|
|
8
8
|
Client_1.Client.prototype.readStream = function (streamName, { maxCount = Number.MAX_SAFE_INTEGER, fromRevision = constants_1.START, resolveLinkTos = false, direction = constants_1.FORWARDS, ...baseOptions } = {}) {
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
fromRevision
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
};
|
|
17
|
-
switch (fromRevision) {
|
|
18
|
-
case constants_1.START: {
|
|
19
|
-
break;
|
|
20
|
-
}
|
|
21
|
-
case constants_1.END: {
|
|
22
|
-
break;
|
|
9
|
+
if (fromRevision !== constants_1.START &&
|
|
10
|
+
fromRevision !== constants_1.END &&
|
|
11
|
+
typeof fromRevision === "bigint") {
|
|
12
|
+
const lowerBound = BigInt("0");
|
|
13
|
+
const upperBound = BigInt("0xffffffffffffffff");
|
|
14
|
+
if (fromRevision < lowerBound) {
|
|
15
|
+
throw new utils_1.InvalidArgumentError(`fromRevision value must be a non-negative integer. Value Received: ${fromRevision}`);
|
|
23
16
|
}
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
const upperBound = BigInt("0xffffffffffffffff");
|
|
27
|
-
if (fromRevision < lowerBound) {
|
|
28
|
-
throw new utils_1.InvalidArgumentError(`fromRevision value must be a non-negative integer. Value Received: ${fromRevision}`);
|
|
29
|
-
}
|
|
30
|
-
if (fromRevision > upperBound) {
|
|
31
|
-
throw new utils_1.InvalidArgumentError(`fromRevision value must be a non-negative integer, range from 0 to 18446744073709551615. Value Received: ${fromRevision}`);
|
|
32
|
-
}
|
|
33
|
-
options.fromRevision = fromRevision;
|
|
34
|
-
break;
|
|
17
|
+
if (fromRevision > upperBound) {
|
|
18
|
+
throw new utils_1.InvalidArgumentError(`fromRevision value must be a non-negative integer, range from 0 to 18446744073709551615. Value Received: ${fromRevision}`);
|
|
35
19
|
}
|
|
36
20
|
}
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
stream
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
21
|
+
const convert = async function* () {
|
|
22
|
+
const credentials = await this.resolveBridgeCredentials(baseOptions.credentials);
|
|
23
|
+
let stream;
|
|
24
|
+
try {
|
|
25
|
+
stream = this.rustClient.readStream(streamName, {
|
|
26
|
+
credentials,
|
|
27
|
+
direction,
|
|
28
|
+
fromRevision,
|
|
29
|
+
maxCount: BigInt(maxCount),
|
|
30
|
+
requiresLeader: baseOptions.requiresLeader ?? false,
|
|
31
|
+
resolvesLink: resolveLinkTos,
|
|
32
|
+
});
|
|
33
|
+
}
|
|
34
|
+
catch (error) {
|
|
35
|
+
throw (0, convertBridgeError_1.convertBridgeError)(error, streamName);
|
|
36
|
+
}
|
|
45
37
|
try {
|
|
46
38
|
for await (const events of stream) {
|
|
47
39
|
for (const event of events) {
|
|
@@ -53,6 +45,6 @@ Client_1.Client.prototype.readStream = function (streamName, { maxCount = Number
|
|
|
53
45
|
throw (0, convertBridgeError_1.convertBridgeError)(error, streamName);
|
|
54
46
|
}
|
|
55
47
|
};
|
|
56
|
-
return convert(
|
|
48
|
+
return convert.call(this);
|
|
57
49
|
};
|
|
58
50
|
//# sourceMappingURL=readStream.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"readStream.js","sourceRoot":"","sources":["../../src/streams/readStream.ts"],"names":[],"mappings":";;
|
|
1
|
+
{"version":3,"file":"readStream.js","sourceRoot":"","sources":["../../src/streams/readStream.ts"],"names":[],"mappings":";;AAAA,sCAAmC;AACnC,4CAAoD;AAQpD,oCAAgD;AAChD,gEAA6D;AAC7D,oEAAiE;AAyCjE,eAAM,CAAC,SAAS,CAAC,UAAU,GAAG,UAI5B,UAAkB,EAClB,EACE,QAAQ,GAAG,MAAM,CAAC,gBAAgB,EAClC,YAAY,GAAG,iBAAK,EACpB,cAAc,GAAG,KAAK,EACtB,SAAS,GAAG,oBAAQ,EACpB,GAAG,WAAW,KACO,EAAE;IAEzB,IACE,YAAY,KAAK,iBAAK;QACtB,YAAY,KAAK,eAAG;QACpB,OAAO,YAAY,KAAK,QAAQ,EAChC,CAAC;QACD,MAAM,UAAU,GAAG,MAAM,CAAC,GAAG,CAAC,CAAC;QAC/B,MAAM,UAAU,GAAG,MAAM,CAAC,oBAAoB,CAAC,CAAC;QAEhD,IAAI,YAAY,GAAG,UAAU,EAAE,CAAC;YAC9B,MAAM,IAAI,4BAAoB,CAC5B,sEAAsE,YAAY,EAAE,CACrF,CAAC;QACJ,CAAC;QAED,IAAI,YAAY,GAAG,UAAU,EAAE,CAAC;YAC9B,MAAM,IAAI,4BAAoB,CAC5B,4GAA4G,YAAY,EAAE,CAC3H,CAAC;QACJ,CAAC;IACH,CAAC;IAED,MAAM,OAAO,GAAG,KAAK,SAAS,CAAC;QAG7B,MAAM,WAAW,GAAG,MAAM,IAAI,CAAC,wBAAwB,CACrD,WAAW,CAAC,WAAW,CACxB,CAAC;QAEF,IAAI,MAAM,CAAC;QACX,IAAI,CAAC;YACH,MAAM,GAAG,IAAI,CAAC,UAAU,CAAC,UAAU,CAAC,UAAU,EAAE;gBAC9C,WAAW;gBACX,SAAS;gBACT,YAAY;gBACZ,QAAQ,EAAE,MAAM,CAAC,QAAQ,CAAC;gBAC1B,cAAc,EAAE,WAAW,CAAC,cAAc,IAAI,KAAK;gBACnD,YAAY,EAAE,cAAc;aAC7B,CAAC,CAAC;QACL,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,MAAM,IAAA,uCAAkB,EAAC,KAAK,EAAE,UAAU,CAAC,CAAC;QAC9C,CAAC;QAED,IAAI,CAAC;YACH,IAAI,KAAK,EAAE,MAAM,MAAM,IAAI,MAAM,EAAE,CAAC;gBAClC,KAAK,MAAM,KAAK,IAAI,MAAM,EAAE,CAAC;oBAC3B,MAAM,IAAA,mCAAgB,EAAC,KAAK,CAAC,CAAC;gBAChC,CAAC;YACH,CAAC;QACH,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,MAAM,IAAA,uCAAkB,EAAC,KAAK,EAAE,UAAU,CAAC,CAAC;QAC9C,CAAC;IACH,CAAC,CAAC;IAEF,OAAO,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;AAC5B,CAAC,CAAC"}
|
package/dist/types/index.d.ts
CHANGED
|
@@ -6,7 +6,8 @@ import type { ResolvedEvent, AllStreamResolvedEvent, EventType, PersistentSubscr
|
|
|
6
6
|
import type * as constants from "../constants";
|
|
7
7
|
export interface BaseOptions {
|
|
8
8
|
/**
|
|
9
|
-
* Overwrite the default credentials.
|
|
9
|
+
* Overwrite the default credentials. Accepts either basic
|
|
10
|
+
* username/password credentials or a bearer token.
|
|
10
11
|
*/
|
|
11
12
|
credentials?: Credentials;
|
|
12
13
|
/**
|
|
@@ -174,6 +175,7 @@ export interface DeleteResult {
|
|
|
174
175
|
export type ConsumerStrategy = typeof constants.DISPATCH_TO_SINGLE | typeof constants.ROUND_ROBIN | typeof constants.PINNED | typeof constants.PINNED_BY_CORRELATION;
|
|
175
176
|
export type PersistentAction = typeof constants.PARK | typeof constants.RETRY | typeof constants.SKIP | typeof constants.STOP;
|
|
176
177
|
export type NodePreference = typeof constants.RANDOM | typeof constants.FOLLOWER | typeof constants.LEADER | typeof constants.READ_ONLY_REPLICA;
|
|
178
|
+
export type ProjectionEngineVersion = typeof constants.PROJECTION_ENGINE_V1 | typeof constants.PROJECTION_ENGINE_V2;
|
|
177
179
|
export interface EndPoint {
|
|
178
180
|
address: string;
|
|
179
181
|
port: number;
|
|
@@ -222,10 +224,34 @@ export interface PrefixesFilter extends FilterBase {
|
|
|
222
224
|
prefixes: string[];
|
|
223
225
|
}
|
|
224
226
|
export type Filter = RegexFilter | PrefixesFilter;
|
|
225
|
-
|
|
227
|
+
/**
|
|
228
|
+
* Username/password credentials used to authenticate against KurrentDB,
|
|
229
|
+
* rendered as an HTTP Basic `Authorization` header.
|
|
230
|
+
*/
|
|
231
|
+
export interface BasicCredentials {
|
|
226
232
|
username: string;
|
|
227
233
|
password: string;
|
|
228
234
|
}
|
|
235
|
+
/**
|
|
236
|
+
* Bearer-token credentials used to authenticate against KurrentDB, rendered
|
|
237
|
+
* as an HTTP Bearer `Authorization` header. Bearer tokens are
|
|
238
|
+
* programmatic-only and cannot be supplied via a connection string.
|
|
239
|
+
*/
|
|
240
|
+
export interface BearerCredentials {
|
|
241
|
+
bearerToken: string;
|
|
242
|
+
}
|
|
243
|
+
/**
|
|
244
|
+
* Credential shape accepted by the client. Either basic username/password
|
|
245
|
+
* or a bearer token.
|
|
246
|
+
*/
|
|
247
|
+
export type Credentials = BasicCredentials | BearerCredentials;
|
|
248
|
+
/**
|
|
249
|
+
* Callback invoked before every RPC to obtain fresh credentials. Use this for
|
|
250
|
+
* refresh-aware token sources such as Azure Entra or OIDC. The provider runs
|
|
251
|
+
* once per outbound request, so consumers can return a cached token until
|
|
252
|
+
* expiry and rotate transparently.
|
|
253
|
+
*/
|
|
254
|
+
export type CredentialsProvider = () => Credentials | Promise<Credentials>;
|
|
229
255
|
export interface Certificate {
|
|
230
256
|
userCertFile: Buffer;
|
|
231
257
|
userKeyFile: Buffer;
|
|
@@ -399,6 +425,66 @@ export type MultiAppendResult = {
|
|
|
399
425
|
position: bigint;
|
|
400
426
|
responses: AppendResponse[];
|
|
401
427
|
};
|
|
428
|
+
/**
|
|
429
|
+
* Represents a record to be appended in an {@link Client.appendRecords} operation.
|
|
430
|
+
* Each record specifies its own target stream, allowing interleaved writes across multiple streams.
|
|
431
|
+
*/
|
|
432
|
+
export interface AppendRecordInput<KnownEventType extends EventType = EventType> {
|
|
433
|
+
/**
|
|
434
|
+
* The name of the target stream for this record.
|
|
435
|
+
*/
|
|
436
|
+
streamName: string;
|
|
437
|
+
/**
|
|
438
|
+
* The record data to append.
|
|
439
|
+
*/
|
|
440
|
+
record: EventData<KnownEventType>;
|
|
441
|
+
}
|
|
442
|
+
/**
|
|
443
|
+
* Represents a consistency check to be evaluated before committing an {@link Client.appendRecords} operation.
|
|
444
|
+
* Checks are decoupled from writes: a check can reference any stream, whether or not the request writes to it.
|
|
445
|
+
*/
|
|
446
|
+
export type ConsistencyCheck = StreamStateCheck;
|
|
447
|
+
/**
|
|
448
|
+
* A check that asserts a stream is at a specific revision or lifecycle state before commit.
|
|
449
|
+
*/
|
|
450
|
+
export interface StreamStateCheck {
|
|
451
|
+
type: typeof constants.STREAM_STATE;
|
|
452
|
+
/**
|
|
453
|
+
* The stream name to check.
|
|
454
|
+
*/
|
|
455
|
+
streamName: string;
|
|
456
|
+
/**
|
|
457
|
+
* The expected state of the stream (revision number or state constant).
|
|
458
|
+
*/
|
|
459
|
+
expectedState: AppendStreamState;
|
|
460
|
+
}
|
|
461
|
+
/**
|
|
462
|
+
* Details of a single consistency check violation.
|
|
463
|
+
*/
|
|
464
|
+
export interface ConsistencyViolation {
|
|
465
|
+
/**
|
|
466
|
+
* Index of the check in the original checks list.
|
|
467
|
+
*/
|
|
468
|
+
checkIndex: number;
|
|
469
|
+
/**
|
|
470
|
+
* The stream whose state was checked.
|
|
471
|
+
*/
|
|
472
|
+
streamName: string;
|
|
473
|
+
/**
|
|
474
|
+
* The expected state of the stream.
|
|
475
|
+
*/
|
|
476
|
+
expectedState: AppendStreamState;
|
|
477
|
+
/**
|
|
478
|
+
* The actual state of the stream at the time the check was evaluated.
|
|
479
|
+
* Specific revision (bigint >= 0), or "no_stream" if the stream doesn't exist.
|
|
480
|
+
* Deleted streams return -5n and tombstoned streams return -6n.
|
|
481
|
+
*/
|
|
482
|
+
actualState: CurrentStreamState;
|
|
483
|
+
}
|
|
484
|
+
/**
|
|
485
|
+
* Result of a successful {@link Client.appendRecords} operation.
|
|
486
|
+
*/
|
|
487
|
+
export type AppendRecordsResult = MultiAppendResult;
|
|
402
488
|
export interface CatchupSubscription {
|
|
403
489
|
addListener(event: "caughtUp", listener: (info: CaughtUp) => void): this;
|
|
404
490
|
addListener(event: "fellBehind", listener: (info: FellBehind) => void): this;
|
package/dist/types/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/types/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;AAOA,gFAAgG;AAChG,IAAO,UAAU,GAAG,sBAAc,CAAC,UAAU,CAAC;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/types/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;AAOA,gFAAgG;AAChG,IAAO,UAAU,GAAG,sBAAc,CAAC,UAAU,CAAC;AAksBrC,gCAAU;AAzHN,QAAA,mBAAmB,GAAuB;IACrD,IAAI,EAAE,SAAS;CACP,CAAC;AAwHX,2CAAyB"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { status as StatusCode, ServiceError } from "@grpc/grpc-js";
|
|
2
2
|
import { WrongExpectedVersion } from "../../generated/kurrentdb/protocols/v1/shared_pb";
|
|
3
|
-
import type { CurrentStreamState, EndPoint, AppendStreamState } from "../types";
|
|
4
|
-
import { AppendTransactionSizeExceededErrorDetails, StreamRevisionConflictErrorDetails, StreamTombstonedErrorDetails, AppendRecordSizeExceededErrorDetails } from "../../generated/kurrentdb/protocols/v2/streams/errors_pb";
|
|
3
|
+
import type { CurrentStreamState, EndPoint, AppendStreamState, ConsistencyViolation } from "../types";
|
|
4
|
+
import { AppendTransactionSizeExceededErrorDetails, StreamRevisionConflictErrorDetails, StreamTombstonedErrorDetails, AppendRecordSizeExceededErrorDetails, AppendConsistencyViolationErrorDetails } from "../../generated/kurrentdb/protocols/v2/streams/errors_pb";
|
|
5
5
|
export declare enum ErrorType {
|
|
6
6
|
TIMEOUT = "timeout",
|
|
7
7
|
DEADLINE_EXCEEDED = "deadline-exceeded",
|
|
@@ -22,6 +22,7 @@ export declare enum ErrorType {
|
|
|
22
22
|
MAXIMUM_APPEND_SIZE_EXCEEDED = "maximum-append-size-exceeded",
|
|
23
23
|
TRANSACTION_MAX_SIZE_EXCEEDED = "transaction-max-size-exceeded",
|
|
24
24
|
APPEND_RECORD_SIZE_EXCEEDED = "append-record-size-exceeded",
|
|
25
|
+
APPEND_CONSISTENCY_VIOLATION = "append-consistency-violation",
|
|
25
26
|
MISSING_REQUIRED_METADATA_PROPERTY = "missing-required-metadata-property",
|
|
26
27
|
PERSISTENT_SUBSCRIPTION_FAILED = "persistent-subscription-failed",
|
|
27
28
|
PERSISTENT_SUBSCRIPTION_DOES_NOT_EXIST = "persistent-subscription-does-not-exist",
|
|
@@ -130,6 +131,11 @@ export declare class TransactionMaxSizeExceededError extends CommandErrorBase {
|
|
|
130
131
|
maxSize: number;
|
|
131
132
|
constructor(error: ServiceError, details: AppendTransactionSizeExceededErrorDetails.AsObject);
|
|
132
133
|
}
|
|
134
|
+
export declare class AppendConsistencyViolationError extends CommandErrorBase {
|
|
135
|
+
type: ErrorType.APPEND_CONSISTENCY_VIOLATION;
|
|
136
|
+
violations: ConsistencyViolation[];
|
|
137
|
+
constructor(error: ServiceError, details: AppendConsistencyViolationErrorDetails.AsObject);
|
|
138
|
+
}
|
|
133
139
|
export declare class RequiredMetadataPropertyMissingError extends CommandErrorBase {
|
|
134
140
|
type: ErrorType.MISSING_REQUIRED_METADATA_PROPERTY;
|
|
135
141
|
requiredMetadataProperties: string[];
|
|
@@ -192,7 +198,7 @@ export declare class InvalidArgumentError extends CommandErrorBase {
|
|
|
192
198
|
errorMessage: string;
|
|
193
199
|
constructor(error: string);
|
|
194
200
|
}
|
|
195
|
-
export type CommandError = NotLeaderError | StreamNotFoundError | NoStreamError | AccessDeniedError | InvalidArgumentError | InvalidTransactionError | StreamDeletedError | StreamTombstonedError | ScavengeNotFoundError | WrongExpectedVersionError | MaxAppendSizeExceededError | AppendRecordSizeExceededError | TransactionMaxSizeExceededError | RequiredMetadataPropertyMissingError | PersistentSubscriptionFailedError | PersistentSubscriptionDoesNotExistError | PersistentSubscriptionExistsError | PersistentSubscriptionDroppedError | PersistentSubscriptionMaximumSubscribersReachedError | LoginNotFoundError | LoginConflictError | TimeoutError | DeadlineExceededError | UnavailableError | CancelledError | UnknownError | UnsupportedError;
|
|
201
|
+
export type CommandError = NotLeaderError | StreamNotFoundError | NoStreamError | AccessDeniedError | InvalidArgumentError | InvalidTransactionError | StreamDeletedError | StreamTombstonedError | ScavengeNotFoundError | WrongExpectedVersionError | MaxAppendSizeExceededError | AppendRecordSizeExceededError | TransactionMaxSizeExceededError | AppendConsistencyViolationError | RequiredMetadataPropertyMissingError | PersistentSubscriptionFailedError | PersistentSubscriptionDoesNotExistError | PersistentSubscriptionExistsError | PersistentSubscriptionDroppedError | PersistentSubscriptionMaximumSubscribersReachedError | LoginNotFoundError | LoginConflictError | TimeoutError | DeadlineExceededError | UnavailableError | CancelledError | UnknownError | UnsupportedError;
|
|
196
202
|
export declare const convertToCommandError: (error: Error) => CommandError | Error;
|
|
197
203
|
export declare const isCommandError: (error: Error) => error is CommandError;
|
|
198
204
|
export {};
|