@vizabi/reader-ddfcsv 4.5.3 → 4.5.4

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.
Files changed (137) hide show
  1. package/.nyc_output/574fe7f0-58f6-4de2-9524-16e72b784218.json +1 -0
  2. package/.nyc_output/9aede69f-00e6-432d-bdeb-2c9f4084a6dc.json +1 -0
  3. package/.nyc_output/processinfo/574fe7f0-58f6-4de2-9524-16e72b784218.json +1 -0
  4. package/.nyc_output/processinfo/9aede69f-00e6-432d-bdeb-2c9f4084a6dc.json +1 -0
  5. package/.nyc_output/processinfo/index.json +1 -0
  6. package/LICENSE +0 -0
  7. package/README.md +2 -2
  8. package/coverage/base.css +224 -0
  9. package/coverage/block-navigation.js +87 -0
  10. package/coverage/favicon.png +0 -0
  11. package/coverage/index.html +161 -0
  12. package/coverage/prettify.css +1 -0
  13. package/coverage/prettify.js +2 -0
  14. package/coverage/sort-arrow-sprite.png +0 -0
  15. package/coverage/sorter.js +210 -0
  16. package/coverage/src/ddf-csv.ts.html +2866 -0
  17. package/coverage/src/ddfcsv-error.ts.html +148 -0
  18. package/coverage/src/ddfcsv-reader.ts.html +538 -0
  19. package/coverage/src/file-readers/backend-file-reader.ts.html +175 -0
  20. package/coverage/src/file-readers/github-path-adapter.ts.html +244 -0
  21. package/coverage/src/file-readers/index.html +131 -0
  22. package/coverage/src/index.html +176 -0
  23. package/coverage/src/index.ts.html +145 -0
  24. package/coverage/src/interfaces.ts.html +196 -0
  25. package/coverage/src/resource-selection-optimizer/in-clause-under-conjunction.ts.html +745 -0
  26. package/coverage/src/resource-selection-optimizer/index.html +131 -0
  27. package/coverage/src/resource-selection-optimizer/index.ts.html +118 -0
  28. package/coverage/src/test-cases/concepts.ts.html +166 -0
  29. package/coverage/src/test-cases/entities.ts.html +241 -0
  30. package/coverage/src/test-cases/index.html +131 -0
  31. package/dist/reader-ddfcsv.js +15 -1
  32. package/dist/reader-ddfcsv.js.map +1 -0
  33. package/dist/stats.html +4950 -0
  34. package/icon.png +0 -0
  35. package/lib/src/ddf-csv.d.ts +0 -0
  36. package/lib/src/ddf-csv.js +13 -14
  37. package/lib/src/ddf-csv.js.map +1 -1
  38. package/lib/src/ddfcsv-error.d.ts +0 -0
  39. package/lib/src/ddfcsv-error.js +0 -0
  40. package/lib/src/ddfcsv-error.js.map +0 -0
  41. package/lib/src/ddfcsv-reader.d.ts +0 -0
  42. package/lib/src/ddfcsv-reader.js +5 -5
  43. package/lib/src/ddfcsv-reader.js.map +1 -1
  44. package/lib/src/file-readers/backend-file-reader.d.ts +0 -0
  45. package/lib/src/file-readers/backend-file-reader.js +0 -0
  46. package/lib/src/file-readers/backend-file-reader.js.map +0 -0
  47. package/lib/src/file-readers/github-path-adapter.d.ts +0 -0
  48. package/lib/src/file-readers/github-path-adapter.js +0 -0
  49. package/lib/src/file-readers/github-path-adapter.js.map +0 -0
  50. package/lib/src/index.d.ts +0 -0
  51. package/lib/src/index.js +2 -2
  52. package/lib/src/index.js.map +0 -0
  53. package/lib/src/interfaces.d.ts +0 -0
  54. package/lib/src/interfaces.js +0 -0
  55. package/lib/src/interfaces.js.map +0 -0
  56. package/lib/src/resource-selection-optimizer/in-clause-under-conjunction.d.ts +0 -0
  57. package/lib/src/resource-selection-optimizer/in-clause-under-conjunction.js +16 -17
  58. package/lib/src/resource-selection-optimizer/in-clause-under-conjunction.js.map +1 -1
  59. package/lib/src/resource-selection-optimizer/index.d.ts +0 -0
  60. package/lib/src/resource-selection-optimizer/index.js +2 -2
  61. package/lib/src/resource-selection-optimizer/index.js.map +1 -1
  62. package/lib-web/src/ddf-csv.d.ts +0 -0
  63. package/lib-web/src/ddf-csv.js +30 -34
  64. package/lib-web/src/ddf-csv.js.map +1 -1
  65. package/lib-web/src/ddfcsv-error.d.ts +0 -0
  66. package/lib-web/src/ddfcsv-error.js +5 -9
  67. package/lib-web/src/ddfcsv-error.js.map +1 -1
  68. package/lib-web/src/ddfcsv-reader.d.ts +0 -0
  69. package/lib-web/src/ddfcsv-reader.js +16 -19
  70. package/lib-web/src/ddfcsv-reader.js.map +1 -1
  71. package/lib-web/src/file-readers/frontend-file-reader.d.ts +0 -0
  72. package/lib-web/src/file-readers/frontend-file-reader.js +1 -5
  73. package/lib-web/src/file-readers/frontend-file-reader.js.map +1 -1
  74. package/lib-web/src/file-readers/github-path-adapter.d.ts +0 -0
  75. package/lib-web/src/file-readers/github-path-adapter.js +1 -4
  76. package/lib-web/src/file-readers/github-path-adapter.js.map +1 -1
  77. package/lib-web/src/index-web.d.ts +0 -0
  78. package/lib-web/src/index-web.js +9 -14
  79. package/lib-web/src/index-web.js.map +1 -1
  80. package/lib-web/src/interfaces.d.ts +0 -0
  81. package/lib-web/src/interfaces.js +1 -2
  82. package/lib-web/src/interfaces.js.map +0 -0
  83. package/lib-web/src/resource-selection-optimizer/in-clause-under-conjunction.d.ts +0 -0
  84. package/lib-web/src/resource-selection-optimizer/in-clause-under-conjunction.js +12 -17
  85. package/lib-web/src/resource-selection-optimizer/in-clause-under-conjunction.js.map +1 -1
  86. package/lib-web/src/resource-selection-optimizer/index.d.ts +0 -0
  87. package/lib-web/src/resource-selection-optimizer/index.js +4 -7
  88. package/lib-web/src/resource-selection-optimizer/index.js.map +1 -1
  89. package/package.json +93 -129
  90. package/rollup.config.mjs +30 -0
  91. package/scripts/set-own-version.js +0 -0
  92. package/src/ddf-csv.ts +927 -927
  93. package/src/ddfcsv-error.ts +0 -0
  94. package/src/ddfcsv-reader.ts +151 -151
  95. package/src/file-readers/backend-file-reader.ts +0 -0
  96. package/src/file-readers/frontend-file-reader.ts +0 -0
  97. package/src/file-readers/github-path-adapter.ts +0 -0
  98. package/src/index-web.ts +0 -0
  99. package/src/index.ts +0 -0
  100. package/src/interfaces.ts +0 -0
  101. package/src/resource-selection-optimizer/in-clause-under-conjunction.ts +220 -220
  102. package/src/resource-selection-optimizer/index.ts +11 -11
  103. package/src/test-cases/concepts.ts +0 -0
  104. package/src/test-cases/entities.ts +52 -52
  105. package/test/assets-fixtures/world-50m.json +0 -0
  106. package/test/assets.spec.ts +0 -0
  107. package/test/common.ts +1 -1
  108. package/test/definition/concepts-definition.spec.ts +0 -0
  109. package/test/definition/datapoints-definition.spec.ts +1 -1
  110. package/test/definition/entities-definition.spec.ts +264 -264
  111. package/test/definition/schema-definition.spec.ts +0 -0
  112. package/test/diagnostics.spec.ts +0 -0
  113. package/test/features-service.spec.ts +95 -95
  114. package/test/high-load.spec.ts +0 -0
  115. package/test/main.spec.ts +0 -0
  116. package/test/multi-instances.spec.ts +0 -0
  117. package/test/result-fixtures/datapoints-assets.json +0 -0
  118. package/test/result-fixtures/in-clause-under-conjunction-1.json +0 -0
  119. package/test/result-fixtures/in-clause-under-conjunction-2.json +0 -0
  120. package/test/result-fixtures/multi-instances/concepts-sg.json +0 -0
  121. package/test/result-fixtures/multi-instances/concepts-soderstornsmodellen.json +0 -0
  122. package/test/result-fixtures/multi-instances/datapoints-sg.json +0 -0
  123. package/test/result-fixtures/multi-instances/datapoints-soderstornsmodellen.json +0 -0
  124. package/test/result-fixtures/multi-instances/entities-sg.json +0 -0
  125. package/test/result-fixtures/multi-instances/entities-soderstornsmodellen.json +0 -0
  126. package/test/result-fixtures/multi-instances/schema-sg.json +0 -0
  127. package/test/result-fixtures/multi-instances/schema-soderstornsmodellen.json +0 -0
  128. package/test/schema.spec.ts +0 -0
  129. package/test/tslint.json +0 -0
  130. package/tsconfig-web.json +41 -41
  131. package/tsconfig.json +40 -37
  132. package/tslint.json +0 -0
  133. package/.travis.yml +0 -37
  134. package/deploy.js +0 -87
  135. package/dist/reader-ddfcsv-polyfill.js +0 -2
  136. package/dist/reader-ddfcsv-polyfill.js.map +0 -1
  137. package/test/mocha.opts +0 -7
File without changes
@@ -1,151 +1,151 @@
1
- import * as isEmpty from 'lodash.isempty';
2
- import { ddfCsvReader } from './ddf-csv';
3
- import { IResourceRead } from './interfaces';
4
- import { getRepositoryPath } from '@vizabi/ddf-query-validator';
5
- import { DdfCsvError } from './ddfcsv-error';
6
- import { createDiagnosticManagerOn, EndpointDiagnosticManager, getLevelByLabel } from 'cross-project-diagnostics';
7
- import { DiagnosticManager, Level } from 'cross-project-diagnostics/lib';
8
- import { githubPathAdapter } from './file-readers/github-path-adapter';
9
-
10
- const myName = '';
11
- const myVersion = '';
12
-
13
- export function prepareDDFCsvReaderObject (defaultResourceReader?: IResourceRead) {
14
- return function(externalResourceReader?: IResourceRead, logger?: any) {
15
- return {
16
- init (readerInfo) {
17
- // TODO: check validity of base path
18
- this._basePath = githubPathAdapter(readerInfo.path || '');
19
-
20
- this._lastModified = readerInfo._lastModified;
21
- this.fileReader = externalResourceReader || defaultResourceReader;
22
- this.logger = logger;
23
- this.resultTransformer = readerInfo.resultTransformer;
24
-
25
- this.readerOptions = {
26
- basePath: this._basePath,
27
- fileReader: this.fileReader,
28
- logger: this.logger,
29
- };
30
-
31
- this.reader = ddfCsvReader(this.logger);
32
- },
33
-
34
- async getDatasetInfo(): Promise<Object> {
35
- const diagnostic = createDiagnosticManagerOn(myName, myVersion).forRequest('').withSeverityLevel(Level.OFF);
36
- const baseOptions = Object.assign({}, this.readerOptions, { diagnostic });
37
- return this.reader.getDatasetInfo(baseOptions).then(dataPackage => {
38
- const datasetInfo = Object.assign({}, dataPackage);
39
- delete datasetInfo.ddfSchema;
40
- delete datasetInfo.resources;
41
- return datasetInfo;
42
- });
43
- },
44
-
45
- async checkFile(path: string): Promise<any> {
46
- return new Promise((resolve, reject) => {
47
- const status = this.fileReader.checkFile(path);
48
- return resolve({status, url: path});
49
- });
50
- },
51
-
52
- async getFile (filePath: string, isJsonFile: boolean, options: object): Promise<any> {
53
- return new Promise((resolve, reject) => {
54
- this.fileReader.readText(filePath, (err, data) => {
55
- if (err) {
56
- return reject(err);
57
- }
58
-
59
- try {
60
- if (isJsonFile) {
61
- return resolve(JSON.parse(data));
62
- }
63
-
64
- return resolve(data);
65
- } catch (jsonErr) {
66
- return reject(jsonErr);
67
- }
68
- }, options);
69
- });
70
- },
71
-
72
- async checkIfAssetExists (filePath: string, repositoryPath: string = ''): Promise<any> {
73
- if (isEmpty(repositoryPath) && isEmpty(this._basePath)) {
74
- throw new DdfCsvError(`Neither initial 'path' nor 'repositoryPath' as a second param were found.`, `Happens in 'checkIfAssetExists' function`, filePath);
75
- }
76
-
77
- const assetPath = `${repositoryPath || this._basePath}/assets/${filePath}`;
78
-
79
- return await this.checkFile(assetPath);
80
- },
81
-
82
- async getAsset (filePath: string, repositoryPath: string = ''): Promise<any> {
83
- if (isEmpty(repositoryPath) && isEmpty(this._basePath)) {
84
- throw new DdfCsvError(`Neither initial 'path' nor 'repositoryPath' as a second param were found.`, `Happens in 'getAsset' function`, filePath);
85
- }
86
-
87
- const assetPath = `${repositoryPath || this._basePath}/${filePath}`;
88
- const isJsonAsset = (assetPath).slice(-'.json'.length) === '.json';
89
-
90
- return await this.getFile(assetPath, isJsonAsset);
91
- },
92
-
93
- async read (queryParam, parsers, parentDiagnostic?: DiagnosticManager) {
94
- const diagnostic = parentDiagnostic ?
95
- createDiagnosticManagerOn(myName, myVersion).basedOn(parentDiagnostic) :
96
- createDiagnosticManagerOn(myName, myVersion).forRequest('').withSeverityLevel(Level.OFF);
97
- const { debug, error, fatal } = diagnostic.prepareDiagnosticFor('read');
98
-
99
- let result;
100
-
101
- debug('start reading', queryParam);
102
-
103
- try {
104
- if (isEmpty(queryParam.repositoryPath) && isEmpty(this._basePath)) {
105
- const message = `Neither initial 'path' nor 'repositoryPath' in query were found.`;
106
- const err = new DdfCsvError(message, JSON.stringify(queryParam));
107
- error(message, err);
108
- throw err;
109
- }
110
-
111
- result = await this.reader.query(queryParam, {
112
- basePath: queryParam.repositoryPath || this._basePath,
113
- fileReader: this.fileReader,
114
- logger: this.logger,
115
- conceptsLookup: new Map<string, any>(),
116
- diagnostic
117
- });
118
- result = parsers ? this._prettifyData(result, parsers) : result;
119
-
120
- if (this.resultTransformer) {
121
- result = this.resultTransformer(result);
122
- }
123
-
124
- if (this.logger && this.logger.log) {
125
- logger.log(JSON.stringify(queryParam), result.length);
126
- logger.log(result);
127
- }
128
- } catch (err) {
129
- fatal('global data reading error', err);
130
- throw err;
131
- }
132
-
133
- return result;
134
- },
135
-
136
- _prettifyData (data, parsers) {
137
- return data.map(record => {
138
- const keys = Object.keys(record);
139
-
140
- keys.forEach(key => {
141
- if (parsers[ key ]) {
142
- record[ key ] = parsers[ key ](record[ key ]);
143
- }
144
- });
145
-
146
- return record;
147
- });
148
- }
149
- };
150
- };
151
- }
1
+ import isEmpty from 'lodash-es/isEmpty';
2
+ import { ddfCsvReader } from './ddf-csv';
3
+ import { IResourceRead } from './interfaces';
4
+ import { getRepositoryPath } from '@vizabi/ddf-query-validator';
5
+ import { DdfCsvError } from './ddfcsv-error';
6
+ import { createDiagnosticManagerOn, EndpointDiagnosticManager, getLevelByLabel } from 'cross-project-diagnostics';
7
+ import { DiagnosticManager, Level } from 'cross-project-diagnostics/lib';
8
+ import { githubPathAdapter } from './file-readers/github-path-adapter';
9
+
10
+ const myName = '';
11
+ const myVersion = '';
12
+
13
+ export function prepareDDFCsvReaderObject (defaultResourceReader?: IResourceRead) {
14
+ return function(externalResourceReader?: IResourceRead, logger?: any) {
15
+ return {
16
+ init (readerInfo) {
17
+ // TODO: check validity of base path
18
+ this._basePath = githubPathAdapter(readerInfo.path || '');
19
+
20
+ this._lastModified = readerInfo._lastModified;
21
+ this.fileReader = externalResourceReader || defaultResourceReader;
22
+ this.logger = logger;
23
+ this.resultTransformer = readerInfo.resultTransformer;
24
+
25
+ this.readerOptions = {
26
+ basePath: this._basePath,
27
+ fileReader: this.fileReader,
28
+ logger: this.logger,
29
+ };
30
+
31
+ this.reader = ddfCsvReader(this.logger);
32
+ },
33
+
34
+ async getDatasetInfo(): Promise<Object> {
35
+ const diagnostic = createDiagnosticManagerOn(myName, myVersion).forRequest('').withSeverityLevel(Level.OFF);
36
+ const baseOptions = Object.assign({}, this.readerOptions, { diagnostic });
37
+ return this.reader.getDatasetInfo(baseOptions).then(dataPackage => {
38
+ const datasetInfo = Object.assign({}, dataPackage);
39
+ delete datasetInfo.ddfSchema;
40
+ delete datasetInfo.resources;
41
+ return datasetInfo;
42
+ });
43
+ },
44
+
45
+ async checkFile(path: string): Promise<any> {
46
+ return new Promise((resolve, reject) => {
47
+ const status = this.fileReader.checkFile(path);
48
+ return resolve({status, url: path});
49
+ });
50
+ },
51
+
52
+ async getFile (filePath: string, isJsonFile: boolean, options: object): Promise<any> {
53
+ return new Promise((resolve, reject) => {
54
+ this.fileReader.readText(filePath, (err, data) => {
55
+ if (err) {
56
+ return reject(err);
57
+ }
58
+
59
+ try {
60
+ if (isJsonFile) {
61
+ return resolve(JSON.parse(data));
62
+ }
63
+
64
+ return resolve(data);
65
+ } catch (jsonErr) {
66
+ return reject(jsonErr);
67
+ }
68
+ }, options);
69
+ });
70
+ },
71
+
72
+ async checkIfAssetExists (filePath: string, repositoryPath: string = ''): Promise<any> {
73
+ if (isEmpty(repositoryPath) && isEmpty(this._basePath)) {
74
+ throw new DdfCsvError(`Neither initial 'path' nor 'repositoryPath' as a second param were found.`, `Happens in 'checkIfAssetExists' function`, filePath);
75
+ }
76
+
77
+ const assetPath = `${repositoryPath || this._basePath}/assets/${filePath}`;
78
+
79
+ return await this.checkFile(assetPath);
80
+ },
81
+
82
+ async getAsset (filePath: string, repositoryPath: string = ''): Promise<any> {
83
+ if (isEmpty(repositoryPath) && isEmpty(this._basePath)) {
84
+ throw new DdfCsvError(`Neither initial 'path' nor 'repositoryPath' as a second param were found.`, `Happens in 'getAsset' function`, filePath);
85
+ }
86
+
87
+ const assetPath = `${repositoryPath || this._basePath}/${filePath}`;
88
+ const isJsonAsset = (assetPath).slice(-'.json'.length) === '.json';
89
+
90
+ return await this.getFile(assetPath, isJsonAsset);
91
+ },
92
+
93
+ async read (queryParam, parsers, parentDiagnostic?: DiagnosticManager) {
94
+ const diagnostic = parentDiagnostic ?
95
+ createDiagnosticManagerOn(myName, myVersion).basedOn(parentDiagnostic) :
96
+ createDiagnosticManagerOn(myName, myVersion).forRequest('').withSeverityLevel(Level.OFF);
97
+ const { debug, error, fatal } = diagnostic.prepareDiagnosticFor('read');
98
+
99
+ let result;
100
+
101
+ debug('start reading', queryParam);
102
+
103
+ try {
104
+ if (isEmpty(queryParam.repositoryPath) && isEmpty(this._basePath)) {
105
+ const message = `Neither initial 'path' nor 'repositoryPath' in query were found.`;
106
+ const err = new DdfCsvError(message, JSON.stringify(queryParam));
107
+ error(message, err);
108
+ throw err;
109
+ }
110
+
111
+ result = await this.reader.query(queryParam, {
112
+ basePath: queryParam.repositoryPath || this._basePath,
113
+ fileReader: this.fileReader,
114
+ logger: this.logger,
115
+ conceptsLookup: new Map<string, any>(),
116
+ diagnostic
117
+ });
118
+ result = parsers ? this._prettifyData(result, parsers) : result;
119
+
120
+ if (this.resultTransformer) {
121
+ result = this.resultTransformer(result);
122
+ }
123
+
124
+ if (this.logger && this.logger.log) {
125
+ logger.log(JSON.stringify(queryParam), result.length);
126
+ logger.log(result);
127
+ }
128
+ } catch (err) {
129
+ fatal('global data reading error', err);
130
+ throw err;
131
+ }
132
+
133
+ return result;
134
+ },
135
+
136
+ _prettifyData (data, parsers) {
137
+ return data.map(record => {
138
+ const keys = Object.keys(record);
139
+
140
+ keys.forEach(key => {
141
+ if (parsers[ key ]) {
142
+ record[ key ] = parsers[ key ](record[ key ]);
143
+ }
144
+ });
145
+
146
+ return record;
147
+ });
148
+ }
149
+ };
150
+ };
151
+ }
File without changes
File without changes
File without changes
package/src/index-web.ts CHANGED
File without changes
package/src/index.ts CHANGED
File without changes
package/src/interfaces.ts CHANGED
File without changes