@progressive-development/pd-spa-helper 0.1.86 → 0.1.87

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 (42) hide show
  1. package/dist/src/InitApplicationData.d.ts +1 -1
  2. package/dist/src/InitApplicationData.js +2 -2
  3. package/dist/src/InitApplicationData.js.map +1 -1
  4. package/dist/src/PdSpaHelper.d.ts +8 -4
  5. package/dist/src/PdSpaHelper.js +11 -40
  6. package/dist/src/PdSpaHelper.js.map +1 -1
  7. package/dist/src/index.d.ts +3 -3
  8. package/dist/src/index.js +3 -3
  9. package/dist/src/index.js.map +1 -1
  10. package/dist/src/service-call-controller2.d.ts +1 -1
  11. package/dist/src/service-call-controller2.js +1 -1
  12. package/dist/src/service-call-controller2.js.map +1 -1
  13. package/dist/src/service-provider/firebase/auth.d.ts +5 -0
  14. package/dist/src/service-provider/firebase/auth.js +48 -0
  15. package/dist/src/service-provider/firebase/auth.js.map +1 -0
  16. package/dist/src/service-provider/firebase/firestore-client.d.ts +9 -0
  17. package/dist/src/service-provider/firebase/firestore-client.js +19 -0
  18. package/dist/src/service-provider/firebase/firestore-client.js.map +1 -0
  19. package/dist/src/service-provider/firebase/functions-client.d.ts +34 -0
  20. package/dist/src/service-provider/firebase/functions-client.js +70 -0
  21. package/dist/src/service-provider/firebase/functions-client.js.map +1 -0
  22. package/dist/src/service-provider/mock/auth.d.ts +4 -0
  23. package/dist/src/service-provider/mock/auth.js +50 -0
  24. package/dist/src/service-provider/mock/auth.js.map +1 -0
  25. package/dist/src/service-provider/service-provider-impl.d.ts +6 -0
  26. package/dist/src/service-provider/service-provider-impl.js +56 -0
  27. package/dist/src/service-provider/service-provider-impl.js.map +1 -0
  28. package/dist/src/tmpown/pd-login.js +2 -2
  29. package/dist/src/tmpown/pd-login.js.map +1 -1
  30. package/dist/tsconfig.tsbuildinfo +1 -1
  31. package/package.json +1 -1
  32. package/src/InitApplicationData.ts +2 -2
  33. package/src/PdSpaHelper.ts +25 -45
  34. package/src/index.ts +6 -6
  35. package/src/service-call-controller2.ts +1 -1
  36. package/src/service-provider/firebase/auth.ts +52 -0
  37. package/src/{firebase → service-provider/firebase}/functions-client.ts +1 -1
  38. package/src/service-provider/mock/auth.ts +68 -0
  39. package/src/service-provider/service-provider-impl.ts +68 -0
  40. package/src/tmpown/pd-login.ts +3 -2
  41. package/src/firebase/auth.ts +0 -30
  42. /package/src/{firebase → service-provider/firebase}/firestore-client.ts +0 -0
@@ -1,3 +1,3 @@
1
1
  import { FirebaseApp } from "firebase/app";
2
- import { FunctionsConfig } from "./firebase/functions-client.js";
2
+ import { FunctionsConfig } from "./service-provider/firebase/functions-client.js";
3
3
  export declare const initApplicationServices: (firebaseApp: FirebaseApp, functionsConfig: FunctionsConfig) => void;
@@ -1,5 +1,5 @@
1
- import { initFirestore } from "./firebase/firestore-client.js";
2
- import { initFunctions } from "./firebase/functions-client.js";
1
+ import { initFirestore } from "./service-provider/firebase/firestore-client.js";
2
+ import { initFunctions } from "./service-provider/firebase/functions-client.js";
3
3
  export const initApplicationServices = (firebaseApp, functionsConfig) => {
4
4
  // do something with the app, init db, firestore and functions
5
5
  initFunctions(firebaseApp, functionsConfig);
@@ -1 +1 @@
1
- {"version":3,"file":"InitApplicationData.js","sourceRoot":"","sources":["../../src/InitApplicationData.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,aAAa,EAAE,MAAM,gCAAgC,CAAC;AAC/D,OAAO,EAAmB,aAAa,EAAE,MAAM,gCAAgC,CAAC;AAEhF,MAAM,CAAC,MAAM,uBAAuB,GAAG,CAAC,WAAwB,EAAE,eAAgC,EAAE,EAAE;IAClG,kEAAkE;IAClE,aAAa,CAAC,WAAW,EAAE,eAAe,CAAC,CAAC;IAC5C,aAAa,CAAC,WAAW,CAAC,CAAC;AAC/B,CAAC,CAAA","sourcesContent":["import { FirebaseApp } from \"firebase/app\";\nimport { initFirestore } from \"./firebase/firestore-client.js\";\nimport { FunctionsConfig, initFunctions } from \"./firebase/functions-client.js\";\n\nexport const initApplicationServices = (firebaseApp: FirebaseApp, functionsConfig: FunctionsConfig) => {\n // do something with the app, init db, firestore and functions \n initFunctions(firebaseApp, functionsConfig);\n initFirestore(firebaseApp);\n}\n"]}
1
+ {"version":3,"file":"InitApplicationData.js","sourceRoot":"","sources":["../../src/InitApplicationData.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,aAAa,EAAE,MAAM,iDAAiD,CAAC;AAChF,OAAO,EAAmB,aAAa,EAAE,MAAM,iDAAiD,CAAC;AAEjG,MAAM,CAAC,MAAM,uBAAuB,GAAG,CAAC,WAAwB,EAAE,eAAgC,EAAE,EAAE;IAClG,kEAAkE;IAClE,aAAa,CAAC,WAAW,EAAE,eAAe,CAAC,CAAC;IAC5C,aAAa,CAAC,WAAW,CAAC,CAAC;AAC/B,CAAC,CAAA","sourcesContent":["import { FirebaseApp } from \"firebase/app\";\nimport { initFirestore } from \"./service-provider/firebase/firestore-client.js\";\nimport { FunctionsConfig, initFunctions } from \"./service-provider/firebase/functions-client.js\";\n\nexport const initApplicationServices = (firebaseApp: FirebaseApp, functionsConfig: FunctionsConfig) => {\n // do something with the app, init db, firestore and functions \n initFunctions(firebaseApp, functionsConfig);\n initFirestore(firebaseApp);\n}\n"]}
@@ -1,10 +1,9 @@
1
1
  import { FirebaseOptions } from 'firebase/app';
2
- import { User } from 'firebase/auth';
3
2
  import { LitElement, CSSResultGroup, TemplateResult } from 'lit';
4
3
  import '@progressive-development/pd-page/pd-menu.js';
5
4
  import '@progressive-development/pd-page/pd-footer.js';
5
+ import { FunctionResult, FunctionsConfig } from './service-provider/firebase/functions-client.js';
6
6
  import { ServiceCallController } from './service-call-controller2.js';
7
- import { FunctionResult, FunctionsConfig } from './firebase/functions-client.js';
8
7
  import './router/AppMain.js';
9
8
  import './defaultpage/default-login.js';
10
9
  import './tmpown/pd-panel-viewer.js';
@@ -34,6 +33,9 @@ export interface NavigationPage {
34
33
  withFooter?: boolean;
35
34
  hideMenu?: boolean;
36
35
  }
36
+ export type ServiceProviderFirebase = "firebase";
37
+ export type ServiceProviderMock = "mock";
38
+ export type ServiceProviderConfiguration = ServiceProviderFirebase | ServiceProviderMock;
37
39
  export interface NavigationConfig {
38
40
  pages: Array<NavigationPage>;
39
41
  includeLogin: boolean;
@@ -54,6 +56,7 @@ export interface StoreConfig {
54
56
  effects: Array<any>;
55
57
  }
56
58
  export interface AppConfiguration {
59
+ serviceProvider?: ServiceProviderConfiguration;
57
60
  navigationConfigParam: NavigationConfig;
58
61
  storeConfigParam?: StoreConfig;
59
62
  firebaseConfig?: FirebaseOptions;
@@ -78,7 +81,7 @@ export declare abstract class PdSpaHelper extends PdSpaHelper_base {
78
81
  /**
79
82
  * Properties needed for login/profile data.
80
83
  */
81
- _user: User | undefined;
84
+ _user: unknown | undefined;
82
85
  _profile: any | undefined;
83
86
  /**
84
87
  * Properties needed for the router.
@@ -109,11 +112,12 @@ export declare abstract class PdSpaHelper extends PdSpaHelper_base {
109
112
  router(route: string, params: Object, query: Object): void;
110
113
  /**
111
114
  * Call to activate onAuthState change with profile request callbacks.
115
+ * Only implemented for firebase provider.
112
116
  */
113
117
  activateLoginHandler(): void;
114
118
  render(): TemplateResult<1>;
115
119
  private _getMainClass;
116
- _renderMenu(pageConfig: NavigationPage, hideTeaser: boolean): "" | TemplateResult<1>;
120
+ _renderMenu(pageConfig: NavigationPage, hideTeaser: boolean): TemplateResult<1> | "";
117
121
  _renderTeaser(): TemplateResult | string;
118
122
  _renderFooter(): TemplateResult<1>;
119
123
  /**
@@ -1,6 +1,5 @@
1
1
  import { __decorate } from "tslib";
2
2
  import { initializeApp } from 'firebase/app';
3
- import { getAuth, onAuthStateChanged } from 'firebase/auth';
4
3
  // TODO: Add SDKs for Firebase products that you want to use
5
4
  // https://firebase.google.com/docs/web/setup#available-libraries
6
5
  import { html, LitElement, css } from 'lit';
@@ -9,9 +8,7 @@ import { property } from 'lit/decorators.js';
9
8
  import '@progressive-development/pd-page/pd-menu.js';
10
9
  import '@progressive-development/pd-page/pd-footer.js';
11
10
  import { initApplicationServices } from './InitApplicationData.js';
12
- import { isAuthenticated, logout } from './firebase/auth.js';
13
11
  import { ServiceCallController } from './service-call-controller2.js';
14
- import { callFunction } from './firebase/functions-client.js';
15
12
  import { initializeStore } from './store/mini-rx.store.js';
16
13
  import './router/AppMain.js';
17
14
  import './defaultpage/default-login.js';
@@ -22,6 +19,7 @@ import './tmpown/pd-panel.js';
22
19
  import { PdToast } from './tmpown/pd-toast.js';
23
20
  // eslint-disable-next-line import/no-duplicates
24
21
  import './tmpown/pd-toast.js';
22
+ import { authStateChangedImpl, isAuthenticatedImpl, setServiceProvider } from './service-provider/service-provider-impl.js';
25
23
  // Footer Text
26
24
  const MADE_BY = {
27
25
  txt: "made by PD Progressive Development",
@@ -44,7 +42,7 @@ const transformRoutes = () => {
44
42
  unauthenticated: {
45
43
  name: 'login',
46
44
  },
47
- authenticate: () => isAuthenticated(),
45
+ authenticate: () => isAuthenticatedImpl(),
48
46
  } : undefined;
49
47
  let generatedRoutes = [];
50
48
  navigationConfig.pages.forEach(cfEntry => {
@@ -71,6 +69,8 @@ const transformRoutes = () => {
71
69
  * @param functionsConfig
72
70
  */
73
71
  export const startInit = (config) => {
72
+ // set service provider
73
+ setServiceProvider(config.serviceProvider);
74
74
  // init mini-rx store
75
75
  if (config.storeConfigParam) {
76
76
  initializeStore(config.storeConfigParam);
@@ -173,39 +173,15 @@ export class PdSpaHelper extends router(navigator(LitElement)) {
173
173
  }
174
174
  /**
175
175
  * Call to activate onAuthState change with profile request callbacks.
176
+ * Only implemented for firebase provider.
176
177
  */
177
178
  activateLoginHandler() {
178
179
  console.log("Activate Login Handler");
179
- // activate firebase auth handler
180
- const auth = getAuth();
181
- onAuthStateChanged(auth, user => {
182
- if (user) {
183
- this._user = user;
184
- if (postLoginFunc) {
185
- callFunction(postLoginFunc, postLoginFunc.param)
186
- .then((result) => {
187
- this._profile = result.resultData;
188
- // redirect if login in the meantime is available
189
- // => else stay on the login page after reload/url navigation
190
- if (this.route === "login" && (postLoginFunc === null || postLoginFunc === void 0 ? void 0 : postLoginFunc.redirect)) {
191
- this.navigate(postLoginFunc.redirect);
192
- }
193
- // new event, could/should replace redirect
194
- document.dispatchEvent(new CustomEvent("user-login-event"));
195
- }).catch(() => {
196
- if (postLoginFunc === null || postLoginFunc === void 0 ? void 0 : postLoginFunc.logoutOnFail) {
197
- logout();
198
- this._user = undefined;
199
- this._profile = undefined;
200
- }
201
- });
202
- }
203
- }
204
- else {
205
- this._user = undefined;
206
- this._profile = undefined;
207
- }
208
- });
180
+ const callback = (user) => {
181
+ console.log("My callback user:", user);
182
+ this._user = user;
183
+ };
184
+ authStateChangedImpl(callback);
209
185
  }
210
186
  render() {
211
187
  const pageConf = navigationConfig.pages.filter(p => p.name === this.route)[0];
@@ -463,12 +439,7 @@ css `
463
439
  .default-main {
464
440
  padding-top: calc(var(--pd-menu-height) + 10px);
465
441
  transition: padding-top 1s;
466
- }
467
-
468
- .default-main-home {
469
- padding-top: calc(var(--pd-menu-height) + var(--pd-spa-padding-top, 120px));
470
- transition: padding-top 1s;
471
- }
442
+ }
472
443
 
473
444
  .default-main-withteaser {
474
445
  padding-top: calc(var(--pd-menu-height) + var(--pd-teaser-height, 380px) + 10px);
@@ -1 +1 @@
1
- {"version":3,"file":"PdSpaHelper.js","sourceRoot":"","sources":["../../src/PdSpaHelper.ts"],"names":[],"mappings":";AAAA,OAAO,EAAgC,aAAa,EAAE,MAAM,cAAc,CAAC;AAC3E,OAAO,EAAE,OAAO,EAAE,kBAAkB,EAAQ,MAAM,eAAe,CAAC;AAClE,4DAA4D;AAC5D,iEAAiE;AAGjE,OAAO,EAAE,IAAI,EAAE,UAAU,EAAE,GAAG,EAAkC,MAAM,KAAK,CAAC;AAC5E,OAAO,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AACvD,OAAO,EAAE,QAAQ,EAAS,MAAM,mBAAmB,CAAC;AAEpD,OA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,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC;kDACN;AAItB;IADC,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC;oDACP","sourcesContent":["import { FirebaseApp, FirebaseOptions, initializeApp } from 'firebase/app';\nimport { getAuth, onAuthStateChanged, User } from 'firebase/auth';\n// TODO: Add SDKs for Firebase products that you want to use\n// https://firebase.google.com/docs/web/setup#available-libraries\n\n\nimport { html, LitElement, css, CSSResultGroup, TemplateResult } from 'lit';\nimport { router, navigator } from 'lit-element-router';\nimport { property, query } from 'lit/decorators.js';\n\nimport '@progressive-development/pd-page/pd-menu.js';\nimport '@progressive-development/pd-page/pd-footer.js';\n\nimport { initApplicationServices } from './InitApplicationData.js';\n\nimport { isAuthenticated, logout } from './firebase/auth.js';\nimport { ServiceCallController } from './service-call-controller2.js';\nimport { callFunction, FunctionDefinition, FunctionResult, FunctionsConfig } from './firebase/functions-client.js';\nimport { initializeStore } from './store/mini-rx.store.js';\n\nimport './router/AppMain.js';\nimport './defaultpage/default-login.js';\nimport './tmpown/pd-panel-viewer.js';\nimport './tmpown/pd-panel.js';\n\n// TODO: How to solve this import problem?\n// eslint-disable-next-line import/no-duplicates\nimport { PdToast } from './tmpown/pd-toast.js';\n// eslint-disable-next-line import/no-duplicates\nimport './tmpown/pd-toast.js';\n\n\n// Footer Text\nconst MADE_BY = {\n txt: \"made by PD Progressive Development\",\n email: \"info@progressive-development.com\"};\n\n// Visible time for time-limited toast\nconst TOAST_DURATION = 6000;\n\n/**\n * Data models.\n */\n\nexport interface MenuElement {\n key: string,\n name: string,\n sec?: string,\n route?: string,\n action?: Function,\n topItem?: boolean,\n ref?: any,\n icon?: string,\n}\n\nexport interface NavigationPage {\n name: string,\n mainClass?: string,\n pattern: Array<string>, \n auth: boolean,\n menu?: Array<MenuElement>,\n topMenu?: Array<MenuElement>,\n withTeaser?: boolean,\n withFooter?: boolean\n hideMenu?: boolean\n}\n\nexport interface NavigationConfig {\n pages: Array<NavigationPage>,\n includeLogin: boolean\n}\n\nexport interface LinkObj {\n name: string,\n key: string,\n link?: string,\n action?: Function\n}\n\nexport interface Footer {\n version: string,\n links: Array<LinkObj>\n}\n\nexport interface StoreConfig {\n appName: string,\n reducer: any,\n effects: Array<any>\n}\n\nexport interface AppConfiguration { \n navigationConfigParam: NavigationConfig;\n storeConfigParam?: StoreConfig;\n firebaseConfig?: FirebaseOptions;\n functionsConfig?: FunctionsConfig;\n}\n\n/**\n * Transformed routes, generated during startInit.\n */\nlet transformedRoutes:Array<any>;\nlet navigationConfig:NavigationConfig;\nlet postLoginFunc:FunctionDefinition | undefined;\n\n/**\n * Internal helper functions to generate route elemets for lit-router. \n */\nconst transformRoutes = () => {\n\n const transformAuthConfig = (withAuth:boolean) => \n withAuth ? \n {\n unauthenticated: {\n name: 'login',\n },\n authenticate: () => isAuthenticated(),\n } : undefined;\n\n let generatedRoutes:Array<any> = [];\n navigationConfig.pages.forEach(cfEntry => {\n const addAraay = cfEntry.pattern.map(routeMapPattern => (\n {\n name: cfEntry.name,\n pattern: routeMapPattern,\n authentication: transformAuthConfig(cfEntry.auth),\n }\n )); \n generatedRoutes = generatedRoutes.concat(addAraay);\n });\n \n // add not-found route\n generatedRoutes.push({\n name: 'not-found',\n pattern: '*',\n });\n\n return generatedRoutes;\n}\n\n\n/**\n * Init the firebase app and application services like\n * functions and firestore. Generate routes from navigationConfig.\n * \n * @param navigationConfig\n * @param firebaseConfig\n * @param functionsConfig\n */\nexport const startInit = (config: AppConfiguration) => {\n \n // init mini-rx store\n if (config.storeConfigParam) {\n initializeStore(config.storeConfigParam);\n }\n\n // init firebase app\n if (config.firebaseConfig) {\n const app:FirebaseApp = initializeApp(config.firebaseConfig);\n if (config.functionsConfig) {\n // init application services (functions, store) \n initApplicationServices(app, config.functionsConfig);\n postLoginFunc = config.functionsConfig.postLoginFunc;\n }\n }\n\n if (config.navigationConfigParam.includeLogin) {\n config.navigationConfigParam.pages.push({\n name: \"login\",\n menu: [\n {key: \"login\", name: \"Login\"}\n ],\n pattern: [\"login\"],\n auth: false\n });\n\n // init ready, trigger by even (if getAuth is called before, error is thrown) \n document.dispatchEvent(new CustomEvent(\"init-app-event\"));\n console.log(\"Init done, Event created\");\n }\n\n // generate routes from navigation config\n navigationConfig = config.navigationConfigParam;\n transformedRoutes = transformRoutes(); \n};\n\n/**\n * Abstract class for SPAs. Extend within the app main class.\n */\nexport abstract class PdSpaHelper extends router(navigator(LitElement)) {\n\n protected functionsController = new ServiceCallController(this);\n\n // not used at the moment\n @property({ type: String }) \n title = 'Hey there';\n\n /**\n * Properties needed for login/profile data.\n */\n @property({ type: Object, state: true }) \n _user: User | undefined;\n\n @property({ type: Object, state: true }) \n _profile: any | undefined;\n \n /**\n * Properties needed for the router.\n */\n @property({ type: String, reflect: true }) \n route = \"\";\n\n @property({ type: Object }) \n params = {};\n\n @property({ type: Object }) \n query = {};\n\n /**\n * Indicates if the teaser should closed (depends on scroll position).\n */\n @property({ type: Boolean })\n _teaserClosed = false; \n\n\n @property({ type: String, state: true })\n abstract _selectedLocale: string;\n\n abstract _availableLocales: string[];\n \n\n static styles = \n // Ref: Additional use classmap to add custom classes in concrete impl\n css`\n\n :host {\n display: flex;\n flex-flow: column;\n height: 100%;\n }\n\n header {\n flex-grow: 0;\n }\n\n main {\n flex-grow: 1;\n flex-basis: max-content;\n }\n\n footer {\n flex-grow: 0;\n }\n\n .default-header {\n width: 100%;\n position: fixed;\n top: 0;\n display: block;\n z-index: 99;\n }\n\n .default-teaser {\n --pd-panel-overflow: hidden;\n --pd-panel-height: var(--pd-teaser-height, 380px);\n --pd-panel-width: 100%; \n --pd-panel-border-radius: 0;\n --pd-panel-bg: var(--pd-default-col);\n --pd-panel-viewer-bg-col: var(--pd-default-col);\n }\n\n .default-menu { \n transition: background-color 1s;\n }\n\n .default-menu-withteaser { \n --pd-menu-bg-col: #AFC1D2;\n --pd-menu-font-col: #0A3A48;\n transition: background-color 1s;\n }\n\n /* needed for pd-spa-padding-top, only for pages with teaser, check if refactor possible... */\n .default-main-padding {\n padding-top: calc(var(--pd-menu-height) + var(--pd-spa-padding-top, 120px));\n transition: padding-top 1s;\n }\n\n .default-main {\n padding-top: calc(var(--pd-menu-height) + 10px);\n transition: padding-top 1s;\n }\n\n .default-main-home {\n padding-top: calc(var(--pd-menu-height) + var(--pd-spa-padding-top, 120px));\n transition: padding-top 1s;\n }\n\n .default-main-withteaser {\n padding-top: calc(var(--pd-menu-height) + var(--pd-teaser-height, 380px) + 10px);\n transition: padding-top 1s;\n }\n\n ` as CSSResultGroup; \n\n constructor() {\n\n super(); \n\n const doSomething = (scrollPos:number) => {\n if (scrollPos <= 50) {\n this._teaserClosed = false;\n } else {\n this._teaserClosed = true;\n }\n };\n\n let ticking = false;\n document.addEventListener('scroll', () => {\n const lastKnownScrollPosition = window.scrollY;\n if (!ticking) {\n window.requestAnimationFrame(() => {\n doSomething(lastKnownScrollPosition);\n ticking = false;\n });\n ticking = true;\n }\n });\n\n // add login handler after init => else error is thrown\n // document.addEventListener(\"init-app-event\", this.activateLoginHandler.bind(this));\n document.addEventListener(\"init-app-event\", () => {\n console.log(\"Init event catched\");\n });\n if (navigationConfig.includeLogin) {\n this.activateLoginHandler();\n }\n\n // For common toast messages (not for callfunction toasts => handelt by own controller)\n this.addEventListener(\"toast-event\", this._createTemporaryToast);\n this.addEventListener(\"route-event\", this._handleMenuRouteEvent); \n }\n\n /**\n * Non reactive private property for the index db class.\n */\n // private _indexDBClient?: YoIndexDBClient|null; \n\n /**\n * Needed for the router.\n * Return all configured routes.\n */\n static get routes() {\n return transformedRoutes; \n }\n\n /**\n * Needed for the router.\n * Set route params to internal members.\n */\n router(route:string, params:Object, query:Object) {\n this.route = route;\n this.params = params;\n this.query = query;\n } \n \n /**\n * Call to activate onAuthState change with profile request callbacks.\n */\n activateLoginHandler() {\n console.log(\"Activate Login Handler\");\n // activate firebase auth handler\n const auth = getAuth();\n onAuthStateChanged(auth, user => {\n if (user) {\n this._user = user;\n if (postLoginFunc) {\n callFunction(postLoginFunc, postLoginFunc.param)\n .then((result:FunctionResult) => {\n this._profile = result.resultData;\n // redirect if login in the meantime is available \n // => else stay on the login page after reload/url navigation\n if (this.route === \"login\" && postLoginFunc?.redirect) { \n this.navigate(postLoginFunc.redirect);\n }\n\n // new event, could/should replace redirect\n document.dispatchEvent(new CustomEvent(\"user-login-event\"));\n\n }).catch(() => {\n if (postLoginFunc?.logoutOnFail) {\n logout();\n this._user = undefined;\n this._profile = undefined;\n }\n });\n }\n } else {\n this._user = undefined;\n this._profile = undefined;\n }\n });\n }\n\n render() { \n const pageConf = navigationConfig.pages.filter(p => p.name === this.route)[0];\n const hideTeaser = this._teaserClosed || !pageConf?.withTeaser;\n return html`\n <header id=\"headerElementId\" class=\"default-header\">\n ${hideTeaser ? '' : this._renderTeaser()}\n ${pageConf?.hideMenu ? '' : this._renderMenu(pageConf, hideTeaser)}\n </header> \n\n <main class=\"${this._getMainClass(hideTeaser, pageConf)}\">\n <app-main active-route=${this.route}\n @init-menu-sections=\"${this._initMenuSections}\">\n ${this._renderRoutePages()}\n ${navigationConfig.includeLogin ? html`\n <default-login route=\"login\"></default-login>` : ''}\n </app-main>\n </main>\n\n ${this.functionsController.render({\n complete: (result: FunctionResult) => this._renderSuccessResultInfo(result),\n initial: () => '',\n pending: () => this._renderPendingInfo(),\n error: (e: any) => this._renderErrorInfo(e),\n })}\n\n ${pageConf?.withFooter ? html`\n <footer class=\"default-footer\">\n ${this._renderFooter()}\n </footer>` : ''}\n `;\n } \n\n // eslint-disable-next-line class-methods-use-this\n private _getMainClass(hideTeaser: boolean, pageConf: NavigationPage): string {\n if (hideTeaser) {\n // eslint-disable-next-line no-nested-ternary\n return pageConf.mainClass ? pageConf.mainClass : (pageConf.withTeaser ? \"default-main-padding\" : \"default-main\");\n }\n return \"default-main-withteaser\";\n }\n\n _renderMenu(pageConfig:NavigationPage, hideTeaser:boolean) {\n const menuForPage = pageConfig ? (pageConfig.menu || []) : [];\n const topMenuForPage = pageConfig ? (pageConfig.topMenu || []) : [];\n return menuForPage ? html`\n <pd-menu \n id=\"pdHelperMenuId\"\n @locale-change=\"${this._localeChange}\"\n class=\"${hideTeaser ? \"default-menu\" : \"default-menu-withteaser\"}\" \n .locales=${this._availableLocales}\n selectedLocale=\"${this._selectedLocale}\"\n .menuItems=${menuForPage}\n .topMenuItems=${topMenuForPage}\n activeRoute=\"${this.route}\"\n headerSize=\"${this._getHeaderSize(hideTeaser)}\"\n >\n ${hideTeaser ? this._getAppLogo() : ''}\n </pd-menu>\n ` : '';\n } \n\n // eslint-disable-next-line class-methods-use-this\n _renderTeaser(): TemplateResult | string {\n const teaserContent = this._getTeaserContent();\n if (!teaserContent || teaserContent.length <= 0) {\n return '';\n }\n return html`\n <pd-panel-viewer class=\"default-teaser\" id=\"teaserPanelViewerId\" deltaCalc=\"4\">\n ${teaserContent.map(content => html`\n <pd-panel>\n ${content}\n </pd-panel>\n `)}\n </pd-panel-viewer>\n `;\n }\n\n _renderFooter() {\n const footer = this._getFooter();\n return html`\n <pd-footer \n class=\"default-footer\"\n .footerLinks=\"${footer.links}\"\n version=\"${footer.version}\" \n copyright=\"PD Progressive Developent UG\" \n .madeBy=\"${MADE_BY}\" \n @footer-link=\"${this._handleFooterRouteEvent}\">\n </pd-footer>\n `;\n }\n\n /**\n * Called when (any) cloud function call was finished. \n */\n // eslint-disable-next-line class-methods-use-this, @typescript-eslint/no-unused-vars\n _renderSuccessResultInfo(result: FunctionResult) {\n return html`\n <pd-toast isSuccess duration=\"${TOAST_DURATION}\">\n ${this.functionsController.callDataPromise?.func.successTxt}\n </pd-toast>`;\n }\n\n /**\n * Called when (any) cloud function is currently running. \n */\n _renderPendingInfo() {\n return this.functionsController.callDataPromise?.func.fadeWindow ? html`\n <p>Überblende und lade ${this.functionsController.callDataPromise?.func.name}...</p>` \n : html`\n <pd-toast duration=\"-1\">\n ${this.functionsController.callDataPromise?.func.pendingTxt}\n </pd-toast>`; \n }\n\n /**\n * Called when (any) cloud function stopped with errors.\n */\n // eslint-disable-next-line class-methods-use-this\n _renderErrorInfo(error:any) {\n return html`\n <pd-toast isError duration=\"-1\">\n ${error}\n </pd-toast>`;\n }\n\n protected abstract _getTeaserContent(): Array<TemplateResult>;\n\n protected abstract _getFooter(): Footer;\n\n protected abstract _getAppLogo(): TemplateResult;\n\n protected abstract _renderRoutePages(): any; \n\n protected abstract _setLocale(locale:string): void;\n\n protected abstract _getHeaderSize(hideTeaser: boolean): number;\n\n _localeChange(e: CustomEvent): void {\n this._setLocale(e.detail)\n this._selectedLocale = e.detail; \n } \n \n // eslint-disable-next-line class-methods-use-this\n _handleMenuRouteEvent(e:any) {\n // test with el, to handel jumps also here, not used at the moment, same postion link problems...\n if (e.detail.el) {\n this._scrollToContent(e.detail.el);\n } else {\n PdSpaHelper._scrollToTop();\n this.navigate(e.detail.route);\n }\n }\n\n // eslint-disable-next-line class-methods-use-this\n _handleFooterRouteEvent(e: CustomEvent) { \n const {linkObj} = e.detail; \n if (linkObj.link) {\n PdSpaHelper._scrollToTop();\n this.navigate(linkObj.link); \n }\n if (linkObj.action ) { \n linkObj.action();\n }\n }\n \n // eslint-disable-next-line class-methods-use-this\n _initMenuSections(e:any) {\n // add link to configuration object\n const menRefConf = navigationConfig.pages.filter(p => p.name === e.detail.name)[0];\n if (menRefConf) { \n menRefConf.menu = menRefConf.menu?.map((menuElement:MenuElement, index:number) => ({\n ...menuElement,\n ref: e.detail.menuRefs[index]\n }));\n }\n }\n\n _createTemporaryToast(e: any) {\n \n // hide existing call function toast (old one still is visible for directly incoming errors)\n this.functionsController.clear();\n \n const tmpToast = new PdToast(); \n tmpToast.isError = e.detail.isError;\n tmpToast.isSuccess = e.detail.isSuccess;\n const slotContent = document.createTextNode(e.detail.txt);\n tmpToast.appendChild(slotContent) \n\n this.shadowRoot?.appendChild(tmpToast);\n tmpToast.duration = TOAST_DURATION;\n\n // set timeout to remove toast (one second later)\n setTimeout(() => {\n this.shadowRoot?.removeChild(tmpToast);\n }, TOAST_DURATION + 1000);\n }\n\n static _scrollToTop() {\n window.scrollTo({\n top: 0,\n left: 0,\n behavior: 'smooth',\n });\n }\n\n // Test, not used at the moment, jump/menu problem...\n // eslint-disable-next-line class-methods-use-this\n _scrollToContent(el:HTMLElement) {\n if (el) {\n const rect = el.getBoundingClientRect();\n console.log(\"Rect: \", rect);\n console.log(\"Offset Top/Height: \", el.offsetTop, el.offsetHeight);\n window.scrollBy({\n top: rect.top - (this._teaserClosed ? 80 : 450),\n left: 0,\n behavior: 'smooth',\n });\n }\n }\n\n}"]}
1
+ {"version":3,"file":"PdSpaHelper.js","sourceRoot":"","sources":["../../src/PdSpaHelper.ts"],"names":[],"mappings":";AAAA,OAAO,EAAgC,aAAa,EAAE,MAAM,cAAc,CAAC;AAC3E,4DAA4D;AAC5D,iEAAiE;AAGjE,OAAO,EAAE,IAAI,EAAE,UAAU,EAAE,GAAG,EAAkC,MAAM,KAAK,CAAC;AAC5E,OAAO,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AACvD,OAAO,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAE7C,OAAO,6CAA6C,CAAC;AACrD,OAAO,+CAA+C,CAAC;AAEvD,OAAO,EAAE,uBAAuB,EAAE,MAAM,0BAA0B,CAAC;AAKnE,OAAO,EAAE,qBAAqB,EAAE,MAAM,+BAA+B,CAAC;AACtE,OAAO,EAAE,eAAe,EAAE,MAAM,0BAA0B,CAAC;AAE3D,OAAO,qBAAqB,CAAC;AAC7B,OAAO,gCAAgC,CAAC;AACxC,OAAO,6BAA6B,CAAC;AACrC,OAAO,sBAAsB,CAAC;AAE9B,0CAA0C;AAC1C,gDAAgD;AAChD,OAAO,EAAE,OAAO,EAAE,MAAM,sBAAsB,CAAC;AAC/C,gDAAgD;AAChD,OAAO,sBAAsB,CAAC;AAC9B,OAAO,EAAE,oBAAoB,EAAE,mBAAmB,EAAE,kBAAkB,EA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,EAAE,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC;oDACP","sourcesContent":["import { FirebaseApp, FirebaseOptions, initializeApp } from 'firebase/app';\n// TODO: Add SDKs for Firebase products that you want to use\n// https://firebase.google.com/docs/web/setup#available-libraries\n\n\nimport { html, LitElement, css, CSSResultGroup, TemplateResult } from 'lit';\nimport { router, navigator } from 'lit-element-router';\nimport { property } from 'lit/decorators.js';\n\nimport '@progressive-development/pd-page/pd-menu.js';\nimport '@progressive-development/pd-page/pd-footer.js';\n\nimport { initApplicationServices } from './InitApplicationData.js';\n\n// Refactor: move function definitions to general place (no firebase specific imports here)\nimport { FunctionDefinition, FunctionResult, FunctionsConfig } from './service-provider/firebase/functions-client.js';\n\nimport { ServiceCallController } from './service-call-controller2.js';\nimport { initializeStore } from './store/mini-rx.store.js';\n\nimport './router/AppMain.js';\nimport './defaultpage/default-login.js';\nimport './tmpown/pd-panel-viewer.js';\nimport './tmpown/pd-panel.js';\n\n// TODO: How to solve this import problem?\n// eslint-disable-next-line import/no-duplicates\nimport { PdToast } from './tmpown/pd-toast.js';\n// eslint-disable-next-line import/no-duplicates\nimport './tmpown/pd-toast.js';\nimport { authStateChangedImpl, isAuthenticatedImpl, setServiceProvider } from './service-provider/service-provider-impl.js';\n\n\n// Footer Text\nconst MADE_BY = {\n txt: \"made by PD Progressive Development\",\n email: \"info@progressive-development.com\"};\n\n// Visible time for time-limited toast\nconst TOAST_DURATION = 6000;\n\n/**\n * Data models.\n */\n\nexport interface MenuElement {\n key: string,\n name: string,\n sec?: string,\n route?: string,\n action?: Function,\n topItem?: boolean,\n ref?: any,\n icon?: string,\n}\n\nexport interface NavigationPage {\n name: string,\n mainClass?: string,\n pattern: Array<string>, \n auth: boolean,\n menu?: Array<MenuElement>,\n topMenu?: Array<MenuElement>,\n withTeaser?: boolean,\n withFooter?: boolean\n hideMenu?: boolean\n}\n\nexport type ServiceProviderFirebase = \"firebase\";\nexport type ServiceProviderMock = \"mock\";\nexport type ServiceProviderConfiguration = ServiceProviderFirebase | ServiceProviderMock;\n\nexport interface NavigationConfig {\n pages: Array<NavigationPage>,\n includeLogin: boolean\n}\n\nexport interface LinkObj {\n name: string,\n key: string,\n link?: string,\n action?: Function\n}\n\nexport interface Footer {\n version: string,\n links: Array<LinkObj>\n}\n\nexport interface StoreConfig {\n appName: string,\n reducer: any,\n effects: Array<any>\n}\n\nexport interface AppConfiguration { \n serviceProvider?: ServiceProviderConfiguration,\n navigationConfigParam: NavigationConfig;\n storeConfigParam?: StoreConfig;\n firebaseConfig?: FirebaseOptions;\n functionsConfig?: FunctionsConfig;\n}\n\n/**\n * Transformed routes, generated during startInit.\n */\nlet transformedRoutes:Array<any>;\nlet navigationConfig:NavigationConfig;\nlet postLoginFunc:FunctionDefinition | undefined;\n\n/**\n * Internal helper functions to generate route elemets for lit-router. \n */\nconst transformRoutes = () => {\n\n const transformAuthConfig = (withAuth:boolean) => \n withAuth ? \n {\n unauthenticated: {\n name: 'login',\n },\n authenticate: () => isAuthenticatedImpl(),\n } : undefined;\n\n let generatedRoutes:Array<any> = [];\n navigationConfig.pages.forEach(cfEntry => {\n const addAraay = cfEntry.pattern.map(routeMapPattern => (\n {\n name: cfEntry.name,\n pattern: routeMapPattern,\n authentication: transformAuthConfig(cfEntry.auth),\n }\n )); \n generatedRoutes = generatedRoutes.concat(addAraay);\n });\n \n // add not-found route\n generatedRoutes.push({\n name: 'not-found',\n pattern: '*',\n });\n\n return generatedRoutes;\n}\n\n\n/**\n * Init the firebase app and application services like\n * functions and firestore. Generate routes from navigationConfig.\n * \n * @param navigationConfig\n * @param firebaseConfig\n * @param functionsConfig\n */\nexport const startInit = (config: AppConfiguration) => {\n\n // set service provider\n setServiceProvider(config.serviceProvider);\n \n // init mini-rx store\n if (config.storeConfigParam) {\n initializeStore(config.storeConfigParam);\n }\n\n // init firebase app\n if (config.firebaseConfig) {\n const app:FirebaseApp = initializeApp(config.firebaseConfig);\n if (config.functionsConfig) {\n // init application services (functions, store) \n initApplicationServices(app, config.functionsConfig);\n postLoginFunc = config.functionsConfig.postLoginFunc;\n }\n }\n\n if (config.navigationConfigParam.includeLogin) {\n config.navigationConfigParam.pages.push({\n name: \"login\",\n menu: [\n {key: \"login\", name: \"Login\"}\n ],\n pattern: [\"login\"],\n auth: false\n });\n\n // init ready, trigger by even (if getAuth is called before, error is thrown) \n document.dispatchEvent(new CustomEvent(\"init-app-event\"));\n console.log(\"Init done, Event created\");\n }\n\n // generate routes from navigation config\n navigationConfig = config.navigationConfigParam;\n transformedRoutes = transformRoutes(); \n};\n\n/**\n * Abstract class for SPAs. Extend within the app main class.\n */\nexport abstract class PdSpaHelper extends router(navigator(LitElement)) {\n\n protected functionsController = new ServiceCallController(this);\n\n // not used at the moment\n @property({ type: String }) \n title = 'Hey there';\n\n /**\n * Properties needed for login/profile data.\n */\n @property({ type: Object, state: true }) \n _user: unknown | undefined;\n\n @property({ type: Object, state: true }) \n _profile: any | undefined;\n \n /**\n * Properties needed for the router.\n */\n @property({ type: String, reflect: true }) \n route = \"\";\n\n @property({ type: Object }) \n params = {};\n\n @property({ type: Object }) \n query = {};\n\n /**\n * Indicates if the teaser should closed (depends on scroll position).\n */\n @property({ type: Boolean })\n _teaserClosed = false; \n\n\n @property({ type: String, state: true })\n abstract _selectedLocale: string;\n\n abstract _availableLocales: string[];\n \n\n static styles = \n // Ref: Additional use classmap to add custom classes in concrete impl\n css`\n\n :host {\n display: flex;\n flex-flow: column;\n height: 100%;\n }\n\n header {\n flex-grow: 0;\n }\n\n main {\n flex-grow: 1;\n flex-basis: max-content;\n }\n\n footer {\n flex-grow: 0;\n }\n\n .default-header {\n width: 100%;\n position: fixed;\n top: 0;\n display: block;\n z-index: 99;\n }\n\n .default-teaser {\n --pd-panel-overflow: hidden;\n --pd-panel-height: var(--pd-teaser-height, 380px);\n --pd-panel-width: 100%; \n --pd-panel-border-radius: 0;\n --pd-panel-bg: var(--pd-default-col);\n --pd-panel-viewer-bg-col: var(--pd-default-col);\n }\n\n .default-menu { \n transition: background-color 1s;\n }\n\n .default-menu-withteaser { \n --pd-menu-bg-col: #AFC1D2;\n --pd-menu-font-col: #0A3A48;\n transition: background-color 1s;\n }\n\n /* needed for pd-spa-padding-top, only for pages with teaser, check if refactor possible... */\n .default-main-padding {\n padding-top: calc(var(--pd-menu-height) + var(--pd-spa-padding-top, 120px));\n transition: padding-top 1s;\n }\n\n .default-main {\n padding-top: calc(var(--pd-menu-height) + 10px);\n transition: padding-top 1s;\n } \n\n .default-main-withteaser {\n padding-top: calc(var(--pd-menu-height) + var(--pd-teaser-height, 380px) + 10px);\n transition: padding-top 1s;\n }\n\n ` as CSSResultGroup; \n\n constructor() {\n\n super(); \n\n const doSomething = (scrollPos:number) => {\n if (scrollPos <= 50) {\n this._teaserClosed = false;\n } else {\n this._teaserClosed = true;\n }\n };\n\n let ticking = false;\n document.addEventListener('scroll', () => {\n const lastKnownScrollPosition = window.scrollY;\n if (!ticking) {\n window.requestAnimationFrame(() => {\n doSomething(lastKnownScrollPosition);\n ticking = false;\n });\n ticking = true;\n }\n });\n\n // add login handler after init => else error is thrown\n // document.addEventListener(\"init-app-event\", this.activateLoginHandler.bind(this));\n document.addEventListener(\"init-app-event\", () => {\n console.log(\"Init event catched\");\n });\n if (navigationConfig.includeLogin) {\n this.activateLoginHandler();\n }\n\n // For common toast messages (not for callfunction toasts => handelt by own controller)\n this.addEventListener(\"toast-event\", this._createTemporaryToast);\n this.addEventListener(\"route-event\", this._handleMenuRouteEvent); \n }\n\n /**\n * Non reactive private property for the index db class.\n */\n // private _indexDBClient?: YoIndexDBClient|null; \n\n /**\n * Needed for the router.\n * Return all configured routes.\n */\n static get routes() {\n return transformedRoutes; \n }\n\n /**\n * Needed for the router.\n * Set route params to internal members.\n */\n router(route:string, params:Object, query:Object) {\n this.route = route;\n this.params = params;\n this.query = query;\n } \n\n\n /**\n * Call to activate onAuthState change with profile request callbacks.\n * Only implemented for firebase provider.\n */\n activateLoginHandler() {\n console.log(\"Activate Login Handler\"); \n const callback = (user: unknown) => {\n console.log(\"My callback user:\", user);\n this._user = user;\n };\n authStateChangedImpl(callback);\n }\n\n render() { \n const pageConf = navigationConfig.pages.filter(p => p.name === this.route)[0];\n const hideTeaser = this._teaserClosed || !pageConf?.withTeaser;\n return html`\n <header id=\"headerElementId\" class=\"default-header\">\n ${hideTeaser ? '' : this._renderTeaser()}\n ${pageConf?.hideMenu ? '' : this._renderMenu(pageConf, hideTeaser)}\n </header> \n\n <main class=\"${this._getMainClass(hideTeaser, pageConf)}\">\n <app-main active-route=${this.route}\n @init-menu-sections=\"${this._initMenuSections}\">\n ${this._renderRoutePages()}\n ${navigationConfig.includeLogin ? html`\n <default-login route=\"login\"></default-login>` : ''}\n </app-main>\n </main>\n\n ${this.functionsController.render({\n complete: (result: FunctionResult) => this._renderSuccessResultInfo(result),\n initial: () => '',\n pending: () => this._renderPendingInfo(),\n error: (e: any) => this._renderErrorInfo(e),\n })}\n\n ${pageConf?.withFooter ? html`\n <footer class=\"default-footer\">\n ${this._renderFooter()}\n </footer>` : ''}\n `;\n } \n\n // eslint-disable-next-line class-methods-use-this\n private _getMainClass(hideTeaser: boolean, pageConf: NavigationPage): string {\n if (hideTeaser) {\n // eslint-disable-next-line no-nested-ternary\n return pageConf.mainClass ? pageConf.mainClass : (pageConf.withTeaser ? \"default-main-padding\" : \"default-main\");\n }\n return \"default-main-withteaser\";\n }\n\n _renderMenu(pageConfig:NavigationPage, hideTeaser:boolean) {\n const menuForPage = pageConfig ? (pageConfig.menu || []) : [];\n const topMenuForPage = pageConfig ? (pageConfig.topMenu || []) : [];\n return menuForPage ? html`\n <pd-menu \n id=\"pdHelperMenuId\"\n @locale-change=\"${this._localeChange}\"\n class=\"${hideTeaser ? \"default-menu\" : \"default-menu-withteaser\"}\" \n .locales=${this._availableLocales}\n selectedLocale=\"${this._selectedLocale}\"\n .menuItems=${menuForPage}\n .topMenuItems=${topMenuForPage}\n activeRoute=\"${this.route}\"\n headerSize=\"${this._getHeaderSize(hideTeaser)}\"\n >\n ${hideTeaser ? this._getAppLogo() : ''}\n </pd-menu>\n ` : '';\n } \n\n // eslint-disable-next-line class-methods-use-this\n _renderTeaser(): TemplateResult | string {\n const teaserContent = this._getTeaserContent();\n if (!teaserContent || teaserContent.length <= 0) {\n return '';\n }\n return html`\n <pd-panel-viewer class=\"default-teaser\" id=\"teaserPanelViewerId\" deltaCalc=\"4\">\n ${teaserContent.map(content => html`\n <pd-panel>\n ${content}\n </pd-panel>\n `)}\n </pd-panel-viewer>\n `;\n }\n\n _renderFooter() {\n const footer = this._getFooter();\n return html`\n <pd-footer \n class=\"default-footer\"\n .footerLinks=\"${footer.links}\"\n version=\"${footer.version}\" \n copyright=\"PD Progressive Developent UG\" \n .madeBy=\"${MADE_BY}\" \n @footer-link=\"${this._handleFooterRouteEvent}\">\n </pd-footer>\n `;\n }\n\n /**\n * Called when (any) cloud function call was finished. \n */\n // eslint-disable-next-line class-methods-use-this, @typescript-eslint/no-unused-vars\n _renderSuccessResultInfo(result: FunctionResult) {\n return html`\n <pd-toast isSuccess duration=\"${TOAST_DURATION}\">\n ${this.functionsController.callDataPromise?.func.successTxt}\n </pd-toast>`;\n }\n\n /**\n * Called when (any) cloud function is currently running. \n */\n _renderPendingInfo() {\n return this.functionsController.callDataPromise?.func.fadeWindow ? html`\n <p>Überblende und lade ${this.functionsController.callDataPromise?.func.name}...</p>` \n : html`\n <pd-toast duration=\"-1\">\n ${this.functionsController.callDataPromise?.func.pendingTxt}\n </pd-toast>`; \n }\n\n /**\n * Called when (any) cloud function stopped with errors.\n */\n // eslint-disable-next-line class-methods-use-this\n _renderErrorInfo(error:any) {\n return html`\n <pd-toast isError duration=\"-1\">\n ${error}\n </pd-toast>`;\n }\n\n protected abstract _getTeaserContent(): Array<TemplateResult>;\n\n protected abstract _getFooter(): Footer;\n\n protected abstract _getAppLogo(): TemplateResult;\n\n protected abstract _renderRoutePages(): any; \n\n protected abstract _setLocale(locale:string): void;\n\n protected abstract _getHeaderSize(hideTeaser: boolean): number;\n\n _localeChange(e: CustomEvent): void {\n this._setLocale(e.detail)\n this._selectedLocale = e.detail; \n } \n \n // eslint-disable-next-line class-methods-use-this\n _handleMenuRouteEvent(e:any) {\n // test with el, to handel jumps also here, not used at the moment, same postion link problems...\n if (e.detail.el) {\n this._scrollToContent(e.detail.el);\n } else {\n PdSpaHelper._scrollToTop();\n this.navigate(e.detail.route);\n }\n }\n\n // eslint-disable-next-line class-methods-use-this\n _handleFooterRouteEvent(e: CustomEvent) { \n const {linkObj} = e.detail; \n if (linkObj.link) {\n PdSpaHelper._scrollToTop();\n this.navigate(linkObj.link); \n }\n if (linkObj.action ) { \n linkObj.action();\n }\n }\n \n // eslint-disable-next-line class-methods-use-this\n _initMenuSections(e:any) {\n // add link to configuration object\n const menRefConf = navigationConfig.pages.filter(p => p.name === e.detail.name)[0];\n if (menRefConf) { \n menRefConf.menu = menRefConf.menu?.map((menuElement:MenuElement, index:number) => ({\n ...menuElement,\n ref: e.detail.menuRefs[index]\n }));\n }\n }\n\n _createTemporaryToast(e: any) {\n \n // hide existing call function toast (old one still is visible for directly incoming errors)\n this.functionsController.clear();\n \n const tmpToast = new PdToast(); \n tmpToast.isError = e.detail.isError;\n tmpToast.isSuccess = e.detail.isSuccess;\n const slotContent = document.createTextNode(e.detail.txt);\n tmpToast.appendChild(slotContent) \n\n this.shadowRoot?.appendChild(tmpToast);\n tmpToast.duration = TOAST_DURATION;\n\n // set timeout to remove toast (one second later)\n setTimeout(() => {\n this.shadowRoot?.removeChild(tmpToast);\n }, TOAST_DURATION + 1000);\n }\n\n static _scrollToTop() {\n window.scrollTo({\n top: 0,\n left: 0,\n behavior: 'smooth',\n });\n }\n\n // Test, not used at the moment, jump/menu problem...\n // eslint-disable-next-line class-methods-use-this\n _scrollToContent(el:HTMLElement) {\n if (el) {\n const rect = el.getBoundingClientRect();\n console.log(\"Rect: \", rect);\n console.log(\"Offset Top/Height: \", el.offsetTop, el.offsetHeight);\n window.scrollBy({\n top: rect.top - (this._teaserClosed ? 80 : 450),\n left: 0,\n behavior: 'smooth',\n });\n }\n }\n\n}"]}
@@ -8,9 +8,9 @@ export { DefaultWizard } from './defaultpage/default-wizard.js';
8
8
  export { DefaultWizardStep } from './defaultpage/default-wizard-step.js';
9
9
  export { DefaultStepAddress } from './defaultpage/default-step-address.js';
10
10
  export { DefaultStepSummary, OrderStep } from './defaultpage/default-step-summary.js';
11
- export { FunctionDefinition, FunctionResult, FunctionParam, FunctionsConfig, callFunction } from './firebase/functions-client.js';
12
- export { getDB, } from './firebase/firestore-client.js';
13
- export { login, logout, isAuthenticated } from './firebase/auth.js';
11
+ export { FunctionDefinition, FunctionResult, FunctionParam, FunctionsConfig, callFunction } from './service-provider/firebase/functions-client.js';
12
+ export { getDB, } from './service-provider/firebase/firestore-client.js';
13
+ export { loginImpl, logoutImpl, isAuthenticatedImpl } from './service-provider/service-provider-impl.js';
14
14
  export { pdStore } from './store/mini-rx.store.js';
15
15
  export { templates as beTemplaes } from './generated/locale-wrapper/be-wrapper.js';
16
16
  export { templates as deTemplaes } from './generated/locale-wrapper/de-wrapper.js';
package/dist/src/index.js CHANGED
@@ -8,9 +8,9 @@ export { DefaultWizard } from './defaultpage/default-wizard.js';
8
8
  export { DefaultWizardStep } from './defaultpage/default-wizard-step.js';
9
9
  export { DefaultStepAddress } from './defaultpage/default-step-address.js';
10
10
  export { DefaultStepSummary } from './defaultpage/default-step-summary.js';
11
- export { callFunction } from './firebase/functions-client.js';
12
- export { getDB, } from './firebase/firestore-client.js';
13
- export { login, logout, isAuthenticated } from './firebase/auth.js';
11
+ export { callFunction } from './service-provider/firebase/functions-client.js';
12
+ export { getDB, } from './service-provider/firebase/firestore-client.js';
13
+ export { loginImpl, logoutImpl, isAuthenticatedImpl } from './service-provider/service-provider-impl.js';
14
14
  export { pdStore } from './store/mini-rx.store.js';
15
15
  export { templates as beTemplaes } from './generated/locale-wrapper/be-wrapper.js';
16
16
  export { templates as deTemplaes } from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WAAW,CAAC,aAAa,EAAC;QAClD,MAAM,EAAE;YACN,GAAG;YACH,SAAS;YACT,OAAO;SACR;QACD,OAAO,EAAE,IAAI;QACb,QAAQ,EAAE,IAAI;KACf,CAAC,CAAC,CAAC;AACN,CAAC,CAAA","sourcesContent":["export { \n PdSpaHelper, \n AppConfiguration,\n startInit, \n NavigationConfig,\n StoreConfig,\n NavigationPage,\n MenuElement,\n LinkObj,\n Footer\n} from './PdSpaHelper.js';\n\nexport {isBlank, isEmpty} from './helper/helper-utils.js';\n\nexport {DefaultViewPage} from './defaultpage/default-view-page.js';\n\nexport {DefaultConfirmPopup, PopupType, ABORT_EVENT_NAME, STORE_EVENT_NAME} from './defaultpage/default-confirm-popup.js';\n\nexport {DefaultDialogPopup} from './defaultpage/default-dialog-popup.js';\n\nexport {DefaultPopup} from './defaultpage/default-popup.js';\n\nexport {DefaultWizard} from './defaultpage/default-wizard.js';\n\nexport {DefaultWizardStep} from './defaultpage/default-wizard-step.js';\n\nexport {DefaultStepAddress} from './defaultpage/default-step-address.js';\n\nexport {DefaultStepSummary, OrderStep} from './defaultpage/default-step-summary.js';\n\nexport {\n FunctionDefinition,\n FunctionResult,\n FunctionParam,\n FunctionsConfig,\n callFunction\n} from './firebase/functions-client.js'\n\nexport {\n getDB,\n} from './firebase/firestore-client.js'\n\nexport {\n login,\n logout,\n isAuthenticated\n} from './firebase/auth.js'\n\nexport { pdStore } from './store/mini-rx.store.js';\n\nexport { templates as beTemplaes} from './generated/locale-wrapper/be-wrapper.js'\nexport { templates as deTemplaes} from './generated/locale-wrapper/de-wrapper.js'\nexport { templates as enTemplaes} from './generated/locale-wrapper/en-wrapper.js'\n\nexport const dispatchToastEvent = (element:any, txt:string, isSuccess:boolean, isError:boolean) => {\n element.dispatchEvent(new CustomEvent(\"toast-event\",{\n detail: {\n txt,\n isSuccess,\n isError\n },\n bubbles: true,\n composed: true\n }));\n}\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts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AO,EAAE,IAAI;QACb,QAAQ,EAAE,IAAI;KACf,CAAC,CAAC,CAAC;AACN,CAAC,CAAA","sourcesContent":["export { \n PdSpaHelper, \n AppConfiguration,\n startInit, \n NavigationConfig,\n StoreConfig,\n NavigationPage,\n MenuElement,\n LinkObj,\n Footer\n} from './PdSpaHelper.js';\n\nexport {isBlank, isEmpty} from './helper/helper-utils.js';\n\nexport {DefaultViewPage} from './defaultpage/default-view-page.js';\n\nexport {DefaultConfirmPopup, PopupType, ABORT_EVENT_NAME, STORE_EVENT_NAME} from './defaultpage/default-confirm-popup.js';\n\nexport {DefaultDialogPopup} from './defaultpage/default-dialog-popup.js';\n\nexport {DefaultPopup} from './defaultpage/default-popup.js';\n\nexport {DefaultWizard} from './defaultpage/default-wizard.js';\n\nexport {DefaultWizardStep} from './defaultpage/default-wizard-step.js';\n\nexport {DefaultStepAddress} from './defaultpage/default-step-address.js';\n\nexport {DefaultStepSummary, OrderStep} from './defaultpage/default-step-summary.js';\n\nexport {\n FunctionDefinition,\n FunctionResult,\n FunctionParam,\n FunctionsConfig,\n callFunction\n} from './service-provider/firebase/functions-client.js'\n\nexport {\n getDB,\n} from './service-provider/firebase/firestore-client.js'\n\nexport {\n loginImpl,\n logoutImpl,\n isAuthenticatedImpl\n} from './service-provider/service-provider-impl.js'\n\nexport { pdStore } from './store/mini-rx.store.js';\n\nexport { templates as beTemplaes} from './generated/locale-wrapper/be-wrapper.js'\nexport { templates as deTemplaes} from './generated/locale-wrapper/de-wrapper.js'\nexport { templates as enTemplaes} from './generated/locale-wrapper/en-wrapper.js'\n\nexport const dispatchToastEvent = (element:any, txt:string, isSuccess:boolean, isError:boolean) => {\n element.dispatchEvent(new CustomEvent(\"toast-event\",{\n detail: {\n txt,\n isSuccess,\n isError\n },\n bubbles: true,\n composed: true\n }));\n}\n"]}
@@ -1,5 +1,5 @@
1
1
  import { ReactiveControllerHost } from 'lit';
2
- import { FunctionDefinition, FunctionResult } from './firebase/functions-client.js';
2
+ import { FunctionDefinition, FunctionResult } from './service-provider/firebase/functions-client.js';
3
3
  export interface ServiceControllerInput {
4
4
  promise: Promise<FunctionResult>;
5
5
  func: FunctionDefinition;
@@ -1,5 +1,5 @@
1
1
  import { initialState, Task } from '@lit-labs/task';
2
- import { initController } from './firebase/functions-client.js';
2
+ import { initController } from './service-provider/firebase/functions-client.js';
3
3
  export class ServiceCallController {
4
4
  constructor(host) {
5
5
  this.host = host;
@@ -1 +1 @@
1
- {"version":3,"file":"service-call-controller2.js","sourceRoot":"","sources":["../../src/service-call-controller2.ts"],"names":[],"mappings":"AACA,OAAO,EAAC,YAAY,EAAE,IAAI,EAAC,MAAM,gBAAgB,CAAC;AAElD,OAAO,EAAsC,cAAc,EAAE,MAAM,gCAAgC,CAAC;AAOpG,MAAM,OAAO,qBAAqB;IAQhC,YAAY,IAA4B;QACtC,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;QACjB,IAAI,CAAC,IAAI,GAAG,IAAI,IAAI,CAA2C,IAAI,EAEjE,KAAK,EAAE,CAAC,eAAe,CAA2B,EAAE,EAAE;YACpD,IAAI,CAAC,eAAe,EAAE;gBACpB,OAAO,YAAY,CAAC;aACrB;YACD,IAAI;gBACF,MAAM,MAAM,GAAG,MAAM,eAAe,CAAC,OAAO,CAAC;gBAC7C,OAAO,MAAwB,CAAC;aACjC;YAAC,OAAO,CAAC,EAAE;gBACV,OAAO,CAAC,KAAK,CAAC,SAAS,EAAE,CAAC,CAAC,CAAC;gBAC5B,MAAM,IAAI,KAAK,CAAC,yBAAyB,eAAe,CAAC,IAAI,CAAC,IAAI,GAAG,CAAC,CAAC;aACxE;QAEH,CAAC,EAAE,GAAG,EAAE,CAAC,CAAC,IAAI,CAAC,eAAe,CAAC,CAEhC,CAAC;QACF,cAAc,CAAC,IAAI,CAAC,CAAC;IACvB,CAAC;IAED;;;;;;;MAOE;IAEF,IAAI,eAAe,CAAC,KAA6B;QAC/C,IAAI,CAAC,gBAAgB,GAAG,KAAK,CAAC;QAC9B,IAAI,CAAC,IAAI,CAAC,aAAa,EAAE,CAAC;IAC5B,CAAC;IAED,IAAI,eAAe,KAA6B,OAAO,IAAI,CAAC,gBAAgB,CAAC,CAAC,CAAC;IAE/E,KAAK;QACH,IAAI,CAAC,IAAI,CAAC,MAAM,GAAG,CAAC,CAAC;QACrB,IAAI,CAAC,IAAI,CAAC,aAAa,EAAE,CAAC;IAC5B,CAAC;IAED,oFAAoF;IACpF,MAAM,CAAC,eAAoB;QACzB,OAAO,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,eAAe,CAAC,CAAC;IAC3C,CAAC;CAEF","sourcesContent":["import {ReactiveControllerHost} from 'lit';\nimport {initialState, Task} from '@lit-labs/task';\n\nimport { FunctionDefinition, FunctionResult, initController } from './firebase/functions-client.js';\n\nexport interface ServiceControllerInput {\n promise: Promise<FunctionResult>,\n func: FunctionDefinition,\n}\n\nexport class ServiceCallController {\n\n host: ReactiveControllerHost;\n\n private task!: Task;\n\n private _callDataPromise!: ServiceControllerInput;\n\n constructor(host: ReactiveControllerHost) {\n this.host = host;\n this.task = new Task<[ServiceControllerInput], FunctionResult>(host,\n\n async ([callDataPromise]: [ServiceControllerInput]) => {\n if (!callDataPromise) {\n return initialState;\n }\n try {\n const result = await callDataPromise.promise;\n return result as FunctionResult;\n } catch (e) {\n console.error(\"Error: \", e);\n throw new Error(`Failed call function \"${callDataPromise.func.name}\"`);\n }\n\n }, () => [this.callDataPromise]\n\n );\n initController(this);\n }\n\n /*\n set callData(value: FunctionParam) {\n this._callData = value;\n this.host.requestUpdate();\n }\n\n get callData(): FunctionParam { return this._callData; }\n */\n\n set callDataPromise(value: ServiceControllerInput) {\n this._callDataPromise = value;\n this.host.requestUpdate();\n }\n\n get callDataPromise(): ServiceControllerInput { return this._callDataPromise; }\n\n clear() {\n this.task.status = 0;\n this.host.requestUpdate();\n }\n\n // TODO: Type definition FunctionResult do not work, but work in Homepage Project...\n render(renderFunctions: any) {\n return this.task.render(renderFunctions);\n }\n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pF,MAAM,CAAC,eAAoB;QACzB,OAAO,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,eAAe,CAAC,CAAC;IAC3C,CAAC;CAEF","sourcesContent":["import {ReactiveControllerHost} from 'lit';\nimport {initialState, Task} from '@lit-labs/task';\n\nimport { FunctionDefinition, FunctionResult, initController } from './service-provider/firebase/functions-client.js';\n\nexport interface ServiceControllerInput {\n promise: Promise<FunctionResult>,\n func: FunctionDefinition,\n}\n\nexport class ServiceCallController {\n\n host: ReactiveControllerHost;\n\n private task!: Task;\n\n private _callDataPromise!: ServiceControllerInput;\n\n constructor(host: ReactiveControllerHost) {\n this.host = host;\n this.task = new Task<[ServiceControllerInput], FunctionResult>(host,\n\n async ([callDataPromise]: [ServiceControllerInput]) => {\n if (!callDataPromise) {\n return initialState;\n }\n try {\n const result = await callDataPromise.promise;\n return result as FunctionResult;\n } catch (e) {\n console.error(\"Error: \", e);\n throw new Error(`Failed call function \"${callDataPromise.func.name}\"`);\n }\n\n }, () => [this.callDataPromise]\n\n );\n initController(this);\n }\n\n /*\n set callData(value: FunctionParam) {\n this._callData = value;\n this.host.requestUpdate();\n }\n\n get callData(): FunctionParam { return this._callData; }\n */\n\n set callDataPromise(value: ServiceControllerInput) {\n this._callDataPromise = value;\n this.host.requestUpdate();\n }\n\n get callDataPromise(): ServiceControllerInput { return this._callDataPromise; }\n\n clear() {\n this.task.status = 0;\n this.host.requestUpdate();\n }\n\n // TODO: Type definition FunctionResult do not work, but work in Homepage Project...\n render(renderFunctions: any) {\n return this.task.render(renderFunctions);\n }\n\n}\n"]}
@@ -0,0 +1,5 @@
1
+ import { User } from 'firebase/auth';
2
+ export declare const logout: () => Promise<boolean>;
3
+ export declare const isAuthenticated: () => boolean;
4
+ export declare const authStateChanged: (callback: Function) => void;
5
+ export declare const login: (user: string, sec: string) => Promise<User>;
@@ -0,0 +1,48 @@
1
+ import { getAuth, onAuthStateChanged, signInWithEmailAndPassword, signOut } from 'firebase/auth';
2
+ export const logout = async () => {
3
+ const auth = getAuth();
4
+ try {
5
+ await signOut(auth);
6
+ return true;
7
+ }
8
+ catch (error) {
9
+ return false;
10
+ }
11
+ };
12
+ export const isAuthenticated = () => getAuth().currentUser !== null;
13
+ export const authStateChanged = (callback) => {
14
+ onAuthStateChanged(getAuth(), (user) => callback(user));
15
+ /* Alter code aus init in pd-spa-helper, hier falsch, noch refactorieren
16
+ if (user) {
17
+ this._user = user;
18
+ if (postLoginFunc) {
19
+ callFunction(postLoginFunc, postLoginFunc.param)
20
+ .then((result:FunctionResult) => {
21
+ this._profile = result.resultData;
22
+ // redirect if login in the meantime is available
23
+ // => else stay on the login page after reload/url navigation
24
+ if (this.route === "login" && postLoginFunc?.redirect) {
25
+ this.navigate(postLoginFunc.redirect);
26
+ }
27
+ // new event, could/should replace redirect
28
+ document.dispatchEvent(new CustomEvent("user-login-event"));
29
+ }).catch(() => {
30
+ if (postLoginFunc?.logoutOnFail) {
31
+ logout();
32
+ this._user = undefined;
33
+ this._profile = undefined;
34
+ }
35
+ });
36
+ } else {
37
+ this._user = undefined;
38
+ this._profile = undefined;
39
+ }
40
+ }
41
+ */
42
+ };
43
+ export const login = async (user, sec) => {
44
+ const auth = getAuth();
45
+ const credentials = await signInWithEmailAndPassword(auth, user, sec);
46
+ return credentials.user;
47
+ };
48
+ //# sourceMappingURL=auth.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"auth.js","sourceRoot":"","sources":["../../../../src/service-provider/firebase/auth.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,kBAAkB,EAAE,0BAA0B,EAAE,OAAO,EAAQ,MAAM,eAAe,CAAC;AAEvG,MAAM,CAAC,MAAM,MAAM,GAAG,KAAK,IAAsB,EAAE;IACjD,MAAM,IAAI,GAAG,OAAO,EAAE,CAAC;IACvB,IAAI;QACF,MAAM,OAAO,CAAC,IAAI,CAAC,CAAC;QACpB,OAAO,IAAI,CAAC;KACb;IAAC,OAAO,KAAK,EAAE;QACd,OAAO,KAAK,CAAC;KACd;AACH,CAAC,CAAC;AAEF,MAAM,CAAC,MAAM,eAAe,GAAG,GAAY,EAAE,CAC3C,OAAO,EAAE,CAAC,WAAW,KAAK,IAAI,CAAC;AAGjC,MAAM,CAAC,MAAM,gBAAgB,GAAG,CAAC,QAAkB,EAAE,EAAE;IACrD,kBAAkB,CAAC,OAAO,EAAE,EAAE,CAAC,IAAI,EAAE,EAAE,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC,CAAC;IACxD;;;;;;;;;;;;;;;;;;;;;;;;;;MA0BE;AACJ,CAAC,CAAA;AAED,MAAM,CAAC,MAAM,KAAK,GAAG,KAAK,EAAE,IAAW,EAAE,GAAU,EAAiB,EAAE;IACpE,MAAM,IAAI,GAAG,OAAO,EAAE,CAAC;IACvB,MAAM,WAAW,GAAG,MAAM,0BAA0B,CAAC,IAAI,EAAE,IAAI,EAAE,GAAG,CAAC,CAAC;IACtE,OAAO,WAAW,CAAC,IAAI,CAAC;AAC1B,CAAC,CAAA","sourcesContent":["import { getAuth, onAuthStateChanged, signInWithEmailAndPassword, signOut, User } from 'firebase/auth';\n\nexport const logout = async (): Promise<boolean> => {\n const auth = getAuth();\n try {\n await signOut(auth);\n return true;\n } catch (error) {\n return false;\n }\n};\n\nexport const isAuthenticated = (): boolean => \n getAuth().currentUser !== null;\n\n\nexport const authStateChanged = (callback: Function) => {\n onAuthStateChanged(getAuth(), (user) => callback(user)); \n /* Alter code aus init in pd-spa-helper, hier falsch, noch refactorieren \n if (user) {\n this._user = user;\n if (postLoginFunc) { \n callFunction(postLoginFunc, postLoginFunc.param)\n .then((result:FunctionResult) => {\n this._profile = result.resultData;\n // redirect if login in the meantime is available \n // => else stay on the login page after reload/url navigation\n if (this.route === \"login\" && postLoginFunc?.redirect) { \n this.navigate(postLoginFunc.redirect);\n }\n // new event, could/should replace redirect\n document.dispatchEvent(new CustomEvent(\"user-login-event\"));\n }).catch(() => {\n if (postLoginFunc?.logoutOnFail) {\n logout();\n this._user = undefined;\n this._profile = undefined;\n }\n }); \n } else {\n this._user = undefined;\n this._profile = undefined;\n }\n }\n */\n}\n \nexport const login = async (user:string, sec:string): Promise<User> => {\n const auth = getAuth(); \n const credentials = await signInWithEmailAndPassword(auth, user, sec);\n return credentials.user; \n}\n"]}
@@ -0,0 +1,9 @@
1
+ import { FirebaseApp } from 'firebase/app';
2
+ import { Firestore } from 'firebase/firestore';
3
+ /**
4
+ * During start/load application, initialize functions.
5
+ *
6
+ * @param {*} app - initialized app.
7
+ */
8
+ export declare const initFirestore: (app: FirebaseApp) => void;
9
+ export declare const getDB: () => Firestore;
@@ -0,0 +1,19 @@
1
+ import { getFirestore } from 'firebase/firestore';
2
+ // import { getAuth } from 'firebase/auth';
3
+ let db;
4
+ /**
5
+ * During start/load application, initialize functions.
6
+ *
7
+ * @param {*} app - initialized app.
8
+ */
9
+ export const initFirestore = (app) => {
10
+ try {
11
+ // init db access
12
+ db = getFirestore(app);
13
+ }
14
+ catch (error) {
15
+ console.error(error);
16
+ }
17
+ };
18
+ export const getDB = () => db;
19
+ //# sourceMappingURL=firestore-client.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"firestore-client.js","sourceRoot":"","sources":["../../../../src/service-provider/firebase/firestore-client.ts"],"names":[],"mappings":"AACA,OAAO,EAAY,YAAY,EAAC,MAAM,oBAAoB,CAAC;AAC3D,2CAA2C;AAE3C,IAAI,EAAY,CAAC;AAEjB;;;;GAIG;AACH,MAAM,CAAC,MAAM,aAAa,GAAG,CAAC,GAAgB,EAAE,EAAE;IAChD,IAAI;QACF,iBAAiB;QACjB,EAAE,GAAG,YAAY,CAAC,GAAG,CAAC,CAAC;KACxB;IAAC,OAAO,KAAK,EAAE;QACd,OAAO,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;KACtB;AACH,CAAC,CAAC;AAEF,MAAM,CAAC,MAAM,KAAK,GAAG,GAAa,EAAE,CAAC,EAAE,CAAC","sourcesContent":["import { FirebaseApp } from 'firebase/app';\nimport {Firestore, getFirestore} from 'firebase/firestore';\n// import { getAuth } from 'firebase/auth';\n\nlet db:Firestore;\n\n/**\n * During start/load application, initialize functions.\n *\n * @param {*} app - initialized app.\n */\nexport const initFirestore = (app: FirebaseApp) => {\n try {\n // init db access\n db = getFirestore(app);\n } catch (error) {\n console.error(error);\n }\n};\n\nexport const getDB = ():Firestore => db;\n"]}
@@ -0,0 +1,34 @@
1
+ import { FirebaseApp } from "firebase/app";
2
+ import { TemplateResult } from "lit";
3
+ import { ServiceCallController } from "../../service-call-controller2.js";
4
+ export interface FunctionDefinition {
5
+ name: string;
6
+ successCodes: Array<Number>;
7
+ fadeWindow: boolean;
8
+ successTxt: TemplateResult;
9
+ pendingTxt: TemplateResult;
10
+ param?: any;
11
+ redirect?: string;
12
+ logoutOnFail?: boolean;
13
+ }
14
+ export interface FunctionParam {
15
+ func: FunctionDefinition;
16
+ inputData: any;
17
+ }
18
+ export interface FunctionResult {
19
+ resultData: unknown;
20
+ statusCode: number;
21
+ }
22
+ export interface FunctionsConfig {
23
+ region: string;
24
+ functions: Array<FunctionDefinition>;
25
+ postLoginFunc?: FunctionDefinition;
26
+ }
27
+ /**
28
+ * During start/load application, initialize functions.
29
+ *
30
+ * @param {*} app - initialized app.
31
+ */
32
+ export declare const initFunctions: (app: FirebaseApp, functionsConfig: FunctionsConfig) => void;
33
+ export declare const initController: (controllerParam: ServiceCallController) => void;
34
+ export declare const callFunction: (def: FunctionDefinition, functionInput: any) => Promise<FunctionResult>;
@@ -0,0 +1,70 @@
1
+ import { getFunctions, httpsCallable } from "firebase/functions";
2
+ const functionMap = new Map;
3
+ let controller;
4
+ /**
5
+ * During start/load application, initialize functions.
6
+ *
7
+ * @param {*} app - initialized app.
8
+ */
9
+ export const initFunctions = (app, functionsConfig) => {
10
+ try {
11
+ // Initialize cloud functions through Firebase
12
+ const functions = getFunctions(app, functionsConfig.region);
13
+ // Initialize functions map
14
+ functionsConfig.functions.forEach(func => {
15
+ functionMap.set(func, httpsCallable(functions, func.name));
16
+ });
17
+ }
18
+ catch (error) {
19
+ console.error("ToDo: Error programmieren...", error);
20
+ }
21
+ };
22
+ export const initController = (controllerParam) => {
23
+ controller = controllerParam;
24
+ };
25
+ const internalCallFunction = async (def, functionInput) => {
26
+ const funcRef = functionMap.get(def);
27
+ if (funcRef) {
28
+ const funcResult = await funcRef(functionInput);
29
+ if (funcResult
30
+ && funcResult.data && def.successCodes.includes(funcResult.data.statusCode)) {
31
+ return funcResult.data;
32
+ }
33
+ /*
34
+ const ne = new Error("Invalid result");
35
+ if (result.data) {
36
+ // Read result of the Cloud Function.
37
+ switch (result.data.statusCode) {
38
+ case 200:
39
+ return resolve(result.data.projects);
40
+ default:
41
+ ne.data = result.data;
42
+ return reject(ne);
43
+ }
44
+ } else {
45
+ return reject(ne);
46
+ }
47
+ })
48
+ .catch((error) => {
49
+ // Getting the Error details.
50
+ const {code} = error;
51
+ const {message} = error;
52
+ const {details} = error;
53
+
54
+ console.warn("Error occured: ", code, message, details);
55
+ console.warn("Error: ", error);
56
+ return reject(error);
57
+ })
58
+ */
59
+ }
60
+ console.log("No function available for ", def.name);
61
+ throw new Error("Illegal state, no data with right state available");
62
+ };
63
+ export const callFunction = async (def, functionInput) => {
64
+ const promise = internalCallFunction(def, functionInput);
65
+ if (controller) {
66
+ controller.callDataPromise = { func: def, promise };
67
+ }
68
+ return promise;
69
+ };
70
+ //# sourceMappingURL=functions-client.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"functions-client.js","sourceRoot":"","sources":["../../../../src/service-provider/firebase/functions-client.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,YAAY,EAAiB,aAAa,EAAE,MAAM,oBAAoB,CAAC;AAgChF,MAAM,WAAW,GAAG,IAAI,GAAsC,CAAC;AAC/D,IAAI,UAAiC,CAAC;AAEtC;;;;GAIG;AACH,MAAM,CAAC,MAAM,aAAa,GAAG,CAAC,GAAgB,EAAE,eAAgC,EAAE,EAAE;IAClF,IAAI;QACA,8CAA8C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C,CAAC;IACzD,IAAI,UAAU,EAAE;QACd,UAAU,CAAC,eAAe,GAAG,EAAC,IAAI,EAAE,GAAG,EAAE,OAAO,EAAC,CAAC;KACnD;IACD,OAAO,OAAO,CAAC;AACjB,CAAC,CAAA","sourcesContent":["import { FirebaseApp } from \"firebase/app\";\nimport { getFunctions, HttpsCallable, httpsCallable } from \"firebase/functions\";\nimport { TemplateResult } from \"lit\";\nimport { ServiceCallController } from \"../../service-call-controller2.js\";\n\nexport interface FunctionDefinition {\n name: string,\n successCodes: Array<Number>, \n // Fade window during function call (true) or show only background infos (false).\n fadeWindow: boolean,\n successTxt: TemplateResult,\n pendingTxt: TemplateResult,\n param?: any,\n redirect?: string,\n logoutOnFail?: boolean\n}\n\nexport interface FunctionParam {\n func: FunctionDefinition,\n inputData: any,\n}\n\nexport interface FunctionResult {\n resultData: unknown,\n statusCode: number,\n}\n\nexport interface FunctionsConfig {\n region: string, // 'europe-west3'\n functions: Array<FunctionDefinition>,\n postLoginFunc?: FunctionDefinition,\n}\n\nconst functionMap = new Map<FunctionDefinition, HttpsCallable>;\nlet controller: ServiceCallController;\n\n/**\n * During start/load application, initialize functions. \n * \n * @param {*} app - initialized app. \n */\nexport const initFunctions = (app: FirebaseApp, functionsConfig: FunctionsConfig) => {\n try {\n // Initialize cloud functions through Firebase\n const functions = getFunctions(app, functionsConfig.region);\n\n // Initialize functions map\n functionsConfig.functions.forEach(func => {\n functionMap.set(func, httpsCallable(functions, func.name));\n });\n\n } catch (error) {\n console.error(\"ToDo: Error programmieren...\", error);\n }\n}\n\nexport const initController = (controllerParam: ServiceCallController) => {\n controller = controllerParam\n}\n\nconst internalCallFunction = async (def: FunctionDefinition, functionInput: any): Promise<FunctionResult> => {\n const funcRef = functionMap.get(def); \n if (funcRef) { \n const funcResult:any = await funcRef(functionInput);\n if (funcResult \n && funcResult.data && def.successCodes.includes(funcResult.data.statusCode)) {\n return funcResult.data as FunctionResult;\n }\n /*\n const ne = new Error(\"Invalid result\");\n if (result.data) {\n // Read result of the Cloud Function. \n switch (result.data.statusCode) {\n case 200:\n return resolve(result.data.projects);\n default:\n ne.data = result.data;\n return reject(ne);\n }\n } else {\n return reject(ne);\n }\n })\n .catch((error) => {\n // Getting the Error details.\n const {code} = error;\n const {message} = error;\n const {details} = error;\n\n console.warn(\"Error occured: \", code, message, details);\n console.warn(\"Error: \", error);\n return reject(error);\n })\n */\n } \n console.log(\"No function available for \", def.name);\n throw new Error(\"Illegal state, no data with right state available\");\n}\n\nexport const callFunction = async (def: FunctionDefinition, functionInput: any): Promise<FunctionResult> => {\n const promise = internalCallFunction(def, functionInput);\n if (controller) {\n controller.callDataPromise = {func: def, promise};\n }\n return promise;\n}"]}