@rvoh/psychic 0.25.0 → 0.26.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.
@@ -2,8 +2,8 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.default = generateController;
4
4
  const dream_1 = require("@rvoh/dream");
5
- const fs_1 = require("fs");
6
5
  const fs = require("fs/promises");
6
+ const node_fs_1 = require("node:fs");
7
7
  const EnvInternal_js_1 = require("../helpers/EnvInternal.js");
8
8
  const psychicFileAndDirPaths_js_1 = require("../helpers/path/psychicFileAndDirPaths.js");
9
9
  const psychicPath_js_1 = require("../helpers/path/psychicPath.js");
@@ -20,13 +20,13 @@ async function generateController({ fullyQualifiedControllerName, fullyQualified
20
20
  const isAdmin = allControllerNameParts[0] === 'Admin';
21
21
  const controllerNameParts = isAdmin ? [allControllerNameParts.shift()] : [];
22
22
  for (let index = 0; index < allControllerNameParts.length; index++) {
23
- if (controllerNameParts.length) {
23
+ if (controllerNameParts.length > (isAdmin ? 1 : 0)) {
24
24
  // Write the ancestor controller
25
25
  const [baseAncestorName, baseAncestorImportStatement] = baseAncestorNameAndImport(controllerNameParts, isAdmin, { forBaseController: true });
26
26
  const baseControllerName = [...controllerNameParts, 'BaseController'].join('/');
27
27
  const { absDirPath, absFilePath } = (0, psychicFileAndDirPaths_js_1.default)((0, psychicPath_js_1.default)('controllers'), baseControllerName + `.ts`);
28
28
  await fs.mkdir(absDirPath, { recursive: true });
29
- if (!(0, fs_1.existsSync)(absFilePath)) {
29
+ if (!(0, node_fs_1.existsSync)(absFilePath)) {
30
30
  await fs.writeFile(absFilePath, (0, generateControllerContent_js_1.default)({
31
31
  ancestorImportStatement: baseAncestorImportStatement,
32
32
  ancestorName: baseAncestorName,
@@ -59,7 +59,7 @@ describe('${fullyQualifiedControllerName}', () => {
59
59
 
60
60
  it('returns the index of ${fullyQualifiedModelName}s', async () => {
61
61
  const ${modelVariableName} = await create${modelClassName}({
62
- user${originalStringKeyValues.length ? ',\n ' + originalStringKeyValues.join(',\n ') : ''}
62
+ user${originalStringKeyValues.length ? ',\n ' + originalStringKeyValues.join('\n ') : ''}
63
63
  })
64
64
  const results = (await subject()).body
65
65
 
@@ -89,7 +89,7 @@ describe('${fullyQualifiedControllerName}', () => {
89
89
 
90
90
  it('returns the specified ${fullyQualifiedModelName}', async () => {
91
91
  const ${modelVariableName} = await create${modelClassName}({
92
- user${originalStringKeyValues.length ? ',\n ' + originalStringKeyValues.join(',\n ') : ''}
92
+ user${originalStringKeyValues.length ? ',\n ' + originalStringKeyValues.join('\n ') : ''}
93
93
  })
94
94
  const results = (await subject(${modelVariableName})).body
95
95
 
@@ -118,7 +118,7 @@ describe('${fullyQualifiedControllerName}', () => {
118
118
 
119
119
  it('creates a ${fullyQualifiedModelName} for this User', async () => {
120
120
  const results = (await subject({
121
- ${originalStringKeyValues.length ? originalStringKeyValues.join(',\n ') : ''}
121
+ ${originalStringKeyValues.length ? originalStringKeyValues.join('\n ') : ''}
122
122
  })).body
123
123
  const ${modelVariableName} = await ${modelClassName}.findOrFailBy({ userId: user.id })
124
124
 
@@ -140,10 +140,10 @@ describe('${fullyQualifiedControllerName}', () => {
140
140
 
141
141
  it('updates the ${fullyQualifiedModelName}', async () => {
142
142
  const ${modelVariableName} = await create${modelClassName}({
143
- user${originalStringKeyValues.length ? ',\n ' + originalStringKeyValues.join(',\n ') : ''}
143
+ user${originalStringKeyValues.length ? ',\n ' + originalStringKeyValues.join('\n ') : ''}
144
144
  })
145
145
  await subject(${modelVariableName}, {
146
- ${updatedStringKeyValues.length ? updatedStringKeyValues.join(',\n ') : ''}
146
+ ${updatedStringKeyValues.length ? updatedStringKeyValues.join('\n ') : ''}
147
147
  })
148
148
 
149
149
  await ${modelVariableName}.reload()
@@ -153,10 +153,10 @@ describe('${fullyQualifiedControllerName}', () => {
153
153
  context('a ${fullyQualifiedModelName} created by another User', () => {
154
154
  it('is not updated', async () => {
155
155
  const ${modelVariableName} = await create${modelClassName}({
156
- ${originalStringKeyValues.length ? originalStringKeyValues.join(',\n ') : ''}
156
+ ${originalStringKeyValues.length ? originalStringKeyValues.join('\n ') : ''}
157
157
  })
158
158
  await subject(${modelVariableName}, {
159
- ${updatedStringKeyValues.length ? updatedStringKeyValues.join(',\n ') : ''}
159
+ ${updatedStringKeyValues.length ? updatedStringKeyValues.join('\n ') : ''}
160
160
  }, 404)
161
161
 
162
162
  await ${modelVariableName}.reload()
@@ -2,10 +2,10 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.loadFile = loadFile;
4
4
  exports.writeFile = writeFile;
5
- const fs_1 = require("fs");
5
+ const node_fs_1 = require("node:fs");
6
6
  async function loadFile(filepath) {
7
- return await fs_1.promises.readFile(filepath);
7
+ return await node_fs_1.promises.readFile(filepath);
8
8
  }
9
9
  async function writeFile(filepath, contents) {
10
- return await fs_1.promises.writeFile(filepath, contents);
10
+ return await node_fs_1.promises.writeFile(filepath, contents);
11
11
  }
@@ -1,6 +1,6 @@
1
1
  import { hyphenize, standardizeFullyQualifiedModelName } from '@rvoh/dream';
2
- import { existsSync } from 'fs';
3
2
  import * as fs from 'fs/promises';
3
+ import { existsSync } from 'node:fs';
4
4
  import EnvInternal from '../helpers/EnvInternal.js';
5
5
  import psychicFileAndDirPaths from '../helpers/path/psychicFileAndDirPaths.js';
6
6
  import psychicPath from '../helpers/path/psychicPath.js';
@@ -17,7 +17,7 @@ export default async function generateController({ fullyQualifiedControllerName,
17
17
  const isAdmin = allControllerNameParts[0] === 'Admin';
18
18
  const controllerNameParts = isAdmin ? [allControllerNameParts.shift()] : [];
19
19
  for (let index = 0; index < allControllerNameParts.length; index++) {
20
- if (controllerNameParts.length) {
20
+ if (controllerNameParts.length > (isAdmin ? 1 : 0)) {
21
21
  // Write the ancestor controller
22
22
  const [baseAncestorName, baseAncestorImportStatement] = baseAncestorNameAndImport(controllerNameParts, isAdmin, { forBaseController: true });
23
23
  const baseControllerName = [...controllerNameParts, 'BaseController'].join('/');
@@ -56,7 +56,7 @@ describe('${fullyQualifiedControllerName}', () => {
56
56
 
57
57
  it('returns the index of ${fullyQualifiedModelName}s', async () => {
58
58
  const ${modelVariableName} = await create${modelClassName}({
59
- user${originalStringKeyValues.length ? ',\n ' + originalStringKeyValues.join(',\n ') : ''}
59
+ user${originalStringKeyValues.length ? ',\n ' + originalStringKeyValues.join('\n ') : ''}
60
60
  })
61
61
  const results = (await subject()).body
62
62
 
@@ -86,7 +86,7 @@ describe('${fullyQualifiedControllerName}', () => {
86
86
 
87
87
  it('returns the specified ${fullyQualifiedModelName}', async () => {
88
88
  const ${modelVariableName} = await create${modelClassName}({
89
- user${originalStringKeyValues.length ? ',\n ' + originalStringKeyValues.join(',\n ') : ''}
89
+ user${originalStringKeyValues.length ? ',\n ' + originalStringKeyValues.join('\n ') : ''}
90
90
  })
91
91
  const results = (await subject(${modelVariableName})).body
92
92
 
@@ -115,7 +115,7 @@ describe('${fullyQualifiedControllerName}', () => {
115
115
 
116
116
  it('creates a ${fullyQualifiedModelName} for this User', async () => {
117
117
  const results = (await subject({
118
- ${originalStringKeyValues.length ? originalStringKeyValues.join(',\n ') : ''}
118
+ ${originalStringKeyValues.length ? originalStringKeyValues.join('\n ') : ''}
119
119
  })).body
120
120
  const ${modelVariableName} = await ${modelClassName}.findOrFailBy({ userId: user.id })
121
121
 
@@ -137,10 +137,10 @@ describe('${fullyQualifiedControllerName}', () => {
137
137
 
138
138
  it('updates the ${fullyQualifiedModelName}', async () => {
139
139
  const ${modelVariableName} = await create${modelClassName}({
140
- user${originalStringKeyValues.length ? ',\n ' + originalStringKeyValues.join(',\n ') : ''}
140
+ user${originalStringKeyValues.length ? ',\n ' + originalStringKeyValues.join('\n ') : ''}
141
141
  })
142
142
  await subject(${modelVariableName}, {
143
- ${updatedStringKeyValues.length ? updatedStringKeyValues.join(',\n ') : ''}
143
+ ${updatedStringKeyValues.length ? updatedStringKeyValues.join('\n ') : ''}
144
144
  })
145
145
 
146
146
  await ${modelVariableName}.reload()
@@ -150,10 +150,10 @@ describe('${fullyQualifiedControllerName}', () => {
150
150
  context('a ${fullyQualifiedModelName} created by another User', () => {
151
151
  it('is not updated', async () => {
152
152
  const ${modelVariableName} = await create${modelClassName}({
153
- ${originalStringKeyValues.length ? originalStringKeyValues.join(',\n ') : ''}
153
+ ${originalStringKeyValues.length ? originalStringKeyValues.join('\n ') : ''}
154
154
  })
155
155
  await subject(${modelVariableName}, {
156
- ${updatedStringKeyValues.length ? updatedStringKeyValues.join(',\n ') : ''}
156
+ ${updatedStringKeyValues.length ? updatedStringKeyValues.join('\n ') : ''}
157
157
  }, 404)
158
158
 
159
159
  await ${modelVariableName}.reload()
@@ -1,4 +1,4 @@
1
- import { promises as fs } from 'fs';
1
+ import { promises as fs } from 'node:fs';
2
2
  export async function loadFile(filepath) {
3
3
  return await fs.readFile(filepath);
4
4
  }
@@ -1,4 +1,4 @@
1
- import PsychicApplication from '.';
1
+ import PsychicApplication from './index.js';
2
2
  export declare function cachePsychicApplication(psychicApp: PsychicApplication): void;
3
3
  export declare function getCachedPsychicApplication(): PsychicApplication | undefined;
4
4
  export declare function getCachedPsychicApplicationOrFail(): PsychicApplication;
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.25.0",
5
+ "version": "0.26.1",
6
6
  "author": "RVOHealth",
7
7
  "repository": "https://github.com/rvohealth/psychic.git",
8
8
  "license": "MIT",
@@ -21,7 +21,7 @@
21
21
  ],
22
22
  "scripts": {
23
23
  "client": "yarn --cwd=./client start",
24
- "psy": "yarn psyts",
24
+ "psy": "NODE_ENV=${NODE_ENV:-test} yarn psyts",
25
25
  "psyjs": "node ./dist/test-app/src/cli/index.js",
26
26
  "psyts": "NODE_ENV=${NODE_ENV:-test} tsx ./test-app/src/cli/index.ts",
27
27
  "psycore": "PSYCHIC_CORE_DEVELOPMENT=1 yarn psyts",
@@ -45,7 +45,6 @@
45
45
  "cors": "^2.8.5",
46
46
  "dotenv": "^16.4.5",
47
47
  "express-openapi-validator": "^5.4.3",
48
- "iso-datestring-validator": "^2.2.2",
49
48
  "lodash-es": "^4.17.21",
50
49
  "lodash.clonedeep": "^4.5.0",
51
50
  "lodash.groupby": "^4.6.0",
@@ -61,14 +60,13 @@
61
60
  "devDependencies": {
62
61
  "@eslint/js": "^9.19.0",
63
62
  "@jest-mock/express": "^3.0.0",
64
- "@rvoh/dream": "^0.30.3",
63
+ "@rvoh/dream": "^0.31.0",
65
64
  "@rvoh/dream-spec-helpers": "=0.1.0",
66
65
  "@rvoh/psychic-spec-helpers": "=0.2.0",
67
66
  "@types/express": "^4.17.21",
68
67
  "@types/lodash-es": "^4",
69
68
  "@types/lodash.clonedeep": "^4.5.9",
70
69
  "@types/lodash.sortby": "^4.7.9",
71
- "@types/luxon": "^3.4.2",
72
70
  "@types/node": "^22.5.1",
73
71
  "@types/pg": "^8.11.8",
74
72
  "@types/supertest": "^6.0.2",
@@ -78,7 +76,6 @@
78
76
  "kysely": "^0.27.4",
79
77
  "kysely-codegen": "~0.17.0",
80
78
  "lodash.sortby": "^4.7.0",
81
- "luxon": "^3.5.0",
82
79
  "luxon-jest-matchers": "^0.1.14",
83
80
  "pg": "^8.12.0",
84
81
  "prettier": "^3.3.3",
@@ -92,5 +89,5 @@
92
89
  "vitest": "^3.0.8",
93
90
  "winston": "^3.14.2"
94
91
  },
95
- "packageManager": "yarn@4.4.1"
92
+ "packageManager": "yarn@4.7.0"
96
93
  }