@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,66 @@
1
+ import { describe, it, expect } from "vitest";
2
+ import {
3
+ MissionControlEnvironment,
4
+ getBaseUrl,
5
+ getScope,
6
+ } from "../src/client/missionControlEnvironment";
7
+
8
+ describe("MissionControlEnvironment", () => {
9
+ describe("enum values", () => {
10
+ it("Sandbox has the expected string value", () => {
11
+ expect(MissionControlEnvironment.Sandbox).toBe("Sandbox");
12
+ });
13
+
14
+ it("Production has the expected string value", () => {
15
+ expect(MissionControlEnvironment.Production).toBe("Production");
16
+ });
17
+ });
18
+
19
+ describe("getBaseUrl", () => {
20
+ it("returns the sandbox base URL for the Sandbox environment", () => {
21
+ expect(getBaseUrl(MissionControlEnvironment.Sandbox)).toBe(
22
+ "https://api.sandbox.missioncontrol.io",
23
+ );
24
+ });
25
+
26
+ it("returns the production base URL for the Production environment", () => {
27
+ expect(getBaseUrl(MissionControlEnvironment.Production)).toBe(
28
+ "https://api.missioncontrol.io",
29
+ );
30
+ });
31
+
32
+ it("Sandbox and Production base URLs are different", () => {
33
+ expect(getBaseUrl(MissionControlEnvironment.Sandbox)).not.toBe(
34
+ getBaseUrl(MissionControlEnvironment.Production),
35
+ );
36
+ });
37
+ });
38
+
39
+ describe("getScope", () => {
40
+ it("returns the sandbox OAuth scope for the Sandbox environment", () => {
41
+ expect(getScope(MissionControlEnvironment.Sandbox)).toBe(
42
+ "api://38fbfaea-5648-4b51-ac09-d5d90117beff/.default",
43
+ );
44
+ });
45
+
46
+ it("returns the production OAuth scope for the Production environment", () => {
47
+ expect(getScope(MissionControlEnvironment.Production)).toBe(
48
+ "api://1b6f40bc-e051-4b7e-987f-47a4a19fa5ef/.default",
49
+ );
50
+ });
51
+
52
+ it("Sandbox and Production scopes are different", () => {
53
+ expect(getScope(MissionControlEnvironment.Sandbox)).not.toBe(
54
+ getScope(MissionControlEnvironment.Production),
55
+ );
56
+ });
57
+
58
+ it("scope follows the api://<guid>/.default pattern", () => {
59
+ const scopePattern = /^api:\/\/[0-9a-f-]+\/.default$/;
60
+ expect(getScope(MissionControlEnvironment.Sandbox)).toMatch(scopePattern);
61
+ expect(getScope(MissionControlEnvironment.Production)).toMatch(
62
+ scopePattern,
63
+ );
64
+ });
65
+ });
66
+ });
@@ -0,0 +1,20 @@
1
+ import { describe, it, expect } from "vitest";
2
+ import { MissionControlHeaders } from "../src/client/missionControlHeaders";
3
+
4
+ describe("MissionControlHeaders", () => {
5
+ it('PartnerId equals "X-Partner-Id"', () => {
6
+ expect(MissionControlHeaders.PartnerId).toBe("X-Partner-Id");
7
+ });
8
+
9
+ it("is a non-empty string", () => {
10
+ expect(typeof MissionControlHeaders.PartnerId).toBe("string");
11
+ expect(MissionControlHeaders.PartnerId.length).toBeGreaterThan(0);
12
+ });
13
+
14
+ it("uses the standard HTTP header casing convention", () => {
15
+ // Header names should be in Train-Case (e.g. X-Partner-Id)
16
+ expect(MissionControlHeaders.PartnerId).toMatch(
17
+ /^[A-Z][a-zA-Z0-9]*(-[A-Z][a-zA-Z0-9]*)*$/,
18
+ );
19
+ });
20
+ });
package/tsconfig.json ADDED
@@ -0,0 +1,18 @@
1
+ {
2
+ "compilerOptions": {
3
+ "rootDir": "./src",
4
+ "outDir": "./dist",
5
+ "target": "ES2020",
6
+ "module": "ES2020",
7
+ "moduleResolution": "node",
8
+ "lib": ["dom", "es2020"],
9
+ "allowSyntheticDefaultImports": true,
10
+ "experimentalDecorators": true,
11
+ "noUnusedLocals": false,
12
+ "removeComments": true,
13
+ "strict": true,
14
+ "typeRoots": ["node_modules/@types"]
15
+ },
16
+ "include": ["src/**/*.ts"],
17
+ "exclude": ["node_modules"]
18
+ }
@@ -0,0 +1,8 @@
1
+ import { defineConfig } from "vitest/config";
2
+
3
+ export default defineConfig({
4
+ test: {
5
+ environment: "node",
6
+ exclude: ["tests/integration/**", "node_modules/**"],
7
+ },
8
+ });
@@ -0,0 +1,9 @@
1
+ import { defineConfig } from "vitest/config";
2
+
3
+ export default defineConfig({
4
+ test: {
5
+ environment: "node",
6
+ include: ["tests/integration/**/*.test.ts"],
7
+ setupFiles: ["tests/integration/setup.ts"],
8
+ },
9
+ });