@nexushub/client 0.5.9 → 0.6.1
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/{chunk-NOIMIIA5.js → chunk-HUABKET6.js} +2 -2
- package/dist/{chunk-VFVPDENW.cjs → chunk-WZ47UVA2.cjs} +2 -2
- package/dist/cli.cjs +34 -34
- package/dist/content/local-cache-server.cjs +2 -2
- package/dist/content/local-cache-server.js +2 -2
- package/dist/index.cjs +13 -50
- package/dist/index.d.cts +11 -23
- package/dist/index.d.ts +11 -23
- package/dist/index.js +13 -50
- package/dist/{local-cache-server-VL4YNBME.js → local-cache-server-667T23JJ.js} +1 -1
- package/dist/{local-cache-server-SGSGWUCL.cjs → local-cache-server-S5KIABVH.cjs} +2 -2
- package/dist/react.cjs +15 -52
- package/dist/react.d.cts +9 -21
- package/dist/react.d.ts +9 -21
- package/dist/react.js +13 -50
- package/dist/studio/assets/{BoQ-SWw9.js → Bqyy7TUK.js} +1 -1
- package/dist/studio/index.html +1 -1
- package/package.json +1 -1
|
@@ -37,9 +37,9 @@ var import_fs = __toESM(require("fs"), 1);
|
|
|
37
37
|
var import_path = __toESM(require("path"), 1);
|
|
38
38
|
|
|
39
39
|
// src/config.ts
|
|
40
|
-
var DEFAULT_API_URL = "https://
|
|
40
|
+
var DEFAULT_API_URL = "https://gnapex.gnexus.co.tz";
|
|
41
41
|
var DEFAULT_ANALYTICS_URL = "https://sentry.gnexus.co.tz";
|
|
42
|
-
var LOCAL_NEST_URL = "https://
|
|
42
|
+
var LOCAL_NEST_URL = "https://gnapex.gnexus.co.tz";
|
|
43
43
|
var LOCAL_RUST_URL = "https://sentry.gnexus.co.tz";
|
|
44
44
|
var getEnvConfig = () => {
|
|
45
45
|
const NEXT_PUBLIC_ID = typeof process !== "undefined" ? process.env.NEXT_PUBLIC_NEXUS_ID : void 0;
|
|
@@ -3,9 +3,9 @@ import fs from "fs";
|
|
|
3
3
|
import path from "path";
|
|
4
4
|
|
|
5
5
|
// src/config.ts
|
|
6
|
-
var DEFAULT_API_URL = "https://
|
|
6
|
+
var DEFAULT_API_URL = "https://gnapex.gnexus.co.tz";
|
|
7
7
|
var DEFAULT_ANALYTICS_URL = "https://sentry.gnexus.co.tz";
|
|
8
|
-
var LOCAL_NEST_URL = "https://
|
|
8
|
+
var LOCAL_NEST_URL = "https://gnapex.gnexus.co.tz";
|
|
9
9
|
var LOCAL_RUST_URL = "https://sentry.gnexus.co.tz";
|
|
10
10
|
var getEnvConfig = () => {
|
|
11
11
|
const NEXT_PUBLIC_ID = typeof process !== "undefined" ? process.env.NEXT_PUBLIC_NEXUS_ID : void 0;
|
package/dist/index.cjs
CHANGED
|
@@ -35,9 +35,9 @@ var DEFAULT_API_URL, DEFAULT_ANALYTICS_URL, LOCAL_NEST_URL, LOCAL_RUST_URL, getE
|
|
|
35
35
|
var init_config = __esm({
|
|
36
36
|
"src/config.ts"() {
|
|
37
37
|
"use strict";
|
|
38
|
-
DEFAULT_API_URL = "https://
|
|
38
|
+
DEFAULT_API_URL = "https://gnapex.gnexus.co.tz";
|
|
39
39
|
DEFAULT_ANALYTICS_URL = "https://sentry.gnexus.co.tz";
|
|
40
|
-
LOCAL_NEST_URL = "https://
|
|
40
|
+
LOCAL_NEST_URL = "https://gnapex.gnexus.co.tz";
|
|
41
41
|
LOCAL_RUST_URL = "https://sentry.gnexus.co.tz";
|
|
42
42
|
getEnvConfig = () => {
|
|
43
43
|
const NEXT_PUBLIC_ID = typeof process !== "undefined" ? process.env.NEXT_PUBLIC_NEXUS_ID : void 0;
|
|
@@ -936,7 +936,7 @@ var ContentEngine = class {
|
|
|
936
936
|
});
|
|
937
937
|
this.requestBatcher = new RequestBatcher(20, 50);
|
|
938
938
|
this.circuitBreaker = new CircuitBreaker();
|
|
939
|
-
this.defaultRevalidate = config.revalidateTime ||
|
|
939
|
+
this.defaultRevalidate = config.revalidateTime || false;
|
|
940
940
|
this.cacheStrategy = config.cacheStrategy || "memory";
|
|
941
941
|
if (!this.isServer) {
|
|
942
942
|
window.addEventListener("beforeunload", this.cleanup.bind(this));
|
|
@@ -1062,7 +1062,7 @@ var ContentEngine = class {
|
|
|
1062
1062
|
}
|
|
1063
1063
|
this.memoryCache.set(cacheKey, result, {
|
|
1064
1064
|
tags: [...tags, CacheTags.collection(collectionId)],
|
|
1065
|
-
revalidate
|
|
1065
|
+
revalidate: revalidate === false ? void 0 : revalidate
|
|
1066
1066
|
});
|
|
1067
1067
|
return result;
|
|
1068
1068
|
}
|
|
@@ -1125,7 +1125,7 @@ var ContentEngine = class {
|
|
|
1125
1125
|
if (localGlobals) {
|
|
1126
1126
|
this.memoryCache.set(cacheKey, localGlobals, {
|
|
1127
1127
|
tags: [CacheTags.global],
|
|
1128
|
-
revalidate
|
|
1128
|
+
revalidate: revalidate === false ? void 0 : revalidate
|
|
1129
1129
|
});
|
|
1130
1130
|
return localGlobals;
|
|
1131
1131
|
}
|
|
@@ -1333,54 +1333,15 @@ var ContentEngine = class {
|
|
|
1333
1333
|
return null;
|
|
1334
1334
|
}
|
|
1335
1335
|
writeCache(key, data, options) {
|
|
1336
|
+
const numericRevalidate = options.revalidate === false ? 31536e5 : options.revalidate;
|
|
1336
1337
|
if (this.cacheStrategy === "memory") {
|
|
1337
1338
|
this.memoryCache.set(key, data, {
|
|
1338
1339
|
tags: options.tags,
|
|
1339
|
-
revalidate:
|
|
1340
|
+
revalidate: numericRevalidate
|
|
1340
1341
|
});
|
|
1341
1342
|
}
|
|
1342
1343
|
if (!this.isServer && this.cacheStrategy === "localStorage" && this.browserCache) {
|
|
1343
|
-
this.browserCache.set(key, data,
|
|
1344
|
-
}
|
|
1345
|
-
}
|
|
1346
|
-
// packages/client-sdk/src/content/index.ts
|
|
1347
|
-
/**
|
|
1348
|
-
* ⚡ THE PULSE: Next.js Cache Revalidation Receiver
|
|
1349
|
-
* Used in app/api/nexus-revalidate/route.ts to handle instant updates from the NexusHub backend.
|
|
1350
|
-
*
|
|
1351
|
-
* @param req The incoming Request object from Next.js
|
|
1352
|
-
* @param revalidateFn The revalidateTag function imported from 'next/cache'
|
|
1353
|
-
*/
|
|
1354
|
-
async handleRevalidation(req, revalidateFn) {
|
|
1355
|
-
try {
|
|
1356
|
-
if (!req.body) {
|
|
1357
|
-
return { success: false, message: "Missing Pulse Payload" };
|
|
1358
|
-
}
|
|
1359
|
-
const body = await req.json();
|
|
1360
|
-
const { secret, tag } = body;
|
|
1361
|
-
if (!secret || secret !== this.config.projectId) {
|
|
1362
|
-
if (this.config.debug) {
|
|
1363
|
-
console.warn(`[NexusHub] \u26A0\uFE0F Blocked unauthorized Pulse request.`);
|
|
1364
|
-
}
|
|
1365
|
-
return { success: false, message: "Invalid Pulse Signature" };
|
|
1366
|
-
}
|
|
1367
|
-
const targetTag = tag || "content_all";
|
|
1368
|
-
revalidateFn(targetTag);
|
|
1369
|
-
this.invalidateCache([targetTag]);
|
|
1370
|
-
if (this.config.debug) {
|
|
1371
|
-
console.log(
|
|
1372
|
-
`[NexusHub] \u26A1 Pulse Received: Successfully revalidated tag [${targetTag}]`
|
|
1373
|
-
);
|
|
1374
|
-
}
|
|
1375
|
-
return { success: true, now: Date.now() };
|
|
1376
|
-
} catch (e) {
|
|
1377
|
-
if (this.config.debug) {
|
|
1378
|
-
console.error(`[NexusHub] \u274C Pulse Processing Error:`, e.message);
|
|
1379
|
-
}
|
|
1380
|
-
return {
|
|
1381
|
-
success: false,
|
|
1382
|
-
message: "Malformed Pulse Payload or Processing Error"
|
|
1383
|
-
};
|
|
1344
|
+
this.browserCache.set(key, data, numericRevalidate * 1e3);
|
|
1384
1345
|
}
|
|
1385
1346
|
}
|
|
1386
1347
|
/**
|
|
@@ -1425,6 +1386,7 @@ var ContentEngine = class {
|
|
|
1425
1386
|
if (this.config.debug) {
|
|
1426
1387
|
console.log(`[NexusHub] \u{1F310} Fetching: ${url}`);
|
|
1427
1388
|
}
|
|
1389
|
+
const expiresAt = revalidate === false ? Infinity : Date.now() + revalidate * 1e3;
|
|
1428
1390
|
const res = await this.fetchWithTimeout(url, {
|
|
1429
1391
|
method: "GET",
|
|
1430
1392
|
headers: this.getHeaders(),
|
|
@@ -1446,7 +1408,7 @@ var ContentEngine = class {
|
|
|
1446
1408
|
metadata: {
|
|
1447
1409
|
timestamp: Date.now(),
|
|
1448
1410
|
etag: etag || void 0,
|
|
1449
|
-
expiresAt
|
|
1411
|
+
expiresAt,
|
|
1450
1412
|
tags: [...tags, CacheTags.content(slug)]
|
|
1451
1413
|
}
|
|
1452
1414
|
};
|
|
@@ -1477,12 +1439,13 @@ var ContentEngine = class {
|
|
|
1477
1439
|
}
|
|
1478
1440
|
const json = await res.json();
|
|
1479
1441
|
const etag = res.headers.get("etag");
|
|
1442
|
+
const expiresAt = revalidate === false ? Infinity : Date.now() + revalidate * 1e3;
|
|
1480
1443
|
const cacheEntry = {
|
|
1481
1444
|
data: json,
|
|
1482
1445
|
metadata: {
|
|
1483
1446
|
timestamp: Date.now(),
|
|
1484
1447
|
etag: etag || void 0,
|
|
1485
|
-
expiresAt
|
|
1448
|
+
expiresAt,
|
|
1486
1449
|
tags: [...tags, CacheTags.collection(collectionId)]
|
|
1487
1450
|
}
|
|
1488
1451
|
};
|
|
@@ -2585,7 +2548,7 @@ var NexusClient = class {
|
|
|
2585
2548
|
this.config = {
|
|
2586
2549
|
debug: config?.debug ?? false,
|
|
2587
2550
|
cacheStrategy: config?.cacheStrategy ?? "memory",
|
|
2588
|
-
revalidateTime: config?.revalidateTime ??
|
|
2551
|
+
revalidateTime: config?.revalidateTime ?? false,
|
|
2589
2552
|
timeout: config?.timeout ?? 1e4,
|
|
2590
2553
|
retries: config?.retries ?? 3,
|
|
2591
2554
|
...fullConfig
|
package/dist/index.d.cts
CHANGED
|
@@ -6,9 +6,9 @@ interface MinimalNexusConfig {
|
|
|
6
6
|
apiKey?: string;
|
|
7
7
|
projectId?: string;
|
|
8
8
|
}
|
|
9
|
-
declare const DEFAULT_API_URL = "https://
|
|
9
|
+
declare const DEFAULT_API_URL = "https://gnapex.gnexus.co.tz";
|
|
10
10
|
declare const DEFAULT_ANALYTICS_URL = "https://sentry.gnexus.co.tz";
|
|
11
|
-
declare const LOCAL_NEST_URL = "https://
|
|
11
|
+
declare const LOCAL_NEST_URL = "https://gnapex.gnexus.co.tz";
|
|
12
12
|
declare const LOCAL_RUST_URL = "https://sentry.gnexus.co.tz";
|
|
13
13
|
declare const getEnvConfig: () => MinimalNexusConfig;
|
|
14
14
|
declare const mergeConfigs: (base: MinimalNexusConfig, override: Partial<MinimalNexusConfig>) => MinimalNexusConfig;
|
|
@@ -17,8 +17,8 @@ declare const validateConfig: (config: MinimalNexusConfig) => string[];
|
|
|
17
17
|
|
|
18
18
|
interface NexusConfig extends MinimalNexusConfig {
|
|
19
19
|
debug?: boolean;
|
|
20
|
-
cacheStrategy?:
|
|
21
|
-
revalidateTime?: number;
|
|
20
|
+
cacheStrategy?: "memory" | "localStorage" | "none";
|
|
21
|
+
revalidateTime?: number | false;
|
|
22
22
|
timeout?: number;
|
|
23
23
|
retries?: number;
|
|
24
24
|
}
|
|
@@ -34,7 +34,7 @@ interface ContentResponse<T = any> {
|
|
|
34
34
|
version: number;
|
|
35
35
|
updatedAt: string;
|
|
36
36
|
locale?: string;
|
|
37
|
-
cacheStatus:
|
|
37
|
+
cacheStatus: "hit" | "miss" | "stale";
|
|
38
38
|
};
|
|
39
39
|
}
|
|
40
40
|
interface CollectionResponse<T = any> {
|
|
@@ -65,7 +65,7 @@ interface CollectionQuery {
|
|
|
65
65
|
page?: number;
|
|
66
66
|
limit?: number;
|
|
67
67
|
sort?: string;
|
|
68
|
-
order?:
|
|
68
|
+
order?: "asc" | "desc";
|
|
69
69
|
filter?: Record<string, any>;
|
|
70
70
|
fields?: string[];
|
|
71
71
|
search?: string;
|
|
@@ -96,7 +96,7 @@ declare class ContentEngine {
|
|
|
96
96
|
* Fetch a Single Page with full strategy pipeline
|
|
97
97
|
*/
|
|
98
98
|
getPage<T = any>(slug: string, options?: {
|
|
99
|
-
revalidate?: number;
|
|
99
|
+
revalidate?: number | false;
|
|
100
100
|
tags?: string[];
|
|
101
101
|
forceRefresh?: boolean;
|
|
102
102
|
includeMetadata?: boolean;
|
|
@@ -106,7 +106,7 @@ declare class ContentEngine {
|
|
|
106
106
|
* Fetch a Collection (Optimized)
|
|
107
107
|
*/
|
|
108
108
|
getCollection<T = any>(collectionId: string, query?: CollectionQuery, options?: {
|
|
109
|
-
revalidate?: number;
|
|
109
|
+
revalidate?: number | false;
|
|
110
110
|
tags?: string[];
|
|
111
111
|
forceRefresh?: boolean;
|
|
112
112
|
includeMetadata?: boolean;
|
|
@@ -117,7 +117,7 @@ declare class ContentEngine {
|
|
|
117
117
|
*/
|
|
118
118
|
getGlobals<T = any>(options?: {
|
|
119
119
|
include?: string[];
|
|
120
|
-
revalidate?: number;
|
|
120
|
+
revalidate?: number | false;
|
|
121
121
|
forceRefresh?: boolean;
|
|
122
122
|
}): Promise<T>;
|
|
123
123
|
/**
|
|
@@ -125,7 +125,7 @@ declare class ContentEngine {
|
|
|
125
125
|
* If you call this 10 times in a loop, it sends 1 HTTP request.
|
|
126
126
|
*/
|
|
127
127
|
getItem<T = any>(collectionId: string, itemId: string, options?: {
|
|
128
|
-
revalidate?: number;
|
|
128
|
+
revalidate?: number | false;
|
|
129
129
|
tags?: string[];
|
|
130
130
|
include?: string[];
|
|
131
131
|
}): Promise<T>;
|
|
@@ -136,7 +136,7 @@ declare class ContentEngine {
|
|
|
136
136
|
collections?: string[];
|
|
137
137
|
fields?: string[];
|
|
138
138
|
limit?: number;
|
|
139
|
-
revalidate?: number;
|
|
139
|
+
revalidate?: number | false;
|
|
140
140
|
}): Promise<{
|
|
141
141
|
results: T[];
|
|
142
142
|
total: number;
|
|
@@ -154,18 +154,6 @@ declare class ContentEngine {
|
|
|
154
154
|
*/
|
|
155
155
|
private checkCaches;
|
|
156
156
|
private writeCache;
|
|
157
|
-
/**
|
|
158
|
-
* ⚡ THE PULSE: Next.js Cache Revalidation Receiver
|
|
159
|
-
* Used in app/api/nexus-revalidate/route.ts to handle instant updates from the NexusHub backend.
|
|
160
|
-
*
|
|
161
|
-
* @param req The incoming Request object from Next.js
|
|
162
|
-
* @param revalidateFn The revalidateTag function imported from 'next/cache'
|
|
163
|
-
*/
|
|
164
|
-
handleRevalidation(req: Request, revalidateFn: (tag: string) => void): Promise<{
|
|
165
|
-
success: boolean;
|
|
166
|
-
message?: string;
|
|
167
|
-
now?: number;
|
|
168
|
-
}>;
|
|
169
157
|
/**
|
|
170
158
|
* Invalidate cache by tags
|
|
171
159
|
*/
|
package/dist/index.d.ts
CHANGED
|
@@ -6,9 +6,9 @@ interface MinimalNexusConfig {
|
|
|
6
6
|
apiKey?: string;
|
|
7
7
|
projectId?: string;
|
|
8
8
|
}
|
|
9
|
-
declare const DEFAULT_API_URL = "https://
|
|
9
|
+
declare const DEFAULT_API_URL = "https://gnapex.gnexus.co.tz";
|
|
10
10
|
declare const DEFAULT_ANALYTICS_URL = "https://sentry.gnexus.co.tz";
|
|
11
|
-
declare const LOCAL_NEST_URL = "https://
|
|
11
|
+
declare const LOCAL_NEST_URL = "https://gnapex.gnexus.co.tz";
|
|
12
12
|
declare const LOCAL_RUST_URL = "https://sentry.gnexus.co.tz";
|
|
13
13
|
declare const getEnvConfig: () => MinimalNexusConfig;
|
|
14
14
|
declare const mergeConfigs: (base: MinimalNexusConfig, override: Partial<MinimalNexusConfig>) => MinimalNexusConfig;
|
|
@@ -17,8 +17,8 @@ declare const validateConfig: (config: MinimalNexusConfig) => string[];
|
|
|
17
17
|
|
|
18
18
|
interface NexusConfig extends MinimalNexusConfig {
|
|
19
19
|
debug?: boolean;
|
|
20
|
-
cacheStrategy?:
|
|
21
|
-
revalidateTime?: number;
|
|
20
|
+
cacheStrategy?: "memory" | "localStorage" | "none";
|
|
21
|
+
revalidateTime?: number | false;
|
|
22
22
|
timeout?: number;
|
|
23
23
|
retries?: number;
|
|
24
24
|
}
|
|
@@ -34,7 +34,7 @@ interface ContentResponse<T = any> {
|
|
|
34
34
|
version: number;
|
|
35
35
|
updatedAt: string;
|
|
36
36
|
locale?: string;
|
|
37
|
-
cacheStatus:
|
|
37
|
+
cacheStatus: "hit" | "miss" | "stale";
|
|
38
38
|
};
|
|
39
39
|
}
|
|
40
40
|
interface CollectionResponse<T = any> {
|
|
@@ -65,7 +65,7 @@ interface CollectionQuery {
|
|
|
65
65
|
page?: number;
|
|
66
66
|
limit?: number;
|
|
67
67
|
sort?: string;
|
|
68
|
-
order?:
|
|
68
|
+
order?: "asc" | "desc";
|
|
69
69
|
filter?: Record<string, any>;
|
|
70
70
|
fields?: string[];
|
|
71
71
|
search?: string;
|
|
@@ -96,7 +96,7 @@ declare class ContentEngine {
|
|
|
96
96
|
* Fetch a Single Page with full strategy pipeline
|
|
97
97
|
*/
|
|
98
98
|
getPage<T = any>(slug: string, options?: {
|
|
99
|
-
revalidate?: number;
|
|
99
|
+
revalidate?: number | false;
|
|
100
100
|
tags?: string[];
|
|
101
101
|
forceRefresh?: boolean;
|
|
102
102
|
includeMetadata?: boolean;
|
|
@@ -106,7 +106,7 @@ declare class ContentEngine {
|
|
|
106
106
|
* Fetch a Collection (Optimized)
|
|
107
107
|
*/
|
|
108
108
|
getCollection<T = any>(collectionId: string, query?: CollectionQuery, options?: {
|
|
109
|
-
revalidate?: number;
|
|
109
|
+
revalidate?: number | false;
|
|
110
110
|
tags?: string[];
|
|
111
111
|
forceRefresh?: boolean;
|
|
112
112
|
includeMetadata?: boolean;
|
|
@@ -117,7 +117,7 @@ declare class ContentEngine {
|
|
|
117
117
|
*/
|
|
118
118
|
getGlobals<T = any>(options?: {
|
|
119
119
|
include?: string[];
|
|
120
|
-
revalidate?: number;
|
|
120
|
+
revalidate?: number | false;
|
|
121
121
|
forceRefresh?: boolean;
|
|
122
122
|
}): Promise<T>;
|
|
123
123
|
/**
|
|
@@ -125,7 +125,7 @@ declare class ContentEngine {
|
|
|
125
125
|
* If you call this 10 times in a loop, it sends 1 HTTP request.
|
|
126
126
|
*/
|
|
127
127
|
getItem<T = any>(collectionId: string, itemId: string, options?: {
|
|
128
|
-
revalidate?: number;
|
|
128
|
+
revalidate?: number | false;
|
|
129
129
|
tags?: string[];
|
|
130
130
|
include?: string[];
|
|
131
131
|
}): Promise<T>;
|
|
@@ -136,7 +136,7 @@ declare class ContentEngine {
|
|
|
136
136
|
collections?: string[];
|
|
137
137
|
fields?: string[];
|
|
138
138
|
limit?: number;
|
|
139
|
-
revalidate?: number;
|
|
139
|
+
revalidate?: number | false;
|
|
140
140
|
}): Promise<{
|
|
141
141
|
results: T[];
|
|
142
142
|
total: number;
|
|
@@ -154,18 +154,6 @@ declare class ContentEngine {
|
|
|
154
154
|
*/
|
|
155
155
|
private checkCaches;
|
|
156
156
|
private writeCache;
|
|
157
|
-
/**
|
|
158
|
-
* ⚡ THE PULSE: Next.js Cache Revalidation Receiver
|
|
159
|
-
* Used in app/api/nexus-revalidate/route.ts to handle instant updates from the NexusHub backend.
|
|
160
|
-
*
|
|
161
|
-
* @param req The incoming Request object from Next.js
|
|
162
|
-
* @param revalidateFn The revalidateTag function imported from 'next/cache'
|
|
163
|
-
*/
|
|
164
|
-
handleRevalidation(req: Request, revalidateFn: (tag: string) => void): Promise<{
|
|
165
|
-
success: boolean;
|
|
166
|
-
message?: string;
|
|
167
|
-
now?: number;
|
|
168
|
-
}>;
|
|
169
157
|
/**
|
|
170
158
|
* Invalidate cache by tags
|
|
171
159
|
*/
|
package/dist/index.js
CHANGED
|
@@ -13,9 +13,9 @@ var DEFAULT_API_URL, DEFAULT_ANALYTICS_URL, LOCAL_NEST_URL, LOCAL_RUST_URL, getE
|
|
|
13
13
|
var init_config = __esm({
|
|
14
14
|
"src/config.ts"() {
|
|
15
15
|
"use strict";
|
|
16
|
-
DEFAULT_API_URL = "https://
|
|
16
|
+
DEFAULT_API_URL = "https://gnapex.gnexus.co.tz";
|
|
17
17
|
DEFAULT_ANALYTICS_URL = "https://sentry.gnexus.co.tz";
|
|
18
|
-
LOCAL_NEST_URL = "https://
|
|
18
|
+
LOCAL_NEST_URL = "https://gnapex.gnexus.co.tz";
|
|
19
19
|
LOCAL_RUST_URL = "https://sentry.gnexus.co.tz";
|
|
20
20
|
getEnvConfig = () => {
|
|
21
21
|
const NEXT_PUBLIC_ID = typeof process !== "undefined" ? process.env.NEXT_PUBLIC_NEXUS_ID : void 0;
|
|
@@ -890,7 +890,7 @@ var ContentEngine = class {
|
|
|
890
890
|
});
|
|
891
891
|
this.requestBatcher = new RequestBatcher(20, 50);
|
|
892
892
|
this.circuitBreaker = new CircuitBreaker();
|
|
893
|
-
this.defaultRevalidate = config.revalidateTime ||
|
|
893
|
+
this.defaultRevalidate = config.revalidateTime || false;
|
|
894
894
|
this.cacheStrategy = config.cacheStrategy || "memory";
|
|
895
895
|
if (!this.isServer) {
|
|
896
896
|
window.addEventListener("beforeunload", this.cleanup.bind(this));
|
|
@@ -1016,7 +1016,7 @@ var ContentEngine = class {
|
|
|
1016
1016
|
}
|
|
1017
1017
|
this.memoryCache.set(cacheKey, result, {
|
|
1018
1018
|
tags: [...tags, CacheTags.collection(collectionId)],
|
|
1019
|
-
revalidate
|
|
1019
|
+
revalidate: revalidate === false ? void 0 : revalidate
|
|
1020
1020
|
});
|
|
1021
1021
|
return result;
|
|
1022
1022
|
}
|
|
@@ -1079,7 +1079,7 @@ var ContentEngine = class {
|
|
|
1079
1079
|
if (localGlobals) {
|
|
1080
1080
|
this.memoryCache.set(cacheKey, localGlobals, {
|
|
1081
1081
|
tags: [CacheTags.global],
|
|
1082
|
-
revalidate
|
|
1082
|
+
revalidate: revalidate === false ? void 0 : revalidate
|
|
1083
1083
|
});
|
|
1084
1084
|
return localGlobals;
|
|
1085
1085
|
}
|
|
@@ -1287,54 +1287,15 @@ var ContentEngine = class {
|
|
|
1287
1287
|
return null;
|
|
1288
1288
|
}
|
|
1289
1289
|
writeCache(key, data, options) {
|
|
1290
|
+
const numericRevalidate = options.revalidate === false ? 31536e5 : options.revalidate;
|
|
1290
1291
|
if (this.cacheStrategy === "memory") {
|
|
1291
1292
|
this.memoryCache.set(key, data, {
|
|
1292
1293
|
tags: options.tags,
|
|
1293
|
-
revalidate:
|
|
1294
|
+
revalidate: numericRevalidate
|
|
1294
1295
|
});
|
|
1295
1296
|
}
|
|
1296
1297
|
if (!this.isServer && this.cacheStrategy === "localStorage" && this.browserCache) {
|
|
1297
|
-
this.browserCache.set(key, data,
|
|
1298
|
-
}
|
|
1299
|
-
}
|
|
1300
|
-
// packages/client-sdk/src/content/index.ts
|
|
1301
|
-
/**
|
|
1302
|
-
* ⚡ THE PULSE: Next.js Cache Revalidation Receiver
|
|
1303
|
-
* Used in app/api/nexus-revalidate/route.ts to handle instant updates from the NexusHub backend.
|
|
1304
|
-
*
|
|
1305
|
-
* @param req The incoming Request object from Next.js
|
|
1306
|
-
* @param revalidateFn The revalidateTag function imported from 'next/cache'
|
|
1307
|
-
*/
|
|
1308
|
-
async handleRevalidation(req, revalidateFn) {
|
|
1309
|
-
try {
|
|
1310
|
-
if (!req.body) {
|
|
1311
|
-
return { success: false, message: "Missing Pulse Payload" };
|
|
1312
|
-
}
|
|
1313
|
-
const body = await req.json();
|
|
1314
|
-
const { secret, tag } = body;
|
|
1315
|
-
if (!secret || secret !== this.config.projectId) {
|
|
1316
|
-
if (this.config.debug) {
|
|
1317
|
-
console.warn(`[NexusHub] \u26A0\uFE0F Blocked unauthorized Pulse request.`);
|
|
1318
|
-
}
|
|
1319
|
-
return { success: false, message: "Invalid Pulse Signature" };
|
|
1320
|
-
}
|
|
1321
|
-
const targetTag = tag || "content_all";
|
|
1322
|
-
revalidateFn(targetTag);
|
|
1323
|
-
this.invalidateCache([targetTag]);
|
|
1324
|
-
if (this.config.debug) {
|
|
1325
|
-
console.log(
|
|
1326
|
-
`[NexusHub] \u26A1 Pulse Received: Successfully revalidated tag [${targetTag}]`
|
|
1327
|
-
);
|
|
1328
|
-
}
|
|
1329
|
-
return { success: true, now: Date.now() };
|
|
1330
|
-
} catch (e) {
|
|
1331
|
-
if (this.config.debug) {
|
|
1332
|
-
console.error(`[NexusHub] \u274C Pulse Processing Error:`, e.message);
|
|
1333
|
-
}
|
|
1334
|
-
return {
|
|
1335
|
-
success: false,
|
|
1336
|
-
message: "Malformed Pulse Payload or Processing Error"
|
|
1337
|
-
};
|
|
1298
|
+
this.browserCache.set(key, data, numericRevalidate * 1e3);
|
|
1338
1299
|
}
|
|
1339
1300
|
}
|
|
1340
1301
|
/**
|
|
@@ -1379,6 +1340,7 @@ var ContentEngine = class {
|
|
|
1379
1340
|
if (this.config.debug) {
|
|
1380
1341
|
console.log(`[NexusHub] \u{1F310} Fetching: ${url}`);
|
|
1381
1342
|
}
|
|
1343
|
+
const expiresAt = revalidate === false ? Infinity : Date.now() + revalidate * 1e3;
|
|
1382
1344
|
const res = await this.fetchWithTimeout(url, {
|
|
1383
1345
|
method: "GET",
|
|
1384
1346
|
headers: this.getHeaders(),
|
|
@@ -1400,7 +1362,7 @@ var ContentEngine = class {
|
|
|
1400
1362
|
metadata: {
|
|
1401
1363
|
timestamp: Date.now(),
|
|
1402
1364
|
etag: etag || void 0,
|
|
1403
|
-
expiresAt
|
|
1365
|
+
expiresAt,
|
|
1404
1366
|
tags: [...tags, CacheTags.content(slug)]
|
|
1405
1367
|
}
|
|
1406
1368
|
};
|
|
@@ -1431,12 +1393,13 @@ var ContentEngine = class {
|
|
|
1431
1393
|
}
|
|
1432
1394
|
const json = await res.json();
|
|
1433
1395
|
const etag = res.headers.get("etag");
|
|
1396
|
+
const expiresAt = revalidate === false ? Infinity : Date.now() + revalidate * 1e3;
|
|
1434
1397
|
const cacheEntry = {
|
|
1435
1398
|
data: json,
|
|
1436
1399
|
metadata: {
|
|
1437
1400
|
timestamp: Date.now(),
|
|
1438
1401
|
etag: etag || void 0,
|
|
1439
|
-
expiresAt
|
|
1402
|
+
expiresAt,
|
|
1440
1403
|
tags: [...tags, CacheTags.collection(collectionId)]
|
|
1441
1404
|
}
|
|
1442
1405
|
};
|
|
@@ -2539,7 +2502,7 @@ var NexusClient = class {
|
|
|
2539
2502
|
this.config = {
|
|
2540
2503
|
debug: config?.debug ?? false,
|
|
2541
2504
|
cacheStrategy: config?.cacheStrategy ?? "memory",
|
|
2542
|
-
revalidateTime: config?.revalidateTime ??
|
|
2505
|
+
revalidateTime: config?.revalidateTime ?? false,
|
|
2543
2506
|
timeout: config?.timeout ?? 1e4,
|
|
2544
2507
|
retries: config?.retries ?? 3,
|
|
2545
2508
|
...fullConfig
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { newObj[key] = obj[key]; } } } newObj.default = obj; return newObj; } } function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
2
2
|
|
|
3
|
-
var
|
|
3
|
+
var _chunkWZ47UVA2cjs = require('./chunk-WZ47UVA2.cjs');
|
|
4
4
|
|
|
5
5
|
// src/content/local-cache-server.ts
|
|
6
6
|
var _fs = require('fs'); var _fs2 = _interopRequireDefault(_fs);
|
|
@@ -109,7 +109,7 @@ var LocalCache = class {
|
|
|
109
109
|
constructor(customPath, apiKey) {
|
|
110
110
|
this.apiKey = "";
|
|
111
111
|
this.baseDir = customPath || ".nexus/local";
|
|
112
|
-
const config =
|
|
112
|
+
const config = _chunkWZ47UVA2cjs.getEnvConfig.call(void 0, );
|
|
113
113
|
this.apiKey = apiKey || config.apiKey || "";
|
|
114
114
|
}
|
|
115
115
|
isLoaded() {
|