未验证 提交 4e425303 编写于 作者: B Boris Sekachev 提交者: GitHub

Refactoring: Removed old docs from cvat-core, added more types, fixed import (#5572)

<!-- Raised an issue to propose your change
(https://github.com/cvat-ai/cvat/issues).
It helps to avoid duplication of efforts from multiple independent
contributors.
Discuss your ideas with maintainers to be sure that changes will be
approved and merged.
Read the
[CONTRIBUTION](https://github.com/cvat-ai/cvat/blob/develop/CONTRIBUTING.md)
guide. -->

<!-- Provide a general summary of your changes in the Title above -->

### Motivation and context
<!-- Why is this change required? What problem does it solve? If it
fixes an open
issue, please link to the issue here. Describe your changes in detail,
add
screenshots. -->

### How has this been tested?
<!-- Please describe in detail how you tested your changes.
Include details of your testing environment, and the tests you ran to
see how your change affects other areas of the code, etc. -->

### Checklist
<!-- Go over all the following points, and put an `x` in all the boxes
that apply.
If an item isn't applicable by a reason then ~~explicitly
strikethrough~~ the whole
line. If you don't do that github will show an incorrect process for the
pull request.
If you're unsure about any of these, don't hesitate to ask. We're here
to help! -->
- [x] I submit my changes into the `develop` branch
- [ ] I have added a description of my changes into
[CHANGELOG](https://github.com/cvat-ai/cvat/blob/develop/CHANGELOG.md)
file
- [ ] I have updated the [documentation](
https://github.com/cvat-ai/cvat/blob/develop/README.md#documentation)
accordingly
- [ ] I have added tests to cover my changes
- [ ] I have linked related issues ([read github docs](

https://help.github.com/en/github/managing-your-work-on-github/linking-a-pull-request-to-an-issue#linking-a-pull-request-to-an-issue-using-a-keyword))
- [ ] I have increased versions of npm packages if it is necessary
([cvat-canvas](https://github.com/cvat-ai/cvat/tree/develop/cvat-canvas#versioning),

[cvat-core](https://github.com/cvat-ai/cvat/tree/develop/cvat-core#versioning),
[cvat-data](https://github.com/cvat-ai/cvat/tree/develop/cvat-data#versioning)
and
[cvat-ui](https://github.com/cvat-ai/cvat/tree/develop/cvat-ui#versioning))

### License

- [x] I submit _my code changes_ under the same [MIT License](
https://github.com/cvat-ai/cvat/blob/develop/LICENSE) that covers the
project.
  Feel free to contact the maintainers if that's a concern.
上级 881c1aa5
......@@ -7,7 +7,6 @@ module.exports = {
'.eslintrc.js',
'webpack.config.js',
'jest.config.js',
'jsdoc.config.js',
'src/3rdparty/**',
'node_modules/**',
'dist/**',
......
......@@ -28,12 +28,6 @@ yarn run build
yarn run build --mode=development # without a minification
```
- Building the documentation in the `docs` directory:
```bash
yarn run docs
```
- Running of tests:
```bash
......
// Copyright (C) 2019-2022 Intel Corporation
//
// SPDX-License-Identifier: MIT
module.exports = {
plugins: [],
recurseDepth: 10,
source: {
includePattern: '.+\\.js(doc|x)?$',
excludePattern: '(^|\\/|\\\\)_',
},
sourceType: 'module',
tags: {
allowUnknownTags: false,
dictionaries: ['jsdoc', 'closure'],
},
templates: {
cleverLinks: false,
monospaceLinks: false,
default: {
outputSourceFiles: false,
},
},
};
......@@ -6,7 +6,6 @@
"scripts": {
"build": "webpack",
"test": "jest --config=jest.config.js --coverage",
"docs": "jsdoc --readme README.md src/*.js -p -c jsdoc.config.js -d docs",
"coveralls": "cat ./reports/coverage/lcov.info | coveralls",
"type-check": "tsc --noEmit",
"type-check:watch": "yarn run type-check --watch"
......@@ -23,7 +22,6 @@
"coveralls": "^3.0.5",
"jest": "^26.6.3",
"jest-junit": "^6.4.0",
"jsdoc": "^3.6.6",
"ts-jest": "26"
},
"dependencies": {
......
// Copyright (C) 2019-2022 Intel Corporation
// Copyright (C) 2023 CVAT.ai Corporation
//
// SPDX-License-Identifier: MIT
......@@ -10,11 +11,6 @@ interface RawLoaderData {
dimension: '2d' | '3d';
}
/**
* Class representing an annotation loader
* @memberof module:API.cvat.classes
* @hideconstructor
*/
export class Loader {
public name: string;
public format: string;
......@@ -33,53 +29,18 @@ export class Loader {
Object.defineProperties(this, {
name: {
/**
* @name name
* @type {string}
* @memberof module:API.cvat.classes.Loader
* @readonly
* @instance
*/
get: () => data.name,
},
format: {
/**
* @name format
* @type {string}
* @memberof module:API.cvat.classes.Loader
* @readonly
* @instance
*/
get: () => data.format,
},
version: {
/**
* @name version
* @type {string}
* @memberof module:API.cvat.classes.Loader
* @readonly
* @instance
*/
get: () => data.version,
},
enabled: {
/**
* @name enabled
* @type {boolean}
* @memberof module:API.cvat.classes.Loader
* @readonly
* @instance
*/
get: () => data.enabled,
},
dimension: {
/**
* @name dimension
* @type {module:API.cvat.enums.DimensionType}
* @memberof module:API.cvat.classes.Loader
* @readonly
* @instance
*/
get: () => data.dimension,
},
});
......@@ -88,11 +49,6 @@ export class Loader {
type RawDumperData = RawLoaderData;
/**
* Class representing an annotation dumper
* @memberof module:API.cvat.classes
* @hideconstructor
*/
export class Dumper {
public name: string;
public format: string;
......@@ -111,53 +67,18 @@ export class Dumper {
Object.defineProperties(this, {
name: {
/**
* @name name
* @type {string}
* @memberof module:API.cvat.classes.Dumper
* @readonly
* @instance
*/
get: () => data.name,
},
format: {
/**
* @name format
* @type {string}
* @memberof module:API.cvat.classes.Dumper
* @readonly
* @instance
*/
get: () => data.format,
},
version: {
/**
* @name version
* @type {string}
* @memberof module:API.cvat.classes.Dumper
* @readonly
* @instance
*/
get: () => data.version,
},
enabled: {
/**
* @name enabled
* @type {boolean}
* @memberof module:API.cvat.classes.Dumper
* @readonly
* @instance
*/
get: () => data.enabled,
},
dimension: {
/**
* @name dimension
* @type {module:API.cvat.enums.DimensionType}
* @memberof module:API.cvat.classes.Dumper
* @readonly
* @instance
*/
get: () => data.dimension,
},
});
......@@ -169,11 +90,6 @@ interface AnnotationFormatRawData {
exporters: RawDumperData[];
}
/**
* Class representing an annotation format
* @memberof module:API.cvat.classes
* @hideconstructor
*/
export class AnnotationFormats {
public loaders: Loader[];
public dumpers: Dumper[];
......@@ -186,23 +102,9 @@ export class AnnotationFormats {
Object.defineProperties(this, {
loaders: {
/**
* @name loaders
* @type {module:API.cvat.classes.Loader[]}
* @memberof module:API.cvat.classes.AnnotationFormats
* @readonly
* @instance
*/
get: () => [...data.importers],
},
dumpers: {
/**
* @name dumpers
* @type {module:API.cvat.classes.Dumper[]}
* @memberof module:API.cvat.classes.AnnotationFormats
* @readonly
* @instance
*/
get: () => [...data.exporters],
},
});
......
......@@ -31,8 +31,8 @@ function copyShape(state: TrackedShape, data: Partial<TrackedShape> = {}): Track
};
}
interface AnnotationInjection {
labels: Label[];
export interface BasicInjection {
labels: Record<number, Label>;
groups: { max: number };
frameMeta: {
deleted_frames: Record<number, boolean>;
......@@ -45,23 +45,28 @@ interface AnnotationInjection {
getMasksOnFrame: (frame: number) => MaskShape[];
}
type AnnotationInjection = BasicInjection & {
parentID?: number;
readOnlyFields?: string[];
};
class Annotation {
public clientID: number;
protected taskLabels: Label[];
protected history: any;
protected groupColors: Record<number, string>;
protected serverID: number | null;
public serverID: number | null;
protected parentID: number | null;
protected group: number;
public group: number;
public label: Label;
protected frame: number;
public frame: number;
private _removed: boolean;
public lock: boolean;
protected readOnlyFields: string[];
protected color: string;
protected source: Source;
public updated: number;
protected attributes: Record<number, string>;
public attributes: Record<number, string>;
protected groupObject: {
color: string;
readonly id: number;
......@@ -366,7 +371,7 @@ class Drawn extends Annotation {
protected descriptions: string[];
public hidden: boolean;
protected pinned: boolean;
protected shapeType: ShapeType;
public shapeType: ShapeType;
constructor(data, clientID: number, color: string, injection: AnnotationInjection) {
super(data, clientID, color, injection);
......@@ -472,7 +477,7 @@ class Drawn extends Annotation {
}
}
interface RawShapeData {
export interface RawShapeData {
id?: number;
clientID?: number;
label_id: number;
......@@ -501,8 +506,8 @@ export class Shape extends Drawn {
public points: number[];
public occluded: boolean;
public outside: boolean;
protected rotation: number;
protected zOrder: number;
public rotation: number;
public zOrder: number;
constructor(data: RawShapeData, clientID: number, color: string, injection: AnnotationInjection) {
super(data, clientID, color, injection);
......@@ -787,7 +792,7 @@ export class Shape extends Drawn {
}
}
interface RawTrackData {
export interface RawTrackData {
id?: number;
clientID?: number;
label_id: number;
......@@ -1415,7 +1420,7 @@ export class Track extends Drawn {
}
}
interface RawTagData {
export interface RawTagData {
id?: number;
clientID?: number;
label_id: number;
......@@ -1867,7 +1872,7 @@ export class CuboidShape extends Shape {
}
export class SkeletonShape extends Shape {
private elements: Shape[];
public elements: Shape[];
constructor(data: RawShapeData, clientID: number, color: string, injection: AnnotationInjection) {
super(data, clientID, color, injection);
......@@ -2186,7 +2191,7 @@ export class MaskShape extends Shape {
return [];
}
protected removeUnderlyingPixels(frame: number): void {
public removeUnderlyingPixels(frame: number): void {
if (frame !== this.frame) {
throw new ArgumentError(
`Wrong "frame" attribute: is not equal to the shape frame (${frame} vs ${this.frame})`,
......@@ -2726,7 +2731,7 @@ export class CuboidTrack extends Track {
}
export class SkeletonTrack extends Track {
private elements: Track[];
public elements: Track[];
constructor(data: RawTrackData, clientID: number, color: string, injection: AnnotationInjection) {
super(data, clientID, color, injection);
......@@ -3069,7 +3074,7 @@ Object.defineProperty(EllipseTrack, 'distance', { value: EllipseShape.distance }
Object.defineProperty(CuboidTrack, 'distance', { value: CuboidShape.distance });
Object.defineProperty(SkeletonTrack, 'distance', { value: SkeletonShape.distance });
export function shapeFactory(data: RawShapeData, clientID: number, injection: AnnotationInjection): Annotation {
export function shapeFactory(data: RawShapeData, clientID: number, injection: AnnotationInjection): Shape {
const { type } = data;
const color = colors[clientID % colors.length];
......@@ -3106,7 +3111,7 @@ export function shapeFactory(data: RawShapeData, clientID: number, injection: An
return shapeModel;
}
export function trackFactory(trackData: RawTrackData, clientID: number, injection: AnnotationInjection): Annotation {
export function trackFactory(trackData: RawTrackData, clientID: number, injection: AnnotationInjection): Track {
if (trackData.shapes.length) {
const { type } = trackData.shapes[0];
const color = colors[clientID % colors.length];
......
// Copyright (C) 2019-2022 Intel Corporation
// Copyright (C) 2022 CVAT.ai Corp
// Copyright (C) 2022-2023 CVAT.ai Corporation
//
// SPDX-License-Identifier: MIT
(() => {
const serverProxy = require('./server-proxy').default;
const { Task } = require('./session');
const { ScriptingError } = require('./exceptions');
class AnnotationsSaver {
constructor(version, collection, session) {
this.sessionType = session instanceof Task ? 'task' : 'job';
this.id = session.id;
this.version = version;
this.collection = collection;
this.initialObjects = {};
this.hash = this._getHash();
// We need use data from export instead of initialData
// Otherwise we have differ keys order and JSON comparison code incorrect
const exported = this.collection.export();
this._resetState();
for (const shape of exported.shapes) {
this.initialObjects.shapes[shape.id] = shape;
}
for (const track of exported.tracks) {
this.initialObjects.tracks[track.id] = track;
}
for (const tag of exported.tags) {
this.initialObjects.tags[tag.id] = tag;
}
import serverProxy from './server-proxy';
import { Task } from './session';
import { ScriptingError } from './exceptions';
export default class AnnotationsSaver {
private sessionType: 'task' | 'job';
private id: number;
private version: number;
private collection: any;
private hash: string;
private initialObjects: any;
constructor(version, collection, session) {
this.sessionType = session instanceof Task ? 'task' : 'job';
this.id = session.id;
this.version = version;
this.collection = collection;
this.initialObjects = {};
this.hash = this._getHash();
// We need use data from export instead of initialData
// Otherwise we have differ keys order and JSON comparison code incorrect
const exported = this.collection.export();
this._resetState();
for (const shape of exported.shapes) {
this.initialObjects.shapes[shape.id] = shape;
}
_resetState() {
this.initialObjects = {
shapes: {},
tracks: {},
tags: {},
};
for (const track of exported.tracks) {
this.initialObjects.tracks[track.id] = track;
}
_getHash() {
const exported = this.collection.export();
return JSON.stringify(exported);
for (const tag of exported.tags) {
this.initialObjects.tags[tag.id] = tag;
}
}
async _request(data, action) {
const result = await serverProxy.annotations.updateAnnotations(this.sessionType, this.id, data, action);
_resetState() {
this.initialObjects = {
shapes: {},
tracks: {},
tags: {},
};
}
return result;
}
_getHash() {
const exported = this.collection.export();
return JSON.stringify(exported);
}
async _put(data) {
const result = await this._request(data, 'put');
return result;
}
async _request(data, action) {
const result = await serverProxy.annotations.updateAnnotations(this.sessionType, this.id, data, action);
async _create(created) {
const result = await this._request(created, 'create');
return result;
}
return result;
}
async _update(updated) {
const result = await this._request(updated, 'update');
return result;
}
async _put(data) {
const result = await this._request(data, 'put');
return result;
}
async _delete(deleted) {
const result = await this._request(deleted, 'delete');
return result;
}
async _create(created) {
const result = await this._request(created, 'create');
return result;
}
_split(exported) {
const splitted = {
created: {
shapes: [],
tracks: [],
tags: [],
},
updated: {
shapes: [],
tracks: [],
tags: [],
},
deleted: {
shapes: [],
tracks: [],
tags: [],
},
};
const keys = [
'id',
'label_id',
'group',
'frame',
'occluded',
'z_order',
'points',
'rotation',
'type',
'shapes',
'elements',
'attributes',
'value',
'spec_id',
'source',
'outside',
];
// Find created and updated objects
for (const type of Object.keys(exported)) {
for (const object of exported[type]) {
if (object.id in this.initialObjects[type]) {
const exportedHash = JSON.stringify(object, keys);
const initialHash = JSON.stringify(this.initialObjects[type][object.id], keys);
if (exportedHash !== initialHash) {
splitted.updated[type].push(object);
}
} else if (typeof object.id === 'undefined') {
splitted.created[type].push(object);
} else {
throw new ScriptingError(
`Id of object is defined "${object.id}" but it absents in initial state`,
);
}
}
}
async _update(updated) {
const result = await this._request(updated, 'update');
return result;
}
// Now find deleted objects
const indexes = {
shapes: exported.shapes.map((object) => +object.id),
tracks: exported.tracks.map((object) => +object.id),
tags: exported.tags.map((object) => +object.id),
};
async _delete(deleted) {
const result = await this._request(deleted, 'delete');
return result;
}
for (const type of Object.keys(this.initialObjects)) {
for (const id of Object.keys(this.initialObjects[type])) {
if (!indexes[type].includes(+id)) {
const object = this.initialObjects[type][id];
splitted.deleted[type].push(object);
_split(exported) {
const splitted = {
created: {
shapes: [],
tracks: [],
tags: [],
},
updated: {
shapes: [],
tracks: [],
tags: [],
},
deleted: {
shapes: [],
tracks: [],
tags: [],
},
};
const keys = [
'id',
'label_id',
'group',
'frame',
'occluded',
'z_order',
'points',
'rotation',
'type',
'shapes',
'elements',
'attributes',
'value',
'spec_id',
'source',
'outside',
];
// Find created and updated objects
for (const type of Object.keys(exported)) {
for (const object of exported[type]) {
if (object.id in this.initialObjects[type]) {
const exportedHash = JSON.stringify(object, keys);
const initialHash = JSON.stringify(this.initialObjects[type][object.id], keys);
if (exportedHash !== initialHash) {
splitted.updated[type].push(object);
}
} else if (typeof object.id === 'undefined') {
splitted.created[type].push(object);
} else {
throw new ScriptingError(
`Id of object is defined "${object.id}" but it absents in initial state`,
);
}
}
return splitted;
}
_updateCreatedObjects(saved, indexes) {
const savedLength = saved.tracks.length + saved.shapes.length + saved.tags.length;
const indexesLength = indexes.tracks.length + indexes.shapes.length + indexes.tags.length;
if (indexesLength !== savedLength) {
throw new ScriptingError(
`Number of indexes is differed by number of saved objects ${indexesLength} vs ${savedLength}`,
);
}
// Updated IDs of created objects
for (const type of Object.keys(indexes)) {
for (let i = 0; i < indexes[type].length; i++) {
const clientID = indexes[type][i];
this.collection.objects[clientID].updateServerID(saved[type][i]);
// Now find deleted objects
const indexes = {
shapes: exported.shapes.map((object) => +object.id),
tracks: exported.tracks.map((object) => +object.id),
tags: exported.tags.map((object) => +object.id),
};
for (const type of Object.keys(this.initialObjects)) {
for (const id of Object.keys(this.initialObjects[type])) {
if (!indexes[type].includes(+id)) {
const object = this.initialObjects[type][id];
splitted.deleted[type].push(object);
}
}
}
_receiveIndexes(exported) {
// Receive client indexes before saving
const indexes = {
tracks: exported.tracks.map((track) => track.clientID),
shapes: exported.shapes.map((shape) => shape.clientID),
tags: exported.tags.map((tag) => tag.clientID),
};
// Remove them from the request body
exported.tracks
.concat(exported.shapes)
.concat(exported.tags)
.map((value) => {
delete value.clientID;
return value;
});
return indexes;
return splitted;
}
_updateCreatedObjects(saved, indexes) {
const savedLength = saved.tracks.length + saved.shapes.length + saved.tags.length;
const indexesLength = indexes.tracks.length + indexes.shapes.length + indexes.tags.length;
if (indexesLength !== savedLength) {
throw new ScriptingError(
`Number of indexes is differed by number of saved objects ${indexesLength} vs ${savedLength}`,
);
}
async save(onUpdateArg) {
const onUpdate = typeof onUpdateArg === 'function' ? onUpdateArg : (message) => {
console.log(message);
};
const exported = this.collection.export();
const { flush } = this.collection;
if (flush) {
onUpdate('Created objects are being saved on the server');
const indexes = this._receiveIndexes(exported);
const savedData = await this._put({ ...exported, version: this.version });
this.version = savedData.version;
this.collection.flush = false;
this._updateCreatedObjects(savedData, indexes);
this._resetState();
for (const type of Object.keys(this.initialObjects)) {
for (const object of savedData[type]) {
this.initialObjects[type][object.id] = object;
}
}
} else {
const { created, updated, deleted } = this._split(exported);
// Updated IDs of created objects
for (const type of Object.keys(indexes)) {
for (let i = 0; i < indexes[type].length; i++) {
const clientID = indexes[type][i];
this.collection.objects[clientID].updateServerID(saved[type][i]);
}
}
}
_receiveIndexes(exported) {
// Receive client indexes before saving
const indexes = {
tracks: exported.tracks.map((track) => track.clientID),
shapes: exported.shapes.map((shape) => shape.clientID),
tags: exported.tags.map((tag) => tag.clientID),
};
// Remove them from the request body
exported.tracks
.concat(exported.shapes)
.concat(exported.tags)
.map((value) => {
delete value.clientID;
return value;
});
return indexes;
}
onUpdate('Created objects are being saved on the server');
const indexes = this._receiveIndexes(created);
const createdData = await this._create({ ...created, version: this.version });
this.version = createdData.version;
async save(onUpdateArg) {
const onUpdate = typeof onUpdateArg === 'function' ? onUpdateArg : (message) => {
console.log(message);
};
this._updateCreatedObjects(createdData, indexes);
const exported = this.collection.export();
const { flush } = this.collection;
if (flush) {
onUpdate('Created objects are being saved on the server');
const indexes = this._receiveIndexes(exported);
const savedData = await this._put({ ...exported, version: this.version });
this.version = savedData.version;
this.collection.flush = false;
for (const type of Object.keys(this.initialObjects)) {
for (const object of createdData[type]) {
this.initialObjects[type][object.id] = object;
}
this._updateCreatedObjects(savedData, indexes);
this._resetState();
for (const type of Object.keys(this.initialObjects)) {
for (const object of savedData[type]) {
this.initialObjects[type][object.id] = object;
}
}
} else {
const { created, updated, deleted } = this._split(exported);
onUpdate('Updated objects are being saved on the server');
this._receiveIndexes(updated);
const updatedData = await this._update({ ...updated, version: this.version });
this.version = updatedData.version;
onUpdate('Created objects are being saved on the server');
const indexes = this._receiveIndexes(created);
const createdData = await this._create({ ...created, version: this.version });
this.version = createdData.version;
for (const type of Object.keys(this.initialObjects)) {
for (const object of updatedData[type]) {
this.initialObjects[type][object.id] = object;
}
this._updateCreatedObjects(createdData, indexes);
for (const type of Object.keys(this.initialObjects)) {
for (const object of createdData[type]) {
this.initialObjects[type][object.id] = object;
}
}
onUpdate('Deleted objects are being deleted from the server');
this._receiveIndexes(deleted);
const deletedData = await this._delete({ ...deleted, version: this.version });
this._version = deletedData.version;
onUpdate('Updated objects are being saved on the server');
this._receiveIndexes(updated);
const updatedData = await this._update({ ...updated, version: this.version });
this.version = updatedData.version;
for (const type of Object.keys(this.initialObjects)) {
for (const object of deletedData[type]) {
delete this.initialObjects[type][object.id];
}
for (const type of Object.keys(this.initialObjects)) {
for (const object of updatedData[type]) {
this.initialObjects[type][object.id] = object;
}
}
this.hash = this._getHash();
}
onUpdate('Deleted objects are being deleted from the server');
this._receiveIndexes(deleted);
const deletedData = await this._delete({ ...deleted, version: this.version });
this.version = deletedData.version;
hasUnsavedChanges() {
return this._getHash() !== this.hash;
for (const type of Object.keys(this.initialObjects)) {
for (const object of deletedData[type]) {
delete this.initialObjects[type][object.id];
}
}
}
this.hash = this._getHash();
}
module.exports = AnnotationsSaver;
})();
hasUnsavedChanges(): boolean {
return this._getHash() !== this.hash;
}
}
......@@ -4,16 +4,15 @@
// SPDX-License-Identifier: MIT
import { Storage } from './storage';
const serverProxy = require('./server-proxy').default;
const Collection = require('./annotations-collection');
const AnnotationsSaver = require('./annotations-saver');
const AnnotationsHistory = require('./annotations-history').default;
const { checkObjectType } = require('./common');
const Project = require('./project').default;
const { Task, Job } = require('./session');
const { ScriptingError, DataError, ArgumentError } = require('./exceptions');
const { getDeletedFrames } = require('./frames');
import serverProxy from './server-proxy';
import Collection from './annotations-collection';
import AnnotationsSaver from './annotations-saver';
import AnnotationsHistory from './annotations-history';
import { checkObjectType } from './common';
import Project from './project';
import { Task, Job } from './session';
import { ScriptingError, DataError, ArgumentError } from './exceptions';
import { getDeletedFrames } from './frames';
const jobCache = new WeakMap();
const taskCache = new WeakMap();
......
此差异已折叠。
......@@ -3,63 +3,23 @@
//
// SPDX-License-Identifier = MIT
/**
* Share files types
* @enum {string}
* @name ShareFileType
* @memberof module:API.cvat.enums
* @property {string} DIR 'DIR'
* @property {string} REG 'REG'
* @readonly
*/
export enum ShareFileType {
DIR = 'DIR',
REG = 'REG',
}
/**
* Task statuses
* @enum {string}
* @name TaskStatus
* @memberof module:API.cvat.enums
* @property {string} ANNOTATION 'annotation'
* @property {string} VALIDATION 'validation'
* @property {string} COMPLETED 'completed'
* @readonly
*/
export enum TaskStatus {
ANNOTATION = 'annotation',
VALIDATION = 'validation',
COMPLETED = 'completed',
}
/**
* Job stages
* @enum {string}
* @name JobStage
* @memberof module:API.cvat.enums
* @property {string} ANNOTATION 'annotation'
* @property {string} VALIDATION 'validation'
* @property {string} ACCEPTANCE 'acceptance'
* @readonly
*/
export enum JobStage {
ANNOTATION = 'annotation',
VALIDATION = 'validation',
ACCEPTANCE = 'acceptance',
}
/**
* Job states
* @enum {string}
* @name JobState
* @memberof module:API.cvat.enums
* @property {string} NEW 'new'
* @property {string} IN_PROGRESS 'in progress'
* @property {string} COMPLETED 'completed'
* @property {string} REJECTED 'rejected'
* @readonly
*/
export enum JobState {
NEW = 'new',
IN_PROGRESS = 'in progress',
......@@ -67,32 +27,11 @@ export enum JobState {
REJECTED = 'rejected',
}
/**
* Task dimension
* @enum
* @name DimensionType
* @memberof module:API.cvat.enums
* @property {string} DIMENSION_2D '2d'
* @property {string} DIMENSION_3D '3d'
* @readonly
*/
export enum DimensionType {
DIMENSION_2D = '2d',
DIMENSION_3D = '3d',
}
/**
* List of RQ statuses
* @enum {string}
* @name RQStatus
* @memberof module:API.cvat.enums
* @property {string} QUEUED 'queued'
* @property {string} STARTED 'started'
* @property {string} FINISHED 'finished'
* @property {string} FAILED 'failed'
* @property {string} UNKNOWN 'unknown'
* @readonly
*/
export enum RQStatus {
QUEUED = 'queued',
STARTED = 'started',
......@@ -101,32 +40,11 @@ export enum RQStatus {
UNKNOWN = 'unknown',
}
/**
* Task modes
* @enum {string}
* @name TaskMode
* @memberof module:API.cvat.enums
* @property {string} ANNOTATION 'annotation'
* @property {string} INTERPOLATION 'interpolation'
* @readonly
*/
export enum TaskMode {
ANNOTATION = 'annotation',
INTERPOLATION = 'interpolation',
}
/**
* Attribute types
* @enum {string}
* @name AttributeType
* @memberof module:API.cvat.enums
* @property {string} CHECKBOX 'checkbox'
* @property {string} SELECT 'select'
* @property {string} RADIO 'radio'
* @property {string} NUMBER 'number'
* @property {string} TEXT 'text'
* @readonly
*/
export enum AttributeType {
CHECKBOX = 'checkbox',
RADIO = 'radio',
......@@ -135,35 +53,12 @@ export enum AttributeType {
TEXT = 'text',
}
/**
* Object types
* @enum {string}
* @name ObjectType
* @memberof module:API.cvat.enums
* @property {string} TAG 'tag'
* @property {string} SHAPE 'shape'
* @property {string} TRACK 'track'
* @readonly
*/
export enum ObjectType {
TAG = 'tag',
SHAPE = 'shape',
TRACK = 'track',
}
/**
* Object shapes
* @enum {string}
* @name ShapeType
* @memberof module:API.cvat.enums
* @property {string} RECTANGLE 'rectangle'
* @property {string} POLYGON 'polygon'
* @property {string} POLYLINE 'polyline'
* @property {string} POINTS 'points'
* @property {string} CUBOID 'cuboid'
* @property {string} SKELETON 'skeleton'
* @readonly
*/
export enum ShapeType {
RECTANGLE = 'rectangle',
POLYGON = 'polygon',
......@@ -175,54 +70,11 @@ export enum ShapeType {
MASK = 'mask',
}
/**
* Annotation type
* @enum {string}
* @name Source
* @memberof module:API.cvat.enums
* @property {string} MANUAL 'manual'
* @property {string} AUTO 'auto'
* @readonly
*/
export enum Source {
MANUAL = 'manual',
AUTO = 'auto',
}
/**
* Logger event types
* @enum {string}
* @name LogType
* @memberof module:API.cvat.enums
* @property {string} loadJob Load job
* @property {string} saveJob Save job
* @property {string} restoreJob Restore job
* @property {string} uploadAnnotations Upload annotations
* @property {string} sendUserActivity Send user activity
* @property {string} sendException Send exception
* @property {string} sendTaskInfo Send task info
* @property {string} drawObject Draw object
* @property {string} pasteObject Paste object
* @property {string} copyObject Copy object
* @property {string} propagateObject Propagate object
* @property {string} dragObject Drag object
* @property {string} resizeObject Resize object
* @property {string} deleteObject Delete object
* @property {string} lockObject Lock object
* @property {string} mergeObjects Merge objects
* @property {string} changeAttribute Change attribute
* @property {string} changeLabel Change label
* @property {string} changeFrame Change frame
* @property {string} moveImage Move image
* @property {string} zoomImage Zoom image
* @property {string} fitImage Fit image
* @property {string} rotateImage Rotate image
* @property {string} undoAction Undo action
* @property {string} redoAction Redo action
* @property {string} pressShortcut Press shortcut
* @property {string} debugInfo Debug info
* @readonly
*/
export enum LogType {
loadJob = 'Load job',
saveJob = 'Save job',
......@@ -257,30 +109,6 @@ export enum LogType {
debugInfo = 'Debug info',
}
/**
* Types of actions with annotations
* @enum {string}
* @name HistoryActions
* @memberof module:API.cvat.enums
* @property {string} CHANGED_LABEL Changed label
* @property {string} CHANGED_ATTRIBUTES Changed attributes
* @property {string} CHANGED_POINTS Changed points
* @property {string} CHANGED_OUTSIDE Changed outside
* @property {string} CHANGED_OCCLUDED Changed occluded
* @property {string} CHANGED_ZORDER Changed z-order
* @property {string} CHANGED_LOCK Changed lock
* @property {string} CHANGED_COLOR Changed color
* @property {string} CHANGED_HIDDEN Changed hidden
* @property {string} CHANGED_SOURCE Changed source
* @property {string} MERGED_OBJECTS Merged objects
* @property {string} SPLITTED_TRACK Splitted track
* @property {string} GROUPED_OBJECTS Grouped objects
* @property {string} CREATED_OBJECTS Created objects
* @property {string} REMOVED_OBJECT Removed object
* @property {string} REMOVED_FRAME Removed frame
* @property {string} RESTORED_FRAME Restored frame
* @readonly
*/
export enum HistoryActions {
CHANGED_LABEL = 'Changed label',
CHANGED_ATTRIBUTES = 'Changed attributes',
......@@ -304,25 +132,12 @@ export enum HistoryActions {
RESTORED_FRAME = 'Restored frame',
}
/**
* Enum string values.
* @name ModelType
* @memberof module:API.cvat.enums
* @enum {string}
*/
export enum ModelType {
DETECTOR = 'detector',
INTERACTOR = 'interactor',
TRACKER = 'tracker',
}
/**
* Array of hex colors
* @name colors
* @memberof module:API.cvat.enums
* @type {string[]}
* @readonly
*/
export const colors = [
'#33ddff',
'#fa3253',
......@@ -356,33 +171,12 @@ export const colors = [
'#733380',
];
/**
* Types of cloud storage providers
* @enum {string}
* @name CloudStorageProviderType
* @memberof module:API.cvat.enums
* @property {string} AWS_S3 'AWS_S3_BUCKET'
* @property {string} AZURE 'AZURE_CONTAINER'
* @property {string} GOOGLE_CLOUD_STORAGE 'GOOGLE_CLOUD_STORAGE'
* @readonly
*/
export enum CloudStorageProviderType {
AWS_S3_BUCKET = 'AWS_S3_BUCKET',
AZURE_CONTAINER = 'AZURE_CONTAINER',
GOOGLE_CLOUD_STORAGE = 'GOOGLE_CLOUD_STORAGE',
}
/**
* Types of cloud storage credentials
* @enum {string}
* @name CloudStorageCredentialsType
* @memberof module:API.cvat.enums
* @property {string} KEY_SECRET_KEY_PAIR 'KEY_SECRET_KEY_PAIR'
* @property {string} ACCOUNT_NAME_TOKEN_PAIR 'ACCOUNT_NAME_TOKEN_PAIR'
* @property {string} ANONYMOUS_ACCESS 'ANONYMOUS_ACCESS'
* @property {string} KEY_FILE_PATH 'KEY_FILE_PATH'
* @readonly
*/
export enum CloudStorageCredentialsType {
KEY_SECRET_KEY_PAIR = 'KEY_SECRET_KEY_PAIR',
ACCOUNT_NAME_TOKEN_PAIR = 'ACCOUNT_NAME_TOKEN_PAIR',
......@@ -390,33 +184,12 @@ export enum CloudStorageCredentialsType {
KEY_FILE_PATH = 'KEY_FILE_PATH',
}
/**
* Types of cloud storage statuses
* @enum {string}
* @name CloudStorageStatus
* @memberof module:API.cvat.enums
* @property {string} AVAILABLE 'AVAILABLE'
* @property {string} NOT_FOUND 'NOT_FOUND'
* @property {string} FORBIDDEN 'FORBIDDEN'
* @readonly
*/
export enum CloudStorageStatus {
AVAILABLE = 'AVAILABLE',
NOT_FOUND = 'NOT_FOUND',
FORBIDDEN = 'FORBIDDEN',
}
/**
* Membership roles
* @enum {string}
* @name MembershipRole
* @memberof module:API.cvat.enums
* @property {string} WORKER 'worker'
* @property {string} SUPERVISOR 'supervisor'
* @property {string} MAINTAINER 'maintainer'
* @property {string} OWNER 'owner'
* @readonly
*/
export enum MembershipRole {
WORKER = 'worker',
SUPERVISOR = 'supervisor',
......@@ -424,17 +197,6 @@ export enum MembershipRole {
OWNER = 'owner',
}
/**
* Sorting methods
* @enum {string}
* @name SortingMethod
* @memberof module:API.cvat.enums
* @property {string} LEXICOGRAPHICAL 'lexicographical'
* @property {string} NATURAL 'natural'
* @property {string} PREDEFINED 'predefined'
* @property {string} RANDOM 'random'
* @readonly
*/
export enum SortingMethod {
LEXICOGRAPHICAL = 'lexicographical',
NATURAL = 'natural',
......@@ -442,42 +204,16 @@ export enum SortingMethod {
RANDOM = 'random',
}
/**
* Types of storage locations
* @enum {string}
* @name StorageLocation
* @memberof module:API.cvat.enums
* @property {string} LOCAL 'local'
* @property {string} CLOUD_STORAGE 'cloud_storage'
* @readonly
*/
export enum StorageLocation {
LOCAL = 'local',
CLOUD_STORAGE = 'cloud_storage',
}
/**
* Webhook source types
* @enum {string}
* @name WebhookSourceType
* @memberof module:API.cvat.enums
* @property {string} ORGANIZATION 'organization'
* @property {string} PROJECT 'project'
* @readonly
*/
export enum WebhookSourceType {
ORGANIZATION = 'organization',
PROJECT = 'project',
}
/**
* Webhook content types
* @enum {string}
* @name WebhookContentType
* @memberof module:API.cvat.enums
* @property {string} JSON 'json'
* @readonly
*/
export enum WebhookContentType {
JSON = 'application/json',
}
......
......@@ -6,12 +6,6 @@
import Platform from 'platform';
import ErrorStackParser from 'error-stack-parser';
/**
* Base exception class
* @memberof module:API.cvat.exceptions
* @extends Error
* @ignore
*/
export class Exception extends Error {
private readonly time: string;
private readonly system: string;
......@@ -21,9 +15,6 @@ export class Exception extends Error {
private readonly line: number;
private readonly column: number;
/**
* @param {string} message - Exception message
*/
constructor(message) {
super(message);
const time = new Date().toISOString();
......@@ -73,43 +64,15 @@ export class Exception extends Error {
get: () => time,
},
// jobID: {
// /**
// * @name jobID
// * @type {number}
// * @memberof module:API.cvat.exceptions.Exception
// * @readonly
// * @instance
// */
// get: () => jobID,
// },
// taskID: {
// /**
// * @name taskID
// * @type {number}
// * @memberof module:API.cvat.exceptions.Exception
// * @readonly
// * @instance
// */
// get: () => taskID,
// },
// projID: {
// /**
// * @name projID
// * @type {number}
// * @memberof module:API.cvat.exceptions.Exception
// * @readonly
// * @instance
// */
// get: () => projID,
// },
// clientID: {
// /**
// * @name clientID
// * @type {number}
// * @memberof module:API.cvat.exceptions.Exception
// * @readonly
// * @instance
// */
// get: () => clientID,
// },
filename: {
......@@ -146,14 +109,6 @@ export class Exception extends Error {
);
}
/**
* Save an exception on a server
* @name save
* @method
* @memberof Exception
* @instance
* @async
*/
async save(): Promise<void> {
const exceptionObject = {
system: this.system,
......@@ -171,6 +126,7 @@ export class Exception extends Error {
};
try {
// eslint-disable-next-line @typescript-eslint/no-var-requires
const serverProxy = require('./server-proxy').default;
await serverProxy.server.exception(exceptionObject);
} catch (exception) {
......@@ -179,73 +135,21 @@ export class Exception extends Error {
}
}
/**
* Exceptions are referred with arguments data
* @memberof module:API.cvat.exceptions
* @extends module:API.cvat.exceptions.Exception
*/
export class ArgumentError extends Exception {
/**
* @param {string} message - Exception message
*/
}
export class ArgumentError extends Exception {}
/**
* Unexpected problems with data which are not connected with a user input
* @memberof module:API.cvat.exceptions
* @extends module:API.cvat.exceptions.Exception
*/
export class DataError extends Exception {
/**
* @param {string} message - Exception message
*/
}
export class DataError extends Exception {}
/**
* Unexpected situations in code
* @memberof module:API.cvat.exceptions
* @extends module:API.cvat.exceptions.Exception
*/
export class ScriptingError extends Exception {
/**
* @param {string} message - Exception message
*/
}
export class ScriptingError extends Exception {}
/**
* Plugin-referred exceptions
* @memberof module:API.cvat.exceptions
* @extends module:API.cvat.exceptions.Exception
*/
export class PluginError extends Exception {
/**
* @param {string} message - Exception message
*/
}
export class PluginError extends Exception {}
/**
* Exceptions in interaction with a server
* @memberof module:API.cvat.exceptions
* @extends module:API.cvat.exceptions.Exception
*/
export class ServerError extends Exception {
/**
* @param {string} message - Exception message
* @param {(string|number)} code - Response code
*/
constructor(message, code) {
super(message);
Object.defineProperties(
this,
Object.freeze({
/**
* @name code
* @type {(string|number)}
* @memberof module:API.cvat.exceptions.ServerError
* @readonly
* @instance
*/
code: {
get: () => code,
},
......
// Copyright (C) 2021-2022 Intel Corporation
// Copyright (C) 2022 CVAT.ai Corporation
// Copyright (C) 2022-2023 CVAT.ai Corporation
//
// SPDX-License-Identifier: MIT
......@@ -12,11 +12,6 @@ import { Exception, ArgumentError, DataError } from './exceptions';
// This is the frames storage
const frameDataCache = {};
/**
* Class provides meta information about specific frame and frame itself
* @memberof module:API.cvat.classes
* @hideconstructor
*/
export class FrameData {
constructor({
width,
......@@ -33,93 +28,34 @@ export class FrameData {
Object.defineProperties(
this,
Object.freeze({
/**
* @name filename
* @type {string}
* @memberof module:API.cvat.classes.FrameData
* @readonly
* @instance
*/
filename: {
value: name,
writable: false,
},
/**
* @name width
* @type {number}
* @memberof module:API.cvat.classes.FrameData
* @readonly
* @instance
*/
width: {
value: width,
writable: false,
},
/**
* @name height
* @type {number}
* @memberof module:API.cvat.classes.FrameData
* @readonly
* @instance
*/
height: {
value: height,
writable: false,
},
/**
* @name jid
* @type {number}
* @memberof module:API.cvat.classes.FrameData
* @readonly
* @instance
*/
jid: {
value: jobID,
writable: false,
},
/**
* @name number
* @type {number}
* @memberof module:API.cvat.classes.FrameData
* @readonly
* @instance
*/
number: {
value: frameNumber,
writable: false,
},
/**
* True if some context images are associated with this frame
* @name hasRelatedContext
* @type {boolean}
* @memberof module:API.cvat.classes.FrameData
* @readonly
* @instance
*/
hasRelatedContext: {
value: hasRelatedContext,
writable: false,
},
/**
* Start frame of the frame in the job
* @name startFrame
* @type {number}
* @memberof module:API.cvat.classes.FrameData
* @readonly
* @instance
*/
startFrame: {
value: startFrame,
writable: false,
},
/**
* Stop frame of the frame in the job
* @name stopFrame
* @type {number}
* @memberof module:API.cvat.classes.FrameData
* @readonly
* @instance
*/
stopFrame: {
value: stopFrame,
writable: false,
......@@ -128,14 +64,6 @@ export class FrameData {
value: decodeForward,
writable: false,
},
/**
* True if frame was deleted from the task data
* @name deleted
* @type {boolean}
* @memberof module:API.cvat.classes.FrameData
* @readonly
* @instance
*/
deleted: {
value: deleted,
writable: false,
......@@ -144,18 +72,6 @@ export class FrameData {
);
}
/**
* Method returns URL encoded image which can be placed in the img tag
* @method data
* @returns {string}
* @memberof module:API.cvat.classes.FrameData
* @instance
* @async
* @param {function} [onServerRequest = () => {}]
* callback which will be called if data absences local
* @throws {module:API.cvat.exception.ServerError}
* @throws {module:API.cvat.exception.PluginError}
*/
async data(onServerRequest = () => {}) {
const result = await PluginRegistry.apiWrapper.call(this, FrameData.prototype.data, onServerRequest);
return result;
......
......@@ -16,11 +16,6 @@ export interface RawAttribute {
id?: number;
}
/**
* Class representing an attribute
* @memberof module:API.cvat.classes
* @hideconstructor
*/
export class Attribute {
public id?: number;
public defaultValue: string;
......@@ -58,63 +53,21 @@ export class Attribute {
Object.defineProperties(
this,
Object.freeze({
/**
* @name id
* @type {number}
* @memberof module:API.cvat.classes.Attribute
* @readonly
* @instance
*/
id: {
get: () => data.id,
},
/**
* @name defaultValue
* @type {string}
* @memberof module:API.cvat.classes.Attribute
* @readonly
* @instance
*/
defaultValue: {
get: () => data.default_value,
},
/**
* @name inputType
* @type {module:API.cvat.enums.AttributeType}
* @memberof module:API.cvat.classes.Attribute
* @readonly
* @instance
*/
inputType: {
get: () => data.input_type,
},
/**
* @name mutable
* @type {boolean}
* @memberof module:API.cvat.classes.Attribute
* @readonly
* @instance
*/
mutable: {
get: () => data.mutable,
},
/**
* @name name
* @type {string}
* @memberof module:API.cvat.classes.Attribute
* @readonly
* @instance
*/
name: {
get: () => data.name,
},
/**
* @name values
* @type {string[]}
* @memberof module:API.cvat.classes.Attribute
* @readonly
* @instance
*/
values: {
get: () => [...data.values],
},
......@@ -152,11 +105,6 @@ export interface RawLabel {
attributes: RawAttribute[];
}
/**
* Class representing a label
* @memberof module:API.cvat.classes
* @hideconstructor
*/
export class Label {
public name: string;
public readonly id?: number;
......@@ -209,22 +157,9 @@ export class Label {
Object.defineProperties(
this,
Object.freeze({
/**
* @name id
* @type {number}
* @memberof module:API.cvat.classes.Label
* @readonly
* @instance
*/
id: {
get: () => data.id,
},
/**
* @name name
* @type {string}
* @memberof module:API.cvat.classes.Label
* @instance
*/
name: {
get: () => data.name,
set: (name) => {
......@@ -234,12 +169,6 @@ export class Label {
data.name = name;
},
},
/**
* @name color
* @type {string}
* @memberof module:API.cvat.classes.Label
* @instance
*/
color: {
get: () => data.color,
set: (color) => {
......@@ -250,40 +179,12 @@ export class Label {
}
},
},
/**
* @name attributes
* @type {module:API.cvat.classes.Attribute[]}
* @memberof module:API.cvat.classes.Label
* @readonly
* @instance
*/
attributes: {
get: () => [...data.attributes],
},
/**
* @typedef {Object} SkeletonStructure
* @property {module:API.cvat.classes.Label[]} sublabels A list of labels the skeleton includes
* @property {Object[]} svg An SVG representation of the skeleton
* A type of a file
* @global
*/
/**
* @name type
* @type {string | undefined}
* @memberof module:API.cvat.classes.Label
* @readonly
* @instance
*/
type: {
get: () => data.type,
},
/**
* @name type
* @type {SkeletonStructure | undefined}
* @memberof module:API.cvat.classes.Label
* @readonly
* @instance
*/
structure: {
get: () => {
if (data.type === ShapeType.SKELETON) {
......@@ -296,25 +197,12 @@ export class Label {
return null;
},
},
/**
* @name deleted
* @type {boolean}
* @memberof module:API.cvat.classes.Label
* @instance
*/
deleted: {
get: () => data.deleted,
set: (value) => {
data.deleted = value;
},
},
/**
* @name hasParent
* @type {boolean}
* @memberof module:API.cvat.classes.Label
* @readonly
* @instance
*/
hasParent: {
get: () => data.has_parent,
},
......
......@@ -64,10 +64,6 @@ export interface SerializedData {
};
}
/**
* Class representing a state of an object on a specific frame
* @memberof module:API.cvat.classes
*/
export default class ObjectState {
private readonly __internal: {
save: (objectState: ObjectState) => ObjectState;
......@@ -105,14 +101,6 @@ export default class ObjectState {
public descriptions: string[];
public elements: ObjectState[];
/**
* @param {Object} serialized - is an dictionary which contains
* initial information about an ObjectState;
* </br> Necessary fields: objectType, shapeType, frame, updated, group
* </br> Optional fields: keyframes, clientID, serverID, parentID
* </br> Optional fields which can be set later: points, zOrder, outside,
* occluded, hidden, attributes, lock, label, color, keyframe, source
*/
constructor(serialized: SerializedData) {
if (!isEnum.call(ObjectType, serialized.objectType)) {
throw new ArgumentError(
......@@ -200,82 +188,27 @@ export default class ObjectState {
get: () => data.updateFlags,
},
frame: {
/**
* @name frame
* @type {number}
* @memberof module:API.cvat.classes.ObjectState
* @readonly
* @instance
*/
get: () => data.frame,
},
objectType: {
/**
* @name objectType
* @type {module:API.cvat.enums.ObjectType}
* @memberof module:API.cvat.classes.ObjectState
* @readonly
* @instance
*/
get: () => data.objectType,
},
shapeType: {
/**
* @name shapeType
* @type {module:API.cvat.enums.ShapeType}
* @memberof module:API.cvat.classes.ObjectState
* @readonly
* @instance
*/
get: () => data.shapeType,
},
source: {
/**
* @name source
* @type {module:API.cvat.enums.Source}
* @memberof module:API.cvat.classes.ObjectState
* @readonly
* @instance
*/
get: () => data.source,
},
clientID: {
/**
* @name clientID
* @type {number}
* @memberof module:API.cvat.classes.ObjectState
* @readonly
* @instance
*/
get: () => data.clientID,
},
serverID: {
/**
* @name serverID
* @type {number}
* @memberof module:API.cvat.classes.ObjectState
* @readonly
* @instance
*/
get: () => data.serverID,
},
parentID: {
/**
* @name parentID
* @type {number | null}
* @memberof module:API.cvat.classes.ObjectState
* @readonly
* @instance
*/
get: () => data.parentID,
},
label: {
/**
* @name shape
* @type {module:API.cvat.classes.Label}
* @memberof module:API.cvat.classes.ObjectState
* @instance
*/
get: () => data.label,
set: (labelInstance) => {
data.updateFlags.label = true;
......@@ -283,12 +216,6 @@ export default class ObjectState {
},
},
color: {
/**
* @name color
* @type {string}
* @memberof module:API.cvat.classes.ObjectState
* @instance
*/
get: () => data.color,
set: (color) => {
data.updateFlags.color = true;
......@@ -296,12 +223,6 @@ export default class ObjectState {
},
},
hidden: {
/**
* @name hidden
* @type {boolean}
* @memberof module:API.cvat.classes.ObjectState
* @instance
*/
get: () => {
if (data.shapeType === ShapeType.SKELETON) {
return data.elements.every((element: ObjectState) => element.hidden);
......@@ -321,13 +242,6 @@ export default class ObjectState {
},
},
points: {
/**
* @name points
* @type {number[]}
* @memberof module:API.cvat.classes.ObjectState
* @throws {module:API.cvat.exceptions.ArgumentError}
* @instance
*/
get: () => {
if (data.shapeType === ShapeType.SKELETON) {
return data.elements.map((element) => element.points).flat();
......@@ -370,14 +284,6 @@ export default class ObjectState {
},
},
rotation: {
/**
* @name rotation
* @description angle measured by degrees
* @type {number}
* @memberof module:API.cvat.classes.ObjectState
* @throws {module:API.cvat.exceptions.ArgumentError}
* @instance
*/
get: () => data.rotation,
set: (rotation) => {
if (typeof rotation === 'number') {
......@@ -394,23 +300,9 @@ export default class ObjectState {
},
},
group: {
/**
* Object with short group info { color, id }
* @name group
* @type {object}
* @memberof module:API.cvat.classes.ObjectState
* @instance
* @readonly
*/
get: () => data.group,
},
zOrder: {
/**
* @name zOrder
* @type {integer | null}
* @memberof module:API.cvat.classes.ObjectState
* @instance
*/
get: () => data.zOrder,
set: (zOrder) => {
data.updateFlags.zOrder = true;
......@@ -418,12 +310,6 @@ export default class ObjectState {
},
},
outside: {
/**
* @name outside
* @type {boolean}
* @memberof module:API.cvat.classes.ObjectState
* @instance
*/
get: () => {
if (data.shapeType === ShapeType.SKELETON) {
return data.elements.every((el) => el.outside);
......@@ -442,12 +328,6 @@ export default class ObjectState {
},
},
keyframe: {
/**
* @name keyframe
* @type {boolean}
* @memberof module:API.cvat.classes.ObjectState
* @instance
*/
get: () => {
if (data.shapeType === ShapeType.SKELETON) {
return data.keyframe || data.elements.some((el) => el.keyframe);
......@@ -467,14 +347,6 @@ export default class ObjectState {
},
},
keyframes: {
/**
* Object of keyframes { first, prev, next, last }
* @name keyframes
* @type {object | null}
* @memberof module:API.cvat.classes.ObjectState
* @readonly
* @instance
*/
get: () => {
if (typeof data.keyframes === 'object') {
return { ...data.keyframes };
......@@ -484,12 +356,6 @@ export default class ObjectState {
},
},
occluded: {
/**
* @name occluded
* @type {boolean}
* @memberof module:API.cvat.classes.ObjectState
* @instance
*/
get: () => {
if (data.shapeType === ShapeType.SKELETON) {
return data.elements.every((el) => el.occluded);
......@@ -508,12 +374,6 @@ export default class ObjectState {
},
},
lock: {
/**
* @name lock
* @type {boolean}
* @memberof module:API.cvat.classes.ObjectState
* @instance
*/
get: () => {
if (data.shapeType === ShapeType.SKELETON) {
return data.elements.every((el) => el.lock);
......@@ -532,12 +392,6 @@ export default class ObjectState {
},
},
pinned: {
/**
* @name pinned
* @type {boolean | null}
* @memberof module:API.cvat.classes.ObjectState
* @instance
*/
get: () => {
if (typeof data.pinned === 'boolean') {
return data.pinned;
......@@ -551,26 +405,9 @@ export default class ObjectState {
},
},
updated: {
/**
* Timestamp of the latest updated of the object
* @name updated
* @type {number}
* @memberof module:API.cvat.classes.ObjectState
* @instance
* @readonly
*/
get: () => data.updated,
},
attributes: {
/**
* Object is id:value pairs where "id" is an integer
* attribute identifier and "value" is an attribute value
* @name attributes
* @type {Object}
* @memberof module:API.cvat.classes.ObjectState
* @throws {module:API.cvat.exceptions.ArgumentError}
* @instance
*/
get: () => data.attributes,
set: (attributes) => {
if (typeof attributes !== 'object') {
......@@ -591,14 +428,6 @@ export default class ObjectState {
},
},
descriptions: {
/**
* Additional text information displayed on canvas
* @name descripttions
* @type {string[]}
* @memberof module:API.cvat.classes.ObjectState
* @throws {module:API.cvat.exceptions.ArgumentError}
* @instance
*/
get: () => [...data.descriptions],
set: (descriptions) => {
if (
......@@ -615,15 +444,6 @@ export default class ObjectState {
},
},
elements: {
/**
* Returns a list of object states for compound objects (like skeletons)
* @name elements
* @type {string[]}
* @memberof module:API.cvat.classes.ObjectState
* @throws {module:API.cvat.exceptions.ArgumentError}
* @readonly
* @instance
*/
get: () => {
if (data.elements) {
return [...data.elements];
......@@ -683,35 +503,11 @@ export default class ObjectState {
}
}
/**
* Method saves/updates an object state in a collection
* @method save
* @memberof module:API.cvat.classes.ObjectState
* @readonly
* @instance
* @async
* @throws {module:API.cvat.exceptions.PluginError}
* @throws {module:API.cvat.exceptions.ArgumentError}
* @returns {module:API.cvat.classes.ObjectState} updated state of an object
*/
async save(): Promise<ObjectState> {
const result = await PluginRegistry.apiWrapper.call(this, ObjectState.prototype.save);
return result;
}
/**
* Method deletes an object from a collection
* @method delete
* @memberof module:API.cvat.classes.ObjectState
* @readonly
* @instance
* @param {integer} frame current frame number
* @param {boolean} [force=false] delete object even if it is locked
* @async
* @returns {boolean} true if object has been deleted
* @throws {module:API.cvat.exceptions.PluginError}
* @throws {module:API.cvat.exceptions.ArgumentError}
*/
async delete(frame, force = false): Promise<boolean> {
const result = await PluginRegistry.apiWrapper.call(this, ObjectState.prototype.delete, frame, force);
return result;
......
此差异已折叠。
此差异已折叠。
......@@ -14,11 +14,6 @@ interface StorageJsonData {
cloud_storage_id?: number;
}
/**
* Class representing a storage for import and export resources
* @memberof module:API.cvat.classes
* @hideconstructor
*/
export class Storage {
public location: StorageLocation;
public cloudStorageId: number;
......@@ -32,23 +27,9 @@ export class Storage {
Object.defineProperties(
this,
Object.freeze({
/**
* @name location
* @type {module:API.cvat.enums.StorageLocation}
* @memberof module:API.cvat.classes.Storage
* @instance
* @readonly
*/
location: {
get: () => data.location,
},
/**
* @name cloudStorageId
* @type {number}
* @memberof module:API.cvat.classes.Storage
* @instance
* @readonly
*/
cloudStorageId: {
get: () => data.cloudStorageId,
},
......
......@@ -58,123 +58,39 @@ export default class User {
this,
Object.freeze({
id: {
/**
* @name id
* @type {number}
* @memberof module:API.cvat.classes.User
* @readonly
* @instance
*/
get: () => data.id,
},
username: {
/**
* @name username
* @type {string}
* @memberof module:API.cvat.classes.User
* @readonly
* @instance
*/
get: () => data.username,
},
email: {
/**
* @name email
* @type {string}
* @memberof module:API.cvat.classes.User
* @readonly
* @instance
*/
get: () => data.email,
},
firstName: {
/**
* @name firstName
* @type {string}
* @memberof module:API.cvat.classes.User
* @readonly
* @instance
*/
get: () => data.first_name,
},
lastName: {
/**
* @name lastName
* @type {string}
* @memberof module:API.cvat.classes.User
* @readonly
* @instance
*/
get: () => data.last_name,
},
groups: {
/**
* @name groups
* @type {string[]}
* @memberof module:API.cvat.classes.User
* @readonly
* @instance
*/
get: () => JSON.parse(JSON.stringify(data.groups)),
},
lastLogin: {
/**
* @name lastLogin
* @type {string}
* @memberof module:API.cvat.classes.User
* @readonly
* @instance
*/
get: () => data.last_login,
},
dateJoined: {
/**
* @name dateJoined
* @type {string}
* @memberof module:API.cvat.classes.User
* @readonly
* @instance
*/
get: () => data.date_joined,
},
isStaff: {
/**
* @name isStaff
* @type {boolean}
* @memberof module:API.cvat.classes.User
* @readonly
* @instance
*/
get: () => data.is_staff,
},
isSuperuser: {
/**
* @name isSuperuser
* @type {boolean}
* @memberof module:API.cvat.classes.User
* @readonly
* @instance
*/
get: () => data.is_superuser,
},
isActive: {
/**
* @name isActive
* @type {boolean}
* @memberof module:API.cvat.classes.User
* @readonly
* @instance
*/
get: () => data.is_active,
},
isVerified: {
/**
* @name isVerified
* @type {boolean}
* @memberof module:API.cvat.classes.User
* @readonly
* @instance
*/
get: () => !data.email_verification_required,
},
}),
......
此差异已折叠。
此差异已折叠。
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册