fase(3): crawling module domain and application
This commit is contained in:
20
dist/modules/crawling/domain/value-objects/Selector.js
vendored
Normal file
20
dist/modules/crawling/domain/value-objects/Selector.js
vendored
Normal file
@@ -0,0 +1,20 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.Selector = void 0;
|
||||
const ValueObject_1 = require("../../../../shared/domain/ValueObject");
|
||||
const Result_1 = require("../../../../shared/domain/Result");
|
||||
class Selector extends ValueObject_1.ValueObject {
|
||||
constructor(props) {
|
||||
super(props);
|
||||
}
|
||||
static create(raw) {
|
||||
if (!raw || raw.trim().length === 0) {
|
||||
return (0, Result_1.Err)('Selector must not be empty');
|
||||
}
|
||||
return (0, Result_1.Ok)(new Selector({ value: raw.trim() }));
|
||||
}
|
||||
toString() {
|
||||
return this.props.value;
|
||||
}
|
||||
}
|
||||
exports.Selector = Selector;
|
||||
21
dist/modules/crawling/domain/value-objects/SessionStatus.js
vendored
Normal file
21
dist/modules/crawling/domain/value-objects/SessionStatus.js
vendored
Normal file
@@ -0,0 +1,21 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.SessionStatus = void 0;
|
||||
const ValueObject_1 = require("../../../../shared/domain/ValueObject");
|
||||
const Result_1 = require("../../../../shared/domain/Result");
|
||||
const VALID_STATUSES = ['running', 'completed', 'failed', 'stopped'];
|
||||
class SessionStatus extends ValueObject_1.ValueObject {
|
||||
constructor(props) {
|
||||
super(props);
|
||||
}
|
||||
static create(val) {
|
||||
if (!VALID_STATUSES.includes(val)) {
|
||||
return (0, Result_1.Err)(`Invalid session status: "${val}". Must be one of: ${VALID_STATUSES.join(', ')}`);
|
||||
}
|
||||
return (0, Result_1.Ok)(new SessionStatus({ value: val }));
|
||||
}
|
||||
getValue() {
|
||||
return this.props.value;
|
||||
}
|
||||
}
|
||||
exports.SessionStatus = SessionStatus;
|
||||
24
dist/modules/crawling/domain/value-objects/Url.js
vendored
Normal file
24
dist/modules/crawling/domain/value-objects/Url.js
vendored
Normal file
@@ -0,0 +1,24 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.Url = void 0;
|
||||
const ValueObject_1 = require("../../../../shared/domain/ValueObject");
|
||||
const Result_1 = require("../../../../shared/domain/Result");
|
||||
class Url extends ValueObject_1.ValueObject {
|
||||
constructor(props) {
|
||||
super(props);
|
||||
}
|
||||
static create(raw) {
|
||||
if (!raw || raw.trim().length === 0) {
|
||||
return (0, Result_1.Err)('URL must not be empty');
|
||||
}
|
||||
const trimmed = raw.trim();
|
||||
if (!trimmed.startsWith('http://') && !trimmed.startsWith('https://')) {
|
||||
return (0, Result_1.Err)('URL must start with http:// or https://');
|
||||
}
|
||||
return (0, Result_1.Ok)(new Url({ value: trimmed }));
|
||||
}
|
||||
toString() {
|
||||
return this.props.value;
|
||||
}
|
||||
}
|
||||
exports.Url = Url;
|
||||
Reference in New Issue
Block a user