UNPKG

office-addin-manifest

Version:
88 lines 3.02 kB
"use strict"; // copyright (c) Microsoft Corporation. All rights reserved. // licensed under the MIT license. Object.defineProperty(exports, "__esModule", { value: true }); exports.toAddInType = exports.parseAddInTypes = exports.parseAddInType = exports.getAddInTypes = exports.getAddInTypeForManifestOfficeAppType = exports.AddInType = void 0; const office_addin_usage_data_1 = require("office-addin-usage-data"); /** * The types of Office add-ins. */ var AddInType; (function (AddInType) { // the string values should be lowercase AddInType["Content"] = "content"; AddInType["Mail"] = "mail"; AddInType["TaskPane"] = "taskpane"; // when adding new entries, update the other functions })(AddInType = exports.AddInType || (exports.AddInType = {})); // initialized once since this list won't change const addInTypes = Object.keys(AddInType).map((key) => parseAddInType(key)); /** * Get the Office app for the manifest Host name * @param host Host name */ function getAddInTypeForManifestOfficeAppType(officeAppType) { switch (officeAppType ? officeAppType.trim().toLowerCase() : officeAppType) { case "contentapp": return AddInType.Content; case "mailapp": return AddInType.Mail; case "taskpaneapp": return AddInType.TaskPane; default: return undefined; } } exports.getAddInTypeForManifestOfficeAppType = getAddInTypeForManifestOfficeAppType; /** * Returns the Office add-in types. */ function getAddInTypes() { return addInTypes; } exports.getAddInTypes = getAddInTypes; /** * Converts the string to the AddInType enum value. * @param value string * @throws Error if the value is not a valid Office add-in type. */ function parseAddInType(value) { const addInType = toAddInType(value); if (!addInType) { throw new office_addin_usage_data_1.ExpectedError(`${value} is not a valid Office add-in type.`); } return addInType; } exports.parseAddInType = parseAddInType; /** * Converts the strings to the AddInType enum values. * @param input "all" for all Office add-in types, or a comma-separated list of one or more Office apps. * @throws Error if a value is not a valid Office app. */ function parseAddInTypes(input) { if (input.trim().toLowerCase() === "all") { return getAddInTypes(); } else { return input.split(",").map((appString) => parseAddInType(appString)); } } exports.parseAddInTypes = parseAddInTypes; /** * Returns the AddInType enum for the value, or undefined if not valid. * @param value Office add-in type string */ function toAddInType(value) { switch (value.trim().toLowerCase()) { case AddInType.Content: return AddInType.Content; case AddInType.Mail: return AddInType.Mail; case AddInType.TaskPane: return AddInType.TaskPane; default: return undefined; } } exports.toAddInType = toAddInType; //# sourceMappingURL=addInTypes.js.map