Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@hexancore/common

Package Overview
Dependencies
Maintainers
0
Versions
22
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@hexancore/common - npm Package Compare versions

Comparing version 0.15.0 to 0.16.0

lib/cjs/Application/HCommand.js

2

lib/cjs/Application/index.js

@@ -5,1 +5,3 @@ "use strict";

tslib_1.__exportStar(require("./ApplicationErrors"), exports);
tslib_1.__exportStar(require("./HCommand"), exports);
tslib_1.__exportStar(require("./HQuery"), exports);

11

lib/cjs/Domain/ValueObject/AccountId.js
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.AccountId = void 0;
const tslib_1 = require("tslib");
const Util_1 = require("../../Util");
const StringValue_1 = require("./StringValue");
const ValueObject_1 = require("./ValueObject");
let AccountId = class AccountId extends StringValue_1.StringValue {
};
class AccountId extends StringValue_1.StringValue {
static HOBJ_META = Util_1.HObjectTypeMeta.domain('Core', 'Account', 'ValueObject', 'AccountId', AccountId);
}
exports.AccountId = AccountId;
exports.AccountId = AccountId = tslib_1.__decorate([
(0, ValueObject_1.ValueObject)('Account')
], AccountId);
"use strict";
var DateTime_1;
Object.defineProperty(exports, "__esModule", { value: true });
exports.DateTime = exports.DEFAULT_DATE_TIME_FORMAT = void 0;
const tslib_1 = require("tslib");
const ValueObject_1 = require("./ValueObject");
const AbstractValueObject_1 = require("./AbstractValueObject");
const Result_1 = require("../../Util/Result");
const core_1 = require("@js-joda/core");
const Util_1 = require("../../Util");
exports.DEFAULT_DATE_TIME_FORMAT = core_1.DateTimeFormatter.ofPattern("yyyy-MM-dd'T'HH:mm:ss");

@@ -28,4 +27,5 @@ function createJsJodaFromString(v) {

}
let DateTime = DateTime_1 = class DateTime extends ValueObject_1.AbstractValueObject {
class DateTime extends AbstractValueObject_1.AbstractValueObject {
value;
static HOBJ_META = Util_1.HObjectTypeMeta.domain('Core', 'Core', 'ValueObject', 'DateTime', DateTime);
constructor(value) {

@@ -41,23 +41,21 @@ super();

}
static c(v) {
switch (typeof v) {
case 'number': return this.fromTimestamp(v);
static parse(plain) {
switch (typeof plain) {
case 'number': return DateTime.fromTimestamp(plain);
case 'string':
try {
return (0, Result_1.OK)(new this(createJsJodaFromString(v)));
return (0, Result_1.OK)(new this(createJsJodaFromString(plain)));
}
catch (e) {
return ValueObject_1.AbstractValueObject.invalidRaw(DateTime_1, {
raw: v,
msg: 'invalid format: ' + e.message,
});
return Util_1.PlainParseHelper.HObjectParseErr(DateTime, [
new Util_1.InvalidStringPlainParseIssue('datetime', {}, 'Given plain string is not valid datetime')
]);
}
}
if (v instanceof Date) {
return (0, Result_1.OK)(new this(createJsJodaFromDate(v)));
if (plain instanceof Date) {
return (0, Result_1.OK)(new this(createJsJodaFromDate(plain)));
}
return ValueObject_1.AbstractValueObject.invalidRaw(DateTime_1, {
raw: v,
msg: 'unsupported datetime raw type',
});
return Util_1.PlainParseHelper.HObjectParseErr(DateTime, [
new Util_1.InvalidTypePlainParseIssue(["number", "string", "Date"], typeof plain)
]);
}

@@ -75,8 +73,7 @@ static cs(v) {

if (timestamp < 0) {
return ValueObject_1.AbstractValueObject.invalidRaw(DateTime_1, {
raw: timestamp,
msg: 'invalid timestamp',
});
return Util_1.PlainParseHelper.HObjectParseErr(DateTime, [
Util_1.TooSmallPlainParseIssue.numberGTE(0, timestamp)
]);
}
return (0, Result_1.OK)(new this(createJsJodaFromTimestamp(timestamp)));
return (0, Result_1.OK)(new DateTime(createJsJodaFromTimestamp(timestamp)));
}

@@ -90,6 +87,6 @@ get v() {

plus(amount) {
return new DateTime_1(this.value.plus(amount));
return new DateTime(this.value.plus(amount));
}
minus(amount) {
return new DateTime_1(this.value.minus(amount));
return new DateTime(this.value.minus(amount));
}

@@ -129,7 +126,3 @@ equals(o) {

}
};
}
exports.DateTime = DateTime;
exports.DateTime = DateTime = DateTime_1 = tslib_1.__decorate([
(0, ValueObject_1.ValueObject)('Core'),
tslib_1.__metadata("design:paramtypes", [core_1.LocalDateTime])
], DateTime);
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.Email = void 0;
const tslib_1 = require("tslib");
const ValueObject_1 = require("./ValueObject");
const Util_1 = require("../../Util");
const EmailHash_1 = require("./EmailHash");
const RegexStringValue_1 = require("./RegexStringValue");
const EMAIL_REGEX = /^(([^<>()[\]\\.,;:\s@"]+(\.[^<>()[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/i;
let Email = class Email extends RegexStringValue_1.RegexStringValue {
class Email extends RegexStringValue_1.RegexStringValue {
static HOBJ_META = Util_1.HObjectTypeMeta.domain('Core', 'Core', 'ValueObject', 'Email', Email);
static getRegex() {

@@ -22,6 +22,3 @@ return EMAIL_REGEX;

}
};
}
exports.Email = Email;
exports.Email = Email = tslib_1.__decorate([
(0, ValueObject_1.ValueObject)('Core')
], Email);
"use strict";
var EmailHash_1;
Object.defineProperty(exports, "__esModule", { value: true });
exports.EmailHash = void 0;
const tslib_1 = require("tslib");
const StringValue_1 = require("./StringValue");
const crypto = tslib_1.__importStar(require("crypto"));
const ValueObject_1 = require("./ValueObject");
let EmailHash = EmailHash_1 = class EmailHash extends StringValue_1.StringValue {
const node_crypto_1 = require("node:crypto");
const Util_1 = require("../../Util");
class EmailHash extends StringValue_1.StringValue {
static HOBJ_META = Util_1.HObjectTypeMeta.domain('Core', 'Core', 'ValueObject', 'EmailHash', EmailHash);
static createFromEmail(email) {
return new EmailHash_1(crypto.createHash('sha1').update(email.v).digest('hex'));
return new EmailHash((0, node_crypto_1.hash)('sha1', email.v, "hex"));
}
};
}
exports.EmailHash = EmailHash;
exports.EmailHash = EmailHash = EmailHash_1 = tslib_1.__decorate([
(0, ValueObject_1.ValueObject)('Core')
], EmailHash);
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const tslib_1 = require("tslib");
tslib_1.__exportStar(require("./ValueObject"), exports);
tslib_1.__exportStar(require("./SimpleValueObject"), exports);
tslib_1.__exportStar(require("./AbstractValueObject"), exports);
tslib_1.__exportStar(require("./AccountId"), exports);

@@ -7,0 +6,0 @@ tslib_1.__exportStar(require("./UserId"), exports);

"use strict";
var RefId_1;
Object.defineProperty(exports, "__esModule", { value: true });
exports.RefId = void 0;
const tslib_1 = require("tslib");
const StringValue_1 = require("./StringValue");
const ValueObject_1 = require("./ValueObject");
const nanoid_1 = require("nanoid");
const Util_1 = require("../../Util");
const RefIdGenerator = (0, nanoid_1.customAlphabet)('0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz-', 21);
let RefId = RefId_1 = class RefId extends StringValue_1.StringValue {
class RefId extends StringValue_1.StringValue {
static HOBJ_META = Util_1.HObjectTypeMeta.domain('Core', 'Core', 'ValueObject', 'RefId', RefId);
static gen() {
return new RefId_1(RefIdGenerator());
return new RefId(RefIdGenerator());
}
};
}
exports.RefId = RefId;
exports.RefId = RefId = RefId_1 = tslib_1.__decorate([
(0, ValueObject_1.ValueObject)('Core')
], RefId);
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.RegexStringValue = void 0;
const Result_1 = require("../../Util/Result");
const ValueObject_1 = require("./ValueObject");
const StringValue_1 = require("./StringValue");
class RegexStringValue extends StringValue_1.StringValue {
static checkRawValue(value) {
return this.getRegex().test(value) ? (0, Result_1.OK)(true) : ValueObject_1.AbstractValueObject.invalidRaw(this, { raw: value });
const Util_1 = require("../../Util");
const AbstractValueObject_1 = require("./AbstractValueObject");
class RegexStringValue extends AbstractValueObject_1.AbstractValueObject {
v;
constructor(v) {
super();
this.v = v;
}
static parse(plain) {
const parsed = Util_1.PlainParseHelper.parseStringRegex(plain, this.getRegex());
if (parsed instanceof Util_1.PlainParseIssue) {
return Util_1.PlainParseHelper.HObjectParseErr(this, [parsed]);
}
return (0, Util_1.OK)(new this(parsed));
}
static getRegex() {
throw new Util_1.LogicError("Must be implemented in value object class");
}
static cs(v) {
return new this(v);
}
equals(other) {
return this.v === other.v;
}
toString() {
return this.v;
}
toJSON() {
return this.v;
}
}
exports.RegexStringValue = RegexStringValue;
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.StringValue = void 0;
const SimpleValueObject_1 = require("./SimpleValueObject");
class StringValue extends SimpleValueObject_1.SimpleValueObject {
const Util_1 = require("../../Util");
const AbstractValueObject_1 = require("./AbstractValueObject");
class StringValue extends AbstractValueObject_1.AbstractValueObject {
v;
static HOBJ_META = Util_1.HObjectTypeMeta.domain('Core', 'Core', 'ValueObject', 'String', StringValue);
constructor(v) {
super();
this.v = v;
}
static parse(plain) {
const parsed = Util_1.PlainParseHelper.parseString(plain);
if (parsed instanceof Util_1.PlainParseIssue) {
return Util_1.PlainParseHelper.HObjectParseErr(this, [parsed]);
}
return (0, Util_1.OK)(new this(parsed));
}
static cs(v) {
return new this(v);
}
equals(other) {
return this.v === other.v;
}
toString() {
return this.v;
}
toJSON() {
return this.v;
}
}
exports.StringValue = StringValue;
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.UBigIntValue = void 0;
const tslib_1 = require("tslib");
const Util_1 = require("../../Util");
const SimpleValueObject_1 = require("./SimpleValueObject");
const ValueObject_1 = require("./ValueObject");
let UBigIntValue = class UBigIntValue extends SimpleValueObject_1.SimpleValueObject {
static c(value) {
if (typeof value === 'string') {
try {
value = BigInt(value);
}
catch (e) {
return ValueObject_1.AbstractValueObject.invalidRaw(this, { raw: value });
}
const AbstractValueObject_1 = require("./AbstractValueObject");
class UBigIntValue extends AbstractValueObject_1.AbstractValueObject {
v;
static HOBJ_META = Util_1.HObjectTypeMeta.domain('Core', 'Core', 'ValueObject', 'UBigInt', UBigIntValue);
constructor(v) {
super();
this.v = v;
}
static parse(plain) {
const parsed = Util_1.PlainParseHelper.parseBigInt64GTE(plain, 0n);
if (parsed instanceof Util_1.PlainParseIssue) {
return Util_1.PlainParseHelper.HObjectParseErr(this, [parsed]);
}
const checkResult = this.checkRawValue(value);
return checkResult.isError() ? (0, Util_1.ERR)(checkResult.e) : (0, Util_1.OK)(new this(value));
return (0, Util_1.OK)(new this(parsed));
}
static cs(value) {
value = BigInt(value.toString());
return new this(value);
static cs(v) {
return new this(BigInt(v));
}
static checkRawValue(value) {
return value >= 0n ? (0, Util_1.OK)(true) : ValueObject_1.AbstractValueObject.invalidRaw(this, { raw: value });
equals(other) {
return this.v === other.v;
}

@@ -34,6 +32,3 @@ toString() {

}
};
}
exports.UBigIntValue = UBigIntValue;
exports.UBigIntValue = UBigIntValue = tslib_1.__decorate([
(0, ValueObject_1.ValueObject)('Core')
], UBigIntValue);
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.UIntValue = void 0;
const tslib_1 = require("tslib");
const Util_1 = require("../../Util");
const SimpleValueObject_1 = require("./SimpleValueObject");
const ValueObject_1 = require("./ValueObject");
let UIntValue = class UIntValue extends SimpleValueObject_1.SimpleValueObject {
static c(value) {
if (typeof value === 'string') {
try {
value = Number.parseInt(value);
}
catch (e) {
return ValueObject_1.AbstractValueObject.invalidRaw(this, { raw: value });
}
const AbstractValueObject_1 = require("./AbstractValueObject");
class UIntValue extends AbstractValueObject_1.AbstractValueObject {
v;
static HOBJ_META = Util_1.HObjectTypeMeta.domain('Core', 'User', 'ValueObject', 'UInt', UIntValue);
constructor(v) {
super();
this.v = v;
}
static parse(plain) {
let parsed;
switch (typeof plain) {
case 'number':
parsed = Math.trunc(plain);
break;
case 'string':
parsed = parseInt(plain);
break;
default:
return Util_1.PlainParseHelper.HObjectParseErr(this, [new Util_1.InvalidTypePlainParseIssue('number', typeof plain)]);
}
const checkResult = this.checkRawValue(value);
return checkResult.isError() ? (0, Util_1.ERR)(checkResult.e) : (0, Util_1.OK)(new this(value));
if (parsed < 0) {
const issue = Util_1.TooSmallPlainParseIssue.numberGTE(0, parsed);
return Util_1.PlainParseHelper.HObjectParseErr(this, [issue]);
}
return (0, Util_1.OK)(new this(parsed));
}
static cs(value) {
if (typeof value === 'string') {
value = Number.parseInt(value);
static cs(v) {
if (typeof v === 'string') {
v = Number.parseInt(v);
}
return new this(value);
return new this(v);
}
static checkRawValue(value) {
return value >= 0 ? (0, Util_1.OK)(true) : ValueObject_1.AbstractValueObject.invalidRaw(this, { raw: value });
equals(other) {
return this.v === other.v;
}

@@ -34,8 +44,5 @@ toString() {

toJSON() {
return this.v;
return this.v.toString();
}
};
}
exports.UIntValue = UIntValue;
exports.UIntValue = UIntValue = tslib_1.__decorate([
(0, ValueObject_1.ValueObject)('Core')
], UIntValue);
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.UserId = void 0;
const tslib_1 = require("tslib");
const Util_1 = require("../../Util");
const StringValue_1 = require("./StringValue");
const ValueObject_1 = require("./ValueObject");
let UserId = class UserId extends StringValue_1.StringValue {
};
class UserId extends StringValue_1.StringValue {
static HOBJ_META = Util_1.HObjectTypeMeta.domain('Core', 'User', 'ValueObject', 'UserId', UserId);
}
exports.UserId = UserId;
exports.UserId = UserId = tslib_1.__decorate([
(0, ValueObject_1.ValueObject)('Account')
], UserId);

@@ -7,1 +7,2 @@ "use strict";

tslib_1.__exportStar(require("./Domain/index"), exports);
tslib_1.__exportStar(require("./Application/index"), exports);
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.Dto = exports.BigIntTransformer = exports.DtoTransformer = exports.ValueObjectTransformer = exports.isPT = exports.TT = exports.INVALID_PLAIN_OBJECT_ERROR_TYPE = void 0;
const class_transformer_1 = require("class-transformer");
const AppError_1 = require("./Error/AppError");
const Result_1 = require("./Result");
exports.INVALID_PLAIN_OBJECT_ERROR_TYPE = 'core.dto.invalid_plain_object';
exports.TT = class_transformer_1.TransformationType;
const isPT = (type) => type === class_transformer_1.TransformationType.CLASS_TO_PLAIN;
exports.isPT = isPT;
function ValueObjectTransformer(t) {
return (0, class_transformer_1.Transform)(({ value, type }) => {
if (value) {
if ((0, exports.isPT)(type)) {
return Array.isArray(value) ? value.map((v) => v.toJSON()) : value.toJSON();
}
else {
return Array.isArray(value) ? value.map((v) => t.c(v)) : t.c(value);
}
}
return undefined;
});
}
exports.ValueObjectTransformer = ValueObjectTransformer;
function DtoTransformer(t) {
return (0, class_transformer_1.Transform)(({ value, type }) => {
if (value) {
if ((0, exports.isPT)(type)) {
return Array.isArray(value) ? value.map((v) => v.toJSON()) : value.toJSON();
}
else {
return Array.isArray(value) ? value.map((v) => t.fromPlain(v)) : t.fromPlain(value);
}
}
return undefined;
});
}
exports.DtoTransformer = DtoTransformer;
function BigIntTransformer() {
return (0, class_transformer_1.Transform)(({ value, type }) => {
if (value) {
if ((0, exports.isPT)(type)) {
return Array.isArray(value) ? value.map((v) => v.toString()) : value.toString();
}
else {
return Array.isArray(value) ? value.map((v) => BigInt(v)) : BigInt(value);
}
}
return undefined;
});
}
exports.BigIntTransformer = BigIntTransformer;
exports.Dto = void 0;
const Error_1 = require("./Error");
class Dto {

@@ -59,36 +11,9 @@ static cs(props) {

}
static fromPlain(plain) {
try {
const i = (0, class_transformer_1.plainToInstance)(this, plain);
return this.processFromPlain(i);
}
catch (e) {
return (0, Result_1.ERR)((0, AppError_1.INTERNAL_ERROR)(e));
}
static parse(plain) {
throw new Error_1.LogicError('Not implemented or AOT generated');
}
static processFromPlain(i) {
const errors = [];
for (const p in i) {
const v = i[p];
if (v instanceof Result_1.Result) {
if (v.isError()) {
errors.push(v.e);
}
else {
i[p] = v.v;
}
}
}
if (errors.length > 0) {
return (0, Result_1.ERR)(exports.INVALID_PLAIN_OBJECT_ERROR_TYPE, 400, {
className: this.name,
errors,
});
}
return (0, Result_1.OK)(i);
}
toJSON() {
return (0, class_transformer_1.instanceToPlain)(this);
throw new Error_1.LogicError('Not implemented or AOT generated');
}
}
exports.Dto = Dto;

@@ -18,4 +18,7 @@ "use strict";

exports.getClassMethods = getClassMethods;
function pascalCaseToSnakeCase(s) {
return s.replace(/(?:^|\.?)([A-Z])/g, (_x, y) => '_' + y.toLowerCase()).replace(/^_/, '');
function pascalCaseToSnakeCase(input) {
return input
.replace(/([a-z0-9])([A-Z])/g, '$1_$2')
.replace(/([A-Z])([A-Z][a-z])/g, '$1_$2')
.toLowerCase();
}

@@ -22,0 +25,0 @@ exports.pascalCaseToSnakeCase = pascalCaseToSnakeCase;

@@ -7,2 +7,5 @@ "use strict";

tslib_1.__exportStar(require("./Result"), exports);
tslib_1.__exportStar(require("./Plain"), exports);
tslib_1.__exportStar(require("./Feature"), exports);
tslib_1.__exportStar(require("./Event/HEvent"), exports);
tslib_1.__exportStar(require("./CurrentTime"), exports);

@@ -9,0 +12,0 @@ tslib_1.__exportStar(require("./RetryHelper"), exports);

@@ -14,2 +14,14 @@ "use strict";

}
if (v === true) {
return TRUE_RESULT;
}
if (v === undefined) {
return UNDEFINED_RESULT;
}
if (v === false) {
return FALSE_RESULT;
}
if (v === null) {
return NULL_RESULT;
}
return new Result(v);

@@ -93,2 +105,6 @@ }

exports.Result = Result;
const NULL_RESULT = new Result(null);
const UNDEFINED_RESULT = new Result(undefined);
const TRUE_RESULT = new Result(true);
const FALSE_RESULT = new Result(false);
const OK = (v) => {

@@ -98,2 +114,14 @@ if (v instanceof Result) {

}
if (v === true) {
return TRUE_RESULT;
}
if (v === undefined) {
return UNDEFINED_RESULT;
}
if (v === false) {
return FALSE_RESULT;
}
if (v === null) {
return NULL_RESULT;
}
return new Result(v);

@@ -100,0 +128,0 @@ };

export * from './ApplicationErrors.js';
export * from './HCommand.js';
export * from './HQuery.js';

@@ -1,9 +0,5 @@

import { __decorate } from "tslib";
import { HObjectTypeMeta } from '../../Util/index.js';
import { StringValue } from './StringValue.js';
import { ValueObject } from './ValueObject.js';
let AccountId = class AccountId extends StringValue {
};
AccountId = __decorate([
ValueObject('Account')
], AccountId);
export { AccountId };
export class AccountId extends StringValue {
static HOBJ_META = HObjectTypeMeta.domain('Core', 'Account', 'ValueObject', 'AccountId', AccountId);
}

@@ -1,6 +0,5 @@

var DateTime_1;
import { __decorate, __metadata } from "tslib";
import { AbstractValueObject, ValueObject } from './ValueObject.js';
import { AbstractValueObject } from './AbstractValueObject.js';
import { OK } from '../../Util/Result/index.js';
import { DateTimeFormatter, Instant, LocalDateTime, ZoneId, ZoneOffset, convert } from '@js-joda/core';
import { HObjectTypeMeta, InvalidStringPlainParseIssue, InvalidTypePlainParseIssue, PlainParseHelper, TooSmallPlainParseIssue } from '../../Util/index.js';
export const DEFAULT_DATE_TIME_FORMAT = DateTimeFormatter.ofPattern("yyyy-MM-dd'T'HH:mm:ss");

@@ -25,4 +24,5 @@ function createJsJodaFromString(v) {

}
let DateTime = DateTime_1 = class DateTime extends AbstractValueObject {
export class DateTime extends AbstractValueObject {
value;
static HOBJ_META = HObjectTypeMeta.domain('Core', 'Core', 'ValueObject', 'DateTime', DateTime);
constructor(value) {

@@ -38,23 +38,21 @@ super();

}
static c(v) {
switch (typeof v) {
case 'number': return this.fromTimestamp(v);
static parse(plain) {
switch (typeof plain) {
case 'number': return DateTime.fromTimestamp(plain);
case 'string':
try {
return OK(new this(createJsJodaFromString(v)));
return OK(new this(createJsJodaFromString(plain)));
}
catch (e) {
return AbstractValueObject.invalidRaw(DateTime_1, {
raw: v,
msg: 'invalid format: ' + e.message,
});
return PlainParseHelper.HObjectParseErr(DateTime, [
new InvalidStringPlainParseIssue('datetime', {}, 'Given plain string is not valid datetime')
]);
}
}
if (v instanceof Date) {
return OK(new this(createJsJodaFromDate(v)));
if (plain instanceof Date) {
return OK(new this(createJsJodaFromDate(plain)));
}
return AbstractValueObject.invalidRaw(DateTime_1, {
raw: v,
msg: 'unsupported datetime raw type',
});
return PlainParseHelper.HObjectParseErr(DateTime, [
new InvalidTypePlainParseIssue(["number", "string", "Date"], typeof plain)
]);
}

@@ -72,8 +70,7 @@ static cs(v) {

if (timestamp < 0) {
return AbstractValueObject.invalidRaw(DateTime_1, {
raw: timestamp,
msg: 'invalid timestamp',
});
return PlainParseHelper.HObjectParseErr(DateTime, [
TooSmallPlainParseIssue.numberGTE(0, timestamp)
]);
}
return OK(new this(createJsJodaFromTimestamp(timestamp)));
return OK(new DateTime(createJsJodaFromTimestamp(timestamp)));
}

@@ -87,6 +84,6 @@ get v() {

plus(amount) {
return new DateTime_1(this.value.plus(amount));
return new DateTime(this.value.plus(amount));
}
minus(amount) {
return new DateTime_1(this.value.minus(amount));
return new DateTime(this.value.minus(amount));
}

@@ -126,7 +123,2 @@ equals(o) {

}
};
DateTime = DateTime_1 = __decorate([
ValueObject('Core'),
__metadata("design:paramtypes", [LocalDateTime])
], DateTime);
export { DateTime };
}

@@ -1,7 +0,7 @@

import { __decorate } from "tslib";
import { ValueObject } from './ValueObject.js';
import { HObjectTypeMeta } from '../../Util/index.js';
import { EmailHash } from './EmailHash.js';
import { RegexStringValue } from './RegexStringValue.js';
const EMAIL_REGEX = /^(([^<>()[\]\\.,;:\s@"]+(\.[^<>()[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/i;
let Email = class Email extends RegexStringValue {
export class Email extends RegexStringValue {
static HOBJ_META = HObjectTypeMeta.domain('Core', 'Core', 'ValueObject', 'Email', Email);
static getRegex() {

@@ -19,6 +19,2 @@ return EMAIL_REGEX;

}
};
Email = __decorate([
ValueObject('Core')
], Email);
export { Email };
}

@@ -1,14 +0,9 @@

var EmailHash_1;
import { __decorate } from "tslib";
import { StringValue } from './StringValue.js';
import * as crypto from 'crypto';
import { ValueObject } from './ValueObject.js';
let EmailHash = EmailHash_1 = class EmailHash extends StringValue {
import { hash } from 'node:crypto';
import { HObjectTypeMeta } from '../../Util/index.js';
export class EmailHash extends StringValue {
static HOBJ_META = HObjectTypeMeta.domain('Core', 'Core', 'ValueObject', 'EmailHash', EmailHash);
static createFromEmail(email) {
return new EmailHash_1(crypto.createHash('sha1').update(email.v).digest('hex'));
return new EmailHash(hash('sha1', email.v, "hex"));
}
};
EmailHash = EmailHash_1 = __decorate([
ValueObject('Core')
], EmailHash);
export { EmailHash };
}

@@ -1,3 +0,2 @@

export * from './ValueObject.js';
export * from './SimpleValueObject.js';
export * from './AbstractValueObject.js';
export * from './AccountId.js';

@@ -4,0 +3,0 @@ export * from './UserId.js';

@@ -1,15 +0,10 @@

var RefId_1;
import { __decorate } from "tslib";
import { StringValue } from './StringValue.js';
import { ValueObject } from './ValueObject.js';
import { customAlphabet } from 'nanoid';
import { HObjectTypeMeta } from '../../Util/index.js';
const RefIdGenerator = customAlphabet('0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz-', 21);
let RefId = RefId_1 = class RefId extends StringValue {
export class RefId extends StringValue {
static HOBJ_META = HObjectTypeMeta.domain('Core', 'Core', 'ValueObject', 'RefId', RefId);
static gen() {
return new RefId_1(RefIdGenerator());
return new RefId(RefIdGenerator());
}
};
RefId = RefId_1 = __decorate([
ValueObject('Core')
], RefId);
export { RefId };
}

@@ -1,8 +0,31 @@

import { OK } from '../../Util/Result/index.js';
import { AbstractValueObject } from './ValueObject.js';
import { StringValue } from './StringValue.js';
export class RegexStringValue extends StringValue {
static checkRawValue(value) {
return this.getRegex().test(value) ? OK(true) : AbstractValueObject.invalidRaw(this, { raw: value });
import { LogicError, OK, PlainParseHelper, PlainParseIssue } from '../../Util/index.js';
import { AbstractValueObject } from './AbstractValueObject.js';
export class RegexStringValue extends AbstractValueObject {
v;
constructor(v) {
super();
this.v = v;
}
static parse(plain) {
const parsed = PlainParseHelper.parseStringRegex(plain, this.getRegex());
if (parsed instanceof PlainParseIssue) {
return PlainParseHelper.HObjectParseErr(this, [parsed]);
}
return OK(new this(parsed));
}
static getRegex() {
throw new LogicError("Must be implemented in value object class");
}
static cs(v) {
return new this(v);
}
equals(other) {
return this.v === other.v;
}
toString() {
return this.v;
}
toJSON() {
return this.v;
}
}

@@ -1,3 +0,29 @@

import { SimpleValueObject } from './SimpleValueObject.js';
export class StringValue extends SimpleValueObject {
import { HObjectTypeMeta, OK, PlainParseHelper, PlainParseIssue } from '../../Util/index.js';
import { AbstractValueObject } from './AbstractValueObject.js';
export class StringValue extends AbstractValueObject {
v;
static HOBJ_META = HObjectTypeMeta.domain('Core', 'Core', 'ValueObject', 'String', StringValue);
constructor(v) {
super();
this.v = v;
}
static parse(plain) {
const parsed = PlainParseHelper.parseString(plain);
if (parsed instanceof PlainParseIssue) {
return PlainParseHelper.HObjectParseErr(this, [parsed]);
}
return OK(new this(parsed));
}
static cs(v) {
return new this(v);
}
equals(other) {
return this.v === other.v;
}
toString() {
return this.v;
}
toJSON() {
return this.v;
}
}

@@ -1,24 +0,22 @@

import { __decorate } from "tslib";
import { ERR, OK } from '../../Util/index.js';
import { SimpleValueObject } from './SimpleValueObject.js';
import { AbstractValueObject, ValueObject } from './ValueObject.js';
let UBigIntValue = class UBigIntValue extends SimpleValueObject {
static c(value) {
if (typeof value === 'string') {
try {
value = BigInt(value);
}
catch (e) {
return AbstractValueObject.invalidRaw(this, { raw: value });
}
import { HObjectTypeMeta, OK, PlainParseHelper, PlainParseIssue } from '../../Util/index.js';
import { AbstractValueObject } from './AbstractValueObject.js';
export class UBigIntValue extends AbstractValueObject {
v;
static HOBJ_META = HObjectTypeMeta.domain('Core', 'Core', 'ValueObject', 'UBigInt', UBigIntValue);
constructor(v) {
super();
this.v = v;
}
static parse(plain) {
const parsed = PlainParseHelper.parseBigInt64GTE(plain, 0n);
if (parsed instanceof PlainParseIssue) {
return PlainParseHelper.HObjectParseErr(this, [parsed]);
}
const checkResult = this.checkRawValue(value);
return checkResult.isError() ? ERR(checkResult.e) : OK(new this(value));
return OK(new this(parsed));
}
static cs(value) {
value = BigInt(value.toString());
return new this(value);
static cs(v) {
return new this(BigInt(v));
}
static checkRawValue(value) {
return value >= 0n ? OK(true) : AbstractValueObject.invalidRaw(this, { raw: value });
equals(other) {
return this.v === other.v;
}

@@ -31,6 +29,2 @@ toString() {

}
};
UBigIntValue = __decorate([
ValueObject('Core')
], UBigIntValue);
export { UBigIntValue };
}

@@ -1,26 +0,36 @@

import { __decorate } from "tslib";
import { ERR, OK } from '../../Util/index.js';
import { SimpleValueObject } from './SimpleValueObject.js';
import { AbstractValueObject, ValueObject } from './ValueObject.js';
let UIntValue = class UIntValue extends SimpleValueObject {
static c(value) {
if (typeof value === 'string') {
try {
value = Number.parseInt(value);
}
catch (e) {
return AbstractValueObject.invalidRaw(this, { raw: value });
}
import { HObjectTypeMeta, InvalidTypePlainParseIssue, OK, PlainParseHelper, TooSmallPlainParseIssue } from '../../Util/index.js';
import { AbstractValueObject } from './AbstractValueObject.js';
export class UIntValue extends AbstractValueObject {
v;
static HOBJ_META = HObjectTypeMeta.domain('Core', 'User', 'ValueObject', 'UInt', UIntValue);
constructor(v) {
super();
this.v = v;
}
static parse(plain) {
let parsed;
switch (typeof plain) {
case 'number':
parsed = Math.trunc(plain);
break;
case 'string':
parsed = parseInt(plain);
break;
default:
return PlainParseHelper.HObjectParseErr(this, [new InvalidTypePlainParseIssue('number', typeof plain)]);
}
const checkResult = this.checkRawValue(value);
return checkResult.isError() ? ERR(checkResult.e) : OK(new this(value));
if (parsed < 0) {
const issue = TooSmallPlainParseIssue.numberGTE(0, parsed);
return PlainParseHelper.HObjectParseErr(this, [issue]);
}
return OK(new this(parsed));
}
static cs(value) {
if (typeof value === 'string') {
value = Number.parseInt(value);
static cs(v) {
if (typeof v === 'string') {
v = Number.parseInt(v);
}
return new this(value);
return new this(v);
}
static checkRawValue(value) {
return value >= 0 ? OK(true) : AbstractValueObject.invalidRaw(this, { raw: value });
equals(other) {
return this.v === other.v;
}

@@ -31,8 +41,4 @@ toString() {

toJSON() {
return this.v;
return this.v.toString();
}
};
UIntValue = __decorate([
ValueObject('Core')
], UIntValue);
export { UIntValue };
}

@@ -1,9 +0,5 @@

import { __decorate } from "tslib";
import { HObjectTypeMeta } from '../../Util/index.js';
import { StringValue } from './StringValue.js';
import { ValueObject } from './ValueObject.js';
let UserId = class UserId extends StringValue {
};
UserId = __decorate([
ValueObject('Account')
], UserId);
export { UserId };
export class UserId extends StringValue {
static HOBJ_META = HObjectTypeMeta.domain('Core', 'User', 'ValueObject', 'UserId', UserId);
}
export * from './Util/index.js';
export * from './Log/index.js';
export * from './Domain/index.js';
export * from './Application/index.js';

@@ -1,46 +0,2 @@

import { instanceToPlain, plainToInstance, Transform, TransformationType } from 'class-transformer';
import { INTERNAL_ERROR } from './Error/AppError.js';
import { ERR, OK, Result } from './Result/index.js';
export const INVALID_PLAIN_OBJECT_ERROR_TYPE = 'core.dto.invalid_plain_object';
export const TT = TransformationType;
export const isPT = (type) => type === TransformationType.CLASS_TO_PLAIN;
export function ValueObjectTransformer(t) {
return Transform(({ value, type }) => {
if (value) {
if (isPT(type)) {
return Array.isArray(value) ? value.map((v) => v.toJSON()) : value.toJSON();
}
else {
return Array.isArray(value) ? value.map((v) => t.c(v)) : t.c(value);
}
}
return undefined;
});
}
export function DtoTransformer(t) {
return Transform(({ value, type }) => {
if (value) {
if (isPT(type)) {
return Array.isArray(value) ? value.map((v) => v.toJSON()) : value.toJSON();
}
else {
return Array.isArray(value) ? value.map((v) => t.fromPlain(v)) : t.fromPlain(value);
}
}
return undefined;
});
}
export function BigIntTransformer() {
return Transform(({ value, type }) => {
if (value) {
if (isPT(type)) {
return Array.isArray(value) ? value.map((v) => v.toString()) : value.toString();
}
else {
return Array.isArray(value) ? value.map((v) => BigInt(v)) : BigInt(value);
}
}
return undefined;
});
}
import { LogicError } from './Error/index.js';
export class Dto {

@@ -52,35 +8,8 @@ static cs(props) {

}
static fromPlain(plain) {
try {
const i = plainToInstance(this, plain);
return this.processFromPlain(i);
}
catch (e) {
return ERR(INTERNAL_ERROR(e));
}
static parse(plain) {
throw new LogicError('Not implemented or AOT generated');
}
static processFromPlain(i) {
const errors = [];
for (const p in i) {
const v = i[p];
if (v instanceof Result) {
if (v.isError()) {
errors.push(v.e);
}
else {
i[p] = v.v;
}
}
}
if (errors.length > 0) {
return ERR(INVALID_PLAIN_OBJECT_ERROR_TYPE, 400, {
className: this.name,
errors,
});
}
return OK(i);
}
toJSON() {
return instanceToPlain(this);
throw new LogicError('Not implemented or AOT generated');
}
}

@@ -13,4 +13,7 @@ import { MissingError } from './Error/index.js';

}
export function pascalCaseToSnakeCase(s) {
return s.replace(/(?:^|\.?)([A-Z])/g, (_x, y) => '_' + y.toLowerCase()).replace(/^_/, '');
export function pascalCaseToSnakeCase(input) {
return input
.replace(/([a-z0-9])([A-Z])/g, '$1_$2')
.replace(/([A-Z])([A-Z][a-z])/g, '$1_$2')
.toLowerCase();
}

@@ -17,0 +20,0 @@ export function pascalCaseToCamelCase(s) {

export * from './AppMeta.js';
export * from './Error/index.js';
export * from './Result/index.js';
export * from './Plain/index.js';
export * from './Feature/index.js';
export * from './Event/HEvent.js';
export * from './CurrentTime.js';

@@ -5,0 +8,0 @@ export * from './RetryHelper.js';

@@ -11,2 +11,14 @@ import { LogicError } from '../Error/index.js';

}
if (v === true) {
return TRUE_RESULT;
}
if (v === undefined) {
return UNDEFINED_RESULT;
}
if (v === false) {
return FALSE_RESULT;
}
if (v === null) {
return NULL_RESULT;
}
return new Result(v);

@@ -88,2 +100,6 @@ }

}
const NULL_RESULT = new Result(null);
const UNDEFINED_RESULT = new Result(undefined);
const TRUE_RESULT = new Result(true);
const FALSE_RESULT = new Result(false);
export const OK = (v) => {

@@ -93,2 +109,14 @@ if (v instanceof Result) {

}
if (v === true) {
return TRUE_RESULT;
}
if (v === undefined) {
return UNDEFINED_RESULT;
}
if (v === false) {
return FALSE_RESULT;
}
if (v === null) {
return NULL_RESULT;
}
return new Result(v);

@@ -95,0 +123,0 @@ };

export * from './ApplicationErrors';
export * from './HCommand';
export * from './HQuery';

@@ -0,3 +1,5 @@

import { HObjectTypeMeta } from "../../Util";
import { StringValue } from "./StringValue";
export declare class AccountId extends StringValue<AccountId> {
static readonly HOBJ_META: HObjectTypeMeta;
}

@@ -1,4 +0,5 @@

import { AbstractValueObject } from './ValueObject';
import { AbstractValueObject, type ValueObjectType } from './AbstractValueObject';
import { R } from '../../Util/Result';
import { DateTimeFormatter, Duration, LocalDateTime, Period } from '@js-joda/core';
import { HObjectTypeMeta, type PlainParseError } from "../../Util";
export type DateTimeRawType = number;

@@ -8,8 +9,9 @@ export declare const DEFAULT_DATE_TIME_FORMAT: DateTimeFormatter;

private readonly value;
static readonly HOBJ_META: HObjectTypeMeta;
constructor(value: LocalDateTime);
static now(): DateTime;
static nowWithNano(): DateTime;
static c(v: Date | number | string): R<DateTime>;
static parse<T extends DateTime>(this: ValueObjectType<T>, plain: unknown): R<T, PlainParseError>;
static cs(v: Date | number | string): DateTime;
static fromTimestamp(timestamp: number): R<DateTime>;
static fromTimestamp(timestamp: number): R<DateTime, PlainParseError>;
get v(): LocalDateTime;

@@ -29,3 +31,3 @@ get t(): number;

toString(): string;
toJSON(): any;
toJSON(): number;
}

@@ -0,6 +1,7 @@

import { HObjectTypeMeta } from "../../Util";
import { EmailHash } from './EmailHash';
import { RegexStringIdRawType, RegexStringValue } from './RegexStringValue';
export type EmailRawType = RegexStringIdRawType;
import { RegexStringValue } from './RegexStringValue';
export declare class Email extends RegexStringValue<Email> {
protected static getRegex(): RegExp;
static readonly HOBJ_META: HObjectTypeMeta;
static getRegex(): RegExp;
get local(): string;

@@ -7,0 +8,0 @@ get domain(): string;

import { StringValue } from './StringValue';
import { Email } from './Email';
import { RegexStringIdRawType } from './RegexStringValue';
export type EmailHashRawType = RegexStringIdRawType;
import { HObjectTypeMeta } from "../../Util";
export declare class EmailHash extends StringValue<EmailHash> {
static readonly HOBJ_META: HObjectTypeMeta;
static createFromEmail(email: Email): EmailHash;
}

@@ -1,3 +0,2 @@

export * from './ValueObject';
export * from './SimpleValueObject';
export * from './AbstractValueObject';
export * from './AccountId';

@@ -4,0 +3,0 @@ export * from './UserId';

import { StringValue } from "./StringValue";
import { HObjectTypeMeta } from "../../Util";
export declare class RefId extends StringValue<RefId> {
static readonly HOBJ_META: HObjectTypeMeta;
static gen(): RefId;
}

@@ -1,10 +0,16 @@

import { Result } from '../../Util/Result';
import { StringValue } from './StringValue';
export type RegexStringIdRawType = string;
import { type PlainParseError, type R } from '../../Util';
import { AbstractValueObject, type ValueObjectType } from "./AbstractValueObject";
export type RegexStringSubtype<T> = {
new (value: string): T;
getRegex(): RegExp;
};
export declare abstract class RegexStringValue<T extends RegexStringValue<any>> extends StringValue<T> {
static checkRawValue<T>(this: RegexStringSubtype<T>, value: string): Result<boolean>;
} & ValueObjectType;
export declare abstract class RegexStringValue<T extends RegexStringValue<any>> extends AbstractValueObject<T> {
readonly v: string;
constructor(v: string);
static parse<T extends RegexStringValue<any>>(this: RegexStringSubtype<T>, plain: unknown): R<T, PlainParseError>;
static getRegex(): RegExp;
static cs<T extends RegexStringValue<any>>(this: RegexStringSubtype<T>, v: string): T;
equals(other: T): boolean;
toString(): string;
toJSON(): string;
}

@@ -1,4 +0,12 @@

import { SimpleValueObject, SimpleValueObjectConstructor } from './SimpleValueObject';
export type StringValueConstructor<T extends StringValue<any> = StringValue<any>> = SimpleValueObjectConstructor<T, string>;
export declare abstract class StringValue<T extends StringValue<any> = any> extends SimpleValueObject<T, string> {
import { HObjectTypeMeta, PlainParseError, type R } from "../../Util";
import { AbstractValueObject, type ValueObjectType } from "./AbstractValueObject";
export declare class StringValue<T extends StringValue<any> = any> extends AbstractValueObject<T> {
readonly v: string;
static readonly HOBJ_META: HObjectTypeMeta;
constructor(v: string);
static parse<T extends StringValue>(this: ValueObjectType<T>, plain: unknown): R<T, PlainParseError>;
static cs<T extends StringValue>(this: ValueObjectType<T>, v: string): T;
equals(other: T): boolean;
toString(): string;
toJSON(): string;
}

@@ -1,10 +0,12 @@

import { Result } from '../../Util';
import { SimpleValueObject, SimpleValueObjectConstructor } from './SimpleValueObject';
export type UBigIntValueConstructor<T> = SimpleValueObjectConstructor<T, bigint>;
export declare class UBigIntValue<T extends UBigIntValue<any> = any> extends SimpleValueObject<T, bigint> {
static c<T extends SimpleValueObject<T, bigint>>(this: UBigIntValueConstructor<T>, value: any): Result<T>;
static cs<T extends SimpleValueObject<T, bigint>>(this: UBigIntValueConstructor<T>, value: any): T;
static checkRawValue(value: any): Result<boolean>;
import { HObjectTypeMeta, type PlainParseError, type R } from '../../Util';
import { AbstractValueObject, type ValueObjectType } from './AbstractValueObject';
export declare class UBigIntValue<T extends UBigIntValue<any> = any> extends AbstractValueObject<T> {
readonly v: bigint;
static readonly HOBJ_META: HObjectTypeMeta;
constructor(v: bigint);
static parse<T extends UBigIntValue>(this: ValueObjectType<T>, plain: unknown): R<T, PlainParseError>;
static cs<T extends UBigIntValue>(this: ValueObjectType<T>, v: string | number | bigint): T;
equals(other: T): boolean;
toString(): string;
toJSON(): string;
}

@@ -1,10 +0,12 @@

import { Result } from '../../Util';
import { SimpleValueObject, SimpleValueObjectConstructor } from './SimpleValueObject';
export type UIntValueConstructor<T> = SimpleValueObjectConstructor<T, number>;
export declare class UIntValue<T extends UIntValue<any> = any> extends SimpleValueObject<T, number> {
static c<T extends SimpleValueObject<T, number>>(this: UIntValueConstructor<T>, value: any): Result<T>;
static cs<T extends SimpleValueObject<T, number>>(this: UIntValueConstructor<T>, value: any): T;
static checkRawValue(value: number): Result<boolean>;
import { HObjectTypeMeta, type PlainParseError, type R } from '../../Util';
import { AbstractValueObject, type ValueObjectType } from './AbstractValueObject';
export declare class UIntValue<T extends UIntValue<any> = any> extends AbstractValueObject<T> {
readonly v: number;
static readonly HOBJ_META: HObjectTypeMeta;
constructor(v: number);
static parse<T extends UIntValue>(this: ValueObjectType<T>, plain: unknown): R<T, PlainParseError>;
static cs<T extends UIntValue>(this: ValueObjectType<T>, v: string | number): T;
equals(other: T): boolean;
toString(): string;
toJSON(): number;
toJSON(): string;
}

@@ -0,3 +1,5 @@

import { HObjectTypeMeta } from "../../Util";
import { StringValue } from "./StringValue";
export declare class UserId extends StringValue<UserId> {
static readonly HOBJ_META: HObjectTypeMeta;
}
export * from './Util/index';
export * from './Log/index';
export * from './Domain/index';
export * from './Application/index';

@@ -1,23 +0,11 @@

import { AbstractValueObject } from '@/Domain';
import { TransformationType } from 'class-transformer';
import { Result } from './Result';
import { HObjectType, type PlainParsableHObjectType } from './Feature/HObjectTypeMeta';
import { JsonSerialize } from './Json/JsonSerialize';
export declare const INVALID_PLAIN_OBJECT_ERROR_TYPE = "core.dto.invalid_plain_object";
export declare const TT: typeof TransformationType;
export declare const isPT: (type: TransformationType) => boolean;
export declare function ValueObjectTransformer<T extends AbstractValueObject<any>>(t: {
c: (value: any) => Result<T>;
}): any;
export declare function DtoTransformer<T extends Dto>(t: {
new (): T;
}): any;
export declare function BigIntTransformer(): any;
export type DtoConstructor<T extends Dto> = {
new (props?: Partial<T>): T;
};
import type { PlainParseError } from './Plain';
import { type R } from './Result';
import type { NonMethodProperties } from './types';
export type DtoType<T extends Dto> = HObjectType<T>;
export declare abstract class Dto implements JsonSerialize {
static cs<T extends Dto>(this: DtoConstructor<T>, props: Partial<T>): T;
static fromPlain<T extends Dto>(this: DtoConstructor<T>, plain: any): Result<T>;
protected static processFromPlain<T extends Dto>(this: DtoConstructor<T>, i: any): Result<any>;
toJSON(): any;
static cs<T extends Dto>(this: DtoType<T>, props: NonMethodProperties<T>): T;
static parse<T extends object>(this: PlainParsableHObjectType<T>, plain: unknown): R<T, PlainParseError>;
toJSON(): Record<string, any>;
}
export declare function isIterable(obj: any): boolean;
export declare function getClassMethods(obj: Record<string, any>): Array<string>;
export declare function pascalCaseToSnakeCase(s: string): string;
export declare function pascalCaseToSnakeCase(input: string): string;
export declare function pascalCaseToCamelCase(s: string): string;

@@ -5,0 +5,0 @@ export declare function parseBoolean(value: string | undefined, defaultValue?: boolean): boolean;

export * from './AppMeta';
export * from './Error';
export * from './Result';
export * from './Plain';
export * from './Feature';
export * from './Event/HEvent';
export * from './CurrentTime';

@@ -5,0 +8,0 @@ export * from './RetryHelper';

@@ -0,1 +1,2 @@

import type { JsonSerialize } from "./Json/JsonSerialize";
export type DeepPartial<T> = Partial<{

@@ -29,1 +30,21 @@ [P in keyof T]: DeepPartial<T[P]>;

export type ExtractKeyof<U, K> = K extends keyof U ? K : never;
export type NO_EXCLUDE_TAG = TUNKNOWN;
export type NonMethodRequiredPropertyNames<T, ExcludeTag = NO_EXCLUDE_TAG> = Exclude<{
[K in keyof T]: T[K] extends Function ? never : (T[K] extends ExcludeTag ? never : (T[K] extends {} ? K : never));
}[keyof T], undefined>;
export type NonMethodOptionalPropertyNames<T, ExcludeTag = NO_EXCLUDE_TAG> = Exclude<{
[K in keyof T]: T[K] extends Function ? never : (T[K] extends ExcludeTag ? never : (T[K] extends {} ? never : K));
}[keyof T], undefined>;
export type NonMethodProperties<T, ExcludeTag = NO_EXCLUDE_TAG> = Pick<T, NonMethodRequiredPropertyNames<T, ExcludeTag>> & Pick<T, NonMethodOptionalPropertyNames<T, ExcludeTag>>;
export type ToJSONReturnType<T> = T extends JsonSerialize ? ReturnType<T['toJSON']> : never;
type PlainFieldType<T, ExcludeTag = NO_EXCLUDE_TAG> = T extends BigInt ? string : T extends Array<infer E> ? Array<PlainFieldType<E, ExcludeTag>> : T extends Map<infer K, infer V> ? [K, V][] : T extends Set<infer V> ? V[] : T extends JsonSerialize ? ToJSONReturnType<T> : T;
export type PlainObjectType<T extends object, ExcludeTag = NO_EXCLUDE_TAG> = {
[K in NonMethodRequiredPropertyNames<T, ExcludeTag>]: PlainFieldType<T[K]>;
} & {
[K in NonMethodOptionalPropertyNames<T, ExcludeTag>]+?: PlainFieldType<T[K]> | undefined;
};
export type JsonExcluded = {
__hctag?: 'json_excluded';
};
export type JsonObjectType<T extends object> = PlainObjectType<T, JsonExcluded>;
export {};
{
"name": "@hexancore/common",
"version": "0.15.0",
"version": "0.16.0",
"engines": {

@@ -5,0 +5,0 @@ "node": ">=22"

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc