dochub-sdk 0.1.176 → 0.1.178

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.
@@ -7,7 +7,8 @@ import type { IDocHubEditableComponent, IDocHubPresentationProfile, IDocHubPrese
7
7
 
8
8
  import ajv from 'ajv';
9
9
  import ajv_localize from 'ajv-i18n/localize/ru';
10
- import mustache from 'mustache';
10
+ import { AxiosResponse } from 'axios';
11
+
11
12
 
12
13
  //********************************************
13
14
  // !!!!!!! followURI не задается !!!!!
@@ -100,8 +101,8 @@ export class DocHubDocumentProto extends DocHubComponentProto implements IDocHub
100
101
  * Обработка полученных данных документа.
101
102
  * Нужно переопределить для типа документа DocHubDocumentType.content
102
103
  */
103
- processingContent(content: any) {
104
- throw new DocHubError('Not implemented.');
104
+ processingContent(content: AxiosResponse) {
105
+ throw new DocHubError(`The document has ${this.getType()} type. It must have processingContent method. But, the method is not implemented.`);
105
106
  }
106
107
 
107
108
  /**
@@ -136,31 +137,31 @@ export class DocHubDocumentProto extends DocHubComponentProto implements IDocHub
136
137
  const template = (this.getType() === DocHubDocumentType.content) && this.profile?.template
137
138
  && (await DocHub.dataLake.pullFile(
138
139
  DocHub.dataLake.resolveURI(this.followURI || this.profile?.template, this.profile?.template)
139
- )).data;
140
+ ));
140
141
  if (!this.profile?.source) throw new DocHubError('Document must have field "source" in profile!');
141
- let result = (template || (this.getType() === DocHubDocumentType.data))
142
- && await DocHub.dataLake.resolveDataSetProfile(this.profile, {
142
+ let result: AxiosResponse = (template || (this.getType() === DocHubDocumentType.data))
143
+ && { data: await DocHub.dataLake.resolveDataSetProfile(this.profile, {
143
144
  params: this.params,
144
145
  baseURI: this.followURI
145
- })
146
+ }) } as AxiosResponse
146
147
  || (await DocHub.dataLake.pullFile(
147
148
  DocHub.dataLake.resolveURI(this.followURI || this.profile?.source as string, this.profile?.source as string)
148
- )).data;
149
+ ));
149
150
  // Валидируем данные по структуре, если это требуется
150
151
  if (template || (this.getType() === DocHubDocumentType.data)) {
151
152
  const rules = new ajv({ allErrors: true });
152
153
  const validator = rules.compile(this.getSchemaData());
153
- if (!validator(result)) {
154
+ if (!validator(result.data)) {
154
155
  ajv_localize(validator.errors);
155
156
  this.error = JSON.stringify(validator.errors, null, 4);
156
157
  return;
157
158
  }
158
159
  // Если все в порядке, вызываем процессинг данных
159
- result = this.processingData(result);
160
+ result = this.processingData(result.data);
160
161
  }
161
162
  // Транслируем по шаблону
162
163
  if (template) {
163
- result = mustache.render(template.toString(), result);
164
+ result.data = DocHub.tools.mustache.render(template.data.toString(), result.data);
164
165
  }
165
166
  // Вызываем метод обработки полученного контента, если это требуется
166
167
  (template || (this.getType() === DocHubDocumentType.content)) && this.processingContent(result);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dochub-sdk",
3
- "version": "0.1.176",
3
+ "version": "0.1.178",
4
4
  "description": "The DocHub System Development Kit.",
5
5
  "private": false,
6
6
  "main": "index.ts",
@@ -25,7 +25,6 @@
25
25
  "dependencies": {
26
26
  "ajv": "8.17.1",
27
27
  "ajv-i18n": "4.2.0",
28
- "axios": "0.21.4",
29
- "mustache": "4.2.0"
28
+ "axios": "0.21.4"
30
29
  }
31
30
  }