dl-commons 0.0.2-testing.10 → 0.0.2-testing.12

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/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "dl-commons",
3
3
  "type": "commonjs",
4
- "version": "0.0.2-testing.10",
4
+ "version": "0.0.2-testing.12",
5
5
  "description": "distance learning commons",
6
6
  "main": "dist/index.js",
7
7
  "types": "dist/index.d.ts",
@@ -4,7 +4,7 @@ import { II18n } from './i18n.interface';
4
4
 
5
5
  export interface IDictionary extends IBase {
6
6
  keyword: string;
7
- parentIds: Types.ObjectId[];
7
+ parentIds: Types.ObjectId[] | string[];
8
8
  title: II18n;
9
9
  metas: Map<string, string>;
10
10
  }
@@ -28,16 +28,21 @@ export class DictionariesService {
28
28
  if (response.data.errors) {
29
29
  throw new RESTError('dictionaries_api_error', response.data.errors);
30
30
  }
31
+
31
32
  if (!response.data || !response.data.result) {
32
33
  throw new RESTError('dictionaries_api_error', 'empty response');
33
34
  }
34
35
 
35
- const result: IDictionary = {
36
- ...response.data.result.data,
37
- _id: new Types.ObjectId(response.data.result.data._id),
38
- };
36
+ if (response.data.result.data) {
37
+ const result: IDictionary = {
38
+ ...response.data.result.data,
39
+ _id: new Types.ObjectId(response.data.result.data._id),
40
+ };
39
41
 
40
- return result;
42
+ return result;
43
+ } else {
44
+ return null;
45
+ }
41
46
  } catch (e) {
42
47
  throw RESTError.createFromCatch(e, { keyword: 'unknown', debug: e });
43
48
  }