Skip to content
This repository has been archived by the owner on Feb 25, 2022. It is now read-only.

feat(excel): support excel spreadsheets on sharepoint sites #6

Closed
wants to merge 13 commits into from

Conversation

trieloff
Copy link
Contributor

Please ensure your pull request adheres to the following guidelines:

  • make sure to link the related issues in this description
  • when merging / squashing, make sure the fixed issue references are visible in the commits, for easy compilation of release notes

Related Issues

Thanks for contributing!

Copy link
Contributor

@tripodsan tripodsan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

better to use the graph api.

test/excel.test.js Outdated Show resolved Hide resolved
const driveItem = await drive.getDriveItemFromShareLink(url);
const xlsxbuffer = await drive.downloadDriveItem(driveItem);

const workbook = XLSX.read(xlsxbuffer, { type: 'buffer' });
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

src/matchers/excel.js Show resolved Hide resolved
test/excel.test.js Outdated Show resolved Hide resolved
package.json Outdated Show resolved Hide resolved
package.json Outdated Show resolved Hide resolved
package.json Outdated Show resolved Hide resolved
const result = await main({
__ow_path: '/https://adobe.sharepoint.com/sites/TheBlog/_layouts/15/guestaccess.aspx',
share: 'ESR1N29Z7HpCh1Zfs_0YS_gB4gVSuKyWRut-kNcHVSvkew',
email: 'helix%40adobe.com',
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what is email used for?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's not needed, but part of the share link as you copy it from the UI.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

as I said, better provide the entire sharelink as param.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't get it. The entire share link is https://adobe.sharepoint.com/sites/TheBlog/_layouts/15/guestaccess.aspx?share=ESR1N29Z7HpCh1Zfs_0YS_gB4gVSuKyWRut-kNcHVSvkew&email=helix%40adobe.com&e=rcfCT3

This gets appended to the service URL, so that the path is /https://adobe.sharepoint.com/sites/TheBlog/_layouts/15/guestaccess.aspx and the URL parameters are passed as individual parameters.

If I pass the remaining parameters as __ow_query="share=ESR1N29Z7HpCh1Zfs_0YS_gB4gVSuKyWRut-kNcHVSvkew&email=helix%40adobe.com&e=rcfCT3" I'm not gaining anything, because I now have to parse the query string – something that only occurs in testing, never in production.

Copy link
Contributor

@tripodsan tripodsan Mar 26, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

my problem is, that your sharelink argument is distributed as path and query params. this is inconsistent and pollutes the action params. I would do:

...data-embed@v1?share=https://adobe.sharepoint.com/sites/TheBlog/_layouts/15/guestaccess.aspx%21share=ESR1N29Z7HpCh1Zfs_0YS_gB4gVSuKyWRut-kNcHVSvkew%22email=helix%40adobe.com%22e=rcfCT

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd rather keep it the way it is, so that helix-embed and helix-data-embed have the same API (just append the full URL)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don' think this is good. if the url would be url-encoded, i would be marginally better.
you already see from your code, that you need to reconstruct the share link based on the path and some params...and you always need to rely on the exact format of the link.

what if MS or google decides to add a new query param to the sharelink?

test/excel.test.js Outdated Show resolved Hide resolved
trieloff and others added 2 commits March 26, 2020 08:08
Co-Authored-By: Tobias Bocanegra <tripodsan@users.noreply.github.com>
Co-Authored-By: Tobias Bocanegra <tripodsan@users.noreply.github.com>
@github-actions
Copy link

This PR will trigger a minor release when merged.

1 similar comment
@github-actions
Copy link

This PR will trigger a minor release when merged.

Co-Authored-By: Tobias Bocanegra <tripodsan@users.noreply.github.com>
@github-actions
Copy link

This PR will trigger a minor release when merged.

@trieloff
Copy link
Contributor Author

@tripodsan I'll add Polly and suggest we merge then, as we can iterate on the minor points later.

@trieloff trieloff marked this pull request as ready for review March 26, 2020 09:37
@github-actions
Copy link

This PR will trigger a minor release when merged.

@codecov
Copy link

codecov bot commented Mar 26, 2020

Codecov Report

Merging #6 into master will not change coverage by %.
The diff coverage is 100.00%.

Impacted file tree graph

@@            Coverage Diff            @@
##            master        #6   +/-   ##
=========================================
  Coverage   100.00%   100.00%           
=========================================
  Files            3         4    +1     
  Lines           40        56   +16     
=========================================
+ Hits            40        56   +16     
Impacted Files Coverage Δ
src/embed.js 100.00% <100.00%> (ø)
src/matchers/excel.js 100.00% <100.00%> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update bec2715...83ee1cb. Read the comment docs.

@tripodsan
Copy link
Contributor

@tripodsan I'll add Polly and suggest we merge then, as we can iterate on the minor points later.

  • I would really try to use the excel API....
  • and pass the share link as param

those are not minor points....

Copy link
Contributor

@tripodsan tripodsan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  • don't abuse __ow_path as document link
  • use excel graph api

@trieloff
Copy link
Contributor Author

don't abuse __ow_path as document link

I don't think it's abuse and I don't want to break compatibility with helix-pipeline or helix-embed. In fact, the question whether to use __ow_path or not is completely orthogonal to this PR.

use excel graph API

I really don't see the benefit of using an API that has proven to be brittle when we have a working alternative. In addition, using the graph API would require more extensive mocking that is just adding dead testing code instead of verifying the functionality.

@github-actions
Copy link

This PR will trigger a minor release when merged.

@tripodsan
Copy link
Contributor

I don't think it's abuse and I don't want to break compatibility with helix-pipeline or helix-embed. In fact, the question whether to use __ow_path or not is completely orthogonal to this PR.

then, I suggest to do it better here and then fix the helix-embed model.
as you see here:

https://github.com/adobe/helix-cli/blob/706a80fb30d16cedb81944cab8eac0f801b4ecf6/test/fixtures/recordings/Integration-test-for-up-command_3614339512/up-command-delivers-correct-response-_668345128/recording.har#L40

it causes already problems. you have to admit, that using the path doesn't add benefits and only complicates the parsing.

@tripodsan
Copy link
Contributor

API that has proven to be brittle

why brittle? donwloading the file has drackbacks

  • if the excel file is large, it is slow to download
  • adding the extra dependency to parse the xls adds overhead

@github-actions
Copy link

This PR will trigger a minor release when merged.

@trieloff
Copy link
Contributor Author

The advantage of the __ow_path model is that you can simply concatenate the URLs. The occasional lack of a / does not negate that.

@github-actions
Copy link

This PR will trigger a minor release when merged.

@github-actions
Copy link

This PR will trigger a minor release when merged.

@trieloff
Copy link
Contributor Author

By the way, I find your insistence on using both the Excel Graph API and then mocking it until it doesn't expose the real-world behavior (and issues) anymore quite hard to reconcile.

I would (grudgingly) try to port it to the Graph API, but not when it means that the tests that I have are completely useless during development and won't help me troubeshoot issues with the underlying APIs.

@github-actions
Copy link

This PR will trigger a minor release when merged.

@tripodsan
Copy link
Contributor

By the way, I find your insistence on using both the Excel Graph API and then mocking it until it doesn't expose the real-world behavior (and issues) anymore quite hard to reconcile.

IMO, the unit tests should work w/o external infrastructure, especially when it relies on resources on personal shares or repositories, or requires authentication with such.

I agree, that mocking the API bears its dangers of not catching changes in that API. the mocking the API tests your code; integration tests test their code.

I would (grudgingly) try to port it to the Graph API, but not when it means that the tests that I have are completely useless during development and won't help me troubeshoot issues with the underlying APIs.

I agree. So maybe the pollyjs approach is the good inbetween solution? you can disable playback during development and record it then for faster testing?


sidenote:
Maybe it's not so relevant for this project - but for larger ones, like helix-cli or helix-pipeline, working remote with a slow (or none) internet connection is very difficult.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants