@missioncontrolio/client 0.0.3

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 (42) hide show
  1. package/.env.local.example +9 -0
  2. package/README.md +226 -0
  3. package/package.json +25 -0
  4. package/src/client/autoCancelOrderHandler.ts +135 -0
  5. package/src/client/clientBuilder.ts +139 -0
  6. package/src/client/generated/client.ts +130 -0
  7. package/src/client/generated/kiota-lock.json +34 -0
  8. package/src/client/generated/models/index.ts +1723 -0
  9. package/src/client/generated/order/cancelOrder/index.ts +53 -0
  10. package/src/client/generated/order/claimReservation/index.ts +34 -0
  11. package/src/client/generated/order/claimReservation/item/index.ts +53 -0
  12. package/src/client/generated/order/createOrder/index.ts +53 -0
  13. package/src/client/generated/order/index.ts +112 -0
  14. package/src/client/generated/order/reportOrder/index.ts +53 -0
  15. package/src/client/generated/partner/index.ts +55 -0
  16. package/src/client/generated/priceList/index.ts +55 -0
  17. package/src/client/generated/product/hasStock/index.ts +53 -0
  18. package/src/client/generated/product/index.ts +119 -0
  19. package/src/client/generated/publisher/index.ts +55 -0
  20. package/src/client/generated/region/index.ts +63 -0
  21. package/src/client/generated/reservation/index.ts +71 -0
  22. package/src/client/generated/reservation/item/cancel/index.ts +48 -0
  23. package/src/client/generated/reservation/item/index.ts +62 -0
  24. package/src/client/missionControlEnvironment.ts +32 -0
  25. package/src/client/missionControlHandlers.ts +61 -0
  26. package/src/client/missionControlHeaders.ts +10 -0
  27. package/src/client/nonIdempotentPaths.ts +9 -0
  28. package/src/client/partnerIdHandler.ts +33 -0
  29. package/tests/autoCancelOrderHandler.test.ts +263 -0
  30. package/tests/clientBuilder.test.ts +154 -0
  31. package/tests/integration/fixture.ts +50 -0
  32. package/tests/integration/partner.test.ts +32 -0
  33. package/tests/integration/priceList.test.ts +28 -0
  34. package/tests/integration/product.test.ts +30 -0
  35. package/tests/integration/publisher.test.ts +30 -0
  36. package/tests/integration/region.test.ts +36 -0
  37. package/tests/integration/setup.ts +22 -0
  38. package/tests/missionControlEnvironment.test.ts +66 -0
  39. package/tests/missionControlHeaders.test.ts +20 -0
  40. package/tsconfig.json +18 -0
  41. package/vitest.config.ts +8 -0
  42. package/vitest.integration.config.ts +9 -0
@@ -0,0 +1,9 @@
1
+ MC_TENANT_ID=<your-azure-ad-tenant-id>
2
+ MC_CLIENT_ID=<your-client-id>
3
+ MC_CLIENT_SECRET=<your-client-secret>
4
+ MC_PARTNER_ID=<your-partner-id>
5
+ MC_BASE_URL=https://api.sandbox.missioncontrol.io
6
+ MC_SCOPE=api://<app-id>/.default
7
+ MC_PRODUCT_ID=<your-product-id>
8
+ MC_REGION_ID=<your-region-id>
9
+ MC_PUBLISHER_ID=<your-publisher-id>
package/README.md ADDED
@@ -0,0 +1,226 @@
1
+ # MissionControl Client — Node SDK
2
+
3
+ The Node SDK for the [Mission:Control](https://www.missioncontrol.io) Partner API. Built on top of [Kiota](https://learn.microsoft.com/en-us/openapi/kiota/), it provides a strongly-typed, async client for all partner operations: listing products, managing reservations, and creating orders.
4
+
5
+ ## Requirements
6
+
7
+ Node.js 18 or later
8
+
9
+ ## Installation
10
+
11
+ ```
12
+ npm install @pandomc/missioncontrol-client
13
+ ```
14
+
15
+ ## Getting started
16
+
17
+ ### Creating a client
18
+
19
+ Credentials are obtained from the **Client Credentials** page in the Mission:Control portal.
20
+
21
+ ```ts
22
+ import { ClientBuilder } from "@pandomc/missioncontrol-client";
23
+
24
+ const client = new ClientBuilder()
25
+ .withAzureAdClientCredentials("your-client-id", "your-client-secret")
26
+ .withDefaultPartnerId("your-partner-id")
27
+ .build();
28
+ ```
29
+
30
+ By default the client targets **Production**. To use the **Sandbox** environment during development:
31
+
32
+ ```ts
33
+ import {
34
+ ClientBuilder,
35
+ MissionControlEnvironment,
36
+ } from "@pandomc/missioncontrol-client";
37
+
38
+ const client = new ClientBuilder()
39
+ .forEnvironment(MissionControlEnvironment.Sandbox)
40
+ .withAzureAdClientCredentials("your-client-id", "your-client-secret")
41
+ .withDefaultPartnerId("your-partner-id")
42
+ .build();
43
+ ```
44
+
45
+ ## Usage examples
46
+
47
+ ### List products
48
+
49
+ ```ts
50
+ const result = await client.product.get();
51
+
52
+ for (const product of result?.result ?? []) {
53
+ console.log(product.id, product.name);
54
+ }
55
+ ```
56
+
57
+ ### Check stock
58
+
59
+ ```ts
60
+ const response = await client.product.hasStock.post({
61
+ productId: productId,
62
+ regionId: regionId,
63
+ });
64
+
65
+ console.log(response?.hasStock ? "In stock" : "Out of stock");
66
+ ```
67
+
68
+ ### Reserve → claim (place an order)
69
+
70
+ ```ts
71
+ // 1. Create a reservation — holds the key briefly while the customer checks out.
72
+ const reservation = await client.reservation.post({
73
+ productId: productId,
74
+ regionId: regionId,
75
+ });
76
+
77
+ // 2. Claim the reservation to finalise the order and receive the key.
78
+ const order = await client.order.claimReservation
79
+ .byReservationId(reservation!.id!)
80
+ .post({
81
+ requestId: crypto.randomUUID(),
82
+ partnerReference: "your-internal-order-ref",
83
+ invoiceDate: new Date().toISOString(),
84
+ salesChannel: [],
85
+ endConsumer: {
86
+ ipAddress: "1.2.3.4",
87
+ language: "en-US",
88
+ location: { countryCode: "NL" },
89
+ },
90
+ salesPrice: {
91
+ priceIncludingVat: { value: 9.99, currencyCode: "EUR" },
92
+ vatDetail: { rate: 21 },
93
+ },
94
+ });
95
+
96
+ console.log(`Order ${order!.id} placed.`);
97
+ ```
98
+
99
+ ### Cancel a reservation
100
+
101
+ ```ts
102
+ await client.reservation.byReservationId(reservation!.id!).cancel.post();
103
+ ```
104
+
105
+ ### Filtering and pagination
106
+
107
+ All list endpoints accept an optional `queryParameters` object for filtering and pagination. Every parameter is optional — only set what you need.
108
+
109
+ **Filter products by publisher, name, and page size:**
110
+
111
+ ```ts
112
+ const result = await client.product.get({
113
+ queryParameters: {
114
+ publisherId: ["publisher-id-1", "publisher-id-2"],
115
+ name: "minecraft",
116
+ pageSize: 25,
117
+ pageIndex: 0,
118
+ },
119
+ });
120
+ ```
121
+
122
+ ## Configuration reference
123
+
124
+ | Key | Required | Description |
125
+ | -------------- | -------- | ----------------------------------------------------------- |
126
+ | `clientId` | ✓ | Application (client) ID from the portal |
127
+ | `clientSecret` | ✓ | Client secret from the portal |
128
+ | `partnerId` | ✓ | Partner ID sent as `X-Partner-Id` with every request |
129
+ | `environment` | — | `Sandbox` or `Production` (default: `Production`) |
130
+ | `tenantId` | — | Azure AD tenant ID (defaults to the Mission:Control tenant) |
131
+
132
+ ### `ClientBuilder` methods
133
+
134
+ | Method | Description |
135
+ | ----------------------------------------------------------------- | -------------------------------------------------- |
136
+ | `withAzureAdClientCredentials(clientId, clientSecret, tenantId?)` | Configure authentication |
137
+ | `withDefaultPartnerId(partnerId)` | Set the `X-Partner-Id` header for every request |
138
+ | `forEnvironment(env)` | Target `Sandbox` or `Production` |
139
+ | `withBaseUrl(url)` | Override the base URL (e.g. for local development) |
140
+ | `withScope(scope)` | Override the OAuth scope |
141
+ | `build()` | Return the configured `Client` instance |
142
+
143
+ ## Resilience
144
+
145
+ The SDK registers Kiota's default HTTP middleware pipeline, which includes a `RetryHandler` that automatically retries transient failures before surfacing an exception:
146
+
147
+ | Status code | Meaning | Behaviour |
148
+ | ----------- | ------------------- | ------------------------------------- |
149
+ | `429` | Too Many Requests | Retried after honouring `Retry-After` |
150
+ | `503` | Service Unavailable | Retried with exponential back-off |
151
+ | `504` | Gateway Timeout | Retried with exponential back-off |
152
+
153
+ The handler retries up to three times by default. If all retries are exhausted without a successful response the last error response is returned to the caller (and mapped to a `ProblemDetails` error where applicable).
154
+
155
+ No extra configuration is required — retries are active out of the box.
156
+
157
+ ## Error handling
158
+
159
+ The API returns errors as [RFC 9457 Problem Details](https://www.rfc-editor.org/rfc/rfc9457) JSON objects. The SDK maps these to `ProblemDetails` objects and throws them, which you catch like any other error.
160
+
161
+ ### `ProblemDetails` properties
162
+
163
+ | Property | Type | Description |
164
+ | ---------------- | ------------------------- | --------------------------------------------------------------- |
165
+ | `status` | `number \| null` | HTTP status code (e.g. `400`, `500`) |
166
+ | `title` | `string \| null` | Short, human-readable summary of the problem |
167
+ | `detail` | `string \| null` | Longer explanation of this specific occurrence |
168
+ | `type` | `string \| null` | URI identifying the problem type |
169
+ | `instance` | `string \| null` | URI identifying this specific occurrence |
170
+ | `additionalData` | `Record<string, unknown>` | Any extra fields returned by the API (e.g. `errors`, `traceId`) |
171
+
172
+ ### Status codes
173
+
174
+ | Status | When it occurs |
175
+ | ------ | --------------------------------------------------------------------------------------------------- |
176
+ | `400` | The request failed validation — check `additionalData["errors"]` for per-field messages |
177
+ | `500` | An unexpected error occurred on the server — `additionalData["traceId"]` can be shared with support |
178
+
179
+ ### Handling a validation error (400)
180
+
181
+ A 400 response from the API looks like:
182
+
183
+ ```json
184
+ {
185
+ "type": "https://tools.ietf.org/html/rfc9110#section-15.5.1",
186
+ "title": "One or more validation errors occurred.",
187
+ "status": 400,
188
+ "errors": {
189
+ "ProductId": ["The value 'foobar' is not valid."]
190
+ },
191
+ "traceId": "00-90f2dadbc2e77ae87cbe3b8a25fe0689-dbff6f5f82d028d2-00"
192
+ }
193
+ ```
194
+
195
+ `errors` and `traceId` are not first-class properties on the model — they land in `additionalData` because they are not part of the OpenAPI schema. Cast them as needed:
196
+
197
+ ```ts
198
+ import type { ProblemDetails } from "@pandomc/missioncontrol-client";
199
+
200
+ try {
201
+ const result = await client.product.get({
202
+ queryParameters: {
203
+ productId: ["not-a-guid"],
204
+ },
205
+ });
206
+ } catch (ex) {
207
+ if (ex && typeof ex === "object" && "status" in ex) {
208
+ const problem = ex as ProblemDetails;
209
+ console.log(`Failed: ${problem.title}`);
210
+
211
+ const errors = problem.additionalData?.["errors"];
212
+ if (errors && typeof errors === "object") {
213
+ for (const [field, messages] of Object.entries(
214
+ errors as Record<string, unknown>,
215
+ )) {
216
+ console.log(` ${field}: ${messages}`);
217
+ }
218
+ }
219
+
220
+ const traceId = problem.additionalData?.["traceId"];
221
+ if (traceId !== undefined) {
222
+ console.log(` Trace ID: ${traceId}`);
223
+ }
224
+ }
225
+ }
226
+ ```
package/package.json ADDED
@@ -0,0 +1,25 @@
1
+ {
2
+ "name": "@missioncontrolio/client",
3
+ "description": "The official Node SDK for the Mission:Control Partner API.",
4
+ "license": "ISC",
5
+ "author": "",
6
+ "type": "module",
7
+ "main": "index.js",
8
+ "scripts": {
9
+ "build": "tsc",
10
+ "test": "vitest run",
11
+ "test:watch": "vitest",
12
+ "test:integration": "vitest run --config vitest.integration.config.ts"
13
+ },
14
+ "devDependencies": {
15
+ "@types/node": "^25.5.0",
16
+ "typescript": "^5.9.3",
17
+ "vitest": "^4.1.0"
18
+ },
19
+ "dependencies": {
20
+ "@azure/identity": "^4.13.0",
21
+ "@microsoft/kiota-authentication-azure": "^1.0.0-preview.100",
22
+ "@microsoft/kiota-bundle": "^1.0.0-preview.100"
23
+ },
24
+ "version": "0.0.3"
25
+ }
@@ -0,0 +1,135 @@
1
+ import type { RequestOption } from "@microsoft/kiota-abstractions";
2
+ import type { Middleware } from "@microsoft/kiota-http-fetchlibrary";
3
+ import { MissionControlHeaders } from "./missionControlHeaders";
4
+ import { nonIdempotentPaths } from "./nonIdempotentPaths";
5
+
6
+ const CANCEL_TIMEOUT_MS = 30_000;
7
+
8
+ /**
9
+ * A Kiota middleware that automatically attempts to cancel an order when a request to one of
10
+ * the order-mutation endpoints fails with a server error (5xx) or a network/connection error.
11
+ *
12
+ * Affected endpoints: `createOrder`, `claimReservation`, `reportOrder`.
13
+ *
14
+ * The cancellation attempt is best-effort. If it fails the original error is still propagated
15
+ * to the caller unchanged.
16
+ */
17
+ export class AutoCancelOrderHandler implements Middleware {
18
+ next: Middleware | undefined;
19
+
20
+ async execute(
21
+ url: string,
22
+ requestInit: RequestInit,
23
+ requestOptions?: Record<string, RequestOption>,
24
+ ): Promise<Response> {
25
+ if (!isAutoCancelEndpoint(url)) {
26
+ return this.next!.execute(url, requestInit, requestOptions);
27
+ }
28
+
29
+ // Buffer the request body before the inner handler consumes it.
30
+ const requestBody =
31
+ requestInit.body != null ? String(requestInit.body) : null;
32
+
33
+ let response: Response;
34
+ try {
35
+ response = await this.next!.execute(url, requestInit, requestOptions);
36
+ } catch (err) {
37
+ // Network/connection error — attempt a best-effort cancel.
38
+ await this.tryCancelOrderAsync(url, requestInit, requestBody);
39
+ throw err;
40
+ }
41
+
42
+ if (isServerError(response)) {
43
+ await this.tryCancelOrderAsync(url, requestInit, requestBody);
44
+ }
45
+
46
+ return response;
47
+ }
48
+
49
+ private async tryCancelOrderAsync(
50
+ originalUrl: string,
51
+ originalInit: RequestInit,
52
+ requestBody: string | null,
53
+ ): Promise<void> {
54
+ try {
55
+ const requestId = extractRequestId(requestBody);
56
+ if (requestId == null) return;
57
+
58
+ const cancelUrl = buildCancelUrl(originalUrl);
59
+ if (cancelUrl == null) return;
60
+
61
+ const headers = new Headers();
62
+ headers.set("Content-Type", "application/json");
63
+
64
+ // Copy auth and partner-id headers so the cancel request is properly authenticated
65
+ // and attributed — the inner middleware handles retry and other cross-cutting concerns.
66
+ const originalHeaders = new Headers(originalInit.headers);
67
+ const auth = originalHeaders.get("Authorization");
68
+ if (auth) headers.set("Authorization", auth);
69
+ const partnerId = originalHeaders.get(MissionControlHeaders.PartnerId);
70
+ if (partnerId) headers.set(MissionControlHeaders.PartnerId, partnerId);
71
+
72
+ const cancelInit: RequestInit = {
73
+ method: "POST",
74
+ headers,
75
+ body: JSON.stringify({ originalRequestId: requestId }),
76
+ signal: AbortSignal.timeout(CANCEL_TIMEOUT_MS),
77
+ };
78
+
79
+ await this.next!.execute(cancelUrl, cancelInit, undefined);
80
+ } catch {
81
+ // Best-effort: swallow failures so the original error propagates.
82
+ }
83
+ }
84
+ }
85
+
86
+ function isAutoCancelEndpoint(url: string): boolean {
87
+ try {
88
+ const path = new URL(url).pathname;
89
+ // Use includes so this works regardless of any base-path prefix
90
+ // (e.g. /partnerApi/v2/Order/createOrder).
91
+ return nonIdempotentPaths.some((prefix) =>
92
+ path.toLowerCase().includes(prefix.toLowerCase()),
93
+ );
94
+ } catch {
95
+ return false;
96
+ }
97
+ }
98
+
99
+ function isServerError(response: Response): boolean {
100
+ return response.status >= 500;
101
+ }
102
+
103
+ function extractRequestId(json: string | null): string | null {
104
+ if (!json) return null;
105
+ try {
106
+ const parsed: unknown = JSON.parse(json);
107
+ if (
108
+ parsed != null &&
109
+ typeof parsed === "object" &&
110
+ "requestId" in parsed &&
111
+ typeof (parsed as Record<string, unknown>).requestId === "string"
112
+ ) {
113
+ return (parsed as Record<string, unknown>).requestId as string;
114
+ }
115
+ } catch {
116
+ // Malformed body — nothing to extract.
117
+ }
118
+ return null;
119
+ }
120
+
121
+ function buildCancelUrl(url: string): string | null {
122
+ try {
123
+ const parsed = new URL(url);
124
+ const path = parsed.pathname;
125
+ const orderIndex = path.toLowerCase().indexOf("/order/");
126
+ if (orderIndex < 0) return null;
127
+
128
+ parsed.pathname =
129
+ path.slice(0, orderIndex + "/Order/".length) + "cancelOrder";
130
+ parsed.search = "";
131
+ return parsed.toString();
132
+ } catch {
133
+ return null;
134
+ }
135
+ }
@@ -0,0 +1,139 @@
1
+ import { ClientSecretCredential } from "@azure/identity";
2
+ import { AzureIdentityAuthenticationProvider } from "@microsoft/kiota-authentication-azure";
3
+ import {
4
+ FetchRequestAdapter,
5
+ KiotaClientFactory,
6
+ } from "@microsoft/kiota-http-fetchlibrary";
7
+ import { createClient, type Client } from "./generated/client";
8
+ import {
9
+ getBaseUrl,
10
+ getScope,
11
+ MissionControlEnvironment,
12
+ } from "./missionControlEnvironment";
13
+ import { createHandlers } from "./missionControlHandlers";
14
+
15
+ /**
16
+ * Fluent builder for creating a configured {@link Client} instance.
17
+ */
18
+ export class ClientBuilder {
19
+ private _baseUrl: string = getBaseUrl(MissionControlEnvironment.Production);
20
+ private _scope: string = getScope(MissionControlEnvironment.Production);
21
+ private _tenantId: string = "13d084c1-d072-41f2-878b-c45ca721c9f6";
22
+ private _clientId?: string;
23
+ private _clientSecret?: string;
24
+ private _defaultPartnerId?: string;
25
+
26
+ /**
27
+ * Sets the default `X-Partner-Id` header value sent with every request.
28
+ *
29
+ * Most partners operate under a single partner identity, so setting this once on the
30
+ * builder means you never have to specify it per-request. When a request explicitly sets
31
+ * the header that value takes precedence over the default configured here.
32
+ *
33
+ * @param partnerId The partner ID shown on the client credentials page in the portal.
34
+ */
35
+ withDefaultPartnerId(partnerId: string): this {
36
+ if (!partnerId?.trim())
37
+ throw new Error("partnerId must not be null or whitespace.");
38
+ this._defaultPartnerId = partnerId;
39
+ return this;
40
+ }
41
+
42
+ /**
43
+ * Overrides the base URL used for all API requests.
44
+ * Useful for pointing at a local development server or a custom endpoint.
45
+ * When combined with {@link forEnvironment}, the last call wins.
46
+ *
47
+ * @param baseUrl The base URL, e.g. `http://localhost:5000`.
48
+ */
49
+ withBaseUrl(baseUrl: string): this {
50
+ if (!baseUrl?.trim())
51
+ throw new Error("baseUrl must not be null or whitespace.");
52
+ this._baseUrl = baseUrl;
53
+ return this;
54
+ }
55
+
56
+ /**
57
+ * Overrides the OAuth scope used when acquiring tokens.
58
+ * Useful when running against a local or custom environment whose app registration
59
+ * differs from the well-known environments.
60
+ * When combined with {@link forEnvironment}, the last call wins.
61
+ *
62
+ * @param scope The full scope URI, e.g. `api://<app-id>/.default`.
63
+ */
64
+ withScope(scope: string): this {
65
+ if (!scope?.trim())
66
+ throw new Error("scope must not be null or whitespace.");
67
+ this._scope = scope;
68
+ return this;
69
+ }
70
+
71
+ /**
72
+ * Targets a well-known MissionControl environment. Sets the matching base URL and API scope together.
73
+ * Defaults to {@link MissionControlEnvironment.Production} when not called.
74
+ *
75
+ * @param environment The target environment.
76
+ */
77
+ forEnvironment(environment: MissionControlEnvironment): this {
78
+ this._baseUrl = getBaseUrl(environment);
79
+ this._scope = getScope(environment);
80
+ return this;
81
+ }
82
+
83
+ /**
84
+ * Configures the client to authenticate using Azure AD client credentials (client secret flow).
85
+ * The API scope is derived from the configured environment unless overridden by {@link withScope}.
86
+ *
87
+ * @param clientId The application (client) ID of the app registration.
88
+ * @param clientSecret The client secret of the app registration.
89
+ * @param tenantId The Azure AD tenant ID. Uses the PandoMC tenant when omitted.
90
+ */
91
+ withAzureAdClientCredentials(
92
+ clientId: string,
93
+ clientSecret: string,
94
+ tenantId?: string,
95
+ ): this {
96
+ this._clientId = clientId;
97
+ this._clientSecret = clientSecret;
98
+ if (tenantId) this._tenantId = tenantId;
99
+ return this;
100
+ }
101
+
102
+ /**
103
+ * Builds and returns the configured {@link Client}.
104
+ *
105
+ * @throws {Error} When credentials have not been configured via {@link withAzureAdClientCredentials}.
106
+ */
107
+ build(): Client {
108
+ if (!this._clientId || !this._clientSecret) {
109
+ throw new Error(
110
+ "No credentials configured. " +
111
+ "Call withAzureAdClientCredentials() before calling build().",
112
+ );
113
+ }
114
+
115
+ const credential = new ClientSecretCredential(
116
+ this._tenantId,
117
+ this._clientId,
118
+ this._clientSecret,
119
+ );
120
+ const allowedHosts = new Set([new URL(this._baseUrl).host]);
121
+ const authProvider = new AzureIdentityAuthenticationProvider(
122
+ credential,
123
+ [this._scope],
124
+ undefined,
125
+ allowedHosts,
126
+ );
127
+
128
+ const middlewares = createHandlers(this._defaultPartnerId);
129
+ const httpClient = KiotaClientFactory.create(undefined, middlewares);
130
+ const adapter = new FetchRequestAdapter(
131
+ authProvider,
132
+ undefined,
133
+ undefined,
134
+ httpClient,
135
+ );
136
+ adapter.baseUrl = this._baseUrl;
137
+ return createClient(adapter);
138
+ }
139
+ }
@@ -0,0 +1,130 @@
1
+ /* tslint:disable */
2
+ /* eslint-disable */
3
+ // Generated by Microsoft Kiota
4
+ // @ts-ignore
5
+ import { OrderRequestBuilderNavigationMetadata, OrderRequestBuilderRequestsMetadata, type OrderRequestBuilder } from './order/index.js';
6
+ // @ts-ignore
7
+ import { PartnerRequestBuilderRequestsMetadata, type PartnerRequestBuilder } from './partner/index.js';
8
+ // @ts-ignore
9
+ import { PriceListRequestBuilderRequestsMetadata, type PriceListRequestBuilder } from './priceList/index.js';
10
+ // @ts-ignore
11
+ import { ProductRequestBuilderNavigationMetadata, ProductRequestBuilderRequestsMetadata, type ProductRequestBuilder } from './product/index.js';
12
+ // @ts-ignore
13
+ import { PublisherRequestBuilderRequestsMetadata, type PublisherRequestBuilder } from './publisher/index.js';
14
+ // @ts-ignore
15
+ import { RegionRequestBuilderRequestsMetadata, type RegionRequestBuilder } from './region/index.js';
16
+ // @ts-ignore
17
+ import { ReservationRequestBuilderNavigationMetadata, ReservationRequestBuilderRequestsMetadata, type ReservationRequestBuilder } from './reservation/index.js';
18
+ // @ts-ignore
19
+ import { apiClientProxifier, ParseNodeFactoryRegistry, SerializationWriterFactoryRegistry, type BaseRequestBuilder, type KeysToExcludeForNavigationMetadata, type NavigationMetadata, type RequestAdapter } from '@microsoft/kiota-abstractions';
20
+ // @ts-ignore
21
+ import { FormParseNodeFactory, FormSerializationWriterFactory } from '@microsoft/kiota-serialization-form';
22
+ // @ts-ignore
23
+ import { JsonParseNodeFactory, JsonSerializationWriterFactory } from '@microsoft/kiota-serialization-json';
24
+ // @ts-ignore
25
+ import { MultipartSerializationWriterFactory } from '@microsoft/kiota-serialization-multipart';
26
+ // @ts-ignore
27
+ import { TextParseNodeFactory, TextSerializationWriterFactory } from '@microsoft/kiota-serialization-text';
28
+
29
+ /**
30
+ * The main entry point of the SDK, exposes the configuration and the fluent API.
31
+ */
32
+ export interface Client extends BaseRequestBuilder<Client> {
33
+ /**
34
+ * The Order property
35
+ */
36
+ get order(): OrderRequestBuilder;
37
+ /**
38
+ * The Partner property
39
+ */
40
+ get partner(): PartnerRequestBuilder;
41
+ /**
42
+ * The PriceList property
43
+ */
44
+ get priceList(): PriceListRequestBuilder;
45
+ /**
46
+ * The Product property
47
+ */
48
+ get product(): ProductRequestBuilder;
49
+ /**
50
+ * The Publisher property
51
+ */
52
+ get publisher(): PublisherRequestBuilder;
53
+ /**
54
+ * The Region property
55
+ */
56
+ get region(): RegionRequestBuilder;
57
+ /**
58
+ * The Reservation property
59
+ */
60
+ get reservation(): ReservationRequestBuilder;
61
+ }
62
+ /**
63
+ * Instantiates a new {@link Client} and sets the default values.
64
+ * @param requestAdapter The request adapter to use to execute the requests.
65
+ */
66
+ // @ts-ignore
67
+ export function createClient(requestAdapter: RequestAdapter) {
68
+ if (requestAdapter === undefined) {
69
+ throw new Error("requestAdapter cannot be undefined");
70
+ }
71
+ const serializationWriterFactory = requestAdapter.getSerializationWriterFactory() as SerializationWriterFactoryRegistry;
72
+ const parseNodeFactoryRegistry = requestAdapter.getParseNodeFactory() as ParseNodeFactoryRegistry;
73
+ const backingStoreFactory = requestAdapter.getBackingStoreFactory();
74
+
75
+ if (parseNodeFactoryRegistry.registerDefaultDeserializer) {
76
+ parseNodeFactoryRegistry.registerDefaultDeserializer(JsonParseNodeFactory, backingStoreFactory);
77
+ parseNodeFactoryRegistry.registerDefaultDeserializer(TextParseNodeFactory, backingStoreFactory);
78
+ parseNodeFactoryRegistry.registerDefaultDeserializer(FormParseNodeFactory, backingStoreFactory);
79
+ }
80
+
81
+ if (serializationWriterFactory.registerDefaultSerializer) {
82
+ serializationWriterFactory.registerDefaultSerializer(JsonSerializationWriterFactory);
83
+ serializationWriterFactory.registerDefaultSerializer(TextSerializationWriterFactory);
84
+ serializationWriterFactory.registerDefaultSerializer(FormSerializationWriterFactory);
85
+ serializationWriterFactory.registerDefaultSerializer(MultipartSerializationWriterFactory);
86
+ }
87
+
88
+ if (requestAdapter.baseUrl === undefined || requestAdapter.baseUrl === null || requestAdapter.baseUrl === "") {
89
+ requestAdapter.baseUrl = "http://api.test.missioncontrol.io/partnerApi/v2";
90
+ }
91
+ const pathParameters: Record<string, unknown> = {
92
+ "baseurl": requestAdapter.baseUrl,
93
+ };
94
+ return apiClientProxifier<Client>(requestAdapter, pathParameters, ClientNavigationMetadata, undefined);
95
+ }
96
+ /**
97
+ * Uri template for the request builder.
98
+ */
99
+ export const ClientUriTemplate = "{+baseurl}";
100
+ /**
101
+ * Metadata for all the navigation properties in the request builder.
102
+ */
103
+ export const ClientNavigationMetadata: Record<Exclude<keyof Client, KeysToExcludeForNavigationMetadata>, NavigationMetadata> = {
104
+ order: {
105
+ requestsMetadata: OrderRequestBuilderRequestsMetadata,
106
+ navigationMetadata: OrderRequestBuilderNavigationMetadata,
107
+ },
108
+ partner: {
109
+ requestsMetadata: PartnerRequestBuilderRequestsMetadata,
110
+ },
111
+ priceList: {
112
+ requestsMetadata: PriceListRequestBuilderRequestsMetadata,
113
+ },
114
+ product: {
115
+ requestsMetadata: ProductRequestBuilderRequestsMetadata,
116
+ navigationMetadata: ProductRequestBuilderNavigationMetadata,
117
+ },
118
+ publisher: {
119
+ requestsMetadata: PublisherRequestBuilderRequestsMetadata,
120
+ },
121
+ region: {
122
+ requestsMetadata: RegionRequestBuilderRequestsMetadata,
123
+ },
124
+ reservation: {
125
+ requestsMetadata: ReservationRequestBuilderRequestsMetadata,
126
+ navigationMetadata: ReservationRequestBuilderNavigationMetadata,
127
+ },
128
+ };
129
+ /* tslint:enable */
130
+ /* eslint-enable */