acebase-server 1.16.1 → 1.17.0

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 (250) hide show
  1. package/README.md +180 -10
  2. package/build-vars.js +2 -1
  3. package/dist/cjs/auth.js +88 -88
  4. package/dist/cjs/cluster.js +56 -56
  5. package/dist/cjs/index.d.ts +1 -1
  6. package/dist/cjs/index.js +24 -24
  7. package/dist/cjs/logger.js +73 -73
  8. package/dist/cjs/middleware/404.js +14 -14
  9. package/dist/cjs/middleware/admin-only.js +28 -28
  10. package/dist/cjs/middleware/cache.js +14 -14
  11. package/dist/cjs/middleware/connection.js +49 -49
  12. package/dist/cjs/middleware/context.js +20 -20
  13. package/dist/cjs/middleware/cors.js +50 -50
  14. package/dist/cjs/middleware/swagger.js +17 -17
  15. package/dist/cjs/middleware/user.js +57 -57
  16. package/dist/cjs/oauth-providers/dropbox.js +109 -109
  17. package/dist/cjs/oauth-providers/facebook.js +85 -85
  18. package/dist/cjs/oauth-providers/google.js +119 -119
  19. package/dist/cjs/oauth-providers/index.js +26 -26
  20. package/dist/cjs/oauth-providers/instagram.js +80 -80
  21. package/dist/cjs/oauth-providers/oauth-provider.js +20 -20
  22. package/dist/cjs/oauth-providers/spotify.js +113 -113
  23. package/dist/cjs/routes/auth-change-password.js +87 -87
  24. package/dist/cjs/routes/auth-delete.js +52 -52
  25. package/dist/cjs/routes/auth-forgot-password.js +77 -77
  26. package/dist/cjs/routes/auth-reset-password.js +97 -97
  27. package/dist/cjs/routes/auth-signin.js +46 -46
  28. package/dist/cjs/routes/auth-signout.js +61 -61
  29. package/dist/cjs/routes/auth-signup.js +142 -142
  30. package/dist/cjs/routes/auth-state.js +25 -25
  31. package/dist/cjs/routes/auth-update.js +131 -131
  32. package/dist/cjs/routes/auth-verify-email.js +71 -71
  33. package/dist/cjs/routes/auth.js +57 -54
  34. package/dist/cjs/routes/data-exists.js +33 -33
  35. package/dist/cjs/routes/data-export.js +48 -48
  36. package/dist/cjs/routes/data-get.js +70 -66
  37. package/dist/cjs/routes/data-import.js +54 -54
  38. package/dist/cjs/routes/data-index-create.js +42 -42
  39. package/dist/cjs/routes/data-index-delete.js +33 -33
  40. package/dist/cjs/routes/data-index-list.js +31 -31
  41. package/dist/cjs/routes/data-query.js +80 -70
  42. package/dist/cjs/routes/data-reflect.js +97 -86
  43. package/dist/cjs/routes/data-schema-get.js +36 -36
  44. package/dist/cjs/routes/data-schema-set.js +30 -30
  45. package/dist/cjs/routes/data-schema-test.js +43 -43
  46. package/dist/cjs/routes/data-schemas-list.js +32 -32
  47. package/dist/cjs/routes/data-set.js +85 -75
  48. package/dist/cjs/routes/data-sync-changes.js +81 -67
  49. package/dist/cjs/routes/data-sync-mutations.js +81 -67
  50. package/dist/cjs/routes/data-transaction.js +159 -139
  51. package/dist/cjs/routes/data-update.js +86 -75
  52. package/dist/cjs/routes/data.js +62 -62
  53. package/dist/cjs/routes/docs.js +258 -251
  54. package/dist/cjs/routes/meta-info.js +63 -63
  55. package/dist/cjs/routes/meta-logs.js +49 -49
  56. package/dist/cjs/routes/meta-ping.js +11 -11
  57. package/dist/cjs/routes/meta-stats.js +27 -27
  58. package/dist/cjs/routes/meta.js +19 -19
  59. package/dist/cjs/routes/oauth2-init.js +54 -54
  60. package/dist/cjs/routes/oauth2-refresh.js +42 -42
  61. package/dist/cjs/routes/oauth2-signin.js +265 -265
  62. package/dist/cjs/routes/webmanager.js +26 -26
  63. package/dist/cjs/rules.js +380 -167
  64. package/dist/cjs/sandbox.js +28 -0
  65. package/dist/cjs/schema/user.js +24 -24
  66. package/dist/cjs/server.js +415 -407
  67. package/dist/cjs/settings/email.js +2 -2
  68. package/dist/cjs/settings/index.js +175 -172
  69. package/dist/cjs/shared/clients.js +26 -26
  70. package/dist/cjs/shared/email.js +2 -2
  71. package/dist/cjs/shared/env.js +2 -2
  72. package/dist/cjs/shared/error.js +33 -33
  73. package/dist/cjs/shared/http.js +28 -28
  74. package/dist/cjs/shared/password.js +45 -45
  75. package/dist/cjs/shared/rootpath.js +16 -16
  76. package/dist/cjs/shared/signin.js +143 -143
  77. package/dist/cjs/shared/simple-fetch.js +76 -76
  78. package/dist/cjs/shared/tokens.js +79 -78
  79. package/dist/cjs/shared/validate.js +61 -61
  80. package/dist/cjs/start.js +53 -53
  81. package/dist/cjs/test.js +10 -10
  82. package/dist/cjs/websocket/index.js +331 -319
  83. package/dist/cjs/websocket/manager.js +15 -15
  84. package/dist/cjs/websocket/socket.io.js +76 -76
  85. package/dist/esm/auth.js +75 -75
  86. package/dist/esm/cluster.js +54 -54
  87. package/dist/esm/index.d.ts +1 -1
  88. package/dist/esm/index.js +4 -4
  89. package/dist/esm/logger.js +51 -51
  90. package/dist/esm/middleware/404.js +10 -10
  91. package/dist/esm/middleware/admin-only.js +24 -24
  92. package/dist/esm/middleware/cache.js +10 -10
  93. package/dist/esm/middleware/connection.js +45 -45
  94. package/dist/esm/middleware/context.js +16 -16
  95. package/dist/esm/middleware/cors.js +44 -44
  96. package/dist/esm/middleware/swagger.js +13 -13
  97. package/dist/esm/middleware/user.js +44 -44
  98. package/dist/esm/oauth-providers/dropbox.js +90 -90
  99. package/dist/esm/oauth-providers/facebook.js +66 -66
  100. package/dist/esm/oauth-providers/google.js +96 -96
  101. package/dist/esm/oauth-providers/index.js +18 -18
  102. package/dist/esm/oauth-providers/instagram.js +61 -61
  103. package/dist/esm/oauth-providers/oauth-provider.js +16 -16
  104. package/dist/esm/oauth-providers/spotify.js +92 -92
  105. package/dist/esm/routes/auth-change-password.js +72 -72
  106. package/dist/esm/routes/auth-delete.js +37 -37
  107. package/dist/esm/routes/auth-forgot-password.js +62 -62
  108. package/dist/esm/routes/auth-reset-password.js +81 -81
  109. package/dist/esm/routes/auth-signin.js +33 -33
  110. package/dist/esm/routes/auth-signout.js +47 -47
  111. package/dist/esm/routes/auth-signup.js +127 -127
  112. package/dist/esm/routes/auth-state.js +12 -12
  113. package/dist/esm/routes/auth-update.js +116 -116
  114. package/dist/esm/routes/auth-verify-email.js +57 -57
  115. package/dist/esm/routes/auth.js +53 -50
  116. package/dist/esm/routes/data-exists.js +20 -20
  117. package/dist/esm/routes/data-export.js +35 -35
  118. package/dist/esm/routes/data-get.js +56 -52
  119. package/dist/esm/routes/data-import.js +41 -41
  120. package/dist/esm/routes/data-index-create.js +28 -28
  121. package/dist/esm/routes/data-index-delete.js +20 -20
  122. package/dist/esm/routes/data-index-list.js +18 -18
  123. package/dist/esm/routes/data-query.js +66 -56
  124. package/dist/esm/routes/data-reflect.js +83 -72
  125. package/dist/esm/routes/data-schema-get.js +23 -23
  126. package/dist/esm/routes/data-schema-set.js +17 -17
  127. package/dist/esm/routes/data-schema-test.js +29 -29
  128. package/dist/esm/routes/data-schemas-list.js +19 -19
  129. package/dist/esm/routes/data-set.js +70 -60
  130. package/dist/esm/routes/data-sync-changes.js +67 -53
  131. package/dist/esm/routes/data-sync-mutations.js +67 -53
  132. package/dist/esm/routes/data-transaction.js +142 -123
  133. package/dist/esm/routes/data-update.js +71 -60
  134. package/dist/esm/routes/data.js +58 -58
  135. package/dist/esm/routes/docs.js +252 -245
  136. package/dist/esm/routes/meta-info.js +59 -59
  137. package/dist/esm/routes/meta-logs.js +35 -35
  138. package/dist/esm/routes/meta-ping.js +7 -7
  139. package/dist/esm/routes/meta-stats.js +14 -14
  140. package/dist/esm/routes/meta.js +15 -15
  141. package/dist/esm/routes/oauth2-init.js +41 -41
  142. package/dist/esm/routes/oauth2-refresh.js +29 -29
  143. package/dist/esm/routes/oauth2-signin.js +251 -251
  144. package/dist/esm/routes/webmanager.js +22 -22
  145. package/dist/esm/rules.js +374 -163
  146. package/dist/esm/sandbox.js +12 -0
  147. package/dist/esm/schema/user.js +19 -19
  148. package/dist/esm/server.js +395 -387
  149. package/dist/esm/settings/email.js +1 -1
  150. package/dist/esm/settings/index.js +168 -165
  151. package/dist/esm/shared/clients.js +22 -22
  152. package/dist/esm/shared/email.js +1 -1
  153. package/dist/esm/shared/env.js +1 -1
  154. package/dist/esm/shared/error.js +25 -25
  155. package/dist/esm/shared/http.js +22 -22
  156. package/dist/esm/shared/password.js +38 -38
  157. package/dist/esm/shared/rootpath.js +13 -13
  158. package/dist/esm/shared/signin.js +128 -128
  159. package/dist/esm/shared/simple-fetch.js +59 -59
  160. package/dist/esm/shared/tokens.js +72 -71
  161. package/dist/esm/shared/validate.js +41 -41
  162. package/dist/esm/start.js +50 -50
  163. package/dist/esm/test.js +8 -8
  164. package/dist/esm/websocket/index.js +313 -302
  165. package/dist/esm/websocket/manager.js +11 -11
  166. package/dist/esm/websocket/socket.io.js +71 -71
  167. package/dist/types/auth.d.ts +3 -3
  168. package/dist/types/cluster.d.ts +1 -1
  169. package/dist/types/index.d.ts +4 -4
  170. package/dist/types/logger.d.ts +35 -35
  171. package/dist/types/middleware/404.d.ts +7 -7
  172. package/dist/types/middleware/admin-only.d.ts +19 -19
  173. package/dist/types/middleware/cache.d.ts +3 -3
  174. package/dist/types/middleware/connection.d.ts +7 -7
  175. package/dist/types/middleware/context.d.ts +3 -3
  176. package/dist/types/middleware/cors.d.ts +25 -25
  177. package/dist/types/middleware/swagger.d.ts +3 -3
  178. package/dist/types/middleware/user.d.ts +2 -2
  179. package/dist/types/oauth-providers/dropbox.d.ts +52 -52
  180. package/dist/types/oauth-providers/facebook.d.ts +41 -41
  181. package/dist/types/oauth-providers/google.d.ts +43 -43
  182. package/dist/types/oauth-providers/index.d.ts +10 -10
  183. package/dist/types/oauth-providers/instagram.d.ts +50 -50
  184. package/dist/types/oauth-providers/oauth-provider.d.ts +74 -74
  185. package/dist/types/oauth-providers/spotify.d.ts +53 -53
  186. package/dist/types/routes/auth-change-password.d.ts +20 -20
  187. package/dist/types/routes/auth-delete.d.ts +16 -16
  188. package/dist/types/routes/auth-forgot-password.d.ts +16 -16
  189. package/dist/types/routes/auth-reset-password.d.ts +23 -23
  190. package/dist/types/routes/auth-signin.d.ts +24 -24
  191. package/dist/types/routes/auth-signout.d.ts +14 -14
  192. package/dist/types/routes/auth-signup.d.ts +32 -32
  193. package/dist/types/routes/auth-state.d.ts +13 -13
  194. package/dist/types/routes/auth-update.d.ts +33 -33
  195. package/dist/types/routes/auth-verify-email.d.ts +21 -21
  196. package/dist/types/routes/auth.d.ts +6 -6
  197. package/dist/types/routes/data-exists.d.ts +9 -9
  198. package/dist/types/routes/data-export.d.ts +10 -10
  199. package/dist/types/routes/data-get.d.ts +14 -14
  200. package/dist/types/routes/data-import.d.ts +13 -13
  201. package/dist/types/routes/data-index-create.d.ts +51 -51
  202. package/dist/types/routes/data-index-delete.d.ts +17 -17
  203. package/dist/types/routes/data-index-list.d.ts +21 -21
  204. package/dist/types/routes/data-query.d.ts +49 -49
  205. package/dist/types/routes/data-reflect.d.ts +29 -29
  206. package/dist/types/routes/data-schema-get.d.ts +11 -11
  207. package/dist/types/routes/data-schema-set.d.ts +19 -19
  208. package/dist/types/routes/data-schema-test.d.ts +19 -19
  209. package/dist/types/routes/data-schemas-list.d.ts +11 -11
  210. package/dist/types/routes/data-set.d.ts +27 -27
  211. package/dist/types/routes/data-sync-changes.d.ts +25 -28
  212. package/dist/types/routes/data-sync-mutations.d.ts +25 -28
  213. package/dist/types/routes/data-transaction.d.ts +34 -34
  214. package/dist/types/routes/data-update.d.ts +27 -27
  215. package/dist/types/routes/data.d.ts +3 -3
  216. package/dist/types/routes/docs.d.ts +3 -3
  217. package/dist/types/routes/meta-info.d.ts +11 -11
  218. package/dist/types/routes/meta-logs.d.ts +20 -20
  219. package/dist/types/routes/meta-ping.d.ts +7 -7
  220. package/dist/types/routes/meta-stats.d.ts +13 -13
  221. package/dist/types/routes/meta.d.ts +3 -3
  222. package/dist/types/routes/oauth2-init.d.ts +13 -13
  223. package/dist/types/routes/oauth2-refresh.d.ts +17 -17
  224. package/dist/types/routes/oauth2-signin.d.ts +15 -15
  225. package/dist/types/routes/webmanager.d.ts +3 -3
  226. package/dist/types/rules.d.ts +73 -34
  227. package/dist/types/sandbox.d.ts +3 -0
  228. package/dist/types/schema/user.d.ts +85 -85
  229. package/dist/types/server.d.ts +117 -111
  230. package/dist/types/settings/email.d.ts +14 -14
  231. package/dist/types/settings/index.d.ts +195 -187
  232. package/dist/types/shared/clients.d.ts +46 -46
  233. package/dist/types/shared/email.d.ts +34 -34
  234. package/dist/types/shared/env.d.ts +47 -44
  235. package/dist/types/shared/error.d.ts +15 -15
  236. package/dist/types/shared/http.d.ts +22 -21
  237. package/dist/types/shared/password.d.ts +19 -19
  238. package/dist/types/shared/rootpath.d.ts +2 -2
  239. package/dist/types/shared/signin.d.ts +31 -31
  240. package/dist/types/shared/simple-fetch.d.ts +21 -21
  241. package/dist/types/shared/tokens.d.ts +24 -23
  242. package/dist/types/shared/validate.d.ts +22 -22
  243. package/dist/types/start.d.ts +1 -1
  244. package/dist/types/test.d.ts +1 -1
  245. package/dist/types/websocket/index.d.ts +6 -6
  246. package/dist/types/websocket/manager.d.ts +99 -99
  247. package/dist/types/websocket/socket.io.d.ts +10 -10
  248. package/package.json +4 -4
  249. package/src/routes/data-set.yaml +5 -5
  250. package/src/routes/data-update.yaml +4 -4
@@ -1,252 +1,259 @@
1
- "use strict";
2
- var _a, _b;
3
- Object.defineProperty(exports, "__esModule", { value: true });
4
- exports.addRoute = void 0;
5
- const swaggerJsdoc = require("swagger-jsdoc");
6
- const createSwaggerDocs = (_a = swaggerJsdoc.default) !== null && _a !== void 0 ? _a : swaggerJsdoc; // ESM and CJS compatible approach
7
- const _swaggerUi = require("swagger-ui-express");
8
- const swaggerUi = (_b = _swaggerUi.default) !== null && _b !== void 0 ? _b : _swaggerUi; // ESM and CJS compatible approach
9
- const rootpath_1 = require("../shared/rootpath");
10
- const path_1 = require("path");
11
- const yamlPath = (0, path_1.join)(rootpath_1.packageRootPath, '/src/routes/*.yaml');
12
- // console.log(`Using path ${yamlPath} for Swagger documentation`);
13
- const addRoute = (env) => {
14
- var _a;
15
- // Generate docs from all yaml files
16
- const options = {
17
- definition: {
18
- openapi: '3.0.0',
19
- info: {
20
- title: 'AceBase Server',
21
- description: 'AceBase Server API endpoint documentation and test environment. This documentation is available on the server because it is running in development mode. To disable this, set your NODE_ENV environment variable to production. Many endpoints require you to authenticate using Bearer authentication. Use the _/auth/{dbname}/signin_ endpoint to obtain an access token, then click the _Authorize_ button and paste your token into the input field. For more information about AceBase, see GitHub',
22
- version: '1.10.0',
23
- contact: {
24
- name: 'AceBase API Support',
25
- email: 'me@appy.one',
26
- url: 'https://github.com/appy-one/acebase-server',
27
- },
28
- },
29
- servers: [
30
- { url: `http${((_a = env.config.https) === null || _a === void 0 ? void 0 : _a.enabled) ? 's' : ''}://${env.config.host}:${env.config.port}${env.config.rootPath ? `/${env.config.rootPath}` : ''}` },
31
- ],
32
- tags: [{
33
- name: 'auth',
34
- description: 'User authentication endpoints',
35
- }, {
36
- name: 'oauth2',
37
- description: 'User authentication using 3rd party OAuth2 providers',
38
- }, {
39
- name: 'data',
40
- description: 'Data manipulation and query endpoints',
41
- }, {
42
- name: 'indexes',
43
- description: 'Index management endpoints',
44
- }, {
45
- name: 'schemas',
46
- description: 'Data schema management endpoints',
47
- }, {
48
- name: 'metadata',
49
- description: 'Metadata endpoints',
50
- }],
51
- components: {
52
- securitySchemes: {
53
- bearerAuth: {
54
- type: 'http',
55
- scheme: 'bearer',
56
- bearerFormat: 'token', // switch to JWT in the future?
57
- },
58
- },
59
- schemas: {
60
- User: {
61
- type: 'object',
62
- properties: {
63
- uid: { type: 'string', example: 'jpx0k53u0002ecr7s354c51l' },
64
- username: { type: 'string', example: 'someuser' },
65
- email: { type: 'string', example: 'email@domain.com' },
66
- displayName: { type: 'string', example: 'Some User' },
67
- picture: {
68
- type: 'object',
69
- properties: {
70
- width: { type: 'number', example: 500 },
71
- height: { type: 'number', example: 500 },
72
- url: { type: 'string', example: 'https://profile.pic/user.jpg' },
73
- },
74
- },
75
- emailVerified: { type: 'boolean', example: true },
76
- created: { type: 'string', example: '2022-03-09T15:38:57.361Z' },
77
- prevSignin: { type: 'string', example: '2022-03-09T15:38:57.361Z' },
78
- prevSigninIp: { type: 'string', example: '127.0.0.1' },
79
- lastSignin: { type: 'string', example: '2022-03-09T15:38:57.361Z' },
80
- lastSigninIp: { type: 'string', example: '127.0.0.1' },
81
- changePassword: { type: 'boolean', example: false },
82
- changePasswordRequested: { type: 'boolean', example: false },
83
- changePasswordBefore: { type: 'string', example: '2022-03-09T15:38:57.361Z' },
84
- settings: { type: 'object' },
85
- },
86
- },
87
- Error: {
88
- type: 'object',
89
- properties: {
90
- code: { type: 'string', description: 'error code', example: 'invalid_request' },
91
- message: { type: 'string', description: 'The error message', example: 'Invalid request for this endpoint' },
92
- },
93
- },
94
- UnexpectedError: {
95
- type: 'object',
96
- properties: {
97
- code: { type: 'string', value: 'unexpected', description: 'The string `"unexpected"`' },
98
- message: { type: 'string', description: 'The server error message' },
99
- },
100
- },
101
- UnknownError: {
102
- type: 'object',
103
- properties: {
104
- code: { type: 'string', value: 'unknown', description: 'The string `"unknown"`' },
105
- message: { type: 'string', description: 'The server error message' },
106
- },
107
- },
108
- SchemaValidationError: {
109
- type: 'object',
110
- properties: {
111
- code: { type: 'string', description: 'The string `"schema_validation_failed"`', example: 'schema_validation_failed' },
112
- message: { type: 'string', description: 'The server error message', example: 'Property at path "path/property" is of the wrong type' },
113
- },
114
- },
115
- SerializedValue: {
116
- type: 'object',
117
- properties: {
118
- val: {
119
- description: 'Any value (serialized for transport)',
120
- oneOf: [
121
- { type: 'string' },
122
- { type: 'number' },
123
- { type: 'integer' },
124
- { type: 'boolean' },
125
- { type: 'object' },
126
- { type: 'array' },
127
- ],
128
- example: '2022-04-07T16:36:21Z',
129
- required: true,
130
- },
131
- map: {
132
- description: 'If the value has been serialized for transport, contains a string defining `val`s data type (eg `"date"` or `"binary"`), or an object with deep property mappings for an object value in `val`',
133
- oneOf: [
134
- { type: 'string', example: 'date' },
135
- { type: 'object', example: { 'stats/created': 'date' } },
136
- ],
137
- example: 'date',
138
- required: false,
139
- },
140
- },
141
- required: ['val'],
142
- example: {
143
- val: { name: 'My todo list', stats: { size: 216, created: '2022-04-07T15:11:42Z', modified: '2022-03-08T12:24:05Z' } },
144
- map: { 'stats/created': 'date', 'stats/modified': 'date' },
145
- },
146
- },
147
- ReflectionNodeInfo: {
148
- type: 'object',
149
- required: ['key', 'exists', 'type'],
150
- properties: {
151
- key: {
152
- description: 'Key or index of the node',
153
- oneOf: [{
154
- type: 'string',
155
- description: 'key of the node',
156
- example: 'jld2cjxh0000qzrmn831i7rn',
157
- }, {
158
- type: 'number',
159
- description: 'index of the node (parent node is an array)',
160
- example: 12,
161
- }],
162
- },
163
- exists: {
164
- type: 'boolean',
165
- description: 'whether the target path exists',
166
- example: true,
167
- },
168
- type: {
169
- type: 'string',
170
- enum: ['unknown', 'object', 'array', 'number', 'boolean', 'string', 'date', 'binary', 'reference'],
171
- description: 'data type of the target path',
172
- example: 'object',
173
- },
174
- value: {
175
- oneOf: [{ type: 'string' }, { type: 'number' }, { type: 'boolean' }, { type: 'array' }, { type: 'object' }],
176
- description: `target node's stored value if it is a boolean, number or date, a small string or binary value (less than configured max inline value size), or an empty object or array`,
177
- example: {},
178
- },
179
- address: {
180
- type: 'object',
181
- description: 'The physical location of the node in the database',
182
- required: ['pageNr', 'recordNr'],
183
- properties: {
184
- pageNr: { type: 'integer' },
185
- recordNr: { type: 'integer' },
186
- },
187
- },
188
- children: {
189
- type: 'object',
190
- description: `Information about the node's children (if requested)`,
191
- required: ['more', 'list'],
192
- properties: {
193
- count: {
194
- type: 'integer',
195
- description: 'The total number of children',
196
- example: 2865,
197
- },
198
- more: {
199
- type: 'boolean',
200
- description: 'If there are more children than the ones in list',
201
- example: true,
202
- },
203
- list: {
204
- type: 'array',
205
- description: 'Reflection info about the requested children',
206
- items: {
207
- $ref: '#/components/schemas/ReflectionNodeInfo',
208
- },
209
- example: [{
210
- key: 'name',
211
- type: 'string',
212
- value: 'My name',
213
- }],
214
- },
215
- },
216
- },
217
- },
218
- example: {
219
- key: 'jld2cjxh0000qzrmn831i7rn',
220
- exists: true,
221
- type: 'object',
222
- address: { pageNr: 0, recordNr: 234 },
223
- children: {
224
- count: 2865,
225
- more: true,
226
- list: [{
227
- key: 'l260qein000009jy3yjig8h9',
228
- type: 'object',
229
- address: { pageNr: 1, recordNr: 25 },
230
- }, {
231
- key: 'l260rp5b000109jy98ykf7x2',
232
- type: 'object',
233
- address: { pageNr: 1, recordNr: 54 },
234
- }],
235
- },
236
- },
237
- },
238
- },
239
- },
240
- security: [
241
- // Enable bearer auth globally
242
- { bearerAuth: [] },
243
- ],
244
- },
245
- apis: [yamlPath],
246
- };
247
- const swaggerDocs = createSwaggerDocs(options);
248
- env.app.use('/docs', swaggerUi.serve, swaggerUi.setup(swaggerDocs));
249
- };
250
- exports.addRoute = addRoute;
251
- exports.default = exports.addRoute;
1
+ "use strict";
2
+ var _a, _b;
3
+ Object.defineProperty(exports, "__esModule", { value: true });
4
+ exports.addRoute = void 0;
5
+ const swaggerJsdoc = require("swagger-jsdoc");
6
+ const createSwaggerDocs = (_a = swaggerJsdoc.default) !== null && _a !== void 0 ? _a : swaggerJsdoc; // ESM and CJS compatible approach
7
+ const _swaggerUi = require("swagger-ui-express");
8
+ const swaggerUi = (_b = _swaggerUi.default) !== null && _b !== void 0 ? _b : _swaggerUi; // ESM and CJS compatible approach
9
+ const rootpath_1 = require("../shared/rootpath");
10
+ const path_1 = require("path");
11
+ const yamlPath = (0, path_1.join)(rootpath_1.packageRootPath, '/src/routes/*.yaml');
12
+ // console.log(`Using path ${yamlPath} for Swagger documentation`);
13
+ const addRoute = (env) => {
14
+ var _a;
15
+ // Generate docs from all yaml files
16
+ const options = {
17
+ definition: {
18
+ openapi: '3.0.0',
19
+ info: {
20
+ title: 'AceBase Server',
21
+ description: 'AceBase Server API endpoint documentation and test environment. This documentation is available on the server because it is running in development mode. To disable this, set your NODE_ENV environment variable to production. Many endpoints require you to authenticate using Bearer authentication. Use the _/auth/{dbname}/signin_ endpoint to obtain an access token, then click the _Authorize_ button and paste your token into the input field. For more information about AceBase, see GitHub',
22
+ version: '1.17.0',
23
+ contact: {
24
+ name: 'AceBase API Support',
25
+ email: 'me@appy.one',
26
+ url: 'https://github.com/appy-one/acebase-server',
27
+ },
28
+ },
29
+ servers: [
30
+ { url: `http${((_a = env.config.https) === null || _a === void 0 ? void 0 : _a.enabled) ? 's' : ''}://${env.config.host}:${env.config.port}${env.config.rootPath ? `/${env.config.rootPath}` : ''}` },
31
+ ],
32
+ tags: [{
33
+ name: 'auth',
34
+ description: 'User authentication endpoints',
35
+ }, {
36
+ name: 'oauth2',
37
+ description: 'User authentication using 3rd party OAuth2 providers',
38
+ }, {
39
+ name: 'data',
40
+ description: 'Data manipulation and query endpoints',
41
+ }, {
42
+ name: 'indexes',
43
+ description: 'Index management endpoints',
44
+ }, {
45
+ name: 'schemas',
46
+ description: 'Data schema management endpoints',
47
+ }, {
48
+ name: 'metadata',
49
+ description: 'Metadata endpoints',
50
+ }],
51
+ components: {
52
+ securitySchemes: {
53
+ bearerAuth: {
54
+ type: 'http',
55
+ scheme: 'bearer',
56
+ bearerFormat: 'token', // switch to JWT in the future?
57
+ },
58
+ },
59
+ schemas: {
60
+ User: {
61
+ type: 'object',
62
+ properties: {
63
+ uid: { type: 'string', example: 'jpx0k53u0002ecr7s354c51l' },
64
+ username: { type: 'string', example: 'someuser' },
65
+ email: { type: 'string', example: 'email@domain.com' },
66
+ displayName: { type: 'string', example: 'Some User' },
67
+ picture: {
68
+ type: 'object',
69
+ properties: {
70
+ width: { type: 'number', example: 500 },
71
+ height: { type: 'number', example: 500 },
72
+ url: { type: 'string', example: 'https://profile.pic/user.jpg' },
73
+ },
74
+ },
75
+ emailVerified: { type: 'boolean', example: true },
76
+ created: { type: 'string', example: '2022-03-09T15:38:57.361Z' },
77
+ prevSignin: { type: 'string', example: '2022-03-09T15:38:57.361Z' },
78
+ prevSigninIp: { type: 'string', example: '127.0.0.1' },
79
+ lastSignin: { type: 'string', example: '2022-03-09T15:38:57.361Z' },
80
+ lastSigninIp: { type: 'string', example: '127.0.0.1' },
81
+ changePassword: { type: 'boolean', example: false },
82
+ changePasswordRequested: { type: 'boolean', example: false },
83
+ changePasswordBefore: { type: 'string', example: '2022-03-09T15:38:57.361Z' },
84
+ settings: { type: 'object' },
85
+ },
86
+ },
87
+ Error: {
88
+ type: 'object',
89
+ properties: {
90
+ code: { type: 'string', description: 'error code', example: 'invalid_request' },
91
+ message: { type: 'string', description: 'The error message', example: 'Invalid request for this endpoint' },
92
+ },
93
+ },
94
+ UnexpectedError: {
95
+ type: 'object',
96
+ properties: {
97
+ code: { type: 'string', value: 'unexpected', description: 'The string `"unexpected"`' },
98
+ message: { type: 'string', description: 'The server error message' },
99
+ },
100
+ },
101
+ UnknownError: {
102
+ type: 'object',
103
+ properties: {
104
+ code: { type: 'string', value: 'unknown', description: 'The string `"unknown"`' },
105
+ message: { type: 'string', description: 'The server error message' },
106
+ },
107
+ },
108
+ SchemaValidationError: {
109
+ type: 'object',
110
+ properties: {
111
+ code: { type: 'string', description: 'The string `"schema_validation_failed"`', example: 'schema_validation_failed' },
112
+ message: { type: 'string', description: 'The server error message', example: 'Property at path "path/property" is of the wrong type' },
113
+ },
114
+ },
115
+ RuleValidationError: {
116
+ type: 'object',
117
+ properties: {
118
+ code: { type: 'string', description: 'The string `"rule"`', example: 'rule' },
119
+ message: { type: 'string', description: 'The server error message', example: 'write operation denied to path "path/property" by set rule' },
120
+ },
121
+ },
122
+ SerializedValue: {
123
+ type: 'object',
124
+ properties: {
125
+ val: {
126
+ description: 'Any value (serialized for transport)',
127
+ oneOf: [
128
+ { type: 'string' },
129
+ { type: 'number' },
130
+ { type: 'integer' },
131
+ { type: 'boolean' },
132
+ { type: 'object' },
133
+ { type: 'array' },
134
+ ],
135
+ example: '2022-04-07T16:36:21Z',
136
+ required: true,
137
+ },
138
+ map: {
139
+ description: 'If the value has been serialized for transport, contains a string defining `val`s data type (eg `"date"` or `"binary"`), or an object with deep property mappings for an object value in `val`',
140
+ oneOf: [
141
+ { type: 'string', example: 'date' },
142
+ { type: 'object', example: { 'stats/created': 'date' } },
143
+ ],
144
+ example: 'date',
145
+ required: false,
146
+ },
147
+ },
148
+ required: ['val'],
149
+ example: {
150
+ val: { name: 'My todo list', stats: { size: 216, created: '2022-04-07T15:11:42Z', modified: '2022-03-08T12:24:05Z' } },
151
+ map: { 'stats/created': 'date', 'stats/modified': 'date' },
152
+ },
153
+ },
154
+ ReflectionNodeInfo: {
155
+ type: 'object',
156
+ required: ['key', 'exists', 'type'],
157
+ properties: {
158
+ key: {
159
+ description: 'Key or index of the node',
160
+ oneOf: [{
161
+ type: 'string',
162
+ description: 'key of the node',
163
+ example: 'jld2cjxh0000qzrmn831i7rn',
164
+ }, {
165
+ type: 'number',
166
+ description: 'index of the node (parent node is an array)',
167
+ example: 12,
168
+ }],
169
+ },
170
+ exists: {
171
+ type: 'boolean',
172
+ description: 'whether the target path exists',
173
+ example: true,
174
+ },
175
+ type: {
176
+ type: 'string',
177
+ enum: ['unknown', 'object', 'array', 'number', 'boolean', 'string', 'date', 'binary', 'reference'],
178
+ description: 'data type of the target path',
179
+ example: 'object',
180
+ },
181
+ value: {
182
+ oneOf: [{ type: 'string' }, { type: 'number' }, { type: 'boolean' }, { type: 'array' }, { type: 'object' }],
183
+ description: `target node's stored value if it is a boolean, number or date, a small string or binary value (less than configured max inline value size), or an empty object or array`,
184
+ example: {},
185
+ },
186
+ address: {
187
+ type: 'object',
188
+ description: 'The physical location of the node in the database',
189
+ required: ['pageNr', 'recordNr'],
190
+ properties: {
191
+ pageNr: { type: 'integer' },
192
+ recordNr: { type: 'integer' },
193
+ },
194
+ },
195
+ children: {
196
+ type: 'object',
197
+ description: `Information about the node's children (if requested)`,
198
+ required: ['more', 'list'],
199
+ properties: {
200
+ count: {
201
+ type: 'integer',
202
+ description: 'The total number of children',
203
+ example: 2865,
204
+ },
205
+ more: {
206
+ type: 'boolean',
207
+ description: 'If there are more children than the ones in list',
208
+ example: true,
209
+ },
210
+ list: {
211
+ type: 'array',
212
+ description: 'Reflection info about the requested children',
213
+ items: {
214
+ $ref: '#/components/schemas/ReflectionNodeInfo',
215
+ },
216
+ example: [{
217
+ key: 'name',
218
+ type: 'string',
219
+ value: 'My name',
220
+ }],
221
+ },
222
+ },
223
+ },
224
+ },
225
+ example: {
226
+ key: 'jld2cjxh0000qzrmn831i7rn',
227
+ exists: true,
228
+ type: 'object',
229
+ address: { pageNr: 0, recordNr: 234 },
230
+ children: {
231
+ count: 2865,
232
+ more: true,
233
+ list: [{
234
+ key: 'l260qein000009jy3yjig8h9',
235
+ type: 'object',
236
+ address: { pageNr: 1, recordNr: 25 },
237
+ }, {
238
+ key: 'l260rp5b000109jy98ykf7x2',
239
+ type: 'object',
240
+ address: { pageNr: 1, recordNr: 54 },
241
+ }],
242
+ },
243
+ },
244
+ },
245
+ },
246
+ },
247
+ security: [
248
+ // Enable bearer auth globally
249
+ { bearerAuth: [] },
250
+ ],
251
+ },
252
+ apis: [yamlPath],
253
+ };
254
+ const swaggerDocs = createSwaggerDocs(options);
255
+ env.router.use('/docs', swaggerUi.serve, swaggerUi.setup(swaggerDocs));
256
+ };
257
+ exports.addRoute = addRoute;
258
+ exports.default = exports.addRoute;
252
259
  //# sourceMappingURL=docs.js.map