@yydb/yyds 0.0.21 → 0.0.23
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/yyds.mjs +56 -3
- package/package.json +6 -6
- package/src/bindings.ts +3 -2
- package/src/node/runtime.ts +2 -2
package/bin/yyds.mjs
CHANGED
|
@@ -1,14 +1,20 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
+
import { readFileSync } from "node:fs";
|
|
3
|
+
|
|
2
4
|
import { loadYydsNative } from "../src/node/load.ts";
|
|
3
5
|
import { parseStartOptions, runNodeStart } from "../src/node/runtime.ts";
|
|
4
6
|
import { parseWebuiArgs, runWebui } from "../src/node/webui-cmd.ts";
|
|
5
7
|
|
|
6
8
|
function usage() {
|
|
7
|
-
return "usage: yyds <init|start|status|stop|webui> ...";
|
|
9
|
+
return "usage: yyds <init|start|status|stop|webui|catalog> ...";
|
|
8
10
|
}
|
|
9
11
|
|
|
10
12
|
function startUsage() {
|
|
11
|
-
return "usage: yyds start --data-dir DIR --cluster-id ID --node-id ID [--redis-port PORT] [--pgsql-port PORT] [--mysql-port PORT] [--mongo-port PORT] [--wire-port PORT]";
|
|
13
|
+
return "usage: yyds start --data-dir DIR --cluster-id ID --node-id ID [--catalog-path FILE] [--redis-port PORT] [--pgsql-port PORT] [--mysql-port PORT] [--mongo-port PORT] [--wire-port PORT]";
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
function catalogUsage() {
|
|
17
|
+
return "usage: yyds catalog --catalog-path FILE --schema-file FILE [--schema-version NUMBER]";
|
|
12
18
|
}
|
|
13
19
|
|
|
14
20
|
function webuiUsage() {
|
|
@@ -20,6 +26,7 @@ function parseCommonArgs(command, args) {
|
|
|
20
26
|
dataDir: "",
|
|
21
27
|
clusterId: "",
|
|
22
28
|
nodeId: "",
|
|
29
|
+
catalogPath: undefined,
|
|
23
30
|
redisPort: 6379,
|
|
24
31
|
pgsqlPort: undefined,
|
|
25
32
|
mysqlPort: undefined,
|
|
@@ -43,6 +50,12 @@ function parseCommonArgs(command, args) {
|
|
|
43
50
|
options.nodeId = value;
|
|
44
51
|
index += 1;
|
|
45
52
|
break;
|
|
53
|
+
case "--catalog-path":
|
|
54
|
+
if (command !== "start")
|
|
55
|
+
throw new Error(`option ${flag} is not valid for this command`);
|
|
56
|
+
options.catalogPath = value;
|
|
57
|
+
index += 1;
|
|
58
|
+
break;
|
|
46
59
|
case "--redis-port":
|
|
47
60
|
if (command !== "start")
|
|
48
61
|
throw new Error(`option ${flag} is not valid for this command`);
|
|
@@ -84,6 +97,39 @@ function parseCommonArgs(command, args) {
|
|
|
84
97
|
return options;
|
|
85
98
|
}
|
|
86
99
|
|
|
100
|
+
function runCatalog(native, args) {
|
|
101
|
+
let catalogPath = "";
|
|
102
|
+
let schemaFile = "";
|
|
103
|
+
let schemaVersion = 1;
|
|
104
|
+
for (let index = 0; index < args.length; index += 1) {
|
|
105
|
+
const flag = args[index];
|
|
106
|
+
const value = args[index + 1];
|
|
107
|
+
if (!value || value.startsWith("--")) throw new Error(`missing value for ${flag}\n${catalogUsage()}`);
|
|
108
|
+
switch (flag) {
|
|
109
|
+
case "--catalog-path":
|
|
110
|
+
catalogPath = value;
|
|
111
|
+
index += 1;
|
|
112
|
+
break;
|
|
113
|
+
case "--schema-file":
|
|
114
|
+
schemaFile = value;
|
|
115
|
+
index += 1;
|
|
116
|
+
break;
|
|
117
|
+
case "--schema-version": {
|
|
118
|
+
const parsed = Number(value);
|
|
119
|
+
if (!Number.isInteger(parsed) || parsed <= 0) throw new Error(`invalid schema version '${value}'`);
|
|
120
|
+
schemaVersion = parsed;
|
|
121
|
+
index += 1;
|
|
122
|
+
break;
|
|
123
|
+
}
|
|
124
|
+
default:
|
|
125
|
+
throw new Error(`unknown option '${flag}'\n${catalogUsage()}`);
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
if (!catalogPath || !schemaFile) throw new Error(catalogUsage());
|
|
129
|
+
native.catalogPublishSchema(catalogPath, schemaVersion, readFileSync(schemaFile, "utf8"));
|
|
130
|
+
console.log(`published schema version ${schemaVersion} into ${catalogPath}`);
|
|
131
|
+
}
|
|
132
|
+
|
|
87
133
|
async function main(args) {
|
|
88
134
|
const command = args[0];
|
|
89
135
|
const rest = args.slice(1);
|
|
@@ -94,6 +140,12 @@ async function main(args) {
|
|
|
94
140
|
}
|
|
95
141
|
|
|
96
142
|
const native = loadYydsNative();
|
|
143
|
+
|
|
144
|
+
if (command === "catalog") {
|
|
145
|
+
runCatalog(native, rest);
|
|
146
|
+
return;
|
|
147
|
+
}
|
|
148
|
+
|
|
97
149
|
const options = parseCommonArgs(command, rest);
|
|
98
150
|
|
|
99
151
|
switch (command) {
|
|
@@ -108,6 +160,7 @@ async function main(args) {
|
|
|
108
160
|
dataDir: options.dataDir,
|
|
109
161
|
clusterId: options.clusterId,
|
|
110
162
|
nodeId: options.nodeId,
|
|
163
|
+
catalogPath: options.catalogPath,
|
|
111
164
|
redisPort: options.redisPort,
|
|
112
165
|
pgsqlPort: options.pgsqlPort,
|
|
113
166
|
mysqlPort: options.mysqlPort,
|
|
@@ -139,7 +192,7 @@ async function main(args) {
|
|
|
139
192
|
return;
|
|
140
193
|
}
|
|
141
194
|
default:
|
|
142
|
-
throw new Error(command ? `unknown command '${command}'` : `${usage()}\n${startUsage()}\n${webuiUsage()}`);
|
|
195
|
+
throw new Error(command ? `unknown command '${command}'` : `${usage()}\n${startUsage()}\n${webuiUsage()}\n${catalogUsage()}`);
|
|
143
196
|
}
|
|
144
197
|
}
|
|
145
198
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@yydb/yyds",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.23",
|
|
4
4
|
"description": "Node.js facade, CLI, and native bindings for local YYDS nodes.",
|
|
5
5
|
"license": "MPL-2.0",
|
|
6
6
|
"type": "module",
|
|
@@ -59,14 +59,14 @@
|
|
|
59
59
|
"access": "public"
|
|
60
60
|
},
|
|
61
61
|
"optionalDependencies": {
|
|
62
|
-
"@yydb/yyds-win32-x64": "0.0.
|
|
63
|
-
"@yydb/yyds-linux-x64": "0.0.
|
|
64
|
-
"@yydb/yyds-darwin-x64": "0.0.
|
|
65
|
-
"@yydb/yyds-darwin-arm64": "0.0.
|
|
62
|
+
"@yydb/yyds-win32-x64": "0.0.23",
|
|
63
|
+
"@yydb/yyds-linux-x64": "0.0.23",
|
|
64
|
+
"@yydb/yyds-darwin-x64": "0.0.23",
|
|
65
|
+
"@yydb/yyds-darwin-arm64": "0.0.23"
|
|
66
66
|
},
|
|
67
67
|
"devDependencies": {
|
|
68
68
|
"@types/node": "^22.15.0",
|
|
69
|
-
"@yydb/yyds-webui": "0.0.
|
|
69
|
+
"@yydb/yyds-webui": "0.0.23",
|
|
70
70
|
"typescript": "^5.9.2"
|
|
71
71
|
},
|
|
72
72
|
"engines": {
|
package/src/bindings.ts
CHANGED
|
@@ -14,7 +14,7 @@ export interface YydsBindings {
|
|
|
14
14
|
) => RedisServiceBinding;
|
|
15
15
|
PgsqlServiceHandle: {
|
|
16
16
|
new (lease: unknown, port: number): PgsqlServiceBinding;
|
|
17
|
-
|
|
17
|
+
startWithExecutor(
|
|
18
18
|
lease: unknown,
|
|
19
19
|
port: number,
|
|
20
20
|
executor: unknown,
|
|
@@ -23,7 +23,7 @@ export interface YydsBindings {
|
|
|
23
23
|
};
|
|
24
24
|
MysqlServiceHandle: {
|
|
25
25
|
new (lease: unknown, port: number): MysqlServiceBinding;
|
|
26
|
-
|
|
26
|
+
startWithExecutor(
|
|
27
27
|
lease: unknown,
|
|
28
28
|
port: number,
|
|
29
29
|
executor: unknown,
|
|
@@ -36,6 +36,7 @@ export interface YydsBindings {
|
|
|
36
36
|
executor: unknown,
|
|
37
37
|
) => MongoServiceBinding;
|
|
38
38
|
WireServerHandle: new (port: number, executor: unknown) => WireServiceBinding;
|
|
39
|
+
catalogPublishSchema(catalogPath: string, schemaVersion: number, schemaDocument: string): void;
|
|
39
40
|
nodeInit(dataDir: string, identity: unknown): void;
|
|
40
41
|
nodeInspect(dataDir: string): NodeStatusBinding;
|
|
41
42
|
nodeReadRuntimeStatus(dataDir: string): string | null;
|
package/src/node/runtime.ts
CHANGED
|
@@ -119,7 +119,7 @@ export async function runNodeStart(options: StartNodeOptions): Promise<void> {
|
|
|
119
119
|
options.pgsqlPort === undefined
|
|
120
120
|
? undefined
|
|
121
121
|
: hasRuntime
|
|
122
|
-
? native.PgsqlServiceHandle.
|
|
122
|
+
? native.PgsqlServiceHandle.startWithExecutor(
|
|
123
123
|
lease,
|
|
124
124
|
options.pgsqlPort,
|
|
125
125
|
executor,
|
|
@@ -130,7 +130,7 @@ export async function runNodeStart(options: StartNodeOptions): Promise<void> {
|
|
|
130
130
|
options.mysqlPort === undefined
|
|
131
131
|
? undefined
|
|
132
132
|
: hasRuntime
|
|
133
|
-
? native.MysqlServiceHandle.
|
|
133
|
+
? native.MysqlServiceHandle.startWithExecutor(
|
|
134
134
|
lease,
|
|
135
135
|
options.mysqlPort,
|
|
136
136
|
executor,
|