"use strict";
/*
 * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT.
 */
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
    if (k2 === undefined) k2 = k;
    var desc = Object.getOwnPropertyDescriptor(m, k);
    if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
      desc = { enumerable: true, get: function() { return m[k]; } };
    }
    Object.defineProperty(o, k2, desc);
}) : (function(o, m, k, k2) {
    if (k2 === undefined) k2 = k;
    o[k2] = m[k];
}));
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
    Object.defineProperty(o, "default", { enumerable: true, value: v });
}) : function(o, v) {
    o["default"] = v;
});
var __importStar = (this && this.__importStar) || (function () {
    var ownKeys = function(o) {
        ownKeys = Object.getOwnPropertyNames || function (o) {
            var ar = [];
            for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
            return ar;
        };
        return ownKeys(o);
    };
    return function (mod) {
        if (mod && mod.__esModule) return mod;
        var result = {};
        if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
        __setModuleDefault(result, mod);
        return result;
    };
})();
Object.defineProperty(exports, "__esModule", { value: true });
exports.ConnectionInput$outboundSchema = exports.ConnectionConfiguration$outboundSchema = exports.ConnectionDefaults$outboundSchema = exports.Connection$inboundSchema = exports.Health$inboundSchema = exports.Configuration$inboundSchema = exports.Defaults$inboundSchema = exports.ConnectionValue$outboundSchema = exports.ConnectionValue$inboundSchema = exports.Value5$outboundSchema = exports.Value5$inboundSchema = exports.Target$inboundSchema = exports.ConnectionStatus$inboundSchema = exports.Health = exports.Target = exports.ConnectionStatus = void 0;
exports.value5ToJSON = value5ToJSON;
exports.value5FromJSON = value5FromJSON;
exports.connectionValueToJSON = connectionValueToJSON;
exports.connectionValueFromJSON = connectionValueFromJSON;
exports.defaultsFromJSON = defaultsFromJSON;
exports.configurationFromJSON = configurationFromJSON;
exports.connectionFromJSON = connectionFromJSON;
exports.connectionDefaultsToJSON = connectionDefaultsToJSON;
exports.connectionConfigurationToJSON = connectionConfigurationToJSON;
exports.connectionInputToJSON = connectionInputToJSON;
const z = __importStar(require("zod/v3"));
const primitives_js_1 = require("../../lib/primitives.js");
const schemas_js_1 = require("../../lib/schemas.js");
const openEnums = __importStar(require("../../types/enums.js"));
const types = __importStar(require("../../types/primitives.js"));
const smartUnion_js_1 = require("../../types/smartUnion.js");
const authtype_js_1 = require("./authtype.js");
const connectionstate_js_1 = require("./connectionstate.js");
const consentrecord_js_1 = require("./consentrecord.js");
const consentrecordinput_js_1 = require("./consentrecordinput.js");
const consentstate_js_1 = require("./consentstate.js");
const custommapping_js_1 = require("./custommapping.js");
const custommappinginput_js_1 = require("./custommappinginput.js");
const datascopes_js_1 = require("./datascopes.js");
const datascopesinput_js_1 = require("./datascopesinput.js");
const formfield_js_1 = require("./formfield.js");
const formfieldoption_js_1 = require("./formfieldoption.js");
const integrationstate_js_1 = require("./integrationstate.js");
const oauthgranttype_js_1 = require("./oauthgranttype.js");
const webhooksubscription_js_1 = require("./webhooksubscription.js");
/**
 * Status of the connection.
 */
exports.ConnectionStatus = {
    Live: "live",
    Upcoming: "upcoming",
    Requested: "requested",
};
exports.Target = {
    CustomFields: "custom_fields",
    Resource: "resource",
};
/**
 * Operational health status of the connection
 */
exports.Health = {
    Revoked: "revoked",
    MissingSettings: "missing_settings",
    NeedsConsent: "needs_consent",
    NeedsAuth: "needs_auth",
    PendingRefresh: "pending_refresh",
    Ok: "ok",
};
/** @internal */
exports.ConnectionStatus$inboundSchema = openEnums.inboundSchema(exports.ConnectionStatus);
/** @internal */
exports.Target$inboundSchema = openEnums.inboundSchema(exports.Target);
/** @internal */
exports.Value5$inboundSchema = (0, smartUnion_js_1.smartUnion)([types.string(), types.number(), types.number()]);
/** @internal */
exports.Value5$outboundSchema = (0, smartUnion_js_1.smartUnion)([z.string(), z.number().int(), z.number()]);
function value5ToJSON(value5) {
    return JSON.stringify(exports.Value5$outboundSchema.parse(value5));
}
function value5FromJSON(jsonString) {
    return (0, schemas_js_1.safeParse)(jsonString, (x) => exports.Value5$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'Value5' from JSON`);
}
/** @internal */
exports.ConnectionValue$inboundSchema = (0, smartUnion_js_1.smartUnion)([
    types.string(),
    types.number(),
    types.number(),
    types.boolean(),
    z.array((0, smartUnion_js_1.smartUnion)([types.string(), types.number(), types.number()])),
]);
/** @internal */
exports.ConnectionValue$outboundSchema = (0, smartUnion_js_1.smartUnion)([
    z.string(),
    z.number().int(),
    z.number(),
    z.boolean(),
    z.array((0, smartUnion_js_1.smartUnion)([z.string(), z.number().int(), z.number()])),
]);
function connectionValueToJSON(connectionValue) {
    return JSON.stringify(exports.ConnectionValue$outboundSchema.parse(connectionValue));
}
function connectionValueFromJSON(jsonString) {
    return (0, schemas_js_1.safeParse)(jsonString, (x) => exports.ConnectionValue$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'ConnectionValue' from JSON`);
}
/** @internal */
exports.Defaults$inboundSchema = z.object({
    target: types.optional(exports.Target$inboundSchema),
    id: types.optional(types.string()),
    options: types.optional(z.array(formfieldoption_js_1.FormFieldOption$inboundSchema)),
    value: types.optional((0, smartUnion_js_1.smartUnion)([
        types.string(),
        types.number(),
        types.number(),
        types.boolean(),
        z.array((0, smartUnion_js_1.smartUnion)([types.string(), types.number(), types.number()])),
    ])),
});
function defaultsFromJSON(jsonString) {
    return (0, schemas_js_1.safeParse)(jsonString, (x) => exports.Defaults$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'Defaults' from JSON`);
}
/** @internal */
exports.Configuration$inboundSchema = z.object({
    resource: types.optional(types.string()),
    defaults: types.optional(z.array(z.lazy(() => exports.Defaults$inboundSchema))),
});
function configurationFromJSON(jsonString) {
    return (0, schemas_js_1.safeParse)(jsonString, (x) => exports.Configuration$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'Configuration' from JSON`);
}
/** @internal */
exports.Health$inboundSchema = openEnums.inboundSchema(exports.Health);
/** @internal */
exports.Connection$inboundSchema = z.object({
    id: types.optional(types.string()),
    service_id: types.optional(types.string()),
    name: types.optional(types.string()),
    tag_line: types.optional(types.string()),
    unified_api: types.optional(types.string()),
    state: types.optional(connectionstate_js_1.ConnectionState$inboundSchema),
    integration_state: types.optional(integrationstate_js_1.IntegrationState$inboundSchema),
    auth_type: types.optional(authtype_js_1.AuthType$inboundSchema),
    oauth_grant_type: types.optional(oauthgranttype_js_1.OAuthGrantType$inboundSchema),
    status: types.optional(exports.ConnectionStatus$inboundSchema),
    enabled: types.optional(types.boolean()),
    website: types.optional(types.string()),
    icon: types.optional(types.string()),
    logo: types.optional(types.string()),
    authorize_url: z.nullable(types.string()).optional(),
    revoke_url: z.nullable(types.string()).optional(),
    settings: z.nullable(z.record(z.any())).optional(),
    metadata: z.nullable(z.record(z.any())).optional(),
    form_fields: types.optional(z.array(formfield_js_1.FormField$inboundSchema)),
    configuration: types.optional(z.array(z.lazy(() => exports.Configuration$inboundSchema))),
    configurable_resources: types.optional(z.array(types.string())),
    resource_schema_support: types.optional(z.array(types.string())),
    resource_settings_support: types.optional(z.array(types.string())),
    validation_support: types.optional(types.boolean()),
    schema_support: types.optional(types.boolean()),
    settings_required_for_authorization: types.optional(z.array(types.string())),
    subscriptions: types.optional(z.array(webhooksubscription_js_1.WebhookSubscription$inboundSchema)),
    has_guide: types.optional(types.boolean()),
    custom_mappings: types.optional(z.array(custommapping_js_1.CustomMapping$inboundSchema)),
    consent_state: types.optional(consentstate_js_1.ConsentState$inboundSchema),
    consents: types.optional(z.array(consentrecord_js_1.ConsentRecord$inboundSchema)),
    latest_consent: types.optional(consentrecord_js_1.ConsentRecord$inboundSchema),
    application_data_scopes: types.optional(datascopes_js_1.DataScopes$inboundSchema),
    health: types.optional(exports.Health$inboundSchema),
    credentials_expire_at: types.optional(types.number()),
    last_refresh_failed_at: types.optional(types.number()),
    created_at: types.optional(types.number()),
    updated_at: z.nullable(types.number()).optional(),
}).transform((v) => {
    return (0, primitives_js_1.remap)(v, {
        "service_id": "serviceId",
        "tag_line": "tagLine",
        "unified_api": "unifiedApi",
        "integration_state": "integrationState",
        "auth_type": "authType",
        "oauth_grant_type": "oauthGrantType",
        "authorize_url": "authorizeUrl",
        "revoke_url": "revokeUrl",
        "form_fields": "formFields",
        "configurable_resources": "configurableResources",
        "resource_schema_support": "resourceSchemaSupport",
        "resource_settings_support": "resourceSettingsSupport",
        "validation_support": "validationSupport",
        "schema_support": "schemaSupport",
        "settings_required_for_authorization": "settingsRequiredForAuthorization",
        "has_guide": "hasGuide",
        "custom_mappings": "customMappings",
        "consent_state": "consentState",
        "latest_consent": "latestConsent",
        "application_data_scopes": "applicationDataScopes",
        "credentials_expire_at": "credentialsExpireAt",
        "last_refresh_failed_at": "lastRefreshFailedAt",
        "created_at": "createdAt",
        "updated_at": "updatedAt",
    });
});
function connectionFromJSON(jsonString) {
    return (0, schemas_js_1.safeParse)(jsonString, (x) => exports.Connection$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'Connection' from JSON`);
}
/** @internal */
exports.ConnectionDefaults$outboundSchema = z.object({
    id: z.string().optional(),
    options: z.array(formfieldoption_js_1.FormFieldOption$outboundSchema).optional(),
    value: (0, smartUnion_js_1.smartUnion)([
        z.string(),
        z.number().int(),
        z.number(),
        z.boolean(),
        z.array((0, smartUnion_js_1.smartUnion)([z.string(), z.number().int(), z.number()])),
    ]).optional(),
});
function connectionDefaultsToJSON(connectionDefaults) {
    return JSON.stringify(exports.ConnectionDefaults$outboundSchema.parse(connectionDefaults));
}
/** @internal */
exports.ConnectionConfiguration$outboundSchema = z.object({
    resource: z.string().optional(),
    defaults: z.array(z.lazy(() => exports.ConnectionDefaults$outboundSchema)).optional(),
});
function connectionConfigurationToJSON(connectionConfiguration) {
    return JSON.stringify(exports.ConnectionConfiguration$outboundSchema.parse(connectionConfiguration));
}
/** @internal */
exports.ConnectionInput$outboundSchema = z.object({
    enabled: z.boolean().optional(),
    settings: z.nullable(z.record(z.any())).optional(),
    metadata: z.nullable(z.record(z.any())).optional(),
    configuration: z.array(z.lazy(() => exports.ConnectionConfiguration$outboundSchema))
        .optional(),
    customMappings: z.array(custommappinginput_js_1.CustomMappingInput$outboundSchema).optional(),
    consentState: consentstate_js_1.ConsentState$outboundSchema.optional(),
    latestConsent: consentrecordinput_js_1.ConsentRecordInput$outboundSchema.optional(),
    applicationDataScopes: datascopesinput_js_1.DataScopesInput$outboundSchema.optional(),
}).transform((v) => {
    return (0, primitives_js_1.remap)(v, {
        customMappings: "custom_mappings",
        consentState: "consent_state",
        latestConsent: "latest_consent",
        applicationDataScopes: "application_data_scopes",
    });
});
function connectionInputToJSON(connectionInput) {
    return JSON.stringify(exports.ConnectionInput$outboundSchema.parse(connectionInput));
}
//# sourceMappingURL=connection.js.map