@h4ad/serverless-adapter 4.0.0 → 4.1.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/lib/adapter.contract-EQE3rlgO.d.ts +278 -0
- package/lib/adapter.contract-y5xSjOjo.d.cts +278 -0
- package/lib/adapters/apollo-server/index.cjs +6 -0
- package/lib/adapters/apollo-server/index.cjs.map +1 -0
- package/lib/adapters/apollo-server/index.d.cts +61 -0
- package/lib/adapters/apollo-server/index.d.ts +61 -0
- package/lib/adapters/apollo-server/index.mjs +2 -0
- package/lib/adapters/apollo-server/index.mjs.map +1 -0
- package/lib/adapters/aws/index.cjs +6 -0
- package/lib/adapters/aws/index.cjs.map +1 -0
- package/lib/adapters/aws/index.d.cts +928 -0
- package/lib/adapters/aws/index.d.ts +928 -0
- package/lib/adapters/aws/index.mjs +2 -0
- package/lib/adapters/aws/index.mjs.map +1 -0
- package/lib/adapters/azure/index.cjs +6 -0
- package/lib/adapters/azure/index.cjs.map +1 -0
- package/lib/adapters/azure/index.d.cts +86 -0
- package/lib/adapters/azure/index.d.ts +86 -0
- package/lib/adapters/azure/index.mjs +2 -0
- package/lib/adapters/azure/index.mjs.map +1 -0
- package/lib/adapters/digital-ocean/index.cjs +6 -0
- package/lib/adapters/digital-ocean/index.cjs.map +1 -0
- package/lib/adapters/digital-ocean/index.d.cts +126 -0
- package/lib/adapters/digital-ocean/index.d.ts +126 -0
- package/lib/adapters/digital-ocean/index.mjs +2 -0
- package/lib/adapters/digital-ocean/index.mjs.map +1 -0
- package/lib/adapters/dummy/index.cjs +6 -0
- package/lib/adapters/dummy/index.cjs.map +1 -0
- package/lib/adapters/dummy/index.d.cts +37 -0
- package/lib/adapters/dummy/index.d.ts +37 -0
- package/lib/adapters/dummy/index.mjs +2 -0
- package/lib/adapters/dummy/index.mjs.map +1 -0
- package/lib/adapters/huawei/index.cjs +6 -0
- package/lib/adapters/huawei/index.cjs.map +1 -0
- package/lib/adapters/huawei/index.d.cts +365 -0
- package/lib/adapters/huawei/index.d.ts +365 -0
- package/lib/adapters/huawei/index.mjs +2 -0
- package/lib/adapters/huawei/index.mjs.map +1 -0
- package/lib/base-handler-fYEk59Xq.d.ts +35 -0
- package/lib/base-handler-peEBoKtZ.d.cts +35 -0
- package/lib/chunk-22SSVZU5.mjs +1 -0
- package/lib/chunk-22SSVZU5.mjs.map +1 -0
- package/lib/chunk-57ZKWTH4.mjs +2 -0
- package/lib/chunk-57ZKWTH4.mjs.map +1 -0
- package/lib/chunk-OYOJMOFP.mjs +2 -0
- package/lib/chunk-OYOJMOFP.mjs.map +1 -0
- package/lib/chunk-PQDB5AVF.mjs +12 -0
- package/lib/chunk-PQDB5AVF.mjs.map +1 -0
- package/lib/chunk-VPGUOREQ.mjs +2 -0
- package/lib/chunk-VPGUOREQ.mjs.map +1 -0
- package/lib/constants-0cgQlFSV.d.cts +32 -0
- package/lib/constants-0cgQlFSV.d.ts +32 -0
- package/lib/framework.contract-YnJ-fl1w.d.cts +20 -0
- package/lib/framework.contract-YnJ-fl1w.d.ts +20 -0
- package/lib/frameworks/apollo-server/index.cjs +6 -0
- package/lib/frameworks/apollo-server/index.cjs.map +1 -0
- package/lib/frameworks/apollo-server/index.d.cts +72 -0
- package/lib/frameworks/apollo-server/index.d.ts +72 -0
- package/lib/frameworks/apollo-server/index.mjs +2 -0
- package/lib/frameworks/apollo-server/index.mjs.map +1 -0
- package/lib/frameworks/body-parser/index.cjs +6 -0
- package/lib/frameworks/body-parser/index.cjs.map +1 -0
- package/lib/frameworks/body-parser/index.d.cts +159 -0
- package/lib/frameworks/body-parser/index.d.ts +159 -0
- package/lib/frameworks/body-parser/index.mjs +2 -0
- package/lib/frameworks/body-parser/index.mjs.map +1 -0
- package/lib/frameworks/cors/index.cjs +7 -0
- package/lib/frameworks/cors/index.cjs.map +1 -0
- package/lib/frameworks/cors/index.d.cts +79 -0
- package/lib/frameworks/cors/index.d.ts +79 -0
- package/lib/frameworks/cors/index.mjs +3 -0
- package/lib/frameworks/cors/index.mjs.map +1 -0
- package/lib/frameworks/deepkit/index.cjs +6 -0
- package/lib/frameworks/deepkit/index.cjs.map +1 -0
- package/lib/frameworks/deepkit/index.d.cts +21 -0
- package/lib/frameworks/deepkit/index.d.ts +21 -0
- package/lib/frameworks/deepkit/index.mjs +2 -0
- package/lib/frameworks/deepkit/index.mjs.map +1 -0
- package/lib/frameworks/express/index.cjs +2 -0
- package/lib/frameworks/express/index.cjs.map +1 -0
- package/lib/frameworks/express/index.d.cts +18 -0
- package/lib/frameworks/express/index.d.ts +18 -0
- package/lib/frameworks/express/index.mjs +2 -0
- package/lib/frameworks/express/index.mjs.map +1 -0
- package/lib/frameworks/fastify/index.cjs +2 -0
- package/lib/frameworks/fastify/index.cjs.map +1 -0
- package/lib/frameworks/fastify/index.d.cts +18 -0
- package/lib/frameworks/fastify/index.d.ts +18 -0
- package/lib/frameworks/fastify/index.mjs +2 -0
- package/lib/frameworks/fastify/index.mjs.map +1 -0
- package/lib/frameworks/hapi/index.cjs +2 -0
- package/lib/frameworks/hapi/index.cjs.map +1 -0
- package/lib/frameworks/hapi/index.d.cts +18 -0
- package/lib/frameworks/hapi/index.d.ts +18 -0
- package/lib/frameworks/hapi/index.mjs +2 -0
- package/lib/frameworks/hapi/index.mjs.map +1 -0
- package/lib/frameworks/koa/index.cjs +2 -0
- package/lib/frameworks/koa/index.cjs.map +1 -0
- package/lib/frameworks/koa/index.d.cts +18 -0
- package/lib/frameworks/koa/index.d.ts +18 -0
- package/lib/frameworks/koa/index.mjs +2 -0
- package/lib/frameworks/koa/index.mjs.map +1 -0
- package/lib/frameworks/lazy/index.cjs +6 -0
- package/lib/frameworks/lazy/index.cjs.map +1 -0
- package/lib/frameworks/lazy/index.d.cts +57 -0
- package/lib/frameworks/lazy/index.d.ts +57 -0
- package/lib/frameworks/lazy/index.mjs +2 -0
- package/lib/frameworks/lazy/index.mjs.map +1 -0
- package/lib/frameworks/trpc/index.cjs +6 -0
- package/lib/frameworks/trpc/index.cjs.map +1 -0
- package/lib/frameworks/trpc/index.d.cts +154 -0
- package/lib/frameworks/trpc/index.d.ts +154 -0
- package/lib/frameworks/trpc/index.mjs +2 -0
- package/lib/frameworks/trpc/index.mjs.map +1 -0
- package/lib/handler.contract-8Cb7qLSi.d.ts +66 -0
- package/lib/handler.contract-TQk8iM8f.d.cts +66 -0
- package/lib/handlers/aws/index.cjs +12 -0
- package/lib/handlers/aws/index.cjs.map +1 -0
- package/lib/handlers/aws/index.d.cts +96 -0
- package/lib/handlers/aws/index.d.ts +96 -0
- package/lib/handlers/aws/index.mjs +2 -0
- package/lib/handlers/aws/index.mjs.map +1 -0
- package/lib/handlers/azure/index.cjs +6 -0
- package/lib/handlers/azure/index.cjs.map +1 -0
- package/lib/handlers/azure/index.d.cts +53 -0
- package/lib/handlers/azure/index.d.ts +53 -0
- package/lib/handlers/azure/index.mjs +2 -0
- package/lib/handlers/azure/index.mjs.map +1 -0
- package/lib/handlers/default/index.cjs +6 -0
- package/lib/handlers/default/index.cjs.map +1 -0
- package/lib/handlers/default/index.d.cts +95 -0
- package/lib/handlers/default/index.d.ts +95 -0
- package/lib/handlers/default/index.mjs +2 -0
- package/lib/handlers/default/index.mjs.map +1 -0
- package/lib/handlers/digital-ocean/index.cjs +6 -0
- package/lib/handlers/digital-ocean/index.cjs.map +1 -0
- package/lib/handlers/digital-ocean/index.d.cts +25 -0
- package/lib/handlers/digital-ocean/index.d.ts +25 -0
- package/lib/handlers/digital-ocean/index.mjs +2 -0
- package/lib/handlers/digital-ocean/index.mjs.map +1 -0
- package/lib/handlers/firebase/index.cjs +6 -0
- package/lib/handlers/firebase/index.cjs.map +1 -0
- package/lib/handlers/firebase/index.d.cts +59 -0
- package/lib/handlers/firebase/index.d.ts +59 -0
- package/lib/handlers/firebase/index.mjs +2 -0
- package/lib/handlers/firebase/index.mjs.map +1 -0
- package/lib/handlers/gcp/index.cjs +6 -0
- package/lib/handlers/gcp/index.cjs.map +1 -0
- package/lib/handlers/gcp/index.d.cts +33 -0
- package/lib/handlers/gcp/index.d.ts +33 -0
- package/lib/handlers/gcp/index.mjs +2 -0
- package/lib/handlers/gcp/index.mjs.map +1 -0
- package/lib/handlers/huawei/index.cjs +6 -0
- package/lib/handlers/huawei/index.cjs.map +1 -0
- package/lib/handlers/huawei/index.d.cts +62 -0
- package/lib/handlers/huawei/index.d.ts +62 -0
- package/lib/handlers/huawei/index.mjs +2 -0
- package/lib/handlers/huawei/index.mjs.map +1 -0
- package/lib/headers-K2qbcurv.d.cts +38 -0
- package/lib/headers-K2qbcurv.d.ts +38 -0
- package/lib/index.cjs +12 -0
- package/lib/index.cjs.map +1 -0
- package/lib/index.d.cts +439 -0
- package/lib/index.d.ts +439 -0
- package/lib/index.mjs +2 -0
- package/lib/index.mjs.map +1 -0
- package/lib/logger-9me5n48P.d.cts +65 -0
- package/lib/logger-9me5n48P.d.ts +65 -0
- package/lib/path-yBwCb8C1.d.cts +64 -0
- package/lib/path-yBwCb8C1.d.ts +64 -0
- package/lib/raw-request-B2vPjAfE.d.cts +32 -0
- package/lib/raw-request-b6AYnkxd.d.ts +32 -0
- package/lib/request-DNNIV9ub.d.cts +44 -0
- package/lib/request-sVa4pxmx.d.ts +44 -0
- package/lib/resolvers/aws-context/index.cjs +2 -0
- package/lib/resolvers/aws-context/index.cjs.map +1 -0
- package/lib/resolvers/aws-context/index.d.cts +25 -0
- package/lib/resolvers/aws-context/index.d.ts +25 -0
- package/lib/resolvers/aws-context/index.mjs +2 -0
- package/lib/resolvers/aws-context/index.mjs.map +1 -0
- package/lib/resolvers/callback/index.cjs +2 -0
- package/lib/resolvers/callback/index.cjs.map +1 -0
- package/lib/resolvers/callback/index.d.cts +29 -0
- package/lib/resolvers/callback/index.d.ts +29 -0
- package/lib/resolvers/callback/index.mjs +2 -0
- package/lib/resolvers/callback/index.mjs.map +1 -0
- package/lib/resolvers/dummy/index.cjs +2 -0
- package/lib/resolvers/dummy/index.cjs.map +1 -0
- package/lib/resolvers/dummy/index.d.cts +20 -0
- package/lib/resolvers/dummy/index.d.ts +20 -0
- package/lib/resolvers/dummy/index.mjs +2 -0
- package/lib/resolvers/dummy/index.mjs.map +1 -0
- package/lib/resolvers/promise/index.cjs +2 -0
- package/lib/resolvers/promise/index.cjs.map +1 -0
- package/lib/resolvers/promise/index.d.cts +20 -0
- package/lib/resolvers/promise/index.d.ts +20 -0
- package/lib/resolvers/promise/index.mjs +2 -0
- package/lib/resolvers/promise/index.mjs.map +1 -0
- package/package.json +1 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/adapters/huawei/index.ts","../../../src/network/request.ts","../../../src/network/response.ts","../../../src/network/utils.ts","../../../src/network/response-stream.ts","../../../src/core/event-body.ts","../../../src/core/headers.ts","../../../src/core/no-op.ts","../../../src/core/logger.ts","../../../src/core/optional.ts","../../../src/core/path.ts","../../../src/core/stream.ts","../../../src/adapters/huawei/huawei-api-gateway.adapter.ts"],"sourcesContent":["export * from './huawei-api-gateway.adapter';\n","// ATTRIBUTION: https://github.com/dougmoscrop/serverless-http\nimport { IncomingMessage } from 'node:http';\nimport type { AddressInfo } from 'node:net';\nimport type { SingleValueHeaders } from '../@types';\nimport { NO_OP } from '../core';\n\nconst HTTPS_PORT = 443;\n\n/**\n * The properties to create a {@link ServerlessRequest}\n *\n * @breadcrumb Network / ServerlessRequest\n * @public\n */\nexport interface ServerlessRequestProps {\n /**\n * The HTTP Method of the request\n */\n method: string;\n\n /**\n * The URL requested\n */\n url: string;\n\n /**\n * The headers from the event source\n */\n headers: SingleValueHeaders;\n\n /**\n * The body from the event source\n */\n body?: Buffer | Uint8Array;\n\n /**\n * The IP Address from caller\n */\n remoteAddress?: string;\n}\n\n/**\n * The class that represents an {@link http#IncomingMessage} created by the library to represent an actual request to the framework.\n *\n * @breadcrumb Network / ServerlessRequest\n * @public\n */\nexport class ServerlessRequest extends IncomingMessage {\n constructor({\n method,\n url,\n headers,\n body,\n remoteAddress,\n }: ServerlessRequestProps) {\n super({\n encrypted: true,\n readable: false,\n remoteAddress,\n address: () => ({ port: HTTPS_PORT }) as AddressInfo,\n end: NO_OP,\n destroy: NO_OP,\n } as any);\n\n this.statusCode = 200;\n this.statusMessage = 'OK';\n this.complete = true;\n this.httpVersion = '1.1';\n this.httpVersionMajor = 1;\n this.httpVersionMinor = 1;\n this.method = method;\n this.headers = headers;\n this.body = body;\n this.url = url;\n this.ip = remoteAddress;\n\n this._read = () => {\n this.push(body);\n this.push(null);\n };\n }\n\n ip?: string;\n body?: Buffer | Uint8Array;\n}\n","// ATTRIBUTION: https://github.com/dougmoscrop/serverless-http\nimport { IncomingMessage, ServerResponse } from 'node:http';\nimport type { Socket } from 'node:net';\nimport { NO_OP } from '../core';\nimport { getString } from './utils';\n\nconst headerEnd = '\\r\\n\\r\\n';\nconst endChunked = '0\\r\\n\\r\\n';\n\nconst BODY = Symbol('Response body');\nconst HEADERS = Symbol('Response headers');\n\nfunction addData(stream: ServerlessResponse, data: Uint8Array | string) {\n if (\n Buffer.isBuffer(data) ||\n typeof data === 'string' ||\n data instanceof Uint8Array\n )\n stream[BODY].push(Buffer.from(data));\n else throw new Error(`response.write() of unexpected type: ${typeof data}`);\n}\n\n/**\n * The properties to create a {@link ServerlessResponse}.\n *\n * @breadcrumb Network / ServerlessResponse\n * @public\n */\nexport interface ServerlessResponseProps {\n /**\n * The HTTP Method from request\n */\n method?: string;\n}\n\n/**\n * The class that represents a response instance used to send to the framework and wait until the framework finishes processing the request.\n * Once it's happens, we use the properties from this response to built the response to the cloud.\n *\n * @breadcrumb Network / ServerlessResponse\n * @public\n */\nexport class ServerlessResponse extends ServerResponse {\n constructor({ method }: ServerlessResponseProps) {\n super({ method } as any);\n\n this[BODY] = [];\n this[HEADERS] = {};\n\n this.useChunkedEncodingByDefault = false;\n this.chunkedEncoding = false;\n this._header = '';\n\n // this ignore is used because I need to ignore these write calls:\n // https://github.com/nodejs/node/blob/main/lib/_http_outgoing.js#L934-L935\n // https://github.com/nodejs/node/blob/main/lib/_http_outgoing.js#L937\n let writesToIgnore = 1;\n\n const socket: Partial<Socket> & { _writableState: any } = {\n _writableState: {},\n writable: true,\n on: NO_OP,\n removeListener: NO_OP,\n destroy: NO_OP,\n cork: NO_OP,\n uncork: NO_OP,\n write: (\n data: Uint8Array | string,\n encoding?: string | null | (() => void),\n cb?: () => void,\n ): any => {\n if (typeof encoding === 'function') {\n cb = encoding;\n encoding = null;\n }\n\n if (this._header === '' || this._wroteHeader) {\n if (!this.chunkedEncoding) addData(this, data);\n else {\n if (writesToIgnore > 0) writesToIgnore--;\n else if (data !== endChunked) {\n addData(this, data);\n writesToIgnore = 3;\n }\n }\n } else {\n const string = getString(data);\n const index = string.indexOf(headerEnd);\n\n if (index !== -1) {\n const remainder = string.slice(index + headerEnd.length);\n\n if (remainder && !this.chunkedEncoding) addData(this, remainder);\n\n this._wroteHeader = true;\n }\n }\n\n if (typeof cb === 'function') cb();\n },\n };\n\n this.assignSocket(socket as unknown as Socket);\n }\n\n _header: string;\n _headers?: Record<any, any>;\n _wroteHeader?: boolean;\n\n [BODY]: any[];\n [HEADERS]: Record<any, any>;\n\n get headers(): Record<any, any> {\n return this[HEADERS];\n }\n\n static from(res: IncomingMessage) {\n const response = new ServerlessResponse({ method: res.method });\n\n response.statusCode = res.statusCode || 0;\n response[HEADERS] = res.headers;\n response[BODY] = (res as any).body ? [Buffer.from((res as any).body)] : [];\n response.end();\n\n return response;\n }\n\n static body(res: ServerlessResponse): Buffer {\n return Buffer.concat(res[BODY]);\n }\n\n static headers(res: ServerlessResponse) {\n const headers = res.getHeaders();\n\n return Object.assign(headers, res[HEADERS]);\n }\n\n override setHeader(\n key: string,\n value: number | string | readonly string[],\n ): any {\n if (this._wroteHeader) this[HEADERS][key] = value;\n else super.setHeader(key, value);\n }\n\n override writeHead(\n statusCode: number,\n statusMessage?: string | any | any[],\n obj?: any | any[],\n ): any {\n const headersObjOrArray =\n typeof statusMessage === 'string' ? obj : statusMessage;\n\n const arrayHeaders = Array.isArray(headersObjOrArray)\n ? headersObjOrArray\n : [headersObjOrArray || {}];\n\n for (const headers of arrayHeaders) {\n for (const name in headers) {\n this.setHeader(name, headers[name]!);\n\n if (!this._wroteHeader) {\n // we only need to initiate super.headers once\n // writeHead will add the other headers itself\n break;\n }\n }\n }\n\n return this.callNativeWriteHead(statusCode, statusMessage, obj);\n }\n\n /**\n * I use ignore here because in nodejs 12.x, statusMessage can be string | OutgoingHttpHeaders\n * But in nodejs \\>=14.x, statusMessage can also be OutgoingHttpHeaders[]\n * I take care of these cases above, but here I can't handle it well, so I give up\n * nodejs 12.x ref: https://github.com/DefinitelyTyped/DefinitelyTyped/blob/master/types/node/v12/http.d.ts#L229\n * nodejs 14.x ref: https://github.com/DefinitelyTyped/DefinitelyTyped/blob/master/types/node/v14/http.d.ts#L263\n */\n protected callNativeWriteHead(\n statusCode: number,\n statusMessage?: string | any | any[],\n obj?: any | any[],\n ): this {\n return super.writeHead(statusCode, statusMessage, obj);\n }\n}\n","/**\n * Get the data from a buffer, string, or Uint8Array\n *\n * @breadcrumb Network\n * @param data - The data that was written inside the stream\n */\nexport function getString(data: Buffer | string | unknown) {\n if (Buffer.isBuffer(data)) return data.toString('utf8');\n else if (typeof data === 'string') return data;\n else if (data instanceof Uint8Array) return new TextDecoder().decode(data);\n else throw new Error(`response.write() of unexpected type: ${typeof data}`);\n}\n","import { ServerResponse } from 'node:http';\nimport type { Socket } from 'node:net';\nimport type { Writable } from 'node:stream';\nimport type { BothValueHeaders } from '../@types';\nimport { type ILogger, NO_OP, parseHeaders } from '../core';\nimport { getString } from './utils';\n\nconst endChunked = '0\\r\\n\\r\\n';\nconst headerEnd = '\\r\\n\\r\\n';\nconst endStatusSeparator = '\\r\\n';\n\n/**\n * The properties to create a {@link ServerlessStreamResponse}.\n *\n * @breadcrumb Network / ServerlessStreamResponse\n * @public\n */\nexport interface ServerlessStreamResponseProps {\n /**\n * The HTTP Method from request\n */\n method?: string;\n\n /**\n * The callback to receive the headers when they are written to the stream\n * You need to return a writable stream be able to continue writing the response\n *\n * @param statusCode - The status code of the response\n * @param headers - The headers of the response\n */\n onReceiveHeaders: (statusCode: number, headers: BothValueHeaders) => Writable;\n\n /**\n * Instance of the logger\n */\n log: ILogger;\n}\n\n/**\n * The class that represents a response instance used to send to the framework and wait until the framework finishes processing the request.\n * This response is specially built to deal with transfer-encoding: chunked\n *\n * @breadcrumb Network / ServerlessStreamResponse\n * @public\n */\nexport class ServerlessStreamResponse extends ServerResponse {\n constructor({\n method,\n onReceiveHeaders,\n log,\n }: ServerlessStreamResponseProps) {\n super({ method } as any);\n\n this.useChunkedEncodingByDefault = true;\n this.chunkedEncoding = true;\n\n let internalWritable: Writable | null = null;\n let isFirstCall = true;\n // this ignore is used because I need to ignore these write calls:\n // https://github.com/nodejs/node/blob/main/lib/_http_outgoing.js#L934-L935\n // https://github.com/nodejs/node/blob/main/lib/_http_outgoing.js#L937\n let writesToIgnore = 0;\n\n const socket: Partial<Socket> & { _writableState: any } = {\n _writableState: {},\n writable: true,\n on: NO_OP,\n removeListener: NO_OP,\n destroy: NO_OP,\n cork: NO_OP,\n uncork: NO_OP,\n write: (\n data: Uint8Array | string,\n encoding?: string | null | (() => void),\n cb?: () => void,\n ): any => {\n // very unlikely, I don't even know how to reproduce this, but exist on types\n // istanbul ignore if\n if (typeof encoding === 'function') {\n cb = encoding;\n encoding = null;\n }\n\n log.debug('SERVERLESS_ADAPTER:RESPONSE_STREAM:DATA', () => ({\n data: Buffer.isBuffer(data) ? data.toString('utf8') : data,\n encoding,\n }));\n\n if (!isFirstCall && internalWritable) {\n if (data === endChunked) {\n internalWritable.end(cb);\n\n return true;\n }\n\n if (writesToIgnore > 0) {\n writesToIgnore--;\n return true;\n }\n\n internalWritable.write(data, cb);\n writesToIgnore = 3;\n } else if (isFirstCall) {\n isFirstCall = false;\n\n const stringData = getString(data);\n const endStatusIndex = stringData.indexOf(endStatusSeparator);\n const status = +stringData.slice(0, endStatusIndex).split(' ')[1];\n\n const headerData = stringData.slice(\n endStatusIndex + 2,\n stringData.indexOf(headerEnd),\n );\n const headers = parseHeaders(headerData);\n log.debug('SERVERLESS_ADAPTER:RESPONSE_STREAM:FRAMEWORK_HEADERS', {\n headers,\n });\n\n writesToIgnore = 1;\n internalWritable = onReceiveHeaders(status, headers);\n }\n\n return true;\n },\n };\n\n this.assignSocket(socket as unknown as Socket);\n }\n}\n","/**\n * Get the event body as buffer from body string with content length\n *\n * @example\n * ```typescript\n * const body = '{}';\n * const [buffer, contentLength] = getEventBodyAsBuffer(body, false);\n * console.log(buffer);\n * // <Buffer 7b 7d>\n * console.log(contentLength);\n * // 2\n * ```\n *\n * @param body - The body string that can be encoded or not\n * @param isBase64Encoded - Tells if body string is encoded in base64\n *\n * @breadcrumb Core\n * @public\n */\nexport function getEventBodyAsBuffer(\n body: string,\n isBase64Encoded: boolean,\n): [body: Buffer, contentLength: number] {\n const encoding: BufferEncoding = isBase64Encoded ? 'base64' : 'utf8';\n\n const buffer = Buffer.from(body, encoding);\n const contentLength = Buffer.byteLength(buffer, encoding);\n\n return [buffer, contentLength];\n}\n","//#region Imports\n\nimport type { BothValueHeaders } from '../@types';\n\n//#endregion\n\n/**\n * Transform a header map and make sure the value is not an array\n *\n * @example\n * ```typescript\n * const headers = { 'accept-encoding': 'gzip', 'accept-language': ['en-US', 'en;q=0.9'] };\n * const flattenedHeaders = getFlattenedHeadersMap(headers, ',', true);\n * console.log(flattenedHeaders);\n * // { 'accept-encoding': 'gzip', 'accept-language': 'en-US,en;q=0.9' }\n * ```\n *\n * @param headersMap - The initial headers\n * @param separator - The separator used when we join the array of header's value\n * @param lowerCaseKey - Should put all keys in lowercase\n *\n * @breadcrumb Core / Headers\n * @public\n */\nexport function getFlattenedHeadersMap(\n headersMap: BothValueHeaders,\n separator: string = ',',\n lowerCaseKey: boolean = false,\n): Record<string, string> {\n return Object.keys(headersMap).reduce((acc, headerKey) => {\n const newKey = lowerCaseKey ? headerKey.toLowerCase() : headerKey;\n const headerValue = headersMap[headerKey];\n\n if (Array.isArray(headerValue)) acc[newKey] = headerValue.join(separator);\n else acc[newKey] = (headerValue ?? '') + '';\n\n return acc;\n }, {});\n}\n\n/**\n * Transforms a header map into a multi-value map header.\n *\n * @example\n * ```typescript\n * const headers = { 'accept-encoding': 'gzip', 'connection': ['keep-alive'] };\n * const multiValueHeaders = getMultiValueHeadersMap(headers);\n * console.log(multiValueHeaders);\n * // { 'accept-encoding': ['gzip'], 'connection': ['keep-alive'] }\n * ```\n *\n * @param headersMap - The initial headers\n *\n * @breadcrumb Core / Headers\n * @public\n */\nexport function getMultiValueHeadersMap(\n headersMap: BothValueHeaders,\n): Record<string, string[]> {\n return Object.keys(headersMap).reduce((acc, headerKey) => {\n const headerValue = headersMap[headerKey];\n\n acc[headerKey.toLowerCase()] = Array.isArray(headerValue)\n ? headerValue.map(String)\n : [String(headerValue)];\n\n return acc;\n }, {});\n}\n\n/**\n * The wrapper that holds the information about single value headers and cookies\n *\n * @breadcrumb Core / Headers\n * @public\n */\nexport type FlattenedHeadersAndCookies = {\n /**\n * Just the single value headers\n */\n headers: Record<string, string>;\n\n /**\n * The list of cookies\n */\n cookies: string[];\n};\n\n/**\n * Transforms a header map into a single value headers and cookies\n *\n * @param headersMap - The initial headers\n *\n * @breadcrumb Core / Headers\n * @public\n */\nexport function getFlattenedHeadersMapAndCookies(\n headersMap: BothValueHeaders,\n): FlattenedHeadersAndCookies {\n return Object.keys(headersMap).reduce(\n (acc, headerKey) => {\n const headerValue = headersMap[headerKey];\n const lowerHeaderKey = headerKey.toLowerCase();\n\n if (Array.isArray(headerValue)) {\n if (lowerHeaderKey !== 'set-cookie')\n acc.headers[headerKey] = headerValue.join(',');\n else acc.cookies.push(...headerValue);\n } else {\n if (lowerHeaderKey === 'set-cookie' && headerValue !== undefined)\n acc.cookies.push(headerValue ?? '');\n else acc.headers[headerKey] = String(headerValue ?? '');\n }\n\n return acc;\n },\n {\n cookies: [],\n headers: {},\n } as FlattenedHeadersAndCookies,\n );\n}\n\n/**\n * Parse HTTP Raw Headers\n * Attribution to {@link https://github.com/kesla/parse-headers/blob/master/parse-headers.js}\n *\n * @param headers - The raw headers\n *\n * @breadcrumb Core / Headers\n * @public\n */\nexport function parseHeaders(\n headers: string,\n): Record<string, string | string[]> {\n if (!headers) return {};\n\n const result = {};\n const headersArr = headers.trim().split('\\n');\n\n for (let i = 0; i < headersArr.length; i++) {\n const row = headersArr[i];\n const index = row.indexOf(':');\n const key = row.slice(0, index).trim().toLowerCase();\n const value = row.slice(index + 1).trim();\n\n if (typeof result[key] === 'undefined') result[key] = value;\n else if (Array.isArray(result[key])) result[key].push(value);\n else result[key] = [result[key], value];\n }\n\n return result;\n}\n","/**\n * No operation function is used when we need to pass a function, but we don't want to specify any behavior.\n *\n * @breadcrumb Core\n * @public\n */\nexport const NO_OP: (...args: any[]) => any = () => void 0;\n","import { NO_OP } from './no-op';\n\n/**\n * The type representing the possible log levels to choose from.\n *\n * @breadcrumb Core / Logger\n * @public\n */\nexport type LogLevels =\n | 'debug'\n | 'verbose'\n | 'info'\n | 'warn'\n | 'error'\n | 'none';\n\n/**\n * The options to customize {@link ILogger}\n *\n * @breadcrumb Core / Logger\n * @public\n */\nexport type LoggerOptions = {\n /**\n * Select the log level, {@link LogLevels | see more}.\n *\n * @defaultValue error\n */\n level: LogLevels;\n};\n\n/**\n * The log function used in any level.\n *\n * @breadcrumb Core / Logger\n * @public\n */\nexport type LoggerFN = (message: any, ...additional: any[]) => void;\n\n/**\n * The interface representing the logger, you can provide a custom logger by implementing this interface.\n *\n * @breadcrumb Core / Logger\n * @public\n */\nexport type ILogger = Record<Exclude<LogLevels, 'none'>, LoggerFN>;\n\n/**\n * The symbol used to check against an ILogger instace to verify if that ILogger was created by this library\n *\n * @breadcrumb Core / Logger\n * @public\n */\nconst InternalLoggerSymbol = Symbol('InternalLogger');\n\nconst logLevels: Record<\n LogLevels,\n [level: LogLevels, consoleMethod: keyof Console][]\n> = {\n debug: [\n ['debug', 'debug'],\n ['verbose', 'debug'],\n ['info', 'info'],\n ['error', 'error'],\n ['warn', 'warn'],\n ],\n verbose: [\n ['verbose', 'debug'],\n ['info', 'info'],\n ['error', 'error'],\n ['warn', 'warn'],\n ],\n info: [\n ['info', 'info'],\n ['error', 'error'],\n ['warn', 'warn'],\n ],\n warn: [\n ['warn', 'warn'],\n ['error', 'error'],\n ],\n error: [['error', 'error']],\n none: [],\n};\n\nconst lazyPrint = (value: () => any | unknown) => {\n if (typeof value === 'function') return value();\n\n return value;\n};\n\nconst print =\n (fn: string) =>\n (message: any, ...additional: (() => any)[]) =>\n console[fn](message, ...additional.map(lazyPrint));\n\n/**\n * The method used to create a simple logger instance to use in this library.\n *\n * @remarks Behind the scenes, this simple logger sends the message to the `console` methods.\n *\n * @example\n * ```typescript\n * const logger = createDefaultLogger();\n *\n * logger.error('An error happens.');\n * // An error happens.\n * ```\n *\n * @param level - Select the level of the log\n *\n * @breadcrumb Core / Logger\n * @public\n */\nexport function createDefaultLogger(\n { level }: LoggerOptions = { level: 'error' },\n): ILogger {\n const levels = logLevels[level];\n\n if (!levels) throw new Error('Invalid log level');\n\n const logger = {\n [InternalLoggerSymbol]: true,\n error: NO_OP,\n debug: NO_OP,\n info: NO_OP,\n verbose: NO_OP,\n warn: NO_OP,\n } as ILogger;\n\n for (const [level, consoleMethod] of levels)\n logger[level] = print(consoleMethod);\n\n return logger;\n}\n\n/**\n * The method used to chck if logger was created by this library, or it was defined by the user.\n *\n * @param logger - The instance of the logger to check\n *\n * @breadcrumb Core / Logger\n * @public\n */\nexport function isInternalLogger(logger: ILogger): boolean {\n return !!logger[InternalLoggerSymbol];\n}\n","/**\n * Return the defaultValue whether the value is undefined, otherwise, return the value.\n *\n * @example\n * ```typescript\n * const value1 = getDefaultIfUndefined(undefined, true);\n * const value2 = getDefaultIfUndefined(false, true);\n *\n * console.log(value1);\n * // true\n * console.log(value2);\n * // false\n * ```\n *\n * @param value - The value to be checked\n * @param defaultValue - The default value when value is undefined\n *\n * @breadcrumb Core\n * @public\n */\nexport function getDefaultIfUndefined<T>(\n value: T | undefined,\n defaultValue: T,\n): T {\n if (value === undefined) return defaultValue;\n\n return value;\n}\n","/**\n * Transform the path and a map of query params to a string with formatted query params\n *\n * @example\n * ```typescript\n * const path = '/pets/search';\n * const queryParams = { batata: undefined, petType: [ 'dog', 'fish' ] };\n * const result = getPathWithQueryStringParams(path, queryParams);\n * console.log(result);\n * // /pets/search?batata=&petType=dog&petType=fish\n * ```\n *\n * @param path - The path\n * @param queryParams - The query params\n *\n * @breadcrumb Core / Path\n * @public\n */\nexport function getPathWithQueryStringParams(\n path: string,\n queryParams:\n | string\n | Record<string, string | string[] | undefined>\n | undefined\n | null,\n): string {\n if (String(queryParams || '').length === 0) return path;\n\n if (typeof queryParams === 'string') return `${path}?${queryParams}`;\n\n const queryParamsString = getQueryParamsStringFromRecord(queryParams);\n\n if (!queryParamsString) return path;\n\n return `${path}?${queryParamsString}`;\n}\n\n/**\n * Map query params to a string with formatted query params\n *\n * @example\n * ```typescript\n * const queryParams = { batata: undefined, petType: [ 'dog', 'fish' ] };\n * const result = getQueryParamsStringFromRecord(queryParams);\n * console.log(result);\n * // batata=&petType=dog&petType=fish\n * ```\n *\n * @param queryParamsRecord - The query params record\n *\n * @breadcrumb Core / Path\n * @public\n */\nexport function getQueryParamsStringFromRecord(\n queryParamsRecord:\n | Record<string, string | string[] | undefined>\n | undefined\n | null,\n): string {\n const searchParams = new URLSearchParams();\n\n const multiValueHeadersEntries: [string, string | string[] | undefined][] =\n Object.entries(queryParamsRecord || {});\n\n if (multiValueHeadersEntries.length === 0) return '';\n\n for (const [key, value] of multiValueHeadersEntries) {\n if (!Array.isArray(value)) {\n searchParams.append(key, value || '');\n continue;\n }\n\n for (const arrayValue of value) searchParams.append(key, arrayValue);\n }\n\n return searchParams.toString();\n}\n\n/**\n * Type of the function to strip base path\n *\n * @breadcrumb Core / Path\n * @public\n */\nexport type StripBasePathFn = (path: string) => string;\n\nconst NOOPBasePath: StripBasePathFn = (path: string) => path;\n\n/**\n * Get the strip base path function\n *\n * @param basePath - The base path\n *\n * @breadcrumb Core / Path\n * @public\n */\nexport function buildStripBasePath(\n basePath: string | undefined,\n): StripBasePathFn {\n if (!basePath) return NOOPBasePath;\n\n const length = basePath.length;\n\n return (path: string) => {\n if (path.startsWith(basePath))\n return path.slice(path.indexOf(basePath) + length, path.length) || '/';\n\n return path;\n };\n}\n","//#region Imports\n\nimport { Readable, Writable } from 'node:stream';\n\n//#endregion\n\n/**\n * Check if stream already ended\n *\n * @param stream - The stream\n *\n * @breadcrumb Core / Stream\n * @public\n */\nexport function isStreamEnded(stream: Readable | Writable): boolean {\n if ('readableEnded' in stream && stream.readableEnded) return true;\n\n if ('writableEnded' in stream && stream.writableEnded) return true;\n\n return false;\n}\n\n/**\n * Wait asynchronous the stream to complete\n *\n * @param stream - The stream\n *\n * @breadcrumb Core / Stream\n * @public\n */\nexport function waitForStreamComplete<TStream extends Readable | Writable>(\n stream: TStream,\n): Promise<TStream> {\n if (isStreamEnded(stream)) return Promise.resolve(stream);\n\n return new Promise<TStream>((resolve, reject) => {\n // Reading the {@link https://github.com/nodejs/node/blob/v12.22.9/lib/events.js#L262 | emit source code},\n // it's almost impossible to complete being called twice because the emit function runs synchronously and removes the other listeners,\n // but I'll leave it at that because I didn't write that code, so I couldn't figure out what the author thought when he wrote this.\n let isComplete = false;\n\n function complete(err: any) {\n /* istanbul ignore next */\n if (isComplete) return;\n\n isComplete = true;\n\n stream.removeListener('error', complete);\n stream.removeListener('end', complete);\n stream.removeListener('finish', complete);\n\n if (err) reject(err);\n else resolve(stream);\n }\n\n stream.once('error', complete);\n stream.once('end', complete);\n stream.once('finish', complete);\n });\n}\n","//#region Imports\n\nimport type {\n HuaweiApiGatewayEvent,\n HuaweiApiGatewayResponse,\n HuaweiContext,\n} from '../../@types/huawei';\nimport type {\n AdapterContract,\n AdapterRequest,\n GetResponseAdapterProps,\n OnErrorProps,\n} from '../../contracts';\nimport {\n getDefaultIfUndefined,\n getEventBodyAsBuffer,\n getFlattenedHeadersMap,\n getMultiValueHeadersMap,\n getPathWithQueryStringParams,\n} from '../../core';\n\n//#endregion\n\n/**\n * The options to customize the {@link HuaweiApiGatewayAdapter}\n *\n * @breadcrumb Adapters / Huawei / HuaweiApiGatewayAdapter\n * @public\n */\nexport interface HuaweiApiGatewayOptions {\n /**\n * Strip base path for custom domains\n *\n * @defaultValue ''\n */\n stripBasePath?: string;\n}\n\n/**\n * The adapter to handle requests from Huawei Api Gateway\n *\n * @example\n * ```typescript\n * const stripBasePath = '/any/custom/base/path'; // default ''\n * const adapter = new ApiGatewayAdapter({ stripBasePath });\n * ```\n *\n * @breadcrumb Adapters / Huawei / HuaweiApiGatewayAdapter\n * @public\n *\n * {@link https://support.huaweicloud.com/intl/en-us/devg-functiongraph/functiongraph_02_0102.html#functiongraph_02_0102__li5178638110137 | Event Reference}\n */\nexport class HuaweiApiGatewayAdapter\n implements\n AdapterContract<\n HuaweiApiGatewayEvent,\n HuaweiContext,\n HuaweiApiGatewayResponse\n >\n{\n //#region Constructor\n\n /**\n * Default constructor\n *\n * @param options - The options to customize the {@link HuaweiApiGatewayAdapter}\n */\n constructor(protected readonly options?: HuaweiApiGatewayOptions) {}\n\n //#endregion\n\n //#region Public Methods\n\n /**\n * {@inheritDoc}\n */\n public getAdapterName(): string {\n return HuaweiApiGatewayAdapter.name;\n }\n\n /**\n * {@inheritDoc}\n */\n public canHandle(event: unknown): event is HuaweiApiGatewayEvent {\n const apiGatewayEvent = event as Partial<HuaweiApiGatewayEvent>;\n\n return !!(\n apiGatewayEvent &&\n apiGatewayEvent.httpMethod &&\n apiGatewayEvent.requestContext &&\n apiGatewayEvent.requestContext.apiId &&\n apiGatewayEvent.requestContext.stage &&\n apiGatewayEvent.requestContext.requestId &&\n // to avoid conflict with api gateway v1 of aws\n !('multiValueQueryStringParameters' in apiGatewayEvent)\n );\n }\n\n /**\n * {@inheritDoc}\n */\n public getRequest(event: HuaweiApiGatewayEvent): AdapterRequest {\n const method = event.httpMethod;\n const path = this.getPathFromEvent(event);\n\n const headers = getFlattenedHeadersMap(event.headers, ',', true);\n\n let body: Buffer | undefined;\n\n if (event.body) {\n const [bufferBody, contentLength] = getEventBodyAsBuffer(\n event.body,\n event.isBase64Encoded,\n );\n\n body = bufferBody;\n headers['content-length'] = String(contentLength);\n }\n\n const remoteAddress = headers['x-real-ip'];\n\n return {\n method,\n headers,\n body,\n remoteAddress,\n path,\n };\n }\n\n /**\n * {@inheritDoc}\n */\n public getResponse({\n headers: responseHeaders,\n body,\n isBase64Encoded,\n statusCode,\n }: GetResponseAdapterProps<HuaweiApiGatewayEvent>): HuaweiApiGatewayResponse {\n const headers = getMultiValueHeadersMap(responseHeaders);\n\n return {\n statusCode,\n body,\n headers,\n isBase64Encoded,\n };\n }\n\n /**\n * {@inheritDoc}\n */\n public onErrorWhileForwarding({\n error,\n delegatedResolver,\n respondWithErrors,\n event,\n log,\n }: OnErrorProps<HuaweiApiGatewayEvent, HuaweiApiGatewayResponse>): void {\n const body = respondWithErrors ? error.stack : '';\n const errorResponse = this.getResponse({\n event,\n statusCode: 500,\n body: body || '',\n headers: {},\n isBase64Encoded: false,\n log,\n });\n\n delegatedResolver.succeed(errorResponse);\n }\n\n //#endregion\n\n //#region Protected Methods\n\n /**\n * Get path from event with query strings\n *\n * @param event - The event sent by serverless\n */\n protected getPathFromEvent(event: HuaweiApiGatewayEvent): string {\n const stripBasePath = getDefaultIfUndefined(\n this.options?.stripBasePath,\n '',\n );\n const replaceRegex = new RegExp(`^${stripBasePath}`);\n const path = event.path.replace(replaceRegex, '');\n\n const queryParams = event.queryStringParameters;\n\n return getPathWithQueryStringParams(path, queryParams);\n }\n\n //#endregion\n}\n"],"mappings":"4dAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,6BAAAE,IAAA,eAAAC,EAAAH,GCCA,IAAAI,EAAgC,gBCAhC,IAAAC,EAAgD,gBCKzC,SAASC,EAAUC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ACd,GAAM,CAACO,EAAYC,CAAa,EAAIC,EAClCT,EAAM,KACNA,EAAM,eACR,EAEAM,EAAOC,EACPH,EAAQ,gBAAgB,EAAI,OAAOI,CAAa,CAClD,CAEA,IAAME,EAAgBN,EAAQ,WAAW,EAEzC,MAAO,CACL,OAAAF,EACA,QAAAE,EACA,KAAAE,EACA,cAAAI,EACA,KAAAP,CACF,CACF,CAKO,YAAY,CACjB,QAASQ,EACT,KAAAL,EACA,gBAAAM,EACA,WAAAC,CACF,EAA6E,CAC3E,IAAMT,EAAUU,EAAwBH,CAAe,EAEvD,MAAO,CACL,WAAAE,EACA,KAAAP,EACA,QAAAF,EACA,gBAAAQ,CACF,CACF,CAKO,uBAAuB,CAC5B,MAAAG,EACA,kBAAAC,EACA,kBAAAC,EACA,MAAAjB,EACA,IAAAkB,CACF,EAAwE,CACtE,IAAMZ,EAAOW,EAAoBF,EAAM,MAAQ,GACzCI,EAAgB,KAAK,YAAY,CACrC,MAAAnB,EACA,WAAY,IACZ,KAAMM,GAAQ,GACd,QAAS,CAAC,EACV,gBAAiB,GACjB,IAAAY,CACF,CAAC,EAEDF,EAAkB,QAAQG,CAAa,CACzC,CAWU,iBAAiBnB,EAAsC,CAC/D,IAAMoB,EAAgBC,EACpB,KAAK,SAAS,cACd,EACF,EACMC,EAAe,IAAI,OAAO,IAAIF,CAAa,EAAE,EAC7CjB,EAAOH,EAAM,KAAK,QAAQsB,EAAc,EAAE,EAE1CC,EAAcvB,EAAM,sBAE1B,OAAOwB,EAA6BrB,EAAMoB,CAAW,CACvD,CAGF","names":["huawei_exports","__export","HuaweiApiGatewayAdapter","__toCommonJS","import_node_http","import_node_http","getString","data","__name","headerEnd","endChunked","BODY","HEADERS","addData","stream","data","__name","ServerlessResponse","_ServerlessResponse","method","writesToIgnore","socket","NO_OP","encoding","cb","string","getString","index","remainder","res","response","headers","key","value","statusCode","statusMessage","obj","headersObjOrArray","arrayHeaders","name","import_node_http","getEventBodyAsBuffer","body","isBase64Encoded","encoding","buffer","contentLength","__name","getFlattenedHeadersMap","headersMap","separator","lowerCaseKey","acc","headerKey","newKey","headerValue","__name","getMultiValueHeadersMap","NO_OP","__name","InternalLoggerSymbol","getDefaultIfUndefined","value","defaultValue","__name","getPathWithQueryStringParams","path","queryParams","queryParamsString","getQueryParamsStringFromRecord","__name","queryParamsRecord","searchParams","multiValueHeadersEntries","key","value","arrayValue","import_node_stream","HuaweiApiGatewayAdapter","_HuaweiApiGatewayAdapter","options","__name","event","apiGatewayEvent","method","path","headers","getFlattenedHeadersMap","body","bufferBody","contentLength","getEventBodyAsBuffer","remoteAddress","responseHeaders","isBase64Encoded","statusCode","getMultiValueHeadersMap","error","delegatedResolver","respondWithErrors","log","errorResponse","stripBasePath","getDefaultIfUndefined","replaceRegex","queryParams","getPathWithQueryStringParams"]}
|
|
@@ -0,0 +1,365 @@
|
|
|
1
|
+
import { B as BothValueHeaders, M as MultiValueHeaders } from '../../headers-K2qbcurv.cjs';
|
|
2
|
+
import { A as AdapterContract, a as AdapterRequest, G as GetResponseAdapterProps, O as OnErrorProps } from '../../adapter.contract-y5xSjOjo.cjs';
|
|
3
|
+
import 'http';
|
|
4
|
+
import 'node:http';
|
|
5
|
+
import '../../logger-9me5n48P.cjs';
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* The return value of {@link HuaweiContext} getRequestID
|
|
9
|
+
*
|
|
10
|
+
* @public
|
|
11
|
+
* @breadcrumb Types / Huawei / HuaweiContext
|
|
12
|
+
*/
|
|
13
|
+
type GetRequestIDSecondsReturn = string;
|
|
14
|
+
/**
|
|
15
|
+
* The return value of {@link HuaweiContext} getRemainingTimeInMilliSeconds
|
|
16
|
+
*
|
|
17
|
+
* @public
|
|
18
|
+
* @breadcrumb Types / Huawei / HuaweiContext
|
|
19
|
+
*/
|
|
20
|
+
type GetRemainingTimeInMilliSecondsReturn = number;
|
|
21
|
+
/**
|
|
22
|
+
* The return value of {@link HuaweiContext} getAccessKey
|
|
23
|
+
*
|
|
24
|
+
* @public
|
|
25
|
+
* @breadcrumb Types / Huawei / HuaweiContext
|
|
26
|
+
*/
|
|
27
|
+
type GetAccessKeyReturn = string;
|
|
28
|
+
/**
|
|
29
|
+
* The return value of {@link HuaweiContext} getSecretKey
|
|
30
|
+
*
|
|
31
|
+
* @public
|
|
32
|
+
* @breadcrumb Types / Huawei / HuaweiContext
|
|
33
|
+
*/
|
|
34
|
+
type GetSecretKeyReturn = string;
|
|
35
|
+
/**
|
|
36
|
+
* The parameters of the method {@link HuaweiContext} getUserData
|
|
37
|
+
*
|
|
38
|
+
* @public
|
|
39
|
+
* @breadcrumb Types / Huawei / HuaweiContext
|
|
40
|
+
*/
|
|
41
|
+
type GetUserDataKeyParameter = string;
|
|
42
|
+
/**
|
|
43
|
+
* The return value of {@link HuaweiContext} getUserData
|
|
44
|
+
*
|
|
45
|
+
* @public
|
|
46
|
+
* @breadcrumb Types / Huawei / HuaweiContext
|
|
47
|
+
*/
|
|
48
|
+
type GetUserDataReturn = any;
|
|
49
|
+
/**
|
|
50
|
+
* The return value of {@link HuaweiContext} getFunctionName
|
|
51
|
+
*
|
|
52
|
+
* @public
|
|
53
|
+
* @breadcrumb Types / Huawei / HuaweiContext
|
|
54
|
+
*/
|
|
55
|
+
type GetFunctionNameReturn = string;
|
|
56
|
+
/**
|
|
57
|
+
* The return value of {@link HuaweiContext} getRunningTimeInSeconds
|
|
58
|
+
*
|
|
59
|
+
* @public
|
|
60
|
+
* @breadcrumb Types / Huawei / HuaweiContext
|
|
61
|
+
*/
|
|
62
|
+
type GetRunningTimeInSecondsReturn = number;
|
|
63
|
+
/**
|
|
64
|
+
* The return value of {@link HuaweiContext} getVersion
|
|
65
|
+
*
|
|
66
|
+
* @public
|
|
67
|
+
* @breadcrumb Types / Huawei / HuaweiContext
|
|
68
|
+
*/
|
|
69
|
+
type GetVersionReturn = string;
|
|
70
|
+
/**
|
|
71
|
+
* The return value of {@link HuaweiContext} getMemorySize
|
|
72
|
+
*
|
|
73
|
+
* @public
|
|
74
|
+
* @breadcrumb Types / Huawei / HuaweiContext
|
|
75
|
+
*/
|
|
76
|
+
type GetMemorySizeReturn = number;
|
|
77
|
+
/**
|
|
78
|
+
* The return value of {@link HuaweiContext} getCPUNumber
|
|
79
|
+
*
|
|
80
|
+
* @public
|
|
81
|
+
* @breadcrumb Types / Huawei / HuaweiContext
|
|
82
|
+
*/
|
|
83
|
+
type GetCPUNumberReturn = number;
|
|
84
|
+
/**
|
|
85
|
+
* The return value of {@link HuaweiContext} getProjectID
|
|
86
|
+
*
|
|
87
|
+
* @public
|
|
88
|
+
* @breadcrumb Types / Huawei / HuaweiContext
|
|
89
|
+
*/
|
|
90
|
+
type GetProjectIdReturn = number;
|
|
91
|
+
/**
|
|
92
|
+
* The return value of {@link HuaweiContext} getPackage
|
|
93
|
+
*
|
|
94
|
+
* @public
|
|
95
|
+
* @breadcrumb Types / Huawei / HuaweiContext
|
|
96
|
+
*/
|
|
97
|
+
type GetPackageReturn = string;
|
|
98
|
+
/**
|
|
99
|
+
* The return value of {@link HuaweiContext} getToken
|
|
100
|
+
*
|
|
101
|
+
* @public
|
|
102
|
+
* @breadcrumb Types / Huawei / HuaweiContext
|
|
103
|
+
*/
|
|
104
|
+
type GetTokenReturn = string;
|
|
105
|
+
/**
|
|
106
|
+
* The return value of {@link HuaweiContext} getLogger
|
|
107
|
+
*
|
|
108
|
+
* Is the instance of logger that can be used to send logs to
|
|
109
|
+
*
|
|
110
|
+
* @public
|
|
111
|
+
* @breadcrumb Types / Huawei / HuaweiContext
|
|
112
|
+
*/
|
|
113
|
+
type GetLoggerReturn = {
|
|
114
|
+
info(message: string): void;
|
|
115
|
+
};
|
|
116
|
+
/**
|
|
117
|
+
* The interface that represents methods sent by huawei to get information about the function graph.
|
|
118
|
+
* See more in {@link https://support.huaweicloud.com/intl/en-us/devg-functiongraph/functiongraph_02_0410.html#section1 | Context Methods}
|
|
119
|
+
*
|
|
120
|
+
* @public
|
|
121
|
+
* @breadcrumb Types / Huawei / HuaweiContext
|
|
122
|
+
*/
|
|
123
|
+
interface HuaweiContext {
|
|
124
|
+
/**
|
|
125
|
+
* Obtains a request ID.
|
|
126
|
+
*/
|
|
127
|
+
getRequestID(): GetRequestIDSecondsReturn;
|
|
128
|
+
/**
|
|
129
|
+
* Obtains the remaining running time of a function.
|
|
130
|
+
*/
|
|
131
|
+
getRemainingTimeInMilliSeconds(): GetRemainingTimeInMilliSecondsReturn;
|
|
132
|
+
/**
|
|
133
|
+
* Obtains the AK (valid for 24 hours) of an agency. If you use this method, you need to configure an agency for the function.
|
|
134
|
+
*/
|
|
135
|
+
getAccessKey(): GetAccessKeyReturn;
|
|
136
|
+
/**
|
|
137
|
+
* Obtains the SK (valid for 24 hours) of an agency. If you use this method, you need to configure an agency for the function.
|
|
138
|
+
*/
|
|
139
|
+
getSecretKey(): GetSecretKeyReturn;
|
|
140
|
+
/**
|
|
141
|
+
* Uses keys to obtain the values passed by environment variables.
|
|
142
|
+
*
|
|
143
|
+
* @param key - The key to get environment variables values
|
|
144
|
+
*/
|
|
145
|
+
getUserData(key: GetUserDataKeyParameter): GetUserDataReturn;
|
|
146
|
+
/**
|
|
147
|
+
* Obtains the name of a function.
|
|
148
|
+
*/
|
|
149
|
+
getFunctionName(): GetFunctionNameReturn;
|
|
150
|
+
/**
|
|
151
|
+
* Obtains the timeout of a function.
|
|
152
|
+
*/
|
|
153
|
+
getRunningTimeInSeconds(): GetRunningTimeInSecondsReturn;
|
|
154
|
+
/**
|
|
155
|
+
* Obtains the version of a function.
|
|
156
|
+
*/
|
|
157
|
+
getVersion(): GetVersionReturn;
|
|
158
|
+
/**
|
|
159
|
+
* Obtains the allocated memory.
|
|
160
|
+
*/
|
|
161
|
+
getMemorySize(): GetMemorySizeReturn;
|
|
162
|
+
/**
|
|
163
|
+
* Number of CPU millicores used by the function (1 core = 1000 millicores).
|
|
164
|
+
*
|
|
165
|
+
* The value of this field is proportional to that of MemorySize. By default, 100 CPU millicores are required for 128 MB memory. The number of CPU millicores is calculated as follows: Memory/128 x 100 + 200 (basic CPU millicores).
|
|
166
|
+
*/
|
|
167
|
+
getCPUNumber(): GetCPUNumberReturn;
|
|
168
|
+
/**
|
|
169
|
+
* Obtains a project ID.
|
|
170
|
+
*/
|
|
171
|
+
getProjectID(): GetProjectIdReturn;
|
|
172
|
+
/**
|
|
173
|
+
* Obtains a function group, that is, an app.
|
|
174
|
+
*/
|
|
175
|
+
getPackage(): GetPackageReturn;
|
|
176
|
+
/**
|
|
177
|
+
* Obtains the token (valid for 24 hours) of an agency. If you use this method, you need to configure an agency for the function.
|
|
178
|
+
*/
|
|
179
|
+
getToken(): GetTokenReturn;
|
|
180
|
+
/**
|
|
181
|
+
* Obtains the logger method provided by the context and returns a log output class. Logs are output in the format of Time-Request ID-Content by using the info method.
|
|
182
|
+
*
|
|
183
|
+
* For example, use the info method to output logs:
|
|
184
|
+
*
|
|
185
|
+
* @example
|
|
186
|
+
* ```typescript
|
|
187
|
+
* logg = context.getLogger()
|
|
188
|
+
*
|
|
189
|
+
* logg.info("hello")
|
|
190
|
+
* ```
|
|
191
|
+
*/
|
|
192
|
+
getLogger(): GetLoggerReturn;
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
/**
|
|
196
|
+
* The interface that represents the Api Gateway Event of Huawei when integrate with Function Graph of Event Type.
|
|
197
|
+
* See more in {@link https://support.huaweicloud.com/intl/en-us/devg-functiongraph/functiongraph_02_0102.html#functiongraph_02_0102__li5178638110137 | Reference}.
|
|
198
|
+
*
|
|
199
|
+
* @public
|
|
200
|
+
* @breadcrumb Types / Huawei / HuaweiApiGatewayEvent
|
|
201
|
+
*/
|
|
202
|
+
interface HuaweiApiGatewayEvent {
|
|
203
|
+
/**
|
|
204
|
+
* The body value with the content of this event serialized in JSON
|
|
205
|
+
*/
|
|
206
|
+
body: string;
|
|
207
|
+
/**
|
|
208
|
+
* The headers of the request which this event represents
|
|
209
|
+
*/
|
|
210
|
+
headers: BothValueHeaders;
|
|
211
|
+
/**
|
|
212
|
+
* The HTTP Method of the request which this event represents
|
|
213
|
+
*/
|
|
214
|
+
httpMethod: string;
|
|
215
|
+
/**
|
|
216
|
+
* Tells if the body is base64 encoded
|
|
217
|
+
*/
|
|
218
|
+
isBase64Encoded: boolean;
|
|
219
|
+
/**
|
|
220
|
+
* The path of the request which this event represents
|
|
221
|
+
*/
|
|
222
|
+
path: string;
|
|
223
|
+
/**
|
|
224
|
+
* The path parameters of the request which this event represents
|
|
225
|
+
*/
|
|
226
|
+
pathParameters: HuaweiRequestPathParameters;
|
|
227
|
+
/**
|
|
228
|
+
* The query strings of the request which this event represents
|
|
229
|
+
*/
|
|
230
|
+
queryStringParameters: HuaweiRequestQueryStringParameters;
|
|
231
|
+
/**
|
|
232
|
+
* The request context with information about the stage, api and requestId
|
|
233
|
+
*/
|
|
234
|
+
requestContext: HuaweiRequestContext;
|
|
235
|
+
/**
|
|
236
|
+
* It can have more properties that I could not discover yet
|
|
237
|
+
*/
|
|
238
|
+
[key: string]: any;
|
|
239
|
+
}
|
|
240
|
+
/**
|
|
241
|
+
* The path parameters of the request, usually is the name of the wildcard you create in FunctionGraph, such as /\{proxy\}.
|
|
242
|
+
*
|
|
243
|
+
* @public
|
|
244
|
+
* @breadcrumb Types / Huawei / HuaweiApiGatewayEvent
|
|
245
|
+
*/
|
|
246
|
+
type HuaweiRequestPathParameters = Record<string, string>;
|
|
247
|
+
/**
|
|
248
|
+
* The query strings of the request
|
|
249
|
+
*
|
|
250
|
+
* @public
|
|
251
|
+
* @breadcrumb Types / Huawei / HuaweiApiGatewayEvent
|
|
252
|
+
*/
|
|
253
|
+
type HuaweiRequestQueryStringParameters = Record<string, string | string[]>;
|
|
254
|
+
/**
|
|
255
|
+
* The interface that represents the values you can get inside request context.
|
|
256
|
+
*
|
|
257
|
+
* @public
|
|
258
|
+
* @breadcrumb Types / Huawei / HuaweiApiGatewayEvent
|
|
259
|
+
*/
|
|
260
|
+
interface HuaweiRequestContext {
|
|
261
|
+
/**
|
|
262
|
+
* The ID of your API inside Api Gateway
|
|
263
|
+
*/
|
|
264
|
+
apiId: string;
|
|
265
|
+
/**
|
|
266
|
+
* The ID of this request
|
|
267
|
+
*/
|
|
268
|
+
requestId: string;
|
|
269
|
+
/**
|
|
270
|
+
* The name of the stage running this Function Graph
|
|
271
|
+
*/
|
|
272
|
+
stage: string;
|
|
273
|
+
}
|
|
274
|
+
|
|
275
|
+
/**
|
|
276
|
+
* The interface that represents the Api Gateway Response of Huawei when integrate with Function Graph of Event Type.
|
|
277
|
+
* See more in {@link https://support.huaweicloud.com/intl/en-us/devg-functiongraph/functiongraph_02_0102.html#functiongraph_02_0102__li5178638110137 | Reference}.
|
|
278
|
+
*
|
|
279
|
+
* @public
|
|
280
|
+
* @breadcrumb Types / Huawei / HuaweiApiGatewayResponse
|
|
281
|
+
*/
|
|
282
|
+
interface HuaweiApiGatewayResponse {
|
|
283
|
+
/**
|
|
284
|
+
* Tells if the body was encoded as base64
|
|
285
|
+
*/
|
|
286
|
+
isBase64Encoded: boolean;
|
|
287
|
+
/**
|
|
288
|
+
* The HTTP Status code of this response
|
|
289
|
+
*/
|
|
290
|
+
statusCode: number;
|
|
291
|
+
/**
|
|
292
|
+
* The headers sent with this response
|
|
293
|
+
*/
|
|
294
|
+
headers: MultiValueHeaders;
|
|
295
|
+
/**
|
|
296
|
+
* The body value with the content of this response serialized in JSON
|
|
297
|
+
*/
|
|
298
|
+
body: string;
|
|
299
|
+
}
|
|
300
|
+
|
|
301
|
+
/**
|
|
302
|
+
* The options to customize the {@link HuaweiApiGatewayAdapter}
|
|
303
|
+
*
|
|
304
|
+
* @breadcrumb Adapters / Huawei / HuaweiApiGatewayAdapter
|
|
305
|
+
* @public
|
|
306
|
+
*/
|
|
307
|
+
interface HuaweiApiGatewayOptions {
|
|
308
|
+
/**
|
|
309
|
+
* Strip base path for custom domains
|
|
310
|
+
*
|
|
311
|
+
* @defaultValue ''
|
|
312
|
+
*/
|
|
313
|
+
stripBasePath?: string;
|
|
314
|
+
}
|
|
315
|
+
/**
|
|
316
|
+
* The adapter to handle requests from Huawei Api Gateway
|
|
317
|
+
*
|
|
318
|
+
* @example
|
|
319
|
+
* ```typescript
|
|
320
|
+
* const stripBasePath = '/any/custom/base/path'; // default ''
|
|
321
|
+
* const adapter = new ApiGatewayAdapter({ stripBasePath });
|
|
322
|
+
* ```
|
|
323
|
+
*
|
|
324
|
+
* @breadcrumb Adapters / Huawei / HuaweiApiGatewayAdapter
|
|
325
|
+
* @public
|
|
326
|
+
*
|
|
327
|
+
* {@link https://support.huaweicloud.com/intl/en-us/devg-functiongraph/functiongraph_02_0102.html#functiongraph_02_0102__li5178638110137 | Event Reference}
|
|
328
|
+
*/
|
|
329
|
+
declare class HuaweiApiGatewayAdapter implements AdapterContract<HuaweiApiGatewayEvent, HuaweiContext, HuaweiApiGatewayResponse> {
|
|
330
|
+
protected readonly options?: HuaweiApiGatewayOptions | undefined;
|
|
331
|
+
/**
|
|
332
|
+
* Default constructor
|
|
333
|
+
*
|
|
334
|
+
* @param options - The options to customize the {@link HuaweiApiGatewayAdapter}
|
|
335
|
+
*/
|
|
336
|
+
constructor(options?: HuaweiApiGatewayOptions | undefined);
|
|
337
|
+
/**
|
|
338
|
+
* {@inheritDoc}
|
|
339
|
+
*/
|
|
340
|
+
getAdapterName(): string;
|
|
341
|
+
/**
|
|
342
|
+
* {@inheritDoc}
|
|
343
|
+
*/
|
|
344
|
+
canHandle(event: unknown): event is HuaweiApiGatewayEvent;
|
|
345
|
+
/**
|
|
346
|
+
* {@inheritDoc}
|
|
347
|
+
*/
|
|
348
|
+
getRequest(event: HuaweiApiGatewayEvent): AdapterRequest;
|
|
349
|
+
/**
|
|
350
|
+
* {@inheritDoc}
|
|
351
|
+
*/
|
|
352
|
+
getResponse({ headers: responseHeaders, body, isBase64Encoded, statusCode, }: GetResponseAdapterProps<HuaweiApiGatewayEvent>): HuaweiApiGatewayResponse;
|
|
353
|
+
/**
|
|
354
|
+
* {@inheritDoc}
|
|
355
|
+
*/
|
|
356
|
+
onErrorWhileForwarding({ error, delegatedResolver, respondWithErrors, event, log, }: OnErrorProps<HuaweiApiGatewayEvent, HuaweiApiGatewayResponse>): void;
|
|
357
|
+
/**
|
|
358
|
+
* Get path from event with query strings
|
|
359
|
+
*
|
|
360
|
+
* @param event - The event sent by serverless
|
|
361
|
+
*/
|
|
362
|
+
protected getPathFromEvent(event: HuaweiApiGatewayEvent): string;
|
|
363
|
+
}
|
|
364
|
+
|
|
365
|
+
export { HuaweiApiGatewayAdapter, type HuaweiApiGatewayOptions };
|