@rvoh/psychic-spec-helpers 1.1.1 → 1.1.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.
package/CHANGELOG.md ADDED
@@ -0,0 +1,7 @@
1
+ ## 1.1.1
2
+
3
+ - bump supertest to close [dependabot issue](https://github.com/rvohealth/psychic-spec-helpers/security/dependabot/20)
4
+
5
+ ## 1.1.0
6
+
7
+ - update for Dream 1.4.0
@@ -0,0 +1,7 @@
1
+ {
2
+ "files": [],
3
+ "references": [
4
+ { "path": "./tsconfig.app.json" },
5
+ { "path": "./tsconfig.node.json" }
6
+ ]
7
+ }
@@ -28,4 +28,30 @@ describe('OpenapiSpecRequest#post', () => {
28
28
  });
29
29
  });
30
30
  });
31
+ context('with requestBody', () => {
32
+ context('type tests', () => {
33
+ it.skip('allows strings for id types', async () => {
34
+ await request.post('/users', 201, {
35
+ data: {
36
+ id: '123',
37
+ },
38
+ });
39
+ });
40
+ it.skip('allows numbers for id types', async () => {
41
+ await request.post('/users', 201, {
42
+ data: {
43
+ id: 123,
44
+ },
45
+ });
46
+ });
47
+ it.skip('allows primary key values for id types', async () => {
48
+ const user = User.new();
49
+ await request.post('/users', 201, {
50
+ data: {
51
+ id: user.id,
52
+ },
53
+ });
54
+ });
55
+ });
56
+ });
31
57
  });
@@ -50,6 +50,7 @@ let UsersController = (() => {
50
50
  const _metadata = typeof Symbol === "function" && Symbol.metadata ? Object.create(_classSuper[Symbol.metadata] ?? null) : void 0;
51
51
  _create_decorators = [OpenAPI(User, {
52
52
  status: 201,
53
+ requestBody: { for: User, including: ['id'] },
53
54
  })];
54
55
  _index_decorators = [OpenAPI(User, {
55
56
  many: true,
@@ -1,10 +1,14 @@
1
1
  import { Dream } from '@rvoh/dream';
2
- import { globalSchema, schema } from '../../types/dream.js';
2
+ import { connectionTypeConfig, schema } from '../../types/dream.js';
3
+ import { globalTypeConfig } from '../../types/dream.globals.js';
3
4
  export default class ApplicationModel extends Dream {
4
5
  get schema() {
5
6
  return schema;
6
7
  }
7
- get globalSchema() {
8
- return globalSchema;
8
+ get connectionTypeConfig() {
9
+ return connectionTypeConfig;
10
+ }
11
+ get globalTypeConfig() {
12
+ return globalTypeConfig;
9
13
  }
10
14
  }
@@ -1,5 +1,4 @@
1
1
  import { DreamSerializer } from '@rvoh/dream';
2
2
  import User from '../models/User.js';
3
3
  export const UserSummarySerializer = (user) => DreamSerializer(User, user).attribute('id');
4
- const UserSerializer = (user) => UserSummarySerializer(user).attribute('email');
5
- export default UserSerializer;
4
+ export const UserSerializer = (user) => UserSummarySerializer(user).attribute('email');
@@ -0,0 +1,3 @@
1
+ export const globalTypeConfig = {
2
+ serializers: ['UserSerializer', 'UserSummarySerializer'],
3
+ };
@@ -105,13 +105,12 @@ export const schema = {
105
105
  associations: {},
106
106
  },
107
107
  };
108
- export const globalSchema = {
108
+ export const connectionTypeConfig = {
109
109
  passthroughColumns: [],
110
110
  allDefaultScopeNames: [],
111
111
  globalNames: {
112
112
  models: {
113
113
  'User': 'users'
114
114
  },
115
- serializers: ['UserSerializer', 'UserSummarySerializer'],
116
115
  },
117
116
  };
@@ -2,6 +2,7 @@ import { ExpectToEvaluateOpts } from './feature/internal/evaluateWithRetryAndTim
2
2
  import { CustomMatcherResult } from './feature/helpers/providePuppeteerViteMatchers.js';
3
3
  import { Page, WaitForSelectorOptions } from 'puppeteer';
4
4
  import { ToFillMatcherOpts } from './feature/matchers/toFill.js';
5
+ export { DreamRequestAttributes as SendableAttributes } from './unit/helpers/typeHelpers.js';
5
6
  export { default as specRequest } from './unit/SpecRequest.js';
6
7
  export { default as createPsychicServer } from './unit/createPsychicServer.js';
7
8
  export { OpenapiSpecRequest } from './unit/OpenapiSpecRequest.js';
@@ -1 +1,5 @@
1
+ import { CalendarDate, DateTime, Dream, DreamAttributes } from '@rvoh/dream';
1
2
  export type StringToInt<T extends string> = T extends `${infer N extends number}` ? N : never;
3
+ export type DreamRequestAttributes<I extends Dream, Attrs extends DreamAttributes<I> = DreamAttributes<I>> = Partial<{
4
+ [K in keyof Attrs]: Attrs[K] extends undefined | null ? Attrs[K] : Attrs[K] extends DateTime | CalendarDate | null ? string : Attrs[K] extends DateTime | CalendarDate ? string : Attrs[K] extends CalendarDate | null ? string : Attrs[K] extends CalendarDate ? string : Attrs[K];
5
+ }>;
@@ -52,14 +52,16 @@ export default class ApplicationModel extends Dream {
52
52
  readonly associations: {};
53
53
  };
54
54
  };
55
- get globalSchema(): {
55
+ get connectionTypeConfig(): {
56
56
  readonly passthroughColumns: readonly [];
57
57
  readonly allDefaultScopeNames: readonly [];
58
58
  readonly globalNames: {
59
59
  readonly models: {
60
60
  readonly User: "users";
61
61
  };
62
- readonly serializers: readonly ["UserSerializer", "UserSummarySerializer"];
63
62
  };
64
63
  };
64
+ get globalTypeConfig(): {
65
+ readonly serializers: readonly ["UserSerializer", "UserSummarySerializer"];
66
+ };
65
67
  }
@@ -1,4 +1,3 @@
1
1
  import User from '../models/User.js';
2
2
  export declare const UserSummarySerializer: (user: User) => import("@rvoh/dream").DreamSerializerBuilder<typeof User, User, undefined, User>;
3
- declare const UserSerializer: (user: User) => import("@rvoh/dream").DreamSerializerBuilder<typeof User, User, undefined, User>;
4
- export default UserSerializer;
3
+ export declare const UserSerializer: (user: User) => import("@rvoh/dream").DreamSerializerBuilder<typeof User, User, undefined, User>;
@@ -49,13 +49,12 @@ export declare const schema: {
49
49
  readonly associations: {};
50
50
  };
51
51
  };
52
- export declare const globalSchema: {
52
+ export declare const connectionTypeConfig: {
53
53
  readonly passthroughColumns: readonly [];
54
54
  readonly allDefaultScopeNames: readonly [];
55
55
  readonly globalNames: {
56
56
  readonly models: {
57
57
  readonly User: "users";
58
58
  };
59
- readonly serializers: readonly ["UserSerializer", "UserSummarySerializer"];
60
59
  };
61
60
  };
@@ -0,0 +1,3 @@
1
+ export declare const globalTypeConfig: {
2
+ readonly serializers: readonly ["UserSerializer", "UserSummarySerializer"];
3
+ };
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "type": "module",
3
3
  "name": "@rvoh/psychic-spec-helpers",
4
- "version": "1.1.1",
4
+ "version": "1.1.2",
5
5
  "description": "psychic framework spec helpers",
6
6
  "author": "RVO Health",
7
7
  "repository": {
@@ -36,6 +36,8 @@
36
36
  },
37
37
  "packageManager": "yarn@4.4.1",
38
38
  "peerDependencies": {
39
+ "@rvoh/dream": "*",
40
+ "@rvoh/psychic": "*",
39
41
  "@types/node": "*",
40
42
  "@types/supertest": "*",
41
43
  "puppeteer": "*",
@@ -44,9 +46,9 @@
44
46
  },
45
47
  "devDependencies": {
46
48
  "@eslint/js": "=9.0.0",
47
- "@rvoh/dream": "^1.4.1",
48
- "@rvoh/dream-spec-helpers": "^1.1.0",
49
- "@rvoh/psychic": "^1.2.0",
49
+ "@rvoh/dream": "^1.5.0",
50
+ "@rvoh/dream-spec-helpers": "^1.1.1",
51
+ "@rvoh/psychic": "^1.5.2",
50
52
  "@types/cookiejar": "^2",
51
53
  "@types/express": "^4",
52
54
  "@types/node": "^22.5.1",
@@ -57,6 +59,7 @@
57
59
  "kysely": "^0.27.5",
58
60
  "kysely-codegen": "^0.17.0",
59
61
  "luxon-jest-matchers": "^0.1.14",
62
+ "openapi-typescript": "^7.8.0",
60
63
  "pg": "^8.13.1",
61
64
  "prettier": "^3.5.3",
62
65
  "puppeteer": "^24.4.0",
@@ -70,4 +73,4 @@
70
73
  "dependencies": {
71
74
  "cookiejar": "^2.1.4"
72
75
  }
73
- }
76
+ }
package/src/index.ts CHANGED
@@ -3,6 +3,9 @@ import { CustomMatcherResult } from './feature/helpers/providePuppeteerViteMatch
3
3
  import { Page, WaitForSelectorOptions } from 'puppeteer'
4
4
  import { ToFillMatcherOpts } from './feature/matchers/toFill.js'
5
5
 
6
+ // type helpers
7
+ export { DreamRequestAttributes as SendableAttributes } from './unit/helpers/typeHelpers.js'
8
+
6
9
  // unit spec helpers
7
10
  export { default as specRequest } from './unit/SpecRequest.js'
8
11
  export { default as createPsychicServer } from './unit/createPsychicServer.js'
@@ -1 +1,20 @@
1
+ import { CalendarDate, DateTime, Dream, DreamAttributes } from '@rvoh/dream'
2
+
1
3
  export type StringToInt<T extends string> = T extends `${infer N extends number}` ? N : never
4
+
5
+ export type DreamRequestAttributes<
6
+ I extends Dream,
7
+ Attrs extends DreamAttributes<I> = DreamAttributes<I>,
8
+ > = Partial<{
9
+ [K in keyof Attrs]: Attrs[K] extends undefined | null
10
+ ? Attrs[K]
11
+ : Attrs[K] extends DateTime | CalendarDate | null
12
+ ? string
13
+ : Attrs[K] extends DateTime | CalendarDate
14
+ ? string
15
+ : Attrs[K] extends CalendarDate | null
16
+ ? string
17
+ : Attrs[K] extends CalendarDate
18
+ ? string
19
+ : Attrs[K]
20
+ }>