@dereekb/firebase 5.3.0 → 6.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 (104) hide show
  1. package/CHANGELOG.md +24 -0
  2. package/package.json +5 -5
  3. package/src/lib/client/firestore/driver.accessor.js +1 -0
  4. package/src/lib/client/firestore/driver.accessor.js.map +1 -1
  5. package/src/lib/client/firestore/driver.query.js +5 -1
  6. package/src/lib/client/firestore/driver.query.js.map +1 -1
  7. package/src/lib/client/function/function.callable.d.ts +13 -0
  8. package/src/lib/client/function/function.callable.js +22 -0
  9. package/src/lib/client/function/function.callable.js.map +1 -0
  10. package/src/lib/client/function/index.d.ts +2 -0
  11. package/src/lib/client/function/index.js +2 -0
  12. package/src/lib/client/function/index.js.map +1 -1
  13. package/src/lib/client/function/model.function.factory.d.ts +36 -0
  14. package/src/lib/client/function/model.function.factory.js +37 -0
  15. package/src/lib/client/function/model.function.factory.js.map +1 -0
  16. package/src/lib/common/auth/auth.context.d.ts +33 -0
  17. package/src/lib/common/auth/auth.context.js +3 -0
  18. package/src/lib/common/auth/auth.context.js.map +1 -0
  19. package/src/lib/common/auth/auth.d.ts +9 -0
  20. package/src/lib/common/auth/index.d.ts +1 -0
  21. package/src/lib/common/auth/index.js +1 -0
  22. package/src/lib/common/auth/index.js.map +1 -1
  23. package/src/lib/common/firestore/accessor/document.d.ts +24 -8
  24. package/src/lib/common/firestore/accessor/document.js +17 -9
  25. package/src/lib/common/firestore/accessor/document.js.map +1 -1
  26. package/src/lib/common/firestore/collection/collection.d.ts +60 -0
  27. package/src/lib/common/firestore/collection/collection.js +14 -1
  28. package/src/lib/common/firestore/collection/collection.js.map +1 -1
  29. package/src/lib/common/firestore/driver/accessor.d.ts +2 -0
  30. package/src/lib/common/firestore/driver/query.d.ts +4 -2
  31. package/src/lib/common/firestore/driver/query.handler.d.ts +1 -1
  32. package/src/lib/common/firestore/driver/query.handler.js +3 -2
  33. package/src/lib/common/firestore/driver/query.handler.js.map +1 -1
  34. package/src/lib/common/firestore/query/constraint.d.ts +21 -3
  35. package/src/lib/common/firestore/query/constraint.js +20 -2
  36. package/src/lib/common/firestore/query/constraint.js.map +1 -1
  37. package/src/lib/common/firestore/query/constraint.template.d.ts +16 -0
  38. package/src/lib/common/firestore/query/constraint.template.js +27 -0
  39. package/src/lib/common/firestore/query/constraint.template.js.map +1 -0
  40. package/src/lib/common/firestore/query/index.d.ts +1 -0
  41. package/src/lib/common/firestore/query/index.js +1 -0
  42. package/src/lib/common/firestore/query/index.js.map +1 -1
  43. package/src/lib/common/firestore/reference.d.ts +7 -1
  44. package/src/lib/common/firestore/types.d.ts +8 -5
  45. package/src/lib/common/firestore/types.js.map +1 -1
  46. package/src/lib/common/index.d.ts +1 -0
  47. package/src/lib/common/index.js +1 -0
  48. package/src/lib/common/index.js.map +1 -1
  49. package/src/lib/common/model/context.d.ts +16 -0
  50. package/src/lib/common/model/context.js +3 -0
  51. package/src/lib/common/model/context.js.map +1 -0
  52. package/src/lib/common/model/function.d.ts +15 -0
  53. package/src/lib/common/model/function.js +12 -0
  54. package/src/lib/common/model/function.js.map +1 -0
  55. package/src/lib/common/model/index.d.ts +5 -0
  56. package/src/lib/common/model/index.js +9 -0
  57. package/src/lib/common/model/index.js.map +1 -0
  58. package/src/lib/common/model/model/index.d.ts +1 -0
  59. package/src/lib/common/model/model/index.js +5 -0
  60. package/src/lib/common/model/model/index.js.map +1 -0
  61. package/src/lib/common/model/model/model.loader.d.ts +30 -0
  62. package/src/lib/common/model/model/model.loader.js +21 -0
  63. package/src/lib/common/model/model/model.loader.js.map +1 -0
  64. package/src/lib/common/model/model.service.d.ts +56 -0
  65. package/src/lib/common/model/model.service.js +111 -0
  66. package/src/lib/common/model/model.service.js.map +1 -0
  67. package/src/lib/common/model/permission/index.d.ts +4 -0
  68. package/src/lib/common/model/permission/index.js +8 -0
  69. package/src/lib/common/model/permission/index.js.map +1 -0
  70. package/src/lib/common/model/permission/permission.context.d.ts +9 -0
  71. package/src/lib/common/model/permission/permission.context.js +3 -0
  72. package/src/lib/common/model/permission/permission.context.js.map +1 -0
  73. package/src/lib/common/model/permission/permission.d.ts +11 -0
  74. package/src/lib/common/model/permission/permission.js +3 -0
  75. package/src/lib/common/model/permission/permission.js.map +1 -0
  76. package/src/lib/common/model/permission/permission.service.d.ts +24 -0
  77. package/src/lib/common/model/permission/permission.service.js +48 -0
  78. package/src/lib/common/model/permission/permission.service.js.map +1 -0
  79. package/src/lib/common/model/permission/permission.service.role.d.ts +40 -0
  80. package/src/lib/common/model/permission/permission.service.role.js +70 -0
  81. package/src/lib/common/model/permission/permission.service.role.js.map +1 -0
  82. package/test/CHANGELOG.md +19 -0
  83. package/test/package.json +7 -7
  84. package/test/src/lib/common/firestore.d.ts +3 -3
  85. package/test/src/lib/common/firestore.js +2 -2
  86. package/test/src/lib/common/firestore.mock.item.d.ts +43 -16
  87. package/test/src/lib/common/firestore.mock.item.fixture.d.ts +3 -1
  88. package/test/src/lib/common/firestore.mock.item.fixture.js +12 -6
  89. package/test/src/lib/common/firestore.mock.item.fixture.js.map +1 -1
  90. package/test/src/lib/common/firestore.mock.item.js +85 -27
  91. package/test/src/lib/common/firestore.mock.item.js.map +1 -1
  92. package/test/src/lib/common/firestore.mock.item.query.d.ts +20 -1
  93. package/test/src/lib/common/firestore.mock.item.query.js +22 -1
  94. package/test/src/lib/common/firestore.mock.item.query.js.map +1 -1
  95. package/test/src/lib/common/firestore.mock.item.service.d.ts +40 -0
  96. package/test/src/lib/common/firestore.mock.item.service.js +62 -0
  97. package/test/src/lib/common/firestore.mock.item.service.js.map +1 -0
  98. package/test/src/lib/common/index.d.ts +1 -0
  99. package/test/src/lib/common/index.js +1 -0
  100. package/test/src/lib/common/index.js.map +1 -1
  101. package/test/src/lib/common/test.driver.accessor.js +77 -24
  102. package/test/src/lib/common/test.driver.accessor.js.map +1 -1
  103. package/test/src/lib/common/test.driver.query.js +138 -75
  104. package/test/src/lib/common/test.driver.query.js.map +1 -1
package/CHANGELOG.md CHANGED
@@ -2,6 +2,30 @@
2
2
 
3
3
  This file was generated using [@jscutlery/semver](https://github.com/jscutlery/semver).
4
4
 
5
+ # [6.0.0](https://github.com/dereekb/dbx-components/compare/v5.3.0-dev...v6.0.0) (2022-06-03)
6
+
7
+
8
+ ### Features
9
+
10
+ * added AbstractFirebaseNestContext ([2f8e1a2](https://github.com/dereekb/dbx-components/commit/2f8e1a2127ffcfb23a428d6b46192633d8bf725f))
11
+ * added ContextGrantedModelRolesReader ([6fba1cc](https://github.com/dereekb/dbx-components/commit/6fba1cc637beeff55523df599eb88391352f9f58))
12
+ * added FirebaseModelService ([3876575](https://github.com/dereekb/dbx-components/commit/387657559a86908eee57326b655c63a0a836c239))
13
+ * added FirebaseModelsPermissionService ([9d75de4](https://github.com/dereekb/dbx-components/commit/9d75de4052dcfb15ef680d30f476ef494d8328a9))
14
+ * added firebaseModelsService ([7432e55](https://github.com/dereekb/dbx-components/commit/7432e55111cec66a239856ecb2db6adfc9e9780d))
15
+ * added InModelContextFirebaseModelServiceFactory ([9bf4697](https://github.com/dereekb/dbx-components/commit/9bf469731699a16ad27c96e3b149f552a429b471))
16
+ * added loadDocumentForKey to LimitedFirestoreDocumentAccessor ([96958b8](https://github.com/dereekb/dbx-components/commit/96958b89df62dc38136ac2dfcd2ce7c139b6099e))
17
+ * added modelType to FirestoreDocument ([deecb5d](https://github.com/dereekb/dbx-components/commit/deecb5df415ed9d99412c336ba65f4da572bbe44))
18
+ * added OnCallDeleteModel ([358189d](https://github.com/dereekb/dbx-components/commit/358189d6db6ef7d8db93d6dd881d29cc724dd083))
19
+ * added OnCallUpdateModel ([3b60a06](https://github.com/dereekb/dbx-components/commit/3b60a06d48ec6a96940f44939e24e5c1f4879aa9))
20
+ * added orderByDocumentId, startAtValue, endAtValue constraints ([c846fee](https://github.com/dereekb/dbx-components/commit/c846feef6c26a3818bb006a807b6e931b7b14eaf))
21
+
22
+
23
+ ### BREAKING CHANGES
24
+
25
+ * model type is now required on FirestoreDocument models
26
+
27
+
28
+
5
29
  # [5.3.0](https://github.com/dereekb/dbx-components/compare/v5.2.1-dev...v5.3.0) (2022-05-30)
6
30
 
7
31
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dereekb/firebase",
3
- "version": "5.3.0",
3
+ "version": "6.0.0",
4
4
  "devDependencies": {
5
5
  "@firebase/rules-unit-testing": "^2.0.0"
6
6
  },
@@ -22,18 +22,18 @@
22
22
  "rxjs": "^7.0.0",
23
23
  "rxfire": "^6.0.3",
24
24
  "firebase": "^9.8.0",
25
- "@dereekb/util": "5.3.0",
25
+ "@dereekb/util": "6.0.0",
26
26
  "make-error": "^1.3.0",
27
27
  "extra-set": "^2.2.11",
28
- "@dereekb/rxjs": "5.3.0",
28
+ "@dereekb/rxjs": "6.0.0",
29
29
  "ms": "^3.0.0-canary.1",
30
- "@dereekb/date": "5.3.0",
30
+ "@dereekb/date": "6.0.0",
31
31
  "class-transformer": "^0.5.1",
32
32
  "date-fns": "^2.28.0",
33
33
  "class-validator": "^0.13.2",
34
34
  "date-fns-tz": "^1.3.0",
35
35
  "rrule": "git+https://git@github.com/dereekb/rrule.git#17adf5708d6567b4d01a3a8afd106261421ea492",
36
- "@dereekb/model": "5.3.0",
36
+ "@dereekb/model": "6.0.0",
37
37
  "tslib": "^2.0.0"
38
38
  }
39
39
  }
@@ -10,6 +10,7 @@ const driver_accessor_transaction_1 = require("./driver.accessor.transaction");
10
10
  function firestoreClientAccessorDriver() {
11
11
  return {
12
12
  doc: firestore_2.doc,
13
+ docAtPath: firestore_2.doc,
13
14
  collectionGroup: firestore_2.collectionGroup,
14
15
  collection: firestore_2.collection,
15
16
  subcollection: firestore_2.collection,
@@ -1 +1 @@
1
- {"version":3,"file":"driver.accessor.js","sourceRoot":"","sources":["../../../../../../../packages/firebase/src/lib/client/firestore/driver.accessor.ts"],"names":[],"mappings":";;;;AAAA,mDAAgE;AAChE,kDAA+F;AAG/F,mEAAoE;AACpE,uEAA4E;AAC5E,+EAA2E;AAI3E,SAAgB,6BAA6B;IAC3C,OAAO;QACL,GAAG,EAAE,eAA4D;QACjE,eAAe,EAAE,2BAA4E;QAC7F,UAAU,EAAE,sBAAqE;QACjF,aAAa,EAAE,sBAAwE;QACvF,8BAA8B,EAC5B,CAAC,SAAS,EAAE,EAAE,CACd,CAAU,EAA0B,EAAE,EAAE,wDACtC,OAAA,MAAM,IAAA,0BAAc,EAAC,SAAsB,EAAE,EAA8C,CAAC,CAAA,GAAA;QAChG,6BAA6B,EAAE,CAAC,SAAS,EAAE,EAAE,CAAC,GAAG,EAAE,CAAC,IAAA,sBAAU,EAAC,SAAsB,CAAC;QACtF,qBAAqB,EAAE,yDAA+B;QACtD,yBAAyB,EAAE,wDAAwE;QACnG,wBAAwB,EAAE,iDAAiF;KAC5G,CAAC;AACJ,CAAC;AAfD,sEAeC"}
1
+ {"version":3,"file":"driver.accessor.js","sourceRoot":"","sources":["../../../../../../../packages/firebase/src/lib/client/firestore/driver.accessor.ts"],"names":[],"mappings":";;;;AAAA,mDAAqF;AACrF,kDAA+F;AAG/F,mEAAoE;AACpE,uEAA4E;AAC5E,+EAA2E;AAI3E,SAAgB,6BAA6B;IAC3C,OAAO;QACL,GAAG,EAAE,eAA4D;QACjE,SAAS,EAAE,eAAoE;QAC/E,eAAe,EAAE,2BAA4E;QAC7F,UAAU,EAAE,sBAAqE;QACjF,aAAa,EAAE,sBAAwE;QACvF,8BAA8B,EAC5B,CAAC,SAAS,EAAE,EAAE,CACd,CAAU,EAA0B,EAAE,EAAE,wDACtC,OAAA,MAAM,IAAA,0BAAc,EAAC,SAA8B,EAAE,EAA8C,CAAC,CAAA,GAAA;QACxG,6BAA6B,EAAE,CAAC,SAAS,EAAE,EAAE,CAAC,GAAG,EAAE,CAAC,IAAA,sBAAU,EAAC,SAA8B,CAAC;QAC9F,qBAAqB,EAAE,yDAA+B;QACtD,yBAAyB,EAAE,wDAAwE;QACnG,wBAAwB,EAAE,iDAAiF;KAC5G,CAAC;AACJ,CAAC;AAhBD,sEAgBC"}
@@ -16,18 +16,22 @@ exports.FIRESTORE_CLIENT_QUERY_CONSTRAINT_HANDLER_MAPPING = {
16
16
  [constraint_1.FIRESTORE_LIMIT_QUERY_CONSTRAINT_TYPE]: (builder, data) => addConstraintToBuilder(builder, (0, firestore_1.limit)(data.limit)),
17
17
  [constraint_1.FIRESTORE_LIMIT_TO_LAST_QUERY_CONSTRAINT_TYPE]: (builder, data) => addConstraintToBuilder(builder, (0, firestore_1.limitToLast)(data.limit)),
18
18
  [constraint_1.FIRESTORE_ORDER_BY_QUERY_CONSTRAINT_TYPE]: (builder, data) => addConstraintToBuilder(builder, (0, firestore_1.orderBy)(data.fieldPath, data.directionStr)),
19
+ [constraint_1.FIRESTORE_ORDER_BY_DOCUMENT_ID_QUERY_CONSTRAINT_TYPE]: (builder, data) => addConstraintToBuilder(builder, (0, firestore_1.orderBy)((0, firestore_1.documentId)(), data.directionStr)),
19
20
  [constraint_1.FIRESTORE_WHERE_QUERY_CONSTRAINT_TYPE]: (builder, data) => addConstraintToBuilder(builder, (0, firestore_1.where)(data.fieldPath, data.opStr, data.value)),
20
21
  [constraint_1.FIRESTORE_OFFSET_QUERY_CONSTRAINT_TYPE]: undefined,
21
22
  [constraint_1.FIRESTORE_START_AT_QUERY_CONSTRAINT_TYPE]: (builder, data) => addConstraintToBuilder(builder, (0, firestore_1.startAt)(data.snapshot)),
23
+ [constraint_1.FIRESTORE_START_AT_VALUE_QUERY_CONSTRAINT_TYPE]: (builder, data) => addConstraintToBuilder(builder, (0, firestore_1.startAt)(...data.fieldValues)),
22
24
  [constraint_1.FIRESTORE_START_AFTER_QUERY_CONSTRAINT_TYPE]: (builder, data) => addConstraintToBuilder(builder, (0, firestore_1.startAfter)(data.snapshot)),
23
25
  [constraint_1.FIRESTORE_END_AT_QUERY_CONSTRAINT_TYPE]: (builder, data) => addConstraintToBuilder(builder, (0, firestore_1.endAt)(data.snapshot)),
26
+ [constraint_1.FIRESTORE_END_AT_VALUE_QUERY_CONSTRAINT_TYPE]: (builder, data) => addConstraintToBuilder(builder, (0, firestore_1.endAt)(...data.fieldValues)),
24
27
  [constraint_1.FIRESTORE_END_BEFORE_QUERY_CONSTRAINT_TYPE]: (builder, data) => addConstraintToBuilder(builder, (0, firestore_1.endBefore)(data.snapshot))
25
28
  };
26
29
  function firebaseFirestoreQueryConstraintFunctionsDriver() {
27
30
  return (0, query_handler_1.makeFirestoreQueryConstraintFunctionsDriver)({
28
31
  mapping: exports.FIRESTORE_CLIENT_QUERY_CONSTRAINT_HANDLER_MAPPING,
29
32
  init: (query) => ({ query, constraints: [] }),
30
- build: ({ query: initialQuery, constraints }) => (0, firestore_1.query)(initialQuery, ...constraints)
33
+ build: ({ query: initialQuery, constraints }) => (0, firestore_1.query)(initialQuery, ...constraints),
34
+ documentIdFieldPath: () => (0, firestore_1.documentId)()
31
35
  });
32
36
  }
33
37
  exports.firebaseFirestoreQueryConstraintFunctionsDriver = firebaseFirestoreQueryConstraintFunctionsDriver;
@@ -1 +1 @@
1
- {"version":3,"file":"driver.query.js","sourceRoot":"","sources":["../../../../../../../packages/firebase/src/lib/client/firestore/driver.query.ts"],"names":[],"mappings":";;;AAEA,kDAA+M;AAC/M,0EAAke;AACle,+EAA0G;AAG1G,wEAA+E;AAO/E,SAAgB,sBAAsB,CAAC,OAAsC,EAAE,UAAyC;IACtH,OAAO;QACL,KAAK,EAAE,OAAO,CAAC,KAAK;QACpB,WAAW,EAAE,OAAO,CAAC,WAAW,CAAC,MAAM,CAAC,UAAU,CAAC;KACpD,CAAC;AACJ,CAAC;AALD,wDAKC;AAEY,QAAA,iDAAiD,GAA+E;IAC3I,CAAC,kDAAqC,CAAC,EAAE,CAAC,OAAO,EAAE,IAAI,EAAE,EAAE,CAAC,sBAAsB,CAAC,OAAO,EAAE,IAAA,iBAAK,EAAC,IAAI,CAAC,KAAK,CAAC,CAAC;IAC9G,CAAC,0DAA6C,CAAC,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E,yDAAiD;QAC1D,IAAI,EAAE,CAAI,KAAe,EAAE,EAAE,CAAC,CAAC,EAAE,KAAK,EAAE,WAAW,EAAE,EAAE,EAAE,CAAC;QAC1D,KAAK,EAAE,CAAI,EAAE,KAAK,EAAE,YAAY,EAAE,WAAW,EAAiC,EAAE,EAAE,CAAC,IAAA,iBAAK,EAAC,YAAyC,EAAE,GAAG,WAAW,CAAC;KACpJ,CAAC,CAAC;AACL,CAAC;AAND,0GAMC;AAED,SAAgB,4BAA4B;IAC1C,uCACK,+CAA+C,EAAE,KACpD,OAAO,CAAI,KAAe,EAAE,WAAyB;YACnD,IAAI,WAAW,EAAE;gBACf,qFAAqF;gBACrF,MAAM,IAAI,KAAK,CAAC,8EAA8E,CAAC,CAAC;aACjG;YAED,OAAO,IAAA,mBAAO,EAAC,KAAkC,CAAC,CAAC;QACrD,CAAC;QACD,UAAU,CAAI,KAAe,EAAE,OAAsC;YACnE,OAAO,IAAA,iCAAoB,EAAC,CAAC,GAAG,EAAE,EAAE,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,IAAA,sBAAU,EAAC,KAAkC,EAAE,OAAO,EAAE,GAAG,CAAC,CAAC,CAAC,CAAC,IAAA,sBAAU,EAAC,KAAkC,EAAE,GAAG,CAAC,CAAC,CAAC,CAAC;QACvK,CAAC,IACD;AACJ,CAAC;AAfD,oEAeC"}
1
+ {"version":3,"file":"driver.query.js","sourceRoot":"","sources":["../../../../../../../packages/firebase/src/lib/client/firestore/driver.query.ts"],"names":[],"mappings":";;;AAEA,kDAA2N;AAC3N,0EAcmD;AACnD,+EAA0G;AAG1G,wEAA+E;AAO/E,SAAgB,sBAAsB,CAAC,OAAsC,EAAE,UAAyC;IACtH,OAAO;QACL,KAAK,EAAE,OAAO,CAAC,KAAK;QACpB,WAAW,EAAE,OAAO,CAAC,WAAW,CAAC,MAAM,CAAC,UAAU,CAAC;KACpD,CAAC;AACJ,CAAC;AALD,wDAKC;AAEY,QAAA,iDAAiD,GAA+E;I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,KAAkC,CAAC,CAAC;QACrD,CAAC;QACD,UAAU,CAAI,KAAe,EAAE,OAAsC;YACnE,OAAO,IAAA,iCAAoB,EAAC,CAAC,GAAG,EAAE,EAAE,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,IAAA,sBAAU,EAAC,KAAkC,EAAE,OAAO,EAAE,GAAG,CAAC,CAAC,CAAC,CAAC,IAAA,sBAAU,EAAC,KAAkC,EAAE,GAAG,CAAC,CAAC,CAAC,CAAC;QACvK,CAAC,IACD;AACJ,CAAC;AAfD,oEAeC"}
@@ -0,0 +1,13 @@
1
+ import { FactoryWithInput, Maybe, PromiseOrValue } from '@dereekb/util';
2
+ import { HttpsCallable } from 'firebase/functions';
3
+ export interface MapHttpsCallable<I, O, A, B> {
4
+ mapInput?: FactoryWithInput<PromiseOrValue<A>, Maybe<I>>;
5
+ mapOutput?: FactoryWithInput<PromiseOrValue<O>, Maybe<B>>;
6
+ }
7
+ /**
8
+ * Maps input and output values for an
9
+ * @param callable
10
+ * @param wrap
11
+ * @returns
12
+ */
13
+ export declare function mapHttpsCallable<I, O, A, B = unknown>(callable: HttpsCallable<A, B>, wrap: MapHttpsCallable<I, O, A, B>): HttpsCallable<I, O>;
@@ -0,0 +1,22 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.mapHttpsCallable = void 0;
4
+ const tslib_1 = require("tslib");
5
+ /**
6
+ * Maps input and output values for an
7
+ * @param callable
8
+ * @param wrap
9
+ * @returns
10
+ */
11
+ function mapHttpsCallable(callable, wrap) {
12
+ const { mapInput = (x) => x, mapOutput = (x) => x } = wrap;
13
+ return (inputData) => tslib_1.__awaiter(this, void 0, void 0, function* () {
14
+ const data = yield mapInput(inputData);
15
+ const result = yield callable(data);
16
+ const resultData = result.data;
17
+ const mappedResultData = yield mapOutput(resultData);
18
+ return Object.assign(Object.assign({}, result), { data: mappedResultData });
19
+ });
20
+ }
21
+ exports.mapHttpsCallable = mapHttpsCallable;
22
+ //# sourceMappingURL=function.callable.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"function.callable.js","sourceRoot":"","sources":["../../../../../../../packages/firebase/src/lib/client/function/function.callable.ts"],"names":[],"mappings":";;;;AAQA;;;;;GAKG;AACH,SAAgB,gBAAgB,CAAuB,QAA6B,EAAE,IAAkC;IACtH,MAAM,EAAE,QAAQ,GAAG,CAAC,CAAW,EAAE,EAAE,CAAC,CAAiB,EAAE,SAAS,GAAG,CAAC,CAAW,EAAE,EAAE,CAAC,CAAiB,EAAE,GAAG,IAAI,CAAC;IAE/G,OAAO,CAAO,SAAoB,EAAmC,EAAE;QACrE,MAAM,IAAI,GAAM,MAAM,QAAQ,CAAC,SAAS,CAAC,CAAC;QAE1C,MAAM,MAAM,GAA2B,MAAM,QAAQ,CAAC,IAAI,CAAC,CAAC;QAC5D,MAAM,UAAU,GAAa,MAAM,CAAC,IAAI,CAAC;QACzC,MAAM,gBAAgB,GAAM,MAAM,SAAS,CAAC,UAAU,CAAC,CAAC;QAExD,uCACK,MAAM,KACT,IAAI,EAAE,gBAAgB,IACtB;IACJ,CAAC,CAAA,CAAC;AACJ,CAAC;AAfD,4CAeC"}
@@ -1,2 +1,4 @@
1
1
  export * from './function';
2
+ export * from './function.callable';
2
3
  export * from './function.factory';
4
+ export * from './model.function.factory';
@@ -2,5 +2,7 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  const tslib_1 = require("tslib");
4
4
  tslib_1.__exportStar(require("./function"), exports);
5
+ tslib_1.__exportStar(require("./function.callable"), exports);
5
6
  tslib_1.__exportStar(require("./function.factory"), exports);
7
+ tslib_1.__exportStar(require("./model.function.factory"), exports);
6
8
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../../../packages/firebase/src/lib/client/function/index.ts"],"names":[],"mappings":";;;AAAA,qDAA2B;AAC3B,6DAAmC"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../../../packages/firebase/src/lib/client/function/index.ts"],"names":[],"mappings":";;;AAAA,qDAA2B;AAC3B,8DAAoC;AACpC,6DAAmC;AACnC,mEAAyC"}
@@ -0,0 +1,36 @@
1
+ import { MaybeNot } from '@dereekb/util';
2
+ import { Functions } from 'firebase/functions';
3
+ import { NonNever } from 'ts-essentials';
4
+ import { FirestoreModelIdentity, FirestoreModelNames } from '../../common';
5
+ import { FirebaseFunctionTypeMap, FirebaseFunctionMap, FirebaseFunction } from './function';
6
+ import { FirebaseFunctionTypeConfigMap } from './function.factory';
7
+ export declare type ModelFirebaseCrudFunction<I> = FirebaseFunction<I, void>;
8
+ export declare type ModelFirebaseCrudFunctionTypeMap<T extends FirestoreModelIdentity = FirestoreModelIdentity> = {
9
+ [K in FirestoreModelNames<T>]: ModelFirebaseCrudFunctionTypeMapEntry;
10
+ };
11
+ export declare type ModelFirebaseCrudFunctionTypeMapEntry = MaybeNot | Partial<ModelFirebaseCrudFunctionUpdateTypeConfig & ModelFirebaseCrudFunctionDeleteTypeConfig>;
12
+ export declare type ModelFirebaseCrudFunctionUpdateTypeConfig<I = unknown> = {
13
+ update: I;
14
+ };
15
+ export declare type ModelFirebaseCrudFunctionDeleteTypeConfig<I = unknown> = {
16
+ delete: I;
17
+ };
18
+ export declare type ModelFirebaseCrudFunctionConfigMap<C extends ModelFirebaseCrudFunctionTypeMap> = NonNever<{
19
+ [K in keyof C]: C[K] extends null ? never : (keyof C[K])[];
20
+ }>;
21
+ export declare type ModelFirebaseFunctionTypeUpdateKey<T extends string> = `update${Capitalize<T>}`;
22
+ export declare type ModelFirebaseFunctionTypeFunctionKey<T extends string> = ModelFirebaseFunctionTypeUpdateKey<T>;
23
+ export declare type ModelFirebaseCrudFunctionMap<C extends ModelFirebaseCrudFunctionTypeMap> = ModelFirebaseCrudFunctionRawMap<C>;
24
+ export declare type ModelFirebaseCrudFunctionRawMap<C extends ModelFirebaseCrudFunctionTypeMap> = NonNever<{
25
+ [K in keyof C]: K extends string ? ModelFirebaseCrudFunctionMapEntry<K, C[K]> : never;
26
+ }>;
27
+ export declare type ModelFirebaseCrudFunctionName<T extends string, K extends string> = `${K}${Capitalize<T>}`;
28
+ export declare type ModelFirebaseCrudFunctionMapEntry<T extends string, E extends ModelFirebaseCrudFunctionTypeMapEntry> = E extends null ? never : {
29
+ [K in keyof E as K extends string ? ModelFirebaseCrudFunctionName<T, K> : never]: ModelFirebaseCrudFunction<E[K]>;
30
+ };
31
+ export declare type ModelFirebaseFunctionMap<M extends FirebaseFunctionTypeMap, C extends ModelFirebaseCrudFunctionTypeMap> = FirebaseFunctionMap<M> & ModelFirebaseCrudFunctionMap<C>;
32
+ /**
33
+ * Used for building a FirebaseFunctionMap<M> for a specific Functions instance.
34
+ */
35
+ export declare type ModelFirebaseFunctionMapFactory<M extends FirebaseFunctionTypeMap, U extends ModelFirebaseCrudFunctionTypeMap> = (functionsInstance: Functions) => ModelFirebaseFunctionMap<M, U>;
36
+ export declare function modelFirebaseFunctionMapFactory<M extends FirebaseFunctionTypeMap, U extends ModelFirebaseCrudFunctionTypeMap>(configMap: FirebaseFunctionTypeConfigMap<M>, crudConfigMap: ModelFirebaseCrudFunctionConfigMap<U>): ModelFirebaseFunctionMapFactory<M, U>;
@@ -0,0 +1,37 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.modelFirebaseFunctionMapFactory = void 0;
4
+ const firebase_1 = require("@dereekb/firebase");
5
+ const util_1 = require("@dereekb/util");
6
+ const functions_1 = require("firebase/functions");
7
+ const common_1 = require("../../common");
8
+ const function_callable_1 = require("./function.callable");
9
+ function modelFirebaseFunctionMapFactory(configMap, crudConfigMap) {
10
+ const functionFactory = (0, firebase_1.firebaseFunctionMapFactory)(configMap);
11
+ return (functionsInstance) => {
12
+ const functionMap = functionFactory(functionsInstance);
13
+ const _updateFn = (0, util_1.cachedGetter)(() => (0, functions_1.httpsCallable)(functionsInstance, common_1.UPDATE_MODEL_APP_FUNCTION_KEY));
14
+ const _deleteFn = (0, util_1.cachedGetter)(() => (0, functions_1.httpsCallable)(functionsInstance, common_1.DELETE_MODEL_APP_FUNCTION_KEY));
15
+ const result = (0, util_1.build)({
16
+ base: functionMap,
17
+ build: (x) => {
18
+ Object.entries(crudConfigMap).forEach(([modelType, config]) => {
19
+ const modelTypeSuffix = (0, util_1.capitalizeFirstLetter)(modelType);
20
+ const crudFunctions = new Set(config);
21
+ const modelTypeCruds = {};
22
+ if (crudFunctions.has('update')) {
23
+ modelTypeCruds[`update${modelTypeSuffix}`] = (0, function_callable_1.mapHttpsCallable)(_updateFn(), { mapInput: (data) => ({ modelType, data }) });
24
+ }
25
+ if (crudFunctions.has('delete')) {
26
+ modelTypeCruds[`delete${modelTypeSuffix}`] = (0, function_callable_1.mapHttpsCallable)(_deleteFn(), { mapInput: (data) => ({ modelType, data }) });
27
+ }
28
+ // tslint:disable-next-line
29
+ x[modelType] = modelTypeCruds;
30
+ });
31
+ }
32
+ });
33
+ return result;
34
+ };
35
+ }
36
+ exports.modelFirebaseFunctionMapFactory = modelFirebaseFunctionMapFactory;
37
+ //# sourceMappingURL=model.function.factory.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"model.function.factory.js","sourceRoot":"","sources":["../../../../../../../packages/firebase/src/lib/client/function/model.function.factory.ts"],"names":[],"mappings":";;;AAAA,gDAA+D;AAC/D,wCAAqF;AACrF,kDAA8D;AAE9D,yCAA2L;AAE3L,2DAAuD;AA+CvD,SAAgB,+BAA+B,CAAgF,SAA2C,EAAE,aAAoD;IAC9N,MAAM,eAAe,GAAG,IAAA,qCAA0B,EAAC,SAAS,CAAC,CAAC;IAE9D,OAAO,CAAC,iBAA4B,EAAE,EAAE;QACtC,MAAM,WAAW,GAA2B,eAAe,CAAC,iBAAiB,CAAC,CAAC;QAE/E,MAAM,SAAS,GAAG,IAAA,mBAAY,EAAC,GAAG,EAAE,CAAC,IAAA,yBAAa,EAAC,iBAAiB,EAAE,sCAA6B,CAAC,CAAC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C"}
@@ -0,0 +1,33 @@
1
+ import { AuthClaims, AuthRoleSet, Maybe } from '@dereekb/util';
2
+ import { FirebaseAuthToken } from './auth';
3
+ /**
4
+ * Provides a context containing FirebaseAuthContextInfo
5
+ */
6
+ export interface FirebaseAuthContext {
7
+ readonly auth?: Maybe<FirebaseAuthContextInfo>;
8
+ }
9
+ /**
10
+ * Auth contextual information
11
+ */
12
+ export interface FirebaseAuthContextInfo {
13
+ /**
14
+ * Current UID
15
+ */
16
+ readonly uid: string;
17
+ /**
18
+ * Returns true if the user is considered a system admin.
19
+ */
20
+ isAdmin?(): boolean;
21
+ /**
22
+ * Retrieves the claims in the context.
23
+ */
24
+ loadClaims(): Promise<AuthClaims>;
25
+ /**
26
+ * The auth roles provided by the token in this context.
27
+ */
28
+ loadAuthRoles(): Promise<AuthRoleSet>;
29
+ /**
30
+ * The token in the context.
31
+ */
32
+ readonly token: FirebaseAuthToken;
33
+ }
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ //# sourceMappingURL=auth.context.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"auth.context.js","sourceRoot":"","sources":["../../../../../../../packages/firebase/src/lib/common/auth/auth.context.ts"],"names":[],"mappings":""}
@@ -1,4 +1,13 @@
1
+ import { Maybe } from '@dereekb/util';
1
2
  /**
2
3
  * Firebase User Identifier (UID)
3
4
  */
4
5
  export declare type FirebaseAuthUserId = string;
6
+ /**
7
+ * Firebase Auth Token interface
8
+ */
9
+ export declare type FirebaseAuthToken = {
10
+ email?: Maybe<string>;
11
+ emailVerified?: Maybe<boolean>;
12
+ phoneNumber?: Maybe<string>;
13
+ };
@@ -1 +1,2 @@
1
1
  export * from './auth';
2
+ export * from './auth.context';
@@ -2,4 +2,5 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  const tslib_1 = require("tslib");
4
4
  tslib_1.__exportStar(require("./auth"), exports);
5
+ tslib_1.__exportStar(require("./auth.context"), exports);
5
6
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../../../packages/firebase/src/lib/common/auth/index.ts"],"names":[],"mappings":";;;AAAA,iDAAuB"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../../../packages/firebase/src/lib/common/auth/index.ts"],"names":[],"mappings":";;;AAAA,iDAAuB;AACvB,yDAA+B"}
@@ -1,23 +1,27 @@
1
+ import { FirestoreModelName } from './../collection/collection';
1
2
  import { Observable } from 'rxjs';
2
3
  import { FirestoreAccessorDriverRef } from '../driver/accessor';
3
4
  import { DocumentReference, CollectionReference, Transaction, WriteBatch, DocumentSnapshot, SnapshotOptions, WriteResult } from '../types';
4
5
  import { FirestoreDocumentDataAccessor } from './accessor';
5
- import { CollectionReferenceRef, DocumentReferenceRef } from '../reference';
6
+ import { CollectionReferenceRef, DocumentReferenceRef, FirestoreContextReference } from '../reference';
6
7
  import { FirestoreDocumentContext } from './context';
7
- import { Maybe } from '@dereekb/util';
8
- export interface FirestoreDocument<T, A extends FirestoreDocumentDataAccessor<T> = FirestoreDocumentDataAccessor<T>> extends DocumentReferenceRef<T>, CollectionReferenceRef<T> {
8
+ import { ModelKey } from '@dereekb/util';
9
+ import { FirestoreModelNameRef, FirestoreModelIdentity, FirestoreModelIdentityRef } from '../collection/collection';
10
+ export interface FirestoreDocument<T, A extends FirestoreDocumentDataAccessor<T> = FirestoreDocumentDataAccessor<T>, M extends FirestoreModelName = FirestoreModelName> extends DocumentReferenceRef<T>, CollectionReferenceRef<T>, FirestoreModelIdentityRef<M>, FirestoreModelNameRef<M> {
9
11
  readonly accessor: A;
10
12
  readonly id: string;
11
13
  }
12
14
  /**
13
15
  * Abstract FirestoreDocument implementation that extends a FirestoreDocumentDataAccessor.
14
16
  */
15
- export declare abstract class AbstractFirestoreDocument<T, D extends AbstractFirestoreDocument<T, any, any>, A extends FirestoreDocumentDataAccessor<T> = FirestoreDocumentDataAccessor<T>> implements FirestoreDocument<T, A>, LimitedFirestoreDocumentAccessorRef<T, D>, CollectionReferenceRef<T> {
17
+ export declare abstract class AbstractFirestoreDocument<T, D extends AbstractFirestoreDocument<T, any, any>, A extends FirestoreDocumentDataAccessor<T> = FirestoreDocumentDataAccessor<T>, M extends FirestoreModelName = FirestoreModelName> implements FirestoreDocument<T, A>, LimitedFirestoreDocumentAccessorRef<T, D>, CollectionReferenceRef<T> {
16
18
  readonly accessor: A;
17
19
  readonly documentAccessor: LimitedFirestoreDocumentAccessor<T, D>;
18
20
  readonly stream$: Observable<DocumentSnapshot<T>>;
19
21
  readonly data$: Observable<T>;
20
22
  constructor(accessor: A, documentAccessor: LimitedFirestoreDocumentAccessor<T, D>);
23
+ abstract get modelIdentity(): FirestoreModelIdentity<M>;
24
+ get modelType(): M;
21
25
  get id(): string;
22
26
  get documentRef(): DocumentReference<T>;
23
27
  get collection(): CollectionReference<T>;
@@ -43,6 +47,18 @@ export interface LimitedFirestoreDocumentAccessor<T, D extends FirestoreDocument
43
47
  * @param document
44
48
  */
45
49
  loadDocumentFrom(document: FirestoreDocument<T>): D;
50
+ /**
51
+ * Loads a document from the datastore with the given key/full path.
52
+ *
53
+ * @param ref
54
+ */
55
+ loadDocumentForKey(fullPath: ModelKey): D;
56
+ /**
57
+ * Creates a document ref with a key/full path.
58
+ *
59
+ * @param ref
60
+ */
61
+ documentRefForKey(fullPath: ModelKey): DocumentReference<T>;
46
62
  }
47
63
  export interface FirestoreDocumentAccessor<T, D extends FirestoreDocument<T> = FirestoreDocument<T>> extends LimitedFirestoreDocumentAccessor<T, D>, CollectionReferenceRef<T>, FirestoreAccessorDriverRef {
48
64
  readonly databaseContext: FirestoreDocumentContext<T>;
@@ -57,6 +73,7 @@ export interface FirestoreDocumentAccessor<T, D extends FirestoreDocument<T> = F
57
73
  */
58
74
  loadDocumentForPath(path: string, ...pathSegments: string[]): D;
59
75
  /**
76
+ * Creates a document ref relative to the current context and given the input path.
60
77
  *
61
78
  * @param path
62
79
  * @param pathSegments
@@ -85,7 +102,7 @@ export interface LimitedFirestoreDocumentAccessorFactory<T, D extends FirestoreD
85
102
  /**
86
103
  * FirestoreDocumentAccessor configuration.
87
104
  */
88
- export interface LimitedFirestoreDocumentAccessorFactoryConfig<T, D extends FirestoreDocument<T> = FirestoreDocument<T>> extends FirestoreAccessorDriverRef {
105
+ export interface LimitedFirestoreDocumentAccessorFactoryConfig<T, D extends FirestoreDocument<T> = FirestoreDocument<T>> extends FirestoreContextReference, FirestoreAccessorDriverRef {
89
106
  readonly makeDocument: FirestoreDocumentFactoryFunction<T, D>;
90
107
  }
91
108
  export declare function limitedFirestoreDocumentAccessorFactory<T, D extends FirestoreDocument<T> = FirestoreDocument<T>>(config: LimitedFirestoreDocumentAccessorFactoryConfig<T, D>): LimitedFirestoreDocumentAccessorFactoryFunction<T, D>;
@@ -100,7 +117,7 @@ export declare type FirestoreDocumentAccessorFactory<T, D extends FirestoreDocum
100
117
  /**
101
118
  * FirestoreDocumentAccessor configuration.
102
119
  */
103
- export interface FirestoreDocumentAccessorFactoryConfig<T, D extends FirestoreDocument<T> = FirestoreDocument<T>> extends CollectionReferenceRef<T>, FirestoreAccessorDriverRef {
120
+ export interface FirestoreDocumentAccessorFactoryConfig<T, D extends FirestoreDocument<T> = FirestoreDocument<T>> extends CollectionReferenceRef<T>, LimitedFirestoreDocumentAccessorFactoryConfig<T, D> {
104
121
  readonly makeDocument: FirestoreDocumentFactoryFunction<T, D>;
105
122
  }
106
123
  export declare function firestoreDocumentAccessorFactory<T, D extends FirestoreDocument<T> = FirestoreDocument<T>>(config: FirestoreDocumentAccessorFactoryConfig<T, D>): FirestoreDocumentAccessorFactoryFunction<T, D>;
@@ -134,9 +151,8 @@ export interface FirestoreDocumentWithParent<P, T, A extends FirestoreDocumentDa
134
151
  readonly parent: DocumentReference<P>;
135
152
  }
136
153
  export declare abstract class AbstractFirestoreDocumentWithParent<P, T, D extends AbstractFirestoreDocument<T, any, any>, A extends FirestoreDocumentDataAccessor<T> = FirestoreDocumentDataAccessor<T>> extends AbstractFirestoreDocument<T, D, A> implements FirestoreDocumentWithParent<P, T, A> {
137
- private _parent;
138
154
  get parent(): DocumentReference<P>;
139
- constructor(parent: Maybe<DocumentReference<P>>, accessor: A, documentAccessor: LimitedFirestoreDocumentAccessor<T, D>);
155
+ constructor(accessor: A, documentAccessor: LimitedFirestoreDocumentAccessor<T, D>);
140
156
  }
141
157
  export interface FirestoreSingleDocumentAccessor<T, D extends FirestoreDocument<T> = FirestoreDocument<T>> {
142
158
  loadDocument(): D;
@@ -1,6 +1,4 @@
1
1
  "use strict";
2
- /*eslint @typescript-eslint/no-explicit-any:"off"*/
3
- // any is used with intent here, as the recursive AbstractFirestoreDocument requires its use to terminate.
4
2
  Object.defineProperty(exports, "__esModule", { value: true });
5
3
  exports.firestoreSingleDocumentAccessor = exports.AbstractFirestoreDocumentWithParent = exports.firestoreDocumentAccessorContextExtension = exports.firestoreDocumentAccessorFactory = exports.limitedFirestoreDocumentAccessorFactory = exports.AbstractFirestoreDocument = void 0;
6
4
  const accessor_1 = require("./accessor");
@@ -15,6 +13,9 @@ class AbstractFirestoreDocument {
15
13
  this.stream$ = this.accessor.stream();
16
14
  this.data$ = (0, accessor_1.dataFromSnapshotStream)(this.stream$);
17
15
  }
16
+ get modelType() {
17
+ return this.modelIdentity.model;
18
+ }
18
19
  get id() {
19
20
  return this.documentRef.id;
20
21
  }
@@ -22,7 +23,6 @@ class AbstractFirestoreDocument {
22
23
  return this.accessor.documentRef;
23
24
  }
24
25
  get collection() {
25
- // TODO: Only works if the documentRef has access to the parent ref
26
26
  return this.accessor.documentRef.parent;
27
27
  }
28
28
  snapshot() {
@@ -37,7 +37,7 @@ class AbstractFirestoreDocument {
37
37
  }
38
38
  exports.AbstractFirestoreDocument = AbstractFirestoreDocument;
39
39
  function limitedFirestoreDocumentAccessorFactory(config) {
40
- const { firestoreAccessorDriver } = config;
40
+ const { firestoreContext, firestoreAccessorDriver } = config;
41
41
  return (context) => {
42
42
  const databaseContext = context !== null && context !== void 0 ? context : config.firestoreAccessorDriver.defaultContextFactory();
43
43
  const dataAccessorFactory = databaseContext.accessorFactory;
@@ -45,11 +45,20 @@ function limitedFirestoreDocumentAccessorFactory(config) {
45
45
  const accessor = dataAccessorFactory.accessorFor(ref);
46
46
  return config.makeDocument(accessor, documentAccessor);
47
47
  }
48
+ function documentRefForKey(fullPath) {
49
+ return firestoreAccessorDriver.docAtPath(firestoreContext.firestore, fullPath);
50
+ }
51
+ function loadDocumentForKey(fullPath) {
52
+ const ref = documentRefForKey(fullPath);
53
+ return loadDocument(ref);
54
+ }
48
55
  const documentAccessor = {
49
56
  loadDocumentFrom(document) {
50
57
  return loadDocument(document.documentRef);
51
58
  },
52
59
  loadDocument,
60
+ documentRefForKey,
61
+ loadDocumentForKey,
53
62
  firestoreAccessorDriver,
54
63
  databaseContext
55
64
  };
@@ -98,12 +107,11 @@ function firestoreDocumentAccessorContextExtension({ documentAccessor, firestore
98
107
  }
99
108
  exports.firestoreDocumentAccessorContextExtension = firestoreDocumentAccessorContextExtension;
100
109
  class AbstractFirestoreDocumentWithParent extends AbstractFirestoreDocument {
101
- constructor(parent, accessor, documentAccessor) {
102
- super(accessor, documentAccessor);
103
- this._parent = parent !== null && parent !== void 0 ? parent : accessor.documentRef.parent.parent;
104
- }
105
110
  get parent() {
106
- return this._parent;
111
+ return this.accessor.documentRef.parent.parent;
112
+ }
113
+ constructor(accessor, documentAccessor) {
114
+ super(accessor, documentAccessor);
107
115
  }
108
116
  }
109
117
  exports.AbstractFirestoreDocumentWithParent = AbstractFirestoreDocumentWithParent;
@@ -1 +1 @@
1
- {"version":3,"file":"document.js","sourceRoot":"","sources":["../../../../../../../../packages/firebase/src/lib/common/firestore/accessor/document.ts"],"names":[],"mappings":";AAAA,mDAAmD;AACnD,0GAA0G;;;AAK1G,yCAAkH;AAGlH,wCAA6C;AAO7C;;GAEG;AACH,MAAsB,yBAAyB;IAI7C,YAAqB,QAA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AAC;QACD,0BAA0B,CAAC,WAAwB;YACjD,OAAO,SAAS,CAAC,8BAA8B,CAAC,WAAW,CAAC,CAAC,mBAAmB,CAAC,UAAU,CAAC,CAAC;QAC/F,CAAC;QACD,yBAAyB,CAAC,UAAsB;YAC9C,OAAO,SAAS,CAAC,6BAA6B,CAAC,UAAU,CAAC,CAAC,mBAAmB,CAAC,UAAU,CAAC,CAAC;QAC7F,CAAC;KACF,CAAC;AACJ,CAAC;AAdD,0EAcC"}
1
+ {"version":3,"file":"document.js","sourceRoot":"","sources":["../../../../../../../../packages/firebase/src/lib/common/firestore/accessor/document.ts"],"names":[],"mappings":";;;AAOA,yCAAkH;AAGlH,wCAAgD;AAQhD;;GAEG;AACH,MAAsB,yBAAyB;IAI7C,YAAqB,QAAW,EAAW,gBAAwD;QAA9E,aAAQ,GAAR,QAAQ,CAAG;QAAW,qBAAgB,GAAhB,gBAAgB,CAAwC;QAH1F,YAAO,GAAG,IAAI,CAAC,QAAQ,CAAC,MAAM,EAAE,CAAC;QACjC,UAAK,GAAkB,IAAA,iCAAsB,EAAC,IAAI,CAAC,OAAO,CAAC,CAAC;IAEiC,CAAC;IAIvG,IAAI,SAAS;QACX,OAAO,IAAI,CAAC,aAAa,CAAC,KAAK,CAAC;IAClC,CAAC;IAED,IAAI,EAAE;QACJ,OAAO,IAAI,CAAC,WAAW,CAAC,EAAE,CAAC;IAC7B,CAAC;IAED,IAAI,WAAW;QACb,OAAO,IAAI,CAAC,QAAQ,CAAC,WAAW,CAAC;IACnC,CAAC;IAED,IAAI,UAAU;QACZ,OAAO,IAAI,CAAC,QAAQ,CAAC,WAAW,CAAC,MAAgC,CAAC;IACpE,CAAC;IAED,QAAQ;QACN,OAAO,IAAI,CAAC,QAAQ,CAAC,GAAG,EAAE,CAAC;IAC7B,CAAC;IAED,YAAY,CAAC,OAAyB;QACpC,OAAO,IAAI,CAAC,QAAQ,EAAE,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAA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OAAO;QACL,gBAAgB;QAChB,8BAA8B,CAAC,WAAwB;YACrD,OAAO,gBAAgB,CAAC,uBAAuB,CAAC,yBAAyB,CAAC,WAAW,CAAC,CAAC,CAAC;QAC1F,CAAC;QACD,6BAA6B,CAAC,UAAsB;YAClD,OAAO,gBAAgB,CAAC,uBAAuB,CAAC,wBAAwB,CAAC,UAAU,CAAC,CAAC,CAAC;QACxF,CAAC;KACF,CAAC;AACJ,CAAC;AAVD,8FAUC;AAOD,MAAsB,mCAA2K,SAAQ,yBAAkC;IACzO,IAAI,MAAM;QACR,OAAQ,IAAI,CAAC,QAAQ,CAAC,WAAW,CAAC,MAAiC,CAAC,MAA8B,CAAC;IACrG,CAAC;IAED,YAAY,QAAW,EAAE,gBAAwD;QAC/E,KAAK,CAAC,QAAQ,EAAE,gBAAgB,CAAC,CAAC;IACpC,CAAC;CACF;AARD,kFAQC;AAcD,SAAgB,+BAA+B,CAA2D,MAAmD;IAC3J,MAAM,EAAE,oBAAoB,EAAE,UAAU,EAAE,SAAS,EAAE,GAAG,MAAM,CAAC;IAE/D,OAAO;QACL,YAAY;YACV,OAAO,SAAS,CAAC,gBAAgB,EAAE,CAAC,mBAAmB,CAAC,UAAU,CAAC,CAAC;QACtE,CAAC;QACD,0BAA0B,CAAC,WAAwB;YACjD,OAAO,SAAS,CAAC,8BAA8B,CAAC,WAAW,CAAC,CAAC,mBAAmB,CAAC,UAAU,CAAC,CAAC;QAC/F,CAAC;QACD,yBAAyB,CAAC,UAAsB;YAC9C,OAAO,SAAS,CAAC,6BAA6B,CAAC,UAAU,CAAC,CAAC,mBAAmB,CAAC,UAAU,CAAC,CAAC;QAC7F,CAAC;KACF,CAAC;AACJ,CAAC;AAdD,0EAcC"}
@@ -4,6 +4,66 @@ import { FirestoreItemPageIterationBaseConfig, FirestoreItemPageIterationFactory
4
4
  import { FirestoreQueryFactory } from '../query/query';
5
5
  import { FirestoreDrivers } from '../driver/driver';
6
6
  import { FirestoreCollectionQueryFactory } from './collection.query';
7
+ import { ModelTypeString } from '@dereekb/util';
8
+ /**
9
+ * The camelCase model name.
10
+ */
11
+ export declare type FirestoreModelName = ModelTypeString;
12
+ /**
13
+ * An all lowercase name that references a collection. Is usually the lowercase version of the FirestoreModelName.
14
+ *
15
+ * This is the part of the path that says what the collection is.
16
+ *
17
+ * Each collection name in the app should be unique, as usage of CollectionGroups would cause collections with the same name to be returned.
18
+ */
19
+ export declare type FirestoreCollectionName = string;
20
+ /**
21
+ * FirestoreCollectionName derived from a FirestoreModelName
22
+ */
23
+ export declare type FirestoreModelCollectionName<M extends FirestoreModelName> = `${Lowercase<M>}`;
24
+ /**
25
+ * A firestore model's identity
26
+ */
27
+ export declare type FirestoreModelIdentity<M extends FirestoreModelName = FirestoreModelName> = {
28
+ readonly model: M;
29
+ readonly collection: FirestoreModelCollectionName<M>;
30
+ };
31
+ export declare type FirestoreCollectionNames<I extends FirestoreModelIdentity> = I extends FirestoreModelIdentity<infer M> ? FirestoreModelCollectionName<M> : never;
32
+ export declare type FirestoreModelNames<I extends FirestoreModelIdentity> = I extends FirestoreModelIdentity<infer M> ? M : never;
33
+ /**
34
+ * Creates a FirestoreModelIdentity value.
35
+ *
36
+ * @param modelName
37
+ * @returns
38
+ */
39
+ export declare function firestoreModelIdentity<M extends FirestoreModelName>(modelName: M): FirestoreModelIdentity<M>;
40
+ /**
41
+ * Reference to a FirestoreCollectionName
42
+ */
43
+ export interface FirestoreModelNameRef<M extends FirestoreModelName = FirestoreModelName> {
44
+ /**
45
+ * Returns the FirestoreModelName for this context.
46
+ */
47
+ readonly modelType: M;
48
+ }
49
+ /**
50
+ * Reference to a FirestoreCollectionName
51
+ */
52
+ export interface FirestoreCollectionNameRef {
53
+ /**
54
+ * Returns the FirestoreCollectionName for this context.
55
+ */
56
+ readonly collectionName: FirestoreCollectionName;
57
+ }
58
+ /**
59
+ * Reference to a FirestoreModelIdentity
60
+ */
61
+ export interface FirestoreModelIdentityRef<M extends FirestoreModelName = FirestoreModelName> {
62
+ /**
63
+ * Returns the FirestoreModelIdentity for this context.
64
+ */
65
+ readonly modelIdentity: FirestoreModelIdentity<M>;
66
+ }
7
67
  /**
8
68
  * Instance that provides several accessors for accessing documents of a collection.
9
69
  */
@@ -1,10 +1,23 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.makeFirestoreCollection = void 0;
3
+ exports.makeFirestoreCollection = exports.firestoreModelIdentity = void 0;
4
4
  const document_1 = require("../accessor/document");
5
5
  const iterator_1 = require("../query/iterator");
6
6
  const query_1 = require("../query/query");
7
7
  const collection_query_1 = require("./collection.query");
8
+ /**
9
+ * Creates a FirestoreModelIdentity value.
10
+ *
11
+ * @param modelName
12
+ * @returns
13
+ */
14
+ function firestoreModelIdentity(modelName) {
15
+ return {
16
+ collection: modelName.toLowerCase(),
17
+ model: modelName
18
+ };
19
+ }
20
+ exports.firestoreModelIdentity = firestoreModelIdentity;
8
21
  /**
9
22
  * Creates a new FirestoreCollection from the input config.
10
23
  */
@@ -1 +1 @@
1
- {"version":3,"file":"collection.js","sourceRoot":"","sources":["../../../../../../../../packages/firebase/src/lib/common/firestore/collection/collection.ts"],"names":[],"mappings":";;;AACA,mDAc8B;AAC9B,gDAA0L;AAC1L,0CAA8E;AAE9E,yDAAsG;AAuCtG;;GAEG;AACH,SAAgB,uBAAuB,CAAoC,WAA4C;IACrH,MAAM,MAAM,GAAG,WAAyE,CAAC;IAEzF,MAAM,EAAE,UAAU,EAAE,gBAAgB,EAAE,uBAAuB,EAAE,GAAG,MAAM,CAAC;IACxE,MAAwD,CAAC,SAAS,GAAG,UAAU,CAAC;IAEjF,MAAM,kBAAkB,GAAiD,IAAA,4CAAiC,EAAC,MAAM,CAAC,CAAC;IACnH,MAAM,gBAAgB,GAAmD,IAAA,2CAAgC,EAAC,MAAM,CAAC,CAAC;IAClH,MAAM,YAAY,GAA6B,IAAA,6BAAqB,EAAC,MAAM,CAAC,CAAC;IAE7E,MAAM,yBAAyB,GAAG,IAAA,oDAAyC,EAAC,EAAE,gBAAgB,EAAE,uBAAuB,EAAE,CAAC,CAAC;IAC3H,MAAM,EAAE,aAAa,EAAE,GAAG,IAAA,kDAA+B,EAAC,YAAY,EAAE,yBAAyB,CAAC,CAAC;IACnG,MAAM,EAAE,KAAK,EAAE,GAAG,YAAY,CAAC;IAE/B,qCACE,MAAM;QACN,UAAU,EACV,SAAS,EAAE,UAAU,EACrB,gBAAgB,IACb,yBAAyB,KAC5B,kBAAkB;QAClB,KAAK;QACL,aAAa,IACb;AACJ,CAAC;AAxBD,0DAwBC"}
1
+ {"version":3,"file":"collection.js","sourceRoot":"","sources":["../../../../../../../../packages/firebase/src/lib/common/firestore/collection/collection.ts"],"names":[],"mappings":";;;AACA,mDAc8B;AAC9B,gDAA0L;AAC1L,0CAA8E;AAE9E,yDAAsG;AAiCtG;;;;;GAKG;AACH,SAAgB,sBAAsB,CAA+B,SAAY;IAC/E,OAAO;QACL,UAAU,EAAE,SAAS,CAAC,WAAW,EAAqC;QACtE,KAAK,EAAE,SAAS;KACjB,CAAC;AACJ,CAAC;AALD,wDAKC;AAoED;;GAEG;AACH,SAAgB,uBAAuB,CAAoC,WAA4C;IACrH,MAAM,MAAM,GAAG,WAAyE,CAAC;IAEzF,MAAM,EAAE,UAAU,EAAE,gBAAgB,EAAE,uBAAuB,EAAE,GAAG,MAAM,CAAC;IACxE,MAAwD,CAAC,SAAS,GAAG,UAAU,CAAC;IAEjF,MAAM,kBAAkB,GAAiD,IAAA,4CAAiC,EAAC,MAAM,CAAC,CAAC;IACnH,MAAM,gBAAgB,GAAmD,IAAA,2CAAgC,EAAC,MAAM,CAAC,CAAC;IAClH,MAAM,YAAY,GAA6B,IAAA,6BAAqB,EAAC,MAAM,CAAC,CAAC;IAE7E,MAAM,yBAAyB,GAAG,IAAA,oDAAyC,EAAC,EAAE,gBAAgB,EAAE,uBAAuB,EAAE,CAAC,CAAC;IAC3H,MAAM,EAAE,aAAa,EAAE,GAAG,IAAA,kDAA+B,EAAC,YAAY,EAAE,yBAAyB,CAAC,CAAC;IACnG,MAAM,EAAE,KAAK,EAAE,GAAG,YAAY,CAAC;IAE/B,qCACE,MAAM;QACN,UAAU,EACV,SAAS,EAAE,UAAU,EACrB,gBAAgB,IACb,yBAAyB,KAC5B,kBAAkB;QAClB,KAAK;QACL,aAAa,IACb;AACJ,CAAC;AAxBD,0DAwBC"}