"use strict";
// Code generated by protoc-gen-ts_proto. DO NOT EDIT.
// versions:
//   protoc-gen-ts_proto  v2.11.8
//   protoc               v4.25.9
// source: io/restorecommerce/commandinterface.proto
Object.defineProperty(exports, "__esModule", { value: true });
exports.protoMetadata = exports.CommandInterfaceServiceDefinition = exports.CommandResponse = exports.CommandRequest = exports.protobufPackage = void 0;
/* eslint-disable */
const wire_1 = require("@bufbuild/protobuf/wire");
const any_1 = require("../../google/protobuf/any");
const auth_1 = require("./auth");
const options_1 = require("./options");
exports.protobufPackage = "io.restorecommerce.commandinterface";
function createBaseCommandRequest() {
    return {};
}
exports.CommandRequest = {
    encode(message, writer = new wire_1.BinaryWriter()) {
        if (message.name !== undefined) {
            writer.uint32(10).string(message.name);
        }
        if (message.payload !== undefined) {
            any_1.Any.encode(message.payload, writer.uint32(18).fork()).join();
        }
        if (message.subject !== undefined) {
            auth_1.Subject.encode(message.subject, writer.uint32(26).fork()).join();
        }
        return writer;
    },
    decode(input, length) {
        const reader = input instanceof wire_1.BinaryReader ? input : new wire_1.BinaryReader(input);
        const end = length === undefined ? reader.len : reader.pos + length;
        const message = createBaseCommandRequest();
        while (reader.pos < end) {
            const tag = reader.uint32();
            switch (tag >>> 3) {
                case 1: {
                    if (tag !== 10) {
                        break;
                    }
                    message.name = reader.string();
                    continue;
                }
                case 2: {
                    if (tag !== 18) {
                        break;
                    }
                    message.payload = any_1.Any.decode(reader, reader.uint32());
                    continue;
                }
                case 3: {
                    if (tag !== 26) {
                        break;
                    }
                    message.subject = auth_1.Subject.decode(reader, reader.uint32());
                    continue;
                }
            }
            if ((tag & 7) === 4 || tag === 0) {
                break;
            }
            reader.skip(tag & 7);
        }
        return message;
    },
    fromJSON(object) {
        return {
            name: isSet(object.name) ? globalThis.String(object.name) : undefined,
            payload: isSet(object.payload) ? any_1.Any.fromJSON(object.payload) : undefined,
            subject: isSet(object.subject) ? auth_1.Subject.fromJSON(object.subject) : undefined,
        };
    },
    toJSON(message) {
        const obj = {};
        if (message.name !== undefined) {
            obj.name = message.name;
        }
        if (message.payload !== undefined) {
            obj.payload = any_1.Any.toJSON(message.payload);
        }
        if (message.subject !== undefined) {
            obj.subject = auth_1.Subject.toJSON(message.subject);
        }
        return obj;
    },
    create(base) {
        return exports.CommandRequest.fromPartial(base ?? {});
    },
    fromPartial(object) {
        const message = createBaseCommandRequest();
        message.name = object.name ?? undefined;
        message.payload = (object.payload !== undefined && object.payload !== null)
            ? any_1.Any.fromPartial(object.payload)
            : undefined;
        message.subject = (object.subject !== undefined && object.subject !== null)
            ? auth_1.Subject.fromPartial(object.subject)
            : undefined;
        return message;
    },
};
function createBaseCommandResponse() {
    return {};
}
exports.CommandResponse = {
    encode(message, writer = new wire_1.BinaryWriter()) {
        if (message.services !== undefined && message.services.length !== 0) {
            for (const v of message.services) {
                writer.uint32(10).string(v);
            }
        }
        if (message.payload !== undefined) {
            any_1.Any.encode(message.payload, writer.uint32(18).fork()).join();
        }
        return writer;
    },
    decode(input, length) {
        const reader = input instanceof wire_1.BinaryReader ? input : new wire_1.BinaryReader(input);
        const end = length === undefined ? reader.len : reader.pos + length;
        const message = createBaseCommandResponse();
        while (reader.pos < end) {
            const tag = reader.uint32();
            switch (tag >>> 3) {
                case 1: {
                    if (tag !== 10) {
                        break;
                    }
                    if (message.services === undefined) {
                        message.services = [];
                    }
                    const el = reader.string();
                    if (el !== undefined) {
                        message.services.push(el);
                    }
                    continue;
                }
                case 2: {
                    if (tag !== 18) {
                        break;
                    }
                    message.payload = any_1.Any.decode(reader, reader.uint32());
                    continue;
                }
            }
            if ((tag & 7) === 4 || tag === 0) {
                break;
            }
            reader.skip(tag & 7);
        }
        return message;
    },
    fromJSON(object) {
        return {
            services: globalThis.Array.isArray(object?.services)
                ? object.services.map((e) => globalThis.String(e))
                : undefined,
            payload: isSet(object.payload) ? any_1.Any.fromJSON(object.payload) : undefined,
        };
    },
    toJSON(message) {
        const obj = {};
        if (message.services?.length) {
            obj.services = message.services;
        }
        if (message.payload !== undefined) {
            obj.payload = any_1.Any.toJSON(message.payload);
        }
        return obj;
    },
    create(base) {
        return exports.CommandResponse.fromPartial(base ?? {});
    },
    fromPartial(object) {
        const message = createBaseCommandResponse();
        message.services = object.services?.map((e) => e) || undefined;
        message.payload = (object.payload !== undefined && object.payload !== null)
            ? any_1.Any.fromPartial(object.payload)
            : undefined;
        return message;
    },
};
exports.CommandInterfaceServiceDefinition = {
    name: "CommandInterfaceService",
    fullName: "io.restorecommerce.commandinterface.CommandInterfaceService",
    methods: {
        command: {
            name: "Command",
            requestType: exports.CommandRequest,
            requestStream: false,
            responseType: any_1.Any,
            responseStream: false,
            options: {},
        },
    },
};
exports.protoMetadata = {
    fileDescriptor: {
        "name": "io/restorecommerce/commandinterface.proto",
        "package": "io.restorecommerce.commandinterface",
        "dependency": ["google/protobuf/any.proto", "io/restorecommerce/auth.proto", "io/restorecommerce/options.proto"],
        "publicDependency": [],
        "weakDependency": [],
        "optionDependency": [],
        "messageType": [{
                "name": "CommandRequest",
                "field": [{
                        "name": "name",
                        "number": 1,
                        "label": 1,
                        "type": 9,
                        "typeName": "",
                        "extendee": "",
                        "defaultValue": "",
                        "oneofIndex": 0,
                        "jsonName": "name",
                        "options": undefined,
                        "proto3Optional": true,
                    }, {
                        "name": "payload",
                        "number": 2,
                        "label": 1,
                        "type": 11,
                        "typeName": ".google.protobuf.Any",
                        "extendee": "",
                        "defaultValue": "",
                        "oneofIndex": 1,
                        "jsonName": "payload",
                        "options": undefined,
                        "proto3Optional": true,
                    }, {
                        "name": "subject",
                        "number": 3,
                        "label": 1,
                        "type": 11,
                        "typeName": ".io.restorecommerce.auth.Subject",
                        "extendee": "",
                        "defaultValue": "",
                        "oneofIndex": 2,
                        "jsonName": "subject",
                        "options": undefined,
                        "proto3Optional": true,
                    }],
                "extension": [],
                "nestedType": [],
                "enumType": [],
                "extensionRange": [],
                "oneofDecl": [{ "name": "_name", "options": undefined }, { "name": "_payload", "options": undefined }, {
                        "name": "_subject",
                        "options": undefined,
                    }],
                "options": undefined,
                "reservedRange": [],
                "reservedName": [],
                "visibility": 0,
            }, {
                "name": "CommandResponse",
                "field": [{
                        "name": "services",
                        "number": 1,
                        "label": 3,
                        "type": 9,
                        "typeName": "",
                        "extendee": "",
                        "defaultValue": "",
                        "oneofIndex": 0,
                        "jsonName": "services",
                        "options": undefined,
                        "proto3Optional": false,
                    }, {
                        "name": "payload",
                        "number": 2,
                        "label": 1,
                        "type": 11,
                        "typeName": ".google.protobuf.Any",
                        "extendee": "",
                        "defaultValue": "",
                        "oneofIndex": 0,
                        "jsonName": "payload",
                        "options": undefined,
                        "proto3Optional": true,
                    }],
                "extension": [],
                "nestedType": [],
                "enumType": [],
                "extensionRange": [],
                "oneofDecl": [{ "name": "_payload", "options": undefined }],
                "options": undefined,
                "reservedRange": [],
                "reservedName": [],
                "visibility": 0,
            }],
        "enumType": [],
        "service": [{
                "name": "CommandInterfaceService",
                "method": [{
                        "name": "Command",
                        "inputType": ".io.restorecommerce.commandinterface.CommandRequest",
                        "outputType": ".google.protobuf.Any",
                        "options": undefined,
                        "clientStreaming": false,
                        "serverStreaming": false,
                    }],
                "options": undefined,
            }],
        "extension": [],
        "options": undefined,
        "sourceCodeInfo": {
            "location": [{
                    "path": [4, 0],
                    "span": [9, 0, 14, 1],
                    "leadingComments": " used to send requests through Kafka or gRPC\n",
                    "trailingComments": "",
                    "leadingDetachedComments": [],
                }, {
                    "path": [4, 0, 2, 0],
                    "span": [11, 2, 27],
                    "leadingComments": "  command identifier (used to demultiplex operation in the command implementation)\n",
                    "trailingComments": "",
                    "leadingDetachedComments": [],
                }, {
                    "path": [4, 0, 2, 1],
                    "span": [12, 2, 43],
                    "leadingComments": "",
                    "trailingComments": " variable payload\n",
                    "leadingDetachedComments": [],
                }, {
                    "path": [4, 1],
                    "span": [17, 0, 23, 1],
                    "leadingComments": " used to push responses to Kafka\n",
                    "trailingComments": "",
                    "leadingDetachedComments": [],
                }, {
                    "path": [4, 1, 2, 0],
                    "span": [21, 2, 31],
                    "leadingComments": " service identifiers\n (multiple services may reply to one system command)\n (multiple service names can be bound to one microservice)\n",
                    "trailingComments": "",
                    "leadingDetachedComments": [],
                }, {
                    "path": [4, 1, 2, 1],
                    "span": [22, 2, 43],
                    "leadingComments": "",
                    "trailingComments": " variable payload\n",
                    "leadingDetachedComments": [],
                }, {
                    "path": [6, 0],
                    "span": [28, 0, 30, 1],
                    "leadingComments": "*\n RPC service for executing commands\n",
                    "trailingComments": "",
                    "leadingDetachedComments": [],
                }],
        },
        "syntax": "proto3",
        "edition": 0,
    },
    references: {
        ".io.restorecommerce.commandinterface.CommandRequest": exports.CommandRequest,
        ".io.restorecommerce.commandinterface.CommandResponse": exports.CommandResponse,
    },
    dependencies: [any_1.protoMetadata, auth_1.protoMetadata, options_1.protoMetadata],
};
function isSet(value) {
    return value !== null && value !== undefined;
}
//# sourceMappingURL=commandinterface.js.map