@squidcloud/client
Version:
A typescript implementation of the Squid client
93 lines (92 loc) • 2.8 kB
TypeScript
/**
* Status lifecycle for management API keys.
* Keys must be suspended before they can be deleted.
* @category ManagementApiKey
*/
export type ManagementApiKeyStatus = 'active' | 'suspended' | 'deleted';
/**
* Prefix for all management API keys.
* Used to identify and validate management keys.
* @category ManagementApiKey
*/
export declare const MANAGEMENT_API_KEY_PREFIX = "squid_mgmt_";
/**
* Represents a user-level management API key.
* These keys provide programmatic access to manage organizations and applications
* where the user is an admin.
* @category ManagementApiKey
*/
export interface ManagementApiKey {
/** Unique identifier for the API key */
id: string;
/** The user ID who owns this key */
userId: string;
/** Optional description for the key */
description?: string;
/** Current status of the key */
status: ManagementApiKeyStatus;
/** Timestamp when the key was created */
createdAt: Date;
/** Timestamp when the key was last updated */
updatedAt: Date;
/** Timestamp when the key was last used, if ever */
lastUsedAt?: Date;
}
/**
* Request to create a new management API key.
* @category ManagementApiKey
*/
export interface CreateManagementApiKeyRequest {
/** Optional description for the key */
description?: string;
}
/**
* Response when creating a new management API key.
* The keyValue is only returned once during creation.
* @category ManagementApiKey
*/
export interface CreateManagementApiKeyResponse {
/** The created key metadata */
key: ManagementApiKey;
/** The raw key value (only returned once during creation) */
keyValue: string;
}
/**
* Request to update a management API key's status.
* @category ManagementApiKey
*/
export interface UpdateManagementApiKeyRequest {
/** The ID of the key to update */
keyId: string;
/** New status (can only toggle between active and suspended) */
status: 'active' | 'suspended';
}
/**
* Request to delete a management API key.
* The key must be suspended before deletion.
* @category ManagementApiKey
*/
export interface DeleteManagementApiKeyRequest {
/** The ID of the key to delete */
keyId: string;
}
/**
* Response containing a list of user's management API keys.
* @category ManagementApiKey
*/
export interface ListManagementApiKeysResponse {
/** List of management API keys (without key values) */
keys: ManagementApiKey[];
}
/**
* Response from validating a management API key.
* @category ManagementApiKey
*/
export interface ValidateManagementApiKeyResponse {
/** Whether the key is valid and active */
valid: boolean;
/** The user ID associated with the key (if valid) */
userId?: string;
/** The key ID (if valid) */
keyId?: string;
}