@paralect/hive 0.1.18 → 0.1.20
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/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@paralect/hive",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.20",
|
|
4
4
|
"description": "",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"bin": {
|
|
@@ -13,6 +13,7 @@
|
|
|
13
13
|
"@koa/cors": "3.1.0",
|
|
14
14
|
"@koa/multer": "3.0.0",
|
|
15
15
|
"@koa/router": "10.1.1",
|
|
16
|
+
"@paralect/hive": "^0.1.19",
|
|
16
17
|
"@paralect/node-mongo": "2.1.1",
|
|
17
18
|
"@react-email/components": "^0.0.20",
|
|
18
19
|
"@react-email/render": "^0.0.16",
|
|
@@ -26,8 +26,7 @@ export default async () => {
|
|
|
26
26
|
|
|
27
27
|
return resourceDirs
|
|
28
28
|
.filter(({ dirName }) => dirName !== "health")
|
|
29
|
-
.map(({ dirName
|
|
30
|
-
dir: isHive ? path.resolve(`${process.env.HIVE_SRC}/resources/${dirName}`) : path.resolve(`${__dirname}/../resources/${dirName}`),
|
|
29
|
+
.map(({ dirName }) => ({
|
|
31
30
|
name: dirName,
|
|
32
31
|
}));
|
|
33
32
|
};
|
|
@@ -1,27 +1,50 @@
|
|
|
1
|
-
import
|
|
1
|
+
import _ from 'lodash';
|
|
2
|
+
import fs, { promises } from "fs";
|
|
2
3
|
import getResources from "./getResources.js";
|
|
3
4
|
|
|
4
5
|
const {
|
|
5
6
|
promises: { readdir },
|
|
6
7
|
} = { promises };
|
|
7
8
|
|
|
9
|
+
|
|
10
|
+
const getSchemas = async (resourceDir) => {
|
|
11
|
+
return (await readdir(resourceDir))
|
|
12
|
+
.filter((f) => f.includes("schema.js"))
|
|
13
|
+
.filter((f) => !f.includes("extends.schema"))
|
|
14
|
+
.map((f) => ({
|
|
15
|
+
name: f.replace(".schema.js", ""),
|
|
16
|
+
file: `${resourceDir}/${f}`,
|
|
17
|
+
resourceName: _.last(resourceDir.split('/')),
|
|
18
|
+
isHive: process.env.HIVE_SRC && resourceDir.includes(process.env.HIVE_SRC),
|
|
19
|
+
}));
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
const getResourceSchemas = async (resourceName) => {
|
|
23
|
+
let schemaFiles = [];
|
|
24
|
+
|
|
25
|
+
if (fs.existsSync(`${process.env.HIVE_SRC}/resources/${resourceName}`)) {
|
|
26
|
+
schemaFiles = (await getSchemas(`${process.env.HIVE_SRC}/resources/${resourceName}`));
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
if (fs.existsSync(`${__dirname}/../resources/${resourceName}`)) {
|
|
30
|
+
schemaFiles = [...schemaFiles, ...(await getSchemas(`${__dirname}/../resources/${resourceName}`)).filter(schema => !schemaFiles.find(s => s.name === schema.name))];
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
return schemaFiles;
|
|
34
|
+
};
|
|
35
|
+
|
|
8
36
|
export default async () => {
|
|
9
37
|
const resources = await getResources();
|
|
10
|
-
|
|
38
|
+
let schemas = [];
|
|
11
39
|
|
|
12
40
|
await Promise.all(
|
|
13
|
-
resources.map(async ({
|
|
14
|
-
const resourceSchemas =
|
|
15
|
-
.filter((f) => f.includes("schema.js"))
|
|
16
|
-
.filter((f) => !f.includes("extends.schema"))
|
|
17
|
-
.map((f) => ({
|
|
18
|
-
file: `${resourceDir}/${f}`,
|
|
19
|
-
resourceName,
|
|
20
|
-
name: f.replace(".schema.js", ""),
|
|
21
|
-
}));
|
|
41
|
+
resources.map(async ({ name: resourceName }) => {
|
|
42
|
+
const resourceSchemas = await getResourceSchemas(resourceName);
|
|
22
43
|
schemas.push(...resourceSchemas);
|
|
23
44
|
})
|
|
24
45
|
);
|
|
25
|
-
|
|
46
|
+
|
|
47
|
+
console.log('schemas', schemas);
|
|
48
|
+
|
|
26
49
|
return schemas;
|
|
27
50
|
};
|
|
@@ -12,7 +12,7 @@ export const requestSchema = z.object({
|
|
|
12
12
|
export const handler = async (ctx) => {
|
|
13
13
|
const { name } = ctx.validatedData;
|
|
14
14
|
|
|
15
|
-
const schedulerHandler = await (import(
|
|
15
|
+
const schedulerHandler = await (import(`${process.env.HIVE_SRC}/scheduler/handlers/${name}`));
|
|
16
16
|
|
|
17
17
|
try {
|
|
18
18
|
const data = await schedulerHandler.handler();
|