@whook/gcp-functions 18.0.3 → 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 +19 -57
- package/dist/commands/testGCPFunctionRoute.d.ts +50 -0
- package/dist/commands/{testHTTPFunction.js → testGCPFunctionRoute.js} +44 -46
- package/dist/commands/testGCPFunctionRoute.js.map +1 -0
- package/dist/index.d.ts +8 -7
- package/dist/index.js +50 -54
- package/dist/index.js.map +1 -1
- package/dist/libs/utils.d.ts +1 -1
- package/dist/libs/utils.js +1 -1
- package/dist/libs/utils.js.map +1 -1
- package/dist/services/_autoload.d.ts +16 -12
- package/dist/services/_autoload.js +49 -63
- 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 +11 -10
- package/src/commands/{testHTTPFunction.ts → testGCPFunctionRoute.ts} +73 -75
- package/src/index.ts +100 -104
- package/src/libs/utils.ts +2 -2
- package/src/services/_autoload.ts +90 -117
- 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 -11
- 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 -23
- package/dist/wrappers/wrapHandlerForGoogleHTTPFunction.js +0 -272
- package/dist/wrappers/wrapHandlerForGoogleHTTPFunction.js.map +0 -1
- package/src/services/HANDLER.ts +0 -43
- package/src/services/log.ts +0 -7
- package/src/wrappers/wrapHandlerForGoogleHTTPFunction.ts +0 -482
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 {
|
|
@@ -97,10 +96,10 @@ Declare this module types in your `src/whook.d.ts` type definitions:
|
|
|
97
96
|
|
|
98
97
|
```diff
|
|
99
98
|
// ...
|
|
100
|
-
+ import type
|
|
101
|
-
+ import
|
|
102
|
-
+
|
|
103
|
-
+
|
|
99
|
+
+ import { type WhookCompilerConfig } from '@whook/whook';
|
|
100
|
+
+ import {
|
|
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
|
|
|
@@ -139,7 +129,7 @@ And add the GCP Functions config (usually in `src/config/common/config.js`):
|
|
|
139
129
|
|
|
140
130
|
```diff
|
|
141
131
|
// ...
|
|
142
|
-
import type
|
|
132
|
+
import { type AppConfig } from 'application-services';
|
|
143
133
|
|
|
144
134
|
// ...
|
|
145
135
|
|
|
@@ -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,86 +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
|
-
import
|
|
5
|
-
import
|
|
6
|
-
import camelCase from 'camelcase';
|
|
7
|
-
import { DEFAULT_COMPILER_OPTIONS, readArgs } from '@whook/whook';
|
|
8
|
-
const SEARCH_SEPARATOR = '?';
|
|
9
|
-
const PATH_SEPARATOR = '/';
|
|
4
|
+
import stream from 'node:stream';
|
|
5
|
+
import { DEFAULT_COMPILER_OPTIONS, PATH_SEPARATOR, SEARCH_SEPARATOR, } from '@whook/whook';
|
|
10
6
|
export const definition = {
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
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: {
|
|
20
16
|
type: 'string',
|
|
21
17
|
},
|
|
22
|
-
|
|
23
|
-
|
|
18
|
+
},
|
|
19
|
+
{
|
|
20
|
+
name: 'type',
|
|
21
|
+
description: 'Type of function to test',
|
|
22
|
+
schema: {
|
|
24
23
|
type: 'string',
|
|
25
24
|
enum: ['main', 'index'],
|
|
26
25
|
default: 'index',
|
|
27
26
|
},
|
|
28
|
-
|
|
29
|
-
|
|
27
|
+
},
|
|
28
|
+
{
|
|
29
|
+
name: 'contentType',
|
|
30
|
+
description: 'Content type of the payload',
|
|
31
|
+
schema: {
|
|
30
32
|
type: 'string',
|
|
31
33
|
default: 'application/json',
|
|
32
34
|
},
|
|
33
|
-
|
|
34
|
-
|
|
35
|
+
},
|
|
36
|
+
{
|
|
37
|
+
name: 'parameters',
|
|
38
|
+
description: 'The HTTP call parameters',
|
|
39
|
+
schema: {
|
|
35
40
|
type: 'string',
|
|
36
41
|
default: '{}',
|
|
37
42
|
},
|
|
38
43
|
},
|
|
39
|
-
|
|
44
|
+
],
|
|
40
45
|
};
|
|
41
|
-
|
|
42
|
-
async
|
|
43
|
-
|
|
44
|
-
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;
|
|
45
49
|
const extension = COMPILER_OPTIONS.format === 'cjs' ? '.cjs' : '.mjs';
|
|
46
50
|
const handler = await loadFunction({ APP_ENV, PROJECT_DIR, log }, name, type, extension);
|
|
47
|
-
const
|
|
48
|
-
if (!
|
|
51
|
+
const handlerDefinition = ROUTES_DEFINITIONS[name]?.module?.definition;
|
|
52
|
+
if (!handlerDefinition) {
|
|
49
53
|
throw new YError('E_OPERATION_NOT_FOUND');
|
|
50
54
|
}
|
|
51
|
-
const hasBody = !!
|
|
55
|
+
const hasBody = !!handlerDefinition.operation.requestBody;
|
|
52
56
|
const parameters = JSON.parse(rawParameters);
|
|
53
|
-
const search = (
|
|
54
|
-
|
|
55
|
-
.reduce((accSearch, p) => {
|
|
56
|
-
if (null != parameters[p.name]) {
|
|
57
|
+
const search = Object.keys(parameters.query || {}).reduce((accSearch, name) => {
|
|
58
|
+
if (null != parameters.query[name]) {
|
|
57
59
|
return (accSearch +
|
|
58
60
|
(accSearch ? '&' : '') +
|
|
59
|
-
|
|
61
|
+
name +
|
|
60
62
|
'=' +
|
|
61
|
-
parameters[
|
|
63
|
+
parameters.query[name]);
|
|
62
64
|
}
|
|
63
65
|
return accSearch;
|
|
64
66
|
}, '');
|
|
65
|
-
const path =
|
|
67
|
+
const path = handlerDefinition.path
|
|
66
68
|
.split(PATH_SEPARATOR)
|
|
67
69
|
.map((part) => {
|
|
68
70
|
const matches = /^\{([\d\w]+)\}$/i.exec(part);
|
|
69
71
|
if (matches) {
|
|
70
|
-
return parameters[matches[1]];
|
|
72
|
+
return parameters.path?.[matches[1]];
|
|
71
73
|
}
|
|
72
74
|
return part;
|
|
73
75
|
})
|
|
74
76
|
.join(PATH_SEPARATOR);
|
|
75
77
|
const gcpfRequest = {
|
|
76
|
-
method:
|
|
78
|
+
method: handlerDefinition.method,
|
|
77
79
|
originalUrl: path + (search ? SEARCH_SEPARATOR + search : ''),
|
|
78
|
-
headers:
|
|
79
|
-
.filter((p) => p.in === 'header')
|
|
80
|
-
.reduce((headerParameters, p) => {
|
|
81
|
-
headerParameters[p.name] = parameters[camelCase(p.name)];
|
|
82
|
-
return headerParameters;
|
|
83
|
-
}, {}),
|
|
80
|
+
headers: parameters.header || {},
|
|
84
81
|
rawBody: Buffer.from(hasBody
|
|
85
82
|
? contentType === 'application/json'
|
|
86
83
|
? parameters.body
|
|
@@ -125,4 +122,5 @@ async function initTestHTTPFunctionCommand({ APP_ENV, PROJECT_DIR, COMPILER_OPTI
|
|
|
125
122
|
log('info', 'SUCCESS:', response);
|
|
126
123
|
};
|
|
127
124
|
}
|
|
128
|
-
|
|
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;YACn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EAAE,CAAC;oBACpC,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;gBACpB,CAAC;YACH,CAAC,CAAC,CAAC;QACL,CAAC,CAAC,CAAC;QACH,GAAG,CAAC,MAAM,EAAE,UAAU,EAAE,QAAQ,CAAC,CAAC;IACpC,CAAC,CAAC;AACJ,CAAC;AAED,eAAe,QAAQ,CACrB,WAAW,CAAC,+BAA+B,CAAC,EAC5C,MAAM,CAAC,IAAI,CAAC,GAAG,CAChB,CAAC"}
|
package/dist/index.d.ts
CHANGED
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
import { Knifecycle } from 'knifecycle';
|
|
2
|
-
import type
|
|
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
|
@@ -6,16 +6,17 @@ import { pathToFileURL } from 'node:url';
|
|
|
6
6
|
import { mkdirp } from 'mkdirp';
|
|
7
7
|
import cpr from 'cpr';
|
|
8
8
|
import { printStackTrace, YError } from 'yerror';
|
|
9
|
-
import { Knifecycle, constant, initInitializerBuilder } from 'knifecycle';
|
|
10
|
-
import { DEFAULT_BUILD_INITIALIZER_PATH_MAP as BASE_DEFAULT_BUILD_INITIALIZER_PATH_MAP, initCompiler, } from '@whook/whook';
|
|
9
|
+
import { Knifecycle, constant, initInitializerBuilder, } from 'knifecycle';
|
|
11
10
|
import initBuildAutoloader from './services/_autoload.js';
|
|
12
|
-
import {
|
|
11
|
+
import { DEFAULT_BUILD_INITIALIZER_PATH_MAP as BASE_DEFAULT_BUILD_INITIALIZER_PATH_MAP, initCompiler, } from '@whook/whook';
|
|
13
12
|
import { parseArgs } from '@whook/whook/dist/libs/args.js';
|
|
13
|
+
import initWrapRouteHandlerForGoogleHTTPFunction from './wrappers/wrapRouteHandlerForGoogleHTTPFunction.js';
|
|
14
14
|
export const DEFAULT_BUILD_PARALLELISM = 10;
|
|
15
15
|
export const DEFAULT_BUILD_INITIALIZER_PATH_MAP = {
|
|
16
16
|
...BASE_DEFAULT_BUILD_INITIALIZER_PATH_MAP,
|
|
17
|
-
log: '@whook/
|
|
17
|
+
log: '@whook/whook/dist/services/rawLog.js',
|
|
18
18
|
};
|
|
19
|
+
export { initWrapRouteHandlerForGoogleHTTPFunction };
|
|
19
20
|
const cprAsync = promisify(cpr);
|
|
20
21
|
export async function prepareBuildEnvironment($ = new Knifecycle()) {
|
|
21
22
|
$.register(initInitializerBuilder);
|
|
@@ -31,7 +32,7 @@ export async function runBuild(aPrepareBuildEnvironment) {
|
|
|
31
32
|
try {
|
|
32
33
|
const handlerName = argv[2];
|
|
33
34
|
const $ = await aPrepareBuildEnvironment();
|
|
34
|
-
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([
|
|
35
36
|
'APP_ENV',
|
|
36
37
|
'?BUILD_PARALLELISM',
|
|
37
38
|
'PROJECT_DIR',
|
|
@@ -39,28 +40,22 @@ export async function runBuild(aPrepareBuildEnvironment) {
|
|
|
39
40
|
'compiler',
|
|
40
41
|
'log',
|
|
41
42
|
'$autoload',
|
|
42
|
-
'
|
|
43
|
+
'DEFINITIONS',
|
|
43
44
|
'buildInitializer',
|
|
44
45
|
]);
|
|
45
46
|
log('info', 'GCP Functions build Environment initialized 🚀🌕');
|
|
46
|
-
const
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
return (handlerName === operation.operationId ||
|
|
50
|
-
handlerName === sourceOperationId);
|
|
51
|
-
}
|
|
52
|
-
return true;
|
|
53
|
-
});
|
|
54
|
-
log('warning', `📃 - ${operations.length} operations to process.`);
|
|
55
|
-
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({
|
|
56
50
|
APP_ENV,
|
|
57
51
|
BUILD_PARALLELISM: BUILD_PARALLELISM || DEFAULT_BUILD_PARALLELISM,
|
|
58
52
|
PROJECT_DIR,
|
|
53
|
+
DEFINITIONS,
|
|
59
54
|
compiler,
|
|
60
55
|
log,
|
|
61
56
|
$autoload,
|
|
62
57
|
buildInitializer,
|
|
63
|
-
},
|
|
58
|
+
}, handlerNames);
|
|
64
59
|
await $.destroy();
|
|
65
60
|
}
|
|
66
61
|
catch (err) {
|
|
@@ -68,58 +63,59 @@ export async function runBuild(aPrepareBuildEnvironment) {
|
|
|
68
63
|
exit(1);
|
|
69
64
|
}
|
|
70
65
|
}
|
|
71
|
-
async function
|
|
72
|
-
const
|
|
73
|
-
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({
|
|
74
69
|
APP_ENV,
|
|
75
70
|
PROJECT_DIR,
|
|
71
|
+
DEFINITIONS,
|
|
76
72
|
compiler,
|
|
77
73
|
log,
|
|
78
74
|
buildInitializer,
|
|
79
|
-
},
|
|
80
|
-
if (
|
|
81
|
-
log('info', `📃 - ${
|
|
82
|
-
return
|
|
75
|
+
}, handlerName)));
|
|
76
|
+
if (handlerNamesLeft.length) {
|
|
77
|
+
log('info', `📃 - ${handlerNamesLeft.length} handlerNames left.`);
|
|
78
|
+
return processHandlers({
|
|
83
79
|
APP_ENV,
|
|
84
80
|
BUILD_PARALLELISM,
|
|
85
81
|
PROJECT_DIR,
|
|
82
|
+
DEFINITIONS,
|
|
86
83
|
compiler,
|
|
87
84
|
log,
|
|
88
85
|
$autoload,
|
|
89
86
|
buildInitializer,
|
|
90
|
-
},
|
|
87
|
+
}, handlerNamesLeft);
|
|
91
88
|
}
|
|
92
|
-
log('info', '🤷 - No more
|
|
89
|
+
log('info', '🤷 - No more handlerNames.');
|
|
93
90
|
}
|
|
94
|
-
async function
|
|
95
|
-
const { operationId } = operation;
|
|
91
|
+
async function buildHandler({ APP_ENV, PROJECT_DIR, DEFINITIONS, compiler, log, buildInitializer, }, handlerName) {
|
|
96
92
|
try {
|
|
97
|
-
const
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
log('warning', `🏗 - Building
|
|
103
|
-
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);
|
|
104
100
|
const srcPath = join(PROJECT_DIR, 'src');
|
|
105
|
-
const srcRelativePath = relative(
|
|
106
|
-
const initializerContent = (await buildInitializer([`
|
|
107
|
-
const indexContent = await
|
|
108
|
-
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);
|
|
109
105
|
await Promise.all([
|
|
110
|
-
copyStaticFiles({ PROJECT_DIR, log },
|
|
111
|
-
ensureFile({ log }, join(
|
|
112
|
-
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),
|
|
113
109
|
]);
|
|
114
|
-
await
|
|
110
|
+
await buildFinalHandler({ DEFINITIONS, compiler, log }, handlerPath, handlerName);
|
|
115
111
|
}
|
|
116
112
|
catch (err) {
|
|
117
|
-
log('error',
|
|
113
|
+
log('error', `💥 - Error building "${handlerName}"...`);
|
|
118
114
|
log('error-stack', printStackTrace(err));
|
|
119
|
-
throw YError.wrap(err, '
|
|
115
|
+
throw YError.wrap(err, 'E_HANDLER_BUILD', handlerName);
|
|
120
116
|
}
|
|
121
117
|
}
|
|
122
|
-
async function
|
|
118
|
+
async function buildHandlerIndex(handlerName) {
|
|
123
119
|
return `// Automatically generated by \`@whook/gcp-functions\`
|
|
124
120
|
import { initialize } from './initialize.js';
|
|
125
121
|
|
|
@@ -127,22 +123,22 @@ const initializationPromise = initialize();
|
|
|
127
123
|
|
|
128
124
|
export default function handler (req, res) {
|
|
129
125
|
return initializationPromise
|
|
130
|
-
.then(services => services['${
|
|
126
|
+
.then(services => services['${handlerName}'](req, res));
|
|
131
127
|
};
|
|
132
128
|
`;
|
|
133
129
|
}
|
|
134
|
-
async function
|
|
135
|
-
const entryPoint = `${
|
|
136
|
-
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);
|
|
137
133
|
await Promise.all([
|
|
138
|
-
ensureFile({ log }, join(
|
|
134
|
+
ensureFile({ log }, join(handlerPath, `/index${extension}`), contents),
|
|
139
135
|
mappings
|
|
140
|
-
? ensureFile({ log }, join(
|
|
136
|
+
? ensureFile({ log }, join(handlerPath, `/index${extension}.map`), mappings)
|
|
141
137
|
: Promise.resolve(),
|
|
142
138
|
]);
|
|
143
139
|
}
|
|
144
|
-
async function copyStaticFiles({ PROJECT_DIR, log },
|
|
145
|
-
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))));
|
|
146
142
|
}
|
|
147
143
|
async function copyFiles({ log }, source, destination) {
|
|
148
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,MAAM,EAAE,MAAM,QAAQ,CAAC;AAChC,OAAO,GAAG,MAAM,KAAK,CAAC;AACtB,OAAO,EAAE,eAAe,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AACjD,OAAO,
|
|
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,MAAM,EAAE,MAAM,QAAQ,CAAC;AAChC,OAAO,GAAG,MAAM,KAAK,CAAC;AACtB,OAAO,EAAE,eAAe,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AACjD,OAAO,EACL,UAAU,EACV,QAAQ,EACR,sBAAsB,GAMvB,M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D,CAAC;IAAC,OAAO,GAAG,EAAE,CAAC;QACb,QAAQ,GAAG,GAAa,CAAC;IAC3B,CAAC;IACD,IAAI,QAAQ,EAAE,CAAC;QACb,IAAI,QAAQ,KAAK,QAAQ,CAAC,IAAI,EAAE,CAAC;YAC/B,MAAM,QAAQ,CAAC;QACjB,CAAC;QACD,MAAM,QAAQ,CAAC,MAAM,EAAE,WAAW,EAAE;YAClC,SAAS,EAAE,IAAI;SAChB,CAAC,CAAC;IACL,CAAC;AACH,CAAC;AAED,KAAK,UAAU,UAAU,CACvB,EAAE,GAAG,EAAuB,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"}
|
package/dist/libs/utils.d.ts
CHANGED
package/dist/libs/utils.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { YError } from 'yerror';
|
|
2
|
-
import path from 'path';
|
|
2
|
+
import path from 'node:path';
|
|
3
3
|
export async function loadFunction({ PROJECT_DIR, APP_ENV, log, }, operationId, type, extension = '.mjs') {
|
|
4
4
|
const modulePath = path.join(PROJECT_DIR, 'builds', APP_ENV, operationId, type + extension);
|
|
5
5
|
log('debug', `⛏️ - Loading function module at path "${modulePath}".`);
|
package/dist/libs/utils.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.js","sourceRoot":"","sources":["../../src/libs/utils.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAChC,OAAO,IAAI,MAAM,
|
|
1
|
+
{"version":3,"file":"utils.js","sourceRoot":"","sources":["../../src/libs/utils.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAChC,OAAO,IAAI,MAAM,WAAW,CAAC;AAG7B,MAAM,CAAC,KAAK,UAAU,YAAY,CAChC,EACE,WAAW,EACX,OAAO,EACP,GAAG,GAKJ,EACD,WAAmB,EACnB,IAAY,EACZ,SAAS,GAAG,MAAM;IAGlB,MAAM,UAAU,GAAG,IAAI,CAAC,IAAI,CAC1B,WAAW,EACX,QAAQ,EACR,OAAO,EACP,WAAW,EACX,IAAI,GAAG,SAAS,CACjB,CAAC;IAEF,GAAG,CAAC,OAAO,EAAE,yCAAyC,UAAU,IAAI,CAAC,CAAC;IAEtE,IAAI,CAAC;QACH,MAAM,MAAM,GAAG,MAAM,MAAM,CAAC,UAAU,CAAC,CAAC;QAExC,IAAI,CAAC,MAAM,EAAE,CAAC;YACZ,MAAM,IAAI,MAAM,CAAC,oBAAoB,EAAE,MAAM,CAAC,CAAC;QACjD,CAAC;QAED,IAAI,CAAC,MAAM,CAAC,OAAO,EAAE,CAAC;YACpB,MAAM,IAAI,MAAM,CAAC,oBAAoB,EAAE,MAAM,EAAE,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC;QACtE,CAAC;QAED,OAAO,MAAM,CAAC,OAAO,CAAC;IACxB,CAAC;IAAC,OAAO,GAAG,EAAE,CAAC;QACb,MAAM,MAAM,CAAC,IAAI,CAAC,GAAY,EAAE,eAAe,CAAC,CAAC;IACnD,CAAC;AACH,CAAC"}
|