"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.SuperblocksError = exports.ErrorDto = exports.ResponseMeta = exports.ApiV2WithIntegrationsResponseWrapper = exports.ResponseWrapper = void 0;
exports.isResponseMetadata = isResponseMetadata;
class ResponseWrapper {
    responseMeta;
    data;
    api;
    intergrations;
    constructor({ data }) {
        this.responseMeta = new ResponseMeta({
            status: 200,
            message: '',
            success: true
        });
        this.data = data;
    }
}
exports.ResponseWrapper = ResponseWrapper;
class ApiV2WithIntegrationsResponseWrapper {
    api;
    integrations;
    metadata;
    stores;
    constructor(api, integrations, metadata, stores) {
        this.api = api;
        this.integrations = integrations;
        this.metadata = metadata;
        this.stores = stores;
    }
}
exports.ApiV2WithIntegrationsResponseWrapper = ApiV2WithIntegrationsResponseWrapper;
class ResponseMeta {
    status;
    message;
    success;
    error;
    timing;
    constructor({ status, message, success }) {
        this.status = status;
        this.message = message;
        this.success = success;
    }
}
exports.ResponseMeta = ResponseMeta;
class ErrorDto {
    code;
    message;
    superblocksError;
    constructor({ code, message, type }) {
        this.code = code;
        this.message = message;
        this.superblocksError = type;
    }
}
exports.ErrorDto = ErrorDto;
/**
 * To let UI know if http error is caused by superblocks or external
 * This enum is intended to provide additional information on top of general
 * error code and message
 */
var SuperblocksError;
(function (SuperblocksError) {
    SuperblocksError["RbacUnauthorized"] = "RbacUnauthorized";
    SuperblocksError["APIKeyInvalid"] = "APIKeyInvalid";
    SuperblocksError["AuthenticatedUserNotFound"] = "AuthenticatedUserNotFound";
    SuperblocksError["UserTokenInvalid"] = "UserTokenInvalid";
    SuperblocksError["JWTExpired"] = "JWTExpired";
})(SuperblocksError || (exports.SuperblocksError = SuperblocksError = {}));
/**
 * Type guard to check if an object is a ResponseMeta
 * Works with both class instances and serialized objects (from API responses)
 */
function isResponseMetadata(responseMetadata) {
    if (responseMetadata instanceof ResponseMeta) {
        return true;
    }
    return (typeof responseMetadata === 'object' &&
        responseMetadata !== null &&
        'status' in responseMetadata &&
        typeof responseMetadata.status === 'number' &&
        'message' in responseMetadata &&
        typeof responseMetadata.message === 'string');
}
//# sourceMappingURL=response.js.map