Compare commits

...

34 Commits

Author SHA1 Message Date
wss-git fb64cc31c9 build: 0.0.23 2022-01-04 13:52:48 +08:00
heimanba 16fef7da63
Merge pull request #21 from devsapp/fix#480
fix: fc 480
2022-01-04 11:29:07 +08:00
wss-git 53524ca5a0 build: 0.0.22 2021-12-31 09:59:32 +08:00
千风 545b575b2e fix: fix async invoke withour stateul invoke id error 2021-12-31 09:57:48 +08:00
wss-git 853611b69f fix: invoke function add timeout 2021-12-27 18:09:00 +08:00
heimanba 25e6625cb2
Merge pull request #20 from devsapp/wss/dev
Wss/dev
2021-12-23 14:28:12 +08:00
wss-git 645a184c06 version: 0.0.21 2021-12-23 14:24:49 +08:00
wss-git 7486b7ee59 build: dev 2021-12-23 14:11:01 +08:00
wss-git e930d19e57 Merge branch 'master' of https://github.com/devsapp/fc-remote-invoke into wss/dev 2021-12-23 14:10:20 +08:00
wss-git 0bc9d61b5f
Merge pull request #19 from devsapp/fix#fc-460
fix: invoke function carry X-Fc-Invocation-Code-Version:Latest
2021-12-23 14:09:43 +08:00
wss-git 0b9712838c build: ncc transfrom esbuild 2021-12-23 14:07:27 +08:00
wss-git 24e0676581 fix: invoke function carry X-Fc-Invocation-Code-Version:Latest 2021-12-20 14:52:19 +08:00
wss-git f0468eddf3
Merge pull request #18 from devsapp/support/event-stdin
support/event-stdin
2021-12-13 15:19:03 +08:00
wss-git 93d6d628c2 support/event-stdin 2021-12-13 15:14:44 +08:00
wss-git 978e57fef7
Merge pull request #16 from devsapp/support-stateful-async-invocation-id
feat: add --stateful-async-invocation-id args
2021-11-16 13:29:42 +08:00
wss-git bf6593e33c build 0.0.20 2021-11-16 11:33:38 +08:00
wss-git 2c0a0b628d
Merge pull request #17 from devsapp/fix#fc-419
fix: show resp code
2021-11-16 11:25:30 +08:00
wss-git c1a2067fb0 style: ignore src dir 2021-11-15 11:23:50 +08:00
wss-git f8c5754072 fix: show resp code 2021-11-15 11:01:30 +08:00
千风 9c10415e0f feat: add --stateful-async-invocation-id args 2021-10-19 21:14:49 +08:00
千风 9c111e5b06 version 0.0.19 2021-10-19 16:00:26 +08:00
wss-git f7670a02aa fix: get client error 2021-10-19 15:56:19 +08:00
wss-git 724001f038
Merge pull request #13 from devsapp/dev
build: 0.0.18
2021-10-18 16:48:23 +08:00
wss-git 3f41b8c50a build: 0.0.18 2021-10-18 16:47:31 +08:00
wss-git ec36588ae7
Merge pull request #12 from devsapp/fc-325
Fc 325
2021-10-17 14:10:44 +08:00
wss-git 9121a9107e fix: handler http header to body 2021-10-17 14:10:24 +08:00
wss-git 2c3bcc6164 build: run build 2021-10-08 16:08:18 +08:00
wss-git 921e32f5db fix: http error log not fount 2021-08-23 17:59:37 +08:00
千风 9875ef92ab feat: version 0.0.17 2021-08-12 17:33:13 +08:00
千风 f3a244a6e1 build: update build process
move build to github action;add .signore;add -e option to ncc to make @serverless-devs/core out of
ncc compile
2021-08-12 17:33:13 +08:00
千风 c3127e9425 feat: upgrade version from 0.0.15 to 0.0.16 2021-08-09 17:24:59 +08:00
千风 6ea73bf213 build: adapt to ncc build and remove unnecessary files 2021-08-09 17:08:43 +08:00
wss-git dfb710158c refactor: v0.0.15 2021-08-06 13:45:35 +08:00
wss-git 3684d13b0b
Merge pull request #7 from devsapp/wss/fix-fc-159
fix: fc 159, command parse to inputs
2021-08-06 13:43:47 +08:00
52 changed files with 231 additions and 4793 deletions

View File

@ -21,9 +21,9 @@ jobs:
python -m pip install --upgrade pip
pip install setuptools wheel twine
pip install requests
- name: NPM install
- name: Build
run: |
npm install --production
npm run build
- name: Add publish file
run: |
wget https://serverless-registry.oss-cn-hangzhou.aliyuncs.com/publish-file/python3/hub-publish.py

4
.gitignore vendored
View File

@ -2,4 +2,6 @@ node_modules
.s
.DS_Store
package-lock.json
package-lock.json
.idea
.vscode

View File

@ -1,7 +1,17 @@
node_modules
.s
tsconfig.json
LICENSE
package-lok.json
package-lock.json
.prettierrc.js
.gitignore
.gitignore
.github
.idea
.vscode
.DS_Store
.git
README.md
./example
./.signore
./src

26
Makefile Normal file
View File

@ -0,0 +1,26 @@
.PHONY: push
CURRENT_BRANCH_NAME := $(shell git symbolic-ref --short HEAD)
add:
git add .
commit: add
git-cz
rebase-main: commit
git pull --rebase origin master
push:
git push --force-with-lease origin $(CURRENT_BRANCH_NAME)
release-dev: push
-gh release delete dev -y
-git tag -d dev
-git push origin :refs/tags/dev
gh release create dev --notes "dev release" --target dev --title "Release dev"
roll-back-dev:
git reset --soft HEAD~1
git restore --staged publish.yaml
git restore publish.yaml

View File

@ -23,9 +23,9 @@ services:
````
$ s exec -- invoke --invocation-type sync --event ${payload}
$ s exec -- invoke --invocation-type async --event-file ${path}
$ s exec -- invoke --event-stdin
$ s invoke --invocation-type sync --event ${payload}
$ s invoke --invocation-type async --event-file ${path}
$ s invoke --event-stdin
````
## CLI 用法

51
dist/index.js vendored Normal file

File diff suppressed because one or more lines are too long

File diff suppressed because it is too large Load Diff

Binary file not shown.

Before

Width:  |  Height:  |  Size: 9.4 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 28 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 480 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 855 B

File diff suppressed because one or more lines are too long

View File

@ -1 +0,0 @@
window.searchData = {"kinds":{"128":"Class","512":"Constructor","2048":"Method"},"rows":[{"id":0,"kind":128,"name":"default","url":"classes/default.html","classes":"tsd-kind-class"},{"id":1,"kind":512,"name":"constructor","url":"classes/default.html#constructor","classes":"tsd-kind-constructor tsd-parent-kind-class","parent":"default"},{"id":2,"kind":2048,"name":"invoke","url":"classes/default.html#invoke","classes":"tsd-kind-method tsd-parent-kind-class","parent":"default"},{"id":3,"kind":2048,"name":"report","url":"classes/default.html#report","classes":"tsd-kind-method tsd-parent-kind-class tsd-is-private","parent":"default"},{"id":4,"kind":2048,"name":"handlerInputs","url":"classes/default.html#handlerinputs","classes":"tsd-kind-method tsd-parent-kind-class tsd-is-private","parent":"default"}],"index":{"version":"2.3.9","fields":["name","parent"],"fieldVectors":[["name/0",[0,0.87]],["parent/0",[]],["name/1",[1,13.863]],["parent/1",[0,0.079]],["name/2",[2,13.863]],["parent/2",[0,0.079]],["name/3",[3,13.863]],["parent/3",[0,0.079]],["name/4",[4,13.863]],["parent/4",[0,0.079]]],"invertedIndex":[["constructor",{"_index":1,"name":{"1":{}},"parent":{}}],["default",{"_index":0,"name":{"0":{}},"parent":{"1":{},"2":{},"3":{},"4":{}}}],["handlerinputs",{"_index":4,"name":{"4":{}},"parent":{}}],["invoke",{"_index":2,"name":{"2":{}},"parent":{}}],["report",{"_index":3,"name":{"3":{}},"parent":{}}]],"pipeline":[]}}

View File

@ -1,254 +0,0 @@
<!doctype html>
<html class="default no-js">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<title>default | fc-remote-invoke</title>
<meta name="description" content="Documentation for fc-remote-invoke">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="../assets/css/main.css">
<script async src="../assets/js/search.js" id="search-script"></script>
</head>
<body>
<header>
<div class="tsd-page-toolbar">
<div class="container">
<div class="table-wrap">
<div class="table-cell" id="tsd-search" data-index="../assets/js/search.json" data-base="..">
<div class="field">
<label for="tsd-search-field" class="tsd-widget search no-caption">Search</label>
<input id="tsd-search-field" type="text" />
</div>
<ul class="results">
<li class="state loading">Preparing search index...</li>
<li class="state failure">The search index is not available</li>
</ul>
<a href="../index.html" class="title">fc-remote-invoke</a>
</div>
<div class="table-cell" id="tsd-widgets">
<div id="tsd-filter">
<a href="#" class="tsd-widget options no-caption" data-toggle="options">Options</a>
<div class="tsd-filter-group">
<div class="tsd-select" id="tsd-filter-visibility">
<span class="tsd-select-label">All</span>
<ul class="tsd-select-list">
<li data-value="public">Public</li>
<li data-value="protected">Public/Protected</li>
<li data-value="private" class="selected">All</li>
</ul>
</div>
<input type="checkbox" id="tsd-filter-inherited" checked />
<label class="tsd-widget" for="tsd-filter-inherited">Inherited</label>
<input type="checkbox" id="tsd-filter-externals" checked />
<label class="tsd-widget" for="tsd-filter-externals">Externals</label>
</div>
</div>
<a href="#" class="tsd-widget menu no-caption" data-toggle="menu">Menu</a>
</div>
</div>
</div>
</div>
<div class="tsd-page-title">
<div class="container">
<ul class="tsd-breadcrumb">
<li>
<a href="../modules.html">fc-remote-invoke</a>
</li>
<li>
<a href="default.html">default</a>
</li>
</ul>
<h1>Class default</h1>
</div>
</div>
</header>
<div class="container container-main">
<div class="row">
<div class="col-8 col-content">
<section class="tsd-panel tsd-hierarchy">
<h3>Hierarchy</h3>
<ul class="tsd-hierarchy">
<li>
<span class="target">default</span>
</li>
</ul>
</section>
<section class="tsd-panel-group tsd-index-group">
<h2>Index</h2>
<section class="tsd-panel tsd-index-panel">
<div class="tsd-index-content">
<section class="tsd-index-section ">
<h3>Constructors</h3>
<ul class="tsd-index-list">
<li class="tsd-kind-constructor tsd-parent-kind-class"><a href="default.html#constructor" class="tsd-kind-icon">constructor</a></li>
</ul>
</section>
<section class="tsd-index-section ">
<h3>Methods</h3>
<ul class="tsd-index-list">
<li class="tsd-kind-method tsd-parent-kind-class tsd-is-private"><a href="default.html#handlerinputs" class="tsd-kind-icon">handler<wbr>Inputs</a></li>
<li class="tsd-kind-method tsd-parent-kind-class"><a href="default.html#invoke" class="tsd-kind-icon">invoke</a></li>
<li class="tsd-kind-method tsd-parent-kind-class tsd-is-private"><a href="default.html#report" class="tsd-kind-icon">report</a></li>
</ul>
</section>
</div>
</section>
</section>
<section class="tsd-panel-group tsd-member-group ">
<h2>Constructors</h2>
<section class="tsd-panel tsd-member tsd-kind-constructor tsd-parent-kind-class">
<a name="constructor" class="tsd-anchor"></a>
<h3>constructor</h3>
<ul class="tsd-signatures tsd-kind-constructor tsd-parent-kind-class">
<li class="tsd-signature tsd-kind-icon">new default<span class="tsd-signature-symbol">(</span><span class="tsd-signature-symbol">)</span><span class="tsd-signature-symbol">: </span><a href="default.html" class="tsd-signature-type" data-tsd-kind="Class">default</a></li>
</ul>
<ul class="tsd-descriptions">
<li class="tsd-description">
<aside class="tsd-sources">
</aside>
<h4 class="tsd-returns-title">Returns <a href="default.html" class="tsd-signature-type" data-tsd-kind="Class">default</a></h4>
</li>
</ul>
</section>
</section>
<section class="tsd-panel-group tsd-member-group ">
<h2>Methods</h2>
<section class="tsd-panel tsd-member tsd-kind-method tsd-parent-kind-class tsd-is-private">
<a name="handlerinputs" class="tsd-anchor"></a>
<h3><span class="tsd-flag ts-flagPrivate">Private</span> handler<wbr>Inputs</h3>
<ul class="tsd-signatures tsd-kind-method tsd-parent-kind-class tsd-is-private">
<li class="tsd-signature tsd-kind-icon">handler<wbr>Inputs<span class="tsd-signature-symbol">(</span>inputs<span class="tsd-signature-symbol">: </span><span class="tsd-signature-type">InputProps</span><span class="tsd-signature-symbol">)</span><span class="tsd-signature-symbol">: </span><span class="tsd-signature-type">Promise</span><span class="tsd-signature-symbol">&lt;</span><span class="tsd-signature-type">any</span><span class="tsd-signature-symbol">&gt;</span></li>
</ul>
<ul class="tsd-descriptions">
<li class="tsd-description">
<aside class="tsd-sources">
<ul>
<li>Defined in <a href="https://github.com/devsapp/fc-remote-invoke/blob/ea689b8/src/index.ts#L46">index.ts:46</a></li>
</ul>
</aside>
<h4 class="tsd-parameters-title">Parameters</h4>
<ul class="tsd-parameters">
<li>
<h5>inputs: <span class="tsd-signature-type">InputProps</span></h5>
</li>
</ul>
<h4 class="tsd-returns-title">Returns <span class="tsd-signature-type">Promise</span><span class="tsd-signature-symbol">&lt;</span><span class="tsd-signature-type">any</span><span class="tsd-signature-symbol">&gt;</span></h4>
</li>
</ul>
</section>
<section class="tsd-panel tsd-member tsd-kind-method tsd-parent-kind-class">
<a name="invoke" class="tsd-anchor"></a>
<h3>invoke</h3>
<ul class="tsd-signatures tsd-kind-method tsd-parent-kind-class">
<li class="tsd-signature tsd-kind-icon">invoke<span class="tsd-signature-symbol">(</span>inputs<span class="tsd-signature-symbol">: </span><span class="tsd-signature-type">InputProps</span><span class="tsd-signature-symbol">)</span><span class="tsd-signature-symbol">: </span><span class="tsd-signature-type">Promise</span><span class="tsd-signature-symbol">&lt;</span><span class="tsd-signature-type">any</span><span class="tsd-signature-symbol">&gt;</span></li>
</ul>
<ul class="tsd-descriptions">
<li class="tsd-description">
<aside class="tsd-sources">
<ul>
<li>Defined in <a href="https://github.com/devsapp/fc-remote-invoke/blob/ea689b8/src/index.ts#L16">index.ts:16</a></li>
</ul>
</aside>
<div class="tsd-comment tsd-typography">
<div class="lead">
<p>event 函数本地调试</p>
</div>
</div>
<h4 class="tsd-parameters-title">Parameters</h4>
<ul class="tsd-parameters">
<li>
<h5>inputs: <span class="tsd-signature-type">InputProps</span></h5>
</li>
</ul>
<h4 class="tsd-returns-title">Returns <span class="tsd-signature-type">Promise</span><span class="tsd-signature-symbol">&lt;</span><span class="tsd-signature-type">any</span><span class="tsd-signature-symbol">&gt;</span></h4>
</li>
</ul>
</section>
<section class="tsd-panel tsd-member tsd-kind-method tsd-parent-kind-class tsd-is-private">
<a name="report" class="tsd-anchor"></a>
<h3><span class="tsd-flag ts-flagPrivate">Private</span> report</h3>
<ul class="tsd-signatures tsd-kind-method tsd-parent-kind-class tsd-is-private">
<li class="tsd-signature tsd-kind-icon">report<span class="tsd-signature-symbol">(</span>componentName<span class="tsd-signature-symbol">: </span><span class="tsd-signature-type">string</span>, command<span class="tsd-signature-symbol">: </span><span class="tsd-signature-type">string</span>, accountID<span class="tsd-signature-symbol">: </span><span class="tsd-signature-type">string</span><span class="tsd-signature-symbol">)</span><span class="tsd-signature-symbol">: </span><span class="tsd-signature-type">Promise</span><span class="tsd-signature-symbol">&lt;</span><span class="tsd-signature-type">void</span><span class="tsd-signature-symbol">&gt;</span></li>
</ul>
<ul class="tsd-descriptions">
<li class="tsd-description">
<aside class="tsd-sources">
<ul>
<li>Defined in <a href="https://github.com/devsapp/fc-remote-invoke/blob/ea689b8/src/index.ts#L39">index.ts:39</a></li>
</ul>
</aside>
<h4 class="tsd-parameters-title">Parameters</h4>
<ul class="tsd-parameters">
<li>
<h5>componentName: <span class="tsd-signature-type">string</span></h5>
</li>
<li>
<h5>command: <span class="tsd-signature-type">string</span></h5>
</li>
<li>
<h5>accountID: <span class="tsd-signature-type">string</span></h5>
</li>
</ul>
<h4 class="tsd-returns-title">Returns <span class="tsd-signature-type">Promise</span><span class="tsd-signature-symbol">&lt;</span><span class="tsd-signature-type">void</span><span class="tsd-signature-symbol">&gt;</span></h4>
</li>
</ul>
</section>
</section>
</div>
<div class="col-4 col-menu menu-sticky-wrap menu-highlight">
<nav class="tsd-navigation primary">
<ul>
<li class=" ">
<a href="../modules.html">Exports</a>
</li>
</ul>
</nav>
<nav class="tsd-navigation secondary menu-sticky">
<ul class="before-current">
</ul>
<ul class="current">
<li class="current tsd-kind-class">
<a href="default.html" class="tsd-kind-icon">default</a>
<ul>
<li class=" tsd-kind-constructor tsd-parent-kind-class">
<a href="default.html#constructor" class="tsd-kind-icon">constructor</a>
</li>
<li class=" tsd-kind-method tsd-parent-kind-class tsd-is-private">
<a href="default.html#handlerinputs" class="tsd-kind-icon">handler<wbr>Inputs</a>
</li>
<li class=" tsd-kind-method tsd-parent-kind-class">
<a href="default.html#invoke" class="tsd-kind-icon">invoke</a>
</li>
<li class=" tsd-kind-method tsd-parent-kind-class tsd-is-private">
<a href="default.html#report" class="tsd-kind-icon">report</a>
</li>
</ul>
</li>
</ul>
<ul class="after-current">
</ul>
</nav>
</div>
</div>
</div>
<footer class="with-border-bottom">
<div class="container">
<h2>Legend</h2>
<div class="tsd-legend-group">
<ul class="tsd-legend">
<li class="tsd-kind-constructor tsd-parent-kind-class"><span class="tsd-kind-icon">Constructor</span></li>
<li class="tsd-kind-method tsd-parent-kind-class"><span class="tsd-kind-icon">Method</span></li>
</ul>
<ul class="tsd-legend">
<li class="tsd-kind-method tsd-parent-kind-class tsd-is-private"><span class="tsd-kind-icon">Private method</span></li>
</ul>
</div>
</div>
</footer>
<div class="container tsd-generator">
<p>Generated using <a href="https://typedoc.org/" target="_blank">TypeDoc</a></p>
</div>
<div class="overlay"></div>
<script src="../assets/js/main.js"></script>
</body>
</html>

View File

@ -1,250 +0,0 @@
{
"id": 0,
"name": "fc-remote-invoke",
"kind": 0,
"kindString": "Project",
"flags": {},
"originalName": "",
"children": [
{
"id": 1,
"name": "default",
"kind": 128,
"kindString": "Class",
"flags": {},
"children": [
{
"id": 2,
"name": "constructor",
"kind": 512,
"kindString": "Constructor",
"flags": {},
"signatures": [
{
"id": 3,
"name": "new default",
"kind": 16384,
"kindString": "Constructor signature",
"flags": {},
"type": {
"type": "reference",
"id": 1,
"name": "default"
}
}
]
},
{
"id": 12,
"name": "handlerInputs",
"kind": 2048,
"kindString": "Method",
"flags": {
"isPrivate": true
},
"sources": [
{
"fileName": "index.ts",
"line": 46,
"character": 29
}
],
"signatures": [
{
"id": 13,
"name": "handlerInputs",
"kind": 4096,
"kindString": "Call signature",
"flags": {},
"parameters": [
{
"id": 14,
"name": "inputs",
"kind": 32768,
"kindString": "Parameter",
"flags": {},
"type": {
"type": "reference",
"name": "InputProps"
}
}
],
"type": {
"type": "reference",
"typeArguments": [
{
"type": "intrinsic",
"name": "any"
}
],
"name": "Promise"
}
}
]
},
{
"id": 4,
"name": "invoke",
"kind": 2048,
"kindString": "Method",
"flags": {},
"sources": [
{
"fileName": "index.ts",
"line": 16,
"character": 14
}
],
"signatures": [
{
"id": 5,
"name": "invoke",
"kind": 4096,
"kindString": "Call signature",
"flags": {},
"comment": {
"shortText": "event 函数本地调试",
"returns": "\n"
},
"parameters": [
{
"id": 6,
"name": "inputs",
"kind": 32768,
"kindString": "Parameter",
"flags": {},
"comment": {},
"type": {
"type": "reference",
"name": "InputProps"
}
}
],
"type": {
"type": "reference",
"typeArguments": [
{
"type": "intrinsic",
"name": "any"
}
],
"name": "Promise"
}
}
]
},
{
"id": 7,
"name": "report",
"kind": 2048,
"kindString": "Method",
"flags": {
"isPrivate": true
},
"sources": [
{
"fileName": "index.ts",
"line": 39,
"character": 22
}
],
"signatures": [
{
"id": 8,
"name": "report",
"kind": 4096,
"kindString": "Call signature",
"flags": {},
"parameters": [
{
"id": 9,
"name": "componentName",
"kind": 32768,
"kindString": "Parameter",
"flags": {},
"type": {
"type": "intrinsic",
"name": "string"
}
},
{
"id": 10,
"name": "command",
"kind": 32768,
"kindString": "Parameter",
"flags": {},
"type": {
"type": "intrinsic",
"name": "string"
}
},
{
"id": 11,
"name": "accountID",
"kind": 32768,
"kindString": "Parameter",
"flags": {},
"type": {
"type": "intrinsic",
"name": "string"
}
}
],
"type": {
"type": "reference",
"typeArguments": [
{
"type": "intrinsic",
"name": "void"
}
],
"name": "Promise"
}
}
]
}
],
"groups": [
{
"title": "Constructors",
"kind": 512,
"children": [
2
]
},
{
"title": "Methods",
"kind": 2048,
"children": [
12,
4,
7
]
}
],
"sources": [
{
"fileName": "index.ts",
"line": 10,
"character": 35
}
]
}
],
"groups": [
{
"title": "Classes",
"kind": 128,
"children": [
1
]
}
],
"sources": [
{
"fileName": "index.ts",
"line": 1,
"character": 0
}
]
}

View File

@ -1,154 +0,0 @@
<!doctype html>
<html class="default no-js">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<title>fc-remote-invoke</title>
<meta name="description" content="Documentation for fc-remote-invoke">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="assets/css/main.css">
<script async src="assets/js/search.js" id="search-script"></script>
</head>
<body>
<header>
<div class="tsd-page-toolbar">
<div class="container">
<div class="table-wrap">
<div class="table-cell" id="tsd-search" data-index="assets/js/search.json" data-base=".">
<div class="field">
<label for="tsd-search-field" class="tsd-widget search no-caption">Search</label>
<input id="tsd-search-field" type="text" />
</div>
<ul class="results">
<li class="state loading">Preparing search index...</li>
<li class="state failure">The search index is not available</li>
</ul>
<a href="index.html" class="title">fc-remote-invoke</a>
</div>
<div class="table-cell" id="tsd-widgets">
<div id="tsd-filter">
<a href="#" class="tsd-widget options no-caption" data-toggle="options">Options</a>
<div class="tsd-filter-group">
<div class="tsd-select" id="tsd-filter-visibility">
<span class="tsd-select-label">All</span>
<ul class="tsd-select-list">
<li data-value="public">Public</li>
<li data-value="protected">Public/Protected</li>
<li data-value="private" class="selected">All</li>
</ul>
</div>
<input type="checkbox" id="tsd-filter-inherited" checked />
<label class="tsd-widget" for="tsd-filter-inherited">Inherited</label>
<input type="checkbox" id="tsd-filter-externals" checked />
<label class="tsd-widget" for="tsd-filter-externals">Externals</label>
</div>
</div>
<a href="#" class="tsd-widget menu no-caption" data-toggle="menu">Menu</a>
</div>
</div>
</div>
</div>
<div class="tsd-page-title">
<div class="container">
<h1>fc-remote-invoke</h1>
</div>
</div>
</header>
<div class="container container-main">
<div class="row">
<div class="col-8 col-content">
<div class="tsd-panel tsd-typography">
<a href="#组件说明" id="组件说明" style="color: inherit; text-decoration: none;">
<h2>组件说明</h2>
</a>
<p>fc-remote-invoke 组件调用 FC 函数。</p>
<a href="#带有-yaml-文件用法" id="带有-yaml-文件用法" style="color: inherit; text-decoration: none;">
<h2>带有 YAML 文件用法</h2>
</a>
<a href="#yaml-配置" id="yaml-配置" style="color: inherit; text-decoration: none;">
<h3>yaml 配置</h3>
</a>
<pre><code><span style="color: #000000">edition: </span><span style="color: #098658">1.0</span><span style="color: #000000">.</span><span style="color: #098658">0</span><span style="color: #000000"> # </span><span style="color: #001080">命令行YAML规范版本</span><span style="color: #000000"></span><span style="color: #001080">遵循语义化版本</span><span style="color: #000000"></span><span style="color: #001080">Semantic</span><span style="color: #000000"> </span><span style="color: #001080">Versioning</span><span style="color: #000000"></span><span style="color: #001080">规范</span>
<span style="color: #000000">name: </span><span style="color: #001080">compoent</span><span style="color: #000000">-</span><span style="color: #001080">test</span><span style="color: #000000"> # </span><span style="color: #001080">项目名称</span>
<span style="color: #000000">services:</span>
<span style="color: #000000"> </span><span style="color: #001080">component</span><span style="color: #000000">-test:</span>
<span style="color: #000000"> component: </span><span style="color: #001080">devsapp</span><span style="color: #000000">/</span><span style="color: #001080">fc</span><span style="color: #000000">-</span><span style="color: #001080">remote</span><span style="color: #000000">-</span><span style="color: #001080">invoke</span><span style="color: #000000"> # </span><span style="color: #001080">这里引入的是相对路径</span><span style="color: #000000"></span><span style="color: #001080">正式配置替换成你自己的component名称即可</span><span style="color: #000000"> </span>
<span style="color: #000000"> props:</span>
<span style="color: #000000"> region: </span><span style="color: #001080">$</span><span style="color: #000000">{</span><span style="color: #001080">region</span><span style="color: #000000">}</span>
<span style="color: #000000"> serviceName: </span><span style="color: #001080">$</span><span style="color: #000000">{</span><span style="color: #001080">serviceName</span><span style="color: #000000">}</span>
<span style="color: #000000"> functionName: </span><span style="color: #001080">$</span><span style="color: #000000">{</span><span style="color: #001080">functionName</span><span style="color: #000000">}</span>
</code></pre>
<a href="#函数调用" id="函数调用" style="color: inherit; text-decoration: none;">
<h3>函数调用</h3>
</a>
<pre><code><span style="color: #001080">$</span><span style="color: #000000"> </span><span style="color: #001080">s</span><span style="color: #000000"> </span><span style="color: #001080">exec</span><span style="color: #000000"> -- </span><span style="color: #001080">invoke</span><span style="color: #000000"> --</span><span style="color: #001080">invocation</span><span style="color: #000000">-</span><span style="color: #0000FF">type</span><span style="color: #000000"> </span><span style="color: #267F99">sync</span><span style="color: #000000"> --event ${payload}</span>
<span style="color: #001080">$</span><span style="color: #000000"> </span><span style="color: #001080">s</span><span style="color: #000000"> </span><span style="color: #001080">exec</span><span style="color: #000000"> -- </span><span style="color: #001080">invoke</span><span style="color: #000000"> --</span><span style="color: #001080">invocation</span><span style="color: #000000">-</span><span style="color: #0000FF">type</span><span style="color: #000000"> </span><span style="color: #267F99">async</span><span style="color: #000000"> --event-file ${path}</span>
<span style="color: #001080">$</span><span style="color: #000000"> </span><span style="color: #001080">s</span><span style="color: #000000"> </span><span style="color: #001080">exec</span><span style="color: #000000"> -- </span><span style="color: #001080">invoke</span><span style="color: #000000"> --</span><span style="color: #001080">event</span><span style="color: #000000">-</span><span style="color: #001080">stdin</span>
</code></pre>
<a href="#cli-用法" id="cli-用法" style="color: inherit; text-decoration: none;">
<h2>CLI 用法</h2>
</a>
<pre><code><span style="color: #001080">$</span><span style="color: #000000"> </span><span style="color: #001080">s</span><span style="color: #000000"> </span><span style="color: #001080">cli</span><span style="color: #000000"> </span><span style="color: #001080">fc</span><span style="color: #000000">-</span><span style="color: #001080">remote</span><span style="color: #000000">-</span><span style="color: #001080">invoke</span><span style="color: #000000"> </span><span style="color: #001080">invoke</span><span style="color: #000000"> --</span><span style="color: #001080">region</span><span style="color: #000000"> * --</span><span style="color: #001080">service</span><span style="color: #000000">-</span><span style="color: #001080">name</span><span style="color: #000000"> * --</span><span style="color: #0000FF">function</span><span style="color: #000000">-</span><span style="color: #795E26">name</span><span style="color: #000000"> </span><span style="color: #0000FF">*</span><span style="color: #000000"> --</span><span style="color: #795E26">invocation</span><span style="color: #000000">-</span><span style="color: #795E26">type</span><span style="color: #000000"> </span><span style="color: #795E26">sync</span><span style="color: #000000"> --</span><span style="color: #795E26">event</span><span style="color: #000000"> </span><span style="color: #795E26">$</span><span style="color: #000000">{</span><span style="color: #001080">payload</span><span style="color: #000000">}</span>
<span style="color: #001080">$</span><span style="color: #000000"> </span><span style="color: #001080">s</span><span style="color: #000000"> </span><span style="color: #001080">cli</span><span style="color: #000000"> </span><span style="color: #001080">fc</span><span style="color: #000000">-</span><span style="color: #001080">remote</span><span style="color: #000000">-</span><span style="color: #001080">invoke</span><span style="color: #000000"> </span><span style="color: #001080">invoke</span><span style="color: #000000"> --</span><span style="color: #001080">region</span><span style="color: #000000"> * --</span><span style="color: #001080">service</span><span style="color: #000000">-</span><span style="color: #001080">name</span><span style="color: #000000"> * --</span><span style="color: #0000FF">function</span><span style="color: #000000">-</span><span style="color: #795E26">name</span><span style="color: #000000"> </span><span style="color: #0000FF">*</span><span style="color: #000000"> --</span><span style="color: #795E26">invocation</span><span style="color: #000000">-</span><span style="color: #795E26">type</span><span style="color: #000000"> </span><span style="color: #795E26">async</span><span style="color: #000000"> --</span><span style="color: #795E26">event</span><span style="color: #000000">-</span><span style="color: #795E26">file</span><span style="color: #000000"> </span><span style="color: #795E26">$</span><span style="color: #000000">{</span><span style="color: #001080">path</span><span style="color: #000000">}</span>
<span style="color: #001080">$</span><span style="color: #000000"> </span><span style="color: #001080">s</span><span style="color: #000000"> </span><span style="color: #001080">cli</span><span style="color: #000000"> </span><span style="color: #001080">fc</span><span style="color: #000000">-</span><span style="color: #001080">remote</span><span style="color: #000000">-</span><span style="color: #001080">invoke</span><span style="color: #000000"> </span><span style="color: #001080">invoke</span><span style="color: #000000"> --</span><span style="color: #001080">region</span><span style="color: #000000"> * --</span><span style="color: #001080">service</span><span style="color: #000000">-</span><span style="color: #001080">name</span><span style="color: #000000"> * --</span><span style="color: #0000FF">function</span><span style="color: #000000">-</span><span style="color: #795E26">name</span><span style="color: #000000"> </span><span style="color: #0000FF">*</span><span style="color: #000000"> --</span><span style="color: #795E26">event</span><span style="color: #000000">-</span><span style="color: #795E26">stdin</span>
</code></pre>
<a href="#特别说明" id="特别说明" style="color: inherit; text-decoration: none;">
<h2>特别说明</h2>
</a>
<p>当函数是 http 函数时event最终获取值目前仅支持 json 字符串,<a href="https://github.com/devsapp/fc-remote-invoke/blob/master/example/http.json">示例参考</a></p>
<pre><code><span style="color: #000000">{</span>
<span style="color: #000000"> </span><span style="color: #A31515">&quot;body&quot;</span><span style="color: #000000">: </span><span style="color: #A31515">&quot;body&quot;</span><span style="color: #000000">,</span>
<span style="color: #000000"> </span><span style="color: #A31515">&quot;method&quot;</span><span style="color: #000000">: </span><span style="color: #A31515">&quot;POST&quot;</span><span style="color: #000000">,</span>
<span style="color: #000000"> </span><span style="color: #A31515">&quot;headers&quot;</span><span style="color: #000000">: {</span>
<span style="color: #000000"> </span><span style="color: #A31515">&quot;key&quot;</span><span style="color: #001080">:</span><span style="color: #000000"> </span><span style="color: #A31515">&quot;value&quot;</span>
<span style="color: #000000"> },</span>
<span style="color: #000000"> </span><span style="color: #A31515">&quot;queries&quot;</span><span style="color: #000000">: {</span>
<span style="color: #000000"> </span><span style="color: #A31515">&quot;key&quot;</span><span style="color: #001080">:</span><span style="color: #000000"> </span><span style="color: #A31515">&quot;value&quot;</span>
<span style="color: #000000"> },</span>
<span style="color: #000000"> </span><span style="color: #A31515">&quot;path&quot;</span><span style="color: #000000">: </span><span style="color: #A31515">&quot;string&quot;</span>
<span style="color: #000000">}</span>
</code></pre>
<p>invocation-type 选填,默认 sync
event 选填event 函数默认为空字符串http 函数默认 GET 请求,其他参数为空</p>
</div>
</div>
<div class="col-4 col-menu menu-sticky-wrap menu-highlight">
<nav class="tsd-navigation primary">
<ul>
<li class=" ">
<a href="modules.html">Exports</a>
</li>
</ul>
</nav>
<nav class="tsd-navigation secondary menu-sticky">
<ul class="before-current">
<li class=" tsd-kind-class">
<a href="classes/default.html" class="tsd-kind-icon">default</a>
</li>
</ul>
</nav>
</div>
</div>
</div>
<footer class="with-border-bottom">
<div class="container">
<h2>Legend</h2>
<div class="tsd-legend-group">
<ul class="tsd-legend">
<li class="tsd-kind-constructor tsd-parent-kind-class"><span class="tsd-kind-icon">Constructor</span></li>
<li class="tsd-kind-method tsd-parent-kind-class"><span class="tsd-kind-icon">Method</span></li>
</ul>
<ul class="tsd-legend">
<li class="tsd-kind-method tsd-parent-kind-class tsd-is-private"><span class="tsd-kind-icon">Private method</span></li>
</ul>
</div>
</div>
</footer>
<div class="container tsd-generator">
<p>Generated using <a href="https://typedoc.org/" target="_blank">TypeDoc</a></p>
</div>
<div class="overlay"></div>
<script src="assets/js/main.js"></script>
</body>
</html>

View File

@ -1,112 +0,0 @@
<!doctype html>
<html class="default no-js">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<title>fc-remote-invoke</title>
<meta name="description" content="Documentation for fc-remote-invoke">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="assets/css/main.css">
<script async src="assets/js/search.js" id="search-script"></script>
</head>
<body>
<header>
<div class="tsd-page-toolbar">
<div class="container">
<div class="table-wrap">
<div class="table-cell" id="tsd-search" data-index="assets/js/search.json" data-base=".">
<div class="field">
<label for="tsd-search-field" class="tsd-widget search no-caption">Search</label>
<input id="tsd-search-field" type="text" />
</div>
<ul class="results">
<li class="state loading">Preparing search index...</li>
<li class="state failure">The search index is not available</li>
</ul>
<a href="index.html" class="title">fc-remote-invoke</a>
</div>
<div class="table-cell" id="tsd-widgets">
<div id="tsd-filter">
<a href="#" class="tsd-widget options no-caption" data-toggle="options">Options</a>
<div class="tsd-filter-group">
<div class="tsd-select" id="tsd-filter-visibility">
<span class="tsd-select-label">All</span>
<ul class="tsd-select-list">
<li data-value="public">Public</li>
<li data-value="protected">Public/Protected</li>
<li data-value="private" class="selected">All</li>
</ul>
</div>
<input type="checkbox" id="tsd-filter-inherited" checked />
<label class="tsd-widget" for="tsd-filter-inherited">Inherited</label>
<input type="checkbox" id="tsd-filter-externals" checked />
<label class="tsd-widget" for="tsd-filter-externals">Externals</label>
</div>
</div>
<a href="#" class="tsd-widget menu no-caption" data-toggle="menu">Menu</a>
</div>
</div>
</div>
</div>
<div class="tsd-page-title">
<div class="container">
<h1>fc-remote-invoke</h1>
</div>
</div>
</header>
<div class="container container-main">
<div class="row">
<div class="col-8 col-content">
<section class="tsd-panel-group tsd-index-group">
<h2>Index</h2>
<section class="tsd-panel tsd-index-panel">
<div class="tsd-index-content">
<section class="tsd-index-section ">
<h3>Classes</h3>
<ul class="tsd-index-list">
<li class="tsd-kind-class"><a href="classes/default.html" class="tsd-kind-icon">default</a></li>
</ul>
</section>
</div>
</section>
</section>
</div>
<div class="col-4 col-menu menu-sticky-wrap menu-highlight">
<nav class="tsd-navigation primary">
<ul>
<li class="current ">
<a href="modules.html">Exports</a>
</li>
</ul>
</nav>
<nav class="tsd-navigation secondary menu-sticky">
<ul class="before-current">
<li class=" tsd-kind-class">
<a href="classes/default.html" class="tsd-kind-icon">default</a>
</li>
</ul>
</nav>
</div>
</div>
</div>
<footer class="with-border-bottom">
<div class="container">
<h2>Legend</h2>
<div class="tsd-legend-group">
<ul class="tsd-legend">
<li class="tsd-kind-constructor tsd-parent-kind-class"><span class="tsd-kind-icon">Constructor</span></li>
<li class="tsd-kind-method tsd-parent-kind-class"><span class="tsd-kind-icon">Method</span></li>
</ul>
<ul class="tsd-legend">
<li class="tsd-kind-method tsd-parent-kind-class tsd-is-private"><span class="tsd-kind-icon">Private method</span></li>
</ul>
</div>
</div>
</footer>
<div class="container tsd-generator">
<p>Generated using <a href="https://typedoc.org/" target="_blank">TypeDoc</a></p>
</div>
<div class="overlay"></div>
<script src="assets/js/main.js"></script>
</body>
</html>

View File

@ -1,11 +1,16 @@
{
"body": 123,
"method": "POST",
"headers": {
"key": "value"
"key": "value",
"Content-Type": "application/json"
},
"queries": {
"key": "value"
},
"path": "string"
"body": {
"abc": "body",
"tmpNasZipPath": "/tmpNasZipPath",
"body": "body"
},
"path": "download"
}

44
lib/common/help.d.ts vendored
View File

@ -1,44 +0,0 @@
declare const _default: ({
header: string;
content: string;
optionList?: undefined;
} | {
header: string;
optionList: ({
name: string;
description: string;
type: StringConstructor;
alias?: undefined;
} | {
name: string;
description: string;
alias: string;
type: StringConstructor;
} | {
name: string;
description: string;
type: BooleanConstructor;
alias?: undefined;
})[];
content?: undefined;
} | {
header: string;
optionList: {
name: string;
description: string;
alias: string;
type: BooleanConstructor;
}[];
content?: undefined;
} | {
header: string;
content: string[];
optionList?: undefined;
} | {
header: string;
content: {
example: string;
}[];
optionList?: undefined;
})[];
export default _default;

View File

@ -1,103 +0,0 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.default = [
{
header: 'Invoke',
content: 'Invoke/trigger online functions.',
},
{
header: 'Usage',
content: '$ s invoke <options>',
},
{
header: 'Options',
optionList: [
{
name: 'invocation-type',
description: 'Invocation type: optional value "async"|"sync", default value "sync" (default: "sync")',
type: String,
},
{
name: 'event',
description: 'Event data (strings) passed to the function during invocation (default: "").Http function format refers to [https://github.com/devsapp/fc-remote-invoke#特别说明]',
type: String,
},
{
name: 'event-file',
description: 'Event funtion: A file containing event data passed to the function during invoke. Http function: A file containing http request options sent to http trigger. Format refers to [https://github.com/devsapp/fc-remote-invoke#特别说明]',
alias: 'f',
type: String,
},
{
name: 'event-stdin',
description: 'Read from standard input, to support script pipeline.Http function format refers to [https://github.com/devsapp/fc-remote-invoke#特别说明]',
type: Boolean,
},
{
name: 'region',
description: 'Specify region in cli mode',
type: String,
},
{
name: 'service-name',
description: 'Specify service name in cli mode',
type: String,
},
{
name: 'function-name',
description: 'Specify function name in cli mode',
type: String,
},
{
name: 'domain-name',
description: 'Specify custom domain name in cli mode',
type: String,
},
],
},
{
header: 'Global Options',
optionList: [
{
name: 'access',
description: 'Specify key alias.',
alias: 'a',
type: Boolean,
},
{
name: 'help',
description: 'fc-remote-invoke help for command.',
alias: 'h',
type: Boolean,
},
],
},
{
header: 'Examples with Yaml',
content: [
'$ s invoke',
'$ s <ProjectName> invoke',
'$ s exec -- invoke --invocation-type sync --event <payload>',
'$ s exec -- invoke --event-file <file-path>',
'$ s exec -- invoke --event-stdin',
],
},
{
header: 'Examples with CLI',
content: [
{
example: '$ s cli fc-remote-invoke invoke --region * --service-name * --function-name * --event <payload>',
},
{
example: '$ s cli fc-remote-invoke invoke --region * --service-name * --function-name * --event-file <file-path>',
},
{
example: '$ s cli fc-remote-invoke invoke --region * --service-name * --function-name * --event-stdin',
},
{
example: '\nYou also can refer to the usage of fc-api and execute [s cli fc-api -h] for help. $ s cli fc-api invokeFunction -h',
},
],
},
];
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiaGVscC5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uLy4uL3NyYy9jb21tb24vaGVscC50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiOztBQUFBLGtCQUFlO0lBQ2I7UUFDRSxNQUFNLEVBQUUsUUFBUTtRQUNoQixPQUFPLEVBQUUsa0NBQWtDO0tBQzVDO0lBQ0Q7UUFDRSxNQUFNLEVBQUUsT0FBTztRQUNmLE9BQU8sRUFBRSxzQkFBc0I7S0FDaEM7SUFDRDtRQUNFLE1BQU0sRUFBRSxTQUFTO1FBQ2pCLFVBQVUsRUFBRTtZQUNWO2dCQUNFLElBQUksRUFBRSxpQkFBaUI7Z0JBQ3ZCLFdBQVcsRUFBRSx3RkFBd0Y7Z0JBQ3JHLElBQUksRUFBRSxNQUFNO2FBQ2I7WUFDRDtnQkFDRSxJQUFJLEVBQUUsT0FBTztnQkFDYixXQUFXLEVBQUUsK0pBQStKO2dCQUM1SyxJQUFJLEVBQUUsTUFBTTthQUNiO1lBQ0Q7Z0JBQ0UsSUFBSSxFQUFFLFlBQVk7Z0JBQ2xCLFdBQVcsRUFBRSxtT0FBbU87Z0JBQ2hQLEtBQUssRUFBRSxHQUFHO2dCQUNWLElBQUksRUFBRSxNQUFNO2FBQ2I7WUFDRDtnQkFDRSxJQUFJLEVBQUUsYUFBYTtnQkFDbkIsV0FBVyxFQUFFLHdJQUF3STtnQkFDckosSUFBSSxFQUFFLE9BQU87YUFDZDtZQUNEO2dCQUNFLElBQUksRUFBRSxRQUFRO2dCQUNkLFdBQVcsRUFBRSw0QkFBNEI7Z0JBQ3pDLElBQUksRUFBRSxNQUFNO2FBQ2I7WUFDRDtnQkFDRSxJQUFJLEVBQUUsY0FBYztnQkFDcEIsV0FBVyxFQUFFLGtDQUFrQztnQkFDL0MsSUFBSSxFQUFFLE1BQU07YUFDYjtZQUNEO2dCQUNFLElBQUksRUFBRSxlQUFlO2dCQUNyQixXQUFXLEVBQUUsbUNBQW1DO2dCQUNoRCxJQUFJLEVBQUUsTUFBTTthQUNiO1lBQ0Q7Z0JBQ0UsSUFBSSxFQUFFLGFBQWE7Z0JBQ25CLFdBQVcsRUFBRSx3Q0FBd0M7Z0JBQ3JELElBQUksRUFBRSxNQUFNO2FBQ2I7U0FDRjtLQUNGO0lBQ0Q7UUFDRSxNQUFNLEVBQUUsZ0JBQWdCO1FBQ3hCLFVBQVUsRUFBRTtZQUNWO2dCQUNFLElBQUksRUFBRSxRQUFRO2dCQUNkLFdBQVcsRUFBRSxvQkFBb0I7Z0JBQ2pDLEtBQUssRUFBRSxHQUFHO2dCQUNWLElBQUksRUFBRSxPQUFPO2FBQ2Q7WUFDRDtnQkFDRSxJQUFJLEVBQUUsTUFBTTtnQkFDWixXQUFXLEVBQUUsb0NBQW9DO2dCQUNqRCxLQUFLLEVBQUUsR0FBRztnQkFDVixJQUFJLEVBQUUsT0FBTzthQUNkO1NBQ0Y7S0FDRjtJQUNEO1FBQ0UsTUFBTSxFQUFFLG9CQUFvQjtRQUM1QixPQUFPLEVBQUU7WUFDUCxZQUFZO1lBQ1osMEJBQTBCO1lBQzFCLDZEQUE2RDtZQUM3RCw2Q0FBNkM7WUFDN0Msa0NBQWtDO1NBQ25DO0tBQ0Y7SUFDRDtRQUNFLE1BQU0sRUFBRSxtQkFBbUI7UUFDM0IsT0FBTyxFQUFFO1lBQ1A7Z0JBQ0UsT0FBTyxFQUFFLGlHQUFpRzthQUMzRztZQUNEO2dCQUNFLE9BQU8sRUFBRSx3R0FBd0c7YUFDbEg7WUFDRDtnQkFDRSxPQUFPLEVBQUUsNkZBQTZGO2FBQ3ZHO1lBQ0Q7Z0JBQ0UsT0FBTyxFQUFFLHdIQUF3SDthQUNsSTtTQUNGO0tBQ0Y7Q0FDRixDQUFBIn0=

View File

@ -1,5 +0,0 @@
export declare function getConfig(key: string): any;
export declare function getProfileFile(): {};
export declare function getDefaultProfilePath(): string;
declare const i18n: any;
export default i18n;

View File

@ -1,45 +0,0 @@
"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.getDefaultProfilePath = exports.getProfileFile = exports.getConfig = void 0;
const os_1 = __importDefault(require("os"));
const fs_1 = __importDefault(require("fs"));
const path_1 = __importDefault(require("path"));
const js_yaml_1 = __importDefault(require("js-yaml"));
const i18n_1 = require("i18n");
function getConfig(key) {
const profile = getProfileFile();
return profile[key];
}
exports.getConfig = getConfig;
function getProfileFile() {
let profileResult = {};
try {
const profileFilePath = getDefaultProfilePath();
profileResult = js_yaml_1.default.load(fs_1.default.readFileSync(profileFilePath, 'utf8')) || {};
}
catch (e) {
console.log(e);
}
return profileResult;
}
exports.getProfileFile = getProfileFile;
function getDefaultProfilePath() {
return path_1.default.join(os_1.default.homedir(), '.s', 'set-config.yml');
}
exports.getDefaultProfilePath = getDefaultProfilePath;
const i18n = new i18n_1.I18n({
locales: ['en', 'zh'],
directory: path_1.default.join(__dirname, '..', '..', 'locales'),
});
const locale = getConfig('locale');
if (locale) {
i18n.setLocale(locale);
}
else {
i18n.setLocale('en');
}
exports.default = i18n;
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiaTE4bi5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uLy4uL3NyYy9jb21tb24vaTE4bi50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiOzs7Ozs7QUFBQSw0Q0FBb0I7QUFDcEIsNENBQW9CO0FBQ3BCLGdEQUF3QjtBQUN4QixzREFBMkI7QUFDM0IsK0JBQTRCO0FBRTVCLFNBQWdCLFNBQVMsQ0FBQyxHQUFXO0lBQ2pDLE1BQU0sT0FBTyxHQUFHLGNBQWMsRUFBRSxDQUFDO0lBQ2pDLE9BQU8sT0FBTyxDQUFDLEdBQUcsQ0FBQyxDQUFDO0FBQ3hCLENBQUM7QUFIRCw4QkFHQztBQUdELFNBQWdCLGNBQWM7SUFDMUIsSUFBSSxhQUFhLEdBQUcsRUFBRSxDQUFBO0lBQ3RCLElBQUk7UUFDQSxNQUFNLGVBQWUsR0FBRyxxQkFBcUIsRUFBRSxDQUFDO1FBQ2hELGFBQWEsR0FBRyxpQkFBSSxDQUFDLElBQUksQ0FBQyxZQUFFLENBQUMsWUFBWSxDQUFDLGVBQWUsRUFBRSxNQUFNLENBQUMsQ0FBQyxJQUFJLEVBQUUsQ0FBQztLQUM3RTtJQUFDLE9BQU8sQ0FBQyxFQUFFO1FBQ1IsT0FBTyxDQUFDLEdBQUcsQ0FBQyxDQUFDLENBQUMsQ0FBQztLQUNsQjtJQUVELE9BQU8sYUFBYSxDQUFDO0FBQ3pCLENBQUM7QUFWRCx3Q0FVQztBQUdELFNBQWdCLHFCQUFxQjtJQUNqQyxPQUFPLGNBQUksQ0FBQyxJQUFJLENBQUMsWUFBRSxDQUFDLE9BQU8sRUFBRSxFQUFFLElBQUksRUFBRSxnQkFBZ0IsQ0FBQyxDQUFDO0FBQzNELENBQUM7QUFGRCxzREFFQztBQUVELE1BQU0sSUFBSSxHQUFHLElBQUksV0FBSSxDQUFDO0lBQ2xCLE9BQU8sRUFBRSxDQUFDLElBQUksRUFBRSxJQUFJLENBQUM7SUFDckIsU0FBUyxFQUFFLGNBQUksQ0FBQyxJQUFJLENBQUMsU0FBUyxFQUFFLElBQUksRUFBRSxJQUFJLEVBQUUsU0FBUyxDQUFDO0NBQ3pELENBQUMsQ0FBQztBQUdILE1BQU0sTUFBTSxHQUFHLFNBQVMsQ0FBQyxRQUFRLENBQUMsQ0FBQztBQUNuQyxJQUFJLE1BQU0sRUFBRTtJQUNSLElBQUksQ0FBQyxTQUFTLENBQUMsTUFBTSxDQUFDLENBQUM7Q0FDMUI7S0FBTTtJQUNILElBQUksQ0FBQyxTQUFTLENBQUMsSUFBSSxDQUFDLENBQUM7Q0FDeEI7QUFFRCxrQkFBZSxJQUFJLENBQUMifQ==

View File

@ -1,10 +0,0 @@
export default class ComponentLogger {
static CONTENT: string;
static setContent(content: any): void;
static log(m: any, color?: 'black' | 'red' | 'green' | 'yellow' | 'blue' | 'magenta' | 'cyan' | 'white' | 'whiteBright' | 'gray'): void;
static info(m: any): void;
static debug(m: any): void;
static error(m: any): void;
static warning(m: any): void;
static success(m: any): void;
}

View File

@ -1,33 +0,0 @@
"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
const i18n_1 = __importDefault(require("./i18n"));
const core_1 = require("@serverless-devs/core");
class ComponentLogger {
static setContent(content) {
ComponentLogger.CONTENT = content;
}
static log(m, color) {
core_1.Logger.log(i18n_1.default.__(m) || m, color);
}
static info(m) {
core_1.Logger.info(ComponentLogger.CONTENT, i18n_1.default.__(m) || m);
}
static debug(m) {
core_1.Logger.debug(ComponentLogger.CONTENT, i18n_1.default.__(m) || m);
}
static error(m) {
core_1.Logger.error(ComponentLogger.CONTENT, i18n_1.default.__(m) || m);
}
static warning(m) {
core_1.Logger.warn(ComponentLogger.CONTENT, i18n_1.default.__(m) || m);
}
static success(m) {
core_1.Logger.log(i18n_1.default.__(m) || m, 'green');
}
}
exports.default = ComponentLogger;
ComponentLogger.CONTENT = 'FC-REMOTE-INVOKE';
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoibG9nZ2VyLmpzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vLi4vc3JjL2NvbW1vbi9sb2dnZXIudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6Ijs7Ozs7QUFDQSxrREFBMEI7QUFDMUIsZ0RBQStDO0FBRS9DLE1BQXFCLGVBQWU7SUFFbEMsTUFBTSxDQUFDLFVBQVUsQ0FBQyxPQUFPO1FBQ3ZCLGVBQWUsQ0FBQyxPQUFPLEdBQUcsT0FBTyxDQUFDO0lBQ3BDLENBQUM7SUFDRCxNQUFNLENBQUMsR0FBRyxDQUFDLENBQUMsRUFBRSxLQUE2RztRQUN6SCxhQUFNLENBQUMsR0FBRyxDQUFDLGNBQUksQ0FBQyxFQUFFLENBQUMsQ0FBQyxDQUFDLElBQUksQ0FBQyxFQUFFLEtBQUssQ0FBQyxDQUFDO0lBQ3JDLENBQUM7SUFDRCxNQUFNLENBQUMsSUFBSSxDQUFDLENBQUM7UUFDWCxhQUFNLENBQUMsSUFBSSxDQUFDLGVBQWUsQ0FBQyxPQUFPLEVBQUUsY0FBSSxDQUFDLEVBQUUsQ0FBQyxDQUFDLENBQUMsSUFBSSxDQUFDLENBQUMsQ0FBQztJQUN4RCxDQUFDO0lBRUQsTUFBTSxDQUFDLEtBQUssQ0FBQyxDQUFDO1FBQ1osYUFBTSxDQUFDLEtBQUssQ0FBQyxlQUFlLENBQUMsT0FBTyxFQUFFLGNBQUksQ0FBQyxFQUFFLENBQUMsQ0FBQyxDQUFDLElBQUksQ0FBQyxDQUFDLENBQUM7SUFDekQsQ0FBQztJQUVELE1BQU0sQ0FBQyxLQUFLLENBQUMsQ0FBQztRQUNaLGFBQU0sQ0FBQyxLQUFLLENBQUMsZUFBZSxDQUFDLE9BQU8sRUFBRSxjQUFJLENBQUMsRUFBRSxDQUFDLENBQUMsQ0FBQyxJQUFJLENBQUMsQ0FBQyxDQUFDO0lBQ3pELENBQUM7SUFFRCxNQUFNLENBQUMsT0FBTyxDQUFDLENBQUM7UUFDZCxhQUFNLENBQUMsSUFBSSxDQUFDLGVBQWUsQ0FBQyxPQUFPLEVBQUUsY0FBSSxDQUFDLEVBQUUsQ0FBQyxDQUFDLENBQUMsSUFBSSxDQUFDLENBQUMsQ0FBQztJQUN4RCxDQUFDO0lBRUQsTUFBTSxDQUFDLE9BQU8sQ0FBQyxDQUFDO1FBQ2QsYUFBTSxDQUFDLEdBQUcsQ0FBQyxjQUFJLENBQUMsRUFBRSxDQUFDLENBQUMsQ0FBQyxJQUFJLENBQUMsRUFBRSxPQUFPLENBQUMsQ0FBQztJQUN2QyxDQUFDOztBQTFCSCxrQ0EyQkM7QUExQlEsdUJBQU8sR0FBRyxrQkFBa0IsQ0FBQyJ9

View File

@ -1,4 +0,0 @@
export default class StdoutFormatter {
static stdoutFormatter: any;
static initStdout(): Promise<void>;
}

View File

@ -1,21 +0,0 @@
"use strict";
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
return new (P || (P = Promise))(function (resolve, reject) {
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
step((generator = generator.apply(thisArg, _arguments || [])).next());
});
};
Object.defineProperty(exports, "__esModule", { value: true });
const core_1 = require("@serverless-devs/core");
class StdoutFormatter {
static initStdout() {
return __awaiter(this, void 0, void 0, function* () {
this.stdoutFormatter = yield core_1.loadComponent('devsapp/stdout-formatter');
});
}
}
exports.default = StdoutFormatter;
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoic3Rkb3V0LWZvcm1hdHRlci5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uLy4uL3NyYy9jb21tb24vc3Rkb3V0LWZvcm1hdHRlci50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiOzs7Ozs7Ozs7OztBQUFBLGdEQUFzRDtBQUV0RCxNQUFxQixlQUFlO0lBR2xDLE1BQU0sQ0FBTyxVQUFVOztZQUNyQixJQUFJLENBQUMsZUFBZSxHQUFHLE1BQU0sb0JBQWEsQ0FBQywwQkFBMEIsQ0FBQyxDQUFDO1FBQ3pFLENBQUM7S0FBQTtDQUNGO0FBTkQsa0NBTUMifQ==

11
lib/index.d.ts vendored
View File

@ -1,11 +0,0 @@
import { InputProps } from './interface/entity';
export default class FcRemoteInvoke {
/**
* event
* @param inputs
* @returns
*/
invoke(inputs: InputProps): Promise<any>;
private report;
private handlerInputs;
}

View File

@ -1,134 +0,0 @@
"use strict";
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
}) : (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
o[k2] = m[k];
}));
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
Object.defineProperty(o, "default", { enumerable: true, value: v });
}) : function(o, v) {
o["default"] = v;
});
var __importStar = (this && this.__importStar) || function (mod) {
if (mod && mod.__esModule) return mod;
var result = {};
if (mod != null) for (var k in mod) if (k !== "default" && Object.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
__setModuleDefault(result, mod);
return result;
};
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
return new (P || (P = Promise))(function (resolve, reject) {
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
step((generator = generator.apply(thisArg, _arguments || [])).next());
});
};
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
const lodash_1 = __importDefault(require("lodash"));
const core = __importStar(require("@serverless-devs/core"));
const logger_1 = __importDefault(require("./common/logger"));
const help_1 = __importDefault(require("./common/help"));
const entity_1 = require("./interface/entity");
// import StdoutFormatter from './common/stdout-formatter';
const remote_invoke_1 = __importDefault(require("./lib/remote-invoke"));
const client_1 = __importDefault(require("./lib/client"));
class FcRemoteInvoke {
/**
* event 函数本地调试
* @param inputs
* @returns
*/
invoke(inputs) {
return __awaiter(this, void 0, void 0, function* () {
const { props, eventPayload, credentials, isHelp, invocationType, } = yield this.handlerInputs(inputs);
yield this.report('fc-remote-invoke', 'invoke', credentials === null || credentials === void 0 ? void 0 : credentials.AccountID);
if (isHelp) {
core.help(help_1.default);
return;
}
let fcClient;
if (!props.domainName) {
fcClient = yield client_1.default.buildFcClient(props.region, credentials);
}
const remoteInvoke = new remote_invoke_1.default(fcClient, credentials.AccountID);
yield remoteInvoke.invoke(props, eventPayload, { invocationType });
});
}
report(componentName, command, accountID) {
return __awaiter(this, void 0, void 0, function* () {
core.reportComponent(componentName, {
command,
uid: accountID,
});
});
}
handlerInputs(inputs) {
var _a, _b, _c, _d, _e, _f;
return __awaiter(this, void 0, void 0, function* () {
// 去除 args 的行首以及行尾的空格
const args = ((inputs === null || inputs === void 0 ? void 0 : inputs.args) || '').replace(/(^\s*)|(\s*$)/g, '');
logger_1.default.debug(`input args: ${args}`);
const parsedArgs = core.commandParse({ args }, {
boolean: ['help', 'event-stdin'],
string: ['invocation-type', 'event', 'event-file', 'region', 'domain-name', 'service-name', 'function-name', 'qualifier'],
alias: {
'help': 'h',
'event': 'e',
'event-file': 'f',
}
});
const argsData = (parsedArgs === null || parsedArgs === void 0 ? void 0 : parsedArgs.data) || {};
logger_1.default.debug(`command parse: ${JSON.stringify(argsData)}`);
if (argsData.help) {
return {
credentials: inputs.credentials,
isHelp: true,
};
}
const { e: event, f: eventFile, 'event-file': eventStdin, 'invocation-type': invocationType = 'sync', 'domain-name': domainName, } = argsData;
const eventPayload = { event, eventFile, eventStdin };
// @ts-ignore: 判断三个值有几个真
const eventFlag = !!event + !!eventFile + !!eventStdin;
if (eventFlag > 1) {
throw new Error('event | event-file | event-stdin must choose one.');
}
else if (eventFlag === 0) {
eventPayload.event = '';
}
if (!['sync', 'async'].includes(invocationType)) {
throw new Error('invocation-type enum value sync, async.');
}
if (!domainName && !(inputs === null || inputs === void 0 ? void 0 : inputs.credentials)) {
inputs.credentials = yield core.getCredential((_a = inputs === null || inputs === void 0 ? void 0 : inputs.project) === null || _a === void 0 ? void 0 : _a.access);
}
logger_1.default.debug(`input props: ${JSON.stringify(inputs.props)}`);
const props = {
region: argsData.region || ((_b = inputs.props) === null || _b === void 0 ? void 0 : _b.region),
serviceName: argsData['service-name'] || ((_c = inputs.props) === null || _c === void 0 ? void 0 : _c.serviceName),
functionName: argsData['function-name'] || ((_d = inputs.props) === null || _d === void 0 ? void 0 : _d.functionName),
domainName: domainName || ((_e = inputs.props) === null || _e === void 0 ? void 0 : _e.domainName),
qualifier: argsData.qualifier || ((_f = inputs.props) === null || _f === void 0 ? void 0 : _f.qualifier),
};
logger_1.default.debug(`input args props: ${JSON.stringify(props)}`);
if (!entity_1.isProperties(props)) {
throw new Error('region/serviceName(service-name)/functionName(function-name) can not be empty.');
}
return {
props,
credentials: inputs.credentials,
eventPayload,
isHelp: false,
invocationType: lodash_1.default.upperFirst(invocationType),
};
});
}
}
exports.default = FcRemoteInvoke;
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiaW5kZXguanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi9zcmMvaW5kZXgudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6Ijs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7O0FBQUEsb0RBQXVCO0FBQ3ZCLDREQUE4QztBQUM5Qyw2REFBcUM7QUFDckMseURBQWlDO0FBQ2pDLCtDQUEyRTtBQUMzRSwyREFBMkQ7QUFDM0Qsd0VBQStDO0FBQy9DLDBEQUFrQztBQUVsQyxNQUFxQixjQUFjO0lBQ2pDOzs7O09BSUc7SUFDRyxNQUFNLENBQUMsTUFBa0I7O1lBQzdCLE1BQU0sRUFDSixLQUFLLEVBQ0wsWUFBWSxFQUNaLFdBQVcsRUFDWCxNQUFNLEVBQ04sY0FBYyxHQUNmLEdBQUcsTUFBTSxJQUFJLENBQUMsYUFBYSxDQUFDLE1BQU0sQ0FBQyxDQUFDO1lBQ3JDLE1BQU0sSUFBSSxDQUFDLE1BQU0sQ0FBQyxrQkFBa0IsRUFBRSxRQUFRLEVBQUUsV0FBVyxhQUFYLFdBQVcsdUJBQVgsV0FBVyxDQUFFLFNBQVMsQ0FBQyxDQUFDO1lBRXhFLElBQUksTUFBTSxFQUFFO2dCQUNWLElBQUksQ0FBQyxJQUFJLENBQUMsY0FBSSxDQUFDLENBQUM7Z0JBQ2hCLE9BQU87YUFDUjtZQUVELElBQUksUUFBUSxDQUFDO1lBQ2IsSUFBSSxDQUFDLEtBQUssQ0FBQyxVQUFVLEVBQUU7Z0JBQ3JCLFFBQVEsR0FBRyxNQUFNLGdCQUFNLENBQUMsYUFBYSxDQUFDLEtBQUssQ0FBQyxNQUFNLEVBQUUsV0FBVyxDQUFDLENBQUM7YUFDbEU7WUFDRCxNQUFNLFlBQVksR0FBRyxJQUFJLHVCQUFZLENBQUMsUUFBUSxFQUFFLFdBQVcsQ0FBQyxTQUFTLENBQUMsQ0FBQztZQUN2RSxNQUFNLFlBQVksQ0FBQyxNQUFNLENBQUMsS0FBSyxFQUFFLFlBQVksRUFBRSxFQUFFLGNBQWMsRUFBRSxDQUFDLENBQUM7UUFDckUsQ0FBQztLQUFBO0lBRWEsTUFBTSxDQUFDLGFBQXFCLEVBQUUsT0FBZSxFQUFFLFNBQWlCOztZQUM1RSxJQUFJLENBQUMsZUFBZSxDQUFDLGFBQWEsRUFBRTtnQkFDbEMsT0FBTztnQkFDUCxHQUFHLEVBQUUsU0FBUzthQUNmLENBQUMsQ0FBQztRQUNMLENBQUM7S0FBQTtJQUVhLGFBQWEsQ0FBQyxNQUFrQjs7O1lBQzVDLHFCQUFxQjtZQUNyQixNQUFNLElBQUksR0FBVyxDQUFDLENBQUEsTUFBTSxhQUFOLE1BQU0sdUJBQU4sTUFBTSxDQUFFLElBQUksS0FBSSxFQUFFLENBQUMsQ0FBQyxPQUFPLENBQUMsZ0JBQWdCLEVBQUUsRUFBRSxDQUFDLENBQUM7WUFDeEUsZ0JBQU0sQ0FBQyxLQUFLLENBQUMsZUFBZSxJQUFJLEVBQUUsQ0FBQyxDQUFDO1lBRXBDLE1BQU0sVUFBVSxHQUF5QixJQUFJLENBQUMsWUFBWSxDQUFDLEVBQUUsSUFBSSxFQUFFLEVBQUU7Z0JBQ25FLE9BQU8sRUFBRSxDQUFDLE1BQU0sRUFBRSxhQUFhLENBQUM7Z0JBQ2hDLE1BQU0sRUFBRSxDQUFDLGlCQUFpQixFQUFFLE9BQU8sRUFBRSxZQUFZLEVBQUUsUUFBUSxFQUFFLGFBQWEsRUFBQyxjQUFjLEVBQUUsZUFBZSxFQUFFLFdBQVcsQ0FBQztnQkFDeEgsS0FBSyxFQUFFO29CQUNMLE1BQU0sRUFBRSxHQUFHO29CQUNYLE9BQU8sRUFBRSxHQUFHO29CQUNaLFlBQVksRUFBRSxHQUFHO2lCQUNsQjthQUNGLENBQUMsQ0FBQztZQUVILE1BQU0sUUFBUSxHQUFRLENBQUEsVUFBVSxhQUFWLFVBQVUsdUJBQVYsVUFBVSxDQUFFLElBQUksS0FBSSxFQUFFLENBQUM7WUFDN0MsZ0JBQU0sQ0FBQyxLQUFLLENBQUMsa0JBQWtCLElBQUksQ0FBQyxTQUFTLENBQUMsUUFBUSxDQUFDLEVBQUUsQ0FBQyxDQUFDO1lBQzNELElBQUksUUFBUSxDQUFDLElBQUksRUFBRTtnQkFDakIsT0FBTztvQkFDTCxXQUFXLEVBQUUsTUFBTSxDQUFDLFdBQVc7b0JBQy9CLE1BQU0sRUFBRSxJQUFJO2lCQUNiLENBQUM7YUFDSDtZQUVELE1BQU0sRUFDSixDQUFDLEVBQUUsS0FBSyxFQUNSLENBQUMsRUFBRSxTQUFTLEVBQ1osWUFBWSxFQUFFLFVBQVUsRUFDeEIsaUJBQWlCLEVBQUUsY0FBYyxHQUFHLE1BQU0sRUFDMUMsYUFBYSxFQUFFLFVBQVUsR0FDMUIsR0FBRyxRQUFRLENBQUM7WUFDYixNQUFNLFlBQVksR0FBRyxFQUFFLEtBQUssRUFBRSxTQUFTLEVBQUUsVUFBVSxFQUFFLENBQUM7WUFDdEQsd0JBQXdCO1lBQ3hCLE1BQU0sU0FBUyxHQUFHLENBQUMsQ0FBQyxLQUFLLEdBQUcsQ0FBQyxDQUFDLFNBQVMsR0FBRyxDQUFDLENBQUMsVUFBVSxDQUFDO1lBRXZELElBQUksU0FBUyxHQUFHLENBQUMsRUFBRTtnQkFDakIsTUFBTSxJQUFJLEtBQUssQ0FBQyxtREFBbUQsQ0FBQyxDQUFDO2FBQ3RFO2lCQUFNLElBQUksU0FBUyxLQUFLLENBQUMsRUFBRTtnQkFDMUIsWUFBWSxDQUFDLEtBQUssR0FBRyxFQUFFLENBQUM7YUFDekI7WUFFRCxJQUFJLENBQUMsQ0FBQyxNQUFNLEVBQUUsT0FBTyxDQUFDLENBQUMsUUFBUSxDQUFDLGNBQWMsQ0FBQyxFQUFFO2dCQUMvQyxNQUFNLElBQUksS0FBSyxDQUFDLHlDQUF5QyxDQUFDLENBQUM7YUFDNUQ7WUFDRCxJQUFJLENBQUMsVUFBVSxJQUFJLEVBQUMsTUFBTSxhQUFOLE1BQU0sdUJBQU4sTUFBTSxDQUFFLFdBQVcsQ0FBQSxFQUFFO2dCQUN2QyxNQUFNLENBQUMsV0FBVyxHQUFHLE1BQU0sSUFBSSxDQUFDLGFBQWEsT0FBQyxNQUFNLGFBQU4sTUFBTSx1QkFBTixNQUFNLENBQUUsT0FBTywwQ0FBRSxNQUFNLENBQUMsQ0FBQzthQUN4RTtZQUVELGdCQUFNLENBQUMsS0FBSyxDQUFDLGdCQUFnQixJQUFJLENBQUMsU0FBUyxDQUFDLE1BQU0sQ0FBQyxLQUFLLENBQUMsRUFBRSxDQUFDLENBQUM7WUFFN0QsTUFBTSxLQUFLLEdBQWdCO2dCQUN6QixNQUFNLEVBQUUsUUFBUSxDQUFDLE1BQU0sV0FBSSxNQUFNLENBQUMsS0FBSywwQ0FBRSxNQUFNLENBQUE7Z0JBQy9DLFdBQVcsRUFBRSxRQUFRLENBQUMsY0FBYyxDQUFDLFdBQUksTUFBTSxDQUFDLEtBQUssMENBQUUsV0FBVyxDQUFBO2dCQUNsRSxZQUFZLEVBQUUsUUFBUSxDQUFDLGVBQWUsQ0FBQyxXQUFJLE1BQU0sQ0FBQyxLQUFLLDBDQUFFLFlBQVksQ0FBQTtnQkFDckUsVUFBVSxFQUFFLFVBQVUsV0FBSSxNQUFNLENBQUMsS0FBSywwQ0FBRSxVQUFVLENBQUE7Z0JBQ2xELFNBQVMsRUFBRSxRQUFRLENBQUMsU0FBUyxXQUFJLE1BQU0sQ0FBQyxLQUFLLDBDQUFFLFNBQVMsQ0FBQTthQUN6RCxDQUFDO1lBQ0YsZ0JBQU0sQ0FBQyxLQUFLLENBQUMscUJBQXFCLElBQUksQ0FBQyxTQUFTLENBQUMsS0FBSyxDQUFDLEVBQUUsQ0FBQyxDQUFDO1lBQzNELElBQUksQ0FBQyxxQkFBWSxDQUFDLEtBQUssQ0FBQyxFQUFFO2dCQUN4QixNQUFNLElBQUksS0FBSyxDQUFDLGdGQUFnRixDQUFDLENBQUM7YUFDbkc7WUFFRCxPQUFPO2dCQUNMLEtBQUs7Z0JBQ0wsV0FBVyxFQUFFLE1BQU0sQ0FBQyxXQUFXO2dCQUMvQixZQUFZO2dCQUNaLE1BQU0sRUFBRSxLQUFLO2dCQUNiLGNBQWMsRUFBRSxnQkFBQyxDQUFDLFVBQVUsQ0FBQyxjQUFjLENBQUM7YUFDN0MsQ0FBQzs7S0FDSDtDQUVGO0FBM0dELGlDQTJHQyJ9

View File

@ -1,34 +0,0 @@
export interface ICredentials {
AccountID?: string;
AccessKeyID?: string;
AccessKeySecret?: string;
SecurityToken?: string;
}
export interface InputProps {
props?: IProperties;
credentials: ICredentials;
appName: string;
project: {
component: string;
access: string;
projectName: string;
};
command: string;
args: string;
path: {
configPath: string;
};
}
export interface IProperties {
region: string;
serviceName: string;
functionName: string;
qualifier?: string;
domainName?: string;
}
export declare function isProperties(args: any): args is IProperties;
export interface IEventPayload {
event?: string;
eventFile?: string;
eventStdin?: boolean;
}

View File

@ -1,11 +0,0 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.isProperties = void 0;
function isProperties(args) {
if (!args) {
return false;
}
return args.domainName || (args.region && args.serviceName && args.functionName);
}
exports.isProperties = isProperties;
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiZW50aXR5LmpzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vLi4vc3JjL2ludGVyZmFjZS9lbnRpdHkudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6Ijs7O0FBOEJBLFNBQWdCLFlBQVksQ0FBQyxJQUFTO0lBQ3BDLElBQUksQ0FBQyxJQUFJLEVBQUU7UUFDVCxPQUFPLEtBQUssQ0FBQztLQUNkO0lBQ0QsT0FBTyxJQUFJLENBQUMsVUFBVSxJQUFJLENBQUMsSUFBSSxDQUFDLE1BQU0sSUFBSSxJQUFJLENBQUMsV0FBVyxJQUFJLElBQUksQ0FBQyxZQUFZLENBQUMsQ0FBRTtBQUNwRixDQUFDO0FBTEQsb0NBS0MifQ==

5
lib/lib/client.d.ts vendored
View File

@ -1,5 +0,0 @@
import { ICredentials } from '../interface/entity';
export default class Client {
static buildFcClient(region: string, credentials: ICredentials): Promise<any>;
private static getFcEndpoint;
}

View File

@ -1,62 +0,0 @@
"use strict";
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
}) : (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
o[k2] = m[k];
}));
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
Object.defineProperty(o, "default", { enumerable: true, value: v });
}) : function(o, v) {
o["default"] = v;
});
var __importStar = (this && this.__importStar) || function (mod) {
if (mod && mod.__esModule) return mod;
var result = {};
if (mod != null) for (var k in mod) if (k !== "default" && Object.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
__setModuleDefault(result, mod);
return result;
};
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
return new (P || (P = Promise))(function (resolve, reject) {
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
step((generator = generator.apply(thisArg, _arguments || [])).next());
});
};
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
const fc2_1 = __importDefault(require("@alicloud/fc2"));
const core = __importStar(require("@serverless-devs/core"));
class Client {
static buildFcClient(region, credentials) {
return __awaiter(this, void 0, void 0, function* () {
return new fc2_1.default(credentials.AccountID, {
accessKeyID: credentials.AccessKeyID,
accessKeySecret: credentials.AccessKeySecret,
securityToken: credentials.SecurityToken,
region,
endpoint: yield this.getFcEndpoint(),
timeout: 6000000,
});
});
}
static getFcEndpoint() {
return __awaiter(this, void 0, void 0, function* () {
const fcDefault = yield core.loadComponent('devsapp/fc-default');
const fcEndpoint = yield fcDefault.get({ args: 'fc-endpoint' });
if (!fcEndpoint) {
return undefined;
}
const enableFcEndpoint = yield fcDefault.get({ args: 'enable-fc-endpoint' });
return (enableFcEndpoint === true || enableFcEndpoint === 'true') ? fcEndpoint : undefined;
});
}
}
exports.default = Client;
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiY2xpZW50LmpzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vLi4vc3JjL2xpYi9jbGllbnQudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6Ijs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7O0FBQUEsd0RBQStCO0FBQy9CLDREQUE4QztBQUc5QyxNQUFxQixNQUFNO0lBQ3pCLE1BQU0sQ0FBTyxhQUFhLENBQUMsTUFBYyxFQUFFLFdBQXlCOztZQUNsRSxPQUFPLElBQUksYUFBRSxDQUFDLFdBQVcsQ0FBQyxTQUFTLEVBQUU7Z0JBQ25DLFdBQVcsRUFBRSxXQUFXLENBQUMsV0FBVztnQkFDcEMsZUFBZSxFQUFFLFdBQVcsQ0FBQyxlQUFlO2dCQUM1QyxhQUFhLEVBQUUsV0FBVyxDQUFDLGFBQWE7Z0JBQ3hDLE1BQU07Z0JBQ04sUUFBUSxFQUFFLE1BQU0sSUFBSSxDQUFDLGFBQWEsRUFBRTtnQkFDcEMsT0FBTyxFQUFFLE9BQU87YUFDakIsQ0FBQyxDQUFBO1FBQ0osQ0FBQztLQUFBO0lBRU8sTUFBTSxDQUFPLGFBQWE7O1lBQ2hDLE1BQU0sU0FBUyxHQUFHLE1BQU0sSUFBSSxDQUFDLGFBQWEsQ0FBQyxvQkFBb0IsQ0FBQyxDQUFDO1lBQ2pFLE1BQU0sVUFBVSxHQUFXLE1BQU0sU0FBUyxDQUFDLEdBQUcsQ0FBQyxFQUFFLElBQUksRUFBRSxhQUFhLEVBQUUsQ0FBQyxDQUFDO1lBQ3hFLElBQUksQ0FBQyxVQUFVLEVBQUU7Z0JBQUUsT0FBTyxTQUFTLENBQUM7YUFBRTtZQUN0QyxNQUFNLGdCQUFnQixHQUFRLE1BQU0sU0FBUyxDQUFDLEdBQUcsQ0FBQyxFQUFFLElBQUksRUFBRSxvQkFBb0IsRUFBRSxDQUFDLENBQUM7WUFDbEYsT0FBTyxDQUFDLGdCQUFnQixLQUFLLElBQUksSUFBSSxnQkFBZ0IsS0FBSyxNQUFNLENBQUMsQ0FBQyxDQUFDLENBQUMsVUFBVSxDQUFDLENBQUMsQ0FBQyxTQUFTLENBQUM7UUFDN0YsQ0FBQztLQUFBO0NBQ0Y7QUFuQkQseUJBbUJDIn0=

4
lib/lib/event.d.ts vendored
View File

@ -1,4 +0,0 @@
export default class File {
static getEvent(eventFile: any): Promise<unknown>;
static eventPriority(eventPriority: any): Promise<any>;
}

View File

@ -1,68 +0,0 @@
"use strict";
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
return new (P || (P = Promise))(function (resolve, reject) {
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
step((generator = generator.apply(thisArg, _arguments || [])).next());
});
};
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
const path_1 = __importDefault(require("path"));
const fs_extra_1 = __importDefault(require("fs-extra"));
const lodash_1 = require("lodash");
const readline_1 = __importDefault(require("readline"));
const logger_1 = __importDefault(require("../common/logger"));
const stdin_1 = require("./stdin");
class File {
static getEvent(eventFile) {
return __awaiter(this, void 0, void 0, function* () {
let event = yield stdin_1.getStdin(); // read from pipes
if (!eventFile)
return event;
return yield new Promise((resolve, reject) => {
let input;
if (eventFile === '-') { // read from stdin
logger_1.default.log('Reading event data from stdin, which can be ended with Enter then Ctrl+D');
input = process.stdin;
}
else {
input = fs_extra_1.default.createReadStream(eventFile, {
encoding: 'utf-8'
});
}
const rl = readline_1.default.createInterface({
input,
output: process.stdout
});
event = '';
rl.on('line', (line) => {
event += line;
});
rl.on('close', () => resolve(event));
rl.on('SIGINT', () => reject(new Error('^C')));
});
});
}
static eventPriority(eventPriority) {
return __awaiter(this, void 0, void 0, function* () {
let eventFile;
if (lodash_1.isString(eventPriority.event)) {
return eventPriority.event;
}
else if (eventPriority.eventStdin) {
eventFile = '-';
}
else if (eventPriority.eventFile) {
eventFile = path_1.default.resolve(process.cwd(), eventPriority.eventFile);
}
return yield this.getEvent(eventFile);
});
}
}
exports.default = File;
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiZXZlbnQuanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi9zcmMvbGliL2V2ZW50LnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiI7Ozs7Ozs7Ozs7Ozs7O0FBQUEsZ0RBQXdCO0FBQ3hCLHdEQUEwQjtBQUMxQixtQ0FBa0M7QUFDbEMsd0RBQWdDO0FBQ2hDLDhEQUFzQztBQUN0QyxtQ0FBbUM7QUFFbkMsTUFBcUIsSUFBSTtJQUV2QixNQUFNLENBQU8sUUFBUSxDQUFDLFNBQVM7O1lBQzdCLElBQUksS0FBSyxHQUFHLE1BQU0sZ0JBQVEsRUFBRSxDQUFDLENBQUMsa0JBQWtCO1lBRWhELElBQUksQ0FBQyxTQUFTO2dCQUFFLE9BQU8sS0FBSyxDQUFDO1lBRTdCLE9BQU8sTUFBTSxJQUFJLE9BQU8sQ0FBQyxDQUFDLE9BQU8sRUFBRSxNQUFNLEVBQUUsRUFBRTtnQkFDM0MsSUFBSSxLQUFLLENBQUM7Z0JBRVYsSUFBSSxTQUFTLEtBQUssR0FBRyxFQUFFLEVBQUUsa0JBQWtCO29CQUN6QyxnQkFBTSxDQUFDLEdBQUcsQ0FBQywwRUFBMEUsQ0FBQyxDQUFBO29CQUN0RixLQUFLLEdBQUcsT0FBTyxDQUFDLEtBQUssQ0FBQztpQkFDdkI7cUJBQU07b0JBQ0wsS0FBSyxHQUFHLGtCQUFFLENBQUMsZ0JBQWdCLENBQUMsU0FBUyxFQUFFO3dCQUNyQyxRQUFRLEVBQUUsT0FBTztxQkFDbEIsQ0FBQyxDQUFBO2lCQUNIO2dCQUNELE1BQU0sRUFBRSxHQUFHLGtCQUFRLENBQUMsZUFBZSxDQUFDO29CQUNsQyxLQUFLO29CQUNMLE1BQU0sRUFBRSxPQUFPLENBQUMsTUFBTTtpQkFDdkIsQ0FBQyxDQUFBO2dCQUVGLEtBQUssR0FBRyxFQUFFLENBQUM7Z0JBQ1gsRUFBRSxDQUFDLEVBQUUsQ0FBQyxNQUFNLEVBQUUsQ0FBQyxJQUFJLEVBQUUsRUFBRTtvQkFDckIsS0FBSyxJQUFJLElBQUksQ0FBQTtnQkFDZixDQUFDLENBQUMsQ0FBQTtnQkFDRixFQUFFLENBQUMsRUFBRSxDQUFDLE9BQU8sRUFBRSxHQUFHLEVBQUUsQ0FBQyxPQUFPLENBQUMsS0FBSyxDQUFDLENBQUMsQ0FBQTtnQkFFcEMsRUFBRSxDQUFDLEVBQUUsQ0FBQyxRQUFRLEVBQUUsR0FBRyxFQUFFLENBQUMsTUFBTSxDQUFDLElBQUksS0FBSyxDQUFDLElBQUksQ0FBQyxDQUFDLENBQUMsQ0FBQTtZQUNoRCxDQUFDLENBQUMsQ0FBQTtRQUNKLENBQUM7S0FBQTtJQUVELE1BQU0sQ0FBTyxhQUFhLENBQUMsYUFBYTs7WUFDdEMsSUFBSSxTQUFpQixDQUFDO1lBRXRCLElBQUksaUJBQVEsQ0FBQyxhQUFhLENBQUMsS0FBSyxDQUFDLEVBQUU7Z0JBQ2pDLE9BQU8sYUFBYSxDQUFDLEtBQUssQ0FBQzthQUM1QjtpQkFBTSxJQUFJLGFBQWEsQ0FBQyxVQUFVLEVBQUU7Z0JBQ25DLFNBQVMsR0FBRyxHQUFHLENBQUM7YUFDakI7aUJBQU0sSUFBSSxhQUFhLENBQUMsU0FBUyxFQUFFO2dCQUNsQyxTQUFTLEdBQUcsY0FBSSxDQUFDLE9BQU8sQ0FBQyxPQUFPLENBQUMsR0FBRyxFQUFFLEVBQUUsYUFBYSxDQUFDLFNBQVMsQ0FBQyxDQUFDO2FBQ2xFO1lBRUQsT0FBTyxNQUFNLElBQUksQ0FBQyxRQUFRLENBQUMsU0FBUyxDQUFDLENBQUE7UUFDdkMsQ0FBQztLQUFBO0NBQ0Y7QUE5Q0QsdUJBOENDIn0=

View File

@ -1,39 +0,0 @@
import { IProperties, IEventPayload } from '../interface/entity';
export default class RemoteInvoke {
fcClient: any;
accountId: string;
constructor(fcClient: any, accountId: string);
invoke(props: IProperties, eventPayload: IEventPayload, { invocationType }: {
invocationType: any;
}): Promise<void>;
requestDomain(url: string, event: string): Promise<void>;
getHttpTrigger(serviceName: any, functionName: any): Promise<any>;
eventInvoke({ serviceName, functionName, event, qualifier, invocationType }: {
serviceName: any;
functionName: any;
event: any;
qualifier?: string;
invocationType: any;
}): Promise<void>;
httpInvoke({ region, serviceName, functionName, event, qualifier }: {
region: any;
serviceName: any;
functionName: any;
event: any;
qualifier: any;
}): Promise<void>;
/**
* @param event: { body, headers, method, queries, path }
* path /proxy/serviceName/functionName/path ,
*/
request(event: any): Promise<void>;
handlerHttpParmase(event: any): {
headers: any;
queries: any;
method: any;
path: any;
body: any;
};
private showLog;
private getJsonEvent;
}

File diff suppressed because one or more lines are too long

5
lib/lib/stdin.d.ts vendored
View File

@ -1,5 +0,0 @@
/// <reference types="node" />
export declare function getStdin(): Promise<string>;
export declare namespace getStdin {
var buffer: () => Promise<Buffer>;
}

View File

@ -1,69 +0,0 @@
"use strict";
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
return new (P || (P = Promise))(function (resolve, reject) {
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
step((generator = generator.apply(thisArg, _arguments || [])).next());
});
};
var __asyncValues = (this && this.__asyncValues) || function (o) {
if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined.");
var m = o[Symbol.asyncIterator], i;
return m ? m.call(o) : (o = typeof __values === "function" ? __values(o) : o[Symbol.iterator](), i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function () { return this; }, i);
function verb(n) { i[n] = o[n] && function (v) { return new Promise(function (resolve, reject) { v = o[n](v), settle(resolve, reject, v.done, v.value); }); }; }
function settle(resolve, reject, d, v) { Promise.resolve(v).then(function(v) { resolve({ value: v, done: d }); }, reject); }
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.getStdin = void 0;
const { stdin } = process;
function getStdin() {
var e_1, _a;
return __awaiter(this, void 0, void 0, function* () {
let result = '';
if (stdin.isTTY) {
return result;
}
stdin.setEncoding('utf8');
try {
for (var stdin_1 = __asyncValues(stdin), stdin_1_1; stdin_1_1 = yield stdin_1.next(), !stdin_1_1.done;) {
const chunk = stdin_1_1.value;
result += chunk;
}
}
catch (e_1_1) { e_1 = { error: e_1_1 }; }
finally {
try {
if (stdin_1_1 && !stdin_1_1.done && (_a = stdin_1.return)) yield _a.call(stdin_1);
}
finally { if (e_1) throw e_1.error; }
}
return result;
});
}
exports.getStdin = getStdin;
getStdin.buffer = () => __awaiter(void 0, void 0, void 0, function* () {
var e_2, _a;
const result = [];
let length = 0;
if (stdin.isTTY) {
return Buffer.concat([]);
}
try {
for (var stdin_2 = __asyncValues(stdin), stdin_2_1; stdin_2_1 = yield stdin_2.next(), !stdin_2_1.done;) {
const chunk = stdin_2_1.value;
result.push(chunk);
length += chunk.length;
}
}
catch (e_2_1) { e_2 = { error: e_2_1 }; }
finally {
try {
if (stdin_2_1 && !stdin_2_1.done && (_a = stdin_2.return)) yield _a.call(stdin_2);
}
finally { if (e_2) throw e_2.error; }
}
return Buffer.concat(result, length);
});
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoic3RkaW4uanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi9zcmMvbGliL3N0ZGluLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiI7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7QUFBQSxNQUFNLEVBQUMsS0FBSyxFQUFDLEdBQUcsT0FBTyxDQUFDO0FBRXhCLFNBQXNCLFFBQVE7OztRQUM3QixJQUFJLE1BQU0sR0FBRyxFQUFFLENBQUM7UUFFaEIsSUFBSSxLQUFLLENBQUMsS0FBSyxFQUFFO1lBQ2hCLE9BQU8sTUFBTSxDQUFDO1NBQ2Q7UUFFRCxLQUFLLENBQUMsV0FBVyxDQUFDLE1BQU0sQ0FBQyxDQUFDOztZQUUxQixLQUEwQixJQUFBLFVBQUEsY0FBQSxLQUFLLENBQUEsV0FBQTtnQkFBcEIsTUFBTSxLQUFLLGtCQUFBLENBQUE7Z0JBQ3JCLE1BQU0sSUFBSSxLQUFLLENBQUM7YUFDaEI7Ozs7Ozs7OztRQUVELE9BQU8sTUFBTSxDQUFDOztDQUNkO0FBZEQsNEJBY0M7QUFFRCxRQUFRLENBQUMsTUFBTSxHQUFHLEdBQVMsRUFBRTs7SUFDNUIsTUFBTSxNQUFNLEdBQUcsRUFBRSxDQUFDO0lBQ2xCLElBQUksTUFBTSxHQUFHLENBQUMsQ0FBQztJQUVmLElBQUksS0FBSyxDQUFDLEtBQUssRUFBRTtRQUNoQixPQUFPLE1BQU0sQ0FBQyxNQUFNLENBQUMsRUFBRSxDQUFDLENBQUM7S0FDekI7O1FBRUQsS0FBMEIsSUFBQSxVQUFBLGNBQUEsS0FBSyxDQUFBLFdBQUE7WUFBcEIsTUFBTSxLQUFLLGtCQUFBLENBQUE7WUFDckIsTUFBTSxDQUFDLElBQUksQ0FBQyxLQUFLLENBQUMsQ0FBQztZQUNuQixNQUFNLElBQUksS0FBSyxDQUFDLE1BQU0sQ0FBQztTQUN2Qjs7Ozs7Ozs7O0lBRUQsT0FBTyxNQUFNLENBQUMsTUFBTSxDQUFDLE1BQU0sRUFBRSxNQUFNLENBQUMsQ0FBQztBQUN0QyxDQUFDLENBQUEsQ0FBQyJ9

View File

@ -1,35 +0,0 @@
{
"deploy test": "部署测试",
"input args: -h -h": "input args: -h -h",
"command parse: {\"_\":[],\"help\":true,\"h\":true,\"event-stdin\":false,\"s\":false}": "command parse: {\"_\":[],\"help\":true,\"h\":true,\"event-stdin\":false,\"s\":false}",
"input args: -h --debug -h": "input args: -h --debug -h",
"command parse: {\"_\":[],\"help\":true,\"h\":true,\"event-stdin\":false,\"s\":false,\"debug\":true}": "command parse: {\"_\":[],\"help\":true,\"h\":true,\"event-stdin\":false,\"s\":false,\"debug\":true}",
"input args: --help": "input args: --help",
"input args: --invocation-type async": "input args: --invocation-type async",
"command parse: {\"_\":[],\"help\":false,\"h\":false,\"event-stdin\":false,\"s\":false,\"invocation-type\":\"async\",\"t\":\"async\"}": "command parse: {\"_\":[],\"help\":false,\"h\":false,\"event-stdin\":false,\"s\":false,\"invocation-type\":\"async\",\"t\":\"async\"}",
"input props: {\"region\":\"cn-shenzhen\",\"serviceName\":\"guide\",\"functionName\":\"guide-hello_world-nodejs12\"}": "input props: {\"region\":\"cn-shenzhen\",\"serviceName\":\"guide\",\"functionName\":\"guide-hello_world-nodejs12\"}",
"input args props: {}": "input args props: {}",
"props: {\"region\":\"cn-shenzhen\",\"serviceName\":\"guide\",\"functionName\":\"guide-hello_world-nodejs12\"}": "props: {\"region\":\"cn-shenzhen\",\"serviceName\":\"guide\",\"functionName\":\"guide-hello_world-nodejs12\"}",
"event: ": "event: ",
"get listTriggers: {\"triggers\":[]}": "get listTriggers: {\"triggers\":[]}",
"guide/guide-hello_world-nodejs12 async invoke success.\n": "guide/guide-hello_world-nodejs12 async invoke success.\n",
"guide/guide-hello_world-nodejs12 async invoke success.\n request id: c30c8868-333e-4bd1-ab33-8ed5ef74873f": "guide/guide-hello_world-nodejs12 async invoke success.\n request id: c30c8868-333e-4bd1-ab33-8ed5ef74873f",
"guide/guide-hello_world-nodejs12 async invoke success.\nrequest id: d4dde5e2-236f-4572-9f15-58adac0d5ed1": "guide/guide-hello_world-nodejs12 async invoke success.\nrequest id: d4dde5e2-236f-4572-9f15-58adac0d5ed1",
"guide/guide-hello_world-nodejs12 async invoke success.\nrequest id: 27872d4f-44aa-4b4c-8deb-3a1295965791\n": "guide/guide-hello_world-nodejs12 async invoke success.\nrequest id: 27872d4f-44aa-4b4c-8deb-3a1295965791\n",
"\nguide/guide-hello_world-nodejs12 async invoke success.\nrequest id: f1798899-985a-4d02-9556-d0882d0d6ccf\n": "\nguide/guide-hello_world-nodejs12 async invoke success.\nrequest id: f1798899-985a-4d02-9556-d0882d0d6ccf\n",
"input args: ": "input args: ",
"command parse: {}": "command parse: {}",
"input props: {\"region\":\"cn-shenzhen\",\"serviceName\":\"guide\",\"functionName\":\"hhh\"}": "input props: {\"region\":\"cn-shenzhen\",\"serviceName\":\"guide\",\"functionName\":\"hhh\"}",
"input args props: {\"region\":\"cn-shenzhen\",\"serviceName\":\"guide\",\"functionName\":\"hhh\"}": "input args props: {\"region\":\"cn-shenzhen\",\"serviceName\":\"guide\",\"functionName\":\"hhh\"}",
"get listTriggers: {\"triggers\":[{\"triggerName\":\"defaultTrigger\",\"description\":\"\",\"triggerId\":\"0c824580-2f4f-4c88-b45c-f953bc71181a\",\"sourceArn\":null,\"triggerType\":\"http\",\"invocationRole\":null,\"qualifier\":null,\"triggerConfig\":{\"methods\":[\"GET\",\"POST\"],\"authType\":\"anonymous\"},\"createdTime\":\"2021-04-02T07:34:07Z\",\"lastModifiedTime\":\"2021-07-16T08:47:37Z\"}]}": "get listTriggers: {\"triggers\":[{\"triggerName\":\"defaultTrigger\",\"description\":\"\",\"triggerId\":\"0c824580-2f4f-4c88-b45c-f953bc71181a\",\"sourceArn\":null,\"triggerType\":\"http\",\"invocationRole\":null,\"qualifier\":null,\"triggerConfig\":{\"methods\":[\"GET\",\"POST\"],\"authType\":\"anonymous\"},\"createdTime\":\"2021-04-02T07:34:07Z\",\"lastModifiedTime\":\"2021-07-16T08:47:37Z\"}]}",
"https://1899690531354629.cn-shenzhen.fc.aliyuncs.com/2016-08-15/proxy/guide/hhh/": "https://1899690531354629.cn-shenzhen.fc.aliyuncs.com/2016-08-15/proxy/guide/hhh/",
"method is GET.": "method is GET.",
"start invoke.": "start invoke.",
"end invoke.": "end invoke.",
"========= FC invoke Logs begin =========": "========= FC invoke Logs begin =========",
"FC Invoke Start RequestId: 56c854f8-b34c-4a2a-a578-64ea26ea022b\r\nload code for handler:index.handler\r\nFC Invoke End RequestId: 56c854f8-b34c-4a2a-a578-64ea26ea022b\r\n\nDuration: 24.77 ms, Billed Duration: 25 ms, Memory Size: 128 MB, Max Memory Used: 49.52 MB": "FC Invoke Start RequestId: 56c854f8-b34c-4a2a-a578-64ea26ea022b\r\nload code for handler:index.handler\r\nFC Invoke End RequestId: 56c854f8-b34c-4a2a-a578-64ea26ea022b\r\n\nDuration: 24.77 ms, Billed Duration: 25 ms, Memory Size: 128 MB, Max Memory Used: 49.52 MB",
"========= FC invoke Logs end =========": "========= FC invoke Logs end =========",
"\nFC Invoke Result:": "\nFC Invoke Result:",
"input args props: {\"region\":\"cn-shenzhen\",\"serviceName\":\"guide\",\"functionName\":\"guide-hello_world-nodejs12\"}": "input args props: {\"region\":\"cn-shenzhen\",\"serviceName\":\"guide\",\"functionName\":\"guide-hello_world-nodejs12\"}",
"FC Invoke Start RequestId: 59635ac4-38ab-48e2-a7fe-c56e435e46ee\r\nload code for handler:index.handler\r\n2021-07-29T01:40:22.922Z 59635ac4-38ab-48e2-a7fe-c56e435e46ee [verbose] \r\nFC Invoke End RequestId: 59635ac4-38ab-48e2-a7fe-c56e435e46ee\r\n\nDuration: 14.06 ms, Billed Duration: 15 ms, Memory Size: 128 MB, Max Memory Used: 49.02 MB": "FC Invoke Start RequestId: 59635ac4-38ab-48e2-a7fe-c56e435e46ee\r\nload code for handler:index.handler\r\n2021-07-29T01:40:22.922Z 59635ac4-38ab-48e2-a7fe-c56e435e46ee [verbose] \r\nFC Invoke End RequestId: 59635ac4-38ab-48e2-a7fe-c56e435e46ee\r\n\nDuration: 14.06 ms, Billed Duration: 15 ms, Memory Size: 128 MB, Max Memory Used: 49.02 MB"
}

View File

@ -1,4 +0,0 @@
{
"deploy test": "部署测试"
}

View File

@ -1,6 +1,6 @@
{
"name": "fc-remote-invoke",
"version": "0.0.14",
"version": "0.0.23",
"description": "This is a component demo for Serverless Devs Tool ",
"keywords": [
"Serverless",
@ -13,7 +13,7 @@
"author": "Serverless-Devs",
"contributors": [],
"license": "MIT",
"main": "./lib/index.js",
"main": "./dist/index.js",
"publishConfig": {
"access": "public"
},
@ -24,20 +24,20 @@
"scripts": {
"start": "npm run watch",
"watch": "tsc -w",
"publish": "npm run build && s cli platform publish",
"build": "npm run doc && tsc",
"postbuild": "npm run doc",
"doc": "npx typedoc src/index.ts --json doc/doc.json --out doc"
"prebuild": "rm -rf node_modules && rm -rf package-lock.json && npm i && rimraf dist",
"esbuild": "esbuild src/index.ts --bundle --log-level=error --minify --platform=node --format=cjs --target=node10.4 --external:@serverless-devs/core --outfile=dist/index.js",
"build": "npm run esbuild"
},
"dependencies": {
"@alicloud/fc2": "^2.2.2",
"@serverless-devs/core": "^0.0.*",
"@serverless-devs/core": "latest",
"form-data": "^4.0.0",
"fs-extra": "^10.0.0",
"got": "^11.8.2",
"i18n": "^0.13.2",
"lodash": "^4.17.21",
"qs": "^6.10.1",
"readline": "^1.3.0"
},
"autoInstall": false,
"devDependencies": {
"@types/lodash": "^4.14.168",
"@types/node": "^14.0.23",
@ -46,6 +46,7 @@
"eslint": "^7.7.0",
"ts-node": "^8.10.2",
"typedoc": "^0.20.35",
"typescript": "^3.9.7"
"typescript": "^3.9.7",
"esbuild": "^0.14.0"
}
}

View File

@ -2,9 +2,9 @@ Type: Component
Name: fc-remote-invoke
Provider:
- 其它
Version: 0.0.14
Version: 0.0.23
Description: 初始化component模板
HomePage: https://www.serverless-devs.com
Tags: #标签详情
- 模板
Category: 其它
Category: 其它

View File

@ -75,9 +75,9 @@ export default [
content: [
'$ s invoke',
'$ s <ProjectName> invoke',
'$ s exec -- invoke --invocation-type sync --event <payload>',
'$ s exec -- invoke --event-file <file-path>',
'$ s exec -- invoke --event-stdin',
'$ s invoke --invocation-type sync --event <payload>',
'$ s invoke --event-file <file-path>',
'$ s invoke --event-stdin',
],
},
{

View File

@ -1,43 +0,0 @@
import os from 'os';
import fs from 'fs';
import path from 'path';
import yaml from 'js-yaml';
import { I18n } from 'i18n';
export function getConfig(key: string): any {
const profile = getProfileFile();
return profile[key];
}
export function getProfileFile() {
let profileResult = {}
try {
const profileFilePath = getDefaultProfilePath();
profileResult = yaml.load(fs.readFileSync(profileFilePath, 'utf8')) || {};
} catch (e) {
console.log(e);
}
return profileResult;
}
export function getDefaultProfilePath(): string {
return path.join(os.homedir(), '.s', 'set-config.yml');
}
const i18n = new I18n({
locales: ['en', 'zh'],
directory: path.join(__dirname, '..', '..', 'locales'),
});
const locale = getConfig('locale');
if (locale) {
i18n.setLocale(locale);
} else {
i18n.setLocale('en');
}
export default i18n;

View File

@ -1,5 +1,4 @@
import i18n from './i18n';
import { Logger } from '@serverless-devs/core';
export default class ComponentLogger {
@ -8,26 +7,26 @@ export default class ComponentLogger {
ComponentLogger.CONTENT = content;
}
static log(m, color?: 'black' | 'red' | 'green' | 'yellow' | 'blue' | 'magenta' | 'cyan' | 'white' | 'whiteBright' | 'gray') {
Logger.log(i18n.__(m) || m, color);
Logger.log(m, color);
}
static info(m) {
Logger.info(ComponentLogger.CONTENT, i18n.__(m) || m);
Logger.info(ComponentLogger.CONTENT, m);
}
static debug(m) {
Logger.debug(ComponentLogger.CONTENT, i18n.__(m) || m);
Logger.debug(ComponentLogger.CONTENT, m);
}
static error(m) {
Logger.error(ComponentLogger.CONTENT, i18n.__(m) || m);
Logger.error(ComponentLogger.CONTENT, m);
}
static warning(m) {
Logger.warn(ComponentLogger.CONTENT, i18n.__(m) || m);
Logger.warn(ComponentLogger.CONTENT, m);
}
static success(m) {
Logger.log(i18n.__(m) || m, 'green');
Logger.log(m, 'green');
}
}

View File

@ -5,7 +5,6 @@ import HELP from './common/help';
import { InputProps, isProperties, IProperties } from './interface/entity';
// import StdoutFormatter from './common/stdout-formatter';
import RemoteInvoke from './lib/remote-invoke';
import Client from './lib/client';
export default class FcRemoteInvoke {
/**
@ -16,10 +15,12 @@ export default class FcRemoteInvoke {
async invoke(inputs: InputProps): Promise<any> {
const {
props,
timeout,
eventPayload,
credentials,
isHelp,
invocationType,
statefulAsyncInvocationId,
} = await this.handlerInputs(inputs);
await this.report('fc-remote-invoke', 'invoke', credentials?.AccountID);
@ -30,10 +31,11 @@ export default class FcRemoteInvoke {
let fcClient;
if (!props.domainName) {
fcClient = await Client.buildFcClient(props.region, credentials);
const fcCommon = await core.loadComponent('devsapp/fc-common');
fcClient = await fcCommon.makeFcClient({ ...inputs, props: { region: props.region, timeout }});
}
const remoteInvoke = new RemoteInvoke(fcClient, credentials.AccountID);
await remoteInvoke.invoke(props, eventPayload, { invocationType });
await remoteInvoke.invoke(props, eventPayload, { invocationType, statefulAsyncInvocationId });
}
private async report(componentName: string, command: string, accountID: string): Promise<void> {
@ -50,11 +52,13 @@ export default class FcRemoteInvoke {
const parsedArgs: {[key: string]: any} = core.commandParse({ ...inputs, args }, {
boolean: ['help', 'event-stdin'],
string: ['invocation-type', 'event', 'event-file', 'region', 'domain-name','service-name', 'function-name', 'qualifier'],
number: ['timeout'],
string: ['invocation-type', 'event', 'event-file', 'region', 'domain-name','service-name', 'function-name', 'qualifier', 'stateful-async-invocation-id'],
alias: {
'help': 'h',
'event': 'e',
'event-file': 'f',
'event-stdin': 's',
}
});
@ -73,6 +77,7 @@ export default class FcRemoteInvoke {
'event-stdin': eventStdin,
'invocation-type': invocationType = 'sync',
'domain-name': domainName,
'stateful-async-invocation-id': statefulAsyncInvocationId,
} = argsData;
const eventPayload = { event, eventFile, eventStdin };
// @ts-ignore: 判断三个值有几个真
@ -105,12 +110,25 @@ export default class FcRemoteInvoke {
throw new Error('region/serviceName(service-name)/functionName(function-name) can not be empty.');
}
// 超时时间获取的原理https://github.com/devsapp/fc/issues/480
const propsTimeout = argsData.timeout || inputs.props?.timeout;
let timeout = 600;
if (_.isNumber(propsTimeout)) {
if (_.isEmpty(inputs.props?.runtime) || inputs.props?.runtime === 'custom-container') {
timeout = propsTimeout + 7 * 60;
} else {
timeout = propsTimeout + 2 * 60;
}
}
return {
props,
timeout,
credentials: inputs.credentials,
eventPayload,
isHelp: false,
invocationType: _.upperFirst(invocationType),
statefulAsyncInvocationId,
};
}

View File

@ -25,8 +25,10 @@ export interface IProperties {
region: string;
serviceName: string;
functionName: string;
runtime?: string;
qualifier?: string;
domainName?: string;
timeout?: string;
}
export function isProperties(args: any): args is IProperties {
if (!args) {

View File

@ -1,24 +0,0 @@
import FC from '@alicloud/fc2';
import * as core from '@serverless-devs/core';
import { ICredentials } from '../interface/entity';
export default class Client {
static async buildFcClient(region: string, credentials: ICredentials) {
return new FC(credentials.AccountID, {
accessKeyID: credentials.AccessKeyID,
accessKeySecret: credentials.AccessKeySecret,
securityToken: credentials.SecurityToken,
region,
endpoint: await this.getFcEndpoint(),
timeout: 6000000,
})
}
private static async getFcEndpoint(): Promise<string | undefined> {
const fcDefault = await core.loadComponent('devsapp/fc-default');
const fcEndpoint: string = await fcDefault.get({ args: 'fc-endpoint' });
if (!fcEndpoint) { return undefined; }
const enableFcEndpoint: any = await fcDefault.get({ args: 'enable-fc-endpoint' });
return (enableFcEndpoint === true || enableFcEndpoint === 'true') ? fcEndpoint : undefined;
}
}

View File

@ -16,9 +16,10 @@ export default class File {
let input;
if (eventFile === '-') { // read from stdin
logger.log('Reading event data from stdin, which can be ended with Enter then Ctrl+D')
logger.log('Reading event data from stdin, which can be ended with Enter then Ctrl+D');
input = process.stdin;
} else {
logger.log('Reading event file content:');
input = fs.createReadStream(eventFile, {
encoding: 'utf-8'
})
@ -32,7 +33,10 @@ export default class File {
rl.on('line', (line) => {
event += line
})
rl.on('close', () => resolve(event))
rl.on('close', () => {
logger.log('');
resolve(event)
})
rl.on('SIGINT', () => reject(new Error('^C')))
})

34
src/lib/handler-body.ts Normal file
View File

@ -0,0 +1,34 @@
import _ from 'lodash';
import qs from 'qs';
import FormData from 'form-data';
export default function handlerBody(contentType: string, body: any) {
if (contentType.includes('text/') || contentType.includes('application/json') || contentType.includes('application/xml')) {
if (_.isString(body)) return body;
try {
return JSON.stringify(body);
} catch (_ex) {
return body.toString();
}
}
if (contentType.includes('application/x-www-form-urlencoded')) {
return qs.stringify(body, { indices: false });
}
if (contentType.includes('multipart/form-data')) {
const form = new FormData();
try {
const newBody = _.isObject(body) ? body : JSON.parse(body);
for (const [key, value] of Object.entries(newBody)) {
form.append(key, value);
}
return form;
} catch (_ex) {
throw new Error(`Handler body error: The request header is ${contentType}, but the request body is not an object`);
}
}
return body;
}

View File

@ -13,7 +13,7 @@ export default class RemoteInvoke {
this.accountId = accountId;
}
async invoke (props: IProperties, eventPayload: IEventPayload, { invocationType }) {
async invoke (props: IProperties, eventPayload: IEventPayload, { invocationType, statefulAsyncInvocationId }) {
const event = await Event.eventPriority(eventPayload);
logger.debug(`event: ${event}`);
@ -32,12 +32,13 @@ export default class RemoteInvoke {
const payload: any = { event, serviceName, functionName, qualifier };
if (_.isEmpty(httpTriggers)) {
payload.invocationType = invocationType;
payload.statefulAsyncInvocationId = statefulAsyncInvocationId;
payload.event = event;
await this.eventInvoke(payload);
} else {
payload.region = region;
payload.event = this.getJsonEvent(event);
await this.httpInvoke(payload);
}
}
@ -48,9 +49,9 @@ export default class RemoteInvoke {
payload.headers = {};
}
payload.headers['X-Fc-Log-Type'] = 'Tail';
const { body, headers } = await got(url, payload);
this.showLog(headers['x-fc-log-result']);
logger.log('\nFC Invoke Result:', 'green');
console.log(body);
@ -74,13 +75,15 @@ export default class RemoteInvoke {
functionName,
event,
qualifier = 'LATEST',
invocationType
invocationType,
statefulAsyncInvocationId
}) {
if (invocationType === 'Sync') {
const rs = await this.fcClient.invokeFunction(serviceName, functionName, event, {
'X-Fc-Log-Type': 'Tail',
'X-Fc-Invocation-Type': invocationType
'X-Fc-Invocation-Code-Version': 'Latest',
'X-Fc-Invocation-Type': invocationType,
}, qualifier);
this.showLog(rs.headers['x-fc-log-result']);
@ -88,8 +91,11 @@ export default class RemoteInvoke {
console.log(rs.data);
console.log('\n');
} else {
logger.debug(`Stateful async invocation id: ${statefulAsyncInvocationId}`);
const { headers } = await this.fcClient.invokeFunction(serviceName, functionName, event, {
'X-Fc-Invocation-Type': invocationType
'X-Fc-Invocation-Code-Version': 'Latest',
'X-Fc-Invocation-Type': invocationType,
'X-Fc-Stateful-Async-Invocation-Id': statefulAsyncInvocationId || "",
}, qualifier);
const rId = headers['x-fc-request-id'];
@ -101,7 +107,7 @@ export default class RemoteInvoke {
const q = qualifier ? `.${qualifier}` : '';
event.path = `/proxy/${serviceName}${q}/${functionName}/${event.path || ''}`;
logger.log(`https://${this.accountId}.${region}.fc.aliyuncs.com/2016-08-15/proxy/${serviceName}${q}/${functionName}/`);
logger.log(`Request url: https://${this.accountId}.${region}.fc.aliyuncs.com/2016-08-15/proxy/${serviceName}${q}/${functionName}/`);
await this.request(event)
}
@ -109,8 +115,14 @@ export default class RemoteInvoke {
* @param event: { body, headers, method, queries, path }
* path /proxy/serviceName/functionName/path ,
*/
async request (event) {
const { headers, queries, method, path: p, body } = this.handlerHttpParmase(event);
async request(event) {
const { headers = {}, queries, method = 'GET', path: p, body } = event;
if (!headers['X-Fc-Log-Type']) {
headers['X-Fc-Log-Type'] = 'Tail';
}
if (!headers['X-Fc-Invocation-Code-Version']) {
headers['X-Fc-Invocation-Code-Version'] = 'Latest';
}
let resp;
try {
@ -118,18 +130,17 @@ export default class RemoteInvoke {
logger.debug(`method is ${mt}.`);
logger.debug(`start invoke.`);
if (mt === 'GET') {
resp = await this.fcClient.get(p, queries, headers);
resp = await this.fcClient.costom_request('GET', p, queries, null, headers);
} else if (mt === 'POST') {
resp = await this.fcClient.post(p, body, headers, queries);
resp = await this.fcClient.costom_request('POST', p, queries, body, headers);
} else if (mt === 'PUT') {
resp = await this.fcClient.put(p, body, headers);
resp = await this.fcClient.costom_request('PUT', p, null, body, headers);
} else if (mt === 'DELETE') {
resp = await this.fcClient.request('DELETE', p, queries, null, headers);
/* else if (method.toLocaleUpperCase() === 'PATCH') {
resp = await this.fcClient.request('PATCH', p, queries, body, headers);
resp = await this.fcClient.costom_request('DELETE', p, queries, null, headers);
} else if (method.toLocaleUpperCase() === 'PATCH') {
resp = await this.fcClient.costom_request('PATCH', p, queries, body, headers);
} else if (method.toLocaleUpperCase() === 'HEAD') {
resp = await this.fcClient.request('HEAD', p, queries, body, headers);
} */
resp = await this.fcClient.costom_request('HEAD', p, queries, body, headers);
} else {
logger.error(`Does not support ${method} requests temporarily.`);
}
@ -142,47 +153,19 @@ export default class RemoteInvoke {
}
logger.debug(`end invoke.`);
if (resp) {
if (resp?.err) {
this.showLog(resp.headers['x-fc-log-result']);
logger.log('\nFC Invoke Result:', 'green');
logger.log(`\nFC Invoke Result[Code: ${resp.code}]:`, 'red');
console.log(resp.data);
console.log('\n');
}
}
} else {
if (resp) {
this.showLog(resp.headers['x-fc-log-result']);
handlerHttpParmase (event) {
const { body = '', headers = {}, method = 'GET', queries = '', path: p = '' } = event;
let postBody;
if (body) {
let buff = null;
if (Buffer.isBuffer(body)) {
buff = body;
headers['content-type'] = 'application/octet-stream';
} else if (typeof body === 'string') {
buff = Buffer.from(body, 'utf8');
headers['content-type'] = 'application/octet-stream';
} else if (typeof body.pipe === 'function') {
buff = body;
headers['content-type'] = 'application/octet-stream';
} else {
buff = Buffer.from(JSON.stringify(body), 'utf8');
headers['content-type'] = 'application/json';
logger.log(`\nFC Invoke Result[Code: ${resp.code}]:`, 'green');
console.log(resp.data);
console.log('\n');
}
postBody = buff;
}
if (!headers['X-Fc-Log-Type']) {
headers['X-Fc-Log-Type'] = 'Tail';
}
return {
headers,
queries,
method,
path: p,
body: postBody
}
}
@ -203,4 +186,4 @@ export default class RemoteInvoke {
throw new Error('handler event error. Example: https://github.com/devsapp/fc-remote-invoke/blob/master/example/http.json');
}
}
}
}

View File

@ -24,7 +24,7 @@
"./node_modules/@types"
],
"rootDir": "src",
"outDir": "lib"
"outDir": "dist"
},
"exclude": [
"**/node_modules/**",