@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
|
@@ -1,18 +1,18 @@
|
|
|
1
|
-
import { Knifecycle } from 'knifecycle';
|
|
2
|
-
import
|
|
3
|
-
import type
|
|
4
|
-
|
|
5
|
-
|
|
1
|
+
import { Knifecycle, type Injector, type Autoloader, type Initializer, type Dependencies, type Service } from 'knifecycle';
|
|
2
|
+
import { type WhookOpenAPI, type WhookBuildConstantsService, type WhookRouteDefinition } from '@whook/whook';
|
|
3
|
+
import { type LogService } from 'common-services';
|
|
4
|
+
export type GCPFunctionDefinition = {
|
|
5
|
+
name: string;
|
|
6
|
+
type: 'route';
|
|
7
|
+
definition: WhookRouteDefinition;
|
|
8
|
+
openAPI: WhookOpenAPI;
|
|
9
|
+
};
|
|
6
10
|
export type WhookGoogleFunctionsAutoloadDependencies = {
|
|
7
11
|
BUILD_CONSTANTS?: WhookBuildConstantsService;
|
|
8
12
|
$injector: Injector<Service>;
|
|
9
13
|
$instance: Knifecycle;
|
|
10
14
|
log?: LogService;
|
|
11
15
|
};
|
|
12
|
-
export declare const GCP_WRAPPERS: Record<Required<WhookAPIOperationGCPFunctionConfig>['type'], {
|
|
13
|
-
name: string;
|
|
14
|
-
initializer: Initializer<Service, Dependencies>;
|
|
15
|
-
}>;
|
|
16
16
|
/**
|
|
17
17
|
* Wrap the _autoload service in order to build for GCP
|
|
18
18
|
* Functions compatible code.
|
|
@@ -29,12 +29,16 @@ export declare const GCP_WRAPPERS: Record<Required<WhookAPIOperationGCPFunctionC
|
|
|
29
29
|
* @return {Promise<Object>}
|
|
30
30
|
* A promise of an object containing the reshaped env vars.
|
|
31
31
|
*/
|
|
32
|
-
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 & {
|
|
33
33
|
APP_CONFIG?: import("application-services").AppConfig;
|
|
34
34
|
INITIALIZER_PATH_MAP?: import("@whook/whook").WhookInitializerMap;
|
|
35
35
|
WHOOK_PLUGINS?: import("@whook/whook").WhookPluginName[];
|
|
36
|
-
WHOOK_RESOLVED_PLUGINS: import("@whook/whook
|
|
37
|
-
|
|
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;
|
|
38
42
|
$injector: import("knifecycle").Injector<Service>;
|
|
39
43
|
importer: import("common-services").ImporterService<{
|
|
40
44
|
default: Initializer<Service, Dependencies>;
|
|
@@ -1,86 +1,72 @@
|
|
|
1
1
|
/* eslint-disable @typescript-eslint/no-explicit-any */
|
|
2
|
-
import {
|
|
3
|
-
import { UNBUILDABLE_SERVICES, wrapInitializer, constant, alsoInject, location, } from 'knifecycle';
|
|
2
|
+
import { wrapInitializer, constant, alsoInject, location, } from 'knifecycle';
|
|
4
3
|
import { YError } from 'yerror';
|
|
5
|
-
import {
|
|
6
|
-
import
|
|
7
|
-
import
|
|
8
|
-
export const GCP_WRAPPERS = {
|
|
9
|
-
http: {
|
|
10
|
-
name: 'wrapHandlerForGoogleHTTPFunction',
|
|
11
|
-
initializer: initWrapHandlerForGoogleHTTPFunction,
|
|
12
|
-
},
|
|
13
|
-
};
|
|
4
|
+
import { initBuildAutoload, initMainHandler, noop, } from '@whook/whook';
|
|
5
|
+
import { cleanupOpenAPI } from 'ya-open-api-types';
|
|
6
|
+
import initWrapRouteHandlerForGoogleHTTPFunction from '../wrappers/wrapRouteHandlerForGoogleHTTPFunction.js';
|
|
14
7
|
const initializerWrapper = (async ({ $injector, log = noop }, $autoload) => {
|
|
15
8
|
let API;
|
|
16
|
-
let
|
|
17
|
-
|
|
9
|
+
let DEFINITIONS;
|
|
10
|
+
let ROUTES_DEFINITIONS;
|
|
11
|
+
const getDefinition = (() => {
|
|
18
12
|
return async (serviceName) => {
|
|
19
13
|
const cleanedName = serviceName.split('_').pop();
|
|
20
14
|
API = API || (await $injector(['API'])).API;
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
log('error', '💥 - Unable to find a function operation definition!');
|
|
31
|
-
throw new YError('E_OPERATION_NOT_FOUND', serviceName);
|
|
15
|
+
DEFINITIONS =
|
|
16
|
+
DEFINITIONS || (await $injector(['DEFINITIONS'])).DEFINITIONS;
|
|
17
|
+
ROUTES_DEFINITIONS =
|
|
18
|
+
ROUTES_DEFINITIONS ||
|
|
19
|
+
(await $injector(['ROUTES_DEFINITIONS'])).ROUTES_DEFINITIONS;
|
|
20
|
+
const config = DEFINITIONS.configs[cleanedName];
|
|
21
|
+
if (!config) {
|
|
22
|
+
log('error', '💥 - Unable to find a GCP Function definition!');
|
|
23
|
+
throw new YError('E_DEFINITION_NOT_FOUND', serviceName, cleanedName);
|
|
32
24
|
}
|
|
33
|
-
|
|
25
|
+
if (!config || config.type !== 'route') {
|
|
26
|
+
log('error', '💥 - GCP Function only supports routes!');
|
|
27
|
+
throw new YError('E_UNSUPPORTED_DEFINITION', serviceName, cleanedName);
|
|
28
|
+
}
|
|
29
|
+
const openAPI = (await cleanupOpenAPI({
|
|
34
30
|
...API,
|
|
35
31
|
paths: {
|
|
36
|
-
[
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
},
|
|
40
|
-
});
|
|
41
|
-
return [
|
|
42
|
-
OPERATION['x-whook']?.type || 'http',
|
|
43
|
-
OPERATION.operationId,
|
|
44
|
-
{
|
|
45
|
-
...OPERATION_API,
|
|
46
|
-
paths: {
|
|
47
|
-
[OPERATION.path]: {
|
|
48
|
-
[OPERATION.method]: (await dereferenceOpenAPIOperations(OPERATION_API, [
|
|
49
|
-
{
|
|
50
|
-
path: OPERATION.path,
|
|
51
|
-
method: OPERATION.method,
|
|
52
|
-
...OPERATION_API.paths?.[OPERATION.path]?.[OPERATION.method],
|
|
53
|
-
parameters: OPERATION.parameters,
|
|
54
|
-
},
|
|
55
|
-
]))[0],
|
|
56
|
-
},
|
|
32
|
+
[config.path]: {
|
|
33
|
+
parameters: API?.paths?.[config.path]?.parameters || [],
|
|
34
|
+
[config.method]: API.paths?.[config.path]?.[config.method],
|
|
57
35
|
},
|
|
58
36
|
},
|
|
59
|
-
|
|
37
|
+
}));
|
|
38
|
+
return {
|
|
39
|
+
name: cleanedName,
|
|
40
|
+
type: 'route',
|
|
41
|
+
openAPI,
|
|
42
|
+
definition: ROUTES_DEFINITIONS[cleanedName]?.module?.definition || config,
|
|
43
|
+
};
|
|
60
44
|
};
|
|
61
45
|
})();
|
|
62
|
-
log('debug', '🤖 - Initializing the `$autoload` build wrapper.');
|
|
46
|
+
log('debug', '🤖 - Initializing the GCP Functions `$autoload` build wrapper.');
|
|
63
47
|
return async (serviceName) => {
|
|
64
|
-
if (
|
|
65
|
-
|
|
66
|
-
return constant(serviceName,
|
|
48
|
+
if (serviceName.startsWith('MAIN_API_')) {
|
|
49
|
+
const definition = await getDefinition(serviceName);
|
|
50
|
+
return constant(serviceName, definition.type === 'route' ? definition.openAPI : {});
|
|
67
51
|
}
|
|
68
|
-
if (serviceName.startsWith('
|
|
69
|
-
const
|
|
70
|
-
return constant(serviceName,
|
|
52
|
+
if (serviceName.startsWith('MAIN_DEFINITION_')) {
|
|
53
|
+
const { definition } = await getDefinition(serviceName);
|
|
54
|
+
return constant(serviceName, definition);
|
|
71
55
|
}
|
|
72
|
-
if (serviceName.startsWith('
|
|
73
|
-
const [type] = await getAPIOperation(serviceName);
|
|
56
|
+
if (serviceName.startsWith('MAIN_WRAPPER_')) {
|
|
74
57
|
return location(alsoInject([
|
|
75
|
-
`
|
|
76
|
-
|
|
58
|
+
`MAIN_DEFINITION>${serviceName.replace('MAIN_WRAPPER_', 'MAIN_DEFINITION_')}`,
|
|
59
|
+
`MAIN_API>${serviceName.replace('MAIN_WRAPPER_', 'MAIN_API_')}`,
|
|
60
|
+
], initWrapRouteHandlerForGoogleHTTPFunction), `@whook/gcp-functions/dist/wrappers/wrapRouteHandlerForGoogleHTTPFunction.js`);
|
|
77
61
|
}
|
|
78
|
-
if (serviceName.startsWith('
|
|
79
|
-
const
|
|
62
|
+
if (serviceName.startsWith('MAIN_HANDLER_')) {
|
|
63
|
+
const { type, name, definition } = await getDefinition(serviceName);
|
|
64
|
+
const targetHandler = definition.config?.targetHandler || name;
|
|
80
65
|
return location(alsoInject([
|
|
81
|
-
`
|
|
82
|
-
|
|
83
|
-
|
|
66
|
+
`MAIN_WRAPPER>MAIN_WRAPPER_${serviceName.replace('MAIN_HANDLER_', '')}`,
|
|
67
|
+
`?WRAPPERS>${type.toUpperCase()}S_WRAPPERS`,
|
|
68
|
+
`BASE_HANDLER>${targetHandler}`,
|
|
69
|
+
], initMainHandler), '@whook/whook/dist/services/MAIN_HANDLER.js');
|
|
84
70
|
}
|
|
85
71
|
return await $autoload(serviceName);
|
|
86
72
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"_autoload.js","sourceRoot":"","sources":["../../src/services/_autoload.ts"],"names":[],"mappings":"AAAA,uDAAuD;AACvD,OAAO,
|
|
1
|
+
{"version":3,"file":"_autoload.js","sourceRoot":"","sources":["../../src/services/_autoload.ts"],"names":[],"mappings":"AAAA,uDAAuD;AACvD,OAAO,EAEL,eAAe,EACf,QAAQ,EACR,UAAU,EACV,QAAQ,GAOT,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outeHandlerWrapper, type WhookErrorHandler, type WhookOpenAPI, type WhookCoercionOptions, type WhookRouteDefinition, type WhookSchemaValidatorsService, type WhookQueryParserBuilderService } from '@whook/whook';
|
|
2
|
+
import { type LogService } from 'common-services';
|
|
3
|
+
export type WhookGCPFunctionRouteWrapperDependencies = {
|
|
4
|
+
MAIN_DEFINITION: WhookRouteDefinition;
|
|
5
|
+
MAIN_API: WhookOpenAPI;
|
|
6
|
+
DECODERS?: typeof DEFAULT_DECODERS;
|
|
7
|
+
ENCODERS?: typeof DEFAULT_ENCODERS;
|
|
8
|
+
PARSERS?: typeof DEFAULT_PARSERS;
|
|
9
|
+
STRINGIFYERS?: typeof DEFAULT_STRINGIFYERS;
|
|
10
|
+
queryParserBuilder: WhookQueryParserBuilderService;
|
|
11
|
+
BUFFER_LIMIT?: string;
|
|
12
|
+
COERCION_OPTIONS: WhookCoercionOptions;
|
|
13
|
+
obfuscator: WhookObfuscatorService;
|
|
14
|
+
errorHandler: WhookErrorHandler;
|
|
15
|
+
schemaValidators: WhookSchemaValidatorsService;
|
|
16
|
+
log?: LogService;
|
|
17
|
+
};
|
|
18
|
+
declare const _default: import("knifecycle").ServiceInitializer<WhookGCPFunctionRouteWrapperDependencies, WhookRouteHandlerWrapper>;
|
|
19
|
+
export default _default;
|
|
@@ -0,0 +1,307 @@
|
|
|
1
|
+
import { YError, printStackTrace } from 'yerror';
|
|
2
|
+
import stream from 'node:stream';
|
|
3
|
+
import { autoService } from 'knifecycle';
|
|
4
|
+
import bytes from 'bytes';
|
|
5
|
+
import { YHTTPError } from 'yhttperror';
|
|
6
|
+
import { DEFAULT_COERCION_OPTIONS, DEFAULT_BUFFER_LIMIT, DEFAULT_PARSERS, DEFAULT_STRINGIFYERS, DEFAULT_DECODERS, DEFAULT_ENCODERS, SEARCH_SEPARATOR, PATH_SEPARATOR, extractOperationSecurityParameters, prepareBodyValidator, extractBodySpec, extractResponseSpec, checkResponseCharset, checkResponseMediaType, executeHandler, extractProduceableMediaTypes, extractConsumableMediaTypes, getBody, sendBody, noop, identity, lowerCaseHeaders, resolveParameters, createParametersValidators, pickFirstHeaderValue, } from '@whook/whook';
|
|
7
|
+
import { ensureResolvedObject, } from 'ya-open-api-types';
|
|
8
|
+
/**
|
|
9
|
+
* Wrap an handler to make it work with GCP Functions.
|
|
10
|
+
* @param {Object} services
|
|
11
|
+
* The services the wrapper depends on
|
|
12
|
+
* @param {Object} services.MAIN_DEFINITION
|
|
13
|
+
* An OpenAPI definitition for that handler
|
|
14
|
+
* @param {Object} services.DECODERS
|
|
15
|
+
* Request body decoders available
|
|
16
|
+
* @param {Object} services.ENCODERS
|
|
17
|
+
* Response body encoders available
|
|
18
|
+
* @param {Object} services.PARSERS
|
|
19
|
+
* Request body parsers available
|
|
20
|
+
* @param {Object} services.STRINGIFYERS
|
|
21
|
+
* Response body stringifyers available
|
|
22
|
+
* @param {Object} services.BUFFER_LIMIT
|
|
23
|
+
* The buffer size limit
|
|
24
|
+
* @param {Object} services.queryParserBuilder
|
|
25
|
+
* A query parser builder from OpenAPI parameters
|
|
26
|
+
* @param {Object} services.obfuscator
|
|
27
|
+
* A service to hide sensible values
|
|
28
|
+
* @param {Object} services.errorHandler
|
|
29
|
+
* A service that changes any error to Whook response
|
|
30
|
+
* @param {Object} [services.log=noop]
|
|
31
|
+
* An optional logging service
|
|
32
|
+
* @return {Promise<Object>}
|
|
33
|
+
* A promise of an object containing the reshaped env vars.
|
|
34
|
+
*/
|
|
35
|
+
async function initWrapRouteHandlerForGoogleHTTPFunction({ MAIN_DEFINITION, MAIN_API, DECODERS = DEFAULT_DECODERS, ENCODERS = DEFAULT_ENCODERS, PARSERS = DEFAULT_PARSERS, STRINGIFYERS = DEFAULT_STRINGIFYERS, BUFFER_LIMIT = DEFAULT_BUFFER_LIMIT, queryParserBuilder, COERCION_OPTIONS = DEFAULT_COERCION_OPTIONS, obfuscator, errorHandler, schemaValidators, log = noop, }) {
|
|
36
|
+
log('debug', '📥 - Initializing the GCP Function wrapper.');
|
|
37
|
+
const path = MAIN_DEFINITION.path;
|
|
38
|
+
const pathItem = MAIN_API.paths?.[path];
|
|
39
|
+
if (typeof pathItem === 'undefined' || '$ref' in pathItem) {
|
|
40
|
+
throw new YError('E_BAD_OPERATION', 'pathItem', pathItem);
|
|
41
|
+
}
|
|
42
|
+
const method = MAIN_DEFINITION.method;
|
|
43
|
+
const operation = pathItem[method];
|
|
44
|
+
if (typeof operation === 'undefined' || '$ref' in operation) {
|
|
45
|
+
throw new YError('E_BAD_OPERATION', 'operation', operation);
|
|
46
|
+
}
|
|
47
|
+
const pathItemParameters = await resolveParameters({ API: MAIN_API, log }, pathItem.parameters || []);
|
|
48
|
+
const pathItemValidators = await createParametersValidators({
|
|
49
|
+
API: MAIN_API,
|
|
50
|
+
COERCION_OPTIONS,
|
|
51
|
+
schemaValidators,
|
|
52
|
+
}, pathItemParameters);
|
|
53
|
+
const operationParameters = await resolveParameters({ API: MAIN_API, log }, operation.parameters || []);
|
|
54
|
+
const ammendedParameters = await resolveParameters({ API: MAIN_API, log }, await extractOperationSecurityParameters({ API: MAIN_API }, operation));
|
|
55
|
+
const operationValidators = await createParametersValidators({
|
|
56
|
+
API: MAIN_API,
|
|
57
|
+
COERCION_OPTIONS,
|
|
58
|
+
schemaValidators,
|
|
59
|
+
}, operationParameters.concat(ammendedParameters));
|
|
60
|
+
const bodyValidator = await prepareBodyValidator({ API: MAIN_API, schemaValidators }, operation);
|
|
61
|
+
const consumableCharsets = Object.keys(DECODERS);
|
|
62
|
+
const produceableCharsets = Object.keys(ENCODERS);
|
|
63
|
+
const consumableMediaTypes = await extractConsumableMediaTypes(MAIN_API, operation);
|
|
64
|
+
const produceableMediaTypes = await extractProduceableMediaTypes(MAIN_API, operation);
|
|
65
|
+
const parameters = pathItemParameters
|
|
66
|
+
.concat(ammendedParameters)
|
|
67
|
+
.filter((parameter) => operationParameters.every((aParameter) => aParameter.in !== parameter.in || aParameter.name !== parameter.name))
|
|
68
|
+
.concat(operationParameters);
|
|
69
|
+
const queryParser = await queryParserBuilder(parameters);
|
|
70
|
+
const wrapper = async (handler) => {
|
|
71
|
+
const wrappedHandler = handleForAWSHTTPFunction.bind(null, {
|
|
72
|
+
MAIN_DEFINITION,
|
|
73
|
+
MAIN_API,
|
|
74
|
+
DECODERS,
|
|
75
|
+
ENCODERS,
|
|
76
|
+
PARSERS,
|
|
77
|
+
STRINGIFYERS,
|
|
78
|
+
BUFFER_LIMIT,
|
|
79
|
+
obfuscator,
|
|
80
|
+
errorHandler,
|
|
81
|
+
log,
|
|
82
|
+
}, {
|
|
83
|
+
consumableCharsets,
|
|
84
|
+
produceableCharsets,
|
|
85
|
+
handler,
|
|
86
|
+
operation,
|
|
87
|
+
queryParser,
|
|
88
|
+
parametersValidators: {
|
|
89
|
+
path: {
|
|
90
|
+
...pathItemValidators.path,
|
|
91
|
+
...operationValidators.path,
|
|
92
|
+
},
|
|
93
|
+
query: {
|
|
94
|
+
...pathItemValidators.query,
|
|
95
|
+
...operationValidators.query,
|
|
96
|
+
},
|
|
97
|
+
header: {
|
|
98
|
+
...pathItemValidators.header,
|
|
99
|
+
...operationValidators.header,
|
|
100
|
+
},
|
|
101
|
+
cookie: {
|
|
102
|
+
...pathItemValidators.cookie,
|
|
103
|
+
...operationValidators.cookie,
|
|
104
|
+
},
|
|
105
|
+
},
|
|
106
|
+
consumableMediaTypes,
|
|
107
|
+
produceableMediaTypes,
|
|
108
|
+
bodyValidator,
|
|
109
|
+
}, MAIN_DEFINITION);
|
|
110
|
+
return wrappedHandler;
|
|
111
|
+
};
|
|
112
|
+
return wrapper;
|
|
113
|
+
}
|
|
114
|
+
async function handleForAWSHTTPFunction({ MAIN_API, DECODERS, ENCODERS, PARSERS, STRINGIFYERS, BUFFER_LIMIT, obfuscator, errorHandler, log, }, { handler, operation, parametersValidators, consumableMediaTypes, produceableMediaTypes, consumableCharsets, produceableCharsets, queryParser, bodyValidator, }, definition, req, res) {
|
|
115
|
+
const bufferLimit = bytes.parse(BUFFER_LIMIT) || bytes.parse(DEFAULT_BUFFER_LIMIT);
|
|
116
|
+
log?.('info', 'GCP_FUNCTIONS_REQUEST', JSON.stringify({
|
|
117
|
+
url: req.originalUrl,
|
|
118
|
+
method: req.method,
|
|
119
|
+
body: req.body,
|
|
120
|
+
// body: obfuscateEventBody(obfuscator, req.body),
|
|
121
|
+
headers: obfuscator.obfuscateSensibleHeaders(req.headers || {}),
|
|
122
|
+
}));
|
|
123
|
+
const request = await gcpfReqToRequest(req);
|
|
124
|
+
let response;
|
|
125
|
+
let responseLog;
|
|
126
|
+
let responseSpec;
|
|
127
|
+
log?.('debug', 'REQUEST', JSON.stringify({
|
|
128
|
+
...request,
|
|
129
|
+
body: request.body ? 'Stream' : undefined,
|
|
130
|
+
headers: obfuscator.obfuscateSensibleHeaders(request.headers),
|
|
131
|
+
}));
|
|
132
|
+
const parametersValues = {
|
|
133
|
+
query: {},
|
|
134
|
+
header: {},
|
|
135
|
+
path: {},
|
|
136
|
+
cookie: {},
|
|
137
|
+
body: undefined,
|
|
138
|
+
options: {},
|
|
139
|
+
};
|
|
140
|
+
try {
|
|
141
|
+
try {
|
|
142
|
+
const path = request.url.split(SEARCH_SEPARATOR)[0];
|
|
143
|
+
const parts = path.split(PATH_SEPARATOR).filter(identity);
|
|
144
|
+
const search = request.url.substr(request.url.split(SEARCH_SEPARATOR)[0].length);
|
|
145
|
+
const queryValues = queryParser(search);
|
|
146
|
+
const pathParameters = definition.path
|
|
147
|
+
.split(PATH_SEPARATOR)
|
|
148
|
+
.filter(identity)
|
|
149
|
+
.map((part, index) => {
|
|
150
|
+
const matches = /^\{([\d\w]+)\}$/i.exec(part);
|
|
151
|
+
if (matches) {
|
|
152
|
+
return {
|
|
153
|
+
name: matches[1],
|
|
154
|
+
value: parts[index],
|
|
155
|
+
};
|
|
156
|
+
}
|
|
157
|
+
})
|
|
158
|
+
.filter(identity)
|
|
159
|
+
.reduce((accParameters, { name, value }) => ({
|
|
160
|
+
...accParameters,
|
|
161
|
+
[name]: value,
|
|
162
|
+
}), {});
|
|
163
|
+
for (const location of Object.keys(parametersValidators)) {
|
|
164
|
+
if (location === 'query') {
|
|
165
|
+
for (const [name, validator] of Object.entries(parametersValidators.query)) {
|
|
166
|
+
parametersValues.query[name] = validator(queryValues && typeof queryValues[name] !== 'undefined'
|
|
167
|
+
? queryValues[name]?.toString()
|
|
168
|
+
: undefined);
|
|
169
|
+
}
|
|
170
|
+
}
|
|
171
|
+
else if (location === 'header') {
|
|
172
|
+
for (const [name, validator] of Object.entries(parametersValidators.header)) {
|
|
173
|
+
// header names are case insensitive
|
|
174
|
+
const canonicalName = name.toLowerCase();
|
|
175
|
+
parametersValues.header[name] = validator(typeof request.headers[canonicalName] !== 'undefined'
|
|
176
|
+
? request.headers[canonicalName].toString()
|
|
177
|
+
: undefined);
|
|
178
|
+
}
|
|
179
|
+
}
|
|
180
|
+
else if (location === 'path') {
|
|
181
|
+
for (const [name, validator] of Object.entries(parametersValidators.path)) {
|
|
182
|
+
parametersValues.path[name] = validator(pathParameters && typeof pathParameters[name] !== 'undefined'
|
|
183
|
+
? pathParameters[name].toString()
|
|
184
|
+
: undefined);
|
|
185
|
+
}
|
|
186
|
+
}
|
|
187
|
+
}
|
|
188
|
+
const bodySpec = extractBodySpec(request, consumableMediaTypes || [], consumableCharsets);
|
|
189
|
+
responseSpec = extractResponseSpec(operation, request, produceableMediaTypes || [], produceableCharsets);
|
|
190
|
+
const body = await getBody({
|
|
191
|
+
API: MAIN_API,
|
|
192
|
+
DECODERS,
|
|
193
|
+
PARSERS,
|
|
194
|
+
bufferLimit,
|
|
195
|
+
}, operation, request.body, bodySpec);
|
|
196
|
+
bodyValidator(operation, bodySpec.contentType, body);
|
|
197
|
+
if (typeof body !== 'undefined') {
|
|
198
|
+
parametersValues.body = body;
|
|
199
|
+
}
|
|
200
|
+
}
|
|
201
|
+
catch (err) {
|
|
202
|
+
throw YHTTPError.cast(err, 400);
|
|
203
|
+
}
|
|
204
|
+
response = await executeHandler(definition, handler, parametersValues);
|
|
205
|
+
response.headers = response.headers || {};
|
|
206
|
+
if (response.body) {
|
|
207
|
+
response.headers['content-type'] =
|
|
208
|
+
response.headers['content-type'] || responseSpec.contentTypes[0];
|
|
209
|
+
}
|
|
210
|
+
const responseContentType = pickFirstHeaderValue('content-type', response.headers || {}) ||
|
|
211
|
+
'text/plain';
|
|
212
|
+
const responseObject = operation.responses && operation.responses[response.status]
|
|
213
|
+
? await ensureResolvedObject(MAIN_API, operation.responses[response.status])
|
|
214
|
+
: undefined;
|
|
215
|
+
const responseSchema = responseObject &&
|
|
216
|
+
responseObject.content &&
|
|
217
|
+
responseObject.content?.[responseContentType] &&
|
|
218
|
+
'schema' in responseObject.content[responseContentType] &&
|
|
219
|
+
(await ensureResolvedObject(MAIN_API, responseObject.content?.[responseContentType].schema));
|
|
220
|
+
// Check the stringifyer only when a schema is
|
|
221
|
+
// specified and it is not a binary one
|
|
222
|
+
const responseHasSchema = typeof responseSchema === 'boolean' ||
|
|
223
|
+
(typeof responseSchema === 'object' &&
|
|
224
|
+
responseSchema &&
|
|
225
|
+
!('type' in responseSchema &&
|
|
226
|
+
responseSchema.type === 'string' &&
|
|
227
|
+
responseSchema.format === 'binary'));
|
|
228
|
+
if (responseHasSchema && !STRINGIFYERS[responseContentType]) {
|
|
229
|
+
throw new YHTTPError(500, 'E_STRINGIFYER_LACK', response.headers['content-type'], response);
|
|
230
|
+
}
|
|
231
|
+
if (response.body) {
|
|
232
|
+
checkResponseMediaType(request, responseSpec, produceableMediaTypes || []);
|
|
233
|
+
checkResponseCharset(request, responseSpec, produceableCharsets);
|
|
234
|
+
}
|
|
235
|
+
responseLog = {
|
|
236
|
+
type: 'success',
|
|
237
|
+
status: response.status,
|
|
238
|
+
};
|
|
239
|
+
log?.('debug', JSON.stringify(responseLog));
|
|
240
|
+
}
|
|
241
|
+
catch (err) {
|
|
242
|
+
response = await errorHandler('none', responseSpec, err);
|
|
243
|
+
responseLog = {
|
|
244
|
+
type: 'error',
|
|
245
|
+
code: err?.code || 'E_UNEXPECTED',
|
|
246
|
+
statusCode: response.status,
|
|
247
|
+
params: err?.params || [],
|
|
248
|
+
stack: printStackTrace(err),
|
|
249
|
+
};
|
|
250
|
+
log?.('error', JSON.stringify(responseLog));
|
|
251
|
+
response = {
|
|
252
|
+
...response,
|
|
253
|
+
headers: {
|
|
254
|
+
...response.headers,
|
|
255
|
+
'content-type': 'application/json',
|
|
256
|
+
},
|
|
257
|
+
};
|
|
258
|
+
}
|
|
259
|
+
log?.('debug', 'RESPONSE', JSON.stringify({
|
|
260
|
+
...response,
|
|
261
|
+
body: obfuscateEventBody(obfuscator, response.body),
|
|
262
|
+
headers: obfuscator.obfuscateSensibleHeaders(response.headers),
|
|
263
|
+
}));
|
|
264
|
+
await pipeResponseInGCPFResponse(await sendBody({
|
|
265
|
+
ENCODERS,
|
|
266
|
+
STRINGIFYERS,
|
|
267
|
+
}, response), res);
|
|
268
|
+
}
|
|
269
|
+
async function gcpfReqToRequest(req) {
|
|
270
|
+
const request = {
|
|
271
|
+
method: req.method.toLowerCase(),
|
|
272
|
+
headers: lowerCaseHeaders(req.headers || {}),
|
|
273
|
+
url: req.originalUrl,
|
|
274
|
+
};
|
|
275
|
+
if (req.rawBody) {
|
|
276
|
+
request.headers['content-length'] = req.rawBody.length.toString();
|
|
277
|
+
const bodyStream = new stream.PassThrough();
|
|
278
|
+
request.body = bodyStream;
|
|
279
|
+
bodyStream.write(req.rawBody);
|
|
280
|
+
bodyStream.end();
|
|
281
|
+
}
|
|
282
|
+
return request;
|
|
283
|
+
}
|
|
284
|
+
async function pipeResponseInGCPFResponse(response, res) {
|
|
285
|
+
Object.keys(response.headers || {}).forEach((headerName) => {
|
|
286
|
+
res.set(headerName, response.headers?.[headerName]);
|
|
287
|
+
});
|
|
288
|
+
res.status(response.status);
|
|
289
|
+
if (response.body) {
|
|
290
|
+
response.body.pipe(res);
|
|
291
|
+
return;
|
|
292
|
+
}
|
|
293
|
+
res.end();
|
|
294
|
+
}
|
|
295
|
+
function obfuscateEventBody(obfuscator, rawBody) {
|
|
296
|
+
if (typeof rawBody === 'string') {
|
|
297
|
+
try {
|
|
298
|
+
const jsonBody = JSON.parse(rawBody);
|
|
299
|
+
return JSON.stringify(obfuscator.obfuscateSensibleProps(jsonBody));
|
|
300
|
+
// eslint-disable-next-line
|
|
301
|
+
}
|
|
302
|
+
catch (err) { }
|
|
303
|
+
}
|
|
304
|
+
return rawBody;
|
|
305
|
+
}
|
|
306
|
+
export default autoService(initWrapRouteHandlerForGoogleHTTPFunction);
|
|
307
|
+
//# sourceMappingURL=wrapRouteHandlerForGoogleHTTPFunction.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"wrapRouteHandlerForGoogleHTTPFunction.js","sourceRoot":"","sources":["../../src/wrappers/wrapRouteHandlerForGoogleHTTPFunction.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,eAAe,EAAE,MAAM,QAAQ,CAAC;AACjD,OAAO,MAAyB,MAAM,aAAa,CAAC;AACpD,OAAO,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AACzC,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AACxC,OAAO,EACL,wBAAwB,EACxB,oBAAoB,EACpB,eAAe,EACf,oBAAoB,EACpB,gBAAgB,EAChB,gBAAgB,EAChB,gBAAgB,EAChB,cAAc,EACd,kCAAkC,EAClC,oBAAoB,EACpB,eAAe,EACf,mBAAmB,EACnB,oBAAoB,EACpB,sBAAsB,EACtB,cAAc,EACd,4BAA4B,EAC5B,2BAA2B,EAC3B,OAAO,EACP,QAAQ,EACR,IAAI,EACJ,QAAQ,EACR,gBAAgB,EAChB,iBAAiB,EACjB,0BAA0B,EAC1B,oBAAoB,GAerB,MAAM,cAAc,CAAC;AAEtB,OAAO,EACL,oBAAoB,GAIrB,MAAM,mBAAmB,CAAC;AAmB3B;;;;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OAAO,OAAO,CAAC;AACjB,CAAC;AAED,KAAK,UAAU,0BAA0B,CACvC,QAAuB,EACvB,GAAG;IAEH,MAAM,CAAC,IAAI,CAAC,QAAQ,CAAC,OAAO,IAAI,EAAE,CAAC,CAAC,OAAO,CAAC,CAAC,UAAU,EAAE,EAAE;QACzD,GAAG,CAAC,GAAG,CAAC,UAAU,EAAE,QAAQ,CAAC,OAAO,EAAE,CAAC,UAAU,CAAC,CAAC,CAAC;IACtD,CAAC,CAAC,CAAC;IACH,GAAG,CAAC,MAAM,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC;IAE5B,IAAI,QAAQ,CAAC,IAAI,EAAE,CAAC;QACjB,QAAQ,CAAC,IAAiB,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;QACtC,OAAO;IACT,CAAC;IAED,GAAG,CAAC,GAAG,EAAE,CAAC;AACZ,CAAC;AAED,SAAS,kBAAkB,CAAC,UAAU,EAAE,OAAO;IAC7C,IAAI,OAAO,OAAO,KAAK,QAAQ,EAAE,CAAC;QAChC,IAAI,CAAC;YACH,MAAM,QAAQ,GAAG,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC;YAErC,OAAO,IAAI,CAAC,SAAS,CAAC,UAAU,CAAC,sBAAsB,CAAC,QAAQ,CAAC,CAAC,CAAC;YACnE,2BAA2B;QAC7B,CAAC;QAAC,OAAO,GAAG,EAAE,CAAC,CAAA,CAAC;IAClB,CAAC;IACD,OAAO,OAAO,CAAC;AACjB,CAAC;AAED,eAAe,WAAW,CAAC,yCAAyC,CAAC,CAAC"}
|
package/package.json
CHANGED
|
@@ -29,7 +29,7 @@
|
|
|
29
29
|
}
|
|
30
30
|
},
|
|
31
31
|
"name": "@whook/gcp-functions",
|
|
32
|
-
"version": "
|
|
32
|
+
"version": "19.0.0",
|
|
33
33
|
"description": "Build and deploy to GCP Cloud Functions with Whook.",
|
|
34
34
|
"type": "module",
|
|
35
35
|
"main": "dist/index.js",
|
|
@@ -49,21 +49,22 @@
|
|
|
49
49
|
},
|
|
50
50
|
"homepage": "https://github.com/nfroidure/whook",
|
|
51
51
|
"dependencies": {
|
|
52
|
-
"@whook/cors": "^
|
|
53
|
-
"@whook/
|
|
54
|
-
"@whook/whook": "^18.0.3",
|
|
52
|
+
"@whook/cors": "^19.0.0",
|
|
53
|
+
"@whook/whook": "^19.0.0",
|
|
55
54
|
"ajv": "^8.17.1",
|
|
56
55
|
"ajv-formats": "^3.0.1",
|
|
57
|
-
"application-services": "^7.0.
|
|
56
|
+
"application-services": "^7.0.2",
|
|
58
57
|
"camelcase": "^8.0.0",
|
|
59
|
-
"common-services": "^17.0.
|
|
58
|
+
"common-services": "^17.0.1",
|
|
60
59
|
"cpr": "3.0.1",
|
|
61
|
-
"knifecycle": "^
|
|
60
|
+
"knifecycle": "^19.0.0",
|
|
62
61
|
"mkdirp": "^3.0.1",
|
|
63
|
-
"openapi-types": "^12.1.3",
|
|
64
62
|
"qs": "^6.13.1",
|
|
65
63
|
"strict-qs": "^8.0.3",
|
|
66
|
-
"
|
|
64
|
+
"ya-json-schema-types": "^1.0.1",
|
|
65
|
+
"ya-open-api-types": "^1.2.0",
|
|
66
|
+
"yerror": "^8.0.0",
|
|
67
|
+
"yhttperror": "^8.1.0"
|
|
67
68
|
},
|
|
68
69
|
"devDependencies": {
|
|
69
70
|
"@eslint/js": "^9.16.0",
|
|
@@ -146,5 +147,5 @@
|
|
|
146
147
|
"overrides": {
|
|
147
148
|
"eslint": "^9.16.0"
|
|
148
149
|
},
|
|
149
|
-
"gitHead": "
|
|
150
|
+
"gitHead": "4963a2a6f790aff942dc0080666619e6ca9c4076"
|
|
150
151
|
}
|