miqro 1.9.3 → 3.0.0

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.
Files changed (75) hide show
  1. package/README.md +18 -37
  2. package/build/cli.js +6 -0
  3. package/build/cmd-map.d.ts +79 -0
  4. package/{dist/cli.js → build/cmd-map.js} +21 -43
  5. package/build/cmds/doc-json.d.ts +2 -0
  6. package/build/cmds/doc-json.js +17 -0
  7. package/build/cmds/doc-md.d.ts +2 -0
  8. package/{dist/cmds/doc-json.js → build/cmds/doc-md.js} +6 -5
  9. package/{dist → build}/cmds/handler-main-new.js +21 -15
  10. package/build/cmds/help.d.ts +1 -0
  11. package/build/cmds/help.js +9 -0
  12. package/{dist → build}/cmds/new-test.js +13 -2
  13. package/{dist → build}/cmds/new.js +20 -15
  14. package/{dist → build}/cmds/serve.d.ts +1 -1
  15. package/{dist → build}/cmds/serve.js +12 -7
  16. package/{dist → build}/cmds/start.d.ts +1 -1
  17. package/{dist → build}/cmds/start.js +1 -1
  18. package/build/utils/doc/json.d.ts +6 -0
  19. package/build/utils/doc/json.js +15 -0
  20. package/build/utils/doc/md.d.ts +18 -0
  21. package/build/utils/doc/md.js +129 -0
  22. package/{dist → build}/utils/index.d.ts +8 -5
  23. package/{dist → build}/utils/index.js +20 -14
  24. package/package.json +15 -16
  25. package/dist/cmds/db-console.d.ts +0 -2
  26. package/dist/cmds/db-console.js +0 -38
  27. package/dist/cmds/db-createmodel.d.ts +0 -2
  28. package/dist/cmds/db-createmodel.js +0 -37
  29. package/dist/cmds/db-dump-data.d.ts +0 -2
  30. package/dist/cmds/db-dump-data.js +0 -43
  31. package/dist/cmds/db-init.d.ts +0 -2
  32. package/dist/cmds/db-init.js +0 -38
  33. package/dist/cmds/db-makemigrations.d.ts +0 -2
  34. package/dist/cmds/db-makemigrations.js +0 -14
  35. package/dist/cmds/db-migrate.d.ts +0 -2
  36. package/dist/cmds/db-migrate.js +0 -12
  37. package/dist/cmds/db-push-data.d.ts +0 -2
  38. package/dist/cmds/db-push-data.js +0 -79
  39. package/dist/cmds/db-sync-makemigrations.d.ts +0 -2
  40. package/dist/cmds/db-sync-makemigrations.js +0 -14
  41. package/dist/cmds/doc-json.d.ts +0 -2
  42. package/dist/cmds/doc-md.d.ts +0 -2
  43. package/dist/cmds/doc-md.js +0 -234
  44. package/dist/cmds/test.d.ts +0 -2
  45. package/dist/cmds/test.js +0 -15
  46. package/dist/utils/db/automigrations/index.d.ts +0 -2
  47. package/dist/utils/db/automigrations/index.js +0 -121
  48. package/dist/utils/db/automigrations/migrate.d.ts +0 -45
  49. package/dist/utils/db/automigrations/migrate.js +0 -750
  50. package/dist/utils/db/index.d.ts +0 -20
  51. package/dist/utils/db/index.js +0 -127
  52. package/dist/utils/doc/index.d.ts +0 -18
  53. package/dist/utils/doc/index.js +0 -36
  54. /package/{dist → build}/cli.d.ts +0 -0
  55. /package/{dist → build}/cmds/config-bash.d.ts +0 -0
  56. /package/{dist → build}/cmds/config-bash.js +0 -0
  57. /package/{dist → build}/cmds/config-env.d.ts +0 -0
  58. /package/{dist → build}/cmds/config-env.js +0 -0
  59. /package/{dist → build}/cmds/config-init.d.ts +0 -0
  60. /package/{dist → build}/cmds/config-init.js +0 -0
  61. /package/{dist → build}/cmds/config.d.ts +0 -0
  62. /package/{dist → build}/cmds/config.js +0 -0
  63. /package/{dist → build}/cmds/handler-apiroute-new.d.ts +0 -0
  64. /package/{dist → build}/cmds/handler-apiroute-new.js +0 -0
  65. /package/{dist → build}/cmds/handler-main-new.d.ts +0 -0
  66. /package/{dist → build}/cmds/new-test.d.ts +0 -0
  67. /package/{dist → build}/cmds/new.d.ts +0 -0
  68. /package/{dist → build}/cmds/watch.d.ts +0 -0
  69. /package/{dist → build}/cmds/watch.js +0 -0
  70. /package/{dist → build}/cmds/wc-new.d.ts +0 -0
  71. /package/{dist → build}/cmds/wc-new.js +0 -0
  72. /package/{dist → build}/index.d.ts +0 -0
  73. /package/{dist → build}/index.js +0 -0
  74. /package/{dist → build}/utils/templates.d.ts +0 -0
  75. /package/{dist → build}/utils/templates.js +0 -0
@@ -1,20 +0,0 @@
1
- import { Logger } from "@miqro/core";
2
- export interface SequelizeRC {
3
- config: string;
4
- "migrations-path": string;
5
- "seeders-path": string;
6
- "models-path": string;
7
- }
8
- export declare const loadSequelizeRC: (sequelizercPath?: string, logger?: Logger) => SequelizeRC;
9
- export declare const loadModels: (args?: {
10
- "models-path": string;
11
- }) => {
12
- path: string;
13
- modelsModule: any;
14
- };
15
- export declare const loadSequelize: (args?: {
16
- "models-path": string;
17
- }, l?: Logger) => any;
18
- export declare const initDBConfig: () => boolean;
19
- export declare const makemigrations: () => void;
20
- export declare const syncMakeMigrations: () => void;
@@ -1,127 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.syncMakeMigrations = exports.makemigrations = exports.initDBConfig = exports.loadSequelize = exports.loadModels = exports.loadSequelizeRC = void 0;
4
- const automigrations_1 = require("./automigrations");
5
- const fs_1 = require("fs");
6
- const path_1 = require("path");
7
- const templates_1 = require("../../utils/templates");
8
- const core_1 = require("@miqro/core");
9
- const parser_1 = require("@miqro/parser");
10
- const logger = console;
11
- const loadSequelizeRC = (sequelizercPath = core_1.ConfigPathResolver.getSequelizeRCFilePath(), logger) => {
12
- // noinspection SpellCheckingInspection
13
- if (!(0, fs_1.existsSync)(sequelizercPath)) {
14
- // noinspection SpellCheckingInspection
15
- throw new core_1.ConfigFileNotFoundError(`missing ${sequelizercPath} file. maybe you didnt init your db config.`);
16
- }
17
- else {
18
- if (logger) {
19
- logger.debug(`loading sequelize config from [${sequelizercPath}]`);
20
- }
21
- // noinspection SpellCheckingInspection
22
- /* eslint-disable @typescript-eslint/no-var-requires */
23
- const sequelizerc = require(sequelizercPath);
24
- return (0, parser_1.parse)(sequelizerc, [
25
- { name: "config", type: "string", required: true },
26
- { name: "migrations-path", type: "string", required: true },
27
- { name: "seeders-path", type: "string", required: true },
28
- { name: "models-path", type: "string", required: true }
29
- ], "no_extra", sequelizercPath);
30
- }
31
- };
32
- exports.loadSequelizeRC = loadSequelizeRC;
33
- const loadModels = (args) => {
34
- const sequelizerc = args ? args : (0, exports.loadSequelizeRC)();
35
- const modelsModule = require(sequelizerc["models-path"]);
36
- return {
37
- path: sequelizerc["models-path"],
38
- modelsModule
39
- };
40
- };
41
- exports.loadModels = loadModels;
42
- const loadSequelize = (args, l) => {
43
- const logger = l ? l : (0, core_1.getLogger)("Database");
44
- const { modelsModule, path } = (0, exports.loadModels)();
45
- if (!modelsModule.sequelize || typeof modelsModule.sequelize !== "object" || typeof modelsModule.sequelize.models !== "object") {
46
- throw new Error(`${path} doesnt export sequelize`);
47
- }
48
- modelsModule.sequelize.log = (text) => {
49
- logger.info(text);
50
- };
51
- return modelsModule.sequelize;
52
- };
53
- exports.loadSequelize = loadSequelize;
54
- // noinspection SpellCheckingInspection
55
- const initDBConfig = () => {
56
- try {
57
- const initDir = (p) => {
58
- if (!(0, fs_1.existsSync)(p)) {
59
- logger.warn(`creating ${p}`);
60
- (0, fs_1.mkdirSync)(p);
61
- }
62
- else {
63
- logger.warn(`${p} already exists!. init will not create it.`);
64
- }
65
- };
66
- const initFile = (p, template) => {
67
- if (!(0, fs_1.existsSync)(p)) {
68
- logger.warn(`creating ${p} file`);
69
- (0, fs_1.writeFileSync)(p, template);
70
- }
71
- else {
72
- logger.warn(`${p} already exists!. init will not create it.`);
73
- }
74
- };
75
- // noinspection SpellCheckingInspection
76
- const sequelizercPath = (0, path_1.resolve)(core_1.ConfigPathResolver.getBaseDirname(), ".sequelizerc");
77
- if ((0, fs_1.existsSync)(sequelizercPath)) {
78
- logger.warn(`.sequelizerc already exists!. init will do nothing.`);
79
- return false;
80
- }
81
- else {
82
- // disable experimental typescript support
83
- const typescript = false; //existsSync(resolve(ConfigPathResolver.getBaseDirname(), "tsconfig.json")) ? true : false;
84
- const dbFolder = (0, path_1.resolve)(core_1.ConfigPathResolver.getBaseDirname(), "db");
85
- const migrationsFolder = (0, path_1.resolve)(dbFolder, "migrations");
86
- const modelsFolder = typescript ? (0, path_1.resolve)("src", "models") : (0, path_1.resolve)(dbFolder, "models");
87
- const seedersFolder = (0, path_1.resolve)(dbFolder, "seeders");
88
- const modelLoaderPath = (0, path_1.resolve)(modelsFolder, typescript ? "index.ts" : "index.js");
89
- const dbConfigFilePath = (0, path_1.resolve)(dbFolder, "connection.js");
90
- // noinspection SpellCheckingInspection
91
- initFile(sequelizercPath, templates_1.templates.sequelizerc(typescript));
92
- initDir(dbFolder);
93
- initFile(dbConfigFilePath, templates_1.templates.dbConfig);
94
- initDir(migrationsFolder);
95
- initDir(modelsFolder);
96
- initFile(modelLoaderPath, templates_1.templates.modelsIndex);
97
- initDir(seedersFolder);
98
- }
99
- return true;
100
- }
101
- catch (e) {
102
- logger.error(e.message);
103
- throw e;
104
- }
105
- };
106
- exports.initDBConfig = initDBConfig;
107
- // noinspection SpellCheckingInspection
108
- const makemigrations = () => {
109
- try {
110
- (0, automigrations_1.makemigrationsImpl)();
111
- }
112
- catch (e) {
113
- logger.error(e.message);
114
- throw e;
115
- }
116
- };
117
- exports.makemigrations = makemigrations;
118
- const syncMakeMigrations = () => {
119
- try {
120
- (0, automigrations_1.syncMakeMigrationsImpl)();
121
- }
122
- catch (e) {
123
- logger.error(e.message);
124
- throw e;
125
- }
126
- };
127
- exports.syncMakeMigrations = syncMakeMigrations;
@@ -1,18 +0,0 @@
1
- import { GroupPolicy, Logger, Method, SessionHandlerOptions } from "@miqro/core";
2
- import { ParseOptions } from "@miqro/parser";
3
- export declare const getDOCJSON: ({ dirname, subPath }: {
4
- dirname: string;
5
- subPath: string;
6
- }, logger: Logger) => {
7
- path?: string | string[];
8
- method?: Method | Method[];
9
- description?: string;
10
- policy?: GroupPolicy;
11
- headers?: ParseOptions | ParseOptions[];
12
- session?: false | true | SessionHandlerOptions;
13
- params?: boolean | ParseOptions | ParseOptions[] | string;
14
- query?: boolean | ParseOptions | ParseOptions[] | string;
15
- body?: boolean | ParseOptions | ParseOptions[] | string;
16
- response?: ParseOptions | ParseOptions[] | string;
17
- featureName: string;
18
- }[];
@@ -1,36 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.getDOCJSON = void 0;
4
- const core_1 = require("@miqro/core");
5
- const api_router_utils_1 = require("@miqro/core/dist/common/api-router-utils");
6
- const path_1 = require("path");
7
- const getDOCJSON = ({ dirname, subPath }, logger) => {
8
- const apiTraverse = (0, api_router_utils_1.traverseAPIRouteDir)((0, path_1.basename)(dirname).toUpperCase(), (0, path_1.resolve)(core_1.ConfigPathResolver.getBaseDirname(), dirname), subPath, undefined, logger);
9
- const docJSON = Object.keys(apiTraverse).map(featureName => {
10
- const { path, method, options } = apiTraverse[featureName];
11
- const { session, policy, description } = options ? options : {
12
- session: undefined,
13
- policy: undefined,
14
- description: undefined
15
- };
16
- const { params, query, body, headers } = options && options.request ? options.request : {
17
- params: undefined,
18
- query: undefined,
19
- body: undefined,
20
- headers: undefined
21
- };
22
- const result = options && options.response !== true ? options.response : undefined;
23
- return {
24
- path,
25
- method,
26
- headers,
27
- session: session ? typeof session === "function" ? true : session : false,
28
- policy,
29
- params,
30
- description, query, body, result,
31
- featureName
32
- };
33
- });
34
- return docJSON;
35
- };
36
- exports.getDOCJSON = getDOCJSON;
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes