@intuitionrobotics/firebase 0.47.58 → 1.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 (192) hide show
  1. package/LICENSE +3 -0
  2. package/{app-backend → dist/app-backend}/FirebaseModule.d.ts +3 -2
  3. package/dist/app-backend/FirebaseModule.d.ts.map +1 -0
  4. package/{app-backend → dist/app-backend}/FirebaseModule.js +17 -19
  5. package/dist/app-backend/FirebaseModule.js.map +1 -0
  6. package/{app-backend → dist/app-backend}/auth/FirebaseBaseWrapper.d.ts +2 -1
  7. package/dist/app-backend/auth/FirebaseBaseWrapper.d.ts.map +1 -0
  8. package/{app-backend → dist/app-backend}/auth/FirebaseBaseWrapper.js +4 -6
  9. package/dist/app-backend/auth/FirebaseBaseWrapper.js.map +1 -0
  10. package/{app-backend → dist/app-backend}/auth/FirebaseSession_Admin.d.ts +4 -3
  11. package/dist/app-backend/auth/FirebaseSession_Admin.d.ts.map +1 -0
  12. package/{app-backend → dist/app-backend}/auth/FirebaseSession_Admin.js +13 -16
  13. package/dist/app-backend/auth/FirebaseSession_Admin.js.map +1 -0
  14. package/dist/app-backend/auth/FirebaseSession_UserPassword.d.ts +2 -0
  15. package/dist/app-backend/auth/FirebaseSession_UserPassword.d.ts.map +1 -0
  16. package/{app-backend → dist/app-backend}/auth/FirebaseSession_UserPassword.js +2 -2
  17. package/{app-backend → dist/app-backend}/auth/FirebaseSession_UserPassword.js.map +1 -1
  18. package/{app-backend → dist/app-backend}/auth/firebase-session.d.ts +6 -5
  19. package/dist/app-backend/auth/firebase-session.d.ts.map +1 -0
  20. package/{app-backend → dist/app-backend}/auth/firebase-session.js +19 -14
  21. package/dist/app-backend/auth/firebase-session.js.map +1 -0
  22. package/{app-backend → dist/app-backend}/database/DatabaseWrapper.d.ts +7 -6
  23. package/dist/app-backend/database/DatabaseWrapper.d.ts.map +1 -0
  24. package/dist/app-backend/database/DatabaseWrapper.js +101 -0
  25. package/dist/app-backend/database/DatabaseWrapper.js.map +1 -0
  26. package/{app-backend → dist/app-backend}/database/types.d.ts +1 -0
  27. package/dist/app-backend/database/types.d.ts.map +1 -0
  28. package/{app-frontend → dist/app-backend}/database/types.js +1 -2
  29. package/{app-backend → dist/app-backend}/database/types.js.map +1 -1
  30. package/{app-backend → dist/app-backend}/firestore/FirestoreCollection.d.ts +12 -10
  31. package/dist/app-backend/firestore/FirestoreCollection.d.ts.map +1 -0
  32. package/dist/app-backend/firestore/FirestoreCollection.js +133 -0
  33. package/dist/app-backend/firestore/FirestoreCollection.js.map +1 -0
  34. package/{app-backend → dist/app-backend}/firestore/FirestoreInterface.d.ts +4 -3
  35. package/dist/app-backend/firestore/FirestoreInterface.d.ts.map +1 -0
  36. package/{app-backend → dist/app-backend}/firestore/FirestoreInterface.js +13 -14
  37. package/dist/app-backend/firestore/FirestoreInterface.js.map +1 -0
  38. package/{app-backend → dist/app-backend}/firestore/FirestoreTransaction.d.ts +5 -4
  39. package/dist/app-backend/firestore/FirestoreTransaction.d.ts.map +1 -0
  40. package/dist/app-backend/firestore/FirestoreTransaction.js +152 -0
  41. package/dist/app-backend/firestore/FirestoreTransaction.js.map +1 -0
  42. package/{app-backend → dist/app-backend}/firestore/FirestoreV2Collection.d.ts +3 -3
  43. package/dist/app-backend/firestore/FirestoreV2Collection.d.ts.map +1 -0
  44. package/{app-backend → dist/app-backend}/firestore/FirestoreV2Collection.js +4 -7
  45. package/dist/app-backend/firestore/FirestoreV2Collection.js.map +1 -0
  46. package/{app-backend → dist/app-backend}/firestore/FirestoreWrapper.d.ts +7 -6
  47. package/dist/app-backend/firestore/FirestoreWrapper.d.ts.map +1 -0
  48. package/dist/app-backend/firestore/FirestoreWrapper.js +41 -0
  49. package/dist/app-backend/firestore/FirestoreWrapper.js.map +1 -0
  50. package/{app-backend → dist/app-backend}/firestore/types.d.ts +1 -0
  51. package/dist/app-backend/firestore/types.d.ts.map +1 -0
  52. package/{app-backend → dist/app-backend}/firestore/types.js +1 -2
  53. package/dist/app-backend/firestore/types.js.map +1 -0
  54. package/{app-backend → dist/app-backend}/functions/firebase-function.d.ts +8 -7
  55. package/dist/app-backend/functions/firebase-function.d.ts.map +1 -0
  56. package/dist/app-backend/functions/firebase-function.js +350 -0
  57. package/dist/app-backend/functions/firebase-function.js.map +1 -0
  58. package/{app-backend → dist/app-backend}/push/PushMessagesWrapper.d.ts +5 -4
  59. package/dist/app-backend/push/PushMessagesWrapper.d.ts.map +1 -0
  60. package/dist/app-backend/push/PushMessagesWrapper.js +48 -0
  61. package/dist/app-backend/push/PushMessagesWrapper.js.map +1 -0
  62. package/{app-backend → dist/app-backend}/push/types.d.ts +1 -0
  63. package/dist/app-backend/push/types.d.ts.map +1 -0
  64. package/{app-backend/database → dist/app-backend/push}/types.js +1 -2
  65. package/{app-backend → dist/app-backend}/push/types.js.map +1 -1
  66. package/{app-backend → dist/app-backend}/storage/StorageWrapper.d.ts +5 -4
  67. package/dist/app-backend/storage/StorageWrapper.d.ts.map +1 -0
  68. package/dist/app-backend/storage/StorageWrapper.js +196 -0
  69. package/dist/app-backend/storage/StorageWrapper.js.map +1 -0
  70. package/{app-backend → dist/app-backend}/storage/types.d.ts +2 -1
  71. package/dist/app-backend/storage/types.d.ts.map +1 -0
  72. package/dist/app-backend/storage/types.js +20 -0
  73. package/{app-backend → dist/app-backend}/storage/types.js.map +1 -1
  74. package/{app-frontend → dist/app-frontend}/FirebaseModule.d.ts +4 -3
  75. package/dist/app-frontend/FirebaseModule.d.ts.map +1 -0
  76. package/dist/app-frontend/FirebaseModule.js +85 -0
  77. package/dist/app-frontend/FirebaseModule.js.map +1 -0
  78. package/{app-frontend → dist/app-frontend}/analytics/AnalyticsModule.d.ts +1 -0
  79. package/dist/app-frontend/analytics/AnalyticsModule.d.ts.map +1 -0
  80. package/dist/app-frontend/analytics/AnalyticsModule.js +46 -0
  81. package/dist/app-frontend/analytics/AnalyticsModule.js.map +1 -0
  82. package/{app-frontend → dist/app-frontend}/analytics/AnalyticsWrapper.d.ts +5 -4
  83. package/dist/app-frontend/analytics/AnalyticsWrapper.d.ts.map +1 -0
  84. package/dist/app-frontend/analytics/AnalyticsWrapper.js +27 -0
  85. package/dist/app-frontend/analytics/AnalyticsWrapper.js.map +1 -0
  86. package/{app-frontend → dist/app-frontend}/analytics/types.d.ts +2 -1
  87. package/dist/app-frontend/analytics/types.d.ts.map +1 -0
  88. package/dist/app-frontend/analytics/types.js +2 -0
  89. package/{app-frontend → dist/app-frontend}/analytics/types.js.map +1 -1
  90. package/dist/app-frontend/auth/FirebaseSession.d.ts +32 -0
  91. package/dist/app-frontend/auth/FirebaseSession.d.ts.map +1 -0
  92. package/dist/app-frontend/auth/FirebaseSession.js +72 -0
  93. package/dist/app-frontend/auth/FirebaseSession.js.map +1 -0
  94. package/{app-frontend → dist/app-frontend}/auth/SwFirebaseSession.d.ts +4 -4
  95. package/dist/app-frontend/auth/SwFirebaseSession.d.ts.map +1 -0
  96. package/dist/app-frontend/auth/SwFirebaseSession.js +21 -0
  97. package/dist/app-frontend/auth/SwFirebaseSession.js.map +1 -0
  98. package/{app-frontend → dist/app-frontend}/database/DatabaseWrapper.d.ts +6 -5
  99. package/dist/app-frontend/database/DatabaseWrapper.d.ts.map +1 -0
  100. package/dist/app-frontend/database/DatabaseWrapper.js +90 -0
  101. package/dist/app-frontend/database/DatabaseWrapper.js.map +1 -0
  102. package/{app-frontend → dist/app-frontend}/database/types.d.ts +1 -0
  103. package/dist/app-frontend/database/types.d.ts.map +1 -0
  104. package/{app-backend/storage → dist/app-frontend/database}/types.js +1 -2
  105. package/{app-frontend → dist/app-frontend}/database/types.js.map +1 -1
  106. package/{app-frontend → dist/app-frontend}/messaging/MessagingWrapper.d.ts +3 -2
  107. package/dist/app-frontend/messaging/MessagingWrapper.d.ts.map +1 -0
  108. package/dist/app-frontend/messaging/MessagingWrapper.js +42 -0
  109. package/dist/app-frontend/messaging/MessagingWrapper.js.map +1 -0
  110. package/{app-frontend → dist/app-frontend}/messaging/SwMessagingWrapper.d.ts +3 -2
  111. package/dist/app-frontend/messaging/SwMessagingWrapper.d.ts.map +1 -0
  112. package/{app-frontend → dist/app-frontend}/messaging/SwMessagingWrapper.js +6 -8
  113. package/dist/app-frontend/messaging/SwMessagingWrapper.js.map +1 -0
  114. package/dist/app-frontend/messaging/types.d.ts +4 -0
  115. package/dist/app-frontend/messaging/types.d.ts.map +1 -0
  116. package/{app-backend/push → dist/app-frontend/messaging}/types.js +1 -2
  117. package/{app-frontend → dist/app-frontend}/messaging/types.js.map +1 -1
  118. package/dist/backend-functions.d.ts +2 -0
  119. package/dist/backend-functions.d.ts.map +1 -0
  120. package/dist/backend-functions.js +19 -0
  121. package/{backend-functions.js.map → dist/backend-functions.js.map} +1 -1
  122. package/dist/backend.d.ts +14 -0
  123. package/dist/backend.d.ts.map +1 -0
  124. package/dist/backend.js +32 -0
  125. package/dist/backend.js.map +1 -0
  126. package/dist/frontend.d.ts +7 -0
  127. package/dist/frontend.d.ts.map +1 -0
  128. package/dist/frontend.js +14 -0
  129. package/dist/frontend.js.map +1 -0
  130. package/dist/index.d.ts +2 -0
  131. package/dist/index.d.ts.map +1 -0
  132. package/dist/index.js +19 -0
  133. package/dist/index.js.map +1 -0
  134. package/{shared → dist/shared}/types.d.ts +4 -3
  135. package/dist/shared/types.d.ts.map +1 -0
  136. package/{shared → dist/shared}/types.js +2 -4
  137. package/dist/shared/types.js.map +1 -0
  138. package/dist/tsconfig.tsbuildinfo +1 -0
  139. package/package.json +67 -14
  140. package/app-backend/FirebaseModule.js.map +0 -1
  141. package/app-backend/auth/FirebaseBaseWrapper.js.map +0 -1
  142. package/app-backend/auth/FirebaseSession_Admin.js.map +0 -1
  143. package/app-backend/auth/FirebaseSession_UserPassword.d.ts +0 -0
  144. package/app-backend/auth/firebase-session.js.map +0 -1
  145. package/app-backend/database/DatabaseWrapper.js +0 -125
  146. package/app-backend/database/DatabaseWrapper.js.map +0 -1
  147. package/app-backend/firestore/FirestoreCollection.js +0 -175
  148. package/app-backend/firestore/FirestoreCollection.js.map +0 -1
  149. package/app-backend/firestore/FirestoreInterface.js.map +0 -1
  150. package/app-backend/firestore/FirestoreTransaction.js +0 -194
  151. package/app-backend/firestore/FirestoreTransaction.js.map +0 -1
  152. package/app-backend/firestore/FirestoreV2Collection.js.map +0 -1
  153. package/app-backend/firestore/FirestoreWrapper.js +0 -54
  154. package/app-backend/firestore/FirestoreWrapper.js.map +0 -1
  155. package/app-backend/firestore/types.js.map +0 -1
  156. package/app-backend/functions/firebase-function.js +0 -335
  157. package/app-backend/functions/firebase-function.js.map +0 -1
  158. package/app-backend/push/PushMessagesWrapper.js +0 -69
  159. package/app-backend/push/PushMessagesWrapper.js.map +0 -1
  160. package/app-backend/storage/StorageWrapper.js +0 -236
  161. package/app-backend/storage/StorageWrapper.js.map +0 -1
  162. package/app-frontend/FirebaseModule.js +0 -107
  163. package/app-frontend/FirebaseModule.js.map +0 -1
  164. package/app-frontend/analytics/AnalyticsModule.js +0 -56
  165. package/app-frontend/analytics/AnalyticsModule.js.map +0 -1
  166. package/app-frontend/analytics/AnalyticsWrapper.js +0 -29
  167. package/app-frontend/analytics/AnalyticsWrapper.js.map +0 -1
  168. package/app-frontend/analytics/types.js +0 -3
  169. package/app-frontend/auth/FirebaseSession.d.ts +0 -24
  170. package/app-frontend/auth/FirebaseSession.js +0 -72
  171. package/app-frontend/auth/FirebaseSession.js.map +0 -1
  172. package/app-frontend/auth/SwFirebaseSession.js +0 -23
  173. package/app-frontend/auth/SwFirebaseSession.js.map +0 -1
  174. package/app-frontend/database/DatabaseWrapper.js +0 -113
  175. package/app-frontend/database/DatabaseWrapper.js.map +0 -1
  176. package/app-frontend/messaging/MessagingWrapper.js +0 -53
  177. package/app-frontend/messaging/MessagingWrapper.js.map +0 -1
  178. package/app-frontend/messaging/SwMessagingWrapper.js.map +0 -1
  179. package/app-frontend/messaging/types.d.ts +0 -3
  180. package/app-frontend/messaging/types.js +0 -20
  181. package/backend-functions.d.ts +0 -1
  182. package/backend-functions.js +0 -35
  183. package/backend.d.ts +0 -13
  184. package/backend.js +0 -48
  185. package/backend.js.map +0 -1
  186. package/frontend.d.ts +0 -4
  187. package/frontend.js +0 -21
  188. package/frontend.js.map +0 -1
  189. package/index.d.ts +0 -1
  190. package/index.js +0 -35
  191. package/index.js.map +0 -1
  192. package/shared/types.js.map +0 -1
@@ -0,0 +1,196 @@
1
+ /*
2
+ * Firebase is a simpler Typescript wrapper to all of firebase services.
3
+ *
4
+ * Copyright (C) 2020 Intuition Robotics
5
+ *
6
+ * Licensed under the Apache License, Version 2.0 (the "License");
7
+ * you may not use this file except in compliance with the License.
8
+ * You may obtain a copy of the License at
9
+ *
10
+ * http://www.apache.org/licenses/LICENSE-2.0
11
+ *
12
+ * Unless required by applicable law or agreed to in writing, software
13
+ * distributed under the License is distributed on an "AS IS" BASIS,
14
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15
+ * See the License for the specific language governing permissions and
16
+ * limitations under the License.
17
+ */
18
+ import { BadImplementationException, currentTimeMillies, ThisShouldNotHappenException } from "@intuitionrobotics/ts-common";
19
+ import { Bucket, File, } from "@google-cloud/storage";
20
+ import {} from "./types.js";
21
+ import { FirebaseSession } from "../auth/firebase-session.js";
22
+ import { FirebaseBaseWrapper } from "../auth/FirebaseBaseWrapper.js";
23
+ import { getStorage } from "firebase-admin/storage";
24
+ export class StorageWrapper extends FirebaseBaseWrapper {
25
+ // readonly storage: FirebaseType_Storage;
26
+ storage;
27
+ constructor(firebaseSession) {
28
+ super(firebaseSession);
29
+ this.storage = getStorage(firebaseSession.app);
30
+ }
31
+ async getOrCreateBucket(bucketName) {
32
+ let _bucketName = bucketName;
33
+ if (!_bucketName)
34
+ _bucketName = `gs://${this.firebaseSession.getProjectId()}.appspot.com`;
35
+ if (!_bucketName.startsWith("gs://"))
36
+ throw new BadImplementationException("Bucket name MUST start with 'gs://'");
37
+ const bucket = (await this.storage.bucket(_bucketName).get({ autoCreate: true }))[0];
38
+ // @ts-expect-error TS struggles with this dynamic typing
39
+ return new BucketWrapper(_bucketName, bucket, this);
40
+ }
41
+ }
42
+ export class BucketWrapper {
43
+ bucketName;
44
+ bucket;
45
+ storage;
46
+ constructor(bucketName, bucket, storage) {
47
+ this.bucketName = bucketName;
48
+ this.bucket = bucket;
49
+ this.storage = storage;
50
+ }
51
+ async getFile(pathToRemoteFile) {
52
+ // @ts-expect-error TS struggles with this dynamic typing
53
+ return new FileWrapper(pathToRemoteFile, await this.bucket.file(pathToRemoteFile), this);
54
+ }
55
+ async listFiles(folder = "", filter = () => true) {
56
+ const filteredFiles = [];
57
+ await this.iterateOverFiles(folder, filter, async (file) => filteredFiles.push(file));
58
+ return filteredFiles;
59
+ }
60
+ async deleteFiles(folder = "", filter = () => true) {
61
+ await this.iterateOverFiles(folder, filter, (file) => file.delete());
62
+ }
63
+ async iterateOverFiles(folder, filter, action) {
64
+ return new Promise((resolve, reject) => {
65
+ const callback = async (err, files, nextQuery) => {
66
+ if (err)
67
+ return reject(err);
68
+ if (files) {
69
+ await Promise.all(files.filter(filter).map(file => action(file)));
70
+ }
71
+ if (!nextQuery)
72
+ return resolve();
73
+ this.bucket.getFiles(nextQuery, callback);
74
+ };
75
+ this.bucket.getFiles({
76
+ prefix: folder,
77
+ autoPaginate: false
78
+ }, callback);
79
+ });
80
+ }
81
+ }
82
+ export class FileWrapper {
83
+ file;
84
+ path;
85
+ bucket;
86
+ constructor(path, file, bucket) {
87
+ this.file = file;
88
+ this.bucket = bucket;
89
+ this.path = path;
90
+ }
91
+ async getWriteSecuredUrl(contentType, expiresInMs) {
92
+ const options = {
93
+ action: 'write',
94
+ contentType: contentType,
95
+ expires: currentTimeMillies() + expiresInMs,
96
+ };
97
+ return this.getSignedUrl(options);
98
+ }
99
+ async getReadSecuredUrl(expiresInMs) {
100
+ const options = {
101
+ action: 'read',
102
+ expires: currentTimeMillies() + expiresInMs,
103
+ };
104
+ return this.getSignedUrl(options);
105
+ }
106
+ async exists() {
107
+ return (await this.file.exists())[0];
108
+ }
109
+ async write(data) {
110
+ if (Buffer.isBuffer(data))
111
+ return this.file.save(data);
112
+ switch (typeof data) {
113
+ case "function":
114
+ case "symbol":
115
+ case "bigint":
116
+ case "undefined":
117
+ throw new BadImplementationException(`Cannot save file: ${this.file.name}, data is ${typeof data}`);
118
+ case "object":
119
+ return this.file.save(JSON.stringify(data));
120
+ case "boolean":
121
+ case "number":
122
+ case "string":
123
+ return this.file.save(`${data}`);
124
+ }
125
+ }
126
+ async read() {
127
+ const downloadResponse = await this.file.download();
128
+ return downloadResponse[0];
129
+ }
130
+ async copy(destination) {
131
+ const copy = await this.copyImpl(destination);
132
+ return copy[0];
133
+ }
134
+ copyImpl(destination) {
135
+ if (typeof destination === "string")
136
+ return this.file.copy(destination);
137
+ const bucketWrapper = destination instanceof FileWrapper ? destination.bucket : destination;
138
+ if (this.bucket.storage.firebaseSession !== bucketWrapper.storage.firebaseSession)
139
+ return this.copyByStream(destination);
140
+ if (destination instanceof FileWrapper)
141
+ return this.file.copy(destination.file);
142
+ return this.file.copy(destination.bucket);
143
+ }
144
+ async copyByStream(destination) {
145
+ const destinationFile = destination instanceof FileWrapper ? destination.file : (await destination.getFile(this.path)).file;
146
+ return new Promise((resolve, reject) => {
147
+ this
148
+ .file
149
+ .createReadStream()
150
+ .pipe(destinationFile
151
+ .createWriteStream()
152
+ .on('error', reject)
153
+ .on('finish', () => resolve([destinationFile, undefined])))
154
+ .on('error', reject);
155
+ });
156
+ }
157
+ async move(destination) {
158
+ const file = await this.copy(destination);
159
+ try {
160
+ await this.delete();
161
+ }
162
+ catch (e) {
163
+ try {
164
+ await file.delete();
165
+ }
166
+ catch (err) {
167
+ throw new ThisShouldNotHappenException('Error during the deletion of the recently copied file, check the attached error', err);
168
+ }
169
+ throw new BadImplementationException('Error during the deletion of the file after a successful copy, attached error stack', e);
170
+ }
171
+ }
172
+ async delete() {
173
+ if (!await this.file.exists())
174
+ return;
175
+ return this.file.delete();
176
+ }
177
+ async getSignedUrl(options) {
178
+ const results = await this.file.getSignedUrl(options);
179
+ const url = results[0];
180
+ return {
181
+ fileName: this.path,
182
+ securedUrl: url,
183
+ publicUrl: encodeURI(`https://storage.googleapis.com/${this.bucket.bucketName.replace(`gs://`, '')}/${this.path}`)
184
+ };
185
+ }
186
+ async makePublic() {
187
+ return this.file.makePublic();
188
+ }
189
+ async setMetadata(metadata, options) {
190
+ return (await this.file.setMetadata({ metadata }, options))[0];
191
+ }
192
+ async getMetadata(options) {
193
+ return (await this.file.getMetadata(options))[0];
194
+ }
195
+ }
196
+ //# sourceMappingURL=StorageWrapper.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"StorageWrapper.js","sourceRoot":"","sources":["../../../src/main/app-backend/storage/StorageWrapper.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAEH,OAAO,EACN,0BAA0B,EAC1B,kBAAkB,EAClB,4BAA4B,EAC5B,MAAM,8BAA8B,CAAC;AACtC,OAAO,EACN,MAAM,EACN,IAAI,GAGJ,MAAM,uBAAuB,CAAC;AAC/B,OAAO,EAKN,MAAM,YAAY,CAAC;AACpB,OAAO,EAAC,eAAe,EAAC,MAAM,6BAA6B,CAAC;AAC5D,OAAO,EAAC,mBAAmB,EAAC,MAAM,gCAAgC,CAAC;AACnE,OAAO,EAAC,UAAU,EAAC,MAAM,wBAAwB,CAAC;AAElD,MAAM,OAAO,cACZ,SAAQ,mBAAmB;IAE3B,0CAA0C;IAClC,OAAO,CAAuB;IAEtC,YAAY,eAA0C;QACrD,KAAK,CAAC,eAAe,CAAC,CAAC;QACvB,IAAI,CAAC,OAAO,GAAG,UAAU,CAAC,eAAe,CAAC,GAAG,CAAC,CAAC;IAChD,CAAC;IAED,KAAK,CAAC,iBAAiB,CAAC,UAAmB;QAC1C,IAAI,WAAW,GAAG,UAAU,CAAC;QAC7B,IAAI,CAAC,WAAW;YACf,WAAW,GAAG,QAAQ,IAAI,CAAC,eAAe,CAAC,Y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AC,UAAU,CAAC,OAAO,CAAC,OAAO,EAAE,EAAE,CAAC,IAAI,IAAI,CAAC,IAAI,EAAE,CAAC;SAClH,CAAC;IACH,CAAC;IAED,KAAK,CAAC,UAAU;QACf,OAAO,IAAI,CAAC,IAAI,CAAC,UAAU,EAAE,CAAC;IAC/B,CAAC;IAED,KAAK,CAAC,WAAW,CAAC,QAA+B,EAAE,OAAgB;QAClE,OAAO,CAAC,MAAM,IAAI,CAAC,IAAI,CAAC,WAAW,CAAC,EAAC,QAAQ,EAAC,EAAE,OAAO,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;IAC9D,CAAC;IAED,KAAK,CAAC,WAAW,CAAC,OAAgB;QACjC,OAAO,CAAC,MAAM,IAAI,CAAC,IAAI,CAAC,WAAW,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;IAClD,CAAC;CACD"}
@@ -1,4 +1,4 @@
1
- import { CopyResponse } from "@google-cloud/storage";
1
+ import { type CopyResponse } from "@google-cloud/storage";
2
2
  import { Storage } from "firebase-admin/storage";
3
3
  export type FirebaseType_Storage = Storage;
4
4
  export type FirebaseType_Metadata = any;
@@ -6,3 +6,4 @@ export type ReturnType_Metadata = {
6
6
  metadata?: FirebaseType_Metadata;
7
7
  };
8
8
  export type Firebase_CopyResponse = [CopyResponse[0], CopyResponse[1] | undefined];
9
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/main/app-backend/storage/types.ts"],"names":[],"mappings":"AAkBA,OAAO,EAAC,KAAK,YAAY,EAAC,MAAM,uBAAuB,CAAC;AACxD,OAAO,EAAC,OAAO,EAAC,MAAM,wBAAwB,CAAC;AAC/C,MAAM,MAAM,oBAAoB,GAAI,OAAO,CAAC;AAE5C,MAAM,MAAM,qBAAqB,GAAG,GAAG,CAAC;AACxC,MAAM,MAAM,mBAAmB,GAAG;IAAE,QAAQ,CAAC,EAAE,qBAAqB,CAAA;CAAE,CAAC;AACvE,MAAM,MAAM,qBAAqB,GAAG,CAAC,YAAY,CAAC,CAAC,CAAC,EAAE,YAAY,CAAC,CAAC,CAAC,GAAG,SAAS,CAAC,CAAA"}
@@ -0,0 +1,20 @@
1
+ /*
2
+ * Firebase is a simpler Typescript wrapper to all of firebase services.
3
+ *
4
+ * Copyright (C) 2020 Intuition Robotics
5
+ *
6
+ * Licensed under the Apache License, Version 2.0 (the "License");
7
+ * you may not use this file except in compliance with the License.
8
+ * You may obtain a copy of the License at
9
+ *
10
+ * http://www.apache.org/licenses/LICENSE-2.0
11
+ *
12
+ * Unless required by applicable law or agreed to in writing, software
13
+ * distributed under the License is distributed on an "AS IS" BASIS,
14
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15
+ * See the License for the specific language governing permissions and
16
+ * limitations under the License.
17
+ */
18
+ import {} from "@google-cloud/storage";
19
+ import { Storage } from "firebase-admin/storage";
20
+ //# sourceMappingURL=types.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"types.js","sourceRoot":"","sources":["../../../src/main/app-backend/storage/types.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;GAgBG"}
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../../../src/main/app-backend/storage/types.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAEH,OAAO,EAAmB,MAAM,uBAAuB,CAAC;AACxD,OAAO,EAAC,OAAO,EAAC,MAAM,wBAAwB,CAAC"}
@@ -1,7 +1,7 @@
1
1
  import { Module } from "@intuitionrobotics/ts-common";
2
- import { FirebaseConfig } from "..";
3
- import { FirebaseSession } from "./auth/FirebaseSession";
4
- import { SwFirebaseSession } from "./auth/SwFirebaseSession";
2
+ import { type FirebaseConfig } from "../index.js";
3
+ import { FirebaseSession } from "./auth/FirebaseSession.js";
4
+ import { SwFirebaseSession } from "./auth/SwFirebaseSession.js";
5
5
  type ConfigType = {
6
6
  [s: string]: FirebaseConfig;
7
7
  };
@@ -20,3 +20,4 @@ export declare class FirebaseModule_Class extends Module<ConfigType> {
20
20
  }
21
21
  export declare const FirebaseModule: FirebaseModule_Class;
22
22
  export {};
23
+ //# sourceMappingURL=FirebaseModule.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"FirebaseModule.d.ts","sourceRoot":"","sources":["../../src/main/app-frontend/FirebaseModule.ts"],"names":[],"mappings":"AAAA,OAAO,EAGN,MAAM,EACN,MAAM,8BAA8B,CAAC;AACtC,OAAO,EAAC,KAAK,cAAc,EAAC,MAAM,aAAa,CAAC;AAChD,OAAO,EAAC,eAAe,EAAC,MAAM,2BAA2B,CAAC;AAC1D,OAAO,EAAC,iBAAiB,EAAC,MAAM,6BAA6B,CAAC;AAI9D,KAAK,UAAU,GAAG;IACjB,CAAC,CAAC,EAAE,MAAM,GAAG,cAAc,CAAC;CAC5B,CAAC;AAEF,qBAAa,oBACZ,SAAQ,MAAM,CAAC,UAAU,CAAC;IAE1B,OAAO,CAAC,QAAQ,CAAgD;IAChE,OAAO,CAAC,SAAS,CAAC,CAAoB;;IAOhC,eAAe,IAAI,OAAO,CAAC,iBAAiB,CAAC;YAUrC,kBAAkB;IAmBhC,OAAO,CAAC,gBAAgB,CAUtB;IAEW,aAAa,CAAC,SAAS,CAAC,EAAE,MAAM,GAAG,cAAc,EAAE,KAAK,CAAC,EAAE,MAAM;YAmBhE,wBAAwB;IAWtC,OAAO,CAAC,cAAc;YAIR,eAAe;IAY7B,OAAO,CAAC,WAAW;CAQnB;AAED,eAAO,MAAM,cAAc,sBAA6B,CAAC"}
@@ -0,0 +1,85 @@
1
+ import { BadImplementationException, ImplementationMissingException, Module } from "@intuitionrobotics/ts-common";
2
+ import {} from "../index.js";
3
+ import { FirebaseSession } from "./auth/FirebaseSession.js";
4
+ import { SwFirebaseSession } from "./auth/SwFirebaseSession.js";
5
+ const localSessionId = 'local';
6
+ export class FirebaseModule_Class extends Module {
7
+ sessions = {};
8
+ swSession;
9
+ constructor() {
10
+ super("FirebaseModule");
11
+ }
12
+ async createSwSession() {
13
+ const swSession = this.swSession;
14
+ if (swSession)
15
+ return swSession;
16
+ const localSession = await this.createLocalSession();
17
+ return this.swSession = new SwFirebaseSession(localSessionId, localSession.app);
18
+ }
19
+ async createLocalSession(token) {
20
+ let session = this.sessions[localSessionId];
21
+ if (session)
22
+ return session;
23
+ let localConfig = this.getProjectAuth(localSessionId);
24
+ if (!localConfig)
25
+ localConfig = await this.fetchLocalConfig();
26
+ this.checkConfig(localConfig, localSessionId);
27
+ // I need to recheck because since it is an async op there might be race conditions
28
+ session = this.sessions[localSessionId];
29
+ if (session)
30
+ return session;
31
+ return this.initiateSession(localSessionId, localConfig, token);
32
+ }
33
+ fetchLocalConfig = async () => {
34
+ try {
35
+ const resp = await fetch('/__/firebase/init.json');
36
+ const config = await resp.json();
37
+ // @ts-expect-error TS struggles with this dynamic typing
38
+ this.setConfig({ [localSessionId]: config });
39
+ return config;
40
+ }
41
+ catch (_e) {
42
+ throw new ImplementationMissingException(`Either specify configs for the 'FirebaseModule' or use SDK auto-configuration with firebase hosting`);
43
+ }
44
+ };
45
+ async createSession(projectId, token) {
46
+ if (!projectId)
47
+ return this.createLocalSession(token);
48
+ if (typeof projectId === "object")
49
+ return this.createSessionWithConfigs(projectId, token);
50
+ const session = this.sessions[projectId];
51
+ if (session)
52
+ return session;
53
+ this.logInfo(`Creating session for config: ${projectId}`);
54
+ const config = this.getProjectAuth(projectId);
55
+ this.checkConfig(config, projectId);
56
+ return this.initiateSession(projectId, config, token);
57
+ }
58
+ async createSessionWithConfigs(config, token) {
59
+ this.checkConfig(config, config.projectId);
60
+ const sessionName = config.projectId + (token || '');
61
+ const session = this.sessions[sessionName];
62
+ if (session)
63
+ return session;
64
+ return this.initiateSession(sessionName, config, token);
65
+ }
66
+ getProjectAuth(projectId) {
67
+ return this.config?.[projectId];
68
+ }
69
+ async initiateSession(sessionName, config, token) {
70
+ const session = new FirebaseSession(sessionName, config);
71
+ this.sessions[sessionName] = session;
72
+ await session.connect();
73
+ if (token)
74
+ await session.signInWithToken(token);
75
+ return session;
76
+ }
77
+ checkConfig(config, projectId) {
78
+ if (!config)
79
+ throw new BadImplementationException('Did you forget to add FirebaseModule to the main.ts in the modules array?');
80
+ if (!config || !config.projectId || !config.apiKey || !config.authDomain)
81
+ throw new BadImplementationException(`Config for key ${projectId} is not an Admin credentials pattern`);
82
+ }
83
+ }
84
+ export const FirebaseModule = new FirebaseModule_Class();
85
+ //# sourceMappingURL=FirebaseModule.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"FirebaseModule.js","sourceRoot":"","sources":["../../src/main/app-frontend/FirebaseModule.ts"],"names":[],"mappings":"AAAA,OAAO,EACN,0BAA0B,EAC1B,8BAA8B,EAC9B,MAAM,EACN,MAAM,8BAA8B,CAAC;AACtC,OAAO,EAAqB,MAAM,aAAa,CAAC;AAChD,OAAO,EAAC,eAAe,EAAC,MAAM,2BAA2B,CAAC;AAC1D,OAAO,EAAC,iBAAiB,EAAC,MAAM,6BAA6B,CAAC;AAE9D,MAAM,cAAc,GAAG,OAAO,CAAC;AAM/B,MAAM,OAAO,oBACZ,SAAQ,MAAkB;IAElB,QAAQ,GAA6C,EAAE,CAAC;IACxD,SAAS,CAAqB;IAEtC;QACC,KAAK,CAAC,gBAAgB,CAAC,CAAC;IACzB,CAAC;IAGD,KAAK,CAAC,eAAe;QACpB,MAAM,SAAS,GAAG,IAAI,CAAC,SAAS,CAAC;QACjC,IAAI,SAAS;YACZ,OAAO,SAAS,CAAC;QAElB,MAAM,YAAY,GAAG,MAAM,IAAI,CAAC,kBAAkB,EAAE,CAAC;QAErD,OAAO,IAAI,CAAC,SAAS,GAAG,IAAI,iBAAiB,CAAC,cAAc,EAAE,YAAY,CAAC,GAAG,CAAC,CAAC;IACjF,CAAC;IAEO,KAAK,CAAC,kBAAkB,CAAC,KAAc;QAC9C,IAAI,OAAO,GAAG,IAAI,CAAC,QAAQ,CAAC,cAAc,CAAC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A0B,CAAC,2EAA2E,CAAC,CAAC;QAEnH,IAAI,CAAC,MAAM,IAAI,CAAC,MAAM,CAAC,SAAS,IAAI,CAAC,MAAM,CAAC,MAAM,IAAI,CAAC,MAAM,CAAC,UAAU;YACvE,MAAM,IAAI,0BAA0B,CAAC,kBAAkB,SAAS,sCAAsC,CAAC,CAAC;IAE1G,CAAC;CACD;AAED,MAAM,CAAC,MAAM,cAAc,GAAG,IAAI,oBAAoB,EAAE,CAAC"}
@@ -11,3 +11,4 @@ declare class FirebaseAnalyticsModule_Class extends Module {
11
11
  }
12
12
  export declare const FirebaseAnalyticsModule: FirebaseAnalyticsModule_Class;
13
13
  export {};
14
+ //# sourceMappingURL=AnalyticsModule.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"AnalyticsModule.d.ts","sourceRoot":"","sources":["../../../src/main/app-frontend/analytics/AnalyticsModule.ts"],"names":[],"mappings":"AAkBA,OAAO,EAAiC,MAAM,EAAC,MAAM,8BAA8B,CAAC;AAIpF,cAAM,6BACF,SAAQ,MAAM;;IAMd,OAAO,CAAC,SAAS,CAAC,CAAmB;IAErC,SAAS,CAAC,IAAI,IAAI,IAAI;IAItB,OAAO,CAAC,KAAK,CAKX;IAEF,QAAQ,CAAC,SAAS,EAAE,MAAM,EAAE,WAAW,CAAC,EAAE;QAAE,CAAC,GAAG,EAAE,MAAM,GAAG,GAAG,CAAA;KAAE;IAOhE,gBAAgB,CAAC,UAAU,EAAE,MAAM;CAMtC;AAED,eAAO,MAAM,uBAAuB,+BAAsC,CAAC"}
@@ -0,0 +1,46 @@
1
+ /*
2
+ * Firebase is a simpler Typescript wrapper to all of firebase services.
3
+ *
4
+ * Copyright (C) 2020 Intuition Robotics
5
+ *
6
+ * Licensed under the Apache License, Version 2.0 (the "License");
7
+ * you may not use this file except in compliance with the License.
8
+ * You may obtain a copy of the License at
9
+ *
10
+ * http://www.apache.org/licenses/LICENSE-2.0
11
+ *
12
+ * Unless required by applicable law or agreed to in writing, software
13
+ * distributed under the License is distributed on an "AS IS" BASIS,
14
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15
+ * See the License for the specific language governing permissions and
16
+ * limitations under the License.
17
+ */
18
+ import { ImplementationMissingException, Module } from "@intuitionrobotics/ts-common";
19
+ import { FirebaseModule } from "../FirebaseModule.js";
20
+ import { AnalyticsWrapper } from "./AnalyticsWrapper.js";
21
+ class FirebaseAnalyticsModule_Class extends Module {
22
+ constructor() {
23
+ super("FirebaseAnalyticsModule");
24
+ }
25
+ analytics;
26
+ init() {
27
+ this.runAsync('Init Analytics', this._init);
28
+ }
29
+ _init = async () => {
30
+ const session = await FirebaseModule.createSession();
31
+ this.analytics = await session.getAnalytics();
32
+ this.analytics.setAnalyticsCollectionEnabled(true);
33
+ };
34
+ logEvent(eventName, eventParams) {
35
+ if (!this.analytics)
36
+ throw new ImplementationMissingException('Missing analytics wrapper');
37
+ return this.analytics.logEvent(eventName, eventParams);
38
+ }
39
+ setCurrentScreen(screenName) {
40
+ if (!this.analytics)
41
+ throw new ImplementationMissingException('Missing analytics wrapper');
42
+ return this.analytics.setCurrentScreen(screenName);
43
+ }
44
+ }
45
+ export const FirebaseAnalyticsModule = new FirebaseAnalyticsModule_Class();
46
+ //# sourceMappingURL=AnalyticsModule.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"AnalyticsModule.js","sourceRoot":"","sources":["../../../src/main/app-frontend/analytics/AnalyticsModule.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAEH,OAAO,EAAC,8BAA8B,EAAE,MAAM,EAAC,MAAM,8BAA8B,CAAC;AACpF,OAAO,EAAC,cAAc,EAAC,MAAM,sBAAsB,CAAC;AACpD,OAAO,EAAC,gBAAgB,EAAC,MAAM,uBAAuB,CAAC;AAEvD,MAAM,6BACF,SAAQ,MAAM;IAEd;QACI,KAAK,CAAC,yBAAyB,CAAC,CAAC;IACrC,CAAC;IAEO,SAAS,CAAoB;IAE3B,IAAI;QACV,IAAI,CAAC,QAAQ,CAAC,gBAAgB,EAAE,IAAI,CAAC,KAAK,CAAC,CAAC;IAChD,CAAC;IAEO,KAAK,GAAG,KAAK,IAAI,EAAE;QACvB,MAAM,OAAO,GAAG,MAAM,cAAc,CAAC,aAAa,EAAE,CAAC;QAErD,IAAI,CAAC,SAAS,GAAG,MAAM,OAAO,CAAC,YAAY,EAAE,CAAC;QAC9C,IAAI,CAAC,SAAS,CAAC,6BAA6B,CAAC,IAAI,CAAC,CAAC;IACvD,CAAC,CAAC;IAEF,QAAQ,CAAC,SAAiB,EAAE,WAAoC;QAC5D,IAAI,CAAC,IAAI,CAAC,SAAS;YACf,MAAM,IAAI,8BAA8B,CAAC,2BAA2B,CAAC,CAAC;QAE1E,OAAO,IAAI,CAAC,SAAS,CAAC,QAAQ,CAAC,SAAS,EAAE,WAAW,CAAC,CAAC;IAC3D,CAAC;IAED,gBAAgB,CAAC,UAAkB;QAC/B,IAAI,CAAC,IAAI,CAAC,SAAS;YACf,MAAM,IAAI,8BAA8B,CAAC,2BAA2B,CAAC,CAAC;QAE1E,OAAO,IAAI,CAAC,SAAS,CAAC,gBAAgB,CAAC,UAAU,CAAC,CAAC;IACvD,CAAC;CACJ;AAED,MAAM,CAAC,MAAM,uBAAuB,GAAG,IAAI,6BAA6B,EAAE,CAAC"}
@@ -1,14 +1,15 @@
1
1
  import { Logger } from "@intuitionrobotics/ts-common";
2
- import { FirebaseType_Analytics, FirebaseType_CallOptions, FirebaseType_EventNameString } from "./types";
3
- import { CustomParams } from "firebase/analytics";
2
+ import { type FirebaseType_Analytics, type FirebaseType_CallOptions, type FirebaseType_EventNameString } from "./types.js";
3
+ import { type CustomParams } from "firebase/analytics";
4
4
  export declare class AnalyticsWrapper extends Logger {
5
5
  private readonly analytics;
6
6
  constructor(analytics: FirebaseType_Analytics);
7
7
  setUserId(userId: string, options?: FirebaseType_CallOptions): void;
8
8
  setCurrentScreen(screenName: string, options?: FirebaseType_CallOptions): void;
9
9
  setAnalyticsCollectionEnabled(enabled: boolean): void;
10
- setUserProperties(properties: CustomParams, options?: FirebaseType_CallOptions): void;
11
- logEvent<T extends string>(eventName: FirebaseType_EventNameString | string, eventParams?: {
10
+ setUserProperties(properties: CustomParams, _options?: FirebaseType_CallOptions): void;
11
+ logEvent<_T extends string>(eventName: FirebaseType_EventNameString | string, eventParams?: {
12
12
  [key: string]: any;
13
13
  }, options?: FirebaseType_CallOptions): void;
14
14
  }
15
+ //# sourceMappingURL=AnalyticsWrapper.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"AnalyticsWrapper.d.ts","sourceRoot":"","sources":["../../../src/main/app-frontend/analytics/AnalyticsWrapper.ts"],"names":[],"mappings":"AACA,OAAO,EAAC,MAAM,EAAC,MAAM,8BAA8B,CAAC;AACpD,OAAO,EACN,KAAK,sBAAsB,EAC3B,KAAK,wBAAwB,EAC7B,KAAK,4BAA4B,EACjC,MAAM,YAAY,CAAC;AAEpB,OAAO,EACN,KAAK,YAAY,EAKjB,MAAM,oBAAoB,CAAC;AAE5B,qBAAa,gBACZ,SAAQ,MAAM;IAEd,OAAO,CAAC,QAAQ,CAAC,SAAS,CAAyB;gBAEvC,SAAS,EAAE,sBAAsB;IAK7C,SAAS,CAAC,MAAM,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,wBAAwB;IAI5D,gBAAgB,CAAC,UAAU,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,wBAAwB;IAIvE,6BAA6B,CAAC,OAAO,EAAE,OAAO;IAI9C,iBAAiB,CAAC,UAAU,EAAE,YAAY,EAAE,QAAQ,CAAC,EAAE,wBAAwB;IAI/E,QAAQ,CAAC,EAAE,SAAS,MAAM,EACzB,SAAS,EAAE,4BAA4B,GAAG,MAAM,EAChD,WAAW,CAAC,EAAE;QAAE,CAAC,GAAG,EAAE,MAAM,GAAG,GAAG,CAAA;KAAE,EACpC,OAAO,CAAC,EAAE,wBAAwB;CAKnC"}
@@ -0,0 +1,27 @@
1
+ import { Logger } from "@intuitionrobotics/ts-common";
2
+ import {} from "./types.js";
3
+ // tslint:disable:no-import-side-effect
4
+ import { logEvent, setAnalyticsCollectionEnabled, setUserId, setUserProperties } from "firebase/analytics";
5
+ export class AnalyticsWrapper extends Logger {
6
+ analytics;
7
+ constructor(analytics) {
8
+ super();
9
+ this.analytics = analytics;
10
+ }
11
+ setUserId(userId, options) {
12
+ setUserId(this.analytics, userId, options);
13
+ }
14
+ setCurrentScreen(screenName, options) {
15
+ this.logEvent("screen_view", { screenName }, options);
16
+ }
17
+ setAnalyticsCollectionEnabled(enabled) {
18
+ setAnalyticsCollectionEnabled(this.analytics, enabled);
19
+ }
20
+ setUserProperties(properties, _options) {
21
+ setUserProperties(this.analytics, properties);
22
+ }
23
+ logEvent(eventName, eventParams, options) {
24
+ return logEvent(this.analytics, eventName, eventParams, options);
25
+ }
26
+ }
27
+ //# sourceMappingURL=AnalyticsWrapper.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"AnalyticsWrapper.js","sourceRoot":"","sources":["../../../src/main/app-frontend/analytics/AnalyticsWrapper.ts"],"names":[],"mappings":"AACA,OAAO,EAAC,MAAM,EAAC,MAAM,8BAA8B,CAAC;AACpD,OAAO,EAIN,MAAM,YAAY,CAAC;AACpB,uCAAuC;AACvC,OAAO,EAEN,QAAQ,EACR,6BAA6B,EAC7B,SAAS,EACT,iBAAiB,EACjB,MAAM,oBAAoB,CAAC;AAE5B,MAAM,OAAO,gBACZ,SAAQ,MAAM;IAEG,SAAS,CAAyB;IAEnD,YAAY,SAAiC;QAC5C,KAAK,EAAE,CAAC;QACR,IAAI,CAAC,SAAS,GAAG,SAAS,CAAC;IAC5B,CAAC;IAED,SAAS,CAAC,MAAc,EAAE,OAAkC;QAC3D,SAAS,CAAC,IAAI,CAAC,SAAS,EAAE,MAAM,EAAE,OAAO,CAAC,CAAC;IAC5C,CAAC;IAED,gBAAgB,CAAC,UAAkB,EAAE,OAAkC;QACtE,IAAI,CAAC,QAAQ,CAAC,aAAa,EAAC,EAAC,UAAU,EAAC,EAAE,OAAO,CAAC,CAAA;IACnD,CAAC;IAED,6BAA6B,CAAC,OAAgB;QAC7C,6BAA6B,CAAC,IAAI,CAAC,SAAS,EAAE,OAAO,CAAC,CAAC;IACxD,CAAC;IAED,iBAAiB,CAAC,UAAwB,EAAE,QAAmC;QAC9E,iBAAiB,CAAC,IAAI,CAAC,SAAS,EAAE,UAAU,CAAC,CAAC;IAC/C,CAAC;IAED,QAAQ,CACP,SAAgD,EAChD,WAAoC,EACpC,OAAkC;QAElC,OAAO,QAAQ,CAAC,IAAI,CAAC,SAAS,EAAE,SAAS,EAAE,WAAW,EAAE,OAAO,CAAC,CAAC;IAClE,CAAC;CAED"}
@@ -1,4 +1,5 @@
1
- import { Analytics, EventNameString, AnalyticsCallOptions } from "firebase/analytics";
1
+ import { type Analytics, type EventNameString, type AnalyticsCallOptions } from "firebase/analytics";
2
2
  export type FirebaseType_Analytics = Analytics;
3
3
  export type FirebaseType_CallOptions = AnalyticsCallOptions;
4
4
  export type FirebaseType_EventNameString = EventNameString;
5
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/main/app-frontend/analytics/types.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,KAAK,SAAS,EAAC,KAAK,eAAe,EAAC,KAAK,oBAAoB,EAAE,MAAM,oBAAoB,CAAA;AAElG,MAAM,MAAM,sBAAsB,GAAG,SAAS,CAAA;AAC9C,MAAM,MAAM,wBAAwB,GAAG,oBAAoB,CAAA;AAC3D,MAAM,MAAM,4BAA4B,GAAG,eAAe,CAAA"}
@@ -0,0 +1,2 @@
1
+ import {} from "firebase/analytics";
2
+ //# sourceMappingURL=types.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"types.js","sourceRoot":"","sources":["../../../src/main/app-frontend/analytics/types.ts"],"names":[],"mappings":""}
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../../../src/main/app-frontend/analytics/types.ts"],"names":[],"mappings":"AACA,OAAO,EAAiE,MAAM,oBAAoB,CAAA"}
@@ -0,0 +1,32 @@
1
+ import { Logger } from "@intuitionrobotics/ts-common";
2
+ import type { FirebaseApp } from "firebase/app";
3
+ import type { FirebaseConfig } from "../../index.js";
4
+ import type { MessagingWrapper } from "../messaging/MessagingWrapper.js";
5
+ import type { AnalyticsWrapper } from "../analytics/AnalyticsWrapper.js";
6
+ import type { DatabaseWrapper } from "../database/DatabaseWrapper.js";
7
+ import type { Firestore } from "firebase/firestore";
8
+ /**
9
+ * Lazy-loaded Firebase wrapper. Each service is imported dynamically the
10
+ * first time it's accessed, so consumers that only need (e.g.) Firestore
11
+ * never pull in auth / messaging / analytics / node-forge.
12
+ *
13
+ * connect() must be awaited before any service accessor is used.
14
+ */
15
+ export declare class FirebaseSession extends Logger {
16
+ app: FirebaseApp;
17
+ protected config: FirebaseConfig;
18
+ protected sessionName: string;
19
+ protected messaging?: MessagingWrapper;
20
+ protected analytics?: AnalyticsWrapper;
21
+ protected database?: DatabaseWrapper;
22
+ constructor(sessionName: string, config: FirebaseConfig);
23
+ connect(): Promise<void>;
24
+ getMessaging(): Promise<MessagingWrapper>;
25
+ getAnalytics(): Promise<AnalyticsWrapper>;
26
+ getDatabase(): Promise<DatabaseWrapper>;
27
+ getFirestore(): Promise<Firestore>;
28
+ signInWithToken(token: string): Promise<import("firebase/auth").UserCredential>;
29
+ signOut(): Promise<void>;
30
+ getProjectId(): string;
31
+ }
32
+ //# sourceMappingURL=FirebaseSession.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"FirebaseSession.d.ts","sourceRoot":"","sources":["../../../src/main/app-frontend/auth/FirebaseSession.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,MAAM,EAA+B,MAAM,8BAA8B,CAAC;AAClF,OAAO,KAAK,EAAC,WAAW,EAAC,MAAM,cAAc,CAAC;AAC9C,OAAO,KAAK,EAAC,cAAc,EAAC,MAAM,gBAAgB,CAAC;AACnD,OAAO,KAAK,EAAC,gBAAgB,EAAC,MAAM,kCAAkC,CAAC;AACvE,OAAO,KAAK,EAAC,gBAAgB,EAAC,MAAM,kCAAkC,CAAC;AACvE,OAAO,KAAK,EAAC,eAAe,EAAC,MAAM,gCAAgC,CAAC;AACpE,OAAO,KAAK,EAAC,SAAS,EAAC,MAAM,oBAAoB,CAAC;AAElD;;;;;;GAMG;AACH,qBAAa,eAAgB,SAAQ,MAAM;IAC1C,GAAG,EAAG,WAAW,CAAC;IAElB,SAAS,CAAC,MAAM,EAAE,cAAc,CAAC;IACjC,SAAS,CAAC,WAAW,EAAE,MAAM,CAAC;IAC9B,SAAS,CAAC,SAAS,CAAC,EAAE,gBAAgB,CAAC;IACvC,SAAS,CAAC,SAAS,CAAC,EAAE,gBAAgB,CAAC;IACvC,SAAS,CAAC,QAAQ,CAAC,EAAE,eAAe,CAAC;gBAEzB,WAAW,EAAE,MAAM,EAAE,MAAM,EAAE,cAAc;IAMjD,OAAO,IAAI,OAAO,CAAC,IAAI,CAAC;IAKxB,YAAY,IAAI,OAAO,CAAC,gBAAgB,CAAC;IASzC,YAAY,IAAI,OAAO,CAAC,gBAAgB,CAAC;IASzC,WAAW,IAAI,OAAO,CAAC,eAAe,CAAC;IASvC,YAAY,IAAI,OAAO,CAAC,SAAS,CAAC;IAKlC,eAAe,CAAC,KAAK,EAAE,MAAM;IAK7B,OAAO;IAKb,YAAY,IAAI,MAAM;CAOtB"}
@@ -0,0 +1,72 @@
1
+ import { Logger, ThisShouldNotHappenException } from "@intuitionrobotics/ts-common";
2
+ /**
3
+ * Lazy-loaded Firebase wrapper. Each service is imported dynamically the
4
+ * first time it's accessed, so consumers that only need (e.g.) Firestore
5
+ * never pull in auth / messaging / analytics / node-forge.
6
+ *
7
+ * connect() must be awaited before any service accessor is used.
8
+ */
9
+ export class FirebaseSession extends Logger {
10
+ app;
11
+ config;
12
+ sessionName;
13
+ messaging;
14
+ analytics;
15
+ database;
16
+ constructor(sessionName, config) {
17
+ super(`firebase: ${sessionName}`);
18
+ this.sessionName = sessionName;
19
+ this.config = config;
20
+ }
21
+ async connect() {
22
+ const { initializeApp } = await import("firebase/app");
23
+ this.app = initializeApp(this.config, this.sessionName);
24
+ }
25
+ async getMessaging() {
26
+ if (this.messaging)
27
+ return this.messaging;
28
+ const [messagingMod, wrapperMod] = await Promise.all([
29
+ import("firebase/messaging"),
30
+ import("../messaging/MessagingWrapper.js")
31
+ ]);
32
+ return this.messaging = new wrapperMod.MessagingWrapper(messagingMod.getMessaging(this.app));
33
+ }
34
+ async getAnalytics() {
35
+ if (this.analytics)
36
+ return this.analytics;
37
+ const [analyticsMod, wrapperMod] = await Promise.all([
38
+ import("firebase/analytics"),
39
+ import("../analytics/AnalyticsWrapper.js")
40
+ ]);
41
+ return this.analytics = new wrapperMod.AnalyticsWrapper(analyticsMod.getAnalytics(this.app));
42
+ }
43
+ async getDatabase() {
44
+ if (this.database)
45
+ return this.database;
46
+ const [databaseMod, wrapperMod] = await Promise.all([
47
+ import("firebase/database"),
48
+ import("../database/DatabaseWrapper.js")
49
+ ]);
50
+ return this.database = new wrapperMod.DatabaseWrapper(databaseMod.getDatabase(this.app));
51
+ }
52
+ async getFirestore() {
53
+ const { getFirestore } = await import("firebase/firestore");
54
+ return getFirestore(this.app);
55
+ }
56
+ async signInWithToken(token) {
57
+ const { getAuth, signInWithCustomToken } = await import("firebase/auth");
58
+ return signInWithCustomToken(getAuth(this.app), token);
59
+ }
60
+ async signOut() {
61
+ const { getAuth, signOut } = await import("firebase/auth");
62
+ return signOut(getAuth(this.app));
63
+ }
64
+ getProjectId() {
65
+ if (!this.config)
66
+ throw new ThisShouldNotHappenException("Missing config. Probably init not resolved yet!");
67
+ if (!this.config.projectId)
68
+ throw new ThisShouldNotHappenException("Could not deduce project id from session config.");
69
+ return this.config.projectId;
70
+ }
71
+ }
72
+ //# sourceMappingURL=FirebaseSession.js.map
@@ -0,0 +1 @@
1
+ {"version":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ED,YAAY;QACX,IAAI,CAAC,IAAI,CAAC,MAAM;YACf,MAAM,IAAI,4BAA4B,CAAC,iDAAiD,CAAC,CAAC;QAC3F,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,SAAS;YACzB,MAAM,IAAI,4BAA4B,CAAC,kDAAkD,CAAC,CAAC;QAC5F,OAAO,IAAI,CAAC,MAAM,CAAC,SAAS,CAAC;IAC9B,CAAC;CACD"}
@@ -1,11 +1,11 @@
1
- import { FirebaseApp } from "firebase/app";
2
- import "firebase/auth";
3
1
  import { Logger } from "@intuitionrobotics/ts-common";
4
- import { SwMessagingWrapper } from "../messaging/SwMessagingWrapper";
2
+ import type { FirebaseApp } from "firebase/app";
3
+ import type { SwMessagingWrapper } from "../messaging/SwMessagingWrapper.js";
5
4
  export declare class SwFirebaseSession extends Logger {
6
5
  app: FirebaseApp;
7
6
  protected sessionName: string;
8
7
  protected messaging?: SwMessagingWrapper;
9
8
  constructor(sessionName: string, app: FirebaseApp);
10
- getMessaging(): SwMessagingWrapper;
9
+ getMessaging(): Promise<SwMessagingWrapper>;
11
10
  }
11
+ //# sourceMappingURL=SwFirebaseSession.d.ts.map