@taskeren/bungie-api-ts 5.10.2 → 5.10.4

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/README.md CHANGED
@@ -1,97 +1,101 @@
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
+ # Taskeren's Bungie API TypeScript support
2
+
3
+ This is a fork of [DestinyItemManager/bungie-api-ts](https://github.com/DestinyItemManager/bungie-api-ts), which generates non-const enums.
4
+
5
+ # Bungie API TypeScript support
6
+
7
+ 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.
8
+
9
+ # Ports
10
+
11
+ Feel free to fork this and use it to generate for your favorite language!
12
+
13
+ - [Dart](https://github.com/marquesinijatinha/bungie-api-dart/)
14
+
15
+ # Install
16
+
17
+ ```
18
+ pnpm add bungie-api-ts
19
+ ```
20
+
21
+ # Interfaces and Enums
22
+
23
+ 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:
24
+
25
+ ```typescript
26
+ import { DestinyInventoryComponent, DestinyInventoryItemDefinition } from 'bungie-api-ts/destiny2';
27
+ ```
28
+
29
+ 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`.
30
+
31
+ # API Helpers
32
+
33
+ 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:
34
+
35
+ ```typescript
36
+ import { getProfile, HttpClientConfig } from 'bungie-api-ts/destiny2';
37
+
38
+ async function $http(config: HttpClientConfig) {
39
+ // fill in the API key, handle OAuth, etc., then make an HTTP request using the config.
40
+ return fetch(config.url, ...);
41
+ }
42
+
43
+ const profileInfo: ServerResponse<DestinyProfileResponse> = await getProfile($http, {
44
+ components: [DestinyComponentType.Profiles, DestinyComponentType.Characters],
45
+ destinyMembershipId: 12345,
46
+ membershipType: BungieMembershipType.TigerPsn
47
+ });
48
+ ```
49
+
50
+ # Imports
51
+
52
+ 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:
53
+
54
+ ```typescript
55
+ // good
56
+ import { getProfile, HttpClientConfig } from 'bungie-api-ts/destiny2';
57
+ getProfile(...);
58
+
59
+ // works, but not as good
60
+ import { Destiny2 } from 'bungie-api-ts';
61
+ Destiny2.getProfile(...);
62
+ ```
63
+
64
+ # Manifest Helpers
65
+
66
+ The `destiny2` import also contains helpers for typing and downloading the Destiny manifest:
67
+
68
+ ```typescript
69
+ import { getDestinyManifestSlice, getDestinyManifest, type HttpClientConfig } from 'bungie-api-ts/destiny2';
70
+
71
+ async function $http(config: HttpClientConfig) {
72
+ // fill in the API key, handle OAuth, etc., then make an HTTP request using the config.
73
+ return fetch(config.url, ...);
74
+ }
75
+
76
+ const destinyManifest = await getDestinyManifest($http);
77
+ const manifestTables = getDestinyManifestSlice($http, {
78
+ destinyManifest: destinyManifest.Response,
79
+ tableNames: ['DestinyInventoryItemDefinition', 'DestinySocketDefinition'],
80
+ language: 'en',
81
+ });
82
+
83
+ // manifestTables is an object with properties DestinyInventoryItemDefinition and DestinySocketDefinition
84
+ ```
85
+
86
+ # Build
87
+
88
+ ```
89
+ # setup
90
+ pnpm i && pnpm submodule
91
+ # run
92
+ pnpm start
93
+ ```
94
+
95
+ # Updating API sources
96
+
97
+ 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.
98
+
99
+ # Publishing
100
+
101
+ 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!
@@ -61,48 +61,51 @@ export interface Application {
61
61
  /** An optional override for the Authorize view name. */
62
62
  readonly overrideAuthorizeViewName: string;
63
63
  }
64
- export declare const enum OAuthApplicationType {
65
- None = 0,
64
+ export declare const OAuthApplicationType: {
65
+ readonly None: 0;
66
66
  /**
67
67
  * Indicates the application is server based and can keep its secrets from end
68
68
  * users and other potential snoops.
69
69
  */
70
- Confidential = 1,
70
+ readonly Confidential: 1;
71
71
  /**
72
72
  * Indicates the application runs in a public place, and it can't be trusted to
73
73
  * keep a secret.
74
74
  */
75
- Public = 2,
76
- }
77
- export declare const enum ApplicationStatus {
75
+ readonly Public: 2;
76
+ };
77
+ export type OAuthApplicationType = (typeof OAuthApplicationType)[keyof typeof OAuthApplicationType];
78
+ export declare const ApplicationStatus: {
78
79
  /** No value assigned */
79
- None = 0,
80
+ readonly None: 0;
80
81
  /**
81
82
  * Application exists and works but will not appear in any public catalog. New
82
83
  * applications start in this state, test applications will remain in this state.
83
84
  */
84
- Private = 1,
85
+ readonly Private: 1;
85
86
  /** Active applications that can appear in an catalog. */
86
- Public = 2,
87
+ readonly Public: 2;
87
88
  /**
88
89
  * Application disabled by the owner. All authorizations will be treated as
89
90
  * terminated while in this state. Owner can move back to private or public state.
90
91
  */
91
- Disabled = 3,
92
+ readonly Disabled: 3;
92
93
  /**
93
94
  * Application has been blocked by Bungie. It cannot be transitioned out of this
94
95
  * state by the owner. Authorizations are terminated when an application is in this
95
96
  * state.
96
97
  */
97
- Blocked = 4,
98
- }
98
+ readonly Blocked: 4;
99
+ };
100
+ export type ApplicationStatus = (typeof ApplicationStatus)[keyof typeof ApplicationStatus];
99
101
  export interface ApplicationDeveloper {
100
102
  readonly role: DeveloperRole;
101
103
  readonly apiEulaVersion: number;
102
104
  readonly user: UserInfoCard;
103
105
  }
104
- export declare const enum DeveloperRole {
105
- None = 0,
106
- Owner = 1,
107
- TeamMember = 2,
108
- }
106
+ export declare const DeveloperRole: {
107
+ readonly None: 0;
108
+ readonly Owner: 1;
109
+ readonly TeamMember: 2;
110
+ };
111
+ export type DeveloperRole = (typeof DeveloperRole)[keyof typeof DeveloperRole];
package/app/interfaces.js CHANGED
@@ -1,16 +1,16 @@
1
- export var OAuthApplicationType = {
1
+ export const OAuthApplicationType = {
2
2
  None: 0,
3
3
  Confidential: 1,
4
4
  Public: 2,
5
5
  };
6
- export var ApplicationStatus = {
6
+ export const ApplicationStatus = {
7
7
  None: 0,
8
8
  Private: 1,
9
9
  Public: 2,
10
10
  Disabled: 3,
11
11
  Blocked: 4,
12
12
  };
13
- export var DeveloperRole = {
13
+ export const DeveloperRole = {
14
14
  None: 0,
15
15
  Owner: 1,
16
16
  TeamMember: 2,
@@ -1,29 +1,29 @@
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.
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.