@dereekb/dbx-firebase 6.0.0 → 7.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.
- package/esm2020/lib/model/store/index.mjs +2 -1
- package/esm2020/lib/model/store/store.document.crud.mjs +43 -0
- package/esm2020/lib/model/store/store.document.mjs +26 -10
- package/fesm2015/dereekb-dbx-firebase.mjs +63 -11
- package/fesm2015/dereekb-dbx-firebase.mjs.map +1 -1
- package/fesm2020/dereekb-dbx-firebase.mjs +67 -11
- package/fesm2020/dereekb-dbx-firebase.mjs.map +1 -1
- package/lib/model/store/index.d.ts +1 -0
- package/lib/model/store/store.document.crud.d.ts +27 -0
- package/lib/model/store/store.document.d.ts +39 -11
- package/package.json +6 -6
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { urlWithoutParameters, cachedGetter, addToSet, removeFromSet, filterMaybeValues, mapIterable, asArray, excludeValuesFromArray, containsStringAnyCase, addToSetCopy, forEachKeyValue, readableError, isMaybeSo } from '@dereekb/util';
|
|
1
|
+
import { urlWithoutParameters, cachedGetter, addToSet, removeFromSet, filterMaybeValues, mapIterable, asArray, excludeValuesFromArray, containsStringAnyCase, addToSetCopy, forEachKeyValue, readableError, isMaybeSo, firstValue } from '@dereekb/util';
|
|
2
2
|
import * as i0 from '@angular/core';
|
|
3
3
|
import { InjectionToken, Injectable, Inject, Optional, Component, Input, Directive, EventEmitter, Output, NgModule, Injector, forwardRef, Host } from '@angular/core';
|
|
4
4
|
import { getToken, initializeAppCheck, ReCaptchaV3Provider } from 'firebase/app-check';
|
|
@@ -11,7 +11,7 @@ import * as i2 from '@angular/material/icon';
|
|
|
11
11
|
import { MatIconModule } from '@angular/material/icon';
|
|
12
12
|
import * as i6 from '@angular/common';
|
|
13
13
|
import { CommonModule } from '@angular/common';
|
|
14
|
-
import { filterMaybe, isNot, SubscriptionObject, cleanupDestroyable, accumulatorFlattenPageListLoadingState, useFirst, successResult, beginLoading, loadingStateFromObs, errorResult, cleanup } from '@dereekb/rxjs';
|
|
14
|
+
import { filterMaybe, isNot, SubscriptionObject, cleanupDestroyable, accumulatorFlattenPageListLoadingState, useFirst, successResult, beginLoading, loadingStateFromObs, errorResult, lazyFrom, cleanup } from '@dereekb/rxjs';
|
|
15
15
|
import * as i3$1 from '@dereekb/dbx-core';
|
|
16
16
|
import { loggedInObsFromIsLoggedIn, loggedOutObsFromIsLoggedIn, authUserIdentifier, DbxInjectionContext, AbstractForwardDbxInjectionContextDirective, DBX_INJECTION_COMPONENT_DATA, DbxInjectionComponentModule, DbxAuthService, AbstractSubscriptionDirective, AbstractIfDirective, LockSetComponentStore } from '@dereekb/dbx-core';
|
|
17
17
|
import * as i1$1 from '@angular/fire/auth';
|
|
@@ -2302,27 +2302,36 @@ class AbstractDbxFirebaseDocumentStore extends LockSetComponentStore {
|
|
|
2302
2302
|
super(...arguments);
|
|
2303
2303
|
// MARK: Effects
|
|
2304
2304
|
// MARK: Accessors
|
|
2305
|
+
this.currentFirestoreCollectionLike$ = this.state$.pipe(map((x) => x.firestoreCollection ?? x.firestoreCollectionLike), distinctUntilChanged(), shareReplay(1));
|
|
2305
2306
|
this.currentFirestoreCollection$ = this.state$.pipe(map((x) => x.firestoreCollection), distinctUntilChanged(), shareReplay(1));
|
|
2307
|
+
this.firestoreCollectionLike$ = this.currentFirestoreCollectionLike$.pipe(filterMaybe());
|
|
2306
2308
|
this.firestoreCollection$ = this.currentFirestoreCollection$.pipe(filterMaybe());
|
|
2307
2309
|
this.currentInputId$ = this.state$.pipe(map((x) => x.id), distinctUntilChanged(), shareReplay(1));
|
|
2308
2310
|
this.inputId$ = this.currentInputId$.pipe(filterMaybe(), distinctUntilChanged(), shareReplay(1));
|
|
2311
|
+
this.currentInputKey$ = this.state$.pipe(map((x) => x.key), distinctUntilChanged(), shareReplay(1));
|
|
2312
|
+
this.inputKey$ = this.currentInputKey$.pipe(filterMaybe(), distinctUntilChanged(), shareReplay(1));
|
|
2309
2313
|
this.currentInputRef$ = this.state$.pipe(map((x) => x.ref), distinctUntilChanged(), shareReplay(1));
|
|
2310
2314
|
this.inputRef$ = this.currentInputRef$.pipe(filterMaybe(), distinctUntilChanged(), shareReplay(1));
|
|
2311
|
-
this.currentDocument$ = combineLatest([this.
|
|
2315
|
+
this.currentDocument$ = combineLatest([this.currentInputId$, this.currentInputKey$, this.currentInputRef$]).pipe(switchMap(([id, key, ref]) => {
|
|
2312
2316
|
let document;
|
|
2313
|
-
if (
|
|
2314
|
-
|
|
2315
|
-
|
|
2316
|
-
|
|
2317
|
-
|
|
2318
|
-
|
|
2319
|
-
|
|
2317
|
+
if (ref) {
|
|
2318
|
+
document = this.firestoreCollectionLike$.pipe(map((x) => x.documentAccessor().loadDocument(ref)));
|
|
2319
|
+
}
|
|
2320
|
+
else if (key) {
|
|
2321
|
+
document = this.firestoreCollectionLike$.pipe(map((x) => x.documentAccessor().loadDocumentForKey(key)));
|
|
2322
|
+
}
|
|
2323
|
+
else if (id) {
|
|
2324
|
+
document = this.firestoreCollection$.pipe(map((x) => x.documentAccessor().loadDocumentForPath(id)));
|
|
2325
|
+
}
|
|
2326
|
+
else {
|
|
2327
|
+
document = of(undefined);
|
|
2320
2328
|
}
|
|
2321
2329
|
return document;
|
|
2322
2330
|
}), distinctUntilChanged(), shareReplay(1));
|
|
2323
2331
|
this.document$ = this.currentDocument$.pipe(filterMaybe(), distinctUntilChanged(), shareReplay(1));
|
|
2324
2332
|
this.documentLoadingState$ = this.currentDocument$.pipe(map((x) => (x ? successResult(x) : beginLoading())), shareReplay(1));
|
|
2325
2333
|
this.id$ = this.document$.pipe(map((x) => x.id), shareReplay());
|
|
2334
|
+
this.key$ = this.document$.pipe(map((x) => x.key), shareReplay());
|
|
2326
2335
|
this.ref$ = this.document$.pipe(map((x) => x.documentRef), shareReplay());
|
|
2327
2336
|
this.snapshot$ = this.document$.pipe(switchMap((x) => x.accessor.stream()), shareReplay(1));
|
|
2328
2337
|
this.snapshotLoadingState$ = this.currentDocument$.pipe(switchMap(() => loadingStateFromObs(this.snapshot$)), shareReplay(1));
|
|
@@ -2349,16 +2358,23 @@ class AbstractDbxFirebaseDocumentStore extends LockSetComponentStore {
|
|
|
2349
2358
|
}), shareReplay(1));
|
|
2350
2359
|
this.exists$ = this.currentData$.pipe(map((x) => isMaybeSo(x)), shareReplay(1));
|
|
2351
2360
|
this.doesNotExist$ = this.exists$.pipe(map((x) => !x), shareReplay(1));
|
|
2361
|
+
this.modelIdentity$ = this.document$.pipe(map((x) => x.modelIdentity), shareReplay(1));
|
|
2352
2362
|
// MARK: State Changes
|
|
2353
2363
|
/**
|
|
2354
2364
|
* Sets the id of the document to load.
|
|
2355
2365
|
*/
|
|
2356
2366
|
this.setId = this.updater((state, id) => (id ? { ...state, id, ref: undefined } : { ...state, id }));
|
|
2367
|
+
/**
|
|
2368
|
+
* Sets the key of the document to load.
|
|
2369
|
+
*/
|
|
2370
|
+
this.setKey = this.updater((state, key) => (key ? { ...state, key, ref: undefined } : { ...state, key }));
|
|
2357
2371
|
/**
|
|
2358
2372
|
* Sets the ref of the document to load.
|
|
2359
2373
|
*/
|
|
2360
2374
|
this.setRef = this.updater((state, ref) => (ref ? { ...state, id: undefined, ref } : { ...state, ref }));
|
|
2375
|
+
this.clearRefs = this.updater((state) => ({ ...state, id: undefined, key: undefined, ref: undefined }));
|
|
2361
2376
|
this.setFirestoreCollection = this.updater((state, firestoreCollection) => ({ ...state, firestoreCollection }));
|
|
2377
|
+
this.setFirestoreCollectionLike = this.updater((state, firestoreCollectionLike) => ({ ...state, firestoreCollectionLike }));
|
|
2362
2378
|
}
|
|
2363
2379
|
}
|
|
2364
2380
|
AbstractDbxFirebaseDocumentStore.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.3.2", ngImport: i0, type: AbstractDbxFirebaseDocumentStore, deps: null, target: i0.ɵɵFactoryTarget.Injectable });
|
|
@@ -2367,6 +2383,46 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.3.2", ngImpor
|
|
|
2367
2383
|
type: Injectable
|
|
2368
2384
|
}] });
|
|
2369
2385
|
|
|
2386
|
+
/**
|
|
2387
|
+
* Creates a function for a store that DbxFirebaseDocumentStore captures the ModelFirebaseCreateFunction result and sets the key of the created value.
|
|
2388
|
+
*
|
|
2389
|
+
* @param store
|
|
2390
|
+
* @param fn
|
|
2391
|
+
* @returns
|
|
2392
|
+
*/
|
|
2393
|
+
function firebaseDocumentStoreCreateFunction(store, fn) {
|
|
2394
|
+
return (params) => loadingStateFromObs(lazyFrom(() => fn(params).then((result) => {
|
|
2395
|
+
const modelKeys = result.modelKeys;
|
|
2396
|
+
const firstKey = firstValue(modelKeys);
|
|
2397
|
+
if (firstKey) {
|
|
2398
|
+
store.setKey(firstKey);
|
|
2399
|
+
}
|
|
2400
|
+
return result;
|
|
2401
|
+
})));
|
|
2402
|
+
}
|
|
2403
|
+
function firebaseDocumentStoreUpdateFunction(store, fn) {
|
|
2404
|
+
return (params) => loadingStateFromObs(store.key$.pipe(first(), switchMap((key) => fn({
|
|
2405
|
+
...params,
|
|
2406
|
+
key // inject key into the parameters.
|
|
2407
|
+
}))));
|
|
2408
|
+
}
|
|
2409
|
+
/**
|
|
2410
|
+
* Deletes a function for a store that DbxFirebaseDocumentStore captures the ModelFirebaseDeleteFunction result and sets the key of the created value.
|
|
2411
|
+
*
|
|
2412
|
+
* @param store
|
|
2413
|
+
* @param fn
|
|
2414
|
+
* @returns
|
|
2415
|
+
*/
|
|
2416
|
+
function firebaseDocumentStoreDeleteFunction(store, fn) {
|
|
2417
|
+
return (params) => loadingStateFromObs(store.key$.pipe(first(), switchMap((key) => fn({
|
|
2418
|
+
...params,
|
|
2419
|
+
key // inject key into the parameters.
|
|
2420
|
+
}).then((result) => {
|
|
2421
|
+
store.clearRefs();
|
|
2422
|
+
return result;
|
|
2423
|
+
}))));
|
|
2424
|
+
}
|
|
2425
|
+
|
|
2370
2426
|
function setParentStoreEffect(store) {
|
|
2371
2427
|
return store.effect((input) => {
|
|
2372
2428
|
return input.pipe(map((parentStore) => {
|
|
@@ -2564,5 +2620,5 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.3.2", ngImpor
|
|
|
2564
2620
|
* Generated bundle index. Do not edit.
|
|
2565
2621
|
*/
|
|
2566
2622
|
|
|
2567
|
-
export { AbstractConfiguredDbxFirebaseLoginButtonDirective, AbstractDbxFirebaseCollectionStore, AbstractDbxFirebaseCollectionWithParentStore, AbstractDbxFirebaseDocumentStore, AbstractDbxFirebaseDocumentWithParentStore, DBX_FIREBASE_MODEL_DOES_NOT_EXIST_ERROR, DBX_FIREBASE_OPTIONS_TOKEN, DBX_FIREBASE_ROUTER_SYNC_DEFAULT_ID_PARAM_KEY, DBX_FIRESTORE_CONTEXT_TOKEN, DEFAULT_CONFIGURED_DBX_FIREBASE_LOGIN_BUTTON_TEMPLATE, DEFAULT_DBX_FIREBASE_AUTH_SERVICE_DELEGATE, DEFAULT_FIREBASE_AUTH_LOGIN_PASSWORD_CONFIG, DEFAULT_FIREBASE_AUTH_LOGIN_PASSWORD_CONFIG_TOKEN, DEFAULT_FIREBASE_AUTH_LOGIN_PROVIDERS_TOKEN, DEFAULT_FIREBASE_AUTH_LOGIN_TERMS_COMPONENT_CLASS_TOKEN, DEFAULT_FIREBASE_LOGIN_METHOD_CATEGORY, DbxFirebaseAppCheckHttpInterceptor, DbxFirebaseAuthContextInfo, DbxFirebaseAuthLoginService, DbxFirebaseAuthModule, DbxFirebaseAuthService, DbxFirebaseAuthServiceDelegate, DbxFirebaseCollectionChangeDirective, DbxFirebaseCollectionHasChangeDirective, DbxFirebaseCollectionListDirective, DbxFirebaseCollectionLoaderInstance, DbxFirebaseCollectionStoreDirective, DbxFirebaseCollectionWithParentStoreDirective, DbxFirebaseDefaultAppCheckProviderModule, DbxFirebaseDefaultAuthProviderModule, DbxFirebaseDefaultFirebaseProvidersModule, DbxFirebaseDefaultFirestoreProviderModule, DbxFirebaseDefaultFunctionsProviderModule, DbxFirebaseDefaultStorageProviderModule, DbxFirebaseDocumentAuthIdDirective, DbxFirebaseDocumentStoreDirective, DbxFirebaseDocumentStoreRouteIdDirective, DbxFirebaseEmailFormComponent, DbxFirebaseEmailRecoveryFormComponent, DbxFirebaseEmulatorModule, DbxFirebaseFirestoreCollectionModule, DbxFirebaseFunctionsModule, DbxFirebaseLoginAnonymousComponent, DbxFirebaseLoginAppleComponent, DbxFirebaseLoginButtonComponent, DbxFirebaseLoginButtonContainerComponent, DbxFirebaseLoginComponent, DbxFirebaseLoginContext, DbxFirebaseLoginContextBackButtonComponent, DbxFirebaseLoginContextDirective, DbxFirebaseLoginEmailComponent, DbxFirebaseLoginEmailContentComponent, DbxFirebaseLoginFacebookComponent, DbxFirebaseLoginGitHubComponent, DbxFirebaseLoginGoogleComponent, DbxFirebaseLoginListComponent, DbxFirebaseLoginMicrosoftComponent, DbxFirebaseLoginModule, DbxFirebaseLoginModuleRootConfig, DbxFirebaseLoginTermsComponent, DbxFirebaseLoginTermsSimpleComponent, DbxFirebaseLoginTwitterComponent, DbxFirebaseModelModule, DbxFirebaseModelStoreModule, DbxFirebaseModule, DbxFirebaseParsedEmulatorsConfig, DbxFirebaseRegisterComponent, DbxFirebaseRegisterEmailComponent, DbxFirestoreContextService, FIREBASE_AUTH_NETWORK_REQUEST_ERROR, FIREBASE_AUTH_USER_NOT_FOUND_ERROR, OAUTH_FIREBASE_LOGIN_METHOD_CATEGORY, authRolesObsWithClaimsService, authUserInfoFromAuthUser, authUserStateFromFirebaseAuthService, dbxFirebaseCollectionLoaderInstance, dbxFirebaseCollectionLoaderInstanceWithCollection, defaultDbxFirebaseAuthServiceDelegateWithClaimsService, defaultFirebaseAuthLoginProvidersFactory, enableAppCheckDebugTokenGeneration, firebaseAuthErrorToReadableError, firebaseAuthTokenFromUser, modelDoesNotExistError, provideDbxFirebaseCollectionStoreDirective, provideDbxFirebaseCollectionWithParentStoreDirective, provideDbxFirebaseDocumentStoreDirective, readValueFromIdToken, setParentStoreEffect };
|
|
2623
|
+
export { AbstractConfiguredDbxFirebaseLoginButtonDirective, AbstractDbxFirebaseCollectionStore, AbstractDbxFirebaseCollectionWithParentStore, AbstractDbxFirebaseDocumentStore, AbstractDbxFirebaseDocumentWithParentStore, DBX_FIREBASE_MODEL_DOES_NOT_EXIST_ERROR, DBX_FIREBASE_OPTIONS_TOKEN, DBX_FIREBASE_ROUTER_SYNC_DEFAULT_ID_PARAM_KEY, DBX_FIRESTORE_CONTEXT_TOKEN, DEFAULT_CONFIGURED_DBX_FIREBASE_LOGIN_BUTTON_TEMPLATE, DEFAULT_DBX_FIREBASE_AUTH_SERVICE_DELEGATE, DEFAULT_FIREBASE_AUTH_LOGIN_PASSWORD_CONFIG, DEFAULT_FIREBASE_AUTH_LOGIN_PASSWORD_CONFIG_TOKEN, DEFAULT_FIREBASE_AUTH_LOGIN_PROVIDERS_TOKEN, DEFAULT_FIREBASE_AUTH_LOGIN_TERMS_COMPONENT_CLASS_TOKEN, DEFAULT_FIREBASE_LOGIN_METHOD_CATEGORY, DbxFirebaseAppCheckHttpInterceptor, DbxFirebaseAuthContextInfo, DbxFirebaseAuthLoginService, DbxFirebaseAuthModule, DbxFirebaseAuthService, DbxFirebaseAuthServiceDelegate, DbxFirebaseCollectionChangeDirective, DbxFirebaseCollectionHasChangeDirective, DbxFirebaseCollectionListDirective, DbxFirebaseCollectionLoaderInstance, DbxFirebaseCollectionStoreDirective, DbxFirebaseCollectionWithParentStoreDirective, DbxFirebaseDefaultAppCheckProviderModule, DbxFirebaseDefaultAuthProviderModule, DbxFirebaseDefaultFirebaseProvidersModule, DbxFirebaseDefaultFirestoreProviderModule, DbxFirebaseDefaultFunctionsProviderModule, DbxFirebaseDefaultStorageProviderModule, DbxFirebaseDocumentAuthIdDirective, DbxFirebaseDocumentStoreDirective, DbxFirebaseDocumentStoreRouteIdDirective, DbxFirebaseEmailFormComponent, DbxFirebaseEmailRecoveryFormComponent, DbxFirebaseEmulatorModule, DbxFirebaseFirestoreCollectionModule, DbxFirebaseFunctionsModule, DbxFirebaseLoginAnonymousComponent, DbxFirebaseLoginAppleComponent, DbxFirebaseLoginButtonComponent, DbxFirebaseLoginButtonContainerComponent, DbxFirebaseLoginComponent, DbxFirebaseLoginContext, DbxFirebaseLoginContextBackButtonComponent, DbxFirebaseLoginContextDirective, DbxFirebaseLoginEmailComponent, DbxFirebaseLoginEmailContentComponent, DbxFirebaseLoginFacebookComponent, DbxFirebaseLoginGitHubComponent, DbxFirebaseLoginGoogleComponent, DbxFirebaseLoginListComponent, DbxFirebaseLoginMicrosoftComponent, DbxFirebaseLoginModule, DbxFirebaseLoginModuleRootConfig, DbxFirebaseLoginTermsComponent, DbxFirebaseLoginTermsSimpleComponent, DbxFirebaseLoginTwitterComponent, DbxFirebaseModelModule, DbxFirebaseModelStoreModule, DbxFirebaseModule, DbxFirebaseParsedEmulatorsConfig, DbxFirebaseRegisterComponent, DbxFirebaseRegisterEmailComponent, DbxFirestoreContextService, FIREBASE_AUTH_NETWORK_REQUEST_ERROR, FIREBASE_AUTH_USER_NOT_FOUND_ERROR, OAUTH_FIREBASE_LOGIN_METHOD_CATEGORY, authRolesObsWithClaimsService, authUserInfoFromAuthUser, authUserStateFromFirebaseAuthService, dbxFirebaseCollectionLoaderInstance, dbxFirebaseCollectionLoaderInstanceWithCollection, defaultDbxFirebaseAuthServiceDelegateWithClaimsService, defaultFirebaseAuthLoginProvidersFactory, enableAppCheckDebugTokenGeneration, firebaseAuthErrorToReadableError, firebaseAuthTokenFromUser, firebaseDocumentStoreCreateFunction, firebaseDocumentStoreDeleteFunction, firebaseDocumentStoreUpdateFunction, modelDoesNotExistError, provideDbxFirebaseCollectionStoreDirective, provideDbxFirebaseCollectionWithParentStoreDirective, provideDbxFirebaseDocumentStoreDirective, readValueFromIdToken, setParentStoreEffect };
|
|
2568
2624
|
//# sourceMappingURL=dereekb-dbx-firebase.mjs.map
|