UNPKG

@applitools/eyes

Version:
170 lines (169 loc) 6.15 kB
"use strict"; var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { if (k2 === undefined) k2 = k; var desc = Object.getOwnPropertyDescriptor(m, k); if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) { desc = { enumerable: true, get: function() { return m[k]; } }; } Object.defineProperty(o, k2, desc); }) : (function(o, m, k, k2) { if (k2 === undefined) k2 = k; o[k2] = m[k]; })); var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) { Object.defineProperty(o, "default", { enumerable: true, value: v }); }) : function(o, v) { o["default"] = v; }); var __importStar = (this && this.__importStar) || function (mod) { if (mod && mod.__esModule) return mod; var result = {}; if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k); __setModuleDefault(result, mod); return result; }; Object.defineProperty(exports, "__esModule", { value: true }); exports.BatchInfoData = void 0; const utils = __importStar(require("@applitools/utils")); const PropertyData_1 = require("./PropertyData"); class BatchInfoData { constructor(batchOrName, startedAt, id) { var _a, _b, _c, _d, _e, _f, _g; const batch = utils.types.isNull(batchOrName) || utils.types.isString(batchOrName) ? { name: batchOrName, id, startedAt } : batchOrName; utils.guard.isString(batch.id, { name: 'id', strict: false }); utils.guard.isString(batch.name, { name: 'name', strict: false }); utils.guard.isString(batch.sequenceName, { name: 'sequenceName', strict: false }); utils.guard.isBoolean(batch.notifyOnCompletion, { name: 'notifyOnCompletion', strict: false }); utils.guard.isArray(batch.properties, { name: 'properties', strict: false }); utils.guard.isString(batch.buildId, { name: 'buildId', strict: false }); this._batch = { id: (_b = (_a = batch.id) !== null && _a !== void 0 ? _a : utils.general.getEnvValue('BATCH_ID')) !== null && _b !== void 0 ? _b : `generated-${utils.general.guid()}`, name: (_c = batch.name) !== null && _c !== void 0 ? _c : utils.general.getEnvValue('BATCH_NAME'), sequenceName: (_d = batch.sequenceName) !== null && _d !== void 0 ? _d : utils.general.getEnvValue('BATCH_SEQUENCE'), startedAt: (_e = batch.startedAt) !== null && _e !== void 0 ? _e : new Date(), notifyOnCompletion: (_g = (_f = batch.notifyOnCompletion) !== null && _f !== void 0 ? _f : utils.general.getEnvValue('BATCH_NOTIFY', 'boolean')) !== null && _g !== void 0 ? _g : false, properties: batch.properties, buildId: batch.buildId, }; } get id() { return this._batch.id; } set id(id) { utils.guard.isString(id, { name: 'id', strict: false }); this._batch.id = id; } getId() { return this.id; } setId(id) { this.id = id; return this; } get name() { return this._batch.name; } set name(name) { utils.guard.isString(name, { name: 'name', strict: false }); this._batch.name = name; } getName() { return this.name; } setName(name) { this.name = name; return this; } get sequenceName() { return this._batch.sequenceName; } set sequenceName(sequenceName) { utils.guard.isString(sequenceName, { name: 'sequenceName', strict: false }); this._batch.sequenceName = sequenceName; } getSequenceName() { return this.sequenceName; } setSequenceName(sequenceName) { this.sequenceName = sequenceName; return this; } get startedAt() { return this._batch.startedAt; } set startedAt(startedAt) { this._batch.startedAt = new Date(startedAt); } getStartedAt() { return this.startedAt; } setStartedAt(startedAt) { this.startedAt = startedAt; return this; } get notifyOnCompletion() { return this._batch.notifyOnCompletion; } set notifyOnCompletion(notifyOnCompletion) { utils.guard.isBoolean(notifyOnCompletion, { name: 'notifyOnCompletion', strict: false }); this._batch.notifyOnCompletion = notifyOnCompletion; } getNotifyOnCompletion() { return this.notifyOnCompletion; } setNotifyOnCompletion(notifyOnCompletion) { this.notifyOnCompletion = notifyOnCompletion; return this; } get properties() { return this._batch.properties; } set properties(properties) { utils.guard.isArray(properties, { name: 'properties', strict: false }); this._batch.properties = properties; } getProperties() { var _a, _b; return (_b = (_a = this.properties) === null || _a === void 0 ? void 0 : _a.map(property => new PropertyData_1.PropertyDataData(property))) !== null && _b !== void 0 ? _b : []; } setProperties(properties) { this.properties = properties; return this; } addProperty(propOrName, value) { const property = utils.types.isString(propOrName) ? { name: propOrName, value: value } : propOrName; if (!this.properties) this.properties = []; this.properties.push(property); return this; } get buildId() { return this._batch.buildId; } set buildId(buildId) { utils.guard.isString(buildId, { name: 'buildId', strict: false }); this._batch.buildId = buildId; } getBuildId() { return this.buildId; } setBuildId(buildId) { this.buildId = buildId; return this; } /** @internal */ toObject() { return this._batch; } /** @internal */ toJSON() { return utils.general.toJSON(this._batch); } /** @internal */ toString() { return utils.general.toString(this); } } exports.BatchInfoData = BatchInfoData;