esim-cli 2026.1201.186 → 2026.1201.188
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/dist/esim.js +252 -74
- package/dist/index.js +253 -75
- package/package.json +1 -1
package/dist/esim.js
CHANGED
|
@@ -14368,9 +14368,10 @@ var catalog = [
|
|
|
14368
14368
|
{ operationId: "SetDuelEnrollment", name: "set-duel-enrollment", method: "PUT", path: "/api/me/duel-tournaments/{id}/enrollment", spec: "duel.yaml", write: true, retry: "natural", description: "Sets the signed-in citizen's state. The request must be same-origin.", parameters: [{ name: "id", in: "path", required: true, schema: { type: "integer", format: "int64", minimum: 1 } }], body: { required: true, schema: { type: "object", additionalProperties: false, required: ["enrolled"], properties: { enrolled: { type: "boolean" } } } }, requiresCredentials: true, responses: { "200": { kind: "json", schema: { type: "object", required: ["enrolled", "hasUpcomingRound"], properties: { enrolled: { type: "boolean" }, hasUpcomingRound: { type: "boolean" } } } } }, responseFields: ["enrolled", "hasUpcomingRound"] },
|
|
14369
14369
|
{ operationId: "SetDuelRoundSelection", name: "set-duel-round-selection", method: "PUT", path: "/api/me/duel-tournaments/{id}/rounds/{number}/selection", spec: "duel.yaml", write: true, retry: "natural", description: "Sets the signed-in citizen's state. The request must be same-origin.", parameters: [{ name: "id", in: "path", required: true, schema: { type: "integer", format: "int64", minimum: 1 } }, { name: "number", in: "path", required: true, schema: { type: "integer", format: "int64", minimum: 1 } }], body: { required: true, schema: { type: "object", additionalProperties: false, required: ["selected"], properties: { selected: { type: "boolean" } } } }, requiresCredentials: true, responses: { "200": { kind: "json", schema: { type: "object", required: ["number", "startsAt", "endsAt", "status", "participants", "selected"], properties: { roster: { description: "Public names and countries of entrants once this round starts.", type: "array", items: { type: "object", required: ["citizenId", "name", "nationId"], properties: { citizenId: { type: "string", pattern: "^[1-9][0-9]*$", description: "Decimal encoding of the citizen ID." }, name: { type: "string" }, nationId: { type: "integer", minimum: 0 } } } }, number: { type: "integer", format: "int64", minimum: 1 }, startsAt: { type: "string", format: "date-time" }, endsAt: { type: "string", format: "date-time" }, status: { type: "string", enum: ["upcoming", "active", "closed"], "x-enum-varnames": ["DuelRoundStatusUpcoming", "DuelRoundStatusActive", "DuelRoundStatusClosed"] }, participants: { type: "integer", format: "int64", minimum: 0 }, selected: { type: "boolean" } } } } }, responseFields: ["roster", "number", "startsAt", "endsAt", "status", "participants", "selected"] },
|
|
14370
14370
|
{ operationId: "ListMarketSummary", name: "list-market-summary", method: "GET", path: "/api/market/summary", spec: "economy.yaml", write: false, retry: "unsafe", description: "Public. List active product and quality groups in a country, ordered by product code and quality. The summary updates asynchronously.", parameters: [{ name: "country", in: "query", required: true, schema: { type: "integer", minimum: 0 } }, { name: "product", in: "query", description: "Filter by product, using the same selectors as the market orders endpoint.", schema: { type: "string", enum: ["jinxed", "finesse", "bloody_mess", "lucky", "GRAIN", "IRON", "OIL", "WOOD", "STONE", "MINERALS", "SMALL_DRINK", "LARGE_DRINK", "SNACK", "MEAL", "PISTOL", "RIFLE", "TICKET_ECONOMY", "TICKET_BUSINESS", "KNIFE", "HOUSE", "MANSION", "BOAT", "YACHT", "DEFENSE_SYSTEM", "HOSPITAL"] } }], requiresCredentials: false, responses: { "200": { kind: "json", schema: { type: "array", items: { type: "object", additionalProperties: false, required: ["product", "quality", "lowestPrice", "qty", "orderCount"], properties: { product: { type: "string", enum: ["jinxed", "finesse", "bloody_mess", "lucky", "GRAIN", "IRON", "OIL", "WOOD", "STONE", "MINERALS", "SMALL_DRINK", "LARGE_DRINK", "SNACK", "MEAL", "PISTOL", "RIFLE", "TICKET_ECONOMY", "TICKET_BUSINESS", "KNIFE", "HOUSE", "MANSION", "BOAT", "YACHT", "DEFENSE_SYSTEM", "HOSPITAL"] }, quality: { type: "integer", format: "int64", minimum: 0, maximum: 6, description: "Current products use quality 0 and potions use qualities 1–6." }, lowestPrice: { allOf: [{ type: "integer", format: "int64", minimum: 1, maximum: 1000000000000, description: "Unit price in hundredths of the listing country currency." }, { description: "Lowest listed unit price in the country's currency, before taxes." }] }, qty: { description: "Total remaining units.", type: "integer", format: "int64", minimum: 1 }, orderCount: { type: "integer", format: "int64", minimum: 1 } } } } } }, responseFields: [] },
|
|
14371
|
-
{ operationId: "
|
|
14372
|
-
{ operationId: "
|
|
14373
|
-
{ operationId: "
|
|
14371
|
+
{ operationId: "ListMarketProducts", name: "list-market-products", method: "GET", path: "/api/market/products", spec: "economy.yaml", write: false, retry: "unsafe", description: "Public. List current product and quality groups across every market country or one selected country.", parameters: [{ name: "cursor", in: "query", description: "Opaque cursor from the previous page. Reuse the same filters.", schema: { type: "string" } }, { name: "limit", in: "query", description: "Maximum number of results.", schema: { type: "integer", minimum: 1, maximum: 100, default: 20 } }, { name: "country", in: "query", description: "Filter by listing country, whose currency is used for settlement.", schema: { type: "integer", minimum: 0 } }, { name: "minQty", in: "query", description: "Minimum remaining units in each counted offer.", schema: { type: "integer", format: "int64", minimum: 1 } }, { name: "sort", in: "query", schema: { type: "string", enum: ["offers", "countries", "quantity", "gold", "product"] } }, { name: "order", in: "query", schema: { type: "string", enum: ["asc", "desc"] } }], requiresCredentials: false, responses: { "200": { kind: "json", schema: { type: "object", additionalProperties: false, required: ["items", "total", "nextCursor"], properties: { items: { type: "array", items: { type: "object", additionalProperties: false, required: ["product", "quality", "countries", "offers", "quantity", "minGold", "price", "country"], properties: { product: { type: "string", enum: ["jinxed", "finesse", "bloody_mess", "lucky", "GRAIN", "IRON", "OIL", "WOOD", "STONE", "MINERALS", "SMALL_DRINK", "LARGE_DRINK", "SNACK", "MEAL", "PISTOL", "RIFLE", "TICKET_ECONOMY", "TICKET_BUSINESS", "KNIFE", "HOUSE", "MANSION", "BOAT", "YACHT", "DEFENSE_SYSTEM", "HOSPITAL"] }, quality: { type: "integer", format: "int64", minimum: 0, maximum: 6, description: "Current products use quality 0 and potions use qualities 1–6." }, countries: { type: "integer", format: "int64", minimum: 1 }, offers: { type: "integer", format: "int64", minimum: 1 }, quantity: { type: "integer", format: "int64", minimum: 1 }, minGold: { description: "Gold-equivalent unit price as an exact decimal in Gold.", type: "string", pattern: "^[0-9]+[.][0-9]{6}$" }, price: { type: "integer", format: "int64", minimum: 1, maximum: 1000000000000, description: "Unit price in hundredths of the listing country currency." }, country: { type: "integer", minimum: 0 } } } }, total: { type: "integer", minimum: 0 }, nextCursor: { type: ["string", "null"] } } } } }, responseFields: ["items", "total", "nextCursor"] },
|
|
14372
|
+
{ operationId: "ListMarketOrders", name: "market-orders", method: "GET", path: "/api/market/orders", spec: "economy.yaml", write: false, retry: "unsafe", description: "Public. List current offers. By default results sort by Gold-equivalent price (unit price times the cheapest current rate selling that currency for Gold, or the 0.1 Gold reference rate) and then order ID, across every market country.", parameters: [{ name: "cursor", in: "query", description: "Opaque cursor from the previous page. Reuse the same filters.", schema: { type: "string" } }, { name: "page", in: "query", description: "Numbered page of `limit` offers in the same order, as on Primera's product market. Use instead of `cursor`; `nextCursor` is then null.", schema: { type: "integer", minimum: 1, maximum: 1e5 } }, { name: "limit", in: "query", description: "Maximum number of results.", schema: { type: "integer", minimum: 1, maximum: 100, default: 20 } }, { name: "book", in: "query", description: "Basic selects standard food and weapons. Industry selects crafted goods and field buildings. Raw selects ungraded raw materials. Omit to include every item.", schema: { type: "string", enum: ["basic", "industry", "raw"] } }, { name: "item", in: "query", description: "Filter by item.", schema: { type: "string", enum: ["jinxed", "finesse", "bloody_mess", "lucky", "GRAIN", "IRON", "OIL", "WOOD", "STONE", "MINERALS", "SMALL_DRINK", "LARGE_DRINK", "SNACK", "MEAL", "PISTOL", "RIFLE", "TICKET_ECONOMY", "TICKET_BUSINESS", "KNIFE", "HOUSE", "MANSION", "BOAT", "YACHT", "DEFENSE_SYSTEM", "HOSPITAL"] } }, { name: "quality", in: "query", description: "Filter by quality. Zero selects basic goods and raw materials.", schema: { type: "integer", format: "int64", minimum: 0, maximum: 6, description: "Current products use quality 0 and potions use qualities 1–6." } }, { name: "country", in: "query", description: "Filter by listing country, whose currency is used for settlement.", schema: { type: "integer", minimum: 0 } }, { name: "seller", in: "query", description: "Filter by the public seller ID.", schema: { type: "string", pattern: "^[1-9][0-9]*$", description: "Decimal encoding of the citizen ID." } }, { name: "stockCompanyId", in: "query", schema: { type: "integer", format: "int64", minimum: 1 } }, { name: "minQty", in: "query", description: "Minimum remaining number of units.", schema: { type: "integer", format: "int64", minimum: 1 } }, { name: "sort", in: "query", description: "`gold` (default) compares every country by Gold-equivalent price; `price` compares local prices and needs `country`; `qty` puts the largest stock first; `created` orders by time, `country` by market country ID and `seller` by seller ID.", schema: { type: "string", enum: ["gold", "price", "qty", "created", "country", "seller"] } }, { name: "order", in: "query", description: "Sorting direction. Ties use the listing ID in the same direction. Use cursors with the same filters and sort.", schema: { type: "string", enum: ["asc", "desc"] } }], requiresCredentials: false, responses: { "200": { kind: "json", schema: { type: "object", additionalProperties: false, required: ["items", "nextCursor", "total"], properties: { total: { type: "integer", minimum: 0 }, items: { type: "array", items: { type: "object", additionalProperties: false, required: ["id", "seller", "sellerName", "sellerNation", "item", "quality", "qty", "price", "createdAt", "country", "priceAsset", "vatPercent", "importTaxPercent"], properties: { stockCompanyId: { type: "integer", format: "int64", minimum: 1 }, id: { type: "integer", format: "int64", minimum: 1 }, seller: { type: "string", pattern: "^[1-9][0-9]*$", description: "Decimal encoding of the citizen ID." }, sellerName: { type: "string" }, sellerAvatarVersion: { description: "Public avatar version, omitted when the seller has no custom avatar.", type: "string" }, sellerLevel: { description: "Public citizen level.", type: "integer" }, sellerNation: { type: "integer", minimum: 0 }, item: { type: "string", enum: ["jinxed", "finesse", "bloody_mess", "lucky", "GRAIN", "IRON", "OIL", "WOOD", "STONE", "MINERALS", "SMALL_DRINK", "LARGE_DRINK", "SNACK", "MEAL", "PISTOL", "RIFLE", "TICKET_ECONOMY", "TICKET_BUSINESS", "KNIFE", "HOUSE", "MANSION", "BOAT", "YACHT", "DEFENSE_SYSTEM", "HOSPITAL"] }, quality: { type: "integer", format: "int64", minimum: 0, maximum: 6, description: "Current products use quality 0 and potions use qualities 1–6." }, qty: { type: "integer", format: "int64", minimum: 1 }, price: { type: "integer", format: "int64", minimum: 1, maximum: 1000000000000, description: "Unit price in hundredths of the listing country currency." }, goldPrice: { description: "Gold-equivalent unit price as an exact decimal in Gold.", type: "string", pattern: "^[0-9]+[.][0-9]{6}$" }, createdAt: { type: "string", format: "date-time" }, country: { type: "integer", minimum: 0 }, priceAsset: { type: "string", pattern: "^(gold|cur:(0|[1-9][0-9]*))$", description: "Gold or a national currency. The number after cur: is the country ID." }, vatPercent: { type: "integer", format: "int64", minimum: 0, maximum: 100 }, importTaxPercent: { type: "integer", format: "int64", minimum: 0, maximum: 100 } } } }, nextCursor: { type: ["string", "null"] } } } } }, responseFields: ["total", "items", "nextCursor"] },
|
|
14373
|
+
{ operationId: "CreateMarketOrder", name: "create-market-order", method: "POST", path: "/api/market/orders", spec: "economy.yaml", write: true, retry: "unsafe", description: "Citizen session required. Escrow the listed goods at the chosen listing country.", parameters: [{ name: "Origin", in: "header", required: true, description: "The same origin as the site hosting the API.", schema: { type: "string", format: "uri" } }], body: { required: true, schema: { type: "object", additionalProperties: false, required: ["country", "item", "quality", "qty", "price"], properties: { stockCompanyId: { type: "integer", format: "int64", minimum: 1 }, country: { type: "integer", minimum: 0 }, item: { type: "string", enum: ["jinxed", "finesse", "bloody_mess", "lucky", "GRAIN", "IRON", "OIL", "WOOD", "STONE", "MINERALS", "SMALL_DRINK", "LARGE_DRINK", "SNACK", "MEAL", "PISTOL", "RIFLE", "TICKET_ECONOMY", "TICKET_BUSINESS", "KNIFE", "HOUSE", "MANSION", "BOAT", "YACHT", "DEFENSE_SYSTEM", "HOSPITAL"] }, quality: { type: "integer", format: "int64", minimum: 0, maximum: 6, description: "Current products use quality 0 and potions use qualities 1–6." }, qty: { type: "integer", format: "int64", minimum: 1 }, price: { type: "integer", format: "int64", minimum: 1, maximum: 1000000000000, description: "Unit price in hundredths of the listing country currency." } } } }, requiresCredentials: true, responses: { "201": { kind: "json", schema: { type: "object", additionalProperties: false, required: ["id", "seller", "sellerName", "sellerNation", "item", "quality", "qty", "price", "createdAt", "country", "priceAsset", "vatPercent", "importTaxPercent"], properties: { stockCompanyId: { type: "integer", format: "int64", minimum: 1 }, id: { type: "integer", format: "int64", minimum: 1 }, seller: { type: "string", pattern: "^[1-9][0-9]*$", description: "Decimal encoding of the citizen ID." }, sellerName: { type: "string" }, sellerAvatarVersion: { description: "Public avatar version, omitted when the seller has no custom avatar.", type: "string" }, sellerLevel: { description: "Public citizen level.", type: "integer" }, sellerNation: { type: "integer", minimum: 0 }, item: { type: "string", enum: ["jinxed", "finesse", "bloody_mess", "lucky", "GRAIN", "IRON", "OIL", "WOOD", "STONE", "MINERALS", "SMALL_DRINK", "LARGE_DRINK", "SNACK", "MEAL", "PISTOL", "RIFLE", "TICKET_ECONOMY", "TICKET_BUSINESS", "KNIFE", "HOUSE", "MANSION", "BOAT", "YACHT", "DEFENSE_SYSTEM", "HOSPITAL"] }, quality: { type: "integer", format: "int64", minimum: 0, maximum: 6, description: "Current products use quality 0 and potions use qualities 1–6." }, qty: { type: "integer", format: "int64", minimum: 1 }, price: { type: "integer", format: "int64", minimum: 1, maximum: 1000000000000, description: "Unit price in hundredths of the listing country currency." }, goldPrice: { description: "Gold-equivalent unit price as an exact decimal in Gold.", type: "string", pattern: "^[0-9]+[.][0-9]{6}$" }, createdAt: { type: "string", format: "date-time" }, country: { type: "integer", minimum: 0 }, priceAsset: { type: "string", pattern: "^(gold|cur:(0|[1-9][0-9]*))$", description: "Gold or a national currency. The number after cur: is the country ID." }, vatPercent: { type: "integer", format: "int64", minimum: 0, maximum: 100 }, importTaxPercent: { type: "integer", format: "int64", minimum: 0, maximum: 100 } } } } }, responseFields: ["stockCompanyId", "id", "seller", "sellerName", "sellerAvatarVersion", "sellerLevel", "sellerNation", "item", "quality", "qty", "price", "goldPrice", "createdAt", "country", "priceAsset", "vatPercent", "importTaxPercent"] },
|
|
14374
|
+
{ operationId: "GetMarketOrder", name: "get-market-order", method: "GET", path: "/api/market/orders/{id}", spec: "economy.yaml", write: false, retry: "unsafe", description: "Public. Read a current offer.", parameters: [{ name: "id", in: "path", required: true, description: "Resource ID.", schema: { type: "integer", format: "int64", minimum: 1 } }], requiresCredentials: false, responses: { "200": { kind: "json", schema: { type: "object", additionalProperties: false, required: ["id", "seller", "sellerName", "sellerNation", "item", "quality", "qty", "price", "createdAt", "country", "priceAsset", "vatPercent", "importTaxPercent"], properties: { stockCompanyId: { type: "integer", format: "int64", minimum: 1 }, id: { type: "integer", format: "int64", minimum: 1 }, seller: { type: "string", pattern: "^[1-9][0-9]*$", description: "Decimal encoding of the citizen ID." }, sellerName: { type: "string" }, sellerAvatarVersion: { description: "Public avatar version, omitted when the seller has no custom avatar.", type: "string" }, sellerLevel: { description: "Public citizen level.", type: "integer" }, sellerNation: { type: "integer", minimum: 0 }, item: { type: "string", enum: ["jinxed", "finesse", "bloody_mess", "lucky", "GRAIN", "IRON", "OIL", "WOOD", "STONE", "MINERALS", "SMALL_DRINK", "LARGE_DRINK", "SNACK", "MEAL", "PISTOL", "RIFLE", "TICKET_ECONOMY", "TICKET_BUSINESS", "KNIFE", "HOUSE", "MANSION", "BOAT", "YACHT", "DEFENSE_SYSTEM", "HOSPITAL"] }, quality: { type: "integer", format: "int64", minimum: 0, maximum: 6, description: "Current products use quality 0 and potions use qualities 1–6." }, qty: { type: "integer", format: "int64", minimum: 1 }, price: { type: "integer", format: "int64", minimum: 1, maximum: 1000000000000, description: "Unit price in hundredths of the listing country currency." }, goldPrice: { description: "Gold-equivalent unit price as an exact decimal in Gold.", type: "string", pattern: "^[0-9]+[.][0-9]{6}$" }, createdAt: { type: "string", format: "date-time" }, country: { type: "integer", minimum: 0 }, priceAsset: { type: "string", pattern: "^(gold|cur:(0|[1-9][0-9]*))$", description: "Gold or a national currency. The number after cur: is the country ID." }, vatPercent: { type: "integer", format: "int64", minimum: 0, maximum: 100 }, importTaxPercent: { type: "integer", format: "int64", minimum: 0, maximum: 100 } } } } }, responseFields: ["stockCompanyId", "id", "seller", "sellerName", "sellerAvatarVersion", "sellerLevel", "sellerNation", "item", "quality", "qty", "price", "goldPrice", "createdAt", "country", "priceAsset", "vatPercent", "importTaxPercent"] },
|
|
14374
14375
|
{ operationId: "CancelMarketOrder", name: "cancel-market-order", method: "DELETE", path: "/api/market/orders/{id}", spec: "economy.yaml", write: true, retry: "natural", description: "Citizen session required. Return the seller's remaining quantity from escrow.", parameters: [{ name: "id", in: "path", required: true, description: "Resource ID.", schema: { type: "integer", format: "int64", minimum: 1 } }, { name: "Origin", in: "header", required: true, description: "The same origin as the site hosting the API.", schema: { type: "string", format: "uri" } }], requiresCredentials: true, responses: { "204": { kind: "empty" } }, responseFields: [] },
|
|
14375
14376
|
{ operationId: "PurchaseMarketOrder", name: "purchase-market-order", method: "POST", path: "/api/market/orders/{id}/purchase", spec: "economy.yaml", write: true, retry: "unsafe", description: "Citizen session required. Buy the requested quantity from the selected listing within maxPayment. The purchase charges buyer VAT and deducts import tax from a foreign seller. An insufficient_funds response includes currency, shortfall and goldBalance in context. Both amounts are in minor units.", parameters: [{ name: "id", in: "path", required: true, description: "Resource ID.", schema: { type: "integer", format: "int64", minimum: 1 } }, { name: "Origin", in: "header", required: true, description: "The same origin as the site hosting the API.", schema: { type: "string", format: "uri" } }], body: { required: true, schema: { type: "object", additionalProperties: false, required: ["qty", "maxPayment"], properties: { qty: { type: "integer", format: "int64", minimum: 1 }, maxPayment: { type: "integer", format: "int64", minimum: 1, description: "Maximum total charge including VAT, in hundredths of the listing country currency." } } } }, requiresCredentials: true, responses: { "200": { kind: "json", schema: { type: "object", additionalProperties: false, required: ["orderId", "item", "quality", "receivedQty", "remainingQty", "priceAsset", "paid", "vat", "importTax", "unitPrice", "seller", "sellerName", "sellerNation"], properties: { orderId: { type: "integer", format: "int64", minimum: 1 }, unitPrice: { type: "integer", format: "int64", minimum: 1, maximum: 1000000000000, description: "Unit price in hundredths of the listing country currency." }, seller: { type: "string", pattern: "^[1-9][0-9]*$", description: "Decimal encoding of the citizen ID." }, sellerName: { type: "string" }, sellerNation: { type: "integer", minimum: 0 }, stockCompanyId: { allOf: [{ type: "integer", format: "int64", minimum: 1 }, { description: "Selling stock company, omitted for a citizen seller." }] }, item: { type: "string", enum: ["jinxed", "finesse", "bloody_mess", "lucky", "GRAIN", "IRON", "OIL", "WOOD", "STONE", "MINERALS", "SMALL_DRINK", "LARGE_DRINK", "SNACK", "MEAL", "PISTOL", "RIFLE", "TICKET_ECONOMY", "TICKET_BUSINESS", "KNIFE", "HOUSE", "MANSION", "BOAT", "YACHT", "DEFENSE_SYSTEM", "HOSPITAL"] }, quality: { type: "integer", format: "int64", minimum: 0, maximum: 6, description: "Current products use quality 0 and potions use qualities 1–6." }, receivedQty: { type: "integer", format: "int64", minimum: 1 }, remainingQty: { type: "integer", format: "int64", minimum: 0 }, priceAsset: { type: "string", pattern: "^(gold|cur:(0|[1-9][0-9]*))$", description: "Gold or a national currency. The number after cur: is the country ID." }, paid: { type: "integer", format: "int64", minimum: 1, description: "Actual buyer debit, including VAT, in hundredths." }, vat: { type: "integer", format: "int64", minimum: 0 }, importTax: { type: "integer", format: "int64", minimum: 0 } } } } }, responseFields: ["orderId", "unitPrice", "seller", "sellerName", "sellerNation", "stockCompanyId", "item", "quality", "receivedQty", "remainingQty", "priceAsset", "paid", "vat", "importTax"] },
|
|
14376
14377
|
{ operationId: "PurchaseLowestMarketOrder", name: "purchase-lowest-market-order", method: "POST", path: "/api/market/purchases", spec: "economy.yaml", write: true, retry: "unsafe", description: "Citizen session required. Buy the requested quantity from the cheapest eligible listing within maxPayment. Ties use order ID. The server skips locked rows and your own listings. An insufficient_funds response includes currency, shortfall and goldBalance in context. Both amounts are in minor units.", parameters: [{ name: "Origin", in: "header", required: true, description: "The same origin as the site hosting the API.", schema: { type: "string", format: "uri" } }], body: { required: true, schema: { type: "object", additionalProperties: false, required: ["country", "item", "quality", "qty", "maxPayment"], properties: { country: { type: "integer", minimum: 0 }, item: { type: "string", enum: ["jinxed", "finesse", "bloody_mess", "lucky", "GRAIN", "IRON", "OIL", "WOOD", "STONE", "MINERALS", "SMALL_DRINK", "LARGE_DRINK", "SNACK", "MEAL", "PISTOL", "RIFLE", "TICKET_ECONOMY", "TICKET_BUSINESS", "KNIFE", "HOUSE", "MANSION", "BOAT", "YACHT", "DEFENSE_SYSTEM", "HOSPITAL"] }, quality: { type: "integer", format: "int64", minimum: 0, maximum: 6, description: "Current products use quality 0 and potions use qualities 1–6." }, qty: { type: "integer", format: "int64", minimum: 1 }, maxPayment: { type: "integer", format: "int64", minimum: 1, description: "Maximum total charge including VAT, in hundredths of the listing country currency." } } } }, requiresCredentials: true, responses: { "200": { kind: "json", schema: { type: "object", additionalProperties: false, required: ["orderId", "item", "quality", "receivedQty", "remainingQty", "priceAsset", "paid", "vat", "importTax", "unitPrice", "seller", "sellerName", "sellerNation"], properties: { orderId: { type: "integer", format: "int64", minimum: 1 }, unitPrice: { type: "integer", format: "int64", minimum: 1, maximum: 1000000000000, description: "Unit price in hundredths of the listing country currency." }, seller: { type: "string", pattern: "^[1-9][0-9]*$", description: "Decimal encoding of the citizen ID." }, sellerName: { type: "string" }, sellerNation: { type: "integer", minimum: 0 }, stockCompanyId: { allOf: [{ type: "integer", format: "int64", minimum: 1 }, { description: "Selling stock company, omitted for a citizen seller." }] }, item: { type: "string", enum: ["jinxed", "finesse", "bloody_mess", "lucky", "GRAIN", "IRON", "OIL", "WOOD", "STONE", "MINERALS", "SMALL_DRINK", "LARGE_DRINK", "SNACK", "MEAL", "PISTOL", "RIFLE", "TICKET_ECONOMY", "TICKET_BUSINESS", "KNIFE", "HOUSE", "MANSION", "BOAT", "YACHT", "DEFENSE_SYSTEM", "HOSPITAL"] }, quality: { type: "integer", format: "int64", minimum: 0, maximum: 6, description: "Current products use quality 0 and potions use qualities 1–6." }, receivedQty: { type: "integer", format: "int64", minimum: 1 }, remainingQty: { type: "integer", format: "int64", minimum: 0 }, priceAsset: { type: "string", pattern: "^(gold|cur:(0|[1-9][0-9]*))$", description: "Gold or a national currency. The number after cur: is the country ID." }, paid: { type: "integer", format: "int64", minimum: 1, description: "Actual buyer debit, including VAT, in hundredths." }, vat: { type: "integer", format: "int64", minimum: 0 }, importTax: { type: "integer", format: "int64", minimum: 0 } } } } }, responseFields: ["orderId", "unitPrice", "seller", "sellerName", "sellerNation", "stockCompanyId", "item", "quality", "receivedQty", "remainingQty", "priceAsset", "paid", "vat", "importTax"] },
|
|
@@ -15357,7 +15358,8 @@ function conditions(command, args, data = {}) {
|
|
|
15357
15358
|
const parts = [];
|
|
15358
15359
|
if (command.sort) {
|
|
15359
15360
|
const key = typeof args.sort === "string" ? args.sort : command.sort.default;
|
|
15360
|
-
|
|
15361
|
+
if (key !== undefined)
|
|
15362
|
+
parts.push(`${key} ${typeof args.order === "string" ? args.order : command.sort.keys[key] ?? ""}`.trim());
|
|
15361
15363
|
}
|
|
15362
15364
|
for (const arg of command.args) {
|
|
15363
15365
|
if (notConditions.has(arg.name))
|
|
@@ -20665,6 +20667,12 @@ var lawLine = (law) => [
|
|
|
20665
20667
|
typeof law.proposal === "string" && law.proposal ? law.proposal : undefined
|
|
20666
20668
|
].filter(Boolean).join(" · ");
|
|
20667
20669
|
var tally = (law) => `yes ${String(law.yes ?? 0)} no ${String(law.no ?? 0)}${Array.isArray(law.voters) ? ` of ${law.voters.length} voters` : ""}`;
|
|
20670
|
+
function lawVotingView(data) {
|
|
20671
|
+
if (!isObject2(data) || !isObject2(data.voting))
|
|
20672
|
+
return data;
|
|
20673
|
+
const voting = Object.fromEntries(Object.entries(data.voting).map(([key, value]) => [key, typeof value === "boolean" ? value ? "yes" : "no" : value]));
|
|
20674
|
+
return { ...data, voting };
|
|
20675
|
+
}
|
|
20668
20676
|
function voteView(data) {
|
|
20669
20677
|
if (!isObject2(data) || typeof data.id !== "number")
|
|
20670
20678
|
return writeView2(data);
|
|
@@ -20682,7 +20690,7 @@ function voteView(data) {
|
|
|
20682
20690
|
proposer: _proposer,
|
|
20683
20691
|
...rest
|
|
20684
20692
|
} = data;
|
|
20685
|
-
return writeView2({ law: lawLine(data), tally: tally(data), ...rest });
|
|
20693
|
+
return writeView2(lawVotingView({ law: lawLine(data), tally: tally(data), ...rest }));
|
|
20686
20694
|
}
|
|
20687
20695
|
function lawListView(data) {
|
|
20688
20696
|
if (!isObject2(data) || !Array.isArray(data.items))
|
|
@@ -20722,6 +20730,24 @@ async function ownLawBallot(ctx, id) {
|
|
|
20722
20730
|
throw error;
|
|
20723
20731
|
}
|
|
20724
20732
|
}
|
|
20733
|
+
async function lawVoting(ctx, law, self, ballot) {
|
|
20734
|
+
const settled = law.status !== "ACTIVE";
|
|
20735
|
+
if (!settled && law.votingEndsAt)
|
|
20736
|
+
await ctx.call("clock");
|
|
20737
|
+
const votingClosed = settled || law.votingEndsAt !== undefined && Date.parse(law.votingEndsAt) <= ctx.now;
|
|
20738
|
+
const eligible = self !== undefined && law.voters.some((voter) => voter.citizen.id === self);
|
|
20739
|
+
const hasVoted = ballot !== null;
|
|
20740
|
+
const reason = settled ? `This law has settled (${law.status}).` : votingClosed ? "Voting has closed." : hasVoted ? "You have already voted." : self === undefined ? "Sign in to check your voting eligibility." : !eligible ? "You are not eligible to vote on this law." : undefined;
|
|
20741
|
+
return { settled, votingClosed, eligible, hasVoted, canVote: reason === undefined, reason };
|
|
20742
|
+
}
|
|
20743
|
+
var lawPageSize = 15;
|
|
20744
|
+
var lawListCommand = (page, args) => [
|
|
20745
|
+
"esim law list",
|
|
20746
|
+
"--page",
|
|
20747
|
+
String(page),
|
|
20748
|
+
...["country", "type", "status"].flatMap((key) => typeof args[key] === "string" ? [`--${key}`, shellWord(args[key])] : []),
|
|
20749
|
+
...args.votable ? ["--votable"] : []
|
|
20750
|
+
].join(" ");
|
|
20725
20751
|
var fiscalLawTypes = new Set([
|
|
20726
20752
|
"PRINT_MONEY",
|
|
20727
20753
|
"DONATE_MONEY",
|
|
@@ -20884,14 +20910,16 @@ var congress = [
|
|
|
20884
20910
|
session: false,
|
|
20885
20911
|
args: [
|
|
20886
20912
|
countryFlag,
|
|
20887
|
-
flag("type", string2().transform((value) => value.toUpperCase().replaceAll("-", "_"))
|
|
20913
|
+
flag("type", string2().transform((value) => value.toUpperCase().replaceAll("-", "_")), {
|
|
20914
|
+
source: "Common types include DECLARE_WAR, CEASE_FIRE_ACCEPT, MPP_PROPOSAL, PROPOSE_NAP, CHANGE_TAX, DONATE_MONEY and PROPOSE_REFERENDUM."
|
|
20915
|
+
}),
|
|
20888
20916
|
flag("status", _enum(["any", "active", "accepted", "accepted-success", "accepted-failed", "rejected"]), { default: "any" }),
|
|
20889
20917
|
flag("page", exports_coerce.number().int().min(1).max(2147483647), { default: 1 }),
|
|
20890
20918
|
votable
|
|
20891
20919
|
],
|
|
20892
|
-
examples: ["esim law list --status active", "esim law list --country Poland --page 2"],
|
|
20920
|
+
examples: ["esim law list --status active", "esim law list --country Poland --page 2", "esim law list --type DECLARE_WAR"],
|
|
20893
20921
|
operations: ["get-geography", "list-laws", "me"],
|
|
20894
|
-
output: { items: "Registry entries", page: "Page number", total: "Matching laws", next: "
|
|
20922
|
+
output: { items: "Registry entries", page: "Page number", total: "Matching laws", next: "Law details and nearby pages" },
|
|
20895
20923
|
view: lawListView,
|
|
20896
20924
|
empty: (data) => isObject2(data) && Array.isArray(data.items) && !data.items.length ? lawsEmpty(String(data.showing)) : undefined,
|
|
20897
20925
|
async run(ctx, args) {
|
|
@@ -20907,7 +20935,8 @@ var congress = [
|
|
|
20907
20935
|
const self = await viewerPid(ctx);
|
|
20908
20936
|
const items = page.items.map((item) => registryLaw(item, world, self));
|
|
20909
20937
|
const anyStatus = args.status === "any" && args.type === undefined && !args.votable;
|
|
20910
|
-
|
|
20938
|
+
const first = items[0];
|
|
20939
|
+
return listHeader(ctx, { ...page, items, next: first ? next({ run: `esim law show ${first.id}`, note: "Replace the ID to inspect another law." }, page.page * lawPageSize < page.total ? { run: lawListCommand(page.page + 1, args), note: "Next page" } : undefined, page.page > 1 ? { run: lawListCommand(page.page - 1, args), note: "Previous page" } : undefined) : anyStatus ? [{ run: "esim law --help", note: "Lists the commands that propose each kind of law." }, { run: "esim congress" }] : [{ run: "esim law list" }] }, country ? { country: ref(country) } : {});
|
|
20911
20940
|
}
|
|
20912
20941
|
}),
|
|
20913
20942
|
politicalCommand({
|
|
@@ -20916,15 +20945,27 @@ var congress = [
|
|
|
20916
20945
|
session: false,
|
|
20917
20946
|
args: [objectId("id")],
|
|
20918
20947
|
examples: ["esim law show 1"],
|
|
20919
|
-
|
|
20920
|
-
|
|
20948
|
+
view: lawVotingView,
|
|
20949
|
+
operations: ["get-geography", "get-law", "get-own-law-ballot", "me", "clock"],
|
|
20950
|
+
output: {
|
|
20951
|
+
effect: "Server's current effect preview",
|
|
20952
|
+
ballot: "Your ballot",
|
|
20953
|
+
voting: "Settlement, eligibility and whether you have voted",
|
|
20954
|
+
next: "Available ballot commands"
|
|
20955
|
+
},
|
|
20921
20956
|
async run(ctx, args) {
|
|
20922
20957
|
const id = number4(args.id);
|
|
20923
20958
|
const world = await geography(ctx);
|
|
20924
20959
|
const item = await ctx.call("get-law", { id });
|
|
20925
20960
|
const self = await viewerPid(ctx);
|
|
20926
20961
|
const ballot = authenticated(ctx) ? await ownLawBallot(ctx, id) : null;
|
|
20927
|
-
|
|
20962
|
+
const voting = await lawVoting(ctx, item, self, ballot);
|
|
20963
|
+
return {
|
|
20964
|
+
...registryLaw(item, world, self),
|
|
20965
|
+
ballot,
|
|
20966
|
+
voting,
|
|
20967
|
+
next: voting.canVote ? voteChoices(undefined, `esim law vote ${id}`) : []
|
|
20968
|
+
};
|
|
20928
20969
|
}
|
|
20929
20970
|
}),
|
|
20930
20971
|
politicalCommand({
|
|
@@ -20932,7 +20973,7 @@ var congress = [
|
|
|
20932
20973
|
summary: "Cast a vote on a registered law.",
|
|
20933
20974
|
args: [objectId("id"), yesNo, dryRun],
|
|
20934
20975
|
examples: ["esim law vote 1 yes --dry-run"],
|
|
20935
|
-
operations: ["get-geography", "get-law", "get-own-law-ballot", "cast-law-ballot", "get-country", "get-country-treasury"],
|
|
20976
|
+
operations: ["get-geography", "get-law", "get-own-law-ballot", "cast-law-ballot", "get-country", "get-country-treasury", "me", "clock"],
|
|
20936
20977
|
confirmWith: ["esim law list --status active"],
|
|
20937
20978
|
confirmUsing: (args) => [`esim law show ${args.id}`],
|
|
20938
20979
|
output: {
|
|
@@ -20940,8 +20981,9 @@ var congress = [
|
|
|
20940
20981
|
effect: "Server's current effect preview",
|
|
20941
20982
|
status: "Law status",
|
|
20942
20983
|
failReason: "Reason enactment failed",
|
|
20984
|
+
voting: "Settlement, eligibility and whether you have voted",
|
|
20943
20985
|
changed: "Ballot and law status before → after",
|
|
20944
|
-
next: "Law details"
|
|
20986
|
+
next: "Law details or the available vote"
|
|
20945
20987
|
},
|
|
20946
20988
|
view: voteView,
|
|
20947
20989
|
async run(ctx, args) {
|
|
@@ -20951,14 +20993,24 @@ var congress = [
|
|
|
20951
20993
|
const before = await ctx.call("get-law", { id });
|
|
20952
20994
|
const ballot = await ownLawBallot(ctx, id);
|
|
20953
20995
|
const follow = { run: `esim law show ${id}` };
|
|
20954
|
-
if (args["dry-run"])
|
|
20996
|
+
if (args["dry-run"]) {
|
|
20997
|
+
const self = await viewerPid(ctx);
|
|
20998
|
+
const voting = await lawVoting(ctx, before, self, ballot);
|
|
20999
|
+
if (voting.reason !== undefined) {
|
|
21000
|
+
const code = voting.votingClosed ? "closed" : voting.hasVoted ? "already_voted" : "forbidden";
|
|
21001
|
+
const eligibility = voting.eligible ? "yes" : "no";
|
|
21002
|
+
const alreadyVoted = voting.hasVoted ? "yes" : "no";
|
|
21003
|
+
return refuse2(ctx, code, `${voting.reason} Eligible: ${eligibility}. Already voted: ${alreadyVoted}.`, { law: { id, status: before.status }, voting, ballot }, follow.run);
|
|
21004
|
+
}
|
|
20955
21005
|
return {
|
|
20956
|
-
...registryLaw(before, world),
|
|
21006
|
+
...registryLaw(before, world, self),
|
|
20957
21007
|
dryRun: true,
|
|
20958
21008
|
ballot,
|
|
20959
|
-
|
|
20960
|
-
|
|
21009
|
+
voting,
|
|
21010
|
+
changed: { ballot: [null, ballotWord(yes)] },
|
|
21011
|
+
next: [{ run: `esim law vote ${id} ${yes ? "yes" : "no"}` }, follow]
|
|
20961
21012
|
};
|
|
21013
|
+
}
|
|
20962
21014
|
const nation = before.country;
|
|
20963
21015
|
const tax = before.taxCategory?.kind ?? "wage";
|
|
20964
21016
|
const product = before.taxCategory?.item;
|
|
@@ -23517,21 +23569,6 @@ function mineView(data) {
|
|
|
23517
23569
|
next: next ?? null
|
|
23518
23570
|
};
|
|
23519
23571
|
}
|
|
23520
|
-
async function missingProduct(ctx) {
|
|
23521
|
-
const local = await observe(async () => {
|
|
23522
|
-
const account = await ctx.call("me");
|
|
23523
|
-
return localMarket(ctx, row2(account.citizen), await geography(ctx));
|
|
23524
|
-
});
|
|
23525
|
-
const listed = "products" in local ? local.products : [];
|
|
23526
|
-
const name = "products" in local && local.country ? `${local.country.name}'s market` : "your local market";
|
|
23527
|
-
throw new CommandError(2, "invalid_arguments", `Name a product to browse${listed.length ? `; ${name} lists ${listed.map((entry) => entry.product).join(", ")}` : ""}.`, `<product> is ${productHelp.charAt(0).toLowerCase()}${productHelp.slice(1)}.`, undefined, {
|
|
23528
|
-
next: [
|
|
23529
|
-
...listed.slice(0, 2).map((entry) => ({ run: `esim market list ${productWord2(entry.item, entry.quality)}` })),
|
|
23530
|
-
{ run: "esim market" },
|
|
23531
|
-
...listed.length ? [] : [{ run: "esim market list snack" }]
|
|
23532
|
-
]
|
|
23533
|
-
});
|
|
23534
|
-
}
|
|
23535
23572
|
async function noOffers(account, item, input, filtered, world) {
|
|
23536
23573
|
const held = account ? await observe(async () => {
|
|
23537
23574
|
const stock = account.inventory.filter((entry) => number4(entry.qty) > 0).find((entry) => entry.item === item.item && (item.quality === undefined || entry.quality === item.quality));
|
|
@@ -23547,67 +23584,97 @@ async function noOffers(account, item, input, filtered, world) {
|
|
|
23547
23584
|
{ run: "esim market" }
|
|
23548
23585
|
];
|
|
23549
23586
|
}
|
|
23587
|
+
var productSorts = { offers: "desc", countries: "desc", quantity: "desc", price: "asc", product: "asc" };
|
|
23588
|
+
var offerSorts = { price: "asc", quantity: "desc", created: "desc", country: "asc", seller: "asc" };
|
|
23589
|
+
var sortChoices = (keys) => Object.entries(keys).map(([key, order]) => `${key} ${order}`).join(" · ");
|
|
23550
23590
|
var market = [
|
|
23551
23591
|
command5({
|
|
23552
23592
|
path: ["market", "list"],
|
|
23553
23593
|
empty: "No market offers match these filters.",
|
|
23554
|
-
summary: "
|
|
23594
|
+
summary: "Summarize products or browse their offers",
|
|
23555
23595
|
args: [
|
|
23556
|
-
{ ...product, required: false, source: `${productHelp}.
|
|
23596
|
+
{ ...product, required: false, source: `${productHelp}. Omit for a product summary.` },
|
|
23557
23597
|
countryFlag2,
|
|
23558
23598
|
flag("min-qty", exports_coerce.number().int().min(1), { placeholder: "units", source: "Only offers with at least this many units left" })
|
|
23559
23599
|
],
|
|
23560
|
-
sort: { keys: {
|
|
23600
|
+
sort: { keys: { ...productSorts, ...offerSorts }, order: true },
|
|
23601
|
+
help: [
|
|
23602
|
+
`Product summary, default offers desc: ${sortChoices(productSorts)}.`,
|
|
23603
|
+
`Offers for a product, default price asc: ${sortChoices(offerSorts)}. Price compares Gold equivalents in both views.`
|
|
23604
|
+
],
|
|
23561
23605
|
examples: [
|
|
23606
|
+
"esim market list",
|
|
23607
|
+
"esim market list --country China",
|
|
23562
23608
|
"esim market list snack",
|
|
23563
|
-
"esim market list jinxed:q3 --sort
|
|
23609
|
+
"esim market list jinxed:q3 --sort quantity",
|
|
23564
23610
|
"esim market list snack --min-qty 10 --sort price --order asc --limit 5",
|
|
23565
23611
|
"esim market list snack --country China",
|
|
23566
23612
|
"esim market list grain --country Poland --order desc"
|
|
23567
23613
|
],
|
|
23568
|
-
output: { ...pageOutput3, next: "
|
|
23614
|
+
output: { ...pageOutput3, next: "Open product offers, or preview a purchase and find currency" },
|
|
23569
23615
|
paged: true,
|
|
23570
|
-
operations: ["market-orders", "get-geography", "me"
|
|
23616
|
+
operations: ["list-market-products", "market-orders", "get-geography", "me"],
|
|
23571
23617
|
async run(ctx, args) {
|
|
23572
|
-
|
|
23573
|
-
|
|
23574
|
-
|
|
23575
|
-
const item = resolveMarketProduct(
|
|
23618
|
+
const input = textArg(args, "product");
|
|
23619
|
+
if (input)
|
|
23620
|
+
rejectEquipment(input);
|
|
23621
|
+
const item = input ? resolveMarketProduct(input) : undefined;
|
|
23622
|
+
const sorts = item ? offerSorts : productSorts;
|
|
23623
|
+
const sort = textArg(args, "sort") ?? (item ? "price" : "offers");
|
|
23624
|
+
if (!Object.hasOwn(sorts, sort)) {
|
|
23625
|
+
usage2(`Invalid --sort for ${item ? "offers" : "the product summary"}. Use one of: ${Object.keys(sorts).join("|")}.`);
|
|
23626
|
+
}
|
|
23576
23627
|
const world = await geography(ctx);
|
|
23577
23628
|
const countryName = textArg(args, "country");
|
|
23578
|
-
const country = countryName && !everyCountry(countryName) ?
|
|
23579
|
-
const
|
|
23580
|
-
const
|
|
23581
|
-
|
|
23582
|
-
...country,
|
|
23583
|
-
...sort !== "price" || country.country !== undefined ? { sort } : {},
|
|
23629
|
+
const country = countryName && !everyCountry(countryName) ? choose(world.countries, countryName, "country").id : undefined;
|
|
23630
|
+
const marketCountry = countryRef(world, country);
|
|
23631
|
+
const header = { command: ctx.command, args: { ...ctx.args, sort } };
|
|
23632
|
+
const filters = {
|
|
23633
|
+
...country === undefined ? {} : { country },
|
|
23584
23634
|
...orderQuery(args),
|
|
23585
23635
|
...typeof args["min-qty"] === "number" ? { minQty: args["min-qty"] } : {}
|
|
23586
23636
|
};
|
|
23637
|
+
if (!input || !item) {
|
|
23638
|
+
const page = await ctx.page("list-market-products", { ...filters, sort: sort === "price" ? "gold" : sort }, (entry) => ({
|
|
23639
|
+
product: productName(entry.product, entry.quality),
|
|
23640
|
+
countries: entry.countries,
|
|
23641
|
+
offers: entry.offers,
|
|
23642
|
+
quantity: entry.quantity,
|
|
23643
|
+
minGold: `${entry.minGold} GOLD`,
|
|
23644
|
+
price: amount(entry.price, currencyName(world, `cur:${entry.country}`)),
|
|
23645
|
+
country: countryRef(world, entry.country),
|
|
23646
|
+
next: [{ run: `esim market list ${productWord2(entry.product, entry.quality)}${country === undefined ? "" : ` --country ${country}`}` }]
|
|
23647
|
+
}));
|
|
23648
|
+
return listHeader(header, page, { product: "all", country: marketCountry ?? "all" });
|
|
23649
|
+
}
|
|
23650
|
+
const query = { ...item, ...filters, sort: sort === "price" ? "gold" : sort === "quantity" ? "qty" : sort };
|
|
23587
23651
|
const viewer = await viewerAccount(ctx);
|
|
23588
23652
|
const viewerId = viewer?.citizen ? row2(viewer.citizen).pid : undefined;
|
|
23589
23653
|
const self = typeof viewerId === "string" ? viewerId : null;
|
|
23590
|
-
const page = await ctx.page("market-orders", query, (order) =>
|
|
23654
|
+
const page = await ctx.page("market-orders", query, (order) => ({
|
|
23655
|
+
...listing(order, world, self),
|
|
23656
|
+
...order.goldPrice === undefined ? {} : { goldPrice: `${order.goldPrice} GOLD` }
|
|
23657
|
+
})).catch((error) => {
|
|
23591
23658
|
if (!(error instanceof CommandError) || error.error !== "invalid_market_browsing")
|
|
23592
23659
|
throw error;
|
|
23593
|
-
const field = typeof query.minQty === "number" && query.minQty < 1 ? "minQty" :
|
|
23660
|
+
const field = typeof query.minQty === "number" && query.minQty < 1 ? "minQty" : "sort";
|
|
23594
23661
|
throw new CommandError(error.exitCode, error.error, error.message, error.hint, error.candidates, {
|
|
23595
23662
|
...error.details,
|
|
23596
23663
|
context: {
|
|
23597
23664
|
field,
|
|
23598
23665
|
sent: { sort: query.sort ?? null, order: query.order ?? null, minQty: query.minQty ?? null, country: query.country ?? null },
|
|
23599
|
-
rules: "minQty ≥ 1; sort is gold,
|
|
23666
|
+
rules: "minQty ≥ 1; sort is gold, qty, created, country or seller"
|
|
23600
23667
|
}
|
|
23601
23668
|
});
|
|
23602
23669
|
});
|
|
23603
23670
|
const first = page.items[0];
|
|
23604
23671
|
const market = first?.country ? row2(first.country) : undefined;
|
|
23605
|
-
const run = first && market ? `esim market buy 1 ${shellWord(
|
|
23672
|
+
const run = first && market ? `esim market buy 1 ${shellWord(input)} --country ${market.id} --dry-run` : undefined;
|
|
23606
23673
|
const next = run && first ? [
|
|
23607
23674
|
{ run, note: "Buying requires a region controlled by the listing country." },
|
|
23608
23675
|
{ run: browseExchange(first.price.currency), note: "Find offers for the listing currency before traveling." }
|
|
23609
|
-
] : await noOffers(viewer, item,
|
|
23610
|
-
return listHeader(
|
|
23676
|
+
] : await noOffers(viewer, item, input, country !== undefined, world);
|
|
23677
|
+
return listHeader(header, { ...page, ...next.length ? { next } : {} }, marketCountry ? { country: marketCountry } : {});
|
|
23611
23678
|
}
|
|
23612
23679
|
}),
|
|
23613
23680
|
command5({
|
|
@@ -32595,7 +32662,7 @@ var visualWorld = [
|
|
|
32595
32662
|
summary: "Read the worldwide country rankings and the selected metric total",
|
|
32596
32663
|
args: [flag("metric", countryMetric, { default: "people" })],
|
|
32597
32664
|
paged: true,
|
|
32598
|
-
operations: ["list-country-rankings"],
|
|
32665
|
+
operations: ["list-country-rankings", "countries"],
|
|
32599
32666
|
examples: [
|
|
32600
32667
|
"esim country stats",
|
|
32601
32668
|
"esim country stats --metric land --limit 10",
|
|
@@ -32604,13 +32671,22 @@ var visualWorld = [
|
|
|
32604
32671
|
output: {
|
|
32605
32672
|
metric: "Selected statistic",
|
|
32606
32673
|
totalScore: "Worldwide sum for this statistic",
|
|
32607
|
-
items: "Rank, country, and
|
|
32674
|
+
items: "Rank, country, score, and current president",
|
|
32608
32675
|
nextCursor: "Cursor for more countries"
|
|
32609
32676
|
},
|
|
32610
32677
|
async run(ctx, args) {
|
|
32611
32678
|
const metric = countryMetric.parse(args.metric);
|
|
32612
|
-
const ranking = await ctx.call("list-country-rankings", { metric, all: true });
|
|
32613
|
-
const
|
|
32679
|
+
const [ranking, countries] = await Promise.all([ctx.call("list-country-rankings", { metric, all: true }), ctx.call("countries")]);
|
|
32680
|
+
const presidents = new Map(countries.map((entry) => [
|
|
32681
|
+
entry.id,
|
|
32682
|
+
entry.leader === null ? null : { id: entry.leader, name: entry.leaderName ?? null }
|
|
32683
|
+
]));
|
|
32684
|
+
const rows = ranking.entries.map((entry, index) => ({
|
|
32685
|
+
rank: index + 1,
|
|
32686
|
+
country: ref(entry),
|
|
32687
|
+
score: entry.score,
|
|
32688
|
+
president: presidents.get(entry.id) ?? null
|
|
32689
|
+
}));
|
|
32614
32690
|
return { metric, totalScore: ranking.totalScore, ...localPoliticalPage(args, rows), total: ranking.total };
|
|
32615
32691
|
}
|
|
32616
32692
|
}),
|
|
@@ -34132,6 +34208,42 @@ var gift = [
|
|
|
34132
34208
|
// commands/war.ts
|
|
34133
34209
|
var command25 = define("battle");
|
|
34134
34210
|
var confirm2 = ["esim war"];
|
|
34211
|
+
var declarationCost = 3000;
|
|
34212
|
+
var battleCommand = (id) => ({ run: `esim battle show ${id}` });
|
|
34213
|
+
var lawCommand = (id) => ({ run: `esim law show ${id}` });
|
|
34214
|
+
var uniqueCommands = (entries) => [...new Map(entries.map((entry) => [entry.run, entry])).values()];
|
|
34215
|
+
function targetReason(entry) {
|
|
34216
|
+
switch (entry.reason) {
|
|
34217
|
+
case "已有战役或败方主动权仍在冷却":
|
|
34218
|
+
return entry.battle === undefined ? "The losing side is still on initiative cooldown." : `Battle #${entry.battle} is already active.`;
|
|
34219
|
+
case "本国尚未取得战争主动权":
|
|
34220
|
+
return "The defending country has not gained the initiative yet.";
|
|
34221
|
+
case "停战已获批准":
|
|
34222
|
+
return "Peace has already been approved.";
|
|
34223
|
+
default:
|
|
34224
|
+
return entry.reason;
|
|
34225
|
+
}
|
|
34226
|
+
}
|
|
34227
|
+
async function declarationBorder(ctx, world, nation, target) {
|
|
34228
|
+
const control = new Map((await ctx.call("list-lands")).map((land) => [land.id, land.owner]));
|
|
34229
|
+
const owned = world.lands.filter((land) => control.get(land.id) === nation);
|
|
34230
|
+
if (owned.some((land) => land.neighbors.some((id) => control.get(id) === target)))
|
|
34231
|
+
return "land";
|
|
34232
|
+
if (owned.some((land) => land.openWaters) && world.lands.some((land) => land.openWaters && control.get(land.id) === target)) {
|
|
34233
|
+
return "sailor_week_required";
|
|
34234
|
+
}
|
|
34235
|
+
return "none";
|
|
34236
|
+
}
|
|
34237
|
+
async function activeAlliance(ctx, nation, target) {
|
|
34238
|
+
let cursor = null;
|
|
34239
|
+
do {
|
|
34240
|
+
const page = await ctx.call("list-alliances", { nation, ...cursor ? { cursor } : {} });
|
|
34241
|
+
if (page.items.some((entry) => entry.accepted && (entry.from === target || entry.to === target) && entry.endsAt !== undefined && Date.parse(entry.endsAt) > ctx.now))
|
|
34242
|
+
return true;
|
|
34243
|
+
cursor = page.nextCursor;
|
|
34244
|
+
} while (cursor);
|
|
34245
|
+
return false;
|
|
34246
|
+
}
|
|
34135
34247
|
var open2 = (entry) => entry.status === "ACTIVE";
|
|
34136
34248
|
var proposal3 = (entry, world, self) => ({
|
|
34137
34249
|
id: entry.id,
|
|
@@ -34184,7 +34296,7 @@ var war = [
|
|
|
34184
34296
|
...Array.isArray(result.proposals) && !result.proposals.length ? { proposals: "none" } : {}
|
|
34185
34297
|
};
|
|
34186
34298
|
},
|
|
34187
|
-
output: { country: "Selected country", wars: "Recent wars", proposals: "Recent proposals", civilPetition: "Latest civil war petition", can: "Available actions", next: "
|
|
34299
|
+
output: { country: "Selected country", wars: "Recent wars", proposals: "Recent proposals", civilPetition: "Latest civil war petition", can: "Available actions", next: "Related battles, laws and available war actions" },
|
|
34188
34300
|
async run(ctx, args) {
|
|
34189
34301
|
const { nation, own, country, world, president, account } = await offices(ctx, args);
|
|
34190
34302
|
const view = await ctx.call("list-wars", { country: nation });
|
|
@@ -34208,7 +34320,8 @@ var war = [
|
|
|
34208
34320
|
opponent: countryRef(world, attacker === nation ? defender : attacker),
|
|
34209
34321
|
status: entry.endedAt ? "ended" : entry.peacePending ? "peace_pending" : "active",
|
|
34210
34322
|
initiative: entry.endedAt || entry.peacePending ? undefined : Date.parse(entry.startedAt) + 86400000 > ctx.now ? "attack" : "both",
|
|
34211
|
-
battle: activeBattleId ? battleRef(activeBattleId)
|
|
34323
|
+
battle: activeBattleId == null ? undefined : battleRef(activeBattleId),
|
|
34324
|
+
next: next(activeBattleId == null ? undefined : battleCommand(activeBattleId), ...view.proposals.filter((item) => item.warId === entry.id && item.lawId != null).slice(0, 3).flatMap((item) => item.lawId == null ? [] : [lawCommand(item.lawId)]), president && nation === own && !entry.endedAt && !entry.peacePending ? { run: `esim war propose peace ${attacker === nation ? defender : attacker} --dry-run` } : undefined)
|
|
34212
34325
|
};
|
|
34213
34326
|
});
|
|
34214
34327
|
const civilPetition = await observe(async () => petition(await ctx.call("get-civil-petition", { nation })));
|
|
@@ -34217,7 +34330,10 @@ var war = [
|
|
|
34217
34330
|
wars,
|
|
34218
34331
|
civilPetition,
|
|
34219
34332
|
proposals: proposals.map((entry) => ({ ...proposal3(entry, world, pid(account)), canVote: canVote(entry) })),
|
|
34220
|
-
next:
|
|
34333
|
+
next: next(...uniqueCommands([
|
|
34334
|
+
...wars.flatMap((entry) => entry.next),
|
|
34335
|
+
...proposals.flatMap((entry) => entry.lawId == null ? [] : [lawCommand(entry.lawId)])
|
|
34336
|
+
]), nation === own ? { run: "esim war targets" } : undefined, ...!wars.length && !proposals.length && nation === own ? [{ run: "esim battle list" }, president ? { run: "esim war propose --help" } : undefined] : []),
|
|
34221
34337
|
can: [
|
|
34222
34338
|
...president && nation === own ? ["war propose", "war attack"] : [],
|
|
34223
34339
|
...proposals.some(canVote) ? ["law vote"] : [],
|
|
@@ -34251,21 +34367,23 @@ var war = [
|
|
|
34251
34367
|
const target = battleRegion(world, entry.region);
|
|
34252
34368
|
return {
|
|
34253
34369
|
...target,
|
|
34254
|
-
adjacent: entry.adjacent.map((region) => battleRegion(world, region)),
|
|
34255
|
-
war: { id: entry.war, name: `War ${entry.war}` },
|
|
34256
|
-
battle: entry.battle == null ? null : battleRef(entry.battle),
|
|
34257
34370
|
canStart: entry.canStart,
|
|
34371
|
+
reason: targetReason(entry),
|
|
34258
34372
|
errorCode: entry.errorCode,
|
|
34259
|
-
|
|
34373
|
+
war: { id: entry.war, name: `War ${entry.war}` },
|
|
34374
|
+
battle: entry.battle == null ? null : battleRef(entry.battle),
|
|
34375
|
+
adjacent: entry.adjacent.map((region) => battleRegion(world, region))
|
|
34260
34376
|
};
|
|
34261
34377
|
});
|
|
34262
34378
|
const empty = !page.items.length;
|
|
34263
34379
|
return {
|
|
34264
34380
|
...page,
|
|
34265
34381
|
...empty ? { country: countryRef(world, typeof named === "number" ? named : undefined) } : {},
|
|
34266
|
-
next: empty ? [{ run: "esim war" }, { run: "esim battle list --kind war" }] : next(...
|
|
34267
|
-
|
|
34268
|
-
|
|
34382
|
+
next: empty ? [{ run: "esim war" }, { run: "esim battle list --kind war" }] : next(...uniqueCommands([
|
|
34383
|
+
...page.items.flatMap((entry) => entry.canStart || entry.battle === null ? [] : [battleCommand(number4(entry.battle.id))]),
|
|
34384
|
+
...page.items.filter((entry) => entry.canStart).map((entry) => ({ run: `esim war attack ${entry.region.id} --dry-run` })),
|
|
34385
|
+
{ run: "esim war" }
|
|
34386
|
+
]))
|
|
34269
34387
|
};
|
|
34270
34388
|
}
|
|
34271
34389
|
}),
|
|
@@ -34273,11 +34391,18 @@ var war = [
|
|
|
34273
34391
|
path: ["war", "propose"],
|
|
34274
34392
|
summary: "Submit a declaration of war or a peace proposal as president.",
|
|
34275
34393
|
session: true,
|
|
34276
|
-
args: [positional("kind", true, _enum(["declare", "peace"])), positional("country")],
|
|
34277
|
-
|
|
34278
|
-
|
|
34394
|
+
args: [{ ...positional("kind", true, _enum(["declare", "peace"])), source: "declare or peace" }, positional("country"), dryRun],
|
|
34395
|
+
help: [
|
|
34396
|
+
"declare opens a declaration for your congress. Your treasury pays 30 GOLD if the law is enacted.",
|
|
34397
|
+
"peace asks the other country's congress and president to approve a ceasefire in an active war.",
|
|
34398
|
+
"Use a country name or ID from esim country stats. Use esim war to find wartime counterparts."
|
|
34399
|
+
],
|
|
34400
|
+
examples: ["esim war propose declare 1 --dry-run", "esim war propose peace 1 --dry-run"],
|
|
34401
|
+
operations: [...officeReads, "propose-war", "list-wars", "list-lands", "list-alliances", "get-country-treasury", "clock"],
|
|
34279
34402
|
confirmWith: confirm2,
|
|
34280
34403
|
output: {
|
|
34404
|
+
dryRun: "Read-only preview",
|
|
34405
|
+
quote: "Target, fee, approval body and current blockers",
|
|
34281
34406
|
proposal: "Submitted proposal: number, kind, countries, tally and closing time",
|
|
34282
34407
|
voters: "Who votes on it",
|
|
34283
34408
|
changed: "New proposal",
|
|
@@ -34287,8 +34412,61 @@ var war = [
|
|
|
34287
34412
|
async run(ctx, args) {
|
|
34288
34413
|
const state = await offices(ctx);
|
|
34289
34414
|
const { president, world, nation } = state;
|
|
34290
|
-
|
|
34415
|
+
if (!args["dry-run"])
|
|
34416
|
+
requireOffice(ctx, state, president, "the presidency", "esim war");
|
|
34291
34417
|
const target = choose(world.countries, String(args.country), "country");
|
|
34418
|
+
if (args["dry-run"]) {
|
|
34419
|
+
const kind = args.kind === "peace" ? "peace" : "declare";
|
|
34420
|
+
const declaring = kind === "declare";
|
|
34421
|
+
const view = await ctx.call("list-wars", { country: nation });
|
|
34422
|
+
const war = view.wars.find((entry) => !entry.endedAt && [entry.attacker, entry.defender].includes(target.id));
|
|
34423
|
+
const pending = view.proposals.find((entry) => open2(entry) && [entry.proposer, entry.targetCountry].includes(target.id));
|
|
34424
|
+
const approvalCountry = declaring ? nation : target.id;
|
|
34425
|
+
const blockers = [];
|
|
34426
|
+
const approvalBlockers = [];
|
|
34427
|
+
const unchecked = [];
|
|
34428
|
+
if (!president)
|
|
34429
|
+
blockers.push("Only your country's president can submit this proposal.");
|
|
34430
|
+
if (target.id === nation)
|
|
34431
|
+
blockers.push("Choose a foreign country.");
|
|
34432
|
+
else if (declaring && war)
|
|
34433
|
+
blockers.push(`War #${war.id} between these countries is already active.`);
|
|
34434
|
+
else if (!declaring && !war)
|
|
34435
|
+
blockers.push("These countries have no active war.");
|
|
34436
|
+
else if (!declaring && war?.peacePending)
|
|
34437
|
+
blockers.push("Peace has already been approved and will take effect after the active battle.");
|
|
34438
|
+
if (pending && target.id !== nation)
|
|
34439
|
+
blockers.push("A diplomatic proposal between these countries is already awaiting a vote.");
|
|
34440
|
+
if (declaring && blockers.length === 0) {
|
|
34441
|
+
await ctx.call("clock");
|
|
34442
|
+
if (await activeAlliance(ctx, nation, target.id))
|
|
34443
|
+
blockers.push("These countries have an active alliance.");
|
|
34444
|
+
const border = await declarationBorder(ctx, world, nation, target.id);
|
|
34445
|
+
if (border === "none")
|
|
34446
|
+
blockers.push("These countries do not share a land border and each must control an open-water region to declare during Sailor Week.");
|
|
34447
|
+
if (border === "sailor_week_required")
|
|
34448
|
+
unchecked.push("An open-water declaration requires an active Sailor Week. Active status is unverified.");
|
|
34449
|
+
}
|
|
34450
|
+
const balance = declaring ? await treasuryGold(ctx, world, nation) : undefined;
|
|
34451
|
+
if (balance && balance.minor < declarationCost)
|
|
34452
|
+
approvalBlockers.push("Your treasury cannot currently cover the declaration fee.");
|
|
34453
|
+
const canPropose = blockers.length ? false : unchecked.length ? null : true;
|
|
34454
|
+
return {
|
|
34455
|
+
dryRun: true,
|
|
34456
|
+
quote: {
|
|
34457
|
+
kind,
|
|
34458
|
+
target: countryRef(world, target.id),
|
|
34459
|
+
canPropose,
|
|
34460
|
+
blockers,
|
|
34461
|
+
approvalBlockers,
|
|
34462
|
+
unchecked,
|
|
34463
|
+
costOnApproval: gold(declaring ? declarationCost : 0),
|
|
34464
|
+
treasuryBalance: balance,
|
|
34465
|
+
voters: voters(world, approvalCountry, declaring ? state.schedule.seats.length : undefined, declaring ? "congress" : "congress and president")
|
|
34466
|
+
},
|
|
34467
|
+
next: next(war?.activeBattleId == null ? undefined : battleCommand(war.activeBattleId), pending?.lawId == null ? undefined : lawCommand(pending.lawId), canPropose && !approvalBlockers.length ? { run: `esim war propose ${kind} ${target.id}` } : undefined, war && declaring ? { run: `esim war propose peace ${target.id} --dry-run` } : undefined, { run: "esim war" })
|
|
34468
|
+
};
|
|
34469
|
+
}
|
|
34292
34470
|
const result = await attempt(ctx, () => ctx.call("propose-war", {}, { kind: String(args.kind), targetCountry: target.id }), async () => {
|
|
34293
34471
|
const view = await ctx.call("list-wars", { country: nation });
|
|
34294
34472
|
const involved = (entry) => [entry.attacker, entry.defender].includes(target.id);
|
|
@@ -37066,7 +37244,7 @@ function saveCredentials(store, credentials) {
|
|
|
37066
37244
|
}
|
|
37067
37245
|
|
|
37068
37246
|
// version.ts
|
|
37069
|
-
var version2 = "2026.1201.
|
|
37247
|
+
var version2 = "2026.1201.188";
|
|
37070
37248
|
var installKind = version2 === "dev" ? "source" : typeof ESIM_CLI_EXECUTABLE === "boolean" && ESIM_CLI_EXECUTABLE ? "executable" : "npm";
|
|
37071
37249
|
var npmLatestUrl = "https://registry.npmjs.org/esim-cli/latest";
|
|
37072
37250
|
var releaseUrl = (release) => `https://github.com/CorrectRoadH/open-esim/releases/download/cli-v${release}`;
|