@nexushub/client 0.7.5 → 0.7.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.
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
- // \u{1F680} Purge the entire Next.js internal data and page cache layout-wide
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: "Next.js cache successfully purged."
182
+ message: "Full stack edge caches successfully purged."
177
183
  });
178
- } catch (err: any) {
179
- return NextResponse.json({ message: err.message }, { status: 500 });
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
- return NextResponse.json({ revalidated: true, now: Date.now() });
251
- } catch (err: any) {
252
- return NextResponse.json({ message: err.message }, { status: 500 });
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
@@ -1517,6 +1517,7 @@ var ContentEngine = class {
1517
1517
  tags = [],
1518
1518
  revalidate,
1519
1519
  ...fetchOptions
1520
+ // 🚀 RESOLVED: Destructure with safe default to prevent undefined spreads
1520
1521
  } = options;
1521
1522
  const controller = new AbortController();
1522
1523
  const id = setTimeout(() => controller.abort(), timeout);
package/dist/index.js CHANGED
@@ -1471,6 +1471,7 @@ var ContentEngine = class {
1471
1471
  tags = [],
1472
1472
  revalidate,
1473
1473
  ...fetchOptions
1474
+ // 🚀 RESOLVED: Destructure with safe default to prevent undefined spreads
1474
1475
  } = options;
1475
1476
  const controller = new AbortController();
1476
1477
  const id = setTimeout(() => controller.abort(), timeout);
package/dist/react.cjs CHANGED
@@ -1116,6 +1116,7 @@ var ContentEngine = class {
1116
1116
  tags = [],
1117
1117
  revalidate,
1118
1118
  ...fetchOptions
1119
+ // 🚀 RESOLVED: Destructure with safe default to prevent undefined spreads
1119
1120
  } = options;
1120
1121
  const controller = new AbortController();
1121
1122
  const id = setTimeout(() => controller.abort(), timeout);
package/dist/react.js CHANGED
@@ -1116,6 +1116,7 @@ var ContentEngine = class {
1116
1116
  tags = [],
1117
1117
  revalidate,
1118
1118
  ...fetchOptions
1119
+ // 🚀 RESOLVED: Destructure with safe default to prevent undefined spreads
1119
1120
  } = options;
1120
1121
  const controller = new AbortController();
1121
1122
  const id = setTimeout(() => controller.abort(), timeout);
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@nexushub/client",
3
3
  "private": false,
4
- "version": "0.7.5",
4
+ "version": "0.7.6",
5
5
  "description": "The God-Tier NexusHub SDK",
6
6
  "type": "module",
7
7
  "main": "./dist/index.cjs",