-
Notifications
You must be signed in to change notification settings - Fork 0
OUT-3742: tighten QBO Fault handling + bind SQL projections to row schemas #251
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
Merged
Merged
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
809f607
fix(OUT-3742): assertNotQBFault extracts code from Fault.Error[0]
SandipBajracharya 05a93eb
refactor(OUT-3742): bind QBO SELECT projections to row schemas
SandipBajracharya 1ba395a
fix(OUT-3742): keep QBO Fault parse intact on non-numeric code
SandipBajracharya 38688ad
docs(OUT-3742): accurate comment on the Fault.Error fallback test
SandipBajracharya b5c3e58
chore(OUT-3742): switch Fault.code to transform; tighten comments & t…
SandipBajracharya 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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,83 @@ | ||
| // Asserts each QB_*_COLUMNS constant stays a superset of its schema's | ||
| // required keys. Optional-field drops still pass — verify callers if you | ||
| // remove one. | ||
|
|
||
| import { describe, it, expect } from 'vitest' | ||
| import { | ||
| QB_ACCOUNT_COLUMNS, | ||
| QB_CUSTOMER_COLUMNS, | ||
| QB_INVOICE_COLUMNS, | ||
| QB_ITEM_COLUMNS, | ||
| } from '@/utils/intuitAPI' | ||
| import { | ||
| CustomerQueryResponseSchema, | ||
| QBAccountRowSchema, | ||
| QBInvoiceRowSchema, | ||
| QBItemRowSchema, | ||
| } from '@/type/dto/intuitAPI.dto' | ||
| import type { ZodTypeAny } from 'zod' | ||
|
|
||
| const requiredKeysOf = (shape: Record<string, ZodTypeAny>): string[] => | ||
| Object.entries(shape) | ||
| .filter(([, s]) => !s.isOptional()) | ||
| .map(([k]) => k) | ||
|
|
||
| describe('QB_INVOICE_COLUMNS', () => { | ||
| it('selects every column the invoice schema marks as required', () => { | ||
| for (const key of requiredKeysOf(QBInvoiceRowSchema.shape)) { | ||
| expect(QB_INVOICE_COLUMNS).toContain(key) | ||
| } | ||
| }) | ||
|
|
||
| it('does not list any column that the invoice schema does not define', () => { | ||
| const schemaKeys = new Set(Object.keys(QBInvoiceRowSchema.shape)) | ||
| for (const col of QB_INVOICE_COLUMNS) { | ||
| expect(schemaKeys.has(col)).toBe(true) | ||
| } | ||
| }) | ||
| }) | ||
|
|
||
| describe('QB_ITEM_COLUMNS', () => { | ||
| it('selects every column the item schema marks as required', () => { | ||
| for (const key of requiredKeysOf(QBItemRowSchema.shape)) { | ||
| expect(QB_ITEM_COLUMNS).toContain(key) | ||
| } | ||
| }) | ||
|
|
||
| it('does not list any column that the item schema does not define', () => { | ||
| const schemaKeys = new Set(Object.keys(QBItemRowSchema.shape)) | ||
| for (const col of QB_ITEM_COLUMNS) { | ||
| expect(schemaKeys.has(col)).toBe(true) | ||
| } | ||
| }) | ||
| }) | ||
|
|
||
| describe('QB_CUSTOMER_COLUMNS', () => { | ||
| it('selects every column the customer schema marks as required', () => { | ||
| for (const key of requiredKeysOf(CustomerQueryResponseSchema.shape)) { | ||
| expect(QB_CUSTOMER_COLUMNS).toContain(key) | ||
| } | ||
| }) | ||
|
|
||
| it('does not list any column that the customer schema does not define', () => { | ||
| const schemaKeys = new Set(Object.keys(CustomerQueryResponseSchema.shape)) | ||
| for (const col of QB_CUSTOMER_COLUMNS) { | ||
| expect(schemaKeys.has(col)).toBe(true) | ||
| } | ||
| }) | ||
| }) | ||
|
|
||
| describe('QB_ACCOUNT_COLUMNS', () => { | ||
| it('selects every column the account schema marks as required', () => { | ||
| for (const key of requiredKeysOf(QBAccountRowSchema.shape)) { | ||
| expect(QB_ACCOUNT_COLUMNS).toContain(key) | ||
| } | ||
| }) | ||
|
|
||
| it('does not list any column that the account schema does not define', () => { | ||
| const schemaKeys = new Set(Object.keys(QBAccountRowSchema.shape)) | ||
| for (const col of QB_ACCOUNT_COLUMNS) { | ||
| expect(schemaKeys.has(col)).toBe(true) | ||
| } | ||
| }) | ||
| }) |
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.