@progressive-development/pd-spa-helper 0.8.1 → 0.8.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/PdSpaHelper.d.ts.map +1 -1
- package/dist/PdSpaHelper.js +51 -35
- package/dist/defaultpage/default-login.d.ts +0 -2
- package/dist/defaultpage/default-login.d.ts.map +1 -1
- package/dist/defaultpage/default-login.js +0 -11
- package/dist/defaultpage/default-not-found.d.ts +6 -0
- package/dist/defaultpage/default-not-found.d.ts.map +1 -0
- package/dist/defaultpage/default-not-found.js +33 -0
- package/dist/defaultpage/default-step-address.d.ts.map +1 -1
- package/dist/defaultpage/default-step-address.js +0 -1
- package/dist/defaultpage/default-wizard-step.d.ts.map +1 -1
- package/dist/defaultpage/default-wizard-step.js +0 -2
- package/dist/defaultpage/default-wizard.d.ts.map +1 -1
- package/dist/defaultpage/default-wizard.js +14 -7
- package/dist/helper/date-helper.d.ts.map +1 -1
- package/dist/helper/date-helper.js +2 -1
- package/dist/helper/logger.d.ts +14 -0
- package/dist/helper/logger.d.ts.map +1 -0
- package/dist/helper/logger.js +54 -0
- package/dist/helper/refresh-id-token.d.ts.map +1 -1
- package/dist/helper/refresh-id-token.js +8 -3
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +3 -0
- package/dist/model/spa-model.d.ts +7 -0
- package/dist/model/spa-model.d.ts.map +1 -1
- package/dist/router/PdRouterService.d.ts +0 -1
- package/dist/router/PdRouterService.d.ts.map +1 -1
- package/dist/router/PdRouterService.js +57 -27
- package/dist/router/rout-types.d.ts +3 -1
- package/dist/router/rout-types.d.ts.map +1 -1
- package/dist/service-provider/firebase/auth.d.ts.map +1 -1
- package/dist/service-provider/firebase/auth.js +4 -3
- package/dist/service-provider/firebase/firestorage-client.d.ts.map +1 -1
- package/dist/service-provider/firebase/firestorage-client.js +7 -5
- package/dist/service-provider/firebase/firestore-client.d.ts.map +1 -1
- package/dist/service-provider/firebase/firestore-client.js +2 -1
- package/dist/service-provider/firebase/functions-client.d.ts.map +1 -1
- package/dist/service-provider/firebase/functions-client.js +5 -3
- package/dist/service-provider/firebase/messagingFirebaseClient.d.ts.map +1 -1
- package/dist/service-provider/firebase/messagingFirebaseClient.js +8 -6
- package/dist/service-provider/service-provider-impl.d.ts.map +1 -1
- package/dist/service-provider/service-provider-impl.js +14 -18
- package/dist/store/indexDB.d.ts.map +1 -1
- package/dist/store/indexDB.js +11 -6
- package/dist/store/mini-rx.store.d.ts.map +1 -1
- package/dist/store/mini-rx.store.js +3 -2
- package/dist/store/spa-app-actions.d.ts +9 -2
- package/dist/store/spa-app-actions.d.ts.map +1 -1
- package/dist/store/spa-app-actions.js +3 -1
- package/dist/store/spa-app-effects.d.ts.map +1 -1
- package/dist/store/spa-app-effects.js +3 -2
- package/dist/store/spa-app-reducer.d.ts +11 -3
- package/dist/store/spa-app-reducer.d.ts.map +1 -1
- package/dist/store/spa-app-reducer.js +15 -4
- package/dist/store/spa-app-selector.d.ts +5 -1
- package/dist/store/spa-app-selector.d.ts.map +1 -1
- package/dist/store/spa-app-selector.js +10 -2
- package/dist/stories/routing.stories.d.ts.map +1 -1
- package/package.json +7 -6
|
@@ -1,41 +1,51 @@
|
|
|
1
1
|
import UniversalRouter from "universal-router";
|
|
2
|
+
import { firstValueFrom, first, filter } from "rxjs";
|
|
3
|
+
import { selectAuthUser } from "../store/spa-app-selector.js";
|
|
4
|
+
import { pdStore } from "../store/mini-rx.store.js";
|
|
5
|
+
import { createLogger } from "../helper/logger.js";
|
|
6
|
+
const routingLogger = createLogger("PdRouterService");
|
|
2
7
|
class PdRouterService {
|
|
3
8
|
constructor() {
|
|
4
9
|
this.router = null;
|
|
5
10
|
this.onChangeHandlers = [];
|
|
6
11
|
this.currentRoute = "";
|
|
7
|
-
this.isAuthenticatedWithSessionRedirect = async () => true;
|
|
8
12
|
window.addEventListener("popstate", () => {
|
|
9
13
|
this.resolve(location.pathname + location.search);
|
|
10
14
|
});
|
|
11
15
|
}
|
|
12
|
-
// Default-Fallback, falls nicht überschrieben
|
|
13
16
|
/**
|
|
14
17
|
* Setzt die Routen-Konfiguration. Muss vor Verwendung von navigate() aufgerufen werden.
|
|
15
18
|
*/
|
|
16
19
|
configureRoutes(definitions) {
|
|
17
|
-
|
|
20
|
+
routingLogger.debug(
|
|
18
21
|
"############ CONFIGURE ROUTING SERVICE ##################",
|
|
19
22
|
definitions
|
|
20
23
|
);
|
|
21
|
-
definitions.forEach((def) => {
|
|
22
|
-
console.log(`[ROUTING] ${def.name}:`);
|
|
23
|
-
(Array.isArray(def.pattern) ? def.pattern : [def.pattern]).forEach(
|
|
24
|
-
(p, idx) => {
|
|
25
|
-
console.log(
|
|
26
|
-
` Pattern[${idx}]: "${p}" | Codes: ${[...p].map((c) => c.charCodeAt(0)).join(", ")}`
|
|
27
|
-
);
|
|
28
|
-
}
|
|
29
|
-
);
|
|
30
|
-
});
|
|
31
24
|
const universalRoutes = definitions.flatMap((def) => {
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
path: pattern,
|
|
25
|
+
return {
|
|
26
|
+
path: def.pattern,
|
|
35
27
|
action: async (context) => {
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
28
|
+
var _a, _b;
|
|
29
|
+
if (def.auth) {
|
|
30
|
+
let authResult;
|
|
31
|
+
if (!((_a = context.userCheck) == null ? void 0 : _a.loginCheckFinish)) {
|
|
32
|
+
routingLogger.debug("Check login is running, wait for result...");
|
|
33
|
+
authResult = await waitForFinalAuthState();
|
|
34
|
+
routingLogger.debug("Check login is done, go on");
|
|
35
|
+
context.userCheck = authResult;
|
|
36
|
+
}
|
|
37
|
+
if (!((_b = context.userCheck) == null ? void 0 : _b.user)) {
|
|
38
|
+
const fallbackRoute = def.authFallback ?? "login";
|
|
39
|
+
return { redirect: fallbackRoute };
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
if (def.roles && !def.roles.some(
|
|
43
|
+
(role) => {
|
|
44
|
+
var _a2;
|
|
45
|
+
return ((_a2 = context.userCheck.user.claims) == null ? void 0 : _a2[role]) === true;
|
|
46
|
+
}
|
|
47
|
+
)) {
|
|
48
|
+
return { redirect: "unauthorized" };
|
|
39
49
|
}
|
|
40
50
|
if (def.action) {
|
|
41
51
|
const result = await def.action();
|
|
@@ -48,8 +58,9 @@ class PdRouterService {
|
|
|
48
58
|
params: context.params
|
|
49
59
|
};
|
|
50
60
|
}
|
|
51
|
-
}
|
|
61
|
+
};
|
|
52
62
|
});
|
|
63
|
+
routingLogger.debug("Universal routes transformed: ", universalRoutes);
|
|
53
64
|
this.router = new UniversalRouter(universalRoutes);
|
|
54
65
|
this.resolve(location.pathname + location.search);
|
|
55
66
|
}
|
|
@@ -60,7 +71,7 @@ class PdRouterService {
|
|
|
60
71
|
const fullPath = new URL(path, window.location.origin).pathname + new URL(path, window.location.origin).search;
|
|
61
72
|
const current = window.location.pathname + window.location.search;
|
|
62
73
|
if (!force && current === fullPath) {
|
|
63
|
-
|
|
74
|
+
routingLogger.debug("Navigation skipped (same path):", path);
|
|
64
75
|
return;
|
|
65
76
|
}
|
|
66
77
|
history.pushState({}, "", path);
|
|
@@ -77,20 +88,31 @@ class PdRouterService {
|
|
|
77
88
|
*/
|
|
78
89
|
async resolve(path) {
|
|
79
90
|
if (!this.router) {
|
|
80
|
-
|
|
91
|
+
routingLogger.warn("Router not yet configured");
|
|
81
92
|
return;
|
|
82
93
|
}
|
|
83
94
|
const url = new URL(path, window.location.origin);
|
|
84
95
|
const pathname = url.pathname;
|
|
85
96
|
const query = Object.fromEntries(url.searchParams.entries());
|
|
86
97
|
try {
|
|
87
|
-
|
|
88
|
-
"
|
|
98
|
+
routingLogger.debug(
|
|
99
|
+
"Bevore resolve current location:",
|
|
89
100
|
location.pathname
|
|
90
101
|
);
|
|
91
|
-
const
|
|
102
|
+
const userCheck = await firstValueFrom(
|
|
103
|
+
pdStore().select(selectAuthUser).pipe(first())
|
|
104
|
+
);
|
|
105
|
+
const result = await this.router.resolve({
|
|
106
|
+
pathname,
|
|
107
|
+
userCheck
|
|
108
|
+
});
|
|
109
|
+
if (result.redirect) {
|
|
110
|
+
history.replaceState({}, "", result.redirect);
|
|
111
|
+
await this.resolve(result.redirect);
|
|
112
|
+
return;
|
|
113
|
+
}
|
|
92
114
|
if (!result || typeof result !== "object" || !result.route) {
|
|
93
|
-
|
|
115
|
+
routingLogger.warn("Invalid route result:", result);
|
|
94
116
|
return;
|
|
95
117
|
}
|
|
96
118
|
const routeInfo = {
|
|
@@ -102,10 +124,18 @@ class PdRouterService {
|
|
|
102
124
|
this.currentRoute = routeInfo.route;
|
|
103
125
|
this.onChangeHandlers.forEach((fn) => fn(routeInfo));
|
|
104
126
|
} catch (err) {
|
|
105
|
-
|
|
127
|
+
routingLogger.error("Routing error:", err);
|
|
106
128
|
}
|
|
107
129
|
}
|
|
108
130
|
}
|
|
131
|
+
async function waitForFinalAuthState() {
|
|
132
|
+
return await firstValueFrom(
|
|
133
|
+
pdStore().select(selectAuthUser).pipe(
|
|
134
|
+
filter((res) => res.loginCheckFinish === true),
|
|
135
|
+
first()
|
|
136
|
+
)
|
|
137
|
+
);
|
|
138
|
+
}
|
|
109
139
|
const pdRouterService = new PdRouterService();
|
|
110
140
|
export {
|
|
111
141
|
pdRouterService
|
|
@@ -1,7 +1,9 @@
|
|
|
1
|
+
import { Path } from 'universal-router/path-to-regexp';
|
|
1
2
|
export interface RouteDefinition {
|
|
2
3
|
name: string;
|
|
3
|
-
pattern:
|
|
4
|
+
pattern: Path | Path[];
|
|
4
5
|
auth?: boolean;
|
|
6
|
+
roles?: string[];
|
|
5
7
|
authFallback?: string;
|
|
6
8
|
action?: () => Promise<{
|
|
7
9
|
route: string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"rout-types.d.ts","sourceRoot":"","sources":["../../src/router/rout-types.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,eAAe;IAC9B,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"rout-types.d.ts","sourceRoot":"","sources":["../../src/router/rout-types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,iCAAiC,CAAC;AAEvD,MAAM,WAAW,eAAe;IAC9B,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,IAAI,GAAG,IAAI,EAAE,CAAC;IACvB,IAAI,CAAC,EAAE,OAAO,CAAC;IACf,KAAK,CAAC,EAAE,MAAM,EAAE,CAAC;IACjB,YAAY,CAAC,EAAE,MAAM,CAAC;IAGtB,MAAM,CAAC,EAAE,MAAM,OAAO,CAAC;QAAE,KAAK,EAAE,MAAM,CAAA;KAAE,GAAG,IAAI,CAAC,CAAC;IACjD,UAAU,CAAC,EAAE,MAAM,CAAC;CACrB;AAED,MAAM,WAAW,eAAe;IAC9B,KAAK,EAAE,MAAM,CAAC;IACd,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAC/B,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;CAC/B"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"auth.d.ts","sourceRoot":"","sources":["../../../src/service-provider/firebase/auth.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAC3C,OAAO,EAOL,IAAI,EACL,MAAM,eAAe,CAAC;
|
|
1
|
+
{"version":3,"file":"auth.d.ts","sourceRoot":"","sources":["../../../src/service-provider/firebase/auth.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAC3C,OAAO,EAOL,IAAI,EACL,MAAM,eAAe,CAAC;AAOvB;;;;GAIG;AACH,eAAO,MAAM,QAAQ,GAAI,UAAU,WAAW,SAG7C,CAAC;AAEF,eAAO,MAAM,MAAM,QAAa,OAAO,CAAC,OAAO,CAU9C,CAAC;AAEF,eAAO,MAAM,eAAe,QAAO,OAMlC,CAAC;AAEF,eAAO,MAAM,WAAW,QAAO,OAK9B,CAAC;AAEF,eAAO,MAAM,sBAAsB,GACjC,SAAS,OAAO,KACf,OAAO,CACN;IACE,SAAS,EAAE,MAAM,CAAC;IAClB,QAAQ,EAAE,MAAM,CAAC;CAClB,GACD,SAAS,CAaZ,CAAC;AAEF,eAAO,MAAM,gBAAgB,GAAI,UAAU,CAAC,IAAI,EAAE,GAAG,KAAK,IAAI,SAiC7D,CAAC;AAEF,eAAO,MAAM,uBAAuB,GAAI,UAAU,CAAC,IAAI,EAAE,GAAG,KAAK,IAAI,SAEpE,CAAC;AAEF,eAAO,MAAM,KAAK,GAAU,MAAM,MAAM,EAAE,KAAK,MAAM,KAAG,OAAO,CAAC,IAAI,CAMnE,CAAC"}
|
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
import { getAuth, onIdTokenChanged, onAuthStateChanged, signInWithEmailAndPassword, signOut } from "firebase/auth";
|
|
2
|
+
import { createLogger } from "../../helper/logger.js";
|
|
3
|
+
const authLogger = createLogger("PdUserAuth");
|
|
2
4
|
let auth;
|
|
3
5
|
const initAuth = (appParam) => {
|
|
4
6
|
auth = getAuth(appParam);
|
|
5
|
-
|
|
7
|
+
authLogger.debug("App for auth is set: ", auth);
|
|
6
8
|
};
|
|
7
9
|
const logout = async () => {
|
|
8
10
|
if (!auth) {
|
|
@@ -20,7 +22,6 @@ const isAuthenticated = () => {
|
|
|
20
22
|
throw new Error("isAuthenticated: Auth was not initialized");
|
|
21
23
|
}
|
|
22
24
|
const authCheck = auth.currentUser !== null;
|
|
23
|
-
console.log("Check auth: ", authCheck);
|
|
24
25
|
return authCheck;
|
|
25
26
|
};
|
|
26
27
|
const getAuthUser = () => {
|
|
@@ -44,7 +45,7 @@ const authStateChanged = (callback) => {
|
|
|
44
45
|
if (!auth) {
|
|
45
46
|
throw new Error("authStateChanged: Auth was not initialized");
|
|
46
47
|
}
|
|
47
|
-
onAuthStateChanged(auth,
|
|
48
|
+
onAuthStateChanged(auth, callback);
|
|
48
49
|
};
|
|
49
50
|
const authIdTokenStateChanged = (callback) => {
|
|
50
51
|
onIdTokenChanged(auth, (user) => callback(user));
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"firestorage-client.d.ts","sourceRoot":"","sources":["../../../src/service-provider/firebase/firestorage-client.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAC3C,OAAO,EAKL,YAAY,EAQb,MAAM,kBAAkB,CAAC;AAE1B,OAAO,EACL,iBAAiB,EACjB,eAAe,EACf,UAAU,EACX,MAAM,8BAA8B,CAAC;
|
|
1
|
+
{"version":3,"file":"firestorage-client.d.ts","sourceRoot":"","sources":["../../../src/service-provider/firebase/firestorage-client.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAC3C,OAAO,EAKL,YAAY,EAQb,MAAM,kBAAkB,CAAC;AAE1B,OAAO,EACL,iBAAiB,EACjB,eAAe,EACf,UAAU,EACX,MAAM,8BAA8B,CAAC;AAqBtC;;;;GAIG;AACH,eAAO,MAAM,eAAe,GAC1B,KAAK,WAAW,EAChB,iBAAiB,MAAM,EACvB,gBAAgB,iBAAiB,SAkClC,CAAC;AAEF,eAAO,MAAM,kBAAkB,QAAO,iBAAiB,GAAG,SAC7C,CAAC;AAEd,eAAO,MAAM,qBAAqB,GAChC,MAAM,UAAU,KACf,OAAO,CAAC,YAAY,CA8CtB,CAAC;AAsFF,eAAO,MAAM,kBAAkB,GAC7B,aAAa,MAAM,EACnB,QAAQ,MAAM,EACd,YAAY,MAAM,EAClB,yBAAuB,KACtB,OAAO,CAAC,eAAe,CA2CzB,CAAC;AAEF,eAAO,MAAM,sBAAsB,GACjC,aAAa,MAAM,EACnB,QAAQ,MAAM,EACd,YAAY,MAAM,EAClB,kBAAkB,OAAO,KACxB,OAAO,CAAC,eAAe,EAAE,CAoC3B,CAAC;AAEF,eAAO,MAAM,uBAAuB,GAAI,MAAM,eAAe,oBAY5D,CAAC;AAEF;;;;;GAKG;AACH,wBAAsB,yBAAyB,CAC7C,UAAU,EAAE,eAAe,GAC1B,OAAO,CAAC,IAAI,CAAC,CAsBf"}
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import { getStorage, ref, uploadString, getMetadata, getDownloadURL, deleteObject, listAll } from "firebase/storage";
|
|
2
2
|
import { getUser } from "../service-provider-impl.js";
|
|
3
|
+
import { createLogger } from "../../helper/logger.js";
|
|
4
|
+
const storageLogger = createLogger("PdStorage");
|
|
3
5
|
const DEFAULT_STORAGE = "default_storage";
|
|
4
6
|
let storageConf;
|
|
5
7
|
const storageMap = /* @__PURE__ */ new Map();
|
|
@@ -29,7 +31,7 @@ const initFirestorage = (app, defaultStorage, storageConfig) => {
|
|
|
29
31
|
});
|
|
30
32
|
});
|
|
31
33
|
} catch (error) {
|
|
32
|
-
|
|
34
|
+
storageLogger.error("Init error", error);
|
|
33
35
|
}
|
|
34
36
|
};
|
|
35
37
|
const getFirestorageConf = () => storageConf;
|
|
@@ -125,7 +127,7 @@ const fetchItemsAndFolders = async (usedRef, storageName, refKey, includeMetaDat
|
|
|
125
127
|
}
|
|
126
128
|
return itemRefs;
|
|
127
129
|
} catch (error) {
|
|
128
|
-
|
|
130
|
+
storageLogger.error("Error during file and folder listing:", error);
|
|
129
131
|
throw error;
|
|
130
132
|
}
|
|
131
133
|
};
|
|
@@ -162,7 +164,7 @@ const getFirestorageFile = async (storageName, refKey, storageURI, includeMetaDa
|
|
|
162
164
|
}
|
|
163
165
|
return storageDocument;
|
|
164
166
|
} catch (error) {
|
|
165
|
-
|
|
167
|
+
storageLogger.error("Error creating StorageDocument:", error);
|
|
166
168
|
throw error;
|
|
167
169
|
}
|
|
168
170
|
};
|
|
@@ -218,9 +220,9 @@ async function deleteFirestorageDocument(deleteFile) {
|
|
|
218
220
|
const deleteRef = ref(storageConf2.storage, deleteFile.filePath);
|
|
219
221
|
try {
|
|
220
222
|
await deleteObject(deleteRef);
|
|
221
|
-
|
|
223
|
+
storageLogger.info(`File ${deleteFile.fileName} successfully deleted.`);
|
|
222
224
|
} catch (error) {
|
|
223
|
-
|
|
225
|
+
storageLogger.error("Error deleting file:", error);
|
|
224
226
|
throw error;
|
|
225
227
|
}
|
|
226
228
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"firestore-client.d.ts","sourceRoot":"","sources":["../../../src/service-provider/firebase/firestore-client.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAC3C,OAAO,EAEL,SAAS,EAMV,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EAAE,mBAAmB,EAAE,MAAM,2BAA2B,CAAC;
|
|
1
|
+
{"version":3,"file":"firestore-client.d.ts","sourceRoot":"","sources":["../../../src/service-provider/firebase/firestore-client.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAC3C,OAAO,EAEL,SAAS,EAMV,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EAAE,mBAAmB,EAAE,MAAM,2BAA2B,CAAC;AAMhE;;;;GAIG;AACH,eAAO,MAAM,aAAa,GAAI,KAAK,WAAW,SAO7C,CAAC;AAEF,eAAO,MAAM,KAAK,QAAO,SAAe,CAAC;AAEzC,eAAO,MAAM,6BAA6B,GACxC,UAAU,CAAC,KAAK,EAAE,GAAG,KAAK,IAAI,EAC9B,KAAK,MAAM,EACX,cAAc,mBAAmB,EAAE,8CAYpC,CAAC"}
|
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
import { getFirestore, where, query, collection, onSnapshot } from "firebase/firestore";
|
|
2
|
+
import { defaultLogger } from "../../helper/logger.js";
|
|
2
3
|
let db;
|
|
3
4
|
const initFirestore = (app) => {
|
|
4
5
|
try {
|
|
5
6
|
db = getFirestore(app);
|
|
6
7
|
} catch (error) {
|
|
7
|
-
|
|
8
|
+
defaultLogger.error("Error during firestore init", error);
|
|
8
9
|
}
|
|
9
10
|
};
|
|
10
11
|
const getFirebaseCollectionListener = (callback, col, constraints) => {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"functions-client.d.ts","sourceRoot":"","sources":["../../../src/service-provider/firebase/functions-client.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAG3C,OAAO,EAEL,kBAAkB,EAClB,cAAc,EACd,eAAe,EAEhB,MAAM,8BAA8B,CAAC;
|
|
1
|
+
{"version":3,"file":"functions-client.d.ts","sourceRoot":"","sources":["../../../src/service-provider/firebase/functions-client.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAG3C,OAAO,EAEL,kBAAkB,EAClB,cAAc,EACd,eAAe,EAEhB,MAAM,8BAA8B,CAAC;AAUtC;;;;GAIG;AACH,eAAO,MAAM,aAAa,GACxB,KAAK,WAAW,EAChB,iBAAiB,eAAe,SAajC,CAAC;AAgGF,eAAO,MAAM,YAAY,GACvB,KAAK,kBAAkB,EACvB,eAAe,GAAG,KACjB,OAAO,CAAC,cAAc,CAA6C,CAAC"}
|
|
@@ -3,6 +3,8 @@ import { getFunctions, httpsCallable } from "firebase/functions";
|
|
|
3
3
|
import { SC_INVALID_USER, BusinessError } from "../service-provider-model.js";
|
|
4
4
|
import { pdStore } from "../../store/mini-rx.store.js";
|
|
5
5
|
import { toastAction } from "../../store/spa-app-actions.js";
|
|
6
|
+
import { createLogger } from "../../helper/logger.js";
|
|
7
|
+
const functionLogger = createLogger("PdFunctions");
|
|
6
8
|
const functionMap = /* @__PURE__ */ new Map();
|
|
7
9
|
const initFunctions = (app, functionsConfig) => {
|
|
8
10
|
try {
|
|
@@ -11,13 +13,13 @@ const initFunctions = (app, functionsConfig) => {
|
|
|
11
13
|
functionMap.set(func, httpsCallable(functions, func.name));
|
|
12
14
|
});
|
|
13
15
|
} catch (error) {
|
|
14
|
-
|
|
16
|
+
functionLogger.error("error during function result", error);
|
|
15
17
|
}
|
|
16
18
|
};
|
|
17
19
|
const internalCallFunction = async (def, functionInput) => {
|
|
18
20
|
const funcRef = functionMap.get(def);
|
|
19
21
|
if (!funcRef) {
|
|
20
|
-
|
|
22
|
+
functionLogger.error("No function available for ", def.name);
|
|
21
23
|
throw new Error("Illegal state, no function available");
|
|
22
24
|
}
|
|
23
25
|
try {
|
|
@@ -38,7 +40,7 @@ const internalCallFunction = async (def, functionInput) => {
|
|
|
38
40
|
}
|
|
39
41
|
throw new Error(`Unexpected error: ${statusCode} - ${resultData}`);
|
|
40
42
|
} catch (error) {
|
|
41
|
-
|
|
43
|
+
functionLogger.error("Error in internalCallFunction:", error);
|
|
42
44
|
throw error;
|
|
43
45
|
}
|
|
44
46
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"messagingFirebaseClient.d.ts","sourceRoot":"","sources":["../../../src/service-provider/firebase/messagingFirebaseClient.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAC3C,OAAO,EAA0B,SAAS,EAAE,MAAM,oBAAoB,CAAC;AAGvE,OAAO,EAAE,eAAe,EAAE,MAAM,8BAA8B,CAAC;
|
|
1
|
+
{"version":3,"file":"messagingFirebaseClient.d.ts","sourceRoot":"","sources":["../../../src/service-provider/firebase/messagingFirebaseClient.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAC3C,OAAO,EAA0B,SAAS,EAAE,MAAM,oBAAoB,CAAC;AAGvE,OAAO,EAAE,eAAe,EAAE,MAAM,8BAA8B,CAAC;AAQ/D,eAAO,MAAM,kBAAkB,qCAAqC,CAAC;AAOrE,wBAAgB,gBAAgB,CAC9B,GAAG,EAAE,WAAW,EAChB,aAAa,EAAE,eAAe,QAI/B;AAED,eAAO,MAAM,0BAA0B,GAAI,SAAS,MAAM,SAczD,CAAC;AA8BF,eAAO,MAAM,cAAc,GACzB,cAAc,yBAAyB,kBAoBxC,CAAC;AAEF,eAAO,MAAM,oBAAoB,iBAAkB,CAAC"}
|
|
@@ -3,7 +3,9 @@ import { update, USER_COLLECTION } from "../../store/indexDB.js";
|
|
|
3
3
|
import { pdStore } from "../../store/mini-rx.store.js";
|
|
4
4
|
import { updateNewNotificationToken } from "../../store/spa-app-actions.js";
|
|
5
5
|
import { authIdTokenStateChanged } from "./auth.js";
|
|
6
|
+
import { createLogger } from "../../helper/logger.js";
|
|
6
7
|
const NOTIFICATION_TOKEN = "pd.spa.helper.notification.token";
|
|
8
|
+
const messagingLogger = createLogger("PdMessaging");
|
|
7
9
|
let messaging;
|
|
8
10
|
let firebaseMessagingAppConfigKey;
|
|
9
11
|
function prepareMessaging(app, messageConfig) {
|
|
@@ -20,7 +22,7 @@ const activateTokenChangeHandler = (appName) => {
|
|
|
20
22
|
userNameToken: user.displayName,
|
|
21
23
|
userIdToken: token
|
|
22
24
|
});
|
|
23
|
-
|
|
25
|
+
messagingLogger.info("UserToken stored in local db");
|
|
24
26
|
}
|
|
25
27
|
}
|
|
26
28
|
});
|
|
@@ -36,21 +38,21 @@ const initMessageToken = async (registration) => {
|
|
|
36
38
|
if (currentToken) {
|
|
37
39
|
const storedToken = localStorage.getItem(NOTIFICATION_TOKEN);
|
|
38
40
|
if (storedToken !== currentToken) {
|
|
39
|
-
|
|
41
|
+
messagingLogger.info("Update new token in Backend");
|
|
40
42
|
pdStore().dispatch(
|
|
41
43
|
updateNewNotificationToken({
|
|
42
44
|
messagingToken: currentToken
|
|
43
45
|
})
|
|
44
46
|
);
|
|
45
47
|
} else {
|
|
46
|
-
|
|
48
|
+
messagingLogger.info("RegisterDevice: Stored token is valid");
|
|
47
49
|
}
|
|
48
50
|
} else {
|
|
49
|
-
|
|
51
|
+
messagingLogger.warn("No token received - no new token was generated.");
|
|
50
52
|
}
|
|
51
53
|
};
|
|
52
54
|
const registerDevice = async (registration) => {
|
|
53
|
-
|
|
55
|
+
messagingLogger.info("Start registering app for messages and notifications");
|
|
54
56
|
if (Notification.permission === "default") {
|
|
55
57
|
await Notification.requestPermission();
|
|
56
58
|
}
|
|
@@ -58,7 +60,7 @@ const registerDevice = async (registration) => {
|
|
|
58
60
|
await initMessageToken(registration);
|
|
59
61
|
}
|
|
60
62
|
if (Notification.permission === "denied") {
|
|
61
|
-
|
|
63
|
+
messagingLogger.warn("Messaging not possible, missing rights");
|
|
62
64
|
}
|
|
63
65
|
};
|
|
64
66
|
const getFirebaseMessaging = () => messaging;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"service-provider-impl.d.ts","sourceRoot":"","sources":["../../src/service-provider/service-provider-impl.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAiB,MAAM,cAAc,CAAC;AAkB1D,OAAO,EACL,gBAAgB,EAChB,mBAAmB,EACnB,iBAAiB,EACjB,kBAAkB,EAClB,cAAc,EACd,4BAA4B,EAC5B,eAAe,EACf,UAAU,EACX,MAAM,6BAA6B,CAAC;
|
|
1
|
+
{"version":3,"file":"service-provider-impl.d.ts","sourceRoot":"","sources":["../../src/service-provider/service-provider-impl.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAiB,MAAM,cAAc,CAAC;AAkB1D,OAAO,EACL,gBAAgB,EAChB,mBAAmB,EACnB,iBAAiB,EACjB,kBAAkB,EAClB,cAAc,EACd,4BAA4B,EAC5B,eAAe,EACf,UAAU,EACX,MAAM,6BAA6B,CAAC;AA8CrC,eAAO,MAAM,kBAAkB,GAC7B,gBAAgB,4BAA4B,SAG7C,CAAC;AAqCF,eAAO,MAAM,WAAW,GAAI,QAAQ,gBAAgB,SAWnD,CAAC;AAKF,eAAO,MAAM,gBAAgB,GAC3B,KAAK,kBAAkB,EACvB,eAAe,GAAG,KACjB,OAAO,CAAC,cAAc,CASxB,CAAC;AAMF,eAAO,MAAM,oBAAoB,GAAI,UAAU,CAAC,IAAI,EAAE,GAAG,KAAK,IAAI,SAQjE,CAAC;AAEF,eAAO,MAAM,mBAAmB,eAQ/B,CAAC;AAEF,eAAO,MAAM,kCAAkC,GAC7C,WAAW,MAAM,KAChB,OAAO,CAAC,OAAO,CAMjB,CAAC;AAEF,eAAO,MAAM,SAAS,GAAI,MAAM,MAAM,EAAE,KAAK,MAAM,qBAiBlD,CAAC;AAEF,eAAO,MAAM,UAAU,wBAQtB,CAAC;AAGF,eAAO,MAAM,OAAO,eAQnB,CAAC;AAKF,eAAO,MAAM,UAAU,GAAI,MAAM,UAAU,KAAG,OAAO,CAAC,OAAO,CAQ5D,CAAC;AAEF,eAAO,MAAM,kBAAkB,GAC7B,aAAa,MAAM,EACnB,QAAQ,MAAM,EACd,YAAY,MAAM,EAClB,kBAAkB,OAAO,KACxB,OAAO,CAAC,eAAe,EAAE,CAa3B,CAAC;AAEF,eAAO,MAAM,cAAc,GACzB,aAAa,MAAM,EACnB,QAAQ,MAAM,EACd,YAAY,MAAM,EAClB,iBAAiB,OAAO,KACvB,OAAO,CAAC,eAAe,CAKzB,CAAC;AAEF,eAAO,MAAM,YAAY,GAAI,MAAM,eAAe,KAAG,OAAO,CAAC,OAAO,CAQnE,CAAC;AAEF,eAAO,MAAM,UAAU,GAAI,MAAM,eAAe,KAAG,OAAO,CAAC,OAAO,CAKjE,CAAC;AAEF,eAAO,MAAM,uBAAuB,QAAO,iBAAiB,GAAG,SAK9D,CAAC;AAKF,eAAO,MAAM,0BAA0B,GACrC,UAAU,CAAC,KAAK,EAAE,GAAG,KAAK,IAAI,EAC9B,KAAK,MAAM,EACX,cAAc,mBAAmB,EAAE,mDAYpC,CAAC;AAKF,eAAO,MAAM,gCAAgC,GAC3C,cAAc,yBAAyB,kBAYxC,CAAC;AAEF,eAAO,MAAM,gBAAgB,2DAS5B,CAAC;AAEF,eAAO,MAAM,cAAc,GACzB,SAAS,OAAO,KACf,OAAO,CACN;IACE,SAAS,EAAE,MAAM,CAAC;IAClB,QAAQ,EAAE,MAAM,CAAC;IACjB,OAAO,EAAE,MAAM,CAAC;CACjB,GACD,SAAS,CAgBZ,CAAC;AAEF,eAAO,MAAM,MAAM,mBAAY,CAAC"}
|
|
@@ -7,7 +7,9 @@ import { initMockResponse, callFunctionMock } from "./mock/function-client.js";
|
|
|
7
7
|
import { initFirestorage, uploadFirestorageFile, getFirestorageFileList, getFirestorageFile, downloadFileFirestorage, deleteFirestorageDocument, getFirestorageConf } from "./firebase/firestorage-client.js";
|
|
8
8
|
import { initStorageMock, uploadStorageFileMock, getMockFileList, downloadFileMock } from "./mock/storage-client.js";
|
|
9
9
|
import { prepareMessaging, activateTokenChangeHandler, registerDevice, getFirebaseMessaging } from "./firebase/messagingFirebaseClient.js";
|
|
10
|
-
import
|
|
10
|
+
import "../PdSpaHelper.js";
|
|
11
|
+
import { createLogger } from "../helper/logger.js";
|
|
12
|
+
const serviceLogger = createLogger("PdServiceProvider");
|
|
11
13
|
let provider;
|
|
12
14
|
let app;
|
|
13
15
|
const throwUndefinedProviderError = () => {
|
|
@@ -24,7 +26,7 @@ const initFirebaseApplicationServices = (firebaseApp, config) => {
|
|
|
24
26
|
initFirestore(firebaseApp);
|
|
25
27
|
if (config.functionsConfig) {
|
|
26
28
|
initFunctions(firebaseApp, config.functionsConfig);
|
|
27
|
-
|
|
29
|
+
serviceLogger.debug("Init provider functions");
|
|
28
30
|
}
|
|
29
31
|
if (((_a = config.firebaseConfig) == null ? void 0 : _a.storageBucket) && config.storageConfig) {
|
|
30
32
|
initFirestorage(
|
|
@@ -32,17 +34,17 @@ const initFirebaseApplicationServices = (firebaseApp, config) => {
|
|
|
32
34
|
(_b = config.firebaseConfig) == null ? void 0 : _b.storageBucket,
|
|
33
35
|
config.storageConfig
|
|
34
36
|
);
|
|
35
|
-
|
|
37
|
+
serviceLogger.debug("Init provider storage");
|
|
36
38
|
}
|
|
37
39
|
if (config.messagingConfig) {
|
|
38
40
|
prepareMessaging(firebaseApp, config.messagingConfig);
|
|
39
|
-
|
|
41
|
+
serviceLogger.debug("Set firebase app and config for messaging");
|
|
40
42
|
activateTokenChangeHandler(firebaseApp.name);
|
|
41
|
-
|
|
43
|
+
serviceLogger.debug(
|
|
42
44
|
`idTokenChangeHandler for messaging and app ${firebaseApp.name} activated`
|
|
43
45
|
);
|
|
44
46
|
}
|
|
45
|
-
|
|
47
|
+
serviceLogger.debug("Firebase initialized");
|
|
46
48
|
};
|
|
47
49
|
const initAppImpl = (config) => {
|
|
48
50
|
if (provider === "firebase" && config.firebaseConfig) {
|
|
@@ -82,13 +84,6 @@ const isAuthenticatedImpl = () => {
|
|
|
82
84
|
}
|
|
83
85
|
return throwUndefinedProviderError();
|
|
84
86
|
};
|
|
85
|
-
const isAuthenticatedWithSessionRedirect = (routeName) => {
|
|
86
|
-
const isAuth = isAuthenticatedImpl();
|
|
87
|
-
if (!isAuth && routeName !== "login") {
|
|
88
|
-
sessionStorage.setItem(POST_LOGIN_REDIRECT_KEY, routeName);
|
|
89
|
-
}
|
|
90
|
-
return Promise.resolve(isAuth);
|
|
91
|
-
};
|
|
92
87
|
const loginImpl = (user, sec) => {
|
|
93
88
|
if (!user) {
|
|
94
89
|
const returnError = new Error("empty user");
|
|
@@ -179,7 +174,9 @@ const activateCollectionListener = (callback, col, constraints) => {
|
|
|
179
174
|
return getFirebaseCollectionListener(callback, col, constraints);
|
|
180
175
|
}
|
|
181
176
|
if (provider === "mock") {
|
|
182
|
-
|
|
177
|
+
serviceLogger.warn(
|
|
178
|
+
"getCollectionListener not implemented for MOCK, do noting"
|
|
179
|
+
);
|
|
183
180
|
return "";
|
|
184
181
|
}
|
|
185
182
|
return throwUndefinedProviderError();
|
|
@@ -189,7 +186,7 @@ const registerAppDeviceForNotification = async (registration) => {
|
|
|
189
186
|
return registerDevice(registration);
|
|
190
187
|
}
|
|
191
188
|
if (provider === "mock") {
|
|
192
|
-
|
|
189
|
+
serviceLogger.warn(
|
|
193
190
|
"registerAppDeviceForNotification not implemented for MOCK, do noting"
|
|
194
191
|
);
|
|
195
192
|
return Promise.resolve();
|
|
@@ -201,7 +198,7 @@ const getMessagingImpl = () => {
|
|
|
201
198
|
return getFirebaseMessaging();
|
|
202
199
|
}
|
|
203
200
|
if (provider === "mock") {
|
|
204
|
-
|
|
201
|
+
serviceLogger.warn("getMessagingImpl not implemented for MOCK, do noting");
|
|
205
202
|
return void 0;
|
|
206
203
|
}
|
|
207
204
|
return throwUndefinedProviderError();
|
|
@@ -215,7 +212,7 @@ const getUserIdToken = async (refresh) => {
|
|
|
215
212
|
} : void 0;
|
|
216
213
|
}
|
|
217
214
|
if (provider === "mock") {
|
|
218
|
-
|
|
215
|
+
serviceLogger.warn("getUserIdToken not implemented for MOCK, do noting");
|
|
219
216
|
return void 0;
|
|
220
217
|
}
|
|
221
218
|
return throwUndefinedProviderError();
|
|
@@ -236,7 +233,6 @@ export {
|
|
|
236
233
|
getUserIdToken,
|
|
237
234
|
initAppImpl,
|
|
238
235
|
isAuthenticatedImpl,
|
|
239
|
-
isAuthenticatedWithSessionRedirect,
|
|
240
236
|
loginImpl,
|
|
241
237
|
logoutImpl,
|
|
242
238
|
registerAppDeviceForNotification,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"indexDB.d.ts","sourceRoot":"","sources":["../../src/store/indexDB.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"indexDB.d.ts","sourceRoot":"","sources":["../../src/store/indexDB.ts"],"names":[],"mappings":"AAQA,eAAO,MAAM,eAAe,mBAAmB,CAAC;AAmBhD,eAAO,MAAM,GAAG,GAAI,CAAC,EAAE,OAAO,MAAM,EAAE,IAAI,CAAC,EAAE,kBAAkB,OAAO,qBAclE,CAAC;AAEL,eAAO,MAAM,MAAM,GAAI,CAAC,EAAE,OAAO,MAAM,EAAE,IAAI,CAAC,qBAW1C,CAAC;AAEL,eAAO,MAAM,SAAS,GAAI,CAAC,EAAE,OAAO,MAAM,EAAE,SAAS,CAAC,EAAE,qBAUpD,CAAC;AAEL,eAAO,MAAM,MAAM,GAAI,CAAC,EACtB,OAAO,MAAM,EACb,SAAS,CAAC,EAAE,EACZ,kBAAkB,OAAO,qBAWvB,CAAC;AAaL,eAAO,MAAM,WAAW,GAAI,OAAO,MAAM,EAAE,WAAW,MAAM,EAAE,qBAU1D,CAAC;AAEL,eAAO,MAAM,GAAG,GAAI,CAAC,EAAE,OAAO,MAAM,EAAE,IAAI,MAAM,KAAG,OAAO,CAAC,CAAC,CAKxD,CAAC;AAEL,eAAO,MAAM,MAAM,GAAI,CAAC,EAAE,OAAO,MAAM,EAAE,QAAQ,MAAM,KAAG,OAAO,CAAC,CAAC,EAAE,CAwBjE,CAAC;AAEL,eAAO,MAAM,SAAS,GAAI,OAAO,MAAM,qBAqBnC,CAAC;AAEL,eAAO,MAAM,SAAS,GAAI,OAAO,MAAM,qBASnC,CAAC;AAEL,eAAO,MAAM,cAAc,GAAI,QAAQ,MAAM,qBAMzC,CAAC;AAEL;;;;;GAKG;AACH,eAAO,MAAM,MAAM,GAAI,QAAQ;IAC7B,MAAM,EAAE,MAAM,CAAC;IACf,SAAS,EAAE,MAAM,CAAC;IAClB,WAAW,EAAE;QACX,IAAI,EAAE,MAAM,CAAC;QACb,cAAc,EAAE;YACd,OAAO,CAAC,EAAE,MAAM,CAAC;SAClB,CAAC;KACH,EAAE,CAAC;CACL,SAgDA,CAAC"}
|
package/dist/store/indexDB.js
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
|
+
import { createLogger } from "../helper/logger.js";
|
|
1
2
|
import { pdStore } from "./mini-rx.store.js";
|
|
2
3
|
import { initIndexDBSucess } from "./spa-app-actions.js";
|
|
4
|
+
const dbLogger = createLogger("PdIndexDB");
|
|
3
5
|
const USER_COLLECTION = "dcInternalUser";
|
|
4
6
|
const { indexedDB } = window;
|
|
5
7
|
let db;
|
|
@@ -10,7 +12,7 @@ const add = (table, el, ignoreDuplicates) => new Promise((resolve, reject) => {
|
|
|
10
12
|
if (event.target.error.code === 0 && ignoreDuplicates) {
|
|
11
13
|
return resolve("duplicate");
|
|
12
14
|
}
|
|
13
|
-
|
|
15
|
+
dbLogger.warn("Unable to add data!", event, el);
|
|
14
16
|
return reject(event.target.error);
|
|
15
17
|
};
|
|
16
18
|
});
|
|
@@ -18,7 +20,7 @@ const update = (table, el) => new Promise((resolve, reject) => {
|
|
|
18
20
|
const request = db.transaction([table], "readwrite").objectStore(table).put(el);
|
|
19
21
|
request.onsuccess = () => resolve(request.result);
|
|
20
22
|
request.onerror = (event) => {
|
|
21
|
-
|
|
23
|
+
dbLogger.warn("Unable to put data!", event, el);
|
|
22
24
|
return reject(event.target.error);
|
|
23
25
|
};
|
|
24
26
|
});
|
|
@@ -99,17 +101,18 @@ const initDB = (config) => {
|
|
|
99
101
|
const { dbName, dbVersion, collections } = config;
|
|
100
102
|
const request = indexedDB.open(dbName, dbVersion);
|
|
101
103
|
request.onerror = (event) => {
|
|
102
|
-
|
|
104
|
+
dbLogger.error("Error during init:", event);
|
|
103
105
|
};
|
|
104
106
|
request.onsuccess = () => {
|
|
105
107
|
db = request.result;
|
|
106
|
-
|
|
108
|
+
dbLogger.debug(`init success: ${db}`);
|
|
107
109
|
pdStore().dispatch(initIndexDBSucess());
|
|
108
110
|
};
|
|
109
111
|
request.onupgradeneeded = (event) => {
|
|
110
|
-
|
|
112
|
+
dbLogger.info("Upgrade needed", event);
|
|
111
113
|
db = event.target.result;
|
|
112
114
|
switch (event.oldVersion) {
|
|
115
|
+
// first call from client, init db
|
|
113
116
|
case 0:
|
|
114
117
|
db.createObjectStore(USER_COLLECTION, {
|
|
115
118
|
keyPath: "id"
|
|
@@ -118,8 +121,10 @@ const initDB = (config) => {
|
|
|
118
121
|
db.createObjectStore(c.name, c.collectionConf);
|
|
119
122
|
});
|
|
120
123
|
break;
|
|
124
|
+
// depending on our needs, add specific versions here to migrate existing db
|
|
125
|
+
// case X: ....
|
|
121
126
|
default:
|
|
122
|
-
|
|
127
|
+
dbLogger.info("Updating database structure for existing version");
|
|
123
128
|
if (!db.objectStoreNames.contains(USER_COLLECTION)) {
|
|
124
129
|
db.createObjectStore(USER_COLLECTION, {
|
|
125
130
|
keyPath: "id"
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mini-rx.store.d.ts","sourceRoot":"","sources":["../../src/store/mini-rx.store.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,KAAK,EAIN,MAAM,eAAe,CAAC;AACvB,OAAO,EAAE,WAAW,EAAE,MAAM,+CAA+C,CAAC;
|
|
1
|
+
{"version":3,"file":"mini-rx.store.d.ts","sourceRoot":"","sources":["../../src/store/mini-rx.store.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,KAAK,EAIN,MAAM,eAAe,CAAC;AACvB,OAAO,EAAE,WAAW,EAAE,MAAM,+CAA+C,CAAC;AAyB5E,eAAO,MAAM,eAAe,GAAI,OAAO,WAAW,SA0BjD,CAAC;AAEF,eAAO,MAAM,OAAO,QAAO,KAAc,CAAC"}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { configureStore, LoggerExtension, ReduxDevtoolsExtension, ImmutableStateExtension } from "mini-rx-store";
|
|
2
2
|
import { spaAppReducer } from "./spa-app-reducer.js";
|
|
3
3
|
import { appRouteEffect, appToastEffect, registerNotificationTokenSuccessEffect } from "./spa-app-effects.js";
|
|
4
|
+
import { defaultLogger } from "../helper/logger.js";
|
|
4
5
|
let store;
|
|
5
6
|
const registerEffects = (effects) => {
|
|
6
7
|
if (store) {
|
|
@@ -9,11 +10,11 @@ const registerEffects = (effects) => {
|
|
|
9
10
|
store.effect(registerNotificationTokenSuccessEffect);
|
|
10
11
|
effects.forEach((effect) => store.effect(effect));
|
|
11
12
|
} else {
|
|
12
|
-
|
|
13
|
+
defaultLogger.error("Store is not initialized. Cannot register effects.");
|
|
13
14
|
}
|
|
14
15
|
};
|
|
15
16
|
const initializeStore = (param) => {
|
|
16
|
-
|
|
17
|
+
defaultLogger.debug("Initialize Store:", param);
|
|
17
18
|
if (!store) {
|
|
18
19
|
store = configureStore({
|
|
19
20
|
reducers: param.reducer ? {
|
|
@@ -1,11 +1,18 @@
|
|
|
1
1
|
import { TemplateResult } from 'lit';
|
|
2
|
-
import { LoadingState, LoadingSubTask } from '../model/spa-model.js';
|
|
2
|
+
import { AppUser, LoadingState, LoadingSubTask } from '../model/spa-model.js';
|
|
3
3
|
export declare const initIndexDBSucess: (() => {
|
|
4
4
|
type: "SPA_INIT_INDEX_DB_SUCCESS";
|
|
5
5
|
}) & {
|
|
6
6
|
type: "SPA_INIT_INDEX_DB_SUCCESS";
|
|
7
7
|
};
|
|
8
|
-
export declare const loginSucess: (() => {
|
|
8
|
+
export declare const loginSucess: ((payload: AppUser) => {
|
|
9
|
+
payload: AppUser;
|
|
10
|
+
} & {
|
|
11
|
+
type: "SPA_LOGIN_SUCCESS";
|
|
12
|
+
}) & {
|
|
13
|
+
type: "SPA_LOGIN_SUCCESS";
|
|
14
|
+
};
|
|
15
|
+
export declare const logoutSucess: (() => {
|
|
9
16
|
type: "SPA_LOGIN_SUCCESS";
|
|
10
17
|
}) & {
|
|
11
18
|
type: "SPA_LOGIN_SUCCESS";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"spa-app-actions.d.ts","sourceRoot":"","sources":["../../src/store/spa-app-actions.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,KAAK,CAAC;AAGrC,OAAO,EAAE,YAAY,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC;
|
|
1
|
+
{"version":3,"file":"spa-app-actions.d.ts","sourceRoot":"","sources":["../../src/store/spa-app-actions.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,KAAK,CAAC;AAGrC,OAAO,EAAE,OAAO,EAAE,YAAY,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC;AAE9E,eAAO,MAAM,iBAAiB;;;;CAAsC,CAAC;AACrE,eAAO,MAAM,WAAW;;;;;;CAAkD,CAAC;AAC3E,eAAO,MAAM,YAAY;;;;CAA8B,CAAC;AACxD,eAAO,MAAM,OAAO;;;;CAAyB,CAAC;AAE9C,eAAO,MAAM,WAAW;;;;;;CAA6C,CAAC;AAEtE,eAAO,MAAM,WAAW;SAGf,MAAM,GAAG,cAAc;aACnB,OAAO;eACL,OAAO;eACP,MAAM;;;aAHZ,MAAM,GAAG,cAAc;iBACnB,OAAO;mBACL,OAAO;mBACP,MAAM;;;;;;CAEpB,CAAC;AAEF,eAAO,MAAM,qBAAqB;;;;;;CAGjC,CAAC;AAEF,eAAO,MAAM,eAAe;;;;;;CAG3B,CAAC;AACF,eAAO,MAAM,aAAa;qBAGL,MAAM;kBACT,cAAc;;;yBADX,MAAM;sBACT,cAAc;;;;;;CAE/B,CAAC;AACF,eAAO,MAAM,kBAAkB;;;;;;CAG9B,CAAC;AAEF,eAAO,MAAM,0BAA0B;oBAGnB,MAAM;;;wBAAN,MAAM;;;;;;CAEzB,CAAC;AACF,eAAO,MAAM,iCAAiC;oBAG1B,MAAM;;;wBAAN,MAAM;;;;;;CAEzB,CAAC;AACF,eAAO,MAAM,8BAA8B;;;;;;CAG1C,CAAC"}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { action, payload } from "ts-action";
|
|
2
2
|
const initIndexDBSucess = action("SPA_INIT_INDEX_DB_SUCCESS");
|
|
3
|
-
const loginSucess = action("SPA_LOGIN_SUCCESS");
|
|
3
|
+
const loginSucess = action("SPA_LOGIN_SUCCESS", payload());
|
|
4
|
+
const logoutSucess = action("SPA_LOGIN_SUCCESS");
|
|
4
5
|
const nologin = action("SPA_NO_LOGIN");
|
|
5
6
|
const routeAction = action("SPA_APP_ROUTE", payload());
|
|
6
7
|
const toastAction = action(
|
|
@@ -40,6 +41,7 @@ export {
|
|
|
40
41
|
changeSubTask,
|
|
41
42
|
initIndexDBSucess,
|
|
42
43
|
loginSucess,
|
|
44
|
+
logoutSucess,
|
|
43
45
|
nologin,
|
|
44
46
|
removeLoadingState,
|
|
45
47
|
routeAction,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"spa-app-effects.d.ts","sourceRoot":"","sources":["../../src/store/spa-app-effects.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"spa-app-effects.d.ts","sourceRoot":"","sources":["../../src/store/spa-app-effects.ts"],"names":[],"mappings":"AAgBA,eAAO,MAAM,eAAe,GAAI,OAAO,WAAW,SAEjD,CAAC;AAIF,eAAO,MAAM,cAAc;;;;4DAoB1B,CAAC;AAEF,eAAO,MAAM,cAAc;;;;;;;;;4DAyB1B,CAAC;AAEF,eAAO,MAAM,sCAAsC;;;;;;4DAUlD,CAAC"}
|