@myapihq/cli 2.26.1 → 2.27.0
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.
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
// `funnel push` overwrites whatever is live at the target, and nothing could
|
|
2
|
+
// tell you what that was.
|
|
3
|
+
//
|
|
4
|
+
// `funnel pages` listed paths only. The API has supported ?include_content=true
|
|
5
|
+
// all along; no client ever sent it. So an agent asked to change one section of
|
|
6
|
+
// a published page had two options: regenerate the whole page from scratch, or
|
|
7
|
+
// scrape the public URL and hope. Every funnel edit was a blind write.
|
|
8
|
+
//
|
|
9
|
+
// Found by asking the reverse-coverage question of QUERY parameters rather than
|
|
10
|
+
// request bodies — the direction the request-field linter documents as out of
|
|
11
|
+
// scope, and the same blind spot that hid `?confirm=` on org delete.
|
|
12
|
+
import { describe, it, expect, vi, beforeEach, afterEach } from 'vitest';
|
|
13
|
+
const ORG = '11111111-1111-4111-8111-111111111111';
|
|
14
|
+
const FUNNEL = 'f1';
|
|
15
|
+
const sdk = vi.hoisted(() => ({
|
|
16
|
+
funnel: { listFunnelPages: vi.fn() },
|
|
17
|
+
hq: { listOrgs: vi.fn() },
|
|
18
|
+
}));
|
|
19
|
+
vi.mock('@myapihq/sdk', () => sdk);
|
|
20
|
+
vi.mock('../config.js', () => ({
|
|
21
|
+
requireConfig: () => ({ api_key: 'hq_live_test', default_org: ORG, default_funnel: FUNNEL }),
|
|
22
|
+
loadConfig: () => ({ api_key: 'hq_live_test', default_org: ORG, default_funnel: FUNNEL }),
|
|
23
|
+
CONFIG_DIR: '/tmp/nowhere',
|
|
24
|
+
}));
|
|
25
|
+
let printed;
|
|
26
|
+
beforeEach(async () => {
|
|
27
|
+
printed = [];
|
|
28
|
+
vi.clearAllMocks();
|
|
29
|
+
const output = await import('../output.js');
|
|
30
|
+
const cap = ((m) => { printed.push(typeof m === 'string' ? m : JSON.stringify(m)); });
|
|
31
|
+
vi.spyOn(output, 'info').mockImplementation(cap);
|
|
32
|
+
vi.spyOn(output, 'printJson').mockImplementation(cap);
|
|
33
|
+
vi.spyOn(output, 'printTable').mockImplementation(cap);
|
|
34
|
+
vi.spyOn(output, 'banner').mockImplementation(() => { });
|
|
35
|
+
vi.spyOn(output, 'error').mockImplementation(((m) => {
|
|
36
|
+
printed.push(String(m));
|
|
37
|
+
throw new Error('__EXIT__');
|
|
38
|
+
}));
|
|
39
|
+
});
|
|
40
|
+
afterEach(() => vi.restoreAllMocks());
|
|
41
|
+
async function run(flags) {
|
|
42
|
+
const { pages } = await import('./funnel.js');
|
|
43
|
+
try {
|
|
44
|
+
await pages(FUNNEL, flags);
|
|
45
|
+
}
|
|
46
|
+
catch (e) {
|
|
47
|
+
if (e?.message !== '__EXIT__')
|
|
48
|
+
throw e;
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
describe('funnel pages --with-content', () => {
|
|
52
|
+
it('asks the API for content, so an edit can read before it writes', async () => {
|
|
53
|
+
sdk.funnel.listFunnelPages.mockResolvedValue([{ slug: '/', content: '<h1>live</h1>' }]);
|
|
54
|
+
await run({ 'with-content': true, json: true });
|
|
55
|
+
expect(sdk.funnel.listFunnelPages).toHaveBeenCalledWith('hq_live_test', ORG, FUNNEL, { includeContent: true });
|
|
56
|
+
});
|
|
57
|
+
it('does not ask for it otherwise — listing paths must stay cheap', async () => {
|
|
58
|
+
sdk.funnel.listFunnelPages.mockResolvedValue([{ slug: '/' }]);
|
|
59
|
+
await run({ json: true });
|
|
60
|
+
expect(sdk.funnel.listFunnelPages).toHaveBeenCalledWith('hq_live_test', ORG, FUNNEL, undefined);
|
|
61
|
+
});
|
|
62
|
+
it('puts the content in --json, which is what an agent reads', async () => {
|
|
63
|
+
sdk.funnel.listFunnelPages.mockResolvedValue([{ slug: '/', content: '<h1>live</h1>' }]);
|
|
64
|
+
await run({ 'with-content': true, json: true });
|
|
65
|
+
expect(printed.join('\n')).toContain('<h1>live</h1>');
|
|
66
|
+
});
|
|
67
|
+
it('keeps HTML out of the human view, showing sizes instead', async () => {
|
|
68
|
+
// Six pages of markup in a terminal buries the thing being looked for.
|
|
69
|
+
sdk.funnel.listFunnelPages.mockResolvedValue([{ slug: '/', content: '<h1>live</h1>' }]);
|
|
70
|
+
await run({ 'with-content': true });
|
|
71
|
+
const out = printed.join('\n');
|
|
72
|
+
expect(out).not.toContain('<h1>live</h1>');
|
|
73
|
+
expect(out).toContain('13');
|
|
74
|
+
});
|
|
75
|
+
});
|
package/dist/commands/funnel.js
CHANGED
|
@@ -28,6 +28,8 @@ export const SCHEMA = {
|
|
|
28
28
|
slug: 'string',
|
|
29
29
|
env: 'string',
|
|
30
30
|
force: 'boolean',
|
|
31
|
+
// \`funnel pages --with-content\` — read what is live before overwriting it.
|
|
32
|
+
'with-content': 'boolean',
|
|
31
33
|
'api-fn': 'string',
|
|
32
34
|
// form
|
|
33
35
|
fields: 'string',
|
|
@@ -214,7 +216,11 @@ export async function pages(funnelArg, flags) {
|
|
|
214
216
|
const funnelId = funnelArg || flags.funnel || config.default_funnel;
|
|
215
217
|
if (!funnelId)
|
|
216
218
|
error('Missing funnel id. Pass it as a positional arg, --funnel <id>, or set: myapi config set-funnel <id>');
|
|
217
|
-
|
|
219
|
+
// --with-content is what makes an edit a read-then-write instead of a blind
|
|
220
|
+
// overwrite. `funnel push` replaces whatever is live at the target, and until
|
|
221
|
+
// now nothing could tell you what that was: an agent asked to change one
|
|
222
|
+
// section had to regenerate the whole page or scrape the public URL.
|
|
223
|
+
const list = await sdkFunnel.listFunnelPages(config.api_key, orgId, funnelId, flags['with-content'] ? { includeContent: true } : undefined);
|
|
218
224
|
// An empty inventory is not proof the funnel is empty. Verified 2026-07-28:
|
|
219
225
|
// a funnel answering 200 with real content on both its subdomain and a bound
|
|
220
226
|
// custom domain reported `{"pages":[]}`. Someone auditing what is deployed
|
|
@@ -244,10 +250,21 @@ export async function pages(funnelArg, flags) {
|
|
|
244
250
|
printJson(list);
|
|
245
251
|
return;
|
|
246
252
|
}
|
|
247
|
-
|
|
253
|
+
// Human output never dumps the content — six pages of HTML in a terminal
|
|
254
|
+
// buries the thing being looked for. The size is the useful summary; --json
|
|
255
|
+
// carries the content itself, which is the shape an agent reads anyway.
|
|
256
|
+
printTable(flags['with-content']
|
|
257
|
+
? list.map(p => ({
|
|
258
|
+
slug: p.slug,
|
|
259
|
+
bytes: typeof p.content === 'string' ? p.content.length : '—',
|
|
260
|
+
updated_at: p.updated_at ?? '',
|
|
261
|
+
}))
|
|
262
|
+
: list, {
|
|
248
263
|
flags,
|
|
249
264
|
empty: 'No pages published to this funnel yet. Push one with: echo "<h1>Hello</h1>" | myapi funnel push /',
|
|
250
265
|
});
|
|
266
|
+
if (flags['with-content'])
|
|
267
|
+
info(' Content is in --json; this view shows sizes so a terminal is not flooded.');
|
|
251
268
|
}
|
|
252
269
|
export async function push(slug, flags) {
|
|
253
270
|
const config = requireConfig();
|
|
@@ -660,7 +677,11 @@ future platform features (rate-limit, captcha, field validation) for
|
|
|
660
677
|
free.`,
|
|
661
678
|
'get': 'myapi funnel get <id> [--org <id>] [--json]',
|
|
662
679
|
'list': 'myapi funnel list [--org <id>] [--json]',
|
|
663
|
-
'pages':
|
|
680
|
+
'pages': `myapi funnel pages [funnel_id] [--funnel <id>] [--with-content] [--org <id>] [--json]
|
|
681
|
+
|
|
682
|
+
Lists what is published. --with-content also fetches each page's live content, which
|
|
683
|
+
is how you read a page before overwriting it — \`funnel push\` replaces whatever
|
|
684
|
+
is there. Human output shows sizes; --json carries the content.`,
|
|
664
685
|
'publish': `myapi funnel publish <dir> [--funnel <id>] [--env dev|prod] [--api-fn <id>] [--force] [--org <id>]
|
|
665
686
|
|
|
666
687
|
Uploads a whole local directory as the funnel's site. Each file's path
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
---
|
|
2
2
|
name: my-funnel-api
|
|
3
|
-
version: 1.0.
|
|
3
|
+
version: 1.0.1
|
|
4
4
|
description: >
|
|
5
5
|
Create and publish websites (funnels) to the edge. Push raw HTML to any slug and it goes live instantly on your org's domain or preview subdomain.
|
|
6
6
|
triggers: [funnel, landing page, website, page, publish, push, slug, html, edge, preview subdomain, makeautonomous]
|
|
7
|
-
checksum: sha256-
|
|
7
|
+
checksum: sha256-7bcaeef9bd17839aa28c62a8e39f67e29a39967397f9e0ee717e19765983e499
|
|
8
8
|
---
|
|
9
9
|
|
|
10
10
|
# MyFunnelAPI
|
|
@@ -19,7 +19,7 @@ Funnels are the publishing surface. You create a funnel under an org (one comman
|
|
|
19
19
|
|
|
20
20
|
By default, your funnel lives on a free preview subdomain (`*.makeautonomous.com`) you get with every org. To serve on a custom domain, register and assign one via **mydomainapi** first.
|
|
21
21
|
|
|
22
|
-
Every funnel auto-provisions a **webhook** at creation (`org_webhook_id`)
|
|
22
|
+
Every funnel auto-provisions a **webhook** at creation (`org_webhook_id`) and exposes two public endpoints your HTML can call without an API key: **form submit** at `POST /funnel/funnels/{id}/submit/{slug}`, which delivers through that webhook (CRM upsert + bound workflows fire automatically), and **event ingest** for pageviews and click tracking. Send a slug elsewhere with `myapi funnel form ... --capture-to webhook:<id>`.
|
|
23
23
|
<!-- llm:end -->
|
|
24
24
|
|
|
25
25
|
## Commands
|
|
@@ -32,7 +32,7 @@ Every funnel auto-provisions a **webhook** at creation (`org_webhook_id`), and e
|
|
|
32
32
|
| `myapi funnel delete <id>` | Delete the funnel and purge its edge pages |
|
|
33
33
|
| `myapi funnel push [slug]` | Push HTML from stdin to a slug (default: `/`). **Overwrites** an existing page — refused without `--force`. `--json` prints `{slug, subdomain_url, overwritten, org_id, funnel_id}` |
|
|
34
34
|
| `myapi funnel publish <dir>` | Upload a whole directory as the funnel's site (`--env dev\|prod`, default prod; `--api-fn <id>`; `--json`). Prod refuses to replace a live site without `--force` |
|
|
35
|
-
| `myapi funnel pages [funnel_id]` |
|
|
35
|
+
| `myapi funnel pages [funnel_id]` | Pages published to a funnel; `--with-content` fetches what is on them |
|
|
36
36
|
| `myapi funnel form [funnel_id]` | Emit canonical form HTML (`--capture-to`, `--cta`, `--success`, `--honeypot`) |
|
|
37
37
|
| `myapi funnel verify [slug]` | Verify a published page is reachable + check links/webhooks |
|
|
38
38
|
<!-- generated:end -->
|
|
@@ -42,7 +42,7 @@ Every funnel auto-provisions a **webhook** at creation (`org_webhook_id`), and e
|
|
|
42
42
|
A write targets a `(org, funnel, slug)` address. Get all three right *before* pushing — the CLI will help, but the thinking is yours:
|
|
43
43
|
|
|
44
44
|
1. **Confirm the org.** `--org` (or `default_org`) decides whose namespace you touch. For a demo or a new project, pass `--org <id>` explicitly every time — don't trust the ambient default. `myapi org list` shows the orgs you can reach.
|
|
45
|
-
2. **Look before you write.** `myapi funnel list --org <id>` shows the org's funnels; `myapi funnel pages --funnel <id>` shows what
|
|
45
|
+
2. **Look before you write.** `myapi funnel list --org <id>` shows the org's funnels; `myapi funnel pages --funnel <id>` shows what is published, and `--with-content` what is on each page (`--json` carries it). `push` replaces a whole page, so edit by reading it first.
|
|
46
46
|
3. **A new demo = a new funnel.** Don't reuse an org's existing funnel for an unrelated demo. `myapi funnel create --name <demo> --org <id>` gives you a clean namespace and its own preview subdomain.
|
|
47
47
|
4. **Pin the funnel.** When an org has exactly one funnel, `push`/`publish` auto-pick it — convenient, but it's how a demo lands on the wrong site. Pass `--funnel <id>` (or set a default) so the target is explicit, not inferred.
|
|
48
48
|
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@myapihq/cli",
|
|
3
3
|
"license": "Apache-2.0",
|
|
4
|
-
"version": "2.
|
|
4
|
+
"version": "2.27.0",
|
|
5
5
|
"description": "MyAPI command-line interface",
|
|
6
6
|
"repository": {
|
|
7
7
|
"type": "git",
|
|
@@ -46,7 +46,7 @@
|
|
|
46
46
|
"lint:skills:strict": "node scripts/copy-skills.js && node scripts/lint-skills.js --strict"
|
|
47
47
|
},
|
|
48
48
|
"dependencies": {
|
|
49
|
-
"@myapihq/sdk": "^2.
|
|
49
|
+
"@myapihq/sdk": "^2.27.0"
|
|
50
50
|
},
|
|
51
51
|
"devDependencies": {
|
|
52
52
|
"@types/node": "^25.6.0",
|