@asyncapi/cli 0.8.0 → 0.9.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (42) hide show
  1. package/README.md +9 -47
  2. package/assets/examples/anyof.yml +31 -0
  3. package/assets/examples/application-headers.yml +83 -0
  4. package/assets/examples/correlation-id.yml +144 -0
  5. package/assets/examples/default-example.yaml +23 -0
  6. package/assets/examples/examples.json +58 -0
  7. package/assets/examples/gitter-streaming.yml +164 -0
  8. package/assets/examples/mercure.yml +49 -0
  9. package/assets/examples/not.yml +24 -0
  10. package/assets/examples/oneof.yml +46 -0
  11. package/assets/examples/rpc-client.yml +69 -0
  12. package/assets/examples/rpc-server.yml +66 -0
  13. package/assets/examples/simple.yml +23 -0
  14. package/assets/examples/slack-rtm.yml +884 -0
  15. package/assets/examples/streetlights-kafka.yml +163 -0
  16. package/assets/examples/streetlights-mqtt.yml +209 -0
  17. package/assets/examples/websocket-gemini.yml +213 -0
  18. package/lib/base.js +2 -1
  19. package/lib/commands/config/context/add.js +2 -1
  20. package/lib/commands/config/context/current.js +2 -1
  21. package/lib/commands/config/context/list.js +2 -1
  22. package/lib/commands/config/context/remove.js +2 -1
  23. package/lib/commands/config/context/use.js +2 -1
  24. package/lib/commands/config/context.js +2 -1
  25. package/lib/commands/config.js +2 -1
  26. package/lib/commands/new.d.ts +17 -0
  27. package/lib/commands/new.js +126 -0
  28. package/lib/commands/start/studio.d.ts +12 -0
  29. package/lib/commands/start/studio.js +23 -0
  30. package/lib/commands/validate.js +3 -2
  31. package/lib/errors/specification-file.d.ts +1 -1
  32. package/lib/errors/specification-file.js +6 -1
  33. package/lib/models/Context.js +8 -7
  34. package/lib/models/SpecificationFile.js +16 -8
  35. package/lib/models/Studio.d.ts +2 -0
  36. package/lib/models/Studio.js +110 -0
  37. package/oclif.manifest.json +1 -1
  38. package/package.json +16 -12
  39. package/lib/help/command.d.ts +0 -5
  40. package/lib/help/command.js +0 -58
  41. package/lib/help/index.d.ts +0 -8
  42. package/lib/help/index.js +0 -49
package/README.md CHANGED
@@ -59,57 +59,19 @@ We have well-documented help commands so just run:
59
59
  asyncapi --help
60
60
  ```
61
61
 
62
+ It should print something like:
62
63
 
63
-
64
-
65
- ## API Reference
66
-
67
- ### `validate`
68
-
69
- **USAGE**
70
-
71
- ```
72
- asyncapi validate <spcPath | context-name> [options]
73
- ```
74
-
75
- If you already have your current context set, run the following command:
76
-
77
- ```
78
- asyncapi validate
79
- ```
80
-
81
- **OPTIONS**
82
-
83
- ```
84
- -h, --help Display help for command
85
- -w, --watch Enable watch mode (not implemented yet)
86
- ```
87
-
88
-
89
- ### `context`
90
-
91
- **Context** makes it easier for you to work with multiple AsyncAPI Files. You can add multiple different files to a context so that you don't have to pass the file as an input every time you use any command. You can also set a default context so that you don't have to pass in either file paths or context names as an input.
92
-
93
- **USAGE**
94
-
95
- ```
96
- asyncapi context [options] [command]
97
64
  ```
65
+ All in one CLI for all AsyncAPI tools
98
66
 
99
- **COMMANDS**
67
+ USAGE
68
+ $ asyncapi [COMMAND]
100
69
 
101
- |command|arguments|description|example|
102
- |-------|---------|-----------|-------|
103
- |`list`|`none` |lists all saved context|`asyncapi context list`|
104
- |`current`|`none`|set current context|`asyncapi context current`|
105
- |`use` | `<context-name>`| set any context from the list as current|`asyncapi context use test`|
106
- |`add`|`<context-name> <spec-file-path>`|add/update a context|`asyncapi context add root ./asyncapi.yml`|
107
- |`remove`|`<context-name>`|remove a context from the list|`asyncapi context remove root`|
108
-
109
- **OPTIONS**
110
-
111
- ```
112
- -h, --help display help for command
70
+ COMMANDS
71
+ config access configs
72
+ help display help for asyncapi
73
+ new creates a new asyncapi file
74
+ validate validate asyncapi file
113
75
  ```
114
76
 
115
77
 
@@ -0,0 +1,31 @@
1
+ asyncapi: '2.2.0'
2
+ info:
3
+ title: AnyOf example
4
+ version: '1.0.0'
5
+
6
+ channels:
7
+ test:
8
+ publish:
9
+ message:
10
+ $ref: '#/components/messages/testMessages'
11
+
12
+ components:
13
+ messages:
14
+ testMessages:
15
+ payload:
16
+ anyOf: # anyOf in payload schema
17
+ - $ref: "#/components/schemas/objectWithKey"
18
+ - $ref: "#/components/schemas/objectWithKey2"
19
+
20
+ schemas:
21
+ objectWithKey:
22
+ type: object
23
+ properties:
24
+ key:
25
+ type: string
26
+ additionalProperties: false
27
+ objectWithKey2:
28
+ type: object
29
+ properties:
30
+ key2:
31
+ type: string
@@ -0,0 +1,83 @@
1
+ asyncapi: '2.2.0'
2
+ info:
3
+ title: Application Headers example
4
+ version: '1.0.0'
5
+ description: A cut of the Streetlights API to test application header changes supporting #112
6
+ license:
7
+ name: Apache 2.0
8
+ url: https://www.apache.org/licenses/LICENSE-2.0
9
+
10
+ servers:
11
+ production:
12
+ url: test.mosquitto.org:{port}
13
+ protocol: mqtt
14
+ description: Test broker
15
+ variables:
16
+ port:
17
+ description: Secure connection (TLS) is available through port 8883.
18
+ default: '1883'
19
+ enum:
20
+ - '1883'
21
+ - '8883'
22
+
23
+ defaultContentType: application/json
24
+
25
+ channels:
26
+ smartylighting/streetlights/1/0/event/{streetlightId}/lighting/measured:
27
+ parameters:
28
+ streetlightId:
29
+ $ref: '#/components/parameters/streetlightId'
30
+ publish:
31
+ summary: Inform about environmental lighting conditions of a particular streetlight.
32
+ operationId: receiveLightMeasurement
33
+ message:
34
+ $ref: '#/components/messages/lightMeasured'
35
+
36
+ components:
37
+ messages:
38
+ lightMeasured:
39
+ name: lightMeasured
40
+ title: Light measured
41
+ summary: Inform about environmental lighting conditions of a particular streetlight.
42
+ correlationId:
43
+ location: "$message.header#/MQMD/CorrelId"
44
+ contentType: application/json
45
+ headers:
46
+ type: object
47
+ properties:
48
+ MQMD:
49
+ type: object
50
+ properties:
51
+ CorrelId:
52
+ type: string
53
+ minLength: 24
54
+ maxLength: 24
55
+ format: binary
56
+ applicationInstanceId:
57
+ $ref: "#/components/schemas/applicationInstanceId"
58
+ payload:
59
+ $ref: "#/components/schemas/lightMeasuredPayload"
60
+
61
+ schemas:
62
+ lightMeasuredPayload:
63
+ type: object
64
+ properties:
65
+ lumens:
66
+ type: integer
67
+ minimum: 0
68
+ description: Light intensity measured in lumens.
69
+ sentAt:
70
+ $ref: "#/components/schemas/sentAt"
71
+ sentAt:
72
+ type: string
73
+ format: date-time
74
+ description: Date and time when the message was sent.
75
+ applicationInstanceId:
76
+ description: Unique identifier for a given instance of the publishing application
77
+ type: string
78
+
79
+ parameters:
80
+ streetlightId:
81
+ description: The ID of the streetlight.
82
+ schema:
83
+ type: string
@@ -0,0 +1,144 @@
1
+ asyncapi: '2.2.0'
2
+ info:
3
+ title: Correlation ID Example
4
+ version: '1.0.0'
5
+ description: A cut of the Streetlights API to test Correlation ID
6
+ license:
7
+ name: Apache 2.0
8
+ url: https://www.apache.org/licenses/LICENSE-2.0
9
+
10
+ servers:
11
+ production:
12
+ url: test.mosquitto.org:{port}
13
+ protocol: mqtt
14
+ description: Test broker
15
+ variables:
16
+ port:
17
+ description: Secure connection (TLS) is available through port 8883.
18
+ default: '1883'
19
+ enum:
20
+ - '1883'
21
+ - '8883'
22
+ security:
23
+ - apiKey: []
24
+ - supportedOauthFlows:
25
+ - streetlights:on
26
+ - streetlights:off
27
+ - streetlights:dim
28
+ - openIdConnectWellKnown: []
29
+
30
+ defaultContentType: application/json
31
+
32
+ channels:
33
+ smartylighting/streetlights/1/0/event/{streetlightId}/lighting/measured:
34
+ parameters:
35
+ streetlightId:
36
+ $ref: '#/components/parameters/streetlightId'
37
+ publish:
38
+ summary: Inform about environmental lighting conditions of a particular streetlight.
39
+ operationId: receiveLightMeasurement
40
+ message:
41
+ $ref: '#/components/messages/lightMeasured'
42
+
43
+ smartylighting/streetlights/1/0/action/{streetlightId}/dim:
44
+ parameters:
45
+ streetlightId:
46
+ $ref: '#/components/parameters/streetlightId'
47
+ subscribe:
48
+ operationId: dimLight
49
+ message:
50
+ $ref: '#/components/messages/dimLight'
51
+
52
+ components:
53
+ messages:
54
+ lightMeasured:
55
+ name: lightMeasured
56
+ title: Light measured
57
+ summary: Inform about environmental lighting conditions of a particular streetlight.
58
+ correlationId:
59
+ location: "$message.header#/MQMD/CorrelId"
60
+ contentType: application/json
61
+ payload:
62
+ $ref: "#/components/schemas/lightMeasuredPayload"
63
+ dimLight:
64
+ name: dimLight
65
+ title: Dim light
66
+ summary: Command a particular streetlight to dim the lights.
67
+ correlationId:
68
+ $ref: "#/components/correlationIds/sentAtCorrelator"
69
+ payload:
70
+ $ref: "#/components/schemas/dimLightPayload"
71
+
72
+ schemas:
73
+ lightMeasuredPayload:
74
+ type: object
75
+ properties:
76
+ lumens:
77
+ type: integer
78
+ minimum: 0
79
+ description: Light intensity measured in lumens.
80
+ sentAt:
81
+ $ref: "#/components/schemas/sentAt"
82
+ dimLightPayload:
83
+ type: object
84
+ properties:
85
+ percentage:
86
+ type: integer
87
+ description: Percentage to which the light should be dimmed to.
88
+ minimum: 0
89
+ maximum: 100
90
+ sentAt:
91
+ $ref: "#/components/schemas/sentAt"
92
+ sentAt:
93
+ type: string
94
+ format: date-time
95
+ description: Date and time when the message was sent.
96
+
97
+ parameters:
98
+ streetlightId:
99
+ description: The ID of the streetlight.
100
+ schema:
101
+ type: string
102
+
103
+ correlationIds:
104
+ sentAtCorrelator:
105
+ description: Data from message payload used as correlation ID
106
+ location: $message.payload#/sentAt
107
+ securitySchemes:
108
+ apiKey:
109
+ type: apiKey
110
+ in: user
111
+ description: Provide your API key as the user and leave the password empty.
112
+ supportedOauthFlows:
113
+ type: oauth2
114
+ description: Flows to support OAuth 2.0
115
+ flows:
116
+ implicit:
117
+ authorizationUrl: 'https://authserver.example/auth'
118
+ scopes:
119
+ 'streetlights:on': Ability to switch lights on
120
+ 'streetlights:off': Ability to switch lights off
121
+ 'streetlights:dim': Ability to dim the lights
122
+ password:
123
+ tokenUrl: 'https://authserver.example/token'
124
+ scopes:
125
+ 'streetlights:on': Ability to switch lights on
126
+ 'streetlights:off': Ability to switch lights off
127
+ 'streetlights:dim': Ability to dim the lights
128
+ clientCredentials:
129
+ tokenUrl: 'https://authserver.example/token'
130
+ scopes:
131
+ 'streetlights:on': Ability to switch lights on
132
+ 'streetlights:off': Ability to switch lights off
133
+ 'streetlights:dim': Ability to dim the lights
134
+ authorizationCode:
135
+ authorizationUrl: 'https://authserver.example/auth'
136
+ tokenUrl: 'https://authserver.example/token'
137
+ refreshUrl: 'https://authserver.example/refresh'
138
+ scopes:
139
+ 'streetlights:on': Ability to switch lights on
140
+ 'streetlights:off': Ability to switch lights off
141
+ 'streetlights:dim': Ability to dim the lights
142
+ openIdConnectWellKnown:
143
+ type: openIdConnect
144
+ openIdConnectUrl: 'https://authserver.example/.well-known'
@@ -0,0 +1,23 @@
1
+ asyncapi: '2.2.0'
2
+ info:
3
+ title: Account Service
4
+ version: 1.0.0
5
+ description: This service is in charge of processing user signups
6
+ channels:
7
+ user/signedup:
8
+ subscribe:
9
+ message:
10
+ $ref: '#/components/messages/UserSignedUp'
11
+ components:
12
+ messages:
13
+ UserSignedUp:
14
+ payload:
15
+ type: object
16
+ properties:
17
+ displayName:
18
+ type: string
19
+ description: Name of the user
20
+ email:
21
+ type: string
22
+ format: email
23
+ description: Email of the user
@@ -0,0 +1,58 @@
1
+ [
2
+ {
3
+ "name": "Account Service",
4
+ "value": "simple.yml"
5
+ },
6
+ {
7
+ "name": "AnyOf example",
8
+ "value": "anyof.yml"
9
+ },
10
+ {
11
+ "name": "Application Headers example - (protocols: mqtt)",
12
+ "value": "application-headers.yml"
13
+ },
14
+ {
15
+ "name": "Correlation ID Example - (protocols: mqtt)",
16
+ "value": "correlation-id.yml"
17
+ },
18
+ {
19
+ "name": "Gemini Market Data Websocket API - (protocols: wss)",
20
+ "value": "websocket-gemini.yml"
21
+ },
22
+ {
23
+ "name": "Gitter Streaming API - (protocols: https)",
24
+ "value": "gitter-streaming.yml"
25
+ },
26
+ {
27
+ "name": "Mercure Hub Example - (protocols: mercure)",
28
+ "value": "mercure.yml"
29
+ },
30
+ {
31
+ "name": "Not example",
32
+ "value": "not.yml"
33
+ },
34
+ {
35
+ "name": "OneOf example",
36
+ "value": "oneof.yml"
37
+ },
38
+ {
39
+ "name": "RPC Client Example - (protocols: amqp)",
40
+ "value": "rpc-client.yml"
41
+ },
42
+ {
43
+ "name": "RPC Server Example - (protocols: amqp)",
44
+ "value": "rpc-server.yml"
45
+ },
46
+ {
47
+ "name": "Slack Real Time Messaging API - (protocols: https)",
48
+ "value": "slack-rtm.yml"
49
+ },
50
+ {
51
+ "name": "Streetlights Kafka API - (protocols: kafka-secure)",
52
+ "value": "streetlights-kafka.yml"
53
+ },
54
+ {
55
+ "name": "Streetlights MQTT API - (protocols: mqtt)",
56
+ "value": "streetlights-mqtt.yml"
57
+ }
58
+ ]
@@ -0,0 +1,164 @@
1
+ asyncapi: '2.2.0'
2
+ id: 'urn:com:gitter:streaming:api'
3
+ info:
4
+ title: Gitter Streaming API
5
+ version: '1.0.0'
6
+
7
+ servers:
8
+ production:
9
+ url: https://stream.gitter.im/v1
10
+ protocol: https
11
+ protocolVersion: '1.1'
12
+ security:
13
+ - httpBearerToken: []
14
+
15
+ channels:
16
+ /rooms/{roomId}/{resource}:
17
+ parameters:
18
+ roomId:
19
+ description: Id of the Gitter room.
20
+ schema:
21
+ type: string
22
+ examples:
23
+ - 53307860c3599d1de448e19d
24
+ resource:
25
+ description: The resource to consume.
26
+ schema:
27
+ type: string
28
+ enum:
29
+ - chatMessages
30
+ - events
31
+ subscribe:
32
+ bindings:
33
+ http:
34
+ type: response
35
+ message:
36
+ oneOf:
37
+ - $ref: '#/components/messages/chatMessage'
38
+ - $ref: '#/components/messages/heartbeat'
39
+
40
+ components:
41
+ securitySchemes:
42
+ httpBearerToken:
43
+ type: http
44
+ scheme: bearer
45
+ messages:
46
+ chatMessage:
47
+ schemaFormat: 'application/schema+yaml;version=draft-07'
48
+ summary: >-
49
+ A message represents an individual chat message sent to a room.
50
+ They are a sub-resource of a room.
51
+ payload:
52
+ type: object
53
+ properties:
54
+ id:
55
+ type: string
56
+ description: ID of the message.
57
+ text:
58
+ type: string
59
+ description: Original message in plain-text/markdown.
60
+ html:
61
+ type: string
62
+ description: HTML formatted message.
63
+ sent:
64
+ type: string
65
+ format: date-time
66
+ description: ISO formatted date of the message.
67
+ fromUser:
68
+ type: object
69
+ description: User that sent the message.
70
+ properties:
71
+ id:
72
+ type: string
73
+ description: Gitter User ID.
74
+ username:
75
+ type: string
76
+ description: Gitter/GitHub username.
77
+ displayName:
78
+ type: string
79
+ description: Gitter/GitHub user real name.
80
+ url:
81
+ type: string
82
+ description: Path to the user on Gitter.
83
+ avatarUrl:
84
+ type: string
85
+ format: uri
86
+ description: User avatar URI.
87
+ avatarUrlSmall:
88
+ type: string
89
+ format: uri
90
+ description: User avatar URI (small).
91
+ avatarUrlMedium:
92
+ type: string
93
+ format: uri
94
+ description: User avatar URI (medium).
95
+ v:
96
+ type: number
97
+ description: Version.
98
+ gv:
99
+ type: string
100
+ description: Stands for "Gravatar version" and is used for cache busting.
101
+ unread:
102
+ type: boolean
103
+ description: Boolean that indicates if the current user has read the message.
104
+ readBy:
105
+ type: number
106
+ description: Number of users that have read the message.
107
+ urls:
108
+ type: array
109
+ description: List of URLs present in the message.
110
+ items:
111
+ type: string
112
+ format: uri
113
+ mentions:
114
+ type: array
115
+ description: List of @Mentions in the message.
116
+ items:
117
+ type: object
118
+ properties:
119
+ screenName:
120
+ type: string
121
+ userId:
122
+ type: string
123
+ userIds:
124
+ type: array
125
+ items:
126
+ type: string
127
+ issues:
128
+ type: array
129
+ description: 'List of #Issues referenced in the message.'
130
+ items:
131
+ type: object
132
+ properties:
133
+ number:
134
+ type: string
135
+ meta:
136
+ type: array
137
+ description: Metadata. This is currently not used for anything.
138
+ items: {}
139
+ v:
140
+ type: number
141
+ description: Version.
142
+ gv:
143
+ type: string
144
+ description: Stands for "Gravatar version" and is used for cache busting.
145
+ bindings:
146
+ http:
147
+ $ref: '#/components/messageBindings/streamingHeaders'
148
+
149
+ heartbeat:
150
+ schemaFormat: 'application/schema+yaml;version=draft-07'
151
+ summary: Its purpose is to keep the connection alive.
152
+ payload:
153
+ type: string
154
+ enum: ["\r\n"]
155
+ bindings:
156
+ http:
157
+ $ref: '#/components/messageBindings/streamingHeaders'
158
+
159
+ messageBindings:
160
+ streamingHeaders:
161
+ http:
162
+ headers:
163
+ 'Transfer-Encoding': 'chunked'
164
+ Trailer: '\r\n'
@@ -0,0 +1,49 @@
1
+ asyncapi: '2.2.0'
2
+ info:
3
+ title: Mercure Hub Example
4
+ version: '1.0.0'
5
+ description: This example demonstrates how to define a Mercure hub.
6
+
7
+ # While not mandatory, it's a best practice to use formats with hypermedia capabilities such as JSON-LD, Atom or HTML with the Mercure protocol
8
+ defaultContentType: application/ld+json
9
+
10
+ servers:
11
+ production:
12
+ url: https://demo.mercure.rocks/.well-known/mercure
13
+ protocol: mercure
14
+
15
+ channels:
16
+ 'https://example.com/books/{id}':
17
+ description: Every time a resource of type `http://schema.org/Book` is created or modified, a JSON-LD representation of the new version of this resource must be pushed in this Mercure topic.
18
+ parameters:
19
+ id:
20
+ schema:
21
+ type: integer
22
+ subscribe:
23
+ message:
24
+ $ref: '#/components/messages/book'
25
+ publish:
26
+ message:
27
+ $ref: '#/components/messages/book'
28
+
29
+ components:
30
+ messages:
31
+ book:
32
+ summary: The content of a book resource.
33
+ externalDocs:
34
+ url: https://schema.org/Book
35
+ payload:
36
+ type: object
37
+ properties:
38
+ '@id':
39
+ type: string
40
+ format: iri-reference
41
+ '@type':
42
+ type: string
43
+ format: iri-reference
44
+ name:
45
+ type: string
46
+ isbn:
47
+ type: string
48
+ abstract:
49
+ type: string
@@ -0,0 +1,24 @@
1
+ asyncapi: '2.2.0'
2
+ info:
3
+ title: Not example
4
+ version: '1.0.0'
5
+
6
+ channels:
7
+ test:
8
+ publish:
9
+ message:
10
+ $ref: '#/components/messages/testMessages'
11
+
12
+ components:
13
+ messages:
14
+ testMessages:
15
+ payload:
16
+ $ref: "#/components/schemas/testSchema"
17
+
18
+ schemas:
19
+ testSchema:
20
+ type: object
21
+ properties:
22
+ key:
23
+ not:
24
+ type: integer
@@ -0,0 +1,46 @@
1
+ asyncapi: '2.2.0'
2
+ info:
3
+ title: OneOf example
4
+ version: '1.0.0'
5
+
6
+ channels:
7
+ test:
8
+ publish:
9
+ message:
10
+ $ref: '#/components/messages/testMessages'
11
+
12
+ test2:
13
+ subscribe:
14
+ message:
15
+ # Use oneOf here if different messages are published on test2 topic.
16
+ oneOf:
17
+ - payload:
18
+ $ref: "#/components/schemas/objectWithKey"
19
+ - payload:
20
+ $ref: "#/components/schemas/objectWithKey2"
21
+
22
+ components:
23
+ messages:
24
+ testMessages:
25
+ payload:
26
+ oneOf: # oneOf in payload schema
27
+ - $ref: "#/components/schemas/objectWithKey"
28
+ - $ref: "#/components/schemas/objectWithKey2"
29
+ testMessage1:
30
+ payload:
31
+ $ref: "#/components/schemas/objectWithKey"
32
+ testMessage2:
33
+ payload:
34
+ $ref: "#/components/schemas/objectWithKey2"
35
+
36
+ schemas:
37
+ objectWithKey:
38
+ type: object
39
+ properties:
40
+ key:
41
+ type: string
42
+ objectWithKey2:
43
+ type: object
44
+ properties:
45
+ key2:
46
+ type: string