@code0-tech/definition-reader 0.0.13 → 0.0.15

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": "@code0-tech/definition-reader",
3
- "version": "0.0.13",
3
+ "version": "0.0.15",
4
4
  "description": "Reader for Code0-Definitions",
5
5
  "main": "./build/index.js",
6
6
  "types": "./build/index.d.ts",
@@ -12,14 +12,14 @@
12
12
  },
13
13
  "type": "module",
14
14
  "scripts": {
15
- "build": "tsc"
15
+ "build": "npx vite build && node dist/definition-reader.js"
16
16
  },
17
17
  "author": "",
18
18
  "license": "",
19
19
  "devDependencies": {
20
- "@code0-tech/sagittarius-graphql-types": "^0.0.0-4b2e73eae302fe499001bf42fdb3a6bcc5be78aa ",
21
20
  "@types/node": "^24.1.0",
22
- "typescript": "^5.8.3"
21
+ "typescript": "^5.8.3",
22
+ "vite": "^7.1.11"
23
23
  },
24
24
  "repository": {
25
25
  "type": "git",
@@ -30,5 +30,10 @@
30
30
  ],
31
31
  "publishConfig": {
32
32
  "access": "public"
33
+ },
34
+ "dependencies": {
35
+ "@code0-tech/sagittarius-graphql-types": "^0.0.0-00f33663039d78ad59e95306730878c687de5c48",
36
+ "@code0-tech/tucana": "^0.0.37",
37
+ "@protobuf-ts/runtime": "^2.11.1"
33
38
  }
34
39
  }
package/build/index.d.ts DELETED
@@ -1,2 +0,0 @@
1
- export { Definition } from './src/parser.js';
2
- export type { Feature, MetaType, Meta } from './src/types.js';
package/build/index.js DELETED
@@ -1 +0,0 @@
1
- export { Definition } from './src/parser.js';
@@ -1,2 +0,0 @@
1
- import { Feature } from "./types.js";
2
- export declare const Definition: (rootPath: string) => Feature[];
@@ -1,50 +0,0 @@
1
- import { Reader } from './reader.js';
2
- import { MetaType } from "./types.js";
3
- export const Definition = (rootPath) => {
4
- const meta = Reader(rootPath);
5
- if (!meta)
6
- return [];
7
- const features = [];
8
- for (const m of meta) {
9
- let feature = features.find((f) => f.name === m.name);
10
- if (feature) {
11
- appendMeta(feature, m);
12
- }
13
- else {
14
- feature = {
15
- name: m.name,
16
- dataTypes: [],
17
- flowTypes: [],
18
- runtimeFunctions: [],
19
- };
20
- appendMeta(feature, m);
21
- features.push(feature);
22
- }
23
- }
24
- return features;
25
- };
26
- function appendMeta(feature, meta) {
27
- const definition = meta.data;
28
- try {
29
- switch (meta.type) {
30
- case MetaType.DataType: {
31
- const parsed = JSON.parse(definition);
32
- feature.dataTypes.push(parsed);
33
- break;
34
- }
35
- case MetaType.FlowType: {
36
- const parsed = JSON.parse(definition);
37
- feature.flowTypes.push(parsed);
38
- break;
39
- }
40
- case MetaType.RuntimeFunction: {
41
- const parsed = JSON.parse(definition);
42
- feature.runtimeFunctions.push(parsed);
43
- break;
44
- }
45
- }
46
- }
47
- catch (err) {
48
- console.error(`Error parsing ${meta.type} ${meta.name} ${definition}:`, err);
49
- }
50
- }
@@ -1,2 +0,0 @@
1
- import { Meta } from "./types.js";
2
- export declare const Reader: (rootPath: string) => Meta[];
@@ -1,75 +0,0 @@
1
- import * as fs from 'fs';
2
- import * as path from 'path';
3
- import { MetaType } from "./types.js";
4
- export const Reader = (rootPath) => {
5
- const result = [];
6
- try {
7
- const features = fs.readdirSync(rootPath, { withFileTypes: true });
8
- for (const featureDirent of features) {
9
- if (!featureDirent.isDirectory())
10
- continue;
11
- const featurePath = path.join(rootPath, featureDirent.name);
12
- const featureName = featureDirent.name;
13
- const typeDirs = fs.readdirSync(featurePath, { withFileTypes: true });
14
- for (const typeDirent of typeDirs) {
15
- if (!typeDirent.isDirectory())
16
- continue;
17
- const metaType = matchMetaType(typeDirent.name);
18
- if (!metaType)
19
- continue;
20
- const typePath = path.join(featurePath, typeDirent.name);
21
- const definitions = fs.readdirSync(typePath, { withFileTypes: true });
22
- for (const def of definitions) {
23
- const defPath = path.join(typePath, def.name);
24
- if (def.isFile()) {
25
- if (!defPath.endsWith('.json'))
26
- continue;
27
- try {
28
- const content = fs.readFileSync(defPath, 'utf-8');
29
- const meta = { name: featureName, type: metaType, data: content };
30
- result.push(meta);
31
- }
32
- catch (err) {
33
- console.error(`Error reading file: ${defPath}`, err);
34
- }
35
- }
36
- else if (def.isDirectory()) {
37
- const subDefinitions = fs.readdirSync(defPath, { withFileTypes: true });
38
- for (const subDef of subDefinitions) {
39
- const subPath = path.join(defPath, subDef.name);
40
- if (!subPath.endsWith('.json'))
41
- continue;
42
- if (!subDef.isFile())
43
- continue;
44
- try {
45
- const content = fs.readFileSync(subPath, 'utf-8');
46
- const meta = { name: featureName, type: metaType, data: content };
47
- result.push(meta);
48
- }
49
- catch (err) {
50
- console.error(`Error reading file: ${subPath}`, err);
51
- }
52
- }
53
- }
54
- }
55
- }
56
- }
57
- return result;
58
- }
59
- catch (err) {
60
- console.error(`Error reading path ${rootPath}:`, err);
61
- return [];
62
- }
63
- };
64
- function matchMetaType(name) {
65
- switch (name) {
66
- case 'flow_type':
67
- return MetaType.FlowType;
68
- case 'data_type':
69
- return MetaType.DataType;
70
- case 'runtime_definition':
71
- return MetaType.RuntimeFunction;
72
- default:
73
- return null;
74
- }
75
- }
@@ -1,17 +0,0 @@
1
- import { DataType, FlowType, RuntimeFunctionDefinition } from "@code0-tech/sagittarius-graphql-types";
2
- export declare enum MetaType {
3
- FlowType = "FlowType",
4
- DataType = "DataType",
5
- RuntimeFunction = "RuntimeFunction"
6
- }
7
- export interface Meta {
8
- name: string;
9
- type: MetaType;
10
- data: string;
11
- }
12
- export interface Feature {
13
- name: string;
14
- dataTypes: DataType[];
15
- flowTypes: FlowType[];
16
- runtimeFunctions: RuntimeFunctionDefinition[];
17
- }
@@ -1,6 +0,0 @@
1
- export var MetaType;
2
- (function (MetaType) {
3
- MetaType["FlowType"] = "FlowType";
4
- MetaType["DataType"] = "DataType";
5
- MetaType["RuntimeFunction"] = "RuntimeFunction";
6
- })(MetaType || (MetaType = {}));