bmdl-sdk 0.0.2
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/bin/cli.js +4 -0
- package/bmdl-sdk-0.0.2.tgz +0 -0
- package/dist/config.json +13 -0
- package/dist/index.js +2 -0
- package/dist/sdk.zip +0 -0
- package/dist/viewOptions.json +57 -0
- package/package.json +39 -0
- package/scripts/postbuild.js +81 -0
- package/src/app/App.js +79 -0
- package/src/app/App.tsx +124 -0
- package/src/config.js +17 -0
- package/src/config.ts +13 -0
- package/src/dataOptions.js +42 -0
- package/src/dataOptions.ts +45 -0
- package/src/index.js +79 -0
- package/src/index.ts +101 -0
- package/src/main.js +7 -0
- package/src/main.tsx +4 -0
- package/src/types/custom.js +20 -0
- package/src/types/custom.ts +17 -0
- package/src/types/index.js +21 -0
- package/src/types/index.ts +93 -0
- package/src/viewOptions.js +79 -0
- package/src/viewOptions.ts +68 -0
- package/tsconfig.json +7 -0
- package/vite.config.js +46 -0
- package/vite.config.ts +44 -0
package/dist/sdk.zip
ADDED
|
Binary file
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
{
|
|
2
|
+
"data": [
|
|
3
|
+
{
|
|
4
|
+
"key": "General",
|
|
5
|
+
"label": {
|
|
6
|
+
"ru": "Заголовок",
|
|
7
|
+
"en": "Title"
|
|
8
|
+
},
|
|
9
|
+
"defaultOpen": true,
|
|
10
|
+
"children": [
|
|
11
|
+
{
|
|
12
|
+
"element": "checkbox",
|
|
13
|
+
"key": "Title",
|
|
14
|
+
"label": {
|
|
15
|
+
"ru": "Заголовок",
|
|
16
|
+
"en": "Title"
|
|
17
|
+
},
|
|
18
|
+
"defaultValue": true
|
|
19
|
+
},
|
|
20
|
+
{
|
|
21
|
+
"element": "select",
|
|
22
|
+
"key": "ColType",
|
|
23
|
+
"label": {
|
|
24
|
+
"ru": "Тип столбцов",
|
|
25
|
+
"en": "Column type"
|
|
26
|
+
},
|
|
27
|
+
"options": [
|
|
28
|
+
{
|
|
29
|
+
"label": {
|
|
30
|
+
"ru": "Стандартный",
|
|
31
|
+
"en": "Default"
|
|
32
|
+
},
|
|
33
|
+
"value": "default"
|
|
34
|
+
},
|
|
35
|
+
{
|
|
36
|
+
"label": {
|
|
37
|
+
"ru": "Стандартный 2",
|
|
38
|
+
"en": "Default 2"
|
|
39
|
+
},
|
|
40
|
+
"value": "default2"
|
|
41
|
+
}
|
|
42
|
+
],
|
|
43
|
+
"defaultValue": "default"
|
|
44
|
+
}
|
|
45
|
+
]
|
|
46
|
+
},
|
|
47
|
+
{
|
|
48
|
+
"element": "input",
|
|
49
|
+
"key": "ColorBy",
|
|
50
|
+
"label": {
|
|
51
|
+
"ru": "Цвет элемента",
|
|
52
|
+
"en": "Item color"
|
|
53
|
+
},
|
|
54
|
+
"defaultValue": "red"
|
|
55
|
+
}
|
|
56
|
+
]
|
|
57
|
+
}
|
package/package.json
ADDED
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "bmdl-sdk",
|
|
3
|
+
"private": false,
|
|
4
|
+
"version": "0.0.2",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"bin": {
|
|
7
|
+
"bmdl-sdk": "./bin/cli.js"
|
|
8
|
+
},
|
|
9
|
+
"scripts": {
|
|
10
|
+
"dev": "vite",
|
|
11
|
+
"build": "tsc && vite build",
|
|
12
|
+
"preview": "vite preview",
|
|
13
|
+
"build:component": "vite build && tsx scripts/postbuild.js"
|
|
14
|
+
},
|
|
15
|
+
"dependencies": {
|
|
16
|
+
"adm-zip": "^0.5.16",
|
|
17
|
+
"echarts": "^6.0.0",
|
|
18
|
+
"echarts-for-react": "^3.0.5",
|
|
19
|
+
"react": "^19.2.0",
|
|
20
|
+
"react-dom": "^19.2.0",
|
|
21
|
+
"teaser": "^0.1.1",
|
|
22
|
+
"tsx": "^4.22.4"
|
|
23
|
+
},
|
|
24
|
+
"devDependencies": {
|
|
25
|
+
"@eslint/js": "^9.39.1",
|
|
26
|
+
"@types/node": "^24.10.1",
|
|
27
|
+
"@types/react": "^19.2.5",
|
|
28
|
+
"@types/react-dom": "^19.2.3",
|
|
29
|
+
"@types/terser": "^3.12.0",
|
|
30
|
+
"@vitejs/plugin-react": "^5.1.1",
|
|
31
|
+
"eslint": "^9.39.1",
|
|
32
|
+
"eslint-plugin-react-hooks": "^7.0.1",
|
|
33
|
+
"eslint-plugin-react-refresh": "^0.4.24",
|
|
34
|
+
"globals": "^16.5.0",
|
|
35
|
+
"typescript": "~5.9.3",
|
|
36
|
+
"typescript-eslint": "^8.46.4",
|
|
37
|
+
"vite": "^7.2.4"
|
|
38
|
+
}
|
|
39
|
+
}
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
import AdmZip from 'adm-zip'
|
|
2
|
+
import { readFileSync, rmSync, writeFileSync } from 'fs'
|
|
3
|
+
import { basename, dirname, resolve } from 'path'
|
|
4
|
+
import { fileURLToPath, pathToFileURL } from 'url'
|
|
5
|
+
|
|
6
|
+
const __dirname = dirname(fileURLToPath(import.meta.url))
|
|
7
|
+
const projectRoot = resolve(__dirname, '..')
|
|
8
|
+
const projectName = basename(projectRoot)
|
|
9
|
+
const distlDir = resolve(projectRoot, 'dist')
|
|
10
|
+
const zipOutputPath = resolve(distlDir, `${projectName}.zip`)
|
|
11
|
+
|
|
12
|
+
async function buildComponent() {
|
|
13
|
+
try {
|
|
14
|
+
const configPath = resolve(projectRoot, 'src/config.ts')
|
|
15
|
+
const dataOptionsPath = resolve(projectRoot, 'src/dataOptions.ts')
|
|
16
|
+
const viewOptionsPath = resolve(projectRoot, 'src/viewOptions.ts')
|
|
17
|
+
|
|
18
|
+
const { config } = await import(pathToFileURL(configPath).href)
|
|
19
|
+
const { createDataOptions } = await import(
|
|
20
|
+
pathToFileURL(dataOptionsPath).href
|
|
21
|
+
)
|
|
22
|
+
const { createViewOptions } = await import(
|
|
23
|
+
pathToFileURL(viewOptionsPath).href
|
|
24
|
+
)
|
|
25
|
+
|
|
26
|
+
const configData = {
|
|
27
|
+
...config,
|
|
28
|
+
dataOptions: createDataOptions(),
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
const viewOptionsData = createViewOptions()
|
|
32
|
+
|
|
33
|
+
///////
|
|
34
|
+
|
|
35
|
+
// copyFileSync(
|
|
36
|
+
// resolve(projectRoot, 'public/icon.svg'),
|
|
37
|
+
// resolve(projectRoot, 'dist/assets/icon.svg'),
|
|
38
|
+
// )
|
|
39
|
+
// copyFileSync(
|
|
40
|
+
// resolve(projectRoot, 'public/preview.webp'),
|
|
41
|
+
// resolve(projectRoot, 'dist/assets/preview.webp'),
|
|
42
|
+
// )
|
|
43
|
+
|
|
44
|
+
///////
|
|
45
|
+
|
|
46
|
+
writeFileSync(
|
|
47
|
+
resolve(distlDir, 'config.json'),
|
|
48
|
+
JSON.stringify(config, null, 2),
|
|
49
|
+
)
|
|
50
|
+
writeFileSync(
|
|
51
|
+
resolve(distlDir, 'viewOptions.json'),
|
|
52
|
+
JSON.stringify({ data: viewOptionsData }, null, 2),
|
|
53
|
+
)
|
|
54
|
+
|
|
55
|
+
///////
|
|
56
|
+
|
|
57
|
+
const componentPath = resolve(distlDir, 'index.iife.js')
|
|
58
|
+
const componentCode = readFileSync(componentPath, 'utf-8')
|
|
59
|
+
//
|
|
60
|
+
const finalCode = componentCode.replace(
|
|
61
|
+
'}(React);',
|
|
62
|
+
'}\nexport default Component',
|
|
63
|
+
)
|
|
64
|
+
|
|
65
|
+
rmSync(resolve(distlDir, 'index.iife.js'))
|
|
66
|
+
writeFileSync(resolve(distlDir, 'index.js'), finalCode)
|
|
67
|
+
|
|
68
|
+
///////
|
|
69
|
+
|
|
70
|
+
const zip = new AdmZip()
|
|
71
|
+
zip.addLocalFolder(distlDir)
|
|
72
|
+
zip.writeZip(zipOutputPath)
|
|
73
|
+
|
|
74
|
+
console.log('✅ Component built successfully!')
|
|
75
|
+
} catch (error) {
|
|
76
|
+
console.error('❌ Build failed:', error)
|
|
77
|
+
process.exit(1)
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
buildComponent()
|
package/src/app/App.js
ADDED
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
var jsx_runtime_1 = require("react/jsx-runtime");
|
|
7
|
+
var echarts_for_react_1 = __importDefault(require("echarts-for-react"));
|
|
8
|
+
var WidgetComponent = function (_a) {
|
|
9
|
+
var dataOptions = _a.dataOptions, viewOptions = _a.viewOptions;
|
|
10
|
+
console.log('dataOptions', dataOptions);
|
|
11
|
+
console.log('viewOptions', viewOptions);
|
|
12
|
+
console.log('render');
|
|
13
|
+
//
|
|
14
|
+
// const [settings, setSettings] = useState<any>({
|
|
15
|
+
// yColumns: [],
|
|
16
|
+
// xAxisData: [],
|
|
17
|
+
// yAxisData: [],
|
|
18
|
+
// })
|
|
19
|
+
// useEffect(() => {
|
|
20
|
+
// console.log('useEffect')
|
|
21
|
+
// if (dataSettings?.columns) {
|
|
22
|
+
// const { data, columns } = dataSettings
|
|
23
|
+
// const xColumn = columns.find(col => col.zoneId === 'X')
|
|
24
|
+
// const sColumn = columns.find(col => col.zoneId === 'S')
|
|
25
|
+
// const yColumns = columns.filter(col => col.zoneId === 'Y')
|
|
26
|
+
// //
|
|
27
|
+
// if (xColumn && yColumns.length) {
|
|
28
|
+
// const xPath = xColumn.path
|
|
29
|
+
// const sPath = sColumn?.path || null
|
|
30
|
+
// const yPaths = yColumns!.map(col => col.path)
|
|
31
|
+
// //
|
|
32
|
+
// const xAxisData = Array.from(new Set(data.map(row => row[xPath])))
|
|
33
|
+
// const yAxisData = yPaths.map(yPath => {
|
|
34
|
+
// return Object.values(
|
|
35
|
+
// data.reduce((xAcc, row) => {
|
|
36
|
+
// if (typeof xAcc[row[xPath]] === 'undefined') xAcc[row[xPath]] = 0
|
|
37
|
+
// xAcc[row[xPath]] += row[yPath]
|
|
38
|
+
// return xAcc
|
|
39
|
+
// }, {}),
|
|
40
|
+
// )
|
|
41
|
+
// })
|
|
42
|
+
// console.log('setSettings', {
|
|
43
|
+
// yColumns,
|
|
44
|
+
// xAxisData,
|
|
45
|
+
// yAxisData,
|
|
46
|
+
// })
|
|
47
|
+
// setSettings((_: any) => {
|
|
48
|
+
// return {
|
|
49
|
+
// yColumns,
|
|
50
|
+
// xAxisData,
|
|
51
|
+
// yAxisData,
|
|
52
|
+
// }
|
|
53
|
+
// })
|
|
54
|
+
// } else {
|
|
55
|
+
// setSettings({
|
|
56
|
+
// yColumns: [],
|
|
57
|
+
// xAxisData: [],
|
|
58
|
+
// yAxisData: [],
|
|
59
|
+
// })
|
|
60
|
+
// }
|
|
61
|
+
// }
|
|
62
|
+
// }, [dataSettings, viewSettings])
|
|
63
|
+
return ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)("style", { children: "\n html,\n body,\n #root {\n width: 100%;\n height: 100%;\n margin: 0;\n }\n " }), (0, jsx_runtime_1.jsx)(echarts_for_react_1.default, { style: { width: '100%', height: '100%' }, notMerge: true, option: {
|
|
64
|
+
xAxis: {
|
|
65
|
+
type: 'category',
|
|
66
|
+
data: ['Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat', 'Sun'],
|
|
67
|
+
},
|
|
68
|
+
yAxis: {
|
|
69
|
+
type: 'value',
|
|
70
|
+
},
|
|
71
|
+
series: [
|
|
72
|
+
{
|
|
73
|
+
data: [150, 230, 224, 218, 135, 147, 260],
|
|
74
|
+
type: 'line',
|
|
75
|
+
},
|
|
76
|
+
],
|
|
77
|
+
} })] }));
|
|
78
|
+
};
|
|
79
|
+
exports.default = WidgetComponent;
|
package/src/app/App.tsx
ADDED
|
@@ -0,0 +1,124 @@
|
|
|
1
|
+
import React from 'react'
|
|
2
|
+
|
|
3
|
+
import ReactECharts from 'echarts-for-react'
|
|
4
|
+
import { DataOptions, ViewOptions } from '../types'
|
|
5
|
+
|
|
6
|
+
export interface DataSettings {
|
|
7
|
+
data: any[]
|
|
8
|
+
columns: any[]
|
|
9
|
+
apiKey?: string
|
|
10
|
+
refreshInterval?: number
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
export interface ViewSettings {
|
|
14
|
+
theme: 'light' | 'dark'
|
|
15
|
+
showHeader: boolean
|
|
16
|
+
showFooter: boolean
|
|
17
|
+
language: string
|
|
18
|
+
[key: string]: any
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
interface WidgetProps {
|
|
22
|
+
dataOptions?: DataOptions
|
|
23
|
+
viewOptions?: ViewOptions
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
const WidgetComponent: React.FC<WidgetProps> = ({
|
|
27
|
+
dataOptions,
|
|
28
|
+
viewOptions,
|
|
29
|
+
}) => {
|
|
30
|
+
console.log('dataOptions', dataOptions)
|
|
31
|
+
console.log('viewOptions', viewOptions)
|
|
32
|
+
console.log('render')
|
|
33
|
+
//
|
|
34
|
+
// const [settings, setSettings] = useState<any>({
|
|
35
|
+
// yColumns: [],
|
|
36
|
+
// xAxisData: [],
|
|
37
|
+
// yAxisData: [],
|
|
38
|
+
// })
|
|
39
|
+
|
|
40
|
+
// useEffect(() => {
|
|
41
|
+
// console.log('useEffect')
|
|
42
|
+
|
|
43
|
+
// if (dataSettings?.columns) {
|
|
44
|
+
// const { data, columns } = dataSettings
|
|
45
|
+
|
|
46
|
+
// const xColumn = columns.find(col => col.zoneId === 'X')
|
|
47
|
+
// const sColumn = columns.find(col => col.zoneId === 'S')
|
|
48
|
+
// const yColumns = columns.filter(col => col.zoneId === 'Y')
|
|
49
|
+
// //
|
|
50
|
+
// if (xColumn && yColumns.length) {
|
|
51
|
+
// const xPath = xColumn.path
|
|
52
|
+
// const sPath = sColumn?.path || null
|
|
53
|
+
// const yPaths = yColumns!.map(col => col.path)
|
|
54
|
+
// //
|
|
55
|
+
// const xAxisData = Array.from(new Set(data.map(row => row[xPath])))
|
|
56
|
+
// const yAxisData = yPaths.map(yPath => {
|
|
57
|
+
// return Object.values(
|
|
58
|
+
// data.reduce((xAcc, row) => {
|
|
59
|
+
// if (typeof xAcc[row[xPath]] === 'undefined') xAcc[row[xPath]] = 0
|
|
60
|
+
// xAcc[row[xPath]] += row[yPath]
|
|
61
|
+
|
|
62
|
+
// return xAcc
|
|
63
|
+
// }, {}),
|
|
64
|
+
// )
|
|
65
|
+
// })
|
|
66
|
+
|
|
67
|
+
// console.log('setSettings', {
|
|
68
|
+
// yColumns,
|
|
69
|
+
// xAxisData,
|
|
70
|
+
// yAxisData,
|
|
71
|
+
// })
|
|
72
|
+
|
|
73
|
+
// setSettings((_: any) => {
|
|
74
|
+
// return {
|
|
75
|
+
// yColumns,
|
|
76
|
+
// xAxisData,
|
|
77
|
+
// yAxisData,
|
|
78
|
+
// }
|
|
79
|
+
// })
|
|
80
|
+
// } else {
|
|
81
|
+
// setSettings({
|
|
82
|
+
// yColumns: [],
|
|
83
|
+
// xAxisData: [],
|
|
84
|
+
// yAxisData: [],
|
|
85
|
+
// })
|
|
86
|
+
// }
|
|
87
|
+
// }
|
|
88
|
+
// }, [dataSettings, viewSettings])
|
|
89
|
+
|
|
90
|
+
return (
|
|
91
|
+
<>
|
|
92
|
+
<style>{`
|
|
93
|
+
html,
|
|
94
|
+
body,
|
|
95
|
+
#root {
|
|
96
|
+
width: 100%;
|
|
97
|
+
height: 100%;
|
|
98
|
+
margin: 0;
|
|
99
|
+
}
|
|
100
|
+
`}</style>
|
|
101
|
+
<ReactECharts
|
|
102
|
+
style={{ width: '100%', height: '100%' }}
|
|
103
|
+
notMerge={true}
|
|
104
|
+
option={{
|
|
105
|
+
xAxis: {
|
|
106
|
+
type: 'category',
|
|
107
|
+
data: ['Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat', 'Sun'],
|
|
108
|
+
},
|
|
109
|
+
yAxis: {
|
|
110
|
+
type: 'value',
|
|
111
|
+
},
|
|
112
|
+
series: [
|
|
113
|
+
{
|
|
114
|
+
data: [150, 230, 224, 218, 135, 147, 260],
|
|
115
|
+
type: 'line',
|
|
116
|
+
},
|
|
117
|
+
],
|
|
118
|
+
}}
|
|
119
|
+
/>
|
|
120
|
+
</>
|
|
121
|
+
)
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
export default WidgetComponent
|
package/src/config.js
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.config = void 0;
|
|
7
|
+
var package_json_1 = __importDefault(require("../package.json"));
|
|
8
|
+
exports.config = {
|
|
9
|
+
label: {
|
|
10
|
+
ru: 'Комбинированная диаграмма: Cтолбчатая и Линейная (UX)',
|
|
11
|
+
en: 'Combo Chart: Bar and Line (UX)',
|
|
12
|
+
},
|
|
13
|
+
categories: ['compare', 'distribution'],
|
|
14
|
+
icon: 'icon.svg',
|
|
15
|
+
preview: 'preview.webp',
|
|
16
|
+
version: package_json_1.default.version,
|
|
17
|
+
};
|
package/src/config.ts
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import packageJson from '../package.json'
|
|
2
|
+
import { Config } from './types'
|
|
3
|
+
|
|
4
|
+
export const config: Config = {
|
|
5
|
+
label: {
|
|
6
|
+
ru: 'Комбинированная диаграмма: Cтолбчатая и Линейная (UX)',
|
|
7
|
+
en: 'Combo Chart: Bar and Line (UX)',
|
|
8
|
+
},
|
|
9
|
+
categories: ['compare', 'distribution'],
|
|
10
|
+
icon: 'icon.svg',
|
|
11
|
+
preview: 'preview.webp',
|
|
12
|
+
version: packageJson.version,
|
|
13
|
+
}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.createDataOptions = void 0;
|
|
4
|
+
var types_1 = require("./types");
|
|
5
|
+
var custom_1 = require("./types/custom");
|
|
6
|
+
var block = function (props) { return props; };
|
|
7
|
+
var createDataOptions = function () {
|
|
8
|
+
return [
|
|
9
|
+
block({
|
|
10
|
+
key: custom_1.EBlockKey.X,
|
|
11
|
+
queryFn: types_1.DataQueryFunction.Group,
|
|
12
|
+
label: {
|
|
13
|
+
ru: 'Ось X',
|
|
14
|
+
en: 'X axis',
|
|
15
|
+
},
|
|
16
|
+
icon: types_1.BlockIcon.AxisX,
|
|
17
|
+
columnTypes: [types_1.ColumnType.String, types_1.ColumnType.Date],
|
|
18
|
+
limit: 1,
|
|
19
|
+
}),
|
|
20
|
+
block({
|
|
21
|
+
key: custom_1.EBlockKey.S,
|
|
22
|
+
queryFn: types_1.DataQueryFunction.Group,
|
|
23
|
+
label: {
|
|
24
|
+
ru: 'Серия',
|
|
25
|
+
en: 'Series',
|
|
26
|
+
},
|
|
27
|
+
columnTypes: [types_1.ColumnType.String, types_1.ColumnType.Date],
|
|
28
|
+
limit: 1,
|
|
29
|
+
}),
|
|
30
|
+
block({
|
|
31
|
+
key: custom_1.EBlockKey.Y,
|
|
32
|
+
queryFn: types_1.DataQueryFunction.Sum,
|
|
33
|
+
label: {
|
|
34
|
+
ru: 'Ось Y',
|
|
35
|
+
en: 'Y axis',
|
|
36
|
+
},
|
|
37
|
+
icon: types_1.BlockIcon.AxisY,
|
|
38
|
+
columnTypes: [types_1.ColumnType.Number],
|
|
39
|
+
}),
|
|
40
|
+
];
|
|
41
|
+
};
|
|
42
|
+
exports.createDataOptions = createDataOptions;
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import {
|
|
2
|
+
BlockIcon,
|
|
3
|
+
ColumnType,
|
|
4
|
+
CreateDataOptions,
|
|
5
|
+
DataQueryFunction,
|
|
6
|
+
} from './types'
|
|
7
|
+
import { EBlockKey } from './types/custom'
|
|
8
|
+
|
|
9
|
+
const block = (props: any) => props
|
|
10
|
+
|
|
11
|
+
export const createDataOptions: CreateDataOptions = () => {
|
|
12
|
+
return [
|
|
13
|
+
block({
|
|
14
|
+
key: EBlockKey.X,
|
|
15
|
+
queryFn: DataQueryFunction.Group,
|
|
16
|
+
label: {
|
|
17
|
+
ru: 'Ось X',
|
|
18
|
+
en: 'X axis',
|
|
19
|
+
},
|
|
20
|
+
icon: BlockIcon.AxisX,
|
|
21
|
+
columnTypes: [ColumnType.String, ColumnType.Date],
|
|
22
|
+
limit: 1,
|
|
23
|
+
}),
|
|
24
|
+
block({
|
|
25
|
+
key: EBlockKey.S,
|
|
26
|
+
queryFn: DataQueryFunction.Group,
|
|
27
|
+
label: {
|
|
28
|
+
ru: 'Серия',
|
|
29
|
+
en: 'Series',
|
|
30
|
+
},
|
|
31
|
+
columnTypes: [ColumnType.String, ColumnType.Date],
|
|
32
|
+
limit: 1,
|
|
33
|
+
}),
|
|
34
|
+
block({
|
|
35
|
+
key: EBlockKey.Y,
|
|
36
|
+
queryFn: DataQueryFunction.Sum,
|
|
37
|
+
label: {
|
|
38
|
+
ru: 'Ось Y',
|
|
39
|
+
en: 'Y axis',
|
|
40
|
+
},
|
|
41
|
+
icon: BlockIcon.AxisY,
|
|
42
|
+
columnTypes: [ColumnType.Number],
|
|
43
|
+
}),
|
|
44
|
+
]
|
|
45
|
+
}
|
package/src/index.js
ADDED
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.ReactSDK = void 0;
|
|
7
|
+
exports.cli = cli;
|
|
8
|
+
var child_process_1 = require("child_process");
|
|
9
|
+
var fs_1 = __importDefault(require("fs"));
|
|
10
|
+
var path_1 = __importDefault(require("path"));
|
|
11
|
+
var url_1 = require("url");
|
|
12
|
+
var __filename = (0, url_1.fileURLToPath)(import.meta.url);
|
|
13
|
+
var __dirname = path_1.default.dirname(__filename);
|
|
14
|
+
var ReactSDK = /** @class */ (function () {
|
|
15
|
+
function ReactSDK() {
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* Инициализация нового проекта
|
|
19
|
+
*/
|
|
20
|
+
ReactSDK.init = function (options) {
|
|
21
|
+
var projectName = options.projectName, _a = options.template, template = _a === void 0 ? 'default' : _a, _b = options.packageManager, packageManager = _b === void 0 ? 'npm' : _b;
|
|
22
|
+
console.log("\uD83D\uDCE6 Creating new React app: ".concat(projectName));
|
|
23
|
+
// Создаем папку проекта
|
|
24
|
+
var projectPath = path_1.default.join(process.cwd(), projectName);
|
|
25
|
+
if (fs_1.default.existsSync(projectPath)) {
|
|
26
|
+
throw new Error("Directory ".concat(projectName, " already exists!"));
|
|
27
|
+
}
|
|
28
|
+
// // Копируем шаблон
|
|
29
|
+
// const templatePath = path.join(__dirname, '../templates/app-template')
|
|
30
|
+
// this.copyTemplate(templatePath, projectPath)
|
|
31
|
+
// // Обновляем package.json
|
|
32
|
+
// const pkgPath = path.join(projectPath, 'package.json')
|
|
33
|
+
// const pkg = JSON.parse(fs.readFileSync(pkgPath, 'utf-8'))
|
|
34
|
+
// pkg.name = projectName
|
|
35
|
+
// fs.writeFileSync(pkgPath, JSON.stringify(pkg, null, 2))
|
|
36
|
+
// Устанавливаем зависимости
|
|
37
|
+
console.log("\uD83D\uDCE6 Installing dependencies using ".concat(packageManager, "..."));
|
|
38
|
+
(0, child_process_1.execSync)("cd ".concat(projectName, " && ").concat(packageManager, " install"), {
|
|
39
|
+
stdio: 'inherit',
|
|
40
|
+
});
|
|
41
|
+
console.log("\u2705 Project ".concat(projectName, " created successfully!"));
|
|
42
|
+
console.log("\n \uD83D\uDE80 To get started:\n cd ".concat(projectName, "\n ").concat(packageManager, " run dev\n "));
|
|
43
|
+
};
|
|
44
|
+
ReactSDK.copyTemplate = function (src, dest) {
|
|
45
|
+
if (!fs_1.default.existsSync(dest)) {
|
|
46
|
+
fs_1.default.mkdirSync(dest, { recursive: true });
|
|
47
|
+
}
|
|
48
|
+
var entries = fs_1.default.readdirSync(src, { withFileTypes: true });
|
|
49
|
+
for (var _i = 0, entries_1 = entries; _i < entries_1.length; _i++) {
|
|
50
|
+
var entry = entries_1[_i];
|
|
51
|
+
var srcPath = path_1.default.join(src, entry.name);
|
|
52
|
+
var destPath = path_1.default.join(dest, entry.name);
|
|
53
|
+
if (entry.isDirectory()) {
|
|
54
|
+
this.copyTemplate(srcPath, destPath);
|
|
55
|
+
}
|
|
56
|
+
else {
|
|
57
|
+
fs_1.default.copyFileSync(srcPath, destPath);
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
};
|
|
61
|
+
return ReactSDK;
|
|
62
|
+
}());
|
|
63
|
+
exports.ReactSDK = ReactSDK;
|
|
64
|
+
// CLI интерфейс
|
|
65
|
+
function cli() {
|
|
66
|
+
var args = process.argv.slice(2);
|
|
67
|
+
var command = args[0];
|
|
68
|
+
if (command === 'init') {
|
|
69
|
+
var projectName = args[1] || 'my-app';
|
|
70
|
+
ReactSDK.init({ projectName: projectName });
|
|
71
|
+
}
|
|
72
|
+
else {
|
|
73
|
+
console.log("\n Usage:\n npx my-react-sdk init <project-name>\n \n Examples:\n npx my-react-sdk init my-new-app\n ");
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
// Если запускается как CLI
|
|
77
|
+
if (import.meta.url === "file://".concat(process.argv[1])) {
|
|
78
|
+
cli();
|
|
79
|
+
}
|
package/src/index.ts
ADDED
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
import { execSync } from 'child_process'
|
|
2
|
+
import fs from 'fs'
|
|
3
|
+
import path from 'path'
|
|
4
|
+
import { fileURLToPath } from 'url'
|
|
5
|
+
|
|
6
|
+
const __filename = fileURLToPath(import.meta.url)
|
|
7
|
+
const __dirname = path.dirname(__filename)
|
|
8
|
+
|
|
9
|
+
export interface InitOptions {
|
|
10
|
+
projectName: string
|
|
11
|
+
template?: 'default' | 'minimal'
|
|
12
|
+
packageManager?: 'npm' | 'yarn' | 'pnpm'
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
export class ReactSDK {
|
|
16
|
+
/**
|
|
17
|
+
* Инициализация нового проекта
|
|
18
|
+
*/
|
|
19
|
+
static init(options: InitOptions) {
|
|
20
|
+
const {
|
|
21
|
+
projectName,
|
|
22
|
+
template = 'default',
|
|
23
|
+
packageManager = 'npm',
|
|
24
|
+
} = options
|
|
25
|
+
|
|
26
|
+
console.log(`📦 Creating new React app: ${projectName}`)
|
|
27
|
+
|
|
28
|
+
// Создаем папку проекта
|
|
29
|
+
const projectPath = path.join(process.cwd(), projectName)
|
|
30
|
+
|
|
31
|
+
if (fs.existsSync(projectPath)) {
|
|
32
|
+
throw new Error(`Directory ${projectName} already exists!`)
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
// // Копируем шаблон
|
|
36
|
+
// const templatePath = path.join(__dirname, '../templates/app-template')
|
|
37
|
+
// this.copyTemplate(templatePath, projectPath)
|
|
38
|
+
|
|
39
|
+
// // Обновляем package.json
|
|
40
|
+
// const pkgPath = path.join(projectPath, 'package.json')
|
|
41
|
+
// const pkg = JSON.parse(fs.readFileSync(pkgPath, 'utf-8'))
|
|
42
|
+
// pkg.name = projectName
|
|
43
|
+
// fs.writeFileSync(pkgPath, JSON.stringify(pkg, null, 2))
|
|
44
|
+
|
|
45
|
+
// Устанавливаем зависимости
|
|
46
|
+
console.log(`📦 Installing dependencies using ${packageManager}...`)
|
|
47
|
+
execSync(`cd ${projectName} && ${packageManager} install`, {
|
|
48
|
+
stdio: 'inherit',
|
|
49
|
+
})
|
|
50
|
+
|
|
51
|
+
console.log(`✅ Project ${projectName} created successfully!`)
|
|
52
|
+
console.log(`
|
|
53
|
+
🚀 To get started:
|
|
54
|
+
cd ${projectName}
|
|
55
|
+
${packageManager} run dev
|
|
56
|
+
`)
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
private static copyTemplate(src: string, dest: string) {
|
|
60
|
+
if (!fs.existsSync(dest)) {
|
|
61
|
+
fs.mkdirSync(dest, { recursive: true })
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
const entries = fs.readdirSync(src, { withFileTypes: true })
|
|
65
|
+
|
|
66
|
+
for (const entry of entries) {
|
|
67
|
+
const srcPath = path.join(src, entry.name)
|
|
68
|
+
const destPath = path.join(dest, entry.name)
|
|
69
|
+
|
|
70
|
+
if (entry.isDirectory()) {
|
|
71
|
+
this.copyTemplate(srcPath, destPath)
|
|
72
|
+
} else {
|
|
73
|
+
fs.copyFileSync(srcPath, destPath)
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
// CLI интерфейс
|
|
80
|
+
export function cli() {
|
|
81
|
+
const args = process.argv.slice(2)
|
|
82
|
+
const command = args[0]
|
|
83
|
+
|
|
84
|
+
if (command === 'init') {
|
|
85
|
+
const projectName = args[1] || 'my-app'
|
|
86
|
+
ReactSDK.init({ projectName })
|
|
87
|
+
} else {
|
|
88
|
+
console.log(`
|
|
89
|
+
Usage:
|
|
90
|
+
npx my-react-sdk init <project-name>
|
|
91
|
+
|
|
92
|
+
Examples:
|
|
93
|
+
npx my-react-sdk init my-new-app
|
|
94
|
+
`)
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
// Если запускается как CLI
|
|
99
|
+
if (import.meta.url === `file://${process.argv[1]}`) {
|
|
100
|
+
cli()
|
|
101
|
+
}
|