@gradial/aci 0.1.8 → 0.1.9
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/next/server.js +0 -1
- package/package.json +8 -7
- package/src/cli/validate-content.mjs +0 -0
- package/bin/aci +0 -0
- package/dist/content/cache.test.d.ts +0 -1
- package/dist/content/cache.test.js +0 -86
package/dist/next/server.js
CHANGED
|
@@ -26,7 +26,6 @@ export async function getFragment(name, config = {}) {
|
|
|
26
26
|
const fragments = runtimeInput.fragments || {};
|
|
27
27
|
if (name in fragments)
|
|
28
28
|
return fragments[name];
|
|
29
|
-
throw new FragmentNotFoundError(name);
|
|
30
29
|
}
|
|
31
30
|
const provider = await resolveProviderWithFallback(config);
|
|
32
31
|
return await provider.getFragment(name);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@gradial/aci",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.9",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"main": "./dist/index.js",
|
|
6
6
|
"types": "./dist/index.d.ts",
|
|
@@ -106,6 +106,12 @@
|
|
|
106
106
|
"./cli/validate-content": "./src/cli/validate-content.mjs",
|
|
107
107
|
"./cli/verify-renderer": "./src/cli/verify-renderer.mjs"
|
|
108
108
|
},
|
|
109
|
+
"scripts": {
|
|
110
|
+
"build": "tsc -p tsconfig.json",
|
|
111
|
+
"build:cli": "cd ../.. && ./scripts/build-cli.sh",
|
|
112
|
+
"compile-registry": "tsx src/cli/compile-registry.mjs",
|
|
113
|
+
"prepack": "npm run build"
|
|
114
|
+
},
|
|
109
115
|
"overrides": {
|
|
110
116
|
"postcss": "^8.5.10"
|
|
111
117
|
},
|
|
@@ -135,10 +141,5 @@
|
|
|
135
141
|
"tsx": "^4.20.0",
|
|
136
142
|
"typescript": "^5.9.3",
|
|
137
143
|
"zod": "^4.0.0"
|
|
138
|
-
},
|
|
139
|
-
"scripts": {
|
|
140
|
-
"build": "tsc -p tsconfig.json",
|
|
141
|
-
"build:cli": "cd ../.. && ./scripts/build-cli.sh",
|
|
142
|
-
"compile-registry": "tsx src/cli/compile-registry.mjs"
|
|
143
144
|
}
|
|
144
|
-
}
|
|
145
|
+
}
|
|
File without changes
|
package/bin/aci
DELETED
|
Binary file
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,86 +0,0 @@
|
|
|
1
|
-
import { describe, it, expect, beforeEach } from '@jest/globals';
|
|
2
|
-
import { getCachedSiteConfig, getCachedManifest, clearProviderCache, getCacheStats, resetCacheStats } from './cache.js';
|
|
3
|
-
describe('Content Cache', () => {
|
|
4
|
-
let mockProvider;
|
|
5
|
-
let getSiteConfigCallCount = 0;
|
|
6
|
-
let manifestCallCount = 0;
|
|
7
|
-
beforeEach(() => {
|
|
8
|
-
getSiteConfigCallCount = 0;
|
|
9
|
-
manifestCallCount = 0;
|
|
10
|
-
resetCacheStats();
|
|
11
|
-
mockProvider = {
|
|
12
|
-
getSiteConfig: async () => {
|
|
13
|
-
getSiteConfigCallCount++;
|
|
14
|
-
return { title: 'Test Site' };
|
|
15
|
-
},
|
|
16
|
-
manifest: async () => {
|
|
17
|
-
manifestCallCount++;
|
|
18
|
-
return {
|
|
19
|
-
routes: {},
|
|
20
|
-
fragments: {},
|
|
21
|
-
siteConfigRef: 'site.json'
|
|
22
|
-
};
|
|
23
|
-
},
|
|
24
|
-
getPage: async () => ({}),
|
|
25
|
-
getFragment: async () => ({}),
|
|
26
|
-
listRoutes: async () => []
|
|
27
|
-
};
|
|
28
|
-
});
|
|
29
|
-
it('should cache siteConfig across multiple calls', async () => {
|
|
30
|
-
const result1 = await getCachedSiteConfig(mockProvider);
|
|
31
|
-
const result2 = await getCachedSiteConfig(mockProvider);
|
|
32
|
-
expect(getSiteConfigCallCount).toBe(1); // Only called once
|
|
33
|
-
expect(result1).toEqual(result2);
|
|
34
|
-
const stats = getCacheStats();
|
|
35
|
-
expect(stats.siteConfig.hits).toBe(1);
|
|
36
|
-
expect(stats.siteConfig.misses).toBe(1);
|
|
37
|
-
});
|
|
38
|
-
it('should cache manifest across multiple calls', async () => {
|
|
39
|
-
const result1 = await getCachedManifest(mockProvider);
|
|
40
|
-
const result2 = await getCachedManifest(mockProvider);
|
|
41
|
-
expect(manifestCallCount).toBe(1); // Only called once
|
|
42
|
-
expect(result1).toEqual(result2);
|
|
43
|
-
const stats = getCacheStats();
|
|
44
|
-
expect(stats.manifest.hits).toBe(1);
|
|
45
|
-
expect(stats.manifest.misses).toBe(1);
|
|
46
|
-
});
|
|
47
|
-
it('should clear cache for a provider', async () => {
|
|
48
|
-
await getCachedSiteConfig(mockProvider);
|
|
49
|
-
expect(getSiteConfigCallCount).toBe(1);
|
|
50
|
-
clearProviderCache(mockProvider);
|
|
51
|
-
await getCachedSiteConfig(mockProvider);
|
|
52
|
-
expect(getSiteConfigCallCount).toBe(2); // Called again after clear
|
|
53
|
-
const stats = getCacheStats();
|
|
54
|
-
expect(stats.siteConfig.misses).toBe(2);
|
|
55
|
-
});
|
|
56
|
-
it('should not cache rejected promises', async () => {
|
|
57
|
-
const errorProvider = {
|
|
58
|
-
getSiteConfig: async () => {
|
|
59
|
-
getSiteConfigCallCount++;
|
|
60
|
-
throw new Error('S3 timeout');
|
|
61
|
-
},
|
|
62
|
-
getPage: async () => ({}),
|
|
63
|
-
getFragment: async () => ({}),
|
|
64
|
-
listRoutes: async () => []
|
|
65
|
-
};
|
|
66
|
-
await expect(getCachedSiteConfig(errorProvider)).rejects.toThrow('S3 timeout');
|
|
67
|
-
expect(getSiteConfigCallCount).toBe(1);
|
|
68
|
-
// Second call should retry (not cached)
|
|
69
|
-
await expect(getCachedSiteConfig(errorProvider)).rejects.toThrow('S3 timeout');
|
|
70
|
-
expect(getSiteConfigCallCount).toBe(2);
|
|
71
|
-
});
|
|
72
|
-
it('should cache separately per provider instance', async () => {
|
|
73
|
-
const provider2 = {
|
|
74
|
-
getSiteConfig: async () => ({ title: 'Site 2' }),
|
|
75
|
-
getPage: async () => ({}),
|
|
76
|
-
getFragment: async () => ({}),
|
|
77
|
-
listRoutes: async () => []
|
|
78
|
-
};
|
|
79
|
-
const result1 = await getCachedSiteConfig(mockProvider);
|
|
80
|
-
const result2 = await getCachedSiteConfig(provider2);
|
|
81
|
-
expect(result1).toEqual({ title: 'Test Site' });
|
|
82
|
-
expect(result2).toEqual({ title: 'Site 2' });
|
|
83
|
-
const stats = getCacheStats();
|
|
84
|
-
expect(stats.siteConfig.misses).toBe(2); // Both are cache misses
|
|
85
|
-
});
|
|
86
|
-
});
|