@furystack/rest-service 7.0.0 → 7.0.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 (189) hide show
  1. package/{types → esm}/actions/error-action.d.ts +1 -1
  2. package/{types → esm}/actions/error-action.d.ts.map +1 -1
  3. package/esm/actions/error-action.js +25 -0
  4. package/esm/actions/error-action.js.map +1 -0
  5. package/{types → esm}/actions/get-current-user.d.ts +1 -1
  6. package/{types → esm}/actions/get-current-user.d.ts.map +1 -1
  7. package/esm/actions/get-current-user.js +12 -0
  8. package/esm/actions/get-current-user.js.map +1 -0
  9. package/esm/actions/index.d.ts +7 -0
  10. package/esm/actions/index.d.ts.map +1 -0
  11. package/esm/actions/index.js +7 -0
  12. package/esm/actions/index.js.map +1 -0
  13. package/{types → esm}/actions/is-authenticated.d.ts +1 -1
  14. package/{types → esm}/actions/is-authenticated.d.ts.map +1 -1
  15. package/esm/actions/is-authenticated.js +13 -0
  16. package/esm/actions/is-authenticated.js.map +1 -0
  17. package/{types → esm}/actions/login.d.ts +2 -2
  18. package/esm/actions/login.d.ts.map +1 -0
  19. package/esm/actions/login.js +22 -0
  20. package/esm/actions/login.js.map +1 -0
  21. package/{types → esm}/actions/logout.d.ts +1 -1
  22. package/{types → esm}/actions/logout.d.ts.map +1 -1
  23. package/esm/actions/logout.js +15 -0
  24. package/esm/actions/logout.js.map +1 -0
  25. package/{types → esm}/actions/not-found-action.d.ts +1 -1
  26. package/{types → esm}/actions/not-found-action.d.ts.map +1 -1
  27. package/esm/actions/not-found-action.js +10 -0
  28. package/esm/actions/not-found-action.js.map +1 -0
  29. package/{types → esm}/api-manager.d.ts +4 -4
  30. package/{types → esm}/api-manager.d.ts.map +1 -1
  31. package/esm/api-manager.js +153 -0
  32. package/esm/api-manager.js.map +1 -0
  33. package/{types → esm}/authenticate.d.ts +1 -1
  34. package/{types → esm}/authenticate.d.ts.map +1 -1
  35. package/esm/authenticate.js +16 -0
  36. package/esm/authenticate.js.map +1 -0
  37. package/{types → esm}/authorize.d.ts +1 -1
  38. package/{types → esm}/authorize.d.ts.map +1 -1
  39. package/esm/authorize.js +19 -0
  40. package/esm/authorize.js.map +1 -0
  41. package/{types → esm}/endpoint-generators/create-delete-endpoint.d.ts +1 -1
  42. package/{types → esm}/endpoint-generators/create-delete-endpoint.d.ts.map +1 -1
  43. package/esm/endpoint-generators/create-delete-endpoint.js +20 -0
  44. package/esm/endpoint-generators/create-delete-endpoint.js.map +1 -0
  45. package/{types → esm}/endpoint-generators/create-get-collection-endpoint.d.ts +1 -1
  46. package/{types → esm}/endpoint-generators/create-get-collection-endpoint.d.ts.map +1 -1
  47. package/esm/endpoint-generators/create-get-collection-endpoint.js +22 -0
  48. package/esm/endpoint-generators/create-get-collection-endpoint.js.map +1 -0
  49. package/{types → esm}/endpoint-generators/create-get-entity-endpoint.d.ts +1 -1
  50. package/{types → esm}/endpoint-generators/create-get-entity-endpoint.d.ts.map +1 -1
  51. package/esm/endpoint-generators/create-get-entity-endpoint.js +25 -0
  52. package/esm/endpoint-generators/create-get-entity-endpoint.js.map +1 -0
  53. package/{types → esm}/endpoint-generators/create-patch-endpoint.d.ts +1 -1
  54. package/{types → esm}/endpoint-generators/create-patch-endpoint.d.ts.map +1 -1
  55. package/esm/endpoint-generators/create-patch-endpoint.js +22 -0
  56. package/esm/endpoint-generators/create-patch-endpoint.js.map +1 -0
  57. package/{types → esm}/endpoint-generators/create-post-endpoint.d.ts +1 -1
  58. package/{types → esm}/endpoint-generators/create-post-endpoint.d.ts.map +1 -1
  59. package/esm/endpoint-generators/create-post-endpoint.js +25 -0
  60. package/esm/endpoint-generators/create-post-endpoint.js.map +1 -0
  61. package/esm/endpoint-generators/index.d.ts +6 -0
  62. package/{types → esm}/endpoint-generators/index.d.ts.map +1 -1
  63. package/esm/endpoint-generators/index.js +6 -0
  64. package/esm/endpoint-generators/index.js.map +1 -0
  65. package/esm/endpoint-generators/utils.js +23 -0
  66. package/esm/endpoint-generators/utils.js.map +1 -0
  67. package/{types → esm}/helpers.d.ts +4 -4
  68. package/esm/helpers.d.ts.map +1 -0
  69. package/esm/helpers.js +28 -0
  70. package/esm/helpers.js.map +1 -0
  71. package/{types → esm}/http-authentication-settings.d.ts +1 -1
  72. package/{types → esm}/http-authentication-settings.d.ts.map +1 -1
  73. package/esm/http-authentication-settings.js +26 -0
  74. package/esm/http-authentication-settings.js.map +1 -0
  75. package/{types → esm}/http-user-context.d.ts +2 -2
  76. package/{types → esm}/http-user-context.d.ts.map +1 -1
  77. package/esm/http-user-context.js +168 -0
  78. package/esm/http-user-context.js.map +1 -0
  79. package/esm/incoming-message-extensions.js +11 -0
  80. package/esm/incoming-message-extensions.js.map +1 -0
  81. package/esm/index.d.ts +19 -0
  82. package/esm/index.d.ts.map +1 -0
  83. package/esm/index.js +19 -0
  84. package/esm/index.js.map +1 -0
  85. package/esm/mime-types.js +333 -0
  86. package/esm/mime-types.js.map +1 -0
  87. package/esm/models/cors-options.js +2 -0
  88. package/esm/models/cors-options.js.map +1 -0
  89. package/esm/models/default-session.js +6 -0
  90. package/esm/models/default-session.js.map +1 -0
  91. package/esm/models/index.d.ts +3 -0
  92. package/esm/models/index.d.ts.map +1 -0
  93. package/esm/models/index.js +3 -0
  94. package/esm/models/index.js.map +1 -0
  95. package/esm/request-action-implementation.js +34 -0
  96. package/esm/request-action-implementation.js.map +1 -0
  97. package/esm/schema-validator/index.d.ts +3 -0
  98. package/{types → esm}/schema-validator/index.d.ts.map +1 -1
  99. package/esm/schema-validator/index.js +3 -0
  100. package/esm/schema-validator/index.js.map +1 -0
  101. package/esm/schema-validator/schema-validation-error.js +11 -0
  102. package/esm/schema-validator/schema-validation-error.js.map +1 -0
  103. package/esm/schema-validator/schema-validator.js +31 -0
  104. package/esm/schema-validator/schema-validator.js.map +1 -0
  105. package/esm/schema-validator/validate-examples.js +26 -0
  106. package/esm/schema-validator/validate-examples.js.map +1 -0
  107. package/{types → esm}/server-manager.d.ts +1 -1
  108. package/esm/server-manager.js +73 -0
  109. package/esm/server-manager.js.map +1 -0
  110. package/{types → esm}/server-response-extensions.d.ts +1 -1
  111. package/{types → esm}/server-response-extensions.d.ts.map +1 -1
  112. package/esm/server-response-extensions.js +12 -0
  113. package/esm/server-response-extensions.js.map +1 -0
  114. package/{types → esm}/static-server-manager.d.ts +1 -1
  115. package/esm/static-server-manager.js +68 -0
  116. package/esm/static-server-manager.js.map +1 -0
  117. package/{types → esm}/utils.d.ts +1 -1
  118. package/{types → esm}/utils.d.ts.map +1 -1
  119. package/esm/utils.js +70 -0
  120. package/esm/utils.js.map +1 -0
  121. package/{types → esm}/validate.d.ts +1 -1
  122. package/{types → esm}/validate.d.ts.map +1 -1
  123. package/esm/validate.integration.schema.js +2 -0
  124. package/esm/validate.integration.schema.js.map +1 -0
  125. package/esm/validate.integration.spec.schema.json +903 -0
  126. package/esm/validate.js +43 -0
  127. package/esm/validate.js.map +1 -0
  128. package/package.json +11 -20
  129. package/src/actions/error-action.ts +3 -3
  130. package/src/actions/get-current-user.ts +3 -3
  131. package/src/actions/index.ts +6 -6
  132. package/src/actions/is-authenticated.ts +2 -2
  133. package/src/actions/login.ts +4 -4
  134. package/src/actions/logout.ts +3 -3
  135. package/src/actions/not-found-action.ts +2 -2
  136. package/src/api-manager.ts +10 -9
  137. package/src/authenticate.ts +3 -3
  138. package/src/authorize.ts +2 -2
  139. package/src/endpoint-generators/create-delete-endpoint.ts +2 -2
  140. package/src/endpoint-generators/create-get-collection-endpoint.ts +2 -2
  141. package/src/endpoint-generators/create-get-entity-endpoint.ts +2 -2
  142. package/src/endpoint-generators/create-patch-endpoint.ts +2 -2
  143. package/src/endpoint-generators/create-post-endpoint.ts +2 -2
  144. package/src/endpoint-generators/index.ts +5 -5
  145. package/src/endpoint-generators/utils.ts +1 -1
  146. package/src/helpers.ts +6 -6
  147. package/src/http-authentication-settings.ts +1 -1
  148. package/src/http-user-context.ts +2 -2
  149. package/src/incoming-message-extensions.ts +1 -1
  150. package/src/index.ts +18 -18
  151. package/src/models/index.ts +2 -2
  152. package/src/schema-validator/index.ts +2 -2
  153. package/src/schema-validator/schema-validator.ts +3 -3
  154. package/src/server-response-extensions.ts +1 -1
  155. package/src/static-server-manager.ts +2 -2
  156. package/src/utils.ts +1 -1
  157. package/src/validate.ts +2 -2
  158. package/types/actions/index.d.ts +0 -7
  159. package/types/actions/index.d.ts.map +0 -1
  160. package/types/actions/login.d.ts.map +0 -1
  161. package/types/endpoint-generators/index.d.ts +0 -6
  162. package/types/helpers.d.ts.map +0 -1
  163. package/types/index.d.ts +0 -19
  164. package/types/index.d.ts.map +0 -1
  165. package/types/models/index.d.ts +0 -3
  166. package/types/models/index.d.ts.map +0 -1
  167. package/types/schema-validator/index.d.ts +0 -3
  168. /package/{types → esm}/endpoint-generators/utils.d.ts +0 -0
  169. /package/{types → esm}/endpoint-generators/utils.d.ts.map +0 -0
  170. /package/{types → esm}/incoming-message-extensions.d.ts +0 -0
  171. /package/{types → esm}/incoming-message-extensions.d.ts.map +0 -0
  172. /package/{types → esm}/mime-types.d.ts +0 -0
  173. /package/{types → esm}/mime-types.d.ts.map +0 -0
  174. /package/{types → esm}/models/cors-options.d.ts +0 -0
  175. /package/{types → esm}/models/cors-options.d.ts.map +0 -0
  176. /package/{types → esm}/models/default-session.d.ts +0 -0
  177. /package/{types → esm}/models/default-session.d.ts.map +0 -0
  178. /package/{types → esm}/request-action-implementation.d.ts +0 -0
  179. /package/{types → esm}/request-action-implementation.d.ts.map +0 -0
  180. /package/{types → esm}/schema-validator/schema-validation-error.d.ts +0 -0
  181. /package/{types → esm}/schema-validator/schema-validation-error.d.ts.map +0 -0
  182. /package/{types → esm}/schema-validator/schema-validator.d.ts +0 -0
  183. /package/{types → esm}/schema-validator/schema-validator.d.ts.map +0 -0
  184. /package/{types → esm}/schema-validator/validate-examples.d.ts +0 -0
  185. /package/{types → esm}/schema-validator/validate-examples.d.ts.map +0 -0
  186. /package/{types → esm}/server-manager.d.ts.map +0 -0
  187. /package/{types → esm}/static-server-manager.d.ts.map +0 -0
  188. /package/{types → esm}/validate.integration.schema.d.ts +0 -0
  189. /package/{types → esm}/validate.integration.schema.d.ts.map +0 -0
@@ -0,0 +1,43 @@
1
+ import { SchemaValidator } from './schema-validator/schema-validator.js';
2
+ export const Validate = (validationOptions) => (action) => {
3
+ const schema = { ...validationOptions.schema };
4
+ Object.values(schema.definitions).forEach((definition) => {
5
+ if (definition.required && definition.required.includes('result')) {
6
+ definition.required = definition.required.filter((value) => value !== 'result');
7
+ }
8
+ definition.additionalProperties = true;
9
+ if (definition.properties?.headers) {
10
+ definition.properties.headers.additionalProperties = true;
11
+ }
12
+ });
13
+ const validator = new SchemaValidator(schema, { coerceTypes: true, strict: false });
14
+ return async (args) => {
15
+ const anyArgs = args;
16
+ let body;
17
+ const { headers } = anyArgs;
18
+ const query = anyArgs.getQuery?.();
19
+ const url = anyArgs.getUrlParams?.();
20
+ try {
21
+ body = await anyArgs.getBody?.();
22
+ }
23
+ catch (error) {
24
+ // ignore
25
+ }
26
+ validator.isValid({
27
+ ...(query ? { query } : {}),
28
+ ...(body ? { body } : {}),
29
+ ...(url ? { url } : {}),
30
+ ...(headers ? { headers } : {}),
31
+ }, { schemaName: validationOptions.schemaName });
32
+ return await action({
33
+ request: args.request,
34
+ response: args.response,
35
+ injector: args.injector,
36
+ headers,
37
+ getQuery: () => query,
38
+ getUrlParams: () => url,
39
+ getBody: () => Promise.resolve(body),
40
+ });
41
+ };
42
+ };
43
+ //# sourceMappingURL=validate.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"validate.js","sourceRoot":"","sources":["../src/validate.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,eAAe,EAAE,MAAM,wCAAwC,CAAA;AAExE,MAAM,CAAC,MAAM,QAAQ,GACnB,CAAkF,iBASjF,EAAE,EAAE,CACL,CAA4B,MAAwB,EAAoB,EAAE;IACxE,MAAM,MAAM,GAAG,EAAE,GAAG,iBAAiB,CAAC,MAAM,EAAE,CAAA;IAE9C,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC,WAAW,CAAC,CAAC,OAAO,CAAC,CAAC,UAAU,EAAE,EAAE;QACvD,IAAI,UAAU,CAAC,QAAQ,IAAI,UAAU,CAAC,QAAQ,CAAC,QAAQ,CAAC,QAAQ,CAAC,EAAE;YACjE,UAAU,CAAC,QAAQ,GAAG,UAAU,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC,KAAU,EAAE,EAAE,CAAC,KAAK,KAAK,QAAQ,CAAC,CAAA;SACrF;QACD,UAAU,CAAC,oBAAoB,GAAG,IAAI,CAAA;QACtC,IAAI,UAAU,CAAC,UAAU,EAAE,OAAO,EAAE;YAClC,UAAU,CAAC,UAAU,CAAC,OAAO,CAAC,oBAAoB,GAAG,IAAI,CAAA;SAC1D;IACH,CAAC,CAAC,CAAA;IAEF,MAAM,SAAS,GAAG,IAAI,eAAe,CAAC,MAAM,EAAE,EAAE,WAAW,EAAE,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,CAAC,CAAA;IAEnF,OAAO,KAAK,EAAE,IAA6B,EAA4B,EAAE;QACvE,MAAM,OAAO,GAAG,IAAW,CAAA;QAC3B,IAAI,IAAU,CAAA;QACd,MAAM,EAAE,OAAO,EAAE,GAAG,OAAO,CAAA;QAC3B,MAAM,KAAK,GAAG,OAAO,CAAC,QAAQ,EAAE,EAAE,CAAA;QAClC,MAAM,GAAG,GAAG,OAAO,CAAC,YAAY,EAAE,EAAE,CAAA;QACpC,IAAI;YACF,IAAI,GAAG,MAAM,OAAO,CAAC,OAAO,EAAE,EAAE,CAAA;SACjC;QAAC,OAAO,KAAK,EAAE;YACd,SAAS;SACV;QACD,SAAS,CAAC,OAAO,CACf;YACE,GAAG,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,KAAK,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;YAC3B,GAAG,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;YACzB,GAAG,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,GAAG,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;YACvB,GAAG,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE,OAAO,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;SAChC,EACD,EAAE,UAAU,EAAE,iBAAiB,CAAC,UAAU,EAAE,CAC7C,CAAA;QACD,OAAO,MAAM,MAAM,CAAC;YAClB,OAAO,EAAE,IAAI,CAAC,OAAO;YACrB,QAAQ,EAAE,IAAI,CAAC,QAAQ;YACvB,QAAQ,EAAE,IAAI,CAAC,QAAQ;YACvB,OAAO;YACP,QAAQ,EAAE,GAAG,EAAE,CAAC,KAAK;YACrB,YAAY,EAAE,GAAG,EAAE,CAAC,GAAG;YACvB,OAAO,EAAE,GAAG,EAAE,CAAC,OAAO,CAAC,OAAO,CAAC,IAAI,CAAC;SAC9B,CAAC,CAAA;IACX,CAAC,CAAA;AACH,CAAC,CAAA"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@furystack/rest-service",
3
- "version": "7.0.0",
3
+ "version": "7.0.2",
4
4
  "description": "Repository implementation for FuryStack",
5
5
  "type": "module",
6
6
  "scripts": {
@@ -8,20 +8,11 @@
8
8
  },
9
9
  "exports": {
10
10
  ".": {
11
- "import": "./esm/index.js",
12
- "types": "./types/index.d.ts"
13
- },
14
- "./package.json": "./package.json"
15
- },
16
- "typesVersions": {
17
- "*": {
18
- "*": [
19
- "types/*"
20
- ]
11
+ "import": "./esm/index.js"
21
12
  }
22
13
  },
23
14
  "files": [
24
- "dist",
15
+ "esm",
25
16
  "types",
26
17
  "src"
27
18
  ],
@@ -46,20 +37,20 @@
46
37
  },
47
38
  "homepage": "https://github.com/furystack/furystack",
48
39
  "dependencies": {
49
- "@furystack/core": "^12.0.0",
50
- "@furystack/inject": "^8.0.0",
51
- "@furystack/repository": "^7.0.0",
52
- "@furystack/rest": "^5.0.0",
53
- "@furystack/security": "^3.0.0",
54
- "@furystack/utils": "^4.0.0",
40
+ "@furystack/core": "^12.0.2",
41
+ "@furystack/inject": "^8.0.2",
42
+ "@furystack/repository": "^7.0.2",
43
+ "@furystack/rest": "^5.0.2",
44
+ "@furystack/security": "^3.0.2",
45
+ "@furystack/utils": "^4.0.2",
55
46
  "ajv": "^8.12.0",
56
47
  "ajv-formats": "^2.1.1",
57
48
  "path-to-regexp": "^6.2.1",
58
49
  "semaphore-async-await": "^1.5.1"
59
50
  },
60
51
  "devDependencies": {
61
- "@furystack/rest-client-fetch": "^5.0.0",
62
- "@types/node": "^18.15.11",
52
+ "@furystack/rest-client-fetch": "^5.0.2",
53
+ "@types/node": "^18.16.2",
63
54
  "typescript": "^5.0.4",
64
55
  "vitest": "^0.30.1"
65
56
  },
@@ -1,8 +1,8 @@
1
1
  import { RequestError } from '@furystack/rest'
2
2
  import { AuthorizationError } from '@furystack/core'
3
- import type { RequestAction } from '../request-action-implementation'
4
- import { JsonResult } from '../request-action-implementation'
5
- import { SchemaValidationError } from '../schema-validator'
3
+ import type { RequestAction } from '../request-action-implementation.js'
4
+ import { JsonResult } from '../request-action-implementation.js'
5
+ import { SchemaValidationError } from '../schema-validator/schema-validation-error.js'
6
6
 
7
7
  /**
8
8
  * Action for unhandled (500) errors
@@ -1,8 +1,8 @@
1
1
  import type { User } from '@furystack/core'
2
2
  import { getCurrentUser } from '@furystack/core'
3
- import { Authenticate } from '../authenticate'
4
- import type { RequestAction } from '../request-action-implementation'
5
- import { JsonResult } from '../request-action-implementation'
3
+ import { Authenticate } from '../authenticate.js'
4
+ import type { RequestAction } from '../request-action-implementation.js'
5
+ import { JsonResult } from '../request-action-implementation.js'
6
6
 
7
7
  /**
8
8
  * Action that returns the current authenticated user
@@ -1,6 +1,6 @@
1
- export * from './error-action'
2
- export * from './get-current-user'
3
- export * from './is-authenticated'
4
- export * from './login'
5
- export * from './logout'
6
- export * from './not-found-action'
1
+ export * from './error-action.js'
2
+ export * from './get-current-user.js'
3
+ export * from './is-authenticated.js'
4
+ export * from './login.js'
5
+ export * from './logout.js'
6
+ export * from './not-found-action.js'
@@ -1,6 +1,6 @@
1
1
  import { isAuthenticated } from '@furystack/core'
2
- import type { RequestAction } from '../request-action-implementation'
3
- import { JsonResult } from '../request-action-implementation'
2
+ import type { RequestAction } from '../request-action-implementation.js'
3
+ import { JsonResult } from '../request-action-implementation.js'
4
4
 
5
5
  /**
6
6
  * Action that returns if the current user is authenticated
@@ -1,9 +1,9 @@
1
- import { HttpUserContext } from '../http-user-context'
2
- import '../helpers'
1
+ import { HttpUserContext } from '../http-user-context.js'
2
+ import '../helpers.js'
3
3
  import type { User } from '@furystack/core'
4
4
  import { RequestError } from '@furystack/rest'
5
- import type { RequestAction } from '../request-action-implementation'
6
- import { JsonResult } from '../request-action-implementation'
5
+ import type { RequestAction } from '../request-action-implementation.js'
6
+ import { JsonResult } from '../request-action-implementation.js'
7
7
 
8
8
  /**
9
9
  * Action that logs in the current user
@@ -1,6 +1,6 @@
1
- import { HttpUserContext } from '../http-user-context'
2
- import type { RequestAction } from '../request-action-implementation'
3
- import { EmptyResult } from '../request-action-implementation'
1
+ import { HttpUserContext } from '../http-user-context.js'
2
+ import type { RequestAction } from '../request-action-implementation.js'
3
+ import { EmptyResult } from '../request-action-implementation.js'
4
4
 
5
5
  /**
6
6
  * Action that logs out the current user
@@ -1,5 +1,5 @@
1
- import type { RequestAction } from '../request-action-implementation'
2
- import { JsonResult } from '../request-action-implementation'
1
+ import type { RequestAction } from '../request-action-implementation.js'
2
+ import { JsonResult } from '../request-action-implementation.js'
3
3
 
4
4
  /**
5
5
  * @returns The standard Not Found action result
@@ -4,19 +4,20 @@ import type { Method, RestApi } from '@furystack/rest'
4
4
  import { deserializeQueryString } from '@furystack/rest'
5
5
  import type { Injector } from '@furystack/inject'
6
6
  import { Injectable, Injected } from '@furystack/inject'
7
- import type { OnRequest } from './server-manager'
8
- import { ServerManager } from './server-manager'
9
7
  import type { MatchFunction } from 'path-to-regexp'
10
8
  import { match } from 'path-to-regexp'
11
- import { NotFoundAction } from './actions/not-found-action'
12
- import type { CorsOptions } from './models/cors-options'
13
- import { Utils } from './utils'
14
- import { ErrorAction } from './actions/error-action'
15
- import './server-response-extensions'
16
9
  import type { User } from '@furystack/core'
17
10
  import { IdentityContext } from '@furystack/core'
18
- import { HttpUserContext } from './http-user-context'
19
- import type { RequestAction } from './request-action-implementation'
11
+
12
+ import type { OnRequest } from './server-manager.js'
13
+ import { ServerManager } from './server-manager.js'
14
+ import { NotFoundAction } from './actions/not-found-action.js'
15
+ import type { CorsOptions } from './models/cors-options.js'
16
+ import { Utils } from './utils.js'
17
+ import { ErrorAction } from './actions/error-action.js'
18
+ import './server-response-extensions.js'
19
+ import { HttpUserContext } from './http-user-context.js'
20
+ import type { RequestAction } from './request-action-implementation.js'
20
21
 
21
22
  export type RestApiImplementation<T extends RestApi> = {
22
23
  [TMethod in keyof T]: {
@@ -1,8 +1,8 @@
1
1
  import { isAuthenticated } from '@furystack/core'
2
2
  import { sleepAsync } from '@furystack/utils'
3
- import { HttpUserContext } from './http-user-context'
4
- import type { ActionResult, RequestAction, RequestActionOptions } from './request-action-implementation'
5
- import { JsonResult } from './request-action-implementation'
3
+ import { HttpUserContext } from './http-user-context.js'
4
+ import type { ActionResult, RequestAction, RequestActionOptions } from './request-action-implementation.js'
5
+ import { JsonResult } from './request-action-implementation.js'
6
6
 
7
7
  export const Authenticate =
8
8
  () =>
package/src/authorize.ts CHANGED
@@ -1,7 +1,7 @@
1
1
  import { isAuthorized } from '@furystack/core'
2
2
  import { sleepAsync } from '@furystack/utils'
3
- import type { ActionResult, RequestAction, RequestActionOptions } from './request-action-implementation'
4
- import { JsonResult } from './request-action-implementation'
3
+ import type { ActionResult, RequestAction, RequestActionOptions } from './request-action-implementation.js'
4
+ import { JsonResult } from './request-action-implementation.js'
5
5
 
6
6
  export const Authorize =
7
7
  (...roles: string[]) =>
@@ -1,8 +1,8 @@
1
1
  import type { Constructable } from '@furystack/inject'
2
2
  import type { DeleteEndpoint } from '@furystack/rest'
3
3
  import '@furystack/repository'
4
- import type { RequestAction } from '../request-action-implementation'
5
- import { JsonResult } from '../request-action-implementation'
4
+ import type { RequestAction } from '../request-action-implementation.js'
5
+ import { JsonResult } from '../request-action-implementation.js'
6
6
  import { getRepository } from '@furystack/repository'
7
7
 
8
8
  /**
@@ -1,8 +1,8 @@
1
1
  import type { Constructable } from '@furystack/inject'
2
2
  import type { GetCollectionEndpoint } from '@furystack/rest'
3
3
  import '@furystack/repository'
4
- import type { RequestAction } from '../request-action-implementation'
5
- import { JsonResult } from '../request-action-implementation'
4
+ import type { RequestAction } from '../request-action-implementation.js'
5
+ import { JsonResult } from '../request-action-implementation.js'
6
6
  import { getRepository } from '@furystack/repository'
7
7
 
8
8
  /**
@@ -2,8 +2,8 @@ import type { Constructable } from '@furystack/inject'
2
2
  import type { GetEntityEndpoint } from '@furystack/rest'
3
3
  import { RequestError } from '@furystack/rest'
4
4
  import '@furystack/repository'
5
- import type { RequestAction } from '../request-action-implementation'
6
- import { JsonResult } from '../request-action-implementation'
5
+ import type { RequestAction } from '../request-action-implementation.js'
6
+ import { JsonResult } from '../request-action-implementation.js'
7
7
  import { getRepository } from '@furystack/repository'
8
8
 
9
9
  /**
@@ -2,8 +2,8 @@ import type { Constructable } from '@furystack/inject'
2
2
  import type { PatchEndpoint } from '@furystack/rest'
3
3
  import '@furystack/repository'
4
4
  import '../incoming-message-extensions'
5
- import type { RequestAction } from '../request-action-implementation'
6
- import { JsonResult } from '../request-action-implementation'
5
+ import type { RequestAction } from '../request-action-implementation.js'
6
+ import { JsonResult } from '../request-action-implementation.js'
7
7
  import { getRepository } from '@furystack/repository'
8
8
  import type { WithOptionalId } from '@furystack/core'
9
9
 
@@ -3,8 +3,8 @@ import type { PostEndpoint } from '@furystack/rest'
3
3
  import { RequestError } from '@furystack/rest'
4
4
  import '@furystack/repository'
5
5
  import '../incoming-message-extensions'
6
- import type { RequestAction } from '../request-action-implementation'
7
- import { JsonResult } from '../request-action-implementation'
6
+ import type { RequestAction } from '../request-action-implementation.js'
7
+ import { JsonResult } from '../request-action-implementation.js'
8
8
  import type { WithOptionalId } from '@furystack/core'
9
9
  import { getRepository } from '@furystack/repository'
10
10
  /**
@@ -1,5 +1,5 @@
1
- export * from './create-delete-endpoint'
2
- export * from './create-get-collection-endpoint'
3
- export * from './create-get-entity-endpoint'
4
- export * from './create-patch-endpoint'
5
- export * from './create-post-endpoint'
1
+ export * from './create-delete-endpoint.js'
2
+ export * from './create-get-collection-endpoint.js'
3
+ export * from './create-get-entity-endpoint.js'
4
+ export * from './create-patch-endpoint.js'
5
+ export * from './create-post-endpoint.js'
@@ -1,6 +1,6 @@
1
1
  import type { Injector } from '@furystack/inject'
2
2
  import { addStore, InMemoryStore, User } from '@furystack/core'
3
- import { DefaultSession } from '../models/default-session'
3
+ import { DefaultSession } from '../models/default-session.js'
4
4
  import '@furystack/repository'
5
5
  import '../helpers'
6
6
  import { getRepository } from '@furystack/repository'
package/src/helpers.ts CHANGED
@@ -1,12 +1,12 @@
1
1
  import type { User } from '@furystack/core'
2
2
  import type { Injector } from '@furystack/inject'
3
- import { HttpAuthenticationSettings } from './http-authentication-settings'
3
+ import { HttpAuthenticationSettings } from './http-authentication-settings.js'
4
4
  import type { RestApi } from '@furystack/rest'
5
- import type { ImplementApiOptions } from './api-manager'
6
- import { ApiManager } from './api-manager'
7
- import type { DefaultSession } from './models/default-session'
8
- import type { StaticServerOptions } from './static-server-manager'
9
- import { StaticServerManager } from './static-server-manager'
5
+ import type { ImplementApiOptions } from './api-manager.js'
6
+ import { ApiManager } from './api-manager.js'
7
+ import type { DefaultSession } from './models/default-session.js'
8
+ import type { StaticServerOptions } from './static-server-manager.js'
9
+ import { StaticServerManager } from './static-server-manager.js'
10
10
 
11
11
  /**
12
12
  * Sets up the @furystack/rest-service with the provided settings
@@ -2,7 +2,7 @@ import type { PhysicalStore, StoreManager } from '@furystack/core'
2
2
  import { User } from '@furystack/core'
3
3
  import type { Constructable } from '@furystack/inject'
4
4
  import { Injectable } from '@furystack/inject'
5
- import { DefaultSession } from './models/default-session'
5
+ import { DefaultSession } from './models/default-session.js'
6
6
 
7
7
  /**
8
8
  * Authentication settings object for FuryStack HTTP Api
@@ -2,8 +2,8 @@ import type { IncomingMessage, ServerResponse } from 'http'
2
2
  import type { User } from '@furystack/core'
3
3
  import { StoreManager } from '@furystack/core'
4
4
  import { Injectable, Injected } from '@furystack/inject'
5
- import { HttpAuthenticationSettings } from './http-authentication-settings'
6
- import type { DefaultSession } from './models/default-session'
5
+ import { HttpAuthenticationSettings } from './http-authentication-settings.js'
6
+ import type { DefaultSession } from './models/default-session.js'
7
7
  import { PasswordAuthenticator, UnauthenticatedError } from '@furystack/security'
8
8
  import { randomBytes } from 'crypto'
9
9
 
@@ -1,5 +1,5 @@
1
1
  import http from 'http'
2
- import { Utils } from './utils'
2
+ import { Utils } from './utils.js'
3
3
 
4
4
  declare module 'http' {
5
5
  export interface IncomingMessage {
package/src/index.ts CHANGED
@@ -1,18 +1,18 @@
1
- export * from './helpers'
2
- export * from './api-manager'
3
- export * from './actions'
4
- export * from './authenticate'
5
- export * from './authorize'
6
- export * from './http-authentication-settings'
7
- export * from './http-user-context'
8
- export * from './incoming-message-extensions'
9
- export * from './server-manager'
10
- export * from './server-response-extensions'
11
- export * from './utils'
12
- export * from './models'
13
- export * from './endpoint-generators'
14
- export * from './schema-validator'
15
- export * from './request-action-implementation'
16
- export * from './validate'
17
- export * from './mime-types'
18
- export * from './static-server-manager'
1
+ export * from './helpers.js'
2
+ export * from './api-manager.js'
3
+ export * from './actions/index.js'
4
+ export * from './authenticate.js'
5
+ export * from './authorize.js'
6
+ export * from './http-authentication-settings.js'
7
+ export * from './http-user-context.js'
8
+ export * from './incoming-message-extensions.js'
9
+ export * from './server-manager.js'
10
+ export * from './server-response-extensions.js'
11
+ export * from './utils.js'
12
+ export * from './models/index.js'
13
+ export * from './endpoint-generators/index.js'
14
+ export * from './schema-validator/index.js'
15
+ export * from './request-action-implementation.js'
16
+ export * from './validate.js'
17
+ export * from './mime-types.js'
18
+ export * from './static-server-manager.js'
@@ -1,2 +1,2 @@
1
- export * from './cors-options'
2
- export * from './default-session'
1
+ export * from './cors-options.js'
2
+ export * from './default-session.js'
@@ -1,2 +1,2 @@
1
- export * from './schema-validator'
2
- export * from './schema-validation-error'
1
+ export * from './schema-validator.js'
2
+ export * from './schema-validation-error.js'
@@ -1,15 +1,15 @@
1
1
  import type { ErrorObject, Options } from 'ajv'
2
2
  import Ajv from 'ajv'
3
3
  import useFormats from 'ajv-formats'
4
- import { SchemaValidationError } from './schema-validation-error'
4
+ import { SchemaValidationError } from './schema-validation-error.js'
5
5
 
6
6
  export class SchemaValidator<TSchema extends { definitions: {} }> {
7
- private readonly ajv = new Ajv({
7
+ private readonly ajv = new Ajv.default({
8
8
  allErrors: true,
9
9
  ...this.ajvOptions,
10
10
  })
11
11
  constructor(private readonly schema: TSchema, private readonly ajvOptions?: Options) {
12
- useFormats(this.ajv)
12
+ useFormats.default(this.ajv)
13
13
  }
14
14
 
15
15
  /**
@@ -1,5 +1,5 @@
1
1
  import http from 'http'
2
- import type { ActionResult } from './request-action-implementation'
2
+ import type { ActionResult } from './request-action-implementation.js'
3
3
 
4
4
  export interface SendJsonOptions<T> {
5
5
  statusCode?: number
@@ -2,9 +2,9 @@ import { Injectable, Injected } from '@furystack/inject'
2
2
  import { createReadStream } from 'fs'
3
3
  import { stat } from 'fs/promises'
4
4
  import type { IncomingMessage, OutgoingHttpHeaders, ServerResponse } from 'http'
5
- import { getMimeForFile } from './mime-types'
5
+ import { getMimeForFile } from './mime-types.js'
6
6
  import { join, normalize, sep } from 'path'
7
- import { ServerManager } from './server-manager'
7
+ import { ServerManager } from './server-manager.js'
8
8
 
9
9
  export interface StaticServerOptions {
10
10
  baseUrl: string
package/src/utils.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  import type { IncomingMessage, ServerResponse } from 'http'
2
2
  import { Injectable } from '@furystack/inject'
3
- import type { CorsOptions } from './models/cors-options'
3
+ import type { CorsOptions } from './models/cors-options.js'
4
4
 
5
5
  /**
6
6
  * A collection of various HTTP API related utilities
package/src/validate.ts CHANGED
@@ -1,5 +1,5 @@
1
- import type { ActionResult, RequestAction, RequestActionOptions } from './request-action-implementation'
2
- import { SchemaValidator } from './schema-validator'
1
+ import type { ActionResult, RequestAction, RequestActionOptions } from './request-action-implementation.js'
2
+ import { SchemaValidator } from './schema-validator/schema-validator.js'
3
3
 
4
4
  export const Validate =
5
5
  <TSchema extends { definitions: { [K: string]: { required?: string[] } | any } }>(validationOptions: {
@@ -1,7 +0,0 @@
1
- export * from './error-action';
2
- export * from './get-current-user';
3
- export * from './is-authenticated';
4
- export * from './login';
5
- export * from './logout';
6
- export * from './not-found-action';
7
- //# sourceMappingURL=index.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/actions/index.ts"],"names":[],"mappings":"AAAA,cAAc,gBAAgB,CAAA;AAC9B,cAAc,oBAAoB,CAAA;AAClC,cAAc,oBAAoB,CAAA;AAClC,cAAc,SAAS,CAAA;AACvB,cAAc,UAAU,CAAA;AACxB,cAAc,oBAAoB,CAAA"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"login.d.ts","sourceRoot":"","sources":["../../src/actions/login.ts"],"names":[],"mappings":"AACA,OAAO,YAAY,CAAA;AACnB,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,iBAAiB,CAAA;AAE3C,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,kCAAkC,CAAA;AAGrE;;;;GAIG;AAEH,eAAO,MAAM,WAAW,EAAE,aAAa,CAAC;IACtC,MAAM,EAAE,IAAI,CAAA;IACZ,IAAI,EAAE;QAAE,QAAQ,EAAE,MAAM,CAAC;QAAC,QAAQ,EAAE,MAAM,CAAA;KAAE,CAAA;CAC7C,CAUA,CAAA"}
@@ -1,6 +0,0 @@
1
- export * from './create-delete-endpoint';
2
- export * from './create-get-collection-endpoint';
3
- export * from './create-get-entity-endpoint';
4
- export * from './create-patch-endpoint';
5
- export * from './create-post-endpoint';
6
- //# sourceMappingURL=index.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"helpers.d.ts","sourceRoot":"","sources":["../src/helpers.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,iBAAiB,CAAA;AAC3C,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAA;AACjD,OAAO,EAAE,0BAA0B,EAAE,MAAM,gCAAgC,CAAA;AAC3E,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,iBAAiB,CAAA;AAC9C,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,eAAe,CAAA;AAExD,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,0BAA0B,CAAA;AAC9D,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,yBAAyB,CAAA;AAGlE;;;;GAIG;AACH,eAAO,MAAM,cAAc,mEACoC,CAAA;AAE/D;;;;;GAKG;AACH,eAAO,MAAM,qBAAqB,kEACtB,QAAQ,sFAE+F,CAAA;AAEnH;;;;;;GAMG;AACH,eAAO,MAAM,cAAc,YAAa;IAAE,QAAQ,EAAE,QAAQ,CAAA;CAAE,GAAG,mBAAmB,kBAGnF,CAAA"}
package/types/index.d.ts DELETED
@@ -1,19 +0,0 @@
1
- export * from './helpers';
2
- export * from './api-manager';
3
- export * from './actions';
4
- export * from './authenticate';
5
- export * from './authorize';
6
- export * from './http-authentication-settings';
7
- export * from './http-user-context';
8
- export * from './incoming-message-extensions';
9
- export * from './server-manager';
10
- export * from './server-response-extensions';
11
- export * from './utils';
12
- export * from './models';
13
- export * from './endpoint-generators';
14
- export * from './schema-validator';
15
- export * from './request-action-implementation';
16
- export * from './validate';
17
- export * from './mime-types';
18
- export * from './static-server-manager';
19
- //# sourceMappingURL=index.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,WAAW,CAAA;AACzB,cAAc,eAAe,CAAA;AAC7B,cAAc,WAAW,CAAA;AACzB,cAAc,gBAAgB,CAAA;AAC9B,cAAc,aAAa,CAAA;AAC3B,cAAc,gCAAgC,CAAA;AAC9C,cAAc,qBAAqB,CAAA;AACnC,cAAc,+BAA+B,CAAA;AAC7C,cAAc,kBAAkB,CAAA;AAChC,cAAc,8BAA8B,CAAA;AAC5C,cAAc,SAAS,CAAA;AACvB,cAAc,UAAU,CAAA;AACxB,cAAc,uBAAuB,CAAA;AACrC,cAAc,oBAAoB,CAAA;AAClC,cAAc,iCAAiC,CAAA;AAC/C,cAAc,YAAY,CAAA;AAC1B,cAAc,cAAc,CAAA;AAC5B,cAAc,yBAAyB,CAAA"}
@@ -1,3 +0,0 @@
1
- export * from './cors-options';
2
- export * from './default-session';
3
- //# sourceMappingURL=index.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/models/index.ts"],"names":[],"mappings":"AAAA,cAAc,gBAAgB,CAAA;AAC9B,cAAc,mBAAmB,CAAA"}
@@ -1,3 +0,0 @@
1
- export * from './schema-validator';
2
- export * from './schema-validation-error';
3
- //# sourceMappingURL=index.d.ts.map
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes