@dereekb/firebase 13.11.18 → 13.12.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.cjs.js +6769 -1967
- package/eslint/index.esm.js +6747 -1968
- package/eslint/package.json +4 -2
- package/eslint/rollup.alias-internal.config.d.ts +1 -0
- package/eslint/src/lib/firebase-rules-text.d.ts +121 -0
- package/eslint/src/lib/firestore-rules-parser.d.ts +61 -0
- package/eslint/src/lib/index.d.ts +8 -0
- package/eslint/src/lib/plugin.d.ts +12 -0
- package/eslint/src/lib/predicate-evaluator.d.ts +47 -0
- package/eslint/src/lib/require-api-details-for-crud-function.rule.d.ts +83 -0
- package/eslint/src/lib/require-dbx-model-companion-tags.rule.d.ts +47 -0
- package/eslint/src/lib/require-dbx-model-service-factory-tag.rule.d.ts +56 -0
- package/eslint/src/lib/require-firestore-rule-for-service-model.rule.d.ts +115 -0
- package/eslint/src/lib/require-service-factory-for-dbx-model.rule.d.ts +80 -0
- package/eslint/src/lib/require-storagefile-policy-matches-rules.rule.d.ts +79 -0
- package/eslint/src/lib/storage-rules-parser.d.ts +38 -0
- package/index.cjs.js +53 -5
- package/index.esm.js +46 -6
- package/package.json +5 -5
- package/src/lib/common/auth/auth.d.ts +8 -0
- package/src/lib/common/auth/oidc/oidc.d.ts +7 -5
- package/src/lib/common/model/function.d.ts +12 -1
- package/src/lib/model/notification/notification.d.ts +6 -0
- package/src/lib/model/oidcmodel/oidcmodel.d.ts +1 -0
- package/src/lib/model/storagefile/storagefile.api.d.ts +113 -2
- package/src/lib/model/storagefile/storagefile.d.ts +2 -0
- package/src/lib/model/storagefile/storagefile.upload.d.ts +33 -1
- package/src/lib/model/system/system.d.ts +1 -0
- package/test/index.cjs.js +2 -4
- package/test/index.esm.js +2 -4
- package/test/package.json +6 -6
- package/eslint/src/lib/comments.d.ts +0 -112
- package/eslint/src/lib/dbx-tag-families.d.ts +0 -280
- package/eslint/src/lib/jsdoc-parser.d.ts +0 -116
|
@@ -12,24 +12,26 @@ export declare const READ_MODEL_OIDC_SCOPE: "model.read";
|
|
|
12
12
|
export declare const UPDATE_MODEL_OIDC_SCOPE: "model.update";
|
|
13
13
|
export declare const DELETE_MODEL_OIDC_SCOPE: "model.delete";
|
|
14
14
|
export declare const QUERY_MODEL_OIDC_SCOPE: "model.query";
|
|
15
|
+
export declare const INVOKE_MODEL_OIDC_SCOPE: "model.invoke";
|
|
15
16
|
export type CreateModelOidcScope = typeof CREATE_MODEL_OIDC_SCOPE;
|
|
16
17
|
export type ReadModelOidcScope = typeof READ_MODEL_OIDC_SCOPE;
|
|
17
18
|
export type UpdateModelOidcScope = typeof UPDATE_MODEL_OIDC_SCOPE;
|
|
18
19
|
export type DeleteModelOidcScope = typeof DELETE_MODEL_OIDC_SCOPE;
|
|
19
20
|
export type QueryModelOidcScope = typeof QUERY_MODEL_OIDC_SCOPE;
|
|
21
|
+
export type InvokeModelOidcScope = typeof INVOKE_MODEL_OIDC_SCOPE;
|
|
20
22
|
/**
|
|
21
|
-
* Canonical CRUD scopes enforced on the `callModel` API.
|
|
23
|
+
* Canonical CRUD + invoke scopes enforced on the `callModel` API.
|
|
22
24
|
*
|
|
23
25
|
* Each scope corresponds 1:1 to a {@link KnownOnCallFunctionType}; see
|
|
24
26
|
* {@link CALL_MODEL_OIDC_SCOPE_FOR_CALL_TYPE}.
|
|
25
27
|
*/
|
|
26
|
-
export declare const CALL_MODEL_OIDC_SCOPES: readonly ["model.create", "model.read", "model.update", "model.delete", "model.query"];
|
|
28
|
+
export declare const CALL_MODEL_OIDC_SCOPES: readonly ["model.create", "model.read", "model.update", "model.delete", "model.query", "model.invoke"];
|
|
27
29
|
/**
|
|
28
|
-
* Union of the
|
|
30
|
+
* Union of the six canonical callModel scope strings (CRUDQ + invoke).
|
|
29
31
|
*/
|
|
30
|
-
export type CallModelOidcScope = CreateModelOidcScope | ReadModelOidcScope | UpdateModelOidcScope | DeleteModelOidcScope | QueryModelOidcScope;
|
|
32
|
+
export type CallModelOidcScope = CreateModelOidcScope | ReadModelOidcScope | UpdateModelOidcScope | DeleteModelOidcScope | QueryModelOidcScope | InvokeModelOidcScope;
|
|
31
33
|
/**
|
|
32
|
-
* Maps each known
|
|
34
|
+
* Maps each known call type to the scope an OIDC token must carry to invoke it.
|
|
33
35
|
*/
|
|
34
36
|
export declare const CALL_MODEL_OIDC_SCOPE_FOR_CALL_TYPE: Readonly<Record<KnownOnCallFunctionType, CallModelOidcScope>>;
|
|
35
37
|
/**
|
|
@@ -3,8 +3,11 @@ import { type DocumentReferenceRef } from '../firestore/reference';
|
|
|
3
3
|
import { type FirestoreModelKey, type FirestoreModelType, type FirestoreModelTypeRef } from '../firestore/collection/collection';
|
|
4
4
|
/**
|
|
5
5
|
* Standard CRUD call types used by the `callModel` Firebase function pattern.
|
|
6
|
+
*
|
|
7
|
+
* CRUDQ + I: 'invoke' covers side-effecting RPC-style operations that don't fit any CRUD verb
|
|
8
|
+
* (e.g. regenerate-thumbnails, resync-with-external, recompute-index).
|
|
6
9
|
*/
|
|
7
|
-
export type KnownOnCallFunctionType = 'create' | 'read' | 'update' | 'delete' | 'query';
|
|
10
|
+
export type KnownOnCallFunctionType = 'create' | 'read' | 'update' | 'delete' | 'query' | 'invoke';
|
|
8
11
|
/**
|
|
9
12
|
* Call type identifier — one of the standard CRUD types or a custom string.
|
|
10
13
|
*/
|
|
@@ -74,6 +77,10 @@ export declare const onCallDeleteModelParams: OnCallTypeModelParamsFunction;
|
|
|
74
77
|
* Pre-configured OnCallTypedModelParamsFunctions for 'query'
|
|
75
78
|
*/
|
|
76
79
|
export declare const onCallQueryModelParams: OnCallTypeModelParamsFunction;
|
|
80
|
+
/**
|
|
81
|
+
* Pre-configured OnCallTypedModelParamsFunctions for 'invoke'
|
|
82
|
+
*/
|
|
83
|
+
export declare const onCallInvokeModelParams: OnCallTypeModelParamsFunction;
|
|
77
84
|
/**
|
|
78
85
|
* Key used on the front-end and backend that refers to the call function.
|
|
79
86
|
*/
|
|
@@ -98,6 +105,10 @@ export type OnCallDeleteModelParams<T = unknown> = OnCallTypedModelParams<T>;
|
|
|
98
105
|
* OnCallTypedModelParams for Query calls.
|
|
99
106
|
*/
|
|
100
107
|
export type OnCallQueryModelParams<T extends OnCallQueryModelRequestParams = OnCallQueryModelRequestParams> = OnCallTypedModelParams<T>;
|
|
108
|
+
/**
|
|
109
|
+
* OnCallTypedModelParams for Invoke calls.
|
|
110
|
+
*/
|
|
111
|
+
export type OnCallInvokeModelParams<T = unknown> = OnCallTypedModelParams<T>;
|
|
101
112
|
/**
|
|
102
113
|
* Default maximum items per page for query operations.
|
|
103
114
|
*/
|
|
@@ -91,6 +91,7 @@ export declare const notificationUserIdentity: import("../..").RootFirestoreMode
|
|
|
91
91
|
* @see `NotificationServerActions.updateNotificationUser` in `@dereekb/firebase-server/model` for server-side sync logic
|
|
92
92
|
*
|
|
93
93
|
* @dbxModel
|
|
94
|
+
* @dbxModelRead system
|
|
94
95
|
*/
|
|
95
96
|
export interface NotificationUser extends UserRelated, UserRelatedById {
|
|
96
97
|
/**
|
|
@@ -194,6 +195,7 @@ export declare const NOTIFICATION_SUMMARY_EMBEDDED_NOTIFICATION_ITEM_MESSAGE_MAX
|
|
|
194
195
|
* Implements {@link InitializedNotificationModel} — requires server-side initialization to populate the owner (`o`) field.
|
|
195
196
|
*
|
|
196
197
|
* @dbxModel
|
|
198
|
+
* @dbxModelRead system
|
|
197
199
|
* @dbxModelArchetype root-singleton-aggregate
|
|
198
200
|
* @dbxModelArchetype composite-key-root
|
|
199
201
|
* @dbxModelCompositeKey from=* encoding=two-way
|
|
@@ -291,6 +293,7 @@ export declare const notificationBoxIdentity: import("../..").RootFirestoreModel
|
|
|
291
293
|
* @see `NotificationServerActions.createNotificationBox` in `@dereekb/firebase-server/model` for creation logic
|
|
292
294
|
*
|
|
293
295
|
* @dbxModel
|
|
296
|
+
* @dbxModelRead system
|
|
294
297
|
* @dbxModelArchetype composite-key-root
|
|
295
298
|
* @dbxModelCompositeKey from=* encoding=two-way
|
|
296
299
|
*/
|
|
@@ -578,6 +581,7 @@ export interface NotificationSendCheckpoints {
|
|
|
578
581
|
* @see `NotificationServerActions.sendQueuedNotifications` in `@dereekb/firebase-server/model` for the send pipeline
|
|
579
582
|
*
|
|
580
583
|
* @dbxModel
|
|
584
|
+
* @dbxModelRead system
|
|
581
585
|
*/
|
|
582
586
|
export interface Notification extends NotificationSendFlags, NotificationSendCheckpoints {
|
|
583
587
|
/**
|
|
@@ -737,6 +741,7 @@ export declare const NOTIFICATION_WEEK_NOTIFICATION_ITEM_LIMIT = 5000;
|
|
|
737
741
|
* Used for historical browsing of past notifications per box.
|
|
738
742
|
*
|
|
739
743
|
* @dbxModel
|
|
744
|
+
* @dbxModelRead system
|
|
740
745
|
*/
|
|
741
746
|
export interface NotificationWeek {
|
|
742
747
|
/**
|
|
@@ -837,6 +842,7 @@ export declare const NOTIFICATION_LOGGED_EVENT_DAY_ITEM_CONVERTER: PagedItemConv
|
|
|
837
842
|
* items are distributed across pages by {@link makePagedItemFirestoreCollection}.
|
|
838
843
|
*
|
|
839
844
|
* @dbxModel
|
|
845
|
+
* @dbxModelRead system
|
|
840
846
|
*/
|
|
841
847
|
export interface NotificationLoggedEventDay {
|
|
842
848
|
/**
|
|
@@ -46,6 +46,7 @@ export declare const OIDC_ENTRY_CLIENT_TYPE: OidcEntryType;
|
|
|
46
46
|
* (used primarily for Client entries so users can query their own registered OAuth clients).
|
|
47
47
|
*
|
|
48
48
|
* @dbxModel
|
|
49
|
+
* @dbxModelRead permissions
|
|
49
50
|
* @dbxModelArchetype reference-registry hasChildren=false,hasInheritance=false
|
|
50
51
|
*/
|
|
51
52
|
export interface OidcEntry {
|
|
@@ -2,9 +2,9 @@ import { type Type } from 'arktype';
|
|
|
2
2
|
import { type TargetModelParams, type OnCallCreateModelResult, type FirestoreModelKey } from '../../common';
|
|
3
3
|
import { type ModelFirebaseCrudFunction, type FirebaseFunctionTypeConfigMap, type ModelFirebaseCrudFunctionConfigMap, type ModelFirebaseFunctionMap, type ModelFirebaseCreateFunction } from '../../client';
|
|
4
4
|
import { type StorageFileSignedDownloadUrl, type StorageFileTypes } from './storagefile';
|
|
5
|
-
import { type StorageFileKey, type StorageFileId } from './storagefile.id';
|
|
5
|
+
import { type StorageFileKey, type StorageFileId, type StorageFilePurpose } from './storagefile.id';
|
|
6
6
|
import { type StorageBucketId, type StoragePath, type StorageSlashPath } from '../../common/storage';
|
|
7
|
-
import { type ContentDispositionString, type ContentTypeMimeType, type Maybe, type Milliseconds, type UnixDateTimeSecondsNumber } from '@dereekb/util';
|
|
7
|
+
import { type ContentDispositionString, type ContentTypeMimeType, type Maybe, type Milliseconds, type SlashPath, type SlashPathFile, type UnixDateTimeMillisecondsNumber, type UnixDateTimeSecondsNumber } from '@dereekb/util';
|
|
8
8
|
import { type SendNotificationResult } from '../notification/notification.api';
|
|
9
9
|
export declare const DOWNLOAD_MULTIPLE_STORAGE_FILES_MIN_FILES = 1;
|
|
10
10
|
export declare const DOWNLOAD_MULTIPLE_STORAGE_FILES_MAX_FILES = 50;
|
|
@@ -187,6 +187,115 @@ export interface DownloadMultipleStorageFilesResult {
|
|
|
187
187
|
readonly success: DownloadMultipleStorageFileSuccessItem[];
|
|
188
188
|
readonly errors: DownloadMultipleStorageFileErrorItem[];
|
|
189
189
|
}
|
|
190
|
+
/**
|
|
191
|
+
* Lower bound for caller-supplied `expiresInMs` on signed-upload-url generation.
|
|
192
|
+
*
|
|
193
|
+
* Anything shorter than 30 seconds is unrealistic for a caller to pick up a
|
|
194
|
+
* URL, perform the PUT, and acknowledge before the URL expires.
|
|
195
|
+
*/
|
|
196
|
+
export declare const CREATE_STORAGE_FILE_SIGNED_UPLOAD_URL_MIN_EXPIRES_IN_MS: Milliseconds;
|
|
197
|
+
/**
|
|
198
|
+
* Upper bound for caller-supplied `expiresInMs` on signed-upload-url generation.
|
|
199
|
+
*
|
|
200
|
+
* 10 minutes is the longest acceptable window for a one-shot upload URL. Any
|
|
201
|
+
* legitimate caller should be uploading within this window; longer windows
|
|
202
|
+
* increase the blast radius if the URL leaks.
|
|
203
|
+
*/
|
|
204
|
+
export declare const CREATE_STORAGE_FILE_SIGNED_UPLOAD_URL_MAX_EXPIRES_IN_MS: Milliseconds;
|
|
205
|
+
/**
|
|
206
|
+
* Default `expiresInMs` applied when the caller does not supply one.
|
|
207
|
+
*/
|
|
208
|
+
export declare const DEFAULT_CREATE_STORAGE_FILE_SIGNED_UPLOAD_URL_EXPIRES_IN_MS: Milliseconds;
|
|
209
|
+
/**
|
|
210
|
+
* Maximum length of a caller-supplied filename. Enforced both at the ArkType
|
|
211
|
+
* layer and again by the handler's sanitizer.
|
|
212
|
+
*/
|
|
213
|
+
export declare const CREATE_STORAGE_FILE_SIGNED_UPLOAD_URL_MAX_FILENAME_LENGTH = 200;
|
|
214
|
+
/**
|
|
215
|
+
* Parameters for creating a short-lived signed PUT URL for a StorageFile upload.
|
|
216
|
+
*
|
|
217
|
+
* The resulting URL is restricted to a specific {@link StorageFilePurpose}, MIME
|
|
218
|
+
* type, and file size and lands the bytes inside the authenticated caller's
|
|
219
|
+
* `/uploads/u/{uid}/...` namespace. Once uploaded, the existing
|
|
220
|
+
* `StorageFileInitializeFromUploadService` flow picks the file up and creates
|
|
221
|
+
* the matching `StorageFile` document.
|
|
222
|
+
*/
|
|
223
|
+
export interface CreateStorageFileSignedUploadUrlParams {
|
|
224
|
+
/**
|
|
225
|
+
* The {@link StorageFilePurpose} to upload as. Must be supported by the
|
|
226
|
+
* app's signed-upload-url policy registry. The chosen policy decides where
|
|
227
|
+
* the file lands and which content-types/sizes are allowed.
|
|
228
|
+
*/
|
|
229
|
+
readonly purpose: StorageFilePurpose;
|
|
230
|
+
/**
|
|
231
|
+
* The MIME type the client intends to PUT. Validated against the policy's
|
|
232
|
+
* `allowedMimeTypes` and signed into the URL so GCS rejects any PUT with a
|
|
233
|
+
* different `Content-Type`.
|
|
234
|
+
*/
|
|
235
|
+
readonly contentType: ContentTypeMimeType;
|
|
236
|
+
/**
|
|
237
|
+
* Filename to place inside the policy's upload folder. Required when the
|
|
238
|
+
* policy has `requiresFilenameInput: true`. Sanitized server-side — must not
|
|
239
|
+
* contain `/`, `..`, or NUL bytes; capped at
|
|
240
|
+
* {@link CREATE_STORAGE_FILE_SIGNED_UPLOAD_URL_MAX_FILENAME_LENGTH} chars.
|
|
241
|
+
*/
|
|
242
|
+
readonly filename?: Maybe<SlashPathFile>;
|
|
243
|
+
/**
|
|
244
|
+
* Client-declared size in bytes for the upload. Validated against the
|
|
245
|
+
* policy's `maxFileSizeBytes` cap. The storage rules independently enforce
|
|
246
|
+
* the same cap via `request.resource.size`.
|
|
247
|
+
*/
|
|
248
|
+
readonly fileSizeBytes: number;
|
|
249
|
+
/**
|
|
250
|
+
* Lifetime of the signed URL in milliseconds. Clamped to
|
|
251
|
+
* [{@link CREATE_STORAGE_FILE_SIGNED_UPLOAD_URL_MIN_EXPIRES_IN_MS},
|
|
252
|
+
* {@link CREATE_STORAGE_FILE_SIGNED_UPLOAD_URL_MAX_EXPIRES_IN_MS}].
|
|
253
|
+
* Defaults to {@link DEFAULT_CREATE_STORAGE_FILE_SIGNED_UPLOAD_URL_EXPIRES_IN_MS}
|
|
254
|
+
* when omitted.
|
|
255
|
+
*/
|
|
256
|
+
readonly expiresInMs?: Maybe<Milliseconds>;
|
|
257
|
+
}
|
|
258
|
+
export declare const createStorageFileSignedUploadUrlParamsType: Type<CreateStorageFileSignedUploadUrlParams>;
|
|
259
|
+
/**
|
|
260
|
+
* Result of creating a signed upload URL.
|
|
261
|
+
*
|
|
262
|
+
* The caller PUTs the file bytes to {@link uploadUrl} with the headers in
|
|
263
|
+
* {@link requiredHeaders}. The existing initializer flow then picks the file
|
|
264
|
+
* up from {@link uploadPath} and creates the StorageFile document.
|
|
265
|
+
*
|
|
266
|
+
* `modelKeys` is intentionally empty — minting the URL does not create a
|
|
267
|
+
* StorageFile document; the document is created later by the upload-complete
|
|
268
|
+
* pipeline.
|
|
269
|
+
*/
|
|
270
|
+
export interface CreateStorageFileSignedUploadUrlResult extends OnCallCreateModelResult {
|
|
271
|
+
readonly modelKeys: [];
|
|
272
|
+
/**
|
|
273
|
+
* Short-lived, content-type-pinned PUT URL.
|
|
274
|
+
*/
|
|
275
|
+
readonly uploadUrl: string;
|
|
276
|
+
/**
|
|
277
|
+
* The full storage path the URL writes to (inside `/uploads/u/{uid}/...`).
|
|
278
|
+
* Returned so the caller can confirm where the file landed.
|
|
279
|
+
*/
|
|
280
|
+
readonly uploadPath: SlashPath;
|
|
281
|
+
/**
|
|
282
|
+
* Unix millisecond timestamp at which the URL expires.
|
|
283
|
+
*/
|
|
284
|
+
readonly expiresAt: UnixDateTimeMillisecondsNumber;
|
|
285
|
+
/**
|
|
286
|
+
* Headers the caller MUST send on the PUT for the signature to validate.
|
|
287
|
+
* At minimum, the `content-type` matches the signed value.
|
|
288
|
+
*/
|
|
289
|
+
readonly requiredHeaders: Readonly<Record<string, string>>;
|
|
290
|
+
/**
|
|
291
|
+
* Echo of the policy's `maxFileSizeBytes` cap, for caller-side validation.
|
|
292
|
+
*/
|
|
293
|
+
readonly maxFileSizeBytes: number;
|
|
294
|
+
/**
|
|
295
|
+
* The resolved {@link StorageFilePurpose}.
|
|
296
|
+
*/
|
|
297
|
+
readonly purpose: StorageFilePurpose;
|
|
298
|
+
}
|
|
190
299
|
/**
|
|
191
300
|
* Used for creating or initializing a new StorageFileGroup for a StorageFile.
|
|
192
301
|
*
|
|
@@ -274,6 +383,7 @@ export type StorageFileModelCrudFunctionsConfig = {
|
|
|
274
383
|
_: CreateStorageFileParams;
|
|
275
384
|
fromUpload: InitializeStorageFileFromUploadParams;
|
|
276
385
|
allFromUpload: [InitializeAllStorageFilesFromUploadsParams, InitializeAllStorageFilesFromUploadsResult];
|
|
386
|
+
signedUploadUrl: [CreateStorageFileSignedUploadUrlParams, CreateStorageFileSignedUploadUrlResult];
|
|
277
387
|
};
|
|
278
388
|
update: {
|
|
279
389
|
_: UpdateStorageFileParams;
|
|
@@ -308,6 +418,7 @@ export declare abstract class StorageFileFunctions implements ModelFirebaseFunct
|
|
|
308
418
|
create: ModelFirebaseCreateFunction<CreateStorageFileParams, OnCallCreateModelResult>;
|
|
309
419
|
fromUpload: ModelFirebaseCreateFunction<InitializeStorageFileFromUploadParams, OnCallCreateModelResult>;
|
|
310
420
|
allFromUpload: ModelFirebaseCrudFunction<InitializeAllStorageFilesFromUploadsParams, InitializeAllStorageFilesFromUploadsResult>;
|
|
421
|
+
signedUploadUrl: ModelFirebaseCreateFunction<CreateStorageFileSignedUploadUrlParams, CreateStorageFileSignedUploadUrlResult>;
|
|
311
422
|
};
|
|
312
423
|
updateStorageFile: {
|
|
313
424
|
update: ModelFirebaseCrudFunction<UpdateStorageFileParams>;
|
|
@@ -263,6 +263,7 @@ export type StorageFileDownloadUrl = StorageFilePublicDownloadUrl | StorageFileS
|
|
|
263
263
|
*
|
|
264
264
|
* @template M - type of the arbitrary metadata stored in the `d` field
|
|
265
265
|
* @dbxModel
|
|
266
|
+
* @dbxModelRead permissions
|
|
266
267
|
* @dbxModelArchetype root-entity
|
|
267
268
|
* @dbxModelArchetype state-machine-item
|
|
268
269
|
*/
|
|
@@ -502,6 +503,7 @@ export declare const storageFileGroupEmbeddedFile: import("../..").FirestoreSubO
|
|
|
502
503
|
* the `s` (needs sync) flag is set on creation and cleared once initialized.
|
|
503
504
|
*
|
|
504
505
|
* @dbxModel
|
|
506
|
+
* @dbxModelRead admin-only
|
|
505
507
|
*/
|
|
506
508
|
export interface StorageFileGroup extends InitializedStorageFileModel {
|
|
507
509
|
/**
|
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
import { type FactoryWithRequiredInput, type Maybe, type SlashPath } from '@dereekb/util';
|
|
1
|
+
import { type ContentTypeMimeType, type FactoryWithRequiredInput, type Maybe, type SlashPath, type SlashPathFile } from '@dereekb/util';
|
|
2
2
|
import { type StoragePath } from '../../common/storage/storage';
|
|
3
3
|
import { type FirebaseAuthUserId } from '../../common';
|
|
4
|
+
import { type StorageFilePurpose } from './storagefile.id';
|
|
4
5
|
/**
|
|
5
6
|
* Root path for all uploaded files in Firebase Storage.
|
|
6
7
|
*
|
|
@@ -97,3 +98,34 @@ export type UploadedFileTypeIdentifier = string;
|
|
|
97
98
|
* - `permanent_initializer_failure` — the initializer failed permanently; the file should be deleted
|
|
98
99
|
*/
|
|
99
100
|
export type StorageFileInitializeFromUploadResultType = 'success' | 'no_determiner_match' | 'no_initializer_configured' | 'initializer_error' | 'permanent_initializer_failure';
|
|
101
|
+
/**
|
|
102
|
+
* Input passed to {@link StorageFilePurposeUploadPolicy.buildUploadPath} when
|
|
103
|
+
* computing the upload destination for a signed-upload-url.
|
|
104
|
+
*/
|
|
105
|
+
export interface StorageFilePurposeUploadPolicyBuildPathInput {
|
|
106
|
+
readonly uid: FirebaseAuthUserId;
|
|
107
|
+
readonly filename?: Maybe<SlashPathFile>;
|
|
108
|
+
}
|
|
109
|
+
/**
|
|
110
|
+
* Per-purpose constraints for generating short-lived signed upload URLs.
|
|
111
|
+
*
|
|
112
|
+
* Implementations are kept in app-level registries (e.g.
|
|
113
|
+
* `STORAGE_FILE_PURPOSE_UPLOAD_POLICIES` in demo-firebase) and wired into the
|
|
114
|
+
* server-action context so the `createStorageFileSignedUploadUrl` action can
|
|
115
|
+
* resolve the policy by purpose at request time.
|
|
116
|
+
*
|
|
117
|
+
* The policy ensures the URL it signs targets a path and content-type that
|
|
118
|
+
* both `storage.rules` and the matching `StorageFileInitializeFromUploadService`
|
|
119
|
+
* initializer accept.
|
|
120
|
+
*/
|
|
121
|
+
export interface StorageFilePurposeUploadPolicy {
|
|
122
|
+
readonly purpose: StorageFilePurpose;
|
|
123
|
+
readonly allowedMimeTypes: readonly ContentTypeMimeType[];
|
|
124
|
+
readonly maxFileSizeBytes: number;
|
|
125
|
+
readonly buildUploadPath: (input: StorageFilePurposeUploadPolicyBuildPathInput) => SlashPath;
|
|
126
|
+
/**
|
|
127
|
+
* When true, the caller MUST provide a filename for `buildUploadPath`.
|
|
128
|
+
* When false (e.g. avatar), the path is derived solely from the uid.
|
|
129
|
+
*/
|
|
130
|
+
readonly requiresFilenameInput: boolean;
|
|
131
|
+
}
|
|
@@ -60,6 +60,7 @@ export type SystemStateStoredData = Record<string, any>;
|
|
|
60
60
|
*
|
|
61
61
|
* @template T - shape of the stored data record
|
|
62
62
|
* @dbxModel
|
|
63
|
+
* @dbxModelRead system
|
|
63
64
|
* @dbxModelArchetype system-state-singleton
|
|
64
65
|
*/
|
|
65
66
|
export interface SystemState<T extends SystemStateStoredData = SystemStateStoredData> {
|
package/test/index.cjs.js
CHANGED
|
@@ -1471,12 +1471,10 @@ function _is_native_reflect_construct$4() {
|
|
|
1471
1471
|
}(firebase.AbstractFirestoreDocument);
|
|
1472
1472
|
/**
|
|
1473
1473
|
* Firestore collection path name.
|
|
1474
|
-
*/
|
|
1475
|
-
var MOCK_ITEM_USER_COLLECTION_NAME = 'mockItemUser';
|
|
1474
|
+
*/ var MOCK_ITEM_USER_COLLECTION_NAME = 'mockItemUser';
|
|
1476
1475
|
/**
|
|
1477
1476
|
* Default document identifier used for MockItemUser in tests.
|
|
1478
|
-
*/
|
|
1479
|
-
var MOCK_ITEM_USER_IDENTIFIER = '0';
|
|
1477
|
+
*/ var MOCK_ITEM_USER_IDENTIFIER = '0';
|
|
1480
1478
|
/**
|
|
1481
1479
|
* Used to build a FirestoreDataConverter. Fields are configured via configuration. See the SnapshotConverterFunctions for more info.
|
|
1482
1480
|
*/ var mockItemUserConverter = firebase.snapshotConverterFunctions({
|
package/test/index.esm.js
CHANGED
|
@@ -1469,12 +1469,10 @@ function _is_native_reflect_construct$4() {
|
|
|
1469
1469
|
}(AbstractFirestoreDocument);
|
|
1470
1470
|
/**
|
|
1471
1471
|
* Firestore collection path name.
|
|
1472
|
-
*/
|
|
1473
|
-
var MOCK_ITEM_USER_COLLECTION_NAME = 'mockItemUser';
|
|
1472
|
+
*/ var MOCK_ITEM_USER_COLLECTION_NAME = 'mockItemUser';
|
|
1474
1473
|
/**
|
|
1475
1474
|
* Default document identifier used for MockItemUser in tests.
|
|
1476
|
-
*/
|
|
1477
|
-
var MOCK_ITEM_USER_IDENTIFIER = '0';
|
|
1475
|
+
*/ var MOCK_ITEM_USER_IDENTIFIER = '0';
|
|
1478
1476
|
/**
|
|
1479
1477
|
* Used to build a FirestoreDataConverter. Fields are configured via configuration. See the SnapshotConverterFunctions for more info.
|
|
1480
1478
|
*/ var mockItemUserConverter = snapshotConverterFunctions({
|
package/test/package.json
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dereekb/firebase/test",
|
|
3
|
-
"version": "13.
|
|
3
|
+
"version": "13.12.0",
|
|
4
4
|
"peerDependencies": {
|
|
5
|
-
"@dereekb/date": "13.
|
|
6
|
-
"@dereekb/firebase": "13.
|
|
7
|
-
"@dereekb/model": "13.
|
|
8
|
-
"@dereekb/rxjs": "13.
|
|
9
|
-
"@dereekb/util": "13.
|
|
5
|
+
"@dereekb/date": "13.12.0",
|
|
6
|
+
"@dereekb/firebase": "13.12.0",
|
|
7
|
+
"@dereekb/model": "13.12.0",
|
|
8
|
+
"@dereekb/rxjs": "13.12.0",
|
|
9
|
+
"@dereekb/util": "13.12.0",
|
|
10
10
|
"@firebase/rules-unit-testing": "5.0.0",
|
|
11
11
|
"date-fns": "^4.1.0",
|
|
12
12
|
"firebase": "^12.12.1",
|
|
@@ -1,112 +0,0 @@
|
|
|
1
|
-
import type { Maybe } from '@dereekb/util';
|
|
2
|
-
/**
|
|
3
|
-
* The bundler hint string that marks a function call as side-effect-free.
|
|
4
|
-
*/
|
|
5
|
-
export declare const NO_SIDE_EFFECTS_TAG = "@__NO_SIDE_EFFECTS__";
|
|
6
|
-
type AstNode = any;
|
|
7
|
-
export interface JsdocCommentInfo {
|
|
8
|
-
readonly node: AstNode;
|
|
9
|
-
readonly text: string;
|
|
10
|
-
readonly hasNoSideEffects: boolean;
|
|
11
|
-
}
|
|
12
|
-
export interface FunctionLeadingContext {
|
|
13
|
-
readonly jsdoc: Maybe<JsdocCommentInfo>;
|
|
14
|
-
/**
|
|
15
|
-
* Adjacent `@__NO_SIDE_EFFECTS__` line/block comments that should be migrated into the JSDoc
|
|
16
|
-
* and removed. Excludes the implementation-leading annotation on overloaded functions, which
|
|
17
|
-
* is tracked separately by {@link implLineComment} because it must be preserved.
|
|
18
|
-
*/
|
|
19
|
-
readonly orphanLineComments: readonly AstNode[];
|
|
20
|
-
/**
|
|
21
|
-
* True when this implementation is preceded by sibling overload signatures (`TSDeclareFunction`
|
|
22
|
-
* statements with the same name).
|
|
23
|
-
*/
|
|
24
|
-
readonly hasOverloads: boolean;
|
|
25
|
-
/**
|
|
26
|
-
* The `@__NO_SIDE_EFFECTS__` line/block comment immediately above the implementation
|
|
27
|
-
* declaration when the function has overloads. TypeScript erases overload signatures during
|
|
28
|
-
* emit, so JSDoc placed only on the first overload is dropped from the bundled JS — the
|
|
29
|
-
* line comment directly above the implementation is what survives and reaches the bundler.
|
|
30
|
-
*
|
|
31
|
-
* `null` when the function is single-signature (the line comment is then a removable orphan)
|
|
32
|
-
* or when no such comment is present.
|
|
33
|
-
*/
|
|
34
|
-
readonly implLineComment: Maybe<AstNode>;
|
|
35
|
-
/**
|
|
36
|
-
* True when the implementation will carry the `@__NO_SIDE_EFFECTS__` annotation in the emitted
|
|
37
|
-
* JavaScript:
|
|
38
|
-
*
|
|
39
|
-
* - Single-signature: true when the (only) JSDoc carries the tag.
|
|
40
|
-
* - Overloaded: true when a line/block comment with the tag sits immediately above the
|
|
41
|
-
* implementation, OR the implementation has its own JSDoc carrying the tag.
|
|
42
|
-
*
|
|
43
|
-
* This is the signal upstream packages need so esbuild/rollup can tree-shake unused calls.
|
|
44
|
-
*/
|
|
45
|
-
readonly implHasSurvivingAnnotation: boolean;
|
|
46
|
-
/**
|
|
47
|
-
* The first statement in the overload chain (i.e. the first overload's export wrapper, or the
|
|
48
|
-
* implementation itself when there are no overloads). Use this as the insertion anchor when
|
|
49
|
-
* creating a brand-new JSDoc for the function, since docs conventionally live on the first
|
|
50
|
-
* overload rather than the implementation.
|
|
51
|
-
*/
|
|
52
|
-
readonly chainStartStatement: AstNode;
|
|
53
|
-
}
|
|
54
|
-
/**
|
|
55
|
-
* Returns true if the given comment text contains the @__NO_SIDE_EFFECTS__ marker.
|
|
56
|
-
*
|
|
57
|
-
* @param text - The comment body text (without the `/*` and `*\/` delimiters).
|
|
58
|
-
* @returns True when the marker substring is present.
|
|
59
|
-
*/
|
|
60
|
-
export declare function commentContainsNoSideEffects(text: string): boolean;
|
|
61
|
-
/**
|
|
62
|
-
* Returns the leading whitespace (column indent) of the line containing the given offset.
|
|
63
|
-
*
|
|
64
|
-
* @param sourceText - The full source text being inspected.
|
|
65
|
-
* @param offset - A character offset into `sourceText` indicating the line of interest.
|
|
66
|
-
* @returns The whitespace prefix (spaces/tabs) of that line.
|
|
67
|
-
*/
|
|
68
|
-
export declare function getLineIndent(sourceText: string, offset: number): string;
|
|
69
|
-
/**
|
|
70
|
-
* Returns the outermost statement node for a FunctionDeclaration — its `ExportNamedDeclaration`
|
|
71
|
-
* or `ExportDefaultDeclaration` parent if exported, otherwise the declaration itself. This is the
|
|
72
|
-
* node ESLint attaches leading comments to.
|
|
73
|
-
*
|
|
74
|
-
* @param node - The FunctionDeclaration AST node.
|
|
75
|
-
* @returns The statement node ESLint attaches leading comments to.
|
|
76
|
-
*/
|
|
77
|
-
export declare function getStatementAnchor(node: AstNode): AstNode;
|
|
78
|
-
/**
|
|
79
|
-
* Returns the JSDoc Block comment immediately preceding `anchor`, or `null` when
|
|
80
|
-
* the anchor has no JSDoc leader. Used by the `@dbx<Family>` companion-tag rules
|
|
81
|
-
* to locate the tagged declaration's documentation.
|
|
82
|
-
*
|
|
83
|
-
* @param sourceCode - The ESLint `SourceCode` object.
|
|
84
|
-
* @param anchor - The statement-level node ESLint attaches leading comments to.
|
|
85
|
-
* @returns The JSDoc block comment, or null when none is present.
|
|
86
|
-
*/
|
|
87
|
-
export declare function leadingJsdocFor(sourceCode: AstNode, anchor: AstNode): Maybe<AstNode>;
|
|
88
|
-
/**
|
|
89
|
-
* Walks backward from the implementation FunctionDeclaration through any overload signatures
|
|
90
|
-
* with the same name, collecting:.
|
|
91
|
-
*
|
|
92
|
-
* - The leading JSDoc block (preferring the one attached to the **first** overload, since that's
|
|
93
|
-
* where the function's documentation conventionally lives).
|
|
94
|
-
* - All orphan `@__NO_SIDE_EFFECTS__` line/block comments encountered between overloads or
|
|
95
|
-
* between the last overload and the implementation.
|
|
96
|
-
*
|
|
97
|
-
* This handles the common pattern:
|
|
98
|
-
*
|
|
99
|
-
* ```ts
|
|
100
|
-
* \/\*\* doc \*\/
|
|
101
|
-
* export function foo(a: number): number;
|
|
102
|
-
* export function foo(a: string): string;
|
|
103
|
-
* \/\/ \@__NO_SIDE_EFFECTS__
|
|
104
|
-
* export function foo(a: any) { ... }
|
|
105
|
-
* ```
|
|
106
|
-
*
|
|
107
|
-
* @param sourceCode - The ESLint `SourceCode` object used to read leading comments.
|
|
108
|
-
* @param implNode - The implementation FunctionDeclaration node.
|
|
109
|
-
* @returns The leading JSDoc (if any) and any orphan side-effect annotation comments.
|
|
110
|
-
*/
|
|
111
|
-
export declare function findFunctionLeadingContext(sourceCode: AstNode, implNode: AstNode): FunctionLeadingContext;
|
|
112
|
-
export {};
|