@terreno/api 0.0.1

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 (119) hide show
  1. package/LICENSE +202 -0
  2. package/README.md +170 -0
  3. package/biome.jsonc +22 -0
  4. package/bunfig.toml +4 -0
  5. package/dist/api.d.ts +227 -0
  6. package/dist/api.js +1024 -0
  7. package/dist/api.test.d.ts +1 -0
  8. package/dist/api.test.js +2143 -0
  9. package/dist/auth.d.ts +50 -0
  10. package/dist/auth.js +512 -0
  11. package/dist/auth.test.d.ts +1 -0
  12. package/dist/auth.test.js +778 -0
  13. package/dist/errors.d.ts +75 -0
  14. package/dist/errors.js +216 -0
  15. package/dist/example.d.ts +1 -0
  16. package/dist/example.js +118 -0
  17. package/dist/expressServer.d.ts +35 -0
  18. package/dist/expressServer.js +436 -0
  19. package/dist/index.d.ts +14 -0
  20. package/dist/index.js +30 -0
  21. package/dist/logger.d.ts +23 -0
  22. package/dist/logger.js +249 -0
  23. package/dist/middleware.d.ts +10 -0
  24. package/dist/middleware.js +52 -0
  25. package/dist/notifiers/googleChatNotifier.d.ts +5 -0
  26. package/dist/notifiers/googleChatNotifier.js +130 -0
  27. package/dist/notifiers/googleChatNotifier.test.d.ts +1 -0
  28. package/dist/notifiers/googleChatNotifier.test.js +260 -0
  29. package/dist/notifiers/index.d.ts +3 -0
  30. package/dist/notifiers/index.js +19 -0
  31. package/dist/notifiers/slackNotifier.d.ts +5 -0
  32. package/dist/notifiers/slackNotifier.js +130 -0
  33. package/dist/notifiers/slackNotifier.test.d.ts +1 -0
  34. package/dist/notifiers/slackNotifier.test.js +259 -0
  35. package/dist/notifiers/zoomNotifier.d.ts +34 -0
  36. package/dist/notifiers/zoomNotifier.js +181 -0
  37. package/dist/notifiers/zoomNotifier.test.d.ts +1 -0
  38. package/dist/notifiers/zoomNotifier.test.js +370 -0
  39. package/dist/openApi.d.ts +60 -0
  40. package/dist/openApi.js +441 -0
  41. package/dist/openApi.test.d.ts +1 -0
  42. package/dist/openApi.test.js +445 -0
  43. package/dist/openApiBuilder.d.ts +419 -0
  44. package/dist/openApiBuilder.js +424 -0
  45. package/dist/openApiBuilder.test.d.ts +1 -0
  46. package/dist/openApiBuilder.test.js +509 -0
  47. package/dist/openApiEtag.d.ts +7 -0
  48. package/dist/openApiEtag.js +38 -0
  49. package/dist/permissions.d.ts +26 -0
  50. package/dist/permissions.js +331 -0
  51. package/dist/permissions.test.d.ts +1 -0
  52. package/dist/permissions.test.js +413 -0
  53. package/dist/plugins.d.ts +67 -0
  54. package/dist/plugins.js +315 -0
  55. package/dist/plugins.test.d.ts +1 -0
  56. package/dist/plugins.test.js +639 -0
  57. package/dist/populate.d.ts +14 -0
  58. package/dist/populate.js +315 -0
  59. package/dist/populate.test.d.ts +1 -0
  60. package/dist/populate.test.js +133 -0
  61. package/dist/response.d.ts +0 -0
  62. package/dist/response.js +1 -0
  63. package/dist/tests/bunSetup.d.ts +1 -0
  64. package/dist/tests/bunSetup.js +297 -0
  65. package/dist/tests/index.d.ts +1 -0
  66. package/dist/tests/index.js +17 -0
  67. package/dist/tests.d.ts +99 -0
  68. package/dist/tests.js +273 -0
  69. package/dist/transformers.d.ts +25 -0
  70. package/dist/transformers.js +217 -0
  71. package/dist/transformers.test.d.ts +1 -0
  72. package/dist/transformers.test.js +370 -0
  73. package/dist/utils.d.ts +11 -0
  74. package/dist/utils.js +143 -0
  75. package/dist/utils.test.d.ts +1 -0
  76. package/dist/utils.test.js +14 -0
  77. package/index.ts +1 -0
  78. package/package.json +88 -0
  79. package/src/__snapshots__/openApi.test.ts.snap +4814 -0
  80. package/src/__snapshots__/openApiBuilder.test.ts.snap +1485 -0
  81. package/src/api.test.ts +1661 -0
  82. package/src/api.ts +1036 -0
  83. package/src/auth.test.ts +550 -0
  84. package/src/auth.ts +408 -0
  85. package/src/errors.ts +225 -0
  86. package/src/example.ts +99 -0
  87. package/src/express.d.ts +5 -0
  88. package/src/expressServer.ts +387 -0
  89. package/src/index.ts +14 -0
  90. package/src/logger.ts +190 -0
  91. package/src/middleware.ts +18 -0
  92. package/src/notifiers/googleChatNotifier.test.ts +114 -0
  93. package/src/notifiers/googleChatNotifier.ts +47 -0
  94. package/src/notifiers/index.ts +3 -0
  95. package/src/notifiers/slackNotifier.test.ts +113 -0
  96. package/src/notifiers/slackNotifier.ts +55 -0
  97. package/src/notifiers/zoomNotifier.test.ts +207 -0
  98. package/src/notifiers/zoomNotifier.ts +111 -0
  99. package/src/openApi.test.ts +331 -0
  100. package/src/openApi.ts +494 -0
  101. package/src/openApiBuilder.test.ts +442 -0
  102. package/src/openApiBuilder.ts +636 -0
  103. package/src/openApiEtag.ts +40 -0
  104. package/src/permissions.test.ts +219 -0
  105. package/src/permissions.ts +228 -0
  106. package/src/plugins.test.ts +390 -0
  107. package/src/plugins.ts +289 -0
  108. package/src/populate.test.ts +65 -0
  109. package/src/populate.ts +258 -0
  110. package/src/response.ts +0 -0
  111. package/src/tests/bunSetup.ts +234 -0
  112. package/src/tests/index.ts +1 -0
  113. package/src/tests.ts +218 -0
  114. package/src/transformers.test.ts +202 -0
  115. package/src/transformers.ts +170 -0
  116. package/src/utils.test.ts +14 -0
  117. package/src/utils.ts +47 -0
  118. package/tsconfig.json +60 -0
  119. package/types.d.ts +17 -0
@@ -0,0 +1,1485 @@
1
+ // Bun Snapshot v1, https://bun.sh/docs/test/snapshots
2
+
3
+ exports[`OpenApiMiddlewareBuilder snapshot tests matches OpenAPI spec snapshot 1`] = `
4
+ {
5
+ "components": {
6
+ "schemas": {
7
+ "APIError": {
8
+ "properties": {
9
+ "code": {
10
+ "description": "An application-specific error code, expressed as a string value.",
11
+ "type": "string",
12
+ },
13
+ "detail": {
14
+ "description": "A human-readable explanation specific to this occurrence of the problem. Like title, this field’s value can be localized.",
15
+ "type": "string",
16
+ },
17
+ "id": {
18
+ "description": "A unique identifier for this particular occurrence of the problem.",
19
+ "type": "string",
20
+ },
21
+ "links": {
22
+ "properties": {
23
+ "about": {
24
+ "description": "A link that leads to further details about this particular occurrence of the problem. When derefenced, this URI SHOULD return a human-readable description of the error.",
25
+ "type": "string",
26
+ },
27
+ "type": {
28
+ "description": "A link that identifies the type of error that this particular error is an instance of. This URI SHOULD be dereferencable to a human-readable explanation of the general error.",
29
+ "type": "string",
30
+ },
31
+ },
32
+ "type": "object",
33
+ },
34
+ "meta": {
35
+ "description": "A meta object containing non-standard meta-information about the error.",
36
+ "type": "object",
37
+ },
38
+ "source": {
39
+ "properties": {
40
+ "header": {
41
+ "description": "A string indicating the name of a single request header which caused the error.",
42
+ "type": "string",
43
+ },
44
+ "parameter": {
45
+ "description": "A string indicating which URI query parameter caused the error.",
46
+ "type": "string",
47
+ },
48
+ "pointer": {
49
+ "description": "A JSON Pointer [RFC6901] to the associated entity in the request document [e.g. "/data" for a primary data object, or "/data/attributes/title" for a specific attribute].",
50
+ "type": "string",
51
+ },
52
+ },
53
+ "type": "object",
54
+ },
55
+ "status": {
56
+ "description": "The HTTP status code applicable to this problem, expressed as a string value.",
57
+ "type": "number",
58
+ },
59
+ "title": {
60
+ "description": "The error message",
61
+ "type": "string",
62
+ },
63
+ },
64
+ "type": "object",
65
+ },
66
+ },
67
+ },
68
+ "info": {
69
+ "description": "Generated docs from an Express api",
70
+ "title": "Express Application",
71
+ "version": "1.0.0",
72
+ },
73
+ "openapi": "3.0.0",
74
+ "paths": {
75
+ "/food/": {
76
+ "get": {
77
+ "parameters": [
78
+ {
79
+ "in": "query",
80
+ "name": "_id",
81
+ "schema": {
82
+ "properties": {
83
+ "$in": {
84
+ "items": {
85
+ "type": "string",
86
+ },
87
+ "type": "array",
88
+ },
89
+ },
90
+ "type": "object",
91
+ },
92
+ },
93
+ {
94
+ "in": "query",
95
+ "name": "page",
96
+ "schema": {
97
+ "type": "number",
98
+ },
99
+ },
100
+ {
101
+ "in": "query",
102
+ "name": "sort",
103
+ "schema": {
104
+ "type": "string",
105
+ },
106
+ },
107
+ {
108
+ "in": "query",
109
+ "name": "limit",
110
+ "schema": {
111
+ "type": "number",
112
+ },
113
+ },
114
+ ],
115
+ "responses": {
116
+ "200": {
117
+ "content": {
118
+ "application/json": {
119
+ "schema": {
120
+ "properties": {
121
+ "data": {
122
+ "items": {
123
+ "properties": {
124
+ "_id": {
125
+ "type": "string",
126
+ },
127
+ "calories": {
128
+ "type": "number",
129
+ },
130
+ "categories": {
131
+ "items": {
132
+ "properties": {
133
+ "_id": {
134
+ "type": "string",
135
+ },
136
+ "created": {
137
+ "format": "date-time",
138
+ "type": "string",
139
+ },
140
+ "name": {
141
+ "type": "string",
142
+ },
143
+ "show": {
144
+ "type": "boolean",
145
+ },
146
+ "updated": {
147
+ "format": "date-time",
148
+ "type": "string",
149
+ },
150
+ },
151
+ "required": [],
152
+ "type": "object",
153
+ },
154
+ "type": "array",
155
+ },
156
+ "created": {
157
+ "format": "date-time",
158
+ "type": "string",
159
+ },
160
+ "description": {
161
+ "type": "any",
162
+ },
163
+ "eatenBy": {
164
+ "items": {
165
+ "required": true,
166
+ "type": "schemaobjectid",
167
+ },
168
+ "type": "array",
169
+ },
170
+ "expiration": {
171
+ "type": "dateonly",
172
+ },
173
+ "hidden": {
174
+ "type": "boolean",
175
+ },
176
+ "lastEatenWith": {
177
+ "additionalProperties": {
178
+ "format": "date-time",
179
+ "type": "string",
180
+ },
181
+ "type": "object",
182
+ },
183
+ "likesIds": {
184
+ "items": {
185
+ "properties": {
186
+ "_id": {
187
+ "type": "string",
188
+ },
189
+ "likes": {
190
+ "type": "boolean",
191
+ },
192
+ "userId": {
193
+ "type": "string",
194
+ },
195
+ },
196
+ "required": [],
197
+ "type": "object",
198
+ },
199
+ "type": "array",
200
+ },
201
+ "name": {
202
+ "type": "string",
203
+ },
204
+ "ownerId": {
205
+ "type": "string",
206
+ },
207
+ "source": {
208
+ "properties": {
209
+ "dateAdded": {
210
+ "type": "string",
211
+ },
212
+ "href": {
213
+ "type": "string",
214
+ },
215
+ "name": {
216
+ "type": "string",
217
+ },
218
+ },
219
+ "type": "object",
220
+ },
221
+ "tags": {
222
+ "items": {
223
+ "type": "string",
224
+ },
225
+ "type": "array",
226
+ },
227
+ },
228
+ "required": [
229
+ "likesIds",
230
+ "_id",
231
+ "created",
232
+ "updated",
233
+ ],
234
+ "type": "object",
235
+ },
236
+ "type": "array",
237
+ },
238
+ "limit": {
239
+ "type": "number",
240
+ },
241
+ "more": {
242
+ "type": "boolean",
243
+ },
244
+ "page": {
245
+ "type": "number",
246
+ },
247
+ "total": {
248
+ "type": "number",
249
+ },
250
+ },
251
+ "type": "object",
252
+ },
253
+ },
254
+ },
255
+ "description": "Successful list",
256
+ },
257
+ "400": {
258
+ "content": {
259
+ "application/json": {
260
+ "schema": {
261
+ "$ref": "#/components/schemas/APIError",
262
+ },
263
+ },
264
+ },
265
+ "description": "Bad request",
266
+ },
267
+ "401": {
268
+ "description": "The user must be authenticated",
269
+ },
270
+ "403": {
271
+ "content": {
272
+ "application/json": {
273
+ "schema": {
274
+ "$ref": "#/components/schemas/APIError",
275
+ },
276
+ },
277
+ },
278
+ "description": "The user is not allowed to perform this action on this document",
279
+ },
280
+ "404": {
281
+ "content": {
282
+ "application/json": {
283
+ "schema": {
284
+ "$ref": "#/components/schemas/APIError",
285
+ },
286
+ },
287
+ },
288
+ "description": "Document not found",
289
+ },
290
+ "405": {
291
+ "content": {
292
+ "application/json": {
293
+ "schema": {
294
+ "$ref": "#/components/schemas/APIError",
295
+ },
296
+ },
297
+ },
298
+ "description": "The user is not allowed to perform this action on any document",
299
+ },
300
+ },
301
+ "tags": [
302
+ "foods",
303
+ ],
304
+ },
305
+ "post": {
306
+ "requestBody": {
307
+ "content": {
308
+ "application/json": {
309
+ "schema": {
310
+ "properties": {
311
+ "_id": {
312
+ "type": "string",
313
+ },
314
+ "calories": {
315
+ "type": "number",
316
+ },
317
+ "categories": {
318
+ "items": {
319
+ "properties": {
320
+ "_id": {
321
+ "type": "string",
322
+ },
323
+ "created": {
324
+ "format": "date-time",
325
+ "type": "string",
326
+ },
327
+ "name": {
328
+ "type": "string",
329
+ },
330
+ "show": {
331
+ "type": "boolean",
332
+ },
333
+ "updated": {
334
+ "format": "date-time",
335
+ "type": "string",
336
+ },
337
+ },
338
+ "required": [],
339
+ "type": "object",
340
+ },
341
+ "type": "array",
342
+ },
343
+ "created": {
344
+ "format": "date-time",
345
+ "type": "string",
346
+ },
347
+ "description": {
348
+ "type": "any",
349
+ },
350
+ "eatenBy": {
351
+ "items": {
352
+ "required": true,
353
+ "type": "schemaobjectid",
354
+ },
355
+ "type": "array",
356
+ },
357
+ "expiration": {
358
+ "type": "dateonly",
359
+ },
360
+ "hidden": {
361
+ "type": "boolean",
362
+ },
363
+ "lastEatenWith": {
364
+ "additionalProperties": {
365
+ "format": "date-time",
366
+ "type": "string",
367
+ },
368
+ "type": "object",
369
+ },
370
+ "likesIds": {
371
+ "items": {
372
+ "properties": {
373
+ "_id": {
374
+ "type": "string",
375
+ },
376
+ "likes": {
377
+ "type": "boolean",
378
+ },
379
+ "userId": {
380
+ "type": "string",
381
+ },
382
+ },
383
+ "required": [],
384
+ "type": "object",
385
+ },
386
+ "type": "array",
387
+ },
388
+ "name": {
389
+ "type": "string",
390
+ },
391
+ "ownerId": {
392
+ "type": "string",
393
+ },
394
+ "source": {
395
+ "properties": {
396
+ "dateAdded": {
397
+ "type": "string",
398
+ },
399
+ "href": {
400
+ "type": "string",
401
+ },
402
+ "name": {
403
+ "type": "string",
404
+ },
405
+ },
406
+ "type": "object",
407
+ },
408
+ "tags": {
409
+ "items": {
410
+ "type": "string",
411
+ },
412
+ "type": "array",
413
+ },
414
+ },
415
+ "type": "object",
416
+ },
417
+ },
418
+ },
419
+ "required": true,
420
+ },
421
+ "responses": {
422
+ "201": {
423
+ "content": {
424
+ "application/json": {
425
+ "schema": {
426
+ "properties": {
427
+ "_id": {
428
+ "type": "string",
429
+ },
430
+ "calories": {
431
+ "type": "number",
432
+ },
433
+ "categories": {
434
+ "items": {
435
+ "properties": {
436
+ "_id": {
437
+ "type": "string",
438
+ },
439
+ "created": {
440
+ "format": "date-time",
441
+ "type": "string",
442
+ },
443
+ "name": {
444
+ "type": "string",
445
+ },
446
+ "show": {
447
+ "type": "boolean",
448
+ },
449
+ "updated": {
450
+ "format": "date-time",
451
+ "type": "string",
452
+ },
453
+ },
454
+ "required": [],
455
+ "type": "object",
456
+ },
457
+ "type": "array",
458
+ },
459
+ "created": {
460
+ "format": "date-time",
461
+ "type": "string",
462
+ },
463
+ "description": {
464
+ "type": "any",
465
+ },
466
+ "eatenBy": {
467
+ "items": {
468
+ "required": true,
469
+ "type": "schemaobjectid",
470
+ },
471
+ "type": "array",
472
+ },
473
+ "expiration": {
474
+ "type": "dateonly",
475
+ },
476
+ "hidden": {
477
+ "type": "boolean",
478
+ },
479
+ "lastEatenWith": {
480
+ "additionalProperties": {
481
+ "format": "date-time",
482
+ "type": "string",
483
+ },
484
+ "type": "object",
485
+ },
486
+ "likesIds": {
487
+ "items": {
488
+ "properties": {
489
+ "_id": {
490
+ "type": "string",
491
+ },
492
+ "likes": {
493
+ "type": "boolean",
494
+ },
495
+ "userId": {
496
+ "type": "string",
497
+ },
498
+ },
499
+ "required": [],
500
+ "type": "object",
501
+ },
502
+ "type": "array",
503
+ },
504
+ "name": {
505
+ "type": "string",
506
+ },
507
+ "ownerId": {
508
+ "type": "string",
509
+ },
510
+ "source": {
511
+ "properties": {
512
+ "dateAdded": {
513
+ "type": "string",
514
+ },
515
+ "href": {
516
+ "type": "string",
517
+ },
518
+ "name": {
519
+ "type": "string",
520
+ },
521
+ },
522
+ "type": "object",
523
+ },
524
+ "tags": {
525
+ "items": {
526
+ "type": "string",
527
+ },
528
+ "type": "array",
529
+ },
530
+ },
531
+ "required": [
532
+ "likesIds",
533
+ "_id",
534
+ "created",
535
+ "updated",
536
+ ],
537
+ "type": "object",
538
+ },
539
+ },
540
+ },
541
+ "description": "Successful create",
542
+ },
543
+ "400": {
544
+ "content": {
545
+ "application/json": {
546
+ "schema": {
547
+ "$ref": "#/components/schemas/APIError",
548
+ },
549
+ },
550
+ },
551
+ "description": "Bad request",
552
+ },
553
+ "401": {
554
+ "description": "The user must be authenticated",
555
+ },
556
+ "403": {
557
+ "content": {
558
+ "application/json": {
559
+ "schema": {
560
+ "$ref": "#/components/schemas/APIError",
561
+ },
562
+ },
563
+ },
564
+ "description": "The user is not allowed to perform this action on this document",
565
+ },
566
+ "404": {
567
+ "content": {
568
+ "application/json": {
569
+ "schema": {
570
+ "$ref": "#/components/schemas/APIError",
571
+ },
572
+ },
573
+ },
574
+ "description": "Document not found",
575
+ },
576
+ "405": {
577
+ "content": {
578
+ "application/json": {
579
+ "schema": {
580
+ "$ref": "#/components/schemas/APIError",
581
+ },
582
+ },
583
+ },
584
+ "description": "The user is not allowed to perform this action on any document",
585
+ },
586
+ },
587
+ "tags": [
588
+ "foods",
589
+ ],
590
+ },
591
+ },
592
+ "/food/categories": {
593
+ "get": {
594
+ "responses": {
595
+ "200": {
596
+ "content": {
597
+ "application/json": {
598
+ "schema": {
599
+ "items": {
600
+ "properties": {
601
+ "count": {
602
+ "description": "Number of items in category",
603
+ "type": "number",
604
+ },
605
+ "id": {
606
+ "description": "Category ID",
607
+ "type": "string",
608
+ },
609
+ "name": {
610
+ "description": "Category name",
611
+ "type": "string",
612
+ },
613
+ },
614
+ "type": "object",
615
+ },
616
+ "type": "array",
617
+ },
618
+ },
619
+ },
620
+ "description": "List of categories",
621
+ },
622
+ "400": {
623
+ "content": {
624
+ "application/json": {
625
+ "schema": {
626
+ "$ref": "#/components/schemas/APIError",
627
+ },
628
+ },
629
+ },
630
+ "description": "Bad request",
631
+ },
632
+ "401": {
633
+ "description": "The user must be authenticated",
634
+ },
635
+ "403": {
636
+ "content": {
637
+ "application/json": {
638
+ "schema": {
639
+ "$ref": "#/components/schemas/APIError",
640
+ },
641
+ },
642
+ },
643
+ "description": "The user is not allowed to perform this action on this document",
644
+ },
645
+ "404": {
646
+ "content": {
647
+ "application/json": {
648
+ "schema": {
649
+ "$ref": "#/components/schemas/APIError",
650
+ },
651
+ },
652
+ },
653
+ "description": "Document not found",
654
+ },
655
+ "405": {
656
+ "content": {
657
+ "application/json": {
658
+ "schema": {
659
+ "$ref": "#/components/schemas/APIError",
660
+ },
661
+ },
662
+ },
663
+ "description": "The user is not allowed to perform this action on any document",
664
+ },
665
+ },
666
+ "summary": "List food categories",
667
+ "tags": [
668
+ "Categories",
669
+ ],
670
+ },
671
+ },
672
+ "/food/categories/{categoryId}": {
673
+ "get": {
674
+ "parameters": [
675
+ {
676
+ "description": "The category identifier",
677
+ "in": "path",
678
+ "name": "categoryId",
679
+ "required": true,
680
+ "schema": {
681
+ "type": "string",
682
+ },
683
+ },
684
+ ],
685
+ "responses": {
686
+ "200": {
687
+ "content": {
688
+ "application/json": {
689
+ "schema": {
690
+ "properties": {
691
+ "id": {
692
+ "type": "string",
693
+ },
694
+ "name": {
695
+ "type": "string",
696
+ },
697
+ },
698
+ "type": "object",
699
+ },
700
+ },
701
+ },
702
+ "description": "Success",
703
+ },
704
+ "400": {
705
+ "content": {
706
+ "application/json": {
707
+ "schema": {
708
+ "$ref": "#/components/schemas/APIError",
709
+ },
710
+ },
711
+ },
712
+ "description": "Bad request",
713
+ },
714
+ "401": {
715
+ "description": "The user must be authenticated",
716
+ },
717
+ "403": {
718
+ "content": {
719
+ "application/json": {
720
+ "schema": {
721
+ "$ref": "#/components/schemas/APIError",
722
+ },
723
+ },
724
+ },
725
+ "description": "The user is not allowed to perform this action on this document",
726
+ },
727
+ "404": {
728
+ "content": {
729
+ "application/json": {
730
+ "schema": {
731
+ "$ref": "#/components/schemas/APIError",
732
+ },
733
+ },
734
+ },
735
+ "description": "Document not found",
736
+ },
737
+ "405": {
738
+ "content": {
739
+ "application/json": {
740
+ "schema": {
741
+ "$ref": "#/components/schemas/APIError",
742
+ },
743
+ },
744
+ },
745
+ "description": "The user is not allowed to perform this action on any document",
746
+ },
747
+ },
748
+ "summary": "Get category by ID",
749
+ "tags": [
750
+ "Categories",
751
+ ],
752
+ },
753
+ },
754
+ "/food/reports": {
755
+ "post": {
756
+ "description": "Generates a report based on provided criteria",
757
+ "requestBody": {
758
+ "content": {
759
+ "application/json": {
760
+ "schema": {
761
+ "properties": {
762
+ "endDate": {
763
+ "description": "Report end date",
764
+ "format": "date",
765
+ "required": true,
766
+ "type": "string",
767
+ },
768
+ "includeDeleted": {
769
+ "description": "Whether to include deleted items",
770
+ "type": "boolean",
771
+ },
772
+ "startDate": {
773
+ "description": "Report start date",
774
+ "format": "date",
775
+ "required": true,
776
+ "type": "string",
777
+ },
778
+ },
779
+ "required": [
780
+ "endDate",
781
+ "startDate",
782
+ ],
783
+ "type": "object",
784
+ },
785
+ },
786
+ },
787
+ "required": true,
788
+ },
789
+ "responses": {
790
+ "201": {
791
+ "content": {
792
+ "application/json": {
793
+ "schema": {
794
+ "properties": {
795
+ "reportId": {
796
+ "description": "Generated report ID",
797
+ "type": "string",
798
+ },
799
+ },
800
+ "type": "object",
801
+ },
802
+ },
803
+ },
804
+ "description": "Report created successfully",
805
+ },
806
+ "400": {
807
+ "content": {
808
+ "application/json": {
809
+ "schema": {
810
+ "$ref": "#/components/schemas/APIError",
811
+ },
812
+ },
813
+ },
814
+ "description": "Bad request",
815
+ },
816
+ "401": {
817
+ "description": "The user must be authenticated",
818
+ },
819
+ "403": {
820
+ "content": {
821
+ "application/json": {
822
+ "schema": {
823
+ "$ref": "#/components/schemas/APIError",
824
+ },
825
+ },
826
+ },
827
+ "description": "The user is not allowed to perform this action on this document",
828
+ },
829
+ "404": {
830
+ "content": {
831
+ "application/json": {
832
+ "schema": {
833
+ "$ref": "#/components/schemas/APIError",
834
+ },
835
+ },
836
+ },
837
+ "description": "Document not found",
838
+ },
839
+ "405": {
840
+ "content": {
841
+ "application/json": {
842
+ "schema": {
843
+ "$ref": "#/components/schemas/APIError",
844
+ },
845
+ },
846
+ },
847
+ "description": "The user is not allowed to perform this action on any document",
848
+ },
849
+ },
850
+ "summary": "Create a food report",
851
+ "tags": [
852
+ "Reports",
853
+ ],
854
+ },
855
+ },
856
+ "/food/stats": {
857
+ "get": {
858
+ "description": "Returns aggregated statistics about food items",
859
+ "parameters": [
860
+ {
861
+ "description": "Filter by food category",
862
+ "in": "query",
863
+ "name": "category",
864
+ "required": false,
865
+ "schema": {
866
+ "type": "string",
867
+ },
868
+ },
869
+ ],
870
+ "responses": {
871
+ "200": {
872
+ "content": {
873
+ "application/json": {
874
+ "schema": {
875
+ "properties": {
876
+ "avgCalories": {
877
+ "description": "Average calories",
878
+ "type": "number",
879
+ },
880
+ "count": {
881
+ "description": "Total number of food items",
882
+ "type": "number",
883
+ },
884
+ },
885
+ "type": "object",
886
+ },
887
+ },
888
+ },
889
+ "description": "Success",
890
+ },
891
+ "400": {
892
+ "content": {
893
+ "application/json": {
894
+ "schema": {
895
+ "$ref": "#/components/schemas/APIError",
896
+ },
897
+ },
898
+ },
899
+ "description": "Bad request",
900
+ },
901
+ "401": {
902
+ "description": "The user must be authenticated",
903
+ },
904
+ "403": {
905
+ "content": {
906
+ "application/json": {
907
+ "schema": {
908
+ "$ref": "#/components/schemas/APIError",
909
+ },
910
+ },
911
+ },
912
+ "description": "The user is not allowed to perform this action on this document",
913
+ },
914
+ "404": {
915
+ "content": {
916
+ "application/json": {
917
+ "schema": {
918
+ "$ref": "#/components/schemas/APIError",
919
+ },
920
+ },
921
+ },
922
+ "description": "Document not found",
923
+ },
924
+ "405": {
925
+ "content": {
926
+ "application/json": {
927
+ "schema": {
928
+ "$ref": "#/components/schemas/APIError",
929
+ },
930
+ },
931
+ },
932
+ "description": "The user is not allowed to perform this action on any document",
933
+ },
934
+ },
935
+ "summary": "Get food statistics",
936
+ "tags": [
937
+ "Stats",
938
+ ],
939
+ },
940
+ },
941
+ "/food/{id}": {
942
+ "delete": {
943
+ "parameters": [
944
+ {
945
+ "in": "path",
946
+ "name": "id",
947
+ "required": true,
948
+ "schema": {
949
+ "type": "string",
950
+ },
951
+ },
952
+ ],
953
+ "responses": {
954
+ "204": {
955
+ "description": "Successful delete",
956
+ },
957
+ "400": {
958
+ "content": {
959
+ "application/json": {
960
+ "schema": {
961
+ "$ref": "#/components/schemas/APIError",
962
+ },
963
+ },
964
+ },
965
+ "description": "Bad request",
966
+ },
967
+ "401": {
968
+ "description": "The user must be authenticated",
969
+ },
970
+ "403": {
971
+ "content": {
972
+ "application/json": {
973
+ "schema": {
974
+ "$ref": "#/components/schemas/APIError",
975
+ },
976
+ },
977
+ },
978
+ "description": "The user is not allowed to perform this action on this document",
979
+ },
980
+ "404": {
981
+ "content": {
982
+ "application/json": {
983
+ "schema": {
984
+ "$ref": "#/components/schemas/APIError",
985
+ },
986
+ },
987
+ },
988
+ "description": "Document not found",
989
+ },
990
+ "405": {
991
+ "content": {
992
+ "application/json": {
993
+ "schema": {
994
+ "$ref": "#/components/schemas/APIError",
995
+ },
996
+ },
997
+ },
998
+ "description": "The user is not allowed to perform this action on any document",
999
+ },
1000
+ },
1001
+ "tags": [
1002
+ "foods",
1003
+ ],
1004
+ },
1005
+ "get": {
1006
+ "parameters": [
1007
+ {
1008
+ "in": "path",
1009
+ "name": "id",
1010
+ "required": true,
1011
+ "schema": {
1012
+ "type": "string",
1013
+ },
1014
+ },
1015
+ ],
1016
+ "responses": {
1017
+ "200": {
1018
+ "content": {
1019
+ "application/json": {
1020
+ "schema": {
1021
+ "properties": {
1022
+ "_id": {
1023
+ "type": "string",
1024
+ },
1025
+ "calories": {
1026
+ "type": "number",
1027
+ },
1028
+ "categories": {
1029
+ "items": {
1030
+ "properties": {
1031
+ "_id": {
1032
+ "type": "string",
1033
+ },
1034
+ "created": {
1035
+ "format": "date-time",
1036
+ "type": "string",
1037
+ },
1038
+ "name": {
1039
+ "type": "string",
1040
+ },
1041
+ "show": {
1042
+ "type": "boolean",
1043
+ },
1044
+ "updated": {
1045
+ "format": "date-time",
1046
+ "type": "string",
1047
+ },
1048
+ },
1049
+ "required": [],
1050
+ "type": "object",
1051
+ },
1052
+ "type": "array",
1053
+ },
1054
+ "created": {
1055
+ "format": "date-time",
1056
+ "type": "string",
1057
+ },
1058
+ "description": {
1059
+ "type": "any",
1060
+ },
1061
+ "eatenBy": {
1062
+ "items": {
1063
+ "required": true,
1064
+ "type": "schemaobjectid",
1065
+ },
1066
+ "type": "array",
1067
+ },
1068
+ "expiration": {
1069
+ "type": "dateonly",
1070
+ },
1071
+ "hidden": {
1072
+ "type": "boolean",
1073
+ },
1074
+ "lastEatenWith": {
1075
+ "additionalProperties": {
1076
+ "format": "date-time",
1077
+ "type": "string",
1078
+ },
1079
+ "type": "object",
1080
+ },
1081
+ "likesIds": {
1082
+ "items": {
1083
+ "properties": {
1084
+ "_id": {
1085
+ "type": "string",
1086
+ },
1087
+ "likes": {
1088
+ "type": "boolean",
1089
+ },
1090
+ "userId": {
1091
+ "type": "string",
1092
+ },
1093
+ },
1094
+ "required": [],
1095
+ "type": "object",
1096
+ },
1097
+ "type": "array",
1098
+ },
1099
+ "name": {
1100
+ "type": "string",
1101
+ },
1102
+ "ownerId": {
1103
+ "type": "string",
1104
+ },
1105
+ "source": {
1106
+ "properties": {
1107
+ "dateAdded": {
1108
+ "type": "string",
1109
+ },
1110
+ "href": {
1111
+ "type": "string",
1112
+ },
1113
+ "name": {
1114
+ "type": "string",
1115
+ },
1116
+ },
1117
+ "type": "object",
1118
+ },
1119
+ "tags": {
1120
+ "items": {
1121
+ "type": "string",
1122
+ },
1123
+ "type": "array",
1124
+ },
1125
+ },
1126
+ "required": [
1127
+ "likesIds",
1128
+ "_id",
1129
+ "created",
1130
+ "updated",
1131
+ ],
1132
+ "type": "object",
1133
+ },
1134
+ },
1135
+ },
1136
+ "description": "Successful read",
1137
+ },
1138
+ "400": {
1139
+ "content": {
1140
+ "application/json": {
1141
+ "schema": {
1142
+ "$ref": "#/components/schemas/APIError",
1143
+ },
1144
+ },
1145
+ },
1146
+ "description": "Bad request",
1147
+ },
1148
+ "401": {
1149
+ "description": "The user must be authenticated",
1150
+ },
1151
+ "403": {
1152
+ "content": {
1153
+ "application/json": {
1154
+ "schema": {
1155
+ "$ref": "#/components/schemas/APIError",
1156
+ },
1157
+ },
1158
+ },
1159
+ "description": "The user is not allowed to perform this action on this document",
1160
+ },
1161
+ "404": {
1162
+ "content": {
1163
+ "application/json": {
1164
+ "schema": {
1165
+ "$ref": "#/components/schemas/APIError",
1166
+ },
1167
+ },
1168
+ },
1169
+ "description": "Document not found",
1170
+ },
1171
+ "405": {
1172
+ "content": {
1173
+ "application/json": {
1174
+ "schema": {
1175
+ "$ref": "#/components/schemas/APIError",
1176
+ },
1177
+ },
1178
+ },
1179
+ "description": "The user is not allowed to perform this action on any document",
1180
+ },
1181
+ },
1182
+ "tags": [
1183
+ "foods",
1184
+ ],
1185
+ },
1186
+ "patch": {
1187
+ "parameters": [
1188
+ {
1189
+ "in": "path",
1190
+ "name": "id",
1191
+ "required": true,
1192
+ "schema": {
1193
+ "type": "string",
1194
+ },
1195
+ },
1196
+ ],
1197
+ "requestBody": {
1198
+ "content": {
1199
+ "application/json": {
1200
+ "schema": {
1201
+ "properties": {
1202
+ "_id": {
1203
+ "type": "string",
1204
+ },
1205
+ "calories": {
1206
+ "type": "number",
1207
+ },
1208
+ "categories": {
1209
+ "items": {
1210
+ "properties": {
1211
+ "_id": {
1212
+ "type": "string",
1213
+ },
1214
+ "created": {
1215
+ "format": "date-time",
1216
+ "type": "string",
1217
+ },
1218
+ "name": {
1219
+ "type": "string",
1220
+ },
1221
+ "show": {
1222
+ "type": "boolean",
1223
+ },
1224
+ "updated": {
1225
+ "format": "date-time",
1226
+ "type": "string",
1227
+ },
1228
+ },
1229
+ "required": [],
1230
+ "type": "object",
1231
+ },
1232
+ "type": "array",
1233
+ },
1234
+ "created": {
1235
+ "format": "date-time",
1236
+ "type": "string",
1237
+ },
1238
+ "description": {
1239
+ "type": "any",
1240
+ },
1241
+ "eatenBy": {
1242
+ "items": {
1243
+ "required": true,
1244
+ "type": "schemaobjectid",
1245
+ },
1246
+ "type": "array",
1247
+ },
1248
+ "expiration": {
1249
+ "type": "dateonly",
1250
+ },
1251
+ "hidden": {
1252
+ "type": "boolean",
1253
+ },
1254
+ "lastEatenWith": {
1255
+ "additionalProperties": {
1256
+ "format": "date-time",
1257
+ "type": "string",
1258
+ },
1259
+ "type": "object",
1260
+ },
1261
+ "likesIds": {
1262
+ "items": {
1263
+ "properties": {
1264
+ "_id": {
1265
+ "type": "string",
1266
+ },
1267
+ "likes": {
1268
+ "type": "boolean",
1269
+ },
1270
+ "userId": {
1271
+ "type": "string",
1272
+ },
1273
+ },
1274
+ "required": [],
1275
+ "type": "object",
1276
+ },
1277
+ "type": "array",
1278
+ },
1279
+ "name": {
1280
+ "type": "string",
1281
+ },
1282
+ "ownerId": {
1283
+ "type": "string",
1284
+ },
1285
+ "source": {
1286
+ "properties": {
1287
+ "dateAdded": {
1288
+ "type": "string",
1289
+ },
1290
+ "href": {
1291
+ "type": "string",
1292
+ },
1293
+ "name": {
1294
+ "type": "string",
1295
+ },
1296
+ },
1297
+ "type": "object",
1298
+ },
1299
+ "tags": {
1300
+ "items": {
1301
+ "type": "string",
1302
+ },
1303
+ "type": "array",
1304
+ },
1305
+ },
1306
+ "type": "object",
1307
+ },
1308
+ },
1309
+ },
1310
+ "required": true,
1311
+ },
1312
+ "responses": {
1313
+ "200": {
1314
+ "content": {
1315
+ "application/json": {
1316
+ "schema": {
1317
+ "properties": {
1318
+ "_id": {
1319
+ "type": "string",
1320
+ },
1321
+ "calories": {
1322
+ "type": "number",
1323
+ },
1324
+ "categories": {
1325
+ "items": {
1326
+ "properties": {
1327
+ "_id": {
1328
+ "type": "string",
1329
+ },
1330
+ "created": {
1331
+ "format": "date-time",
1332
+ "type": "string",
1333
+ },
1334
+ "name": {
1335
+ "type": "string",
1336
+ },
1337
+ "show": {
1338
+ "type": "boolean",
1339
+ },
1340
+ "updated": {
1341
+ "format": "date-time",
1342
+ "type": "string",
1343
+ },
1344
+ },
1345
+ "required": [],
1346
+ "type": "object",
1347
+ },
1348
+ "type": "array",
1349
+ },
1350
+ "created": {
1351
+ "format": "date-time",
1352
+ "type": "string",
1353
+ },
1354
+ "description": {
1355
+ "type": "any",
1356
+ },
1357
+ "eatenBy": {
1358
+ "items": {
1359
+ "required": true,
1360
+ "type": "schemaobjectid",
1361
+ },
1362
+ "type": "array",
1363
+ },
1364
+ "expiration": {
1365
+ "type": "dateonly",
1366
+ },
1367
+ "hidden": {
1368
+ "type": "boolean",
1369
+ },
1370
+ "lastEatenWith": {
1371
+ "additionalProperties": {
1372
+ "format": "date-time",
1373
+ "type": "string",
1374
+ },
1375
+ "type": "object",
1376
+ },
1377
+ "likesIds": {
1378
+ "items": {
1379
+ "properties": {
1380
+ "_id": {
1381
+ "type": "string",
1382
+ },
1383
+ "likes": {
1384
+ "type": "boolean",
1385
+ },
1386
+ "userId": {
1387
+ "type": "string",
1388
+ },
1389
+ },
1390
+ "required": [],
1391
+ "type": "object",
1392
+ },
1393
+ "type": "array",
1394
+ },
1395
+ "name": {
1396
+ "type": "string",
1397
+ },
1398
+ "ownerId": {
1399
+ "type": "string",
1400
+ },
1401
+ "source": {
1402
+ "properties": {
1403
+ "dateAdded": {
1404
+ "type": "string",
1405
+ },
1406
+ "href": {
1407
+ "type": "string",
1408
+ },
1409
+ "name": {
1410
+ "type": "string",
1411
+ },
1412
+ },
1413
+ "type": "object",
1414
+ },
1415
+ "tags": {
1416
+ "items": {
1417
+ "type": "string",
1418
+ },
1419
+ "type": "array",
1420
+ },
1421
+ },
1422
+ "required": [
1423
+ "likesIds",
1424
+ "_id",
1425
+ "created",
1426
+ "updated",
1427
+ ],
1428
+ "type": "object",
1429
+ },
1430
+ },
1431
+ },
1432
+ "description": "Successful update",
1433
+ },
1434
+ "400": {
1435
+ "content": {
1436
+ "application/json": {
1437
+ "schema": {
1438
+ "$ref": "#/components/schemas/APIError",
1439
+ },
1440
+ },
1441
+ },
1442
+ "description": "Bad request",
1443
+ },
1444
+ "401": {
1445
+ "description": "The user must be authenticated",
1446
+ },
1447
+ "403": {
1448
+ "content": {
1449
+ "application/json": {
1450
+ "schema": {
1451
+ "$ref": "#/components/schemas/APIError",
1452
+ },
1453
+ },
1454
+ },
1455
+ "description": "The user is not allowed to perform this action on this document",
1456
+ },
1457
+ "404": {
1458
+ "content": {
1459
+ "application/json": {
1460
+ "schema": {
1461
+ "$ref": "#/components/schemas/APIError",
1462
+ },
1463
+ },
1464
+ },
1465
+ "description": "Document not found",
1466
+ },
1467
+ "405": {
1468
+ "content": {
1469
+ "application/json": {
1470
+ "schema": {
1471
+ "$ref": "#/components/schemas/APIError",
1472
+ },
1473
+ },
1474
+ },
1475
+ "description": "The user is not allowed to perform this action on any document",
1476
+ },
1477
+ },
1478
+ "tags": [
1479
+ "foods",
1480
+ ],
1481
+ },
1482
+ },
1483
+ },
1484
+ }
1485
+ `;