@static-suite/static-suite-data-server 0.0.8 → 0.0.9

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 (202) hide show
  1. package/.eslintrc.json +0 -3
  2. package/.husky/pre-commit +4 -0
  3. package/api-extractor.json +1 -1
  4. package/dist/bin/serve.js +4 -6
  5. package/dist/http/httpServer.js +1 -1
  6. package/dist/http/public/assets/bulma/bulma.min.css +1 -1
  7. package/dist/http/public/assets/clipboard/clipboard.min.js +2 -2
  8. package/dist/http/public/assets/simple-datatables/index.js +2 -6
  9. package/dist/http/public/assets/simple-datatables/style.css +87 -51
  10. package/dist/http/routes/cache.js +2 -2
  11. package/dist/http/routes/data.js +3 -3
  12. package/dist/http/routes/dependency.d.ts.map +1 -1
  13. package/dist/http/routes/dependency.js +5 -5
  14. package/dist/http/routes/docs.js +3 -3
  15. package/dist/http/routes/dump.js +3 -3
  16. package/dist/http/routes/query.js +2 -2
  17. package/dist/http/routes/status.js +7 -7
  18. package/dist/http/routes/task.js +2 -2
  19. package/dist/http/views/cacheIndex.pug +1 -1
  20. package/dist/http/views/docs.pug +1 -1
  21. package/dist/lib/config/config.js +2 -2
  22. package/dist/lib/config/config.types.d.ts +3 -3
  23. package/dist/lib/config/config.types.d.ts.map +1 -1
  24. package/dist/lib/config/error/InvalidRunMode.d.ts +1 -1
  25. package/dist/lib/config/error/InvalidRunMode.d.ts.map +1 -1
  26. package/dist/lib/config/error/InvalidRunMode.js +1 -1
  27. package/dist/lib/config/error/MissingDirectory.d.ts +1 -1
  28. package/dist/lib/config/error/MissingDirectory.d.ts.map +1 -1
  29. package/dist/lib/config/error/MissingDirectory.js +1 -1
  30. package/dist/lib/config/error/MissingRequiredOption.d.ts +1 -1
  31. package/dist/lib/config/error/MissingRequiredOption.d.ts.map +1 -1
  32. package/dist/lib/config/error/MissingRequiredOption.js +1 -1
  33. package/dist/lib/config/error/NonWritableDirectory.d.ts +1 -1
  34. package/dist/lib/config/error/NonWritableDirectory.d.ts.map +1 -1
  35. package/dist/lib/config/error/NonWritableDirectory.js +1 -1
  36. package/dist/lib/config/error/index.js +5 -1
  37. package/dist/lib/config/index.js +5 -1
  38. package/dist/lib/dataServer.d.ts +4 -4
  39. package/dist/lib/dataServer.d.ts.map +1 -1
  40. package/dist/lib/dataServer.js +9 -9
  41. package/dist/lib/dataServer.types.d.ts +5 -5
  42. package/dist/lib/dataServer.types.d.ts.map +1 -1
  43. package/dist/lib/index.d.ts.map +1 -1
  44. package/dist/lib/index.js +5 -3
  45. package/dist/lib/query/index.js +5 -1
  46. package/dist/lib/query/query.types.d.ts +8 -8
  47. package/dist/lib/query/query.types.d.ts.map +1 -1
  48. package/dist/lib/query/queryManager.js +1 -1
  49. package/dist/lib/query/queryRunner.js +6 -6
  50. package/dist/lib/query/queryTagManager.js +1 -1
  51. package/dist/lib/store/dataDir/dataDir.types.d.ts +1 -1
  52. package/dist/lib/store/dataDir/dataDir.types.d.ts.map +1 -1
  53. package/dist/lib/store/dataDir/dataDirManager.js +10 -10
  54. package/dist/lib/store/dataDir/index.js +5 -1
  55. package/dist/lib/store/dependency/dependency.types.d.ts +3 -3
  56. package/dist/lib/store/dependency/dependency.types.d.ts.map +1 -1
  57. package/dist/lib/store/dependency/dependencyFileHelper.d.ts +1 -1
  58. package/dist/lib/store/dependency/dependencyFileHelper.d.ts.map +1 -1
  59. package/dist/lib/store/diff/diff.types.d.ts +2 -2
  60. package/dist/lib/store/diff/diff.types.d.ts.map +1 -1
  61. package/dist/lib/store/diff/diffManager.js +1 -1
  62. package/dist/lib/store/diff/index.js +5 -1
  63. package/dist/lib/store/dump/dump.types.d.ts +3 -3
  64. package/dist/lib/store/dump/dump.types.d.ts.map +1 -1
  65. package/dist/lib/store/dump/dumpManager.js +4 -4
  66. package/dist/lib/store/dump/dumpMetadataHelper.js +3 -3
  67. package/dist/lib/store/dump/index.js +5 -1
  68. package/dist/lib/store/hook/hook.types.d.ts +7 -7
  69. package/dist/lib/store/hook/hook.types.d.ts.map +1 -1
  70. package/dist/lib/store/hook/hookManager.js +5 -5
  71. package/dist/lib/store/hook/index.js +5 -1
  72. package/dist/lib/store/include/includeParser.types.d.ts +5 -5
  73. package/dist/lib/store/include/includeParser.types.d.ts.map +1 -1
  74. package/dist/lib/store/include/index.js +5 -1
  75. package/dist/lib/store/include/parsers/entityIncludeParser.js +1 -1
  76. package/dist/lib/store/include/parsers/index.js +5 -1
  77. package/dist/lib/store/include/parsers/queryIncludeParser.js +5 -5
  78. package/dist/lib/store/include/parsers/types/aliasIncludeParser.d.ts +1 -1
  79. package/dist/lib/store/include/parsers/types/aliasIncludeParser.d.ts.map +1 -1
  80. package/dist/lib/store/include/parsers/types/aliasIncludeParser.js +1 -1
  81. package/dist/lib/store/include/parsers/types/aliasWithoutTypeIncludeParser.d.ts +1 -1
  82. package/dist/lib/store/include/parsers/types/aliasWithoutTypeIncludeParser.d.ts.map +1 -1
  83. package/dist/lib/store/include/parsers/types/aliasWithoutTypeIncludeParser.js +1 -1
  84. package/dist/lib/store/index.js +5 -1
  85. package/dist/lib/store/store.js +3 -3
  86. package/dist/lib/store/store.types.d.ts +4 -4
  87. package/dist/lib/store/store.types.d.ts.map +1 -1
  88. package/dist/lib/store/storeManager.js +2 -2
  89. package/dist/lib/store/workDir/index.js +5 -1
  90. package/dist/lib/store/workDir/storage/getChangedLinesBetween.js +2 -2
  91. package/dist/lib/store/workDir/storage/getDataFromLogLine.js +1 -1
  92. package/dist/lib/store/workDir/storage/getLogFile.js +1 -1
  93. package/dist/lib/store/workDir/storage/index.js +5 -1
  94. package/dist/lib/store/workDir/workDir.types.d.ts +2 -2
  95. package/dist/lib/store/workDir/workDir.types.d.ts.map +1 -1
  96. package/dist/lib/store/workDir/workDirHelper.js +2 -2
  97. package/dist/lib/task/index.js +5 -1
  98. package/dist/lib/task/task.types.d.ts +7 -7
  99. package/dist/lib/task/task.types.d.ts.map +1 -1
  100. package/dist/lib/task/taskManager.js +1 -1
  101. package/dist/lib/task/taskRunner.js +3 -3
  102. package/dist/lib/tsdoc-metadata.json +1 -1
  103. package/dist/lib/utils/cache/cacheBinManager.d.ts +2 -2
  104. package/dist/lib/utils/cache/cacheBinManager.d.ts.map +1 -1
  105. package/dist/lib/utils/cache/index.js +5 -1
  106. package/dist/lib/utils/fs/fs.types.d.ts +2 -2
  107. package/dist/lib/utils/fs/fs.types.d.ts.map +1 -1
  108. package/dist/lib/utils/fs/fsUtils.js +2 -2
  109. package/dist/lib/utils/fs/index.js +5 -1
  110. package/dist/lib/utils/logger/index.js +5 -1
  111. package/dist/lib/utils/logger/logger.d.ts +1 -1
  112. package/dist/lib/utils/logger/logger.d.ts.map +1 -1
  113. package/dist/lib/utils/logger/logger.js +3 -1
  114. package/dist/lib/utils/logger/logger.types.d.ts +3 -3
  115. package/dist/lib/utils/logger/logger.types.d.ts.map +1 -1
  116. package/dist/lib/utils/module/dirBasedModuleGroupManager.js +3 -3
  117. package/dist/lib/utils/module/index.js +5 -1
  118. package/dist/lib/utils/module/module.types.d.ts +2 -2
  119. package/dist/lib/utils/module/module.types.d.ts.map +1 -1
  120. package/dist/lib/utils/module/moduleManager.js +3 -3
  121. package/dist/lib/utils/object/index.js +5 -1
  122. package/dist/lib/utils/object/object.types.d.ts +2 -2
  123. package/dist/lib/utils/object/object.types.d.ts.map +1 -1
  124. package/dist/lib/utils/object/objectUtils.d.ts +2 -2
  125. package/dist/lib/utils/object/objectUtils.d.ts.map +1 -1
  126. package/dist/lib/utils/string/index.js +5 -1
  127. package/dist/lib/utils/string/string.types.d.ts +1 -1
  128. package/dist/lib/utils/string/string.types.d.ts.map +1 -1
  129. package/dist/lib/utils/string/stringUtils.d.ts +1 -1
  130. package/dist/lib/utils/string/stringUtils.js +2 -2
  131. package/dist/lib/watcher/index.js +5 -1
  132. package/dist/lib/watcher/watcher.js +8 -8
  133. package/dist/static-suite-data-server.d.ts +201 -27
  134. package/package.json +43 -60
  135. package/src/bin/serve.ts +4 -6
  136. package/src/http/httpServer.ts +1 -1
  137. package/src/http/routes/cache.ts +2 -2
  138. package/src/http/routes/data.ts +3 -3
  139. package/src/http/routes/dependency.ts +5 -6
  140. package/src/http/routes/docs.ts +3 -3
  141. package/src/http/routes/dump.ts +3 -3
  142. package/src/http/routes/query.ts +3 -3
  143. package/src/http/routes/status.ts +8 -8
  144. package/src/http/routes/task.ts +3 -3
  145. package/src/http/views/cacheIndex.pug +1 -1
  146. package/src/http/views/docs.pug +1 -1
  147. package/src/lib/config/__tests__/config.test.ts +1 -1
  148. package/src/lib/config/config.ts +2 -2
  149. package/src/lib/config/config.types.ts +1 -1
  150. package/src/lib/config/error/InvalidRunMode.ts +1 -1
  151. package/src/lib/config/error/MissingDirectory.ts +1 -1
  152. package/src/lib/config/error/MissingRequiredOption.ts +1 -1
  153. package/src/lib/config/error/NonWritableDirectory.ts +1 -1
  154. package/src/lib/dataServer.ts +11 -11
  155. package/src/lib/dataServer.types.ts +2 -2
  156. package/src/lib/index.ts +0 -3
  157. package/src/lib/query/__tests__/queryRunner.test.ts +4 -4
  158. package/src/lib/query/query.types.ts +1 -1
  159. package/src/lib/query/queryManager.ts +1 -1
  160. package/src/lib/query/queryRunner.ts +6 -6
  161. package/src/lib/query/queryTagManager.ts +2 -2
  162. package/src/lib/store/dataDir/__tests__/dataDirManager.test.ts +1 -1
  163. package/src/lib/store/dataDir/dataDirManager.ts +10 -10
  164. package/src/lib/store/dependency/dependencyFileHelper.ts +1 -1
  165. package/src/lib/store/diff/diffManager.ts +1 -1
  166. package/src/lib/store/dump/dumpManager.ts +4 -4
  167. package/src/lib/store/dump/dumpMetadataHelper.ts +3 -3
  168. package/src/lib/store/hook/hook.types.ts +5 -5
  169. package/src/lib/store/hook/hookManager.ts +6 -6
  170. package/src/lib/store/include/__tests__/includeParser.test.ts +2 -2
  171. package/src/lib/store/include/includeParser.ts +1 -1
  172. package/src/lib/store/include/includeParser.types.ts +1 -1
  173. package/src/lib/store/include/parsers/entityIncludeParser.ts +1 -1
  174. package/src/lib/store/include/parsers/queryIncludeParser.ts +5 -5
  175. package/src/lib/store/include/parsers/types/aliasIncludeParser.ts +2 -2
  176. package/src/lib/store/include/parsers/types/aliasWithoutTypeIncludeParser.ts +2 -2
  177. package/src/lib/store/store.ts +3 -3
  178. package/src/lib/store/storeManager.ts +3 -3
  179. package/src/lib/store/workDir/__tests__/workDirHelper.test.ts +1 -1
  180. package/src/lib/store/workDir/storage/__tests__/getChangedLinesBetween.test.ts +1 -1
  181. package/src/lib/store/workDir/storage/getChangedLinesBetween.ts +2 -2
  182. package/src/lib/store/workDir/storage/getDataFromLogLine.ts +1 -1
  183. package/src/lib/store/workDir/storage/getLogFile.ts +1 -1
  184. package/src/lib/store/workDir/workDirHelper.ts +2 -2
  185. package/src/lib/task/__tests__/taskRunner.test.ts +3 -3
  186. package/src/lib/task/task.types.ts +1 -1
  187. package/src/lib/task/taskManager.ts +1 -1
  188. package/src/lib/task/taskRunner.ts +3 -3
  189. package/src/lib/utils/fs/__tests__/fsUtils.test.ts +1 -1
  190. package/src/lib/utils/fs/fs.types.ts +1 -1
  191. package/src/lib/utils/fs/fsUtils.ts +2 -2
  192. package/src/lib/utils/logger/__tests__/logger.test.ts +1 -1
  193. package/src/lib/utils/logger/logger.ts +1 -0
  194. package/src/lib/utils/module/__tests__/dirBasedModuleGroupManager.test.ts +2 -2
  195. package/src/lib/utils/module/__tests__/moduleHandler.test.ts +19 -11
  196. package/src/lib/utils/module/dirBasedModuleGroupManager.ts +3 -3
  197. package/src/lib/utils/module/moduleManager.ts +3 -3
  198. package/src/lib/utils/object/objectUtils.ts +4 -1
  199. package/src/lib/utils/string/__tests__/stringUtils.test.ts +4 -2
  200. package/src/lib/utils/string/stringUtils.ts +2 -2
  201. package/src/lib/watcher/watcher.ts +8 -8
  202. package/tsconfig.json +0 -4
@@ -1,2 +1,2 @@
1
- export declare type URLSearchParamsObject = Record<string, string | string[] | null>;
1
+ export type URLSearchParamsObject = Record<string, string | string[] | null>;
2
2
  //# sourceMappingURL=string.types.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"string.types.d.ts","sourceRoot":"","sources":["../../../../src/lib/utils/string/string.types.ts"],"names":[],"mappings":"AAAA,oBAAY,qBAAqB,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,EAAE,GAAG,IAAI,CAAC,CAAC"}
1
+ {"version":3,"file":"string.types.d.ts","sourceRoot":"","sources":["../../../../src/lib/utils/string/string.types.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,qBAAqB,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,EAAE,GAAG,IAAI,CAAC,CAAC"}
@@ -45,7 +45,7 @@ export declare const parseUniqueId: (uniqueId: string) => Date | null;
45
45
  /**
46
46
  * Checks that a string is a unique id.
47
47
  *
48
- * @param uniqueId - A unique id t be checked
48
+ * @param uniqueId - A unique id to be checked
49
49
  */
50
50
  export declare const isUniqueId: (uniqueId: string) => boolean;
51
51
  //# sourceMappingURL=stringUtils.d.ts.map
@@ -1,7 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.isUniqueId = exports.parseUniqueId = exports.parseURLSearchParams = exports.parseJsonString = exports.VARIANT_SEPARATOR = void 0;
4
- const logger_1 = require("@lib/utils/logger");
4
+ const logger_1 = require("../logger");
5
5
  /**
6
6
  * Separator for variant data files saved to storage.
7
7
  *
@@ -83,7 +83,7 @@ exports.parseUniqueId = parseUniqueId;
83
83
  /**
84
84
  * Checks that a string is a unique id.
85
85
  *
86
- * @param uniqueId - A unique id t be checked
86
+ * @param uniqueId - A unique id to be checked
87
87
  */
88
88
  const isUniqueId = (uniqueId) => /(\d{4})-(\d{2})-(\d{2})_(\d{2})-(\d{2})-(\d{2})\.(\d{3}).*/.test(uniqueId);
89
89
  exports.isUniqueId = isUniqueId;
@@ -1,7 +1,11 @@
1
1
  "use strict";
2
2
  var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
3
  if (k2 === undefined) k2 = k;
4
- Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
5
9
  }) : (function(o, m, k, k2) {
6
10
  if (k2 === undefined) k2 = k;
7
11
  o[k2] = m[k];
@@ -1,14 +1,14 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.initWatcher = void 0;
4
- const config_1 = require("@lib/config");
5
- const dataDirManager_1 = require("@lib/store/dataDir/dataDirManager");
6
- const logger_1 = require("@lib/utils/logger");
7
- const cache_1 = require("@lib/utils/cache");
8
- const fs_1 = require("@lib/utils/fs");
9
- const hook_1 = require("@lib/store/hook");
10
- const query_1 = require("@lib/query");
11
- const task_1 = require("@lib/task");
4
+ const config_1 = require("../config");
5
+ const dataDirManager_1 = require("../store/dataDir/dataDirManager");
6
+ const logger_1 = require("../utils/logger");
7
+ const cache_1 = require("../utils/cache");
8
+ const fs_1 = require("../utils/fs");
9
+ const hook_1 = require("../store/hook");
10
+ const query_1 = require("../query");
11
+ const task_1 = require("../task");
12
12
  /**
13
13
  * Initializes a watcher on any file inside queryDir, hookDir and taskDir.
14
14
  *
@@ -1,15 +1,12 @@
1
- import { CacheStatus } from '@lib/query/query.types';
2
- import { LogFile } from '@lib/utils/logger/logger.types';
3
- import { LogLevel } from '@lib/utils/logger/logger.types';
4
- import { QueryArgs } from '@lib/query/query.types';
5
- import { QueryErrorResponse } from '@lib/query/query.types';
6
- import { QueryModule } from '@lib/query/query.types';
7
- import { QueryRunner } from '@lib/query/query.types';
8
- import { QuerySuccessfulResponse } from '@lib/query/query.types';
9
- import { Store } from '@lib/store/store.types';
10
- import { TaskRunner } from '@lib/task/task.types';
11
-
12
- export { CacheStatus }
1
+ /**
2
+ * Possible values for a cache get operation: miss or hit.
3
+ *
4
+ * @public
5
+ */
6
+ export declare enum CacheStatus {
7
+ MISS = "miss",
8
+ HIT = "hit"
9
+ }
13
10
 
14
11
  /**
15
12
  * The Data Server instance.
@@ -84,7 +81,7 @@ export declare type DataServerReturn = {
84
81
  /**
85
82
  * The data store.
86
83
  */
87
- store: Store_2;
84
+ store: Store;
88
85
  /**
89
86
  * The query runner, to be able to run queries on demand.
90
87
  */
@@ -92,22 +89,203 @@ export declare type DataServerReturn = {
92
89
  /**
93
90
  * The task runner, to be able to run tasks on demand.
94
91
  */
95
- taskRunner: TaskRunner_2;
92
+ taskRunner: TaskRunner;
96
93
  };
97
94
 
98
- export { LogFile }
95
+ /**
96
+ * A log file definition.
97
+ */
98
+ export declare type LogFile = {
99
+ /**
100
+ * Path to the log file.
101
+ */
102
+ path: string;
103
+ /**
104
+ * Log level for the log file.
105
+ */
106
+ level: LogLevel;
107
+ };
99
108
 
100
- export { LogLevel }
109
+ /**
110
+ * Log levels: error, warn, info and debug.
111
+ *
112
+ * @public
113
+ */
114
+ export declare enum LogLevel {
115
+ ERROR = "error",
116
+ WARN = "warn",
117
+ INFO = "info",
118
+ DEBUG = "debug"
119
+ }
101
120
 
102
- export { QueryArgs }
121
+ /**
122
+ * An object with query arguments.
123
+ *
124
+ * @public
125
+ */
126
+ export declare type QueryArgs = Record<string, any>;
103
127
 
104
- export { QueryErrorResponse }
128
+ /**
129
+ * An error response returned after executing a query.
130
+ *
131
+ * @remarks
132
+ * It takes an string from QueryModule#queryHandler, and wraps them into an
133
+ * structure with metadata. @see {@link QueryModule#default}
134
+ *
135
+ * @public
136
+ */
137
+ export declare type QueryErrorResponse = {
138
+ /**
139
+ * Error message from the query, usually coming from a failed validation.
140
+ */
141
+ error: string;
142
+ };
105
143
 
106
- export { QueryModule }
144
+ /**
145
+ * A module that defines a query.
146
+ */
147
+ export declare type QueryModule = {
148
+ /**
149
+ * The handler that executes a query.
150
+ *
151
+ * @remarks
152
+ * It receives the store and a set of arguments, executes the query
153
+ * and returns its results.
154
+ *
155
+ * @param options - An object with options for the query: store and args
156
+ */
157
+ default(options: {
158
+ /**
159
+ * Store data to be used in the query
160
+ */
161
+ store: Store;
162
+ args: QueryArgs;
163
+ }): QueryModuleResult;
164
+ };
107
165
 
108
- export { QueryRunner }
166
+ /**
167
+ * The result that a query returns after being executed.
168
+ */
169
+ declare type QueryModuleResult = {
170
+ /**
171
+ * A result, which can be of any kind (and array, an object, a string, etc)
172
+ */
173
+ result: any;
174
+ /**
175
+ * Optional content type for the data available in "result"
176
+ *
177
+ * @remarks
178
+ * Data coming from the query can be anything (XML, a string, etc).
179
+ * This content type is added to the metadata section of the QueryResponse.
180
+ * @see {@link QuerySuccessfulResponse#metadata}.
181
+ *
182
+ * @defaultValue 'application/json'
183
+ */
184
+ contentType?: string;
185
+ /**
186
+ * Optional flag that tells whether this result can be cached or not.
187
+ */
188
+ cacheable?: boolean;
189
+ /**
190
+ * A list of tags to get this query invalidated.
191
+ */
192
+ tags?: string[];
193
+ };
109
194
 
110
- export { QuerySuccessfulResponse }
195
+ /**
196
+ * A service to handle the execution of queries.
197
+ *
198
+ * @public
199
+ */
200
+ export declare type QueryRunner = {
201
+ /**
202
+ * Runs a query and returns its results with metadata.
203
+ *
204
+ * @remarks
205
+ * It checks several validations before a query is run, and then it tries to get
206
+ * the query result from cache. If cache is empty, query is executed and saved
207
+ * into the cache.
208
+ *
209
+ * It logs an error and throws an exception if any problem occurs during the
210
+ * query execution.
211
+ *
212
+ * @param queryDefinition - An URL containing a query ID (filename without extension
213
+ * and suffix) of the query to be executed, plus and optional query string with arguments.
214
+ * @see {@link ModuleInfo#id | Definition of a module ID}
215
+ *
216
+ * @returns The result of the query as a JSON object with data and metadata keys,
217
+ * or an error response if some validation is not met.
218
+ *
219
+ * @example
220
+ * Here's a result example:
221
+ * ```
222
+ * {
223
+ * data: ['title 1', 'title 2'],
224
+ * metadata: {
225
+ * contentType: 'application/json',
226
+ * execTime: 2,
227
+ * cache: ['miss'|'hit'],
228
+ * num: 2,
229
+ * }
230
+ * }
231
+ * ```
232
+
233
+ * @throws
234
+ * Exception thrown if any problem occurs during the query execution.
235
+ */
236
+ run(queryDefinition: string): QuerySuccessfulResponse | QueryErrorResponse;
237
+ /**
238
+ * Gets number of executed queries.
239
+ *
240
+ * @remarks
241
+ * A simple counter that stores the number of executed queries, of any type.
242
+ *
243
+ * @returns Number of executed queries.
244
+ */
245
+ getCount(): number;
246
+ };
247
+
248
+ /**
249
+ * A successful response returned after executing a query.
250
+ *
251
+ * @remarks
252
+ * It takes the results from a QueryModule#queryHandler, and wraps them into an
253
+ * structure with metadata. @see {@link QueryModule#default}
254
+ *
255
+ * @public
256
+ */
257
+ export declare type QuerySuccessfulResponse = {
258
+ /**
259
+ * Data returned by the query. @see {@link QueryModule#default}
260
+ */
261
+ data: any;
262
+ /**
263
+ * Query metadata
264
+ */
265
+ metadata: {
266
+ /**
267
+ * Content type for the data available in "data"
268
+ *
269
+ * @remarks
270
+ * Even thought this structure is a JSON object, data coming from the
271
+ * query can be anything (XML, a string, etc). It must be specified so any
272
+ * consumer of this data knows what is being returned.
273
+ */
274
+ contentType: string;
275
+ /**
276
+ * Execution time taken by the query, in milliseconds.
277
+ */
278
+ execTimeMs: number;
279
+ /**
280
+ * Tells wether the query results comes from a miss or hit.
281
+ */
282
+ cache: CacheStatus;
283
+ /**
284
+ * A list of tags to get this query invalidated.
285
+ */
286
+ tags?: string[];
287
+ };
288
+ };
111
289
 
112
290
  /**
113
291
  * Available run modes: dev or prod.
@@ -119,12 +297,10 @@ export declare enum RunMode {
119
297
  PROD = "prod"
120
298
  }
121
299
 
122
- export { Store }
123
-
124
300
  /**
125
301
  * The store that holds all data.
126
302
  */
127
- declare type Store_2 = {
303
+ export declare type Store = {
128
304
  /**
129
305
  * Initial unique id when the store was initially loaded.
130
306
  */
@@ -293,14 +469,12 @@ declare type TaskErrorResponse = {
293
469
  error: string;
294
470
  };
295
471
 
296
- export { TaskRunner }
297
-
298
472
  /**
299
473
  * A service to handle the execution of tasks.
300
474
  *
301
475
  * @public
302
476
  */
303
- declare type TaskRunner_2 = {
477
+ export declare type TaskRunner = {
304
478
  /**
305
479
  * Runs a task and returns its results with metadata.
306
480
  *
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@static-suite/static-suite-data-server",
3
- "version": "0.0.8",
3
+ "version": "0.0.9",
4
4
  "description": "A flexible, fast and developer friendly Data Server for Static Suite",
5
5
  "main": "./dist/lib/index.js",
6
6
  "typings": "./dist/lib/index.d.ts",
@@ -12,29 +12,28 @@
12
12
  },
13
13
  "dependencies": {
14
14
  "@creativebulma/bulma-tooltip": "^1.2.0",
15
- "@microsoft/api-extractor": "^7.18.19",
16
- "@types/jest": "^27.0.2",
17
- "@types/tap": "^15.0.5",
18
- "bulma": "^0.9.3",
19
- "chokidar": "^3.5.2",
20
- "clear-module": "^4.1.1",
21
- "clipboard": "^2.0.8",
15
+ "@microsoft/api-extractor": "^7.34.4",
16
+ "@types/jest": "^29.4.0",
17
+ "@types/tap": "^15.0.8",
18
+ "bulma": "^0.9.4",
19
+ "chokidar": "^3.5.3",
20
+ "clear-module": "^4.1.2",
21
+ "clipboard": "^2.0.11",
22
22
  "copyfiles": "^2.4.1",
23
23
  "cors": "^2.8.5",
24
- "decache": "^4.6.0",
25
- "express": "^4.17.1",
26
- "fast-glob": "^3.2.7",
27
- "marked": "^3.0.4",
28
- "microtime": "^3.0.0",
29
- "mime-types": "^2.1.33",
30
- "module-alias": "^2.2.2",
31
- "nodemon": "^2.0.13",
24
+ "decache": "^4.6.1",
25
+ "express": "^4.18.2",
26
+ "fast-glob": "^3.2.12",
27
+ "marked": "^4.2.12",
28
+ "microtime": "^3.1.1",
29
+ "mime-types": "^2.1.35",
30
+ "nodemon": "^2.0.20",
32
31
  "pug": "^3.0.2",
33
- "simple-datatables": "^3.1.2",
34
- "tsc-watch": "^4.5.0",
35
- "typescript": "^4.4.3",
36
- "winston": "^3.3.3",
37
- "yargs": "^17.2.1"
32
+ "simple-datatables": "^7.1.2",
33
+ "tsc-watch": "^6.0.0",
34
+ "typescript": "^4.9.5",
35
+ "winston": "^3.8.2",
36
+ "yargs": "^17.6.2"
38
37
  },
39
38
  "bin": {
40
39
  "static-suite-data-server": "./dist/bin/serve.js"
@@ -49,37 +48,32 @@
49
48
  "prettier-format": "prettier --config .prettierrc 'src/**/*.ts' --write",
50
49
  "test": "jest --watch",
51
50
  "copy-http-files-to-src": "node ./scripts/copy-http-files-to-src.js",
52
- "copy-http-files-to-dist": "cp -r ./src/http/public/ ./dist/http/ && cp -r ./src/http/views/ ./dist/http/ && cp README.md ./dist/http/"
51
+ "copy-http-files-to-dist": "cp -r ./src/http/public/ ./dist/http/ && cp -r ./src/http/views/ ./dist/http/ && cp README.md ./dist/http/",
52
+ "prepare": "husky install"
53
53
  },
54
54
  "devDependencies": {
55
- "@types/cors": "^2.8.12",
56
- "@types/express": "^4.17.13",
57
- "@types/marked": "^3.0.2",
55
+ "@types/cors": "^2.8.13",
56
+ "@types/express": "^4.17.17",
57
+ "@types/marked": "^4.0.8",
58
58
  "@types/microtime": "^2.1.0",
59
59
  "@types/mime-types": "^2.1.1",
60
60
  "@types/module-alias": "^2.0.1",
61
- "@types/node": "^16.10.2",
62
- "@types/yargs": "^17.0.3",
63
- "@typescript-eslint/eslint-plugin": "^4.33.0",
64
- "@typescript-eslint/parser": "^4.33.0",
65
- "eslint": "^7.32.0",
66
- "eslint-config-airbnb-typescript-prettier": "^4.2.0",
67
- "eslint-import-resolver-typescript": "^2.5.0",
68
- "eslint-plugin-import": "^2.25.2",
69
- "eslint-plugin-prettier": "^4.0.0",
70
- "eslint-plugin-tsdoc": "^0.2.14",
71
- "husky": "^4.3.7",
72
- "jest": "^27.3.1",
73
- "prettier": "^2.4.1",
74
- "ts-jest": "^27.0.7",
75
- "typedoc": "^0.22.6",
76
- "yarn-upgrade-all": "^0.5.4"
77
- },
78
- "_moduleAliases": {
79
- "@bin": "dist/bin",
80
- "@http": "dist/http",
81
- "@lib": "dist/lib",
82
- "@__tests__": "dist/__tests__"
61
+ "@types/node": "^18.13.0",
62
+ "@types/yargs": "^17.0.22",
63
+ "@typescript-eslint/eslint-plugin": "^5.52.0",
64
+ "@typescript-eslint/parser": "^5.52.0",
65
+ "eslint": "^8.34.0",
66
+ "eslint-config-airbnb-typescript-prettier": "^5.0.0",
67
+ "eslint-import-resolver-typescript": "^3.5.3",
68
+ "eslint-plugin-import": "^2.27.5",
69
+ "eslint-plugin-prettier": "^4.2.1",
70
+ "eslint-plugin-tsdoc": "^0.2.17",
71
+ "husky": "^8.0.0",
72
+ "jest": "^29.4.3",
73
+ "prettier": "^2.8.4",
74
+ "ts-jest": "^29.0.5",
75
+ "typedoc": "^0.23.25",
76
+ "yarn-upgrade-all": "^0.7.2"
83
77
  },
84
78
  "jest": {
85
79
  "preset": "ts-jest",
@@ -91,17 +85,6 @@
91
85
  "testPathIgnorePatterns": [
92
86
  "src/__tests__/fixtures/*",
93
87
  "src/__tests__/mocks/*"
94
- ],
95
- "moduleNameMapper": {
96
- "^@bin/(.*)$": "<rootDir>/src/bin/$1",
97
- "^@http/(.*)$": "<rootDir>/src/http/$1",
98
- "^@lib/(.*)$": "<rootDir>/src/lib/$1",
99
- "^@__tests__/(.*)$": "<rootDir>/src/__tests__/$1"
100
- }
101
- },
102
- "husky": {
103
- "hooks": {
104
- "pre-commit": "yarn build"
105
- }
88
+ ]
106
89
  }
107
- }
90
+ }
package/src/bin/serve.ts CHANGED
@@ -3,13 +3,11 @@
3
3
 
4
4
  import yargs from 'yargs/yargs';
5
5
  import { hideBin } from 'yargs/helpers';
6
- // eslint-disable-next-line @typescript-eslint/no-var-requires
7
- require('module-alias')(`${__dirname}/../..`);
8
6
 
9
- import { httpServer } from '@http/httpServer';
10
- import { dataServer } from '@lib/dataServer';
11
- import { RunMode, RunModeStrings } from '@lib/dataServer.types';
12
- import { LogLevel, LogLevelStrings } from '@lib/utils/logger/logger.types';
7
+ import { httpServer } from '../http/httpServer';
8
+ import { dataServer } from '../lib/dataServer';
9
+ import { RunMode, RunModeStrings } from '../lib/dataServer.types';
10
+ import { LogLevel, LogLevelStrings } from '../lib/utils/logger/logger.types';
13
11
 
14
12
  const argv = yargs(hideBin(process.argv))
15
13
  .usage('Usage: $0 http --data-dir [path]')
@@ -1,7 +1,7 @@
1
1
  import path from 'path';
2
2
  import express from 'express';
3
3
  import cors from 'cors';
4
- import { logger } from '@lib/utils/logger';
4
+ import { logger } from '../lib/utils/logger';
5
5
  import routes from './routes';
6
6
 
7
7
  export const httpServer = {
@@ -1,8 +1,8 @@
1
1
  import { Request, Response } from 'express';
2
- import { cache } from '@lib/utils/cache';
2
+ import { cache } from '../../lib/utils/cache';
3
3
 
4
4
  export const cacheIndex = (req: Request, res: Response): void => {
5
- const cacheBins = Array.from(cache.keys());
5
+ const cacheBins = cache.keys();
6
6
  res.render('cacheIndex', { cacheBins });
7
7
  };
8
8
 
@@ -1,9 +1,9 @@
1
1
  import path from 'path';
2
2
  import { Request, Response } from 'express';
3
3
  import mime from 'mime-types';
4
- import { store } from '@lib/store';
5
- import { logger } from '@lib/utils/logger';
6
- import { dataDirManager } from '@lib/store/dataDir';
4
+ import { store } from '../../lib/store';
5
+ import { logger } from '../../lib/utils/logger';
6
+ import { dataDirManager } from '../../lib/store/dataDir';
7
7
 
8
8
  const data = (req: Request, res: Response): void => {
9
9
  dataDirManager.update();
@@ -1,17 +1,16 @@
1
- // import microtime from 'microtime';
2
1
  import { Request, Response } from 'express';
3
- import { dataDirManager } from '@lib/store/dataDir';
4
- import { jsonify } from '@lib/utils/object';
2
+ import { dataDirManager } from '../../lib/store/dataDir';
3
+ import { jsonify } from '../../lib/utils/object';
5
4
  import {
6
5
  dependencyManager,
7
6
  getAllInvalidatedTags,
8
7
  getTagParents,
9
- } from '@lib/store/dependency/dependencyManager';
8
+ } from '../../lib/store/dependency/dependencyManager';
10
9
  import {
11
10
  dependencyTree,
12
11
  getReversedDependencyTree,
13
12
  invalidatedTags,
14
- } from '@lib/store/dependency/dependencyTagger';
13
+ } from '../../lib/store/dependency/dependencyTagger';
15
14
 
16
15
  const dependencyIndex = (req: Request, res: Response): void => {
17
16
  res.render('dependencyIndex', {
@@ -74,7 +73,7 @@ const dependencyInvalidatedFilepaths = (req: Request, res: Response): void => {
74
73
  const dependencyTagParents = (req: Request, res: Response): void => {
75
74
  dataDirManager.update();
76
75
  const args: any = req.query;
77
- const response = args?.tag ? jsonify(getTagParents(args.tag)) : null;
76
+ const response = args?.tag ? jsonify(getTagParents(args.tag)) : {};
78
77
  res.status(200);
79
78
  res.set({ 'Content-Type': 'application/json' });
80
79
  res.send(response);
@@ -1,9 +1,9 @@
1
1
  import { Request, Response } from 'express';
2
2
  import path from 'path';
3
- import marked from 'marked';
4
- import { readFile } from '@lib/utils/fs/fsUtils';
3
+ import { marked } from 'marked';
4
+ import { readFile } from '../../lib/utils/fs/fsUtils';
5
5
 
6
6
  export const docs = (req: Request, res: Response): void => {
7
7
  const readme = readFile(path.join(__dirname, '../README.md'));
8
- res.render('docs', { marked, readme });
8
+ res.render('docs', { readme: readme ? marked(readme) : '' });
9
9
  };
@@ -1,8 +1,8 @@
1
1
  import fs from 'fs';
2
2
  import { Request, Response } from 'express';
3
- import { dumpManager } from '@lib/store/dump';
4
- import { jsonify } from '@lib/utils/object';
5
- import { config } from '@lib/config';
3
+ import { dumpManager } from '../../lib/store/dump';
4
+ import { jsonify } from '../../lib/utils/object';
5
+ import { config } from '../../lib/config';
6
6
 
7
7
  const dumpIndex = (req: Request, res: Response): void => {
8
8
  res.render('dumpIndex', {
@@ -1,10 +1,10 @@
1
1
  import { Request, Response } from 'express';
2
- import { dataDirManager } from '@lib/store/dataDir';
3
- import { queryRunner, queryManager } from '@lib/query';
2
+ import { dataDirManager } from '../../lib/store/dataDir';
3
+ import { queryRunner, queryManager } from '../../lib/query';
4
4
  import {
5
5
  QueryErrorResponse,
6
6
  QuerySuccessfulResponse,
7
- } from '@lib/query/query.types';
7
+ } from '../../lib/query/query.types';
8
8
 
9
9
  const queryIndex = (req: Request, res: Response): void => {
10
10
  const queryIds = Array.from(queryManager.getModuleGroupInfo().keys());
@@ -1,13 +1,13 @@
1
1
  // import microtime from 'microtime';
2
2
  import { Request, Response } from 'express';
3
- import { dataDirManager } from '@lib/store/dataDir';
4
- import { queryRunner } from '@lib/query';
5
- import { config } from '@lib/config';
6
- import { cache } from '@lib/utils/cache';
7
- import { store } from '@lib/store';
8
- import { jsonify } from '@lib/utils/object';
9
- import { diffManager } from '@lib/store/diff/diffManager';
10
- import { ObjectType } from '@lib/utils/object/object.types';
3
+ import { dataDirManager } from '../../lib/store/dataDir';
4
+ import { queryRunner } from '../../lib/query';
5
+ import { config } from '../../lib/config';
6
+ import { cache } from '../../lib/utils/cache';
7
+ import { store } from '../../lib/store';
8
+ import { jsonify } from '../../lib/utils/object';
9
+ import { diffManager } from '../../lib/store/diff/diffManager';
10
+ import { ObjectType } from '../../lib/utils/object/object.types';
11
11
 
12
12
  const statusIndex = (req: Request, res: Response): void => {
13
13
  res.render('statusIndex', {
@@ -1,10 +1,10 @@
1
1
  import { Request, Response } from 'express';
2
- import { dataDirManager } from '@lib/store/dataDir';
3
- import { taskRunner, taskManager } from '@lib/task';
2
+ import { dataDirManager } from '../../lib/store/dataDir';
3
+ import { taskRunner, taskManager } from '../../lib/task';
4
4
  import {
5
5
  TaskErrorResponse,
6
6
  TaskSuccessfulResponse,
7
- } from '@lib/task/task.types';
7
+ } from '../../lib/task/task.types';
8
8
 
9
9
  const taskIndex = (req: Request, res: Response): void => {
10
10
  const taskIds = Array.from(taskManager.getModuleGroupInfo().keys());