UNPKG

5.53 kBJavaScriptView Raw
1"use strict";
2/*
3 * Copyright (c) 2020, salesforce.com, inc.
4 * All rights reserved.
5 * Licensed under the BSD 3-Clause license.
6 * For full license text, see LICENSE.txt file in the repo root or https://opensource.org/licenses/BSD-3-Clause
7 */
8Object.defineProperty(exports, "__esModule", { value: true });
9exports.ORG_CONFIG_ALLOWED_PROPERTIES = exports.OrgConfigProperties = void 0;
10const path_1 = require("path");
11const ts_types_1 = require("@salesforce/ts-types");
12const messages_1 = require("../messages");
13const sfdcUrl_1 = require("../util/sfdcUrl");
14const sfdc_1 = require("../util/sfdc");
15messages_1.Messages.importMessagesDirectory((0, path_1.join)(__dirname));
16const messages = messages_1.Messages.load('@salesforce/core', 'config', [
17 'invalidApiVersion',
18 'invalidBooleanConfigValue',
19 'invalidInstanceUrl',
20 'invalidIsvDebuggerSid',
21 'invalidIsvDebuggerUrl',
22 'invalidNumberConfigValue',
23 'org-api-version',
24 'org-instance-url',
25 'org-isv-debugger-sid',
26 'org-isv-debugger-url',
27 'org-max-query-limit',
28 'target-dev-hub',
29 'target-org',
30 'org-custom-metadata-templates',
31]);
32var OrgConfigProperties;
33(function (OrgConfigProperties) {
34 /**
35 * Username associate with the default org.
36 */
37 OrgConfigProperties["TARGET_ORG"] = "target-org";
38 /**
39 * Username associated with the default dev hub org.
40 */
41 OrgConfigProperties["TARGET_DEV_HUB"] = "target-dev-hub";
42 /**
43 * The api version
44 */
45 OrgConfigProperties["ORG_API_VERSION"] = "org-api-version";
46 /**
47 * Custom templates repo or local location.
48 */
49 OrgConfigProperties["ORG_CUSTOM_METADATA_TEMPLATES"] = "org-custom-metadata-templates";
50 /**
51 * Allows users to override the 10,000 result query limit.
52 */
53 OrgConfigProperties["ORG_MAX_QUERY_LIMIT"] = "org-max-query-limit";
54 /**
55 * The instance url of the org.
56 */
57 OrgConfigProperties["ORG_INSTANCE_URL"] = "org-instance-url";
58 /**
59 * The sid for the debugger configuration.
60 */
61 OrgConfigProperties["ORG_ISV_DEBUGGER_SID"] = "org-isv-debugger-sid";
62 /**
63 * The url for the debugger configuration.
64 */
65 OrgConfigProperties["ORG_ISV_DEBUGGER_URL"] = "org-isv-debugger-url";
66})(OrgConfigProperties = exports.OrgConfigProperties || (exports.OrgConfigProperties = {}));
67exports.ORG_CONFIG_ALLOWED_PROPERTIES = [
68 {
69 key: OrgConfigProperties.ORG_CUSTOM_METADATA_TEMPLATES,
70 description: messages.getMessage(OrgConfigProperties.ORG_CUSTOM_METADATA_TEMPLATES),
71 },
72 {
73 key: OrgConfigProperties.TARGET_ORG,
74 description: messages.getMessage(OrgConfigProperties.TARGET_ORG),
75 },
76 {
77 key: OrgConfigProperties.TARGET_DEV_HUB,
78 description: messages.getMessage(OrgConfigProperties.TARGET_DEV_HUB),
79 },
80 {
81 key: OrgConfigProperties.ORG_INSTANCE_URL,
82 description: messages.getMessage(OrgConfigProperties.ORG_INSTANCE_URL),
83 input: {
84 // If a value is provided validate it otherwise no value is unset.
85 validator: (value) => {
86 if (value == null)
87 return true;
88 // validate if the value is a string and is a valid url and is either a salesforce domain
89 // or an internal url.
90 return ((0, ts_types_1.isString)(value) &&
91 sfdcUrl_1.SfdcUrl.isValidUrl(value) &&
92 (new sfdcUrl_1.SfdcUrl(value).isSalesforceDomain() || new sfdcUrl_1.SfdcUrl(value).isInternalUrl()));
93 },
94 failedMessage: messages.getMessage('invalidInstanceUrl'),
95 },
96 },
97 {
98 key: OrgConfigProperties.ORG_API_VERSION,
99 description: messages.getMessage(OrgConfigProperties.ORG_API_VERSION),
100 hidden: true,
101 input: {
102 // If a value is provided validate it otherwise no value is unset.
103 validator: (value) => value == null || ((0, ts_types_1.isString)(value) && (0, sfdc_1.validateApiVersion)(value)),
104 failedMessage: messages.getMessage('invalidApiVersion'),
105 },
106 },
107 {
108 key: OrgConfigProperties.ORG_ISV_DEBUGGER_SID,
109 description: messages.getMessage(OrgConfigProperties.ORG_ISV_DEBUGGER_SID),
110 encrypted: true,
111 input: {
112 // If a value is provided validate it otherwise no value is unset.
113 validator: (value) => value == null || (0, ts_types_1.isString)(value),
114 failedMessage: messages.getMessage('invalidIsvDebuggerSid'),
115 },
116 },
117 {
118 key: OrgConfigProperties.ORG_ISV_DEBUGGER_URL,
119 description: messages.getMessage(OrgConfigProperties.ORG_ISV_DEBUGGER_URL),
120 input: {
121 // If a value is provided validate it otherwise no value is unset.
122 validator: (value) => value == null || (0, ts_types_1.isString)(value),
123 failedMessage: messages.getMessage('invalidIsvDebuggerUrl'),
124 },
125 },
126 {
127 key: OrgConfigProperties.ORG_MAX_QUERY_LIMIT,
128 description: messages.getMessage(OrgConfigProperties.ORG_MAX_QUERY_LIMIT),
129 input: {
130 // the bit shift will remove the negative bit, and any decimal numbers
131 // then the parseFloat will handle converting it to a number from a string
132 validator: (value) => value >>> 0 === parseFloat(value) && value > 0,
133 failedMessage: messages.getMessage('invalidNumberConfigValue'),
134 },
135 },
136];
137//# sourceMappingURL=orgConfigProperties.js.map
\No newline at end of file