@api-now/cli 1.9.0 → 1.10.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/README.md +181 -25
- package/dist/index.js +40 -40
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# API NOW! CLI
|
|
2
2
|
|
|
3
|
-
The **API NOW! CLI** is a robust, cross-platform command-line tool designed to manage settings, handle authentication, organize directories/files, and publish assets directly to the Data Catalog from your terminal.
|
|
3
|
+
The **API NOW! CLI** is a robust, cross-platform command-line tool designed to manage settings, handle authentication, organize directories/files, validate and transition data domains, and publish assets directly to the Data Catalog from your terminal.
|
|
4
4
|
|
|
5
5
|
---
|
|
6
6
|
|
|
@@ -10,7 +10,9 @@ The **API NOW! CLI** is a robust, cross-platform command-line tool designed to m
|
|
|
10
10
|
- **Interactive Onboarding**: Guided setup prompts for first-time users to configure organization names and slugs (validated against reserved keywords/taken values).
|
|
11
11
|
- **Default Organization Management**: List organizations and pin a default workspace ID.
|
|
12
12
|
- **Metadata and Media Uploads**: Create, list, and read blueprints, domains, and multimedia assets.
|
|
13
|
-
- **Data
|
|
13
|
+
- **Data Domain Management & Publishing**: Mutate data domains via declarative JSON patch diffing, transition data domain lifecycles (`draft`, `committed`, `published`), bump versions, run pre-publish validation, and publish domains directly to the Data Catalog.
|
|
14
|
+
- **Local & Remote Schema Validation**: Validate Data Domain and API Model schemas from local files, STDIN, or directly from remote organization files.
|
|
15
|
+
- **Data Catalog Publishing**: Publish schemas and datasets to the global/private catalog with automatic semantic versioning support, deprecation, and unpublishing.
|
|
14
16
|
- **Developer Formatting Options**: Toggle outputs between human-friendly ASCII tables and machine-readable JSON.
|
|
15
17
|
|
|
16
18
|
---
|
|
@@ -30,12 +32,15 @@ Once installed, the CLI is available as the `apinow` command.
|
|
|
30
32
|
## Usage & Commands
|
|
31
33
|
|
|
32
34
|
All commands support the following global options (which can be specified before or after any subcommand):
|
|
33
|
-
|
|
35
|
+
|
|
36
|
+
- `--api-url <url>`: Override the target API Server URL (Default: `http://localhost:8080`).
|
|
34
37
|
- `--format <text|json>`: Define the output layout (Default: `text`).
|
|
35
|
-
- `--debug`: Enable debug/verbose logging.
|
|
38
|
+
- `--debug` / `-v, --verbose`: Enable debug/verbose logging.
|
|
36
39
|
|
|
37
40
|
### 1. Configuration (`config`)
|
|
41
|
+
|
|
38
42
|
Read and write persistent CLI configurations stored in the OS settings folder depending on the platform:
|
|
43
|
+
|
|
39
44
|
- **Linux**: `~/.config/apinow-cli/config.json` (or respects `$XDG_CONFIG_HOME`)
|
|
40
45
|
- **macOS**: `~/Library/Preferences/apinow-cli/config.json`
|
|
41
46
|
- **Windows**: `%APPDATA%\apinow-cli\config.json`
|
|
@@ -50,9 +55,16 @@ apinow config get <key>
|
|
|
50
55
|
|
|
51
56
|
# Set a configuration property
|
|
52
57
|
apinow config set <key> <value>
|
|
58
|
+
|
|
59
|
+
# List all current configuration settings
|
|
60
|
+
apinow config list
|
|
61
|
+
|
|
62
|
+
# Reset configuration to default values
|
|
63
|
+
apinow config reset
|
|
53
64
|
```
|
|
54
65
|
|
|
55
66
|
### 2. Authentication (`auth`)
|
|
67
|
+
|
|
56
68
|
Securely log in to the API platform using OAuth2.
|
|
57
69
|
|
|
58
70
|
```bash
|
|
@@ -66,9 +78,10 @@ apinow auth status
|
|
|
66
78
|
apinow auth logout
|
|
67
79
|
```
|
|
68
80
|
|
|
69
|
-
|
|
81
|
+
_Note: On your first login or checking status with no registered organization, an interactive step will automatically guide you through creating your first organization with live slug verification._
|
|
70
82
|
|
|
71
83
|
#### Personal Access Tokens (`auth tokens`)
|
|
84
|
+
|
|
72
85
|
Generate and manage Personal Access Tokens (PATs) for programmatic access.
|
|
73
86
|
|
|
74
87
|
```bash
|
|
@@ -78,14 +91,15 @@ apinow auth tokens list
|
|
|
78
91
|
# Create a new personal access token
|
|
79
92
|
apinow auth tokens create [--name <token_name>] [--expires-at <duration_or_timestamp>]
|
|
80
93
|
|
|
81
|
-
Example:
|
|
82
|
-
apinow auth tokens create --name "
|
|
94
|
+
# Example:
|
|
95
|
+
apinow auth tokens create --name "CI Deploy Token" --expires-at "30 days"
|
|
83
96
|
|
|
84
97
|
# Delete a personal access token by its ID
|
|
85
98
|
apinow auth tokens delete <token_id>
|
|
86
99
|
```
|
|
87
100
|
|
|
88
101
|
### 3. Organizations (`orgs`)
|
|
102
|
+
|
|
89
103
|
Manage organization contexts.
|
|
90
104
|
|
|
91
105
|
```bash
|
|
@@ -100,6 +114,7 @@ apinow orgs set-default <organization_id>
|
|
|
100
114
|
```
|
|
101
115
|
|
|
102
116
|
### 4. Files (`files`)
|
|
117
|
+
|
|
103
118
|
Manage domain and API files in your organizations.
|
|
104
119
|
|
|
105
120
|
```bash
|
|
@@ -107,7 +122,7 @@ Manage domain and API files in your organizations.
|
|
|
107
122
|
apinow files list --org <org_id> --parent <parent_id> --kind <domain|api>
|
|
108
123
|
|
|
109
124
|
# Create file metadata and upload local media
|
|
110
|
-
apinow files create --name "My Domain File" --kind "domain" --org <org_id> --parent <parent_id> --media ./path/to/schema.
|
|
125
|
+
apinow files create --name "My Domain File" --kind "domain" --org <org_id> --parent <parent_id> --media ./path/to/schema.json
|
|
111
126
|
|
|
112
127
|
# Create file metadata and pipe media contents from STDIN
|
|
113
128
|
echo '{"schema": "content"}' | apinow files create --name "My Piped File" --kind "api" --org <org_id> --stdin
|
|
@@ -116,21 +131,155 @@ echo '{"schema": "content"}' | apinow files create --name "My Piped File" --kind
|
|
|
116
131
|
apinow files read --id <file_id> --org <org_id> [--media]
|
|
117
132
|
```
|
|
118
133
|
|
|
119
|
-
### 5. Data
|
|
120
|
-
|
|
134
|
+
### 5. Data Domains (`domain`)
|
|
135
|
+
|
|
136
|
+
Manage Data Domain files, lifecycles, and catalog publications.
|
|
137
|
+
|
|
138
|
+
#### List Data Domains (`domain list`)
|
|
139
|
+
|
|
140
|
+
List all Data Domain files in an organization.
|
|
141
|
+
|
|
142
|
+
```bash
|
|
143
|
+
# List all domain files in an organization
|
|
144
|
+
apinow domain list [--org <org_id>] [--parent <parent_id>]
|
|
145
|
+
```
|
|
146
|
+
|
|
147
|
+
#### Create Data Domain (`domain create`)
|
|
148
|
+
|
|
149
|
+
Create a new Data Domain file record in your organization, with optional local schema or STDIN upload.
|
|
150
|
+
|
|
151
|
+
```bash
|
|
152
|
+
# Create a data domain metadata record
|
|
153
|
+
apinow domain create --name "Billing Domain" [--org <org_id>]
|
|
154
|
+
|
|
155
|
+
# Create a data domain and upload local schema media
|
|
156
|
+
apinow domain create --name "Billing Domain" --media ./domain.json [--org <org_id>]
|
|
157
|
+
|
|
158
|
+
# Create a data domain with schema piped from STDIN
|
|
159
|
+
cat ./domain.json | apinow domain create --name "Piped Domain" --stdin [--org <org_id>]
|
|
160
|
+
```
|
|
161
|
+
|
|
162
|
+
#### Read Data Domain (`domain read`)
|
|
163
|
+
|
|
164
|
+
Read Data Domain file metadata or schema media content.
|
|
165
|
+
|
|
166
|
+
```bash
|
|
167
|
+
# Read domain file metadata
|
|
168
|
+
apinow domain read --file <file_id> [--org <org_id>]
|
|
169
|
+
|
|
170
|
+
# Read domain schema media content (JSON)
|
|
171
|
+
apinow domain read --file <file_id> --media [--org <org_id>]
|
|
172
|
+
```
|
|
173
|
+
|
|
174
|
+
#### Lifecycle Transitions (`domain transition`)
|
|
175
|
+
|
|
176
|
+
Transition the state of a data domain (`draft`, `committed`, `published`).
|
|
177
|
+
|
|
178
|
+
```bash
|
|
179
|
+
# Transition domain to committed state
|
|
180
|
+
apinow domain transition committed --file <file_id> [--org <org_id>]
|
|
181
|
+
|
|
182
|
+
# Transition published domain to draft with a new semantic version
|
|
183
|
+
apinow domain transition draft --file <file_id> --ver 1.1.0 [--org <org_id>]
|
|
184
|
+
```
|
|
185
|
+
|
|
186
|
+
#### Mutating Data Domains (`domain mutate` / `domain apply`)
|
|
187
|
+
|
|
188
|
+
Mutate an existing Data Domain schema by comparing a target local schema file or STDIN stream against the current server version, computing a JSON patch (RFC 6902), and sending the patch to the server using optimistic concurrency control.
|
|
189
|
+
|
|
190
|
+
The target file ID is automatically extracted from the schema's `key` property.
|
|
191
|
+
|
|
192
|
+
```bash
|
|
193
|
+
# Mutate a data domain using a local schema file
|
|
194
|
+
apinow domain mutate ./domain.json [--org <org_id>]
|
|
195
|
+
|
|
196
|
+
# Mutate a data domain via STDIN (e.g. piped from an editor or generator)
|
|
197
|
+
cat ./domain.json | apinow domain mutate --stdin [--org <org_id>]
|
|
198
|
+
|
|
199
|
+
# Using the 'apply' alias
|
|
200
|
+
apinow domain apply ./domain.json
|
|
201
|
+
|
|
202
|
+
# Preview diff operations without applying changes
|
|
203
|
+
apinow domain mutate ./domain.json --dry-run
|
|
204
|
+
|
|
205
|
+
# Options:
|
|
206
|
+
# [file] Path to the local Data Domain schema JSON file
|
|
207
|
+
# --stdin Read domain schema content from STDIN
|
|
208
|
+
# --file <fid> File ID of the data domain (optional, asserts match with schema key)
|
|
209
|
+
# --id <fid> File ID alias
|
|
210
|
+
# --org <oid> Organization ID (optional, defaults to configured default org)
|
|
211
|
+
# --dry-run Compute diff and preview patch operations without applying them
|
|
212
|
+
# --no-validate Skip local pre-flight domain schema validation
|
|
213
|
+
# -y, --yes Automatically accept confirmation prompts for destructive changes
|
|
214
|
+
```
|
|
215
|
+
|
|
216
|
+
#### Publishing Domains (`domain publish`)
|
|
217
|
+
|
|
218
|
+
Validates the domain schema, transitions its lifecycle to `committed`, patches the server-side media file, and publishes the domain and version to the Data Catalog.
|
|
219
|
+
|
|
220
|
+
```bash
|
|
221
|
+
# Publish a data domain file to the Data Catalog
|
|
222
|
+
apinow domain publish --file <file_id> --ver 1.0.0 --scope public --name "Billing Domain" --description "Domain for Billing Services"
|
|
223
|
+
|
|
224
|
+
# Options:
|
|
225
|
+
# --file <fid> File ID of the data domain (prompts interactively if omitted)
|
|
226
|
+
# --org <oid> Organization ID (optional, defaults to configured default org)
|
|
227
|
+
# --ver <ver> Semantic version to publish (e.g. 1.0.0)
|
|
228
|
+
# --scope <scope> Publish scope: public, organization, private (default: "public")
|
|
229
|
+
# --name <name> Name for the catalog entry (defaults to domain name)
|
|
230
|
+
# --description <desc> Description of the catalog entry (defaults to domain description)
|
|
231
|
+
# --lifecycle <lifecycle> Version lifecycle status: dev, beta, stable (default: "stable")
|
|
232
|
+
# --changelog <changelog> Changelog description for this version
|
|
233
|
+
```
|
|
234
|
+
|
|
235
|
+
### 6. Schema Validation (`validate`)
|
|
236
|
+
|
|
237
|
+
Validate local or remote Data Domain and API Model schemas against syntax, modeling rules, and naming conventions.
|
|
238
|
+
|
|
239
|
+
```bash
|
|
240
|
+
# Validate a local Data Domain or API Model schema file
|
|
241
|
+
apinow validate ./domain.json
|
|
242
|
+
|
|
243
|
+
# Validate an API Model against a local Data Domain dependency
|
|
244
|
+
apinow validate ./api.json --domain ./domain.json
|
|
245
|
+
|
|
246
|
+
# Validate a schema streamed via STDIN
|
|
247
|
+
cat domain.json | apinow validate --stdin
|
|
248
|
+
|
|
249
|
+
# Validate a remote file stored in an organization
|
|
250
|
+
apinow validate --org <org_id> --fid <file_id>
|
|
251
|
+
```
|
|
252
|
+
|
|
253
|
+
### 7. Data Catalog (`catalog`)
|
|
254
|
+
|
|
255
|
+
Publish, inspect, and manage published catalog items.
|
|
121
256
|
|
|
122
257
|
```bash
|
|
123
|
-
#
|
|
124
|
-
apinow catalog
|
|
258
|
+
# List all published items in the catalog (or versions of a specific item)
|
|
259
|
+
apinow catalog list [--scope <all|public|organization|private>] [--key <catalog_key>]
|
|
260
|
+
|
|
261
|
+
# Show details of a catalog entry or specific version
|
|
262
|
+
apinow catalog show <catalog_key> [--ver <version>]
|
|
263
|
+
|
|
264
|
+
# Check publication status for a data domain file
|
|
265
|
+
apinow catalog status <file_id> [--org <org_id>]
|
|
266
|
+
|
|
267
|
+
# List APIs depending on a catalog item or specific version
|
|
268
|
+
apinow catalog dependent-apis <catalog_key> [--ver <version>]
|
|
269
|
+
|
|
270
|
+
# Deprecate a catalog entry or specific version
|
|
271
|
+
apinow catalog deprecate <catalog_key> --reason "Superseded by v2" [--ver <version>]
|
|
125
272
|
|
|
126
|
-
#
|
|
127
|
-
apinow catalog
|
|
273
|
+
# Unpublish a catalog entry or specific version
|
|
274
|
+
apinow catalog unpublish <catalog_key> [--ver <version>]
|
|
128
275
|
```
|
|
129
276
|
|
|
130
|
-
###
|
|
277
|
+
### 8. Runtime (`runtime`)
|
|
278
|
+
|
|
131
279
|
Administrative operations for the API runtime. This command allows API Now! platform managers and administrators to modify runtime users directly.
|
|
132
280
|
|
|
133
281
|
#### Bypass Authorization Restrictions
|
|
282
|
+
|
|
134
283
|
By default, the API's semantic pipeline does not allow granting permissions to a user that exceed the permissions of the authenticated caller. Consequently, an API user cannot be granted permissions higher than the lowest permission in the chain.
|
|
135
284
|
|
|
136
285
|
The `runtime users update` command bypasses this restriction by writing updates directly to the runtime database, allowing administrators to designate users with higher permissions or update arbitrary properties.
|
|
@@ -145,26 +294,28 @@ apinow runtime users update --api api-123 --user-id user-123 --property role=adm
|
|
|
145
294
|
|
|
146
295
|
---
|
|
147
296
|
|
|
148
|
-
|
|
149
297
|
## Development
|
|
150
298
|
|
|
151
299
|
### Local Setup & Building
|
|
152
300
|
|
|
153
301
|
> [!NOTE]
|
|
154
302
|
> This project depends on private workspace packages (such as `@api-now/core`) during development and local testing. Before running `npm install`, ensure you have configured a local `.npmrc` file at the root of the workspace with access to the private registry.
|
|
155
|
-
>
|
|
303
|
+
>
|
|
156
304
|
> Example `.npmrc`:
|
|
305
|
+
>
|
|
157
306
|
> ```ini
|
|
158
307
|
> @api-now:registry=https://registry.npmjs.org/
|
|
159
308
|
> //registry.npmjs.org/:_authToken=YOUR_NPM_TOKEN
|
|
160
309
|
> ```
|
|
161
310
|
|
|
162
311
|
1. Clone the repository, set up your `.npmrc`, and install dependencies:
|
|
312
|
+
|
|
163
313
|
```bash
|
|
164
314
|
npm install
|
|
165
315
|
```
|
|
166
316
|
|
|
167
317
|
2. Build the package:
|
|
318
|
+
|
|
168
319
|
```bash
|
|
169
320
|
npm run build
|
|
170
321
|
```
|
|
@@ -178,19 +329,24 @@ apinow runtime users update --api api-123 --user-id user-123 --property role=adm
|
|
|
178
329
|
node dist/index.js [command]
|
|
179
330
|
```
|
|
180
331
|
|
|
181
|
-
### Formatting and
|
|
182
|
-
|
|
332
|
+
### Formatting, Linting, and Type Checking
|
|
333
|
+
|
|
183
334
|
```bash
|
|
335
|
+
# Format source code with Prettier
|
|
184
336
|
npm run format
|
|
185
|
-
```
|
|
186
337
|
|
|
187
|
-
|
|
188
|
-
```bash
|
|
338
|
+
# Run ESLint static analysis
|
|
189
339
|
npm run lint
|
|
340
|
+
|
|
341
|
+
# Run TypeScript compiler type checking
|
|
342
|
+
npm run typecheck
|
|
343
|
+
|
|
344
|
+
# Check unused exports and dependencies
|
|
345
|
+
npm run knip
|
|
190
346
|
```
|
|
191
347
|
|
|
192
|
-
###
|
|
193
|
-
|
|
348
|
+
### Running Tests
|
|
349
|
+
|
|
194
350
|
```bash
|
|
195
|
-
npm run
|
|
351
|
+
npm run test
|
|
196
352
|
```
|