@elisym/cli 0.38.0 → 0.38.1
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/index.js +46 -20
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -492,10 +492,30 @@ function planHintOf(view) {
|
|
|
492
492
|
}
|
|
493
493
|
return view.billing?.checkoutAvailable === true ? CHOOSE_PLAN_BILLING_HINT : CHOOSE_PLAN_HINT;
|
|
494
494
|
}
|
|
495
|
-
function
|
|
495
|
+
function upgradeOf(billing, adminUrl) {
|
|
496
|
+
if (billing?.enabled !== true || billing.operatorManaged === true) {
|
|
497
|
+
return UPGRADE;
|
|
498
|
+
}
|
|
499
|
+
if (billing.checkoutAvailable) {
|
|
500
|
+
return { ...UPGRADE, howTo: `Run ${PAID_CHECKOUT}` };
|
|
501
|
+
}
|
|
502
|
+
if (billing.manageable) {
|
|
503
|
+
return {
|
|
504
|
+
...UPGRADE,
|
|
505
|
+
howTo: "Change the paid plan under Manage billing in the admin",
|
|
506
|
+
admin: adminUrl
|
|
507
|
+
};
|
|
508
|
+
}
|
|
509
|
+
return UPGRADE;
|
|
510
|
+
}
|
|
511
|
+
function inactiveExit(view, adminUrl, exitCode = EXIT.LIMIT) {
|
|
496
512
|
return new AskrExit(exitCode, "inactive", {
|
|
497
513
|
hint: `the store is ${view.status}, not active: ${planHintOf(view)}`,
|
|
498
|
-
fields: {
|
|
514
|
+
fields: {
|
|
515
|
+
status: view.status,
|
|
516
|
+
awaitingPlan: awaitingPlanOf(view),
|
|
517
|
+
upgrade: upgradeOf(view.billing, adminUrl)
|
|
518
|
+
}
|
|
499
519
|
});
|
|
500
520
|
}
|
|
501
521
|
function movedExit(fields) {
|
|
@@ -573,14 +593,15 @@ async function waitPublished(session, first, onStopped) {
|
|
|
573
593
|
function stoppedKinds(view) {
|
|
574
594
|
return view.events.failing.filter((event) => event.stopped).map((event) => event.kind);
|
|
575
595
|
}
|
|
576
|
-
var CHOOSE_PLAN_HINT, CHOOSE_PLAN_BILLING_HINT, CONTACT_HINT, INIT_FIRST_HINT, CLOCK_HINT, UNAUTHORIZED_HINTS, MOVED_HINT;
|
|
596
|
+
var CHOOSE_PLAN_HINT, PAID_CHECKOUT, CHOOSE_PLAN_BILLING_HINT, CONTACT_HINT, INIT_FIRST_HINT, CLOCK_HINT, UNAUTHORIZED_HINTS, MOVED_HINT;
|
|
577
597
|
var init_store = __esm({
|
|
578
598
|
"src/commands/askr/store.ts"() {
|
|
579
599
|
init_constants();
|
|
580
600
|
init_errors();
|
|
581
601
|
init_owner_key();
|
|
582
602
|
CHOOSE_PLAN_HINT = "choose a plan: askr plan free (only if the human chose Free), or message us with your Store ID for a paid plan";
|
|
583
|
-
|
|
603
|
+
PAID_CHECKOUT = "askr plan <starter|growth|pro|scale> [--yearly] for the paid plan the human chose, then give them its checkoutUrl to pay";
|
|
604
|
+
CHOOSE_PLAN_BILLING_HINT = `choose a plan: askr plan free (only if the human chose Free), or ${PAID_CHECKOUT}`;
|
|
584
605
|
CONTACT_HINT = `message us with your Store ID: ${CONTACT_URL}`;
|
|
585
606
|
INIT_FIRST_HINT = "run askr init first";
|
|
586
607
|
CLOCK_HINT = "check this computer's clock: it is off by more than a minute";
|
|
@@ -1269,14 +1290,14 @@ async function runInit(session, options) {
|
|
|
1269
1290
|
adminUrl: session.adminUrl
|
|
1270
1291
|
};
|
|
1271
1292
|
if (awaitingPlan) {
|
|
1272
|
-
output.next = NEXT_PLAN;
|
|
1273
|
-
output.upgrade =
|
|
1293
|
+
output.next = view.billing?.checkoutAvailable === true ? NEXT_PLAN_BILLING : NEXT_PLAN;
|
|
1294
|
+
output.upgrade = upgradeOf(view.billing, session.adminUrl);
|
|
1274
1295
|
} else if (view.status !== "active") {
|
|
1275
1296
|
output.hint = CONTACT_HINT;
|
|
1276
1297
|
}
|
|
1277
1298
|
return { exitCode: EXIT.OK, output };
|
|
1278
1299
|
}
|
|
1279
|
-
var DEFAULT_LANGUAGE, DEFAULT_CURRENCY, LANGUAGE_RE, CURRENCY_RE, SCHEME_RE, BARE_HOST_RE, MAX_URL_CHARS, NEXT_PLAN, STOPPED_HINT;
|
|
1300
|
+
var DEFAULT_LANGUAGE, DEFAULT_CURRENCY, LANGUAGE_RE, CURRENCY_RE, SCHEME_RE, BARE_HOST_RE, MAX_URL_CHARS, NEXT_PLAN, NEXT_PLAN_BILLING, STOPPED_HINT;
|
|
1280
1301
|
var init_init = __esm({
|
|
1281
1302
|
"src/commands/askr/init.ts"() {
|
|
1282
1303
|
init_constants();
|
|
@@ -1294,6 +1315,7 @@ var init_init = __esm({
|
|
|
1294
1315
|
BARE_HOST_RE = /^[^\s/:]+\.[^\s/:]+(?::\d+)?(?:\/.*)?$/u;
|
|
1295
1316
|
MAX_URL_CHARS = 2048;
|
|
1296
1317
|
NEXT_PLAN = `choose a plan: Free via askr plan free, only if the human chose Free; a paid plan: message us at ${CONTACT_URL} with your Store ID and the name of the plan the human chose`;
|
|
1318
|
+
NEXT_PLAN_BILLING = `choose a plan: Free via askr plan free, only if the human chose Free; a paid plan: ${PAID_CHECKOUT}`;
|
|
1297
1319
|
STOPPED_HINT = "report this to us with your Store ID";
|
|
1298
1320
|
}
|
|
1299
1321
|
});
|
|
@@ -1574,7 +1596,7 @@ async function runProducts(session, options) {
|
|
|
1574
1596
|
const view = await readView(session);
|
|
1575
1597
|
const localDryRun = options.dryRun === true && view.status === "pending";
|
|
1576
1598
|
if (view.status !== "active" && !localDryRun) {
|
|
1577
|
-
throw inactiveExit(view);
|
|
1599
|
+
throw inactiveExit(view, session.adminUrl);
|
|
1578
1600
|
}
|
|
1579
1601
|
const { config } = await readSigned(session, key.owner, key.secretKey);
|
|
1580
1602
|
if (config === void 0) {
|
|
@@ -1741,7 +1763,10 @@ var init_products = __esm({
|
|
|
1741
1763
|
case "too_many_products":
|
|
1742
1764
|
return new AskrExit(EXIT.LIMIT, "too_many_products", {
|
|
1743
1765
|
hint: "more products than the store's plan allows",
|
|
1744
|
-
fields: {
|
|
1766
|
+
fields: {
|
|
1767
|
+
max: result.detail.max,
|
|
1768
|
+
upgrade: upgradeOf(this.view.billing, this.session.adminUrl)
|
|
1769
|
+
}
|
|
1745
1770
|
});
|
|
1746
1771
|
case "invalid_items":
|
|
1747
1772
|
return new AskrExit(EXIT.BAD_INPUT, "invalid_items", {
|
|
@@ -1750,7 +1775,7 @@ var init_products = __esm({
|
|
|
1750
1775
|
}
|
|
1751
1776
|
});
|
|
1752
1777
|
case "inactive":
|
|
1753
|
-
return inactiveExit(this.view);
|
|
1778
|
+
return inactiveExit(this.view, this.session.adminUrl);
|
|
1754
1779
|
case "bad_request":
|
|
1755
1780
|
return new AskrExit(EXIT.BAD_INPUT, "bad_request", {
|
|
1756
1781
|
...typeof result.detail.message === "string" ? { message: result.detail.message } : {}
|
|
@@ -1847,7 +1872,7 @@ async function runPolicy(session, options) {
|
|
|
1847
1872
|
const key = await useOwnerKey(session);
|
|
1848
1873
|
const view = await readView(session);
|
|
1849
1874
|
if (view.status !== "active") {
|
|
1850
|
-
throw inactiveExit(view);
|
|
1875
|
+
throw inactiveExit(view, session.adminUrl);
|
|
1851
1876
|
}
|
|
1852
1877
|
const { config } = await readSigned(session, key.owner, key.secretKey);
|
|
1853
1878
|
if (config === void 0) {
|
|
@@ -1897,7 +1922,7 @@ async function runPolicy(session, options) {
|
|
|
1897
1922
|
hint: "a store has at most 50 policies: remove one in the admin"
|
|
1898
1923
|
});
|
|
1899
1924
|
case "inactive":
|
|
1900
|
-
throw inactiveExit(view);
|
|
1925
|
+
throw inactiveExit(view, session.adminUrl);
|
|
1901
1926
|
case "bad_request":
|
|
1902
1927
|
throw new AskrExit(EXIT.BAD_INPUT, "bad_request");
|
|
1903
1928
|
default:
|
|
@@ -1962,7 +1987,7 @@ var connector_exports = {};
|
|
|
1962
1987
|
__export(connector_exports, {
|
|
1963
1988
|
runConnector: () => runConnector
|
|
1964
1989
|
});
|
|
1965
|
-
function resultExit(summary, detail) {
|
|
1990
|
+
function resultExit(summary, detail, upgrade) {
|
|
1966
1991
|
if (summary.status === "ok") {
|
|
1967
1992
|
return void 0;
|
|
1968
1993
|
}
|
|
@@ -1975,7 +2000,7 @@ function resultExit(summary, detail) {
|
|
|
1975
2000
|
if (summary.reason === "too_many_products") {
|
|
1976
2001
|
return new AskrExit(EXIT.LIMIT, "too_many_products", {
|
|
1977
2002
|
hint: "the shop has more products than the store's plan allows",
|
|
1978
|
-
fields: { count: summary.count, max: summary.max, upgrade
|
|
2003
|
+
fields: { count: summary.count, max: summary.max, upgrade }
|
|
1979
2004
|
});
|
|
1980
2005
|
}
|
|
1981
2006
|
if (summary.status === "source_closed") {
|
|
@@ -2027,7 +2052,7 @@ function noConnectorExit() {
|
|
|
2027
2052
|
}
|
|
2028
2053
|
function actionRefusal(session, view, result) {
|
|
2029
2054
|
if (!result.ok && result.code === "inactive") {
|
|
2030
|
-
return inactiveExit(view);
|
|
2055
|
+
return inactiveExit(view, session.adminUrl);
|
|
2031
2056
|
}
|
|
2032
2057
|
if (!result.ok && result.code === "no_connector") {
|
|
2033
2058
|
return noConnectorExit();
|
|
@@ -2038,7 +2063,7 @@ async function runConnector(session) {
|
|
|
2038
2063
|
const key = await useOwnerKey(session);
|
|
2039
2064
|
const view = await readView(session);
|
|
2040
2065
|
if (view.status !== "active" || view.tier === null) {
|
|
2041
|
-
throw inactiveExit(view);
|
|
2066
|
+
throw inactiveExit(view, session.adminUrl);
|
|
2042
2067
|
}
|
|
2043
2068
|
const connector = view.connector;
|
|
2044
2069
|
if (connector === null) {
|
|
@@ -2068,7 +2093,8 @@ async function runConnector(session) {
|
|
|
2068
2093
|
if (previewed === null) {
|
|
2069
2094
|
throw new AskrExit(EXIT.REFUSED, "unexpected");
|
|
2070
2095
|
}
|
|
2071
|
-
const
|
|
2096
|
+
const upgrade = upgradeOf(view.billing, session.adminUrl);
|
|
2097
|
+
const previewExit = resultExit(previewed, failuresOf(preview.body.result), upgrade);
|
|
2072
2098
|
if (previewExit !== void 0) {
|
|
2073
2099
|
throw previewExit;
|
|
2074
2100
|
}
|
|
@@ -2099,7 +2125,7 @@ async function runConnector(session) {
|
|
|
2099
2125
|
fields: { retryAfterSeconds: 60 }
|
|
2100
2126
|
});
|
|
2101
2127
|
}
|
|
2102
|
-
const runExit = run === null ? void 0 : resultExit(run, failuresOf(current.lastStatus));
|
|
2128
|
+
const runExit = run === null ? void 0 : resultExit(run, failuresOf(current.lastStatus), upgrade);
|
|
2103
2129
|
if (runExit !== void 0) {
|
|
2104
2130
|
throw runExit;
|
|
2105
2131
|
}
|
|
@@ -2318,7 +2344,7 @@ async function runStatus(session, options) {
|
|
|
2318
2344
|
billing: billingOf(view),
|
|
2319
2345
|
ownerKeyFile: key.path,
|
|
2320
2346
|
adminUrl: session.adminUrl,
|
|
2321
|
-
upgrade:
|
|
2347
|
+
upgrade: upgradeOf(view.billing, session.adminUrl)
|
|
2322
2348
|
};
|
|
2323
2349
|
if (view.status !== "active") {
|
|
2324
2350
|
output.hint = planHintOf(view);
|
|
@@ -2349,7 +2375,7 @@ var init_status = __esm({
|
|
|
2349
2375
|
init_owner_key();
|
|
2350
2376
|
init_read();
|
|
2351
2377
|
init_store();
|
|
2352
|
-
BUDGET_HINT = "the store reached its plan's monthly limit, so the chat does not answer until the plan is upgraded or the next month starts: to upgrade,
|
|
2378
|
+
BUDGET_HINT = "the store reached its plan's monthly limit, so the chat does not answer until the plan is upgraded or the next month starts: to upgrade, follow upgrade.howTo";
|
|
2353
2379
|
}
|
|
2354
2380
|
});
|
|
2355
2381
|
function storeLlmsTxtUrl(npub) {
|