@great-detail/support-sdk 0.1.6 → 0.2.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 (63) hide show
  1. package/dist/chunk-IXJNWCJL.js +1 -0
  2. package/dist/{chunk-GQPMRQEH.js → chunk-SRYAEALQ.js} +1 -1
  3. package/dist/cli/index.cjs +1 -1
  4. package/dist/cli/index.d.cts +1 -1
  5. package/dist/cli/index.d.ts +1 -1
  6. package/dist/cli/index.js +1 -1
  7. package/dist/cli.cjs +1 -1
  8. package/dist/cli.js +1 -1
  9. package/dist/{index-fAkhYzqW.d.cts → index-Dj17QRj0.d.cts} +135 -112
  10. package/dist/{index-fAkhYzqW.d.ts → index-Dj17QRj0.d.ts} +135 -112
  11. package/dist/index.cjs +1 -1
  12. package/dist/index.d.cts +63 -6
  13. package/dist/index.d.ts +63 -6
  14. package/dist/index.js +1 -1
  15. package/package.json +2 -1
  16. package/src/Action/ListActions.ts +8 -12
  17. package/src/Authentication/KeyAuthentication.ts +10 -11
  18. package/src/Authentication/PublicAuthentication.ts +8 -2
  19. package/src/Authentication/TokenAuthentication.ts +9 -7
  20. package/src/Channel/ListChannels.ts +8 -12
  21. package/src/Client/index.ts +6 -5
  22. package/src/Contact/ContactVCF/GetContactVCF.ts +13 -11
  23. package/src/Contact/CreateContact.ts +12 -16
  24. package/src/Contact/GetContact.ts +8 -12
  25. package/src/Contact/ListContacts.ts +8 -12
  26. package/src/Contact/ListLabelContacts.ts +8 -12
  27. package/src/Contact/UpdateContact.ts +12 -16
  28. package/src/Conversation/GetConversation.ts +8 -12
  29. package/src/Conversation/ListConversations.ts +8 -12
  30. package/src/Conversation/ListLabelConversations.ts +8 -12
  31. package/src/Conversation/UpdateConversation.ts +12 -16
  32. package/src/Error/AuthError.ts +12 -0
  33. package/src/Error/AuthenticationError.ts +16 -0
  34. package/src/Error/AuthorizationError.ts +16 -0
  35. package/src/Error/LogicError.ts +20 -0
  36. package/src/Error/NetworkError.ts +12 -0
  37. package/src/Error/SupportError.ts +10 -0
  38. package/src/Error/ValidationError.ts +16 -0
  39. package/src/Error/index.ts +11 -0
  40. package/src/Label/CreateLabel.ts +12 -16
  41. package/src/Label/DeleteLabel.ts +8 -12
  42. package/src/Label/GetLabel.ts +8 -12
  43. package/src/Label/ListLabels.ts +8 -12
  44. package/src/Label/UpdateLabel.ts +12 -16
  45. package/src/Message/ListConversationMessages.ts +8 -12
  46. package/src/Message/ListMessages.ts +8 -12
  47. package/src/Model/Correction/CreateCorrectionModel.ts +12 -16
  48. package/src/Model/GetModel.ts +8 -12
  49. package/src/Model/ListModels.ts +8 -12
  50. package/src/Model/Response/CreateResponseModel.ts +12 -16
  51. package/src/Request/RequestFilterable.ts +5 -1
  52. package/src/Request/RequestStandardHeaders.ts +6 -6
  53. package/src/Source/GetSource.ts +8 -12
  54. package/src/Source/ListSources.ts +8 -12
  55. package/src/Transport/FetchTransport.ts +112 -0
  56. package/src/Transport/index.ts +2 -44
  57. package/src/__tests__/Client/Client.test.ts +38 -0
  58. package/src/constants/environment.ts +36 -0
  59. package/src/constants/index.ts +0 -21
  60. package/src/index.ts +4 -4
  61. package/dist/chunk-Q4LJP3V4.js +0 -1
  62. package/src/__tests__/Authentication/KeyAuthentication.test.ts +0 -79
  63. package/src/__tests__/Authentication/TokenAuthentication.test.ts +0 -79
@@ -1,79 +0,0 @@
1
- /**
2
- * Great Detail Support System.
3
- *
4
- * @copyright 2024 Great Detail Ltd
5
- * @author Great Detail Ltd <info@greatdetail.com>
6
- * @author Dom Webber <dom.webber@greatdetail.com>
7
- * @see https://greatdetail.com
8
- */
9
-
10
- import { describe, expect, test } from "@jest/globals";
11
- import TokenAuthentication from "../../Authentication/TokenAuthentication.js";
12
-
13
- describe("TokenAuthentication", () => {
14
- describe("Authentication application via filtering", () => {
15
- test("When a token is sourced from environment variables, it should be added in request headers", async () => {
16
- // Arrange
17
- const token = "example-access-token";
18
- process.env.SUPPORT_ACCESS_TOKEN = token;
19
- const auth = new TokenAuthentication();
20
- const init = {
21
- headers: {
22
- // Ensure that existing, non-colliding, headers remain
23
- "X-Trace-ID": "example",
24
-
25
- // Ensure that existing, colliding, headers are overwritten
26
- Authorization: "Basic ZXhhbXBsZTpleGFtcGxl", // example:example
27
- },
28
- };
29
-
30
- // Act
31
- const request = await auth.filter(init);
32
-
33
- // Assert
34
- expect(request).toHaveProperty("headers");
35
- expect(request.headers).toHaveProperty(
36
- "Authorization",
37
- "Bearer " + token,
38
- );
39
- expect(request.headers).toHaveProperty("X-Trace-ID", "example");
40
- });
41
-
42
- test("When a token is sourced directly, it should be added in request headers", async () => {
43
- // Arrange
44
- const token = "example-access-token";
45
- const auth = new TokenAuthentication({ token });
46
- const init = {
47
- headers: {
48
- // Ensure that existing, non-colliding, headers remain
49
- "X-Trace-ID": "example",
50
-
51
- // Ensure that existing, colliding, headers are overwritten
52
- Authorization: "Basic ZXhhbXBsZTpleGFtcGxl", // example:example
53
- },
54
- };
55
-
56
- // Act
57
- const request = await auth.filter(init);
58
-
59
- // Assert
60
- expect(request).toHaveProperty("headers");
61
- expect(request.headers).toHaveProperty(
62
- "Authorization",
63
- "Bearer " + token,
64
- );
65
- expect(request.headers).toHaveProperty("X-Trace-ID", "example");
66
- });
67
-
68
- test("When no token can be found, the constructor should throw", async () => {
69
- // Arrange
70
- process.env = {};
71
-
72
- // Act
73
- const auth = () => new TokenAuthentication(); // eslint-disable-line unicorn/consistent-function-scoping
74
-
75
- // Assert
76
- expect(auth).toThrow();
77
- });
78
- });
79
- });