contracts 1.18.0 + website: Get more storage
contracts: hub.storageRequestSchema and its reply, a sample and JSON Schemas. Website: an Owner or Admin asks for more 5 GB steps under Media library (signed to the Hub); the heartbeat reports the licence's storage limit, so the Hub emails the church at 80% and when full. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@crosscode/contracts",
|
||||
"version": "1.17.0",
|
||||
"version": "1.18.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",
|
||||
|
||||
@@ -0,0 +1,7 @@
|
||||
{
|
||||
"protocolVersion": 2,
|
||||
"steps": 1,
|
||||
"usedBytes": 5100000000,
|
||||
"limitBytes": 5368709120,
|
||||
"requestedBy": "Pastor Sam"
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
{
|
||||
"$id": "https://c-git.crosscode.co.za/joshua/crosscode-platform/raw/branch/main/packages/contracts/schemas/hub-storage-request-response.json",
|
||||
"$schema": "https://json-schema.org/draft/2020-12/schema",
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"requestedAt": {
|
||||
"type": "string",
|
||||
"format": "date-time",
|
||||
"pattern": "^(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))T(?:(?:[01]\\d|2[0-3]):[0-5]\\d:[0-5]\\d(?:\\.\\d+)?(?:Z))$"
|
||||
},
|
||||
"steps": {
|
||||
"type": "integer",
|
||||
"minimum": 1,
|
||||
"maximum": 10
|
||||
},
|
||||
"alreadyRequested": {
|
||||
"type": "boolean"
|
||||
}
|
||||
},
|
||||
"required": [
|
||||
"requestedAt",
|
||||
"steps",
|
||||
"alreadyRequested"
|
||||
]
|
||||
}
|
||||
@@ -0,0 +1,44 @@
|
||||
{
|
||||
"$id": "https://c-git.crosscode.co.za/joshua/crosscode-platform/raw/branch/main/packages/contracts/schemas/hub-storage-request.json",
|
||||
"$schema": "https://json-schema.org/draft/2020-12/schema",
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"protocolVersion": {
|
||||
"type": "number",
|
||||
"const": 2
|
||||
},
|
||||
"steps": {
|
||||
"type": "integer",
|
||||
"minimum": 1,
|
||||
"maximum": 10
|
||||
},
|
||||
"usedBytes": {
|
||||
"type": "integer",
|
||||
"minimum": 0,
|
||||
"maximum": 9007199254740991
|
||||
},
|
||||
"limitBytes": {
|
||||
"type": "integer",
|
||||
"minimum": 0,
|
||||
"maximum": 9007199254740991
|
||||
},
|
||||
"requestedBy": {
|
||||
"anyOf": [
|
||||
{
|
||||
"type": "string",
|
||||
"maxLength": 200
|
||||
},
|
||||
{
|
||||
"type": "null"
|
||||
}
|
||||
]
|
||||
}
|
||||
},
|
||||
"required": [
|
||||
"protocolVersion",
|
||||
"steps",
|
||||
"usedBytes",
|
||||
"limitBytes",
|
||||
"requestedBy"
|
||||
]
|
||||
}
|
||||
@@ -35,6 +35,8 @@ function contracts(c) {
|
||||
"hub-update-request-response": c.hub.updateRequestResponseSchema,
|
||||
"hub-update-request-cancel": c.hub.updateRequestCancelSchema,
|
||||
"hub-update-request-cancel-response": c.hub.updateRequestCancelResponseSchema,
|
||||
"hub-storage-request": c.hub.storageRequestSchema,
|
||||
"hub-storage-request-response": c.hub.storageRequestResponseSchema,
|
||||
"hub-ai-status-request": c.hub.aiStatusRequestSchema,
|
||||
"hub-ai-status": c.hub.aiStatusSchema,
|
||||
"hub-ai-complete-request": c.hub.aiCompleteRequestSchema,
|
||||
|
||||
@@ -294,6 +294,36 @@ export const updateRequestResponseSchema = z.object({
|
||||
export const updateRequestCancelSchema = z.object({ protocolVersion });
|
||||
export const updateRequestCancelResponseSchema = z.object({ cancelled: z.boolean() });
|
||||
|
||||
// ---------------------------------------------------------------------------------------------
|
||||
// More storage (contracts 1.18.0, WEBSITE-1.0-PLAN §10, decision 12): a Website's admin presses
|
||||
// "Get more storage". `POST /api/installs/storage-request`, signed as the heartbeat. The Hub records
|
||||
// it and emails Joshua; he adds the steps to the licence, and the new limit reaches the site with
|
||||
// the next heartbeat answer (`limits.storageBytes`). Asking again while a request is open changes
|
||||
// its number of steps; nobody is emailed twice for the same request.
|
||||
// ---------------------------------------------------------------------------------------------
|
||||
|
||||
/** One step is 5 GB (ROADMAP-v3 §10: R20 a month each). */
|
||||
export const STORAGE_STEP_BYTES = 5 * 1024 ** 3;
|
||||
|
||||
export const storageRequestSchema = z.object({
|
||||
protocolVersion,
|
||||
/** How many 5 GB steps to add. */
|
||||
steps: z.int().min(1).max(10),
|
||||
/** What the site uses and may use now, for the email. */
|
||||
usedBytes: z.int().nonnegative(),
|
||||
limitBytes: z.int().nonnegative(),
|
||||
/** Who asked (their name in the Website's admin), for the email. */
|
||||
requestedBy: z.string().trim().max(200).nullable(),
|
||||
});
|
||||
export type StorageRequest = z.infer<typeof storageRequestSchema>;
|
||||
|
||||
export const storageRequestResponseSchema = z.object({
|
||||
requestedAt: dateTimeSchema,
|
||||
steps: z.int().min(1).max(10),
|
||||
alreadyRequested: z.boolean(),
|
||||
});
|
||||
export type StorageRequestResponse = z.infer<typeof storageRequestResponseSchema>;
|
||||
|
||||
// ---------------------------------------------------------------------------------------------
|
||||
// AI (as v1; usage is recorded per product on the Hub, the cap stays per customer)
|
||||
// ---------------------------------------------------------------------------------------------
|
||||
|
||||
@@ -34,6 +34,7 @@ const SAMPLE_SCHEMA: Record<string, string> = {
|
||||
"hub-heartbeat-app.json": "hub-heartbeat-request",
|
||||
"hub-heartbeat-accounts.json": "hub-heartbeat-request",
|
||||
"hub-heartbeat-response.json": "hub-heartbeat-response",
|
||||
"hub-storage-request.json": "hub-storage-request",
|
||||
"hub-licence-payload.json": "hub-licence-payload",
|
||||
"hub-licence-payload-website.json": "hub-licence-payload",
|
||||
"church-export.json": "church-export",
|
||||
|
||||
@@ -40,6 +40,7 @@ const SCHEMAS: Record<string, z.ZodType> = {
|
||||
"hub-register-response.json": hub.registerResponseSchema,
|
||||
"hub-heartbeat-events.json": hub.heartbeatRequestSchema,
|
||||
"hub-heartbeat-website.json": hub.heartbeatRequestSchema,
|
||||
"hub-storage-request.json": hub.storageRequestSchema,
|
||||
"hub-heartbeat-app.json": hub.heartbeatRequestSchema,
|
||||
"hub-heartbeat-accounts.json": hub.heartbeatRequestSchema,
|
||||
"hub-heartbeat-response.json": hub.heartbeatResponseSchema,
|
||||
|
||||
Reference in New Issue
Block a user