@furystack/rest-service 6.2.21 → 6.2.22
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/dist/endpoint-generators/create-patch-endpoint.js +1 -1
- package/dist/endpoint-generators/create-patch-endpoint.js.map +1 -1
- package/dist/endpoint-generators/create-post-endpoint.js.map +1 -1
- package/package.json +2 -2
- package/src/endpoint-generators/create-patch-endpoint.ts +11 -2
- package/src/endpoint-generators/create-post-endpoint.ts +11 -4
- package/types/endpoint-generators/create-patch-endpoint.d.ts +3 -2
- package/types/endpoint-generators/create-patch-endpoint.d.ts.map +1 -1
- package/types/endpoint-generators/create-post-endpoint.d.ts +3 -2
- package/types/endpoint-generators/create-post-endpoint.d.ts.map +1 -1
|
@@ -14,7 +14,7 @@ const repository_1 = require("@furystack/repository");
|
|
|
14
14
|
* @returns a boolean that indicates the success
|
|
15
15
|
*/
|
|
16
16
|
const createPatchEndpoint = (options) => {
|
|
17
|
-
const endpoint = async ({ injector, request, getUrlParams }) => {
|
|
17
|
+
const endpoint = async ({ injector, request, getUrlParams, }) => {
|
|
18
18
|
const { id } = getUrlParams();
|
|
19
19
|
const patchData = await request.readPostBody();
|
|
20
20
|
const dataSet = (0, repository_1.getRepository)(injector).getDataSetFor(options.model, options.primaryKey);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"create-patch-endpoint.js","sourceRoot":"","sources":["../../src/endpoint-generators/create-patch-endpoint.ts"],"names":[],"mappings":";;;AAEA,iCAA8B;AAC9B,0CAAuC;AAEvC,oFAA6D;AAC7D,sDAAqD;
|
|
1
|
+
{"version":3,"file":"create-patch-endpoint.js","sourceRoot":"","sources":["../../src/endpoint-generators/create-patch-endpoint.ts"],"names":[],"mappings":";;;AAEA,iCAA8B;AAC9B,0CAAuC;AAEvC,oFAA6D;AAC7D,sDAAqD;AAGrD;;;;;;;GAOG;AACI,MAAM,mBAAmB,GAAG,CAIjC,OAGD,EAAE,EAAE;IACH,MAAM,QAAQ,GAAgE,KAAK,EAAE,EACnF,QAAQ,EACR,OAAO,EACP,YAAY,GACb,EAAE,EAAE;QACH,MAAM,EAAE,EAAE,EAAE,GAAG,YAAY,EAAE,CAAA;QAC7B,MAAM,SAAS,GAAG,MAAM,OAAO,CAAC,YAAY,EAAK,CAAA;QACjD,MAAM,OAAO,GAAG,IAAA,0BAAa,EAAC,QAAQ,CAAC,CAAC,aAAa,CAAC,OAAO,CAAC,KAAK,EAAE,OAAO,CAAC,UAAU,CAAC,CAAA;QACxF,MAAM,OAAO,CAAC,MAAM,CAAC,QAAQ,EAAE,EAAE,EAAE,SAAS,CAAC,CAAA;QAC7C,OAAO,IAAA,0CAAU,EAAC,EAAE,CAAC,CAAA;IACvB,CAAC,CAAA;IACD,OAAO,QAAQ,CAAA;AACjB,CAAC,CAAA;AApBY,QAAA,mBAAmB,uBAoB/B"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"create-post-endpoint.js","sourceRoot":"","sources":["../../src/endpoint-generators/create-post-endpoint.ts"],"names":[],"mappings":";;;AAEA,0CAA8C;AAC9C,iCAA8B;AAC9B,0CAAuC;AAEvC,oFAA6D;AAE7D,sDAAqD;AACrD;;;;;;;GAOG;AACI,MAAM,kBAAkB,GAAG,
|
|
1
|
+
{"version":3,"file":"create-post-endpoint.js","sourceRoot":"","sources":["../../src/endpoint-generators/create-post-endpoint.ts"],"names":[],"mappings":";;;AAEA,0CAA8C;AAC9C,iCAA8B;AAC9B,0CAAuC;AAEvC,oFAA6D;AAE7D,sDAAqD;AACrD;;;;;;;GAOG;AACI,MAAM,kBAAkB,GAAG,CAIhC,OAGD,EAAE,EAAE;IACH,MAAM,QAAQ,GAA+D,KAAK,EAAE,EAAE,QAAQ,EAAE,OAAO,EAAE,EAAE,EAAE;QAC3G,MAAM,OAAO,GAAG,IAAA,0BAAa,EAAC,QAAQ,CAAC,CAAC,aAAa,CACnD,OAAO,CAAC,KAAK,EACb,OAAO,CAAC,UAAU,CACnB,CAAA;QAED,MAAM,cAAc,GAAG,MAAM,OAAO,CAAC,YAAY,EAAiB,CAAA;QAClE,MAAM,EAAE,OAAO,EAAE,GAAG,MAAM,OAAO,CAAC,GAAG,CAAC,QAAQ,EAAE,cAAc,CAAC,CAAA;QAC/D,IAAI,CAAC,OAAO,IAAI,CAAC,OAAO,CAAC,MAAM,EAAE;YAC/B,MAAM,IAAI,mBAAY,CAAC,kBAAkB,EAAE,GAAG,CAAC,CAAA;SAChD;QACD,OAAO,IAAA,0CAAU,EAAC,OAAO,CAAC,CAAC,CAAC,EAAE,GAAG,CAAC,CAAA;IACpC,CAAC,CAAA;IACD,OAAO,QAAQ,CAAA;AACjB,CAAC,CAAA;AAtBY,QAAA,kBAAkB,sBAsB9B"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@furystack/rest-service",
|
|
3
|
-
"version": "6.2.
|
|
3
|
+
"version": "6.2.22",
|
|
4
4
|
"description": "Repository implementation for FuryStack",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"files": [
|
|
@@ -31,7 +31,7 @@
|
|
|
31
31
|
"dependencies": {
|
|
32
32
|
"@furystack/core": "^11.3.0",
|
|
33
33
|
"@furystack/inject": "^7.1.8",
|
|
34
|
-
"@furystack/repository": "^6.1.
|
|
34
|
+
"@furystack/repository": "^6.1.16",
|
|
35
35
|
"@furystack/rest": "^4.2.0",
|
|
36
36
|
"@furystack/security": "^2.1.15",
|
|
37
37
|
"@furystack/utils": "^3.1.7",
|
|
@@ -5,6 +5,7 @@ import '../incoming-message-extensions'
|
|
|
5
5
|
import type { RequestAction } from '../request-action-implementation'
|
|
6
6
|
import { JsonResult } from '../request-action-implementation'
|
|
7
7
|
import { getRepository } from '@furystack/repository'
|
|
8
|
+
import type { WithOptionalId } from '@furystack/core'
|
|
8
9
|
|
|
9
10
|
/**
|
|
10
11
|
* Creates a PATCH endpoint for updating entities
|
|
@@ -14,11 +15,19 @@ import { getRepository } from '@furystack/repository'
|
|
|
14
15
|
* @param options.primaryKey The field name that is used as primary key on the model
|
|
15
16
|
* @returns a boolean that indicates the success
|
|
16
17
|
*/
|
|
17
|
-
export const createPatchEndpoint = <
|
|
18
|
+
export const createPatchEndpoint = <
|
|
19
|
+
T extends object,
|
|
20
|
+
TPrimaryKey extends keyof T,
|
|
21
|
+
TWritableData = WithOptionalId<T, TPrimaryKey>,
|
|
22
|
+
>(options: {
|
|
18
23
|
model: Constructable<T>
|
|
19
24
|
primaryKey: TPrimaryKey
|
|
20
25
|
}) => {
|
|
21
|
-
const endpoint: RequestAction<PatchEndpoint<T, TPrimaryKey>> = async ({
|
|
26
|
+
const endpoint: RequestAction<PatchEndpoint<T, TPrimaryKey, TWritableData>> = async ({
|
|
27
|
+
injector,
|
|
28
|
+
request,
|
|
29
|
+
getUrlParams,
|
|
30
|
+
}) => {
|
|
22
31
|
const { id } = getUrlParams()
|
|
23
32
|
const patchData = await request.readPostBody<T>()
|
|
24
33
|
const dataSet = getRepository(injector).getDataSetFor(options.model, options.primaryKey)
|
|
@@ -15,14 +15,21 @@ import { getRepository } from '@furystack/repository'
|
|
|
15
15
|
* @param options.primaryKey The field name used as primary key
|
|
16
16
|
* @returns a boolean that indicates the success
|
|
17
17
|
*/
|
|
18
|
-
export const createPostEndpoint = <
|
|
18
|
+
export const createPostEndpoint = <
|
|
19
|
+
T extends object,
|
|
20
|
+
TPrimaryKey extends keyof T,
|
|
21
|
+
TWritableData = WithOptionalId<T, TPrimaryKey>,
|
|
22
|
+
>(options: {
|
|
19
23
|
model: Constructable<T>
|
|
20
24
|
primaryKey: TPrimaryKey
|
|
21
25
|
}) => {
|
|
22
|
-
const endpoint: RequestAction<PostEndpoint<T, TPrimaryKey>> = async ({ injector, request }) => {
|
|
23
|
-
const dataSet = getRepository(injector).getDataSetFor
|
|
26
|
+
const endpoint: RequestAction<PostEndpoint<T, TPrimaryKey, TWritableData>> = async ({ injector, request }) => {
|
|
27
|
+
const dataSet = getRepository(injector).getDataSetFor<T, TPrimaryKey, TWritableData>(
|
|
28
|
+
options.model,
|
|
29
|
+
options.primaryKey,
|
|
30
|
+
)
|
|
24
31
|
|
|
25
|
-
const entityToCreate = await request.readPostBody<
|
|
32
|
+
const entityToCreate = await request.readPostBody<TWritableData>()
|
|
26
33
|
const { created } = await dataSet.add(injector, entityToCreate)
|
|
27
34
|
if (!created || !created.length) {
|
|
28
35
|
throw new RequestError('Entity not found', 404)
|
|
@@ -3,6 +3,7 @@ import type { PatchEndpoint } from '@furystack/rest';
|
|
|
3
3
|
import '@furystack/repository';
|
|
4
4
|
import '../incoming-message-extensions';
|
|
5
5
|
import type { RequestAction } from '../request-action-implementation';
|
|
6
|
+
import type { WithOptionalId } from '@furystack/core';
|
|
6
7
|
/**
|
|
7
8
|
* Creates a PATCH endpoint for updating entities
|
|
8
9
|
*
|
|
@@ -11,8 +12,8 @@ import type { RequestAction } from '../request-action-implementation';
|
|
|
11
12
|
* @param options.primaryKey The field name that is used as primary key on the model
|
|
12
13
|
* @returns a boolean that indicates the success
|
|
13
14
|
*/
|
|
14
|
-
export declare const createPatchEndpoint: <T extends object, TPrimaryKey extends keyof T
|
|
15
|
+
export declare const createPatchEndpoint: <T extends object, TPrimaryKey extends keyof T, TWritableData = WithOptionalId<T, TPrimaryKey>>(options: {
|
|
15
16
|
model: Constructable<T>;
|
|
16
17
|
primaryKey: TPrimaryKey;
|
|
17
|
-
}) => RequestAction<PatchEndpoint<T, TPrimaryKey>>;
|
|
18
|
+
}) => RequestAction<PatchEndpoint<T, TPrimaryKey, TWritableData>>;
|
|
18
19
|
//# 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,aAAa,EAAE,MAAM,mBAAmB,CAAA;AACtD,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAA;AACpD,OAAO,uBAAuB,CAAA;AAC9B,OAAO,gCAAgC,CAAA;AACvC,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,kCAAkC,CAAA;
|
|
1
|
+
{"version":3,"file":"create-patch-endpoint.d.ts","sourceRoot":"","sources":["../../src/endpoint-generators/create-patch-endpoint.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAA;AACtD,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAA;AACpD,OAAO,uBAAuB,CAAA;AAC9B,OAAO,gCAAgC,CAAA;AACvC,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,kCAAkC,CAAA;AAGrE,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAA;AAErD;;;;;;;GAOG;AACH,eAAO,MAAM,mBAAmB;;;iEAoB/B,CAAA"}
|
|
@@ -3,6 +3,7 @@ import type { PostEndpoint } from '@furystack/rest';
|
|
|
3
3
|
import '@furystack/repository';
|
|
4
4
|
import '../incoming-message-extensions';
|
|
5
5
|
import type { RequestAction } from '../request-action-implementation';
|
|
6
|
+
import type { WithOptionalId } from '@furystack/core';
|
|
6
7
|
/**
|
|
7
8
|
* Creates a POST endpoint for updating entities
|
|
8
9
|
*
|
|
@@ -11,8 +12,8 @@ import type { RequestAction } from '../request-action-implementation';
|
|
|
11
12
|
* @param options.primaryKey The field name used as primary key
|
|
12
13
|
* @returns a boolean that indicates the success
|
|
13
14
|
*/
|
|
14
|
-
export declare const createPostEndpoint: <T extends object, TPrimaryKey extends keyof T
|
|
15
|
+
export declare const createPostEndpoint: <T extends object, TPrimaryKey extends keyof T, TWritableData = WithOptionalId<T, TPrimaryKey>>(options: {
|
|
15
16
|
model: Constructable<T>;
|
|
16
17
|
primaryKey: TPrimaryKey;
|
|
17
|
-
}) => RequestAction<PostEndpoint<T, TPrimaryKey>>;
|
|
18
|
+
}) => RequestAction<PostEndpoint<T, TPrimaryKey, TWritableData>>;
|
|
18
19
|
//# 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,aAAa,EAAE,MAAM,mBAAmB,CAAA;AACtD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAA;AAEnD,OAAO,uBAAuB,CAAA;AAC9B,OAAO,gCAAgC,CAAA;AACvC,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,kCAAkC,CAAA;
|
|
1
|
+
{"version":3,"file":"create-post-endpoint.d.ts","sourceRoot":"","sources":["../../src/endpoint-generators/create-post-endpoint.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAA;AACtD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAA;AAEnD,OAAO,uBAAuB,CAAA;AAC9B,OAAO,gCAAgC,CAAA;AACvC,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,kCAAkC,CAAA;AAErE,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAA;AAErD;;;;;;;GAOG;AACH,eAAO,MAAM,kBAAkB;;;gEAsB9B,CAAA"}
|