@dereekb/firebase-server 13.2.2 → 13.3.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/index.cjs.js +7506 -1884
- package/index.esm.js +7505 -1890
- package/mailgun/index.cjs.js +333 -31
- package/mailgun/index.esm.js +333 -31
- package/mailgun/package.json +8 -8
- package/mailgun/src/lib/auth.mailgun.d.ts +22 -3
- package/model/index.cjs.js +11334 -3830
- package/model/index.esm.js +11338 -3834
- package/model/package.json +8 -8
- package/model/src/lib/mailgun/notification.send.service.mailgun.d.ts +27 -1
- package/model/src/lib/notification/notification.action.init.service.d.ts +93 -1
- package/model/src/lib/notification/notification.action.service.d.ts +151 -2
- package/model/src/lib/notification/notification.config.d.ts +19 -7
- package/model/src/lib/notification/notification.config.service.d.ts +44 -6
- package/model/src/lib/notification/notification.create.run.d.ts +33 -5
- package/model/src/lib/notification/notification.error.d.ts +63 -0
- package/model/src/lib/notification/notification.module.d.ts +11 -0
- package/model/src/lib/notification/notification.send.d.ts +8 -1
- package/model/src/lib/notification/notification.send.service.d.ts +7 -1
- package/model/src/lib/notification/notification.send.service.notificationsummary.d.ts +32 -2
- package/model/src/lib/notification/notification.send.service.text.d.ts +11 -3
- package/model/src/lib/notification/notification.task.service.d.ts +13 -1
- package/model/src/lib/notification/notification.task.service.handler.d.ts +27 -3
- package/model/src/lib/notification/notification.task.service.util.d.ts +16 -4
- package/model/src/lib/notification/notification.task.subtask.handler.d.ts +31 -1
- package/model/src/lib/notification/notification.util.d.ts +70 -0
- package/model/src/lib/storagefile/storagefile.action.init.service.d.ts +62 -1
- package/model/src/lib/storagefile/storagefile.action.server.d.ts +124 -2
- package/model/src/lib/storagefile/storagefile.error.d.ts +44 -0
- package/model/src/lib/storagefile/storagefile.module.d.ts +11 -0
- package/model/src/lib/storagefile/storagefile.task.service.handler.d.ts +4 -1
- package/model/src/lib/storagefile/storagefile.upload.service.d.ts +13 -1
- package/model/src/lib/storagefile/storagefile.upload.service.initializer.d.ts +43 -1
- package/model/src/lib/storagefile/storagefile.util.d.ts +8 -0
- package/oidc/index.cjs.default.js +1 -0
- package/oidc/index.cjs.js +5607 -0
- package/oidc/index.cjs.mjs +2 -0
- package/oidc/index.d.ts +1 -0
- package/oidc/index.esm.js +5560 -0
- package/oidc/package.json +26 -0
- package/oidc/src/index.d.ts +1 -0
- package/oidc/src/lib/controller/index.d.ts +3 -0
- package/oidc/src/lib/controller/oidc.interaction.controller.d.ts +54 -0
- package/oidc/src/lib/controller/oidc.provider.controller.d.ts +18 -0
- package/oidc/src/lib/controller/oidc.wellknown.controller.d.ts +36 -0
- package/oidc/src/lib/index.d.ts +6 -0
- package/oidc/src/lib/middleware/index.d.ts +3 -0
- package/oidc/src/lib/middleware/oauth-auth.decorator.d.ts +14 -0
- package/oidc/src/lib/middleware/oauth-auth.middleware.d.ts +21 -0
- package/oidc/src/lib/middleware/oauth-auth.module.d.ts +50 -0
- package/oidc/src/lib/model/index.d.ts +3 -0
- package/oidc/src/lib/model/jwks/index.d.ts +3 -0
- package/oidc/src/lib/model/jwks/jwks.d.ts +107 -0
- package/oidc/src/lib/model/jwks/jwks.id.d.ts +9 -0
- package/oidc/src/lib/model/jwks/jwks.query.d.ts +18 -0
- package/oidc/src/lib/model/model.d.ts +12 -0
- package/oidc/src/lib/model/oidc/index.d.ts +2 -0
- package/oidc/src/lib/model/oidc/oidcmodel.action.server.d.ts +62 -0
- package/oidc/src/lib/model/oidc/oidcmodel.module.d.ts +23 -0
- package/oidc/src/lib/oidc.config.d.ts +175 -0
- package/oidc/src/lib/oidc.module.d.ts +100 -0
- package/oidc/src/lib/service/index.d.ts +10 -0
- package/oidc/src/lib/service/oidc.account.d.ts +36 -0
- package/oidc/src/lib/service/oidc.account.service.d.ts +104 -0
- package/oidc/src/lib/service/oidc.adapter.service.d.ts +20 -0
- package/oidc/src/lib/service/oidc.auth.d.ts +26 -0
- package/oidc/src/lib/service/oidc.client.service.d.ts +57 -0
- package/oidc/src/lib/service/oidc.config.service.d.ts +100 -0
- package/oidc/src/lib/service/oidc.encryption.service.d.ts +53 -0
- package/oidc/src/lib/service/oidc.interaction.service.d.ts +44 -0
- package/oidc/src/lib/service/oidc.jwks.service.d.ts +105 -0
- package/oidc/src/lib/service/oidc.service.d.ts +55 -0
- package/package.json +15 -9
- package/src/lib/auth/auth.context.d.ts +22 -2
- package/src/lib/auth/auth.service.d.ts +5 -0
- package/src/lib/auth/auth.service.error.d.ts +2 -1
- package/src/lib/auth/auth.util.d.ts +15 -3
- package/src/lib/env/env.config.d.ts +42 -0
- package/src/lib/env/env.service.d.ts +17 -0
- package/src/lib/env/index.d.ts +1 -0
- package/src/lib/firestore/array.d.ts +11 -3
- package/src/lib/firestore/driver.accessor.batch.d.ts +27 -4
- package/src/lib/firestore/driver.accessor.d.ts +43 -0
- package/src/lib/firestore/driver.accessor.default.d.ts +20 -0
- package/src/lib/firestore/driver.accessor.transaction.d.ts +28 -4
- package/src/lib/firestore/driver.d.ts +14 -0
- package/src/lib/firestore/driver.query.d.ts +25 -0
- package/src/lib/firestore/increment.d.ts +13 -3
- package/src/lib/firestore/snapshot/index.d.ts +1 -1
- package/src/lib/firestore/snapshot/{snapshot.field.d.ts → snapshot.field.encrypt.d.ts} +13 -27
- package/src/lib/function/assert.d.ts +32 -16
- package/src/lib/function/context.d.ts +26 -0
- package/src/lib/function/error.auth.d.ts +15 -0
- package/src/lib/function/error.d.ts +68 -4
- package/src/lib/nest/app.d.ts +53 -9
- package/src/lib/nest/app.module.d.ts +90 -0
- package/src/lib/nest/auth/auth.module.d.ts +30 -4
- package/src/lib/nest/auth/auth.util.d.ts +38 -0
- package/src/lib/nest/controller/auth.context.server.d.ts +27 -0
- package/src/lib/nest/controller/index.d.ts +1 -0
- package/src/lib/nest/development/development.app.function.d.ts +45 -0
- package/src/lib/nest/development/development.assert.function.d.ts +19 -1
- package/src/lib/nest/development/development.function.d.ts +42 -3
- package/src/lib/nest/development/development.schedule.function.d.ts +29 -0
- package/src/lib/nest/development/development.schedule.function.error.d.ts +21 -0
- package/src/lib/nest/env/env.service.d.ts +9 -0
- package/src/lib/nest/env/env.util.d.ts +16 -0
- package/src/lib/nest/firebase/firebase.module.d.ts +13 -1
- package/src/lib/nest/firestore/firestore.module.d.ts +24 -8
- package/src/lib/nest/function/call.d.ts +75 -6
- package/src/lib/nest/function/context.d.ts +85 -2
- package/src/lib/nest/function/nest.d.ts +46 -0
- package/src/lib/nest/function/schedule.d.ts +49 -0
- package/src/lib/nest/function/v2/blocking.d.ts +92 -8
- package/src/lib/nest/function/v2/call.d.ts +38 -8
- package/src/lib/nest/function/v2/event.d.ts +67 -4
- package/src/lib/nest/function/v2/schedule.d.ts +36 -5
- package/src/lib/nest/index.d.ts +3 -0
- package/src/lib/nest/middleware/appcheck.d.ts +5 -0
- package/src/lib/nest/middleware/appcheck.middleware.d.ts +44 -14
- package/src/lib/nest/middleware/appcheck.module.d.ts +10 -1
- package/src/lib/nest/middleware/globalprefix.d.ts +31 -3
- package/src/lib/nest/middleware/index.d.ts +2 -1
- package/src/lib/nest/middleware/rawbody.middleware.d.ts +6 -0
- package/src/lib/nest/model/call.model.function.d.ts +69 -3
- package/src/lib/nest/model/create.model.function.d.ts +66 -0
- package/src/lib/nest/model/crud.assert.function.d.ts +27 -1
- package/src/lib/nest/model/delete.model.function.d.ts +55 -0
- package/src/lib/nest/model/permission.error.d.ts +15 -0
- package/src/lib/nest/model/read.model.function.d.ts +57 -0
- package/src/lib/nest/model/specifier.function.d.ts +58 -1
- package/src/lib/nest/model/update.model.function.d.ts +58 -0
- package/src/lib/nest/nest.provider.d.ts +24 -11
- package/src/lib/nest/nest.provider.server.d.ts +12 -0
- package/src/lib/nest/storage/storage.module.d.ts +30 -4
- package/src/lib/storage/driver.accessor.d.ts +33 -0
- package/src/lib/storage/driver.d.ts +14 -0
- package/src/lib/storage/storage.d.ts +11 -4
- package/src/lib/storage/storage.service.d.ts +10 -1
- package/src/lib/type.d.ts +7 -2
- package/test/index.cjs.js +4072 -757
- package/test/index.esm.js +4073 -761
- package/test/package.json +8 -8
- package/test/src/lib/firebase/firebase.admin.auth.d.ts +82 -1
- package/test/src/lib/firebase/firebase.admin.collection.d.ts +55 -3
- package/test/src/lib/firebase/firebase.admin.d.ts +64 -0
- package/test/src/lib/firebase/firebase.admin.function.d.ts +84 -0
- package/test/src/lib/firebase/firebase.admin.nest.d.ts +125 -17
- package/test/src/lib/firebase/firebase.admin.nest.function.callable.context.d.ts +44 -0
- package/test/src/lib/firebase/firebase.admin.nest.function.cloud.context.d.ts +41 -0
- package/test/src/lib/firebase/firebase.admin.nest.function.d.ts +98 -0
- package/test/src/lib/firebase/firebase.admin.test.server.d.ts +26 -0
- package/test/src/lib/firebase/firebase.d.ts +57 -2
- package/test/src/lib/firebase/firebase.function.d.ts +138 -0
- package/test/src/lib/firestore/firestore.admin.d.ts +6 -0
- package/test/src/lib/firestore/firestore.d.ts +30 -0
- package/test/src/lib/storage/storage.admin.d.ts +9 -3
- package/test/src/lib/storage/storage.d.ts +30 -0
- package/zoho/index.cjs.js +406 -73
- package/zoho/index.esm.js +406 -73
- package/zoho/package.json +8 -8
- package/zoho/src/lib/zoho.accounts.firebase.d.ts +13 -2
- package/zoho/src/lib/zoho.accounts.firebase.system.d.ts +29 -6
- package/index.cjs.js.map +0 -1
- package/index.esm.js.map +0 -1
- /package/src/lib/nest/middleware/{webhook.d.ts → webhook.module.d.ts} +0 -0
|
@@ -3,21 +3,79 @@ import { type FirestoreModelType, type FirestoreModelIdentity, type FirestoreMod
|
|
|
3
3
|
import { type OnCallWithAuthAwareNestRequireAuthRef, type OnCallWithNestContext } from '../function/call';
|
|
4
4
|
import { type NestContextCallableRequestWithAuth, type NestContextCallableRequestWithOptionalAuth } from '../function/nest';
|
|
5
5
|
import { type AssertModelCrudRequestFunction } from './crud.assert.function';
|
|
6
|
+
/**
|
|
7
|
+
* Request type for model update handlers that require authentication.
|
|
8
|
+
*
|
|
9
|
+
* @typeParam N - The NestJS context type.
|
|
10
|
+
* @typeParam I - The input data type for the update operation.
|
|
11
|
+
*/
|
|
6
12
|
export type OnCallUpdateModelRequest<N, I = unknown> = NestContextCallableRequestWithAuth<N, I> & ModelFirebaseCrudFunctionSpecifierRef;
|
|
13
|
+
/**
|
|
14
|
+
* A model update handler function that requires an authenticated caller.
|
|
15
|
+
*/
|
|
7
16
|
export type OnCallUpdateModelFunctionWithAuth<N, I = unknown, O = void> = ((request: OnCallUpdateModelRequest<N, I>) => PromiseOrValue<O>) & {
|
|
8
17
|
readonly _requiresAuth?: true;
|
|
9
18
|
};
|
|
19
|
+
/**
|
|
20
|
+
* Request type for model update handlers that allow unauthenticated callers.
|
|
21
|
+
*/
|
|
10
22
|
export type OnCallUpdateModelRequestWithOptionalAuth<N, I = unknown> = NestContextCallableRequestWithOptionalAuth<N, I> & ModelFirebaseCrudFunctionSpecifierRef;
|
|
23
|
+
/**
|
|
24
|
+
* A model update handler function that does not require authentication.
|
|
25
|
+
*/
|
|
11
26
|
export type OnCallUpdateModelFunctionWithOptionalAuth<N, I = unknown, O = void> = ((request: OnCallUpdateModelRequestWithOptionalAuth<N, I>) => PromiseOrValue<O>) & {
|
|
12
27
|
readonly _requireAuth: false;
|
|
13
28
|
};
|
|
29
|
+
/**
|
|
30
|
+
* Standard model update handler requiring auth (the common case).
|
|
31
|
+
*/
|
|
14
32
|
export type OnCallUpdateModelFunction<N, I = unknown, O = void> = OnCallUpdateModelFunctionWithAuth<N, I, O> & OnCallWithAuthAwareNestRequireAuthRef;
|
|
33
|
+
/**
|
|
34
|
+
* Union of auth-required and optional-auth update handlers.
|
|
35
|
+
*/
|
|
15
36
|
export type OnCallUpdateModelFunctionAuthAware<N, I = unknown, O = void> = OnCallUpdateModelFunction<N, I, O> | OnCallUpdateModelFunctionWithOptionalAuth<N, I, O>;
|
|
37
|
+
/**
|
|
38
|
+
* Maps Firestore model type strings to their update handler functions.
|
|
39
|
+
*
|
|
40
|
+
* Pass this map to {@link onCallUpdateModel} to register all model types
|
|
41
|
+
* that support updates through the call model system.
|
|
42
|
+
*
|
|
43
|
+
* @typeParam N - The NestJS context type.
|
|
44
|
+
* @typeParam T - The Firestore model identity constraining valid model type keys.
|
|
45
|
+
*/
|
|
16
46
|
export type OnCallUpdateModelMap<N, T extends FirestoreModelIdentity = FirestoreModelIdentity> = {
|
|
17
47
|
readonly [K in FirestoreModelTypes<T>]?: OnCallUpdateModelFunctionAuthAware<N, any, any>;
|
|
18
48
|
};
|
|
49
|
+
/**
|
|
50
|
+
* Configuration for {@link onCallUpdateModel}.
|
|
51
|
+
*/
|
|
19
52
|
export interface OnCallUpdateModelConfig<N> {
|
|
53
|
+
/** Optional assertion run before the update handler; throw to reject. */
|
|
20
54
|
readonly preAssert?: AssertModelCrudRequestFunction<N, OnCallUpdateModelParams>;
|
|
21
55
|
}
|
|
56
|
+
/**
|
|
57
|
+
* Factory that creates a callable function handling model updates for multiple model types.
|
|
58
|
+
*
|
|
59
|
+
* Dispatches to the correct handler based on the `modelType` field in the request,
|
|
60
|
+
* enforces auth requirements per handler, and aggregates API details for MCP introspection.
|
|
61
|
+
*
|
|
62
|
+
* @param map - Maps model type strings to their update handler functions.
|
|
63
|
+
* @param config - Optional configuration including a pre-assertion hook.
|
|
64
|
+
* @returns A callable function for the 'update' CRUD operation.
|
|
65
|
+
*
|
|
66
|
+
* @example
|
|
67
|
+
* ```typescript
|
|
68
|
+
* const updateHandler = onCallUpdateModel<DemoNestContext>({
|
|
69
|
+
* profile: onCallSpecifierHandler({
|
|
70
|
+
* _: updateProfileDefault,
|
|
71
|
+
* username: updateProfileUsername
|
|
72
|
+
* }),
|
|
73
|
+
* guestbook: updateGuestbook
|
|
74
|
+
* });
|
|
75
|
+
* ```
|
|
76
|
+
*/
|
|
22
77
|
export declare function onCallUpdateModel<N>(map: OnCallUpdateModelMap<N>, config?: OnCallUpdateModelConfig<N>): OnCallWithNestContext<N, OnCallUpdateModelParams, unknown>;
|
|
78
|
+
/**
|
|
79
|
+
* Creates a bad-request error indicating the requested model type is not valid for updating.
|
|
80
|
+
*/
|
|
23
81
|
export declare function updateModelUnknownModelTypeError(modelType: FirestoreModelType): import("firebase-functions/https").HttpsError;
|
|
@@ -11,13 +11,14 @@ import { type FirebaseServerActionsContext } from './function/context';
|
|
|
11
11
|
*/
|
|
12
12
|
export type NestApplicationPromiseGetter = Getter<Promise<INestApplicationContext>>;
|
|
13
13
|
/**
|
|
14
|
-
*
|
|
14
|
+
* Factory type that creates a function from a {@link NestApplicationPromiseGetter}.
|
|
15
15
|
*
|
|
16
|
-
* This pattern
|
|
16
|
+
* This pattern enables generating the same function shape for different contexts
|
|
17
|
+
* (e.g., production vs testing) by parameterizing on the Nest application source.
|
|
17
18
|
*/
|
|
18
19
|
export type NestApplicationFunctionFactory<F> = (nestAppPromiseGetter: NestApplicationPromiseGetter) => F;
|
|
19
20
|
/**
|
|
20
|
-
*
|
|
21
|
+
* Factory function that creates a typed context from an initialized {@link INestApplicationContext}.
|
|
21
22
|
*/
|
|
22
23
|
export type MakeNestContext<C> = (nest: INestApplicationContext) => C;
|
|
23
24
|
/**
|
|
@@ -28,6 +29,11 @@ export declare abstract class AbstractNestContext {
|
|
|
28
29
|
constructor(nest: INestApplicationContext);
|
|
29
30
|
get nest(): INestApplicationContext;
|
|
30
31
|
}
|
|
32
|
+
/**
|
|
33
|
+
* Abstract class used for the top-level NestJS context for Firebase services.
|
|
34
|
+
*
|
|
35
|
+
* Your API implementation of this class is usually <AppPrefix>ApiNestContext (e.g. `DemoApiNestContext`).
|
|
36
|
+
*/
|
|
31
37
|
export declare abstract class AbstractFirebaseNestContext<A, Y extends FirebaseModelsService<any, FirebaseAppModelContext<A>>> extends AbstractNestContext implements FirebaseServerEnvServiceRef, FirebaseServerAuthServiceRef, FirebaseServerStorageServiceRef {
|
|
32
38
|
/**
|
|
33
39
|
* FirebasePermissionErrorContextErrorFunction to use with makeModelContext().
|
|
@@ -51,28 +57,35 @@ export declare abstract class AbstractFirebaseNestContext<A, Y extends FirebaseM
|
|
|
51
57
|
abstract get app(): A;
|
|
52
58
|
get storageService(): FirebaseServerStorageService;
|
|
53
59
|
/**
|
|
54
|
-
* Creates a FirebaseAppModelContext
|
|
60
|
+
* Creates a {@link FirebaseAppModelContext} from request auth data.
|
|
61
|
+
*
|
|
62
|
+
* The context includes auth info, app reference, and error factories for permissions/existence checks.
|
|
55
63
|
*
|
|
56
|
-
* @param auth
|
|
57
|
-
* @param buildFn
|
|
58
|
-
* @returns
|
|
64
|
+
* @param auth - The request's auth data reference.
|
|
65
|
+
* @param buildFn - Optional builder to customize the context.
|
|
59
66
|
*/
|
|
60
67
|
makeModelContext(auth: AuthDataRef, buildFn?: BuildFunction<FirebaseAppModelContext<A>>): FirebaseAppModelContext<A>;
|
|
61
68
|
/**
|
|
62
|
-
* Creates
|
|
69
|
+
* Creates an {@link InContextFirebaseModelsService} bound to the given auth context,
|
|
70
|
+
* enabling scoped model selection and permission checking.
|
|
63
71
|
*
|
|
64
|
-
* @param context
|
|
65
|
-
* @param buildFn
|
|
66
|
-
* @returns
|
|
72
|
+
* @param context - The request's auth data reference.
|
|
73
|
+
* @param buildFn - Optional builder to customize the model context.
|
|
67
74
|
*/
|
|
68
75
|
model(context: AuthDataRef, buildFn?: BuildFunction<FirebaseAppModelContext<A>>): InContextFirebaseModelsService<Y>;
|
|
69
76
|
useModel<T extends FirebaseModelsServiceTypes<Y>, O>(type: T, select: UseModelInput<FirebaseAppModelContext<A>, Y, T, O>): Promise<O>;
|
|
70
77
|
useModel<T extends FirebaseModelsServiceTypes<Y>>(type: T, select: UseModelInputForRolesReader<FirebaseAppModelContext<A>, Y, T>): Promise<FirebaseModelsServiceSelectionResultRolesReader<Y, T>>;
|
|
71
78
|
}
|
|
79
|
+
/**
|
|
80
|
+
* Input for {@link AbstractFirebaseNestContext.useModel} when only a roles reader is needed (no custom use function).
|
|
81
|
+
*/
|
|
72
82
|
export type UseModelInputForRolesReader<C extends FirebaseModelServiceContext, Y extends FirebaseModelsService<any, C>, T extends FirebaseModelsServiceTypes<Y>> = Omit<UseFirebaseModelsServiceSelection<Y, T>, 'type' | 'context'> & {
|
|
73
83
|
readonly request: AuthDataRef;
|
|
74
84
|
readonly buildFn?: BuildFunction<C>;
|
|
75
85
|
};
|
|
86
|
+
/**
|
|
87
|
+
* Input for {@link AbstractFirebaseNestContext.useModel} with a custom use function that transforms the selection result.
|
|
88
|
+
*/
|
|
76
89
|
export type UseModelInput<C extends FirebaseModelServiceContext, Y extends FirebaseModelsService<any, C>, T extends FirebaseModelsServiceTypes<Y>, O> = UseModelInputForRolesReader<C, Y, T> & {
|
|
77
90
|
readonly use: UseFirebaseModelsServiceSelectionUseFunction<Y, T, O>;
|
|
78
91
|
};
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { type AbstractFirebaseNestContext } from './nest.provider';
|
|
2
|
+
/**
|
|
3
|
+
* Abstract class used for the top-level server NestJS context for server-only services.
|
|
4
|
+
*
|
|
5
|
+
* Your API implementation of this class is usually <AppPrefix>ApiServerNestContext (e.g. `DemoApiServerNestContext`).
|
|
6
|
+
*/
|
|
7
|
+
export declare abstract class AbstractServerFirebaseNestContext<C extends AbstractFirebaseNestContext<any, any>> {
|
|
8
|
+
private readonly _context;
|
|
9
|
+
constructor(c: C);
|
|
10
|
+
get context(): C;
|
|
11
|
+
get nest(): import("@nestjs/common").INestApplicationContext;
|
|
12
|
+
}
|
|
@@ -24,21 +24,47 @@ export declare class FirebaseServerStorageModule {
|
|
|
24
24
|
*/
|
|
25
25
|
export declare class FirebaseServerStorageContextModule {
|
|
26
26
|
}
|
|
27
|
+
/**
|
|
28
|
+
* Creates a NestJS provider that configures the default storage bucket ID.
|
|
29
|
+
*
|
|
30
|
+
* @param input - A bucket ID string or full factory config object.
|
|
31
|
+
* @throws Error if `defaultBucketId` is empty.
|
|
32
|
+
*
|
|
33
|
+
* @example
|
|
34
|
+
* ```typescript
|
|
35
|
+
* const provider = firebaseServerStorageDefaultBucketIdTokenProvider('my-bucket-name');
|
|
36
|
+
* ```
|
|
37
|
+
*/
|
|
27
38
|
export declare function firebaseServerStorageDefaultBucketIdTokenProvider(input: StorageBucketId | FirebaseStorageContextFactoryConfig): Provider;
|
|
39
|
+
/**
|
|
40
|
+
* Simplified provider config that receives only the {@link FirebaseStorageContext}.
|
|
41
|
+
*/
|
|
28
42
|
export type ProvideFirebaseServerStorageServiceSimple<T extends FirebaseServerStorageService> = Pick<FactoryProvider<T>, 'provide'> & {
|
|
29
43
|
useFactory: (context: FirebaseStorageContext) => T;
|
|
30
44
|
};
|
|
45
|
+
/**
|
|
46
|
+
* Returns the default provider config that creates a standard {@link FirebaseServerStorageService}.
|
|
47
|
+
*/
|
|
31
48
|
export declare function defaultProvideFirebaseServerStorageServiceSimple(): ProvideFirebaseServerStorageServiceSimple<FirebaseServerStorageService>;
|
|
32
49
|
export type ProvideFirebaseServerStorageService<T extends FirebaseServerStorageService> = FactoryProvider<T> | ProvideFirebaseServerStorageServiceSimple<T>;
|
|
50
|
+
/**
|
|
51
|
+
* Creates NestJS provider entries for a {@link FirebaseServerStorageService} implementation.
|
|
52
|
+
*
|
|
53
|
+
* If the provider token differs from `FirebaseServerStorageService`, an alias provider is added
|
|
54
|
+
* so the service can also be injected by the abstract type.
|
|
55
|
+
*/
|
|
33
56
|
export declare function provideFirebaseServerStorageService<T extends FirebaseServerStorageService = FirebaseServerStorageService>(provider: ProvideFirebaseServerStorageService<T>): Provider<T>[];
|
|
34
57
|
export interface FirebaseServerStorageModuleMetadataConfig<T extends FirebaseServerStorageService = FirebaseServerStorageService> extends AdditionalModuleMetadata {
|
|
35
58
|
readonly serviceProvider?: ProvideFirebaseServerStorageService<T>;
|
|
36
59
|
}
|
|
37
60
|
/**
|
|
38
|
-
*
|
|
61
|
+
* Generates NestJS {@link ModuleMetadata} for an app's storage module, including the
|
|
62
|
+
* {@link FirebaseServerStorageContextModule} import and the storage service provider.
|
|
39
63
|
*
|
|
40
|
-
* @
|
|
41
|
-
*
|
|
42
|
-
* @
|
|
64
|
+
* @example
|
|
65
|
+
* ```typescript
|
|
66
|
+
* @Module(firebaseServerStorageModuleMetadata())
|
|
67
|
+
* export class AppStorageModule {}
|
|
68
|
+
* ```
|
|
43
69
|
*/
|
|
44
70
|
export declare function firebaseServerStorageModuleMetadata<T extends FirebaseServerStorageService = FirebaseServerStorageService>(config?: FirebaseServerStorageModuleMetadataConfig<T>): ModuleMetadata;
|
|
@@ -1,11 +1,32 @@
|
|
|
1
1
|
import { type FirebaseStorageAccessorDriver, type FirebaseStorageAccessorFile, type FirebaseStorageAccessorFolder, type StoragePath, type StorageMetadata, type StorageBucketId } from '@dereekb/firebase';
|
|
2
2
|
import { type SlashPathFolder } from '@dereekb/util';
|
|
3
3
|
import { type GetFilesOptions, type Storage as GoogleCloudStorage, type File as GoogleCloudFile, type FileMetadata, type Bucket } from '@google-cloud/storage';
|
|
4
|
+
/**
|
|
5
|
+
* Resolves a Google Cloud Storage {@link Bucket} from a {@link StoragePath}.
|
|
6
|
+
*/
|
|
4
7
|
export declare function googleCloudStorageBucketForStorageFilePath(storage: GoogleCloudStorage, path: StoragePath): Bucket;
|
|
8
|
+
/**
|
|
9
|
+
* Resolves a Google Cloud Storage {@link GoogleCloudFile} from a {@link StoragePath}.
|
|
10
|
+
*/
|
|
5
11
|
export declare function googleCloudStorageFileForStorageFilePath(storage: GoogleCloudStorage, path: StoragePath): GoogleCloudFile;
|
|
12
|
+
/**
|
|
13
|
+
* Server-side file accessor type that guarantees stream operations are available.
|
|
14
|
+
*/
|
|
6
15
|
export type GoogleCloudStorageAccessorFile = FirebaseStorageAccessorFile<GoogleCloudFile> & Required<Pick<FirebaseStorageAccessorFile<GoogleCloudFile>, 'uploadStream' | 'getStream'>>;
|
|
16
|
+
/**
|
|
17
|
+
* Converts Google Cloud Storage {@link FileMetadata} into the normalized {@link StorageMetadata} format.
|
|
18
|
+
*/
|
|
7
19
|
export declare function googleCloudFileMetadataToStorageMetadata(file: GoogleCloudFile, metadata: FileMetadata): StorageMetadata;
|
|
20
|
+
/**
|
|
21
|
+
* Creates a {@link GoogleCloudStorageAccessorFile} providing CRUD, streaming, signed URL,
|
|
22
|
+
* and ACL operations for a single file in Google Cloud Storage.
|
|
23
|
+
*
|
|
24
|
+
* Handles emulator-specific edge cases (e.g., signing errors, atomic move fallback).
|
|
25
|
+
*/
|
|
8
26
|
export declare function googleCloudStorageAccessorFile(storage: GoogleCloudStorage, storagePath: StoragePath): GoogleCloudStorageAccessorFile;
|
|
27
|
+
/**
|
|
28
|
+
* Server-side folder accessor type for Google Cloud Storage.
|
|
29
|
+
*/
|
|
9
30
|
export type GoogleCloudStorageAccessorFolder = FirebaseStorageAccessorFolder<GoogleCloudFile>;
|
|
10
31
|
export interface GoogleCloudListResult {
|
|
11
32
|
readonly files: GoogleCloudFile[];
|
|
@@ -25,5 +46,17 @@ export interface GoogleCloudStorageListApiResponseItem extends Pick<StorageMetad
|
|
|
25
46
|
readonly bucket: StorageBucketId;
|
|
26
47
|
}
|
|
27
48
|
export declare const googleCloudStorageListFilesResultFactory: import("@dereekb/firebase").StorageListFilesResultFactory<GoogleCloudStorage, GoogleCloudListResult>;
|
|
49
|
+
/**
|
|
50
|
+
* Creates a {@link GoogleCloudStorageAccessorFolder} that supports checking folder existence
|
|
51
|
+
* and listing files/subfolders with pagination.
|
|
52
|
+
*/
|
|
28
53
|
export declare function googleCloudStorageAccessorFolder(storage: GoogleCloudStorage, storagePath: StoragePath): GoogleCloudStorageAccessorFolder;
|
|
54
|
+
/**
|
|
55
|
+
* Creates a {@link FirebaseStorageAccessorDriver} for Google Cloud Storage (Admin SDK).
|
|
56
|
+
*
|
|
57
|
+
* @example
|
|
58
|
+
* ```typescript
|
|
59
|
+
* const driver = googleCloudStorageFirebaseStorageAccessorDriver();
|
|
60
|
+
* ```
|
|
61
|
+
*/
|
|
29
62
|
export declare function googleCloudStorageFirebaseStorageAccessorDriver(): FirebaseStorageAccessorDriver;
|
|
@@ -1,3 +1,17 @@
|
|
|
1
1
|
import { type FirebaseStorageDrivers } from '@dereekb/firebase';
|
|
2
|
+
/**
|
|
3
|
+
* Alias for {@link FirebaseStorageDrivers} specific to the Google Cloud Storage (server) implementation.
|
|
4
|
+
*/
|
|
2
5
|
export type GoogleCloudFirebaseStorageDrivers = FirebaseStorageDrivers;
|
|
6
|
+
/**
|
|
7
|
+
* Creates a complete set of {@link FirebaseStorageDrivers} for Google Cloud Storage (Admin SDK).
|
|
8
|
+
*
|
|
9
|
+
* Bundles the server-side storage accessor driver, identified as `@google-cloud/storage`.
|
|
10
|
+
*
|
|
11
|
+
* @example
|
|
12
|
+
* ```typescript
|
|
13
|
+
* const drivers = googleCloudFirebaseStorageDrivers();
|
|
14
|
+
* const context = firebaseStorageContextFactory(drivers);
|
|
15
|
+
* ```
|
|
16
|
+
*/
|
|
3
17
|
export declare function googleCloudFirebaseStorageDrivers(): GoogleCloudFirebaseStorageDrivers;
|
|
@@ -2,13 +2,20 @@ import { type FirebaseStorageContextFactory } from '@dereekb/firebase';
|
|
|
2
2
|
import { type Storage as FirebaseAdminStorage } from 'firebase-admin/storage';
|
|
3
3
|
import { type Storage as GoogleCloudStorage } from '@google-cloud/storage';
|
|
4
4
|
/**
|
|
5
|
-
*
|
|
5
|
+
* Pre-configured {@link FirebaseStorageContextFactory} using the Google Cloud Storage (Admin SDK) drivers.
|
|
6
6
|
*/
|
|
7
7
|
export declare const googleCloudFirebaseStorageContextFactory: FirebaseStorageContextFactory;
|
|
8
8
|
/**
|
|
9
|
-
*
|
|
9
|
+
* Extracts the underlying {@link GoogleCloudStorage} client from a Firebase Admin {@link FirebaseAdminStorage} instance.
|
|
10
10
|
*
|
|
11
|
-
*
|
|
12
|
-
*
|
|
11
|
+
* This accesses an internal property (`storageClient`) to bridge between the Firebase Admin
|
|
12
|
+
* Storage wrapper and the raw Google Cloud Storage SDK.
|
|
13
|
+
*
|
|
14
|
+
* @param storage - The Firebase Admin Storage instance.
|
|
15
|
+
*
|
|
16
|
+
* @example
|
|
17
|
+
* ```typescript
|
|
18
|
+
* const gcs = googleCloudStorageFromFirebaseAdminStorage(admin.storage());
|
|
19
|
+
* ```
|
|
13
20
|
*/
|
|
14
21
|
export declare function googleCloudStorageFromFirebaseAdminStorage(storage: FirebaseAdminStorage): GoogleCloudStorage;
|
|
@@ -6,7 +6,16 @@ export interface FirebaseServerStorageServiceRef<S extends FirebaseServerStorage
|
|
|
6
6
|
readonly storageService: S;
|
|
7
7
|
}
|
|
8
8
|
/**
|
|
9
|
-
*
|
|
9
|
+
* Server-side storage service that wraps a {@link FirebaseStorageContext} and implements
|
|
10
|
+
* the {@link FirebaseStorageAccessor} interface for file and folder operations.
|
|
11
|
+
*
|
|
12
|
+
* Typically injected via NestJS and backed by the Google Cloud Storage driver.
|
|
13
|
+
*
|
|
14
|
+
* @example
|
|
15
|
+
* ```typescript
|
|
16
|
+
* const storageService = new FirebaseServerStorageService(storageContext);
|
|
17
|
+
* const file = storageService.file({ bucketId: 'my-bucket', pathString: 'path/to/file.txt' });
|
|
18
|
+
* ```
|
|
10
19
|
*/
|
|
11
20
|
export declare class FirebaseServerStorageService implements FirebaseStorageAccessor {
|
|
12
21
|
private readonly _storageContext;
|
package/src/lib/type.d.ts
CHANGED
|
@@ -1,9 +1,14 @@
|
|
|
1
1
|
import { type CallableRequest } from 'firebase-functions/v2/https';
|
|
2
2
|
/**
|
|
3
|
-
*
|
|
3
|
+
* The authenticated user's data from a Firebase v2 {@link CallableRequest}.
|
|
4
|
+
*
|
|
5
|
+
* Non-nullable — use this type when auth is guaranteed to be present.
|
|
4
6
|
*/
|
|
5
7
|
export type AuthData = NonNullable<CallableRequest['auth']>;
|
|
6
8
|
/**
|
|
7
|
-
*
|
|
9
|
+
* The request context from a Firebase v2 callable function, excluding the payload and streaming fields.
|
|
10
|
+
*
|
|
11
|
+
* Used throughout `@dereekb/firebase-server` as the standard callable context type
|
|
12
|
+
* passed to auth services and function handlers.
|
|
8
13
|
*/
|
|
9
14
|
export type CallableContext = Omit<CallableRequest<any>, 'data' | 'acceptsStreaming'>;
|