@dereekb/firebase-server 13.2.1 → 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
|
@@ -4,14 +4,46 @@ import { type TransformAndValidateFunctionResultFactory, type TransformAndValida
|
|
|
4
4
|
* Context used for building FirebaseServerActions. It contains references to reusable factories.
|
|
5
5
|
*/
|
|
6
6
|
export type FirebaseServerActionsContext = FirebaseServerActionsTransformContext;
|
|
7
|
+
/**
|
|
8
|
+
* Abstract base class for {@link FirebaseServerActionsContext} implementations.
|
|
9
|
+
*
|
|
10
|
+
* Subclass this when you need to provide the transform and validation factories
|
|
11
|
+
* from an injected source (e.g., a NestJS provider) rather than constructing them inline.
|
|
12
|
+
*/
|
|
7
13
|
export declare abstract class AbstractFirebaseServerActionsContext implements FirebaseServerActionsContext {
|
|
8
14
|
abstract readonly firebaseServerActionTransformFactory: TransformAndValidateObjectFactory;
|
|
9
15
|
abstract readonly firebaseServerActionTransformFunctionFactory: TransformAndValidateFunctionResultFactory<unknown>;
|
|
10
16
|
}
|
|
17
|
+
/**
|
|
18
|
+
* Options for creating a {@link FirebaseServerActionsContext}.
|
|
19
|
+
*/
|
|
11
20
|
export type FirebaseServerActionsContextOptions = FirebaseServerActionsTransformFactoryOptions;
|
|
21
|
+
/**
|
|
22
|
+
* Creates a {@link FirebaseServerActionsContext} with the default transform and validation factories.
|
|
23
|
+
*
|
|
24
|
+
* @example
|
|
25
|
+
* ```ts
|
|
26
|
+
* const context = firebaseServerActionsContext({ logError: true });
|
|
27
|
+
* ```
|
|
28
|
+
*
|
|
29
|
+
* @param options - Optional configuration for error logging behavior.
|
|
30
|
+
* @returns A fully configured actions context.
|
|
31
|
+
*/
|
|
12
32
|
export declare function firebaseServerActionsContext(options?: FirebaseServerActionsContextOptions): FirebaseServerActionsContext;
|
|
33
|
+
/**
|
|
34
|
+
* Callback invoked when a validation error occurs during request transformation.
|
|
35
|
+
* Receives the error details object for logging or telemetry purposes.
|
|
36
|
+
*/
|
|
13
37
|
export type FirebaseServerActionsTransformFactoryLogErrorFunction = (details: object) => void;
|
|
38
|
+
/**
|
|
39
|
+
* Configuration for validation error logging. Pass `true` to use the default console logger,
|
|
40
|
+
* `false` to suppress logging entirely, or a custom function for application-specific logging.
|
|
41
|
+
*/
|
|
14
42
|
export type FirebaseServerActionsTransformFactoryLogErrorFunctionInput = FirebaseServerActionsTransformFactoryLogErrorFunction | boolean;
|
|
43
|
+
/**
|
|
44
|
+
* Default error logger that writes validation error details to the console.
|
|
45
|
+
* Used when `logError` is `true` or omitted in the factory options.
|
|
46
|
+
*/
|
|
15
47
|
export declare const defaultFirebaseServerActionsTransformFactoryLogErrorFunction: FirebaseServerActionsTransformFactoryLogErrorFunction;
|
|
16
48
|
/**
|
|
17
49
|
* Context used for transforming content.
|
|
@@ -20,11 +52,31 @@ export interface FirebaseServerActionsTransformContext {
|
|
|
20
52
|
readonly firebaseServerActionTransformFactory: TransformAndValidateObjectFactory;
|
|
21
53
|
readonly firebaseServerActionTransformFunctionFactory: TransformAndValidateFunctionResultFactory;
|
|
22
54
|
}
|
|
55
|
+
/**
|
|
56
|
+
* Options for creating a {@link FirebaseServerActionsTransformContext}.
|
|
57
|
+
*/
|
|
23
58
|
export type FirebaseServerActionsTransformContextOptions = FirebaseServerActionsTransformFactoryOptions;
|
|
59
|
+
/**
|
|
60
|
+
* Creates a {@link FirebaseServerActionsTransformContext} with both the object transform factory
|
|
61
|
+
* and the function result transform factory configured from the same options.
|
|
62
|
+
*
|
|
63
|
+
* @param options - Optional configuration for error logging behavior.
|
|
64
|
+
* @returns A transform context with both factory types ready to use.
|
|
65
|
+
*/
|
|
24
66
|
export declare function firebaseServerActionsTransformContext(options?: FirebaseServerActionsTransformContextOptions): FirebaseServerActionsTransformContext;
|
|
67
|
+
/**
|
|
68
|
+
* Error code used in server error responses for ArkType validation failures.
|
|
69
|
+
* Clients can check for this code to distinguish validation errors from other bad-request errors.
|
|
70
|
+
*/
|
|
25
71
|
export declare const FIREBASE_SERVER_VALIDATION_ERROR_CODE = "VALIDATION_ERROR";
|
|
26
72
|
/**
|
|
27
|
-
* Creates a server error object from ArkType validation errors.
|
|
73
|
+
* Creates a structured server error object from ArkType validation errors.
|
|
74
|
+
*
|
|
75
|
+
* The returned object is suitable for embedding in HTTP error responses. Use {@link firebaseServerValidationError}
|
|
76
|
+
* instead if you need a throwable `HttpsError`.
|
|
77
|
+
*
|
|
78
|
+
* @param validationErrors - The ArkType validation errors to convert.
|
|
79
|
+
* @returns A plain object with a message, error code, and validation summary.
|
|
28
80
|
*/
|
|
29
81
|
export declare function firebaseServerValidationServerError(validationErrors: ArkErrors): {
|
|
30
82
|
message: string;
|
|
@@ -34,10 +86,41 @@ export declare function firebaseServerValidationServerError(validationErrors: Ar
|
|
|
34
86
|
};
|
|
35
87
|
};
|
|
36
88
|
/**
|
|
37
|
-
* Creates a
|
|
89
|
+
* Creates a throwable `badRequestError` wrapping ArkType validation errors.
|
|
90
|
+
*
|
|
91
|
+
* This is the preferred way to reject requests with invalid input data in Firebase server actions.
|
|
92
|
+
*
|
|
93
|
+
* @param validationErrors - The ArkType validation errors to wrap.
|
|
94
|
+
* @returns A throwable error suitable for Firebase callable function responses.
|
|
38
95
|
*/
|
|
39
96
|
export declare function firebaseServerValidationError(validationErrors: ArkErrors): import("firebase-functions/https").HttpsError;
|
|
97
|
+
/**
|
|
98
|
+
* Options for configuring the transform and validation factory used by Firebase server actions.
|
|
99
|
+
*/
|
|
40
100
|
export interface FirebaseServerActionsTransformFactoryOptions {
|
|
101
|
+
/**
|
|
102
|
+
* Controls whether and how validation errors are logged.
|
|
103
|
+
*
|
|
104
|
+
* - `true` or omitted: uses the default console logger.
|
|
105
|
+
* - `false`: suppresses all validation error logging.
|
|
106
|
+
* - A function: uses the provided function for custom logging.
|
|
107
|
+
*/
|
|
41
108
|
readonly logError?: FirebaseServerActionsTransformFactoryLogErrorFunctionInput;
|
|
42
109
|
}
|
|
110
|
+
/**
|
|
111
|
+
* Creates a {@link TransformAndValidateObjectFactory} that validates incoming data using ArkType
|
|
112
|
+
* and throws a `badRequestError` on validation failure.
|
|
113
|
+
*
|
|
114
|
+
* Validation errors are optionally logged before the error is thrown, controlled by the `logError` option.
|
|
115
|
+
*
|
|
116
|
+
* @example
|
|
117
|
+
* ```ts
|
|
118
|
+
* const transformFactory = firebaseServerActionsTransformFactory({ logError: true });
|
|
119
|
+
* const transform = transformFactory(myArkTypeSchema);
|
|
120
|
+
* const validated = await transform(rawInput);
|
|
121
|
+
* ```
|
|
122
|
+
*
|
|
123
|
+
* @param options - Optional configuration for error logging behavior.
|
|
124
|
+
* @returns A factory that creates type-safe transform functions from ArkType schemas.
|
|
125
|
+
*/
|
|
43
126
|
export declare function firebaseServerActionsTransformFactory(options?: FirebaseServerActionsTransformFactoryOptions): TransformAndValidateObjectFactory;
|
|
@@ -2,17 +2,63 @@ import { type INestApplicationContext } from '@nestjs/common';
|
|
|
2
2
|
import { type CallableRequest } from 'firebase-functions/v2/https';
|
|
3
3
|
import { type CallableContextWithAuthData } from '../../function/context';
|
|
4
4
|
import { type OnCallWithNestContextRequest } from './call';
|
|
5
|
+
/**
|
|
6
|
+
* Augments a request type with a reference to the raw {@link INestApplicationContext}.
|
|
7
|
+
*
|
|
8
|
+
* This is the lowest-level nest integration type -- most handlers should prefer {@link NestContextRequest}
|
|
9
|
+
* which provides a typed, domain-specific context instead of the raw application context.
|
|
10
|
+
*
|
|
11
|
+
* @typeParam R - The base request type to augment.
|
|
12
|
+
*/
|
|
5
13
|
export type NestApplicationContextRequest<R> = R & {
|
|
6
14
|
readonly nestApplication: INestApplicationContext;
|
|
7
15
|
};
|
|
16
|
+
/**
|
|
17
|
+
* Simple reference wrapper holding a typed nest context object.
|
|
18
|
+
*
|
|
19
|
+
* @typeParam N - The nest context type.
|
|
20
|
+
*/
|
|
8
21
|
export type NestRef<N> = {
|
|
9
22
|
readonly nest: N;
|
|
10
23
|
};
|
|
24
|
+
/**
|
|
25
|
+
* Augments a request type with a typed nest context. This is the primary request shape used by
|
|
26
|
+
* nest-integrated Firebase function handlers throughout the codebase.
|
|
27
|
+
*
|
|
28
|
+
* @typeParam N - The nest context type, typically an application-specific context class.
|
|
29
|
+
* @typeParam R - The base request type to augment.
|
|
30
|
+
*/
|
|
11
31
|
export type NestContextRequest<N, R> = R & {
|
|
12
32
|
readonly nest: N;
|
|
13
33
|
};
|
|
34
|
+
/**
|
|
35
|
+
* Creates a new request object with the typed nest context spread into it.
|
|
36
|
+
*
|
|
37
|
+
* Unlike {@link injectNestApplicationContextIntoRequest}, this attaches a domain-specific context rather
|
|
38
|
+
* than the raw NestJS application context.
|
|
39
|
+
*
|
|
40
|
+
* @param nest - The typed nest context to attach.
|
|
41
|
+
* @param request - The base request to augment.
|
|
42
|
+
* @returns A new object combining the request properties with the nest context.
|
|
43
|
+
*/
|
|
14
44
|
export declare function injectNestIntoRequest<N, R>(nest: N, request: R): NestContextRequest<N, R>;
|
|
45
|
+
/**
|
|
46
|
+
* Creates a new request object with the raw {@link INestApplicationContext} spread into it.
|
|
47
|
+
*
|
|
48
|
+
* This is typically used at the outermost layer of function wiring before a {@link MakeNestContext}
|
|
49
|
+
* factory converts it into a typed context via {@link injectNestIntoRequest}.
|
|
50
|
+
*
|
|
51
|
+
* @param nestContext - The NestJS application context to attach.
|
|
52
|
+
* @param request - The base request to augment.
|
|
53
|
+
* @returns A new object combining the request properties with the application context.
|
|
54
|
+
*/
|
|
15
55
|
export declare function injectNestApplicationContextIntoRequest<R>(nestContext: INestApplicationContext, request: R): NestApplicationContextRequest<R>;
|
|
56
|
+
/**
|
|
57
|
+
* A Firebase v2 {@link CallableRequest} augmented with a typed nest context.
|
|
58
|
+
*
|
|
59
|
+
* @typeParam N - The nest context type.
|
|
60
|
+
* @typeParam I - The callable request input data type.
|
|
61
|
+
*/
|
|
16
62
|
export type NestContextCallableRequest<N, I> = NestContextRequest<N, CallableRequest<I>>;
|
|
17
63
|
/**
|
|
18
64
|
* Equivalent to OnCallWithNestContextRequest
|
|
@@ -1,6 +1,12 @@
|
|
|
1
1
|
import { type Minutes, type PromiseOrValue } from '@dereekb/util';
|
|
2
2
|
import { type MakeNestContext, type NestApplicationFunctionFactory } from '../nest.provider';
|
|
3
3
|
import { type NestApplicationContextRequest, type NestContextRequest } from './nest';
|
|
4
|
+
/**
|
|
5
|
+
* Configuration for scheduled Firebase functions, supporting both cron expressions and human-readable schedules.
|
|
6
|
+
*
|
|
7
|
+
* At least one of `cron` or `schedule` must be provided. If `cron` is a number, it is interpreted as
|
|
8
|
+
* a repeating interval in minutes and converted to a cron expression automatically.
|
|
9
|
+
*/
|
|
4
10
|
export interface OnScheduleConfig {
|
|
5
11
|
/**
|
|
6
12
|
* Scheduled time in a cron-tab format.
|
|
@@ -39,23 +45,66 @@ export interface OnScheduleConfig {
|
|
|
39
45
|
*/
|
|
40
46
|
readonly maxDoublings?: number;
|
|
41
47
|
}
|
|
48
|
+
/**
|
|
49
|
+
* Request object passed to scheduled function handlers, containing the platform-specific schedule event context.
|
|
50
|
+
*
|
|
51
|
+
* @typeParam S - The schedule event type (e.g., `scheduler.ScheduledEvent` for v2).
|
|
52
|
+
*/
|
|
42
53
|
export interface OnScheduleRequest<S> {
|
|
43
54
|
readonly scheduleContext?: S;
|
|
44
55
|
}
|
|
56
|
+
/**
|
|
57
|
+
* Request type for scheduled functions that receive the raw {@link INestApplicationContext}.
|
|
58
|
+
*
|
|
59
|
+
* @typeParam S - The schedule event type.
|
|
60
|
+
*/
|
|
45
61
|
export type OnScheduleWithNestApplicationRequest<S = unknown> = NestApplicationContextRequest<OnScheduleRequest<S>>;
|
|
46
62
|
/**
|
|
47
63
|
* Scheduled function that is passed an INestApplicationContext in addition to the OnScheduleRequest object.
|
|
48
64
|
*/
|
|
49
65
|
export type OnScheduleWithNestApplication<S = unknown> = (request: OnScheduleWithNestApplicationRequest<S>) => PromiseOrValue<void>;
|
|
66
|
+
/**
|
|
67
|
+
* Request type for scheduled functions that receive a typed nest context.
|
|
68
|
+
*
|
|
69
|
+
* @typeParam N - The nest context type.
|
|
70
|
+
* @typeParam S - The schedule event type.
|
|
71
|
+
*/
|
|
50
72
|
export type OnScheduleWithNestContextRequest<N, S = unknown> = NestContextRequest<N, OnScheduleRequest<S>>;
|
|
51
73
|
/**
|
|
52
74
|
* Scheduled function that is passed an arbitrary nest context object in addition to the OnScheduleRequest object.
|
|
53
75
|
*/
|
|
54
76
|
export type OnScheduleWithNestContext<N, S = unknown> = (request: OnScheduleWithNestContextRequest<N, S>) => PromiseOrValue<void>;
|
|
77
|
+
/**
|
|
78
|
+
* Mutates the application-level schedule request to attach a typed nest context.
|
|
79
|
+
*
|
|
80
|
+
* This is the schedule-function equivalent of {@link setNestContextOnRequest} for callable functions.
|
|
81
|
+
*
|
|
82
|
+
* @param makeNestContext - Factory that creates the typed context from the application context.
|
|
83
|
+
* @param request - The application-level schedule request to augment.
|
|
84
|
+
* @returns The same request object, now typed with the nest context attached.
|
|
85
|
+
*/
|
|
55
86
|
export declare function setNestContextOnScheduleRequest<N, S>(makeNestContext: MakeNestContext<N>, request: OnScheduleWithNestApplicationRequest<S>): OnScheduleWithNestContextRequest<N, S>;
|
|
87
|
+
/**
|
|
88
|
+
* A scheduled Firebase function augmented with metadata for testing and introspection.
|
|
89
|
+
*
|
|
90
|
+
* The `_runNow` method allows triggering the scheduled function outside of its cron schedule,
|
|
91
|
+
* which is useful for testing or manual invocation. The `_schedule` field exposes the resolved
|
|
92
|
+
* schedule configuration.
|
|
93
|
+
*
|
|
94
|
+
* @typeParam F - The base Firebase function type (e.g., `scheduler.ScheduleFunction`).
|
|
95
|
+
*/
|
|
56
96
|
export type NestApplicationScheduleConfiguredFunction<F extends object = object> = F & {
|
|
57
97
|
_runNow(): PromiseOrValue<void>;
|
|
58
98
|
readonly _schedule: OnScheduleConfig;
|
|
59
99
|
};
|
|
100
|
+
/**
|
|
101
|
+
* Factory that creates a {@link NestApplicationScheduleConfiguredFunction} from a {@link NestApplicationPromiseGetter}.
|
|
102
|
+
*
|
|
103
|
+
* @typeParam F - The base Firebase function type.
|
|
104
|
+
*/
|
|
60
105
|
export type NestApplicationScheduleConfiguredFunctionFactory<F extends object = object> = NestApplicationFunctionFactory<NestApplicationScheduleConfiguredFunction<F>>;
|
|
106
|
+
/**
|
|
107
|
+
* A map of named scheduled functions, keyed by function name. Useful for registering
|
|
108
|
+
* multiple scheduled functions as a group (e.g., in a module's function map).
|
|
109
|
+
*/
|
|
61
110
|
export type NestApplicationScheduleConfiguredFunctionMap = Record<string, NestApplicationScheduleConfiguredFunction>;
|
|
@@ -3,9 +3,32 @@ import { type MakeNestContext, type NestApplicationFunctionFactory } from '../..
|
|
|
3
3
|
import { type NestContextRequest } from '../nest';
|
|
4
4
|
import { type BlockingFunction } from 'firebase-functions/v1';
|
|
5
5
|
import { type BlockingOptions, type beforeUserCreated } from 'firebase-functions/identity';
|
|
6
|
+
/**
|
|
7
|
+
* The response type returned by a `beforeUserCreated` blocking function handler.
|
|
8
|
+
*
|
|
9
|
+
* Derived from the Firebase SDK's `beforeUserCreated` handler signature to stay in sync
|
|
10
|
+
* with upstream type changes.
|
|
11
|
+
*/
|
|
6
12
|
export type BeforeCreateResponse = MaybeSo<Awaited<ReturnType<Parameters<typeof beforeUserCreated>[1]>>>;
|
|
13
|
+
/**
|
|
14
|
+
* Request type for blocking function handlers that include a typed nest context alongside the blocking event.
|
|
15
|
+
*
|
|
16
|
+
* @typeParam N - The nest context type.
|
|
17
|
+
* @typeParam E - The blocking event type (e.g., `AuthBlockingEvent`).
|
|
18
|
+
*/
|
|
7
19
|
export type BlockingFunctionNestContextRequest<N, E extends object> = NestContextRequest<N, E>;
|
|
20
|
+
/**
|
|
21
|
+
* A raw blocking function handler that receives the Firebase event and optionally returns a response
|
|
22
|
+
* to modify the authentication flow (e.g., setting custom claims or blocking sign-in).
|
|
23
|
+
*
|
|
24
|
+
* @typeParam E - The blocking event type.
|
|
25
|
+
* @typeParam O - The optional return type that can modify the auth flow.
|
|
26
|
+
*/
|
|
8
27
|
export type BlockingFunctionHandler<E extends object, O> = (event: E) => PromiseOrValue<O | void>;
|
|
28
|
+
/**
|
|
29
|
+
* Ref that holds a reference to the underlying {@link BlockingFunctionHandler}, enabling
|
|
30
|
+
* direct invocation in tests without going through the Firebase trigger machinery.
|
|
31
|
+
*/
|
|
9
32
|
export type BlockingFunctionHandlerRef<E extends object, O> = {
|
|
10
33
|
__handler: BlockingFunctionHandler<E, O>;
|
|
11
34
|
};
|
|
@@ -13,22 +36,69 @@ export type BlockingFunctionHandlerRef<E extends object, O> = {
|
|
|
13
36
|
* BlockingFunction extension that also contains the handler and typing info.
|
|
14
37
|
*/
|
|
15
38
|
export type BlockingFunctionWithHandler<E extends object, O> = BlockingFunction & BlockingFunctionHandlerRef<E, O>;
|
|
39
|
+
/**
|
|
40
|
+
* A {@link BlockingFunction} that may or may not have a handler ref attached. Used as the return type
|
|
41
|
+
* of builder functions where the handler attachment is optional.
|
|
42
|
+
*/
|
|
16
43
|
export type BlockingFunctionMaybeWithHandler<E extends object, O> = BlockingFunction & Partial<BlockingFunctionHandlerRef<E, O>>;
|
|
44
|
+
/**
|
|
45
|
+
* Abstraction over Firebase blocking function constructors (e.g., `beforeUserCreated`, `beforeUserSignedIn`).
|
|
46
|
+
*
|
|
47
|
+
* Supports both the options-less and options-with overloads, allowing the same builder pattern
|
|
48
|
+
* to work with any blocking function type.
|
|
49
|
+
*
|
|
50
|
+
* @typeParam E - The blocking event type.
|
|
51
|
+
* @typeParam O - The optional return type.
|
|
52
|
+
*/
|
|
17
53
|
export interface BlockingFunctionBuilder<E extends object, O> {
|
|
18
54
|
(handler: (event: E) => PromiseOrValue<O | void>): BlockingFunction;
|
|
19
55
|
(opts: BlockingOptions, handler: (event: E) => PromiseOrValue<O | void>): BlockingFunction;
|
|
20
56
|
}
|
|
21
57
|
/**
|
|
22
|
-
* Creates a BlockingFunctionWithHandler
|
|
58
|
+
* Creates a {@link BlockingFunctionWithHandler} by invoking the builder and attaching the handler ref.
|
|
59
|
+
*
|
|
60
|
+
* The attached `__handler` enables direct handler invocation in tests without triggering
|
|
61
|
+
* the full Firebase blocking function infrastructure.
|
|
62
|
+
*
|
|
63
|
+
* @example
|
|
64
|
+
* ```ts
|
|
65
|
+
* const fn = makeBlockingFunctionWithHandler(
|
|
66
|
+
* beforeUserCreated,
|
|
67
|
+
* (event) => ({ displayName: event.data.email?.split('@')[0] }),
|
|
68
|
+
* { accessToken: true }
|
|
69
|
+
* );
|
|
70
|
+
* // In tests: fn.__handler(mockEvent)
|
|
71
|
+
* ```
|
|
23
72
|
*
|
|
24
|
-
* @param blockingFunctionBuilder
|
|
25
|
-
* @param handler
|
|
26
|
-
* @
|
|
73
|
+
* @param blockingFunctionBuilder - The Firebase blocking function constructor (e.g., `beforeUserCreated`).
|
|
74
|
+
* @param handler - The handler logic to execute on each event.
|
|
75
|
+
* @param opts - Optional {@link BlockingOptions} passed to the builder.
|
|
76
|
+
* @returns A {@link BlockingFunctionWithHandler} with the handler accessible via `__handler`.
|
|
27
77
|
*/
|
|
28
78
|
export declare function makeBlockingFunctionWithHandler<E extends object, O>(blockingFunctionBuilder: BlockingFunctionBuilder<E, O>, handler: BlockingFunctionHandler<E, O>, opts?: Maybe<BlockingOptions>): BlockingFunctionWithHandler<E, O>;
|
|
79
|
+
/**
|
|
80
|
+
* A blocking function handler that receives the event augmented with a typed nest context.
|
|
81
|
+
*
|
|
82
|
+
* @typeParam N - The nest context type.
|
|
83
|
+
* @typeParam E - The blocking event type.
|
|
84
|
+
* @typeParam O - The optional return type.
|
|
85
|
+
*/
|
|
29
86
|
export type NestContextBlockingFunctionHandler<N, E extends object, O> = (request: BlockingFunctionNestContextRequest<N, E>) => PromiseOrValue<O | void>;
|
|
87
|
+
/**
|
|
88
|
+
* Builder that wraps a {@link NestContextBlockingFunctionHandler} into a raw {@link BlockingFunctionHandler}
|
|
89
|
+
* by injecting the nest context into each event before delegation.
|
|
90
|
+
*/
|
|
30
91
|
export type NestContextBlockingFunctionHandlerBuilder<N, E extends object, O> = (handler: NestContextBlockingFunctionHandler<N, E, O>) => BlockingFunctionHandler<E, O>;
|
|
92
|
+
/**
|
|
93
|
+
* Builder function that receives a {@link NestContextBlockingFunctionHandlerBuilder} and uses it
|
|
94
|
+
* to construct a complete {@link BlockingFunctionMaybeWithHandler}, typically by calling
|
|
95
|
+
* {@link makeBlockingFunctionWithHandler} internally.
|
|
96
|
+
*/
|
|
31
97
|
export type BlockingFunctionHandlerWithNestContextBuilder<N, E extends object, O> = (nest: NestContextBlockingFunctionHandlerBuilder<N, E, O>) => BlockingFunctionMaybeWithHandler<E, O>;
|
|
98
|
+
/**
|
|
99
|
+
* Utility type that infers the correct {@link BlockingFunctionHandlerWithNestContextBuilder} type
|
|
100
|
+
* from a given {@link BlockingFunctionBuilder}, preserving the event and output type parameters.
|
|
101
|
+
*/
|
|
32
102
|
export type BlockingFunctionHandlerWithNestContextBuilderForBuilder<N, B extends BlockingFunctionBuilder<any, any>> = B extends BlockingFunctionBuilder<infer E, infer O> ? BlockingFunctionHandlerWithNestContextBuilder<N, E, O> : never;
|
|
33
103
|
/**
|
|
34
104
|
* Factory produced by BlockingFunctionHandlerWithNestContextFactory.
|
|
@@ -39,10 +109,24 @@ export type NestApplicationBlockingFunctionFactory<E extends object, O> = NestAp
|
|
|
39
109
|
*/
|
|
40
110
|
export type BlockingFunctionHandlerWithNestContextFactory<N> = <E extends object, O>(fn: BlockingFunctionHandlerWithNestContextBuilder<N, E, O>) => NestApplicationBlockingFunctionFactory<E, O>;
|
|
41
111
|
/**
|
|
42
|
-
* Creates a BlockingFunctionHandlerWithNestContextFactory
|
|
112
|
+
* Creates a {@link BlockingFunctionHandlerWithNestContextFactory} that wires up the NestJS application
|
|
113
|
+
* context injection for blocking functions (e.g., `beforeUserCreated`, `beforeUserSignedIn`).
|
|
114
|
+
*
|
|
115
|
+
* The returned factory lazily resolves the NestJS application on each invocation, injects the
|
|
116
|
+
* typed context into the event, and delegates to the handler.
|
|
117
|
+
*
|
|
118
|
+
* @example
|
|
119
|
+
* ```ts
|
|
120
|
+
* const factory = blockingFunctionHandlerWithNestContextFactory(makeMyContext);
|
|
121
|
+
* const beforeCreate = factory<AuthBlockingEvent, BeforeCreateResponse>((nestHandler) =>
|
|
122
|
+
* makeBlockingFunctionWithHandler(beforeUserCreated, nestHandler((request) => {
|
|
123
|
+
* // request.nest is the typed context
|
|
124
|
+
* return { displayName: 'new-user' };
|
|
125
|
+
* }))
|
|
126
|
+
* );
|
|
127
|
+
* ```
|
|
43
128
|
*
|
|
44
|
-
* @param
|
|
45
|
-
* @
|
|
46
|
-
* @returns
|
|
129
|
+
* @param makeNestContext - Factory that creates the typed context from the NestJS application context.
|
|
130
|
+
* @returns A factory for creating nest-context-aware blocking function handlers.
|
|
47
131
|
*/
|
|
48
132
|
export declare function blockingFunctionHandlerWithNestContextFactory<N>(makeNestContext: MakeNestContext<N>): BlockingFunctionHandlerWithNestContextFactory<N>;
|
|
@@ -3,7 +3,10 @@ import { type CallableHttpFunction } from '../../../function/type';
|
|
|
3
3
|
import { type MakeNestContext, type NestApplicationFunctionFactory } from '../../nest.provider';
|
|
4
4
|
import { type OnCallWithNestApplication, type OnCallWithNestContext } from '../call';
|
|
5
5
|
/**
|
|
6
|
-
* A NestApplicationFunctionFactory
|
|
6
|
+
* A {@link NestApplicationFunctionFactory} that produces a typed {@link CallableHttpFunction}.
|
|
7
|
+
*
|
|
8
|
+
* @typeParam I - The expected input data type for the callable request.
|
|
9
|
+
* @typeParam O - The return type of the callable function.
|
|
7
10
|
*/
|
|
8
11
|
export type NestApplicationCallableHttpFunctionFactory<I = unknown, O = unknown> = NestApplicationFunctionFactory<CallableHttpFunction<I, O>>;
|
|
9
12
|
/**
|
|
@@ -11,10 +14,23 @@ export type NestApplicationCallableHttpFunctionFactory<I = unknown, O = unknown>
|
|
|
11
14
|
*/
|
|
12
15
|
export type OnCallHandlerWithNestApplicationFactory = <I = unknown, O = unknown>(fn: OnCallWithNestApplication<I, O>, opts?: https.CallableOptions<I>) => NestApplicationCallableHttpFunctionFactory<I, O>;
|
|
13
16
|
/**
|
|
14
|
-
* Creates
|
|
17
|
+
* Creates an {@link OnCallHandlerWithNestApplicationFactory} that registers Firebase v2 callable functions
|
|
18
|
+
* with automatic NestJS application context injection.
|
|
19
|
+
*
|
|
20
|
+
* The `defaultOpts` are merged with per-function options, allowing shared configuration (e.g., CORS settings,
|
|
21
|
+
* memory allocation) to be set once at the factory level.
|
|
22
|
+
*
|
|
23
|
+
* @example
|
|
24
|
+
* ```ts
|
|
25
|
+
* const callFactory = onCallHandlerWithNestApplicationFactory({ cors: true });
|
|
26
|
+
* const myFunction = callFactory<InputType, OutputType>(
|
|
27
|
+
* (request) => request.nestApplication.get(MyService).handle(request.data),
|
|
28
|
+
* { memory: '256MiB' }
|
|
29
|
+
* );
|
|
30
|
+
* ```
|
|
15
31
|
*
|
|
16
|
-
* @param
|
|
17
|
-
* @returns
|
|
32
|
+
* @param defaultOpts - Default {@link https.CallableOptions} applied to all functions created by this factory.
|
|
33
|
+
* @returns A factory that creates nest-application-aware callable functions.
|
|
18
34
|
*/
|
|
19
35
|
export declare function onCallHandlerWithNestApplicationFactory(defaultOpts?: https.CallableOptions): OnCallHandlerWithNestApplicationFactory;
|
|
20
36
|
/**
|
|
@@ -22,10 +38,24 @@ export declare function onCallHandlerWithNestApplicationFactory(defaultOpts?: ht
|
|
|
22
38
|
*/
|
|
23
39
|
export type OnCallHandlerWithNestContextFactory<C> = <I = unknown, O = unknown>(fn: OnCallWithNestContext<C, I, O>, opts?: https.CallableOptions<I>) => NestApplicationCallableHttpFunctionFactory<I, O>;
|
|
24
40
|
/**
|
|
25
|
-
* Creates
|
|
41
|
+
* Creates an {@link OnCallHandlerWithNestContextFactory} that builds on an existing
|
|
42
|
+
* {@link OnCallHandlerWithNestApplicationFactory} by additionally injecting a typed nest context.
|
|
43
|
+
*
|
|
44
|
+
* This is the standard way to create callable functions that receive a domain-specific context
|
|
45
|
+
* (e.g., `MyApiNestContext`) rather than the raw NestJS application context.
|
|
46
|
+
*
|
|
47
|
+
* @example
|
|
48
|
+
* ```ts
|
|
49
|
+
* const appFactory = onCallHandlerWithNestApplicationFactory();
|
|
50
|
+
* const contextFactory = onCallHandlerWithNestContextFactory(appFactory, makeMyContext);
|
|
51
|
+
* const myFunction = contextFactory<InputType, OutputType>((request) => {
|
|
52
|
+
* // request.nest is MyApiNestContext
|
|
53
|
+
* return request.nest.someService.handle(request.data);
|
|
54
|
+
* });
|
|
55
|
+
* ```
|
|
26
56
|
*
|
|
27
|
-
* @param appFactory
|
|
28
|
-
* @param makeNestContext
|
|
29
|
-
* @returns
|
|
57
|
+
* @param appFactory - The base application-level callable factory.
|
|
58
|
+
* @param makeNestContext - Factory that creates the typed context from the application context.
|
|
59
|
+
* @returns A factory that creates typed-context-aware callable functions.
|
|
30
60
|
*/
|
|
31
61
|
export declare function onCallHandlerWithNestContextFactory<C>(appFactory: OnCallHandlerWithNestApplicationFactory, makeNestContext: MakeNestContext<C>): OnCallHandlerWithNestContextFactory<C>;
|
|
@@ -2,15 +2,63 @@ import { type PromiseOrValue } from '@dereekb/util';
|
|
|
2
2
|
import { type CloudEvent, type CloudFunction } from 'firebase-functions/v2';
|
|
3
3
|
import { type MakeNestContext, type NestApplicationFunctionFactory } from '../../nest.provider';
|
|
4
4
|
import { type NestContextRequest } from '../nest';
|
|
5
|
+
/**
|
|
6
|
+
* Request type for cloud event handlers that include a typed nest context alongside the cloud event.
|
|
7
|
+
*
|
|
8
|
+
* @typeParam N - The nest context type.
|
|
9
|
+
* @typeParam E - The specific {@link CloudEvent} subtype.
|
|
10
|
+
*/
|
|
5
11
|
export type CloudEventNestContextRequest<N, E extends CloudEvent<any>> = NestContextRequest<N, E>;
|
|
12
|
+
/**
|
|
13
|
+
* A raw handler for a Firebase v2 {@link CloudEvent}.
|
|
14
|
+
*
|
|
15
|
+
* @typeParam E - The specific cloud event subtype.
|
|
16
|
+
* @typeParam O - The return type (typically `void` for event handlers).
|
|
17
|
+
*/
|
|
6
18
|
export type CloudEventHandler<E extends CloudEvent<any>, O = unknown> = (event: E) => PromiseOrValue<O>;
|
|
19
|
+
/**
|
|
20
|
+
* Abstraction over Firebase v2 cloud event function constructors (e.g., `onDocumentWritten`, `onObjectFinalized`).
|
|
21
|
+
*
|
|
22
|
+
* This enables the same factory pattern to work with any event-triggered function type.
|
|
23
|
+
*
|
|
24
|
+
* @typeParam E - The specific cloud event subtype.
|
|
25
|
+
* @typeParam O - The return type.
|
|
26
|
+
*/
|
|
7
27
|
export interface CloudFunctionBuilder<E extends CloudEvent<any>, O = unknown> {
|
|
8
28
|
(handler: (event: E) => PromiseOrValue<O>): CloudFunction<E>;
|
|
9
29
|
}
|
|
30
|
+
/**
|
|
31
|
+
* A cloud event handler that receives the event augmented with a typed nest context.
|
|
32
|
+
*
|
|
33
|
+
* @typeParam N - The nest context type.
|
|
34
|
+
* @typeParam E - The specific cloud event subtype.
|
|
35
|
+
* @typeParam O - The return type.
|
|
36
|
+
*/
|
|
10
37
|
export type NestContextCloudEventHandler<N, E extends CloudEvent<any>, O = unknown> = (request: CloudEventNestContextRequest<N, E>) => PromiseOrValue<O>;
|
|
38
|
+
/**
|
|
39
|
+
* Builder that wraps a {@link NestContextCloudEventHandler} into a raw {@link CloudEventHandler}
|
|
40
|
+
* by injecting the nest context into each event before delegation.
|
|
41
|
+
*/
|
|
11
42
|
export type NestContextCloudEventHandlerBuilder<N, E extends CloudEvent<any>, O = unknown> = (handler: NestContextCloudEventHandler<N, E, O>) => CloudEventHandler<E, O>;
|
|
43
|
+
/**
|
|
44
|
+
* Convenience alias for a {@link NestContextCloudEventHandler} where the event data type is specified
|
|
45
|
+
* directly rather than as a full {@link CloudEvent} subtype.
|
|
46
|
+
*
|
|
47
|
+
* @typeParam N - The nest context type.
|
|
48
|
+
* @typeParam I - The cloud event data type.
|
|
49
|
+
* @typeParam O - The return type.
|
|
50
|
+
*/
|
|
12
51
|
export type NestContextCloudEventHandlerWithData<N, I, O = unknown> = NestContextCloudEventHandler<N, CloudEvent<I>, O>;
|
|
52
|
+
/**
|
|
53
|
+
* Builder function that receives a {@link NestContextCloudEventHandlerBuilder} and uses it
|
|
54
|
+
* to construct a complete {@link CloudFunction}, typically by calling the Firebase event
|
|
55
|
+
* function constructor (e.g., `onDocumentWritten`) with the wrapped handler.
|
|
56
|
+
*/
|
|
13
57
|
export type CloudEventHandlerWithNestContextBuilder<N, E extends CloudEvent<any>, O = unknown> = (nest: NestContextCloudEventHandlerBuilder<N, E, O>) => CloudFunction<E>;
|
|
58
|
+
/**
|
|
59
|
+
* Utility type that infers the correct {@link CloudEventHandlerWithNestContextBuilder} type
|
|
60
|
+
* from a given {@link CloudFunctionBuilder}, preserving the event and output type parameters.
|
|
61
|
+
*/
|
|
14
62
|
export type CloudEventHandlerWithNestContextBuilderForBuilder<N, B extends CloudFunctionBuilder<any, any>> = B extends CloudFunctionBuilder<infer E, infer O> ? CloudEventHandlerWithNestContextBuilder<N, E, O> : never;
|
|
15
63
|
/**
|
|
16
64
|
* Factory produced by CloudEventHandlerWithNestContextFactory.
|
|
@@ -21,10 +69,25 @@ export type NestApplicationCloudEventFunctionFactory<E extends CloudEvent<any>>
|
|
|
21
69
|
*/
|
|
22
70
|
export type CloudEventHandlerWithNestContextFactory<N> = <E extends CloudEvent<any>, O = unknown>(fn: CloudEventHandlerWithNestContextBuilder<N, E, O>) => NestApplicationCloudEventFunctionFactory<E>;
|
|
23
71
|
/**
|
|
24
|
-
* Creates a CloudEventHandlerWithNestContextFactory
|
|
72
|
+
* Creates a {@link CloudEventHandlerWithNestContextFactory} that wires up NestJS application context
|
|
73
|
+
* injection for Firebase v2 event-triggered functions.
|
|
74
|
+
*
|
|
75
|
+
* The returned factory lazily resolves the NestJS application on each event, injects the typed
|
|
76
|
+
* context, and delegates to the handler. This is the event-triggered equivalent of
|
|
77
|
+
* {@link onCallHandlerWithNestContextFactory} for callable functions.
|
|
78
|
+
*
|
|
79
|
+
* @example
|
|
80
|
+
* ```ts
|
|
81
|
+
* const factory = cloudEventHandlerWithNestContextFactory(makeMyContext);
|
|
82
|
+
* const onWrite = factory<DocumentEvent, void>((nestHandler) =>
|
|
83
|
+
* onDocumentWritten('path/{id}', nestHandler((request) => {
|
|
84
|
+
* // request.nest is the typed context
|
|
85
|
+
* request.nest.myService.handleWrite(request.data);
|
|
86
|
+
* }))
|
|
87
|
+
* );
|
|
88
|
+
* ```
|
|
25
89
|
*
|
|
26
|
-
* @param
|
|
27
|
-
* @
|
|
28
|
-
* @returns
|
|
90
|
+
* @param makeNestContext - Factory that creates the typed context from the NestJS application context.
|
|
91
|
+
* @returns A factory for creating nest-context-aware event function handlers.
|
|
29
92
|
*/
|
|
30
93
|
export declare function cloudEventHandlerWithNestContextFactory<N>(makeNestContext: MakeNestContext<N>): CloudEventHandlerWithNestContextFactory<N>;
|
|
@@ -7,21 +7,52 @@ import { type ScheduleOptions } from 'firebase-functions/v2/scheduler';
|
|
|
7
7
|
* Configuration options for OnScheduleHandlerWithNestApplicationFactory that extends the base OnScheduleConfig with the gen 2 ScheduleOptions.
|
|
8
8
|
*/
|
|
9
9
|
export type OnScheduleConfigWithGlobalOptions = OnScheduleConfig & Omit<ScheduleOptions, 'schedule'>;
|
|
10
|
+
/**
|
|
11
|
+
* Creates an {@link OnScheduleWithNestApplicationRequest} by combining the NestJS application context
|
|
12
|
+
* with an optional scheduler event. Used internally by schedule handler factories to build the
|
|
13
|
+
* request object passed to schedule function handlers.
|
|
14
|
+
*
|
|
15
|
+
* @param nestApplication - The initialized NestJS application context.
|
|
16
|
+
* @param scheduleContext - The optional Firebase scheduler event, absent when invoked via `_runNow()`.
|
|
17
|
+
* @returns A request object ready for schedule function handlers.
|
|
18
|
+
*/
|
|
10
19
|
export declare function makeOnScheduleHandlerWithNestApplicationRequest(nestApplication: INestApplicationContext, scheduleContext?: scheduler.ScheduledEvent): OnScheduleWithNestApplicationRequest<scheduler.ScheduledEvent>;
|
|
20
|
+
/**
|
|
21
|
+
* A {@link NestApplicationScheduleConfiguredFunctionFactory} specialized for Firebase v2 schedule functions.
|
|
22
|
+
*/
|
|
11
23
|
export type NestApplicationScheduleFunctionFactory = NestApplicationScheduleConfiguredFunctionFactory<scheduler.ScheduleFunction>;
|
|
12
24
|
/**
|
|
13
|
-
* Factory function
|
|
25
|
+
* Factory function that creates a {@link NestApplicationScheduleFunctionFactory} from a schedule configuration
|
|
26
|
+
* and an {@link OnScheduleWithNestApplication} handler.
|
|
27
|
+
*
|
|
28
|
+
* Produced by {@link onScheduleHandlerWithNestApplicationFactory}.
|
|
14
29
|
*/
|
|
15
30
|
export type OnScheduleHandlerWithNestApplicationFactory = (schedule: OnScheduleConfigWithGlobalOptions, fn: OnScheduleWithNestApplication<scheduler.ScheduledEvent>) => NestApplicationScheduleFunctionFactory;
|
|
16
31
|
/**
|
|
17
|
-
* Creates
|
|
32
|
+
* Creates an {@link OnScheduleHandlerWithNestApplicationFactory} for Firebase v2 scheduled functions.
|
|
18
33
|
*
|
|
19
|
-
*
|
|
20
|
-
*
|
|
34
|
+
* The factory resolves `cron` values (including numeric minute intervals) into cron expressions,
|
|
35
|
+
* merges base and per-function schedule options, and attaches `_runNow` and `_schedule` metadata
|
|
36
|
+
* to the resulting function for testing and introspection.
|
|
37
|
+
*
|
|
38
|
+
* @example
|
|
39
|
+
* ```ts
|
|
40
|
+
* const scheduleFactory = onScheduleHandlerWithNestApplicationFactory({ timeoutSeconds: 60 });
|
|
41
|
+
* const dailyCleanup = scheduleFactory(
|
|
42
|
+
* { cron: '0 2 * * *', timezone: 'America/New_York' },
|
|
43
|
+
* (request) => request.nestApplication.get(CleanupService).run()
|
|
44
|
+
* );
|
|
45
|
+
* ```
|
|
46
|
+
*
|
|
47
|
+
* @param baseScheduleConfig - Optional default schedule options merged into every function created by this factory.
|
|
48
|
+
* @returns A factory for creating nest-application-aware scheduled functions.
|
|
21
49
|
*/
|
|
22
50
|
export declare function onScheduleHandlerWithNestApplicationFactory(baseScheduleConfig?: OnScheduleConfigWithGlobalOptions): OnScheduleHandlerWithNestApplicationFactory;
|
|
23
51
|
/**
|
|
24
|
-
* Factory function
|
|
52
|
+
* Factory function that creates a {@link NestApplicationScheduleFunctionFactory} from a schedule configuration
|
|
53
|
+
* and an {@link OnScheduleWithNestContext} handler that receives a typed nest context.
|
|
54
|
+
*
|
|
55
|
+
* Produced by {@link onScheduleHandlerWithNestContextFactory}.
|
|
25
56
|
*/
|
|
26
57
|
export type OnScheduleHandlerWithNestContextFactory<N> = (schedule: OnScheduleConfigWithGlobalOptions, fn: OnScheduleWithNestContext<N, scheduler.ScheduledEvent>) => NestApplicationScheduleFunctionFactory;
|
|
27
58
|
/**
|
package/src/lib/nest/index.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
export * from './auth';
|
|
2
|
+
export * from './controller';
|
|
2
3
|
export * from './development';
|
|
3
4
|
export * from './env';
|
|
4
5
|
export * from './firebase';
|
|
@@ -7,5 +8,7 @@ export * from './function';
|
|
|
7
8
|
export * from './middleware';
|
|
8
9
|
export * from './model';
|
|
9
10
|
export * from './storage';
|
|
11
|
+
export * from './app.module';
|
|
10
12
|
export * from './app';
|
|
11
13
|
export * from './nest.provider';
|
|
14
|
+
export * from './nest.provider.server';
|
|
@@ -1,4 +1,9 @@
|
|
|
1
1
|
import { type Request } from 'express';
|
|
2
|
+
/**
|
|
3
|
+
* Extended Express request with an optional flag to skip AppCheck verification.
|
|
4
|
+
*
|
|
5
|
+
* Set by the {@link SkipAppCheck} decorator to bypass verification for specific routes.
|
|
6
|
+
*/
|
|
2
7
|
export interface AppCheckRequest extends Request {
|
|
3
8
|
skipAppCheck?: boolean;
|
|
4
9
|
}
|