@dereekb/dbx-firebase 12.5.8 → 12.5.10
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/esm2022/lib/modules/storagefile/container/index.mjs +2 -1
- package/esm2022/lib/modules/storagefile/container/storagefile.download.button.component.mjs +210 -0
- package/esm2022/lib/modules/storagefile/index.mjs +3 -1
- package/esm2022/lib/modules/storagefile/service/index.mjs +3 -0
- package/esm2022/lib/modules/storagefile/service/storagefile.download.service.mjs +120 -0
- package/esm2022/lib/modules/storagefile/service/storagefile.download.storage.service.mjs +89 -0
- package/esm2022/lib/modules/storagefile/storagefile.providers.mjs +33 -0
- package/esm2022/lib/modules/storagefile/store/storagefile.document.store.mjs +3 -2
- package/esm2022/lib/providers.mjs +6 -2
- package/fesm2022/dereekb-dbx-firebase.mjs +440 -7
- package/fesm2022/dereekb-dbx-firebase.mjs.map +1 -1
- package/lib/modules/storagefile/container/index.d.ts +1 -0
- package/lib/modules/storagefile/container/storagefile.download.button.component.d.ts +87 -0
- package/lib/modules/storagefile/index.d.ts +2 -0
- package/lib/modules/storagefile/service/index.d.ts +2 -0
- package/lib/modules/storagefile/service/storagefile.download.service.d.ts +48 -0
- package/lib/modules/storagefile/service/storagefile.download.storage.service.d.ts +52 -0
- package/lib/modules/storagefile/storagefile.providers.d.ts +13 -0
- package/lib/modules/storagefile/storagefile.upload.module.d.ts +1 -1
- package/lib/modules/storagefile/store/storagefile.document.store.d.ts +1 -0
- package/lib/providers.d.ts +4 -0
- package/package.json +1 -1
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
import { DbxActionDialogFunction, DbxButtonStyle } from '@dereekb/dbx-web';
|
|
2
|
+
import { StorageFileKey } from '@dereekb/firebase';
|
|
3
|
+
import { DateOrUnixTimeNumber, Maybe } from '@dereekb/util';
|
|
4
|
+
import { DbxFirebaseStorageFileDownloadService } from '../service/storagefile.download.service';
|
|
5
|
+
import { ClickableAnchor } from '@dereekb/dbx-core';
|
|
6
|
+
import { WorkUsingObservable } from '@dereekb/rxjs';
|
|
7
|
+
import { Observable } from 'rxjs';
|
|
8
|
+
import { DbxFirebaseStorageFileDownloadUrlPair } from '../service/storagefile.download.storage.service';
|
|
9
|
+
import { MatDialog } from '@angular/material/dialog';
|
|
10
|
+
import * as i0 from "@angular/core";
|
|
11
|
+
/**
|
|
12
|
+
* Configuration for the DbxFirebaseStorageFileDownloadButton.
|
|
13
|
+
*/
|
|
14
|
+
export interface DbxFirebaseStorageFileDownloadButtonConfig {
|
|
15
|
+
readonly buttonStyle?: Maybe<DbxButtonStyle>;
|
|
16
|
+
readonly previewButtonStyle?: Maybe<DbxButtonStyle>;
|
|
17
|
+
/**
|
|
18
|
+
* Whether or not to pre-load the download url from the source.
|
|
19
|
+
*/
|
|
20
|
+
readonly preload?: Maybe<boolean>;
|
|
21
|
+
/**
|
|
22
|
+
* Whether or not to show a preview button.
|
|
23
|
+
*/
|
|
24
|
+
readonly showPreviewButton?: Maybe<boolean>;
|
|
25
|
+
readonly icon?: Maybe<string>;
|
|
26
|
+
readonly text?: Maybe<string>;
|
|
27
|
+
readonly downloadReadyIcon?: Maybe<string>;
|
|
28
|
+
readonly downloadReadyText?: Maybe<string>;
|
|
29
|
+
readonly previewIcon?: Maybe<string>;
|
|
30
|
+
readonly previewText?: Maybe<string>;
|
|
31
|
+
}
|
|
32
|
+
export declare class DbxFirebaseStorageFileDownloadButton {
|
|
33
|
+
readonly dbxFirebaseStorageFileDownloadService: DbxFirebaseStorageFileDownloadService;
|
|
34
|
+
readonly matDialog: MatDialog;
|
|
35
|
+
/**
|
|
36
|
+
* The StorageFileKey to set up the download button for.
|
|
37
|
+
*/
|
|
38
|
+
readonly storageFileKey: import("@angular/core").InputSignal<Maybe<string>>;
|
|
39
|
+
/**
|
|
40
|
+
* The download URL to use for the download button.
|
|
41
|
+
*/
|
|
42
|
+
readonly storageFileDownloadUrl: import("@angular/core").InputSignal<Maybe<string>>;
|
|
43
|
+
/**
|
|
44
|
+
* The MIME type to use the embed component.
|
|
45
|
+
*/
|
|
46
|
+
readonly embedMimeType: import("@angular/core").InputSignal<Maybe<string>>;
|
|
47
|
+
/**
|
|
48
|
+
* Whether or not to show a preview button.
|
|
49
|
+
*
|
|
50
|
+
* Defaults to true.
|
|
51
|
+
*/
|
|
52
|
+
readonly showPreviewButton: import("@angular/core").InputSignal<Maybe<boolean>>;
|
|
53
|
+
/**
|
|
54
|
+
* Output event emitted when the download URL changes.
|
|
55
|
+
*/
|
|
56
|
+
readonly downloadUrlChange: import("@angular/core").OutputEmitterRef<Maybe<string>>;
|
|
57
|
+
readonly config: import("@angular/core").InputSignal<Maybe<DbxFirebaseStorageFileDownloadButtonConfig>>;
|
|
58
|
+
readonly configSignal: import("@angular/core").Signal<DbxFirebaseStorageFileDownloadButtonConfig>;
|
|
59
|
+
readonly preloadSignal: import("@angular/core").Signal<boolean>;
|
|
60
|
+
readonly downloadUrlSignal: import("@angular/core").WritableSignal<Maybe<string>>;
|
|
61
|
+
readonly downloadUrlExpiresAtSignal: import("@angular/core").WritableSignal<Maybe<DateOrUnixTimeNumber>>;
|
|
62
|
+
readonly storageFileKey$: Observable<Maybe<string>>;
|
|
63
|
+
readonly hasDownloadUrlSignal: import("@angular/core").Signal<boolean>;
|
|
64
|
+
readonly buttonStyleSignal: import("@angular/core").Signal<DbxButtonStyle>;
|
|
65
|
+
readonly previewButtonStyleSignal: import("@angular/core").Signal<DbxButtonStyle>;
|
|
66
|
+
readonly iconSignal: import("@angular/core").Signal<Maybe<string>>;
|
|
67
|
+
readonly textSignal: import("@angular/core").Signal<Maybe<string>>;
|
|
68
|
+
readonly previewIconSignal: import("@angular/core").Signal<Maybe<string>>;
|
|
69
|
+
readonly previewTextSignal: import("@angular/core").Signal<Maybe<string>>;
|
|
70
|
+
readonly anchorSignal: import("@angular/core").Signal<Maybe<ClickableAnchor>>;
|
|
71
|
+
readonly storageFileDownloadUrlEffect: import("@angular/core").EffectRef;
|
|
72
|
+
readonly showPreviewButtonSignal: import("@angular/core").Signal<boolean>;
|
|
73
|
+
readonly handleOpenPreviewDialog: DbxActionDialogFunction;
|
|
74
|
+
readonly cachedUrlForStorageFileKey$: Observable<Maybe<DbxFirebaseStorageFileDownloadUrlPair>>;
|
|
75
|
+
readonly cachedUrlForStorageFileKeySignal: import("@angular/core").Signal<Maybe<DbxFirebaseStorageFileDownloadUrlPair>>;
|
|
76
|
+
readonly cachedUrlEffect: import("@angular/core").EffectRef;
|
|
77
|
+
readonly downloadUrlExpiresAt$: Observable<Maybe<Date>>;
|
|
78
|
+
readonly downloadUrlHasExpired$: Observable<boolean>;
|
|
79
|
+
readonly downloadUrlHasExpiredSignal: import("@angular/core").Signal<boolean | undefined>;
|
|
80
|
+
readonly downloadUrlHasExpiredEffect: import("@angular/core").EffectRef;
|
|
81
|
+
readonly downloadUrlChangeEffect: import("@angular/core").EffectRef;
|
|
82
|
+
readonly handleGetDownloadUrl: WorkUsingObservable<StorageFileKey, DbxFirebaseStorageFileDownloadUrlPair>;
|
|
83
|
+
readonly handleGetDownloadUrlSuccess: (value: DbxFirebaseStorageFileDownloadUrlPair) => void;
|
|
84
|
+
readonly handleGetDownloadUrlError: (error: unknown) => void;
|
|
85
|
+
static ɵfac: i0.ɵɵFactoryDeclaration<DbxFirebaseStorageFileDownloadButton, never>;
|
|
86
|
+
static ɵcmp: i0.ɵɵComponentDeclaration<DbxFirebaseStorageFileDownloadButton, "dbx-firebase-storagefile-download-button", never, { "storageFileKey": { "alias": "storageFileKey"; "required": false; "isSignal": true; }; "storageFileDownloadUrl": { "alias": "storageFileDownloadUrl"; "required": false; "isSignal": true; }; "embedMimeType": { "alias": "embedMimeType"; "required": false; "isSignal": true; }; "showPreviewButton": { "alias": "showPreviewButton"; "required": false; "isSignal": true; }; "config": { "alias": "config"; "required": false; "isSignal": true; }; }, { "downloadUrlChange": "downloadUrlChange"; }, never, never, true, never>;
|
|
87
|
+
}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import { StorageFileFunctions, DownloadStorageFileParams, StorageFileKey, StorageFileId } from '@dereekb/firebase';
|
|
2
|
+
import { Maybe, Milliseconds, Seconds } from '@dereekb/util';
|
|
3
|
+
import { DbxFirebaseStorageFileDownloadStorage, DbxFirebaseStorageFileDownloadUrlPair } from './storagefile.download.storage.service';
|
|
4
|
+
import { Observable } from 'rxjs';
|
|
5
|
+
import * as i0 from "@angular/core";
|
|
6
|
+
/**
|
|
7
|
+
* Service used for retrieving download links for StorageFiles.
|
|
8
|
+
*/
|
|
9
|
+
export declare class DbxFirebaseStorageFileDownloadService {
|
|
10
|
+
/**
|
|
11
|
+
* Expiration duration for cached download URLs.
|
|
12
|
+
*/
|
|
13
|
+
protected _expiresAfterTime: Milliseconds;
|
|
14
|
+
/**
|
|
15
|
+
* When reading cached values, this buffer is added to the expiration time to prevent the URL from expiring while it is being used.
|
|
16
|
+
*/
|
|
17
|
+
protected _expiresAfterTimeBuffer: Seconds;
|
|
18
|
+
readonly storageFileFunctions: StorageFileFunctions;
|
|
19
|
+
readonly storageFileDownloadStorage: DbxFirebaseStorageFileDownloadStorage;
|
|
20
|
+
getExpiresAfterTime(): number;
|
|
21
|
+
setExpiresAfterTime(expiresAfter: number): void;
|
|
22
|
+
/**
|
|
23
|
+
* Returns an observable that returns the cached download URL pair for the StorageFile, and emits null once it expires.
|
|
24
|
+
*
|
|
25
|
+
* @param storageFileIdOrKey
|
|
26
|
+
* @returns
|
|
27
|
+
*/
|
|
28
|
+
getCachedDownloadPairForStorageFile(storageFileIdOrKey: StorageFileId | StorageFileKey): Observable<Maybe<DbxFirebaseStorageFileDownloadUrlPair>>;
|
|
29
|
+
/**
|
|
30
|
+
* Retrieves the download URL for the StorageFile using the default parameters.
|
|
31
|
+
*
|
|
32
|
+
* These URLs are cached locally to prevent extra/redundant calls to the server.
|
|
33
|
+
*
|
|
34
|
+
* @param storageFileIdOrKey
|
|
35
|
+
* @returns
|
|
36
|
+
*/
|
|
37
|
+
downloadPairForStorageFile(storageFileIdOrKey: StorageFileId | StorageFileKey): Observable<DbxFirebaseStorageFileDownloadUrlPair>;
|
|
38
|
+
/**
|
|
39
|
+
* Creates a new download URL for the StorageFile.
|
|
40
|
+
*
|
|
41
|
+
* @param storageFileIdOrKey
|
|
42
|
+
* @param inputParams
|
|
43
|
+
* @returns
|
|
44
|
+
*/
|
|
45
|
+
createDownloadPairForStorageFile(storageFileIdOrKey: StorageFileId | StorageFileKey, inputParams?: Omit<DownloadStorageFileParams, 'key'>): Promise<DbxFirebaseStorageFileDownloadUrlPair>;
|
|
46
|
+
static ɵfac: i0.ɵɵFactoryDeclaration<DbxFirebaseStorageFileDownloadService, never>;
|
|
47
|
+
static ɵprov: i0.ɵɵInjectableDeclaration<DbxFirebaseStorageFileDownloadService>;
|
|
48
|
+
}
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import { InjectionToken } from '@angular/core';
|
|
2
|
+
import { StorageAccessor } from '@dereekb/dbx-core';
|
|
3
|
+
import { Observable } from 'rxjs';
|
|
4
|
+
import { FirebaseAuthUserId, FirestoreModelIdInput, StorageFileId, StorageFileSignedDownloadUrl } from '@dereekb/firebase';
|
|
5
|
+
import { DbxFirebaseAuthService } from '../../../auth/service/firebase.auth.service';
|
|
6
|
+
import { UnixTimeNumber } from '@dereekb/util';
|
|
7
|
+
import * as i0 from "@angular/core";
|
|
8
|
+
export interface DbxFirebaseStorageFileDownloadUrlPair {
|
|
9
|
+
readonly id: StorageFileId;
|
|
10
|
+
readonly downloadUrl: StorageFileSignedDownloadUrl;
|
|
11
|
+
/**
|
|
12
|
+
* Expiration in seconds since epoch.
|
|
13
|
+
*/
|
|
14
|
+
readonly expiresAt: UnixTimeNumber;
|
|
15
|
+
}
|
|
16
|
+
export type DbxFirebaseStorageFileDownloadUrlPairString = `${UnixTimeNumber}_${StorageFileSignedDownloadUrl}`;
|
|
17
|
+
export type DbxFirebaseStorageFileDownloadUrlPairsRecord = Record<StorageFileId, DbxFirebaseStorageFileDownloadUrlPairString>;
|
|
18
|
+
export interface DbxFirebaseStorageFileDownloadUserCache {
|
|
19
|
+
readonly uid: FirebaseAuthUserId;
|
|
20
|
+
readonly pairs: DbxFirebaseStorageFileDownloadUrlPairsRecord;
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* Token that corresponds to a StorageAccessor<DbxFirebaseStorageFileDownloadUserCache> that is used by DbxModelViewTrackerStorage.
|
|
24
|
+
*/
|
|
25
|
+
export declare const DBX_FIREBASE_STORAGEFILE_DOWNLOAD_STORAGE_ACCESSOR_TOKEN: InjectionToken<unknown>;
|
|
26
|
+
/**
|
|
27
|
+
* Used for managing DbxModelViewTrackerEvent storage.
|
|
28
|
+
*/
|
|
29
|
+
export declare class DbxFirebaseStorageFileDownloadStorage {
|
|
30
|
+
static readonly DEFAULT_MAX_DOWNLOAD_URLS = 100;
|
|
31
|
+
readonly authService: DbxFirebaseAuthService;
|
|
32
|
+
readonly storageAccessor: StorageAccessor<DbxFirebaseStorageFileDownloadUserCache>;
|
|
33
|
+
addDownloadUrl({ id, downloadUrl, expiresAt }: DbxFirebaseStorageFileDownloadUrlPair): Observable<void>;
|
|
34
|
+
/**
|
|
35
|
+
* Returns the cached download URL pair for the given key.
|
|
36
|
+
*
|
|
37
|
+
* The pair may be expired.
|
|
38
|
+
*
|
|
39
|
+
* @param key
|
|
40
|
+
* @returns
|
|
41
|
+
*/
|
|
42
|
+
getDownloadUrlPair(input: FirestoreModelIdInput): Observable<DbxFirebaseStorageFileDownloadUrlPair | undefined>;
|
|
43
|
+
getAllDownloadUrlPairsRecord(uid: FirebaseAuthUserId): Observable<DbxFirebaseStorageFileDownloadUrlPairsRecord>;
|
|
44
|
+
getCurrentUserDownloadCache(): Observable<DbxFirebaseStorageFileDownloadUserCache>;
|
|
45
|
+
getUserDownloadCache(uid: FirebaseAuthUserId): Observable<DbxFirebaseStorageFileDownloadUserCache>;
|
|
46
|
+
clearCurrentUserDownloadCache(): Observable<void>;
|
|
47
|
+
clearUserDownloadCache(uid: FirebaseAuthUserId): Observable<void>;
|
|
48
|
+
private _getUserDownloadCacheForStorageKey;
|
|
49
|
+
getStorageKeyForUid(uid: FirebaseAuthUserId): string;
|
|
50
|
+
static ɵfac: i0.ɵɵFactoryDeclaration<DbxFirebaseStorageFileDownloadStorage, never>;
|
|
51
|
+
static ɵprov: i0.ɵɵInjectableDeclaration<DbxFirebaseStorageFileDownloadStorage>;
|
|
52
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { type EnvironmentProviders } from '@angular/core';
|
|
2
|
+
import { SimpleStorageAccessorFactory, type StorageAccessor } from '@dereekb/dbx-core';
|
|
3
|
+
import { type DbxFirebaseStorageFileDownloadUserCache } from './service/storagefile.download.storage.service';
|
|
4
|
+
/**
|
|
5
|
+
* Factory function for creating a StorageAccessor for the model view tracker.
|
|
6
|
+
*/
|
|
7
|
+
export declare function defaultDbxFirebaseStorageFileDownloadStorageAccessorFactory(storageAccessorFactory: SimpleStorageAccessorFactory): StorageAccessor<DbxFirebaseStorageFileDownloadUserCache>;
|
|
8
|
+
/**
|
|
9
|
+
* Creates EnvironmentProviders for providing DbxModelTrackerService, DbxModelObjectStateService and sets up the NgRx store for DbxModelTrackerEffects.
|
|
10
|
+
*
|
|
11
|
+
* @returns EnvironmentProviders
|
|
12
|
+
*/
|
|
13
|
+
export declare function provideDbxFirebaseStorageFileService(): EnvironmentProviders;
|
|
@@ -10,7 +10,7 @@ import * as i4 from "./container/storagefile.upload.sync.directive";
|
|
|
10
10
|
import * as i5 from "./container/storagefile.upload.initialize.document.directive";
|
|
11
11
|
import * as i6 from "./store/storagefile.collection.store.directive";
|
|
12
12
|
import * as i7 from "./store/storagefile.document.store.directive";
|
|
13
|
-
export declare const importsAndExports: (typeof DbxActionModule | typeof DbxFirebaseStorageFileCollectionStoreDirective | typeof DbxFirebaseStorageFileDocumentStoreDirective | typeof DbxFirebaseStorageFileUploadActionHandlerDirective | typeof DbxFirebaseStorageFileUploadInitializeDocumentDirective | typeof DbxFirebaseStorageFileUploadStoreDirective | typeof DbxFirebaseStorageFileUploadSyncDirective | typeof DbxFileUploadComponent | typeof DbxLoadingComponent | typeof DbxActionLoadingContextDirective | typeof
|
|
13
|
+
export declare const importsAndExports: (typeof DbxActionModule | typeof DbxActionSnackbarErrorDirective | typeof DbxFirebaseStorageFileCollectionStoreDirective | typeof DbxFirebaseStorageFileDocumentStoreDirective | typeof DbxFirebaseStorageFileUploadActionHandlerDirective | typeof DbxFirebaseStorageFileUploadInitializeDocumentDirective | typeof DbxFirebaseStorageFileUploadStoreDirective | typeof DbxFirebaseStorageFileUploadSyncDirective | typeof DbxFileUploadComponent | typeof DbxLoadingComponent | typeof DbxActionLoadingContextDirective | typeof DbxFileUploadActionSyncDirective)[];
|
|
14
14
|
/**
|
|
15
15
|
* Convenience module for importing various modules/components that are relevant to the storage file upload feature.
|
|
16
16
|
*
|
|
@@ -10,6 +10,7 @@ export declare class StorageFileDocumentStore extends AbstractDbxFirebaseDocumen
|
|
|
10
10
|
readonly updateStorageFile: import("../../../model/modules/store").DbxFirebaseDocumentStoreFunction<import("@dereekb/firebase").UpdateStorageFileParams, void>;
|
|
11
11
|
readonly processStorageFile: import("../../../model/modules/store").DbxFirebaseDocumentStoreFunction<import("@dereekb/firebase").ProcessStorageFileParams, import("@dereekb/firebase").ProcessStorageFileResult>;
|
|
12
12
|
readonly deleteStorageFile: import("../../../model/modules/store").DbxFirebaseDocumentStoreFunction<import("@dereekb/firebase").DeleteStorageFileParams, void>;
|
|
13
|
+
readonly downloadStorageFile: import("../../../model/modules/store").DbxFirebaseDocumentStoreFunction<import("@dereekb/firebase").DownloadStorageFileParams, import("@dereekb/firebase").DownloadStorageFileResult>;
|
|
13
14
|
static ɵfac: i0.ɵɵFactoryDeclaration<StorageFileDocumentStore, never>;
|
|
14
15
|
static ɵprov: i0.ɵɵInjectableDeclaration<StorageFileDocumentStore>;
|
|
15
16
|
}
|
package/lib/providers.d.ts
CHANGED
|
@@ -42,6 +42,10 @@ export interface ProvideDbxFirebaseConfig<T, M extends FirebaseFunctionsMap = Fi
|
|
|
42
42
|
* If true, provideDbxFirebaseAnalyticsUserEventsListenerService() will be provided/called.
|
|
43
43
|
*/
|
|
44
44
|
readonly provideAnalyticsUserEventsListener?: Maybe<boolean>;
|
|
45
|
+
/**
|
|
46
|
+
* If true, provideDbxFirebaseStorageFileService() will be provided/called.
|
|
47
|
+
*/
|
|
48
|
+
readonly provideStorageFileService?: Maybe<boolean>;
|
|
45
49
|
}
|
|
46
50
|
/**
|
|
47
51
|
* All-in-one provider for providing the main configurations for DbxFirebase.
|