├── .eslintrc.js ├── .gitattributes ├── .github ├── actions │ └── setup │ │ └── action.yaml ├── dependabot.yml └── workflows │ ├── add-to-project.yaml │ ├── ci.yaml │ ├── emergency-review-bypass.yaml │ ├── notify-approval-bypass.yaml │ └── pr-title.yaml ├── .gitignore ├── .prettierignore ├── .vscode └── settings.json ├── LICENSE ├── README.md ├── package.json ├── packages ├── eslint-config-custom │ ├── index.js │ ├── license-header │ └── package.json ├── knit-test-spec │ ├── buf.gen.yaml │ ├── package.json │ ├── proto │ │ ├── buf.lock │ │ ├── buf.yaml │ │ └── spec │ │ │ ├── all.proto │ │ │ ├── enum.proto │ │ │ ├── json.proto │ │ │ ├── map.proto │ │ │ ├── messages.proto │ │ │ ├── oneof.proto │ │ │ ├── proto2.proto │ │ │ ├── relations.proto │ │ │ ├── scalars.proto │ │ │ ├── sub │ │ │ └── sub.proto │ │ │ └── wkt.proto │ └── spec │ │ ├── all_connect.d.ts │ │ ├── all_connect.js │ │ ├── all_knit.d.ts │ │ ├── all_pb.d.ts │ │ ├── all_pb.js │ │ ├── enum_knit.d.ts │ │ ├── enum_pb.d.ts │ │ ├── enum_pb.js │ │ ├── json_knit.d.ts │ │ ├── json_pb.d.ts │ │ ├── json_pb.js │ │ ├── map_knit.d.ts │ │ ├── map_pb.d.ts │ │ ├── map_pb.js │ │ ├── messages_knit.d.ts │ │ ├── messages_pb.d.ts │ │ ├── messages_pb.js │ │ ├── oneof_knit.d.ts │ │ ├── oneof_pb.d.ts │ │ ├── oneof_pb.js │ │ ├── proto2_knit.d.ts │ │ ├── proto2_pb.d.ts │ │ ├── proto2_pb.js │ │ ├── relations_connect.d.ts │ │ ├── relations_connect.js │ │ ├── relations_knit.d.ts │ │ ├── relations_pb.d.ts │ │ ├── relations_pb.js │ │ ├── scalars_knit.d.ts │ │ ├── scalars_pb.d.ts │ │ ├── scalars_pb.js │ │ ├── sub │ │ ├── sub_connect.d.ts │ │ ├── sub_connect.js │ │ ├── sub_knit.d.ts │ │ ├── sub_pb.d.ts │ │ └── sub_pb.js │ │ ├── wkt_connect.d.ts │ │ ├── wkt_connect.js │ │ ├── wkt_knit.d.ts │ │ ├── wkt_pb.d.ts │ │ └── wkt_pb.js ├── knit │ ├── .eslintrc.cjs │ ├── README.md │ ├── gateway.js │ ├── jest.config.js │ ├── package.json │ ├── src │ │ ├── alias.ts │ │ ├── client.test.ts │ │ ├── client.ts │ │ ├── error.ts │ │ ├── gateway │ │ │ ├── gateway.test.ts │ │ │ ├── gateway.ts │ │ │ ├── headers.test.ts │ │ │ ├── headers.ts │ │ │ ├── index.ts │ │ │ ├── json.test.ts │ │ │ ├── json.ts │ │ │ ├── schema.test.ts │ │ │ ├── schema.ts │ │ │ ├── service.test.ts │ │ │ ├── service.ts │ │ │ ├── stitch.test.ts │ │ │ ├── stitch.ts │ │ │ ├── util.ts │ │ │ └── wkt.ts │ │ ├── index.ts │ │ ├── jest │ │ │ └── util.ts │ │ ├── json.test.ts │ │ ├── json.ts │ │ ├── oneof.test.ts │ │ ├── oneof.ts │ │ ├── protocol.test.ts │ │ ├── protocol.ts │ │ ├── schema.test.ts │ │ ├── schema.ts │ │ ├── scope.test.ts │ │ ├── scope.ts │ │ ├── utils │ │ │ └── types.ts │ │ └── wkt │ │ │ ├── any.ts │ │ │ ├── duration.ts │ │ │ ├── empty.ts │ │ │ ├── field_mask.ts │ │ │ ├── struct.ts │ │ │ └── timestamp.ts │ ├── tsconfig.json │ └── tsup.config.ts ├── protoc-gen-knit-ts │ ├── .eslintrc.cjs │ ├── README.md │ ├── bin │ │ └── protoc-gen-knit-ts │ ├── package.json │ ├── src │ │ └── index.ts │ └── tsconfig.json └── tsconfig │ ├── base.json │ ├── library.json │ └── package.json ├── pnpm-lock.yaml ├── pnpm-workspace.yaml └── turbo.json /.eslintrc.js: -------------------------------------------------------------------------------- 1 | // Copyright 2023-2024 Buf Technologies, Inc. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | /** @type { import('eslint').Linter.Config } */ 16 | module.exports = { 17 | root: true, 18 | // This tells ESLint to load the config from the package `eslint-config-custom` 19 | extends: ["custom"], 20 | settings: {}, 21 | }; 22 | -------------------------------------------------------------------------------- /.gitattributes: -------------------------------------------------------------------------------- 1 | # Ignore generated files in GitHub diffs by default 2 | **/*_pb.ts linguist-generated=true 3 | **/*_pb.js linguist-generated=true 4 | **/*_pb.d.ts linguist-generated=true 5 | **/*_knit.ts linguist-generated=true 6 | **/*_knit.js linguist-generated=true 7 | **/*_knit.d.ts linguist-generated=true 8 | **/*connect.ts linguist-generated=true 9 | **/*connect.js linguist-generated=true 10 | **/*connect.d.ts linguist-generated=true -------------------------------------------------------------------------------- /.github/actions/setup/action.yaml: -------------------------------------------------------------------------------- 1 | name: Setup 2 | description: Sets up the environment for the rest of the workflow 3 | runs: 4 | using: composite 5 | steps: 6 | - uses: bufbuild/buf-setup-action@v1 7 | - uses: pnpm/action-setup@v2 8 | with: 9 | run_install: false 10 | - name: Install Node.js 11 | uses: actions/setup-node@v3 12 | with: 13 | node-version-file: "package.json" 14 | cache: "pnpm" 15 | cache-dependency-path: "pnpm-lock.yaml" 16 | - shell: bash 17 | run: pnpm config set @buf:registry https://buf.build/gen/npm/v1 18 | - name: pnpm install 19 | shell: bash 20 | run: pnpm install --frozen-lockfile 21 | - name: Cache turbo build setup 22 | uses: actions/cache@v3 23 | with: 24 | path: .turbo 25 | key: ${{ runner.os }}-turbo-${{ github.sha }} 26 | restore-keys: | 27 | ${{ runner.os }}-turbo- 28 | -------------------------------------------------------------------------------- /.github/dependabot.yml: -------------------------------------------------------------------------------- 1 | # To get started with Dependabot version updates, you'll need to specify which 2 | # package ecosystems to update and where the package manifests are located. 3 | # Please see the documentation for all configuration options: 4 | # https://docs.github.com/github/administering-a-repository/configuration-options-for-dependency-updates 5 | version: 2 6 | updates: 7 | - package-ecosystem: "npm" 8 | directory: "/" 9 | schedule: 10 | interval: "weekly" 11 | open-pull-requests-limit: 50 12 | -------------------------------------------------------------------------------- /.github/workflows/add-to-project.yaml: -------------------------------------------------------------------------------- 1 | name: Add issues and PRs to project 2 | 3 | on: 4 | issues: 5 | types: 6 | - opened 7 | - reopened 8 | - transferred 9 | pull_request_target: 10 | types: 11 | - opened 12 | - reopened 13 | issue_comment: 14 | types: 15 | - created 16 | 17 | jobs: 18 | call-workflow-add-to-project: 19 | name: Call workflow to add issue to project 20 | uses: bufbuild/base-workflows/.github/workflows/add-to-project.yaml@main 21 | secrets: inherit 22 | -------------------------------------------------------------------------------- /.github/workflows/ci.yaml: -------------------------------------------------------------------------------- 1 | name: ci 2 | on: 3 | workflow_dispatch: 4 | push: 5 | permissions: 6 | contents: read 7 | jobs: 8 | lint: 9 | runs-on: ubuntu-latest 10 | steps: 11 | - name: checkout 12 | uses: actions/checkout@v3 13 | - name: Setup 14 | uses: ./.github/actions/setup 15 | - name: lint 16 | run: pnpm run lint 17 | test: 18 | runs-on: ubuntu-latest 19 | steps: 20 | - name: checkout 21 | uses: actions/checkout@v3 22 | - name: Setup 23 | uses: ./.github/actions/setup 24 | - name: test 25 | run: pnpm run test 26 | - name: attw 27 | run: pnpm run attw 28 | -------------------------------------------------------------------------------- /.github/workflows/emergency-review-bypass.yaml: -------------------------------------------------------------------------------- 1 | name: Bypass review in case of emergency 2 | on: 3 | pull_request: 4 | types: 5 | - labeled 6 | permissions: 7 | pull-requests: write 8 | jobs: 9 | approve: 10 | if: github.event.label.name == 'Emergency Bypass Review' 11 | uses: bufbuild/base-workflows/.github/workflows/emergency-review-bypass.yaml@main 12 | secrets: inherit 13 | -------------------------------------------------------------------------------- /.github/workflows/notify-approval-bypass.yaml: -------------------------------------------------------------------------------- 1 | name: PR Approval Bypass Notifier 2 | on: 3 | pull_request: 4 | types: 5 | - closed 6 | branches: 7 | - main 8 | permissions: 9 | pull-requests: read 10 | jobs: 11 | approval: 12 | uses: bufbuild/base-workflows/.github/workflows/notify-approval-bypass.yaml@main 13 | secrets: inherit 14 | -------------------------------------------------------------------------------- /.github/workflows/pr-title.yaml: -------------------------------------------------------------------------------- 1 | name: Lint PR Title 2 | # Prevent writing to the repository using the CI token. 3 | # Ref: https://docs.github.com/en/actions/reference/workflow-syntax-for-github-actions#permissions 4 | permissions: 5 | pull-requests: read 6 | on: 7 | pull_request: 8 | # By default, a workflow only runs when a pull_request's activity type is opened, 9 | # synchronize, or reopened. We explicity override here so that PR titles are 10 | # re-linted when the PR text content is edited. 11 | types: 12 | - opened 13 | - edited 14 | - reopened 15 | - synchronize 16 | jobs: 17 | lint: 18 | uses: bufbuild/base-workflows/.github/workflows/pr-title.yaml@main 19 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | node_modules 2 | /packages/*/dist 3 | .turbo 4 | -------------------------------------------------------------------------------- /.prettierignore: -------------------------------------------------------------------------------- 1 | # Defaults 2 | **/.git 3 | **/.svn 4 | **/.hg 5 | **/node_modules 6 | 7 | **/dist 8 | **/src/gen 9 | packages/knit-test-spec/spec/** -------------------------------------------------------------------------------- /.vscode/settings.json: -------------------------------------------------------------------------------- 1 | { 2 | "typescript.tsdk": "node_modules/typescript/lib" 3 | } 4 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # 🧶 Knit 2 | 3 | [![License](https://img.shields.io/github/license/bufbuild/knit-ts?color=blue)][badges_license] 4 | [![NPM Version](https://img.shields.io/npm/v/@bufbuild/knit/latest?color=green&label=%40bufbuild%2Fknit)][npm_knit] 5 | [![NPM Version](https://img.shields.io/npm/v/@bufbuild/protoc-gen-knit-ts/latest?color=green&label=%40bufbuild%2Fprotoc-gen-knit-ts)][npm_protoc-gen-knit-ts] 6 | [![Slack](https://img.shields.io/badge/slack-buf-%23e01563)][badges_slack] 7 | 8 | **Knit brings GraphQL-like capabilities to RPCs. Knit has type-safe and 9 | declarative queries that shape the response, batching support to eliminate 10 | the N+1 problem, and first-class support for error handling with partial 11 | responses. It is built on top of Protobuf and Connect.** 12 | 13 | **[Knit] is currently in alpha (α), and looking for feedback. Learn more 14 | about it at the [Knit] repo, and learn how to use it with the [Tutorial].** 15 | 16 | --- 17 | 18 | This repo houses TypeScript packages for Knit: 19 | 20 | - [@bufbuild/knit](https://npmjs.com/@bufbuild/knit) - The TypeScript client package. 21 | - [@bufbuild/protoc-gen-knit-ts](https://npmjs.com/@bufbuild/protoc-gen-knit-ts) - The schema generator. 22 | 23 | ## Quick example 24 | 25 | To demonstrate the querying capabilities of Knit we've made a Protobuf equivalent of the star wars API at [swapi.dev](https://swapi.dev). 26 | The definitions are available [here](https://buf.build/bufbuild/knit-demo). 27 | 28 | Run the following command to install the runtime package and schema for the star wars APIs: 29 | 30 | ```sh 31 | npm i @bufbuild/knit @buf/bufbuild_knit-demo.bufbuild_knit-es 32 | ``` 33 | 34 | In a TypeScript file write the following query: 35 | 36 | ```ts 37 | import { createClient } from "@bufbuild/knit"; 38 | import type { FilmsService } from "@buf/bufbuild_knit-demo.bufbuild_knit-es/buf/knit/demo/swapi/film/v1/film_knit"; 39 | import type {} from "@buf/bufbuild_knit-demo.bufbuild_knit-es/buf/knit/demo/swapi/relations/v1/relations_knit"; 40 | 41 | const client = createClient({ 42 | baseUrl: "https://knit-demo.connect.build", // The gateway-url 43 | }); 44 | 45 | // Construct a query. 46 | // 47 | // The type system will ensure a query is valid. 48 | const filmsResult = await client.fetch({ 49 | // The fully qualified service name of the RPC you want to invoke. 50 | "buf.knit.demo.swapi.film.v1.FilmService": { 51 | // The camelCase name of the RPC you want to invoke. 52 | getFilms: { 53 | // $ is the request message for the RPC. 54 | $: { ids: ["1"] }, 55 | // The fields you want to select from the result. 56 | films: { 57 | id: {}, 58 | title: {}, 59 | director: {}, 60 | releaseDate: {}, 61 | // Include the relation you want to use. 62 | // This field is not part of the original 63 | // proto definition of a `Film`, it comes 64 | // from `.../relations_knit`. 65 | characters: { 66 | // Relations can accept additional parameters. 67 | // In this case it accepts a limit parameter 68 | // to limit the number of characters returned. 69 | $: { limit: 10 } 70 | // The fields you want to select from the characters. 71 | id: {}, 72 | name: {}, 73 | }, 74 | }, 75 | }, 76 | }, 77 | }); 78 | 79 | // The result is a strongly typed object that matches the query. 80 | console.log(JSON.strigify(filmsResult, null, 2)); 81 | /** 82 | * This will print: 83 | * { 84 | * "buf.knit.demo.swapi.film.v1.FilmService": { 85 | * "getFilms": { 86 | * "films": [ 87 | * { 88 | * "id": "1", 89 | * "title": "A New Hope", 90 | * "director": "George Lucas", 91 | * "releaseDate": "1977-05-25", 92 | * "characters": [{ 93 | * { "id": "1", "name": "Luke Skywalker" }, 94 | * { "id": "2", "name": "C-3PO" }, 95 | * ... 96 | * }] 97 | * } 98 | * ] 99 | * } 100 | * } 101 | * } 102 | */ 103 | ``` 104 | 105 | ## Status: Alpha 106 | 107 | Knit is undergoing initial development and is not yet stable. 108 | 109 | ## Legal 110 | 111 | Offered under the [Apache 2 license][license]. 112 | 113 | [badges_license]: https://github.com/bufbuild/knit-ts/blob/main/LICENSE 114 | [badges_slack]: https://buf.build/links/slack 115 | [license]: https://github.com/bufbuild/knit-ts/blob/main/LICENSE 116 | [npm_knit]: https://www.npmjs.com/package/@bufbuild/knit 117 | [npm_protoc-gen-knit-ts]: https://www.npmjs.com/package/@bufbuild/protoc-gen-knit-ts 118 | [knit]: https://github.com/bufbuild/knit 119 | [tutorial]: https://github.com/bufbuild/knit/tree/main/tutorial 120 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "knit", 3 | "version": "0.0.0", 4 | "private": true, 5 | "workspaces": [ 6 | "packages/*" 7 | ], 8 | "scripts": { 9 | "clean": "turbo run clean --no-daemon --cache-dir=.turbo", 10 | "build": "turbo run build --no-daemon --cache-dir=.turbo", 11 | "lint": "turbo run lint --no-daemon --cache-dir=.turbo", 12 | "attw": "turbo run attw --no-daemon --cache-dir=.turbo", 13 | "test": "turbo run test --no-daemon --cache-dir=.turbo", 14 | "test:watch": "turbo run test:watch --no-daemon --cache-dir=.turbo", 15 | "buf:generate": "turbo run buf:generate --no-daemon --cache-dir=.turbo", 16 | "format": "prettier --write \"**/*.{ts,tsx,md}\"" 17 | }, 18 | "devDependencies": { 19 | "@types/node": "^20.10.1", 20 | "eslint-config-custom": "workspace:*", 21 | "jest": "^29.7.0", 22 | "prettier": "^3.1.0", 23 | "ts-jest": "^29.1.1", 24 | "turbo": "^1.10.16", 25 | "typescript": "^5.3.2", 26 | "@arethetypeswrong/cli": "^0.13.2" 27 | }, 28 | "engines": { 29 | "node": ">=18.16.0", 30 | "pnpm": ">=8.3.1" 31 | }, 32 | "packageManager": "pnpm@8.3.1" 33 | } 34 | -------------------------------------------------------------------------------- /packages/eslint-config-custom/index.js: -------------------------------------------------------------------------------- 1 | // Copyright 2023-2024 Buf Technologies, Inc. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | /** @type { import('eslint').Linter.Config } */ 16 | module.exports = { 17 | env: { 18 | browser: true, 19 | es2021: true, 20 | node: true, 21 | }, 22 | ignorePatterns: [ 23 | "dist/**", 24 | "node_modules/**", 25 | "src/**/*.test.ts", 26 | "jest.config.js", 27 | ], 28 | parser: "@typescript-eslint/parser", 29 | parserOptions: { 30 | sourceType: "module", 31 | project: "./tsconfig.json", // Because we use turbo this is relative to the package root. 32 | }, 33 | plugins: ["@typescript-eslint", "notice"], 34 | extends: [ 35 | "eslint:recommended", 36 | "plugin:@typescript-eslint/recommended", 37 | "plugin:@typescript-eslint/recommended-requiring-type-checking", 38 | "turbo", 39 | "prettier", 40 | ], 41 | rules: { 42 | "no-console": "error", 43 | "@typescript-eslint/strict-boolean-expressions": "error", 44 | "@typescript-eslint/no-unnecessary-condition": "error", 45 | "@typescript-eslint/array-type": "off", // we use complex typings, where Array is actually more readable than T[] 46 | "@typescript-eslint/switch-exhaustiveness-check": "error", 47 | "@typescript-eslint/prefer-nullish-coalescing": "error", 48 | "@typescript-eslint/no-unnecessary-boolean-literal-compare": "error", 49 | "@typescript-eslint/no-invalid-void-type": "error", 50 | "@typescript-eslint/no-base-to-string": "error", 51 | "notice/notice": [ 52 | "error", 53 | { 54 | templateFile: "../eslint-config-custom/license-header", 55 | }, 56 | ], 57 | }, 58 | }; 59 | -------------------------------------------------------------------------------- /packages/eslint-config-custom/license-header: -------------------------------------------------------------------------------- 1 | // Copyright 2023-2024 Buf Technologies, Inc. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. -------------------------------------------------------------------------------- /packages/eslint-config-custom/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "eslint-config-custom", 3 | "version": "0.0.0", 4 | "main": "index.js", 5 | "license": "MIT", 6 | "dependencies": { 7 | "@typescript-eslint/eslint-plugin": "^6.12.0", 8 | "@typescript-eslint/parser": "^6.13.1", 9 | "eslint-plugin-notice": "^0.9.10", 10 | "eslint": "^8.54.0", 11 | "eslint-config-prettier": "^9.0.0", 12 | "eslint-config-turbo": "^1.10.16" 13 | }, 14 | "devDependencies": { 15 | "typescript": "^5.3.2" 16 | }, 17 | "publishConfig": { 18 | "access": "public" 19 | }, 20 | "files": [ 21 | "license-header" 22 | ] 23 | } 24 | -------------------------------------------------------------------------------- /packages/knit-test-spec/buf.gen.yaml: -------------------------------------------------------------------------------- 1 | version: v1 2 | plugins: 3 | - plugin: knit-ts 4 | path: ./node_modules/.bin/protoc-gen-knit-ts 5 | out: . 6 | - plugin: es 7 | path: ./node_modules/.bin/protoc-gen-es 8 | out: . 9 | - plugin: connect-es 10 | path: ./node_modules/.bin/protoc-gen-connect-es 11 | out: . 12 | -------------------------------------------------------------------------------- /packages/knit-test-spec/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "@bufbuild/knit-test-spec", 3 | "version": "0.0.0", 4 | "description": "Contains the generated test data", 5 | "private": true, 6 | "type": "module", 7 | "scripts": { 8 | "buf:generate": "buf generate ./proto" 9 | }, 10 | "peerDependencies": { 11 | "@bufbuild/protobuf": "^1.5.0" 12 | }, 13 | "devDependencies": { 14 | "@bufbuild/buf": "^1.28.1", 15 | "@bufbuild/protobuf": "^1.5.0", 16 | "@bufbuild/protoc-gen-es": "^1.5.0", 17 | "@bufbuild/protoc-gen-knit-ts": "workspace:*", 18 | "@connectrpc/protoc-gen-connect-es": "^1.1.3" 19 | } 20 | } -------------------------------------------------------------------------------- /packages/knit-test-spec/proto/buf.lock: -------------------------------------------------------------------------------- 1 | # Generated by buf. DO NOT EDIT. 2 | version: v1 3 | deps: 4 | - remote: buf.build 5 | owner: bufbuild 6 | repository: knit 7 | commit: 3dc602456973471584684e4878f99b10 8 | digest: shake256:5909694f816b2ebb5a502fadcb722a3cb73c217c4e118508c41219009b91d2b2b484fd6b5d9eb5b972f1fe9244ab24783a191d859390f9e6e36ee5a6c2479823 9 | -------------------------------------------------------------------------------- /packages/knit-test-spec/proto/buf.yaml: -------------------------------------------------------------------------------- 1 | version: v1 2 | deps: 3 | - buf.build/bufbuild/knit 4 | lint: 5 | use: 6 | - MINIMAL 7 | -------------------------------------------------------------------------------- /packages/knit-test-spec/proto/spec/all.proto: -------------------------------------------------------------------------------- 1 | syntax = "proto3"; 2 | 3 | package spec; 4 | 5 | import "spec/enum.proto"; 6 | import "spec/map.proto"; 7 | import "spec/messages.proto"; 8 | import "spec/oneof.proto"; 9 | import "spec/scalars.proto"; 10 | import "spec/wkt.proto"; 11 | 12 | message All { 13 | All self = 1; 14 | Wkt wkt = 2; 15 | Scalar scalars = 3; 16 | Map map = 4; 17 | Oneof oneof = 5; 18 | Message message = 6; 19 | TopLevel enum = 7; 20 | EnumShell enum_shell = 8; 21 | } 22 | 23 | service AllService { 24 | rpc GetAll(All) returns (All) { 25 | option idempotency_level = NO_SIDE_EFFECTS; 26 | } 27 | rpc CreateAll(All) returns (All); 28 | rpc StreamAll(All) returns (stream All); 29 | rpc ClientAll(stream All) returns (All); 30 | rpc BiDiAll(stream All) returns (stream All); 31 | } 32 | -------------------------------------------------------------------------------- /packages/knit-test-spec/proto/spec/enum.proto: -------------------------------------------------------------------------------- 1 | syntax = "proto3"; 2 | 3 | package spec; 4 | 5 | enum TopLevel { 6 | FIRST = 0; 7 | SECOND = 1; 8 | } 9 | 10 | message EnumShell { 11 | enum InsideMessage { 12 | THIRD = 0; 13 | FOURTH = 1; 14 | } 15 | optional InsideMessage optional_enum = 1; 16 | } 17 | -------------------------------------------------------------------------------- /packages/knit-test-spec/proto/spec/json.proto: -------------------------------------------------------------------------------- 1 | syntax = "proto3"; 2 | 3 | package spec; 4 | 5 | message CustomJsonName { 6 | string name = 1 [json_name = "not_name"]; 7 | } 8 | -------------------------------------------------------------------------------- /packages/knit-test-spec/proto/spec/map.proto: -------------------------------------------------------------------------------- 1 | syntax = "proto3"; 2 | 3 | package spec; 4 | 5 | message Map { 6 | Keys keys = 1; 7 | map message = 2; 8 | map enum = 3; 9 | } 10 | 11 | message Keys { 12 | map str = 1; 13 | map bl = 2; 14 | map i32 = 3; 15 | map i64 = 4; 16 | map u32 = 5; 17 | map u64 = 6; 18 | map s32 = 7; 19 | map s64 = 8; 20 | map f32 = 9; 21 | map f64 = 10; 22 | map sf32 = 11; 23 | map sf64 = 12; 24 | } 25 | 26 | enum MapEnum { 27 | MAP_ENUM_UNSPECIFIED = 0; 28 | MAP_ENUM_FIRST = 1; 29 | } 30 | -------------------------------------------------------------------------------- /packages/knit-test-spec/proto/spec/messages.proto: -------------------------------------------------------------------------------- 1 | syntax = "proto3"; 2 | 3 | package spec; 4 | 5 | message Message { 6 | string id = 1; 7 | message Inner { 8 | optional Message mess = 1; 9 | message WithinInner { 10 | float fl = 1; 11 | } 12 | } 13 | Inner inner = 2; 14 | Inner.WithinInner within_inner = 3; 15 | Message self = 4; 16 | repeated Message selfs = 5; 17 | map self_map = 6; 18 | } 19 | -------------------------------------------------------------------------------- /packages/knit-test-spec/proto/spec/oneof.proto: -------------------------------------------------------------------------------- 1 | syntax = "proto3"; 2 | 3 | package spec; 4 | 5 | message Oneof { 6 | oneof oneof_value { 7 | string scalar = 1; 8 | OneofMessage message = 2; 9 | OneofEnum enum = 3; 10 | NestedMessage nestedMessage = 4; 11 | } 12 | } 13 | 14 | message OneofMessage { 15 | string id = 1; 16 | } 17 | 18 | enum OneofEnum { 19 | ONEOF_ENUM_ZERO = 0; 20 | ONEOF_ENUM_TWO = 1; 21 | } 22 | 23 | message NestedMessage { 24 | OneofMessage nested = 1; 25 | } -------------------------------------------------------------------------------- /packages/knit-test-spec/proto/spec/proto2.proto: -------------------------------------------------------------------------------- 1 | syntax = "proto2"; 2 | 3 | package spec; 4 | 5 | message Proto2Message { 6 | required int32 required_field = 1; 7 | optional uint32 optional_field = 2; 8 | optional Proto2Enum enum = 3; 9 | optional Proto2Child child = 4; 10 | } 11 | 12 | enum Proto2Enum { 13 | UNSPECIFIED = 1; 14 | SOMETHING = 2; 15 | } 16 | 17 | message Proto2Child { 18 | optional string id = 1; 19 | } 20 | -------------------------------------------------------------------------------- /packages/knit-test-spec/proto/spec/relations.proto: -------------------------------------------------------------------------------- 1 | syntax = "proto3"; 2 | 3 | package spec; 4 | 5 | import "buf/knit/v1alpha1/options.proto"; 6 | import "spec/all.proto"; 7 | 8 | service AllResolverService { 9 | rpc GetAllRelSelf(GetAllRelSelfRequest) returns (GetAllRelSelfResponse) { 10 | option (buf.knit.v1alpha1.relation).name = "rel_self"; 11 | } 12 | 13 | rpc GetAllRelSelfParam(GetAllRelSelfParamRequest) returns (GetAllRelSelfParamResponse) { 14 | option (buf.knit.v1alpha1.relation).name = "rel_self_param"; 15 | } 16 | } 17 | 18 | message GetAllRelSelfRequest { 19 | repeated All bases = 1; 20 | } 21 | 22 | message GetAllRelSelfResponse { 23 | repeated AllResult values = 1; 24 | message AllResult { 25 | All rel_self = 1; 26 | } 27 | } 28 | 29 | 30 | message GetAllRelSelfParamRequest { 31 | repeated spec.All bases = 1; 32 | string id = 2; 33 | } 34 | 35 | message GetAllRelSelfParamResponse { 36 | repeated AllParamResult values = 1; 37 | message AllParamResult { 38 | All rel_self_param = 1; 39 | } 40 | } -------------------------------------------------------------------------------- /packages/knit-test-spec/proto/spec/scalars.proto: -------------------------------------------------------------------------------- 1 | syntax = "proto3"; 2 | 3 | package spec; 4 | 5 | message Scalar { 6 | ScalarFields fields = 1; 7 | ScalarRepeated repeated = 2; 8 | ScalarMap map = 3; 9 | ScalarOneof oneof = 4; 10 | } 11 | 12 | message ScalarFields { 13 | string str = 1; 14 | bool bl = 2; 15 | int32 i32 = 3; 16 | int64 i64 = 4; 17 | uint32 u32 = 5; 18 | uint64 u64 = 6; 19 | sint32 s32 = 7; 20 | sint64 s64 = 8; 21 | fixed32 f32 = 9; 22 | fixed64 f64 = 10; 23 | sfixed32 sf32 = 11; 24 | sfixed64 sf64 = 12; 25 | bytes by = 13; 26 | double db = 14; 27 | float fl = 15; 28 | } 29 | 30 | message ScalarFieldsOptional { 31 | optional string str = 1; 32 | optional bool bl = 2; 33 | optional int32 i32 = 3; 34 | optional int64 i64 = 4; 35 | optional uint32 u32 = 5; 36 | optional uint64 u64 = 6; 37 | optional sint32 s32 = 7; 38 | optional sint64 s64 = 8; 39 | optional fixed32 f32 = 9; 40 | optional fixed64 f64 = 10; 41 | optional sfixed32 sf32 = 11; 42 | optional sfixed64 sf64 = 12; 43 | optional bytes by = 13; 44 | optional double db = 14; 45 | optional float fl = 15; 46 | } 47 | 48 | message ScalarRepeated { 49 | repeated string str = 1; 50 | repeated bool bl = 2; 51 | repeated int32 i32 = 3; 52 | repeated int64 i64 = 4; 53 | repeated uint32 u32 = 5; 54 | repeated uint64 u64 = 6; 55 | repeated sint32 s32 = 7; 56 | repeated sint64 s64 = 8; 57 | repeated fixed32 f32 = 9; 58 | repeated fixed64 f64 = 10; 59 | repeated sfixed32 sf32 = 11; 60 | repeated sfixed64 sf64 = 12; 61 | repeated bytes by = 13; 62 | repeated double db = 14; 63 | repeated float fl = 15; 64 | } 65 | 66 | message ScalarMap { 67 | map str = 1; 68 | map bl = 2; 69 | map i32 = 3; 70 | map i64 = 4; 71 | map u32 = 5; 72 | map u64 = 6; 73 | map s32 = 7; 74 | map s64 = 8; 75 | map f32 = 9; 76 | map f64 = 10; 77 | map sf32 = 11; 78 | map sf64 = 12; 79 | map by = 13; 80 | map db = 14; 81 | map fl = 15; 82 | } 83 | 84 | message ScalarOneof { 85 | oneof oneof_value { 86 | string str = 1; 87 | bool bl = 2; 88 | int32 i32 = 3; 89 | int64 i64 = 4; 90 | uint32 u32 = 5; 91 | uint64 u64 = 6; 92 | sint32 s32 = 7; 93 | sint64 s64 = 8; 94 | fixed32 f32 = 9; 95 | fixed64 f64 = 10; 96 | sfixed32 sf32 = 11; 97 | sfixed64 sf64 = 12; 98 | bytes by = 13; 99 | double db = 14; 100 | float fl = 15; 101 | } 102 | } 103 | -------------------------------------------------------------------------------- /packages/knit-test-spec/proto/spec/sub/sub.proto: -------------------------------------------------------------------------------- 1 | syntax = "proto3"; 2 | 3 | package spec.sub; 4 | 5 | message SubMessage {} 6 | 7 | service SubService { 8 | rpc SubMethod(SubMessage) returns (SubMessage); 9 | } 10 | -------------------------------------------------------------------------------- /packages/knit-test-spec/proto/spec/wkt.proto: -------------------------------------------------------------------------------- 1 | syntax = "proto3"; 2 | 3 | package spec; 4 | 5 | import "google/protobuf/any.proto"; 6 | import "google/protobuf/duration.proto"; 7 | import "google/protobuf/empty.proto"; 8 | import "google/protobuf/field_mask.proto"; 9 | import "google/protobuf/struct.proto"; 10 | import "google/protobuf/timestamp.proto"; 11 | import "google/protobuf/wrappers.proto"; 12 | 13 | message Wkt { 14 | WktFields fields = 1; 15 | WktOneof oneofs = 2; 16 | WktMap maps = 3; 17 | WktRepeated repeated = 4; 18 | } 19 | 20 | message WktFields { 21 | google.protobuf.DoubleValue double_value = 1; 22 | google.protobuf.BoolValue bool_value = 2; 23 | google.protobuf.FloatValue float_value = 3; 24 | google.protobuf.Int64Value int64_value = 4; 25 | google.protobuf.UInt64Value uint64_value = 5; 26 | google.protobuf.Int32Value int32_value = 6; 27 | google.protobuf.UInt32Value uint32_value = 7; 28 | google.protobuf.StringValue string_value = 8; 29 | google.protobuf.BytesValue bytes_value = 9; 30 | google.protobuf.Any any = 10; 31 | google.protobuf.Duration duration = 11; 32 | google.protobuf.Empty empty = 12; 33 | google.protobuf.FieldMask field_mask = 13; 34 | google.protobuf.Timestamp timestamp = 14; 35 | google.protobuf.Struct struct = 15; 36 | google.protobuf.ListValue list_value = 16; 37 | google.protobuf.Value value = 17; 38 | google.protobuf.NullValue null_value = 18; 39 | } 40 | 41 | message WktOneof { 42 | oneof oneof_value { 43 | google.protobuf.DoubleValue double_value = 1; 44 | google.protobuf.BoolValue bool_value = 2; 45 | google.protobuf.FloatValue float_value = 3; 46 | google.protobuf.Int64Value int64_value = 4; 47 | google.protobuf.UInt64Value uint64_value = 5; 48 | google.protobuf.Int32Value int32_value = 6; 49 | google.protobuf.UInt32Value uint32_value = 7; 50 | google.protobuf.StringValue string_value = 8; 51 | google.protobuf.BytesValue bytes_value = 9; 52 | google.protobuf.Any any = 10; 53 | google.protobuf.Duration duration = 11; 54 | google.protobuf.Empty empty = 12; 55 | google.protobuf.FieldMask field_mask = 13; 56 | google.protobuf.Timestamp timestamp = 14; 57 | google.protobuf.Struct struct = 15; 58 | google.protobuf.ListValue list_value = 16; 59 | google.protobuf.Value value = 17; 60 | google.protobuf.NullValue null_value = 18; 61 | } 62 | } 63 | 64 | message WktMap { 65 | map double_value = 1; 66 | map bool_value = 2; 67 | map float_value = 3; 68 | map int64_value = 4; 69 | map uint64_value = 5; 70 | map int32_value = 6; 71 | map uint32_value = 7; 72 | map string_value = 8; 73 | map bytes_value = 9; 74 | map any = 10; 75 | map duration = 11; 76 | map empty = 12; 77 | map field_mask = 13; 78 | map timestamp = 14; 79 | map struct = 15; 80 | map list_value = 16; 81 | map value = 17; 82 | map null_value = 18; 83 | } 84 | 85 | message WktRepeated { 86 | repeated google.protobuf.DoubleValue double_value = 1; 87 | repeated google.protobuf.BoolValue bool_value = 2; 88 | repeated google.protobuf.FloatValue float_value = 3; 89 | repeated google.protobuf.Int64Value int64_value = 4; 90 | repeated google.protobuf.UInt64Value uint64_value = 5; 91 | repeated google.protobuf.Int32Value int32_value = 6; 92 | repeated google.protobuf.UInt32Value uint32_value = 7; 93 | repeated google.protobuf.StringValue string_value = 8; 94 | repeated google.protobuf.BytesValue bytes_value = 9; 95 | repeated google.protobuf.Any any = 10; 96 | repeated google.protobuf.Duration duration = 11; 97 | repeated google.protobuf.Empty empty = 12; 98 | repeated google.protobuf.FieldMask field_mask = 13; 99 | repeated google.protobuf.Timestamp timestamp = 14; 100 | repeated google.protobuf.Struct struct = 15; 101 | repeated google.protobuf.ListValue list_value = 16; 102 | repeated google.protobuf.Value value = 17; 103 | repeated google.protobuf.NullValue null_value = 18; 104 | } 105 | 106 | service WktService { 107 | rpc GetDoubleValue(google.protobuf.DoubleValue) returns (google.protobuf.DoubleValue); 108 | rpc GetBoolValue(google.protobuf.BoolValue) returns (google.protobuf.BoolValue); 109 | rpc GetFloatValue(google.protobuf.FloatValue) returns (google.protobuf.FloatValue); 110 | rpc GetInt64Value(google.protobuf.Int64Value) returns (google.protobuf.Int64Value); 111 | rpc GetUint64Value(google.protobuf.UInt64Value) returns (google.protobuf.UInt64Value); 112 | rpc GetInt32Value(google.protobuf.Int32Value) returns (google.protobuf.Int32Value); 113 | rpc GetUint32Value(google.protobuf.UInt32Value) returns (google.protobuf.UInt32Value); 114 | rpc GetStringValue(google.protobuf.StringValue) returns (google.protobuf.StringValue); 115 | rpc GetBytesValue(google.protobuf.BytesValue) returns (google.protobuf.BytesValue); 116 | rpc GetAny(google.protobuf.Any) returns (google.protobuf.Any); 117 | rpc GetDuration(google.protobuf.Duration) returns (google.protobuf.Duration); 118 | rpc GetEmpty(google.protobuf.Empty) returns (google.protobuf.Empty); 119 | rpc GetFieldMask(google.protobuf.FieldMask) returns (google.protobuf.FieldMask); 120 | rpc GetTimestamp(google.protobuf.Timestamp) returns (google.protobuf.Timestamp); 121 | rpc GetStruct(google.protobuf.Struct) returns (google.protobuf.Struct); 122 | rpc GetListValue(google.protobuf.ListValue) returns (google.protobuf.ListValue); 123 | rpc GetValue(google.protobuf.Value) returns (google.protobuf.Value); 124 | } 125 | -------------------------------------------------------------------------------- /packages/knit-test-spec/spec/all_connect.d.ts: -------------------------------------------------------------------------------- 1 | // @generated by protoc-gen-connect-es v1.1.3 2 | // @generated from file spec/all.proto (package spec, syntax proto3) 3 | /* eslint-disable */ 4 | // @ts-nocheck 5 | 6 | import { All } from "./all_pb.js"; 7 | import { MethodIdempotency, MethodKind } from "@bufbuild/protobuf"; 8 | 9 | /** 10 | * @generated from service spec.AllService 11 | */ 12 | export declare const AllService: { 13 | readonly typeName: "spec.AllService", 14 | readonly methods: { 15 | /** 16 | * @generated from rpc spec.AllService.GetAll 17 | */ 18 | readonly getAll: { 19 | readonly name: "GetAll", 20 | readonly I: typeof All, 21 | readonly O: typeof All, 22 | readonly kind: MethodKind.Unary, 23 | readonly idempotency: MethodIdempotency.NoSideEffects, 24 | }, 25 | /** 26 | * @generated from rpc spec.AllService.CreateAll 27 | */ 28 | readonly createAll: { 29 | readonly name: "CreateAll", 30 | readonly I: typeof All, 31 | readonly O: typeof All, 32 | readonly kind: MethodKind.Unary, 33 | }, 34 | /** 35 | * @generated from rpc spec.AllService.StreamAll 36 | */ 37 | readonly streamAll: { 38 | readonly name: "StreamAll", 39 | readonly I: typeof All, 40 | readonly O: typeof All, 41 | readonly kind: MethodKind.ServerStreaming, 42 | }, 43 | /** 44 | * @generated from rpc spec.AllService.ClientAll 45 | */ 46 | readonly clientAll: { 47 | readonly name: "ClientAll", 48 | readonly I: typeof All, 49 | readonly O: typeof All, 50 | readonly kind: MethodKind.ClientStreaming, 51 | }, 52 | /** 53 | * @generated from rpc spec.AllService.BiDiAll 54 | */ 55 | readonly biDiAll: { 56 | readonly name: "BiDiAll", 57 | readonly I: typeof All, 58 | readonly O: typeof All, 59 | readonly kind: MethodKind.BiDiStreaming, 60 | }, 61 | } 62 | }; 63 | 64 | -------------------------------------------------------------------------------- /packages/knit-test-spec/spec/all_connect.js: -------------------------------------------------------------------------------- 1 | // @generated by protoc-gen-connect-es v1.1.3 2 | // @generated from file spec/all.proto (package spec, syntax proto3) 3 | /* eslint-disable */ 4 | // @ts-nocheck 5 | 6 | import { All } from "./all_pb.js"; 7 | import { MethodIdempotency, MethodKind } from "@bufbuild/protobuf"; 8 | 9 | /** 10 | * @generated from service spec.AllService 11 | */ 12 | export const AllService = { 13 | typeName: "spec.AllService", 14 | methods: { 15 | /** 16 | * @generated from rpc spec.AllService.GetAll 17 | */ 18 | getAll: { 19 | name: "GetAll", 20 | I: All, 21 | O: All, 22 | kind: MethodKind.Unary, 23 | idempotency: MethodIdempotency.NoSideEffects, 24 | }, 25 | /** 26 | * @generated from rpc spec.AllService.CreateAll 27 | */ 28 | createAll: { 29 | name: "CreateAll", 30 | I: All, 31 | O: All, 32 | kind: MethodKind.Unary, 33 | }, 34 | /** 35 | * @generated from rpc spec.AllService.StreamAll 36 | */ 37 | streamAll: { 38 | name: "StreamAll", 39 | I: All, 40 | O: All, 41 | kind: MethodKind.ServerStreaming, 42 | }, 43 | /** 44 | * @generated from rpc spec.AllService.ClientAll 45 | */ 46 | clientAll: { 47 | name: "ClientAll", 48 | I: All, 49 | O: All, 50 | kind: MethodKind.ClientStreaming, 51 | }, 52 | /** 53 | * @generated from rpc spec.AllService.BiDiAll 54 | */ 55 | biDiAll: { 56 | name: "BiDiAll", 57 | I: All, 58 | O: All, 59 | kind: MethodKind.BiDiStreaming, 60 | }, 61 | } 62 | }; 63 | 64 | -------------------------------------------------------------------------------- /packages/knit-test-spec/spec/all_knit.d.ts: -------------------------------------------------------------------------------- 1 | // @generated by protoc-gen-knit-ts v0.0.7 2 | // @generated from file spec/all.proto (package spec, syntax proto3) 3 | /* eslint-disable */ 4 | // @ts-nocheck 5 | 6 | import type { Wkt } from "./wkt_knit.js"; 7 | import type { Scalar } from "./scalars_knit.js"; 8 | import type { Map } from "./map_knit.js"; 9 | import type { Oneof } from "./oneof_knit.js"; 10 | import type { Message } from "./messages_knit.js"; 11 | import type { EnumShell, TopLevel } from "./enum_knit.js"; 12 | export declare type AllService = { 13 | "spec.AllService": { 14 | fetch: { 15 | getAll: { 16 | $: All; 17 | value: All; 18 | }; 19 | }; 20 | do: { 21 | createAll: { 22 | $: All; 23 | value: All; 24 | }; 25 | }; 26 | listen: { 27 | streamAll: { 28 | $: All; 29 | value: All; 30 | }; 31 | }; 32 | }; 33 | }; 34 | export interface All { 35 | self?: All; 36 | wkt?: Wkt; 37 | scalars?: Scalar; 38 | map?: Map; 39 | oneof?: Oneof; 40 | message?: Message; 41 | enum: { 42 | "@enum": TopLevel; 43 | }; 44 | enumShell?: EnumShell; 45 | } 46 | -------------------------------------------------------------------------------- /packages/knit-test-spec/spec/all_pb.d.ts: -------------------------------------------------------------------------------- 1 | // @generated by protoc-gen-es v1.5.0 2 | // @generated from file spec/all.proto (package spec, syntax proto3) 3 | /* eslint-disable */ 4 | // @ts-nocheck 5 | 6 | import type { BinaryReadOptions, FieldList, JsonReadOptions, JsonValue, PartialMessage, PlainMessage } from "@bufbuild/protobuf"; 7 | import { Message, proto3 } from "@bufbuild/protobuf"; 8 | import type { Wkt } from "./wkt_pb.js"; 9 | import type { Scalar } from "./scalars_pb.js"; 10 | import type { Map } from "./map_pb.js"; 11 | import type { Oneof } from "./oneof_pb.js"; 12 | import type { Message as Message$1 } from "./messages_pb.js"; 13 | import type { EnumShell, TopLevel } from "./enum_pb.js"; 14 | 15 | /** 16 | * @generated from message spec.All 17 | */ 18 | export declare class All extends Message { 19 | /** 20 | * @generated from field: spec.All self = 1; 21 | */ 22 | self?: All; 23 | 24 | /** 25 | * @generated from field: spec.Wkt wkt = 2; 26 | */ 27 | wkt?: Wkt; 28 | 29 | /** 30 | * @generated from field: spec.Scalar scalars = 3; 31 | */ 32 | scalars?: Scalar; 33 | 34 | /** 35 | * @generated from field: spec.Map map = 4; 36 | */ 37 | map?: Map; 38 | 39 | /** 40 | * @generated from field: spec.Oneof oneof = 5; 41 | */ 42 | oneof?: Oneof; 43 | 44 | /** 45 | * @generated from field: spec.Message message = 6; 46 | */ 47 | message?: Message$1; 48 | 49 | /** 50 | * @generated from field: spec.TopLevel enum = 7; 51 | */ 52 | enum: TopLevel; 53 | 54 | /** 55 | * @generated from field: spec.EnumShell enum_shell = 8; 56 | */ 57 | enumShell?: EnumShell; 58 | 59 | constructor(data?: PartialMessage); 60 | 61 | static readonly runtime: typeof proto3; 62 | static readonly typeName = "spec.All"; 63 | static readonly fields: FieldList; 64 | 65 | static fromBinary(bytes: Uint8Array, options?: Partial): All; 66 | 67 | static fromJson(jsonValue: JsonValue, options?: Partial): All; 68 | 69 | static fromJsonString(jsonString: string, options?: Partial): All; 70 | 71 | static equals(a: All | PlainMessage | undefined, b: All | PlainMessage | undefined): boolean; 72 | } 73 | 74 | -------------------------------------------------------------------------------- /packages/knit-test-spec/spec/all_pb.js: -------------------------------------------------------------------------------- 1 | // @generated by protoc-gen-es v1.5.0 2 | // @generated from file spec/all.proto (package spec, syntax proto3) 3 | /* eslint-disable */ 4 | // @ts-nocheck 5 | 6 | import { proto3 } from "@bufbuild/protobuf"; 7 | import { Wkt } from "./wkt_pb.js"; 8 | import { Scalar } from "./scalars_pb.js"; 9 | import { Map } from "./map_pb.js"; 10 | import { Oneof } from "./oneof_pb.js"; 11 | import { Message } from "./messages_pb.js"; 12 | import { EnumShell, TopLevel } from "./enum_pb.js"; 13 | 14 | /** 15 | * @generated from message spec.All 16 | */ 17 | export const All = proto3.makeMessageType( 18 | "spec.All", 19 | () => [ 20 | { no: 1, name: "self", kind: "message", T: All }, 21 | { no: 2, name: "wkt", kind: "message", T: Wkt }, 22 | { no: 3, name: "scalars", kind: "message", T: Scalar }, 23 | { no: 4, name: "map", kind: "message", T: Map }, 24 | { no: 5, name: "oneof", kind: "message", T: Oneof }, 25 | { no: 6, name: "message", kind: "message", T: Message }, 26 | { no: 7, name: "enum", kind: "enum", T: proto3.getEnumType(TopLevel) }, 27 | { no: 8, name: "enum_shell", kind: "message", T: EnumShell }, 28 | ], 29 | ); 30 | 31 | -------------------------------------------------------------------------------- /packages/knit-test-spec/spec/enum_knit.d.ts: -------------------------------------------------------------------------------- 1 | // @generated by protoc-gen-knit-ts v0.0.7 2 | // @generated from file spec/enum.proto (package spec, syntax proto3) 3 | /* eslint-disable */ 4 | // @ts-nocheck 5 | 6 | export interface EnumShell { 7 | optionalEnum?: { 8 | "@enum": EnumShell_InsideMessage; 9 | }; 10 | } 11 | export declare type EnumShell_InsideMessage = "THIRD" | "FOURTH" | number; 12 | export declare type TopLevel = "FIRST" | "SECOND" | number; 13 | -------------------------------------------------------------------------------- /packages/knit-test-spec/spec/enum_pb.d.ts: -------------------------------------------------------------------------------- 1 | // @generated by protoc-gen-es v1.5.0 2 | // @generated from file spec/enum.proto (package spec, syntax proto3) 3 | /* eslint-disable */ 4 | // @ts-nocheck 5 | 6 | import type { BinaryReadOptions, FieldList, JsonReadOptions, JsonValue, PartialMessage, PlainMessage } from "@bufbuild/protobuf"; 7 | import { Message, proto3 } from "@bufbuild/protobuf"; 8 | 9 | /** 10 | * @generated from enum spec.TopLevel 11 | */ 12 | export declare enum TopLevel { 13 | /** 14 | * @generated from enum value: FIRST = 0; 15 | */ 16 | FIRST = 0, 17 | 18 | /** 19 | * @generated from enum value: SECOND = 1; 20 | */ 21 | SECOND = 1, 22 | } 23 | 24 | /** 25 | * @generated from message spec.EnumShell 26 | */ 27 | export declare class EnumShell extends Message { 28 | /** 29 | * @generated from field: optional spec.EnumShell.InsideMessage optional_enum = 1; 30 | */ 31 | optionalEnum?: EnumShell_InsideMessage; 32 | 33 | constructor(data?: PartialMessage); 34 | 35 | static readonly runtime: typeof proto3; 36 | static readonly typeName = "spec.EnumShell"; 37 | static readonly fields: FieldList; 38 | 39 | static fromBinary(bytes: Uint8Array, options?: Partial): EnumShell; 40 | 41 | static fromJson(jsonValue: JsonValue, options?: Partial): EnumShell; 42 | 43 | static fromJsonString(jsonString: string, options?: Partial): EnumShell; 44 | 45 | static equals(a: EnumShell | PlainMessage | undefined, b: EnumShell | PlainMessage | undefined): boolean; 46 | } 47 | 48 | /** 49 | * @generated from enum spec.EnumShell.InsideMessage 50 | */ 51 | export declare enum EnumShell_InsideMessage { 52 | /** 53 | * @generated from enum value: THIRD = 0; 54 | */ 55 | THIRD = 0, 56 | 57 | /** 58 | * @generated from enum value: FOURTH = 1; 59 | */ 60 | FOURTH = 1, 61 | } 62 | 63 | -------------------------------------------------------------------------------- /packages/knit-test-spec/spec/enum_pb.js: -------------------------------------------------------------------------------- 1 | // @generated by protoc-gen-es v1.5.0 2 | // @generated from file spec/enum.proto (package spec, syntax proto3) 3 | /* eslint-disable */ 4 | // @ts-nocheck 5 | 6 | import { proto3 } from "@bufbuild/protobuf"; 7 | 8 | /** 9 | * @generated from enum spec.TopLevel 10 | */ 11 | export const TopLevel = proto3.makeEnum( 12 | "spec.TopLevel", 13 | [ 14 | {no: 0, name: "FIRST"}, 15 | {no: 1, name: "SECOND"}, 16 | ], 17 | ); 18 | 19 | /** 20 | * @generated from message spec.EnumShell 21 | */ 22 | export const EnumShell = proto3.makeMessageType( 23 | "spec.EnumShell", 24 | () => [ 25 | { no: 1, name: "optional_enum", kind: "enum", T: proto3.getEnumType(EnumShell_InsideMessage), opt: true }, 26 | ], 27 | ); 28 | 29 | /** 30 | * @generated from enum spec.EnumShell.InsideMessage 31 | */ 32 | export const EnumShell_InsideMessage = proto3.makeEnum( 33 | "spec.EnumShell.InsideMessage", 34 | [ 35 | {no: 0, name: "THIRD"}, 36 | {no: 1, name: "FOURTH"}, 37 | ], 38 | ); 39 | 40 | -------------------------------------------------------------------------------- /packages/knit-test-spec/spec/json_knit.d.ts: -------------------------------------------------------------------------------- 1 | // @generated by protoc-gen-knit-ts v0.0.7 2 | // @generated from file spec/json.proto (package spec, syntax proto3) 3 | /* eslint-disable */ 4 | // @ts-nocheck 5 | 6 | export interface CustomJsonName { 7 | name: { 8 | "@alias": "not_name"; 9 | value: string; 10 | }; 11 | } 12 | -------------------------------------------------------------------------------- /packages/knit-test-spec/spec/json_pb.d.ts: -------------------------------------------------------------------------------- 1 | // @generated by protoc-gen-es v1.5.0 2 | // @generated from file spec/json.proto (package spec, syntax proto3) 3 | /* eslint-disable */ 4 | // @ts-nocheck 5 | 6 | import type { BinaryReadOptions, FieldList, JsonReadOptions, JsonValue, PartialMessage, PlainMessage } from "@bufbuild/protobuf"; 7 | import { Message, proto3 } from "@bufbuild/protobuf"; 8 | 9 | /** 10 | * @generated from message spec.CustomJsonName 11 | */ 12 | export declare class CustomJsonName extends Message { 13 | /** 14 | * @generated from field: string name = 1 [json_name = "not_name"]; 15 | */ 16 | name: string; 17 | 18 | constructor(data?: PartialMessage); 19 | 20 | static readonly runtime: typeof proto3; 21 | static readonly typeName = "spec.CustomJsonName"; 22 | static readonly fields: FieldList; 23 | 24 | static fromBinary(bytes: Uint8Array, options?: Partial): CustomJsonName; 25 | 26 | static fromJson(jsonValue: JsonValue, options?: Partial): CustomJsonName; 27 | 28 | static fromJsonString(jsonString: string, options?: Partial): CustomJsonName; 29 | 30 | static equals(a: CustomJsonName | PlainMessage | undefined, b: CustomJsonName | PlainMessage | undefined): boolean; 31 | } 32 | 33 | -------------------------------------------------------------------------------- /packages/knit-test-spec/spec/json_pb.js: -------------------------------------------------------------------------------- 1 | // @generated by protoc-gen-es v1.5.0 2 | // @generated from file spec/json.proto (package spec, syntax proto3) 3 | /* eslint-disable */ 4 | // @ts-nocheck 5 | 6 | import { proto3 } from "@bufbuild/protobuf"; 7 | 8 | /** 9 | * @generated from message spec.CustomJsonName 10 | */ 11 | export const CustomJsonName = proto3.makeMessageType( 12 | "spec.CustomJsonName", 13 | () => [ 14 | { no: 1, name: "name", jsonName: "not_name", kind: "scalar", T: 9 /* ScalarType.STRING */ }, 15 | ], 16 | ); 17 | 18 | -------------------------------------------------------------------------------- /packages/knit-test-spec/spec/map_knit.d.ts: -------------------------------------------------------------------------------- 1 | // @generated by protoc-gen-knit-ts v0.0.7 2 | // @generated from file spec/map.proto (package spec, syntax proto3) 3 | /* eslint-disable */ 4 | // @ts-nocheck 5 | 6 | export interface Map { 7 | keys?: Keys; 8 | message: { 9 | "@map": { 10 | [k: string]: Map; 11 | }; 12 | }; 13 | enum: { 14 | "@map": { 15 | [k: string]: { 16 | "@enum": MapEnum; 17 | }; 18 | }; 19 | }; 20 | } 21 | export interface Keys { 22 | str: { 23 | "@map": { 24 | [k: string]: string; 25 | }; 26 | }; 27 | bl: { 28 | "@map": { 29 | [k: string]: string; 30 | }; 31 | }; 32 | i32: { 33 | "@map": { 34 | [k: number]: string; 35 | }; 36 | }; 37 | i64: { 38 | "@map": { 39 | [k: string]: string; 40 | }; 41 | }; 42 | u32: { 43 | "@map": { 44 | [k: number]: string; 45 | }; 46 | }; 47 | u64: { 48 | "@map": { 49 | [k: string]: string; 50 | }; 51 | }; 52 | s32: { 53 | "@map": { 54 | [k: number]: string; 55 | }; 56 | }; 57 | s64: { 58 | "@map": { 59 | [k: string]: string; 60 | }; 61 | }; 62 | f32: { 63 | "@map": { 64 | [k: number]: string; 65 | }; 66 | }; 67 | f64: { 68 | "@map": { 69 | [k: string]: string; 70 | }; 71 | }; 72 | sf32: { 73 | "@map": { 74 | [k: number]: string; 75 | }; 76 | }; 77 | sf64: { 78 | "@map": { 79 | [k: string]: string; 80 | }; 81 | }; 82 | } 83 | export declare type MapEnum = "MAP_ENUM_UNSPECIFIED" | "MAP_ENUM_FIRST" | number; 84 | -------------------------------------------------------------------------------- /packages/knit-test-spec/spec/map_pb.d.ts: -------------------------------------------------------------------------------- 1 | // @generated by protoc-gen-es v1.5.0 2 | // @generated from file spec/map.proto (package spec, syntax proto3) 3 | /* eslint-disable */ 4 | // @ts-nocheck 5 | 6 | import type { BinaryReadOptions, FieldList, JsonReadOptions, JsonValue, PartialMessage, PlainMessage } from "@bufbuild/protobuf"; 7 | import { Message, proto3 } from "@bufbuild/protobuf"; 8 | 9 | /** 10 | * @generated from enum spec.MapEnum 11 | */ 12 | export declare enum MapEnum { 13 | /** 14 | * @generated from enum value: MAP_ENUM_UNSPECIFIED = 0; 15 | */ 16 | UNSPECIFIED = 0, 17 | 18 | /** 19 | * @generated from enum value: MAP_ENUM_FIRST = 1; 20 | */ 21 | FIRST = 1, 22 | } 23 | 24 | /** 25 | * @generated from message spec.Map 26 | */ 27 | export declare class Map extends Message { 28 | /** 29 | * @generated from field: spec.Keys keys = 1; 30 | */ 31 | keys?: Keys; 32 | 33 | /** 34 | * @generated from field: map message = 2; 35 | */ 36 | message: { [key: string]: Map }; 37 | 38 | /** 39 | * @generated from field: map enum = 3; 40 | */ 41 | enum: { [key: string]: MapEnum }; 42 | 43 | constructor(data?: PartialMessage); 44 | 45 | static readonly runtime: typeof proto3; 46 | static readonly typeName = "spec.Map"; 47 | static readonly fields: FieldList; 48 | 49 | static fromBinary(bytes: Uint8Array, options?: Partial): Map; 50 | 51 | static fromJson(jsonValue: JsonValue, options?: Partial): Map; 52 | 53 | static fromJsonString(jsonString: string, options?: Partial): Map; 54 | 55 | static equals(a: Map | PlainMessage | undefined, b: Map | PlainMessage | undefined): boolean; 56 | } 57 | 58 | /** 59 | * @generated from message spec.Keys 60 | */ 61 | export declare class Keys extends Message { 62 | /** 63 | * @generated from field: map str = 1; 64 | */ 65 | str: { [key: string]: string }; 66 | 67 | /** 68 | * @generated from field: map bl = 2; 69 | */ 70 | bl: { [key: string]: string }; 71 | 72 | /** 73 | * @generated from field: map i32 = 3; 74 | */ 75 | i32: { [key: number]: string }; 76 | 77 | /** 78 | * @generated from field: map i64 = 4; 79 | */ 80 | i64: { [key: string]: string }; 81 | 82 | /** 83 | * @generated from field: map u32 = 5; 84 | */ 85 | u32: { [key: number]: string }; 86 | 87 | /** 88 | * @generated from field: map u64 = 6; 89 | */ 90 | u64: { [key: string]: string }; 91 | 92 | /** 93 | * @generated from field: map s32 = 7; 94 | */ 95 | s32: { [key: number]: string }; 96 | 97 | /** 98 | * @generated from field: map s64 = 8; 99 | */ 100 | s64: { [key: string]: string }; 101 | 102 | /** 103 | * @generated from field: map f32 = 9; 104 | */ 105 | f32: { [key: number]: string }; 106 | 107 | /** 108 | * @generated from field: map f64 = 10; 109 | */ 110 | f64: { [key: string]: string }; 111 | 112 | /** 113 | * @generated from field: map sf32 = 11; 114 | */ 115 | sf32: { [key: number]: string }; 116 | 117 | /** 118 | * @generated from field: map sf64 = 12; 119 | */ 120 | sf64: { [key: string]: string }; 121 | 122 | constructor(data?: PartialMessage); 123 | 124 | static readonly runtime: typeof proto3; 125 | static readonly typeName = "spec.Keys"; 126 | static readonly fields: FieldList; 127 | 128 | static fromBinary(bytes: Uint8Array, options?: Partial): Keys; 129 | 130 | static fromJson(jsonValue: JsonValue, options?: Partial): Keys; 131 | 132 | static fromJsonString(jsonString: string, options?: Partial): Keys; 133 | 134 | static equals(a: Keys | PlainMessage | undefined, b: Keys | PlainMessage | undefined): boolean; 135 | } 136 | 137 | -------------------------------------------------------------------------------- /packages/knit-test-spec/spec/map_pb.js: -------------------------------------------------------------------------------- 1 | // @generated by protoc-gen-es v1.5.0 2 | // @generated from file spec/map.proto (package spec, syntax proto3) 3 | /* eslint-disable */ 4 | // @ts-nocheck 5 | 6 | import { proto3 } from "@bufbuild/protobuf"; 7 | 8 | /** 9 | * @generated from enum spec.MapEnum 10 | */ 11 | export const MapEnum = proto3.makeEnum( 12 | "spec.MapEnum", 13 | [ 14 | {no: 0, name: "MAP_ENUM_UNSPECIFIED", localName: "UNSPECIFIED"}, 15 | {no: 1, name: "MAP_ENUM_FIRST", localName: "FIRST"}, 16 | ], 17 | ); 18 | 19 | /** 20 | * @generated from message spec.Map 21 | */ 22 | export const Map = proto3.makeMessageType( 23 | "spec.Map", 24 | () => [ 25 | { no: 1, name: "keys", kind: "message", T: Keys }, 26 | { no: 2, name: "message", kind: "map", K: 9 /* ScalarType.STRING */, V: {kind: "message", T: Map} }, 27 | { no: 3, name: "enum", kind: "map", K: 9 /* ScalarType.STRING */, V: {kind: "enum", T: proto3.getEnumType(MapEnum)} }, 28 | ], 29 | ); 30 | 31 | /** 32 | * @generated from message spec.Keys 33 | */ 34 | export const Keys = proto3.makeMessageType( 35 | "spec.Keys", 36 | () => [ 37 | { no: 1, name: "str", kind: "map", K: 9 /* ScalarType.STRING */, V: {kind: "scalar", T: 9 /* ScalarType.STRING */} }, 38 | { no: 2, name: "bl", kind: "map", K: 8 /* ScalarType.BOOL */, V: {kind: "scalar", T: 9 /* ScalarType.STRING */} }, 39 | { no: 3, name: "i32", kind: "map", K: 5 /* ScalarType.INT32 */, V: {kind: "scalar", T: 9 /* ScalarType.STRING */} }, 40 | { no: 4, name: "i64", kind: "map", K: 3 /* ScalarType.INT64 */, V: {kind: "scalar", T: 9 /* ScalarType.STRING */} }, 41 | { no: 5, name: "u32", kind: "map", K: 13 /* ScalarType.UINT32 */, V: {kind: "scalar", T: 9 /* ScalarType.STRING */} }, 42 | { no: 6, name: "u64", kind: "map", K: 4 /* ScalarType.UINT64 */, V: {kind: "scalar", T: 9 /* ScalarType.STRING */} }, 43 | { no: 7, name: "s32", kind: "map", K: 17 /* ScalarType.SINT32 */, V: {kind: "scalar", T: 9 /* ScalarType.STRING */} }, 44 | { no: 8, name: "s64", kind: "map", K: 18 /* ScalarType.SINT64 */, V: {kind: "scalar", T: 9 /* ScalarType.STRING */} }, 45 | { no: 9, name: "f32", kind: "map", K: 7 /* ScalarType.FIXED32 */, V: {kind: "scalar", T: 9 /* ScalarType.STRING */} }, 46 | { no: 10, name: "f64", kind: "map", K: 6 /* ScalarType.FIXED64 */, V: {kind: "scalar", T: 9 /* ScalarType.STRING */} }, 47 | { no: 11, name: "sf32", kind: "map", K: 15 /* ScalarType.SFIXED32 */, V: {kind: "scalar", T: 9 /* ScalarType.STRING */} }, 48 | { no: 12, name: "sf64", kind: "map", K: 16 /* ScalarType.SFIXED64 */, V: {kind: "scalar", T: 9 /* ScalarType.STRING */} }, 49 | ], 50 | ); 51 | 52 | -------------------------------------------------------------------------------- /packages/knit-test-spec/spec/messages_knit.d.ts: -------------------------------------------------------------------------------- 1 | // @generated by protoc-gen-knit-ts v0.0.7 2 | // @generated from file spec/messages.proto (package spec, syntax proto3) 3 | /* eslint-disable */ 4 | // @ts-nocheck 5 | 6 | export interface Message { 7 | id: string; 8 | inner?: Message_Inner; 9 | withinInner?: Message_Inner_WithinInner; 10 | self?: Message; 11 | selfs: Array; 12 | selfMap: { 13 | "@map": { 14 | [k: string]: Message; 15 | }; 16 | }; 17 | } 18 | export interface Message_Inner { 19 | mess?: Message; 20 | } 21 | export interface Message_Inner_WithinInner { 22 | fl: number; 23 | } 24 | -------------------------------------------------------------------------------- /packages/knit-test-spec/spec/messages_pb.d.ts: -------------------------------------------------------------------------------- 1 | // @generated by protoc-gen-es v1.5.0 2 | // @generated from file spec/messages.proto (package spec, syntax proto3) 3 | /* eslint-disable */ 4 | // @ts-nocheck 5 | 6 | import type { BinaryReadOptions, FieldList, JsonReadOptions, JsonValue, PartialMessage, PlainMessage } from "@bufbuild/protobuf"; 7 | import { Message as Message$1, proto3 } from "@bufbuild/protobuf"; 8 | 9 | /** 10 | * @generated from message spec.Message 11 | */ 12 | export declare class Message extends Message$1 { 13 | /** 14 | * @generated from field: string id = 1; 15 | */ 16 | id: string; 17 | 18 | /** 19 | * @generated from field: spec.Message.Inner inner = 2; 20 | */ 21 | inner?: Message_Inner; 22 | 23 | /** 24 | * @generated from field: spec.Message.Inner.WithinInner within_inner = 3; 25 | */ 26 | withinInner?: Message_Inner_WithinInner; 27 | 28 | /** 29 | * @generated from field: spec.Message self = 4; 30 | */ 31 | self?: Message; 32 | 33 | /** 34 | * @generated from field: repeated spec.Message selfs = 5; 35 | */ 36 | selfs: Message[]; 37 | 38 | /** 39 | * @generated from field: map self_map = 6; 40 | */ 41 | selfMap: { [key: string]: Message }; 42 | 43 | constructor(data?: PartialMessage); 44 | 45 | static readonly runtime: typeof proto3; 46 | static readonly typeName = "spec.Message"; 47 | static readonly fields: FieldList; 48 | 49 | static fromBinary(bytes: Uint8Array, options?: Partial): Message; 50 | 51 | static fromJson(jsonValue: JsonValue, options?: Partial): Message; 52 | 53 | static fromJsonString(jsonString: string, options?: Partial): Message; 54 | 55 | static equals(a: Message | PlainMessage | undefined, b: Message | PlainMessage | undefined): boolean; 56 | } 57 | 58 | /** 59 | * @generated from message spec.Message.Inner 60 | */ 61 | export declare class Message_Inner extends Message$1 { 62 | /** 63 | * @generated from field: optional spec.Message mess = 1; 64 | */ 65 | mess?: Message; 66 | 67 | constructor(data?: PartialMessage); 68 | 69 | static readonly runtime: typeof proto3; 70 | static readonly typeName = "spec.Message.Inner"; 71 | static readonly fields: FieldList; 72 | 73 | static fromBinary(bytes: Uint8Array, options?: Partial): Message_Inner; 74 | 75 | static fromJson(jsonValue: JsonValue, options?: Partial): Message_Inner; 76 | 77 | static fromJsonString(jsonString: string, options?: Partial): Message_Inner; 78 | 79 | static equals(a: Message_Inner | PlainMessage | undefined, b: Message_Inner | PlainMessage | undefined): boolean; 80 | } 81 | 82 | /** 83 | * @generated from message spec.Message.Inner.WithinInner 84 | */ 85 | export declare class Message_Inner_WithinInner extends Message$1 { 86 | /** 87 | * @generated from field: float fl = 1; 88 | */ 89 | fl: number; 90 | 91 | constructor(data?: PartialMessage); 92 | 93 | static readonly runtime: typeof proto3; 94 | static readonly typeName = "spec.Message.Inner.WithinInner"; 95 | static readonly fields: FieldList; 96 | 97 | static fromBinary(bytes: Uint8Array, options?: Partial): Message_Inner_WithinInner; 98 | 99 | static fromJson(jsonValue: JsonValue, options?: Partial): Message_Inner_WithinInner; 100 | 101 | static fromJsonString(jsonString: string, options?: Partial): Message_Inner_WithinInner; 102 | 103 | static equals(a: Message_Inner_WithinInner | PlainMessage | undefined, b: Message_Inner_WithinInner | PlainMessage | undefined): boolean; 104 | } 105 | 106 | -------------------------------------------------------------------------------- /packages/knit-test-spec/spec/messages_pb.js: -------------------------------------------------------------------------------- 1 | // @generated by protoc-gen-es v1.5.0 2 | // @generated from file spec/messages.proto (package spec, syntax proto3) 3 | /* eslint-disable */ 4 | // @ts-nocheck 5 | 6 | import { proto3 } from "@bufbuild/protobuf"; 7 | 8 | /** 9 | * @generated from message spec.Message 10 | */ 11 | export const Message = proto3.makeMessageType( 12 | "spec.Message", 13 | () => [ 14 | { no: 1, name: "id", kind: "scalar", T: 9 /* ScalarType.STRING */ }, 15 | { no: 2, name: "inner", kind: "message", T: Message_Inner }, 16 | { no: 3, name: "within_inner", kind: "message", T: Message_Inner_WithinInner }, 17 | { no: 4, name: "self", kind: "message", T: Message }, 18 | { no: 5, name: "selfs", kind: "message", T: Message, repeated: true }, 19 | { no: 6, name: "self_map", kind: "map", K: 9 /* ScalarType.STRING */, V: {kind: "message", T: Message} }, 20 | ], 21 | ); 22 | 23 | /** 24 | * @generated from message spec.Message.Inner 25 | */ 26 | export const Message_Inner = proto3.makeMessageType( 27 | "spec.Message.Inner", 28 | () => [ 29 | { no: 1, name: "mess", kind: "message", T: Message, opt: true }, 30 | ], 31 | {localName: "Message_Inner"}, 32 | ); 33 | 34 | /** 35 | * @generated from message spec.Message.Inner.WithinInner 36 | */ 37 | export const Message_Inner_WithinInner = proto3.makeMessageType( 38 | "spec.Message.Inner.WithinInner", 39 | () => [ 40 | { no: 1, name: "fl", kind: "scalar", T: 2 /* ScalarType.FLOAT */ }, 41 | ], 42 | {localName: "Message_Inner_WithinInner"}, 43 | ); 44 | 45 | -------------------------------------------------------------------------------- /packages/knit-test-spec/spec/oneof_knit.d.ts: -------------------------------------------------------------------------------- 1 | // @generated by protoc-gen-knit-ts v0.0.7 2 | // @generated from file spec/oneof.proto (package spec, syntax proto3) 3 | /* eslint-disable */ 4 | // @ts-nocheck 5 | 6 | export interface Oneof { 7 | oneofValue?: { 8 | "@oneof": { 9 | scalar: string; 10 | message: OneofMessage; 11 | enum: { 12 | "@enum": OneofEnum; 13 | }; 14 | nestedMessage: NestedMessage; 15 | }; 16 | }; 17 | } 18 | export interface OneofMessage { 19 | id: string; 20 | } 21 | export interface NestedMessage { 22 | nested?: OneofMessage; 23 | } 24 | export declare type OneofEnum = "ONEOF_ENUM_ZERO" | "ONEOF_ENUM_TWO" | number; 25 | -------------------------------------------------------------------------------- /packages/knit-test-spec/spec/oneof_pb.d.ts: -------------------------------------------------------------------------------- 1 | // @generated by protoc-gen-es v1.5.0 2 | // @generated from file spec/oneof.proto (package spec, syntax proto3) 3 | /* eslint-disable */ 4 | // @ts-nocheck 5 | 6 | import type { BinaryReadOptions, FieldList, JsonReadOptions, JsonValue, PartialMessage, PlainMessage } from "@bufbuild/protobuf"; 7 | import { Message, proto3 } from "@bufbuild/protobuf"; 8 | 9 | /** 10 | * @generated from enum spec.OneofEnum 11 | */ 12 | export declare enum OneofEnum { 13 | /** 14 | * @generated from enum value: ONEOF_ENUM_ZERO = 0; 15 | */ 16 | ZERO = 0, 17 | 18 | /** 19 | * @generated from enum value: ONEOF_ENUM_TWO = 1; 20 | */ 21 | TWO = 1, 22 | } 23 | 24 | /** 25 | * @generated from message spec.Oneof 26 | */ 27 | export declare class Oneof extends Message { 28 | /** 29 | * @generated from oneof spec.Oneof.oneof_value 30 | */ 31 | oneofValue: { 32 | /** 33 | * @generated from field: string scalar = 1; 34 | */ 35 | value: string; 36 | case: "scalar"; 37 | } | { 38 | /** 39 | * @generated from field: spec.OneofMessage message = 2; 40 | */ 41 | value: OneofMessage; 42 | case: "message"; 43 | } | { 44 | /** 45 | * @generated from field: spec.OneofEnum enum = 3; 46 | */ 47 | value: OneofEnum; 48 | case: "enum"; 49 | } | { 50 | /** 51 | * @generated from field: spec.NestedMessage nestedMessage = 4; 52 | */ 53 | value: NestedMessage; 54 | case: "nestedMessage"; 55 | } | { case: undefined; value?: undefined }; 56 | 57 | constructor(data?: PartialMessage); 58 | 59 | static readonly runtime: typeof proto3; 60 | static readonly typeName = "spec.Oneof"; 61 | static readonly fields: FieldList; 62 | 63 | static fromBinary(bytes: Uint8Array, options?: Partial): Oneof; 64 | 65 | static fromJson(jsonValue: JsonValue, options?: Partial): Oneof; 66 | 67 | static fromJsonString(jsonString: string, options?: Partial): Oneof; 68 | 69 | static equals(a: Oneof | PlainMessage | undefined, b: Oneof | PlainMessage | undefined): boolean; 70 | } 71 | 72 | /** 73 | * @generated from message spec.OneofMessage 74 | */ 75 | export declare class OneofMessage extends Message { 76 | /** 77 | * @generated from field: string id = 1; 78 | */ 79 | id: string; 80 | 81 | constructor(data?: PartialMessage); 82 | 83 | static readonly runtime: typeof proto3; 84 | static readonly typeName = "spec.OneofMessage"; 85 | static readonly fields: FieldList; 86 | 87 | static fromBinary(bytes: Uint8Array, options?: Partial): OneofMessage; 88 | 89 | static fromJson(jsonValue: JsonValue, options?: Partial): OneofMessage; 90 | 91 | static fromJsonString(jsonString: string, options?: Partial): OneofMessage; 92 | 93 | static equals(a: OneofMessage | PlainMessage | undefined, b: OneofMessage | PlainMessage | undefined): boolean; 94 | } 95 | 96 | /** 97 | * @generated from message spec.NestedMessage 98 | */ 99 | export declare class NestedMessage extends Message { 100 | /** 101 | * @generated from field: spec.OneofMessage nested = 1; 102 | */ 103 | nested?: OneofMessage; 104 | 105 | constructor(data?: PartialMessage); 106 | 107 | static readonly runtime: typeof proto3; 108 | static readonly typeName = "spec.NestedMessage"; 109 | static readonly fields: FieldList; 110 | 111 | static fromBinary(bytes: Uint8Array, options?: Partial): NestedMessage; 112 | 113 | static fromJson(jsonValue: JsonValue, options?: Partial): NestedMessage; 114 | 115 | static fromJsonString(jsonString: string, options?: Partial): NestedMessage; 116 | 117 | static equals(a: NestedMessage | PlainMessage | undefined, b: NestedMessage | PlainMessage | undefined): boolean; 118 | } 119 | 120 | -------------------------------------------------------------------------------- /packages/knit-test-spec/spec/oneof_pb.js: -------------------------------------------------------------------------------- 1 | // @generated by protoc-gen-es v1.5.0 2 | // @generated from file spec/oneof.proto (package spec, syntax proto3) 3 | /* eslint-disable */ 4 | // @ts-nocheck 5 | 6 | import { proto3 } from "@bufbuild/protobuf"; 7 | 8 | /** 9 | * @generated from enum spec.OneofEnum 10 | */ 11 | export const OneofEnum = proto3.makeEnum( 12 | "spec.OneofEnum", 13 | [ 14 | {no: 0, name: "ONEOF_ENUM_ZERO", localName: "ZERO"}, 15 | {no: 1, name: "ONEOF_ENUM_TWO", localName: "TWO"}, 16 | ], 17 | ); 18 | 19 | /** 20 | * @generated from message spec.Oneof 21 | */ 22 | export const Oneof = proto3.makeMessageType( 23 | "spec.Oneof", 24 | () => [ 25 | { no: 1, name: "scalar", kind: "scalar", T: 9 /* ScalarType.STRING */, oneof: "oneof_value" }, 26 | { no: 2, name: "message", kind: "message", T: OneofMessage, oneof: "oneof_value" }, 27 | { no: 3, name: "enum", kind: "enum", T: proto3.getEnumType(OneofEnum), oneof: "oneof_value" }, 28 | { no: 4, name: "nestedMessage", kind: "message", T: NestedMessage, oneof: "oneof_value" }, 29 | ], 30 | ); 31 | 32 | /** 33 | * @generated from message spec.OneofMessage 34 | */ 35 | export const OneofMessage = proto3.makeMessageType( 36 | "spec.OneofMessage", 37 | () => [ 38 | { no: 1, name: "id", kind: "scalar", T: 9 /* ScalarType.STRING */ }, 39 | ], 40 | ); 41 | 42 | /** 43 | * @generated from message spec.NestedMessage 44 | */ 45 | export const NestedMessage = proto3.makeMessageType( 46 | "spec.NestedMessage", 47 | () => [ 48 | { no: 1, name: "nested", kind: "message", T: OneofMessage }, 49 | ], 50 | ); 51 | 52 | -------------------------------------------------------------------------------- /packages/knit-test-spec/spec/proto2_knit.d.ts: -------------------------------------------------------------------------------- 1 | // @generated by protoc-gen-knit-ts v0.0.7 2 | // @generated from file spec/proto2.proto (package spec, syntax proto2) 3 | /* eslint-disable */ 4 | // @ts-nocheck 5 | 6 | export interface Proto2Message { 7 | requiredField: number; 8 | optionalField?: number; 9 | enum?: { 10 | "@enum": Proto2Enum; 11 | }; 12 | child?: Proto2Child; 13 | } 14 | export interface Proto2Child { 15 | id?: string; 16 | } 17 | export declare type Proto2Enum = "UNSPECIFIED" | "SOMETHING" | number; 18 | -------------------------------------------------------------------------------- /packages/knit-test-spec/spec/proto2_pb.d.ts: -------------------------------------------------------------------------------- 1 | // @generated by protoc-gen-es v1.5.0 2 | // @generated from file spec/proto2.proto (package spec, syntax proto2) 3 | /* eslint-disable */ 4 | // @ts-nocheck 5 | 6 | import type { BinaryReadOptions, FieldList, JsonReadOptions, JsonValue, PartialMessage, PlainMessage } from "@bufbuild/protobuf"; 7 | import { Message, proto2 } from "@bufbuild/protobuf"; 8 | 9 | /** 10 | * @generated from enum spec.Proto2Enum 11 | */ 12 | export declare enum Proto2Enum { 13 | /** 14 | * @generated from enum value: UNSPECIFIED = 1; 15 | */ 16 | UNSPECIFIED = 1, 17 | 18 | /** 19 | * @generated from enum value: SOMETHING = 2; 20 | */ 21 | SOMETHING = 2, 22 | } 23 | 24 | /** 25 | * @generated from message spec.Proto2Message 26 | */ 27 | export declare class Proto2Message extends Message { 28 | /** 29 | * @generated from field: required int32 required_field = 1; 30 | */ 31 | requiredField: number; 32 | 33 | /** 34 | * @generated from field: optional uint32 optional_field = 2; 35 | */ 36 | optionalField?: number; 37 | 38 | /** 39 | * @generated from field: optional spec.Proto2Enum enum = 3; 40 | */ 41 | enum?: Proto2Enum; 42 | 43 | /** 44 | * @generated from field: optional spec.Proto2Child child = 4; 45 | */ 46 | child?: Proto2Child; 47 | 48 | constructor(data?: PartialMessage); 49 | 50 | static readonly runtime: typeof proto2; 51 | static readonly typeName = "spec.Proto2Message"; 52 | static readonly fields: FieldList; 53 | 54 | static fromBinary(bytes: Uint8Array, options?: Partial): Proto2Message; 55 | 56 | static fromJson(jsonValue: JsonValue, options?: Partial): Proto2Message; 57 | 58 | static fromJsonString(jsonString: string, options?: Partial): Proto2Message; 59 | 60 | static equals(a: Proto2Message | PlainMessage | undefined, b: Proto2Message | PlainMessage | undefined): boolean; 61 | } 62 | 63 | /** 64 | * @generated from message spec.Proto2Child 65 | */ 66 | export declare class Proto2Child extends Message { 67 | /** 68 | * @generated from field: optional string id = 1; 69 | */ 70 | id?: string; 71 | 72 | constructor(data?: PartialMessage); 73 | 74 | static readonly runtime: typeof proto2; 75 | static readonly typeName = "spec.Proto2Child"; 76 | static readonly fields: FieldList; 77 | 78 | static fromBinary(bytes: Uint8Array, options?: Partial): Proto2Child; 79 | 80 | static fromJson(jsonValue: JsonValue, options?: Partial): Proto2Child; 81 | 82 | static fromJsonString(jsonString: string, options?: Partial): Proto2Child; 83 | 84 | static equals(a: Proto2Child | PlainMessage | undefined, b: Proto2Child | PlainMessage | undefined): boolean; 85 | } 86 | 87 | -------------------------------------------------------------------------------- /packages/knit-test-spec/spec/proto2_pb.js: -------------------------------------------------------------------------------- 1 | // @generated by protoc-gen-es v1.5.0 2 | // @generated from file spec/proto2.proto (package spec, syntax proto2) 3 | /* eslint-disable */ 4 | // @ts-nocheck 5 | 6 | import { proto2 } from "@bufbuild/protobuf"; 7 | 8 | /** 9 | * @generated from enum spec.Proto2Enum 10 | */ 11 | export const Proto2Enum = proto2.makeEnum( 12 | "spec.Proto2Enum", 13 | [ 14 | {no: 1, name: "UNSPECIFIED"}, 15 | {no: 2, name: "SOMETHING"}, 16 | ], 17 | ); 18 | 19 | /** 20 | * @generated from message spec.Proto2Message 21 | */ 22 | export const Proto2Message = proto2.makeMessageType( 23 | "spec.Proto2Message", 24 | () => [ 25 | { no: 1, name: "required_field", kind: "scalar", T: 5 /* ScalarType.INT32 */ }, 26 | { no: 2, name: "optional_field", kind: "scalar", T: 13 /* ScalarType.UINT32 */, opt: true }, 27 | { no: 3, name: "enum", kind: "enum", T: proto2.getEnumType(Proto2Enum), opt: true }, 28 | { no: 4, name: "child", kind: "message", T: Proto2Child, opt: true }, 29 | ], 30 | ); 31 | 32 | /** 33 | * @generated from message spec.Proto2Child 34 | */ 35 | export const Proto2Child = proto2.makeMessageType( 36 | "spec.Proto2Child", 37 | () => [ 38 | { no: 1, name: "id", kind: "scalar", T: 9 /* ScalarType.STRING */, opt: true }, 39 | ], 40 | ); 41 | 42 | -------------------------------------------------------------------------------- /packages/knit-test-spec/spec/relations_connect.d.ts: -------------------------------------------------------------------------------- 1 | // @generated by protoc-gen-connect-es v1.1.3 2 | // @generated from file spec/relations.proto (package spec, syntax proto3) 3 | /* eslint-disable */ 4 | // @ts-nocheck 5 | 6 | import { GetAllRelSelfParamRequest, GetAllRelSelfParamResponse, GetAllRelSelfRequest, GetAllRelSelfResponse } from "./relations_pb.js"; 7 | import { MethodKind } from "@bufbuild/protobuf"; 8 | 9 | /** 10 | * @generated from service spec.AllResolverService 11 | */ 12 | export declare const AllResolverService: { 13 | readonly typeName: "spec.AllResolverService", 14 | readonly methods: { 15 | /** 16 | * @generated from rpc spec.AllResolverService.GetAllRelSelf 17 | */ 18 | readonly getAllRelSelf: { 19 | readonly name: "GetAllRelSelf", 20 | readonly I: typeof GetAllRelSelfRequest, 21 | readonly O: typeof GetAllRelSelfResponse, 22 | readonly kind: MethodKind.Unary, 23 | }, 24 | /** 25 | * @generated from rpc spec.AllResolverService.GetAllRelSelfParam 26 | */ 27 | readonly getAllRelSelfParam: { 28 | readonly name: "GetAllRelSelfParam", 29 | readonly I: typeof GetAllRelSelfParamRequest, 30 | readonly O: typeof GetAllRelSelfParamResponse, 31 | readonly kind: MethodKind.Unary, 32 | }, 33 | } 34 | }; 35 | 36 | -------------------------------------------------------------------------------- /packages/knit-test-spec/spec/relations_connect.js: -------------------------------------------------------------------------------- 1 | // @generated by protoc-gen-connect-es v1.1.3 2 | // @generated from file spec/relations.proto (package spec, syntax proto3) 3 | /* eslint-disable */ 4 | // @ts-nocheck 5 | 6 | import { GetAllRelSelfParamRequest, GetAllRelSelfParamResponse, GetAllRelSelfRequest, GetAllRelSelfResponse } from "./relations_pb.js"; 7 | import { MethodKind } from "@bufbuild/protobuf"; 8 | 9 | /** 10 | * @generated from service spec.AllResolverService 11 | */ 12 | export const AllResolverService = { 13 | typeName: "spec.AllResolverService", 14 | methods: { 15 | /** 16 | * @generated from rpc spec.AllResolverService.GetAllRelSelf 17 | */ 18 | getAllRelSelf: { 19 | name: "GetAllRelSelf", 20 | I: GetAllRelSelfRequest, 21 | O: GetAllRelSelfResponse, 22 | kind: MethodKind.Unary, 23 | }, 24 | /** 25 | * @generated from rpc spec.AllResolverService.GetAllRelSelfParam 26 | */ 27 | getAllRelSelfParam: { 28 | name: "GetAllRelSelfParam", 29 | I: GetAllRelSelfParamRequest, 30 | O: GetAllRelSelfParamResponse, 31 | kind: MethodKind.Unary, 32 | }, 33 | } 34 | }; 35 | 36 | -------------------------------------------------------------------------------- /packages/knit-test-spec/spec/relations_knit.d.ts: -------------------------------------------------------------------------------- 1 | // @generated by protoc-gen-knit-ts v0.0.7 2 | // @generated from file spec/relations.proto (package spec, syntax proto3) 3 | /* eslint-disable */ 4 | // @ts-nocheck 5 | 6 | import type { All } from "./all_knit.js"; 7 | export declare type AllResolverService = { 8 | "spec.AllResolverService": { 9 | fetch: {}; 10 | do: { 11 | getAllRelSelf: { 12 | $: GetAllRelSelfRequest; 13 | value: GetAllRelSelfResponse; 14 | }; 15 | getAllRelSelfParam: { 16 | $: GetAllRelSelfParamRequest; 17 | value: GetAllRelSelfParamResponse; 18 | }; 19 | }; 20 | listen: {}; 21 | }; 22 | }; 23 | export interface GetAllRelSelfRequest { 24 | bases: Array; 25 | } 26 | export interface GetAllRelSelfResponse { 27 | values: Array; 28 | } 29 | export interface GetAllRelSelfResponse_AllResult { 30 | relSelf?: All; 31 | } 32 | export interface GetAllRelSelfParamRequest { 33 | bases: Array; 34 | id: string; 35 | } 36 | export interface GetAllRelSelfParamResponse { 37 | values: Array; 38 | } 39 | export interface GetAllRelSelfParamResponse_AllParamResult { 40 | relSelfParam?: All; 41 | } 42 | declare module "./all_knit.js" { 43 | interface All { 44 | relSelf?: { 45 | $: undefined; 46 | value: GetAllRelSelfResponse_AllResult["relSelf"]; 47 | }; 48 | } 49 | } 50 | declare module "./all_knit.js" { 51 | interface All { 52 | relSelfParam?: { 53 | $: Omit; 54 | value: GetAllRelSelfParamResponse_AllParamResult["relSelfParam"]; 55 | }; 56 | } 57 | } 58 | -------------------------------------------------------------------------------- /packages/knit-test-spec/spec/relations_pb.d.ts: -------------------------------------------------------------------------------- 1 | // @generated by protoc-gen-es v1.5.0 2 | // @generated from file spec/relations.proto (package spec, syntax proto3) 3 | /* eslint-disable */ 4 | // @ts-nocheck 5 | 6 | import type { BinaryReadOptions, FieldList, JsonReadOptions, JsonValue, PartialMessage, PlainMessage } from "@bufbuild/protobuf"; 7 | import { Message, proto3 } from "@bufbuild/protobuf"; 8 | import type { All } from "./all_pb.js"; 9 | 10 | /** 11 | * @generated from message spec.GetAllRelSelfRequest 12 | */ 13 | export declare class GetAllRelSelfRequest extends Message { 14 | /** 15 | * @generated from field: repeated spec.All bases = 1; 16 | */ 17 | bases: All[]; 18 | 19 | constructor(data?: PartialMessage); 20 | 21 | static readonly runtime: typeof proto3; 22 | static readonly typeName = "spec.GetAllRelSelfRequest"; 23 | static readonly fields: FieldList; 24 | 25 | static fromBinary(bytes: Uint8Array, options?: Partial): GetAllRelSelfRequest; 26 | 27 | static fromJson(jsonValue: JsonValue, options?: Partial): GetAllRelSelfRequest; 28 | 29 | static fromJsonString(jsonString: string, options?: Partial): GetAllRelSelfRequest; 30 | 31 | static equals(a: GetAllRelSelfRequest | PlainMessage | undefined, b: GetAllRelSelfRequest | PlainMessage | undefined): boolean; 32 | } 33 | 34 | /** 35 | * @generated from message spec.GetAllRelSelfResponse 36 | */ 37 | export declare class GetAllRelSelfResponse extends Message { 38 | /** 39 | * @generated from field: repeated spec.GetAllRelSelfResponse.AllResult values = 1; 40 | */ 41 | values: GetAllRelSelfResponse_AllResult[]; 42 | 43 | constructor(data?: PartialMessage); 44 | 45 | static readonly runtime: typeof proto3; 46 | static readonly typeName = "spec.GetAllRelSelfResponse"; 47 | static readonly fields: FieldList; 48 | 49 | static fromBinary(bytes: Uint8Array, options?: Partial): GetAllRelSelfResponse; 50 | 51 | static fromJson(jsonValue: JsonValue, options?: Partial): GetAllRelSelfResponse; 52 | 53 | static fromJsonString(jsonString: string, options?: Partial): GetAllRelSelfResponse; 54 | 55 | static equals(a: GetAllRelSelfResponse | PlainMessage | undefined, b: GetAllRelSelfResponse | PlainMessage | undefined): boolean; 56 | } 57 | 58 | /** 59 | * @generated from message spec.GetAllRelSelfResponse.AllResult 60 | */ 61 | export declare class GetAllRelSelfResponse_AllResult extends Message { 62 | /** 63 | * @generated from field: spec.All rel_self = 1; 64 | */ 65 | relSelf?: All; 66 | 67 | constructor(data?: PartialMessage); 68 | 69 | static readonly runtime: typeof proto3; 70 | static readonly typeName = "spec.GetAllRelSelfResponse.AllResult"; 71 | static readonly fields: FieldList; 72 | 73 | static fromBinary(bytes: Uint8Array, options?: Partial): GetAllRelSelfResponse_AllResult; 74 | 75 | static fromJson(jsonValue: JsonValue, options?: Partial): GetAllRelSelfResponse_AllResult; 76 | 77 | static fromJsonString(jsonString: string, options?: Partial): GetAllRelSelfResponse_AllResult; 78 | 79 | static equals(a: GetAllRelSelfResponse_AllResult | PlainMessage | undefined, b: GetAllRelSelfResponse_AllResult | PlainMessage | undefined): boolean; 80 | } 81 | 82 | /** 83 | * @generated from message spec.GetAllRelSelfParamRequest 84 | */ 85 | export declare class GetAllRelSelfParamRequest extends Message { 86 | /** 87 | * @generated from field: repeated spec.All bases = 1; 88 | */ 89 | bases: All[]; 90 | 91 | /** 92 | * @generated from field: string id = 2; 93 | */ 94 | id: string; 95 | 96 | constructor(data?: PartialMessage); 97 | 98 | static readonly runtime: typeof proto3; 99 | static readonly typeName = "spec.GetAllRelSelfParamRequest"; 100 | static readonly fields: FieldList; 101 | 102 | static fromBinary(bytes: Uint8Array, options?: Partial): GetAllRelSelfParamRequest; 103 | 104 | static fromJson(jsonValue: JsonValue, options?: Partial): GetAllRelSelfParamRequest; 105 | 106 | static fromJsonString(jsonString: string, options?: Partial): GetAllRelSelfParamRequest; 107 | 108 | static equals(a: GetAllRelSelfParamRequest | PlainMessage | undefined, b: GetAllRelSelfParamRequest | PlainMessage | undefined): boolean; 109 | } 110 | 111 | /** 112 | * @generated from message spec.GetAllRelSelfParamResponse 113 | */ 114 | export declare class GetAllRelSelfParamResponse extends Message { 115 | /** 116 | * @generated from field: repeated spec.GetAllRelSelfParamResponse.AllParamResult values = 1; 117 | */ 118 | values: GetAllRelSelfParamResponse_AllParamResult[]; 119 | 120 | constructor(data?: PartialMessage); 121 | 122 | static readonly runtime: typeof proto3; 123 | static readonly typeName = "spec.GetAllRelSelfParamResponse"; 124 | static readonly fields: FieldList; 125 | 126 | static fromBinary(bytes: Uint8Array, options?: Partial): GetAllRelSelfParamResponse; 127 | 128 | static fromJson(jsonValue: JsonValue, options?: Partial): GetAllRelSelfParamResponse; 129 | 130 | static fromJsonString(jsonString: string, options?: Partial): GetAllRelSelfParamResponse; 131 | 132 | static equals(a: GetAllRelSelfParamResponse | PlainMessage | undefined, b: GetAllRelSelfParamResponse | PlainMessage | undefined): boolean; 133 | } 134 | 135 | /** 136 | * @generated from message spec.GetAllRelSelfParamResponse.AllParamResult 137 | */ 138 | export declare class GetAllRelSelfParamResponse_AllParamResult extends Message { 139 | /** 140 | * @generated from field: spec.All rel_self_param = 1; 141 | */ 142 | relSelfParam?: All; 143 | 144 | constructor(data?: PartialMessage); 145 | 146 | static readonly runtime: typeof proto3; 147 | static readonly typeName = "spec.GetAllRelSelfParamResponse.AllParamResult"; 148 | static readonly fields: FieldList; 149 | 150 | static fromBinary(bytes: Uint8Array, options?: Partial): GetAllRelSelfParamResponse_AllParamResult; 151 | 152 | static fromJson(jsonValue: JsonValue, options?: Partial): GetAllRelSelfParamResponse_AllParamResult; 153 | 154 | static fromJsonString(jsonString: string, options?: Partial): GetAllRelSelfParamResponse_AllParamResult; 155 | 156 | static equals(a: GetAllRelSelfParamResponse_AllParamResult | PlainMessage | undefined, b: GetAllRelSelfParamResponse_AllParamResult | PlainMessage | undefined): boolean; 157 | } 158 | 159 | -------------------------------------------------------------------------------- /packages/knit-test-spec/spec/relations_pb.js: -------------------------------------------------------------------------------- 1 | // @generated by protoc-gen-es v1.5.0 2 | // @generated from file spec/relations.proto (package spec, syntax proto3) 3 | /* eslint-disable */ 4 | // @ts-nocheck 5 | 6 | import { proto3 } from "@bufbuild/protobuf"; 7 | import { All } from "./all_pb.js"; 8 | 9 | /** 10 | * @generated from message spec.GetAllRelSelfRequest 11 | */ 12 | export const GetAllRelSelfRequest = proto3.makeMessageType( 13 | "spec.GetAllRelSelfRequest", 14 | () => [ 15 | { no: 1, name: "bases", kind: "message", T: All, repeated: true }, 16 | ], 17 | ); 18 | 19 | /** 20 | * @generated from message spec.GetAllRelSelfResponse 21 | */ 22 | export const GetAllRelSelfResponse = proto3.makeMessageType( 23 | "spec.GetAllRelSelfResponse", 24 | () => [ 25 | { no: 1, name: "values", kind: "message", T: GetAllRelSelfResponse_AllResult, repeated: true }, 26 | ], 27 | ); 28 | 29 | /** 30 | * @generated from message spec.GetAllRelSelfResponse.AllResult 31 | */ 32 | export const GetAllRelSelfResponse_AllResult = proto3.makeMessageType( 33 | "spec.GetAllRelSelfResponse.AllResult", 34 | () => [ 35 | { no: 1, name: "rel_self", kind: "message", T: All }, 36 | ], 37 | {localName: "GetAllRelSelfResponse_AllResult"}, 38 | ); 39 | 40 | /** 41 | * @generated from message spec.GetAllRelSelfParamRequest 42 | */ 43 | export const GetAllRelSelfParamRequest = proto3.makeMessageType( 44 | "spec.GetAllRelSelfParamRequest", 45 | () => [ 46 | { no: 1, name: "bases", kind: "message", T: All, repeated: true }, 47 | { no: 2, name: "id", kind: "scalar", T: 9 /* ScalarType.STRING */ }, 48 | ], 49 | ); 50 | 51 | /** 52 | * @generated from message spec.GetAllRelSelfParamResponse 53 | */ 54 | export const GetAllRelSelfParamResponse = proto3.makeMessageType( 55 | "spec.GetAllRelSelfParamResponse", 56 | () => [ 57 | { no: 1, name: "values", kind: "message", T: GetAllRelSelfParamResponse_AllParamResult, repeated: true }, 58 | ], 59 | ); 60 | 61 | /** 62 | * @generated from message spec.GetAllRelSelfParamResponse.AllParamResult 63 | */ 64 | export const GetAllRelSelfParamResponse_AllParamResult = proto3.makeMessageType( 65 | "spec.GetAllRelSelfParamResponse.AllParamResult", 66 | () => [ 67 | { no: 1, name: "rel_self_param", kind: "message", T: All }, 68 | ], 69 | {localName: "GetAllRelSelfParamResponse_AllParamResult"}, 70 | ); 71 | 72 | -------------------------------------------------------------------------------- /packages/knit-test-spec/spec/scalars_knit.d.ts: -------------------------------------------------------------------------------- 1 | // @generated by protoc-gen-knit-ts v0.0.7 2 | // @generated from file spec/scalars.proto (package spec, syntax proto3) 3 | /* eslint-disable */ 4 | // @ts-nocheck 5 | 6 | export interface Scalar { 7 | fields?: ScalarFields; 8 | repeated?: ScalarRepeated; 9 | map?: ScalarMap; 10 | oneof?: ScalarOneof; 11 | } 12 | export interface ScalarFields { 13 | str: string; 14 | bl: boolean; 15 | i32: number; 16 | i64: bigint; 17 | u32: number; 18 | u64: bigint; 19 | s32: number; 20 | s64: bigint; 21 | f32: number; 22 | f64: bigint; 23 | sf32: number; 24 | sf64: bigint; 25 | by: Uint8Array; 26 | db: number; 27 | fl: number; 28 | } 29 | export interface ScalarFieldsOptional { 30 | str?: string; 31 | bl?: boolean; 32 | i32?: number; 33 | i64?: bigint; 34 | u32?: number; 35 | u64?: bigint; 36 | s32?: number; 37 | s64?: bigint; 38 | f32?: number; 39 | f64?: bigint; 40 | sf32?: number; 41 | sf64?: bigint; 42 | by?: Uint8Array; 43 | db?: number; 44 | fl?: number; 45 | } 46 | export interface ScalarRepeated { 47 | str: Array; 48 | bl: Array; 49 | i32: Array; 50 | i64: Array; 51 | u32: Array; 52 | u64: Array; 53 | s32: Array; 54 | s64: Array; 55 | f32: Array; 56 | f64: Array; 57 | sf32: Array; 58 | sf64: Array; 59 | by: Array; 60 | db: Array; 61 | fl: Array; 62 | } 63 | export interface ScalarMap { 64 | str: { 65 | "@map": { 66 | [k: string]: string; 67 | }; 68 | }; 69 | bl: { 70 | "@map": { 71 | [k: string]: boolean; 72 | }; 73 | }; 74 | i32: { 75 | "@map": { 76 | [k: string]: number; 77 | }; 78 | }; 79 | i64: { 80 | "@map": { 81 | [k: string]: bigint; 82 | }; 83 | }; 84 | u32: { 85 | "@map": { 86 | [k: string]: number; 87 | }; 88 | }; 89 | u64: { 90 | "@map": { 91 | [k: string]: bigint; 92 | }; 93 | }; 94 | s32: { 95 | "@map": { 96 | [k: string]: number; 97 | }; 98 | }; 99 | s64: { 100 | "@map": { 101 | [k: string]: bigint; 102 | }; 103 | }; 104 | f32: { 105 | "@map": { 106 | [k: string]: number; 107 | }; 108 | }; 109 | f64: { 110 | "@map": { 111 | [k: string]: bigint; 112 | }; 113 | }; 114 | sf32: { 115 | "@map": { 116 | [k: string]: number; 117 | }; 118 | }; 119 | sf64: { 120 | "@map": { 121 | [k: string]: bigint; 122 | }; 123 | }; 124 | by: { 125 | "@map": { 126 | [k: string]: Uint8Array; 127 | }; 128 | }; 129 | db: { 130 | "@map": { 131 | [k: string]: number; 132 | }; 133 | }; 134 | fl: { 135 | "@map": { 136 | [k: string]: number; 137 | }; 138 | }; 139 | } 140 | export interface ScalarOneof { 141 | oneofValue?: { 142 | "@oneof": { 143 | str: string; 144 | bl: boolean; 145 | i32: number; 146 | i64: bigint; 147 | u32: number; 148 | u64: bigint; 149 | s32: number; 150 | s64: bigint; 151 | f32: number; 152 | f64: bigint; 153 | sf32: number; 154 | sf64: bigint; 155 | by: Uint8Array; 156 | db: number; 157 | fl: number; 158 | }; 159 | }; 160 | } 161 | -------------------------------------------------------------------------------- /packages/knit-test-spec/spec/scalars_pb.js: -------------------------------------------------------------------------------- 1 | // @generated by protoc-gen-es v1.5.0 2 | // @generated from file spec/scalars.proto (package spec, syntax proto3) 3 | /* eslint-disable */ 4 | // @ts-nocheck 5 | 6 | import { proto3 } from "@bufbuild/protobuf"; 7 | 8 | /** 9 | * @generated from message spec.Scalar 10 | */ 11 | export const Scalar = proto3.makeMessageType( 12 | "spec.Scalar", 13 | () => [ 14 | { no: 1, name: "fields", kind: "message", T: ScalarFields }, 15 | { no: 2, name: "repeated", kind: "message", T: ScalarRepeated }, 16 | { no: 3, name: "map", kind: "message", T: ScalarMap }, 17 | { no: 4, name: "oneof", kind: "message", T: ScalarOneof }, 18 | ], 19 | ); 20 | 21 | /** 22 | * @generated from message spec.ScalarFields 23 | */ 24 | export const ScalarFields = proto3.makeMessageType( 25 | "spec.ScalarFields", 26 | () => [ 27 | { no: 1, name: "str", kind: "scalar", T: 9 /* ScalarType.STRING */ }, 28 | { no: 2, name: "bl", kind: "scalar", T: 8 /* ScalarType.BOOL */ }, 29 | { no: 3, name: "i32", kind: "scalar", T: 5 /* ScalarType.INT32 */ }, 30 | { no: 4, name: "i64", kind: "scalar", T: 3 /* ScalarType.INT64 */ }, 31 | { no: 5, name: "u32", kind: "scalar", T: 13 /* ScalarType.UINT32 */ }, 32 | { no: 6, name: "u64", kind: "scalar", T: 4 /* ScalarType.UINT64 */ }, 33 | { no: 7, name: "s32", kind: "scalar", T: 17 /* ScalarType.SINT32 */ }, 34 | { no: 8, name: "s64", kind: "scalar", T: 18 /* ScalarType.SINT64 */ }, 35 | { no: 9, name: "f32", kind: "scalar", T: 7 /* ScalarType.FIXED32 */ }, 36 | { no: 10, name: "f64", kind: "scalar", T: 6 /* ScalarType.FIXED64 */ }, 37 | { no: 11, name: "sf32", kind: "scalar", T: 15 /* ScalarType.SFIXED32 */ }, 38 | { no: 12, name: "sf64", kind: "scalar", T: 16 /* ScalarType.SFIXED64 */ }, 39 | { no: 13, name: "by", kind: "scalar", T: 12 /* ScalarType.BYTES */ }, 40 | { no: 14, name: "db", kind: "scalar", T: 1 /* ScalarType.DOUBLE */ }, 41 | { no: 15, name: "fl", kind: "scalar", T: 2 /* ScalarType.FLOAT */ }, 42 | ], 43 | ); 44 | 45 | /** 46 | * @generated from message spec.ScalarFieldsOptional 47 | */ 48 | export const ScalarFieldsOptional = proto3.makeMessageType( 49 | "spec.ScalarFieldsOptional", 50 | () => [ 51 | { no: 1, name: "str", kind: "scalar", T: 9 /* ScalarType.STRING */, opt: true }, 52 | { no: 2, name: "bl", kind: "scalar", T: 8 /* ScalarType.BOOL */, opt: true }, 53 | { no: 3, name: "i32", kind: "scalar", T: 5 /* ScalarType.INT32 */, opt: true }, 54 | { no: 4, name: "i64", kind: "scalar", T: 3 /* ScalarType.INT64 */, opt: true }, 55 | { no: 5, name: "u32", kind: "scalar", T: 13 /* ScalarType.UINT32 */, opt: true }, 56 | { no: 6, name: "u64", kind: "scalar", T: 4 /* ScalarType.UINT64 */, opt: true }, 57 | { no: 7, name: "s32", kind: "scalar", T: 17 /* ScalarType.SINT32 */, opt: true }, 58 | { no: 8, name: "s64", kind: "scalar", T: 18 /* ScalarType.SINT64 */, opt: true }, 59 | { no: 9, name: "f32", kind: "scalar", T: 7 /* ScalarType.FIXED32 */, opt: true }, 60 | { no: 10, name: "f64", kind: "scalar", T: 6 /* ScalarType.FIXED64 */, opt: true }, 61 | { no: 11, name: "sf32", kind: "scalar", T: 15 /* ScalarType.SFIXED32 */, opt: true }, 62 | { no: 12, name: "sf64", kind: "scalar", T: 16 /* ScalarType.SFIXED64 */, opt: true }, 63 | { no: 13, name: "by", kind: "scalar", T: 12 /* ScalarType.BYTES */, opt: true }, 64 | { no: 14, name: "db", kind: "scalar", T: 1 /* ScalarType.DOUBLE */, opt: true }, 65 | { no: 15, name: "fl", kind: "scalar", T: 2 /* ScalarType.FLOAT */, opt: true }, 66 | ], 67 | ); 68 | 69 | /** 70 | * @generated from message spec.ScalarRepeated 71 | */ 72 | export const ScalarRepeated = proto3.makeMessageType( 73 | "spec.ScalarRepeated", 74 | () => [ 75 | { no: 1, name: "str", kind: "scalar", T: 9 /* ScalarType.STRING */, repeated: true }, 76 | { no: 2, name: "bl", kind: "scalar", T: 8 /* ScalarType.BOOL */, repeated: true }, 77 | { no: 3, name: "i32", kind: "scalar", T: 5 /* ScalarType.INT32 */, repeated: true }, 78 | { no: 4, name: "i64", kind: "scalar", T: 3 /* ScalarType.INT64 */, repeated: true }, 79 | { no: 5, name: "u32", kind: "scalar", T: 13 /* ScalarType.UINT32 */, repeated: true }, 80 | { no: 6, name: "u64", kind: "scalar", T: 4 /* ScalarType.UINT64 */, repeated: true }, 81 | { no: 7, name: "s32", kind: "scalar", T: 17 /* ScalarType.SINT32 */, repeated: true }, 82 | { no: 8, name: "s64", kind: "scalar", T: 18 /* ScalarType.SINT64 */, repeated: true }, 83 | { no: 9, name: "f32", kind: "scalar", T: 7 /* ScalarType.FIXED32 */, repeated: true }, 84 | { no: 10, name: "f64", kind: "scalar", T: 6 /* ScalarType.FIXED64 */, repeated: true }, 85 | { no: 11, name: "sf32", kind: "scalar", T: 15 /* ScalarType.SFIXED32 */, repeated: true }, 86 | { no: 12, name: "sf64", kind: "scalar", T: 16 /* ScalarType.SFIXED64 */, repeated: true }, 87 | { no: 13, name: "by", kind: "scalar", T: 12 /* ScalarType.BYTES */, repeated: true }, 88 | { no: 14, name: "db", kind: "scalar", T: 1 /* ScalarType.DOUBLE */, repeated: true }, 89 | { no: 15, name: "fl", kind: "scalar", T: 2 /* ScalarType.FLOAT */, repeated: true }, 90 | ], 91 | ); 92 | 93 | /** 94 | * @generated from message spec.ScalarMap 95 | */ 96 | export const ScalarMap = proto3.makeMessageType( 97 | "spec.ScalarMap", 98 | () => [ 99 | { no: 1, name: "str", kind: "map", K: 9 /* ScalarType.STRING */, V: {kind: "scalar", T: 9 /* ScalarType.STRING */} }, 100 | { no: 2, name: "bl", kind: "map", K: 9 /* ScalarType.STRING */, V: {kind: "scalar", T: 8 /* ScalarType.BOOL */} }, 101 | { no: 3, name: "i32", kind: "map", K: 9 /* ScalarType.STRING */, V: {kind: "scalar", T: 5 /* ScalarType.INT32 */} }, 102 | { no: 4, name: "i64", kind: "map", K: 9 /* ScalarType.STRING */, V: {kind: "scalar", T: 3 /* ScalarType.INT64 */} }, 103 | { no: 5, name: "u32", kind: "map", K: 9 /* ScalarType.STRING */, V: {kind: "scalar", T: 13 /* ScalarType.UINT32 */} }, 104 | { no: 6, name: "u64", kind: "map", K: 9 /* ScalarType.STRING */, V: {kind: "scalar", T: 4 /* ScalarType.UINT64 */} }, 105 | { no: 7, name: "s32", kind: "map", K: 9 /* ScalarType.STRING */, V: {kind: "scalar", T: 17 /* ScalarType.SINT32 */} }, 106 | { no: 8, name: "s64", kind: "map", K: 9 /* ScalarType.STRING */, V: {kind: "scalar", T: 18 /* ScalarType.SINT64 */} }, 107 | { no: 9, name: "f32", kind: "map", K: 9 /* ScalarType.STRING */, V: {kind: "scalar", T: 7 /* ScalarType.FIXED32 */} }, 108 | { no: 10, name: "f64", kind: "map", K: 9 /* ScalarType.STRING */, V: {kind: "scalar", T: 6 /* ScalarType.FIXED64 */} }, 109 | { no: 11, name: "sf32", kind: "map", K: 9 /* ScalarType.STRING */, V: {kind: "scalar", T: 15 /* ScalarType.SFIXED32 */} }, 110 | { no: 12, name: "sf64", kind: "map", K: 9 /* ScalarType.STRING */, V: {kind: "scalar", T: 16 /* ScalarType.SFIXED64 */} }, 111 | { no: 13, name: "by", kind: "map", K: 9 /* ScalarType.STRING */, V: {kind: "scalar", T: 12 /* ScalarType.BYTES */} }, 112 | { no: 14, name: "db", kind: "map", K: 9 /* ScalarType.STRING */, V: {kind: "scalar", T: 1 /* ScalarType.DOUBLE */} }, 113 | { no: 15, name: "fl", kind: "map", K: 9 /* ScalarType.STRING */, V: {kind: "scalar", T: 2 /* ScalarType.FLOAT */} }, 114 | ], 115 | ); 116 | 117 | /** 118 | * @generated from message spec.ScalarOneof 119 | */ 120 | export const ScalarOneof = proto3.makeMessageType( 121 | "spec.ScalarOneof", 122 | () => [ 123 | { no: 1, name: "str", kind: "scalar", T: 9 /* ScalarType.STRING */, oneof: "oneof_value" }, 124 | { no: 2, name: "bl", kind: "scalar", T: 8 /* ScalarType.BOOL */, oneof: "oneof_value" }, 125 | { no: 3, name: "i32", kind: "scalar", T: 5 /* ScalarType.INT32 */, oneof: "oneof_value" }, 126 | { no: 4, name: "i64", kind: "scalar", T: 3 /* ScalarType.INT64 */, oneof: "oneof_value" }, 127 | { no: 5, name: "u32", kind: "scalar", T: 13 /* ScalarType.UINT32 */, oneof: "oneof_value" }, 128 | { no: 6, name: "u64", kind: "scalar", T: 4 /* ScalarType.UINT64 */, oneof: "oneof_value" }, 129 | { no: 7, name: "s32", kind: "scalar", T: 17 /* ScalarType.SINT32 */, oneof: "oneof_value" }, 130 | { no: 8, name: "s64", kind: "scalar", T: 18 /* ScalarType.SINT64 */, oneof: "oneof_value" }, 131 | { no: 9, name: "f32", kind: "scalar", T: 7 /* ScalarType.FIXED32 */, oneof: "oneof_value" }, 132 | { no: 10, name: "f64", kind: "scalar", T: 6 /* ScalarType.FIXED64 */, oneof: "oneof_value" }, 133 | { no: 11, name: "sf32", kind: "scalar", T: 15 /* ScalarType.SFIXED32 */, oneof: "oneof_value" }, 134 | { no: 12, name: "sf64", kind: "scalar", T: 16 /* ScalarType.SFIXED64 */, oneof: "oneof_value" }, 135 | { no: 13, name: "by", kind: "scalar", T: 12 /* ScalarType.BYTES */, oneof: "oneof_value" }, 136 | { no: 14, name: "db", kind: "scalar", T: 1 /* ScalarType.DOUBLE */, oneof: "oneof_value" }, 137 | { no: 15, name: "fl", kind: "scalar", T: 2 /* ScalarType.FLOAT */, oneof: "oneof_value" }, 138 | ], 139 | ); 140 | 141 | -------------------------------------------------------------------------------- /packages/knit-test-spec/spec/sub/sub_connect.d.ts: -------------------------------------------------------------------------------- 1 | // @generated by protoc-gen-connect-es v1.1.3 2 | // @generated from file spec/sub/sub.proto (package spec.sub, syntax proto3) 3 | /* eslint-disable */ 4 | // @ts-nocheck 5 | 6 | import { SubMessage } from "./sub_pb.js"; 7 | import { MethodKind } from "@bufbuild/protobuf"; 8 | 9 | /** 10 | * @generated from service spec.sub.SubService 11 | */ 12 | export declare const SubService: { 13 | readonly typeName: "spec.sub.SubService", 14 | readonly methods: { 15 | /** 16 | * @generated from rpc spec.sub.SubService.SubMethod 17 | */ 18 | readonly subMethod: { 19 | readonly name: "SubMethod", 20 | readonly I: typeof SubMessage, 21 | readonly O: typeof SubMessage, 22 | readonly kind: MethodKind.Unary, 23 | }, 24 | } 25 | }; 26 | 27 | -------------------------------------------------------------------------------- /packages/knit-test-spec/spec/sub/sub_connect.js: -------------------------------------------------------------------------------- 1 | // @generated by protoc-gen-connect-es v1.1.3 2 | // @generated from file spec/sub/sub.proto (package spec.sub, syntax proto3) 3 | /* eslint-disable */ 4 | // @ts-nocheck 5 | 6 | import { SubMessage } from "./sub_pb.js"; 7 | import { MethodKind } from "@bufbuild/protobuf"; 8 | 9 | /** 10 | * @generated from service spec.sub.SubService 11 | */ 12 | export const SubService = { 13 | typeName: "spec.sub.SubService", 14 | methods: { 15 | /** 16 | * @generated from rpc spec.sub.SubService.SubMethod 17 | */ 18 | subMethod: { 19 | name: "SubMethod", 20 | I: SubMessage, 21 | O: SubMessage, 22 | kind: MethodKind.Unary, 23 | }, 24 | } 25 | }; 26 | 27 | -------------------------------------------------------------------------------- /packages/knit-test-spec/spec/sub/sub_knit.d.ts: -------------------------------------------------------------------------------- 1 | // @generated by protoc-gen-knit-ts v0.0.7 2 | // @generated from file spec/sub/sub.proto (package spec.sub, syntax proto3) 3 | /* eslint-disable */ 4 | // @ts-nocheck 5 | 6 | export declare type SubService = { 7 | "spec.sub.SubService": { 8 | fetch: {}; 9 | do: { 10 | subMethod: { 11 | $: SubMessage; 12 | value: SubMessage; 13 | }; 14 | }; 15 | listen: {}; 16 | }; 17 | }; 18 | export interface SubMessage { 19 | } 20 | -------------------------------------------------------------------------------- /packages/knit-test-spec/spec/sub/sub_pb.d.ts: -------------------------------------------------------------------------------- 1 | // @generated by protoc-gen-es v1.5.0 2 | // @generated from file spec/sub/sub.proto (package spec.sub, syntax proto3) 3 | /* eslint-disable */ 4 | // @ts-nocheck 5 | 6 | import type { BinaryReadOptions, FieldList, JsonReadOptions, JsonValue, PartialMessage, PlainMessage } from "@bufbuild/protobuf"; 7 | import { Message, proto3 } from "@bufbuild/protobuf"; 8 | 9 | /** 10 | * @generated from message spec.sub.SubMessage 11 | */ 12 | export declare class SubMessage extends Message { 13 | constructor(data?: PartialMessage); 14 | 15 | static readonly runtime: typeof proto3; 16 | static readonly typeName = "spec.sub.SubMessage"; 17 | static readonly fields: FieldList; 18 | 19 | static fromBinary(bytes: Uint8Array, options?: Partial): SubMessage; 20 | 21 | static fromJson(jsonValue: JsonValue, options?: Partial): SubMessage; 22 | 23 | static fromJsonString(jsonString: string, options?: Partial): SubMessage; 24 | 25 | static equals(a: SubMessage | PlainMessage | undefined, b: SubMessage | PlainMessage | undefined): boolean; 26 | } 27 | 28 | -------------------------------------------------------------------------------- /packages/knit-test-spec/spec/sub/sub_pb.js: -------------------------------------------------------------------------------- 1 | // @generated by protoc-gen-es v1.5.0 2 | // @generated from file spec/sub/sub.proto (package spec.sub, syntax proto3) 3 | /* eslint-disable */ 4 | // @ts-nocheck 5 | 6 | import { proto3 } from "@bufbuild/protobuf"; 7 | 8 | /** 9 | * @generated from message spec.sub.SubMessage 10 | */ 11 | export const SubMessage = proto3.makeMessageType( 12 | "spec.sub.SubMessage", 13 | [], 14 | ); 15 | 16 | -------------------------------------------------------------------------------- /packages/knit-test-spec/spec/wkt_connect.d.ts: -------------------------------------------------------------------------------- 1 | // @generated by protoc-gen-connect-es v1.1.3 2 | // @generated from file spec/wkt.proto (package spec, syntax proto3) 3 | /* eslint-disable */ 4 | // @ts-nocheck 5 | 6 | import { Any, BoolValue, BytesValue, DoubleValue, Duration, Empty, FieldMask, FloatValue, Int32Value, Int64Value, ListValue, MethodKind, StringValue, Struct, Timestamp, UInt32Value, UInt64Value, Value } from "@bufbuild/protobuf"; 7 | 8 | /** 9 | * @generated from service spec.WktService 10 | */ 11 | export declare const WktService: { 12 | readonly typeName: "spec.WktService", 13 | readonly methods: { 14 | /** 15 | * @generated from rpc spec.WktService.GetDoubleValue 16 | */ 17 | readonly getDoubleValue: { 18 | readonly name: "GetDoubleValue", 19 | readonly I: typeof DoubleValue, 20 | readonly O: typeof DoubleValue, 21 | readonly kind: MethodKind.Unary, 22 | }, 23 | /** 24 | * @generated from rpc spec.WktService.GetBoolValue 25 | */ 26 | readonly getBoolValue: { 27 | readonly name: "GetBoolValue", 28 | readonly I: typeof BoolValue, 29 | readonly O: typeof BoolValue, 30 | readonly kind: MethodKind.Unary, 31 | }, 32 | /** 33 | * @generated from rpc spec.WktService.GetFloatValue 34 | */ 35 | readonly getFloatValue: { 36 | readonly name: "GetFloatValue", 37 | readonly I: typeof FloatValue, 38 | readonly O: typeof FloatValue, 39 | readonly kind: MethodKind.Unary, 40 | }, 41 | /** 42 | * @generated from rpc spec.WktService.GetInt64Value 43 | */ 44 | readonly getInt64Value: { 45 | readonly name: "GetInt64Value", 46 | readonly I: typeof Int64Value, 47 | readonly O: typeof Int64Value, 48 | readonly kind: MethodKind.Unary, 49 | }, 50 | /** 51 | * @generated from rpc spec.WktService.GetUint64Value 52 | */ 53 | readonly getUint64Value: { 54 | readonly name: "GetUint64Value", 55 | readonly I: typeof UInt64Value, 56 | readonly O: typeof UInt64Value, 57 | readonly kind: MethodKind.Unary, 58 | }, 59 | /** 60 | * @generated from rpc spec.WktService.GetInt32Value 61 | */ 62 | readonly getInt32Value: { 63 | readonly name: "GetInt32Value", 64 | readonly I: typeof Int32Value, 65 | readonly O: typeof Int32Value, 66 | readonly kind: MethodKind.Unary, 67 | }, 68 | /** 69 | * @generated from rpc spec.WktService.GetUint32Value 70 | */ 71 | readonly getUint32Value: { 72 | readonly name: "GetUint32Value", 73 | readonly I: typeof UInt32Value, 74 | readonly O: typeof UInt32Value, 75 | readonly kind: MethodKind.Unary, 76 | }, 77 | /** 78 | * @generated from rpc spec.WktService.GetStringValue 79 | */ 80 | readonly getStringValue: { 81 | readonly name: "GetStringValue", 82 | readonly I: typeof StringValue, 83 | readonly O: typeof StringValue, 84 | readonly kind: MethodKind.Unary, 85 | }, 86 | /** 87 | * @generated from rpc spec.WktService.GetBytesValue 88 | */ 89 | readonly getBytesValue: { 90 | readonly name: "GetBytesValue", 91 | readonly I: typeof BytesValue, 92 | readonly O: typeof BytesValue, 93 | readonly kind: MethodKind.Unary, 94 | }, 95 | /** 96 | * @generated from rpc spec.WktService.GetAny 97 | */ 98 | readonly getAny: { 99 | readonly name: "GetAny", 100 | readonly I: typeof Any, 101 | readonly O: typeof Any, 102 | readonly kind: MethodKind.Unary, 103 | }, 104 | /** 105 | * @generated from rpc spec.WktService.GetDuration 106 | */ 107 | readonly getDuration: { 108 | readonly name: "GetDuration", 109 | readonly I: typeof Duration, 110 | readonly O: typeof Duration, 111 | readonly kind: MethodKind.Unary, 112 | }, 113 | /** 114 | * @generated from rpc spec.WktService.GetEmpty 115 | */ 116 | readonly getEmpty: { 117 | readonly name: "GetEmpty", 118 | readonly I: typeof Empty, 119 | readonly O: typeof Empty, 120 | readonly kind: MethodKind.Unary, 121 | }, 122 | /** 123 | * @generated from rpc spec.WktService.GetFieldMask 124 | */ 125 | readonly getFieldMask: { 126 | readonly name: "GetFieldMask", 127 | readonly I: typeof FieldMask, 128 | readonly O: typeof FieldMask, 129 | readonly kind: MethodKind.Unary, 130 | }, 131 | /** 132 | * @generated from rpc spec.WktService.GetTimestamp 133 | */ 134 | readonly getTimestamp: { 135 | readonly name: "GetTimestamp", 136 | readonly I: typeof Timestamp, 137 | readonly O: typeof Timestamp, 138 | readonly kind: MethodKind.Unary, 139 | }, 140 | /** 141 | * @generated from rpc spec.WktService.GetStruct 142 | */ 143 | readonly getStruct: { 144 | readonly name: "GetStruct", 145 | readonly I: typeof Struct, 146 | readonly O: typeof Struct, 147 | readonly kind: MethodKind.Unary, 148 | }, 149 | /** 150 | * @generated from rpc spec.WktService.GetListValue 151 | */ 152 | readonly getListValue: { 153 | readonly name: "GetListValue", 154 | readonly I: typeof ListValue, 155 | readonly O: typeof ListValue, 156 | readonly kind: MethodKind.Unary, 157 | }, 158 | /** 159 | * @generated from rpc spec.WktService.GetValue 160 | */ 161 | readonly getValue: { 162 | readonly name: "GetValue", 163 | readonly I: typeof Value, 164 | readonly O: typeof Value, 165 | readonly kind: MethodKind.Unary, 166 | }, 167 | } 168 | }; 169 | 170 | -------------------------------------------------------------------------------- /packages/knit-test-spec/spec/wkt_connect.js: -------------------------------------------------------------------------------- 1 | // @generated by protoc-gen-connect-es v1.1.3 2 | // @generated from file spec/wkt.proto (package spec, syntax proto3) 3 | /* eslint-disable */ 4 | // @ts-nocheck 5 | 6 | import { Any, BoolValue, BytesValue, DoubleValue, Duration, Empty, FieldMask, FloatValue, Int32Value, Int64Value, ListValue, MethodKind, StringValue, Struct, Timestamp, UInt32Value, UInt64Value, Value } from "@bufbuild/protobuf"; 7 | 8 | /** 9 | * @generated from service spec.WktService 10 | */ 11 | export const WktService = { 12 | typeName: "spec.WktService", 13 | methods: { 14 | /** 15 | * @generated from rpc spec.WktService.GetDoubleValue 16 | */ 17 | getDoubleValue: { 18 | name: "GetDoubleValue", 19 | I: DoubleValue, 20 | O: DoubleValue, 21 | kind: MethodKind.Unary, 22 | }, 23 | /** 24 | * @generated from rpc spec.WktService.GetBoolValue 25 | */ 26 | getBoolValue: { 27 | name: "GetBoolValue", 28 | I: BoolValue, 29 | O: BoolValue, 30 | kind: MethodKind.Unary, 31 | }, 32 | /** 33 | * @generated from rpc spec.WktService.GetFloatValue 34 | */ 35 | getFloatValue: { 36 | name: "GetFloatValue", 37 | I: FloatValue, 38 | O: FloatValue, 39 | kind: MethodKind.Unary, 40 | }, 41 | /** 42 | * @generated from rpc spec.WktService.GetInt64Value 43 | */ 44 | getInt64Value: { 45 | name: "GetInt64Value", 46 | I: Int64Value, 47 | O: Int64Value, 48 | kind: MethodKind.Unary, 49 | }, 50 | /** 51 | * @generated from rpc spec.WktService.GetUint64Value 52 | */ 53 | getUint64Value: { 54 | name: "GetUint64Value", 55 | I: UInt64Value, 56 | O: UInt64Value, 57 | kind: MethodKind.Unary, 58 | }, 59 | /** 60 | * @generated from rpc spec.WktService.GetInt32Value 61 | */ 62 | getInt32Value: { 63 | name: "GetInt32Value", 64 | I: Int32Value, 65 | O: Int32Value, 66 | kind: MethodKind.Unary, 67 | }, 68 | /** 69 | * @generated from rpc spec.WktService.GetUint32Value 70 | */ 71 | getUint32Value: { 72 | name: "GetUint32Value", 73 | I: UInt32Value, 74 | O: UInt32Value, 75 | kind: MethodKind.Unary, 76 | }, 77 | /** 78 | * @generated from rpc spec.WktService.GetStringValue 79 | */ 80 | getStringValue: { 81 | name: "GetStringValue", 82 | I: StringValue, 83 | O: StringValue, 84 | kind: MethodKind.Unary, 85 | }, 86 | /** 87 | * @generated from rpc spec.WktService.GetBytesValue 88 | */ 89 | getBytesValue: { 90 | name: "GetBytesValue", 91 | I: BytesValue, 92 | O: BytesValue, 93 | kind: MethodKind.Unary, 94 | }, 95 | /** 96 | * @generated from rpc spec.WktService.GetAny 97 | */ 98 | getAny: { 99 | name: "GetAny", 100 | I: Any, 101 | O: Any, 102 | kind: MethodKind.Unary, 103 | }, 104 | /** 105 | * @generated from rpc spec.WktService.GetDuration 106 | */ 107 | getDuration: { 108 | name: "GetDuration", 109 | I: Duration, 110 | O: Duration, 111 | kind: MethodKind.Unary, 112 | }, 113 | /** 114 | * @generated from rpc spec.WktService.GetEmpty 115 | */ 116 | getEmpty: { 117 | name: "GetEmpty", 118 | I: Empty, 119 | O: Empty, 120 | kind: MethodKind.Unary, 121 | }, 122 | /** 123 | * @generated from rpc spec.WktService.GetFieldMask 124 | */ 125 | getFieldMask: { 126 | name: "GetFieldMask", 127 | I: FieldMask, 128 | O: FieldMask, 129 | kind: MethodKind.Unary, 130 | }, 131 | /** 132 | * @generated from rpc spec.WktService.GetTimestamp 133 | */ 134 | getTimestamp: { 135 | name: "GetTimestamp", 136 | I: Timestamp, 137 | O: Timestamp, 138 | kind: MethodKind.Unary, 139 | }, 140 | /** 141 | * @generated from rpc spec.WktService.GetStruct 142 | */ 143 | getStruct: { 144 | name: "GetStruct", 145 | I: Struct, 146 | O: Struct, 147 | kind: MethodKind.Unary, 148 | }, 149 | /** 150 | * @generated from rpc spec.WktService.GetListValue 151 | */ 152 | getListValue: { 153 | name: "GetListValue", 154 | I: ListValue, 155 | O: ListValue, 156 | kind: MethodKind.Unary, 157 | }, 158 | /** 159 | * @generated from rpc spec.WktService.GetValue 160 | */ 161 | getValue: { 162 | name: "GetValue", 163 | I: Value, 164 | O: Value, 165 | kind: MethodKind.Unary, 166 | }, 167 | } 168 | }; 169 | 170 | -------------------------------------------------------------------------------- /packages/knit-test-spec/spec/wkt_knit.d.ts: -------------------------------------------------------------------------------- 1 | // @generated by protoc-gen-knit-ts v0.0.7 2 | // @generated from file spec/wkt.proto (package spec, syntax proto3) 3 | /* eslint-disable */ 4 | // @ts-nocheck 5 | 6 | export declare type WktService = { 7 | "spec.WktService": { 8 | fetch: {}; 9 | do: { 10 | getDoubleValue: { 11 | $: "@wkt/DoubleValue"; 12 | value: "@wkt/DoubleValue"; 13 | }; 14 | getBoolValue: { 15 | $: "@wkt/BoolValue"; 16 | value: "@wkt/BoolValue"; 17 | }; 18 | getFloatValue: { 19 | $: "@wkt/FloatValue"; 20 | value: "@wkt/FloatValue"; 21 | }; 22 | getInt64Value: { 23 | $: "@wkt/Int64Value"; 24 | value: "@wkt/Int64Value"; 25 | }; 26 | getUint64Value: { 27 | $: "@wkt/UInt64Value"; 28 | value: "@wkt/UInt64Value"; 29 | }; 30 | getInt32Value: { 31 | $: "@wkt/Int32Value"; 32 | value: "@wkt/Int32Value"; 33 | }; 34 | getUint32Value: { 35 | $: "@wkt/UInt32Value"; 36 | value: "@wkt/UInt32Value"; 37 | }; 38 | getStringValue: { 39 | $: "@wkt/StringValue"; 40 | value: "@wkt/StringValue"; 41 | }; 42 | getBytesValue: { 43 | $: "@wkt/BytesValue"; 44 | value: "@wkt/BytesValue"; 45 | }; 46 | getAny: { 47 | $: "@wkt/Any"; 48 | value: "@wkt/Any"; 49 | }; 50 | getDuration: { 51 | $: "@wkt/Duration"; 52 | value: "@wkt/Duration"; 53 | }; 54 | getEmpty: { 55 | $: "@wkt/Empty"; 56 | value: "@wkt/Empty"; 57 | }; 58 | getFieldMask: { 59 | $: "@wkt/FieldMask"; 60 | value: "@wkt/FieldMask"; 61 | }; 62 | getTimestamp: { 63 | $: "@wkt/Timestamp"; 64 | value: "@wkt/Timestamp"; 65 | }; 66 | getStruct: { 67 | $: "@wkt/Struct"; 68 | value: "@wkt/Struct"; 69 | }; 70 | getListValue: { 71 | $: "@wkt/ListValue"; 72 | value: "@wkt/ListValue"; 73 | }; 74 | getValue: { 75 | $: "@wkt/Value"; 76 | value: "@wkt/Value"; 77 | }; 78 | }; 79 | listen: {}; 80 | }; 81 | }; 82 | export interface Wkt { 83 | fields?: WktFields; 84 | oneofs?: WktOneof; 85 | maps?: WktMap; 86 | repeated?: WktRepeated; 87 | } 88 | export interface WktFields { 89 | doubleValue?: "@wkt/DoubleValue"; 90 | boolValue?: "@wkt/BoolValue"; 91 | floatValue?: "@wkt/FloatValue"; 92 | int64Value?: "@wkt/Int64Value"; 93 | uint64Value?: "@wkt/UInt64Value"; 94 | int32Value?: "@wkt/Int32Value"; 95 | uint32Value?: "@wkt/UInt32Value"; 96 | stringValue?: "@wkt/StringValue"; 97 | bytesValue?: "@wkt/BytesValue"; 98 | any?: "@wkt/Any"; 99 | duration?: "@wkt/Duration"; 100 | empty?: "@wkt/Empty"; 101 | fieldMask?: "@wkt/FieldMask"; 102 | timestamp?: "@wkt/Timestamp"; 103 | struct?: "@wkt/Struct"; 104 | listValue?: "@wkt/ListValue"; 105 | value?: "@wkt/Value"; 106 | nullValue: "@wkt/NullValue"; 107 | } 108 | export interface WktOneof { 109 | oneofValue?: { 110 | "@oneof": { 111 | doubleValue: "@wkt/DoubleValue"; 112 | boolValue: "@wkt/BoolValue"; 113 | floatValue: "@wkt/FloatValue"; 114 | int64Value: "@wkt/Int64Value"; 115 | uint64Value: "@wkt/UInt64Value"; 116 | int32Value: "@wkt/Int32Value"; 117 | uint32Value: "@wkt/UInt32Value"; 118 | stringValue: "@wkt/StringValue"; 119 | bytesValue: "@wkt/BytesValue"; 120 | any: "@wkt/Any"; 121 | duration: "@wkt/Duration"; 122 | empty: "@wkt/Empty"; 123 | fieldMask: "@wkt/FieldMask"; 124 | timestamp: "@wkt/Timestamp"; 125 | struct: "@wkt/Struct"; 126 | listValue: "@wkt/ListValue"; 127 | value: "@wkt/Value"; 128 | nullValue: "@wkt/NullValue"; 129 | }; 130 | }; 131 | } 132 | export interface WktMap { 133 | doubleValue: { 134 | "@map": { 135 | [k: string]: "@wkt/DoubleValue"; 136 | }; 137 | }; 138 | boolValue: { 139 | "@map": { 140 | [k: string]: "@wkt/BoolValue"; 141 | }; 142 | }; 143 | floatValue: { 144 | "@map": { 145 | [k: string]: "@wkt/FloatValue"; 146 | }; 147 | }; 148 | int64Value: { 149 | "@map": { 150 | [k: string]: "@wkt/Int64Value"; 151 | }; 152 | }; 153 | uint64Value: { 154 | "@map": { 155 | [k: string]: "@wkt/UInt64Value"; 156 | }; 157 | }; 158 | int32Value: { 159 | "@map": { 160 | [k: string]: "@wkt/Int32Value"; 161 | }; 162 | }; 163 | uint32Value: { 164 | "@map": { 165 | [k: string]: "@wkt/UInt32Value"; 166 | }; 167 | }; 168 | stringValue: { 169 | "@map": { 170 | [k: string]: "@wkt/StringValue"; 171 | }; 172 | }; 173 | bytesValue: { 174 | "@map": { 175 | [k: string]: "@wkt/BytesValue"; 176 | }; 177 | }; 178 | any: { 179 | "@map": { 180 | [k: string]: "@wkt/Any"; 181 | }; 182 | }; 183 | duration: { 184 | "@map": { 185 | [k: string]: "@wkt/Duration"; 186 | }; 187 | }; 188 | empty: { 189 | "@map": { 190 | [k: string]: "@wkt/Empty"; 191 | }; 192 | }; 193 | fieldMask: { 194 | "@map": { 195 | [k: string]: "@wkt/FieldMask"; 196 | }; 197 | }; 198 | timestamp: { 199 | "@map": { 200 | [k: string]: "@wkt/Timestamp"; 201 | }; 202 | }; 203 | struct: { 204 | "@map": { 205 | [k: string]: "@wkt/Struct"; 206 | }; 207 | }; 208 | listValue: { 209 | "@map": { 210 | [k: string]: "@wkt/ListValue"; 211 | }; 212 | }; 213 | value: { 214 | "@map": { 215 | [k: string]: "@wkt/Value"; 216 | }; 217 | }; 218 | nullValue: { 219 | "@map": { 220 | [k: string]: "@wkt/NullValue"; 221 | }; 222 | }; 223 | } 224 | export interface WktRepeated { 225 | doubleValue: Array<"@wkt/DoubleValue">; 226 | boolValue: Array<"@wkt/BoolValue">; 227 | floatValue: Array<"@wkt/FloatValue">; 228 | int64Value: Array<"@wkt/Int64Value">; 229 | uint64Value: Array<"@wkt/UInt64Value">; 230 | int32Value: Array<"@wkt/Int32Value">; 231 | uint32Value: Array<"@wkt/UInt32Value">; 232 | stringValue: Array<"@wkt/StringValue">; 233 | bytesValue: Array<"@wkt/BytesValue">; 234 | any: Array<"@wkt/Any">; 235 | duration: Array<"@wkt/Duration">; 236 | empty: Array<"@wkt/Empty">; 237 | fieldMask: Array<"@wkt/FieldMask">; 238 | timestamp: Array<"@wkt/Timestamp">; 239 | struct: Array<"@wkt/Struct">; 240 | listValue: Array<"@wkt/ListValue">; 241 | value: Array<"@wkt/Value">; 242 | nullValue: Array<"@wkt/NullValue">; 243 | } 244 | -------------------------------------------------------------------------------- /packages/knit-test-spec/spec/wkt_pb.js: -------------------------------------------------------------------------------- 1 | // @generated by protoc-gen-es v1.5.0 2 | // @generated from file spec/wkt.proto (package spec, syntax proto3) 3 | /* eslint-disable */ 4 | // @ts-nocheck 5 | 6 | import { Any, BoolValue, BytesValue, DoubleValue, Duration, Empty, FieldMask, FloatValue, Int32Value, Int64Value, ListValue, NullValue, proto3, StringValue, Struct, Timestamp, UInt32Value, UInt64Value, Value } from "@bufbuild/protobuf"; 7 | 8 | /** 9 | * @generated from message spec.Wkt 10 | */ 11 | export const Wkt = proto3.makeMessageType( 12 | "spec.Wkt", 13 | () => [ 14 | { no: 1, name: "fields", kind: "message", T: WktFields }, 15 | { no: 2, name: "oneofs", kind: "message", T: WktOneof }, 16 | { no: 3, name: "maps", kind: "message", T: WktMap }, 17 | { no: 4, name: "repeated", kind: "message", T: WktRepeated }, 18 | ], 19 | ); 20 | 21 | /** 22 | * @generated from message spec.WktFields 23 | */ 24 | export const WktFields = proto3.makeMessageType( 25 | "spec.WktFields", 26 | () => [ 27 | { no: 1, name: "double_value", kind: "message", T: DoubleValue }, 28 | { no: 2, name: "bool_value", kind: "message", T: BoolValue }, 29 | { no: 3, name: "float_value", kind: "message", T: FloatValue }, 30 | { no: 4, name: "int64_value", kind: "message", T: Int64Value }, 31 | { no: 5, name: "uint64_value", kind: "message", T: UInt64Value }, 32 | { no: 6, name: "int32_value", kind: "message", T: Int32Value }, 33 | { no: 7, name: "uint32_value", kind: "message", T: UInt32Value }, 34 | { no: 8, name: "string_value", kind: "message", T: StringValue }, 35 | { no: 9, name: "bytes_value", kind: "message", T: BytesValue }, 36 | { no: 10, name: "any", kind: "message", T: Any }, 37 | { no: 11, name: "duration", kind: "message", T: Duration }, 38 | { no: 12, name: "empty", kind: "message", T: Empty }, 39 | { no: 13, name: "field_mask", kind: "message", T: FieldMask }, 40 | { no: 14, name: "timestamp", kind: "message", T: Timestamp }, 41 | { no: 15, name: "struct", kind: "message", T: Struct }, 42 | { no: 16, name: "list_value", kind: "message", T: ListValue }, 43 | { no: 17, name: "value", kind: "message", T: Value }, 44 | { no: 18, name: "null_value", kind: "enum", T: proto3.getEnumType(NullValue) }, 45 | ], 46 | ); 47 | 48 | /** 49 | * @generated from message spec.WktOneof 50 | */ 51 | export const WktOneof = proto3.makeMessageType( 52 | "spec.WktOneof", 53 | () => [ 54 | { no: 1, name: "double_value", kind: "message", T: DoubleValue, oneof: "oneof_value" }, 55 | { no: 2, name: "bool_value", kind: "message", T: BoolValue, oneof: "oneof_value" }, 56 | { no: 3, name: "float_value", kind: "message", T: FloatValue, oneof: "oneof_value" }, 57 | { no: 4, name: "int64_value", kind: "message", T: Int64Value, oneof: "oneof_value" }, 58 | { no: 5, name: "uint64_value", kind: "message", T: UInt64Value, oneof: "oneof_value" }, 59 | { no: 6, name: "int32_value", kind: "message", T: Int32Value, oneof: "oneof_value" }, 60 | { no: 7, name: "uint32_value", kind: "message", T: UInt32Value, oneof: "oneof_value" }, 61 | { no: 8, name: "string_value", kind: "message", T: StringValue, oneof: "oneof_value" }, 62 | { no: 9, name: "bytes_value", kind: "message", T: BytesValue, oneof: "oneof_value" }, 63 | { no: 10, name: "any", kind: "message", T: Any, oneof: "oneof_value" }, 64 | { no: 11, name: "duration", kind: "message", T: Duration, oneof: "oneof_value" }, 65 | { no: 12, name: "empty", kind: "message", T: Empty, oneof: "oneof_value" }, 66 | { no: 13, name: "field_mask", kind: "message", T: FieldMask, oneof: "oneof_value" }, 67 | { no: 14, name: "timestamp", kind: "message", T: Timestamp, oneof: "oneof_value" }, 68 | { no: 15, name: "struct", kind: "message", T: Struct, oneof: "oneof_value" }, 69 | { no: 16, name: "list_value", kind: "message", T: ListValue, oneof: "oneof_value" }, 70 | { no: 17, name: "value", kind: "message", T: Value, oneof: "oneof_value" }, 71 | { no: 18, name: "null_value", kind: "enum", T: proto3.getEnumType(NullValue), oneof: "oneof_value" }, 72 | ], 73 | ); 74 | 75 | /** 76 | * @generated from message spec.WktMap 77 | */ 78 | export const WktMap = proto3.makeMessageType( 79 | "spec.WktMap", 80 | () => [ 81 | { no: 1, name: "double_value", kind: "map", K: 9 /* ScalarType.STRING */, V: {kind: "message", T: DoubleValue} }, 82 | { no: 2, name: "bool_value", kind: "map", K: 9 /* ScalarType.STRING */, V: {kind: "message", T: BoolValue} }, 83 | { no: 3, name: "float_value", kind: "map", K: 9 /* ScalarType.STRING */, V: {kind: "message", T: FloatValue} }, 84 | { no: 4, name: "int64_value", kind: "map", K: 9 /* ScalarType.STRING */, V: {kind: "message", T: Int64Value} }, 85 | { no: 5, name: "uint64_value", kind: "map", K: 9 /* ScalarType.STRING */, V: {kind: "message", T: UInt64Value} }, 86 | { no: 6, name: "int32_value", kind: "map", K: 9 /* ScalarType.STRING */, V: {kind: "message", T: Int32Value} }, 87 | { no: 7, name: "uint32_value", kind: "map", K: 9 /* ScalarType.STRING */, V: {kind: "message", T: UInt32Value} }, 88 | { no: 8, name: "string_value", kind: "map", K: 9 /* ScalarType.STRING */, V: {kind: "message", T: StringValue} }, 89 | { no: 9, name: "bytes_value", kind: "map", K: 9 /* ScalarType.STRING */, V: {kind: "message", T: BytesValue} }, 90 | { no: 10, name: "any", kind: "map", K: 9 /* ScalarType.STRING */, V: {kind: "message", T: Any} }, 91 | { no: 11, name: "duration", kind: "map", K: 9 /* ScalarType.STRING */, V: {kind: "message", T: Duration} }, 92 | { no: 12, name: "empty", kind: "map", K: 9 /* ScalarType.STRING */, V: {kind: "message", T: Empty} }, 93 | { no: 13, name: "field_mask", kind: "map", K: 9 /* ScalarType.STRING */, V: {kind: "message", T: FieldMask} }, 94 | { no: 14, name: "timestamp", kind: "map", K: 9 /* ScalarType.STRING */, V: {kind: "message", T: Timestamp} }, 95 | { no: 15, name: "struct", kind: "map", K: 9 /* ScalarType.STRING */, V: {kind: "message", T: Struct} }, 96 | { no: 16, name: "list_value", kind: "map", K: 9 /* ScalarType.STRING */, V: {kind: "message", T: ListValue} }, 97 | { no: 17, name: "value", kind: "map", K: 9 /* ScalarType.STRING */, V: {kind: "message", T: Value} }, 98 | { no: 18, name: "null_value", kind: "map", K: 9 /* ScalarType.STRING */, V: {kind: "enum", T: proto3.getEnumType(NullValue)} }, 99 | ], 100 | ); 101 | 102 | /** 103 | * @generated from message spec.WktRepeated 104 | */ 105 | export const WktRepeated = proto3.makeMessageType( 106 | "spec.WktRepeated", 107 | () => [ 108 | { no: 1, name: "double_value", kind: "message", T: DoubleValue, repeated: true }, 109 | { no: 2, name: "bool_value", kind: "message", T: BoolValue, repeated: true }, 110 | { no: 3, name: "float_value", kind: "message", T: FloatValue, repeated: true }, 111 | { no: 4, name: "int64_value", kind: "message", T: Int64Value, repeated: true }, 112 | { no: 5, name: "uint64_value", kind: "message", T: UInt64Value, repeated: true }, 113 | { no: 6, name: "int32_value", kind: "message", T: Int32Value, repeated: true }, 114 | { no: 7, name: "uint32_value", kind: "message", T: UInt32Value, repeated: true }, 115 | { no: 8, name: "string_value", kind: "message", T: StringValue, repeated: true }, 116 | { no: 9, name: "bytes_value", kind: "message", T: BytesValue, repeated: true }, 117 | { no: 10, name: "any", kind: "message", T: Any, repeated: true }, 118 | { no: 11, name: "duration", kind: "message", T: Duration, repeated: true }, 119 | { no: 12, name: "empty", kind: "message", T: Empty, repeated: true }, 120 | { no: 13, name: "field_mask", kind: "message", T: FieldMask, repeated: true }, 121 | { no: 14, name: "timestamp", kind: "message", T: Timestamp, repeated: true }, 122 | { no: 15, name: "struct", kind: "message", T: Struct, repeated: true }, 123 | { no: 16, name: "list_value", kind: "message", T: ListValue, repeated: true }, 124 | { no: 17, name: "value", kind: "message", T: Value, repeated: true }, 125 | { no: 18, name: "null_value", kind: "enum", T: proto3.getEnumType(NullValue), repeated: true }, 126 | ], 127 | ); 128 | 129 | -------------------------------------------------------------------------------- /packages/knit/.eslintrc.cjs: -------------------------------------------------------------------------------- 1 | // Copyright 2023-2024 Buf Technologies, Inc. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | /** @type { import('eslint').Linter.Config } */ 16 | module.exports = { 17 | root: true, 18 | extends: ["custom"], 19 | ignorePatterns: ["src/jest/*.ts", "tsup.config.ts", "gateway.js"], 20 | }; 21 | -------------------------------------------------------------------------------- /packages/knit/gateway.js: -------------------------------------------------------------------------------- 1 | // Copyright 2023-2024 Buf Technologies, Inc. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | // Workaround for bundlers that do not support subpath exports. 16 | module.exports = require("./dist/cjs/gateway/index.js"); 17 | -------------------------------------------------------------------------------- /packages/knit/jest.config.js: -------------------------------------------------------------------------------- 1 | // Copyright 2023-2024 Buf Technologies, Inc. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | /* 16 | * For a detailed explanation regarding each configuration property and type check, visit: 17 | * https://jestjs.io/docs/configuration 18 | */ 19 | /** @type {import('ts-jest').JestConfigWithTsJest} */ 20 | const config = { 21 | // Indicates which provider should be used to instrument code for coverage 22 | coverageProvider: "v8", 23 | 24 | // The root directory that Jest should scan for tests and modules within 25 | rootDir: "src", 26 | moduleNameMapper: { 27 | "(.+)\\.js": "$1", // https://connect.build/docs/web/supported-browsers-and-frameworks/#jest 28 | }, 29 | extensionsToTreatAsEsm: [".ts"], 30 | transform: { 31 | "^.+\\.ts$": [ 32 | "ts-jest", 33 | { 34 | useESM: true, 35 | diagnostics: { 36 | ignoreCodes: [ 37 | 151001, // ts-jest[config] (WARN) message TS151001: If you have issues related to imports, you should consider setting `esModuleInterop` to `true` in your TypeScript configuration file (usually `tsconfig.json`). See https://blogs.msdn.microsoft.com/typescript/2018/01/31/announcing-typescript-2-7/#easier-ecmascript-module-interoperability for more information. 38 | ], 39 | }, 40 | }, 41 | ], 42 | }, 43 | }; 44 | 45 | export default config; 46 | -------------------------------------------------------------------------------- /packages/knit/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "@bufbuild/knit", 3 | "version": "0.0.7", 4 | "description": "TypeScript client for Knit", 5 | "license": "Apache-2.0", 6 | "repository": { 7 | "type": "git", 8 | "url": "https://github.com/bufbuild/knit-ts.git", 9 | "directory": "packages/knit" 10 | }, 11 | "sideEffects": false, 12 | "type": "module", 13 | "scripts": { 14 | "clean": "rm -rf ./dist/* .turbo/*", 15 | "lint": "eslint .", 16 | "attw": "attw --pack", 17 | "test": "NODE_OPTIONS=--experimental-vm-modules ../../node_modules/.bin/jest", 18 | "test:watch": "pnpm run build:esm+types --watch & pnpm run test --watchAll", 19 | "build:esm": "tsup --format esm", 20 | "build:cjs": "tsup --format cjs && mv ./dist/cjs/index.d.cts ./dist/cjs/index.d.ts && mv ./dist/cjs/gateway/index.d.cts ./dist/cjs/gateway/index.d.ts", 21 | "build": "pnpm run build:esm && pnpm run build:cjs" 22 | }, 23 | "main": "./dist/cjs/index.js", 24 | "exports": { 25 | ".": { 26 | "import": { 27 | "types": "./dist/esm/index.d.ts", 28 | "default": "./dist/esm/index.js" 29 | }, 30 | "require": { 31 | "types": "./dist/cjs/index.d.ts", 32 | "default": "./dist/cjs/index.js" 33 | } 34 | }, 35 | "./gateway": { 36 | "import": { 37 | "types": "./dist/esm/gateway/index.d.ts", 38 | "default": "./dist/esm/gateway/index.js" 39 | }, 40 | "require": { 41 | "types": "./dist/cjs/gateway/index.d.ts", 42 | "default": "./dist/cjs/gateway/index.js" 43 | } 44 | } 45 | }, 46 | "typesVersions": { 47 | "*": { 48 | "gateway": [ 49 | "./dist/cjs/gateway/index.d.ts" 50 | ] 51 | } 52 | }, 53 | "dependencies": { 54 | "@bufbuild/protobuf": "^1.5.0", 55 | "@connectrpc/connect": "^1.1.3", 56 | "@connectrpc/connect-web": "^1.1.3" 57 | }, 58 | "devDependencies": { 59 | "@buf/bufbuild_knit.connectrpc_es": "1.0.0-20230504140941-3dc602456973.1", 60 | "@buf/bufbuild_knit.bufbuild_es": "1.3.1-20230504140941-3dc602456973.1", 61 | "@bufbuild/knit-test-spec": "workspace:*", 62 | "@jest/globals": "^29.7.0", 63 | "eslint-config-custom": "workspace:*", 64 | "tsconfig": "workspace:*", 65 | "tsup": "^8.0.1" 66 | }, 67 | "files": [ 68 | "dist/**" 69 | ] 70 | } 71 | -------------------------------------------------------------------------------- /packages/knit/src/alias.ts: -------------------------------------------------------------------------------- 1 | // Copyright 2023-2024 Buf Technologies, Inc. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | const aliasSymbol = Symbol("alias"); 16 | 17 | /** 18 | * Alias is the type expected by a parameter field that uses a custom json name. 19 | * 20 | * @see {@link alias} to create one. 21 | * 22 | * @internal 23 | * @param K is always a literal string 24 | */ 25 | export type Alias = { 26 | [aliasSymbol]: K; 27 | value: V; 28 | }; 29 | 30 | /** 31 | * Parameter fields that use a custom {@link https://protobuf.com/docs/language-spec#pseudo-options | json_name} 32 | * option expect a special type. This is needed to determine the special name. This function can be used 33 | * to create the special type. 34 | * 35 | * @example 36 | * For the following protobuf code: 37 | * ```protobuf 38 | * message Example { 39 | * int32 field = 1 [json_name = "someName"]; 40 | * } 41 | * ``` 42 | * We would pass a parameter value of 123 for `field` like so: 43 | * ```ts 44 | * const example: Parameter = { 45 | * field: alias("someName", 123), 46 | * }; 47 | * ``` 48 | * 49 | * @remarks 50 | * 51 | * The generated type exactly matches the custom `json_name` option. This eliminates typos and the need to 52 | * refer to the sources/generated code as it will result in a compile time error in TypeScript. 53 | * 54 | * We expect the `json_name` option usage to be minimal. If that is not the case we are open to exploring 55 | * alternatives. 56 | * 57 | * @param k The custom json name of the field. 58 | * @param v The value of the field. 59 | * @returns The aliased field. 60 | * 61 | * @privateRemarks 62 | * 63 | * This is needed to support the Json interop with protobuf's Json mapping. If we ever decide on a fully custom 64 | * Json mapping for Knit this will no longer be needed. 65 | */ 66 | export function alias(k: K, v: V): Alias { 67 | return { 68 | [aliasSymbol]: k, 69 | value: v, 70 | }; 71 | } 72 | 73 | /** 74 | * Checks if an object is an `Alias` and returns the alias and value. 75 | * 76 | * @internal 77 | */ 78 | export function getAlias( 79 | v: object, 80 | ): { alias: string; value: unknown } | undefined { 81 | if (!(aliasSymbol in v && "value" in v)) { 82 | return undefined; 83 | } 84 | return { alias: v[aliasSymbol] as string, value: v["value"] }; 85 | } 86 | -------------------------------------------------------------------------------- /packages/knit/src/client.test.ts: -------------------------------------------------------------------------------- 1 | import { describe, expect, test } from "@jest/globals"; 2 | import { createClientWithTransport } from "./client.js"; 3 | import { 4 | type HandlerContext, 5 | createRouterTransport, 6 | } from "@connectrpc/connect"; 7 | import type { AllService } from "@bufbuild/knit-test-spec/spec/all_knit.js"; 8 | import { All } from "@bufbuild/knit-test-spec/spec/all_pb.js"; 9 | import { KnitService } from "@buf/bufbuild_knit.connectrpc_es/buf/knit/gateway/v1alpha1/knit_connect.js"; 10 | import { type PartialMessage, Value } from "@bufbuild/protobuf"; 11 | import { 12 | FetchRequest, 13 | FetchResponse, 14 | Schema, 15 | Schema_Field_Type_ScalarType, 16 | } from "@buf/bufbuild_knit.bufbuild_es/buf/knit/gateway/v1alpha1/knit_pb.js"; 17 | import { 18 | Scalar, 19 | ScalarFields, 20 | } from "@bufbuild/knit-test-spec/spec/scalars_pb.js"; 21 | import type { Query } from "./schema.js"; 22 | 23 | describe("client", () => { 24 | const schema: PartialMessage = { 25 | name: All.typeName, 26 | fields: [ 27 | { 28 | name: "scalars", 29 | type: { 30 | value: { 31 | case: "message", 32 | value: { 33 | name: Scalar.typeName, 34 | fields: [ 35 | { 36 | name: "fields", 37 | type: { 38 | value: { 39 | case: "message", 40 | value: { 41 | name: ScalarFields.typeName, 42 | fields: [ 43 | { 44 | name: "str", 45 | type: { 46 | value: { 47 | case: "scalar", 48 | value: Schema_Field_Type_ScalarType.STRING, 49 | }, 50 | }, 51 | }, 52 | ], 53 | }, 54 | }, 55 | }, 56 | }, 57 | ], 58 | }, 59 | }, 60 | }, 61 | }, 62 | ], 63 | }; 64 | const request = { 65 | scalars: { fields: { str: "request" } }, 66 | }; 67 | const response = { 68 | scalars: { fields: { str: "response" } }, 69 | }; 70 | const headerKey = "Authorization"; 71 | const headerValue = "some-token"; 72 | const unary = ( 73 | { requests }: FetchRequest, 74 | { requestHeader }: HandlerContext, 75 | ): PartialMessage => { 76 | expect(requests).toHaveLength(1); 77 | expect(requests[0].body?.toJson()).toEqual(request); 78 | expect(requestHeader.get(headerKey)).toEqual(headerValue); 79 | return { 80 | responses: [ 81 | { 82 | body: Value.fromJson(response), 83 | schema: schema, 84 | method: requests[0].method, 85 | }, 86 | ], 87 | }; 88 | }; 89 | const client = createClientWithTransport( 90 | createRouterTransport(({ service }) => { 91 | service(KnitService, { 92 | fetch: unary, 93 | do: unary, 94 | async *listen( 95 | { request: actualRequest }, 96 | { requestHeader }: HandlerContext, 97 | ) { 98 | expect(requestHeader.get(headerKey)).toEqual(headerValue); 99 | expect(actualRequest?.body?.toJson()).toEqual(request); 100 | for (let i = 0; i < 5; i++) { 101 | yield { 102 | response: { 103 | body: Value.fromJson(response), 104 | schema: schema, 105 | method: actualRequest?.method, 106 | }, 107 | }; 108 | } 109 | }, 110 | }); 111 | }), 112 | { headers: { [headerKey]: headerValue } }, 113 | ); 114 | const allQuery = { 115 | scalars: { 116 | fields: { 117 | str: {}, 118 | }, 119 | }, 120 | } satisfies Query; 121 | test("fetch", async () => { 122 | const fetchResponse = await client.fetch({ 123 | "spec.AllService": { 124 | getAll: { 125 | $: request, 126 | ...allQuery, 127 | }, 128 | }, 129 | }); 130 | expect(fetchResponse["spec.AllService"].getAll).toEqual(response); 131 | }); 132 | test("do", async () => { 133 | const fetchResponse = await client.do({ 134 | "spec.AllService": { 135 | createAll: { 136 | $: request, 137 | ...allQuery, 138 | }, 139 | }, 140 | }); 141 | expect(fetchResponse["spec.AllService"].createAll).toEqual(response); 142 | }); 143 | test("listen", async () => { 144 | const listenResponse = client.listen({ 145 | "spec.AllService": { 146 | streamAll: { 147 | $: request, 148 | ...allQuery, 149 | }, 150 | }, 151 | }); 152 | let count = 0; 153 | for await (const next of listenResponse) { 154 | expect(next["spec.AllService"].streamAll).toEqual(response); 155 | count++; 156 | } 157 | expect(count).toBe(5); 158 | }); 159 | }); 160 | -------------------------------------------------------------------------------- /packages/knit/src/error.ts: -------------------------------------------------------------------------------- 1 | // Copyright 2023-2024 Buf Technologies, Inc. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | import { Code, ConnectError } from "@connectrpc/connect"; 16 | import type { Client } from "./client.js"; // eslint-disable-line @typescript-eslint/no-unused-vars 17 | import { type JsonValue, Message } from "@bufbuild/protobuf"; 18 | 19 | interface ErrorDetail { 20 | type: string; 21 | value: Uint8Array; 22 | debug?: JsonValue; 23 | } 24 | 25 | /** 26 | * KnitError is the error type returned by {@link Client} as part of the response. 27 | * It is also thrown by {@link Client} when the response is not successful. 28 | */ 29 | export class KnitError { 30 | /** 31 | * Create a new KnitError 32 | * @param code The error code 33 | * @param message The error message 34 | * @param details The error details 35 | * @param path The path where the error has occurred 36 | */ 37 | constructor( 38 | public code: Code, 39 | public message: string, 40 | public details: ErrorDetail[], 41 | public path: string, 42 | ) { } 43 | } 44 | 45 | /** 46 | * Convert any value - typically a caught error into a {@link KnitError}, 47 | * following these rules: 48 | * - If the value is already a {@link KnitError}, return it as is. 49 | * - For all other values, use {@link connectErrorFromReason} to convert to 50 | * a {@link ConnectError}, and then convert that to a {@link KnitError}. 51 | */ 52 | export function knitErrorFromReason(reason: unknown) { 53 | if (reason instanceof KnitError) { 54 | return reason; 55 | } 56 | const connectErr = ConnectError.from(reason); 57 | const details: ErrorDetail[] = []; 58 | for (const detail of connectErr.details) { 59 | if (detail instanceof Message) { 60 | details.push({ 61 | type: detail.getType().typeName, 62 | value: detail.toBinary(), 63 | debug: detail.toJson(), 64 | }); 65 | continue; 66 | } 67 | details.push({ 68 | type: detail.type, 69 | debug: detail.debug ?? null, 70 | value: detail.value, 71 | }); 72 | } 73 | return new KnitError( 74 | connectErr.code as unknown as Code, 75 | connectErr.message, 76 | details, 77 | "", 78 | ); 79 | } 80 | -------------------------------------------------------------------------------- /packages/knit/src/gateway/gateway.test.ts: -------------------------------------------------------------------------------- 1 | // Copyright 2023-2024 Buf Technologies, Inc. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | import { describe, test, expect } from "@jest/globals"; 16 | import { expectType } from "../jest/util.js"; 17 | import type { Equal } from "../utils/types.js"; 18 | import { createGateway, type UnaryAndServerStreamMethods } from "./gateway.js"; 19 | import type { KnitService } from "@buf/bufbuild_knit.connectrpc_es/buf/knit/gateway/v1alpha1/knit_connect.js"; 20 | import { AllService } from "@bufbuild/knit-test-spec/spec/all_connect.js"; 21 | import { AllResolverService } from "@bufbuild/knit-test-spec/spec/relations_connect.js"; 22 | import { createRouterTransport } from "@connectrpc/connect"; 23 | import { All } from "@bufbuild/knit-test-spec/spec/all_pb.js"; 24 | import type { AnyMessage } from "@bufbuild/protobuf"; 25 | 26 | describe("types", () => { 27 | test("UnaryAndServerStreamMethods", () => { 28 | type ExpectedType = "do" | "fetch" | "listen"; 29 | type ActualType = UnaryAndServerStreamMethods; 30 | expectType>(true); 31 | }); 32 | }); 33 | 34 | describe("service", () => { 35 | test("defaults to all supported methods", () => { 36 | const gateway = createGateway({ transport: {} as any }); 37 | gateway.service(AllService); 38 | expect([...gateway.entryPoints.keys()].sort()).toEqual( 39 | [ 40 | "spec.AllService.GetAll", 41 | "spec.AllService.CreateAll", 42 | "spec.AllService.StreamAll", 43 | ].sort(), 44 | ); 45 | }); 46 | test("respects methods option", () => { 47 | const gateway = createGateway({ transport: {} as any }); 48 | gateway.service(AllService, { methods: ["getAll"] }); 49 | expect([...gateway.entryPoints.keys()]).toEqual(["spec.AllService.GetAll"]); 50 | }); 51 | test("respects transport override", () => { 52 | const gateway = createGateway({ transport: { kind: "base" } as any }); 53 | gateway.service(AllService, { transport: { kind: "override" } as any }); 54 | expect( 55 | [...gateway.entryPoints.values()].map((v) => v.transport), 56 | ).toContainEqual({ 57 | kind: "override", 58 | }); 59 | }); 60 | }); 61 | 62 | describe("relation", () => { 63 | test("adds relation", async () => { 64 | const gateway = createGateway({ 65 | transport: createRouterTransport(({ service }) => { 66 | service(AllResolverService, { 67 | getAllRelSelf: ({ bases }) => { 68 | return { 69 | values: bases.map((base) => ({ 70 | relSelf: base, 71 | })), 72 | }; 73 | }, 74 | }); 75 | }), 76 | }); 77 | gateway.relation(AllResolverService, { 78 | getAllRelSelf: { 79 | name: "rel_self", 80 | }, 81 | }); 82 | const base = new All({ 83 | scalars: { 84 | fields: { 85 | str: "foo", 86 | }, 87 | }, 88 | }); 89 | const response = await gateway.relations 90 | .get(All.typeName) 91 | ?.get("rel_self") 92 | ?.resolver([base], undefined, {}); 93 | expect(response).toHaveLength(1); 94 | expect((response?.[0]! as AnyMessage).toJson()).toEqual(base.toJson()); 95 | }); 96 | }); 97 | -------------------------------------------------------------------------------- /packages/knit/src/gateway/headers.test.ts: -------------------------------------------------------------------------------- 1 | // Copyright 2023-2024 Buf Technologies, Inc. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | import { expect } from "@jest/globals"; 16 | import { test, describe } from "@jest/globals"; 17 | import { makeOutboundHeader } from "./headers.js"; 18 | 19 | describe("well known headers", () => { 20 | const headers = [ 21 | "Accept", 22 | "Connect", 23 | "Connection", 24 | "Expect", 25 | "Host", 26 | "Http2-Settings", 27 | "Keep-Alive", 28 | "Origin", 29 | "Proxy-Connection", 30 | "TE", 31 | "Trailer", 32 | "Transfer-Encoding", 33 | "Upgrade", 34 | ]; 35 | for (const header of headers) { 36 | test(header, () => { 37 | expect( 38 | makeOutboundHeader(new Headers({ [header]: "foo" })).has(header), 39 | ).toBeFalsy(); 40 | }); 41 | } 42 | }); 43 | 44 | describe("well known prefix", () => { 45 | const prefixes = ["Accept-", "Connect-", "Content-", "If-", "Grpc-"]; 46 | for (const prefix of prefixes) { 47 | test(prefix, () => { 48 | const header = prefix + "-FOO"; 49 | expect( 50 | makeOutboundHeader(new Headers({ [header]: "foo" })).has(header), 51 | ).toBeFalsy(); 52 | }); 53 | } 54 | }); 55 | 56 | test("Allow", () => { 57 | expect( 58 | makeOutboundHeader(new Headers({ Authorization: "foo" })).get( 59 | "Authorization", 60 | ), 61 | ).toEqual("foo"); 62 | }); 63 | -------------------------------------------------------------------------------- /packages/knit/src/gateway/headers.ts: -------------------------------------------------------------------------------- 1 | // Copyright 2023-2024 Buf Technologies, Inc. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | const forbiddenHeaders = new Set([ 16 | "accept", 17 | "connect", 18 | "connection", 19 | "expect", 20 | "host", 21 | "http2-settings", 22 | "keep-alive", 23 | "origin", 24 | "proxy-connection", 25 | "te", 26 | "trailer", 27 | "transfer-encoding", 28 | "upgrade", 29 | ]); 30 | 31 | const forbiddenPrefixes = [ 32 | ":", 33 | "accept-", 34 | "connect-", 35 | "content-", 36 | "grpc-", 37 | "if-", 38 | ] as const; 39 | 40 | const operationsHeaderKey = "Knit-Operations"; 41 | 42 | export function makeOutboundHeader( 43 | requestHeader: Headers | HeadersInit, 44 | ): Headers { 45 | const outboundHeader = new Headers(); 46 | new Headers(requestHeader).forEach((v: string, k: string) => { 47 | const lowerK = k.toLowerCase(); 48 | if (forbiddenHeaders.has(lowerK)) { 49 | return; 50 | } 51 | if (forbiddenPrefixes.findIndex((e) => lowerK.startsWith(e)) >= 0) { 52 | return; 53 | } 54 | outboundHeader.set(k, v); 55 | }); 56 | return outboundHeader; 57 | } 58 | 59 | export function makeResolverHeaders( 60 | baseHeaders: Headers | undefined, 61 | operations: string[], 62 | ) { 63 | const headers = new Headers(baseHeaders); 64 | headers.delete(operationsHeaderKey); 65 | for (const operation of operations) { 66 | headers.append(operationsHeaderKey, operation); 67 | } 68 | return headers; 69 | } 70 | -------------------------------------------------------------------------------- /packages/knit/src/gateway/index.ts: -------------------------------------------------------------------------------- 1 | // Copyright 2023-2024 Buf Technologies, Inc. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | export { createKnitService, registerKnitService } from "./service.js"; 16 | 17 | export type { CreateKnitServiceOptions } from "./service.js"; 18 | export type { Gateway } from "./gateway.js"; 19 | -------------------------------------------------------------------------------- /packages/knit/src/gateway/json.ts: -------------------------------------------------------------------------------- 1 | // Copyright 2023-2024 Buf Technologies, Inc. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | import { 16 | Message, 17 | type AnyMessage, 18 | type FieldInfo, 19 | type IMessageTypeRegistry, 20 | type JsonObject, 21 | type JsonValue, 22 | type MessageType, 23 | type PlainMessage, 24 | protoBase64, 25 | } from "@bufbuild/protobuf"; 26 | import { 27 | Error_Code, 28 | MaskField, 29 | type Schema, 30 | type Schema_Field, 31 | type Schema_Field_Type, 32 | type Schema_Field_Type_MapType, 33 | type Schema_Field_Type_RepeatedType, 34 | } from "@buf/bufbuild_knit.bufbuild_es/buf/knit/gateway/v1alpha1/knit_pb.js"; 35 | import { wktSet } from "./wkt.js"; 36 | import type { Relation } from "./gateway.js"; 37 | import { Code, ConnectError } from "@connectrpc/connect"; 38 | import type { } from "./schema.js"; 39 | 40 | export interface Patch { 41 | base: AnyMessage; 42 | target: JsonObject; 43 | errorPatch: ErrorPatch | undefined; 44 | field: PlainMessage & { 45 | relation: Relation; 46 | params?: AnyMessage; 47 | operations: string[]; 48 | }; 49 | } 50 | 51 | export interface ErrorPatch { 52 | target: JsonObject; 53 | // The name of the field to patch in the target 54 | name: string; 55 | } 56 | 57 | /** 58 | * Formats the message as a `JsonValue` according to the schema. It also returns the 59 | * patches to be applied to the message. 60 | * 61 | * It doesn't verify if the json object is valid for the schema, it just tries to apply 62 | * the mask. It will throw an error for some mismatches like Array instead of object and doesn't 63 | * throw for some like string instead of number. 64 | * 65 | * @internal 66 | */ 67 | export function formatMessage( 68 | message: AnyMessage, 69 | schema: PlainMessage, 70 | upstreamErrPatch: ErrorPatch | undefined, 71 | fallbackCatch: boolean, 72 | typeRegistry: IMessageTypeRegistry | undefined, 73 | ): [JsonValue, Patch[]] { 74 | const type = message.getType(); 75 | if (wktSet.has(type.typeName)) { 76 | return [message.toJson({ typeRegistry }), []]; 77 | } 78 | const formattedObject: JsonObject = {}; 79 | const patches: Patch[] = []; 80 | for (const field of schema.fields) { 81 | if (field.relation !== undefined) { 82 | let errorPatch = upstreamErrPatch; 83 | if (shouldCatch(field.onError, fallbackCatch)) { 84 | errorPatch = { 85 | target: formattedObject, 86 | name: field.name, 87 | }; 88 | } 89 | patches.push({ 90 | base: message, 91 | field: field as Patch["field"], 92 | target: formattedObject, 93 | errorPatch: errorPatch, 94 | }); 95 | continue; 96 | } 97 | const fieldInfo = type.fields.findJsonName( 98 | field.jsonName === "" ? field.name : field.jsonName, 99 | ); 100 | if (fieldInfo === undefined) { 101 | // Shouldn't happen because schema is created from the message 102 | throw new ConnectError( 103 | `Field '${field.name}' not found for '${type.typeName}'`, 104 | Code.InvalidArgument, 105 | ); 106 | } 107 | const [fieldValue, fieldPatches] = formatValue( 108 | message[field.name], 109 | fieldInfo, 110 | type.runtime, 111 | field.type?.value.value, 112 | upstreamErrPatch, 113 | fallbackCatch, 114 | typeRegistry, 115 | ); 116 | if (fieldValue === undefined) continue; 117 | formattedObject[field.name] = fieldValue; 118 | patches.push(...fieldPatches); 119 | } 120 | return [formattedObject, patches]; 121 | } 122 | 123 | export function formatValue( 124 | value: unknown, 125 | fieldInfo: FieldInfo, 126 | runtime: MessageType["runtime"], 127 | schemaType: PlainMessage["value"]["value"], 128 | upstreamErrPatch: ErrorPatch | undefined, 129 | fallbackCatch: boolean, 130 | typeRegistry: IMessageTypeRegistry | undefined, 131 | ): [JsonValue | undefined, Patch[]] { 132 | if (fieldInfo.kind === "map") { 133 | const formattedValue: JsonObject = {}; 134 | const patches: Patch[] = []; 135 | for (const [k, v] of Object.entries(value as object)) { 136 | const [elementValue, elementPatches] = formatSingular( 137 | v, 138 | fieldInfo.V, 139 | runtime, 140 | (schemaType as PlainMessage).value.value, 141 | upstreamErrPatch, 142 | fallbackCatch, 143 | typeRegistry, 144 | ); 145 | formattedValue[k] = elementValue ?? null; 146 | patches.push(...elementPatches); 147 | } 148 | return [formattedValue, patches]; 149 | } 150 | if (fieldInfo.repeated) { 151 | const formattedValue: JsonValue[] = []; 152 | const patches: Patch[] = []; 153 | for (const element of value as Array) { 154 | const [elementValue, elementPatches] = formatSingular( 155 | element, 156 | fieldInfo as (FieldInfo & { kind: "map" })["V"], 157 | runtime, 158 | (schemaType as PlainMessage).element 159 | .value, 160 | upstreamErrPatch, 161 | fallbackCatch, 162 | typeRegistry, 163 | ); 164 | formattedValue.push(elementValue ?? null); 165 | patches.push(...elementPatches); 166 | } 167 | return [formattedValue, patches]; 168 | } 169 | return formatSingular( 170 | value, 171 | fieldInfo, 172 | runtime, 173 | schemaType, 174 | upstreamErrPatch, 175 | fallbackCatch, 176 | typeRegistry, 177 | ); 178 | } 179 | 180 | export function formatError( 181 | rawErr: unknown, 182 | path: string, 183 | typeRegistry?: IMessageTypeRegistry, 184 | ): JsonValue { 185 | if (typeof rawErr === "object" && rawErr !== null && "[@error]" in rawErr) { 186 | return rawErr as JsonValue; 187 | } 188 | const connectErr = ConnectError.from(rawErr); 189 | const details: JsonValue[] = []; 190 | for (const detail of connectErr.details) { 191 | let type: string, value: string, debug: JsonValue | null; 192 | if (detail instanceof Message) { 193 | type = detail.getType().typeName; 194 | value = protoBase64.enc(detail.toBinary()); 195 | debug = detail.toJson({ typeRegistry }); 196 | } else { 197 | type = detail.type; 198 | value = protoBase64.enc(detail.value); 199 | debug = detail.debug ?? null; 200 | } 201 | details.push({ 202 | type: type, 203 | value: value, 204 | debug: debug, 205 | }); 206 | } 207 | return { 208 | "[@error]": {}, 209 | code: Error_Code[connectErr.code], 210 | message: connectErr.message, 211 | details: details, 212 | path: path, 213 | }; 214 | } 215 | 216 | function formatSingular( 217 | value: unknown, 218 | type: (FieldInfo & { kind: "map" })["V"], 219 | runtime: MessageType["runtime"], 220 | schemaType: PlainMessage["value"]["value"], 221 | upstreamErrPatch: ErrorPatch | undefined, 222 | fallbackCatch: boolean, 223 | typeRegistry: IMessageTypeRegistry | undefined, 224 | ): [JsonValue | undefined, Patch[]] { 225 | switch (type.kind) { 226 | case "scalar": 227 | return [runtime.json.writeScalar(type.T, value, false), []]; 228 | case "enum": 229 | if (type.T.typeName === "google.protobuf.NullValue") { 230 | return [null, []]; 231 | } 232 | // return the number if the enum is not found 233 | return [ 234 | type.T.findNumber(value as number)?.name ?? (value as number), 235 | [], 236 | ]; 237 | case "message": 238 | return formatMessage( 239 | value as AnyMessage, 240 | schemaType as PlainMessage, 241 | upstreamErrPatch, 242 | fallbackCatch, 243 | typeRegistry, 244 | ); 245 | } 246 | } 247 | 248 | export function shouldCatch( 249 | onError: PlainMessage["onError"], 250 | fallbackCatch: boolean, 251 | ) { 252 | return ( 253 | onError.case === "catch" || (fallbackCatch && onError.case !== "throw") 254 | ); 255 | } 256 | -------------------------------------------------------------------------------- /packages/knit/src/gateway/stitch.test.ts: -------------------------------------------------------------------------------- 1 | import { expect, test } from "@jest/globals"; 2 | import { stitch } from "./stitch.js"; 3 | import type { Patch } from "./json.js"; 4 | import { All } from "@bufbuild/knit-test-spec/spec/all_pb.js"; 5 | import { type AnyMessage, type PlainMessage, proto3 } from "@bufbuild/protobuf"; 6 | import { GetAllRelSelfParamResponse_AllParamResult } from "@bufbuild/knit-test-spec/spec/relations_pb.js"; 7 | import type { Relation } from "./gateway.js"; 8 | import { 9 | Schema_Field, 10 | Schema_Field_Type, 11 | } from "@buf/bufbuild_knit.bufbuild_es/buf/knit/gateway/v1alpha1/knit_pb.js"; 12 | import type {} from "./schema.js"; 13 | 14 | test("stitch", async () => { 15 | const base = new All(); 16 | const relationFieldInfo = 17 | GetAllRelSelfParamResponse_AllParamResult.fields.find(1)!; 18 | expect(relationFieldInfo).toBeDefined(); 19 | const target = {}; 20 | const params = { scalars: { fields: { str: "param" } } }; 21 | const relation = { 22 | field: relationFieldInfo, 23 | base: All, 24 | runtime: proto3, 25 | method: "", 26 | resolver: async (bases, gotParams) => { 27 | expect((gotParams as AnyMessage).toJson()).toEqual(params); 28 | return Array(bases.length).fill(new All({})); 29 | }, 30 | } satisfies Relation; 31 | const localName = relationFieldInfo.localName; 32 | const terminalField = { 33 | name: localName, 34 | path: localName + "." + localName, 35 | jsonName: "", 36 | relation: relation, 37 | operations: [], 38 | params: new All(params), 39 | onError: { case: undefined }, 40 | type: { 41 | value: { 42 | case: "message", 43 | value: { 44 | localNameTable: new Map(), 45 | name: All.typeName, 46 | fields: [], 47 | }, 48 | }, 49 | }, 50 | } satisfies PlainMessage; 51 | const type = { 52 | value: { 53 | case: "message", 54 | value: { 55 | localNameTable: new Map([[localName, terminalField]]), 56 | name: All.typeName, 57 | fields: [terminalField], 58 | }, 59 | }, 60 | } satisfies PlainMessage; 61 | const patch = { 62 | base: base, 63 | target: target, 64 | errorPatch: undefined, 65 | field: { 66 | name: localName, 67 | relation: relation, 68 | path: localName, 69 | jsonName: "", 70 | type: type, 71 | operations: [], 72 | onError: { case: undefined }, 73 | params: new All(params), 74 | }, 75 | } satisfies Patch; 76 | await stitch([patch], false, undefined, {}); 77 | expect(target).toEqual({ 78 | [localName]: { 79 | [localName]: {}, 80 | }, 81 | }); 82 | }); 83 | -------------------------------------------------------------------------------- /packages/knit/src/gateway/stitch.ts: -------------------------------------------------------------------------------- 1 | // Copyright 2023-2024 Buf Technologies, Inc. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | import type { Schema_Field } from "@buf/bufbuild_knit.bufbuild_es/buf/knit/gateway/v1alpha1/knit_pb.js"; 16 | import type { 17 | JsonObject, 18 | AnyMessage, 19 | PlainMessage, 20 | IMessageTypeRegistry, 21 | } from "@bufbuild/protobuf"; 22 | import type { Relation, ResolverContext } from "./gateway.js"; 23 | import { 24 | formatValue, 25 | type ErrorPatch, 26 | type Patch, 27 | formatError, 28 | } from "./json.js"; 29 | import { Code, ConnectError } from "@connectrpc/connect"; 30 | import { makeResolverHeaders } from "./headers.js"; 31 | 32 | interface Batch { 33 | bases: AnyMessage[]; 34 | formatTargets: JsonObject[]; 35 | errorPatches: (ErrorPatch | undefined)[]; 36 | field: PlainMessage & { 37 | relation: Relation; 38 | operations: string[]; 39 | }; 40 | } 41 | 42 | /** 43 | * Stitches the patches into the targets. 44 | */ 45 | export async function stitch( 46 | patches: Patch[], 47 | fallbackCatch: boolean, 48 | typeRegistry: IMessageTypeRegistry | undefined, 49 | context: ResolverContext, 50 | ) { 51 | while (patches.length > 0) { 52 | const batches = makeBatches(patches); 53 | const resolves: Promise[] = []; 54 | for (const batch of batches) { 55 | resolves.push(resolveBatch(batch, fallbackCatch, typeRegistry, context)); 56 | } 57 | patches = (await Promise.all(resolves)).flat(); 58 | } 59 | } 60 | 61 | async function resolveBatch( 62 | { field, bases, formatTargets, errorPatches }: Batch, 63 | fallbackCatch: boolean, 64 | typeRegistry: IMessageTypeRegistry | undefined, 65 | context: ResolverContext, 66 | ): Promise { 67 | let results: unknown[]; 68 | try { 69 | const headers = new Headers(context.headers); 70 | headers.set("Knit-Operations", field.operations.join(",")); 71 | results = await field.relation.resolver(bases, field.params, { 72 | ...context, 73 | headers: makeResolverHeaders(context.headers, field.operations), 74 | }); 75 | if (results.length !== formatTargets.length) { 76 | throw new ConnectError( 77 | `resolver returned ${results.length} results, expected ${formatTargets.length}`, 78 | Code.Internal, 79 | ); 80 | } 81 | } catch (err) { 82 | const knitError = formatError(err, "", typeRegistry); 83 | for (const errorPatch of errorPatches) { 84 | if (errorPatch === undefined) { 85 | throw err; 86 | } 87 | errorPatch.target[errorPatch.name] = knitError; 88 | } 89 | return []; 90 | } 91 | const patches: Patch[] = []; 92 | for (let i = 0; i < results.length; i++) { 93 | const target = formatTargets[i]; 94 | const result = results[i]; 95 | const [formattedResult, resultPatches] = formatValue( 96 | result, 97 | field.relation.field, 98 | field.relation.runtime, 99 | field.type?.value.value, 100 | errorPatches[i], 101 | fallbackCatch, 102 | typeRegistry, 103 | ); 104 | if (formattedResult === undefined) continue; 105 | target[field.name] = formattedResult; 106 | patches.push(...resultPatches); 107 | } 108 | return patches; 109 | } 110 | 111 | function makeBatches(patches: Patch[]) { 112 | // Maps only support reference checks for objects, so we use nested maps 113 | // as an alternative to composite keys. 114 | const groups = new Map>(); 115 | const batches: Batch[] = []; 116 | for (const patch of patches) { 117 | let relationPatches = groups.get(patch.field.relation); 118 | if (relationPatches === undefined) { 119 | relationPatches = new Map(); 120 | groups.set(patch.field.relation, relationPatches); 121 | } 122 | let batch = relationPatches.get(patch.field.params); 123 | if (batch === undefined) { 124 | batch = { 125 | bases: [], 126 | formatTargets: [], 127 | errorPatches: [], 128 | field: patch.field, 129 | }; 130 | relationPatches.set(patch.field.params, batch); 131 | batches.push(batch); 132 | } 133 | batch.bases.push(patch.base); 134 | batch.formatTargets.push(patch.target); 135 | batch.errorPatches.push(patch.errorPatch); 136 | } 137 | return batches; 138 | } 139 | -------------------------------------------------------------------------------- /packages/knit/src/gateway/util.ts: -------------------------------------------------------------------------------- 1 | // Copyright 2023-2024 Buf Technologies, Inc. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | export function min(left: number | undefined, right: number | undefined) { 16 | if (left === undefined) { 17 | return right; 18 | } 19 | if (right === undefined) { 20 | return left; 21 | } 22 | return Math.min(left, right); 23 | } 24 | -------------------------------------------------------------------------------- /packages/knit/src/gateway/wkt.ts: -------------------------------------------------------------------------------- 1 | // Copyright 2023-2024 Buf Technologies, Inc. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | export const wktSet = new Set([ 16 | "google.protobuf.DoubleValue", 17 | "google.protobuf.BoolValue", 18 | "google.protobuf.FloatValue", 19 | "google.protobuf.Int64Value", 20 | "google.protobuf.UInt64Value", 21 | "google.protobuf.Int32Value", 22 | "google.protobuf.UInt32Value", 23 | "google.protobuf.StringValue", 24 | "google.protobuf.BytesValue", 25 | "google.protobuf.Any", 26 | "google.protobuf.Duration", 27 | "google.protobuf.Empty", 28 | "google.protobuf.FieldMask", 29 | "google.protobuf.Timestamp", 30 | "google.protobuf.Struct", 31 | "google.protobuf.ListValue", 32 | "google.protobuf.Value", 33 | "google.protobuf.NullValue", 34 | ]); 35 | -------------------------------------------------------------------------------- /packages/knit/src/index.ts: -------------------------------------------------------------------------------- 1 | // Copyright 2023-2024 Buf Technologies, Inc. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | /** 16 | * This is a simple library that provides an intuitive Typescript client for Knit. 17 | * Knit is a novel way for declarative data fetching from Protobuf APIs. It is 18 | * built on top of {@link https://connect.build/ | Connect}. 19 | * 20 | * Checkout the {@link https://github.com/bufbuild/knit/tree/main/docs | docs} to know more. 21 | * 22 | * @packageDocumentation 23 | */ 24 | 25 | export { alias } from "./alias.js"; 26 | export { createClient } from "./client.js"; 27 | export { makeScopedClient } from "./scope.js"; 28 | 29 | export { Duration } from "./wkt/duration.js"; 30 | export { FieldMask } from "./wkt/field_mask.js"; 31 | export { Timestamp } from "./wkt/timestamp.js"; 32 | export { KnitError, knitErrorFromReason } from "./error.js"; 33 | 34 | export type { Empty } from "./wkt/empty.js"; 35 | export type { Struct, Value } from "./wkt/struct.js"; 36 | export type { Any } from "./wkt/any.js"; 37 | export type { Client } from "./client.js"; 38 | export type { Oneof } from "./oneof.js"; 39 | export type { 40 | Mask, 41 | Query, 42 | Parameter, 43 | Schema, 44 | DoQuery, 45 | DoSchema, 46 | ListenQuery, 47 | ListenSchema, 48 | FetchQuery, 49 | FetchSchema, 50 | } from "./schema.js"; 51 | -------------------------------------------------------------------------------- /packages/knit/src/jest/util.ts: -------------------------------------------------------------------------------- 1 | // Copyright 2023-2024 Buf Technologies, Inc. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | import type { Equal } from "../utils/types.js"; 16 | 17 | /** 18 | * Useful to test types: `expectType>(true)` 19 | * @param _ 20 | */ 21 | export function expectType(_expectedValue: T) { } // eslint-disable-line @typescript-eslint/no-unused-vars,@typescript-eslint/no-empty-function 22 | 23 | /** 24 | * The equality check is accurate, the diff may not cover all cases, only used for debugging type tests. 25 | */ 26 | export type DeepDiff = Equal extends true 27 | ? never 28 | : L extends (infer LE)[] 29 | ? R extends (infer RE)[] 30 | ? DeepDiff[] 31 | : L | R 32 | : L extends Record 33 | ? R extends Record 34 | ? { 35 | [P in keyof L | keyof R as P extends keyof R & keyof L 36 | ? Equal extends true 37 | ? never 38 | : P 39 | : P]: P extends keyof R & keyof L 40 | ? DeepDiff 41 | : P extends keyof L 42 | ? L[P] 43 | : P extends keyof R 44 | ? R[P] 45 | : never; 46 | } 47 | : L | R 48 | : L | R; 49 | -------------------------------------------------------------------------------- /packages/knit/src/oneof.test.ts: -------------------------------------------------------------------------------- 1 | // Copyright 2023-2024 Buf Technologies, Inc. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | import { describe, test } from "@jest/globals"; 16 | import type { Oneof } from "./oneof.js"; 17 | type Cases = { a: string; b: number }; 18 | 19 | describe("Oneof", () => { 20 | const f = (_: Oneof) => { }; 21 | test("works for correct cases", () => { 22 | f({ "@case": "a", value: "str" }); 23 | f({ "@case": "b", value: 123 }); 24 | }); 25 | test("fails on empty object", () => { 26 | //@ts-expect-error 27 | const _ = {} satisfies Oneof; 28 | }); 29 | test("fails if not made from `makeOneof`", () => { 30 | // @ts-expect-error 31 | const _ = { a: "string" } satisfies Oneof; 32 | }); 33 | }); 34 | -------------------------------------------------------------------------------- /packages/knit/src/oneof.ts: -------------------------------------------------------------------------------- 1 | // Copyright 2023-2024 Buf Technologies, Inc. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | import type { AnyQuery } from "./protocol.js"; 16 | import type { AnyRecord, OneOrMore } from "./utils/types.js"; 17 | 18 | /** 19 | * Represents a Oneof type. 20 | * 21 | * The type has `@case` and `value` fields. `@case` 22 | * is the name of the field that is set, and `value` is the corresponding value. 23 | * 24 | * This can be used in a switch statement exhaustively check all possible cases. 25 | * 26 | * @remarks 27 | * 28 | * @example 29 | * Here's an example of using it in a switch case: 30 | * ```ts 31 | * let result: Oneof<{value: number; error: string}>; 32 | * 33 | * switch(result.case) { 34 | * case "value": 35 | * console.log(`The result is ${result.value}`); 36 | * // ^? number 37 | * break; 38 | * case "error": 39 | * throw new Error(result.value); 40 | * // ^? string 41 | * } 42 | * ``` 43 | * 44 | * @privateRemarks 45 | * 46 | * We use the '@case' to identify oneofs at runtime. This is needed for parameter types, to make the result and parameter 47 | * types interoperable we also return the result with these same field keys. 48 | */ 49 | export type Oneof = { 50 | [K in keyof T]-?: { 51 | "@case": K; 52 | value: T[K]; 53 | }; 54 | }[keyof T]; 55 | 56 | /** 57 | * Checks if an object is a `OneofQuery`. 58 | * 59 | * @internal 60 | */ 61 | export function isOneofQuery(v: object): v is { "@oneof": AnyQuery } { 62 | return "@oneof" in v; 63 | } 64 | 65 | /** 66 | * Returns the object as a {@link Oneof} if it is one or `undefined`. 67 | * 68 | * @internal 69 | */ 70 | export function getOneof( 71 | v: object, 72 | ): { "@case": string; value: unknown } | undefined { 73 | if ("@case" in v) { 74 | return v as Oneof>; 75 | } 76 | return undefined; 77 | } 78 | 79 | /** 80 | * The type of the oneof query. 81 | * 82 | * @internal 83 | */ 84 | export type OneofQuery = { 85 | "@oneof": OneOrMore; 86 | }; 87 | -------------------------------------------------------------------------------- /packages/knit/src/protocol.ts: -------------------------------------------------------------------------------- 1 | // Copyright 2023-2024 Buf Technologies, Inc. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | import { type PartialMessage, Value } from "@bufbuild/protobuf"; 16 | import { 17 | type ListenResponse, 18 | type MaskField, 19 | type Request, 20 | type Response, 21 | type Schema, 22 | } from "@buf/bufbuild_knit.bufbuild_es/buf/knit/gateway/v1alpha1/knit_pb.js"; 23 | import { decodeMessage, format } from "./json.js"; 24 | import { isOneofQuery } from "./oneof.js"; 25 | import { KnitError, knitErrorFromReason } from "./error.js"; 26 | import { Code } from "@connectrpc/connect"; 27 | 28 | /** 29 | * @internal 30 | */ 31 | export type AnyQuery = { 32 | [k: string]: AnyQuery; 33 | }; 34 | 35 | /** 36 | * 37 | * @internal 38 | */ 39 | export function makeRequests( 40 | query: AnyQuery, 41 | ): [PartialMessage[], Record[]] { 42 | const requests: PartialMessage[] = []; 43 | const oneofs: Record[] = []; 44 | for (const [service, methods] of Object.entries(query)) { 45 | for (const [method, request] of Object.entries(methods)) { 46 | const [maskField, oneofTable] = makeMaskField( 47 | request, 48 | service + "." + method, 49 | ); 50 | requests.push({ 51 | method: service + "." + capitalize(method), 52 | body: maskField.params, 53 | mask: maskField.mask, 54 | onError: maskField.onError, 55 | }); 56 | oneofs.push(oneofTable); 57 | } 58 | } 59 | return [requests, oneofs]; 60 | } 61 | 62 | function makeMaskField( 63 | value: AnyQuery, 64 | path: string, 65 | ): [PartialMessage, Record] { 66 | let params: PartialMessage | undefined = undefined; 67 | let onError: PartialMessage["onError"] = undefined; 68 | const mask: PartialMessage[] = []; 69 | let oneofTable: Record = {}; 70 | for (const [k, v] of Object.entries(value)) { 71 | if (k === "$") { 72 | params = Value.fromJson(format(v)); 73 | continue; 74 | } 75 | if (k === "@throw") { 76 | onError = { case: "throw", value: {} }; 77 | continue; 78 | } 79 | if (k === "@catch") { 80 | onError = { case: "catch", value: {} }; 81 | continue; 82 | } 83 | if (isOneofQuery(v)) { 84 | for (const [oneOfKey, oneOfValue] of Object.entries(v["@oneof"])) { 85 | const keyPath = path + "." + oneOfKey; 86 | const [maskField, fieldOneofTable] = makeMaskField(oneOfValue, keyPath); 87 | mask.push({ ...maskField, name: oneOfKey }); 88 | oneofTable = { 89 | ...oneofTable, 90 | [keyPath]: k, 91 | ...fieldOneofTable, 92 | }; 93 | } 94 | continue; 95 | } 96 | const [maskField, fieldOneofTable] = makeMaskField(v, path + "." + k); 97 | mask.push({ ...maskField, name: k }); 98 | oneofTable = { 99 | ...oneofTable, 100 | ...fieldOneofTable, 101 | }; 102 | } 103 | return [{ params, mask, onError }, oneofTable]; 104 | } 105 | 106 | /** 107 | * 108 | * @internal 109 | */ 110 | export function makeResult( 111 | oneofs: Record[], 112 | responses: Response[], 113 | ) { 114 | const result: { [k: string]: { [k: string]: unknown } } = {}; 115 | for (let i = 0; i < responses.length; i++) { 116 | const response = responses[i]; 117 | const serviceParts = response.method.split("."); 118 | const method = uncapitalize(serviceParts.pop() as string); 119 | const service = serviceParts.join("."); 120 | let serviceResult = result[service]; 121 | // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition 122 | if (serviceResult === undefined) { 123 | result[service] = serviceResult = {}; 124 | } 125 | serviceResult[method] = decodeMessage( 126 | oneofs[i], 127 | response.body?.toJson(), 128 | response.schema, 129 | service + "." + method, 130 | ); 131 | } 132 | return result; 133 | } 134 | 135 | /** 136 | * 137 | * @internal 138 | */ 139 | export async function* makeResultIterable( 140 | oneofs: Record, 141 | response: AsyncIterable, 142 | ) { 143 | let schema: Schema | undefined = undefined; 144 | try { 145 | for await (const next of response) { 146 | if (next.response === undefined) { 147 | throw new KnitError(Code.Unknown, "no response", [], ""); 148 | } 149 | if (schema === undefined) { 150 | schema = next.response.schema; 151 | } else { 152 | next.response.schema = schema; 153 | } 154 | yield makeResult([oneofs], [next.response]); 155 | } 156 | } catch (reason) { 157 | throw knitErrorFromReason(reason); 158 | } 159 | } 160 | 161 | function capitalize(s: string): string { 162 | return s.charAt(0).toUpperCase() + s.slice(1); 163 | } 164 | 165 | function uncapitalize(s: string): string { 166 | return s.charAt(0).toLowerCase() + s.slice(1); 167 | } 168 | -------------------------------------------------------------------------------- /packages/knit/src/scope.test.ts: -------------------------------------------------------------------------------- 1 | // Copyright 2023-2024 Buf Technologies, Inc. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | import type { AllService } from "@bufbuild/knit-test-spec/spec/all_knit.js"; 16 | import type { WktService } from "@bufbuild/knit-test-spec/spec/wkt_knit.js"; 17 | import type { SubService } from "@bufbuild/knit-test-spec/spec/sub/sub_knit.js"; 18 | import { describe, expect, test } from "@jest/globals"; 19 | import type { Client } from "./client.js"; 20 | 21 | import { makeScopedClient } from "./scope.js"; 22 | 23 | type Schema = AllService & WktService & SubService; 24 | 25 | const client = { 26 | async fetch(q: unknown) { 27 | return q; 28 | }, 29 | async do(q: unknown) { 30 | return q; 31 | }, 32 | listen(q: unknown) { 33 | return Promise.resolve(); 34 | }, 35 | } as any as Client; 36 | 37 | describe("scope", () => { 38 | test("package", async () => { 39 | const scopedClient = makeScopedClient(client, "spec.sub"); 40 | const res = await scopedClient.do({ 41 | SubService: { 42 | subMethod: { 43 | $: {}, 44 | }, 45 | }, 46 | }); 47 | expect(res).toStrictEqual({ 48 | SubService: { 49 | subMethod: { 50 | $: {}, 51 | }, 52 | }, 53 | }); 54 | }); 55 | test("package prefix", async () => { 56 | const scopedClient = makeScopedClient(client, "spec"); 57 | const res = await scopedClient.do({ 58 | AllService: { 59 | createAll: { 60 | $: {}, 61 | }, 62 | }, 63 | "sub.SubService": { 64 | subMethod: { 65 | $: {}, 66 | }, 67 | }, 68 | }); 69 | expect(res).toStrictEqual({ 70 | AllService: { 71 | createAll: { 72 | $: {}, 73 | }, 74 | }, 75 | "sub.SubService": { 76 | subMethod: { 77 | $: {}, 78 | }, 79 | }, 80 | }); 81 | }); 82 | }); 83 | -------------------------------------------------------------------------------- /packages/knit/src/scope.ts: -------------------------------------------------------------------------------- 1 | // Copyright 2023-2024 Buf Technologies, Inc. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | /* eslint-disable @typescript-eslint/no-unsafe-return,@typescript-eslint/no-unsafe-argument,@typescript-eslint/no-explicit-any */ 16 | import type { Schema } from "./schema.js"; 17 | import type { Client } from "./client.js"; 18 | import type { AnyQuery } from "./protocol.js"; 19 | 20 | /** 21 | * Scopes the client a package or package prefix. 22 | * 23 | * @example 24 | * ```ts 25 | * client.do({ 26 | * "com.example.foo.v1.FooService": { 27 | * ... 28 | * }, 29 | * "com.example.bar.v1.BarService": { 30 | * ... 31 | * }, 32 | * }); 33 | * // The above call can be simplified. 34 | * const scopedClient = makeScopedClient(client, "com.example"); 35 | * // `com.example` is be omitted: 36 | * scopedClient.do({ 37 | * "foo.v1.FooService": { 38 | * ... 39 | * }, 40 | * "bar.v1.BarService": { 41 | * ... 42 | * }, 43 | * }); 44 | * 45 | * 46 | * ``` 47 | * @param client Any Knit client. 48 | * @param scope The prefix to which to scope client. 49 | */ 50 | export function makeScopedClient< 51 | S extends Schema, 52 | P extends Split, ".">, 53 | >(client: Client, scope: P): Client> { 54 | return { 55 | fetch: async (query) => { 56 | return scopeResult( 57 | (await client.fetch( 58 | unscopeQuery(query as AnyQuery, scope) as any, 59 | )) as any, 60 | scope, 61 | ) as any; 62 | }, 63 | do: async (query) => { 64 | return scopeResult( 65 | (await client.do(unscopeQuery(query as AnyQuery, scope) as any)) as any, 66 | scope, 67 | ) as any; 68 | }, 69 | listen: (query) => { 70 | const resultIterable = client.listen( 71 | unscopeQuery(query as AnyQuery, scope) as any, 72 | ); 73 | return scopeResultIterable(resultIterable as any, scope) as any; 74 | }, 75 | }; 76 | } 77 | 78 | async function* scopeResultIterable( 79 | result: AsyncIterable<{ [k: string]: unknown }>, 80 | scope: string, 81 | ) { 82 | for await (const next of result) { 83 | yield scopeResult(next, scope); 84 | } 85 | } 86 | 87 | function unscopeQuery(scopedQuery: AnyQuery, scope: string): AnyQuery { 88 | const query: { [k: string]: any } = {}; 89 | for (const [k, v] of Object.entries(scopedQuery)) { 90 | query[scope + "." + k] = v; 91 | } 92 | return query; 93 | } 94 | 95 | function scopeResult(result: { [k: string]: unknown }, scope: string) { 96 | const scopedResult: typeof result = {}; 97 | for (const [k, v] of Object.entries(result as object)) { 98 | if (!k.startsWith(scope + ".")) { 99 | // Should not happen but could be another extension so we 100 | // just ignore. 101 | continue; 102 | } 103 | scopedResult[k.slice(scope.length + 1)] = v; 104 | } 105 | return scopedResult; 106 | } 107 | 108 | /** 109 | * For the string `com.example.foo.v1.FooService` as S and `.` as C, the expected 110 | * result is "com" | "com.example" | "com.example.foo" | "com.example.foo.v1" 111 | */ 112 | // prettier-ignore 113 | type Split< 114 | S extends string, 115 | C extends string, 116 | P extends string = "" 117 | > = 118 | // Check to see if S has at least one `C` somewhere. 119 | // This always matches the first `C`. 120 | // 121 | // For com.example.foo.v1.FooService 122 | // L -> com 123 | // R -> example.foo.v1.FooService 124 | S extends `${infer L}${C}${infer R}` 125 | // Prefix `L` with `P`, for the first run P is always ''. 126 | // 127 | // For com.example.foo.v1.FooService 128 | // 129 | // First iteration: 130 | // "com" | Split<"example.foo.v1.FooService", ".", "com."> 131 | // 132 | // Second iteration: 133 | // "com.example" | Split<"foo.v1.FooService", ".", "com.example."> 134 | ? `${P}${L}` | Split 135 | // Last iteration: 136 | // `never`. `|` with never is a noop. 137 | : never; 138 | 139 | /** 140 | * Scope a Schema to only include services that have the prefix `P` and 141 | * strip `P` from their names. 142 | */ 143 | type Scope = { 144 | [K in keyof S as K extends `${P}.${infer R}` ? R : never]: S[K]; 145 | }; 146 | 147 | /** 148 | * Useful to narrow the type. 149 | * 150 | * Eg: keyof T = string | number; 151 | * 152 | * But if we know that T will only have string keys or 153 | * if we only care about string keys. Cast 154 | * can be used to get a union of all the string keys. 155 | */ 156 | type Cast = T extends V ? T : never; 157 | -------------------------------------------------------------------------------- /packages/knit/src/utils/types.ts: -------------------------------------------------------------------------------- 1 | // Copyright 2023-2024 Buf Technologies, Inc. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | /** 16 | * A type that requires exactly one of the properties of an object to be set. 17 | */ 18 | export type ExactlyOne = { 19 | [K in keyof T]-?: Required> & Partial, never>>; //prettier-ignore 20 | }[keyof T]; 21 | 22 | /** 23 | * A type that requires at least one of the properties of an object to be set. 24 | * 25 | */ 26 | export type OneOrMore = { 27 | [K in keyof T]-?: Required> & Partial>>; //prettier-ignore 28 | }[keyof T]; 29 | 30 | /** 31 | * A type that requires exactly one or none of the properties of an object to be set. 32 | */ 33 | export type ZeroOrOne = 34 | | ExactlyOne 35 | | Partial>; 36 | 37 | /** 38 | * Allows anything object type ({}). 39 | */ 40 | export type AnyRecord = { [K in string]: any }; // eslint-disable-line @typescript-eslint/no-explicit-any 41 | 42 | /** 43 | * 44 | * Checks if two types are equal. 45 | * 46 | * @link https://github.com/microsoft/TypeScript/issues/27024#issuecomment-421529650 47 | */ 48 | //prettier-ignore 49 | export type Equal = 50 | (() => T extends L ? 1 : 2) extends (() => T extends R ? 1 : 2) 51 | ? true 52 | : false; 53 | 54 | /** 55 | * @link https://www.typescriptlang.org/docs/handbook/2/conditional-types.html#distributive-conditional-types 56 | */ 57 | export type DistributiveKeyOf = T extends T ? keyof T : never; 58 | 59 | /** 60 | * Seals `I` to only contain field of `T`. 61 | */ 62 | //prettier-ignore 63 | export type Subset = 64 | Equal extends true 65 | ? T 66 | : T extends any[] // eslint-disable-line @typescript-eslint/no-explicit-any 67 | ? Array, Element>> 68 | : T extends AnyRecord 69 | ? SubsetRecord 70 | : T; 71 | 72 | //prettier-ignore 73 | type SubsetRecord = 74 | & { [P in keyof T]: Subset

; } 75 | & Record>, never>; 76 | 77 | type Element = T extends (infer E)[] ? E : never; 78 | -------------------------------------------------------------------------------- /packages/knit/src/wkt/any.ts: -------------------------------------------------------------------------------- 1 | // Copyright 2023-2024 Buf Technologies, Inc. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | import type { Value } from "./struct.js"; 16 | 17 | /** 18 | * `Any` contains an arbitrary serialized protocol buffer message along with a 19 | * URL that describes the type of the serialized message. 20 | * 21 | * The JSON representation of an `Any` value uses the regular 22 | * representation of the deserialized, embedded message, with an 23 | * additional field `@type` which contains the type URL. Example: 24 | * 25 | * package google.profile; 26 | * message Person { 27 | * string first_name = 1; 28 | * string last_name = 2; 29 | * } 30 | * 31 | * { 32 | * "@type": "type.googleapis.com/google.profile.Person", 33 | * "firstName": , 34 | * "lastName": 35 | * } 36 | * 37 | * If the embedded message type is well-known and has a custom JSON 38 | * representation, that representation will be embedded adding a field 39 | * `value` which holds the custom JSON in addition to the `@type` 40 | * field. Example (for message [google.protobuf.Duration][]): 41 | * 42 | * { 43 | * "@type": "type.googleapis.com/google.protobuf.Duration", 44 | * "value": "1.212s" 45 | * } 46 | */ 47 | export type Any = { 48 | "@type": string; 49 | [k: string]: Value; 50 | }; 51 | -------------------------------------------------------------------------------- /packages/knit/src/wkt/duration.ts: -------------------------------------------------------------------------------- 1 | // Copyright 2023-2024 Buf Technologies, Inc. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | /** 16 | * A Duration represents a signed, fixed-length span of time represented 17 | * as a count of seconds and fractions of seconds at nanosecond 18 | * resolution. It is independent of any calendar and concepts like "day" 19 | * or "month". It is related to Timestamp in that the difference between 20 | * two Timestamp values is a Duration and it can be added or subtracted 21 | * from a Timestamp. Range is approximately +-10,000 years. 22 | * 23 | */ 24 | export class Duration { 25 | /** 26 | * Signed seconds of the span of time. Must be from -315,576,000,000 27 | * to +315,576,000,000 inclusive. Note: these bounds are computed from: 28 | * 60 sec/min * 60 min/hr * 24 hr/day * 365.25 days/year * 10000 years 29 | */ 30 | seconds = BigInt("0"); 31 | 32 | /** 33 | * Signed fractions of a second at nanosecond resolution of the span 34 | * of time. Durations less than one second are represented with a 0 35 | * `seconds` field and a positive or negative `nanos` field. For durations 36 | * of one second or more, a non-zero value for the `nanos` field must be 37 | * of the same sign as the `seconds` field. Must be from -999,999,999 38 | * to +999,999,999 inclusive. 39 | */ 40 | nanos = 0; 41 | 42 | constructor(data?: { seconds?: bigint; nanos?: number }) { 43 | this.seconds = data?.seconds ?? this.seconds; 44 | this.nanos = data?.nanos ?? this.nanos; 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /packages/knit/src/wkt/empty.ts: -------------------------------------------------------------------------------- 1 | // Copyright 2023-2024 Buf Technologies, Inc. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | /** 16 | * A generic empty message that you can re-use to avoid defining duplicated 17 | * empty messages in your APIs. A typical example is to use it as the request 18 | * or the response type of an API method. For instance: 19 | * 20 | * service Foo { 21 | * rpc Bar(google.protobuf.Empty) returns (google.protobuf.Empty); 22 | * } 23 | * 24 | * 25 | */ 26 | export type Empty = Record; 27 | -------------------------------------------------------------------------------- /packages/knit/src/wkt/field_mask.ts: -------------------------------------------------------------------------------- 1 | // Copyright 2023-2024 Buf Technologies, Inc. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | /** 16 | * `FieldMask` represents a set of symbolic field paths, for example: 17 | * 18 | * paths: "f.a" 19 | * paths: "f.b.d" 20 | * 21 | * Here `f` represents a field in some root message, `a` and `b` 22 | * fields in the message found in `f`, and `d` a field found in the 23 | * message in `f.b`. 24 | * 25 | * Field masks are used to specify a subset of fields that should be 26 | * returned by a get operation or modified by an update operation. 27 | * Field masks also have a custom JSON encoding (see below). 28 | * 29 | * # Field Masks in Projections 30 | * 31 | * When used in the context of a projection, a response message or 32 | * sub-message is filtered by the API to only contain those fields as 33 | * specified in the mask. For example, if the mask in the previous 34 | * example is applied to a response message as follows: 35 | * 36 | * f { 37 | * a : 22 38 | * b { 39 | * d : 1 40 | * x : 2 41 | * } 42 | * y : 13 43 | * } 44 | * z: 8 45 | * 46 | * The result will not contain specific values for fields x,y and z 47 | * (their value will be set to the default, and omitted in proto text 48 | * output): 49 | * 50 | * 51 | * f { 52 | * a : 22 53 | * b { 54 | * d : 1 55 | * } 56 | * } 57 | * 58 | * A repeated field is not allowed except at the last position of a 59 | * paths string. 60 | * 61 | * If a FieldMask object is not present in a get operation, the 62 | * operation applies to all fields (as if a FieldMask of all fields 63 | * had been specified). 64 | * 65 | * Note that a field mask does not necessarily apply to the 66 | * top-level response message. In case of a REST get operation, the 67 | * field mask applies directly to the response, but in case of a REST 68 | * list operation, the mask instead applies to each individual message 69 | * in the returned resource list. In case of a REST custom method, 70 | * other definitions may be used. Where the mask applies will be 71 | * clearly documented together with its declaration in the API. In 72 | * any case, the effect on the returned resource/resources is required 73 | * behavior for APIs. 74 | * 75 | * # Field Masks in Update Operations 76 | * 77 | * A field mask in update operations specifies which fields of the 78 | * targeted resource are going to be updated. The API is required 79 | * to only change the values of the fields as specified in the mask 80 | * and leave the others untouched. If a resource is passed in to 81 | * describe the updated values, the API ignores the values of all 82 | * fields not covered by the mask. 83 | * 84 | * If a repeated field is specified for an update operation, new values will 85 | * be appended to the existing repeated field in the target resource. Note that 86 | * a repeated field is only allowed in the last position of a `paths` string. 87 | * 88 | * If a sub-message is specified in the last position of the field mask for an 89 | * update operation, then new value will be merged into the existing sub-message 90 | * in the target resource. 91 | * 92 | * For example, given the target message: 93 | * 94 | * f { 95 | * b { 96 | * d: 1 97 | * x: 2 98 | * } 99 | * c: [1] 100 | * } 101 | * 102 | * And an update message: 103 | * 104 | * f { 105 | * b { 106 | * d: 10 107 | * } 108 | * c: [2] 109 | * } 110 | * 111 | * then if the field mask is: 112 | * 113 | * paths: ["f.b", "f.c"] 114 | * 115 | * then the result will be: 116 | * 117 | * f { 118 | * b { 119 | * d: 10 120 | * x: 2 121 | * } 122 | * c: [1, 2] 123 | * } 124 | * 125 | * An implementation may provide options to override this default behavior for 126 | * repeated and message fields. 127 | * 128 | * In order to reset a field's value to the default, the field must 129 | * be in the mask and set to the default value in the provided resource. 130 | * Hence, in order to reset all fields of a resource, provide a default 131 | * instance of the resource and set all fields in the mask, or do 132 | * not provide a mask as described below. 133 | * 134 | * If a field mask is not present on update, the operation applies to 135 | * all fields (as if a field mask of all fields has been specified). 136 | * Note that in the presence of schema evolution, this may mean that 137 | * fields the client does not know and has therefore not filled into 138 | * the request will be reset to their default. If this is unwanted 139 | * behavior, a specific service may require a client to always specify 140 | * a field mask, producing an error if not. 141 | * 142 | * As with get operations, the location of the resource which 143 | * describes the updated values in the request message depends on the 144 | * operation kind. In any case, the effect of the field mask is 145 | * required to be honored by the API. 146 | */ 147 | export class FieldMask { 148 | /** 149 | * The set of field mask paths. 150 | */ 151 | paths: string[] = []; 152 | 153 | constructor(data?: { paths?: string[] }) { 154 | this.paths = data?.paths ?? this.paths; 155 | } 156 | } 157 | -------------------------------------------------------------------------------- /packages/knit/src/wkt/struct.ts: -------------------------------------------------------------------------------- 1 | // Copyright 2023-2024 Buf Technologies, Inc. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | /** 16 | * Represents any possible JSON value: 17 | * - number 18 | * - string 19 | * - boolean 20 | * - null 21 | * - object (with any JSON value as property) 22 | * - array (with any JSON value as element) 23 | */ 24 | export type Value = number | string | boolean | null | Struct | Value[]; 25 | 26 | /** 27 | * Represents a JSON object. 28 | */ 29 | export type Struct = { 30 | [k: string]: Value; 31 | }; 32 | -------------------------------------------------------------------------------- /packages/knit/src/wkt/timestamp.ts: -------------------------------------------------------------------------------- 1 | // Copyright 2023-2024 Buf Technologies, Inc. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | /** 16 | * A Timestamp represents a point in time independent of any time zone or local 17 | * calendar, encoded as a count of seconds and fractions of seconds at 18 | * nanosecond resolution. The count is relative to an epoch at UTC midnight on 19 | * January 1, 1970, in the proleptic Gregorian calendar which extends the 20 | * Gregorian calendar backwards to year one. 21 | * 22 | * All minutes are 60 seconds long. Leap seconds are "smeared" so that no leap 23 | * second table is needed for interpretation, using a [24-hour linear 24 | * smear](https://developers.google.com/time/smear). 25 | * 26 | * The range is from 0001-01-01T00:00:00Z to 9999-12-31T23:59:59.999999999Z. By 27 | * restricting to that range, we ensure that we can convert to and from [RFC 28 | * 3339](https://www.ietf.org/rfc/rfc3339.txt) date strings. 29 | */ 30 | export class Timestamp { 31 | /** 32 | * Represents seconds of UTC time since Unix epoch 33 | * 1970-01-01T00:00:00Z. Must be from 0001-01-01T00:00:00Z to 34 | * 9999-12-31T23:59:59Z inclusive. 35 | */ 36 | seconds = BigInt(0); 37 | 38 | /** 39 | * Non-negative fractions of a second at nanosecond resolution. Negative 40 | * second values with fractions must still have non-negative nanos values 41 | * that count forward in time. Must be from 0 to 999,999,999 42 | * inclusive. 43 | */ 44 | nanos = 0; 45 | 46 | constructor(data?: { seconds?: bigint; nanos?: number }) { 47 | this.seconds = data?.seconds ?? this.seconds; 48 | this.nanos = data?.nanos ?? this.nanos; 49 | } 50 | 51 | toDate(): Date { 52 | return new Date( 53 | Number(this.seconds) * 1000 + Math.ceil(this.nanos / 1000000), 54 | ); 55 | } 56 | 57 | static fromDate(date: Date): Timestamp { 58 | const ms = date.getTime(); 59 | return new Timestamp({ 60 | seconds: BigInt(Math.floor(ms / 1000)), 61 | nanos: (ms % 1000) * 1000000, 62 | }); 63 | } 64 | } 65 | -------------------------------------------------------------------------------- /packages/knit/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "tsconfig/library.json", 3 | "compilerOptions": { 4 | "target": "ES2018" 5 | }, 6 | "files": ["src/index.ts", "src/gateway/index.ts"] 7 | } 8 | -------------------------------------------------------------------------------- /packages/knit/tsup.config.ts: -------------------------------------------------------------------------------- 1 | import { defineConfig, type Options } from "tsup"; 2 | import { writeFileSync } from "fs"; 3 | 4 | const cjsPackageJson = { 5 | type: "commonjs", 6 | }; 7 | 8 | const esmPackageJson = { 9 | type: "module", 10 | sideEffects: false, 11 | }; 12 | 13 | const sharedOptions = { 14 | splitting: false, // Doesn't share code between entry points. 15 | dts: true, 16 | clean: true, 17 | treeshake: true, 18 | entry: ["./src/index.ts", "./src/gateway/index.ts"], 19 | outExtension() { 20 | return { 21 | js: ".js", 22 | dts: ".d.ts", 23 | }; 24 | }, 25 | } satisfies Options; 26 | 27 | const cjsOptions = { 28 | ...sharedOptions, 29 | format: "cjs", 30 | outDir: "./dist/cjs", 31 | onSuccess: async () => 32 | writeFileSync("./dist/cjs/package.json", JSON.stringify(cjsPackageJson)), 33 | } satisfies Options; 34 | 35 | const esmOptions = { 36 | ...sharedOptions, 37 | format: "esm", 38 | outDir: "./dist/esm", 39 | onSuccess: async () => 40 | writeFileSync("./dist/esm/package.json", JSON.stringify(esmPackageJson)), 41 | } satisfies Options; 42 | 43 | export default defineConfig((options) => { 44 | let format = ""; 45 | if (typeof options.format === "string") { 46 | format = options.format; 47 | } else if (Array.isArray(options.format)) { 48 | if (options.format.length != 1) { 49 | throw new Error("Only one format can be specified at a time"); 50 | } 51 | format = options.format[0]; 52 | } 53 | switch (format) { 54 | case "cjs": 55 | return { ...cjsOptions, ...options }; 56 | case "esm": 57 | return { ...esmOptions, ...options }; 58 | default: 59 | throw new Error( 60 | `Unexpected build format ${options.format} must be either cjs or esm`, 61 | ); 62 | } 63 | }); 64 | -------------------------------------------------------------------------------- /packages/protoc-gen-knit-ts/.eslintrc.cjs: -------------------------------------------------------------------------------- 1 | // Copyright 2023-2024 Buf Technologies, Inc. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | /** @type { import('eslint').Linter.Config } */ 16 | module.exports = { 17 | root: true, 18 | extends: ["custom"], 19 | }; 20 | -------------------------------------------------------------------------------- /packages/protoc-gen-knit-ts/bin/protoc-gen-knit-ts: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env node 2 | 3 | const {runNodeJs} = require("@bufbuild/protoplugin"); 4 | const {protocGenKnitTs} = require("../dist/cjs/index.js"); 5 | 6 | runNodeJs(protocGenKnitTs); -------------------------------------------------------------------------------- /packages/protoc-gen-knit-ts/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "@bufbuild/protoc-gen-knit-ts", 3 | "version": "0.0.7", 4 | "description": "TypeScript code generator for Knit", 5 | "license": "Apache-2.0", 6 | "repository": { 7 | "type": "git", 8 | "url": "https://github.com/bufbuild/knit-ts.git", 9 | "directory": "packages/protoc-gen-knit-ts" 10 | }, 11 | "bin": { 12 | "protoc-gen-knit-ts": "bin/protoc-gen-knit-ts" 13 | }, 14 | "engines": { 15 | "node": ">=18" 16 | }, 17 | "scripts": { 18 | "lint": "eslint .", 19 | "clean": "rm -rf ./dist/cjs/*", 20 | "build": "esbuild src/index.ts --bundle --platform=node --target=node18 --outdir=./dist/cjs --external:@bufbuild/protoplugin --external:@bufbuild/protobuf && echo >./dist/cjs/package.json '{\"type\":\"commonjs\"}'" 21 | }, 22 | "preferUnplugged": true, 23 | "dependencies": { 24 | "@bufbuild/protoplugin": "^1.5.0" 25 | }, 26 | "peerDependencies": { 27 | "@bufbuild/protobuf": "^1.5.0" 28 | }, 29 | "peerDependenciesMeta": { 30 | "@bufbuild/protobuf": { 31 | "optional": true 32 | } 33 | }, 34 | "devDependencies": { 35 | "@buf/bufbuild_knit.bufbuild_es": "1.3.1-20230504140941-3dc602456973.1", 36 | "@bufbuild/protobuf": "^1.5.0", 37 | "esbuild": "^0.19.8", 38 | "eslint-config-custom": "workspace:*", 39 | "tsconfig": "workspace:*" 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /packages/protoc-gen-knit-ts/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "tsconfig/base.json", 3 | "compilerOptions": { 4 | "resolveJsonModule": true 5 | } 6 | } 7 | -------------------------------------------------------------------------------- /packages/tsconfig/base.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "https://json.schemastore.org/tsconfig", 3 | "display": "Default", 4 | "compilerOptions": { 5 | "target": "ES2017", 6 | "lib": ["ES2017", "ES2020", "DOM", "ES2018.AsyncIterable"], 7 | "esModuleInterop": false, 8 | "verbatimModuleSyntax": true, 9 | "forceConsistentCasingInFileNames": true, 10 | "strict": true, 11 | "noImplicitAny": true, 12 | "strictNullChecks": true, 13 | "strictFunctionTypes": true, 14 | "strictBindCallApply": true, 15 | "strictPropertyInitialization": true, 16 | "noImplicitThis": true, 17 | "useUnknownInCatchVariables": true, 18 | "noUnusedLocals": true, 19 | "noImplicitReturns": true, 20 | "noFallthroughCasesInSwitch": true, 21 | "noImplicitOverride": true, 22 | "moduleResolution": "node", 23 | "skipLibCheck": false, 24 | "isolatedModules": true 25 | }, 26 | "exclude": ["node_modules"] 27 | } 28 | -------------------------------------------------------------------------------- /packages/tsconfig/library.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "https://json.schemastore.org/tsconfig", 3 | "display": "Library", 4 | "extends": "./base.json" 5 | } 6 | -------------------------------------------------------------------------------- /packages/tsconfig/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "tsconfig", 3 | "version": "0.0.0", 4 | "private": true, 5 | "files": [ 6 | "base.json", 7 | "library.json" 8 | ] 9 | } 10 | -------------------------------------------------------------------------------- /pnpm-workspace.yaml: -------------------------------------------------------------------------------- 1 | packages: 2 | - "packages/*" 3 | -------------------------------------------------------------------------------- /turbo.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "https://turbo.build/schema.json", 3 | 4 | "pipeline": { 5 | "buf:generate": { 6 | "dependsOn": ["^build"], 7 | "inputs": ["proto/**"], 8 | "outputs": ["spec/**", "src/gen/**"] 9 | }, 10 | "build": { 11 | "dependsOn": ["^build", "buf:generate", "clean"], 12 | "inputs": ["src/**"], 13 | "outputs": ["dist/**/*"] 14 | }, 15 | "attw": { 16 | "dependsOn": ["build"], 17 | "inputs": ["dist/", "package.json"], 18 | "outputs": [] 19 | }, 20 | "test": { 21 | "dependsOn": ["build"], 22 | "outputs": [] 23 | }, 24 | "lint": { 25 | "outputs": [] 26 | }, 27 | "clean": { 28 | "cache": false, 29 | "outputs": [] 30 | }, 31 | "test:watch": { 32 | "dependsOn": ["clean", "buf:generate"], 33 | "persistent": true 34 | } 35 | }, 36 | "globalDependencies": [ 37 | "packages/eslint-config-custom/index.js", 38 | "packages/tsconfig/*.json" 39 | ] 40 | } 41 | --------------------------------------------------------------------------------