Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #926 from lowdefy/requests
Add V4 requests
- Loading branch information
Showing
104 changed files
with
1,930 additions
and
575 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file added
BIN
+7.28 KB
.yarn/cache/pino-abstract-transport-npm-0.4.0-0d0e316a28-9df1bc78e1.zip
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
{ | ||
"name": "eslint", | ||
"version": "7.27.0-sdk", | ||
"version": "8.1.0-sdk", | ||
"main": "./lib/api.js", | ||
"type": "commonjs" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
{ | ||
"name": "prettier", | ||
"version": "2.3.0-sdk", | ||
"version": "2.4.1-sdk", | ||
"main": "./index.js", | ||
"type": "commonjs" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
/* | ||
Copyright 2020-2021 Lowdefy, Inc | ||
Licensed under the Apache License, Version 2.0 (the "License"); | ||
you may not use this file except in compliance with the License. | ||
You may obtain a copy of the License at | ||
http://www.apache.org/licenses/LICENSE-2.0 | ||
Unless required by applicable law or agreed to in writing, software | ||
distributed under the License is distributed on an "AS IS" BASIS, | ||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
See the License for the specific language governing permissions and | ||
limitations under the License. | ||
*/ | ||
|
||
import { ConfigurationError } from '../../context/errors'; | ||
|
||
function authorizeRequest({ authorize, logger }, { requestConfig }) { | ||
if (!authorize(requestConfig)) { | ||
logger.warn({ authorized: false }, 'Unauthorized Request'); | ||
// Throw does not exist error to avoid leaking information that request exists to unauthorized users | ||
throw new ConfigurationError(`Request "${requestConfig.requestId}" does not exist.`); | ||
} | ||
logger.debug({ authorized: true }, 'Authorize Request'); | ||
} | ||
|
||
export default authorizeRequest; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
/* | ||
Copyright 2020-2021 Lowdefy, Inc | ||
Licensed under the Apache License, Version 2.0 (the "License"); | ||
you may not use this file except in compliance with the License. | ||
You may obtain a copy of the License at | ||
http://www.apache.org/licenses/LICENSE-2.0 | ||
Unless required by applicable law or agreed to in writing, software | ||
distributed under the License is distributed on an "AS IS" BASIS, | ||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
See the License for the specific language governing permissions and | ||
limitations under the License. | ||
*/ | ||
|
||
import { RequestError } from '../../context/errors'; | ||
|
||
async function callRequestResolver( | ||
{ logger }, | ||
{ connectionProperties, requestConfig, requestProperties, requestHandler } | ||
) { | ||
try { | ||
const response = await requestHandler.resolver({ | ||
request: requestProperties, | ||
connection: connectionProperties, | ||
}); | ||
return response; | ||
} catch (error) { | ||
const err = new RequestError(error.message); | ||
logger.debug( | ||
{ params: { id: requestConfig.requestId, type: requestConfig.type }, err }, | ||
err.message | ||
); | ||
throw err; | ||
} | ||
} | ||
|
||
export default callRequestResolver; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
/* | ||
Copyright 2020-2021 Lowdefy, Inc | ||
Licensed under the Apache License, Version 2.0 (the "License"); | ||
you may not use this file except in compliance with the License. | ||
You may obtain a copy of the License at | ||
http://www.apache.org/licenses/LICENSE-2.0 | ||
Unless required by applicable law or agreed to in writing, software | ||
distributed under the License is distributed on an "AS IS" BASIS, | ||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
See the License for the specific language governing permissions and | ||
limitations under the License. | ||
*/ | ||
import { ConfigurationError } from '../../context/errors'; | ||
|
||
function checkConnectionRead( | ||
{ logger }, | ||
{ connectionConfig, connectionProperties, requestConfig, requestHandler } | ||
) { | ||
if (requestHandler.checkRead && connectionProperties.read === false) { | ||
const err = new ConfigurationError( | ||
`Connection "${connectionConfig.connectionId}" does not allow reads.` | ||
); | ||
logger.debug( | ||
{ | ||
params: { connectionId: connectionConfig.connectionId, requestId: requestConfig.requestId }, | ||
err, | ||
}, | ||
err.message | ||
); | ||
throw err; | ||
} | ||
} | ||
|
||
export default checkConnectionRead; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
/* | ||
Copyright 2020-2021 Lowdefy, Inc | ||
Licensed under the Apache License, Version 2.0 (the "License"); | ||
you may not use this file except in compliance with the License. | ||
You may obtain a copy of the License at | ||
http://www.apache.org/licenses/LICENSE-2.0 | ||
Unless required by applicable law or agreed to in writing, software | ||
distributed under the License is distributed on an "AS IS" BASIS, | ||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
See the License for the specific language governing permissions and | ||
limitations under the License. | ||
*/ | ||
import { ConfigurationError } from '../../context/errors'; | ||
|
||
function checkConnectionWrite( | ||
{ logger }, | ||
{ connectionConfig, connectionProperties, requestConfig, requestHandler } | ||
) { | ||
if (requestHandler.checkWrite && connectionProperties.write !== true) { | ||
const err = new ConfigurationError( | ||
`Connection "${connectionConfig.connectionId}" does not allow writes.` | ||
); | ||
logger.debug( | ||
{ | ||
params: { connectionId: connectionConfig.connectionId, requestId: requestConfig.requestId }, | ||
err, | ||
}, | ||
err.message | ||
); | ||
throw err; | ||
} | ||
} | ||
|
||
export default checkConnectionWrite; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
/* | ||
Copyright 2020-2021 Lowdefy, Inc | ||
Licensed under the Apache License, Version 2.0 (the "License"); | ||
you may not use this file except in compliance with the License. | ||
You may obtain a copy of the License at | ||
http://www.apache.org/licenses/LICENSE-2.0 | ||
Unless required by applicable law or agreed to in writing, software | ||
distributed under the License is distributed on an "AS IS" BASIS, | ||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
See the License for the specific language governing permissions and | ||
limitations under the License. | ||
*/ | ||
|
||
import { NodeParser } from '@lowdefy/operators'; | ||
|
||
import { RequestError } from '../../context/errors'; | ||
|
||
async function evaluateOperators({ secrets, user }, { connectionConfig, payload, requestConfig }) { | ||
const operatorsParser = new NodeParser({ | ||
payload, | ||
secrets, | ||
user, | ||
}); | ||
await operatorsParser.init(); | ||
const { output: connectionProperties, errors: connectionErrors } = operatorsParser.parse({ | ||
input: connectionConfig.properties || {}, | ||
location: connectionConfig.connectionId, | ||
}); | ||
if (connectionErrors.length > 0) { | ||
throw new RequestError(connectionErrors[0]); | ||
} | ||
|
||
const { output: requestProperties, errors: requestErrors } = operatorsParser.parse({ | ||
input: requestConfig.properties || {}, | ||
location: requestConfig.requestId, | ||
}); | ||
if (requestErrors.length > 0) { | ||
throw new RequestError(requestErrors[0]); | ||
} | ||
|
||
return { | ||
connectionProperties, | ||
requestProperties, | ||
}; | ||
} | ||
|
||
export default evaluateOperators; |
Oops, something went wrong.