@kurrent/kurrentdb-client 1.1.0 → 1.2.0-alpha.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.
Files changed (77) hide show
  1. package/dist/index.d.ts +1 -0
  2. package/dist/index.js +1 -0
  3. package/dist/index.js.map +1 -1
  4. package/dist/schemaRegistry/checkSchemaCompatibility.d.ts +12 -0
  5. package/dist/schemaRegistry/checkSchemaCompatibility.js +60 -0
  6. package/dist/schemaRegistry/checkSchemaCompatibility.js.map +1 -0
  7. package/dist/schemaRegistry/createSchema.d.ts +13 -0
  8. package/dist/schemaRegistry/createSchema.js +36 -0
  9. package/dist/schemaRegistry/createSchema.js.map +1 -0
  10. package/dist/schemaRegistry/deleteSchema.d.ts +11 -0
  11. package/dist/schemaRegistry/deleteSchema.js +23 -0
  12. package/dist/schemaRegistry/deleteSchema.js.map +1 -0
  13. package/dist/schemaRegistry/deleteSchemaVersions.d.ts +13 -0
  14. package/dist/schemaRegistry/deleteSchemaVersions.js +29 -0
  15. package/dist/schemaRegistry/deleteSchemaVersions.js.map +1 -0
  16. package/dist/schemaRegistry/getSchema.d.ts +12 -0
  17. package/dist/schemaRegistry/getSchema.js +28 -0
  18. package/dist/schemaRegistry/getSchema.js.map +1 -0
  19. package/dist/schemaRegistry/getSchemaVersion.d.ts +12 -0
  20. package/dist/schemaRegistry/getSchemaVersion.js +33 -0
  21. package/dist/schemaRegistry/getSchemaVersion.js.map +1 -0
  22. package/dist/schemaRegistry/getSchemaVersionById.d.ts +12 -0
  23. package/dist/schemaRegistry/getSchemaVersionById.js +28 -0
  24. package/dist/schemaRegistry/getSchemaVersionById.js.map +1 -0
  25. package/dist/schemaRegistry/index.d.ts +14 -0
  26. package/dist/schemaRegistry/index.js +35 -0
  27. package/dist/schemaRegistry/index.js.map +1 -0
  28. package/dist/schemaRegistry/listRegisteredSchemas.d.ts +11 -0
  29. package/dist/schemaRegistry/listRegisteredSchemas.js +41 -0
  30. package/dist/schemaRegistry/listRegisteredSchemas.js.map +1 -0
  31. package/dist/schemaRegistry/listSchemaVersions.d.ts +12 -0
  32. package/dist/schemaRegistry/listSchemaVersions.js +28 -0
  33. package/dist/schemaRegistry/listSchemaVersions.js.map +1 -0
  34. package/dist/schemaRegistry/listSchemas.d.ts +11 -0
  35. package/dist/schemaRegistry/listSchemas.js +35 -0
  36. package/dist/schemaRegistry/listSchemas.js.map +1 -0
  37. package/dist/schemaRegistry/lookupSchemaName.d.ts +12 -0
  38. package/dist/schemaRegistry/lookupSchemaName.js +23 -0
  39. package/dist/schemaRegistry/lookupSchemaName.js.map +1 -0
  40. package/dist/schemaRegistry/registerSchemaVersion.d.ts +13 -0
  41. package/dist/schemaRegistry/registerSchemaVersion.js +31 -0
  42. package/dist/schemaRegistry/registerSchemaVersion.js.map +1 -0
  43. package/dist/schemaRegistry/types.d.ts +347 -0
  44. package/dist/schemaRegistry/types.js +3 -0
  45. package/dist/schemaRegistry/types.js.map +1 -0
  46. package/dist/schemaRegistry/updateSchema.d.ts +11 -0
  47. package/dist/schemaRegistry/updateSchema.js +51 -0
  48. package/dist/schemaRegistry/updateSchema.js.map +1 -0
  49. package/dist/schemaRegistry/utils/index.d.ts +1 -0
  50. package/dist/schemaRegistry/utils/index.js +18 -0
  51. package/dist/schemaRegistry/utils/index.js.map +1 -0
  52. package/dist/schemaRegistry/utils/mappers.d.ts +24 -0
  53. package/dist/schemaRegistry/utils/mappers.js +198 -0
  54. package/dist/schemaRegistry/utils/mappers.js.map +1 -0
  55. package/generated/kurrentdb/protocols/v2/registry/errors_grpc_pb.js +1 -0
  56. package/generated/kurrentdb/protocols/v2/registry/errors_pb.d.ts +75 -0
  57. package/generated/kurrentdb/protocols/v2/registry/errors_pb.js +493 -0
  58. package/generated/kurrentdb/protocols/v2/registry/events_grpc_pb.js +1 -0
  59. package/generated/kurrentdb/protocols/v2/registry/events_pb.d.ts +255 -0
  60. package/generated/kurrentdb/protocols/v2/registry/events_pb.js +2057 -0
  61. package/generated/kurrentdb/protocols/v2/registry/groups_grpc_pb.js +1 -0
  62. package/generated/kurrentdb/protocols/v2/registry/groups_pb.d.ts +474 -0
  63. package/generated/kurrentdb/protocols/v2/registry/groups_pb.js +3593 -0
  64. package/generated/kurrentdb/protocols/v2/registry/schemas_grpc_pb.js +1 -0
  65. package/generated/kurrentdb/protocols/v2/registry/schemas_pb.d.ts +825 -0
  66. package/generated/kurrentdb/protocols/v2/registry/schemas_pb.js +6500 -0
  67. package/generated/kurrentdb/protocols/v2/registry/service_grpc_pb.d.ts +350 -0
  68. package/generated/kurrentdb/protocols/v2/registry/service_grpc_pb.js +654 -0
  69. package/generated/kurrentdb/protocols/v2/registry/service_pb.d.ts +10 -0
  70. package/generated/kurrentdb/protocols/v2/registry/service_pb.js +29 -0
  71. package/generated/kurrentdb/protocols/v2/registry/shared_grpc_pb.js +1 -0
  72. package/generated/kurrentdb/protocols/v2/registry/shared_pb.d.ts +26 -0
  73. package/generated/kurrentdb/protocols/v2/registry/shared_pb.js +51 -0
  74. package/generated/kurrentdb/protocols/v2/registry/validation_grpc_pb.js +1 -0
  75. package/generated/kurrentdb/protocols/v2/registry/validation_pb.d.ts +247 -0
  76. package/generated/kurrentdb/protocols/v2/registry/validation_pb.js +1789 -0
  77. package/package.json +1 -1
@@ -0,0 +1,12 @@
1
+ import type { LookupSchemaNameOptions } from "./types";
2
+ declare module "../Client" {
3
+ interface Client {
4
+ /**
5
+ * Looks up the schema name by a schema version ID.
6
+ * @param schemaVersionId - The schema version ID to look up.
7
+ * @param options - Command options.
8
+ * @returns The schema name that owns the specified version.
9
+ */
10
+ lookupSchemaName(schemaVersionId: string, options?: LookupSchemaNameOptions): Promise<string>;
11
+ }
12
+ }
@@ -0,0 +1,23 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const service_grpc_pb_1 = require("../../generated/kurrentdb/protocols/v2/registry/service_grpc_pb");
4
+ const schemas_pb_1 = require("../../generated/kurrentdb/protocols/v2/registry/schemas_pb");
5
+ const Client_1 = require("../Client");
6
+ const utils_1 = require("../utils");
7
+ Client_1.Client.prototype.lookupSchemaName = async function (schemaVersionId, options = {}) {
8
+ const req = new schemas_pb_1.LookupSchemaNameRequest();
9
+ req.setSchemaVersionId(schemaVersionId);
10
+ utils_1.debug.command("lookupSchemaName: %O", {
11
+ schemaVersionId,
12
+ options,
13
+ });
14
+ utils_1.debug.command_grpc("lookupSchemaName: %g", req);
15
+ return this.execute(service_grpc_pb_1.SchemaRegistryServiceClient, "lookupSchemaName", (client) => new Promise((resolve, reject) => {
16
+ client.lookupSchemaName(req, ...this.callArguments(options), (error, response) => {
17
+ if (error)
18
+ return reject((0, utils_1.convertToCommandError)(error));
19
+ return resolve(response?.getSchemaName() ?? "");
20
+ });
21
+ }));
22
+ };
23
+ //# sourceMappingURL=lookupSchemaName.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"lookupSchemaName.js","sourceRoot":"","sources":["../../src/schemaRegistry/lookupSchemaName.ts"],"names":[],"mappings":";;AAAA,qGAA8G;AAC9G,2FAAqG;AAErG,sCAAmC;AACnC,oCAAwD;AAmBxD,eAAM,CAAC,SAAS,CAAC,gBAAgB,GAAG,KAAK,WAEvC,eAAuB,EACvB,UAAmC,EAAE;IAErC,MAAM,GAAG,GAAG,IAAI,oCAAuB,EAAE,CAAC;IAC1C,GAAG,CAAC,kBAAkB,CAAC,eAAe,CAAC,CAAC;IAExC,aAAK,CAAC,OAAO,CAAC,sBAAsB,EAAE;QACpC,eAAe;QACf,OAAO;KACR,CAAC,CAAC;IACH,aAAK,CAAC,YAAY,CAAC,sBAAsB,EAAE,GAAG,CAAC,CAAC;IAEhD,OAAO,IAAI,CAAC,OAAO,CACjB,6CAA2B,EAC3B,kBAAkB,EAClB,CAAC,MAAM,EAAE,EAAE,CACT,IAAI,OAAO,CAAS,CAAC,OAAO,EAAE,MAAM,EAAE,EAAE;QACtC,MAAM,CAAC,gBAAgB,CACrB,GAAG,EACH,GAAG,IAAI,CAAC,aAAa,CAAC,OAAO,CAAC,EAC9B,CAAC,KAAK,EAAE,QAAQ,EAAE,EAAE;YAClB,IAAI,KAAK;gBAAE,OAAO,MAAM,CAAC,IAAA,6BAAqB,EAAC,KAAK,CAAC,CAAC,CAAC;YACvD,OAAO,OAAO,CAAC,QAAQ,EAAE,aAAa,EAAE,IAAI,EAAE,CAAC,CAAC;QAClD,CAAC,CACF,CAAC;IACJ,CAAC,CAAC,CACL,CAAC;AACJ,CAAC,CAAC"}
@@ -0,0 +1,13 @@
1
+ import type { RegisterSchemaVersionOptions, RegisterSchemaVersionResult } from "./types";
2
+ declare module "../Client" {
3
+ interface Client {
4
+ /**
5
+ * Registers a new version for an existing schema.
6
+ * @param schemaName - The name of the schema to add a version to.
7
+ * @param schemaDefinition - The schema definition for the new version.
8
+ * @param options - Command options.
9
+ * @returns The registered schema version ID and version number.
10
+ */
11
+ registerSchemaVersion(schemaName: string, schemaDefinition: string | Uint8Array, options?: RegisterSchemaVersionOptions): Promise<RegisterSchemaVersionResult>;
12
+ }
13
+ }
@@ -0,0 +1,31 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const service_grpc_pb_1 = require("../../generated/kurrentdb/protocols/v2/registry/service_grpc_pb");
4
+ const schemas_pb_1 = require("../../generated/kurrentdb/protocols/v2/registry/schemas_pb");
5
+ const Client_1 = require("../Client");
6
+ const utils_1 = require("../utils");
7
+ const mappers_1 = require("./utils/mappers");
8
+ Client_1.Client.prototype.registerSchemaVersion = async function (schemaName, schemaDefinition, options = {}) {
9
+ const req = new schemas_pb_1.RegisterSchemaVersionRequest();
10
+ req.setSchemaName(schemaName);
11
+ req.setSchemaDefinition((0, mappers_1.toSchemaDefinitionBytes)(schemaDefinition));
12
+ utils_1.debug.command("registerSchemaVersion: %O", {
13
+ schemaName,
14
+ definitionLength: typeof schemaDefinition === "string"
15
+ ? schemaDefinition.length
16
+ : schemaDefinition.byteLength,
17
+ options,
18
+ });
19
+ utils_1.debug.command_grpc("registerSchemaVersion: %g", req);
20
+ return this.execute(service_grpc_pb_1.SchemaRegistryServiceClient, "registerSchemaVersion", (client) => new Promise((resolve, reject) => {
21
+ client.registerSchemaVersion(req, ...this.callArguments(options), (error, response) => {
22
+ if (error)
23
+ return reject((0, utils_1.convertToCommandError)(error));
24
+ return resolve({
25
+ schemaVersionId: response?.getSchemaVersionId() ?? "",
26
+ versionNumber: response?.getVersionNumber() ?? 0,
27
+ });
28
+ });
29
+ }));
30
+ };
31
+ //# sourceMappingURL=registerSchemaVersion.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"registerSchemaVersion.js","sourceRoot":"","sources":["../../src/schemaRegistry/registerSchemaVersion.ts"],"names":[],"mappings":";;AAAA,qGAA8G;AAC9G,2FAA0G;AAE1G,sCAAmC;AACnC,oCAAwD;AAMxD,6CAA0D;AAmB1D,eAAM,CAAC,SAAS,CAAC,qBAAqB,GAAG,KAAK,WAE5C,UAAkB,EAClB,gBAAqC,EACrC,UAAwC,EAAE;IAE1C,MAAM,GAAG,GAAG,IAAI,yCAA4B,EAAE,CAAC;IAC/C,GAAG,CAAC,aAAa,CAAC,UAAU,CAAC,CAAC;IAC9B,GAAG,CAAC,mBAAmB,CAAC,IAAA,iCAAuB,EAAC,gBAAgB,CAAC,CAAC,CAAC;IAEnE,aAAK,CAAC,OAAO,CAAC,2BAA2B,EAAE;QACzC,UAAU;QACV,gBAAgB,EACd,OAAO,gBAAgB,KAAK,QAAQ;YAClC,CAAC,CAAC,gBAAgB,CAAC,MAAM;YACzB,CAAC,CAAC,gBAAgB,CAAC,UAAU;QACjC,OAAO;KACR,CAAC,CAAC;IACH,aAAK,CAAC,YAAY,CAAC,2BAA2B,EAAE,GAAG,CAAC,CAAC;IAErD,OAAO,IAAI,CAAC,OAAO,CACjB,6CAA2B,EAC3B,uBAAuB,EACvB,CAAC,MAAM,EAAE,EAAE,CACT,IAAI,OAAO,CAA8B,CAAC,OAAO,EAAE,MAAM,EAAE,EAAE;QAC3D,MAAM,CAAC,qBAAqB,CAC1B,GAAG,EACH,GAAG,IAAI,CAAC,aAAa,CAAC,OAAO,CAAC,EAC9B,CAAC,KAAK,EAAE,QAAQ,EAAE,EAAE;YAClB,IAAI,KAAK;gBAAE,OAAO,MAAM,CAAC,IAAA,6BAAqB,EAAC,KAAK,CAAC,CAAC,CAAC;YAEvD,OAAO,OAAO,CAAC;gBACb,eAAe,EAAE,QAAQ,EAAE,kBAAkB,EAAE,IAAI,EAAE;gBACrD,aAAa,EAAE,QAAQ,EAAE,gBAAgB,EAAE,IAAI,CAAC;aACjD,CAAC,CAAC;QACL,CAAC,CACF,CAAC;IACJ,CAAC,CAAC,CACL,CAAC;AACJ,CAAC,CAAC"}
@@ -0,0 +1,347 @@
1
+ import type { BaseOptions } from "../types";
2
+ /**
3
+ * Schema data format types supported by the schema registry.
4
+ */
5
+ export type SchemaDataFormat = "json" | "protobuf" | "avro" | "bytes";
6
+ /**
7
+ * Schema compatibility modes for version validation.
8
+ */
9
+ export type CompatibilityMode = "backward" | "forward" | "full" | "backward-all" | "forward-all" | "full-all" | "none";
10
+ /**
11
+ * Schema details for creating or updating a schema.
12
+ */
13
+ export interface SchemaDetails {
14
+ /**
15
+ * The data format of the schema.
16
+ */
17
+ dataFormat: SchemaDataFormat;
18
+ /**
19
+ * The compatibility mode for schema versions.
20
+ */
21
+ compatibility: CompatibilityMode;
22
+ /**
23
+ * Optional description of the schema.
24
+ */
25
+ description?: string;
26
+ /**
27
+ * Optional tags for the schema.
28
+ */
29
+ tags?: Record<string, string>;
30
+ }
31
+ /**
32
+ * Represents a schema in the registry.
33
+ */
34
+ export interface Schema {
35
+ /**
36
+ * The name of the schema.
37
+ */
38
+ schemaName: string;
39
+ /**
40
+ * The schema details.
41
+ */
42
+ details: SchemaDetails;
43
+ /**
44
+ * The latest version number of the schema.
45
+ */
46
+ latestSchemaVersion: number;
47
+ /**
48
+ * When the schema was created.
49
+ */
50
+ createdAt?: Date;
51
+ /**
52
+ * When the schema was last updated.
53
+ */
54
+ updatedAt?: Date;
55
+ }
56
+ /**
57
+ * Represents a version of a schema.
58
+ */
59
+ export interface SchemaVersion {
60
+ /**
61
+ * The unique identifier for this schema version.
62
+ */
63
+ schemaVersionId: string;
64
+ /**
65
+ * The version number.
66
+ */
67
+ versionNumber: number;
68
+ /**
69
+ * The schema definition bytes.
70
+ */
71
+ schemaDefinition: Uint8Array;
72
+ /**
73
+ * The data format of the schema.
74
+ */
75
+ dataFormat: SchemaDataFormat;
76
+ /**
77
+ * When the version was registered.
78
+ */
79
+ registeredAt?: Date;
80
+ }
81
+ /**
82
+ * Represents a registered schema with its latest version information.
83
+ */
84
+ export interface RegisteredSchema {
85
+ /**
86
+ * The name of the schema.
87
+ */
88
+ schemaName: string;
89
+ /**
90
+ * The unique identifier for the schema version.
91
+ */
92
+ schemaVersionId: string;
93
+ /**
94
+ * The version number.
95
+ */
96
+ versionNumber: number;
97
+ /**
98
+ * The schema definition bytes.
99
+ */
100
+ schemaDefinition?: Uint8Array;
101
+ /**
102
+ * The data format of the schema.
103
+ */
104
+ dataFormat: SchemaDataFormat;
105
+ /**
106
+ * The compatibility mode for schema versions.
107
+ */
108
+ compatibility: CompatibilityMode;
109
+ /**
110
+ * Tags associated with the schema.
111
+ */
112
+ tags: Record<string, string>;
113
+ /**
114
+ * When the version was registered.
115
+ */
116
+ registeredAt?: Date;
117
+ }
118
+ /**
119
+ * Error details for a schema version operation.
120
+ */
121
+ export interface SchemaVersionError {
122
+ /**
123
+ * The version number that had an error.
124
+ */
125
+ versionNumber: number;
126
+ /**
127
+ * The error details.
128
+ */
129
+ error?: {
130
+ code: string;
131
+ message: string;
132
+ };
133
+ }
134
+ /**
135
+ * Schema compatibility error information.
136
+ */
137
+ export interface SchemaCompatibilityError {
138
+ /**
139
+ * The kind of compatibility error.
140
+ */
141
+ kind: SchemaCompatibilityErrorKind;
142
+ /**
143
+ * Detailed description of the error.
144
+ */
145
+ details: string;
146
+ /**
147
+ * The property path where the error occurred.
148
+ */
149
+ propertyPath?: string;
150
+ /**
151
+ * The original type before the change.
152
+ */
153
+ originalType?: string;
154
+ /**
155
+ * The new type after the change.
156
+ */
157
+ newType?: string;
158
+ }
159
+ /**
160
+ * Types of schema compatibility errors.
161
+ */
162
+ export type SchemaCompatibilityErrorKind = "unspecified" | "missing-required-property" | "incompatible-type-change" | "optional-to-required" | "new-required-property" | "removed-property" | "array-type-incompatibility" | "data-format-mismatch";
163
+ /**
164
+ * Options for creating a schema.
165
+ */
166
+ export interface CreateSchemaOptions extends BaseOptions {
167
+ /**
168
+ * Optional initial schema definition. If provided, the schema will be created
169
+ * with version 1 containing this definition.
170
+ */
171
+ schemaDefinition?: string | Uint8Array;
172
+ }
173
+ /**
174
+ * Result of creating a schema.
175
+ */
176
+ export interface CreateSchemaResult {
177
+ /**
178
+ * The schema version ID (only present if schemaDefinition was provided).
179
+ */
180
+ schemaVersionId?: string;
181
+ /**
182
+ * The version number (only present if schemaDefinition was provided).
183
+ */
184
+ versionNumber?: number;
185
+ }
186
+ /**
187
+ * Options for updating a schema.
188
+ */
189
+ export interface UpdateSchemaOptions extends BaseOptions {
190
+ /**
191
+ * The data format of the schema (must match existing schema).
192
+ */
193
+ dataFormat: SchemaDataFormat;
194
+ /**
195
+ * The compatibility mode (must match existing schema).
196
+ */
197
+ compatibility: CompatibilityMode;
198
+ /**
199
+ * Updated description for the schema.
200
+ */
201
+ description?: string;
202
+ /**
203
+ * Updated tags for the schema.
204
+ */
205
+ tags?: Record<string, string>;
206
+ }
207
+ /**
208
+ * Options for deleting a schema.
209
+ */
210
+ export type DeleteSchemaOptions = BaseOptions;
211
+ /**
212
+ * Options for getting a schema.
213
+ */
214
+ export type GetSchemaOptions = BaseOptions;
215
+ /**
216
+ * Options for listing schemas.
217
+ */
218
+ export interface ListSchemasOptions extends BaseOptions {
219
+ /**
220
+ * Filter schemas by name prefix.
221
+ */
222
+ schemaNamePrefix?: string;
223
+ /**
224
+ * Filter schemas by tags.
225
+ */
226
+ schemaTags?: Record<string, string>;
227
+ }
228
+ /**
229
+ * Options for looking up a schema name.
230
+ */
231
+ export type LookupSchemaNameOptions = BaseOptions;
232
+ /**
233
+ * Options for registering a schema version.
234
+ */
235
+ export type RegisterSchemaVersionOptions = BaseOptions;
236
+ /**
237
+ * Result of registering a schema version.
238
+ */
239
+ export interface RegisterSchemaVersionResult {
240
+ /**
241
+ * The unique identifier for the registered schema version.
242
+ */
243
+ schemaVersionId: string;
244
+ /**
245
+ * The version number assigned to the registration.
246
+ */
247
+ versionNumber: number;
248
+ }
249
+ /**
250
+ * Options for deleting schema versions.
251
+ */
252
+ export type DeleteSchemaVersionsOptions = BaseOptions;
253
+ /**
254
+ * Result of deleting schema versions.
255
+ */
256
+ export interface DeleteSchemaVersionsResult {
257
+ /**
258
+ * Errors that occurred during deletion, if any.
259
+ */
260
+ errors: SchemaVersionError[];
261
+ }
262
+ /**
263
+ * Options for getting a schema version.
264
+ */
265
+ export interface GetSchemaVersionOptions extends BaseOptions {
266
+ /**
267
+ * The specific version number to retrieve. If not provided, returns the latest version.
268
+ */
269
+ versionNumber?: number;
270
+ }
271
+ /**
272
+ * Options for getting a schema version by ID.
273
+ */
274
+ export type GetSchemaVersionByIdOptions = BaseOptions;
275
+ /**
276
+ * Options for listing schema versions.
277
+ */
278
+ export interface ListSchemaVersionsOptions extends BaseOptions {
279
+ /**
280
+ * Whether to include the schema definition in the response.
281
+ * @defaultValue false
282
+ */
283
+ includeDefinition?: boolean;
284
+ }
285
+ /**
286
+ * Options for listing registered schemas.
287
+ */
288
+ export interface ListRegisteredSchemasOptions extends BaseOptions {
289
+ /**
290
+ * Filter by a specific schema version ID.
291
+ */
292
+ schemaVersionId?: string;
293
+ /**
294
+ * Filter schemas by name prefix.
295
+ */
296
+ schemaNamePrefix?: string;
297
+ /**
298
+ * Filter schemas by tags.
299
+ */
300
+ schemaTags?: Record<string, string>;
301
+ /**
302
+ * Whether to include the schema definition in the response.
303
+ * @defaultValue false
304
+ */
305
+ includeDefinition?: boolean;
306
+ }
307
+ /**
308
+ * Options for checking schema compatibility.
309
+ */
310
+ export interface CheckSchemaCompatibilityOptions extends BaseOptions {
311
+ /**
312
+ * The schema name to check compatibility against.
313
+ * Either schemaName or schemaVersionId must be provided.
314
+ */
315
+ schemaName?: string;
316
+ /**
317
+ * The specific schema version ID to check compatibility against.
318
+ * Either schemaName or schemaVersionId must be provided.
319
+ */
320
+ schemaVersionId?: string;
321
+ /**
322
+ * The data format of the schema definition being checked.
323
+ */
324
+ dataFormat: SchemaDataFormat;
325
+ }
326
+ /**
327
+ * Result of checking schema compatibility.
328
+ */
329
+ export type CheckSchemaCompatibilityResult = {
330
+ /**
331
+ * Whether the schema is compatible.
332
+ */
333
+ isCompatible: true;
334
+ /**
335
+ * The schema version ID that was checked against.
336
+ */
337
+ schemaVersionId: string;
338
+ } | {
339
+ /**
340
+ * Whether the schema is compatible.
341
+ */
342
+ isCompatible: false;
343
+ /**
344
+ * The compatibility errors found.
345
+ */
346
+ errors: SchemaCompatibilityError[];
347
+ };
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/schemaRegistry/types.ts"],"names":[],"mappings":""}
@@ -0,0 +1,11 @@
1
+ import type { UpdateSchemaOptions } from "./types";
2
+ declare module "../Client" {
3
+ interface Client {
4
+ /**
5
+ * Updates schema metadata (description and/or tags).
6
+ * @param schemaName - The name of the schema to update.
7
+ * @param options - The update options including description and tags to update.
8
+ */
9
+ updateSchema(schemaName: string, options?: UpdateSchemaOptions): Promise<void>;
10
+ }
11
+ }
@@ -0,0 +1,51 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const field_mask_pb_1 = require("google-protobuf/google/protobuf/field_mask_pb");
4
+ const service_grpc_pb_1 = require("../../generated/kurrentdb/protocols/v2/registry/service_grpc_pb");
5
+ const schemas_pb_1 = require("../../generated/kurrentdb/protocols/v2/registry/schemas_pb");
6
+ const Client_1 = require("../Client");
7
+ const utils_1 = require("../utils");
8
+ const utils_2 = require("./utils");
9
+ Client_1.Client.prototype.updateSchema = async function (schemaName, options) {
10
+ const { description, tags, dataFormat, compatibility, ...baseOptions } = options;
11
+ const req = new schemas_pb_1.UpdateSchemaRequest();
12
+ req.setSchemaName(schemaName);
13
+ const details = new schemas_pb_1.SchemaDetails();
14
+ const updatePaths = [];
15
+ // dataFormat and compatibility are required fields but not updated via field mask
16
+ details.setDataFormat((0, utils_2.mapSchemaDataFormatToGrpc)(dataFormat));
17
+ details.setCompatibility((0, utils_2.mapCompatibilityModeToGrpc)(compatibility));
18
+ if (description !== undefined) {
19
+ details.setDescription(description);
20
+ updatePaths.push("details.description");
21
+ }
22
+ if (tags !== undefined) {
23
+ const tagsMap = details.getTagsMap();
24
+ for (const [key, value] of Object.entries(tags)) {
25
+ tagsMap.set(key, value);
26
+ }
27
+ updatePaths.push("details.tags");
28
+ }
29
+ req.setDetails(details);
30
+ if (updatePaths.length > 0) {
31
+ const fieldMask = new field_mask_pb_1.FieldMask();
32
+ fieldMask.setPathsList(updatePaths);
33
+ req.setUpdateMask(fieldMask);
34
+ }
35
+ utils_1.debug.command("updateSchema: %O", {
36
+ schemaName,
37
+ description,
38
+ tags,
39
+ updatePaths,
40
+ options: baseOptions,
41
+ });
42
+ utils_1.debug.command_grpc("updateSchema: %g", req);
43
+ return this.execute(service_grpc_pb_1.SchemaRegistryServiceClient, "updateSchema", (client) => new Promise((resolve, reject) => {
44
+ client.updateSchema(req, ...this.callArguments(baseOptions), (error) => {
45
+ if (error)
46
+ return reject((0, utils_1.convertToCommandError)(error));
47
+ return resolve();
48
+ });
49
+ }));
50
+ };
51
+ //# sourceMappingURL=updateSchema.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"updateSchema.js","sourceRoot":"","sources":["../../src/schemaRegistry/updateSchema.ts"],"names":[],"mappings":";;AAAA,iFAA0E;AAE1E,qGAA8G;AAC9G,2FAGoE;AAEpE,sCAAmC;AACnC,oCAAwD;AAGxD,mCAAgF;AAgBhF,eAAM,CAAC,SAAS,CAAC,YAAY,GAAG,KAAK,WAEnC,UAAkB,EAClB,OAA4B;IAE5B,MAAM,EAAE,WAAW,EAAE,IAAI,EAAE,UAAU,EAAE,aAAa,EAAE,GAAG,WAAW,EAAE,GACpE,OAAO,CAAC;IAEV,MAAM,GAAG,GAAG,IAAI,gCAAmB,EAAE,CAAC;IACtC,GAAG,CAAC,aAAa,CAAC,UAAU,CAAC,CAAC;IAE9B,MAAM,OAAO,GAAG,IAAI,0BAAiB,EAAE,CAAC;IACxC,MAAM,WAAW,GAAa,EAAE,CAAC;IAEjC,kFAAkF;IAClF,OAAO,CAAC,aAAa,CAAC,IAAA,iCAAyB,EAAC,UAAU,CAAC,CAAC,CAAC;IAC7D,OAAO,CAAC,gBAAgB,CAAC,IAAA,kCAA0B,EAAC,aAAa,CAAC,CAAC,CAAC;IAEpE,IAAI,WAAW,KAAK,SAAS,EAAE,CAAC;QAC9B,OAAO,CAAC,cAAc,CAAC,WAAW,CAAC,CAAC;QACpC,WAAW,CAAC,IAAI,CAAC,qBAAqB,CAAC,CAAC;IAC1C,CAAC;IAED,IAAI,IAAI,KAAK,SAAS,EAAE,CAAC;QACvB,MAAM,OAAO,GAAG,OAAO,CAAC,UAAU,EAAE,CAAC;QACrC,KAAK,MAAM,CAAC,GAAG,EAAE,KAAK,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,IAAI,CAAC,EAAE,CAAC;YAChD,OAAO,CAAC,GAAG,CAAC,GAAG,EAAE,KAAK,CAAC,CAAC;QAC1B,CAAC;QACD,WAAW,CAAC,IAAI,CAAC,cAAc,CAAC,CAAC;IACnC,CAAC;IAED,GAAG,CAAC,UAAU,CAAC,OAAO,CAAC,CAAC;IAExB,IAAI,WAAW,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;QAC3B,MAAM,SAAS,GAAG,IAAI,yBAAS,EAAE,CAAC;QAClC,SAAS,CAAC,YAAY,CAAC,WAAW,CAAC,CAAC;QACpC,GAAG,CAAC,aAAa,CAAC,SAAS,CAAC,CAAC;IAC/B,CAAC;IAED,aAAK,CAAC,OAAO,CAAC,kBAAkB,EAAE;QAChC,UAAU;QACV,WAAW;QACX,IAAI;QACJ,WAAW;QACX,OAAO,EAAE,WAAW;KACrB,CAAC,CAAC;IACH,aAAK,CAAC,YAAY,CAAC,kBAAkB,EAAE,GAAG,CAAC,CAAC;IAE5C,OAAO,IAAI,CAAC,OAAO,CACjB,6CAA2B,EAC3B,cAAc,EACd,CAAC,MAAM,EAAE,EAAE,CACT,IAAI,OAAO,CAAO,CAAC,OAAO,EAAE,MAAM,EAAE,EAAE;QACpC,MAAM,CAAC,YAAY,CACjB,GAAG,EACH,GAAG,IAAI,CAAC,aAAa,CAAC,WAAW,CAAC,EAClC,CAAC,KAAK,EAAE,EAAE;YACR,IAAI,KAAK;gBAAE,OAAO,MAAM,CAAC,IAAA,6BAAqB,EAAC,KAAK,CAAC,CAAC,CAAC;YACvD,OAAO,OAAO,EAAE,CAAC;QACnB,CAAC,CACF,CAAC;IACJ,CAAC,CAAC,CACL,CAAC;AACJ,CAAC,CAAC"}
@@ -0,0 +1 @@
1
+ export * from "./mappers";
@@ -0,0 +1,18 @@
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 __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ __exportStar(require("./mappers"), exports);
18
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/schemaRegistry/utils/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,4CAA0B"}
@@ -0,0 +1,24 @@
1
+ import { Timestamp } from "google-protobuf/google/protobuf/timestamp_pb";
2
+ import { SchemaDataFormat as GrpcSchemaDataFormat, CompatibilityMode as GrpcCompatibilityMode } from "../../../generated/kurrentdb/protocols/v2/registry/shared_pb";
3
+ import { Schema as GrpcSchema, SchemaDetails as GrpcSchemaDetails, SchemaVersion as GrpcSchemaVersion, RegisteredSchema as GrpcRegisteredSchema, DeleteSchemaVersionsResponse } from "../../../generated/kurrentdb/protocols/v2/registry/schemas_pb";
4
+ import { SchemaCompatibilityError as GrpcSchemaCompatibilityError } from "../../../generated/kurrentdb/protocols/v2/registry/validation_pb";
5
+ import type { SchemaDataFormat, CompatibilityMode, Schema, SchemaDetails, SchemaVersion, RegisteredSchema, SchemaVersionError, SchemaCompatibilityError } from "../types";
6
+ export declare function mapSchemaDataFormatToGrpc(format: SchemaDataFormat): GrpcSchemaDataFormat;
7
+ export declare function mapGrpcSchemaDataFormat(format: GrpcSchemaDataFormat): SchemaDataFormat;
8
+ export declare function mapCompatibilityModeToGrpc(mode: CompatibilityMode): GrpcCompatibilityMode;
9
+ export declare function mapGrpcCompatibilityMode(mode: GrpcCompatibilityMode): CompatibilityMode;
10
+ export declare function mapGrpcTimestamp(timestamp: Timestamp | undefined): Date | undefined;
11
+ export declare function mapGrpcSchemaDetails(details: GrpcSchemaDetails | undefined): SchemaDetails;
12
+ export declare function mapGrpcSchema(grpcSchema: GrpcSchema): Schema;
13
+ export declare function mapGrpcSchemaVersion(grpcVersion: GrpcSchemaVersion): SchemaVersion;
14
+ export declare function mapGrpcRegisteredSchema(grpcSchema: GrpcRegisteredSchema): RegisteredSchema;
15
+ export declare function mapGrpcSchemaVersionError(error: DeleteSchemaVersionsResponse.SchemaVersionError): SchemaVersionError;
16
+ export declare function mapGrpcSchemaCompatibilityError(error: GrpcSchemaCompatibilityError): SchemaCompatibilityError;
17
+ /**
18
+ * Converts a string or Uint8Array schema definition to Uint8Array.
19
+ */
20
+ export declare function toSchemaDefinitionBytes(definition: string | Uint8Array): Uint8Array;
21
+ /**
22
+ * Creates a GrpcSchemaDetails from the input parameters.
23
+ */
24
+ export declare function createGrpcSchemaDetails(details: SchemaDetails): GrpcSchemaDetails;