@dereekb/firebase 13.42.0 → 14.0.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.
Files changed (33) hide show
  1. package/eslint/index.esm.js +209 -302
  2. package/eslint/package.json +9 -9
  3. package/index.esm.js +5774 -3926
  4. package/package.json +10 -10
  5. package/src/lib/common/firestore/accessor/document.rxjs.d.ts +0 -4
  6. package/src/lib/common/firestore/query/accumulator.d.ts +2 -2
  7. package/src/lib/common/firestore/query/iterator.d.ts +1 -1
  8. package/src/lib/common/model/function.d.ts +0 -14
  9. package/src/lib/model/formspace/formspace.access.d.ts +139 -0
  10. package/src/lib/model/formspace/formspace.action.d.ts +34 -0
  11. package/src/lib/model/formspace/formspace.api.d.ts +240 -0
  12. package/src/lib/model/formspace/formspace.api.error.d.ts +96 -0
  13. package/src/lib/model/formspace/formspace.d.ts +461 -0
  14. package/src/lib/model/formspace/formspace.id.d.ts +60 -0
  15. package/src/lib/model/formspace/formspace.permission.d.ts +47 -0
  16. package/src/lib/model/formspace/formspace.processing.d.ts +86 -0
  17. package/src/lib/model/formspace/formspace.query.d.ts +110 -0
  18. package/src/lib/model/formspace/formspace.task.d.ts +136 -0
  19. package/src/lib/model/formspace/formspace.type.d.ts +300 -0
  20. package/src/lib/model/formspace/formspace.upload.d.ts +204 -0
  21. package/src/lib/model/formspace/formspace.util.d.ts +514 -0
  22. package/src/lib/model/formspace/index.d.ts +13 -0
  23. package/src/lib/model/index.d.ts +1 -0
  24. package/src/lib/model/notification/notification.task.d.ts +3 -1
  25. package/src/lib/model/storagefile/storagefile.api.d.ts +19 -0
  26. package/src/lib/model/storagefile/storagefile.file.d.ts +42 -2
  27. package/src/lib/model/storagefile/storagefile.upload.d.ts +30 -0
  28. package/test/index.esm.js +158 -258
  29. package/test/package.json +8 -8
  30. package/test/src/lib/common/firebase.instance.d.ts +0 -4
  31. package/test/src/lib/common/firestore/firestore.instance.d.ts +0 -4
  32. package/test/src/lib/common/mock/mock.item.collection.fixture.d.ts +0 -7
  33. package/test/src/lib/common/storage/storage.instance.d.ts +0 -4
@@ -0,0 +1,204 @@
1
+ import { type ContentTypeMimeType, type Maybe, type SlashPath, type SlashPathFile, type SlashPathFolder, type SlashPathTypedFileExtension, type SlashPathUntypedFile } from '@dereekb/util';
2
+ import { type FirebaseAuthUserId } from '../../common/auth/auth';
3
+ import { type StorageFilePurpose } from '../storagefile/storagefile.id';
4
+ import { type StorageFilePurposeUploadPolicy, type UploadedFileTypeIdentifier } from '../storagefile/storagefile.upload';
5
+ import { type FormSpaceFileSlot, type FormSpaceId } from './formspace.id';
6
+ /**
7
+ * @module formspace.upload
8
+ *
9
+ * Where a FormSpace's uploads land, and how a landed file is read back into `{ formSpaceId, slot }`.
10
+ *
11
+ * ONE purpose for every FormSpace file, across every type. The per-type rules live in the
12
+ * {@link FormSpaceTypeConfig} registry and are enforced by the initializer against the loaded FormSpace, so
13
+ * a new form type needs no new purpose, no new storage-rules block, and no new initializer.
14
+ */
15
+ /**
16
+ * {@link UploadedFileTypeIdentifier} for a file uploaded into a FormSpace.
17
+ */
18
+ export declare const FORM_SPACE_UPLOADED_FILE_TYPE_IDENTIFIER: UploadedFileTypeIdentifier;
19
+ /**
20
+ * The single {@link StorageFilePurpose} carried by every FormSpace upload.
21
+ */
22
+ export declare const FORM_SPACE_PURPOSE: StorageFilePurpose;
23
+ /**
24
+ * The folder under a user's uploads folder that FormSpace uploads land in.
25
+ */
26
+ export declare const FORM_SPACE_UPLOADS_FOLDER_NAME = "formSpace";
27
+ /**
28
+ * Returns the uploads folder path for one FormSpace slot.
29
+ *
30
+ * @param uid - The uploading Firebase Auth user id.
31
+ * @param formSpaceId - The FormSpace being uploaded into.
32
+ * @param slot - The slot being filled.
33
+ * @returns The SlashPathFolder the slot's uploads land in.
34
+ *
35
+ * @example
36
+ * ```ts
37
+ * formSpaceUploadsFolderPath('user123', 'fsp1', 'resume');
38
+ * // 'uploads/u/user123/formSpace/fsp1/resume/'
39
+ * ```
40
+ */
41
+ export declare function formSpaceUploadsFolderPath(uid: FirebaseAuthUserId, formSpaceId: FormSpaceId, slot: FormSpaceFileSlot): SlashPathFolder;
42
+ /**
43
+ * Input for {@link formSpaceUploadsFilePath}.
44
+ */
45
+ export interface FormSpaceUploadsFilePathInput {
46
+ readonly uid: FirebaseAuthUserId;
47
+ readonly formSpaceId: FormSpaceId;
48
+ readonly slot: FormSpaceFileSlot;
49
+ readonly filename: SlashPathFile;
50
+ }
51
+ /**
52
+ * Returns the full uploads path for one file in one FormSpace slot.
53
+ *
54
+ * The FormSpace id and the slot are IN THE PATH rather than in custom metadata because the initializer runs
55
+ * from a storage-triggered sweep that only ever sees the path — and because the storage rules can then keep
56
+ * the write inside the uploader's own namespace with no Firestore read.
57
+ *
58
+ * @param input - The uploader, the target space and slot, and the file name.
59
+ * @returns The full upload path.
60
+ *
61
+ * @example
62
+ * ```ts
63
+ * formSpaceUploadsFilePath({ uid: 'user123', formSpaceId: 'fsp1', slot: 'resume', filename: 'resume.pdf' });
64
+ * // 'uploads/u/user123/formSpace/fsp1/resume/resume.pdf'
65
+ * ```
66
+ *
67
+ * @__NO_SIDE_EFFECTS__
68
+ */
69
+ export declare function formSpaceUploadsFilePath(input: FormSpaceUploadsFilePathInput): SlashPath;
70
+ /**
71
+ * Root folder every FormSpace's accepted files are moved to, out of the transient uploads folder.
72
+ */
73
+ export declare const FORM_SPACE_FILES_ROOT_FOLDER_PATH: SlashPathFolder;
74
+ /**
75
+ * Input for {@link formSpaceFileStoragePath}.
76
+ */
77
+ export interface FormSpaceFileStoragePathInput {
78
+ readonly formSpaceId: FormSpaceId;
79
+ readonly slot: FormSpaceFileSlot;
80
+ /**
81
+ * The index claimed from the space's `fi` counter.
82
+ */
83
+ readonly index: number;
84
+ /**
85
+ * The extension, without its leading separator. Absent when neither the uploaded name nor its mime type
86
+ * named one.
87
+ */
88
+ readonly extension?: Maybe<SlashPathTypedFileExtension>;
89
+ }
90
+ /**
91
+ * Returns the permanent storage path an accepted FormSpace file is moved to.
92
+ *
93
+ * Keyed by the space, the slot, and a monotonic INDEX rather than by the uploaded name. A name-keyed
94
+ * destination is not unique: a file removed from the space's `f` keeps its object until the delete sweep
95
+ * runs, so re-uploading the same name overwrote it — leaving two StorageFiles on one object, where
96
+ * deleting the first destroyed the second's bytes.
97
+ *
98
+ * The leaf carries at most one separator, which is also the only shape {@link slashPathDetails} can read
99
+ * ({@link slashPathType} calls two or more `invalid`), so the destination always parses back into a name
100
+ * and an extension.
101
+ *
102
+ * @param input - The space, the slot, the claimed index, and the file's extension.
103
+ * @returns The permanent storage path.
104
+ *
105
+ * @example
106
+ * ```ts
107
+ * formSpaceFileStoragePath({ formSpaceId: 'fsp1', slot: 'resume', index: 0, extension: 'pdf' });
108
+ * // '/fsp/fsp1/resume/0.pdf'
109
+ * ```
110
+ *
111
+ * @__NO_SIDE_EFFECTS__
112
+ */
113
+ export declare function formSpaceFileStoragePath(input: FormSpaceFileStoragePathInput): SlashPath;
114
+ /**
115
+ * Input for {@link formSpaceUploadFileNameDetails}.
116
+ */
117
+ export interface FormSpaceUploadFileNameDetailsInput {
118
+ readonly filename: SlashPathFile;
119
+ /**
120
+ * The uploaded file's content type, used to name the extension when the filename does not.
121
+ */
122
+ readonly mimeType?: Maybe<ContentTypeMimeType>;
123
+ }
124
+ /**
125
+ * The uploaded name, split into the parts each layer stores.
126
+ */
127
+ export interface FormSpaceUploadFileNameDetails {
128
+ /**
129
+ * The name without its extension, for the StorageFile's `n` — which is UNTYPED by contract (see
130
+ * {@link StorageFileDisplayName}) because the zip builder merges it with the path's extension.
131
+ *
132
+ * Absent for a name that is nothing but an extension, such as `.gitignore`.
133
+ */
134
+ readonly displayName?: Maybe<SlashPathUntypedFile>;
135
+ /**
136
+ * The extension for the destination leaf.
137
+ */
138
+ readonly extension?: Maybe<SlashPathTypedFileExtension>;
139
+ /**
140
+ * The two recomposed — what the FormSpace's `f` entry records as the file's name, and what a download
141
+ * of it is named.
142
+ */
143
+ readonly fileName: SlashPathFile;
144
+ }
145
+ /**
146
+ * Splits an uploaded filename into the display name and extension the rest of the pipeline stores.
147
+ *
148
+ * Normalizes first: an uploaded name may carry any number of separators, and {@link slashPathDetails}
149
+ * reads a path with two or more as `invalid` and yields neither a name nor an extension for it. The
150
+ * canonical {@link replaceInvalidFilePathTypeSeparatorsInSlashPath} collapses it to at most one, so
151
+ * `my.report.pdf` becomes `my_report.pdf` rather than losing its extension entirely.
152
+ *
153
+ * Falls back to the mime type for a name that has no extension, which keeps the stored object
154
+ * self-describing and keeps `fileName` in step with what a download or a zip entry is actually called.
155
+ *
156
+ * @param input - The uploaded filename and its content type.
157
+ * @returns The display name, the extension, and the two recomposed.
158
+ *
159
+ * @example
160
+ * ```ts
161
+ * formSpaceUploadFileNameDetails({ filename: 'resume.pdf' });
162
+ * // { displayName: 'resume', extension: 'pdf', fileName: 'resume.pdf' }
163
+ * ```
164
+ *
165
+ * @__NO_SIDE_EFFECTS__
166
+ */
167
+ export declare function formSpaceUploadFileNameDetails(input: FormSpaceUploadFileNameDetailsInput): FormSpaceUploadFileNameDetails;
168
+ /**
169
+ * The pieces {@link parseFormSpaceUploadPath} recovers from a FormSpace upload path.
170
+ */
171
+ export interface ParsedFormSpaceUploadPath {
172
+ readonly uid: FirebaseAuthUserId;
173
+ readonly formSpaceId: FormSpaceId;
174
+ readonly slot: FormSpaceFileSlot;
175
+ readonly filename: SlashPathFile;
176
+ }
177
+ /**
178
+ * Reads a FormSpace upload path back into its parts.
179
+ *
180
+ * Returns null for anything that is not exactly a FormSpace upload path, including a path with extra
181
+ * segments: a nested path would otherwise resolve to a slot name that no config declares, and silently
182
+ * widening the parse is how an upload lands somewhere nobody validated.
183
+ *
184
+ * @param path - The path to parse.
185
+ * @returns The parsed parts, or null when the path is not a FormSpace upload path.
186
+ *
187
+ * @example
188
+ * ```ts
189
+ * parseFormSpaceUploadPath('uploads/u/user123/formSpace/fsp1/resume/resume.pdf');
190
+ * // { uid: 'user123', formSpaceId: 'fsp1', slot: 'resume', filename: 'resume.pdf' }
191
+ * ```
192
+ *
193
+ * @__NO_SIDE_EFFECTS__
194
+ */
195
+ export declare function parseFormSpaceUploadPath(path: SlashPath): Maybe<ParsedFormSpaceUploadPath>;
196
+ /**
197
+ * Upload policy for {@link FORM_SPACE_PURPOSE}.
198
+ *
199
+ * The caps here are the OUTER bound — the widest a FormSpace upload may ever be — and they are what
200
+ * `storage.rules` mirrors. The per-type and per-slot rules in the {@link FormSpaceTypeConfig} registry
201
+ * narrow it further, and are enforced by the initializer, which is the only layer that can read the
202
+ * FormSpace to learn which type it even is.
203
+ */
204
+ export declare const FORM_SPACE_UPLOAD_POLICY: StorageFilePurposeUploadPolicy;