-
Notifications
You must be signed in to change notification settings - Fork 34
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
Document Record Service #274
base: main
Are you sure you want to change the base?
Conversation
src/services/document-services.ts
Outdated
@@ -0,0 +1,125 @@ | |||
import Axios, { AxiosResponse } from 'axios' |
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.
I know the FeeServices imports Axios like this but I think it's bad practice.
Consider passing the existing Axios instance in as a prop, like this:
@Prop({ required: true }) readonly axios!: any |
and
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.
The only catch i bumped into here is the interceptors from a local instance may not meet all requirements.
ie missing account-id insertion into the header etc
Work around is to create another local instance but it might also make sense to make a service or component atomic so it doesn't need to rely on that local axios etc.
Just considerations!
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.
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.
For sure
Just calling out that passing in axios vs a local Axios instance with defined interceptors matters.
If a service or component here has somewhat unique headers for it's requests, than the argument could be made to just make it atomic on this end, is all.
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.
The thing is, I might need to use these functions in any project that has doc-related components.
However, I believe we use useBcrosFetch in Nuxt applications(e.g. dashboard ui), and in that case, I need to create a new Axios instance to pass as a prop.
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.
I'm still not sure whether a local Axios instance (in your component) is desirable.
I do see the problem with the unwanted interceptor. Does it actually cause a problem?
Also, is there no auth for DRS calls?
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.
Depending on how Axios is working currently with shared components, the local axios idea might be ideal or just as fraught with issues. I'm waiting for your response on my questions above to understand this and give an informed opinion. Thx.
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.
I need to override the intercepter because we get 401 response with JWT and we use apikey for authentication.

But yes I've included axios
instance as a param for each function and I am writing unit test as requested.
Once the updated fucntions are fully test locally across create ui, edit ui, filings ui, and sbc-auth, i will make another commit and will inform you.
Thanks.
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.
Are you saying that import Axios, { AxiosResponse } from 'axios'
returns the existing instance (with interceptors), and that's why you don't need to "create" it but you do need to override the interceptor?
In a way, that's good, as it means we don't have to pass the axios instance into the component; the code above just returns it.
In a way, that's bad, because the existing instance can have interceptors, and it's really unfortunate you need to hack the UI's axios instance in order to use an external component (which, ideally, would be "atomic" as Cameron put it, or I would say "independent").
If the above is true then you don't need to pass in the prop, and let's keep this simple for now -- I will accept your existing code.
If I still have my lines crossed, let me know 😄
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.
Happy Friday Severin!
I just pushed a new commit which includes the below updates:
- passed axios instance as a param
- implemented unit test
- confirmed fee-summary component is working on storybook
- tested on create-ui and edit-ui
- addressed additional issues.
This is the first time for me to work on npm package which is a great opportunity to learn new skills.
Please let me know if I missed anything.
Thank you for your help! ❤️ ❤️ ❤️
src/services/package.json
Outdated
"publishConfig": { | ||
"access": "public" | ||
}, | ||
"dependencies": { | ||
"@bcrs-shared-components/enums": "^1.1.21", | ||
"@bcrs-shared-components/enums": "^1.1.22", |
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.
As above, revert these changes. Lerna will do them automatically in step 14:
https://github.com/bcgov/bcrs-shared-components/blob/main/README.md
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.
To be clear: leave the extra dependency here but use current version numbers. Lerna will update the version numbers.
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.
This will be nice to have as a shared component 👍
Are there any possible unit tests that could be written (even though it's not a UI component)?
Is it possible to create a Storybook config for this (even though it's not a UI component)?
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.
Looks great, outside the manual version bumps!
Read the readme good sir hahah
Joking joking... sort of :)
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.
Looks good to me (don't forget to revert the version changes back to their original state). Sev or I can publish the changes once the PR is merged (please wait for another approval before merging). Let us know 😄
PayApiUrl = 'PAY_API_URL' | ||
PayApiUrl = 'PAY_API_URL', | ||
DocApiUrl = 'DOC_API_URL', | ||
DocApiKey = 'DOC_API_KEY' |
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.
Next time this file is updated, we should alphabetize these keys to make them easier to look through!
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.
I will do it right now 😄
tests/utils.ts
Outdated
return new Promise((resolve) => setTimeout(resolve, ms)) | ||
} | ||
|
||
export { instance as AxiosInstance } |
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.
Would you mind breaking this up into separate functions (named for their content)?
tests/utils.ts
Outdated
instance.interceptors.response.use( | ||
(response) => response, | ||
(error) => Promise.reject(error) | ||
) |
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.
Why do you need this for the tests?
COOP_RULES = 'COOP_RULES', // Rules | ||
COU = 'COU', // Court Order | ||
COOP_MISC = 'COOP_MISC', // Correction Filing | ||
COFI = 'COFI', // Cooperatives Miscellaneous Documents |
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 alphabetize :)
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.
(this whole list)
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.
(within each section is OK)
You can also add whitespace between sections to make it easy to read.
Issue #: /bcgov/entity#25849
Description of changes:
Added enums and services for document service integration.
By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of the business-filings-ui license (Apache 2.0).