@gravity-rail/cli 0.8.0 → 0.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.
package/dist/lib.d.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  import { GravityRailClient, PhoneCall } from '@gravity-rail/sdk';
2
- import { E as EnvironmentConfig, C as CredentialsManager } from './cli-client-context-9KRUt6O-.js';
3
- export { a as ConciergeAppContextPayload, b as buildCliConciergeAppContext } from './cli-client-context-9KRUt6O-.js';
2
+ import { E as EnvironmentConfig, C as CredentialsManager, a as CLICredentials } from './cli-client-context-C5l8lg7h.js';
3
+ export { b as ConciergeAppContextPayload, c as buildCliConciergeAppContext } from './cli-client-context-C5l8lg7h.js';
4
4
 
5
5
  /** Metadata extracted from a paginated API response */
6
6
  interface PaginationMeta {
@@ -114,7 +114,12 @@ declare function detectOutputFormat(explicit?: string): OutputFormat;
114
114
  declare function outputData(data: unknown, opts: OutputOptions, columns?: TableColumn<any>[], paginationMeta?: PaginationMeta, supportsAll?: boolean): void;
115
115
  /** Write a single object to stdout in the requested format */
116
116
  declare function outputSingle<T>(data: T, opts: OutputOptions, columns?: TableColumn<T>[]): void;
117
- /** Common column factory helpers for domain files */
117
+ /** Common column factory helpers for domain files.
118
+ *
119
+ * GR app-facing API wire is camelCase. First-party consumers (CLI, lambdas we
120
+ * own) read that shape only — no snake_case dual-read "bandaid". When the API
121
+ * flips a key, convert the consumer; do not carry both. (#19305)
122
+ */
118
123
  declare const COL: {
119
124
  id: () => TableColumn<any>;
120
125
  uuid: () => TableColumn<any>;
@@ -130,12 +135,13 @@ declare function stderr(msg: string): void;
130
135
 
131
136
  interface GlobalOptions {
132
137
  env: string;
133
- realm?: string;
134
138
  /** Override API base URL (also: GRAVITY_RAIL_API_URL env var). */
135
139
  apiUrl?: string;
136
140
  outputFormat?: string;
137
141
  verbose?: boolean;
138
142
  allowWrite?: boolean;
143
+ /** Named credential profile (`--profile` / GRAVITY_RAIL_PROFILE). */
144
+ profile?: string;
139
145
  }
140
146
  interface PublicGlobalOptions {
141
147
  env?: string;
@@ -144,6 +150,8 @@ interface PublicGlobalOptions {
144
150
  outputFormat?: string;
145
151
  verbose?: boolean;
146
152
  allowWrite?: boolean;
153
+ /** Named credential profile (`--profile` / GRAVITY_RAIL_PROFILE). */
154
+ profile?: string;
147
155
  }
148
156
  interface CommandContext {
149
157
  env: string;
@@ -152,15 +160,24 @@ interface CommandContext {
152
160
  verbose: boolean;
153
161
  allowWrite: boolean;
154
162
  credentialsManager: CredentialsManager;
163
+ /** Resolved credential profile for this invocation. */
164
+ profile: string;
155
165
  }
156
166
  interface AuthenticatedContext extends CommandContext {
157
167
  accessToken: string;
158
168
  apiClient: GravityRailClient;
159
- realmWorkspace?: string;
169
+ /** Default workspace UUID from the profile (dev workspace/member profiles). */
170
+ profileWorkspace?: string;
160
171
  }
161
172
  /** Create a base command context (no auth required) */
162
173
  declare function createContext(opts: GlobalOptions): CommandContext;
163
- /** Create an authenticated command context. Tries realm, env var, then cached token. Never auto-triggers OAuth. */
174
+ /**
175
+ * Create an authenticated command context.
176
+ * Order: GRAVITY_RAIL_API_KEY → named/current profile store. Never auto-triggers OAuth.
177
+ *
178
+ * Dev accounts that used to be selected with `--realm` are now named profiles
179
+ * (import with `gr auth import-dev` after provisioning).
180
+ */
164
181
  declare function createAuthenticatedContext(opts: GlobalOptions): Promise<AuthenticatedContext>;
165
182
  /**
166
183
  * Narrow a handler context to `AuthenticatedContext`.
@@ -319,6 +336,18 @@ interface CrudConfig<T = unknown> {
319
336
  * Default: `false` (safe — never forwards pagination options unless opted in).
320
337
  */
321
338
  paginationSupport?: 'full' | 'client-only' | false;
339
+ /**
340
+ * Optional resolver for the client object that string methods are dispatched
341
+ * against. Defaults to the context's plain `apiClient` (`GravityRailClient`).
342
+ *
343
+ * Domains whose CRUD methods live on an extended/rebound surface (e.g. the
344
+ * gr-cli admin client, where `adminApi(ctx)` lazily binds `*AsAdmin` methods
345
+ * onto the instance) must pass a resolver so the generic dispatcher targets
346
+ * the rebound client instead of the stale bare `apiClient` — otherwise the
347
+ * methods are undefined and dispatch fails with "API method not found".
348
+ * See issue #17508.
349
+ */
350
+ resolveClient?: (ctx: AuthenticatedContext | CommandContext) => unknown;
322
351
  }
323
352
  /**
324
353
  * @deprecated Use `simpleCrudCommands()` for new code — it provides compile-time
@@ -500,8 +529,47 @@ declare function requireDirectoryTrust(opts: DirectoryTrustOptions): Promise<voi
500
529
 
501
530
  declare function devImportLocalCommand(ctx: AuthenticatedContext, workspace: string): Promise<void>;
502
531
 
503
- declare function loginCommand(ctx: CommandContext): Promise<void>;
504
- declare function logoutCommand(ctx: CommandContext): Promise<void>;
532
+ declare function loginCommand(ctx: CommandContext, args?: ParsedArgs): Promise<void>;
533
+ declare function logoutCommand(ctx: CommandContext, args?: ParsedArgs): Promise<void>;
534
+ /** List stored credential profiles for the current environment. */
535
+ declare function authListCommand(ctx: CommandContext): Promise<void>;
536
+ /** Switch the default profile for subsequent commands. */
537
+ declare function authSwitchCommand(ctx: CommandContext, args: ParsedArgs): Promise<void>;
538
+ /**
539
+ * Import account + workspace/member tokens from dev-realms.json into named profiles.
540
+ * Replaces the old per-invocation `--realm` flag.
541
+ */
542
+ declare function authImportDevCommand(ctx: CommandContext, args?: ParsedArgs): Promise<void>;
543
+
544
+ /**
545
+ * Import local/dev-cloud auth tokens from dev-realms.json into gr CLI profiles.
546
+ *
547
+ * Replaces the old `--realm` flag: after import, use
548
+ * yarn gr whoami --profile superadmin
549
+ * yarn gr tasks list --profile acme-demo/acme-admin
550
+ *
551
+ * dev-realms.json remains the provisioner output (and is still used by e2e /
552
+ * site-template tooling). The gr CLI no longer reads it at command time.
553
+ */
554
+
555
+ interface ImportDevProfilesResult {
556
+ path: string;
557
+ imported: number;
558
+ accountProfiles: number;
559
+ memberProfiles: number;
560
+ storePath: string;
561
+ }
562
+ /** Parse dev-realms.json into profile name → credentials (token + optional workspace). */
563
+ declare function profilesFromDevRealms(data: Record<string, unknown>): Record<string, CLICredentials>;
564
+ /**
565
+ * Import all accounts + workspace/member entries from dev-realms into the
566
+ * credential store for `env`. Overwrites matching profile names; leaves
567
+ * unrelated OAuth profiles intact.
568
+ */
569
+ declare function importDevProfiles(credentialsManager: CredentialsManager, env: string, options?: {
570
+ file?: string;
571
+ preferCurrent?: string;
572
+ }): ImportDevProfilesResult;
505
573
 
506
574
  declare function manageCommand(hctx: CommandHandlerContext): Promise<void>;
507
575
  declare function chatCommand(hctx: CommandHandlerContext): Promise<void>;
@@ -510,4 +578,4 @@ declare function organizationsListCommand(ctx: AuthenticatedContext): Promise<vo
510
578
 
511
579
  declare function whoamiCommand(ctx: AuthenticatedContext): Promise<void>;
512
580
 
513
- export { type ArgDef, AuthRequiredError, type AuthenticatedContext, CLIError, COL, type CommandContext, type CommandDef, type CommandHandlerContext, CommandRegistry, type ConciergeChat, type ConciergeMessage, type DomainDef, type GlobalOptions, LIST_PAGINATION_ARGS, type OutputFormat, type OutputOptions, PAGINATION_ARGS, type PaginationMeta, type ParsedArgs, type PublicGlobalOptions, type TableColumn, authBrowserCommand, chatCommand, commandNeedsJsonBody, conciergeCommand, conciergeOutboundCommand, confirmAccountPhoneVerify, createAuthenticatedContext, createConciergeChat, createContext, createPublicAuthenticatedContext, createPublicContext, crudCommands, detectOutputFormat, devImportLocalCommand, extractPaginationMeta, fetchAllCursorPages, fetchAllPages, formatPaginationWarning, getConciergeChat, getConciergeChatMessages, getStartedCommand, handleError, isCursorPaginatedResponse, isDirectoryTrusted, isLikelySeedPhoneNumber, isListResult, isPagePaginatedResponse, isPaginatedResponse, listConciergeChats, listResult, loginCommand, logoutCommand, manageCommand, organizationsListCommand, originateConciergeCall, originateConciergeSms, outputData, outputSingle, parseArgs, parsePaginationArgs, readJsonInput, registerPublicDomains, requireAuth, requireDirectoryTrust, requireNumber, requireString, resolveVoicePhoneNumberId, simpleCrudCommands, startAccountPhoneVerify, stderr, topLevelCommands, unwrapItems, waitForOutboundPhoneCallOutcome, whoamiCommand };
581
+ export { type ArgDef, AuthRequiredError, type AuthenticatedContext, CLIError, COL, type CommandContext, type CommandDef, type CommandHandlerContext, CommandRegistry, type ConciergeChat, type ConciergeMessage, type DomainDef, type GlobalOptions, LIST_PAGINATION_ARGS, type OutputFormat, type OutputOptions, PAGINATION_ARGS, type PaginationMeta, type ParsedArgs, type PublicGlobalOptions, type TableColumn, authBrowserCommand, authImportDevCommand, authListCommand, authSwitchCommand, chatCommand, commandNeedsJsonBody, conciergeCommand, conciergeOutboundCommand, confirmAccountPhoneVerify, createAuthenticatedContext, createConciergeChat, createContext, createPublicAuthenticatedContext, createPublicContext, crudCommands, detectOutputFormat, devImportLocalCommand, extractPaginationMeta, fetchAllCursorPages, fetchAllPages, formatPaginationWarning, getConciergeChat, getConciergeChatMessages, getStartedCommand, handleError, importDevProfiles, isCursorPaginatedResponse, isDirectoryTrusted, isLikelySeedPhoneNumber, isListResult, isPagePaginatedResponse, isPaginatedResponse, listConciergeChats, listResult, loginCommand, logoutCommand, manageCommand, organizationsListCommand, originateConciergeCall, originateConciergeSms, outputData, outputSingle, parseArgs, parsePaginationArgs, profilesFromDevRealms, readJsonInput, registerPublicDomains, requireAuth, requireDirectoryTrust, requireNumber, requireString, resolveVoicePhoneNumberId, simpleCrudCommands, startAccountPhoneVerify, stderr, topLevelCommands, unwrapItems, waitForOutboundPhoneCallOutcome, whoamiCommand };