@monkeyplus/flow 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/_types/index.d.ts +120 -0
- package/dist/_types/index.d.ts.map +1 -0
- package/dist/_types/index.js +3 -0
- package/dist/_types/index.js.map +1 -0
- package/dist/config.d.ts +15 -0
- package/dist/config.d.ts.map +1 -0
- package/dist/config.js +12 -0
- package/dist/config.js.map +1 -0
- package/dist/helpers/index.d.ts +15 -0
- package/dist/helpers/index.d.ts.map +1 -0
- package/dist/helpers/index.js +91 -0
- package/dist/helpers/index.js.map +1 -0
- package/dist/index.d.ts +27 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +248 -0
- package/dist/index.js.map +1 -0
- package/dist/lib/index.d.ts +4 -0
- package/dist/lib/index.d.ts.map +1 -0
- package/dist/lib/index.js +15 -0
- package/dist/lib/index.js.map +1 -0
- package/dist/lib/pages/index copy.d.ts +6 -0
- package/dist/lib/pages/index copy.d.ts.map +1 -0
- package/dist/lib/pages/index copy.js +108 -0
- package/dist/lib/pages/index copy.js.map +1 -0
- package/dist/lib/pages/index.d.ts +3 -0
- package/dist/lib/pages/index.d.ts.map +1 -0
- package/dist/lib/pages/index.js +107 -0
- package/dist/lib/pages/index.js.map +1 -0
- package/dist/lib/pages/pre.d.ts +9 -0
- package/dist/lib/pages/pre.d.ts.map +1 -0
- package/dist/lib/pages/pre.js +97 -0
- package/dist/lib/pages/pre.js.map +1 -0
- package/dist/lib/utils/index.d.ts +3 -0
- package/dist/lib/utils/index.d.ts.map +1 -0
- package/dist/lib/utils/index.js +48 -0
- package/dist/lib/utils/index.js.map +1 -0
- package/dist/routes/index.d.ts +4 -0
- package/dist/routes/index.d.ts.map +1 -0
- package/dist/routes/index.js +89 -0
- package/dist/routes/index.js.map +1 -0
- package/dist/routes/sitemap.d.ts +3 -0
- package/dist/routes/sitemap.d.ts.map +1 -0
- package/dist/routes/sitemap.js +137 -0
- package/dist/routes/sitemap.js.map +1 -0
- package/dist/utils/index.d.ts +4 -0
- package/dist/utils/index.d.ts.map +1 -0
- package/dist/utils/index.js +20 -0
- package/dist/utils/index.js.map +1 -0
- package/package.json +26 -0
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
import { PageInfo, OptionsPage, OptionsLocalPage, CtxBuildLocal, CtxBuildGlobal, RunContext, DictionaryImagesSeo, ExtraOptions, BlogInfo, LocalesUrl } from '@monkeyplus/flow-core';
|
|
2
|
+
import { Dictionary } from 'ramda';
|
|
3
|
+
import { Lifecycle, RouteOptions, Server, ServerRoute } from '@hapi/hapi';
|
|
4
|
+
export interface AppObject {
|
|
5
|
+
images: DictionaryImagesSeo;
|
|
6
|
+
domain: string;
|
|
7
|
+
locale: string;
|
|
8
|
+
locales: string[];
|
|
9
|
+
pages: Map<string, PageInfo>;
|
|
10
|
+
localePages: Dictionary<any>;
|
|
11
|
+
prevRoutes: Map<string, ResultPage>;
|
|
12
|
+
}
|
|
13
|
+
export interface OptionsHapiLocalPage extends OptionsLocalPage {
|
|
14
|
+
url: string;
|
|
15
|
+
blogInfo?: BlogInfo;
|
|
16
|
+
routeOptions?: RouteOptions;
|
|
17
|
+
rules?: Record<string, unknown>;
|
|
18
|
+
context?: RunContextHapi;
|
|
19
|
+
vhost?: string | string[];
|
|
20
|
+
}
|
|
21
|
+
export interface CtxHapiBuildLocal extends CtxBuildLocal {
|
|
22
|
+
server: Server;
|
|
23
|
+
isStatic?: boolean;
|
|
24
|
+
shared: any;
|
|
25
|
+
sharedLocale: any;
|
|
26
|
+
page: PageInfo;
|
|
27
|
+
}
|
|
28
|
+
export interface CtxHapiBuilGlobal extends CtxBuildGlobal {
|
|
29
|
+
server: Server;
|
|
30
|
+
isStatic?: boolean;
|
|
31
|
+
}
|
|
32
|
+
export declare type RunContextHapi<CTX = any> = RunContext<CtxHapiBuildLocal, CTX>;
|
|
33
|
+
export interface OptionsHapiPage extends OptionsPage {
|
|
34
|
+
routeOptions?: RouteOptions;
|
|
35
|
+
context: RunContextHapi;
|
|
36
|
+
locales: Dictionary<OptionsHapiLocalPage>;
|
|
37
|
+
rules?: Record<string, unknown>;
|
|
38
|
+
vhost?: string | string[];
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
*
|
|
42
|
+
*/
|
|
43
|
+
interface DefaultLocale {
|
|
44
|
+
language: string;
|
|
45
|
+
ubication: string;
|
|
46
|
+
publicPath?: string;
|
|
47
|
+
}
|
|
48
|
+
export interface ResultPage {
|
|
49
|
+
name: string;
|
|
50
|
+
routes: (ctx: CtxHapiBuildLocal, handler: Lifecycle.Method) => Promise<ServerRoute[]>;
|
|
51
|
+
pages: PageInfo[];
|
|
52
|
+
}
|
|
53
|
+
export declare type RunDefinePage = (server: Server, defs: DefaultLocale, locales: string[], runGlobal?: RunDefineGlobalContext) => Promise<ResultPage>;
|
|
54
|
+
export declare type PreRunDefinePage<T = RunDefinePage> = (extOpts?: ExtraOptions, prefixName?: string) => T;
|
|
55
|
+
export declare type DefinePage = (options: OptionsHapiPage) => PreRunDefinePage;
|
|
56
|
+
export interface ResultPage2 {
|
|
57
|
+
name: string;
|
|
58
|
+
options: OptionsHapiPage;
|
|
59
|
+
pages: PageInfo[];
|
|
60
|
+
}
|
|
61
|
+
export declare type RunDefinePage2 = (server: Server, defs: DefaultLocale, locales: string[]) => Promise<ResultPage2>;
|
|
62
|
+
export declare type DefinePage2 = (options: OptionsHapiPage) => PreRunDefinePage<RunDefinePage2>;
|
|
63
|
+
/**
|
|
64
|
+
*
|
|
65
|
+
*/
|
|
66
|
+
export interface OptionsInfo {
|
|
67
|
+
locale: string;
|
|
68
|
+
name: string;
|
|
69
|
+
path: string;
|
|
70
|
+
view?: {
|
|
71
|
+
template: string;
|
|
72
|
+
bundle?: string;
|
|
73
|
+
};
|
|
74
|
+
}
|
|
75
|
+
export interface Flow {
|
|
76
|
+
init: () => Promise<void>;
|
|
77
|
+
addPage: (page: RunDefinePage | OptionsHapiPage) => Promise<void>;
|
|
78
|
+
defineInfoPage: (options: OptionsInfo) => Promise<{
|
|
79
|
+
path: string;
|
|
80
|
+
flow: PageInfo;
|
|
81
|
+
}>;
|
|
82
|
+
}
|
|
83
|
+
export declare type GetUrl = (server: Server, options: R.Dictionary<OptionsHapiLocalPage>, def: string) => (locale: string) => Promise<LocalesUrl>;
|
|
84
|
+
export declare type UrlPromise = (locale: string, name: string) => Promise<{
|
|
85
|
+
url: string;
|
|
86
|
+
seo: any;
|
|
87
|
+
[key: string]: any;
|
|
88
|
+
}>;
|
|
89
|
+
/**
|
|
90
|
+
*
|
|
91
|
+
*/
|
|
92
|
+
export declare type RunDefineGlobalContext = (ctx: CtxHapiBuildLocal) => Promise<any>;
|
|
93
|
+
export declare type DefineGlobalContext = (options: {
|
|
94
|
+
shared: RunContextHapi;
|
|
95
|
+
locales?: Dictionary<RunContextHapi>;
|
|
96
|
+
}) => RunDefineGlobalContext;
|
|
97
|
+
export interface FlowConfigs {
|
|
98
|
+
relativeTo: string;
|
|
99
|
+
locales: string[];
|
|
100
|
+
defaultUbication: string;
|
|
101
|
+
defaultLanguage: string;
|
|
102
|
+
domain: string;
|
|
103
|
+
publicPath: string;
|
|
104
|
+
sourceImagesDir: string;
|
|
105
|
+
dictionaryImages: string;
|
|
106
|
+
assetsDir: string;
|
|
107
|
+
assetsImagesDir: string;
|
|
108
|
+
sourceRename: string;
|
|
109
|
+
images: {
|
|
110
|
+
sources: string;
|
|
111
|
+
dirJsons: string;
|
|
112
|
+
};
|
|
113
|
+
server: {
|
|
114
|
+
watch: number;
|
|
115
|
+
dev: number;
|
|
116
|
+
};
|
|
117
|
+
vue: Record<string, string>;
|
|
118
|
+
}
|
|
119
|
+
export {};
|
|
120
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/_types/index.ts"],"names":[],"mappings":"AACA,OAAO,EACL,QAAQ,EACR,WAAW,EACX,gBAA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C,GAAG,CAAC,CAAC;AAC9E,oBAAY,mBAAmB,GAAG,CAAC,OAAO,EAAE;IAC1C,MAAM,EAAE,cAAc,CAAC;IACvB,OAAO,CAAC,EAAE,UAAU,CAAC,cAAc,CAAC,CAAC;CACtC,KAAK,sBAAsB,CAAC;AAE7B,MAAM,WAAW,WAAW;IAC1B,UAAU,EAAE,MAAM,CAAC;IACnB,OAAO,EAAE,MAAM,EAAE,CAAC;IAClB,gBAAgB,EAAE,MAAM,CAAC;IACzB,eAAe,EAAE,MAAM,CAAC;IACxB,MAAM,EAAE,MAAM,CAAC;IACf,UAAU,EAAE,MAAM,CAAC;IACnB,eAAe,EAAE,MAAM,CAAC;IACxB,gBAAgB,EAAE,MAAM,CAAC;IACzB,SAAS,EAAE,MAAM,CAAC;IAClB,eAAe,EAAE,MAAM,CAAC;IACxB,YAAY,EAAE,MAAM,CAAC;IACrB,MAAM,EAAE;QACN,OAAO,EAAE,MAAM,CAAC;QAChB,QAAQ,EAAE,MAAM,CAAC;KAClB,CAAC;IACF,MAAM,EAAE;QACN,KAAK,EAAE,MAAM,CAAC;QACd,GAAG,EAAE,MAAM,CAAC;KACb,CAAC;IACF,GAAG,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;CAE7B"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/_types/index.ts"],"names":[],"mappings":""}
|
package/dist/config.d.ts
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/**
|
|
2
|
+
*
|
|
3
|
+
* GLOBAL VARS
|
|
4
|
+
*/
|
|
5
|
+
export declare const FULL_NAME_PLUGIN = "@monkeyplus/flow";
|
|
6
|
+
import { RouteOptions } from '@hapi/hapi';
|
|
7
|
+
import { RunDefineGlobalContext } from './_types';
|
|
8
|
+
export declare const DEPENDENCIES: {};
|
|
9
|
+
export interface PluginOptions {
|
|
10
|
+
relativeTo: string;
|
|
11
|
+
globals?: RunDefineGlobalContext;
|
|
12
|
+
routeOptions?: RouteOptions;
|
|
13
|
+
dirTemplates?: string;
|
|
14
|
+
}
|
|
15
|
+
//# sourceMappingURL=config.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,eAAO,MAAM,gBAAgB,qBAAqB,CAAC;AACnD,OAAO,EAAE,YAAY,EAAU,MAAM,YAAY,CAAC;AAClD,OAAO,EAAE,sBAAsB,EAAE,MAAM,UAAU,CAAC;AAElD,eAAO,MAAM,YAAY,IAExB,CAAC;AAKF,MAAM,WAAW,aAAa;IAC5B,UAAU,EAAE,MAAM,CAAC;IACnB,OAAO,CAAC,EAAE,sBAAsB,CAAC;IACjC,YAAY,CAAC,EAAE,YAAY,CAAC;IAC5B,YAAY,CAAC,EAAE,MAAM,CAAC;CACvB"}
|
package/dist/config.js
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.DEPENDENCIES = exports.FULL_NAME_PLUGIN = void 0;
|
|
4
|
+
/**
|
|
5
|
+
*
|
|
6
|
+
* GLOBAL VARS
|
|
7
|
+
*/
|
|
8
|
+
exports.FULL_NAME_PLUGIN = `@monkeyplus/flow`;
|
|
9
|
+
exports.DEPENDENCIES = {
|
|
10
|
+
// '@hapi/vision': '6.x.x',
|
|
11
|
+
};
|
|
12
|
+
//# sourceMappingURL=config.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"config.js","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":";;;AAAA;;;GAGG;AACU,QAAA,gBAAgB,GAAG,kBAAkB,CAAC;AAItC,QAAA,YAAY,GAAG;AAC1B,2BAA2B;CAC5B,CAAC"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { CtxHapiBuildLocal } from '../_types/index';
|
|
2
|
+
import { PageInfo, ImageSeo } from '@monkeyplus/flow-core';
|
|
3
|
+
export declare const useHelpers: ({ pages, isStatic, server, name, locale, images, }: CtxHapiBuildLocal) => {
|
|
4
|
+
getPage: (_locale: string, name: string) => {
|
|
5
|
+
link: string;
|
|
6
|
+
page: PageInfo | undefined;
|
|
7
|
+
};
|
|
8
|
+
getLocalePage: (name: string) => {
|
|
9
|
+
link: string;
|
|
10
|
+
page: PageInfo | undefined;
|
|
11
|
+
};
|
|
12
|
+
getContextPage: (page: PageInfo | undefined) => Promise<any> | object;
|
|
13
|
+
getImage: (name: string) => ImageSeo;
|
|
14
|
+
};
|
|
15
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/helpers/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,iBAAiB,CAAC;AACpD,OAAO,EAAE,QAAQ,EAAE,QAAQ,EAAE,MAAM,uBAAuB,CAAC;AAI3D,eAAO,MAAM,UAAU,uDAOpB,iBAAiB;uBAEP,MAAM,QACT,MAAM;cAEN,MAAM;cACN,QAAQ,GAAG,SAAS;;0BAeC,MAAM;cAhB3B,MAAM;cACN,QAAQ,GAAG,SAAS;;2BAiBpB,QAAQ,GAAG,SAAS,KACzB,QAAQ,GAAG,CAAC,GAAG,MAAM;qBA6BA,MAAM,KAAG,QAAQ;CAmB1C,CAAC"}
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
|
|
5
|
+
}) : (function(o, m, k, k2) {
|
|
6
|
+
if (k2 === undefined) k2 = k;
|
|
7
|
+
o[k2] = m[k];
|
|
8
|
+
}));
|
|
9
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
10
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
11
|
+
}) : function(o, v) {
|
|
12
|
+
o["default"] = v;
|
|
13
|
+
});
|
|
14
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
15
|
+
if (mod && mod.__esModule) return mod;
|
|
16
|
+
var result = {};
|
|
17
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
18
|
+
__setModuleDefault(result, mod);
|
|
19
|
+
return result;
|
|
20
|
+
};
|
|
21
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
22
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
23
|
+
};
|
|
24
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
25
|
+
exports.useHelpers = void 0;
|
|
26
|
+
const R = __importStar(require("ramda"));
|
|
27
|
+
const path_1 = __importDefault(require("path"));
|
|
28
|
+
// interface PageLink
|
|
29
|
+
exports.useHelpers = ({ pages, isStatic, server, name, locale, images, }) => {
|
|
30
|
+
const getPage = (_locale, name) => {
|
|
31
|
+
const page = pages.get(path_1.default.posix.join(_locale, name));
|
|
32
|
+
if (!page) {
|
|
33
|
+
server.log(['warn', name], {
|
|
34
|
+
error: 'Error in getPage',
|
|
35
|
+
message: `${name} not found`,
|
|
36
|
+
});
|
|
37
|
+
return { link: isStatic ? '/404.html' : '/404', page };
|
|
38
|
+
}
|
|
39
|
+
return {
|
|
40
|
+
link: isStatic ? page.urlObject.static : page.urlObject.path,
|
|
41
|
+
page,
|
|
42
|
+
};
|
|
43
|
+
};
|
|
44
|
+
const getLocalePage = (name) => getPage(locale, name);
|
|
45
|
+
const getContextPage = (page) => {
|
|
46
|
+
return new Promise((res) => {
|
|
47
|
+
if (!page) {
|
|
48
|
+
server.log(['warn', name], {
|
|
49
|
+
error: 'Error in read context page',
|
|
50
|
+
message: `Param page is undefined`,
|
|
51
|
+
});
|
|
52
|
+
return res({});
|
|
53
|
+
}
|
|
54
|
+
const pathInject = page.urlObject.path + '/_context';
|
|
55
|
+
server
|
|
56
|
+
.inject(pathInject)
|
|
57
|
+
.then((r) => {
|
|
58
|
+
const local = R.path(['result', 'local'], r) || {};
|
|
59
|
+
res(Object.assign(Object.assign({}, local), { _seo: R.path(['result', 'globals', 'SEO'], r) }));
|
|
60
|
+
})
|
|
61
|
+
.catch((details) => {
|
|
62
|
+
server.log(['error', name], {
|
|
63
|
+
error: 'Error in read context page',
|
|
64
|
+
message: `Error in injector to ${pathInject}`,
|
|
65
|
+
details,
|
|
66
|
+
});
|
|
67
|
+
res({});
|
|
68
|
+
});
|
|
69
|
+
});
|
|
70
|
+
};
|
|
71
|
+
const getImage = (name) => {
|
|
72
|
+
if (images[name]) {
|
|
73
|
+
return images[name];
|
|
74
|
+
}
|
|
75
|
+
else {
|
|
76
|
+
return {
|
|
77
|
+
src: '/assets/static/no-image.jpg',
|
|
78
|
+
alt: '',
|
|
79
|
+
title: '',
|
|
80
|
+
name: '',
|
|
81
|
+
};
|
|
82
|
+
}
|
|
83
|
+
};
|
|
84
|
+
return {
|
|
85
|
+
getPage,
|
|
86
|
+
getLocalePage,
|
|
87
|
+
getContextPage,
|
|
88
|
+
getImage,
|
|
89
|
+
};
|
|
90
|
+
};
|
|
91
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/helpers/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AAEA,yCAA2B;AAC3B,gDAAwB;AACxB,qBAAqB;AACR,QAAA,UAAU,GAAG,CAAC,EACzB,KAAK,EACL,QAAQ,EACR,MAAM,EACN,IAAI,EACJ,MAAM,EACN,MAAM,GACY,EAAE,EAAE;IACtB,MAAM,OAAO,GAAG,CACd,OAAe,EACf,IAAY,EAIZ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E,OAAO,CAAC,EAAE,CAAC,CAAC,IAAI,EAAE,CAAC;gBACxD,GAAG,iCACE,KAAK,KACR,IAAI,EAAE,CAAC,CAAC,IAAI,CAAC,CAAC,QAAQ,EAAE,SAAS,EAAE,KAAK,CAAC,EAAE,CAAC,CAAC,IAC7C,CAAC;YACL,CAAC,CAAC;iBACD,KAAK,CAAC,CAAC,OAAO,EAAE,EAAE;gBACjB,MAAM,CAAC,GAAG,CAAC,CAAC,OAAO,EAAE,IAAI,CAAC,EAAE;oBAC1B,KAAK,EAAE,4BAA4B;oBACnC,OAAO,EAAE,wBAAwB,UAAU,EAAE;oBAC7C,OAAO;iBACR,CAAC,CAAC;gBACH,GAAG,CAAC,EAAE,CAAC,CAAC;YACV,CAAC,CAAC,CAAC;QACP,CAAC,CAAC,CAAC;IACL,CAAC,CAAC;IACF,MAAM,QAAQ,GAAG,CAAC,IAAY,EAAY,EAAE;QAC1C,IAAI,MAAM,CAAC,IAAI,CAAC,EAAE;YAChB,OAAO,MAAM,CAAC,IAAI,CAAC,CAAC;SACrB;aAAM;YACL,OAAO;gBACL,GAAG,EAAE,6BAA6B;gBAClC,GAAG,EAAE,EAAE;gBACP,KAAK,EAAE,EAAE;gBACT,IAAI,EAAE,EAAE;aACT,CAAC;SACH;IACH,CAAC,CAAC;IAEF,OAAO;QACL,OAAO;QACP,aAAa;QACb,cAAc;QACd,QAAQ;KACT,CAAC;AACJ,CAAC,CAAC"}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { Plugin } from '@hapi/hapi';
|
|
2
|
+
import { PluginOptions } from './config';
|
|
3
|
+
import { AppObject, Flow, FlowConfigs } from './_types/index';
|
|
4
|
+
export { PluginOptions } from './config';
|
|
5
|
+
import { PageInfo } from '@monkeyplus/flow-core';
|
|
6
|
+
export { definePage, defineSharedContext } from './lib';
|
|
7
|
+
export { defineImages, PageInfo } from '@monkeyplus/flow-core';
|
|
8
|
+
export { AppObject, DefinePage, ResultPage, RunDefinePage, Flow, PreRunDefinePage, UrlPromise, RunContextHapi, CtxHapiBuildLocal, FlowConfigs, } from './_types/index';
|
|
9
|
+
export declare const plugin: Plugin<PluginOptions>;
|
|
10
|
+
declare module '@hapi/hapi' {
|
|
11
|
+
interface ServerApplicationState {
|
|
12
|
+
flow: AppObject;
|
|
13
|
+
}
|
|
14
|
+
interface RouteOptionsApp {
|
|
15
|
+
flow: PageInfo;
|
|
16
|
+
}
|
|
17
|
+
interface Server {
|
|
18
|
+
flow: Flow;
|
|
19
|
+
}
|
|
20
|
+
interface PluginProperties {
|
|
21
|
+
flow: {
|
|
22
|
+
configs: FlowConfigs;
|
|
23
|
+
getPath: (...paths: string[]) => string;
|
|
24
|
+
};
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAa,MAAM,EAAe,MAAM,YAAY,CAAC;AAC5D,OAAO,EAAkC,aAAa,EAAE,MAAM,UAAU,CAAC;AACzE,OAAO,EACL,SAAS,EAET,IAAI,EACJ,WAAW,EAGZ,MAAM,gBAAgB,CAAC;AACxB,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AACzC,OAAO,EAAE,QAAQ,EAAE,MAAM,uBAAuB,CAAC;AAEjD,OAAO,EAAE,UAAU,EAAE,mBAAmB,EAAE,MAAM,OAAO,CAAC;AAExD,OAAO,EAAE,YAAY,EAAE,QAAQ,EAAE,MAAM,uBAAuB,CAAC;AAG/D,OAAO,EACL,SAAS,EACT,UAAU,EACV,UAAU,EACV,aAAa,EACb,IAAI,EACJ,gBAAgB,EAChB,UAAU,EACV,cAAc,EACd,iBAAiB,EACjB,WAAW,GACZ,MAAM,gBAAgB,CAAC;AAExB,eAAO,MAAM,MAAM,EAAE,MAAM,CAAC,aAAa,CA0OxC,CAAC;AAEF,OAAO,QAAQ,YAAY,CAAC;IAC1B,UAAU,sBAAsB;QAC9B,IAAI,EAAE,SAAS,CAAC;KACjB;IACD,UAAU,eAAe;QACvB,IAAI,EAAE,QAAQ,CAAC;KAChB;IAID,UAAU,MAAM;QACd,IAAI,EAAE,IAAI,CAAC;KACZ;IACD,UAAU,gBAAgB;QACxB,IAAI,EAAE;YACJ,OAAO,EAAE,WAAW,CAAC;YACrB,OAAO,EAAE,CAAC,GAAG,KAAK,EAAE,MAAM,EAAE,KAAK,MAAM,CAAC;SACzC,CAAC;KACH;CACF"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,248 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
|
|
5
|
+
}) : (function(o, m, k, k2) {
|
|
6
|
+
if (k2 === undefined) k2 = k;
|
|
7
|
+
o[k2] = m[k];
|
|
8
|
+
}));
|
|
9
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
10
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
11
|
+
}) : function(o, v) {
|
|
12
|
+
o["default"] = v;
|
|
13
|
+
});
|
|
14
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
15
|
+
if (mod && mod.__esModule) return mod;
|
|
16
|
+
var result = {};
|
|
17
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
18
|
+
__setModuleDefault(result, mod);
|
|
19
|
+
return result;
|
|
20
|
+
};
|
|
21
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
22
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
23
|
+
};
|
|
24
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
25
|
+
exports.plugin = exports.defineImages = exports.defineSharedContext = exports.definePage = void 0;
|
|
26
|
+
const config_1 = require("./config");
|
|
27
|
+
const R = __importStar(require("ramda"));
|
|
28
|
+
var lib_1 = require("./lib");
|
|
29
|
+
Object.defineProperty(exports, "definePage", { enumerable: true, get: function () { return lib_1.definePage; } });
|
|
30
|
+
Object.defineProperty(exports, "defineSharedContext", { enumerable: true, get: function () { return lib_1.defineSharedContext; } });
|
|
31
|
+
const lib_2 = require("./lib");
|
|
32
|
+
var flow_core_1 = require("@monkeyplus/flow-core");
|
|
33
|
+
Object.defineProperty(exports, "defineImages", { enumerable: true, get: function () { return flow_core_1.defineImages; } });
|
|
34
|
+
const path_1 = __importDefault(require("path"));
|
|
35
|
+
const utils_1 = require("./utils");
|
|
36
|
+
exports.plugin = {
|
|
37
|
+
pkg: require('../package.json'),
|
|
38
|
+
name: config_1.FULL_NAME_PLUGIN,
|
|
39
|
+
dependencies: config_1.DEPENDENCIES,
|
|
40
|
+
register: async (server, options) => {
|
|
41
|
+
// // console.log('Images');
|
|
42
|
+
// if (options.truncate) {
|
|
43
|
+
// server.decorate('server', 'flow', {
|
|
44
|
+
// init: () => Promise.resolve(),
|
|
45
|
+
// addPage: () => Promise.resolve(),
|
|
46
|
+
// } as any);
|
|
47
|
+
// return Promise.resolve();
|
|
48
|
+
// }
|
|
49
|
+
const config = utils_1.getConfigs(server, options.relativeTo);
|
|
50
|
+
server.expose('configs', config);
|
|
51
|
+
server.expose('getPath', (...paths) => path_1.default.join(config.relativeTo, ...paths));
|
|
52
|
+
const locales = config.locales || ['es-ec'];
|
|
53
|
+
const LOCALE = `${config.defaultLanguage}-${config.defaultUbication}`;
|
|
54
|
+
server.app.flow = {
|
|
55
|
+
images: {},
|
|
56
|
+
locales,
|
|
57
|
+
prevRoutes: new Map(),
|
|
58
|
+
pages: new Map(),
|
|
59
|
+
localePages: {},
|
|
60
|
+
locale: LOCALE,
|
|
61
|
+
domain: config.domain || 'http://localhost',
|
|
62
|
+
};
|
|
63
|
+
// const pathAssets = options.pathAssets || 'assets';
|
|
64
|
+
// const pathImages = options.pathImages || 'images';
|
|
65
|
+
// const publicPath = options.publicPath || '/';
|
|
66
|
+
// // let images = {};
|
|
67
|
+
// // images = loadImages();
|
|
68
|
+
// const appObject: AppObject = {
|
|
69
|
+
// images: {},
|
|
70
|
+
// defaultUbication: options.defaultUbication || 'ec',
|
|
71
|
+
// defaultLanguage: options.defaultLanguage || 'es',
|
|
72
|
+
// publicPath,
|
|
73
|
+
// domain: options.domain || 'http://localhost',
|
|
74
|
+
// locales,
|
|
75
|
+
// locale: '',
|
|
76
|
+
// pages: new Map(),
|
|
77
|
+
// prevRoutes: new Map(),
|
|
78
|
+
// localePages: {},
|
|
79
|
+
// routes: {},
|
|
80
|
+
// globalData: {},
|
|
81
|
+
// pathAssets,
|
|
82
|
+
// pathImages,
|
|
83
|
+
// };
|
|
84
|
+
// loadImages();
|
|
85
|
+
// const LOCALE = `${appObject.defaultLanguage}-${appObject.defaultUbication}`;
|
|
86
|
+
// appObject.locale = LOCALE;
|
|
87
|
+
// R.mapObjIndexed((v, k) => {
|
|
88
|
+
// (server as any).app[k] = v;
|
|
89
|
+
// }, appObject);
|
|
90
|
+
/**
|
|
91
|
+
*
|
|
92
|
+
*/
|
|
93
|
+
const inserPage = (pages) => {
|
|
94
|
+
for (const page of pages) {
|
|
95
|
+
if (server.app.flow.pages.has(page.name)) {
|
|
96
|
+
server.log(['warn', config_1.FULL_NAME_PLUGIN], {
|
|
97
|
+
error: 'insertPage',
|
|
98
|
+
message: `Duplicate name page, "${page.name}" already exists`,
|
|
99
|
+
details: page,
|
|
100
|
+
});
|
|
101
|
+
}
|
|
102
|
+
else {
|
|
103
|
+
server.log(['debug', config_1.FULL_NAME_PLUGIN], {
|
|
104
|
+
method: 'isertPage',
|
|
105
|
+
message: `Insert page`,
|
|
106
|
+
info: {
|
|
107
|
+
url: page.urlObject.path,
|
|
108
|
+
name: page.name,
|
|
109
|
+
locale: page.locale,
|
|
110
|
+
level: page.level,
|
|
111
|
+
},
|
|
112
|
+
});
|
|
113
|
+
server.app.flow.pages.set(page.name, page);
|
|
114
|
+
server.app.flow.localePages = R.groupBy((f) => {
|
|
115
|
+
return f.locale;
|
|
116
|
+
}, Array.from(server.app.flow.pages.values()));
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
};
|
|
120
|
+
const addPage = async (_page) => {
|
|
121
|
+
try {
|
|
122
|
+
let page;
|
|
123
|
+
if (typeof _page === 'function') {
|
|
124
|
+
page = _page;
|
|
125
|
+
}
|
|
126
|
+
else {
|
|
127
|
+
page = lib_2.definePage(_page)();
|
|
128
|
+
}
|
|
129
|
+
const result = await page(server, {
|
|
130
|
+
language: config.defaultLanguage,
|
|
131
|
+
ubication: config.defaultUbication,
|
|
132
|
+
publicPath: config.publicPath,
|
|
133
|
+
}, locales, options.globals);
|
|
134
|
+
// server.log(['debug', FULL_NAME_PLUGIN], {
|
|
135
|
+
// method: 'addPage',
|
|
136
|
+
// message: `Insert *${result.name}*`,
|
|
137
|
+
// });
|
|
138
|
+
const hasPage = server.app.flow.prevRoutes.has(result.name);
|
|
139
|
+
if (hasPage) {
|
|
140
|
+
server.log(['warn', config_1.FULL_NAME_PLUGIN], {
|
|
141
|
+
error: 'addPage',
|
|
142
|
+
message: `The name of group pages '${result.name}' already exists`,
|
|
143
|
+
page: result,
|
|
144
|
+
});
|
|
145
|
+
}
|
|
146
|
+
else {
|
|
147
|
+
server.app.flow.prevRoutes.set(result.name, result);
|
|
148
|
+
inserPage(result.pages);
|
|
149
|
+
} // if(server.app.)
|
|
150
|
+
}
|
|
151
|
+
catch (details) {
|
|
152
|
+
server.log(['error', config_1.FULL_NAME_PLUGIN], {
|
|
153
|
+
error: 'addPage',
|
|
154
|
+
message: 'Error addPage',
|
|
155
|
+
details,
|
|
156
|
+
});
|
|
157
|
+
}
|
|
158
|
+
};
|
|
159
|
+
const registerRoutes = (routes) => {
|
|
160
|
+
for (const route of routes) {
|
|
161
|
+
const _routes = server.table();
|
|
162
|
+
const _route = _routes.find((v) => v.path === route.path);
|
|
163
|
+
if (_route) {
|
|
164
|
+
server.log(['warn'], {
|
|
165
|
+
error: 'registerRoutes',
|
|
166
|
+
message: `Duplicate route, the route already exists`,
|
|
167
|
+
info: {
|
|
168
|
+
path: route.path,
|
|
169
|
+
},
|
|
170
|
+
});
|
|
171
|
+
}
|
|
172
|
+
else {
|
|
173
|
+
if (route.path.includes('_context')) {
|
|
174
|
+
server.route(route);
|
|
175
|
+
}
|
|
176
|
+
else {
|
|
177
|
+
const r = Object.assign(Object.assign({}, route), { options: R.hasPath(['options'], route)
|
|
178
|
+
? R.mergeDeepLeft(route.options, options.routeOptions || {})
|
|
179
|
+
: undefined });
|
|
180
|
+
server.route(r);
|
|
181
|
+
}
|
|
182
|
+
}
|
|
183
|
+
}
|
|
184
|
+
};
|
|
185
|
+
/**
|
|
186
|
+
* Define info page to include in pages
|
|
187
|
+
*/
|
|
188
|
+
const defineInfoPage = async (_opts) => {
|
|
189
|
+
const info = await lib_2.definePage({
|
|
190
|
+
context: () => ({}),
|
|
191
|
+
name: _opts.name,
|
|
192
|
+
view: _opts.view ? _opts.view : { template: '' },
|
|
193
|
+
locales: {
|
|
194
|
+
[_opts.locale]: {
|
|
195
|
+
url: _opts.path,
|
|
196
|
+
},
|
|
197
|
+
},
|
|
198
|
+
})()(server, {
|
|
199
|
+
language: config.defaultLanguage,
|
|
200
|
+
ubication: config.defaultUbication,
|
|
201
|
+
publicPath: config.publicPath,
|
|
202
|
+
}, locales, options.globals);
|
|
203
|
+
const flow = info.pages[0];
|
|
204
|
+
return {
|
|
205
|
+
path: flow.urlObject.path,
|
|
206
|
+
flow,
|
|
207
|
+
};
|
|
208
|
+
};
|
|
209
|
+
const visioHandler = (req, h) => {
|
|
210
|
+
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
211
|
+
const { template } = req.route.settings.app.flow;
|
|
212
|
+
return h.view(options.dirTemplates || '' + template, Object.assign({}, req.pre.context));
|
|
213
|
+
};
|
|
214
|
+
const init = async () => {
|
|
215
|
+
const list = Array.from(server.app.flow.prevRoutes.values());
|
|
216
|
+
const prePages = server
|
|
217
|
+
.table()
|
|
218
|
+
.filter((p) => { var _a; return (_a = p.settings.app) === null || _a === void 0 ? void 0 : _a.flow; })
|
|
219
|
+
.map((p) => p.settings.app.flow);
|
|
220
|
+
inserPage(prePages);
|
|
221
|
+
for (const preRoute of list) {
|
|
222
|
+
const routes = await preRoute.routes({
|
|
223
|
+
images: server.app.flow.images,
|
|
224
|
+
globals: {},
|
|
225
|
+
locale: '',
|
|
226
|
+
name: '',
|
|
227
|
+
shared: '',
|
|
228
|
+
sharedLocale: '',
|
|
229
|
+
originName: '',
|
|
230
|
+
page: {},
|
|
231
|
+
defaultLocal: LOCALE,
|
|
232
|
+
pages: server.app.flow.pages,
|
|
233
|
+
server,
|
|
234
|
+
}, visioHandler);
|
|
235
|
+
registerRoutes(routes);
|
|
236
|
+
}
|
|
237
|
+
server.log(['info', config_1.FULL_NAME_PLUGIN], 'Init flow');
|
|
238
|
+
};
|
|
239
|
+
const flow = {
|
|
240
|
+
init,
|
|
241
|
+
addPage,
|
|
242
|
+
defineInfoPage,
|
|
243
|
+
};
|
|
244
|
+
server.decorate('server', 'flow', flow);
|
|
245
|
+
server.log(['debug', config_1.FULL_NAME_PLUGIN], { message: 'Registered plugin' });
|
|
246
|
+
},
|
|
247
|
+
};
|
|
248
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AAEA,qCAAyE;AAWzE,yCAA2B;AAC3B,6BAAwD;AAA/C,iGAAA,UAAU,OAAA;AAAE,0GAAA,mBAAmB,OAAA;AACxC,+BAAmC;AACnC,mDAA+D;AAAtD,yGAAA,YAAY,OAAA;AACrB,gDAAwB;A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EAAE,MAAM,WAAW,CAAC;AAChD,OAAO,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AAErC,eAAO,MAAM,mBAAmB,EAAE,mBAmBjC,CAAC"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.defineSharedContext = exports.definePage = void 0;
|
|
4
|
+
var pages_1 = require("./pages");
|
|
5
|
+
Object.defineProperty(exports, "definePage", { enumerable: true, get: function () { return pages_1.definePage; } });
|
|
6
|
+
exports.defineSharedContext = (options) => async (ctx) => {
|
|
7
|
+
const SHARED = await options.shared(Object.assign({}, ctx));
|
|
8
|
+
const locales = options.locales || {};
|
|
9
|
+
const obj = {};
|
|
10
|
+
for (const key in locales) {
|
|
11
|
+
obj[key.toUpperCase().replace('-', '_')] = await locales[key](Object.assign(Object.assign({}, ctx), { locale: key }));
|
|
12
|
+
}
|
|
13
|
+
return Object.assign(Object.assign({}, obj), { SHARED_LOCALE: obj[ctx.locale.toUpperCase().replace('-', '_')], $_: obj[ctx.locale.toUpperCase().replace('-', '_')], SHARED, $: SHARED });
|
|
14
|
+
};
|
|
15
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/lib/index.ts"],"names":[],"mappings":";;;AACA,iCAAqC;AAA5B,mGAAA,UAAU,OAAA;AAEN,QAAA,mBAAmB,GAAwB,CAAC,OAAO,EAAE,EAAE,CAAC,KAAK,EACxE,GAAG,EACH,EAAE;IACF,MAAM,MAAM,GAAG,MAAM,OAAO,CAAC,MAAM,mBAAM,GAAG,EAAG,CAAC;IAChD,MAAM,OAAO,GAAG,OAAO,CAAC,OAAO,IAAI,EAAE,CAAC;IACtC,MAAM,GAAG,GAAQ,EAAE,CAAC;IACpB,KAAK,MAAM,GAAG,IAAI,OAAO,EAAE;QACzB,GAAG,CAAC,GAAG,CAAC,WAAW,EAAE,CAAC,OAAO,CAAC,GAAG,EAAE,GAAG,CAAC,CAAC,GAAG,MAAM,OAAO,CAAC,GAAG,CAAC,iCACxD,GAAG,KACN,MAAM,EAAE,GAAG,IACX,CAAC;KACJ;IACD,uCACK,GAAG,KACN,aAAa,EAAE,GAAG,CAAC,GAAG,CAAC,MAAM,CAAC,WAAW,EAAE,CAAC,OAAO,CAAC,GAAG,EAAE,GAAG,CAAC,CAAC,EAC9D,EAAE,EAAE,GAAG,CAAC,GAAG,CAAC,MAAM,CAAC,WAAW,EAAE,CAAC,OAAO,CAAC,GAAG,EAAE,GAAG,CAAC,CAAC,EACnD,MAAM,EACN,CAAC,EAAE,MAAM,IACT;AACJ,CAAC,CAAC"}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { PageInfo } from '@monkeyplus/flow-core';
|
|
2
|
+
import { DefinePage2, OptionsHapiPage, CtxHapiBuildLocal, RunDefineGlobalContext } from '../../_types/index';
|
|
3
|
+
import { ServerRoute } from '@hapi/hapi';
|
|
4
|
+
export declare const definePage: DefinePage2;
|
|
5
|
+
export declare const buildHapiRoutes: (options: OptionsHapiPage, pages: PageInfo[], ctx: CtxHapiBuildLocal, runGlobal: RunDefineGlobalContext) => Promise<ServerRoute[]>;
|
|
6
|
+
//# sourceMappingURL=index copy.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index copy.d.ts","sourceRoot":"","sources":["../../../src/lib/pages/index copy.ts"],"names":[],"mappings":"AACA,OAAO,EAAe,QAAQ,EAAE,MAAM,uBAAuB,CAAC;AAC9D,OAAO,EACL,WAAW,EACX,eAAe,EACf,iBAAiB,EACjB,sBAAsB,EACvB,MAAM,oBAAoB,CAAC;AAI5B,OAAO,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AAWzC,eAAO,MAAM,UAAU,EAAE,WAgBxB,CAAC;AAEF,eAAO,MAAM,eAAe,YACjB,eAAe,SACjB,QAAQ,EAAE,OACZ,iBAAiB,aACX,sBAAsB,2BA+ElC,CAAC"}
|