From 5b9433ce8e8570dca2692606aab76b4a2f34b53e Mon Sep 17 00:00:00 2001 From: Pedro Guerreiro Date: Thu, 9 May 2024 22:18:26 +0100 Subject: [PATCH 01/16] docs: add onyx types descriptions --- .../settings/Wallet/ExpensifyCardPage.tsx | 2 + src/types/onyx/Account.ts | 11 + src/types/onyx/AccountData.ts | 16 + src/types/onyx/Bank.ts | 13 + src/types/onyx/BankAccount.ts | 19 +- src/types/onyx/Beta.ts | 1 + src/types/onyx/BlockedFromConcierge.ts | 1 + src/types/onyx/Card.ts | 60 ++++ src/types/onyx/Console.ts | 7 + src/types/onyx/Credentials.ts | 1 + src/types/onyx/Currency.ts | 2 + src/types/onyx/CustomStatusDraft.ts | 1 + src/types/onyx/DismissedReferralBanners.ts | 10 + src/types/onyx/Download.ts | 1 + src/types/onyx/FrequentlyUsedEmoji.ts | 1 + src/types/onyx/Fund.ts | 44 ++- src/types/onyx/IOU.ts | 91 ++++++ src/types/onyx/IntroSelected.ts | 1 + src/types/onyx/InvitedEmailsToAccountIDs.ts | 1 + src/types/onyx/LastPaymentMethod.ts | 1 + src/types/onyx/LastSelectedDistanceRates.ts | 1 + src/types/onyx/Locale.ts | 1 + src/types/onyx/Login.ts | 2 + src/types/onyx/MapboxAccessToken.ts | 6 + src/types/onyx/Modal.ts | 2 + src/types/onyx/Network.ts | 1 + src/types/onyx/NewGroupChatDraft.ts | 10 + src/types/onyx/Onboarding.ts | 1 + src/types/onyx/OnyxCommon.ts | 12 + src/types/onyx/OnyxUpdatesFromServer.ts | 20 ++ src/types/onyx/PaymentMethod.ts | 12 + src/types/onyx/PersonalBankAccount.ts | 1 + src/types/onyx/PersonalDetails.ts | 7 + src/types/onyx/PlaidBankAccount.ts | 1 + src/types/onyx/PlaidData.ts | 4 + src/types/onyx/Policy.ts | 301 +++++++++++++++++- src/types/onyx/PolicyCategory.ts | 2 + src/types/onyx/PolicyEmployee.ts | 2 + src/types/onyx/PolicyJoinMember.ts | 1 + src/types/onyx/PolicyOwnershipChangeChecks.ts | 8 + src/types/onyx/PolicyTag.ts | 3 + src/types/onyx/PreferredTheme.ts | 1 + src/types/onyx/PriorityMode.ts | 1 + src/types/onyx/PrivatePersonalDetails.ts | 34 ++ src/types/onyx/QuickAction.ts | 2 + src/types/onyx/RecentWaypoint.ts | 1 + src/types/onyx/RecentlyUsedCategories.ts | 1 + src/types/onyx/RecentlyUsedReportFields.ts | 1 + src/types/onyx/RecentlyUsedTags.ts | 1 + src/types/onyx/ReimbursementAccount.ts | 4 + src/types/onyx/Report.ts | 85 ++++- src/types/onyx/ReportAction.ts | 52 +++ src/types/onyx/ReportActionReactions.ts | 4 + src/types/onyx/ReportActionsDraft.ts | 2 + src/types/onyx/ReportActionsDrafts.ts | 2 + src/types/onyx/ReportMetadata.ts | 1 + src/types/onyx/ReportNextStep.ts | 17 + src/types/onyx/ReportUserIsTyping.ts | 1 + src/types/onyx/Request.ts | 32 ++ src/types/onyx/Response.ts | 39 +++ src/types/onyx/ScreenShareRequest.ts | 1 + src/types/onyx/SecurityGroup.ts | 2 + src/types/onyx/SelectedTabRequest.ts | 1 + src/types/onyx/Session.ts | 3 + src/types/onyx/Task.ts | 1 + src/types/onyx/Transaction.ts | 108 ++++++- src/types/onyx/TransactionViolation.ts | 44 +++ src/types/onyx/User.ts | 1 + src/types/onyx/UserLocation.ts | 1 + src/types/onyx/UserWallet.ts | 4 + src/types/onyx/WalletAdditionalDetails.ts | 13 + src/types/onyx/WalletOnfido.ts | 1 + src/types/onyx/WalletStatement.ts | 1 + src/types/onyx/WalletTerms.ts | 1 + src/types/onyx/WalletTransfer.ts | 3 + src/types/onyx/WorkspaceRateAndUnit.ts | 4 +- 76 files changed, 1146 insertions(+), 6 deletions(-) diff --git a/src/pages/settings/Wallet/ExpensifyCardPage.tsx b/src/pages/settings/Wallet/ExpensifyCardPage.tsx index 49686e19852c..2f4135820b08 100644 --- a/src/pages/settings/Wallet/ExpensifyCardPage.tsx +++ b/src/pages/settings/Wallet/ExpensifyCardPage.tsx @@ -116,6 +116,8 @@ function ExpensifyCardPage({ // eslint-disable-next-line rulesdir/no-thenable-actions-in-views Card.revealVirtualCardDetails(revealedCardID) .then((value) => { + // TODO: Card.revealVirtualCardDetails return type doesn't include TCardDetails, forcing us to type cast it here. + // The return type could be rewritten like Promise setCardsDetails((prevState: Record) => ({...prevState, [revealedCardID]: value as TCardDetails})); setCardsDetailsErrors((prevState) => ({ ...prevState, diff --git a/src/types/onyx/Account.ts b/src/types/onyx/Account.ts index c53d7ea816f8..95a0f4ce5314 100644 --- a/src/types/onyx/Account.ts +++ b/src/types/onyx/Account.ts @@ -4,8 +4,10 @@ import type DismissedReferralBanners from './DismissedReferralBanners'; import type * as OnyxCommon from './OnyxCommon'; import type {TravelSettings} from './TravelSettings'; +/** Two factor authentication steps */ type TwoFactorAuthStep = ValueOf | ''; +/** Model of user account */ type Account = { /** Whether SAML is enabled for the current account */ isSAMLEnabled?: boolean; @@ -55,10 +57,19 @@ type Account = { /** Whether a sign is loading */ isLoading?: boolean; + /** Authentication failure errors */ errors?: OnyxCommon.Errors | null; + + /** Authentication success message */ success?: string; + + /** Whether the two factor authentication codes were copied */ codesAreCopied?: boolean; + + /** Current two factor authentication step */ twoFactorAuthStep?: TwoFactorAuthStep; + + /** Referral banners that the user dismissed */ dismissedReferralBanners?: DismissedReferralBanners; /** Object containing all account information necessary to connect with Spontana */ diff --git a/src/types/onyx/AccountData.ts b/src/types/onyx/AccountData.ts index 124a006ff57c..78c8391ac8ae 100644 --- a/src/types/onyx/AccountData.ts +++ b/src/types/onyx/AccountData.ts @@ -1,15 +1,29 @@ import type {BankName} from './Bank'; import type * as OnyxCommon from './OnyxCommon'; +/** Model of additional bank account data */ type AdditionalData = { + /** Is a Peer-To-Peer debit card */ isP2PDebitCard?: boolean; + + /** Owners that can benefit from this bank account */ beneficialOwners?: string[]; + + /** In which currency is the bank account */ currency?: string; + + /** In which bank is the bank account */ bankName?: BankName; + + // TODO: Confirm this + /** Whether the bank account is local or international */ fieldsType?: string; + + /** In which country is the bank account */ country?: string; }; +/** Model of bank account data */ type AccountData = { /** The masked bank account number */ accountNumber?: string; @@ -38,6 +52,7 @@ type AccountData = { /** All user emails that have access to this bank account */ sharees?: string[]; + /** Institution that processes the account payments */ processor?: string; /** The bankAccountID in the bankAccounts db */ @@ -52,6 +67,7 @@ type AccountData = { /** Any error message to show */ errors?: OnyxCommon.Errors; + /** The debit card ID */ fundID?: number; }; diff --git a/src/types/onyx/Bank.ts b/src/types/onyx/Bank.ts index 72b5fcda4788..3eee283da5c6 100644 --- a/src/types/onyx/Bank.ts +++ b/src/types/onyx/Bank.ts @@ -3,15 +3,28 @@ import type {ValueOf} from 'type-fest'; import type CONST from '@src/CONST'; import type IconAsset from '@src/types/utils/IconAsset'; +/** Bank icon configurations */ type BankIcon = { + /** Source of the icon, can be a component or an image */ icon: IconAsset; + + /** Size of the icon */ iconSize?: number; + + /** Height of the icon */ iconHeight?: number; + + /** Width of the icon */ iconWidth?: number; + + /** Icon wrapper styles */ iconStyles?: ViewStyle[]; }; +/** Bank names */ type BankName = ValueOf; + +/** Bank name keys */ type BankNameKey = keyof typeof CONST.BANK_NAMES; export type {BankIcon, BankName, BankNameKey}; diff --git a/src/types/onyx/BankAccount.ts b/src/types/onyx/BankAccount.ts index d0f80708842c..6ca40f37093d 100644 --- a/src/types/onyx/BankAccount.ts +++ b/src/types/onyx/BankAccount.ts @@ -2,15 +2,30 @@ import type CONST from '@src/CONST'; import type AccountData from './AccountData'; import type * as OnyxCommon from './OnyxCommon'; +// TODO: This type is a duplicate of the one present in AccountData.ts +/** Model of additional bank account data */ type AdditionalData = { + /** Is a Peer-To-Peer Debit Card */ isP2PDebitCard?: boolean; + + /** Owners that can benefit from this bank account */ beneficialOwners?: string[]; + + /** In which currency is the bank account */ currency?: string; + + /** In which bank is the bank account */ bankName?: string; + + // TODO: Confirm this + /** Whether the bank account is local or international */ fieldsType?: string; + + /** In which country is the bank account */ country?: string; }; +/** Model of bank account */ type BankAccount = OnyxCommon.OnyxValueWithOfflineFeedback<{ /** The bank account type */ accountType?: typeof CONST.PAYMENT_METHODS.PERSONAL_BANK_ACCOUNT; @@ -18,6 +33,7 @@ type BankAccount = OnyxCommon.OnyxValueWithOfflineFeedback<{ /** string like 'Account ending in XXXX' */ description?: string; + /** Determines if the bank account is a default payment method */ isDefault?: boolean; /* Determines if the bank account is a savings account */ @@ -26,7 +42,7 @@ type BankAccount = OnyxCommon.OnyxValueWithOfflineFeedback<{ /** Date when the 3 micro amounts for validation were supposed to reach the bank account. */ validateCodeExpectedDate?: string; - /** string like 'bankAccount-{}' where is the bankAccountID */ + /** string like 'bankAccount-{\}' where is the bankAccountID */ key?: string; /** Alias for bankAccountID */ @@ -42,6 +58,7 @@ type BankAccount = OnyxCommon.OnyxValueWithOfflineFeedback<{ errors?: OnyxCommon.Errors; }>; +/** Record of bank accounts, indexed by bankAccountID */ type BankAccountList = Record; export default BankAccount; diff --git a/src/types/onyx/Beta.ts b/src/types/onyx/Beta.ts index 35ed4c804ab8..1c282409aea5 100644 --- a/src/types/onyx/Beta.ts +++ b/src/types/onyx/Beta.ts @@ -1,6 +1,7 @@ import type {ValueOf} from 'type-fest'; import type CONST from '@src/CONST'; +/** New Dot Beta features */ type Beta = ValueOf; export default Beta; diff --git a/src/types/onyx/BlockedFromConcierge.ts b/src/types/onyx/BlockedFromConcierge.ts index 4eebd537604c..7274602bee38 100644 --- a/src/types/onyx/BlockedFromConcierge.ts +++ b/src/types/onyx/BlockedFromConcierge.ts @@ -1,3 +1,4 @@ +/** Model of blocked from concierge */ type BlockedFromConcierge = { /** The date that the user will be unblocked */ expiresAt: string; diff --git a/src/types/onyx/Card.ts b/src/types/onyx/Card.ts index 50403b982c0d..4ede25c34be6 100644 --- a/src/types/onyx/Card.ts +++ b/src/types/onyx/Card.ts @@ -2,43 +2,103 @@ import type {ValueOf} from 'type-fest'; import type CONST from '@src/CONST'; import type * as OnyxCommon from './OnyxCommon'; +/** Model of expensify card */ type Card = { + /** Card ID number */ cardID: number; + + /** Current card state */ state: ValueOf; + + /** Bank name */ bank: string; + + /** Available amount to spend */ availableSpend: number; + + /** Domain name */ domainName: string; + + /** Last four Primary Account Number digits */ lastFourPAN?: string; + + /** Determines if the current card was flagged as fraud */ fraud: ValueOf; + + /** Card related error messages */ errors?: OnyxCommon.Errors; + + /** Is card data loading */ isLoading?: boolean; + + /** Additional card data */ nameValuePairs?: { + // TODO: Doesn't seem to be used in app + /** Type of spending limits */ limitType?: ValueOf; + + // TODO: Doesn't seem to be used in app cardTitle?: string; // Used only for admin-issued virtual cards + + // TODO: Doesn't seem to be used in app issuedBy?: number; + + // TODO: Doesn't seem to be used in app hasCustomUnapprovedExpenseLimit?: boolean; + + // TODO: Doesn't seem to be used in app unapprovedExpenseLimit?: number; + + // TODO: Doesn't seem to be used in app feedCountry?: string; + + /** Is a virtual card */ isVirtual?: boolean; + + // TODO: Doesn't seem to be used in app previousState?: number; + + // TODO: Doesn't seem to be used in app + /** Card expiration date */ expirationDate?: string; }; }; +/** Model of expensify card details */ type TCardDetails = { + /** Card Primary Account Number */ pan: string; + + /** Card expiration date */ expiration: string; + + /** Card Verification Value number */ cvv: string; + + // TODO: Doesn't seem to be used in app + /** Card owner address */ address: { + /** Address line 1 */ street: string; + + /** Address line 2 */ street2: string; + + /** City */ city: string; + + /** State */ state: string; + + /** Zip code */ zip: string; + + /** Country */ country: string; }; }; +/** Record of expensify cards, indexed by cardID */ type CardList = Record; export default Card; diff --git a/src/types/onyx/Console.ts b/src/types/onyx/Console.ts index 592d23fecfa0..371782fe9156 100644 --- a/src/types/onyx/Console.ts +++ b/src/types/onyx/Console.ts @@ -1,11 +1,18 @@ import type CONST from '@src/CONST'; +/** Model of a log */ type Log = { + /** Log time */ time: Date; + + /** Log level */ level: keyof typeof CONST.DEBUG_CONSOLE.LEVELS; + + /** Log message */ message: string; }; +/** Record of logs */ type CapturedLogs = Record; export type {Log, CapturedLogs}; diff --git a/src/types/onyx/Credentials.ts b/src/types/onyx/Credentials.ts index 6a22eeb5af89..135cbae5fe76 100644 --- a/src/types/onyx/Credentials.ts +++ b/src/types/onyx/Credentials.ts @@ -1,3 +1,4 @@ +/** Model of user credentials */ type Credentials = { /** The email/phone the user logged in with */ login?: string; diff --git a/src/types/onyx/Currency.ts b/src/types/onyx/Currency.ts index b8d6f8dda88b..69b4203cdbf1 100644 --- a/src/types/onyx/Currency.ts +++ b/src/types/onyx/Currency.ts @@ -1,3 +1,4 @@ +/** Model of currency */ type Currency = { /** Symbol for the currency */ symbol: string; @@ -21,6 +22,7 @@ type Currency = { cacheBurst?: number; }; +/** Record of currencies, index by currency code */ type CurrencyList = Record; export default Currency; diff --git a/src/types/onyx/CustomStatusDraft.ts b/src/types/onyx/CustomStatusDraft.ts index 73c8fa4baa1a..d29061f5b5ed 100644 --- a/src/types/onyx/CustomStatusDraft.ts +++ b/src/types/onyx/CustomStatusDraft.ts @@ -1,3 +1,4 @@ +/** Model of custom status draft */ type CustomStatusDraft = { /** The emoji code of the draft status */ emojiCode?: string; diff --git a/src/types/onyx/DismissedReferralBanners.ts b/src/types/onyx/DismissedReferralBanners.ts index 86937d3bfbaf..92b3da647759 100644 --- a/src/types/onyx/DismissedReferralBanners.ts +++ b/src/types/onyx/DismissedReferralBanners.ts @@ -1,10 +1,20 @@ import type CONST from '@src/CONST'; +/** Model of dismissed referral banners */ type DismissedReferralBanners = { + /** Is 'Submit expense' referral dismissed */ [CONST.REFERRAL_PROGRAM.CONTENT_TYPES.SUBMIT_EXPENSE]?: boolean; + + /** Is 'Start chat' referral dismissed */ [CONST.REFERRAL_PROGRAM.CONTENT_TYPES.START_CHAT]?: boolean; + + /** Is 'Pay someone' referral dismissed */ [CONST.REFERRAL_PROGRAM.CONTENT_TYPES.PAY_SOMEONE]?: boolean; + + /** Is 'Refer friend' referral dismissed */ [CONST.REFERRAL_PROGRAM.CONTENT_TYPES.REFER_FRIEND]?: boolean; + + /** Is 'Share code' referral dismissed */ [CONST.REFERRAL_PROGRAM.CONTENT_TYPES.SHARE_CODE]?: boolean; }; diff --git a/src/types/onyx/Download.ts b/src/types/onyx/Download.ts index 9c6c2f61f716..de9e91064ed1 100644 --- a/src/types/onyx/Download.ts +++ b/src/types/onyx/Download.ts @@ -1,3 +1,4 @@ +/** Model of file download */ type Download = { /** If a file download is happening */ isDownloading: boolean; diff --git a/src/types/onyx/FrequentlyUsedEmoji.ts b/src/types/onyx/FrequentlyUsedEmoji.ts index c8f6a5179fc6..82de844c0c6f 100644 --- a/src/types/onyx/FrequentlyUsedEmoji.ts +++ b/src/types/onyx/FrequentlyUsedEmoji.ts @@ -1,3 +1,4 @@ +/** Model of frequently used emoji */ type FrequentlyUsedEmoji = { /** The emoji code */ code: string; diff --git a/src/types/onyx/Fund.ts b/src/types/onyx/Fund.ts index a3c0a95849d1..3a527a45db2c 100644 --- a/src/types/onyx/Fund.ts +++ b/src/types/onyx/Fund.ts @@ -2,40 +2,82 @@ import type CONST from '@src/CONST'; import type {BankName} from './Bank'; import type * as OnyxCommon from './OnyxCommon'; +/** Mode of additional debit card account data */ type AdditionalData = { + // TODO: Not used in app explicitly isBillingCard?: boolean; + + /** Is Peer-To-Peer debit card */ isP2PDebitCard?: boolean; }; +/** Model of debit card account data */ type AccountData = { + /** Additional account data */ additionalData?: AdditionalData; + + /** Address name */ addressName?: string; + + /** Address state */ addressState?: string; + + /** Address street */ addressStreet?: string; + + /** Address zip code */ addressZip?: number; + + /** Debit card month */ cardMonth?: number; - /** The masked credit card number */ + /** The masked debit card number */ cardNumber?: string; + /** Debit card year */ cardYear?: number; + + /** Debit card creation date */ created?: string; + + /** Debit card currency */ currency?: string; + + /** Debit card ID number */ fundID?: number; + + /** Debit card bank name */ bank?: BankName; }; +/** Model of debit card fund */ type Fund = OnyxCommon.OnyxValueWithOfflineFeedback<{ + /** All data related to the debit card */ accountData?: AccountData; + + /** Debit card type */ accountType?: typeof CONST.PAYMENT_METHODS.DEBIT_CARD; + + /** Debit card description */ description?: string; + + /** String like 'fund-{}' where is the fundID */ key?: string; + + /** Alias for fundID */ methodID?: number; + + /** Debit card title */ title?: string; + + /** Is default debit card */ isDefault?: boolean; + + /** Debit card related error messages */ errors?: OnyxCommon.Errors; }>; +/** Record of debit card funds, indexed by fundID */ type FundList = Record; export default Fund; diff --git a/src/types/onyx/IOU.ts b/src/types/onyx/IOU.ts index 726b94c5f6d3..29744dac5615 100644 --- a/src/types/onyx/IOU.ts +++ b/src/types/onyx/IOU.ts @@ -2,60 +2,151 @@ import type {ValueOf} from 'type-fest'; import type CONST from '@src/CONST'; import type {Icon} from './OnyxCommon'; +/** Model of IOU participant */ type Participant = { + /** IOU participant account ID */ accountID?: number; + + /** IOU participant login */ login?: string; + + /** IOU participant display name */ displayName?: string; + + /** Is IOU participant associated with policy expense chat */ isPolicyExpenseChat?: boolean; + + /** Is IOU participant associated with is own policy expense chat */ isOwnPolicyExpenseChat?: boolean; + + /** Type of chat associated with IOU participant */ chatType?: ValueOf; + + /** IOU participant report ID */ reportID?: string; + + /** IOU participant policy ID */ policyID?: string; + + /** Is IOU participant selected in list */ selected?: boolean; + + /** Text that IOU participant display name and login, if available, for searching purposes */ searchText?: string; + + /** Additional text shown in lists (participant phone number or display name) */ alternateText?: string; + + /** IOU participant first name */ firstName?: string; + + /** Icons used in lists (participant avatar) */ icons?: Icon[]; + + /** Key to be used in lists (participant account ID) */ keyForList?: string; + + /** IOU participant last name */ lastName?: string; + + /** IOU participant phone number */ phoneNumber?: string; + + /** Text to be displayed in lists (participant display name) */ text?: string; + + /** Is IOU participant selected in list */ isSelected?: boolean; + + /** Is IOU participant the current user */ isSelfDM?: boolean; isSender?: boolean; }; +/** Model of IOU split */ type Split = { + /** IOU split participant email */ email?: string; + + /** IOU split participant amount paid */ amount?: number; + + /** IOU split participant account ID */ accountID?: number; + + /** Chat report ID */ chatReportID?: string; + + /** IOU report ID */ iouReportID?: string; + + /** Report Action ID */ reportActionID?: string; + + /** Transaction ID */ transactionID?: string; + + /** Policy ID */ policyID?: string; + + /** Created chat report action ID */ createdChatReportActionID?: string; + + /** Created IOU report action ID */ createdIOUReportActionID?: string; + + /** Report preview report action ID */ reportPreviewReportActionID?: string; + + /** Transaction thread report ID */ transactionThreadReportID?: string; + + /** Created report action ID for thread */ createdReportActionIDForThread?: string; }; +/** Model of IOU request */ type IOU = { + /** IOU ID */ id: string; + + /** IOU amount */ amount?: number; + /** Selected Currency Code of the current IOU */ currency?: string; + + /** IOU comment */ comment?: string; + + /** IOU category */ category?: string; + + /** IOU merchant */ merchant?: string; + + /** IOU creation date */ created?: string; + + /** IOU receipt file path */ receiptPath?: string; + + /** IOU comment */ receiptFilename?: string; + + /** IOU transaction ID */ transactionID?: string; + + /** IOU participants */ participants?: Participant[]; + + /** IOU tag */ tag?: string; + + /** Is IOU billable */ billable?: boolean; + + /** Is an IOU split request */ isSplitRequest?: boolean; }; diff --git a/src/types/onyx/IntroSelected.ts b/src/types/onyx/IntroSelected.ts index 14a0d2f70dfe..6850f651ca2a 100644 --- a/src/types/onyx/IntroSelected.ts +++ b/src/types/onyx/IntroSelected.ts @@ -1,5 +1,6 @@ import type {OnboardingPurposeType} from '@src/CONST'; +/** Model of onboarding */ type IntroSelected = { /** The choice that the user selected in the engagement modal */ choice: OnboardingPurposeType; diff --git a/src/types/onyx/InvitedEmailsToAccountIDs.ts b/src/types/onyx/InvitedEmailsToAccountIDs.ts index 929d21746682..1f233e7c968c 100644 --- a/src/types/onyx/InvitedEmailsToAccountIDs.ts +++ b/src/types/onyx/InvitedEmailsToAccountIDs.ts @@ -1,3 +1,4 @@ +/** Record of workspace invited accountIDs, indexed by login name of inviter */ type InvitedEmailsToAccountIDs = Record; export default InvitedEmailsToAccountIDs; diff --git a/src/types/onyx/LastPaymentMethod.ts b/src/types/onyx/LastPaymentMethod.ts index 677a23fa9586..ea0c644fc730 100644 --- a/src/types/onyx/LastPaymentMethod.ts +++ b/src/types/onyx/LastPaymentMethod.ts @@ -1,3 +1,4 @@ +/** Record of last payment methods, indexed by policy id */ type LastPaymentMethod = Record; export default LastPaymentMethod; diff --git a/src/types/onyx/LastSelectedDistanceRates.ts b/src/types/onyx/LastSelectedDistanceRates.ts index 1db1cf32b160..3b09864db905 100644 --- a/src/types/onyx/LastSelectedDistanceRates.ts +++ b/src/types/onyx/LastSelectedDistanceRates.ts @@ -1,3 +1,4 @@ +/** Record of last selected distance rates, indexed by policy id */ type LastSelectedDistanceRates = Record; export default LastSelectedDistanceRates; diff --git a/src/types/onyx/Locale.ts b/src/types/onyx/Locale.ts index 89d7636009d7..37c340945bf1 100644 --- a/src/types/onyx/Locale.ts +++ b/src/types/onyx/Locale.ts @@ -1,6 +1,7 @@ import type {ValueOf} from 'type-fest'; import type CONST from '@src/CONST'; +/** Available locale values */ type Locale = ValueOf; export default Locale; diff --git a/src/types/onyx/Login.ts b/src/types/onyx/Login.ts index fec12da1b8e4..d89b7f2a29a3 100644 --- a/src/types/onyx/Login.ts +++ b/src/types/onyx/Login.ts @@ -1,5 +1,6 @@ import type * as OnyxCommon from './OnyxCommon'; +/** Model of user login data */ type Login = OnyxCommon.OnyxValueWithOfflineFeedback< { /** Phone/Email associated with user */ @@ -20,6 +21,7 @@ type Login = OnyxCommon.OnyxValueWithOfflineFeedback< 'defaultLogin' | 'validateLogin' | 'addedLogin' | 'deletedLogin' >; +/** Record of user login data, indexed by partnerUserID */ type LoginList = Record; export default Login; diff --git a/src/types/onyx/MapboxAccessToken.ts b/src/types/onyx/MapboxAccessToken.ts index bea23bcf86c4..9af8621d09b4 100644 --- a/src/types/onyx/MapboxAccessToken.ts +++ b/src/types/onyx/MapboxAccessToken.ts @@ -1,6 +1,12 @@ +/** Model of Mapbox access token data */ type MapboxAccessToken = { + /** Mapbox access token */ token: string; + + /** Mapbox access token expiration date */ expiration: string; + + /** Mapbox access error messages */ errors: string[]; }; diff --git a/src/types/onyx/Modal.ts b/src/types/onyx/Modal.ts index 1ea96cd283ce..b4b761cc8677 100644 --- a/src/types/onyx/Modal.ts +++ b/src/types/onyx/Modal.ts @@ -1,3 +1,4 @@ +/** Modal state */ type Modal = { /** Indicates when an Alert modal is about to be visible */ willAlertModalBecomeVisible?: boolean; @@ -8,6 +9,7 @@ type Modal = { /** Indicates if there is a modal currently visible or not */ isVisible?: boolean; + /** Indicates if the modal is a popover */ isPopover?: boolean; }; diff --git a/src/types/onyx/Network.ts b/src/types/onyx/Network.ts index cdfa7e02c8f6..680c6c468c00 100644 --- a/src/types/onyx/Network.ts +++ b/src/types/onyx/Network.ts @@ -1,5 +1,6 @@ import type {NetworkStatus} from '@libs/NetworkConnection'; +/** Model of network state */ type Network = { /** Is the network currently offline or not */ isOffline: boolean; diff --git a/src/types/onyx/NewGroupChatDraft.ts b/src/types/onyx/NewGroupChatDraft.ts index 008475212cbe..9e4ad3c54299 100644 --- a/src/types/onyx/NewGroupChatDraft.ts +++ b/src/types/onyx/NewGroupChatDraft.ts @@ -1,11 +1,21 @@ +/** Selected chat participant */ type SelectedParticipant = { + /** Participant ID */ accountID: number; + + /** Participant login name */ login: string; }; +/** Model of new group chat draft */ type NewGroupChatDraft = { + /** New group chat participants */ participants: SelectedParticipant[]; + + /** New group chat name */ reportName: string | null; + + /** New group chat avatar URI */ avatarUri: string | null; }; export type {SelectedParticipant}; diff --git a/src/types/onyx/Onboarding.ts b/src/types/onyx/Onboarding.ts index 3559dea90450..9860dd93f9ce 100644 --- a/src/types/onyx/Onboarding.ts +++ b/src/types/onyx/Onboarding.ts @@ -1,3 +1,4 @@ +/** Model of onboarding */ type Onboarding = { /** A Boolean that informs whether the user has completed the guided setup onboarding flow */ hasCompletedGuidedSetupFlow: boolean; diff --git a/src/types/onyx/OnyxCommon.ts b/src/types/onyx/OnyxCommon.ts index c4a3afc3e0b9..186801df6e30 100644 --- a/src/types/onyx/OnyxCommon.ts +++ b/src/types/onyx/OnyxCommon.ts @@ -3,10 +3,13 @@ import type {MaybePhraseKey} from '@libs/Localize'; import type {AvatarSource} from '@libs/UserUtils'; import type CONST from '@src/CONST'; +/** Pending onyx actions */ type PendingAction = ValueOf | null; +/** Mapping of form fields with pending actions */ type PendingFields = {[key in Exclude]?: PendingAction}; +/** Offline properties that store information about data that was written while the app was offline */ type OfflineFeedback = { /** The type of action that's pending */ pendingAction?: PendingAction; @@ -15,14 +18,23 @@ type OfflineFeedback = { pendingFields?: PendingFields; }; +/** Onyx data with offline properties that store information about data that was written while the app was offline */ type OnyxValueWithOfflineFeedback = keyof TOnyx extends string ? TOnyx & OfflineFeedback : never; +/** Mapping of form fields with errors */ type ErrorFields = Record; +/** Mapping of form fields with error translation keys and variables */ type Errors = Record; +/** + * Types of avatars + ** avatar - user avatar + ** workspace - workspace avatar + */ type AvatarType = typeof CONST.ICON_TYPE_AVATAR | typeof CONST.ICON_TYPE_WORKSPACE; +/** Icon properties */ type Icon = { /** Avatar source to display */ source?: AvatarSource; diff --git a/src/types/onyx/OnyxUpdatesFromServer.ts b/src/types/onyx/OnyxUpdatesFromServer.ts index 0877ea6755f8..525fb34e59cd 100644 --- a/src/types/onyx/OnyxUpdatesFromServer.ts +++ b/src/types/onyx/OnyxUpdatesFromServer.ts @@ -3,22 +3,42 @@ import CONST from '@src/CONST'; import type Request from './Request'; import type Response from './Response'; +/** Model of a onyx server update */ type OnyxServerUpdate = OnyxUpdate & { + /** Whether the update should notify UI */ shouldNotify?: boolean; + + /** Whether the update should be shown as a push notification */ shouldShowPushNotification?: boolean; }; +/** Model of a onyx update event */ type OnyxUpdateEvent = { + /** Type of the update event received from the server */ eventType: string; + + /** Collections of data updates */ data: OnyxServerUpdate[]; }; +/** Model of onyx server updates */ type OnyxUpdatesFromServer = { + /** Delivery method of onyx updates */ type: 'https' | 'pusher' | 'airship'; + + /** Last update ID from server */ lastUpdateID: number | string; + + /** Previous update ID from server */ previousUpdateID: number | string; + + /** Request data sent to the server */ request?: Request; + + /** Response data from server */ response?: Response; + + /** Collection of onyx updates */ updates?: OnyxUpdateEvent[]; }; diff --git a/src/types/onyx/PaymentMethod.ts b/src/types/onyx/PaymentMethod.ts index 4b3a4c8986fb..b95f890939eb 100644 --- a/src/types/onyx/PaymentMethod.ts +++ b/src/types/onyx/PaymentMethod.ts @@ -3,12 +3,24 @@ import type IconAsset from '@src/types/utils/IconAsset'; import type BankAccount from './BankAccount'; import type Fund from './Fund'; +/** Model of a payment method */ type PaymentMethod = (BankAccount | Fund) & { + /** Text shown under menu item title */ description: string; + + /** Source of the menu item icon, which can be a component or an image asset */ icon: IconAsset; + + /** Size of the menu item icon */ iconSize?: number; + + /** Height of the menu item icon */ iconHeight?: number; + + /** Width of the menu item icon */ iconWidth?: number; + + /** Icon wrapper styles */ iconStyles?: ViewStyle[]; }; diff --git a/src/types/onyx/PersonalBankAccount.ts b/src/types/onyx/PersonalBankAccount.ts index 3e52a3cf59f3..b36e7754ca23 100644 --- a/src/types/onyx/PersonalBankAccount.ts +++ b/src/types/onyx/PersonalBankAccount.ts @@ -1,6 +1,7 @@ import type {Route} from '@src/ROUTES'; import type * as OnyxCommon from './OnyxCommon'; +/** Model of personal bank account */ type PersonalBankAccount = { /** An error message to display to the user */ errors?: OnyxCommon.Errors; diff --git a/src/types/onyx/PersonalDetails.ts b/src/types/onyx/PersonalDetails.ts index b7c96998080c..939835028392 100644 --- a/src/types/onyx/PersonalDetails.ts +++ b/src/types/onyx/PersonalDetails.ts @@ -2,8 +2,10 @@ import type {AvatarSource} from '@libs/UserUtils'; import type TIMEZONES from '@src/TIMEZONES'; import type * as OnyxCommon from './OnyxCommon'; +/** Selectable timezones */ type SelectedTimezone = (typeof TIMEZONES)[number]; +/** Model of timezone */ type Timezone = { /** Value of selected timezone */ selected?: SelectedTimezone; @@ -12,6 +14,7 @@ type Timezone = { automatic?: boolean; }; +/** Model of user status */ type Status = { /** The emoji code of the status */ emojiCode: string; @@ -23,6 +26,7 @@ type Status = { clearAfter: string; // ISO 8601 format; }; +/** Model of user personal details */ type PersonalDetails = OnyxCommon.OnyxValueWithOfflineFeedback<{ /** ID of the current user from their personal details */ accountID: number; @@ -48,6 +52,7 @@ type PersonalDetails = OnyxCommon.OnyxValueWithOfflineFeedback<{ /** Avatar thumbnail URL of the current user from their personal details */ avatarThumbnail?: string; + /** Avatar original file name with extension */ originalFileName?: string; /** Flag to set when Avatar uploading */ @@ -78,11 +83,13 @@ type PersonalDetails = OnyxCommon.OnyxValueWithOfflineFeedback<{ status?: Status; }>; +/** Model of personal details metadata */ type PersonalDetailsMetadata = { /** Whether we are waiting for the data to load via the API */ isLoading?: boolean; }; +/** Record of user personal details, indexed by user id */ type PersonalDetailsList = Record; export default PersonalDetails; diff --git a/src/types/onyx/PlaidBankAccount.ts b/src/types/onyx/PlaidBankAccount.ts index 7620c4aee367..6e59fc015ca4 100644 --- a/src/types/onyx/PlaidBankAccount.ts +++ b/src/types/onyx/PlaidBankAccount.ts @@ -1,3 +1,4 @@ +/** Model of plaid bank account data */ type PlaidBankAccount = { /** Masked account number */ accountNumber: string; diff --git a/src/types/onyx/PlaidData.ts b/src/types/onyx/PlaidData.ts index 8ec93119cbd8..8f8e16324176 100644 --- a/src/types/onyx/PlaidData.ts +++ b/src/types/onyx/PlaidData.ts @@ -1,6 +1,7 @@ import type * as OnyxCommon from './OnyxCommon'; import type PlaidBankAccount from './PlaidBankAccount'; +/** Model of plaid data */ type PlaidData = { /** Name of the bank */ bankName?: string; @@ -14,7 +15,10 @@ type PlaidData = { /** List of plaid bank accounts */ bankAccounts?: PlaidBankAccount[]; + /** Whether the data is being fetched from server */ isLoading?: boolean; + + /** Error messages to show in UI */ errors: OnyxCommon.Errors; }; diff --git a/src/types/onyx/Policy.ts b/src/types/onyx/Policy.ts index 3a322405c6e1..c0f74747d5b0 100644 --- a/src/types/onyx/Policy.ts +++ b/src/types/onyx/Policy.ts @@ -5,48 +5,96 @@ import type * as OnyxTypes from '.'; import type * as OnyxCommon from './OnyxCommon'; import type {WorkspaceTravelSettings} from './TravelSettings'; +/** Distance units */ type Unit = 'mi' | 'km'; +/** Model of policy distance rate */ type Rate = OnyxCommon.OnyxValueWithOfflineFeedback<{ + /** Name of the distance rate */ name?: string; + + /** Amount to be reimbursed per distance unit travelled */ rate?: number; + + /** Currency used to pay the distance rate */ currency?: string; + + /** Generated ID to identify the distance rate */ customUnitRateID?: string; + + /** Whether this distance rate is currently enabled */ enabled?: boolean; + + /** Error messages to show in UI */ errors?: OnyxCommon.Errors; + + /** Form fields that triggered the errors */ errorFields?: OnyxCommon.ErrorFields; }>; +/** Custom unit attributes */ type Attributes = { + /** Distance unit name */ unit: Unit; }; +/** Policy custom unit */ type CustomUnit = OnyxCommon.OnyxValueWithOfflineFeedback<{ + /** Custom unit name */ name: string; + + /** ID that identifies this custom unit */ customUnitID: string; + + /** Contains custom attributes like unit, for this custom unit */ attributes: Attributes; + + /** Distance rates using this custom unit */ rates: Record; + + /** The default category in which this custom unit is used */ defaultCategory?: string; + + /** Whether this custom unit is enabled */ enabled?: boolean; + + /** Error messages to show in UI */ errors?: OnyxCommon.Errors; + + /** Form fields that triggered errors */ errorFields?: OnyxCommon.ErrorFields; }>; +/** Policy company address data */ type CompanyAddress = { + /** Street address */ addressStreet: string; + + /** City */ city: string; + + /** State */ state: string; + + /** Zip post code */ zipCode: string; + + /** Country code */ country: Country | ''; }; +/** Policy disabled fields */ type DisabledFields = { + /** Whether the default billable field is disabled */ defaultBillable?: boolean; + + /** Whether the reimbursable field is disabled */ reimbursable?: boolean; }; +/** Policy tax rate */ type TaxRate = OnyxCommon.OnyxValueWithOfflineFeedback<{ - /** Name of the a tax rate. */ + /** Name of the tax rate. */ name: string; /** The value of the tax rate. */ @@ -68,8 +116,10 @@ type TaxRate = OnyxCommon.OnyxValueWithOfflineFeedback<{ errorFields?: OnyxCommon.ErrorFields; }>; +/** Record of policy tax rates, indexed by id_{taxRateName} where taxRateName is the name of the tax rate in UPPER_SNAKE_CASE */ type TaxRates = Record; +/** Policy tax rates with default tax rate */ type TaxRatesWithDefault = OnyxCommon.OnyxValueWithOfflineFeedback<{ /** Name of the tax */ name: string; @@ -93,40 +143,85 @@ type TaxRatesWithDefault = OnyxCommon.OnyxValueWithOfflineFeedback<{ errorFields?: OnyxCommon.ErrorFields; }>; +/** Connection last synchronization state */ type ConnectionLastSync = { + /** Date when the connection's last successful sync occurred */ successfulDate?: string; + + /** Date when the connection's last failed sync occurred */ errorDate?: string; + + /** Whether the connection's last sync was successful */ isSuccessful: boolean; + + /** Where did the connection's last sync came from */ source: 'DIRECT' | 'EXPENSIFYWEB' | 'EXPENSIFYAPI' | 'AUTOSYNC' | 'AUTOAPPROVE'; }; +/** Financial account (bank account, debit card, etc) */ type Account = { + /** GL code assigned to the financial account */ glCode?: string; + + /** Name of the financial account */ name: string; + + /** Currency of the financial account */ currency: string; + + /** ID assigned to the financial account */ id: string; }; +/** Model of QuickBooks Online employee data */ type Employee = { + /** ID assigned to the employee */ id: string; + + /** Employee's first name */ firstName?: string; + + /** Employee's last name */ lastName?: string; + + /** Employee's display name */ name: string; + + /** Employee's e-mail */ email: string; }; +/** Model of QuickBooks Online vendor data */ type Vendor = { + /** ID assigned to the vendor */ id: string; + + /** Vendor's name */ name: string; + + /** Vendor's currency */ currency: string; + + /** Vendor's e-mail */ email: string; }; +/** Model of QuickBooks Online tax code data */ type TaxCode = { + /** TODO: Not used in app */ totalTaxRateVal: string; + + /** TODO: Not used in app */ simpleName: string; + + /** TODO: Not used in app */ taxCodeRef: string; + + /** TODO: Not used in app */ taxRateRefs: Record; + + /** TODO: Not used in app */ + /** Name of the tax code */ name: string; }; @@ -134,86 +229,190 @@ type TaxCode = { * Data imported from QuickBooks Online. */ type QBOConnectionData = { + /** TODO: I think this value can be changed to `ValueOf` */ + /** Country code */ country: string; + + /** TODO: Doesn't exist in the app */ edition: string; + + /** TODO: Doesn't exist in the app */ homeCurrency: string; + + /** TODO: Doesn't exist in the app */ isMultiCurrencyEnabled: boolean; + /** Collection of journal entry accounts */ journalEntryAccounts: Account[]; + + /** Collection of bank accounts */ bankAccounts: Account[]; + + /** Collection of credit cards */ creditCards: Account[]; + + /** Collection of export destination accounts */ accountsReceivable: Account[]; + + /** TODO: Not enough context */ accountPayable: Account[]; + + /** TODO: Not enough context */ otherCurrentAssetAccounts: Account[]; + /** TODO: Doesn't exist in the app */ taxCodes: TaxCode[]; + + /** TODO: Doesn't exist in the app */ employees: Employee[]; + + /** Collections of vendors */ vendors: Vendor[]; }; +/** Sync entity names */ type IntegrationEntityMap = (typeof CONST.INTEGRATION_ENTITY_MAP_TYPES)[keyof typeof CONST.INTEGRATION_ENTITY_MAP_TYPES]; +/** Non reimbursable account types exported from QuickBooks Online */ type QBONonReimbursableExportAccountType = (typeof CONST.QUICKBOOKS_NON_REIMBURSABLE_EXPORT_ACCOUNT_TYPE)[keyof typeof CONST.QUICKBOOKS_NON_REIMBURSABLE_EXPORT_ACCOUNT_TYPE]; + +/** Reimbursable account types exported from QuickBooks Online */ type QBOReimbursableExportAccountType = (typeof CONST.QUICKBOOKS_REIMBURSABLE_ACCOUNT_TYPE)[keyof typeof CONST.QUICKBOOKS_REIMBURSABLE_ACCOUNT_TYPE]; /** * User configuration for the QuickBooks Online accounting integration. */ type QBOConnectionConfig = OnyxCommon.OnyxValueWithOfflineFeedback<{ + /** TODO: Doesn't exist in the app */ + /** ID of the QuickBooks Online realm */ realmId: string; + + /** TODO: Doesn't exist in the app */ + /** Company name */ companyName: string; + + /** Configuration of automatic synchronization from QuickBooks Online to the app */ autoSync: { + /** TODO: Doesn't exist in the app */ jobID: string; + + /** Whether changes made in QuickBooks Online should be reflected into the app automatically */ enabled: boolean; }; + + /** Whether employees can be invited */ syncPeople: boolean; + + /** TODO: Doesn't exist in the app */ syncItems: boolean; + + /** TODO: Doesn't exist in the app */ markChecksToBePrinted: boolean; + reimbursableExpensesExportDestination: QBOReimbursableExportAccountType; + nonReimbursableExpensesExportDestination: QBONonReimbursableExportAccountType; + nonReimbursableBillDefaultVendor: string; + collectionAccountID?: string; + reimbursementAccountID?: string; + reimbursableExpensesAccount?: Account; + nonReimbursableExpensesAccount?: Account; + + /** Account that receives the exported invoices */ receivableAccount?: Account; + + /** + * Whether a default vendor will be created and applied to all credit card + * transactions upon import + */ autoCreateVendor: boolean; + + /** TODO: Doesn't exist in the app */ hasChosenAutoSyncOption: boolean; + + /** Whether Quickbooks Online classes should be imported */ syncClasses: IntegrationEntityMap; + + /** Whether Quickbooks Online customers should be imported */ syncCustomers: IntegrationEntityMap; + + /** Whether Quickbooks Online locations should be imported */ syncLocations: IntegrationEntityMap; + + /** TODO: Doesn't exist in the app */ lastConfigurationTime: number; + + /** Whether the taxes should be synchronized */ syncTax: boolean; + + /** Whether new categories are enabled in chart of accounts */ enableNewCategories: boolean; + + /** TODO: Doesn't exist in the app */ errors?: OnyxCommon.Errors; + + /** TODO: Doesn't exist in the app */ exportDate: ValueOf; + + /** Configuration of the export */ export: { + /** E-mail of the exporter */ exporter: string; }; + + /** Collections of form field errors */ errorFields?: OnyxCommon.ErrorFields; }>; +/** Xero bill status values */ type BillStatusValues = 'DRAFT' | 'AWT_APPROVAL' | 'AWT_PAYMENT'; +/** Xero expense status values */ type ExpenseTypesValues = 'BILL' | 'BANK_TRANSACTION' | 'SALES_INVOICE' | 'NOTHING'; +/** Xero bill date values */ type BillDateValues = 'REPORT_SUBMITTED' | 'REPORT_EXPORTED' | 'LAST_EXPENSE'; +/** Model of an organization in Xero */ type Tenant = { + /** ID of the organization */ id: string; + + /** Name of the organization */ name: string; + + /** TODO: Doesn't exist in the app */ value: string; }; +/** + * Data imported from Xero + */ type XeroConnectionData = { + /** Collection of bank accounts */ bankAccounts: Account[]; + + /** TODO: Doesn't exist in the app */ countryCode: string; + + /** TODO: Doesn't exist in the app */ organisationID: string; + + /** TODO: Doesn't exist in the app */ revenueAccounts: Array<{ id: string; name: string; }>; + + /** Collection of organizations */ tenants: Tenant[]; + + /** TODO: Doesn't exist in the app */ trackingCategories: unknown[]; }; @@ -221,68 +420,143 @@ type XeroConnectionData = { * User configuration for the Xero accounting integration. */ type XeroConnectionConfig = OnyxCommon.OnyxValueWithOfflineFeedback<{ + /** Xero auto synchronization configs */ autoSync: { + /** Whether data should be automatically synched between the app and Xero */ enabled: boolean; + + /** TODO: Doesn't exist in the app */ jobID: string; }; + + /** TODO: Doesn't exist in the app */ enableNewCategories: boolean; + + /** Xero export configs */ export: { + /** Current bill status */ billDate: BillDateValues; + billStatus: { + /** Current status of the purchase bill */ purchase: BillStatusValues; + + /** Current status of the sales bill */ sales: BillStatusValues; }; + + /** TODO: Doesn't exist in the app */ billable: ExpenseTypesValues; + + /** The e-mail of the exporter */ exporter: string; + + /** TODO: Doesn't exist in the app */ nonReimbursable: ExpenseTypesValues; + + /** TODO: Doesn't exist in the app */ nonReimbursableAccount: string; + + /** TODO: Doesn't exist in the app */ reimbursable: ExpenseTypesValues; }; + + /** Whether customers should be imported from Xero */ importCustomers: boolean; + + /** Whether tax rates should be imported from Xero */ importTaxRates: boolean; + + /** Whether tracking categories should be imported from Xero */ importTrackingCategories: boolean; + + /** TODO: Doesn't exist in the app */ isConfigured: boolean; + + /** TODO: Doesn't exist in the app */ mappings: { customer: string; }; sync: { + /** TODO: Doesn't exist in the app */ hasChosenAutoSyncOption: boolean; + + /** TODO: Doesn't exist in the app */ hasChosenSyncReimbursedReportsOption: boolean; + + /** ID of the bank account for Xero invoice collections */ invoiceCollectionsAccountID: string; + + /** TODO: Doesn't exist in the app */ reimbursementAccountID: string; + + /** TODO: Doesn't exist in the app */ syncReimbursedReports: boolean; }; + + /** ID of Xero organization */ tenantID: string; + + /** TODO: Doesn't exist in the app */ errors?: OnyxCommon.Errors; + + /** Collection of form field errors */ errorFields?: OnyxCommon.ErrorFields; }>; +/** State of integration connection */ type Connection = { + /** TODO: Doesn't exist in the app */ + /** State of the last synchronization */ lastSync?: ConnectionLastSync; + + /** Data imported from integration */ data: ConnectionData; + + /** Configuration of the connection */ config: ConnectionConfig; }; +/** Available integration connections */ type Connections = { + /** QuickBooks integration connection */ quickbooksOnline: Connection; + + /** Xero integration connection */ xero: Connection; }; +/** Names of integration connections */ type ConnectionName = keyof Connections; +/** Model of verified reimbursement bank account linked to policy */ type ACHAccount = { + /** ID of the bank account */ bankAccountID: number; + + /** Bank account number */ accountNumber: string; + + /** Routing number of bank account */ routingNumber: string; + + /** Address name of the bank account */ addressName: string; + + /** Name of the bank */ bankName: string; + + /** E-mail of the reimburser */ reimburser: string; }; +/** Day of the month to schedule submission */ type AutoReportingOffset = number | ValueOf; +/** Types of policy report fields */ type PolicyReportFieldType = 'text' | 'date' | 'dropdown' | 'formula'; +/** Model of policy report field */ type PolicyReportField = { /** Name of the field */ name: string; @@ -308,6 +582,7 @@ type PolicyReportField = { /** Options to select from if field is of type dropdown */ values: string[]; + /** TODO: Doesn't seem to be used in app */ target: string; /** Tax UDFs have keys holding the names of taxes (eg, VAT), values holding percentages (eg, 15%) and a value indicating the currently selected tax value (eg, 15%). */ @@ -316,6 +591,7 @@ type PolicyReportField = { /** list of externalIDs, this are either imported from the integrations or auto generated by us, each externalID */ externalIDs: string[]; + /** Collection of flags that state whether droplist field options are disabled */ disabledOptions: boolean[]; /** Is this a tax user defined report field */ @@ -331,22 +607,37 @@ type PolicyReportField = { defaultExternalID?: string | null; }; +/** Names of policy features */ type PolicyFeatureName = ValueOf; +/** Current user policy join request state */ type PendingJoinRequestPolicy = { + /** Whether the current user requested to join the policy */ isJoinRequestPending: boolean; + + /** Record of public policy details, indexed by policy ID */ policyDetailsForNonMembers: Record< string, OnyxCommon.OnyxValueWithOfflineFeedback<{ + /** Name of the policy */ name: string; + + /** Policy owner account ID */ ownerAccountID: number; + + /** Policy owner e-mail */ ownerEmail: string; + + /** Policy type */ type: ValueOf; + + /** Policy avatar */ avatar?: string; }> >; }; +/** Model of policy data */ type Policy = OnyxCommon.OnyxValueWithOfflineFeedback< { /** The ID of the policy */ @@ -528,10 +819,18 @@ type Policy = OnyxCommon.OnyxValueWithOfflineFeedback< 'generalSettings' | 'addWorkspaceRoom' | keyof ACHAccount >; +/** Stages of policy connection sync */ type PolicyConnectionSyncStage = ValueOf; + +/** Names of policy connection services */ type PolicyConnectionName = ValueOf; + +/** Policy connection sync progress state */ type PolicyConnectionSyncProgress = { + /** Current sync stage */ stageInProgress: PolicyConnectionSyncStage; + + /** Name of the connected service */ connectionName: PolicyConnectionName; }; diff --git a/src/types/onyx/PolicyCategory.ts b/src/types/onyx/PolicyCategory.ts index b42bceec0468..c0e80de364d3 100644 --- a/src/types/onyx/PolicyCategory.ts +++ b/src/types/onyx/PolicyCategory.ts @@ -1,5 +1,6 @@ import type * as OnyxCommon from './OnyxCommon'; +/** Model of policy category */ type PolicyCategory = OnyxCommon.OnyxValueWithOfflineFeedback<{ /** Name of a category */ name: string; @@ -27,6 +28,7 @@ type PolicyCategory = OnyxCommon.OnyxValueWithOfflineFeedback<{ errors?: OnyxCommon.Errors | null; }>; +/** Record of policy categories, indexed by their name */ type PolicyCategories = Record; export type {PolicyCategory, PolicyCategories}; diff --git a/src/types/onyx/PolicyEmployee.ts b/src/types/onyx/PolicyEmployee.ts index 4a5f374de44a..741e1e01ec05 100644 --- a/src/types/onyx/PolicyEmployee.ts +++ b/src/types/onyx/PolicyEmployee.ts @@ -1,5 +1,6 @@ import type * as OnyxCommon from './OnyxCommon'; +/** Model of policy employee */ type PolicyEmployee = OnyxCommon.OnyxValueWithOfflineFeedback<{ /** Role of the user in the policy */ role?: string; @@ -20,6 +21,7 @@ type PolicyEmployee = OnyxCommon.OnyxValueWithOfflineFeedback<{ errors?: OnyxCommon.Errors; }>; +/** Record of policy employees, indexed by their email */ type PolicyEmployeeList = Record; export default PolicyEmployee; diff --git a/src/types/onyx/PolicyJoinMember.ts b/src/types/onyx/PolicyJoinMember.ts index 7c540b334b4a..bb7b346e6ded 100644 --- a/src/types/onyx/PolicyJoinMember.ts +++ b/src/types/onyx/PolicyJoinMember.ts @@ -1,5 +1,6 @@ import type * as OnyxCommon from './OnyxCommon'; +/** Model of policy join member */ type PolicyJoinMember = { /** The ID of the policy */ policyID?: string; diff --git a/src/types/onyx/PolicyOwnershipChangeChecks.ts b/src/types/onyx/PolicyOwnershipChangeChecks.ts index 8033cffdee3c..9950122b069a 100644 --- a/src/types/onyx/PolicyOwnershipChangeChecks.ts +++ b/src/types/onyx/PolicyOwnershipChangeChecks.ts @@ -1,7 +1,15 @@ +/** Model of policy ownership change checks */ type PolicyOwnershipChangeChecks = { + /** Whether the outstanding balance should be cleared after changing workspace owner */ shouldClearOutstandingBalance?: boolean; + + /** Whether the amount owed should be transferred after changing workspace owner */ shouldTransferAmountOwed?: boolean; + + /** Whether the subscription should be transferred after changing workspace owner */ shouldTransferSubscription?: boolean; + + /** Whether the single subscription should be transferred after changing workspace owner */ shouldTransferSingleSubscription?: boolean; }; diff --git a/src/types/onyx/PolicyTag.ts b/src/types/onyx/PolicyTag.ts index 37e979fb58f6..a9d5377e1432 100644 --- a/src/types/onyx/PolicyTag.ts +++ b/src/types/onyx/PolicyTag.ts @@ -1,5 +1,6 @@ import type * as OnyxCommon from './OnyxCommon'; +/** Model of policy tag */ type PolicyTag = OnyxCommon.OnyxValueWithOfflineFeedback<{ /** Name of a Tag */ name: string; @@ -15,8 +16,10 @@ type PolicyTag = OnyxCommon.OnyxValueWithOfflineFeedback<{ errors?: OnyxCommon.Errors | null; }>; +/** Record of policy tags, indexed by their name */ type PolicyTags = Record; +/** Record of policy tag lists, index by the name of the tag list */ type PolicyTagList = Record< T, OnyxCommon.OnyxValueWithOfflineFeedback<{ diff --git a/src/types/onyx/PreferredTheme.ts b/src/types/onyx/PreferredTheme.ts index 408748ad06ea..98c001df018c 100644 --- a/src/types/onyx/PreferredTheme.ts +++ b/src/types/onyx/PreferredTheme.ts @@ -2,6 +2,7 @@ import type {OnyxEntry} from 'react-native-onyx'; import type {ValueOf} from 'type-fest'; import type CONST from '@src/CONST'; +/** Possible user preferred themes to be used in the whole app */ type PreferredTheme = OnyxEntry>; export default PreferredTheme; diff --git a/src/types/onyx/PriorityMode.ts b/src/types/onyx/PriorityMode.ts index 224c86867f35..404c678945ad 100644 --- a/src/types/onyx/PriorityMode.ts +++ b/src/types/onyx/PriorityMode.ts @@ -2,6 +2,7 @@ import type {OnyxEntry} from 'react-native-onyx'; import type {ValueOf} from 'type-fest'; import type CONST from '@src/CONST'; +/** Modes that define how the user's chats are displayed in his chat list */ type PriorityMode = OnyxEntry>; export default PriorityMode; diff --git a/src/types/onyx/PrivatePersonalDetails.ts b/src/types/onyx/PrivatePersonalDetails.ts index 3099cb0095e9..1f81108bf538 100644 --- a/src/types/onyx/PrivatePersonalDetails.ts +++ b/src/types/onyx/PrivatePersonalDetails.ts @@ -1,25 +1,59 @@ import type {Country} from '@src/CONST'; +/** User address data */ type Address = { + /** Street line 1 */ street: string; + + /** Street line 2 */ street2?: string; + + /** City */ city?: string; + + /** State */ state?: string; + + /** Zip post code */ zip?: string; + + /** Country code */ country?: Country | ''; + + /** Zip post code */ zipPostCode?: string; + + /** Street line 1 */ addressLine1?: string; + + /** Street line 2 */ addressLine2?: string; + + /** Latitude */ lat?: string; + + /** Longitude */ lng?: string; + + /** Zip post code */ zipCode?: string; + + /** Google place description */ address?: string; }; +/** Model of user private personal details */ type PrivatePersonalDetails = { + /** User's legal first name */ legalFirstName?: string; + + /** User's legal last name */ legalLastName?: string; + + /** User's date of birth */ dob?: string; + + /** User's phone number */ phoneNumber?: string; /** User's home address */ diff --git a/src/types/onyx/QuickAction.ts b/src/types/onyx/QuickAction.ts index 325893637911..c10ec8356546 100644 --- a/src/types/onyx/QuickAction.ts +++ b/src/types/onyx/QuickAction.ts @@ -1,8 +1,10 @@ import type {ValueOf} from 'type-fest'; import type CONST from '@src/CONST'; +/** Names of quick actions that the user can execute */ type QuickActionName = ValueOf; +/** Model of user quick action */ type QuickAction = { /** The action to take */ action?: QuickActionName; diff --git a/src/types/onyx/RecentWaypoint.ts b/src/types/onyx/RecentWaypoint.ts index 55232f7ef71d..8653366898cb 100644 --- a/src/types/onyx/RecentWaypoint.ts +++ b/src/types/onyx/RecentWaypoint.ts @@ -1,3 +1,4 @@ +/** Model of recent endpoint used in distance expense */ type RecentWaypoint = { /** The name associated with the address of the waypoint */ name?: string; diff --git a/src/types/onyx/RecentlyUsedCategories.ts b/src/types/onyx/RecentlyUsedCategories.ts index d251b16f8667..c3d7c187c710 100644 --- a/src/types/onyx/RecentlyUsedCategories.ts +++ b/src/types/onyx/RecentlyUsedCategories.ts @@ -1,3 +1,4 @@ +/** Workspace categories that have been recently used by members */ type RecentlyUsedCategories = string[]; export default RecentlyUsedCategories; diff --git a/src/types/onyx/RecentlyUsedReportFields.ts b/src/types/onyx/RecentlyUsedReportFields.ts index 2b3d046c8316..95af207eaa31 100644 --- a/src/types/onyx/RecentlyUsedReportFields.ts +++ b/src/types/onyx/RecentlyUsedReportFields.ts @@ -1,3 +1,4 @@ +/** Record of policy recently used report fields, indexed by expensify_${reportFieldId} */ type RecentlyUsedReportFields = Record; export default RecentlyUsedReportFields; diff --git a/src/types/onyx/RecentlyUsedTags.ts b/src/types/onyx/RecentlyUsedTags.ts index 1d6112514609..650a0554ef37 100644 --- a/src/types/onyx/RecentlyUsedTags.ts +++ b/src/types/onyx/RecentlyUsedTags.ts @@ -1,3 +1,4 @@ +/** Record of policy recently used tags, indexed by nvp_recentlyUsedTags_{policyID} */ type RecentlyUsedTags = Record; export default RecentlyUsedTags; diff --git a/src/types/onyx/ReimbursementAccount.ts b/src/types/onyx/ReimbursementAccount.ts index f2565b29eaf3..2322f6faab17 100644 --- a/src/types/onyx/ReimbursementAccount.ts +++ b/src/types/onyx/ReimbursementAccount.ts @@ -4,10 +4,13 @@ import type {ACHContractStepProps, BeneficialOwnersStepProps, CompanyStepProps, import type {BankName} from './Bank'; import type * as OnyxCommon from './OnyxCommon'; +/** Steps to setup a reimbursement bank account */ type BankAccountStep = ValueOf; +/** Substeps to setup a reimbursement bank account */ type BankAccountSubStep = ValueOf; +/** Model of ACH data */ type ACHData = Partial & { /** Step of the setup flow that we are on. Determines which view is presented. */ currentStep?: BankAccountStep; @@ -46,6 +49,7 @@ type ACHData = Partial; +/** Defines who's able to write messages in the chat */ type WriteCapability = ValueOf; +/** Defines which users have access to the chat */ type RoomVisibility = ValueOf; +/** Model of report private note */ type Note = OnyxCommon.OnyxValueWithOfflineFeedback<{ + /** Content of the note */ note: string; + + /** Collection of errors to show to the user */ errors?: OnyxCommon.Errors; }>; /** The pending member of report */ type PendingChatMember = { + /** Account ID of the pending member */ accountID: string; + + /** Action to be applied to the pending member of report */ pendingAction: OnyxCommon.PendingAction; }; +/** Report participant properties */ type Participant = OnyxCommon.OnyxValueWithOfflineFeedback<{ + /** Whether the participant is visible in the report */ hidden?: boolean; + + /** What is the role of the participant in the report */ role?: 'admin' | 'member'; }>; +/** Types of invoice receivers in a report */ type InvoiceReceiver = | { + /** An individual */ type: typeof CONST.REPORT.INVOICE_RECEIVER_TYPE.INDIVIDUAL; + + /** Account ID of the user */ accountID: number; } | { + /** A business */ type: typeof CONST.REPORT.INVOICE_RECEIVER_TYPE.BUSINESS; + + /** ID of the policy */ policyID: string; }; +/** Record of report participants, indexed by their accountID */ type Participants = Record; +/** Model of report data */ type Report = OnyxCommon.OnyxValueWithOfflineFeedback< { /** The URL of the Group Chat report custom avatar */ @@ -141,29 +164,70 @@ type Report = OnyxCommon.OnyxValueWithOfflineFeedback< /** Invoice room receiver data */ invoiceReceiver?: InvoiceReceiver; + /** Translation key of the last message in the report */ lastMessageTranslationKey?: string; + + /** ID of the parent report of the current report, if it exists */ parentReportID?: string; + + /** ID of the parent report action of the current report, if it exists */ parentReportActionID?: string; + + /** Whether the current report is optimistic */ isOptimisticReport?: boolean; + + /** Account ID of the report manager */ managerID?: number; + + /** When was the last visible action last modified */ lastVisibleActionLastModified?: string; + + /** Display name of the report, shown in options and mentions */ displayName?: string; + + /** HTML content of the last message in the report */ lastMessageHtml?: string; + + /** Account ID of the user that sent the last message */ lastActorAccountID?: number; - // The type of the last action + /** The type of the last action */ lastActionType?: ValueOf; + + /** Account ID of the report owner */ ownerAccountID?: number; + + /** E-mail of the report owner */ ownerEmail?: string; + + /** Collection of report participants, indexed by their accountID */ participants?: Participants; + + /** Collection of report participants account IDs */ participantAccountIDs?: number[]; + + /** Collection of visible chat members account IDs */ visibleChatMemberAccountIDs?: number[]; + + /** For expense reports, this is the total amount approved */ total?: number; + + /** For expense reports, this is the total amount requested */ unheldTotal?: number; + + /** For expense reports, this is the currency of the expense */ currency?: string; + + /** Collection of errors to be shown to the user */ errors?: OnyxCommon.Errors; + + /** TODO: Doesn't exist in the app */ managerEmail?: string; + + /** TODO: Doesn't exist in the app */ parentReportActionIDs?: number[]; + + /** Collection of errors that exist in report fields */ errorFields?: OnyxCommon.ErrorFields; /** Whether the report is waiting on a bank account */ @@ -186,13 +250,29 @@ type Report = OnyxCommon.OnyxValueWithOfflineFeedback< /** If the report contains nonreimbursable expenses, send the nonreimbursable total */ nonReimbursableTotal?: number; + + /** Whether the report is hidden from options list */ isHidden?: boolean; + + /** Whether the report is a chat room */ isChatRoom?: boolean; + + /** Collection of participants personal details */ participantsList?: PersonalDetails[]; + + /** Text to be displayed in options list, which matches reportName by default */ text?: string; + + /** TODO: Doesn't exist in the app */ updateReportInLHN?: boolean; + + /** Collection of participant private notes, indexed by their accountID */ privateNotes?: Record; + + /** Whether participants private notes are being currently loaded */ isLoadingPrivateNotes?: boolean; + + /** Whether the report is currently selected in the options list */ selected?: boolean; /** Pending members of the report */ @@ -201,13 +281,16 @@ type Report = OnyxCommon.OnyxValueWithOfflineFeedback< /** The ID of the single transaction thread report associated with this report, if one exists */ transactionThreadReportID?: string; + /** Collection of policy report fields, indexed by their fieldID */ fieldList?: Record; + /** Collection of report permissions granted to the current user */ permissions?: Array>; }, PolicyReportField['fieldID'] >; +/** Collection of reports, indexed by report_{reportID} */ type ReportCollectionDataSet = CollectionDataSet; export default Report; diff --git a/src/types/onyx/ReportAction.ts b/src/types/onyx/ReportAction.ts index 8c4b3435771c..b8783cfe2d9f 100644 --- a/src/types/onyx/ReportAction.ts +++ b/src/types/onyx/ReportAction.ts @@ -11,6 +11,7 @@ import type OriginalMessage from './OriginalMessage'; import type {NotificationPreference} from './Report'; import type {Receipt} from './Transaction'; +/** Model of report action message */ type Message = { /** The type of the action item fragment. Used to render a corresponding component */ type: string; @@ -49,10 +50,17 @@ type Message = { /** Whether the pending transaction was reversed and didn't post to the card */ isReversedTransaction?: boolean; + + /** TODO: Only used in tests */ whisperedTo?: number[]; + + /** TODO: Only used in tests */ reactions?: Reaction[]; + /** In situations where moderation is required, this is the moderator decision data */ moderationDecision?: Decision; + + /** Key to translate the message */ translationKey?: string; /** ID of a task report */ @@ -77,6 +85,7 @@ type Message = { deleted?: string; }; +/** Model of image */ type ImageMetadata = { /** The height of the image. */ height?: number; @@ -91,6 +100,7 @@ type ImageMetadata = { type?: string; }; +/** Model of link */ type LinkMetadata = { /** The URL of the link. */ url?: string; @@ -111,12 +121,19 @@ type LinkMetadata = { logo?: ImageMetadata; }; +/** Model of report action person */ type Person = { + /** Type of the message to display */ type?: string; + + /** Style applied to the message */ style?: string; + + /** Content of the message to display which corresponds to the user display name */ text?: string; }; +/** Main properties of report action */ type ReportActionBase = OnyxCommon.OnyxValueWithOfflineFeedback<{ /** The ID of the reportAction. It is the string representation of the a 64-bit integer. */ reportActionID: string; @@ -127,6 +144,7 @@ type ReportActionBase = OnyxCommon.OnyxValueWithOfflineFeedback<{ /** The ID of the previous reportAction on the report. It is a string represenation of a 64-bit integer (or null for CREATED actions). */ previousReportActionID?: string; + /** Account ID of the actor that created the action */ actorAccountID?: number; /** The account of the last message's actor */ @@ -150,10 +168,13 @@ type ReportActionBase = OnyxCommon.OnyxValueWithOfflineFeedback<{ /** accountIDs of the people to which the whisper was sent to (if any). Returns empty array if it is not a whisper */ whisperedToAccountIDs?: number[]; + /** Avatar data to display on the report action */ avatar?: AvatarSource; + /** TODO: not enough context, seems to be used in tests only */ automatic?: boolean; + /** TODO: Not enough context, seems to be used in tests only */ shouldShow?: boolean; /** The ID of childReport */ @@ -168,12 +189,25 @@ type ReportActionBase = OnyxCommon.OnyxValueWithOfflineFeedback<{ /** The user's ID */ accountID?: number; + /** TODO: Doesn't exist in the app */ childOldestFourEmails?: string; + + /** Account IDs of the oldest four participants, useful to determine which avatars to display in threads */ childOldestFourAccountIDs?: string; + + /** TODO: Not enough context, but I think this represents how many participants are in the thread */ childCommenterCount?: number; + + /** Timestamp of the most recent reply */ childLastVisibleActionCreated?: string; + + /** Number of thread replies */ childVisibleActionCount?: number; + + /** Report ID of the parent report, if there's one */ parentReportID?: string; + + /** In task reports this is account ID of the user assigned to the task */ childManagerAccountID?: number; /** The status of the child report */ @@ -181,12 +215,26 @@ type ReportActionBase = OnyxCommon.OnyxValueWithOfflineFeedback<{ /** Report action child status name */ childStateNum?: ValueOf; + + /** TODO: Doesn't exist in the app */ childLastReceiptTransactionIDs?: string; + + /** Content of the last money request comment, used in report preview */ childLastMoneyRequestComment?: string; + + /** Account ID of the last actor */ childLastActorAccountID?: number; + + /** TODO: Only used in tests */ timestamp?: number; + + /** TODO: Only used in tests */ reportActionTimestamp?: number; + + /** Amount of money requests */ childMoneyRequestCount?: number; + + /** TODO: Seems to be used only on tests */ isFirstItem?: boolean; /** Informations about attachments of report action */ @@ -198,6 +246,7 @@ type ReportActionBase = OnyxCommon.OnyxValueWithOfflineFeedback<{ /** ISO-formatted datetime */ lastModified?: string; + /** The accountID of the copilot who took this action on behalf of the user */ delegateAccountID?: number; /** Server side errors keyed by microtime */ @@ -231,10 +280,13 @@ type ReportActionBase = OnyxCommon.OnyxValueWithOfflineFeedback<{ adminAccountID?: number; }>; +/** Model of report action */ type ReportAction = ReportActionBase & OriginalMessage; +/** Record of report actions, indexed by report action ID */ type ReportActions = Record; +/** Collection of mock report actions, indexed by reportActions_${reportID} */ type ReportActionsCollectionDataSet = CollectionDataSet; export default ReportAction; diff --git a/src/types/onyx/ReportActionReactions.ts b/src/types/onyx/ReportActionReactions.ts index 983598e0b420..fd14b681d6e9 100644 --- a/src/types/onyx/ReportActionReactions.ts +++ b/src/types/onyx/ReportActionReactions.ts @@ -1,5 +1,6 @@ import type * as OnyxCommon from './OnyxCommon'; +/** Model of report user reaction */ type UserReaction = { /** ID of user reaction */ id: string; @@ -11,8 +12,10 @@ type UserReaction = { oldestTimestamp: string; }; +/** Record of report user reactions, indexed by their login name or account id */ type UsersReactions = Record; +/** Model of report action reaction */ type ReportActionReaction = OnyxCommon.OnyxValueWithOfflineFeedback<{ /** The time the emoji was added */ createdAt: string; @@ -24,6 +27,7 @@ type ReportActionReaction = OnyxCommon.OnyxValueWithOfflineFeedback<{ users: UsersReactions; }>; +/** Record of report action reactions, indexed by emoji name */ type ReportActionReactions = Record; export default ReportActionReactions; diff --git a/src/types/onyx/ReportActionsDraft.ts b/src/types/onyx/ReportActionsDraft.ts index 41a701f16e71..762e4f690853 100644 --- a/src/types/onyx/ReportActionsDraft.ts +++ b/src/types/onyx/ReportActionsDraft.ts @@ -1,5 +1,7 @@ +/** Model of a report action draft */ type ReportActionsDraft = | { + /** Chat message content */ message: string; } | string; diff --git a/src/types/onyx/ReportActionsDrafts.ts b/src/types/onyx/ReportActionsDrafts.ts index e4c51c61ed25..56be910d53de 100644 --- a/src/types/onyx/ReportActionsDrafts.ts +++ b/src/types/onyx/ReportActionsDrafts.ts @@ -2,8 +2,10 @@ import type ONYXKEYS from '@src/ONYXKEYS'; import type CollectionDataSet from '@src/types/utils/CollectionDataSet'; import type ReportActionsDraft from './ReportActionsDraft'; +/** Record of report actions drafts, indexed by their ID */ type ReportActionsDrafts = Record; +/** Record of report actions drafts grouped by report, indexed by reportActionsDrafts_\ */ type ReportActionsDraftCollectionDataSet = CollectionDataSet; export default ReportActionsDrafts; diff --git a/src/types/onyx/ReportMetadata.ts b/src/types/onyx/ReportMetadata.ts index c6484705553c..8a6c004bc1c5 100644 --- a/src/types/onyx/ReportMetadata.ts +++ b/src/types/onyx/ReportMetadata.ts @@ -1,3 +1,4 @@ +/** Model of report metadata */ type ReportMetadata = { /** Are we loading newer report actions? */ isLoadingNewerReportActions?: boolean; diff --git a/src/types/onyx/ReportNextStep.ts b/src/types/onyx/ReportNextStep.ts index b619319d8f91..67c0852febc1 100644 --- a/src/types/onyx/ReportNextStep.ts +++ b/src/types/onyx/ReportNextStep.ts @@ -1,9 +1,16 @@ +/** Model of report next step message */ type Message = { + /** Message content */ text: string; + + /** HTML tag name */ type?: string; + + // TODO: Doesn't seem to be used in app action?: string; }; +// TODO: Doesn't seem to be used in app type DataOptions = { canSeeACHOption?: boolean; isManualReimbursementEnabled?: boolean; @@ -11,6 +18,7 @@ type DataOptions = { preferredWithdrawalDeleted?: boolean; }; +// TODO: Doesn't seem to be used in app type Button = { text?: string; tooltip?: string; @@ -19,6 +27,7 @@ type Button = { data?: DataOptions; }; +/** Model for next step of a report */ type ReportNextStep = { /** The message parts of the next step */ message?: Message[]; @@ -26,27 +35,35 @@ type ReportNextStep = { /** The title for the next step */ title?: string; + // TODO: Doesn't seem to be used in app /** Whether the user should take some sort of action in order to unblock the report */ requiresUserAction?: boolean; + // TODO: Doesn't seem to be used in app /** The type of next step */ type: 'alert' | 'neutral' | null; + // TODO: Doesn't seem to be used in app /** If the "Undo submit" button should be visible */ showUndoSubmit?: boolean; + // TODO: Doesn't seem to be used in app /** Deprecated - If the next step should be displayed on mobile, related to OldApp */ showForMobile?: boolean; + // TODO: Doesn't seem to be used in app /** If the next step should be displayed at the expense level */ showForExpense?: boolean; + // TODO: Doesn't seem to be used in app /** An optional alternate message to display on expenses instead of what is provided in the "message" field */ expenseMessage?: Message[]; + // TODO: Doesn't seem to be used in app /** The next person in the approval chain of the report */ nextReceiver?: string; + // TODO: Doesn't seem to be used in app /** An array of buttons to be displayed next to the next step */ buttons?: Record; }; diff --git a/src/types/onyx/ReportUserIsTyping.ts b/src/types/onyx/ReportUserIsTyping.ts index 1e6f482ffa7a..b599da4974fe 100644 --- a/src/types/onyx/ReportUserIsTyping.ts +++ b/src/types/onyx/ReportUserIsTyping.ts @@ -1,3 +1,4 @@ +/** Record of report users typing state, indexed by their login name or account id */ type ReportUserIsTyping = Record; export default ReportUserIsTyping; diff --git a/src/types/onyx/Request.ts b/src/types/onyx/Request.ts index 233519f010fc..ab45fcf84c42 100644 --- a/src/types/onyx/Request.ts +++ b/src/types/onyx/Request.ts @@ -1,29 +1,61 @@ import type {OnyxUpdate} from 'react-native-onyx'; import type Response from './Response'; +/** Model of onyx requests sent to the API */ type OnyxData = { + /** Onyx instructions that are executed after getting response from server with jsonCode === 200 */ successData?: OnyxUpdate[]; + + /** Onyx instructions that are executed after getting response from server with jsonCode !== 200 */ failureData?: OnyxUpdate[]; + + /** Onyx instructions that are executed after getting any response from server */ finallyData?: OnyxUpdate[]; + + /** Onyx instructions that are executed before request is made to the server */ optimisticData?: OnyxUpdate[]; }; +/** HTTP request method names */ type RequestType = 'get' | 'post'; +/** Model of overall requests sent to the API */ type RequestData = { + /** Name of the API command */ command: string; + + /** Command name for logging purposes */ commandName?: string; + + /** Additional parameters that can be sent with the request */ data?: Record; + + /** The HTTP request method name */ type?: RequestType; + + /** Whether the app should connect to the secure API endpoints */ shouldUseSecure?: boolean; + + /** Onyx instructions that are executed after getting response from server with jsonCode === 200 */ successData?: OnyxUpdate[]; + + /** Onyx instructions that are executed after getting response from server with jsonCode !== 200 */ failureData?: OnyxUpdate[]; + + /** Onyx instructions that are executed after getting any response from server */ finallyData?: OnyxUpdate[]; + + /** Promise resolve handler */ resolve?: (value: Response) => void; + + /** Promise reject handler */ reject?: (value?: unknown) => void; + + /** Whether the app should skip the web proxy to connect to API endpoints */ shouldSkipWebProxy?: boolean; }; +/** Model of requests sent to the API */ type Request = RequestData & OnyxData; export default Request; diff --git a/src/types/onyx/Response.ts b/src/types/onyx/Response.ts index 5e606738c56d..02f0ca62063e 100644 --- a/src/types/onyx/Response.ts +++ b/src/types/onyx/Response.ts @@ -1,26 +1,65 @@ import type {OnyxUpdate} from 'react-native-onyx'; +/** Model of commands data */ type Data = { + /** Name of the API call */ phpCommandName: string; + + /** Collection of auth write requests */ authWriteCommands: string[]; }; +/** Model of server response */ type Response = { + /** ID of the next update that needs to be fetched from the server */ previousUpdateID?: number | string; + + /** ID of the last update that needs to be fetched from the server */ lastUpdateID?: number | string; + + /** HTTP response status code */ jsonCode?: number | string; + + /** Collection of onyx updates (SET/MERGE/...) */ onyxData?: OnyxUpdate[]; + + /** ID of the request that triggered this response */ requestID?: string; + + /** Report ID of the updated report */ reportID?: string; + + /** + * Whether the sequential queue should not send any requests to the server. + * Used when there's a gap between client and server updates. + */ shouldPauseQueue?: boolean; + + /** User session auth token */ authToken?: string; + + /** Used to load resources like attachment videos and images */ encryptedAuthToken?: string; + + /** Used to pass error messages for error handling purposes */ message?: string; + + /** Used to pass error title for error handling purposes */ title?: string; + + /** Commands data */ data?: Data; + + /** Used to pass error type for error handling purposes */ type?: string; + + /** Short lived auth token generated by API */ shortLivedAuthToken?: string; + + // TODO: This doesn't seem to be used in app auth?: string; + + // TODO: This doesn't seem to be used in app // eslint-disable-next-line @typescript-eslint/naming-convention shared_secret?: string; }; diff --git a/src/types/onyx/ScreenShareRequest.ts b/src/types/onyx/ScreenShareRequest.ts index 564ba99c22ac..920921e8c9b2 100644 --- a/src/types/onyx/ScreenShareRequest.ts +++ b/src/types/onyx/ScreenShareRequest.ts @@ -1,3 +1,4 @@ +/** Model of screen share request */ type ScreenShareRequest = { /** Access token required to join a screen share room, generated by the backend */ accessToken: string; diff --git a/src/types/onyx/SecurityGroup.ts b/src/types/onyx/SecurityGroup.ts index b2362c1eb628..7b213c2e88c8 100644 --- a/src/types/onyx/SecurityGroup.ts +++ b/src/types/onyx/SecurityGroup.ts @@ -1,4 +1,6 @@ +/** Model of security group */ type SecurityGroup = { + /** Whether the security group restricts primary login switching */ hasRestrictedPrimaryLogin: boolean; }; diff --git a/src/types/onyx/SelectedTabRequest.ts b/src/types/onyx/SelectedTabRequest.ts index 8a87db6eee82..db79b948dcde 100644 --- a/src/types/onyx/SelectedTabRequest.ts +++ b/src/types/onyx/SelectedTabRequest.ts @@ -1,6 +1,7 @@ import type {ValueOf} from 'type-fest'; import type CONST from '@src/CONST'; +/** Selectable IOU request tabs */ type SelectedTabRequest = ValueOf; export default SelectedTabRequest; diff --git a/src/types/onyx/Session.ts b/src/types/onyx/Session.ts index d181114d02d3..7cb47a380717 100644 --- a/src/types/onyx/Session.ts +++ b/src/types/onyx/Session.ts @@ -2,8 +2,10 @@ import type {ValueOf} from 'type-fest'; import type CONST from '@src/CONST'; import type * as OnyxCommon from './OnyxCommon'; +/** Possible states of the automatic authentication after user clicks on a magic link */ type AutoAuthState = ValueOf; +/** Model of user session data */ type Session = { /** The user's email for the current session */ email?: string; @@ -26,6 +28,7 @@ type Session = { /** Currently logged in user accountID */ accountID?: number; + /** Current state of the automatic authentication after user clicks on a magic link */ autoAuthState?: AutoAuthState; /** Server side errors keyed by microtime */ diff --git a/src/types/onyx/Task.ts b/src/types/onyx/Task.ts index ee3b8e8abd87..4878802135c2 100644 --- a/src/types/onyx/Task.ts +++ b/src/types/onyx/Task.ts @@ -1,5 +1,6 @@ import type Report from './Report'; +/** Model of task data */ type Task = { /** Title of the Task */ title?: string; diff --git a/src/types/onyx/Transaction.ts b/src/types/onyx/Transaction.ts index 5ed318b21ce5..a7f61a6f07b4 100644 --- a/src/types/onyx/Transaction.ts +++ b/src/types/onyx/Transaction.ts @@ -8,6 +8,7 @@ import type * as OnyxCommon from './OnyxCommon'; import type RecentWaypoint from './RecentWaypoint'; import type ReportAction from './ReportAction'; +/** Model of waypoint */ type Waypoint = { /** The name associated with the address of the waypoint */ name?: string; @@ -40,80 +41,174 @@ type Waypoint = { street2?: string; }; +/** + * Collection of waypoints, indexed by `waypoint${index}` + * where `index` corresponds to the position of the waypoint in the list + */ type WaypointCollection = Record; +/** Model of transaction comment */ type Comment = { + /** Content of the transaction comment */ comment?: string; + + /** Whether the transaction is on hold */ hold?: string; + + /** Collection of waypoints associated with the transaction */ waypoints?: WaypointCollection; + + /** Whether the transaction comment is loading */ isLoading?: boolean; + + /** TODO: I think this type can be changed to `ValueOf` */ + /** Type of the transaction */ type?: string; + + /** In custom unit transactions this holds the information of the custom unit */ customUnit?: TransactionCustomUnit; + + /** Source of the transaction which when specified matches `split` */ source?: string; + + /** ID of the original transaction */ originalTransactionID?: string; + + /** In split transactions this is a collection of participant split data */ splits?: Split[]; }; +/** Model of transaction custom unit */ type TransactionCustomUnit = { + /** ID of the custom unit */ customUnitID?: string; + + /** ID of the custom unit rate */ customUnitRateID?: string; + + /** Custom unit amount */ quantity?: number; + + /** TODO: I think this value can be changed to `ValueOf` */ + /** Name of the custom unit */ name?: string; + + /** Default rate for custom unit */ defaultP2PRate?: number; }; +/** Types of geometry */ type GeometryType = 'LineString'; +/** Geometry data */ type Geometry = { + /** Matrix of points, indexed by their coordinates */ coordinates: number[][] | null; + + /** Type of connections between coordinates */ type?: GeometryType; }; +/** Accepted receipt paths */ type ReceiptSource = string; +/** Model of receipt */ type Receipt = { + /** TODO: This doesn't exist in the app */ receiptID?: number; + + /** TODO: This doesn't exist in the app */ path?: string; + + /** TODO: This doesn't exist in the app */ name?: string; + + /** Path of the receipt file */ source?: ReceiptSource; + + /** Name of receipt file */ filename?: string; + + /** Current receipt scan state */ state?: ValueOf; + + /** Type of the receipt file */ type?: string; }; +/** Model of route */ type Route = { + /** Distance amount of the route */ distance: number | null; + + /** Route geometry data */ geometry: Geometry; }; +/** Collection of routes, indexed by `route${index}` where `index` is the position of the route in the list */ type Routes = Record; -type ReceiptError = {error?: string; source: string; filename: string}; +/** Model of receipt error */ +type ReceiptError = { + /** TODO: This doesn't exist in the app */ + error?: string; + /** Path of the receipt file */ + source: string; + + /** Name of the receipt file */ + filename: string; +}; + +/** Collection of receipt errors, indexed by a UNIX timestamp of when the error occurred */ type ReceiptErrors = Record; +/** Tax rate data */ type TaxRateData = { + /** TODO: This doesn't exist in the app */ name: string; + + /** Tax rate percentage */ value: string; + + /** Tax rate code */ code?: string; }; +/** Model of tax rate */ type TaxRate = { + /** Default name of the tax rate */ text: string; + + /** Key of the tax rate to index it on options list */ keyForList: string; + + /** TODO: This doesn't exist in the app */ searchText: string; + + /** TODO: This doesn't exist in the app */ tooltipText: string; + + /** TODO: This doesn't exist in the app */ isDisabled?: boolean; + + /** Data of the tax rate */ data?: TaxRateData; }; +/** Participant split data */ type SplitShare = { + /** Amount to be split with participant */ amount: number; + + /** Whether the split was modified */ isModified?: boolean; }; +/** Record of participant split data, indexed by their `accountID` */ type SplitShares = Record; +/** Model of transaction */ type Transaction = OnyxCommon.OnyxValueWithOfflineFeedback< { /** The original transaction amount */ @@ -250,17 +345,28 @@ type Transaction = OnyxCommon.OnyxValueWithOfflineFeedback< keyof Comment >; +/** Keys of pending transaction fields */ type TransactionPendingFieldsKey = KeysOfUnion; +/** Additional transaction changes data */ type AdditionalTransactionChanges = { + /** Content of modified comment */ comment?: string; + + /** Collection of modified waypoints */ waypoints?: WaypointCollection; + + /** Previous amount before changes */ oldAmount?: number; + + /** Previous currency before changes */ oldCurrency?: string; }; +/** Model of transaction changes */ type TransactionChanges = Partial & AdditionalTransactionChanges; +/** Collection of mock transactions, indexed by `transactions_${transactionID}` */ type TransactionCollectionDataSet = CollectionDataSet; export default Transaction; diff --git a/src/types/onyx/TransactionViolation.ts b/src/types/onyx/TransactionViolation.ts index 28de4582bd5e..666a92898cbc 100644 --- a/src/types/onyx/TransactionViolation.ts +++ b/src/types/onyx/TransactionViolation.ts @@ -6,32 +6,76 @@ import type CONST from '@src/CONST'; */ type ViolationName = (typeof CONST.VIOLATIONS)[keyof typeof CONST.VIOLATIONS]; +/** Model of a transaction violation */ type TransactionViolation = { + /** Type of transaction violation ('violation', 'notice', 'warning', ...) */ type: string; + + /** Name of the transaction violation */ name: ViolationName; + + /** Additional violation information to provide the user */ data?: { + /** Who rejected the transaction */ rejectedBy?: string; + + /** Why the transaction was rejected */ rejectReason?: string; + + /** Limit that the transaction violated */ formattedLimit?: string; + + /** Percentage amount of conversion surcharge applied to the transaction */ surcharge?: number; + + /** Percentage amount of invoice markup applied to the transaction */ invoiceMarkup?: number; + + /** Amount of days which the transaction date overpasses the date limit */ maxAge?: number; + + /** Name of the tag that triggered this violation */ tagName?: string; + + // TODO: Doesn't seem to be used in app categoryLimit?: string; + + // TODO: Doesn't seem to be used in app limit?: string; + + /** Name of the category that triggered this violation */ category?: string; + + /** Whether the transaction failed due to a broken bank connection */ brokenBankConnection?: boolean; + + /** Whether the workspace admin needs to resolve this violation */ isAdmin?: boolean; + + /** Workspace admin email */ email?: string; + + /** Whether the transaction is older than 7 days */ isTransactionOlderThan7Days?: boolean; + + /** Workspace admin name */ member?: string; + + /** Name of the tax that triggered this violation */ taxName?: string; + + /** Index of the tag form field that triggered this violation */ tagListIndex?: number; + + /** Name of the tag form field that triggered this violation */ tagListName?: string; + + /** Collection of form fields that triggered this violation */ errorIndexes?: number[]; }; }; +/** Collection of transaction violations */ type TransactionViolations = TransactionViolation[]; export type {TransactionViolation, ViolationName}; diff --git a/src/types/onyx/User.ts b/src/types/onyx/User.ts index 973f09e16b82..f30ca846ef43 100644 --- a/src/types/onyx/User.ts +++ b/src/types/onyx/User.ts @@ -1,3 +1,4 @@ +/** Model of user data */ type User = { /** Whether or not the user is subscribed to news updates */ isSubscribedToNewsletter: boolean; diff --git a/src/types/onyx/UserLocation.ts b/src/types/onyx/UserLocation.ts index b22802bfefb1..8ff0b8f8f101 100644 --- a/src/types/onyx/UserLocation.ts +++ b/src/types/onyx/UserLocation.ts @@ -1,3 +1,4 @@ +/** Location coordinates for user */ type UserLocation = Pick; export default UserLocation; diff --git a/src/types/onyx/UserWallet.ts b/src/types/onyx/UserWallet.ts index 55a1b31a9084..eb1b11c7adb0 100644 --- a/src/types/onyx/UserWallet.ts +++ b/src/types/onyx/UserWallet.ts @@ -2,12 +2,16 @@ import type {ValueOf} from 'type-fest'; import type CONST from '@src/CONST'; import type * as OnyxCommon from './OnyxCommon'; +/** Type of account linked to user's wallet */ type WalletLinkedAccountType = 'debitCard' | 'bankAccount'; +/** Error code sent from the server after updating user's wallet */ type ErrorCode = 'ssnError' | 'kbaNeeded' | 'kycFailed'; +/** Type of setup that the user follows to link an account to his wallet */ type SetupType = ValueOf; +/** Model of user wallet */ type UserWallet = { /** The user's available wallet balance */ availableBalance: number; diff --git a/src/types/onyx/WalletAdditionalDetails.ts b/src/types/onyx/WalletAdditionalDetails.ts index c574006e9f66..bd2ba89d181d 100644 --- a/src/types/onyx/WalletAdditionalDetails.ts +++ b/src/types/onyx/WalletAdditionalDetails.ts @@ -1,8 +1,14 @@ import type * as OnyxCommon from './OnyxCommon'; +/** Model of user wallet Idology question */ type WalletAdditionalQuestionDetails = { + /** Question prompt */ prompt: string; + + /** Question type */ type: string; + + /** Possible answers */ answer: string[]; }; @@ -18,6 +24,7 @@ type WalletPersonalDetails = { phoneNumber: string; }; +/** Model of user wallet additional details */ type WalletAdditionalDetails = { /** Questions returned by Idology */ questions?: WalletAdditionalQuestionDetails[]; @@ -30,8 +37,14 @@ type WalletAdditionalDetails = { /** Which field needs attention? */ errorFields?: OnyxCommon.ErrorFields; + + // TODO: this property is not used in app additionalErrorMessage?: string; + + /** Whether the details are being loaded */ isLoading?: boolean; + + /** Error messages to display to the user */ errors?: OnyxCommon.Errors; }; diff --git a/src/types/onyx/WalletOnfido.ts b/src/types/onyx/WalletOnfido.ts index de7c80b34037..d144431eff9f 100644 --- a/src/types/onyx/WalletOnfido.ts +++ b/src/types/onyx/WalletOnfido.ts @@ -1,5 +1,6 @@ import type * as OnyxCommon from './OnyxCommon'; +/** Model of wallet onfido */ type WalletOnfido = { /** Unique identifier returned from openOnfidoFlow then re-sent to ActivateWallet with Onfido response data */ applicantID?: string; diff --git a/src/types/onyx/WalletStatement.ts b/src/types/onyx/WalletStatement.ts index 62b8266c8e43..c9cc72662c1c 100644 --- a/src/types/onyx/WalletStatement.ts +++ b/src/types/onyx/WalletStatement.ts @@ -1,3 +1,4 @@ +/** Model of wallet statement */ type WalletStatement = { /** Whether we are currently generating a PDF version of the statement */ isGenerating: boolean; diff --git a/src/types/onyx/WalletTerms.ts b/src/types/onyx/WalletTerms.ts index c2653cae0f97..be66b779b91f 100644 --- a/src/types/onyx/WalletTerms.ts +++ b/src/types/onyx/WalletTerms.ts @@ -1,6 +1,7 @@ import type {Source} from '@components/KYCWall/types'; import type * as OnyxCommon from './OnyxCommon'; +/** Model of wallet terms */ type WalletTerms = { /** Any error message to show */ errors?: OnyxCommon.Errors; diff --git a/src/types/onyx/WalletTransfer.ts b/src/types/onyx/WalletTransfer.ts index 961a7c9752a5..8bcf6e7217a3 100644 --- a/src/types/onyx/WalletTransfer.ts +++ b/src/types/onyx/WalletTransfer.ts @@ -3,6 +3,7 @@ import type CONST from '@src/CONST'; import type * as OnyxCommon from './OnyxCommon'; import type PaymentMethod from './PaymentMethod'; +/** Model of user wallet transfer */ type WalletTransfer = { /** Selected accountID for transfer */ selectedAccountID?: string | number; @@ -22,9 +23,11 @@ type WalletTransfer = { /** Whether or not data is loading */ loading?: boolean; + /** Payment method used for transfer */ paymentMethodType?: ValueOf>; }; +/** Available payment methods */ type FilterMethodPaymentType = typeof CONST.PAYMENT_METHODS.DEBIT_CARD | typeof CONST.PAYMENT_METHODS.PERSONAL_BANK_ACCOUNT | ''; export default WalletTransfer; diff --git a/src/types/onyx/WorkspaceRateAndUnit.ts b/src/types/onyx/WorkspaceRateAndUnit.ts index a374239c93f8..ebef0902d972 100644 --- a/src/types/onyx/WorkspaceRateAndUnit.ts +++ b/src/types/onyx/WorkspaceRateAndUnit.ts @@ -1,5 +1,7 @@ +/** Units of distance */ type Unit = 'mi' | 'km'; +/** Model of workspace distance rate */ type WorkspaceRateAndUnit = { /** policyID of the Workspace */ policyID: string; @@ -7,7 +9,7 @@ type WorkspaceRateAndUnit = { /** Unit of the Workspace */ unit?: Unit; - /** Unit of the Workspace */ + /** Distance rate of the Workspace */ rate?: string; }; From 4dac52f425e48af2396760a7c9747a0c9ec32bb8 Mon Sep 17 00:00:00 2001 From: Pedro Guerreiro Date: Tue, 14 May 2024 00:23:07 +0100 Subject: [PATCH 02/16] docs: add missing onyx types descriptions --- src/libs/ReportUtils.ts | 1 + src/types/onyx/OriginalMessage.ts | 224 +++++++++++++++++++++++++++++- src/types/onyx/Policy.ts | 7 + 3 files changed, 231 insertions(+), 1 deletion(-) diff --git a/src/libs/ReportUtils.ts b/src/libs/ReportUtils.ts index 641d3ddaa268..871eff75cdea 100644 --- a/src/libs/ReportUtils.ts +++ b/src/libs/ReportUtils.ts @@ -86,6 +86,7 @@ type AvatarRange = 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | type WelcomeMessage = {showReportName: boolean; phrase1?: string; phrase2?: string}; +/** TODO: I'd move this to `OriginalMessage.ts` and add it to `OriginalMessageModifiedExpense` type */ type ExpenseOriginalMessage = { oldComment?: string; newComment?: string; diff --git a/src/types/onyx/OriginalMessage.ts b/src/types/onyx/OriginalMessage.ts index dabfdc9aa485..5d1f0f290b04 100644 --- a/src/types/onyx/OriginalMessage.ts +++ b/src/types/onyx/OriginalMessage.ts @@ -2,9 +2,13 @@ import type {ValueOf} from 'type-fest'; import type CONST from '@src/CONST'; import type DeepValueOf from '@src/types/utils/DeepValueOf'; +/** Types of payments methods */ type PaymentMethodType = DeepValueOf; +/** Names of report actions */ type ActionName = DeepValueOf; + +/** Names of task report actions */ type OriginalMessageActionName = | 'ADDCOMMENT' | 'APPROVED' @@ -28,235 +32,425 @@ type OriginalMessageActionName = | 'ACTIONABLEREPORTMENTIONWHISPER' | 'ACTIONABLETRACKEXPENSEWHISPER' | ValueOf; + +/** Model of `approved` report action */ type OriginalMessageApproved = { actionName: typeof CONST.REPORT.ACTIONS.TYPE.APPROVED; + + /** TODO: I think the type should match the scructure of `originalMessage` in `buildOptimisticApprovedReportAction` */ originalMessage: unknown; }; + +/** Types of sources of original message */ type OriginalMessageSource = 'Chronos' | 'email' | 'ios' | 'android' | 'web' | ''; +/** Model of `hold` report action */ type OriginalMessageHold = { actionName: typeof CONST.REPORT.ACTIONS.TYPE.HOLD; originalMessage: unknown; }; +/** Model of `hold comment` report action */ type OriginalMessageHoldComment = { actionName: typeof CONST.REPORT.ACTIONS.TYPE.HOLD_COMMENT; originalMessage: unknown; }; +/** Model of `unhold` report action */ type OriginalMessageUnHold = { actionName: typeof CONST.REPORT.ACTIONS.TYPE.UNHOLD; originalMessage: unknown; }; +/** Details provided when sending money */ type IOUDetails = { + /** How much was sent */ amount: number; + + /** Optional comment */ comment?: string; + + /** Currency of the money sent */ currency: string; }; +/** Model of original message of `IOU` report action */ type IOUMessage = { - /** The ID of the iou transaction */ + /** The ID of the `IOU` transaction */ IOUTransactionID?: string; + + /** ID of the `IOU` report */ IOUReportID?: string; + + /** ID of the expense report */ expenseReportID?: string; + + /** How much was transactioned */ amount: number; + + /** Optional comment */ comment?: string; + + /** Currency of the transactioned money */ currency: string; + + /** When was the `IOU` last modified */ lastModified?: string; + + /** Who participated in the transaction, by accountID */ participantAccountIDs?: number[]; + + /** Type of `IOU` report action */ type: ValueOf; + + /** If the action was cancelled, this is the reason for the cancellation */ cancellationReason?: string; + + /** Type of payment method used in transaction */ paymentType?: PaymentMethodType; + + /** Timestamp of when the `IOU` report action was deleted */ deleted?: string; + /** Only exists when we are sending money */ IOUDetails?: IOUDetails; }; +/** Model of original message of `reimbursed dequeued` report action */ type ReimbursementDeQueuedMessage = { + /** TODO: I'd replace this type with `ValueOf` */ + /** Why the reimbursement was cancelled */ cancellationReason: string; + + /** ID of the `expense` report */ expenseReportID?: string; + + /** Amount that wasn't reimbursed */ amount: number; + + /** Currency of the money that wasn't reimbursed */ currency: string; }; +/** Model of `IOU` report action */ type OriginalMessageIOU = { actionName: typeof CONST.REPORT.ACTIONS.TYPE.IOU; originalMessage: IOUMessage; }; +/** Names of severity flags */ type FlagSeverityName = ValueOf< Pick< typeof CONST.MODERATION, 'FLAG_SEVERITY_SPAM' | 'FLAG_SEVERITY_INCONSIDERATE' | 'FLAG_SEVERITY_INTIMIDATION' | 'FLAG_SEVERITY_BULLYING' | 'FLAG_SEVERITY_HARASSMENT' | 'FLAG_SEVERITY_ASSAULT' > >; + +/** Model of severity flag */ type FlagSeverity = { + /** Account ID of the user that flagged the comment */ accountID: number; + + /** When was the comment flagged */ timestamp: string; }; +/** Names of moderation decisions */ type DecisionName = ValueOf< Pick< typeof CONST.MODERATION, 'MODERATOR_DECISION_PENDING' | 'MODERATOR_DECISION_PENDING_HIDE' | 'MODERATOR_DECISION_PENDING_REMOVE' | 'MODERATOR_DECISION_APPROVED' | 'MODERATOR_DECISION_HIDDEN' > >; + +/** Model of moderator decision */ type Decision = { + /** Name of the decision */ decision: DecisionName; + + /** When was the decision name */ timestamp?: string; }; +/** Model of user reaction */ type User = { + /** Account ID of the user that reacted to the comment */ accountID: number; + + /** What's the skin tone of the user reaction */ skinTone: number; }; +/** Model of comment reaction */ type Reaction = { + /** Which emoji was used to react to the comment */ emoji: string; + + /** Which users reacted with this emoji */ users: User[]; }; +/** Model of original message of `closed` report action */ type Closed = { + /** Name of the policy */ policyName: string; + + /** What was the reason to close the report */ reason: ValueOf; + + /** When was the message last modified */ lastModified?: string; + + /** If the report was closed because accounts got merged, then this is the new account ID */ newAccountID?: number; + + /** If the report was closed because accounts got merged, then this is the old account ID */ oldAccountID?: number; }; +/** Model of `add comment` report action */ type OriginalMessageAddComment = { actionName: typeof CONST.REPORT.ACTIONS.TYPE.ADD_COMMENT; originalMessage: { + /** HTML content of the comment */ html: string; + + /** Origin of the comment */ source?: OriginalMessageSource; + + /** When was the comment last modified */ lastModified?: string; + + /** ID of the task report */ taskReportID?: string; + + /** TODO: Doesn't exist in the app */ edits?: string[]; + + /** TODO: Doesn't exist in the app */ childReportID?: string; + + /** TODO: Doesn't exist in the app */ isDeletedParentAction?: boolean; + + /** TODO: Doesn't exist in the app */ flags?: Record; + + /** TODO: Doesn't exist in the app */ moderationDecisions?: Decision[]; + + /** TODO: Only used in tests */ whisperedTo: number[]; + + /** TODO: Doesn't exist in the app */ reactions?: Reaction[]; }; }; +/** Model of `actionable mention whisper` report action */ type OriginalMessageActionableMentionWhisper = { actionName: typeof CONST.REPORT.ACTIONS.TYPE.ACTIONABLE_MENTION_WHISPER; originalMessage: { + /** Account IDs of users that aren't members of the room */ inviteeAccountIDs: number[]; + + /** TODO: Doesn't exist in the app */ inviteeEmails: string; + + /** TODO: Only used in tests */ lastModified: string; + + /** TODO: Doesn't exist in the app */ reportID: number; + + /** Decision on whether to invite users that were mentioned but aren't members or do nothing */ resolution?: ValueOf | null; + + /** TODO: Doesn't exist in the app */ whisperedTo?: number[]; }; }; +/** Model of `actionable report mention whisper` report action */ type OriginalMessageActionableReportMentionWhisper = { actionName: typeof CONST.REPORT.ACTIONS.TYPE.ACTIONABLE_REPORT_MENTION_WHISPER; originalMessage: { + /** TODO: Doesn't exist in the app */ reportNames: string[]; + + /** TODO: Doesn't exist in the app */ mentionedAccountIDs: number[]; + + /** TODO: Doesn't exist in the app */ reportActionID: number; + + /** TODO: Doesn't exist in the app */ reportID: number; + + /** TODO: Only used in tests */ lastModified: string; + + /** Decision on whether to create a report that were mentioned but doesn't exist or do nothing */ resolution?: ValueOf | null; + + /** TODO: Doesn't exist in the app */ whisperedTo?: number[]; }; }; +/** Model of `submitted` report action */ type OriginalMessageSubmitted = { actionName: typeof CONST.REPORT.ACTIONS.TYPE.SUBMITTED; + + /** TODO: I think the type should match the scructure of `originalMessage` in `buildOptimisticSubmittedReportAction` */ originalMessage: unknown; }; +/** Model of `closed` report action */ type OriginalMessageClosed = { actionName: typeof CONST.REPORT.ACTIONS.TYPE.CLOSED; originalMessage: Closed; }; +/** Model of `created` report action */ type OriginalMessageCreated = { actionName: typeof CONST.REPORT.ACTIONS.TYPE.CREATED; originalMessage?: unknown; }; +/** Model of `marked reimbursed` report action */ type OriginalMessageMarkedReimbursed = { actionName: typeof CONST.REPORT.ACTIONS.TYPE.MARKED_REIMBURSED; originalMessage?: unknown; }; +/** Model of `renamed` report action, created when chat rooms get renamed */ type OriginalMessageRenamed = { actionName: typeof CONST.REPORT.ACTIONS.TYPE.RENAMED; originalMessage: { + /** Renamed room comment */ html: string; + + /** When was report action last modified */ lastModified: string; + + /** Old room name */ oldName: string; + + /** New room name */ newName: string; }; }; +/** Model of Chronos OOO Timestamp */ type ChronosOOOTimestamp = { + /** Date timestamp */ date: string; + + /** TODO: Doesn't exist in the app */ + /** Timezone code */ timezone: string; + + /** TODO: Doesn't exist in the app */ // eslint-disable-next-line @typescript-eslint/naming-convention timezone_type: number; }; +/** Model of change log */ type ChangeLog = { + /** Account IDs of users that either got invited or removed from the room */ targetAccountIDs?: number[]; + + /** Name of the chat room */ roomName?: string; + + /** ID of the report */ reportID?: number; }; +/** Model of Chronos OOO Event */ type ChronosOOOEvent = { + /** ID of the OOO event */ id: string; + + /** How many days will the user be OOO */ lengthInDays: number; + + /** Description of the OOO state */ summary: string; + + /** When will the OOO state start */ start: ChronosOOOTimestamp; + + /** When will the OOO state end */ end: ChronosOOOTimestamp; }; +/** Model of `Chronos OOO List` report action */ type OriginalMessageChronosOOOList = { actionName: typeof CONST.REPORT.ACTIONS.TYPE.CHRONOS_OOO_LIST; originalMessage: { + /** TODO: Doesn't exist in the app */ edits: string[]; + + /** Collection of OOO events to show in report action */ events: ChronosOOOEvent[]; + + /** TODO: Only used in tests */ html: string; + + /** TODO: Only used in tests */ lastModified: string; }; }; +/** Model of `report preview` report action */ type OriginalMessageReportPreview = { actionName: typeof CONST.REPORT.ACTIONS.TYPE.REPORT_PREVIEW; originalMessage: { + /** ID of the report to be previewed */ linkedReportID: string; + + /** TODO: Only used in tests */ lastModified?: string; }; }; +/** Model of `policy change log` report action */ type OriginalMessagePolicyChangeLog = { actionName: ValueOf; originalMessage: ChangeLog; }; +/** Model of `join policy change log` report action */ type OriginalMessageJoinPolicyChangeLog = { actionName: typeof CONST.REPORT.ACTIONS.TYPE.ACTIONABLE_JOIN_REQUEST; originalMessage: { + /** TODO: I think this type could be changed to `ValueOf` */ + /** What was the invited user decision */ choice: string; + + /** TODO: Doesn't exist in the app */ email: string; + + /** TODO: Doesn't exist in the app */ inviterEmail: string; + + /** TODO: Only used in tests */ lastModified: string; + + /** TODO: Doesn't exist in the app */ policyID: string; }; }; +/** Model of `room change log` report action */ type OriginalMessageRoomChangeLog = { actionName: ValueOf; originalMessage: ChangeLog; }; +/** Model of `policy task` report action */ type OriginalMessagePolicyTask = { actionName: | typeof CONST.REPORT.ACTIONS.TYPE.TASK_EDITED @@ -267,8 +461,10 @@ type OriginalMessagePolicyTask = { originalMessage: unknown; }; +/** Model of `modified expense` report action */ type OriginalMessageModifiedExpense = { actionName: typeof CONST.REPORT.ACTIONS.TYPE.MODIFIED_EXPENSE; + /** TODO: I think this type could be replaced by `ExpenseOriginalMessage` from `ReportUtils.ts` */ originalMessage: { oldMerchant?: string; merchant?: string; @@ -293,52 +489,78 @@ type OriginalMessageModifiedExpense = { }; }; +/** Model of `reimbursement queued` report action */ type OriginalMessageReimbursementQueued = { actionName: typeof CONST.REPORT.ACTIONS.TYPE.REIMBURSEMENT_QUEUED; originalMessage: { + /** How is the payment getting reimbursed */ paymentType: DeepValueOf; }; }; +/** Model of `actionable tracked expense whisper` report action */ type OriginalMessageActionableTrackedExpenseWhisper = { actionName: typeof CONST.REPORT.ACTIONS.TYPE.ACTIONABLE_TRACK_EXPENSE_WHISPER; originalMessage: { + /** ID of the transaction */ transactionID: string; + + /** TODO: Only used in tests */ lastModified: string; + + /** What was the decision of the user */ resolution?: ValueOf; }; }; +/** Model of `reimbursement dequeued` report action */ type OriginalMessageReimbursementDequeued = { actionName: typeof CONST.REPORT.ACTIONS.TYPE.REIMBURSEMENT_DEQUEUED; + + /** TODO: I think this type should be `ReimbursementDeQueuedMessage` */ originalMessage: { + /** ID of the expense report */ expenseReportID: string; }; }; +/** Model of `moved` report action */ type OriginalMessageMoved = { actionName: typeof CONST.REPORT.ACTIONS.TYPE.MOVED; originalMessage: { + /** ID of the old policy */ fromPolicyID: string; + + /** ID of the new policy */ toPolicyID: string; + + /** ID of the new parent report */ newParentReportID: string; + + /** ID of the moved report */ movedReportID: string; }; }; +/** Model of `merged with cash transaction` report action */ type OriginalMessageMergedWithCashTransaction = { actionName: typeof CONST.REPORT.ACTIONS.TYPE.MERGED_WITH_CASH_TRANSACTION; originalMessage: Record; // No data is sent with this action }; +/** Model of `dismissed violation` report action */ type OriginalMessageDismissedViolation = { actionName: typeof CONST.REPORT.ACTIONS.TYPE.DISMISSED_VIOLATION; originalMessage: { + /** Why the violation was dismissed */ reason: string; + + /** Name of the violation */ violationName: string; }; }; +/** Model of report action */ type OriginalMessage = | OriginalMessageApproved | OriginalMessageIOU diff --git a/src/types/onyx/Policy.ts b/src/types/onyx/Policy.ts index c0f74747d5b0..170104eab0e5 100644 --- a/src/types/onyx/Policy.ts +++ b/src/types/onyx/Policy.ts @@ -309,18 +309,25 @@ type QBOConnectionConfig = OnyxCommon.OnyxValueWithOfflineFeedback<{ /** TODO: Doesn't exist in the app */ markChecksToBePrinted: boolean; + /** Defines how reimbursable expenses are exported */ reimbursableExpensesExportDestination: QBOReimbursableExportAccountType; + /** Defines how non reimbursable expenses are exported */ nonReimbursableExpensesExportDestination: QBONonReimbursableExportAccountType; + /** Default vendor of non reimbursable bill */ nonReimbursableBillDefaultVendor: string; + /** ID of the invoice collection account */ collectionAccountID?: string; + /** ID of the bill payment account */ reimbursementAccountID?: string; + /** Account that receives the reimbursable expenses */ reimbursableExpensesAccount?: Account; + /** Account that receives the non reimbursable expenses */ nonReimbursableExpensesAccount?: Account; /** Account that receives the exported invoices */ From 13029ae924c52345317b5865f576d5241e428230 Mon Sep 17 00:00:00 2001 From: Pedro Guerreiro Date: Wed, 15 May 2024 15:21:01 +0100 Subject: [PATCH 03/16] docs: add missing type descriptions --- src/types/onyx/IOU.ts | 8 +++++++- src/types/onyx/OriginalMessage.ts | 4 ++++ src/types/onyx/ReportAction.ts | 6 ++++++ 3 files changed, 17 insertions(+), 1 deletion(-) diff --git a/src/types/onyx/IOU.ts b/src/types/onyx/IOU.ts index 04c1bb49ab52..20f9a0ea4677 100644 --- a/src/types/onyx/IOU.ts +++ b/src/types/onyx/IOU.ts @@ -15,7 +15,8 @@ type Participant = { /** Is IOU participant associated with policy expense chat */ isPolicyExpenseChat?: boolean; - + + /** Whether the IOU participant is an invoice receiver */ isInvoiceRoom?: boolean; /** Is IOU participant associated with is own policy expense chat */ @@ -62,7 +63,12 @@ type Participant = { /** Is IOU participant the current user */ isSelfDM?: boolean; + + /** Whether the IOU participant is an invoice sender */ isSender?: boolean; + + /** TODO: I think this type could be changes to `IOUType` */ + /** The type of IOU report, i.e. split, request, send, track */ iouType?: string; }; diff --git a/src/types/onyx/OriginalMessage.ts b/src/types/onyx/OriginalMessage.ts index 7f7c9001d7ff..c54602503bae 100644 --- a/src/types/onyx/OriginalMessage.ts +++ b/src/types/onyx/OriginalMessage.ts @@ -114,6 +114,8 @@ type IOUMessage = { /** Only exists when we are sending money */ IOUDetails?: IOUDetails; + + /** Collection of accountIDs of users mentioned in message */ whisperedTo?: number[]; }; @@ -414,6 +416,8 @@ type OriginalMessageReportPreview = { /** TODO: Only used in tests */ lastModified?: string; + + /** Collection of accountIDs of users mentioned in report */ whisperedTo?: number[]; }; }; diff --git a/src/types/onyx/ReportAction.ts b/src/types/onyx/ReportAction.ts index 1e973d9a7a86..ae319c120f20 100644 --- a/src/types/onyx/ReportAction.ts +++ b/src/types/onyx/ReportAction.ts @@ -11,7 +11,9 @@ import type OriginalMessage from './OriginalMessage'; import type {NotificationPreference} from './Report'; import type {Receipt} from './Transaction'; +/** Partial content of report action message */ type ReportActionMessageJSON = { + /** Collection of accountIDs from users that were mentioned in report */ whisperedTo?: number[]; }; @@ -283,7 +285,11 @@ type ReportActionBase = OnyxCommon.OnyxValueWithOfflineFeedback<{ /** Model of report action */ type ReportAction = ReportActionBase & OriginalMessage; + +/** Model of report preview action */ type ReportPreviewAction = ReportActionBase & OriginalMessageReportPreview; + +/** Model of modifies expense action */ type ModifiedExpenseAction = ReportActionBase & OriginalMessageModifiedExpense; /** Record of report actions, indexed by report action ID */ From 96f6955166498e0b4a08f377fd057d9f8b7149dc Mon Sep 17 00:00:00 2001 From: Pedro Guerreiro Date: Mon, 20 May 2024 23:47:50 +0100 Subject: [PATCH 04/16] docs: apply pull request suggestions --- src/types/onyx/BankAccount.ts | 4 ++-- src/types/onyx/BlockedFromConcierge.ts | 2 +- src/types/onyx/Card.ts | 8 ++++---- src/types/onyx/Console.ts | 2 +- src/types/onyx/Fund.ts | 2 +- src/types/onyx/IOU.ts | 26 +++++++++++++------------- src/types/onyx/WalletOnfido.ts | 2 +- 7 files changed, 23 insertions(+), 23 deletions(-) diff --git a/src/types/onyx/BankAccount.ts b/src/types/onyx/BankAccount.ts index 6ca40f37093d..33d35d547935 100644 --- a/src/types/onyx/BankAccount.ts +++ b/src/types/onyx/BankAccount.ts @@ -39,10 +39,10 @@ type BankAccount = OnyxCommon.OnyxValueWithOfflineFeedback<{ /* Determines if the bank account is a savings account */ isSavings?: boolean; - /** Date when the 3 micro amounts for validation were supposed to reach the bank account. */ + /** Date when the 3 micro amounts for validation were supposed to reach the bank account */ validateCodeExpectedDate?: string; - /** string like 'bankAccount-{\}' where is the bankAccountID */ + /** string like `bankAccount-` */ key?: string; /** Alias for bankAccountID */ diff --git a/src/types/onyx/BlockedFromConcierge.ts b/src/types/onyx/BlockedFromConcierge.ts index 7274602bee38..ed4381076555 100644 --- a/src/types/onyx/BlockedFromConcierge.ts +++ b/src/types/onyx/BlockedFromConcierge.ts @@ -1,4 +1,4 @@ -/** Model of blocked from concierge */ +/** Model of blocked user from concierge */ type BlockedFromConcierge = { /** The date that the user will be unblocked */ expiresAt: string; diff --git a/src/types/onyx/Card.ts b/src/types/onyx/Card.ts index 4ede25c34be6..7c958a4e8bd1 100644 --- a/src/types/onyx/Card.ts +++ b/src/types/onyx/Card.ts @@ -2,7 +2,7 @@ import type {ValueOf} from 'type-fest'; import type CONST from '@src/CONST'; import type * as OnyxCommon from './OnyxCommon'; -/** Model of expensify card */ +/** Model of Expensify card */ type Card = { /** Card ID number */ cardID: number; @@ -22,7 +22,7 @@ type Card = { /** Last four Primary Account Number digits */ lastFourPAN?: string; - /** Determines if the current card was flagged as fraud */ + /** Current fraud state of the card */ fraud: ValueOf; /** Card related error messages */ @@ -64,7 +64,7 @@ type Card = { }; }; -/** Model of expensify card details */ +/** Model of Expensify card details */ type TCardDetails = { /** Card Primary Account Number */ pan: string; @@ -98,7 +98,7 @@ type TCardDetails = { }; }; -/** Record of expensify cards, indexed by cardID */ +/** Record of Expensify cards, indexed by cardID */ type CardList = Record; export default Card; diff --git a/src/types/onyx/Console.ts b/src/types/onyx/Console.ts index 371782fe9156..c8d2b714ae2b 100644 --- a/src/types/onyx/Console.ts +++ b/src/types/onyx/Console.ts @@ -12,7 +12,7 @@ type Log = { message: string; }; -/** Record of logs */ +/** Record of captured logs */ type CapturedLogs = Record; export type {Log, CapturedLogs}; diff --git a/src/types/onyx/Fund.ts b/src/types/onyx/Fund.ts index 3a527a45db2c..3cb7255e4bfe 100644 --- a/src/types/onyx/Fund.ts +++ b/src/types/onyx/Fund.ts @@ -61,7 +61,7 @@ type Fund = OnyxCommon.OnyxValueWithOfflineFeedback<{ /** Debit card description */ description?: string; - /** String like 'fund-{}' where is the fundID */ + /** String like `fund-` */ key?: string; /** Alias for fundID */ diff --git a/src/types/onyx/IOU.ts b/src/types/onyx/IOU.ts index 20f9a0ea4677..9c04ad59ef3a 100644 --- a/src/types/onyx/IOU.ts +++ b/src/types/onyx/IOU.ts @@ -116,46 +116,46 @@ type Split = { /** Model of IOU request */ type IOU = { - /** IOU ID */ + /** ID of the IOU request */ id: string; - /** IOU amount */ + /** Amount requested in IOU */ amount?: number; /** Selected Currency Code of the current IOU */ currency?: string; - /** IOU comment */ + /** Comment of the IOU request creator */ comment?: string; - /** IOU category */ + /** Category assigned to the IOU request */ category?: string; - /** IOU merchant */ + /** Merchant where the amount was spent */ merchant?: string; - /** IOU creation date */ + /** Date timestamp when the IOU request was created */ created?: string; - /** IOU receipt file path */ + /** Local file path of the expense receipt */ receiptPath?: string; - /** IOU comment */ + /** File name of the expense receipt */ receiptFilename?: string; - /** IOU transaction ID */ + /** Transaction ID assigned to the IOU request */ transactionID?: string; - /** IOU participants */ + /** Users involved in the IOU request */ participants?: Participant[]; - /** IOU tag */ + /** Tag assigned to the IOU request */ tag?: string; - /** Is IOU billable */ + /** Whether the IOU request is billable */ billable?: boolean; - /** Is an IOU split request */ + /** Whether the IOU request is to be split with multiple users */ isSplitRequest?: boolean; }; diff --git a/src/types/onyx/WalletOnfido.ts b/src/types/onyx/WalletOnfido.ts index d144431eff9f..344ffdef170c 100644 --- a/src/types/onyx/WalletOnfido.ts +++ b/src/types/onyx/WalletOnfido.ts @@ -1,6 +1,6 @@ import type * as OnyxCommon from './OnyxCommon'; -/** Model of wallet onfido */ +/** Model of wallet Onfido flow */ type WalletOnfido = { /** Unique identifier returned from openOnfidoFlow then re-sent to ActivateWallet with Onfido response data */ applicantID?: string; From 65022fb6ef5ed7962007f5877eea6766eee2180f Mon Sep 17 00:00:00 2001 From: Pedro Guerreiro Date: Wed, 22 May 2024 10:14:59 +0100 Subject: [PATCH 05/16] refactor: apply pull request suggestions --- src/libs/ModifiedExpenseMessage.ts | 4 +- src/libs/ReportUtils.ts | 31 +----- src/libs/actions/Card.ts | 6 +- src/libs/models/BankAccount.ts | 4 +- .../settings/Wallet/ExpensifyCardPage.tsx | 8 +- src/types/onyx/AccountData.ts | 26 +---- src/types/onyx/BankAccount.ts | 5 +- src/types/onyx/Card.ts | 4 +- src/types/onyx/Fund.ts | 12 +-- src/types/onyx/OriginalMessage.ts | 51 ++++----- src/types/onyx/Transaction.ts | 6 +- src/types/onyx/TransactionViolation.ts | 102 +++++++++--------- 12 files changed, 103 insertions(+), 156 deletions(-) diff --git a/src/libs/ModifiedExpenseMessage.ts b/src/libs/ModifiedExpenseMessage.ts index 2df75030ac19..77a77281a95e 100644 --- a/src/libs/ModifiedExpenseMessage.ts +++ b/src/libs/ModifiedExpenseMessage.ts @@ -3,12 +3,12 @@ import type {OnyxCollection, OnyxEntry} from 'react-native-onyx'; import CONST from '@src/CONST'; import ONYXKEYS from '@src/ONYXKEYS'; import type {PolicyTagList, ReportAction} from '@src/types/onyx'; +import type {ModifiedExpense} from '@src/types/onyx/OriginalMessage'; import * as CurrencyUtils from './CurrencyUtils'; import DateUtils from './DateUtils'; import getReportPolicyID from './getReportPolicyID'; import * as Localize from './Localize'; import * as PolicyUtils from './PolicyUtils'; -import type {ExpenseOriginalMessage} from './ReportUtils'; import * as TransactionUtils from './TransactionUtils'; let allPolicyTags: OnyxCollection = {}; @@ -109,7 +109,7 @@ function getForReportAction(reportID: string | undefined, reportAction: OnyxEntr if (reportAction?.actionName !== CONST.REPORT.ACTIONS.TYPE.MODIFIED_EXPENSE) { return ''; } - const reportActionOriginalMessage = reportAction?.originalMessage as ExpenseOriginalMessage | undefined; + const reportActionOriginalMessage = reportAction?.originalMessage as ModifiedExpense | undefined; const policyID = getReportPolicyID(reportID) ?? ''; const removalFragments: string[] = []; diff --git a/src/libs/ReportUtils.ts b/src/libs/ReportUtils.ts index 99e21c243c73..47c9b12dec6f 100644 --- a/src/libs/ReportUtils.ts +++ b/src/libs/ReportUtils.ts @@ -41,6 +41,7 @@ import type {Errors, Icon, PendingAction} from '@src/types/onyx/OnyxCommon'; import type { ChangeLog, IOUMessage, + ModifiedExpense, OriginalMessageActionName, OriginalMessageCreated, OriginalMessageDismissedViolation, @@ -86,31 +87,6 @@ type AvatarRange = 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | type WelcomeMessage = {showReportName: boolean; phrase1?: string; phrase2?: string}; -/** TODO: I'd move this to `OriginalMessage.ts` and add it to `OriginalMessageModifiedExpense` type */ -type ExpenseOriginalMessage = { - oldComment?: string; - newComment?: string; - comment?: string; - merchant?: string; - oldCreated?: string; - created?: string; - oldMerchant?: string; - oldAmount?: number; - amount?: number; - oldCurrency?: string; - currency?: string; - category?: string; - oldCategory?: string; - tag?: string; - oldTag?: string; - billable?: string; - oldBillable?: string; - oldTaxAmount?: number; - taxAmount?: number; - taxRate?: string; - oldTaxRate?: string; -}; - type SpendBreakdown = { nonReimbursableSpend: number; reimbursableSpend: number; @@ -2970,8 +2946,8 @@ function getModifiedExpenseOriginalMessage( transactionChanges: TransactionChanges, isFromExpenseReport: boolean, policy: OnyxEntry, -): ExpenseOriginalMessage { - const originalMessage: ExpenseOriginalMessage = {}; +): ModifiedExpense { + const originalMessage: ModifiedExpense = {}; // Remark: Comment field is the only one which has new/old prefixes for the keys (newComment/ oldComment), // all others have old/- pattern such as oldCreated/created if ('comment' in transactionChanges) { @@ -6947,7 +6923,6 @@ export { export type { Ancestor, DisplayNameWithTooltips, - ExpenseOriginalMessage, OptimisticAddCommentReportAction, OptimisticChatReport, OptimisticClosedReportAction, diff --git a/src/libs/actions/Card.ts b/src/libs/actions/Card.ts index 756ef902d913..9a011d88e582 100644 --- a/src/libs/actions/Card.ts +++ b/src/libs/actions/Card.ts @@ -5,7 +5,7 @@ import type {ActivatePhysicalExpensifyCardParams, ReportVirtualExpensifyCardFrau import {SIDE_EFFECT_REQUEST_COMMANDS, WRITE_COMMANDS} from '@libs/API/types'; import CONST from '@src/CONST'; import ONYXKEYS from '@src/ONYXKEYS'; -import type {Response} from '@src/types/onyx'; +import type {ExpensifyCardDetails} from '@src/types/onyx/Card'; type ReplacementReason = 'damaged' | 'stolen'; @@ -158,7 +158,7 @@ function clearCardListErrors(cardID: number) { * * @returns promise with card details object */ -function revealVirtualCardDetails(cardID: number): Promise { +function revealVirtualCardDetails(cardID: number): Promise { return new Promise((resolve, reject) => { const parameters: RevealExpensifyCardDetailsParams = {cardID}; @@ -170,7 +170,7 @@ function revealVirtualCardDetails(cardID: number): Promise { reject('cardPage.cardDetailsLoadingFailure'); return; } - resolve(response); + resolve(response as ExpensifyCardDetails); }) // eslint-disable-next-line prefer-promise-reject-errors .catch(() => reject('cardPage.cardDetailsLoadingFailure')); diff --git a/src/libs/models/BankAccount.ts b/src/libs/models/BankAccount.ts index 611d77c99927..198b8f25334b 100644 --- a/src/libs/models/BankAccount.ts +++ b/src/libs/models/BankAccount.ts @@ -1,7 +1,7 @@ import Str from 'expensify-common/lib/str'; import type {ValueOf} from 'type-fest'; import CONST from '@src/CONST'; -import type {AdditionalData} from '@src/types/onyx/BankAccount'; +import type {BankAccountAdditionalData} from '@src/types/onyx/BankAccount'; import type BankAccountJSON from '@src/types/onyx/BankAccount'; type State = ValueOf; @@ -194,7 +194,7 @@ class BankAccount { /** * Get the additional data of a bankAccount */ - getAdditionalData(): Partial { + getAdditionalData(): Partial { return this.json.accountData?.additionalData ?? {}; } diff --git a/src/pages/settings/Wallet/ExpensifyCardPage.tsx b/src/pages/settings/Wallet/ExpensifyCardPage.tsx index 2f4135820b08..6ab2554c2cda 100644 --- a/src/pages/settings/Wallet/ExpensifyCardPage.tsx +++ b/src/pages/settings/Wallet/ExpensifyCardPage.tsx @@ -32,7 +32,7 @@ import ROUTES from '@src/ROUTES'; import type SCREENS from '@src/SCREENS'; import type {GetPhysicalCardForm} from '@src/types/form'; import type {LoginList, Card as OnyxCard, PrivatePersonalDetails} from '@src/types/onyx'; -import type {TCardDetails} from '@src/types/onyx/Card'; +import type {ExpensifyCardDetails} from '@src/types/onyx/Card'; import RedDotCardSection from './RedDotCardSection'; import CardDetails from './WalletPage/CardDetails'; @@ -101,7 +101,7 @@ function ExpensifyCardPage({ const virtualCards = useMemo(() => cardsToShow?.filter((card) => card?.nameValuePairs?.isVirtual), [cardsToShow]); const physicalCards = useMemo(() => cardsToShow?.filter((card) => !card?.nameValuePairs?.isVirtual), [cardsToShow]); - const [cardsDetails, setCardsDetails] = useState>({}); + const [cardsDetails, setCardsDetails] = useState>({}); const [isCardDetailsLoading, setIsCardDetailsLoading] = useState>({}); const [cardsDetailsErrors, setCardsDetailsErrors] = useState>({}); @@ -116,9 +116,7 @@ function ExpensifyCardPage({ // eslint-disable-next-line rulesdir/no-thenable-actions-in-views Card.revealVirtualCardDetails(revealedCardID) .then((value) => { - // TODO: Card.revealVirtualCardDetails return type doesn't include TCardDetails, forcing us to type cast it here. - // The return type could be rewritten like Promise - setCardsDetails((prevState: Record) => ({...prevState, [revealedCardID]: value as TCardDetails})); + setCardsDetails((prevState: Record) => ({...prevState, [revealedCardID]: value})); setCardsDetailsErrors((prevState) => ({ ...prevState, [revealedCardID]: '', diff --git a/src/types/onyx/AccountData.ts b/src/types/onyx/AccountData.ts index 78c8391ac8ae..010715f15f85 100644 --- a/src/types/onyx/AccountData.ts +++ b/src/types/onyx/AccountData.ts @@ -1,28 +1,6 @@ -import type {BankName} from './Bank'; +import type {BankAccountAdditionalData} from './BankAccount'; import type * as OnyxCommon from './OnyxCommon'; -/** Model of additional bank account data */ -type AdditionalData = { - /** Is a Peer-To-Peer debit card */ - isP2PDebitCard?: boolean; - - /** Owners that can benefit from this bank account */ - beneficialOwners?: string[]; - - /** In which currency is the bank account */ - currency?: string; - - /** In which bank is the bank account */ - bankName?: BankName; - - // TODO: Confirm this - /** Whether the bank account is local or international */ - fieldsType?: string; - - /** In which country is the bank account */ - country?: string; -}; - /** Model of bank account data */ type AccountData = { /** The masked bank account number */ @@ -59,7 +37,7 @@ type AccountData = { bankAccountID?: number; /** All data related to the bank account */ - additionalData?: AdditionalData; + additionalData?: BankAccountAdditionalData; /** The bank account type */ type?: string; diff --git a/src/types/onyx/BankAccount.ts b/src/types/onyx/BankAccount.ts index 33d35d547935..1a2505a83592 100644 --- a/src/types/onyx/BankAccount.ts +++ b/src/types/onyx/BankAccount.ts @@ -2,9 +2,8 @@ import type CONST from '@src/CONST'; import type AccountData from './AccountData'; import type * as OnyxCommon from './OnyxCommon'; -// TODO: This type is a duplicate of the one present in AccountData.ts /** Model of additional bank account data */ -type AdditionalData = { +type BankAccountAdditionalData = { /** Is a Peer-To-Peer Debit Card */ isP2PDebitCard?: boolean; @@ -62,4 +61,4 @@ type BankAccount = OnyxCommon.OnyxValueWithOfflineFeedback<{ type BankAccountList = Record; export default BankAccount; -export type {AccountData, AdditionalData, BankAccountList}; +export type {AccountData, BankAccountAdditionalData, BankAccountList}; diff --git a/src/types/onyx/Card.ts b/src/types/onyx/Card.ts index 7c958a4e8bd1..9e683a29ee06 100644 --- a/src/types/onyx/Card.ts +++ b/src/types/onyx/Card.ts @@ -65,7 +65,7 @@ type Card = { }; /** Model of Expensify card details */ -type TCardDetails = { +type ExpensifyCardDetails = { /** Card Primary Account Number */ pan: string; @@ -102,4 +102,4 @@ type TCardDetails = { type CardList = Record; export default Card; -export type {TCardDetails, CardList}; +export type {ExpensifyCardDetails, CardList}; diff --git a/src/types/onyx/Fund.ts b/src/types/onyx/Fund.ts index 3cb7255e4bfe..8ee8fe42e734 100644 --- a/src/types/onyx/Fund.ts +++ b/src/types/onyx/Fund.ts @@ -1,20 +1,12 @@ import type CONST from '@src/CONST'; import type {BankName} from './Bank'; +import type {BankAccountAdditionalData} from './BankAccount'; import type * as OnyxCommon from './OnyxCommon'; -/** Mode of additional debit card account data */ -type AdditionalData = { - // TODO: Not used in app explicitly - isBillingCard?: boolean; - - /** Is Peer-To-Peer debit card */ - isP2PDebitCard?: boolean; -}; - /** Model of debit card account data */ type AccountData = { /** Additional account data */ - additionalData?: AdditionalData; + additionalData?: BankAccountAdditionalData; /** Address name */ addressName?: string; diff --git a/src/types/onyx/OriginalMessage.ts b/src/types/onyx/OriginalMessage.ts index c54602503bae..734ffc3cf064 100644 --- a/src/types/onyx/OriginalMessage.ts +++ b/src/types/onyx/OriginalMessage.ts @@ -389,6 +389,31 @@ type ChronosOOOEvent = { end: ChronosOOOTimestamp; }; +/** Model of modified expense */ +type ModifiedExpense = { + oldComment?: string; + newComment?: string; + comment?: string; + merchant?: string; + oldCreated?: string; + created?: string; + oldMerchant?: string; + oldAmount?: number; + amount?: number; + oldCurrency?: string; + currency?: string; + category?: string; + oldCategory?: string; + tag?: string; + oldTag?: string; + billable?: string; + oldBillable?: string; + oldTaxAmount?: number; + taxAmount?: number; + taxRate?: string; + oldTaxRate?: string; +}; + /** Model of `Chronos OOO List` report action */ type OriginalMessageChronosOOOList = { actionName: typeof CONST.REPORT.ACTIONS.TYPE.CHRONOS_OOO_LIST; @@ -470,30 +495,7 @@ type OriginalMessagePolicyTask = { /** Model of `modified expense` report action */ type OriginalMessageModifiedExpense = { actionName: typeof CONST.REPORT.ACTIONS.TYPE.MODIFIED_EXPENSE; - /** TODO: I think this type could be replaced by `ExpenseOriginalMessage` from `ReportUtils.ts` */ - originalMessage: { - oldMerchant?: string; - merchant?: string; - oldCurrency?: string; - currency?: string; - oldAmount?: number; - amount?: number; - oldComment?: string; - newComment?: string; - oldCreated?: string; - created?: string; - oldCategory?: string; - category?: string; - oldTag?: string; - tag?: string; - oldTaxAmount?: number; - taxAmount?: number; - oldTaxRate?: string; - taxRate?: string; - oldBillable?: string; - billable?: string; - whisperedTo?: number[]; - }; + originalMessage: ModifiedExpense; }; /** Model of `reimbursement queued` report action */ @@ -607,6 +609,7 @@ export type { Closed, OriginalMessageActionName, ChangeLog, + ModifiedExpense, OriginalMessageIOU, OriginalMessageCreated, OriginalMessageRenamed, diff --git a/src/types/onyx/Transaction.ts b/src/types/onyx/Transaction.ts index a7f61a6f07b4..844bacc9c66c 100644 --- a/src/types/onyx/Transaction.ts +++ b/src/types/onyx/Transaction.ts @@ -61,9 +61,8 @@ type Comment = { /** Whether the transaction comment is loading */ isLoading?: boolean; - /** TODO: I think this type can be changed to `ValueOf` */ /** Type of the transaction */ - type?: string; + type?: ValueOf; /** In custom unit transactions this holds the information of the custom unit */ customUnit?: TransactionCustomUnit; @@ -89,9 +88,8 @@ type TransactionCustomUnit = { /** Custom unit amount */ quantity?: number; - /** TODO: I think this value can be changed to `ValueOf` */ /** Name of the custom unit */ - name?: string; + name?: ValueOf; /** Default rate for custom unit */ defaultP2PRate?: number; diff --git a/src/types/onyx/TransactionViolation.ts b/src/types/onyx/TransactionViolation.ts index 49cdf51c1eb5..821bbdcb1fa4 100644 --- a/src/types/onyx/TransactionViolation.ts +++ b/src/types/onyx/TransactionViolation.ts @@ -1,79 +1,83 @@ +import type {ValueOf} from 'type-fest'; import type CONST from '@src/CONST'; /** * Names of violations. * Derived from `CONST.VIOLATIONS` to maintain a single source of truth. */ -type ViolationName = (typeof CONST.VIOLATIONS)[keyof typeof CONST.VIOLATIONS]; +type ViolationName = ValueOf; -/** Model of a transaction violation */ -type TransactionViolation = { - /** Type of transaction violation ('violation', 'notice', 'warning', ...) */ - type: string; +/** Model of transaction violation data */ +type TransactionViolationData = { + /** Who rejected the transaction */ + rejectedBy?: string; - /** Name of the transaction violation */ - name: ViolationName; + /** Why the transaction was rejected */ + rejectReason?: string; - /** Additional violation information to provide the user */ - data?: { - /** Who rejected the transaction */ - rejectedBy?: string; + /** Limit that the transaction violated */ + formattedLimit?: string; + + /** Percentage amount of conversion surcharge applied to the transaction */ + surcharge?: number; - /** Why the transaction was rejected */ - rejectReason?: string; + /** Percentage amount of invoice markup applied to the transaction */ + invoiceMarkup?: number; - /** Limit that the transaction violated */ - formattedLimit?: string; + /** Amount of days which the transaction date overpasses the date limit */ + maxAge?: number; - /** Percentage amount of conversion surcharge applied to the transaction */ - surcharge?: number; + /** Name of the tag that triggered this violation */ + tagName?: string; - /** Percentage amount of invoice markup applied to the transaction */ - invoiceMarkup?: number; + // TODO: Doesn't seem to be used in app + categoryLimit?: string; - /** Amount of days which the transaction date overpasses the date limit */ - maxAge?: number; + // TODO: Doesn't seem to be used in app + limit?: string; - /** Name of the tag that triggered this violation */ - tagName?: string; + /** Name of the category that triggered this violation */ + category?: string; - // TODO: Doesn't seem to be used in app - categoryLimit?: string; + /** Whether the transaction failed due to a broken bank connection */ + brokenBankConnection?: boolean; - // TODO: Doesn't seem to be used in app - limit?: string; + /** Whether the workspace admin needs to resolve this violation */ + isAdmin?: boolean; - /** Name of the category that triggered this violation */ - category?: string; + /** Workspace admin email */ + email?: string; - /** Whether the transaction failed due to a broken bank connection */ - brokenBankConnection?: boolean; + /** Whether the transaction is older than 7 days */ + isTransactionOlderThan7Days?: boolean; - /** Whether the workspace admin needs to resolve this violation */ - isAdmin?: boolean; + /** Workspace admin name */ + member?: string; - /** Workspace admin email */ - email?: string; + /** Name of the tax that triggered this violation */ + taxName?: string; - /** Whether the transaction is older than 7 days */ - isTransactionOlderThan7Days?: boolean; + /** Index of the tag form field that triggered this violation */ + tagListIndex?: number; - /** Workspace admin name */ - member?: string; + /** Name of the tag form field that triggered this violation */ + tagListName?: string; - /** Name of the tax that triggered this violation */ - taxName?: string; + /** Collection of form fields that triggered this violation */ + errorIndexes?: number[]; + pendingPattern?: boolean; +}; - /** Index of the tag form field that triggered this violation */ - tagListIndex?: number; +/** Model of a transaction violation */ +type TransactionViolation = { + /** Type of transaction violation ('violation', 'notice', 'warning', ...) */ + type: string; - /** Name of the tag form field that triggered this violation */ - tagListName?: string; + /** Name of the transaction violation */ + name: ViolationName; - /** Collection of form fields that triggered this violation */ - errorIndexes?: number[]; - pendingPattern?: boolean; - }; + /** Additional violation information to provide the user */ + data?: TransactionViolationData; }; /** Collection of transaction violations */ From f3e1c8f75fb6ffff6ee4153a06810c58d8cdb591 Mon Sep 17 00:00:00 2001 From: Pedro Guerreiro Date: Wed, 22 May 2024 15:17:48 +0100 Subject: [PATCH 06/16] refactor: apply pull request suggestions --- src/types/onyx/Response.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/types/onyx/Response.ts b/src/types/onyx/Response.ts index 02f0ca62063e..aa060223637b 100644 --- a/src/types/onyx/Response.ts +++ b/src/types/onyx/Response.ts @@ -56,10 +56,10 @@ type Response = { /** Short lived auth token generated by API */ shortLivedAuthToken?: string; - // TODO: This doesn't seem to be used in app + /** User authorization token to authorize Pusher connections */ auth?: string; - // TODO: This doesn't seem to be used in app + /** Base64 key to decrypt messages from Pusher encrypted channels */ // eslint-disable-next-line @typescript-eslint/naming-convention shared_secret?: string; }; From 530d6d681c806fab09862755f6c003846cc57556 Mon Sep 17 00:00:00 2001 From: Pedro Guerreiro Date: Wed, 22 May 2024 15:55:25 +0100 Subject: [PATCH 07/16] refactor: remove unused property from wallet additional details --- src/libs/actions/Wallet.ts | 5 ----- src/types/onyx/WalletAdditionalDetails.ts | 3 --- 2 files changed, 8 deletions(-) diff --git a/src/libs/actions/Wallet.ts b/src/libs/actions/Wallet.ts index 045cc34f39ef..3dd3f01c0703 100644 --- a/src/libs/actions/Wallet.ts +++ b/src/libs/actions/Wallet.ts @@ -61,10 +61,6 @@ function setAdditionalDetailsErrors(errorFields: OnyxCommon.ErrorFields) { Onyx.merge(ONYXKEYS.WALLET_ADDITIONAL_DETAILS, {errorFields}); } -function setAdditionalDetailsErrorMessage(additionalErrorMessage: string) { - Onyx.merge(ONYXKEYS.WALLET_ADDITIONAL_DETAILS, {additionalErrorMessage}); -} - /** * Save the source that triggered the KYC wall and optionally the chat report ID associated with the IOU */ @@ -304,7 +300,6 @@ export { openInitialSettingsPage, openEnablePaymentsPage, setAdditionalDetailsErrors, - setAdditionalDetailsErrorMessage, setAdditionalDetailsQuestions, updateCurrentStep, answerQuestionsForWallet, diff --git a/src/types/onyx/WalletAdditionalDetails.ts b/src/types/onyx/WalletAdditionalDetails.ts index bd2ba89d181d..c92fd14390b5 100644 --- a/src/types/onyx/WalletAdditionalDetails.ts +++ b/src/types/onyx/WalletAdditionalDetails.ts @@ -38,9 +38,6 @@ type WalletAdditionalDetails = { /** Which field needs attention? */ errorFields?: OnyxCommon.ErrorFields; - // TODO: this property is not used in app - additionalErrorMessage?: string; - /** Whether the details are being loaded */ isLoading?: boolean; From 9a50d43625b9aa680ea42650ed97fdd4e851497d Mon Sep 17 00:00:00 2001 From: Pedro Guerreiro Date: Wed, 22 May 2024 15:55:48 +0100 Subject: [PATCH 08/16] docs: add missing type description --- src/types/onyx/TransactionViolation.ts | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/types/onyx/TransactionViolation.ts b/src/types/onyx/TransactionViolation.ts index 821bbdcb1fa4..ffbbb23037d0 100644 --- a/src/types/onyx/TransactionViolation.ts +++ b/src/types/onyx/TransactionViolation.ts @@ -65,6 +65,8 @@ type TransactionViolationData = { /** Collection of form fields that triggered this violation */ errorIndexes?: number[]; + + /** Whether the current violation is `pending RTER` */ pendingPattern?: boolean; }; From a4d41028ea452559e4748257f8be86ac8321fb2d Mon Sep 17 00:00:00 2001 From: Pedro Guerreiro Date: Fri, 24 May 2024 13:15:30 +0100 Subject: [PATCH 09/16] chore: resolve pending descriptions --- src/types/onyx/Card.ts | 24 ++++++++++++++---------- src/types/onyx/ReportNextStep.ts | 24 ++++++++++-------------- 2 files changed, 24 insertions(+), 24 deletions(-) diff --git a/src/types/onyx/Card.ts b/src/types/onyx/Card.ts index 9e683a29ee06..9ab60a06f7e6 100644 --- a/src/types/onyx/Card.ts +++ b/src/types/onyx/Card.ts @@ -33,32 +33,36 @@ type Card = { /** Additional card data */ nameValuePairs?: { - // TODO: Doesn't seem to be used in app - /** Type of spending limits */ + /** Type of card spending limits */ limitType?: ValueOf; - // TODO: Doesn't seem to be used in app - cardTitle?: string; // Used only for admin-issued virtual cards + /** User-defined nickname for a virtual card */ + cardTitle?: string; - // TODO: Doesn't seem to be used in app + /** Account ID of user that issued the card */ issuedBy?: number; - // TODO: Doesn't seem to be used in app + /** + * Whether the card has a custom unapproved expense limit. + * When not set, the domain unapproved expense limit is used + */ hasCustomUnapprovedExpenseLimit?: boolean; - // TODO: Doesn't seem to be used in app + /** + * The maximum unapproved spend allowed on the card. + * If it's $100 and you spend $100, you need to get the expenses approved for the card to continue working + */ unapprovedExpenseLimit?: number; - // TODO: Doesn't seem to be used in app + /** Card product under which the card is provisioned */ feedCountry?: string; /** Is a virtual card */ isVirtual?: boolean; - // TODO: Doesn't seem to be used in app + /** Previous card state */ previousState?: number; - // TODO: Doesn't seem to be used in app /** Card expiration date */ expirationDate?: string; }; diff --git a/src/types/onyx/ReportNextStep.ts b/src/types/onyx/ReportNextStep.ts index 67c0852febc1..d2c1f2477c56 100644 --- a/src/types/onyx/ReportNextStep.ts +++ b/src/types/onyx/ReportNextStep.ts @@ -35,36 +35,32 @@ type ReportNextStep = { /** The title for the next step */ title?: string; - // TODO: Doesn't seem to be used in app /** Whether the user should take some sort of action in order to unblock the report */ requiresUserAction?: boolean; - // TODO: Doesn't seem to be used in app - /** The type of next step */ + /** + * The type of next step + * + * "neutral" for normal next steps, "alert" for more urgent/actionable + */ type: 'alert' | 'neutral' | null; - // TODO: Doesn't seem to be used in app - /** If the "Undo submit" button should be visible */ + /** Whether the "Undo submit" button should be visible */ showUndoSubmit?: boolean; - // TODO: Doesn't seem to be used in app - /** Deprecated - If the next step should be displayed on mobile, related to OldApp */ + /** Whether the next step should be displayed on mobile, related to OldApp */ showForMobile?: boolean; - // TODO: Doesn't seem to be used in app - /** If the next step should be displayed at the expense level */ + /** Whether the next step should be displayed at the expense level */ showForExpense?: boolean; - // TODO: Doesn't seem to be used in app /** An optional alternate message to display on expenses instead of what is provided in the "message" field */ expenseMessage?: Message[]; - // TODO: Doesn't seem to be used in app - /** The next person in the approval chain of the report */ + /** Email of the next person in the approval chain that needs to approve the report */ nextReceiver?: string; - // TODO: Doesn't seem to be used in app - /** An array of buttons to be displayed next to the next step */ + /** An array listing the buttons to be displayed alongside the next step copy */ buttons?: Record; }; From 5599455b32aa406fbe4f7714a432e925dd7acd78 Mon Sep 17 00:00:00 2001 From: Pedro Guerreiro Date: Mon, 27 May 2024 21:20:52 +0100 Subject: [PATCH 10/16] docs: apply suggestions --- src/types/onyx/BankAccount.ts | 3 +-- src/types/onyx/Card.ts | 22 ---------------------- src/types/onyx/Task.ts | 7 +++++-- src/types/onyx/TransactionViolation.ts | 6 ------ 4 files changed, 6 insertions(+), 32 deletions(-) diff --git a/src/types/onyx/BankAccount.ts b/src/types/onyx/BankAccount.ts index 1a2505a83592..34eb15646b2f 100644 --- a/src/types/onyx/BankAccount.ts +++ b/src/types/onyx/BankAccount.ts @@ -16,8 +16,7 @@ type BankAccountAdditionalData = { /** In which bank is the bank account */ bankName?: string; - // TODO: Confirm this - /** Whether the bank account is local or international */ + /** Whether the bank account details were obtained for local transfer or international wire */ fieldsType?: string; /** In which country is the bank account */ diff --git a/src/types/onyx/Card.ts b/src/types/onyx/Card.ts index 9ab60a06f7e6..595104d4aed3 100644 --- a/src/types/onyx/Card.ts +++ b/src/types/onyx/Card.ts @@ -78,28 +78,6 @@ type ExpensifyCardDetails = { /** Card Verification Value number */ cvv: string; - - // TODO: Doesn't seem to be used in app - /** Card owner address */ - address: { - /** Address line 1 */ - street: string; - - /** Address line 2 */ - street2: string; - - /** City */ - city: string; - - /** State */ - state: string; - - /** Zip code */ - zip: string; - - /** Country */ - country: string; - }; }; /** Record of Expensify cards, indexed by cardID */ diff --git a/src/types/onyx/Task.ts b/src/types/onyx/Task.ts index 4878802135c2..ac11e5f3755f 100644 --- a/src/types/onyx/Task.ts +++ b/src/types/onyx/Task.ts @@ -8,8 +8,11 @@ type Task = { /** Description of the Task */ description?: string; - // TODO: Make sure this field exists in the API - /** Share destination of the Task */ + /** + * Report ID of the report where the task will be shared + * + * (Note: This variable doesn't exist in the API. It's only used locally for UI purposes) + */ shareDestination?: string; /** The task report if it's currently being edited */ diff --git a/src/types/onyx/TransactionViolation.ts b/src/types/onyx/TransactionViolation.ts index ffbbb23037d0..745c3c260a1f 100644 --- a/src/types/onyx/TransactionViolation.ts +++ b/src/types/onyx/TransactionViolation.ts @@ -30,12 +30,6 @@ type TransactionViolationData = { /** Name of the tag that triggered this violation */ tagName?: string; - // TODO: Doesn't seem to be used in app - categoryLimit?: string; - - // TODO: Doesn't seem to be used in app - limit?: string; - /** Name of the category that triggered this violation */ category?: string; From 2d91475808f042b2c47401f398566d4436e03296 Mon Sep 17 00:00:00 2001 From: Pedro Guerreiro Date: Mon, 27 May 2024 23:34:31 +0100 Subject: [PATCH 11/16] docs: apply suggestions --- src/types/onyx/ReportNextStep.ts | 26 +++++++++++++++++++++++--- 1 file changed, 23 insertions(+), 3 deletions(-) diff --git a/src/types/onyx/ReportNextStep.ts b/src/types/onyx/ReportNextStep.ts index d2c1f2477c56..00943dc1a1f8 100644 --- a/src/types/onyx/ReportNextStep.ts +++ b/src/types/onyx/ReportNextStep.ts @@ -6,24 +6,44 @@ type Message = { /** HTML tag name */ type?: string; - // TODO: Doesn't seem to be used in app + /** Action for the user to take */ action?: string; }; -// TODO: Doesn't seem to be used in app +/** Model of report next step button data */ type DataOptions = { + /** Whether the user should see the option to pay via Expensify (ACH) */ canSeeACHOption?: boolean; + + /** Whether workspace reimbursements is set to Indirect reimbursements */ isManualReimbursementEnabled?: boolean; + + /** + * If there is a masked bank account number from the server, the account needs to be unlocked + * + * (Note: Copied directly from a comment in Old Dot JS) + */ maskedLockedAccountNumber?: string; + + /** Whether the preferred business bank account of the policy is deleted or no longer accessible to the policy reimburser */ preferredWithdrawalDeleted?: boolean; }; -// TODO: Doesn't seem to be used in app +/** Model of report next step button */ type Button = { + /** Text/label shown on the button */ text?: string; + + /** Text to show on a tooltip */ tooltip?: string; + + /** Whether the button should be disabled */ disabled?: boolean; + + /** Whether the button should be hidden */ hidden?: boolean; + + /** Data needed to render the button and handle its click events */ data?: DataOptions; }; From 68ce115af543eed22d87242a2c0dc086da2424e8 Mon Sep 17 00:00:00 2001 From: Pedro Guerreiro Date: Sat, 1 Jun 2024 15:28:26 +0100 Subject: [PATCH 12/16] refactor: apply pull request suggestions --- src/libs/ReportActionsUtils.ts | 2 +- src/libs/ReportUtils.ts | 9 +- src/pages/home/report/ReportActionItem.tsx | 6 +- src/types/onyx/BankAccount.ts | 3 +- src/types/onyx/IOU.ts | 7 +- src/types/onyx/OriginalMessage.ts | 136 +++++---------------- src/types/onyx/Policy.ts | 37 ++++-- src/types/onyx/Report.ts | 9 -- src/types/onyx/ReportAction.ts | 26 +--- src/types/onyx/Transaction.ts | 23 +--- tests/ui/UnreadIndicatorsTest.tsx | 1 - tests/utils/LHNTestUtils.tsx | 24 ---- tests/utils/ReportTestUtils.ts | 5 +- tests/utils/collections/reportActions.ts | 11 -- 14 files changed, 81 insertions(+), 218 deletions(-) diff --git a/src/libs/ReportActionsUtils.ts b/src/libs/ReportActionsUtils.ts index 75d8e22ac975..724412230a57 100644 --- a/src/libs/ReportActionsUtils.ts +++ b/src/libs/ReportActionsUtils.ts @@ -1205,7 +1205,7 @@ function isActionableJoinRequest(reportAction: OnyxEntry): reportA */ function isActionableJoinRequestPending(reportID: string): boolean { const sortedReportActions = getSortedReportActions(Object.values(getAllReportActions(reportID))); - const findPendingRequest = sortedReportActions.find((reportActionItem) => isActionableJoinRequest(reportActionItem) && reportActionItem.originalMessage.choice === ''); + const findPendingRequest = sortedReportActions.find((reportActionItem) => isActionableJoinRequest(reportActionItem) && reportActionItem.originalMessage.choice === '' as ValueOf); return !!findPendingRequest; } diff --git a/src/libs/ReportUtils.ts b/src/libs/ReportUtils.ts index f9068cd6cf45..4ad7db0f6a72 100644 --- a/src/libs/ReportUtils.ts +++ b/src/libs/ReportUtils.ts @@ -43,12 +43,13 @@ import type { IOUMessage, ModifiedExpense, OriginalMessageActionName, + OriginalMessageApproved, OriginalMessageCreated, OriginalMessageDismissedViolation, OriginalMessageReimbursementDequeued, OriginalMessageRenamed, + OriginalMessageSubmitted, PaymentMethodType, - ReimbursementDeQueuedMessage, } from '@src/types/onyx/OriginalMessage'; import type {Status} from '@src/types/onyx/PersonalDetails'; import type {NotificationPreference, Participants, PendingChatMember, Participant as ReportParticipant} from '@src/types/onyx/Report'; @@ -189,12 +190,12 @@ type ReportOfflinePendingActionAndErrors = { }; type OptimisticApprovedReportAction = Pick< - ReportAction, + ReportAction & OriginalMessageApproved, 'actionName' | 'actorAccountID' | 'automatic' | 'avatar' | 'isAttachment' | 'originalMessage' | 'message' | 'person' | 'reportActionID' | 'shouldShow' | 'created' | 'pendingAction' >; type OptimisticSubmittedReportAction = Pick< - ReportAction, + ReportAction & OriginalMessageSubmitted, | 'actionName' | 'actorAccountID' | 'adminAccountID' @@ -2159,7 +2160,7 @@ function getReimbursementDeQueuedActionMessage( report: OnyxEntry | EmptyObject, isLHNPreview = false, ): string { - const originalMessage = reportAction?.originalMessage as ReimbursementDeQueuedMessage | undefined; + const originalMessage = reportAction?.originalMessage; const amount = originalMessage?.amount; const currency = originalMessage?.currency; const formattedAmount = CurrencyUtils.convertToDisplayString(amount, currency); diff --git a/src/pages/home/report/ReportActionItem.tsx b/src/pages/home/report/ReportActionItem.tsx index 4b248bf14131..b45c25d26d53 100644 --- a/src/pages/home/report/ReportActionItem.tsx +++ b/src/pages/home/report/ReportActionItem.tsx @@ -4,6 +4,7 @@ import type {GestureResponderEvent, TextInput} from 'react-native'; import {InteractionManager, View} from 'react-native'; import type {OnyxCollection, OnyxEntry} from 'react-native-onyx'; import {withOnyx} from 'react-native-onyx'; +import type {ValueOf} from 'type-fest'; import type {Emoji} from '@assets/emojis/types'; import {AttachmentContext} from '@components/AttachmentContext'; import Button from '@components/Button'; @@ -393,7 +394,10 @@ function ReportActionItem({ const attachmentContextValue = useMemo(() => ({reportID: report.reportID, type: CONST.ATTACHMENT_TYPE.REPORT}), [report.reportID]); const actionableItemButtons: ActionableItem[] = useMemo(() => { - if (!isActionableWhisper && (!ReportActionsUtils.isActionableJoinRequest(action) || action.originalMessage.choice !== '')) { + if ( + !isActionableWhisper && + (!ReportActionsUtils.isActionableJoinRequest(action) || action.originalMessage.choice !== ('' as ValueOf)) + ) { return []; } diff --git a/src/types/onyx/BankAccount.ts b/src/types/onyx/BankAccount.ts index 34eb15646b2f..a5b96941e172 100644 --- a/src/types/onyx/BankAccount.ts +++ b/src/types/onyx/BankAccount.ts @@ -1,5 +1,6 @@ import type CONST from '@src/CONST'; import type AccountData from './AccountData'; +import type {BankName} from './Bank'; import type * as OnyxCommon from './OnyxCommon'; /** Model of additional bank account data */ @@ -14,7 +15,7 @@ type BankAccountAdditionalData = { currency?: string; /** In which bank is the bank account */ - bankName?: string; + bankName?: BankName; /** Whether the bank account details were obtained for local transfer or international wire */ fieldsType?: string; diff --git a/src/types/onyx/IOU.ts b/src/types/onyx/IOU.ts index 9c04ad59ef3a..068cd6dc5c68 100644 --- a/src/types/onyx/IOU.ts +++ b/src/types/onyx/IOU.ts @@ -1,5 +1,6 @@ import type {ValueOf} from 'type-fest'; import type CONST from '@src/CONST'; +import type {IOUType} from '@src/CONST'; import type {Icon} from './OnyxCommon'; /** Model of IOU participant */ @@ -67,9 +68,11 @@ type Participant = { /** Whether the IOU participant is an invoice sender */ isSender?: boolean; - /** TODO: I think this type could be changes to `IOUType` */ /** The type of IOU report, i.e. split, request, send, track */ - iouType?: string; + iouType?: IOUType; + + /** When the participant is associated with a policy expense chat, this is the account ID of the policy owner */ + ownerAccountID?: number; }; /** Model of IOU split */ diff --git a/src/types/onyx/OriginalMessage.ts b/src/types/onyx/OriginalMessage.ts index 734ffc3cf064..1e7c3cb3e0df 100644 --- a/src/types/onyx/OriginalMessage.ts +++ b/src/types/onyx/OriginalMessage.ts @@ -36,9 +36,16 @@ type OriginalMessageActionName = /** Model of `approved` report action */ type OriginalMessageApproved = { actionName: typeof CONST.REPORT.ACTIONS.TYPE.APPROVED; + originalMessage: { + /** Approved expense amount */ + amount: number; - /** TODO: I think the type should match the scructure of `originalMessage` in `buildOptimisticApprovedReportAction` */ - originalMessage: unknown; + /** Currency of the approved expense amount */ + currency: string; + + /** Report ID of the expense */ + expenseReportID: string; + }; }; /** Types of sources of original message */ @@ -121,9 +128,8 @@ type IOUMessage = { /** Model of original message of `reimbursed dequeued` report action */ type ReimbursementDeQueuedMessage = { - /** TODO: I'd replace this type with `ValueOf` */ /** Why the reimbursement was cancelled */ - cancellationReason: string; + cancellationReason: ValueOf; /** ID of the `expense` report */ expenseReportID?: string; @@ -141,23 +147,6 @@ type OriginalMessageIOU = { originalMessage: IOUMessage; }; -/** Names of severity flags */ -type FlagSeverityName = ValueOf< - Pick< - typeof CONST.MODERATION, - 'FLAG_SEVERITY_SPAM' | 'FLAG_SEVERITY_INCONSIDERATE' | 'FLAG_SEVERITY_INTIMIDATION' | 'FLAG_SEVERITY_BULLYING' | 'FLAG_SEVERITY_HARASSMENT' | 'FLAG_SEVERITY_ASSAULT' - > ->; - -/** Model of severity flag */ -type FlagSeverity = { - /** Account ID of the user that flagged the comment */ - accountID: number; - - /** When was the comment flagged */ - timestamp: string; -}; - /** Names of moderation decisions */ type DecisionName = ValueOf< Pick< @@ -227,26 +216,8 @@ type OriginalMessageAddComment = { /** ID of the task report */ taskReportID?: string; - /** TODO: Doesn't exist in the app */ - edits?: string[]; - - /** TODO: Doesn't exist in the app */ - childReportID?: string; - - /** TODO: Doesn't exist in the app */ - isDeletedParentAction?: boolean; - - /** TODO: Doesn't exist in the app */ - flags?: Record; - - /** TODO: Doesn't exist in the app */ - moderationDecisions?: Decision[]; - - /** TODO: Only used in tests */ + /** Collection of accountIDs of users mentioned in message */ whisperedTo: number[]; - - /** TODO: Doesn't exist in the app */ - reactions?: Reaction[]; }; }; @@ -257,19 +228,10 @@ type OriginalMessageActionableMentionWhisper = { /** Account IDs of users that aren't members of the room */ inviteeAccountIDs: number[]; - /** TODO: Doesn't exist in the app */ - inviteeEmails: string; - - /** TODO: Only used in tests */ - lastModified: string; - - /** TODO: Doesn't exist in the app */ - reportID: number; - /** Decision on whether to invite users that were mentioned but aren't members or do nothing */ resolution?: ValueOf | null; - /** TODO: Doesn't exist in the app */ + /** Collection of accountIDs of users mentioned in message */ whisperedTo?: number[]; }; }; @@ -278,25 +240,10 @@ type OriginalMessageActionableMentionWhisper = { type OriginalMessageActionableReportMentionWhisper = { actionName: typeof CONST.REPORT.ACTIONS.TYPE.ACTIONABLE_REPORT_MENTION_WHISPER; originalMessage: { - /** TODO: Doesn't exist in the app */ - reportNames: string[]; - - /** TODO: Doesn't exist in the app */ - mentionedAccountIDs: number[]; - - /** TODO: Doesn't exist in the app */ - reportActionID: number; - - /** TODO: Doesn't exist in the app */ - reportID: number; - - /** TODO: Only used in tests */ - lastModified: string; - /** Decision on whether to create a report that were mentioned but doesn't exist or do nothing */ resolution?: ValueOf | null; - /** TODO: Doesn't exist in the app */ + /** Collection of accountIDs of users mentioned in message */ whisperedTo?: number[]; }; }; @@ -304,9 +251,16 @@ type OriginalMessageActionableReportMentionWhisper = { /** Model of `submitted` report action */ type OriginalMessageSubmitted = { actionName: typeof CONST.REPORT.ACTIONS.TYPE.SUBMITTED; + originalMessage: { + /** Approved expense amount */ + amount: number; - /** TODO: I think the type should match the scructure of `originalMessage` in `buildOptimisticSubmittedReportAction` */ - originalMessage: unknown; + /** Currency of the approved expense amount */ + currency: string; + + /** Report ID of the expense */ + expenseReportID: string; + }; }; /** Model of `closed` report action */ @@ -349,14 +303,6 @@ type OriginalMessageRenamed = { type ChronosOOOTimestamp = { /** Date timestamp */ date: string; - - /** TODO: Doesn't exist in the app */ - /** Timezone code */ - timezone: string; - - /** TODO: Doesn't exist in the app */ - // eslint-disable-next-line @typescript-eslint/naming-convention - timezone_type: number; }; /** Model of change log */ @@ -412,23 +358,15 @@ type ModifiedExpense = { taxAmount?: number; taxRate?: string; oldTaxRate?: string; + whisperedTo?: number[]; }; /** Model of `Chronos OOO List` report action */ type OriginalMessageChronosOOOList = { actionName: typeof CONST.REPORT.ACTIONS.TYPE.CHRONOS_OOO_LIST; originalMessage: { - /** TODO: Doesn't exist in the app */ - edits: string[]; - /** Collection of OOO events to show in report action */ events: ChronosOOOEvent[]; - - /** TODO: Only used in tests */ - html: string; - - /** TODO: Only used in tests */ - lastModified: string; }; }; @@ -439,9 +377,6 @@ type OriginalMessageReportPreview = { /** ID of the report to be previewed */ linkedReportID: string; - /** TODO: Only used in tests */ - lastModified?: string; - /** Collection of accountIDs of users mentioned in report */ whisperedTo?: number[]; }; @@ -457,20 +392,10 @@ type OriginalMessagePolicyChangeLog = { type OriginalMessageJoinPolicyChangeLog = { actionName: typeof CONST.REPORT.ACTIONS.TYPE.ACTIONABLE_JOIN_REQUEST; originalMessage: { - /** TODO: I think this type could be changed to `ValueOf` */ /** What was the invited user decision */ - choice: string; - - /** TODO: Doesn't exist in the app */ - email: string; - - /** TODO: Doesn't exist in the app */ - inviterEmail: string; + choice: ValueOf; - /** TODO: Only used in tests */ - lastModified: string; - - /** TODO: Doesn't exist in the app */ + /** ID of the affected policy */ policyID: string; }; }; @@ -514,7 +439,7 @@ type OriginalMessageActionableTrackedExpenseWhisper = { /** ID of the transaction */ transactionID: string; - /** TODO: Only used in tests */ + /** When was the tracked expense whisper last modified */ lastModified: string; /** What was the decision of the user */ @@ -525,12 +450,7 @@ type OriginalMessageActionableTrackedExpenseWhisper = { /** Model of `reimbursement dequeued` report action */ type OriginalMessageReimbursementDequeued = { actionName: typeof CONST.REPORT.ACTIONS.TYPE.REIMBURSEMENT_DEQUEUED; - - /** TODO: I think this type should be `ReimbursementDeQueuedMessage` */ - originalMessage: { - /** ID of the expense report */ - expenseReportID: string; - }; + originalMessage: ReimbursementDeQueuedMessage; }; /** Model of `moved` report action */ @@ -610,6 +530,8 @@ export type { OriginalMessageActionName, ChangeLog, ModifiedExpense, + OriginalMessageApproved, + OriginalMessageSubmitted, OriginalMessageIOU, OriginalMessageCreated, OriginalMessageRenamed, diff --git a/src/types/onyx/Policy.ts b/src/types/onyx/Policy.ts index 8659d0d474f5..ebacad3482b7 100644 --- a/src/types/onyx/Policy.ts +++ b/src/types/onyx/Policy.ts @@ -8,8 +8,12 @@ import type {WorkspaceTravelSettings} from './TravelSettings'; /** Distance units */ type Unit = 'mi' | 'km'; +/** TODO: Not enough context */ type TaxRateAttributes = { + /** TODO: Not enough context */ taxClaimablePercentage?: number; + + /** TODO: Not enough context */ taxRateExternalID?: string; }; @@ -35,6 +39,8 @@ type Rate = OnyxCommon.OnyxValueWithOfflineFeedback<{ /** Form fields that triggered the errors */ errorFields?: OnyxCommon.ErrorFields; + + /** TODO: Not enough context */ attributes?: TaxRateAttributes; }>; @@ -42,6 +48,8 @@ type Rate = OnyxCommon.OnyxValueWithOfflineFeedback<{ type Attributes = { /** Distance unit name */ unit: Unit; + + /** TODO: Not enough context */ taxEnabled?: boolean; }; @@ -239,9 +247,8 @@ type TaxCode = { * Data imported from QuickBooks Online. */ type QBOConnectionData = { - /** TODO: I think this value can be changed to `ValueOf` */ /** Country code */ - country: string; + country: ValueOf; /** TODO: Doesn't exist in the app */ edition: string; @@ -373,7 +380,7 @@ type QBOConnectionConfig = OnyxCommon.OnyxValueWithOfflineFeedback<{ /** TODO: Doesn't exist in the app */ errors?: OnyxCommon.Errors; - /** TODO: Doesn't exist in the app */ + /** TODO: Not enough context */ exportDate: ValueOf; /** Configuration of the export */ @@ -407,8 +414,12 @@ type Tenant = { value: string; }; +/** TODO: Not enough context */ type XeroTrackingCategory = { + /** TODO: Not enough context */ id: string; + + /** TODO: Not enough context */ name: string; }; @@ -427,12 +438,17 @@ type XeroConnectionData = { /** TODO: Doesn't exist in the app */ revenueAccounts: Array<{ + /** TODO: Not enough context */ id: string; + + /** TODO: Not enough context */ name: string; }>; /** Collection of organizations */ tenants: Tenant[]; + + /** TODO: Not enough context */ trackingCategories: XeroTrackingCategory[]; }; @@ -455,7 +471,7 @@ type XeroConnectionConfig = OnyxCommon.OnyxValueWithOfflineFeedback<{ jobID: string; }; - /** TODO: Doesn't exist in the app */ + /** TODO: Not enough context */ enableNewCategories: boolean; /** Xero export configs */ @@ -480,7 +496,7 @@ type XeroConnectionConfig = OnyxCommon.OnyxValueWithOfflineFeedback<{ /** TODO: Doesn't exist in the app */ nonReimbursable: ExpenseTypesValues; - /** TODO: Doesn't exist in the app */ + /** TODO: Not enough context */ nonReimbursableAccount: string; /** TODO: Doesn't exist in the app */ @@ -498,7 +514,10 @@ type XeroConnectionConfig = OnyxCommon.OnyxValueWithOfflineFeedback<{ /** TODO: Doesn't exist in the app */ isConfigured: boolean; + + /** TODO: Not enough context */ mappings: XeroMappingType; + sync: { /** TODO: Doesn't exist in the app */ hasChosenAutoSyncOption: boolean; @@ -509,10 +528,10 @@ type XeroConnectionConfig = OnyxCommon.OnyxValueWithOfflineFeedback<{ /** ID of the bank account for Xero invoice collections */ invoiceCollectionsAccountID: string; - /** TODO: Doesn't exist in the app */ + /** ID of the bank account for Xero bill payment account */ reimbursementAccountID: string; - /** TODO: Doesn't exist in the app */ + /** Whether the reimbursed reports should be synched */ syncReimbursedReports: boolean; }; @@ -528,7 +547,6 @@ type XeroConnectionConfig = OnyxCommon.OnyxValueWithOfflineFeedback<{ /** State of integration connection */ type Connection = { - /** TODO: Doesn't exist in the app */ /** State of the last synchronization */ lastSync?: ConnectionLastSync; @@ -604,9 +622,6 @@ type PolicyReportField = { /** Options to select from if field is of type dropdown */ values: string[]; - /** TODO: Doesn't seem to be used in app */ - target: string; - /** Tax UDFs have keys holding the names of taxes (eg, VAT), values holding percentages (eg, 15%) and a value indicating the currently selected tax value (eg, 15%). */ keys: string[]; diff --git a/src/types/onyx/Report.ts b/src/types/onyx/Report.ts index 82b8bb0260c5..3818a6dd6ad1 100644 --- a/src/types/onyx/Report.ts +++ b/src/types/onyx/Report.ts @@ -216,12 +216,6 @@ type Report = OnyxCommon.OnyxValueWithOfflineFeedback< /** Collection of errors to be shown to the user */ errors?: OnyxCommon.Errors; - /** TODO: Doesn't exist in the app */ - managerEmail?: string; - - /** TODO: Doesn't exist in the app */ - parentReportActionIDs?: number[]; - /** Collection of errors that exist in report fields */ errorFields?: OnyxCommon.ErrorFields; @@ -258,9 +252,6 @@ type Report = OnyxCommon.OnyxValueWithOfflineFeedback< /** Text to be displayed in options list, which matches reportName by default */ text?: string; - /** TODO: Doesn't exist in the app */ - updateReportInLHN?: boolean; - /** Collection of participant private notes, indexed by their accountID */ privateNotes?: Record; diff --git a/src/types/onyx/ReportAction.ts b/src/types/onyx/ReportAction.ts index ae319c120f20..dc9bd2f94410 100644 --- a/src/types/onyx/ReportAction.ts +++ b/src/types/onyx/ReportAction.ts @@ -6,7 +6,7 @@ import type ONYXKEYS from '@src/ONYXKEYS'; import type CollectionDataSet from '@src/types/utils/CollectionDataSet'; import type {EmptyObject} from '@src/types/utils/EmptyObject'; import type * as OnyxCommon from './OnyxCommon'; -import type {Decision, OriginalMessageModifiedExpense, OriginalMessageReportPreview, Reaction} from './OriginalMessage'; +import type {Decision, OriginalMessageModifiedExpense, OriginalMessageReportPreview} from './OriginalMessage'; import type OriginalMessage from './OriginalMessage'; import type {NotificationPreference} from './Report'; import type {Receipt} from './Transaction'; @@ -57,12 +57,9 @@ type Message = { /** Whether the pending transaction was reversed and didn't post to the card */ isReversedTransaction?: boolean; - /** TODO: Only used in tests */ + /** Collection of accountIDs of users mentioned in message */ whisperedTo?: number[]; - /** TODO: Only used in tests */ - reactions?: Reaction[]; - /** In situations where moderation is required, this is the moderator decision data */ moderationDecision?: Decision; @@ -174,10 +171,10 @@ type ReportActionBase = OnyxCommon.OnyxValueWithOfflineFeedback<{ /** Avatar data to display on the report action */ avatar?: AvatarSource; - /** TODO: not enough context, seems to be used in tests only */ + /** TODO: not enough context */ automatic?: boolean; - /** TODO: Not enough context, seems to be used in tests only */ + /** TODO: Not enough context */ shouldShow?: boolean; /** The ID of childReport */ @@ -192,13 +189,10 @@ type ReportActionBase = OnyxCommon.OnyxValueWithOfflineFeedback<{ /** The user's ID */ accountID?: number; - /** TODO: Doesn't exist in the app */ - childOldestFourEmails?: string; - /** Account IDs of the oldest four participants, useful to determine which avatars to display in threads */ childOldestFourAccountIDs?: string; - /** TODO: Not enough context, but I think this represents how many participants are in the thread */ + /** How many participants commented in the report */ childCommenterCount?: number; /** Timestamp of the most recent reply */ @@ -219,25 +213,15 @@ type ReportActionBase = OnyxCommon.OnyxValueWithOfflineFeedback<{ /** Report action child status name */ childStateNum?: ValueOf; - /** TODO: Doesn't exist in the app */ - childLastReceiptTransactionIDs?: string; - /** Content of the last money request comment, used in report preview */ childLastMoneyRequestComment?: string; /** Account ID of the last actor */ childLastActorAccountID?: number; - /** TODO: Only used in tests */ - timestamp?: number; - - /** TODO: Only used in tests */ - reportActionTimestamp?: number; - /** Amount of money requests */ childMoneyRequestCount?: number; - /** TODO: Seems to be used only on tests */ isFirstItem?: boolean; /** Informations about attachments of report action */ diff --git a/src/types/onyx/Transaction.ts b/src/types/onyx/Transaction.ts index b3177b3d5d32..bda3f780bc37 100644 --- a/src/types/onyx/Transaction.ts +++ b/src/types/onyx/Transaction.ts @@ -115,13 +115,7 @@ type ReceiptSource = string; /** Model of receipt */ type Receipt = { - /** TODO: This doesn't exist in the app */ - receiptID?: number; - - /** TODO: This doesn't exist in the app */ - path?: string; - - /** TODO: This doesn't exist in the app */ + /** Name of receipt file */ name?: string; /** Path of the receipt file */ @@ -151,9 +145,6 @@ type Routes = Record; /** Model of receipt error */ type ReceiptError = { - /** TODO: This doesn't exist in the app */ - error?: string; - /** Path of the receipt file */ source: string; @@ -166,9 +157,6 @@ type ReceiptErrors = Record; /** Tax rate data */ type TaxRateData = { - /** TODO: This doesn't exist in the app */ - name: string; - /** Tax rate percentage */ value: string; @@ -184,15 +172,6 @@ type TaxRate = { /** Key of the tax rate to index it on options list */ keyForList: string; - /** TODO: This doesn't exist in the app */ - searchText: string; - - /** TODO: This doesn't exist in the app */ - tooltipText: string; - - /** TODO: This doesn't exist in the app */ - isDisabled?: boolean; - /** Data of the tax rate */ data?: TaxRateData; }; diff --git a/tests/ui/UnreadIndicatorsTest.tsx b/tests/ui/UnreadIndicatorsTest.tsx index 0f13062b2e94..7b820281a5a6 100644 --- a/tests/ui/UnreadIndicatorsTest.tsx +++ b/tests/ui/UnreadIndicatorsTest.tsx @@ -607,7 +607,6 @@ describe('Unread Indicators', () => { lastReportAction = reportActions ? CollectionUtils.lastItem(reportActions) : undefined; Onyx.merge(`${ONYXKEYS.COLLECTION.REPORT}${REPORT_ID}`, { lastMessageText: lastReportAction?.message?.[0]?.text, - lastVisibleActionCreated: DateUtils.getDBTime(lastReportAction?.timestamp), lastActorAccountID: lastReportAction?.actorAccountID, reportID: REPORT_ID, }); diff --git a/tests/utils/LHNTestUtils.tsx b/tests/utils/LHNTestUtils.tsx index d35eb61feb35..89c31d92843e 100644 --- a/tests/utils/LHNTestUtils.tsx +++ b/tests/utils/LHNTestUtils.tsx @@ -150,8 +150,6 @@ function getFakeReportAction(actor = 'email1@test.com', millisecondsInThePast = actionName: CONST.REPORT.ACTIONS.TYPE.CREATED, shouldShow: true, created, - timestamp, - reportActionTimestamp: timestamp, person: [ { type: 'TEXT', @@ -168,17 +166,6 @@ function getFakeReportAction(actor = 'email1@test.com', millisecondsInThePast = isEdited: false, whisperedTo: [], isDeletedParentAction: false, - reactions: [ - { - emoji: 'heart', - users: [ - { - accountID: 1, - skinTone: -1, - }, - ], - }, - ], }, ], originalMessage: { @@ -198,17 +185,6 @@ function getFakeReportAction(actor = 'email1@test.com', millisecondsInThePast = }, html: 'hey', lastModified: '2023-08-28 15:28:12.432', - reactions: [ - { - emoji: 'heart', - users: [ - { - accountID: 1, - skinTone: -1, - }, - ], - }, - ], }, }; } diff --git a/tests/utils/ReportTestUtils.ts b/tests/utils/ReportTestUtils.ts index b9dc50aecec0..88fc6fc1bde1 100644 --- a/tests/utils/ReportTestUtils.ts +++ b/tests/utils/ReportTestUtils.ts @@ -19,7 +19,6 @@ const getFakeReportAction = (index: number, actionName?: ActionName): ReportActi html: 'hey', isDeletedParentAction: false, isEdited: false, - reactions: [], text: 'test', type: 'TEXT', whisperedTo: [], @@ -31,6 +30,8 @@ const getFakeReportAction = (index: number, actionName?: ActionName): ReportActi // IOUReportID: index, linkedReportID: index.toString(), whisperedTo: [], + reason: '', + violationName: '', }, pendingAction: null, person: [ @@ -42,10 +43,8 @@ const getFakeReportAction = (index: number, actionName?: ActionName): ReportActi ], reportActionID: index.toString(), previousReportActionID: (index === 0 ? 0 : index - 1).toString(), - reportActionTimestamp: 1696243169753, sequenceNumber: 0, shouldShow: true, - timestamp: 1696243169, } as ReportAction); const getMockedSortedReportActions = (length = 100): ReportAction[] => diff --git a/tests/utils/collections/reportActions.ts b/tests/utils/collections/reportActions.ts index 6dd82c3134ab..dc3e9d8427b5 100644 --- a/tests/utils/collections/reportActions.ts +++ b/tests/utils/collections/reportActions.ts @@ -58,17 +58,6 @@ export default function createRandomReportAction(index: number): ReportAction { isEdited: randBoolean(), isDeletedParentAction: randBoolean(), whisperedTo: randAggregation(), - reactions: [ - { - emoji: randWord(), - users: [ - { - accountID: index, - skinTone: index, - }, - ], - }, - ], }, ], originalMessage: { From 9fe67122d120fc89544d7652d1ddfd089670cd0e Mon Sep 17 00:00:00 2001 From: Pedro Guerreiro Date: Wed, 5 Jun 2024 21:05:06 +0100 Subject: [PATCH 13/16] chore: apply pull request suggestions and address types with missing comments --- src/pages/home/ReportScreen.tsx | 1 + src/pages/home/report/ReportFooter.tsx | 1 + src/types/onyx/OnyxUpdatesFromServer.ts | 6 ++ src/types/onyx/OriginalMessage.ts | 46 +++++++++++++++- src/types/onyx/Report.ts | 2 + src/types/onyx/ReportNameValuePairs.ts | 2 + src/types/onyx/SearchResults.ts | 50 ++++++++++++++++- src/types/onyx/Transaction.ts | 67 +++++++++++++++++++++++ src/types/onyx/TravelSettings.ts | 2 + src/types/onyx/UserMetadata.ts | 8 +++ src/types/onyx/WalletAdditionalDetails.ts | 18 ++++++ 11 files changed, 200 insertions(+), 3 deletions(-) diff --git a/src/pages/home/ReportScreen.tsx b/src/pages/home/ReportScreen.tsx index 5696f0b800f4..976fc626090b 100644 --- a/src/pages/home/ReportScreen.tsx +++ b/src/pages/home/ReportScreen.tsx @@ -66,6 +66,7 @@ type ReportScreenOnyxProps = { /** An array containing all report actions related to this report, sorted based on a date criterion */ sortedAllReportActions: OnyxTypes.ReportAction[]; + /** Additional report details */ reportNameValuePairs: OnyxEntry; /** The report metadata loading states */ diff --git a/src/pages/home/report/ReportFooter.tsx b/src/pages/home/report/ReportFooter.tsx index ac56fe916bc9..7e643c676ac1 100644 --- a/src/pages/home/report/ReportFooter.tsx +++ b/src/pages/home/report/ReportFooter.tsx @@ -40,6 +40,7 @@ type ReportFooterProps = ReportFooterOnyxProps & { /** Report object for the current report */ report?: OnyxTypes.Report; + /** Additional report details */ reportNameValuePairs?: OnyxEntry; /** The last report action */ diff --git a/src/types/onyx/OnyxUpdatesFromServer.ts b/src/types/onyx/OnyxUpdatesFromServer.ts index 525fb34e59cd..99d565ede08f 100644 --- a/src/types/onyx/OnyxUpdatesFromServer.ts +++ b/src/types/onyx/OnyxUpdatesFromServer.ts @@ -42,6 +42,12 @@ type OnyxUpdatesFromServer = { updates?: OnyxUpdateEvent[]; }; +/** + * Helper function to determine if onyx update received from server is valid + * + * @param value - represent the onyx update received from the server + * @returns boolean indicating if the onyx update received from the server is valid + */ function isValidOnyxUpdateFromServer(value: unknown): value is OnyxUpdatesFromServer { if (!value || typeof value !== 'object') { return false; diff --git a/src/types/onyx/OriginalMessage.ts b/src/types/onyx/OriginalMessage.ts index 02cf66554d74..c862c5f43c61 100644 --- a/src/types/onyx/OriginalMessage.ts +++ b/src/types/onyx/OriginalMessage.ts @@ -338,27 +338,65 @@ type ChronosOOOEvent = { /** Model of modified expense */ type ModifiedExpense = { + /** Old content of the comment */ oldComment?: string; + + /** Edited content of the comment */ newComment?: string; - comment?: string; + + /** Edited merchant name */ merchant?: string; + + /** Old creation date timestamp */ oldCreated?: string; + + /** Edited creation date timestamp */ created?: string; + + /** Old merchant name */ oldMerchant?: string; + + /** Old expense amount */ oldAmount?: number; + + /** Edited expense amount */ amount?: number; + + /** Old expense amount currency */ oldCurrency?: string; + + /** Edited expense amount currency */ currency?: string; + + /** Edited expense category */ category?: string; + + /** Old expense category */ oldCategory?: string; + + /** Edited expense tag */ tag?: string; + + /** Old expense tag */ oldTag?: string; + billable?: string; + oldBillable?: string; + + /** Old expense tag amount */ oldTaxAmount?: number; + + /** Edited expense tax amount */ taxAmount?: number; + + /** Edited expense tax rate */ taxRate?: string; + + /** Old expense tax rate */ oldTaxRate?: string; + + /** Collection of accountIDs of users mentioned in expense report */ whisperedTo?: number[]; }; @@ -490,11 +528,17 @@ type OriginalMessageDismissedViolation = { }; }; +/** Model of `trip room preview` report action */ type OriginalMessageTripRoomPreview = { actionName: typeof CONST.REPORT.ACTIONS.TYPE.TRIPPREVIEW; originalMessage: { + /** ID of the report to be previewed */ linkedReportID: string; + + /** When was report action last modified */ lastModified?: string; + + /** Collection of accountIDs of users mentioned in report */ whisperedTo?: number[]; }; }; diff --git a/src/types/onyx/Report.ts b/src/types/onyx/Report.ts index 3818a6dd6ad1..77409c036696 100644 --- a/src/types/onyx/Report.ts +++ b/src/types/onyx/Report.ts @@ -31,6 +31,8 @@ type PendingChatMember = { /** Action to be applied to the pending member of report */ pendingAction: OnyxCommon.PendingAction; + + /** Collection of errors to show to the user */ errors?: OnyxCommon.Errors; }; diff --git a/src/types/onyx/ReportNameValuePairs.ts b/src/types/onyx/ReportNameValuePairs.ts index 1cf56c300f00..7726d07a3074 100644 --- a/src/types/onyx/ReportNameValuePairs.ts +++ b/src/types/onyx/ReportNameValuePairs.ts @@ -1,6 +1,8 @@ import type * as OnyxCommon from './OnyxCommon'; +/** Model of additional report details */ type ReportNameValuePairs = OnyxCommon.OnyxValueWithOfflineFeedback<{ + /** Whether the report is an archived room */ isArchived: boolean; }>; diff --git a/src/types/onyx/SearchResults.ts b/src/types/onyx/SearchResults.ts index c7d63e95fd3d..76b10626ada2 100644 --- a/src/types/onyx/SearchResults.ts +++ b/src/types/onyx/SearchResults.ts @@ -5,48 +5,80 @@ import type {ReportListItemType, TransactionListItemType} from '@components/Sele import type {SearchColumnType, SortOrder} from '@libs/SearchUtils'; import type CONST from '@src/CONST'; +/** Types of search data */ type SearchDataTypes = ValueOf; +/** Model of search result list item */ type ListItemType = T extends typeof CONST.SEARCH_DATA_TYPES.TRANSACTION ? typeof TransactionListItem : T extends typeof CONST.SEARCH_DATA_TYPES.REPORT ? typeof ReportListItem : never; +/** Model of search result section */ type SectionsType = T extends typeof CONST.SEARCH_DATA_TYPES.TRANSACTION ? TransactionListItemType[] : T extends typeof CONST.SEARCH_DATA_TYPES.REPORT ? ReportListItemType[] : never; +/** Mapping of search results to list item */ type SearchTypeToItemMap = { [K in SearchDataTypes]: { + /** Collection of search result list item */ listItem: ListItemType; + + /** Returns search results sections based on search results data */ getSections: (data: SearchResults['data']) => SectionsType; + + /** Returns sorted search results sections based on search results data */ getSortedSections: (data: SectionsType, sortBy?: SearchColumnType, sortOrder?: SortOrder) => SectionsType; }; }; +/** Model of search result state */ type SearchResultsInfo = { + /** Current search results offset/cursor */ offset: number; + + /** Type of search */ type: string; + + /** Whether the user can fetch more search results */ hasMoreResults: boolean; + + /** Whether the search results are currently loading */ isLoading: boolean; }; +/** Model of personal details search result */ type SearchPersonalDetails = { + /** ID of user account */ accountID: number; + + /** User's avatar URL */ avatar: string; + + /** User's display name */ displayName?: string; + + /** User's email */ login?: string; }; +/** Model of policy details search result */ type SearchPolicyDetails = { + /** ID of the policy */ id: string; + + /** Policy avatar URL */ avatarURL: string; + + /** Policy name */ name: string; }; +/** Model of report search result */ type SearchReport = { /** The ID of the report */ reportID?: string; @@ -67,6 +99,7 @@ type SearchReport = { action?: string; }; +/** Model of transaction search result */ type SearchTransaction = { /** The ID of the transaction */ transactionID: string; @@ -96,13 +129,19 @@ type SearchTransaction = { modifiedMerchant: string; /** The receipt object */ - receipt?: {source?: string}; + receipt?: { + /** Source of the receipt */ + source?: string; + }; /** The transaction tag */ tag: string; /** The transaction description */ - comment: {comment: string}; + comment: { + /** Content of the transaction description */ + comment: string; + }; /** The transaction category */ category: string; @@ -153,14 +192,21 @@ type SearchTransaction = { modifiedMCCGroup?: ValueOf; }; +/** Model of account details search result */ type SearchAccountDetails = Partial; +/** Types of searchable transactions */ type SearchTransactionType = ValueOf; +/** Types of search queries */ type SearchQuery = ValueOf; +/** Model of search results */ type SearchResults = { + /** Current search results state */ search: SearchResultsInfo; + + /** Search results data */ data: Record> & Record & Record; }; diff --git a/src/types/onyx/Transaction.ts b/src/types/onyx/Transaction.ts index 33f9c30e5287..d9cadfb5e230 100644 --- a/src/types/onyx/Transaction.ts +++ b/src/types/onyx/Transaction.ts @@ -129,6 +129,8 @@ type Receipt = { /** Type of the receipt file */ type?: string; + + /** Collection of reservations */ reservationList?: Reservation[]; }; @@ -177,49 +179,114 @@ type TaxRate = { data?: TaxRateData; }; +/** Model of reservation */ type Reservation = { + /** ID of the reservation */ reservationID?: string; + + /** Details about the start of the reservation */ start: ReservationTimeDetails; + + /** Details about the end of the reservation */ end: ReservationTimeDetails; + + /** Type of reservation */ type: ReservationType; + + /** In flight reservations, this represents the details of the airline company */ company?: Company; + + /** TODO: To be confirmed */ + /** Collection of passenger confirmations */ confirmations?: ReservationConfirmation[]; + + /** TODO: To be confirmed */ + /** In flight and car reservations, this represents the number of passengers */ numPassengers?: number; + + /** In hotel reservations, this represents the number of rooms reserved */ numberOfRooms?: number; + + /** In flight reservations, this represents the details of the route */ route?: { + /** Route airline code */ airlineCode: string; + + /** TODO: To be confirmed */ + /** Passenger class */ class?: string; + + /** TODO: To be confirmed */ + /** Passenger seat number */ number: string; }; + + /** TODO: To be confirmed */ + /** In car reservations, this represents the car dealership name */ vendor?: string; + + /** In car reservations, this represents the details of the car */ carInfo?: CarInfo; }; +/** Model of trip reservation time details */ type ReservationTimeDetails = { + /** Date timestamp */ date: string; + + /** In hotel reservations, this is the address of the hotel */ address?: string; + + /** TODO: To be confirmed */ + /** In car reservations, this is the location of the car dealership */ location?: string; + + /** In flight reservations, this is the long name of the airport */ longName?: string; + + /** In flight reservations, this is the short name of the airport */ shortName?: string; + + /** Timezone offset */ timezoneOffset?: string; }; +/** Model of airline company details */ type Company = { + /** Long name of airline company */ longName: string; + + /** Short name of airline company */ shortName?: string; + + /** TODO: To be confirmed */ + /** Phone number of airline company support */ phone?: string; }; +/** Model of reservation confirmation */ type ReservationConfirmation = { + /** TODO: To be confirmed */ + /** Passenger name */ name: string; + + /** TODO: To be confirmed */ + /** Reservation code */ value: string; }; +/** Model of car details */ type CarInfo = { + /** TODO: To be confirmed */ + /** Name of the car */ name?: string; + + /** TODO: To be confirmed */ + /** Engine type */ engine?: string; }; +/** Types of reservations */ type ReservationType = ValueOf; /** Participant split data */ diff --git a/src/types/onyx/TravelSettings.ts b/src/types/onyx/TravelSettings.ts index e653c3378572..2e838ac2d008 100644 --- a/src/types/onyx/TravelSettings.ts +++ b/src/types/onyx/TravelSettings.ts @@ -1,3 +1,4 @@ +/** Model of user travel information to connect with Spotnana */ type TravelSettings = { /** UUIDs that spotnana provides us with when we provision users in their system, and the spotnanaCompanyIDs as the values */ accountIDs: Record; @@ -6,6 +7,7 @@ type TravelSettings = { hasAcceptedTerms: boolean; }; +/** Model of workspace travel information to connect with Spotnana */ type WorkspaceTravelSettings = { /** The UUID that spotnana provides us when we create a “company” in their system */ spotnanaCompanyID: string; diff --git a/src/types/onyx/UserMetadata.ts b/src/types/onyx/UserMetadata.ts index fc6490264087..642fd035225b 100644 --- a/src/types/onyx/UserMetadata.ts +++ b/src/types/onyx/UserMetadata.ts @@ -1,7 +1,15 @@ +/** Model of user metadata */ type UserMetadata = { + /** Type of user plan */ planType?: string; + + /** Type of user role */ role?: string; + + /** Whether the user is on a free trial */ freeTrial?: boolean; + + /** User's account ID */ accountID?: number; }; diff --git a/src/types/onyx/WalletAdditionalDetails.ts b/src/types/onyx/WalletAdditionalDetails.ts index c92fd14390b5..b53fb5ad8bf6 100644 --- a/src/types/onyx/WalletAdditionalDetails.ts +++ b/src/types/onyx/WalletAdditionalDetails.ts @@ -12,15 +12,33 @@ type WalletAdditionalQuestionDetails = { answer: string[]; }; +/** Model of wallet personal details */ type WalletPersonalDetails = { + /** Legal first name */ legalFirstName: string; + + /** Legal last name */ legalLastName: string; + + /** Date of birth */ dob: string; + + /** Social Security Number (SSN) */ ssn: string; + + /** Street address */ addressStreet: string; + + /** City */ addressCity: string; + + /** State */ addressState: string; + + /** ZIP code */ addressZipCode: string; + + /** Phone number */ phoneNumber: string; }; From 6dabcc01b1d479763caeb7379bebe3ce327cc8e3 Mon Sep 17 00:00:00 2001 From: Pedro Guerreiro Date: Thu, 6 Jun 2024 15:53:02 +0100 Subject: [PATCH 14/16] chore: enable eslint rule that requires comments on onyx types and their properties --- .eslintrc.js | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/.eslintrc.js b/.eslintrc.js index 135252825dcf..ed6f162ad8d4 100644 --- a/.eslintrc.js +++ b/.eslintrc.js @@ -235,8 +235,21 @@ module.exports = { ], }, - // Remove once no JS files are left overrides: [ + // Enforces every Onyx type and its properties to have a comment explaining its purpose. + { + files: ['src/types/onyx/**/*.ts'], + rules: { + 'jsdoc/require-jsdoc': [ + 'error', + { + contexts: ['TSInterfaceDeclaration', 'TSTypeAliasDeclaration', 'TSPropertySignature'], + }, + ], + }, + }, + + // Remove once no JS files are left { files: ['*.js', '*.jsx'], rules: { From 453343e5cac98e1866dc8b8c8f54dd48541b24fa Mon Sep 17 00:00:00 2001 From: Pedro Guerreiro Date: Fri, 7 Jun 2024 12:32:56 +0100 Subject: [PATCH 15/16] refactor: apply pull request suggestions --- src/libs/ReportActionsUtils.ts | 5 +- src/pages/home/report/ReportActionItem.tsx | 6 +- src/types/onyx/OriginalMessage.ts | 91 +++++++++++++++++++++- 3 files changed, 95 insertions(+), 7 deletions(-) diff --git a/src/libs/ReportActionsUtils.ts b/src/libs/ReportActionsUtils.ts index de6a0f863ed6..ac0ee9e9025e 100644 --- a/src/libs/ReportActionsUtils.ts +++ b/src/libs/ReportActionsUtils.ts @@ -11,6 +11,7 @@ import type { ActionName, ChangeLog, IOUMessage, + JoinWorkspaceResolution, OriginalMessageActionableMentionWhisper, OriginalMessageActionableReportMentionWhisper, OriginalMessageActionableTrackedExpenseWhisper, @@ -1205,7 +1206,9 @@ function isActionableJoinRequest(reportAction: OnyxEntry): reportA */ function isActionableJoinRequestPending(reportID: string): boolean { const sortedReportActions = getSortedReportActions(Object.values(getAllReportActions(reportID))); - const findPendingRequest = sortedReportActions.find((reportActionItem) => isActionableJoinRequest(reportActionItem) && reportActionItem.originalMessage.choice === '' as ValueOf); + const findPendingRequest = sortedReportActions.find( + (reportActionItem) => isActionableJoinRequest(reportActionItem) && reportActionItem.originalMessage.choice === ('' as JoinWorkspaceResolution), + ); return !!findPendingRequest; } diff --git a/src/pages/home/report/ReportActionItem.tsx b/src/pages/home/report/ReportActionItem.tsx index 0fe5553fba65..2e7f8a42905d 100644 --- a/src/pages/home/report/ReportActionItem.tsx +++ b/src/pages/home/report/ReportActionItem.tsx @@ -68,6 +68,7 @@ import ONYXKEYS from '@src/ONYXKEYS'; import ROUTES from '@src/ROUTES'; import type * as OnyxTypes from '@src/types/onyx'; import type {Errors} from '@src/types/onyx/OnyxCommon'; +import type {JoinWorkspaceResolution} from '@src/types/onyx/OriginalMessage'; import {isEmptyObject} from '@src/types/utils/EmptyObject'; import AnimatedEmptyStateBackground from './AnimatedEmptyStateBackground'; import {RestrictedReadOnlyContextMenuActions} from './ContextMenu/ContextMenuActions'; @@ -399,10 +400,7 @@ function ReportActionItem({ const attachmentContextValue = useMemo(() => ({reportID: report.reportID, type: CONST.ATTACHMENT_TYPE.REPORT}), [report.reportID]); const actionableItemButtons: ActionableItem[] = useMemo(() => { - if ( - !isActionableWhisper && - (!ReportActionsUtils.isActionableJoinRequest(action) || action.originalMessage.choice !== ('' as ValueOf)) - ) { + if (!isActionableWhisper && (!ReportActionsUtils.isActionableJoinRequest(action) || action.originalMessage.choice !== ('' as JoinWorkspaceResolution))) { return []; } diff --git a/src/types/onyx/OriginalMessage.ts b/src/types/onyx/OriginalMessage.ts index c862c5f43c61..8f645a411520 100644 --- a/src/types/onyx/OriginalMessage.ts +++ b/src/types/onyx/OriginalMessage.ts @@ -2,6 +2,9 @@ import type {ValueOf} from 'type-fest'; import type CONST from '@src/CONST'; import type DeepValueOf from '@src/types/utils/DeepValueOf'; +/** Types of join workspace resolutions */ +type JoinWorkspaceResolution = ValueOf; + /** Types of payments methods */ type PaymentMethodType = DeepValueOf; @@ -36,7 +39,10 @@ type OriginalMessageActionName = /** Model of `approved` report action */ type OriginalMessageApproved = { + /** Approved */ actionName: typeof CONST.REPORT.ACTIONS.TYPE.APPROVED; + + /** Content of the original message */ originalMessage: { /** Approved expense amount */ amount: number; @@ -54,19 +60,28 @@ type OriginalMessageSource = 'Chronos' | 'email' | 'ios' | 'android' | 'web' | ' /** Model of `hold` report action */ type OriginalMessageHold = { + /** Hold */ actionName: typeof CONST.REPORT.ACTIONS.TYPE.HOLD; + + /** Content of the original message */ originalMessage: unknown; }; /** Model of `hold comment` report action */ type OriginalMessageHoldComment = { + /** Hold comment */ actionName: typeof CONST.REPORT.ACTIONS.TYPE.HOLD_COMMENT; + + /** Content of the original message */ originalMessage: unknown; }; /** Model of `unhold` report action */ type OriginalMessageUnHold = { + /** Unhold */ actionName: typeof CONST.REPORT.ACTIONS.TYPE.UNHOLD; + + /** Content of the original message */ originalMessage: unknown; }; @@ -144,7 +159,10 @@ type ReimbursementDeQueuedMessage = { /** Model of `IOU` report action */ type OriginalMessageIOU = { + /** IOU */ actionName: typeof CONST.REPORT.ACTIONS.TYPE.IOU; + + /** Content of the original message */ originalMessage: IOUMessage; }; @@ -203,7 +221,10 @@ type Closed = { /** Model of `add comment` report action */ type OriginalMessageAddComment = { + /** Add comment */ actionName: typeof CONST.REPORT.ACTIONS.TYPE.ADD_COMMENT; + + /** Content of the original message */ originalMessage: { /** HTML content of the comment */ html: string; @@ -224,7 +245,10 @@ type OriginalMessageAddComment = { /** Model of `actionable mention whisper` report action */ type OriginalMessageActionableMentionWhisper = { + /** Actionable mention whisper */ actionName: typeof CONST.REPORT.ACTIONS.TYPE.ACTIONABLE_MENTION_WHISPER; + + /** Content of the original message */ originalMessage: { /** Account IDs of users that aren't members of the room */ inviteeAccountIDs: number[]; @@ -239,7 +263,10 @@ type OriginalMessageActionableMentionWhisper = { /** Model of `actionable report mention whisper` report action */ type OriginalMessageActionableReportMentionWhisper = { + /** Actionable report mention whisper */ actionName: typeof CONST.REPORT.ACTIONS.TYPE.ACTIONABLE_REPORT_MENTION_WHISPER; + + /** Content of the original message */ originalMessage: { /** Decision on whether to create a report that were mentioned but doesn't exist or do nothing */ resolution?: ValueOf | null; @@ -251,7 +278,10 @@ type OriginalMessageActionableReportMentionWhisper = { /** Model of `submitted` report action */ type OriginalMessageSubmitted = { + /** Submitted */ actionName: typeof CONST.REPORT.ACTIONS.TYPE.SUBMITTED; + + /** Content of the original message */ originalMessage: { /** Approved expense amount */ amount: number; @@ -266,25 +296,37 @@ type OriginalMessageSubmitted = { /** Model of `closed` report action */ type OriginalMessageClosed = { + /** Closed */ actionName: typeof CONST.REPORT.ACTIONS.TYPE.CLOSED; + + /** Content of the original message */ originalMessage: Closed; }; /** Model of `created` report action */ type OriginalMessageCreated = { + /** Created */ actionName: typeof CONST.REPORT.ACTIONS.TYPE.CREATED; + + /** Content of the original message */ originalMessage?: unknown; }; /** Model of `marked reimbursed` report action */ type OriginalMessageMarkedReimbursed = { + /** Marked reimbursed */ actionName: typeof CONST.REPORT.ACTIONS.TYPE.MARKED_REIMBURSED; + + /** Content of the original message */ originalMessage?: unknown; }; /** Model of `renamed` report action, created when chat rooms get renamed */ type OriginalMessageRenamed = { + /** Renamed */ actionName: typeof CONST.REPORT.ACTIONS.TYPE.RENAMED; + + /** Content of the original message */ originalMessage: { /** Renamed room comment */ html: string; @@ -380,8 +422,10 @@ type ModifiedExpense = { /** Old expense tag */ oldTag?: string; + /** Edited billable */ billable?: string; + /** Old billable */ oldBillable?: string; /** Old expense tag amount */ @@ -402,7 +446,10 @@ type ModifiedExpense = { /** Model of `Chronos OOO List` report action */ type OriginalMessageChronosOOOList = { + /** Chronos OOO list */ actionName: typeof CONST.REPORT.ACTIONS.TYPE.CHRONOS_OOO_LIST; + + /** Content of the original message */ originalMessage: { /** Collection of OOO events to show in report action */ events: ChronosOOOEvent[]; @@ -411,7 +458,10 @@ type OriginalMessageChronosOOOList = { /** Model of `report preview` report action */ type OriginalMessageReportPreview = { + /** Report preview */ actionName: typeof CONST.REPORT.ACTIONS.TYPE.REPORT_PREVIEW; + + /** Content of the original message */ originalMessage: { /** ID of the report to be previewed */ linkedReportID: string; @@ -423,16 +473,22 @@ type OriginalMessageReportPreview = { /** Model of `policy change log` report action */ type OriginalMessagePolicyChangeLog = { + /** Policy change log */ actionName: ValueOf; + + /** Content of the original message */ originalMessage: ChangeLog; }; -/** Model of `join policy change log` report action */ +/** Model of `join policy changelog` report action */ type OriginalMessageJoinPolicyChangeLog = { + /** Actionable join request */ actionName: typeof CONST.REPORT.ACTIONS.TYPE.ACTIONABLE_JOIN_REQUEST; + + /** Content of the original message */ originalMessage: { /** What was the invited user decision */ - choice: ValueOf; + choice: JoinWorkspaceResolution; /** ID of the affected policy */ policyID: string; @@ -441,30 +497,42 @@ type OriginalMessageJoinPolicyChangeLog = { /** Model of `room change log` report action */ type OriginalMessageRoomChangeLog = { + /** Room change log */ actionName: ValueOf; + + /** Content of the original message */ originalMessage: ChangeLog; }; /** Model of `policy task` report action */ type OriginalMessagePolicyTask = { + /** Policy task */ actionName: | typeof CONST.REPORT.ACTIONS.TYPE.TASK_EDITED | typeof CONST.REPORT.ACTIONS.TYPE.TASK_CANCELLED | typeof CONST.REPORT.ACTIONS.TYPE.TASK_COMPLETED | typeof CONST.REPORT.ACTIONS.TYPE.TASK_REOPENED | typeof CONST.REPORT.ACTIONS.TYPE.MODIFIED_EXPENSE; + + /** Content of the original message */ originalMessage: unknown; }; /** Model of `modified expense` report action */ type OriginalMessageModifiedExpense = { + /** Modified expense */ actionName: typeof CONST.REPORT.ACTIONS.TYPE.MODIFIED_EXPENSE; + + /** Content of the original message */ originalMessage: ModifiedExpense; }; /** Model of `reimbursement queued` report action */ type OriginalMessageReimbursementQueued = { + /** Reimbursement queued */ actionName: typeof CONST.REPORT.ACTIONS.TYPE.REIMBURSEMENT_QUEUED; + + /** Content of the original message */ originalMessage: { /** How is the payment getting reimbursed */ paymentType: DeepValueOf; @@ -473,7 +541,10 @@ type OriginalMessageReimbursementQueued = { /** Model of `actionable tracked expense whisper` report action */ type OriginalMessageActionableTrackedExpenseWhisper = { + /** Actionable track expense whisper */ actionName: typeof CONST.REPORT.ACTIONS.TYPE.ACTIONABLE_TRACK_EXPENSE_WHISPER; + + /** Content of the original message */ originalMessage: { /** ID of the transaction */ transactionID: string; @@ -488,13 +559,19 @@ type OriginalMessageActionableTrackedExpenseWhisper = { /** Model of `reimbursement dequeued` report action */ type OriginalMessageReimbursementDequeued = { + /** Reimbursement dequeued */ actionName: typeof CONST.REPORT.ACTIONS.TYPE.REIMBURSEMENT_DEQUEUED; + + /** Content of the original message */ originalMessage: ReimbursementDeQueuedMessage; }; /** Model of `moved` report action */ type OriginalMessageMoved = { + /** Moved */ actionName: typeof CONST.REPORT.ACTIONS.TYPE.MOVED; + + /** Content of the original message */ originalMessage: { /** ID of the old policy */ fromPolicyID: string; @@ -512,13 +589,19 @@ type OriginalMessageMoved = { /** Model of `merged with cash transaction` report action */ type OriginalMessageMergedWithCashTransaction = { + /** Merged with cash transaction */ actionName: typeof CONST.REPORT.ACTIONS.TYPE.MERGED_WITH_CASH_TRANSACTION; + + /** Content of the original message */ originalMessage: Record; // No data is sent with this action }; /** Model of `dismissed violation` report action */ type OriginalMessageDismissedViolation = { + /** Dismissed violation */ actionName: typeof CONST.REPORT.ACTIONS.TYPE.DISMISSED_VIOLATION; + + /** Content of the original message */ originalMessage: { /** Why the violation was dismissed */ reason: string; @@ -530,7 +613,10 @@ type OriginalMessageDismissedViolation = { /** Model of `trip room preview` report action */ type OriginalMessageTripRoomPreview = { + /** Trip Room Preview */ actionName: typeof CONST.REPORT.ACTIONS.TYPE.TRIPPREVIEW; + + /** Content of the original message */ originalMessage: { /** ID of the report to be previewed */ linkedReportID: string; @@ -575,6 +661,7 @@ type OriginalMessage = export default OriginalMessage; export type { + JoinWorkspaceResolution, ChronosOOOEvent, Decision, Reaction, From a354239de1f638eb3eb848ef28a23fc57238970f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?F=C3=A1bio=20Henriques?= Date: Fri, 7 Jun 2024 18:03:08 +0100 Subject: [PATCH 16/16] Fix lint errors and improve comments --- src/pages/home/report/ReportActionItem.tsx | 1 - src/types/onyx/BankAccount.ts | 2 +- src/types/onyx/Policy.ts | 167 +++++++++++++-------- src/types/onyx/PrivateSubscription.ts | 1 + src/types/onyx/ReportAction.ts | 3 +- src/types/onyx/ReportNextStep.ts | 2 +- src/types/onyx/Task.ts | 4 +- src/types/onyx/Transaction.ts | 13 +- src/types/onyx/WalletAdditionalDetails.ts | 2 +- 9 files changed, 117 insertions(+), 78 deletions(-) diff --git a/src/pages/home/report/ReportActionItem.tsx b/src/pages/home/report/ReportActionItem.tsx index 7ee538fc6b9b..b9abd96583b4 100644 --- a/src/pages/home/report/ReportActionItem.tsx +++ b/src/pages/home/report/ReportActionItem.tsx @@ -4,7 +4,6 @@ import type {GestureResponderEvent, TextInput} from 'react-native'; import {InteractionManager, View} from 'react-native'; import type {OnyxCollection, OnyxEntry} from 'react-native-onyx'; import {withOnyx} from 'react-native-onyx'; -import type {ValueOf} from 'type-fest'; import type {Emoji} from '@assets/emojis/types'; import {AttachmentContext} from '@components/AttachmentContext'; import Button from '@components/Button'; diff --git a/src/types/onyx/BankAccount.ts b/src/types/onyx/BankAccount.ts index a5b96941e172..862b5aa45a4e 100644 --- a/src/types/onyx/BankAccount.ts +++ b/src/types/onyx/BankAccount.ts @@ -35,7 +35,7 @@ type BankAccount = OnyxCommon.OnyxValueWithOfflineFeedback<{ /** Determines if the bank account is a default payment method */ isDefault?: boolean; - /* Determines if the bank account is a savings account */ + /** Determines if the bank account is a savings account */ isSavings?: boolean; /** Date when the 3 micro amounts for validation were supposed to reach the bank account */ diff --git a/src/types/onyx/Policy.ts b/src/types/onyx/Policy.ts index 4c6e8bc62caf..079a01d82c89 100644 --- a/src/types/onyx/Policy.ts +++ b/src/types/onyx/Policy.ts @@ -8,12 +8,12 @@ import type {WorkspaceTravelSettings} from './TravelSettings'; /** Distance units */ type Unit = 'mi' | 'km'; -/** TODO: Not enough context */ +/** Tax rate attributes of the policy distance rate */ type TaxRateAttributes = { - /** TODO: Not enough context */ + /** Percentage of the tax that can be reclaimable */ taxClaimablePercentage?: number; - /** TODO: Not enough context */ + /** External ID associated to this tax rate */ taxRateExternalID?: string; }; @@ -40,7 +40,7 @@ type Rate = OnyxCommon.OnyxValueWithOfflineFeedback<{ /** Form fields that triggered the errors */ errorFields?: OnyxCommon.ErrorFields; - /** TODO: Not enough context */ + /** Tax rate attributes of the policy */ attributes?: TaxRateAttributes; }>; @@ -49,7 +49,7 @@ type Attributes = { /** Distance unit name */ unit: Unit; - /** TODO: Not enough context */ + /** Whether the tax tracking is enabled or not */ taxEnabled?: boolean; }; @@ -191,7 +191,11 @@ type Account = { id: string; }; -/** Model of QuickBooks Online employee data */ +/** + * Model of QuickBooks Online employee data + * + * TODO: QBO remaining comments will be handled here (https://github.com/Expensify/App/issues/43033) + */ type Employee = { /** ID assigned to the employee */ id: string; @@ -209,7 +213,11 @@ type Employee = { email: string; }; -/** Model of QuickBooks Online vendor data */ +/** + * Model of QuickBooks Online vendor data + * + * TODO: QBO remaining comments will be handled here (https://github.com/Expensify/App/issues/43033) + */ type Vendor = { /** ID assigned to the vendor */ id: string; @@ -224,39 +232,45 @@ type Vendor = { email: string; }; -/** Model of QuickBooks Online tax code data */ +/** + * Model of QuickBooks Online tax code data + * + * TODO: QBO remaining comments will be handled here (https://github.com/Expensify/App/issues/43033) + */ type TaxCode = { - /** TODO: Not used in app */ + /** TODO: Will be handled in another issue */ totalTaxRateVal: string; - /** TODO: Not used in app */ + /** TODO: Will be handled in another issue */ simpleName: string; - /** TODO: Not used in app */ + /** TODO: Will be handled in another issue */ taxCodeRef: string; - /** TODO: Not used in app */ + /** TODO: Will be handled in another issue */ taxRateRefs: Record; - /** TODO: Not used in app */ + /** TODO: Will be handled in another issue */ /** Name of the tax code */ name: string; }; /** * Data imported from QuickBooks Online. + * + * TODO: QBO remaining comments will be handled here (https://github.com/Expensify/App/issues/43033) */ type QBOConnectionData = { /** Country code */ country: ValueOf; - /** TODO: Doesn't exist in the app */ + /** TODO: Will be handled in another issue */ edition: string; - /** TODO: Doesn't exist in the app */ + /** TODO: Will be handled in another issue */ homeCurrency: string; - /** TODO: Doesn't exist in the app */ + /** TODO: Will be handled in another issue */ isMultiCurrencyEnabled: boolean; /** Collection of journal entry accounts */ @@ -271,16 +285,16 @@ type QBOConnectionData = { /** Collection of export destination accounts */ accountsReceivable: Account[]; - /** TODO: Not enough context */ + /** TODO: Will be handled in another issue */ accountPayable: Account[]; - /** TODO: Not enough context */ + /** TODO: Will be handled in another issue */ otherCurrentAssetAccounts: Account[]; - /** TODO: Doesn't exist in the app */ + /** TODO: Will be handled in another issue */ taxCodes: TaxCode[]; - /** TODO: Doesn't exist in the app */ + /** TODO: Will be handled in another issue */ employees: Employee[]; /** Collections of vendors */ @@ -290,27 +304,35 @@ type QBOConnectionData = { /** Sync entity names */ type IntegrationEntityMap = (typeof CONST.INTEGRATION_ENTITY_MAP_TYPES)[keyof typeof CONST.INTEGRATION_ENTITY_MAP_TYPES]; -/** Non reimbursable account types exported from QuickBooks Online */ +/** + * Non reimbursable account types exported from QuickBooks Online + * + * TODO: QBO remaining comments will be handled here (https://github.com/Expensify/App/issues/43033) + */ type QBONonReimbursableExportAccountType = (typeof CONST.QUICKBOOKS_NON_REIMBURSABLE_EXPORT_ACCOUNT_TYPE)[keyof typeof CONST.QUICKBOOKS_NON_REIMBURSABLE_EXPORT_ACCOUNT_TYPE]; -/** Reimbursable account types exported from QuickBooks Online */ +/** + * Reimbursable account types exported from QuickBooks Online + * + * TODO: QBO remaining comments will be handled here (https://github.com/Expensify/App/issues/43033) + */ type QBOReimbursableExportAccountType = (typeof CONST.QUICKBOOKS_REIMBURSABLE_ACCOUNT_TYPE)[keyof typeof CONST.QUICKBOOKS_REIMBURSABLE_ACCOUNT_TYPE]; /** * User configuration for the QuickBooks Online accounting integration. + * + * TODO: QBO remaining comments will be handled here (https://github.com/Expensify/App/issues/43033) */ type QBOConnectionConfig = OnyxCommon.OnyxValueWithOfflineFeedback<{ - /** TODO: Doesn't exist in the app */ - /** ID of the QuickBooks Online realm */ + /** TODO: Will be handled in another issue */ realmId: string; - /** TODO: Doesn't exist in the app */ - /** Company name */ + /** TODO: Will be handled in another issue */ companyName: string; /** Configuration of automatic synchronization from QuickBooks Online to the app */ autoSync: { - /** TODO: Doesn't exist in the app */ + /** TODO: Will be handled in another issue */ jobID: string; /** Whether changes made in QuickBooks Online should be reflected into the app automatically */ @@ -320,10 +342,10 @@ type QBOConnectionConfig = OnyxCommon.OnyxValueWithOfflineFeedback<{ /** Whether employees can be invited */ syncPeople: boolean; - /** TODO: Doesn't exist in the app */ + /** TODO: Will be handled in another issue */ syncItems: boolean; - /** TODO: Doesn't exist in the app */ + /** TODO: Will be handled in another issue */ markChecksToBePrinted: boolean; /** Defines how reimbursable expenses are exported */ @@ -356,7 +378,7 @@ type QBOConnectionConfig = OnyxCommon.OnyxValueWithOfflineFeedback<{ */ autoCreateVendor: boolean; - /** TODO: Doesn't exist in the app */ + /** TODO: Will be handled in another issue */ hasChosenAutoSyncOption: boolean; /** Whether Quickbooks Online classes should be imported */ @@ -368,7 +390,7 @@ type QBOConnectionConfig = OnyxCommon.OnyxValueWithOfflineFeedback<{ /** Whether Quickbooks Online locations should be imported */ syncLocations: IntegrationEntityMap; - /** TODO: Doesn't exist in the app */ + /** TODO: Will be handled in another issue */ lastConfigurationTime: number; /** Whether the taxes should be synchronized */ @@ -377,10 +399,10 @@ type QBOConnectionConfig = OnyxCommon.OnyxValueWithOfflineFeedback<{ /** Whether new categories are enabled in chart of accounts */ enableNewCategories: boolean; - /** TODO: Doesn't exist in the app */ + /** TODO: Will be handled in another issue */ errors?: OnyxCommon.Errors; - /** TODO: Not enough context */ + /** TODO: Will be handled in another issue */ exportDate: ValueOf; /** Configuration of the export */ @@ -393,16 +415,29 @@ type QBOConnectionConfig = OnyxCommon.OnyxValueWithOfflineFeedback<{ errorFields?: OnyxCommon.ErrorFields; }>; -/** Xero bill status values */ +/** Xero bill status values + * + * TODO: Xero remaining comments will be handled here (https://github.com/Expensify/App/issues/43033) + */ type BillStatusValues = 'DRAFT' | 'AWT_APPROVAL' | 'AWT_PAYMENT'; -/** Xero expense status values */ +/** Xero expense status values + * + * TODO: Xero remaining comments will be handled here (https://github.com/Expensify/App/issues/43033) + */ type ExpenseTypesValues = 'BILL' | 'BANK_TRANSACTION' | 'SALES_INVOICE' | 'NOTHING'; -/** Xero bill date values */ +/** Xero bill date values + * + * TODO: Xero remaining comments will be handled here (https://github.com/Expensify/App/issues/43033) + */ type BillDateValues = 'REPORT_SUBMITTED' | 'REPORT_EXPORTED' | 'LAST_EXPENSE'; -/** Model of an organization in Xero */ +/** + * Model of an organization in Xero + * + * TODO: Xero remaining comments will be handled here (https://github.com/Expensify/App/issues/43033) + */ type Tenant = { /** ID of the organization */ id: string; @@ -410,49 +445,53 @@ type Tenant = { /** Name of the organization */ name: string; - /** TODO: Doesn't exist in the app */ + /** TODO: Will be handled in another issue */ value: string; }; -/** TODO: Not enough context */ +/** TODO: Xero remaining comments will be handled here (https://github.com/Expensify/App/issues/43033) */ type XeroTrackingCategory = { - /** TODO: Not enough context */ + /** TODO: Will be handled in another issue */ id: string; - /** TODO: Not enough context */ + /** TODO: Will be handled in another issue */ name: string; }; /** * Data imported from Xero + * + * TODO: Xero remaining comments will be handled here (https://github.com/Expensify/App/issues/43033) */ type XeroConnectionData = { /** Collection of bank accounts */ bankAccounts: Account[]; - /** TODO: Doesn't exist in the app */ + /** TODO: Will be handled in another issue */ countryCode: string; - /** TODO: Doesn't exist in the app */ + /** TODO: Will be handled in another issue */ organisationID: string; - /** TODO: Doesn't exist in the app */ + /** TODO: Will be handled in another issue */ revenueAccounts: Array<{ - /** TODO: Not enough context */ + /** TODO: Will be handled in another issue */ id: string; - /** TODO: Not enough context */ + /** TODO: Will be handled in another issue */ name: string; }>; /** Collection of organizations */ tenants: Tenant[]; - /** TODO: Not enough context */ + /** TODO: Will be handled in another issue */ trackingCategories: XeroTrackingCategory[]; }; +/** TODO: Xero remaining comments will be handled here (https://github.com/Expensify/App/issues/43033) */ type XeroMappingType = { + /** TODO: Will be handled in another issue */ customer: string; } & { [key in `trackingCategory_${string}`]: string; @@ -460,6 +499,8 @@ type XeroMappingType = { /** * User configuration for the Xero accounting integration. + * + * TODO: Xero remaining comments will be handled here (https://github.com/Expensify/App/issues/43033) */ type XeroConnectionConfig = OnyxCommon.OnyxValueWithOfflineFeedback<{ /** Xero auto synchronization configs */ @@ -467,11 +508,11 @@ type XeroConnectionConfig = OnyxCommon.OnyxValueWithOfflineFeedback<{ /** Whether data should be automatically synched between the app and Xero */ enabled: boolean; - /** TODO: Doesn't exist in the app */ + /** TODO: Will be handled in another issue */ jobID: string; }; - /** TODO: Not enough context */ + /** TODO: Will be handled in another issue */ enableNewCategories: boolean; /** Xero export configs */ @@ -479,6 +520,7 @@ type XeroConnectionConfig = OnyxCommon.OnyxValueWithOfflineFeedback<{ /** Current bill status */ billDate: BillDateValues; + /** TODO: Will be handled in another issue */ billStatus: { /** Current status of the purchase bill */ purchase: BillStatusValues; @@ -487,19 +529,19 @@ type XeroConnectionConfig = OnyxCommon.OnyxValueWithOfflineFeedback<{ sales: BillStatusValues; }; - /** TODO: Doesn't exist in the app */ + /** TODO: Will be handled in another issue */ billable: ExpenseTypesValues; /** The e-mail of the exporter */ exporter: string; - /** TODO: Doesn't exist in the app */ + /** TODO: Will be handled in another issue */ nonReimbursable: ExpenseTypesValues; - /** TODO: Not enough context */ + /** TODO: Will be handled in another issue */ nonReimbursableAccount: string; - /** TODO: Doesn't exist in the app */ + /** TODO: Will be handled in another issue */ reimbursable: ExpenseTypesValues; }; @@ -512,17 +554,18 @@ type XeroConnectionConfig = OnyxCommon.OnyxValueWithOfflineFeedback<{ /** Whether tracking categories should be imported from Xero */ importTrackingCategories: boolean; - /** TODO: Doesn't exist in the app */ + /** TODO: Will be handled in another issue */ isConfigured: boolean; - /** TODO: Not enough context */ + /** TODO: Will be handled in another issue */ mappings: XeroMappingType; + /** TODO: Will be handled in another issue */ sync: { - /** TODO: Doesn't exist in the app */ + /** TODO: Will be handled in another issue */ hasChosenAutoSyncOption: boolean; - /** TODO: Doesn't exist in the app */ + /** TODO: Will be handled in another issue */ hasChosenSyncReimbursedReportsOption: boolean; /** ID of the bank account for Xero invoice collections */ @@ -538,7 +581,7 @@ type XeroConnectionConfig = OnyxCommon.OnyxValueWithOfflineFeedback<{ /** ID of Xero organization */ tenantID: string; - /** TODO: Doesn't exist in the app */ + /** TODO: Will be handled in another issue */ errors?: OnyxCommon.Errors; /** Collection of form field errors */ @@ -728,8 +771,9 @@ type Policy = OnyxCommon.OnyxValueWithOfflineFeedback< /** The scheduled submit frequency set up on this policy */ autoReportingFrequency?: ValueOf; - /** Whether the scheduled submit is enabled */ + /** Scheduled submit data */ harvesting?: { + /** Whether the scheduled submit is enabled */ enabled: boolean; }; @@ -797,8 +841,9 @@ type Policy = OnyxCommon.OnyxValueWithOfflineFeedback< */ isTaxTrackingEnabled?: boolean; - /** Whether or not the policy has tax tracking enabled */ + /** Tax data */ tax?: { + /** Whether or not the policy has tax tracking enabled */ trackingEnabled: boolean; }; @@ -872,6 +917,8 @@ type PolicyConnectionSyncProgress = { /** Name of the connected service */ connectionName: PolicyConnectionName; + + /** Timestamp of the connection */ timestamp: string; }; diff --git a/src/types/onyx/PrivateSubscription.ts b/src/types/onyx/PrivateSubscription.ts index fbed6a89e49c..b9314b2bc66a 100644 --- a/src/types/onyx/PrivateSubscription.ts +++ b/src/types/onyx/PrivateSubscription.ts @@ -1,6 +1,7 @@ import type {ValueOf} from 'type-fest'; import type CONST from '@src/CONST'; +/** Model of private subscription */ type PrivateSubscription = { /** "auto increase annual seats" setting */ addNewUsersAutomatically: boolean; diff --git a/src/types/onyx/ReportAction.ts b/src/types/onyx/ReportAction.ts index 78dae6699cb7..ee6fc76ba3cd 100644 --- a/src/types/onyx/ReportAction.ts +++ b/src/types/onyx/ReportAction.ts @@ -171,7 +171,7 @@ type ReportActionBase = OnyxCommon.OnyxValueWithOfflineFeedback<{ /** Avatar data to display on the report action */ avatar?: AvatarSource; - /** TODO: not enough context */ + /** TODO: Not enough context */ automatic?: boolean; /** TODO: Not enough context */ @@ -222,6 +222,7 @@ type ReportActionBase = OnyxCommon.OnyxValueWithOfflineFeedback<{ /** Amount of money requests */ childMoneyRequestCount?: number; + /** Whether the report action is the first one */ isFirstItem?: boolean; /** Informations about attachments of report action */ diff --git a/src/types/onyx/ReportNextStep.ts b/src/types/onyx/ReportNextStep.ts index 00943dc1a1f8..0d158880a137 100644 --- a/src/types/onyx/ReportNextStep.ts +++ b/src/types/onyx/ReportNextStep.ts @@ -20,7 +20,7 @@ type DataOptions = { /** * If there is a masked bank account number from the server, the account needs to be unlocked - * + * * (Note: Copied directly from a comment in Old Dot JS) */ maskedLockedAccountNumber?: string; diff --git a/src/types/onyx/Task.ts b/src/types/onyx/Task.ts index ac11e5f3755f..fcdb97899338 100644 --- a/src/types/onyx/Task.ts +++ b/src/types/onyx/Task.ts @@ -8,9 +8,9 @@ type Task = { /** Description of the Task */ description?: string; - /** + /** * Report ID of the report where the task will be shared - * + * * (Note: This variable doesn't exist in the API. It's only used locally for UI purposes) */ shareDestination?: string; diff --git a/src/types/onyx/Transaction.ts b/src/types/onyx/Transaction.ts index df52adbaec46..21ffaee3f5ce 100644 --- a/src/types/onyx/Transaction.ts +++ b/src/types/onyx/Transaction.ts @@ -79,6 +79,8 @@ type Comment = { /** In split transactions this is a collection of participant split data */ splits?: Split[]; + + /** Violations that were dismissed */ dismissedViolations?: Record>; }; @@ -198,11 +200,9 @@ type Reservation = { /** In flight reservations, this represents the details of the airline company */ company?: Company; - /** TODO: To be confirmed */ /** Collection of passenger confirmations */ confirmations?: ReservationConfirmation[]; - /** TODO: To be confirmed */ /** In flight and car reservations, this represents the number of passengers */ numPassengers?: number; @@ -214,16 +214,13 @@ type Reservation = { /** Route airline code */ airlineCode: string; - /** TODO: To be confirmed */ /** Passenger class */ class?: string; - /** TODO: To be confirmed */ /** Passenger seat number */ number: string; }; - /** TODO: To be confirmed */ /** In car reservations, this represents the car dealership name */ vendor?: string; @@ -239,7 +236,6 @@ type ReservationTimeDetails = { /** In hotel reservations, this is the address of the hotel */ address?: string; - /** TODO: To be confirmed */ /** In car reservations, this is the location of the car dealership */ location?: string; @@ -261,29 +257,24 @@ type Company = { /** Short name of airline company */ shortName?: string; - /** TODO: To be confirmed */ /** Phone number of airline company support */ phone?: string; }; /** Model of reservation confirmation */ type ReservationConfirmation = { - /** TODO: To be confirmed */ /** Passenger name */ name: string; - /** TODO: To be confirmed */ /** Reservation code */ value: string; }; /** Model of car details */ type CarInfo = { - /** TODO: To be confirmed */ /** Name of the car */ name?: string; - /** TODO: To be confirmed */ /** Engine type */ engine?: string; }; diff --git a/src/types/onyx/WalletAdditionalDetails.ts b/src/types/onyx/WalletAdditionalDetails.ts index b53fb5ad8bf6..0593b64ffc3b 100644 --- a/src/types/onyx/WalletAdditionalDetails.ts +++ b/src/types/onyx/WalletAdditionalDetails.ts @@ -63,7 +63,7 @@ type WalletAdditionalDetails = { errors?: OnyxCommon.Errors; }; -// TODO: refactor into one type after removing old wallet flow +/** TODO: refactor into one type after removing old wallet flow */ type WalletAdditionalDetailsRefactor = WalletAdditionalDetails & WalletPersonalDetails; export default WalletAdditionalDetails;