Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat!: merge next-major into master #15

Merged
merged 1 commit into from
Apr 25, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,9 @@ insert_final_newline = true

[*.js]
indent_size = 2
indent_style = space
indent_style = space

[*.ts]
indent_size = 2
indent_style = space
quote_type = single
9 changes: 9 additions & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
node_modules
*.tgz
.vscode
.DS_Store
/docs
/coverage
/lib
/esm
/cjs
41 changes: 33 additions & 8 deletions .eslintrc
Original file line number Diff line number Diff line change
@@ -1,15 +1,20 @@
env:
node: true
es6: true
mocha: true
jest: true

plugins:
- "@typescript-eslint"
- sonarjs
- mocha
- security
- github

extends:
- eslint:recommended
- plugin:@typescript-eslint/eslint-recommended
- plugin:@typescript-eslint/recommended
- plugin:sonarjs/recommended
- plugin:mocha/recommended
- plugin:security/recommended

parserOptions:
ecmaVersion: 2018
Expand All @@ -21,6 +26,7 @@ rules:
no-mixed-requires: 0
no-process-exit: 0
no-warning-comments: 0
no-use-before-define: 0
curly: 0
no-multi-spaces: 0
no-alert: 0
Expand All @@ -29,6 +35,10 @@ rules:
func-style: 0
max-nested-callbacks: 0
camelcase: 0
no-dupe-class-members: 0
security/detect-object-injection: 0
sonarjs/no-small-switch: 0
sonarjs/no-nested-template-literals: 0

# Warnings
no-debugger: 1
Expand All @@ -46,7 +56,6 @@ rules:
no-empty-character-class: 2
no-self-compare: 2
valid-typeof: 2
no-unused-vars: [2, { "args": "none" }]
handle-callback-err: 2
no-shadow-restricted-names: 2
no-new-require: 2
Expand All @@ -58,7 +67,6 @@ rules:
radix: 2
wrap-iife: [2, outside]
no-shadow: 0
no-use-before-define: [2, nofunc]
no-path-concat: 2
valid-jsdoc: [0, {requireReturn: false, requireParamDescription: false, requireReturnDescription: false}]

Expand Down Expand Up @@ -89,7 +97,6 @@ rules:
arrow-spacing: [2, {before: true, after: true}]
no-class-assign: 2
no-const-assign: 2
no-dupe-class-members: 2
no-this-before-super: 2
no-var: 2
object-shorthand: [2, always]
Expand All @@ -98,8 +105,26 @@ rules:
prefer-spread: 2
prefer-template: 2

# TypeScript
"@typescript-eslint/no-empty-interface": "off"
"@typescript-eslint/no-use-before-define": ["off"]
"@typescript-eslint/no-empty-function": "off"
"@typescript-eslint/ban-ts-comment": "off"
"@typescript-eslint/no-explicit-any": "off"
"@typescript-eslint/explicit-module-boundary-types": "off"
"@typescript-eslint/no-this-alias": "off"
"@typescript-eslint/no-unnecessary-type-constraint": "off"
"@typescript-eslint/ban-types": "off"

overrides:
- files: "test/**"
- files:
- "test/**"
- "*.spec.ts"
- "*.test.ts"
rules:
prefer-arrow-callback: 0
sonarjs/no-duplicate-string: 0
sonarjs/no-duplicate-string: 0
security/detect-object-injection: 0
security/detect-non-literal-fs-filename: 0
"@typescript-eslint/no-non-null-assertion": 0
"@typescript-eslint/no-unused-vars": 0
10 changes: 9 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,9 @@
node_modules
node_modules
*.tgz
.vscode
.DS_Store
/docs
/coverage
/lib
/esm
/cjs
10 changes: 10 additions & 0 deletions .npmignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
.DS_Store
*.tgz
*.swp
.github
.all-contributorsrc
.editorconfig
assets/logo.png
vscode
coverage
node_modules
51 changes: 43 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,7 @@ For ProtoBuff 2 and 3 schemas.

There is no explicit distinction between ProtoBuff 2 and 3. You dont have to expect any errors if your `schemaFormat` is `application/vnd.google.protobuf;version=2` defined, but your schema is proto3.

Support for AsyncApi schema versions: 2

Compatible with: [@asyncapi/parser](https://www.npmjs.com/package/@asyncapi/parser) 1.x (tested with: 1.18.1)
Version >= `2.0.0` of package is only supported by `@asyncapi/parser` version >= `2.0.0`.

This package is browser-compatible.

Expand All @@ -16,13 +14,18 @@ This package is browser-compatible.

```
npm install @asyncapi/protobuf-schema-parser
// OR
yarn add @asyncapi/protobuf-schema-parser
```

## Usage

```js
const parser = require('asyncapi-parser')
const protoParser = require('@asyncapi/protobuf-schema-parser')
```ts
import { Parser } from '@asyncapi/parser';
import { ProtoSchemaParser } from '@asyncapi/protobuf-schema-parser'

const parser = new Parser();
parser.registerSchemaParser(ProtoSchemaParser());

const asyncapiWithProto = `
asyncapi: 2.0.0
Expand All @@ -48,9 +51,41 @@ channels:
}
`

parser.registerSchemaParser(protoParser)
const { document } = await parser.parse(asyncapiWithProto);
```

```js
const { Parser } = require('@asyncapi/parser');
const { ProtoSchemaParser } = require('@asyncapi/protobuf-schema-parser');

const parser = new Parser();
parser.registerSchemaParser(ProtoSchemaParser());

const asyncapiWithProto = `
asyncapi: 2.0.0
info:
title: Example with ProtoBuff
version: 0.1.0
channels:
example:
publish:
message:
schemaFormat: 'application/vnd.google.protobuf;version=3'
payload: |
message Point {
required int32 x = 1;
required int32 y = 2;
optional string label = 3;
}

message Line {
required Point start = 1;
required Point end = 2;
optional string label = 3;
}
`

await parser.parse(asyncapiWithProto)
const { document } = await parser.parse(asyncapiWithProto);
```

Place your protoBuff schema as string in `payload` to get it parsed.
Expand Down
Loading