|
| 1 | +import { $TSFixMe } from '../../commands/types.js' |
1 | 2 | import { error } from '../command-helpers.js'
|
2 | 3 |
|
3 | 4 | export const AVAILABLE_CONTEXTS = ['all', 'production', 'deploy-preview', 'branch-deploy', 'dev']
|
@@ -57,18 +58,20 @@ export const filterEnvBySource = (env, source) =>
|
57 | 58 | // @ts-expect-error TS(2571) FIXME: Object is of type 'unknown'.
|
58 | 59 | Object.fromEntries(Object.entries(env).filter(([, variable]) => variable.sources[0] === source))
|
59 | 60 |
|
60 |
| -/** |
61 |
| - * Fetches data from Envelope |
62 |
| - * @param {string} accountId - The account id |
63 |
| - * @param {object} api - The api singleton object |
64 |
| - * @param {string} key - If present, fetch a single key (case-sensitive) |
65 |
| - * @param {string} siteId - The site id |
66 |
| - * @returns {Array<object>} An array of environment variables from the Envelope service |
67 |
| - */ |
68 |
| -// @ts-expect-error TS(7031) FIXME: Binding element 'accountId' implicitly has an 'any... Remove this comment to see the full error message |
69 |
| -const fetchEnvelopeItems = async function ({ accountId, api, key, siteId }) { |
| 61 | +// Fetches data from Envelope |
| 62 | +const fetchEnvelopeItems = async function ({ |
| 63 | + accountId, |
| 64 | + api, |
| 65 | + key, |
| 66 | + siteId, |
| 67 | +}: { |
| 68 | + accountId: string |
| 69 | + api: $TSFixMe |
| 70 | + key: string |
| 71 | + siteId: string |
| 72 | +}): Promise<$TSFixMe[]> { |
70 | 73 | if (accountId === undefined) {
|
71 |
| - return {} |
| 74 | + return [] |
72 | 75 | }
|
73 | 76 | try {
|
74 | 77 | // if a single key is passed, fetch that single env var
|
@@ -109,28 +112,32 @@ const fetchEnvelopeItems = async function ({ accountId, api, key, siteId }) {
|
109 | 112 | * },
|
110 | 113 | * }
|
111 | 114 | */
|
112 |
| -// @ts-expect-error TS(7031) FIXME: Binding element 'source' implicitly has an 'any' t... Remove this comment to see the full error message |
113 |
| -export const formatEnvelopeData = ({ context = 'dev', envelopeItems = [], scope = 'any', source }) => |
| 115 | +export const formatEnvelopeData = ({ |
| 116 | + context = 'dev', |
| 117 | + envelopeItems = [], |
| 118 | + scope = 'any', |
| 119 | + source, |
| 120 | +}: { |
| 121 | + context?: string |
| 122 | + envelopeItems: $TSFixMe[] |
| 123 | + scope?: string |
| 124 | + source: string |
| 125 | +}) => |
114 | 126 | envelopeItems
|
115 | 127 | // filter by context
|
116 | 128 | .filter(({ values }) => Boolean(findValueInValues(values, context)))
|
117 | 129 | // filter by scope
|
118 |
| - // @ts-expect-error TS(2339) FIXME: Property 'includes' does not exist on type 'never'... Remove this comment to see the full error message |
119 | 130 | .filter(({ scopes }) => (scope === 'any' ? true : scopes.includes(scope)))
|
120 | 131 | // sort alphabetically, case insensitive
|
121 |
| - // @ts-expect-error TS(2339) FIXME: Property 'key' does not exist on type 'never'. |
122 | 132 | .sort((left, right) => (left.key.toLowerCase() < right.key.toLowerCase() ? -1 : 1))
|
123 | 133 | // format the data
|
124 | 134 | .reduce((acc, cur) => {
|
125 |
| - // @ts-expect-error TS(2339) FIXME: Property 'values' does not exist on type 'never'. |
126 | 135 | const { context: ctx, context_parameter: branch, value } = findValueInValues(cur.values, context)
|
127 | 136 | return {
|
128 | 137 | ...acc,
|
129 |
| - // @ts-expect-error TS(2339) FIXME: Property 'key' does not exist on type 'never'. |
130 | 138 | [cur.key]: {
|
131 | 139 | context: ctx,
|
132 | 140 | branch,
|
133 |
| - // @ts-expect-error TS(2339) FIXME: Property 'scopes' does not exist on type 'never'. |
134 | 141 | scopes: cur.scopes,
|
135 | 142 | sources: [source],
|
136 | 143 | value,
|
|
2 commit comments
github-actions[bot] commentedon May 24, 2024
📊 Benchmark results
github-actions[bot] commentedon May 24, 2024
📊 Benchmark results