Socket
Socket
Sign inDemoInstall

@alipay/faas-server-sdk

Package Overview
Dependencies
Maintainers
3
Versions
137
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.7 to 1.1.8-alpha.0

2

lib/callFunction.d.ts
import type { CloudConfig } from '@alipay/faas-server-utils';
export declare function createCallFunction<T = any>(config: CloudConfig): import("@alipay/faas-web-sdk").CallFunction<T>;
export declare function createCallFunction<T = any>(config: CloudConfig): import("@alipay/faas-common-sdk").CallFunction<T>;

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

"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.createCallFunction=void 0;const faas_web_sdk_1=require("@alipay/faas-web-sdk"),requester_1=require("./requester");function createCallFunction(e){const t=requester_1.Httpclient.createFunctionHttpclient(e);return faas_web_sdk_1.WebSDK.createCallFunction({httpclient:t,type:"function"})}exports.createCallFunction=createCallFunction;
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.createCallFunction=void 0;const faas_common_sdk_1=require("@alipay/faas-common-sdk"),requester_1=require("./requester");function createCallFunction(e){const t=requester_1.Httpclient.createFunctionHttpclient(e);return faas_common_sdk_1.WebSDK.createCallFunction({httpclient:t,type:"function"})}exports.createCallFunction=createCallFunction;
import { AlipayContext } from '@alipay/faas-server-utils';
import { CallFunctionResult, DeleteFileParam, DeleteFileResult, DownloadFileParam, GetTempFileURLParam, GetTempFileURLResult } from '@alipay/faas-web-sdk';
import { CallFunctionResult, DeleteFileParam, DeleteFileResult, DownloadFileParam, GetTempFileURLParam, GetTempFileURLResult } from '@alipay/faas-common-sdk';
import { Database } from './Database';

@@ -4,0 +4,0 @@ import { MySQL } from './MySQL';

import type { AddManyDocumentParam, AddOneDocumentParam, QueryChainCommand } from '@alipay/faas-db-builder';
import { Sort } from '@alipay/faas-db-builder';
import { CountDocumentResult, Document, Query } from '@alipay/faas-web-sdk';
import { CountDocumentResult, Document, Query } from '@alipay/faas-common-sdk';
import { Httpclient } from '../requester';

@@ -18,5 +18,5 @@ import { AddManyDocumentsResult, AddOneDocumentResult, DatabaseCloudConfig } from '../types';

orderBy(field: string, sort: Sort): Query;
aggregate(): import("@alipay/faas-web-sdk").Aggregate;
aggregate(): import("@alipay/faas-common-sdk").Aggregate;
get<T = any>(): Promise<Array<T>>;
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"),faas_web_sdk_1=require("@alipay/faas-web-sdk");class Collection{#e;#s;#a;#i;#t;constructor(t,e,s){this.#e=t,this.#s=e,this.#i=s,this.#a=new faas_db_builder_1.CollectionBuilder(e),this.#t=new faas_web_sdk_1.Collection(e,{httpclient:s,type:"function",databaseName:t.functionDatabaseName,throwOnNotFound:t.throwOnNotFound})}async add(t){if(Array.isArray(t.data))return this.#r(t);const e=(0,faas_server_utils_1.getAlipayContext)(),{data:s}=t,i={...s,_openid:s._openid||e.OPENID};return this.#t.add({data:i})}async#r(t){const{options:e}=this.#a.add(t),s="POST",i=`${this.#n()}?batchCreate`,r=(0,faas_server_utils_1.getAlipayContext)();e.$create.forEach(a=>{a._openid=a._openid||r.OPENID});const n=await this.#i.request({method:s,path:i,data:e});return{_ids:faas_web_sdk_1.ResponseUtil.handleResponse(n).insertedIds.map(({_id:a})=>a)}}doc(t){return this.#t.doc(t)}limit(t){return this.#t.limit(t)}skip(t){return this.#t.skip(t)}where(t){return this.#t.where(t)}projection(t){return this.#t.projection(t)}field(t){return this.projection(t)}orderBy(t,e){return this.#t.orderBy(t,e)}aggregate(){return this.#t.aggregate()}async get(){return await this.#t.get()}async count(){return await this.#t.count()}#n(){return`/${this.#e.functionDatabaseName||"faas"}/${this.#s}`}}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"),faas_common_sdk_1=require("@alipay/faas-common-sdk");class Collection{#e;#s;#a;#i;#t;constructor(t,e,s){this.#e=t,this.#s=e,this.#i=s,this.#a=new faas_db_builder_1.CollectionBuilder(e),this.#t=new faas_common_sdk_1.Collection(e,{httpclient:s,type:"function",databaseName:t.functionDatabaseName,throwOnNotFound:t.throwOnNotFound})}async add(t){if(Array.isArray(t.data))return this.#o(t);const e=(0,faas_server_utils_1.getAlipayContext)(),{data:s}=t,i={...s,_openid:s._openid||e.OPENID};return this.#t.add({data:i})}async#o(t){const{options:e}=this.#a.add(t),s="POST",i=`${this.#r()}?batchCreate`,o=(0,faas_server_utils_1.getAlipayContext)();e.$create.forEach(a=>{a._openid=a._openid||o.OPENID});const r=await this.#i.request({method:s,path:i,data:e});return{_ids:faas_common_sdk_1.ResponseUtil.handleResponse(r).insertedIds.map(({_id:a})=>a)}}doc(t){return this.#t.doc(t)}limit(t){return this.#t.limit(t)}skip(t){return this.#t.skip(t)}where(t){return this.#t.where(t)}projection(t){return this.#t.projection(t)}field(t){return this.projection(t)}orderBy(t,e){return this.#t.orderBy(t,e)}aggregate(){return this.#t.aggregate()}async get(){return await this.#t.get()}async count(){return await this.#t.count()}#r(){return`/${this.#e.functionDatabaseName||"faas"}/${this.#s}`}}exports.Collection=Collection;
import { Command } from '@alipay/faas-db-builder';
import type { DeleteDocumentResult } from '@alipay/faas-web-sdk';
import { HttpMethod } from '@alipay/faas-web-sdk';
import type { DeleteDocumentResult } from '@alipay/faas-common-sdk';
import { HttpMethod } from '@alipay/faas-common-sdk';
import { CollectionDescription, DatabaseCloudConfig } from '../types';

@@ -11,3 +11,3 @@ import { Collection } from './Collection';

collection(collectionName: string): Collection;
requestRaw(method: HttpMethod, path: string, data?: object, headers?: Record<string, string | string[]>): Promise<import("urllib").HttpClientResponse<unknown>>;
requestRaw(method: HttpMethod, path: string, data?: object, headers?: Record<string, string>): Promise<import("urllib").HttpClientResponse<unknown>>;
createCollection(collectionName: string): Promise<CollectionDescription>;

@@ -14,0 +14,0 @@ getCollection(collectionName: string): Promise<CollectionDescription>;

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

"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.Database=void 0;const faas_db_builder_1=require("@alipay/faas-db-builder"),faas_web_sdk_1=require("@alipay/faas-web-sdk"),requester_1=require("../requester"),Collection_1=require("./Collection");class Database{#t;command;#a;#e;constructor(t){this.#t=t,this.command=new faas_db_builder_1.Command,this.#a=new faas_db_builder_1.MongoBuilder,this.#e=requester_1.Httpclient.createDatabaseHttpclient(t)}collection(t){return new Collection_1.Collection(this.#t,t,this.#e)}#n(){return`/${this.#t.functionDatabaseName||"faas"}`}#i(t){return`${this.#n()}/${t}`}async requestRaw(t,e,s,i){const{res:a}=await this.#e.requestRaw({method:t,path:e,data:s,headers:i});return a}async createCollection(t){if(this.#t.ignoreCollectionExists){const i=await this.#o(t);if(i)return i}const e="PUT",s=this.#i(t);return await this.#s(e,s)}async getCollection(t){const e="GET",s=this.#i(t);return await this.#s(e,s)}async listCollection(t,e){const s="POST",i=`${this.#n()}?list`,{options:a}=this.#a.listCollection(t,e);return await this.#s(s,i,a)}async deleteCollection(t){const e="DELETE",s=this.#i(t);return await this.#s(e,s)}async#o(t){try{return await this.getCollection(t)}catch(e){if(e.httpStatus===404)return null;throw e}}async#s(t,e,s){const i=await this.#e.request({method:t,path:e,data:s});return faas_web_sdk_1.ResponseUtil.handleResponse(i)}}exports.Database=Database;
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.Database=void 0;const faas_db_builder_1=require("@alipay/faas-db-builder"),faas_common_sdk_1=require("@alipay/faas-common-sdk"),requester_1=require("../requester"),Collection_1=require("./Collection");class Database{#t;command;#i;#e;constructor(t){this.#t=t,this.command=new faas_db_builder_1.Command,this.#i=new faas_db_builder_1.MongoBuilder,this.#e=requester_1.Httpclient.createDatabaseHttpclient(t)}collection(t){return new Collection_1.Collection(this.#t,t,this.#e)}#o(){return`/${this.#t.functionDatabaseName||"faas"}`}#n(t){return`${this.#o()}/${t}`}async requestRaw(t,e,s,n){const{res:i}=await this.#e.requestRaw({method:t,path:e,data:s,headers:n});return i}async createCollection(t){if(this.#t.ignoreCollectionExists){const n=await this.#a(t);if(n)return n}const e="PUT",s=this.#n(t);return await this.#s(e,s)}async getCollection(t){const e="GET",s=this.#n(t);return await this.#s(e,s)}async listCollection(t,e){const s="POST",n=`${this.#o()}?list`,{options:i}=this.#i.listCollection(t,e);return await this.#s(s,n,i)}async deleteCollection(t){const e="DELETE",s=this.#n(t);return await this.#s(e,s)}async#a(t){try{return await this.getCollection(t)}catch(e){if(e.httpStatus===404)return null;throw e}}async#s(t,e,s){const n=await this.#e.request({method:t,path:e,data:s});return faas_common_sdk_1.ResponseUtil.handleResponse(n)}}exports.Database=Database;

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

import { FaasError } from '@alipay/faas-web-sdk';
import { FaasError } from '@alipay/faas-common-sdk';
export declare const errors: {

@@ -3,0 +3,0 @@ INVALID_PARAM(paramName: string, message: string): FaasError;

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

"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.errors=void 0;const faas_web_sdk_1=require("@alipay/faas-web-sdk");exports.errors={INVALID_PARAM(r,s){return faas_web_sdk_1.FaasError.INVALID_PARAM_ERR(r,s)},NETWORK_ERR(r,s){const e=new faas_web_sdk_1.FaasError(-1,r.toString());return e.requestID=s,e},STORAGE_DOWNLOAD_FILE_ERR(r,s){const e=new faas_web_sdk_1.FaasError(-1,`\u6587\u4EF6\u4E0B\u8F7D\u5931\u8D25, ${r}`);return e.requestID=s,e},STORAGE_UPLOAD_FILE_ERR(r,s){const e=new faas_web_sdk_1.FaasError(-1,`\u6587\u4EF6\u4E0A\u4F20\u5931\u8D25, ${r}`);return e.requestID=s,e},INVALID_OPENAPI_RESPONSE_ERR(r,s){const e=new faas_web_sdk_1.FaasError(-1,`\u8FD4\u56DE\u503C ${JSON.stringify(s)} \u683C\u5F0F\u4E0D\u6B63\u786E`);return e.requestID=r,e},NOT_FOUND_ERR(r){return faas_web_sdk_1.FaasError.NOT_FOUND_ERR(r)}};
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.errors=void 0;const faas_common_sdk_1=require("@alipay/faas-common-sdk");exports.errors={INVALID_PARAM(r,s){return faas_common_sdk_1.FaasError.INVALID_PARAM_ERR(r,s)},NETWORK_ERR(r,s){const e=new faas_common_sdk_1.FaasError(-1,r.toString());return e.requestID=s,e},STORAGE_DOWNLOAD_FILE_ERR(r,s){const e=new faas_common_sdk_1.FaasError(-1,`\u6587\u4EF6\u4E0B\u8F7D\u5931\u8D25, ${r}`);return e.requestID=s,e},STORAGE_UPLOAD_FILE_ERR(r,s){const e=new faas_common_sdk_1.FaasError(-1,`\u6587\u4EF6\u4E0A\u4F20\u5931\u8D25, ${r}`);return e.requestID=s,e},INVALID_OPENAPI_RESPONSE_ERR(r,s){const e=new faas_common_sdk_1.FaasError(-1,`\u8FD4\u56DE\u503C ${JSON.stringify(s)} \u683C\u5F0F\u4E0D\u6B63\u786E`);return e.requestID=r,e},NOT_FOUND_ERR(r){return faas_common_sdk_1.FaasError.NOT_FOUND_ERR(r)}};

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

export declare const getAlipayContext: () => import("@alipay/faas-server-utils").AlipayContext;
export declare const callFunction: <T = any>(param: import("./types").CallFunctionParam) => Promise<import("@alipay/faas-web-sdk").CallFunctionResult<T>>;
export declare const callFunction: <T = any>(param: import("./types").CallFunctionParam) => Promise<import("@alipay/faas-common-sdk").CallFunctionResult<T>>;
export declare const database: (config?: import("./types").GetDatabaseOptions | undefined) => import("./Database").Database;

@@ -13,5 +13,5 @@ export declare const mysql: () => import("./MySQL").MySQL;

export declare const uploadFile: (param: import("./types").UploadFileParam) => Promise<import("./types").UploadFileResult>;
export declare const downloadFile: (param: import("@alipay/faas-web-sdk").DownloadFileParam) => Promise<import("./types").DownloadFileResult>;
export declare const deleteFile: (param: import("@alipay/faas-web-sdk").DeleteFileParam) => Promise<import("@alipay/faas-web-sdk").DeleteFileResult>;
export declare const getTempFileURL: (param: import("@alipay/faas-web-sdk").GetTempFileURLParam) => Promise<import("@alipay/faas-web-sdk").GetTempFileURLResult>;
export declare const downloadFile: (param: import("@alipay/faas-common-sdk").DownloadFileParam) => Promise<import("./types").DownloadFileResult>;
export declare const deleteFile: (param: import("@alipay/faas-common-sdk").DeleteFileParam) => Promise<import("@alipay/faas-common-sdk").DeleteFileResult>;
export declare const getTempFileURL: (param: import("@alipay/faas-common-sdk").GetTempFileURLParam) => Promise<import("@alipay/faas-common-sdk").GetTempFileURLResult>;
export { Cloud, initRuntimeEnv } from './Cloud';

@@ -18,0 +18,0 @@ export { DYNAMIC_CURRENT_ENV } from './constant';

import type { CloudConfig } from '@alipay/faas-server-utils';
import { HttpMethod } from '@alipay/faas-web-sdk';
import { HttpMethod } from '@alipay/faas-common-sdk';
export declare class OpenapiCaller {
#private;
constructor(config: CloudConfig, version: string);
requestRaw(method: HttpMethod, path: string, data: object, headers: Record<string, string | string[]>): Promise<import("urllib").HttpClientResponse<unknown>>;
requestRaw(method: HttpMethod, path: string, data: object, headers: Record<string, string>): Promise<import("urllib").HttpClientResponse<unknown>>;
request(name: string, params?: Record<string, unknown>): Promise<any>;
}

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

"use strict";var __importDefault=this&&this.__importDefault||function(r){return r&&r.__esModule?r:{default:r}};Object.defineProperty(exports,"__esModule",{value:!0}),exports.OpenapiCaller=void 0;const faas_web_sdk_1=require("@alipay/faas-web-sdk"),snakecase_keys_1=__importDefault(require("snakecase-keys")),errors_1=require("../errors"),requester_1=require("../requester");class OpenapiCaller{#t;#e;constructor(s,a){this.#t=a,this.#e=requester_1.Httpclient.createOpenapiHttpclient(s)}async requestRaw(s,a,n,i){const{res:e}=await this.#e.requestRaw({method:s,path:a,data:n,headers:i});return e}async request(s,a){const n="POST",i="/functions/invokeOpenapi",e=(0,snakecase_keys_1.default)(Object.assign({},a),{deep:!0});e.biz_content&&typeof e.biz_content!="string"&&(e.biz_content=JSON.stringify(e.biz_content));const c={"x-openapi":s,"x-openapi-version":this.#t},t=await this.#e.request({method:n,path:i,data:e,headers:c});if(t.status!==200){const{code:u,message:_,errCode:l,errMsg:d}=t.data;throw faas_web_sdk_1.FaasError.SERVER_ERR(u||l,_||d,t.requestID,t.status)}const p=`${s.replace(/\./g,"_")}_response`,o=t.data?.[p];if(!o)throw errors_1.errors.INVALID_OPENAPI_RESPONSE_ERR(t.requestID,t.data||"");return o}}exports.OpenapiCaller=OpenapiCaller;
"use strict";var __importDefault=this&&this.__importDefault||function(r){return r&&r.__esModule?r:{default:r}};Object.defineProperty(exports,"__esModule",{value:!0}),exports.OpenapiCaller=void 0;const faas_common_sdk_1=require("@alipay/faas-common-sdk"),snakecase_keys_1=__importDefault(require("snakecase-keys")),errors_1=require("../errors"),requester_1=require("../requester");class OpenapiCaller{#t;#e;constructor(s,n){this.#t=n,this.#e=requester_1.Httpclient.createOpenapiHttpclient(s)}async requestRaw(s,n,a,o){const{res:e}=await this.#e.requestRaw({method:s,path:n,data:a,headers:o});return e}async request(s,n){const a="POST",o="/functions/invokeOpenapi",e=(0,snakecase_keys_1.default)(Object.assign({},n),{deep:!0});e.biz_content&&typeof e.biz_content!="string"&&(e.biz_content=JSON.stringify(e.biz_content));const c={"x-openapi":s,"x-openapi-version":this.#t},t=await this.#e.request({method:a,path:o,data:e,headers:c});if(t.status!==200){const{code:u,message:_,errCode:l,errMsg:d}=t.data;throw faas_common_sdk_1.FaasError.SERVER_ERR(u||l,_||d,t.requestID,t.status)}const p=`${s.replace(/\./g,"_")}_response`,i=t.data?.[p];if(!i)throw errors_1.errors.INVALID_OPENAPI_RESPONSE_ERR(t.requestID,t.data||"");return i}}exports.OpenapiCaller=OpenapiCaller;
import type { HttpClientResponse } from 'urllib';
import type { CloudConfig } from '@alipay/faas-server-utils';
import type { HttpResponse } from '@alipay/faas-web-sdk';
import type { HttpResponse } from '@alipay/faas-common-sdk';
import type { HttpRequest } from '../types';

@@ -5,0 +5,0 @@ export declare class HttpRequestContext<T, R> {

import { Middleware } from 'koa-compose';
import { CloudConfig } from '@alipay/faas-server-utils';
import { HttpRequestOptions, HttpResponse } from '@alipay/faas-web-sdk';
import { HttpRequestOptions, HttpResponse } from '@alipay/faas-common-sdk';
import { HttpRequestContext } from './HttpRequestContext';

@@ -5,0 +5,0 @@ type MiddlewareArray = Array<Middleware<HttpRequestContext<unknown, unknown>>>;

/// <reference types="node" />
/// <reference types="node" />
import { Readable } from 'node:stream';
import { FileUploaderDownloadParam, FileUploaderResult, FileUploaderUploadParam } from '@alipay/faas-web-sdk';
import { FileUploaderDownloadParam, FileUploaderResult, FileUploaderUploadParam } from '@alipay/faas-common-sdk';
import { DownloadFileResult } from '../types';

@@ -6,0 +6,0 @@ export declare class FileUploader {

/// <reference types="node" />
/// <reference types="node" />
import type { CloudConfig } from '@alipay/faas-server-utils';
import { HttpMethod, Storage as StorageSDK } from '@alipay/faas-web-sdk';
import { HttpMethod, Storage as StorageSDK } from '@alipay/faas-common-sdk';
import { Readable } from 'node:stream';

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

constructor(config: CloudConfig);
requestRaw(method: HttpMethod, path: string, data: object, headers: Record<string, string | string[]>): Promise<import("urllib").HttpClientResponse<unknown>>;
requestRaw(method: HttpMethod, path: string, data: object, headers: Record<string, string>): Promise<import("urllib").HttpClientResponse<unknown>>;
}

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

"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.Storage=void 0;const faas_web_sdk_1=require("@alipay/faas-web-sdk"),requester_1=require("../requester"),FileUploader_1=require("./FileUploader");class Storage extends faas_web_sdk_1.Storage{#e;constructor(e){const t=requester_1.Httpclient.createStorageHttpclient(e),r=new FileUploader_1.FileUploader;super({httpclient:t,fileUploader:r,type:"function",toEnvId:e.toEnvId}),this.#e=t}async requestRaw(e,t,r,s){const{res:o}=await this.#e.requestRaw({method:e,path:t,data:r,headers:s});return o}}exports.Storage=Storage;
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.Storage=void 0;const faas_common_sdk_1=require("@alipay/faas-common-sdk"),requester_1=require("../requester"),FileUploader_1=require("./FileUploader");class Storage extends faas_common_sdk_1.Storage{#e;constructor(e){const t=requester_1.Httpclient.createStorageHttpclient(e),r=new FileUploader_1.FileUploader;super({httpclient:t,fileUploader:r,type:"function",toEnvId:e.toEnvId}),this.#e=t}async requestRaw(e,t,r,o){const{res:s}=await this.#e.requestRaw({method:e,path:t,data:r,headers:o});return s}}exports.Storage=Storage;

@@ -6,3 +6,3 @@ /// <reference types="node" />

import type { CloudConfig } from '@alipay/faas-server-utils';
import type { CallFunctionParam as SDKCallFunctionParam, UploadFileParam as SDKUploadFileParam } from '@alipay/faas-web-sdk';
import type { CallFunctionParam as SDKCallFunctionParam, UploadFileParam as SDKUploadFileParam } from '@alipay/faas-common-sdk';
export type CloudInitOptions = {

@@ -9,0 +9,0 @@ env?: string | symbol | {

{
"name": "@alipay/faas-server-sdk",
"version": "1.1.7",
"version": "1.1.8-alpha.0",
"description": "云函数服务 SDK",

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

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

@@ -42,0 +42,0 @@ "koa-compose": "^4.1.0",

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