@alipay/faas-server-sdk
Advanced tools
Comparing version 0.0.28 to 0.0.29
@@ -1,2 +0,2 @@ | ||
import { CallFunctionParam, CallFunctionResult, CloudConfig } from './types'; | ||
import type { CallFunctionParam, CallFunctionResult, CloudConfig } from './types'; | ||
export declare function callFunction<T = any>(config: CloudConfig, param: CallFunctionParam): Promise<CallFunctionResult<T>>; |
@@ -1,1 +0,1 @@ | ||
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.callFunction=void 0;const errors_1=require("./errors"),middlewares_1=require("./requester/middlewares");async function callFunction(t,r){if(!r.name)throw errors_1.errors.INVALID_PARAM("name","\u51FD\u6570\u540D\u4E0D\u80FD\u4E3A\u7A7A");const n={"x-to-function-name":r.name},o="POST",s=buildUrl(t),u={requestData:r.data},e=await middlewares_1.HttpRequester.function.request(o,s,u,n,{cloudConfig:t});if(e.succeed)return{requestId:e.requestId,requestID:e.requestId,result:e.data};throw errors_1.errors.CALL_FUNCTION_ERR(e)}exports.callFunction=callFunction;function buildUrl(t){return`${t.functionGatewayEndpoint}/functions/invokeFunction`} | ||
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.callFunction=void 0;const errors_1=require("./errors"),middlewares_1=require("./requester/middlewares");async function callFunction(t,r){if(!r.name)throw errors_1.errors.INVALID_PARAM("name","cannot be an empty string");const n={"x-to-function-name":r.name},o="POST",s=buildUrl(t),u={requestData:r.data},e=await middlewares_1.HttpRequester.function.request(o,s,u,n,{cloudConfig:t});if(e.succeed)return{requestId:e.requestId,requestID:e.requestId,result:e.data};throw errors_1.errors.CALL_FUNCTION_ERR(e)}exports.callFunction=callFunction;function buildUrl(t){return`${t.functionGatewayEndpoint}/functions/invokeFunction`} |
@@ -1,2 +0,2 @@ | ||
import type { AlipayContext, CallFunctionParam } from './types'; | ||
import type { AlipayContext, CallFunctionParam, UploadFileParam, DownloadFileParam } from './types'; | ||
import { Database } from './Database'; | ||
@@ -14,2 +14,6 @@ import { MySQL } from './MySQL'; | ||
mysql(): MySQL; | ||
uploadFile(param: UploadFileParam): Promise<import("./types").UploadFileResult>; | ||
downloadFile(param: DownloadFileParam): Promise<import("./types").DownloadFileResult>; | ||
deleteFile(fileList: string[]): Promise<import("./types").DeleteFileResult>; | ||
getTempFileURL(fileList: string[]): Promise<import("./types").GetTempFileURLResult>; | ||
} | ||
@@ -16,0 +20,0 @@ export type CloudInitOptions = { |
@@ -1,1 +0,1 @@ | ||
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.Cloud=exports.initRuntimeEnv=void 0;const callFunction_1=require("./callFunction"),Database_1=require("./Database"),MySQL_1=require("./MySQL"),utils_1=require("./utils"),runtimeEnv={RUNTIME_ACCESS_KEY:process.env.RUNTIME_ACCESS_KEY||"",RUNTIME_SECRET_KEY:process.env.RUNTIME_SECRET_KEY||"",RUNTIME_ENV_ID:process.env.RUNTIME_ENV_ID||"",RUNTIME_FUNCTION_NAME:process.env.RUNTIME_FUNCTION_NAME||"",RUNTIME_FUNCTION_GATEWAY_ENDPOINT:process.env.RUNTIME_FUNCTION_GATEWAY_ENDPOINT||"",RUNTIME_FUNCTION_INSTANCE_ID:process.env.RUNTIME_FUNCTION_INSTANCE_ID||"",RUNTIME_MONGO_CLUSTER_ENDPOINT:process.env.RUNTIME_MONGO_CLUSTER_ENDPOINT||"",RUNTIME_MONGO_DATABASE_NAME:process.env.RUNTIME_MONGO_DATABASE_NAME||""};function initRuntimeEnv(E){Object.assign(runtimeEnv,E)}exports.initRuntimeEnv=initRuntimeEnv;class Cloud{#N;#E;#_;constructor(){this.refreshConfig()}refreshConfig(){this.#N?(runtimeEnv.RUNTIME_ACCESS_KEY&&(this.#N.secretId=runtimeEnv.RUNTIME_ACCESS_KEY),runtimeEnv.RUNTIME_SECRET_KEY&&(this.#N.secretKey=runtimeEnv.RUNTIME_SECRET_KEY),runtimeEnv.RUNTIME_ENV_ID&&(this.#N.fromEnvId=runtimeEnv.RUNTIME_ENV_ID,this.#N.toEnvId||(this.#N.toEnvId=runtimeEnv.RUNTIME_ENV_ID)),runtimeEnv.RUNTIME_FUNCTION_NAME&&(this.#N.functionName=runtimeEnv.RUNTIME_FUNCTION_NAME),runtimeEnv.RUNTIME_FUNCTION_GATEWAY_ENDPOINT&&(this.#N.functionGatewayEndpoint=runtimeEnv.RUNTIME_FUNCTION_GATEWAY_ENDPOINT),runtimeEnv.RUNTIME_FUNCTION_INSTANCE_ID&&(this.#N.functionInstanceId=runtimeEnv.RUNTIME_FUNCTION_INSTANCE_ID),runtimeEnv.RUNTIME_MONGO_CLUSTER_ENDPOINT&&(this.#N.functionDatabaseEndpoint=runtimeEnv.RUNTIME_MONGO_CLUSTER_ENDPOINT),runtimeEnv.RUNTIME_MONGO_DATABASE_NAME&&(this.#N.functionDatabaseName=runtimeEnv.RUNTIME_MONGO_DATABASE_NAME)):this.#N={secretId:runtimeEnv.RUNTIME_ACCESS_KEY,secretKey:runtimeEnv.RUNTIME_SECRET_KEY,fromEnvId:runtimeEnv.RUNTIME_ENV_ID,toEnvId:runtimeEnv.RUNTIME_ENV_ID,functionName:runtimeEnv.RUNTIME_FUNCTION_NAME,functionGatewayEndpoint:runtimeEnv.RUNTIME_FUNCTION_GATEWAY_ENDPOINT,functionInstanceId:runtimeEnv.RUNTIME_FUNCTION_INSTANCE_ID,functionDatabaseEndpoint:runtimeEnv.RUNTIME_MONGO_CLUSTER_ENDPOINT,functionDatabaseName:runtimeEnv.RUNTIME_MONGO_DATABASE_NAME}}init(N){N?.env&&typeof N?.env=="string"&&(this.#N.toEnvId=N.env),N?.envId&&(this.#N.toEnvId=N.envId)}getAlipayContext(){return(0,utils_1.getAlipayContext)()}async callFunction(N){return await(0,callFunction_1.callFunction)(this.#N,N)}database(){return this.#E||(this.#E=new Database_1.Database(this.#N)),this.#E}mysql(){return this.#_||(this.#_=new MySQL_1.MySQL(this.#N)),this.#_}}exports.Cloud=Cloud; | ||
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.Cloud=exports.initRuntimeEnv=void 0;const callFunction_1=require("./callFunction"),Database_1=require("./Database"),Storage_1=require("./Storage"),MySQL_1=require("./MySQL"),utils_1=require("./utils"),runtimeEnv={RUNTIME_ACCESS_KEY:process.env.RUNTIME_ACCESS_KEY||"",RUNTIME_SECRET_KEY:process.env.RUNTIME_SECRET_KEY||"",RUNTIME_ENV_ID:process.env.RUNTIME_ENV_ID||"",RUNTIME_FUNCTION_NAME:process.env.RUNTIME_FUNCTION_NAME||"",RUNTIME_FUNCTION_GATEWAY_ENDPOINT:process.env.RUNTIME_FUNCTION_GATEWAY_ENDPOINT||"",RUNTIME_FUNCTION_INSTANCE_ID:process.env.RUNTIME_FUNCTION_INSTANCE_ID||"",RUNTIME_MONGO_CLUSTER_ENDPOINT:process.env.RUNTIME_MONGO_CLUSTER_ENDPOINT||"",RUNTIME_MONGO_DATABASE_NAME:process.env.RUNTIME_MONGO_DATABASE_NAME||"",RUNTIME_OSS_ENDPOINT:process.env.RUNTIME_OSS_ENDPOINT||""};function initRuntimeEnv(t){Object.assign(runtimeEnv,t)}exports.initRuntimeEnv=initRuntimeEnv;class Cloud{#N;#E;#e;#_;constructor(){this.refreshConfig()}refreshConfig(){this.#N?(runtimeEnv.RUNTIME_ACCESS_KEY&&(this.#N.secretId=runtimeEnv.RUNTIME_ACCESS_KEY),runtimeEnv.RUNTIME_SECRET_KEY&&(this.#N.secretKey=runtimeEnv.RUNTIME_SECRET_KEY),runtimeEnv.RUNTIME_ENV_ID&&(this.#N.fromEnvId=runtimeEnv.RUNTIME_ENV_ID,this.#N.toEnvId||(this.#N.toEnvId=runtimeEnv.RUNTIME_ENV_ID)),runtimeEnv.RUNTIME_FUNCTION_NAME&&(this.#N.functionName=runtimeEnv.RUNTIME_FUNCTION_NAME),runtimeEnv.RUNTIME_FUNCTION_GATEWAY_ENDPOINT&&(this.#N.functionGatewayEndpoint=runtimeEnv.RUNTIME_FUNCTION_GATEWAY_ENDPOINT),runtimeEnv.RUNTIME_FUNCTION_INSTANCE_ID&&(this.#N.functionInstanceId=runtimeEnv.RUNTIME_FUNCTION_INSTANCE_ID),runtimeEnv.RUNTIME_MONGO_CLUSTER_ENDPOINT&&(this.#N.functionDatabaseEndpoint=runtimeEnv.RUNTIME_MONGO_CLUSTER_ENDPOINT),runtimeEnv.RUNTIME_MONGO_DATABASE_NAME&&(this.#N.functionDatabaseName=runtimeEnv.RUNTIME_MONGO_DATABASE_NAME),runtimeEnv.RUNTIME_OSS_ENDPOINT&&(this.#N.functionStorageEndpoint=runtimeEnv.RUNTIME_OSS_ENDPOINT)):this.#N={secretId:runtimeEnv.RUNTIME_ACCESS_KEY,secretKey:runtimeEnv.RUNTIME_SECRET_KEY,fromEnvId:runtimeEnv.RUNTIME_ENV_ID,toEnvId:runtimeEnv.RUNTIME_ENV_ID,functionName:runtimeEnv.RUNTIME_FUNCTION_NAME,functionGatewayEndpoint:runtimeEnv.RUNTIME_FUNCTION_GATEWAY_ENDPOINT,functionInstanceId:runtimeEnv.RUNTIME_FUNCTION_INSTANCE_ID,functionDatabaseEndpoint:runtimeEnv.RUNTIME_MONGO_CLUSTER_ENDPOINT,functionDatabaseName:runtimeEnv.RUNTIME_MONGO_DATABASE_NAME,functionStorageEndpoint:runtimeEnv.RUNTIME_OSS_ENDPOINT}}init(N){N?.env&&typeof N?.env=="string"&&(this.#N.toEnvId=N.env),N?.envId&&(this.#N.toEnvId=N.envId)}getAlipayContext(){return(0,utils_1.getAlipayContext)()}async callFunction(N){return await(0,callFunction_1.callFunction)(this.#N,N)}database(){return this.#E||(this.#E=new Database_1.Database(this.#N)),this.#E}mysql(){return this.#_||(this.#_=new MySQL_1.MySQL(this.#N)),this.#_}#t(){return this.#e||(this.#e=new Storage_1.Storage(this.#N)),this.#e}async uploadFile(N){return await this.#t().uploadFile(N)}async downloadFile(N){return await this.#t().downloadFile(N)}async deleteFile(N){return await this.#t().deleteFile(N)}async getTempFileURL(N){return await this.#t().getTempFileURL(N)}}exports.Cloud=Cloud; |
@@ -5,2 +5,3 @@ import { HttpRequestFailedResult } from './types'; | ||
CALL_FUNCTION_ERR = "CALL_FUNCTION_ERR", | ||
CALL_STORAGE_ERR = "CALL_STORAGE_ERR", | ||
SYS_ERR = "SYS_ERR", | ||
@@ -12,6 +13,7 @@ NOT_FOUND = "NOT_FOUND" | ||
requestId: string; | ||
errCode: number; | ||
get requestID(): string; | ||
errCode: number; | ||
errMsg: string; | ||
get errMsg(): string; | ||
static create(code: ErrorCode, message: string, ...args: any[]): FunctionError; | ||
static createByHttpRequestFailedResult(code: ErrorCode, result: HttpRequestFailedResult): FunctionError; | ||
} | ||
@@ -21,4 +23,5 @@ export declare const errors: { | ||
CALL_FUNCTION_ERR(result: HttpRequestFailedResult): FunctionError; | ||
CALL_STORAGE_ERR(result: HttpRequestFailedResult): FunctionError; | ||
SYS_ERR(message?: string): FunctionError; | ||
NOT_FOUND(message: any): FunctionError; | ||
NOT_FOUND(message: string): FunctionError; | ||
}; |
@@ -1,1 +0,1 @@ | ||
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.errors=exports.FunctionError=exports.ErrorCode=void 0;const node_util_1=require("node:util");var ErrorCode;(function(r){r.INVALID_PARAM="INVALID_PARAM",r.CALL_FUNCTION_ERR="CALL_FUNCTION_ERR",r.SYS_ERR="SYS_ERR",r.NOT_FOUND="NOT_FOUND"})(ErrorCode=exports.ErrorCode||(exports.ErrorCode={}));class FunctionError extends Error{code;requestId;get requestID(){return this.requestId}errCode;errMsg;static create(e,o,...s){const t=new FunctionError((0,node_util_1.format)(o,...s));return t.code=e,t}}exports.FunctionError=FunctionError,exports.errors={INVALID_PARAM(r,e){return FunctionError.create(ErrorCode.INVALID_PARAM,`${r} \u53C2\u6570\u9519\u8BEF\uFF0C${e}`)},CALL_FUNCTION_ERR(r){const e=FunctionError.create(ErrorCode.CALL_FUNCTION_ERR,`requestId ${r.requestId}, ${r.errMsg}`);return e.requestId=r.requestId,e.errCode=r.errCode,e.errMsg=r.errMsg,e},SYS_ERR(r="\u5185\u90E8\u7CFB\u7EDF\u9519\u8BEF"){return FunctionError.create(ErrorCode.SYS_ERR,r)},NOT_FOUND(r){return FunctionError.create(ErrorCode.NOT_FOUND,r)}}; | ||
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.errors=exports.FunctionError=exports.ErrorCode=void 0;const node_util_1=require("node:util");var ErrorCode;(function(e){e.INVALID_PARAM="INVALID_PARAM",e.CALL_FUNCTION_ERR="CALL_FUNCTION_ERR",e.CALL_STORAGE_ERR="CALL_STORAGE_ERR",e.SYS_ERR="SYS_ERR",e.NOT_FOUND="NOT_FOUND"})(ErrorCode=exports.ErrorCode||(exports.ErrorCode={}));class FunctionError extends Error{code;requestId;errCode=-1;get requestID(){return this.requestId}get errMsg(){return this.message}static create(t,r,...R){const s=new FunctionError((0,node_util_1.format)(r,...R));return s.code=t,s}static createByHttpRequestFailedResult(t,r){const R=FunctionError.create(t,`requestId ${r.requestId}, ${r.errMsg}`);return R.requestId=r.requestId,R.errCode=r.errCode,R}}exports.FunctionError=FunctionError,exports.errors={INVALID_PARAM(e,t){return FunctionError.create(ErrorCode.INVALID_PARAM,`Invalid param "${e}", ${t}`)},CALL_FUNCTION_ERR(e){return FunctionError.createByHttpRequestFailedResult(ErrorCode.CALL_FUNCTION_ERR,e)},CALL_STORAGE_ERR(e){return FunctionError.createByHttpRequestFailedResult(ErrorCode.CALL_STORAGE_ERR,e)},SYS_ERR(e="\u5185\u90E8\u7CFB\u7EDF\u9519\u8BEF"){return FunctionError.create(ErrorCode.SYS_ERR,e)},NOT_FOUND(e){return FunctionError.create(ErrorCode.NOT_FOUND,e)}}; |
@@ -1,4 +0,4 @@ | ||
import { CallDatabaseResponse } from '../../types'; | ||
import type { Next } from 'koa'; | ||
import { HttpRequestContext } from './HttpRequestContext'; | ||
import type { CallDatabaseResponse } from '../../types'; | ||
import type { HttpRequestContext } from './HttpRequestContext'; | ||
export declare function callDatabaseMiddleware<T>(ctx: HttpRequestContext<CallDatabaseResponse<T>, T>, next: Next): Promise<void>; |
@@ -1,4 +0,4 @@ | ||
import { CallFunctionResponse } from '../../types'; | ||
import type { Next } from 'koa'; | ||
import { HttpRequestContext } from './HttpRequestContext'; | ||
import type { CallFunctionResponse } from '../../types'; | ||
import type { HttpRequestContext } from './HttpRequestContext'; | ||
export declare function callFunctionMiddleware<T>(ctx: HttpRequestContext<CallFunctionResponse | T, T>, next: Next): Promise<void>; |
@@ -1,3 +0,3 @@ | ||
import { HttpRequestContext } from './HttpRequestContext'; | ||
import type { Next } from 'koa'; | ||
import type { HttpRequestContext } from './HttpRequestContext'; | ||
export declare function callMiddleware(ctx: HttpRequestContext<unknown, unknown>, next: Next): Promise<void>; |
@@ -1,1 +0,1 @@ | ||
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.callMiddleware=void 0;const node_util_1=require("node:util"),urllib_1=require("urllib"),debug=(0,node_util_1.debuglog)("faas-server-sdk:httpRequest");async function callMiddleware(e,r){await r(),debug("%s %o with headers: %o",e.req.requestOptions.method,e.req.url,e.req.requestOptions.headers),e.res=await(0,urllib_1.request)(e.req.url,e.req.requestOptions),debug("%s %o got response status: %o, headers: %o, data: %o",e.req.requestOptions.method,e.req.url,e.res.status,e.res.headers,e.res.data)}exports.callMiddleware=callMiddleware; | ||
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.callMiddleware=void 0;const node_util_1=require("node:util"),urllib_1=require("urllib"),debug=(0,node_util_1.debuglog)("faas-server-sdk:httpRequest");async function callMiddleware(e,r){await r(),debug("%s %o with headers: %o, content: %o",e.req.requestOptions.method,e.req.url.href,e.req.requestOptions.headers,e.req.requestOptions.content),e.res=await(0,urllib_1.request)(e.req.url,e.req.requestOptions),debug("%s %o got response status: %o, headers: %o, data: %o",e.req.requestOptions.method,e.req.url.href,e.res.status,e.res.headers,e.res.data)}exports.callMiddleware=callMiddleware; |
@@ -1,3 +0,3 @@ | ||
import { HttpRequestContext } from './HttpRequestContext'; | ||
import type { Next } from 'koa'; | ||
import type { HttpRequestContext } from './HttpRequestContext'; | ||
export declare function errorHandlerMiddleware(ctx: HttpRequestContext<unknown, unknown>, next: Next): Promise<void>; |
@@ -1,3 +0,3 @@ | ||
import { CloudConfig, HttpRequest, HttpRequestResult } from '../../types'; | ||
import { HttpClientResponse } from 'urllib'; | ||
import type { HttpClientResponse } from 'urllib'; | ||
import type { CloudConfig, HttpRequest, HttpRequestResult } from '../../types'; | ||
export declare class HttpRequestContext<T, R> { | ||
@@ -4,0 +4,0 @@ readonly req: HttpRequest; |
/// <reference types="node" /> | ||
import { IncomingHttpHeaders } from 'node:http'; | ||
import { HttpMethod } from 'urllib'; | ||
import type { IncomingHttpHeaders } from 'node:http'; | ||
import type { HttpMethod } from 'urllib'; | ||
import type { Middleware } from 'koa-compose'; | ||
import { CloudConfig, HttpRequestResult } from '../../types'; | ||
import type { CloudConfig, HttpRequestResult } from '../../types'; | ||
import { HttpRequestContext } from './HttpRequestContext'; | ||
@@ -16,3 +16,4 @@ type Options = { | ||
static get database(): HttpRequester; | ||
static get storage(): HttpRequester; | ||
} | ||
export {}; |
@@ -1,1 +0,1 @@ | ||
"use strict";var __importDefault=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(exports,"__esModule",{value:!0}),exports.HttpRequester=void 0;const node_assert_1=__importDefault(require("node:assert")),koa_compose_1=__importDefault(require("koa-compose")),HttpRequestContext_1=require("./HttpRequestContext"),call_database_middleware_1=require("./call_database_middleware"),call_function_middleware_1=require("./call_function_middleware"),call_middleware_1=require("./call_middleware"),sign_middleware_factory_1=require("./sign_middleware_factory"),init_call_database_headers_middleware_1=require("./init_call_database_headers_middleware"),node_crypto_1=require("node:crypto"),error_handler_middleware_1=require("./error_handler_middleware");class HttpRequester{static#e;static#t;#r;constructor(e){this.#r=(0,koa_compose_1.default)(e)}async request(e,s,n,r,d){const a=d?.cloudConfig;(0,node_assert_1.default)(a,"cloud config not set");const o=JSON.stringify(n),l=(0,node_crypto_1.randomUUID)();r["x-request-id"]=l;const c={method:e,contentType:"application/json",content:o,dataType:"json",headers:r},_={url:new URL(s),requestOptions:c},i=new HttpRequestContext_1.HttpRequestContext(_,a);return await this.#r(i),i.result}static get function(){if(!this.#e){const e=[error_handler_middleware_1.errorHandlerMiddleware,(0,sign_middleware_factory_1.signMiddlewareFactory)(["x-to-function-name"]),call_function_middleware_1.callFunctionMiddleware,call_middleware_1.callMiddleware];this.#e=new HttpRequester(e)}return this.#e}static get database(){if(!this.#t){const e=[error_handler_middleware_1.errorHandlerMiddleware,init_call_database_headers_middleware_1.initCallDatabaseHeadersMiddleware,(0,sign_middleware_factory_1.signMiddlewareFactory)(["x-data-api-type","x-expire-timestamp"]),call_database_middleware_1.callDatabaseMiddleware,call_middleware_1.callMiddleware];this.#t=new HttpRequester(e)}return this.#t}}exports.HttpRequester=HttpRequester; | ||
"use strict";var __importDefault=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(exports,"__esModule",{value:!0}),exports.HttpRequester=void 0;const node_assert_1=__importDefault(require("node:assert")),node_crypto_1=require("node:crypto"),koa_compose_1=__importDefault(require("koa-compose")),HttpRequestContext_1=require("./HttpRequestContext"),call_database_middleware_1=require("./call_database_middleware"),call_function_middleware_1=require("./call_function_middleware"),call_middleware_1=require("./call_middleware"),sign_middleware_factory_1=require("./sign_middleware_factory"),init_call_dataproxy_headers_middleware_1=require("./init_call_dataproxy_headers_middleware"),error_handler_middleware_1=require("./error_handler_middleware");class HttpRequester{static#e;static#t;static#a;#r;constructor(e){this.#r=(0,koa_compose_1.default)(e)}async request(e,s,d,a,n){const r=n.cloudConfig;(0,node_assert_1.default)(r,"cloud config not set");const o=JSON.stringify(d),l=(0,node_crypto_1.randomUUID)();a["x-request-id"]=l;const c={method:e,contentType:"application/json",content:o,dataType:"json",headers:a},u={url:new URL(s),requestOptions:c},i=new HttpRequestContext_1.HttpRequestContext(u,r);return await this.#r(i),i.result}static get function(){if(!this.#e){const e=[error_handler_middleware_1.errorHandlerMiddleware,(0,sign_middleware_factory_1.signMiddlewareFactory)(["x-to-function-name"]),call_function_middleware_1.callFunctionMiddleware,call_middleware_1.callMiddleware];this.#e=new HttpRequester(e)}return this.#e}static get database(){if(!this.#t){const e=[error_handler_middleware_1.errorHandlerMiddleware,(0,init_call_dataproxy_headers_middleware_1.createInitCallDataProxyHeadersMiddleware)("mongo"),(0,sign_middleware_factory_1.signMiddlewareFactory)(["x-data-api-type","x-expire-timestamp"]),call_database_middleware_1.callDatabaseMiddleware,call_middleware_1.callMiddleware];this.#t=new HttpRequester(e)}return this.#t}static get storage(){if(!this.#a){const e=[error_handler_middleware_1.errorHandlerMiddleware,(0,init_call_dataproxy_headers_middleware_1.createInitCallDataProxyHeadersMiddleware)("oss"),(0,sign_middleware_factory_1.signMiddlewareFactory)(["x-data-api-type","x-expire-timestamp"]),call_database_middleware_1.callDatabaseMiddleware,call_middleware_1.callMiddleware];this.#a=new HttpRequester(e)}return this.#a}}exports.HttpRequester=HttpRequester; |
@@ -0,3 +1,3 @@ | ||
import type { Next } from 'koa'; | ||
import { HttpRequestContext } from './HttpRequestContext'; | ||
import type { Next } from 'koa'; | ||
export declare function signMiddlewareFactory(signedHeaders: string[]): (ctx: HttpRequestContext<unknown, unknown>, next: Next) => Promise<void>; |
@@ -1,2 +0,5 @@ | ||
import { RequestOptions } from 'urllib'; | ||
/// <reference types="node" /> | ||
/// <reference types="node" /> | ||
import type { Readable } from 'node:stream'; | ||
import type { RequestOptions } from 'urllib'; | ||
export interface AlipayContext { | ||
@@ -45,2 +48,9 @@ UNIONID: string; | ||
} | ||
export interface CallStorageResponse<T = object> { | ||
success: boolean; | ||
code: number; | ||
message: string; | ||
trace_id: string; | ||
data: T; | ||
} | ||
export interface HttpRequest { | ||
@@ -75,2 +85,3 @@ url: URL; | ||
functionDatabaseName?: string; | ||
functionStorageEndpoint?: string; | ||
} | ||
@@ -89,1 +100,30 @@ export interface CollectionDescription { | ||
} | ||
export interface UploadFileParam { | ||
cloudPath: string; | ||
fileContent: Buffer | Readable; | ||
} | ||
export interface UploadFileResult { | ||
fileID: string; | ||
statusCode: number; | ||
} | ||
export interface DownloadFileParam { | ||
fileID: string; | ||
} | ||
export interface DownloadFileResult { | ||
fileContent: Buffer; | ||
statusCode: number; | ||
} | ||
export interface FileInfo { | ||
fileID: string; | ||
status: number; | ||
errMsg: string; | ||
} | ||
export interface TempFileInfo extends FileInfo { | ||
tempFileURL: string; | ||
} | ||
export interface DeleteFileResult { | ||
fileList: FileInfo[]; | ||
} | ||
export interface GetTempFileURLResult { | ||
fileList: TempFileInfo[]; | ||
} |
{ | ||
"name": "@alipay/faas-server-sdk", | ||
"version": "0.0.28", | ||
"version": "0.0.29", | ||
"description": "云函数服务 SDK", | ||
@@ -5,0 +5,0 @@ "main": "lib/index.js", |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Environment variable access
Supply chain riskPackage accesses environment variables, which may be a sign of credential stuffing or data theft.
Found 1 instance in 1 package
Minified code
QualityThis package contains minified code. This may be harmless in some cases where minified code is included in packaged libraries, however packages on npm should not minify code.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
62967
98
576
41
29