@dereekb/dbx-firebase 12.5.10 → 12.6.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/esm2022/lib/development/development.widget.service.mjs +1 -1
- package/esm2022/lib/modules/storagefile/container/storagefile.download.button.component.mjs +52 -18
- package/esm2022/lib/modules/storagefile/service/storagefile.download.service.mjs +55 -17
- package/esm2022/lib/modules/storagefile/service/storagefile.download.storage.service.mjs +7 -5
- package/fesm2022/dereekb-dbx-firebase.mjs +107 -36
- package/fesm2022/dereekb-dbx-firebase.mjs.map +1 -1
- package/lib/development/development.widget.service.d.ts +1 -1
- package/lib/modules/storagefile/container/storagefile.download.button.component.d.ts +57 -11
- package/lib/modules/storagefile/service/storagefile.download.service.d.ts +32 -1
- package/lib/modules/storagefile/service/storagefile.download.storage.service.d.ts +8 -4
- package/package.json +1 -1
|
@@ -5,7 +5,7 @@ import * as i0 from "@angular/core";
|
|
|
5
5
|
/**
|
|
6
6
|
* Default providers to inject.
|
|
7
7
|
*/
|
|
8
|
-
export declare const DEFAULT_FIREBASE_DEVELOPMENT_WIDGET_PROVIDERS_TOKEN: InjectionToken<
|
|
8
|
+
export declare const DEFAULT_FIREBASE_DEVELOPMENT_WIDGET_PROVIDERS_TOKEN: InjectionToken<DbxFirebaseDevelopmentWidgetEntry[]>;
|
|
9
9
|
/**
|
|
10
10
|
* Service used for registering widgets used for development.
|
|
11
11
|
*
|
|
@@ -1,13 +1,41 @@
|
|
|
1
|
-
import { DbxActionDialogFunction, DbxButtonStyle } from '@dereekb/dbx-web';
|
|
2
|
-
import { StorageFileKey } from '@dereekb/firebase';
|
|
3
|
-
import {
|
|
4
|
-
import { DbxFirebaseStorageFileDownloadService } from '../service/storagefile.download.service';
|
|
1
|
+
import { DbxActionDialogFunction, DbxButtonStyle, DbxWebFilePreviewService } from '@dereekb/dbx-web';
|
|
2
|
+
import { StorageFileDownloadUrl, StorageFileKey } from '@dereekb/firebase';
|
|
3
|
+
import { ContentTypeMimeType, DateOrUnixDateTimeSecondsNumber, Maybe } from '@dereekb/util';
|
|
4
|
+
import { DbxFirebaseStorageFileDownloadService, DbxFirebaseStorageFileDownloadServiceCustomSource } from '../service/storagefile.download.service';
|
|
5
5
|
import { ClickableAnchor } from '@dereekb/dbx-core';
|
|
6
|
-
import {
|
|
6
|
+
import { MaybeObservableOrValue, WorkUsingContext } from '@dereekb/rxjs';
|
|
7
7
|
import { Observable } from 'rxjs';
|
|
8
8
|
import { DbxFirebaseStorageFileDownloadUrlPair } from '../service/storagefile.download.storage.service';
|
|
9
|
-
import { MatDialog } from '@angular/material/dialog';
|
|
9
|
+
import { MatDialog, MatDialogRef } from '@angular/material/dialog';
|
|
10
10
|
import * as i0 from "@angular/core";
|
|
11
|
+
export interface DbxFirebaseStorageFileDownloadButtonSource {
|
|
12
|
+
/**
|
|
13
|
+
* A static StorageFileKey to use.
|
|
14
|
+
*/
|
|
15
|
+
readonly storageFileKey?: MaybeObservableOrValue<StorageFileKey>;
|
|
16
|
+
/**
|
|
17
|
+
* The expected mime type of the StorageFile to use when previewing.
|
|
18
|
+
*/
|
|
19
|
+
readonly storageFileEmbedMimeType?: MaybeObservableOrValue<ContentTypeMimeType | string>;
|
|
20
|
+
/**
|
|
21
|
+
* Custom source to use with the DbxFirebaseStorageFileDownloadService. A more simple alternative to using handleGetDownloadUrl().
|
|
22
|
+
*/
|
|
23
|
+
readonly customSource?: Maybe<DbxFirebaseStorageFileDownloadServiceCustomSource>;
|
|
24
|
+
/**
|
|
25
|
+
* Optional custom work to use to get the download URL.
|
|
26
|
+
*
|
|
27
|
+
* If provided, customSource is ignored.
|
|
28
|
+
*/
|
|
29
|
+
readonly handleGetDownloadUrl?: Maybe<WorkUsingContext<StorageFileKey, DbxFirebaseStorageFileDownloadUrlPair>>;
|
|
30
|
+
/**
|
|
31
|
+
* Optional custom success handler for the download URL.
|
|
32
|
+
*/
|
|
33
|
+
readonly handleGetDownloadUrlSuccess?: (value: DbxFirebaseStorageFileDownloadUrlPair) => void;
|
|
34
|
+
/**
|
|
35
|
+
* Optional custom error handler for the download URL.
|
|
36
|
+
*/
|
|
37
|
+
readonly handleGetDownloadUrlError?: (error: unknown) => void;
|
|
38
|
+
}
|
|
11
39
|
/**
|
|
12
40
|
* Configuration for the DbxFirebaseStorageFileDownloadButton.
|
|
13
41
|
*/
|
|
@@ -16,10 +44,14 @@ export interface DbxFirebaseStorageFileDownloadButtonConfig {
|
|
|
16
44
|
readonly previewButtonStyle?: Maybe<DbxButtonStyle>;
|
|
17
45
|
/**
|
|
18
46
|
* Whether or not to pre-load the download url from the source.
|
|
47
|
+
*
|
|
48
|
+
* Defaults to false.
|
|
19
49
|
*/
|
|
20
50
|
readonly preload?: Maybe<boolean>;
|
|
21
51
|
/**
|
|
22
52
|
* Whether or not to show a preview button.
|
|
53
|
+
*
|
|
54
|
+
* Defaults to true.
|
|
23
55
|
*/
|
|
24
56
|
readonly showPreviewButton?: Maybe<boolean>;
|
|
25
57
|
readonly icon?: Maybe<string>;
|
|
@@ -28,10 +60,17 @@ export interface DbxFirebaseStorageFileDownloadButtonConfig {
|
|
|
28
60
|
readonly downloadReadyText?: Maybe<string>;
|
|
29
61
|
readonly previewIcon?: Maybe<string>;
|
|
30
62
|
readonly previewText?: Maybe<string>;
|
|
63
|
+
/**
|
|
64
|
+
* Optional custom function to open a preview dialog. If not provided, the default preview dialog provided by the DbxWebFilePreviewService will be used.
|
|
65
|
+
*
|
|
66
|
+
* The function can return undefined, in which case the default preview dialog will be used.
|
|
67
|
+
*/
|
|
68
|
+
readonly openCustomPreview?: Maybe<(downloadUrl: StorageFileDownloadUrl, embedMimeType?: Maybe<string>) => Maybe<MatDialogRef<any>>>;
|
|
31
69
|
}
|
|
32
70
|
export declare class DbxFirebaseStorageFileDownloadButton {
|
|
33
|
-
readonly dbxFirebaseStorageFileDownloadService: DbxFirebaseStorageFileDownloadService;
|
|
34
71
|
readonly matDialog: MatDialog;
|
|
72
|
+
readonly dbxWebFilePreviewService: DbxWebFilePreviewService;
|
|
73
|
+
readonly dbxFirebaseStorageFileDownloadService: DbxFirebaseStorageFileDownloadService;
|
|
35
74
|
/**
|
|
36
75
|
* The StorageFileKey to set up the download button for.
|
|
37
76
|
*/
|
|
@@ -55,11 +94,17 @@ export declare class DbxFirebaseStorageFileDownloadButton {
|
|
|
55
94
|
*/
|
|
56
95
|
readonly downloadUrlChange: import("@angular/core").OutputEmitterRef<Maybe<string>>;
|
|
57
96
|
readonly config: import("@angular/core").InputSignal<Maybe<DbxFirebaseStorageFileDownloadButtonConfig>>;
|
|
97
|
+
readonly source: import("@angular/core").InputSignal<Maybe<DbxFirebaseStorageFileDownloadButtonSource>>;
|
|
98
|
+
readonly source$: Observable<Maybe<DbxFirebaseStorageFileDownloadButtonSource>>;
|
|
58
99
|
readonly configSignal: import("@angular/core").Signal<DbxFirebaseStorageFileDownloadButtonConfig>;
|
|
59
100
|
readonly preloadSignal: import("@angular/core").Signal<boolean>;
|
|
60
101
|
readonly downloadUrlSignal: import("@angular/core").WritableSignal<Maybe<string>>;
|
|
61
|
-
readonly
|
|
62
|
-
readonly
|
|
102
|
+
readonly downloadMimeTypeSignal: import("@angular/core").WritableSignal<Maybe<string>>;
|
|
103
|
+
readonly downloadUrlExpiresAtSignal: import("@angular/core").WritableSignal<Maybe<DateOrUnixDateTimeSecondsNumber>>;
|
|
104
|
+
readonly storageFileKeyFromInput$: Observable<Maybe<string>>;
|
|
105
|
+
readonly storageFileKeyFromSource$: Observable<Maybe<StorageFileKey>>;
|
|
106
|
+
readonly storageFileKey$: Observable<Maybe<StorageFileKey>>;
|
|
107
|
+
readonly storageFileKeySignal: import("@angular/core").Signal<Maybe<string>>;
|
|
63
108
|
readonly hasDownloadUrlSignal: import("@angular/core").Signal<boolean>;
|
|
64
109
|
readonly buttonStyleSignal: import("@angular/core").Signal<DbxButtonStyle>;
|
|
65
110
|
readonly previewButtonStyleSignal: import("@angular/core").Signal<DbxButtonStyle>;
|
|
@@ -70,6 +115,7 @@ export declare class DbxFirebaseStorageFileDownloadButton {
|
|
|
70
115
|
readonly anchorSignal: import("@angular/core").Signal<Maybe<ClickableAnchor>>;
|
|
71
116
|
readonly storageFileDownloadUrlEffect: import("@angular/core").EffectRef;
|
|
72
117
|
readonly showPreviewButtonSignal: import("@angular/core").Signal<boolean>;
|
|
118
|
+
readonly openCustomPreviewSignal: import("@angular/core").Signal<Maybe<(downloadUrl: StorageFileDownloadUrl, embedMimeType?: Maybe<string>) => Maybe<MatDialogRef<any>>>>;
|
|
73
119
|
readonly handleOpenPreviewDialog: DbxActionDialogFunction;
|
|
74
120
|
readonly cachedUrlForStorageFileKey$: Observable<Maybe<DbxFirebaseStorageFileDownloadUrlPair>>;
|
|
75
121
|
readonly cachedUrlForStorageFileKeySignal: import("@angular/core").Signal<Maybe<DbxFirebaseStorageFileDownloadUrlPair>>;
|
|
@@ -79,9 +125,9 @@ export declare class DbxFirebaseStorageFileDownloadButton {
|
|
|
79
125
|
readonly downloadUrlHasExpiredSignal: import("@angular/core").Signal<boolean | undefined>;
|
|
80
126
|
readonly downloadUrlHasExpiredEffect: import("@angular/core").EffectRef;
|
|
81
127
|
readonly downloadUrlChangeEffect: import("@angular/core").EffectRef;
|
|
82
|
-
readonly handleGetDownloadUrl:
|
|
128
|
+
readonly handleGetDownloadUrl: WorkUsingContext<StorageFileKey, DbxFirebaseStorageFileDownloadUrlPair>;
|
|
83
129
|
readonly handleGetDownloadUrlSuccess: (value: DbxFirebaseStorageFileDownloadUrlPair) => void;
|
|
84
130
|
readonly handleGetDownloadUrlError: (error: unknown) => void;
|
|
85
131
|
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>;
|
|
132
|
+
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; }; "source": { "alias": "source"; "required": false; "isSignal": true; }; }, { "downloadUrlChange": "downloadUrlChange"; }, never, never, true, never>;
|
|
87
133
|
}
|
|
@@ -1,8 +1,23 @@
|
|
|
1
|
-
import { StorageFileFunctions, DownloadStorageFileParams, StorageFileKey, StorageFileId } from '@dereekb/firebase';
|
|
1
|
+
import { StorageFileFunctions, DownloadStorageFileParams, StorageFileKey, StorageFileId, DownloadStorageFileResult } from '@dereekb/firebase';
|
|
2
2
|
import { Maybe, Milliseconds, Seconds } from '@dereekb/util';
|
|
3
3
|
import { DbxFirebaseStorageFileDownloadStorage, DbxFirebaseStorageFileDownloadUrlPair } from './storagefile.download.storage.service';
|
|
4
4
|
import { Observable } from 'rxjs';
|
|
5
|
+
import { LoadingState } from '@dereekb/rxjs';
|
|
5
6
|
import * as i0 from "@angular/core";
|
|
7
|
+
export type DbxFirebaseStorageFileDownloadServiceCustomSourceDownloadFunction = (params: DownloadStorageFileParams, storageFileId: StorageFileId) => Promise<DownloadStorageFileResult>;
|
|
8
|
+
/**
|
|
9
|
+
* Used as a custom source for downloading StorageFiles.
|
|
10
|
+
*/
|
|
11
|
+
export interface DbxFirebaseStorageFileDownloadServiceCustomSource {
|
|
12
|
+
/**
|
|
13
|
+
* Retrieves the download result for the StorageFile using the input parameters.
|
|
14
|
+
*
|
|
15
|
+
* @param storageFileId
|
|
16
|
+
* @returns
|
|
17
|
+
*/
|
|
18
|
+
downloadStorageFileResult: DbxFirebaseStorageFileDownloadServiceCustomSourceDownloadFunction;
|
|
19
|
+
}
|
|
20
|
+
export declare function dbxFirebaseStorageFileDownloadServiceCustomSourceFromObs(obsForInput: (params: DownloadStorageFileParams, storageFileId: StorageFileId) => Observable<LoadingState<DownloadStorageFileResult>>): DbxFirebaseStorageFileDownloadServiceCustomSource;
|
|
6
21
|
/**
|
|
7
22
|
* Service used for retrieving download links for StorageFiles.
|
|
8
23
|
*/
|
|
@@ -35,6 +50,21 @@ export declare class DbxFirebaseStorageFileDownloadService {
|
|
|
35
50
|
* @returns
|
|
36
51
|
*/
|
|
37
52
|
downloadPairForStorageFile(storageFileIdOrKey: StorageFileId | StorageFileKey): Observable<DbxFirebaseStorageFileDownloadUrlPair>;
|
|
53
|
+
/**
|
|
54
|
+
* Retrieves the download URL for the StorageFile using the default parameters and pulled from the input source, if applicable.
|
|
55
|
+
*
|
|
56
|
+
* If no source is provided, uses the default internal source.
|
|
57
|
+
*
|
|
58
|
+
* These URLs are cached locally to prevent extra/redundant calls to the server.
|
|
59
|
+
*
|
|
60
|
+
* @param storageFileIdOrKey
|
|
61
|
+
* @returns
|
|
62
|
+
*/
|
|
63
|
+
downloadPairForStorageFileUsingSource(storageFileIdOrKey: StorageFileId | StorageFileKey, source: Maybe<DbxFirebaseStorageFileDownloadServiceCustomSource>): Observable<DbxFirebaseStorageFileDownloadUrlPair>;
|
|
64
|
+
/**
|
|
65
|
+
* Adds the given download URL pair to the cache.
|
|
66
|
+
*/
|
|
67
|
+
addPairForStorageFileToCache(downloadUrlPair: DbxFirebaseStorageFileDownloadUrlPair): void;
|
|
38
68
|
/**
|
|
39
69
|
* Creates a new download URL for the StorageFile.
|
|
40
70
|
*
|
|
@@ -43,6 +73,7 @@ export declare class DbxFirebaseStorageFileDownloadService {
|
|
|
43
73
|
* @returns
|
|
44
74
|
*/
|
|
45
75
|
createDownloadPairForStorageFile(storageFileIdOrKey: StorageFileId | StorageFileKey, inputParams?: Omit<DownloadStorageFileParams, 'key'>): Promise<DbxFirebaseStorageFileDownloadUrlPair>;
|
|
76
|
+
private _createDownloadPairForStorageFileUsingSource;
|
|
46
77
|
static ɵfac: i0.ɵɵFactoryDeclaration<DbxFirebaseStorageFileDownloadService, never>;
|
|
47
78
|
static ɵprov: i0.ɵɵInjectableDeclaration<DbxFirebaseStorageFileDownloadService>;
|
|
48
79
|
}
|
|
@@ -3,17 +3,21 @@ import { StorageAccessor } from '@dereekb/dbx-core';
|
|
|
3
3
|
import { Observable } from 'rxjs';
|
|
4
4
|
import { FirebaseAuthUserId, FirestoreModelIdInput, StorageFileId, StorageFileSignedDownloadUrl } from '@dereekb/firebase';
|
|
5
5
|
import { DbxFirebaseAuthService } from '../../../auth/service/firebase.auth.service';
|
|
6
|
-
import {
|
|
6
|
+
import { ContentTypeMimeType, Maybe, UnixDateTimeSecondsNumber } from '@dereekb/util';
|
|
7
7
|
import * as i0 from "@angular/core";
|
|
8
8
|
export interface DbxFirebaseStorageFileDownloadUrlPair {
|
|
9
9
|
readonly id: StorageFileId;
|
|
10
10
|
readonly downloadUrl: StorageFileSignedDownloadUrl;
|
|
11
|
+
/**
|
|
12
|
+
* Mime type, if available.
|
|
13
|
+
*/
|
|
14
|
+
readonly mimeType?: Maybe<ContentTypeMimeType>;
|
|
11
15
|
/**
|
|
12
16
|
* Expiration in seconds since epoch.
|
|
13
17
|
*/
|
|
14
|
-
readonly expiresAt:
|
|
18
|
+
readonly expiresAt: UnixDateTimeSecondsNumber;
|
|
15
19
|
}
|
|
16
|
-
export type DbxFirebaseStorageFileDownloadUrlPairString = `${
|
|
20
|
+
export type DbxFirebaseStorageFileDownloadUrlPairString = `${UnixDateTimeSecondsNumber}_${StorageFileSignedDownloadUrl}`;
|
|
17
21
|
export type DbxFirebaseStorageFileDownloadUrlPairsRecord = Record<StorageFileId, DbxFirebaseStorageFileDownloadUrlPairString>;
|
|
18
22
|
export interface DbxFirebaseStorageFileDownloadUserCache {
|
|
19
23
|
readonly uid: FirebaseAuthUserId;
|
|
@@ -30,7 +34,7 @@ export declare class DbxFirebaseStorageFileDownloadStorage {
|
|
|
30
34
|
static readonly DEFAULT_MAX_DOWNLOAD_URLS = 100;
|
|
31
35
|
readonly authService: DbxFirebaseAuthService;
|
|
32
36
|
readonly storageAccessor: StorageAccessor<DbxFirebaseStorageFileDownloadUserCache>;
|
|
33
|
-
addDownloadUrl({ id, downloadUrl, expiresAt }: DbxFirebaseStorageFileDownloadUrlPair): Observable<void>;
|
|
37
|
+
addDownloadUrl({ id, downloadUrl, expiresAt, mimeType }: DbxFirebaseStorageFileDownloadUrlPair): Observable<void>;
|
|
34
38
|
/**
|
|
35
39
|
* Returns the cached download URL pair for the given key.
|
|
36
40
|
*
|