UNPKG

toggl-webhook

Version:
693 lines (691 loc) 32.3 kB
"use strict"; var __defProp = Object.defineProperty; var __name = (target, value) => __defProp(target, "name", { value, configurable: true }); // src/api/v1/schemas/validations.js var CreateSubscriptionParams = validate10; var schema13 = { "$id": "EventAction", "$schema": "http://json-schema.org/draft-07/schema#", "type": "string", "enum": ["created", "updated", "deleted"] }; function validate11(data, { instancePath = "", parentData, parentDataProperty, rootData = data } = {}) { ; let vErrors = null; let errors = 0; if (errors === 0) { if (data && typeof data == "object" && !Array.isArray(data)) { let missing0; if (data.entity === void 0 && (missing0 = "entity") || data.action === void 0 && (missing0 = "action")) { validate11.errors = [{ instancePath, schemaPath: "#/required", keyword: "required", params: { missingProperty: missing0 }, message: "must have required property '" + missing0 + "'" }]; return false; } else { const _errs1 = errors; for (const key0 in data) { if (!(key0 === "entity" || key0 === "action")) { validate11.errors = [{ instancePath, schemaPath: "#/additionalProperties", keyword: "additionalProperties", params: { additionalProperty: key0 }, message: "must NOT have additional properties" }]; return false; break; } } if (_errs1 === errors) { if (data.entity !== void 0) { const _errs2 = errors; if (typeof data.entity !== "string") { validate11.errors = [{ instancePath: instancePath + "/entity", schemaPath: "#/properties/entity/type", keyword: "type", params: { type: "string" }, message: "must be string" }]; return false; } var valid0 = _errs2 === errors; } else { var valid0 = true; } if (valid0) { if (data.action !== void 0) { let data1 = data.action; const _errs4 = errors; const _errs5 = errors; let valid1 = false; const _errs6 = errors; if (typeof data1 !== "string") { const err0 = { instancePath: instancePath + "/action", schemaPath: "#/properties/action/anyOf/0/type", keyword: "type", params: { type: "string" }, message: "must be string" }; if (vErrors === null) { vErrors = [err0]; } else { vErrors.push(err0); } errors++; } if (data1 !== "*") { const err1 = { instancePath: instancePath + "/action", schemaPath: "#/properties/action/anyOf/0/const", keyword: "const", params: { allowedValue: "*" }, message: "must be equal to constant" }; if (vErrors === null) { vErrors = [err1]; } else { vErrors.push(err1); } errors++; } var _valid0 = _errs6 === errors; valid1 = valid1 || _valid0; if (!valid1) { const _errs8 = errors; if (typeof data1 !== "string") { const err2 = { instancePath: instancePath + "/action", schemaPath: "EventAction/type", keyword: "type", params: { type: "string" }, message: "must be string" }; if (vErrors === null) { vErrors = [err2]; } else { vErrors.push(err2); } errors++; } if (!(data1 === "created" || data1 === "updated" || data1 === "deleted")) { const err3 = { instancePath: instancePath + "/action", schemaPath: "EventAction/enum", keyword: "enum", params: { allowedValues: schema13.enum }, message: "must be equal to one of the allowed values" }; if (vErrors === null) { vErrors = [err3]; } else { vErrors.push(err3); } errors++; } var _valid0 = _errs8 === errors; valid1 = valid1 || _valid0; } if (!valid1) { const err4 = { instancePath: instancePath + "/action", schemaPath: "#/properties/action/anyOf", keyword: "anyOf", params: {}, message: "must match a schema in anyOf" }; if (vErrors === null) { vErrors = [err4]; } else { vErrors.push(err4); } errors++; validate11.errors = vErrors; return false; } else { errors = _errs5; if (vErrors !== null) { if (_errs5) { vErrors.length = _errs5; } else { vErrors = null; } } } var valid0 = _errs4 === errors; } else { var valid0 = true; } } } } } else { validate11.errors = [{ instancePath, schemaPath: "#/type", keyword: "type", params: { type: "object" }, message: "must be object" }]; return false; } } validate11.errors = vErrors; return errors === 0; } __name(validate11, "validate11"); function validate10(data, { instancePath = "", parentData, parentDataProperty, rootData = data } = {}) { ; let vErrors = null; let errors = 0; if (errors === 0) { if (data && typeof data == "object" && !Array.isArray(data)) { let missing0; if (data.workspace_id === void 0 && (missing0 = "workspace_id") || data.url_callback === void 0 && (missing0 = "url_callback") || data.event_filters === void 0 && (missing0 = "event_filters") || data.description === void 0 && (missing0 = "description")) { validate10.errors = [{ instancePath, schemaPath: "#/required", keyword: "required", params: { missingProperty: missing0 }, message: "must have required property '" + missing0 + "'" }]; return false; } else { const _errs1 = errors; for (const key0 in data) { if (!(key0 === "workspace_id" || key0 === "url_callback" || key0 === "event_filters" || key0 === "description" || key0 === "enabled" || key0 === "secret")) { validate10.errors = [{ instancePath, schemaPath: "#/additionalProperties", keyword: "additionalProperties", params: { additionalProperty: key0 }, message: "must NOT have additional properties" }]; return false; break; } } if (_errs1 === errors) { if (data.workspace_id !== void 0) { let data0 = data.workspace_id; const _errs2 = errors; if (!(typeof data0 == "number" && isFinite(data0))) { validate10.errors = [{ instancePath: instancePath + "/workspace_id", schemaPath: "#/properties/workspace_id/type", keyword: "type", params: { type: "number" }, message: "must be number" }]; return false; } var valid0 = _errs2 === errors; } else { var valid0 = true; } if (valid0) { if (data.url_callback !== void 0) { const _errs4 = errors; if (typeof data.url_callback !== "string") { validate10.errors = [{ instancePath: instancePath + "/url_callback", schemaPath: "#/properties/url_callback/type", keyword: "type", params: { type: "string" }, message: "must be string" }]; return false; } var valid0 = _errs4 === errors; } else { var valid0 = true; } if (valid0) { if (data.event_filters !== void 0) { let data2 = data.event_filters; const _errs6 = errors; if (errors === _errs6) { if (Array.isArray(data2)) { var valid1 = true; const len0 = data2.length; for (let i0 = 0; i0 < len0; i0++) { const _errs8 = errors; if (!validate11(data2[i0], { instancePath: instancePath + "/event_filters/" + i0, parentData: data2, parentDataProperty: i0, rootData })) { vErrors = vErrors === null ? validate11.errors : vErrors.concat(validate11.errors); errors = vErrors.length; } var valid1 = _errs8 === errors; if (!valid1) { break; } } } else { validate10.errors = [{ instancePath: instancePath + "/event_filters", schemaPath: "#/properties/event_filters/type", keyword: "type", params: { type: "array" }, message: "must be array" }]; return false; } } var valid0 = _errs6 === errors; } else { var valid0 = true; } if (valid0) { if (data.description !== void 0) { const _errs9 = errors; if (typeof data.description !== "string") { validate10.errors = [{ instancePath: instancePath + "/description", schemaPath: "#/properties/description/type", keyword: "type", params: { type: "string" }, message: "must be string" }]; return false; } var valid0 = _errs9 === errors; } else { var valid0 = true; } if (valid0) { if (data.enabled !== void 0) { const _errs11 = errors; if (typeof data.enabled !== "boolean") { validate10.errors = [{ instancePath: instancePath + "/enabled", schemaPath: "#/properties/enabled/type", keyword: "type", params: { type: "boolean" }, message: "must be boolean" }]; return false; } var valid0 = _errs11 === errors; } else { var valid0 = true; } if (valid0) { if (data.secret !== void 0) { const _errs13 = errors; if (typeof data.secret !== "string") { validate10.errors = [{ instancePath: instancePath + "/secret", schemaPath: "#/properties/secret/type", keyword: "type", params: { type: "string" }, message: "must be string" }]; return false; } var valid0 = _errs13 === errors; } else { var valid0 = true; } } } } } } } } } else { validate10.errors = [{ instancePath, schemaPath: "#/type", keyword: "type", params: { type: "object" }, message: "must be object" }]; return false; } } validate10.errors = vErrors; return errors === 0; } __name(validate10, "validate10"); var EventFilter = validate11; var EventAction = validate13; function validate13(data, { instancePath = "", parentData, parentDataProperty, rootData = data } = {}) { ; let vErrors = null; let errors = 0; if (typeof data !== "string") { validate13.errors = [{ instancePath, schemaPath: "#/type", keyword: "type", params: { type: "string" }, message: "must be string" }]; return false; } if (!(data === "created" || data === "updated" || data === "deleted")) { validate13.errors = [{ instancePath, schemaPath: "#/enum", keyword: "enum", params: { allowedValues: schema13.enum }, message: "must be equal to one of the allowed values" }]; return false; } validate13.errors = vErrors; return errors === 0; } __name(validate13, "validate13"); var UpdateSubscriptionParams = validate14; function validate14(data, { instancePath = "", parentData, parentDataProperty, rootData = data } = {}) { ; let vErrors = null; let errors = 0; if (errors === 0) { if (data && typeof data == "object" && !Array.isArray(data)) { let missing0; if (data.description === void 0 && (missing0 = "description") || data.event_filters === void 0 && (missing0 = "event_filters") || data.subscription_id === void 0 && (missing0 = "subscription_id") || data.url_callback === void 0 && (missing0 = "url_callback") || data.workspace_id === void 0 && (missing0 = "workspace_id")) { validate14.errors = [{ instancePath, schemaPath: "#/required", keyword: "required", params: { missingProperty: missing0 }, message: "must have required property '" + missing0 + "'" }]; return false; } else { const _errs1 = errors; for (const key0 in data) { if (!(key0 === "workspace_id" || key0 === "url_callback" || key0 === "event_filters" || key0 === "description" || key0 === "enabled" || key0 === "secret" || key0 === "subscription_id")) { validate14.errors = [{ instancePath, schemaPath: "#/additionalProperties", keyword: "additionalProperties", params: { additionalProperty: key0 }, message: "must NOT have additional properties" }]; return false; break; } } if (_errs1 === errors) { if (data.workspace_id !== void 0) { let data0 = data.workspace_id; const _errs2 = errors; if (!(typeof data0 == "number" && isFinite(data0))) { validate14.errors = [{ instancePath: instancePath + "/workspace_id", schemaPath: "#/properties/workspace_id/type", keyword: "type", params: { type: "number" }, message: "must be number" }]; return false; } var valid0 = _errs2 === errors; } else { var valid0 = true; } if (valid0) { if (data.url_callback !== void 0) { const _errs4 = errors; if (typeof data.url_callback !== "string") { validate14.errors = [{ instancePath: instancePath + "/url_callback", schemaPath: "#/properties/url_callback/type", keyword: "type", params: { type: "string" }, message: "must be string" }]; return false; } var valid0 = _errs4 === errors; } else { var valid0 = true; } if (valid0) { if (data.event_filters !== void 0) { let data2 = data.event_filters; const _errs6 = errors; if (errors === _errs6) { if (Array.isArray(data2)) { var valid1 = true; const len0 = data2.length; for (let i0 = 0; i0 < len0; i0++) { const _errs8 = errors; if (!validate11(data2[i0], { instancePath: instancePath + "/event_filters/" + i0, parentData: data2, parentDataProperty: i0, rootData })) { vErrors = vErrors === null ? validate11.errors : vErrors.concat(validate11.errors); errors = vErrors.length; } var valid1 = _errs8 === errors; if (!valid1) { break; } } } else { validate14.errors = [{ instancePath: instancePath + "/event_filters", schemaPath: "#/properties/event_filters/type", keyword: "type", params: { type: "array" }, message: "must be array" }]; return false; } } var valid0 = _errs6 === errors; } else { var valid0 = true; } if (valid0) { if (data.description !== void 0) { const _errs9 = errors; if (typeof data.description !== "string") { validate14.errors = [{ instancePath: instancePath + "/description", schemaPath: "#/properties/description/type", keyword: "type", params: { type: "string" }, message: "must be string" }]; return false; } var valid0 = _errs9 === errors; } else { var valid0 = true; } if (valid0) { if (data.enabled !== void 0) { const _errs11 = errors; if (typeof data.enabled !== "boolean") { validate14.errors = [{ instancePath: instancePath + "/enabled", schemaPath: "#/properties/enabled/type", keyword: "type", params: { type: "boolean" }, message: "must be boolean" }]; return false; } var valid0 = _errs11 === errors; } else { var valid0 = true; } if (valid0) { if (data.secret !== void 0) { const _errs13 = errors; if (typeof data.secret !== "string") { validate14.errors = [{ instancePath: instancePath + "/secret", schemaPath: "#/properties/secret/type", keyword: "type", params: { type: "string" }, message: "must be string" }]; return false; } var valid0 = _errs13 === errors; } else { var valid0 = true; } if (valid0) { if (data.subscription_id !== void 0) { let data7 = data.subscription_id; const _errs15 = errors; if (!(typeof data7 == "number" && isFinite(data7))) { validate14.errors = [{ instancePath: instancePath + "/subscription_id", schemaPath: "#/properties/subscription_id/type", keyword: "type", params: { type: "number" }, message: "must be number" }]; return false; } var valid0 = _errs15 === errors; } else { var valid0 = true; } } } } } } } } } } else { validate14.errors = [{ instancePath, schemaPath: "#/type", keyword: "type", params: { type: "object" }, message: "must be object" }]; return false; } } validate14.errors = vErrors; return errors === 0; } __name(validate14, "validate14"); var DeleteSubscriptionParams = validate16; function validate16(data, { instancePath = "", parentData, parentDataProperty, rootData = data } = {}) { ; let vErrors = null; let errors = 0; if (errors === 0) { if (data && typeof data == "object" && !Array.isArray(data)) { let missing0; if (data.workspace_id === void 0 && (missing0 = "workspace_id") || data.subscription_id === void 0 && (missing0 = "subscription_id")) { validate16.errors = [{ instancePath, schemaPath: "#/required", keyword: "required", params: { missingProperty: missing0 }, message: "must have required property '" + missing0 + "'" }]; return false; } else { const _errs1 = errors; for (const key0 in data) { if (!(key0 === "workspace_id" || key0 === "subscription_id")) { validate16.errors = [{ instancePath, schemaPath: "#/additionalProperties", keyword: "additionalProperties", params: { additionalProperty: key0 }, message: "must NOT have additional properties" }]; return false; break; } } if (_errs1 === errors) { if (data.workspace_id !== void 0) { let data0 = data.workspace_id; const _errs2 = errors; if (!(typeof data0 == "number" && isFinite(data0))) { validate16.errors = [{ instancePath: instancePath + "/workspace_id", schemaPath: "#/properties/workspace_id/type", keyword: "type", params: { type: "number" }, message: "must be number" }]; return false; } var valid0 = _errs2 === errors; } else { var valid0 = true; } if (valid0) { if (data.subscription_id !== void 0) { let data1 = data.subscription_id; const _errs4 = errors; if (!(typeof data1 == "number" && isFinite(data1))) { validate16.errors = [{ instancePath: instancePath + "/subscription_id", schemaPath: "#/properties/subscription_id/type", keyword: "type", params: { type: "number" }, message: "must be number" }]; return false; } var valid0 = _errs4 === errors; } else { var valid0 = true; } } } } } else { validate16.errors = [{ instancePath, schemaPath: "#/type", keyword: "type", params: { type: "object" }, message: "must be object" }]; return false; } } validate16.errors = vErrors; return errors === 0; } __name(validate16, "validate16"); var ListSubscriptionsParams = validate17; function validate17(data, { instancePath = "", parentData, parentDataProperty, rootData = data } = {}) { ; let vErrors = null; let errors = 0; if (errors === 0) { if (data && typeof data == "object" && !Array.isArray(data)) { let missing0; if (data.workspace_id === void 0 && (missing0 = "workspace_id")) { validate17.errors = [{ instancePath, schemaPath: "#/required", keyword: "required", params: { missingProperty: missing0 }, message: "must have required property '" + missing0 + "'" }]; return false; } else { const _errs1 = errors; for (const key0 in data) { if (!(key0 === "workspace_id")) { validate17.errors = [{ instancePath, schemaPath: "#/additionalProperties", keyword: "additionalProperties", params: { additionalProperty: key0 }, message: "must NOT have additional properties" }]; return false; break; } } if (_errs1 === errors) { if (data.workspace_id !== void 0) { let data0 = data.workspace_id; if (!(typeof data0 == "number" && isFinite(data0))) { validate17.errors = [{ instancePath: instancePath + "/workspace_id", schemaPath: "#/properties/workspace_id/type", keyword: "type", params: { type: "number" }, message: "must be number" }]; return false; } } } } } else { validate17.errors = [{ instancePath, schemaPath: "#/type", keyword: "type", params: { type: "object" }, message: "must be object" }]; return false; } } validate17.errors = vErrors; return errors === 0; } __name(validate17, "validate17"); var ListSubscriptionEventsParams = validate18; function validate18(data, { instancePath = "", parentData, parentDataProperty, rootData = data } = {}) { ; let vErrors = null; let errors = 0; if (errors === 0) { if (data && typeof data == "object" && !Array.isArray(data)) { let missing0; if (data.workspace_id === void 0 && (missing0 = "workspace_id") || data.subscription_id === void 0 && (missing0 = "subscription_id")) { validate18.errors = [{ instancePath, schemaPath: "#/required", keyword: "required", params: { missingProperty: missing0 }, message: "must have required property '" + missing0 + "'" }]; return false; } else { const _errs1 = errors; for (const key0 in data) { if (!(key0 === "workspace_id" || key0 === "subscription_id" || key0 === "offset")) { validate18.errors = [{ instancePath, schemaPath: "#/additionalProperties", keyword: "additionalProperties", params: { additionalProperty: key0 }, message: "must NOT have additional properties" }]; return false; break; } } if (_errs1 === errors) { if (data.workspace_id !== void 0) { let data0 = data.workspace_id; const _errs2 = errors; if (!(typeof data0 == "number" && isFinite(data0))) { validate18.errors = [{ instancePath: instancePath + "/workspace_id", schemaPath: "#/properties/workspace_id/type", keyword: "type", params: { type: "number" }, message: "must be number" }]; return false; } var valid0 = _errs2 === errors; } else { var valid0 = true; } if (valid0) { if (data.subscription_id !== void 0) { let data1 = data.subscription_id; const _errs4 = errors; if (!(typeof data1 == "number" && isFinite(data1))) { validate18.errors = [{ instancePath: instancePath + "/subscription_id", schemaPath: "#/properties/subscription_id/type", keyword: "type", params: { type: "number" }, message: "must be number" }]; return false; } var valid0 = _errs4 === errors; } else { var valid0 = true; } if (valid0) { if (data.offset !== void 0) { let data2 = data.offset; const _errs6 = errors; if (!(typeof data2 == "number" && isFinite(data2))) { validate18.errors = [{ instancePath: instancePath + "/offset", schemaPath: "#/properties/offset/type", keyword: "type", params: { type: "number" }, message: "must be number" }]; return false; } var valid0 = _errs6 === errors; } else { var valid0 = true; } } } } } } else { validate18.errors = [{ instancePath, schemaPath: "#/type", keyword: "type", params: { type: "object" }, message: "must be object" }]; return false; } } validate18.errors = vErrors; return errors === 0; } __name(validate18, "validate18"); var PingSubscriptionParams = validate19; function validate19(data, { instancePath = "", parentData, parentDataProperty, rootData = data } = {}) { ; let vErrors = null; let errors = 0; if (errors === 0) { if (data && typeof data == "object" && !Array.isArray(data)) { let missing0; if (data.workspace_id === void 0 && (missing0 = "workspace_id") || data.subscription_id === void 0 && (missing0 = "subscription_id")) { validate19.errors = [{ instancePath, schemaPath: "#/required", keyword: "required", params: { missingProperty: missing0 }, message: "must have required property '" + missing0 + "'" }]; return false; } else { const _errs1 = errors; for (const key0 in data) { if (!(key0 === "workspace_id" || key0 === "subscription_id")) { validate19.errors = [{ instancePath, schemaPath: "#/additionalProperties", keyword: "additionalProperties", params: { additionalProperty: key0 }, message: "must NOT have additional properties" }]; return false; break; } } if (_errs1 === errors) { if (data.workspace_id !== void 0) { let data0 = data.workspace_id; const _errs2 = errors; if (!(typeof data0 == "number" && isFinite(data0))) { validate19.errors = [{ instancePath: instancePath + "/workspace_id", schemaPath: "#/properties/workspace_id/type", keyword: "type", params: { type: "number" }, message: "must be number" }]; return false; } var valid0 = _errs2 === errors; } else { var valid0 = true; } if (valid0) { if (data.subscription_id !== void 0) { let data1 = data.subscription_id; const _errs4 = errors; if (!(typeof data1 == "number" && isFinite(data1))) { validate19.errors = [{ instancePath: instancePath + "/subscription_id", schemaPath: "#/properties/subscription_id/type", keyword: "type", params: { type: "number" }, message: "must be number" }]; return false; } var valid0 = _errs4 === errors; } else { var valid0 = true; } } } } } else { validate19.errors = [{ instancePath, schemaPath: "#/type", keyword: "type", params: { type: "object" }, message: "must be object" }]; return false; } } validate19.errors = vErrors; return errors === 0; } __name(validate19, "validate19"); var SetSubscriptionEnabledParams = validate20; function validate20(data, { instancePath = "", parentData, parentDataProperty, rootData = data } = {}) { ; let vErrors = null; let errors = 0; if (errors === 0) { if (data && typeof data == "object" && !Array.isArray(data)) { let missing0; if (data.workspace_id === void 0 && (missing0 = "workspace_id") || data.subscription_id === void 0 && (missing0 = "subscription_id") || data.enabled === void 0 && (missing0 = "enabled")) { validate20.errors = [{ instancePath, schemaPath: "#/required", keyword: "required", params: { missingProperty: missing0 }, message: "must have required property '" + missing0 + "'" }]; return false; } else { const _errs1 = errors; for (const key0 in data) { if (!(key0 === "workspace_id" || key0 === "subscription_id" || key0 === "enabled")) { validate20.errors = [{ instancePath, schemaPath: "#/additionalProperties", keyword: "additionalProperties", params: { additionalProperty: key0 }, message: "must NOT have additional properties" }]; return false; break; } } if (_errs1 === errors) { if (data.workspace_id !== void 0) { let data0 = data.workspace_id; const _errs2 = errors; if (!(typeof data0 == "number" && isFinite(data0))) { validate20.errors = [{ instancePath: instancePath + "/workspace_id", schemaPath: "#/properties/workspace_id/type", keyword: "type", params: { type: "number" }, message: "must be number" }]; return false; } var valid0 = _errs2 === errors; } else { var valid0 = true; } if (valid0) { if (data.subscription_id !== void 0) { let data1 = data.subscription_id; const _errs4 = errors; if (!(typeof data1 == "number" && isFinite(data1))) { validate20.errors = [{ instancePath: instancePath + "/subscription_id", schemaPath: "#/properties/subscription_id/type", keyword: "type", params: { type: "number" }, message: "must be number" }]; return false; } var valid0 = _errs4 === errors; } else { var valid0 = true; } if (valid0) { if (data.enabled !== void 0) { const _errs6 = errors; if (typeof data.enabled !== "boolean") { validate20.errors = [{ instancePath: instancePath + "/enabled", schemaPath: "#/properties/enabled/type", keyword: "type", params: { type: "boolean" }, message: "must be boolean" }]; return false; } var valid0 = _errs6 === errors; } else { var valid0 = true; } } } } } } else { validate20.errors = [{ instancePath, schemaPath: "#/type", keyword: "type", params: { type: "object" }, message: "must be object" }]; return false; } } validate20.errors = vErrors; return errors === 0; } __name(validate20, "validate20"); export { CreateSubscriptionParams, DeleteSubscriptionParams, EventAction, EventFilter, ListSubscriptionEventsParams, ListSubscriptionsParams, PingSubscriptionParams, SetSubscriptionEnabledParams, UpdateSubscriptionParams };