@stoker-platform/types 0.2.1
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/package.json +32 -0
- package/src/main.ts +2 -0
- package/src/types/app.ts +405 -0
- package/src/types/schema.ts +1074 -0
package/package.json
ADDED
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@stoker-platform/types",
|
|
3
|
+
"publishConfig": {
|
|
4
|
+
"access": "restricted"
|
|
5
|
+
},
|
|
6
|
+
"version": "0.2.1",
|
|
7
|
+
"type": "module",
|
|
8
|
+
"license": "UNLICENSED",
|
|
9
|
+
"main": "src/main.ts",
|
|
10
|
+
"types": "src/main.ts",
|
|
11
|
+
"files": [
|
|
12
|
+
"src"
|
|
13
|
+
],
|
|
14
|
+
"scripts": {
|
|
15
|
+
"lint": "eslint .",
|
|
16
|
+
"test": "echo \"Error: no test specified\""
|
|
17
|
+
},
|
|
18
|
+
"devDependencies": {
|
|
19
|
+
"eslint-config-custom": "*",
|
|
20
|
+
"tsconfig": "*"
|
|
21
|
+
},
|
|
22
|
+
"engines": {
|
|
23
|
+
"node": "22",
|
|
24
|
+
"npm": "11"
|
|
25
|
+
},
|
|
26
|
+
"dependencies": {
|
|
27
|
+
"@fullcalendar/core": "^6.1.19",
|
|
28
|
+
"@google-cloud/storage": "^7.18.0",
|
|
29
|
+
"firebase": "^12.6.0",
|
|
30
|
+
"firebase-admin": "^13.6.0"
|
|
31
|
+
}
|
|
32
|
+
}
|
package/src/main.ts
ADDED
package/src/types/app.ts
ADDED
|
@@ -0,0 +1,405 @@
|
|
|
1
|
+
import type {
|
|
2
|
+
CollectionAdminCache,
|
|
3
|
+
CollectionCustomCache,
|
|
4
|
+
CollectionCustomization,
|
|
5
|
+
CollectionsSchema,
|
|
6
|
+
PostFileAddHook,
|
|
7
|
+
PostFileUpdateHook,
|
|
8
|
+
PostOperationHook,
|
|
9
|
+
PostReadHook,
|
|
10
|
+
PostWriteErrorHook,
|
|
11
|
+
PostWriteHook,
|
|
12
|
+
PreDuplicateHook,
|
|
13
|
+
PreFileAddHook,
|
|
14
|
+
PreFileUpdateHook,
|
|
15
|
+
PreOperationHook,
|
|
16
|
+
PreReadHook,
|
|
17
|
+
PreValidateHook,
|
|
18
|
+
PreWriteHook,
|
|
19
|
+
RoleGroup,
|
|
20
|
+
StokerCollection,
|
|
21
|
+
StokerPermissions,
|
|
22
|
+
StokerRole,
|
|
23
|
+
} from "./schema"
|
|
24
|
+
|
|
25
|
+
import type { Auth, ParsedToken, User } from "firebase/auth"
|
|
26
|
+
import type { Firestore, Timestamp, WhereFilterOp } from "firebase/firestore"
|
|
27
|
+
import type { AnalyticsSettings, ConsentSettings } from "firebase/analytics"
|
|
28
|
+
import type { AppCheck } from "firebase/app-check"
|
|
29
|
+
|
|
30
|
+
import type { FieldValue } from "firebase-admin/firestore"
|
|
31
|
+
import { FirebaseError } from "firebase-admin"
|
|
32
|
+
|
|
33
|
+
export interface AuthConfig {
|
|
34
|
+
enableMultiFactorAuth: boolean | StokerRole[]
|
|
35
|
+
authPersistenceType:
|
|
36
|
+
| "LOCAL"
|
|
37
|
+
| "SESSION"
|
|
38
|
+
| "NONE"
|
|
39
|
+
| (() => "LOCAL" | "SESSION" | "NONE" | Promise<"LOCAL" | "SESSION" | "NONE">)
|
|
40
|
+
signOutOnPermissionsChange?: boolean
|
|
41
|
+
clearPersistenceOnSignOut?: boolean
|
|
42
|
+
offlinePersistenceType:
|
|
43
|
+
| "ALL"
|
|
44
|
+
| "WRITE"
|
|
45
|
+
| "NONE"
|
|
46
|
+
| ((user: User, claims: ParsedToken) => "ALL" | "WRITE" | "NONE" | Promise<"ALL" | "WRITE" | "NONE">)
|
|
47
|
+
tabManager?: "SINGLE" | "MULTI"
|
|
48
|
+
garbageCollectionStrategy?: "LRU" | "EAGER"
|
|
49
|
+
maxCacheSize?: number
|
|
50
|
+
maxWriteCacheSize?: number
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
export interface FirebaseConfig {
|
|
54
|
+
enableEmulators?: boolean | (() => boolean | Promise<boolean>)
|
|
55
|
+
disableIndividualEmulators?: ("Auth" | "Database" | "Firestore" | "Storage" | "Functions")[]
|
|
56
|
+
GDPRSettings?: boolean | (() => boolean | Promise<boolean>)
|
|
57
|
+
enableAnalytics?: boolean | (() => boolean | Promise<boolean>)
|
|
58
|
+
analyticsSettings?: AnalyticsSettings | (() => AnalyticsSettings | Promise<AnalyticsSettings>)
|
|
59
|
+
analyticsConsentSettings?: ConsentSettings | (() => ConsentSettings | Promise<ConsentSettings>)
|
|
60
|
+
logLevel?: {
|
|
61
|
+
dev?: "debug" | "verbose" | "info" | "warn" | "error" | "silent"
|
|
62
|
+
prod?: "debug" | "verbose" | "info" | "warn" | "error" | "silent"
|
|
63
|
+
}
|
|
64
|
+
permissionsIndexExemption?: boolean
|
|
65
|
+
writeLogIndexExemption?: string[]
|
|
66
|
+
writeLogTTL?: number
|
|
67
|
+
serverTimestampOptions?:
|
|
68
|
+
| "none"
|
|
69
|
+
| "estimate"
|
|
70
|
+
| "previous"
|
|
71
|
+
| (() => "none" | "estimate" | "previous" | Promise<"none" | "estimate" | "previous">)
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
export interface PreloadConfig {
|
|
75
|
+
sync?: StokerCollection[] | (() => StokerCollection[] | Promise<StokerCollection[]>)
|
|
76
|
+
async?: StokerCollection[] | (() => StokerCollection[] | Promise<StokerCollection[]>)
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
export interface MailConfig {
|
|
80
|
+
emailVerification?: (
|
|
81
|
+
verificationLink: string,
|
|
82
|
+
appName?: string,
|
|
83
|
+
) => {
|
|
84
|
+
subject: string
|
|
85
|
+
html: string
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
export interface MenuGroup {
|
|
90
|
+
title: string
|
|
91
|
+
position: number
|
|
92
|
+
collections: StokerCollection[]
|
|
93
|
+
roles?: StokerRole[]
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
export interface MetaIcon {
|
|
97
|
+
rel: string
|
|
98
|
+
type: string
|
|
99
|
+
url: string
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
export interface DashboardMetric {
|
|
103
|
+
kind: "metric"
|
|
104
|
+
collection: StokerCollection
|
|
105
|
+
type: "sum" | "average" | "count"
|
|
106
|
+
field?: string
|
|
107
|
+
roles?: StokerRole[]
|
|
108
|
+
title?: string
|
|
109
|
+
decimal?: number
|
|
110
|
+
prefix?: string
|
|
111
|
+
suffix?: string
|
|
112
|
+
textSize?: "text-xl" | "text-2xl" | "text-3xl"
|
|
113
|
+
}
|
|
114
|
+
export interface DashboardChart {
|
|
115
|
+
kind: "chart"
|
|
116
|
+
collection: StokerCollection
|
|
117
|
+
type: "area"
|
|
118
|
+
dateField: string
|
|
119
|
+
metricField1?: string
|
|
120
|
+
metricField2?: string
|
|
121
|
+
defaultRange: "90d" | "30d" | "7d"
|
|
122
|
+
roles?: StokerRole[]
|
|
123
|
+
title?: string
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
export interface DashboardReminder {
|
|
127
|
+
kind: "reminder"
|
|
128
|
+
collection: StokerCollection
|
|
129
|
+
columns: string[]
|
|
130
|
+
title?: string
|
|
131
|
+
roles?: StokerRole[]
|
|
132
|
+
constraints?: [string, WhereFilterOp, unknown][]
|
|
133
|
+
sort?: {
|
|
134
|
+
field: string
|
|
135
|
+
direction: "asc" | "desc"
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
export type DashboardItem = DashboardMetric | DashboardChart | DashboardReminder
|
|
140
|
+
|
|
141
|
+
export interface Background {
|
|
142
|
+
light?: {
|
|
143
|
+
color: string
|
|
144
|
+
image?: string
|
|
145
|
+
}
|
|
146
|
+
dark?: {
|
|
147
|
+
color: string
|
|
148
|
+
image?: string
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
export interface AdminConfig {
|
|
153
|
+
access?: StokerRole[] | (() => StokerRole[])
|
|
154
|
+
background?: Background | (() => Background)
|
|
155
|
+
logo?: {
|
|
156
|
+
navbar?: string
|
|
157
|
+
login?: string
|
|
158
|
+
}
|
|
159
|
+
menu?: {
|
|
160
|
+
groups?: MenuGroup[]
|
|
161
|
+
}
|
|
162
|
+
dateFormat?: string | (() => string)
|
|
163
|
+
meta?: {
|
|
164
|
+
description?: string
|
|
165
|
+
icons?: MetaIcon[]
|
|
166
|
+
}
|
|
167
|
+
dashboard?: DashboardItem[]
|
|
168
|
+
homePage?: Record<StokerRole, StokerCollection> | (() => Record<StokerRole, StokerCollection>)
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
export type GenerateGlobalConfig = (
|
|
172
|
+
sdk: "web" | "node",
|
|
173
|
+
config?: WebUtilities | NodeUtilities,
|
|
174
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
175
|
+
context?: any,
|
|
176
|
+
) => GlobalConfig
|
|
177
|
+
|
|
178
|
+
export type Region =
|
|
179
|
+
| "asia-east1"
|
|
180
|
+
| "asia-east2"
|
|
181
|
+
| "asia-northeast1"
|
|
182
|
+
| "asia-northeast2"
|
|
183
|
+
| "asia-northeast3"
|
|
184
|
+
| "asia-south1"
|
|
185
|
+
| "asia-southeast1"
|
|
186
|
+
| "asia-southeast2"
|
|
187
|
+
| "australia-southeast1"
|
|
188
|
+
| "australia-southeast2"
|
|
189
|
+
| "europe-central2"
|
|
190
|
+
| "europe-north1"
|
|
191
|
+
| "europe-west1"
|
|
192
|
+
| "europe-west2"
|
|
193
|
+
| "europe-west3"
|
|
194
|
+
| "europe-west6"
|
|
195
|
+
| "northamerica-northeast1"
|
|
196
|
+
| "northamerica-northeast2"
|
|
197
|
+
| "southamerica-east1"
|
|
198
|
+
| "southamerica-west1"
|
|
199
|
+
| "us-central1"
|
|
200
|
+
| "us-east1"
|
|
201
|
+
| "us-east4"
|
|
202
|
+
| "us-west1"
|
|
203
|
+
| "us-west2"
|
|
204
|
+
| "us-west3"
|
|
205
|
+
| "us-west4"
|
|
206
|
+
|
|
207
|
+
export type GlobalConfig = {
|
|
208
|
+
roles: StokerRole[]
|
|
209
|
+
disabledCollections?: StokerCollection[]
|
|
210
|
+
appName: string | (() => string | Promise<string>)
|
|
211
|
+
timezone?: string | (() => string | Promise<string>)
|
|
212
|
+
auth: AuthConfig
|
|
213
|
+
firebase?: FirebaseConfig
|
|
214
|
+
preload?: PreloadConfig
|
|
215
|
+
enableUserIDLogging?: boolean | (() => boolean | Promise<boolean>)
|
|
216
|
+
mail?: MailConfig
|
|
217
|
+
preLogin?: (user: User) => boolean | void | Promise<boolean | void>
|
|
218
|
+
postLogin?: (user?: User, error?: unknown) => void | Promise<void>
|
|
219
|
+
preLogout?: (user: User) => boolean | void | Promise<boolean | void>
|
|
220
|
+
postLogout?: (errorDetails: {
|
|
221
|
+
error: boolean
|
|
222
|
+
instances: {
|
|
223
|
+
instance: "[DEFAULT]" | "firestoreWrite"
|
|
224
|
+
code: "SIGN_OUT" | "TERMINATE_APP" | "CLEAR_CACHE"
|
|
225
|
+
error: unknown
|
|
226
|
+
}[]
|
|
227
|
+
}) => void | Promise<void>
|
|
228
|
+
onVersionUpdate?: (versionInfo: VersionInfo, numberOfUpdates: number) => void | Promise<void>
|
|
229
|
+
onMaintenanceUpdate?: (status: "on" | "off") => void | Promise<void>
|
|
230
|
+
onConnectionStatusChange?: (status: "Online" | "Offline", first: boolean) => void | Promise<void>
|
|
231
|
+
onFirestoreSlowConnection?: () => void | Promise<void>
|
|
232
|
+
onFirestoreLoadFailure?: () => void | Promise<void>
|
|
233
|
+
onIndexedDBConnectionLost?: () => void | Promise<void>
|
|
234
|
+
onAppCheckTokenFailure?: (error: FirebaseError) => void | Promise<void>
|
|
235
|
+
preOperation?: PreOperationHook
|
|
236
|
+
preRead?: PreReadHook
|
|
237
|
+
postRead?: PostReadHook
|
|
238
|
+
preDuplicate?: PreDuplicateHook
|
|
239
|
+
preValidate?: PreValidateHook
|
|
240
|
+
preWrite?: PreWriteHook
|
|
241
|
+
postWrite?: PostWriteHook
|
|
242
|
+
postWriteError?: PostWriteErrorHook
|
|
243
|
+
postOperation?: PostOperationHook
|
|
244
|
+
preFileAdd?: PreFileAddHook
|
|
245
|
+
preFileUpdate?: PreFileUpdateHook
|
|
246
|
+
postFileAdd?: PostFileAddHook
|
|
247
|
+
postFileUpdate?: PostFileUpdateHook
|
|
248
|
+
admin?: AdminConfig
|
|
249
|
+
}
|
|
250
|
+
|
|
251
|
+
export interface ConfigCache {
|
|
252
|
+
global?: GlobalConfigCache
|
|
253
|
+
collections?: {
|
|
254
|
+
[collection: string]: {
|
|
255
|
+
custom?: CollectionCustomCache
|
|
256
|
+
admin?: CollectionAdminCache
|
|
257
|
+
}
|
|
258
|
+
}
|
|
259
|
+
}
|
|
260
|
+
|
|
261
|
+
export interface GlobalConfigCache {
|
|
262
|
+
roles?: StokerRole[]
|
|
263
|
+
disabledCollections?: StokerCollection[]
|
|
264
|
+
appName?: string
|
|
265
|
+
timezone?: string
|
|
266
|
+
auth?: {
|
|
267
|
+
enableMultiFactorAuth?: boolean | StokerRole[]
|
|
268
|
+
autoRefreshAppCheckToken?: boolean
|
|
269
|
+
authPersistenceType?: "LOCAL" | "SESSION" | "NONE"
|
|
270
|
+
offlinePersistenceType?: "ALL" | "WRITE" | "NONE"
|
|
271
|
+
tabManager?: "SINGLE" | "MULTI"
|
|
272
|
+
garbageCollectionStrategy?: "LRU" | "EAGER"
|
|
273
|
+
maxCacheSize?: number
|
|
274
|
+
maxWriteCacheSize?: number
|
|
275
|
+
}
|
|
276
|
+
firebase?: {
|
|
277
|
+
disableIndividualEmulators?: ("Auth" | "Database" | "Firestore" | "Storage" | "Functions")[]
|
|
278
|
+
GDPRSettings?: boolean
|
|
279
|
+
enableAnalytics?: boolean
|
|
280
|
+
analyticsSettings?: AnalyticsSettings
|
|
281
|
+
analyticsConsentSettings?: ConsentSettings
|
|
282
|
+
logLevel?: {
|
|
283
|
+
dev?: "debug" | "verbose" | "info" | "warn" | "error" | "silent"
|
|
284
|
+
prod?: "debug" | "verbose" | "info" | "warn" | "error" | "silent"
|
|
285
|
+
}
|
|
286
|
+
permissionsIndexExemption?: boolean
|
|
287
|
+
writeLogIndexExemption?: string[]
|
|
288
|
+
writeLogTTL?: number
|
|
289
|
+
serverTimestampOptions?: "none" | "estimate" | "previous"
|
|
290
|
+
}
|
|
291
|
+
preload?: {
|
|
292
|
+
sync?: StokerCollection[]
|
|
293
|
+
async?: StokerCollection[]
|
|
294
|
+
}
|
|
295
|
+
enableUserIDLogging?: boolean
|
|
296
|
+
admin?: {
|
|
297
|
+
logo?: {
|
|
298
|
+
small?: string
|
|
299
|
+
large?: string
|
|
300
|
+
}
|
|
301
|
+
menu?: {
|
|
302
|
+
groups?: string[]
|
|
303
|
+
}
|
|
304
|
+
dateFormat?: string
|
|
305
|
+
meta?: {
|
|
306
|
+
icons?: MetaIcon[]
|
|
307
|
+
}
|
|
308
|
+
dashboard?: DashboardItem[]
|
|
309
|
+
homePage?: Record<StokerRole, StokerCollection>
|
|
310
|
+
}
|
|
311
|
+
}
|
|
312
|
+
|
|
313
|
+
export interface VersionInfo {
|
|
314
|
+
version: number
|
|
315
|
+
force: boolean
|
|
316
|
+
refresh: boolean
|
|
317
|
+
time: Timestamp | FieldValue
|
|
318
|
+
payload: unknown
|
|
319
|
+
}
|
|
320
|
+
|
|
321
|
+
export interface WebUtilities {
|
|
322
|
+
getEnv: () => Record<string, string>
|
|
323
|
+
getTimezone: () => string
|
|
324
|
+
getConnectionStatus: () => "Online" | "Offline"
|
|
325
|
+
getNetworkStatus: () => "Online" | "Offline"
|
|
326
|
+
getSchema: (includeComputedFields?: boolean) => CollectionsSchema
|
|
327
|
+
getCurrentUser: () => User & { token: { claims: ParsedToken } }
|
|
328
|
+
getCurrentUserRoleGroups: () => Record<StokerCollection, RoleGroup>
|
|
329
|
+
getAllRoleGroups: () => Record<StokerCollection, Set<RoleGroup>>
|
|
330
|
+
getGlobalConfigModule: () => GlobalConfig
|
|
331
|
+
getCollectionConfigModule: (collection: string) => CollectionCustomization
|
|
332
|
+
getVersionInfo: () => VersionInfo | undefined
|
|
333
|
+
getMaintenanceInfo: () => { active: boolean } | undefined
|
|
334
|
+
getCurrentUserPermissions: () => StokerPermissions | null
|
|
335
|
+
getLoadingState: () => { [collection: string]: "Loading" | "Loaded" | "Error" }
|
|
336
|
+
|
|
337
|
+
getAppCheck: () => AppCheck
|
|
338
|
+
getAppCheckFirestoreWrite: () => AppCheck
|
|
339
|
+
getFirestoreWriteAuth: () => Auth
|
|
340
|
+
getFirestoreWrite: () => Firestore
|
|
341
|
+
getFirestoreMaintenance: () => Firestore
|
|
342
|
+
}
|
|
343
|
+
|
|
344
|
+
export interface NodeUtilities {
|
|
345
|
+
getMode: () => "development" | "production"
|
|
346
|
+
getTimezone: () => string
|
|
347
|
+
getGlobalConfigModule: () => GlobalConfig
|
|
348
|
+
getCustomizationFile: (collection: string, schema: CollectionsSchema) => CollectionCustomization
|
|
349
|
+
getVersionInfo: () => VersionInfo | undefined
|
|
350
|
+
getMaintenanceInfo: () => { active: boolean } | undefined
|
|
351
|
+
}
|
|
352
|
+
|
|
353
|
+
export interface StokerState {
|
|
354
|
+
[key: `collection-tab-${StokerCollection}`]: string
|
|
355
|
+
[key: `collection-search-${StokerCollection}`]: string
|
|
356
|
+
[key: `collection-status-filter-${StokerCollection}`]: string
|
|
357
|
+
[key: `collection-page-number-${StokerCollection}`]: string
|
|
358
|
+
[key: `collection-start-after-${StokerCollection}`]: string
|
|
359
|
+
[key: `collection-end-before-${StokerCollection}`]: string
|
|
360
|
+
[key: `collection-sort-${StokerCollection}`]: string
|
|
361
|
+
[key: `collection-calendar-large-${StokerCollection}`]: string
|
|
362
|
+
[key: `collection-calendar-small-${StokerCollection}`]: string
|
|
363
|
+
[key: `collection-calendar-large-date-${StokerCollection}`]: string
|
|
364
|
+
[key: `collection-calendar-small-date-${StokerCollection}`]: string
|
|
365
|
+
[key: `collection-filters-${StokerCollection}`]: string
|
|
366
|
+
[key: `collection-range-${StokerCollection}`]: string
|
|
367
|
+
[key: `collection-range-field-${StokerCollection}`]: string
|
|
368
|
+
[key: `collection-range-selector-${StokerCollection}`]: string
|
|
369
|
+
}
|
|
370
|
+
|
|
371
|
+
export interface DialogContent {
|
|
372
|
+
title: string
|
|
373
|
+
description: string
|
|
374
|
+
disableClose?: boolean
|
|
375
|
+
buttons?: {
|
|
376
|
+
label: string
|
|
377
|
+
onClick: () => void | Promise<void>
|
|
378
|
+
}[]
|
|
379
|
+
}
|
|
380
|
+
|
|
381
|
+
export interface UserData {
|
|
382
|
+
permissions?: StokerPermissions
|
|
383
|
+
operation?: "create" | "update" | "delete"
|
|
384
|
+
password?: string
|
|
385
|
+
passwordConfirm?: string
|
|
386
|
+
}
|
|
387
|
+
|
|
388
|
+
export interface StorageItem {
|
|
389
|
+
name: string
|
|
390
|
+
fullPath: string
|
|
391
|
+
isFolder: boolean
|
|
392
|
+
metadata?: {
|
|
393
|
+
read?: string[]
|
|
394
|
+
update?: string[]
|
|
395
|
+
delete?: string[]
|
|
396
|
+
createdBy?: string
|
|
397
|
+
}
|
|
398
|
+
}
|
|
399
|
+
|
|
400
|
+
export interface UploadProgress {
|
|
401
|
+
file: File
|
|
402
|
+
progress: number
|
|
403
|
+
status: "uploading" | "completed" | "error"
|
|
404
|
+
completedAt?: number
|
|
405
|
+
}
|