@rvoh/psychic 1.13.0 → 1.14.0-beta.1
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/generate/helpers/generateControllerContent.js +3 -4
- package/dist/cjs/src/generate/helpers/generateResourceControllerSpecContent.js +11 -14
- package/dist/esm/src/generate/helpers/generateControllerContent.js +4 -5
- package/dist/esm/src/generate/helpers/generateResourceControllerSpecContent.js +12 -15
- package/package.json +2 -2
|
@@ -6,7 +6,6 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
6
6
|
exports.default = generateControllerContent;
|
|
7
7
|
const dream_1 = require("@rvoh/dream");
|
|
8
8
|
const pluralize_esm_1 = __importDefault(require("pluralize-esm"));
|
|
9
|
-
const relativePsychicPath_js_1 = __importDefault(require("../../helpers/path/relativePsychicPath.js"));
|
|
10
9
|
function generateControllerContent({ ancestorName, ancestorImportStatement, fullyQualifiedControllerName, fullyQualifiedModelName, actions = [], omitOpenApi = false, owningModel, forAdmin, singular, }) {
|
|
11
10
|
fullyQualifiedControllerName = (0, dream_1.standardizeFullyQualifiedModelName)(fullyQualifiedControllerName);
|
|
12
11
|
const additionalImports = [];
|
|
@@ -23,7 +22,7 @@ function generateControllerContent({ ancestorName, ancestorImportStatement, full
|
|
|
23
22
|
modelClassName = (0, dream_1.globalClassNameFromFullyQualifiedModelName)(fullyQualifiedModelName);
|
|
24
23
|
modelAttributeName = (0, dream_1.camelize)(modelClassName);
|
|
25
24
|
pluralizedModelAttributeName = singular ? modelAttributeName : (0, pluralize_esm_1.default)(modelAttributeName);
|
|
26
|
-
additionalImports.push(importStatementForModel(
|
|
25
|
+
additionalImports.push(importStatementForModel(fullyQualifiedModelName));
|
|
27
26
|
}
|
|
28
27
|
const defaultOpenapiSerializerKeyProperty = forAdmin
|
|
29
28
|
? `
|
|
@@ -197,8 +196,8 @@ function loadModelStatement(forAdmin, modelClassName, loadQueryBase, singular) {
|
|
|
197
196
|
// ${singular ? '.firstOrFail()' : ".findOrFail(this.castParam('id', 'string'))"}
|
|
198
197
|
}`;
|
|
199
198
|
}
|
|
200
|
-
function importStatementForModel(
|
|
201
|
-
return `import ${(0, dream_1.globalClassNameFromFullyQualifiedModelName)(destinationModelName)} from '${(0,
|
|
199
|
+
function importStatementForModel(destinationModelName) {
|
|
200
|
+
return `import ${(0, dream_1.globalClassNameFromFullyQualifiedModelName)(destinationModelName)} from '${(0, dream_1.absoluteDreamPath)('models', destinationModelName)}'`;
|
|
202
201
|
}
|
|
203
202
|
function aOrAnDreamModelName(dreamName) {
|
|
204
203
|
if (/^[aeiou]/.test(dreamName))
|
|
@@ -6,8 +6,6 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
6
6
|
exports.default = generateResourceControllerSpecContent;
|
|
7
7
|
const dream_1 = require("@rvoh/dream");
|
|
8
8
|
const addImportSuffix_js_1 = __importDefault(require("../../helpers/path/addImportSuffix.js"));
|
|
9
|
-
const relativePsychicPath_js_1 = __importDefault(require("../../helpers/path/relativePsychicPath.js"));
|
|
10
|
-
const updirsFromPath_js_1 = __importDefault(require("../../helpers/path/updirsFromPath.js"));
|
|
11
9
|
const index_js_1 = require("../../index.js");
|
|
12
10
|
function generateResourceControllerSpecContent({ fullyQualifiedControllerName, route, fullyQualifiedModelName, columnsWithTypes, owningModel, forAdmin, singular, actions, }) {
|
|
13
11
|
fullyQualifiedModelName = (0, dream_1.standardizeFullyQualifiedModelName)(fullyQualifiedModelName);
|
|
@@ -23,14 +21,13 @@ function generateResourceControllerSpecContent({ fullyQualifiedControllerName, r
|
|
|
23
21
|
const owningModelVariableName = owningModelName ? (0, dream_1.camelize)(owningModelName) : userVariableName;
|
|
24
22
|
const dreamImports = [];
|
|
25
23
|
const importStatements = (0, dream_1.compact)([
|
|
26
|
-
importStatementForModel(
|
|
27
|
-
importStatementForModel(
|
|
28
|
-
owningModel ? importStatementForModel(
|
|
29
|
-
importStatementForModelFactory(
|
|
30
|
-
importStatementForModelFactory(
|
|
31
|
-
owningModel ? importStatementForModelFactory(
|
|
24
|
+
importStatementForModel(fullyQualifiedModelName),
|
|
25
|
+
importStatementForModel(userModelName),
|
|
26
|
+
owningModel ? importStatementForModel(owningModel) : undefined,
|
|
27
|
+
importStatementForModelFactory(fullyQualifiedModelName),
|
|
28
|
+
importStatementForModelFactory(userModelName),
|
|
29
|
+
owningModel ? importStatementForModelFactory(owningModel) : undefined,
|
|
32
30
|
]);
|
|
33
|
-
const specUnitUpdirs = (0, updirsFromPath_js_1.default)(fullyQualifiedControllerName);
|
|
34
31
|
const attributeCreationKeyValues = [];
|
|
35
32
|
const attributeUpdateKeyValues = [];
|
|
36
33
|
const comparableOriginalAttributeKeyValues = [];
|
|
@@ -132,7 +129,7 @@ function generateResourceControllerSpecContent({ fullyQualifiedControllerName, r
|
|
|
132
129
|
const omitUpdate = !actions.includes('update');
|
|
133
130
|
const omitDestroy = !actions.includes('destroy');
|
|
134
131
|
return `${dreamImports.length ? `import { ${(0, dream_1.uniq)(dreamImports).join(', ')} } from '@rvoh/dream'\n` : ''}${(0, dream_1.uniq)(importStatements).join('\n')}
|
|
135
|
-
import { RequestBody, session, SpecRequestType } from '
|
|
132
|
+
import { RequestBody, session, SpecRequestType } from '@spec/helpers/${(0, addImportSuffix_js_1.default)('authentication.js')}'
|
|
136
133
|
|
|
137
134
|
describe('${fullyQualifiedControllerName}', () => {
|
|
138
135
|
let request: SpecRequestType
|
|
@@ -346,11 +343,11 @@ describe('${fullyQualifiedControllerName}', () => {
|
|
|
346
343
|
})
|
|
347
344
|
`;
|
|
348
345
|
}
|
|
349
|
-
function importStatementForModel(
|
|
350
|
-
return `import ${(0, dream_1.globalClassNameFromFullyQualifiedModelName)(destinationModelName)} from '${(0,
|
|
346
|
+
function importStatementForModel(destinationModelName) {
|
|
347
|
+
return `import ${(0, dream_1.globalClassNameFromFullyQualifiedModelName)(destinationModelName)} from '${(0, dream_1.absoluteDreamPath)('models', destinationModelName)}'`;
|
|
351
348
|
}
|
|
352
|
-
function importStatementForModelFactory(
|
|
353
|
-
return `import create${(0, dream_1.globalClassNameFromFullyQualifiedModelName)(destinationModelName)} from '${(0,
|
|
349
|
+
function importStatementForModelFactory(destinationModelName) {
|
|
350
|
+
return `import create${(0, dream_1.globalClassNameFromFullyQualifiedModelName)(destinationModelName)} from '${(0, dream_1.absoluteDreamPath)('factories', destinationModelName)}'`;
|
|
354
351
|
}
|
|
355
352
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
356
353
|
function jsonify(val) {
|
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
import { camelize, globalClassNameFromFullyQualifiedModelName, hyphenize, standardizeFullyQualifiedModelName, } from '@rvoh/dream';
|
|
1
|
+
import { absoluteDreamPath, camelize, globalClassNameFromFullyQualifiedModelName, hyphenize, standardizeFullyQualifiedModelName, } from '@rvoh/dream';
|
|
2
2
|
import pluralize from 'pluralize-esm';
|
|
3
|
-
import relativePsychicPath from '../../helpers/path/relativePsychicPath.js';
|
|
4
3
|
export default function generateControllerContent({ ancestorName, ancestorImportStatement, fullyQualifiedControllerName, fullyQualifiedModelName, actions = [], omitOpenApi = false, owningModel, forAdmin, singular, }) {
|
|
5
4
|
fullyQualifiedControllerName = standardizeFullyQualifiedModelName(fullyQualifiedControllerName);
|
|
6
5
|
const additionalImports = [];
|
|
@@ -17,7 +16,7 @@ export default function generateControllerContent({ ancestorName, ancestorImport
|
|
|
17
16
|
modelClassName = globalClassNameFromFullyQualifiedModelName(fullyQualifiedModelName);
|
|
18
17
|
modelAttributeName = camelize(modelClassName);
|
|
19
18
|
pluralizedModelAttributeName = singular ? modelAttributeName : pluralize(modelAttributeName);
|
|
20
|
-
additionalImports.push(importStatementForModel(
|
|
19
|
+
additionalImports.push(importStatementForModel(fullyQualifiedModelName));
|
|
21
20
|
}
|
|
22
21
|
const defaultOpenapiSerializerKeyProperty = forAdmin
|
|
23
22
|
? `
|
|
@@ -191,8 +190,8 @@ function loadModelStatement(forAdmin, modelClassName, loadQueryBase, singular) {
|
|
|
191
190
|
// ${singular ? '.firstOrFail()' : ".findOrFail(this.castParam('id', 'string'))"}
|
|
192
191
|
}`;
|
|
193
192
|
}
|
|
194
|
-
function importStatementForModel(
|
|
195
|
-
return `import ${globalClassNameFromFullyQualifiedModelName(destinationModelName)} from '${
|
|
193
|
+
function importStatementForModel(destinationModelName) {
|
|
194
|
+
return `import ${globalClassNameFromFullyQualifiedModelName(destinationModelName)} from '${absoluteDreamPath('models', destinationModelName)}'`;
|
|
196
195
|
}
|
|
197
196
|
function aOrAnDreamModelName(dreamName) {
|
|
198
197
|
if (/^[aeiou]/.test(dreamName))
|
|
@@ -1,7 +1,5 @@
|
|
|
1
|
-
import { camelize, capitalize, compact, globalClassNameFromFullyQualifiedModelName, standardizeFullyQualifiedModelName, uniq, } from '@rvoh/dream';
|
|
1
|
+
import { absoluteDreamPath, camelize, capitalize, compact, globalClassNameFromFullyQualifiedModelName, standardizeFullyQualifiedModelName, uniq, } from '@rvoh/dream';
|
|
2
2
|
import addImportSuffix from '../../helpers/path/addImportSuffix.js';
|
|
3
|
-
import relativePsychicPath from '../../helpers/path/relativePsychicPath.js';
|
|
4
|
-
import updirsFromPath from '../../helpers/path/updirsFromPath.js';
|
|
5
3
|
import { pluralize } from '../../index.js';
|
|
6
4
|
export default function generateResourceControllerSpecContent({ fullyQualifiedControllerName, route, fullyQualifiedModelName, columnsWithTypes, owningModel, forAdmin, singular, actions, }) {
|
|
7
5
|
fullyQualifiedModelName = standardizeFullyQualifiedModelName(fullyQualifiedModelName);
|
|
@@ -17,14 +15,13 @@ export default function generateResourceControllerSpecContent({ fullyQualifiedCo
|
|
|
17
15
|
const owningModelVariableName = owningModelName ? camelize(owningModelName) : userVariableName;
|
|
18
16
|
const dreamImports = [];
|
|
19
17
|
const importStatements = compact([
|
|
20
|
-
importStatementForModel(
|
|
21
|
-
importStatementForModel(
|
|
22
|
-
owningModel ? importStatementForModel(
|
|
23
|
-
importStatementForModelFactory(
|
|
24
|
-
importStatementForModelFactory(
|
|
25
|
-
owningModel ? importStatementForModelFactory(
|
|
18
|
+
importStatementForModel(fullyQualifiedModelName),
|
|
19
|
+
importStatementForModel(userModelName),
|
|
20
|
+
owningModel ? importStatementForModel(owningModel) : undefined,
|
|
21
|
+
importStatementForModelFactory(fullyQualifiedModelName),
|
|
22
|
+
importStatementForModelFactory(userModelName),
|
|
23
|
+
owningModel ? importStatementForModelFactory(owningModel) : undefined,
|
|
26
24
|
]);
|
|
27
|
-
const specUnitUpdirs = updirsFromPath(fullyQualifiedControllerName);
|
|
28
25
|
const attributeCreationKeyValues = [];
|
|
29
26
|
const attributeUpdateKeyValues = [];
|
|
30
27
|
const comparableOriginalAttributeKeyValues = [];
|
|
@@ -126,7 +123,7 @@ export default function generateResourceControllerSpecContent({ fullyQualifiedCo
|
|
|
126
123
|
const omitUpdate = !actions.includes('update');
|
|
127
124
|
const omitDestroy = !actions.includes('destroy');
|
|
128
125
|
return `${dreamImports.length ? `import { ${uniq(dreamImports).join(', ')} } from '@rvoh/dream'\n` : ''}${uniq(importStatements).join('\n')}
|
|
129
|
-
import { RequestBody, session, SpecRequestType } from '
|
|
126
|
+
import { RequestBody, session, SpecRequestType } from '@spec/helpers/${addImportSuffix('authentication.js')}'
|
|
130
127
|
|
|
131
128
|
describe('${fullyQualifiedControllerName}', () => {
|
|
132
129
|
let request: SpecRequestType
|
|
@@ -340,11 +337,11 @@ describe('${fullyQualifiedControllerName}', () => {
|
|
|
340
337
|
})
|
|
341
338
|
`;
|
|
342
339
|
}
|
|
343
|
-
function importStatementForModel(
|
|
344
|
-
return `import ${globalClassNameFromFullyQualifiedModelName(destinationModelName)} from '${
|
|
340
|
+
function importStatementForModel(destinationModelName) {
|
|
341
|
+
return `import ${globalClassNameFromFullyQualifiedModelName(destinationModelName)} from '${absoluteDreamPath('models', destinationModelName)}'`;
|
|
345
342
|
}
|
|
346
|
-
function importStatementForModelFactory(
|
|
347
|
-
return `import create${globalClassNameFromFullyQualifiedModelName(destinationModelName)} from '${
|
|
343
|
+
function importStatementForModelFactory(destinationModelName) {
|
|
344
|
+
return `import create${globalClassNameFromFullyQualifiedModelName(destinationModelName)} from '${absoluteDreamPath('factories', destinationModelName)}'`;
|
|
348
345
|
}
|
|
349
346
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
350
347
|
function jsonify(val) {
|
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": "1.
|
|
5
|
+
"version": "1.14.0-beta.1",
|
|
6
6
|
"author": "RVOHealth",
|
|
7
7
|
"repository": {
|
|
8
8
|
"type": "git",
|
|
@@ -63,7 +63,7 @@
|
|
|
63
63
|
"devDependencies": {
|
|
64
64
|
"@eslint/js": "^9.19.0",
|
|
65
65
|
"@jest-mock/express": "^3.0.0",
|
|
66
|
-
"@rvoh/dream": "^1.
|
|
66
|
+
"@rvoh/dream": "^1.13.0-beta.1",
|
|
67
67
|
"@rvoh/dream-spec-helpers": "^1.2.1",
|
|
68
68
|
"@rvoh/psychic-spec-helpers": "^1.1.6",
|
|
69
69
|
"@types/express": "^5.0.1",
|