Skip to content

Commit

Permalink
Return id when upserting data
Browse files Browse the repository at this point in the history
  • Loading branch information
jesko-plitt committed Apr 5, 2023
1 parent 531ac0f commit c597c76
Show file tree
Hide file tree
Showing 4 changed files with 39 additions and 15 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
# v1.0.0-alpha.17

- (bug) Return id when upserting data

# v1.0.0-alpha.16

- (feature) Specify correlation and causation ids
Expand Down
5 changes: 3 additions & 2 deletions delivery/upsert_projection_data.proto
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,9 @@ message UpsertProjectionDataRequest {

message UpsertProjectionDataResponse {
map<string, string> newData = 1;
repeated string validationErrors = 2;
map<string, string> fieldValidationErrors = 3;
string id = 2;
repeated string validationErrors = 3;
map<string, string> fieldValidationErrors = 4;
}


21 changes: 15 additions & 6 deletions go/deliverypb/upsert_projection_data.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

24 changes: 17 additions & 7 deletions nodejs/src/delivery/upsert_projection_data.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ export interface UpsertProjectionDataRequest_PayloadEntry {

export interface UpsertProjectionDataResponse {
newData: { [key: string]: string };
id: string;
validationErrors: string[];
fieldValidationErrors: { [key: string]: string };
}
Expand Down Expand Up @@ -203,21 +204,24 @@ export const UpsertProjectionDataRequest_PayloadEntry = {
};

function createBaseUpsertProjectionDataResponse(): UpsertProjectionDataResponse {
return { newData: {}, validationErrors: [], fieldValidationErrors: {} };
return { newData: {}, id: "", validationErrors: [], fieldValidationErrors: {} };
}

export const UpsertProjectionDataResponse = {
encode(message: UpsertProjectionDataResponse, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer {
Object.entries(message.newData).forEach(([key, value]) => {
UpsertProjectionDataResponse_NewDataEntry.encode({ key: key as any, value }, writer.uint32(10).fork()).ldelim();
});
if (message.id !== "") {
writer.uint32(18).string(message.id);
}
for (const v of message.validationErrors) {
writer.uint32(18).string(v!);
writer.uint32(26).string(v!);
}
Object.entries(message.fieldValidationErrors).forEach(([key, value]) => {
UpsertProjectionDataResponse_FieldValidationErrorsEntry.encode(
{ key: key as any, value },
writer.uint32(26).fork(),
writer.uint32(34).fork(),
).ldelim();
});
return writer;
Expand All @@ -237,12 +241,15 @@ export const UpsertProjectionDataResponse = {
}
break;
case 2:
message.validationErrors.push(reader.string());
message.id = reader.string();
break;
case 3:
const entry3 = UpsertProjectionDataResponse_FieldValidationErrorsEntry.decode(reader, reader.uint32());
if (entry3.value !== undefined) {
message.fieldValidationErrors[entry3.key] = entry3.value;
message.validationErrors.push(reader.string());
break;
case 4:
const entry4 = UpsertProjectionDataResponse_FieldValidationErrorsEntry.decode(reader, reader.uint32());
if (entry4.value !== undefined) {
message.fieldValidationErrors[entry4.key] = entry4.value;
}
break;
default:
Expand All @@ -261,6 +268,7 @@ export const UpsertProjectionDataResponse = {
return acc;
}, {})
: {},
id: isSet(object.id) ? String(object.id) : "",
validationErrors: Array.isArray(object?.validationErrors)
? object.validationErrors.map((e: any) => String(e))
: [],
Expand All @@ -281,6 +289,7 @@ export const UpsertProjectionDataResponse = {
obj.newData[k] = v;
});
}
message.id !== undefined && (obj.id = message.id);
if (message.validationErrors) {
obj.validationErrors = message.validationErrors.map((e) => e);
} else {
Expand All @@ -307,6 +316,7 @@ export const UpsertProjectionDataResponse = {
}
return acc;
}, {});
message.id = object.id ?? "";
message.validationErrors = object.validationErrors?.map((e) => e) || [];
message.fieldValidationErrors = Object.entries(object.fieldValidationErrors ?? {}).reduce<
{ [key: string]: string }
Expand Down

0 comments on commit c597c76

Please sign in to comment.