@taskeren/bungie-api-ts 5.10.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/.babelrc +4 -0
- package/.gitattributes +2 -0
- package/.github/workflows/pr-build.yml +50 -0
- package/.github/workflows/publish.yml +48 -0
- package/.github/workflows/update.yml +55 -0
- package/.gitmodules +3 -0
- package/.nvmrc +1 -0
- package/.prettierrc +10 -0
- package/.vscode/extensions.json +8 -0
- package/.vscode/settings.json +7 -0
- package/LICENSE.md +21 -0
- package/README.md +97 -0
- package/api-src/.github/workflows/close-inactive.yml +24 -0
- package/api-src/CHANGELOG.md +271 -0
- package/api-src/CONTRIBUTING.md +19 -0
- package/api-src/LICENSE +28 -0
- package/api-src/README.md +378 -0
- package/api-src/openapi-2.json +44518 -0
- package/api-src/openapi.json +46467 -0
- package/build.sh +30 -0
- package/bungie-api-LICENSE +29 -0
- package/generated-src/app/api.ts +50 -0
- package/generated-src/app/index.ts +17 -0
- package/generated-src/app/interfaces.ts +119 -0
- package/generated-src/common.ts +985 -0
- package/generated-src/communitycontent/api.ts +36 -0
- package/generated-src/communitycontent/index.ts +16 -0
- package/generated-src/content/api.ts +142 -0
- package/generated-src/content/index.ts +17 -0
- package/generated-src/content/interfaces.ts +225 -0
- package/generated-src/core/api.ts +57 -0
- package/generated-src/core/index.ts +17 -0
- package/generated-src/core/interfaces.ts +151 -0
- package/generated-src/destiny2/api.ts +821 -0
- package/generated-src/destiny2/index.ts +17 -0
- package/generated-src/destiny2/interfaces.ts +15714 -0
- package/generated-src/destiny2/manifest.ts +341 -0
- package/generated-src/fireteam/api.ts +151 -0
- package/generated-src/fireteam/index.ts +17 -0
- package/generated-src/fireteam/interfaces.ts +183 -0
- package/generated-src/forum/api.ts +197 -0
- package/generated-src/forum/index.ts +17 -0
- package/generated-src/forum/interfaces.ts +171 -0
- package/generated-src/groupv2/api.ts +515 -0
- package/generated-src/groupv2/index.ts +17 -0
- package/generated-src/groupv2/interfaces.ts +773 -0
- package/generated-src/http.ts +52 -0
- package/generated-src/index.ts +37 -0
- package/generated-src/package.json.notyet +99 -0
- package/generated-src/platform.ts +39 -0
- package/generated-src/social/api.ts +115 -0
- package/generated-src/social/index.ts +17 -0
- package/generated-src/social/interfaces.ts +89 -0
- package/generated-src/tokens/api.ts +126 -0
- package/generated-src/tokens/index.ts +17 -0
- package/generated-src/tokens/interfaces.ts +102 -0
- package/generated-src/trending/api.ts +62 -0
- package/generated-src/trending/index.ts +17 -0
- package/generated-src/trending/interfaces.ts +188 -0
- package/generated-src/user/api.ts +130 -0
- package/generated-src/user/index.ts +17 -0
- package/generated-src/user/interfaces.ts +338 -0
- package/generator/generate-api.ts +254 -0
- package/generator/generate-common.ts +123 -0
- package/generator/generate-index.ts +45 -0
- package/generator/generate-interfaces.ts +173 -0
- package/generator/generate-manifest.ts +217 -0
- package/generator/generate-package-json.ts +45 -0
- package/generator/generate.ts +54 -0
- package/generator/http.ts +52 -0
- package/generator/missing-props.ts +11 -0
- package/generator/type-index.ts +184 -0
- package/generator/util.ts +131 -0
- package/lib/README.md +97 -0
- package/lib/app/api.d.ts +36 -0
- package/lib/app/api.js +15 -0
- package/lib/app/index.d.ts +16 -0
- package/lib/app/index.js +5 -0
- package/lib/app/interfaces.d.ts +108 -0
- package/lib/app/interfaces.js +17 -0
- package/lib/bungie-api-LICENSE +29 -0
- package/lib/common.d.ts +979 -0
- package/lib/common.js +923 -0
- package/lib/communitycontent/api.d.ts +31 -0
- package/lib/communitycontent/api.js +7 -0
- package/lib/communitycontent/index.d.ts +15 -0
- package/lib/communitycontent/index.js +4 -0
- package/lib/content/api.d.ts +111 -0
- package/lib/content/api.js +75 -0
- package/lib/content/index.d.ts +16 -0
- package/lib/content/index.js +5 -0
- package/lib/content/interfaces.d.ts +214 -0
- package/lib/content/interfaces.js +17 -0
- package/lib/core/api.d.ts +45 -0
- package/lib/core/api.js +18 -0
- package/lib/core/index.d.ts +16 -0
- package/lib/core/index.js +5 -0
- package/lib/core/interfaces.d.ts +144 -0
- package/lib/core/interfaces.js +10 -0
- package/lib/destiny2/api.d.ts +765 -0
- package/lib/destiny2/api.js +295 -0
- package/lib/destiny2/index.d.ts +16 -0
- package/lib/destiny2/index.js +5 -0
- package/lib/destiny2/interfaces.d.ts +15340 -0
- package/lib/destiny2/interfaces.js +826 -0
- package/lib/destiny2/manifest.d.ts +465 -0
- package/lib/destiny2/manifest.js +56 -0
- package/lib/fireteam/api.d.ts +131 -0
- package/lib/fireteam/api.js +50 -0
- package/lib/fireteam/index.d.ts +16 -0
- package/lib/fireteam/index.js +5 -0
- package/lib/fireteam/interfaces.d.ts +166 -0
- package/lib/fireteam/interfaces.js +33 -0
- package/lib/forum/api.d.ts +165 -0
- package/lib/forum/api.js +79 -0
- package/lib/forum/index.d.ts +16 -0
- package/lib/forum/index.js +5 -0
- package/lib/forum/interfaces.d.ts +147 -0
- package/lib/forum/interfaces.js +61 -0
- package/lib/groupv2/api.d.ts +484 -0
- package/lib/groupv2/api.js +154 -0
- package/lib/groupv2/index.d.ts +16 -0
- package/lib/groupv2/index.js +5 -0
- package/lib/groupv2/interfaces.d.ts +718 -0
- package/lib/groupv2/interfaces.js +100 -0
- package/lib/http.d.ts +18 -0
- package/lib/http.js +20 -0
- package/lib/index.d.ts +35 -0
- package/lib/index.js +24 -0
- package/lib/package.json +99 -0
- package/lib/platform.d.ts +36 -0
- package/lib/platform.js +9 -0
- package/lib/social/api.d.ts +101 -0
- package/lib/social/api.js +26 -0
- package/lib/social/index.d.ts +16 -0
- package/lib/social/index.js +5 -0
- package/lib/social/interfaces.d.ts +75 -0
- package/lib/social/interfaces.js +22 -0
- package/lib/tokens/api.d.ts +120 -0
- package/lib/tokens/api.js +38 -0
- package/lib/tokens/index.d.ts +16 -0
- package/lib/tokens/index.js +5 -0
- package/lib/tokens/interfaces.d.ts +88 -0
- package/lib/tokens/interfaces.js +5 -0
- package/lib/trending/api.d.ts +53 -0
- package/lib/trending/api.js +11 -0
- package/lib/trending/index.d.ts +16 -0
- package/lib/trending/index.js +5 -0
- package/lib/trending/interfaces.d.ts +171 -0
- package/lib/trending/interfaces.js +14 -0
- package/lib/user/api.d.ts +117 -0
- package/lib/user/api.js +35 -0
- package/lib/user/index.d.ts +16 -0
- package/lib/user/index.js +5 -0
- package/lib/user/interfaces.d.ts +320 -0
- package/lib/user/interfaces.js +28 -0
- package/package.json +60 -0
- package/test-consumer.ts +5 -0
- package/tests/__snapshots__/config-builders.test.ts.snap +343 -0
- package/tests/config-builders.test.ts +145 -0
- package/tests/manifest-fetcher.test.ts +43 -0
- package/tests/test-manifest.js +69 -0
- package/tsconfig-package.json +14 -0
- package/tsconfig.json +17 -0
|
@@ -0,0 +1,338 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Bungie.Net API
|
|
3
|
+
* These endpoints constitute the functionality exposed by Bungie.net, both for more traditional website functionality and for connectivity to Bungie video games and their related functionality.
|
|
4
|
+
*
|
|
5
|
+
* OpenAPI spec version: 2.21.9
|
|
6
|
+
* Contact: support@bungie.com
|
|
7
|
+
*
|
|
8
|
+
* NOTE: This class is auto generated by the bungie-api-ts code generator program.
|
|
9
|
+
* https://github.com/DestinyItemManager/bungie-api-ts
|
|
10
|
+
* Do not edit these files manually.
|
|
11
|
+
*/
|
|
12
|
+
|
|
13
|
+
import {
|
|
14
|
+
BungieMembershipType
|
|
15
|
+
} from '../common.js';
|
|
16
|
+
import {
|
|
17
|
+
GroupUserInfoCard
|
|
18
|
+
} from '../groupv2/interfaces.js';
|
|
19
|
+
import {
|
|
20
|
+
IgnoreResponse
|
|
21
|
+
} from '../platform.js';
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
* This contract supplies basic information commonly used to display a minimal
|
|
25
|
+
* amount of information about a user. Take care to not add more properties here
|
|
26
|
+
* unless the property applies in all (or at least the majority) of the situations
|
|
27
|
+
* where UserInfoCard is used. Avoid adding game specific or platform specific
|
|
28
|
+
* details here. In cases where UserInfoCard is a subset of the data needed in a
|
|
29
|
+
* contract, use UserInfoCard as a property of other contracts.
|
|
30
|
+
*/
|
|
31
|
+
export interface UserInfoCard {
|
|
32
|
+
/**
|
|
33
|
+
* A platform specific additional display name - ex: psn Real Name, bnet Unique
|
|
34
|
+
* Name, etc.
|
|
35
|
+
*/
|
|
36
|
+
readonly supplementalDisplayName: string;
|
|
37
|
+
/** URL the Icon if available. */
|
|
38
|
+
readonly iconPath: string;
|
|
39
|
+
/**
|
|
40
|
+
* If there is a cross save override in effect, this value will tell you the type
|
|
41
|
+
* that is overridding this one.
|
|
42
|
+
*/
|
|
43
|
+
readonly crossSaveOverride: BungieMembershipType;
|
|
44
|
+
/**
|
|
45
|
+
* The list of Membership Types indicating the platforms on which this Membership
|
|
46
|
+
* can be used.
|
|
47
|
+
*
|
|
48
|
+
* Not in Cross Save = its original membership type. Cross Save Primary = Any
|
|
49
|
+
* membership types it is overridding, and its original membership type Cross Save
|
|
50
|
+
* Overridden = Empty list
|
|
51
|
+
*/
|
|
52
|
+
readonly applicableMembershipTypes: BungieMembershipType[];
|
|
53
|
+
/** If True, this is a public user membership. */
|
|
54
|
+
readonly isPublic: boolean;
|
|
55
|
+
/** Type of the membership. Not necessarily the native type. */
|
|
56
|
+
readonly membershipType: BungieMembershipType;
|
|
57
|
+
/** Membership ID as they user is known in the Accounts service */
|
|
58
|
+
readonly membershipId: string;
|
|
59
|
+
/**
|
|
60
|
+
* Display Name the player has chosen for themselves. The display name is optional
|
|
61
|
+
* when the data type is used as input to a platform API.
|
|
62
|
+
*/
|
|
63
|
+
readonly displayName: string;
|
|
64
|
+
/** The bungie global display name, if set. */
|
|
65
|
+
readonly bungieGlobalDisplayName: string;
|
|
66
|
+
/** The bungie global display name code, if set. */
|
|
67
|
+
readonly bungieGlobalDisplayNameCode?: number;
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
/**
|
|
71
|
+
* The types of credentials the Accounts system supports. This is the external
|
|
72
|
+
* facing enum used in place of the internal-only Bungie.SharedDefinitions.
|
|
73
|
+
* CredentialType.
|
|
74
|
+
*/
|
|
75
|
+
export const enum BungieCredentialType {
|
|
76
|
+
None = 0,
|
|
77
|
+
Xuid = 1,
|
|
78
|
+
Psnid = 2,
|
|
79
|
+
Wlid = 3,
|
|
80
|
+
Fake = 4,
|
|
81
|
+
Facebook = 5,
|
|
82
|
+
Google = 8,
|
|
83
|
+
Windows = 9,
|
|
84
|
+
DemonId = 10,
|
|
85
|
+
SteamId = 12,
|
|
86
|
+
BattleNetId = 14,
|
|
87
|
+
StadiaId = 16,
|
|
88
|
+
TwitchId = 18,
|
|
89
|
+
EgsId = 20
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
export interface UserSearchPrefixRequest {
|
|
93
|
+
readonly displayNamePrefix: string;
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
export interface GeneralUser {
|
|
97
|
+
readonly membershipId: string;
|
|
98
|
+
readonly uniqueName: string;
|
|
99
|
+
readonly normalizedName: string;
|
|
100
|
+
readonly displayName: string;
|
|
101
|
+
readonly profilePicture: number;
|
|
102
|
+
readonly profileTheme: number;
|
|
103
|
+
readonly userTitle: number;
|
|
104
|
+
readonly successMessageFlags: string;
|
|
105
|
+
readonly isDeleted: boolean;
|
|
106
|
+
readonly about: string;
|
|
107
|
+
readonly firstAccess?: string;
|
|
108
|
+
readonly lastUpdate?: string;
|
|
109
|
+
readonly legacyPortalUID?: string;
|
|
110
|
+
readonly context: UserToUserContext;
|
|
111
|
+
readonly psnDisplayName: string;
|
|
112
|
+
readonly xboxDisplayName: string;
|
|
113
|
+
readonly fbDisplayName: string;
|
|
114
|
+
readonly showActivity?: boolean;
|
|
115
|
+
readonly locale: string;
|
|
116
|
+
readonly localeInheritDefault: boolean;
|
|
117
|
+
readonly lastBanReportId?: string;
|
|
118
|
+
readonly showGroupMessaging: boolean;
|
|
119
|
+
readonly profilePicturePath: string;
|
|
120
|
+
readonly profilePictureWidePath: string;
|
|
121
|
+
readonly profileThemeName: string;
|
|
122
|
+
readonly userTitleDisplay: string;
|
|
123
|
+
readonly statusText: string;
|
|
124
|
+
readonly statusDate: string;
|
|
125
|
+
readonly profileBanExpire?: string;
|
|
126
|
+
readonly blizzardDisplayName: string;
|
|
127
|
+
readonly steamDisplayName: string;
|
|
128
|
+
readonly stadiaDisplayName: string;
|
|
129
|
+
readonly twitchDisplayName: string;
|
|
130
|
+
readonly cachedBungieGlobalDisplayName: string;
|
|
131
|
+
readonly cachedBungieGlobalDisplayNameCode?: number;
|
|
132
|
+
readonly egsDisplayName: string;
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
export interface UserToUserContext {
|
|
136
|
+
readonly isFollowing: boolean;
|
|
137
|
+
readonly ignoreStatus: IgnoreResponse;
|
|
138
|
+
readonly globalIgnoreEndDate?: string;
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
export interface GetCredentialTypesForAccountResponse {
|
|
142
|
+
readonly credentialType: BungieCredentialType;
|
|
143
|
+
readonly credentialDisplayName: string;
|
|
144
|
+
readonly isPublic: boolean;
|
|
145
|
+
readonly credentialAsString: string;
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
export interface UserTheme {
|
|
149
|
+
readonly userThemeId: number;
|
|
150
|
+
readonly userThemeName: string;
|
|
151
|
+
readonly userThemeDescription: string;
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
export interface UserMembershipData {
|
|
155
|
+
/**
|
|
156
|
+
* this allows you to see destiny memberships that are visible and linked to this
|
|
157
|
+
* account (regardless of whether or not they have characters on the world server)
|
|
158
|
+
*/
|
|
159
|
+
readonly destinyMemberships: GroupUserInfoCard[];
|
|
160
|
+
/**
|
|
161
|
+
* If this property is populated, it will have the membership ID of the account
|
|
162
|
+
* considered to be "primary" in this user's cross save relationship.
|
|
163
|
+
*
|
|
164
|
+
* If null, this user has no cross save relationship, nor primary account.
|
|
165
|
+
*/
|
|
166
|
+
readonly primaryMembershipId?: string;
|
|
167
|
+
/**
|
|
168
|
+
* If this property is populated, it will have the membershipId for the Marathon
|
|
169
|
+
* Membership on this user's account
|
|
170
|
+
*
|
|
171
|
+
* If null, this user has no Marathon (i.e. "GoliathGame") membership.
|
|
172
|
+
*/
|
|
173
|
+
readonly marathonMembershipId?: string;
|
|
174
|
+
readonly bungieNetUser: GeneralUser;
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
export interface HardLinkedUserMembership {
|
|
178
|
+
readonly membershipType: BungieMembershipType;
|
|
179
|
+
readonly membershipId: string;
|
|
180
|
+
readonly CrossSaveOverriddenType: BungieMembershipType;
|
|
181
|
+
readonly CrossSaveOverriddenMembershipId?: string;
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
export interface UserSearchResponse {
|
|
185
|
+
readonly searchResults: UserSearchResponseDetail[];
|
|
186
|
+
readonly page: number;
|
|
187
|
+
readonly hasMore: boolean;
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
export interface UserSearchResponseDetail {
|
|
191
|
+
readonly bungieGlobalDisplayName: string;
|
|
192
|
+
readonly bungieGlobalDisplayNameCode?: number;
|
|
193
|
+
readonly bungieNetMembershipId?: string;
|
|
194
|
+
readonly destinyMemberships: UserInfoCard[];
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
/** Very basic info about a user as returned by the Account server. */
|
|
198
|
+
export interface UserMembership {
|
|
199
|
+
/** Type of the membership. Not necessarily the native type. */
|
|
200
|
+
readonly membershipType: BungieMembershipType;
|
|
201
|
+
/** Membership ID as they user is known in the Accounts service */
|
|
202
|
+
readonly membershipId: string;
|
|
203
|
+
/**
|
|
204
|
+
* Display Name the player has chosen for themselves. The display name is optional
|
|
205
|
+
* when the data type is used as input to a platform API.
|
|
206
|
+
*/
|
|
207
|
+
readonly displayName: string;
|
|
208
|
+
/** The bungie global display name, if set. */
|
|
209
|
+
readonly bungieGlobalDisplayName: string;
|
|
210
|
+
/** The bungie global display name code, if set. */
|
|
211
|
+
readonly bungieGlobalDisplayNameCode?: number;
|
|
212
|
+
}
|
|
213
|
+
|
|
214
|
+
export interface ExactSearchRequest {
|
|
215
|
+
readonly displayName: string;
|
|
216
|
+
readonly displayNameCode: number;
|
|
217
|
+
}
|
|
218
|
+
|
|
219
|
+
/** The set of all email subscription/opt-in settings and definitions. */
|
|
220
|
+
export interface EmailSettings {
|
|
221
|
+
/** Keyed by the name identifier of the opt-in definition. */
|
|
222
|
+
readonly optInDefinitions: { [key: string]: EmailOptInDefinition };
|
|
223
|
+
/** Keyed by the name identifier of the Subscription definition. */
|
|
224
|
+
readonly subscriptionDefinitions: { [key: string]: EmailSubscriptionDefinition };
|
|
225
|
+
/** Keyed by the name identifier of the View definition. */
|
|
226
|
+
readonly views: { [key: string]: EmailViewDefinition };
|
|
227
|
+
}
|
|
228
|
+
|
|
229
|
+
/**
|
|
230
|
+
* Defines a single opt-in category: a wide-scoped permission to send emails for
|
|
231
|
+
* the subject related to the opt-in.
|
|
232
|
+
*/
|
|
233
|
+
export interface EmailOptInDefinition {
|
|
234
|
+
/** The unique identifier for this opt-in category. */
|
|
235
|
+
readonly name: string;
|
|
236
|
+
/**
|
|
237
|
+
* The flag value for this opt-in category. For historical reasons, this is defined
|
|
238
|
+
* as a flags enum.
|
|
239
|
+
*
|
|
240
|
+
* This enum represents a set of flags - use bitwise operators to check which of
|
|
241
|
+
* these match your value.
|
|
242
|
+
*/
|
|
243
|
+
readonly value: OptInFlags;
|
|
244
|
+
/**
|
|
245
|
+
* If true, this opt-in setting should be set by default in situations where
|
|
246
|
+
* accounts are created without explicit choices about what they're opting into.
|
|
247
|
+
*/
|
|
248
|
+
readonly setByDefault: boolean;
|
|
249
|
+
/** Information about the dependent subscriptions for this opt-in. */
|
|
250
|
+
readonly dependentSubscriptions: EmailSubscriptionDefinition[];
|
|
251
|
+
}
|
|
252
|
+
|
|
253
|
+
/**
|
|
254
|
+
* This enum represents a set of flags - use bitwise operators to check which of
|
|
255
|
+
* these match your value.
|
|
256
|
+
*/
|
|
257
|
+
export const enum OptInFlags {
|
|
258
|
+
None = 0,
|
|
259
|
+
Newsletter = 1,
|
|
260
|
+
System = 2,
|
|
261
|
+
Marketing = 4,
|
|
262
|
+
UserResearch = 8,
|
|
263
|
+
CustomerService = 16,
|
|
264
|
+
Social = 32,
|
|
265
|
+
PlayTests = 64,
|
|
266
|
+
PlayTestsLocal = 128,
|
|
267
|
+
Careers = 256
|
|
268
|
+
}
|
|
269
|
+
|
|
270
|
+
/**
|
|
271
|
+
* Defines a single subscription: permission to send emails for a specific, focused
|
|
272
|
+
* subject (generally timeboxed, such as for a specific release of a product or
|
|
273
|
+
* feature).
|
|
274
|
+
*/
|
|
275
|
+
export interface EmailSubscriptionDefinition {
|
|
276
|
+
/** The unique identifier for this subscription. */
|
|
277
|
+
readonly name: string;
|
|
278
|
+
/** A dictionary of localized text for the EMail Opt-in setting, keyed by the locale. */
|
|
279
|
+
readonly localization: { [key: string]: EMailSettingSubscriptionLocalization };
|
|
280
|
+
/** The bitflag value for this subscription. Should be a unique power of two value. */
|
|
281
|
+
readonly value: string;
|
|
282
|
+
}
|
|
283
|
+
|
|
284
|
+
/**
|
|
285
|
+
* Localized text relevant to a given EMail setting in a given localization. Extra
|
|
286
|
+
* settings specifically for subscriptions.
|
|
287
|
+
*/
|
|
288
|
+
export interface EMailSettingSubscriptionLocalization {
|
|
289
|
+
readonly unknownUserDescription: string;
|
|
290
|
+
readonly registeredUserDescription: string;
|
|
291
|
+
readonly unregisteredUserDescription: string;
|
|
292
|
+
readonly unknownUserActionText: string;
|
|
293
|
+
readonly knownUserActionText: string;
|
|
294
|
+
readonly title: string;
|
|
295
|
+
readonly description: string;
|
|
296
|
+
}
|
|
297
|
+
|
|
298
|
+
/**
|
|
299
|
+
* Represents a data-driven view for Email settings. Web/Mobile UI can use this
|
|
300
|
+
* data to show new EMail settings consistently without further manual work.
|
|
301
|
+
*/
|
|
302
|
+
export interface EmailViewDefinition {
|
|
303
|
+
/** The identifier for this view. */
|
|
304
|
+
readonly name: string;
|
|
305
|
+
/** The ordered list of settings to show in this view. */
|
|
306
|
+
readonly viewSettings: EmailViewDefinitionSetting[];
|
|
307
|
+
}
|
|
308
|
+
|
|
309
|
+
export interface EmailViewDefinitionSetting {
|
|
310
|
+
/**
|
|
311
|
+
* The identifier for this UI Setting, which can be used to relate it to custom
|
|
312
|
+
* strings or other data as desired.
|
|
313
|
+
*/
|
|
314
|
+
readonly name: string;
|
|
315
|
+
/** A dictionary of localized text for the EMail setting, keyed by the locale. */
|
|
316
|
+
readonly localization: { [key: string]: EMailSettingLocalization };
|
|
317
|
+
/**
|
|
318
|
+
* If true, this setting should be set by default if the user hasn't chosen whether
|
|
319
|
+
* it's set or cleared yet.
|
|
320
|
+
*/
|
|
321
|
+
readonly setByDefault: boolean;
|
|
322
|
+
/**
|
|
323
|
+
* The OptInFlags value to set or clear if this setting is set or cleared in the UI.
|
|
324
|
+
* It is the aggregate of all underlying opt-in flags related to this setting.
|
|
325
|
+
*
|
|
326
|
+
* This enum represents a set of flags - use bitwise operators to check which of
|
|
327
|
+
* these match your value.
|
|
328
|
+
*/
|
|
329
|
+
readonly optInAggregateValue: OptInFlags;
|
|
330
|
+
/** The subscriptions to show as children of this setting, if any. */
|
|
331
|
+
readonly subscriptions: EmailSubscriptionDefinition[];
|
|
332
|
+
}
|
|
333
|
+
|
|
334
|
+
/** Localized text relevant to a given EMail setting in a given localization. */
|
|
335
|
+
export interface EMailSettingLocalization {
|
|
336
|
+
readonly title: string;
|
|
337
|
+
readonly description: string;
|
|
338
|
+
}
|
|
@@ -0,0 +1,254 @@
|
|
|
1
|
+
import {
|
|
2
|
+
DefInfo,
|
|
3
|
+
getRef,
|
|
4
|
+
isReferenceObject,
|
|
5
|
+
isRequestBodyObject,
|
|
6
|
+
lastPart,
|
|
7
|
+
lcFirst,
|
|
8
|
+
resolveSchemaType,
|
|
9
|
+
} from './util.js';
|
|
10
|
+
import { OpenAPIObject, ParameterObject, PathItemObject } from 'openapi3-ts';
|
|
11
|
+
import {
|
|
12
|
+
addImport,
|
|
13
|
+
docComment,
|
|
14
|
+
generateHeader,
|
|
15
|
+
generateImports,
|
|
16
|
+
indent,
|
|
17
|
+
writeOutFile,
|
|
18
|
+
} from './generate-common.js';
|
|
19
|
+
|
|
20
|
+
const httpClientType = `import { HttpClient, get, post } from '../http.js';`;
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* Generate an api.ts file for a particular "service", which is defined by a specific tag on the path entry
|
|
24
|
+
* in the OpenAPI spec. e.g. all the User service paths have the tag "User".
|
|
25
|
+
*/
|
|
26
|
+
export function generateServiceDefinition(
|
|
27
|
+
tag: string,
|
|
28
|
+
paths: [path: string, pathDef: PathItemObject][],
|
|
29
|
+
doc: OpenAPIObject,
|
|
30
|
+
componentByDef: { [def: string]: DefInfo }
|
|
31
|
+
): void {
|
|
32
|
+
const importFiles: { [filename: string]: Set<string> } = {};
|
|
33
|
+
|
|
34
|
+
let server = doc.servers![0].url;
|
|
35
|
+
const prefix = getLongestCommonPrefix(paths.map((p) => p[0]));
|
|
36
|
+
|
|
37
|
+
const pathDefinitions = paths.map(([path, pathDef]) =>
|
|
38
|
+
generatePathDefinition(path, pathDef, doc, componentByDef, importFiles, prefix)
|
|
39
|
+
);
|
|
40
|
+
|
|
41
|
+
const filename = `generated-src/${tag.toLowerCase()}/api.ts`;
|
|
42
|
+
|
|
43
|
+
const imports = generateImports(filename, importFiles);
|
|
44
|
+
|
|
45
|
+
const apiBase = `const API_BASE = "${server}${prefix}";`;
|
|
46
|
+
|
|
47
|
+
const definition =
|
|
48
|
+
[
|
|
49
|
+
generateHeader(doc),
|
|
50
|
+
httpClientType,
|
|
51
|
+
imports,
|
|
52
|
+
prefix.length > 0 ? apiBase : undefined,
|
|
53
|
+
...pathDefinitions,
|
|
54
|
+
]
|
|
55
|
+
.filter(Boolean)
|
|
56
|
+
.join('\n\n') + '\n';
|
|
57
|
+
|
|
58
|
+
writeOutFile(filename, definition);
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
/**
|
|
62
|
+
* Generate a properly typed function for the API implementation, that will pass the correct parameters
|
|
63
|
+
* to the HTTP client.
|
|
64
|
+
*
|
|
65
|
+
* Example:
|
|
66
|
+
*
|
|
67
|
+
* export function getVendors(http: HttpClient, params: GetVendorsParams): Promise<ServerResponse<DestinyVendorsResponse>> {
|
|
68
|
+
* return http({
|
|
69
|
+
* method: 'GET',
|
|
70
|
+
* url: `https://www.bungie.net/Platform/Destiny2/${params.membershipType}/Profile/${params.destinyMembershipId}/Character/${params.characterId}/Vendors/`,
|
|
71
|
+
* params: {
|
|
72
|
+
* components: params.components?.join(','),
|
|
73
|
+
* filter: params.filter
|
|
74
|
+
* }
|
|
75
|
+
* });
|
|
76
|
+
* }
|
|
77
|
+
*/
|
|
78
|
+
function generatePathDefinition(
|
|
79
|
+
/** The path specification for the API */
|
|
80
|
+
path: string,
|
|
81
|
+
/** OpenAPI information about the path object */
|
|
82
|
+
pathDef: PathItemObject,
|
|
83
|
+
/** The whole OpenAPI document */
|
|
84
|
+
doc: OpenAPIObject,
|
|
85
|
+
componentByDef: Readonly<{ [def: string]: DefInfo }>,
|
|
86
|
+
importFiles: { [filename: string]: Set<string> }, // mutated
|
|
87
|
+
pathPrefix: string
|
|
88
|
+
) {
|
|
89
|
+
let server = doc.servers![0].url;
|
|
90
|
+
// per https://github.com/Bungie-net/api/issues/853
|
|
91
|
+
// strict condition, so no surprises if doc.servers changes
|
|
92
|
+
let usePathPrefix = pathPrefix.length > 0;
|
|
93
|
+
if (
|
|
94
|
+
server === 'https://www.bungie.net/Platform' &&
|
|
95
|
+
path.includes('/Stats/PostGameCarnageReport/')
|
|
96
|
+
) {
|
|
97
|
+
server = 'https://stats.bungie.net/Platform';
|
|
98
|
+
usePathPrefix = false;
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
if (usePathPrefix) {
|
|
102
|
+
path = path.substring(pathPrefix.length);
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
const interfaceName = lastPart(pathDef.summary!);
|
|
106
|
+
const functionName = lcFirst(interfaceName);
|
|
107
|
+
|
|
108
|
+
const method = pathDef.get ? 'GET' : 'POST';
|
|
109
|
+
const methodDef = pathDef.get || pathDef.post!;
|
|
110
|
+
const params = (methodDef.parameters || []) as ParameterObject[];
|
|
111
|
+
|
|
112
|
+
const queryParameterNames = params
|
|
113
|
+
.filter((param) => param.in === 'query')
|
|
114
|
+
.map((param) => param.name);
|
|
115
|
+
|
|
116
|
+
const parameterArgs: string[] = [`http: HttpClient`];
|
|
117
|
+
|
|
118
|
+
let interfaceDefinition = '';
|
|
119
|
+
if (params.length) {
|
|
120
|
+
interfaceDefinition =
|
|
121
|
+
generateInterfaceSchema(interfaceName + 'Params', params, doc, componentByDef, importFiles) +
|
|
122
|
+
'\n\n';
|
|
123
|
+
parameterArgs.push(`params: ${interfaceName}Params`);
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
if (methodDef.requestBody) {
|
|
127
|
+
if (isRequestBodyObject(methodDef.requestBody)) {
|
|
128
|
+
const schema = methodDef.requestBody.content['application/json'].schema!;
|
|
129
|
+
|
|
130
|
+
const paramType = resolveSchemaType(schema, doc);
|
|
131
|
+
addImport(doc, schema, componentByDef, importFiles);
|
|
132
|
+
const docString = methodDef.requestBody.description
|
|
133
|
+
? docComment(methodDef.requestBody.description) + '\n'
|
|
134
|
+
: '';
|
|
135
|
+
parameterArgs.push(
|
|
136
|
+
`${docString}body${methodDef.requestBody.required ? '' : '?'}: ${paramType}`
|
|
137
|
+
);
|
|
138
|
+
} else if (isReferenceObject(methodDef.requestBody)) {
|
|
139
|
+
throw new Error("didn't expect this");
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
const templatizedPath = `\`${usePathPrefix ? '${API_BASE}' : server}${path.replace(
|
|
144
|
+
/{/g,
|
|
145
|
+
'${params.'
|
|
146
|
+
)}\``;
|
|
147
|
+
|
|
148
|
+
let paramsObject = '';
|
|
149
|
+
if (queryParameterNames.length) {
|
|
150
|
+
const paramInitializers = queryParameterNames.map((p) => {
|
|
151
|
+
const param = params.find((pa) => pa.name === p)!;
|
|
152
|
+
const paramType = resolveSchemaType(param.schema!, doc);
|
|
153
|
+
|
|
154
|
+
if (paramType.endsWith('[]')) {
|
|
155
|
+
if (!param.required) {
|
|
156
|
+
return `if (params.${p}?.length) { strParams.${p} = params.${p}.join(','); }`;
|
|
157
|
+
}
|
|
158
|
+
return `strParams.${p} = params.${p}.join(',');`;
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
return param.required
|
|
162
|
+
? `strParams.${p} = params.${p}.toString();`
|
|
163
|
+
: `if (params.${p} !== undefined) { strParams.${p} = params.${p}${
|
|
164
|
+
paramType === 'string' ? '' : '.toString()'
|
|
165
|
+
}; }`;
|
|
166
|
+
});
|
|
167
|
+
|
|
168
|
+
paramsObject = `const strParams: Record<string, string> = {};
|
|
169
|
+
${indent(paramInitializers.join('\n'), 1)}
|
|
170
|
+
`;
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
let requestBodyParam = '';
|
|
174
|
+
if (methodDef.requestBody && isRequestBodyObject(methodDef.requestBody)) {
|
|
175
|
+
requestBodyParam = ', body';
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
const returnValue = resolveSchemaType(methodDef.responses['200'], doc);
|
|
179
|
+
addImport(doc, methodDef.responses['200'], componentByDef, importFiles);
|
|
180
|
+
|
|
181
|
+
const rateDoc =
|
|
182
|
+
methodDef['x-documentation-attributes']?.ThrottleSecondsBetweenActionPerUser &&
|
|
183
|
+
`Wait at least ${methodDef['x-documentation-attributes']?.ThrottleSecondsBetweenActionPerUser}s between actions.`;
|
|
184
|
+
|
|
185
|
+
const fnBody =
|
|
186
|
+
method == 'GET'
|
|
187
|
+
? `${paramsObject}return get(http, ${templatizedPath}${
|
|
188
|
+
paramsObject.length ? ', strParams' : ''
|
|
189
|
+
})`
|
|
190
|
+
: ` return post(http, ${templatizedPath}${requestBodyParam})`;
|
|
191
|
+
|
|
192
|
+
return `${interfaceDefinition}${docComment(
|
|
193
|
+
methodDef.description! + (rateDoc ? '\n' + rateDoc : '')
|
|
194
|
+
)}
|
|
195
|
+
export function ${functionName}(${parameterArgs.join(', ')}): Promise<${returnValue}> {
|
|
196
|
+
${fnBody};
|
|
197
|
+
}`;
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
function generateInterfaceSchema(
|
|
201
|
+
interfaceName: string,
|
|
202
|
+
params: ParameterObject[],
|
|
203
|
+
doc: OpenAPIObject,
|
|
204
|
+
componentByDef: { [def: string]: DefInfo },
|
|
205
|
+
importFiles: { [filename: string]: Set<string> }
|
|
206
|
+
) {
|
|
207
|
+
const parameterArgs = params.map((param) => {
|
|
208
|
+
// TODO: in general, need something that returns a type object
|
|
209
|
+
const paramType = resolveSchemaType(param.schema!, doc);
|
|
210
|
+
addImport(doc, param.schema!, componentByDef, importFiles);
|
|
211
|
+
const docString = param.description ? docComment(param.description) + '\n' : '';
|
|
212
|
+
return `${docString}${param.name}${
|
|
213
|
+
param.required || (param.name === 'components' && paramType === 'DestinyComponentType[]')
|
|
214
|
+
? ''
|
|
215
|
+
: '?'
|
|
216
|
+
}: ${paramType};`;
|
|
217
|
+
});
|
|
218
|
+
|
|
219
|
+
return `export interface ${interfaceName} {
|
|
220
|
+
${indent(parameterArgs.join('\n'), 1)}
|
|
221
|
+
}`;
|
|
222
|
+
}
|
|
223
|
+
|
|
224
|
+
/**
|
|
225
|
+
* Find the longest prefix for a list of strings.
|
|
226
|
+
*
|
|
227
|
+
* @example
|
|
228
|
+
*
|
|
229
|
+
* // Returns "/Destiny2/"
|
|
230
|
+
* getLongestCommonPrefix("Destiny2/Clan/{groupId}/WeeklyRewardState/", "/Destiny2/Clan/ClanBannerDictionary/", "/Destiny2/{membershipType}/Profile/{destinyMembershipId}/Character/{characterId}/")
|
|
231
|
+
*/
|
|
232
|
+
function getLongestCommonPrefix(paths: string[]) {
|
|
233
|
+
if (paths.length < 2) {
|
|
234
|
+
return '';
|
|
235
|
+
}
|
|
236
|
+
|
|
237
|
+
let prefixLetters = '';
|
|
238
|
+
|
|
239
|
+
let index = 0;
|
|
240
|
+
for (const letter of paths[0]) {
|
|
241
|
+
if (letter === '{') {
|
|
242
|
+
break;
|
|
243
|
+
}
|
|
244
|
+
for (const path of paths) {
|
|
245
|
+
if (path[index] !== letter) {
|
|
246
|
+
return prefixLetters;
|
|
247
|
+
}
|
|
248
|
+
}
|
|
249
|
+
prefixLetters = prefixLetters.concat(letter);
|
|
250
|
+
index++;
|
|
251
|
+
}
|
|
252
|
+
|
|
253
|
+
return prefixLetters;
|
|
254
|
+
}
|