@ioka-technologies/asyncapi-ts-client-template 0.0.7 → 0.0.10
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.
- package/README.md +468 -122
- package/examples/auth-retry/README.md +384 -0
- package/examples/auth-retry/asyncapi.yaml +464 -0
- package/examples/auth-retry/login-flow-example.ts +375 -0
- package/package.json +3 -2
- package/template/helpers/security.js +137 -0
- package/template/src/client.ts.js +24 -2
- package/template/src/models.ts.js +157 -17
- package/template/src/runtime/auth/headers.ts.js +95 -0
- package/template/src/runtime/auth/index.ts.js +15 -0
- package/template/src/runtime/auth/types.ts.js +74 -0
- package/template/src/runtime/retry/index.ts.js +18 -0
- package/template/src/runtime/retry/manager.ts.js +150 -0
- package/template/src/runtime/retry/presets.ts.js +81 -0
- package/template/src/runtime/retry/types.ts.js +60 -0
- package/template/src/runtime/transports/http.ts.js +112 -17
- package/template/src/runtime/transports/websocket.ts.js +28 -3
- package/template/src/runtime/types.ts.js +12 -3
|
@@ -0,0 +1,464 @@
|
|
|
1
|
+
# yaml-language-server: $schema=https://raw.githubusercontent.com/asyncapi/spec-json-schemas/refs/heads/master/schemas/all.schema-store.json
|
|
2
|
+
asyncapi: 3.0.0
|
|
3
|
+
info:
|
|
4
|
+
title: User Service API
|
|
5
|
+
version: 1.0.0
|
|
6
|
+
description: Example API demonstrating authentication and retry features with AsyncAPI 3.0.0
|
|
7
|
+
|
|
8
|
+
servers:
|
|
9
|
+
production:
|
|
10
|
+
host: api.example.com
|
|
11
|
+
protocol: https
|
|
12
|
+
description: Production server
|
|
13
|
+
security:
|
|
14
|
+
- $ref: '#/components/securitySchemes/jwtAuth'
|
|
15
|
+
websocket:
|
|
16
|
+
host: ws.example.com
|
|
17
|
+
protocol: wss
|
|
18
|
+
description: WebSocket server for real-time events
|
|
19
|
+
security:
|
|
20
|
+
- $ref: '#/components/securitySchemes/jwtAuth'
|
|
21
|
+
|
|
22
|
+
channels:
|
|
23
|
+
userSignup:
|
|
24
|
+
address: user/signup
|
|
25
|
+
description: Channel for user signup operations
|
|
26
|
+
messages:
|
|
27
|
+
UserSignupRequest:
|
|
28
|
+
$ref: '#/components/messages/UserSignupRequest'
|
|
29
|
+
UserSignupResponse:
|
|
30
|
+
$ref: '#/components/messages/UserSignupResponse'
|
|
31
|
+
|
|
32
|
+
userProfile:
|
|
33
|
+
address: user/profile/{userId}
|
|
34
|
+
description: Channel for user profile operations
|
|
35
|
+
parameters:
|
|
36
|
+
userId:
|
|
37
|
+
description: User ID
|
|
38
|
+
location: $message.payload#/userId
|
|
39
|
+
messages:
|
|
40
|
+
GetUserProfileRequest:
|
|
41
|
+
$ref: '#/components/messages/GetUserProfileRequest'
|
|
42
|
+
GetUserProfileResponse:
|
|
43
|
+
$ref: '#/components/messages/GetUserProfileResponse'
|
|
44
|
+
|
|
45
|
+
userNotifications:
|
|
46
|
+
address: user/notifications
|
|
47
|
+
description: Channel for user notifications
|
|
48
|
+
messages:
|
|
49
|
+
UserNotification:
|
|
50
|
+
$ref: '#/components/messages/UserNotification'
|
|
51
|
+
|
|
52
|
+
userUpdate:
|
|
53
|
+
address: user/update/{userId}
|
|
54
|
+
description: Channel for user profile updates
|
|
55
|
+
parameters:
|
|
56
|
+
userId:
|
|
57
|
+
description: User ID
|
|
58
|
+
location: $message.payload#/userId
|
|
59
|
+
messages:
|
|
60
|
+
UpdateUserRequest:
|
|
61
|
+
$ref: '#/components/messages/UpdateUserRequest'
|
|
62
|
+
UpdateUserResponse:
|
|
63
|
+
$ref: '#/components/messages/UpdateUserResponse'
|
|
64
|
+
|
|
65
|
+
userDelete:
|
|
66
|
+
address: user/delete/{userId}
|
|
67
|
+
description: Channel for user deletion
|
|
68
|
+
parameters:
|
|
69
|
+
userId:
|
|
70
|
+
description: User ID
|
|
71
|
+
location: $message.payload#/userId
|
|
72
|
+
messages:
|
|
73
|
+
DeleteUserRequest:
|
|
74
|
+
$ref: '#/components/messages/DeleteUserRequest'
|
|
75
|
+
DeleteUserResponse:
|
|
76
|
+
$ref: '#/components/messages/DeleteUserResponse'
|
|
77
|
+
|
|
78
|
+
operations:
|
|
79
|
+
userSignup:
|
|
80
|
+
action: send
|
|
81
|
+
channel:
|
|
82
|
+
$ref: '#/channels/userSignup'
|
|
83
|
+
title: User Signup
|
|
84
|
+
summary: Register a new user account
|
|
85
|
+
description: Creates a new user account with email and password
|
|
86
|
+
security:
|
|
87
|
+
- $ref: '#/components/securitySchemes/apiKeyAuth'
|
|
88
|
+
messages:
|
|
89
|
+
- $ref: '#/channels/userSignup/messages/UserSignupRequest'
|
|
90
|
+
reply:
|
|
91
|
+
channel:
|
|
92
|
+
$ref: '#/channels/userSignup'
|
|
93
|
+
messages:
|
|
94
|
+
- $ref: '#/channels/userSignup/messages/UserSignupResponse'
|
|
95
|
+
|
|
96
|
+
getUserProfile:
|
|
97
|
+
action: send
|
|
98
|
+
channel:
|
|
99
|
+
$ref: '#/channels/userProfile'
|
|
100
|
+
title: Get User Profile
|
|
101
|
+
summary: Retrieve user profile information
|
|
102
|
+
description: |
|
|
103
|
+
Fetches detailed user profile information including preferences if requested
|
|
104
|
+
|
|
105
|
+
- read:user: Read user profile information
|
|
106
|
+
security:
|
|
107
|
+
- $ref: '#/components/securitySchemes/jwtAuth'
|
|
108
|
+
messages:
|
|
109
|
+
- $ref: '#/channels/userProfile/messages/GetUserProfileRequest'
|
|
110
|
+
reply:
|
|
111
|
+
channel:
|
|
112
|
+
$ref: '#/channels/userProfile'
|
|
113
|
+
messages:
|
|
114
|
+
- $ref: '#/channels/userProfile/messages/GetUserProfileResponse'
|
|
115
|
+
|
|
116
|
+
updateUserProfile:
|
|
117
|
+
action: send
|
|
118
|
+
channel:
|
|
119
|
+
$ref: '#/channels/userUpdate'
|
|
120
|
+
title: Update User Profile
|
|
121
|
+
summary: Update user profile information
|
|
122
|
+
description: Updates user profile data such as name, email, or preferences
|
|
123
|
+
security:
|
|
124
|
+
- $ref: '#/components/securitySchemes/jwtAuth'
|
|
125
|
+
messages:
|
|
126
|
+
- $ref: '#/channels/userUpdate/messages/UpdateUserRequest'
|
|
127
|
+
reply:
|
|
128
|
+
channel:
|
|
129
|
+
$ref: '#/channels/userUpdate'
|
|
130
|
+
messages:
|
|
131
|
+
- $ref: '#/channels/userUpdate/messages/UpdateUserResponse'
|
|
132
|
+
|
|
133
|
+
deleteUser:
|
|
134
|
+
action: send
|
|
135
|
+
channel:
|
|
136
|
+
$ref: '#/channels/userDelete'
|
|
137
|
+
title: Delete User
|
|
138
|
+
summary: Delete user account
|
|
139
|
+
description: Permanently deletes a user account and all associated data
|
|
140
|
+
security:
|
|
141
|
+
- $ref: '#/components/securitySchemes/jwtAuth'
|
|
142
|
+
messages:
|
|
143
|
+
- $ref: '#/channels/userDelete/messages/DeleteUserRequest'
|
|
144
|
+
reply:
|
|
145
|
+
channel:
|
|
146
|
+
$ref: '#/channels/userDelete'
|
|
147
|
+
messages:
|
|
148
|
+
- $ref: '#/channels/userDelete/messages/DeleteUserResponse'
|
|
149
|
+
|
|
150
|
+
subscribeUserNotifications:
|
|
151
|
+
action: receive
|
|
152
|
+
channel:
|
|
153
|
+
$ref: '#/channels/userNotifications'
|
|
154
|
+
title: Subscribe to User Notifications
|
|
155
|
+
summary: Receive real-time user notifications
|
|
156
|
+
description: Subscribe to receive real-time notifications for the authenticated user
|
|
157
|
+
security:
|
|
158
|
+
- $ref: '#/components/securitySchemes/jwtAuth'
|
|
159
|
+
messages:
|
|
160
|
+
- $ref: '#/channels/userNotifications/messages/UserNotification'
|
|
161
|
+
|
|
162
|
+
components:
|
|
163
|
+
securitySchemes:
|
|
164
|
+
jwtAuth:
|
|
165
|
+
type: http
|
|
166
|
+
scheme: bearer
|
|
167
|
+
bearerFormat: JWT
|
|
168
|
+
description: JWT token for authenticated requests. Include in Authorization header as 'Bearer <token>'
|
|
169
|
+
|
|
170
|
+
apiKeyAuth:
|
|
171
|
+
type: apiKey
|
|
172
|
+
in: user
|
|
173
|
+
description: API key for service-to-service authentication
|
|
174
|
+
|
|
175
|
+
basicAuth:
|
|
176
|
+
type: http
|
|
177
|
+
scheme: basic
|
|
178
|
+
description: Basic authentication for legacy systems
|
|
179
|
+
|
|
180
|
+
messages:
|
|
181
|
+
UserSignupRequest:
|
|
182
|
+
name: UserSignupRequest
|
|
183
|
+
title: User Signup Request
|
|
184
|
+
summary: Request to create a new user account
|
|
185
|
+
contentType: application/json
|
|
186
|
+
payload:
|
|
187
|
+
$ref: '#/components/schemas/UserSignupPayload'
|
|
188
|
+
|
|
189
|
+
UserSignupResponse:
|
|
190
|
+
name: UserSignupResponse
|
|
191
|
+
title: User Signup Response
|
|
192
|
+
summary: Response containing created user information
|
|
193
|
+
contentType: application/json
|
|
194
|
+
payload:
|
|
195
|
+
$ref: '#/components/schemas/UserResponsePayload'
|
|
196
|
+
|
|
197
|
+
GetUserProfileRequest:
|
|
198
|
+
name: GetUserProfileRequest
|
|
199
|
+
title: Get User Profile Request
|
|
200
|
+
summary: Request to retrieve user profile
|
|
201
|
+
contentType: application/json
|
|
202
|
+
payload:
|
|
203
|
+
$ref: '#/components/schemas/GetUserProfilePayload'
|
|
204
|
+
|
|
205
|
+
GetUserProfileResponse:
|
|
206
|
+
name: GetUserProfileResponse
|
|
207
|
+
title: Get User Profile Response
|
|
208
|
+
summary: Response containing user profile data
|
|
209
|
+
contentType: application/json
|
|
210
|
+
payload:
|
|
211
|
+
$ref: '#/components/schemas/UserProfilePayload'
|
|
212
|
+
|
|
213
|
+
UpdateUserRequest:
|
|
214
|
+
name: UpdateUserRequest
|
|
215
|
+
title: Update User Request
|
|
216
|
+
summary: Request to update user profile
|
|
217
|
+
contentType: application/json
|
|
218
|
+
payload:
|
|
219
|
+
$ref: '#/components/schemas/UpdateUserPayload'
|
|
220
|
+
|
|
221
|
+
UpdateUserResponse:
|
|
222
|
+
name: UpdateUserResponse
|
|
223
|
+
title: Update User Response
|
|
224
|
+
summary: Response confirming user profile update
|
|
225
|
+
contentType: application/json
|
|
226
|
+
payload:
|
|
227
|
+
$ref: '#/components/schemas/UserResponsePayload'
|
|
228
|
+
|
|
229
|
+
DeleteUserRequest:
|
|
230
|
+
name: DeleteUserRequest
|
|
231
|
+
title: Delete User Request
|
|
232
|
+
summary: Request to delete user account
|
|
233
|
+
contentType: application/json
|
|
234
|
+
payload:
|
|
235
|
+
$ref: '#/components/schemas/DeleteUserPayload'
|
|
236
|
+
|
|
237
|
+
DeleteUserResponse:
|
|
238
|
+
name: DeleteUserResponse
|
|
239
|
+
title: Delete User Response
|
|
240
|
+
summary: Response confirming user deletion
|
|
241
|
+
contentType: application/json
|
|
242
|
+
payload:
|
|
243
|
+
$ref: '#/components/schemas/DeleteUserResponsePayload'
|
|
244
|
+
|
|
245
|
+
UserNotification:
|
|
246
|
+
name: UserNotification
|
|
247
|
+
title: User Notification
|
|
248
|
+
summary: Real-time user notification
|
|
249
|
+
contentType: application/json
|
|
250
|
+
payload:
|
|
251
|
+
$ref: '#/components/schemas/NotificationPayload'
|
|
252
|
+
|
|
253
|
+
schemas:
|
|
254
|
+
UserSignupPayload:
|
|
255
|
+
type: object
|
|
256
|
+
required:
|
|
257
|
+
- email
|
|
258
|
+
- password
|
|
259
|
+
properties:
|
|
260
|
+
email:
|
|
261
|
+
type: string
|
|
262
|
+
format: email
|
|
263
|
+
description: User email address
|
|
264
|
+
example: "user@example.com"
|
|
265
|
+
password:
|
|
266
|
+
type: string
|
|
267
|
+
minLength: 8
|
|
268
|
+
description: User password (minimum 8 characters)
|
|
269
|
+
example: "securePassword123"
|
|
270
|
+
firstName:
|
|
271
|
+
type: string
|
|
272
|
+
description: User first name
|
|
273
|
+
example: "John"
|
|
274
|
+
lastName:
|
|
275
|
+
type: string
|
|
276
|
+
description: User last name
|
|
277
|
+
example: "Doe"
|
|
278
|
+
|
|
279
|
+
UserResponsePayload:
|
|
280
|
+
type: object
|
|
281
|
+
required:
|
|
282
|
+
- id
|
|
283
|
+
- email
|
|
284
|
+
- createdAt
|
|
285
|
+
properties:
|
|
286
|
+
id:
|
|
287
|
+
type: string
|
|
288
|
+
description: Unique user identifier
|
|
289
|
+
example: "usr_1234567890"
|
|
290
|
+
email:
|
|
291
|
+
type: string
|
|
292
|
+
format: email
|
|
293
|
+
description: User email address
|
|
294
|
+
example: "user@example.com"
|
|
295
|
+
firstName:
|
|
296
|
+
type: string
|
|
297
|
+
description: User first name
|
|
298
|
+
example: "John"
|
|
299
|
+
lastName:
|
|
300
|
+
type: string
|
|
301
|
+
description: User last name
|
|
302
|
+
example: "Doe"
|
|
303
|
+
createdAt:
|
|
304
|
+
type: string
|
|
305
|
+
format: date-time
|
|
306
|
+
description: Account creation timestamp
|
|
307
|
+
example: "2023-01-15T10:30:00Z"
|
|
308
|
+
updatedAt:
|
|
309
|
+
type: string
|
|
310
|
+
format: date-time
|
|
311
|
+
description: Last update timestamp
|
|
312
|
+
example: "2023-01-15T10:30:00Z"
|
|
313
|
+
|
|
314
|
+
GetUserProfilePayload:
|
|
315
|
+
type: object
|
|
316
|
+
properties:
|
|
317
|
+
includePreferences:
|
|
318
|
+
type: boolean
|
|
319
|
+
default: false
|
|
320
|
+
description: Whether to include user preferences in response
|
|
321
|
+
example: true
|
|
322
|
+
|
|
323
|
+
UserProfilePayload:
|
|
324
|
+
type: object
|
|
325
|
+
required:
|
|
326
|
+
- id
|
|
327
|
+
- email
|
|
328
|
+
properties:
|
|
329
|
+
id:
|
|
330
|
+
type: string
|
|
331
|
+
description: Unique user identifier
|
|
332
|
+
example: "usr_1234567890"
|
|
333
|
+
email:
|
|
334
|
+
type: string
|
|
335
|
+
format: email
|
|
336
|
+
description: User email address
|
|
337
|
+
example: "user@example.com"
|
|
338
|
+
firstName:
|
|
339
|
+
type: string
|
|
340
|
+
description: User first name
|
|
341
|
+
example: "John"
|
|
342
|
+
lastName:
|
|
343
|
+
type: string
|
|
344
|
+
description: User last name
|
|
345
|
+
example: "Doe"
|
|
346
|
+
preferences:
|
|
347
|
+
type: object
|
|
348
|
+
description: User preferences (included if requested)
|
|
349
|
+
properties:
|
|
350
|
+
theme:
|
|
351
|
+
type: string
|
|
352
|
+
enum: [light, dark]
|
|
353
|
+
example: "dark"
|
|
354
|
+
notifications:
|
|
355
|
+
type: boolean
|
|
356
|
+
example: true
|
|
357
|
+
language:
|
|
358
|
+
type: string
|
|
359
|
+
example: "en"
|
|
360
|
+
lastLoginAt:
|
|
361
|
+
type: string
|
|
362
|
+
format: date-time
|
|
363
|
+
description: Last login timestamp
|
|
364
|
+
example: "2023-01-15T09:15:00Z"
|
|
365
|
+
|
|
366
|
+
UpdateUserPayload:
|
|
367
|
+
type: object
|
|
368
|
+
properties:
|
|
369
|
+
email:
|
|
370
|
+
type: string
|
|
371
|
+
format: email
|
|
372
|
+
description: Updated email address
|
|
373
|
+
example: "newemail@example.com"
|
|
374
|
+
firstName:
|
|
375
|
+
type: string
|
|
376
|
+
description: Updated first name
|
|
377
|
+
example: "Jane"
|
|
378
|
+
lastName:
|
|
379
|
+
type: string
|
|
380
|
+
description: Updated last name
|
|
381
|
+
example: "Smith"
|
|
382
|
+
preferences:
|
|
383
|
+
type: object
|
|
384
|
+
description: Updated user preferences
|
|
385
|
+
properties:
|
|
386
|
+
theme:
|
|
387
|
+
type: string
|
|
388
|
+
enum: [light, dark]
|
|
389
|
+
example: "light"
|
|
390
|
+
notifications:
|
|
391
|
+
type: boolean
|
|
392
|
+
example: false
|
|
393
|
+
language:
|
|
394
|
+
type: string
|
|
395
|
+
example: "es"
|
|
396
|
+
|
|
397
|
+
DeleteUserPayload:
|
|
398
|
+
type: object
|
|
399
|
+
properties:
|
|
400
|
+
confirmation:
|
|
401
|
+
type: string
|
|
402
|
+
description: Confirmation string (must be "DELETE")
|
|
403
|
+
example: "DELETE"
|
|
404
|
+
reason:
|
|
405
|
+
type: string
|
|
406
|
+
description: Optional reason for deletion
|
|
407
|
+
example: "Account no longer needed"
|
|
408
|
+
|
|
409
|
+
DeleteUserResponsePayload:
|
|
410
|
+
type: object
|
|
411
|
+
required:
|
|
412
|
+
- success
|
|
413
|
+
- deletedAt
|
|
414
|
+
properties:
|
|
415
|
+
success:
|
|
416
|
+
type: boolean
|
|
417
|
+
description: Whether deletion was successful
|
|
418
|
+
example: true
|
|
419
|
+
deletedAt:
|
|
420
|
+
type: string
|
|
421
|
+
format: date-time
|
|
422
|
+
description: Deletion timestamp
|
|
423
|
+
example: "2023-01-15T11:45:00Z"
|
|
424
|
+
message:
|
|
425
|
+
type: string
|
|
426
|
+
description: Confirmation message
|
|
427
|
+
example: "User account successfully deleted"
|
|
428
|
+
|
|
429
|
+
NotificationPayload:
|
|
430
|
+
type: object
|
|
431
|
+
required:
|
|
432
|
+
- id
|
|
433
|
+
- type
|
|
434
|
+
- message
|
|
435
|
+
- timestamp
|
|
436
|
+
properties:
|
|
437
|
+
id:
|
|
438
|
+
type: string
|
|
439
|
+
description: Notification ID
|
|
440
|
+
example: "notif_1234567890"
|
|
441
|
+
type:
|
|
442
|
+
type: string
|
|
443
|
+
enum: [info, warning, error, success]
|
|
444
|
+
description: Notification type
|
|
445
|
+
example: "info"
|
|
446
|
+
message:
|
|
447
|
+
type: string
|
|
448
|
+
description: Notification message
|
|
449
|
+
example: "Your profile has been updated successfully"
|
|
450
|
+
timestamp:
|
|
451
|
+
type: string
|
|
452
|
+
format: date-time
|
|
453
|
+
description: Notification timestamp
|
|
454
|
+
example: "2023-01-15T10:35:00Z"
|
|
455
|
+
data:
|
|
456
|
+
type: object
|
|
457
|
+
description: Additional notification data
|
|
458
|
+
properties:
|
|
459
|
+
userId:
|
|
460
|
+
type: string
|
|
461
|
+
example: "usr_1234567890"
|
|
462
|
+
action:
|
|
463
|
+
type: string
|
|
464
|
+
example: "profile_update"
|