Adds treasures
This commit is contained in:
@@ -6,23 +6,48 @@ export type UserId = Id<"User">;
|
||||
export type CampaignId = Id<"Campaign">;
|
||||
export type DocumentId = Id<"Document">;
|
||||
|
||||
export type ISO8601Date = string & { __type: "iso8601date" };
|
||||
|
||||
export type Campaign = RecordModel & {
|
||||
id: CampaignId;
|
||||
name: string;
|
||||
owner: UserId;
|
||||
};
|
||||
|
||||
/******************************************
|
||||
* Relationships
|
||||
******************************************/
|
||||
|
||||
export const RelationshipType = {
|
||||
Secrets: "secrets",
|
||||
DiscoveredIn: "discoveredIn",
|
||||
Treasures: "treasures",
|
||||
} as const;
|
||||
|
||||
export type RelationshipType =
|
||||
(typeof RelationshipType)[keyof typeof RelationshipType];
|
||||
|
||||
export type Relationship = RecordModel & {
|
||||
primary: DocumentId;
|
||||
secondary: DocumentId[];
|
||||
type: RelationshipType;
|
||||
};
|
||||
|
||||
/******************************************
|
||||
* Documents
|
||||
******************************************/
|
||||
|
||||
export type DocumentData<K extends string, V> = {
|
||||
data: Record<K, V>;
|
||||
};
|
||||
|
||||
export type Document = RecordModel & {
|
||||
id: DocumentId;
|
||||
campaign: CampaignId;
|
||||
data: {};
|
||||
// These two are not in Pocketbase's types, but they seem to always be present
|
||||
created: string;
|
||||
updated: string;
|
||||
};
|
||||
|
||||
export type DocumentData<K extends string, V> = {
|
||||
data: Record<K, V>;
|
||||
created: ISO8601Date;
|
||||
updated: ISO8601Date;
|
||||
};
|
||||
|
||||
export type Session = Document &
|
||||
@@ -37,8 +62,6 @@ export function isSession(doc: Document): doc is Session {
|
||||
return Object.hasOwn(doc.data, "session");
|
||||
}
|
||||
|
||||
export type ISO8601Date = string & { __type: "iso8601date" };
|
||||
|
||||
export type Secret = Document &
|
||||
DocumentData<
|
||||
"secret",
|
||||
@@ -52,16 +75,15 @@ export function isSecret(doc: Document): doc is Secret {
|
||||
return Object.hasOwn(doc.data, "secret");
|
||||
}
|
||||
|
||||
export const RelationshipType = {
|
||||
Secrets: "secrets",
|
||||
DiscoveredIn: "discoveredIn",
|
||||
} as const;
|
||||
export type Treasure = Document &
|
||||
DocumentData<
|
||||
"treasure",
|
||||
{
|
||||
text: string;
|
||||
discovered: boolean;
|
||||
}
|
||||
>;
|
||||
|
||||
export type RelationshipType =
|
||||
(typeof RelationshipType)[keyof typeof RelationshipType];
|
||||
|
||||
export type Relationship = RecordModel & {
|
||||
primary: DocumentId;
|
||||
secondary: DocumentId[];
|
||||
type: RelationshipType;
|
||||
};
|
||||
export function isTreasure(doc: Document): doc is Treasure {
|
||||
return Object.hasOwn(doc.data, "treasure");
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user