diff --git a/packages/core/src/infrastructure/RequestHelper.ts b/packages/core/src/infrastructure/RequestHelper.ts index adcfc503..ee95434f 100644 --- a/packages/core/src/infrastructure/RequestHelper.ts +++ b/packages/core/src/infrastructure/RequestHelper.ts @@ -25,6 +25,10 @@ export interface ShowExpanded { showExpanded?: E; } +export interface AsAdmin { + asAdmin?: A; +} + export type BaseRequestOptions = Sudo & ShowExpanded & { [Key in string]?: any }; diff --git a/packages/core/src/resources/Commits.ts b/packages/core/src/resources/Commits.ts index 4b04d150..3d0f26d0 100644 --- a/packages/core/src/resources/Commits.ts +++ b/packages/core/src/resources/Commits.ts @@ -8,7 +8,7 @@ import type { ShowExpanded, Sudo, } from '../infrastructure'; -import type { UserSchema } from './Users'; +import type { SimpleUserSchema } from './Users'; import type { AllMergeRequestsOptions, MergeRequestSchema } from './MergeRequests'; import type { DiscussionNoteSchema, DiscussionSchema } from '../templates/ResourceDiscussions'; import type { CommitablePipelineStatus } from './Pipelines'; @@ -111,7 +111,7 @@ export type CommitSignatureSchema = export interface CondensedCommitCommentSchema extends Record { note: string; - author: MappedOmit; + author: MappedOmit; } export interface CommitCommentSchema extends CondensedCommitCommentSchema { @@ -137,7 +137,7 @@ export interface CommitStatusSchema extends Record { started_at?: string; name: string; allow_failure: boolean; - author: MappedOmit; + author: MappedOmit; description?: string; sha: string; target_url: string; diff --git a/packages/core/src/resources/Deployments.ts b/packages/core/src/resources/Deployments.ts index 9466009e..256ed3f9 100644 --- a/packages/core/src/resources/Deployments.ts +++ b/packages/core/src/resources/Deployments.ts @@ -9,7 +9,7 @@ import type { } from '../infrastructure'; import type { CommitSchema } from './Commits'; import type { PipelineSchema } from './Pipelines'; -import type { UserSchema } from './Users'; +import type { SimpleUserSchema } from './Users'; import type { RunnerSchema } from './Runners'; import type { EnvironmentSchema } from './Environments'; import type { AllMergeRequestsOptions, MergeRequestSchema } from './MergeRequests'; @@ -29,12 +29,12 @@ export interface DeployableSchema extends Record { coverage?: string; created_at?: string; finished_at?: string; - user?: UserSchema; + user?: SimpleUserSchema; pipeline?: PipelineSchema; } export interface DeploymentApprovalStatusSchema extends Record { - user: UserSchema; + user: SimpleUserSchema; status: 'approved' | 'rejected'; created_at: string; comment: string; @@ -48,7 +48,7 @@ export interface DeploymentSchema extends Record { created_at: string; updated_at: string; status: DeploymentStatus; - user: UserSchema; + user: SimpleUserSchema; deployable: DeployableSchema; environment: EnvironmentSchema; pending_approval_count?: number; diff --git a/packages/core/src/resources/EpicLinks.ts b/packages/core/src/resources/EpicLinks.ts index 2fcab8b6..fa3bd352 100644 --- a/packages/core/src/resources/EpicLinks.ts +++ b/packages/core/src/resources/EpicLinks.ts @@ -7,7 +7,7 @@ import type { ShowExpanded, Sudo, } from '../infrastructure'; -import { UserSchema } from './Users'; +import { SimpleUserSchema } from './Users'; export interface CondensedEpicLinkSchema extends Record { id: number; @@ -29,7 +29,7 @@ export interface EpicLinkSchema extends Record { parent_id: number; title: string; description: string; - author: UserSchema; + author: SimpleUserSchema; start_date?: string; start_date_is_fixed: boolean; start_date_fixed?: string; diff --git a/packages/core/src/resources/Epics.ts b/packages/core/src/resources/Epics.ts index 185b3888..12b3a428 100644 --- a/packages/core/src/resources/Epics.ts +++ b/packages/core/src/resources/Epics.ts @@ -9,7 +9,7 @@ import type { Sudo, } from '../infrastructure'; import type { TodoSchema } from './TodoLists'; -import type { UserSchema } from './Users'; +import type { SimpleUserSchema } from './Users'; import type { GroupSchema } from './Groups'; import type { SimpleLabelSchema } from '../templates/ResourceLabels'; @@ -29,7 +29,7 @@ export interface EpicSchema extends Record { relative: string; full: string; }; - author: MappedOmit; + author: MappedOmit; start_date?: string; start_date_is_fixed: boolean; start_date_fixed?: string; diff --git a/packages/core/src/resources/Events.ts b/packages/core/src/resources/Events.ts index 4e6deefc..f3870f2e 100644 --- a/packages/core/src/resources/Events.ts +++ b/packages/core/src/resources/Events.ts @@ -8,7 +8,7 @@ import type { PaginationRequestOptions, PaginationTypes, } from '../infrastructure'; -import { UserSchema } from './Users'; +import { SimpleUserSchema } from './Users'; export type AllEventOptions = { action?: @@ -40,7 +40,7 @@ export interface EventSchema extends Record { author_id: number; target_title: string; created_at: string; - author: MappedOmit; + author: MappedOmit; author_username: string; } diff --git a/packages/core/src/resources/Groups.ts b/packages/core/src/resources/Groups.ts index e6884765..5f80bf1d 100644 --- a/packages/core/src/resources/Groups.ts +++ b/packages/core/src/resources/Groups.ts @@ -9,7 +9,7 @@ import type { Sudo, } from '../infrastructure'; import type { CondensedProjectSchema, ProjectSchema } from './Projects'; -import type { UserSchema } from './Users'; +import type { SimpleUserSchema } from './Users'; import type { CustomAttributeSchema } from '../templates/ResourceCustomAttributes'; import { AccessLevel } from '../constants'; @@ -304,8 +304,8 @@ export class Groups extends BaseResource { allProvisionedUsers( groupId: string | number, options?: AllProvisionedUsersOptions & PaginationRequestOptions

& Sudo & ShowExpanded, - ): Promise> { - return RequestHelper.get()( + ): Promise> { + return RequestHelper.get()( this, endpoint`groups/${groupId}/provisioned_users`, options, diff --git a/packages/core/src/resources/IssueLinks.ts b/packages/core/src/resources/IssueLinks.ts index 76b473ff..2c77541b 100644 --- a/packages/core/src/resources/IssueLinks.ts +++ b/packages/core/src/resources/IssueLinks.ts @@ -8,7 +8,7 @@ import type { ShowExpanded, Sudo, } from '../infrastructure'; -import { UserSchema } from './Users'; +import { SimpleUserSchema } from './Users'; import { MilestoneSchema } from '../templates/ResourceMilestones'; export interface IssueLinkSchema extends Record { @@ -19,9 +19,9 @@ export interface IssueLinkSchema extends Record { state: string; description: string; weight?: number; - author: MappedOmit; + author: MappedOmit; milestone: MilestoneSchema; - assignees?: MappedOmit[]; + assignees?: MappedOmit[]; title: string; labels?: string[]; user_notes_count: number; diff --git a/packages/core/src/resources/Issues.ts b/packages/core/src/resources/Issues.ts index b41b2a5e..0345ff9a 100644 --- a/packages/core/src/resources/Issues.ts +++ b/packages/core/src/resources/Issues.ts @@ -11,7 +11,7 @@ import type { Sudo, UserAgentDetailSchema, } from '../infrastructure'; -import type { UserSchema } from './Users'; +import type { SimpleUserSchema } from './Users'; import type { MergeRequestSchema } from './MergeRequests'; import type { TodoSchema } from './TodoLists'; import type { MetricImageSchema } from './AlertManagement'; @@ -30,10 +30,10 @@ export interface IssueSchema extends Record { description: string; health_status?: string; weight?: number; - author: MappedOmit; + author: MappedOmit; milestone: MilestoneSchema; project_id: number; - assignees?: MappedOmit[]; + assignees?: MappedOmit[]; type: string; updated_at: string; closed_at?: string; @@ -241,8 +241,8 @@ export class Issues extends BaseResource { projectId: string | number, issueIId: number, options?: Sudo & ShowExpanded, - ): Promise[], C, E, void>> { - return RequestHelper.get[]>()( + ): Promise[], C, E, void>> { + return RequestHelper.get[]>()( this, endpoint`projects/${projectId}/issues/${issueIId}/participants`, options, diff --git a/packages/core/src/resources/Jobs.ts b/packages/core/src/resources/Jobs.ts index 335bdf62..30a20a1e 100644 --- a/packages/core/src/resources/Jobs.ts +++ b/packages/core/src/resources/Jobs.ts @@ -12,7 +12,7 @@ import type { import type { SimpleProjectSchema } from './Projects'; import type { CondensedCommitSchema } from './Commits'; import type { RunnerSchema } from './Runners'; -import type { ExpandedUserSchema, UserSchema } from './Users'; +import type { ExpandedUserSchema, SimpleUserSchema } from './Users'; import type { PipelineSchema } from './Pipelines'; export type JobScope = @@ -105,7 +105,7 @@ export interface JobKubernetesAgentsSchema extends Record { job: CondensedJobSchema; pipeline: PipelineSchema; project: MappedOmit; - user: UserSchema; + user: SimpleUserSchema; } export interface JobVariableAttributeOption extends Record { diff --git a/packages/core/src/resources/MergeRequestApprovals.ts b/packages/core/src/resources/MergeRequestApprovals.ts index ecc84f30..2fadb5de 100644 --- a/packages/core/src/resources/MergeRequestApprovals.ts +++ b/packages/core/src/resources/MergeRequestApprovals.ts @@ -1,7 +1,7 @@ import { BaseResource } from '@gitbeaker/requester-utils'; import { RequestHelper, endpoint } from '../infrastructure'; import type { GitlabAPIResponse, MappedOmit, ShowExpanded, Sudo } from '../infrastructure'; -import type { UserSchema } from './Users'; +import type { SimpleUserSchema } from './Users'; import type { GroupSchema } from './Groups'; import type { ProtectedBranchSchema } from './ProtectedBranches'; @@ -15,7 +15,7 @@ export interface ProjectLevelMergeRequestApprovalSchema extends Record; + user: MappedOmit; } export interface MergeRequestLevelMergeRequestApprovalSchema extends Record { @@ -37,9 +37,9 @@ export interface ApprovalRuleSchema extends Record { id: number; name: string; rule_type: string; - eligible_approvers?: MappedOmit[]; + eligible_approvers?: MappedOmit[]; approvals_required: number; - users?: MappedOmit[]; + users?: MappedOmit[]; groups?: GroupSchema[]; contains_hidden_groups: boolean; overridden: boolean; diff --git a/packages/core/src/resources/MergeRequests.ts b/packages/core/src/resources/MergeRequests.ts index aafed2f6..d43db5fe 100644 --- a/packages/core/src/resources/MergeRequests.ts +++ b/packages/core/src/resources/MergeRequests.ts @@ -15,7 +15,7 @@ import type { IssueSchema, TimeStatsSchema } from './Issues'; import type { ExpandedPipelineSchema, PipelineSchema } from './Pipelines'; import type { SimpleProjectSchema } from './Projects'; import type { TodoSchema } from './TodoLists'; -import type { UserSchema } from './Users'; +import type { SimpleUserSchema } from './Users'; import type { MilestoneSchema } from '../templates/ResourceMilestones'; import type { SimpleLabelSchema } from '../templates/ResourceLabels'; @@ -91,19 +91,19 @@ export interface CondensedMergeRequestSchema extends Record { } export interface MergeRequestSchema extends CondensedMergeRequestSchema { - merged_by: MappedOmit | null; + merged_by: MappedOmit | null; merged_at: string | null; - closed_by: MappedOmit | null; + closed_by: MappedOmit | null; closed_at: string | null; target_branch: string; source_branch: string; user_notes_count: number; upvotes: number; downvotes: number; - author: MappedOmit; - assignees: MappedOmit[] | null; - assignee: MappedOmit | null; - reviewers: MappedOmit[] | null; + author: MappedOmit; + assignees: MappedOmit[] | null; + assignee: MappedOmit | null; + reviewers: MappedOmit[] | null; source_project_id: number; target_project_id: number; labels: string[] | SimpleLabelSchema[]; @@ -394,8 +394,8 @@ export class MergeRequests extends BaseResource { projectId: string | number, mergerequestIId: number, options?: Sudo & ShowExpanded, - ): Promise[], C, E, void>> { - return RequestHelper.get[]>()( + ): Promise[], C, E, void>> { + return RequestHelper.get[]>()( this, endpoint`projects/${projectId}/merge_requests/${mergerequestIId}/participants`, options, diff --git a/packages/core/src/resources/MergeTrains.ts b/packages/core/src/resources/MergeTrains.ts index 0317e114..9d316436 100644 --- a/packages/core/src/resources/MergeTrains.ts +++ b/packages/core/src/resources/MergeTrains.ts @@ -9,14 +9,14 @@ import type { ShowExpanded, Sudo, } from '../infrastructure'; -import type { UserSchema } from './Users'; +import type { SimpleUserSchema } from './Users'; import type { PipelineSchema } from './Pipelines'; import type { CondensedMergeRequestSchema } from './MergeRequests'; export interface MergeTrainSchema extends Record { id: number; merge_request: CondensedMergeRequestSchema; - user: MappedOmit; + user: MappedOmit; pipeline: PipelineSchema; created_at: string; updated_at: string; diff --git a/packages/core/src/resources/PipelineSchedules.ts b/packages/core/src/resources/PipelineSchedules.ts index a8e6e7d4..e53cbf13 100644 --- a/packages/core/src/resources/PipelineSchedules.ts +++ b/packages/core/src/resources/PipelineSchedules.ts @@ -8,7 +8,7 @@ import type { ShowExpanded, Sudo, } from '../infrastructure'; -import type { UserSchema } from './Users'; +import type { SimpleUserSchema } from './Users'; import type { PipelineSchema } from './Pipelines'; import type { PipelineVariableSchema } from './PipelineScheduleVariables'; @@ -22,7 +22,7 @@ export interface CondensedPipelineScheduleSchema extends Record active: boolean; created_at: string; updated_at: string; - owner: MappedOmit; + owner: MappedOmit; } export interface PipelineScheduleSchema extends CondensedPipelineScheduleSchema { diff --git a/packages/core/src/resources/PipelineTriggerTokens.ts b/packages/core/src/resources/PipelineTriggerTokens.ts index 00e9b61b..776f5c67 100644 --- a/packages/core/src/resources/PipelineTriggerTokens.ts +++ b/packages/core/src/resources/PipelineTriggerTokens.ts @@ -9,7 +9,7 @@ import type { Sudo, } from '../infrastructure'; import type { ExpandedPipelineSchema } from './Pipelines'; -import type { UserSchema } from './Users'; +import type { SimpleUserSchema } from './Users'; export interface PipelineTriggerTokenSchema extends Record { id: number; @@ -18,7 +18,7 @@ export interface PipelineTriggerTokenSchema extends Record { last_used: string | null; token: string; updated_at: string; - owner: MappedOmit | null; + owner: MappedOmit | null; } export class PipelineTriggerTokens extends BaseResource { diff --git a/packages/core/src/resources/Pipelines.ts b/packages/core/src/resources/Pipelines.ts index b8b8273f..8381eb1c 100644 --- a/packages/core/src/resources/Pipelines.ts +++ b/packages/core/src/resources/Pipelines.ts @@ -8,7 +8,7 @@ import type { ShowExpanded, Sudo, } from '../infrastructure'; -import type { UserSchema } from './Users'; +import type { SimpleUserSchema } from './Users'; import type { PipelineVariableSchema } from './PipelineScheduleVariables'; export type CommitablePipelineStatus = 'pending' | 'running' | 'success' | 'failed' | 'canceled'; @@ -39,7 +39,7 @@ export interface ExpandedPipelineSchema extends PipelineSchema { before_sha: string; tag: boolean; yaml_errors?: unknown; - user: MappedOmit; + user: MappedOmit; started_at: string; finished_at: string; committed_at?: string; @@ -97,7 +97,7 @@ export interface PipelineTestReportSummarySchema extends Record failed: number; skipped: number; error: number; - suite_error?: null; + suite_error: string | null; }; test_suites?: PipelineTestSuiteSchema[]; } diff --git a/packages/core/src/resources/ProjectReleases.ts b/packages/core/src/resources/ProjectReleases.ts index bf2ecf27..b5a6fad9 100644 --- a/packages/core/src/resources/ProjectReleases.ts +++ b/packages/core/src/resources/ProjectReleases.ts @@ -9,7 +9,7 @@ import type { ShowExpanded, Sudo, } from '../infrastructure'; -import type { UserSchema } from './Users'; +import type { SimpleUserSchema } from './Users'; import type { CommitSchema } from './Commits'; import type { MilestoneSchema } from '../templates/ResourceMilestones'; @@ -38,7 +38,7 @@ export interface ReleaseSchema extends Record { name: string | null; created_at: string; released_at: string | null; - user: MappedOmit; + user: MappedOmit; commit: CommitSchema; milestones: MilestoneSchema[] | null; commit_path: string; diff --git a/packages/core/src/resources/Projects.ts b/packages/core/src/resources/Projects.ts index 65790f01..a4ed9b2e 100644 --- a/packages/core/src/resources/Projects.ts +++ b/packages/core/src/resources/Projects.ts @@ -11,7 +11,7 @@ import type { Sudo, } from '../infrastructure'; import type { ProjectRemoteMirrorSchema } from './ProjectRemoteMirrors'; -import type { UserSchema } from './Users'; +import type { SimpleUserSchema } from './Users'; import type { CondensedNamespaceSchema } from './Namespaces'; import type { SimpleGroupSchema } from './Groups'; import type { CustomAttributeSchema } from '../templates/ResourceCustomAttributes'; @@ -21,7 +21,7 @@ export type AccessLevelSettingState = 'disabled' | 'enabled' | 'private'; export interface ProjectStarrerSchema extends Record { starred_since: string; - user: MappedOmit; + user: MappedOmit; } export interface ProjectStoragePath extends Record { @@ -82,7 +82,7 @@ export interface ProjectSchema extends SimpleProjectSchema { merge_requests_template?: string; empty_repo: boolean; issues_template?: string; - owner: Pick; + owner: Pick; issues_enabled: boolean; open_issues_count: number; merge_requests_enabled: boolean; @@ -483,8 +483,8 @@ export class Projects extends BaseResource { allUsers( projectId: string | number, options?: { search?: string; skipUsers?: number[] } & Sudo & ShowExpanded, - ): Promise[], C, E, void>> { - return RequestHelper.get[]>()( + ): Promise[], C, E, void>> { + return RequestHelper.get[]>()( this, endpoint`projects/${projectId}/users`, options, diff --git a/packages/core/src/resources/Search.ts b/packages/core/src/resources/Search.ts index 2dc77226..b309671f 100644 --- a/packages/core/src/resources/Search.ts +++ b/packages/core/src/resources/Search.ts @@ -15,7 +15,7 @@ import type { MilestoneSchema } from '../templates/ResourceMilestones'; import type { SimpleSnippetSchema } from './Snippets'; import type { CommitSchema } from './Commits'; import type { NoteSchema } from '../templates/ResourceNotes'; -import type { UserSchema } from './Users'; +import type { SimpleUserSchema } from './Users'; export interface BlobSchema extends Record { id: number; @@ -59,7 +59,7 @@ export class Search extends BaseResource { Sudo & ShowExpanded & PaginationRequestOptions

, - ): Promise>; + ): Promise>; all( scope: 'notes', diff --git a/packages/core/src/resources/Snippets.ts b/packages/core/src/resources/Snippets.ts index c326e42e..b4d63ffa 100644 --- a/packages/core/src/resources/Snippets.ts +++ b/packages/core/src/resources/Snippets.ts @@ -7,7 +7,7 @@ import type { Sudo, UserAgentDetailSchema, } from '../infrastructure'; -import type { UserSchema } from './Users'; +import type { SimpleUserSchema } from './Users'; export type SnippetVisibility = 'private' | 'public' | 'internal'; @@ -16,7 +16,7 @@ export interface SimpleSnippetSchema extends Record { title: string; file_name: string; description?: string; - author: MappedOmit; + author: MappedOmit; updated_at: string; created_at: string; project_id?: string | number; diff --git a/packages/core/src/resources/TodoLists.ts b/packages/core/src/resources/TodoLists.ts index 280406cc..884c1a7a 100644 --- a/packages/core/src/resources/TodoLists.ts +++ b/packages/core/src/resources/TodoLists.ts @@ -8,7 +8,7 @@ import type { ShowExpanded, Sudo, } from '../infrastructure'; -import type { UserSchema } from './Users'; +import type { SimpleUserSchema } from './Users'; import type { SimpleProjectSchema } from './Projects'; export type TodoAction = @@ -31,7 +31,7 @@ export type TodoState = 'pending' | 'done'; export interface TodoSchema extends Record { id: number; - author: MappedOmit; + author: MappedOmit; project: Pick< SimpleProjectSchema, 'id' | 'name' | 'name_with_namespace' | 'path' | 'path_with_namespace' diff --git a/packages/core/src/resources/Users.ts b/packages/core/src/resources/Users.ts index 9edd8b3e..92d5e2d0 100644 --- a/packages/core/src/resources/Users.ts +++ b/packages/core/src/resources/Users.ts @@ -2,6 +2,7 @@ import { BaseResource } from '@gitbeaker/requester-utils'; import { RequestHelper, endpoint } from '../infrastructure'; import type { AllOrNone, + AsAdmin, GitlabAPIResponse, PaginationRequestOptions, PaginationTypes, @@ -14,34 +15,40 @@ import type { PersonalAccessTokenSchema } from './PersonalAccessTokens'; import type { CustomAttributeSchema } from '../templates/ResourceCustomAttributes'; import { AccessLevel } from '../constants'; -export interface UserSchema extends Record { +export interface SimpleUserSchema extends Record { id: number; name: string; username: string; state: string; avatar_url: string; web_url: string; - created_at?: string; + created_at: string; } -export interface ExpandedUserSchema extends UserSchema { - is_admin: boolean | null; +export interface UserSchema extends SimpleUserSchema { + locked: boolean | null; bio: string | null; - bot: boolean; + bot: boolean | null; location: string | null; - public_email: string; - skype: string; - linkedin: string; - twitter: string; - website_url: string; + public_email: string | null; + skype: string | null; + linkedin: string | null; + twitter: string | null; + discord: string | null; + website_url: string | null; + pronouns: string | null; organization: string | null; job_title: string | null; - prnouns: string | null; work_information: string | null; followers: number | null; following: number | null; local_time: string | null; is_followed: boolean | null; +} + +export interface ExpandedUserSchema extends UserSchema { + is_admin: boolean | null; + bot: boolean; last_sign_in_at: string; confirmed_at: string; last_activity_on: string; @@ -57,15 +64,21 @@ export interface ExpandedUserSchema extends UserSchema { two_factor_enabled: boolean; external: boolean; private_profile: string | null; - current_sign_in_ip: string; - last_sign_in_ip: string; namespace_id: number | null; created_by: string | null; - shared_runners_minutes_limit: number | null; - extra_shared_runners_minutes_limit: number | null; - is_auditor: boolean | null; +} + +export interface AdminUserSchema extends ExpandedUserSchema { + current_sign_in_ip: string; + last_sign_in_ip: string; using_license_seat: boolean | null; - provisioned_by_group_id: number | null; + email_reset_offered_at: string | null; + shared_runners_minutes_limit?: number | null; + extra_shared_runners_minutes_limit?: number | null; + is_auditor?: boolean | null; + provisioned_by_group_id?: number | null; + plan?: string; + trial?: boolean; } export interface UserActivitySchema extends Record { @@ -147,6 +160,7 @@ export type CreateUserOptions = { bio?: string; canCreateGroup?: boolean; colorSchemeId?: number; + commitEmail?: string; email?: string; externUid?: string; external?: boolean; @@ -161,7 +175,9 @@ export type CreateUserOptions = { password?: string; privateProfile?: string; projectsLimit?: number; + pronouns?: string; provider?: string; + publicEmail?: string; resetPassword?: boolean; sharedRunnersMinutesLimit?: number; skipConfirmation?: boolean; @@ -219,28 +235,35 @@ export class Users extends BaseResource { return RequestHelper.post()(this, endpoint`users/${userId}/activate`, options); } - all( - options?: AllUsersOptions & + all( + options?: { withCustomAttributes: true } & AsAdmin & + AllUsersOptions & PaginationRequestOptions

& Sudo & - ShowExpanded & { withCustomAttributes: true }, + ShowExpanded, ): Promise< GitlabAPIResponse< - (ExpandedUserSchema & { custom_attributes: CustomAttributeSchema[] })[], + ((A extends false ? SimpleUserSchema : AdminUserSchema) & { + custom_attributes: CustomAttributeSchema[]; + })[], C, E, P > >; - all( - options?: AllUsersOptions & PaginationRequestOptions

& Sudo & ShowExpanded, - ): Promise>; + all( + options?: AllUsersOptions & AsAdmin & PaginationRequestOptions

& Sudo & ShowExpanded, + ): Promise>; - all( - options?: AllUsersOptions & PaginationRequestOptions

& Sudo & ShowExpanded, - ): Promise> { - return RequestHelper.get()(this, 'users', options); + all( + options?: AllUsersOptions & AsAdmin & PaginationRequestOptions

& Sudo & ShowExpanded, + ): Promise> { + return RequestHelper.get<(A extends false ? SimpleUserSchema : AdminUserSchema)[]>()( + this, + 'users', + options, + ); } allActivities( @@ -259,15 +282,23 @@ export class Users extends BaseResource { allFollowers( userId: number, options?: PaginationRequestOptions

& Sudo & ShowExpanded, - ): Promise> { - return RequestHelper.get()(this, endpoint`users/${userId}/followers`, options); + ): Promise> { + return RequestHelper.get()( + this, + endpoint`users/${userId}/followers`, + options, + ); } allFollowing( userId: number, options?: PaginationRequestOptions

& Sudo & ShowExpanded, - ): Promise> { - return RequestHelper.get()(this, endpoint`users/${userId}/following`, options); + ): Promise> { + return RequestHelper.get()( + this, + endpoint`users/${userId}/following`, + options, + ); } allMemberships( @@ -409,8 +440,8 @@ export class Users extends BaseResource { create( options?: CreateUserOptions & Sudo & ShowExpanded, - ): Promise> { - return RequestHelper.post()(this, 'users', options); + ): Promise> { + return RequestHelper.post()(this, 'users', options); } createPersonalAccessToken( @@ -458,7 +489,7 @@ export class Users extends BaseResource { userId: number, options?: EditUserOptions & Sudo & ShowExpanded, ) { - return RequestHelper.put()(this, endpoint`users/${userId}`, options); + return RequestHelper.put()(this, endpoint`users/${userId}`, options); } editStatus( @@ -494,8 +525,8 @@ export class Users extends BaseResource { follow( userId: number, options?: Sudo & ShowExpanded, - ): Promise> { - return RequestHelper.post()(this, endpoint`users/${userId}/follow`, options); + ): Promise> { + return RequestHelper.post()(this, endpoint`users/${userId}/follow`, options); } reject( @@ -509,11 +540,11 @@ export class Users extends BaseResource { ); } - show( + show( userId: number, - options?: Sudo & ShowExpanded, - ): Promise> { - return RequestHelper.get()( + options?: AsAdmin & Sudo & ShowExpanded, + ): Promise> { + return RequestHelper.get()( this, endpoint`users/${userId}`, options, @@ -537,10 +568,16 @@ export class Users extends BaseResource { ); } - showCurrentUser( - options?: Sudo & ShowExpanded, - ): Promise> { - return RequestHelper.get()(this, 'user', options); + showCurrentUser( + options?: AsAdmin & Sudo & ShowExpanded, + ): Promise< + GitlabAPIResponse + > { + return RequestHelper.get()( + this, + 'user', + options, + ); } showCurrentUserPreferences( diff --git a/packages/core/src/resources/Webhooks.ts b/packages/core/src/resources/Webhooks.ts index 6be6f4cb..bae3d892 100644 --- a/packages/core/src/resources/Webhooks.ts +++ b/packages/core/src/resources/Webhooks.ts @@ -1,5 +1,5 @@ import type { MappedOmit } from '../infrastructure'; -import type { UserSchema } from './Users'; +import type { SimpleUserSchema } from './Users'; // Sub / Base Schemas export interface WebhookRepositorySchema { @@ -67,7 +67,7 @@ export interface BaseWebhookEventSchema { object_kind: string; event_name: string; project: WebhookProjectSchema; - user: MappedOmit; + user: MappedOmit; } export interface WebhookBaseNoteEventSchema extends BaseWebhookEventSchema { @@ -191,8 +191,8 @@ export interface WebhookIssueEventSchema extends BaseWebhookEventSchema { description: string; homepage: string; }; - assignees: Pick[] | null; - assignee: Pick | null; + assignees: Pick[] | null; + assignee: Pick | null; labels: WebhookLabelSchema[] | null; changes: { updated_by_id: { @@ -256,7 +256,7 @@ export interface WebhookMergeRequestNoteEventSchema extends WebhookBaseNoteEvent }; work_in_progress: boolean; draft: boolean; - assignee: Pick | null; + assignee: Pick | null; detailed_merge_status: string; }; } @@ -377,7 +377,7 @@ export interface WebhookMergeRequestEventSchema extends BaseWebhookEventSchema { current: number | null; }; }; - assignees: Pick[] | null; + assignees: Pick[] | null; reviewers: WebhookLabelSchema[] | null; } @@ -466,7 +466,7 @@ export interface WebhookPipelineEventSchema when: string; manual: boolean; allow_failure: boolean; - user: MappedOmit; + user: MappedOmit; runner: { id: number; description: string; diff --git a/packages/core/src/templates/ResourceAwardEmojis.ts b/packages/core/src/templates/ResourceAwardEmojis.ts index ca7c3c41..16531eed 100644 --- a/packages/core/src/templates/ResourceAwardEmojis.ts +++ b/packages/core/src/templates/ResourceAwardEmojis.ts @@ -8,12 +8,12 @@ import type { ShowExpanded, Sudo, } from '../infrastructure'; -import type { UserSchema } from '../resources/Users'; +import type { SimpleUserSchema } from '../resources/Users'; export interface AwardEmojiSchema extends Record { id: number; name: string; - user: UserSchema; + user: SimpleUserSchema; created_at: string; updated_at: string; awardable_id: number; diff --git a/packages/core/src/templates/ResourceDiscussions.ts b/packages/core/src/templates/ResourceDiscussions.ts index fcf4e320..41a7f11a 100644 --- a/packages/core/src/templates/ResourceDiscussions.ts +++ b/packages/core/src/templates/ResourceDiscussions.ts @@ -10,7 +10,7 @@ import type { ShowExpanded, Sudo, } from '../infrastructure'; -import type { UserSchema } from '../resources/Users'; +import type { SimpleUserSchema } from '../resources/Users'; export interface DiscussionNotePositionBaseSchema extends Record { base_sha: string; @@ -57,7 +57,7 @@ export interface DiscussionNoteSchema extends Record { type: 'DiffNote' | 'DiscussionNote' | null; body: string; attachment: string | null; - author: MappedOmit; + author: MappedOmit; created_at: string; updated_at: string; system: boolean; diff --git a/packages/core/src/templates/ResourceIterationEvents.ts b/packages/core/src/templates/ResourceIterationEvents.ts index cfdbe1a6..80fb4282 100644 --- a/packages/core/src/templates/ResourceIterationEvents.ts +++ b/packages/core/src/templates/ResourceIterationEvents.ts @@ -9,12 +9,12 @@ import type { ShowExpanded, Sudo, } from '../infrastructure'; -import type { UserSchema } from '../resources/Users'; +import type { SimpleUserSchema } from '../resources/Users'; import type { IterationSchema } from './ResourceIterations'; export interface IterationEventSchema extends Record { id: number; - user: MappedOmit; + user: MappedOmit; created_at: string; resource_type: 'Issue'; resource_id: number; diff --git a/packages/core/src/templates/ResourceLabelEvents.ts b/packages/core/src/templates/ResourceLabelEvents.ts index 10b62dc9..954f2acf 100644 --- a/packages/core/src/templates/ResourceLabelEvents.ts +++ b/packages/core/src/templates/ResourceLabelEvents.ts @@ -9,12 +9,12 @@ import type { ShowExpanded, Sudo, } from '../infrastructure'; -import type { UserSchema } from '../resources/Users'; +import type { SimpleUserSchema } from '../resources/Users'; import type { LabelSchema } from './ResourceLabels'; export interface LabelEventSchema extends Record { id: number; - user: MappedOmit; + user: MappedOmit; created_at: string; resource_type: 'Issue' | 'Epic' | 'MergeRequest'; resource_id: number; diff --git a/packages/core/src/templates/ResourceMilestoneEvents.ts b/packages/core/src/templates/ResourceMilestoneEvents.ts index 5747a921..d79d6457 100644 --- a/packages/core/src/templates/ResourceMilestoneEvents.ts +++ b/packages/core/src/templates/ResourceMilestoneEvents.ts @@ -9,12 +9,12 @@ import type { ShowExpanded, Sudo, } from '../infrastructure'; -import type { UserSchema } from '../resources/Users'; +import type { SimpleUserSchema } from '../resources/Users'; import type { MilestoneSchema } from './ResourceMilestones'; export interface MilestoneEventSchema extends Record { id: number; - user: MappedOmit; + user: MappedOmit; created_at: string; resource_type: 'Issue' | 'MergeRequest'; resource_id: number; diff --git a/packages/core/src/templates/ResourceNotes.ts b/packages/core/src/templates/ResourceNotes.ts index 7f40ac20..713688de 100644 --- a/packages/core/src/templates/ResourceNotes.ts +++ b/packages/core/src/templates/ResourceNotes.ts @@ -9,13 +9,13 @@ import type { ShowExpanded, Sudo, } from '../infrastructure'; -import { UserSchema } from '../resources/Users'; +import { SimpleUserSchema } from '../resources/Users'; export interface NoteSchema extends Record { id: number; body: string; attachment: string | null; - author: MappedOmit; + author: MappedOmit; created_at: string; updated_at: string; system: boolean; diff --git a/packages/core/src/templates/ResourceStateEvents.ts b/packages/core/src/templates/ResourceStateEvents.ts index 458e505c..eda7ddf1 100644 --- a/packages/core/src/templates/ResourceStateEvents.ts +++ b/packages/core/src/templates/ResourceStateEvents.ts @@ -9,11 +9,11 @@ import type { ShowExpanded, Sudo, } from '../infrastructure'; -import type { UserSchema } from '../resources/Users'; +import type { SimpleUserSchema } from '../resources/Users'; export interface StateEventSchema extends Record { id: number; - user: MappedOmit; + user: MappedOmit; created_at: string; resource_type: 'Issue'; resource_id: number; diff --git a/packages/core/src/templates/ResourceWeightEvents.ts b/packages/core/src/templates/ResourceWeightEvents.ts index 5df02c16..4a9efd8e 100644 --- a/packages/core/src/templates/ResourceWeightEvents.ts +++ b/packages/core/src/templates/ResourceWeightEvents.ts @@ -9,11 +9,11 @@ import type { ShowExpanded, Sudo, } from '../infrastructure'; -import type { UserSchema } from '../resources/Users'; +import type { SimpleUserSchema } from '../resources/Users'; export interface WeightEventSchema extends Record { id: number; - user: MappedOmit; + user: MappedOmit; created_at: string; issue_id: number; weight: number;