@dereekb/firebase-server 5.2.1 → 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.
Files changed (98) hide show
  1. package/CHANGELOG.md +41 -0
  2. package/package.json +13 -13
  3. package/src/lib/auth/auth.context.d.ts +7 -0
  4. package/src/lib/auth/auth.context.js +12 -0
  5. package/src/lib/auth/auth.context.js.map +1 -0
  6. package/src/lib/auth/auth.service.d.ts +19 -2
  7. package/src/lib/auth/auth.service.js +20 -2
  8. package/src/lib/auth/auth.service.js.map +1 -1
  9. package/src/lib/auth/index.d.ts +1 -0
  10. package/src/lib/auth/index.js +1 -1
  11. package/src/lib/auth/index.js.map +1 -1
  12. package/src/lib/firestore/driver.accessor.js +1 -0
  13. package/src/lib/firestore/driver.accessor.js.map +1 -1
  14. package/src/lib/firestore/driver.query.js +6 -1
  15. package/src/lib/firestore/driver.query.js.map +1 -1
  16. package/src/lib/function/context.d.ts +3 -3
  17. package/src/lib/function/context.js.map +1 -1
  18. package/src/lib/function/error.d.ts +3 -0
  19. package/src/lib/function/error.js +10 -1
  20. package/src/lib/function/error.js.map +1 -1
  21. package/src/lib/nest/function/call.d.ts +23 -0
  22. package/src/lib/nest/function/call.js +28 -0
  23. package/src/lib/nest/function/call.js.map +1 -0
  24. package/src/lib/nest/function/context.d.ts +9 -1
  25. package/src/lib/nest/function/context.js +25 -3
  26. package/src/lib/nest/function/context.js.map +1 -1
  27. package/src/lib/nest/function/index.d.ts +2 -1
  28. package/src/lib/nest/function/index.js +2 -1
  29. package/src/lib/nest/function/index.js.map +1 -1
  30. package/src/lib/nest/function/nest.d.ts +19 -0
  31. package/src/lib/nest/function/nest.js +12 -0
  32. package/src/lib/nest/function/nest.js.map +1 -0
  33. package/src/lib/nest/function/v1/call.d.ts +5 -11
  34. package/src/lib/nest/function/v1/call.js +9 -3
  35. package/src/lib/nest/function/v1/call.js.map +1 -1
  36. package/src/lib/nest/function/v1/event.d.ts +14 -9
  37. package/src/lib/nest/function/v1/event.js +3 -2
  38. package/src/lib/nest/function/v1/event.js.map +1 -1
  39. package/src/lib/nest/function/v1/index.d.ts +0 -1
  40. package/src/lib/nest/function/v1/index.js +0 -1
  41. package/src/lib/nest/function/v1/index.js.map +1 -1
  42. package/src/lib/nest/function/v2/blocking.d.ts +8 -6
  43. package/src/lib/nest/function/v2/blocking.js +1 -1
  44. package/src/lib/nest/function/v2/blocking.js.map +1 -1
  45. package/src/lib/nest/function/v2/call.d.ts +3 -12
  46. package/src/lib/nest/function/v2/call.js +3 -2
  47. package/src/lib/nest/function/v2/call.js.map +1 -1
  48. package/src/lib/nest/function/v2/event.d.ts +8 -6
  49. package/src/lib/nest/function/v2/event.js +1 -1
  50. package/src/lib/nest/function/v2/event.js.map +1 -1
  51. package/src/lib/nest/function/v2/taskqueue.d.ts +9 -7
  52. package/src/lib/nest/function/v2/taskqueue.js +1 -1
  53. package/src/lib/nest/function/v2/taskqueue.js.map +1 -1
  54. package/src/lib/nest/index.d.ts +1 -0
  55. package/src/lib/nest/index.js +1 -0
  56. package/src/lib/nest/index.js.map +1 -1
  57. package/src/lib/nest/middleware/webhook.js.map +1 -1
  58. package/src/lib/nest/model/create.model.function.d.ts +16 -0
  59. package/src/lib/nest/model/create.model.function.js +37 -0
  60. package/src/lib/nest/model/create.model.function.js.map +1 -0
  61. package/src/lib/nest/model/delete.model.function.d.ts +16 -0
  62. package/src/lib/nest/model/delete.model.function.js +37 -0
  63. package/src/lib/nest/model/delete.model.function.js.map +1 -0
  64. package/src/lib/nest/model/index.d.ts +4 -0
  65. package/src/lib/nest/model/index.js +8 -0
  66. package/src/lib/nest/model/index.js.map +1 -0
  67. package/src/lib/nest/model/permission.error.d.ts +2 -0
  68. package/src/lib/nest/model/permission.error.js +20 -0
  69. package/src/lib/nest/model/permission.error.js.map +1 -0
  70. package/src/lib/nest/model/update.model.function.d.ts +16 -0
  71. package/src/lib/nest/model/update.model.function.js +37 -0
  72. package/src/lib/nest/model/update.model.function.js.map +1 -0
  73. package/src/lib/nest/nest.provider.d.ts +36 -1
  74. package/src/lib/nest/nest.provider.js +53 -1
  75. package/src/lib/nest/nest.provider.js.map +1 -1
  76. package/test/CHANGELOG.md +32 -0
  77. package/test/package.json +10 -10
  78. package/test/src/lib/firebase/firebase.admin.auth.d.ts +7 -6
  79. package/test/src/lib/firebase/firebase.admin.auth.js.map +1 -1
  80. package/test/src/lib/firebase/firebase.admin.collection.d.ts +5 -5
  81. package/test/src/lib/firebase/firebase.admin.function.d.ts +1 -2
  82. package/test/src/lib/firebase/firebase.admin.nest.function.d.ts +1 -2
  83. package/test/src/lib/firebase/firebase.admin.nest.function.js.map +1 -1
  84. package/test/src/lib/firebase/firebase.function.d.ts +5 -2
  85. package/test/src/lib/firebase/firebase.function.js +4 -0
  86. package/test/src/lib/firebase/firebase.function.js.map +1 -1
  87. package/test/src/lib/firebase/firebase.js +1 -1
  88. package/test/src/lib/firebase/firebase.js.map +1 -1
  89. package/test/src/lib/firestore/firestore.d.ts +1 -2
  90. package/src/lib/auth/auth.user.d.ts +0 -0
  91. package/src/lib/auth/auth.user.js +0 -2
  92. package/src/lib/auth/auth.user.js.map +0 -1
  93. package/src/lib/nest/function/transform.d.ts +0 -10
  94. package/src/lib/nest/function/transform.js +0 -27
  95. package/src/lib/nest/function/transform.js.map +0 -1
  96. package/src/lib/nest/function/v1/call.utility.d.ts +0 -10
  97. package/src/lib/nest/function/v1/call.utility.js +0 -23
  98. package/src/lib/nest/function/v1/call.utility.js.map +0 -1
@@ -1,7 +1,13 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.onCallWithNestContextFactory = exports.onCallWithNestApplicationFactory = void 0;
3
+ exports.onCallWithNestContextFactory = exports.onCallWithNestApplicationFactory = exports.makeOnCallWithNestApplicationRequest = void 0;
4
4
  const functions = require("firebase-functions");
5
+ const call_1 = require("../call");
6
+ function makeOnCallWithNestApplicationRequest(nestApplication, data, context) {
7
+ return Object.assign(Object.assign({}, context), { nestApplication,
8
+ data });
9
+ }
10
+ exports.makeOnCallWithNestApplicationRequest = makeOnCallWithNestApplicationRequest;
5
11
  /**
6
12
  * Creates a factory for generating OnCallWithNestApplication functions.
7
13
  *
@@ -10,7 +16,7 @@ const functions = require("firebase-functions");
10
16
  */
11
17
  function onCallWithNestApplicationFactory() {
12
18
  return (fn) => {
13
- return (nestAppPromiseGetter) => functions.https.onCall((data, context) => nestAppPromiseGetter().then((x) => fn(x, data, context)));
19
+ return (nestAppPromiseGetter) => functions.https.onCall((data, context) => nestAppPromiseGetter().then((x) => fn(makeOnCallWithNestApplicationRequest(x, data, context))));
14
20
  };
15
21
  }
16
22
  exports.onCallWithNestApplicationFactory = onCallWithNestApplicationFactory;
@@ -22,7 +28,7 @@ exports.onCallWithNestApplicationFactory = onCallWithNestApplicationFactory;
22
28
  * @returns
23
29
  */
24
30
  function onCallWithNestContextFactory(appFactory, makeNestContext) {
25
- return (fn) => appFactory((nest, data, context) => fn(makeNestContext(nest), data, context));
31
+ return (fn) => appFactory((request) => fn((0, call_1.setNestContextOnRequest)(makeNestContext, request)));
26
32
  }
27
33
  exports.onCallWithNestContextFactory = onCallWithNestContextFactory;
28
34
  //# sourceMappingURL=call.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"call.js","sourceRoot":"","sources":["../../../../../../../../packages/firebase-server/src/lib/nest/function/v1/call.ts"],"names":[],"mappings":";;;AAAA,gDAAgD;AAkBhD;;;;;GAKG;AACH,SAAgB,gCAAgC;IAC9C,OAAO,CAAO,EAAmC,EAAE,EAAE;QACnD,OAAO,CAAC,oBAAkD,EAAE,EAAE,CAAC,SAAS,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC,IAAO,EAAE,OAAwC,EAAE,EAAE,CAAC,oBAAoB,EAAE,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,EAAE,CAAC,CAAC,EAAE,IAAI,EAAE,OAAO,CAAC,CAAC,CAAC,CAAC;IACzM,CAAC,CAAC;AACJ,CAAC;AAJD,4EAIC;AAYD;;;;;;GAMG;AACH,SAAgB,4BAA4B,CAAI,UAA4C,EAAE,eAAmC;IAC/H,OAAO,CAAO,EAAkC,EAAE,EAAE,CAAC,UAAU,CAAO,CAAC,IAAI,EAAE,IAAI,EAAE,OAAO,EAAE,EAAE,CAAC,EAAE,CAAC,eAAe,CAAC,IAAI,CAAC,EAAE,IAAI,EAAE,OAAO,CAAC,CAAC,CAAC;AAC3I,CAAC;AAFD,oEAEC"}
1
+ {"version":3,"file":"call.js","sourceRoot":"","sources":["../../../../../../../../packages/firebase-server/src/lib/nest/function/v1/call.ts"],"names":[],"mappings":";;;AAAA,gDAAgD;AAIhD,kCAAsI;AAEtI,SAAgB,oCAAoC,CAAI,eAAwC,EAAE,IAAO,EAAE,OAAwC;IACjJ,uCACK,OAAO,KACV,eAAe;QACf,IAAI,IACJ;AACJ,CAAC;AAND,oFAMC;AAUD;;;;;GAKG;AACH,SAAgB,gCAAgC;IAC9C,OAAO,CAAO,EAAmC,EAAE,EAAE;QACnD,OAAO,CAAC,oBAAkD,EAAE,EAAE,CAAC,SAAS,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC,IAAO,EAAE,OAAwC,EAAE,EAAE,CAAC,oBAAoB,EAAE,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,EAAE,CAAC,oCAAoC,CAAC,CAAC,EAAE,IAAI,EAAE,OAAO,CAAC,CAAC,CAAC,CAAC,CAAC;IAC/O,CAAC,CAAC;AACJ,CAAC;AAJD,4EAIC;AAOD;;;;;;GAMG;AACH,SAAgB,4BAA4B,CAAI,UAA4C,EAAE,eAAmC;IAC/H,OAAO,CAAO,EAAkC,EAAE,EAAE,CAAC,UAAU,CAAO,CAAC,OAAO,EAAE,EAAE,CAAC,EAAE,CAAC,IAAA,8BAAuB,EAAC,eAAe,EAAE,OAAO,CAAC,CAAC,CAAC,CAAC;AAC5I,CAAC;AAFD,oEAEC"}
@@ -1,11 +1,16 @@
1
1
  import { PromiseOrValue } from '@dereekb/util';
2
- import { INestApplicationContext } from '@nestjs/common';
3
2
  import * as functions from 'firebase-functions';
4
3
  import { EventContext } from 'firebase-functions';
5
4
  import { MakeNestContext, NestApplicationFunctionFactory } from '../../nest.provider';
6
- export declare type FirestoreEventHandler<I = unknown, O = unknown> = (data: I, context: EventContext) => PromiseOrValue<O>;
7
- export declare type NestApplicationEventHandler<I = unknown, O = unknown> = (nest: INestApplicationContext, data: I, context: EventContext) => PromiseOrValue<O>;
8
- export declare type NestApplicationEventHandlerBuilder<I = unknown, O = unknown> = (handler: NestApplicationEventHandler<I, O>) => FirestoreEventHandler<I, O>;
5
+ import { NestApplicationContextRequest, NestContextRequest } from '../nest';
6
+ export declare type EventContextWithData<I> = EventContext & {
7
+ data: I;
8
+ };
9
+ export declare type FirebaseEventNestApplicationRequest<I> = NestApplicationContextRequest<EventContextWithData<I>>;
10
+ export declare type FirebaseEventNestContextRequest<N, I> = NestContextRequest<N, EventContextWithData<I>>;
11
+ export declare type FirebaseEventContextHandler<I = unknown, O = unknown> = (data: I, context: EventContext) => PromiseOrValue<O>;
12
+ export declare type NestApplicationEventHandler<I = unknown, O = unknown> = (event: FirebaseEventNestApplicationRequest<I>) => PromiseOrValue<O>;
13
+ export declare type NestApplicationEventHandlerBuilder<I = unknown, O = unknown> = (handler: NestApplicationEventHandler<I, O>) => FirebaseEventContextHandler<I, O>;
9
14
  export declare type OnEventWithNestApplicationBuilder<I = unknown, O = unknown> = (nest: NestApplicationEventHandlerBuilder<I, O>) => functions.CloudFunction<I>;
10
15
  /**
11
16
  * Factory function for generating a CloudFunctionHandler via a NestApplicationCloudFunctionHandler.
@@ -18,16 +23,16 @@ export declare type OnEventWithNestApplicationFactory = <I, O>(fn: OnEventWithNe
18
23
  * @returns
19
24
  */
20
25
  export declare function onEventWithNestApplicationFactory(): OnEventWithNestApplicationFactory;
21
- export declare type NestContextEventHandler<C, I = unknown, O = unknown> = (nest: C, data: I, context: EventContext) => Promise<O>;
22
- export declare type NestContextEventHandlerBuilder<C, I = unknown, O = unknown> = (handler: NestContextEventHandler<C, I, O>) => FirestoreEventHandler<I, O>;
26
+ export declare type NestContextEventHandler<N, I = unknown, O = unknown> = (request: FirebaseEventNestContextRequest<N, I>) => Promise<O>;
27
+ export declare type NestContextEventHandlerBuilder<N, I = unknown, O = unknown> = (handler: NestContextEventHandler<N, I, O>) => FirebaseEventContextHandler<I, O>;
23
28
  /**
24
29
  * Runnable function that is passed an arbitrary nest context object in addition to the usual data/context provided by firebase.
25
30
  */
26
- export declare type OnEventWithNestContextBuilder<C, I = unknown, O = unknown> = (nest: NestContextEventHandlerBuilder<C, I, O>) => functions.CloudFunction<I>;
31
+ export declare type OnEventWithNestContextBuilder<N, I = unknown, O = unknown> = (nest: NestContextEventHandlerBuilder<N, I, O>) => functions.CloudFunction<I>;
27
32
  /**
28
33
  * Factory function for generating a firebase CloudFunction for a specific event.
29
34
  */
30
- export declare type OnEventWithNestContextFactory<C> = <I, O = unknown>(fn: OnEventWithNestContextBuilder<C, I, O>) => NestApplicationFunctionFactory<functions.CloudFunction<I>>;
35
+ export declare type OnEventWithNestContextFactory<N> = <I, O = unknown>(fn: OnEventWithNestContextBuilder<N, I, O>) => NestApplicationFunctionFactory<functions.CloudFunction<I>>;
31
36
  /**
32
37
  * Creates a factory for generating OnCallWithNestContext functions with a nest context object that is generated by the input function.
33
38
  *
@@ -35,4 +40,4 @@ export declare type OnEventWithNestContextFactory<C> = <I, O = unknown>(fn: OnEv
35
40
  * @param makeNestContext
36
41
  * @returns
37
42
  */
38
- export declare function onEventWithNestContextFactory<C>(makeNestContext: MakeNestContext<C>): OnEventWithNestContextFactory<C>;
43
+ export declare function onEventWithNestContextFactory<N>(makeNestContext: MakeNestContext<N>): OnEventWithNestContextFactory<N>;
@@ -11,7 +11,8 @@ function onEventWithNestApplicationFactory() {
11
11
  return (fn) => {
12
12
  return (nestAppPromiseGetter) => {
13
13
  const handlerBuilder = (handler) => {
14
- const fnHandler = (data, context) => nestAppPromiseGetter().then((nest) => handler(nest, data, context));
14
+ const fnHandler = (data, context) => nestAppPromiseGetter().then((nestApplication) => handler(Object.assign(Object.assign({}, context), { data,
15
+ nestApplication })));
15
16
  return fnHandler;
16
17
  };
17
18
  return fn(handlerBuilder);
@@ -30,7 +31,7 @@ function onEventWithNestContextFactory(makeNestContext) {
30
31
  return (fn) => {
31
32
  return (nestAppPromiseGetter) => {
32
33
  const handlerBuilder = (handler) => {
33
- const fnHandler = (data, context) => nestAppPromiseGetter().then((nest) => handler(makeNestContext(nest), data, context));
34
+ const fnHandler = (data, context) => nestAppPromiseGetter().then((nestApplication) => handler(Object.assign(Object.assign({}, context), { data, nest: makeNestContext(nestApplication) })));
34
35
  return fnHandler;
35
36
  };
36
37
  return fn(handlerBuilder);
@@ -1 +1 @@
1
- {"version":3,"file":"event.js","sourceRoot":"","sources":["../../../../../../../../packages/firebase-server/src/lib/nest/function/v1/event.ts"],"names":[],"mappings":";;;AAkBA;;;;;GAKG;AACH,SAAgB,iCAAiC;IAC/C,OAAO,CAAO,EAA2C,EAAE,EAAE;QAC3D,OAAO,CAAC,oBAAkD,EAAE,EAAE;YAC5D,MAAM,cAAc,GAA6C,CAAC,OAAO,EAAE,EAAE;gBAC3E,MAAM,SAAS,GAAgC,CAAC,IAAI,EAAE,OAAO,EAAE,EAAE,CAAC,oBAAoB,EAAE,CAAC,IAAI,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,OAAO,CAAC,IAAI,EAAE,IAAI,EAAE,OAAO,CAAC,CAAC,CAAC;gBACtI,OAAO,SAAS,CAAC;YACnB,CAAC,CAAC;YAEF,OAAO,EAAE,CAAC,cAAc,CAAC,CAAC;QAC5B,CAAC,CAAC;IACJ,CAAC,CAAC;AACJ,CAAC;AAXD,8EAWC;AAeD;;;;;;GAMG;AACH,SAAgB,6BAA6B,CAAI,eAAmC;IAClF,OAAO,CAAiB,EAA0C,EAAE,EAAE;QACpE,OAAO,CAAC,oBAAkD,EAAE,EAAE;YAC5D,MAAM,cAAc,GAA4C,CAAC,OAAO,EAAE,EAAE;gBAC1E,MAAM,SAAS,GAAgC,CAAC,IAAI,EAAE,OAAO,EAAE,EAAE,CAAC,oBAAoB,EAAE,CAAC,IAAI,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,OAAO,CAAC,eAAe,CAAC,IAAI,CAAC,EAAE,IAAI,EAAE,OAAO,CAAC,CAAC,CAAC;gBACvJ,OAAO,SAAS,CAAC;YACnB,CAAC,CAAC;YAEF,OAAO,EAAE,CAAC,cAAc,CAAC,CAAC;QAC5B,CAAC,CAAC;IACJ,CAAC,CAAC;AACJ,CAAC;AAXD,sEAWC"}
1
+ {"version":3,"file":"event.js","sourceRoot":"","sources":["../../../../../../../../packages/firebase-server/src/lib/nest/function/v1/event.ts"],"names":[],"mappings":";;;AAwBA;;;;;GAKG;AACH,SAAgB,iCAAiC;IAC/C,OAAO,CAAO,EAA2C,EAAE,EAAE;QAC3D,OAAO,CAAC,oBAAkD,EAAE,EAAE;YAC5D,MAAM,cAAc,GAA6C,CAAC,OAAO,EAAE,EAAE;gBAC3E,MAAM,SAAS,GAAsC,CAAC,IAAI,EAAE,OAAO,EAAE,EAAE,CACrE,oBAAoB,EAAE,CAAC,IAAI,CAAC,CAAC,eAAe,EAAE,EAAE,CAC9C,OAAO,iCACF,OAAO,KACV,IAAI;oBACJ,eAAe,IACf,CACH,CAAC;gBACJ,OAAO,SAAS,CAAC;YACnB,CAAC,CAAC;YAEF,OAAO,EAAE,CAAC,cAAc,CAAC,CAAC;QAC5B,CAAC,CAAC;IACJ,CAAC,CAAC;AACJ,CAAC;AAlBD,8EAkBC;AAeD;;;;;;GAMG;AACH,SAAgB,6BAA6B,CAAI,eAAmC;IAClF,OAAO,CAAiB,EAA0C,EAAE,EAAE;QACpE,OAAO,CAAC,oBAAkD,EAAE,EAAE;YAC5D,MAAM,cAAc,GAA4C,CAAC,OAAO,EAAE,EAAE;gBAC1E,MAAM,SAAS,GAAsC,CAAC,IAAI,EAAE,OAAO,EAAE,EAAE,CACrE,oBAAoB,EAAE,CAAC,IAAI,CAAC,CAAC,eAAe,EAAE,EAAE,CAC9C,OAAO,iCACF,OAAO,KACV,IAAI,EACJ,IAAI,EAAE,eAAe,CAAC,eAAe,CAAC,IACtC,CACH,CAAC;gBAEJ,OAAO,SAAS,CAAC;YACnB,CAAC,CAAC;YAEF,OAAO,EAAE,CAAC,cAAc,CAAC,CAAC;QAC5B,CAAC,CAAC;IACJ,CAAC,CAAC;AACJ,CAAC;AAnBD,sEAmBC"}
@@ -1,3 +1,2 @@
1
1
  export * from './call';
2
- export * from './call.utility';
3
2
  export * from './event';
@@ -2,6 +2,5 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  const tslib_1 = require("tslib");
4
4
  tslib_1.__exportStar(require("./call"), exports);
5
- tslib_1.__exportStar(require("./call.utility"), exports);
6
5
  tslib_1.__exportStar(require("./event"), exports);
7
6
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../../../../packages/firebase-server/src/lib/nest/function/v1/index.ts"],"names":[],"mappings":";;;AAAA,iDAAuB;AACvB,yDAA+B;AAC/B,kDAAwB"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../../../../packages/firebase-server/src/lib/nest/function/v1/index.ts"],"names":[],"mappings":";;;AAAA,iDAAuB;AACvB,kDAAwB"}
@@ -1,14 +1,16 @@
1
1
  import { PromiseOrValue } from '@dereekb/util';
2
2
  import { BlockingFunction } from 'firebase-functions';
3
3
  import { MakeNestContext, NestApplicationFunctionFactory } from '../../nest.provider';
4
- export declare type BlockingFunctionHandler<E, O = unknown> = (event: E) => PromiseOrValue<O>;
5
- export declare type NestContextBlockingFunctionHandler<C, E, O = unknown> = (nest: C, event: E) => PromiseOrValue<O>;
6
- export declare type NestContextBlockingFunctionHandlerBuilder<C, E, O = unknown> = (handler: NestContextBlockingFunctionHandler<C, E, O>) => BlockingFunctionHandler<E, O>;
7
- export declare type BlockingFunctionHandlerWithNestContextBuilder<C, E, O = unknown> = (nest: NestContextBlockingFunctionHandlerBuilder<C, E, O>) => BlockingFunction;
4
+ import { NestContextRequest } from '../nest';
5
+ export declare type BlockingFunctionNestContextRequest<N, E extends object> = NestContextRequest<N, E>;
6
+ export declare type BlockingFunctionHandler<E extends object, O = unknown> = (event: E) => PromiseOrValue<O>;
7
+ export declare type NestContextBlockingFunctionHandler<N, E extends object, O = unknown> = (request: BlockingFunctionNestContextRequest<N, E>) => PromiseOrValue<O>;
8
+ export declare type NestContextBlockingFunctionHandlerBuilder<N, E extends object, O = unknown> = (handler: NestContextBlockingFunctionHandler<N, E, O>) => BlockingFunctionHandler<E, O>;
9
+ export declare type BlockingFunctionHandlerWithNestContextBuilder<N, E extends object, O = unknown> = (nest: NestContextBlockingFunctionHandlerBuilder<N, E, O>) => BlockingFunction;
8
10
  /**
9
11
  * Factory function for generating a firebase BlockingFunction for a specific event.
10
12
  */
11
- export declare type BlockingFunctionHandlerWithNestContextFactory<C> = <E, O = unknown>(fn: BlockingFunctionHandlerWithNestContextBuilder<C, E, O>) => NestApplicationFunctionFactory<BlockingFunction>;
13
+ export declare type BlockingFunctionHandlerWithNestContextFactory<N> = <E extends object, O = unknown>(fn: BlockingFunctionHandlerWithNestContextBuilder<N, E, O>) => NestApplicationFunctionFactory<BlockingFunction>;
12
14
  /**
13
15
  * Creates a BlockingFunctionHandlerWithNestContextFactory.
14
16
  *
@@ -16,4 +18,4 @@ export declare type BlockingFunctionHandlerWithNestContextFactory<C> = <E, O = u
16
18
  * @param makeNestContext
17
19
  * @returns
18
20
  */
19
- export declare function blockingFunctionHandlerWithNestContextFactory<C>(makeNestContext: MakeNestContext<C>): BlockingFunctionHandlerWithNestContextFactory<C>;
21
+ export declare function blockingFunctionHandlerWithNestContextFactory<N>(makeNestContext: MakeNestContext<N>): BlockingFunctionHandlerWithNestContextFactory<N>;
@@ -12,7 +12,7 @@ function blockingFunctionHandlerWithNestContextFactory(makeNestContext) {
12
12
  return (fn) => {
13
13
  return (nestAppPromiseGetter) => {
14
14
  const handlerBuilder = (handler) => {
15
- const fnHandler = (event) => nestAppPromiseGetter().then((nest) => handler(makeNestContext(nest), event));
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":"blocking.js","sourceRoot":"","sources":["../../../../../../../../packages/firebase-server/src/lib/nest/function/v2/blocking.ts"],"names":[],"mappings":";;;AAeA;;;;;;GAMG;AACH,SAAgB,6CAA6C,CAAI,eAAmC;IAClG,OAAO,CAAO,EAA0D,EAAE,EAAE;QAC1E,OAAO,CAAC,oBAAkD,EAAE,EAAE;YAC5D,MAAM,cAAc,GAAuD,CAAC,OAAoD,EAAE,EAAE;gBAClI,MAAM,SAAS,GAAkC,CAAC,KAAQ,EAAE,EAAE,CAAC,oBAAoB,EAAE,CAAC,IAAI,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,OAAO,CAAC,eAAe,CAAC,IAAI,CAAC,EAAE,KAAK,CAAC,CAAC,CAAC;gBAC5I,OAAO,SAAS,CAAC;YACnB,CAAC,CAAC;YAEF,OAAO,EAAE,CAAC,cAAc,CAAC,CAAC;QAC5B,CAAC,CAAC;IACJ,CAAC,CAAC;AACJ,CAAC;AAXD,sGAWC"}
1
+ {"version":3,"file":"blocking.js","sourceRoot":"","sources":["../../../../../../../../packages/firebase-server/src/lib/nest/function/v2/blocking.ts"],"names":[],"mappings":";;;AAoBA;;;;;;GAMG;AACH,SAAgB,6CAA6C,CAAI,eAAmC;IAClG,OAAO,CAAsB,EAA0D,EAAE,EAAE;QACzF,OAAO,CAAC,oBAAkD,EAAE,EAAE;YAC5D,MAAM,cAAc,GAAuD,CAAC,OAAoD,EAAE,EAAE;gBAClI,MAAM,SAAS,GAAkC,CAAC,KAAQ,EAAE,EAAE,CAC5D,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,sGAiBC"}
@@ -1,16 +1,11 @@
1
- import { INestApplicationContext } from '@nestjs/common';
2
- import { CallableRequest } from 'firebase-functions/v2/https';
3
1
  import { CallableHttpFunction } from '../../../function/type';
4
2
  import { MakeNestContext, NestApplicationFunctionFactory } from '../../nest.provider';
3
+ import { OnCallWithNestApplication, OnCallWithNestContext } from '../call';
5
4
  export declare type NestApplicationCallableHttpFunctionFactory<I, O = unknown> = NestApplicationFunctionFactory<CallableHttpFunction<I, O>>;
6
- /**
7
- * Runnable function that is passed an INestApplicationContext in addition to the usual data/context provided by firebase.
8
- */
9
- export declare type OnCallHandlerWithNestApplication<I = unknown, O = unknown> = (nest: INestApplicationContext, request: CallableRequest<I>) => O;
10
5
  /**
11
6
  * Factory function for generating a NestApplicationFunctionFactory for a HttpsFunctions/Runnable firebase function.
12
7
  */
13
- export declare type OnCallHandlerWithNestApplicationFactory = <I, O>(fn: OnCallHandlerWithNestApplication<I, O>) => NestApplicationCallableHttpFunctionFactory<I, O>;
8
+ export declare type OnCallHandlerWithNestApplicationFactory = <I, O>(fn: OnCallWithNestApplication<I, O>) => NestApplicationCallableHttpFunctionFactory<I, O>;
14
9
  /**
15
10
  * Creates a factory for generating OnCallWithNestApplication functions.
16
11
  *
@@ -18,14 +13,10 @@ export declare type OnCallHandlerWithNestApplicationFactory = <I, O>(fn: OnCallH
18
13
  * @returns
19
14
  */
20
15
  export declare function onCallHandlerWithNestApplicationFactory(): OnCallHandlerWithNestApplicationFactory;
21
- /**
22
- * Runnable function that is passed an arbitrary nest context object in addition to the usual data/context provided by firebase.
23
- */
24
- export declare type OnCallHandlerWithNestContext<C, I = unknown, O = unknown> = (nestContext: C, request: CallableRequest<I>) => O;
25
16
  /**
26
17
  * Factory function for generating HttpsFunctions/Runnable firebase function that returns the value from the input OnCallWithNestContext function.
27
18
  */
28
- export declare type OnCallHandlerWithNestContextFactory<C> = <I, O>(fn: OnCallHandlerWithNestContext<C, I, O>) => NestApplicationCallableHttpFunctionFactory<I>;
19
+ export declare type OnCallHandlerWithNestContextFactory<C> = <I, O>(fn: OnCallWithNestContext<C, I, O>) => NestApplicationCallableHttpFunctionFactory<I>;
29
20
  /**
30
21
  * Creates a factory for generating OnCallWithNestContext functions with a nest context object that is generated by the input function.
31
22
  *
@@ -2,6 +2,7 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.onCallHandlerWithNestContextFactory = exports.onCallHandlerWithNestApplicationFactory = void 0;
4
4
  const v2_1 = require("firebase-functions/v2");
5
+ const call_1 = require("../call");
5
6
  /**
6
7
  * Creates a factory for generating OnCallWithNestApplication functions.
7
8
  *
@@ -10,7 +11,7 @@ const v2_1 = require("firebase-functions/v2");
10
11
  */
11
12
  function onCallHandlerWithNestApplicationFactory() {
12
13
  return (fn) => {
13
- return (nestAppPromiseGetter) => v2_1.https.onCall((request) => nestAppPromiseGetter().then((x) => fn(x, request)));
14
+ return (nestAppPromiseGetter) => v2_1.https.onCall((request) => nestAppPromiseGetter().then((nestApplication) => fn(Object.assign(Object.assign({}, request), { nestApplication }))));
14
15
  };
15
16
  }
16
17
  exports.onCallHandlerWithNestApplicationFactory = onCallHandlerWithNestApplicationFactory;
@@ -22,7 +23,7 @@ exports.onCallHandlerWithNestApplicationFactory = onCallHandlerWithNestApplicati
22
23
  * @returns
23
24
  */
24
25
  function onCallHandlerWithNestContextFactory(appFactory, makeNestContext) {
25
- return (fn) => appFactory((nest, request) => fn(makeNestContext(nest), request));
26
+ return (fn) => appFactory((request) => fn((0, call_1.setNestContextOnRequest)(makeNestContext, request)));
26
27
  }
27
28
  exports.onCallHandlerWithNestContextFactory = onCallHandlerWithNestContextFactory;
28
29
  //# sourceMappingURL=call.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"call.js","sourceRoot":"","sources":["../../../../../../../../packages/firebase-server/src/lib/nest/function/v2/call.ts"],"names":[],"mappings":";;;AAEA,8CAA8C;AAmB9C;;;;;GAKG;AACH,SAAgB,uCAAuC;IACrD,OAAO,CAAO,EAA0C,EAAE,EAAE;QAC1D,OAAO,CAAC,oBAAkD,EAAE,EAAE,CAAC,UAAK,CAAC,MAAM,CAAC,CAAC,OAA2B,EAAE,EAAE,CAAC,oBAAoB,EAAE,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,EAAE,CAAC,CAAC,EAAE,OAAO,CAAC,CAAC,CAAC,CAAC;IACnK,CAAC,CAAC;AACJ,CAAC;AAJD,0FAIC;AAYD;;;;;;GAMG;AACH,SAAgB,mCAAmC,CAAI,UAAmD,EAAE,eAAmC;IAC7I,OAAO,CAAO,EAAyC,EAAE,EAAE,CAAC,UAAU,CAAO,CAAC,IAAI,EAAE,OAAO,EAAE,EAAE,CAAC,EAAE,CAAC,eAAe,CAAC,IAAI,CAAC,EAAE,OAAO,CAAC,CAAC,CAAC;AACtI,CAAC;AAFD,kFAEC"}
1
+ {"version":3,"file":"call.js","sourceRoot":"","sources":["../../../../../../../../packages/firebase-server/src/lib/nest/function/v2/call.ts"],"names":[],"mappings":";;;AACA,8CAA8C;AAG9C,kCAAoG;AAYpG;;;;;GAKG;AACH,SAAgB,uCAAuC;IACrD,OAAO,CAAO,EAAmC,EAAE,EAAE;QACnD,OAAO,CAAC,oBAAkD,EAAE,EAAE,CAC5D,UAAK,CAAC,MAAM,CAAC,CAAC,OAA2B,EAAE,EAAE,CAC3C,oBAAoB,EAAE,CAAC,IAAI,CAAC,CAAC,eAAe,EAAE,EAAE,CAC9C,EAAE,iCACG,OAAO,KACV,eAAe,IACf,CACH,CACF,CAAC;IACN,CAAC,CAAC;AACJ,CAAC;AAZD,0FAYC;AAMD;;;;;;GAMG;AACH,SAAgB,mCAAmC,CAAI,UAAmD,EAAE,eAAmC;IAC7I,OAAO,CAAO,EAAkC,EAAE,EAAE,CAAC,UAAU,CAAO,CAAC,OAAO,EAAE,EAAE,CAAC,EAAE,CAAC,IAAA,8BAAuB,EAAC,eAAe,EAAE,OAAO,CAAC,CAAC,CAAC,CAAC;AAC5I,CAAC;AAFD,kFAEC"}
@@ -1,15 +1,17 @@
1
1
  import { PromiseOrValue } from '@dereekb/util';
2
2
  import { CloudEvent, CloudFunction } from 'firebase-functions/v2';
3
3
  import { MakeNestContext, NestApplicationFunctionFactory } from '../../nest.provider';
4
+ import { NestContextRequest } from '../nest';
5
+ export declare type CloudEventNestContextRequest<N, E extends CloudEvent<unknown>> = NestContextRequest<N, E>;
4
6
  export declare type CloudEventHandler<E extends CloudEvent<unknown>, O = unknown> = (event: E) => PromiseOrValue<O>;
5
- export declare type NestContextCloudEventHandler<C, E extends CloudEvent<unknown>, O = unknown> = (nest: C, event: E) => PromiseOrValue<O>;
6
- export declare type NestContextCloudEventHandlerBuilder<C, E extends CloudEvent<unknown>, O = unknown> = (handler: NestContextCloudEventHandler<C, E, O>) => CloudEventHandler<E, O>;
7
- export declare type NestContextCloudEventHandlerWithData<C, I, O = unknown> = NestContextCloudEventHandler<C, CloudEvent<I>, O>;
8
- export declare type CloudEventHandlerWithNestContextBuilder<C, E extends CloudEvent<unknown>, O = unknown> = (nest: NestContextCloudEventHandlerBuilder<C, E, O>) => CloudFunction<E>;
7
+ export declare type NestContextCloudEventHandler<N, E extends CloudEvent<unknown>, O = unknown> = (request: CloudEventNestContextRequest<N, E>) => PromiseOrValue<O>;
8
+ export declare type NestContextCloudEventHandlerBuilder<N, E extends CloudEvent<unknown>, O = unknown> = (handler: NestContextCloudEventHandler<N, E, O>) => CloudEventHandler<E, O>;
9
+ export declare type NestContextCloudEventHandlerWithData<N, I, O = unknown> = NestContextCloudEventHandler<N, CloudEvent<I>, O>;
10
+ export declare type CloudEventHandlerWithNestContextBuilder<N, E extends CloudEvent<unknown>, O = unknown> = (nest: NestContextCloudEventHandlerBuilder<N, E, O>) => CloudFunction<E>;
9
11
  /**
10
12
  * Factory function for generating a firebase CloudFunction for a specific event.
11
13
  */
12
- export declare type CloudEventHandlerWithNestContextFactory<C> = <E extends CloudEvent<unknown>, O = unknown>(fn: CloudEventHandlerWithNestContextBuilder<C, E, O>) => NestApplicationFunctionFactory<CloudFunction<E>>;
14
+ export declare type CloudEventHandlerWithNestContextFactory<N> = <E extends CloudEvent<unknown>, O = unknown>(fn: CloudEventHandlerWithNestContextBuilder<N, E, O>) => NestApplicationFunctionFactory<CloudFunction<E>>;
13
15
  /**
14
16
  * Creates a CloudEventHandlerWithNestContextFactory.
15
17
  *
@@ -17,4 +19,4 @@ export declare type CloudEventHandlerWithNestContextFactory<C> = <E extends Clou
17
19
  * @param makeNestContext
18
20
  * @returns
19
21
  */
20
- export declare function cloudEventHandlerWithNestContextFactory<C>(makeNestContext: MakeNestContext<C>): CloudEventHandlerWithNestContextFactory<C>;
22
+ export declare function cloudEventHandlerWithNestContextFactory<N>(makeNestContext: MakeNestContext<N>): CloudEventHandlerWithNestContextFactory<N>;
@@ -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((nest) => handler(makeNestContext(nest), event));
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":";;;AAgBA;;;;;;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,CAAC,oBAAoB,EAAE,CAAC,IAAI,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,OAAO,CAAC,eAAe,CAAC,IAAI,CAAC,EAAE,KAAK,CAAC,CAAC,CAAC;gBACtI,OAAO,SAAS,CAAC;YACnB,CAAC,CAAC;YAEF,OAAO,EAAE,CAAC,cAAc,CAAC,CAAC;QAC5B,CAAC,CAAC;IACJ,CAAC,CAAC;AACJ,CAAC;AAXD,0FAWC"}
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
- export declare type TaskQueueFunctionHandler<E = unknown> = (event: E) => PromiseOrValue<void>;
5
- export declare type NestContextTaskQueueFunctionHandler<C, E = unknown> = (nest: C, event: E) => PromiseOrValue<void>;
6
- export declare type NestContextTaskQueueFunctionHandlerBuilder<C, E = unknown> = (handler: NestContextTaskQueueFunctionHandler<C, E>) => TaskQueueFunctionHandler<E>;
7
- export declare type TaskQueueFunctionHandlerWithNestContextBuilder<C, E = unknown> = (nest: NestContextTaskQueueFunctionHandlerBuilder<C, E>) => TaskQueueFunction<E>;
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<C> = <E = unknown>(fn: TaskQueueFunctionHandlerWithNestContextBuilder<C, E>) => NestApplicationFunctionFactory<TaskQueueFunction<E>>;
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<C>(makeNestContext: MakeNestContext<C>): TaskQueueFunctionHandlerWithNestContextFactory<C>;
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 = (event) => nestAppPromiseGetter().then((nest) => handler(makeNestContext(nest), event));
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":";;;AAeA;;;;;;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,KAAQ,EAAE,EAAE,CAAC,oBAAoB,EAAE,CAAC,IAAI,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,OAAO,CAAC,eAAe,CAAC,IAAI,CAAC,EAAE,KAAK,CAAC,CAAC,CAAC;gBAC1I,OAAO,SAAS,CAAC;YACnB,CAAC,CAAC;YAEF,OAAO,EAAE,CAAC,cAAc,CAAC,CAAC;QAC5B,CAAC,CAAC;IACJ,CAAC,CAAC;AACJ,CAAC;AAXD,wGAWC"}
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"}
@@ -1,4 +1,5 @@
1
1
  export * from './function';
2
2
  export * from './middleware';
3
+ export * from './model';
3
4
  export * from './app';
4
5
  export * from './nest.provider';
@@ -3,6 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  const tslib_1 = require("tslib");
4
4
  tslib_1.__exportStar(require("./function"), exports);
5
5
  tslib_1.__exportStar(require("./middleware"), exports);
6
+ tslib_1.__exportStar(require("./model"), exports);
6
7
  tslib_1.__exportStar(require("./app"), exports);
7
8
  tslib_1.__exportStar(require("./nest.provider"), exports);
8
9
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../../packages/firebase-server/src/lib/nest/index.ts"],"names":[],"mappings":";;;AAAA,qDAA2B;AAC3B,uDAA6B;AAC7B,gDAAsB;AACtB,0DAAgC"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../../packages/firebase-server/src/lib/nest/index.ts"],"names":[],"mappings":";;;AAAA,qDAA2B;AAC3B,uDAA6B;AAC7B,kDAAwB;AACxB,gDAAsB;AACtB,0DAAgC"}
@@ -1 +1 @@
1
- {"version":3,"file":"webhook.js","sourceRoot":"","sources":["../../../../../../../packages/firebase-server/src/lib/nest/middleware/webhook.ts"],"names":[],"mappings":";;;;AAAA,4CAAwE;AACxE,2CAAmF;AACnF,6DAAiE;AAEjE;;;;GAIG;AAEH,IAAa,wCAAwC,GAArD,MAAa,wCAAwC;IAArD;QACmB,WAAM,GAAG,IAAI,eAAM,CAAC,0CAA0C,CAAC,CAAC;IAMnF,CAAC;IAJQ,SAAS,CAAC,QAA4B;QAC3C,QAAQ,CAAC,KAAK,CAAC,8CAAyB,CAAC,CAAC,SAAS,CAAC,8CAAqC,CAAC,CAAC;QAC3F,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,4DAA4D,CAAC,CAAC;IAClF,CAAC;CACF,CAAA;AAPY,wCAAwC;IADpD,IAAA,eAAM,EAAC,EAAE,CAAC;GACE,wCAAwC,CAOpD;AAPY,4FAAwC"}
1
+ {"version":3,"file":"webhook.js","sourceRoot":"","sources":["../../../../../../../packages/firebase-server/src/lib/nest/middleware/webhook.ts"],"names":[],"mappings":";;;;AAAA,4CAAwE;AACxE,2CAAoE;AACpE,6DAAiE;AAEjE;;;;GAIG;AAEH,IAAa,wCAAwC,GAArD,MAAa,wCAAwC;IAArD;QACmB,WAAM,GAAG,IAAI,eAAM,CAAC,0CAA0C,CAAC,CAAC;IAMnF,CAAC;IAJQ,SAAS,CAAC,QAA4B;QAC3C,QAAQ,CAAC,KAAK,CAAC,8CAAyB,CAAC,CAAC,SAAS,CAAC,8CAAqC,CAAC,CAAC;QAC3F,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,4DAA4D,CAAC,CAAC;IAClF,CAAC;CACF,CAAA;AAPY,wCAAwC;IADpD,IAAA,eAAM,EAAC,EAAE,CAAC;GACE,wCAAwC,CAOpD;AAPY,4FAAwC"}
@@ -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"}
@@ -0,0 +1,16 @@
1
+ import { PromiseOrValue } from '@dereekb/util';
2
+ import { FirestoreModelName, FirestoreModelIdentity, FirestoreModelNames, OnCallDeleteModelParams } from '@dereekb/firebase';
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>;
8
+ };
9
+ /**
10
+ * Creates a OnCallWithAuthorizedNestContext function for updating model params.
11
+ *
12
+ * @param map
13
+ * @returns
14
+ */
15
+ export declare function onCallDeleteModel<N>(map: OnCallDeleteModelMap<N>): OnCallWithAuthorizedNestContext<N, OnCallDeleteModelParams, unknown>;
16
+ export declare function deleteModelUnknownModelTypeError(modelType: FirestoreModelName): import("firebase-functions/v1/auth").HttpsError;
@@ -0,0 +1,37 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.deleteModelUnknownModelTypeError = exports.onCallDeleteModel = void 0;
4
+ const util_1 = require("@dereekb/util");
5
+ const function_1 = require("../../function");
6
+ /**
7
+ * Creates a OnCallWithAuthorizedNestContext function for updating model params.
8
+ *
9
+ * @param map
10
+ * @returns
11
+ */
12
+ function onCallDeleteModel(map) {
13
+ return (request) => {
14
+ var _a;
15
+ const modelType = (_a = request.data) === null || _a === void 0 ? void 0 : _a.modelType;
16
+ const deleteFn = map[modelType];
17
+ if (deleteFn) {
18
+ return deleteFn(Object.assign(Object.assign({}, request), { data: request.data.data }));
19
+ }
20
+ else {
21
+ throw deleteModelUnknownModelTypeError(modelType);
22
+ }
23
+ };
24
+ }
25
+ exports.onCallDeleteModel = onCallDeleteModel;
26
+ function deleteModelUnknownModelTypeError(modelType) {
27
+ return (0, function_1.badRequestError)((0, util_1.serverError)({
28
+ status: 400,
29
+ code: 'UNKNOWN_TYPE_ERROR',
30
+ message: 'Invalid type to delete.',
31
+ data: {
32
+ modelType
33
+ }
34
+ }));
35
+ }
36
+ exports.deleteModelUnknownModelTypeError = deleteModelUnknownModelTypeError;
37
+ //# sourceMappingURL=delete.model.function.js.map
@@ -0,0 +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,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"}
@@ -0,0 +1,4 @@
1
+ export * from './permission.error';
2
+ export * from './create.model.function';
3
+ export * from './update.model.function';
4
+ export * from './delete.model.function';
@@ -0,0 +1,8 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const tslib_1 = require("tslib");
4
+ tslib_1.__exportStar(require("./permission.error"), exports);
5
+ tslib_1.__exportStar(require("./create.model.function"), exports);
6
+ tslib_1.__exportStar(require("./update.model.function"), exports);
7
+ tslib_1.__exportStar(require("./delete.model.function"), exports);
8
+ //# sourceMappingURL=index.js.map
@@ -0,0 +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;AACxC,kEAAwC"}
@@ -0,0 +1,2 @@
1
+ import { FirebasePermissionErrorContextErrorFunction } from '@dereekb/firebase';
2
+ export declare const nestFirebaseForbiddenPermissionError: FirebasePermissionErrorContextErrorFunction;
@@ -0,0 +1,20 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.nestFirebaseForbiddenPermissionError = void 0;
4
+ const util_1 = require("@dereekb/util");
5
+ const error_1 = require("../../function/error");
6
+ const nestFirebaseForbiddenPermissionError = (firebaseContextGrantedModelRoles, roles) => {
7
+ var _a, _b;
8
+ return (0, error_1.forbiddenError)((0, util_1.serverError)({
9
+ status: 403,
10
+ code: 'PERMISSION_ERROR',
11
+ message: 'You do not have permission to do this.',
12
+ data: {
13
+ id: (_a = firebaseContextGrantedModelRoles.data) === null || _a === void 0 ? void 0 : _a.document.id,
14
+ type: (_b = firebaseContextGrantedModelRoles.data) === null || _b === void 0 ? void 0 : _b.document.modelType,
15
+ roles
16
+ }
17
+ }));
18
+ };
19
+ exports.nestFirebaseForbiddenPermissionError = nestFirebaseForbiddenPermissionError;
20
+ //# sourceMappingURL=permission.error.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"permission.error.js","sourceRoot":"","sources":["../../../../../../../packages/firebase-server/src/lib/nest/model/permission.error.ts"],"names":[],"mappings":";;;AACA,wCAA0D;AAE1D,gDAAsD;AAE/C,MAAM,oCAAoC,GAAgD,CAAC,gCAA2G,EAAE,KAAiC,EAAE,EAAE;;IAClP,OAAO,IAAA,sBAAc,EACnB,IAAA,kBAAW,EAAC;QACV,MAAM,EAAE,GAAG;QACX,IAAI,EAAE,kBAAkB;QACxB,OAAO,EAAE,wCAAwC;QACjD,IAAI,EAAE;YACJ,EAAE,EAAE,MAAA,gCAAgC,CAAC,IAAI,0CAAE,QAAQ,CAAC,EAAE;YACtD,IAAI,EAAE,MAAA,gCAAgC,CAAC,IAAI,0CAAE,QAAQ,CAAC,SAAS;YAC/D,KAAK;SACN;KACF,CAAC,CACH,CAAC;AACJ,CAAC,CAAC;AAbW,QAAA,oCAAoC,wCAa/C"}
@@ -0,0 +1,16 @@
1
+ import { PromiseOrValue } from '@dereekb/util';
2
+ import { FirestoreModelName, FirestoreModelIdentity, FirestoreModelNames, OnCallUpdateModelParams } from '@dereekb/firebase';
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>;
8
+ };
9
+ /**
10
+ * Creates a OnCallWithAuthorizedNestContext function for updating model params.
11
+ *
12
+ * @param map
13
+ * @returns
14
+ */
15
+ export declare function onCallUpdateModel<N>(map: OnCallUpdateModelMap<N>): OnCallWithAuthorizedNestContext<N, OnCallUpdateModelParams, unknown>;
16
+ export declare function updateModelUnknownModelTypeError(modelType: FirestoreModelName): import("firebase-functions/v1/auth").HttpsError;