{"version":3,"file":"DidDocumentService.mjs","names":[],"sources":["../../../../../src/modules/dids/domain/service/DidDocumentService.ts"],"sourcesContent":["import type { ValidationOptions } from 'class-validator'\n\nimport { buildMessage, IsString, isString, ValidateBy } from 'class-validator'\n\nimport { isJsonObject, type SingleOrArray } from '../../../../types'\n\ntype ServiceEndpointType = SingleOrArray<string | Record<string, unknown>>\n\nexport class DidDocumentService {\n  public constructor(options: { id: string; serviceEndpoint: ServiceEndpointType; type: string }) {\n    if (options) {\n      this.id = options.id\n      this.serviceEndpoint = options.serviceEndpoint\n      this.type = options.type\n    }\n  }\n\n  @IsString()\n  public id!: string\n\n  @IsStringOrJsonObjectSingleOrArray()\n  public serviceEndpoint!: SingleOrArray<string | Record<string, unknown>>\n\n  @IsString()\n  public type!: string\n}\n\n/**\n * Checks if a given value is a string, a json object, or an array of strings and json objects\n */\nfunction IsStringOrJsonObjectSingleOrArray(validationOptions?: Omit<ValidationOptions, 'each'>): PropertyDecorator {\n  return ValidateBy(\n    {\n      name: 'isStringOrJsonObjectSingleOrArray',\n      validator: {\n        validate: (value): boolean =>\n          isString(value) ||\n          isJsonObject(value) ||\n          (Array.isArray(value) && value.every((v) => isString(v) || isJsonObject(v))),\n        defaultMessage: buildMessage(\n          (eachPrefix) =>\n            `${eachPrefix}$property must be a string, JSON object, or an array consisting of strings and JSON objects`,\n          validationOptions\n        ),\n      },\n    },\n    validationOptions\n  )\n}\n"],"mappings":";;;;;AAQA,IAAa,qBAAb,MAAgC;CAC9B,YAAmB,SAA6E;EAC9F,IAAI,SAAS;GACX,KAAK,KAAK,QAAQ;GAClB,KAAK,kBAAkB,QAAQ;GAC/B,KAAK,OAAO,QAAQ;EACtB;CACF;AAUF;AARG,WAAA,CAAA,SAAS,GAAA,mBAAA,eAAA,MAAA,CAAA,GAAA,mBAAA,WAAA,MAAA,KAAA,CAAA;AAGT,WAAA,CAAA,kCAAkC,GAAA,mBAAA,eAAA,MAAA,CAAA,GAAA,mBAAA,WAAA,mBAAA,KAAA,CAAA;AAGlC,WAAA,CAAA,SAAS,GAAA,mBAAA,eAAA,MAAA,CAAA,GAAA,mBAAA,WAAA,QAAA,KAAA,CAAA;;;;AAOZ,SAAS,kCAAkC,mBAAwE;CACjH,OAAO,WACL;EACE,MAAM;EACN,WAAW;GACT,WAAW,UACT,SAAS,KAAK,KACd,aAAa,KAAK,KACjB,MAAM,QAAQ,KAAK,KAAK,MAAM,OAAO,MAAM,SAAS,CAAC,KAAK,aAAa,CAAC,CAAC;GAC5E,gBAAgB,cACb,eACC,GAAG,WAAW,8FAChB,iBACF;EACF;CACF,GACA,iBACF;AACF"}