@rvoh/psychic 0.26.1 → 0.26.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/dist/cjs/src/bin/index.js +9 -11
- package/dist/cjs/src/generate/helpers/generateResourceControllerSpecContent.js +11 -11
- package/dist/cjs/src/server/helpers/startPsychicServer.js +2 -4
- package/dist/esm/src/bin/index.js +9 -11
- package/dist/esm/src/generate/helpers/generateResourceControllerSpecContent.js +11 -11
- package/dist/esm/src/server/helpers/startPsychicServer.js +2 -4
- package/package.json +2 -2
|
@@ -28,9 +28,7 @@ class PsychicBin {
|
|
|
28
28
|
await dream_1.DreamBin.sync(() => { });
|
|
29
29
|
await PsychicBin.syncTypes();
|
|
30
30
|
const psychicApp = index_js_1.default.getOrFail();
|
|
31
|
-
|
|
32
|
-
await PsychicBin.syncOpenapiJson();
|
|
33
|
-
}
|
|
31
|
+
await PsychicBin.syncOpenapiJson();
|
|
34
32
|
if (psychicApp.openapi?.syncEnumsToClient) {
|
|
35
33
|
await this.syncClientEnums();
|
|
36
34
|
}
|
|
@@ -50,30 +48,30 @@ class PsychicBin {
|
|
|
50
48
|
}
|
|
51
49
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
52
50
|
static async syncTypes(customTypes = undefined) {
|
|
53
|
-
|
|
51
|
+
dream_1.DreamCLI.logger.logStartProgress(`syncing types/psychic.ts...`);
|
|
54
52
|
await TypesBuilder_js_1.default.sync(customTypes);
|
|
55
|
-
|
|
53
|
+
dream_1.DreamCLI.logger.logEndProgress();
|
|
56
54
|
}
|
|
57
55
|
static async syncOpenapiJson() {
|
|
58
|
-
|
|
56
|
+
dream_1.DreamCLI.logger.logStartProgress(`syncing openapi...`);
|
|
59
57
|
await app_js_1.default.sync();
|
|
60
|
-
|
|
58
|
+
dream_1.DreamCLI.logger.logEndProgress();
|
|
61
59
|
}
|
|
62
60
|
static async syncRoutes() {
|
|
63
|
-
|
|
61
|
+
dream_1.DreamCLI.logger.logStartProgress(`syncing routes...`);
|
|
64
62
|
const server = new index_js_2.default();
|
|
65
63
|
await server.boot();
|
|
66
64
|
const routes = await server.routes();
|
|
67
65
|
await (0, generateRouteTypes_js_1.default)(routes);
|
|
68
|
-
|
|
66
|
+
dream_1.DreamCLI.logger.logEndProgress();
|
|
69
67
|
}
|
|
70
68
|
static async syncClientEnums() {
|
|
71
|
-
|
|
69
|
+
dream_1.DreamCLI.logger.logStartProgress(`syncing client enums...`);
|
|
72
70
|
const psychicApp = index_js_1.default.getOrFail();
|
|
73
71
|
const apiPath = path.join(psychicApp.clientRoot, psychicApp.client.apiPath);
|
|
74
72
|
const enumsStr = await (0, enumsFileStr_js_1.default)();
|
|
75
73
|
await fs.writeFile(`${apiPath}/enums.ts`, enumsStr);
|
|
76
|
-
|
|
74
|
+
dream_1.DreamCLI.logger.logEndProgress();
|
|
77
75
|
}
|
|
78
76
|
}
|
|
79
77
|
exports.default = PsychicBin;
|
|
@@ -40,7 +40,7 @@ function generateResourceControllerSpecContent({ fullyQualifiedControllerName, r
|
|
|
40
40
|
import { UpdateableProperties } from '@rvoh/dream'
|
|
41
41
|
import { PsychicServer } from '@rvoh/psychic'
|
|
42
42
|
import { specRequest as request } from '@rvoh/psychic-spec-helpers'${(0, dream_1.uniq)(importStatements).join('')}
|
|
43
|
-
import
|
|
43
|
+
import addEndUserAuthHeader from '${specUnitUpdirs}helpers/authentication.js'
|
|
44
44
|
|
|
45
45
|
describe('${fullyQualifiedControllerName}', () => {
|
|
46
46
|
let user: User
|
|
@@ -51,9 +51,9 @@ describe('${fullyQualifiedControllerName}', () => {
|
|
|
51
51
|
})
|
|
52
52
|
|
|
53
53
|
describe('GET index', () => {
|
|
54
|
-
|
|
54
|
+
const subject = async (expectedStatus: number = 200) => {
|
|
55
55
|
return request.get('/${route}', expectedStatus, {
|
|
56
|
-
headers: addEndUserAuthHeader(request, user, {}),
|
|
56
|
+
headers: await addEndUserAuthHeader(request, user, {}),
|
|
57
57
|
})
|
|
58
58
|
}
|
|
59
59
|
|
|
@@ -81,9 +81,9 @@ describe('${fullyQualifiedControllerName}', () => {
|
|
|
81
81
|
})
|
|
82
82
|
|
|
83
83
|
describe('GET show', () => {
|
|
84
|
-
|
|
84
|
+
const subject = async (${modelVariableName}: ${modelClassName}, expectedStatus: number = 200) => {
|
|
85
85
|
return request.get(\`/${route}/\${${modelVariableName}.id}\`, expectedStatus, {
|
|
86
|
-
headers: addEndUserAuthHeader(request, user, {}),
|
|
86
|
+
headers: await addEndUserAuthHeader(request, user, {}),
|
|
87
87
|
})
|
|
88
88
|
}
|
|
89
89
|
|
|
@@ -109,10 +109,10 @@ describe('${fullyQualifiedControllerName}', () => {
|
|
|
109
109
|
})
|
|
110
110
|
|
|
111
111
|
describe('POST create', () => {
|
|
112
|
-
|
|
112
|
+
const subject = async (data: UpdateableProperties<${modelClassName}>, expectedStatus: number = 201) => {
|
|
113
113
|
return request.post('/${route}', expectedStatus, {
|
|
114
114
|
data,
|
|
115
|
-
headers: addEndUserAuthHeader(request, user, {}),
|
|
115
|
+
headers: await addEndUserAuthHeader(request, user, {}),
|
|
116
116
|
})
|
|
117
117
|
}
|
|
118
118
|
|
|
@@ -131,10 +131,10 @@ describe('${fullyQualifiedControllerName}', () => {
|
|
|
131
131
|
})
|
|
132
132
|
|
|
133
133
|
describe('PATCH update', () => {
|
|
134
|
-
|
|
134
|
+
const subject = async (${modelVariableName}: ${modelClassName}, data: UpdateableProperties<${modelClassName}>, expectedStatus: number = 204) => {
|
|
135
135
|
return request.patch(\`/${route}/\${${modelVariableName}.id}\`, expectedStatus, {
|
|
136
136
|
data,
|
|
137
|
-
headers: addEndUserAuthHeader(request, user, {}),
|
|
137
|
+
headers: await addEndUserAuthHeader(request, user, {}),
|
|
138
138
|
})
|
|
139
139
|
}
|
|
140
140
|
|
|
@@ -166,9 +166,9 @@ describe('${fullyQualifiedControllerName}', () => {
|
|
|
166
166
|
})
|
|
167
167
|
|
|
168
168
|
describe('DELETE destroy', () => {
|
|
169
|
-
|
|
169
|
+
const subject = async (${modelVariableName}: ${modelClassName}, expectedStatus: number = 204) => {
|
|
170
170
|
return request.delete(\`/${route}/\${${modelVariableName}.id}\`, expectedStatus, {
|
|
171
|
-
headers: addEndUserAuthHeader(request, user, {}),
|
|
171
|
+
headers: await addEndUserAuthHeader(request, user, {}),
|
|
172
172
|
})
|
|
173
173
|
}
|
|
174
174
|
|
|
@@ -30,10 +30,8 @@ function createPsychicHttpInstance(app, sslCredentials) {
|
|
|
30
30
|
}
|
|
31
31
|
function welcomeMessage({ port }) {
|
|
32
32
|
if (!EnvInternal_js_1.default.isTest) {
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
dream_1.DreamCLI.logger.log(index_js_1.default.asciiLogo(), { permanent: true, logPrefix: '' });
|
|
36
|
-
spinner.stop();
|
|
33
|
+
dream_1.DreamCLI.logger.log('starting psychic server...');
|
|
34
|
+
dream_1.DreamCLI.logger.log(index_js_1.default.asciiLogo(), { logPrefix: '' });
|
|
37
35
|
dream_1.DreamCLI.logger.log(`psychic dev server started at port ${port}`);
|
|
38
36
|
}
|
|
39
37
|
}
|
|
@@ -26,9 +26,7 @@ export default class PsychicBin {
|
|
|
26
26
|
await DreamBin.sync(() => { });
|
|
27
27
|
await PsychicBin.syncTypes();
|
|
28
28
|
const psychicApp = PsychicApplication.getOrFail();
|
|
29
|
-
|
|
30
|
-
await PsychicBin.syncOpenapiJson();
|
|
31
|
-
}
|
|
29
|
+
await PsychicBin.syncOpenapiJson();
|
|
32
30
|
if (psychicApp.openapi?.syncEnumsToClient) {
|
|
33
31
|
await this.syncClientEnums();
|
|
34
32
|
}
|
|
@@ -48,29 +46,29 @@ export default class PsychicBin {
|
|
|
48
46
|
}
|
|
49
47
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
50
48
|
static async syncTypes(customTypes = undefined) {
|
|
51
|
-
|
|
49
|
+
DreamCLI.logger.logStartProgress(`syncing types/psychic.ts...`);
|
|
52
50
|
await TypesBuilder.sync(customTypes);
|
|
53
|
-
|
|
51
|
+
DreamCLI.logger.logEndProgress();
|
|
54
52
|
}
|
|
55
53
|
static async syncOpenapiJson() {
|
|
56
|
-
|
|
54
|
+
DreamCLI.logger.logStartProgress(`syncing openapi...`);
|
|
57
55
|
await OpenapiAppRenderer.sync();
|
|
58
|
-
|
|
56
|
+
DreamCLI.logger.logEndProgress();
|
|
59
57
|
}
|
|
60
58
|
static async syncRoutes() {
|
|
61
|
-
|
|
59
|
+
DreamCLI.logger.logStartProgress(`syncing routes...`);
|
|
62
60
|
const server = new PsychicServer();
|
|
63
61
|
await server.boot();
|
|
64
62
|
const routes = await server.routes();
|
|
65
63
|
await generateRouteTypes(routes);
|
|
66
|
-
|
|
64
|
+
DreamCLI.logger.logEndProgress();
|
|
67
65
|
}
|
|
68
66
|
static async syncClientEnums() {
|
|
69
|
-
|
|
67
|
+
DreamCLI.logger.logStartProgress(`syncing client enums...`);
|
|
70
68
|
const psychicApp = PsychicApplication.getOrFail();
|
|
71
69
|
const apiPath = path.join(psychicApp.clientRoot, psychicApp.client.apiPath);
|
|
72
70
|
const enumsStr = await enumsFileStr();
|
|
73
71
|
await fs.writeFile(`${apiPath}/enums.ts`, enumsStr);
|
|
74
|
-
|
|
72
|
+
DreamCLI.logger.logEndProgress();
|
|
75
73
|
}
|
|
76
74
|
}
|
|
@@ -37,7 +37,7 @@ export default function generateResourceControllerSpecContent({ fullyQualifiedCo
|
|
|
37
37
|
import { UpdateableProperties } from '@rvoh/dream'
|
|
38
38
|
import { PsychicServer } from '@rvoh/psychic'
|
|
39
39
|
import { specRequest as request } from '@rvoh/psychic-spec-helpers'${uniq(importStatements).join('')}
|
|
40
|
-
import
|
|
40
|
+
import addEndUserAuthHeader from '${specUnitUpdirs}helpers/authentication.js'
|
|
41
41
|
|
|
42
42
|
describe('${fullyQualifiedControllerName}', () => {
|
|
43
43
|
let user: User
|
|
@@ -48,9 +48,9 @@ describe('${fullyQualifiedControllerName}', () => {
|
|
|
48
48
|
})
|
|
49
49
|
|
|
50
50
|
describe('GET index', () => {
|
|
51
|
-
|
|
51
|
+
const subject = async (expectedStatus: number = 200) => {
|
|
52
52
|
return request.get('/${route}', expectedStatus, {
|
|
53
|
-
headers: addEndUserAuthHeader(request, user, {}),
|
|
53
|
+
headers: await addEndUserAuthHeader(request, user, {}),
|
|
54
54
|
})
|
|
55
55
|
}
|
|
56
56
|
|
|
@@ -78,9 +78,9 @@ describe('${fullyQualifiedControllerName}', () => {
|
|
|
78
78
|
})
|
|
79
79
|
|
|
80
80
|
describe('GET show', () => {
|
|
81
|
-
|
|
81
|
+
const subject = async (${modelVariableName}: ${modelClassName}, expectedStatus: number = 200) => {
|
|
82
82
|
return request.get(\`/${route}/\${${modelVariableName}.id}\`, expectedStatus, {
|
|
83
|
-
headers: addEndUserAuthHeader(request, user, {}),
|
|
83
|
+
headers: await addEndUserAuthHeader(request, user, {}),
|
|
84
84
|
})
|
|
85
85
|
}
|
|
86
86
|
|
|
@@ -106,10 +106,10 @@ describe('${fullyQualifiedControllerName}', () => {
|
|
|
106
106
|
})
|
|
107
107
|
|
|
108
108
|
describe('POST create', () => {
|
|
109
|
-
|
|
109
|
+
const subject = async (data: UpdateableProperties<${modelClassName}>, expectedStatus: number = 201) => {
|
|
110
110
|
return request.post('/${route}', expectedStatus, {
|
|
111
111
|
data,
|
|
112
|
-
headers: addEndUserAuthHeader(request, user, {}),
|
|
112
|
+
headers: await addEndUserAuthHeader(request, user, {}),
|
|
113
113
|
})
|
|
114
114
|
}
|
|
115
115
|
|
|
@@ -128,10 +128,10 @@ describe('${fullyQualifiedControllerName}', () => {
|
|
|
128
128
|
})
|
|
129
129
|
|
|
130
130
|
describe('PATCH update', () => {
|
|
131
|
-
|
|
131
|
+
const subject = async (${modelVariableName}: ${modelClassName}, data: UpdateableProperties<${modelClassName}>, expectedStatus: number = 204) => {
|
|
132
132
|
return request.patch(\`/${route}/\${${modelVariableName}.id}\`, expectedStatus, {
|
|
133
133
|
data,
|
|
134
|
-
headers: addEndUserAuthHeader(request, user, {}),
|
|
134
|
+
headers: await addEndUserAuthHeader(request, user, {}),
|
|
135
135
|
})
|
|
136
136
|
}
|
|
137
137
|
|
|
@@ -163,9 +163,9 @@ describe('${fullyQualifiedControllerName}', () => {
|
|
|
163
163
|
})
|
|
164
164
|
|
|
165
165
|
describe('DELETE destroy', () => {
|
|
166
|
-
|
|
166
|
+
const subject = async (${modelVariableName}: ${modelClassName}, expectedStatus: number = 204) => {
|
|
167
167
|
return request.delete(\`/${route}/\${${modelVariableName}.id}\`, expectedStatus, {
|
|
168
|
-
headers: addEndUserAuthHeader(request, user, {}),
|
|
168
|
+
headers: await addEndUserAuthHeader(request, user, {}),
|
|
169
169
|
})
|
|
170
170
|
}
|
|
171
171
|
|
|
@@ -26,10 +26,8 @@ export function createPsychicHttpInstance(app, sslCredentials) {
|
|
|
26
26
|
}
|
|
27
27
|
function welcomeMessage({ port }) {
|
|
28
28
|
if (!EnvInternal.isTest) {
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
DreamCLI.logger.log(PsychicServer.asciiLogo(), { permanent: true, logPrefix: '' });
|
|
32
|
-
spinner.stop();
|
|
29
|
+
DreamCLI.logger.log('starting psychic server...');
|
|
30
|
+
DreamCLI.logger.log(PsychicServer.asciiLogo(), { logPrefix: '' });
|
|
33
31
|
DreamCLI.logger.log(`psychic dev server started at port ${port}`);
|
|
34
32
|
}
|
|
35
33
|
}
|
package/package.json
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"type": "module",
|
|
3
3
|
"name": "@rvoh/psychic",
|
|
4
4
|
"description": "Typescript web framework",
|
|
5
|
-
"version": "0.26.
|
|
5
|
+
"version": "0.26.2",
|
|
6
6
|
"author": "RVOHealth",
|
|
7
7
|
"repository": "https://github.com/rvohealth/psychic.git",
|
|
8
8
|
"license": "MIT",
|
|
@@ -60,7 +60,7 @@
|
|
|
60
60
|
"devDependencies": {
|
|
61
61
|
"@eslint/js": "^9.19.0",
|
|
62
62
|
"@jest-mock/express": "^3.0.0",
|
|
63
|
-
"@rvoh/dream": "^0.31.
|
|
63
|
+
"@rvoh/dream": "^0.31.3",
|
|
64
64
|
"@rvoh/dream-spec-helpers": "=0.1.0",
|
|
65
65
|
"@rvoh/psychic-spec-helpers": "=0.2.0",
|
|
66
66
|
"@types/express": "^4.17.21",
|