Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
19 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions .codespellignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
mor
tok
fpan
dpan
31 changes: 31 additions & 0 deletions .github/workflows/linter.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
# Copyright 2026 Google LLC
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

name: Lint

on:
push:
branches: [main]
pull_request:
branches: [main]

jobs:
pre-commit:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: '3.x'
- uses: pre-commit/action@v3.0.1
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
node_modules/
dist/
.DS_Store
*.log
42 changes: 42 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
# Copyright 2026 Google LLC
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

exclude: '^(\.github/|\.vscode/|node_modules/).*|CODE_OF_CONDUCT\.md|CHANGELOG\.md'

repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v6.0.0
hooks:
- id: trailing-whitespace
- id: end-of-file-fixer
- id: check-yaml
args: [--unsafe]
- id: check-json
- id: check-added-large-files
- id: check-shebang-scripts-are-executable
- id: check-executables-have-shebangs
- repo: https://github.com/pre-commit/mirrors-prettier
rev: v4.0.0-alpha.8
hooks:
- id: prettier
files: \.(ts|js|json|md|yaml|yml|html)$
- repo: https://github.com/koalaman/shellcheck-precommit
rev: v0.10.0
hooks:
- id: shellcheck
- repo: https://github.com/codespell-project/codespell
rev: v2.4.1
hooks:
- id: codespell
args: ["--skip", "package-lock.json", "-I", ".codespellignore"]
8 changes: 8 additions & 0 deletions .prettierrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"tabWidth": 2,
"useTabs": false,
"singleQuote": false,
"trailingComma": "es5",
"bracketSameLine": false,
"printWidth": 80
}
12 changes: 8 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,10 +45,12 @@ This project uses `npm` for package management and `typescript` for building.

### Generating Models

The models are automatically generated from the JSON schemas in the [UCP
Specification](https://ucp.dev).
The models are automatically generated from the JSON schemas in the
[UCP Specification](https://ucp.dev).

To regenerate the models, you first need a local copy of the [UCP specification](https://github.com/Universal-Commerce-Protocol/ucp). If you don't have one, you can clone it via:
To regenerate the models, you first need a local copy of the
[UCP specification](https://github.com/Universal-Commerce-Protocol/ucp). If you
don't have one, you can clone it via:

```bash
git clone https://github.com/Universal-Commerce-Protocol/ucp.git
Expand All @@ -71,7 +73,9 @@ npm run build

## Contributing

We welcome community contributions. See our [Contribution Guide](https://github.com/Universal-Commerce-Protocol/.github/blob/main/CONTRIBUTING.md) for details.
We welcome community contributions. See our
[Contribution Guide](https://github.com/Universal-Commerce-Protocol/.github/blob/main/CONTRIBUTING.md)
for details.

## License

Expand Down
16 changes: 7 additions & 9 deletions src/extensions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ export const PlatformConfigSchema = z.object({
export type PlatformConfig = z.infer<typeof PlatformConfigSchema>;

export const ExtendedCheckoutResponseSchema = CheckoutResponseSchema.extend(
CheckoutWithFulfillmentResponseSchema.pick({ fulfillment: true }).shape,
CheckoutWithFulfillmentResponseSchema.pick({ fulfillment: true }).shape
)
.extend(CheckoutWithDiscountResponseSchema.pick({ discounts: true }).shape)
.extend(CheckoutWithBuyerConsentResponseSchema.pick({ buyer: true }).shape)
Expand All @@ -45,29 +45,27 @@ export type ExtendedCheckoutResponse = z.infer<

export const ExtendedCheckoutCreateRequestSchema =
CheckoutCreateRequestSchema.extend(
CheckoutWithFulfillmentCreateRequestSchema.pick({ fulfillment: true })
.shape,
CheckoutWithFulfillmentCreateRequestSchema.pick({ fulfillment: true }).shape
)
.extend(
CheckoutWithDiscountCreateRequestSchema.pick({ discounts: true }).shape,
CheckoutWithDiscountCreateRequestSchema.pick({ discounts: true }).shape
)
.extend(
CheckoutWithBuyerConsentCreateRequestSchema.pick({ buyer: true }).shape,
CheckoutWithBuyerConsentCreateRequestSchema.pick({ buyer: true }).shape
);
export type ExtendedCheckoutCreateRequest = z.infer<
typeof ExtendedCheckoutCreateRequestSchema
>;

export const ExtendedCheckoutUpdateRequestSchema =
CheckoutUpdateRequestSchema.extend(
CheckoutWithFulfillmentUpdateRequestSchema.pick({ fulfillment: true })
.shape,
CheckoutWithFulfillmentUpdateRequestSchema.pick({ fulfillment: true }).shape
)
.extend(
CheckoutWithDiscountUpdateRequestSchema.pick({ discounts: true }).shape,
CheckoutWithDiscountUpdateRequestSchema.pick({ discounts: true }).shape
)
.extend(
CheckoutWithBuyerConsentUpdateRequestSchema.pick({ buyer: true }).shape,
CheckoutWithBuyerConsentUpdateRequestSchema.pick({ buyer: true }).shape
);
export type ExtendedCheckoutUpdateRequest = z.infer<
typeof ExtendedCheckoutUpdateRequestSchema
Expand Down
Loading