upend/sdks/js/src/types.ts

127 lines
2.4 KiB
TypeScript
Raw Normal View History

2021-11-11 23:37:42 +01:00
export type Address = string;
2023-06-28 18:44:08 +02:00
export type ADDRESS_TYPE = "Hash" | "Uuid" | "Attribute" | "Url";
2022-01-28 20:51:34 +01:00
export type VALUE_TYPE = "Address" | "String" | "Number" | "Invalid";
2021-11-11 23:37:42 +01:00
export function isAddress(address: string): address is Address {
return address.startsWith("@");
}
/**
* A single atomic entry in UpEnd.
*/
2021-11-11 23:37:42 +01:00
export interface IEntry {
/** The entity this entry annotates. */
2021-11-11 23:37:42 +01:00
entity: Address;
/** The attribute of the relation. */
2021-11-11 23:37:42 +01:00
attribute: string;
/** The value of the attribute. */
value: IValue;
/** The origin or provenance of the data entry (e.g. SYSTEM or USER API...) */
provenance: string;
/** The user who created the data entry. */
user: string;
/** The timestamp when the data entry was created in RFC 3339 format. */
timestamp: string;
}
2022-01-28 20:51:34 +01:00
export type IValue =
| {
t: "Address";
c: string;
}
| {
t: "String";
c: string;
}
| {
t: "Number";
c: number;
}
2022-02-20 18:04:16 +01:00
| {
t: "Null";
c: null;
2022-01-28 20:51:34 +01:00
};
2021-11-11 23:37:42 +01:00
export interface InvariantEntry {
attribute: string;
value: IValue;
}
export type InAddress =
| Address
| { t: "Attribute" | "Url" | "Uuid"; c?: string };
2023-04-25 19:57:15 +02:00
export type InEntry = {
entity: Address;
attribute: string;
value: IValue;
provenance?: string;
};
export type PutInput =
| InEntry
| InEntry[]
| InvariantEntry
| { entity: InAddress };
2021-11-11 23:37:42 +01:00
export interface ListingResult {
[key: string]: IEntry;
}
// entry address, entity address address
export type PutResult = [string | undefined, string];
// export type OrderedListing = [Address, IEntry][];
2021-11-11 23:37:42 +01:00
export type AttributeListingResult = Array<{
name: string;
labels: string[];
}>;
2021-11-11 23:37:42 +01:00
export interface IFile {
hash: string;
path: string;
valid: boolean;
added: string;
size: number;
mtime: string;
}
2021-12-21 16:10:16 +01:00
export interface IJob {
title: string;
job_type: string;
2021-12-21 16:10:16 +01:00
progress: number;
state: "InProgress" | "Done" | "Failed";
}
2021-11-11 23:37:42 +01:00
export interface VaultInfo {
name: string | null;
location: string;
2022-02-02 22:36:45 +01:00
version: string;
desktop: boolean;
public: boolean;
}
export interface StoreInfo {
totals: { count: number; size: number };
blobs: {
hash: string;
size: number;
paths: { added: number; valid: boolean; path: string }[];
}[];
}
export type EntityInfo =
| {
t: "Hash" | "Uuid";
}
| {
t: "Attribute" | "Url";
c: string;
};
export interface EntityListing {
entity: EntityInfo;
entries: ListingResult;
}