Skip to content

Commit 5380b8f

Browse files
committed
feat: add team membership endpoints
These are all the `npm team` endpoints
1 parent 8afddd1 commit 5380b8f

5 files changed

Lines changed: 210 additions & 41 deletions

File tree

api/base.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,7 @@ x-tagGroups:
9393
- Trust
9494
- Access
9595
- Org
96+
- Team
9697

9798
components:
9899
securitySchemes:

api/merge-config.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ inputs:
33
- inputFile: registry.npmjs.com/access.yaml
44
- inputFile: registry.npmjs.com/oidc.yaml
55
- inputFile: registry.npmjs.com/org.yaml
6+
- inputFile: registry.npmjs.com/team.yaml
67
- inputFile: registry.npmjs.com/token.yaml
78
- inputFile: registry.npmjs.com/trust.yaml
89

api/registry.npmjs.com/access.yaml

Lines changed: 28 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -1,52 +1,44 @@
11
components:
2-
parameters:
3-
TeamName:
4-
name: teamName
5-
in: path
6-
required: true
7-
schema:
8-
type: string
9-
description: Name of a team
102
responses:
113
PackageAccessLevels:
12-
description: "Packages with their access levels"
4+
description: 'Packages with their access levels'
135
content:
146
application/json:
157
schema:
168
type: object
179
additionalProperties:
1810
type: string
1911
example:
20-
"@npmcli/arborist": "read-write"
21-
"@npmcli/config": "read-only"
12+
'@npmcli/arborist': read-write
13+
'@npmcli/config': read-only
2214
PackageVisibility:
23-
description: "Packages with their visibility"
15+
description: 'Packages with their visibility'
2416
content:
2517
application/json:
2618
schema:
2719
type: object
2820
additionalProperties:
2921
type: string
3022
example:
31-
"@npmcli/arborist": "public"
32-
"@npmcli/hidden": "private"
23+
'@npmcli/arborist': public
24+
'@npmcli/hidden': private
3325
UserAccessLevels:
34-
description: "User access levels"
26+
description: User access levels
3527
content:
3628
application/json:
3729
schema:
3830
type: object
3931
additionalProperties:
4032
type: string
4133
example:
42-
"npm": "read-write"
43-
"microsoft": "read-only"
34+
npm: read-write
35+
microsoft: read-only
4436
paths:
4537
/-/team/{orgName}/{teamName}/package:
4638
parameters:
4739
- $ref: './api/shared-components.yaml#/components/parameters/OrgName'
48-
- $ref: '#/components/parameters/TeamName'
49-
- $ref: "./api/shared-components.yaml#/components/parameters/RequiredBearerToken"
40+
- $ref: './api/shared-components.yaml#/components/parameters/TeamName'
41+
- $ref: './api/shared-components.yaml#/components/parameters/RequiredBearerToken'
5042
get:
5143
tags:
5244
- Access
@@ -56,9 +48,9 @@ paths:
5648
security:
5749
- npmSessionToken: []
5850
responses:
59-
"200":
51+
'200':
6052
$ref: '#/components/responses/PackageAccessLevels'
61-
"401":
53+
'401':
6254
$ref: './api/shared-components.yaml#/components/responses/Unauthorized'
6355
put:
6456
tags:
@@ -84,24 +76,24 @@ paths:
8476
security:
8577
- npmSessionToken: []
8678
responses:
87-
"201":
79+
'201':
8880
$ref: './api/shared-components.yaml#/components/responses/EmptySuccess'
89-
"401":
81+
'401':
9082
$ref: './api/shared-components.yaml#/components/responses/Unauthorized'
9183
delete:
9284
summary: Remove access to a package for a team
9385
operationId: deleteTeamPackageGrant
9486
security:
9587
- npmSessionToken: []
9688
responses:
97-
"204":
89+
'204':
9890
$ref: './api/shared-components.yaml#/components/responses/EmptySuccess'
99-
"401":
91+
'401':
10092
$ref: './api/shared-components.yaml#/components/responses/Unauthorized'
10193
/-/org/{orgName}/package:
10294
parameters:
10395
- $ref: './api/shared-components.yaml#/components/parameters/OrgName'
104-
- $ref: "./api/shared-components.yaml#/components/parameters/RequiredBearerToken"
96+
- $ref: './api/shared-components.yaml#/components/parameters/RequiredBearerToken'
10597
get:
10698
tags:
10799
- Access
@@ -111,14 +103,14 @@ paths:
111103
security:
112104
- npmSessionToken: []
113105
responses:
114-
"200":
106+
'200':
115107
$ref: '#/components/responses/PackageAccessLevels'
116-
"401":
108+
'401':
117109
$ref: './api/shared-components.yaml#/components/responses/Unauthorized'
118110
/-/package/{escapedPackageName}/collaborators:
119111
parameters:
120112
- $ref: './api/shared-components.yaml#/components/parameters/EscapedPackageName'
121-
- $ref: "./api/shared-components.yaml#/components/parameters/RequiredBearerToken"
113+
- $ref: './api/shared-components.yaml#/components/parameters/RequiredBearerToken'
122114
get:
123115
tags:
124116
- Access
@@ -127,14 +119,14 @@ paths:
127119
security:
128120
- npmSessionToken: []
129121
responses:
130-
"200":
122+
'200':
131123
$ref: '#/components/responses/UserAccessLevels'
132-
"401":
124+
'401':
133125
$ref: './api/shared-components.yaml#/components/responses/Unauthorized'
134126
/-/package/{escapedPackageName}/visibility:
135127
parameters:
136128
- $ref: './api/shared-components.yaml#/components/parameters/EscapedPackageName'
137-
- $ref: "./api/shared-components.yaml#/components/parameters/RequiredBearerToken"
129+
- $ref: './api/shared-components.yaml#/components/parameters/RequiredBearerToken'
138130
get:
139131
tags:
140132
- Access
@@ -143,9 +135,9 @@ paths:
143135
security:
144136
- npmSessionToken: []
145137
responses:
146-
"200":
138+
'200':
147139
$ref: '#/components/responses/PackageVisibility'
148-
"401":
140+
'401':
149141
$ref: './api/shared-components.yaml#/components/responses/Unauthorized'
150142
/-/package/{escapedPackageName}/access:
151143
parameters:
@@ -178,7 +170,7 @@ paths:
178170
security:
179171
- npmSessionToken: []
180172
responses:
181-
"200":
173+
'200':
182174
$ref: './api/shared-components.yaml#/components/responses/EmptySuccess'
183-
"401":
175+
'401':
184176
$ref: './api/shared-components.yaml#/components/responses/Unauthorized'

api/registry.npmjs.com/team.yaml

Lines changed: 166 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,166 @@
1+
components:
2+
responses:
3+
TeamUsers:
4+
description: The users in a team
5+
content:
6+
application/json:
7+
schema:
8+
type: array
9+
items:
10+
type: string
11+
description: A username of a user in the team
12+
example:
13+
- npm
14+
- npm-cli-bot
15+
OrgTeams:
16+
description: The teams in an org
17+
content:
18+
application/json:
19+
schema:
20+
type: array
21+
items:
22+
type: string
23+
description: The teams in the org, in the format of orgname:teamname
24+
example:
25+
- '@npmcli:wombats'
26+
27+
paths:
28+
/-/org/{orgName}/team:
29+
parameters:
30+
- $ref: './api/shared-components.yaml#/components/parameters/OrgName'
31+
- $ref: './api/shared-components.yaml#/components/parameters/RequiredBearerToken'
32+
get:
33+
tags:
34+
- Org
35+
summary: Get teams in an org
36+
description: Get all of the teams in an org
37+
operationId: getScopeTeams
38+
security:
39+
- npmSessionToken: []
40+
responses:
41+
'200':
42+
$ref: '#/components/responses/OrgTeams'
43+
'401':
44+
$ref: './api/shared-components.yaml#/components/responses/Unauthorized'
45+
put:
46+
tags:
47+
- Team
48+
summary: Create a new team
49+
description: Create a new team for an org
50+
operationId: putScopeTeam
51+
requestBody:
52+
required: true
53+
content:
54+
application/json:
55+
schema:
56+
type: object
57+
properties:
58+
name:
59+
type: string
60+
description: The name of the team to create
61+
description:
62+
type: string
63+
description: The description of the team to create
64+
example: { name: 'wombats', description: 'All developers' }
65+
security:
66+
- npmSessionToken: []
67+
responses:
68+
'201':
69+
description: Team was created successfully
70+
content:
71+
application/json:
72+
schema:
73+
type: object
74+
properties:
75+
name:
76+
type: string
77+
description: The name of the team that was created
78+
example:
79+
name: wombats
80+
'401':
81+
$ref: './api/shared-components.yaml#/components/responses/Unauthorized'
82+
/-/org/{orgName}/{teamName}:
83+
parameters:
84+
- $ref: './api/shared-components.yaml#/components/parameters/OrgName'
85+
- $ref: './api/shared-components.yaml#/components/parameters/TeamName'
86+
- $ref: './api/shared-components.yaml#/components/parameters/RequiredBearerToken'
87+
delete:
88+
tags:
89+
- Team
90+
summary: Delete a team
91+
description: Delete a team from a given org
92+
operationId: deleteTeam
93+
security:
94+
- npmSessionToken: []
95+
responses:
96+
'204':
97+
$ref: './api/shared-components.yaml#/components/responses/EmptySuccess'
98+
'401':
99+
$ref: './api/shared-components.yaml#/components/responses/Unauthorized'
100+
/-/org/{orgName}/{teamName}/user:
101+
parameters:
102+
- $ref: './api/shared-components.yaml#/components/parameters/OrgName'
103+
- $ref: './api/shared-components.yaml#/components/parameters/TeamName'
104+
- $ref: './api/shared-components.yaml#/components/parameters/RequiredBearerToken'
105+
get:
106+
tags:
107+
- Team
108+
summary: Get all users in a team
109+
description: Get all users in a team
110+
operationId: getTeamMembership
111+
security:
112+
- npmSessionToken: []
113+
responses:
114+
'200':
115+
$ref: '#/components/responses/TeamUsers'
116+
'401':
117+
$ref: './api/shared-components.yaml#/components/responses/Unauthorized'
118+
put:
119+
tags:
120+
- Team
121+
summary: Add a user to a team
122+
description: Add a user to a team in an org. The user must already be a member of the org.
123+
operationId: createTeamMembership
124+
requestBody:
125+
required: true
126+
content:
127+
application/json:
128+
schema:
129+
type: object
130+
properties:
131+
user:
132+
type: string
133+
description: The username of the user to add to the team
134+
example:
135+
user: npm-cli-bot
136+
security:
137+
- npmSessionToken: []
138+
responses:
139+
'201':
140+
$ref: './api/shared-components.yaml#/components/responses/EmptySuccess'
141+
'401':
142+
$ref: './api/shared-components.yaml#/components/responses/Unauthorized'
143+
delete:
144+
tags:
145+
- Team
146+
summary: Remove a user from a team
147+
operationId: deleteTeamMembership
148+
requestBody:
149+
required: true
150+
content:
151+
application/json:
152+
schema:
153+
type: object
154+
properties:
155+
user:
156+
type: string
157+
description: The username of the user to remove from the team
158+
example:
159+
user: npm-cli-bot
160+
security:
161+
- npmSessionToken: []
162+
responses:
163+
'204':
164+
$ref: './api/shared-components.yaml#/components/responses/EmptySuccess'
165+
'401':
166+
$ref: './api/shared-components.yaml#/components/responses/Unauthorized'

api/shared-components.yaml

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,15 +6,22 @@ components:
66
required: true
77
schema:
88
type: string
9-
description: The name of a package. Scoped packages need their "/" to be url encoded to "%2F"
10-
example: "@npmcli%2Farborist"
9+
description: The name of a package. Scoped packages need "/" to be url encoded to "%2F"
10+
example: '@npmcli%2Farborist'
1111
OrgName:
1212
name: orgName
1313
in: path
1414
required: true
1515
schema:
1616
type: string
1717
description: Name of an org
18+
TeamName:
19+
name: teamName
20+
in: path
21+
required: true
22+
schema:
23+
type: string
24+
description: Name of a team
1825
RequiredBearerToken:
1926
name: Authorization
2027
in: header
@@ -31,14 +38,14 @@ components:
3138
- npm access token (traditional user token created via `npm login`)
3239
responses:
3340
EmptySuccess:
34-
description: "Success"
41+
description: Success
3542
content:
36-
"*/*":
43+
'*/*':
3744
schema:
3845
not:
3946
{}
4047
Unauthorized:
41-
description: "Unauthorized"
48+
description: Unauthorized
4249
headers:
4350
www-authenticate:
4451
description: Authentication challenge (e.g., "OTP" when OTP is required)
@@ -56,3 +63,5 @@ components:
5663
error:
5764
type: string
5865
description: Error message
66+
example:
67+
error: Missing "Bearer" header.

0 commit comments

Comments
 (0)