@griddo/cx 11.13.0 → 11.13.2
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/README.md +2 -3
- package/build/commands/end-render.js +150 -20
- package/build/commands/end-render.js.map +4 -4
- package/build/commands/prepare-assets-directory.js +146 -8
- package/build/commands/prepare-assets-directory.js.map +4 -4
- package/build/commands/prepare-domains-render.js +158 -28
- package/build/commands/prepare-domains-render.js.map +4 -4
- package/build/commands/reset-render.js +150 -20
- package/build/commands/reset-render.js.map +4 -4
- package/build/commands/start-render.js +179 -49
- package/build/commands/start-render.js.map +4 -4
- package/build/commands/upload-search-content.js +151 -21
- package/build/commands/upload-search-content.js.map +4 -4
- package/build/core/check-env-health.d.ts +47 -1
- package/build/core/http/create-adapter.d.ts +13 -0
- package/build/core/http/index.d.ts +6 -0
- package/build/core/http/types.d.ts +20 -0
- package/build/core/http/undici-adapter.d.ts +7 -0
- package/build/core/http/with-circuit-breaker.d.ts +24 -0
- package/build/core/http/with-retry.d.ts +32 -0
- package/build/index.js +25026 -42
- package/build/react/GriddoIntegrations/utils.d.ts +1 -1
- package/build/services/manage-store.d.ts +8 -1
- package/build/services/pages.d.ts +73 -2
- package/build/services/reference-fields.d.ts +1 -1
- package/build/shared/envs.d.ts +5 -2
- package/build/shared/types/api.d.ts +0 -2
- package/cli.mjs +28 -10
- package/exporter/commands/README.md +1 -1
- package/exporter/commands/end-render.ts +1 -1
- package/exporter/commands/prepare-domains-render.ts +1 -1
- package/exporter/commands/{single-domain-upload-search-content.ts → single-domain-upload-search-content.noop} +2 -4
- package/exporter/commands/upload-search-content.ts +1 -4
- package/exporter/core/check-env-health.ts +1 -1
- package/exporter/core/errors.ts +13 -13
- package/exporter/core/fs.ts +35 -31
- package/exporter/core/http/create-adapter.ts +58 -0
- package/exporter/core/http/index.ts +7 -0
- package/exporter/core/http/types.ts +22 -0
- package/exporter/core/http/undici-adapter.ts +53 -0
- package/exporter/core/http/with-circuit-breaker.ts +86 -0
- package/exporter/core/http/with-retry.ts +87 -0
- package/exporter/services/api.ts +22 -66
- package/exporter/services/auth.ts +11 -2
- package/exporter/services/domains.ts +6 -1
- package/exporter/services/llms.ts +1 -1
- package/exporter/services/manage-store.ts +16 -18
- package/exporter/services/pages.ts +7 -0
- package/exporter/services/reference-fields.ts +3 -5
- package/exporter/services/render.ts +3 -7
- package/exporter/services/store.ts +10 -4
- package/exporter/shared/envs.ts +20 -6
- package/exporter/shared/types/api.ts +0 -2
- package/exporter/ssg-adapters/gatsby/index.ts +4 -2
- package/exporter/ssg-adapters/gatsby/shared/sync-render.ts +5 -1
- package/package.json +15 -16
- package/tsconfig.commands.json +9 -22
- package/tsconfig.exporter.json +3 -4
- package/tsconfig.json +2 -3
- package/build/commands/single-domain-upload-search-content.d.ts +0 -1
|
@@ -1,3 +1,49 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Check if required environment variables exist with any value.
|
|
3
|
+
*
|
|
4
|
+
* @returns An object containing:
|
|
5
|
+
* - isValid: boolean indicating if all required environment variables are present.
|
|
6
|
+
* - missing: an array of missing environment variable names.
|
|
7
|
+
*/
|
|
8
|
+
declare function checkRequiredEnvVars(): {
|
|
9
|
+
isValid: boolean;
|
|
10
|
+
missing: string[];
|
|
11
|
+
};
|
|
12
|
+
/**
|
|
13
|
+
* Check if environment variables have the expected values.
|
|
14
|
+
*
|
|
15
|
+
* @returns An object containing:
|
|
16
|
+
* - isValid: boolean indicating if all required environment variables have the expected values.
|
|
17
|
+
* - mismatches: an array of mismatched environment variable names and their expected and actual values.
|
|
18
|
+
*/
|
|
19
|
+
declare function checkEnvVarValues(): {
|
|
20
|
+
isValid: boolean;
|
|
21
|
+
mismatches: {
|
|
22
|
+
key: string;
|
|
23
|
+
expected: string;
|
|
24
|
+
actual: string;
|
|
25
|
+
}[];
|
|
26
|
+
};
|
|
27
|
+
/**
|
|
28
|
+
* Check recommended environment variables and show warnings for missing ones.
|
|
29
|
+
*
|
|
30
|
+
* @returns An object containing:
|
|
31
|
+
* - isValid: boolean indicating if all recommended environment variables are set.
|
|
32
|
+
* - missing: an array of missing recommended environment variable names.
|
|
33
|
+
*/
|
|
34
|
+
declare function checkRecommendedEnvVars(): void;
|
|
35
|
+
/**
|
|
36
|
+
* Check if set enviroment variables have been deprecated
|
|
37
|
+
*
|
|
38
|
+
* @returns An object containing:
|
|
39
|
+
* - deprecated: an array of deprecated environment variable names.
|
|
40
|
+
*/
|
|
41
|
+
declare function checkDeprecatedEnvVars(): {
|
|
42
|
+
deprecated: {
|
|
43
|
+
key: string;
|
|
44
|
+
description?: string;
|
|
45
|
+
}[];
|
|
46
|
+
};
|
|
1
47
|
/**
|
|
2
48
|
* Check if the environment is secure to launch a render.
|
|
3
49
|
* If something fails then log an error message and exit from the process.
|
|
@@ -6,4 +52,4 @@
|
|
|
6
52
|
* @returns A boolean indicating if the environment is secure to launch a render.
|
|
7
53
|
*/
|
|
8
54
|
declare function checkEnvironmentHealth(): boolean;
|
|
9
|
-
export { checkEnvironmentHealth };
|
|
55
|
+
export { checkDeprecatedEnvVars, checkEnvVarValues, checkEnvironmentHealth, checkRecommendedEnvVars, checkRequiredEnvVars };
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { HttpAdapter } from "./types";
|
|
2
|
+
/**
|
|
3
|
+
* Sync getter del adapter HTTP.
|
|
4
|
+
*
|
|
5
|
+
* Composición:
|
|
6
|
+
* circuitBreaker → retry(exponential + jitter) → undici(timeout nativo)
|
|
7
|
+
*/
|
|
8
|
+
declare function getHttpAdapter(): HttpAdapter;
|
|
9
|
+
/**
|
|
10
|
+
* Reset del singleton (para tests).
|
|
11
|
+
*/
|
|
12
|
+
declare function resetHttpAdapter(): void;
|
|
13
|
+
export { getHttpAdapter, resetHttpAdapter };
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
export type { HttpAdapter, HttpRequest, HttpResponse } from "./types";
|
|
2
|
+
export type { CircuitBreakerOptions } from "./with-circuit-breaker";
|
|
3
|
+
export type { RetryOptions } from "./with-retry";
|
|
4
|
+
export { getHttpAdapter, resetHttpAdapter } from "./create-adapter";
|
|
5
|
+
export { CircuitOpenError, withCircuitBreaker } from "./with-circuit-breaker";
|
|
6
|
+
export { withRetry } from "./with-retry";
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/** Descriptor de request que recibe el adapter. */
|
|
2
|
+
export interface HttpRequest {
|
|
3
|
+
url: string;
|
|
4
|
+
method: string;
|
|
5
|
+
headers: Record<string, string>;
|
|
6
|
+
body?: string;
|
|
7
|
+
}
|
|
8
|
+
/** Descriptor de response que devuelve el adapter. */
|
|
9
|
+
export interface HttpResponse {
|
|
10
|
+
status: number;
|
|
11
|
+
statusText: string;
|
|
12
|
+
ok: boolean;
|
|
13
|
+
headers: Record<string, string>;
|
|
14
|
+
json: <T = unknown>() => Promise<T>;
|
|
15
|
+
text: () => Promise<string>;
|
|
16
|
+
}
|
|
17
|
+
/** Contrato del adapter. Un solo metodo, sin estado. */
|
|
18
|
+
export interface HttpAdapter {
|
|
19
|
+
request: (req: HttpRequest) => Promise<HttpResponse>;
|
|
20
|
+
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { HttpAdapter } from "./types";
|
|
2
|
+
export interface UndiciAdapterOptions {
|
|
3
|
+
/** Request timeout in milliseconds. Cancels the request if exceeded. */
|
|
4
|
+
timeoutMs?: number;
|
|
5
|
+
}
|
|
6
|
+
declare function createUndiciAdapter(options?: UndiciAdapterOptions): HttpAdapter;
|
|
7
|
+
export { createUndiciAdapter };
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import type { HttpAdapter } from "./types";
|
|
2
|
+
export interface CircuitBreakerOptions {
|
|
3
|
+
/** Number of consecutive failures before opening the circuit. */
|
|
4
|
+
failureThreshold: number;
|
|
5
|
+
/** Time in ms before switching from open to half-open. */
|
|
6
|
+
cooldownMs: number;
|
|
7
|
+
/** Called when the circuit opens. */
|
|
8
|
+
onOpen?: () => void;
|
|
9
|
+
/** Called when the circuit closes (recovery). */
|
|
10
|
+
onClose?: () => void;
|
|
11
|
+
}
|
|
12
|
+
export declare class CircuitOpenError extends Error {
|
|
13
|
+
constructor(cooldownMs: number);
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* Decorator that adds circuit breaker logic to an HttpAdapter.
|
|
17
|
+
*
|
|
18
|
+
* States:
|
|
19
|
+
* - CLOSED: requests pass through normally, failures are counted
|
|
20
|
+
* - OPEN: all requests fail immediately with CircuitOpenError
|
|
21
|
+
* - HALF-OPEN: one probe request is allowed; success → CLOSED, failure → OPEN
|
|
22
|
+
*/
|
|
23
|
+
declare function withCircuitBreaker(adapter: HttpAdapter, options: CircuitBreakerOptions): HttpAdapter;
|
|
24
|
+
export { withCircuitBreaker };
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import type { HttpAdapter, HttpRequest, HttpResponse } from "./types";
|
|
2
|
+
export interface RetryOptions {
|
|
3
|
+
/** Max number of attempts (including the first one). */
|
|
4
|
+
attempts: number;
|
|
5
|
+
/** Base delay between retries in milliseconds. */
|
|
6
|
+
delayMs: number;
|
|
7
|
+
/** Backoff strategy: "fixed" (same delay) or "exponential" (1x, 2x, 4x...). Default: "fixed". */
|
|
8
|
+
backoff?: "fixed" | "exponential";
|
|
9
|
+
/** Add random jitter (±50%) to the delay to avoid thundering herd. Default: false. */
|
|
10
|
+
jitter?: boolean;
|
|
11
|
+
/** Decide whether a successful response should be retried (e.g. 5xx). */
|
|
12
|
+
retryOn?: (response: HttpResponse) => boolean;
|
|
13
|
+
/** Called before each retry. */
|
|
14
|
+
onRetry?: (context: {
|
|
15
|
+
request: HttpRequest;
|
|
16
|
+
attempt: number;
|
|
17
|
+
delayMs: number;
|
|
18
|
+
error?: Error;
|
|
19
|
+
response?: HttpResponse;
|
|
20
|
+
}) => void;
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* Decorator that adds retry logic to an HttpAdapter.
|
|
24
|
+
*
|
|
25
|
+
* Retries on:
|
|
26
|
+
* - Transport errors (network failures, DNS, connection refused, timeouts)
|
|
27
|
+
* - Responses matching `retryOn` predicate (e.g. status >= 500)
|
|
28
|
+
*
|
|
29
|
+
* Supports fixed and exponential backoff with optional jitter.
|
|
30
|
+
*/
|
|
31
|
+
declare function withRetry(adapter: HttpAdapter, options: RetryOptions): HttpAdapter;
|
|
32
|
+
export { withRetry };
|