@furystack/rest-service 13.0.0 → 14.1.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.
- package/CHANGELOG.md +124 -0
- package/README.md +47 -28
- package/esm/actions/error-action.d.ts +7 -2
- package/esm/actions/error-action.d.ts.map +1 -1
- package/esm/actions/error-action.js +7 -2
- package/esm/actions/error-action.js.map +1 -1
- package/esm/actions/get-current-user.d.ts +1 -4
- package/esm/actions/get-current-user.d.ts.map +1 -1
- package/esm/actions/get-current-user.js +1 -4
- package/esm/actions/get-current-user.js.map +1 -1
- package/esm/actions/get-current-user.spec.js +10 -6
- package/esm/actions/get-current-user.spec.js.map +1 -1
- package/esm/actions/is-authenticated.d.ts +3 -4
- package/esm/actions/is-authenticated.d.ts.map +1 -1
- package/esm/actions/is-authenticated.js +3 -4
- package/esm/actions/is-authenticated.js.map +1 -1
- package/esm/actions/is-authenticated.spec.js +10 -6
- package/esm/actions/is-authenticated.spec.js.map +1 -1
- package/esm/actions/logout-action.spec.js +11 -9
- package/esm/actions/logout-action.spec.js.map +1 -1
- package/esm/actions/logout.d.ts +2 -6
- package/esm/actions/logout.d.ts.map +1 -1
- package/esm/actions/logout.js +3 -7
- package/esm/actions/logout.js.map +1 -1
- package/esm/actions/not-found-action.d.ts +1 -3
- package/esm/actions/not-found-action.d.ts.map +1 -1
- package/esm/actions/not-found-action.js +1 -3
- package/esm/actions/not-found-action.js.map +1 -1
- package/esm/actions/password-login-action.d.ts +5 -12
- package/esm/actions/password-login-action.d.ts.map +1 -1
- package/esm/actions/password-login-action.js +6 -13
- package/esm/actions/password-login-action.js.map +1 -1
- package/esm/actions/password-login-action.spec.js +23 -28
- package/esm/actions/password-login-action.spec.js.map +1 -1
- package/esm/authenticate.d.ts +5 -11
- package/esm/authenticate.d.ts.map +1 -1
- package/esm/authenticate.js +6 -12
- package/esm/authenticate.js.map +1 -1
- package/esm/authenticate.spec.js +41 -33
- package/esm/authenticate.spec.js.map +1 -1
- package/esm/authentication-providers/authentication-provider.d.ts +17 -0
- package/esm/authentication-providers/authentication-provider.d.ts.map +1 -1
- package/esm/authentication-providers/basic-auth-provider.d.ts +7 -0
- package/esm/authentication-providers/basic-auth-provider.d.ts.map +1 -1
- package/esm/authentication-providers/basic-auth-provider.js +7 -0
- package/esm/authentication-providers/basic-auth-provider.js.map +1 -1
- package/esm/authentication-providers/cookie-auth-provider.d.ts.map +1 -1
- package/esm/authentication-providers/cookie-auth-provider.js +8 -0
- package/esm/authentication-providers/cookie-auth-provider.js.map +1 -1
- package/esm/authorize.d.ts +5 -17
- package/esm/authorize.d.ts.map +1 -1
- package/esm/authorize.js +5 -17
- package/esm/authorize.js.map +1 -1
- package/esm/authorize.spec.js +34 -29
- package/esm/authorize.spec.js.map +1 -1
- package/esm/endpoint-generators/create-delete-endpoint.d.ts +6 -11
- package/esm/endpoint-generators/create-delete-endpoint.d.ts.map +1 -1
- package/esm/endpoint-generators/create-delete-endpoint.js +7 -11
- package/esm/endpoint-generators/create-delete-endpoint.js.map +1 -1
- package/esm/endpoint-generators/create-delete-endpoint.spec.js +14 -21
- package/esm/endpoint-generators/create-delete-endpoint.spec.js.map +1 -1
- package/esm/endpoint-generators/create-get-collection-endpoint.d.ts +11 -11
- package/esm/endpoint-generators/create-get-collection-endpoint.d.ts.map +1 -1
- package/esm/endpoint-generators/create-get-collection-endpoint.js +13 -12
- package/esm/endpoint-generators/create-get-collection-endpoint.js.map +1 -1
- package/esm/endpoint-generators/create-get-collection-endpoint.spec.js +43 -70
- package/esm/endpoint-generators/create-get-collection-endpoint.spec.js.map +1 -1
- package/esm/endpoint-generators/create-get-entity-endpoint.d.ts +6 -11
- package/esm/endpoint-generators/create-get-entity-endpoint.d.ts.map +1 -1
- package/esm/endpoint-generators/create-get-entity-endpoint.js +7 -11
- package/esm/endpoint-generators/create-get-entity-endpoint.js.map +1 -1
- package/esm/endpoint-generators/create-get-entity-endpoint.spec.js +16 -33
- package/esm/endpoint-generators/create-get-entity-endpoint.spec.js.map +1 -1
- package/esm/endpoint-generators/create-get-openapi-document-action.d.ts +1 -1
- package/esm/endpoint-generators/create-get-openapi-document-action.d.ts.map +1 -1
- package/esm/endpoint-generators/create-get-openapi-document-action.js +1 -1
- package/esm/endpoint-generators/create-get-openapi-document-action.js.map +1 -1
- package/esm/endpoint-generators/create-get-schema-action.d.ts +1 -1
- package/esm/endpoint-generators/create-get-schema-action.d.ts.map +1 -1
- package/esm/endpoint-generators/create-get-schema-action.js.map +1 -1
- package/esm/endpoint-generators/create-patch-endpoint.d.ts +7 -13
- package/esm/endpoint-generators/create-patch-endpoint.d.ts.map +1 -1
- package/esm/endpoint-generators/create-patch-endpoint.js +8 -13
- package/esm/endpoint-generators/create-patch-endpoint.js.map +1 -1
- package/esm/endpoint-generators/create-patch-endpoint.spec.js +10 -17
- package/esm/endpoint-generators/create-patch-endpoint.spec.js.map +1 -1
- package/esm/endpoint-generators/create-post-endpoint.d.ts +7 -13
- package/esm/endpoint-generators/create-post-endpoint.d.ts.map +1 -1
- package/esm/endpoint-generators/create-post-endpoint.js +8 -13
- package/esm/endpoint-generators/create-post-endpoint.js.map +1 -1
- package/esm/endpoint-generators/create-post-endpoint.spec.js +41 -14
- package/esm/endpoint-generators/create-post-endpoint.spec.js.map +1 -1
- package/esm/endpoint-generators/utils.d.ts +17 -2
- package/esm/endpoint-generators/utils.d.ts.map +1 -1
- package/esm/endpoint-generators/utils.js +33 -20
- package/esm/endpoint-generators/utils.js.map +1 -1
- package/esm/get-schema-from-api.d.ts +1 -1
- package/esm/get-schema-from-api.d.ts.map +1 -1
- package/esm/get-schema-from-api.js +1 -0
- package/esm/get-schema-from-api.js.map +1 -1
- package/esm/get-schema-from-api.spec.js.map +1 -1
- package/esm/helpers.d.ts +54 -88
- package/esm/helpers.d.ts.map +1 -1
- package/esm/helpers.js +90 -92
- package/esm/helpers.js.map +1 -1
- package/esm/helpers.spec.d.ts +2 -1
- package/esm/helpers.spec.d.ts.map +1 -1
- package/esm/helpers.spec.js +41 -38
- package/esm/helpers.spec.js.map +1 -1
- package/esm/http-authentication-settings.d.ts +56 -12
- package/esm/http-authentication-settings.d.ts.map +1 -1
- package/esm/http-authentication-settings.js +27 -29
- package/esm/http-authentication-settings.js.map +1 -1
- package/esm/http-server-pool.d.ts +64 -0
- package/esm/http-server-pool.d.ts.map +1 -0
- package/esm/http-server-pool.js +95 -0
- package/esm/http-server-pool.js.map +1 -0
- package/esm/http-server-pool.spec.d.ts +2 -0
- package/esm/http-server-pool.spec.d.ts.map +1 -0
- package/esm/http-server-pool.spec.js +193 -0
- package/esm/http-server-pool.spec.js.map +1 -0
- package/esm/http-user-context.d.ts +34 -44
- package/esm/http-user-context.d.ts.map +1 -1
- package/esm/http-user-context.js +75 -95
- package/esm/http-user-context.js.map +1 -1
- package/esm/http-user-context.spec.d.ts +8 -2
- package/esm/http-user-context.spec.d.ts.map +1 -1
- package/esm/http-user-context.spec.js +226 -332
- package/esm/http-user-context.spec.js.map +1 -1
- package/esm/identity-cache-keys.d.ts +28 -0
- package/esm/identity-cache-keys.d.ts.map +1 -0
- package/esm/identity-cache-keys.js +13 -0
- package/esm/identity-cache-keys.js.map +1 -0
- package/esm/identity-cache-keys.spec.d.ts +2 -0
- package/esm/identity-cache-keys.spec.d.ts.map +1 -0
- package/esm/identity-cache-keys.spec.js +21 -0
- package/esm/identity-cache-keys.spec.js.map +1 -0
- package/esm/identity-event-bus.d.ts +102 -0
- package/esm/identity-event-bus.d.ts.map +1 -0
- package/esm/identity-event-bus.js +151 -0
- package/esm/identity-event-bus.js.map +1 -0
- package/esm/identity-event-bus.spec.d.ts +2 -0
- package/esm/identity-event-bus.spec.d.ts.map +1 -0
- package/esm/identity-event-bus.spec.js +392 -0
- package/esm/identity-event-bus.spec.js.map +1 -0
- package/esm/index.d.ts +9 -4
- package/esm/index.d.ts.map +1 -1
- package/esm/index.js +9 -4
- package/esm/index.js.map +1 -1
- package/esm/login-response-strategy.d.ts +11 -10
- package/esm/login-response-strategy.d.ts.map +1 -1
- package/esm/login-response-strategy.js +7 -6
- package/esm/login-response-strategy.js.map +1 -1
- package/esm/login-response-strategy.spec.js +25 -29
- package/esm/login-response-strategy.spec.js.map +1 -1
- package/esm/openapi/generate-openapi-document.spec.js.map +1 -1
- package/esm/proxy-manager.spec.js +152 -176
- package/esm/proxy-manager.spec.js.map +1 -1
- package/esm/proxy-runtime.d.ts +27 -0
- package/esm/proxy-runtime.d.ts.map +1 -0
- package/esm/proxy-runtime.js +45 -0
- package/esm/proxy-runtime.js.map +1 -0
- package/esm/proxy-runtime.spec.d.ts +2 -0
- package/esm/proxy-runtime.spec.d.ts.map +1 -0
- package/esm/proxy-runtime.spec.js +39 -0
- package/esm/proxy-runtime.spec.js.map +1 -0
- package/esm/request-action-implementation.d.ts +25 -0
- package/esm/request-action-implementation.d.ts.map +1 -1
- package/esm/request-action-implementation.js +9 -0
- package/esm/request-action-implementation.js.map +1 -1
- package/esm/rest-api-runtime.d.ts +76 -0
- package/esm/rest-api-runtime.d.ts.map +1 -0
- package/esm/rest-api-runtime.js +131 -0
- package/esm/rest-api-runtime.js.map +1 -0
- package/esm/rest-api-runtime.spec.d.ts +2 -0
- package/esm/rest-api-runtime.spec.d.ts.map +1 -0
- package/esm/rest-api-runtime.spec.js +58 -0
- package/esm/rest-api-runtime.spec.js.map +1 -0
- package/esm/rest-service.integration.spec.d.ts +1 -1
- package/esm/rest-service.integration.spec.d.ts.map +1 -1
- package/esm/rest-service.integration.spec.js +57 -80
- package/esm/rest-service.integration.spec.js.map +1 -1
- package/esm/rest.integration.test.js +26 -84
- package/esm/rest.integration.test.js.map +1 -1
- package/esm/server-telemetry.d.ts +49 -0
- package/esm/server-telemetry.d.ts.map +1 -0
- package/esm/server-telemetry.js +25 -0
- package/esm/server-telemetry.js.map +1 -0
- package/esm/server-telemetry.spec.d.ts +2 -0
- package/esm/server-telemetry.spec.d.ts.map +1 -0
- package/esm/server-telemetry.spec.js +52 -0
- package/esm/server-telemetry.spec.js.map +1 -0
- package/esm/static-server-manager.spec.js +60 -125
- package/esm/static-server-manager.spec.js.map +1 -1
- package/esm/static-site-runtime.d.ts +21 -0
- package/esm/static-site-runtime.d.ts.map +1 -0
- package/esm/static-site-runtime.js +48 -0
- package/esm/static-site-runtime.js.map +1 -0
- package/esm/static-site-runtime.spec.d.ts +2 -0
- package/esm/static-site-runtime.spec.d.ts.map +1 -0
- package/esm/static-site-runtime.spec.js +30 -0
- package/esm/static-site-runtime.spec.js.map +1 -0
- package/esm/user-resolution-cache.d.ts +65 -0
- package/esm/user-resolution-cache.d.ts.map +1 -0
- package/esm/user-resolution-cache.js +101 -0
- package/esm/user-resolution-cache.js.map +1 -0
- package/esm/user-resolution-cache.spec.d.ts +2 -0
- package/esm/user-resolution-cache.spec.d.ts.map +1 -0
- package/esm/user-resolution-cache.spec.js +220 -0
- package/esm/user-resolution-cache.spec.js.map +1 -0
- package/esm/user-store.d.ts +39 -0
- package/esm/user-store.d.ts.map +1 -0
- package/esm/user-store.js +62 -0
- package/esm/user-store.js.map +1 -0
- package/esm/user-store.spec.d.ts +2 -0
- package/esm/user-store.spec.d.ts.map +1 -0
- package/esm/user-store.spec.js +72 -0
- package/esm/user-store.spec.js.map +1 -0
- package/esm/validate.d.ts +13 -12
- package/esm/validate.d.ts.map +1 -1
- package/esm/validate.integration.spec.js +27 -28
- package/esm/validate.integration.spec.js.map +1 -1
- package/esm/validate.js +12 -0
- package/esm/validate.js.map +1 -1
- package/package.json +14 -12
- package/src/actions/error-action.ts +7 -3
- package/src/actions/get-current-user.spec.ts +11 -10
- package/src/actions/get-current-user.ts +1 -4
- package/src/actions/is-authenticated.spec.ts +12 -7
- package/src/actions/is-authenticated.ts +3 -4
- package/src/actions/logout-action.spec.ts +12 -12
- package/src/actions/logout.ts +3 -7
- package/src/actions/not-found-action.ts +1 -3
- package/src/actions/password-login-action.spec.ts +30 -30
- package/src/actions/password-login-action.ts +6 -13
- package/src/authenticate.spec.ts +45 -51
- package/src/authenticate.ts +6 -12
- package/src/authentication-providers/authentication-provider.ts +17 -0
- package/src/authentication-providers/basic-auth-provider.ts +7 -0
- package/src/authentication-providers/cookie-auth-provider.ts +8 -0
- package/src/authorize.spec.ts +37 -39
- package/src/authorize.ts +6 -17
- package/src/endpoint-generators/create-delete-endpoint.spec.ts +16 -24
- package/src/endpoint-generators/create-delete-endpoint.ts +11 -17
- package/src/endpoint-generators/create-get-collection-endpoint.spec.ts +45 -78
- package/src/endpoint-generators/create-get-collection-endpoint.ts +17 -19
- package/src/endpoint-generators/create-get-entity-endpoint.spec.ts +17 -33
- package/src/endpoint-generators/create-get-entity-endpoint.ts +11 -17
- package/src/endpoint-generators/create-get-openapi-document-action.ts +2 -2
- package/src/endpoint-generators/create-get-schema-action.ts +1 -1
- package/src/endpoint-generators/create-patch-endpoint.spec.ts +11 -18
- package/src/endpoint-generators/create-patch-endpoint.ts +12 -23
- package/src/endpoint-generators/create-post-endpoint.spec.ts +45 -14
- package/src/endpoint-generators/create-post-endpoint.ts +13 -23
- package/src/endpoint-generators/utils.ts +36 -28
- package/src/get-schema-from-api.spec.ts +1 -1
- package/src/get-schema-from-api.ts +2 -1
- package/src/helpers.spec.ts +51 -41
- package/src/helpers.ts +140 -109
- package/src/http-authentication-settings.ts +78 -24
- package/src/http-server-pool.spec.ts +220 -0
- package/src/http-server-pool.ts +169 -0
- package/src/http-user-context.spec.ts +246 -378
- package/src/http-user-context.ts +122 -92
- package/src/identity-cache-keys.spec.ts +24 -0
- package/src/identity-cache-keys.ts +31 -0
- package/src/identity-event-bus.spec.ts +285 -0
- package/src/identity-event-bus.ts +230 -0
- package/src/index.ts +9 -4
- package/src/login-response-strategy.spec.ts +32 -31
- package/src/login-response-strategy.ts +14 -12
- package/src/openapi/generate-openapi-document.spec.ts +2 -2
- package/src/proxy-manager.spec.ts +158 -188
- package/src/proxy-runtime.spec.ts +50 -0
- package/src/proxy-runtime.ts +75 -0
- package/src/request-action-implementation.ts +25 -0
- package/src/rest-api-runtime.spec.ts +77 -0
- package/src/rest-api-runtime.ts +204 -0
- package/src/rest-service.integration.spec.ts +65 -85
- package/src/rest.integration.test.ts +27 -87
- package/src/server-telemetry.spec.ts +56 -0
- package/src/server-telemetry.ts +43 -0
- package/src/static-server-manager.spec.ts +63 -151
- package/src/static-site-runtime.spec.ts +39 -0
- package/src/static-site-runtime.ts +75 -0
- package/src/user-resolution-cache.spec.ts +241 -0
- package/src/user-resolution-cache.ts +164 -0
- package/src/user-store.spec.ts +86 -0
- package/src/user-store.ts +69 -0
- package/src/validate.integration.spec.ts +40 -35
- package/src/validate.ts +14 -12
- package/esm/api-manager.d.ts +0 -104
- package/esm/api-manager.d.ts.map +0 -1
- package/esm/api-manager.js +0 -179
- package/esm/api-manager.js.map +0 -1
- package/esm/proxy-manager.d.ts +0 -53
- package/esm/proxy-manager.d.ts.map +0 -1
- package/esm/proxy-manager.js +0 -84
- package/esm/proxy-manager.js.map +0 -1
- package/esm/server-manager.d.ts +0 -48
- package/esm/server-manager.d.ts.map +0 -1
- package/esm/server-manager.js +0 -100
- package/esm/server-manager.js.map +0 -1
- package/esm/static-server-manager.d.ts +0 -19
- package/esm/static-server-manager.d.ts.map +0 -1
- package/esm/static-server-manager.js +0 -65
- package/esm/static-server-manager.js.map +0 -1
- package/src/api-manager.ts +0 -304
- package/src/proxy-manager.ts +0 -102
- package/src/server-manager.ts +0 -135
- package/src/static-server-manager.ts +0 -90
|
@@ -1,24 +1,20 @@
|
|
|
1
1
|
import { RequestError } from '@furystack/rest';
|
|
2
2
|
import { JsonResult } from '../request-action-implementation.js';
|
|
3
|
-
import { getRepository } from '@furystack/repository';
|
|
4
3
|
/**
|
|
5
|
-
* Creates a
|
|
6
|
-
* @
|
|
7
|
-
*
|
|
8
|
-
* @param options.primaryKey The field name used as primary key on the model
|
|
9
|
-
* @returns The generated endpoint
|
|
4
|
+
* Creates a GET entity endpoint backed by the DataSet resolved from the
|
|
5
|
+
* provided {@link DataSetToken}. Throws a 404 `RequestError` when the
|
|
6
|
+
* entity cannot be found.
|
|
10
7
|
*/
|
|
11
|
-
export const createGetEntityEndpoint = (
|
|
12
|
-
|
|
8
|
+
export const createGetEntityEndpoint = (dataSet) => {
|
|
9
|
+
return async ({ injector, getUrlParams, getQuery }) => {
|
|
13
10
|
const { id } = getUrlParams();
|
|
14
11
|
const { select } = getQuery();
|
|
15
|
-
const
|
|
16
|
-
const entry = await
|
|
12
|
+
const ds = injector.get(dataSet);
|
|
13
|
+
const entry = await ds.get(injector, id, select);
|
|
17
14
|
if (!entry) {
|
|
18
15
|
throw new RequestError('Entity not found', 404);
|
|
19
16
|
}
|
|
20
17
|
return JsonResult(entry);
|
|
21
18
|
};
|
|
22
|
-
return endpoint;
|
|
23
19
|
};
|
|
24
20
|
//# sourceMappingURL=create-get-entity-endpoint.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"create-get-entity-endpoint.js","sourceRoot":"","sources":["../../src/endpoint-generators/create-get-entity-endpoint.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAA;
|
|
1
|
+
{"version":3,"file":"create-get-entity-endpoint.js","sourceRoot":"","sources":["../../src/endpoint-generators/create-get-entity-endpoint.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAA;AAC9C,OAAO,EAAE,UAAU,EAAsB,MAAM,qCAAqC,CAAA;AAEpF;;;;GAIG;AACH,MAAM,CAAC,MAAM,uBAAuB,GAAG,CACrC,OAAqC,EACa,EAAE;IACpD,OAAO,KAAK,EAAE,EAAE,QAAQ,EAAE,YAAY,EAAE,QAAQ,EAAE,EAAE,EAAE;QACpD,MAAM,EAAE,EAAE,EAAE,GAAG,YAAY,EAAE,CAAA;QAC7B,MAAM,EAAE,MAAM,EAAE,GAAG,QAAQ,EAAE,CAAA;QAC7B,MAAM,EAAE,GAAG,QAAQ,CAAC,GAAG,CAAC,OAAO,CAAC,CAAA;QAChC,MAAM,KAAK,GAAG,MAAM,EAAE,CAAC,GAAG,CAAC,QAAQ,EAAE,EAAE,EAAE,MAAM,CAAC,CAAA;QAChD,IAAI,CAAC,KAAK,EAAE,CAAC;YACX,MAAM,IAAI,YAAY,CAAC,kBAAkB,EAAE,GAAG,CAAC,CAAA;QACjD,CAAC;QACD,OAAO,UAAU,CAAC,KAAK,CAAC,CAAA;IAC1B,CAAC,CAAA;AACH,CAAC,CAAA"}
|
|
@@ -1,77 +1,60 @@
|
|
|
1
1
|
import { getPort } from '@furystack/core/port-generator';
|
|
2
|
-
import {
|
|
3
|
-
import { getDataSetFor } from '@furystack/repository';
|
|
2
|
+
import { createInjector } from '@furystack/inject';
|
|
4
3
|
import { serializeToQueryString } from '@furystack/rest';
|
|
5
4
|
import { usingAsync } from '@furystack/utils';
|
|
6
5
|
import { describe, expect, it } from 'vitest';
|
|
7
6
|
import { useRestService } from '../helpers.js';
|
|
8
7
|
import { createGetEntityEndpoint } from './create-get-entity-endpoint.js';
|
|
9
|
-
import {
|
|
8
|
+
import { MockDataSet, setupContext } from './utils.js';
|
|
10
9
|
describe('createGetEntityEndpoint', () => {
|
|
11
|
-
it('
|
|
12
|
-
await usingAsync(
|
|
10
|
+
it('returns the entity by id', async () => {
|
|
11
|
+
await usingAsync(createInjector(), async (i) => {
|
|
13
12
|
setupContext(i);
|
|
14
13
|
const port = getPort();
|
|
15
14
|
await useRestService({
|
|
16
15
|
injector: i,
|
|
17
16
|
root: '/api',
|
|
18
17
|
port,
|
|
19
|
-
api: {
|
|
20
|
-
GET: {
|
|
21
|
-
'/:id': createGetEntityEndpoint({ model: MockClass, primaryKey: 'id' }),
|
|
22
|
-
},
|
|
23
|
-
},
|
|
18
|
+
api: { GET: { '/:id': createGetEntityEndpoint(MockDataSet) } },
|
|
24
19
|
});
|
|
25
20
|
const mockEntity = { id: 'mock', value: 'mock' };
|
|
26
|
-
await
|
|
21
|
+
await i.get(MockDataSet).add(i, mockEntity);
|
|
27
22
|
const response = await fetch(`http://127.0.0.1:${port}/api/mock`, { method: 'GET' });
|
|
28
23
|
expect(response.status).toBe(200);
|
|
29
|
-
|
|
30
|
-
expect(body).toEqual(mockEntity);
|
|
24
|
+
expect(await response.json()).toEqual(mockEntity);
|
|
31
25
|
});
|
|
32
26
|
});
|
|
33
|
-
it('
|
|
34
|
-
await usingAsync(
|
|
27
|
+
it('honours a select query parameter', async () => {
|
|
28
|
+
await usingAsync(createInjector(), async (i) => {
|
|
35
29
|
setupContext(i);
|
|
36
30
|
const port = getPort();
|
|
37
31
|
await useRestService({
|
|
38
32
|
injector: i,
|
|
39
33
|
root: '/api',
|
|
40
34
|
port,
|
|
41
|
-
api: {
|
|
42
|
-
GET: {
|
|
43
|
-
'/:id': createGetEntityEndpoint({ model: MockClass, primaryKey: 'id' }),
|
|
44
|
-
},
|
|
45
|
-
},
|
|
35
|
+
api: { GET: { '/:id': createGetEntityEndpoint(MockDataSet) } },
|
|
46
36
|
});
|
|
47
|
-
|
|
48
|
-
await getDataSetFor(i, MockClass, 'id').add(i, mockEntity);
|
|
37
|
+
await i.get(MockDataSet).add(i, { id: 'mock', value: 'mock' });
|
|
49
38
|
const response = await fetch(`http://127.0.0.1:${port}/api/mock?${serializeToQueryString({ select: ['id'] })}`, {
|
|
50
39
|
method: 'GET',
|
|
51
40
|
});
|
|
52
41
|
expect(response.status).toBe(200);
|
|
53
|
-
|
|
54
|
-
expect(body).toEqual({ id: mockEntity.id });
|
|
42
|
+
expect(await response.json()).toEqual({ id: 'mock' });
|
|
55
43
|
});
|
|
56
44
|
});
|
|
57
|
-
it('
|
|
58
|
-
await usingAsync(
|
|
45
|
+
it('responds with 404 when the entity does not exist', async () => {
|
|
46
|
+
await usingAsync(createInjector(), async (i) => {
|
|
59
47
|
setupContext(i);
|
|
60
48
|
const port = getPort();
|
|
61
49
|
await useRestService({
|
|
62
50
|
injector: i,
|
|
63
51
|
root: '/api',
|
|
64
52
|
port,
|
|
65
|
-
api: {
|
|
66
|
-
GET: {
|
|
67
|
-
'/:id': createGetEntityEndpoint({ model: MockClass, primaryKey: 'id' }),
|
|
68
|
-
},
|
|
69
|
-
},
|
|
53
|
+
api: { GET: { '/:id': createGetEntityEndpoint(MockDataSet) } },
|
|
70
54
|
});
|
|
71
55
|
const result = await fetch(`http://127.0.0.1:${port}/api/mock`, { method: 'GET' });
|
|
72
56
|
expect(result.status).toBe(404);
|
|
73
|
-
|
|
74
|
-
expect(body).toEqual({ message: 'Entity not found' });
|
|
57
|
+
expect(await result.json()).toEqual({ message: 'Entity not found' });
|
|
75
58
|
});
|
|
76
59
|
});
|
|
77
60
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"create-get-entity-endpoint.spec.js","sourceRoot":"","sources":["../../src/endpoint-generators/create-get-entity-endpoint.spec.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,gCAAgC,CAAA;AACxD,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"create-get-entity-endpoint.spec.js","sourceRoot":"","sources":["../../src/endpoint-generators/create-get-entity-endpoint.spec.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,gCAAgC,CAAA;AACxD,OAAO,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAA;AAElD,OAAO,EAAE,sBAAsB,EAAE,MAAM,iBAAiB,CAAA;AACxD,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAA;AAC7C,OAAO,EAAE,QAAQ,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,QAAQ,CAAA;AAC7C,OAAO,EAAE,cAAc,EAAE,MAAM,eAAe,CAAA;AAC9C,OAAO,EAAE,uBAAuB,EAAE,MAAM,iCAAiC,CAAA;AAEzE,OAAO,EAAE,WAAW,EAAE,YAAY,EAAE,MAAM,YAAY,CAAA;AAEtD,QAAQ,CAAC,yBAAyB,EAAE,GAAG,EAAE;IACvC,EAAE,CAAC,0BAA0B,EAAE,KAAK,IAAI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AAM,CAAC,IAAI,EAAE,CAAC,CAAC,OAAO,CAAC,EAAE,OAAO,EAAE,kBAAkB,EAAE,CAAC,CAAA;QACtE,CAAC,CAAC,CAAA;IACJ,CAAC,CAAC,CAAA;AACJ,CAAC,CAAC,CAAA"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { OpenApiDocument, RestApi } from '@furystack/rest';
|
|
2
|
-
import type { RestApiImplementation } from '../api-manager.js';
|
|
3
2
|
import { type RequestAction } from '../request-action-implementation.js';
|
|
3
|
+
import type { RestApiImplementation } from '../rest-api-runtime.js';
|
|
4
4
|
/**
|
|
5
5
|
* Generates a RequestAction that retrieves the OpenAPI document from a FuryStack API implementation.
|
|
6
6
|
* When authentication providers are configured (via `useHttpAuthentication` / `useJwtAuthentication`),
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"create-get-openapi-document-action.d.ts","sourceRoot":"","sources":["../../src/endpoint-generators/create-get-openapi-document-action.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAuB,eAAe,EAAE,OAAO,EAAwB,MAAM,iBAAiB,CAAA;
|
|
1
|
+
{"version":3,"file":"create-get-openapi-document-action.d.ts","sourceRoot":"","sources":["../../src/endpoint-generators/create-get-openapi-document-action.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAuB,eAAe,EAAE,OAAO,EAAwB,MAAM,iBAAiB,CAAA;AAM1G,OAAO,EAAc,KAAK,aAAa,EAAE,MAAM,qCAAqC,CAAA;AACpF,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,wBAAwB,CAAA;AAsBnE;;;;;;;GAOG;AACH,eAAO,MAAM,8BAA8B,GAAI,CAAC,SAAS,qBAAqB,CAAC,OAAO,CAAC,EACrF,KAAK,CAAC,EACN,aAAsB,EACtB,oBAAqE,EACrE,gBAAiB,KAChB,aAAa,CAAC;IAAE,MAAM,EAAE,eAAe,CAAA;CAAE,CAgB3C,CAAA"}
|
|
@@ -5,7 +5,7 @@ import { generateOpenApiDocument } from '../openapi/generate-openapi-document.js
|
|
|
5
5
|
import { JsonResult } from '../request-action-implementation.js';
|
|
6
6
|
const getSecuritySchemesFromInjector = (injector) => {
|
|
7
7
|
try {
|
|
8
|
-
const settings = injector.
|
|
8
|
+
const settings = injector.get(HttpAuthenticationSettings);
|
|
9
9
|
if (settings.authenticationProviders.length > 0) {
|
|
10
10
|
return mapProvidersToSecuritySchemes(settings.authenticationProviders);
|
|
11
11
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"create-get-openapi-document-action.js","sourceRoot":"","sources":["../../src/endpoint-generators/create-get-openapi-document-action.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"create-get-openapi-document-action.js","sourceRoot":"","sources":["../../src/endpoint-generators/create-get-openapi-document-action.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,gBAAgB,EAAE,MAAM,2BAA2B,CAAA;AAC5D,OAAO,EAAE,0BAA0B,EAAE,MAAM,oCAAoC,CAAA;AAC/E,OAAO,EAAE,6BAA6B,EAAE,MAAM,gDAAgD,CAAA;AAC9F,OAAO,EAAE,uBAAuB,EAAE,MAAM,yCAAyC,CAAA;AACjF,OAAO,EAAE,UAAU,EAAsB,MAAM,qCAAqC,CAAA;AAGpF,MAAM,8BAA8B,GAAG,CAAC,QAAkB,EAAoD,EAAE;IAC9G,IAAI,CAAC;QACH,MAAM,QAAQ,GAAG,QAAQ,CAAC,GAAG,CAAC,0BAA0B,CAAC,CAAA;QACzD,IAAI,QAAQ,CAAC,uBAAuB,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;YAChD,OAAO,6BAA6B,CAAC,QAAQ,CAAC,uBAAuB,CAAC,CAAA;QACxE,CAAC;IACH,CAAC;IAAC,MAAM,CAAC;QACP,yBAAyB;IAC3B,CAAC;IACD,OAAO,SAAS,CAAA;AAClB,CAAC,CAAA;AAED,MAAM,eAAe,GAAG,CACtB,SAA2D,EAC3D,IAAY,EACZ,WAAmB,EACnB,OAAe,EACf,QAA8B,EACb,EAAE,CAAC,uBAAuB,CAAC,EAAE,GAAG,EAAE,SAAS,EAAE,KAAK,EAAE,IAAI,EAAE,WAAW,EAAE,OAAO,EAAE,QAAQ,EAAE,CAAC,CAAA;AAE9G;;;;;;;GAOG;AACH,MAAM,CAAC,MAAM,8BAA8B,GAAG,CAC5C,GAAM,EACN,IAAI,GAAG,eAAe,EACtB,WAAW,GAAG,uDAAuD,EACrE,OAAO,GAAG,OAAO,EAC2B,EAAE;IAC9C,MAAM,EAAE,SAAS,EAAE,GAAG,gBAAgB,CAAC,EAAE,GAAG,EAAE,IAAI,EAAE,WAAW,EAAE,OAAO,EAAE,CAAC,CAAA;IAC3E,IAAI,SAAsC,CAAA;IAC1C,OAAO,KAAK,EAAE,EAAE,QAAQ,EAAE,EAAE,EAAE;QAC5B,IAAI,CAAC,SAAS,EAAE,CAAC;YACf,MAAM,eAAe,GAAG,8BAA8B,CAAC,QAAQ,CAAC,CAAA;YAChE,SAAS,GAAG,eAAe,CACzB,SAAS,EACT,IAAI,EACJ,WAAW,EACX,OAAO,EACP,eAAe,CAAC,CAAC,CAAC,EAAE,eAAe,EAAE,CAAC,CAAC,CAAC,SAAS,CAClD,CAAA;QACH,CAAC;QACD,OAAO,UAAU,CAAC,SAAS,EAAE,GAAG,CAAC,CAAA;IACnC,CAAC,CAAA;AACH,CAAC,CAAA"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import type { RestApiImplementation } from '../api-manager.js';
|
|
2
1
|
import { getSchemaFromApi } from '../get-schema-from-api.js';
|
|
3
2
|
import { type RequestAction } from '../request-action-implementation.js';
|
|
3
|
+
import type { RestApiImplementation } from '../rest-api-runtime.js';
|
|
4
4
|
export type GetSchemaResult = ReturnType<typeof getSchemaFromApi>;
|
|
5
5
|
/**
|
|
6
6
|
* Creates a GET action that returns the schema of the provided API.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"create-get-schema-action.d.ts","sourceRoot":"","sources":["../../src/endpoint-generators/create-get-schema-action.ts"],"names":[],"mappings":"AACA,OAAO,
|
|
1
|
+
{"version":3,"file":"create-get-schema-action.d.ts","sourceRoot":"","sources":["../../src/endpoint-generators/create-get-schema-action.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,gBAAgB,EAAE,MAAM,2BAA2B,CAAA;AAC5D,OAAO,EAAc,KAAK,aAAa,EAAE,MAAM,qCAAqC,CAAA;AACpF,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,wBAAwB,CAAA;AAEnE,MAAM,MAAM,eAAe,GAAG,UAAU,CAAC,OAAO,gBAAgB,CAAC,CAAA;AAEjE;;;;;;;GAOG;AACH,eAAO,MAAM,qBAAqB,GAAI,CAAC,SAAS,qBAAqB,CAAC,GAAG,CAAC,EACxE,KAAK,CAAC,EACN,aAAsB,EACtB,oBAAqE,EACrE,gBAAiB,KAChB,aAAa,CAAC;IAAE,MAAM,EAAE,eAAe,CAAA;CAAE,CAQ3C,CAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"create-get-schema-action.js","sourceRoot":"","sources":["../../src/endpoint-generators/create-get-schema-action.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAA;
|
|
1
|
+
{"version":3,"file":"create-get-schema-action.js","sourceRoot":"","sources":["../../src/endpoint-generators/create-get-schema-action.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAA;AAC9C,OAAO,EAAE,gBAAgB,EAAE,MAAM,2BAA2B,CAAA;AAC5D,OAAO,EAAE,UAAU,EAAsB,MAAM,qCAAqC,CAAA;AAKpF;;;;;;;GAOG;AACH,MAAM,CAAC,MAAM,qBAAqB,GAAG,CACnC,GAAM,EACN,IAAI,GAAG,eAAe,EACtB,WAAW,GAAG,uDAAuD,EACrE,OAAO,GAAG,OAAO,EAC2B,EAAE;IAC9C,MAAM,MAAM,GAAG,gBAAgB,CAAC,EAAE,GAAG,EAAE,IAAI,EAAE,WAAW,EAAE,OAAO,EAAE,CAAC,CAAA;IACpE,OAAO,KAAK,EAAE,EAAE,OAAO,EAAE,EAAE,EAAE;QAC3B,IAAI,OAAO,CAAC,OAAO,CAAC,MAAM,EAAE,QAAQ,CAAC,yBAAyB,CAAC,EAAE,CAAC;YAChE,OAAO,UAAU,CAAC,MAAM,EAAE,GAAG,CAAC,CAAA;QAChC,CAAC;QACD,MAAM,IAAI,YAAY,CAAC,oFAAoF,EAAE,GAAG,CAAC,CAAA;IACnH,CAAC,CAAA;AACH,CAAC,CAAA"}
|
|
@@ -1,17 +1,11 @@
|
|
|
1
|
-
import type { Constructable } from '@furystack/inject';
|
|
2
|
-
import type { PatchEndpoint } from '@furystack/rest';
|
|
3
|
-
import '@furystack/repository';
|
|
4
|
-
import type { RequestAction } from '../request-action-implementation.js';
|
|
5
1
|
import type { WithOptionalId } from '@furystack/core';
|
|
2
|
+
import type { DataSetToken } from '@furystack/repository';
|
|
3
|
+
import type { PatchEndpoint } from '@furystack/rest';
|
|
4
|
+
import { type RequestAction } from '../request-action-implementation.js';
|
|
6
5
|
/**
|
|
7
|
-
* Creates a PATCH endpoint
|
|
8
|
-
*
|
|
9
|
-
* @
|
|
10
|
-
* @param options.primaryKey The field name that is used as primary key on the model
|
|
11
|
-
* @returns a boolean that indicates the success
|
|
6
|
+
* Creates a PATCH endpoint that applies a partial update to an entity
|
|
7
|
+
* identified by the URL's `:id` parameter. The DataSet is resolved from the
|
|
8
|
+
* supplied {@link DataSetToken}.
|
|
12
9
|
*/
|
|
13
|
-
export declare const createPatchEndpoint: <T extends object, TPrimaryKey extends keyof T, TWritableData = WithOptionalId<T, TPrimaryKey>>(
|
|
14
|
-
model: Constructable<T>;
|
|
15
|
-
primaryKey: TPrimaryKey;
|
|
16
|
-
}) => RequestAction<PatchEndpoint<T, TPrimaryKey, TWritableData>>;
|
|
10
|
+
export declare const createPatchEndpoint: <T extends object, TPrimaryKey extends keyof T, TWritableData = WithOptionalId<T, TPrimaryKey>>(dataSet: DataSetToken<T, TPrimaryKey, TWritableData>) => RequestAction<PatchEndpoint<T, TPrimaryKey, TWritableData>>;
|
|
17
11
|
//# sourceMappingURL=create-patch-endpoint.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"create-patch-endpoint.d.ts","sourceRoot":"","sources":["../../src/endpoint-generators/create-patch-endpoint.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,
|
|
1
|
+
{"version":3,"file":"create-patch-endpoint.d.ts","sourceRoot":"","sources":["../../src/endpoint-generators/create-patch-endpoint.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAA;AACrD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,uBAAuB,CAAA;AACzD,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAA;AAEpD,OAAO,EAAc,KAAK,aAAa,EAAE,MAAM,qCAAqC,CAAA;AAEpF;;;;GAIG;AACH,eAAO,MAAM,mBAAmB,GAC9B,CAAC,SAAS,MAAM,EAChB,WAAW,SAAS,MAAM,CAAC,EAC3B,aAAa,GAAG,cAAc,CAAC,CAAC,EAAE,WAAW,CAAC,EAE9C,SAAS,YAAY,CAAC,CAAC,EAAE,WAAW,EAAE,aAAa,CAAC,KACnD,aAAa,CAAC,aAAa,CAAC,CAAC,EAAE,WAAW,EAAE,aAAa,CAAC,CAQ5D,CAAA"}
|
|
@@ -1,22 +1,17 @@
|
|
|
1
|
-
import '@furystack/repository';
|
|
2
|
-
import { JsonResult } from '../request-action-implementation.js';
|
|
3
|
-
import { getRepository } from '@furystack/repository';
|
|
4
1
|
import { readPostBody } from '../read-post-body.js';
|
|
2
|
+
import { JsonResult } from '../request-action-implementation.js';
|
|
5
3
|
/**
|
|
6
|
-
* Creates a PATCH endpoint
|
|
7
|
-
*
|
|
8
|
-
* @
|
|
9
|
-
* @param options.primaryKey The field name that is used as primary key on the model
|
|
10
|
-
* @returns a boolean that indicates the success
|
|
4
|
+
* Creates a PATCH endpoint that applies a partial update to an entity
|
|
5
|
+
* identified by the URL's `:id` parameter. The DataSet is resolved from the
|
|
6
|
+
* supplied {@link DataSetToken}.
|
|
11
7
|
*/
|
|
12
|
-
export const createPatchEndpoint = (
|
|
13
|
-
|
|
8
|
+
export const createPatchEndpoint = (dataSet) => {
|
|
9
|
+
return async ({ injector, request, getUrlParams }) => {
|
|
14
10
|
const { id } = getUrlParams();
|
|
15
11
|
const patchData = await readPostBody(request);
|
|
16
|
-
const
|
|
17
|
-
await
|
|
12
|
+
const ds = injector.get(dataSet);
|
|
13
|
+
await ds.update(injector, id, patchData);
|
|
18
14
|
return JsonResult({});
|
|
19
15
|
};
|
|
20
|
-
return endpoint;
|
|
21
16
|
};
|
|
22
17
|
//# sourceMappingURL=create-patch-endpoint.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"create-patch-endpoint.js","sourceRoot":"","sources":["../../src/endpoint-generators/create-patch-endpoint.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"create-patch-endpoint.js","sourceRoot":"","sources":["../../src/endpoint-generators/create-patch-endpoint.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAA;AACnD,OAAO,EAAE,UAAU,EAAsB,MAAM,qCAAqC,CAAA;AAEpF;;;;GAIG;AACH,MAAM,CAAC,MAAM,mBAAmB,GAAG,CAKjC,OAAoD,EACS,EAAE;IAC/D,OAAO,KAAK,EAAE,EAAE,QAAQ,EAAE,OAAO,EAAE,YAAY,EAAE,EAAE,EAAE;QACnD,MAAM,EAAE,EAAE,EAAE,GAAG,YAAY,EAAE,CAAA;QAC7B,MAAM,SAAS,GAAG,MAAM,YAAY,CAAI,OAAO,CAAC,CAAA;QAChD,MAAM,EAAE,GAAG,QAAQ,CAAC,GAAG,CAAC,OAAO,CAAC,CAAA;QAChC,MAAM,EAAE,CAAC,MAAM,CAAC,QAAQ,EAAE,EAAE,EAAE,SAAS,CAAC,CAAA;QACxC,OAAO,UAAU,CAAC,EAAE,CAAC,CAAA;IACvB,CAAC,CAAA;AACH,CAAC,CAAA"}
|
|
@@ -1,38 +1,31 @@
|
|
|
1
1
|
import { getPort } from '@furystack/core/port-generator';
|
|
2
|
-
import {
|
|
3
|
-
import { getDataSetFor } from '@furystack/repository';
|
|
2
|
+
import { createInjector } from '@furystack/inject';
|
|
4
3
|
import { usingAsync } from '@furystack/utils';
|
|
5
4
|
import { describe, expect, it } from 'vitest';
|
|
6
5
|
import { useRestService } from '../helpers.js';
|
|
7
6
|
import { createPatchEndpoint } from './create-patch-endpoint.js';
|
|
8
|
-
import {
|
|
7
|
+
import { MockDataSet, setupContext } from './utils.js';
|
|
9
8
|
describe('createPatchEndpoint', () => {
|
|
10
|
-
it('
|
|
11
|
-
await usingAsync(
|
|
9
|
+
it('updates the entity and responds 200', async () => {
|
|
10
|
+
await usingAsync(createInjector(), async (i) => {
|
|
12
11
|
setupContext(i);
|
|
13
12
|
const port = getPort();
|
|
14
13
|
await useRestService({
|
|
15
14
|
injector: i,
|
|
16
15
|
root: '/api',
|
|
17
16
|
port,
|
|
18
|
-
api: {
|
|
19
|
-
PATCH: {
|
|
20
|
-
'/:id': createPatchEndpoint({ model: MockClass, primaryKey: 'id' }),
|
|
21
|
-
},
|
|
22
|
-
},
|
|
17
|
+
api: { PATCH: { '/:id': createPatchEndpoint(MockDataSet) } },
|
|
23
18
|
});
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
expect(
|
|
19
|
+
const dataSet = i.get(MockDataSet);
|
|
20
|
+
await dataSet.add(i, { id: 'mock', value: 'mock' });
|
|
21
|
+
expect(await dataSet.count(i)).toBe(1);
|
|
27
22
|
const response = await fetch(`http://127.0.0.1:${port}/api/mock`, {
|
|
28
23
|
method: 'PATCH',
|
|
29
24
|
body: JSON.stringify({ value: 'updated' }),
|
|
30
25
|
});
|
|
31
26
|
expect(response.status).toBe(200);
|
|
32
|
-
|
|
33
|
-
expect(
|
|
34
|
-
const updated = await getDataSetFor(i, MockClass, 'id').get(i, 'mock');
|
|
35
|
-
expect(updated?.value).toBe('updated');
|
|
27
|
+
expect(await response.json()).toEqual({});
|
|
28
|
+
expect((await dataSet.get(i, 'mock'))?.value).toBe('updated');
|
|
36
29
|
});
|
|
37
30
|
});
|
|
38
31
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"create-patch-endpoint.spec.js","sourceRoot":"","sources":["../../src/endpoint-generators/create-patch-endpoint.spec.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,gCAAgC,CAAA;AACxD,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"create-patch-endpoint.spec.js","sourceRoot":"","sources":["../../src/endpoint-generators/create-patch-endpoint.spec.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,gCAAgC,CAAA;AACxD,OAAO,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAA;AAElD,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAA;AAC7C,OAAO,EAAE,QAAQ,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,QAAQ,CAAA;AAC7C,OAAO,EAAE,cAAc,EAAE,MAAM,eAAe,CAAA;AAC9C,OAAO,EAAE,mBAAmB,EAAE,MAAM,4BAA4B,CAAA;AAEhE,OAAO,EAAE,WAAW,EAAE,YAAY,EAAE,MAAM,YAAY,CAAA;AAEtD,QAAQ,CAAC,qBAAqB,EAAE,GAAG,EAAE;IACnC,EAAE,CAAC,qCAAqC,EAAE,KAAK,IAAI,EAAE;QACnD,MAAM,UAAU,CAAC,cAAc,EAAE,EAAE,KAAK,EAAE,CAAC,EAAE,EAAE;YAC7C,YAAY,CAAC,CAAC,CAAC,CAAA;YACf,MAAM,IAAI,GAAG,OAAO,EAAE,CAAA;YACtB,MAAM,cAAc,CAAwD;gBAC1E,QAAQ,EAAE,CAAC;gBACX,IAAI,EAAE,MAAM;gBACZ,IAAI;gBACJ,GAAG,EAAE,EAAE,KAAK,EAAE,EAAE,MAAM,EAAE,mBAAmB,CAAC,WAAW,CAAC,EAAE,EAAE;aAC7D,CAAC,CAAA;YACF,MAAM,OAAO,GAAG,CAAC,CAAC,GAAG,CAAC,WAAW,CAAC,CAAA;YAClC,MAAM,OAAO,CAAC,GAAG,CAAC,CAAC,EAAE,EAAE,EAAE,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,CAAC,CAAA;YACnD,MAAM,CAAC,MAAM,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,CAAA;YAEtC,MAAM,QAAQ,GAAG,MAAM,KAAK,CAAC,oBAAoB,IAAI,WAAW,EAAE;gBAChE,MAAM,EAAE,OAAO;gBACf,IAAI,EAAE,IAAI,CAAC,SAAS,CAAC,EAAE,KAAK,EAAE,SAAS,EAAE,CAAC;aAC3C,CAAC,CAAA;YACF,MAAM,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,CAAA;YACjC,MAAM,CAAC,MAAM,QAAQ,CAAC,IAAI,EAAE,CAAC,CAAC,OAAO,CAAC,EAAE,CAAC,CAAA;YACzC,MAAM,CAAC,CAAC,MAAM,OAAO,CAAC,GAAG,CAAC,CAAC,EAAE,MAAM,CAAC,CAAC,EAAE,KAAK,CAAC,CAAC,IAAI,CAAC,SAAS,CAAC,CAAA;QAC/D,CAAC,CAAC,CAAA;IACJ,CAAC,CAAC,CAAA;AACJ,CAAC,CAAC,CAAA"}
|
|
@@ -1,17 +1,11 @@
|
|
|
1
|
-
import type { Constructable } from '@furystack/inject';
|
|
2
|
-
import type { PostEndpoint } from '@furystack/rest';
|
|
3
|
-
import '@furystack/repository';
|
|
4
|
-
import type { RequestAction } from '../request-action-implementation.js';
|
|
5
1
|
import type { WithOptionalId } from '@furystack/core';
|
|
2
|
+
import type { DataSetToken } from '@furystack/repository';
|
|
3
|
+
import type { PostEndpoint } from '@furystack/rest';
|
|
4
|
+
import { type RequestAction } from '../request-action-implementation.js';
|
|
6
5
|
/**
|
|
7
|
-
* Creates a POST endpoint
|
|
8
|
-
*
|
|
9
|
-
*
|
|
10
|
-
* @param options.primaryKey The field name used as primary key
|
|
11
|
-
* @returns a boolean that indicates the success
|
|
6
|
+
* Creates a POST endpoint that inserts a new entity into the DataSet
|
|
7
|
+
* resolved from `dataSet`. Returns `201 Created` on success; throws a
|
|
8
|
+
* `RequestError(404)` when the underlying store returns no created entity.
|
|
12
9
|
*/
|
|
13
|
-
export declare const createPostEndpoint: <T extends object, TPrimaryKey extends keyof T, TWritableData = WithOptionalId<T, TPrimaryKey>>(
|
|
14
|
-
model: Constructable<T>;
|
|
15
|
-
primaryKey: TPrimaryKey;
|
|
16
|
-
}) => RequestAction<PostEndpoint<T, TPrimaryKey, TWritableData>>;
|
|
10
|
+
export declare const createPostEndpoint: <T extends object, TPrimaryKey extends keyof T, TWritableData = WithOptionalId<T, TPrimaryKey>>(dataSet: DataSetToken<T, TPrimaryKey, TWritableData>) => RequestAction<PostEndpoint<T, TPrimaryKey, TWritableData>>;
|
|
17
11
|
//# sourceMappingURL=create-post-endpoint.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"create-post-endpoint.d.ts","sourceRoot":"","sources":["../../src/endpoint-generators/create-post-endpoint.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,
|
|
1
|
+
{"version":3,"file":"create-post-endpoint.d.ts","sourceRoot":"","sources":["../../src/endpoint-generators/create-post-endpoint.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAA;AACrD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,uBAAuB,CAAA;AACzD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAA;AAGnD,OAAO,EAAc,KAAK,aAAa,EAAE,MAAM,qCAAqC,CAAA;AAEpF;;;;GAIG;AACH,eAAO,MAAM,kBAAkB,GAC7B,CAAC,SAAS,MAAM,EAChB,WAAW,SAAS,MAAM,CAAC,EAC3B,aAAa,GAAG,cAAc,CAAC,CAAC,EAAE,WAAW,CAAC,EAE9C,SAAS,YAAY,CAAC,CAAC,EAAE,WAAW,EAAE,aAAa,CAAC,KACnD,aAAa,CAAC,YAAY,CAAC,CAAC,EAAE,WAAW,EAAE,aAAa,CAAC,CAU3D,CAAA"}
|
|
@@ -1,25 +1,20 @@
|
|
|
1
1
|
import { RequestError } from '@furystack/rest';
|
|
2
|
-
import '@furystack/repository';
|
|
3
|
-
import { JsonResult } from '../request-action-implementation.js';
|
|
4
|
-
import { getRepository } from '@furystack/repository';
|
|
5
2
|
import { readPostBody } from '../read-post-body.js';
|
|
3
|
+
import { JsonResult } from '../request-action-implementation.js';
|
|
6
4
|
/**
|
|
7
|
-
* Creates a POST endpoint
|
|
8
|
-
*
|
|
9
|
-
*
|
|
10
|
-
* @param options.primaryKey The field name used as primary key
|
|
11
|
-
* @returns a boolean that indicates the success
|
|
5
|
+
* Creates a POST endpoint that inserts a new entity into the DataSet
|
|
6
|
+
* resolved from `dataSet`. Returns `201 Created` on success; throws a
|
|
7
|
+
* `RequestError(404)` when the underlying store returns no created entity.
|
|
12
8
|
*/
|
|
13
|
-
export const createPostEndpoint = (
|
|
14
|
-
|
|
15
|
-
const
|
|
9
|
+
export const createPostEndpoint = (dataSet) => {
|
|
10
|
+
return async ({ injector, request }) => {
|
|
11
|
+
const ds = injector.get(dataSet);
|
|
16
12
|
const entityToCreate = await readPostBody(request);
|
|
17
|
-
const { created } = await
|
|
13
|
+
const { created } = await ds.add(injector, entityToCreate);
|
|
18
14
|
if (!created || !created.length) {
|
|
19
15
|
throw new RequestError('Entity not found', 404);
|
|
20
16
|
}
|
|
21
17
|
return JsonResult(created[0], 201);
|
|
22
18
|
};
|
|
23
|
-
return endpoint;
|
|
24
19
|
};
|
|
25
20
|
//# sourceMappingURL=create-post-endpoint.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"create-post-endpoint.js","sourceRoot":"","sources":["../../src/endpoint-generators/create-post-endpoint.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"create-post-endpoint.js","sourceRoot":"","sources":["../../src/endpoint-generators/create-post-endpoint.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAA;AAC9C,OAAO,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAA;AACnD,OAAO,EAAE,UAAU,EAAsB,MAAM,qCAAqC,CAAA;AAEpF;;;;GAIG;AACH,MAAM,CAAC,MAAM,kBAAkB,GAAG,CAKhC,OAAoD,EACQ,EAAE;IAC9D,OAAO,KAAK,EAAE,EAAE,QAAQ,EAAE,OAAO,EAAE,EAAE,EAAE;QACrC,MAAM,EAAE,GAAG,QAAQ,CAAC,GAAG,CAAC,OAAO,CAAC,CAAA;QAChC,MAAM,cAAc,GAAG,MAAM,YAAY,CAAgB,OAAO,CAAC,CAAA;QACjE,MAAM,EAAE,OAAO,EAAE,GAAG,MAAM,EAAE,CAAC,GAAG,CAAC,QAAQ,EAAE,cAAc,CAAC,CAAA;QAC1D,IAAI,CAAC,OAAO,IAAI,CAAC,OAAO,CAAC,MAAM,EAAE,CAAC;YAChC,MAAM,IAAI,YAAY,CAAC,kBAAkB,EAAE,GAAG,CAAC,CAAA;QACjD,CAAC;QACD,OAAO,UAAU,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE,GAAG,CAAC,CAAA;IACpC,CAAC,CAAA;AACH,CAAC,CAAA"}
|
|
@@ -1,25 +1,20 @@
|
|
|
1
1
|
import { getPort } from '@furystack/core/port-generator';
|
|
2
|
-
import {
|
|
3
|
-
import { getDataSetFor } from '@furystack/repository';
|
|
2
|
+
import { createInjector } from '@furystack/inject';
|
|
4
3
|
import { usingAsync } from '@furystack/utils';
|
|
5
4
|
import { describe, expect, it } from 'vitest';
|
|
6
5
|
import { useRestService } from '../helpers.js';
|
|
7
6
|
import { createPostEndpoint } from './create-post-endpoint.js';
|
|
8
|
-
import {
|
|
7
|
+
import { MockDataSet, MockStore, setupContext } from './utils.js';
|
|
9
8
|
describe('createPostEndpoint', () => {
|
|
10
|
-
it('
|
|
11
|
-
await usingAsync(
|
|
9
|
+
it('creates the entity and responds 201', async () => {
|
|
10
|
+
await usingAsync(createInjector(), async (i) => {
|
|
12
11
|
setupContext(i);
|
|
13
12
|
const port = getPort();
|
|
14
13
|
await useRestService({
|
|
15
14
|
injector: i,
|
|
16
15
|
root: '/api',
|
|
17
16
|
port,
|
|
18
|
-
api: {
|
|
19
|
-
POST: {
|
|
20
|
-
'/': createPostEndpoint({ model: MockClass, primaryKey: 'id' }),
|
|
21
|
-
},
|
|
22
|
-
},
|
|
17
|
+
api: { POST: { '/': createPostEndpoint(MockDataSet) } },
|
|
23
18
|
});
|
|
24
19
|
const entityToPost = { id: 'mock', value: 'posted' };
|
|
25
20
|
const response = await fetch(`http://127.0.0.1:${port}/api`, {
|
|
@@ -27,10 +22,42 @@ describe('createPostEndpoint', () => {
|
|
|
27
22
|
body: JSON.stringify(entityToPost),
|
|
28
23
|
});
|
|
29
24
|
expect(response.status).toBe(201);
|
|
30
|
-
|
|
31
|
-
expect(
|
|
32
|
-
|
|
33
|
-
|
|
25
|
+
expect(await response.json()).toEqual(entityToPost);
|
|
26
|
+
expect((await i.get(MockDataSet).get(i, entityToPost.id))?.value).toBe('posted');
|
|
27
|
+
});
|
|
28
|
+
});
|
|
29
|
+
it('responds 404 when the underlying data set returned no created entity', async () => {
|
|
30
|
+
await usingAsync(createInjector(), async (i) => {
|
|
31
|
+
setupContext(i);
|
|
32
|
+
// Swap the dataset binding for a stub whose `add` comes back empty --
|
|
33
|
+
// this is the only way to exercise the `!created.length` branch.
|
|
34
|
+
i.bind(MockDataSet, () => ({ add: async () => ({ created: [] }) }));
|
|
35
|
+
const port = getPort();
|
|
36
|
+
await useRestService({
|
|
37
|
+
injector: i,
|
|
38
|
+
root: '/api',
|
|
39
|
+
port,
|
|
40
|
+
api: { POST: { '/': createPostEndpoint(MockDataSet) } },
|
|
41
|
+
});
|
|
42
|
+
const response = await fetch(`http://127.0.0.1:${port}/api`, {
|
|
43
|
+
method: 'POST',
|
|
44
|
+
body: JSON.stringify({ id: 'mock', value: 'x' }),
|
|
45
|
+
});
|
|
46
|
+
expect(response.status).toBe(404);
|
|
47
|
+
expect(await response.json()).toEqual({ message: 'Entity not found' });
|
|
48
|
+
});
|
|
49
|
+
});
|
|
50
|
+
});
|
|
51
|
+
describe('endpoint-generators/utils', () => {
|
|
52
|
+
it('MockStore throws from its default factory when setupContext was not called', async () => {
|
|
53
|
+
await usingAsync(createInjector(), async (i) => {
|
|
54
|
+
expect(() => i.get(MockStore)).toThrow(/MockStore is not configured/);
|
|
55
|
+
});
|
|
56
|
+
});
|
|
57
|
+
it('setupContext binds MockStore in-memory so the default factory is bypassed', async () => {
|
|
58
|
+
await usingAsync(createInjector(), async (i) => {
|
|
59
|
+
setupContext(i);
|
|
60
|
+
expect(i.get(MockStore)).toBeDefined();
|
|
34
61
|
});
|
|
35
62
|
});
|
|
36
63
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"create-post-endpoint.spec.js","sourceRoot":"","sources":["../../src/endpoint-generators/create-post-endpoint.spec.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,gCAAgC,CAAA;AACxD,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"create-post-endpoint.spec.js","sourceRoot":"","sources":["../../src/endpoint-generators/create-post-endpoint.spec.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,gCAAgC,CAAA;AACxD,OAAO,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAA;AAElD,OAAO,EAAE,UAAU,EAAE,M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AAEF,QAAQ,CAAC,2BAA2B,EAAE,GAAG,EAAE;IACzC,EAAE,CAAC,4EAA4E,EAAE,KAAK,IAAI,EAAE;QAC1F,MAAM,UAAU,CAAC,cAAc,EAAE,EAAE,KAAK,EAAE,CAAC,EAAE,EAAE;YAC7C,MAAM,CAAC,GAAG,EAAE,CAAC,CAAC,CAAC,GAAG,CAAC,SAAS,CAAC,CAAC,CAAC,OAAO,CAAC,6BAA6B,CAAC,CAAA;QACvE,CAAC,CAAC,CAAA;IACJ,CAAC,CAAC,CAAA;IAEF,EAAE,CAAC,2EAA2E,EAAE,KAAK,IAAI,EAAE;QACzF,MAAM,UAAU,CAAC,cAAc,EAAE,EAAE,KAAK,EAAE,CAAC,EAAE,EAAE;YAC7C,YAAY,CAAC,CAAC,CAAC,CAAA;YACf,MAAM,CAAC,CAAC,CAAC,GAAG,CAAC,SAAS,CAAC,CAAC,CAAC,WAAW,EAAE,CAAA;QACxC,CAAC,CAAC,CAAA;IACJ,CAAC,CAAC,CAAA;AACJ,CAAC,CAAC,CAAA"}
|
|
@@ -1,9 +1,24 @@
|
|
|
1
1
|
import type { Injector } from '@furystack/inject';
|
|
2
|
-
|
|
3
|
-
|
|
2
|
+
/**
|
|
3
|
+
* Mock entity used by endpoint-generator specs.
|
|
4
|
+
*/
|
|
4
5
|
export declare class MockClass {
|
|
5
6
|
id: string;
|
|
6
7
|
value: string;
|
|
7
8
|
}
|
|
9
|
+
/**
|
|
10
|
+
* Store token for {@link MockClass}. The default factory throws so each spec
|
|
11
|
+
* explicitly opts into an in-memory backing via `setupContext`.
|
|
12
|
+
*/
|
|
13
|
+
export declare const MockStore: import("@furystack/core").StoreToken<MockClass, "id">;
|
|
14
|
+
/**
|
|
15
|
+
* Data set token over {@link MockStore}.
|
|
16
|
+
*/
|
|
17
|
+
export declare const MockDataSet: import("@furystack/repository").DataSetToken<MockClass, "id", import("@furystack/core").WithOptionalId<MockClass, "id">>;
|
|
18
|
+
/**
|
|
19
|
+
* Binds in-memory implementations of {@link UserStore}, {@link SessionStore}
|
|
20
|
+
* and {@link MockStore} on the provided injector. Endpoint-generator specs
|
|
21
|
+
* and integration tests call this at setup time.
|
|
22
|
+
*/
|
|
8
23
|
export declare const setupContext: (i: Injector) => void;
|
|
9
24
|
//# sourceMappingURL=utils.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../src/endpoint-generators/utils.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../src/endpoint-generators/utils.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAA;AAKjD;;GAEG;AACH,qBAAa,SAAS;IACZ,EAAE,EAAE,MAAM,CAAA;IACV,KAAK,EAAE,MAAM,CAAA;CACtB;AAED;;;GAGG;AACH,eAAO,MAAM,SAAS,uDAOpB,CAAA;AAEF;;GAEG;AACH,eAAO,MAAM,WAAW,0HAGtB,CAAA;AAEF;;;;GAIG;AACH,eAAO,MAAM,YAAY,GAAI,GAAG,QAAQ,KAAG,IAI1C,CAAA"}
|