Allow a string id for HoudiniObjects

This commit is contained in:
Eric Schultz 2021-01-21 11:30:12 -06:00 committed by Eric Schultz
parent 9f4c94d5a5
commit 69b6141652

View file

@ -6,6 +6,11 @@
*/ */
export type IdType = number; export type IdType = number;
/**
* an identifier for HoudiniObjects which is unique among all HoudiniObjects.
*/
export type UuidType = string;
/** /**
* Describes a monetary value in the minimum unit for this current. Corresponds to Money class in * Describes a monetary value in the minimum unit for this current. Corresponds to Money class in
* Ruby and Typescript * Ruby and Typescript
@ -55,18 +60,20 @@ 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 { export interface HoudiniObject<Id extends IdType|UuidType=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: IdType; 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
*/ */
object: string; object: string;
} }
type HoudiniObjectOfAllIds = HoudiniObject<IdType> | HoudiniObject<UuidType>;
/** /**
* An event published by Houdini * An event published by Houdini
* *
@ -76,7 +83,7 @@ export interface HoudiniObject {
* * 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 HoudiniObject> { 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 */