Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@alipay/faas-server-sdk

Package Overview
Dependencies
Maintainers
3
Versions
141
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@alipay/faas-server-sdk - npm Package Compare versions

Comparing version 1.1.14-alpha.0 to 1.1.14-alpha.1

2

lib/Cloud.d.ts

@@ -19,3 +19,3 @@ import { AlipayContext } from '@alipay/faas-server-utils';

mysql(): MySQL;
redis(options?: RedisOptions): Redis;
redis(options?: RedisOptions | string): Redis;
get openapi(): OpenapiFunction;

@@ -22,0 +22,0 @@ getOpenapiCaller(): OpenapiCaller;

@@ -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"),constant_1=require("./constant"),Database_1=require("./Database"),MySQL_1=require("./MySQL"),Redis_1=require("./Redis"),Openapi_1=require("./Openapi"),Storage_1=require("./Storage"),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||"",RUNTIME_MYSQL_ENDPOINT:process.env.RUNTIME_MYSQL_ENDPOINT||"",RUNTIME_REDIS_ENDPOINT:process.env.RUNTIME_REDIS_ENDPOINT||""};function initRuntimeEnv(i){Object.assign(runtimeEnv,i)}exports.initRuntimeEnv=initRuntimeEnv;class Cloud{#t;#e;#i;#N;#n;#E;constructor(){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,functionMysqlEndpoint:runtimeEnv.RUNTIME_MYSQL_ENDPOINT,functionRedisEndpoint:runtimeEnv.RUNTIME_REDIS_ENDPOINT,timeout:1e4}}refreshConfig(){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),runtimeEnv.RUNTIME_MYSQL_ENDPOINT&&(this.#t.functionMysqlEndpoint=runtimeEnv.RUNTIME_MYSQL_ENDPOINT),runtimeEnv.RUNTIME_REDIS_ENDPOINT&&(this.#t.functionRedisEndpoint=runtimeEnv.RUNTIME_REDIS_ENDPOINT)}init(t){const e=this.#s(t?.env);e&&(this.#t.toEnvId=e),t?.envId&&(this.#t.toEnvId=t.envId),t?.timeout!==void 0&&(this.#t.timeout=(0,utils_1.validateTimeout)(t.timeout))}getAlipayContext(){return(0,faas_server_utils_1.getAlipayContext)()}async callFunction(t){const{config:e,...N}=t||{},n=this.#_(e?.env);return await(0,callFunction_1.createCallFunction)(n)(N)}database(t){const e=this.#_(t?.env);return new Database_1.Database({...e,throwOnNotFound:t?.throwOnNotFound!==!1,ignoreCollectionExists:t?.ignoreCollectionExists===!0,timeout:(0,utils_1.validateTimeout)(t?.timeout??e.timeout)})}mysql(){return this.#i||(this.#i=new MySQL_1.MySQL(this.#t)),this.#i}redis(t){return t&&t.host&&t.password?new Redis_1.Redis({...t,innerConfig:this.#t}):(this.#N||(this.#N=new Redis_1.Redis({innerConfig:this.#t})),this.#N)}get openapi(){return this.#n||(this.#n=(0,Openapi_1.createOpenapi)(this.#t)),this.#n}getOpenapiCaller(){return this.#E||(this.#E=(0,Openapi_1.createOpenapiCaller)({config:this.#t})),this.#E}getStorage(){return this.#e||(this.#e=new Storage_1.Storage(this.#t)),this.#e}async uploadFile(t){return await this.getStorage().uploadFile(t)}async downloadFile(t){return await this.getStorage().downloadFile(t)}async deleteFile(t){return await this.getStorage().deleteFile(t)}async getTempFileURL(t){return await this.getStorage().getTempFileURL(t)}#_(t){const e=this.#s(t);return e?{...this.#t,toEnvId:e}:this.#t}#s(t){return t&&typeof t=="string"?t:t&&t===constant_1.DYNAMIC_CURRENT_ENV?runtimeEnv.RUNTIME_ENV_ID:null}}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"),constant_1=require("./constant"),Database_1=require("./Database"),MySQL_1=require("./MySQL"),Redis_1=require("./Redis"),Openapi_1=require("./Openapi"),Storage_1=require("./Storage"),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||"",RUNTIME_MYSQL_ENDPOINT:process.env.RUNTIME_MYSQL_ENDPOINT||"",RUNTIME_REDIS_ENDPOINT:process.env.RUNTIME_REDIS_ENDPOINT||""};function initRuntimeEnv(i){Object.assign(runtimeEnv,i)}exports.initRuntimeEnv=initRuntimeEnv;class Cloud{#t;#e;#i;#n;#N;#E;constructor(){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,functionMysqlEndpoint:runtimeEnv.RUNTIME_MYSQL_ENDPOINT,functionRedisEndpoint:runtimeEnv.RUNTIME_REDIS_ENDPOINT,timeout:1e4}}refreshConfig(){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),runtimeEnv.RUNTIME_MYSQL_ENDPOINT&&(this.#t.functionMysqlEndpoint=runtimeEnv.RUNTIME_MYSQL_ENDPOINT),runtimeEnv.RUNTIME_REDIS_ENDPOINT&&(this.#t.functionRedisEndpoint=runtimeEnv.RUNTIME_REDIS_ENDPOINT)}init(t){const e=this.#s(t?.env);e&&(this.#t.toEnvId=e),t?.envId&&(this.#t.toEnvId=t.envId),t?.timeout!==void 0&&(this.#t.timeout=(0,utils_1.validateTimeout)(t.timeout))}getAlipayContext(){return(0,faas_server_utils_1.getAlipayContext)()}async callFunction(t){const{config:e,...n}=t||{},N=this.#_(e?.env);return await(0,callFunction_1.createCallFunction)(N)(n)}database(t){const e=this.#_(t?.env);return new Database_1.Database({...e,throwOnNotFound:t?.throwOnNotFound!==!1,ignoreCollectionExists:t?.ignoreCollectionExists===!0,timeout:(0,utils_1.validateTimeout)(t?.timeout??e.timeout)})}mysql(){return this.#i||(this.#i=new MySQL_1.MySQL(this.#t)),this.#i}redis(t){return typeof t=="string"?new Redis_1.Redis({url:t,innerConfig:this.#t}):t&&t.host?new Redis_1.Redis({...t,innerConfig:this.#t}):(this.#n||(this.#n=new Redis_1.Redis({innerConfig:this.#t})),this.#n)}get openapi(){return this.#N||(this.#N=(0,Openapi_1.createOpenapi)(this.#t)),this.#N}getOpenapiCaller(){return this.#E||(this.#E=(0,Openapi_1.createOpenapiCaller)({config:this.#t})),this.#E}getStorage(){return this.#e||(this.#e=new Storage_1.Storage(this.#t)),this.#e}async uploadFile(t){return await this.getStorage().uploadFile(t)}async downloadFile(t){return await this.getStorage().downloadFile(t)}async deleteFile(t){return await this.getStorage().deleteFile(t)}async getTempFileURL(t){return await this.getStorage().getTempFileURL(t)}#_(t){const e=this.#s(t);return e?{...this.#t,toEnvId:e}:this.#t}#s(t){return t&&typeof t=="string"?t:t&&t===constant_1.DYNAMIC_CURRENT_ENV?runtimeEnv.RUNTIME_ENV_ID:null}}exports.Cloud=Cloud;

@@ -10,3 +10,3 @@ import { Cloud } from './Cloud';

export declare const mysql: () => import("./MySQL").MySQL;
export declare const redis: (options?: import("./Redis").RedisOptions | undefined) => import("./Redis").Redis;
export declare const redis: (options?: string | import("./Redis").RedisOptions | undefined) => import("./Redis").Redis;
export declare const openapi: import("./Openapi").OpenapiFunction;

@@ -13,0 +13,0 @@ export declare const uploadFile: (param: import("./types").UploadFileParam) => Promise<import("./types").UploadFileResult>;

@@ -5,2 +5,3 @@ import { CloudConfig } from '@alipay/faas-server-utils';

innerConfig?: CloudConfig;
url?: string;
};

@@ -7,0 +8,0 @@ export declare class Redis extends IORedis {

@@ -1,1 +0,1 @@

"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.Redis=void 0;const faas_common_sdk_1=require("@alipay/faas-common-sdk"),ioredis_1=require("ioredis"),utils_1=require("../utils");class Redis extends ioredis_1.Redis{#e;#s;constructor(e){if(!e.innerConfig?.functionRedisEndpoint)throw new faas_common_sdk_1.FaasError(40006,"Redis \u670D\u52A1\u672A\u5F00\u901A");const s=e.host,r=e.port??6379,t=e.password,[i,n]=e.innerConfig.functionRedisEndpoint.split(":");if(e.host=i,e.port=parseInt(n),e.password="need-auth-string",super(e),this.#e=e.innerConfig,s){const o=e.username??"";this.#s=`!cloudbase:__direct-conn__:${o}:${t}@${s}:${r}`}}auth(...e){return this.#s?e[0]=this.#s:this.#e&&(e[0]=(0,utils_1.authString)(this.#e)),super.auth.apply(this,e)}}exports.Redis=Redis;
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.Redis=void 0;const faas_common_sdk_1=require("@alipay/faas-common-sdk"),ioredis_1=require("ioredis"),utils_1=require("../utils");class Redis extends ioredis_1.Redis{#s;#e;constructor(e){if(!e.innerConfig?.functionRedisEndpoint)throw new faas_common_sdk_1.FaasError(40006,"Redis \u670D\u52A1\u672A\u5F00\u901A");const r=e.host,t=e.port??6379,i=e.password,[n,o]=e.innerConfig.functionRedisEndpoint.split(":");if(e.host=n,e.port=parseInt(o),e.password="need-auth-string",super(e),this.#s=e.innerConfig,e.url)this.#e=`!cloudbase:__direct-conn__:${e.url.replace("redis://","")}`;else if(r){const a=e.username??"";this.#e=`!cloudbase:__direct-conn__:${a}:${i}@${r}:${t}`}}auth(...e){return this.#e?e[0]=this.#e:this.#s&&(e[0]=(0,utils_1.authString)(this.#s)),super.auth.apply(this,e)}}exports.Redis=Redis;function forbidden(s){return()=>{throw new Error(`'${s}' is not support, see https://opendocs.alipay.com/cloud/089gv6?pathHash=4325d091`)}}["cluster","readonly","readwrite","select","keys","migrate","move","scan","wait","psubscribe","pubsub","publish","punsubscribe","subscribe","unsubscribe","bgrewriteaof","bgsave","debug","lastsave","monitor","module","psync","role","save","shutdown","slaveof","slowlog","swapdb","sync","discard","exec","multi","unwatch","watch"].forEach(s=>{Redis.prototype[s]=forbidden(s)});

@@ -62,1 +62,7 @@ /// <reference types="node" />

}
export interface CallContext {
appId: string;
traceId: string;
requestId: string;
rpcId: string;
}
{
"name": "@alipay/faas-server-sdk",
"version": "1.1.14-alpha.0",
"version": "1.1.14-alpha.1",
"description": "云函数服务 SDK",

@@ -37,5 +37,5 @@ "main": "lib/index.js",

"dependencies": {
"@alipay/faas-db-builder": "^1.1.14-alpha.0",
"@alipay/faas-server-utils": "^1.1.14-alpha.0",
"@alipay/faas-web-sdk": "^1.1.14-alpha.0",
"@alipay/faas-db-builder": "^1.1.14-alpha.1",
"@alipay/faas-server-utils": "^1.1.14-alpha.1",
"@alipay/faas-web-sdk": "^1.1.14-alpha.1",
"ali-rds": "^6.2.0",

@@ -42,0 +42,0 @@ "ioredis": "^5.3.2",

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc