Agent 1.5.0 + contracts 1.16.0: uninstall, export and purge one product of a church
crosscode uninstall/export/purge <church> [product ...]: with products named only those go and the church keeps the others; naming every product it still has removes the church (folder and app user), so the last product to go takes the church with it. The report gives products and remaining. Uninstalling cross-events-demo's Events removed its Accounts too, which the Hub still showed as live. Contracts 1.16.0: optional products on export/uninstall/purge, PRODUCT_UNINSTALL_MIN_AGENT. Agent 1.5.0 passes them to crosscode. The Website plan moves to contracts 1.17.0 / Hub 2.13.0. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@crosscode/contracts",
|
||||
"version": "1.15.0",
|
||||
"version": "1.16.0",
|
||||
"description": "The shared JSON formats used by every Cross Code product: zod schemas, JSON Schema, TypeScript types and sample payloads",
|
||||
"license": "UNLICENSED",
|
||||
"type": "commonjs",
|
||||
|
||||
@@ -1177,6 +1177,20 @@
|
||||
"exportId": {
|
||||
"type": "string",
|
||||
"pattern": "^exp_[A-Za-z0-9_-]{8,64}$"
|
||||
},
|
||||
"products": {
|
||||
"minItems": 1,
|
||||
"maxItems": 4,
|
||||
"type": "array",
|
||||
"items": {
|
||||
"type": "string",
|
||||
"enum": [
|
||||
"events",
|
||||
"website",
|
||||
"app",
|
||||
"accounts"
|
||||
]
|
||||
}
|
||||
}
|
||||
},
|
||||
"required": [
|
||||
@@ -1273,6 +1287,20 @@
|
||||
"church": {
|
||||
"type": "string",
|
||||
"pattern": "^[a-z][a-z0-9-]{1,30}$"
|
||||
},
|
||||
"products": {
|
||||
"minItems": 1,
|
||||
"maxItems": 4,
|
||||
"type": "array",
|
||||
"items": {
|
||||
"type": "string",
|
||||
"enum": [
|
||||
"events",
|
||||
"website",
|
||||
"app",
|
||||
"accounts"
|
||||
]
|
||||
}
|
||||
}
|
||||
},
|
||||
"required": [
|
||||
@@ -1368,6 +1396,20 @@
|
||||
"church": {
|
||||
"type": "string",
|
||||
"pattern": "^[a-z][a-z0-9-]{1,30}$"
|
||||
},
|
||||
"products": {
|
||||
"minItems": 1,
|
||||
"maxItems": 4,
|
||||
"type": "array",
|
||||
"items": {
|
||||
"type": "string",
|
||||
"enum": [
|
||||
"events",
|
||||
"website",
|
||||
"app",
|
||||
"accounts"
|
||||
]
|
||||
}
|
||||
}
|
||||
},
|
||||
"required": [
|
||||
|
||||
@@ -84,6 +84,13 @@ export const ENV_SET_MAX = 50;
|
||||
/** The first agent that runs `frp-read`, `frp-write` and `probe-ports` jobs (an older one refuses the unknown types). */
|
||||
export const FRP_JOBS_MIN_AGENT = "1.4.0";
|
||||
|
||||
/**
|
||||
* The first agent that takes `products` on `export`, `uninstall` and `purge` (only those products
|
||||
* go; the church keeps its others). An older one refuses the key, and uninstalls the whole church
|
||||
* without it.
|
||||
*/
|
||||
export const PRODUCT_UNINSTALL_MIN_AGENT = "1.5.0";
|
||||
|
||||
/**
|
||||
* Where frps (central server) or frpc (church server) keeps its config: an absolute path to a file
|
||||
* whose name starts with `frp` and ends in `.ini` or `.toml` (`/etc/frp/frps.toml`).
|
||||
@@ -162,12 +169,16 @@ export const jobArgsSchemas = {
|
||||
if (secret) issue(`${secret} is a secret: it can't be changed from the Hub`);
|
||||
if (a.unset.some((n) => Object.prototype.hasOwnProperty.call(a.set, n))) issue("A name can't be both set and removed");
|
||||
}),
|
||||
/** `crosscode export <church> --out <zip> --json`; the agent encrypts the ZIP and uploads it under `exportId`. */
|
||||
export: z.strictObject({ church: shortNameSchema, exportId: z.string().regex(/^exp_[A-Za-z0-9_-]{8,64}$/) }),
|
||||
/** `crosscode uninstall <church> --json` */
|
||||
uninstall: z.strictObject({ church: shortNameSchema }),
|
||||
/** `crosscode purge <church> --json` (deletes what uninstall kept for 30 days) */
|
||||
purge: z.strictObject({ church: shortNameSchema }),
|
||||
/** `crosscode export <church> [products] --out <zip> --json`; the agent encrypts the ZIP and uploads it under `exportId`. */
|
||||
export: z.strictObject({ church: shortNameSchema, exportId: z.string().regex(/^exp_[A-Za-z0-9_-]{8,64}$/), products: z.array(productSchema).min(1).max(4).optional() }),
|
||||
/**
|
||||
* `crosscode uninstall <church> [products] --json`. With `products` (agent 1.5.0, {@link
|
||||
* PRODUCT_UNINSTALL_MIN_AGENT}) only those go and the church keeps its others; without it, or
|
||||
* naming every product, the whole church goes.
|
||||
*/
|
||||
uninstall: z.strictObject({ church: shortNameSchema, products: z.array(productSchema).min(1).max(4).optional() }),
|
||||
/** `crosscode purge <church> [products] --json` (deletes what uninstall kept for 30 days: with `products`, only what was kept of those) */
|
||||
purge: z.strictObject({ church: shortNameSchema, products: z.array(productSchema).min(1).max(4).optional() }),
|
||||
/** The agent updates itself to that tag. */
|
||||
"update-agent": z.strictObject({ version: agentTagSchema }),
|
||||
/**
|
||||
|
||||
@@ -275,3 +275,17 @@ describe("frp config and free ports (1.15.0)", () => {
|
||||
expect(agent.probePortsResultSchema.safeParse({ ports: [{ port: 20000, free: false, reason: "in use" }], configPath: null }).success).toBe(true);
|
||||
});
|
||||
});
|
||||
|
||||
describe("uninstalling one product (contracts 1.16.0)", () => {
|
||||
const ok = (type: "export" | "uninstall" | "purge", args: unknown) => agent.jobArgsSchemas[type].safeParse(args).success;
|
||||
it("export, uninstall and purge take the products, or none (the whole church)", () => {
|
||||
for (const type of ["uninstall", "purge"] as const) {
|
||||
expect(ok(type, { church: "hope" })).toBe(true);
|
||||
expect(ok(type, { church: "hope", products: ["events"] })).toBe(true);
|
||||
expect(ok(type, { church: "hope", products: [] })).toBe(false);
|
||||
expect(ok(type, { church: "hope", products: ["everything"] })).toBe(false);
|
||||
}
|
||||
expect(ok("export", { church: "hope", exportId: "exp_abcdefgh", products: ["accounts"] })).toBe(true);
|
||||
expect(agent.PRODUCT_UNINSTALL_MIN_AGENT).toBe("1.5.0");
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user