@nextclaw/app-runtime 0.2.0 → 0.4.0

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.
Files changed (68) hide show
  1. package/README.md +125 -4
  2. package/dist/bundle/app-bundle.service.d.ts +27 -0
  3. package/dist/bundle/app-bundle.service.js +133 -0
  4. package/dist/bundle/app-bundle.types.d.ts +24 -0
  5. package/dist/cli/app-runtime-cli.service.d.ts +28 -0
  6. package/dist/cli/app-runtime-cli.service.js +298 -0
  7. package/dist/cli/app-runtime-options.service.d.ts +67 -0
  8. package/dist/cli/app-runtime-options.service.js +242 -0
  9. package/dist/commands/create.controller.d.ts +14 -0
  10. package/dist/commands/grant.controller.d.ts +16 -0
  11. package/dist/commands/grant.controller.js +25 -0
  12. package/dist/commands/info.controller.d.ts +14 -0
  13. package/dist/commands/info.controller.js +27 -0
  14. package/dist/commands/install.controller.d.ts +15 -0
  15. package/dist/commands/install.controller.js +24 -0
  16. package/dist/commands/list.controller.d.ts +13 -0
  17. package/dist/commands/list.controller.js +25 -0
  18. package/dist/commands/pack.controller.d.ts +15 -0
  19. package/dist/commands/pack.controller.js +25 -0
  20. package/dist/commands/permissions.controller.d.ts +14 -0
  21. package/dist/commands/permissions.controller.js +26 -0
  22. package/dist/commands/publish.controller.d.ts +17 -0
  23. package/dist/commands/publish.controller.js +29 -0
  24. package/dist/commands/registry.controller.d.ts +16 -0
  25. package/dist/commands/registry.controller.js +27 -0
  26. package/dist/commands/revoke.controller.d.ts +15 -0
  27. package/dist/commands/revoke.controller.js +24 -0
  28. package/dist/commands/run.controller.js +14 -6
  29. package/dist/commands/uninstall.controller.d.ts +15 -0
  30. package/dist/commands/uninstall.controller.js +23 -0
  31. package/dist/commands/update.controller.d.ts +16 -0
  32. package/dist/commands/update.controller.js +29 -0
  33. package/dist/host/app-instance.service.d.ts +3 -1
  34. package/dist/host/app-instance.service.js +2 -2
  35. package/dist/index.d.ts +31 -2
  36. package/dist/index.js +28 -2
  37. package/dist/install/app-installation.service.d.ts +37 -0
  38. package/dist/install/app-installation.service.js +255 -0
  39. package/dist/install/app-installation.types.d.ts +62 -0
  40. package/dist/main.js +5 -132
  41. package/dist/package.js +1 -1
  42. package/dist/paths/app-home.service.d.ts +16 -0
  43. package/dist/paths/app-home.service.js +42 -0
  44. package/dist/permissions/app-grant.service.d.ts +22 -0
  45. package/dist/permissions/app-grant.service.js +63 -0
  46. package/dist/permissions/app-permissions.service.d.ts +3 -1
  47. package/dist/permissions/app-permissions.service.js +12 -5
  48. package/dist/permissions/app-permissions.types.d.ts +28 -1
  49. package/dist/publish/app-marketplace-client.service.d.ts +13 -0
  50. package/dist/publish/app-marketplace-client.service.js +31 -0
  51. package/dist/publish/app-marketplace-metadata.service.d.ts +27 -0
  52. package/dist/publish/app-marketplace-metadata.service.js +84 -0
  53. package/dist/publish/app-publish.service.d.ts +22 -0
  54. package/dist/publish/app-publish.service.js +74 -0
  55. package/dist/publish/app-publish.types.d.ts +66 -0
  56. package/dist/publish/app-publish.types.js +4 -0
  57. package/dist/registry/app-registry-config.service.d.ts +16 -0
  58. package/dist/registry/app-registry-config.service.js +84 -0
  59. package/dist/registry/app-registry.service.d.ts +38 -0
  60. package/dist/registry/app-registry.service.js +115 -0
  61. package/dist/registry/app-registry.types.d.ts +33 -0
  62. package/dist/registry/app-remote-registry-client.service.d.ts +28 -0
  63. package/dist/registry/app-remote-registry-client.service.js +114 -0
  64. package/dist/registry/app-remote-registry.types.d.ts +52 -0
  65. package/dist/registry/app-remote-registry.types.js +4 -0
  66. package/dist/scaffold/app-scaffold.service.d.ts +21 -0
  67. package/dist/scaffold/app-scaffold.service.js +55 -1
  68. package/package.json +4 -2
@@ -0,0 +1,67 @@
1
+ import { AppDocumentGrantMap } from "../permissions/app-permissions.types.js";
2
+
3
+ //#region src/cli/app-runtime-options.service.d.ts
4
+ type RuntimeCliOptions = {
5
+ host: string;
6
+ port: number;
7
+ json: boolean;
8
+ documentGrantMap: AppDocumentGrantMap;
9
+ };
10
+ type CreateCliOptions = {
11
+ json: boolean;
12
+ };
13
+ type PackCliOptions = {
14
+ json: boolean;
15
+ outputPath?: string;
16
+ };
17
+ type JsonOnlyCliOptions = {
18
+ json: boolean;
19
+ };
20
+ type InstallCliOptions = {
21
+ json: boolean;
22
+ registryUrl?: string;
23
+ };
24
+ type UpdateCliOptions = {
25
+ json: boolean;
26
+ registryUrl?: string;
27
+ version?: string;
28
+ };
29
+ type UninstallCliOptions = {
30
+ json: boolean;
31
+ purgeData: boolean;
32
+ };
33
+ type GrantCliOptions = {
34
+ json: boolean;
35
+ documentGrantMap: AppDocumentGrantMap;
36
+ };
37
+ type RevokeCliOptions = {
38
+ json: boolean;
39
+ documentScopeIds: string[];
40
+ };
41
+ type PublishCliOptions = {
42
+ json: boolean;
43
+ metadataPath?: string;
44
+ apiBaseUrl?: string;
45
+ token?: string;
46
+ };
47
+ declare class AppRuntimeOptionsService {
48
+ readTarget: (command: string, rawArgs: string[]) => {
49
+ target: string;
50
+ optionArgs: string[];
51
+ };
52
+ readCreateOptions: (rawArgs: string[]) => CreateCliOptions;
53
+ readPackOptions: (rawArgs: string[]) => PackCliOptions;
54
+ readJsonOnlyOptions: (rawArgs: string[]) => JsonOnlyCliOptions;
55
+ readInstallOptions: (rawArgs: string[]) => InstallCliOptions;
56
+ readUpdateOptions: (rawArgs: string[]) => UpdateCliOptions;
57
+ readUninstallOptions: (rawArgs: string[]) => UninstallCliOptions;
58
+ readRuntimeOptions: (rawArgs: string[]) => RuntimeCliOptions;
59
+ readGrantOptions: (rawArgs: string[]) => GrantCliOptions;
60
+ readRevokeOptions: (rawArgs: string[]) => RevokeCliOptions;
61
+ readPublishOptions: (rawArgs: string[]) => PublishCliOptions;
62
+ private assignDocumentGrant;
63
+ private readDocumentScopeId;
64
+ private requireOptionValue;
65
+ }
66
+ //#endregion
67
+ export { AppRuntimeOptionsService, CreateCliOptions, GrantCliOptions, InstallCliOptions, JsonOnlyCliOptions, PackCliOptions, PublishCliOptions, RevokeCliOptions, RuntimeCliOptions, UninstallCliOptions, UpdateCliOptions };
@@ -0,0 +1,242 @@
1
+ //#region src/cli/app-runtime-options.service.ts
2
+ var AppRuntimeOptionsService = class {
3
+ readTarget = (command, rawArgs) => {
4
+ const [target, ...optionArgs] = rawArgs;
5
+ if (!target || target.startsWith("--")) throw new Error(`${command} 缺少目标参数。`);
6
+ return {
7
+ target,
8
+ optionArgs
9
+ };
10
+ };
11
+ readCreateOptions = (rawArgs) => {
12
+ const options = { json: false };
13
+ for (const current of rawArgs) {
14
+ if (!current?.startsWith("--")) throw new Error(`未知参数:${current}`);
15
+ switch (current) {
16
+ case "--json":
17
+ options.json = true;
18
+ break;
19
+ default: throw new Error(`未知参数:${current}`);
20
+ }
21
+ }
22
+ return options;
23
+ };
24
+ readPackOptions = (rawArgs) => {
25
+ const options = { json: false };
26
+ for (let index = 0; index < rawArgs.length; index += 1) {
27
+ const current = rawArgs[index];
28
+ if (!current?.startsWith("--")) throw new Error(`未知参数:${current}`);
29
+ const nextValue = rawArgs[index + 1];
30
+ switch (current) {
31
+ case "--json":
32
+ options.json = true;
33
+ break;
34
+ case "--out":
35
+ options.outputPath = this.requireOptionValue(current, nextValue);
36
+ index += 1;
37
+ break;
38
+ default: throw new Error(`未知参数:${current}`);
39
+ }
40
+ }
41
+ return options;
42
+ };
43
+ readJsonOnlyOptions = (rawArgs) => {
44
+ const options = { json: false };
45
+ for (const current of rawArgs) {
46
+ if (!current?.startsWith("--")) throw new Error(`未知参数:${current}`);
47
+ switch (current) {
48
+ case "--json":
49
+ options.json = true;
50
+ break;
51
+ default: throw new Error(`未知参数:${current}`);
52
+ }
53
+ }
54
+ return options;
55
+ };
56
+ readInstallOptions = (rawArgs) => {
57
+ const options = { json: false };
58
+ for (let index = 0; index < rawArgs.length; index += 1) {
59
+ const current = rawArgs[index];
60
+ if (!current?.startsWith("--")) throw new Error(`未知参数:${current}`);
61
+ const nextValue = rawArgs[index + 1];
62
+ switch (current) {
63
+ case "--json":
64
+ options.json = true;
65
+ break;
66
+ case "--registry":
67
+ options.registryUrl = this.requireOptionValue(current, nextValue);
68
+ index += 1;
69
+ break;
70
+ default: throw new Error(`未知参数:${current}`);
71
+ }
72
+ }
73
+ return options;
74
+ };
75
+ readUpdateOptions = (rawArgs) => {
76
+ const options = { json: false };
77
+ for (let index = 0; index < rawArgs.length; index += 1) {
78
+ const current = rawArgs[index];
79
+ if (!current?.startsWith("--")) throw new Error(`未知参数:${current}`);
80
+ const nextValue = rawArgs[index + 1];
81
+ switch (current) {
82
+ case "--json":
83
+ options.json = true;
84
+ break;
85
+ case "--registry":
86
+ options.registryUrl = this.requireOptionValue(current, nextValue);
87
+ index += 1;
88
+ break;
89
+ case "--version":
90
+ options.version = this.requireOptionValue(current, nextValue);
91
+ index += 1;
92
+ break;
93
+ default: throw new Error(`未知参数:${current}`);
94
+ }
95
+ }
96
+ return options;
97
+ };
98
+ readUninstallOptions = (rawArgs) => {
99
+ const options = {
100
+ json: false,
101
+ purgeData: false
102
+ };
103
+ for (const current of rawArgs) {
104
+ if (!current?.startsWith("--")) throw new Error(`未知参数:${current}`);
105
+ switch (current) {
106
+ case "--json":
107
+ options.json = true;
108
+ break;
109
+ case "--purge-data":
110
+ options.purgeData = true;
111
+ break;
112
+ default: throw new Error(`未知参数:${current}`);
113
+ }
114
+ }
115
+ return options;
116
+ };
117
+ readRuntimeOptions = (rawArgs) => {
118
+ const options = {
119
+ host: "127.0.0.1",
120
+ port: 3100,
121
+ json: false,
122
+ documentGrantMap: {}
123
+ };
124
+ for (let index = 0; index < rawArgs.length; index += 1) {
125
+ const current = rawArgs[index];
126
+ if (!current?.startsWith("--")) throw new Error(`未知参数:${current}`);
127
+ const nextValue = rawArgs[index + 1];
128
+ switch (current) {
129
+ case "--host":
130
+ options.host = this.requireOptionValue(current, nextValue);
131
+ index += 1;
132
+ break;
133
+ case "--port":
134
+ options.port = Number.parseInt(this.requireOptionValue(current, nextValue), 10);
135
+ if (Number.isNaN(options.port) || options.port < 0) throw new Error("--port 必须是非负整数。");
136
+ index += 1;
137
+ break;
138
+ case "--json":
139
+ options.json = true;
140
+ break;
141
+ case "--document":
142
+ this.assignDocumentGrant(options.documentGrantMap, this.requireOptionValue(current, nextValue));
143
+ index += 1;
144
+ break;
145
+ default: throw new Error(`未知参数:${current}`);
146
+ }
147
+ }
148
+ return options;
149
+ };
150
+ readGrantOptions = (rawArgs) => {
151
+ const options = {
152
+ json: false,
153
+ documentGrantMap: {}
154
+ };
155
+ for (let index = 0; index < rawArgs.length; index += 1) {
156
+ const current = rawArgs[index];
157
+ if (!current?.startsWith("--")) throw new Error(`未知参数:${current}`);
158
+ const nextValue = rawArgs[index + 1];
159
+ switch (current) {
160
+ case "--json":
161
+ options.json = true;
162
+ break;
163
+ case "--document":
164
+ this.assignDocumentGrant(options.documentGrantMap, this.requireOptionValue(current, nextValue));
165
+ index += 1;
166
+ break;
167
+ default: throw new Error(`未知参数:${current}`);
168
+ }
169
+ }
170
+ if (Object.keys(options.documentGrantMap).length === 0) throw new Error("grant 至少需要一个 --document scope=/path。");
171
+ return options;
172
+ };
173
+ readRevokeOptions = (rawArgs) => {
174
+ const options = {
175
+ json: false,
176
+ documentScopeIds: []
177
+ };
178
+ for (let index = 0; index < rawArgs.length; index += 1) {
179
+ const current = rawArgs[index];
180
+ if (!current?.startsWith("--")) throw new Error(`未知参数:${current}`);
181
+ const nextValue = rawArgs[index + 1];
182
+ switch (current) {
183
+ case "--json":
184
+ options.json = true;
185
+ break;
186
+ case "--document":
187
+ options.documentScopeIds.push(this.readDocumentScopeId(this.requireOptionValue(current, nextValue)));
188
+ index += 1;
189
+ break;
190
+ default: throw new Error(`未知参数:${current}`);
191
+ }
192
+ }
193
+ if (options.documentScopeIds.length === 0) throw new Error("revoke 至少需要一个 --document scope。");
194
+ return options;
195
+ };
196
+ readPublishOptions = (rawArgs) => {
197
+ const options = { json: false };
198
+ for (let index = 0; index < rawArgs.length; index += 1) {
199
+ const current = rawArgs[index];
200
+ if (!current?.startsWith("--")) throw new Error(`未知参数:${current}`);
201
+ const nextValue = rawArgs[index + 1];
202
+ switch (current) {
203
+ case "--json":
204
+ options.json = true;
205
+ break;
206
+ case "--meta":
207
+ options.metadataPath = this.requireOptionValue(current, nextValue);
208
+ index += 1;
209
+ break;
210
+ case "--api-base":
211
+ options.apiBaseUrl = this.requireOptionValue(current, nextValue);
212
+ index += 1;
213
+ break;
214
+ case "--token":
215
+ options.token = this.requireOptionValue(current, nextValue);
216
+ index += 1;
217
+ break;
218
+ default: throw new Error(`未知参数:${current}`);
219
+ }
220
+ }
221
+ return options;
222
+ };
223
+ assignDocumentGrant = (documentGrantMap, rawGrant) => {
224
+ const delimiterIndex = rawGrant.indexOf("=");
225
+ if (delimiterIndex < 1) throw new Error("--document 必须使用 scopeId=/absolute/or/relative/path 格式。");
226
+ const scopeId = rawGrant.slice(0, delimiterIndex).trim();
227
+ const directoryPath = rawGrant.slice(delimiterIndex + 1).trim();
228
+ if (!scopeId || !directoryPath) throw new Error("--document 缺少 scopeId 或 path。");
229
+ documentGrantMap[scopeId] = directoryPath;
230
+ };
231
+ readDocumentScopeId = (scopeId) => {
232
+ const normalized = scopeId.trim();
233
+ if (!normalized || normalized.includes("=")) throw new Error("--document 必须使用 scopeId 格式。");
234
+ return normalized;
235
+ };
236
+ requireOptionValue = (flag, nextValue) => {
237
+ if (!nextValue || nextValue.startsWith("--")) throw new Error(`${flag} 缺少值。`);
238
+ return nextValue;
239
+ };
240
+ };
241
+ //#endregion
242
+ export { AppRuntimeOptionsService };
@@ -0,0 +1,14 @@
1
+ import { AppScaffoldService } from "../scaffold/app-scaffold.service.js";
2
+
3
+ //#region src/commands/create.controller.d.ts
4
+ declare class CreateCommand {
5
+ private readonly scaffoldService;
6
+ constructor(scaffoldService?: AppScaffoldService);
7
+ run: (params: {
8
+ appDirectory: string;
9
+ json: boolean;
10
+ write: (text: string) => void;
11
+ }) => Promise<void>;
12
+ }
13
+ //#endregion
14
+ export { CreateCommand };
@@ -0,0 +1,16 @@
1
+ import { AppDocumentGrantMap } from "../permissions/app-permissions.types.js";
2
+ import { AppGrantService } from "../permissions/app-grant.service.js";
3
+
4
+ //#region src/commands/grant.controller.d.ts
5
+ declare class GrantCommand {
6
+ private readonly grantService;
7
+ constructor(grantService?: AppGrantService);
8
+ run: (params: {
9
+ appId: string;
10
+ documentGrantMap: AppDocumentGrantMap;
11
+ json: boolean;
12
+ write: (text: string) => void;
13
+ }) => Promise<void>;
14
+ }
15
+ //#endregion
16
+ export { GrantCommand };
@@ -0,0 +1,25 @@
1
+ import { AppGrantService } from "../permissions/app-grant.service.js";
2
+ //#region src/commands/grant.controller.ts
3
+ var GrantCommand = class {
4
+ constructor(grantService = new AppGrantService()) {
5
+ this.grantService = grantService;
6
+ }
7
+ run = async (params) => {
8
+ const { appId, documentGrantMap, json, write } = params;
9
+ const results = await Promise.all(Object.entries(documentGrantMap).map(([scopeId, directoryPath]) => this.grantService.grantDocumentScope({
10
+ appId,
11
+ scopeId,
12
+ directoryPath
13
+ })));
14
+ if (json) {
15
+ write(`${JSON.stringify({
16
+ ok: true,
17
+ grants: results
18
+ }, null, 2)}\n`);
19
+ return;
20
+ }
21
+ for (const result of results) write(`Granted ${result.scopeId} -> ${result.grantedPath}\n`);
22
+ };
23
+ };
24
+ //#endregion
25
+ export { GrantCommand };
@@ -0,0 +1,14 @@
1
+ import { AppInstallationService } from "../install/app-installation.service.js";
2
+
3
+ //#region src/commands/info.controller.d.ts
4
+ declare class InfoCommand {
5
+ private readonly installationService;
6
+ constructor(installationService?: AppInstallationService);
7
+ run: (params: {
8
+ appId: string;
9
+ json: boolean;
10
+ write: (text: string) => void;
11
+ }) => Promise<void>;
12
+ }
13
+ //#endregion
14
+ export { InfoCommand };
@@ -0,0 +1,27 @@
1
+ import { AppInstallationService } from "../install/app-installation.service.js";
2
+ //#region src/commands/info.controller.ts
3
+ var InfoCommand = class {
4
+ constructor(installationService = new AppInstallationService()) {
5
+ this.installationService = installationService;
6
+ }
7
+ run = async (params) => {
8
+ const { appId, json, write } = params;
9
+ const result = await this.installationService.info(appId);
10
+ if (json) {
11
+ write(`${JSON.stringify({
12
+ ok: true,
13
+ app: result
14
+ }, null, 2)}\n`);
15
+ return;
16
+ }
17
+ write(`App: ${result.name} (${result.appId})\n`);
18
+ write(`Active version: ${result.activeVersion}\n`);
19
+ write(`Data: ${result.dataDirectory}\n`);
20
+ write(`Installed versions: ${result.installedVersions.map((item) => item.version).join(", ")}\n`);
21
+ const activeVersion = result.installedVersions.find((item) => item.version === result.activeVersion);
22
+ if (activeVersion?.registryUrl) write(`Registry: ${activeVersion.registryUrl}\n`);
23
+ if (activeVersion?.publisher) write(`Publisher: ${activeVersion.publisher.name} (${activeVersion.publisher.id})\n`);
24
+ };
25
+ };
26
+ //#endregion
27
+ export { InfoCommand };
@@ -0,0 +1,15 @@
1
+ import { AppInstallationService } from "../install/app-installation.service.js";
2
+
3
+ //#region src/commands/install.controller.d.ts
4
+ declare class InstallCommand {
5
+ private readonly installationService;
6
+ constructor(installationService?: AppInstallationService);
7
+ run: (params: {
8
+ appSource: string;
9
+ registryUrl?: string;
10
+ json: boolean;
11
+ write: (text: string) => void;
12
+ }) => Promise<void>;
13
+ }
14
+ //#endregion
15
+ export { InstallCommand };
@@ -0,0 +1,24 @@
1
+ import { AppInstallationService } from "../install/app-installation.service.js";
2
+ //#region src/commands/install.controller.ts
3
+ var InstallCommand = class {
4
+ constructor(installationService = new AppInstallationService()) {
5
+ this.installationService = installationService;
6
+ }
7
+ run = async (params) => {
8
+ const { appSource, registryUrl, json, write } = params;
9
+ const result = await this.installationService.install(appSource, { registryUrl });
10
+ if (json) {
11
+ write(`${JSON.stringify({
12
+ ok: true,
13
+ installation: result
14
+ }, null, 2)}\n`);
15
+ return;
16
+ }
17
+ write(`Installed ${result.name} (${result.appId}) ${result.version}\n`);
18
+ write(`Code: ${result.installDirectory}\n`);
19
+ write(`Data: ${result.dataDirectory}\n`);
20
+ if (result.registryUrl) write(`Registry: ${result.registryUrl}\n`);
21
+ };
22
+ };
23
+ //#endregion
24
+ export { InstallCommand };
@@ -0,0 +1,13 @@
1
+ import { AppInstallationService } from "../install/app-installation.service.js";
2
+
3
+ //#region src/commands/list.controller.d.ts
4
+ declare class ListCommand {
5
+ private readonly installationService;
6
+ constructor(installationService?: AppInstallationService);
7
+ run: (params: {
8
+ json: boolean;
9
+ write: (text: string) => void;
10
+ }) => Promise<void>;
11
+ }
12
+ //#endregion
13
+ export { ListCommand };
@@ -0,0 +1,25 @@
1
+ import { AppInstallationService } from "../install/app-installation.service.js";
2
+ //#region src/commands/list.controller.ts
3
+ var ListCommand = class {
4
+ constructor(installationService = new AppInstallationService()) {
5
+ this.installationService = installationService;
6
+ }
7
+ run = async (params) => {
8
+ const { json, write } = params;
9
+ const result = await this.installationService.list();
10
+ if (json) {
11
+ write(`${JSON.stringify({
12
+ ok: true,
13
+ apps: result
14
+ }, null, 2)}\n`);
15
+ return;
16
+ }
17
+ if (result.length === 0) {
18
+ write("No installed apps.\n");
19
+ return;
20
+ }
21
+ for (const appItem of result) write(`${appItem.appId} ${appItem.activeVersion} ${appItem.sourceKind} ${appItem.name}\n`);
22
+ };
23
+ };
24
+ //#endregion
25
+ export { ListCommand };
@@ -0,0 +1,15 @@
1
+ import { AppBundleService } from "../bundle/app-bundle.service.js";
2
+
3
+ //#region src/commands/pack.controller.d.ts
4
+ declare class PackCommand {
5
+ private readonly bundleService;
6
+ constructor(bundleService?: AppBundleService);
7
+ run: (params: {
8
+ appDirectory: string;
9
+ outputPath?: string;
10
+ json: boolean;
11
+ write: (text: string) => void;
12
+ }) => Promise<void>;
13
+ }
14
+ //#endregion
15
+ export { PackCommand };
@@ -0,0 +1,25 @@
1
+ import { AppBundleService } from "../bundle/app-bundle.service.js";
2
+ //#region src/commands/pack.controller.ts
3
+ var PackCommand = class {
4
+ constructor(bundleService = new AppBundleService()) {
5
+ this.bundleService = bundleService;
6
+ }
7
+ run = async (params) => {
8
+ const { appDirectory, outputPath, json, write } = params;
9
+ const result = await this.bundleService.packAppDirectory({
10
+ appDirectory,
11
+ outputPath
12
+ });
13
+ if (json) {
14
+ write(`${JSON.stringify({
15
+ ok: true,
16
+ bundle: result
17
+ }, null, 2)}\n`);
18
+ return;
19
+ }
20
+ write(`Packed ${result.metadata.name} ${result.metadata.version}\n`);
21
+ write(`Bundle: ${result.bundlePath}\n`);
22
+ };
23
+ };
24
+ //#endregion
25
+ export { PackCommand };
@@ -0,0 +1,14 @@
1
+ import { AppGrantService } from "../permissions/app-grant.service.js";
2
+
3
+ //#region src/commands/permissions.controller.d.ts
4
+ declare class PermissionsCommand {
5
+ private readonly grantService;
6
+ constructor(grantService?: AppGrantService);
7
+ run: (params: {
8
+ appId: string;
9
+ json: boolean;
10
+ write: (text: string) => void;
11
+ }) => Promise<void>;
12
+ }
13
+ //#endregion
14
+ export { PermissionsCommand };
@@ -0,0 +1,26 @@
1
+ import { AppGrantService } from "../permissions/app-grant.service.js";
2
+ //#region src/commands/permissions.controller.ts
3
+ var PermissionsCommand = class {
4
+ constructor(grantService = new AppGrantService()) {
5
+ this.grantService = grantService;
6
+ }
7
+ run = async (params) => {
8
+ const { appId, json, write } = params;
9
+ const result = await this.grantService.summarize(appId);
10
+ if (json) {
11
+ write(`${JSON.stringify({
12
+ ok: true,
13
+ permissions: result
14
+ }, null, 2)}\n`);
15
+ return;
16
+ }
17
+ write(`Permissions: ${result.name} (${result.appId}) ${result.activeVersion}\n`);
18
+ if (result.documentAccess.length === 0) write("Document access: none\n");
19
+ else for (const scope of result.documentAccess) write(`Document ${scope.id} ${scope.mode} ${scope.granted ? scope.grantedPath : "[missing]"}\n`);
20
+ write(`Allowed domains: ${result.allowedDomains.length > 0 ? result.allowedDomains.join(", ") : "none"}\n`);
21
+ write(`Storage: ${result.storage.enabled ? result.storage.namespace ?? "enabled" : "disabled"}\n`);
22
+ write(`Host bridge: ${result.capabilities.hostBridge ? "enabled" : "disabled"}\n`);
23
+ };
24
+ };
25
+ //#endregion
26
+ export { PermissionsCommand };
@@ -0,0 +1,17 @@
1
+ import { AppPublishService } from "../publish/app-publish.service.js";
2
+
3
+ //#region src/commands/publish.controller.d.ts
4
+ declare class PublishCommand {
5
+ private readonly publishService;
6
+ constructor(publishService?: AppPublishService);
7
+ run: (params: {
8
+ appDirectory: string;
9
+ metadataPath?: string;
10
+ apiBaseUrl?: string;
11
+ token?: string;
12
+ json: boolean;
13
+ write: (text: string) => void;
14
+ }) => Promise<void>;
15
+ }
16
+ //#endregion
17
+ export { PublishCommand };
@@ -0,0 +1,29 @@
1
+ import { AppPublishService } from "../publish/app-publish.service.js";
2
+ //#region src/commands/publish.controller.ts
3
+ var PublishCommand = class {
4
+ constructor(publishService = new AppPublishService()) {
5
+ this.publishService = publishService;
6
+ }
7
+ run = async (params) => {
8
+ const { appDirectory, metadataPath, apiBaseUrl, token, json, write } = params;
9
+ const result = await this.publishService.publish({
10
+ appDirectory,
11
+ metadataPath,
12
+ apiBaseUrl,
13
+ token
14
+ });
15
+ if (json) {
16
+ write(`${JSON.stringify({
17
+ ok: true,
18
+ publish: result
19
+ }, null, 2)}\n`);
20
+ return;
21
+ }
22
+ write(`${result.created ? "Published" : "Updated"} ${result.item.name} (${result.item.appId}) ${result.item.latestVersion}\n`);
23
+ write(`Bundle: ${result.bundle.path}\n`);
24
+ if (result.item.webUrl) write(`Details: ${result.item.webUrl}\n`);
25
+ write(`Install: ${result.item.install.command}\n`);
26
+ };
27
+ };
28
+ //#endregion
29
+ export { PublishCommand };
@@ -0,0 +1,16 @@
1
+ import { AppRegistryConfigService } from "../registry/app-registry-config.service.js";
2
+
3
+ //#region src/commands/registry.controller.d.ts
4
+ declare class RegistryCommand {
5
+ private readonly configService;
6
+ constructor(configService?: AppRegistryConfigService);
7
+ run: (params: {
8
+ action: "get" | "set" | "reset";
9
+ registryUrl?: string;
10
+ json: boolean;
11
+ write: (text: string) => void;
12
+ }) => Promise<void>;
13
+ private requireRegistryUrl;
14
+ }
15
+ //#endregion
16
+ export { RegistryCommand };
@@ -0,0 +1,27 @@
1
+ import { AppRegistryConfigService } from "../registry/app-registry-config.service.js";
2
+ //#region src/commands/registry.controller.ts
3
+ var RegistryCommand = class {
4
+ constructor(configService = new AppRegistryConfigService()) {
5
+ this.configService = configService;
6
+ }
7
+ run = async (params) => {
8
+ const { action, registryUrl, json, write } = params;
9
+ const snapshot = action === "set" ? await this.configService.setRegistryUrl(this.requireRegistryUrl(registryUrl)) : action === "reset" ? await this.configService.resetRegistryUrl() : await this.configService.getSnapshot();
10
+ if (json) {
11
+ write(`${JSON.stringify({
12
+ ok: true,
13
+ registry: snapshot
14
+ }, null, 2)}\n`);
15
+ return;
16
+ }
17
+ write(`Registry: ${snapshot.currentUrl}\n`);
18
+ write(`Source: ${snapshot.source}\n`);
19
+ write(`Default: ${snapshot.defaultUrl}\n`);
20
+ };
21
+ requireRegistryUrl = (registryUrl) => {
22
+ if (!registryUrl) throw new Error("registry set 缺少 URL。");
23
+ return registryUrl;
24
+ };
25
+ };
26
+ //#endregion
27
+ export { RegistryCommand };