zudoku 0.71.3 → 0.71.5
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.
- package/dist/cli/cli.js +1 -1
- package/dist/declarations/index.d.ts +1 -0
- package/dist/declarations/lib/util/problemJson.d.ts +10 -0
- package/package.json +1 -1
- package/src/app/main.css +4 -0
- package/src/index.ts +4 -0
- package/src/lib/plugins/api-keys/index.tsx +1 -18
- package/src/zuplo/enrich-with-zuplo.ts +4 -2
package/dist/cli/cli.js
CHANGED
|
@@ -10,4 +10,5 @@ export type { MDXImport } from "./lib/plugins/markdown/index.js";
|
|
|
10
10
|
export { defaultLanguages } from "./lib/shiki.js";
|
|
11
11
|
export { cn } from "./lib/ui/util.js";
|
|
12
12
|
export { joinUrl } from "./lib/util/joinUrl.js";
|
|
13
|
+
export { type ProblemJson, throwIfProblemJson, } from "./lib/util/problemJson.js";
|
|
13
14
|
export type { MdxComponentsType } from "./lib/util/MdxComponents.js";
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export type ProblemJson = {
|
|
2
|
+
type: string;
|
|
3
|
+
title?: string;
|
|
4
|
+
status?: number;
|
|
5
|
+
detail?: string;
|
|
6
|
+
instance?: string;
|
|
7
|
+
[extension: string]: unknown;
|
|
8
|
+
};
|
|
9
|
+
export declare const getProblemJson: (response: Response) => Promise<ProblemJson | undefined>;
|
|
10
|
+
export declare const throwIfProblemJson: (response: Response) => Promise<void>;
|
package/package.json
CHANGED
package/src/app/main.css
CHANGED
package/src/index.ts
CHANGED
|
@@ -26,4 +26,8 @@ export type { MDXImport } from "./lib/plugins/markdown/index.js";
|
|
|
26
26
|
export { defaultLanguages } from "./lib/shiki.js";
|
|
27
27
|
export { cn } from "./lib/ui/util.js";
|
|
28
28
|
export { joinUrl } from "./lib/util/joinUrl.js";
|
|
29
|
+
export {
|
|
30
|
+
type ProblemJson,
|
|
31
|
+
throwIfProblemJson,
|
|
32
|
+
} from "./lib/util/problemJson.js";
|
|
29
33
|
export type { MdxComponentsType } from "./lib/util/MdxComponents.js";
|
|
@@ -10,6 +10,7 @@ import type {
|
|
|
10
10
|
import type { ZudokuContext } from "../../core/ZudokuContext.js";
|
|
11
11
|
import invariant from "../../util/invariant.js";
|
|
12
12
|
import { joinUrl } from "../../util/joinUrl.js";
|
|
13
|
+
import { throwIfProblemJson } from "../../util/problemJson.js";
|
|
13
14
|
import { SettingsApiKeys } from "./SettingsApiKeys.js";
|
|
14
15
|
|
|
15
16
|
const DEFAULT_GATEWAY_URL = "https://api.zuploedge.com";
|
|
@@ -70,24 +71,6 @@ export interface ApiConsumer {
|
|
|
70
71
|
key?: ApiKey;
|
|
71
72
|
}
|
|
72
73
|
|
|
73
|
-
const parseJsonSafe = async (response: Response) => {
|
|
74
|
-
try {
|
|
75
|
-
return await response.json();
|
|
76
|
-
} catch {
|
|
77
|
-
return;
|
|
78
|
-
}
|
|
79
|
-
};
|
|
80
|
-
|
|
81
|
-
const throwIfProblemJson = async (response: Response) => {
|
|
82
|
-
const contentType = response.headers.get("content-type");
|
|
83
|
-
if (!response.ok && contentType?.includes("application/problem+json")) {
|
|
84
|
-
const data = await parseJsonSafe(response);
|
|
85
|
-
if (data.type && data.title) {
|
|
86
|
-
throw new Error(data.detail ?? data.title);
|
|
87
|
-
}
|
|
88
|
-
}
|
|
89
|
-
};
|
|
90
|
-
|
|
91
74
|
const developerHintOptions = {
|
|
92
75
|
developerHint:
|
|
93
76
|
"This project is not linked to a Zuplo deployment. Run `zuplo link` to get started with API Keys.",
|
|
@@ -193,7 +193,8 @@ export const enrichWithZuploData = ({
|
|
|
193
193
|
(policy) =>
|
|
194
194
|
inboundPolicies.includes(policy.name) &&
|
|
195
195
|
(policy.handler.export === "ApiAuthKeyInboundPolicy" ||
|
|
196
|
-
policy.handler.export === "ApiKeyInboundPolicy"
|
|
196
|
+
policy.handler.export === "ApiKeyInboundPolicy" ||
|
|
197
|
+
policy.handler.export === "MonetizationInboundPolicy") &&
|
|
197
198
|
!policy.handler.options
|
|
198
199
|
?.disableAutomaticallyAddingKeyHeaderToOpenApi,
|
|
199
200
|
) ?? [];
|
|
@@ -225,7 +226,8 @@ export const enrichWithZuploData = ({
|
|
|
225
226
|
policiesConfig.policies?.some(
|
|
226
227
|
(policy) =>
|
|
227
228
|
policy.handler.export === "ApiAuthKeyInboundPolicy" ||
|
|
228
|
-
policy.handler.export === "ApiKeyInboundPolicy"
|
|
229
|
+
policy.handler.export === "ApiKeyInboundPolicy" ||
|
|
230
|
+
policy.handler.export === "MonetizationInboundPolicy",
|
|
229
231
|
)
|
|
230
232
|
) {
|
|
231
233
|
if (!schema.components) schema.components = {};
|