pasika 0.10.4 → 0.10.6
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.
|
@@ -2869,7 +2869,7 @@ var crossFeatureImportRule = {
|
|
|
2869
2869
|
schema: [],
|
|
2870
2870
|
type: "problem",
|
|
2871
2871
|
docs: {
|
|
2872
|
-
description: "Require non-composition files that import from two or more feature folders to live in src/compositions/."
|
|
2872
|
+
description: "Require non-composition files that import from two or more feature folders other than their own to live in src/compositions/."
|
|
2873
2873
|
}
|
|
2874
2874
|
},
|
|
2875
2875
|
create(context) {
|
|
@@ -2883,6 +2883,7 @@ var crossFeatureImportRule = {
|
|
|
2883
2883
|
const isInApp = fileSegments[0] === "app";
|
|
2884
2884
|
const isConfig = fileSegments[0] === "config";
|
|
2885
2885
|
if (isInCompositions || isInApp || isConfig) return {};
|
|
2886
|
+
const ownFeature = fileSegments[0] === FEATURES_SEGMENT ? fileSegments[1] : void 0;
|
|
2886
2887
|
const importedFeatures = /* @__PURE__ */ new Set();
|
|
2887
2888
|
let alreadyReported = false;
|
|
2888
2889
|
return {
|
|
@@ -2898,7 +2899,7 @@ var crossFeatureImportRule = {
|
|
|
2898
2899
|
}
|
|
2899
2900
|
if (!resolved) return;
|
|
2900
2901
|
const feature = featureNameOf(resolved, sourceRoot);
|
|
2901
|
-
if (feature) importedFeatures.add(feature);
|
|
2902
|
+
if (feature !== void 0 && feature !== ownFeature) importedFeatures.add(feature);
|
|
2902
2903
|
if (importedFeatures.size >= 2) {
|
|
2903
2904
|
alreadyReported = true;
|
|
2904
2905
|
const names = [...importedFeatures].sort().join(", ");
|
|
@@ -3398,6 +3399,7 @@ var FETCHED = `fetch must not be called; make the request through ${HELPER3} fro
|
|
|
3398
3399
|
var DECLARED3 = `A file must not declare its own ${HELPER3}; import it from ${ENTRY3}. See ${DOC4}`;
|
|
3399
3400
|
var IMPORTED3 = `${HELPER3} must be imported from ${ENTRY3}. See ${DOC4}`;
|
|
3400
3401
|
var GLOBAL_OBJECTS = /* @__PURE__ */ new Set(["globalThis", "window", "self", "global"]);
|
|
3402
|
+
var TEST_FILE = /(?:^|[\\/])(?:__tests__|tests)[\\/]|[.](?:test|spec)[.][cm]?[jt]sx?$/;
|
|
3401
3403
|
function isNamed3(node, name) {
|
|
3402
3404
|
return node?.type === "Identifier" && node.name === name;
|
|
3403
3405
|
}
|
|
@@ -3414,6 +3416,7 @@ var zodFetchHelperRule = {
|
|
|
3414
3416
|
}
|
|
3415
3417
|
},
|
|
3416
3418
|
create(context) {
|
|
3419
|
+
if (TEST_FILE.test(context.filename)) return {};
|
|
3417
3420
|
const checkSource = (node) => {
|
|
3418
3421
|
if (!node.source || node.source.value === ENTRY3) return;
|
|
3419
3422
|
for (const specifier of node.specifiers) {
|
|
@@ -19,7 +19,7 @@ interface ZodFetchRelayedResponse {
|
|
|
19
19
|
*
|
|
20
20
|
* A success that carries no body is the schema's call: one that allows its data to
|
|
21
21
|
* be absent, such as `z.undefined()` for an endpoint answering `204`, accepts it, and
|
|
22
|
-
* one that does not makes it a failure
|
|
22
|
+
* one that does not makes it a failure of this gateway's own, a 502.
|
|
23
23
|
*/
|
|
24
24
|
declare function zodFetch<TSchema extends ZodType>(options: ZodFetchOptions<TSchema> & {
|
|
25
25
|
responseSchema: TSchema;
|
|
@@ -5,6 +5,7 @@ import {
|
|
|
5
5
|
// helpers/zod-fetch.ts
|
|
6
6
|
import { z } from "zod";
|
|
7
7
|
var streamBody = z.custom((value) => value instanceof ReadableStream);
|
|
8
|
+
var BAD_GATEWAY = 502;
|
|
8
9
|
function decodeFailureBody(body) {
|
|
9
10
|
try {
|
|
10
11
|
const parsed = JSON.parse(body);
|
|
@@ -27,7 +28,7 @@ async function zodFetch(options) {
|
|
|
27
28
|
if (options.responseSchema === void 0) {
|
|
28
29
|
const streamed = streamBody.safeParse(response.body);
|
|
29
30
|
if (!streamed.success) {
|
|
30
|
-
throw new HttpError("The upstream answered without a body to relay.",
|
|
31
|
+
throw new HttpError("The upstream answered without a body to relay.", BAD_GATEWAY);
|
|
31
32
|
}
|
|
32
33
|
return { body: streamed.data, status: response.status, headers: response.headers };
|
|
33
34
|
}
|
|
@@ -35,7 +36,7 @@ async function zodFetch(options) {
|
|
|
35
36
|
if (body === "") {
|
|
36
37
|
const absent = options.responseSchema.safeParse(void 0);
|
|
37
38
|
if (absent.success) return absent.data;
|
|
38
|
-
throw new HttpError("The upstream answered without a body to decode.",
|
|
39
|
+
throw new HttpError("The upstream answered without a body to decode.", BAD_GATEWAY);
|
|
39
40
|
}
|
|
40
41
|
const decoded = JSON.parse(body);
|
|
41
42
|
return options.responseSchema.parse(decoded);
|