corebasic 1.0.251 → 1.0.253
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/libs/features.js +0 -1
- package/dist/libs/schemas.js +38 -26
- package/libs/features.ts +1 -1
- package/libs/schemas.ts +50 -29
- package/package.json +1 -1
package/dist/libs/features.js
CHANGED
|
@@ -84,7 +84,6 @@ export const get = (feature) => {
|
|
|
84
84
|
let { api, service = SERVICE_ADDRESS, topic } = baseFeature ? baseFeature : (SLYP_FEATURES_LIST[feature] ?? throwError());
|
|
85
85
|
return { api, service, topic };
|
|
86
86
|
};
|
|
87
|
-
// export const send = async <K extends keyof FeatureTypes> (meta: Partial<FeatureMeta>, feature: K, data?: Parameters<FeatureTypes[K]>[0]["data"], params?: FeatureParams): Promise<Awaited<ReturnType<FeatureTypes[K]>>> => {
|
|
88
87
|
export const send = async (meta, feature, data, params) => {
|
|
89
88
|
const throwError = () => { throw new Error(`Feature ${feature} not found in internal or external list during inter feature call`); };
|
|
90
89
|
const baseFeature = getFeature(feature);
|
package/dist/libs/schemas.js
CHANGED
|
@@ -6,14 +6,23 @@ var __rewriteRelativeImportExtension = (this && this.__rewriteRelativeImportExte
|
|
|
6
6
|
}
|
|
7
7
|
return path;
|
|
8
8
|
};
|
|
9
|
-
import { readdir } from "node:fs/promises"
|
|
9
|
+
// import { readdir } from "node:fs/promises"
|
|
10
10
|
import * as Utils from './utils.js';
|
|
11
11
|
const SCHEMAS_DIR = `${Utils.PROJECT_ROOT_PATH}/schemas`;
|
|
12
|
-
const
|
|
13
|
-
const
|
|
12
|
+
const LEAF_DIR = `${Utils.PROJECT_ROOT_PATH}/leaf`;
|
|
13
|
+
// const TYPES_DIR = `${Utils.PROJECT_ROOT_PATH}/types`
|
|
14
|
+
// const REMOTES_DIR = `${Utils.PROJECT_ROOT_PATH}/types/remotes`
|
|
14
15
|
const g_this = globalThis;
|
|
15
|
-
|
|
16
|
-
|
|
16
|
+
async function schema_init(collection, partial) {
|
|
17
|
+
const module = await import(__rewriteRelativeImportExtension(`${SCHEMAS_DIR}/${collection}.ts`));
|
|
18
|
+
return module.default(partial);
|
|
19
|
+
}
|
|
20
|
+
async function leaf_init(collection, partial) {
|
|
21
|
+
const module = await import(__rewriteRelativeImportExtension(`${LEAF_DIR}/${collection}.ts`));
|
|
22
|
+
return module.default(partial);
|
|
23
|
+
}
|
|
24
|
+
g_this.Schema ??= { init: schema_init };
|
|
25
|
+
g_this.Leaf ??= { init: leaf_init };
|
|
17
26
|
// ================
|
|
18
27
|
function init(partial) {
|
|
19
28
|
return {
|
|
@@ -31,24 +40,27 @@ function init(partial) {
|
|
|
31
40
|
}
|
|
32
41
|
g_this.DefaultSchema = { init };
|
|
33
42
|
// ================
|
|
34
|
-
async function load(path) {
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
43
|
+
// async function load(path: string) {
|
|
44
|
+
// let files: string[]
|
|
45
|
+
// try {
|
|
46
|
+
// files = await readdir(path)
|
|
47
|
+
// } catch {
|
|
48
|
+
// files = []
|
|
49
|
+
// }
|
|
50
|
+
//
|
|
51
|
+
// for (const file of files) {
|
|
52
|
+
// if (file.endsWith(".ts")) {
|
|
53
|
+
// const imported = await import(`${path}/${file}`)
|
|
54
|
+
// Object.assign(g_this.Schemas, imported?.Schemas ?? {})
|
|
55
|
+
//
|
|
56
|
+
// const { Remotes: remotes, ...types } = imported?.Types ?? {};
|
|
57
|
+
// Object.assign(g_this.Types, types ?? {})
|
|
58
|
+
// Object.assign(g_this.Types.Remotes, remotes ?? {})
|
|
59
|
+
// }
|
|
60
|
+
// }
|
|
61
|
+
// }
|
|
62
|
+
//
|
|
63
|
+
//
|
|
64
|
+
// await load(SCHEMAS_DIR)
|
|
65
|
+
// await load(TYPES_DIR)
|
|
66
|
+
// await load(REMOTES_DIR)
|
package/libs/features.ts
CHANGED
|
@@ -188,7 +188,7 @@ export const get = (feature: string) => {
|
|
|
188
188
|
|
|
189
189
|
|
|
190
190
|
type HandlerInput<T> = T extends Handler<infer I, any> ? I : never
|
|
191
|
-
|
|
191
|
+
|
|
192
192
|
export const send = async <K extends keyof FeatureTypes> (meta: Partial<FeatureMeta>, feature: K, data?: HandlerInput<FeatureTypes[K]>, params?: FeatureParams): Promise<Awaited<ReturnType<FeatureTypes[K]>>> => {
|
|
193
193
|
const throwError = () => {throw new Error(`Feature ${feature} not found in internal or external list during inter feature call`)}
|
|
194
194
|
const baseFeature: FeatureEntry | undefined = getFeature(feature)
|
package/libs/schemas.ts
CHANGED
|
@@ -1,15 +1,36 @@
|
|
|
1
|
-
import { readdir } from "node:fs/promises"
|
|
1
|
+
// import { readdir } from "node:fs/promises"
|
|
2
2
|
import * as Utils from './utils.ts'
|
|
3
3
|
|
|
4
4
|
const SCHEMAS_DIR = `${Utils.PROJECT_ROOT_PATH}/schemas`
|
|
5
|
-
const
|
|
6
|
-
const
|
|
5
|
+
const LEAF_DIR = `${Utils.PROJECT_ROOT_PATH}/leaf`
|
|
6
|
+
// const TYPES_DIR = `${Utils.PROJECT_ROOT_PATH}/types`
|
|
7
|
+
// const REMOTES_DIR = `${Utils.PROJECT_ROOT_PATH}/types/remotes`
|
|
7
8
|
|
|
8
9
|
const g_this: any = globalThis as any
|
|
9
|
-
g_this.Schemas ??= {};
|
|
10
|
-
g_this.Types ??= {Remotes: {}};
|
|
10
|
+
// g_this.Schemas ??= {};
|
|
11
|
+
// g_this.Types ??= {Remotes: {}};
|
|
11
12
|
|
|
12
13
|
|
|
14
|
+
// ================
|
|
15
|
+
// Schema Core
|
|
16
|
+
// ================
|
|
17
|
+
declare global {
|
|
18
|
+
const Schema: { init: typeof schema_init }
|
|
19
|
+
const Leaf: { init: typeof leaf_init }
|
|
20
|
+
interface Schema {}
|
|
21
|
+
interface Leaf {}
|
|
22
|
+
}
|
|
23
|
+
async function schema_init<K extends keyof Schema>(collection: K, partial?: Partial<Schema[K]>): Promise<Schema[K]> {
|
|
24
|
+
const module = await import(`${SCHEMAS_DIR}/${collection}.ts`)
|
|
25
|
+
return module.default(partial)
|
|
26
|
+
}
|
|
27
|
+
async function leaf_init<K extends keyof Leaf>(collection: K, partial?: Partial<Leaf[K]>): Promise<Leaf[K]> {
|
|
28
|
+
const module = await import(`${LEAF_DIR}/${collection}.ts`)
|
|
29
|
+
return module.default(partial)
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
g_this.Schema ??= {init: schema_init};
|
|
33
|
+
g_this.Leaf ??= {init: leaf_init};
|
|
13
34
|
// ================
|
|
14
35
|
|
|
15
36
|
function init(partial?: Partial<DefaultSchema>): DefaultSchema {
|
|
@@ -43,28 +64,28 @@ declare global {
|
|
|
43
64
|
g_this.DefaultSchema = { init }
|
|
44
65
|
// ================
|
|
45
66
|
|
|
46
|
-
async function load(path: string) {
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
await load(SCHEMAS_DIR)
|
|
68
|
-
await load(TYPES_DIR)
|
|
69
|
-
await load(REMOTES_DIR)
|
|
67
|
+
// async function load(path: string) {
|
|
68
|
+
// let files: string[]
|
|
69
|
+
// try {
|
|
70
|
+
// files = await readdir(path)
|
|
71
|
+
// } catch {
|
|
72
|
+
// files = []
|
|
73
|
+
// }
|
|
74
|
+
//
|
|
75
|
+
// for (const file of files) {
|
|
76
|
+
// if (file.endsWith(".ts")) {
|
|
77
|
+
// const imported = await import(`${path}/${file}`)
|
|
78
|
+
// Object.assign(g_this.Schemas, imported?.Schemas ?? {})
|
|
79
|
+
//
|
|
80
|
+
// const { Remotes: remotes, ...types } = imported?.Types ?? {};
|
|
81
|
+
// Object.assign(g_this.Types, types ?? {})
|
|
82
|
+
// Object.assign(g_this.Types.Remotes, remotes ?? {})
|
|
83
|
+
// }
|
|
84
|
+
// }
|
|
85
|
+
// }
|
|
86
|
+
//
|
|
87
|
+
//
|
|
88
|
+
// await load(SCHEMAS_DIR)
|
|
89
|
+
// await load(TYPES_DIR)
|
|
90
|
+
// await load(REMOTES_DIR)
|
|
70
91
|
|