UNPKG

@backstage/plugin-catalog-backend

Version:

The Backstage backend plugin that provides the Backstage catalog

31 lines (27 loc) 941 B
'use strict'; var backendPluginApi = require('@backstage/backend-plugin-api'); var errors = require('@backstage/errors'); var luxon = require('luxon'); function timestampToDateTime(input) { try { if (typeof input === "object") { return luxon.DateTime.fromJSDate(input).toUTC(); } const result = input.includes(" ") ? luxon.DateTime.fromSQL(input, { zone: "utc" }) : luxon.DateTime.fromISO(input, { zone: "utc" }); if (!result.isValid) { throw new TypeError("Not valid"); } return result; } catch (e) { throw new errors.InputError(`Failed to parse database timestamp ${input}`, e); } } function rethrowError(e) { if (backendPluginApi.isDatabaseConflictError(e)) { throw new errors.ConflictError(`Rejected due to a conflicting entity`, e); } throw e; } exports.rethrowError = rethrowError; exports.timestampToDateTime = timestampToDateTime; //# sourceMappingURL=conversion.cjs.js.map