@datum-cloud/strapi-revalidate 0.1.2 → 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.
- package/dist/cache/manager.d.ts +15 -2
- package/dist/cache/manager.d.ts.map +1 -1
- package/dist/cache/manager.js +28 -2
- package/dist/cache/manager.js.map +1 -1
- package/dist/client/graphql.d.ts +5 -2
- package/dist/client/graphql.d.ts.map +1 -1
- package/dist/client/graphql.js +1 -1
- package/dist/client/graphql.js.map +1 -1
- package/dist/client/rest.d.ts +1 -1
- package/dist/client/rest.d.ts.map +1 -1
- package/dist/client/rest.js.map +1 -1
- package/dist/types/config.d.ts +3 -3
- package/dist/types/config.js +1 -1
- package/dist/types/config.js.map +1 -1
- package/package.json +1 -1
package/dist/cache/manager.d.ts
CHANGED
|
@@ -5,8 +5,8 @@
|
|
|
5
5
|
* - Track tag membership across writes so `invalidate(tag)` is O(tagged keys).
|
|
6
6
|
* - Mirror every successful `set()` to a persistent fallback driver with no
|
|
7
7
|
* TTL, so Strapi outages don't take the site down.
|
|
8
|
-
* -
|
|
9
|
-
*
|
|
8
|
+
* - `getWithFallback()` for resilient read paths: primary hit → fetcher →
|
|
9
|
+
* fallback, with a single cache write on fresh data.
|
|
10
10
|
*
|
|
11
11
|
* Drivers themselves stay storage-only; tag accounting lives here.
|
|
12
12
|
*/
|
|
@@ -36,6 +36,19 @@ export declare class CacheManager {
|
|
|
36
36
|
get<T>(key: string): Promise<T | null>;
|
|
37
37
|
/** Read from the persistent fallback cache. Returns `null` if never populated. */
|
|
38
38
|
getFallback<T>(key: string): Promise<T | null>;
|
|
39
|
+
/**
|
|
40
|
+
* Full read path with outage resilience:
|
|
41
|
+
* 1. Return the primary cache value if present.
|
|
42
|
+
* 2. Call `fetcher()` to get fresh data.
|
|
43
|
+
* 3. On success, write to both primary and fallback caches, then return.
|
|
44
|
+
* 4. On failure (`null`), return whatever the fallback cache holds.
|
|
45
|
+
*
|
|
46
|
+
* @param key Cache key.
|
|
47
|
+
* @param fetcher Async function that fetches fresh data. Return `null` to
|
|
48
|
+
* signal failure and trigger the fallback read.
|
|
49
|
+
* @param options TTL and tag options forwarded to `set()` on a fresh write.
|
|
50
|
+
*/
|
|
51
|
+
getWithFallback<T>(key: string, fetcher: () => Promise<T | null>, options?: CacheSetOptions): Promise<T | null>;
|
|
39
52
|
/**
|
|
40
53
|
* Write to both the primary cache (with TTL + tags) and the fallback cache
|
|
41
54
|
* (no TTL, no tags). Tag accounting happens at the driver level.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"manager.d.ts","sourceRoot":"","sources":["../../src/cache/manager.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAEH,OAAO,KAAK,EAAE,WAAW,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC;AAE/D,kDAAkD;AAClD,MAAM,WAAW,mBAAmB;IAClC,sDAAsD;IACtD,OAAO,EAAE,WAAW,CAAC;IACrB,mFAAmF;IACnF,QAAQ,EAAE,WAAW,CAAC;IACtB,sEAAsE;IACtE,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,6DAA6D;IAC7D,KAAK,CAAC,EAAE,OAAO,CAAC;CACjB;AAED;;;GAGG;AACH,qBAAa,YAAY;IACvB,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAc;IACtC,OAAO,CAAC,QAAQ,CAAC,QAAQ,CAAc;IACvC,OAAO,CAAC,QAAQ,CAAC,UAAU,CAAS;IACpC,OAAO,CAAC,QAAQ,CAAC,KAAK,CAAU;gBAEpB,OAAO,EAAE,mBAAmB;IAOxC,qEAAqE;IAC/D,GAAG,CAAC,CAAC,EAAE,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,CAAC,GAAG,IAAI,CAAC;IAQ5C,kFAAkF;IAC5E,WAAW,CAAC,CAAC,EAAE,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,CAAC,GAAG,IAAI,CAAC;IAIpD;;;OAGG;IACG,GAAG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WG;IACG,eAAe,CAAC,CAAC,EACrB,GAAG,EAAE,MAAM,EACX,OAAO,EAAE,MAAM,OAAO,CAAC,CAAC,GAAG,IAAI,CAAC,EAChC,OAAO,GAAE,eAAoB,GAC5B,OAAO,CAAC,CAAC,GAAG,IAAI,CAAC;IAgBpB;;;OAGG;IACG,GAAG,CAAC,CAAC,EAAE,GAAG,EAAE,MAAM,EAAE,IAAI,EAAE,CAAC,EAAE,OAAO,GAAE,eAAoB,GAAG,OAAO,CAAC,IAAI,CAAC;IAOhF,mFAAmF;IAC7E,MAAM,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAIxC;;;;OAIG;IACG,UAAU,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAO5C,mEAAmE;IAC7D,aAAa,IAAI,OAAO,CAAC,IAAI,CAAC;CAMrC"}
|
package/dist/cache/manager.js
CHANGED
|
@@ -5,8 +5,8 @@
|
|
|
5
5
|
* - Track tag membership across writes so `invalidate(tag)` is O(tagged keys).
|
|
6
6
|
* - Mirror every successful `set()` to a persistent fallback driver with no
|
|
7
7
|
* TTL, so Strapi outages don't take the site down.
|
|
8
|
-
* -
|
|
9
|
-
*
|
|
8
|
+
* - `getWithFallback()` for resilient read paths: primary hit → fetcher →
|
|
9
|
+
* fallback, with a single cache write on fresh data.
|
|
10
10
|
*
|
|
11
11
|
* Drivers themselves stay storage-only; tag accounting lives here.
|
|
12
12
|
*/
|
|
@@ -37,6 +37,32 @@ export class CacheManager {
|
|
|
37
37
|
async getFallback(key) {
|
|
38
38
|
return this.fallback.get(key);
|
|
39
39
|
}
|
|
40
|
+
/**
|
|
41
|
+
* Full read path with outage resilience:
|
|
42
|
+
* 1. Return the primary cache value if present.
|
|
43
|
+
* 2. Call `fetcher()` to get fresh data.
|
|
44
|
+
* 3. On success, write to both primary and fallback caches, then return.
|
|
45
|
+
* 4. On failure (`null`), return whatever the fallback cache holds.
|
|
46
|
+
*
|
|
47
|
+
* @param key Cache key.
|
|
48
|
+
* @param fetcher Async function that fetches fresh data. Return `null` to
|
|
49
|
+
* signal failure and trigger the fallback read.
|
|
50
|
+
* @param options TTL and tag options forwarded to `set()` on a fresh write.
|
|
51
|
+
*/
|
|
52
|
+
async getWithFallback(key, fetcher, options = {}) {
|
|
53
|
+
const cached = await this.get(key);
|
|
54
|
+
if (cached !== null)
|
|
55
|
+
return cached;
|
|
56
|
+
const fresh = await fetcher();
|
|
57
|
+
if (fresh !== null) {
|
|
58
|
+
await this.set(key, fresh, options);
|
|
59
|
+
return fresh;
|
|
60
|
+
}
|
|
61
|
+
if (this.debug) {
|
|
62
|
+
console.debug(`[strapi-revalidate] fetcher returned null, reading fallback → ${key}`);
|
|
63
|
+
}
|
|
64
|
+
return this.getFallback(key);
|
|
65
|
+
}
|
|
40
66
|
/**
|
|
41
67
|
* Write to both the primary cache (with TTL + tags) and the fallback cache
|
|
42
68
|
* (no TTL, no tags). Tag accounting happens at the driver level.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"manager.js","sourceRoot":"","sources":["../../src/cache/manager.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAgBH;;;GAGG;AACH,MAAM,OAAO,YAAY;IACN,OAAO,CAAc;IACrB,QAAQ,CAAc;IACtB,UAAU,CAAS;IACnB,KAAK,CAAU;IAEhC,YAAY,OAA4B;QACtC,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC,OAAO,CAAC;QAC/B,IAAI,CAAC,QAAQ,GAAG,OAAO,CAAC,QAAQ,CAAC;QACjC,IAAI,CAAC,UAAU,GAAG,OAAO,CAAC,UAAU,IAAI,IAAI,CAAC;QAC7C,IAAI,CAAC,KAAK,GAAG,OAAO,CAAC,KAAK,IAAI,KAAK,CAAC;IACtC,CAAC;IAED,qEAAqE;IACrE,KAAK,CAAC,GAAG,CAAI,GAAW;QACtB,MAAM,KAAK,GAAG,MAAM,IAAI,CAAC,OAAO,CAAC,GAA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AE,CAAC;QAC3B,IAAI,IAAI,CAAC,KAAK,EAAE,CAAC;YACf,OAAO,CAAC,KAAK,CAAC,qCAAqC,CAAC,CAAC;QACvD,CAAC;IACH,CAAC;CACF","sourcesContent":["/**\n * CacheManager — the composition layer the public API talks to.\n *\n * Responsibilities:\n * - Track tag membership across writes so `invalidate(tag)` is O(tagged keys).\n * - Mirror every successful `set()` to a persistent fallback driver with no\n * TTL, so Strapi outages don't take the site down.\n * -
|
|
1
|
+
{"version":3,"file":"manager.js","sourceRoot":"","sources":["../../src/cache/manager.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAgBH;;;GAGG;AACH,MAAM,OAAO,YAAY;IACN,OAAO,CAAc;IACrB,QAAQ,CAAc;IACtB,UAAU,CAAS;IACnB,KAAK,CAAU;IAEhC,YAAY,OAA4B;QACtC,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC,OAAO,CAAC;QAC/B,IAAI,CAAC,QAAQ,GAAG,OAAO,CAAC,QAAQ,CAAC;QACjC,IAAI,CAAC,UAAU,GAAG,OAAO,CAAC,UAAU,IAAI,IAAI,CAAC;QAC7C,IAAI,CAAC,KAAK,GAAG,OAAO,CAAC,KAAK,IAAI,KAAK,CAAC;IACtC,CAAC;IAED,qEAAqE;IACrE,KAAK,CAAC,GAAG,CAAI,GAAW;QACtB,MAAM,KAAK,GAAG,MAAM,IAAI,CAAC,OAAO,CAAC,GAAG,CAAI,GAAG,CAAC,CAAC;QAC7C,IAAI,IAAI,CAAC,KAAK,EAAE,CAAC;YACf,OAAO,CAAC,KAAK,CAAC,6BAA6B,KAAK,KAAK,IAAI,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,KAAK,MAAM,GAAG,EAAE,CAAC,CAAC;QACzF,CAAC;QACD,OAAO,KAAK,CAAC;IACf,CAAC;IAED,kFAAkF;IAClF,KAAK,CAAC,WAAW,CAAI,GAAW;QAC9B,OAAO,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAI,G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,OAAO,CAAC,WAAW,CAAC,GAAG,CAAC,CAAC;QACpC,IAAI,IAAI,CAAC,KAAK,EAAE,CAAC;YACf,OAAO,CAAC,KAAK,CAAC,yCAAyC,GAAG,EAAE,CAAC,CAAC;QAChE,CAAC;IACH,CAAC;IAED,mEAAmE;IACnE,KAAK,CAAC,aAAa;QACjB,MAAM,IAAI,CAAC,OAAO,CAAC,KAAK,EAAE,CAAC;QAC3B,IAAI,IAAI,CAAC,KAAK,EAAE,CAAC;YACf,OAAO,CAAC,KAAK,CAAC,qCAAqC,CAAC,CAAC;QACvD,CAAC;IACH,CAAC;CACF","sourcesContent":["/**\n * CacheManager — the composition layer the public API talks to.\n *\n * Responsibilities:\n * - Track tag membership across writes so `invalidate(tag)` is O(tagged keys).\n * - Mirror every successful `set()` to a persistent fallback driver with no\n * TTL, so Strapi outages don't take the site down.\n * - `getWithFallback()` for resilient read paths: primary hit → fetcher →\n * fallback, with a single cache write on fresh data.\n *\n * Drivers themselves stay storage-only; tag accounting lives here.\n */\n\nimport type { CacheDriver, CacheSetOptions } from './types.js';\n\n/** Options for instantiating a `CacheManager`. */\nexport interface CacheManagerOptions {\n /** Primary driver — honours TTL, serves hot reads. */\n primary: CacheDriver;\n /** Persistent fallback driver — never expires, written on every successful set. */\n fallback: CacheDriver;\n /** Default TTL (seconds) applied when `set` is called without one. */\n defaultTtl?: number;\n /** When true, hits/misses are logged via `console.debug`. */\n debug?: boolean;\n}\n\n/**\n * Cache facade. All content fetchers and the webhook handler talk to this,\n * not to a driver directly.\n */\nexport class CacheManager {\n private readonly primary: CacheDriver;\n private readonly fallback: CacheDriver;\n private readonly defaultTtl: number;\n private readonly debug: boolean;\n\n constructor(options: CacheManagerOptions) {\n this.primary = options.primary;\n this.fallback = options.fallback;\n this.defaultTtl = options.defaultTtl ?? 3600;\n this.debug = options.debug ?? false;\n }\n\n /** Read from the primary cache. Returns `null` on miss or expiry. */\n async get<T>(key: string): Promise<T | null> {\n const value = await this.primary.get<T>(key);\n if (this.debug) {\n console.debug(`[strapi-revalidate] cache ${value === null ? 'MISS' : 'HIT'} → ${key}`);\n }\n return value;\n }\n\n /** Read from the persistent fallback cache. Returns `null` if never populated. */\n async getFallback<T>(key: string): Promise<T | null> {\n return this.fallback.get<T>(key);\n }\n\n /**\n * Full read path with outage resilience:\n * 1. Return the primary cache value if present.\n * 2. Call `fetcher()` to get fresh data.\n * 3. On success, write to both primary and fallback caches, then return.\n * 4. On failure (`null`), return whatever the fallback cache holds.\n *\n * @param key Cache key.\n * @param fetcher Async function that fetches fresh data. Return `null` to\n * signal failure and trigger the fallback read.\n * @param options TTL and tag options forwarded to `set()` on a fresh write.\n */\n async getWithFallback<T>(\n key: string,\n fetcher: () => Promise<T | null>,\n options: CacheSetOptions = {}\n ): Promise<T | null> {\n const cached = await this.get<T>(key);\n if (cached !== null) return cached;\n\n const fresh = await fetcher();\n if (fresh !== null) {\n await this.set(key, fresh, options);\n return fresh;\n }\n\n if (this.debug) {\n console.debug(`[strapi-revalidate] fetcher returned null, reading fallback → ${key}`);\n }\n return this.getFallback<T>(key);\n }\n\n /**\n * Write to both the primary cache (with TTL + tags) and the fallback cache\n * (no TTL, no tags). Tag accounting happens at the driver level.\n */\n async set<T>(key: string, data: T, options: CacheSetOptions = {}): Promise<void> {\n const ttl = options.ttl ?? this.defaultTtl;\n await this.primary.set(key, data, { ttl, tags: options.tags });\n // Fallback: no TTL, no tag indexing — it exists purely to survive outages.\n await this.fallback.set(key, data);\n }\n\n /** Remove a single key from the primary cache. Fallback is preserved by design. */\n async delete(key: string): Promise<void> {\n await this.primary.delete(key);\n }\n\n /**\n * Invalidate every primary-cache key associated with `tag`. The fallback\n * cache is intentionally untouched — if the upcoming refetch fails, stale\n * data should still serve.\n */\n async invalidate(tag: string): Promise<void> {\n await this.primary.deleteByTag(tag);\n if (this.debug) {\n console.debug(`[strapi-revalidate] invalidated tag → ${tag}`);\n }\n }\n\n /** Invalidate all primary-cache entries. Fallback is preserved. */\n async invalidateAll(): Promise<void> {\n await this.primary.clear();\n if (this.debug) {\n console.debug('[strapi-revalidate] invalidated all');\n }\n }\n}\n"]}
|
package/dist/client/graphql.d.ts
CHANGED
|
@@ -16,8 +16,11 @@ export interface GraphQLResponse<T> {
|
|
|
16
16
|
export interface GraphQLClientOptions {
|
|
17
17
|
/** Strapi base URL (no trailing `/graphql`). */
|
|
18
18
|
url: string;
|
|
19
|
-
/**
|
|
20
|
-
|
|
19
|
+
/**
|
|
20
|
+
* Strapi API token. Sent as `Authorization: Bearer <token>` when present.
|
|
21
|
+
* Omit for Strapi instances where the queried content is publicly readable.
|
|
22
|
+
*/
|
|
23
|
+
token?: string;
|
|
21
24
|
/** Per-request timeout in **milliseconds**. */
|
|
22
25
|
timeout: number;
|
|
23
26
|
/** Number of retries on transport failure (timeout, network, 5xx). 0 disables retry. */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"graphql.d.ts","sourceRoot":"","sources":["../../src/client/graphql.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,gDAAgD;AAChD,MAAM,WAAW,eAAe,CAAC,CAAC;IAChC,IAAI,EAAE,CAAC,CAAC;IACR,MAAM,CAAC,EAAE,KAAK,CAAC;QAAE,OAAO,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC;CACrC;AAED,iDAAiD;AACjD,MAAM,WAAW,oBAAoB;IACnC,gDAAgD;IAChD,GAAG,EAAE,MAAM,CAAC;IACZ
|
|
1
|
+
{"version":3,"file":"graphql.d.ts","sourceRoot":"","sources":["../../src/client/graphql.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,gDAAgD;AAChD,MAAM,WAAW,eAAe,CAAC,CAAC;IAChC,IAAI,EAAE,CAAC,CAAC;IACR,MAAM,CAAC,EAAE,KAAK,CAAC;QAAE,OAAO,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC;CACrC;AAED,iDAAiD;AACjD,MAAM,WAAW,oBAAoB;IACnC,gDAAgD;IAChD,GAAG,EAAE,MAAM,CAAC;IACZ;;;OAGG;IACH,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,+CAA+C;IAC/C,OAAO,EAAE,MAAM,CAAC;IAChB,wFAAwF;IACxF,KAAK,EAAE,MAAM,CAAC;IACd,6DAA6D;IAC7D,KAAK,CAAC,EAAE,OAAO,CAAC;CACjB;AAED;;;;;;GAMG;AACH,qBAAa,mBAAmB;IAC9B,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAuB;gBAEnC,OAAO,EAAE,oBAAoB;IAIzC;;;;OAIG;IACG,KAAK,CAAC,CAAC,EAAE,KAAK,EAAE,MAAM,EAAE,SAAS,GAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAM,GAAG,OAAO,CAAC,CAAC,GAAG,IAAI,CAAC;YAiC3E,WAAW;CAwC1B"}
|
package/dist/client/graphql.js
CHANGED
|
@@ -60,7 +60,7 @@ export class GraphQLStrapiClient {
|
|
|
60
60
|
method: 'POST',
|
|
61
61
|
headers: {
|
|
62
62
|
'Content-Type': 'application/json',
|
|
63
|
-
Authorization: `Bearer ${this.options.token}
|
|
63
|
+
...(this.options.token ? { Authorization: `Bearer ${this.options.token}` } : {}),
|
|
64
64
|
},
|
|
65
65
|
body: JSON.stringify({ query, variables }),
|
|
66
66
|
signal: controller.signal,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"graphql.js","sourceRoot":"","sources":["../../src/client/graphql.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;
|
|
1
|
+
{"version":3,"file":"graphql.js","sourceRoot":"","sources":["../../src/client/graphql.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAyBH;;;;;;GAMG;AACH,MAAM,OAAO,mBAAmB;IACb,OAAO,CAAuB;IAE/C,YAAY,OAA6B;QACvC,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC;IACzB,CAAC;IAED;;;;OAIG;IACH,KAAK,CAAC,KAAK,CAAI,KAAa,EAAE,YAAqC,EAAE;QACnE,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,CAAC;gBAC9C,OAAO,CAAC,KAAK,CAAC,wBAAwB,EAAE,MAAM,CAAC,MAAM,CAAC,CAAC;gBACvD,OAAO,IAAI,CAAC;YACd,CAAC;YAED,OAAO,MAAM,CAAC,IAAI,CAAC;QACrB,CAAC;gBAAS,CAAC;YACT,YAAY,CAAC,SAAS,CAAC,CAAC;QAC1B,CAAC;IACH,CAAC;CACF;AAED,SAAS,KAAK,CAAC,EAAU;IACvB,OAAO,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,UAAU,CAAC,OAAO,EAAE,EAAE,CAAC,CAAC,CAAC;AAC3D,CAAC;AAED,iEAAiE;AACjE,SAAS,SAAS,CAAC,OAAe;IAChC,MAAM,IAAI,GAAG,GAAG,GAAG,CAAC,IAAI,OAAO,CAAC;IAChC,OAAO,IAAI,CAAC,GAAG,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC;AAC9B,CAAC","sourcesContent":["/**\n * GraphQL transport for Strapi v5.\n *\n * Adapted from datum.net's `graphqlQuery()` with two additions: configurable\n * retry with exponential backoff, and a structured `StrapiClient` surface so\n * the same instance is reused across fetchers (no module-level state).\n */\n\n/** Generic Strapi GraphQL response envelope. */\nexport interface GraphQLResponse<T> {\n data: T;\n errors?: Array<{ message: string }>;\n}\n\n/** Configuration for a `GraphQLStrapiClient`. */\nexport interface GraphQLClientOptions {\n /** Strapi base URL (no trailing `/graphql`). */\n url: string;\n /**\n * Strapi API token. Sent as `Authorization: Bearer <token>` when present.\n * Omit for Strapi instances where the queried content is publicly readable.\n */\n token?: string;\n /** Per-request timeout in **milliseconds**. */\n timeout: number;\n /** Number of retries on transport failure (timeout, network, 5xx). 0 disables retry. */\n retry: number;\n /** When true, logs request lifecycle via `console.debug`. */\n debug?: boolean;\n}\n\n/**\n * Strapi GraphQL client.\n *\n * `query<T>()` returns the unwrapped `data` payload or `null` on failure;\n * callers are expected to treat `null` as \"Strapi unreachable / invalid\"\n * and fall back to stale cache.\n */\nexport class GraphQLStrapiClient {\n private readonly options: GraphQLClientOptions;\n\n constructor(options: GraphQLClientOptions) {\n this.options = options;\n }\n\n /**\n * Execute a GraphQL operation. Returns the `data` payload on success,\n * `null` if the server returns an error envelope, a non-2xx status,\n * times out, or all retries are exhausted.\n */\n async query<T>(query: string, variables: Record<string, unknown> = {}): Promise<T | null> {\n const { retry } = this.options;\n let lastError: unknown = null;\n\n for (let attempt = 0; attempt <= retry; attempt++) {\n try {\n const result = await this.executeOnce<T>(query, variables);\n if (result !== null) return result;\n // result === null means a structured Strapi error (4xx / GraphQL errors).\n // Don't retry those — they won't get better.\n return null;\n } catch (err) {\n lastError = err;\n if (this.options.debug) {\n console.debug(\n `[strapi-revalidate] graphql attempt ${attempt + 1}/${retry + 1} failed:`,\n err\n );\n }\n if (attempt < retry) {\n await sleep(backoffMs(attempt));\n }\n }\n }\n\n if (lastError instanceof Error && lastError.name === 'AbortError') {\n console.error(`Strapi request timed out after ${this.options.timeout}ms`);\n } else if (lastError) {\n console.error('Error fetching from Strapi:', lastError);\n }\n return null;\n }\n\n private async executeOnce<T>(\n query: string,\n variables: Record<string, unknown>\n ): Promise<T | null> {\n const controller = new AbortController();\n const timeoutId = setTimeout(() => controller.abort(), this.options.timeout);\n\n try {\n const response = await fetch(`${this.options.url.replace(/\\/$/, '')}/graphql`, {\n method: 'POST',\n headers: {\n 'Content-Type': 'application/json',\n ...(this.options.token ? { Authorization: `Bearer ${this.options.token}` } : {}),\n },\n body: JSON.stringify({ query, variables }),\n signal: controller.signal,\n });\n\n if (!response.ok) {\n const text = await response.text();\n console.error(`Strapi GraphQL error: ${response.status} ${response.statusText}`, text);\n // 5xx is retryable — surface as a thrown error so the retry loop fires.\n if (response.status >= 500) {\n throw new Error(`Strapi ${response.status} ${response.statusText}`);\n }\n return null;\n }\n\n const result = (await response.json()) as GraphQLResponse<T>;\n\n if (result.errors && result.errors.length > 0) {\n console.error('Strapi GraphQL errors:', result.errors);\n return null;\n }\n\n return result.data;\n } finally {\n clearTimeout(timeoutId);\n }\n }\n}\n\nfunction sleep(ms: number): Promise<void> {\n return new Promise((resolve) => setTimeout(resolve, ms));\n}\n\n/** Exponential backoff with a sane cap. Attempt is 0-indexed. */\nfunction backoffMs(attempt: number): number {\n const base = 200 * 2 ** attempt;\n return Math.min(base, 2000);\n}\n"]}
|
package/dist/client/rest.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"rest.d.ts","sourceRoot":"","sources":["../../src/client/rest.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,+DAA+D;AAC/D,MAAM,WAAW,iBAAiB;IAChC,GAAG,EAAE,MAAM,CAAC;IACZ,KAAK,EAAE,MAAM,CAAC;
|
|
1
|
+
{"version":3,"file":"rest.d.ts","sourceRoot":"","sources":["../../src/client/rest.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,+DAA+D;AAC/D,MAAM,WAAW,iBAAiB;IAChC,GAAG,EAAE,MAAM,CAAC;IACZ,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,OAAO,EAAE,MAAM,CAAC;IAChB,KAAK,EAAE,MAAM,CAAC;CACf;AAKD,4FAA4F;AAC5F,qBAAa,gBAAgB;IAE3B,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAoB;gBAEhC,OAAO,EAAE,iBAAiB;IAIhC,GAAG,CAAC,CAAC,EAAE,KAAK,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,OAAO,CAAC,CAAC,GAAG,IAAI,CAAC;CAIlF;AAED,4EAA4E;AAC5E,wBAAgB,gBAAgB,CAAC,QAAQ,EAAE,iBAAiB,GAAG,gBAAgB,CAE9E"}
|
package/dist/client/rest.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"rest.js","sourceRoot":"","sources":["../../src/client/rest.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAUH,MAAM,uBAAuB,GAC3B,+FAA+F,CAAC;AAElG,4FAA4F;AAC5F,MAAM,OAAO,gBAAgB;IAC3B,iEAAiE;IAChD,OAAO,CAAoB;IAE5C,YAAY,OAA0B;QACpC,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC;IACzB,CAAC;IAED,KAAK,CAAC,GAAG,CAAI,KAAa,EAAE,OAAiC;QAC3D,KAAK,IAAI,CAAC,OAAO,CAAC;QAClB,MAAM,IAAI,KAAK,CAAC,uBAAuB,CAAC,CAAC;IAC3C,CAAC;CACF;AAED,4EAA4E;AAC5E,MAAM,UAAU,gBAAgB,CAAC,QAA2B;IAC1D,MAAM,IAAI,KAAK,CAAC,uBAAuB,CAAC,CAAC;AAC3C,CAAC","sourcesContent":["/**\n * REST transport for Strapi — STUB.\n *\n * The interface is exported for forward compatibility; runtime usage throws\n * a clear error. v0.1.0 only ships the GraphQL transport because every\n * built-in content fetcher uses GraphQL.\n */\n\n/** Configuration for the (not-yet-implemented) REST client. */\nexport interface RestClientOptions {\n url: string;\n token
|
|
1
|
+
{"version":3,"file":"rest.js","sourceRoot":"","sources":["../../src/client/rest.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAUH,MAAM,uBAAuB,GAC3B,+FAA+F,CAAC;AAElG,4FAA4F;AAC5F,MAAM,OAAO,gBAAgB;IAC3B,iEAAiE;IAChD,OAAO,CAAoB;IAE5C,YAAY,OAA0B;QACpC,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC;IACzB,CAAC;IAED,KAAK,CAAC,GAAG,CAAI,KAAa,EAAE,OAAiC;QAC3D,KAAK,IAAI,CAAC,OAAO,CAAC;QAClB,MAAM,IAAI,KAAK,CAAC,uBAAuB,CAAC,CAAC;IAC3C,CAAC;CACF;AAED,4EAA4E;AAC5E,MAAM,UAAU,gBAAgB,CAAC,QAA2B;IAC1D,MAAM,IAAI,KAAK,CAAC,uBAAuB,CAAC,CAAC;AAC3C,CAAC","sourcesContent":["/**\n * REST transport for Strapi — STUB.\n *\n * The interface is exported for forward compatibility; runtime usage throws\n * a clear error. v0.1.0 only ships the GraphQL transport because every\n * built-in content fetcher uses GraphQL.\n */\n\n/** Configuration for the (not-yet-implemented) REST client. */\nexport interface RestClientOptions {\n url: string;\n token?: string;\n timeout: number;\n retry: number;\n}\n\nconst NOT_IMPLEMENTED_MESSAGE =\n 'REST transport not yet implemented. Use transport: \"graphql\" or pin to a future v1.x release.';\n\n/** Stubbed REST client. Constructor is callable so config typing works; all reads throw. */\nexport class RestStrapiClient {\n // Stored to keep strict property init quiet and document intent.\n private readonly options: RestClientOptions;\n\n constructor(options: RestClientOptions) {\n this.options = options;\n }\n\n async get<T>(_path: string, _params?: Record<string, unknown>): Promise<T | null> {\n void this.options;\n throw new Error(NOT_IMPLEMENTED_MESSAGE);\n }\n}\n\n/** Factory that mirrors `createStrapiClient` shape. Throws on first use. */\nexport function createRestClient(_options: RestClientOptions): RestStrapiClient {\n throw new Error(NOT_IMPLEMENTED_MESSAGE);\n}\n"]}
|
package/dist/types/config.d.ts
CHANGED
|
@@ -20,7 +20,7 @@ export type TransportName = z.infer<typeof transportNameSchema>;
|
|
|
20
20
|
*/
|
|
21
21
|
export declare const revalidateConfigSchema: z.ZodObject<{
|
|
22
22
|
url: z.ZodString;
|
|
23
|
-
token: z.ZodString
|
|
23
|
+
token: z.ZodOptional<z.ZodString>;
|
|
24
24
|
webhook: z.ZodOptional<z.ZodObject<{
|
|
25
25
|
secret: z.ZodOptional<z.ZodString>;
|
|
26
26
|
tagMap: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodArray<z.ZodString, "many">>>;
|
|
@@ -62,7 +62,6 @@ export declare const revalidateConfigSchema: z.ZodObject<{
|
|
|
62
62
|
debug: z.ZodDefault<z.ZodBoolean>;
|
|
63
63
|
}, "strip", z.ZodTypeAny, {
|
|
64
64
|
url: string;
|
|
65
|
-
token: string;
|
|
66
65
|
cache: {
|
|
67
66
|
driver: "file" | "memory" | "redis";
|
|
68
67
|
ttl: number;
|
|
@@ -75,6 +74,7 @@ export declare const revalidateConfigSchema: z.ZodObject<{
|
|
|
75
74
|
timeout: number;
|
|
76
75
|
retry: number;
|
|
77
76
|
debug: boolean;
|
|
77
|
+
token?: string | undefined;
|
|
78
78
|
webhook?: {
|
|
79
79
|
secret?: string | undefined;
|
|
80
80
|
tagMap?: Record<string, string[]> | undefined;
|
|
@@ -82,7 +82,7 @@ export declare const revalidateConfigSchema: z.ZodObject<{
|
|
|
82
82
|
} | undefined;
|
|
83
83
|
}, {
|
|
84
84
|
url: string;
|
|
85
|
-
token
|
|
85
|
+
token?: string | undefined;
|
|
86
86
|
webhook?: {
|
|
87
87
|
secret?: string | undefined;
|
|
88
88
|
tagMap?: Record<string, string[]> | undefined;
|
package/dist/types/config.js
CHANGED
|
@@ -40,7 +40,7 @@ const webhookConfigSchema = z
|
|
|
40
40
|
*/
|
|
41
41
|
export const revalidateConfigSchema = z.object({
|
|
42
42
|
url: z.string().url(),
|
|
43
|
-
token: z.string().min(1),
|
|
43
|
+
token: z.string().min(1).optional(),
|
|
44
44
|
webhook: webhookConfigSchema,
|
|
45
45
|
cache: cacheConfigSchema,
|
|
46
46
|
transport: transportNameSchema.default('graphql'),
|
package/dist/types/config.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"config.js","sourceRoot":"","sources":["../../src/types/config.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAGxB,0CAA0C;AAC1C,MAAM,CAAC,MAAM,qBAAqB,GAAG,CAAC,CAAC,IAAI,CAAC,CAAC,MAAM,EAAE,QAAQ,EAAE,OAAO,CAAC,CAAC,CAAC;AAGzE,6DAA6D;AAC7D,MAAM,CAAC,MAAM,mBAAmB,GAAG,CAAC,CAAC,IAAI,CAAC,CAAC,SAAS,EAAE,MAAM,CAAC,CAAC,CAAC;AAG/D,MAAM,iBAAiB,GAAG,CAAC;KACxB,MAAM,CAAC;IACN,M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AE,EAAE,CAAC,OAAO,GAAG,KAAK,UAAU,CACnC;SACA,QAAQ,EAAE;CACd,CAAC;KACD,QAAQ,EAAE,CAAC;AAEd;;;;;GAKG;AACH,MAAM,CAAC,MAAM,sBAAsB,GAAG,CAAC,CAAC,MAAM,CAAC;IAC7C,GAAG,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,EAAE;IACrB,KAAK,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,QAAQ,EAAE;IACnC,OAAO,EAAE,mBAAmB;IAC5B,KAAK,EAAE,iBAAiB;IACxB,SAAS,EAAE,mBAAmB,CAAC,OAAO,CAAC,SAAS,CAAC;IACjD,OAAO,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,EAAE,CAAC,QAAQ,EAAE,CAAC,OAAO,CAAC,IAAI,CAAC;IAClD,KAAK,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC;IACzC,KAAK,EAAE,CAAC,CAAC,OAAO,EAAE,CAAC,OAAO,CAAC,KAAK,CAAC;CAClC,CAAC,CAAC","sourcesContent":["/**\n * Runtime configuration schema for strapi-revalidate.\n *\n * Validated with zod so misconfigurations surface at startup rather than\n * at the first cache miss or webhook delivery.\n */\n\nimport { z } from 'zod';\nimport type { WebhookEvent } from '../webhook/types.js';\n\n/** Supported cache driver identifiers. */\nexport const cacheDriverNameSchema = z.enum(['file', 'memory', 'redis']);\nexport type CacheDriverName = z.infer<typeof cacheDriverNameSchema>;\n\n/** Supported transport identifiers for the Strapi client. */\nexport const transportNameSchema = z.enum(['graphql', 'rest']);\nexport type TransportName = z.infer<typeof transportNameSchema>;\n\nconst cacheConfigSchema = z\n .object({\n driver: cacheDriverNameSchema.default('file'),\n ttl: z.number().int().positive().default(3600),\n dir: z.string().default('.cache/strapi-revalidate'),\n fallbackDir: z.string().default('.cache/strapi-fallback'),\n redisUrl: z.string().url().optional(),\n keyPrefix: z.string().optional(),\n })\n .default({});\n\nconst webhookConfigSchema = z\n .object({\n secret: z.string().optional(),\n tagMap: z.record(z.array(z.string())).optional(),\n // `z.function().args(...).returns(...)` is a zod v3-only chain — v4 reshaped\n // the function schema API and removed it. Use `z.custom` instead so the schema\n // loads under either major version. Runtime validation still ensures the value\n // is a function; the TS-level signature carries the typed shape.\n onRevalidate: z\n .custom<(event: WebhookEvent) => void | Promise<void>>(\n (val) => typeof val === 'function'\n )\n .optional(),\n })\n .optional();\n\n/**\n * Full runtime configuration schema.\n *\n * Use `revalidateConfigSchema.parse(input)` to validate user input and\n * apply defaults in one step.\n */\nexport const revalidateConfigSchema = z.object({\n url: z.string().url(),\n token: z.string().min(1).optional(),\n webhook: webhookConfigSchema,\n cache: cacheConfigSchema,\n transport: transportNameSchema.default('graphql'),\n timeout: z.number().int().positive().default(3000),\n retry: z.number().int().min(0).default(2),\n debug: z.boolean().default(false),\n});\n\n/** User-supplied configuration (pre-validation). */\nexport type RevalidateConfigInput = z.input<typeof revalidateConfigSchema>;\n\n/** Validated, defaults-applied configuration. */\nexport type RevalidateConfig = z.output<typeof revalidateConfigSchema>;\n"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@datum-cloud/strapi-revalidate",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.2.0",
|
|
4
4
|
"description": "Framework-agnostic runtime cache invalidation for Strapi v5 in SSR frontends. Receives Strapi publish webhooks, clears affected cache tags, next request serves fresh data.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"strapi",
|