@taskeren/bungie-api-ts 5.10.0 → 5.10.2

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.
Files changed (162) hide show
  1. package/package.json +66 -27
  2. package/.babelrc +0 -4
  3. package/.gitattributes +0 -2
  4. package/.github/workflows/pr-build.yml +0 -50
  5. package/.github/workflows/publish.yml +0 -48
  6. package/.github/workflows/update.yml +0 -55
  7. package/.gitmodules +0 -3
  8. package/.nvmrc +0 -1
  9. package/.prettierrc +0 -10
  10. package/.vscode/extensions.json +0 -8
  11. package/.vscode/settings.json +0 -7
  12. package/LICENSE.md +0 -21
  13. package/api-src/.github/workflows/close-inactive.yml +0 -24
  14. package/api-src/CHANGELOG.md +0 -271
  15. package/api-src/CONTRIBUTING.md +0 -19
  16. package/api-src/LICENSE +0 -28
  17. package/api-src/README.md +0 -378
  18. package/api-src/openapi-2.json +0 -44518
  19. package/api-src/openapi.json +0 -46467
  20. package/build.sh +0 -30
  21. package/generated-src/app/api.ts +0 -50
  22. package/generated-src/app/index.ts +0 -17
  23. package/generated-src/app/interfaces.ts +0 -119
  24. package/generated-src/common.ts +0 -985
  25. package/generated-src/communitycontent/api.ts +0 -36
  26. package/generated-src/communitycontent/index.ts +0 -16
  27. package/generated-src/content/api.ts +0 -142
  28. package/generated-src/content/index.ts +0 -17
  29. package/generated-src/content/interfaces.ts +0 -225
  30. package/generated-src/core/api.ts +0 -57
  31. package/generated-src/core/index.ts +0 -17
  32. package/generated-src/core/interfaces.ts +0 -151
  33. package/generated-src/destiny2/api.ts +0 -821
  34. package/generated-src/destiny2/index.ts +0 -17
  35. package/generated-src/destiny2/interfaces.ts +0 -15714
  36. package/generated-src/destiny2/manifest.ts +0 -341
  37. package/generated-src/fireteam/api.ts +0 -151
  38. package/generated-src/fireteam/index.ts +0 -17
  39. package/generated-src/fireteam/interfaces.ts +0 -183
  40. package/generated-src/forum/api.ts +0 -197
  41. package/generated-src/forum/index.ts +0 -17
  42. package/generated-src/forum/interfaces.ts +0 -171
  43. package/generated-src/groupv2/api.ts +0 -515
  44. package/generated-src/groupv2/index.ts +0 -17
  45. package/generated-src/groupv2/interfaces.ts +0 -773
  46. package/generated-src/http.ts +0 -52
  47. package/generated-src/index.ts +0 -37
  48. package/generated-src/package.json.notyet +0 -99
  49. package/generated-src/platform.ts +0 -39
  50. package/generated-src/social/api.ts +0 -115
  51. package/generated-src/social/index.ts +0 -17
  52. package/generated-src/social/interfaces.ts +0 -89
  53. package/generated-src/tokens/api.ts +0 -126
  54. package/generated-src/tokens/index.ts +0 -17
  55. package/generated-src/tokens/interfaces.ts +0 -102
  56. package/generated-src/trending/api.ts +0 -62
  57. package/generated-src/trending/index.ts +0 -17
  58. package/generated-src/trending/interfaces.ts +0 -188
  59. package/generated-src/user/api.ts +0 -130
  60. package/generated-src/user/index.ts +0 -17
  61. package/generated-src/user/interfaces.ts +0 -338
  62. package/generator/generate-api.ts +0 -254
  63. package/generator/generate-common.ts +0 -123
  64. package/generator/generate-index.ts +0 -45
  65. package/generator/generate-interfaces.ts +0 -173
  66. package/generator/generate-manifest.ts +0 -217
  67. package/generator/generate-package-json.ts +0 -45
  68. package/generator/generate.ts +0 -54
  69. package/generator/http.ts +0 -52
  70. package/generator/missing-props.ts +0 -11
  71. package/generator/type-index.ts +0 -184
  72. package/generator/util.ts +0 -131
  73. package/lib/README.md +0 -97
  74. package/lib/bungie-api-LICENSE +0 -29
  75. package/lib/package.json +0 -99
  76. package/test-consumer.ts +0 -5
  77. package/tests/__snapshots__/config-builders.test.ts.snap +0 -343
  78. package/tests/config-builders.test.ts +0 -145
  79. package/tests/manifest-fetcher.test.ts +0 -43
  80. package/tests/test-manifest.js +0 -69
  81. package/tsconfig-package.json +0 -14
  82. package/tsconfig.json +0 -17
  83. /package/{lib/app → app}/api.d.ts +0 -0
  84. /package/{lib/app → app}/api.js +0 -0
  85. /package/{lib/app → app}/index.d.ts +0 -0
  86. /package/{lib/app → app}/index.js +0 -0
  87. /package/{lib/app → app}/interfaces.d.ts +0 -0
  88. /package/{lib/app → app}/interfaces.js +0 -0
  89. /package/{lib/common.d.ts → common.d.ts} +0 -0
  90. /package/{lib/common.js → common.js} +0 -0
  91. /package/{lib/communitycontent → communitycontent}/api.d.ts +0 -0
  92. /package/{lib/communitycontent → communitycontent}/api.js +0 -0
  93. /package/{lib/communitycontent → communitycontent}/index.d.ts +0 -0
  94. /package/{lib/communitycontent → communitycontent}/index.js +0 -0
  95. /package/{lib/content → content}/api.d.ts +0 -0
  96. /package/{lib/content → content}/api.js +0 -0
  97. /package/{lib/content → content}/index.d.ts +0 -0
  98. /package/{lib/content → content}/index.js +0 -0
  99. /package/{lib/content → content}/interfaces.d.ts +0 -0
  100. /package/{lib/content → content}/interfaces.js +0 -0
  101. /package/{lib/core → core}/api.d.ts +0 -0
  102. /package/{lib/core → core}/api.js +0 -0
  103. /package/{lib/core → core}/index.d.ts +0 -0
  104. /package/{lib/core → core}/index.js +0 -0
  105. /package/{lib/core → core}/interfaces.d.ts +0 -0
  106. /package/{lib/core → core}/interfaces.js +0 -0
  107. /package/{lib/destiny2 → destiny2}/api.d.ts +0 -0
  108. /package/{lib/destiny2 → destiny2}/api.js +0 -0
  109. /package/{lib/destiny2 → destiny2}/index.d.ts +0 -0
  110. /package/{lib/destiny2 → destiny2}/index.js +0 -0
  111. /package/{lib/destiny2 → destiny2}/interfaces.d.ts +0 -0
  112. /package/{lib/destiny2 → destiny2}/interfaces.js +0 -0
  113. /package/{lib/destiny2 → destiny2}/manifest.d.ts +0 -0
  114. /package/{lib/destiny2 → destiny2}/manifest.js +0 -0
  115. /package/{lib/fireteam → fireteam}/api.d.ts +0 -0
  116. /package/{lib/fireteam → fireteam}/api.js +0 -0
  117. /package/{lib/fireteam → fireteam}/index.d.ts +0 -0
  118. /package/{lib/fireteam → fireteam}/index.js +0 -0
  119. /package/{lib/fireteam → fireteam}/interfaces.d.ts +0 -0
  120. /package/{lib/fireteam → fireteam}/interfaces.js +0 -0
  121. /package/{lib/forum → forum}/api.d.ts +0 -0
  122. /package/{lib/forum → forum}/api.js +0 -0
  123. /package/{lib/forum → forum}/index.d.ts +0 -0
  124. /package/{lib/forum → forum}/index.js +0 -0
  125. /package/{lib/forum → forum}/interfaces.d.ts +0 -0
  126. /package/{lib/forum → forum}/interfaces.js +0 -0
  127. /package/{lib/groupv2 → groupv2}/api.d.ts +0 -0
  128. /package/{lib/groupv2 → groupv2}/api.js +0 -0
  129. /package/{lib/groupv2 → groupv2}/index.d.ts +0 -0
  130. /package/{lib/groupv2 → groupv2}/index.js +0 -0
  131. /package/{lib/groupv2 → groupv2}/interfaces.d.ts +0 -0
  132. /package/{lib/groupv2 → groupv2}/interfaces.js +0 -0
  133. /package/{lib/http.d.ts → http.d.ts} +0 -0
  134. /package/{lib/http.js → http.js} +0 -0
  135. /package/{lib/index.d.ts → index.d.ts} +0 -0
  136. /package/{lib/index.js → index.js} +0 -0
  137. /package/{lib/platform.d.ts → platform.d.ts} +0 -0
  138. /package/{lib/platform.js → platform.js} +0 -0
  139. /package/{lib/social → social}/api.d.ts +0 -0
  140. /package/{lib/social → social}/api.js +0 -0
  141. /package/{lib/social → social}/index.d.ts +0 -0
  142. /package/{lib/social → social}/index.js +0 -0
  143. /package/{lib/social → social}/interfaces.d.ts +0 -0
  144. /package/{lib/social → social}/interfaces.js +0 -0
  145. /package/{lib/tokens → tokens}/api.d.ts +0 -0
  146. /package/{lib/tokens → tokens}/api.js +0 -0
  147. /package/{lib/tokens → tokens}/index.d.ts +0 -0
  148. /package/{lib/tokens → tokens}/index.js +0 -0
  149. /package/{lib/tokens → tokens}/interfaces.d.ts +0 -0
  150. /package/{lib/tokens → tokens}/interfaces.js +0 -0
  151. /package/{lib/trending → trending}/api.d.ts +0 -0
  152. /package/{lib/trending → trending}/api.js +0 -0
  153. /package/{lib/trending → trending}/index.d.ts +0 -0
  154. /package/{lib/trending → trending}/index.js +0 -0
  155. /package/{lib/trending → trending}/interfaces.d.ts +0 -0
  156. /package/{lib/trending → trending}/interfaces.js +0 -0
  157. /package/{lib/user → user}/api.d.ts +0 -0
  158. /package/{lib/user → user}/api.js +0 -0
  159. /package/{lib/user → user}/index.d.ts +0 -0
  160. /package/{lib/user → user}/index.js +0 -0
  161. /package/{lib/user → user}/interfaces.d.ts +0 -0
  162. /package/{lib/user → user}/interfaces.js +0 -0
package/generator/http.ts DELETED
@@ -1,52 +0,0 @@
1
- export type HttpQueryParams = Record<string, string>;
2
-
3
- export interface HttpClientConfig {
4
- method: 'GET' | 'POST';
5
- url: string;
6
- /** Query string params */
7
- params?: HttpQueryParams;
8
- /** Request body */
9
- body?: any;
10
- }
11
-
12
- /**
13
- * A generic, minimal type for providing an HTTP client function.
14
- * This gets the necessary config provided as an argument, and then
15
- * should produce a promise for the parsed JSON as a result. The API
16
- * helper functions will use this to return the right type.
17
- */
18
- export type HttpClient = <Return>(config: HttpClientConfig) => Promise<Return>;
19
-
20
- export function get<Return>(
21
- http: HttpClient,
22
- url: string,
23
- params?: HttpQueryParams
24
- ): Promise<Return> {
25
- return http(
26
- params
27
- ? {
28
- method: 'GET',
29
- url,
30
- params,
31
- }
32
- : {
33
- method: 'GET',
34
- url,
35
- }
36
- );
37
- }
38
-
39
- export function post<Return>(http: HttpClient, url: string, body?: any): Promise<Return> {
40
- return http(
41
- body
42
- ? {
43
- method: 'POST',
44
- url,
45
- body,
46
- }
47
- : {
48
- method: 'POST',
49
- url,
50
- }
51
- );
52
- }
@@ -1,11 +0,0 @@
1
- import { SchemaObject } from 'openapi3-ts';
2
-
3
- export const missingPropsByInterfaceName: {
4
- [propertyName: string]: SchemaObject;
5
- } = {
6
- DestinyArtifactTierItem: {
7
- isVisible: {
8
- type: 'boolean',
9
- },
10
- },
11
- };
@@ -1,184 +0,0 @@
1
- import _ from 'lodash';
2
- import {
3
- OpenAPIObject,
4
- PathItemObject,
5
- ParameterObject,
6
- SchemaObject,
7
- ReferenceObject,
8
- } from 'openapi3-ts';
9
- import {
10
- getRef,
11
- lastPart,
12
- getReferencedTypes,
13
- DefInfo,
14
- interfaceName,
15
- isRequestBodyObject,
16
- } from './util.js';
17
-
18
- export function computeTypeMaps(
19
- pathPairsByTag: { [tag: string]: [string, PathItemObject][] },
20
- doc: OpenAPIObject
21
- ) {
22
- const allDefsEverywhere = new Set<string>();
23
- const defsByTag: { [tag: string]: Set<string> } = {};
24
- _.each(pathPairsByTag, (paths, tag) => {
25
- const defs = findReachableComponents(paths, doc);
26
- addAll(allDefsEverywhere, defs);
27
- defsByTag[tag] = defs;
28
- });
29
-
30
- // Add manifest tables that aren't referenced by any API endpoint.
31
- for (const [defName, def] of Object.entries(doc.components!.schemas!)) {
32
- const typePath = `#/components/schemas/${defName}`;
33
- if (
34
- !allDefsEverywhere.has(typePath) &&
35
- 'type' in def &&
36
- def.type === 'object' &&
37
- def['x-mobile-manifest-name']
38
- ) {
39
- console.log(`Found unreferenced manifest table ${typePath}`);
40
- allDefsEverywhere.add(typePath);
41
- addReachableComponentsFromComponent(allDefsEverywhere, typePath, doc);
42
- }
43
- }
44
-
45
- const allTags = Object.keys(pathPairsByTag);
46
-
47
- const componentsByFile: { [filename: string]: DefInfo[] } = {};
48
- const componentByDef: { [def: string]: DefInfo } = {};
49
- for (const def of allDefsEverywhere) {
50
- const tags: string[] = [];
51
- _.each(defsByTag, (defs: Set<string>, tag) => {
52
- if (defs.has(def)) {
53
- tags.push(tag);
54
- }
55
- });
56
- const info: DefInfo = {
57
- def,
58
- tags,
59
- filename: chooseFile(def, tags, allTags),
60
- interfaceName: interfaceName(def, doc),
61
- };
62
-
63
- componentsByFile[info.filename] = componentsByFile[info.filename] || [];
64
- componentsByFile[info.filename].push(info);
65
- componentByDef[info.def] = info;
66
- }
67
-
68
- return { componentsByFile, componentByDef };
69
- }
70
-
71
- // TODO: put enums in a separate file???
72
- // TODO: put things ending in Request in a separate file?
73
- // TODO: put manifest stuff in a separate file?
74
- function chooseFile(def: string, tags: string[], allTags: string[]) {
75
- const schemaName: string = _.last(def.split('/'))!;
76
- const matchingTag = allTags.find((tag) => schemaName.startsWith(tag + '.'));
77
-
78
- const filename = '/interfaces.ts';
79
- if (matchingTag) {
80
- return matchingTag.toLowerCase() + filename;
81
- } else if (schemaName.startsWith('GroupsV2.')) {
82
- return 'groupv2' + filename;
83
- } else if (schemaName.startsWith('Destiny.')) {
84
- return 'destiny2' + filename;
85
- } else {
86
- if (tags.length === 1) {
87
- return tags[0].toLowerCase() + filename;
88
- } else if (!tags.includes('Destiny2')) {
89
- return 'platform.ts';
90
- } else {
91
- return 'common.ts';
92
- }
93
- }
94
- }
95
-
96
- function findReachableComponents(paths: [string, PathItemObject][], doc: OpenAPIObject) {
97
- const pathDefinitions = paths.reduce(
98
- (memo: Set<string>, [_, pathDef]) => addAll(memo, findReachableComponentsFromPath(pathDef)),
99
- new Set<string>()
100
- );
101
-
102
- const allDefinitions = new Set(pathDefinitions);
103
- pathDefinitions.forEach((definition) =>
104
- addReachableComponentsFromComponent(allDefinitions, definition, doc)
105
- );
106
- return allDefinitions;
107
- }
108
-
109
- function addAll<T>(first: Set<T>, second: Set<T>): Set<T> {
110
- for (const value of second) {
111
- first.add(value);
112
- }
113
- return first;
114
- }
115
-
116
- function findReachableComponentsFromPath(pathDef: PathItemObject): Set<string> {
117
- const methodDef = pathDef.get || pathDef.post!;
118
- const params = (methodDef.parameters || []) as ParameterObject[];
119
- const paramTypes = new Set(
120
- params.map((param) => getReferencedTypes(param.schema!)).filter((p) => p)
121
- ) as Set<string>;
122
-
123
- const requestBody = methodDef.requestBody;
124
- if (requestBody && isRequestBodyObject(requestBody)) {
125
- const schema = requestBody.content['application/json'].schema!;
126
- const paramType = getReferencedTypes(schema);
127
- if (paramType) {
128
- paramTypes.add(paramType);
129
- }
130
- }
131
-
132
- const returnType = getReferencedTypes(methodDef.responses['200']);
133
- if (returnType) {
134
- paramTypes.add(returnType);
135
- }
136
-
137
- return paramTypes;
138
- }
139
-
140
- function addReachableComponentsFromComponent(
141
- allDefinitions: Set<string>,
142
- definition: string,
143
- doc: OpenAPIObject
144
- ) {
145
- const component = getRef(doc, definition);
146
- if (!component) {
147
- return;
148
- }
149
-
150
- if (component && component.type === 'array') {
151
- addDefinitions(allDefinitions, component.items!, doc);
152
- } else if (component.type === 'object') {
153
- if (component.properties) {
154
- Object.values(component.properties).forEach((schema: SchemaObject | ReferenceObject) => {
155
- addDefinitions(allDefinitions, schema, doc);
156
- });
157
- }
158
- (component.allOf || []).forEach((schema: SchemaObject | ReferenceObject) => {
159
- addDefinitions(allDefinitions, schema, doc);
160
- });
161
- if (component.additionalProperties && typeof component.additionalProperties !== 'boolean') {
162
- addDefinitions(allDefinitions, component.additionalProperties, doc);
163
- }
164
- }
165
- }
166
-
167
- function addDefinitions(allDefinitions: Set<string>, schema: SchemaObject, doc: OpenAPIObject) {
168
- const newDefinition = getReferencedTypes(schema);
169
- addDefinitionsFromComponent(allDefinitions, newDefinition, doc);
170
- if (schema['x-mapped-definition']) {
171
- addDefinitionsFromComponent(allDefinitions, schema['x-mapped-definition'].$ref, doc);
172
- }
173
- }
174
-
175
- function addDefinitionsFromComponent(
176
- allDefinitions: Set<string>,
177
- definition: string | undefined,
178
- doc: OpenAPIObject
179
- ) {
180
- if (definition && !allDefinitions.has(definition)) {
181
- allDefinitions.add(definition);
182
- addReachableComponentsFromComponent(allDefinitions, definition, doc);
183
- }
184
- }
package/generator/util.ts DELETED
@@ -1,131 +0,0 @@
1
- import { SchemaObject, ReferenceObject, OpenAPIObject, RequestBodyObject } from 'openapi3-ts';
2
- import _ from 'lodash';
3
-
4
- export interface DefInfo {
5
- def: string;
6
- tags: string[];
7
- filename: string;
8
- interfaceName: string;
9
- }
10
-
11
- export function resolveSchemaType(
12
- schema: SchemaObject | ReferenceObject,
13
- doc: OpenAPIObject
14
- ): string {
15
- if (isReferenceObject(schema)) {
16
- return interfaceName(schema.$ref, doc);
17
- } else if (schema['x-enum-reference']) {
18
- return interfaceName(schema['x-enum-reference'].$ref, doc);
19
- } else {
20
- return typeMapping(schema, doc);
21
- }
22
- }
23
-
24
- export function typeMapping(schema: SchemaObject, doc: OpenAPIObject): string {
25
- switch (schema.type) {
26
- case 'string':
27
- return schema.format === 'byte' ? 'number' : 'string';
28
- case 'integer':
29
- // JS can't represent a 64-bit int as a number, so bungie.net returns it as a string in JSON
30
- return schema.format === 'int64' ? 'string' : 'number';
31
-
32
- case 'array':
33
- return resolveSchemaType(schema.items!, doc) + '[]';
34
- case 'object':
35
- if (schema.allOf) {
36
- return resolveSchemaType(schema.allOf[0], doc);
37
- } else if (
38
- schema.additionalProperties &&
39
- schema['x-dictionary-key'] &&
40
- typeof schema.additionalProperties !== 'boolean'
41
- ) {
42
- const keySchema: SchemaObject | ReferenceObject = schema['x-dictionary-key'];
43
- const key = isReferenceObject(keySchema) ? 'number' : resolveSchemaType(keySchema, doc);
44
- const val = resolveSchemaType(schema.additionalProperties, doc);
45
- const keyExp = key === 'number' || key === 'string' ? `key: ${key}` : `key in ${key}`;
46
- return `{ [${keyExp}]: ${val} }`;
47
- }
48
- }
49
-
50
- return schema.type!;
51
- }
52
-
53
- export function getReferencedTypes(schema: SchemaObject | ReferenceObject): string | undefined {
54
- if (isReferenceObject(schema)) {
55
- return schema.$ref;
56
- } else if (schema['x-enum-reference']) {
57
- return schema['x-enum-reference'].$ref;
58
- } else if (schema.items) {
59
- return getReferencedTypes(schema.items!);
60
- } else if (schema.allOf) {
61
- return getReferencedTypes(schema.allOf[0]);
62
- } else if (schema.additionalProperties && typeof schema.additionalProperties !== 'boolean') {
63
- return getReferencedTypes(schema.additionalProperties);
64
- }
65
- }
66
-
67
- export function lcFirst(name: string): string {
68
- return name[0].toLowerCase() + name.substring(1);
69
- }
70
-
71
- export function lastPart(name: string): string {
72
- return _.last(name.split(/[\.\/]/))!;
73
- }
74
-
75
- export function getRef(doc: OpenAPIObject, ref: string): SchemaObject | undefined {
76
- const path = ref.replace('#/', '').split('/');
77
- let result = doc;
78
- let pathSegment = path.shift();
79
- while (pathSegment) {
80
- result = result[pathSegment];
81
- pathSegment = path.shift();
82
- }
83
- if (!result) {
84
- return undefined;
85
- }
86
- if (result.content) {
87
- return result.content['application/json'].schema;
88
- } else {
89
- return result;
90
- }
91
- }
92
-
93
- export function interfaceName(componentPath: string, doc: OpenAPIObject) {
94
- const name = lastPart(componentPath);
95
- const component = getRef(doc, componentPath);
96
- if (!component) {
97
- return 'any';
98
- }
99
-
100
- const singleResponse = name.match(/SingleComponentResponseOf(.*)/);
101
- if (singleResponse) {
102
- return `SingleComponentResponse<${singleResponse[1]}>`;
103
- }
104
-
105
- const dictionaryResponse = name.match(/DictionaryComponentResponseOfu?int(?:64|32)And(.*)/);
106
- if (dictionaryResponse) {
107
- return `DictionaryComponentResponse<${dictionaryResponse[1]}>`;
108
- }
109
-
110
- if (componentPath.includes('/responses/')) {
111
- const property = component.properties!.Response;
112
- if (property) {
113
- const paramType = resolveSchemaType(property, doc);
114
- return `ServerResponse<${paramType}>`;
115
- }
116
- }
117
-
118
- return name;
119
- }
120
-
121
- export function isRequestBodyObject(
122
- requestBody: RequestBodyObject | ReferenceObject
123
- ): requestBody is RequestBodyObject {
124
- return (requestBody as RequestBodyObject).content !== undefined;
125
- }
126
-
127
- export function isReferenceObject(
128
- schema: SchemaObject | ReferenceObject
129
- ): schema is ReferenceObject {
130
- return (schema as ReferenceObject).$ref !== undefined;
131
- }
package/lib/README.md DELETED
@@ -1,97 +0,0 @@
1
- # Bungie API TypeScript support
2
-
3
- This project implements TypeScript definitions and API helpers for the [Bungie.net API](https://github.com/Bungie-net/api). It's meant for use in [Destiny Item Manager](https://destinyitemmanager.com), but should be general enough to use in any project. The code is completely generated from Bungie's documentation - I considered using something like Swagger Codegen, but instead opted for a custom generator so we could make the result as nice as possible.
4
-
5
- # Ports
6
-
7
- Feel free to fork this and use it to generate for your favorite language!
8
-
9
- - [Dart](https://github.com/marquesinijatinha/bungie-api-dart/)
10
-
11
- # Install
12
-
13
- ```
14
- pnpm add bungie-api-ts
15
- ```
16
-
17
- # Interfaces and Enums
18
-
19
- All the interface type definitions and enums are for type info only - everything will compile out. Only the API helpers produce real JavaScript output. You can import types from each service defined on Bungie.net:
20
-
21
- ```typescript
22
- import { DestinyInventoryComponent, DestinyInventoryItemDefinition } from 'bungie-api-ts/destiny2';
23
- ```
24
-
25
- There are definitions for every type defined in the Bungie.net services. See [their documentation](https://bungie-net.github.io/multi/) for a list - the interface names are the last part of the full name (for example, `Destiny.Definitions.DestinyVendorActionDefinition` becomes `DestinyVendorActionDefinition`). There are a few exceptions, like `SingleComponentResponseOfDestinyInventoryComponent`, which have been mapped into nicer forms like `SingleComponentResponse<DestinyInventoryComponent>`, and the server responses, which are now `ServerResponse<T>` instead of something like `DestinyCharacterResponse`.
26
-
27
- # API Helpers
28
-
29
- In addition to the types, there are also simple helper functions for each API endpoint. They define the inputs and outputs to that endpoint, and will call a user-provided function with HTTP request info that you can then use to make an HTTP request. This pattern was used so the API helpers could provide full type information. These helpers are not a full API client - they assist in building one. An example:
30
-
31
- ```typescript
32
- import { getProfile, HttpClientConfig } from 'bungie-api-ts/destiny2';
33
-
34
- async function $http(config: HttpClientConfig) {
35
- // fill in the API key, handle OAuth, etc., then make an HTTP request using the config.
36
- return fetch(config.url, ...);
37
- }
38
-
39
- const profileInfo: ServerResponse<DestinyProfileResponse> = await getProfile($http, {
40
- components: [DestinyComponentType.Profiles, DestinyComponentType.Characters],
41
- destinyMembershipId: 12345,
42
- membershipType: BungieMembershipType.TigerPsn
43
- });
44
- ```
45
-
46
- # Imports
47
-
48
- It is possible to import all services from `bungie-api-ts` directly, but it's better to import the specific service and pick out what you want:
49
-
50
- ```typescript
51
- // good
52
- import { getProfile, HttpClientConfig } from 'bungie-api-ts/destiny2';
53
- getProfile(...);
54
-
55
- // works, but not as good
56
- import { Destiny2 } from 'bungie-api-ts';
57
- Destiny2.getProfile(...);
58
- ```
59
-
60
- # Manifest Helpers
61
-
62
- The `destiny2` import also contains helpers for typing and downloading the Destiny manifest:
63
-
64
- ```typescript
65
- import { getDestinyManifestSlice, getDestinyManifest, type HttpClientConfig } from 'bungie-api-ts/destiny2';
66
-
67
- async function $http(config: HttpClientConfig) {
68
- // fill in the API key, handle OAuth, etc., then make an HTTP request using the config.
69
- return fetch(config.url, ...);
70
- }
71
-
72
- const destinyManifest = await getDestinyManifest($http);
73
- const manifestTables = getDestinyManifestSlice($http, {
74
- destinyManifest: destinyManifest.Response,
75
- tableNames: ['DestinyInventoryItemDefinition', 'DestinySocketDefinition'],
76
- language: 'en',
77
- });
78
-
79
- // manifestTables is an object with properties DestinyInventoryItemDefinition and DestinySocketDefinition
80
- ```
81
-
82
- # Build
83
-
84
- ```
85
- # setup
86
- pnpm i && pnpm submodule
87
- # run
88
- pnpm start
89
- ```
90
-
91
- # Updating API sources
92
-
93
- Run the [update API sources](https://github.com/DestinyItemManager/bungie-api-ts/actions/workflows/update.yml) GitHub Action and it should create a new PR for the updated sources.
94
-
95
- # Publishing
96
-
97
- Update the version in `package.json`, and when the PR merges to `master`, a GitHub workflow will automatically publish to NPM. Don't forget to run `pnpm start` and commit all changed files!
@@ -1,29 +0,0 @@
1
- Bungie SDK License Agreement (BSD 3-Clause License)
2
-
3
- Copyright (c) 2017, Bungie, Inc.
4
- All rights reserved.
5
-
6
- Redistribution and use in source and binary forms, with or without
7
- modification, are permitted provided that the following conditions are met:
8
-
9
- * Redistributions of source code must retain the above copyright notice, this
10
- list of conditions and the following disclaimer.
11
-
12
- * Redistributions in binary form must reproduce the above copyright notice,
13
- this list of conditions and the following disclaimer in the documentation
14
- and/or other materials provided with the distribution.
15
-
16
- * Neither the name of the copyright holder nor the names of its
17
- contributors may be used to endorse or promote products derived from
18
- this software without specific prior written permission.
19
-
20
- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
21
- AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
22
- IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
23
- DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
24
- FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
25
- DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
26
- SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
27
- CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
28
- OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
29
- OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
package/lib/package.json DELETED
@@ -1,99 +0,0 @@
1
- {
2
- "name": "bungie-api-ts",
3
- "version": "5.10.0",
4
- "description": "TypeScript mappings for the Bungie.net API",
5
- "type": "module",
6
- "sideEffects": false,
7
- "scripts": {},
8
- "jest": {
9
- "preset": "ts-jest/presets/js-with-babel-esm",
10
- "testEnvironment": "node",
11
- "moduleNameMapper": {
12
- "^(\\.{1,2}/.*)\\.js$": "$1"
13
- }
14
- },
15
- "engines": {
16
- "node": ">=13.2.0"
17
- },
18
- "repository": {
19
- "type": "git",
20
- "url": "https://github.com/DestinyItemManager/bungie-api-ts.git"
21
- },
22
- "author": "Ben Hollis",
23
- "license": "MIT",
24
- "bugs": {
25
- "url": "https://github.com/DestinyItemManager/bungie-api-ts/issues"
26
- },
27
- "keywords": [
28
- "Destiny",
29
- "Bungie",
30
- "Bungie.net",
31
- "TypeScript"
32
- ],
33
- "homepage": "https://github.com/DestinyItemManager/bungie-api-ts",
34
- "devDependencies": {},
35
- "packageManager": "pnpm@8.15.9+sha512.499434c9d8fdd1a2794ebf4552b3b25c0a633abcee5bb15e7b5de90f32f47b513aca98cd5cfd001c31f0db454bc3804edccd578501e4ca293a6816166bbd9f81",
36
- "main": "./index.js",
37
- "types": "./index.d.ts",
38
- "module": "./index.js",
39
- "exports": {
40
- ".": {
41
- "default": "./index.js",
42
- "types": "./index.d.ts"
43
- },
44
- "./http": {
45
- "default": "./http.js",
46
- "types": "./http.d.ts"
47
- },
48
- "./package.json": "./package.json",
49
- "./app": {
50
- "default": "./app/index.js",
51
- "types": "./app/index.d.ts"
52
- },
53
- "./user": {
54
- "default": "./user/index.js",
55
- "types": "./user/index.d.ts"
56
- },
57
- "./content": {
58
- "default": "./content/index.js",
59
- "types": "./content/index.d.ts"
60
- },
61
- "./forum": {
62
- "default": "./forum/index.js",
63
- "types": "./forum/index.d.ts"
64
- },
65
- "./groupv2": {
66
- "default": "./groupv2/index.js",
67
- "types": "./groupv2/index.d.ts"
68
- },
69
- "./tokens": {
70
- "default": "./tokens/index.js",
71
- "types": "./tokens/index.d.ts"
72
- },
73
- "./destiny2": {
74
- "default": "./destiny2/index.js",
75
- "types": "./destiny2/index.d.ts"
76
- },
77
- "./communitycontent": {
78
- "default": "./communitycontent/index.js",
79
- "types": "./communitycontent/index.d.ts"
80
- },
81
- "./trending": {
82
- "default": "./trending/index.js",
83
- "types": "./trending/index.d.ts"
84
- },
85
- "./fireteam": {
86
- "default": "./fireteam/index.js",
87
- "types": "./fireteam/index.d.ts"
88
- },
89
- "./social": {
90
- "default": "./social/index.js",
91
- "types": "./social/index.d.ts"
92
- },
93
- "./core": {
94
- "default": "./core/index.js",
95
- "types": "./core/index.d.ts"
96
- }
97
- },
98
- "dependencies": {}
99
- }
package/test-consumer.ts DELETED
@@ -1,5 +0,0 @@
1
- import { getDestinyManifest } from './lib/destiny2/api.js';
2
-
3
- const fakeHttp = async (config) => console.log(config.url);
4
-
5
- getDestinyManifest(fakeHttp);