@stryker-mutator/dashboard-data-access 0.15.1-pr-897.3 → 0.15.1-pr-905.0

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.
@@ -1,8 +1,6 @@
1
1
  import { encodeKey } from '../utils.js';
2
2
  import { odata } from '@azure/data-tables';
3
3
  export class DashboardQuery {
4
- ModelClass;
5
- whereConditions;
6
4
  constructor(ModelClass, whereConditions) {
7
5
  this.ModelClass = ModelClass;
8
6
  this.whereConditions = whereConditions;
@@ -1,3 +1,15 @@
1
+ var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
2
+ if (kind === "m") throw new TypeError("Private method is not writable");
3
+ if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
4
+ if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
5
+ return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
6
+ };
7
+ var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
8
+ if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
9
+ if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
10
+ return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
11
+ };
12
+ var _MutationTestingResultMapper_containerClient;
1
13
  import { hasErrorCode, toBlobName } from '../utils.js';
2
14
  import { OptimisticConcurrencyError } from '../errors/index.js';
3
15
  import { createBlobServiceClient } from '../services/BlobServiceClient.js';
@@ -9,17 +21,16 @@ const errCodes = Object.freeze({
9
21
  * The report json part of a mutation testing report is stored in blob storage
10
22
  */
11
23
  export class MutationTestingResultMapper {
12
- static CONTAINER_NAME = 'mutation-testing-report';
13
- #containerClient;
14
24
  constructor(blobService = createBlobServiceClient()) {
15
- this.#containerClient = blobService.getContainerClient(MutationTestingResultMapper.CONTAINER_NAME);
25
+ _MutationTestingResultMapper_containerClient.set(this, void 0);
26
+ __classPrivateFieldSet(this, _MutationTestingResultMapper_containerClient, blobService.getContainerClient(MutationTestingResultMapper.CONTAINER_NAME), "f");
16
27
  }
17
28
  createStorageIfNotExists() {
18
- return this.#containerClient.createIfNotExists({});
29
+ return __classPrivateFieldGet(this, _MutationTestingResultMapper_containerClient, "f").createIfNotExists({});
19
30
  }
20
31
  async insertOrReplace(id, result) {
21
32
  try {
22
- await this.#containerClient
33
+ await __classPrivateFieldGet(this, _MutationTestingResultMapper_containerClient, "f")
23
34
  .getBlockBlobClient(toBlobName(id))
24
35
  .uploadData(Buffer.from(JSON.stringify(result), 'utf-8'), {
25
36
  blobHTTPHeaders: {
@@ -40,7 +51,7 @@ export class MutationTestingResultMapper {
40
51
  async findOne(identifier) {
41
52
  const blobName = toBlobName(identifier);
42
53
  try {
43
- const result = JSON.parse((await this.#containerClient.getBlockBlobClient(blobName).downloadToBuffer()).toString('utf-8'));
54
+ const result = JSON.parse((await __classPrivateFieldGet(this, _MutationTestingResultMapper_containerClient, "f").getBlockBlobClient(blobName).downloadToBuffer()).toString('utf-8'));
44
55
  return result;
45
56
  }
46
57
  catch (error) {
@@ -55,7 +66,9 @@ export class MutationTestingResultMapper {
55
66
  }
56
67
  async delete(id) {
57
68
  const blobName = toBlobName(id);
58
- await this.#containerClient.getBlockBlobClient(blobName).deleteIfExists();
69
+ await __classPrivateFieldGet(this, _MutationTestingResultMapper_containerClient, "f").getBlockBlobClient(blobName).deleteIfExists();
59
70
  }
60
71
  }
72
+ _MutationTestingResultMapper_containerClient = new WeakMap();
73
+ MutationTestingResultMapper.CONTAINER_NAME = 'mutation-testing-report';
61
74
  //# sourceMappingURL=MutationTestingResultMapper.js.map
@@ -1,3 +1,22 @@
1
+ var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
2
+ if (kind === "m") throw new TypeError("Private method is not writable");
3
+ if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
4
+ if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
5
+ return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
6
+ };
7
+ var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
8
+ if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
9
+ if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
10
+ return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
11
+ };
12
+ var __asyncValues = (this && this.__asyncValues) || function (o) {
13
+ if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined.");
14
+ var m = o[Symbol.asyncIterator], i;
15
+ return m ? m.call(o) : (o = typeof __values === "function" ? __values(o) : o[Symbol.iterator](), i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function () { return this; }, i);
16
+ function verb(n) { i[n] = o[n] && function (v) { return new Promise(function (resolve, reject) { v = o[n](v), settle(resolve, reject, v.done, v.value); }); }; }
17
+ function settle(resolve, reject, d, v) { Promise.resolve(v).then(function(v) { resolve({ value: v, done: d }); }, reject); }
18
+ };
19
+ var _TableStorageMapper_tableClient;
1
20
  import { encodeKey, decodeKey, hasErrorCode } from '../utils.js';
2
21
  import { OptimisticConcurrencyError } from '../errors/index.js';
3
22
  import { DashboardQuery } from './DashboardQuery.js';
@@ -7,23 +26,22 @@ const errCodes = Object.freeze({
7
26
  ENTITY_ALREADY_EXISTS: 'EntityAlreadyExists',
8
27
  RESOURCE_NOT_FOUND: 'ResourceNotFound',
9
28
  });
10
- export default class TableStorageMapper {
11
- ModelClass;
12
- #tableClient;
29
+ class TableStorageMapper {
13
30
  constructor(ModelClass, tableClient = createTableClient(ModelClass.name)) {
14
31
  this.ModelClass = ModelClass;
15
- this.#tableClient = tableClient;
32
+ _TableStorageMapper_tableClient.set(this, void 0);
33
+ __classPrivateFieldSet(this, _TableStorageMapper_tableClient, tableClient, "f");
16
34
  }
17
35
  async createStorageIfNotExists() {
18
- await this.#tableClient.createTable();
36
+ await __classPrivateFieldGet(this, _TableStorageMapper_tableClient, "f").createTable();
19
37
  }
20
38
  async insertOrMerge(model) {
21
39
  const entity = this.toEntity(model);
22
- await this.#tableClient.upsertEntity(entity, 'Merge');
40
+ await __classPrivateFieldGet(this, _TableStorageMapper_tableClient, "f").upsertEntity(entity, 'Merge');
23
41
  }
24
42
  async findOne(identity) {
25
43
  try {
26
- const result = await this.#tableClient.getEntity(encodeKey(this.ModelClass.createPartitionKey(identity)), encodeKey(this.ModelClass.createRowKey(identity) || ''));
44
+ const result = await __classPrivateFieldGet(this, _TableStorageMapper_tableClient, "f").getEntity(encodeKey(this.ModelClass.createPartitionKey(identity)), encodeKey(this.ModelClass.createRowKey(identity) || ''));
27
45
  return this.toModel(result);
28
46
  }
29
47
  catch (err) {
@@ -37,11 +55,24 @@ export default class TableStorageMapper {
37
55
  }
38
56
  }
39
57
  async findAll(query = DashboardQuery.create(this.ModelClass)) {
58
+ var _a, e_1, _b, _c;
40
59
  const tableQuery = query.build();
41
- const entities = this.#tableClient.listEntities({ queryOptions: tableQuery });
60
+ const entities = __classPrivateFieldGet(this, _TableStorageMapper_tableClient, "f").listEntities({ queryOptions: tableQuery });
42
61
  const results = [];
43
- for await (const entity of entities) {
44
- results.push(this.toModel(entity));
62
+ try {
63
+ for (var _d = true, entities_1 = __asyncValues(entities), entities_1_1; entities_1_1 = await entities_1.next(), _a = entities_1_1.done, !_a; _d = true) {
64
+ _c = entities_1_1.value;
65
+ _d = false;
66
+ const entity = _c;
67
+ results.push(this.toModel(entity));
68
+ }
69
+ }
70
+ catch (e_1_1) { e_1 = { error: e_1_1 }; }
71
+ finally {
72
+ try {
73
+ if (!_d && !_a && (_b = entities_1.return)) await _b.call(entities_1);
74
+ }
75
+ finally { if (e_1) throw e_1.error; }
45
76
  }
46
77
  return results;
47
78
  }
@@ -54,7 +85,7 @@ export default class TableStorageMapper {
54
85
  async replace(model, etag) {
55
86
  const entity = this.toEntity(model);
56
87
  try {
57
- const result = await this.#tableClient.updateEntity(entity, 'Replace', { etag });
88
+ const result = await __classPrivateFieldGet(this, _TableStorageMapper_tableClient, "f").updateEntity(entity, 'Replace', { etag });
58
89
  return { model, etag: result.etag };
59
90
  }
60
91
  catch (err) {
@@ -69,7 +100,7 @@ export default class TableStorageMapper {
69
100
  async insert(model) {
70
101
  const entity = this.toEntity(model);
71
102
  try {
72
- const result = await this.#tableClient.createEntity(entity);
103
+ const result = await __classPrivateFieldGet(this, _TableStorageMapper_tableClient, "f").createEntity(entity);
73
104
  return { model, etag: result.etag };
74
105
  }
75
106
  catch (err) {
@@ -91,7 +122,6 @@ export default class TableStorageMapper {
91
122
  };
92
123
  }
93
124
  toEntity(entity) {
94
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
95
125
  const data = {
96
126
  partitionKey: encodeKey(this.ModelClass.createPartitionKey(entity)),
97
127
  rowKey: encodeKey(this.ModelClass.createRowKey(entity) || ''),
@@ -100,4 +130,6 @@ export default class TableStorageMapper {
100
130
  return data;
101
131
  }
102
132
  }
133
+ _TableStorageMapper_tableClient = new WeakMap();
134
+ export default TableStorageMapper;
103
135
  //# sourceMappingURL=TableStorageMapper.js.map
@@ -1,24 +1,4 @@
1
1
  export class MutationTestingReport {
2
- /**
3
- * The repo slug. /:provider/:owner/:name (could also have more components in the future, for example gitlab supports this)
4
- * @example /github.com/stryker-mutator/mutation-testing-elements
5
- */
6
- projectName;
7
- /**
8
- * The branch, tag or git hash
9
- * @example 'master', 'v1', '0d3af4840904c42dede7016f45b53718a617bbd8'
10
- */
11
- version;
12
- /**
13
- * Optional: the module
14
- * For example 'schema'
15
- */
16
- moduleName;
17
- /**
18
- * Indicates whether this report is real-time.
19
- */
20
- realTime;
21
- mutationScore;
22
2
  static createRowKey(identifier) {
23
3
  return identifier.moduleName;
24
4
  }
@@ -31,7 +11,7 @@ export class MutationTestingReport {
31
11
  entity.version = partitionKeyValue.substr(versionSplit + 1);
32
12
  entity.moduleName = rowKeyValue;
33
13
  }
34
- static persistedFields = ['mutationScore'];
35
- static tableName = 'MutationTestingReport';
36
14
  }
15
+ MutationTestingReport.persistedFields = ['mutationScore'];
16
+ MutationTestingReport.tableName = 'MutationTestingReport';
37
17
  //# sourceMappingURL=MutationTestingReport.js.map
@@ -1,10 +1,4 @@
1
1
  export class Project {
2
- owner;
3
- name;
4
- enabled;
5
- apiKeyHash;
6
- static persistedFields = ['enabled', 'apiKeyHash'];
7
- static tableName = 'Project';
8
2
  static createRowKey(identifier) {
9
3
  return identifier.name;
10
4
  }
@@ -16,4 +10,6 @@ export class Project {
16
10
  entity.owner = partitionKeyValue;
17
11
  }
18
12
  }
13
+ Project.persistedFields = ['enabled', 'apiKeyHash'];
14
+ Project.tableName = 'Project';
19
15
  //# sourceMappingURL=Project.js.map
@@ -1,6 +1,6 @@
1
1
  import { aggregateResultsByModule, calculateMetrics } from 'mutation-testing-metrics';
2
2
  import { MutationTestingResultMapper } from '../mappers/MutationTestingResultMapper.js';
3
- import { createMutationTestingReportMapper, DashboardQuery } from '../mappers/index.js';
3
+ import { createMutationTestingReportMapper, DashboardQuery, } from '../mappers/index.js';
4
4
  import { isMutationTestResult, } from '@stryker-mutator/dashboard-common';
5
5
  import { MutationTestingReport } from '../models/index.js';
6
6
  import { OptimisticConcurrencyError } from '../errors/index.js';
@@ -8,8 +8,6 @@ function moduleHasResult(tuple) {
8
8
  return !!tuple[1];
9
9
  }
10
10
  export class MutationTestingReportService {
11
- resultMapper;
12
- mutationScoreMapper;
13
11
  constructor(resultMapper = new MutationTestingResultMapper(), mutationScoreMapper = createMutationTestingReportMapper()) {
14
12
  this.resultMapper = resultMapper;
15
13
  this.mutationScoreMapper = mutationScoreMapper;
@@ -20,10 +18,7 @@ export class MutationTestingReportService {
20
18
  }
21
19
  async saveReport(id, result, logger) {
22
20
  const mutationScore = this.calculateMutationScore(result);
23
- await this.insertOrMergeReport(id, {
24
- ...id,
25
- mutationScore,
26
- }, isMutationTestResult(result) ? result : null);
21
+ await this.insertOrMergeReport(id, Object.assign(Object.assign({}, id), { mutationScore }), isMutationTestResult(result) ? result : null);
27
22
  if (isMutationTestResult(result) && id.moduleName) {
28
23
  await this.aggregateProjectReport(id.projectName, id.version, logger);
29
24
  }
@@ -48,10 +43,7 @@ export class MutationTestingReportService {
48
43
  const resultsByModule = Object.fromEntries((await Promise.all(moduleScoreResults.map(async (score) => [score.model.moduleName, await this.resultMapper.findOne(score.model)]))).filter(moduleHasResult));
49
44
  if (Object.keys(resultsByModule).length) {
50
45
  const projectResult = aggregateResultsByModule(resultsByModule);
51
- const projectReport = {
52
- ...id,
53
- mutationScore: this.calculateMutationScore(projectResult),
54
- };
46
+ const projectReport = Object.assign(Object.assign({}, id), { mutationScore: this.calculateMutationScore(projectResult) });
55
47
  try {
56
48
  await this.resultMapper.insertOrReplace(id, projectResult);
57
49
  if (projectMutationScoreModel) {
@@ -79,14 +71,10 @@ export class MutationTestingReportService {
79
71
  ]);
80
72
  if (reportEntity) {
81
73
  if (result) {
82
- return {
83
- ...id,
84
- mutationScore: reportEntity.model.mutationScore,
85
- ...result,
86
- };
74
+ return Object.assign(Object.assign(Object.assign({}, id), { mutationScore: reportEntity.model.mutationScore }), result);
87
75
  }
88
76
  else {
89
- return { ...id, mutationScore: reportEntity.model.mutationScore };
77
+ return Object.assign(Object.assign({}, id), { mutationScore: reportEntity.model.mutationScore });
90
78
  }
91
79
  }
92
80
  else {
@@ -97,7 +85,10 @@ export class MutationTestingReportService {
97
85
  await this.resultMapper.delete(id);
98
86
  }
99
87
  async insertOrMergeReport(id, report, result) {
100
- await Promise.all([this.resultMapper.insertOrReplace(id, result), this.mutationScoreMapper.insertOrMerge(report)]);
88
+ await Promise.all([
89
+ this.resultMapper.insertOrReplace(id, result),
90
+ this.mutationScoreMapper.insertOrMerge(report),
91
+ ]);
101
92
  }
102
93
  calculateMutationScore(result) {
103
94
  if (isMutationTestResult(result)) {
@@ -1,26 +1,37 @@
1
+ var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
2
+ if (kind === "m") throw new TypeError("Private method is not writable");
3
+ if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
4
+ if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
5
+ return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
6
+ };
7
+ var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
8
+ if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
9
+ if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
10
+ return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
11
+ };
12
+ var _RealTimeMutantsBlobService_containerClient;
1
13
  import { toBlobName } from '../utils.js';
2
14
  import { createBlobServiceClient } from './BlobServiceClient.js';
3
15
  // To make resource delete themselves automatically, this should be managed from within Azure:
4
16
  // https://learn.microsoft.com/en-us/azure/storage/blobs/lifecycle-management-overview?tabs=azure-portal
5
17
  export class RealTimeMutantsBlobService {
6
- static CONTAINER_NAME = 'real-time-mutant-results';
7
- #containerClient;
8
18
  constructor(blobService = createBlobServiceClient()) {
9
- this.#containerClient = blobService.getContainerClient(RealTimeMutantsBlobService.CONTAINER_NAME);
19
+ _RealTimeMutantsBlobService_containerClient.set(this, void 0);
20
+ __classPrivateFieldSet(this, _RealTimeMutantsBlobService_containerClient, blobService.getContainerClient(RealTimeMutantsBlobService.CONTAINER_NAME), "f");
10
21
  }
11
22
  async createStorageIfNotExists() {
12
- await this.#containerClient.createIfNotExists({});
23
+ await __classPrivateFieldGet(this, _RealTimeMutantsBlobService_containerClient, "f").createIfNotExists({});
13
24
  }
14
25
  async createReport(id) {
15
- await this.#containerClient.getAppendBlobClient(toBlobName(id)).create();
26
+ await __classPrivateFieldGet(this, _RealTimeMutantsBlobService_containerClient, "f").getAppendBlobClient(toBlobName(id)).create();
16
27
  }
17
28
  async appendToReport(id, mutants) {
18
29
  const blobName = toBlobName(id);
19
30
  const data = mutants.map((mutant) => `${JSON.stringify(mutant)}\n`).join('');
20
- await this.#containerClient.getAppendBlobClient(blobName).appendBlock(data, data.length);
31
+ await __classPrivateFieldGet(this, _RealTimeMutantsBlobService_containerClient, "f").getAppendBlobClient(blobName).appendBlock(data, data.length);
21
32
  }
22
33
  async getReport(id) {
23
- const data = await this.#containerClient.getAppendBlobClient(toBlobName(id)).downloadToBuffer();
34
+ const data = await __classPrivateFieldGet(this, _RealTimeMutantsBlobService_containerClient, "f").getAppendBlobClient(toBlobName(id)).downloadToBuffer();
24
35
  return (data
25
36
  .toString('utf-8')
26
37
  .split('\n')
@@ -31,7 +42,9 @@ export class RealTimeMutantsBlobService {
31
42
  }
32
43
  async delete(id) {
33
44
  const blobName = toBlobName(id);
34
- await this.#containerClient.getAppendBlobClient(blobName).deleteIfExists();
45
+ await __classPrivateFieldGet(this, _RealTimeMutantsBlobService_containerClient, "f").getAppendBlobClient(blobName).deleteIfExists();
35
46
  }
36
47
  }
48
+ _RealTimeMutantsBlobService_containerClient = new WeakMap();
49
+ RealTimeMutantsBlobService.CONTAINER_NAME = 'real-time-mutant-results';
37
50
  //# sourceMappingURL=RealTimeMutantsBlobService.js.map
package/dist/src/utils.js CHANGED
@@ -9,14 +9,18 @@ export function isStorageError(maybeStorageError) {
9
9
  return maybeStorageError instanceof RestError;
10
10
  }
11
11
  export function hasErrorCode(err, code) {
12
+ var _a;
12
13
  if (!isStorageError(err))
13
14
  return false;
14
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
15
15
  const details = err.details;
16
- return (typeof details === 'object' && details !== null && (details.errorCode === code || details.odataError?.code === code));
16
+ return (typeof details === 'object' &&
17
+ details !== null &&
18
+ (details.errorCode === code || ((_a = details.odataError) === null || _a === void 0 ? void 0 : _a.code) === code));
17
19
  }
18
20
  export function toBlobName({ projectName, version, moduleName, realTime }) {
19
- const slug = [projectName, version, moduleName, realTime ? 'real-time' : realTime].filter(Boolean).join('/');
21
+ const slug = [projectName, version, moduleName, realTime ? 'real-time' : realTime]
22
+ .filter(Boolean)
23
+ .join('/');
20
24
  return encodeKey(slug);
21
25
  }
22
26
  //# sourceMappingURL=utils.js.map
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@stryker-mutator/dashboard-data-access",
3
- "version": "0.15.1-pr-897.3",
3
+ "version": "0.15.1-pr-905.0",
4
4
  "type": "module",
5
5
  "description": "This package contains the data access layer of the stryker dashboard application.",
6
6
  "scripts": {
@@ -24,9 +24,9 @@
24
24
  "dependencies": {
25
25
  "@azure/data-tables": "13.2.2",
26
26
  "@azure/storage-blob": "12.24.0",
27
- "@stryker-mutator/dashboard-common": "0.15.1-pr-897.3",
27
+ "@stryker-mutator/dashboard-common": "0.15.1-pr-905.0",
28
28
  "mutation-testing-metrics": "3.2.0",
29
29
  "mutation-testing-report-schema": "3.1.1"
30
30
  },
31
- "gitHead": "d08a4ea5e40bd3506ca873af2efe319ef0703548"
31
+ "gitHead": "173a7c8f7de641d8923b867d10486cf4cbc76bad"
32
32
  }