@nexushub/client 0.0.4 → 0.0.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/chunk-2JRYABGG.cjs +117 -0
- package/dist/chunk-BPQMAYT3.js +110 -0
- package/dist/{tools/cli.js → cli.cjs} +14 -8
- package/dist/content/local-cache-client.cjs +56 -0
- package/dist/content/local-cache-client.d.cts +48 -0
- package/dist/content/local-cache-client.d.ts +48 -0
- package/dist/content/local-cache-client.js +54 -0
- package/dist/content/local-cache-server.cjs +10 -0
- package/dist/content/local-cache-server.d.cts +38 -0
- package/dist/content/local-cache-server.d.ts +38 -0
- package/dist/content/local-cache-server.js +1 -0
- package/dist/index.cjs +2008 -0
- package/dist/{src/index.d.mts → index.d.cts} +32 -28
- package/dist/{src/index.d.ts → index.d.ts} +32 -28
- package/dist/index.js +1984 -0
- package/package.json +18 -5
- package/dist/src/index.js +0 -7259
- package/dist/src/index.mjs +0 -7238
- package/dist/tools/cli.d.mts +0 -1
- package/dist/tools/cli.d.ts +0 -1
- package/dist/tools/cli.mjs +0 -639
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var fs = require('fs');
|
|
4
|
+
var path = require('path');
|
|
5
|
+
|
|
6
|
+
function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
|
|
7
|
+
|
|
8
|
+
var fs__default = /*#__PURE__*/_interopDefault(fs);
|
|
9
|
+
var path__default = /*#__PURE__*/_interopDefault(path);
|
|
10
|
+
|
|
11
|
+
// src/content/local-cache-server.ts
|
|
12
|
+
var LocalCache = class {
|
|
13
|
+
constructor(customPath) {
|
|
14
|
+
this.data = null;
|
|
15
|
+
this.hasLoaded = false;
|
|
16
|
+
this.cachePath = customPath || ".nexus/cache.json";
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* Returns true if the local cache file has been successfully
|
|
20
|
+
* loaded and parsed into memory.
|
|
21
|
+
*/
|
|
22
|
+
isLoaded() {
|
|
23
|
+
return this.hasLoaded;
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* Reads the cache file from the filesystem.
|
|
27
|
+
* Internal method called lazily by the getters.
|
|
28
|
+
*/
|
|
29
|
+
load() {
|
|
30
|
+
if (typeof window !== "undefined") return;
|
|
31
|
+
if (this.hasLoaded) return;
|
|
32
|
+
try {
|
|
33
|
+
const fullPath = path__default.default.resolve(process.cwd(), this.cachePath);
|
|
34
|
+
if (fs__default.default.existsSync(fullPath)) {
|
|
35
|
+
const fileContent = fs__default.default.readFileSync(fullPath, "utf-8");
|
|
36
|
+
this.data = JSON.parse(fileContent);
|
|
37
|
+
this.hasLoaded = true;
|
|
38
|
+
if (process.env.NODE_ENV === "development") {
|
|
39
|
+
console.log(
|
|
40
|
+
`\u26A1 NexusHub: Serving content from local cache (${this.cachePath})`
|
|
41
|
+
);
|
|
42
|
+
console.log(` - Pages: ${this.data.pages?.length || 0}`);
|
|
43
|
+
console.log(
|
|
44
|
+
` - Collections: ${Object.keys(this.data.collections || {}).length}`
|
|
45
|
+
);
|
|
46
|
+
console.log(
|
|
47
|
+
` - Globals: ${this.data.globals ? "Loaded" : "Not found"}`
|
|
48
|
+
);
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
} catch (error) {
|
|
52
|
+
if (this.shouldWarnAboutMissingCache(error)) {
|
|
53
|
+
console.warn(
|
|
54
|
+
`\u26A0\uFE0F NexusHub: Local cache not found or invalid at ${this.cachePath}
|
|
55
|
+
Run \`npx nexus pull\` to generate seed data if you want to work offline.`
|
|
56
|
+
);
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
/**
|
|
61
|
+
* Retrieve a specific page from the local pages array.
|
|
62
|
+
*/
|
|
63
|
+
getPage(slug) {
|
|
64
|
+
this.load();
|
|
65
|
+
if (!this.data?.pages) return null;
|
|
66
|
+
const page = this.data.pages.find((p) => p.slug === slug);
|
|
67
|
+
if (!page) {
|
|
68
|
+
if (process.env.NODE_ENV === "development") {
|
|
69
|
+
console.warn(`\u26A0\uFE0F NexusHub: Page '${slug}' not found in local cache.`);
|
|
70
|
+
}
|
|
71
|
+
return null;
|
|
72
|
+
}
|
|
73
|
+
return page.data;
|
|
74
|
+
}
|
|
75
|
+
/**
|
|
76
|
+
* Retrieve an entire collection from the local collections map.
|
|
77
|
+
*/
|
|
78
|
+
getCollection(collectionId) {
|
|
79
|
+
this.load();
|
|
80
|
+
if (!this.data?.collections) return null;
|
|
81
|
+
const collection = this.data.collections[collectionId];
|
|
82
|
+
if (!collection) {
|
|
83
|
+
if (process.env.NODE_ENV === "development") {
|
|
84
|
+
console.warn(
|
|
85
|
+
`\u26A0\uFE0F NexusHub: Collection '${collectionId}' not found in local cache.`
|
|
86
|
+
);
|
|
87
|
+
}
|
|
88
|
+
return null;
|
|
89
|
+
}
|
|
90
|
+
return collection;
|
|
91
|
+
}
|
|
92
|
+
/**
|
|
93
|
+
* Retrieve global settings from the local cache.
|
|
94
|
+
*/
|
|
95
|
+
getGlobals() {
|
|
96
|
+
this.load();
|
|
97
|
+
return this.data?.globals || null;
|
|
98
|
+
}
|
|
99
|
+
/**
|
|
100
|
+
* Returns the entire raw JSON data structure from the cache file.
|
|
101
|
+
*/
|
|
102
|
+
getAllData() {
|
|
103
|
+
this.load();
|
|
104
|
+
return this.data;
|
|
105
|
+
}
|
|
106
|
+
/**
|
|
107
|
+
* Helper to determine if we should bother the user with a warning.
|
|
108
|
+
*/
|
|
109
|
+
shouldWarnAboutMissingCache(error) {
|
|
110
|
+
const isMissing = error.code === "ENOENT";
|
|
111
|
+
const isMalformed = error instanceof SyntaxError;
|
|
112
|
+
if (process.env.NODE_ENV !== "development") return false;
|
|
113
|
+
return !isMissing || isMalformed;
|
|
114
|
+
}
|
|
115
|
+
};
|
|
116
|
+
|
|
117
|
+
exports.LocalCache = LocalCache;
|
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
import fs from 'fs';
|
|
2
|
+
import path from 'path';
|
|
3
|
+
|
|
4
|
+
// src/content/local-cache-server.ts
|
|
5
|
+
var LocalCache = class {
|
|
6
|
+
constructor(customPath) {
|
|
7
|
+
this.data = null;
|
|
8
|
+
this.hasLoaded = false;
|
|
9
|
+
this.cachePath = customPath || ".nexus/cache.json";
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* Returns true if the local cache file has been successfully
|
|
13
|
+
* loaded and parsed into memory.
|
|
14
|
+
*/
|
|
15
|
+
isLoaded() {
|
|
16
|
+
return this.hasLoaded;
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* Reads the cache file from the filesystem.
|
|
20
|
+
* Internal method called lazily by the getters.
|
|
21
|
+
*/
|
|
22
|
+
load() {
|
|
23
|
+
if (typeof window !== "undefined") return;
|
|
24
|
+
if (this.hasLoaded) return;
|
|
25
|
+
try {
|
|
26
|
+
const fullPath = path.resolve(process.cwd(), this.cachePath);
|
|
27
|
+
if (fs.existsSync(fullPath)) {
|
|
28
|
+
const fileContent = fs.readFileSync(fullPath, "utf-8");
|
|
29
|
+
this.data = JSON.parse(fileContent);
|
|
30
|
+
this.hasLoaded = true;
|
|
31
|
+
if (process.env.NODE_ENV === "development") {
|
|
32
|
+
console.log(
|
|
33
|
+
`\u26A1 NexusHub: Serving content from local cache (${this.cachePath})`
|
|
34
|
+
);
|
|
35
|
+
console.log(` - Pages: ${this.data.pages?.length || 0}`);
|
|
36
|
+
console.log(
|
|
37
|
+
` - Collections: ${Object.keys(this.data.collections || {}).length}`
|
|
38
|
+
);
|
|
39
|
+
console.log(
|
|
40
|
+
` - Globals: ${this.data.globals ? "Loaded" : "Not found"}`
|
|
41
|
+
);
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
} catch (error) {
|
|
45
|
+
if (this.shouldWarnAboutMissingCache(error)) {
|
|
46
|
+
console.warn(
|
|
47
|
+
`\u26A0\uFE0F NexusHub: Local cache not found or invalid at ${this.cachePath}
|
|
48
|
+
Run \`npx nexus pull\` to generate seed data if you want to work offline.`
|
|
49
|
+
);
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
/**
|
|
54
|
+
* Retrieve a specific page from the local pages array.
|
|
55
|
+
*/
|
|
56
|
+
getPage(slug) {
|
|
57
|
+
this.load();
|
|
58
|
+
if (!this.data?.pages) return null;
|
|
59
|
+
const page = this.data.pages.find((p) => p.slug === slug);
|
|
60
|
+
if (!page) {
|
|
61
|
+
if (process.env.NODE_ENV === "development") {
|
|
62
|
+
console.warn(`\u26A0\uFE0F NexusHub: Page '${slug}' not found in local cache.`);
|
|
63
|
+
}
|
|
64
|
+
return null;
|
|
65
|
+
}
|
|
66
|
+
return page.data;
|
|
67
|
+
}
|
|
68
|
+
/**
|
|
69
|
+
* Retrieve an entire collection from the local collections map.
|
|
70
|
+
*/
|
|
71
|
+
getCollection(collectionId) {
|
|
72
|
+
this.load();
|
|
73
|
+
if (!this.data?.collections) return null;
|
|
74
|
+
const collection = this.data.collections[collectionId];
|
|
75
|
+
if (!collection) {
|
|
76
|
+
if (process.env.NODE_ENV === "development") {
|
|
77
|
+
console.warn(
|
|
78
|
+
`\u26A0\uFE0F NexusHub: Collection '${collectionId}' not found in local cache.`
|
|
79
|
+
);
|
|
80
|
+
}
|
|
81
|
+
return null;
|
|
82
|
+
}
|
|
83
|
+
return collection;
|
|
84
|
+
}
|
|
85
|
+
/**
|
|
86
|
+
* Retrieve global settings from the local cache.
|
|
87
|
+
*/
|
|
88
|
+
getGlobals() {
|
|
89
|
+
this.load();
|
|
90
|
+
return this.data?.globals || null;
|
|
91
|
+
}
|
|
92
|
+
/**
|
|
93
|
+
* Returns the entire raw JSON data structure from the cache file.
|
|
94
|
+
*/
|
|
95
|
+
getAllData() {
|
|
96
|
+
this.load();
|
|
97
|
+
return this.data;
|
|
98
|
+
}
|
|
99
|
+
/**
|
|
100
|
+
* Helper to determine if we should bother the user with a warning.
|
|
101
|
+
*/
|
|
102
|
+
shouldWarnAboutMissingCache(error) {
|
|
103
|
+
const isMissing = error.code === "ENOENT";
|
|
104
|
+
const isMalformed = error instanceof SyntaxError;
|
|
105
|
+
if (process.env.NODE_ENV !== "development") return false;
|
|
106
|
+
return !isMissing || isMalformed;
|
|
107
|
+
}
|
|
108
|
+
};
|
|
109
|
+
|
|
110
|
+
export { LocalCache };
|
|
@@ -25,12 +25,12 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
|
|
|
25
25
|
|
|
26
26
|
// tools/cli.ts
|
|
27
27
|
var import_commander = require("commander");
|
|
28
|
-
var fs = __toESM(require("fs-extra"));
|
|
29
|
-
var import_path = __toESM(require("path"));
|
|
30
|
-
var import_node_fetch = __toESM(require("node-fetch"));
|
|
31
|
-
var import_dotenv = __toESM(require("dotenv"));
|
|
32
|
-
var import_chalk = __toESM(require("chalk"));
|
|
33
|
-
var import_ora = __toESM(require("ora"));
|
|
28
|
+
var fs = __toESM(require("fs-extra"), 1);
|
|
29
|
+
var import_path = __toESM(require("path"), 1);
|
|
30
|
+
var import_node_fetch = __toESM(require("node-fetch"), 1);
|
|
31
|
+
var import_dotenv = __toESM(require("dotenv"), 1);
|
|
32
|
+
var import_chalk = __toESM(require("chalk"), 1);
|
|
33
|
+
var import_ora = __toESM(require("ora"), 1);
|
|
34
34
|
import_dotenv.default.config({ path: import_path.default.resolve(process.cwd(), ".env.local") });
|
|
35
35
|
import_dotenv.default.config({ path: import_path.default.resolve(process.cwd(), ".env") });
|
|
36
36
|
var program = new import_commander.Command();
|
|
@@ -266,7 +266,7 @@ async function syncContent(options) {
|
|
|
266
266
|
const [pages, collections, globals] = await Promise.all([
|
|
267
267
|
fetchWithAuth(`${apiUrl}/content/${projectId}/pages`, apiKey),
|
|
268
268
|
fetchCollections(`${apiUrl}/content/${projectId}`, apiKey, projectId),
|
|
269
|
-
fetchWithAuth(`${apiUrl}/
|
|
269
|
+
fetchWithAuth(`${apiUrl}/projects/${projectId}/globals`, apiKey)
|
|
270
270
|
]);
|
|
271
271
|
const cacheData = {
|
|
272
272
|
pages: pages.data || pages,
|
|
@@ -477,7 +477,7 @@ async function seedCollections(collectionsDir, apiUrl, projectId, apiKey) {
|
|
|
477
477
|
}
|
|
478
478
|
async function seedGlobals(globals, apiUrl, projectId, apiKey) {
|
|
479
479
|
try {
|
|
480
|
-
await (0, import_node_fetch.default)(`${apiUrl}/
|
|
480
|
+
await (0, import_node_fetch.default)(`${apiUrl}/projects/${projectId}/globals`, {
|
|
481
481
|
method: "PUT",
|
|
482
482
|
headers: {
|
|
483
483
|
Authorization: `Bearer ${apiKey}`,
|
|
@@ -612,6 +612,12 @@ async function generateTypes(options) {
|
|
|
612
612
|
`;
|
|
613
613
|
}
|
|
614
614
|
typeDefs += `}
|
|
615
|
+
`;
|
|
616
|
+
typeDefs += `/**
|
|
617
|
+
* Helper type to get the type of a specific collection by its slug
|
|
618
|
+
*/
|
|
619
|
+
`;
|
|
620
|
+
typeDefs += `export type NexusContent<T extends keyof NexusCollections> = NexusCollections[T];
|
|
615
621
|
`;
|
|
616
622
|
const outputPath = import_path.default.resolve(process.cwd(), options.output);
|
|
617
623
|
await fs.writeFile(outputPath, typeDefs);
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
// src/content/local-cache-client.ts
|
|
4
|
+
var LocalCache = class {
|
|
5
|
+
constructor(customPath) {
|
|
6
|
+
this.data = null;
|
|
7
|
+
this.hasLoaded = false;
|
|
8
|
+
this.cachePath = customPath || ".nexus/cache.json";
|
|
9
|
+
}
|
|
10
|
+
/**
|
|
11
|
+
* Always returns false in the browser as local file caching
|
|
12
|
+
* is a server-side only feature.
|
|
13
|
+
*/
|
|
14
|
+
isLoaded() {
|
|
15
|
+
return false;
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* No-op method to maintain API compatibility with the Node version.
|
|
19
|
+
*/
|
|
20
|
+
load() {
|
|
21
|
+
return;
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* Returns null. Browsers should fetch pages from the Remote API
|
|
25
|
+
* or the Memory/Browser cache.
|
|
26
|
+
*/
|
|
27
|
+
getPage(_slug) {
|
|
28
|
+
return null;
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* Returns null. Browsers should fetch collections from the Remote API.
|
|
32
|
+
*/
|
|
33
|
+
getCollection(_collectionId) {
|
|
34
|
+
return null;
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* Returns null.
|
|
38
|
+
*/
|
|
39
|
+
getGlobals() {
|
|
40
|
+
return null;
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* Returns null.
|
|
44
|
+
*/
|
|
45
|
+
getAllData() {
|
|
46
|
+
return null;
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* Dummy helper to match Node implementation.
|
|
50
|
+
*/
|
|
51
|
+
shouldWarnAboutMissingCache(_error) {
|
|
52
|
+
return false;
|
|
53
|
+
}
|
|
54
|
+
};
|
|
55
|
+
|
|
56
|
+
exports.LocalCache = LocalCache;
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* NexusHub LocalCache (Browser Implementation)
|
|
3
|
+
*
|
|
4
|
+
* This is a dummy implementation used when the SDK is bundled for the browser.
|
|
5
|
+
* Since the browser has no access to the Node.js File System (fs), this
|
|
6
|
+
* implementation returns null for all operations.
|
|
7
|
+
*
|
|
8
|
+
* The real logic is located in local-cache.node.ts and is swapped
|
|
9
|
+
* automatically by the bundler via the "browser" field in package.json.
|
|
10
|
+
*/
|
|
11
|
+
declare class LocalCache {
|
|
12
|
+
private data;
|
|
13
|
+
private hasLoaded;
|
|
14
|
+
private cachePath;
|
|
15
|
+
constructor(customPath?: string);
|
|
16
|
+
/**
|
|
17
|
+
* Always returns false in the browser as local file caching
|
|
18
|
+
* is a server-side only feature.
|
|
19
|
+
*/
|
|
20
|
+
isLoaded(): boolean;
|
|
21
|
+
/**
|
|
22
|
+
* No-op method to maintain API compatibility with the Node version.
|
|
23
|
+
*/
|
|
24
|
+
private load;
|
|
25
|
+
/**
|
|
26
|
+
* Returns null. Browsers should fetch pages from the Remote API
|
|
27
|
+
* or the Memory/Browser cache.
|
|
28
|
+
*/
|
|
29
|
+
getPage(_slug: string): any;
|
|
30
|
+
/**
|
|
31
|
+
* Returns null. Browsers should fetch collections from the Remote API.
|
|
32
|
+
*/
|
|
33
|
+
getCollection(_collectionId: string): any[] | null;
|
|
34
|
+
/**
|
|
35
|
+
* Returns null.
|
|
36
|
+
*/
|
|
37
|
+
getGlobals(): any;
|
|
38
|
+
/**
|
|
39
|
+
* Returns null.
|
|
40
|
+
*/
|
|
41
|
+
getAllData(): any;
|
|
42
|
+
/**
|
|
43
|
+
* Dummy helper to match Node implementation.
|
|
44
|
+
*/
|
|
45
|
+
private shouldWarnAboutMissingCache;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
export { LocalCache };
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* NexusHub LocalCache (Browser Implementation)
|
|
3
|
+
*
|
|
4
|
+
* This is a dummy implementation used when the SDK is bundled for the browser.
|
|
5
|
+
* Since the browser has no access to the Node.js File System (fs), this
|
|
6
|
+
* implementation returns null for all operations.
|
|
7
|
+
*
|
|
8
|
+
* The real logic is located in local-cache.node.ts and is swapped
|
|
9
|
+
* automatically by the bundler via the "browser" field in package.json.
|
|
10
|
+
*/
|
|
11
|
+
declare class LocalCache {
|
|
12
|
+
private data;
|
|
13
|
+
private hasLoaded;
|
|
14
|
+
private cachePath;
|
|
15
|
+
constructor(customPath?: string);
|
|
16
|
+
/**
|
|
17
|
+
* Always returns false in the browser as local file caching
|
|
18
|
+
* is a server-side only feature.
|
|
19
|
+
*/
|
|
20
|
+
isLoaded(): boolean;
|
|
21
|
+
/**
|
|
22
|
+
* No-op method to maintain API compatibility with the Node version.
|
|
23
|
+
*/
|
|
24
|
+
private load;
|
|
25
|
+
/**
|
|
26
|
+
* Returns null. Browsers should fetch pages from the Remote API
|
|
27
|
+
* or the Memory/Browser cache.
|
|
28
|
+
*/
|
|
29
|
+
getPage(_slug: string): any;
|
|
30
|
+
/**
|
|
31
|
+
* Returns null. Browsers should fetch collections from the Remote API.
|
|
32
|
+
*/
|
|
33
|
+
getCollection(_collectionId: string): any[] | null;
|
|
34
|
+
/**
|
|
35
|
+
* Returns null.
|
|
36
|
+
*/
|
|
37
|
+
getGlobals(): any;
|
|
38
|
+
/**
|
|
39
|
+
* Returns null.
|
|
40
|
+
*/
|
|
41
|
+
getAllData(): any;
|
|
42
|
+
/**
|
|
43
|
+
* Dummy helper to match Node implementation.
|
|
44
|
+
*/
|
|
45
|
+
private shouldWarnAboutMissingCache;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
export { LocalCache };
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
// src/content/local-cache-client.ts
|
|
2
|
+
var LocalCache = class {
|
|
3
|
+
constructor(customPath) {
|
|
4
|
+
this.data = null;
|
|
5
|
+
this.hasLoaded = false;
|
|
6
|
+
this.cachePath = customPath || ".nexus/cache.json";
|
|
7
|
+
}
|
|
8
|
+
/**
|
|
9
|
+
* Always returns false in the browser as local file caching
|
|
10
|
+
* is a server-side only feature.
|
|
11
|
+
*/
|
|
12
|
+
isLoaded() {
|
|
13
|
+
return false;
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* No-op method to maintain API compatibility with the Node version.
|
|
17
|
+
*/
|
|
18
|
+
load() {
|
|
19
|
+
return;
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* Returns null. Browsers should fetch pages from the Remote API
|
|
23
|
+
* or the Memory/Browser cache.
|
|
24
|
+
*/
|
|
25
|
+
getPage(_slug) {
|
|
26
|
+
return null;
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* Returns null. Browsers should fetch collections from the Remote API.
|
|
30
|
+
*/
|
|
31
|
+
getCollection(_collectionId) {
|
|
32
|
+
return null;
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* Returns null.
|
|
36
|
+
*/
|
|
37
|
+
getGlobals() {
|
|
38
|
+
return null;
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* Returns null.
|
|
42
|
+
*/
|
|
43
|
+
getAllData() {
|
|
44
|
+
return null;
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* Dummy helper to match Node implementation.
|
|
48
|
+
*/
|
|
49
|
+
shouldWarnAboutMissingCache(_error) {
|
|
50
|
+
return false;
|
|
51
|
+
}
|
|
52
|
+
};
|
|
53
|
+
|
|
54
|
+
export { LocalCache };
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
declare class LocalCache {
|
|
2
|
+
private data;
|
|
3
|
+
private hasLoaded;
|
|
4
|
+
private cachePath;
|
|
5
|
+
constructor(customPath?: string);
|
|
6
|
+
/**
|
|
7
|
+
* Returns true if the local cache file has been successfully
|
|
8
|
+
* loaded and parsed into memory.
|
|
9
|
+
*/
|
|
10
|
+
isLoaded(): boolean;
|
|
11
|
+
/**
|
|
12
|
+
* Reads the cache file from the filesystem.
|
|
13
|
+
* Internal method called lazily by the getters.
|
|
14
|
+
*/
|
|
15
|
+
private load;
|
|
16
|
+
/**
|
|
17
|
+
* Retrieve a specific page from the local pages array.
|
|
18
|
+
*/
|
|
19
|
+
getPage(slug: string): any;
|
|
20
|
+
/**
|
|
21
|
+
* Retrieve an entire collection from the local collections map.
|
|
22
|
+
*/
|
|
23
|
+
getCollection(collectionId: string): any[] | null;
|
|
24
|
+
/**
|
|
25
|
+
* Retrieve global settings from the local cache.
|
|
26
|
+
*/
|
|
27
|
+
getGlobals(): any;
|
|
28
|
+
/**
|
|
29
|
+
* Returns the entire raw JSON data structure from the cache file.
|
|
30
|
+
*/
|
|
31
|
+
getAllData(): any;
|
|
32
|
+
/**
|
|
33
|
+
* Helper to determine if we should bother the user with a warning.
|
|
34
|
+
*/
|
|
35
|
+
private shouldWarnAboutMissingCache;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
export { LocalCache };
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
declare class LocalCache {
|
|
2
|
+
private data;
|
|
3
|
+
private hasLoaded;
|
|
4
|
+
private cachePath;
|
|
5
|
+
constructor(customPath?: string);
|
|
6
|
+
/**
|
|
7
|
+
* Returns true if the local cache file has been successfully
|
|
8
|
+
* loaded and parsed into memory.
|
|
9
|
+
*/
|
|
10
|
+
isLoaded(): boolean;
|
|
11
|
+
/**
|
|
12
|
+
* Reads the cache file from the filesystem.
|
|
13
|
+
* Internal method called lazily by the getters.
|
|
14
|
+
*/
|
|
15
|
+
private load;
|
|
16
|
+
/**
|
|
17
|
+
* Retrieve a specific page from the local pages array.
|
|
18
|
+
*/
|
|
19
|
+
getPage(slug: string): any;
|
|
20
|
+
/**
|
|
21
|
+
* Retrieve an entire collection from the local collections map.
|
|
22
|
+
*/
|
|
23
|
+
getCollection(collectionId: string): any[] | null;
|
|
24
|
+
/**
|
|
25
|
+
* Retrieve global settings from the local cache.
|
|
26
|
+
*/
|
|
27
|
+
getGlobals(): any;
|
|
28
|
+
/**
|
|
29
|
+
* Returns the entire raw JSON data structure from the cache file.
|
|
30
|
+
*/
|
|
31
|
+
getAllData(): any;
|
|
32
|
+
/**
|
|
33
|
+
* Helper to determine if we should bother the user with a warning.
|
|
34
|
+
*/
|
|
35
|
+
private shouldWarnAboutMissingCache;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
export { LocalCache };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { LocalCache } from '../chunk-BPQMAYT3.js';
|