@kontent-ai/core-sdk 12.0.0-preview.4 → 12.0.0-preview.40

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 (146) hide show
  1. package/.npmignore +1 -5
  2. package/LICENSE.md +1 -1
  3. package/README.md +117 -12
  4. package/dist/core-sdk-info.d.ts +2 -0
  5. package/dist/core-sdk-info.js +6 -0
  6. package/dist/core-sdk-info.js.map +1 -0
  7. package/dist/devkit/console.utils.d.ts +2 -0
  8. package/dist/devkit/console.utils.js +5 -0
  9. package/dist/devkit/console.utils.js.map +1 -0
  10. package/dist/devkit/environment.utils.d.ts +2 -0
  11. package/dist/devkit/environment.utils.js +12 -0
  12. package/dist/devkit/environment.utils.js.map +1 -0
  13. package/dist/devkit/script.utils.js +3 -3
  14. package/dist/devkit/script.utils.js.map +1 -1
  15. package/dist/{utils → devkit}/sdk-version.utils.js +2 -2
  16. package/dist/devkit/sdk-version.utils.js.map +1 -0
  17. package/dist/devkit_api.d.ts +4 -1
  18. package/dist/devkit_api.js +4 -2
  19. package/dist/devkit_api.js.map +1 -1
  20. package/dist/http/http.adapter.d.ts +1 -1
  21. package/dist/http/http.adapter.js +74 -24
  22. package/dist/http/http.adapter.js.map +1 -1
  23. package/dist/http/http.models.d.ts +49 -37
  24. package/dist/http/http.service.d.ts +2 -2
  25. package/dist/http/http.service.js +305 -220
  26. package/dist/http/http.service.js.map +1 -1
  27. package/dist/models/core.models.d.ts +33 -40
  28. package/dist/models/error.models.d.ts +78 -32
  29. package/dist/models/error.models.js +51 -1
  30. package/dist/models/error.models.js.map +1 -1
  31. package/dist/models/json.models.d.ts +13 -4
  32. package/dist/models/json.models.js +10 -1
  33. package/dist/models/json.models.js.map +1 -1
  34. package/dist/models/utility.types.d.ts +16 -0
  35. package/dist/models/utility.types.js +2 -0
  36. package/dist/models/utility.types.js.map +1 -0
  37. package/dist/public_api.d.ts +22 -11
  38. package/dist/public_api.js +18 -6
  39. package/dist/public_api.js.map +1 -1
  40. package/dist/sdk/queries/fetch-sdk-query.d.ts +4 -0
  41. package/dist/sdk/queries/fetch-sdk-query.js +17 -0
  42. package/dist/sdk/queries/fetch-sdk-query.js.map +1 -0
  43. package/dist/sdk/queries/mutation-sdk-query.d.ts +5 -0
  44. package/dist/sdk/queries/mutation-sdk-query.js +16 -0
  45. package/dist/sdk/queries/mutation-sdk-query.js.map +1 -0
  46. package/dist/sdk/queries/paged-fetch-sdk-query.d.ts +8 -0
  47. package/dist/sdk/queries/paged-fetch-sdk-query.js +101 -0
  48. package/dist/sdk/queries/paged-fetch-sdk-query.js.map +1 -0
  49. package/dist/sdk/resolve-query.d.ts +12 -0
  50. package/dist/sdk/resolve-query.js +172 -0
  51. package/dist/sdk/resolve-query.js.map +1 -0
  52. package/dist/sdk/sdk-config.d.ts +24 -0
  53. package/dist/sdk/sdk-config.js +31 -0
  54. package/dist/sdk/sdk-config.js.map +1 -0
  55. package/dist/sdk/sdk-models.d.ts +118 -40
  56. package/dist/sdk/sdk-utils.d.ts +16 -0
  57. package/dist/sdk/sdk-utils.js +36 -0
  58. package/dist/sdk/sdk-utils.js.map +1 -0
  59. package/dist/sdk/transform/transform-fetch-query.d.ts +11 -0
  60. package/dist/sdk/transform/transform-fetch-query.js +15 -0
  61. package/dist/sdk/transform/transform-fetch-query.js.map +1 -0
  62. package/dist/sdk/transform/transform-mutation-query.d.ts +11 -0
  63. package/dist/sdk/transform/transform-mutation-query.js +15 -0
  64. package/dist/sdk/transform/transform-mutation-query.js.map +1 -0
  65. package/dist/sdk/transform/transform-paged-fetch-query.d.ts +11 -0
  66. package/dist/sdk/transform/transform-paged-fetch-query.js +75 -0
  67. package/dist/sdk/transform/transform-paged-fetch-query.js.map +1 -0
  68. package/dist/sdk/transform/transform-utils.d.ts +23 -0
  69. package/dist/sdk/transform/transform-utils.js +86 -0
  70. package/dist/sdk/transform/transform-utils.js.map +1 -0
  71. package/dist/testkit/poll.utils.d.ts +5 -0
  72. package/dist/testkit/poll.utils.js +15 -0
  73. package/dist/testkit/poll.utils.js.map +1 -0
  74. package/dist/testkit/testkit.models.d.ts +2 -2
  75. package/dist/testkit/testkit.utils.d.ts +27 -0
  76. package/dist/testkit/testkit.utils.js +113 -0
  77. package/dist/testkit/testkit.utils.js.map +1 -0
  78. package/dist/testkit_api.d.ts +3 -1
  79. package/dist/testkit_api.js +3 -2
  80. package/dist/testkit_api.js.map +1 -1
  81. package/dist/utils/abort.utils.d.ts +12 -0
  82. package/dist/utils/abort.utils.js +30 -0
  83. package/dist/utils/abort.utils.js.map +1 -0
  84. package/dist/utils/array.utils.d.ts +1 -0
  85. package/dist/utils/array.utils.js +4 -0
  86. package/dist/utils/array.utils.js.map +1 -0
  87. package/dist/utils/core.utils.d.ts +3 -1
  88. package/dist/utils/core.utils.js +18 -2
  89. package/dist/utils/core.utils.js.map +1 -1
  90. package/dist/utils/error.utils.d.ts +24 -8
  91. package/dist/utils/error.utils.js +47 -9
  92. package/dist/utils/error.utils.js.map +1 -1
  93. package/dist/utils/header.utils.d.ts +7 -2
  94. package/dist/utils/header.utils.js +43 -11
  95. package/dist/utils/header.utils.js.map +1 -1
  96. package/dist/utils/retry.utils.d.ts +17 -12
  97. package/dist/utils/retry.utils.js +125 -80
  98. package/dist/utils/retry.utils.js.map +1 -1
  99. package/dist/utils/schema.utils.d.ts +3 -0
  100. package/dist/utils/schema.utils.js +10 -0
  101. package/dist/utils/schema.utils.js.map +1 -0
  102. package/dist/utils/try-catch.utils.d.ts +15 -0
  103. package/dist/utils/{try.utils.js → try-catch.utils.js} +1 -1
  104. package/dist/utils/try-catch.utils.js.map +1 -0
  105. package/dist/utils/url.utils.d.ts +6 -0
  106. package/dist/utils/url.utils.js +10 -0
  107. package/dist/utils/url.utils.js.map +1 -0
  108. package/package.json +64 -64
  109. package/dist/models/utility.models.d.ts +0 -20
  110. package/dist/models/utility.models.js +0 -2
  111. package/dist/models/utility.models.js.map +0 -1
  112. package/dist/sdk/sdk-queries.d.ts +0 -30
  113. package/dist/sdk/sdk-queries.js +0 -152
  114. package/dist/sdk/sdk-queries.js.map +0 -1
  115. package/dist/sdk-info.d.ts +0 -5
  116. package/dist/sdk-info.js +0 -6
  117. package/dist/sdk-info.js.map +0 -1
  118. package/dist/testkit/test.utils.d.ts +0 -15
  119. package/dist/testkit/test.utils.js +0 -42
  120. package/dist/testkit/test.utils.js.map +0 -1
  121. package/dist/utils/sdk-version.utils.js.map +0 -1
  122. package/dist/utils/try.utils.d.ts +0 -14
  123. package/dist/utils/try.utils.js.map +0 -1
  124. package/lib/devkit/script.utils.ts +0 -12
  125. package/lib/devkit_api.ts +0 -3
  126. package/lib/http/http.adapter.ts +0 -38
  127. package/lib/http/http.models.ts +0 -122
  128. package/lib/http/http.service.ts +0 -320
  129. package/lib/models/core.models.ts +0 -89
  130. package/lib/models/error.models.ts +0 -83
  131. package/lib/models/json.models.ts +0 -9
  132. package/lib/models/utility.models.ts +0 -21
  133. package/lib/public_api.ts +0 -46
  134. package/lib/sdk/sdk-models.ts +0 -86
  135. package/lib/sdk/sdk-queries.ts +0 -232
  136. package/lib/sdk-info.ts +0 -5
  137. package/lib/testkit/test.utils.ts +0 -79
  138. package/lib/testkit/testkit.models.ts +0 -7
  139. package/lib/testkit_api.ts +0 -3
  140. package/lib/utils/core.utils.ts +0 -3
  141. package/lib/utils/error.utils.ts +0 -48
  142. package/lib/utils/header.utils.ts +0 -40
  143. package/lib/utils/retry.utils.ts +0 -156
  144. package/lib/utils/sdk-version.utils.ts +0 -16
  145. package/lib/utils/try.utils.ts +0 -30
  146. /package/dist/{utils → devkit}/sdk-version.utils.d.ts +0 -0
package/.npmignore CHANGED
@@ -1,10 +1,6 @@
1
1
  # Ignore everything
2
2
  *
3
-
4
- # But descend into directories
5
-
6
- # Recursively allow files under subtree
7
- !/lib/**
3
+ # And allow following
8
4
  !/dist/**
9
5
  !package.json
10
6
  !.npmignore
package/LICENSE.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # MIT License
2
2
 
3
- Copyright (c) 2025 Kontent s.r.o.
3
+ Copyright (c) 2026 Kontent s.r.o.
4
4
 
5
5
  Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
6
6
 
package/README.md CHANGED
@@ -12,6 +12,22 @@ The **Core SDK** provides foundational functionality leveraged by dependent Kont
12
12
 
13
13
  ---
14
14
 
15
+ ## Requirements
16
+
17
+ Before using this package, make sure your environment matches the published package requirements:
18
+
19
+ - Node.js `>=22`
20
+ - ESM-compatible runtime, because the package is published as an ES module
21
+ - Peer dependencies: `zod` and `ts-pattern`
22
+
23
+ With modern package managers such as npm, peer dependencies are typically installed automatically, so you usually only need:
24
+
25
+ ```bash
26
+ npm install @kontent-ai/core-sdk
27
+ ```
28
+
29
+ ---
30
+
15
31
  ## HTTP Request Infrastructure
16
32
 
17
33
  The SDK includes a default implementation of the `HttpService` and `HttpAdapter` components, which handle HTTP requests to the Kontent.ai APIs.
@@ -25,32 +41,42 @@ These implementations are designed to work out-of-the-box but are also fully cus
25
41
  The `HttpService` comes with several built-in capabilities, such as:
26
42
 
27
43
  - **Retry policies**
28
- - **Request validation**
44
+ - **Request parsing and validation** (URL parsing, body serialization)
29
45
  - **Automatic header and tracking management**
30
46
  - **Kontent.ai-specific error extraction**
31
47
 
32
48
  To customize these behaviors entirely, you can replace the `HttpService` with your own implementation.
33
49
 
34
- However, if your goal is to retain the core features (e.g., retry policies, request validation) and only swap out the underlying HTTP client, you can do so by supplying a custom `HttpAdapter` to the `getDefaultHttpService` method.
50
+ However, if your goal is to retain the core features (e.g., retry policies, request parsing) and only swap out the underlying HTTP client, you can do so by supplying a custom `HttpAdapter` to the `getDefaultHttpService` method.
35
51
 
36
52
  ---
37
53
 
38
54
  ## Example: Custom `HttpAdapter` Implementation
39
55
 
40
- Below is an example demonstrating how to provide your own HTTP client by implementing a custom `HttpAdapter`:
56
+ Below is an example demonstrating how to provide your own HTTP client by implementing a custom `HttpAdapter`. Both `executeRequest` and `downloadFile` are optional, so you only need to implement the methods you want to override.
57
+
58
+ If you want the SDK to preserve specific `error.details.reason` values for custom adapters, throw:
59
+
60
+ - `AdapterAbortError` when the request is aborted
61
+ - `AdapterParseError` when the response cannot be parsed as JSON or `Blob`
62
+
63
+ If you throw some other error, the SDK will classify it as `adapterError`.
41
64
 
42
65
  ```typescript
43
- const httpService = await getDefaultHttpService({
66
+ import { getDefaultHttpService } from "@kontent-ai/core-sdk";
67
+
68
+ const httpService = getDefaultHttpService({
44
69
  adapter: {
45
- requestAsync: async (options) => {
46
- // Execute the request using your custom HTTP client
70
+ executeRequest: async ({ url, method, body, requestHeaders, abortSignal }) => {
71
+ // use any HTTP client here
72
+ const { payload, responseHeaders, status, statusText } = await yourHttpClient.request(...);
73
+
47
74
  return {
48
- isValidResponse: <true | false>,
49
- responseHeaders: <arrayOfHeaders>,
50
- status: <statusCode>,
51
- statusText: <statusText>,
52
- toJsonAsync: async () => <responseInJson>,
53
- toBlobAsync: async () => <responseInBlob>,
75
+ payload,
76
+ responseHeaders,
77
+ status,
78
+ statusText,
79
+ url,
54
80
  };
55
81
  },
56
82
  },
@@ -58,3 +84,82 @@ const httpService = await getDefaultHttpService({
58
84
  ```
59
85
 
60
86
  This approach gives you fine-grained control over how requests are made, while still benefiting from the core service's additional functionalities.
87
+
88
+ ---
89
+
90
+ ## Error Handling
91
+
92
+ Each query exposes two variants: a safe variant (e.g. `fetchSafe`, `executeSafe`) that returns a discriminated `success`/`error` result and never throws, and an unsafe variant (e.g. `fetch`, `execute`) that unwraps the response directly but throws on failure. Errors are represented by `KontentSdkError`, which carries a `details` object with a `reason` discriminant that can be narrowed for type-safe handling:
93
+
94
+ ```typescript
95
+ const { success, response, error } = await httpService.request({
96
+ url: "https://manage.kontent.ai/v2/projects/...",
97
+ method: "GET"
98
+ });
99
+
100
+ if (!success) {
101
+ switch (error.details.reason) {
102
+ case "unauthorized":
103
+ // error.details includes: status, statusText, responseHeaders, kontentErrorResponse
104
+ console.error("Check your API key:", error.details.kontentErrorResponse?.message);
105
+ break;
106
+ case "notFound":
107
+ console.error("Resource not found:", error.url);
108
+ break;
109
+ case "invalidResponse":
110
+ // Any non-2xx response that isn't 401 or 404
111
+ console.error(`HTTP ${error.details.status}:`, error.details.kontentErrorResponse?.message);
112
+ break;
113
+ case "parseError":
114
+ // The response claimed to be JSON, but parsing it failed
115
+ console.error("Failed to parse response:", error.details.originalError);
116
+ break;
117
+ case "adapterError":
118
+ // Network failure, timeout, or other transport-level issue
119
+ console.error("Request failed:", error.details.originalError);
120
+ break;
121
+ case "invalidUrl":
122
+ // The provided URL could not be parsed before the request was sent
123
+ console.error("Invalid URL:", error.details.originalError);
124
+ break;
125
+ case "invalidBody":
126
+ // The request body could not be serialized before the request was sent
127
+ console.error("Invalid body:", error.details.originalError);
128
+ break;
129
+ case "parsingFailed":
130
+ // Zod schema parsing fails
131
+ console.error("Unexpected response shape for", error.details.url, error.details.zodError);
132
+ break;
133
+ case "aborted":
134
+ // The request was cancelled before it could complete
135
+ console.error("Request was aborted:", error.details.originalError);
136
+ break;
137
+ }
138
+ return;
139
+ }
140
+
141
+ // response is fully typed here
142
+ console.log(response.payload);
143
+ ```
144
+
145
+ ---
146
+
147
+ ## Retry Strategy
148
+
149
+ The default `HttpService` includes configurable retry logic. HTTP 429 (rate limit) responses are always retried automatically with a delay based on the `Retry-After` header. All other HTTP error responses are not retried.
150
+
151
+ For transport-level failures (network errors, timeouts), you can control retry behavior via `canRetryAdapterError`:
152
+
153
+ ```typescript
154
+ const httpService = getDefaultHttpService({
155
+ retryStrategy: {
156
+ maxRetries: 3,
157
+ canRetryAdapterError: (error) => {
158
+ // `error` is typed as KontentSdkError<ErrorDetailsFor<"adapterError">>
159
+ // Return true to retry, false to stop
160
+ return true;
161
+ },
162
+ logRetryAttempt: "logToConsole",
163
+ },
164
+ });
165
+ ```
@@ -0,0 +1,2 @@
1
+ import type { SdkInfo } from "./models/core.models.js";
2
+ export declare const coreSdkInfo: SdkInfo;
@@ -0,0 +1,6 @@
1
+ export const coreSdkInfo = {
2
+ host: "npmjs.com",
3
+ version: "12.0.0-preview.40",
4
+ name: "@kontent-ai/core-sdk",
5
+ };
6
+ //# sourceMappingURL=core-sdk-info.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"core-sdk-info.js","sourceRoot":"","sources":["../lib/core-sdk-info.ts"],"names":[],"mappings":"AAEA,MAAM,CAAC,MAAM,WAAW,GAAY;IACnC,IAAI,EAAE,WAAW;IACjB,OAAO,EAAE,aAAa;IACtB,IAAI,EAAE,sBAAsB;CAC5B,CAAC"}
@@ -0,0 +1,2 @@
1
+ export type ConsoleColor = "red" | "green" | "yellow" | "blue" | "cyan" | "magenta" | "white" | "gray";
2
+ export declare function colorize(color: ConsoleColor, text: string): string;
@@ -0,0 +1,5 @@
1
+ import { styleText } from "node:util";
2
+ export function colorize(color, text) {
3
+ return styleText(color, text);
4
+ }
5
+ //# sourceMappingURL=console.utils.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"console.utils.js","sourceRoot":"","sources":["../../lib/devkit/console.utils.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,WAAW,CAAC;AAItC,MAAM,UAAU,QAAQ,CAAC,KAAmB,EAAE,IAAY;IACzD,OAAO,SAAS,CAAC,KAAK,EAAE,IAAI,CAAC,CAAC;AAC/B,CAAC"}
@@ -0,0 +1,2 @@
1
+ export declare function getEnvironmentRequiredValue(variableName: string): string;
2
+ export declare function getEnvironmentOptionalValue(variableName: string): string | undefined;
@@ -0,0 +1,12 @@
1
+ import { colorize } from "./console.utils.js";
2
+ export function getEnvironmentRequiredValue(variableName) {
3
+ const value = getEnvironmentOptionalValue(variableName);
4
+ if (!value || value.trim() === "") {
5
+ throw new Error(`Missing environment variable '${colorize("red", variableName)}'`);
6
+ }
7
+ return value;
8
+ }
9
+ export function getEnvironmentOptionalValue(variableName) {
10
+ return process.env[variableName];
11
+ }
12
+ //# sourceMappingURL=environment.utils.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"environment.utils.js","sourceRoot":"","sources":["../../lib/devkit/environment.utils.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,oBAAoB,CAAC;AAE9C,MAAM,UAAU,2BAA2B,CAAC,YAAoB;IAC/D,MAAM,KAAK,GAAG,2BAA2B,CAAC,YAAY,CAAC,CAAC;IAExD,IAAI,CAAC,KAAK,IAAI,KAAK,CAAC,IAAI,EAAE,KAAK,EAAE,EAAE,CAAC;QACnC,MAAM,IAAI,KAAK,CAAC,iCAAiC,QAAQ,CAAC,KAAK,EAAE,YAAY,CAAC,GAAG,CAAC,CAAC;IACpF,CAAC;IAED,OAAO,KAAK,CAAC;AACd,CAAC;AAED,MAAM,UAAU,2BAA2B,CAAC,YAAoB;IAC/D,OAAO,OAAO,CAAC,GAAG,CAAC,YAAY,CAAC,CAAC;AAClC,CAAC"}
@@ -1,11 +1,11 @@
1
1
  import { rmSync } from "node:fs";
2
- import chalk from "chalk";
2
+ import { colorize } from "./console.utils.js";
3
3
  export function deleteFolderRecursive(path) {
4
- console.log(`Deleting existing folder '${chalk.yellow(path)}'`);
4
+ console.log(`Deleting existing folder '${colorize("yellow", path)}'`);
5
5
  rmSync(path, {
6
6
  recursive: true,
7
7
  force: true,
8
8
  });
9
- console.log(`Folder '${chalk.yellow(path)}' deleted successfully`);
9
+ console.log(`Folder '${colorize("yellow", path)}' deleted successfully`);
10
10
  }
11
11
  //# sourceMappingURL=script.utils.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"script.utils.js","sourceRoot":"","sources":["../../lib/devkit/script.utils.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,SAAS,CAAC;AACjC,OAAO,KAAK,MAAM,OAAO,CAAC;AAE1B,MAAM,UAAU,qBAAqB,CAAC,IAAY;IACjD,OAAO,CAAC,GAAG,CAAC,6BAA6B,KAAK,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;IAChE,MAAM,CAAC,IAAI,EAAE;QACZ,SAAS,EAAE,IAAI;QACf,KAAK,EAAE,IAAI;KACX,CAAC,CAAC;IAEH,OAAO,CAAC,GAAG,CAAC,WAAW,KAAK,CAAC,MAAM,CAAC,IAAI,CAAC,wBAAwB,CAAC,CAAC;AACpE,CAAC"}
1
+ {"version":3,"file":"script.utils.js","sourceRoot":"","sources":["../../lib/devkit/script.utils.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,SAAS,CAAC;AACjC,OAAO,EAAE,QAAQ,EAAE,MAAM,oBAAoB,CAAC;AAE9C,MAAM,UAAU,qBAAqB,CAAC,IAAY;IACjD,OAAO,CAAC,GAAG,CAAC,6BAA6B,QAAQ,CAAC,QAAQ,EAAE,IAAI,CAAC,GAAG,CAAC,CAAC;IACtE,MAAM,CAAC,IAAI,EAAE;QACZ,SAAS,EAAE,IAAI;QACf,KAAK,EAAE,IAAI;KACX,CAAC,CAAC;IAEH,OAAO,CAAC,GAAG,CAAC,WAAW,QAAQ,CAAC,QAAQ,EAAE,IAAI,CAAC,wBAAwB,CAAC,CAAC;AAC1E,CAAC"}
@@ -1,5 +1,5 @@
1
1
  import { readFileSync, writeFileSync } from "node:fs";
2
- import chalk from "chalk";
2
+ import { colorize } from "./console.utils.js";
3
3
  const sdkVersionPlaceholderMacro = "{{version}}";
4
4
  export function replaceSdkVersionPlaceholder(filePath, version) {
5
5
  const fileContent = readFileSync(filePath, "utf8");
@@ -7,6 +7,6 @@ export function replaceSdkVersionPlaceholder(filePath, version) {
7
7
  throw new Error(`File '${filePath}' does not contain macro '${sdkVersionPlaceholderMacro}'`);
8
8
  }
9
9
  writeFileSync(filePath, fileContent.replace(sdkVersionPlaceholderMacro, version));
10
- console.log(`Updated SDK version in '${chalk.yellow(filePath)}' to '${chalk.green(version)}'`);
10
+ console.log(`Updated SDK version in '${colorize("yellow", filePath)}' to '${colorize("green", version)}'`);
11
11
  }
12
12
  //# sourceMappingURL=sdk-version.utils.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"sdk-version.utils.js","sourceRoot":"","sources":["../../lib/devkit/sdk-version.utils.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AACtD,OAAO,EAAE,QAAQ,EAAE,MAAM,oBAAoB,CAAC;AAE9C,MAAM,0BAA0B,GAAG,aAAa,CAAC;AAEjD,MAAM,UAAU,4BAA4B,CAAC,QAAgB,EAAE,OAAe;IAC7E,MAAM,WAAW,GAAG,YAAY,CAAC,QAAQ,EAAE,MAAM,CAAC,CAAC;IAEnD,IAAI,CAAC,WAAW,CAAC,QAAQ,CAAC,0BAA0B,CAAC,EAAE,CAAC;QACvD,MAAM,IAAI,KAAK,CAAC,SAAS,QAAQ,6BAA6B,0BAA0B,GAAG,CAAC,CAAC;IAC9F,CAAC;IAED,aAAa,CAAC,QAAQ,EAAE,WAAW,CAAC,OAAO,CAAC,0BAA0B,EAAE,OAAO,CAAC,CAAC,CAAC;IAElF,OAAO,CAAC,GAAG,CAAC,2BAA2B,QAAQ,CAAC,QAAQ,EAAE,QAAQ,CAAC,SAAS,QAAQ,CAAC,OAAO,EAAE,OAAO,CAAC,GAAG,CAAC,CAAC;AAC5G,CAAC"}
@@ -1,2 +1,5 @@
1
+ /** biome-ignore-all lint/performance/noBarrelFile: One barrel for exported API is fine */
2
+ export { type ConsoleColor, colorize } from "./devkit/console.utils.js";
3
+ export { getEnvironmentOptionalValue, getEnvironmentRequiredValue } from "./devkit/environment.utils.js";
1
4
  export { deleteFolderRecursive } from "./devkit/script.utils.js";
2
- export { replaceSdkVersionPlaceholder } from "./utils/sdk-version.utils.js";
5
+ export { replaceSdkVersionPlaceholder } from "./devkit/sdk-version.utils.js";
@@ -1,4 +1,6 @@
1
- // biome-ignore lint/performance/noBarrelFile: One barrel for the Devkit API is fine
1
+ /** biome-ignore-all lint/performance/noBarrelFile: One barrel for exported API is fine */
2
+ export { colorize } from "./devkit/console.utils.js";
3
+ export { getEnvironmentOptionalValue, getEnvironmentRequiredValue } from "./devkit/environment.utils.js";
2
4
  export { deleteFolderRecursive } from "./devkit/script.utils.js";
3
- export { replaceSdkVersionPlaceholder } from "./utils/sdk-version.utils.js";
5
+ export { replaceSdkVersionPlaceholder } from "./devkit/sdk-version.utils.js";
4
6
  //# sourceMappingURL=devkit_api.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"devkit_api.js","sourceRoot":"","sources":["../lib/devkit_api.ts"],"names":[],"mappings":"AAAA,oFAAoF;AACpF,OAAO,EAAE,qBAAqB,EAAE,MAAM,0BAA0B,CAAC;AACjE,OAAO,EAAE,4BAA4B,EAAE,MAAM,8BAA8B,CAAC"}
1
+ {"version":3,"file":"devkit_api.js","sourceRoot":"","sources":["../lib/devkit_api.ts"],"names":[],"mappings":"AAAA,0FAA0F;AAE1F,OAAO,EAAqB,QAAQ,EAAE,MAAM,2BAA2B,CAAC;AACxE,OAAO,EAAE,2BAA2B,EAAE,2BAA2B,EAAE,MAAM,+BAA+B,CAAC;AACzG,OAAO,EAAE,qBAAqB,EAAE,MAAM,0BAA0B,CAAC;AACjE,OAAO,EAAE,4BAA4B,EAAE,MAAM,+BAA+B,CAAC"}
@@ -1,2 +1,2 @@
1
1
  import type { HttpAdapter } from "./http.models.js";
2
- export declare function getDefaultHttpAdapter(): HttpAdapter;
2
+ export declare function getDefaultHttpAdapter(): Required<HttpAdapter>;
@@ -1,31 +1,81 @@
1
- import { toFetchHeaders, toSdkHeaders } from "../utils/header.utils.js";
1
+ import { AdapterAbortError, AdapterParseError } from "../models/error.models.js";
2
+ import { runWithAbortSignal } from "../utils/abort.utils.js";
3
+ import { isFetchAbortError } from "../utils/error.utils.js";
4
+ import { isApplicationJsonResponseType, toFetchHeaders, toSdkHeaders } from "../utils/header.utils.js";
5
+ import { tryCatchAsync } from "../utils/try-catch.utils.js";
2
6
  export function getDefaultHttpAdapter() {
3
7
  return {
4
- requestAsync: async (options) => {
5
- const response = await fetch(options.url, {
6
- method: options.method,
7
- headers: toFetchHeaders(options.requestHeaders ?? []),
8
- body: options.body,
8
+ executeRequest: async (options) => {
9
+ const response = await getResponse(options);
10
+ const sdkHeaders = toSdkHeaders(response.headers);
11
+ const payload = isApplicationJsonResponseType(sdkHeaders)
12
+ ? await parseResponse({
13
+ parseFunc: async () => (await response.json()),
14
+ abortSignal: options.abortSignal,
15
+ })
16
+ : null;
17
+ return createAdapterResponse({ url: options.url, response, payload, responseHeaders: sdkHeaders });
18
+ },
19
+ downloadFile: async (options) => {
20
+ const response = await getResponse({
21
+ ...options,
22
+ method: "GET",
23
+ body: null,
9
24
  });
10
- const sdkResponseHeaders = toSdkHeaders(response.headers);
11
- return {
12
- isValidResponse: response.ok,
13
- responseHeaders: sdkResponseHeaders,
14
- status: response.status,
15
- statusText: response.statusText,
16
- toBlobAsync: async () => await response.blob(),
17
- toJsonAsync: async () => {
18
- const contentTypeResponseHeader = sdkResponseHeaders
19
- .find((m) => m.name.toLowerCase() === "Content-Type".toLowerCase())
20
- ?.value.toLowerCase();
21
- if (contentTypeResponseHeader?.includes("application/json")) {
22
- // Includes instead of equal due to the fact that the header value can be 'application/json; charset=utf-8' or similar
23
- return (await response.json());
24
- }
25
- return null;
26
- },
27
- };
25
+ const file = await parseResponse({ parseFunc: async () => await response.blob(), abortSignal: options.abortSignal });
26
+ return createAdapterResponse({ url: options.url, response, payload: file, responseHeaders: toSdkHeaders(response.headers) });
28
27
  },
29
28
  };
30
29
  }
30
+ async function getResponse(options) {
31
+ const { error, data, success } = await tryCatchAsync(async () => await fetch(options.url, {
32
+ method: options.method,
33
+ headers: toFetchHeaders(options.requestHeaders ?? []),
34
+ body: options.body ?? null,
35
+ signal: options.abortSignal ?? null,
36
+ }));
37
+ if (success) {
38
+ return data;
39
+ }
40
+ if (isFetchAbortError(error)) {
41
+ // this is to notify the HttpService that the request was aborted
42
+ // HttpService will then convert the error to a KontentSdkError with the reason "aborted"
43
+ throw new AdapterAbortError({ message: "Request was aborted.", error });
44
+ }
45
+ // re-throw original error
46
+ throw error;
47
+ }
48
+ async function parseResponse({ parseFunc, abortSignal, }) {
49
+ const runParseFunc = async () => {
50
+ const { success, data, error } = await tryCatchAsync(async () => {
51
+ return await parseFunc();
52
+ });
53
+ if (!success) {
54
+ // this is to notify the HttpService that the response is not valid JSON or BLOB
55
+ // HttpService will then convert the error to a KontentSdkError with the reason "parseError"
56
+ throw new AdapterParseError({ message: "Failed to parse the response.", error });
57
+ }
58
+ return data;
59
+ };
60
+ if (!abortSignal) {
61
+ return await runParseFunc();
62
+ }
63
+ const { isAborted, data } = await runWithAbortSignal({
64
+ func: runParseFunc,
65
+ abortSignal: abortSignal,
66
+ });
67
+ if (isAborted) {
68
+ throw new AdapterAbortError({ message: "Request was aborted while parsing the response." });
69
+ }
70
+ return data;
71
+ }
72
+ function createAdapterResponse({ url, response, payload, responseHeaders, }) {
73
+ return {
74
+ responseHeaders,
75
+ status: response.status,
76
+ statusText: response.statusText,
77
+ url: url,
78
+ payload,
79
+ };
80
+ }
31
81
  //# sourceMappingURL=http.adapter.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"http.adapter.js","sourceRoot":"","sources":["../../lib/http/http.adapter.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,cAAc,EAAE,YAAY,EAAE,MAAM,0BAA0B,CAAC;AAGxE,MAAM,UAAU,qBAAqB;IACpC,OAAO;QACN,YAAY,EAAE,KAAK,EAAE,OAAO,EAAE,EAAE;YAC/B,MAAM,QAAQ,GAAG,MAAM,KAAK,CAAC,OAAO,CAAC,GAAG,EAAE;gBACzC,MAAM,EAAE,OAAO,CAAC,MAAM;gBACtB,OAAO,EAAE,cAAc,CAAC,OAAO,CAAC,cAAc,IAAI,EAAE,CAAC;gBACrD,IAAI,EAAE,OAAO,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E,YAAY;QAClB,WAAW,EAAE,WAAW;KACxB,CAAC,CAAC;IAEH,IAAI,SAAS,EAAE,CAAC;QACf,MAAM,IAAI,iBAAiB,CAAC,EAAE,OAAO,EAAE,iDAAiD,EAAE,CAAC,CAAC;IAC7F,CAAC;IAED,OAAO,IAAI,CAAC;AACb,CAAC;AAED,SAAS,qBAAqB,CAAkC,EAC/D,GAAG,EACH,QAAQ,EACR,OAAO,EACP,eAAe,GAMf;IACA,OAAO;QACN,eAAe;QACf,MAAM,EAAE,QAAQ,CAAC,MAAM;QACvB,UAAU,EAAE,QAAQ,CAAC,UAAU;QAC/B,GAAG,EAAE,GAAG;QACR,OAAO;KACP,CAAC;AACH,CAAC"}
@@ -1,23 +1,20 @@
1
- import type { Header, HttpMethod, LiteralUnionNumber, RetryStrategyOptions } from "../models/core.models.js";
2
- import type { CoreSdkError } from "../models/error.models.js";
3
- import type { JsonValue } from "../models/json.models.js";
4
- type Success<TData> = {
5
- readonly success: true;
6
- readonly response: TData;
7
- readonly error?: never;
8
- };
9
- type Failure = {
10
- readonly success: false;
1
+ import type { Header, HttpMethod, RetryStrategyOptions } from "../models/core.models.js";
2
+ import type { KontentSdkError } from "../models/error.models.js";
3
+ import type { JsonObject, JsonValue } from "../models/json.models.js";
4
+ import type { LiteralUnionNumber } from "../models/utility.types.js";
5
+ import type { QueryResponse } from "../sdk/sdk-models.js";
6
+ import type { Failure, Success } from "../utils/try-catch.utils.js";
7
+ export type HttpResult<TResponse> = Success<{
8
+ readonly response: TResponse;
9
+ }> | Failure<{
11
10
  readonly response?: never;
12
- readonly error: CoreSdkError;
13
- };
14
- export type HttpResult<TData> = Success<TData> | Failure;
11
+ }, KontentSdkError>;
15
12
  /**
16
13
  * Helper status codes for the HTTP service.
17
14
  * It can be any valid number status code as this type only serves as a helper.
18
15
  */
19
- export type HttpServiceStatus = LiteralUnionNumber<200 | 201 | 204 | 500 | 429 | 404 | 403 | 401 | 400>;
20
- export type DefaultHttpServiceConfig = {
16
+ export type HttpStatusCode = LiteralUnionNumber<200 | 201 | 204 | 500 | 429 | 404 | 403 | 401 | 400>;
17
+ export type DefaultHttpServiceOptions = {
21
18
  /**
22
19
  * The retry strategy to be used. If not provided, the default retry strategy will be used.
23
20
  */
@@ -31,23 +28,25 @@ export type DefaultHttpServiceConfig = {
31
28
  */
32
29
  readonly adapter?: HttpAdapter;
33
30
  };
34
- export type HttpResponse<TResponseData extends JsonValue | Blob, TBodyData extends JsonValue | Blob> = HttpResult<{
35
- readonly data: TResponseData;
36
- readonly body: TBodyData;
31
+ export type HttpRequestBody = JsonObject | Blob | null;
32
+ export type HttpResponse<TPayload extends AdapterPayload, TBody extends HttpRequestBody> = HttpResult<{
33
+ readonly payload: TPayload;
34
+ readonly body?: TBody;
37
35
  readonly method: HttpMethod;
38
36
  readonly requestHeaders: readonly Header[];
39
- readonly adapterResponse: Omit<AdapterResponse, "toJsonAsync" | "toBlobAsync">;
37
+ readonly adapterResponse: AdapterResponse<TPayload>;
40
38
  }>;
41
- export type ExecuteRequestOptions<TBodyData extends JsonValue | Blob> = {
42
- readonly url: string;
39
+ export type HttpServiceRequestOptions<TBody extends HttpRequestBody> = {
40
+ readonly url: string | URL;
43
41
  readonly method: HttpMethod;
44
- readonly body: TBodyData;
42
+ readonly body?: TBody;
45
43
  readonly requestHeaders?: readonly Header[];
44
+ readonly abortSignal?: AbortSignal | undefined;
46
45
  };
47
- export type UploadFileRequestOptions = Omit<ExecuteRequestOptions<Blob>, "method"> & {
46
+ export type UploadFileRequestOptions = Omit<HttpServiceRequestOptions<Blob>, "method"> & {
48
47
  readonly method: Extract<HttpMethod, "POST" | "PUT" | "PATCH">;
49
48
  };
50
- export type DownloadFileRequestOptions = Pick<ExecuteRequestOptions<Blob>, "url" | "requestHeaders">;
49
+ export type DownloadFileRequestOptions = Pick<HttpServiceRequestOptions<null>, "url" | "requestHeaders" | "abortSignal">;
51
50
  /**
52
51
  * Represents the HTTP service used for making requests to the Kontent.ai API.
53
52
  *
@@ -62,29 +61,42 @@ export type HttpService = {
62
61
  /**
63
62
  * Executes request with the given method and body.
64
63
  */
65
- requestAsync<TResponseData extends JsonValue, TBodyData extends JsonValue>(opts: ExecuteRequestOptions<TBodyData>): Promise<HttpResponse<TResponseData, TBodyData>>;
64
+ request<TPayload extends JsonValue, TBody extends HttpRequestBody>(opts: HttpServiceRequestOptions<TBody>): Promise<HttpResponse<TPayload, TBody>>;
66
65
  /**
67
66
  * Downloads a file from the given URL as a blob.
68
67
  */
69
- downloadFileAsync(opts: DownloadFileRequestOptions): Promise<HttpResponse<Blob, null>>;
68
+ downloadFile(opts: DownloadFileRequestOptions): Promise<HttpResponse<Blob, null>>;
70
69
  /**
71
70
  * This method is used to upload a kontent.ai binary file.
72
71
  */
73
- uploadFileAsync<TResponseData extends JsonValue>(opts: UploadFileRequestOptions): Promise<HttpResponse<TResponseData, Blob>>;
72
+ uploadFile<TPayload extends JsonValue>(opts: UploadFileRequestOptions): Promise<HttpResponse<TPayload, Blob>>;
74
73
  };
75
- export type AdapterResponse<TStatusCode extends HttpServiceStatus = HttpServiceStatus> = {
76
- readonly toJsonAsync: () => Promise<JsonValue>;
77
- readonly toBlobAsync: () => Promise<Blob>;
78
- readonly isValidResponse: boolean;
74
+ export type AdapterResponse<TPayload extends AdapterPayload> = {
75
+ readonly payload: TPayload;
79
76
  readonly responseHeaders: readonly Header[];
80
- readonly status: TStatusCode;
77
+ readonly status: HttpStatusCode;
81
78
  readonly statusText: string;
79
+ readonly url: URL;
82
80
  };
81
+ export type AdapterRequestBody = string | Blob | null;
82
+ export type AdapterPayload = JsonValue | Blob;
83
83
  export type AdapterRequestOptions = {
84
- readonly url: string;
84
+ readonly url: URL;
85
85
  readonly method: HttpMethod;
86
- readonly body: string | Blob | undefined | null;
86
+ readonly body: AdapterRequestBody;
87
87
  readonly requestHeaders?: readonly Header[];
88
+ readonly abortSignal?: AbortSignal | undefined;
89
+ };
90
+ export type AdapterDownloadOptions = Pick<AdapterRequestOptions, "url" | "requestHeaders" | "abortSignal">;
91
+ export type GetNextPageData<TPayload extends JsonValue, TMeta = unknown, TExtra = unknown> = (response: QueryResponse<TPayload, TMeta, TExtra>) => {
92
+ readonly continuationToken?: string | undefined;
93
+ readonly nextPageUrl?: string | undefined;
94
+ };
95
+ export type PagingConfig = {
96
+ /**
97
+ * The maximum number of pages to fetch. If not provided or set to 0, the pagination will continue until the last page is reached.
98
+ */
99
+ readonly maxPagesCount?: number;
88
100
  };
89
101
  /**
90
102
  * Defines the adapter responsible solely for executing HTTP requests.
@@ -95,9 +107,9 @@ export type AdapterRequestOptions = {
95
107
  * To extend functionality, you can implement a custom adapter and pass it to the `getDefaultHttpService` function,
96
108
  * which handles additional concerns like retries and parsing.
97
109
  *
98
- * Alternatively, you may implement the entire `HttpService` interface to create a fully customized HTTP service.
110
+ * Alternatively, you may implement the entire `HttpService` to create a fully customized HTTP service.
99
111
  */
100
112
  export type HttpAdapter = {
101
- readonly requestAsync: (options: AdapterRequestOptions) => Promise<AdapterResponse>;
113
+ readonly executeRequest?: (options: AdapterRequestOptions) => Promise<AdapterResponse<JsonValue>>;
114
+ readonly downloadFile?: (options: AdapterDownloadOptions) => Promise<AdapterResponse<Blob>>;
102
115
  };
103
- export {};
@@ -1,2 +1,2 @@
1
- import type { DefaultHttpServiceConfig, HttpService } from "./http.models.js";
2
- export declare function getDefaultHttpService(config?: DefaultHttpServiceConfig): HttpService;
1
+ import type { DefaultHttpServiceOptions, HttpService } from "./http.models.js";
2
+ export declare function getDefaultHttpService(config?: DefaultHttpServiceOptions): HttpService;