@whook/gcp-functions 18.1.0 → 19.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/README.md +16 -54
- package/dist/commands/testGCPFunctionRoute.d.ts +50 -0
- package/dist/commands/{testHTTPFunction.js → testGCPFunctionRoute.js} +43 -44
- package/dist/commands/testGCPFunctionRoute.js.map +1 -0
- package/dist/index.d.ts +7 -6
- package/dist/index.js +49 -52
- package/dist/index.js.map +1 -1
- package/dist/services/_autoload.d.ts +14 -9
- package/dist/services/_autoload.js +49 -62
- package/dist/services/_autoload.js.map +1 -1
- package/dist/wrappers/wrapRouteHandlerForGoogleHTTPFunction.d.ts +19 -0
- package/dist/wrappers/wrapRouteHandlerForGoogleHTTPFunction.js +307 -0
- package/dist/wrappers/wrapRouteHandlerForGoogleHTTPFunction.js.map +1 -0
- package/package.json +10 -8
- package/src/commands/{testHTTPFunction.ts → testGCPFunctionRoute.ts} +68 -69
- package/src/index.ts +85 -87
- package/src/services/_autoload.ts +79 -106
- package/src/types.d.ts +8 -0
- package/src/wrappers/wrapRouteHandlerForGoogleHTTPFunction.ts +571 -0
- package/dist/commands/testHTTPFunction.d.ts +0 -13
- package/dist/commands/testHTTPFunction.js.map +0 -1
- package/dist/services/HANDLER.d.ts +0 -10
- package/dist/services/HANDLER.js +0 -21
- package/dist/services/HANDLER.js.map +0 -1
- package/dist/services/log.d.ts +0 -5
- package/dist/services/log.js +0 -4
- package/dist/services/log.js.map +0 -1
- package/dist/wrappers/wrapHandlerForGoogleHTTPFunction.d.ts +0 -21
- package/dist/wrappers/wrapHandlerForGoogleHTTPFunction.js +0 -270
- package/dist/wrappers/wrapHandlerForGoogleHTTPFunction.js.map +0 -1
- package/src/services/HANDLER.ts +0 -47
- package/src/services/log.ts +0 -7
- package/src/wrappers/wrapHandlerForGoogleHTTPFunction.ts +0 -480
package/README.md
CHANGED
|
@@ -44,8 +44,7 @@ Add the plugin to the `src/index.ts` main file:
|
|
|
44
44
|
// ...
|
|
45
45
|
```
|
|
46
46
|
|
|
47
|
-
Tweak the 2 build functions in your
|
|
48
|
-
`src/build.ts` main file:
|
|
47
|
+
Tweak the 2 build functions in your `src/build.ts` main file:
|
|
49
48
|
|
|
50
49
|
```diff
|
|
51
50
|
import {
|
|
@@ -99,8 +98,8 @@ Declare this module types in your `src/whook.d.ts` type definitions:
|
|
|
99
98
|
// ...
|
|
100
99
|
+ import { type WhookCompilerConfig } from '@whook/whook';
|
|
101
100
|
+ import {
|
|
102
|
-
+ type
|
|
103
|
-
+ type
|
|
101
|
+
+ type WhookGCPFunctionBuildConfig,
|
|
102
|
+
+ type WhookGCPFunctionRouteConfig
|
|
104
103
|
+ } from '@whook/gcp-functions';
|
|
105
104
|
|
|
106
105
|
declare module 'application-services' {
|
|
@@ -110,8 +109,8 @@ declare module 'application-services' {
|
|
|
110
109
|
export interface AppConfig
|
|
111
110
|
- extends WhookBaseConfigs {}
|
|
112
111
|
+ extends WhookBaseConfigs,
|
|
113
|
-
+
|
|
114
|
-
+
|
|
112
|
+
+ WhookGCPFunctionBuildConfig,
|
|
113
|
+
+ WhookCompilerConfig {}
|
|
115
114
|
|
|
116
115
|
// ...
|
|
117
116
|
}
|
|
@@ -119,19 +118,10 @@ declare module 'application-services' {
|
|
|
119
118
|
// ...
|
|
120
119
|
|
|
121
120
|
declare module '@whook/whook' {
|
|
122
|
-
export interface
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
} = unknown,
|
|
127
|
-
V extends Record<string, unknown> = Record<string, unknown>,
|
|
128
|
-
> extends WhookBaseAPIHandlerDefinition<T, U> {
|
|
129
|
-
operation: U & WhookAPIOperation<
|
|
130
|
-
T &
|
|
131
|
-
+ WhookAPIOperationGCPFunctionConfig &
|
|
132
|
-
WhookAPIOperationCORSConfig
|
|
133
|
-
>;
|
|
134
|
-
}
|
|
121
|
+
export interface WhookRouteConfig
|
|
122
|
+
extends WhookBaseRouteConfig,
|
|
123
|
+
+ WhookGCPFunctionRouteConfig,
|
|
124
|
+
WhookCORSRouteConfig {}
|
|
135
125
|
}
|
|
136
126
|
```
|
|
137
127
|
|
|
@@ -170,16 +160,16 @@ npm run build -- getPing
|
|
|
170
160
|
|
|
171
161
|
You can easily test your function builds by adding `@whook/gcp-functions` to
|
|
172
162
|
your `WHOOK_PLUGINS` list. It provides you some commands like the
|
|
173
|
-
`
|
|
163
|
+
`testGCPFunctionRoute` one:
|
|
174
164
|
|
|
175
165
|
```sh
|
|
176
|
-
npx whook
|
|
166
|
+
npx whook testGCPFunctionRoute --name getPing
|
|
177
167
|
```
|
|
178
168
|
|
|
179
169
|
To get more insights when some errors happens:
|
|
180
170
|
|
|
181
171
|
```sh
|
|
182
|
-
DEBUG=whook npm run dev --
|
|
172
|
+
DEBUG=whook npm run dev -- testGCPFunctionRoute --name getPing
|
|
183
173
|
```
|
|
184
174
|
|
|
185
175
|
## Deployment
|
|
@@ -192,35 +182,9 @@ There is a complete example on how to deploy your functions
|
|
|
192
182
|
[//]: # (::contents:end)
|
|
193
183
|
|
|
194
184
|
# API
|
|
195
|
-
|
|
185
|
+
<a name="initWrapRouteHandlerForGoogleHTTPFunction"></a>
|
|
196
186
|
|
|
197
|
-
<
|
|
198
|
-
<dt><a href="#initHandler">initHandler(services)</a> ⇒ <code>Promise.<function()></code></dt>
|
|
199
|
-
<dd><p>Initialize one Whook handler</p>
|
|
200
|
-
</dd>
|
|
201
|
-
<dt><a href="#initWrapHandlerForGoogleHTTPFunction">initWrapHandlerForGoogleHTTPFunction(services)</a> ⇒ <code>Promise.<Object></code></dt>
|
|
202
|
-
<dd><p>Wrap an handler to make it work with GCP Functions.</p>
|
|
203
|
-
</dd>
|
|
204
|
-
</dl>
|
|
205
|
-
|
|
206
|
-
<a name="initHandler"></a>
|
|
207
|
-
|
|
208
|
-
## initHandler(services) ⇒ <code>Promise.<function()></code>
|
|
209
|
-
Initialize one Whook handler
|
|
210
|
-
|
|
211
|
-
**Kind**: global function
|
|
212
|
-
**Returns**: <code>Promise.<function()></code> - A promise of the `HANDLERS` hash.
|
|
213
|
-
|
|
214
|
-
| Param | Type | Default | Description |
|
|
215
|
-
| --- | --- | --- | --- |
|
|
216
|
-
| services | <code>Object</code> | | The services `$autoload` depends on |
|
|
217
|
-
| services.WRAPPERS | <code>Array</code> | | An optional list of wrappers to inject |
|
|
218
|
-
| [services.log] | <code>Object</code> | <code>noop</code> | An optional logging service |
|
|
219
|
-
| services.HANDLERS | <code>Object</code> | | The rest is a hash of handlers mapped by their operation id |
|
|
220
|
-
|
|
221
|
-
<a name="initWrapHandlerForGoogleHTTPFunction"></a>
|
|
222
|
-
|
|
223
|
-
## initWrapHandlerForGoogleHTTPFunction(services) ⇒ <code>Promise.<Object></code>
|
|
187
|
+
## initWrapRouteHandlerForGoogleHTTPFunction(services) ⇒ <code>Promise.<Object></code>
|
|
224
188
|
Wrap an handler to make it work with GCP Functions.
|
|
225
189
|
|
|
226
190
|
**Kind**: global function
|
|
@@ -229,15 +193,13 @@ Wrap an handler to make it work with GCP Functions.
|
|
|
229
193
|
| Param | Type | Default | Description |
|
|
230
194
|
| --- | --- | --- | --- |
|
|
231
195
|
| services | <code>Object</code> | | The services the wrapper depends on |
|
|
232
|
-
| services.
|
|
233
|
-
| services.ENV | <code>Object</code> | | The process environment |
|
|
234
|
-
| services.DEBUG_NODE_ENVS | <code>Object</code> | | The NODE_ENV values that trigger debugging |
|
|
196
|
+
| services.MAIN_DEFINITION | <code>Object</code> | | An OpenAPI definitition for that handler |
|
|
235
197
|
| services.DECODERS | <code>Object</code> | | Request body decoders available |
|
|
236
198
|
| services.ENCODERS | <code>Object</code> | | Response body encoders available |
|
|
237
199
|
| services.PARSERS | <code>Object</code> | | Request body parsers available |
|
|
238
200
|
| services.STRINGIFYERS | <code>Object</code> | | Response body stringifyers available |
|
|
239
201
|
| services.BUFFER_LIMIT | <code>Object</code> | | The buffer size limit |
|
|
240
|
-
| services.
|
|
202
|
+
| services.queryParserBuilder | <code>Object</code> | | A query parser builder from OpenAPI parameters |
|
|
241
203
|
| services.obfuscator | <code>Object</code> | | A service to hide sensible values |
|
|
242
204
|
| services.errorHandler | <code>Object</code> | | A service that changes any error to Whook response |
|
|
243
205
|
| [services.log] | <code>Object</code> | <code>noop</code> | An optional logging service |
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import { type WhookCommandHandler, type WhookCommandDefinition, type WhookCompilerOptions, type WhookRoutesDefinitionsService } from '@whook/whook';
|
|
2
|
+
import { type LogService } from 'common-services';
|
|
3
|
+
export declare const definition: {
|
|
4
|
+
readonly name: "testGCPFunctionRoute";
|
|
5
|
+
readonly description: "A command for testing a GCP function route";
|
|
6
|
+
readonly example: "whook testGCPFunctionRoute --name getPing";
|
|
7
|
+
readonly arguments: [{
|
|
8
|
+
readonly description: "Name of the function to run";
|
|
9
|
+
readonly name: "name";
|
|
10
|
+
readonly required: true;
|
|
11
|
+
readonly schema: {
|
|
12
|
+
readonly type: "string";
|
|
13
|
+
};
|
|
14
|
+
}, {
|
|
15
|
+
readonly name: "type";
|
|
16
|
+
readonly description: "Type of function to test";
|
|
17
|
+
readonly schema: {
|
|
18
|
+
readonly type: "string";
|
|
19
|
+
readonly enum: ["main", "index"];
|
|
20
|
+
readonly default: "index";
|
|
21
|
+
};
|
|
22
|
+
}, {
|
|
23
|
+
readonly name: "contentType";
|
|
24
|
+
readonly description: "Content type of the payload";
|
|
25
|
+
readonly schema: {
|
|
26
|
+
readonly type: "string";
|
|
27
|
+
readonly default: "application/json";
|
|
28
|
+
};
|
|
29
|
+
}, {
|
|
30
|
+
readonly name: "parameters";
|
|
31
|
+
readonly description: "The HTTP call parameters";
|
|
32
|
+
readonly schema: {
|
|
33
|
+
readonly type: "string";
|
|
34
|
+
readonly default: "{}";
|
|
35
|
+
};
|
|
36
|
+
}];
|
|
37
|
+
};
|
|
38
|
+
declare const _default: import("knifecycle").ServiceInitializer<{
|
|
39
|
+
APP_ENV: string;
|
|
40
|
+
PROJECT_DIR: string;
|
|
41
|
+
COMPILER_OPTIONS?: WhookCompilerOptions;
|
|
42
|
+
ROUTES_DEFINITIONS: WhookRoutesDefinitionsService;
|
|
43
|
+
log: LogService;
|
|
44
|
+
}, WhookCommandHandler<{
|
|
45
|
+
name: string;
|
|
46
|
+
type: string;
|
|
47
|
+
contentType: string;
|
|
48
|
+
parameters: string;
|
|
49
|
+
}, WhookCommandDefinition>>;
|
|
50
|
+
export default _default;
|
|
@@ -1,85 +1,83 @@
|
|
|
1
1
|
import { loadFunction } from '../libs/utils.js';
|
|
2
|
-
import {
|
|
2
|
+
import { location, autoService } from 'knifecycle';
|
|
3
3
|
import { YError } from 'yerror';
|
|
4
4
|
import stream from 'node:stream';
|
|
5
|
-
import
|
|
6
|
-
import { dereferenceOpenAPIOperations, getOpenAPIOperations, DEFAULT_COMPILER_OPTIONS, readArgs, } from '@whook/whook';
|
|
7
|
-
const SEARCH_SEPARATOR = '?';
|
|
8
|
-
const PATH_SEPARATOR = '/';
|
|
5
|
+
import { DEFAULT_COMPILER_OPTIONS, PATH_SEPARATOR, SEARCH_SEPARATOR, } from '@whook/whook';
|
|
9
6
|
export const definition = {
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
7
|
+
name: 'testGCPFunctionRoute',
|
|
8
|
+
description: 'A command for testing a GCP function route',
|
|
9
|
+
example: `whook testGCPFunctionRoute --name getPing`,
|
|
10
|
+
arguments: [
|
|
11
|
+
{
|
|
12
|
+
description: 'Name of the function to run',
|
|
13
|
+
name: 'name',
|
|
14
|
+
required: true,
|
|
15
|
+
schema: {
|
|
19
16
|
type: 'string',
|
|
20
17
|
},
|
|
21
|
-
|
|
22
|
-
|
|
18
|
+
},
|
|
19
|
+
{
|
|
20
|
+
name: 'type',
|
|
21
|
+
description: 'Type of function to test',
|
|
22
|
+
schema: {
|
|
23
23
|
type: 'string',
|
|
24
24
|
enum: ['main', 'index'],
|
|
25
25
|
default: 'index',
|
|
26
26
|
},
|
|
27
|
-
|
|
28
|
-
|
|
27
|
+
},
|
|
28
|
+
{
|
|
29
|
+
name: 'contentType',
|
|
30
|
+
description: 'Content type of the payload',
|
|
31
|
+
schema: {
|
|
29
32
|
type: 'string',
|
|
30
33
|
default: 'application/json',
|
|
31
34
|
},
|
|
32
|
-
|
|
33
|
-
|
|
35
|
+
},
|
|
36
|
+
{
|
|
37
|
+
name: 'parameters',
|
|
38
|
+
description: 'The HTTP call parameters',
|
|
39
|
+
schema: {
|
|
34
40
|
type: 'string',
|
|
35
41
|
default: '{}',
|
|
36
42
|
},
|
|
37
43
|
},
|
|
38
|
-
|
|
44
|
+
],
|
|
39
45
|
};
|
|
40
|
-
|
|
41
|
-
async
|
|
42
|
-
|
|
43
|
-
const { namedArguments: { name, type, contentType, parameters: rawParameters }, } = readArgs(definition.arguments, args);
|
|
46
|
+
async function initTestGCPFunctionRouteCommand({ APP_ENV, PROJECT_DIR, COMPILER_OPTIONS = DEFAULT_COMPILER_OPTIONS, ROUTES_DEFINITIONS, log, }) {
|
|
47
|
+
return async (args) => {
|
|
48
|
+
const { namedArguments: { name, type, contentType, parameters: rawParameters }, } = args;
|
|
44
49
|
const extension = COMPILER_OPTIONS.format === 'cjs' ? '.cjs' : '.mjs';
|
|
45
50
|
const handler = await loadFunction({ APP_ENV, PROJECT_DIR, log }, name, type, extension);
|
|
46
|
-
const
|
|
47
|
-
if (!
|
|
51
|
+
const handlerDefinition = ROUTES_DEFINITIONS[name]?.module?.definition;
|
|
52
|
+
if (!handlerDefinition) {
|
|
48
53
|
throw new YError('E_OPERATION_NOT_FOUND');
|
|
49
54
|
}
|
|
50
|
-
const hasBody = !!
|
|
55
|
+
const hasBody = !!handlerDefinition.operation.requestBody;
|
|
51
56
|
const parameters = JSON.parse(rawParameters);
|
|
52
|
-
const search = (
|
|
53
|
-
|
|
54
|
-
.reduce((accSearch, p) => {
|
|
55
|
-
if (null != parameters[p.name]) {
|
|
57
|
+
const search = Object.keys(parameters.query || {}).reduce((accSearch, name) => {
|
|
58
|
+
if (null != parameters.query[name]) {
|
|
56
59
|
return (accSearch +
|
|
57
60
|
(accSearch ? '&' : '') +
|
|
58
|
-
|
|
61
|
+
name +
|
|
59
62
|
'=' +
|
|
60
|
-
parameters[
|
|
63
|
+
parameters.query[name]);
|
|
61
64
|
}
|
|
62
65
|
return accSearch;
|
|
63
66
|
}, '');
|
|
64
|
-
const path =
|
|
67
|
+
const path = handlerDefinition.path
|
|
65
68
|
.split(PATH_SEPARATOR)
|
|
66
69
|
.map((part) => {
|
|
67
70
|
const matches = /^\{([\d\w]+)\}$/i.exec(part);
|
|
68
71
|
if (matches) {
|
|
69
|
-
return parameters[matches[1]];
|
|
72
|
+
return parameters.path?.[matches[1]];
|
|
70
73
|
}
|
|
71
74
|
return part;
|
|
72
75
|
})
|
|
73
76
|
.join(PATH_SEPARATOR);
|
|
74
77
|
const gcpfRequest = {
|
|
75
|
-
method:
|
|
78
|
+
method: handlerDefinition.method,
|
|
76
79
|
originalUrl: path + (search ? SEARCH_SEPARATOR + search : ''),
|
|
77
|
-
headers:
|
|
78
|
-
.filter((p) => p.in === 'header')
|
|
79
|
-
.reduce((headerParameters, p) => {
|
|
80
|
-
headerParameters[p.name] = parameters[camelCase(p.name)];
|
|
81
|
-
return headerParameters;
|
|
82
|
-
}, {}),
|
|
80
|
+
headers: parameters.header || {},
|
|
83
81
|
rawBody: Buffer.from(hasBody
|
|
84
82
|
? contentType === 'application/json'
|
|
85
83
|
? parameters.body
|
|
@@ -124,4 +122,5 @@ async function initTestHTTPFunctionCommand({ APP_ENV, PROJECT_DIR, COMPILER_OPTI
|
|
|
124
122
|
log('info', 'SUCCESS:', response);
|
|
125
123
|
};
|
|
126
124
|
}
|
|
127
|
-
|
|
125
|
+
export default location(autoService(initTestGCPFunctionRouteCommand), import.meta.url);
|
|
126
|
+
//# sourceMappingURL=testGCPFunctionRoute.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"testGCPFunctionRoute.js","sourceRoot":"","sources":["../../src/commands/testGCPFunctionRoute.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAC;AAChD,OAAO,EAAE,QAAQ,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AACnD,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAChC,OAAO,MAAM,MAAM,aAAa,CAAC;AACjC,OAAO,EACL,wBAAwB,EACxB,cAAc,EACd,gBAAgB,GAMjB,MAAM,cAAc,CAAC;AAGtB,MAAM,CAAC,MAAM,UAAU,GAAG;IACxB,IAAI,EAAE,sBAAsB;IAC5B,WAAW,EAAE,4CAA4C;IACzD,OAAO,EAAE,2CAA2C;IACpD,SAAS,EAAE;QACT;YACE,WAAW,EAAE,6BAA6B;YAC1C,IAAI,EAAE,MAAM;YACZ,QAAQ,EAAE,IAAI;YACd,MAAM,EAAE;gBACN,IAAI,EAAE,QAAQ;aACf;SACF;QACD;YACE,IAAI,EAAE,MAAM;YACZ,WAAW,EAAE,0BAA0B;YACvC,MAAM,EAAE;gBACN,IAAI,EAAE,QAAQ;gBACd,IAAI,EAAE,CAAC,MAAM,EAAE,OAAO,CAAC;gBACvB,OAAO,EAAE,OAAO;aACjB;SACF;QACD;YACE,IAAI,EAAE,aAAa;YACnB,WAAW,EAAE,6BAA6B;YAC1C,MAAM,EAAE;gBACN,IAAI,EAAE,QAAQ;gBACd,OAAO,EAAE,kBAAkB;aAC5B;SACF;QACD;YACE,IAAI,EAAE,YAAY;YAClB,WAAW,EAAE,0BAA0B;YACvC,MAAM,EAAE;gBACN,IAAI,EAAE,QAAQ;gBACd,OAAO,EAAE,IAAI;aACd;SACF;KACF;CACwC,CAAC;AAE5C,KAAK,UAAU,+BAA+B,CAAC,EAC7C,OAAO,EACP,WAAW,EACX,gBAAgB,GAAG,wBAAwB,EAC3C,kBAAkB,EAClB,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|
|
1
1
|
import { Knifecycle } from 'knifecycle';
|
|
2
2
|
import { type WhookCompilerOptions } from '@whook/whook';
|
|
3
|
+
import initWrapRouteHandlerForGoogleHTTPFunction from './wrappers/wrapRouteHandlerForGoogleHTTPFunction.js';
|
|
3
4
|
export declare const DEFAULT_BUILD_PARALLELISM = 10;
|
|
4
5
|
export declare const DEFAULT_BUILD_INITIALIZER_PATH_MAP: {
|
|
5
6
|
log: string;
|
|
6
7
|
$fatalError: string;
|
|
7
8
|
BASE_URL: string;
|
|
8
|
-
|
|
9
|
+
DEFINITIONS: string;
|
|
9
10
|
logger: string;
|
|
10
11
|
exit: string;
|
|
11
12
|
PORT: string;
|
|
@@ -28,15 +29,15 @@ export declare const DEFAULT_BUILD_INITIALIZER_PATH_MAP: {
|
|
|
28
29
|
importer: string;
|
|
29
30
|
resolve: string;
|
|
30
31
|
};
|
|
31
|
-
export type
|
|
32
|
+
export type * from './wrappers/wrapRouteHandlerForGoogleHTTPFunction.js';
|
|
33
|
+
export { initWrapRouteHandlerForGoogleHTTPFunction };
|
|
34
|
+
export type WhookGCPFunctionBuildConfig = {
|
|
32
35
|
BUILD_PARALLELISM?: number;
|
|
33
36
|
};
|
|
34
|
-
export type
|
|
35
|
-
type?: 'http';
|
|
36
|
-
sourceOperationId?: string;
|
|
37
|
+
export type WhookGCPFunctionBaseConfig = {
|
|
37
38
|
staticFiles?: string[];
|
|
38
39
|
compilerOptions?: WhookCompilerOptions;
|
|
39
|
-
suffix?: string;
|
|
40
40
|
};
|
|
41
|
+
export type WhookGCPFunctionRouteConfig = WhookGCPFunctionBaseConfig;
|
|
41
42
|
export declare function prepareBuildEnvironment<T extends Knifecycle>($?: T): Promise<T>;
|
|
42
43
|
export declare function runBuild(aPrepareBuildEnvironment: typeof prepareBuildEnvironment): Promise<void>;
|
package/dist/index.js
CHANGED
|
@@ -8,13 +8,15 @@ import cpr from 'cpr';
|
|
|
8
8
|
import { printStackTrace, YError } from 'yerror';
|
|
9
9
|
import { Knifecycle, constant, initInitializerBuilder, } from 'knifecycle';
|
|
10
10
|
import initBuildAutoloader from './services/_autoload.js';
|
|
11
|
-
import { DEFAULT_BUILD_INITIALIZER_PATH_MAP as BASE_DEFAULT_BUILD_INITIALIZER_PATH_MAP, initCompiler,
|
|
11
|
+
import { DEFAULT_BUILD_INITIALIZER_PATH_MAP as BASE_DEFAULT_BUILD_INITIALIZER_PATH_MAP, initCompiler, } from '@whook/whook';
|
|
12
12
|
import { parseArgs } from '@whook/whook/dist/libs/args.js';
|
|
13
|
+
import initWrapRouteHandlerForGoogleHTTPFunction from './wrappers/wrapRouteHandlerForGoogleHTTPFunction.js';
|
|
13
14
|
export const DEFAULT_BUILD_PARALLELISM = 10;
|
|
14
15
|
export const DEFAULT_BUILD_INITIALIZER_PATH_MAP = {
|
|
15
16
|
...BASE_DEFAULT_BUILD_INITIALIZER_PATH_MAP,
|
|
16
|
-
log: '@whook/
|
|
17
|
+
log: '@whook/whook/dist/services/rawLog.js',
|
|
17
18
|
};
|
|
19
|
+
export { initWrapRouteHandlerForGoogleHTTPFunction };
|
|
18
20
|
const cprAsync = promisify(cpr);
|
|
19
21
|
export async function prepareBuildEnvironment($ = new Knifecycle()) {
|
|
20
22
|
$.register(initInitializerBuilder);
|
|
@@ -30,7 +32,7 @@ export async function runBuild(aPrepareBuildEnvironment) {
|
|
|
30
32
|
try {
|
|
31
33
|
const handlerName = argv[2];
|
|
32
34
|
const $ = await aPrepareBuildEnvironment();
|
|
33
|
-
const { APP_ENV, BUILD_PARALLELISM, PROJECT_DIR, compiler, log, $autoload,
|
|
35
|
+
const { APP_ENV, BUILD_PARALLELISM, PROJECT_DIR, compiler, log, $autoload, DEFINITIONS, buildInitializer, } = await $.run([
|
|
34
36
|
'APP_ENV',
|
|
35
37
|
'?BUILD_PARALLELISM',
|
|
36
38
|
'PROJECT_DIR',
|
|
@@ -38,28 +40,22 @@ export async function runBuild(aPrepareBuildEnvironment) {
|
|
|
38
40
|
'compiler',
|
|
39
41
|
'log',
|
|
40
42
|
'$autoload',
|
|
41
|
-
'
|
|
43
|
+
'DEFINITIONS',
|
|
42
44
|
'buildInitializer',
|
|
43
45
|
]);
|
|
44
46
|
log('info', 'GCP Functions build Environment initialized 🚀🌕');
|
|
45
|
-
const
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
return (handlerName === operation.operationId ||
|
|
49
|
-
handlerName === sourceOperationId);
|
|
50
|
-
}
|
|
51
|
-
return true;
|
|
52
|
-
});
|
|
53
|
-
log('warning', `📃 - ${operations.length} operations to process.`);
|
|
54
|
-
await processOperations({
|
|
47
|
+
const handlerNames = Object.keys(DEFINITIONS.configs).filter((aHandlerName) => handlerName === aHandlerName || !handlerName);
|
|
48
|
+
log('warning', `📃 - ${handlerNames.length} handlerNames to process.`);
|
|
49
|
+
await processHandlers({
|
|
55
50
|
APP_ENV,
|
|
56
51
|
BUILD_PARALLELISM: BUILD_PARALLELISM || DEFAULT_BUILD_PARALLELISM,
|
|
57
52
|
PROJECT_DIR,
|
|
53
|
+
DEFINITIONS,
|
|
58
54
|
compiler,
|
|
59
55
|
log,
|
|
60
56
|
$autoload,
|
|
61
57
|
buildInitializer,
|
|
62
|
-
},
|
|
58
|
+
}, handlerNames);
|
|
63
59
|
await $.destroy();
|
|
64
60
|
}
|
|
65
61
|
catch (err) {
|
|
@@ -67,58 +63,59 @@ export async function runBuild(aPrepareBuildEnvironment) {
|
|
|
67
63
|
exit(1);
|
|
68
64
|
}
|
|
69
65
|
}
|
|
70
|
-
async function
|
|
71
|
-
const
|
|
72
|
-
await Promise.all(
|
|
66
|
+
async function processHandlers({ APP_ENV, BUILD_PARALLELISM, PROJECT_DIR, DEFINITIONS, compiler, log, $autoload, buildInitializer, }, handlerNames) {
|
|
67
|
+
const handlerNamesLeft = handlerNames.slice(BUILD_PARALLELISM);
|
|
68
|
+
await Promise.all(handlerNames.slice(0, BUILD_PARALLELISM).map((handlerName) => buildHandler({
|
|
73
69
|
APP_ENV,
|
|
74
70
|
PROJECT_DIR,
|
|
71
|
+
DEFINITIONS,
|
|
75
72
|
compiler,
|
|
76
73
|
log,
|
|
77
74
|
buildInitializer,
|
|
78
|
-
},
|
|
79
|
-
if (
|
|
80
|
-
log('info', `📃 - ${
|
|
81
|
-
return
|
|
75
|
+
}, handlerName)));
|
|
76
|
+
if (handlerNamesLeft.length) {
|
|
77
|
+
log('info', `📃 - ${handlerNamesLeft.length} handlerNames left.`);
|
|
78
|
+
return processHandlers({
|
|
82
79
|
APP_ENV,
|
|
83
80
|
BUILD_PARALLELISM,
|
|
84
81
|
PROJECT_DIR,
|
|
82
|
+
DEFINITIONS,
|
|
85
83
|
compiler,
|
|
86
84
|
log,
|
|
87
85
|
$autoload,
|
|
88
86
|
buildInitializer,
|
|
89
|
-
},
|
|
87
|
+
}, handlerNamesLeft);
|
|
90
88
|
}
|
|
91
|
-
log('info', '🤷 - No more
|
|
89
|
+
log('info', '🤷 - No more handlerNames.');
|
|
92
90
|
}
|
|
93
|
-
async function
|
|
94
|
-
const { operationId } = operation;
|
|
91
|
+
async function buildHandler({ APP_ENV, PROJECT_DIR, DEFINITIONS, compiler, log, buildInitializer, }, handlerName) {
|
|
95
92
|
try {
|
|
96
|
-
const
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
log('warning', `🏗 - Building
|
|
102
|
-
const
|
|
93
|
+
const definition = DEFINITIONS.configs[handlerName];
|
|
94
|
+
if (definition.type !== 'route') {
|
|
95
|
+
log('warning', `🚮 - Skipping "${handlerName}"...`);
|
|
96
|
+
return;
|
|
97
|
+
}
|
|
98
|
+
log('warning', `🏗 - Building "${handlerName}"...`);
|
|
99
|
+
const handlerPath = join(PROJECT_DIR, 'builds', APP_ENV, handlerName);
|
|
103
100
|
const srcPath = join(PROJECT_DIR, 'src');
|
|
104
|
-
const srcRelativePath = relative(
|
|
105
|
-
const initializerContent = (await buildInitializer([`
|
|
106
|
-
const indexContent = await
|
|
107
|
-
await mkdirp(
|
|
101
|
+
const srcRelativePath = relative(handlerPath, srcPath);
|
|
102
|
+
const initializerContent = (await buildInitializer([`MAIN_HANDLER_${handlerName}`])).replaceAll(pathToFileURL(srcPath).toString(), srcRelativePath);
|
|
103
|
+
const indexContent = await buildHandlerIndex(`MAIN_HANDLER_${handlerName}`);
|
|
104
|
+
await mkdirp(handlerPath);
|
|
108
105
|
await Promise.all([
|
|
109
|
-
copyStaticFiles({ PROJECT_DIR, log },
|
|
110
|
-
ensureFile({ log }, join(
|
|
111
|
-
ensureFile({ log }, join(
|
|
106
|
+
copyStaticFiles({ PROJECT_DIR, log }, handlerPath, definition.config?.staticFiles || []),
|
|
107
|
+
ensureFile({ log }, join(handlerPath, 'initialize.js'), initializerContent),
|
|
108
|
+
ensureFile({ log }, join(handlerPath, 'main.js'), indexContent),
|
|
112
109
|
]);
|
|
113
|
-
await
|
|
110
|
+
await buildFinalHandler({ DEFINITIONS, compiler, log }, handlerPath, handlerName);
|
|
114
111
|
}
|
|
115
112
|
catch (err) {
|
|
116
|
-
log('error',
|
|
113
|
+
log('error', `💥 - Error building "${handlerName}"...`);
|
|
117
114
|
log('error-stack', printStackTrace(err));
|
|
118
|
-
throw YError.wrap(err, '
|
|
115
|
+
throw YError.wrap(err, 'E_HANDLER_BUILD', handlerName);
|
|
119
116
|
}
|
|
120
117
|
}
|
|
121
|
-
async function
|
|
118
|
+
async function buildHandlerIndex(handlerName) {
|
|
122
119
|
return `// Automatically generated by \`@whook/gcp-functions\`
|
|
123
120
|
import { initialize } from './initialize.js';
|
|
124
121
|
|
|
@@ -126,22 +123,22 @@ const initializationPromise = initialize();
|
|
|
126
123
|
|
|
127
124
|
export default function handler (req, res) {
|
|
128
125
|
return initializationPromise
|
|
129
|
-
.then(services => services['${
|
|
126
|
+
.then(services => services['${handlerName}'](req, res));
|
|
130
127
|
};
|
|
131
128
|
`;
|
|
132
129
|
}
|
|
133
|
-
async function
|
|
134
|
-
const entryPoint = `${
|
|
135
|
-
const { extension, contents, mappings } = await compiler(entryPoint,
|
|
130
|
+
async function buildFinalHandler({ DEFINITIONS, compiler, log, }, handlerPath, handlerName) {
|
|
131
|
+
const entryPoint = `${handlerPath}/main.js`;
|
|
132
|
+
const { extension, contents, mappings } = await compiler(entryPoint, DEFINITIONS[handlerName]?.config?.compilerOptions);
|
|
136
133
|
await Promise.all([
|
|
137
|
-
ensureFile({ log }, join(
|
|
134
|
+
ensureFile({ log }, join(handlerPath, `/index${extension}`), contents),
|
|
138
135
|
mappings
|
|
139
|
-
? ensureFile({ log }, join(
|
|
136
|
+
? ensureFile({ log }, join(handlerPath, `/index${extension}.map`), mappings)
|
|
140
137
|
: Promise.resolve(),
|
|
141
138
|
]);
|
|
142
139
|
}
|
|
143
|
-
async function copyStaticFiles({ PROJECT_DIR, log },
|
|
144
|
-
await Promise.all(staticFiles.map(async (staticFile) => await copyFiles({ log }, join(PROJECT_DIR, 'node_modules', staticFile), join(
|
|
140
|
+
async function copyStaticFiles({ PROJECT_DIR, log }, handlerPath, staticFiles = []) {
|
|
141
|
+
await Promise.all(staticFiles.map(async (staticFile) => await copyFiles({ log }, join(PROJECT_DIR, 'node_modules', staticFile), join(handlerPath, 'node_modules', staticFile))));
|
|
145
142
|
}
|
|
146
143
|
async function copyFiles({ log }, source, destination) {
|
|
147
144
|
let theError = undefined;
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,IAAI,EAAE,MAAM,EAAE,MAAM,cAAc,CAAC;AAClD,OAAO,EAAE,QAAQ,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AACvD,OAAO,EAAE,SAAS,EAAE,MAAM,WAAW,CAAC;AACtC,OAAO,EAAE,IAAI,EAAE,QAAQ,EAAE,MAAM,WAAW,CAAC;AAC3C,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AACzC,OAAO,EAAE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EAC5B,IAAY,EACZ,OAAe;IAEf,IAAI,CAAC;QACH,MAAM,UAAU,GAAG,CAAC,MAAM,QAAQ,CAAC,IAAI,CAAC,CAAC,CAAC,QAAQ,EAAE,CAAC;QAErD,IAAI,UAAU,KAAK,OAAO,EAAE,CAAC;YAC3B,GAAG,CAAC,OAAO,EAAE,gCAAgC,IAAI,IAAI,CAAC,CAAC;YACvD,OAAO;QACT,CAAC;IACH,CAAC;IAAC,OAAO,GAAG,EAAE,CAAC;QACb,GAAG,CAAC,OAAO,EAAE,yBAAyB,IAAI,IAAI,CAAC,CAAC;QAChD,GAAG,CAAC,aAAa,EAAE,eAAe,CAAC,GAAY,CAAC,CAAC,CAAC;QAClD,OAAO,MAAM,SAAS,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC;IACxC,CAAC;IACD,GAAG,CAAC,OAAO,EAAE,6BAA6B,IAAI,IAAI,CAAC,CAAC;IACpD,OAAO,MAAM,SAAS,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC;AACxC,CAAC"}
|
|
@@ -1,17 +1,18 @@
|
|
|
1
1
|
import { Knifecycle, type Injector, type Autoloader, type Initializer, type Dependencies, type Service } from 'knifecycle';
|
|
2
|
-
import { type WhookBuildConstantsService } from '@whook/whook';
|
|
2
|
+
import { type WhookOpenAPI, type WhookBuildConstantsService, type WhookRouteDefinition } from '@whook/whook';
|
|
3
3
|
import { type LogService } from 'common-services';
|
|
4
|
-
|
|
4
|
+
export type GCPFunctionDefinition = {
|
|
5
|
+
name: string;
|
|
6
|
+
type: 'route';
|
|
7
|
+
definition: WhookRouteDefinition;
|
|
8
|
+
openAPI: WhookOpenAPI;
|
|
9
|
+
};
|
|
5
10
|
export type WhookGoogleFunctionsAutoloadDependencies = {
|
|
6
11
|
BUILD_CONSTANTS?: WhookBuildConstantsService;
|
|
7
12
|
$injector: Injector<Service>;
|
|
8
13
|
$instance: Knifecycle;
|
|
9
14
|
log?: LogService;
|
|
10
15
|
};
|
|
11
|
-
export declare const GCP_WRAPPERS: Record<Required<WhookAPIOperationGCPFunctionConfig>['type'], {
|
|
12
|
-
name: string;
|
|
13
|
-
initializer: Initializer<Service, Dependencies>;
|
|
14
|
-
}>;
|
|
15
16
|
/**
|
|
16
17
|
* Wrap the _autoload service in order to build for GCP
|
|
17
18
|
* Functions compatible code.
|
|
@@ -28,12 +29,16 @@ export declare const GCP_WRAPPERS: Record<Required<WhookAPIOperationGCPFunctionC
|
|
|
28
29
|
* @return {Promise<Object>}
|
|
29
30
|
* A promise of an object containing the reshaped env vars.
|
|
30
31
|
*/
|
|
31
|
-
declare const _default: import("knifecycle").ServiceInitializer<Dependencies<any> & import("@whook/whook").
|
|
32
|
+
declare const _default: import("knifecycle").ServiceInitializer<Dependencies<any> & import("@whook/whook").WhookRoutesWrappersConfig & import("@whook/whook").WhookCronsWrappersConfig & import("@whook/whook").WhookConsumersWrappersConfig & import("@whook/whook").WhookTransformersWrappersConfig & {
|
|
32
33
|
APP_CONFIG?: import("application-services").AppConfig;
|
|
33
34
|
INITIALIZER_PATH_MAP?: import("@whook/whook").WhookInitializerMap;
|
|
34
35
|
WHOOK_PLUGINS?: import("@whook/whook").WhookPluginName[];
|
|
35
|
-
WHOOK_RESOLVED_PLUGINS: import("@whook/whook
|
|
36
|
-
|
|
36
|
+
WHOOK_RESOLVED_PLUGINS: import("@whook/whook").WhookResolvedPluginsService;
|
|
37
|
+
ROUTES_DEFINITIONS_OPTIONS?: import("@whook/whook").WhookRoutesDefinitionsOptions;
|
|
38
|
+
CRONS_DEFINITIONS_OPTIONS?: import("@whook/whook").WhookCronDefinitionsOptions;
|
|
39
|
+
CONSUMERS_DEFINITIONS_OPTIONS?: import("@whook/whook").WhookConsumerDefinitionsOptions;
|
|
40
|
+
TRANSFORMERS_DEFINITIONS_OPTIONS?: import("@whook/whook").WhookTransformerDefinitionsOptions;
|
|
41
|
+
args: import("@whook/whook").WhookRawCommandArgs;
|
|
37
42
|
$injector: import("knifecycle").Injector<Service>;
|
|
38
43
|
importer: import("common-services").ImporterService<{
|
|
39
44
|
default: Initializer<Service, Dependencies>;
|