From c1754f5f97309b0a5714036c54e66ace7934785d Mon Sep 17 00:00:00 2001 From: Jordan Reimer Date: Tue, 25 Feb 2025 16:08:51 -0700 Subject: [PATCH] [UI] Types Linting (#29702) * adds linting for types to scripts and lint staged * fixes issue with AdapterError type * moves lint-staged setup out of package.json and into config file * fixes ember data store service type * fixes route params types * fixes model types * fixes general type errors * fixes ts declaration errors in js files * adds missing copyright headers * fixes issue accessing capabilities model properties * ignores AdapterError import type error * more updates to AdapterError type * adds comment to lint-staged config * moves ember data store type to @ember-data namespace * updates store import * moves AdapterError type to @ember-data namespace * turns ember-data import eslint rule back on --- ui/app/components/alphabet-edit.js | 2 +- ui/app/components/auth-jwt.js | 4 +- .../clients/charts/vertical-bar-stacked.ts | 4 +- ui/app/components/clients/page/counts.ts | 7 +- ui/app/components/mount-backend-form.ts | 7 +- ui/app/components/outer-html.js | 16 -- ui/app/components/role-edit.js | 3 + .../components/secret-engine/configure-wif.ts | 4 +- ui/app/components/transform-edit-base.js | 3 + ui/app/components/transform-edit-form.js | 2 +- ui/app/components/transform-template-edit.js | 2 +- ui/app/controllers/application.ts | 5 +- .../vault/cluster/access/identity/create.js | 3 + ui/app/lib/console-helpers.ts | 13 +- ui/app/routes/vault/cluster/clients.ts | 8 +- ui/app/routes/vault/cluster/clients/counts.ts | 12 +- .../vault/cluster/cluster-route-base.js | 3 + ui/app/routes/vault/cluster/init.js | 2 +- ui/app/routes/vault/cluster/policy/show.js | 3 + .../secrets/backend/configuration/edit.ts | 3 +- .../cluster/secrets/backend/secret-edit.js | 3 + ui/app/services/capabilities.ts | 10 +- ui/app/services/flags.ts | 9 +- .../addon/components/kv-suggestion-input.ts | 4 +- .../components/replication-actions-single.js | 3 + .../decorators/fetch-secrets-engine-config.ts | 6 +- ui/lib/core/addon/utils/client-count-utils.ts | 4 +- .../addon/components/page/configuration.ts | 2 +- .../addon/components/page/role/credentials.ts | 9 +- ui/lib/ldap/addon/routes/configuration.ts | 4 +- ui/lib/ldap/addon/routes/error.ts | 2 +- ui/lib/ldap/addon/routes/libraries/index.ts | 2 +- ui/lib/ldap/addon/routes/libraries/library.ts | 2 +- .../routes/libraries/library/check-out.ts | 5 +- ui/lib/ldap/addon/routes/roles.ts | 2 +- ui/lib/ldap/addon/routes/roles/index.ts | 4 +- .../addon/routes/roles/role/credentials.ts | 2 +- .../ldap/addon/routes/roles/subdirectory.ts | 6 +- .../page/pki-configuration-details.ts | 2 +- .../components/page/pki-configure-create.ts | 1 + .../components/page/pki-issuer-rotate-root.ts | 1 + .../pki/addon/components/page/pki-overview.ts | 1 + .../pki/addon/components/pki-generate-csr.ts | 5 +- ui/lib/pki/addon/components/pki-role-form.ts | 1 + .../pki/addon/components/pki-role-generate.ts | 1 + .../addon/controllers/application.js | 3 + .../addon/routes/replication-base.js | 3 + .../page/destinations/destination/sync.ts | 6 +- .../addon/components/secrets/page/overview.ts | 4 +- .../secrets/sync-activation-modal.ts | 4 +- .../destinations/create/destination.ts | 6 +- .../secrets/destinations/destination.ts | 6 +- .../destinations/destination/secrets.ts | 2 +- .../routes/secrets/destinations/index.ts | 8 +- ui/lib/sync/addon/routes/secrets/overview.ts | 4 +- ui/lint-staged.config.js | 14 ++ ui/package.json | 22 +- ui/tests/helpers/pki/pki-helpers.ts | 4 +- ui/types/@ember-data/adapter/error.d.ts | 19 ++ ui/types/@ember-data/store.d.ts | 8 + .../ember-data/types/registries/adapter.d.ts | 4 - .../ember-data/types/registries/model.d.ts | 10 + ui/types/vault/app-types.ts | 18 +- ui/types/vault/models/capabilities.d.ts | 6 +- ui/types/vault/models/mount-config.d.ts | 1 + ui/types/vault/models/pki/action.d.ts | 13 +- .../vault/models/pki/certificate/base.d.ts | 9 +- .../models/pki/certificate/generate.d.ts | 11 +- .../pki/certificate/sign-intermediate.d.ts | 13 +- .../vault/models/pki/certificate/sign.d.ts | 13 +- ui/types/vault/models/pki/config/acme.d.ts | 22 ++ ui/types/vault/models/pki/config/cluster.d.ts | 16 ++ ui/types/vault/models/pki/config/crl.d.ts | 10 +- ui/types/vault/models/pki/config/urls.d.ts | 8 +- ui/types/vault/models/pki/issuer.d.ts | 28 ++- ui/types/vault/models/pki/key.d.ts | 11 +- ui/types/vault/models/pki/role.d.ts | 11 +- ui/types/vault/models/pki/tidy.d.ts | 11 +- ui/types/vault/models/ssh/ca-config.d.ts | 17 ++ ui/types/vault/services/store.d.ts | 14 -- ui/yarn.lock | 200 +++++++++++++++++- 81 files changed, 521 insertions(+), 235 deletions(-) delete mode 100644 ui/app/components/outer-html.js create mode 100644 ui/lint-staged.config.js create mode 100644 ui/types/@ember-data/adapter/error.d.ts create mode 100644 ui/types/@ember-data/store.d.ts create mode 100644 ui/types/vault/models/pki/config/acme.d.ts create mode 100644 ui/types/vault/models/pki/config/cluster.d.ts create mode 100644 ui/types/vault/models/ssh/ca-config.d.ts delete mode 100644 ui/types/vault/services/store.d.ts diff --git a/ui/app/components/alphabet-edit.js b/ui/app/components/alphabet-edit.js index 435a814ae3..646d07208e 100644 --- a/ui/app/components/alphabet-edit.js +++ b/ui/app/components/alphabet-edit.js @@ -5,4 +5,4 @@ import TransformBase from './transform-edit-base'; -export default class AlphabetEdit extends TransformBase {} +export default TransformBase; diff --git a/ui/app/components/auth-jwt.js b/ui/app/components/auth-jwt.js index 6f69f22396..55333d620c 100644 --- a/ui/app/components/auth-jwt.js +++ b/ui/app/components/auth-jwt.js @@ -5,7 +5,7 @@ import Ember from 'ember'; import { service } from '@ember/service'; // ARG NOTE: Once you remove outer-html after glimmerizing you can remove the outer-html component -import Component from './outer-html'; +import Component from '@ember/component'; import { task, timeout, waitForEvent } from 'ember-concurrency'; import { debounce } from '@ember/runloop'; @@ -17,6 +17,8 @@ const ERROR_JWT_LOGIN = 'OIDC login is not configured for this mount'; export { ERROR_WINDOW_CLOSED, ERROR_MISSING_PARAMS, ERROR_JWT_LOGIN }; export default Component.extend({ + tagName: '', + store: service(), flagsService: service('flags'), diff --git a/ui/app/components/clients/charts/vertical-bar-stacked.ts b/ui/app/components/clients/charts/vertical-bar-stacked.ts index 4d6826d90c..2944e32516 100644 --- a/ui/app/components/clients/charts/vertical-bar-stacked.ts +++ b/ui/app/components/clients/charts/vertical-bar-stacked.ts @@ -65,7 +65,7 @@ export default class VerticalBarStacked extends Component { } label(legendKey: string) { - return this.args.chartLegend.find((l: Legend) => l.key === legendKey).label; + return this.args.chartLegend.find((l: Legend) => l.key === legendKey)?.label; } get chartData() { @@ -136,7 +136,7 @@ export default class VerticalBarStacked extends Component { tooltipY = (original: number) => (!original ? '0' : `${original}`); - formatTicksX = (timestamp: string): string => parseAPITimestamp(timestamp, 'M/yy'); + formatTicksX = (timestamp: string): string => parseAPITimestamp(timestamp, 'M/yy') as string; formatTicksY = (num: number): string => numericalAxisLabel(num) || num.toString(); } diff --git a/ui/app/components/clients/page/counts.ts b/ui/app/components/clients/page/counts.ts index 8d1b6c56cf..2d92614a4a 100644 --- a/ui/app/components/clients/page/counts.ts +++ b/ui/app/components/clients/page/counts.ts @@ -11,14 +11,15 @@ import { parseAPITimestamp } from 'core/utils/date-formatters'; import { filteredTotalForMount, filterVersionHistory, TotalClients } from 'core/utils/client-count-utils'; import { sanitizePath } from 'core/utils/sanitize-path'; -import type AdapterError from '@ember-data/adapter'; +import type AdapterError from '@ember-data/adapter/error'; import type FlagsService from 'vault/services/flags'; -import type StoreService from 'vault/services/store'; +import type Store from '@ember-data/store'; import type VersionService from 'vault/services/version'; import type ClientsActivityModel from 'vault/models/clients/activity'; import type ClientsConfigModel from 'vault/models/clients/config'; import type ClientsVersionHistoryModel from 'vault/models/clients/version-history'; import type NamespaceService from 'vault/services/namespace'; + interface Args { activity: ClientsActivityModel; activityError?: AdapterError; @@ -35,7 +36,7 @@ export default class ClientsCountsPageComponent extends Component { @service declare readonly flags: FlagsService; @service declare readonly version: VersionService; @service declare readonly namespace: NamespaceService; - @service declare readonly store: StoreService; + @service declare readonly store: Store; get formattedStartDate() { return this.args.startTimestamp ? parseAPITimestamp(this.args.startTimestamp, 'MMMM yyyy') : null; diff --git a/ui/app/components/mount-backend-form.ts b/ui/app/components/mount-backend-form.ts index abd1edef3f..51fb54ea32 100644 --- a/ui/app/components/mount-backend-form.ts +++ b/ui/app/components/mount-backend-form.ts @@ -14,6 +14,7 @@ import { isAddonEngine, allEngines } from 'vault/helpers/mountable-secret-engine import type FlashMessageService from 'vault/services/flash-messages'; import type Store from '@ember-data/store'; +import type AdapterError from '@ember-data/adapter/error'; import type { AuthEnableModel } from 'vault/routes/vault/cluster/settings/auth/enable'; import type { MountSecretBackendModel } from 'vault/routes/vault/cluster/settings/mount-secret-backend'; @@ -46,7 +47,7 @@ export default class MountBackendForm extends Component { @tracked modelValidations = null; @tracked invalidFormAlert = null; - @tracked errorMessage = ''; + @tracked errorMessage: string | string[] = ''; willDestroy() { // components are torn down after store is unloaded and will cause an error if attempt to unload record @@ -144,7 +145,9 @@ export default class MountBackendForm extends Component { try { yield mountModel.save(); - } catch (err) { + } catch (error) { + const err = error as AdapterError; + if (err.httpStatus === 403) { this.flashMessages.danger( 'You do not have access to the sys/mounts endpoint. The secret engine was not mounted.' diff --git a/ui/app/components/outer-html.js b/ui/app/components/outer-html.js deleted file mode 100644 index 251c64a5c5..0000000000 --- a/ui/app/components/outer-html.js +++ /dev/null @@ -1,16 +0,0 @@ -/** - * Copyright (c) HashiCorp, Inc. - * SPDX-License-Identifier: BUSL-1.1 - */ - -// THIS COMPONENT IS ONLY FOR EXTENDING -// You should use this component if you want to use outerHTML symantics -// in your components - this is the default for upcoming Glimmer components -import Component from '@ember/component'; - -export default Component.extend({ - tagName: '', -}); - -// yep! that's it, it's more of a way to keep track of what components -// use tagless semantics to make the upgrade to glimmer components easier diff --git a/ui/app/components/role-edit.js b/ui/app/components/role-edit.js index 514cdab619..d6c1af20cf 100644 --- a/ui/app/components/role-edit.js +++ b/ui/app/components/role-edit.js @@ -15,6 +15,9 @@ import keys from 'core/utils/key-codes'; const LIST_ROOT_ROUTE = 'vault.cluster.secrets.backend.list-root'; const SHOW_ROUTE = 'vault.cluster.secrets.backend.show'; +/** + * @type Class + */ export default Component.extend(FocusOnInsertMixin, { router: service(), diff --git a/ui/app/components/secret-engine/configure-wif.ts b/ui/app/components/secret-engine/configure-wif.ts index 763416ee31..725603df02 100644 --- a/ui/app/components/secret-engine/configure-wif.ts +++ b/ui/app/components/secret-engine/configure-wif.ts @@ -18,7 +18,7 @@ import type MountConfigModel from 'vault/vault/models/secret-engine/mount-config import type AdditionalConfigModel from 'vault/vault/models/secret-engine/additional-config'; import type IdentityOidcConfigModel from 'vault/models/identity/oidc/config'; import type Router from '@ember/routing/router'; -import type StoreService from 'vault/services/store'; +import type Store from '@ember-data/store'; import type VersionService from 'vault/services/version'; import type FlashMessageService from 'vault/services/flash-messages'; @@ -57,7 +57,7 @@ interface Args { export default class ConfigureWif extends Component { @service declare readonly router: Router; - @service declare readonly store: StoreService; + @service declare readonly store: Store; @service declare readonly version: VersionService; @service declare readonly flashMessages: FlashMessageService; diff --git a/ui/app/components/transform-edit-base.js b/ui/app/components/transform-edit-base.js index dbb182e779..7b6a5b1713 100644 --- a/ui/app/components/transform-edit-base.js +++ b/ui/app/components/transform-edit-base.js @@ -27,6 +27,9 @@ export const removeFromList = (list, itemToRemove) => { return newList.uniq(); }; +/** + * @type Class + */ export default Component.extend(FocusOnInsertMixin, { store: service(), flashMessages: service(), diff --git a/ui/app/components/transform-edit-form.js b/ui/app/components/transform-edit-form.js index efdd96008f..f3e88f5ab3 100644 --- a/ui/app/components/transform-edit-form.js +++ b/ui/app/components/transform-edit-form.js @@ -5,4 +5,4 @@ import TransformationEdit from './transformation-edit'; -export default TransformationEdit.extend({}); +export default TransformationEdit; diff --git a/ui/app/components/transform-template-edit.js b/ui/app/components/transform-template-edit.js index a0c0bda47f..646d07208e 100644 --- a/ui/app/components/transform-template-edit.js +++ b/ui/app/components/transform-template-edit.js @@ -5,4 +5,4 @@ import TransformBase from './transform-edit-base'; -export default TransformBase.extend({}); +export default TransformBase; diff --git a/ui/app/controllers/application.ts b/ui/app/controllers/application.ts index c634b41452..447a0d964a 100644 --- a/ui/app/controllers/application.ts +++ b/ui/app/controllers/application.ts @@ -6,11 +6,12 @@ import { service } from '@ember/service'; import Controller from '@ember/controller'; import config from '../config/environment'; + import type AuthService from 'vault/vault/services/auth'; -import type StoreService from 'vault/services/store'; +import type Store from '@ember-data/store'; export default class ApplicationController extends Controller { @service declare readonly auth: AuthService; - @service declare readonly store: StoreService; + @service declare readonly store: Store; env = config.environment; } diff --git a/ui/app/controllers/vault/cluster/access/identity/create.js b/ui/app/controllers/vault/cluster/access/identity/create.js index 3f6d1c8bae..c3c9bd267a 100644 --- a/ui/app/controllers/vault/cluster/access/identity/create.js +++ b/ui/app/controllers/vault/cluster/access/identity/create.js @@ -6,6 +6,9 @@ import Controller from '@ember/controller'; import { service } from '@ember/service'; +/** + * @type Class + */ export default Controller.extend({ router: service(), showRoute: 'vault.cluster.access.identity.show', diff --git a/ui/app/lib/console-helpers.ts b/ui/app/lib/console-helpers.ts index 5bee858d95..4c51f3484f 100644 --- a/ui/app/lib/console-helpers.ts +++ b/ui/app/lib/console-helpers.ts @@ -4,11 +4,11 @@ */ import keys from 'core/utils/key-codes'; -import AdapterError from '@ember-data/adapter/error'; import { parse } from 'shell-quote'; - import argTokenizer from './arg-tokenizer'; -import { StringMap } from 'vault/vault/app-types'; + +import type { StringMap } from 'vault/app-types'; +import type AdapterError from '@ember-data/adapter/error'; // Add new commands to `log-help` component for visibility const supportedCommands = ['read', 'write', 'list', 'delete', 'kv-get']; @@ -188,12 +188,7 @@ export function logFromResponse(response: LogResponse, path: string, method: str return { type: 'object', content: secret }; } -interface CustomError extends AdapterError { - httpStatus: number; - path: string; - errors: string[]; -} -export function logFromError(error: CustomError, vaultPath: string, method: string) { +export function logFromError(error: AdapterError, vaultPath: string, method: string) { let content; const { httpStatus, path } = error; const verbClause = { diff --git a/ui/app/routes/vault/cluster/clients.ts b/ui/app/routes/vault/cluster/clients.ts index 774c4a1977..815dcae96e 100644 --- a/ui/app/routes/vault/cluster/clients.ts +++ b/ui/app/routes/vault/cluster/clients.ts @@ -7,12 +7,14 @@ import Route from '@ember/routing/route'; import { hash } from 'rsvp'; import { service } from '@ember/service'; -import type StoreService from 'vault/services/store'; +import type Store from '@ember-data/store'; export default class ClientsRoute extends Route { - @service declare readonly store: StoreService; + @service declare readonly store: Store; - getVersionHistory() { + getVersionHistory(): Promise< + Array<{ version: string; previousVersion: string; timestampInstalled: string }> + > { return this.store .findAll('clients/version-history') .then((response) => { diff --git a/ui/app/routes/vault/cluster/clients/counts.ts b/ui/app/routes/vault/cluster/clients/counts.ts index 50644ed8dc..29a9228d20 100644 --- a/ui/app/routes/vault/cluster/clients/counts.ts +++ b/ui/app/routes/vault/cluster/clients/counts.ts @@ -7,10 +7,10 @@ import Route from '@ember/routing/route'; import { service } from '@ember/service'; import { fromUnixTime } from 'date-fns'; -import type AdapterError from '@ember-data/adapter'; +import type AdapterError from '@ember-data/adapter/error'; import type FlagsService from 'vault/services/flags'; import type NamespaceService from 'vault/services/namespace'; -import type StoreService from 'vault/services/store'; +import type Store from '@ember-data/store'; import type VersionService from 'vault/services/version'; import type { ModelFrom } from 'vault/vault/route'; import type ClientsRoute from '../clients'; @@ -35,7 +35,7 @@ export type ClientsCountsRouteModel = ModelFrom; export default class ClientsCountsRoute extends Route { @service declare readonly flags: FlagsService; @service declare readonly namespace: NamespaceService; - @service declare readonly store: StoreService; + @service declare readonly store: Store; @service declare readonly version: VersionService; queryParams = { @@ -69,8 +69,8 @@ export default class ClientsCountsRoute extends Route { } async getActivity(params: ClientsCountsRouteParams): Promise<{ - activity: ClientsActivityModel; - activityError: AdapterError; + activity?: ClientsActivityModel; + activityError?: AdapterError; }> { let activity, activityError; // if CE without start time we want to skip the activity call @@ -88,7 +88,7 @@ export default class ClientsCountsRoute extends Route { try { activity = await this.store.queryRecord('clients/activity', query); } catch (error) { - activityError = error; + activityError = error as AdapterError; } } return { diff --git a/ui/app/routes/vault/cluster/cluster-route-base.js b/ui/app/routes/vault/cluster/cluster-route-base.js index b8ceb8a4ed..741d25ec68 100644 --- a/ui/app/routes/vault/cluster/cluster-route-base.js +++ b/ui/app/routes/vault/cluster/cluster-route-base.js @@ -9,6 +9,9 @@ import Route from '@ember/routing/route'; import ClusterRoute from 'vault/mixins/cluster-route'; +/** + * @type Class + */ export default Route.extend(ClusterRoute, { model() { return this.modelFor('vault.cluster'); diff --git a/ui/app/routes/vault/cluster/init.js b/ui/app/routes/vault/cluster/init.js index b9b4b37fb0..6ae6001818 100644 --- a/ui/app/routes/vault/cluster/init.js +++ b/ui/app/routes/vault/cluster/init.js @@ -5,4 +5,4 @@ import ClusterRoute from './cluster-route-base'; -export default ClusterRoute.extend({}); +export default ClusterRoute; diff --git a/ui/app/routes/vault/cluster/policy/show.js b/ui/app/routes/vault/cluster/policy/show.js index 0745c933a7..1c7f54d016 100644 --- a/ui/app/routes/vault/cluster/policy/show.js +++ b/ui/app/routes/vault/cluster/policy/show.js @@ -8,6 +8,9 @@ import Route from '@ember/routing/route'; import UnloadModelRoute from 'vault/mixins/unload-model-route'; import { service } from '@ember/service'; +/** + * @type Class + */ export default Route.extend(UnloadModelRoute, { router: service(), store: service(), diff --git a/ui/app/routes/vault/cluster/secrets/backend/configuration/edit.ts b/ui/app/routes/vault/cluster/secrets/backend/configuration/edit.ts index 07df70c527..9babb880ee 100644 --- a/ui/app/routes/vault/cluster/secrets/backend/configuration/edit.ts +++ b/ui/app/routes/vault/cluster/secrets/backend/configuration/edit.ts @@ -77,7 +77,8 @@ export default class SecretsBackendConfigurationEdit extends Route { } else { model[standardizedKey] = configModel; } - } catch (e: AdapterError) { + } catch (error) { + const e = error as AdapterError; // For most models if the adapter returns a 404, we want to create a new record. // The ssh secret engine however returns a 400 if the CA is not configured. // For ssh's 400 error, we want to create the CA config model. diff --git a/ui/app/routes/vault/cluster/secrets/backend/secret-edit.js b/ui/app/routes/vault/cluster/secrets/backend/secret-edit.js index 767dc10dfd..9d1346e600 100644 --- a/ui/app/routes/vault/cluster/secrets/backend/secret-edit.js +++ b/ui/app/routes/vault/cluster/secrets/backend/secret-edit.js @@ -11,6 +11,9 @@ import Route from '@ember/routing/route'; import { encodePath, normalizePath } from 'vault/utils/path-encoding-helpers'; import { keyIsFolder, parentKeyForKey } from 'core/utils/key-utils'; +/** + * @type Class + */ export default Route.extend({ store: service(), router: service(), diff --git a/ui/app/services/capabilities.ts b/ui/app/services/capabilities.ts index d7fbb6df36..4dfbc165d0 100644 --- a/ui/app/services/capabilities.ts +++ b/ui/app/services/capabilities.ts @@ -8,7 +8,7 @@ import { assert } from '@ember/debug'; import type AdapterError from '@ember-data/adapter/error'; import type CapabilitiesModel from 'vault/vault/models/capabilities'; -import type StoreService from 'vault/services/store'; +import type Store from '@ember-data/store'; interface Capabilities { canCreate: boolean; @@ -25,7 +25,7 @@ interface MultipleCapabilities { } export default class CapabilitiesService extends Service { - @service declare readonly store: StoreService; + @service declare readonly store: Store; async request(query: { paths?: string[]; path?: string }) { if (query?.paths) { @@ -74,7 +74,7 @@ export default class CapabilitiesService extends Service { try { return this.request({ path }); } catch (error) { - return error; + return error as AdapterError; } } @@ -85,12 +85,12 @@ export default class CapabilitiesService extends Service { async _fetchSpecificCapability( path: string, capability: string - ): Promise | AdapterError { + ): Promise { try { const capabilities = await this.request({ path }); return capabilities[capability]; } catch (e) { - return e; + return e as AdapterError; } } diff --git a/ui/app/services/flags.ts b/ui/app/services/flags.ts index ccacb50d9e..a529467e5c 100644 --- a/ui/app/services/flags.ts +++ b/ui/app/services/flags.ts @@ -8,9 +8,11 @@ import { tracked } from '@glimmer/tracking'; import { keepLatestTask } from 'ember-concurrency'; import { DEBUG } from '@glimmer/env'; import lazyCapabilities, { apiPath } from 'vault/macros/lazy-capabilities'; -import type StoreService from 'vault/services/store'; + +import type Store from '@ember-data/store'; import type VersionService from 'vault/services/version'; import type PermissionsService from 'vault/services/permissions'; +import type CapabilitiesModel from 'vault/models/capabilities'; const FLAGS = { vaultCloudNamespace: 'VAULT_CLOUD_ADMIN_NAMESPACE', @@ -24,7 +26,7 @@ const FLAGS = { export default class flagsService extends Service { @service declare readonly version: VersionService; - @service declare readonly store: StoreService; + @service declare readonly store: Store; @service declare readonly permissions: PermissionsService; @tracked activatedFlags: string[] = []; @@ -80,7 +82,8 @@ export default class flagsService extends Service { return this.getActivatedFlags.perform(); } - @lazyCapabilities(apiPath`sys/activation-flags/secrets-sync/activate`) secretsSyncActivatePath; + @lazyCapabilities(apiPath`sys/activation-flags/secrets-sync/activate`) + declare secretsSyncActivatePath: CapabilitiesModel; get canActivateSecretsSync() { return ( diff --git a/ui/lib/core/addon/components/kv-suggestion-input.ts b/ui/lib/core/addon/components/kv-suggestion-input.ts index 9ac701da7f..bd151e89c7 100644 --- a/ui/lib/core/addon/components/kv-suggestion-input.ts +++ b/ui/lib/core/addon/components/kv-suggestion-input.ts @@ -11,7 +11,7 @@ import { guidFor } from '@ember/object/internals'; import { run } from '@ember/runloop'; import { keyIsFolder, parentKeyForKey, keyWithoutParentKey } from 'core/utils/key-utils'; -import type StoreService from 'vault/services/store'; +import type Store from '@ember-data/store'; import type KvSecretMetadataModel from 'vault/models/kv/metadata'; /** @@ -49,7 +49,7 @@ interface PowerSelectAPI { } export default class KvSuggestionInputComponent extends Component { - @service declare readonly store: StoreService; + @service declare readonly store: Store; @tracked secrets: KvSecretMetadataModel[] = []; powerSelectAPI: PowerSelectAPI | undefined; diff --git a/ui/lib/core/addon/components/replication-actions-single.js b/ui/lib/core/addon/components/replication-actions-single.js index 92950ddf2d..fe6d580683 100644 --- a/ui/lib/core/addon/components/replication-actions-single.js +++ b/ui/lib/core/addon/components/replication-actions-single.js @@ -5,6 +5,9 @@ import Component from '@ember/component'; +/** + * @type Class + */ export default Component.extend({ onSubmit() {}, replicationMode: null, diff --git a/ui/lib/core/addon/decorators/fetch-secrets-engine-config.ts b/ui/lib/core/addon/decorators/fetch-secrets-engine-config.ts index bb071782d6..d326f0ecb8 100644 --- a/ui/lib/core/addon/decorators/fetch-secrets-engine-config.ts +++ b/ui/lib/core/addon/decorators/fetch-secrets-engine-config.ts @@ -8,8 +8,8 @@ import Route from '@ember/routing/route'; import type Store from '@ember-data/store'; import type SecretMountPath from 'vault/services/secret-mount-path'; import type Transition from '@ember/routing/transition'; -import type Model from '@ember-data/model'; -import type AdapterError from 'ember-data/adapter'; // eslint-disable-line ember/use-ember-data-rfc-395-imports +import type MountConfigModel from 'vault/models/mount-config'; +import type AdapterError from '@ember-data/adapter/error'; /** * for use in routes that need to be aware of the config for a secrets engine @@ -34,7 +34,7 @@ export function withConfig(modelName: string) { } return class FetchSecretsEngineConfig extends SuperClass { - configModel: Model | null = null; + configModel: MountConfigModel | null = null; configError: AdapterError | null = null; promptConfig = false; diff --git a/ui/lib/core/addon/utils/client-count-utils.ts b/ui/lib/core/addon/utils/client-count-utils.ts index eb2024d252..c4b85f27bb 100644 --- a/ui/lib/core/addon/utils/client-count-utils.ts +++ b/ui/lib/core/addon/utils/client-count-utils.ts @@ -239,9 +239,7 @@ export const sortMonthsByTimestamp = (monthsArray: ActivityMonthBlock[]) => { function monthIsEmpty(month: ActivityMonthBlock): month is ActivityMonthEmpty { return !month || month?.counts === null; } -function monthWithoutNewCounts(month: ActivityMonthBlock): month is ActivityMonthNoNewClients { - return month?.counts !== null && month?.new_clients?.counts === null; -} + function monthWithAllCounts(month: ActivityMonthBlock): month is ActivityMonthStandard { return month?.counts !== null && month?.new_clients?.counts !== null; } diff --git a/ui/lib/ldap/addon/components/page/configuration.ts b/ui/lib/ldap/addon/components/page/configuration.ts index d29bdf142b..cccc4efe21 100644 --- a/ui/lib/ldap/addon/components/page/configuration.ts +++ b/ui/lib/ldap/addon/components/page/configuration.ts @@ -11,7 +11,7 @@ import errorMessage from 'vault/utils/error-message'; import type LdapConfigModel from 'vault/models/ldap/config'; import type SecretEngineModel from 'vault/models/secret-engine'; -import type AdapterError from 'ember-data/adapter'; // eslint-disable-line ember/use-ember-data-rfc-395-imports +import type AdapterError from '@ember-data/adapter/error'; import type { Breadcrumb } from 'vault/vault/app-types'; import type FlashMessageService from 'vault/services/flash-messages'; diff --git a/ui/lib/ldap/addon/components/page/role/credentials.ts b/ui/lib/ldap/addon/components/page/role/credentials.ts index 9bb1dd1dbf..9bc0e5c1eb 100644 --- a/ui/lib/ldap/addon/components/page/role/credentials.ts +++ b/ui/lib/ldap/addon/components/page/role/credentials.ts @@ -5,15 +5,12 @@ import Component from '@glimmer/component'; -import type { - LdapStaticRoleCredentials, - LdapDynamicRoleCredentials, -} from 'ldap/routes/roles/role/credentials'; +import type { StaticCredentials, DynamicCredentials } from 'ldap/routes/roles/role/credentials'; import { Breadcrumb } from 'vault/vault/app-types'; -import type AdapterError from 'ember-data/adapter'; // eslint-disable-line ember/use-ember-data-rfc-395-imports +import type AdapterError from '@ember-data/adapter/error'; interface Args { - credentials: LdapStaticRoleCredentials | LdapDynamicRoleCredentials; + credentials: StaticCredentials | DynamicCredentials; error: AdapterError; breadcrumbs: Array; } diff --git a/ui/lib/ldap/addon/routes/configuration.ts b/ui/lib/ldap/addon/routes/configuration.ts index d58f7d2c93..4c60455db2 100644 --- a/ui/lib/ldap/addon/routes/configuration.ts +++ b/ui/lib/ldap/addon/routes/configuration.ts @@ -14,7 +14,7 @@ import type LdapConfigModel from 'vault/models/ldap/config'; import type SecretEngineModel from 'vault/models/secret-engine'; import type Controller from '@ember/controller'; import type { Breadcrumb } from 'vault/vault/app-types'; -import type AdapterError from 'ember-data/adapter'; // eslint-disable-line ember/use-ember-data-rfc-395-imports +import type AdapterError from '@ember-data/adapter/error'; interface RouteModel { backendModel: SecretEngineModel; @@ -47,7 +47,7 @@ export default class LdapConfigurationRoute extends Route { controller.breadcrumbs = [ { label: 'Secrets', route: 'secrets', linkExternal: true }, - { label: resolvedModel.backendModel.id, route: 'overview', model: resolvedModel.backend }, + { label: resolvedModel.backendModel.id, route: 'overview', model: resolvedModel.backendModel.id }, { label: 'Configuration' }, ]; } diff --git a/ui/lib/ldap/addon/routes/error.ts b/ui/lib/ldap/addon/routes/error.ts index 6b8f4cac7a..23aa634273 100644 --- a/ui/lib/ldap/addon/routes/error.ts +++ b/ui/lib/ldap/addon/routes/error.ts @@ -7,7 +7,7 @@ import Route from '@ember/routing/route'; import { service } from '@ember/service'; import type Transition from '@ember/routing/transition'; -import type AdapterError from 'ember-data/adapter'; // eslint-disable-line ember/use-ember-data-rfc-395-imports +import type AdapterError from '@ember-data/adapter/error'; import type SecretEngineModel from 'vault/models/secret-engine'; import type { Breadcrumb } from 'vault/vault/app-types'; import type Controller from '@ember/controller'; diff --git a/ui/lib/ldap/addon/routes/libraries/index.ts b/ui/lib/ldap/addon/routes/libraries/index.ts index 8ea7c7b867..aac2cf5b83 100644 --- a/ui/lib/ldap/addon/routes/libraries/index.ts +++ b/ui/lib/ldap/addon/routes/libraries/index.ts @@ -51,7 +51,7 @@ export default class LdapLibrariesRoute extends Route { controller.breadcrumbs = [ { label: 'Secrets', route: 'secrets', linkExternal: true }, - { label: resolvedModel.backendModel.id, route: 'overview', model: resolvedModel.backend }, + { label: resolvedModel.backendModel.id, route: 'overview', model: resolvedModel.backendModel.id }, { label: 'Libraries' }, ]; } diff --git a/ui/lib/ldap/addon/routes/libraries/library.ts b/ui/lib/ldap/addon/routes/libraries/library.ts index 5a026c2b35..a6319ad7a0 100644 --- a/ui/lib/ldap/addon/routes/libraries/library.ts +++ b/ui/lib/ldap/addon/routes/libraries/library.ts @@ -10,7 +10,7 @@ import type Store from '@ember-data/store'; import type SecretMountPath from 'vault/services/secret-mount-path'; interface LdapLibraryRouteParams { - name: string; + name?: string; } export default class LdapLibraryRoute extends Route { diff --git a/ui/lib/ldap/addon/routes/libraries/library/check-out.ts b/ui/lib/ldap/addon/routes/libraries/library/check-out.ts index c8f71936a2..1124e74665 100644 --- a/ui/lib/ldap/addon/routes/libraries/library/check-out.ts +++ b/ui/lib/ldap/addon/routes/libraries/library/check-out.ts @@ -15,7 +15,6 @@ import type Controller from '@ember/controller'; import type Transition from '@ember/routing/transition'; import type { Breadcrumb } from 'vault/vault/app-types'; import { LdapLibraryCheckOutCredentials } from 'vault/vault/adapters/ldap/library'; -import type AdapterError from 'ember-data/adapter'; // eslint-disable-line ember/use-ember-data-rfc-395-imports import { ldapBreadcrumbs, libraryRoutes } from 'ldap/utils/ldap-breadcrumbs'; interface LdapLibraryCheckOutController extends Controller { @@ -36,7 +35,7 @@ export default class LdapLibraryCheckOutRoute extends Route { } } model(_params: object, transition: Transition) { - const ttl = transition.to?.queryParams['ttl']; + const ttl = transition.to?.queryParams['ttl'] as string; const library = this.modelFor('libraries.library') as LdapLibraryModel; return library.checkOutAccount(ttl); } @@ -59,7 +58,7 @@ export default class LdapLibraryCheckOutRoute extends Route { } @action - error(error: AdapterError) { + error(error: Error) { // if check-out fails, return to library details route const message = errorMessage(error, 'Error checking out account. Please try again or contact support.'); this.flashMessages.danger(message); diff --git a/ui/lib/ldap/addon/routes/roles.ts b/ui/lib/ldap/addon/routes/roles.ts index 7d6edef179..7ef6038c11 100644 --- a/ui/lib/ldap/addon/routes/roles.ts +++ b/ui/lib/ldap/addon/routes/roles.ts @@ -14,7 +14,7 @@ export default class LdapRolesRoute extends Route { @service declare readonly pagination: PaginationService; @service declare readonly secretMountPath: SecretMountPath; - lazyQuery(backendId: string, params: { page?: string; pageFilter: string }, adapterOptions: object) { + lazyQuery(backendId: string, params: { page?: string; pageFilter?: string }, adapterOptions: object) { const page = Number(params.page) || 1; return this.pagination.lazyPaginatedQuery( 'ldap/role', diff --git a/ui/lib/ldap/addon/routes/roles/index.ts b/ui/lib/ldap/addon/routes/roles/index.ts index 9f03309164..fc50656510 100644 --- a/ui/lib/ldap/addon/routes/roles/index.ts +++ b/ui/lib/ldap/addon/routes/roles/index.ts @@ -8,7 +8,7 @@ import { service } from '@ember/service'; import { withConfig } from 'core/decorators/fetch-secrets-engine-config'; import { hash } from 'rsvp'; -import type StoreService from 'vault/services/store'; +import type Store from '@ember-data/store'; import type Transition from '@ember/routing/transition'; import type LdapRoleModel from 'vault/models/ldap/role'; import type SecretEngineModel from 'vault/models/secret-engine'; @@ -28,7 +28,7 @@ interface RouteController extends Controller { @withConfig('ldap/config') export default class LdapRolesIndexRoute extends LdapRolesRoute { - @service declare readonly store: StoreService; // necessary for @withConfig decorator + @service declare readonly store: Store; // necessary for @withConfig decorator declare promptConfig: boolean; diff --git a/ui/lib/ldap/addon/routes/roles/role/credentials.ts b/ui/lib/ldap/addon/routes/roles/role/credentials.ts index 70c68c8135..53c690c122 100644 --- a/ui/lib/ldap/addon/routes/roles/role/credentials.ts +++ b/ui/lib/ldap/addon/routes/roles/role/credentials.ts @@ -12,7 +12,7 @@ import type LdapRoleModel from 'vault/models/ldap/role'; import type Controller from '@ember/controller'; import type Transition from '@ember/routing/transition'; import type { Breadcrumb } from 'vault/vault/app-types'; -import type AdapterError from 'ember-data/adapter'; // eslint-disable-line ember/use-ember-data-rfc-395-imports +import type AdapterError from '@ember-data/adapter/error'; export interface StaticCredentials { dn: string; diff --git a/ui/lib/ldap/addon/routes/roles/subdirectory.ts b/ui/lib/ldap/addon/routes/roles/subdirectory.ts index 5b83c72dec..28e180425c 100644 --- a/ui/lib/ldap/addon/routes/roles/subdirectory.ts +++ b/ui/lib/ldap/addon/routes/roles/subdirectory.ts @@ -26,9 +26,9 @@ interface RouteController extends Controller { interface RouteParams { page?: string; - pageFilter: string; - path_to_role: string; - type: string; + pageFilter?: string; + path_to_role?: string; + type?: string; } export default class LdapRolesSubdirectoryRoute extends LdapRolesRoute { diff --git a/ui/lib/pki/addon/components/page/pki-configuration-details.ts b/ui/lib/pki/addon/components/page/pki-configuration-details.ts index 78ef13da0d..47614528b6 100644 --- a/ui/lib/pki/addon/components/page/pki-configuration-details.ts +++ b/ui/lib/pki/addon/components/page/pki-configuration-details.ts @@ -10,7 +10,7 @@ import { tracked } from '@glimmer/tracking'; import errorMessage from 'vault/utils/error-message'; import type RouterService from '@ember/routing/router-service'; import type FlashMessageService from 'vault/services/flash-messages'; -import type Store from 'vault/services/store'; +import type Store from '@ember-data/store'; import type VersionService from 'vault/services/version'; interface Args { diff --git a/ui/lib/pki/addon/components/page/pki-configure-create.ts b/ui/lib/pki/addon/components/page/pki-configure-create.ts index 8bcb723c65..1946ee8668 100644 --- a/ui/lib/pki/addon/components/page/pki-configure-create.ts +++ b/ui/lib/pki/addon/components/page/pki-configure-create.ts @@ -6,6 +6,7 @@ import Component from '@glimmer/component'; import { service } from '@ember/service'; import { tracked } from '@glimmer/tracking'; + import type Store from '@ember-data/store'; import type RouterService from '@ember/routing/router'; import type FlashMessageService from 'vault/services/flash-messages'; diff --git a/ui/lib/pki/addon/components/page/pki-issuer-rotate-root.ts b/ui/lib/pki/addon/components/page/pki-issuer-rotate-root.ts index 7b74640a3f..87be32083e 100644 --- a/ui/lib/pki/addon/components/page/pki-issuer-rotate-root.ts +++ b/ui/lib/pki/addon/components/page/pki-issuer-rotate-root.ts @@ -10,6 +10,7 @@ import { action } from '@ember/object'; import { waitFor } from '@ember/test-waiters'; import { task } from 'ember-concurrency'; import errorMessage from 'vault/utils/error-message'; + import type Store from '@ember-data/store'; import type RouterService from '@ember/routing/router'; import type FlashMessageService from 'vault/services/flash-messages'; diff --git a/ui/lib/pki/addon/components/page/pki-overview.ts b/ui/lib/pki/addon/components/page/pki-overview.ts index daf879d0cc..85596c09e3 100644 --- a/ui/lib/pki/addon/components/page/pki-overview.ts +++ b/ui/lib/pki/addon/components/page/pki-overview.ts @@ -7,6 +7,7 @@ import Component from '@glimmer/component'; import { action } from '@ember/object'; import { tracked } from '@glimmer/tracking'; import { service } from '@ember/service'; + import type Store from '@ember-data/store'; import type RouterService from '@ember/routing/router-service'; import type PkiIssuerModel from 'vault/models/pki/issuer'; diff --git a/ui/lib/pki/addon/components/pki-generate-csr.ts b/ui/lib/pki/addon/components/pki-generate-csr.ts index 75ba5b34b2..91ed7065f3 100644 --- a/ui/lib/pki/addon/components/pki-generate-csr.ts +++ b/ui/lib/pki/addon/components/pki-generate-csr.ts @@ -11,9 +11,10 @@ import { task } from 'ember-concurrency'; import { waitFor } from '@ember/test-waiters'; import { expandAttributeMeta } from 'vault/utils/field-to-attrs'; import errorMessage from 'vault/utils/error-message'; + import type FlashMessageService from 'vault/services/flash-messages'; import type PkiActionModel from 'vault/models/pki/action'; -import type { ValidationMap } from 'vault/vault/app-types'; +import type { Model, ValidationMap } from 'vault/app-types'; interface Args { model: PkiActionModel; @@ -82,7 +83,7 @@ export default class PkiGenerateCsrComponent extends Component { @task @waitFor - *save(event: Event): Generator> { + *save(event: Event): Generator> { event.preventDefault(); try { const { model, onSave } = this.args; diff --git a/ui/lib/pki/addon/components/pki-role-form.ts b/ui/lib/pki/addon/components/pki-role-form.ts index f870242bb0..61e50cff9d 100644 --- a/ui/lib/pki/addon/components/pki-role-form.ts +++ b/ui/lib/pki/addon/components/pki-role-form.ts @@ -9,6 +9,7 @@ import { task } from 'ember-concurrency'; import { tracked } from '@glimmer/tracking'; import { action } from '@ember/object'; import errorMessage from 'vault/utils/error-message'; + import type Store from '@ember-data/store'; import type FlashMessageService from 'vault/services/flash-messages'; import type SecretMountPathService from 'vault/services/secret-mount-path'; diff --git a/ui/lib/pki/addon/components/pki-role-generate.ts b/ui/lib/pki/addon/components/pki-role-generate.ts index 56c327c8f4..c6b8762a3d 100644 --- a/ui/lib/pki/addon/components/pki-role-generate.ts +++ b/ui/lib/pki/addon/components/pki-role-generate.ts @@ -9,6 +9,7 @@ import { task } from 'ember-concurrency'; import { service } from '@ember/service'; import { tracked } from '@glimmer/tracking'; import errorMessage from 'vault/utils/error-message'; + import type RouterService from '@ember/routing/router'; import type Store from '@ember-data/store'; import type FlashMessageService from 'vault/services/flash-messages'; diff --git a/ui/lib/replication/addon/controllers/application.js b/ui/lib/replication/addon/controllers/application.js index f3c680fbd6..1bcd96d067 100644 --- a/ui/lib/replication/addon/controllers/application.js +++ b/ui/lib/replication/addon/controllers/application.js @@ -25,6 +25,9 @@ const DEFAULTS = { }; const waiter = buildWaiter('replication-actions'); +/** + * @type Class + */ export default Controller.extend(structuredClone(DEFAULTS), { isModalActive: false, isTokenCopied: false, diff --git a/ui/lib/replication/addon/routes/replication-base.js b/ui/lib/replication/addon/routes/replication-base.js index 6cfff08fdd..8b6e89a07b 100644 --- a/ui/lib/replication/addon/routes/replication-base.js +++ b/ui/lib/replication/addon/routes/replication-base.js @@ -8,6 +8,9 @@ import { service } from '@ember/service'; import Route from '@ember/routing/route'; import UnloadModelRouteMixin from 'vault/mixins/unload-model-route'; +/** + * @type Class + */ export default Route.extend(UnloadModelRouteMixin, { router: service('app-router'), store: service(), diff --git a/ui/lib/sync/addon/components/secrets/page/destinations/destination/sync.ts b/ui/lib/sync/addon/components/secrets/page/destinations/destination/sync.ts index b7a012c93e..bb12dd4756 100644 --- a/ui/lib/sync/addon/components/secrets/page/destinations/destination/sync.ts +++ b/ui/lib/sync/addon/components/secrets/page/destinations/destination/sync.ts @@ -13,7 +13,7 @@ import errorMessage from 'vault/utils/error-message'; import type SyncDestinationModel from 'vault/models/sync/destination'; import type RouterService from '@ember/routing/router-service'; -import type StoreService from 'vault/services/store'; +import type Store from '@ember-data/store'; import type PaginationService from 'vault/services/pagination'; import type FlashMessageService from 'vault/services/flash-messages'; import type { SearchSelectOption } from 'vault/vault/app-types'; @@ -24,7 +24,7 @@ interface Args { export default class DestinationSyncPageComponent extends Component { @service('app-router') declare readonly router: RouterService; - @service declare readonly store: StoreService; + @service declare readonly store: Store; @service declare readonly flashMessages: FlashMessageService; @service declare readonly pagination: PaginationService; @@ -56,7 +56,7 @@ export default class DestinationSyncPageComponent extends Component { async fetchMounts() { try { const secretEngines = await this.store.query('secret-engine', {}); - this.mounts = secretEngines.reduce((filtered, model) => { + this.mounts = secretEngines.reduce((filtered: SearchSelectOption[], model) => { if (model.type === 'kv' && model.version === 2) { filtered.push({ name: model.path, id: model.path }); } diff --git a/ui/lib/sync/addon/components/secrets/page/overview.ts b/ui/lib/sync/addon/components/secrets/page/overview.ts index 265d869b93..11991decce 100644 --- a/ui/lib/sync/addon/components/secrets/page/overview.ts +++ b/ui/lib/sync/addon/components/secrets/page/overview.ts @@ -12,7 +12,7 @@ import Ember from 'ember'; import { DEBUG } from '@glimmer/env'; import type FlashMessageService from 'vault/services/flash-messages'; -import type StoreService from 'vault/services/store'; +import type Store from '@ember-data/store'; import type VersionService from 'vault/services/version'; import type FlagsService from 'vault/services/flags'; import type { SyncDestinationAssociationMetrics } from 'vault/vault/adapters/sync/association'; @@ -28,7 +28,7 @@ interface Args { export default class SyncSecretsDestinationsPageComponent extends Component { @service declare readonly flashMessages: FlashMessageService; - @service declare readonly store: StoreService; + @service declare readonly store: Store; @service declare readonly version: VersionService; @service declare readonly flags: FlagsService; diff --git a/ui/lib/sync/addon/components/secrets/sync-activation-modal.ts b/ui/lib/sync/addon/components/secrets/sync-activation-modal.ts index 2ccce7463d..def661f210 100644 --- a/ui/lib/sync/addon/components/secrets/sync-activation-modal.ts +++ b/ui/lib/sync/addon/components/secrets/sync-activation-modal.ts @@ -11,7 +11,7 @@ import { waitFor } from '@ember/test-waiters'; import errorMessage from 'vault/utils/error-message'; import type FlashMessageService from 'vault/services/flash-messages'; -import type StoreService from 'vault/services/store'; +import type Store from '@ember-data/store'; import type RouterService from '@ember/routing/router-service'; interface Args { @@ -23,7 +23,7 @@ interface Args { export default class SyncActivationModal extends Component { @service declare readonly flashMessages: FlashMessageService; - @service declare readonly store: StoreService; + @service declare readonly store: Store; @service('app-router') declare readonly router: RouterService; @tracked hasConfirmedDocs = false; diff --git a/ui/lib/sync/addon/routes/secrets/destinations/create/destination.ts b/ui/lib/sync/addon/routes/secrets/destinations/create/destination.ts index ebb04b6167..b8993b1192 100644 --- a/ui/lib/sync/addon/routes/secrets/destinations/create/destination.ts +++ b/ui/lib/sync/addon/routes/secrets/destinations/create/destination.ts @@ -7,15 +7,15 @@ import Route from '@ember/routing/route'; import { service } from '@ember/service'; import { findDestination } from 'core/helpers/sync-destinations'; -import type StoreService from 'vault/services/store'; +import type Store from '@ember-data/store'; import type { SyncDestinationType } from 'vault/vault/helpers/sync-destinations'; interface Params { - type: SyncDestinationType; + type?: SyncDestinationType; } export default class SyncSecretsDestinationsCreateDestinationRoute extends Route { - @service declare readonly store: StoreService; + @service declare readonly store: Store; model(params: Params) { const { type } = params; diff --git a/ui/lib/sync/addon/routes/secrets/destinations/destination.ts b/ui/lib/sync/addon/routes/secrets/destinations/destination.ts index 919b173fa0..622b9d8d64 100644 --- a/ui/lib/sync/addon/routes/secrets/destinations/destination.ts +++ b/ui/lib/sync/addon/routes/secrets/destinations/destination.ts @@ -13,8 +13,8 @@ import type Transition from '@ember/routing/transition'; import type SyncDestinationModel from 'vault/models/sync/destination'; interface RouteParams { - name: string; - type: string; + name?: string; + type?: string; } export default class SyncSecretsDestinationsDestinationRoute extends Route { @@ -23,7 +23,7 @@ export default class SyncSecretsDestinationsDestinationRoute extends Route { @service declare readonly flashMessages: FlashMessageService; model(params: RouteParams) { - const { name, type } = params; + const { name = '', type } = params; return this.store.findRecord(`sync/destinations/${type}`, name); } diff --git a/ui/lib/sync/addon/routes/secrets/destinations/destination/secrets.ts b/ui/lib/sync/addon/routes/secrets/destinations/destination/secrets.ts index f2ba3a91bd..9ae9574637 100644 --- a/ui/lib/sync/addon/routes/secrets/destinations/destination/secrets.ts +++ b/ui/lib/sync/addon/routes/secrets/destinations/destination/secrets.ts @@ -13,7 +13,7 @@ import type SyncAssociationModel from 'vault/vault/models/sync/association'; import type Controller from '@ember/controller'; interface SyncDestinationSecretsRouteParams { - page: string; + page?: string; } interface SyncDestinationSecretsRouteModel { diff --git a/ui/lib/sync/addon/routes/secrets/destinations/index.ts b/ui/lib/sync/addon/routes/secrets/destinations/index.ts index 5508bd849d..f1d8e61de9 100644 --- a/ui/lib/sync/addon/routes/secrets/destinations/index.ts +++ b/ui/lib/sync/addon/routes/secrets/destinations/index.ts @@ -14,9 +14,9 @@ import type SyncDestinationModel from 'vault/vault/models/sync/destination'; import type Controller from '@ember/controller'; interface SyncSecretsDestinationsIndexRouteParams { - name: string; - type: string; - page: string; + name?: string; + type?: string; + page?: string; } interface SyncSecretsDestinationsRouteModel { @@ -71,7 +71,7 @@ export default class SyncSecretsDestinationsIndexRoute extends Route { } async model(params: SyncSecretsDestinationsIndexRouteParams) { - const { name, type, page } = params; + const { name = '', type = '', page } = params; return hash({ destinations: this.pagination.lazyPaginatedQuery('sync/destination', { page: Number(page) || 1, diff --git a/ui/lib/sync/addon/routes/secrets/overview.ts b/ui/lib/sync/addon/routes/secrets/overview.ts index 7ebeffc197..5abbc18982 100644 --- a/ui/lib/sync/addon/routes/secrets/overview.ts +++ b/ui/lib/sync/addon/routes/secrets/overview.ts @@ -9,12 +9,12 @@ import { hash } from 'rsvp'; import type FlagsService from 'vault/services/flags'; import type RouterService from '@ember/routing/router-service'; -import type StoreService from 'vault/services/store'; +import type Store from '@ember-data/store'; import type VersionService from 'vault/services/version'; export default class SyncSecretsOverviewRoute extends Route { @service('app-router') declare readonly router: RouterService; - @service declare readonly store: StoreService; + @service declare readonly store: Store; @service declare readonly flags: FlagsService; @service declare readonly version: VersionService; diff --git a/ui/lint-staged.config.js b/ui/lint-staged.config.js new file mode 100644 index 0000000000..a4af5d9b56 --- /dev/null +++ b/ui/lint-staged.config.js @@ -0,0 +1,14 @@ +/* eslint-env node */ +/** + * Copyright (c) HashiCorp, Inc. + * SPDX-License-Identifier: BUSL-1.1 + */ + +// defining config here rather than in package.json to run tsc on all .ts files, not just the staged changes +// this is accomplished by using function syntax rather than string + +module.exports = { + '*.{js,ts}': ['prettier --config .prettierrc.js --write', 'eslint --quiet', () => 'tsc --noEmit'], + '*.hbs': ['prettier --config .prettierrc.js --write', 'ember-template-lint --quiet'], + '*.scss': ['prettier --write'], +}; diff --git a/ui/package.json b/ui/package.json index 139fbaa119..8c0ebf9bcd 100644 --- a/ui/package.json +++ b/ui/package.json @@ -22,6 +22,7 @@ "lint:js": "eslint . --cache", "lint:js:quiet": "eslint . --cache --quiet", "lint:js:fix": "eslint . --fix", + "lint:types": "tsc --noEmit", "fmt": "concurrently -c \"auto\" -n fmt: \"yarn:fmt:*\"", "fmt:js": "prettier --config .prettierrc.js --write '{app,tests,config,lib}/**/*.js'", "fmt:hbs": "prettier --config .prettierrc.js --write '**/*.hbs'", @@ -29,8 +30,8 @@ "start": "VAULT_ADDR=http://127.0.0.1:8200; ember server --proxy=$VAULT_ADDR", "start2": "ember server --proxy=http://127.0.0.1:8202 --port=4202", "start:chroot": "ember server --proxy=http://127.0.0.1:8300 --port=4300", - "test": "concurrently --kill-others-on-fail -P -c \"auto\" -n lint:js,lint:hbs,vault \"yarn:lint:js:quiet\" \"yarn:lint:hbs:quiet\" \"node scripts/start-vault.js {@}\" --", - "test:enos": "concurrently --kill-others-on-fail -P -c \"auto\" -n lint:js,lint:hbs,enos \"yarn:lint:js:quiet\" \"yarn:lint:hbs:quiet\" \"node scripts/enos-test-ember.js {@}\" --", + "test": "concurrently --kill-others-on-fail -P -c \"auto\" -n lint:js,lint:hbs,lint:types,vault \"yarn:lint:js:quiet\" \"yarn:lint:hbs:quiet\" \"yarn:lint:types\" \"node scripts/start-vault.js {@}\" --", + "test:enos": "concurrently --kill-others-on-fail -P -c \"auto\" -n lint:js,lint:hbs,lint:types,enos \"yarn:lint:js:quiet\" \"yarn:lint:hbs:quiet\" \"yarn:lint:types\" \"node scripts/enos-test-ember.js {@}\" --", "test:oss": "yarn run test -f='!enterprise'", "test:ent": "node scripts/start-vault.js -f='enterprise'", "test:quick": "node scripts/start-vault.js --split=8 --preserve-test-name --parallel", @@ -39,22 +40,6 @@ "vault": "VAULT_REDIRECT_ADDR=http://127.0.0.1:8200 vault server -log-level=error -dev -dev-root-token-id=root -dev-ha -dev-transactional", "vault:cluster": "VAULT_REDIRECT_ADDR=http://127.0.0.1:8202 vault server -log-level=error -dev -dev-root-token-id=root -dev-listen-address=127.0.0.1:8202 -dev-ha -dev-transactional" }, - "lint-staged": { - "*.js": [ - "prettier --config .prettierrc.js --write", - "eslint --quiet", - "git add" - ], - "*.hbs": [ - "prettier --config .prettierrc.js --write", - "ember-template-lint --quiet", - "git add" - ], - "*.scss": [ - "prettier --write", - "git add" - ] - }, "devDependencies": { "@babel/cli": "^7.24.6", "@babel/core": "^7.23.2", @@ -78,6 +63,7 @@ "@lineal-viz/lineal": "^0.5.1", "@tsconfig/ember": "^2.0.0", "@types/d3-array": "^3.2.1", + "@types/ember-data": "^4.4.16", "@types/qunit": "^2.19.4", "@types/rsvp": "^4.0.4", "@types/shell-quote": "^1.7.1", diff --git a/ui/tests/helpers/pki/pki-helpers.ts b/ui/tests/helpers/pki/pki-helpers.ts index 3552e93e74..7942798eb6 100644 --- a/ui/tests/helpers/pki/pki-helpers.ts +++ b/ui/tests/helpers/pki/pki-helpers.ts @@ -3,13 +3,13 @@ * SPDX-License-Identifier: BUSL-1.1 */ -import type StoreService from 'vault/services/store'; +import type Store from '@ember-data/store'; export const PKI_BASE_URL = `/vault/cluster/secrets/backend/pki/roles`; // Clears pki-related data and capabilities so that admin // capabilities from setup don't rollover -export function clearRecords(store: StoreService) { +export function clearRecords(store: Store) { store.unloadAll('pki/action'); store.unloadAll('pki/issuer'); store.unloadAll('pki/key'); diff --git a/ui/types/@ember-data/adapter/error.d.ts b/ui/types/@ember-data/adapter/error.d.ts new file mode 100644 index 0000000000..ec62f95228 --- /dev/null +++ b/ui/types/@ember-data/adapter/error.d.ts @@ -0,0 +1,19 @@ +/** + * Copyright (c) HashiCorp, Inc. + * SPDX-License-Identifier: BUSL-1.1 + */ + +import Error from 'ember-data/adapter/errors'; + +export type ApiError = string | { [key: string]: unknown; title?: string; message?: string }; + +export default class AdapterError extends Error { + httpStatus: number; + path: string; + message: string; + errors: ApiError[]; + data?: { + [key: string]: unknown; + error?: string; + }; +} diff --git a/ui/types/@ember-data/store.d.ts b/ui/types/@ember-data/store.d.ts new file mode 100644 index 0000000000..a7502540ba --- /dev/null +++ b/ui/types/@ember-data/store.d.ts @@ -0,0 +1,8 @@ +/** + * Copyright (c) HashiCorp, Inc. + * SPDX-License-Identifier: BUSL-1.1 + */ + +import Store from 'ember-data/store'; + +export default Store; diff --git a/ui/types/ember-data/types/registries/adapter.d.ts b/ui/types/ember-data/types/registries/adapter.d.ts index 928285d316..5eadb0f38d 100644 --- a/ui/types/ember-data/types/registries/adapter.d.ts +++ b/ui/types/ember-data/types/registries/adapter.d.ts @@ -30,7 +30,3 @@ export default interface AdapterRegistry { application: Application; [key: keyof ModelRegistry]: Adapter; } - -export default interface AdapterError extends Error { - httpStatus: number; -} diff --git a/ui/types/ember-data/types/registries/model.d.ts b/ui/types/ember-data/types/registries/model.d.ts index eb5485c757..6f1db4c070 100644 --- a/ui/types/ember-data/types/registries/model.d.ts +++ b/ui/types/ember-data/types/registries/model.d.ts @@ -8,19 +8,29 @@ import KvSecretDataModel from 'vault/models/kv/data'; import KvSecretMetadataModel from 'vault/models/kv/metadata'; import PkiActionModel from 'vault/models/pki/action'; import PkiCertificateGenerateModel from 'vault/models/pki/certificate/generate'; +import PkiConfigAcmeModel from 'vault/models/pki/config/acme'; +import PkiConfigClusterModel from 'vault/models/pki/config/cluster'; +import PkiConfigCrlModel from 'vault/models/pki/config/crl'; +import PkiConfigUrlsModel from 'vault/models/pki/config/urls'; import ClientsActivityModel from 'vault/models/clients/activity'; import ClientsConfigModel from 'vault/models/clients/config'; import ClientsVersionHistoryModel from 'vault/models/clients/version-history'; +import CaConfigModel from 'vault/models/ssh/ca-config'; declare module 'ember-data/types/registries/model' { export default interface ModelRegistry { 'pki/action': PkiActionModel; 'pki/certificate/generate': PkiCertificateGenerateModel; + 'pki/config/acme': PkiConfigAcmeModel; + 'pki/config/cluster': PkiConfigClusterModel; + 'pki/config/crl': PkiConfigCrlModel; + 'pki/config/urls': PkiConfigUrlModel; 'kv/data': KvSecretDataModel; 'kv/metadata': KvSecretMetadataModel; 'clients/activity': ClientsActivityModel; 'clients/config': ClientsConfigModel; 'clients/version-history': ClientsVersionHistoryModel; + 'ssh/ca-config': CaConfigModel; // Catchall for any other models [key: string]: any; } diff --git a/ui/types/vault/app-types.ts b/ui/types/vault/app-types.ts index f578e6f8fe..a5bf890b1c 100644 --- a/ui/types/vault/app-types.ts +++ b/ui/types/vault/app-types.ts @@ -2,7 +2,7 @@ * Copyright (c) HashiCorp, Inc. * SPDX-License-Identifier: BUSL-1.1 */ -import type EmberDataModel from '@ember-data/model'; +import type EmberDataModel from 'ember-data/model'; // eslint-disable-line ember/use-ember-data-rfc-395-imports import type Owner from '@ember/owner'; // Type that comes back from expandAttributeMeta @@ -43,22 +43,24 @@ export interface ModelValidations { invalidFormMessage: string; } -export interface Model extends Omit { +export type Model = Omit & { // override isNew which is a computed prop and ts will complain since it sees it as a function isNew: boolean; -} +}; -export interface WithFormFieldsModel extends Model { +export type WithFormFieldsModel = Model & { formFields: Array; formFieldGroups: FormFieldGroups; allFields: Array; -} +}; -export interface WithValidationsModel extends Model { +export type WithValidationsModel = Model & { validate(): ModelValidations; -} +}; -export interface WithFormFieldsAndValidationsModel extends WithFormFieldsModel, WithValidationsModel {} +export type WithFormFieldsAndValidationsModel = WithFormFieldsModel & { + validate(): ModelValidations; +}; export interface Breadcrumb { label: string; diff --git a/ui/types/vault/models/capabilities.d.ts b/ui/types/vault/models/capabilities.d.ts index 9ef39f7e2d..b76960eb1a 100644 --- a/ui/types/vault/models/capabilities.d.ts +++ b/ui/types/vault/models/capabilities.d.ts @@ -4,9 +4,9 @@ */ import ComputedProperty from '@ember/object/computed'; -import Model from '@ember-data/model'; +import { Model } from 'vault/app-types'; -interface CapabilitiesModel extends Model { +type CapabilitiesModel = Model & { path: string; capabilities: Array; canCreate: ComputedProperty; @@ -20,7 +20,7 @@ interface CapabilitiesModel extends Model { // inferring type from key name allowedParameters: Array; deniedParameters: Array; -} +}; export default CapabilitiesModel; export const SUDO_PATHS: string[]; diff --git a/ui/types/vault/models/mount-config.d.ts b/ui/types/vault/models/mount-config.d.ts index a463296112..0f3489a0d7 100644 --- a/ui/types/vault/models/mount-config.d.ts +++ b/ui/types/vault/models/mount-config.d.ts @@ -15,4 +15,5 @@ export default class MountConfigModel extends Model { allowedResponseHeaders: string; tokenType: string; allowedManagedKeys: string; + identityTokenKey: string; } diff --git a/ui/types/vault/models/pki/action.d.ts b/ui/types/vault/models/pki/action.d.ts index 851049a0f4..89dbf1ce99 100644 --- a/ui/types/vault/models/pki/action.d.ts +++ b/ui/types/vault/models/pki/action.d.ts @@ -3,11 +3,10 @@ * SPDX-License-Identifier: BUSL-1.1 */ -import Model from '@ember-data/model'; -import { FormField, ModelValidations, StringMap } from 'vault/app-types'; -import CapabilitiesModel from '../capabilities'; +import type { StringMap, WithFormFieldsAndValidationsModel } from 'vault/app-types'; +import type CapabilitiesModel from '../capabilities'; -export default class PkiActionModel extends Model { +type PkiActionModel = WithFormFieldsAndValidationsModel & { secretMountPath: unknown; actionType: string | null; pemBundle: string; @@ -51,11 +50,11 @@ export default class PkiActionModel extends Model { generateIssuerRootPath: Promise; generateIssuerCsrPath: Promise; crossSignPath: string; - allFields: Array; - validate(): ModelValidations; // Capabilities get canImportBundle(): boolean; get canGenerateIssuerRoot(): boolean; get canGenerateIssuerIntermediate(): boolean; get canCrossSign(): boolean; -} +}; + +export default PkiActionModel; diff --git a/ui/types/vault/models/pki/certificate/base.d.ts b/ui/types/vault/models/pki/certificate/base.d.ts index 9a8632aca7..2162c71eb6 100644 --- a/ui/types/vault/models/pki/certificate/base.d.ts +++ b/ui/types/vault/models/pki/certificate/base.d.ts @@ -3,8 +3,9 @@ * SPDX-License-Identifier: BUSL-1.1 */ -import Model from '@ember-data/model'; -export default class PkiCertificateBaseModel extends Model { +import type { WithFormFieldsAndValidationsModel } from 'vault/app-types'; + +type PkiCertificateBaseModel = WithFormFieldsAndValidationsModel & { secretMountPath: class; get backend(): string; altNames: string; @@ -24,4 +25,6 @@ export default class PkiCertificateBaseModel extends Model { revocationTime: number; serialNumber: string; get canRevoke(): boolean; -} +}; + +export default PkiCertificateBaseModel; diff --git a/ui/types/vault/models/pki/certificate/generate.d.ts b/ui/types/vault/models/pki/certificate/generate.d.ts index db7ad7c03e..eec5b537c2 100644 --- a/ui/types/vault/models/pki/certificate/generate.d.ts +++ b/ui/types/vault/models/pki/certificate/generate.d.ts @@ -3,11 +3,10 @@ * SPDX-License-Identifier: BUSL-1.1 */ -import { FormField, FormFieldGroups } from 'vault/app-types'; -import PkiCertificateBaseModel from './base'; +import type PkiCertificateBaseModel from './base'; -export default class PkiCertificateGenerateModel extends PkiCertificateBaseModel { +type PkiCertificateGenerateModel = PkiCertificateBaseModel & { role: string; - formFields: FormField[]; - formFieldGroups: FormFieldGroups; -} +}; + +export default PkiCertificateGenerateModel; diff --git a/ui/types/vault/models/pki/certificate/sign-intermediate.d.ts b/ui/types/vault/models/pki/certificate/sign-intermediate.d.ts index 75860dbe1d..34398ebc31 100644 --- a/ui/types/vault/models/pki/certificate/sign-intermediate.d.ts +++ b/ui/types/vault/models/pki/certificate/sign-intermediate.d.ts @@ -3,13 +3,11 @@ * SPDX-License-Identifier: BUSL-1.1 */ -import PkiCertificateBaseModel from './base'; -import { FormField, FormFieldGroups, ModelValidations } from 'vault/app-types'; -export default class PkiCertificateSignIntermediateModel extends PkiCertificateBaseModel { +import type PkiCertificateBaseModel from './base'; + +type PkiCertificateSignIntermediateModel = PkiCertificateBaseModel & { role: string; csr: string; - formFields: FormField[]; - formFieldGroups: FormFieldGroups; issuerRef: string; maxPathLength: string; notBeforeDuration: string; @@ -18,5 +16,6 @@ export default class PkiCertificateSignIntermediateModel extends PkiCertificateB usePss: boolean; skid: string; signatureBits: string; - validate(): ModelValidations; -} +}; + +export default PkiCertificateSignIntermediateModel; diff --git a/ui/types/vault/models/pki/certificate/sign.d.ts b/ui/types/vault/models/pki/certificate/sign.d.ts index 1521cde9a6..ed17b39ba5 100644 --- a/ui/types/vault/models/pki/certificate/sign.d.ts +++ b/ui/types/vault/models/pki/certificate/sign.d.ts @@ -3,13 +3,12 @@ * SPDX-License-Identifier: BUSL-1.1 */ -import PkiCertificateBaseModel from './base'; -import { FormField, FormFieldGroups, ModelValidations } from 'vault/app-types'; -export default class PkiCertificateSignModel extends PkiCertificateBaseModel { +import type PkiCertificateBaseModel from './base'; + +export type PkiCertificateSignModel = PkiCertificateBaseModel & { role: string; csr: string; - formFields: FormField[]; - formFieldGroups: FormFieldGroups; removeRootsFromChain: boolean; - validate(): ModelValidations; -} +}; + +export default PkiCertificateSignModel; diff --git a/ui/types/vault/models/pki/config/acme.d.ts b/ui/types/vault/models/pki/config/acme.d.ts new file mode 100644 index 0000000000..f81e6ada4e --- /dev/null +++ b/ui/types/vault/models/pki/config/acme.d.ts @@ -0,0 +1,22 @@ +/** + * Copyright (c) HashiCorp, Inc. + * SPDX-License-Identifier: BUSL-1.1 + */ + +import type { Model } from 'vault/app-types'; +import type CapabilitiesModel from 'vault/models/capabilities'; + +type PkiConfigAcmeModel = Model & { + enabled: boolean; + defaultDirectoryPolicy: string; + allowedRoles: string[]; + allowRoleExtKeyUsage: boolean; + allowedIssuers: string[]; + eabPolicy: string; + dnsResolver: string; + maxTtl: string; + acmePath: CapabilitiesModel; + get canSet(): boolean; +}; + +export default PkiConfigAcmeModel; diff --git a/ui/types/vault/models/pki/config/cluster.d.ts b/ui/types/vault/models/pki/config/cluster.d.ts new file mode 100644 index 0000000000..4614ca3077 --- /dev/null +++ b/ui/types/vault/models/pki/config/cluster.d.ts @@ -0,0 +1,16 @@ +/** + * Copyright (c) HashiCorp, Inc. + * SPDX-License-Identifier: BUSL-1.1 + */ + +import type { Model } from 'vault/app-types'; +import type CapabilitiesModel from 'vault/models/capabilities'; + +type PkiConfigClusterModel = Model & { + path: boolean; + aiaPath: string; + clusterPath: CapabilitiesModel; + get canSet(): boolean; +}; + +export default PkiConfigClusterModel; diff --git a/ui/types/vault/models/pki/config/crl.d.ts b/ui/types/vault/models/pki/config/crl.d.ts index b558f5f9cb..1b4000c86d 100644 --- a/ui/types/vault/models/pki/config/crl.d.ts +++ b/ui/types/vault/models/pki/config/crl.d.ts @@ -3,10 +3,9 @@ * SPDX-License-Identifier: BUSL-1.1 */ -import Model from '@ember-data/model'; -import { FormField } from 'vault/app-types'; +import type { WithFormFieldsModel } from 'vault/app-types'; -export default class PkiConfigCrlModel extends Model { +type PkiConfigCrlModel = WithFormFieldsModel & { autoRebuild: boolean; autoRebuildGracePeriod: string; enableDelta: boolean; @@ -16,6 +15,7 @@ export default class PkiConfigCrlModel extends Model { ocspExpiry: string; ocspDisable: boolean; crlPath: string; - formFields: FormField[]; get canSet(): boolean; -} +}; + +export default PkiConfigCrlModel; diff --git a/ui/types/vault/models/pki/config/urls.d.ts b/ui/types/vault/models/pki/config/urls.d.ts index 47c1b43eb4..c4999b17a3 100644 --- a/ui/types/vault/models/pki/config/urls.d.ts +++ b/ui/types/vault/models/pki/config/urls.d.ts @@ -3,12 +3,14 @@ * SPDX-License-Identifier: BUSL-1.1 */ -import Model from '@ember-data/model'; +import type { Model } from 'vault/app-types'; -export default class PkiConfigUrlsModel extends Model { +type PkiConfigUrlsModel = Model & { issuingCertificates: array; crlDistributionPoints: array; ocspServers: array; urlsPath: string; get canSet(): boolean; -} +}; + +export default PkiConfigUrlsModel; diff --git a/ui/types/vault/models/pki/issuer.d.ts b/ui/types/vault/models/pki/issuer.d.ts index 4c56c04e61..7954dbe167 100644 --- a/ui/types/vault/models/pki/issuer.d.ts +++ b/ui/types/vault/models/pki/issuer.d.ts @@ -2,11 +2,11 @@ * Copyright (c) HashiCorp, Inc. * SPDX-License-Identifier: BUSL-1.1 */ +import type { WithFormFieldsAndValidationsModel } from 'vault/app-types'; +import type { ParsedCertificateData } from 'vault/utils/parse-pki-cert'; +import type CapabilitiesModel from 'vault/models/capabilities'; -import Model from '@ember-data/model'; -import { FormField, FormFieldGroups, ModelValidations } from 'vault/app-types'; -import { ParsedCertificateData } from 'vault/vault/utils/parse-pki-cert'; -export default class PkiIssuerModel extends Model { +type PkiIssuerModel = WithFormFieldsAndValidationsModel & { secretMountPath: class; get backend(): string; get issuerRef(): string; @@ -22,22 +22,18 @@ export default class PkiIssuerModel extends Model { crlDistributionPoints: string; ocspServers: string; parsedCertificate: ParsedCertificateData; - /** these are all instances of the capabilities model which should be converted to native class and typed - rotateExported: any; - rotateInternal: any; - rotateExisting: any; - crossSignPath: any; - signIntermediate: any; - -------------------- **/ + rotateExported: CapabilitiesModel; + rotateInternal: CapabilitiesModel; + rotateExisting: CapabilitiesModel; + crossSignPath: CapabilitiesModel; + signIntermediate: CapabilitiesModel; pemBundle: string; importedIssuers: string[]; importedKeys: string[]; - formFields: FormField[]; - formFieldGroups: FormFieldGroups[]; - allFields: FormField[]; get canRotateIssuer(): boolean; get canCrossSign(): boolean; get canSignIntermediate(): boolean; get canConfigure(): boolean; - validate(): ModelValidations; -} +}; + +export default PkiIssuerModel; diff --git a/ui/types/vault/models/pki/key.d.ts b/ui/types/vault/models/pki/key.d.ts index 7f82b2d1a1..8cbba1a936 100644 --- a/ui/types/vault/models/pki/key.d.ts +++ b/ui/types/vault/models/pki/key.d.ts @@ -3,10 +3,9 @@ * SPDX-License-Identifier: BUSL-1.1 */ -import Model from '@ember-data/model'; -import { ModelValidations } from 'vault/app-types'; +import type { WithValidationsModel } from 'vault/app-types'; -export default class PkiKeyModel extends Model { +type PkiKeyModel = WithValidationsModel & { secretMountPath: class; keyId: string; keyName: string; @@ -15,12 +14,12 @@ export default class PkiKeyModel extends Model { keyBits: string; pemBundle: string; privateKey: string; - isNew: boolean; get backend(): string; get canRead(): boolean; get canEdit(): boolean; get canDelete(): boolean; get canGenerateKey(): boolean; get canImportKey(): boolean; - validate(): ModelValidations; -} +}; + +export default PkiKeyModel; diff --git a/ui/types/vault/models/pki/role.d.ts b/ui/types/vault/models/pki/role.d.ts index fddc804073..814daa6128 100644 --- a/ui/types/vault/models/pki/role.d.ts +++ b/ui/types/vault/models/pki/role.d.ts @@ -3,14 +3,13 @@ * SPDX-License-Identifier: BUSL-1.1 */ -import Model from '@ember-data/model'; -import { ModelValidations } from 'vault/app-types'; +import type { WithValidationsModel } from 'vault/app-types'; -export default class PkiRoleModel extends Model { +type PkiRoleModel = WithValidationsModel & { name: string; issuerRef: string; - validate(): ModelValidations; - isNew: boolean; keyType: string; keyBits: string | undefined; -} +}; + +export default PkiRoleModel; diff --git a/ui/types/vault/models/pki/tidy.d.ts b/ui/types/vault/models/pki/tidy.d.ts index 1dd13330ff..42c24e1354 100644 --- a/ui/types/vault/models/pki/tidy.d.ts +++ b/ui/types/vault/models/pki/tidy.d.ts @@ -3,10 +3,9 @@ * SPDX-License-Identifier: BUSL-1.1 */ -import Model from '@ember-data/model'; -import { FormField, FormFieldGroups } from 'vault/vault/app-types'; +import type { FormField, FormFieldGroups, WithFormFieldsModel } from 'vault/app-types'; -export default class PkiTidyModel extends Model { +type PkiTidyModel = WithFormFieldsModel & { version: string; acmeAccountSafetyBuffer: string; tidyAcme: boolean; @@ -29,7 +28,7 @@ export default class PkiTidyModel extends Model { allByKey: { intervalDuration: FormField[]; }; - get allGroups(): FormFieldGroups[]; get sharedFields(): FormFieldGroups[]; - get formFieldGroups(): FormFieldGroups[]; -} +}; + +export default PkiTidyModel; diff --git a/ui/types/vault/models/ssh/ca-config.d.ts b/ui/types/vault/models/ssh/ca-config.d.ts new file mode 100644 index 0000000000..d36f421967 --- /dev/null +++ b/ui/types/vault/models/ssh/ca-config.d.ts @@ -0,0 +1,17 @@ +/** + * Copyright (c) HashiCorp, Inc. + * SPDX-License-Identifier: BUSL-1.1 + */ + +import { FormField, WithFormFieldsAndValidationsModel } from 'vault/app-types'; + +export default interface SshCaConfig extends WithFormFieldsAndValidationsModel { + backend: string; + privateKey: string; + publicKey: string; + generateSigningKey: boolean; + + configurableParams: ['privateKey', 'publicKey', 'generateSigningKey']; + + get displayAttrs(): FormField[]; +} diff --git a/ui/types/vault/services/store.d.ts b/ui/types/vault/services/store.d.ts deleted file mode 100644 index 970990b691..0000000000 --- a/ui/types/vault/services/store.d.ts +++ /dev/null @@ -1,14 +0,0 @@ -/** - * Copyright (c) HashiCorp, Inc. - * SPDX-License-Identifier: BUSL-1.1 - */ - -import Store from '@ember-data/store'; - -export default class StoreService extends Store { - adapterFor(modelName: string); - createRecord(modelName: string, object); - findRecord(modelName: string, path: string); - peekRecord(modelName: string, path: string); - query(modelName: string, query: object); -} diff --git a/ui/yarn.lock b/ui/yarn.lock index ec433e9101..f961470ba8 100644 --- a/ui/yarn.lock +++ b/ui/yarn.lock @@ -1967,7 +1967,7 @@ __metadata: languageName: node linkType: hard -"@glimmer/component@npm:^1.1.2": +"@glimmer/component@npm:^1.1.0, @glimmer/component@npm:^1.1.2": version: 1.1.2 resolution: "@glimmer/component@npm:1.1.2" dependencies: @@ -3062,6 +3062,201 @@ __metadata: languageName: node linkType: hard +"@types/ember-data@npm:^4.4.16": + version: 4.4.16 + resolution: "@types/ember-data@npm:4.4.16" + dependencies: + "@types/ember": "*" + "@types/ember__error": "*" + "@types/ember__object": "*" + "@types/rsvp": "*" + checksum: 7edbc8cd27d440e63b179df010064a580fa8c0b18b03f4efc091599848cb82bab266ea704947c5038d35b17d65b0f64d88a3de9cb1328466c1a35da6da2c5f08 + languageName: node + linkType: hard + +"@types/ember@npm:*": + version: 4.0.11 + resolution: "@types/ember@npm:4.0.11" + dependencies: + "@types/ember__application": "*" + "@types/ember__array": "*" + "@types/ember__component": "*" + "@types/ember__controller": "*" + "@types/ember__debug": "*" + "@types/ember__engine": "*" + "@types/ember__error": "*" + "@types/ember__object": "*" + "@types/ember__polyfills": "*" + "@types/ember__routing": "*" + "@types/ember__runloop": "*" + "@types/ember__service": "*" + "@types/ember__string": "*" + "@types/ember__template": "*" + "@types/ember__test": "*" + "@types/ember__utils": "*" + "@types/rsvp": "*" + checksum: cda022b2f439f20a60d0834f592459722819654cb48c8f6f3661ad64b3efc8230844f1b112b29995bac44e62b6c95a2caf1f0f330f0df9d56a141dcac6f2b7ca + languageName: node + linkType: hard + +"@types/ember__application@npm:*": + version: 4.0.11 + resolution: "@types/ember__application@npm:4.0.11" + dependencies: + "@glimmer/component": ^1.1.0 + "@types/ember": "*" + "@types/ember__engine": "*" + "@types/ember__object": "*" + "@types/ember__owner": "*" + "@types/ember__routing": "*" + checksum: ba9e913fd2d965f205923817cbdef1353cf05c496c76d6179f75af041b9a4fd0368f5dd96adfeb8df97bc398bfb34073cfd1c1a33bb10e63f065a2150b98c9ef + languageName: node + linkType: hard + +"@types/ember__array@npm:*": + version: 4.0.10 + resolution: "@types/ember__array@npm:4.0.10" + dependencies: + "@types/ember": "*" + "@types/ember__object": "*" + checksum: 3ec77e13466c130d1af8c468e4a8d33a35060ea89bbd7fdcaf48650f2a88e0a5cdfa3fd15a62e780531f0937e7115635600d6b7cd486398087391f5c900f5934 + languageName: node + linkType: hard + +"@types/ember__component@npm:*": + version: 4.0.22 + resolution: "@types/ember__component@npm:4.0.22" + dependencies: + "@types/ember": "*" + "@types/ember__object": "*" + checksum: ef2b7141ca6dabbc311158a253ce6184d56ad691cb6fb22b0ff8f2ac0109fb4f929deef66ef56cf40a1b069cc52d23a1a6e3d511cab56fb29302b6be848e8259 + languageName: node + linkType: hard + +"@types/ember__controller@npm:*": + version: 4.0.12 + resolution: "@types/ember__controller@npm:4.0.12" + dependencies: + "@types/ember__object": "*" + checksum: 02001690069e1e537fc92d84d2de103693e499bc2c7ba12597a454aa7c45b7d1b93092232c44601d06915f28240ec189eb1ca0aaec139ebf39dd63e6b42b197b + languageName: node + linkType: hard + +"@types/ember__debug@npm:*": + version: 4.0.8 + resolution: "@types/ember__debug@npm:4.0.8" + dependencies: + "@types/ember__object": "*" + "@types/ember__owner": "*" + checksum: a379664f6de9c63e37c6d834185e0609a7ee3e7993650912bf0a02c51770b94818b86fa7928b80f7df3b32e4cdcc5344917da65341d66d0950599ad11656e5a4 + languageName: node + linkType: hard + +"@types/ember__engine@npm:*": + version: 4.0.11 + resolution: "@types/ember__engine@npm:4.0.11" + dependencies: + "@types/ember__object": "*" + "@types/ember__owner": "*" + checksum: 55a2fc9eb82f64e5d87d74b0624198b0ae898389ec5bb5ff845234aa60e4c8d72ccfe99bec449b3edd3f236f38d1ad5f07e64bb1daf9aacd0441a86041b4d56a + languageName: node + linkType: hard + +"@types/ember__error@npm:*": + version: 4.0.6 + resolution: "@types/ember__error@npm:4.0.6" + checksum: 8433d8960925ac59870f8152b32e9e2ee31fdcb89d2446d268a40fa68bd7551dc8cf168ff6d1dce66b56ad36a877c77e3c53da337259b76afc04b8553c995c84 + languageName: node + linkType: hard + +"@types/ember__object@npm:*": + version: 4.0.12 + resolution: "@types/ember__object@npm:4.0.12" + dependencies: + "@types/ember": "*" + "@types/rsvp": "*" + checksum: 0c17e20b59e0c530be61cd539a01845aecebabb3750c0e2b5ca6af5118b3ddbffe75bedeaa1d279a19cbc216e1b6085207c130bf5c0cc9a172a354eb034c13d3 + languageName: node + linkType: hard + +"@types/ember__owner@npm:*": + version: 4.0.9 + resolution: "@types/ember__owner@npm:4.0.9" + checksum: b8e7aad0dac031e240f78b5b263e295da3d7450d6e4a76054be95b9e23e091edc4d7d728d098999722c7500616f33275d02f5b5c3095aa5f5b4c0d81e6052311 + languageName: node + linkType: hard + +"@types/ember__polyfills@npm:*": + version: 4.0.6 + resolution: "@types/ember__polyfills@npm:4.0.6" + checksum: 331d2dd66d106ffd67866d20186da1d6321080692de174bc7f61618735228f67ae41bc435c79fbce9532bd0a63d3489f73843edefe555f63021d28ee70fb0ea8 + languageName: node + linkType: hard + +"@types/ember__routing@npm:*": + version: 4.0.22 + resolution: "@types/ember__routing@npm:4.0.22" + dependencies: + "@types/ember": "*" + "@types/ember__controller": "*" + "@types/ember__object": "*" + "@types/ember__service": "*" + checksum: 377ec37cc2e7062ae4d5423d056957825b7116fb749b55f505d9dce8c1e0affb330c4249c6db97eb76f0c738f1b45711e90a78c0d9af245015f8a8bfa9f6971c + languageName: node + linkType: hard + +"@types/ember__runloop@npm:*": + version: 4.0.10 + resolution: "@types/ember__runloop@npm:4.0.10" + dependencies: + "@types/ember": "*" + checksum: 9a25acc53969640324ef14b0802a57b1b34ba45d2bea4653d401be691c134584ccb43807218784ea8bcf4efcf680f941dc015bda9a8d63f13ed8f7fa4c4ed15a + languageName: node + linkType: hard + +"@types/ember__service@npm:*": + version: 4.0.9 + resolution: "@types/ember__service@npm:4.0.9" + dependencies: + "@types/ember__object": "*" + checksum: 1459e93f13a019a5d824349642aa39b7b7e1ddb6970f04592076b2c1f2027a98f43acf5bda20874cfe45821f8731e982abeff0f09bed6f00bdc468ba1ee28dfd + languageName: node + linkType: hard + +"@types/ember__string@npm:*": + version: 3.16.3 + resolution: "@types/ember__string@npm:3.16.3" + dependencies: + "@types/ember__template": "*" + checksum: ee5998efc58c663dd316743ed91b1e0242321ccb79b83e2eae666e33570df8533a1ee25311ba156ec077ef63a8cbaadcf66d58cc440b86787e7a5f8e19f9f529 + languageName: node + linkType: hard + +"@types/ember__template@npm:*": + version: 4.0.7 + resolution: "@types/ember__template@npm:4.0.7" + checksum: 6641c12dc0d33d9dcf0d67306e42acbc3c9cca0d6c21d93d0c616eafa89a0ebb35f8253dc9bf6eeced3a84e3222f8b4f64bdf69de294e5a3e53e03ea414feac4 + languageName: node + linkType: hard + +"@types/ember__test@npm:*": + version: 4.0.6 + resolution: "@types/ember__test@npm:4.0.6" + dependencies: + "@types/ember__application": "*" + checksum: aeea4a6b9f716e6205f2c7334f1047c2ed88573279d3b6fa6bf23780031ceaaa5f97bb9bf9f589b50dc77807d78d5fb868b727be34a8bb15bc673b5c5f6318a5 + languageName: node + linkType: hard + +"@types/ember__utils@npm:*": + version: 4.0.7 + resolution: "@types/ember__utils@npm:4.0.7" + dependencies: + "@types/ember": "*" + checksum: b14162ae496771afa41bbc2edf301edee62a52a43408c3c2b98337f8417ad47d187a205ab5235e11679af2002432f5bf447096ecdbc5e3a9b0b3aa163a1f603d + languageName: node + linkType: hard + "@types/eslint@npm:^8.4.2, @types/eslint@npm:^8.4.9": version: 8.56.12 resolution: "@types/eslint@npm:8.56.12" @@ -3302,7 +3497,7 @@ __metadata: languageName: node linkType: hard -"@types/rsvp@npm:^4.0.4": +"@types/rsvp@npm:*, @types/rsvp@npm:^4.0.4": version: 4.0.9 resolution: "@types/rsvp@npm:4.0.9" checksum: 2c93a5bab22bd0ecfb6ecc238ca1e7e1dd0dff870d63eb63670d33148112f9d66b0af832e5c31cc0aa6534ab916092938a9b64072377070832808b7b36283a27 @@ -18174,6 +18369,7 @@ __metadata: "@lineal-viz/lineal": ^0.5.1 "@tsconfig/ember": ^2.0.0 "@types/d3-array": ^3.2.1 + "@types/ember-data": ^4.4.16 "@types/qunit": ^2.19.4 "@types/rsvp": ^4.0.4 "@types/shell-quote": ^1.7.1