all repos — stealth-developers @ de6df0112179e6b09758cb0da72ca1854368eda9

src/roblox/types/index.ts (view raw)

 1
 2
 3
 4
 5
 6
 7
 8
 9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
 100
 101
 102
// -- primitives -----------------------------------------------------------------------------------
export type RobloxUserId = string;
export type UniverseId = string;
export type PlaceId = string;
export type UserRef = `users/${RobloxUserId}`;
export type UniverseRef = `universes/${UniverseId}`;
export type PlaceRef = `universes/${UniverseId}/places/${PlaceId}`;
export type ISO8601 = string;
export type Duration = `${number}s`;
export type Base64 = string;
export type FieldMask = string;
export type CurrencyCode = string;

// -- commons --------------------------------------------------------------------------------------
export interface Decimal {
	significand: number;
	exponent?: number;
}

export interface Money {
	currencyCode: CurrencyCode;
	quantity: Decimal;
}

export interface Moderator {
	robloxUser: UserRef;
}

export interface Paginated<T> {
	logs: T[];
	nextPageToken?: string;
}

// -- operations -----------------------------------------------------------------------------------
export interface Operation<T = unknown, M = unknown> {
	path: string;
	done: boolean;
	response?: T;
	metadata?: M;
}

// -- errors ---------------------------------------------------------------------------------------
export interface GatewayError {
	errors: {
		code: number;
		message: string;
	}[];
}

export type ErrorCode =
	| "INVALID_ARGUMENT"
	| "PERMISSION_DENIED"
	| "NOT_FOUND"
	| "ABORTED"
	| "RESOURCE_EXHAUSTED"
	| "CANCELLED"
	| "INTERNAL"
	| "NOT_IMPLEMENTED"
	| "UNAVAILABLE";

export interface ApiErrorV2 {
	code: ErrorCode;
	message: string;
	details?: Record<string, unknown>[];
}

export interface ApiErrorV1 {
	error: ErrorCode;
	message: string;
	errorDetails?: {
		errorDetailType: string;
		datastoreErrorCode?: string;
	}[];
}

export interface ApiErrorV1Alt {
	code: ErrorCode;
	message: string;
}

export interface ApiValidationError {
	errors: Record<string, string[]>;
	type: string;
	title: string;
	status: number;
	extensions?: {
		traceId?: string;
	};
}

export type ApiError =
	| ApiErrorV2
	| ApiErrorV1
	| ApiErrorV1Alt
	| GatewayError
	| ApiValidationError;

export type Result<T> = [T, null] | [null, ApiError];

// -- exports --------------------------------------------------------------------------------------
export * from "./user-restriction";
export * from "./users";