Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@connectrpc/protoc-gen-connect-query

Package Overview
Dependencies
Maintainers
0
Versions
28
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@connectrpc/protoc-gen-connect-query - npm Package Compare versions

Comparing version 1.4.2 to 2.0.0-beta.1

17

dist/cjs/package.json
{
"name": "@connectrpc/protoc-gen-connect-query",
"version": "1.4.2",
"version": "2.0.0-beta.1",
"description": "Code generator for connect-query",

@@ -25,3 +25,3 @@ "license": "Apache-2.0",

"format": "prettier . --write --ignore-path ./.eslintignore && eslint . --fix && license-header",
"generate": "rm -rf snapshots/gen* && cd snapshots && buf generate buf.build/connectrpc/eliza:8b8b971d6fde4dc8ba5d96f9fda7d53c",
"generate": "cd snapshots && buf generate",
"test": "tsc --declaration --declarationDir .type-dump --emitDeclarationOnly"

@@ -31,13 +31,12 @@ },

"devDependencies": {
"@bufbuild/buf": "1.39.0",
"@bufbuild/protoc-gen-es": "^1.10.0",
"@connectrpc/connect": "^1.4.0",
"@bufbuild/buf": "1.43.0",
"@bufbuild/protoc-gen-es": "^2.2.0",
"@connectrpc/connect": "^2.0.0-beta.1",
"@connectrpc/connect-query": "workspace:*",
"@connectrpc/protoc-gen-connect-es": "^1.4.0",
"@tanstack/react-query": "^5.53.3",
"@tanstack/react-query": "^5.56.2",
"typescript": "^5.5.4"
},
"dependencies": {
"@bufbuild/protobuf": "^1.10.0",
"@bufbuild/protoplugin": "^1.10.0"
"@bufbuild/protobuf": "^2.2.0",
"@bufbuild/protoplugin": "^2.2.0"
},

@@ -44,0 +43,0 @@ "peerDependencies": {

@@ -17,5 +17,3 @@ "use strict";

exports.generateDts = void 0;
const protobuf_1 = require("@bufbuild/protobuf");
const ecmascript_1 = require("@bufbuild/protoplugin/ecmascript");
const { safeIdentifier } = protobuf_1.codegenInfo;
const protoplugin_1 = require("@bufbuild/protoplugin");
// prettier-ignore

@@ -26,22 +24,10 @@ /**

const generateServiceFile = (schema, protoFile) => (service) => {
const { MethodKind: rtMethodKind, MethodIdempotency: rtMethodIdempotency } = schema.runtime;
const f = schema.generateFile(`${protoFile.name}-${(0, ecmascript_1.localName)(service)}_connectquery.d.ts`);
const f = schema.generateFile(`${protoFile.name}-${service.name}_connectquery.d.ts`);
f.preamble(protoFile);
service.methods.forEach((method) => {
switch (method.methodKind) {
case protobuf_1.MethodKind.Unary:
case "unary":
{
f.print(f.jsDoc(method));
f.print(f.exportDecl("const", safeIdentifier((0, ecmascript_1.localName)(method))), ": {");
f.print(" readonly name: ", f.string(method.name), ",");
f.print(" readonly I: typeof ", method.input, ",");
f.print(" readonly O: typeof ", method.output, ",");
f.print(" readonly kind: ", rtMethodKind, ".", protobuf_1.MethodKind[method.methodKind], ",");
if (method.idempotency !== undefined) {
f.print(" readonly idempotency: ", rtMethodIdempotency, ".", protobuf_1.MethodIdempotency[method.idempotency], ",");
}
f.print(" readonly service: {");
f.print(" readonly typeName: ", f.string(service.typeName));
f.print(" }");
f.print("};");
f.print(f.export("const", (0, protoplugin_1.safeIdentifier)(method.localName)), ": typeof ", f.importSchema(service), '["method"]["', method.localName, '"];');
}

@@ -48,0 +34,0 @@ break;

@@ -17,5 +17,3 @@ "use strict";

exports.generateTs = void 0;
const protobuf_1 = require("@bufbuild/protobuf");
const ecmascript_1 = require("@bufbuild/protoplugin/ecmascript");
const { safeIdentifier } = protobuf_1.codegenInfo;
const protoplugin_1 = require("@bufbuild/protoplugin");
// prettier-ignore

@@ -28,23 +26,9 @@ /**

const generateServiceFile = (schema, protoFile, extension) => (service) => {
const isTs = extension === "ts";
const f = schema.generateFile(`${protoFile.name}-${(0, ecmascript_1.localName)(service)}_connectquery.${extension}`);
const f = schema.generateFile(`${protoFile.name}-${service.name}_connectquery.${extension}`);
f.preamble(protoFile);
const { MethodKind: rtMethodKind, MethodIdempotency: rtMethodIdempotency } = schema.runtime;
service.methods
.filter((method) => method.methodKind === protobuf_1.MethodKind.Unary)
.filter((method) => method.methodKind === "unary")
.forEach((method, index, filteredMethods) => {
f.print(f.jsDoc(method));
f.print(f.exportDecl("const", safeIdentifier((0, ecmascript_1.localName)(method))), " = {");
f.print(" localName: ", f.string((0, ecmascript_1.localName)(method)), ",");
f.print(" name: ", f.string(method.name), ",");
f.print(" kind: ", rtMethodKind, ".", protobuf_1.MethodKind[method.methodKind], ",");
f.print(" I: ", method.input, ",");
f.print(" O: ", method.output, ",");
if (method.idempotency !== undefined) {
f.print(" idempotency: ", rtMethodIdempotency, ".", protobuf_1.MethodIdempotency[method.idempotency], ",");
}
f.print(" service: {");
f.print(" typeName: ", f.string(service.typeName));
f.print(" }");
f.print("}", isTs ? " as const" : "", ";");
f.print(f.export("const", (0, protoplugin_1.safeIdentifier)(method.localName)), " = ", f.importSchema(service), ".method.", method.localName, ";");
const lastIndex = index === filteredMethods.length - 1;

@@ -51,0 +35,0 @@ if (!lastIndex) {

{
"name": "@connectrpc/protoc-gen-connect-query",
"version": "1.4.2",
"version": "2.0.0-beta.1",
"description": "Code generator for connect-query",

@@ -23,13 +23,12 @@ "license": "Apache-2.0",

"devDependencies": {
"@bufbuild/buf": "1.39.0",
"@bufbuild/protoc-gen-es": "^1.10.0",
"@connectrpc/connect": "^1.4.0",
"@connectrpc/protoc-gen-connect-es": "^1.4.0",
"@tanstack/react-query": "^5.53.3",
"@bufbuild/buf": "1.43.0",
"@bufbuild/protoc-gen-es": "^2.2.0",
"@connectrpc/connect": "^2.0.0-beta.1",
"@tanstack/react-query": "^5.56.2",
"typescript": "^5.5.4",
"@connectrpc/connect-query": "1.4.2"
"@connectrpc/connect-query": "2.0.0-beta.1"
},
"dependencies": {
"@bufbuild/protobuf": "^1.10.0",
"@bufbuild/protoplugin": "^1.10.0"
"@bufbuild/protobuf": "^2.2.0",
"@bufbuild/protoplugin": "^2.2.0"
},

@@ -48,5 +47,5 @@ "peerDependencies": {

"format": "prettier . --write --ignore-path ./.eslintignore && eslint . --fix && license-header",
"generate": "rm -rf snapshots/gen* && cd snapshots && buf generate buf.build/connectrpc/eliza:8b8b971d6fde4dc8ba5d96f9fda7d53c",
"generate": "cd snapshots && buf generate",
"test": "tsc --declaration --declarationDir .type-dump --emitDeclarationOnly"
}
}

@@ -14,6 +14,6 @@ # @connectrpc/protoc-gen-connect-query

- [`target`](#target)
- [`import_extension=.js`](#import_extensionjs)
- [`import_extension`](#import_extension)
- [`keep_empty_files=true`](#keep_empty_filestrue)
- [`js_import_style`](#js_import_style)
- [`ts_nocheck=false`](#ts_nocheckfalse)
- [`ts_nocheck=true`](#ts_nochecktrue)
- [Example Generated Code](#example-generated-code)

@@ -78,10 +78,10 @@

```yaml
version: v1
version: v2
plugins:
# This will invoke protoc-gen-es and write output to src/gen
- name: es
- local: protoc-gen-es
out: src/gen
opt: target=ts
# This will invoke protoc-gen-connect-query
- name: connect-query
- local: protoc-gen-connect-query
out: src/gen

@@ -128,3 +128,3 @@ opt: target=ts

...
"buf:generate": "npx @bufbuild/buf generate example.proto"
"buf:generate": "buf generate"
},

@@ -191,13 +191,10 @@ ```

### `import_extension=.js`
### `import_extension`
By default, [protoc-gen-connect-query](https://www.npmjs.com/package/@connectrpc/protoc-gen-connect-query) (and all other plugins based on [@bufbuild/protoplugin](https://www.npmjs.com/package/@bufbuild/protoplugin)) uses a `.js` file extensions in import paths, even in TypeScript files.
By default, [protoc-gen-connect-query](https://www.npmjs.com/package/@connectrpc/protoc-gen-connect-query) (and all other plugins based on [@bufbuild/protoplugin](https://www.npmjs.com/package/@bufbuild/protoplugin)) doesn't add file extensions to import paths. However, some environments require an import extension. For example, using ECMAScript modules in Node.js requires the `.js` extension, and Deno requires `.ts`. With this plugin option, you can add `.js`/`.ts` extensions in import paths with the given value. Possible values:
This is unintuitive, but necessary for [ECMAScript modules in Node.js](https://www.typescriptlang.org/docs/handbook/esm-node.html).
- `import_extension=none`: Doesn't add an extension. (Default)
- `import_extension=js`: Adds the `.js` extension.
- `import_extension=ts`. Adds the `.ts` extension.
Unfortunately, not all bundlers and tools have caught up yet, and Deno requires `.ts`. With this plugin option, you can replace `.js` extensions in import paths with the given value. For example, set
- `import_extension=none` to remove the `.js` extension
- `import_extension=.ts` to replace the `.js` extension with `.ts`
### `js_import_style`

@@ -221,15 +218,8 @@

### `ts_nocheck=false`
### `ts_nocheck=true`
By default, [protoc-gen-connect-query](https://www.npmjs.com/package/@connectrpc/protoc-gen-connect-query)
(and all other plugins based on [@bufbuild/protoplugin](https://www.npmjs.com/package/@bufbuild/protoplugin))
generate an annotation at the top of each file: `// @ts-nocheck`.
[protoc-gen-connect-query](https://www.npmjs.com/package/@connectrpc/protoc-gen-connect-query) generates valid TypeScript for current versions of the TypeScript compiler with standard settings. If you use compiler settings that yield an error for generated code, setting this option generates an annotation at the top of each file to skip type checks: `// @ts-nocheck`.
We generate the annotation to support a wide range of compiler configurations and
future changes to the language. But there can be situations where the annotation
shadows an underlying problem, for example an unresolvable import. To remove
the annotation and to enable type checks, set the plugin option `ts_nocheck=false`.
## Example Generated Code
See [`eliza.proto`](../../examples/react/basic/eliza.proto) for example inputs, and look [here](../../examples/react/basic/src/gen) to see the outputs those files generate.

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc