kenso 0.1.13 → 0.1.16
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/kenso.js +19 -12
- package/dist/operations.json +1 -1
- package/docs/reference.md +4 -4
- package/docs/studio.md +1 -1
- package/package.json +2 -2
package/dist/kenso.js
CHANGED
|
@@ -2397,7 +2397,7 @@ var VERSION;
|
|
|
2397
2397
|
var init_version = __esm({
|
|
2398
2398
|
"src/core/version.ts"() {
|
|
2399
2399
|
"use strict";
|
|
2400
|
-
VERSION = true ? "0.1.
|
|
2400
|
+
VERSION = true ? "0.1.16" : "0.0.0-dev";
|
|
2401
2401
|
}
|
|
2402
2402
|
});
|
|
2403
2403
|
|
|
@@ -8395,10 +8395,10 @@ async function readCampaign(ctx, campaignId) {
|
|
|
8395
8395
|
const channel = isRecord4(campaign) && typeof campaign.channel === "string" ? campaign.channel.toLowerCase() : "";
|
|
8396
8396
|
return { linkedInOnly: LINKEDIN_ONLY_CHANNELS.has(channel) ? true : void 0 };
|
|
8397
8397
|
}
|
|
8398
|
-
async function estimate(ctx,
|
|
8398
|
+
async function estimate(ctx, leadCount) {
|
|
8399
8399
|
if (leadCount === 0) return { estimate: null };
|
|
8400
8400
|
try {
|
|
8401
|
-
const res = await ctx.client.request({ method: "POST", path: "/v1/credits/estimates", body: { kind: "leads", leadCount
|
|
8401
|
+
const res = await ctx.client.request({ method: "POST", path: "/v1/credits/estimates", body: { kind: "leads", leadCount } });
|
|
8402
8402
|
const data = unwrap(res.body);
|
|
8403
8403
|
if (!isRecord4(data)) return { estimate: data ?? null };
|
|
8404
8404
|
const credits = (key) => typeof data[key] === "number" ? data[key] / 1e3 : void 0;
|
|
@@ -8502,7 +8502,7 @@ var init_import2 = __esm({
|
|
|
8502
8502
|
...Object.keys(mapping.dropped).length > 0 ? { droppedColumns: mapping.dropped } : {},
|
|
8503
8503
|
...emailLess > 0 ? { emailLessRows: emailLess } : {}
|
|
8504
8504
|
};
|
|
8505
|
-
if (dryRun2) Object.assign(dryRunExtra, await estimate(ctx,
|
|
8505
|
+
if (dryRun2) Object.assign(dryRunExtra, await estimate(ctx, items.length));
|
|
8506
8506
|
const outcome = await runBatch(
|
|
8507
8507
|
{
|
|
8508
8508
|
command: "contacts import",
|
|
@@ -9501,7 +9501,7 @@ var init_README = __esm({
|
|
|
9501
9501
|
var studio_default;
|
|
9502
9502
|
var init_studio = __esm({
|
|
9503
9503
|
"docs/studio.md"() {
|
|
9504
|
-
studio_default = "# Studio (beta)\n\nStudio templates are the pages, docs and other assets Kenso builds for each account or lead. The `kenso studio` commands let you edit a template as a folder of files on your machine, check it, preview it, and fill it for many accounts or leads at once. They are beta: they need the `studio` feature flag on your workspace. Help and `kenso describe` hide them until your workspace has it; `--all-commands` shows them.\n\n| Command | What it does |\n|---|---|\n| `studio pull <templateId> --dir <dir>` | Write a template version's files to a folder |\n| `studio push <templateId> --dir <dir>` | Save the folder's files to the template's draft and print the validation |\n| `studio validate <templateId> --dir <dir>` | Validate the folder against the template without saving |\n| `studio preview <templateId>` | Render a version for up to 3 accounts and print the preview links |\n| `studio fill <templateId>` | Fill the template for many accounts or campaign leads, estimate first |\n\nFind template ids with the generated commands:\n\n```bash\nkenso asset-templates list\n```\n\n## Edit a template locally\n\n```bash\nkenso studio pull 12 --dir ./my-template\nkenso studio validate 12 --dir ./my-template\nkenso studio push 12 --dir ./my-template\nkenso studio preview 12 --dir ./my-template --account-ids 501,502\nkenso studio push 12 --dir ./my-template --publish\n```\n\n### pull\n\n`pull` writes every file of the version under `--dir`: text files from the answer, binaries downloaded from signed links and checked against their SHA-256. It overwrites files with the same path and leaves other files in the folder alone. It checks every path before it writes anything, and refuses one that would land outside `--dir` (`unsafe_path`).\n\n`--template-version` picks the version: `draft`, `latest` (the latest published) or a version id. The default is the draft, else the latest published version. (The flag is not `--version
|
|
9504
|
+
studio_default = "# Studio (beta)\n\nStudio templates are the pages, docs and other assets Kenso builds for each account or lead. The `kenso studio` commands let you edit a template as a folder of files on your machine, check it, preview it, and fill it for many accounts or leads at once. They are beta: they need the `studio` feature flag on your workspace. Help and `kenso describe` hide them until your workspace has it; `--all-commands` shows them.\n\n| Command | What it does |\n|---|---|\n| `studio pull <templateId> --dir <dir>` | Write a template version's files to a folder |\n| `studio push <templateId> --dir <dir>` | Save the folder's files to the template's draft and print the validation |\n| `studio validate <templateId> --dir <dir>` | Validate the folder against the template without saving |\n| `studio preview <templateId>` | Render a version for up to 3 accounts and print the preview links |\n| `studio fill <templateId>` | Fill the template for many accounts or campaign leads, estimate first |\n\nFind template ids with the generated commands:\n\n```bash\nkenso asset-templates list\n```\n\n## Edit a template locally\n\n```bash\nkenso studio pull 12 --dir ./my-template\nkenso studio validate 12 --dir ./my-template\nkenso studio push 12 --dir ./my-template\nkenso studio preview 12 --dir ./my-template --account-ids 501,502\nkenso studio push 12 --dir ./my-template --publish\n```\n\n### pull\n\n`pull` writes every file of the version under `--dir`: text files from the answer, binaries downloaded from signed links and checked against their SHA-256. It overwrites files with the same path and leaves other files in the folder alone. It checks every path before it writes anything, and refuses one that would land outside `--dir` (`unsafe_path`).\n\n`--template-version` picks the version: `draft`, `latest` (the latest published) or a version id. The default is the draft, else the latest published version. (The flag is not `--version`: after a command, `--version` fails with `unknown_flag` and points at `--template-version`.)\n\n```bash\nkenso studio pull 12 --dir ./v3 --template-version 345\nkenso studio pull 12 --dir ./my-template --dry-run\n```\n\nIt prints `{templateId, versionId, files, dir}`. `--dry-run` lists the paths and writes nothing.\n\n### push\n\n`push` reads `--dir`, skipping dotfiles, dot folders and `node_modules`.\n\n- A text file (valid UTF-8, no NUL byte, under 1 MB) goes inline.\n- Any other file is uploaded through a signed upload URL first, 4 at a time, up to 5 MB each. A larger file is refused before any call.\n- One push then saves the files into the draft and prints `{templateId, versionId, versionNumber, validation, changed, deleted}`.\n\nFiles that are in the draft but not in the folder stay, unless you pass `--delete-missing`. `--message` describes the change (default \"Pushed with the Kenso CLI\"). With `--publish`, the new version is published when validation passes, and the output adds `published`.\n\n```bash\nkenso studio push 12 --dir ./my-template --message \"New hero copy\"\nkenso studio push 12 --dir ./my-template --delete-missing --publish\nkenso studio push 12 --dir ./my-template --dry-run\n```\n\nWhen validation finds errors, the draft is still saved: the result prints, then the error `validation_failed` (exit 2) with the first problem as its `hint`. When publishing fails after a good push, the push result still prints and the error says which version was saved. `--dry-run` lists what would be sent and calls nothing.\n\n### validate\n\n`validate` reads the folder the same way and checks the files laid over the draft, as a push would, without saving them. Binaries are uploaded so they can be checked. `--delete-missing` validates exactly the folder's files. It prints the validation and exits 2 when there are errors.\n\n### preview\n\n`preview` renders a saved version, not your local files: the draft, else the latest published version, or `--version-id`. It takes up to a minute per account.\n\n```bash\nkenso studio preview 12\nkenso studio preview 12 --account-ids 501,502,503 --mode render\nkenso studio preview 12 --sample samples/acme.json\nkenso studio preview 12 --mode interact --interact @steps.json\n```\n\n- `--account-ids` takes up to 3 ids. Without it, Kenso picks the 3 most recently touched accounts, else the template's samples.\n- `--mode` is `render` (default) or `interact`. `--interact` takes the click, type and wait steps as JSON, `@file` or `-` (up to 20).\n- With `--dir`, the CLI compares your folder to the version it renders and warns on stderr when they differ, naming the push command to run first.\n\nThe output lists each preview's link, screenshots, console errors and link issues.\n\n## Fill a template for many accounts or leads\n\n`fill` creates pages for a list of accounts, or for the leads of a campaign. A fill is charged per page, so it always prices the work first.\n\n```bash\nkenso studio fill 12 --accounts accounts.txt\nkenso studio fill 12 --accounts accounts.csv --column accountId --yes --wait\nkenso studio fill 12 --campaign 345 --contacts leads.csv --yes\n```\n\n- **Ids** come from `--accounts <file>`, or from `--contacts <file>` with `--campaign <id>`; `-` reads stdin. A file holds one id per line, or a CSV or JSONL with an id column (`--column`, else `id`, else `contactId`). Repeated ids are filled once.\n- **Without `--yes`** (or with `--estimate`) it prints the estimate and the apply command, and creates nothing. For a campaign, the estimate counts one page per lead; Kenso builds one page per company, so it is an upper bound.\n- **With `--yes`** it creates one fill run per 500 ids, one after another.\n- **With `--wait`** it follows each run every 5 seconds until it completes, fails or is cancelled. Without it, follow a run with `kenso asset-runs get --run-id <id>`.\n\nThe summary lists `runs: [{runId, state, rows}]`, and `results.csv` has one line per id with its page id and state.\n\n**The same fill never runs twice.** Rebuilding a page charges again, so when you rerun a fill with the same file (the same bytes) and the same flags:\n\n- an unfinished fill continues where it stopped;\n- a finished fill where every id succeeded answers from that run and changes nothing;\n- anything else is refused with `already_filled` (exit 7). To retry only the ids that failed, take them from the earlier run's `results.csv` into a new file and fill that file.\n\nThe guard compares the file and the flags, not the ids: the same ids in another file, or in another order, are filled and charged again. Keep one ids file per fill, and check `kenso runs list` before you fill ids from a new file.\n\n## Other Studio commands\n\nEverything else (create a template, list versions, restore a version, datasets, publish) is a generated command under `asset-templates`, `asset-runs` and `asset-template-datasets`:\n\n```bash\nkenso asset-templates --help --all-commands\nkenso describe asset-templates\n```\n";
|
|
9505
9505
|
}
|
|
9506
9506
|
});
|
|
9507
9507
|
|
|
@@ -11892,7 +11892,7 @@ var init_help = __esm({
|
|
|
11892
11892
|
["--progress", "Print progress to stderr even when it is not a terminal"],
|
|
11893
11893
|
["--all-commands", "Show beta commands in help"],
|
|
11894
11894
|
["-h, --help", "Show help"],
|
|
11895
|
-
["--version", "Print the version"]
|
|
11895
|
+
["--version", "Print the CLI version (only on its own: kenso --version)"]
|
|
11896
11896
|
];
|
|
11897
11897
|
GLOBAL_FLAGS_LINE = "Global flags: --dry-run, -y/--yes, --workspace <id>, --profile, -o/--output json|ndjson|table|ids, --fields, --query, -v, --progress (kenso --help --all-commands explains them).";
|
|
11898
11898
|
COMMON_RESOURCES = [
|
|
@@ -12042,6 +12042,11 @@ async function unknownCommand(tokens, resource) {
|
|
|
12042
12042
|
next: "kenso --help"
|
|
12043
12043
|
});
|
|
12044
12044
|
}
|
|
12045
|
+
function versionHint(spec) {
|
|
12046
|
+
const own = Object.keys(spec.flags).filter((name) => name.includes("version") && !name.startsWith("no-"));
|
|
12047
|
+
const cli = "--version prints the CLI version, and only on its own: kenso --version.";
|
|
12048
|
+
return own.length > 0 ? `did you mean ${own.map((name) => `--${name}`).join(" or ")}? ${cli}` : cli;
|
|
12049
|
+
}
|
|
12045
12050
|
function flagError(err, spec) {
|
|
12046
12051
|
const name = commandName(spec);
|
|
12047
12052
|
const code = err.code;
|
|
@@ -12049,21 +12054,21 @@ function flagError(err, spec) {
|
|
|
12049
12054
|
if (code === "ERR_PARSE_ARGS_UNKNOWN_OPTION") {
|
|
12050
12055
|
const flag = /'(-{1,2}[^']+)'/.exec(message)?.[1] ?? "";
|
|
12051
12056
|
const bare = flag.replace(/^-+/, "").split("=")[0];
|
|
12052
|
-
const suggestion = closest(bare, [...Object.keys(spec.flags), ...Object.keys(
|
|
12057
|
+
const suggestion = closest(bare, [...Object.keys(spec.flags), ...Object.keys(COMMAND_GLOBAL_OPTIONS)]);
|
|
12053
12058
|
return new KensoError({
|
|
12054
12059
|
code: "unknown_flag",
|
|
12055
12060
|
message: `Unknown flag ${flag} for ${name}.`,
|
|
12056
12061
|
exitCode: ExitCode.Usage,
|
|
12057
12062
|
field: bare || void 0,
|
|
12058
|
-
hint: suggestion ? `did you mean --${suggestion}?` : `Run ${name} --help to list its flags.`,
|
|
12063
|
+
hint: bare === "version" ? versionHint(spec) : suggestion ? `did you mean --${suggestion}?` : `Run ${name} --help to list its flags.`,
|
|
12059
12064
|
next: `${name} --help`
|
|
12060
12065
|
});
|
|
12061
12066
|
}
|
|
12062
12067
|
return new KensoError({ code: "invalid_flag", message: `${message} (${name}).`, exitCode: ExitCode.Usage, next: `${name} --help` });
|
|
12063
12068
|
}
|
|
12064
12069
|
function strictParse(argv, spec) {
|
|
12065
|
-
const options = { ...
|
|
12066
|
-
const booleans = new Set(
|
|
12070
|
+
const options = { ...COMMAND_GLOBAL_OPTIONS };
|
|
12071
|
+
const booleans = new Set(COMMAND_GLOBAL_BOOLEANS);
|
|
12067
12072
|
for (const [name, flag] of Object.entries(spec.flags)) {
|
|
12068
12073
|
const option = { type: flag.type };
|
|
12069
12074
|
if (flag.short) option.short = flag.short;
|
|
@@ -12161,7 +12166,7 @@ async function main(argv, env = process.env, overrides = {}) {
|
|
|
12161
12166
|
let verbose = false;
|
|
12162
12167
|
try {
|
|
12163
12168
|
const loose = parseArgs({ args: normalizeBooleans(argv, new Set(GLOBAL_BOOLEANS), void 0), options: GLOBAL_OPTIONS, strict: false, allowPositionals: true });
|
|
12164
|
-
if (loose.values.version === true) {
|
|
12169
|
+
if (loose.values.version === true && loose.positionals.length === 0) {
|
|
12165
12170
|
stdout.write(`${VERSION}
|
|
12166
12171
|
`);
|
|
12167
12172
|
return ExitCode.Ok;
|
|
@@ -12255,7 +12260,7 @@ function invokedDirectly() {
|
|
|
12255
12260
|
return false;
|
|
12256
12261
|
}
|
|
12257
12262
|
}
|
|
12258
|
-
var GLOBAL_OPTIONS, INTERRUPT_GRACE_MS, GLOBAL_BOOLEANS, activeRuns, sigintCount, lookupFailed, LINGERING_REQUEST_GRACE_MS, guardedStreams;
|
|
12263
|
+
var GLOBAL_OPTIONS, INTERRUPT_GRACE_MS, GLOBAL_BOOLEANS, COMMAND_GLOBAL_OPTIONS, COMMAND_GLOBAL_BOOLEANS, activeRuns, sigintCount, lookupFailed, LINGERING_REQUEST_GRACE_MS, guardedStreams;
|
|
12259
12264
|
var init_main = __esm({
|
|
12260
12265
|
"src/main.ts"() {
|
|
12261
12266
|
init_generated_hook();
|
|
@@ -12284,6 +12289,8 @@ var init_main = __esm({
|
|
|
12284
12289
|
};
|
|
12285
12290
|
INTERRUPT_GRACE_MS = 3e3;
|
|
12286
12291
|
GLOBAL_BOOLEANS = Object.entries(GLOBAL_OPTIONS).filter(([, option]) => option.type === "boolean").map(([name]) => name);
|
|
12292
|
+
COMMAND_GLOBAL_OPTIONS = Object.fromEntries(Object.entries(GLOBAL_OPTIONS).filter(([name]) => name !== "version"));
|
|
12293
|
+
COMMAND_GLOBAL_BOOLEANS = GLOBAL_BOOLEANS.filter((name) => name !== "version");
|
|
12287
12294
|
activeRuns = [];
|
|
12288
12295
|
sigintCount = 0;
|
|
12289
12296
|
lookupFailed = false;
|