@sylphx/sdk 0.3.7 → 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/dist/index.d.ts CHANGED
@@ -19946,6 +19946,16 @@ declare class SylphxError extends Error {
19946
19946
  static isRateLimited(err: unknown): err is SylphxError & {
19947
19947
  code: 'TOO_MANY_REQUESTS';
19948
19948
  };
19949
+ /**
19950
+ * Check if error is an account lockout error (too many failed login attempts).
19951
+ * When true, `error.data?.lockoutUntil` contains the ISO 8601 timestamp when the lockout expires.
19952
+ */
19953
+ static isAccountLocked(err: unknown): err is SylphxError & {
19954
+ code: 'TOO_MANY_REQUESTS';
19955
+ data: {
19956
+ lockoutUntil: string | null;
19957
+ };
19958
+ };
19949
19959
  /**
19950
19960
  * Check if error is a quota exceeded error (plan limit reached)
19951
19961
  */
@@ -21353,11 +21363,16 @@ interface RegisterInput {
21353
21363
  }
21354
21364
  /**
21355
21365
  * Org context claims present in org-scoped tokens.
21366
+ *
21367
+ * After switch-org, the JWT includes `org_permissions` — a flat array of
21368
+ * resolved RBAC permission keys for the member in that org.
21356
21369
  */
21357
21370
  interface OrgTokenPayload {
21358
21371
  org_id: string;
21359
21372
  org_slug: string;
21360
21373
  org_role: string;
21374
+ /** RBAC: resolved permission keys (e.g. ["org:members:read", "payroll:approve"]) */
21375
+ org_permissions?: string[];
21361
21376
  }
21362
21377
  /**
21363
21378
  * Invite a user request payload.
@@ -23788,6 +23803,350 @@ declare function canManageSettings(membership: OrganizationMembership | null): b
23788
23803
  */
23789
23804
  declare function canDeleteOrganization(membership: OrganizationMembership | null): boolean;
23790
23805
 
23806
+ /**
23807
+ * Permission Functions
23808
+ *
23809
+ * Pure functions for permission management — no hidden state.
23810
+ * Each function takes config as the first parameter.
23811
+ *
23812
+ * Uses REST API at /permissions/* for project-scoped operations.
23813
+ * Uses REST API at /orgs/{orgId}/members/{memberId}/permissions for member checks.
23814
+ *
23815
+ * Types are self-contained (not dependent on generated OpenAPI spec) because
23816
+ * the RBAC routes were added after the last spec generation.
23817
+ */
23818
+
23819
+ /**
23820
+ * A permission definition within a project.
23821
+ *
23822
+ * Permissions are the atomic building blocks of RBAC roles.
23823
+ * They use colon-separated keys (e.g. "org:members:read", "payroll:approve").
23824
+ */
23825
+ interface Permission {
23826
+ /** Prefixed permission ID (e.g. "perm_xxx") */
23827
+ id: string;
23828
+ /** Unique key within the project (e.g. "org:members:read") */
23829
+ key: string;
23830
+ /** Human-readable name */
23831
+ name: string;
23832
+ /** Optional description */
23833
+ description: string | null;
23834
+ /** Whether this is a system-defined permission (immutable) */
23835
+ isSystem: boolean;
23836
+ /** ISO 8601 creation timestamp */
23837
+ createdAt: string;
23838
+ }
23839
+ /**
23840
+ * Input for creating a custom permission.
23841
+ */
23842
+ interface CreatePermissionInput {
23843
+ /** Unique key — colon-separated lowercase segments (e.g. "org:leave:approve") */
23844
+ key: string;
23845
+ /** Human-readable name */
23846
+ name: string;
23847
+ /** Optional description */
23848
+ description?: string;
23849
+ }
23850
+ /**
23851
+ * Resolved permissions for a member, including their assigned role.
23852
+ */
23853
+ interface MemberPermissionsResult {
23854
+ /** Prefixed user ID of the member */
23855
+ memberId: string;
23856
+ /** Assigned role (null if no role assigned) */
23857
+ role: {
23858
+ key: string;
23859
+ name: string;
23860
+ } | null;
23861
+ /** Flattened, deduplicated permission keys from all assigned roles */
23862
+ permissions: string[];
23863
+ }
23864
+ /**
23865
+ * List all permissions for the current project.
23866
+ *
23867
+ * Returns both system-defined and custom permissions.
23868
+ * Requires a secret key (server-side only).
23869
+ *
23870
+ * @example
23871
+ * ```typescript
23872
+ * const { permissions } = await listPermissions(config)
23873
+ * console.log(permissions.map(p => p.key))
23874
+ * // ['org:members:read', 'org:members:manage', 'payroll:view', ...]
23875
+ * ```
23876
+ */
23877
+ declare function listPermissions(config: SylphxConfig): Promise<{
23878
+ permissions: Permission[];
23879
+ }>;
23880
+ /**
23881
+ * Create a custom permission for the project.
23882
+ *
23883
+ * Permission keys must be colon-separated lowercase segments
23884
+ * (e.g. "org:leave:approve", "payroll:run").
23885
+ * Requires a secret key (server-side only).
23886
+ *
23887
+ * @example
23888
+ * ```typescript
23889
+ * const { permission } = await createPermission(config, {
23890
+ * key: 'payroll:approve',
23891
+ * name: 'Approve Payroll',
23892
+ * description: 'Can approve payroll runs for the organization',
23893
+ * })
23894
+ * ```
23895
+ */
23896
+ declare function createPermission(config: SylphxConfig, input: CreatePermissionInput): Promise<{
23897
+ permission: Permission;
23898
+ }>;
23899
+ /**
23900
+ * Delete a custom permission by key.
23901
+ *
23902
+ * System permissions cannot be deleted.
23903
+ * Role-permission assignments are removed automatically via cascading delete.
23904
+ * Requires a secret key (server-side only).
23905
+ *
23906
+ * @example
23907
+ * ```typescript
23908
+ * const { success } = await deletePermission(config, 'payroll:approve')
23909
+ * ```
23910
+ */
23911
+ declare function deletePermission(config: SylphxConfig, permissionKey: string): Promise<{
23912
+ success: boolean;
23913
+ }>;
23914
+ /**
23915
+ * Get a member's resolved permissions within an organization.
23916
+ *
23917
+ * Returns the flattened, deduplicated set of permission keys from all
23918
+ * roles assigned to the member. Also returns their current role info.
23919
+ * Requires the caller to be a member of the same organization.
23920
+ *
23921
+ * @example
23922
+ * ```typescript
23923
+ * const result = await getMemberPermissions(config, 'my-org', 'usr_abc123')
23924
+ * console.log(result.permissions)
23925
+ * // ['org:members:read', 'payroll:view', 'payroll:approve']
23926
+ * console.log(result.role)
23927
+ * // { key: 'hr_manager', name: 'HR Manager' }
23928
+ * ```
23929
+ */
23930
+ declare function getMemberPermissions(config: SylphxConfig, orgIdOrSlug: string, memberId: string): Promise<MemberPermissionsResult>;
23931
+ /**
23932
+ * Check if a permission set includes a specific permission.
23933
+ *
23934
+ * Pure function — no API call. Use with permissions from JWT claims
23935
+ * (org_permissions) or from getMemberPermissions().
23936
+ *
23937
+ * @example
23938
+ * ```typescript
23939
+ * const permissions = ['org:members:read', 'payroll:view']
23940
+ * hasPermission(permissions, 'payroll:view') // true
23941
+ * hasPermission(permissions, 'payroll:approve') // false
23942
+ * ```
23943
+ */
23944
+ declare function hasPermission(permissions: string[], required: string): boolean;
23945
+ /**
23946
+ * Check if a permission set includes ANY of the required permissions.
23947
+ *
23948
+ * Pure function — no API call. Returns true if at least one of the
23949
+ * required permissions is present.
23950
+ *
23951
+ * @example
23952
+ * ```typescript
23953
+ * const permissions = ['org:members:read', 'payroll:view']
23954
+ * hasAnyPermission(permissions, ['payroll:view', 'payroll:approve']) // true
23955
+ * hasAnyPermission(permissions, ['admin:full', 'super:admin']) // false
23956
+ * ```
23957
+ */
23958
+ declare function hasAnyPermission(permissions: string[], required: string[]): boolean;
23959
+ /**
23960
+ * Check if a permission set includes ALL of the required permissions.
23961
+ *
23962
+ * Pure function — no API call. Returns true only if every required
23963
+ * permission is present.
23964
+ *
23965
+ * @example
23966
+ * ```typescript
23967
+ * const permissions = ['org:members:read', 'payroll:view', 'payroll:approve']
23968
+ * hasAllPermissions(permissions, ['payroll:view', 'payroll:approve']) // true
23969
+ * hasAllPermissions(permissions, ['payroll:view', 'admin:full']) // false
23970
+ * ```
23971
+ */
23972
+ declare function hasAllPermissions(permissions: string[], required: string[]): boolean;
23973
+
23974
+ /**
23975
+ * Role Functions
23976
+ *
23977
+ * Pure functions for role management — no hidden state.
23978
+ * Each function takes config as the first parameter.
23979
+ *
23980
+ * Uses REST API at /roles/* for project-scoped operations.
23981
+ * Uses REST API at /orgs/{orgId}/members/{memberId}/assign-role for assignment.
23982
+ *
23983
+ * Types are self-contained (not dependent on generated OpenAPI spec) because
23984
+ * the RBAC routes were added after the last spec generation.
23985
+ */
23986
+
23987
+ /**
23988
+ * A role definition within a project.
23989
+ *
23990
+ * Roles bundle permissions into named groups that can be assigned to
23991
+ * organization members (e.g. "HR Manager", "Payroll Admin").
23992
+ */
23993
+ interface Role {
23994
+ /** Prefixed role ID (e.g. "role_xxx") */
23995
+ id: string;
23996
+ /** Unique key within the project (e.g. "hr_manager") */
23997
+ key: string;
23998
+ /** Human-readable name */
23999
+ name: string;
24000
+ /** Optional description */
24001
+ description: string | null;
24002
+ /** Whether this is a system-defined role (metadata immutable) */
24003
+ isSystem: boolean;
24004
+ /** Whether this role is automatically assigned to new org members */
24005
+ isDefault: boolean;
24006
+ /** Display order (lower = higher priority) */
24007
+ sortOrder: number;
24008
+ /** Permission keys assigned to this role */
24009
+ permissions: string[];
24010
+ /** ISO 8601 creation timestamp */
24011
+ createdAt: string;
24012
+ /** ISO 8601 update timestamp (present on roles route response) */
24013
+ updatedAt?: string;
24014
+ }
24015
+ /**
24016
+ * Input for creating a custom role.
24017
+ */
24018
+ interface CreateRoleInput {
24019
+ /** Unique key — lowercase alphanumeric with underscores (e.g. "hr_manager") */
24020
+ key: string;
24021
+ /** Human-readable name */
24022
+ name: string;
24023
+ /** Optional description */
24024
+ description?: string;
24025
+ /** Permission keys to assign to this role */
24026
+ permissions?: string[];
24027
+ /** Whether to auto-assign to new org members */
24028
+ isDefault?: boolean;
24029
+ /** Display order (lower = higher priority) */
24030
+ sortOrder?: number;
24031
+ }
24032
+ /**
24033
+ * Input for updating an existing role.
24034
+ *
24035
+ * System role metadata (name, description) is immutable, but their
24036
+ * permissions can be changed.
24037
+ */
24038
+ interface UpdateRoleInput {
24039
+ /** Human-readable name (ignored for system roles) */
24040
+ name?: string;
24041
+ /** Description (ignored for system roles) */
24042
+ description?: string | null;
24043
+ /** Permission keys to assign (replaces existing) */
24044
+ permissions?: string[];
24045
+ /** Whether to auto-assign to new org members */
24046
+ isDefault?: boolean;
24047
+ /** Display order */
24048
+ sortOrder?: number;
24049
+ }
24050
+ /**
24051
+ * List all roles for the current project.
24052
+ *
24053
+ * Returns both system-defined and custom roles, each with their
24054
+ * assigned permission keys. Requires a secret key (server-side only).
24055
+ *
24056
+ * @example
24057
+ * ```typescript
24058
+ * const { roles } = await listRoles(config)
24059
+ * for (const role of roles) {
24060
+ * console.log(`${role.name}: ${role.permissions.join(', ')}`)
24061
+ * }
24062
+ * ```
24063
+ */
24064
+ declare function listRoles(config: SylphxConfig): Promise<{
24065
+ roles: Role[];
24066
+ }>;
24067
+ /**
24068
+ * Get a single role by key, including its assigned permission keys.
24069
+ *
24070
+ * Requires a secret key (server-side only).
24071
+ *
24072
+ * @example
24073
+ * ```typescript
24074
+ * const { role } = await getRole(config, 'hr_manager')
24075
+ * console.log(role.permissions)
24076
+ * // ['org:members:read', 'payroll:view', 'payroll:approve']
24077
+ * ```
24078
+ */
24079
+ declare function getRole(config: SylphxConfig, roleKey: string): Promise<{
24080
+ role: Role;
24081
+ }>;
24082
+ /**
24083
+ * Create a custom role with optional permission assignments.
24084
+ *
24085
+ * Role keys must be lowercase alphanumeric with underscores
24086
+ * (e.g. "hr_manager", "payroll_admin").
24087
+ * Requires a secret key (server-side only).
24088
+ *
24089
+ * @example
24090
+ * ```typescript
24091
+ * const { role } = await createRole(config, {
24092
+ * key: 'hr_manager',
24093
+ * name: 'HR Manager',
24094
+ * description: 'Can manage employees and approve leave',
24095
+ * permissions: ['org:members:read', 'leave:approve', 'payroll:view'],
24096
+ * })
24097
+ * ```
24098
+ */
24099
+ declare function createRole(config: SylphxConfig, input: CreateRoleInput): Promise<{
24100
+ role: Role;
24101
+ }>;
24102
+ /**
24103
+ * Update a role's metadata and/or permission assignments.
24104
+ *
24105
+ * System role metadata (name, description) is immutable, but their
24106
+ * permissions can be changed. Passing `permissions` replaces the
24107
+ * entire permission set for the role.
24108
+ * Requires a secret key (server-side only).
24109
+ *
24110
+ * @example
24111
+ * ```typescript
24112
+ * const { role } = await updateRole(config, 'hr_manager', {
24113
+ * permissions: ['org:members:read', 'org:members:manage', 'leave:approve'],
24114
+ * })
24115
+ * ```
24116
+ */
24117
+ declare function updateRole(config: SylphxConfig, roleKey: string, input: UpdateRoleInput): Promise<{
24118
+ role: Role;
24119
+ }>;
24120
+ /**
24121
+ * Delete a custom role by key.
24122
+ *
24123
+ * System roles cannot be deleted. Roles with active member assignments
24124
+ * cannot be deleted — reassign members first.
24125
+ * Requires a secret key (server-side only).
24126
+ *
24127
+ * @example
24128
+ * ```typescript
24129
+ * const { success } = await deleteRole(config, 'hr_manager')
24130
+ * ```
24131
+ */
24132
+ declare function deleteRole(config: SylphxConfig, roleKey: string): Promise<{
24133
+ success: boolean;
24134
+ }>;
24135
+ /**
24136
+ * Assign an RBAC role to an organization member.
24137
+ *
24138
+ * Replaces any existing role assignment (single-role mode).
24139
+ * Requires admin access to the organization.
24140
+ *
24141
+ * @example
24142
+ * ```typescript
24143
+ * const { success } = await assignMemberRole(config, 'my-org', 'usr_abc123', 'hr_manager')
24144
+ * ```
24145
+ */
24146
+ declare function assignMemberRole(config: SylphxConfig, orgIdOrSlug: string, memberId: string, roleKey: string): Promise<{
24147
+ success: boolean;
24148
+ }>;
24149
+
23791
24150
  /**
23792
24151
  * Secrets SDK
23793
24152
  *
@@ -25786,4 +26145,4 @@ declare const WorkersClient: {
25786
26145
  }): Promise<WorkerResult>;
25787
26146
  };
25788
26147
 
25789
- export { ACHIEVEMENT_TIER_CONFIG, type AIListModelsOptions, type AIListModelsResponse, type AIMessage, type AIMessageRole, type AIModel, type AIModelInfo, type AIModelsResponse, type AIProvider, type AIRateLimitInfo, type AIRateLimitResponse, type AIRequestType, type AIStreamChunk, type AITool, type AIToolCall, type AIUsageResponse, type AIUsageStats, type AccessTokenPayload, type AchievementCategory, type AchievementCriteria, type AchievementCriterion, type AchievementDefinition, type AchievementTier, type AchievementType, type AchievementUnlockEvent, type AdminUser, AuthenticationError, AuthorizationError, type BalanceResponse, type BatchEvent, type BatchIndexInput, type BatchIndexResult, type Breadcrumb, type BuildLog, type BuildLogHistoryResponse, type CaptureExceptionRequest, type CaptureMessageRequest, type ChatCompletionInput, type ChatCompletionResponse, type ChatInput, type ChatMessage, type ChatResult, type ChatStreamChunk, type CheckoutRequest, type CheckoutResponse, type CircuitBreakerConfig, CircuitBreakerOpenError, type CircuitState, type CommandResult, type ConsentCategory, type ConsentHistoryEntry, type ConsentHistoryResult, type ConsentPurposeDefaults, type ConsentType, type ContentPart, type CreateOrgInput, type CriteriaOperator, type CronInput, type CronSchedule, type DatabaseConnectionInfo, type DatabaseStatus, type DatabaseStatusInfo, type DebugCategory, type DeduplicationConfig, type DeleteDocumentInput, type DeployHistoryResponse, type DeployInfo, type DeployStatus, type DynamicRestClient, ERROR_CODE_STATUS, type EmbedInput, type EmbedResult, type EmbeddingInput, type EmbeddingResponse, type LeaderboardEntry as EngagementLeaderboardEntry, type LeaderboardResult as EngagementLeaderboardResult, type EnvVar, type ErrorCode, type ErrorResponse, type ExceptionFrame, type ExceptionValue, type ExecOptions, type FacetsResponse, type FileInfo, type FileUploadOptions, type FlagContext, type FlagResult, type GetConsentHistoryInput, type GetConsentsInput, type GetFacetsInput, type GetSecretInput, type GetSecretResult, type GetSecretsInput, type GetSecretsResult, type IdentifyInput, type IndexDocumentInput, type IndexDocumentResult, type InviteMemberInput, type InviteUserRequest, type InviteUserResponse, type KvExpireRequest, type KvHgetRequest, type KvHgetallRequest, type KvHsetRequest, type KvIncrRequest, type KvLpushRequest, type KvLrangeRequest, type KvMgetRequest, type KvMsetRequest, type KvRateLimitRequest, type KvRateLimitResult, type KvScanOptions, type KvScanResult, type KvSetOptions, type KvSetRequest, type KvZMember, type KvZaddRequest, type KvZrangeRequest, type LeaderboardAggregation, type LeaderboardDefinition, type LeaderboardEntry$1 as LeaderboardEntry, type LeaderboardOptions, type LeaderboardQueryOptions, type LeaderboardResetPeriod, type LeaderboardResult$1 as LeaderboardResult, type LeaderboardSortDirection, type LinkAnonymousConsentsInput, type ListScheduledEmailsOptions, type ListSecretKeysInput, type ListUsersOptions, type ListUsersResult, type ListWorkersOptions, type ListWorkersResult, type LoginHistoryEntry, type LoginRequest, type LoginResponse, type MeResponse, type MonitoringResponse, type MonitoringSeverity, type NativeStepContext, type NativeTaskDefinition, type TaskRunStatus as NativeTaskRunStatus, NetworkError, NotFoundError, type OrgRole, type OrgTokenPayload, type Organization, type OrganizationInvitation, type OrganizationMember, type OrganizationMembership, type PageInput, type PaginatedResponse, type PaginationInput, type ParsedKey, type Plan, type PortalRequest, type PortalResponse, type PushNotification, type PushNotificationPayload, type PushServiceWorkerConfig, type PushSubscription, RETRYABLE_CODES, RateLimitError, type RealtimeEmitRequest, type RealtimeEmitResponse, type RealtimeHistoryRequest, type RealtimeHistoryResponse, type RecordActivityInput, type RecordActivityResult, type RedeemReferralInput, type RedeemResult, type ReferralCode, type ReferralStats, type RegisterInput, type RegisterRequest, type RegisterResponse, type RestClient, type RestClientConfig, type RestDynamicConfig, type paths as RestPaths, type RetryConfig, type RevokeTokenOptions, type RollbackDeployRequest, type RunWorkerOptions, SandboxClient, type SandboxFile, type SandboxOptions, type ScheduleEmailOptions, type ScheduledEmail, type ScheduledEmailStats, type ScheduledEmailsResult, type SearchInput, type SearchResponse, type SearchResultItem, type SearchStatsResult, type SearchType, type SecretKeyInfo, type SecuritySettings, type SendEmailOptions, type SendResult, type SendTemplatedEmailOptions, type SendToUserOptions, type SessionResult, type SetConsentsInput, type SetEnvVarRequest, type SignedUrlOptions, type SignedUrlResult, StepCompleteSignal, StepSleepSignal, type StreakDefinition, type StreakFrequency, type StreakState, type StreamMessage, type SubmitScoreInput, type SubmitScoreResult, type Subscription, type SuccessResponse, type SylphxConfig, type SylphxConfigInput, SylphxError, type SylphxErrorCode, type SylphxErrorOptions, type TaskInput, type TaskResult, type TaskStatus, type TextCompletionInput, type TextCompletionResponse, TimeoutError, type TokenIntrospectionResult, type TokenResponse, type Tool, type ToolCall, type TrackClickInput, type TrackInput, type TriggerDeployRequest, type TwoFactorVerifyRequest, type UpdateOrgInput, type UploadProgressEvent, type UploadResult, type UpsertDocumentInput, type UpsertDocumentResult, type UsageResponse, type User, type UserAchievement, type UserConsent, type UserProfile, ValidationError, type VisionInput, type WebhookConfig, type WebhookConfigUpdate, type WebhookDeliveriesResult, type WebhookDelivery, type WebhookStats, WorkerHandle, type WorkerLogsResult, type WorkerResourceSpec, type WorkerResult, type WorkerRun, type WorkerStatus, type WorkerVolumeMount, WorkersClient, acceptAllConsents, acceptOrganizationInvitation, batchIndex, canDeleteOrganization, canManageMembers, canManageSettings, cancelScheduledEmail, cancelTask, captureException, captureExceptionRaw, captureMessage, chat, chatStream, checkFlag, complete, createCheckout, createConfig, createCron, createDynamicRestClient, createOrganization, createPortalSession, createRestClient, createServiceWorkerScript, createStepContext, createTasksHandler, createTracker, debugError, debugLog, debugTimer, debugWarn, declineOptionalConsents, deleteCron, deleteDocument, deleteEnvVar, deleteFile, deleteOrganization, deleteUser, disableDebug, embed, enableDebug, exponentialBackoff, extendedSignUp, forgotPassword, generateAnonymousId, getAchievement, getAchievementPoints, getAchievements, getAllFlags, getAllSecrets, getAllStreaks, getBillingBalance, getBillingUsage, getBuildLogHistory, getCircuitBreakerState, getConsentHistory, getConsentTypes, getDatabaseConnectionString, getDatabaseStatus, getDebugMode, getDeployHistory, getDeployStatus, getErrorCode, getErrorMessage, getFacets, getFileInfo, getFileUrl, getFlagPayload, getFlags, getLeaderboard, getMyReferralCode, getOrganization, getOrganizationInvitations, getOrganizationMembers, getOrganizations, getPlans, getPushPreferences, getRealtimeHistory, getReferralLeaderboard, getReferralStats, getRestErrorMessage, getScheduledEmail, getScheduledEmailStats, getSearchStats, getSecret, getSecrets, getSession, getSignedUrl, getStreak, getSubscription, getTask, getUser, getUserByEmail, getUserConsents, getUserLeaderboardRank, getVariant, getWebhookConfig, getWebhookDeliveries, getWebhookDelivery, getWebhookStats, hasConsent, hasError, hasRole, hasSecret, identify, incrementAchievementProgress, indexDocument, initPushServiceWorker, installGlobalDebugHelpers, introspectToken, inviteOrganizationMember, inviteUser, isEmailConfigured, isEnabled, isRetryableError, isSylphxError, kvDelete, kvExists, kvExpire, kvGet, kvGetJSON, kvHget, kvHgetall, kvHset, kvIncr, kvLpush, kvLrange, kvMget, kvMset, kvRateLimit, kvScan, kvSet, kvSetJSON, kvZadd, kvZrange, leaveOrganization, linkAnonymousConsents, listEnvVars, listScheduledEmails, listSecretKeys, listTasks, listUsers, page, parseKey, pauseCron, realtimeEmit, recordStreakActivity, recoverStreak, redeemReferralCode, refreshToken, regenerateReferralCode, registerPush, registerPushServiceWorker, removeOrganizationMember, replayWebhookDelivery, rescheduleEmail, resetCircuitBreaker, resetDebugModeCache, resetPassword, resumeCron, revokeAllTokens, revokeOrganizationInvitation, revokeToken, rollbackDeploy, scheduleEmail, scheduleTask, search, sendEmail, sendEmailToUser, sendPush, sendTemplatedEmail, setConsents, setEnvVar, signIn, signOut, signUp, streamToString, submitScore, suspendUser, switchOrg, toSylphxError, track, trackBatch, trackClick, triggerDeploy, unlockAchievement, unregisterPush, updateOrganization, updateOrganizationMemberRole, updatePushPreferences, updateUser, updateUserMetadata, updateWebhookConfig, uploadAvatar, uploadFile, upsertDocument, verifyEmail, verifySignature as verifyTaskSignature, verifyTwoFactor, withToken };
26148
+ export { ACHIEVEMENT_TIER_CONFIG, type AIListModelsOptions, type AIListModelsResponse, type AIMessage, type AIMessageRole, type AIModel, type AIModelInfo, type AIModelsResponse, type AIProvider, type AIRateLimitInfo, type AIRateLimitResponse, type AIRequestType, type AIStreamChunk, type AITool, type AIToolCall, type AIUsageResponse, type AIUsageStats, type AccessTokenPayload, type AchievementCategory, type AchievementCriteria, type AchievementCriterion, type AchievementDefinition, type AchievementTier, type AchievementType, type AchievementUnlockEvent, type AdminUser, AuthenticationError, AuthorizationError, type BalanceResponse, type BatchEvent, type BatchIndexInput, type BatchIndexResult, type Breadcrumb, type BuildLog, type BuildLogHistoryResponse, type CaptureExceptionRequest, type CaptureMessageRequest, type ChatCompletionInput, type ChatCompletionResponse, type ChatInput, type ChatMessage, type ChatResult, type ChatStreamChunk, type CheckoutRequest, type CheckoutResponse, type CircuitBreakerConfig, CircuitBreakerOpenError, type CircuitState, type CommandResult, type ConsentCategory, type ConsentHistoryEntry, type ConsentHistoryResult, type ConsentPurposeDefaults, type ConsentType, type ContentPart, type CreateOrgInput, type CreatePermissionInput, type CreateRoleInput, type CriteriaOperator, type CronInput, type CronSchedule, type DatabaseConnectionInfo, type DatabaseStatus, type DatabaseStatusInfo, type DebugCategory, type DeduplicationConfig, type DeleteDocumentInput, type DeployHistoryResponse, type DeployInfo, type DeployStatus, type DynamicRestClient, ERROR_CODE_STATUS, type EmbedInput, type EmbedResult, type EmbeddingInput, type EmbeddingResponse, type LeaderboardEntry as EngagementLeaderboardEntry, type LeaderboardResult as EngagementLeaderboardResult, type EnvVar, type ErrorCode, type ErrorResponse, type ExceptionFrame, type ExceptionValue, type ExecOptions, type FacetsResponse, type FileInfo, type FileUploadOptions, type FlagContext, type FlagResult, type GetConsentHistoryInput, type GetConsentsInput, type GetFacetsInput, type GetSecretInput, type GetSecretResult, type GetSecretsInput, type GetSecretsResult, type IdentifyInput, type IndexDocumentInput, type IndexDocumentResult, type InviteMemberInput, type InviteUserRequest, type InviteUserResponse, type KvExpireRequest, type KvHgetRequest, type KvHgetallRequest, type KvHsetRequest, type KvIncrRequest, type KvLpushRequest, type KvLrangeRequest, type KvMgetRequest, type KvMsetRequest, type KvRateLimitRequest, type KvRateLimitResult, type KvScanOptions, type KvScanResult, type KvSetOptions, type KvSetRequest, type KvZMember, type KvZaddRequest, type KvZrangeRequest, type LeaderboardAggregation, type LeaderboardDefinition, type LeaderboardEntry$1 as LeaderboardEntry, type LeaderboardOptions, type LeaderboardQueryOptions, type LeaderboardResetPeriod, type LeaderboardResult$1 as LeaderboardResult, type LeaderboardSortDirection, type LinkAnonymousConsentsInput, type ListScheduledEmailsOptions, type ListSecretKeysInput, type ListUsersOptions, type ListUsersResult, type ListWorkersOptions, type ListWorkersResult, type LoginHistoryEntry, type LoginRequest, type LoginResponse, type MeResponse, type MemberPermissionsResult, type MonitoringResponse, type MonitoringSeverity, type NativeStepContext, type NativeTaskDefinition, type TaskRunStatus as NativeTaskRunStatus, NetworkError, NotFoundError, type OrgRole, type OrgTokenPayload, type Organization, type OrganizationInvitation, type OrganizationMember, type OrganizationMembership, type PageInput, type PaginatedResponse, type PaginationInput, type ParsedKey, type Permission, type Plan, type PortalRequest, type PortalResponse, type PushNotification, type PushNotificationPayload, type PushServiceWorkerConfig, type PushSubscription, RETRYABLE_CODES, RateLimitError, type RealtimeEmitRequest, type RealtimeEmitResponse, type RealtimeHistoryRequest, type RealtimeHistoryResponse, type RecordActivityInput, type RecordActivityResult, type RedeemReferralInput, type RedeemResult, type ReferralCode, type ReferralStats, type RegisterInput, type RegisterRequest, type RegisterResponse, type RestClient, type RestClientConfig, type RestDynamicConfig, type paths as RestPaths, type RetryConfig, type RevokeTokenOptions, type Role, type RollbackDeployRequest, type RunWorkerOptions, SandboxClient, type SandboxFile, type SandboxOptions, type ScheduleEmailOptions, type ScheduledEmail, type ScheduledEmailStats, type ScheduledEmailsResult, type SearchInput, type SearchResponse, type SearchResultItem, type SearchStatsResult, type SearchType, type SecretKeyInfo, type SecuritySettings, type SendEmailOptions, type SendResult, type SendTemplatedEmailOptions, type SendToUserOptions, type SessionResult, type SetConsentsInput, type SetEnvVarRequest, type SignedUrlOptions, type SignedUrlResult, StepCompleteSignal, StepSleepSignal, type StreakDefinition, type StreakFrequency, type StreakState, type StreamMessage, type SubmitScoreInput, type SubmitScoreResult, type Subscription, type SuccessResponse, type SylphxConfig, type SylphxConfigInput, SylphxError, type SylphxErrorCode, type SylphxErrorOptions, type TaskInput, type TaskResult, type TaskStatus, type TextCompletionInput, type TextCompletionResponse, TimeoutError, type TokenIntrospectionResult, type TokenResponse, type Tool, type ToolCall, type TrackClickInput, type TrackInput, type TriggerDeployRequest, type TwoFactorVerifyRequest, type UpdateOrgInput, type UpdateRoleInput, type UploadProgressEvent, type UploadResult, type UpsertDocumentInput, type UpsertDocumentResult, type UsageResponse, type User, type UserAchievement, type UserConsent, type UserProfile, ValidationError, type VisionInput, type WebhookConfig, type WebhookConfigUpdate, type WebhookDeliveriesResult, type WebhookDelivery, type WebhookStats, WorkerHandle, type WorkerLogsResult, type WorkerResourceSpec, type WorkerResult, type WorkerRun, type WorkerStatus, type WorkerVolumeMount, WorkersClient, acceptAllConsents, acceptOrganizationInvitation, assignMemberRole, batchIndex, canDeleteOrganization, canManageMembers, canManageSettings, cancelScheduledEmail, cancelTask, captureException, captureExceptionRaw, captureMessage, chat, chatStream, checkFlag, complete, createCheckout, createConfig, createCron, createDynamicRestClient, createOrganization, createPermission, createPortalSession, createRestClient, createRole, createServiceWorkerScript, createStepContext, createTasksHandler, createTracker, debugError, debugLog, debugTimer, debugWarn, declineOptionalConsents, deleteCron, deleteDocument, deleteEnvVar, deleteFile, deleteOrganization, deletePermission, deleteRole, deleteUser, disableDebug, embed, enableDebug, exponentialBackoff, extendedSignUp, forgotPassword, generateAnonymousId, getAchievement, getAchievementPoints, getAchievements, getAllFlags, getAllSecrets, getAllStreaks, getBillingBalance, getBillingUsage, getBuildLogHistory, getCircuitBreakerState, getConsentHistory, getConsentTypes, getDatabaseConnectionString, getDatabaseStatus, getDebugMode, getDeployHistory, getDeployStatus, getErrorCode, getErrorMessage, getFacets, getFileInfo, getFileUrl, getFlagPayload, getFlags, getLeaderboard, getMemberPermissions, getMyReferralCode, getOrganization, getOrganizationInvitations, getOrganizationMembers, getOrganizations, getPlans, getPushPreferences, getRealtimeHistory, getReferralLeaderboard, getReferralStats, getRestErrorMessage, getRole, getScheduledEmail, getScheduledEmailStats, getSearchStats, getSecret, getSecrets, getSession, getSignedUrl, getStreak, getSubscription, getTask, getUser, getUserByEmail, getUserConsents, getUserLeaderboardRank, getVariant, getWebhookConfig, getWebhookDeliveries, getWebhookDelivery, getWebhookStats, hasAllPermissions, hasAnyPermission, hasConsent, hasError, hasPermission, hasRole, hasSecret, identify, incrementAchievementProgress, indexDocument, initPushServiceWorker, installGlobalDebugHelpers, introspectToken, inviteOrganizationMember, inviteUser, isEmailConfigured, isEnabled, isRetryableError, isSylphxError, kvDelete, kvExists, kvExpire, kvGet, kvGetJSON, kvHget, kvHgetall, kvHset, kvIncr, kvLpush, kvLrange, kvMget, kvMset, kvRateLimit, kvScan, kvSet, kvSetJSON, kvZadd, kvZrange, leaveOrganization, linkAnonymousConsents, listEnvVars, listPermissions, listRoles, listScheduledEmails, listSecretKeys, listTasks, listUsers, page, parseKey, pauseCron, realtimeEmit, recordStreakActivity, recoverStreak, redeemReferralCode, refreshToken, regenerateReferralCode, registerPush, registerPushServiceWorker, removeOrganizationMember, replayWebhookDelivery, rescheduleEmail, resetCircuitBreaker, resetDebugModeCache, resetPassword, resumeCron, revokeAllTokens, revokeOrganizationInvitation, revokeToken, rollbackDeploy, scheduleEmail, scheduleTask, search, sendEmail, sendEmailToUser, sendPush, sendTemplatedEmail, setConsents, setEnvVar, signIn, signOut, signUp, streamToString, submitScore, suspendUser, switchOrg, toSylphxError, track, trackBatch, trackClick, triggerDeploy, unlockAchievement, unregisterPush, updateOrganization, updateOrganizationMemberRole, updatePushPreferences, updateRole, updateUser, updateUserMetadata, updateWebhookConfig, uploadAvatar, uploadFile, upsertDocument, verifyEmail, verifySignature as verifyTaskSignature, verifyTwoFactor, withToken };
package/dist/index.js CHANGED
@@ -49,6 +49,7 @@ __export(index_exports, {
49
49
  WorkersClient: () => WorkersClient,
50
50
  acceptAllConsents: () => acceptAllConsents,
51
51
  acceptOrganizationInvitation: () => acceptOrganizationInvitation,
52
+ assignMemberRole: () => assignMemberRole,
52
53
  batchIndex: () => batchIndex,
53
54
  canDeleteOrganization: () => canDeleteOrganization,
54
55
  canManageMembers: () => canManageMembers,
@@ -67,8 +68,10 @@ __export(index_exports, {
67
68
  createCron: () => createCron,
68
69
  createDynamicRestClient: () => createDynamicRestClient,
69
70
  createOrganization: () => createOrganization,
71
+ createPermission: () => createPermission,
70
72
  createPortalSession: () => createPortalSession,
71
73
  createRestClient: () => createRestClient,
74
+ createRole: () => createRole,
72
75
  createServiceWorkerScript: () => createServiceWorkerScript,
73
76
  createStepContext: () => createStepContext,
74
77
  createTasksHandler: () => createTasksHandler,
@@ -83,6 +86,8 @@ __export(index_exports, {
83
86
  deleteEnvVar: () => deleteEnvVar,
84
87
  deleteFile: () => deleteFile,
85
88
  deleteOrganization: () => deleteOrganization,
89
+ deletePermission: () => deletePermission,
90
+ deleteRole: () => deleteRole,
86
91
  deleteUser: () => deleteUser,
87
92
  disableDebug: () => disableDebug,
88
93
  embed: () => embed,
@@ -116,6 +121,7 @@ __export(index_exports, {
116
121
  getFlagPayload: () => getFlagPayload,
117
122
  getFlags: () => getFlags,
118
123
  getLeaderboard: () => getLeaderboard,
124
+ getMemberPermissions: () => getMemberPermissions,
119
125
  getMyReferralCode: () => getMyReferralCode,
120
126
  getOrganization: () => getOrganization,
121
127
  getOrganizationInvitations: () => getOrganizationInvitations,
@@ -127,6 +133,7 @@ __export(index_exports, {
127
133
  getReferralLeaderboard: () => getReferralLeaderboard,
128
134
  getReferralStats: () => getReferralStats,
129
135
  getRestErrorMessage: () => getRestErrorMessage,
136
+ getRole: () => getRole,
130
137
  getScheduledEmail: () => getScheduledEmail,
131
138
  getScheduledEmailStats: () => getScheduledEmailStats,
132
139
  getSearchStats: () => getSearchStats,
@@ -146,8 +153,11 @@ __export(index_exports, {
146
153
  getWebhookDeliveries: () => getWebhookDeliveries,
147
154
  getWebhookDelivery: () => getWebhookDelivery,
148
155
  getWebhookStats: () => getWebhookStats,
156
+ hasAllPermissions: () => hasAllPermissions,
157
+ hasAnyPermission: () => hasAnyPermission,
149
158
  hasConsent: () => hasConsent,
150
159
  hasError: () => hasError,
160
+ hasPermission: () => hasPermission,
151
161
  hasRole: () => hasRole,
152
162
  hasSecret: () => hasSecret,
153
163
  identify: () => identify,
@@ -184,6 +194,8 @@ __export(index_exports, {
184
194
  leaveOrganization: () => leaveOrganization,
185
195
  linkAnonymousConsents: () => linkAnonymousConsents,
186
196
  listEnvVars: () => listEnvVars,
197
+ listPermissions: () => listPermissions,
198
+ listRoles: () => listRoles,
187
199
  listScheduledEmails: () => listScheduledEmails,
188
200
  listSecretKeys: () => listSecretKeys,
189
201
  listTasks: () => listTasks,
@@ -236,6 +248,7 @@ __export(index_exports, {
236
248
  updateOrganization: () => updateOrganization,
237
249
  updateOrganizationMemberRole: () => updateOrganizationMemberRole,
238
250
  updatePushPreferences: () => updatePushPreferences,
251
+ updateRole: () => updateRole,
239
252
  updateUser: () => updateUser,
240
253
  updateUserMetadata: () => updateUserMetadata,
241
254
  updateWebhookConfig: () => updateWebhookConfig,
@@ -354,6 +367,13 @@ var SylphxError = class _SylphxError extends Error {
354
367
  static isRateLimited(err) {
355
368
  return err instanceof _SylphxError && err.code === "TOO_MANY_REQUESTS";
356
369
  }
370
+ /**
371
+ * Check if error is an account lockout error (too many failed login attempts).
372
+ * When true, `error.data?.lockoutUntil` contains the ISO 8601 timestamp when the lockout expires.
373
+ */
374
+ static isAccountLocked(err) {
375
+ return err instanceof _SylphxError && err.code === "TOO_MANY_REQUESTS" && err.data?.code === "ACCOUNT_LOCKED";
376
+ }
357
377
  /**
358
378
  * Check if error is a quota exceeded error (plan limit reached)
359
379
  */
@@ -2936,6 +2956,86 @@ function canDeleteOrganization(membership) {
2936
2956
  return hasRole(membership, "super_admin");
2937
2957
  }
2938
2958
 
2959
+ // src/permissions.ts
2960
+ async function listPermissions(config) {
2961
+ return callApi(config, "/permissions");
2962
+ }
2963
+ async function createPermission(config, input) {
2964
+ return callApi(config, "/permissions", {
2965
+ method: "POST",
2966
+ body: input
2967
+ });
2968
+ }
2969
+ async function deletePermission(config, permissionKey) {
2970
+ return callApi(config, `/permissions/${permissionKey}`, {
2971
+ method: "DELETE"
2972
+ });
2973
+ }
2974
+ async function getMemberPermissions(config, orgIdOrSlug, memberId) {
2975
+ return callApi(
2976
+ config,
2977
+ `/orgs/${orgIdOrSlug}/members/${memberId}/permissions`
2978
+ );
2979
+ }
2980
+ function hasPermission(permissions, required) {
2981
+ return permissions.includes(required);
2982
+ }
2983
+ function hasAnyPermission(permissions, required) {
2984
+ return required.some((perm) => permissions.includes(perm));
2985
+ }
2986
+ function hasAllPermissions(permissions, required) {
2987
+ return required.every((perm) => permissions.includes(perm));
2988
+ }
2989
+
2990
+ // src/roles.ts
2991
+ async function listRoles(config) {
2992
+ return callApi(config, "/roles");
2993
+ }
2994
+ async function getRole(config, roleKey) {
2995
+ return callApi(config, `/roles/${roleKey}`);
2996
+ }
2997
+ async function createRole(config, input) {
2998
+ const body = {
2999
+ key: input.key,
3000
+ name: input.name
3001
+ };
3002
+ if (input.description !== void 0) body.description = input.description;
3003
+ if (input.permissions !== void 0) body.permissionKeys = input.permissions;
3004
+ if (input.isDefault !== void 0) body.isDefault = input.isDefault;
3005
+ if (input.sortOrder !== void 0) body.sortOrder = input.sortOrder;
3006
+ return callApi(config, "/roles", {
3007
+ method: "POST",
3008
+ body
3009
+ });
3010
+ }
3011
+ async function updateRole(config, roleKey, input) {
3012
+ const body = {};
3013
+ if (input.name !== void 0) body.name = input.name;
3014
+ if (input.description !== void 0) body.description = input.description;
3015
+ if (input.permissions !== void 0) body.permissionKeys = input.permissions;
3016
+ if (input.isDefault !== void 0) body.isDefault = input.isDefault;
3017
+ if (input.sortOrder !== void 0) body.sortOrder = input.sortOrder;
3018
+ return callApi(config, `/roles/${roleKey}`, {
3019
+ method: "PUT",
3020
+ body
3021
+ });
3022
+ }
3023
+ async function deleteRole(config, roleKey) {
3024
+ return callApi(config, `/roles/${roleKey}`, {
3025
+ method: "DELETE"
3026
+ });
3027
+ }
3028
+ async function assignMemberRole(config, orgIdOrSlug, memberId, roleKey) {
3029
+ return callApi(
3030
+ config,
3031
+ `/orgs/${orgIdOrSlug}/members/${memberId}/assign-role`,
3032
+ {
3033
+ method: "PUT",
3034
+ body: { roleKey }
3035
+ }
3036
+ );
3037
+ }
3038
+
2939
3039
  // src/secrets.ts
2940
3040
  async function getSecret(config, input) {
2941
3041
  return callApi(config, "/secrets/get", {
@@ -3784,6 +3884,7 @@ function sleep2(ms) {
3784
3884
  WorkersClient,
3785
3885
  acceptAllConsents,
3786
3886
  acceptOrganizationInvitation,
3887
+ assignMemberRole,
3787
3888
  batchIndex,
3788
3889
  canDeleteOrganization,
3789
3890
  canManageMembers,
@@ -3802,8 +3903,10 @@ function sleep2(ms) {
3802
3903
  createCron,
3803
3904
  createDynamicRestClient,
3804
3905
  createOrganization,
3906
+ createPermission,
3805
3907
  createPortalSession,
3806
3908
  createRestClient,
3909
+ createRole,
3807
3910
  createServiceWorkerScript,
3808
3911
  createStepContext,
3809
3912
  createTasksHandler,
@@ -3818,6 +3921,8 @@ function sleep2(ms) {
3818
3921
  deleteEnvVar,
3819
3922
  deleteFile,
3820
3923
  deleteOrganization,
3924
+ deletePermission,
3925
+ deleteRole,
3821
3926
  deleteUser,
3822
3927
  disableDebug,
3823
3928
  embed,
@@ -3851,6 +3956,7 @@ function sleep2(ms) {
3851
3956
  getFlagPayload,
3852
3957
  getFlags,
3853
3958
  getLeaderboard,
3959
+ getMemberPermissions,
3854
3960
  getMyReferralCode,
3855
3961
  getOrganization,
3856
3962
  getOrganizationInvitations,
@@ -3862,6 +3968,7 @@ function sleep2(ms) {
3862
3968
  getReferralLeaderboard,
3863
3969
  getReferralStats,
3864
3970
  getRestErrorMessage,
3971
+ getRole,
3865
3972
  getScheduledEmail,
3866
3973
  getScheduledEmailStats,
3867
3974
  getSearchStats,
@@ -3881,8 +3988,11 @@ function sleep2(ms) {
3881
3988
  getWebhookDeliveries,
3882
3989
  getWebhookDelivery,
3883
3990
  getWebhookStats,
3991
+ hasAllPermissions,
3992
+ hasAnyPermission,
3884
3993
  hasConsent,
3885
3994
  hasError,
3995
+ hasPermission,
3886
3996
  hasRole,
3887
3997
  hasSecret,
3888
3998
  identify,
@@ -3919,6 +4029,8 @@ function sleep2(ms) {
3919
4029
  leaveOrganization,
3920
4030
  linkAnonymousConsents,
3921
4031
  listEnvVars,
4032
+ listPermissions,
4033
+ listRoles,
3922
4034
  listScheduledEmails,
3923
4035
  listSecretKeys,
3924
4036
  listTasks,
@@ -3971,6 +4083,7 @@ function sleep2(ms) {
3971
4083
  updateOrganization,
3972
4084
  updateOrganizationMemberRole,
3973
4085
  updatePushPreferences,
4086
+ updateRole,
3974
4087
  updateUser,
3975
4088
  updateUserMetadata,
3976
4089
  updateWebhookConfig,