@progressive-development/pd-spa-helper 0.1.91 → 0.1.92
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/src/PdSpaHelper.d.ts +2 -56
- package/dist/src/PdSpaHelper.js +5 -17
- package/dist/src/PdSpaHelper.js.map +1 -1
- package/dist/src/index.d.ts +3 -3
- package/dist/src/index.js +3 -3
- package/dist/src/index.js.map +1 -1
- package/dist/src/service-call-controller2.d.ts +1 -1
- package/dist/src/service-call-controller2.js +1 -1
- package/dist/src/service-call-controller2.js.map +1 -1
- package/dist/src/service-provider/firebase/functions-client.d.ts +1 -26
- package/dist/src/service-provider/firebase/functions-client.js +1 -11
- package/dist/src/service-provider/firebase/functions-client.js.map +1 -1
- package/dist/src/service-provider/mock/auth.d.ts +1 -1
- package/dist/src/service-provider/mock/auth.js +1 -1
- package/dist/src/service-provider/mock/auth.js.map +1 -1
- package/dist/src/service-provider/mock/function-client.d.ts +2 -0
- package/dist/src/service-provider/mock/function-client.js +8 -0
- package/dist/src/service-provider/mock/function-client.js.map +1 -0
- package/dist/src/service-provider/service-provider-impl.d.ts +5 -1
- package/dist/src/service-provider/service-provider-impl.js +56 -1
- package/dist/src/service-provider/service-provider-impl.js.map +1 -1
- package/dist/src/service-provider/service-provider-model.d.ts +85 -0
- package/dist/src/service-provider/service-provider-model.js +2 -0
- package/dist/src/service-provider/service-provider-model.js.map +1 -0
- package/dist/src/store/mini-rx.store.d.ts +1 -1
- package/dist/src/store/mini-rx.store.js.map +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +1 -1
- package/src/PdSpaHelper.ts +7 -84
- package/src/index.ts +6 -18
- package/src/service-call-controller2.ts +2 -1
- package/src/service-provider/firebase/functions-client.ts +4 -42
- package/src/service-provider/mock/auth.ts +1 -1
- package/src/service-provider/mock/function-client.ts +11 -0
- package/src/service-provider/service-provider-impl.ts +69 -4
- package/src/service-provider/service-provider-model.ts +106 -0
- package/src/store/mini-rx.store.ts +1 -1
- package/src/InitApplicationData.ts +0 -9
|
@@ -1,67 +1,13 @@
|
|
|
1
|
-
import { FirebaseOptions } from 'firebase/app';
|
|
2
1
|
import { LitElement, CSSResultGroup, TemplateResult } from 'lit';
|
|
3
2
|
import '@progressive-development/pd-page/pd-menu.js';
|
|
4
3
|
import '@progressive-development/pd-page/pd-footer.js';
|
|
5
|
-
import { FunctionResult, FunctionsConfig } from './service-provider/firebase/functions-client.js';
|
|
6
4
|
import { ServiceCallController } from './service-call-controller2.js';
|
|
5
|
+
import { AppConfiguration, Footer, FunctionResult, NavigationPage } from './service-provider/service-provider-model.js';
|
|
7
6
|
import './router/AppMain.js';
|
|
8
7
|
import './defaultpage/default-login.js';
|
|
9
8
|
import './tmpown/pd-panel-viewer.js';
|
|
10
9
|
import './tmpown/pd-panel.js';
|
|
11
10
|
import './tmpown/pd-toast.js';
|
|
12
|
-
/**
|
|
13
|
-
* Data models.
|
|
14
|
-
*/
|
|
15
|
-
export interface MenuElement {
|
|
16
|
-
key: string;
|
|
17
|
-
name: string;
|
|
18
|
-
sec?: string;
|
|
19
|
-
route?: string;
|
|
20
|
-
action?: Function;
|
|
21
|
-
topItem?: boolean;
|
|
22
|
-
ref?: any;
|
|
23
|
-
icon?: string;
|
|
24
|
-
}
|
|
25
|
-
export interface NavigationPage {
|
|
26
|
-
name: string;
|
|
27
|
-
mainClass?: string;
|
|
28
|
-
pattern: Array<string>;
|
|
29
|
-
auth: boolean;
|
|
30
|
-
menu?: Array<MenuElement>;
|
|
31
|
-
topMenu?: Array<MenuElement>;
|
|
32
|
-
withTeaser?: boolean;
|
|
33
|
-
withFooter?: boolean;
|
|
34
|
-
hideMenu?: boolean;
|
|
35
|
-
}
|
|
36
|
-
export type ServiceProviderFirebase = "firebase";
|
|
37
|
-
export type ServiceProviderMock = "mock";
|
|
38
|
-
export type ServiceProviderConfiguration = ServiceProviderFirebase | ServiceProviderMock;
|
|
39
|
-
export interface NavigationConfig {
|
|
40
|
-
pages: Array<NavigationPage>;
|
|
41
|
-
includeLogin: boolean;
|
|
42
|
-
}
|
|
43
|
-
export interface LinkObj {
|
|
44
|
-
name: string;
|
|
45
|
-
key: string;
|
|
46
|
-
link?: string;
|
|
47
|
-
action?: Function;
|
|
48
|
-
}
|
|
49
|
-
export interface Footer {
|
|
50
|
-
version: string;
|
|
51
|
-
links: Array<LinkObj>;
|
|
52
|
-
}
|
|
53
|
-
export interface StoreConfig {
|
|
54
|
-
appName: string;
|
|
55
|
-
reducer: any;
|
|
56
|
-
effects: Array<any>;
|
|
57
|
-
}
|
|
58
|
-
export interface AppConfiguration {
|
|
59
|
-
serviceProvider?: ServiceProviderConfiguration;
|
|
60
|
-
navigationConfigParam: NavigationConfig;
|
|
61
|
-
storeConfigParam?: StoreConfig;
|
|
62
|
-
firebaseConfig?: FirebaseOptions;
|
|
63
|
-
functionsConfig?: FunctionsConfig;
|
|
64
|
-
}
|
|
65
11
|
/**
|
|
66
12
|
* Init the firebase app and application services like
|
|
67
13
|
* functions and firestore. Generate routes from navigationConfig.
|
|
@@ -117,7 +63,7 @@ export declare abstract class PdSpaHelper extends PdSpaHelper_base {
|
|
|
117
63
|
activateLoginHandler(): void;
|
|
118
64
|
render(): TemplateResult<1>;
|
|
119
65
|
private _getMainClass;
|
|
120
|
-
_renderMenu(pageConfig: NavigationPage, hideTeaser: boolean): TemplateResult<1
|
|
66
|
+
_renderMenu(pageConfig: NavigationPage, hideTeaser: boolean): "" | TemplateResult<1>;
|
|
121
67
|
_renderTeaser(): TemplateResult | string;
|
|
122
68
|
_renderFooter(): TemplateResult<1>;
|
|
123
69
|
/**
|
package/dist/src/PdSpaHelper.js
CHANGED
|
@@ -1,25 +1,21 @@
|
|
|
1
1
|
import { __decorate } from "tslib";
|
|
2
|
-
import { initializeApp } from 'firebase/app';
|
|
3
|
-
// TODO: Add SDKs for Firebase products that you want to use
|
|
4
|
-
// https://firebase.google.com/docs/web/setup#available-libraries
|
|
5
2
|
import { html, LitElement, css } from 'lit';
|
|
6
3
|
import { router, navigator } from 'lit-element-router';
|
|
7
4
|
import { property } from 'lit/decorators.js';
|
|
8
5
|
import '@progressive-development/pd-page/pd-menu.js';
|
|
9
6
|
import '@progressive-development/pd-page/pd-footer.js';
|
|
10
|
-
import { initApplicationServices } from './InitApplicationData.js';
|
|
11
7
|
import { ServiceCallController } from './service-call-controller2.js';
|
|
12
8
|
import { initializeStore } from './store/mini-rx.store.js';
|
|
9
|
+
import { authStateChangedImpl, initAppImpl, isAuthenticatedImpl, setServiceProvider } from './service-provider/service-provider-impl.js';
|
|
13
10
|
import './router/AppMain.js';
|
|
14
11
|
import './defaultpage/default-login.js';
|
|
15
12
|
import './tmpown/pd-panel-viewer.js';
|
|
16
13
|
import './tmpown/pd-panel.js';
|
|
14
|
+
// eslint-disable-next-line import/no-duplicates
|
|
15
|
+
import './tmpown/pd-toast.js';
|
|
17
16
|
// TODO: How to solve this import problem?
|
|
18
17
|
// eslint-disable-next-line import/no-duplicates
|
|
19
18
|
import { PdToast } from './tmpown/pd-toast.js';
|
|
20
|
-
// eslint-disable-next-line import/no-duplicates
|
|
21
|
-
import './tmpown/pd-toast.js';
|
|
22
|
-
import { authStateChangedImpl, isAuthenticatedImpl, setServiceProvider } from './service-provider/service-provider-impl.js';
|
|
23
19
|
// Footer Text
|
|
24
20
|
const MADE_BY = {
|
|
25
21
|
txt: "made by PD Progressive Development",
|
|
@@ -32,7 +28,6 @@ const TOAST_DURATION = 6000;
|
|
|
32
28
|
*/
|
|
33
29
|
let transformedRoutes;
|
|
34
30
|
let navigationConfig;
|
|
35
|
-
let postLoginFunc;
|
|
36
31
|
/**
|
|
37
32
|
* Internal helper functions to generate route elemets for lit-router.
|
|
38
33
|
*/
|
|
@@ -75,15 +70,8 @@ export const startInit = (config) => {
|
|
|
75
70
|
if (config.storeConfigParam) {
|
|
76
71
|
initializeStore(config.storeConfigParam);
|
|
77
72
|
}
|
|
78
|
-
// init
|
|
79
|
-
|
|
80
|
-
const app = initializeApp(config.firebaseConfig);
|
|
81
|
-
if (config.functionsConfig) {
|
|
82
|
-
// init application services (functions, store)
|
|
83
|
-
initApplicationServices(app, config.functionsConfig);
|
|
84
|
-
postLoginFunc = config.functionsConfig.postLoginFunc;
|
|
85
|
-
}
|
|
86
|
-
}
|
|
73
|
+
// init app
|
|
74
|
+
initAppImpl(config);
|
|
87
75
|
if (config.navigationConfigParam.includeLogin) {
|
|
88
76
|
config.navigationConfigParam.pages.push({
|
|
89
77
|
name: "login",
|
|
@@ -1 +1 @@
|
|
|
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,EAAE,MAAM,6CAA6C,CAAC;AAG5H,cAA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;kDACN;AAItB;IADC,QAAQ,CAAC,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 @login-success=\"${this._loginSuccess}\">\n ${this._renderRoutePages()}\n ${navigationConfig.includeLogin ? html`\n <default-login ?active=\"${this.route === \"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 _loginSuccess(e: CustomEvent): void;\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,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,qBAAqB,EAAE,MAAM,+BAA+B,CAAC;AACtE,OAAO,EAAE,eAAe,EAAE,MAAM,0BAA0B,CAAC;AAE3D,OAAO,EAAE,oBAAoB,EAAE,WAAW,EAAE,mBAAmB,EAAE,kBAAkB,EAAE,MAAM,6CAA6C,CAAC;AAGzI,OAAO,qBAAqB,CAAC;AAC7B,OAAO,gCAAgC,CAAC;AACxC,OAAO,6BAA6B,CAAC;AACrC,OAAO,sBAAsB,CAAC;AAC9B,gDAAgD;AAChD,OAAO,sBAAsB,CAAC;AAE9B,0CAA0C;AAC1C,gDAAgD;AAChD,OAAO,EAAE,OAAO,EAAE,MAAM,sBAAsB,CAAC;AAG/C,cAAc;AACd,MAAM,OAAO,GAAG;IACd,GAAG,EAAE,oCAAoC;IACzC,KAAK,EAAE,kCAAkC;CAAC,CAAC;AAE7C,sCAAsC;AACtC,MAAM,cAAc,GAAG,IAAI,CAAC;AAG5B;;GAEG;AACH,IAAI,iBAA4B,CAAC;AACjC,IAAI,gBAAiC,CAAC;AAEtC;;GAEG;AACH,MAAM,eAAe,GAAG,GAAG,EAAE;IAE3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AAC;SACJ;IACH,CAAC;;AA7WM,kBAAM;AACX,sEAAsE;AACtE,GAAG,CAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAgEc,CAAC;AAtGpB;IADC,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;0CACP;AAMpB;IADC,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC;0CACb;AAG3B;IADC,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC;6CACd;AAM1B;IADC,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;0CAC/B;AAGX;IADC,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;2CACf;AAGZ;IADC,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;0CAChB;AAMX;IADC,QAAQ,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 { 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 { ServiceCallController } from './service-call-controller2.js';\nimport { initializeStore } from './store/mini-rx.store.js';\n\nimport { authStateChangedImpl, initAppImpl, isAuthenticatedImpl, setServiceProvider } from './service-provider/service-provider-impl.js';\nimport { AppConfiguration, Footer, FunctionResult, MenuElement, NavigationConfig, NavigationPage } from './service-provider/service-provider-model.js';\n\nimport './router/AppMain.js';\nimport './defaultpage/default-login.js';\nimport './tmpown/pd-panel-viewer.js';\nimport './tmpown/pd-panel.js';\n// eslint-disable-next-line import/no-duplicates\nimport './tmpown/pd-toast.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\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/**\n * Transformed routes, generated during startInit.\n */\nlet transformedRoutes:Array<any>;\nlet navigationConfig:NavigationConfig;\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 app\n initAppImpl(config);\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 @login-success=\"${this._loginSuccess}\">\n ${this._renderRoutePages()}\n ${navigationConfig.includeLogin ? html`\n <default-login ?active=\"${this.route === \"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 _loginSuccess(e: CustomEvent): void;\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}"]}
|
package/dist/src/index.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
export { PdSpaHelper,
|
|
1
|
+
export { PdSpaHelper, startInit, } from './PdSpaHelper.js';
|
|
2
|
+
export * as pdSpaModel from './service-provider/service-provider-model.js';
|
|
2
3
|
export { isBlank, isEmpty } from './helper/helper-utils.js';
|
|
3
4
|
export { DefaultViewPage } from './defaultpage/default-view-page.js';
|
|
4
5
|
export { DefaultConfirmPopup, PopupType, ABORT_EVENT_NAME, STORE_EVENT_NAME } from './defaultpage/default-confirm-popup.js';
|
|
@@ -8,9 +9,8 @@ export { DefaultWizard } from './defaultpage/default-wizard.js';
|
|
|
8
9
|
export { DefaultWizardStep } from './defaultpage/default-wizard-step.js';
|
|
9
10
|
export { DefaultStepAddress } from './defaultpage/default-step-address.js';
|
|
10
11
|
export { DefaultStepSummary, OrderStep } from './defaultpage/default-step-summary.js';
|
|
11
|
-
export { FunctionDefinition, FunctionResult, FunctionParam, FunctionsConfig, callFunction } from './service-provider/firebase/functions-client.js';
|
|
12
12
|
export { getDB, } from './service-provider/firebase/firestore-client.js';
|
|
13
|
-
export { loginImpl, logoutImpl, isAuthenticatedImpl } from './service-provider/service-provider-impl.js';
|
|
13
|
+
export { loginImpl, logoutImpl, isAuthenticatedImpl, callFunctionImpl } 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
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
export { PdSpaHelper, startInit } from './PdSpaHelper.js';
|
|
1
|
+
export { PdSpaHelper, startInit, } from './PdSpaHelper.js';
|
|
2
|
+
export * as pdSpaModel from './service-provider/service-provider-model.js';
|
|
2
3
|
export { isBlank, isEmpty } from './helper/helper-utils.js';
|
|
3
4
|
export { DefaultViewPage } from './defaultpage/default-view-page.js';
|
|
4
5
|
export { DefaultConfirmPopup, ABORT_EVENT_NAME, STORE_EVENT_NAME } from './defaultpage/default-confirm-popup.js';
|
|
@@ -8,9 +9,8 @@ export { DefaultWizard } from './defaultpage/default-wizard.js';
|
|
|
8
9
|
export { DefaultWizardStep } from './defaultpage/default-wizard-step.js';
|
|
9
10
|
export { DefaultStepAddress } from './defaultpage/default-step-address.js';
|
|
10
11
|
export { DefaultStepSummary } from './defaultpage/default-step-summary.js';
|
|
11
|
-
export { callFunction } from './service-provider/firebase/functions-client.js';
|
|
12
12
|
export { getDB, } from './service-provider/firebase/firestore-client.js';
|
|
13
|
-
export { loginImpl, logoutImpl, isAuthenticatedImpl } from './service-provider/service-provider-impl.js';
|
|
13
|
+
export { loginImpl, logoutImpl, isAuthenticatedImpl, callFunctionImpl } 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.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,WAAW,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,WAAW,EACX,SAAS,GACV,MAAM,kBAAkB,CAAC;AAE1B,OAAO,KAAK,UAAU,MAAM,8CAA8C,CAAA;AAE1E,OAAO,EAAC,OAAO,EAAE,OAAO,EAAC,MAAM,0BAA0B,CAAC;AAE1D,OAAO,EAAC,eAAe,EAAC,MAAM,oCAAoC,CAAC;AAEnE,OAAO,EAAC,mBAAmB,EAAa,gBAAgB,EAAE,gBAAgB,EAAC,MAAM,wCAAwC,CAAC;AAE1H,OAAO,EAAC,kBAAkB,EAAC,MAAM,uCAAuC,CAAC;AAEzE,OAAO,EAAC,YAAY,EAAC,MAAM,gCAAgC,CAAC;AAE5D,OAAO,EAAC,aAAa,EAAC,MAAM,iCAAiC,CAAC;AAE9D,OAAO,EAAC,iBAAiB,EAAC,MAAM,sCAAsC,CAAC;AAEvE,OAAO,EAAC,kBAAkB,EAAC,MAAM,uCAAuC,CAAC;AAEzE,OAAO,EAAC,kBAAkB,EAAY,MAAM,uCAAuC,CAAC;AAEpF,OAAO,EACL,KAAK,GACN,MAAM,iDAAiD,CAAA;AAExD,OAAO,EACL,SAAS,EACT,UAAU,EACV,mBAAmB,EACnB,gBAAgB,EACjB,MAAM,6CAA6C,CAAA;AAEpD,OAAO,EAAE,OAAO,EAAE,MAAM,0BAA0B,CAAC;AAEnD,OAAO,EAAE,SAAS,IAAI,UAAU,EAAC,MAAM,0CAA0C,CAAA;AACjF,OAAO,EAAE,SAAS,IAAI,UAAU,EAAC,MAAM,0CAA0C,CAAA;AACjF,OAAO,EAAE,SAAS,IAAI,UAAU,EAAC,MAAM,0CAA0C,CAAA;AAEjF,MAAM,CAAC,MAAM,kBAAkB,GAAG,CAAC,OAAW,EAAE,GAAU,EAAE,SAAiB,EAAE,OAAe,EAAE,EAAE;IAChG,OAAO,CAAC,aAAa,CAAC,IAAI,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 startInit, \n} from './PdSpaHelper.js';\n\nexport * as pdSpaModel from './service-provider/service-provider-model.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 getDB,\n} from './service-provider/firebase/firestore-client.js'\n\nexport {\n loginImpl,\n logoutImpl,\n isAuthenticatedImpl,\n callFunctionImpl\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 './service-provider/
|
|
2
|
+
import { FunctionDefinition, FunctionResult } from './service-provider/service-provider-model.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 './service-provider/
|
|
2
|
+
import { initController } from './service-provider/service-provider-impl.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;
|
|
1
|
+
{"version":3,"file":"service-call-controller2.js","sourceRoot":"","sources":["../../src/service-call-controller2.ts"],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e,CAAC,CAAC;IAC3C,CAAC;CAEF","sourcesContent":["import {ReactiveControllerHost} from 'lit';\nimport {initialState, Task} from '@lit-labs/task';\n\nimport { FunctionDefinition, FunctionResult } from './service-provider/service-provider-model.js';\nimport { initController } from './service-provider/service-provider-impl.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"]}
|
|
@@ -1,34 +1,9 @@
|
|
|
1
1
|
import { FirebaseApp } from "firebase/app";
|
|
2
|
-
import {
|
|
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
|
-
}
|
|
2
|
+
import { FunctionDefinition, FunctionResult, FunctionsConfig } from "../service-provider-model.js";
|
|
27
3
|
/**
|
|
28
4
|
* During start/load application, initialize functions.
|
|
29
5
|
*
|
|
30
6
|
* @param {*} app - initialized app.
|
|
31
7
|
*/
|
|
32
8
|
export declare const initFunctions: (app: FirebaseApp, functionsConfig: FunctionsConfig) => void;
|
|
33
|
-
export declare const initController: (controllerParam: ServiceCallController) => void;
|
|
34
9
|
export declare const callFunction: (def: FunctionDefinition, functionInput: any) => Promise<FunctionResult>;
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { getFunctions, httpsCallable } from "firebase/functions";
|
|
2
2
|
const functionMap = new Map;
|
|
3
|
-
let controller;
|
|
4
3
|
/**
|
|
5
4
|
* During start/load application, initialize functions.
|
|
6
5
|
*
|
|
@@ -19,9 +18,6 @@ export const initFunctions = (app, functionsConfig) => {
|
|
|
19
18
|
console.error("ToDo: Error programmieren...", error);
|
|
20
19
|
}
|
|
21
20
|
};
|
|
22
|
-
export const initController = (controllerParam) => {
|
|
23
|
-
controller = controllerParam;
|
|
24
|
-
};
|
|
25
21
|
const internalCallFunction = async (def, functionInput) => {
|
|
26
22
|
const funcRef = functionMap.get(def);
|
|
27
23
|
if (funcRef) {
|
|
@@ -60,11 +56,5 @@ const internalCallFunction = async (def, functionInput) => {
|
|
|
60
56
|
console.log("No function available for ", def.name);
|
|
61
57
|
throw new Error("Illegal state, no data with right state available");
|
|
62
58
|
};
|
|
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
|
-
};
|
|
59
|
+
export const callFunction = async (def, functionInput) => internalCallFunction(def, functionInput);
|
|
70
60
|
//# sourceMappingURL=functions-client.js.map
|
|
@@ -1 +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;
|
|
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;AAGhF,MAAM,WAAW,GAAG,IAAI,GAAsC,CAAC;AAE/D;;;;GAIG;AACH,MAAM,CAAC,MAAM,aAAa,GAAG,CAAC,GAAgB,EAAE,eAAgC,EAAE,EAAE;IAClF,IAAI;QACA,8CAA8C;QAC9C,MAAM,SAAS,GAAG,YAAY,CAAC,GAAG,EAAE,eAAe,CAAC,MAAM,CAAC,CAAC;QAE5D,2BAA2B;QAC3B,eAAe,CAAC,SAAS,CAAC,OAAO,CAAC,IAAI,CAAC,EAAE;YACvC,WAAW,CAAC,GAAG,CAAC,IAAI,EAAE,aAAa,CAAC,SAAS,EAAE,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC;QAC7D,CAAC,CAAC,CAAC;KAEN;IAAC,OAAO,KAAK,EAAE;QACZ,OAAO,CAAC,KAAK,CAAC,8BAA8B,EAAE,KAAK,CAAC,CAAC;KACxD;AACH,CAAC,CAAA;AAED,MAAM,oBAAoB,GAAG,KAAK,EAAE,GAAuB,EAAE,aAAkB,EAA2B,EAAE;IAC1G,MAAM,OAAO,GAAG,WAAW,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;IACrC,IAAI,OAAO,EAAE;QACX,MAAM,UAAU,GAAO,MAAM,OAAO,CAAC,aAAa,CAAC,CAAC;QACpD,IAAI,UAAU;eACP,UAAU,CAAC,IAAI,IAAI,GAAG,CAAC,YAAY,CAAC,QAAQ,CAAC,UAAU,CAAC,IAAI,CAAC,UAAU,CAAC,EAAE;YAC/E,OAAO,UAAU,CAAC,IAAsB,CAAC;SAC1C;QACD;;;;;;;;;;;;;;;;;;;;;;;;;UAyBE;KACH;IACD,OAAO,CAAC,GAAG,CAAC,4BAA4B,EAAE,GAAG,CAAC,IAAI,CAAC,CAAC;IACpD,MAAM,IAAI,KAAK,CAAC,mDAAmD,CAAC,CAAC;AACvE,CAAC,CAAA;AAED,MAAM,CAAC,MAAM,YAAY,GAAG,KAAK,EAAE,GAAuB,EAAE,aAAkB,EAA2B,EAAE,CACzG,oBAAoB,CAAC,GAAG,EAAE,aAAa,CAAC,CAAC","sourcesContent":["import { FirebaseApp } from \"firebase/app\";\nimport { getFunctions, HttpsCallable, httpsCallable } from \"firebase/functions\";\nimport { FunctionDefinition, FunctionResult, FunctionsConfig } from \"../service-provider-model.js\";\n\nconst functionMap = new Map<FunctionDefinition, HttpsCallable>;\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\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 internalCallFunction(def, functionInput); \n \n"]}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
export declare const logoutMock: () => Promise<boolean>;
|
|
2
2
|
export declare const isAuthenticatedMock: () => boolean;
|
|
3
|
-
export declare const authStateChangedMock: (
|
|
3
|
+
export declare const authStateChangedMock: () => void;
|
|
4
4
|
export declare const loginMock: (user: string, sec: string) => Promise<unknown>;
|
|
@@ -27,7 +27,7 @@ export const isAuthenticatedMock = () => {
|
|
|
27
27
|
}
|
|
28
28
|
return loginAvailable;
|
|
29
29
|
};
|
|
30
|
-
export const authStateChangedMock = (
|
|
30
|
+
export const authStateChangedMock = () => {
|
|
31
31
|
console.log("Not implemented for MOCK");
|
|
32
32
|
};
|
|
33
33
|
export const loginMock = async (user, sec) => {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"auth.js","sourceRoot":"","sources":["../../../../src/service-provider/mock/auth.ts"],"names":[],"mappings":"AACA;;;;GAIG;AACH,MAAM,gBAAgB,GAAG,IAAI,CAAC;AAC9B,MAAM,mBAAmB,GAAG,aAAa,CAAC;AAC1C,MAAM,cAAc,GAAG,wBAAwB,CAAC;AAChD,MAAM,aAAa,GAAG,MAAM,CAAC;AAI7B,IAAI,cAAmC,CAAC;AA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;IACxC,MAAM,KAAK,GAAQ,GAAG,CAAC;IACvB,KAAK,CAAC,IAAI,GAAG,qBAAqB,CAAC;IACnC,MAAM,KAAK,CAAC;AACd,CAAC,CAAA","sourcesContent":["\n/*\n * Only for temporary development:\n * Set to true/false if the user should hold only in session (login after each reload)\n * or in the localstore (login until the local store entry is invalid or not available).\n */\nconst LOCALSTORE_ACTIV = true;\nconst LOCALSTORE_ITEM_KEY = 'pdUserLogin';\nconst HARDCODED_USER = 'mock@pd-spa-helper.com';\nconst HARDCODED_PWD = 'mock';\n\n\n\nlet loginAvailable: boolean | undefined;\n\n\nconst checkLocalStore = () => {\n const userItem = localStorage.getItem(LOCALSTORE_ITEM_KEY);\n return userItem === 'true';\n}\n\n\nexport const logoutMock = async (): Promise<boolean> => {\n console.log(\"Do MOCK logout\");\n loginAvailable = undefined;\n if (LOCALSTORE_ACTIV) {\n localStorage.removeItem(LOCALSTORE_ITEM_KEY);\n }\n return Promise.resolve(true);\n};\n\nexport const isAuthenticatedMock = (): boolean => {\n if (loginAvailable === undefined) {\n console.log('MOCK: check authentication');\n loginAvailable = LOCALSTORE_ACTIV ? checkLocalStore() : false;\n }\n return loginAvailable;\n} \n\n\nexport const authStateChangedMock = () => {\n console.log(\"Not implemented for MOCK\");\n}\n\nexport const loginMock = async (user:string, sec:string): Promise<unknown> => { \n\n console.log('MOCK: do authentication for user: ', user);\n let valid = false;\n if (user === HARDCODED_USER && sec === HARDCODED_PWD) {\n if (LOCALSTORE_ACTIV) {\n localStorage.setItem(LOCALSTORE_ITEM_KEY, 'true');\n }\n valid = true;\n loginAvailable = true;\n }\n\n if (valid) {\n return Promise.resolve({\n uid: \"123124\"\n }); \n }\n\n const err = new Error(\"Invalid login\");\n const error: any = err;\n error.code = \"auth/wrong-password\";\n throw error;\n}\n\n\n\n\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"function-client.js","sourceRoot":"","sources":["../../../../src/service-provider/mock/function-client.ts"],"names":[],"mappings":"AAEA,MAAM,CAAC,MAAM,gBAAgB,GAAG,CAAC,GAAuB,EAAE,aAAkB,EAA2B,EAAE;IACvG,OAAO,CAAC,GAAG,CAAC,oBAAoB,EAAE,GAAG,EAAE,aAAa,CAAC,CAAC;IACtD,OAAO,OAAO,CAAC,OAAO,CACpB,GAAG,CAAC,UAAU,IAAI;QAChB,UAAU,EAAE,GAAG;QACf,UAAU,EAAE,SAAS;KACtB,CACF,CAAC;AACJ,CAAC,CAAA","sourcesContent":["import { FunctionDefinition, FunctionResult } from \"../service-provider-model.js\";\n\nexport const callFunctionMock = (def: FunctionDefinition, functionInput: any): Promise<FunctionResult> => {\n console.log(\"Mock function call\", def, functionInput);\n return Promise.resolve(\n def.mockResult || {\n statusCode: 404,\n resultData: undefined\n }\n );\n}"]}
|
|
@@ -1,5 +1,9 @@
|
|
|
1
|
-
import { ServiceProviderConfiguration } from "
|
|
1
|
+
import { AppConfiguration, FunctionDefinition, FunctionResult, ServiceProviderConfiguration } from "./service-provider-model.js";
|
|
2
|
+
import { ServiceCallController } from "../service-call-controller2.js";
|
|
2
3
|
export declare const setServiceProvider: (providerParam?: ServiceProviderConfiguration) => void;
|
|
4
|
+
export declare const initController: (controllerParam: ServiceCallController) => void;
|
|
5
|
+
export declare const initAppImpl: (config: AppConfiguration) => void;
|
|
6
|
+
export declare const callFunctionImpl: (def: FunctionDefinition, functionInput: any) => Promise<FunctionResult>;
|
|
3
7
|
export declare const authStateChangedImpl: (callback: Function) => void;
|
|
4
8
|
export declare const isAuthenticatedImpl: () => boolean;
|
|
5
9
|
export declare const loginImpl: (user: string, sec: string) => Promise<unknown>;
|
|
@@ -1,18 +1,73 @@
|
|
|
1
|
+
import { initializeApp } from "firebase/app";
|
|
1
2
|
import { authStateChanged, isAuthenticated, login, logout } from "./firebase/auth.js";
|
|
2
3
|
import { authStateChangedMock, isAuthenticatedMock, loginMock, logoutMock } from "./mock/auth.js";
|
|
4
|
+
import { callFunction, initFunctions } from "./firebase/functions-client.js";
|
|
5
|
+
import { initFirestore } from "./firebase/firestore-client.js";
|
|
6
|
+
import { callFunctionMock } from "./mock/function-client.js";
|
|
3
7
|
let provider;
|
|
8
|
+
let controller;
|
|
4
9
|
const throwUndefinedProviderError = () => {
|
|
5
10
|
throw new Error("Undefined service provider, please check configuration. 'firebase' or 'mock' allowed here.");
|
|
6
11
|
};
|
|
12
|
+
/* #####################
|
|
13
|
+
* Init Implementation
|
|
14
|
+
* ##################### */
|
|
7
15
|
export const setServiceProvider = (providerParam) => {
|
|
8
16
|
provider = providerParam;
|
|
9
17
|
};
|
|
18
|
+
export const initController = (controllerParam) => {
|
|
19
|
+
controller = controllerParam;
|
|
20
|
+
};
|
|
21
|
+
const initFirebaseApplicationServices = (firebaseApp, functionsConfig) => {
|
|
22
|
+
// do something with the app, init db, firestore and functions
|
|
23
|
+
initFunctions(firebaseApp, functionsConfig);
|
|
24
|
+
initFirestore(firebaseApp);
|
|
25
|
+
};
|
|
26
|
+
export const initAppImpl = (config) => {
|
|
27
|
+
if (provider === "firebase" && config.firebaseConfig) {
|
|
28
|
+
const app = initializeApp(config.firebaseConfig);
|
|
29
|
+
if (config.functionsConfig) {
|
|
30
|
+
// init application services (functions, store)
|
|
31
|
+
initFirebaseApplicationServices(app, config.functionsConfig);
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
else if (provider === "mock") {
|
|
35
|
+
// no init needed
|
|
36
|
+
}
|
|
37
|
+
else {
|
|
38
|
+
throwUndefinedProviderError();
|
|
39
|
+
}
|
|
40
|
+
};
|
|
41
|
+
/* #####################
|
|
42
|
+
* Functions Implementation
|
|
43
|
+
* ##################### */
|
|
44
|
+
export const callFunctionImpl = async (def, functionInput) => {
|
|
45
|
+
const callController = (promise) => {
|
|
46
|
+
if (controller) {
|
|
47
|
+
controller.callDataPromise = { func: def, promise };
|
|
48
|
+
}
|
|
49
|
+
};
|
|
50
|
+
if (provider === "firebase") {
|
|
51
|
+
const promise = callFunction(def, functionInput);
|
|
52
|
+
callController(promise);
|
|
53
|
+
return promise;
|
|
54
|
+
}
|
|
55
|
+
if (provider === "mock") {
|
|
56
|
+
const promise = callFunctionMock(def, functionInput);
|
|
57
|
+
callController(promise);
|
|
58
|
+
return promise;
|
|
59
|
+
}
|
|
60
|
+
return throwUndefinedProviderError();
|
|
61
|
+
};
|
|
62
|
+
/* #####################
|
|
63
|
+
* Auth Implementation
|
|
64
|
+
* ##################### */
|
|
10
65
|
export const authStateChangedImpl = (callback) => {
|
|
11
66
|
if (provider === "firebase") {
|
|
12
67
|
authStateChanged(callback);
|
|
13
68
|
}
|
|
14
69
|
else if (provider === "mock") {
|
|
15
|
-
authStateChangedMock(
|
|
70
|
+
authStateChangedMock();
|
|
16
71
|
}
|
|
17
72
|
else {
|
|
18
73
|
throwUndefinedProviderError();
|