@sphereon/ssi-sdk.data-store
Version:
1,320 lines (1,300 loc) • 414 kB
JavaScript
"use strict";
var __create = Object.create;
var __defProp = Object.defineProperty;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
var __getOwnPropNames = Object.getOwnPropertyNames;
var __getProtoOf = Object.getPrototypeOf;
var __hasOwnProp = Object.prototype.hasOwnProperty;
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
var __export = (target, all) => {
for (var name in all)
__defProp(target, name, { get: all[name], enumerable: true });
};
var __copyProps = (to, from, except, desc) => {
if (from && typeof from === "object" || typeof from === "function") {
for (let key of __getOwnPropNames(from))
if (!__hasOwnProp.call(to, key) && key !== except)
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
}
return to;
};
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
// If the importer is in node compatibility mode or this is not an ESM
// file that has been converted to a CommonJS file using a Babel-
// compatible transform (i.e. "__esModule" has not been set), then set
// "default" to the CommonJS "module.exports" for node compatibility.
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
mod
));
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
// src/index.ts
var index_exports = {};
__export(index_exports, {
AbstractContactStore: () => AbstractContactStore,
AbstractDigitalCredentialStore: () => AbstractDigitalCredentialStore,
AbstractEventLoggerStore: () => AbstractEventLoggerStore,
AbstractIssuanceBrandingStore: () => AbstractIssuanceBrandingStore,
AbstractPDStore: () => AbstractPDStore,
AuditEventEntity: () => AuditEventEntity,
BackgroundAttributesEntity: () => BackgroundAttributesEntity,
BaseConfigEntity: () => BaseConfigEntity,
BaseContactEntity: () => BaseContactEntity,
BaseLocaleBrandingEntity: () => BaseLocaleBrandingEntity,
ConnectionEntity: () => ConnectionEntity,
ConnectionType: () => ConnectionType,
ContactMetadataItemEntity: () => ContactMetadataItemEntity,
ContactStore: () => ContactStore,
CorrelationIdentifierEntity: () => CorrelationIdentifierEntity,
CorrelationIdentifierType: () => CorrelationIdentifierType,
CredentialBrandingEntity: () => CredentialBrandingEntity,
CredentialClaimsEntity: () => CredentialClaimsEntity,
CredentialCorrelationType: () => CredentialCorrelationType,
CredentialDocumentFormat: () => CredentialDocumentFormat,
CredentialLocaleBrandingEntity: () => CredentialLocaleBrandingEntity,
CredentialRole: () => CredentialRole,
CredentialStateType: () => CredentialStateType,
DataStoreContactEntities: () => DataStoreContactEntities,
DataStoreContactMigrations: () => DataStoreContactMigrations,
DataStoreDigitalCredentialEntities: () => DataStoreDigitalCredentialEntities,
DataStoreDigitalCredentialMigrations: () => DataStoreDigitalCredentialMigrations,
DataStoreEntities: () => DataStoreEntities,
DataStoreEventLoggerEntities: () => DataStoreEventLoggerEntities,
DataStoreEventLoggerMigrations: () => DataStoreEventLoggerMigrations,
DataStoreIssuanceBrandingEntities: () => DataStoreIssuanceBrandingEntities,
DataStoreIssuanceBrandingMigrations: () => DataStoreIssuanceBrandingMigrations,
DataStoreMachineStateEntities: () => DataStoreMachineStateEntities,
DataStoreMachineStateMigrations: () => DataStoreMachineStateMigrations,
DataStoreMigrations: () => DataStoreMigrations,
DataStoreOid4vcStateEntities: () => DataStoreOid4vcStateEntities,
DataStorePresentationDefinitionEntities: () => DataStorePresentationDefinitionEntities,
DataStorePresentationDefinitionMigrations: () => DataStorePresentationDefinitionMigrations,
DataStoreStatusListEntities: () => DataStoreStatusListEntities,
DataStoreStatusListMigrations: () => DataStoreStatusListMigrations,
DidAuthConfigEntity: () => DidAuthConfigEntity,
DigitalCredentialEntity: () => DigitalCredentialEntity,
DigitalCredentialStore: () => DigitalCredentialStore,
DocumentType: () => DocumentType,
ElectronicAddressEntity: () => ElectronicAddressEntity,
EventLoggerStore: () => EventLoggerStore,
IAbstractMachineStateStore: () => IAbstractMachineStateStore,
IdentityEntity: () => IdentityEntity,
IdentityMetadataItemEntity: () => IdentityMetadataItemEntity,
IdentityOrigin: () => IdentityOrigin,
ImageAttributesEntity: () => ImageAttributesEntity,
ImageDimensionsEntity: () => ImageDimensionsEntity,
IssuanceBrandingStore: () => IssuanceBrandingStore,
IssuerBrandingEntity: () => IssuerBrandingEntity,
IssuerLocaleBrandingEntity: () => IssuerLocaleBrandingEntity,
MachineStateInfoEntity: () => MachineStateInfoEntity,
MachineStateStore: () => MachineStateStore,
OAuthStatusListEntity: () => OAuthStatusListEntity,
Oid4vcStateEntity: () => Oid4vcStateEntity,
OpenIdConfigEntity: () => OpenIdConfigEntity,
PDStore: () => PDStore,
PartyEntity: () => PartyEntity,
PartyOrigin: () => PartyOrigin,
PartyTypeType: () => PartyTypeType,
PhysicalAddressEntity: () => PhysicalAddressEntity,
PresentationDefinitionItemEntity: () => PresentationDefinitionItemEntity,
RegulationType: () => RegulationType,
StatusList2021Entity: () => StatusList2021Entity,
StatusListEntity: () => StatusListEntity,
StatusListEntryEntity: () => StatusListEntryEntity,
StatusListStore: () => StatusListStore,
TextAttributesEntity: () => TextAttributesEntity,
activityEventEntityFrom: () => activityEventEntityFrom,
activityEventFrom: () => activityEventFrom,
auditEventEntityFrom: () => auditEventEntityFrom,
auditEventFrom: () => auditEventFrom,
backgroundAttributesEntityFrom: () => backgroundAttributesEntityFrom,
configFrom: () => configFrom,
connectionEntityFrom: () => connectionEntityFrom,
connectionFrom: () => connectionFrom,
contactEntityFrom: () => contactEntityFrom,
contactFrom: () => contactFrom,
contactMetadataItemEntityFrom: () => contactMetadataItemEntityFrom,
correlationIdentifierEntityFrom: () => correlationIdentifierEntityFrom,
correlationIdentifierFrom: () => correlationIdentifierFrom,
credentialBrandingEntityFrom: () => credentialBrandingEntityFrom,
credentialBrandingFrom: () => credentialBrandingFrom,
credentialClaimsEntityFrom: () => credentialClaimsEntityFrom,
credentialLocaleBrandingEntityFrom: () => credentialLocaleBrandingEntityFrom,
didAuthConfigEntityFrom: () => didAuthConfigEntityFrom,
didAuthConfigFrom: () => didAuthConfigFrom,
digitalCredentialFrom: () => digitalCredentialFrom,
digitalCredentialsFrom: () => digitalCredentialsFrom,
electronicAddressEntityFrom: () => electronicAddressEntityFrom,
electronicAddressFrom: () => electronicAddressFrom,
ensureRawDocument: () => ensureRawDocument,
identityEntityFrom: () => identityEntityFrom,
identityFrom: () => identityFrom,
identityMetadataItemEntityFrom: () => identityMetadataItemEntityFrom,
imageAttributesEntityFrom: () => imageAttributesEntityFrom,
imageDimensionsEntityFrom: () => imageDimensionsEntityFrom,
isDidAuthConfig: () => isDidAuthConfig,
isHex: () => isHex,
isNaturalPerson: () => isNaturalPerson,
isOpenIdConfig: () => isOpenIdConfig,
isOrganization: () => isOrganization,
isPresentationDefinitionEqual: () => isPresentationDefinitionEqual,
issuerBrandingEntityFrom: () => issuerBrandingEntityFrom,
issuerBrandingFrom: () => issuerBrandingFrom,
issuerLocaleBrandingEntityFrom: () => issuerLocaleBrandingEntityFrom,
localeBrandingFrom: () => localeBrandingFrom,
metadataItemFrom: () => metadataItemFrom,
naturalPersonEntityFrom: () => naturalPersonEntityFrom,
naturalPersonFrom: () => naturalPersonFrom,
nonPersistedDigitalCredentialEntityFromAddArgs: () => nonPersistedDigitalCredentialEntityFromAddArgs,
openIdConfigEntityFrom: () => openIdConfigEntityFrom,
openIdConfigFrom: () => openIdConfigFrom,
organizationEntityFrom: () => organizationEntityFrom,
organizationFrom: () => organizationFrom,
parseRawDocument: () => parseRawDocument,
partyEntityFrom: () => partyEntityFrom,
partyFrom: () => partyFrom,
partyRelationshipEntityFrom: () => partyRelationshipEntityFrom,
partyRelationshipFrom: () => partyRelationshipFrom,
partyTypeEntityFrom: () => partyTypeEntityFrom,
partyTypeFrom: () => partyTypeFrom,
physicalAddressEntityFrom: () => physicalAddressEntityFrom,
physicalAddressFrom: () => physicalAddressFrom,
presentationDefinitionEntityItemFrom: () => presentationDefinitionEntityItemFrom,
presentationDefinitionItemFrom: () => presentationDefinitionItemFrom,
textAttributesEntityFrom: () => textAttributesEntityFrom
});
module.exports = __toCommonJS(index_exports);
// src/entities/contact/BaseConfigEntity.ts
var import_typeorm12 = __toESM(require("typeorm"), 1);
// src/entities/contact/ConnectionEntity.ts
var import_typeorm11 = __toESM(require("typeorm"), 1);
// src/types/contact/contact.ts
var ConnectionType = /* @__PURE__ */ function(ConnectionType2) {
ConnectionType2["OPENID_CONNECT"] = "OIDC";
ConnectionType2["SIOPv2"] = "SIOPv2";
ConnectionType2["SIOPv2_OpenID4VP"] = "SIOPv2+OpenID4VP";
return ConnectionType2;
}({});
var CorrelationIdentifierType = /* @__PURE__ */ function(CorrelationIdentifierType2) {
CorrelationIdentifierType2["DID"] = "did";
CorrelationIdentifierType2["URL"] = "url";
return CorrelationIdentifierType2;
}({});
var PartyTypeType = /* @__PURE__ */ function(PartyTypeType2) {
PartyTypeType2["NATURAL_PERSON"] = "naturalPerson";
PartyTypeType2["ORGANIZATION"] = "organization";
return PartyTypeType2;
}({});
var PartyOrigin = /* @__PURE__ */ function(PartyOrigin2) {
PartyOrigin2["INTERNAL"] = "INTERNAL";
PartyOrigin2["EXTERNAL"] = "EXTERNAL";
return PartyOrigin2;
}({});
var IdentityOrigin = /* @__PURE__ */ function(IdentityOrigin2) {
IdentityOrigin2["INTERNAL"] = "INTERNAL";
IdentityOrigin2["EXTERNAL"] = "EXTERNAL";
return IdentityOrigin2;
}({});
// src/types/digitalCredential/enums.ts
var DocumentType = /* @__PURE__ */ function(DocumentType2) {
DocumentType2["VC"] = "VC";
DocumentType2["VP"] = "VP";
DocumentType2["P"] = "P";
DocumentType2["C"] = "C";
return DocumentType2;
}({});
var RegulationType = /* @__PURE__ */ function(RegulationType2) {
RegulationType2["PID"] = "PID";
RegulationType2["QEAA"] = "QEAA";
RegulationType2["EAA"] = "EAA";
RegulationType2["NON_REGULATED"] = "NON_REGULATED";
return RegulationType2;
}({});
var CredentialDocumentFormat = /* @__PURE__ */ function(CredentialDocumentFormat2) {
CredentialDocumentFormat2["JSON_LD"] = "JSON_LD";
CredentialDocumentFormat2["JWT"] = "JWT";
CredentialDocumentFormat2["SD_JWT"] = "SD_JWT";
CredentialDocumentFormat2["MSO_MDOC"] = "MSO_MDOC";
return CredentialDocumentFormat2;
}({});
(function(CredentialDocumentFormat2) {
function fromSpecValue(credentialFormat) {
const format = credentialFormat.toLowerCase();
if (format.includes("sd")) {
return "SD_JWT";
} else if (format.includes("ldp")) {
return "JSON_LD";
} else if (format.includes("mso") || credentialFormat.includes("mdoc")) {
return "MSO_MDOC";
} else if (format.includes("jwt_")) {
return "JWT";
} else {
throw Error(`Could not map format ${format} to known format`);
}
}
__name(fromSpecValue, "fromSpecValue");
CredentialDocumentFormat2.fromSpecValue = fromSpecValue;
function toSpecValue(documentFormat, documentType) {
switch (documentFormat) {
case "SD_JWT":
return "vc+sd-jwt";
case "MSO_MDOC":
return "mso_mdoc";
case "JSON_LD":
return documentType === "C" || documentType === "VC" ? "ldp_vc" : "ldp_vp";
case "JWT":
return documentType === "C" || documentType === "VC" ? "jwt_vc_json" : "jwt_vp_json";
}
}
__name(toSpecValue, "toSpecValue");
CredentialDocumentFormat2.toSpecValue = toSpecValue;
})(CredentialDocumentFormat || (CredentialDocumentFormat = {}));
var CredentialCorrelationType = /* @__PURE__ */ function(CredentialCorrelationType2) {
CredentialCorrelationType2["DID"] = "DID";
CredentialCorrelationType2["X509_SAN"] = "X509_SAN";
CredentialCorrelationType2["KID"] = "KID";
CredentialCorrelationType2["URL"] = "URL";
return CredentialCorrelationType2;
}({});
var CredentialRole = /* @__PURE__ */ function(CredentialRole2) {
CredentialRole2["ISSUER"] = "ISSUER";
CredentialRole2["VERIFIER"] = "VERIFIER";
CredentialRole2["HOLDER"] = "HOLDER";
CredentialRole2["FEDERATION_TRUST_ANCHOR"] = "FEDERATION_TRUST_ANCHOR";
return CredentialRole2;
}({});
var CredentialStateType = /* @__PURE__ */ function(CredentialStateType2) {
CredentialStateType2["REVOKED"] = "REVOKED";
CredentialStateType2["VERIFIED"] = "VERIFIED";
CredentialStateType2["EXPIRED"] = "EXPIRED";
return CredentialStateType2;
}({});
// src/entities/contact/IdentityEntity.ts
var import_typeorm10 = require("typeorm");
var import_class_validator9 = require("class-validator");
var import_ssi_sdk9 = require("@sphereon/ssi-sdk.agent-config");
// src/entities/contact/CorrelationIdentifierEntity.ts
var import_typeorm = __toESM(require("typeorm"), 1);
var import_class_validator = require("class-validator");
// src/utils/ValidatorUtils.ts
var getConstraint = /* @__PURE__ */ __name((validation) => {
if (validation.children && validation.children.length > 0) {
return getConstraint(validation.children[0]);
} else {
return validation.constraints;
}
}, "getConstraint");
// src/entities/contact/CorrelationIdentifierEntity.ts
function _ts_decorate(decorators, target, key, desc) {
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
return c > 3 && r && Object.defineProperty(target, key, r), r;
}
__name(_ts_decorate, "_ts_decorate");
function _ts_metadata(k, v) {
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
}
__name(_ts_metadata, "_ts_metadata");
var { Entity, Column, PrimaryGeneratedColumn, BaseEntity, OneToOne, JoinColumn, BeforeInsert, BeforeUpdate } = import_typeorm.default;
var CorrelationIdentifierEntity = class extends BaseEntity {
static {
__name(this, "CorrelationIdentifierEntity");
}
id;
type;
correlationId;
ownerId;
tenantId;
identity;
async validate() {
const validation = await (0, import_class_validator.validate)(this);
if (validation.length > 0) {
const constraint = getConstraint(validation[0]);
if (constraint) {
const message = Object.values(constraint)[0];
return Promise.reject(Error(message));
}
}
}
};
_ts_decorate([
PrimaryGeneratedColumn("uuid"),
_ts_metadata("design:type", String)
], CorrelationIdentifierEntity.prototype, "id", void 0);
_ts_decorate([
Column("simple-enum", {
name: "type",
enum: CorrelationIdentifierType,
nullable: false
}),
_ts_metadata("design:type", typeof CorrelationIdentifierType === "undefined" ? Object : CorrelationIdentifierType)
], CorrelationIdentifierEntity.prototype, "type", void 0);
_ts_decorate([
Column("text", {
name: "correlation_id",
nullable: false,
unique: true
}),
(0, import_class_validator.IsNotEmpty)({
message: "Blank correlation ids are not allowed"
}),
_ts_metadata("design:type", String)
], CorrelationIdentifierEntity.prototype, "correlationId", void 0);
_ts_decorate([
Column("text", {
name: "owner_id",
nullable: true
}),
_ts_metadata("design:type", String)
], CorrelationIdentifierEntity.prototype, "ownerId", void 0);
_ts_decorate([
Column("text", {
name: "tenant_id",
nullable: true
}),
_ts_metadata("design:type", String)
], CorrelationIdentifierEntity.prototype, "tenantId", void 0);
_ts_decorate([
OneToOne(() => IdentityEntity, (identity) => identity.identifier, {
onDelete: "CASCADE"
}),
JoinColumn({
name: "identity_id"
}),
_ts_metadata("design:type", typeof IdentityEntity === "undefined" ? Object : IdentityEntity)
], CorrelationIdentifierEntity.prototype, "identity", void 0);
_ts_decorate([
BeforeInsert(),
BeforeUpdate(),
_ts_metadata("design:type", Function),
_ts_metadata("design:paramtypes", []),
_ts_metadata("design:returntype", Promise)
], CorrelationIdentifierEntity.prototype, "validate", null);
CorrelationIdentifierEntity = _ts_decorate([
Entity("CorrelationIdentifier")
], CorrelationIdentifierEntity);
// src/entities/contact/IdentityMetadataItemEntity.ts
var import_ssi_sdk = require("@sphereon/ssi-sdk.agent-config");
var import_typeorm2 = require("typeorm");
var import_class_validator2 = require("class-validator");
function _ts_decorate2(decorators, target, key, desc) {
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
return c > 3 && r && Object.defineProperty(target, key, r), r;
}
__name(_ts_decorate2, "_ts_decorate");
function _ts_metadata2(k, v) {
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
}
__name(_ts_metadata2, "_ts_metadata");
var IdentityMetadataItemEntity = class extends import_typeorm2.BaseEntity {
static {
__name(this, "IdentityMetadataItemEntity");
}
id;
label;
valueType;
stringValue;
numberValue;
dateValue;
boolValue;
identity;
async validate() {
const validation = await (0, import_class_validator2.validate)(this);
if (validation.length > 0) {
const constraint = getConstraint(validation[0]);
if (constraint) {
const message = Object.values(constraint)[0];
return Promise.reject(Error(message));
}
}
}
};
_ts_decorate2([
(0, import_typeorm2.PrimaryGeneratedColumn)("uuid"),
_ts_metadata2("design:type", String)
], IdentityMetadataItemEntity.prototype, "id", void 0);
_ts_decorate2([
(0, import_typeorm2.Column)("varchar", {
name: "label",
length: 255,
nullable: false
}),
(0, import_class_validator2.IsNotEmpty)({
message: "Blank metadata labels are not allowed"
}),
_ts_metadata2("design:type", String)
], IdentityMetadataItemEntity.prototype, "label", void 0);
_ts_decorate2([
(0, import_typeorm2.Column)("varchar", {
name: "valueType",
nullable: false
}),
(0, import_class_validator2.IsNotEmpty)({
message: "valueType must not be empty"
}),
_ts_metadata2("design:type", String)
], IdentityMetadataItemEntity.prototype, "valueType", void 0);
_ts_decorate2([
(0, import_typeorm2.Column)("varchar", {
name: "stringValue",
length: 255,
nullable: true
}),
_ts_metadata2("design:type", String)
], IdentityMetadataItemEntity.prototype, "stringValue", void 0);
_ts_decorate2([
(0, import_typeorm2.Column)("numeric", {
name: "numberValue",
nullable: true
}),
_ts_metadata2("design:type", Number)
], IdentityMetadataItemEntity.prototype, "numberValue", void 0);
_ts_decorate2([
(0, import_typeorm2.Column)({
name: "dateValue",
nullable: true,
type: (0, import_ssi_sdk.typeOrmDateTime)()
}),
_ts_metadata2("design:type", typeof Date === "undefined" ? Object : Date)
], IdentityMetadataItemEntity.prototype, "dateValue", void 0);
_ts_decorate2([
(0, import_typeorm2.Column)("boolean", {
name: "boolValue",
nullable: true
}),
_ts_metadata2("design:type", Boolean)
], IdentityMetadataItemEntity.prototype, "boolValue", void 0);
_ts_decorate2([
(0, import_typeorm2.ManyToOne)(() => IdentityEntity, (identity) => identity.metadata, {
cascade: [
"insert",
"update"
],
onDelete: "CASCADE"
}),
_ts_metadata2("design:type", typeof IdentityEntity === "undefined" ? Object : IdentityEntity)
], IdentityMetadataItemEntity.prototype, "identity", void 0);
_ts_decorate2([
(0, import_typeorm2.BeforeInsert)(),
(0, import_typeorm2.BeforeUpdate)(),
_ts_metadata2("design:type", Function),
_ts_metadata2("design:paramtypes", []),
_ts_metadata2("design:returntype", Promise)
], IdentityMetadataItemEntity.prototype, "validate", null);
IdentityMetadataItemEntity = _ts_decorate2([
(0, import_typeorm2.Entity)("IdentityMetadata")
], IdentityMetadataItemEntity);
// src/entities/contact/PartyEntity.ts
var import_typeorm9 = require("typeorm");
var import_ssi_sdk8 = require("@sphereon/ssi-sdk.agent-config");
var import_class_validator8 = require("class-validator");
// src/entities/contact/PartyTypeEntity.ts
var import_typeorm3 = require("typeorm");
var import_ssi_sdk2 = require("@sphereon/ssi-sdk.agent-config");
var import_class_validator4 = require("class-validator");
// src/entities/validators/index.ts
var import_class_validator3 = require("class-validator");
function _ts_decorate3(decorators, target, key, desc) {
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
return c > 3 && r && Object.defineProperty(target, key, r), r;
}
__name(_ts_decorate3, "_ts_decorate");
var IsNonEmptyStringConstraint = class {
static {
__name(this, "IsNonEmptyStringConstraint");
}
validate(value, args) {
return !isEmptyString(value);
}
defaultMessage(args) {
return `${args.property} must not be an empty string.`;
}
};
IsNonEmptyStringConstraint = _ts_decorate3([
(0, import_class_validator3.ValidatorConstraint)({
name: "isNonEmptyString",
async: false
})
], IsNonEmptyStringConstraint);
var isEmptyString = /* @__PURE__ */ __name((value) => {
return typeof value === "string" && value.trim().length === 0;
}, "isEmptyString");
// src/entities/contact/PartyTypeEntity.ts
function _ts_decorate4(decorators, target, key, desc) {
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
return c > 3 && r && Object.defineProperty(target, key, r), r;
}
__name(_ts_decorate4, "_ts_decorate");
function _ts_metadata3(k, v) {
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
}
__name(_ts_metadata3, "_ts_metadata");
var PartyTypeEntity = class {
static {
__name(this, "PartyTypeEntity");
}
id;
type;
origin;
name;
description;
tenantId;
parties;
createdAt;
lastUpdatedAt;
// By default, @UpdateDateColumn in TypeORM updates the timestamp only when the entity's top-level properties change.
updateUpdatedDate() {
this.lastUpdatedAt = /* @__PURE__ */ new Date();
}
async validate() {
const validation = await (0, import_class_validator4.validate)(this);
if (validation.length > 0) {
const constraint = getConstraint(validation[0]);
if (constraint) {
const message = Object.values(constraint)[0];
return Promise.reject(Error(message));
}
}
}
};
_ts_decorate4([
(0, import_typeorm3.PrimaryGeneratedColumn)("uuid"),
_ts_metadata3("design:type", String)
], PartyTypeEntity.prototype, "id", void 0);
_ts_decorate4([
(0, import_typeorm3.Column)("simple-enum", {
name: "type",
enum: PartyTypeType,
nullable: false
}),
_ts_metadata3("design:type", typeof PartyTypeType === "undefined" ? Object : PartyTypeType)
], PartyTypeEntity.prototype, "type", void 0);
_ts_decorate4([
(0, import_typeorm3.Column)("simple-enum", {
name: "origin",
enum: PartyOrigin,
nullable: false,
unique: false
}),
_ts_metadata3("design:type", typeof PartyOrigin === "undefined" ? Object : PartyOrigin)
], PartyTypeEntity.prototype, "origin", void 0);
_ts_decorate4([
(0, import_typeorm3.Column)("varchar", {
name: "name",
length: 255,
nullable: false,
unique: true
}),
(0, import_class_validator4.IsNotEmpty)({
message: "Blank names are not allowed"
}),
_ts_metadata3("design:type", String)
], PartyTypeEntity.prototype, "name", void 0);
_ts_decorate4([
(0, import_typeorm3.Column)("varchar", {
name: "description",
length: 255,
nullable: true
}),
(0, import_class_validator4.Validate)(IsNonEmptyStringConstraint, {
message: "Blank descriptions are not allowed"
}),
_ts_metadata3("design:type", String)
], PartyTypeEntity.prototype, "description", void 0);
_ts_decorate4([
(0, import_typeorm3.Column)({
name: "tenant_id",
type: "varchar",
length: 255,
nullable: true
}),
(0, import_class_validator4.IsNotEmpty)({
message: "Blank tenant id's are not allowed"
}),
_ts_metadata3("design:type", String)
], PartyTypeEntity.prototype, "tenantId", void 0);
_ts_decorate4([
(0, import_typeorm3.OneToMany)(() => PartyEntity, (party) => party.partyType, {
nullable: false
}),
_ts_metadata3("design:type", typeof Array === "undefined" ? Object : Array)
], PartyTypeEntity.prototype, "parties", void 0);
_ts_decorate4([
(0, import_typeorm3.CreateDateColumn)({
name: "created_at",
nullable: false,
type: (0, import_ssi_sdk2.typeOrmDateTime)()
}),
_ts_metadata3("design:type", typeof Date === "undefined" ? Object : Date)
], PartyTypeEntity.prototype, "createdAt", void 0);
_ts_decorate4([
(0, import_typeorm3.UpdateDateColumn)({
name: "last_updated_at",
nullable: false,
type: (0, import_ssi_sdk2.typeOrmDateTime)()
}),
_ts_metadata3("design:type", typeof Date === "undefined" ? Object : Date)
], PartyTypeEntity.prototype, "lastUpdatedAt", void 0);
_ts_decorate4([
(0, import_typeorm3.BeforeInsert)(),
(0, import_typeorm3.BeforeUpdate)(),
_ts_metadata3("design:type", Function),
_ts_metadata3("design:paramtypes", []),
_ts_metadata3("design:returntype", void 0)
], PartyTypeEntity.prototype, "updateUpdatedDate", null);
_ts_decorate4([
(0, import_typeorm3.BeforeInsert)(),
(0, import_typeorm3.BeforeUpdate)(),
_ts_metadata3("design:type", Function),
_ts_metadata3("design:paramtypes", []),
_ts_metadata3("design:returntype", Promise)
], PartyTypeEntity.prototype, "validate", null);
PartyTypeEntity = _ts_decorate4([
(0, import_typeorm3.Entity)("PartyType"),
(0, import_typeorm3.Index)("IDX_PartyType_type_tenant_id", [
"type",
"tenantId"
], {
unique: true
})
], PartyTypeEntity);
// src/entities/contact/BaseContactEntity.ts
var import_typeorm5 = __toESM(require("typeorm"), 1);
var import_ssi_sdk4 = require("@sphereon/ssi-sdk.agent-config");
// src/entities/contact/ContactMetadataItemEntity.ts
var import_typeorm4 = __toESM(require("typeorm"), 1);
var import_ssi_sdk3 = require("@sphereon/ssi-sdk.agent-config");
var import_class_validator5 = require("class-validator");
function _ts_decorate5(decorators, target, key, desc) {
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
return c > 3 && r && Object.defineProperty(target, key, r), r;
}
__name(_ts_decorate5, "_ts_decorate");
function _ts_metadata4(k, v) {
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
}
__name(_ts_metadata4, "_ts_metadata");
var { Entity: Entity4, Column: Column4, PrimaryGeneratedColumn: PrimaryGeneratedColumn4, BaseEntity: BaseEntity3, ManyToOne: ManyToOne2, BeforeInsert: BeforeInsert4, BeforeUpdate: BeforeUpdate4 } = import_typeorm4.default;
var ContactMetadataItemEntity = class extends BaseEntity3 {
static {
__name(this, "ContactMetadataItemEntity");
}
id;
label;
valueType;
stringValue;
numberValue;
dateValue;
boolValue;
contact;
async validate() {
const validation = await (0, import_class_validator5.validate)(this);
if (validation.length > 0) {
const constraint = getConstraint(validation[0]);
if (constraint) {
const message = Object.values(constraint)[0];
return Promise.reject(Error(message));
}
}
}
};
_ts_decorate5([
PrimaryGeneratedColumn4("uuid"),
_ts_metadata4("design:type", String)
], ContactMetadataItemEntity.prototype, "id", void 0);
_ts_decorate5([
Column4("varchar", {
name: "label",
length: 255,
nullable: false
}),
(0, import_class_validator5.IsNotEmpty)({
message: "Blank metadata labels are not allowed"
}),
_ts_metadata4("design:type", String)
], ContactMetadataItemEntity.prototype, "label", void 0);
_ts_decorate5([
Column4("varchar", {
name: "valueType",
nullable: false
}),
(0, import_class_validator5.IsNotEmpty)({
message: "valueType must not be empty"
}),
_ts_metadata4("design:type", String)
], ContactMetadataItemEntity.prototype, "valueType", void 0);
_ts_decorate5([
Column4("varchar", {
name: "stringValue",
length: 255,
nullable: true
}),
_ts_metadata4("design:type", String)
], ContactMetadataItemEntity.prototype, "stringValue", void 0);
_ts_decorate5([
Column4("numeric", {
name: "numberValue",
nullable: true
}),
_ts_metadata4("design:type", Number)
], ContactMetadataItemEntity.prototype, "numberValue", void 0);
_ts_decorate5([
Column4({
name: "dateValue",
nullable: true,
type: (0, import_ssi_sdk3.typeOrmDateTime)()
}),
_ts_metadata4("design:type", typeof Date === "undefined" ? Object : Date)
], ContactMetadataItemEntity.prototype, "dateValue", void 0);
_ts_decorate5([
Column4("boolean", {
name: "boolValue",
nullable: true
}),
_ts_metadata4("design:type", Boolean)
], ContactMetadataItemEntity.prototype, "boolValue", void 0);
_ts_decorate5([
ManyToOne2(() => BaseContactEntity, (contact) => contact.metadata, {
cascade: [
"insert",
"update"
],
onDelete: "CASCADE"
}),
_ts_metadata4("design:type", typeof BaseContactEntity === "undefined" ? Object : BaseContactEntity)
], ContactMetadataItemEntity.prototype, "contact", void 0);
_ts_decorate5([
BeforeInsert4(),
BeforeUpdate4(),
_ts_metadata4("design:type", Function),
_ts_metadata4("design:paramtypes", []),
_ts_metadata4("design:returntype", Promise)
], ContactMetadataItemEntity.prototype, "validate", null);
ContactMetadataItemEntity = _ts_decorate5([
Entity4("ContactMetadata")
], ContactMetadataItemEntity);
// src/entities/contact/BaseContactEntity.ts
function _ts_decorate6(decorators, target, key, desc) {
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
return c > 3 && r && Object.defineProperty(target, key, r), r;
}
__name(_ts_decorate6, "_ts_decorate");
function _ts_metadata5(k, v) {
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
}
__name(_ts_metadata5, "_ts_metadata");
var { BaseEntity: BaseEntity4, BeforeInsert: BeforeInsert5, BeforeUpdate: BeforeUpdate5, CreateDateColumn: CreateDateColumn2, Entity: Entity5, JoinColumn: JoinColumn2, OneToMany: OneToMany2, OneToOne: OneToOne2, PrimaryGeneratedColumn: PrimaryGeneratedColumn5, TableInheritance, UpdateDateColumn: UpdateDateColumn2 } = import_typeorm5.default;
var BaseContactEntity = class extends BaseEntity4 {
static {
__name(this, "BaseContactEntity");
}
id;
createdAt;
lastUpdatedAt;
party;
metadata;
// By default, @UpdateDateColumn in TypeORM updates the timestamp only when the entity's top-level properties change.
updateUpdatedDate() {
this.lastUpdatedAt = /* @__PURE__ */ new Date();
}
};
_ts_decorate6([
PrimaryGeneratedColumn5("uuid"),
_ts_metadata5("design:type", String)
], BaseContactEntity.prototype, "id", void 0);
_ts_decorate6([
CreateDateColumn2({
name: "created_at",
nullable: false,
type: (0, import_ssi_sdk4.typeOrmDateTime)()
}),
_ts_metadata5("design:type", typeof Date === "undefined" ? Object : Date)
], BaseContactEntity.prototype, "createdAt", void 0);
_ts_decorate6([
UpdateDateColumn2({
name: "last_updated_at",
nullable: false,
type: (0, import_ssi_sdk4.typeOrmDateTime)()
}),
_ts_metadata5("design:type", typeof Date === "undefined" ? Object : Date)
], BaseContactEntity.prototype, "lastUpdatedAt", void 0);
_ts_decorate6([
OneToOne2(() => PartyEntity, (party) => party.contact, {
onDelete: "CASCADE"
}),
JoinColumn2({
name: "party_id"
}),
_ts_metadata5("design:type", typeof PartyEntity === "undefined" ? Object : PartyEntity)
], BaseContactEntity.prototype, "party", void 0);
_ts_decorate6([
OneToMany2(() => ContactMetadataItemEntity, (metadata) => metadata.contact, {
cascade: true,
onDelete: "CASCADE",
eager: true,
nullable: false
}),
JoinColumn2({
name: "metadata_id"
}),
_ts_metadata5("design:type", typeof Array === "undefined" ? Object : Array)
], BaseContactEntity.prototype, "metadata", void 0);
_ts_decorate6([
BeforeInsert5(),
BeforeUpdate5(),
_ts_metadata5("design:type", Function),
_ts_metadata5("design:paramtypes", []),
_ts_metadata5("design:returntype", void 0)
], BaseContactEntity.prototype, "updateUpdatedDate", null);
BaseContactEntity = _ts_decorate6([
Entity5("BaseContact"),
TableInheritance({
column: {
type: "varchar",
name: "type"
}
})
], BaseContactEntity);
// src/entities/contact/PartyRelationshipEntity.ts
var import_typeorm6 = require("typeorm");
var import_ssi_sdk5 = require("@sphereon/ssi-sdk.agent-config");
function _ts_decorate7(decorators, target, key, desc) {
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
return c > 3 && r && Object.defineProperty(target, key, r), r;
}
__name(_ts_decorate7, "_ts_decorate");
function _ts_metadata6(k, v) {
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
}
__name(_ts_metadata6, "_ts_metadata");
var PartyRelationshipEntity = class {
static {
__name(this, "PartyRelationshipEntity");
}
id;
left;
leftId;
right;
rightId;
ownerId;
tenantId;
createdAt;
lastUpdatedAt;
// By default, @UpdateDateColumn in TypeORM updates the timestamp only when the entity's top-level properties change.
updateUpdatedDate() {
this.lastUpdatedAt = /* @__PURE__ */ new Date();
}
async checkRelationshipSides() {
if ((this.left?.id ?? this.leftId) === (this.right?.id ?? this.rightId)) {
return Promise.reject(Error("Cannot use the same id for both sides of the relationship"));
}
}
};
_ts_decorate7([
(0, import_typeorm6.PrimaryGeneratedColumn)("uuid"),
_ts_metadata6("design:type", String)
], PartyRelationshipEntity.prototype, "id", void 0);
_ts_decorate7([
(0, import_typeorm6.ManyToOne)(() => PartyEntity, {
nullable: false,
onDelete: "CASCADE"
}),
(0, import_typeorm6.JoinColumn)({
name: "left_id"
}),
_ts_metadata6("design:type", typeof PartyEntity === "undefined" ? Object : PartyEntity)
], PartyRelationshipEntity.prototype, "left", void 0);
_ts_decorate7([
(0, import_typeorm6.Column)("text", {
name: "left_id",
nullable: false
}),
_ts_metadata6("design:type", String)
], PartyRelationshipEntity.prototype, "leftId", void 0);
_ts_decorate7([
(0, import_typeorm6.ManyToOne)(() => PartyEntity, {
nullable: false,
onDelete: "CASCADE"
}),
(0, import_typeorm6.JoinColumn)({
name: "right_id"
}),
_ts_metadata6("design:type", typeof PartyEntity === "undefined" ? Object : PartyEntity)
], PartyRelationshipEntity.prototype, "right", void 0);
_ts_decorate7([
(0, import_typeorm6.Column)("text", {
name: "right_id",
nullable: false
}),
_ts_metadata6("design:type", String)
], PartyRelationshipEntity.prototype, "rightId", void 0);
_ts_decorate7([
(0, import_typeorm6.Column)("text", {
name: "owner_id",
nullable: true
}),
_ts_metadata6("design:type", String)
], PartyRelationshipEntity.prototype, "ownerId", void 0);
_ts_decorate7([
(0, import_typeorm6.Column)("text", {
name: "tenant_id",
nullable: true
}),
_ts_metadata6("design:type", String)
], PartyRelationshipEntity.prototype, "tenantId", void 0);
_ts_decorate7([
(0, import_typeorm6.CreateDateColumn)({
name: "created_at",
nullable: false,
type: (0, import_ssi_sdk5.typeOrmDateTime)()
}),
_ts_metadata6("design:type", typeof Date === "undefined" ? Object : Date)
], PartyRelationshipEntity.prototype, "createdAt", void 0);
_ts_decorate7([
(0, import_typeorm6.UpdateDateColumn)({
name: "last_updated_at",
nullable: false,
type: (0, import_ssi_sdk5.typeOrmDateTime)()
}),
_ts_metadata6("design:type", typeof Date === "undefined" ? Object : Date)
], PartyRelationshipEntity.prototype, "lastUpdatedAt", void 0);
_ts_decorate7([
(0, import_typeorm6.BeforeInsert)(),
(0, import_typeorm6.BeforeUpdate)(),
_ts_metadata6("design:type", Function),
_ts_metadata6("design:paramtypes", []),
_ts_metadata6("design:returntype", void 0)
], PartyRelationshipEntity.prototype, "updateUpdatedDate", null);
_ts_decorate7([
(0, import_typeorm6.BeforeInsert)(),
(0, import_typeorm6.BeforeUpdate)(),
_ts_metadata6("design:type", Function),
_ts_metadata6("design:paramtypes", []),
_ts_metadata6("design:returntype", Promise)
], PartyRelationshipEntity.prototype, "checkRelationshipSides", null);
PartyRelationshipEntity = _ts_decorate7([
(0, import_typeorm6.Entity)("PartyRelationship"),
(0, import_typeorm6.Index)("IDX_PartyRelationship_left_right", [
"left",
"right"
], {
unique: true
})
], PartyRelationshipEntity);
// src/entities/contact/ElectronicAddressEntity.ts
var import_class_validator6 = require("class-validator");
var import_typeorm7 = __toESM(require("typeorm"), 1);
var import_ssi_sdk6 = require("@sphereon/ssi-sdk.agent-config");
function _ts_decorate8(decorators, target, key, desc) {
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
return c > 3 && r && Object.defineProperty(target, key, r), r;
}
__name(_ts_decorate8, "_ts_decorate");
function _ts_metadata7(k, v) {
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
}
__name(_ts_metadata7, "_ts_metadata");
var { Entity: Entity7, Column: Column6, PrimaryGeneratedColumn: PrimaryGeneratedColumn7, BaseEntity: BaseEntity5, ManyToOne: ManyToOne4, BeforeInsert: BeforeInsert7, BeforeUpdate: BeforeUpdate7, CreateDateColumn: CreateDateColumn4, UpdateDateColumn: UpdateDateColumn4 } = import_typeorm7.default;
var ElectronicAddressEntity = class extends BaseEntity5 {
static {
__name(this, "ElectronicAddressEntity");
}
id;
type;
electronicAddress;
party;
partyId;
ownerId;
tenantId;
createdAt;
lastUpdatedAt;
// By default, @UpdateDateColumn in TypeORM updates the timestamp only when the entity's top-level properties change.
updateUpdatedDate() {
this.lastUpdatedAt = /* @__PURE__ */ new Date();
}
async validate() {
const validation = await (0, import_class_validator6.validate)(this);
if (validation.length > 0) {
const constraint = getConstraint(validation[0]);
if (constraint) {
const message = Object.values(constraint)[0];
return Promise.reject(Error(message));
}
}
}
};
_ts_decorate8([
PrimaryGeneratedColumn7("uuid"),
_ts_metadata7("design:type", String)
], ElectronicAddressEntity.prototype, "id", void 0);
_ts_decorate8([
Column6("varchar", {
name: "type",
length: 255,
nullable: false
}),
(0, import_class_validator6.IsNotEmpty)({
message: "Blank electronic address types are not allowed"
}),
_ts_metadata7("design:type", typeof ElectronicAddressType === "undefined" ? Object : ElectronicAddressType)
], ElectronicAddressEntity.prototype, "type", void 0);
_ts_decorate8([
Column6("varchar", {
name: "electronic_address",
length: 255,
nullable: false
}),
(0, import_class_validator6.IsNotEmpty)({
message: "Blank electronic addresses are not allowed"
}),
_ts_metadata7("design:type", String)
], ElectronicAddressEntity.prototype, "electronicAddress", void 0);
_ts_decorate8([
ManyToOne4(() => PartyEntity, (party) => party.electronicAddresses, {
onDelete: "CASCADE"
}),
_ts_metadata7("design:type", typeof PartyEntity === "undefined" ? Object : PartyEntity)
], ElectronicAddressEntity.prototype, "party", void 0);
_ts_decorate8([
Column6("text", {
name: "partyId",
nullable: true
}),
_ts_metadata7("design:type", String)
], ElectronicAddressEntity.prototype, "partyId", void 0);
_ts_decorate8([
Column6("text", {
name: "owner_id",
nullable: true
}),
_ts_metadata7("design:type", String)
], ElectronicAddressEntity.prototype, "ownerId", void 0);
_ts_decorate8([
Column6("text", {
name: "tenant_id",
nullable: true
}),
_ts_metadata7("design:type", String)
], ElectronicAddressEntity.prototype, "tenantId", void 0);
_ts_decorate8([
CreateDateColumn4({
name: "created_at",
nullable: false,
type: (0, import_ssi_sdk6.typeOrmDateTime)()
}),
_ts_metadata7("design:type", typeof Date === "undefined" ? Object : Date)
], ElectronicAddressEntity.prototype, "createdAt", void 0);
_ts_decorate8([
UpdateDateColumn4({
name: "last_updated_at",
nullable: false,
type: (0, import_ssi_sdk6.typeOrmDateTime)()
}),
_ts_metadata7("design:type", typeof Date === "undefined" ? Object : Date)
], ElectronicAddressEntity.prototype, "lastUpdatedAt", void 0);
_ts_decorate8([
BeforeInsert7(),
BeforeUpdate7(),
_ts_metadata7("design:type", Function),
_ts_metadata7("design:paramtypes", []),
_ts_metadata7("design:returntype", void 0)
], ElectronicAddressEntity.prototype, "updateUpdatedDate", null);
_ts_decorate8([
BeforeInsert7(),
BeforeUpdate7(),
_ts_metadata7("design:type", Function),
_ts_metadata7("design:paramtypes", []),
_ts_metadata7("design:returntype", Promise)
], ElectronicAddressEntity.prototype, "validate", null);
ElectronicAddressEntity = _ts_decorate8([
Entity7("ElectronicAddress")
], ElectronicAddressEntity);
// src/entities/contact/PhysicalAddressEntity.ts
var import_class_validator7 = require("class-validator");
var import_typeorm8 = require("typeorm");
var import_ssi_sdk7 = require("@sphereon/ssi-sdk.agent-config");
function _ts_decorate9(decorators, target, key, desc) {
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
return c > 3 && r && Object.defineProperty(target, key, r), r;
}
__name(_ts_decorate9, "_ts_decorate");
function _ts_metadata8(k, v) {
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
}
__name(_ts_metadata8, "_ts_metadata");
var PhysicalAddressEntity = class extends import_typeorm8.BaseEntity {
static {
__name(this, "PhysicalAddressEntity");
}
id;
type;
streetName;
streetNumber;
postalCode;
cityName;
provinceName;
countryCode;
buildingName;
ownerId;
tenantId;
party;
partyId;
createdAt;
lastUpdatedAt;
// By default, @UpdateDateColumn in TypeORM updates the timestamp only when the entity's top-level properties change.
updateUpdatedDate() {
this.lastUpdatedAt = /* @__PURE__ */ new Date();
}
async validate() {
const validation = await (0, import_class_validator7.validate)(this);
if (validation.length > 0) {
const constraint = getConstraint(validation[0]);
if (constraint) {
const message = Object.values(constraint)[0];
return Promise.reject(Error(message));
}
}
}
};
_ts_decorate9([
(0, import_typeorm8.PrimaryGeneratedColumn)("uuid"),
_ts_metadata8("design:type", String)
], PhysicalAddressEntity.prototype, "id", void 0);
_ts_decorate9([
(0, import_typeorm8.Column)("varchar", {
name: "type",
length: 255,
nullable: false
}),
(0, import_class_validator7.IsNotEmpty)({
message: "Blank physical address types are not allowed"
}),
_ts_metadata8("design:type", typeof PhysicalAddressType === "undefined" ? Object : PhysicalAddressType)
], PhysicalAddressEntity.prototype, "type", void 0);
_ts_decorate9([
(0, import_typeorm8.Column)("varchar", {
name: "street_name",
length: 255,
nullable: false
}),
(0, import_class_validator7.IsNotEmpty)({
message: "Blank street names are not allowed"
}),
_ts_metadata8("design:type", String)
], PhysicalAddressEntity.prototype, "streetName", void 0);
_ts_decorate9([
(0, import_typeorm8.Column)("varchar", {
name: "street_number",
length: 255,
nullable: false
}),
(0, import_class_validator7.IsNotEmpty)({
message: "Blank street numbers are not allowed"
}),
_ts_metadata8("design:type", String)
], PhysicalAddressEntity.prototype, "streetNumber", void 0);
_ts_decorate9([
(0, import_typeorm8.Column)("varchar", {
name: "postal_code",
length: 255,
nullable: false
}),
(0, import_class_validator7.IsNotEmpty)({
message: "Blank postal codes are not allowed"
}),
_ts_metadata8("design:type", String)
], PhysicalAddressEntity.prototype, "postalCode", void 0);
_ts_decorate9([
(0, import_typeorm8.Column)("varchar", {
name: "city_name",
length: 255,
nullable: false
}),
(0, import_class_validator7.IsNotEmpty)({
message: "Blank city names are not allowed"
}),
_ts_metadata8("design:type", String)
], PhysicalAddressEntity.prototype, "cityName", void 0);
_ts_decorate9([
(0, import_typeorm8.Column)("varchar", {
name: "province_name",
length: 255,
nullable: false
}),
(0, import_class_validator7.IsNotEmpty)({
message: "Blank province names are not allowed"
}),
_ts_metadata8("design:type", String)
], PhysicalAddressEntity.prototype, "provinceName", void 0);
_ts_decorate9([
(0, import_typeorm8.Column)("varchar", {
name: "country_code",
length: 2,
nullable: false
}),
(0, import_class_validator7.IsNotEmpty)({
message: "Blank country codes are not allowed"
}),
_ts_metadata8("design:type", String)
], PhysicalAddressEntity.prototype, "countryCode", void 0);
_ts_decorate9([
(0, import_typeorm8.Column)("varchar", {
name: "building_name",
length: 255,
nullable: true
}),
(0, import_class_validator7.Validate)(IsNonEmptyStringConstraint, {
message: "Blank building names are not allowed"
}),
_ts_metadata8("design:type", String)
], PhysicalAddressEntity.prototype, "buildingName", void 0);
_ts_decorate9([
(0, import_typeorm8.Column)("text", {
name: "owner_id",
nullable: true
}),
_ts_metadata8("design:type", String)
], PhysicalAddressEntity.prototype, "ownerId", void 0);
_ts_decorate9([
(0, import_typeorm8.Column)("text", {
name: "tenant_id",
nullable: true
}),
_ts_metadata8("design:type", String)
], PhysicalAddressEntity.prototype, "tenantId", void 0);
_ts_decorate9([
(0, import_typeorm8.ManyToOne)(() => PartyEntity, (party) => party.physicalAddresses, {
onDelete: "CASCADE"
}),
_ts_metadata8("design:type", typeof PartyEntity === "undefined" ? Object : PartyEntity)
], PhysicalAddressEntity.prototype, "party", void 0);
_ts_decorate9([
(0, import_typeorm8.Column)("text", {
name: "partyId",
nullable: true
}),
_ts_metadata8("design:type", String)
], PhysicalAddressEntity.prototype, "partyId", void 0);
_ts_decorate9([
(0, import_typeorm8.CreateDateColumn)({
name: "created_at",
nullable: false,
type: (0, import_ssi_sdk7.typeOrmDateTime)()
}),
_ts_metadata8("design:type", typeof Date === "undefined" ?