Make various ID related types in Typescript consistently named

This commit is contained in:
Eric Schultz 2021-02-10 16:04:05 -06:00 committed by Eric Schultz
parent c676e70a49
commit 8ee309c1f2
18 changed files with 60 additions and 60 deletions

View file

@ -1,5 +1,5 @@
// License: LGPL-3.0-or-later // License: LGPL-3.0-or-later
import type { IdType, HoudiniObject, HoudiniEvent, Amount, RecurrenceRule } from '../../common'; import type { IDType, HoudiniObject, HoudiniEvent, Amount, RecurrenceRule } from '../../common';
import type Nonprofit from '..'; import type Nonprofit from '..';
import type Campaign from '.'; import type Campaign from '.';
@ -13,13 +13,13 @@ interface RecurringGiftOptionAmount {
} }
export interface CampaignGiftOption extends HoudiniObject { export interface CampaignGiftOption extends HoudiniObject {
campaign: IdType | Campaign; campaign: IDType | Campaign;
deleted: boolean; deleted: boolean;
description: string; description: string;
gift_option_amount: Array<RecurringGiftOptionAmount | OneTimeGiftOptionAmount>; gift_option_amount: Array<RecurringGiftOptionAmount | OneTimeGiftOptionAmount>;
hide_contributions: boolean; hide_contributions: boolean;
name: string; name: string;
nonprofit: IdType | Nonprofit; nonprofit: IDType | Nonprofit;
object: "campaign_gift_option"; object: "campaign_gift_option";
order: number; order: number;
quantity?: number; quantity?: number;

View file

@ -1,10 +1,10 @@
// License: LGPL-3.0-or-later // License: LGPL-3.0-or-later
import { IdType, HoudiniObject } from '../../common'; import { IDType, HoudiniObject } from '../../common';
import Nonprofit from '../'; import Nonprofit from '../';
export default interface Campaign extends HoudiniObject { export default interface Campaign extends HoudiniObject {
name: string; name: string;
nonprofit: IdType | Nonprofit; nonprofit: IDType | Nonprofit;
object: "campaign"; object: "campaign";
} }

View file

@ -1,12 +1,12 @@
// License: LGPL-3.0-or-later // License: LGPL-3.0-or-later
import type { HoudiniEvent, HoudiniObject, IdType } from "../common"; import type { HoudiniEvent, HoudiniObject, IDType } from "../common";
import type Nonprofit from '.'; import type Nonprofit from '.';
export interface CustomFieldDefinition extends HoudiniObject { export interface CustomFieldDefinition extends HoudiniObject {
deleted: boolean; deleted: boolean;
name: string; name: string;
nonprofit: IdType | Nonprofit; nonprofit: IDType | Nonprofit;
object: 'custom_field_definition'; object: 'custom_field_definition';
} }

View file

@ -1,5 +1,5 @@
// License: LGPL-3.0-or-later // License: LGPL-3.0-or-later
import type { IdType, HoudiniObject, Amount, HoudiniEvent } from '../../common'; import type { IDType, HoudiniObject, Amount, HoudiniEvent } from '../../common';
import type Nonprofit from '..'; import type Nonprofit from '..';
import type Event from '.'; import type Event from '.';
import type { TicketLevel } from './TicketLevel'; import type { TicketLevel } from './TicketLevel';
@ -12,10 +12,10 @@ type DiscountType = { percent: number } | { amount: Amount };
export interface EventDiscount extends HoudiniObject { export interface EventDiscount extends HoudiniObject {
code: string; code: string;
discount: DiscountType; discount: DiscountType;
event: IdType | Event; event: IDType | Event;
nonprofit: IdType | Nonprofit; nonprofit: IDType | Nonprofit;
object: "event_discount"; object: "event_discount";
ticket_levels: IdType[] | TicketLevel[]; ticket_levels: IDType[] | TicketLevel[];
} }
export type EventDiscountCreated = HoudiniEvent<'event_discount.created', EventDiscount>; export type EventDiscountCreated = HoudiniEvent<'event_discount.created', EventDiscount>;

View file

@ -1,5 +1,5 @@
// License: LGPL-3.0-or-later // License: LGPL-3.0-or-later
import type { HouID, HoudiniObject, HoudiniEvent, Amount, IdType} from '../../common'; import type { HouID, HoudiniObject, HoudiniEvent, Amount, IDType} from '../../common';
import type Nonprofit from '..'; import type Nonprofit from '..';
import type Event from '.'; import type Event from '.';
import type { TicketLevel , TicketPurchase} from '.'; import type { TicketLevel , TicketPurchase} from '.';
@ -9,12 +9,12 @@ export interface Ticket extends HoudiniObject<HouID> {
amount: Amount; amount: Amount;
checked_in: boolean; checked_in: boolean;
deleted: boolean; deleted: boolean;
event: IdType | Event; event: IDType | Event;
nonprofit: IdType | Nonprofit; nonprofit: IDType | Nonprofit;
note: string; note: string;
object: 'ticket'; object: 'ticket';
supporter: IdType | Supporter; supporter: IDType | Supporter;
ticket_level: IdType | TicketLevel; ticket_level: IDType | TicketLevel;
ticket_purchase: HouID | TicketPurchase; ticket_purchase: HouID | TicketPurchase;
} }

View file

@ -1,5 +1,5 @@
// License: LGPL-3.0-or-later // License: LGPL-3.0-or-later
import { IdType, HoudiniObject, HoudiniEvent, Amount } from '../../common'; import { IDType, HoudiniObject, HoudiniEvent, Amount } from '../../common';
import Nonprofit from '..'; import Nonprofit from '..';
import Event from './'; import Event from './';
import { EventDiscount } from './EventDiscount'; import { EventDiscount } from './EventDiscount';
@ -17,12 +17,12 @@ export interface TicketLevel extends HoudiniObject {
available_to: 'everyone' | 'admins'; available_to: 'everyone' | 'admins';
deleted: boolean; deleted: boolean;
description: string; description: string;
event: IdType | Event; event: IDType | Event;
/** /**
* at some time, event discounts will be associated with a given ticket level. * at some time, event discounts will be associated with a given ticket level.
* For now, this returns all of the discounts for the event though. * For now, this returns all of the discounts for the event though.
*/ */
event_discounts: IdType[] | EventDiscount[]; event_discounts: IDType[] | EventDiscount[];
/** /**
* the max number of tickets to be sold on this TicketLevel, null means unlimited. * the max number of tickets to be sold on this TicketLevel, null means unlimited.
* If you edit this and decide to lower the limit below the number of tickets currently sold, * If you edit this and decide to lower the limit below the number of tickets currently sold,
@ -33,7 +33,7 @@ export interface TicketLevel extends HoudiniObject {
* Nice readable name fo the ticket level * Nice readable name fo the ticket level
*/ */
name: string; name: string;
nonprofit: IdType | Nonprofit; nonprofit: IDType | Nonprofit;
object: "ticket_level"; object: "ticket_level";
/** order to be displayed */ /** order to be displayed */
order: number; order: number;

View file

@ -1,5 +1,5 @@
// License: LGPL-3.0-or-later // License: LGPL-3.0-or-later
import type { HouID, HoudiniObject, HoudiniEvent, Amount, IdType} from '../../common'; import type { HouID, HoudiniObject, HoudiniEvent, Amount, IDType} from '../../common';
import type Nonprofit from '..'; import type Nonprofit from '..';
import type Event from '.'; import type Event from '.';
import type { EventDiscount, Ticket } from '.'; import type { EventDiscount, Ticket } from '.';
@ -9,11 +9,11 @@ import { Transaction } from '../Supporter';
export interface TicketPurchase extends HoudiniObject<HouID> { export interface TicketPurchase extends HoudiniObject<HouID> {
amount: Amount; amount: Amount;
event: IdType | Event; event: IDType | Event;
event_discount?: IdType | EventDiscount | null; event_discount?: IDType | EventDiscount | null;
nonprofit: IdType | Nonprofit; nonprofit: IDType | Nonprofit;
object: 'ticket_purchase'; object: 'ticket_purchase';
supporter: IdType | Supporter; supporter: IDType | Supporter;
tickets: Ticket[] | HouID[]; tickets: Ticket[] | HouID[];
transaction: HouID | Transaction; transaction: HouID | Transaction;
} }

View file

@ -1,11 +1,11 @@
// License: LGPL-3.0-or-later // License: LGPL-3.0-or-later
import { IdType, HoudiniObject } from '../../common'; import { IDType, HoudiniObject } from '../../common';
import Nonprofit from '../'; import Nonprofit from '../';
export default interface Event extends HoudiniObject { export default interface Event extends HoudiniObject {
end_date: Date; end_date: Date;
name: string; name: string;
nonprofit: IdType | Nonprofit; nonprofit: IDType | Nonprofit;
object: "event"; object: "event";
start_date: Date; start_date: Date;
} }

View file

@ -1,5 +1,5 @@
// License: LGPL-3.0-or-later // License: LGPL-3.0-or-later
import type { IdType, HoudiniObject, HoudiniEvent } from '../../common'; import type { IDType, HoudiniObject, HoudiniEvent } from '../../common';
import type Nonprofit from '..'; import type Nonprofit from '..';
import type Supporter from '.'; import type Supporter from '.';
@ -8,10 +8,10 @@ export interface SupporterAddress extends HoudiniObject {
city: string; city: string;
country: string; country: string;
deleted: boolean; deleted: boolean;
nonprofit: IdType | Nonprofit; nonprofit: IDType | Nonprofit;
object: "supporter_address"; object: "supporter_address";
state_code: string; state_code: string;
supporter: IdType | Supporter; supporter: IDType | Supporter;
zip_code: string; zip_code: string;
} }

View file

@ -1,5 +1,5 @@
// License: LGPL-3.0-or-later // License: LGPL-3.0-or-later
import type { IdType, HoudiniObject, HoudiniEvent } from '../../common'; import type { IDType, HoudiniObject, HoudiniEvent } from '../../common';
import type Nonprofit from '..'; import type Nonprofit from '..';
import Supporter from '.'; import Supporter from '.';
import type { User } from '../../User'; import type { User } from '../../User';
@ -7,10 +7,10 @@ import type { User } from '../../User';
export interface SupporterNote extends HoudiniObject { export interface SupporterNote extends HoudiniObject {
content: string; content: string;
deleted: boolean; deleted: boolean;
nonprofit: IdType | Nonprofit; nonprofit: IDType | Nonprofit;
object: "supporter_note"; object: "supporter_note";
supporter: IdType | Supporter; supporter: IDType | Supporter;
user: IdType | User; user: IDType | User;
} }
export type SupporterNoteCreated = HoudiniEvent<'supporter_note.created', SupporterNote>; export type SupporterNoteCreated = HoudiniEvent<'supporter_note.created', SupporterNote>;

View file

@ -1,5 +1,5 @@
// License: LGPL-3.0-or-later // License: LGPL-3.0-or-later
import type { Amount, HoudiniObject, IdType, HouID } from "../../common"; import type { Amount, HoudiniObject, IDType, HouID } from "../../common";
import type Nonprofit from '..'; import type Nonprofit from '..';
import type Supporter from "."; import type Supporter from ".";
@ -8,11 +8,11 @@ import type Supporter from ".";
*/ */
export interface Transaction extends HoudiniObject<HouID> { export interface Transaction extends HoudiniObject<HouID> {
amount: Amount; amount: Amount;
nonprofit: IdType | Nonprofit; nonprofit: IDType | Nonprofit;
object: 'transaction'; object: 'transaction';
payment_methods: Array<unknown>; payment_methods: Array<unknown>;
payments: Array<unknown>; payments: Array<unknown>;
status: string; status: string;
supporter: IdType | Supporter; supporter: IDType | Supporter;
transaction_assignments: Array<unknown>; transaction_assignments: Array<unknown>;
} }

View file

@ -1,5 +1,5 @@
// License: LGPL-3.0-or-later // License: LGPL-3.0-or-later
import type { IdType, HoudiniObject, HoudiniEvent } from '../../common'; import type { IDType, HoudiniObject, HoudiniEvent } from '../../common';
import type Nonprofit from '../'; import type Nonprofit from '../';
import type { SupporterAddress } from './SupporterAddress'; import type { SupporterAddress } from './SupporterAddress';
@ -7,13 +7,13 @@ export default interface Supporter extends HoudiniObject {
anonymous: boolean; anonymous: boolean;
deleted: boolean; deleted: boolean;
email: string; email: string;
merged_into: IdType | Supporter | null; merged_into: IDType | Supporter | null;
name: string; name: string;
nonprofit: IdType | Nonprofit; nonprofit: IDType | Nonprofit;
object: "supporter"; object: "supporter";
organization: string; organization: string;
phone: string; phone: string;
supporter_addresses: IdType[] | SupporterAddress[]; supporter_addresses: IDType[] | SupporterAddress[];
} }
export type SupporterCreated = HoudiniEvent<'supporter_address.created', Supporter>; export type SupporterCreated = HoudiniEvent<'supporter_address.created', Supporter>;

View file

@ -1,12 +1,12 @@
// License: LGPL-3.0-or-later // License: LGPL-3.0-or-later
import type { HoudiniEvent, HoudiniObject, IdType } from "../common"; import type { HoudiniEvent, HoudiniObject, IDType } from "../common";
import type Nonprofit from './'; import type Nonprofit from './';
export interface TagDefinition extends HoudiniObject { export interface TagDefinition extends HoudiniObject {
deleted: boolean; deleted: boolean;
name: string; name: string;
nonprofit: IdType | Nonprofit; nonprofit: IDType | Nonprofit;
object: 'tag_definition'; object: 'tag_definition';
} }

View file

@ -1,5 +1,5 @@
// License: LGPL-3.0-or-later // License: LGPL-3.0-or-later
import type { Amount, HoudiniObject, IdType, HouID, HoudiniEvent } from "../../common"; import type { Amount, HoudiniObject, IDType, HouID, HoudiniEvent } from "../../common";
import type Nonprofit from '../'; import type Nonprofit from '../';
import type Supporter from "../Supporter"; import type Supporter from "../Supporter";
import type Transaction from './'; import type Transaction from './';
@ -19,9 +19,9 @@ export interface Donation extends HoudiniObject<HouID> {
amount: Amount; amount: Amount;
dedication?: Dedication | null; dedication?: Dedication | null;
designation?: string | null; designation?: string | null;
nonprofit: IdType | Nonprofit; nonprofit: IDType | Nonprofit;
object: 'donation'; object: 'donation';
supporter: IdType | Supporter; supporter: IDType | Supporter;
transaction: HouID | Transaction; transaction: HouID | Transaction;
} }

View file

@ -1,5 +1,5 @@
// License: LGPL-3.0-or-later // License: LGPL-3.0-or-later
import type { Amount, HoudiniObject, IdType, HouID } from "../../common"; import type { Amount, HoudiniObject, IDType, HouID } from "../../common";
import type Nonprofit from '../'; import type Nonprofit from '../';
import type Supporter from "../Supporter"; import type Supporter from "../Supporter";
import type Transaction from './'; import type Transaction from './';
@ -7,9 +7,9 @@ import type Transaction from './';
export interface Payment extends HoudiniObject<HouID> { export interface Payment extends HoudiniObject<HouID> {
amount: Amount; amount: Amount;
nonprofit: IdType | Nonprofit; nonprofit: IDType | Nonprofit;
object: 'payment'; object: 'payment';
supporter: IdType | Supporter; supporter: IDType | Supporter;
transaction: HouID | Transaction; transaction: HouID | Transaction;
} }

View file

@ -1,16 +1,16 @@
// License: LGPL-3.0-or-later // License: LGPL-3.0-or-later
import type { Amount, HoudiniObject, IdType, HouID } from "../../common"; import type { Amount, HoudiniObject, IDType, HouID } from "../../common";
import type Nonprofit from '../'; import type Nonprofit from '../';
import type Supporter from "../Supporter"; import type Supporter from "../Supporter";
import type { Payment } from "./Payment"; import type { Payment } from "./Payment";
export default interface Transaction extends HoudiniObject<HouID> { export default interface Transaction extends HoudiniObject<HouID> {
amount: Amount; amount: Amount;
nonprofit: IdType | Nonprofit; nonprofit: IDType | Nonprofit;
object: 'transaction'; object: 'transaction';
payments: IdType[] | Payment[]; payments: IDType[] | Payment[];
status: "not-submitted"|"created" | "waiting-on-supporter" | "failed" | "completed"; status: "not-submitted"|"created" | "waiting-on-supporter" | "failed" | "completed";
supporter: IdType | Supporter; supporter: IDType | Supporter;
/** /**
* We don't specify more for now * We don't specify more for now
*/ */

View file

@ -1,5 +1,5 @@
// License: LGPL-3.0-or-later // License: LGPL-3.0-or-later
import { IdType, HoudiniObject } from './common'; import { IDType, HoudiniObject } from './common';
export interface User extends HoudiniObject { export interface User extends HoudiniObject {
object: 'user'; object: 'user';

View file

@ -4,7 +4,7 @@
* the main identifier for HoudiniObjects which is unique between all other HoudiniObjects with the same object value. * the main identifier for HoudiniObjects which is unique between all other HoudiniObjects with the same object value.
* Currently just an integer but we could reevaluate later; * Currently just an integer but we could reevaluate later;
*/ */
export type IdType = number; export type IDType = number;
/** /**
* an identifier for HoudiniObjects which is unique among all HoudiniObjects. * an identifier for HoudiniObjects which is unique among all HoudiniObjects.
@ -60,12 +60,12 @@ export type RecurrenceRule = {
* Every object controlled by the Houdini event publisher must meet this standard interface * Every object controlled by the Houdini event publisher must meet this standard interface
* and will inherit from it. * and will inherit from it.
*/ */
export interface HoudiniObject<Id extends IdType|HouID=IdType> { export interface HoudiniObject<ID extends IDType|HouID=IDType> {
/** /**
* An IdType which unique which uniquely identifies this object * An IDType which unique which uniquely identifies this object
* from all other similar objects * from all other similar objects
*/ */
id: Id; id: ID;
/** /**
* the type of object. Roughly corresponds to the object's class in Rails * the type of object. Roughly corresponds to the object's class in Rails
*/ */
@ -73,7 +73,7 @@ export interface HoudiniObject<Id extends IdType|HouID=IdType> {
} }
type HoudiniObjectOfAllIds = HoudiniObject<IdType> | HoudiniObject<HouID>; type HoudiniObjectOfAllIDs = HoudiniObject<IDType> | HoudiniObject<HouID>;
/** /**
* An event published by Houdini * An event published by Houdini
* *
@ -83,7 +83,7 @@ type HoudiniObjectOfAllIds = HoudiniObject<IdType> | HoudiniObject<HouID>;
* * DataObject: the interface representing the actual object which the event occurred on. An object of that type is * * DataObject: the interface representing the actual object which the event occurred on. An object of that type is
* on the 'data' attribute * on the 'data' attribute
*/ */
export interface HoudiniEvent<EventType extends string, DataObject extends HoudiniObjectOfAllIds> { export interface HoudiniEvent<EventType extends string, DataObject extends HoudiniObjectOfAllIDs> {
/** data for the event. We wrap the object inside becuase we might want to provide some sort of */ /** data for the event. We wrap the object inside becuase we might want to provide some sort of */
data: { data: {
/** the object after the event has occurred */ /** the object after the event has occurred */