@eskais/app-sdk 0.0.0-stage → 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +68 -2
- package/dist/action/action.d.ts +74 -0
- package/dist/action/action.js +106 -0
- package/dist/cli/cli.d.ts +2 -0
- package/dist/cli/cli.js +51 -0
- package/dist/cli/routes.d.ts +17 -0
- package/dist/cli/routes.js +36 -0
- package/dist/core/assume.d.ts +1 -0
- package/dist/core/assume.js +8 -0
- package/dist/core/constants.d.ts +302 -0
- package/dist/core/constants.js +156 -0
- package/dist/core/contracts.d.ts +100 -0
- package/dist/core/contracts.js +3 -0
- package/dist/core/data-labels.d.ts +196 -0
- package/dist/core/data-labels.js +345 -0
- package/dist/core/errors.d.ts +46 -0
- package/dist/core/errors.js +166 -0
- package/dist/core/guards.d.ts +9 -0
- package/dist/core/guards.js +14 -0
- package/dist/core/refusal.d.ts +30 -0
- package/dist/core/refusal.js +53 -0
- package/dist/draft/draft.d.ts +36 -0
- package/dist/draft/draft.js +87 -0
- package/dist/export/csv.d.ts +25 -0
- package/dist/export/csv.js +59 -0
- package/dist/import/csv-parse.d.ts +11 -0
- package/dist/import/csv-parse.js +70 -0
- package/dist/import/import.d.ts +102 -0
- package/dist/import/import.js +263 -0
- package/dist/index.d.ts +31 -0
- package/dist/index.js +30 -0
- package/dist/navigation/nav.d.ts +119 -0
- package/dist/navigation/nav.js +278 -0
- package/dist/navigation/router.d.ts +81 -0
- package/dist/navigation/router.js +249 -0
- package/dist/navigation/shortcuts.d.ts +37 -0
- package/dist/navigation/shortcuts.js +93 -0
- package/dist/next/index.d.ts +3 -0
- package/dist/next/index.js +3 -0
- package/dist/next/screen-hydration.d.ts +12 -0
- package/dist/next/screen-hydration.js +26 -0
- package/dist/next/screen.d.ts +25 -0
- package/dist/next/screen.js +44 -0
- package/dist/next/server/handler.d.ts +39 -0
- package/dist/next/server/handler.js +190 -0
- package/dist/next/server/index.d.ts +5 -0
- package/dist/next/server/index.js +5 -0
- package/dist/next/server/page.d.ts +57 -0
- package/dist/next/server/page.js +103 -0
- package/dist/next/server/prefetch.d.ts +29 -0
- package/dist/next/server/prefetch.js +97 -0
- package/dist/next/server/session.d.ts +12 -0
- package/dist/next/server/session.js +10 -0
- package/dist/next/use-next-router.d.ts +21 -0
- package/dist/next/use-next-router.js +104 -0
- package/dist/react/data-layer.d.ts +31 -0
- package/dist/react/data-layer.js +31 -0
- package/dist/react/hooks/use-action.d.ts +12 -0
- package/dist/react/hooks/use-action.js +67 -0
- package/dist/react/hooks/use-better-auth.d.ts +12 -0
- package/dist/react/hooks/use-better-auth.js +11 -0
- package/dist/react/hooks/use-draft.d.ts +5 -0
- package/dist/react/hooks/use-draft.js +17 -0
- package/dist/react/hooks/use-nav.d.ts +17 -0
- package/dist/react/hooks/use-nav.js +34 -0
- package/dist/react/hooks/use-resource.d.ts +69 -0
- package/dist/react/hooks/use-resource.js +218 -0
- package/dist/react/hooks/use-view.d.ts +6 -0
- package/dist/react/hooks/use-view.js +24 -0
- package/dist/react/index.d.ts +8 -0
- package/dist/react/index.js +8 -0
- package/dist/react/keys.d.ts +51 -0
- package/dist/react/keys.js +67 -0
- package/dist/resource/form-schema.d.ts +11 -0
- package/dist/resource/form-schema.js +51 -0
- package/dist/resource/relations.d.ts +99 -0
- package/dist/resource/relations.js +194 -0
- package/dist/resource/resource-relations.d.ts +44 -0
- package/dist/resource/resource-relations.js +141 -0
- package/dist/resource/resource-schema.d.ts +9 -0
- package/dist/resource/resource-schema.js +73 -0
- package/dist/resource/resource-types.d.ts +281 -0
- package/dist/resource/resource-types.js +1 -0
- package/dist/resource/resource.d.ts +11 -0
- package/dist/resource/resource.js +354 -0
- package/dist/resource/schema.d.ts +57 -0
- package/dist/resource/schema.js +115 -0
- package/dist/services/from-page-source.d.ts +15 -0
- package/dist/services/from-page-source.js +27 -0
- package/dist/services/memory-query.d.ts +8 -0
- package/dist/services/memory-query.js +165 -0
- package/dist/services/memory-service.d.ts +33 -0
- package/dist/services/memory-service.js +291 -0
- package/dist/services/rest-service.d.ts +62 -0
- package/dist/services/rest-service.js +220 -0
- package/dist/services/rng.d.ts +9 -0
- package/dist/services/rng.js +22 -0
- package/dist/services/spring-service.d.ts +58 -0
- package/dist/services/spring-service.js +132 -0
- package/dist/session/better-auth.d.ts +83 -0
- package/dist/session/better-auth.js +86 -0
- package/dist/session/session.d.ts +45 -0
- package/dist/session/session.js +36 -0
- package/dist/view/preferences.d.ts +35 -0
- package/dist/view/preferences.js +93 -0
- package/dist/view/view-types.d.ts +122 -0
- package/dist/view/view-types.js +1 -0
- package/dist/view/view-url.d.ts +7 -0
- package/dist/view/view-url.js +54 -0
- package/dist/view/view.d.ts +4 -0
- package/dist/view/view.js +392 -0
- package/package.json +85 -4
|
@@ -0,0 +1,302 @@
|
|
|
1
|
+
export declare const SortDirection: {
|
|
2
|
+
readonly asc: "asc";
|
|
3
|
+
readonly desc: "desc";
|
|
4
|
+
};
|
|
5
|
+
export type SortDirection = (typeof SortDirection)[keyof typeof SortDirection];
|
|
6
|
+
export declare const CursorDirection: {
|
|
7
|
+
readonly forward: "forward";
|
|
8
|
+
readonly backward: "backward";
|
|
9
|
+
};
|
|
10
|
+
export type CursorDirection = (typeof CursorDirection)[keyof typeof CursorDirection];
|
|
11
|
+
export declare const PagePositionKind: {
|
|
12
|
+
readonly page: "page";
|
|
13
|
+
readonly cursor: "cursor";
|
|
14
|
+
};
|
|
15
|
+
export type PagePositionKind = (typeof PagePositionKind)[keyof typeof PagePositionKind];
|
|
16
|
+
export declare const TotalKind: {
|
|
17
|
+
readonly exact: "exact";
|
|
18
|
+
readonly estimate: "estimate";
|
|
19
|
+
readonly none: "none";
|
|
20
|
+
};
|
|
21
|
+
export type TotalKind = (typeof TotalKind)[keyof typeof TotalKind];
|
|
22
|
+
export declare const ServiceErrorKind: {
|
|
23
|
+
readonly validation: "validation";
|
|
24
|
+
readonly conflict: "conflict";
|
|
25
|
+
readonly forbidden: "forbidden";
|
|
26
|
+
readonly notFound: "not-found";
|
|
27
|
+
readonly network: "network";
|
|
28
|
+
readonly server: "server";
|
|
29
|
+
readonly aborted: "aborted";
|
|
30
|
+
};
|
|
31
|
+
export type ServiceErrorKind = (typeof ServiceErrorKind)[keyof typeof ServiceErrorKind];
|
|
32
|
+
export declare const TargetKind: {
|
|
33
|
+
readonly ids: "ids";
|
|
34
|
+
readonly query: "query";
|
|
35
|
+
};
|
|
36
|
+
export type TargetKind = (typeof TargetKind)[keyof typeof TargetKind];
|
|
37
|
+
export declare const ActionTargetKind: {
|
|
38
|
+
readonly none: "none";
|
|
39
|
+
readonly row: "row";
|
|
40
|
+
readonly rows: "rows";
|
|
41
|
+
readonly query: "query";
|
|
42
|
+
};
|
|
43
|
+
export type ActionTargetKind = (typeof ActionTargetKind)[keyof typeof ActionTargetKind];
|
|
44
|
+
export declare const ResourceAction: {
|
|
45
|
+
readonly list: "list";
|
|
46
|
+
readonly get: "get";
|
|
47
|
+
readonly create: "create";
|
|
48
|
+
readonly update: "update";
|
|
49
|
+
readonly remove: "remove";
|
|
50
|
+
readonly restore: "restore";
|
|
51
|
+
readonly export: "export";
|
|
52
|
+
readonly import: "import";
|
|
53
|
+
};
|
|
54
|
+
export type ResourceAction = (typeof ResourceAction)[keyof typeof ResourceAction];
|
|
55
|
+
export declare const ColumnKind: {
|
|
56
|
+
readonly text: "text";
|
|
57
|
+
readonly number: "number";
|
|
58
|
+
readonly currency: "currency";
|
|
59
|
+
readonly date: "date";
|
|
60
|
+
readonly datetime: "datetime";
|
|
61
|
+
readonly relativeTime: "relativeTime";
|
|
62
|
+
readonly boolean: "boolean";
|
|
63
|
+
readonly status: "status";
|
|
64
|
+
readonly badge: "badge";
|
|
65
|
+
readonly avatar: "avatar";
|
|
66
|
+
readonly link: "link";
|
|
67
|
+
readonly tags: "tags";
|
|
68
|
+
};
|
|
69
|
+
export type ColumnKind = (typeof ColumnKind)[keyof typeof ColumnKind];
|
|
70
|
+
export declare const FieldKind: {
|
|
71
|
+
readonly text: "text";
|
|
72
|
+
readonly textarea: "textarea";
|
|
73
|
+
readonly email: "email";
|
|
74
|
+
readonly password: "password";
|
|
75
|
+
readonly number: "number";
|
|
76
|
+
readonly currency: "currency";
|
|
77
|
+
readonly date: "date";
|
|
78
|
+
readonly datetime: "datetime";
|
|
79
|
+
readonly time: "time";
|
|
80
|
+
readonly duration: "duration";
|
|
81
|
+
readonly select: "select";
|
|
82
|
+
readonly radio: "radio";
|
|
83
|
+
readonly checkbox: "checkbox";
|
|
84
|
+
readonly switch: "switch";
|
|
85
|
+
readonly tags: "tags";
|
|
86
|
+
readonly color: "color";
|
|
87
|
+
readonly file: "file";
|
|
88
|
+
readonly image: "image";
|
|
89
|
+
readonly markdown: "markdown";
|
|
90
|
+
readonly resource: "resource";
|
|
91
|
+
readonly rows: "rows";
|
|
92
|
+
readonly object: "object";
|
|
93
|
+
};
|
|
94
|
+
export type FieldKind = (typeof FieldKind)[keyof typeof FieldKind];
|
|
95
|
+
export declare const FilterKind: {
|
|
96
|
+
readonly select: "select";
|
|
97
|
+
readonly multiSelect: "multiSelect";
|
|
98
|
+
readonly resource: "resource";
|
|
99
|
+
readonly dateRange: "dateRange";
|
|
100
|
+
readonly numberRange: "numberRange";
|
|
101
|
+
readonly boolean: "boolean";
|
|
102
|
+
readonly search: "search";
|
|
103
|
+
};
|
|
104
|
+
export type FilterKind = (typeof FilterKind)[keyof typeof FilterKind];
|
|
105
|
+
export declare const Align: {
|
|
106
|
+
readonly start: "start";
|
|
107
|
+
readonly end: "end";
|
|
108
|
+
};
|
|
109
|
+
export type Align = (typeof Align)[keyof typeof Align];
|
|
110
|
+
export declare const MobileSlot: {
|
|
111
|
+
readonly title: "title";
|
|
112
|
+
readonly description: "description";
|
|
113
|
+
readonly meta: "meta";
|
|
114
|
+
};
|
|
115
|
+
export type MobileSlot = (typeof MobileSlot)[keyof typeof MobileSlot];
|
|
116
|
+
export declare const FormStage: {
|
|
117
|
+
readonly create: "create";
|
|
118
|
+
readonly edit: "edit";
|
|
119
|
+
};
|
|
120
|
+
export type FormStage = (typeof FormStage)[keyof typeof FormStage];
|
|
121
|
+
export declare const ActionScope: {
|
|
122
|
+
readonly row: "row";
|
|
123
|
+
readonly bulk: "bulk";
|
|
124
|
+
readonly global: "global";
|
|
125
|
+
};
|
|
126
|
+
export type ActionScope = (typeof ActionScope)[keyof typeof ActionScope];
|
|
127
|
+
export declare const Concurrency: {
|
|
128
|
+
readonly block: "block";
|
|
129
|
+
readonly switch: "switch";
|
|
130
|
+
readonly queue: "queue";
|
|
131
|
+
};
|
|
132
|
+
export type Concurrency = (typeof Concurrency)[keyof typeof Concurrency];
|
|
133
|
+
export declare const SelectionMode: {
|
|
134
|
+
readonly none: "none";
|
|
135
|
+
readonly single: "single";
|
|
136
|
+
readonly multiple: "multiple";
|
|
137
|
+
};
|
|
138
|
+
export type SelectionMode = (typeof SelectionMode)[keyof typeof SelectionMode];
|
|
139
|
+
export declare const SelectionKind: {
|
|
140
|
+
readonly ids: "ids";
|
|
141
|
+
readonly query: "query";
|
|
142
|
+
};
|
|
143
|
+
export type SelectionKind = (typeof SelectionKind)[keyof typeof SelectionKind];
|
|
144
|
+
export declare const DraftPersist: {
|
|
145
|
+
readonly memory: "memory";
|
|
146
|
+
readonly local: "local";
|
|
147
|
+
};
|
|
148
|
+
export type DraftPersist = (typeof DraftPersist)[keyof typeof DraftPersist];
|
|
149
|
+
export declare const FlowPersist: {
|
|
150
|
+
readonly url: "url";
|
|
151
|
+
readonly local: "local";
|
|
152
|
+
};
|
|
153
|
+
export type FlowPersist = (typeof FlowPersist)[keyof typeof FlowPersist];
|
|
154
|
+
export declare const FileFormat: {
|
|
155
|
+
readonly csv: "csv";
|
|
156
|
+
readonly xlsx: "xlsx";
|
|
157
|
+
};
|
|
158
|
+
export type FileFormat = (typeof FileFormat)[keyof typeof FileFormat];
|
|
159
|
+
export declare const ImportMode: {
|
|
160
|
+
readonly create: "create";
|
|
161
|
+
readonly upsert: "upsert";
|
|
162
|
+
};
|
|
163
|
+
export type ImportMode = (typeof ImportMode)[keyof typeof ImportMode];
|
|
164
|
+
export declare const JobState: {
|
|
165
|
+
readonly queued: "queued";
|
|
166
|
+
readonly running: "running";
|
|
167
|
+
readonly done: "done";
|
|
168
|
+
readonly failed: "failed";
|
|
169
|
+
readonly cancelled: "cancelled";
|
|
170
|
+
};
|
|
171
|
+
export type JobState = (typeof JobState)[keyof typeof JobState];
|
|
172
|
+
export declare const LiveEventType: {
|
|
173
|
+
readonly created: "created";
|
|
174
|
+
readonly updated: "updated";
|
|
175
|
+
readonly removed: "removed";
|
|
176
|
+
readonly restored: "restored";
|
|
177
|
+
readonly invalidate: "invalidate";
|
|
178
|
+
};
|
|
179
|
+
export type LiveEventType = (typeof LiveEventType)[keyof typeof LiveEventType];
|
|
180
|
+
export declare const MetricCompare: {
|
|
181
|
+
readonly previous: "previous";
|
|
182
|
+
readonly year: "year";
|
|
183
|
+
};
|
|
184
|
+
export type MetricCompare = (typeof MetricCompare)[keyof typeof MetricCompare];
|
|
185
|
+
export declare const SettingsSave: {
|
|
186
|
+
readonly section: "section";
|
|
187
|
+
readonly field: "field";
|
|
188
|
+
};
|
|
189
|
+
export type SettingsSave = (typeof SettingsSave)[keyof typeof SettingsSave];
|
|
190
|
+
export declare const NavMatch: {
|
|
191
|
+
readonly exact: "exact";
|
|
192
|
+
readonly prefix: "prefix";
|
|
193
|
+
};
|
|
194
|
+
export type NavMatch = (typeof NavMatch)[keyof typeof NavMatch];
|
|
195
|
+
export declare const RouterKind: {
|
|
196
|
+
readonly tanstack: "tanstack";
|
|
197
|
+
readonly hash: "hash";
|
|
198
|
+
readonly history: "history";
|
|
199
|
+
readonly memory: "memory";
|
|
200
|
+
readonly react: "react";
|
|
201
|
+
readonly next: "next";
|
|
202
|
+
};
|
|
203
|
+
export type RouterKind = (typeof RouterKind)[keyof typeof RouterKind];
|
|
204
|
+
export declare const VersionRead: {
|
|
205
|
+
readonly etag: "etag";
|
|
206
|
+
readonly field: "field";
|
|
207
|
+
};
|
|
208
|
+
export type VersionRead = (typeof VersionRead)[keyof typeof VersionRead];
|
|
209
|
+
export declare const VersionSend: {
|
|
210
|
+
readonly ifMatch: "ifMatch";
|
|
211
|
+
readonly field: "field";
|
|
212
|
+
};
|
|
213
|
+
export type VersionSend = (typeof VersionSend)[keyof typeof VersionSend];
|
|
214
|
+
export declare const ResourceFormMode: {
|
|
215
|
+
readonly inline: "inline";
|
|
216
|
+
readonly dialog: "dialog";
|
|
217
|
+
readonly drawer: "drawer";
|
|
218
|
+
readonly page: "page";
|
|
219
|
+
};
|
|
220
|
+
export type ResourceFormMode = (typeof ResourceFormMode)[keyof typeof ResourceFormMode];
|
|
221
|
+
export declare const ResourceDetailMode: {
|
|
222
|
+
readonly page: "page";
|
|
223
|
+
readonly drawer: "drawer";
|
|
224
|
+
};
|
|
225
|
+
export type ResourceDetailMode = (typeof ResourceDetailMode)[keyof typeof ResourceDetailMode];
|
|
226
|
+
export declare const RelationKind: {
|
|
227
|
+
readonly belongsTo: "belongsTo";
|
|
228
|
+
readonly hasMany: "hasMany";
|
|
229
|
+
readonly manyToMany: "manyToMany";
|
|
230
|
+
readonly embeds: "embeds";
|
|
231
|
+
};
|
|
232
|
+
export type RelationKind = (typeof RelationKind)[keyof typeof RelationKind];
|
|
233
|
+
/** What a relation shows when the session can't read its resource: the raw id, or nothing (the column hides). */
|
|
234
|
+
export declare const RelationDenied: {
|
|
235
|
+
readonly showId: "show-id";
|
|
236
|
+
readonly hide: "hide";
|
|
237
|
+
};
|
|
238
|
+
export type RelationDenied = (typeof RelationDenied)[keyof typeof RelationDenied];
|
|
239
|
+
/** Where a `hasMany` is edited: a tab of its own with a table and a path, or rows inside the form. */
|
|
240
|
+
export declare const RowsMode: {
|
|
241
|
+
readonly tab: "tab";
|
|
242
|
+
readonly inline: "inline";
|
|
243
|
+
};
|
|
244
|
+
export type RowsMode = (typeof RowsMode)[keyof typeof RowsMode];
|
|
245
|
+
/** How `ResourceCombobox` creates what's typed: straight from the text, or in a quick-create form. */
|
|
246
|
+
export declare const CreateMode: {
|
|
247
|
+
readonly text: "text";
|
|
248
|
+
readonly form: "form";
|
|
249
|
+
};
|
|
250
|
+
export type CreateMode = (typeof CreateMode)[keyof typeof CreateMode];
|
|
251
|
+
export declare const FormLayout: {
|
|
252
|
+
readonly stack: "stack";
|
|
253
|
+
readonly grid: "grid";
|
|
254
|
+
};
|
|
255
|
+
export type FormLayout = (typeof FormLayout)[keyof typeof FormLayout];
|
|
256
|
+
export declare const ReadAll: {
|
|
257
|
+
readonly all: "all";
|
|
258
|
+
};
|
|
259
|
+
export type ReadAll = (typeof ReadAll)[keyof typeof ReadAll];
|
|
260
|
+
export declare const ResourceScreen: {
|
|
261
|
+
readonly list: "list";
|
|
262
|
+
readonly create: "create";
|
|
263
|
+
readonly detail: "detail";
|
|
264
|
+
readonly edit: "edit";
|
|
265
|
+
};
|
|
266
|
+
export type ResourceScreen = (typeof ResourceScreen)[keyof typeof ResourceScreen];
|
|
267
|
+
export declare const ValueType: {
|
|
268
|
+
readonly string: "string";
|
|
269
|
+
readonly number: "number";
|
|
270
|
+
readonly boolean: "boolean";
|
|
271
|
+
readonly object: "object";
|
|
272
|
+
readonly function: "function";
|
|
273
|
+
readonly undefined: "undefined";
|
|
274
|
+
readonly bigint: "bigint";
|
|
275
|
+
};
|
|
276
|
+
export type ValueType = (typeof ValueType)[keyof typeof ValueType];
|
|
277
|
+
export declare const JsonType: {
|
|
278
|
+
readonly string: "string";
|
|
279
|
+
readonly number: "number";
|
|
280
|
+
readonly integer: "integer";
|
|
281
|
+
readonly boolean: "boolean";
|
|
282
|
+
readonly array: "array";
|
|
283
|
+
readonly object: "object";
|
|
284
|
+
readonly null: "null";
|
|
285
|
+
};
|
|
286
|
+
export type JsonType = (typeof JsonType)[keyof typeof JsonType];
|
|
287
|
+
export declare const JsonFormat: {
|
|
288
|
+
readonly email: "email";
|
|
289
|
+
readonly uri: "uri";
|
|
290
|
+
readonly url: "url";
|
|
291
|
+
readonly uuid: "uuid";
|
|
292
|
+
readonly date: "date";
|
|
293
|
+
readonly dateTime: "date-time";
|
|
294
|
+
readonly time: "time";
|
|
295
|
+
readonly duration: "duration";
|
|
296
|
+
};
|
|
297
|
+
export type JsonFormat = (typeof JsonFormat)[keyof typeof JsonFormat];
|
|
298
|
+
export declare const RefusalKind: {
|
|
299
|
+
readonly refused: "refused";
|
|
300
|
+
readonly unavailable: "unavailable";
|
|
301
|
+
};
|
|
302
|
+
export type RefusalKind = (typeof RefusalKind)[keyof typeof RefusalKind];
|
|
@@ -0,0 +1,156 @@
|
|
|
1
|
+
export const SortDirection = { asc: "asc", desc: "desc" };
|
|
2
|
+
export const CursorDirection = { forward: "forward", backward: "backward" };
|
|
3
|
+
export const PagePositionKind = { page: "page", cursor: "cursor" };
|
|
4
|
+
export const TotalKind = { exact: "exact", estimate: "estimate", none: "none" };
|
|
5
|
+
export const ServiceErrorKind = {
|
|
6
|
+
validation: "validation",
|
|
7
|
+
conflict: "conflict",
|
|
8
|
+
forbidden: "forbidden",
|
|
9
|
+
notFound: "not-found",
|
|
10
|
+
network: "network",
|
|
11
|
+
server: "server",
|
|
12
|
+
aborted: "aborted",
|
|
13
|
+
};
|
|
14
|
+
export const TargetKind = { ids: "ids", query: "query" };
|
|
15
|
+
export const ActionTargetKind = { none: "none", row: "row", rows: "rows", query: "query" };
|
|
16
|
+
export const ResourceAction = {
|
|
17
|
+
list: "list",
|
|
18
|
+
get: "get",
|
|
19
|
+
create: "create",
|
|
20
|
+
update: "update",
|
|
21
|
+
remove: "remove",
|
|
22
|
+
restore: "restore",
|
|
23
|
+
export: "export",
|
|
24
|
+
import: "import",
|
|
25
|
+
};
|
|
26
|
+
export const ColumnKind = {
|
|
27
|
+
text: "text",
|
|
28
|
+
number: "number",
|
|
29
|
+
currency: "currency",
|
|
30
|
+
date: "date",
|
|
31
|
+
datetime: "datetime",
|
|
32
|
+
relativeTime: "relativeTime",
|
|
33
|
+
boolean: "boolean",
|
|
34
|
+
status: "status",
|
|
35
|
+
badge: "badge",
|
|
36
|
+
avatar: "avatar",
|
|
37
|
+
link: "link",
|
|
38
|
+
tags: "tags",
|
|
39
|
+
};
|
|
40
|
+
export const FieldKind = {
|
|
41
|
+
text: "text",
|
|
42
|
+
textarea: "textarea",
|
|
43
|
+
email: "email",
|
|
44
|
+
password: "password",
|
|
45
|
+
number: "number",
|
|
46
|
+
currency: "currency",
|
|
47
|
+
date: "date",
|
|
48
|
+
datetime: "datetime",
|
|
49
|
+
time: "time",
|
|
50
|
+
duration: "duration",
|
|
51
|
+
select: "select",
|
|
52
|
+
radio: "radio",
|
|
53
|
+
checkbox: "checkbox",
|
|
54
|
+
switch: "switch",
|
|
55
|
+
tags: "tags",
|
|
56
|
+
color: "color",
|
|
57
|
+
file: "file",
|
|
58
|
+
image: "image",
|
|
59
|
+
markdown: "markdown",
|
|
60
|
+
resource: "resource",
|
|
61
|
+
rows: "rows",
|
|
62
|
+
object: "object",
|
|
63
|
+
};
|
|
64
|
+
export const FilterKind = {
|
|
65
|
+
select: "select",
|
|
66
|
+
multiSelect: "multiSelect",
|
|
67
|
+
resource: "resource",
|
|
68
|
+
dateRange: "dateRange",
|
|
69
|
+
numberRange: "numberRange",
|
|
70
|
+
boolean: "boolean",
|
|
71
|
+
search: "search",
|
|
72
|
+
};
|
|
73
|
+
export const Align = { start: "start", end: "end" };
|
|
74
|
+
export const MobileSlot = { title: "title", description: "description", meta: "meta" };
|
|
75
|
+
export const FormStage = { create: "create", edit: "edit" };
|
|
76
|
+
export const ActionScope = { row: "row", bulk: "bulk", global: "global" };
|
|
77
|
+
export const Concurrency = { block: "block", switch: "switch", queue: "queue" };
|
|
78
|
+
export const SelectionMode = { none: "none", single: "single", multiple: "multiple" };
|
|
79
|
+
export const SelectionKind = { ids: "ids", query: "query" };
|
|
80
|
+
export const DraftPersist = { memory: "memory", local: "local" };
|
|
81
|
+
export const FlowPersist = { url: "url", local: "local" };
|
|
82
|
+
export const FileFormat = { csv: "csv", xlsx: "xlsx" };
|
|
83
|
+
export const ImportMode = { create: "create", upsert: "upsert" };
|
|
84
|
+
export const JobState = {
|
|
85
|
+
queued: "queued",
|
|
86
|
+
running: "running",
|
|
87
|
+
done: "done",
|
|
88
|
+
failed: "failed",
|
|
89
|
+
cancelled: "cancelled",
|
|
90
|
+
};
|
|
91
|
+
export const LiveEventType = {
|
|
92
|
+
created: "created",
|
|
93
|
+
updated: "updated",
|
|
94
|
+
removed: "removed",
|
|
95
|
+
restored: "restored",
|
|
96
|
+
invalidate: "invalidate",
|
|
97
|
+
};
|
|
98
|
+
export const MetricCompare = { previous: "previous", year: "year" };
|
|
99
|
+
export const SettingsSave = { section: "section", field: "field" };
|
|
100
|
+
export const NavMatch = { exact: "exact", prefix: "prefix" };
|
|
101
|
+
export const RouterKind = {
|
|
102
|
+
tanstack: "tanstack",
|
|
103
|
+
hash: "hash",
|
|
104
|
+
history: "history",
|
|
105
|
+
memory: "memory",
|
|
106
|
+
react: "react",
|
|
107
|
+
next: "next",
|
|
108
|
+
};
|
|
109
|
+
export const VersionRead = { etag: "etag", field: "field" };
|
|
110
|
+
export const VersionSend = { ifMatch: "ifMatch", field: "field" };
|
|
111
|
+
export const ResourceFormMode = { inline: "inline", dialog: "dialog", drawer: "drawer", page: "page" };
|
|
112
|
+
export const ResourceDetailMode = { page: "page", drawer: "drawer" };
|
|
113
|
+
export const RelationKind = {
|
|
114
|
+
belongsTo: "belongsTo",
|
|
115
|
+
hasMany: "hasMany",
|
|
116
|
+
manyToMany: "manyToMany",
|
|
117
|
+
embeds: "embeds",
|
|
118
|
+
};
|
|
119
|
+
/** What a relation shows when the session can't read its resource: the raw id, or nothing (the column hides). */
|
|
120
|
+
export const RelationDenied = { showId: "show-id", hide: "hide" };
|
|
121
|
+
/** Where a `hasMany` is edited: a tab of its own with a table and a path, or rows inside the form. */
|
|
122
|
+
export const RowsMode = { tab: "tab", inline: "inline" };
|
|
123
|
+
/** How `ResourceCombobox` creates what's typed: straight from the text, or in a quick-create form. */
|
|
124
|
+
export const CreateMode = { text: "text", form: "form" };
|
|
125
|
+
export const FormLayout = { stack: "stack", grid: "grid" };
|
|
126
|
+
export const ReadAll = { all: "all" };
|
|
127
|
+
export const ResourceScreen = { list: "list", create: "create", detail: "detail", edit: "edit" };
|
|
128
|
+
export const ValueType = {
|
|
129
|
+
string: "string",
|
|
130
|
+
number: "number",
|
|
131
|
+
boolean: "boolean",
|
|
132
|
+
object: "object",
|
|
133
|
+
function: "function",
|
|
134
|
+
undefined: "undefined",
|
|
135
|
+
bigint: "bigint",
|
|
136
|
+
};
|
|
137
|
+
export const JsonType = {
|
|
138
|
+
string: "string",
|
|
139
|
+
number: "number",
|
|
140
|
+
integer: "integer",
|
|
141
|
+
boolean: "boolean",
|
|
142
|
+
array: "array",
|
|
143
|
+
object: "object",
|
|
144
|
+
null: "null",
|
|
145
|
+
};
|
|
146
|
+
export const JsonFormat = {
|
|
147
|
+
email: "email",
|
|
148
|
+
uri: "uri",
|
|
149
|
+
url: "url",
|
|
150
|
+
uuid: "uuid",
|
|
151
|
+
date: "date",
|
|
152
|
+
dateTime: "date-time",
|
|
153
|
+
time: "time",
|
|
154
|
+
duration: "duration",
|
|
155
|
+
};
|
|
156
|
+
export const RefusalKind = { refused: "refused", unavailable: "unavailable" };
|
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
import type { CursorDirection, FileFormat, PagePositionKind, SortDirection, TargetKind, TotalKind } from "./constants.js";
|
|
2
|
+
import type { Session } from "../session/session.js";
|
|
3
|
+
export type CallContext = {
|
|
4
|
+
signal: AbortSignal;
|
|
5
|
+
session?: Session | undefined;
|
|
6
|
+
};
|
|
7
|
+
export type SortSpec = {
|
|
8
|
+
field: string;
|
|
9
|
+
direction: SortDirection;
|
|
10
|
+
};
|
|
11
|
+
export type PagePosition = {
|
|
12
|
+
page: number;
|
|
13
|
+
} | {
|
|
14
|
+
cursor: string | null;
|
|
15
|
+
direction: CursorDirection;
|
|
16
|
+
};
|
|
17
|
+
export type Query<F = Record<string, unknown>> = {
|
|
18
|
+
filter: F;
|
|
19
|
+
search?: string | undefined;
|
|
20
|
+
sort: readonly SortSpec[];
|
|
21
|
+
size: number;
|
|
22
|
+
position: PagePosition;
|
|
23
|
+
/**
|
|
24
|
+
* Relations the screen shows (`customer`, `tags`), so a server that can embeds them in the page (a JOIN, Prisma's
|
|
25
|
+
* `include`, Mongo's `$lookup`). Services may ignore it: the rest is read in batches.
|
|
26
|
+
*/
|
|
27
|
+
include?: readonly string[] | undefined;
|
|
28
|
+
};
|
|
29
|
+
export type Page<T> = {
|
|
30
|
+
items: T[];
|
|
31
|
+
total?: number;
|
|
32
|
+
totalEstimate?: number;
|
|
33
|
+
hasMore?: boolean;
|
|
34
|
+
hasPrevious?: boolean;
|
|
35
|
+
nextCursor?: string | null;
|
|
36
|
+
prevCursor?: string | null;
|
|
37
|
+
};
|
|
38
|
+
export type SourceCapabilities = {
|
|
39
|
+
position: PagePositionKind;
|
|
40
|
+
total?: TotalKind;
|
|
41
|
+
maxPageSize?: number;
|
|
42
|
+
/** The most ids one `getMany` takes (Firestore's `in` 30, DynamoDB's BatchGetItem 100); unlimited by default. */
|
|
43
|
+
batchSize?: number;
|
|
44
|
+
/** Sorts by a related record's field (`sort=customer.name`), like a JOIN does; off by default. */
|
|
45
|
+
relationSort?: boolean;
|
|
46
|
+
};
|
|
47
|
+
export type Version = string | number;
|
|
48
|
+
export type Target<Id, F> = {
|
|
49
|
+
kind: typeof TargetKind.ids;
|
|
50
|
+
ids: readonly Id[];
|
|
51
|
+
} | {
|
|
52
|
+
kind: typeof TargetKind.query;
|
|
53
|
+
filter: F;
|
|
54
|
+
search?: string | undefined;
|
|
55
|
+
except: readonly Id[];
|
|
56
|
+
};
|
|
57
|
+
export type ResourceCapabilities = SourceCapabilities & {
|
|
58
|
+
restore?: boolean;
|
|
59
|
+
versioned?: boolean;
|
|
60
|
+
bulkByQuery?: boolean;
|
|
61
|
+
};
|
|
62
|
+
export type ExportResult = {
|
|
63
|
+
download: string;
|
|
64
|
+
} | {
|
|
65
|
+
job: string;
|
|
66
|
+
};
|
|
67
|
+
export interface ResourceService<T, Id = string, F = Record<string, unknown>, Create = Partial<T>, Update = Partial<T>> {
|
|
68
|
+
capabilities: ResourceCapabilities;
|
|
69
|
+
list(query: Query<F>, context: CallContext): Promise<Page<T>>;
|
|
70
|
+
count?(filter: F, context: CallContext): Promise<number>;
|
|
71
|
+
get(id: Id, context: CallContext): Promise<T>;
|
|
72
|
+
getMany?(ids: readonly Id[], context: CallContext): Promise<T[]>;
|
|
73
|
+
create(input: Create, context: CallContext): Promise<T>;
|
|
74
|
+
update(id: Id, patch: Update, context: CallContext & {
|
|
75
|
+
version?: Version | undefined;
|
|
76
|
+
}): Promise<T>;
|
|
77
|
+
remove(target: Target<Id, F>, context: CallContext): Promise<void>;
|
|
78
|
+
restore?(target: Target<Id, F>, context: CallContext): Promise<void>;
|
|
79
|
+
export?(query: Query<F>, format: FileFormat, context: CallContext): Promise<ExportResult>;
|
|
80
|
+
versionOf?(row: T): Version | undefined;
|
|
81
|
+
}
|
|
82
|
+
export type PageSourceLike<T, F> = {
|
|
83
|
+
key: readonly unknown[];
|
|
84
|
+
getId(item: T): string;
|
|
85
|
+
capabilities: SourceCapabilities;
|
|
86
|
+
fetchPage(request: {
|
|
87
|
+
filter: F;
|
|
88
|
+
sort: readonly SortSpec[];
|
|
89
|
+
size: number;
|
|
90
|
+
position: PagePosition;
|
|
91
|
+
}, context: {
|
|
92
|
+
signal: AbortSignal;
|
|
93
|
+
}): Promise<Page<T>>;
|
|
94
|
+
fetchTotal?(filter: F, context: {
|
|
95
|
+
signal: AbortSignal;
|
|
96
|
+
}): Promise<number>;
|
|
97
|
+
};
|
|
98
|
+
export declare function isPagePosition(position: PagePosition): position is {
|
|
99
|
+
page: number;
|
|
100
|
+
};
|