Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[No QA][TS Migration] Add comments for remaining properties in Onyx types #41956

Merged
Show file tree
Hide file tree
Changes from 7 commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
5b9433c
docs: add onyx types descriptions
pac-guerreiro May 9, 2024
4dac52f
docs: add missing onyx types descriptions
pac-guerreiro May 13, 2024
ee11f2e
Merge branch 'main' into pac-guerreiro/refactor/39129-add-comments-to…
pac-guerreiro May 13, 2024
8631fa8
Merge branch 'main' into pac-guerreiro/refactor/39129-add-comments-to…
pac-guerreiro May 15, 2024
13029ae
docs: add missing type descriptions
pac-guerreiro May 15, 2024
3494545
Merge branch 'main' into pac-guerreiro/refactor/39129-add-comments-to…
pac-guerreiro May 20, 2024
96f6955
docs: apply pull request suggestions
pac-guerreiro May 20, 2024
65022fb
refactor: apply pull request suggestions
pac-guerreiro May 22, 2024
f3e1c8f
refactor: apply pull request suggestions
pac-guerreiro May 22, 2024
530d6d6
refactor: remove unused property from wallet additional details
pac-guerreiro May 22, 2024
9a50d43
docs: add missing type description
pac-guerreiro May 22, 2024
611266d
Merge branch 'main' into pac-guerreiro/refactor/39129-add-comments-to…
pac-guerreiro May 24, 2024
a4d4102
chore: resolve pending descriptions
pac-guerreiro May 24, 2024
8025926
Merge branch 'main' into pac-guerreiro/refactor/39129-add-comments-to…
pac-guerreiro May 27, 2024
5599455
docs: apply suggestions
pac-guerreiro May 27, 2024
2d91475
docs: apply suggestions
pac-guerreiro May 27, 2024
da515a8
Merge branch 'main' into pac-guerreiro/refactor/39129-add-comments-to…
pac-guerreiro May 31, 2024
530b1ce
Merge branch 'main' into pac-guerreiro/refactor/39129-add-comments-to…
pac-guerreiro Jun 1, 2024
68ce115
refactor: apply pull request suggestions
pac-guerreiro Jun 1, 2024
279e50a
Merge branch 'main' into pac-guerreiro/refactor/39129-add-comments-to…
pac-guerreiro Jun 5, 2024
9fe6712
chore: apply pull request suggestions and address types with missing …
pac-guerreiro Jun 5, 2024
c46d709
Merge branch 'main' into pac-guerreiro/refactor/39129-add-comments-to…
pac-guerreiro Jun 5, 2024
6dabcc0
chore: enable eslint rule that requires comments on onyx types and th…
pac-guerreiro Jun 6, 2024
11090bd
Merge branch 'main' into pac-guerreiro/refactor/39129-add-comments-to…
pac-guerreiro Jun 7, 2024
453343e
refactor: apply pull request suggestions
pac-guerreiro Jun 7, 2024
98fa483
Merge branch 'main' into pac-guerreiro/refactor/39129-add-comments-to…
fabioh8010 Jun 7, 2024
a354239
Fix lint errors and improve comments
fabioh8010 Jun 7, 2024
199e228
Merge remote-tracking branch 'origin/main' into pac-guerreiro/refacto…
fabioh8010 Jun 7, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/libs/ReportUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 */
pac-guerreiro marked this conversation as resolved.
Show resolved Hide resolved
type ExpenseOriginalMessage = {
oldComment?: string;
newComment?: string;
Expand Down
2 changes: 2 additions & 0 deletions src/pages/settings/Wallet/ExpensifyCardPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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<Response & TCardDetails>
pac-guerreiro marked this conversation as resolved.
Show resolved Hide resolved
setCardsDetails((prevState: Record<number, TCardDetails | null>) => ({...prevState, [revealedCardID]: value as TCardDetails}));
setCardsDetailsErrors((prevState) => ({
...prevState,
Expand Down
11 changes: 11 additions & 0 deletions src/types/onyx/Account.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<typeof CONST.TWO_FACTOR_AUTH_STEPS> | '';

/** Model of user account */
type Account = {
/** Whether SAML is enabled for the current account */
isSAMLEnabled?: boolean;
Expand Down Expand Up @@ -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 */
Expand Down
16 changes: 16 additions & 0 deletions src/types/onyx/AccountData.ts
Original file line number Diff line number Diff line change
@@ -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 */
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Putting comment here for me to get back to this later.

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;
Expand Down Expand Up @@ -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 */
Expand All @@ -52,6 +67,7 @@ type AccountData = {
/** Any error message to show */
errors?: OnyxCommon.Errors;

/** The debit card ID */
fundID?: number;
};

Expand Down
13 changes: 13 additions & 0 deletions src/types/onyx/Bank.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<typeof CONST.BANK_NAMES>;

/** Bank name keys */
type BankNameKey = keyof typeof CONST.BANK_NAMES;

export type {BankIcon, BankName, BankNameKey};
21 changes: 19 additions & 2 deletions src/types/onyx/BankAccount.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,31 +2,47 @@ 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 = {
pac-guerreiro marked this conversation as resolved.
Show resolved Hide resolved
/** 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;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Putting comment here for me to get back to this later.


/** 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;

/** 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 */
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-{<bankAccountID>}' where <bankAccountID> is the bankAccountID */
/** string like `bankAccount-<bankAccountID>` */
key?: string;

/** Alias for bankAccountID */
Expand All @@ -42,6 +58,7 @@ type BankAccount = OnyxCommon.OnyxValueWithOfflineFeedback<{
errors?: OnyxCommon.Errors;
}>;

/** Record of bank accounts, indexed by bankAccountID */
type BankAccountList = Record<string, BankAccount>;

export default BankAccount;
Expand Down
1 change: 1 addition & 0 deletions src/types/onyx/Beta.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import type {ValueOf} from 'type-fest';
import type CONST from '@src/CONST';

/** New Dot Beta features */
type Beta = ValueOf<typeof CONST.BETAS>;

export default Beta;
1 change: 1 addition & 0 deletions src/types/onyx/BlockedFromConcierge.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
/** Model of blocked user from concierge */
type BlockedFromConcierge = {
/** The date that the user will be unblocked */
expiresAt: string;
Expand Down
60 changes: 60 additions & 0 deletions src/types/onyx/Card.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<typeof CONST.EXPENSIFY_CARD.STATE>;

/** Bank name */
bank: string;

/** Available amount to spend */
availableSpend: number;

/** Domain name */
domainName: string;

/** Last four Primary Account Number digits */
lastFourPAN?: string;

/** Current fraud state of the card */
fraud: ValueOf<typeof CONST.EXPENSIFY_CARD.FRAUD_TYPES>;

/** 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<typeof CONST.EXPENSIFY_CARD.LIMIT_TYPES>;

// 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: {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Putting comment here for me to get back to this later.

/** 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<string, Card>;

export default Card;
Expand Down
7 changes: 7 additions & 0 deletions src/types/onyx/Console.ts
Original file line number Diff line number Diff line change
@@ -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 captured logs */
type CapturedLogs = Record<number, Log>;

export type {Log, CapturedLogs};
1 change: 1 addition & 0 deletions src/types/onyx/Credentials.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
/** Model of user credentials */
type Credentials = {
/** The email/phone the user logged in with */
login?: string;
Expand Down
2 changes: 2 additions & 0 deletions src/types/onyx/Currency.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
/** Model of currency */
type Currency = {
/** Symbol for the currency */
symbol: string;
Expand All @@ -21,6 +22,7 @@ type Currency = {
cacheBurst?: number;
};

/** Record of currencies, index by currency code */
type CurrencyList = Record<string, Currency | null>;

export default Currency;
Expand Down
1 change: 1 addition & 0 deletions src/types/onyx/CustomStatusDraft.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
/** Model of custom status draft */
type CustomStatusDraft = {
/** The emoji code of the draft status */
emojiCode?: string;
Expand Down
10 changes: 10 additions & 0 deletions src/types/onyx/DismissedReferralBanners.ts
Original file line number Diff line number Diff line change
@@ -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;
};

Expand Down
1 change: 1 addition & 0 deletions src/types/onyx/Download.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
/** Model of file download */
type Download = {
/** If a file download is happening */
isDownloading: boolean;
Expand Down
1 change: 1 addition & 0 deletions src/types/onyx/FrequentlyUsedEmoji.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
/** Model of frequently used emoji */
type FrequentlyUsedEmoji = {
/** The emoji code */
code: string;
Expand Down
Loading
Loading