@tokenbuddy/tb-admin 1.0.12 → 1.0.14

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.
@@ -1,5 +1,6 @@
1
1
  import { ConfigManager } from "../src/config.js";
2
2
  import { buildAdminCli } from "../src/cli.js";
3
+ import { FlyProvider, parseFlyMachineIds } from "../src/server-cmd.js";
3
4
  import {
4
5
  validateRegistryDocument
5
6
  } from "../src/bootstrap-registry.js";
@@ -66,6 +67,7 @@ describe("Admin CLI Config Profile Management Tests", () => {
66
67
  const sellerConfig = program.commands.find((command) => command.name() === "seller-config");
67
68
  const payments = program.commands.find((command) => command.name() === "payments");
68
69
  const upstreams = program.commands.find((command) => command.name() === "upstreams");
70
+ const models = program.commands.find((command) => command.name() === "models");
69
71
 
70
72
  expect(bootstrap).toBeDefined();
71
73
  expect(sellers).toBeDefined();
@@ -77,6 +79,8 @@ describe("Admin CLI Config Profile Management Tests", () => {
77
79
  expect(sellerConfig?.commands.find((command) => command.name() === "put")?.options.some((option) => option.long === "--file")).toBe(true);
78
80
  expect(sellerConfig?.commands.find((command) => command.name() === "validate")?.options.some((option) => option.long === "--file")).toBe(true);
79
81
  expect(upstreams).toBeDefined();
82
+ expect(models).toBeDefined();
83
+ expect(models?.options.some((option) => option.long === "--json")).toBe(true);
80
84
  expect(upstreams?.commands.map((command) => command.name()).sort()).toEqual(["get", "refresh", "update"]);
81
85
  expect(upstreams?.commands.find((command) => command.name() === "update")?.options.some((option) => option.long === "--upstream-url")).toBe(true);
82
86
  expect(upstreams?.commands.find((command) => command.name() === "refresh")?.options.some((option) => option.long === "--auto-models")).toBe(true);
@@ -89,8 +93,56 @@ describe("Admin CLI Config Profile Management Tests", () => {
89
93
  ]);
90
94
  });
91
95
 
96
+ test("seller Fly commands separate create config from deploy image updates", () => {
97
+ const program = buildAdminCli(new ConfigManager(TEMP_CONF_PATH));
98
+ const seller = program.commands.find((command) => command.name() === "seller");
99
+ const create = seller?.commands.find((command) => command.name() === "create");
100
+ const deploy = seller?.commands.find((command) => command.name() === "deploy");
101
+
102
+ expect(create).toBeDefined();
103
+ expect(deploy).toBeDefined();
104
+ expect(create?.options.some((option) => option.long === "--fly-config" && option.required)).toBe(true);
105
+ expect(create?.options.some((option) => option.long === "--image" && option.required)).toBe(true);
106
+ expect(create?.options.some((option) => option.long === "--config")).toBe(false);
107
+ expect(deploy?.options.some((option) => option.long === "--fly-config")).toBe(false);
108
+ expect(deploy?.options.some((option) => option.long === "--image" && option.required)).toBe(true);
109
+ expect(deploy?.options.some((option) => option.long === "--config")).toBe(false);
110
+
111
+ const provider = new FlyProvider({
112
+ default_image: "registry.fly.io/tb-seller:latest",
113
+ default_config: "fly.toml"
114
+ });
115
+ expect(() => provider.createSeller({
116
+ name: "test",
117
+ operatorSecret: "secret",
118
+ dryRun: true
119
+ })).toThrow("seller create requires --image");
120
+ expect(() => provider.deploySeller({
121
+ app: "tbs-test",
122
+ dryRun: true
123
+ })).toThrow("seller deploy requires --image");
124
+
125
+ expect(provider.deploySeller({
126
+ app: "tbs-test",
127
+ image: "registry.fly.io/tb-seller:1.0.13",
128
+ dryRun: true
129
+ })).toContain("Volumes: unchanged");
130
+ });
131
+
132
+ test("parseFlyMachineIds reads machine ids and rejects unusable machine lists", () => {
133
+ expect(parseFlyMachineIds(JSON.stringify([
134
+ { id: "machine-1" },
135
+ { id: "machine-2" }
136
+ ]), "tbs-test")).toEqual(["machine-1", "machine-2"]);
137
+
138
+ expect(() => parseFlyMachineIds("{", "tbs-test")).toThrow("invalid JSON");
139
+ expect(() => parseFlyMachineIds("[]", "tbs-test")).toThrow("has no machines");
140
+ });
141
+
92
142
  test("bootstrap registry validation accepts demo config and rejects unsafe variants", () => {
93
- const document = JSON.parse(fs.readFileSync(path.resolve(__dirname, "../../../config/demo-sellers.json"), "utf8"));
143
+ const document = JSON.parse(
144
+ fs.readFileSync(path.resolve(__dirname, "../../wallet-bootstrap/seed/demo-sellers.json"), "utf8")
145
+ );
94
146
 
95
147
  expect(() => validateRegistryDocument(document)).not.toThrow();
96
148