@rvoh/psychic 0.34.0 → 0.34.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/cli/index.js +1 -14
- package/dist/cjs/src/generate/initializer/syncEnums.js +2 -9
- package/dist/cjs/src/psychic-app/index.js +3 -7
- package/dist/esm/src/cli/index.js +1 -14
- package/dist/esm/src/generate/initializer/syncEnums.js +2 -9
- package/dist/esm/src/psychic-app/index.js +3 -7
- package/dist/types/src/cli/index.d.ts +1 -1
- package/dist/types/src/psychic-app/index.d.ts +0 -1
- package/dist/types/src/psychic-app/types.d.ts +2 -2
- package/package.json +1 -1
|
@@ -6,10 +6,9 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
6
6
|
const dream_1 = require("@rvoh/dream");
|
|
7
7
|
const index_js_1 = __importDefault(require("../bin/index.js"));
|
|
8
8
|
const reduxBindings_js_1 = __importDefault(require("../generate/openapi/reduxBindings.js"));
|
|
9
|
-
const index_js_2 = __importDefault(require("../psychic-app/index.js"));
|
|
10
9
|
const syncEnums_js_1 = __importDefault(require("../generate/initializer/syncEnums.js"));
|
|
11
10
|
class PsychicCLI {
|
|
12
|
-
static
|
|
11
|
+
static provide(program, { initializePsychicApp, seedDb, }) {
|
|
13
12
|
dream_1.DreamCLI.generateDreamCli(program, {
|
|
14
13
|
initializeDreamApp: initializePsychicApp,
|
|
15
14
|
seedDb,
|
|
@@ -109,18 +108,6 @@ class PsychicCLI {
|
|
|
109
108
|
await index_js_1.default.syncOpenapiJson();
|
|
110
109
|
process.exit();
|
|
111
110
|
});
|
|
112
|
-
program
|
|
113
|
-
.command('sync:client:enums')
|
|
114
|
-
.argument('<outfile>', 'the path from your backend directory to the location which you want the enums copied. Should end with .ts, i.e. "../client/src/api/enums.ts"')
|
|
115
|
-
.description('syncs your backend enums to a location of your choosing')
|
|
116
|
-
.action(async (outfile) => {
|
|
117
|
-
await initializePsychicApp();
|
|
118
|
-
await index_js_1.default.syncClientEnums(outfile);
|
|
119
|
-
process.exit();
|
|
120
|
-
});
|
|
121
|
-
for (const hook of index_js_2.default.getOrFail().specialHooks.cliStart) {
|
|
122
|
-
await hook(program);
|
|
123
|
-
}
|
|
124
111
|
}
|
|
125
112
|
}
|
|
126
113
|
exports.default = PsychicCLI;
|
|
@@ -30,7 +30,6 @@ exports.default = generateSyncEnumsInitializer;
|
|
|
30
30
|
const dream_1 = require("@rvoh/dream");
|
|
31
31
|
const fs = __importStar(require("node:fs/promises"));
|
|
32
32
|
const path = __importStar(require("node:path"));
|
|
33
|
-
const PackageManager_js_1 = __importDefault(require("../../cli/helpers/PackageManager.js"));
|
|
34
33
|
const psychicPath_js_1 = __importDefault(require("../../helpers/path/psychicPath.js"));
|
|
35
34
|
async function generateSyncEnumsInitializer(outfile, initializerFilename = 'sync-enums.ts') {
|
|
36
35
|
const initializerFilenameWithoutExtension = initializerFilename.replace(/\.ts$/, '');
|
|
@@ -52,20 +51,14 @@ async function generateSyncEnumsInitializer(outfile, initializerFilename = 'sync
|
|
|
52
51
|
}
|
|
53
52
|
const contents = `\
|
|
54
53
|
import { DreamCLI } from '@rvoh/dream'
|
|
55
|
-
import { PsychicApp } from
|
|
54
|
+
import { PsychicApp, PsychicBin } from "@rvoh/psychic"
|
|
56
55
|
import AppEnv from '../AppEnv.js'
|
|
57
56
|
|
|
58
57
|
export default function ${camelized}(psy: PsychicApp) {
|
|
59
58
|
psy.on('sync', async () => {
|
|
60
59
|
if (AppEnv.isDevelopmentOrTest) {
|
|
61
60
|
DreamCLI.logger.logStartProgress(\`[${camelized}] syncing enums to ${outfile}...\`)
|
|
62
|
-
await
|
|
63
|
-
onStdout: message => {
|
|
64
|
-
DreamCLI.logger.logContinueProgress(\`[${camelized}]\` + ' ' + message, {
|
|
65
|
-
logPrefixColor: 'green',
|
|
66
|
-
})
|
|
67
|
-
},
|
|
68
|
-
})
|
|
61
|
+
await PsychicBin.syncClientEnums('${outfile}')
|
|
69
62
|
DreamCLI.logger.logEndProgress()
|
|
70
63
|
}
|
|
71
64
|
})
|
|
@@ -71,12 +71,12 @@ class PsychicApp {
|
|
|
71
71
|
}
|
|
72
72
|
}
|
|
73
73
|
});
|
|
74
|
-
for (const plugin of psychicApp.plugins) {
|
|
75
|
-
await plugin(psychicApp);
|
|
76
|
-
}
|
|
77
74
|
for (const initializerCb of Object.values(PsychicApp.getInitializersOrBlank())) {
|
|
78
75
|
await initializerCb(psychicApp);
|
|
79
76
|
}
|
|
77
|
+
for (const plugin of psychicApp.plugins) {
|
|
78
|
+
await plugin(psychicApp);
|
|
79
|
+
}
|
|
80
80
|
(0, cache_js_1.cachePsychicApp)(psychicApp);
|
|
81
81
|
});
|
|
82
82
|
return psychicApp;
|
|
@@ -237,7 +237,6 @@ Try setting it to something valid, like:
|
|
|
237
237
|
serverStart: [],
|
|
238
238
|
serverError: [],
|
|
239
239
|
serverShutdown: [],
|
|
240
|
-
cliStart: [],
|
|
241
240
|
};
|
|
242
241
|
get specialHooks() {
|
|
243
242
|
return this._specialHooks;
|
|
@@ -333,9 +332,6 @@ Try setting it to something valid, like:
|
|
|
333
332
|
case 'server:init:after-routes':
|
|
334
333
|
this._specialHooks.serverInitAfterRoutes.push(cb);
|
|
335
334
|
break;
|
|
336
|
-
case 'cli:start':
|
|
337
|
-
this._specialHooks.cliStart.push(cb);
|
|
338
|
-
break;
|
|
339
335
|
case 'sync':
|
|
340
336
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
341
337
|
this._specialHooks['sync'].push(cb);
|
|
@@ -1,10 +1,9 @@
|
|
|
1
1
|
import { DreamCLI } from '@rvoh/dream';
|
|
2
2
|
import PsychicBin from '../bin/index.js';
|
|
3
3
|
import generateOpenapiReduxBindings from '../generate/openapi/reduxBindings.js';
|
|
4
|
-
import PsychicApp from '../psychic-app/index.js';
|
|
5
4
|
import generateSyncEnumsInitializer from '../generate/initializer/syncEnums.js';
|
|
6
5
|
export default class PsychicCLI {
|
|
7
|
-
static
|
|
6
|
+
static provide(program, { initializePsychicApp, seedDb, }) {
|
|
8
7
|
DreamCLI.generateDreamCli(program, {
|
|
9
8
|
initializeDreamApp: initializePsychicApp,
|
|
10
9
|
seedDb,
|
|
@@ -104,17 +103,5 @@ export default class PsychicCLI {
|
|
|
104
103
|
await PsychicBin.syncOpenapiJson();
|
|
105
104
|
process.exit();
|
|
106
105
|
});
|
|
107
|
-
program
|
|
108
|
-
.command('sync:client:enums')
|
|
109
|
-
.argument('<outfile>', 'the path from your backend directory to the location which you want the enums copied. Should end with .ts, i.e. "../client/src/api/enums.ts"')
|
|
110
|
-
.description('syncs your backend enums to a location of your choosing')
|
|
111
|
-
.action(async (outfile) => {
|
|
112
|
-
await initializePsychicApp();
|
|
113
|
-
await PsychicBin.syncClientEnums(outfile);
|
|
114
|
-
process.exit();
|
|
115
|
-
});
|
|
116
|
-
for (const hook of PsychicApp.getOrFail().specialHooks.cliStart) {
|
|
117
|
-
await hook(program);
|
|
118
|
-
}
|
|
119
106
|
}
|
|
120
107
|
}
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { camelize } from '@rvoh/dream';
|
|
2
2
|
import * as fs from 'node:fs/promises';
|
|
3
3
|
import * as path from 'node:path';
|
|
4
|
-
import PackageManager from '../../cli/helpers/PackageManager.js';
|
|
5
4
|
import psychicPath from '../../helpers/path/psychicPath.js';
|
|
6
5
|
export default async function generateSyncEnumsInitializer(outfile, initializerFilename = 'sync-enums.ts') {
|
|
7
6
|
const initializerFilenameWithoutExtension = initializerFilename.replace(/\.ts$/, '');
|
|
@@ -23,20 +22,14 @@ export default async function generateSyncEnumsInitializer(outfile, initializerF
|
|
|
23
22
|
}
|
|
24
23
|
const contents = `\
|
|
25
24
|
import { DreamCLI } from '@rvoh/dream'
|
|
26
|
-
import { PsychicApp } from
|
|
25
|
+
import { PsychicApp, PsychicBin } from "@rvoh/psychic"
|
|
27
26
|
import AppEnv from '../AppEnv.js'
|
|
28
27
|
|
|
29
28
|
export default function ${camelized}(psy: PsychicApp) {
|
|
30
29
|
psy.on('sync', async () => {
|
|
31
30
|
if (AppEnv.isDevelopmentOrTest) {
|
|
32
31
|
DreamCLI.logger.logStartProgress(\`[${camelized}] syncing enums to ${outfile}...\`)
|
|
33
|
-
await
|
|
34
|
-
onStdout: message => {
|
|
35
|
-
DreamCLI.logger.logContinueProgress(\`[${camelized}]\` + ' ' + message, {
|
|
36
|
-
logPrefixColor: 'green',
|
|
37
|
-
})
|
|
38
|
-
},
|
|
39
|
-
})
|
|
32
|
+
await PsychicBin.syncClientEnums('${outfile}')
|
|
40
33
|
DreamCLI.logger.logEndProgress()
|
|
41
34
|
}
|
|
42
35
|
})
|
|
@@ -42,12 +42,12 @@ export default class PsychicApp {
|
|
|
42
42
|
}
|
|
43
43
|
}
|
|
44
44
|
});
|
|
45
|
-
for (const plugin of psychicApp.plugins) {
|
|
46
|
-
await plugin(psychicApp);
|
|
47
|
-
}
|
|
48
45
|
for (const initializerCb of Object.values(PsychicApp.getInitializersOrBlank())) {
|
|
49
46
|
await initializerCb(psychicApp);
|
|
50
47
|
}
|
|
48
|
+
for (const plugin of psychicApp.plugins) {
|
|
49
|
+
await plugin(psychicApp);
|
|
50
|
+
}
|
|
51
51
|
cachePsychicApp(psychicApp);
|
|
52
52
|
});
|
|
53
53
|
return psychicApp;
|
|
@@ -208,7 +208,6 @@ Try setting it to something valid, like:
|
|
|
208
208
|
serverStart: [],
|
|
209
209
|
serverError: [],
|
|
210
210
|
serverShutdown: [],
|
|
211
|
-
cliStart: [],
|
|
212
211
|
};
|
|
213
212
|
get specialHooks() {
|
|
214
213
|
return this._specialHooks;
|
|
@@ -304,9 +303,6 @@ Try setting it to something valid, like:
|
|
|
304
303
|
case 'server:init:after-routes':
|
|
305
304
|
this._specialHooks.serverInitAfterRoutes.push(cb);
|
|
306
305
|
break;
|
|
307
|
-
case 'cli:start':
|
|
308
|
-
this._specialHooks.cliStart.push(cb);
|
|
309
|
-
break;
|
|
310
306
|
case 'sync':
|
|
311
307
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
312
308
|
this._specialHooks['sync'].push(cb);
|
|
@@ -109,7 +109,6 @@ export interface PsychicAppSpecialHooks {
|
|
|
109
109
|
serverStart: ((server: PsychicServer) => void | Promise<void>)[];
|
|
110
110
|
serverShutdown: ((server: PsychicServer) => void | Promise<void>)[];
|
|
111
111
|
serverError: ((err: Error, req: Request, res: Response) => void | Promise<void>)[];
|
|
112
|
-
cliStart: ((program: Command) => void | Promise<void>)[];
|
|
113
112
|
}
|
|
114
113
|
export interface PsychicAppOverrides {
|
|
115
114
|
['server:start']: ((psychicServer: PsychicServer, opts: PsychicServerStartProviderOptions) => http.Server | Promise<http.Server>) | null;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import PsychicApp from './index.js';
|
|
2
2
|
export type UUID = string;
|
|
3
|
-
export type PsychicHookEventType = 'boot' | 'sync' | 'load' | 'load:dev' | 'load:prod' | 'load:test' | 'server:init' | 'server:init:after-routes' | 'server:start' | 'server:error' | 'server:shutdown'
|
|
4
|
-
export type PsychicHookLoadEventTypes = Exclude<PsychicHookEventType, 'server:error' | 'server:init' | 'server:init:after-routes' | 'server:start' | 'server:shutdown' | 'sync'
|
|
3
|
+
export type PsychicHookEventType = 'boot' | 'sync' | 'load' | 'load:dev' | 'load:prod' | 'load:test' | 'server:init' | 'server:init:after-routes' | 'server:start' | 'server:error' | 'server:shutdown';
|
|
4
|
+
export type PsychicHookLoadEventTypes = Exclude<PsychicHookEventType, 'server:error' | 'server:init' | 'server:init:after-routes' | 'server:start' | 'server:shutdown' | 'sync'>;
|
|
5
5
|
export type PsychicAppInitializerCb = (psychicApp: PsychicApp) => void | Promise<void>;
|
|
6
6
|
type Only<T, U> = T & Partial<Record<Exclude<keyof U, keyof T>, never>>;
|
|
7
7
|
export type Either<T, U> = Only<T, U> | Only<U, T>;
|