@dereekb/firebase 13.41.0 → 13.43.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/eslint/index.esm.js +145 -170
- package/eslint/package.json +3 -3
- package/index.esm.js +7207 -2997
- package/package.json +5 -5
- package/src/lib/common/firestore/snapshot/snapshot.field.d.ts +4 -0
- package/src/lib/common/storage/context.d.ts +9 -1
- package/src/lib/common/storage/driver/accessor.d.ts +12 -0
- package/src/lib/common/storage/index.d.ts +1 -0
- package/src/lib/common/storage/storage.url.d.ts +69 -0
- package/src/lib/model/calendar/calendar.action.d.ts +34 -0
- package/src/lib/model/calendar/calendar.api.d.ts +147 -0
- package/src/lib/model/calendar/calendar.api.error.d.ts +24 -0
- package/src/lib/model/calendar/calendar.d.ts +460 -0
- package/src/lib/model/calendar/calendar.expand.d.ts +95 -0
- package/src/lib/model/calendar/calendar.ics.d.ts +322 -0
- package/src/lib/model/calendar/calendar.id.d.ts +110 -0
- package/src/lib/model/calendar/calendar.processing.d.ts +77 -0
- package/src/lib/model/calendar/calendar.query.d.ts +76 -0
- package/src/lib/model/calendar/calendar.schedule.d.ts +82 -0
- package/src/lib/model/calendar/calendar.type.d.ts +188 -0
- package/src/lib/model/calendar/calendar.util.d.ts +485 -0
- package/src/lib/model/calendar/index.d.ts +12 -0
- package/src/lib/model/formspace/formspace.access.d.ts +139 -0
- package/src/lib/model/formspace/formspace.action.d.ts +34 -0
- package/src/lib/model/formspace/formspace.api.d.ts +216 -0
- package/src/lib/model/formspace/formspace.api.error.d.ts +71 -0
- package/src/lib/model/formspace/formspace.d.ts +390 -0
- package/src/lib/model/formspace/formspace.id.d.ts +60 -0
- package/src/lib/model/formspace/formspace.permission.d.ts +47 -0
- package/src/lib/model/formspace/formspace.processing.d.ts +86 -0
- package/src/lib/model/formspace/formspace.query.d.ts +110 -0
- package/src/lib/model/formspace/formspace.task.d.ts +75 -0
- package/src/lib/model/formspace/formspace.type.d.ts +267 -0
- package/src/lib/model/formspace/formspace.upload.d.ts +204 -0
- package/src/lib/model/formspace/formspace.util.d.ts +348 -0
- package/src/lib/model/formspace/index.d.ts +13 -0
- package/src/lib/model/index.d.ts +2 -0
- package/src/lib/model/notification/notification.message.d.ts +83 -0
- package/src/lib/model/notification/notification.query.d.ts +41 -0
- package/src/lib/model/oidcmodel/oidcmodel.query.d.ts +36 -0
- package/src/lib/model/storagefile/storagefile.api.d.ts +42 -2
- package/src/lib/model/storagefile/storagefile.create.d.ts +14 -3
- package/src/lib/model/storagefile/storagefile.file.d.ts +42 -2
- package/src/lib/model/storagefile/storagefile.query.d.ts +36 -0
- package/src/lib/model/storagefile/storagefile.upload.d.ts +30 -0
- package/src/lib/model/system/index.d.ts +1 -0
- package/src/lib/model/system/system.scheduler.d.ts +235 -0
- package/test/index.esm.js +24 -1
- package/test/package.json +6 -6
|
@@ -0,0 +1,139 @@
|
|
|
1
|
+
import { type Maybe } from '@dereekb/util';
|
|
2
|
+
import { type FirebaseAuthUserId } from '../../common/auth/auth';
|
|
3
|
+
import { type StorageFile } from '../storagefile/storagefile';
|
|
4
|
+
import { type FormSpace, type FormSpaceFile, type FormSpaceFirestoreCollections } from './formspace';
|
|
5
|
+
import { type FormSpaceFileSlot, type FormSpaceKey } from './formspace.id';
|
|
6
|
+
import { type AppFormSpaceTypeConfigService, type FormSpaceFileAccess, type FormSpaceTypeConfig } from './formspace.type';
|
|
7
|
+
/**
|
|
8
|
+
* Input for {@link formSpaceSlotFileAccess}.
|
|
9
|
+
*/
|
|
10
|
+
export interface FormSpaceSlotFileAccessInput {
|
|
11
|
+
readonly config: FormSpaceTypeConfig;
|
|
12
|
+
readonly slot: Maybe<FormSpaceFileSlot>;
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* Resolves the {@link FormSpaceFileAccess} governing one slot.
|
|
16
|
+
*
|
|
17
|
+
* Slot narrows type narrows default, the same precedence `allowedMimeTypes` and `maxFileSizeBytes` use.
|
|
18
|
+
*
|
|
19
|
+
* @param input - The type config and the slot.
|
|
20
|
+
* @returns The effective file access policy.
|
|
21
|
+
*
|
|
22
|
+
* @__NO_SIDE_EFFECTS__
|
|
23
|
+
*/
|
|
24
|
+
export declare function formSpaceSlotFileAccess(input: FormSpaceSlotFileAccessInput): FormSpaceFileAccess;
|
|
25
|
+
/**
|
|
26
|
+
* Input for {@link formSpaceFileUploaderId}.
|
|
27
|
+
*/
|
|
28
|
+
export interface FormSpaceFileUploaderIdInput {
|
|
29
|
+
readonly formSpace: Pick<FormSpace, 'u'>;
|
|
30
|
+
readonly file: Pick<FormSpaceFile, 'ub'>;
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* The uid that owns one file for access purposes.
|
|
34
|
+
*
|
|
35
|
+
* Falls back to the space's `u` when the entry carries no `ub`. That is not a guess: `ub` was added after
|
|
36
|
+
* FormSpace shipped, and every entry written before it existed came from the only party that could upload
|
|
37
|
+
* at the time — the space's own user. Falling back keeps an older single-user space working unchanged
|
|
38
|
+
* under an `'uploader'` policy instead of locking its owner out of their own files.
|
|
39
|
+
*
|
|
40
|
+
* @param input - The space and the file entry.
|
|
41
|
+
* @returns The uploader's uid.
|
|
42
|
+
*
|
|
43
|
+
* @__NO_SIDE_EFFECTS__
|
|
44
|
+
*/
|
|
45
|
+
export declare function formSpaceFileUploaderId(input: FormSpaceFileUploaderIdInput): FirebaseAuthUserId;
|
|
46
|
+
/**
|
|
47
|
+
* Input for {@link isFormSpaceFileAccessibleWithAccess}.
|
|
48
|
+
*/
|
|
49
|
+
export interface IsFormSpaceFileAccessibleWithAccessInput {
|
|
50
|
+
readonly fileAccess: FormSpaceFileAccess;
|
|
51
|
+
readonly formSpace: Pick<FormSpace, 'u'>;
|
|
52
|
+
readonly file: Pick<FormSpaceFile, 'ub'>;
|
|
53
|
+
readonly uid: Maybe<FirebaseAuthUserId>;
|
|
54
|
+
}
|
|
55
|
+
/**
|
|
56
|
+
* THE per-file rule, applied to an ALREADY-RESOLVED {@link FormSpaceFileAccess}.
|
|
57
|
+
*
|
|
58
|
+
* Split from {@link isFormSpaceFileAccessibleByUser} so a caller holding the policy but not the whole
|
|
59
|
+
* `FormSpaceTypeConfig` — a UI handed `fileAccess` as an input, say — decides with the same function the
|
|
60
|
+
* server enforces with, rather than a second copy of `ub ?? u` that could drift from it.
|
|
61
|
+
*
|
|
62
|
+
* @param input - The resolved policy, the space, the file entry, and the caller.
|
|
63
|
+
* @returns True when the caller may read and remove this file.
|
|
64
|
+
*
|
|
65
|
+
* @__NO_SIDE_EFFECTS__
|
|
66
|
+
*/
|
|
67
|
+
export declare function isFormSpaceFileAccessibleWithAccess(input: IsFormSpaceFileAccessibleWithAccessInput): boolean;
|
|
68
|
+
/**
|
|
69
|
+
* Input for {@link isFormSpaceFileAccessibleByUser}.
|
|
70
|
+
*/
|
|
71
|
+
export interface IsFormSpaceFileAccessibleByUserInput {
|
|
72
|
+
readonly formSpace: Pick<FormSpace, 'u'>;
|
|
73
|
+
readonly config: FormSpaceTypeConfig;
|
|
74
|
+
readonly file: Pick<FormSpaceFile, 'sl' | 'ub'>;
|
|
75
|
+
readonly uid: Maybe<FirebaseAuthUserId>;
|
|
76
|
+
}
|
|
77
|
+
/**
|
|
78
|
+
* THE per-file predicate: may this user read or remove this file, given they already reach the space?
|
|
79
|
+
*
|
|
80
|
+
* One function for both verbs on purpose. "You can see it but not delete it" and "you can delete it but not
|
|
81
|
+
* see it" are both worse than either consistent answer, and two policies would be two things to keep in
|
|
82
|
+
* step. A type that genuinely needs to split them should keep files in separate slots and narrow one.
|
|
83
|
+
*
|
|
84
|
+
* @param input - The space, its type config, the file entry, and the caller.
|
|
85
|
+
* @returns True when the caller may read and remove this file.
|
|
86
|
+
*
|
|
87
|
+
* @example
|
|
88
|
+
* ```ts
|
|
89
|
+
* const allowed = isFormSpaceFileAccessibleByUser({ formSpace, config, file, uid: context.auth?.uid });
|
|
90
|
+
* ```
|
|
91
|
+
*
|
|
92
|
+
* @__NO_SIDE_EFFECTS__
|
|
93
|
+
*/
|
|
94
|
+
export declare function isFormSpaceFileAccessibleByUser(input: IsFormSpaceFileAccessibleByUserInput): boolean;
|
|
95
|
+
/**
|
|
96
|
+
* Returns the {@link FormSpaceKey} a StorageFile was uploaded into, or null when it is not a FormSpace file.
|
|
97
|
+
*
|
|
98
|
+
* Reads the group ids rather than a dedicated field: a FormSpace upload joins the group
|
|
99
|
+
* {@link formSpaceStorageFileGroupId} keys by the space's own model key, so the key is already recoverable
|
|
100
|
+
* and a second copy of it could only drift. The purpose is checked first, so a file from any other pipeline
|
|
101
|
+
* costs one string comparison.
|
|
102
|
+
*
|
|
103
|
+
* Decoded by splitting the FIRST separator rather than through
|
|
104
|
+
* {@link inferStorageFileGroupRelatedModelKey}, which replaces EVERY `_` with a `/`. That generic inverse is
|
|
105
|
+
* only two-way for an id that contains no underscore, and a space keyed by {@link formSpaceIdForModel}
|
|
106
|
+
* always does — a guestbook's album is `fsp/gb_<id>`, which the generic inverse turns into the three-segment
|
|
107
|
+
* `fsp/gb/<id>`: not a document path at all. FormSpace is a ROOT collection, so everything after the first
|
|
108
|
+
* separator is the id, underscores and all.
|
|
109
|
+
*
|
|
110
|
+
* @param storageFile - The StorageFile to inspect.
|
|
111
|
+
* @returns The FormSpace's model key, or null.
|
|
112
|
+
*
|
|
113
|
+
* @__NO_SIDE_EFFECTS__
|
|
114
|
+
*/
|
|
115
|
+
export declare function formSpaceKeyForStorageFile(storageFile: Pick<StorageFile, 'p' | 'g'>): Maybe<FormSpaceKey>;
|
|
116
|
+
/**
|
|
117
|
+
* Input for {@link isFormSpaceStorageFileAccessibleByUser}.
|
|
118
|
+
*/
|
|
119
|
+
export interface IsFormSpaceStorageFileAccessibleByUserInput {
|
|
120
|
+
readonly collections: FormSpaceFirestoreCollections;
|
|
121
|
+
readonly appFormSpaceTypeConfigService: AppFormSpaceTypeConfigService;
|
|
122
|
+
readonly storageFile: Pick<StorageFile, 'p' | 'g' | 'pg' | 'uby'>;
|
|
123
|
+
readonly uid: Maybe<FirebaseAuthUserId>;
|
|
124
|
+
}
|
|
125
|
+
/**
|
|
126
|
+
* {@link isFormSpaceFileAccessibleByUser}, asked from the StorageFile side — where a download is authorized.
|
|
127
|
+
*
|
|
128
|
+
* Returns true for a StorageFile that is not a FormSpace upload at all, so a caller can AND it into an
|
|
129
|
+
* existing role grant without first classifying the file: this narrows FormSpace files and abstains on
|
|
130
|
+
* everything else.
|
|
131
|
+
*
|
|
132
|
+
* Costs at most one FormSpace read, and usually none. A caller who IS the file's `uby` is allowed under
|
|
133
|
+
* BOTH policies, so the space never has to be loaded to answer for them — which is the common case, since
|
|
134
|
+
* the person downloading a file is overwhelmingly the person who uploaded it.
|
|
135
|
+
*
|
|
136
|
+
* @param input - The collections, the type registry, the StorageFile, and the caller.
|
|
137
|
+
* @returns True when the caller may read this file.
|
|
138
|
+
*/
|
|
139
|
+
export declare function isFormSpaceStorageFileAccessibleByUser(input: IsFormSpaceStorageFileAccessibleByUserInput): Promise<boolean>;
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { type AsyncFirebaseFunctionCreateAction, type AsyncFirebaseFunctionDeleteAction, type AsyncFirebaseFunctionUpdateAction, type FirebaseFunctionCreateAction, type FirebaseFunctionDeleteAction, type FirebaseFunctionUpdateAction } from '../../common';
|
|
2
|
+
import { type FormSpaceDocument } from './formspace';
|
|
3
|
+
/**
|
|
4
|
+
* @module formspace.action
|
|
5
|
+
*
|
|
6
|
+
* Type aliases for FormSpace server action functions, following the same pattern as the StorageFile and
|
|
7
|
+
* Calendar actions. See `@dereekb/firebase-server/model` for the implementations.
|
|
8
|
+
*
|
|
9
|
+
* @template P - the parameter type for the action
|
|
10
|
+
*/
|
|
11
|
+
/**
|
|
12
|
+
* Synchronous create action targeting a {@link FormSpaceDocument}.
|
|
13
|
+
*/
|
|
14
|
+
export type FormSpaceCreateAction<P extends object> = FirebaseFunctionCreateAction<P, FormSpaceDocument>;
|
|
15
|
+
/**
|
|
16
|
+
* Async create action targeting a {@link FormSpaceDocument}.
|
|
17
|
+
*/
|
|
18
|
+
export type AsyncFormSpaceCreateAction<P extends object> = AsyncFirebaseFunctionCreateAction<P, FormSpaceDocument>;
|
|
19
|
+
/**
|
|
20
|
+
* Synchronous update action targeting a {@link FormSpaceDocument}.
|
|
21
|
+
*/
|
|
22
|
+
export type FormSpaceUpdateAction<P extends object> = FirebaseFunctionUpdateAction<P, FormSpaceDocument>;
|
|
23
|
+
/**
|
|
24
|
+
* Async update action targeting a {@link FormSpaceDocument}.
|
|
25
|
+
*/
|
|
26
|
+
export type AsyncFormSpaceUpdateAction<P extends object> = AsyncFirebaseFunctionUpdateAction<P, FormSpaceDocument>;
|
|
27
|
+
/**
|
|
28
|
+
* Synchronous delete action targeting a {@link FormSpaceDocument}.
|
|
29
|
+
*/
|
|
30
|
+
export type FormSpaceDeleteAction<P extends object> = FirebaseFunctionDeleteAction<P, FormSpaceDocument>;
|
|
31
|
+
/**
|
|
32
|
+
* Async delete action targeting a {@link FormSpaceDocument}.
|
|
33
|
+
*/
|
|
34
|
+
export type AsyncFormSpaceDeleteAction<P extends object> = AsyncFirebaseFunctionDeleteAction<P, FormSpaceDocument>;
|
|
@@ -0,0 +1,216 @@
|
|
|
1
|
+
import { type Type } from 'arktype';
|
|
2
|
+
import { type Maybe, type Milliseconds } from '@dereekb/util';
|
|
3
|
+
import { type FirestoreModelKey, type OnCallCreateModelResult, type TargetModelParams } from '../../common';
|
|
4
|
+
import { type FirebaseFunctionTypeConfigMap, type ModelFirebaseCreateFunction, type ModelFirebaseCrudFunction, type ModelFirebaseCrudFunctionConfigMap, type ModelFirebaseFunctionMap } from '../../client';
|
|
5
|
+
import { type StorageFileId } from '../storagefile/storagefile.id';
|
|
6
|
+
import { type FormSpaceData, type FormSpaceTypes } from './formspace';
|
|
7
|
+
import { type FormSpaceFileSlot, type FormSpaceType } from './formspace.id';
|
|
8
|
+
/**
|
|
9
|
+
* @module formspace.api
|
|
10
|
+
*
|
|
11
|
+
* ARKTYPE PARAM/RESULT TYPES plus the callable CRUD map for the FormSpace model.
|
|
12
|
+
*
|
|
13
|
+
* Unlike Calendar — which is driven entirely internally — a FormSpace is a CLIENT-FACING container: the
|
|
14
|
+
* user creates it, edits it, and submits it, so every one of those is a callable.
|
|
15
|
+
*/
|
|
16
|
+
/**
|
|
17
|
+
* Parameters for creating a FormSpace.
|
|
18
|
+
*
|
|
19
|
+
* @dbxModelApiParams
|
|
20
|
+
*/
|
|
21
|
+
export interface CreateFormSpaceParams<T extends FormSpaceData = FormSpaceData> {
|
|
22
|
+
/**
|
|
23
|
+
* The registered {@link FormSpaceType} to create. Creation of an unregistered type is rejected.
|
|
24
|
+
*/
|
|
25
|
+
readonly formSpaceType: FormSpaceType;
|
|
26
|
+
/**
|
|
27
|
+
* Display name for the space.
|
|
28
|
+
*/
|
|
29
|
+
readonly displayName?: Maybe<string>;
|
|
30
|
+
/**
|
|
31
|
+
* The model this space is being opened against, if any.
|
|
32
|
+
*/
|
|
33
|
+
readonly targetModelKey?: Maybe<FirestoreModelKey>;
|
|
34
|
+
/**
|
|
35
|
+
* Initial form data.
|
|
36
|
+
*/
|
|
37
|
+
readonly data?: Maybe<T>;
|
|
38
|
+
}
|
|
39
|
+
export declare const createFormSpaceParamsType: Type<CreateFormSpaceParams>;
|
|
40
|
+
/**
|
|
41
|
+
* Parameters for updating a draft FormSpace's content.
|
|
42
|
+
*
|
|
43
|
+
* `data` REPLACES the stored JSON rather than merging into it. The client owns the whole form; a merge
|
|
44
|
+
* would make clearing a field impossible to express.
|
|
45
|
+
*
|
|
46
|
+
* @dbxModelApiParams
|
|
47
|
+
*/
|
|
48
|
+
export interface UpdateFormSpaceParams<T extends FormSpaceData = FormSpaceData> extends TargetModelParams {
|
|
49
|
+
readonly displayName?: Maybe<string>;
|
|
50
|
+
readonly data?: Maybe<T>;
|
|
51
|
+
}
|
|
52
|
+
export declare const updateFormSpaceParamsType: Type<UpdateFormSpaceParams>;
|
|
53
|
+
/**
|
|
54
|
+
* Parameters for submitting a FormSpace.
|
|
55
|
+
*
|
|
56
|
+
* @dbxModelApiParams
|
|
57
|
+
*/
|
|
58
|
+
export interface SubmitFormSpaceParams extends TargetModelParams {
|
|
59
|
+
/**
|
|
60
|
+
* Whether to run the submission's processing task immediately rather than waiting for the queue.
|
|
61
|
+
*/
|
|
62
|
+
readonly runImmediately?: Maybe<boolean>;
|
|
63
|
+
}
|
|
64
|
+
export declare const submitFormSpaceParamsType: Type<SubmitFormSpaceParams>;
|
|
65
|
+
/**
|
|
66
|
+
* Result of submitting a FormSpace.
|
|
67
|
+
*/
|
|
68
|
+
export interface SubmitFormSpaceResult {
|
|
69
|
+
/**
|
|
70
|
+
* The key of the NotificationTask processing the submission.
|
|
71
|
+
*/
|
|
72
|
+
readonly processingNotificationKey: string;
|
|
73
|
+
/**
|
|
74
|
+
* True if the processing task was newly created by this call.
|
|
75
|
+
*/
|
|
76
|
+
readonly processingTaskCreated: boolean;
|
|
77
|
+
}
|
|
78
|
+
/**
|
|
79
|
+
* Parameters for removing one uploaded file from a FormSpace slot.
|
|
80
|
+
*
|
|
81
|
+
* The file is dropped from the space's `f` array and its StorageFile is FLAGGED for deletion, never deleted
|
|
82
|
+
* inline — the StorageFile delete sweep owns removing the object, and a second code path that removed it
|
|
83
|
+
* here is how an orphaned object gets left behind.
|
|
84
|
+
*
|
|
85
|
+
* @dbxModelApiParams
|
|
86
|
+
*/
|
|
87
|
+
export interface RemoveFormSpaceFileParams extends TargetModelParams {
|
|
88
|
+
/**
|
|
89
|
+
* The slot holding the file.
|
|
90
|
+
*/
|
|
91
|
+
readonly slot: FormSpaceFileSlot;
|
|
92
|
+
/**
|
|
93
|
+
* The StorageFile to remove.
|
|
94
|
+
*
|
|
95
|
+
* Optional only when the slot holds exactly one file: a folder slot with several files has no unambiguous
|
|
96
|
+
* "the" file, so omitting it there is an error rather than a guess.
|
|
97
|
+
*/
|
|
98
|
+
readonly storageFileId?: Maybe<StorageFileId>;
|
|
99
|
+
}
|
|
100
|
+
export declare const removeFormSpaceFileParamsType: Type<RemoveFormSpaceFileParams>;
|
|
101
|
+
/**
|
|
102
|
+
* Parameters for deleting a FormSpace and flagging its uploaded files for deletion.
|
|
103
|
+
*
|
|
104
|
+
* @dbxModelApiParams
|
|
105
|
+
*/
|
|
106
|
+
export interface DeleteFormSpaceParams extends TargetModelParams {
|
|
107
|
+
}
|
|
108
|
+
export declare const deleteFormSpaceParamsType: Type<DeleteFormSpaceParams>;
|
|
109
|
+
/**
|
|
110
|
+
* Parameters for the backstop sweep over FormSpaces stuck in QUEUED_FOR_PROCESSING.
|
|
111
|
+
*/
|
|
112
|
+
export interface ProcessAllQueuedFormSpacesParams {
|
|
113
|
+
/**
|
|
114
|
+
* Maximum number of spaces to visit. Defaults to unbounded.
|
|
115
|
+
*/
|
|
116
|
+
readonly limit?: Maybe<number>;
|
|
117
|
+
}
|
|
118
|
+
export declare const processAllQueuedFormSpacesParamsType: Type<ProcessAllQueuedFormSpacesParams>;
|
|
119
|
+
/**
|
|
120
|
+
* Result of the backstop processing sweep.
|
|
121
|
+
*/
|
|
122
|
+
export interface ProcessAllQueuedFormSpacesResult {
|
|
123
|
+
readonly formSpacesVisited: number;
|
|
124
|
+
readonly formSpacesProcessStarted: number;
|
|
125
|
+
readonly formSpacesFailedStarting: number;
|
|
126
|
+
}
|
|
127
|
+
/**
|
|
128
|
+
* Parameters for the expiration sweep.
|
|
129
|
+
*/
|
|
130
|
+
export interface ExpireAllExpiredFormSpacesParams {
|
|
131
|
+
/**
|
|
132
|
+
* Spaces whose `eat` is at or before this instant are expired. Defaults to now.
|
|
133
|
+
*/
|
|
134
|
+
readonly before?: Maybe<Date>;
|
|
135
|
+
/**
|
|
136
|
+
* Spaces expired per page.
|
|
137
|
+
*/
|
|
138
|
+
readonly pageSize?: Maybe<number>;
|
|
139
|
+
/**
|
|
140
|
+
* Hard wall-clock budget for the whole sweep.
|
|
141
|
+
*/
|
|
142
|
+
readonly maxRunTimeMs?: Maybe<Milliseconds>;
|
|
143
|
+
/**
|
|
144
|
+
* Maximum number of pages. Defaults to unlimited, bounded by the time budget.
|
|
145
|
+
*/
|
|
146
|
+
readonly maxPages?: Maybe<number>;
|
|
147
|
+
}
|
|
148
|
+
export declare const expireAllExpiredFormSpacesParamsType: Type<ExpireAllExpiredFormSpacesParams>;
|
|
149
|
+
/**
|
|
150
|
+
* Result of the expiration sweep.
|
|
151
|
+
*/
|
|
152
|
+
export interface ExpireAllExpiredFormSpacesResult {
|
|
153
|
+
readonly formSpacesExpired: number;
|
|
154
|
+
readonly storageFilesFlaggedForDelete: number;
|
|
155
|
+
readonly pages: number;
|
|
156
|
+
/**
|
|
157
|
+
* Whether the sweep stopped because its time budget ran out rather than because nothing was left.
|
|
158
|
+
*/
|
|
159
|
+
readonly stoppedForTimeBudget: boolean;
|
|
160
|
+
readonly durationMs: Milliseconds;
|
|
161
|
+
}
|
|
162
|
+
/**
|
|
163
|
+
* Custom (non-CRUD) function type map for FormSpace. Currently empty — all operations use CRUD functions.
|
|
164
|
+
*/
|
|
165
|
+
export type FormSpaceFunctionTypeMap = {};
|
|
166
|
+
export declare const FORM_SPACE_FUNCTION_TYPE_CONFIG_MAP: FirebaseFunctionTypeConfigMap<FormSpaceFunctionTypeMap>;
|
|
167
|
+
/**
|
|
168
|
+
* CRUD function configuration map for the FormSpace model family.
|
|
169
|
+
*/
|
|
170
|
+
export type FormSpaceModelCrudFunctionsConfig = {
|
|
171
|
+
readonly formSpace: {
|
|
172
|
+
create: {
|
|
173
|
+
_: CreateFormSpaceParams;
|
|
174
|
+
};
|
|
175
|
+
update: {
|
|
176
|
+
_: UpdateFormSpaceParams;
|
|
177
|
+
submit: [SubmitFormSpaceParams, SubmitFormSpaceResult];
|
|
178
|
+
removeFile: RemoveFormSpaceFileParams;
|
|
179
|
+
};
|
|
180
|
+
delete: {
|
|
181
|
+
_: DeleteFormSpaceParams;
|
|
182
|
+
};
|
|
183
|
+
};
|
|
184
|
+
};
|
|
185
|
+
export declare const FORM_SPACE_MODEL_CRUD_FUNCTIONS_CONFIG: ModelFirebaseCrudFunctionConfigMap<FormSpaceModelCrudFunctionsConfig, FormSpaceTypes>;
|
|
186
|
+
/**
|
|
187
|
+
* Abstract class defining all callable FormSpace cloud functions.
|
|
188
|
+
*
|
|
189
|
+
* Implement this in your app module to wire up the function endpoints.
|
|
190
|
+
* Use {@link formSpaceFunctionMap} to create a client-side callable map.
|
|
191
|
+
*/
|
|
192
|
+
export declare abstract class FormSpaceFunctions implements ModelFirebaseFunctionMap<FormSpaceFunctionTypeMap, FormSpaceModelCrudFunctionsConfig> {
|
|
193
|
+
abstract formSpace: {
|
|
194
|
+
createFormSpace: {
|
|
195
|
+
create: ModelFirebaseCreateFunction<CreateFormSpaceParams, OnCallCreateModelResult>;
|
|
196
|
+
};
|
|
197
|
+
updateFormSpace: {
|
|
198
|
+
update: ModelFirebaseCrudFunction<UpdateFormSpaceParams>;
|
|
199
|
+
submit: ModelFirebaseCrudFunction<SubmitFormSpaceParams, SubmitFormSpaceResult>;
|
|
200
|
+
removeFile: ModelFirebaseCrudFunction<RemoveFormSpaceFileParams>;
|
|
201
|
+
};
|
|
202
|
+
deleteFormSpace: {
|
|
203
|
+
delete: ModelFirebaseCrudFunction<DeleteFormSpaceParams>;
|
|
204
|
+
};
|
|
205
|
+
};
|
|
206
|
+
}
|
|
207
|
+
/**
|
|
208
|
+
* Client-side callable function map factory for all FormSpace CRUD operations.
|
|
209
|
+
*
|
|
210
|
+
* @example
|
|
211
|
+
* ```ts
|
|
212
|
+
* const functions = formSpaceFunctionMap(callableFactory);
|
|
213
|
+
* const result = await functions.formSpace.createFormSpace.create({ formSpaceType: 'demo_example' });
|
|
214
|
+
* ```
|
|
215
|
+
*/
|
|
216
|
+
export declare const formSpaceFunctionMap: import("../..").ModelFirebaseFunctionMapFactory<FormSpaceFunctionTypeMap, FormSpaceModelCrudFunctionsConfig>;
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @module formspace.api.error
|
|
3
|
+
*
|
|
4
|
+
* Error codes raised by the FormSpace actions and its upload initializer.
|
|
5
|
+
*/
|
|
6
|
+
/**
|
|
7
|
+
* Thrown when a FormSpace is created for a {@link FormSpaceType} the app never registered.
|
|
8
|
+
*
|
|
9
|
+
* Unlike a SWEEP over existing documents — which falls back to {@link DEFAULT_FORM_SPACE_TYPE_CONFIG} so one
|
|
10
|
+
* bad document cannot take the pass down — creation is strict: an unregistered type has no upload rules and
|
|
11
|
+
* no handler, so a space of that type could never be filled in or submitted.
|
|
12
|
+
*/
|
|
13
|
+
export declare const FORM_SPACE_TYPE_NOT_REGISTERED_ERROR_CODE = "FORM_SPACE_TYPE_NOT_REGISTERED";
|
|
14
|
+
/**
|
|
15
|
+
* Thrown when a FormSpace is edited, uploaded into, or submitted after it stopped being a draft.
|
|
16
|
+
*/
|
|
17
|
+
export declare const FORM_SPACE_NOT_EDITABLE_ERROR_CODE = "FORM_SPACE_NOT_EDITABLE";
|
|
18
|
+
/**
|
|
19
|
+
* Thrown when a FormSpace is submitted while one of its type's required slots is still empty.
|
|
20
|
+
*/
|
|
21
|
+
export declare const FORM_SPACE_REQUIRED_SLOT_MISSING_ERROR_CODE = "FORM_SPACE_REQUIRED_SLOT_MISSING";
|
|
22
|
+
/**
|
|
23
|
+
* Thrown when a FormSpace is submitted while one of its slots holds a file validation judged invalid.
|
|
24
|
+
*
|
|
25
|
+
* Separate from {@link FORM_SPACE_REQUIRED_SLOT_MISSING_ERROR_CODE}: the slot IS filled, so telling the owner
|
|
26
|
+
* to upload something would be wrong — they need to remove or replace what is already there.
|
|
27
|
+
*/
|
|
28
|
+
export declare const FORM_SPACE_HAS_INVALID_FILES_ERROR_CODE = "FORM_SPACE_HAS_INVALID_FILES";
|
|
29
|
+
/**
|
|
30
|
+
* Thrown when a FormSpace is submitted while a slot that requires validation is still awaiting a verdict.
|
|
31
|
+
*
|
|
32
|
+
* Transient by nature — the same submission succeeds once validation concludes — which is why it is not
|
|
33
|
+
* folded into {@link FORM_SPACE_HAS_INVALID_FILES_ERROR_CODE}.
|
|
34
|
+
*/
|
|
35
|
+
export declare const FORM_SPACE_VALIDATION_PENDING_ERROR_CODE = "FORM_SPACE_VALIDATION_PENDING";
|
|
36
|
+
/**
|
|
37
|
+
* Thrown when a file is removed from a FormSpace slot that does not hold it.
|
|
38
|
+
*/
|
|
39
|
+
export declare const FORM_SPACE_FILE_NOT_FOUND_ERROR_CODE = "FORM_SPACE_FILE_NOT_FOUND";
|
|
40
|
+
/**
|
|
41
|
+
* Thrown when a caller who may reach the FormSpace may not touch THAT file of it.
|
|
42
|
+
*
|
|
43
|
+
* Distinct from a plain FORBIDDEN: the caller does hold the space-level role, and the refusal is the type's
|
|
44
|
+
* {@link FormSpaceFileAccess} narrowing it to the file's own uploader.
|
|
45
|
+
*/
|
|
46
|
+
export declare const FORM_SPACE_FILE_ACCESS_DENIED_ERROR_CODE = "FORM_SPACE_FILE_ACCESS_DENIED";
|
|
47
|
+
/**
|
|
48
|
+
* Thrown when an upload is rejected by {@link assertFormSpaceUploadAllowed}.
|
|
49
|
+
*/
|
|
50
|
+
export declare const FORM_SPACE_UPLOAD_NOT_ALLOWED_ERROR_CODE = "FORM_SPACE_UPLOAD_NOT_ALLOWED";
|
|
51
|
+
/**
|
|
52
|
+
* Thrown when a file is uploaded into a FormSpace by someone other than the user the space belongs to.
|
|
53
|
+
*/
|
|
54
|
+
export declare const FORM_SPACE_UPLOAD_USER_MISMATCH_ERROR_CODE = "FORM_SPACE_UPLOAD_USER_MISMATCH";
|
|
55
|
+
/**
|
|
56
|
+
* Thrown when a FormSpace upload path names a FormSpace that does not exist.
|
|
57
|
+
*/
|
|
58
|
+
export declare const FORM_SPACE_NOT_FOUND_ERROR_CODE = "FORM_SPACE_NOT_FOUND";
|
|
59
|
+
/**
|
|
60
|
+
* Thrown when a FormSpace is created at an explicit id that is already taken, without `getOrCreate`.
|
|
61
|
+
*
|
|
62
|
+
* Only reachable for a space keyed by {@link formSpaceIdForModel}; a generated id can never collide.
|
|
63
|
+
*/
|
|
64
|
+
export declare const FORM_SPACE_ALREADY_EXISTS_ERROR_CODE = "FORM_SPACE_ALREADY_EXISTS";
|
|
65
|
+
/**
|
|
66
|
+
* Thrown when a get-or-create resolves to an existing FormSpace of a DIFFERENT {@link FormSpaceType}.
|
|
67
|
+
*
|
|
68
|
+
* Two types keyed to the same target model derive the same id, and returning the other type's space would
|
|
69
|
+
* hand the caller a document whose slots, expiration and submission handler are all someone else's.
|
|
70
|
+
*/
|
|
71
|
+
export declare const FORM_SPACE_TYPE_MISMATCH_ERROR_CODE = "FORM_SPACE_TYPE_MISMATCH";
|