MCPcopy Index your code
hub / github.com/apitable/apitable / loadFile

Method loadFile

packages/core/src/tablebundle/table_bundle.ts:66–100  ·  view source on GitHub ↗
(path: string)

Source from the content-addressed store, hash-verified

64 }
65
66 loadFile(path: string) {
67 if (this._loader === undefined) {
68 return;
69 }
70 this._nodeMap = new Map<string, TableBundleDataSheet>();
71 const buffer = this._loader.load(path);
72 const unzipped = fflate.unzipSync(buffer);
73 if (unzipped['manifest.json'] === undefined) {
74 throw new Error('manifest.json not found');
75 }
76
77 this.manifest = TableBundleManifest.build(JSON.parse(fflate.strFromU8(unzipped['manifest.json'])));
78 const allChildNodes = this.manifest.allChildNodes();
79 for (let i = 0; i < allChildNodes.length; i++) {
80 const nodeId = allChildNodes[i];
81 if (nodeId === undefined) {
82 throw new Error('nodeId ' + nodeId + ' is undefined');
83 }
84 const fileName = 'data/' + nodeId + '.json';
85 if (unzipped[fileName] === undefined) {
86 throw new Error(fileName + ' not found');
87 }
88 // @ts-ignore
89 const sn = JSON.parse(fflate.strFromU8(unzipped[fileName])) as TableBundleSnapshot;
90
91 const extrasFileName = 'data/' + nodeId + '.extras.json';
92 let extras;
93 if (unzipped[extrasFileName] !== undefined) {
94 // @ts-ignore
95 extras = fflate.strFromU8(unzipped[extrasFileName]);
96 }
97 const dataSheet = new TableBundleDataSheet(sn, extras);
98 this._nodeMap.set(nodeId, dataSheet);
99 }
100 }
101
102}
103

Callers 1

Calls 5

allChildNodesMethod · 0.80
loadMethod · 0.65
buildMethod · 0.65
parseMethod · 0.65
setMethod · 0.65

Tested by

no test coverage detected