@gradial/aci 0.1.6 → 0.1.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.
@@ -36,14 +36,23 @@ export class FileContentProvider {
36
36
  async getFragment(id) {
37
37
  const manifest = await this.manifest();
38
38
  const entry = manifest.fragments[id];
39
- if (!entry) {
40
- throw new FragmentNotFoundError(id);
39
+ if (entry) {
40
+ try {
41
+ return await this.readJSON(entry.payloadRef);
42
+ }
43
+ catch (error) {
44
+ throw new FragmentNotFoundError(id, error);
45
+ }
41
46
  }
47
+ // Raw content directory stores fragments as flat files
48
+ const contentRoot = process.env.ACI_CONTENT_DIR || path.join(path.resolve(process.cwd()), '.content');
49
+ const rawPath = path.join(contentRoot, 'fragments', `${id}.json`);
42
50
  try {
43
- return await this.readJSON(entry.payloadRef);
51
+ const raw = await fs.readFile(rawPath, 'utf8');
52
+ return JSON.parse(raw);
44
53
  }
45
- catch (error) {
46
- throw new FragmentNotFoundError(id, error);
54
+ catch {
55
+ throw new FragmentNotFoundError(id);
47
56
  }
48
57
  }
49
58
  async manifest() {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gradial/aci",
3
- "version": "0.1.6",
3
+ "version": "0.1.7",
4
4
  "type": "module",
5
5
  "main": "./dist/index.js",
6
6
  "types": "./dist/index.d.ts",