-
Notifications
You must be signed in to change notification settings - Fork 2
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
Pangolin 3184: staged quote model #433
Merged
Merged
Changes from 5 commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
2141d98
feat(staged quote model): yakshaving for staged quote model package
ByronDWall 4828ad7
feat(staged quote model): implement model for StagedQuote, begin on S…
ByronDWall 2bfe609
feat(staged quote model): implement model for StagedQuoteDraft
ByronDWall 14f8167
feat(staged quote model): add changeset
ByronDWall 123a879
feat(quote request model): update types, builder, and transformers to…
ByronDWall fc4b2f9
feat(quote request model): more fun with arcane typescript warnings a…
ByronDWall 75ca705
feat(staged quote model): actually export the draft in src/index.ts
ByronDWall 4437a73
feat(quote request model): even more fun with types and how to make t…
ByronDWall 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 |
---|---|---|
@@ -0,0 +1,6 @@ | ||
--- | ||
'@commercetools-test-data/quote-request': minor | ||
'@commercetools-test-data/staged-quote': patch | ||
--- | ||
|
||
feat(staged quote) add test data package for staged quote model |
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,21 @@ | ||
MIT License | ||
|
||
Copyright (c) commercetools GmbH | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining a copy | ||
of this software and associated documentation files (the "Software"), to deal | ||
in the Software without restriction, including without limitation the rights | ||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
copies of the Software, and to permit persons to whom the Software is | ||
furnished to do so, subject to the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be included in all | ||
copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
SOFTWARE. |
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,25 @@ | ||
# @commercetools-test-data/quote | ||
|
||
This package provides the data model for the commercetools platform `StagedQuote` type | ||
|
||
https://docs.commercetools.com/api/projects/staged-quotes | ||
|
||
# Install | ||
|
||
```bash | ||
$ pnpm add -D @commercetools-test-data/staged-quote | ||
``` | ||
|
||
# Usage | ||
|
||
```ts | ||
import { | ||
StagedQuote, | ||
StagedQuoteDraft, | ||
type TStagedQuote, | ||
type TStagedQuoteDraft, | ||
} from '@commercetools-test-data/quote-request'; | ||
|
||
const stagedQuote = StagedQuote.random().build<TStagedQuote>(); | ||
const stagedQuoteDraft = StagedQuoteDraft.random().build<TStagedQuoteDraft>(); | ||
``` |
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,34 @@ | ||
{ | ||
"name": "@commercetools-test-data/staged-quote", | ||
"version": "6.5.0", | ||
"description": "Data model for commercetools API StagedQuote", | ||
"bugs": "https://github.com/commercetools/test-data/issues", | ||
"repository": { | ||
"type": "git", | ||
"url": "https://github.com/commercetools/test-data.git", | ||
"directory": "models/quote" | ||
}, | ||
"keywords": ["javascript", "typescript", "test-data"], | ||
"license": "MIT", | ||
"publishConfig": { | ||
"access": "public" | ||
}, | ||
"main": "dist/commercetools-test-data-staged-quote.cjs.js", | ||
"module": "dist/commercetools-test-data-staged-quote.esm.js", | ||
"files": ["dist", "package.json", "LICENSE", "README.md"], | ||
"dependencies": { | ||
"@babel/runtime": "^7.17.9", | ||
"@babel/runtime-corejs3": "^7.17.9", | ||
"@commercetools-test-data/business-unit": "6.5.0", | ||
"@commercetools-test-data/cart": "6.5.0", | ||
"@commercetools-test-data/commons": "6.5.0", | ||
"@commercetools-test-data/core": "6.5.0", | ||
"@commercetools-test-data/customer": "6.5.0", | ||
"@commercetools-test-data/customer-group": "6.5.0", | ||
"@commercetools-test-data/quote-request": "6.5.0", | ||
"@commercetools-test-data/store": "6.5.0", | ||
"@commercetools-test-data/utils": "6.5.0", | ||
"@commercetools/platform-sdk": "^6.0.0", | ||
"@faker-js/faker": "^8.0.0" | ||
} | ||
} |
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,149 @@ | ||
/* eslint-disable jest/valid-title */ | ||
/* eslint-disable jest/no-disabled-tests */ | ||
|
||
import { createBuilderSpec } from '@commercetools-test-data/core/test-utils'; | ||
import type { | ||
TStagedQuote, | ||
TStagedQuoteRest, | ||
TStagedQuoteGraphql, | ||
} from './types'; | ||
import * as StagedQuote from './index'; | ||
|
||
describe('builder', () => { | ||
it( | ||
...createBuilderSpec<TStagedQuote, TStagedQuote>( | ||
'default', | ||
StagedQuote.random(), | ||
expect.objectContaining({ | ||
id: expect.any(String), | ||
version: expect.any(Number), | ||
key: expect.any(String), | ||
stagedQuoteState: expect.any(String), | ||
customer: expect.objectContaining({ | ||
email: expect.any(String), | ||
}), | ||
quoteRequest: expect.objectContaining({ | ||
quoteRequestState: expect.any(String), | ||
}), | ||
quotationCart: expect.objectContaining({ | ||
cartState: expect.any(String), | ||
}), | ||
validTo: expect.any(String), | ||
sellerComment: expect.any(String), | ||
state: null, | ||
purchaseOrderNumber: null, | ||
businessUnit: expect.objectContaining({ | ||
id: expect.any(String), | ||
key: expect.any(String), | ||
associateMode: expect.any(String), | ||
}), | ||
custom: null, | ||
createdAt: expect.any(String), | ||
createdBy: expect.objectContaining({ | ||
customer: expect.objectContaining({ typeId: 'customer' }), | ||
}), | ||
lastModifiedAt: expect.any(String), | ||
lastModifiedBy: expect.objectContaining({ | ||
customer: expect.objectContaining({ typeId: 'customer' }), | ||
}), | ||
}) | ||
) | ||
); | ||
it( | ||
...createBuilderSpec<TStagedQuote, TStagedQuoteRest>( | ||
'rest', | ||
StagedQuote.random(), | ||
expect.objectContaining({ | ||
id: expect.any(String), | ||
version: expect.any(Number), | ||
key: expect.any(String), | ||
stagedQuoteState: expect.any(String), | ||
customer: expect.objectContaining({ | ||
id: expect.any(String), | ||
typeId: 'customer', | ||
}), | ||
quoteRequest: expect.objectContaining({ | ||
typeId: 'quote-request', | ||
}), | ||
quotationCart: expect.objectContaining({ | ||
typeId: 'cart', | ||
}), | ||
validTo: expect.any(String), | ||
sellerComment: expect.any(String), | ||
state: undefined, | ||
purchaseOrderNumber: null, | ||
businessUnit: expect.objectContaining({ | ||
typeId: 'business-unit', | ||
}), | ||
custom: null, | ||
createdAt: expect.any(String), | ||
createdBy: expect.objectContaining({ | ||
customer: expect.objectContaining({ typeId: 'customer' }), | ||
}), | ||
lastModifiedAt: expect.any(String), | ||
lastModifiedBy: expect.objectContaining({ | ||
customer: expect.objectContaining({ typeId: 'customer' }), | ||
}), | ||
}) | ||
) | ||
); | ||
it( | ||
...createBuilderSpec<TStagedQuote, TStagedQuoteGraphql>( | ||
'graphql', | ||
StagedQuote.random(), | ||
expect.objectContaining({ | ||
id: expect.any(String), | ||
version: expect.any(Number), | ||
key: expect.any(String), | ||
stagedQuoteState: expect.any(String), | ||
customer: expect.objectContaining({ | ||
email: expect.any(String), | ||
}), | ||
customerRef: expect.objectContaining({ | ||
typeId: 'customer', | ||
__typename: 'Reference', | ||
}), | ||
quoteRequest: expect.objectContaining({ | ||
quoteRequestState: expect.any(String), | ||
}), | ||
quoteRequestRef: expect.objectContaining({ | ||
typeId: 'quote-request', | ||
__typename: 'Reference', | ||
}), | ||
quotationCart: expect.objectContaining({ | ||
cartState: expect.any(String), | ||
}), | ||
quotationCartRef: expect.objectContaining({ | ||
typeId: 'cart', | ||
__typename: 'Reference', | ||
}), | ||
validTo: expect.any(String), | ||
sellerComment: expect.any(String), | ||
state: null, | ||
stateRef: undefined, | ||
purchaseOrderNumber: null, | ||
businessUnit: expect.objectContaining({ | ||
id: expect.any(String), | ||
key: expect.any(String), | ||
associateMode: expect.any(String), | ||
}), | ||
businessUnitRef: expect.objectContaining({ | ||
typeId: 'business-unit', | ||
__typename: 'Reference', | ||
}), | ||
custom: null, | ||
createdAt: expect.any(String), | ||
createdBy: expect.objectContaining({ | ||
customerRef: expect.objectContaining({ typeId: 'customer' }), | ||
userRef: expect.objectContaining({ typeId: 'user' }), | ||
}), | ||
lastModifiedAt: expect.any(String), | ||
lastModifiedBy: expect.objectContaining({ | ||
customerRef: expect.objectContaining({ typeId: 'customer' }), | ||
userRef: expect.objectContaining({ typeId: 'user' }), | ||
}), | ||
__typename: 'StagedQuote', | ||
}) | ||
) | ||
); | ||
}); |
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,12 @@ | ||
import { Builder } from '@commercetools-test-data/core'; | ||
import generator from './generator'; | ||
import transformers from './transformers'; | ||
import type { TStagedQuote, TCreateStagedQuoteBuilder } from './types'; | ||
|
||
const Model: TCreateStagedQuoteBuilder = () => | ||
Builder<TStagedQuote>({ | ||
generator, | ||
transformers, | ||
}); | ||
|
||
export default Model; |
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,5 @@ | ||
export const STAGED_QUOTE_STATE = { | ||
inProgress: 'InProgress', | ||
sent: 'Sent', | ||
closed: 'Closed', | ||
} as const; |
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.
This fixes an error I made in building the graphql data for
![Screenshot 2023-11-21 at 10 28 05 AM](https://private-user-images.githubusercontent.com/87667330/284633603-233a9c01-d383-48f7-8b52-6d78e0b2da0e.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3Mzk0NDk5MDgsIm5iZiI6MTczOTQ0OTYwOCwicGF0aCI6Ii84NzY2NzMzMC8yODQ2MzM2MDMtMjMzYTljMDEtZDM4My00OGY3LThiNTItNmQ3OGUwYjJkYTBlLnBuZz9YLUFtei1BbGdvcml0aG09QVdTNC1ITUFDLVNIQTI1NiZYLUFtei1DcmVkZW50aWFsPUFLSUFWQ09EWUxTQTUzUFFLNFpBJTJGMjAyNTAyMTMlMkZ1cy1lYXN0LTElMkZzMyUyRmF3czRfcmVxdWVzdCZYLUFtei1EYXRlPTIwMjUwMjEzVDEyMjY0OFomWC1BbXotRXhwaXJlcz0zMDAmWC1BbXotU2lnbmF0dXJlPWZmMTM1NTRiYjE0Mjg5M2IwMGE0NDYxNjVjOTkwM2ZlODQwMDg1MmU3ZmE1NzlmN2Q5MDEzMGIxYzdkNzBlZTkmWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0In0._ghimdtQxKYWbQfLQ_9miqx0Dq1cejEdSuO0xiXpbU4)
QuoteRequest
,cart
is the only field that only returns aReference
, and not the full data, i.e. the graphql api returns acartRef
field, but does not returncart