bmlt-server-semantic-client 1.0.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.
Files changed (174) hide show
  1. package/.github/workflows/release.yml +25 -0
  2. package/.openapi-generator/FILES +44 -0
  3. package/.openapi-generator/VERSION +1 -0
  4. package/.openapi-generator-ignore +23 -0
  5. package/Makefile +31 -0
  6. package/README.md +125 -0
  7. package/dist/apis/FieldsApi.d.ts +56 -0
  8. package/dist/apis/FieldsApi.js +123 -0
  9. package/dist/apis/FormatsApi.d.ts +44 -0
  10. package/dist/apis/FormatsApi.js +87 -0
  11. package/dist/apis/MeetingsApi.d.ts +157 -0
  12. package/dist/apis/MeetingsApi.js +288 -0
  13. package/dist/apis/ServerApi.d.ts +43 -0
  14. package/dist/apis/ServerApi.js +104 -0
  15. package/dist/apis/ServiceBodiesApi.d.ts +51 -0
  16. package/dist/apis/ServiceBodiesApi.js +91 -0
  17. package/dist/apis/index.d.ts +5 -0
  18. package/dist/apis/index.js +23 -0
  19. package/dist/esm/apis/FieldsApi.d.ts +56 -0
  20. package/dist/esm/apis/FieldsApi.js +119 -0
  21. package/dist/esm/apis/FormatsApi.d.ts +44 -0
  22. package/dist/esm/apis/FormatsApi.js +83 -0
  23. package/dist/esm/apis/MeetingsApi.d.ts +157 -0
  24. package/dist/esm/apis/MeetingsApi.js +284 -0
  25. package/dist/esm/apis/ServerApi.d.ts +43 -0
  26. package/dist/esm/apis/ServerApi.js +100 -0
  27. package/dist/esm/apis/ServiceBodiesApi.d.ts +51 -0
  28. package/dist/esm/apis/ServiceBodiesApi.js +87 -0
  29. package/dist/esm/apis/index.d.ts +5 -0
  30. package/dist/esm/apis/index.js +7 -0
  31. package/dist/esm/index.d.ts +3 -0
  32. package/dist/esm/index.js +5 -0
  33. package/dist/esm/models/Format.d.ts +81 -0
  34. package/dist/esm/models/Format.js +37 -0
  35. package/dist/esm/models/GetCoverageArea200Response.d.ts +50 -0
  36. package/dist/esm/models/GetCoverageArea200Response.js +47 -0
  37. package/dist/esm/models/GetFieldKeys200ResponseInner.d.ts +38 -0
  38. package/dist/esm/models/GetFieldKeys200ResponseInner.js +43 -0
  39. package/dist/esm/models/GetFieldValues200ResponseInner.d.ts +38 -0
  40. package/dist/esm/models/GetFieldValues200ResponseInner.js +43 -0
  41. package/dist/esm/models/GetSearchResults200Response.d.ts +24 -0
  42. package/dist/esm/models/GetSearchResults200Response.js +68 -0
  43. package/dist/esm/models/GetSearchResults200ResponseOneOf.d.ts +40 -0
  44. package/dist/esm/models/GetSearchResults200ResponseOneOf.js +45 -0
  45. package/dist/esm/models/Meeting.d.ts +255 -0
  46. package/dist/esm/models/Meeting.js +37 -0
  47. package/dist/esm/models/MeetingChange.d.ts +89 -0
  48. package/dist/esm/models/MeetingChange.js +37 -0
  49. package/dist/esm/models/ModelError.d.ts +33 -0
  50. package/dist/esm/models/ModelError.js +37 -0
  51. package/dist/esm/models/SemanticError.d.ts +33 -0
  52. package/dist/esm/models/SemanticError.js +37 -0
  53. package/dist/esm/models/SemanticFormat.d.ts +81 -0
  54. package/dist/esm/models/SemanticFormat.js +37 -0
  55. package/dist/esm/models/SemanticMeeting.d.ts +255 -0
  56. package/dist/esm/models/SemanticMeeting.js +37 -0
  57. package/dist/esm/models/SemanticMeetingChange.d.ts +89 -0
  58. package/dist/esm/models/SemanticMeetingChange.js +37 -0
  59. package/dist/esm/models/SemanticServerInfo.d.ts +156 -0
  60. package/dist/esm/models/SemanticServerInfo.js +45 -0
  61. package/dist/esm/models/SemanticServerInfoAggregatorModeEnabled.d.ts +21 -0
  62. package/dist/esm/models/SemanticServerInfoAggregatorModeEnabled.js +43 -0
  63. package/dist/esm/models/SemanticServiceBody.d.ts +87 -0
  64. package/dist/esm/models/SemanticServiceBody.js +37 -0
  65. package/dist/esm/models/ServerInfo.d.ts +156 -0
  66. package/dist/esm/models/ServerInfo.js +45 -0
  67. package/dist/esm/models/ServerInfoAggregatorModeEnabled.d.ts +21 -0
  68. package/dist/esm/models/ServerInfoAggregatorModeEnabled.js +43 -0
  69. package/dist/esm/models/ServiceBody.d.ts +87 -0
  70. package/dist/esm/models/ServiceBody.js +37 -0
  71. package/dist/esm/models/index.d.ts +12 -0
  72. package/dist/esm/models/index.js +14 -0
  73. package/dist/esm/runtime.d.ts +184 -0
  74. package/dist/esm/runtime.js +349 -0
  75. package/dist/index.d.ts +3 -0
  76. package/dist/index.js +21 -0
  77. package/dist/models/Format.d.ts +81 -0
  78. package/dist/models/Format.js +44 -0
  79. package/dist/models/GetCoverageArea200Response.d.ts +50 -0
  80. package/dist/models/GetCoverageArea200Response.js +54 -0
  81. package/dist/models/GetFieldKeys200ResponseInner.d.ts +38 -0
  82. package/dist/models/GetFieldKeys200ResponseInner.js +50 -0
  83. package/dist/models/GetFieldValues200ResponseInner.d.ts +38 -0
  84. package/dist/models/GetFieldValues200ResponseInner.js +50 -0
  85. package/dist/models/GetSearchResults200Response.d.ts +24 -0
  86. package/dist/models/GetSearchResults200Response.js +74 -0
  87. package/dist/models/GetSearchResults200ResponseOneOf.d.ts +40 -0
  88. package/dist/models/GetSearchResults200ResponseOneOf.js +52 -0
  89. package/dist/models/Meeting.d.ts +255 -0
  90. package/dist/models/Meeting.js +44 -0
  91. package/dist/models/MeetingChange.d.ts +89 -0
  92. package/dist/models/MeetingChange.js +44 -0
  93. package/dist/models/ModelError.d.ts +33 -0
  94. package/dist/models/ModelError.js +44 -0
  95. package/dist/models/SemanticError.d.ts +33 -0
  96. package/dist/models/SemanticError.js +44 -0
  97. package/dist/models/SemanticFormat.d.ts +81 -0
  98. package/dist/models/SemanticFormat.js +44 -0
  99. package/dist/models/SemanticMeeting.d.ts +255 -0
  100. package/dist/models/SemanticMeeting.js +44 -0
  101. package/dist/models/SemanticMeetingChange.d.ts +89 -0
  102. package/dist/models/SemanticMeetingChange.js +44 -0
  103. package/dist/models/SemanticServerInfo.d.ts +156 -0
  104. package/dist/models/SemanticServerInfo.js +53 -0
  105. package/dist/models/SemanticServerInfoAggregatorModeEnabled.d.ts +21 -0
  106. package/dist/models/SemanticServerInfoAggregatorModeEnabled.js +49 -0
  107. package/dist/models/SemanticServiceBody.d.ts +87 -0
  108. package/dist/models/SemanticServiceBody.js +44 -0
  109. package/dist/models/ServerInfo.d.ts +156 -0
  110. package/dist/models/ServerInfo.js +53 -0
  111. package/dist/models/ServerInfoAggregatorModeEnabled.d.ts +21 -0
  112. package/dist/models/ServerInfoAggregatorModeEnabled.js +49 -0
  113. package/dist/models/ServiceBody.d.ts +87 -0
  114. package/dist/models/ServiceBody.js +44 -0
  115. package/dist/models/index.d.ts +12 -0
  116. package/dist/models/index.js +30 -0
  117. package/dist/runtime.d.ts +184 -0
  118. package/dist/runtime.js +365 -0
  119. package/docs/FieldsApi.md +139 -0
  120. package/docs/Format.md +50 -0
  121. package/docs/FormatsApi.md +83 -0
  122. package/docs/GetCoverageArea200Response.md +40 -0
  123. package/docs/GetFieldKeys200ResponseInner.md +36 -0
  124. package/docs/GetFieldValues200ResponseInner.md +36 -0
  125. package/docs/GetSearchResults200Response.md +36 -0
  126. package/docs/GetSearchResults200ResponseOneOf.md +36 -0
  127. package/docs/Meeting.md +109 -0
  128. package/docs/MeetingChange.md +52 -0
  129. package/docs/MeetingsApi.md +261 -0
  130. package/docs/ModelError.md +34 -0
  131. package/docs/SemanticError.md +34 -0
  132. package/docs/SemanticFormat.md +50 -0
  133. package/docs/SemanticMeeting.md +109 -0
  134. package/docs/SemanticMeetingChange.md +52 -0
  135. package/docs/SemanticServerInfo.md +72 -0
  136. package/docs/SemanticServerInfoAggregatorModeEnabled.md +33 -0
  137. package/docs/SemanticServiceBody.md +52 -0
  138. package/docs/ServerApi.md +124 -0
  139. package/docs/ServerInfo.md +72 -0
  140. package/docs/ServerInfoAggregatorModeEnabled.md +33 -0
  141. package/docs/ServiceBodiesApi.md +80 -0
  142. package/docs/ServiceBody.md +52 -0
  143. package/openapi.json +1 -0
  144. package/package.json +21 -0
  145. package/src/apis/FieldsApi.ts +145 -0
  146. package/src/apis/FormatsApi.ts +96 -0
  147. package/src/apis/MeetingsApi.ts +392 -0
  148. package/src/apis/ServerApi.ts +106 -0
  149. package/src/apis/ServiceBodiesApi.ts +99 -0
  150. package/src/apis/index.ts +7 -0
  151. package/src/index.ts +5 -0
  152. package/src/models/Format.ts +132 -0
  153. package/src/models/GetCoverageArea200Response.ts +89 -0
  154. package/src/models/GetFieldKeys200ResponseInner.ts +73 -0
  155. package/src/models/GetFieldValues200ResponseInner.ts +73 -0
  156. package/src/models/GetSearchResults200Response.ts +99 -0
  157. package/src/models/GetSearchResults200ResponseOneOf.ts +88 -0
  158. package/src/models/Meeting.ts +364 -0
  159. package/src/models/MeetingChange.ts +140 -0
  160. package/src/models/ModelError.ts +68 -0
  161. package/src/models/SemanticError.ts +68 -0
  162. package/src/models/SemanticFormat.ts +132 -0
  163. package/src/models/SemanticMeeting.ts +364 -0
  164. package/src/models/SemanticMeetingChange.ts +140 -0
  165. package/src/models/SemanticServerInfo.ts +239 -0
  166. package/src/models/SemanticServerInfoAggregatorModeEnabled.ts +55 -0
  167. package/src/models/SemanticServiceBody.ts +140 -0
  168. package/src/models/ServerInfo.ts +239 -0
  169. package/src/models/ServerInfoAggregatorModeEnabled.ts +55 -0
  170. package/src/models/ServiceBody.ts +140 -0
  171. package/src/models/index.ts +14 -0
  172. package/src/runtime.ts +449 -0
  173. package/tsconfig.esm.json +7 -0
  174. package/tsconfig.json +16 -0
@@ -0,0 +1,55 @@
1
+ /* tslint:disable */
2
+ /* eslint-disable */
3
+ /**
4
+ * BMLT Semantic API
5
+ * OpenAPI description of the Basic Meeting List Toolbox (BMLT) Semantic Interface for the JSON data format. The semantic interface dispatches all operations from a single endpoint (`/client_interface/json/`) using a `switcher` query parameter. To keep each operation discoverable, this spec models each `switcher` value as a distinct path key with the query string baked in. Tools such as Swagger UI, Redoc, and openapi-generator handle these path keys correctly even though the OpenAPI spec technically expects unique URL paths. ### Things that do not map cleanly onto OpenAPI - **PHP array syntax** — repeatable array parameters use trailing `[]` in the name (`weekdays[]=2&weekdays[]=3`). The parameter names in this spec preserve the brackets so generated clients emit them. - **Sign-as-operator** — many filters (`formats`, `services`, `weekdays`, `venue_types`, `meeting_ids`, `root_server_ids`, `format_ids`) use *positive* values to include and *negative* values to exclude. JSON Schema cannot enforce that semantics; it is documented per parameter. - **Cross-parameter constraints** — in aggregator mode `GetSearchResults` requires at least one filter parameter. Invalid combinations typically return an empty array `[]` instead of an HTTP error. - **Empty-array errors** — many endpoints return `[]` for invalid input rather than a 4xx response body.
6
+ *
7
+ * The version of the OpenAPI document: 1.0.0
8
+ *
9
+ *
10
+ * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
11
+ * https://openapi-generator.tech
12
+ * Do not edit the class manually.
13
+ */
14
+
15
+ /**
16
+ * @type ServerInfoAggregatorModeEnabled
17
+ * 1 / true if this server is running in aggregator mode.
18
+ * @export
19
+ */
20
+ export type ServerInfoAggregatorModeEnabled = boolean | string;
21
+
22
+ export function ServerInfoAggregatorModeEnabledFromJSON(json: any): ServerInfoAggregatorModeEnabled {
23
+ return ServerInfoAggregatorModeEnabledFromJSONTyped(json, false);
24
+ }
25
+
26
+ export function ServerInfoAggregatorModeEnabledFromJSONTyped(json: any, ignoreDiscriminator: boolean): ServerInfoAggregatorModeEnabled {
27
+ if (json == null) {
28
+ return json;
29
+ }
30
+ if (typeof json === 'string') {
31
+ return json;
32
+ }
33
+ if (typeof json === 'boolean') {
34
+ return json;
35
+ }
36
+ return {} as any;
37
+ }
38
+
39
+ export function ServerInfoAggregatorModeEnabledToJSON(json: any): any {
40
+ return ServerInfoAggregatorModeEnabledToJSONTyped(json, false);
41
+ }
42
+
43
+ export function ServerInfoAggregatorModeEnabledToJSONTyped(value?: ServerInfoAggregatorModeEnabled | null, ignoreDiscriminator: boolean = false): any {
44
+ if (value == null) {
45
+ return value;
46
+ }
47
+ if (typeof value === 'string') {
48
+ return value;
49
+ }
50
+ if (typeof value === 'boolean') {
51
+ return value;
52
+ }
53
+ return {};
54
+ }
55
+
@@ -0,0 +1,140 @@
1
+ /* tslint:disable */
2
+ /* eslint-disable */
3
+ /**
4
+ * BMLT Semantic API
5
+ * OpenAPI description of the Basic Meeting List Toolbox (BMLT) Semantic Interface for the JSON data format. The semantic interface dispatches all operations from a single endpoint (`/client_interface/json/`) using a `switcher` query parameter. To keep each operation discoverable, this spec models each `switcher` value as a distinct path key with the query string baked in. Tools such as Swagger UI, Redoc, and openapi-generator handle these path keys correctly even though the OpenAPI spec technically expects unique URL paths. ### Things that do not map cleanly onto OpenAPI - **PHP array syntax** — repeatable array parameters use trailing `[]` in the name (`weekdays[]=2&weekdays[]=3`). The parameter names in this spec preserve the brackets so generated clients emit them. - **Sign-as-operator** — many filters (`formats`, `services`, `weekdays`, `venue_types`, `meeting_ids`, `root_server_ids`, `format_ids`) use *positive* values to include and *negative* values to exclude. JSON Schema cannot enforce that semantics; it is documented per parameter. - **Cross-parameter constraints** — in aggregator mode `GetSearchResults` requires at least one filter parameter. Invalid combinations typically return an empty array `[]` instead of an HTTP error. - **Empty-array errors** — many endpoints return `[]` for invalid input rather than a 4xx response body.
6
+ *
7
+ * The version of the OpenAPI document: 1.0.0
8
+ *
9
+ *
10
+ * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
11
+ * https://openapi-generator.tech
12
+ * Do not edit the class manually.
13
+ */
14
+
15
+ import { mapValues } from '../runtime';
16
+ /**
17
+ *
18
+ * @export
19
+ * @interface ServiceBody
20
+ */
21
+ export interface ServiceBody {
22
+ [key: string]: any | any;
23
+ /**
24
+ *
25
+ * @type {string}
26
+ * @memberof ServiceBody
27
+ */
28
+ id?: string;
29
+ /**
30
+ *
31
+ * @type {string}
32
+ * @memberof ServiceBody
33
+ */
34
+ parentId?: string;
35
+ /**
36
+ *
37
+ * @type {string}
38
+ * @memberof ServiceBody
39
+ */
40
+ name?: string;
41
+ /**
42
+ *
43
+ * @type {string}
44
+ * @memberof ServiceBody
45
+ */
46
+ description?: string;
47
+ /**
48
+ *
49
+ * @type {string}
50
+ * @memberof ServiceBody
51
+ */
52
+ type?: string;
53
+ /**
54
+ *
55
+ * @type {string}
56
+ * @memberof ServiceBody
57
+ */
58
+ url?: string;
59
+ /**
60
+ *
61
+ * @type {string}
62
+ * @memberof ServiceBody
63
+ */
64
+ helpline?: string;
65
+ /**
66
+ *
67
+ * @type {string}
68
+ * @memberof ServiceBody
69
+ */
70
+ worldId?: string;
71
+ /**
72
+ * Aggregator mode only.
73
+ * @type {string}
74
+ * @memberof ServiceBody
75
+ */
76
+ rootServerId?: string;
77
+ /**
78
+ * Aggregator mode only.
79
+ * @type {string}
80
+ * @memberof ServiceBody
81
+ */
82
+ rootServerUri?: string;
83
+ }
84
+
85
+ /**
86
+ * Check if a given object implements the ServiceBody interface.
87
+ */
88
+ export function instanceOfServiceBody(value: object): value is ServiceBody {
89
+ return true;
90
+ }
91
+
92
+ export function ServiceBodyFromJSON(json: any): ServiceBody {
93
+ return ServiceBodyFromJSONTyped(json, false);
94
+ }
95
+
96
+ export function ServiceBodyFromJSONTyped(json: any, ignoreDiscriminator: boolean): ServiceBody {
97
+ if (json == null) {
98
+ return json;
99
+ }
100
+ return {
101
+
102
+ ...json,
103
+ 'id': json['id'] == null ? undefined : json['id'],
104
+ 'parentId': json['parent_id'] == null ? undefined : json['parent_id'],
105
+ 'name': json['name'] == null ? undefined : json['name'],
106
+ 'description': json['description'] == null ? undefined : json['description'],
107
+ 'type': json['type'] == null ? undefined : json['type'],
108
+ 'url': json['url'] == null ? undefined : json['url'],
109
+ 'helpline': json['helpline'] == null ? undefined : json['helpline'],
110
+ 'worldId': json['world_id'] == null ? undefined : json['world_id'],
111
+ 'rootServerId': json['root_server_id'] == null ? undefined : json['root_server_id'],
112
+ 'rootServerUri': json['root_server_uri'] == null ? undefined : json['root_server_uri'],
113
+ };
114
+ }
115
+
116
+ export function ServiceBodyToJSON(json: any): ServiceBody {
117
+ return ServiceBodyToJSONTyped(json, false);
118
+ }
119
+
120
+ export function ServiceBodyToJSONTyped(value?: ServiceBody | null, ignoreDiscriminator: boolean = false): any {
121
+ if (value == null) {
122
+ return value;
123
+ }
124
+
125
+ return {
126
+
127
+ ...value,
128
+ 'id': value['id'],
129
+ 'parent_id': value['parentId'],
130
+ 'name': value['name'],
131
+ 'description': value['description'],
132
+ 'type': value['type'],
133
+ 'url': value['url'],
134
+ 'helpline': value['helpline'],
135
+ 'world_id': value['worldId'],
136
+ 'root_server_id': value['rootServerId'],
137
+ 'root_server_uri': value['rootServerUri'],
138
+ };
139
+ }
140
+
@@ -0,0 +1,14 @@
1
+ /* tslint:disable */
2
+ /* eslint-disable */
3
+ export * from './GetCoverageArea200Response';
4
+ export * from './GetFieldKeys200ResponseInner';
5
+ export * from './GetFieldValues200ResponseInner';
6
+ export * from './GetSearchResults200Response';
7
+ export * from './GetSearchResults200ResponseOneOf';
8
+ export * from './SemanticError';
9
+ export * from './SemanticFormat';
10
+ export * from './SemanticMeeting';
11
+ export * from './SemanticMeetingChange';
12
+ export * from './SemanticServerInfo';
13
+ export * from './SemanticServerInfoAggregatorModeEnabled';
14
+ export * from './SemanticServiceBody';
package/src/runtime.ts ADDED
@@ -0,0 +1,449 @@
1
+ /* tslint:disable */
2
+ /* eslint-disable */
3
+ /**
4
+ * BMLT Semantic API
5
+ * OpenAPI description of the BMLT Semantic Interface (the read-only meeting-query API) for the JSON data format. The semantic interface dispatches all operations from a single endpoint (`/client_interface/json/`) using a `switcher` query parameter. To keep each operation discoverable, this spec models each `switcher` value as a distinct path key with the query string baked in. Tools such as Swagger UI, Redoc, and openapi-generator handle these path keys correctly even though the OpenAPI spec technically expects unique URL paths. ### Things that do not map cleanly onto OpenAPI - **Sign-as-operator** — many filters (`formats`, `services`, `weekdays`, `venue_types`, `meeting_ids`, `root_server_ids`, `format_ids`) use *positive* values to include and *negative* values to exclude. JSON Schema cannot enforce that semantics; it is documented per parameter. - **Cross-parameter constraints** — in aggregator mode `GetSearchResults` requires at least one filter parameter. Invalid combinations typically return an empty array `[]` instead of an HTTP error. - **Empty-array errors** — many endpoints return `[]` for invalid input rather than a 4xx response body.
6
+ *
7
+ * The version of the OpenAPI document: 1.0.0
8
+ *
9
+ *
10
+ * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
11
+ * https://openapi-generator.tech
12
+ * Do not edit the class manually.
13
+ */
14
+
15
+ export const BASE_PATH = "http://localhost:8000/main_server".replace(/\/+$/, "");
16
+
17
+ export interface ConfigurationParameters {
18
+ basePath?: string; // override base path
19
+ fetchApi?: FetchAPI; // override for fetch implementation
20
+ middleware?: Middleware[]; // middleware to apply before/after fetch requests
21
+ queryParamsStringify?: (params: HTTPQuery) => string; // stringify function for query strings
22
+ username?: string; // parameter for basic security
23
+ password?: string; // parameter for basic security
24
+ apiKey?: string | Promise<string> | ((name: string) => string | Promise<string>); // parameter for apiKey security
25
+ accessToken?: string | Promise<string> | ((name?: string, scopes?: string[]) => string | Promise<string>); // parameter for oauth2 security
26
+ headers?: HTTPHeaders; //header params we want to use on every request
27
+ credentials?: RequestCredentials; //value for the credentials param we want to use on each request
28
+ }
29
+
30
+ export class Configuration {
31
+ constructor(private configuration: ConfigurationParameters = {}) {}
32
+
33
+ set config(configuration: Configuration) {
34
+ this.configuration = configuration;
35
+ }
36
+
37
+ get basePath(): string {
38
+ return this.configuration.basePath != null ? this.configuration.basePath : BASE_PATH;
39
+ }
40
+
41
+ get fetchApi(): FetchAPI | undefined {
42
+ return this.configuration.fetchApi;
43
+ }
44
+
45
+ get middleware(): Middleware[] {
46
+ return this.configuration.middleware || [];
47
+ }
48
+
49
+ get queryParamsStringify(): (params: HTTPQuery) => string {
50
+ return this.configuration.queryParamsStringify || querystring;
51
+ }
52
+
53
+ get username(): string | undefined {
54
+ return this.configuration.username;
55
+ }
56
+
57
+ get password(): string | undefined {
58
+ return this.configuration.password;
59
+ }
60
+
61
+ get apiKey(): ((name: string) => string | Promise<string>) | undefined {
62
+ const apiKey = this.configuration.apiKey;
63
+ if (apiKey) {
64
+ return typeof apiKey === 'function' ? apiKey : () => apiKey;
65
+ }
66
+ return undefined;
67
+ }
68
+
69
+ get accessToken(): ((name?: string, scopes?: string[]) => string | Promise<string>) | undefined {
70
+ const accessToken = this.configuration.accessToken;
71
+ if (accessToken) {
72
+ return typeof accessToken === 'function' ? accessToken : async () => accessToken;
73
+ }
74
+ return undefined;
75
+ }
76
+
77
+ get headers(): HTTPHeaders | undefined {
78
+ return this.configuration.headers;
79
+ }
80
+
81
+ get credentials(): RequestCredentials | undefined {
82
+ return this.configuration.credentials;
83
+ }
84
+ }
85
+
86
+ export const DefaultConfig = new Configuration();
87
+
88
+ /**
89
+ * This is the base class for all generated API classes.
90
+ */
91
+ export class BaseAPI {
92
+
93
+ private static readonly jsonRegex = /^(:?application\/json|[^;/ \t]+\/[^;/ \t]+[+]json)[ \t]*(:?;.*)?$/i;
94
+ private middleware: Middleware[];
95
+
96
+ constructor(protected configuration = DefaultConfig) {
97
+ this.middleware = configuration.middleware;
98
+ }
99
+
100
+ withMiddleware<T extends BaseAPI>(this: T, ...middlewares: Middleware[]) {
101
+ const next = this.clone<T>();
102
+ next.middleware = next.middleware.concat(...middlewares);
103
+ return next;
104
+ }
105
+
106
+ withPreMiddleware<T extends BaseAPI>(this: T, ...preMiddlewares: Array<Middleware['pre']>) {
107
+ const middlewares = preMiddlewares.map((pre) => ({ pre }));
108
+ return this.withMiddleware<T>(...middlewares);
109
+ }
110
+
111
+ withPostMiddleware<T extends BaseAPI>(this: T, ...postMiddlewares: Array<Middleware['post']>) {
112
+ const middlewares = postMiddlewares.map((post) => ({ post }));
113
+ return this.withMiddleware<T>(...middlewares);
114
+ }
115
+
116
+ /**
117
+ * Check if the given MIME is a JSON MIME.
118
+ * JSON MIME examples:
119
+ * application/json
120
+ * application/json; charset=UTF8
121
+ * APPLICATION/JSON
122
+ * application/vnd.company+json
123
+ * @param mime - MIME (Multipurpose Internet Mail Extensions)
124
+ * @return True if the given MIME is JSON, false otherwise.
125
+ */
126
+ protected isJsonMime(mime: string | null | undefined): boolean {
127
+ if (!mime) {
128
+ return false;
129
+ }
130
+ return BaseAPI.jsonRegex.test(mime);
131
+ }
132
+
133
+ protected async request(context: RequestOpts, initOverrides?: RequestInit | InitOverrideFunction): Promise<Response> {
134
+ const { url, init } = await this.createFetchParams(context, initOverrides);
135
+ const response = await this.fetchApi(url, init);
136
+ if (response && (response.status >= 200 && response.status < 300)) {
137
+ return response;
138
+ }
139
+ throw new ResponseError(response, 'Response returned an error code');
140
+ }
141
+
142
+ private async createFetchParams(context: RequestOpts, initOverrides?: RequestInit | InitOverrideFunction) {
143
+ let url = this.configuration.basePath + context.path;
144
+ if (context.query !== undefined && Object.keys(context.query).length !== 0) {
145
+ // only add the querystring to the URL if there are query parameters.
146
+ // this is done to avoid urls ending with a "?" character which buggy webservers
147
+ // do not handle correctly sometimes.
148
+ url += (context.path.indexOf('?') >= 0 ? '&' : '?') + this.configuration.queryParamsStringify(context.query);
149
+ }
150
+
151
+ const headers = Object.assign({}, this.configuration.headers, context.headers);
152
+ Object.keys(headers).forEach(key => headers[key] === undefined ? delete headers[key] : {});
153
+
154
+ const initOverrideFn =
155
+ typeof initOverrides === "function"
156
+ ? initOverrides
157
+ : async () => initOverrides;
158
+
159
+ const initParams = {
160
+ method: context.method,
161
+ headers,
162
+ body: context.body,
163
+ credentials: this.configuration.credentials,
164
+ };
165
+
166
+ const overriddenInit: RequestInit = {
167
+ ...initParams,
168
+ ...(await initOverrideFn({
169
+ init: initParams,
170
+ context,
171
+ }))
172
+ };
173
+
174
+ let body: any;
175
+ if (isFormData(overriddenInit.body)
176
+ || (overriddenInit.body instanceof URLSearchParams)
177
+ || isBlob(overriddenInit.body)) {
178
+ body = overriddenInit.body;
179
+ } else if (this.isJsonMime(headers['Content-Type'])) {
180
+ body = JSON.stringify(overriddenInit.body);
181
+ } else {
182
+ body = overriddenInit.body;
183
+ }
184
+
185
+ const init: RequestInit = {
186
+ ...overriddenInit,
187
+ body
188
+ };
189
+
190
+ return { url, init };
191
+ }
192
+
193
+ private fetchApi = async (url: string, init: RequestInit) => {
194
+ let fetchParams = { url, init };
195
+ for (const middleware of this.middleware) {
196
+ if (middleware.pre) {
197
+ fetchParams = await middleware.pre({
198
+ fetch: this.fetchApi,
199
+ ...fetchParams,
200
+ }) || fetchParams;
201
+ }
202
+ }
203
+ let response: Response | undefined = undefined;
204
+ try {
205
+ response = await (this.configuration.fetchApi || fetch)(fetchParams.url, fetchParams.init);
206
+ } catch (e) {
207
+ for (const middleware of this.middleware) {
208
+ if (middleware.onError) {
209
+ response = await middleware.onError({
210
+ fetch: this.fetchApi,
211
+ url: fetchParams.url,
212
+ init: fetchParams.init,
213
+ error: e,
214
+ response: response ? response.clone() : undefined,
215
+ }) || response;
216
+ }
217
+ }
218
+ if (response === undefined) {
219
+ if (e instanceof Error) {
220
+ throw new FetchError(e, 'The request failed and the interceptors did not return an alternative response');
221
+ } else {
222
+ throw e;
223
+ }
224
+ }
225
+ }
226
+ for (const middleware of this.middleware) {
227
+ if (middleware.post) {
228
+ response = await middleware.post({
229
+ fetch: this.fetchApi,
230
+ url: fetchParams.url,
231
+ init: fetchParams.init,
232
+ response: response.clone(),
233
+ }) || response;
234
+ }
235
+ }
236
+ return response;
237
+ }
238
+
239
+ /**
240
+ * Create a shallow clone of `this` by constructing a new instance
241
+ * and then shallow cloning data members.
242
+ */
243
+ private clone<T extends BaseAPI>(this: T): T {
244
+ const constructor = this.constructor as any;
245
+ const next = new constructor(this.configuration);
246
+ next.middleware = this.middleware.slice();
247
+ return next;
248
+ }
249
+ };
250
+
251
+ function isBlob(value: any): value is Blob {
252
+ return typeof Blob !== 'undefined' && value instanceof Blob;
253
+ }
254
+
255
+ function isFormData(value: any): value is FormData {
256
+ return typeof FormData !== "undefined" && value instanceof FormData;
257
+ }
258
+
259
+ export class ResponseError extends Error {
260
+ override name: "ResponseError" = "ResponseError";
261
+ constructor(public response: Response, msg?: string) {
262
+ super(msg);
263
+
264
+ // restore prototype chain
265
+ const actualProto = new.target.prototype;
266
+ if (Object.setPrototypeOf) {
267
+ Object.setPrototypeOf(this, actualProto);
268
+ }
269
+ }
270
+ }
271
+
272
+ export class FetchError extends Error {
273
+ override name: "FetchError" = "FetchError";
274
+ constructor(public cause: Error, msg?: string) {
275
+ super(msg);
276
+
277
+ // restore prototype chain
278
+ const actualProto = new.target.prototype;
279
+ if (Object.setPrototypeOf) {
280
+ Object.setPrototypeOf(this, actualProto);
281
+ }
282
+ }
283
+ }
284
+
285
+ export class RequiredError extends Error {
286
+ override name: "RequiredError" = "RequiredError";
287
+ constructor(public field: string, msg?: string) {
288
+ super(msg);
289
+
290
+ // restore prototype chain
291
+ const actualProto = new.target.prototype;
292
+ if (Object.setPrototypeOf) {
293
+ Object.setPrototypeOf(this, actualProto);
294
+ }
295
+ }
296
+ }
297
+
298
+ export const COLLECTION_FORMATS = {
299
+ csv: ",",
300
+ ssv: " ",
301
+ tsv: "\t",
302
+ pipes: "|",
303
+ };
304
+
305
+ export type FetchAPI = WindowOrWorkerGlobalScope['fetch'];
306
+
307
+ export type Json = any;
308
+ export type HTTPMethod = 'GET' | 'POST' | 'PUT' | 'PATCH' | 'DELETE' | 'OPTIONS' | 'HEAD';
309
+ export type HTTPHeaders = { [key: string]: string };
310
+ export type HTTPQuery = { [key: string]: string | number | null | boolean | Array<string | number | null | boolean> | Set<string | number | null | boolean> | HTTPQuery };
311
+ export type HTTPBody = Json | FormData | URLSearchParams;
312
+ export type HTTPRequestInit = { headers?: HTTPHeaders; method: HTTPMethod; credentials?: RequestCredentials; body?: HTTPBody };
313
+ export type ModelPropertyNaming = 'camelCase' | 'snake_case' | 'PascalCase' | 'original';
314
+
315
+ export type InitOverrideFunction = (requestContext: { init: HTTPRequestInit, context: RequestOpts }) => Promise<RequestInit>
316
+
317
+ export interface FetchParams {
318
+ url: string;
319
+ init: RequestInit;
320
+ }
321
+
322
+ export interface RequestOpts {
323
+ path: string;
324
+ method: HTTPMethod;
325
+ headers: HTTPHeaders;
326
+ query?: HTTPQuery;
327
+ body?: HTTPBody;
328
+ }
329
+
330
+ export function querystring(params: HTTPQuery, prefix: string = ''): string {
331
+ return Object.keys(params)
332
+ .map(key => querystringSingleKey(key, params[key], prefix))
333
+ .filter(part => part.length > 0)
334
+ .join('&');
335
+ }
336
+
337
+ function querystringSingleKey(key: string, value: string | number | null | undefined | boolean | Array<string | number | null | boolean> | Set<string | number | null | boolean> | HTTPQuery, keyPrefix: string = ''): string {
338
+ const fullKey = keyPrefix + (keyPrefix.length ? `[${key}]` : key);
339
+ if (value instanceof Array) {
340
+ const multiValue = value.map(singleValue => encodeURIComponent(String(singleValue)))
341
+ .join(`&${encodeURIComponent(fullKey)}=`);
342
+ return `${encodeURIComponent(fullKey)}=${multiValue}`;
343
+ }
344
+ if (value instanceof Set) {
345
+ const valueAsArray = Array.from(value);
346
+ return querystringSingleKey(key, valueAsArray, keyPrefix);
347
+ }
348
+ if (value instanceof Date) {
349
+ return `${encodeURIComponent(fullKey)}=${encodeURIComponent(value.toISOString())}`;
350
+ }
351
+ if (value instanceof Object) {
352
+ return querystring(value as HTTPQuery, fullKey);
353
+ }
354
+ return `${encodeURIComponent(fullKey)}=${encodeURIComponent(String(value))}`;
355
+ }
356
+
357
+ export function exists(json: any, key: string) {
358
+ const value = json[key];
359
+ return value !== null && value !== undefined;
360
+ }
361
+
362
+ export function mapValues(data: any, fn: (item: any) => any) {
363
+ const result: { [key: string]: any } = {};
364
+ for (const key of Object.keys(data)) {
365
+ result[key] = fn(data[key]);
366
+ }
367
+ return result;
368
+ }
369
+
370
+ export function canConsumeForm(consumes: Consume[]): boolean {
371
+ for (const consume of consumes) {
372
+ if ('multipart/form-data' === consume.contentType) {
373
+ return true;
374
+ }
375
+ }
376
+ return false;
377
+ }
378
+
379
+ export interface Consume {
380
+ contentType: string;
381
+ }
382
+
383
+ export interface RequestContext {
384
+ fetch: FetchAPI;
385
+ url: string;
386
+ init: RequestInit;
387
+ }
388
+
389
+ export interface ResponseContext {
390
+ fetch: FetchAPI;
391
+ url: string;
392
+ init: RequestInit;
393
+ response: Response;
394
+ }
395
+
396
+ export interface ErrorContext {
397
+ fetch: FetchAPI;
398
+ url: string;
399
+ init: RequestInit;
400
+ error: unknown;
401
+ response?: Response;
402
+ }
403
+
404
+ export interface Middleware {
405
+ pre?(context: RequestContext): Promise<FetchParams | void>;
406
+ post?(context: ResponseContext): Promise<Response | void>;
407
+ onError?(context: ErrorContext): Promise<Response | void>;
408
+ }
409
+
410
+ export interface ApiResponse<T> {
411
+ raw: Response;
412
+ value(): Promise<T>;
413
+ }
414
+
415
+ export interface ResponseTransformer<T> {
416
+ (json: any): T;
417
+ }
418
+
419
+ export class JSONApiResponse<T> {
420
+ constructor(public raw: Response, private transformer: ResponseTransformer<T> = (jsonValue: any) => jsonValue) {}
421
+
422
+ async value(): Promise<T> {
423
+ return this.transformer(await this.raw.json());
424
+ }
425
+ }
426
+
427
+ export class VoidApiResponse {
428
+ constructor(public raw: Response) {}
429
+
430
+ async value(): Promise<void> {
431
+ return undefined;
432
+ }
433
+ }
434
+
435
+ export class BlobApiResponse {
436
+ constructor(public raw: Response) {}
437
+
438
+ async value(): Promise<Blob> {
439
+ return await this.raw.blob();
440
+ };
441
+ }
442
+
443
+ export class TextApiResponse {
444
+ constructor(public raw: Response) {}
445
+
446
+ async value(): Promise<string> {
447
+ return await this.raw.text();
448
+ };
449
+ }
@@ -0,0 +1,7 @@
1
+ {
2
+ "extends": "./tsconfig.json",
3
+ "compilerOptions": {
4
+ "module": "esnext",
5
+ "outDir": "dist/esm"
6
+ }
7
+ }
package/tsconfig.json ADDED
@@ -0,0 +1,16 @@
1
+ {
2
+ "compilerOptions": {
3
+ "declaration": true,
4
+ "target": "es6",
5
+ "module": "commonjs",
6
+ "moduleResolution": "node",
7
+ "outDir": "dist",
8
+ "typeRoots": [
9
+ "node_modules/@types"
10
+ ]
11
+ },
12
+ "exclude": [
13
+ "dist",
14
+ "node_modules"
15
+ ]
16
+ }