MCPcopy Create free account
hub / github.com/lightdash/lightdash / validateDataAppCode

Function validateDataAppCode

packages/common/src/ee/apps/code.ts:78–99  ·  view source on GitHub ↗
(value: unknown)

Source from the content-addressed store, hash-verified

76};
77
78export function validateDataAppCode(value: unknown): DataAppCode {
79 const v = value as Partial<DataAppCode>;
80 if (!v || typeof v !== 'object')
81 throw new Error('Invalid app bundle: not an object');
82 if (!v.manifest || typeof v.manifest !== 'object')
83 throw new Error('Invalid app bundle: missing manifest');
84 if (!Array.isArray(v.files))
85 throw new Error('Invalid app bundle: missing files');
86 for (const f of v.files) {
87 if (!f || typeof f !== 'object')
88 throw new Error('Invalid app bundle: file entry is not an object');
89 if (!isSafeRelPath(f?.path))
90 throw new Error(
91 `Invalid app bundle: unsafe file path "${f?.path}"`,
92 );
93 if (typeof f?.contentBase64 !== 'string')
94 throw new Error(
95 `Invalid app bundle: file "${f?.path}" missing content`,
96 );
97 }
98 return v as DataAppCode;
99}

Callers 3

importAppCodeMethod · 0.90
readBundleFromDirFunction · 0.90
code.test.tsFile · 0.90

Calls 1

isSafeRelPathFunction · 0.85

Tested by

no test coverage detected