-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
support for caliper graded profile (#759)
* support for caliper graded profile * add iso duration * remove unused imports * export interfaces * add caliper endpoint to v1 api * Revert "add iso duration" This reverts commit be6677b. * stricter typing * add caliper actor * error handling for unsupported profiles and events * update caliper data object * add to v1 * add caliper enums to interfaces * resolve conflicts * add duration package * match log file * update version * use upgrade types * resolve conflicts * update lockfile
- Loading branch information
Showing
13 changed files
with
848 additions
and
17,868 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
44 changes: 44 additions & 0 deletions
44
backend/packages/Upgrade/src/api/controllers/validators/CaliperLogData.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
import { IsNotEmpty, IsDefined, IsString, IsJSON, IsObject } from 'class-validator'; | ||
import { Attempt, CaliperActor, ScoreObject, SUPPORTED_CALIPER_EVENTS, SUPPORTED_CALIPER_PROFILES } from 'upgrade_types'; | ||
|
||
export class CaliperLogData { | ||
|
||
@IsDefined() | ||
@IsNotEmpty() | ||
@IsString() | ||
public profile: SUPPORTED_CALIPER_PROFILES; | ||
|
||
@IsDefined() | ||
@IsNotEmpty() | ||
@IsString() | ||
public type: SUPPORTED_CALIPER_EVENTS; | ||
|
||
@IsDefined() | ||
@IsNotEmpty() | ||
@IsJSON() | ||
public actor: CaliperActor; | ||
|
||
@IsDefined() | ||
@IsNotEmpty() | ||
@IsString() | ||
public action: string; | ||
|
||
@IsDefined() | ||
@IsNotEmpty() | ||
@IsString() | ||
public eventTime: string; | ||
|
||
@IsDefined() | ||
@IsNotEmpty() | ||
@IsJSON() | ||
public object: Attempt; | ||
|
||
@IsObject() | ||
public extensions: Record<string, unknown>; | ||
|
||
@IsObject() | ||
@IsNotEmpty() | ||
@IsJSON() | ||
public generated: ScoreObject; | ||
|
||
} |
22 changes: 22 additions & 0 deletions
22
backend/packages/Upgrade/src/api/controllers/validators/CaliperLogEnvelope.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
import { IsNotEmpty, IsDefined, IsString } from 'class-validator'; | ||
import { CaliperLogData } from './CaliperLogData'; | ||
|
||
|
||
export class CaliperLogEnvelope { | ||
@IsDefined() | ||
@IsNotEmpty() | ||
@IsString() | ||
public sensor: string; | ||
|
||
@IsDefined() | ||
@IsNotEmpty() | ||
@IsString() | ||
public sendTime: string; | ||
|
||
@IsDefined() | ||
@IsNotEmpty() | ||
@IsString() | ||
public dataVersion: string; | ||
|
||
public data: CaliperLogData[]; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
import { Types, Interfaces } from '../identifiers'; | ||
import fetchDataService from '../common/fetchDataService'; | ||
import { CaliperEnvelope } from 'upgrade_types'; | ||
|
||
export default async function logCaliper( | ||
url: string, | ||
userId: string, | ||
token: string, | ||
clientSessionId: string, | ||
value: CaliperEnvelope, | ||
sendAsAnalytics = false | ||
): Promise<Interfaces.ILog[]> { | ||
const logResponse = await fetchDataService( | ||
url, | ||
token, | ||
clientSessionId, | ||
value, | ||
Types.REQUEST_TYPES.POST, | ||
sendAsAnalytics | ||
); | ||
if (logResponse.status) { | ||
return logResponse.data; | ||
} else { | ||
throw new Error(JSON.stringify(logResponse.message)); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.