@anybuild-ai/ab 0.2.0 → 0.4.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.
- package/CHANGELOG.md +14 -1
- package/README.md +59 -2
- package/dist/api/entity-api.d.ts +35 -0
- package/dist/api/entity-api.d.ts.map +1 -0
- package/dist/api/entity-api.js +138 -0
- package/dist/api/entity-api.js.map +1 -0
- package/dist/commands/api-key.d.ts +3 -0
- package/dist/commands/api-key.d.ts.map +1 -0
- package/dist/commands/api-key.js +109 -0
- package/dist/commands/api-key.js.map +1 -0
- package/dist/commands/api.d.ts +3 -0
- package/dist/commands/api.d.ts.map +1 -0
- package/dist/commands/api.js +89 -0
- package/dist/commands/api.js.map +1 -0
- package/dist/commands/index.d.ts.map +1 -1
- package/dist/commands/index.js +6 -0
- package/dist/commands/index.js.map +1 -1
- package/dist/commands/status.js +1 -1
- package/dist/commands/status.js.map +1 -1
- package/dist/commands/test.d.ts +3 -0
- package/dist/commands/test.d.ts.map +1 -0
- package/dist/commands/test.js +105 -0
- package/dist/commands/test.js.map +1 -0
- package/dist/config/global-config.d.ts +4 -1
- package/dist/config/global-config.d.ts.map +1 -1
- package/dist/config/global-config.js +25 -0
- package/dist/config/global-config.js.map +1 -1
- package/dist/config/index.d.ts +2 -2
- package/dist/config/index.d.ts.map +1 -1
- package/dist/config/index.js +1 -1
- package/dist/config/index.js.map +1 -1
- package/dist/config/types.d.ts +13 -0
- package/dist/config/types.d.ts.map +1 -1
- package/dist/export/import-batch.d.ts.map +1 -1
- package/dist/export/import-batch.js +37 -5
- package/dist/export/import-batch.js.map +1 -1
- package/dist/export/schema-json.d.ts +3 -1
- package/dist/export/schema-json.d.ts.map +1 -1
- package/dist/export/schema-json.js +34 -1
- package/dist/export/schema-json.js.map +1 -1
- package/dist/export/status.js +2 -2
- package/dist/export/status.js.map +1 -1
- package/dist/export/working-dirs.d.ts +12 -1
- package/dist/export/working-dirs.d.ts.map +1 -1
- package/dist/export/working-dirs.js +41 -3
- package/dist/export/working-dirs.js.map +1 -1
- package/dist/export/working-tree-validation.js +1 -1
- package/dist/export/working-tree-validation.js.map +1 -1
- package/dist/io/read-credentials.d.ts +3 -0
- package/dist/io/read-credentials.d.ts.map +1 -1
- package/dist/io/read-credentials.js +31 -20
- package/dist/io/read-credentials.js.map +1 -1
- package/dist/router.d.ts.map +1 -1
- package/dist/router.js +3 -0
- package/dist/router.js.map +1 -1
- package/dist/scenario-tests/run-tests.d.ts +78 -0
- package/dist/scenario-tests/run-tests.d.ts.map +1 -0
- package/dist/scenario-tests/run-tests.js +206 -0
- package/dist/scenario-tests/run-tests.js.map +1 -0
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,6 +1,19 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
-
##
|
|
3
|
+
## 0.4.0
|
|
4
|
+
|
|
5
|
+
- `anybuild test <kind>`: test runner, one kind so far; `anybuild test` alone lists the kinds.
|
|
6
|
+
- `anybuild test scenarios [suites…] [--case <id>] [--tag <tag>] [--verbose]` runs AnyInput scenario test suites from the local `be/scenario_tests/` files against the pushed scenarios (server `POST /api/cli/v1/test/case`, two cases at a time). Allowed for users whose role is a system designer, on applications installed for development. Nothing is changed unless a case sets `"execute": true`.
|
|
7
|
+
- Failing cases print what the assistant understood: each message with its outcome and reply, the nearest scenarios, the ranker's decision and reason, the slots and the words no slot took; the whole reply when a reply check fails. Full report in `.ab/test-reports/scenarios.json`; exit code 1 when a case fails or cannot run. Local scenario / profile changes that are not pushed yet are listed first.
|
|
8
|
+
- Writable `be/scenario_tests/*.json` (create / update / delete on push, validated against the application's scenarios, sent after them).
|
|
9
|
+
- `validate` prints the server's warnings for applied files (as `push` already did), e.g. the AnyInput authoring warnings for scenarios.
|
|
10
|
+
|
|
11
|
+
## 0.3.0
|
|
12
|
+
|
|
13
|
+
- `anybuild api <METHOD> <path>` calls entity endpoints (OData) of the project's host with a stored API key: only `<api_url>/api/…`, no full URLs, no redirects; body to stdout, status to stderr, exit code 1 on HTTP errors. Writes (POST / PATCH / DELETE) need a key stored with writes allowed.
|
|
14
|
+
- `anybuild api-key set | show | remove`: store an API key per host in `~/.ab/config.json` (terminal only, hidden input, checked against the server before it is stored, writes allowed only when confirmed), show it masked, or remove it.
|
|
15
|
+
- Hidden prompts (password, API key) accept pasted input that arrives in one chunk.
|
|
16
|
+
- Writable `be/scenarios/*.json` (AnyInput scenarios, readable format) and `be/capability_profiles/*.json` (AnyInput capability profiles, `<type>.<name>.json`): create/update/delete on push; the server translates names, embeds examples and saves through the AnyInput registry. `validate` runs the full AnyInput validation. Profiles are sent before scenarios, both after `be/entities` / `be/views`.
|
|
4
17
|
|
|
5
18
|
## 0.2.0
|
|
6
19
|
|
package/README.md
CHANGED
|
@@ -76,6 +76,9 @@ If a push includes **deletions**, the CLI lists them and asks for confirmation.
|
|
|
76
76
|
| `be/node/` | Node modules (`.js`) |
|
|
77
77
|
| `be/entities/` | Entity authoring JSON |
|
|
78
78
|
| `be/views/` | Custom view authoring JSON |
|
|
79
|
+
| `be/scenarios/` | AnyInput scenarios (readable JSON) |
|
|
80
|
+
| `be/capability_profiles/` | AnyInput capability profiles (`<type>.<name>.json`) |
|
|
81
|
+
| `be/scenario_tests/` | AnyInput scenario test suites (`<suite_id>.json`), run with `anybuild test scenarios` |
|
|
79
82
|
|
|
80
83
|
`meta/` is **read-only** (catalogs, generated schema dumps, default entity widgets, AI rule files). Do not put source entity/view JSON there.
|
|
81
84
|
|
|
@@ -103,9 +106,62 @@ Checksums: `.json` under `ui/lit`, `ui/navigation`, `ui/portals`, `be/entities`,
|
|
|
103
106
|
| `anybuild status` | List local added / modified / deleted files |
|
|
104
107
|
| `anybuild validate [paths…]` | Check pending changes against the server without applying them (checksums, JSON shape, JS parse, schema expand). Does not compile entities or views. Options: `--debug` |
|
|
105
108
|
| `anybuild push [paths…]` | Upload local changes (optional file paths). Options: `--debug`, `--yes` / `-y` (skip confirm when the push includes deletions) |
|
|
109
|
+
| `anybuild test scenarios [suites…]` | Run AnyInput scenario test suites (`be/scenario_tests/`, the local files) against the pushed scenarios, as you. Options: `--case <id>`, `--tag <tag>` (both repeatable), `--verbose`. Report in `.ab/test-reports/scenarios.json`; exit code 1 when a case fails. `anybuild test` lists the test kinds |
|
|
110
|
+
| `anybuild api <GET\|POST\|PATCH\|DELETE> <path> [--data <json> \| --data-file <file>]` | Call an entity endpoint (OData) of the project's host with the stored API key. `<path>` is relative to `/api/`. Body to stdout, status line to stderr, exit code 1 on HTTP errors |
|
|
111
|
+
| `anybuild api-key set [--allow-writes \| --read-only]` | Store an API key for the project's host (hidden prompt, terminal only). Checks the key first; asks whether writes are allowed (default no) |
|
|
112
|
+
| `anybuild api-key show` / `remove` | Show which key is stored (never the secret) / forget it |
|
|
106
113
|
|
|
107
114
|
Also: `anybuild help`, `anybuild -v` / `--version`.
|
|
108
115
|
|
|
116
|
+
### Scenario tests
|
|
117
|
+
|
|
118
|
+
A suite (`be/scenario_tests/<suite_id>.json`) lists requests (one message or a short conversation) and what the assistant should do: which scenario, the outcome (`result`, `confirm`, `ask:<slot>`, `choose:<slot>`, `no_match`, …) and the slot values. Format: `meta/be/scenarios/RULES.md` ("Test suites") and `meta/be/scenario_tests/examples/` after clone/pull.
|
|
119
|
+
|
|
120
|
+
- `anybuild test scenarios` sends each case of the local files to the server, two at a time; each case is a new test conversation of the signed-in user with the suite's fixed "now". The assistant uses the **pushed** scenarios and profiles: push them first (the command lists local changes it cannot see).
|
|
121
|
+
- Nothing is changed unless a case sets `"execute": true`; without it a confirmed change ends as outcome `confirmed`.
|
|
122
|
+
- Suites are pushed and pulled like scenarios (push checks scenario and slot names, outcomes, and that no test message copies a scenario example).
|
|
123
|
+
- Allowed for users whose role is a system designer, while the application is in development mode in that environment.
|
|
124
|
+
|
|
125
|
+
### Calling entity endpoints
|
|
126
|
+
|
|
127
|
+
Entities with endpoints are served as an OData API under `/api/<path>`. `anybuild api` calls them for testing and seeding, for you or for an AI agent working in the project.
|
|
128
|
+
|
|
129
|
+
#### Setting up an API key (once per host, by a person)
|
|
130
|
+
|
|
131
|
+
`anybuild api` never uses your login. It needs an API key, stored once per host on your machine.
|
|
132
|
+
|
|
133
|
+
1. **Create the key** in Anybuild: Identities → open the identity the calls should run as (preferably a service account with a minimal role, not your own user) → API keys → Create API key. Give it a name and a short expiry, and do not make it unscoped. Copy the key (`odk_…`): it is shown only once.
|
|
134
|
+
2. **Grant the endpoints** it may use: open the key on the same page; in the scope editor tick Read / Save / Submit / Delete for each entity it needs, then Save scopes.
|
|
135
|
+
3. **Store it in the CLI**: open a terminal in the project folder (the folder that contains `.ab/`) and run
|
|
136
|
+
|
|
137
|
+
```bash
|
|
138
|
+
anybuild api-key set
|
|
139
|
+
```
|
|
140
|
+
|
|
141
|
+
- At `API key for https://… (input hidden):` paste the key and press Enter. Nothing is shown while you paste; that is expected.
|
|
142
|
+
- The CLI checks the key against the server. A rejected key is not stored.
|
|
143
|
+
- At `Allow writes (POST / PATCH / DELETE) …? [y/N]` answer `y` only on a development or test environment. With `N` (the default) the key can only read.
|
|
144
|
+
- It ends with `Stored odk_<id>_… for https://… (environment: …), read only.` (or `reads and writes`).
|
|
145
|
+
4. **Check it**: `anybuild api-key show` prints which key is stored (never the secret); `anybuild api GET '<app>/<entity>?$top=1'` should return data.
|
|
146
|
+
|
|
147
|
+
Good to know:
|
|
148
|
+
|
|
149
|
+
- The key belongs to the host, not to one project: every project on that host on this machine uses it.
|
|
150
|
+
- To replace the key or change the write setting, run `anybuild api-key set` again.
|
|
151
|
+
- When you are done: `anybuild api-key remove`, then revoke the key on the Identities page.
|
|
152
|
+
|
|
153
|
+
#### Calling
|
|
154
|
+
|
|
155
|
+
```bash
|
|
156
|
+
anybuild api GET 'my_app/invoice?$top=5&$count=true'
|
|
157
|
+
anybuild api POST my_app/invoice --data '{"invoice_number":"INV-1"}'
|
|
158
|
+
anybuild api PATCH 'my_app/invoice(<thing_id>)' --data '{"note":"x"}'
|
|
159
|
+
anybuild api POST 'my_app/invoice(<thing_id>)/submit'
|
|
160
|
+
```
|
|
161
|
+
|
|
162
|
+
- Requests only go to the project's `api_url` (`.ab/config.json`); full URLs and redirects are refused, so the key is not sent elsewhere.
|
|
163
|
+
- POST / PATCH / DELETE are refused unless the key was stored with writes allowed.
|
|
164
|
+
|
|
109
165
|
### Clone examples
|
|
110
166
|
|
|
111
167
|
```bash
|
|
@@ -122,14 +178,15 @@ anybuild clone https://your-host.example.com/my-app ./other-folder --force
|
|
|
122
178
|
|
|
123
179
|
| Location | Purpose |
|
|
124
180
|
| --- | --- |
|
|
125
|
-
| `~/.ab/config.json` | Your login sessions (credentials for each host) |
|
|
181
|
+
| `~/.ab/config.json` | Your login sessions and stored API keys (credentials for each host) |
|
|
126
182
|
| `.ab/` in the project | Project settings and sync state (no passwords) |
|
|
127
183
|
|
|
128
184
|
Run project commands (`pull`, `push`, `status`, `validate`) from inside a cloned application directory.
|
|
129
185
|
|
|
130
186
|
## Security
|
|
131
187
|
|
|
132
|
-
- Sessions live in `~/.ab/` with restrictive file permissions on Unix. Do not share or commit that folder.
|
|
188
|
+
- Sessions and API keys live in `~/.ab/` with restrictive file permissions on Unix. Do not share or commit that folder.
|
|
189
|
+
- `anybuild api-key set` only runs in a terminal (hidden input), so a key is always stored by a person. The CLI never prints a stored key.
|
|
133
190
|
- On shared machines, run `anybuild logout <host-url>` when done.
|
|
134
191
|
- Avoid `--debug` in shared or CI logs.
|
|
135
192
|
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
/** Methods `anybuild api` sends. Anything but GET changes data and needs a key stored with writes allowed. */
|
|
2
|
+
export declare const API_METHODS: readonly ["GET", "POST", "PATCH", "DELETE"];
|
|
3
|
+
export type ApiMethod = (typeof API_METHODS)[number];
|
|
4
|
+
export declare function parseApiMethod(value: string | undefined): ApiMethod;
|
|
5
|
+
export declare function isWriteMethod(method: ApiMethod): boolean;
|
|
6
|
+
export declare function isValidApiKey(value: string): boolean;
|
|
7
|
+
/** odk_<key id>_… — the key id is not secret, the rest is never shown. */
|
|
8
|
+
export declare function maskApiKey(value: string): string;
|
|
9
|
+
/**
|
|
10
|
+
* The URL is always `<api_url>/api/<path>` of the project, so a stored key is only ever sent to that host.
|
|
11
|
+
* `path` may be given with or without the leading `/api/`; it may carry a query string.
|
|
12
|
+
*/
|
|
13
|
+
export declare function buildApiUrl(apiUrl: string, path: string): string;
|
|
14
|
+
/** Validates the body locally, so a typo does not become a server round trip. */
|
|
15
|
+
export declare function parseJsonBody(text: string, source: string): string;
|
|
16
|
+
export type ApiCallResult = {
|
|
17
|
+
status: number;
|
|
18
|
+
statusText: string;
|
|
19
|
+
contentType: string;
|
|
20
|
+
body: string;
|
|
21
|
+
durationMs: number;
|
|
22
|
+
};
|
|
23
|
+
export declare function callEntityApi(options: {
|
|
24
|
+
apiUrl: string;
|
|
25
|
+
path: string;
|
|
26
|
+
method: ApiMethod;
|
|
27
|
+
apiKey: string;
|
|
28
|
+
body?: string;
|
|
29
|
+
timeoutMs?: number;
|
|
30
|
+
}, fetchImpl?: typeof fetch): Promise<ApiCallResult>;
|
|
31
|
+
/** JSON bodies are pretty printed; anything else (e.g. $metadata XML) is returned as is. */
|
|
32
|
+
export declare function formatBody(result: ApiCallResult): string;
|
|
33
|
+
/** The OData error message, when the body has one. */
|
|
34
|
+
export declare function errorMessage(result: ApiCallResult): string | undefined;
|
|
35
|
+
//# sourceMappingURL=entity-api.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"entity-api.d.ts","sourceRoot":"","sources":["../../src/api/entity-api.ts"],"names":[],"mappings":"AAGA,8GAA8G;AAC9G,eAAO,MAAM,WAAW,6CAA8C,CAAC;AACvE,MAAM,MAAM,SAAS,GAAG,CAAC,OAAO,WAAW,CAAC,CAAC,MAAM,CAAC,CAAC;AAMrD,wBAAgB,cAAc,CAAC,KAAK,EAAE,MAAM,GAAG,SAAS,GAAG,SAAS,CASnE;AAED,wBAAgB,aAAa,CAAC,MAAM,EAAE,SAAS,GAAG,OAAO,CAExD;AAED,wBAAgB,aAAa,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAEpD;AAED,0EAA0E;AAC1E,wBAAgB,UAAU,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAGhD;AAED;;;GAGG;AACH,wBAAgB,WAAW,CAAC,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,MAAM,CA2BhE;AAED,iFAAiF;AACjF,wBAAgB,aAAa,CAAC,IAAI,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,MAAM,CASlE;AAED,MAAM,MAAM,aAAa,GAAG;IAC1B,MAAM,EAAE,MAAM,CAAC;IACf,UAAU,EAAE,MAAM,CAAC;IACnB,WAAW,EAAE,MAAM,CAAC;IACpB,IAAI,EAAE,MAAM,CAAC;IACb,UAAU,EAAE,MAAM,CAAC;CACpB,CAAC;AAEF,wBAAsB,aAAa,CACjC,OAAO,EAAE;IACP,MAAM,EAAE,MAAM,CAAC;IACf,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,EAAE,SAAS,CAAC;IAClB,MAAM,EAAE,MAAM,CAAC;IACf,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB,EACD,SAAS,GAAE,OAAO,KAAa,GAC9B,OAAO,CAAC,aAAa,CAAC,CA8CxB;AAED,4FAA4F;AAC5F,wBAAgB,UAAU,CAAC,MAAM,EAAE,aAAa,GAAG,MAAM,CAYxD;AAED,sDAAsD;AACtD,wBAAgB,YAAY,CAAC,MAAM,EAAE,aAAa,GAAG,MAAM,GAAG,SAAS,CAYtE"}
|
|
@@ -0,0 +1,138 @@
|
|
|
1
|
+
import { normalizeApiUrl } from "../config/normalize-url.js";
|
|
2
|
+
import { AbCliError, CLI_PROGRAM } from "../errors.js";
|
|
3
|
+
/** Methods `anybuild api` sends. Anything but GET changes data and needs a key stored with writes allowed. */
|
|
4
|
+
export const API_METHODS = ["GET", "POST", "PATCH", "DELETE"];
|
|
5
|
+
const API_PREFIX = "/api/";
|
|
6
|
+
const API_KEY_PATTERN = /^odk_[A-Za-z0-9-]+_[A-Za-z0-9_-]+$/;
|
|
7
|
+
const REQUEST_TIMEOUT_MS = 120_000;
|
|
8
|
+
export function parseApiMethod(value) {
|
|
9
|
+
const method = (value ?? "").trim().toUpperCase();
|
|
10
|
+
if (!API_METHODS.includes(method)) {
|
|
11
|
+
throw new AbCliError("CONFIG", `Method must be one of ${API_METHODS.join(", ")}, got ${JSON.stringify(value ?? "")}.`);
|
|
12
|
+
}
|
|
13
|
+
return method;
|
|
14
|
+
}
|
|
15
|
+
export function isWriteMethod(method) {
|
|
16
|
+
return method !== "GET";
|
|
17
|
+
}
|
|
18
|
+
export function isValidApiKey(value) {
|
|
19
|
+
return API_KEY_PATTERN.test(value);
|
|
20
|
+
}
|
|
21
|
+
/** odk_<key id>_… — the key id is not secret, the rest is never shown. */
|
|
22
|
+
export function maskApiKey(value) {
|
|
23
|
+
const match = /^(odk_[A-Za-z0-9-]+)_/.exec(value);
|
|
24
|
+
return match ? `${match[1]}_…` : "odk_…";
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* The URL is always `<api_url>/api/<path>` of the project, so a stored key is only ever sent to that host.
|
|
28
|
+
* `path` may be given with or without the leading `/api/`; it may carry a query string.
|
|
29
|
+
*/
|
|
30
|
+
export function buildApiUrl(apiUrl, path) {
|
|
31
|
+
const raw = (path ?? "").trim();
|
|
32
|
+
if (!raw) {
|
|
33
|
+
throw new AbCliError("CONFIG", `Path is required, e.g. ${CLI_PROGRAM} api GET my_app/invoice?$top=5`);
|
|
34
|
+
}
|
|
35
|
+
if (/^[a-z][a-z0-9+.-]*:/i.test(raw) || raw.startsWith("//")) {
|
|
36
|
+
throw new AbCliError("CONFIG", "Path must be relative to the project's API (for example my_app/invoice), not a full URL.");
|
|
37
|
+
}
|
|
38
|
+
let relative = raw.replace(/^\/+/, "");
|
|
39
|
+
if (relative.toLowerCase().startsWith("api/")) {
|
|
40
|
+
relative = relative.slice(4);
|
|
41
|
+
}
|
|
42
|
+
if (!relative || relative.split(/[?#]/)[0].split("/").some((segment) => segment === "..")) {
|
|
43
|
+
throw new AbCliError("CONFIG", `Path ${JSON.stringify(raw)} is not a valid API path.`);
|
|
44
|
+
}
|
|
45
|
+
// keep $, (, ), ', commas readable; encode spaces and other characters a URL cannot carry
|
|
46
|
+
// accept an already encoded path (%20) as well as a readable one; encode once
|
|
47
|
+
let decoded = relative;
|
|
48
|
+
try {
|
|
49
|
+
decoded = decodeURI(relative);
|
|
50
|
+
}
|
|
51
|
+
catch {
|
|
52
|
+
// keep as typed
|
|
53
|
+
}
|
|
54
|
+
return `${normalizeApiUrl(apiUrl)}${API_PREFIX}${encodeURI(decoded)}`;
|
|
55
|
+
}
|
|
56
|
+
/** Validates the body locally, so a typo does not become a server round trip. */
|
|
57
|
+
export function parseJsonBody(text, source) {
|
|
58
|
+
try {
|
|
59
|
+
return JSON.stringify(JSON.parse(text));
|
|
60
|
+
}
|
|
61
|
+
catch (e) {
|
|
62
|
+
throw new AbCliError("CONFIG", `${source} is not valid JSON: ${e instanceof Error ? e.message : String(e)}`);
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
export async function callEntityApi(options, fetchImpl = fetch) {
|
|
66
|
+
const url = buildApiUrl(options.apiUrl, options.path);
|
|
67
|
+
const headers = new Headers({
|
|
68
|
+
Authorization: `Bearer ${options.apiKey}`,
|
|
69
|
+
Accept: "application/json, application/xml;q=0.9, */*;q=0.1",
|
|
70
|
+
});
|
|
71
|
+
if (options.body !== undefined) {
|
|
72
|
+
headers.set("Content-Type", "application/json");
|
|
73
|
+
}
|
|
74
|
+
const controller = new AbortController();
|
|
75
|
+
const timer = setTimeout(() => controller.abort(), options.timeoutMs ?? REQUEST_TIMEOUT_MS);
|
|
76
|
+
const started = Date.now();
|
|
77
|
+
let res;
|
|
78
|
+
try {
|
|
79
|
+
res = await fetchImpl(url, {
|
|
80
|
+
method: options.method,
|
|
81
|
+
headers,
|
|
82
|
+
body: options.body,
|
|
83
|
+
// a redirect would carry the key to wherever it points
|
|
84
|
+
redirect: "manual",
|
|
85
|
+
signal: controller.signal,
|
|
86
|
+
});
|
|
87
|
+
}
|
|
88
|
+
catch (e) {
|
|
89
|
+
if (controller.signal.aborted) {
|
|
90
|
+
throw new AbCliError("HTTP", `${options.method} ${url} timed out after ${Math.round((options.timeoutMs ?? REQUEST_TIMEOUT_MS) / 1000)} s.`);
|
|
91
|
+
}
|
|
92
|
+
throw new AbCliError("HTTP", `${options.method} ${url} failed: ${e instanceof Error ? e.message : String(e)}`);
|
|
93
|
+
}
|
|
94
|
+
finally {
|
|
95
|
+
clearTimeout(timer);
|
|
96
|
+
}
|
|
97
|
+
if (res.status >= 300 && res.status < 400) {
|
|
98
|
+
throw new AbCliError("HTTP", `${options.method} ${url} answered with a redirect (${res.status}); the CLI does not follow redirects with an API key.`);
|
|
99
|
+
}
|
|
100
|
+
return {
|
|
101
|
+
status: res.status,
|
|
102
|
+
statusText: res.statusText,
|
|
103
|
+
contentType: res.headers.get("content-type") ?? "",
|
|
104
|
+
body: await res.text(),
|
|
105
|
+
durationMs: Date.now() - started,
|
|
106
|
+
};
|
|
107
|
+
}
|
|
108
|
+
/** JSON bodies are pretty printed; anything else (e.g. $metadata XML) is returned as is. */
|
|
109
|
+
export function formatBody(result) {
|
|
110
|
+
if (!result.body) {
|
|
111
|
+
return "";
|
|
112
|
+
}
|
|
113
|
+
if (/json/i.test(result.contentType)) {
|
|
114
|
+
try {
|
|
115
|
+
return JSON.stringify(JSON.parse(result.body), null, 2);
|
|
116
|
+
}
|
|
117
|
+
catch {
|
|
118
|
+
return result.body;
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
return result.body;
|
|
122
|
+
}
|
|
123
|
+
/** The OData error message, when the body has one. */
|
|
124
|
+
export function errorMessage(result) {
|
|
125
|
+
try {
|
|
126
|
+
const parsed = JSON.parse(result.body);
|
|
127
|
+
if (parsed?.error && typeof parsed.error.message === "string") {
|
|
128
|
+
return typeof parsed.error.code === "string"
|
|
129
|
+
? `${parsed.error.code}: ${parsed.error.message}`
|
|
130
|
+
: parsed.error.message;
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
catch {
|
|
134
|
+
// not JSON
|
|
135
|
+
}
|
|
136
|
+
return undefined;
|
|
137
|
+
}
|
|
138
|
+
//# sourceMappingURL=entity-api.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"entity-api.js","sourceRoot":"","sources":["../../src/api/entity-api.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,4BAA4B,CAAC;AAC7D,OAAO,EAAE,UAAU,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAEvD,8GAA8G;AAC9G,MAAM,CAAC,MAAM,WAAW,GAAG,CAAC,KAAK,EAAE,MAAM,EAAE,OAAO,EAAE,QAAQ,CAAU,CAAC;AAGvE,MAAM,UAAU,GAAG,OAAO,CAAC;AAC3B,MAAM,eAAe,GAAG,oCAAoC,CAAC;AAC7D,MAAM,kBAAkB,GAAG,OAAO,CAAC;AAEnC,MAAM,UAAU,cAAc,CAAC,KAAyB;IACtD,MAAM,MAAM,GAAG,CAAC,KAAK,IAAI,EAAE,CAAC,CAAC,IAAI,EAAE,CAAC,WAAW,EAAE,CAAC;IAClD,IAAI,CAAE,WAAiC,CAAC,QAAQ,CAAC,MAAM,CAAC,EAAE,CAAC;QACzD,MAAM,IAAI,UAAU,CAClB,QAAQ,EACR,yBAAyB,WAAW,CAAC,IAAI,CAAC,IAAI,CAAC,SAAS,IAAI,CAAC,SAAS,CAAC,KAAK,IAAI,EAAE,CAAC,GAAG,CACvF,CAAC;IACJ,CAAC;IACD,OAAO,MAAmB,CAAC;AAC7B,CAAC;AAED,MAAM,UAAU,aAAa,CAAC,MAAiB;IAC7C,OAAO,MAAM,KAAK,KAAK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AK,CAAC,OAAO,EAAE;gBACjD,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,OAAO,CAAC;QAC3B,CAAC;IACH,CAAC;IAAC,MAAM,CAAC;QACP,WAAW;IACb,CAAC;IACD,OAAO,SAAS,CAAC;AACnB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"api-key.d.ts","sourceRoot":"","sources":["../../src/commands/api-key.ts"],"names":[],"mappings":"AAYA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AA0GjD,eAAO,MAAM,MAAM,EAAE,cAoBpB,CAAC"}
|
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
import { isValidApiKey, maskApiKey, callEntityApi, errorMessage } from "../api/entity-api.js";
|
|
2
|
+
import { getApiKeyFromGlobal, removeApiKeyFromGlobal, upsertApiKeyInGlobal, } from "../config/global-config.js";
|
|
3
|
+
import { loadProjectConfigFromCwd } from "../config/project-config.js";
|
|
4
|
+
import { sessionKey } from "../config/session-key.js";
|
|
5
|
+
import { AbCliError, CLI_PROGRAM } from "../errors.js";
|
|
6
|
+
import { confirmYesNo } from "../io/confirm-yes.js";
|
|
7
|
+
import { readSecretHidden } from "../io/read-credentials.js";
|
|
8
|
+
import { logProgress } from "../progress.js";
|
|
9
|
+
function usage() {
|
|
10
|
+
console.error(`Usage:
|
|
11
|
+
${CLI_PROGRAM} api-key set [--allow-writes | --read-only] Store an API key for this project's environment (asks for it, hidden)
|
|
12
|
+
${CLI_PROGRAM} api-key show Show which key is stored (never the secret)
|
|
13
|
+
${CLI_PROGRAM} api-key remove Forget the stored key
|
|
14
|
+
|
|
15
|
+
The key is used by "${CLI_PROGRAM} api" for every project on this host. Before "set":
|
|
16
|
+
1. Identities page → open the identity (preferably a service account) → API keys → Create API key
|
|
17
|
+
(short expiry, not unscoped). Copy the key; it is shown only once.
|
|
18
|
+
2. Open the key and tick the endpoints it may use (Read / Save / Submit / Delete), then Save scopes.
|
|
19
|
+
Run "set" in the project folder, paste the key (nothing is shown) and press Enter.
|
|
20
|
+
Allow writes only on development or test environments.`);
|
|
21
|
+
}
|
|
22
|
+
function requireTerminal() {
|
|
23
|
+
if (!process.stdin.isTTY || !process.stdout.isTTY) {
|
|
24
|
+
throw new AbCliError("CONFIG", `${CLI_PROGRAM} api-key set must be run by a person in a terminal (it asks for the key with hidden input).`);
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
async function setKey(flags) {
|
|
28
|
+
const allowFlag = flags.includes("--allow-writes");
|
|
29
|
+
const readOnlyFlag = flags.includes("--read-only");
|
|
30
|
+
const unknown = flags.filter((flag) => flag !== "--allow-writes" && flag !== "--read-only");
|
|
31
|
+
if (unknown.length > 0 || (allowFlag && readOnlyFlag)) {
|
|
32
|
+
usage();
|
|
33
|
+
process.exitCode = 1;
|
|
34
|
+
return;
|
|
35
|
+
}
|
|
36
|
+
requireTerminal();
|
|
37
|
+
const project = loadProjectConfigFromCwd();
|
|
38
|
+
const key = sessionKey(project.api_url, project.environment);
|
|
39
|
+
const apiKey = await readSecretHidden(`API key for ${project.api_url} (input hidden): `);
|
|
40
|
+
if (!isValidApiKey(apiKey)) {
|
|
41
|
+
throw new AbCliError("CONFIG", "That is not an Anybuild API key (expected odk_<id>_<secret>). Nothing was stored.");
|
|
42
|
+
}
|
|
43
|
+
// the key is checked before it is stored: 401 means the server does not accept it; 403 only means it has no scope on $metadata
|
|
44
|
+
logProgress("Checking the key…");
|
|
45
|
+
const check = await callEntityApi({
|
|
46
|
+
apiUrl: project.api_url,
|
|
47
|
+
path: `${project.application_id}/$metadata`,
|
|
48
|
+
method: "GET",
|
|
49
|
+
apiKey,
|
|
50
|
+
});
|
|
51
|
+
if (check.status === 401) {
|
|
52
|
+
throw new AbCliError("AUTH_LOGIN", `The server rejected the key (${errorMessage(check) ?? "401"}). Nothing was stored.`);
|
|
53
|
+
}
|
|
54
|
+
if (check.status === 403) {
|
|
55
|
+
logProgress(`Note: the key is valid but has no scope on ${project.application_id}/$metadata. That is fine unless you need $metadata; grant endpoint scopes on the Identities page.`);
|
|
56
|
+
}
|
|
57
|
+
else if (check.status >= 400) {
|
|
58
|
+
logProgress(`Note: checking the key returned HTTP ${check.status} (${errorMessage(check) ?? check.statusText}).`);
|
|
59
|
+
}
|
|
60
|
+
let allowWrites = allowFlag;
|
|
61
|
+
if (!allowFlag && !readOnlyFlag) {
|
|
62
|
+
allowWrites = await confirmYesNo(`Allow writes (POST / PATCH / DELETE) with this key on ${project.api_url}? Only for development or test data. [y/N] `);
|
|
63
|
+
}
|
|
64
|
+
upsertApiKeyInGlobal(key, {
|
|
65
|
+
api_key: apiKey,
|
|
66
|
+
allow_writes: allowWrites,
|
|
67
|
+
saved_at: new Date().toISOString(),
|
|
68
|
+
});
|
|
69
|
+
console.log(`Stored ${maskApiKey(apiKey)} for ${project.api_url} (environment: ${project.environment}), ${allowWrites ? "reads and writes" : "read only"}.`);
|
|
70
|
+
}
|
|
71
|
+
function showKey() {
|
|
72
|
+
const project = loadProjectConfigFromCwd();
|
|
73
|
+
const entry = getApiKeyFromGlobal(sessionKey(project.api_url, project.environment));
|
|
74
|
+
if (!entry) {
|
|
75
|
+
console.log(`No API key stored for ${project.api_url} (environment: ${project.environment}).`);
|
|
76
|
+
return;
|
|
77
|
+
}
|
|
78
|
+
console.log(`${maskApiKey(entry.api_key)} for ${project.api_url} (environment: ${project.environment}), ${entry.allow_writes ? "reads and writes" : "read only"}, stored ${entry.saved_at}.`);
|
|
79
|
+
}
|
|
80
|
+
function removeKey() {
|
|
81
|
+
const project = loadProjectConfigFromCwd();
|
|
82
|
+
const removed = removeApiKeyFromGlobal(sessionKey(project.api_url, project.environment));
|
|
83
|
+
console.log(removed
|
|
84
|
+
? `Removed the API key for ${project.api_url}. Revoke it on the Identities page if it is no longer needed.`
|
|
85
|
+
: `No API key stored for ${project.api_url}.`);
|
|
86
|
+
}
|
|
87
|
+
export const apiKey = async (args) => {
|
|
88
|
+
const [sub, ...flags] = args;
|
|
89
|
+
try {
|
|
90
|
+
if (sub === "set") {
|
|
91
|
+
await setKey(flags);
|
|
92
|
+
}
|
|
93
|
+
else if (sub === "show" && flags.length === 0) {
|
|
94
|
+
showKey();
|
|
95
|
+
}
|
|
96
|
+
else if (sub === "remove" && flags.length === 0) {
|
|
97
|
+
removeKey();
|
|
98
|
+
}
|
|
99
|
+
else {
|
|
100
|
+
usage();
|
|
101
|
+
process.exitCode = 1;
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
catch (e) {
|
|
105
|
+
console.error(`${CLI_PROGRAM} api-key: ${e instanceof Error ? e.message : String(e)}`);
|
|
106
|
+
process.exitCode = 1;
|
|
107
|
+
}
|
|
108
|
+
};
|
|
109
|
+
//# sourceMappingURL=api-key.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"api-key.js","sourceRoot":"","sources":["../../src/commands/api-key.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,UAAU,EAAE,aAAa,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAC;AAC9F,OAAO,EACL,mBAAmB,EACnB,sBAAsB,EACtB,oBAAoB,GACrB,MAAM,4BAA4B,CAAC;AACpC,OAAO,EAAE,wBAAwB,EAAE,MAAM,6BAA6B,CAAC;AACvE,OAAO,EAAE,UAAU,EAAE,MAAM,0BAA0B,CAAC;AACtD,OAAO,EAAE,UAAU,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AACvD,OAAO,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAC;AACpD,OAAO,EAAE,gBAAgB,EAAE,MAAM,2BAA2B,CAAC;AAC7D,OAAO,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAG7C,SAAS,KAAK;IACZ,OAAO,CAAC,KAAK,CAAC;IACZ,WAAW;IACX,WAAW;IACX,WAAW;;sBAEO,WAAW;;;;;uDAKsB,CAAC,CAAC;AACzD,CAAC;AAED,SAAS,eAAe;IACtB,IAAI,CAA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,CAAC;aACI,CAAC;YACJ,KAAK,EAAE,CAAC;YACR,OAAO,CAAC,QAAQ,GAAG,CAAC,CAAC;QACvB,CAAC;IACH,CAAC;IAAC,OAAO,CAAC,EAAE,CAAC;QACX,OAAO,CAAC,KAAK,CAAC,GAAG,WAAW,aAAa,CAAC,YAAY,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC;QACvF,OAAO,CAAC,QAAQ,GAAG,CAAC,CAAC;IACvB,CAAC;AACH,CAAC,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"api.d.ts","sourceRoot":"","sources":["../../src/commands/api.ts"],"names":[],"mappings":"AAaA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AAuCjD,eAAO,MAAM,GAAG,EAAE,cAuDjB,CAAC"}
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
import { readFileSync } from "node:fs";
|
|
2
|
+
import { callEntityApi, errorMessage, formatBody, isWriteMethod, parseApiMethod, parseJsonBody, } from "../api/entity-api.js";
|
|
3
|
+
import { getApiKeyFromGlobal } from "../config/global-config.js";
|
|
4
|
+
import { loadProjectConfigFromCwd } from "../config/project-config.js";
|
|
5
|
+
import { sessionKey } from "../config/session-key.js";
|
|
6
|
+
import { AbCliError, CLI_PROGRAM } from "../errors.js";
|
|
7
|
+
function usage() {
|
|
8
|
+
console.error(`Usage: ${CLI_PROGRAM} api <GET|POST|PATCH|DELETE> <path> [--data <json> | --data-file <file>]
|
|
9
|
+
|
|
10
|
+
Calls an entity endpoint of this project's environment with the key stored by "${CLI_PROGRAM} api-key set".
|
|
11
|
+
<path> is relative to /api/, e.g.:
|
|
12
|
+
${CLI_PROGRAM} api GET "my_app/invoice?\\$top=5&\\$count=true"
|
|
13
|
+
${CLI_PROGRAM} api POST my_app/invoice --data '{"invoice_number":"INV-1"}'
|
|
14
|
+
${CLI_PROGRAM} api PATCH "my_app/invoice(<thing_id>)" --data-file body.json
|
|
15
|
+
${CLI_PROGRAM} api POST "my_app/invoice(<thing_id>)/submit"
|
|
16
|
+
|
|
17
|
+
The response body goes to stdout, the status line to stderr; the exit code is 1 for HTTP errors.`);
|
|
18
|
+
}
|
|
19
|
+
function readBody(flags) {
|
|
20
|
+
let body;
|
|
21
|
+
for (let i = 0; i < flags.length; i++) {
|
|
22
|
+
const flag = flags[i];
|
|
23
|
+
if (flag === "--data" || flag === "--data-file") {
|
|
24
|
+
const value = flags[i + 1];
|
|
25
|
+
if (value === undefined) {
|
|
26
|
+
throw new AbCliError("CONFIG", `${flag} needs a value.`);
|
|
27
|
+
}
|
|
28
|
+
if (body !== undefined) {
|
|
29
|
+
throw new AbCliError("CONFIG", "Give the body once (--data or --data-file).");
|
|
30
|
+
}
|
|
31
|
+
body = flag === "--data"
|
|
32
|
+
? parseJsonBody(value, "--data")
|
|
33
|
+
: parseJsonBody(readFileSync(value, "utf8"), value);
|
|
34
|
+
i++;
|
|
35
|
+
}
|
|
36
|
+
else {
|
|
37
|
+
throw new AbCliError("CONFIG", `Unknown option ${flag}.`);
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
return body;
|
|
41
|
+
}
|
|
42
|
+
export const api = async (args) => {
|
|
43
|
+
const [methodArg, path, ...flags] = args;
|
|
44
|
+
if (methodArg === undefined || path === undefined || methodArg === "--help" || methodArg === "-h") {
|
|
45
|
+
usage();
|
|
46
|
+
process.exitCode = methodArg === undefined || path === undefined ? 1 : 0;
|
|
47
|
+
return;
|
|
48
|
+
}
|
|
49
|
+
try {
|
|
50
|
+
const method = parseApiMethod(methodArg);
|
|
51
|
+
const body = readBody(flags);
|
|
52
|
+
if (body !== undefined && method === "GET") {
|
|
53
|
+
throw new AbCliError("CONFIG", "GET does not take a body.");
|
|
54
|
+
}
|
|
55
|
+
const project = loadProjectConfigFromCwd();
|
|
56
|
+
const entry = getApiKeyFromGlobal(sessionKey(project.api_url, project.environment));
|
|
57
|
+
if (!entry) {
|
|
58
|
+
throw new AbCliError("NO_SESSION", `No API key for ${project.api_url}. A person sets one up once: create an API key on the Identities page (API keys), tick the endpoints it may use, then run "${CLI_PROGRAM} api-key set" in this project folder and paste the key. See "Setting up an API key" in the CLI README.`);
|
|
59
|
+
}
|
|
60
|
+
if (isWriteMethod(method) && !entry.allow_writes) {
|
|
61
|
+
throw new AbCliError("CONFIG", `The API key for ${project.api_url} is stored read only, so ${method} is refused. A person can run "${CLI_PROGRAM} api-key set" again and allow writes (development or test environments only).`);
|
|
62
|
+
}
|
|
63
|
+
const result = await callEntityApi({
|
|
64
|
+
apiUrl: project.api_url,
|
|
65
|
+
path,
|
|
66
|
+
method,
|
|
67
|
+
apiKey: entry.api_key,
|
|
68
|
+
body,
|
|
69
|
+
});
|
|
70
|
+
const formatted = formatBody(result);
|
|
71
|
+
if (formatted) {
|
|
72
|
+
process.stdout.write(formatted.endsWith("\n") ? formatted : `${formatted}\n`);
|
|
73
|
+
}
|
|
74
|
+
const seconds = (result.durationMs / 1000).toFixed(1);
|
|
75
|
+
const status = `HTTP ${result.status}${result.statusText ? ` ${result.statusText}` : ""} (${seconds} s)`;
|
|
76
|
+
if (result.status >= 400) {
|
|
77
|
+
console.error(`${status}: ${errorMessage(result) ?? "request failed"}`);
|
|
78
|
+
process.exitCode = 1;
|
|
79
|
+
}
|
|
80
|
+
else {
|
|
81
|
+
console.error(status);
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
catch (e) {
|
|
85
|
+
console.error(`${CLI_PROGRAM} api: ${e instanceof Error ? e.message : String(e)}`);
|
|
86
|
+
process.exitCode = 1;
|
|
87
|
+
}
|
|
88
|
+
};
|
|
89
|
+
//# sourceMappingURL=api.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"api.js","sourceRoot":"","sources":["../../src/commands/api.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,SAAS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AAC,GAAG,WAAW,SAAS,CAAC,YAAY,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC;QACnF,OAAO,CAAC,QAAQ,GAAG,CAAC,CAAC;IACvB,CAAC;AACH,CAAC,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/commands/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/commands/index.ts"],"names":[],"mappings":"AAUA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AAEjD,YAAY,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AAEjD,eAAO,MAAM,QAAQ,EAAE,MAAM,CAAC,MAAM,EAAE,cAAc,CAWnD,CAAC"}
|
package/dist/commands/index.js
CHANGED
|
@@ -1,9 +1,12 @@
|
|
|
1
|
+
import { api } from "./api.js";
|
|
2
|
+
import { apiKey } from "./api-key.js";
|
|
1
3
|
import { clone } from "./clone.js";
|
|
2
4
|
import { login } from "./login.js";
|
|
3
5
|
import { logout } from "./logout.js";
|
|
4
6
|
import { pull } from "./pull.js";
|
|
5
7
|
import { push } from "./push.js";
|
|
6
8
|
import { status } from "./status.js";
|
|
9
|
+
import { test } from "./test.js";
|
|
7
10
|
import { validate } from "./validate.js";
|
|
8
11
|
export const commands = {
|
|
9
12
|
login,
|
|
@@ -13,5 +16,8 @@ export const commands = {
|
|
|
13
16
|
status,
|
|
14
17
|
push,
|
|
15
18
|
validate,
|
|
19
|
+
test,
|
|
20
|
+
api,
|
|
21
|
+
"api-key": apiKey,
|
|
16
22
|
};
|
|
17
23
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/commands/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,YAAY,CAAC;AACnC,OAAO,EAAE,KAAK,EAAE,MAAM,YAAY,CAAC;AACnC,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AACrC,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AACjC,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AACjC,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AACrC,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AAKzC,MAAM,CAAC,MAAM,QAAQ,GAAmC;IACtD,KAAK;IACL,MAAM;IACN,KAAK;IACL,IAAI;IACJ,MAAM;IACN,IAAI;IACJ,QAAQ;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/commands/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,MAAM,UAAU,CAAC;AAC/B,OAAO,EAAE,MAAM,EAAE,MAAM,cAAc,CAAC;AACtC,OAAO,EAAE,KAAK,EAAE,MAAM,YAAY,CAAC;AACnC,OAAO,EAAE,KAAK,EAAE,MAAM,YAAY,CAAC;AACnC,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AACrC,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AACjC,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AACjC,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AACrC,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AACjC,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AAKzC,MAAM,CAAC,MAAM,QAAQ,GAAmC;IACtD,KAAK;IACL,MAAM;IACN,KAAK;IACL,IAAI;IACJ,MAAM;IACN,IAAI;IACJ,QAAQ;IACR,IAAI;IACJ,GAAG;IACH,SAAS,EAAE,MAAM;CAClB,CAAC"}
|
package/dist/commands/status.js
CHANGED
|
@@ -20,7 +20,7 @@ function printDebugChecksums(d) {
|
|
|
20
20
|
return;
|
|
21
21
|
}
|
|
22
22
|
console.log("");
|
|
23
|
-
console.log("Checksums (MD5 hex, utf-8): manifest = .ab/manifest.json. Disk: .json under ui/lit, ui/navigation, ui/portals, be/entities, and be/
|
|
23
|
+
console.log("Checksums (MD5 hex, utf-8): manifest = .ab/manifest.json. Disk: .json under ui/lit, ui/navigation, ui/portals, be/entities, be/views, be/scenarios, be/capability_profiles, and be/scenario_tests uses canonical JSON; other files use raw UTF-8. Backend trees (be/plv8, be/node) also show Modified when manifest differs from .ab/file-state.json (new manifest row). Added = on-disk file not listed in manifest.");
|
|
24
24
|
if (d.modified.length > 0) {
|
|
25
25
|
console.log("");
|
|
26
26
|
console.log("Modified (detail):");
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"status.js","sourceRoot":"","sources":["../../src/commands/status.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,mBAAmB,EACnB,oBAAoB,GAErB,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EAAE,4BAA4B,EAAE,MAAM,2BAA2B,CAAC;AACzE,OAAO,EAAE,eAAe,EAAE,MAAM,6BAA6B,CAAC;AAC9D,OAAO,EAAE,UAAU,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AACvD,OAAO,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAG7C,SAAS,YAAY,CAAC,KAAa,EAAE,KAAe;IAClD,OAAO,CAAC,GAAG,CAAC,GAAG,KAAK,GAAG,CAAC,CAAC;IACzB,IAAI,KAAK,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QACvB,OAAO,CAAC,GAAG,CAAC,UAAU,CAAC,CAAC;QACxB,OAAO;IACT,CAAC;IACD,KAAK,MAAM,CAAC,IAAI,KAAK,EAAE,CAAC;QACtB,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC;IACxB,CAAC;AACH,CAAC;AAED,SAAS,mBAAmB,CAAC,CAAoB;IA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