@alipay/faas-server-sdk
Advanced tools
Comparing version 1.0.4 to 1.0.5-alpha.0
import { AlipayContext } from '@alipay/faas-server-utils'; | ||
import type { CallFunctionParam, UploadFileParam, DownloadFileParam } from './types'; | ||
import { Database } from './Database'; | ||
import { MySQL } from './MySQL'; | ||
import type { OpenapiFunction } from './Openapi'; | ||
import type { CallFunctionParam, DownloadFileParam, UploadFileParam } from './types'; | ||
export declare function initRuntimeEnv(env: Record<string, string>): void; | ||
@@ -15,2 +16,3 @@ export declare class Cloud { | ||
mysql(): MySQL; | ||
get openapi(): OpenapiFunction; | ||
uploadFile(param: UploadFileParam): Promise<import("./types").UploadFileResult>; | ||
@@ -17,0 +19,0 @@ downloadFile(param: DownloadFileParam): Promise<import("./types").DownloadFileResult>; |
@@ -1,1 +0,1 @@ | ||
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.Cloud=exports.initRuntimeEnv=void 0;const faas_server_utils_1=require("@alipay/faas-server-utils"),callFunction_1=require("./callFunction"),Database_1=require("./Database"),Storage_1=require("./Storage"),MySQL_1=require("./MySQL"),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,faas_server_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; | ||
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.Cloud=exports.initRuntimeEnv=void 0;const faas_server_utils_1=require("@alipay/faas-server-utils"),callFunction_1=require("./callFunction"),Database_1=require("./Database"),MySQL_1=require("./MySQL"),Openapi_1=require("./Openapi"),Storage_1=require("./Storage"),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(N){Object.assign(runtimeEnv,N)}exports.initRuntimeEnv=initRuntimeEnv;class Cloud{#t;#e;#E;#_;#i;constructor(){this.refreshConfig()}refreshConfig(){this.#t?(runtimeEnv.RUNTIME_ACCESS_KEY&&(this.#t.secretId=runtimeEnv.RUNTIME_ACCESS_KEY),runtimeEnv.RUNTIME_SECRET_KEY&&(this.#t.secretKey=runtimeEnv.RUNTIME_SECRET_KEY),runtimeEnv.RUNTIME_ENV_ID&&(this.#t.fromEnvId=runtimeEnv.RUNTIME_ENV_ID,this.#t.toEnvId||(this.#t.toEnvId=runtimeEnv.RUNTIME_ENV_ID)),runtimeEnv.RUNTIME_FUNCTION_NAME&&(this.#t.functionName=runtimeEnv.RUNTIME_FUNCTION_NAME),runtimeEnv.RUNTIME_FUNCTION_GATEWAY_ENDPOINT&&(this.#t.functionGatewayEndpoint=runtimeEnv.RUNTIME_FUNCTION_GATEWAY_ENDPOINT),runtimeEnv.RUNTIME_FUNCTION_INSTANCE_ID&&(this.#t.functionInstanceId=runtimeEnv.RUNTIME_FUNCTION_INSTANCE_ID),runtimeEnv.RUNTIME_MONGO_CLUSTER_ENDPOINT&&(this.#t.functionDatabaseEndpoint=runtimeEnv.RUNTIME_MONGO_CLUSTER_ENDPOINT),runtimeEnv.RUNTIME_MONGO_DATABASE_NAME&&(this.#t.functionDatabaseName=runtimeEnv.RUNTIME_MONGO_DATABASE_NAME),runtimeEnv.RUNTIME_OSS_ENDPOINT&&(this.#t.functionStorageEndpoint=runtimeEnv.RUNTIME_OSS_ENDPOINT)):this.#t={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(t){t?.env&&typeof t?.env=="string"&&(this.#t.toEnvId=t.env),t?.envId&&(this.#t.toEnvId=t.envId)}getAlipayContext(){return(0,faas_server_utils_1.getAlipayContext)()}async callFunction(t){return await(0,callFunction_1.callFunction)(this.#t,t)}database(){return this.#e||(this.#e=new Database_1.Database(this.#t)),this.#e}mysql(){return this.#_||(this.#_=new MySQL_1.MySQL(this.#t)),this.#_}get openapi(){return this.#i||(this.#i=(0,Openapi_1.createOpenapi)(this.#t)),this.#i}#N(){return this.#E||(this.#E=new Storage_1.Storage(this.#t)),this.#E}async uploadFile(t){return await this.#N().uploadFile(t)}async downloadFile(t){return await this.#N().downloadFile(t)}async deleteFile(t){return await this.#N().deleteFile(t)}async getTempFileURL(t){return await this.#N().getTempFileURL(t)}}exports.Cloud=Cloud; |
@@ -5,2 +5,3 @@ import type { AddDocumentParam, QueryChainCommand } from '@alipay/faas-db-builder'; | ||
import { CountDocumentResult } from '../types'; | ||
import { Aggregate } from './Aggregate'; | ||
import { Document } from './Document'; | ||
@@ -18,2 +19,3 @@ import { Query } from './Query'; | ||
orderBy(field: string, sort: Sort): Query; | ||
aggregate(): Aggregate; | ||
get<T = any>(): Promise<Array<T>>; | ||
@@ -20,0 +22,0 @@ count(): Promise<CountDocumentResult>; |
@@ -1,1 +0,1 @@ | ||
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.Collection=void 0;const faas_db_builder_1=require("@alipay/faas-db-builder"),faas_server_utils_1=require("@alipay/faas-server-utils"),errors_1=require("../errors"),middlewares_1=require("../requester/middlewares"),Document_1=require("./Document"),Query_1=require("./Query");class Collection{#e;#t;#r;constructor(e,t){this.#t=t,this.#r=new faas_db_builder_1.CollectionBuilder(t),this.#e=e}async add(e){const{options:t}=this.#r.add(e),s="POST",i=this.#s(e.data._id),n=(0,faas_server_utils_1.getAlipayContext)();t._openid=t._openid||n.OPENID;const r=await middlewares_1.HttpRequester.database.request(s,i,t,{},{cloudConfig:this.#e});if(!r.succeed)throw errors_1.errors.SYS_ERR(r.errMsg);return r.data}doc(e){return new Document_1.Document(this.#t,e,this.#e)}limit(e){return new Query_1.Query(this.#t,this.#e).limit(e)}skip(e){return new Query_1.Query(this.#t,this.#e).skip(e)}where(e){return new Query_1.Query(this.#t,this.#e).where(e)}projection(e){return new Query_1.Query(this.#t,this.#e).projection(e)}orderBy(e,t){return new Query_1.Query(this.#t,this.#e).orderBy(e,t)}async get(){return await new Query_1.Query(this.#t,this.#e).get()}async count(){return await new Query_1.Query(this.#t,this.#e).count()}#s(e){return e||(e=""),`${this.#e.functionDatabaseEndpoint}/${this.#e.functionDatabaseName||"faas"}/${this.#t}?_id=${e}`}}exports.Collection=Collection; | ||
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.Collection=void 0;const faas_db_builder_1=require("@alipay/faas-db-builder"),faas_server_utils_1=require("@alipay/faas-server-utils"),errors_1=require("../errors"),middlewares_1=require("../requester/middlewares"),Aggregate_1=require("./Aggregate"),Document_1=require("./Document"),Query_1=require("./Query");class Collection{#e;#t;#r;constructor(e,t){this.#t=t,this.#r=new faas_db_builder_1.CollectionBuilder(t),this.#e=e}async add(e){const{options:t}=this.#r.add(e),s="POST",i=this.#s(e.data._id),n=(0,faas_server_utils_1.getAlipayContext)();t._openid=t._openid||n.OPENID;const r=await middlewares_1.HttpRequester.database.request(s,i,t,{},{cloudConfig:this.#e});if(!r.succeed)throw errors_1.errors.SYS_ERR(r.errMsg);return r.data}doc(e){return new Document_1.Document(this.#t,e,this.#e)}limit(e){return new Query_1.Query(this.#t,this.#e).limit(e)}skip(e){return new Query_1.Query(this.#t,this.#e).skip(e)}where(e){return new Query_1.Query(this.#t,this.#e).where(e)}projection(e){return new Query_1.Query(this.#t,this.#e).projection(e)}orderBy(e,t){return new Query_1.Query(this.#t,this.#e).orderBy(e,t)}aggregate(){return new Aggregate_1.Aggregate(this.#t,this.#e)}async get(){return await new Query_1.Query(this.#t,this.#e).get()}async count(){return await new Query_1.Query(this.#t,this.#e).count()}#s(e){return e||(e=""),`${this.#e.functionDatabaseEndpoint}/${this.#e.functionDatabaseName||"faas"}/${this.#t}?_id=${e}`}}exports.Collection=Collection; |
@@ -6,2 +6,4 @@ import { HttpRequestFailedResult } from './types'; | ||
CALL_STORAGE_ERR = "CALL_STORAGE_ERR", | ||
CALL_OPENAPI_ERR = "CALL_OPENAPI_ERR", | ||
REQUEST_OPENAPI_ERR = "REQUEST_OPENAPI_ERR", | ||
SYS_ERR = "SYS_ERR", | ||
@@ -23,4 +25,6 @@ NOT_FOUND = "NOT_FOUND" | ||
CALL_STORAGE_ERR(result: HttpRequestFailedResult): FunctionError; | ||
CALL_OPENAPI_ERR(result: HttpRequestFailedResult): FunctionError; | ||
REQUEST_OPENAPI_ERR(result: HttpRequestFailedResult): FunctionError; | ||
SYS_ERR(message?: string): 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(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)}}; | ||
"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.CALL_OPENAPI_ERR="CALL_OPENAPI_ERR",e.REQUEST_OPENAPI_ERR="REQUEST_OPENAPI_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(r,t,...R){const _=new FunctionError((0,node_util_1.format)(t,...R));return _.code=r,_}static createByHttpRequestFailedResult(r,t){const R=FunctionError.create(r,`requestId ${t.requestId}, ${t.errMsg}`);return R.requestId=t.requestId,R.errCode=t.errCode,R}}exports.FunctionError=FunctionError,exports.errors={INVALID_PARAM(e,r){return FunctionError.create(ErrorCode.INVALID_PARAM,`Invalid param "${e}", ${r}`)},CALL_FUNCTION_ERR(e){return FunctionError.createByHttpRequestFailedResult(ErrorCode.CALL_FUNCTION_ERR,e)},CALL_STORAGE_ERR(e){return FunctionError.createByHttpRequestFailedResult(ErrorCode.CALL_STORAGE_ERR,e)},CALL_OPENAPI_ERR(e){return FunctionError.createByHttpRequestFailedResult(ErrorCode.CALL_OPENAPI_ERR,e)},REQUEST_OPENAPI_ERR(e){return FunctionError.createByHttpRequestFailedResult(ErrorCode.REQUEST_OPENAPI_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)}}; |
@@ -5,3 +5,4 @@ import { Cloud } from './Cloud'; | ||
export type { CloudInitOptions, initRuntimeEnv } from './Cloud'; | ||
export type { Openapi, OpenapiFunction } from './Openapi'; | ||
export default cloud; | ||
export { Cloud }; |
@@ -18,3 +18,4 @@ /// <reference types="node" /> | ||
static get storage(): HttpRequester; | ||
static get openapi(): 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")),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; | ||
"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")),call_openapi_middleware_1=require("./call_openapi_middleware"),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;static#r;#i;constructor(e){this.#i=(0,koa_compose_1.default)(e)}async request(e,d,s,a,n){const r=n.cloudConfig;(0,node_assert_1.default)(r,"cloud config not set");const l=JSON.stringify(s),o=(0,node_crypto_1.randomUUID)();a["x-request-id"]=o;const c={method:e,contentType:"application/json",content:l,dataType:"json",headers:a},_={url:new URL(d),requestOptions:c},i=new HttpRequestContext_1.HttpRequestContext(_,r);return await this.#i(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}static get openapi(){if(!this.#r){const e=[error_handler_middleware_1.errorHandlerMiddleware,(0,sign_middleware_factory_1.signMiddlewareFactory)(["x-openapi","x-openapi-version"]),call_openapi_middleware_1.callOpenapiMiddleware,call_middleware_1.callMiddleware];this.#r=new HttpRequester(e)}return this.#r}}exports.HttpRequester=HttpRequester; |
@@ -31,2 +31,8 @@ /// <reference types="node" /> | ||
} | ||
export interface CallOpenapiResponse<T = object> { | ||
code: string; | ||
message: string; | ||
requestId: string; | ||
result: T; | ||
} | ||
export interface HttpRequest { | ||
@@ -95,1 +101,4 @@ url: URL; | ||
} | ||
export interface OpenapiConfig { | ||
version?: string; | ||
} |
{ | ||
"name": "@alipay/faas-server-sdk", | ||
"version": "1.0.4", | ||
"version": "1.0.5-alpha.0", | ||
"description": "云函数服务 SDK", | ||
@@ -33,4 +33,4 @@ "main": "lib/index.js", | ||
"dependencies": { | ||
"@alipay/faas-db-builder": "^1.0.4", | ||
"@alipay/faas-server-utils": "^1.0.4", | ||
"@alipay/faas-db-builder": "^1.0.5-alpha.0", | ||
"@alipay/faas-server-utils": "^1.0.5-alpha.0", | ||
"ali-rds": "^5.1.2", | ||
@@ -37,0 +37,0 @@ "koa-compose": "^4.1.0", |
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
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
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
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
62182
54
503
19
1