dochub-sdk 0.1.359 → 0.1.361
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/classes/vue2/Documents.ts +12 -8
- package/package.json +1 -1
@@ -170,18 +170,19 @@ export class DocHubDocumentProto extends DocHubComponentProto implements IDocHub
|
|
170
170
|
*/
|
171
171
|
async doRefresh(): Promise<void> {
|
172
172
|
try {
|
173
|
-
if (!this.
|
173
|
+
if (!this.profile?.source) throw new DocHubError('Document must have field "source" in profile!');
|
174
174
|
this.isPending = true;
|
175
175
|
await this.refreshFilesFollow();
|
176
176
|
// Если есть шаблон, загружаем его
|
177
177
|
const template = (this.getType() === DocHubDocumentType.content) && this.templateURI
|
178
178
|
&& (await DocHub.dataLake.pullFile(this.templateURI));
|
179
|
-
let result: AxiosResponse = (template || (this.getType() === DocHubDocumentType.data))
|
179
|
+
let result: AxiosResponse | null = (template || (this.getType() === DocHubDocumentType.data))
|
180
180
|
&& { data: await DocHub.dataLake.resolveDataSetProfile(this.profile, {
|
181
181
|
params: this.params,
|
182
182
|
baseURI: this.baseURI
|
183
183
|
}) } as AxiosResponse
|
184
|
-
|| await DocHub.dataLake.pullFile(this.sourceURI);
|
184
|
+
|| (this.sourceURI ? await DocHub.dataLake.pullFile(this.sourceURI) : null);
|
185
|
+
if (!result) throw new DocHubError(`Can not render document [${this.profile?.$base}]`);
|
185
186
|
// Валидируем данные по структуре, если это требуется
|
186
187
|
if (template || (this.getType() === DocHubDocumentType.data)) {
|
187
188
|
const rules = new ajv({ allErrors: true });
|
@@ -238,16 +239,19 @@ export class DocHubDocumentProto extends DocHubComponentProto implements IDocHub
|
|
238
239
|
if(this.profile?.template) {
|
239
240
|
debugger;
|
240
241
|
const templatePath = [...baseStruct, 'template'].join('/');
|
241
|
-
this.templateURI =
|
242
|
-
|
242
|
+
this.templateURI = DocHub.dataLake.resolveURI(
|
243
|
+
(await DocHub.dataLake.getURIForPath(templatePath) || []).pop() || this.baseURI,
|
244
|
+
this.profile.template
|
245
|
+
);
|
243
246
|
if (!this.templateURI) throw new DocHubError(`Can not resolve template URI for path [${templatePath}]`);
|
244
247
|
followFiles.push(this.templateURI);
|
245
248
|
} else if (typeof this.profile?.source === 'string' && this.getType() === DocHubDocumentType.content) {
|
246
|
-
debugger;
|
247
249
|
// Если шаблона нет, но документ предполагает работу с содержимым файла, то отслеживаем source
|
248
250
|
const sourcePath = [...baseStruct, 'source'].join('/');
|
249
|
-
this.sourceURI =
|
250
|
-
|
251
|
+
this.sourceURI = DocHub.dataLake.resolveURI(
|
252
|
+
(await DocHub.dataLake.getURIForPath(sourcePath) || []).pop() || this.baseURI,
|
253
|
+
this.profile.source
|
254
|
+
);
|
251
255
|
if (!this.sourceURI) throw new DocHubError(`Can not resolve source URI for path [${sourcePath}]`);
|
252
256
|
followFiles.push(this.sourceURI);
|
253
257
|
}
|