@dereekb/firebase-server 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/CHANGELOG.md +21 -0
- package/package.json +7 -7
- package/src/lib/function/context.d.ts +3 -3
- package/src/lib/function/context.js.map +1 -1
- package/src/lib/nest/function/call.d.ts +23 -0
- package/src/lib/nest/function/call.js +28 -0
- package/src/lib/nest/function/call.js.map +1 -0
- package/src/lib/nest/function/context.d.ts +9 -1
- package/src/lib/nest/function/context.js +25 -3
- package/src/lib/nest/function/context.js.map +1 -1
- package/src/lib/nest/function/index.d.ts +2 -1
- package/src/lib/nest/function/index.js +2 -1
- package/src/lib/nest/function/index.js.map +1 -1
- package/src/lib/nest/function/nest.d.ts +19 -0
- package/src/lib/nest/function/nest.js +12 -0
- package/src/lib/nest/function/nest.js.map +1 -0
- package/src/lib/nest/function/v1/call.d.ts +5 -11
- package/src/lib/nest/function/v1/call.js +9 -3
- package/src/lib/nest/function/v1/call.js.map +1 -1
- package/src/lib/nest/function/v1/event.d.ts +14 -9
- package/src/lib/nest/function/v1/event.js +3 -2
- package/src/lib/nest/function/v1/event.js.map +1 -1
- package/src/lib/nest/function/v1/index.d.ts +0 -1
- package/src/lib/nest/function/v1/index.js +0 -1
- package/src/lib/nest/function/v1/index.js.map +1 -1
- package/src/lib/nest/function/v2/blocking.d.ts +8 -6
- package/src/lib/nest/function/v2/blocking.js +1 -1
- package/src/lib/nest/function/v2/blocking.js.map +1 -1
- package/src/lib/nest/function/v2/call.d.ts +3 -12
- package/src/lib/nest/function/v2/call.js +3 -2
- package/src/lib/nest/function/v2/call.js.map +1 -1
- package/src/lib/nest/function/v2/event.d.ts +8 -6
- package/src/lib/nest/function/v2/event.js +1 -1
- package/src/lib/nest/function/v2/event.js.map +1 -1
- package/src/lib/nest/function/v2/taskqueue.d.ts +9 -7
- package/src/lib/nest/function/v2/taskqueue.js +1 -1
- package/src/lib/nest/function/v2/taskqueue.js.map +1 -1
- package/src/lib/nest/model/create.model.function.d.ts +16 -0
- package/src/lib/nest/model/create.model.function.js +37 -0
- package/src/lib/nest/model/create.model.function.js.map +1 -0
- package/src/lib/nest/model/delete.model.function.d.ts +7 -6
- package/src/lib/nest/model/delete.model.function.js +4 -3
- package/src/lib/nest/model/delete.model.function.js.map +1 -1
- package/src/lib/nest/model/index.d.ts +1 -0
- package/src/lib/nest/model/index.js +1 -0
- package/src/lib/nest/model/index.js.map +1 -1
- package/src/lib/nest/model/update.model.function.d.ts +7 -6
- package/src/lib/nest/model/update.model.function.js +4 -3
- package/src/lib/nest/model/update.model.function.js.map +1 -1
- package/src/lib/nest/nest.provider.d.ts +18 -7
- package/src/lib/nest/nest.provider.js +20 -5
- package/src/lib/nest/nest.provider.js.map +1 -1
- package/test/CHANGELOG.md +19 -0
- package/test/package.json +10 -10
- package/test/src/lib/firebase/firebase.admin.collection.d.ts +5 -5
- package/test/src/lib/firebase/firebase.function.d.ts +5 -2
- package/test/src/lib/firebase/firebase.function.js +4 -0
- package/test/src/lib/firebase/firebase.function.js.map +1 -1
- package/src/lib/nest/function/transform.d.ts +0 -10
- package/src/lib/nest/function/transform.js +0 -27
- package/src/lib/nest/function/transform.js.map +0 -1
- package/src/lib/nest/function/v1/call.utility.d.ts +0 -10
- package/src/lib/nest/function/v1/call.utility.js +0 -23
- package/src/lib/nest/function/v1/call.utility.js.map +0 -1
- package/src/lib/nest/model/model.api.d.ts +0 -0
- package/src/lib/nest/model/model.api.js +0 -2
- package/src/lib/nest/model/model.api.js.map +0 -1
|
@@ -12,7 +12,7 @@ function cloudEventHandlerWithNestContextFactory(makeNestContext) {
|
|
|
12
12
|
return (fn) => {
|
|
13
13
|
return (nestAppPromiseGetter) => {
|
|
14
14
|
const handlerBuilder = (handler) => {
|
|
15
|
-
const fnHandler = (event) => nestAppPromiseGetter().then((
|
|
15
|
+
const fnHandler = (event) => nestAppPromiseGetter().then((nestApplication) => handler(Object.assign(Object.assign({}, event), { nest: makeNestContext(nestApplication) })));
|
|
16
16
|
return fnHandler;
|
|
17
17
|
};
|
|
18
18
|
return fn(handlerBuilder);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"event.js","sourceRoot":"","sources":["../../../../../../../../packages/firebase-server/src/lib/nest/function/v2/event.ts"],"names":[],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"event.js","sourceRoot":"","sources":["../../../../../../../../packages/firebase-server/src/lib/nest/function/v2/event.ts"],"names":[],"mappings":";;;AAsBA;;;;;;GAMG;AACH,SAAgB,uCAAuC,CAAI,eAAmC;IAC5F,OAAO,CAA6C,EAAoD,EAAE,EAAE;QAC1G,OAAO,CAAC,oBAAkD,EAAE,EAAE;YAC5D,MAAM,cAAc,GAAiD,CAAC,OAA8C,EAAE,EAAE;gBACtH,MAAM,SAAS,GAA4B,CAAC,KAAQ,EAAE,EAAE,CACtD,oBAAoB,EAAE,CAAC,IAAI,CAAC,CAAC,eAAe,EAAE,EAAE,CAC9C,OAAO,iCACF,KAAK,KACR,IAAI,EAAE,eAAe,CAAC,eAAe,CAAC,IACtC,CACH,CAAC;gBACJ,OAAO,SAAS,CAAC;YACnB,CAAC,CAAC;YAEF,OAAO,EAAE,CAAC,cAAc,CAAC,CAAC;QAC5B,CAAC,CAAC;IACJ,CAAC,CAAC;AACJ,CAAC;AAjBD,0FAiBC"}
|
|
@@ -1,14 +1,16 @@
|
|
|
1
1
|
import { PromiseOrValue } from '@dereekb/util';
|
|
2
|
-
import { TaskQueueFunction } from 'firebase-functions/v2/tasks';
|
|
2
|
+
import { TaskQueueFunction, Request } from 'firebase-functions/v2/tasks';
|
|
3
3
|
import { MakeNestContext, NestApplicationFunctionFactory } from '../../nest.provider';
|
|
4
|
-
|
|
5
|
-
export declare type
|
|
6
|
-
export declare type
|
|
7
|
-
export declare type
|
|
4
|
+
import { NestContextRequest } from '../nest';
|
|
5
|
+
export declare type TaskQueueNestContextRequest<N, I> = NestContextRequest<N, Request<I>>;
|
|
6
|
+
export declare type TaskQueueFunctionHandler<I = unknown> = (taskRequest: Request<I>) => PromiseOrValue<void>;
|
|
7
|
+
export declare type NestContextTaskQueueFunctionHandler<N, I = unknown> = (request: TaskQueueNestContextRequest<N, I>) => PromiseOrValue<void>;
|
|
8
|
+
export declare type NestContextTaskQueueFunctionHandlerBuilder<N, I = unknown> = (handler: NestContextTaskQueueFunctionHandler<N, I>) => TaskQueueFunctionHandler<I>;
|
|
9
|
+
export declare type TaskQueueFunctionHandlerWithNestContextBuilder<N, I = unknown> = (nest: NestContextTaskQueueFunctionHandlerBuilder<N, I>) => TaskQueueFunction<I>;
|
|
8
10
|
/**
|
|
9
11
|
* Factory function for generating a TaskQueueFunction for a specific task.
|
|
10
12
|
*/
|
|
11
|
-
export declare type TaskQueueFunctionHandlerWithNestContextFactory<
|
|
13
|
+
export declare type TaskQueueFunctionHandlerWithNestContextFactory<N> = <I = unknown>(fn: TaskQueueFunctionHandlerWithNestContextBuilder<N, I>) => NestApplicationFunctionFactory<TaskQueueFunction<I>>;
|
|
12
14
|
/**
|
|
13
15
|
* Creates a TaskQueueFunctionHandlerWithNestContextFactory.
|
|
14
16
|
*
|
|
@@ -16,4 +18,4 @@ export declare type TaskQueueFunctionHandlerWithNestContextFactory<C> = <E = unk
|
|
|
16
18
|
* @param makeNestContext
|
|
17
19
|
* @returns
|
|
18
20
|
*/
|
|
19
|
-
export declare function taskQueueFunctionHandlerWithNestContextFactory<
|
|
21
|
+
export declare function taskQueueFunctionHandlerWithNestContextFactory<N>(makeNestContext: MakeNestContext<N>): TaskQueueFunctionHandlerWithNestContextFactory<N>;
|
|
@@ -12,7 +12,7 @@ function taskQueueFunctionHandlerWithNestContextFactory(makeNestContext) {
|
|
|
12
12
|
return (fn) => {
|
|
13
13
|
return (nestAppPromiseGetter) => {
|
|
14
14
|
const handlerBuilder = (handler) => {
|
|
15
|
-
const fnHandler = (
|
|
15
|
+
const fnHandler = (taskRequest) => nestAppPromiseGetter().then((nestApplication) => handler(Object.assign(Object.assign({}, taskRequest), { nest: makeNestContext(nestApplication) })));
|
|
16
16
|
return fnHandler;
|
|
17
17
|
};
|
|
18
18
|
return fn(handlerBuilder);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"taskqueue.js","sourceRoot":"","sources":["../../../../../../../../packages/firebase-server/src/lib/nest/function/v2/taskqueue.ts"],"names":[],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"taskqueue.js","sourceRoot":"","sources":["../../../../../../../../packages/firebase-server/src/lib/nest/function/v2/taskqueue.ts"],"names":[],"mappings":";;;AAoBA;;;;;;GAMG;AACH,SAAgB,8CAA8C,CAAI,eAAmC;IACnG,OAAO,CAAc,EAAwD,EAAE,EAAE;QAC/E,OAAO,CAAC,oBAAkD,EAAE,EAAE;YAC5D,MAAM,cAAc,GAAqD,CAAC,OAAkD,EAAE,EAAE;gBAC9H,MAAM,SAAS,GAAgC,CAAC,WAAuB,EAAE,EAAE,CACzE,oBAAoB,EAAE,CAAC,IAAI,CAAC,CAAC,eAAe,EAAE,EAAE,CAC9C,OAAO,iCACF,WAAW,KACd,IAAI,EAAE,eAAe,CAAC,eAAe,CAAC,IACtC,CACH,CAAC;gBACJ,OAAO,SAAS,CAAC;YACnB,CAAC,CAAC;YAEF,OAAO,EAAE,CAAC,cAAc,CAAC,CAAC;QAC5B,CAAC,CAAC;IACJ,CAAC,CAAC;AACJ,CAAC;AAjBD,wGAiBC"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { PromiseOrValue } from '@dereekb/util';
|
|
2
|
+
import { FirestoreModelName, FirestoreModelIdentity, FirestoreModelNames, OnCallCreateModelParams, OnCallCreateModelResult } from '@dereekb/firebase';
|
|
3
|
+
import { OnCallWithAuthorizedNestContext } from '../function/call';
|
|
4
|
+
import { NestContextCallableRequestWithAuth } from '../function/nest';
|
|
5
|
+
export declare type OnCallCreateModelFunction<N, I = unknown, O extends OnCallCreateModelResult = OnCallCreateModelResult> = (request: NestContextCallableRequestWithAuth<N, I>) => PromiseOrValue<O>;
|
|
6
|
+
export declare type OnCallCreateModelMap<N, T extends FirestoreModelIdentity = FirestoreModelIdentity> = {
|
|
7
|
+
[K in FirestoreModelNames<T>]?: OnCallCreateModelFunction<N, any, OnCallCreateModelResult>;
|
|
8
|
+
};
|
|
9
|
+
/**
|
|
10
|
+
* Creates a OnCallWithAuthorizedNestContext function for creating a model.
|
|
11
|
+
*
|
|
12
|
+
* @param map
|
|
13
|
+
* @returns
|
|
14
|
+
*/
|
|
15
|
+
export declare function onCallCreateModel<N>(map: OnCallCreateModelMap<N>): OnCallWithAuthorizedNestContext<N, OnCallCreateModelParams, OnCallCreateModelResult>;
|
|
16
|
+
export declare function createModelUnknownModelTypeError(modelType: FirestoreModelName): import("firebase-functions/v1/auth").HttpsError;
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.createModelUnknownModelTypeError = exports.onCallCreateModel = void 0;
|
|
4
|
+
const util_1 = require("@dereekb/util");
|
|
5
|
+
const function_1 = require("../../function");
|
|
6
|
+
/**
|
|
7
|
+
* Creates a OnCallWithAuthorizedNestContext function for creating a model.
|
|
8
|
+
*
|
|
9
|
+
* @param map
|
|
10
|
+
* @returns
|
|
11
|
+
*/
|
|
12
|
+
function onCallCreateModel(map) {
|
|
13
|
+
return (request) => {
|
|
14
|
+
var _a;
|
|
15
|
+
const modelType = (_a = request.data) === null || _a === void 0 ? void 0 : _a.modelType;
|
|
16
|
+
const createFn = map[modelType];
|
|
17
|
+
if (createFn) {
|
|
18
|
+
return createFn(Object.assign(Object.assign({}, request), { data: request.data.data }));
|
|
19
|
+
}
|
|
20
|
+
else {
|
|
21
|
+
throw createModelUnknownModelTypeError(modelType);
|
|
22
|
+
}
|
|
23
|
+
};
|
|
24
|
+
}
|
|
25
|
+
exports.onCallCreateModel = onCallCreateModel;
|
|
26
|
+
function createModelUnknownModelTypeError(modelType) {
|
|
27
|
+
return (0, function_1.badRequestError)((0, util_1.serverError)({
|
|
28
|
+
status: 400,
|
|
29
|
+
code: 'UNKNOWN_TYPE_ERROR',
|
|
30
|
+
message: 'Invalid type to create.',
|
|
31
|
+
data: {
|
|
32
|
+
modelType
|
|
33
|
+
}
|
|
34
|
+
}));
|
|
35
|
+
}
|
|
36
|
+
exports.createModelUnknownModelTypeError = createModelUnknownModelTypeError;
|
|
37
|
+
//# sourceMappingURL=create.model.function.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"create.model.function.js","sourceRoot":"","sources":["../../../../../../../packages/firebase-server/src/lib/nest/model/create.model.function.ts"],"names":[],"mappings":";;;AAAA,wCAA4D;AAE5D,6CAAiD;AAWjD;;;;;GAKG;AACH,SAAgB,iBAAiB,CAAI,GAA4B;IAC/D,OAAO,CAAC,OAAO,EAAE,EAAE;;QACjB,MAAM,SAAS,GAAG,MAAA,OAAO,CAAC,IAAI,0CAAE,SAAS,CAAC;QAC1C,MAAM,QAAQ,GAAG,GAAG,CAAC,SAAS,CAAC,CAAC;QAEhC,IAAI,QAAQ,EAAE;YACZ,OAAO,QAAQ,iCACV,OAAO,KACV,IAAI,EAAE,OAAO,CAAC,IAAI,CAAC,IAAI,IACvB,CAAC;SACJ;aAAM;YACL,MAAM,gCAAgC,CAAC,SAAS,CAAC,CAAC;SACnD;IACH,CAAC,CAAC;AACJ,CAAC;AAdD,8CAcC;AAED,SAAgB,gCAAgC,CAAC,SAA6B;IAC5E,OAAO,IAAA,0BAAe,EACpB,IAAA,kBAAW,EAAC;QACV,MAAM,EAAE,GAAG;QACX,IAAI,EAAE,oBAAoB;QAC1B,OAAO,EAAE,yBAAyB;QAClC,IAAI,EAAE;YACJ,SAAS;SACV;KACF,CAAC,CACH,CAAC;AACJ,CAAC;AAXD,4EAWC"}
|
|
@@ -1,9 +1,10 @@
|
|
|
1
|
+
import { PromiseOrValue } from '@dereekb/util';
|
|
1
2
|
import { FirestoreModelName, FirestoreModelIdentity, FirestoreModelNames, OnCallDeleteModelParams } from '@dereekb/firebase';
|
|
2
|
-
import {
|
|
3
|
-
import { OnCallWithAuthorizedNestContext } from '../function/
|
|
4
|
-
export declare type OnCallDeleteModelFunction<
|
|
5
|
-
export declare type OnCallDeleteModelMap<
|
|
6
|
-
[K in FirestoreModelNames<T>]?: OnCallDeleteModelFunction<
|
|
3
|
+
import { NestContextCallableRequestWithAuth } from '../function/nest';
|
|
4
|
+
import { OnCallWithAuthorizedNestContext } from '../function/call';
|
|
5
|
+
export declare type OnCallDeleteModelFunction<N, I = unknown, O = void> = (request: NestContextCallableRequestWithAuth<N, I>) => PromiseOrValue<O>;
|
|
6
|
+
export declare type OnCallDeleteModelMap<N, T extends FirestoreModelIdentity = FirestoreModelIdentity> = {
|
|
7
|
+
[K in FirestoreModelNames<T>]?: OnCallDeleteModelFunction<N, any, any>;
|
|
7
8
|
};
|
|
8
9
|
/**
|
|
9
10
|
* Creates a OnCallWithAuthorizedNestContext function for updating model params.
|
|
@@ -11,5 +12,5 @@ export declare type OnCallDeleteModelMap<C, T extends FirestoreModelIdentity = F
|
|
|
11
12
|
* @param map
|
|
12
13
|
* @returns
|
|
13
14
|
*/
|
|
14
|
-
export declare function onCallDeleteModel<
|
|
15
|
+
export declare function onCallDeleteModel<N>(map: OnCallDeleteModelMap<N>): OnCallWithAuthorizedNestContext<N, OnCallDeleteModelParams, unknown>;
|
|
15
16
|
export declare function deleteModelUnknownModelTypeError(modelType: FirestoreModelName): import("firebase-functions/v1/auth").HttpsError;
|
|
@@ -10,11 +10,12 @@ const function_1 = require("../../function");
|
|
|
10
10
|
* @returns
|
|
11
11
|
*/
|
|
12
12
|
function onCallDeleteModel(map) {
|
|
13
|
-
return (
|
|
14
|
-
|
|
13
|
+
return (request) => {
|
|
14
|
+
var _a;
|
|
15
|
+
const modelType = (_a = request.data) === null || _a === void 0 ? void 0 : _a.modelType;
|
|
15
16
|
const deleteFn = map[modelType];
|
|
16
17
|
if (deleteFn) {
|
|
17
|
-
return deleteFn(
|
|
18
|
+
return deleteFn(Object.assign(Object.assign({}, request), { data: request.data.data }));
|
|
18
19
|
}
|
|
19
20
|
else {
|
|
20
21
|
throw deleteModelUnknownModelTypeError(modelType);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"delete.model.function.js","sourceRoot":"","sources":["../../../../../../../packages/firebase-server/src/lib/nest/model/delete.model.function.ts"],"names":[],"mappings":";;;AAAA,
|
|
1
|
+
{"version":3,"file":"delete.model.function.js","sourceRoot":"","sources":["../../../../../../../packages/firebase-server/src/lib/nest/model/delete.model.function.ts"],"names":[],"mappings":";;;AAAA,wCAA4D;AAE5D,6CAAiD;AAWjD;;;;;GAKG;AACH,SAAgB,iBAAiB,CAAI,GAA4B;IAC/D,OAAO,CAAC,OAAO,EAAE,EAAE;;QACjB,MAAM,SAAS,GAAG,MAAA,OAAO,CAAC,IAAI,0CAAE,SAAS,CAAC;QAC1C,MAAM,QAAQ,GAAG,GAAG,CAAC,SAAS,CAAC,CAAC;QAEhC,IAAI,QAAQ,EAAE;YACZ,OAAO,QAAQ,iCACV,OAAO,KACV,IAAI,EAAE,OAAO,CAAC,IAAI,CAAC,IAAI,IACvB,CAAC;SACJ;aAAM;YACL,MAAM,gCAAgC,CAAC,SAAS,CAAC,CAAC;SACnD;IACH,CAAC,CAAC;AACJ,CAAC;AAdD,8CAcC;AAED,SAAgB,gCAAgC,CAAC,SAA6B;IAC5E,OAAO,IAAA,0BAAe,EACpB,IAAA,kBAAW,EAAC;QACV,MAAM,EAAE,GAAG;QACX,IAAI,EAAE,oBAAoB;QAC1B,OAAO,EAAE,yBAAyB;QAClC,IAAI,EAAE;YACJ,SAAS;SACV;KACF,CAAC,CACH,CAAC;AACJ,CAAC;AAXD,4EAWC"}
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
const tslib_1 = require("tslib");
|
|
4
4
|
tslib_1.__exportStar(require("./permission.error"), exports);
|
|
5
|
+
tslib_1.__exportStar(require("./create.model.function"), exports);
|
|
5
6
|
tslib_1.__exportStar(require("./update.model.function"), exports);
|
|
6
7
|
tslib_1.__exportStar(require("./delete.model.function"), exports);
|
|
7
8
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../../../packages/firebase-server/src/lib/nest/model/index.ts"],"names":[],"mappings":";;;AAAA,6DAAmC;AACnC,kEAAwC;AACxC,kEAAwC"}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../../../packages/firebase-server/src/lib/nest/model/index.ts"],"names":[],"mappings":";;;AAAA,6DAAmC;AACnC,kEAAwC;AACxC,kEAAwC;AACxC,kEAAwC"}
|
|
@@ -1,9 +1,10 @@
|
|
|
1
|
+
import { PromiseOrValue } from '@dereekb/util';
|
|
1
2
|
import { FirestoreModelName, FirestoreModelIdentity, FirestoreModelNames, OnCallUpdateModelParams } from '@dereekb/firebase';
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
export declare type OnCallUpdateModelFunction<
|
|
5
|
-
export declare type OnCallUpdateModelMap<
|
|
6
|
-
[K in FirestoreModelNames<T>]?: OnCallUpdateModelFunction<
|
|
3
|
+
import { OnCallWithAuthorizedNestContext } from '../function/call';
|
|
4
|
+
import { NestContextCallableRequestWithAuth } from '../function/nest';
|
|
5
|
+
export declare type OnCallUpdateModelFunction<N, I = unknown, O = void> = (request: NestContextCallableRequestWithAuth<N, I>) => PromiseOrValue<O>;
|
|
6
|
+
export declare type OnCallUpdateModelMap<N, T extends FirestoreModelIdentity = FirestoreModelIdentity> = {
|
|
7
|
+
[K in FirestoreModelNames<T>]?: OnCallUpdateModelFunction<N, any, any>;
|
|
7
8
|
};
|
|
8
9
|
/**
|
|
9
10
|
* Creates a OnCallWithAuthorizedNestContext function for updating model params.
|
|
@@ -11,5 +12,5 @@ export declare type OnCallUpdateModelMap<C, T extends FirestoreModelIdentity = F
|
|
|
11
12
|
* @param map
|
|
12
13
|
* @returns
|
|
13
14
|
*/
|
|
14
|
-
export declare function onCallUpdateModel<
|
|
15
|
+
export declare function onCallUpdateModel<N>(map: OnCallUpdateModelMap<N>): OnCallWithAuthorizedNestContext<N, OnCallUpdateModelParams, unknown>;
|
|
15
16
|
export declare function updateModelUnknownModelTypeError(modelType: FirestoreModelName): import("firebase-functions/v1/auth").HttpsError;
|
|
@@ -10,11 +10,12 @@ const function_1 = require("../../function");
|
|
|
10
10
|
* @returns
|
|
11
11
|
*/
|
|
12
12
|
function onCallUpdateModel(map) {
|
|
13
|
-
return (
|
|
14
|
-
|
|
13
|
+
return (request) => {
|
|
14
|
+
var _a;
|
|
15
|
+
const modelType = (_a = request.data) === null || _a === void 0 ? void 0 : _a.modelType;
|
|
15
16
|
const updateFn = map[modelType];
|
|
16
17
|
if (updateFn) {
|
|
17
|
-
return updateFn(
|
|
18
|
+
return updateFn(Object.assign(Object.assign({}, request), { data: request.data.data }));
|
|
18
19
|
}
|
|
19
20
|
else {
|
|
20
21
|
throw updateModelUnknownModelTypeError(modelType);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"update.model.function.js","sourceRoot":"","sources":["../../../../../../../packages/firebase-server/src/lib/nest/model/update.model.function.ts"],"names":[],"mappings":";;;AAAA,
|
|
1
|
+
{"version":3,"file":"update.model.function.js","sourceRoot":"","sources":["../../../../../../../packages/firebase-server/src/lib/nest/model/update.model.function.ts"],"names":[],"mappings":";;;AAAA,wCAA4D;AAE5D,6CAAiD;AAWjD;;;;;GAKG;AACH,SAAgB,iBAAiB,CAAI,GAA4B;IAC/D,OAAO,CAAC,OAAO,EAAE,EAAE;;QACjB,MAAM,SAAS,GAAG,MAAA,OAAO,CAAC,IAAI,0CAAE,SAAS,CAAC;QAC1C,MAAM,QAAQ,GAAG,GAAG,CAAC,SAAS,CAAC,CAAC;QAEhC,IAAI,QAAQ,EAAE;YACZ,OAAO,QAAQ,iCACV,OAAO,KACV,IAAI,EAAE,OAAO,CAAC,IAAI,CAAC,IAAI,IACvB,CAAC;SACJ;aAAM;YACL,MAAM,gCAAgC,CAAC,SAAS,CAAC,CAAC;SACnD;IACH,CAAC,CAAC;AACJ,CAAC;AAdD,8CAcC;AAED,SAAgB,gCAAgC,CAAC,SAA6B;IAC5E,OAAO,IAAA,0BAAe,EACpB,IAAA,kBAAW,EAAC;QACV,MAAM,EAAE,GAAG;QACX,IAAI,EAAE,oBAAoB;QAC1B,OAAO,EAAE,yBAAyB;QAClC,IAAI,EAAE;YACJ,SAAS;SACV;KACF,CAAC,CACH,CAAC;AACJ,CAAC;AAXD,4EAWC"}
|
|
@@ -1,8 +1,9 @@
|
|
|
1
|
-
import { FirebaseAppModelContext, FirebaseModelsService, InContextFirebaseModelsService } from '@dereekb/firebase';
|
|
1
|
+
import { FirebaseAppModelContext, FirebaseModelServiceContext, FirebaseModelsService, FirebaseModelsServiceSelectionResultRolesReader, FirebaseModelsServiceTypes, InContextFirebaseModelsService, UseFirebaseModelsServiceSelection, UseFirebaseModelsServiceSelectionUseFunction } from '@dereekb/firebase';
|
|
2
2
|
import { BuildFunction, Getter } from '@dereekb/util';
|
|
3
3
|
import { INestApplicationContext } from '@nestjs/common';
|
|
4
4
|
import { AuthDataRef } from '../auth';
|
|
5
5
|
import { FirebaseServerAuthService } from '../auth/auth.service';
|
|
6
|
+
import { FirebaseServerActionsContext } from './function/context';
|
|
6
7
|
/**
|
|
7
8
|
* Getter for an INestApplicationContext promise. Nest should be initialized when the promise resolves.
|
|
8
9
|
*/
|
|
@@ -24,10 +25,11 @@ export declare abstract class AbstractNestContext {
|
|
|
24
25
|
readonly nest: INestApplicationContext;
|
|
25
26
|
constructor(nest: INestApplicationContext);
|
|
26
27
|
}
|
|
27
|
-
export declare abstract class AbstractFirebaseNestContext<
|
|
28
|
+
export declare abstract class AbstractFirebaseNestContext<A, Y extends FirebaseModelsService<any, FirebaseAppModelContext<A>>> extends AbstractNestContext {
|
|
29
|
+
abstract get actionContext(): FirebaseServerActionsContext;
|
|
28
30
|
abstract get authService(): FirebaseServerAuthService;
|
|
29
|
-
abstract get
|
|
30
|
-
abstract get app():
|
|
31
|
+
abstract get firebaseModelsService(): Y;
|
|
32
|
+
abstract get app(): A;
|
|
31
33
|
/**
|
|
32
34
|
* Creates a FirebaseAppModelContext instance.
|
|
33
35
|
*
|
|
@@ -35,13 +37,22 @@ export declare abstract class AbstractFirebaseNestContext<C, Y extends FirebaseM
|
|
|
35
37
|
* @param buildFn
|
|
36
38
|
* @returns
|
|
37
39
|
*/
|
|
38
|
-
|
|
40
|
+
makeModelContext(auth: AuthDataRef, buildFn?: BuildFunction<FirebaseAppModelContext<A>>): FirebaseAppModelContext<A>;
|
|
39
41
|
/**
|
|
40
42
|
* Creates a InContextFirebaseModelsService given the input context and parameters.
|
|
41
43
|
*
|
|
42
|
-
* @param
|
|
44
|
+
* @param context
|
|
43
45
|
* @param buildFn
|
|
44
46
|
* @returns
|
|
45
47
|
*/
|
|
46
|
-
|
|
48
|
+
model(context: AuthDataRef, buildFn?: BuildFunction<FirebaseAppModelContext<A>>): InContextFirebaseModelsService<Y>;
|
|
49
|
+
useModel<T extends FirebaseModelsServiceTypes<Y>, O>(type: T, select: UseModelInput<FirebaseAppModelContext<A>, Y, T, O>): Promise<O>;
|
|
50
|
+
useModel<T extends FirebaseModelsServiceTypes<Y>>(type: T, select: UseModelInputForRolesReader<FirebaseAppModelContext<A>, Y, T>): Promise<FirebaseModelsServiceSelectionResultRolesReader<Y, T>>;
|
|
47
51
|
}
|
|
52
|
+
export declare type UseModelInputForRolesReader<C extends FirebaseModelServiceContext, Y extends FirebaseModelsService<any, C>, T extends FirebaseModelsServiceTypes<Y>> = Omit<UseFirebaseModelsServiceSelection<Y, T>, 'type' | 'context'> & {
|
|
53
|
+
request: AuthDataRef;
|
|
54
|
+
buildFn?: BuildFunction<C>;
|
|
55
|
+
};
|
|
56
|
+
export declare type UseModelInput<C extends FirebaseModelServiceContext, Y extends FirebaseModelsService<any, C>, T extends FirebaseModelsServiceTypes<Y>, O> = UseModelInputForRolesReader<C, Y, T> & {
|
|
57
|
+
use: UseFirebaseModelsServiceSelectionUseFunction<Y, T, O>;
|
|
58
|
+
};
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.AbstractFirebaseNestContext = exports.AbstractNestContext = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
4
5
|
const firebase_1 = require("@dereekb/firebase");
|
|
5
6
|
const util_1 = require("@dereekb/util");
|
|
6
7
|
const permission_error_1 = require("./model/permission.error");
|
|
@@ -21,7 +22,7 @@ class AbstractFirebaseNestContext extends AbstractNestContext {
|
|
|
21
22
|
* @param buildFn
|
|
22
23
|
* @returns
|
|
23
24
|
*/
|
|
24
|
-
|
|
25
|
+
makeModelContext(auth, buildFn) {
|
|
25
26
|
const base = {
|
|
26
27
|
auth: this.authService.authContextInfo(auth),
|
|
27
28
|
app: this.app,
|
|
@@ -37,13 +38,27 @@ class AbstractFirebaseNestContext extends AbstractNestContext {
|
|
|
37
38
|
/**
|
|
38
39
|
* Creates a InContextFirebaseModelsService given the input context and parameters.
|
|
39
40
|
*
|
|
40
|
-
* @param
|
|
41
|
+
* @param context
|
|
41
42
|
* @param buildFn
|
|
42
43
|
* @returns
|
|
43
44
|
*/
|
|
44
|
-
|
|
45
|
-
const firebaseModelContext = this.
|
|
46
|
-
return (0, firebase_1.inContextFirebaseModelsServiceFactory)(this.
|
|
45
|
+
model(context, buildFn) {
|
|
46
|
+
const firebaseModelContext = this.makeModelContext(context, buildFn);
|
|
47
|
+
return (0, firebase_1.inContextFirebaseModelsServiceFactory)(this.firebaseModelsService)(firebaseModelContext);
|
|
48
|
+
}
|
|
49
|
+
useModel(type, select) {
|
|
50
|
+
var _a;
|
|
51
|
+
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
52
|
+
const context = this.makeModelContext(select.request, select.buildFn);
|
|
53
|
+
const usePromise = (0, firebase_1.useFirebaseModelsService)(this.firebaseModelsService, type, {
|
|
54
|
+
context,
|
|
55
|
+
key: select.key,
|
|
56
|
+
roles: select.roles,
|
|
57
|
+
rolesSetIncludes: select.rolesSetIncludes
|
|
58
|
+
});
|
|
59
|
+
const use = (_a = select.use) !== null && _a !== void 0 ? _a : ((x) => x);
|
|
60
|
+
return usePromise(use);
|
|
61
|
+
});
|
|
47
62
|
}
|
|
48
63
|
}
|
|
49
64
|
exports.AbstractFirebaseNestContext = AbstractFirebaseNestContext;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"nest.provider.js","sourceRoot":"","sources":["../../../../../../packages/firebase-server/src/lib/nest/nest.provider.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"nest.provider.js","sourceRoot":"","sources":["../../../../../../packages/firebase-server/src/lib/nest/nest.provider.ts"],"names":[],"mappings":";;;;AAAA,gDAA+W;AAC/W,wCAA6D;AAK7D,+DAAgF;AAmBhF;;GAEG;AACH,MAAsB,mBAAmB;IACvC,YAAqB,IAA6B;QAA7B,SAAI,GAAJ,IAAI,CAAyB;IAAG,CAAC;CACvD;AAFD,kDAEC;AAED,MAAsB,2BAAiG,SAAQ,mBAAmB;IAMhJ;;;;;;OAMG;IACH,gBAAgB,CAAC,IAAiB,EAAE,OAAmD;QACrF,MAAM,IAAI,GAA+B;YACvC,IAAI,EAAE,IAAI,CAAC,WAAW,CAAC,eAAe,CAAC,IAAI,CAAC;YAC5C,GAAG,EAAE,IAAI,CAAC,GAAG;YACb,mBAAmB,EAAE,uDAAoC;SAC1D,CAAC;QAEF,OAAO,OAAO;YACZ,CAAC,CAAC,IAAA,YAAK,EAAC;gBACJ,IAAI;gBACJ,KAAK,EAAE,OAAO;aACf,CAAC;YACJ,CAAC,CAAC,IAAI,CAAC;IACX,CAAC;IAED;;;;;;OAMG;IACH,KAAK,CAAC,OAAoB,EAAE,OAAmD;QAC7E,MAAM,oBAAoB,GAAG,IAAI,CAAC,gBAAgB,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC;QACrE,OAAO,IAAA,gDAAqC,EAAC,IAAI,CAAC,qBAAqB,CAAC,CAAC,oBAAoB,CAAsC,CAAC;IACtI,CAAC;IAIK,QAAQ,CAA6C,IAAO,EAAE,MAA0H;;;YAC5L,MAAM,OAAO,GAA+B,IAAI,CAAC,gBAAgB,CAAC,MAAM,CAAC,OAAO,EAAE,MAAM,CAAC,OAAO,CAAC,CAAC;YAClG,MAAM,UAAU,GAAG,IAAA,mCAAwB,EAAC,IAAI,CAAC,qBAAqB,EAAE,IAAI,EAAE;gBAC5E,OAAO;gBACP,GAAG,EAAE,MAAM,CAAC,GAAG;gBACf,KAAK,EAAE,MAAM,CAAC,KAAK;gBACnB,gBAAgB,EAAE,MAAM,CAAC,gBAAgB;aACC,CAAC,CAAC;YAE9C,MAAM,GAAG,GAA0D,MAAC,MAA6D,CAAC,GAAG,mCAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAiB,CAAC,CAAC;YACpK,OAAO,UAAU,CAAC,GAAG,CAAC,CAAC;;KACxB;CACF;AAtDD,kEAsDC"}
|
package/test/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,25 @@
|
|
|
2
2
|
|
|
3
3
|
This file was generated using [@jscutlery/semver](https://github.com/jscutlery/semver).
|
|
4
4
|
|
|
5
|
+
# [7.0.0](https://github.com/dereekb/dbx-components/compare/v6.0.0-dev...v7.0.0) (2022-06-05)
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
### Code Refactoring
|
|
9
|
+
|
|
10
|
+
* updated OnCallWithNestContextRequest to use single object ([2ef4002](https://github.com/dereekb/dbx-components/commit/2ef4002153d3e4b7efb012e31b2739378ac49789))
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
### Features
|
|
14
|
+
|
|
15
|
+
* added FirestoreDocumentStore crud functions ([7786a40](https://github.com/dereekb/dbx-components/commit/7786a40f6033c2a1d5161805cde283dca7323db5))
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
### BREAKING CHANGES
|
|
19
|
+
|
|
20
|
+
* updated all onCall and functions to now use a single request object instead of multiple parameters
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
|
|
5
24
|
# [6.0.0](https://github.com/dereekb/dbx-components/compare/v5.3.0-dev...v6.0.0) (2022-06-03)
|
|
6
25
|
|
|
7
26
|
|
package/test/package.json
CHANGED
|
@@ -1,35 +1,35 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dereekb/firebase-server/test",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "7.0.0",
|
|
4
4
|
"main": "./src/index.js",
|
|
5
5
|
"typings": "./src/index.d.ts",
|
|
6
6
|
"dependencies": {},
|
|
7
7
|
"peerDependencies": {
|
|
8
|
-
"@dereekb/firebase": "
|
|
8
|
+
"@dereekb/firebase": "7.0.0",
|
|
9
9
|
"rxjs": "^7.0.0",
|
|
10
10
|
"rxfire": "^6.0.3",
|
|
11
11
|
"firebase": "^9.8.0",
|
|
12
|
-
"@dereekb/util": "
|
|
12
|
+
"@dereekb/util": "7.0.0",
|
|
13
13
|
"make-error": "^1.3.0",
|
|
14
14
|
"extra-set": "^2.2.11",
|
|
15
|
-
"@dereekb/rxjs": "
|
|
15
|
+
"@dereekb/rxjs": "7.0.0",
|
|
16
16
|
"ms": "^3.0.0-canary.1",
|
|
17
|
-
"@dereekb/date": "
|
|
17
|
+
"@dereekb/date": "7.0.0",
|
|
18
18
|
"class-transformer": "^0.5.1",
|
|
19
19
|
"date-fns": "^2.28.0",
|
|
20
20
|
"class-validator": "^0.13.2",
|
|
21
21
|
"date-fns-tz": "^1.3.0",
|
|
22
22
|
"rrule": "git+https://git@github.com/dereekb/rrule.git#17adf5708d6567b4d01a3a8afd106261421ea492",
|
|
23
|
-
"@dereekb/model": "
|
|
24
|
-
"@dereekb/util/test": "
|
|
23
|
+
"@dereekb/model": "7.0.0",
|
|
24
|
+
"@dereekb/util/test": "7.0.0",
|
|
25
25
|
"firebase-admin": "^10.2.0",
|
|
26
26
|
"jsonwebtoken": "^8.0.0",
|
|
27
27
|
"firebase-functions": "^3.21.2",
|
|
28
28
|
"@nestjs/common": "^8.4.0",
|
|
29
29
|
"@google-cloud/firestore": "^5.0.2",
|
|
30
|
-
"@dereekb/firebase/test": "
|
|
31
|
-
"@dereekb/firebase-server": "
|
|
32
|
-
"@dereekb/nestjs": "
|
|
30
|
+
"@dereekb/firebase/test": "7.0.0",
|
|
31
|
+
"@dereekb/firebase-server": "7.0.0",
|
|
32
|
+
"@dereekb/nestjs": "7.0.0",
|
|
33
33
|
"@nestjs/config": "^2.0.1",
|
|
34
34
|
"@nestjs/core": "^8.4.0",
|
|
35
35
|
"@nestjs/platform-express": "^8.4.0",
|
|
@@ -1,17 +1,17 @@
|
|
|
1
|
-
import { FirestoreCollection, FirestoreDocument, DocumentReference } from '@dereekb/firebase';
|
|
2
|
-
import {
|
|
1
|
+
import { FirestoreCollection, FirestoreDocument, DocumentReference, FirestoreModelId } from '@dereekb/firebase';
|
|
2
|
+
import { PromiseOrValue } from '@dereekb/util';
|
|
3
3
|
import { JestTestContextFixture, AbstractChildJestTestContextFixture } from '@dereekb/util/test';
|
|
4
4
|
import { FirebaseAdminTestContext } from './firebase.admin';
|
|
5
5
|
/**
|
|
6
6
|
* Testing context for a single model.
|
|
7
7
|
*/
|
|
8
8
|
export interface ModelTestContext<T, D extends FirestoreDocument<T> = FirestoreDocument<T>> {
|
|
9
|
-
get documentId():
|
|
9
|
+
get documentId(): FirestoreModelId;
|
|
10
10
|
get documentRef(): DocumentReference<T>;
|
|
11
11
|
get document(): D;
|
|
12
12
|
}
|
|
13
13
|
export declare class ModelTestContextFixture<T, D extends FirestoreDocument<T> = FirestoreDocument<T>, PI extends FirebaseAdminTestContext = FirebaseAdminTestContext, PF extends JestTestContextFixture<PI> = JestTestContextFixture<PI>, I extends ModelTestContextInstance<T, D, PI> = ModelTestContextInstance<T, D, PI>> extends AbstractChildJestTestContextFixture<I, PF> implements ModelTestContext<T, D> {
|
|
14
|
-
get documentId():
|
|
14
|
+
get documentId(): FirestoreModelId;
|
|
15
15
|
get documentRef(): DocumentReference<T>;
|
|
16
16
|
get document(): D;
|
|
17
17
|
}
|
|
@@ -20,7 +20,7 @@ export declare class ModelTestContextInstance<T, D extends FirestoreDocument<T>
|
|
|
20
20
|
readonly ref: DocumentReference<T>;
|
|
21
21
|
readonly testContext: PI;
|
|
22
22
|
constructor(collection: FirestoreCollection<T, D>, ref: DocumentReference<T>, testContext: PI);
|
|
23
|
-
get documentId():
|
|
23
|
+
get documentId(): FirestoreModelId;
|
|
24
24
|
get documentRef(): DocumentReference<T>;
|
|
25
25
|
get document(): D;
|
|
26
26
|
}
|
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
import { CloudFunction as CloudFunctionV1 } from 'firebase-functions';
|
|
2
2
|
import { CloudFunction as CloudFunctionV2, CloudEvent } from 'firebase-functions/v2';
|
|
3
|
-
import { wrap, WrappedFunction, WrappedScheduledFunction, WrappedV2Function } from 'firebase-functions-test/lib/main';
|
|
4
|
-
import { Getter } from '@dereekb/util';
|
|
3
|
+
import { CallableContextOptions, wrap, WrappedFunction, WrappedScheduledFunction, WrappedV2Function } from 'firebase-functions-test/lib/main';
|
|
4
|
+
import { Getter, PromiseOrValue } from '@dereekb/util';
|
|
5
5
|
import { FeaturesList } from 'firebase-functions-test/lib/features';
|
|
6
6
|
export declare type WrapCloudFunctionV1 = <T>(cloudFunction: CloudFunctionV1<T>) => WrappedScheduledFunction | WrappedFunction<T>;
|
|
7
|
+
export declare type WrappedV2CallableRequestDataOnly<T> = (data: T, options: CallableContextOptions) => PromiseOrValue<any>;
|
|
8
|
+
export declare type WrapCallableRequestV2 = <T>(cloudFunction: CloudFunctionV1<T>) => WrappedV2CallableRequestDataOnly<T>;
|
|
7
9
|
export declare type WrapCloudFunctionV2 = <T extends CloudEvent<unknown>>(cloudFunction: CloudFunctionV2<T>) => WrappedV2Function<T>;
|
|
8
10
|
export declare type WrapCloudFunctionV1Input<T> = CloudFunctionV1<T>;
|
|
9
11
|
export declare type WrappedCloudFunctionV1<T> = WrappedScheduledFunction | WrappedFunction<T>;
|
|
@@ -15,6 +17,7 @@ export interface FirebaseAdminCloudFunctionWrapperSource {
|
|
|
15
17
|
}
|
|
16
18
|
export interface FirebaseAdminCloudFunctionWrapper {
|
|
17
19
|
readonly wrapV1CloudFunction: WrapCloudFunctionV1;
|
|
20
|
+
readonly wrapV2CallableRequest: WrapCallableRequestV2;
|
|
18
21
|
readonly wrapV2CloudFunction: WrapCloudFunctionV2;
|
|
19
22
|
readonly wrapBlockingFunction: WrapBlockingFunction;
|
|
20
23
|
}
|
|
@@ -9,6 +9,10 @@ function firebaseAdminCloudFunctionWrapper(instance) {
|
|
|
9
9
|
wrapV2CloudFunction(x) {
|
|
10
10
|
return instance.wrap(x);
|
|
11
11
|
},
|
|
12
|
+
wrapV2CallableRequest(x) {
|
|
13
|
+
const wrappedCloudFunction = this.wrapV1CloudFunction(x);
|
|
14
|
+
return (data, context) => wrappedCloudFunction(Object.assign(Object.assign({}, context), { data }));
|
|
15
|
+
},
|
|
12
16
|
wrapBlockingFunction() {
|
|
13
17
|
throw new Error('Not supported yet.');
|
|
14
18
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"firebase.function.js","sourceRoot":"","sources":["../../../../../../../packages/firebase-server/test/src/lib/firebase/firebase.function.ts"],"names":[],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"firebase.function.js","sourceRoot":"","sources":["../../../../../../../packages/firebase-server/test/src/lib/firebase/firebase.function.ts"],"names":[],"mappings":";;;AA8BA,SAAgB,iCAAiC,CAAC,QAAsB;IACtE,MAAM,OAAO,GAAsC;QACjD,mBAAmB,CAAC,CAAC;YACnB,OAAO,QAAQ,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;QAC1B,CAAC;QACD,mBAAmB,CAAC,CAAC;YACnB,OAAO,QAAQ,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;QAC1B,CAAC;QACD,qBAAqB,CAAC,CAAC;YACrB,MAAM,oBAAoB,GAAG,IAAI,CAAC,mBAAmB,CAAC,CAAC,CAAC,CAAC;YAEzD,OAAO,CAAC,IAAI,EAAE,OAAO,EAAE,EAAE,CACvB,oBAAoB,CAAC,gCAChB,OAAO,KACV,IAAI,GACE,CAAC,CAAC;QACd,CAAC;QACD,oBAAoB;YAClB,MAAM,IAAI,KAAK,CAAC,oBAAoB,CAAC,CAAC;QACxC,CAAC;KACF,CAAC;IAEF,OAAO,OAAO,CAAC;AACjB,CAAC;AAvBD,8EAuBC;AAED,SAAgB,2BAA2B,CAAyE,OAA0C,EAAE,MAAiB;IAC/K,OAAO,GAAG,EAAE,CAAC,OAAO,CAAC,mBAAmB,CAAC,MAAM,EAAE,CAAC,CAAC;AACrD,CAAC;AAFD,kEAEC;AAED,SAAgB,2BAA2B,CAAqG,OAA0C,EAAE,MAAiB;IAC3M,OAAO,GAAG,EAAE,CAAC,OAAO,CAAC,mBAAmB,CAAC,MAAM,EAAE,CAAC,CAAC;AACrD,CAAC;AAFD,kEAEC"}
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import { TransformAndValidateFunctionResultFactory, TransformAndValidateObjectFactory } from '@dereekb/model';
|
|
2
|
-
/**
|
|
3
|
-
* Context used for transforming content.
|
|
4
|
-
*/
|
|
5
|
-
export interface FirebaseServerActionsTransformContext {
|
|
6
|
-
readonly firebaseServerActionTransformFactory: TransformAndValidateObjectFactory;
|
|
7
|
-
readonly firebaseServerActionTransformFunctionFactory: TransformAndValidateFunctionResultFactory;
|
|
8
|
-
}
|
|
9
|
-
export declare function firebaseServerActionsTransformContext(): FirebaseServerActionsTransformContext;
|
|
10
|
-
export declare function firebaseServerActionsTransformFactory(): TransformAndValidateObjectFactory;
|
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.firebaseServerActionsTransformFactory = exports.firebaseServerActionsTransformContext = void 0;
|
|
4
|
-
const model_1 = require("@dereekb/model");
|
|
5
|
-
const common_1 = require("@nestjs/common");
|
|
6
|
-
const firebase_functions_1 = require("firebase-functions");
|
|
7
|
-
function firebaseServerActionsTransformContext() {
|
|
8
|
-
const firebaseServerActionTransformFactory = firebaseServerActionsTransformFactory();
|
|
9
|
-
const firebaseServerActionTransformFunctionFactory = (0, model_1.toTransformAndValidateFunctionResultFactory)(firebaseServerActionTransformFactory);
|
|
10
|
-
return {
|
|
11
|
-
firebaseServerActionTransformFactory,
|
|
12
|
-
firebaseServerActionTransformFunctionFactory
|
|
13
|
-
};
|
|
14
|
-
}
|
|
15
|
-
exports.firebaseServerActionsTransformContext = firebaseServerActionsTransformContext;
|
|
16
|
-
function firebaseServerActionsTransformFactory() {
|
|
17
|
-
const nestValidationExceptionFactory = new common_1.ValidationPipe().createExceptionFactory();
|
|
18
|
-
return (0, model_1.transformAndValidateObjectFactory)({
|
|
19
|
-
handleValidationError: (validationError) => {
|
|
20
|
-
const nestError = nestValidationExceptionFactory(validationError);
|
|
21
|
-
const details = nestError.getResponse();
|
|
22
|
-
throw new firebase_functions_1.https.HttpsError('invalid-argument', 'Parameters validation check failed.', details);
|
|
23
|
-
}
|
|
24
|
-
});
|
|
25
|
-
}
|
|
26
|
-
exports.firebaseServerActionsTransformFactory = firebaseServerActionsTransformFactory;
|
|
27
|
-
//# sourceMappingURL=transform.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"transform.js","sourceRoot":"","sources":["../../../../../../../packages/firebase-server/src/lib/nest/function/transform.ts"],"names":[],"mappings":";;;AACA,0CAA8L;AAC9L,2CAA+D;AAC/D,2DAA2C;AAU3C,SAAgB,qCAAqC;IACnD,MAAM,oCAAoC,GAAG,qCAAqC,EAAE,CAAC;IACrF,MAAM,4CAA4C,GAAG,IAAA,mDAA2C,EAAC,oCAAoC,CAAC,CAAC;IAEvI,OAAO;QACL,oCAAoC;QACpC,4CAA4C;KAC7C,CAAC;AACJ,CAAC;AARD,sFAQC;AAED,SAAgB,qCAAqC;IACnD,MAAM,8BAA8B,GAAG,IAAI,uBAAc,EAAE,CAAC,sBAAsB,EAAE,CAAC;IAErF,OAAO,IAAA,yCAAiC,EAAC;QACvC,qBAAqB,EAAE,CAAC,eAAkC,EAAE,EAAE;YAC5D,MAAM,SAAS,GAAG,8BAA8B,CAAC,eAAe,CAAC,CAAC;YAClE,MAAM,OAAO,GAAI,SAA2B,CAAC,WAAW,EAAE,CAAC;YAC3D,MAAM,IAAI,0BAAK,CAAC,UAAU,CAAC,kBAAkB,EAAE,qCAAqC,EAAE,OAAO,CAAC,CAAC;QACjG,CAAC;KACF,CAAC,CAAC;AACL,CAAC;AAVD,sFAUC"}
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import { CallableContextWithAuthData } from '../../../function/context';
|
|
2
|
-
import { OnCallWithNestContext } from './call';
|
|
3
|
-
export declare type OnCallWithAuthorizedNestContext<C, I = unknown, O = unknown> = (nestContext: C, data: I, context: CallableContextWithAuthData) => O;
|
|
4
|
-
/**
|
|
5
|
-
* Creates an OnCallWithNestContext wrapper that validates the input CallableContext to assert the context has auth data before entering the function.
|
|
6
|
-
*
|
|
7
|
-
* @param fn
|
|
8
|
-
* @returns
|
|
9
|
-
*/
|
|
10
|
-
export declare function inAuthContext<C, I, O>(fn: OnCallWithAuthorizedNestContext<C, I, O>): OnCallWithNestContext<C, I, O>;
|
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.inAuthContext = void 0;
|
|
4
|
-
const context_1 = require("../../../function/context");
|
|
5
|
-
const error_1 = require("../../../function/error");
|
|
6
|
-
/**
|
|
7
|
-
* Creates an OnCallWithNestContext wrapper that validates the input CallableContext to assert the context has auth data before entering the function.
|
|
8
|
-
*
|
|
9
|
-
* @param fn
|
|
10
|
-
* @returns
|
|
11
|
-
*/
|
|
12
|
-
function inAuthContext(fn) {
|
|
13
|
-
return (nestContext, data, context) => {
|
|
14
|
-
if ((0, context_1.isContextWithAuthData)(context)) {
|
|
15
|
-
return fn(nestContext, data, context);
|
|
16
|
-
}
|
|
17
|
-
else {
|
|
18
|
-
throw (0, error_1.unauthenticatedContextHasNoUidError)();
|
|
19
|
-
}
|
|
20
|
-
};
|
|
21
|
-
}
|
|
22
|
-
exports.inAuthContext = inAuthContext;
|
|
23
|
-
//# sourceMappingURL=call.utility.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"call.utility.js","sourceRoot":"","sources":["../../../../../../../../packages/firebase-server/src/lib/nest/function/v1/call.utility.ts"],"names":[],"mappings":";;;AACA,uDAA+F;AAC/F,mDAA8E;AAK9E;;;;;GAKG;AACH,SAAgB,aAAa,CAAU,EAA4C;IACjF,OAAO,CAAC,WAAc,EAAE,IAAO,EAAE,OAAwC,EAAE,EAAE;QAC3E,IAAI,IAAA,+BAAqB,EAAC,OAAO,CAAC,EAAE;YAClC,OAAO,EAAE,CAAC,WAAW,EAAE,IAAI,EAAE,OAAO,CAAC,CAAC;SACvC;aAAM;YACL,MAAM,IAAA,2CAAmC,GAAE,CAAC;SAC7C;IACH,CAAC,CAAC;AACJ,CAAC;AARD,sCAQC"}
|
|
File without changes
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"model.api.js","sourceRoot":"","sources":["../../../../../../../packages/firebase-server/src/lib/nest/model/model.api.ts"],"names":[],"mappings":""}
|