-
Notifications
You must be signed in to change notification settings - Fork 3
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Sdmext279/read document #6
Merged
Merged
Changes from 14 commits
Commits
Show all changes
17 commits
Select commit
Hold shift + click to select a range
7222033
read document
rishikunnath2747 76ab265
return failed IDs in createDocument
rishikunnath2747 8dc02c8
Merge branch 'attachmentsusecase' into SDMEXT279/readDocument
rishikunnath2747 55ff111
Error handling for DI response
rishikunnath2747 0c086a8
unit test cases
rishikunnath2747 deb9118
Unit tests
rishikunnath2747 09f51b2
Merge branch 'attachmentsusecase' into SDMEXT279/readDocument
rishikunnath2747 d10f036
Unit tests with new db structure
rishikunnath2747 a98f30c
Merge branch 'develop' into SDMEXT279/readDocument
yashmeet29 551aa1e
Removed coverage and package-lock.json
rishikunnath2747 692bf2f
Removed create and delete code
rishikunnath2747 5859358
Removed console statements
rishikunnath2747 c6d49b4
Merged with develop
rishikunnath2747 e79c687
Merged with develop branch
rishikunnath2747 0a78d9c
removed url error
rishikunnath2747 dd134b2
Made changes and added test case
rishikunnath2747 4e77f85
Removed unused import
rishikunnath2747 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,10 @@ | ||
const config = { | ||
verbose: true, | ||
testTimeout: 100000, | ||
testMatch: ["**/test/**/**/*.test.js"], | ||
testMatch: ["**/test/**/*.test.js"], | ||
collectCoverageFrom: ["**/lib/**/*"], | ||
coveragePathIgnorePatterns: ["node_modules", "<rootDir>/lib/persistence"], | ||
coverageReporters: ["lcov", "text", "text-summary"], | ||
}; | ||
|
||
module.exports = config; | ||
module.exports = config; |
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 |
---|---|---|
@@ -1,12 +1,14 @@ | ||
const cds = require("@sap/cds/lib"); | ||
const { createAttachment, deleteAttachment } = require("../lib/handler"); | ||
const { createAttachment, deleteAttachment, readAttachment } = require("../lib/handler"); | ||
const { fetchAccessToken } = require("./util/index"); | ||
const { | ||
getDraftAttachments, | ||
getDuplicateAttachments, | ||
getURLsToDeleteFromAttachments, | ||
getURLFromAttachments | ||
} = require("../lib/persistence"); | ||
const { duplicateFileErr } = require("./util/messageConsts"); | ||
const { fileNotFoundErr } = require("./util/messageConsts"); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Please remove this import |
||
|
||
module.exports = class SDMAttachmentsService extends ( | ||
require("@cap-js/attachments/lib/basic") | ||
|
@@ -19,6 +21,21 @@ module.exports = class SDMAttachmentsService extends ( | |
return this.creds; | ||
} | ||
|
||
async get(attachments, keys) { | ||
const response = await getURLFromAttachments(keys, attachments); | ||
const token = await fetchAccessToken(this.creds); | ||
try { | ||
if (response?.url) { | ||
const Key = response.url; | ||
const content = await readAttachment(Key, token, this.creds); | ||
return content; | ||
} | ||
throw new Error("Url not found"); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. can we put this message in message constant file |
||
} catch (error) { | ||
throw new Error(fileNotFoundErr()); | ||
} | ||
} | ||
|
||
async draftSaveHandler(req) { | ||
const attachments = | ||
cds.model.definitions[req.query.target.name + ".attachments"]; | ||
|
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,2 +1,4 @@ | ||
module.exports.duplicateFileErr = (duplicateFiles) => | ||
`The files ${duplicateFiles} are already present in the repository. Please remove them from drafts, rename and try again.`; | ||
module.exports.fileNotFoundErr = (fileNotFound) => | ||
`File not found.`; |
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
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please add spaces after commas in readAttachment() & readDocument()