@api-now/cli 1.9.0 → 1.11.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.
Files changed (3) hide show
  1. package/README.md +208 -36
  2. package/dist/index.js +40 -40
  3. 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 Catalog Publishing**: Publish schemas and datasets to the global/private catalog with automatic semantic versioning support.
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,45 +32,72 @@ 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
- - `--api-url <url>`: Override the target API Server URL (Default: `http://localhost:8080`). Note that the platform is actively under development and the final default URL will be set once the platform is officially released.
35
+
34
36
  - `--format <text|json>`: Define the output layout (Default: `text`).
35
- - `--debug`: Enable debug/verbose logging.
37
+ - `--debug` / `-v, --verbose`: Enable debug/verbose logging.
36
38
 
37
39
  ### 1. Configuration (`config`)
38
- Read and write persistent CLI configurations stored in the OS settings folder depending on the platform:
40
+
41
+ Read and manage CLI configurations stored in the OS settings folder depending on the platform:
42
+
39
43
  - **Linux**: `~/.config/apinow-cli/config.json` (or respects `$XDG_CONFIG_HOME`)
40
44
  - **macOS**: `~/Library/Preferences/apinow-cli/config.json`
41
45
  - **Windows**: `%APPDATA%\apinow-cli\config.json`
42
46
 
43
47
  > [!TIP]
44
- > **Local Project Configuration**:
45
- > The CLI and MCP server both support local project-level configuration overrides. If a file named `apinow.json` or `.apinowrc.json` is found in the current working directory or any parent directories, its settings are loaded and merged, with local keys overriding global config settings. This is useful for project-specific settings (like pointing to a local development API URL) without changing global config files.
48
+ > **Local Project Configuration (Single Source of Truth)**:
49
+ > When a file named `apinow.json` or `.apinowrc.json` is found in the current working directory or any parent directories, it is treated as the complete, authoritative single source of truth (SSOT) configuration for the project, replacing the global configuration. This allows project-local test environments with dedicated endpoints, tokens, or organizations without polluting your global configuration.
50
+ >
51
+ > Note that CLI write commands (such as `apinow auth login` and `apinow orgs set-default`) persist updates to your global configuration and will not modify tracked project files.
46
52
 
47
53
  ```bash
48
- # Get a configuration property (e.g. apiUrl, defaultOrg)
54
+ # Get a configuration property (e.g. apiUrl, defaultOrg, activeProfile)
49
55
  apinow config get <key>
50
56
 
51
- # Set a configuration property
52
- apinow config set <key> <value>
57
+ # Reset configuration to default values
58
+ apinow config reset
53
59
  ```
54
60
 
55
61
  ### 2. Authentication (`auth`)
56
- Securely log in to the API platform using OAuth2.
62
+
63
+ Securely log in to the API Now platform using OAuth2.
57
64
 
58
65
  ```bash
59
- # Log in using Google, GitHub, or LinkedIn
66
+ # Log in using Google, GitHub, or LinkedIn (defaults to 'default' profile)
60
67
  apinow auth login <google|github|linkedin>
61
68
 
62
- # Verify current authentication status and user identity details
69
+ # Log in under a specific profile alias with an optional custom API URL
70
+ apinow auth login google --profile work --api-url https://api.apinow.app
71
+
72
+ # Verify current authentication status and active profile details
63
73
  apinow auth status
64
74
 
65
- # Log out and erase stored authentication tokens
66
- apinow auth logout
75
+ # Log out and remove credentials for the active profile (or a specified profile)
76
+ apinow auth logout [--profile <name>]
67
77
  ```
68
78
 
69
- *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.*
79
+ _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._
80
+
81
+ #### Authentication Profiles (`auth profile`)
82
+
83
+ Manage multiple authentication profiles to switch seamlessly between organizations or accounts.
84
+
85
+ ```bash
86
+ # List all configured authentication profiles (active profile marked with *)
87
+ apinow auth profile list
88
+
89
+ # Switch to a different profile
90
+ apinow auth profile use <profile_name>
91
+
92
+ # Switch to a profile and verify that its authentication token is still valid
93
+ apinow auth profile use <profile_name> --verify
94
+
95
+ # Delete a configured profile
96
+ apinow auth profile delete <profile_name>
97
+ ```
70
98
 
71
99
  #### Personal Access Tokens (`auth tokens`)
100
+
72
101
  Generate and manage Personal Access Tokens (PATs) for programmatic access.
73
102
 
74
103
  ```bash
@@ -78,14 +107,15 @@ apinow auth tokens list
78
107
  # Create a new personal access token
79
108
  apinow auth tokens create [--name <token_name>] [--expires-at <duration_or_timestamp>]
80
109
 
81
- Example:
82
- apinow auth tokens create --name "Test Token" --expires-at "30 days"
110
+ # Example:
111
+ apinow auth tokens create --name "CI Deploy Token" --expires-at "30 days"
83
112
 
84
113
  # Delete a personal access token by its ID
85
114
  apinow auth tokens delete <token_id>
86
115
  ```
87
116
 
88
117
  ### 3. Organizations (`orgs`)
118
+
89
119
  Manage organization contexts.
90
120
 
91
121
  ```bash
@@ -100,6 +130,7 @@ apinow orgs set-default <organization_id>
100
130
  ```
101
131
 
102
132
  ### 4. Files (`files`)
133
+
103
134
  Manage domain and API files in your organizations.
104
135
 
105
136
  ```bash
@@ -107,7 +138,7 @@ Manage domain and API files in your organizations.
107
138
  apinow files list --org <org_id> --parent <parent_id> --kind <domain|api>
108
139
 
109
140
  # 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.ts
141
+ apinow files create --name "My Domain File" --kind "domain" --org <org_id> --parent <parent_id> --media ./path/to/schema.json
111
142
 
112
143
  # Create file metadata and pipe media contents from STDIN
113
144
  echo '{"schema": "content"}' | apinow files create --name "My Piped File" --kind "api" --org <org_id> --stdin
@@ -116,21 +147,155 @@ echo '{"schema": "content"}' | apinow files create --name "My Piped File" --kind
116
147
  apinow files read --id <file_id> --org <org_id> [--media]
117
148
  ```
118
149
 
119
- ### 5. Data Catalog (`catalog`)
120
- Publish and browse published catalog items.
150
+ ### 5. Data Domains (`domain`)
151
+
152
+ Manage Data Domain files, lifecycles, and catalog publications.
153
+
154
+ #### List Data Domains (`domain list`)
155
+
156
+ List all Data Domain files in an organization.
157
+
158
+ ```bash
159
+ # List all domain files in an organization
160
+ apinow domain list [--org <org_id>] [--parent <parent_id>]
161
+ ```
162
+
163
+ #### Create Data Domain (`domain create`)
164
+
165
+ Create a new Data Domain file record in your organization, with optional local schema or STDIN upload.
166
+
167
+ ```bash
168
+ # Create a data domain metadata record
169
+ apinow domain create --name "Billing Domain" [--org <org_id>]
170
+
171
+ # Create a data domain and upload local schema media
172
+ apinow domain create --name "Billing Domain" --media ./domain.json [--org <org_id>]
173
+
174
+ # Create a data domain with schema piped from STDIN
175
+ cat ./domain.json | apinow domain create --name "Piped Domain" --stdin [--org <org_id>]
176
+ ```
177
+
178
+ #### Read Data Domain (`domain read`)
179
+
180
+ Read Data Domain file metadata or schema media content.
181
+
182
+ ```bash
183
+ # Read domain file metadata
184
+ apinow domain read --file <file_id> [--org <org_id>]
185
+
186
+ # Read domain schema media content (JSON)
187
+ apinow domain read --file <file_id> --media [--org <org_id>]
188
+ ```
189
+
190
+ #### Lifecycle Transitions (`domain transition`)
191
+
192
+ Transition the state of a data domain (`draft`, `committed`, `published`).
121
193
 
122
194
  ```bash
123
- # Publish a local data domain file to the catalog
124
- apinow catalog publish --file <file_id> --name "Catalog Name" --description "Catalog Description" --scope public --catalog-version 1.0.0
195
+ # Transition domain to committed state
196
+ apinow domain transition committed --file <file_id> [--org <org_id>]
125
197
 
126
- # List all published data domains in the catalog
127
- apinow catalog list --scope <all|public|organization|private> [--key <domain_key>]
198
+ # Transition published domain to draft with a new semantic version
199
+ apinow domain transition draft --file <file_id> --ver 1.1.0 [--org <org_id>]
128
200
  ```
129
201
 
130
- ### 6. Runtime (`runtime`)
202
+ #### Mutating Data Domains (`domain mutate` / `domain apply`)
203
+
204
+ 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.
205
+
206
+ The target file ID is automatically extracted from the schema's `key` property.
207
+
208
+ ```bash
209
+ # Mutate a data domain using a local schema file
210
+ apinow domain mutate ./domain.json [--org <org_id>]
211
+
212
+ # Mutate a data domain via STDIN (e.g. piped from an editor or generator)
213
+ cat ./domain.json | apinow domain mutate --stdin [--org <org_id>]
214
+
215
+ # Using the 'apply' alias
216
+ apinow domain apply ./domain.json
217
+
218
+ # Preview diff operations without applying changes
219
+ apinow domain mutate ./domain.json --dry-run
220
+
221
+ # Options:
222
+ # [file] Path to the local Data Domain schema JSON file
223
+ # --stdin Read domain schema content from STDIN
224
+ # --file <fid> File ID of the data domain (optional, asserts match with schema key)
225
+ # --id <fid> File ID alias
226
+ # --org <oid> Organization ID (optional, defaults to configured default org)
227
+ # --dry-run Compute diff and preview patch operations without applying them
228
+ # --no-validate Skip local pre-flight domain schema validation
229
+ # -y, --yes Automatically accept confirmation prompts for destructive changes
230
+ ```
231
+
232
+ #### Publishing Domains (`domain publish`)
233
+
234
+ 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.
235
+
236
+ ```bash
237
+ # Publish a data domain file to the Data Catalog
238
+ apinow domain publish --file <file_id> --ver 1.0.0 --scope public --name "Billing Domain" --description "Domain for Billing Services"
239
+
240
+ # Options:
241
+ # --file <fid> File ID of the data domain (prompts interactively if omitted)
242
+ # --org <oid> Organization ID (optional, defaults to configured default org)
243
+ # --ver <ver> Semantic version to publish (e.g. 1.0.0)
244
+ # --scope <scope> Publish scope: public, organization, private (default: "public")
245
+ # --name <name> Name for the catalog entry (defaults to domain name)
246
+ # --description <desc> Description of the catalog entry (defaults to domain description)
247
+ # --lifecycle <lifecycle> Version lifecycle status: dev, beta, stable (default: "stable")
248
+ # --changelog <changelog> Changelog description for this version
249
+ ```
250
+
251
+ ### 6. Schema Validation (`validate`)
252
+
253
+ Validate local or remote Data Domain and API Model schemas against syntax, modeling rules, and naming conventions.
254
+
255
+ ```bash
256
+ # Validate a local Data Domain or API Model schema file
257
+ apinow validate ./domain.json
258
+
259
+ # Validate an API Model against a local Data Domain dependency
260
+ apinow validate ./api.json --domain ./domain.json
261
+
262
+ # Validate a schema streamed via STDIN
263
+ cat domain.json | apinow validate --stdin
264
+
265
+ # Validate a remote file stored in an organization
266
+ apinow validate --org <org_id> --fid <file_id>
267
+ ```
268
+
269
+ ### 7. Data Catalog (`catalog`)
270
+
271
+ Publish, inspect, and manage published catalog items.
272
+
273
+ ```bash
274
+ # List all published items in the catalog (or versions of a specific item)
275
+ apinow catalog list [--scope <all|public|organization|private>] [--key <catalog_key>]
276
+
277
+ # Show details of a catalog entry or specific version
278
+ apinow catalog show <catalog_key> [--ver <version>]
279
+
280
+ # Check publication status for a data domain file
281
+ apinow catalog status <file_id> [--org <org_id>]
282
+
283
+ # List APIs depending on a catalog item or specific version
284
+ apinow catalog dependent-apis <catalog_key> [--ver <version>]
285
+
286
+ # Deprecate a catalog entry or specific version
287
+ apinow catalog deprecate <catalog_key> --reason "Superseded by v2" [--ver <version>]
288
+
289
+ # Unpublish a catalog entry or specific version
290
+ apinow catalog unpublish <catalog_key> [--ver <version>]
291
+ ```
292
+
293
+ ### 8. Runtime (`runtime`)
294
+
131
295
  Administrative operations for the API runtime. This command allows API Now! platform managers and administrators to modify runtime users directly.
132
296
 
133
297
  #### Bypass Authorization Restrictions
298
+
134
299
  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
300
 
136
301
  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 +310,28 @@ apinow runtime users update --api api-123 --user-id user-123 --property role=adm
145
310
 
146
311
  ---
147
312
 
148
-
149
313
  ## Development
150
314
 
151
315
  ### Local Setup & Building
152
316
 
153
317
  > [!NOTE]
154
318
  > 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
- >
319
+ >
156
320
  > Example `.npmrc`:
321
+ >
157
322
  > ```ini
158
323
  > @api-now:registry=https://registry.npmjs.org/
159
324
  > //registry.npmjs.org/:_authToken=YOUR_NPM_TOKEN
160
325
  > ```
161
326
 
162
327
  1. Clone the repository, set up your `.npmrc`, and install dependencies:
328
+
163
329
  ```bash
164
330
  npm install
165
331
  ```
166
332
 
167
333
  2. Build the package:
334
+
168
335
  ```bash
169
336
  npm run build
170
337
  ```
@@ -178,19 +345,24 @@ apinow runtime users update --api api-123 --user-id user-123 --property role=adm
178
345
  node dist/index.js [command]
179
346
  ```
180
347
 
181
- ### Formatting and Linting
182
- To format the source code with Prettier:
348
+ ### Formatting, Linting, and Type Checking
349
+
183
350
  ```bash
351
+ # Format source code with Prettier
184
352
  npm run format
185
- ```
186
353
 
187
- To run the ESLint static code analysis checks:
188
- ```bash
354
+ # Run ESLint static analysis
189
355
  npm run lint
356
+
357
+ # Run TypeScript compiler type checking
358
+ npm run typecheck
359
+
360
+ # Check unused exports and dependencies
361
+ npm run knip
190
362
  ```
191
363
 
192
- ### Type Checking
193
- To run the TypeScript compiler in dry-run mode:
364
+ ### Running Tests
365
+
194
366
  ```bash
195
- npm run typecheck
367
+ npm run test
196
368
  ```