UNPKG

@unito/integration-debugger

Version:

The Unito Integration Debugger

55 lines (54 loc) 2.31 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.extractQueryParams = extractQueryParams; exports.createInvalidItem = createInvalidItem; exports.getSemanticSupportedFieldTypes = getSemanticSupportedFieldTypes; const integration_api_1 = require("@unito/integration-api"); /** * Returns the URLSearchParams for a given path * * @param path Relative path from which we extract the URLSearchParams * @returns URLSearchParams */ function extractQueryParams(path) { return new URL(['http://dummy-integration.com', path].join('/')).searchParams; } function createInvalidItem(fields) { const invalidItem = {}; for (const field of fields) { if (field.type === integration_api_1.FieldValueTypes.EMAIL || field.type === integration_api_1.FieldValueTypes.RICH_TEXT_HTML || field.type === integration_api_1.FieldValueTypes.RICH_TEXT_MARKDOWN || field.type === integration_api_1.FieldValueTypes.STRING || field.type === integration_api_1.FieldValueTypes.URL) { invalidItem[field.name] = 0b0100101011100110; } else { invalidItem[field.name] = `random string that shouldn't be`; } } return invalidItem; } /** * Returns the field types supported by a given semantic * * @param semantic Semantic for which we want to get the supported field types * @returns Supported field types * */ function getSemanticSupportedFieldTypes(semantic) { switch (semantic) { case integration_api_1.Semantics.DESCRIPTION: return [integration_api_1.FieldValueTypes.RICH_TEXT_HTML, integration_api_1.FieldValueTypes.RICH_TEXT_MARKDOWN, integration_api_1.FieldValueTypes.STRING]; case integration_api_1.Semantics.CREATED_AT: case integration_api_1.Semantics.UPDATED_AT: return [integration_api_1.FieldValueTypes.DATETIME]; case integration_api_1.Semantics.PROVIDER_URL: return [integration_api_1.FieldValueTypes.URL]; case integration_api_1.Semantics.DISPLAY_NAME: return [integration_api_1.FieldValueTypes.STRING]; case integration_api_1.Semantics.USER: case integration_api_1.Semantics.PARENT: return [integration_api_1.FieldValueTypes.REFERENCE]; } }