diff --git a/.codespellignore b/.codespellignore new file mode 100644 index 0000000..4d75c60 --- /dev/null +++ b/.codespellignore @@ -0,0 +1,4 @@ +mor +tok +fpan +dpan diff --git a/.github/workflows/linter.yml b/.github/workflows/linter.yml new file mode 100644 index 0000000..102b38d --- /dev/null +++ b/.github/workflows/linter.yml @@ -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 diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..9451024 --- /dev/null +++ b/.gitignore @@ -0,0 +1,4 @@ +node_modules/ +dist/ +.DS_Store +*.log diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml new file mode 100644 index 0000000..b4f782d --- /dev/null +++ b/.pre-commit-config.yaml @@ -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"] diff --git a/.prettierrc b/.prettierrc new file mode 100644 index 0000000..a4388dd --- /dev/null +++ b/.prettierrc @@ -0,0 +1,8 @@ +{ + "tabWidth": 2, + "useTabs": false, + "singleQuote": false, + "trailingComma": "es5", + "bracketSameLine": false, + "printWidth": 80 +} diff --git a/README.md b/README.md index 9fd0cc2..e060b92 100644 --- a/README.md +++ b/README.md @@ -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 @@ -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 diff --git a/src/extensions.ts b/src/extensions.ts index 42aeece..36c584f 100644 --- a/src/extensions.ts +++ b/src/extensions.ts @@ -30,7 +30,7 @@ export const PlatformConfigSchema = z.object({ export type PlatformConfig = z.infer; 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) @@ -45,14 +45,13 @@ 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 @@ -60,14 +59,13 @@ export type ExtendedCheckoutCreateRequest = z.infer< 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