@monkeyplus/flow 1.1.9 → 3.0.2
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/config.d.ts +3 -9
- package/dist/config.js +3 -0
- package/dist/config.js.map +1 -1
- package/dist/generate.d.ts +2 -1
- package/dist/generate.js +147 -38
- package/dist/generate.js.map +1 -1
- package/dist/helper.d.ts +2 -0
- package/dist/helper.js +95 -0
- package/dist/helper.js.map +1 -0
- package/dist/index copy.d.ts +0 -0
- package/dist/index copy.js +315 -0
- package/dist/index copy.js.map +1 -0
- package/dist/index.d.ts +18 -13
- package/dist/index.js +186 -218
- package/dist/index.js.map +1 -1
- package/dist/lib/index.d.ts +0 -3
- package/dist/lib/index.js +22 -23
- package/dist/lib/index.js.map +1 -1
- package/dist/lib/pages/index copy.d.ts +0 -0
- package/dist/lib/pages/index copy.js +117 -0
- package/dist/lib/pages/index copy.js.map +1 -0
- package/dist/lib/pages/index.d.ts +0 -2
- package/dist/lib/pages/index.js +115 -121
- package/dist/lib/pages/index.js.map +1 -1
- package/dist/lib/pages/pre.d.ts +0 -8
- package/dist/lib/pages/pre.js +125 -135
- package/dist/lib/pages/pre.js.map +1 -1
- package/dist/lib/utils/index.d.ts +0 -2
- package/dist/lib/utils/index.js +25 -47
- package/dist/lib/utils/index.js.map +1 -1
- package/dist/pages.d.ts +2 -0
- package/dist/pages.js +97 -0
- package/dist/pages.js.map +1 -0
- package/dist/routes.json +0 -0
- package/dist/utils/index.d.ts +3 -2
- package/dist/utils/index.js +34 -7
- package/dist/utils/index.js.map +1 -1
- package/package.json +8 -6
- package/types/flow.d.ts +128 -0
- package/types/index.d.ts +13 -174
package/types/flow.d.ts
ADDED
|
@@ -0,0 +1,128 @@
|
|
|
1
|
+
import {
|
|
2
|
+
OptionsPage,
|
|
3
|
+
OptionsLocalPage,
|
|
4
|
+
BlogInfo,
|
|
5
|
+
LevelOptions,
|
|
6
|
+
PageInfo
|
|
7
|
+
} from '@monkeyplus/flow-core';
|
|
8
|
+
import {
|
|
9
|
+
RouteOptions,
|
|
10
|
+
ServerRoute,
|
|
11
|
+
Request,
|
|
12
|
+
ResponseToolkit
|
|
13
|
+
} from '@hapi/hapi';
|
|
14
|
+
|
|
15
|
+
export interface FlowOptions {
|
|
16
|
+
relativeTo: string;
|
|
17
|
+
outputDir?: string;
|
|
18
|
+
routeOptions?: RouteOptions;
|
|
19
|
+
dirTemplates?: string;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
export interface GenerateFolder {
|
|
23
|
+
prefix: string;
|
|
24
|
+
relativeTo: string;
|
|
25
|
+
dirs: string[];
|
|
26
|
+
override?: Record<string, string>;
|
|
27
|
+
type?: string;
|
|
28
|
+
}
|
|
29
|
+
export namespace Flow {
|
|
30
|
+
interface Url {
|
|
31
|
+
url: string;
|
|
32
|
+
locale: string;
|
|
33
|
+
name: string;
|
|
34
|
+
originalName: string;
|
|
35
|
+
}
|
|
36
|
+
export type Urls = Record<string, Url>;
|
|
37
|
+
export type Pages = Record<string, ServerRoute>;
|
|
38
|
+
export type Redirects = Record<string, string>;
|
|
39
|
+
export type Truncates = Record<string, string>;
|
|
40
|
+
export type DynamicContent = Record<string, { path: string; page: PageInfo }>;
|
|
41
|
+
export type DynamicPages = Record<string, string[]>;
|
|
42
|
+
|
|
43
|
+
export interface AppState {
|
|
44
|
+
redirects: Redirects;
|
|
45
|
+
urls: Urls;
|
|
46
|
+
pages: Pages;
|
|
47
|
+
truncates: Truncates;
|
|
48
|
+
dynamicPages: DynamicPages;
|
|
49
|
+
}
|
|
50
|
+
export interface Configs extends FlowOptions {
|
|
51
|
+
relativeTo: string;
|
|
52
|
+
locales: string[];
|
|
53
|
+
defaultUbication: string;
|
|
54
|
+
defaultLanguage: string;
|
|
55
|
+
publicPath: string;
|
|
56
|
+
locale: string;
|
|
57
|
+
url: string;
|
|
58
|
+
// redirects: {};
|
|
59
|
+
}
|
|
60
|
+
export interface GenerateOptions {
|
|
61
|
+
assets?: GenerateFolder[];
|
|
62
|
+
ommitAssets?: string[];
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
export interface Decorate {
|
|
66
|
+
init: (proxy?: boolean) => Promise<void>;
|
|
67
|
+
addPage: (page: RunDefinePage | OptionsHapiPage) => Promise<void>;
|
|
68
|
+
getPath: (...path: string[]) => string;
|
|
69
|
+
runGenerate: (options?: GenerateOptions) => Promise<void>;
|
|
70
|
+
}
|
|
71
|
+
export interface HandlerOptions {
|
|
72
|
+
name: string;
|
|
73
|
+
locale?: string;
|
|
74
|
+
view: {
|
|
75
|
+
template: string;
|
|
76
|
+
bundle?: string;
|
|
77
|
+
};
|
|
78
|
+
context?: RunContextHapi;
|
|
79
|
+
content?: string;
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
export interface OptionsHapiLocalPage extends OptionsLocalPage {
|
|
84
|
+
url: string;
|
|
85
|
+
blogInfo?: BlogInfo;
|
|
86
|
+
options?: RouteOptions;
|
|
87
|
+
rules?: Record<string, unknown>;
|
|
88
|
+
context?: RunContextHapi;
|
|
89
|
+
vhost?: string | string[];
|
|
90
|
+
}
|
|
91
|
+
interface Context {
|
|
92
|
+
req: Request;
|
|
93
|
+
h: ResponseToolkit;
|
|
94
|
+
page: {
|
|
95
|
+
level: string;
|
|
96
|
+
name: string;
|
|
97
|
+
locale: string;
|
|
98
|
+
template: string;
|
|
99
|
+
bundle: string;
|
|
100
|
+
publicPath: string;
|
|
101
|
+
path: string;
|
|
102
|
+
};
|
|
103
|
+
/**
|
|
104
|
+
* Si la genoracion de paginas es dinamica este es el contenido
|
|
105
|
+
*/
|
|
106
|
+
dataContent: any;
|
|
107
|
+
utils: {
|
|
108
|
+
getLocalUrl: (name: string) => string;
|
|
109
|
+
getUrl: (locale: string, name: string) => string;
|
|
110
|
+
};
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
export type RunContextHapi = (ctx: Context) => Promise<any>;
|
|
114
|
+
|
|
115
|
+
export interface OptionsHapiPage extends OptionsPage {
|
|
116
|
+
options?: RouteOptions;
|
|
117
|
+
context?: RunContextHapi;
|
|
118
|
+
locales: Record<string, OptionsHapiLocalPage>;
|
|
119
|
+
rules?: Record<string, unknown>;
|
|
120
|
+
vhost?: string | string[];
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
export type RunDefinePage = (configs: Flow.Configs) => ServerRoute[];
|
|
124
|
+
export type RunPreDefinePage = (level?: LevelOptions) => RunDefinePage;
|
|
125
|
+
export type DefinePage = (
|
|
126
|
+
page: OptionsHapiPage,
|
|
127
|
+
extensions?: { content?: string; [key: string]: any }
|
|
128
|
+
) => RunPreDefinePage;
|
package/types/index.d.ts
CHANGED
|
@@ -1,176 +1,15 @@
|
|
|
1
1
|
/* eslint-disable @typescript-eslint/no-explicit-any */
|
|
2
|
-
import {
|
|
3
|
-
PageInfo,
|
|
4
|
-
OptionsPage,
|
|
5
|
-
OptionsLocalPage,
|
|
6
|
-
CtxBuildLocal,
|
|
7
|
-
CtxBuildGlobal,
|
|
8
|
-
RunContext,
|
|
9
|
-
DictionaryImagesSeo,
|
|
10
|
-
ExtraOptions,
|
|
11
|
-
BlogInfo,
|
|
12
|
-
LocalesUrl
|
|
13
|
-
} from '@monkeyplus/flow-core';
|
|
14
|
-
import { Dictionary } from 'ramda';
|
|
15
|
-
import { Lifecycle, RouteOptions, Server, ServerRoute } from '@hapi/hapi';
|
|
16
|
-
import { Options } from 'prettier';
|
|
17
|
-
export interface AppObject {
|
|
18
|
-
images: DictionaryImagesSeo;
|
|
19
|
-
// defaultUbication: string;
|
|
20
|
-
// defaultLanguage: string;
|
|
21
|
-
// publicPath: string;
|
|
22
|
-
domain: string;
|
|
23
|
-
locale: string;
|
|
24
|
-
locales: string[];
|
|
25
|
-
pages: Map<string, PageInfo>;
|
|
26
|
-
// routes: Dictionary<any>;
|
|
27
|
-
localePages: Dictionary<any>;
|
|
28
|
-
// globalData: Dictionary<any>;
|
|
29
|
-
// pathImages: string;
|
|
30
|
-
// pathAssets: string;
|
|
31
|
-
// // robots: {
|
|
32
|
-
// // dissallowPaths?: string[];
|
|
33
|
-
// // allowPaths?: string[];
|
|
34
|
-
// // };
|
|
35
|
-
prevRoutes: Map<string, ResultPage>;
|
|
36
|
-
}
|
|
37
2
|
|
|
38
|
-
export
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
}
|
|
47
|
-
export
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
sharedLocale: any;
|
|
52
|
-
page: PageInfo;
|
|
53
|
-
}
|
|
54
|
-
export interface CtxHapiBuilGlobal extends CtxBuildGlobal {
|
|
55
|
-
server: Server;
|
|
56
|
-
isStatic?: boolean;
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
export type RunContextHapi<CTX = any> = RunContext<CtxHapiBuildLocal, CTX>;
|
|
60
|
-
export interface OptionsHapiPage extends OptionsPage {
|
|
61
|
-
routeOptions?: RouteOptions;
|
|
62
|
-
context: RunContextHapi;
|
|
63
|
-
locales: Dictionary<OptionsHapiLocalPage>;
|
|
64
|
-
rules?: Record<string, unknown>;
|
|
65
|
-
vhost?: string | string[];
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
/**
|
|
69
|
-
*
|
|
70
|
-
*/
|
|
71
|
-
interface DefaultLocale {
|
|
72
|
-
language: string;
|
|
73
|
-
ubication: string;
|
|
74
|
-
publicPath?: string;
|
|
75
|
-
}
|
|
76
|
-
export interface ResultPage {
|
|
77
|
-
name: string;
|
|
78
|
-
routes: (
|
|
79
|
-
ctx: CtxHapiBuildLocal,
|
|
80
|
-
handler: Lifecycle.Method
|
|
81
|
-
) => Promise<ServerRoute[]>;
|
|
82
|
-
pages: PageInfo[];
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
export type RunDefinePage = (
|
|
86
|
-
server: Server,
|
|
87
|
-
defs: DefaultLocale,
|
|
88
|
-
locales: string[],
|
|
89
|
-
runGlobal?: RunDefineGlobalContext
|
|
90
|
-
) => Promise<ResultPage>;
|
|
91
|
-
|
|
92
|
-
export type PreRunDefinePage<T = RunDefinePage> = (
|
|
93
|
-
extOpts?: ExtraOptions,
|
|
94
|
-
prefixName?: string
|
|
95
|
-
) => T;
|
|
96
|
-
export type DefinePage = (options: OptionsHapiPage) => PreRunDefinePage;
|
|
97
|
-
|
|
98
|
-
export interface ResultPage2 {
|
|
99
|
-
name: string;
|
|
100
|
-
options: OptionsHapiPage;
|
|
101
|
-
pages: PageInfo[];
|
|
102
|
-
}
|
|
103
|
-
|
|
104
|
-
export type RunDefinePage2 = (
|
|
105
|
-
server: Server,
|
|
106
|
-
defs: DefaultLocale,
|
|
107
|
-
locales: string[]
|
|
108
|
-
) => Promise<ResultPage2>;
|
|
109
|
-
|
|
110
|
-
export type DefinePage2 = (
|
|
111
|
-
options: OptionsHapiPage
|
|
112
|
-
) => PreRunDefinePage<RunDefinePage2>;
|
|
113
|
-
|
|
114
|
-
/**
|
|
115
|
-
*
|
|
116
|
-
*/
|
|
117
|
-
export interface OptionsInfo {
|
|
118
|
-
locale: string;
|
|
119
|
-
name: string;
|
|
120
|
-
path: string;
|
|
121
|
-
view?: {
|
|
122
|
-
template: string;
|
|
123
|
-
bundle?: string;
|
|
124
|
-
};
|
|
125
|
-
}
|
|
126
|
-
export interface Flow {
|
|
127
|
-
init: (proxy?: boolean) => Promise<void>;
|
|
128
|
-
addPage: (page: RunDefinePage | OptionsHapiPage) => Promise<void>;
|
|
129
|
-
defineInfoPage: (
|
|
130
|
-
options: OptionsInfo
|
|
131
|
-
) => Promise<{ path: string; flow: PageInfo }>;
|
|
132
|
-
getPath: (...path: string[]) => string;
|
|
133
|
-
runGenerate: () => Promise<void>;
|
|
134
|
-
}
|
|
135
|
-
|
|
136
|
-
export type GetUrl = (
|
|
137
|
-
server: Server,
|
|
138
|
-
options: R.Dictionary<OptionsHapiLocalPage>,
|
|
139
|
-
def: string
|
|
140
|
-
) => (locale: string) => Promise<LocalesUrl>;
|
|
141
|
-
export type UrlPromise = (
|
|
142
|
-
locale: string,
|
|
143
|
-
name: string
|
|
144
|
-
) => Promise<{ url: string; seo: any; [key: string]: any }>;
|
|
145
|
-
/**
|
|
146
|
-
*
|
|
147
|
-
*/
|
|
148
|
-
export type RunDefineGlobalContext = (ctx: CtxHapiBuildLocal) => Promise<any>;
|
|
149
|
-
export type DefineGlobalContext = (options: {
|
|
150
|
-
shared: RunContextHapi;
|
|
151
|
-
locales?: Dictionary<RunContextHapi>;
|
|
152
|
-
}) => RunDefineGlobalContext;
|
|
153
|
-
|
|
154
|
-
export interface FlowConfigs {
|
|
155
|
-
relativeTo: string;
|
|
156
|
-
locales: string[];
|
|
157
|
-
defaultUbication: string;
|
|
158
|
-
defaultLanguage: string;
|
|
159
|
-
domain: string;
|
|
160
|
-
publicPath: string;
|
|
161
|
-
sourceImagesDir: string;
|
|
162
|
-
dictionaryImages: string;
|
|
163
|
-
assetsDir: string;
|
|
164
|
-
assetsImagesDir: string;
|
|
165
|
-
sourceRename: string;
|
|
166
|
-
images: {
|
|
167
|
-
sources: string;
|
|
168
|
-
dirJsons: string;
|
|
169
|
-
};
|
|
170
|
-
server: {
|
|
171
|
-
watch: number;
|
|
172
|
-
dev: number;
|
|
173
|
-
};
|
|
174
|
-
vue: Record<string, string>;
|
|
175
|
-
// redirects: {};
|
|
176
|
-
}
|
|
3
|
+
export {
|
|
4
|
+
Flow,
|
|
5
|
+
FlowOptions,
|
|
6
|
+
RunDefinePage,
|
|
7
|
+
RunPreDefinePage,
|
|
8
|
+
DefinePage,
|
|
9
|
+
OptionsHapiPage,
|
|
10
|
+
GenerateFolder
|
|
11
|
+
} from './flow';
|
|
12
|
+
export type GenerateOptions =
|
|
13
|
+
| boolean
|
|
14
|
+
| string
|
|
15
|
+
| { isAsset: boolean; file: string; type?: string; isRemane?: boolean };
|