-
Notifications
You must be signed in to change notification settings - Fork 394
feat: structured constraints for instruments and beyond #424
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
Draft
raginpirate
wants to merge
1
commit into
main
Choose a base branch
from
proto/funding-source-and-credential-constraints
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Changes from all commits
Commits
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,44 @@ | ||
| { | ||
| "$schema": "https://json-schema.org/draft/2020-12/schema", | ||
| "$id": "https://ucp.dev/schemas/shopping/types/address_constraint.json", | ||
| "title": "Address Constraint", | ||
| "description": "Constraint on a postal address. Reusable across UCP — payments uses this for billing addresses, fulfillment can reuse it for shipping addresses. The requirement of the address field itself is owned by the parent's `required_fields` (e.g., an instrument constraint listing `\"billing_address\"` in its own `required_fields`); this object only describes what fields of the address must be populated when the address is present.", | ||
| "allOf": [ | ||
| { "$ref": "constraint.json" }, | ||
| { | ||
| "type": "object", | ||
| "properties": { | ||
| "required_fields": { | ||
| "type": "array", | ||
| "items": { | ||
| "type": "string", | ||
| "enum": [ | ||
| "street_address", | ||
| "extended_address", | ||
| "address_locality", | ||
| "address_region", | ||
| "address_country", | ||
| "postal_code", | ||
| "first_name", | ||
| "last_name", | ||
| "phone_number" | ||
| ] | ||
| }, | ||
| "uniqueItems": true | ||
| } | ||
| } | ||
| } | ||
| ], | ||
| "examples": [ | ||
| { "required_fields": ["postal_code", "address_country"] }, | ||
| { | ||
| "required_fields": [ | ||
| "street_address", | ||
| "address_locality", | ||
| "address_region", | ||
| "postal_code", | ||
| "address_country" | ||
| ] | ||
| } | ||
| ] | ||
| } |
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,15 @@ | ||
| { | ||
| "$schema": "https://json-schema.org/draft/2020-12/schema", | ||
| "$id": "https://ucp.dev/schemas/shopping/types/constraint.json", | ||
| "title": "Constraint", | ||
| "description": "The universal shape of a constraint object in UCP. Any constraint, on any field, on any object, is structured this way: a `required_fields` list naming properties of the constrained object that MUST be present, plus optional domain-specific custom constraint keys. Concrete constraint schemas (e.g., `address_constraint.json`, `credential_constraint.json`) extend this base and scope `required_fields` to the property names of the object they constrain.", | ||
| "type": "object", | ||
| "properties": { | ||
| "required_fields": { | ||
| "type": "array", | ||
| "items": { "type": "string" }, | ||
| "description": "Names of properties on the constrained object that MUST be present. Concrete constraints should contain the actual property names of the constrained schema." | ||
| } | ||
| }, | ||
| "additionalProperties": true | ||
| } |
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,23 @@ | ||
| { | ||
| "$schema": "https://json-schema.org/draft/2020-12/schema", | ||
| "$id": "https://ucp.dev/schemas/shopping/types/credential_constraint.json", | ||
| "title": "Credential Constraint", | ||
| "description": "An entry in an instrument's `credentials` or `funding_sources` list. Identifies a credential `type` and carries a `constraints` object specific to that credential schema. The same primitive is used on both axes; merchants put each constraint on the semantically correct axis (wire shape vs. underlying funding source) and do not repeat. Entries in `funding_sources` MUST reference credential types whose schema inherits from `payment_funding_source.json`.", | ||
| "type": "object", | ||
| "required": ["type"], | ||
| "properties": { | ||
| "type": { | ||
| "type": "string", | ||
| "description": "The credential type discriminator (matches `payment_credential.json#/properties/type` on a concrete credential schema). Examples: `card`, `network_token`, `token`." | ||
| }, | ||
| "constraints": { | ||
| "$ref": "constraint.json", | ||
| "description": "Constraint object scoped to the named credential type. Concrete credential schemas define their own constraint `$def` narrowing `required_fields` to that schema's properties." | ||
| } | ||
| }, | ||
| "examples": [ | ||
| { "type": "card", "constraints": { "required_fields": ["cvc"] } }, | ||
| { "type": "network_token", "constraints": {} }, | ||
| { "type": "token", "constraints": { "token_provider": ["dev.shopify.spt"] } } | ||
| ] | ||
| } |
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
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.
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.
Should we deprecate rather than removing to avoid a breaking change?