corebasic 1.0.251 → 1.0.252

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.
@@ -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);
@@ -6,14 +6,25 @@ 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 TYPES_DIR = `${Utils.PROJECT_ROOT_PATH}/types`;
13
- const REMOTES_DIR = `${Utils.PROJECT_ROOT_PATH}/types/remotes`;
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
  g_this.Schemas ??= {};
16
17
  g_this.Types ??= { Remotes: {} };
18
+ async function schema_init(collection, partial) {
19
+ const module = await import(__rewriteRelativeImportExtension(`${SCHEMAS_DIR}/${collection}.ts`));
20
+ return module.default(partial);
21
+ }
22
+ async function leaf_init(collection, partial) {
23
+ const module = await import(__rewriteRelativeImportExtension(`${LEAF_DIR}/${collection}.ts`));
24
+ return module.default(partial);
25
+ }
26
+ g_this.Schema ??= { init: schema_init };
27
+ g_this.Leaf ??= { init: leaf_init };
17
28
  // ================
18
29
  function init(partial) {
19
30
  return {
@@ -31,24 +42,27 @@ function init(partial) {
31
42
  }
32
43
  g_this.DefaultSchema = { init };
33
44
  // ================
34
- async function load(path) {
35
- let files;
36
- try {
37
- files = await readdir(path);
38
- }
39
- catch {
40
- files = [];
41
- }
42
- for (const file of files) {
43
- if (file.endsWith(".ts")) {
44
- const imported = await import(__rewriteRelativeImportExtension(`${path}/${file}`));
45
- Object.assign(g_this.Schemas, imported?.Schemas ?? {});
46
- const { Remotes: remotes, ...types } = imported?.Types ?? {};
47
- Object.assign(g_this.Types, types ?? {});
48
- Object.assign(g_this.Types.Remotes, remotes ?? {});
49
- }
50
- }
51
- }
52
- await load(SCHEMAS_DIR);
53
- await load(TYPES_DIR);
54
- await load(REMOTES_DIR);
45
+ // async function load(path: string) {
46
+ // let files: string[]
47
+ // try {
48
+ // files = await readdir(path)
49
+ // } catch {
50
+ // files = []
51
+ // }
52
+ //
53
+ // for (const file of files) {
54
+ // if (file.endsWith(".ts")) {
55
+ // const imported = await import(`${path}/${file}`)
56
+ // Object.assign(g_this.Schemas, imported?.Schemas ?? {})
57
+ //
58
+ // const { Remotes: remotes, ...types } = imported?.Types ?? {};
59
+ // Object.assign(g_this.Types, types ?? {})
60
+ // Object.assign(g_this.Types.Remotes, remotes ?? {})
61
+ // }
62
+ // }
63
+ // }
64
+ //
65
+ //
66
+ // await load(SCHEMAS_DIR)
67
+ // await load(TYPES_DIR)
68
+ // 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
- // 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]>>> => {
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 TYPES_DIR = `${Utils.PROJECT_ROOT_PATH}/types`
6
- const REMOTES_DIR = `${Utils.PROJECT_ROOT_PATH}/types/remotes`
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
10
  g_this.Schemas ??= {};
10
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
- let files: string[]
48
- try {
49
- files = await readdir(path)
50
- } catch {
51
- files = []
52
- }
53
-
54
- for (const file of files) {
55
- if (file.endsWith(".ts")) {
56
- const imported = await import(`${path}/${file}`)
57
- Object.assign(g_this.Schemas, imported?.Schemas ?? {})
58
-
59
- const { Remotes: remotes, ...types } = imported?.Types ?? {};
60
- Object.assign(g_this.Types, types ?? {})
61
- Object.assign(g_this.Types.Remotes, remotes ?? {})
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
 
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "corebasic",
3
3
  "type": "module",
4
- "version": "1.0.251",
4
+ "version": "1.0.252",
5
5
  "description": "",
6
6
  "main": "dist/index.js",
7
7
  "types": "./index.ts",