@stoker-platform/types 0.5.69 → 0.5.71

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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@stoker-platform/types",
3
- "version": "0.5.69",
3
+ "version": "0.5.71",
4
4
  "type": "module",
5
5
  "license": "SEE LICENSE IN LICENSE.md",
6
6
  "main": "src/main.ts",
package/src/types/app.ts CHANGED
@@ -32,37 +32,96 @@ import type { AppCheck } from "firebase/app-check"
32
32
  import type { FieldValue, Firestore as AdminFirestore } from "firebase-admin/firestore"
33
33
  import { FirebaseError } from "firebase-admin"
34
34
 
35
+ /** Auth config for the app */
35
36
  export interface AuthConfig {
37
+ /** An array of roles. App users with these roles will have the option to enable multi factor auth (using an Authenticator app) */
36
38
  enableMultiFactorAuth: boolean | StokerRole[]
39
+ /**
40
+ * The auth persistence strategy for your app.
41
+ * "LOCAL": Auth state is persisted across sessions. The user will stay logged in even when the window is closed or refreshed.
42
+ * "SESSION": Auth state is persisted within the same session. The user will be logged out when the window is closed.
43
+ * "NONE": Auth state is not persisted. The user will be logged out when the window is closed or refreshed
44
+ */
37
45
  authPersistenceType:
38
46
  "LOCAL" | "SESSION" | "NONE" | (() => "LOCAL" | "SESSION" | "NONE" | Promise<"LOCAL" | "SESSION" | "NONE">)
47
+ /**
48
+ * Set to `true` to sign out a user when their permissions are changed. If falsy, the Admin UI
49
+ * will attempt to reload data affected by the permissions change
50
+ */
39
51
  signOutOnPermissionsChange?: boolean
52
+ /**
53
+ * Only relevant if `offlinePersistenceType` is set to "ALL" or "WRITE".
54
+ * Set to `true` to clear offline persistence data from IndexedDB on sign out.
55
+ * Warning: the Firebase team does not recommend relying on this method for security purposes
56
+ */
40
57
  clearPersistenceOnSignOut?: boolean
58
+ /**
59
+ * The offline persistence strategy for your app.
60
+ * "ALL": All data read and written is stored in IndexedDB and persisted across sessions. Offline writes will be retried when the connection is restored, even if the window is closed while still offline. Warning: creates a security risk on public computers.
61
+ * "WRITE": Writes are persisted across sessions. `enableWriteLog` must be set to `true` for offline persistent writes to work for a collection.
62
+ * "NONE": No offline persistence. Offline writes will fail if the window is closed before the connection is restored
63
+ */
41
64
  offlinePersistenceType:
42
65
  | "ALL"
43
66
  | "WRITE"
44
67
  | "NONE"
45
68
  | ((user: User, claims: ParsedToken) => "ALL" | "WRITE" | "NONE" | Promise<"ALL" | "WRITE" | "NONE">)
69
+ /**
70
+ * Only relevant if `offlinePersistenceType` is set to "ALL" or "WRITE".
71
+ * Whether to use offline persisted data across tabs. If set to "SINGLE", offline persistence
72
+ * will only be available in the first tab opened. Defaults to "MULTI"
73
+ */
46
74
  tabManager?: "SINGLE" | "MULTI"
75
+ /**
76
+ * Only relevant if `offlinePersistenceType` is set to "WRITE" or "NONE".
77
+ * The garbage collection strategy to use for in-memory data. We highly recommend using "LRU".
78
+ * Defaults to "LRU"
79
+ */
47
80
  garbageCollectionStrategy?: "LRU" | "EAGER"
81
+ /**
82
+ * The maximum cache size for in-memory ("LRU" only) and persisted ("ALL" or "WRITE" only) caches.
83
+ * Use `-1` to set an unlimited cache size. Defaults to `-1`
84
+ */
48
85
  maxCacheSize?: number
86
+ /** Overwrites `maxCacheSize` for the write database instance only. Use `-1` to set an unlimited cache size. Defaults to `-1` */
49
87
  maxWriteCacheSize?: number
50
88
  }
51
89
 
90
+ /** Firebase config for the app */
52
91
  export interface FirebaseConfig {
92
+ /** Enable or disable the Firebase Emulators. */
53
93
  enableEmulators?: boolean | (() => boolean | Promise<boolean>)
94
+ /** Disable individual Firebase Emulators */
54
95
  disableIndividualEmulators?: ("Auth" | "Database" | "Firestore" | "Storage" | "Functions")[]
96
+ /** The settable config flag for GDPR opt-in/opt-out */
55
97
  GDPRSettings?: boolean | (() => boolean | Promise<boolean>)
98
+ /** Enable or disable Google Analytics for your app */
56
99
  enableAnalytics?: boolean | (() => boolean | Promise<boolean>)
100
+ /** Google Analytics config */
57
101
  analyticsSettings?: AnalyticsSettings | (() => AnalyticsSettings | Promise<AnalyticsSettings>)
102
+ /** Google Analytics consent config */
58
103
  analyticsConsentSettings?: ConsentSettings | (() => ConsentSettings | Promise<ConsentSettings>)
104
+ /** The Firebase log levels for development and production mode */
59
105
  logLevel?: {
106
+ /** The Firebase log level for development mode */
60
107
  dev?: "debug" | "verbose" | "info" | "warn" | "error" | "silent"
108
+ /** The Firebase log level for production mode */
61
109
  prod?: "debug" | "verbose" | "info" | "warn" | "error" | "silent"
62
110
  }
111
+ /**
112
+ * Exempt the user permissions collection from Firestore indexing. We recommend setting this to
113
+ * `true` for performance reasons, however you will need to set it to falsy in order to query
114
+ * the permissions collection by specific fields
115
+ */
63
116
  permissionsIndexExemption?: boolean
117
+ /** Exempt individual fields from the write log. We recommend leaving this as an empty array unless you have a good reason to exempt fields */
64
118
  writeLogIndexExemption?: string[]
119
+ /**
120
+ * If set, this is the number of days after which write log entries will be deleted.
121
+ * We recommend leaving it out in order to keep records of write activity indefinitely
122
+ */
65
123
  writeLogTTL?: number
124
+ /** The strategy to use for Firestore server timestamps. We recommend setting this to "estimate". Defaults to "none" */
66
125
  serverTimestampOptions?:
67
126
  | "none"
68
127
  | "estimate"
@@ -70,12 +129,24 @@ export interface FirebaseConfig {
70
129
  | (() => "none" | "estimate" | "previous" | Promise<"none" | "estimate" | "previous">)
71
130
  }
72
131
 
132
+ /** Preload cache config, defining the order in which collections are preloaded on app startup */
73
133
  export interface PreloadConfig {
134
+ /**
135
+ * An array of collection names that have the preload cache enabled. These collections will be
136
+ * preloaded synchronously while the async collections also load. Collections not listed in
137
+ * `async` or `sync` will load synchronously after the collections in this list
138
+ */
74
139
  sync?: StokerCollection[] | (() => StokerCollection[] | Promise<StokerCollection[]>)
140
+ /** An array of collection names that have the preload cache enabled. These collections will be preloaded first, in parallel */
75
141
  async?: StokerCollection[] | (() => StokerCollection[] | Promise<StokerCollection[]>)
76
142
  }
77
143
 
144
+ /** Mail config for the app */
78
145
  export interface MailConfig {
146
+ /**
147
+ * Customize the email address verification email sent out to your app's users.
148
+ * Receives the verification link and app name, and returns the subject and html message to send
149
+ */
79
150
  emailVerification?: (
80
151
  verificationLink: string,
81
152
  appName?: string,
@@ -85,72 +156,120 @@ export interface MailConfig {
85
156
  }
86
157
  }
87
158
 
159
+ /** A menu group defining the menu structure for the user roles in your system */
88
160
  export interface MenuGroup {
161
+ /** The title for the menu group */
89
162
  title: string
163
+ /** The position of the group in the menu */
90
164
  position: number
165
+ /** The collections in the menu group */
91
166
  collections: StokerCollection[]
167
+ /** The roles that can see this menu group */
92
168
  roles?: StokerRole[]
93
169
  }
94
170
 
171
+ /** A meta tag icon for the app's home page, i.e. `<link rel="icon" type="image/png" href="./favicon.ico" />` */
95
172
  export interface MetaIcon {
96
173
  rel: string
97
174
  type: string
98
175
  url: string
99
176
  }
100
177
 
178
+ /** Display a metric (numerical counter) on the Dashboard */
101
179
  export interface DashboardMetric {
102
180
  kind: "metric"
181
+ /** The collection to aggregate */
103
182
  collection: StokerCollection
183
+ /** The metric type */
104
184
  type: "sum" | "average" | "count"
185
+ /** The field to aggregate. Not required for `count` */
105
186
  field?: string
187
+ /** Limit which user roles can view the metric */
106
188
  roles?: StokerRole[]
189
+ /** The title shown above the metric */
107
190
  title?: string
191
+ /** Maximum decimal places to display */
108
192
  decimal?: number
193
+ /** Prefix text, for example a currency symbol */
109
194
  prefix?: string
195
+ /** Suffix text, for example units */
110
196
  suffix?: string
197
+ /** Tailwind text size for the metric value */
111
198
  textSize?: "text-xl" | "text-2xl" | "text-3xl"
199
+ /** Firestore constraints to apply to the metric query */
112
200
  constraints?: [string, WhereFilterOp, unknown][]
201
+ /** Force metric data to be loaded from the server */
113
202
  forceServer?: boolean
114
203
  }
204
+ /** Display a chart on the Dashboard */
115
205
  export interface DashboardChart {
116
206
  kind: "chart"
207
+ /** The collection to chart */
117
208
  collection: StokerCollection
209
+ /** The chart type */
118
210
  type: "area"
211
+ /** The date field used to group points */
119
212
  dateField: string
213
+ /** First metric field */
120
214
  metricField1?: string
215
+ /** Optional second metric field */
121
216
  metricField2?: string
217
+ /** Custom calculation for the first metric */
122
218
  formula1?: (record: StokerRecord) => number
219
+ /** Custom calculation for the second metric */
123
220
  formula2?: (record: StokerRecord) => number
221
+ /** The label for the first metric */
124
222
  label1?: string | (() => string)
223
+ /** The label for the second metric */
125
224
  label2?: string | (() => string)
225
+ /** Show or hide the y-axis */
126
226
  yAxis?: { show?: boolean | (() => boolean) }
227
+ /** Limit which user roles can view the chart */
127
228
  roles?: StokerRole[]
229
+ /** Title shown above the chart */
128
230
  title?: string
231
+ /** Firestore constraints to apply to the chart query */
129
232
  constraints?: [string, WhereFilterOp, unknown][]
233
+ /** The interval to group points by */
130
234
  interval?: "day" | "month" | "year"
235
+ /** The number of intervals to display */
131
236
  numberOfIntervals?: number
237
+ /** Offset the intervals by this amount */
132
238
  offset?: number
239
+ /** Animate the chart */
133
240
  animate?: boolean
241
+ /** Currency symbol to display */
134
242
  currency?: string | (() => string)
135
243
  }
136
244
 
245
+ /** Display a reminder (a list of pertinent records) on the Dashboard */
137
246
  export interface DashboardReminder {
138
247
  kind: "reminder"
248
+ /** The collection to show records from */
139
249
  collection: StokerCollection
250
+ /** Which columns to show in the list */
140
251
  columns: string[]
252
+ /** The title shown above the reminder */
141
253
  title?: string
254
+ /** Limit which user roles can view the reminder */
142
255
  roles?: StokerRole[]
256
+ /** Firestore constraints to apply to the reminder query */
143
257
  constraints?: [string, WhereFilterOp, unknown][]
258
+ /** The field and direction to sort records by */
144
259
  sort?: {
145
260
  field: string
146
261
  direction: "asc" | "desc"
147
262
  }
263
+ /** Force the reminder records to be loaded from the server */
148
264
  forceServer?: boolean
265
+ /** Filter which records are displayed */
149
266
  filter?: (record: StokerRecord) => boolean
150
267
  }
151
268
 
269
+ /** An item shown on the Dashboard. Items will be laid out in a grid */
152
270
  export type DashboardItem = DashboardMetric | DashboardChart | DashboardReminder
153
271
 
272
+ /** Background properties of the `body` for light and dark mode */
154
273
  export interface Background {
155
274
  light?: {
156
275
  color: string
@@ -162,22 +281,37 @@ export interface Background {
162
281
  }
163
282
  }
164
283
 
284
+ /** Admin UI config for the app */
165
285
  export interface AdminConfig {
286
+ /**
287
+ * If defined, only the roles listed will be able to see the Admin UI. Warning: this access
288
+ * restriction is only enforced on the client. Users can still log in, but they won't see anything
289
+ */
166
290
  access?: StokerRole[] | (() => StokerRole[])
291
+ /** Background objects for light and dark mode. This lets you control the background properties of the `body` */
167
292
  background?: Background | (() => Background)
293
+ /** Image urls to be used for the navbar title and the login page. If not provided, the icons in your `icons` directory will be used */
168
294
  logo?: {
169
295
  navbar?: string
170
296
  login?: string
171
297
  }
298
+ /** The menu structures for the user roles in your system */
172
299
  menu?: {
173
300
  groups?: MenuGroup[]
174
301
  }
302
+ /** The Luxon date format to display dates in */
175
303
  dateFormat?: string | (() => string)
304
+ /** The meta tag description and icons for your app's home page */
176
305
  meta?: {
177
306
  description?: string
178
307
  icons?: MetaIcon[]
179
308
  }
309
+ /** Items shown on the Dashboard, laid out in a grid. We recommend that each row contains 1-2 metrics and a chart, 1 reminder and a chart, or 3 reminders */
180
310
  dashboard?: DashboardItem[]
311
+ /**
312
+ * Key/value pairs defining user roles and the collection that will act as their homepage.
313
+ * If the user role has access to the Dashboard, that will take precedence
314
+ */
181
315
  homePage?: Record<StokerRole, StokerCollection> | (() => Record<StokerRole, StokerCollection>)
182
316
  searchAll?: boolean | (() => boolean)
183
317
  }
@@ -220,19 +354,47 @@ export type Region =
220
354
  | "us-west3"
221
355
  | "us-west4"
222
356
 
357
+ /** Project-wide config for your app, defined in the global config file at src/main.ts */
223
358
  export type GlobalConfig = {
359
+ /**
360
+ * This is the big one. Name the access roles that will be used in your app.
361
+ * Each role will have its own permissions, i.e. `["Manager", "Supervisor", "Staff Member", "Client"]`
362
+ */
224
363
  roles: StokerRole[]
364
+ /** An array of collection names that will be disabled in your app (on the next `stoker deploy`) */
225
365
  disabledCollections?: StokerCollection[]
366
+ /** The name of your app. Shorter is better, as this will be used for page titles etc */
226
367
  appName: string | (() => string | Promise<string>)
368
+ /** Your app will be based in this timezone. Must be a valid IANA timezone */
227
369
  timezone?: string | (() => string | Promise<string>)
370
+ /** Auth config for the app */
228
371
  auth: AuthConfig
372
+ /** Firebase config for the app */
229
373
  firebase?: FirebaseConfig
374
+ /** Preload cache config, defining the order in which collections are preloaded on app startup */
230
375
  preload?: PreloadConfig
376
+ /**
377
+ * Whether to log the user's ID in the client whenever Firebase prints logs. This can be useful
378
+ * for debugging, but may cause privacy concerns in some scenarios. Disabled by default
379
+ */
231
380
  enableUserIDLogging?: boolean | (() => boolean | Promise<boolean>)
381
+ /** Mail config for the app */
232
382
  mail?: MailConfig
383
+ /**
384
+ * Fires before the user is logged in, prior to any other authentication logic being processed.
385
+ * You may block the sign in by returning `false`. Warning: this logic is client-side and is
386
+ * skippable. Use Firebase Auth Blocking Cloud Functions for secure sign-in-blocking operations
387
+ */
233
388
  preLogin?: (user: User) => boolean | void | Promise<boolean | void>
389
+ /** Fires after the user has successfully logged in */
234
390
  postLogin?: (user?: User, error?: unknown) => void | Promise<void>
391
+ /** Fires when the user attempts to log out. You may block the sign out by returning `false` */
235
392
  preLogout?: (user: User) => boolean | void | Promise<boolean | void>
393
+ /**
394
+ * Fires when the user has logged out. If an error is encountered during sign out, additional
395
+ * information is provided describing which Firestore instances encountered the error, the
396
+ * operation that encountered the error, and the error itself
397
+ */
236
398
  postLogout?: (errorDetails: {
237
399
  error: boolean
238
400
  instances: {
@@ -241,27 +403,59 @@ export type GlobalConfig = {
241
403
  error: unknown
242
404
  }[]
243
405
  }) => void | Promise<void>
406
+ /**
407
+ * Fires when the schema version is updated. Note: if `refresh` is `true` for the schema update,
408
+ * the page will automatically refresh and this hook will not fire
409
+ */
244
410
  onVersionUpdate?: (versionInfo: VersionInfo, numberOfUpdates: number) => void | Promise<void>
411
+ /** Fires when maintenance mode is engaged / disengaged */
245
412
  onMaintenanceUpdate?: (status: "on" | "off") => void | Promise<void>
413
+ /** Fires when the app goes online / offline. `first` will be true for the initial value read on app startup */
246
414
  onConnectionStatusChange?: (status: "Online" | "Offline", first: boolean) => void | Promise<void>
415
+ /** Fires when Cloud Firestore detects a slow internet connection */
247
416
  onFirestoreSlowConnection?: () => void | Promise<void>
417
+ /** Fires when Cloud Firestore experiences a read failure, usually due to excessive contention on documents or exceeded quotas */
248
418
  onFirestoreLoadFailure?: () => void | Promise<void>
419
+ /** Fires in rare cases where Firestore IndexedDB persistence fails */
249
420
  onIndexedDBConnectionLost?: () => void | Promise<void>
421
+ /** Fires when App Check token refresh fails */
250
422
  onAppCheckTokenFailure?: (error: FirebaseError) => void | Promise<void>
423
+ /** Fires before all read and write operations. Return `false` to cancel the operation */
251
424
  preOperation?: PreOperationHook
425
+ /** Fires before all read operations */
252
426
  preRead?: PreReadHook
427
+ /** Fires after all read operations */
253
428
  postRead?: PostReadHook
429
+ /** Fires before all duplicate operations in the Admin UI. Return `false` to cancel the operation */
254
430
  preDuplicate?: PreDuplicateHook
431
+ /**
432
+ * Fires at write validation time for all write operations. This is where you can define custom
433
+ * validation logic. Return an object with a boolean indicating whether validation passed, and
434
+ * a message to display to the user if validation has failed
435
+ */
255
436
  preValidate?: PreValidateHook
437
+ /** Fires before all write operations. Return `false` to cancel the operation */
256
438
  preWrite?: PreWriteHook
439
+ /** Fires after all write operations */
257
440
  postWrite?: PostWriteHook
441
+ /**
442
+ * Fires when a write operation encounters an error. This hook may fire multiple times per write,
443
+ * so be sure to write idempotent code
444
+ */
258
445
  postWriteError?: PostWriteErrorHook
446
+ /** Fires after all read and write operations */
259
447
  postOperation?: PostOperationHook
448
+ /** Fires before a file is uploaded. Return `false` to cancel the operation */
260
449
  preFileAdd?: PreFileAddHook
450
+ /** Fires before a file is updated. Return `false` to cancel the operation */
261
451
  preFileUpdate?: PreFileUpdateHook
452
+ /** Fires after a file is uploaded */
262
453
  postFileAdd?: PostFileAddHook
454
+ /** Fires when a file upload fails */
263
455
  postFileAddError?: PostFileAddErrorHook
456
+ /** Fires after a file is updated */
264
457
  postFileUpdate?: PostFileUpdateHook
458
+ /** Admin UI config for the app */
265
459
  admin?: AdminConfig
266
460
  }
267
461