-
Notifications
You must be signed in to change notification settings - Fork 14
/
Copy pathtypes.ts
280 lines (246 loc) · 6.72 KB
/
types.ts
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
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
/* Copyright (c) 2018 Environmental Systems Research Institute, Inc.
* Apache-2.0 */
import { IItem, IUser, IGroup, IGeometry } from "@esri/arcgis-rest-types";
import { IPortal } from "@esri/arcgis-rest-portal";
import { IUserRequestOptions } from "@esri/arcgis-rest-auth";
/**
* Generic Model, used with all items that have a json
* `/data` payload
*
* @export
* @interface IModel
*/
export interface IModel {
item: IItem;
data?: {
[propName: string]: any;
};
[key: string]: any;
}
/**
* Defined the Initiative Item as having
* `type: "Hub Initiative"`
*
* @export
* @interface IInitiativeItem
* @extends {IItemAdd}
*/
export interface IInitiativeItem extends IItem {
id: string;
type: "Hub Initiative";
}
/**
* Initiative Model
*
* @export
* @interface IInitiativeModel
* @extends {IModel}
*/
export interface IInitiativeModel extends IModel {
item: IInitiativeItem;
data?: {
[propName: string]: any;
};
}
export interface IInitiativeModelTemplate {
item: Partial<IInitiativeItem>;
data: {
[propName: string]: any;
};
}
// TODO fine-tune this with sensible constraints
export type IItemTemplate = Record<string, any>;
export interface ITemplateAsset {
mimeType?: "image/png" | "image/jpg" | "image/jpeg";
name: string;
url?: string;
type?: string;
}
export interface IModelTemplate {
itemId: string;
item: IItemTemplate;
data: { [propName: string]: any };
properties?: { [propName: string]: any };
type: string;
key: string;
dependencies?: any[];
resources?: string[];
assets?: ITemplateAsset[];
[propName: string]: any;
}
export interface ISolutionTemplate extends IModel {
data: {
templates: IModelTemplate[];
};
}
export type GenericAsyncFunc = (...args: any) => Promise<any>;
interface IHubRequestOptionsPortalSelf extends IPortal {
user?: IUser;
}
export interface IHubRequestOptions extends IUserRequestOptions {
isPortal: boolean;
hubApiUrl: string;
portalSelf?: IHubRequestOptionsPortalSelf;
}
export interface IItemResource {
type?: string;
url: string;
name: string;
}
export type IBBox = number[][];
export type IBatch = any[];
export type IBatchTransform = (value: any) => any;
export interface IGetSurveyModelsResponse {
form: IModel;
featureService: IModel;
fieldworker: IModel;
stakeholder: IModel;
}
export interface IGetGroupSharingDetailsResults {
group: IGroup;
modelsToShare: IModel[];
}
export interface IRevertableTaskSuccess {
status: "fullfilled";
revert: (...args: any[]) => Promise<any>;
results: any;
}
export interface IRevertableTaskFailed {
status: "rejected";
error: Error;
}
export type IRevertableTaskResult =
| IRevertableTaskSuccess
| IRevertableTaskFailed;
/**
* Types of Hub resources
*/
export type HubType =
| "member"
| "team"
| "event"
| "dataset"
| "document"
| "map "
| "app "
| "site"
| "initiative"
| "template"
| "organization";
/**
* Visibility levels of a Hub resource
*/
export type Visibility = "private" | "org" | "public";
/**
* User's access level to a Hub resource
*/
export type AccessControl = "view" | "edit" | "admin";
/**
* Location of a Hub resource
*
* @export
* @interface IHubGeography
*/
export interface IHubGeography {
center?: [number, number];
geometry?: IGeometry;
}
/**
* Properties that are common to Hub content, community, members, etc
*
* @export
* @interface IHubResource
*/
export interface IHubResource {
/** Generic term for the primary label (title, fullname, username, etc.) */
name: string;
/** Content snippet or other summary */
summary?: string;
// TODO: publisher: IHubOwner // TODO: better name? item.owner with more user metadata
// Derived metadata
/** Type of Hub resource */
hubType: HubType;
// Explicit data information since this is a common confusion + bug report
/** Date the item was created */
createdDate: Date;
/**
* description of what was used for this attribute
* the item key, e.g. `item.created` or `item.metadata.created_date`
*/
createdDateSource?: string;
/** Date the item was last updated */
updatedDate: Date;
/**
* description of what was used for this attribute
* the item key, e.g. `item.modified` or `item.metadata.modified_date`
*/
updatedDateSource?: string;
/** URL of the resource's page in the Portal Home application */
portalHomeUrl?: string;
/** URL of the Portal API endpoint for the resource */
portalApiUrl?: string;
/** Fully qualified URL for the item's thumbnail, including current user's token if authenticated and required */
thumbnailUrl?: string; // Full URL. item.thumbnail with host + path
/**
* boundary will default to the item extent
* but can be overwritten by enrichments from the Hub API (inline)
* or fetched from a location such as /resources/boundary.json
*/
boundary?: IHubGeography;
// TODO: Change to use mdJSON translation for configurable metadata?
/** Additional metadata from custom/formal elements */
metadata?: any;
// Unique or additional formal metadata that will be displayed in sidebar
}
/**
* Properties that are common to all Hub content types (dataset, map, document, etc)
*
* @export
* @interface IHubContent
* @extends {IHubResource,IItem}
*/
export interface IHubContent extends IHubResource, IItem {
/**
* The content's ID for use with the Hub API
*/
hubId: string;
// NOTE: we may want to elevate this to IHubResource if it's needed for other subtypes
/**
* Content visibility and access control, including groups
*/
permissions: {
/** Visibility of the content */
visibility: Visibility;
/** Current user's control over the content */
control?: AccessControl;
/** The groups that have access to the item (as far as you know) */
groups?: IGroup[]; // TODO: item.sharing.groups via content/users/:username/items/:id
};
// TODO: license: IHubLicense // [Future] item.licenseInfo
/**
* Date the content was published (formal metadata),
* defaults to the date the content was created
*/
publishedDate: Date;
/** Description of the source of the published date */
publishedDateSource?: string;
// Hub configuration metadata
/** Optional links to show in the Hub application for this content */
actionLinks?: IActionLink[];
/** Configure which Hub application actions (i.e. create web map) are available for this content */
hubActions?: object;
metrics?: {
/** Visibility of the metrics for this content in the Hub application */
visibility: Visibility | "updateGroups";
};
/** The content's unique URL slug in the Hub app */
slug?: string;
/** URL of the Portal API data endpoint for the resource */
portalDataUrl?: string;
}
interface IActionLink {
/** Link title */
title: string;
/** Link URL */
url: string;
}