-
-
Notifications
You must be signed in to change notification settings - Fork 77
Expand file tree
/
Copy pathResource.ts
More file actions
47 lines (42 loc) · 1.21 KB
/
Resource.ts
File metadata and controls
47 lines (42 loc) · 1.21 KB
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
import type { Field } from "./Field.js";
import type { Operation } from "./Operation.js";
import type { Parameter } from "./Parameter.js";
import type { Nullable } from "./types.js";
export interface ManagesBlock {
property?: string;
object?: string;
}
export interface ResourceOptions
extends Nullable<{
id?: string;
title?: string;
description?: string;
fields?: Field[];
readableFields?: Field[];
writableFields?: Field[];
getParameters?: () => Promise<Parameter[]>;
operations?: Operation[];
deprecated?: boolean;
parameters?: Parameter[];
manages?: ManagesBlock[];
}> {}
export class Resource implements ResourceOptions {
name: string;
url: string;
id?: string | null;
title?: string | null;
description?: string | null;
fields?: Field[] | null;
readableFields?: Field[] | null;
writableFields?: Field[] | null;
getParameters?: (() => Promise<Parameter[]>) | null;
operations?: Operation[] | null;
deprecated?: boolean | null;
parameters?: Parameter[] | null;
manages?: ManagesBlock[] | null;
constructor(name: string, url: string, options: ResourceOptions = {}) {
this.name = name;
this.url = url;
Object.assign(this, options);
}
}