@nexushub/client 0.7.5 → 0.7.7
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.cjs +32 -9
- package/dist/index.cjs +24 -18
- package/dist/index.js +24 -18
- package/dist/react.cjs +24 -18
- package/dist/react.js +24 -18
- package/package.json +1 -1
package/dist/cli.cjs
CHANGED
|
@@ -155,11 +155,12 @@ instead of making network calls. Edit the JSON files directly, then run
|
|
|
155
155
|
|
|
156
156
|
Empty schema values are intentional placeholders \u2014 fill them with your content.
|
|
157
157
|
`),W.includes("type_gen")&&(Oe.pages?.length||0)+(Oe.collections?.length||0)>0){let H=rc(Oe),Y=S.default.resolve(n,"types/nexus.d.ts");await w.default.ensureDir(S.default.dirname(Y)),await w.default.writeFile(Y,H),console.log(E(" + Generated types/nexus.d.ts"))}if(await Od(me),D.succeed(X("Workspace scaffolded")),i.id==="nextjs"){let H=S.default.join(n,"src/app"),Y=S.default.join(n,"app"),oe="";if(w.default.existsSync(H)?oe=S.default.join(H,"api","revalidate"):w.default.existsSync(Y)&&(oe=S.default.join(Y,"api","revalidate")),oe){let ye=S.default.join(oe,"route.ts");if(!await w.default.pathExists(ye)){let be=`import { NextRequest, NextResponse } from "next/server";
|
|
158
|
-
import { revalidatePath } from "next/cache";
|
|
158
|
+
import { revalidatePath, revalidateTag } from "next/cache";
|
|
159
159
|
|
|
160
160
|
export async function GET(request: NextRequest) {
|
|
161
161
|
const secret = request.nextUrl.searchParams.get("secret");
|
|
162
162
|
const apiKey = process.env.NEXT_PUBLIC_NEXUS_KEY || process.env.NEXUS_API_KEY;
|
|
163
|
+
const projectId = process.env.NEXT_PUBLIC_NEXUS_ID || process.env.NEXUS_PROJECT_ID;
|
|
163
164
|
|
|
164
165
|
// \u{1F6E1}\uFE0F Zero-Config Handshake: Validates incoming secret against their active SDK API Key
|
|
165
166
|
if (!secret || secret !== apiKey) {
|
|
@@ -167,16 +168,23 @@ export async function GET(request: NextRequest) {
|
|
|
167
168
|
}
|
|
168
169
|
|
|
169
170
|
try {
|
|
170
|
-
//
|
|
171
|
+
// 1. Clear the Full Route Cache (HTML Page Cache)
|
|
171
172
|
revalidatePath("/", "layout");
|
|
172
173
|
|
|
174
|
+
// 2. Clear the Next.js Data Cache (JSON Fetch Cache) using the global project tag
|
|
175
|
+
if (projectId) {
|
|
176
|
+
revalidateTag(\`nexus_project_\${projectId}\`);
|
|
177
|
+
}
|
|
178
|
+
|
|
173
179
|
return NextResponse.json({
|
|
174
180
|
revalidated: true,
|
|
175
181
|
now: Date.now(),
|
|
176
|
-
message: "
|
|
182
|
+
message: "Full stack edge caches successfully purged."
|
|
177
183
|
});
|
|
178
|
-
} catch (err:
|
|
179
|
-
|
|
184
|
+
} catch (err: unknown) {
|
|
185
|
+
// \u{1F6E1}\uFE0F Resolved: Explicit unknown typing to eliminate unsafe ESLint warnings
|
|
186
|
+
const errMsg = err instanceof Error ? err.message : String(err);
|
|
187
|
+
return NextResponse.json({ message: errMsg }, { status: 500 });
|
|
180
188
|
}
|
|
181
189
|
}
|
|
182
190
|
`;await w.default.ensureDir(oe),await w.default.writeFile(ye,be),console.log(E(" + Auto-Injected Next.js On-Demand Revalidation API Route"))}}}console.log(`
|
|
@@ -235,21 +243,36 @@ export async function GET(request: NextRequest) {
|
|
|
235
243
|
`+x.toString())}catch(d){m.warn(ce("Remote: Could not connect ("+d.message+")"))}console.log()}async function Gd(n){Te("Edge Deployment Protocol");let{apiKey:t,projectId:o,apiUrl:i}=rr(n),a=Zl(),l=a==="npm"?"npx":a==="bun"?"bunx":"pnpx",u=Ql(),p=Q("[1/4] Verifying project handshake...").start(),m;try{let C=await fe(`${i}/projects/${o}`,t);m=C?.data||C,p.succeed(R.green(`Connected: ${m.name}`))}catch(C){p.fail(Z("Cannot connect to NexusHub API: "+C.message)),process.exit(1)}if(!!(m.githubOwner&&m.githubRepo)){let C=Q("[2/4] Initiating remote build pipeline...").start();try{let y=await fe(`${i}/projects/${o}/deploy`,t,{method:"POST",body:{environment:n.environment||"production",trigger:"cli"}});C.succeed(X("Remote pipeline activated")),console.log(E(` Deployment ID: ${R.white(y.deploymentId||"\u2014")}`)),console.log(E(` Repository: ${R.white(m.githubOwner+"/"+m.githubRepo)}`)),console.log(R.cyan(`
|
|
236
244
|
\u2728 NexusHub is managing the build. Check your dashboard for progress.
|
|
237
245
|
`))}catch(y){C.fail(Z(y.message)),process.exit(1)}return}let h=oc();if(!h&&u.id==="nextjs"){let C=S.default.join(process.cwd(),"src/app"),y=S.default.join(process.cwd(),"app"),T="";if(w.default.existsSync(C)?T=S.default.join(C,"api","revalidate"):w.default.existsSync(y)&&(T=S.default.join(y,"api","revalidate")),T){let I=S.default.join(T,"route.ts");if(!await w.default.pathExists(I)){let O=`import { NextRequest, NextResponse } from "next/server";
|
|
238
|
-
import { revalidatePath } from "next/cache";
|
|
246
|
+
import { revalidatePath, revalidateTag } from "next/cache";
|
|
239
247
|
|
|
240
248
|
export async function GET(request: NextRequest) {
|
|
241
249
|
const secret = request.nextUrl.searchParams.get("secret");
|
|
242
250
|
const apiKey = process.env.NEXT_PUBLIC_NEXUS_KEY || process.env.NEXUS_API_KEY;
|
|
251
|
+
const projectId = process.env.NEXT_PUBLIC_NEXUS_ID || process.env.NEXUS_PROJECT_ID;
|
|
243
252
|
|
|
253
|
+
// \u{1F6E1}\uFE0F Zero-Config Handshake: Validates incoming secret against their active SDK API Key
|
|
244
254
|
if (!secret || secret !== apiKey) {
|
|
245
255
|
return NextResponse.json({ message: "Unauthorized Handshake" }, { status: 401 });
|
|
246
256
|
}
|
|
247
257
|
|
|
248
258
|
try {
|
|
259
|
+
// 1. Clear the Full Route Cache (HTML Page Cache)
|
|
249
260
|
revalidatePath("/", "layout");
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
261
|
+
|
|
262
|
+
// 2. Clear the Next.js Data Cache (JSON Fetch Cache) using the global project tag
|
|
263
|
+
if (projectId) {
|
|
264
|
+
revalidateTag(\`nexus_project_\${projectId}\`);
|
|
265
|
+
}
|
|
266
|
+
|
|
267
|
+
return NextResponse.json({
|
|
268
|
+
revalidated: true,
|
|
269
|
+
now: Date.now(),
|
|
270
|
+
message: "Full stack edge caches successfully purged."
|
|
271
|
+
});
|
|
272
|
+
} catch (err: unknown) {
|
|
273
|
+
// \u{1F6E1}\uFE0F Resolved: Explicit unknown typing to eliminate unsafe ESLint warnings
|
|
274
|
+
const errMsg = err instanceof Error ? err.message : String(err);
|
|
275
|
+
return NextResponse.json({ message: errMsg }, { status: 500 });
|
|
253
276
|
}
|
|
254
277
|
}
|
|
255
278
|
`;await w.default.ensureDir(T),await w.default.writeFile(I,O),console.log(E(" - Self-Healed: Regenerated missing Next.js revalidation route."))}}}let x=m.cloudflareProjectName||m.subdomain||"",A=S.default.resolve(process.cwd(),"wrangler.json");try{if(!h&&!w.default.existsSync(A)){let B={name:x,main:".open-next/worker.js",compatibility_date:"2024-09-25",compatibility_flags:["nodejs_compat"],assets:{directory:".open-next/assets"},r2_buckets:[{binding:"NEXT_INC_CACHE_R2_BUCKET",bucket_name:`${x}-cache-r2`}],vars:{NEXT_PUBLIC_NEXUS_ID:o,NEXT_PUBLIC_NEXUS_KEY:t,NEXT_PUBLIC_NEXUS_API_URL:i}};await w.default.writeJson(A,B,{spaces:2})}if(h){let B=Q("[2/4] Building static production artifacts...").start();try{(0,Ke.execSync)(`${a} run build`,{stdio:"pipe",env:{...process.env,NODE_ENV:"production",NODE_OPTIONS:"--dns-result-order=ipv4first"}}),B.succeed(X("Build complete"))}catch(v){B.fail(Z("Build failed")),v.stderr&&console.log(R.red(`
|
package/dist/index.cjs
CHANGED
|
@@ -1048,7 +1048,7 @@ var ContentEngine = class {
|
|
|
1048
1048
|
}
|
|
1049
1049
|
return includeMetadata ? cached : cached.data;
|
|
1050
1050
|
}
|
|
1051
|
-
if (!forceRefresh) {
|
|
1051
|
+
if (!forceRefresh && process.env.NODE_ENV === "development") {
|
|
1052
1052
|
try {
|
|
1053
1053
|
const localCollection = await this.localCache.getCollection(collectionId);
|
|
1054
1054
|
if (localCollection) {
|
|
@@ -1123,7 +1123,7 @@ var ContentEngine = class {
|
|
|
1123
1123
|
return cached;
|
|
1124
1124
|
}
|
|
1125
1125
|
}
|
|
1126
|
-
if (!forceRefresh) {
|
|
1126
|
+
if (!forceRefresh && process.env.NODE_ENV === "development") {
|
|
1127
1127
|
try {
|
|
1128
1128
|
const localGlobals = await this.localCache.getGlobals();
|
|
1129
1129
|
if (localGlobals) {
|
|
@@ -1318,22 +1318,24 @@ var ContentEngine = class {
|
|
|
1318
1318
|
};
|
|
1319
1319
|
}
|
|
1320
1320
|
}
|
|
1321
|
-
if (
|
|
1322
|
-
|
|
1323
|
-
|
|
1324
|
-
|
|
1325
|
-
|
|
1326
|
-
|
|
1327
|
-
|
|
1328
|
-
|
|
1329
|
-
|
|
1330
|
-
|
|
1331
|
-
|
|
1332
|
-
|
|
1333
|
-
|
|
1334
|
-
|
|
1321
|
+
if (process.env.NODE_ENV === "development") {
|
|
1322
|
+
if (key.startsWith("page:")) {
|
|
1323
|
+
const slug = key.split(":")[1];
|
|
1324
|
+
try {
|
|
1325
|
+
const local = await this.localCache.getPage(slug);
|
|
1326
|
+
if (local) {
|
|
1327
|
+
return {
|
|
1328
|
+
data: local,
|
|
1329
|
+
metadata: {
|
|
1330
|
+
timestamp: Date.now(),
|
|
1331
|
+
expiresAt: Infinity,
|
|
1332
|
+
tags: [],
|
|
1333
|
+
etag: void 0
|
|
1334
|
+
}
|
|
1335
|
+
};
|
|
1336
|
+
}
|
|
1337
|
+
} catch {
|
|
1335
1338
|
}
|
|
1336
|
-
} catch {
|
|
1337
1339
|
}
|
|
1338
1340
|
}
|
|
1339
1341
|
return null;
|
|
@@ -1520,11 +1522,15 @@ var ContentEngine = class {
|
|
|
1520
1522
|
} = options;
|
|
1521
1523
|
const controller = new AbortController();
|
|
1522
1524
|
const id = setTimeout(() => controller.abort(), timeout);
|
|
1523
|
-
const nextConfig = this.isServer ? {
|
|
1525
|
+
const nextConfig = this.isServer ? {
|
|
1526
|
+
cache: "force-cache",
|
|
1527
|
+
next: { tags, revalidate: revalidate === false ? false : revalidate }
|
|
1528
|
+
} : {};
|
|
1524
1529
|
try {
|
|
1525
1530
|
const response = await fetch(url, {
|
|
1526
1531
|
...fetchOptions,
|
|
1527
1532
|
...nextConfig,
|
|
1533
|
+
// Inject Next.js tags
|
|
1528
1534
|
signal: controller.signal
|
|
1529
1535
|
});
|
|
1530
1536
|
clearTimeout(id);
|
package/dist/index.js
CHANGED
|
@@ -1002,7 +1002,7 @@ var ContentEngine = class {
|
|
|
1002
1002
|
}
|
|
1003
1003
|
return includeMetadata ? cached : cached.data;
|
|
1004
1004
|
}
|
|
1005
|
-
if (!forceRefresh) {
|
|
1005
|
+
if (!forceRefresh && process.env.NODE_ENV === "development") {
|
|
1006
1006
|
try {
|
|
1007
1007
|
const localCollection = await this.localCache.getCollection(collectionId);
|
|
1008
1008
|
if (localCollection) {
|
|
@@ -1077,7 +1077,7 @@ var ContentEngine = class {
|
|
|
1077
1077
|
return cached;
|
|
1078
1078
|
}
|
|
1079
1079
|
}
|
|
1080
|
-
if (!forceRefresh) {
|
|
1080
|
+
if (!forceRefresh && process.env.NODE_ENV === "development") {
|
|
1081
1081
|
try {
|
|
1082
1082
|
const localGlobals = await this.localCache.getGlobals();
|
|
1083
1083
|
if (localGlobals) {
|
|
@@ -1272,22 +1272,24 @@ var ContentEngine = class {
|
|
|
1272
1272
|
};
|
|
1273
1273
|
}
|
|
1274
1274
|
}
|
|
1275
|
-
if (
|
|
1276
|
-
|
|
1277
|
-
|
|
1278
|
-
|
|
1279
|
-
|
|
1280
|
-
|
|
1281
|
-
|
|
1282
|
-
|
|
1283
|
-
|
|
1284
|
-
|
|
1285
|
-
|
|
1286
|
-
|
|
1287
|
-
|
|
1288
|
-
|
|
1275
|
+
if (process.env.NODE_ENV === "development") {
|
|
1276
|
+
if (key.startsWith("page:")) {
|
|
1277
|
+
const slug = key.split(":")[1];
|
|
1278
|
+
try {
|
|
1279
|
+
const local = await this.localCache.getPage(slug);
|
|
1280
|
+
if (local) {
|
|
1281
|
+
return {
|
|
1282
|
+
data: local,
|
|
1283
|
+
metadata: {
|
|
1284
|
+
timestamp: Date.now(),
|
|
1285
|
+
expiresAt: Infinity,
|
|
1286
|
+
tags: [],
|
|
1287
|
+
etag: void 0
|
|
1288
|
+
}
|
|
1289
|
+
};
|
|
1290
|
+
}
|
|
1291
|
+
} catch {
|
|
1289
1292
|
}
|
|
1290
|
-
} catch {
|
|
1291
1293
|
}
|
|
1292
1294
|
}
|
|
1293
1295
|
return null;
|
|
@@ -1474,11 +1476,15 @@ var ContentEngine = class {
|
|
|
1474
1476
|
} = options;
|
|
1475
1477
|
const controller = new AbortController();
|
|
1476
1478
|
const id = setTimeout(() => controller.abort(), timeout);
|
|
1477
|
-
const nextConfig = this.isServer ? {
|
|
1479
|
+
const nextConfig = this.isServer ? {
|
|
1480
|
+
cache: "force-cache",
|
|
1481
|
+
next: { tags, revalidate: revalidate === false ? false : revalidate }
|
|
1482
|
+
} : {};
|
|
1478
1483
|
try {
|
|
1479
1484
|
const response = await fetch(url, {
|
|
1480
1485
|
...fetchOptions,
|
|
1481
1486
|
...nextConfig,
|
|
1487
|
+
// Inject Next.js tags
|
|
1482
1488
|
signal: controller.signal
|
|
1483
1489
|
});
|
|
1484
1490
|
clearTimeout(id);
|
package/dist/react.cjs
CHANGED
|
@@ -647,7 +647,7 @@ var ContentEngine = class {
|
|
|
647
647
|
}
|
|
648
648
|
return includeMetadata ? cached : cached.data;
|
|
649
649
|
}
|
|
650
|
-
if (!forceRefresh) {
|
|
650
|
+
if (!forceRefresh && process.env.NODE_ENV === "development") {
|
|
651
651
|
try {
|
|
652
652
|
const localCollection = await this.localCache.getCollection(collectionId);
|
|
653
653
|
if (localCollection) {
|
|
@@ -722,7 +722,7 @@ var ContentEngine = class {
|
|
|
722
722
|
return cached;
|
|
723
723
|
}
|
|
724
724
|
}
|
|
725
|
-
if (!forceRefresh) {
|
|
725
|
+
if (!forceRefresh && process.env.NODE_ENV === "development") {
|
|
726
726
|
try {
|
|
727
727
|
const localGlobals = await this.localCache.getGlobals();
|
|
728
728
|
if (localGlobals) {
|
|
@@ -917,22 +917,24 @@ var ContentEngine = class {
|
|
|
917
917
|
};
|
|
918
918
|
}
|
|
919
919
|
}
|
|
920
|
-
if (
|
|
921
|
-
|
|
922
|
-
|
|
923
|
-
|
|
924
|
-
|
|
925
|
-
|
|
926
|
-
|
|
927
|
-
|
|
928
|
-
|
|
929
|
-
|
|
930
|
-
|
|
931
|
-
|
|
932
|
-
|
|
933
|
-
|
|
920
|
+
if (process.env.NODE_ENV === "development") {
|
|
921
|
+
if (key.startsWith("page:")) {
|
|
922
|
+
const slug = key.split(":")[1];
|
|
923
|
+
try {
|
|
924
|
+
const local = await this.localCache.getPage(slug);
|
|
925
|
+
if (local) {
|
|
926
|
+
return {
|
|
927
|
+
data: local,
|
|
928
|
+
metadata: {
|
|
929
|
+
timestamp: Date.now(),
|
|
930
|
+
expiresAt: Infinity,
|
|
931
|
+
tags: [],
|
|
932
|
+
etag: void 0
|
|
933
|
+
}
|
|
934
|
+
};
|
|
935
|
+
}
|
|
936
|
+
} catch (e7) {
|
|
934
937
|
}
|
|
935
|
-
} catch (e7) {
|
|
936
938
|
}
|
|
937
939
|
}
|
|
938
940
|
return null;
|
|
@@ -1119,11 +1121,15 @@ var ContentEngine = class {
|
|
|
1119
1121
|
} = options;
|
|
1120
1122
|
const controller = new AbortController();
|
|
1121
1123
|
const id = setTimeout(() => controller.abort(), timeout);
|
|
1122
|
-
const nextConfig = this.isServer ? {
|
|
1124
|
+
const nextConfig = this.isServer ? {
|
|
1125
|
+
cache: "force-cache",
|
|
1126
|
+
next: { tags, revalidate: revalidate === false ? false : revalidate }
|
|
1127
|
+
} : {};
|
|
1123
1128
|
try {
|
|
1124
1129
|
const response = await fetch(url, {
|
|
1125
1130
|
...fetchOptions,
|
|
1126
1131
|
...nextConfig,
|
|
1132
|
+
// Inject Next.js tags
|
|
1127
1133
|
signal: controller.signal
|
|
1128
1134
|
});
|
|
1129
1135
|
clearTimeout(id);
|
package/dist/react.js
CHANGED
|
@@ -647,7 +647,7 @@ var ContentEngine = class {
|
|
|
647
647
|
}
|
|
648
648
|
return includeMetadata ? cached : cached.data;
|
|
649
649
|
}
|
|
650
|
-
if (!forceRefresh) {
|
|
650
|
+
if (!forceRefresh && process.env.NODE_ENV === "development") {
|
|
651
651
|
try {
|
|
652
652
|
const localCollection = await this.localCache.getCollection(collectionId);
|
|
653
653
|
if (localCollection) {
|
|
@@ -722,7 +722,7 @@ var ContentEngine = class {
|
|
|
722
722
|
return cached;
|
|
723
723
|
}
|
|
724
724
|
}
|
|
725
|
-
if (!forceRefresh) {
|
|
725
|
+
if (!forceRefresh && process.env.NODE_ENV === "development") {
|
|
726
726
|
try {
|
|
727
727
|
const localGlobals = await this.localCache.getGlobals();
|
|
728
728
|
if (localGlobals) {
|
|
@@ -917,22 +917,24 @@ var ContentEngine = class {
|
|
|
917
917
|
};
|
|
918
918
|
}
|
|
919
919
|
}
|
|
920
|
-
if (
|
|
921
|
-
|
|
922
|
-
|
|
923
|
-
|
|
924
|
-
|
|
925
|
-
|
|
926
|
-
|
|
927
|
-
|
|
928
|
-
|
|
929
|
-
|
|
930
|
-
|
|
931
|
-
|
|
932
|
-
|
|
933
|
-
|
|
920
|
+
if (process.env.NODE_ENV === "development") {
|
|
921
|
+
if (key.startsWith("page:")) {
|
|
922
|
+
const slug = key.split(":")[1];
|
|
923
|
+
try {
|
|
924
|
+
const local = await this.localCache.getPage(slug);
|
|
925
|
+
if (local) {
|
|
926
|
+
return {
|
|
927
|
+
data: local,
|
|
928
|
+
metadata: {
|
|
929
|
+
timestamp: Date.now(),
|
|
930
|
+
expiresAt: Infinity,
|
|
931
|
+
tags: [],
|
|
932
|
+
etag: void 0
|
|
933
|
+
}
|
|
934
|
+
};
|
|
935
|
+
}
|
|
936
|
+
} catch {
|
|
934
937
|
}
|
|
935
|
-
} catch {
|
|
936
938
|
}
|
|
937
939
|
}
|
|
938
940
|
return null;
|
|
@@ -1119,11 +1121,15 @@ var ContentEngine = class {
|
|
|
1119
1121
|
} = options;
|
|
1120
1122
|
const controller = new AbortController();
|
|
1121
1123
|
const id = setTimeout(() => controller.abort(), timeout);
|
|
1122
|
-
const nextConfig = this.isServer ? {
|
|
1124
|
+
const nextConfig = this.isServer ? {
|
|
1125
|
+
cache: "force-cache",
|
|
1126
|
+
next: { tags, revalidate: revalidate === false ? false : revalidate }
|
|
1127
|
+
} : {};
|
|
1123
1128
|
try {
|
|
1124
1129
|
const response = await fetch(url, {
|
|
1125
1130
|
...fetchOptions,
|
|
1126
1131
|
...nextConfig,
|
|
1132
|
+
// Inject Next.js tags
|
|
1127
1133
|
signal: controller.signal
|
|
1128
1134
|
});
|
|
1129
1135
|
clearTimeout(id);
|