@stryker-mutator/dashboard-data-access 0.14.1 → 0.14.2-pr-536.1

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.
@@ -0,0 +1,3 @@
1
+ export declare class OptimisticConcurrencyError extends Error {
2
+ }
3
+ //# sourceMappingURL=OptimisticConcurrencyError.d.ts.map
@@ -0,0 +1,2 @@
1
+ export * from './OptimisticConcurrencyError.js';
2
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1,6 @@
1
+ export * from './models/index.js';
2
+ export * from './mappers/index.js';
3
+ export { MutationTestingReportService } from './services/MutationTestingReportService.js';
4
+ export { RealTimeMutantsBlobService } from './services/RealTimeMutantsBlobService.js';
5
+ export * from './errors/index.js';
6
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1,12 @@
1
+ import { ModelClass } from './ModelClass.js';
2
+ import { TableQuery } from 'azure-storage';
3
+ export declare class DashboardQuery<TModel, TPartitionKeyFields extends keyof TModel, TRowKeyFields extends keyof TModel> {
4
+ protected ModelClass: ModelClass<TModel, TPartitionKeyFields, TRowKeyFields>;
5
+ private readonly whereConditions;
6
+ private constructor();
7
+ whereRowKeyNotEquals(rowKey: Pick<TModel, TRowKeyFields>): DashboardQuery<TModel, TPartitionKeyFields, TRowKeyFields>;
8
+ wherePartitionKeyEquals(partitionKey: Pick<TModel, TPartitionKeyFields>): DashboardQuery<TModel, TPartitionKeyFields, TRowKeyFields>;
9
+ static create<TModel, TPartitionKeyFields extends keyof TModel, TRowKeyFields extends keyof TModel>(ModelClass: ModelClass<TModel, TPartitionKeyFields, TRowKeyFields>): DashboardQuery<TModel, TPartitionKeyFields, TRowKeyFields>;
10
+ build(): TableQuery;
11
+ }
12
+ //# sourceMappingURL=DashboardQuery.d.ts.map
@@ -0,0 +1,14 @@
1
+ import { DashboardQuery } from './DashboardQuery.js';
2
+ export interface Result<TModel> {
3
+ etag: string;
4
+ model: TModel;
5
+ }
6
+ export interface Mapper<TModel, TPartitionKeyFields extends keyof TModel, TRowKeyFields extends keyof TModel> {
7
+ createStorageIfNotExists(): Promise<void>;
8
+ insertOrMerge(model: TModel): Promise<void>;
9
+ insert(model: TModel): Promise<Result<TModel>>;
10
+ replace(model: TModel, etag: string): Promise<Result<TModel>>;
11
+ findOne(identifier: Pick<TModel, TPartitionKeyFields | TRowKeyFields>): Promise<Result<TModel> | null>;
12
+ findAll(query: DashboardQuery<TModel, TPartitionKeyFields, TRowKeyFields>): Promise<Result<TModel>[]>;
13
+ }
14
+ //# sourceMappingURL=Mapper.d.ts.map
@@ -0,0 +1,9 @@
1
+ export interface ModelClass<TModel, TPartitionKeyFields extends keyof TModel, TRowKeyFields extends keyof TModel> {
2
+ new (): TModel;
3
+ createPartitionKey(entity: Pick<TModel, TPartitionKeyFields>): string;
4
+ createRowKey(entity: Pick<TModel, TRowKeyFields>): string | undefined;
5
+ identify(entity: Partial<TModel>, partitionKeyValue: string, rowKeyValue: string): void;
6
+ readonly persistedFields: ReadonlyArray<Exclude<keyof TModel, TRowKeyFields>>;
7
+ readonly tableName: string;
8
+ }
9
+ //# sourceMappingURL=ModelClass.d.ts.map
@@ -0,0 +1,17 @@
1
+ import { BlobServiceAsPromised } from '../services/BlobServiceAsPromised.js';
2
+ import { BlobService } from 'azure-storage';
3
+ import * as schema from 'mutation-testing-report-schema';
4
+ import { ReportIdentifier } from '@stryker-mutator/dashboard-common';
5
+ /**
6
+ * The report json part of a mutation testing report is stored in blob storage
7
+ */
8
+ export declare class MutationTestingResultMapper {
9
+ private readonly blobService;
10
+ private static readonly CONTAINER_NAME;
11
+ constructor(blobService?: BlobServiceAsPromised);
12
+ createStorageIfNotExists(): Promise<BlobService.ContainerResult>;
13
+ insertOrReplace(id: ReportIdentifier, result: schema.MutationTestResult | null): Promise<void>;
14
+ findOne(identifier: ReportIdentifier): Promise<schema.MutationTestResult | null>;
15
+ delete(id: ReportIdentifier): Promise<void>;
16
+ }
17
+ //# sourceMappingURL=MutationTestingResultMapper.d.ts.map
@@ -0,0 +1,24 @@
1
+ import TableServiceAsPromised from '../services/TableServiceAsPromised.js';
2
+ import { Mapper, Result } from './Mapper.js';
3
+ import { ModelClass } from './ModelClass.js';
4
+ import { DashboardQuery } from './DashboardQuery.js';
5
+ export default class TableStorageMapper<TModel extends object, TPartitionKeyFields extends keyof TModel, TRowKeyFields extends keyof TModel> implements Mapper<TModel, TPartitionKeyFields, TRowKeyFields> {
6
+ private readonly ModelClass;
7
+ private readonly tableService;
8
+ constructor(ModelClass: ModelClass<TModel, TPartitionKeyFields, TRowKeyFields>, tableService?: TableServiceAsPromised);
9
+ createStorageIfNotExists(): Promise<void>;
10
+ insertOrMerge(model: TModel): Promise<void>;
11
+ findOne(identity: Pick<TModel, TPartitionKeyFields | TRowKeyFields>): Promise<Result<TModel> | null>;
12
+ findAll(query?: DashboardQuery<TModel, TPartitionKeyFields, TRowKeyFields>): Promise<Result<TModel>[]>;
13
+ /**
14
+ * Replace an entity of a specific version (throws error otherwise)
15
+ * @param model The model to replace
16
+ * @param etag The etag (version id)
17
+ * @throws {OptimisticConcurrencyError}
18
+ */
19
+ replace(model: TModel, etag: string): Promise<Result<TModel>>;
20
+ insert(model: TModel): Promise<Result<TModel>>;
21
+ private toModel;
22
+ private toEntity;
23
+ }
24
+ //# sourceMappingURL=TableStorageMapper.d.ts.map
@@ -0,0 +1,7 @@
1
+ import { Mapper } from './Mapper.js';
2
+ import { MutationTestingReport, Project } from '../models/index.js';
3
+ export type MutationTestingReportMapper = Mapper<MutationTestingReport, 'projectName' | 'version', 'moduleName'>;
4
+ export type ProjectMapper = Mapper<Project, 'owner', 'name'>;
5
+ export declare function createMutationTestingReportMapper(): MutationTestingReportMapper;
6
+ export declare function createProjectMapper(): ProjectMapper;
7
+ //# sourceMappingURL=factories.d.ts.map
@@ -0,0 +1,4 @@
1
+ export * from './factories.js';
2
+ export * from './Mapper.js';
3
+ export * from './DashboardQuery.js';
4
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1,29 @@
1
+ import { ReportIdentifier } from '@stryker-mutator/dashboard-common';
2
+ export declare class MutationTestingReport implements ReportIdentifier {
3
+ /**
4
+ * The repo slug. /:provider/:owner/:name (could also have more components in the future, for example gitlab supports this)
5
+ * @example /github.com/stryker-mutator/mutation-testing-elements
6
+ */
7
+ projectName: string;
8
+ /**
9
+ * The branch, tag or git hash
10
+ * @example 'master', 'v1', '0d3af4840904c42dede7016f45b53718a617bbd8'
11
+ */
12
+ version: string;
13
+ /**
14
+ * Optional: the module
15
+ * For example 'schema'
16
+ */
17
+ moduleName: string | undefined;
18
+ /**
19
+ * Indicates whether this report is real-time.
20
+ */
21
+ realTime?: boolean;
22
+ mutationScore: number;
23
+ static createRowKey(identifier: Pick<MutationTestingReport, 'moduleName'>): string | undefined;
24
+ static createPartitionKey(identifier: Pick<MutationTestingReport, 'version' | 'projectName'>): string;
25
+ static identify(entity: Partial<MutationTestingReport>, partitionKeyValue: string, rowKeyValue: string): void;
26
+ static readonly persistedFields: readonly ["mutationScore"];
27
+ static readonly tableName = "MutationTestingReport";
28
+ }
29
+ //# sourceMappingURL=MutationTestingReport.d.ts.map
@@ -0,0 +1,12 @@
1
+ export declare class Project {
2
+ owner: string;
3
+ name: string;
4
+ enabled: boolean;
5
+ apiKeyHash: string;
6
+ static readonly persistedFields: readonly ["enabled", "apiKeyHash"];
7
+ static readonly tableName = "Project";
8
+ static createRowKey(identifier: Pick<Project, 'name'>): string;
9
+ static createPartitionKey(identifier: Pick<Project, 'owner'>): string;
10
+ static identify(entity: Partial<Project>, partitionKeyValue: string, rowKeyValue: string): void;
11
+ }
12
+ //# sourceMappingURL=Project.d.ts.map
@@ -0,0 +1,4 @@
1
+ export interface Timestamped {
2
+ timestamp: string;
3
+ }
4
+ //# sourceMappingURL=Timestamped.d.ts.map
@@ -0,0 +1,4 @@
1
+ export * from './MutationTestingReport.js';
2
+ export * from './Project.js';
3
+ export * from './Timestamped.js';
4
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1,12 @@
1
+ /// <reference types="node" />
2
+ import { BlobService } from 'azure-storage';
3
+ export declare class BlobServiceAsPromised {
4
+ createContainerIfNotExists: (container: string, options: BlobService.CreateContainerOptions) => Promise<BlobService.ContainerResult>;
5
+ createBlockBlobFromText: (container: string, blob: string, text: string | Buffer, options: BlobService.CreateBlobRequestOptions) => Promise<BlobService.BlobResult>;
6
+ blobToText: (container: string, blob: string) => Promise<string>;
7
+ createAppendBlobFromText: (container: string, blob: string, text: string | Buffer) => Promise<BlobService.BlobResult>;
8
+ appendBlockFromText: (container: string, blob: string, text: string | Buffer) => Promise<BlobService.BlobResult>;
9
+ deleteBlobIfExists: (container: string, blob: string) => Promise<unknown>;
10
+ constructor(blobService?: BlobService);
11
+ }
12
+ //# sourceMappingURL=BlobServiceAsPromised.d.ts.map
@@ -0,0 +1,18 @@
1
+ import { MutationTestResult } from 'mutation-testing-report-schema';
2
+ import { MutationTestingResultMapper } from '../mappers/MutationTestingResultMapper.js';
3
+ import { MutationTestingReportMapper } from '../mappers/index.js';
4
+ import { MutationScoreOnlyResult, ReportIdentifier, Report, Logger } from '@stryker-mutator/dashboard-common';
5
+ export declare class MutationTestingReportService {
6
+ private readonly resultMapper;
7
+ private readonly mutationScoreMapper;
8
+ constructor(resultMapper?: MutationTestingResultMapper, mutationScoreMapper?: MutationTestingReportMapper);
9
+ createStorageIfNotExists(): Promise<void>;
10
+ saveReport(id: ReportIdentifier, result: MutationScoreOnlyResult | MutationTestResult, logger: Logger): Promise<void>;
11
+ private aggregateProjectReport;
12
+ private tryAggregateProjectReport;
13
+ findOne(id: ReportIdentifier): Promise<Report | null>;
14
+ delete(id: ReportIdentifier): Promise<void>;
15
+ private insertOrMergeReport;
16
+ private calculateMutationScore;
17
+ }
18
+ //# sourceMappingURL=MutationTestingReportService.d.ts.map
@@ -0,0 +1,14 @@
1
+ import { ReportIdentifier } from '@stryker-mutator/dashboard-common';
2
+ import { BlobServiceAsPromised } from './BlobServiceAsPromised.js';
3
+ import { MutantResult } from 'mutation-testing-report-schema';
4
+ export declare class RealTimeMutantsBlobService {
5
+ #private;
6
+ private static readonly CONTAINER_NAME;
7
+ constructor(blobService?: BlobServiceAsPromised);
8
+ createStorageIfNotExists(): Promise<void>;
9
+ createReport(id: ReportIdentifier): Promise<void>;
10
+ appendToReport(id: ReportIdentifier, mutants: Array<Partial<MutantResult>>): Promise<void>;
11
+ getReport(id: ReportIdentifier): Promise<Array<Partial<MutantResult>>>;
12
+ delete(id: ReportIdentifier): Promise<void>;
13
+ }
14
+ //# sourceMappingURL=RealTimeMutantsBlobService.d.ts.map
@@ -0,0 +1,32 @@
1
+ import { TableService, TableQuery, common } from 'azure-storage';
2
+ export type Entity<T, TKeyFields extends keyof T> = {
3
+ [K in Exclude<keyof T, TKeyFields>]: {
4
+ $: string;
5
+ _: T[K];
6
+ };
7
+ } & EntityKey & EntityMetadata;
8
+ export interface EntityKey {
9
+ PartitionKey: {
10
+ $: 'Edm.String';
11
+ _: string;
12
+ };
13
+ RowKey: {
14
+ $: 'Edm.String';
15
+ _: string;
16
+ };
17
+ }
18
+ export interface EntityMetadata {
19
+ ['.metadata']: {
20
+ etag: string;
21
+ };
22
+ }
23
+ export default class TableServiceAsPromised {
24
+ constructor(tableService?: TableService);
25
+ insertEntity: (table: string, entityDescriptor: unknown, options: common.RequestOptions) => Promise<TableService.EntityMetadata>;
26
+ replaceEntity: (table: string, entityDescriptor: unknown, options: common.RequestOptions) => Promise<TableService.EntityMetadata>;
27
+ createTableIfNotExists: (name: string) => Promise<TableService.TableResult>;
28
+ queryEntities: <T, Keys extends keyof T>(table: string, tableQuery: TableQuery, cancellationToken: TableService.TableContinuationToken | undefined) => Promise<TableService.QueryEntitiesResult<Entity<T, Keys> & EntityKey>>;
29
+ insertOrMergeEntity: (table: string, entity: any) => Promise<TableService.EntityMetadata>;
30
+ retrieveEntity: <TResult>(table: string, partitionKey: string, rowKey: string, options?: TableService.TableEntityRequestOptions) => Promise<TResult>;
31
+ }
32
+ //# sourceMappingURL=TableServiceAsPromised.d.ts.map
@@ -0,0 +1,7 @@
1
+ import { ReportIdentifier } from '@stryker-mutator/dashboard-common';
2
+ import { StorageError } from 'azure-storage';
3
+ export declare function encodeKey(inputWithSlashes: string): string;
4
+ export declare function decodeKey(inputWithSemiColons: string): string;
5
+ export declare function isStorageError(maybeStorageError: unknown): maybeStorageError is StorageError;
6
+ export declare function toBlobName({ projectName, version, moduleName, realTime, }: ReportIdentifier): string;
7
+ //# sourceMappingURL=utils.d.ts.map
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@stryker-mutator/dashboard-data-access",
3
- "version": "0.14.1",
3
+ "version": "0.14.2-pr-536.1",
4
4
  "type": "module",
5
5
  "description": "This package contains the data access layer of the stryker dashboard application.",
6
6
  "scripts": {
@@ -21,10 +21,10 @@
21
21
  "typings": "src/index.ts",
22
22
  "license": "ISC",
23
23
  "dependencies": {
24
- "@stryker-mutator/dashboard-common": "0.14.1",
24
+ "@stryker-mutator/dashboard-common": "0.14.2-pr-536.1",
25
25
  "azure-storage": "2.10.7",
26
26
  "mutation-testing-metrics": "3.0.2",
27
27
  "mutation-testing-report-schema": "3.0.2"
28
28
  },
29
- "gitHead": "679afa76e9281bb4d641764a2bdc15a450fab9b8"
29
+ "gitHead": "6b70cbe421a22e4e7ed570c0ed69852e1ed5efda"
30
30
  }