@furystack/rest-service 6.2.20 → 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.
@@ -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;AAErD;;;;;;;GAOG;AACI,MAAM,mBAAmB,GAAG,CAAgD,OAGlF,EAAE,EAAE;IACH,MAAM,QAAQ,GAAiD,KAAK,EAAE,EAAE,QAAQ,EAAE,OAAO,EAAE,YAAY,EAAE,EAAE,EAAE;QAC3G,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;AAZY,QAAA,mBAAmB,uBAY/B"}
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,CAAgD,OAGjF,EAAE,EAAE;IACH,MAAM,QAAQ,GAAgD,KAAK,EAAE,EAAE,QAAQ,EAAE,OAAO,EAAE,EAAE,EAAE;QAC5F,MAAM,OAAO,GAAG,IAAA,0BAAa,EAAC,QAAQ,CAAC,CAAC,aAAa,CAAC,OAAO,CAAC,KAAK,EAAE,OAAO,CAAC,UAAU,CAAC,CAAA;QAExF,MAAM,cAAc,GAAG,MAAM,OA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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.20",
3
+ "version": "6.2.22",
4
4
  "description": "Repository implementation for FuryStack",
5
5
  "main": "dist/index.js",
6
6
  "files": [
@@ -29,11 +29,11 @@
29
29
  },
30
30
  "homepage": "https://github.com/furystack/furystack",
31
31
  "dependencies": {
32
- "@furystack/core": "^11.2.12",
32
+ "@furystack/core": "^11.3.0",
33
33
  "@furystack/inject": "^7.1.8",
34
- "@furystack/repository": "^6.1.14",
35
- "@furystack/rest": "^4.1.17",
36
- "@furystack/security": "^2.1.14",
34
+ "@furystack/repository": "^6.1.16",
35
+ "@furystack/rest": "^4.2.0",
36
+ "@furystack/security": "^2.1.15",
37
37
  "@furystack/utils": "^3.1.7",
38
38
  "ajv": "^8.12.0",
39
39
  "ajv-formats": "^2.1.1",
@@ -41,7 +41,7 @@
41
41
  "semaphore-async-await": "^1.5.1"
42
42
  },
43
43
  "devDependencies": {
44
- "@furystack/rest-client-fetch": "^4.1.17",
44
+ "@furystack/rest-client-fetch": "^4.1.18",
45
45
  "@types/jest": "^29.5.0",
46
46
  "@types/node": "^18.15.11"
47
47
  },
@@ -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 = <T extends object, TPrimaryKey extends keyof T>(options: {
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 ({ injector, request, getUrlParams }) => {
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 = <T extends object, TPrimaryKey extends keyof T>(options: {
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(options.model, options.primaryKey)
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<WithOptionalId<T, (typeof dataSet)['primaryKey']>>()
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>(options: {
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;AAIrE;;;;;;;GAOG;AACH,eAAO,MAAM,mBAAmB;;;kDAY/B,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>(options: {
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;AAIrE;;;;;;;GAOG;AACH,eAAO,MAAM,kBAAkB;;;iDAe9B,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"}
@@ -6,8 +6,8 @@ import type { DefaultSession } from './models/default-session';
6
6
  * Injectable UserContext for FuryStack HTTP Api
7
7
  */
8
8
  export declare class HttpUserContext {
9
- getUserStore: () => import("@furystack/core").PhysicalStore<User, keyof User>;
10
- getSessionStore: () => import("@furystack/core").PhysicalStore<DefaultSession, keyof DefaultSession>;
9
+ getUserStore: () => import("@furystack/core").PhysicalStore<User, keyof User, import("@furystack/core").WithOptionalId<User, keyof User>>;
10
+ getSessionStore: () => import("@furystack/core").PhysicalStore<DefaultSession, keyof DefaultSession, import("@furystack/core").WithOptionalId<DefaultSession, keyof DefaultSession>>;
11
11
  private getUserByName;
12
12
  private getSessionById;
13
13
  private user?;
@@ -1 +1 @@
1
- {"version":3,"file":"http-user-context.d.ts","sourceRoot":"","sources":["../src/http-user-context.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,cAAc,EAAE,MAAM,MAAM,CAAA;AAC3D,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,iBAAiB,CAAA;AAG3C,OAAO,EAAE,0BAA0B,EAAE,MAAM,gCAAgC,CAAA;AAC3E,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,0BAA0B,CAAA;AAI9D;;GAEG;AACH,qBACa,eAAe;IACnB,YAAY,kEAA4D;IAExE,eAAe,sFAA+D;IAErF,OAAO,CAAC,aAAa,CAOpB;IAED,OAAO,CAAC,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