@twin.org/identity-connector-entity-storage 0.0.3-next.24 → 0.0.3-next.26

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1 +1 @@
1
- {"version":3,"file":"entityStorageIdentityProfileConnector.js","sourceRoot":"","sources":["../../src/entityStorageIdentityProfileConnector.ts"],"names":[],"mappings":"AAAA,gCAAgC;AAChC,uCAAuC;AACvC,OAAO,EACN,kBAAkB,EAClB,SAAS,EACT,YAAY,EACZ,MAAM,EACN,EAAE,EACF,aAAa,EACb,YAAY,EACZ,MAAM,gBAAgB,CAAC;AAExB,OAAO,EAAE,kBAAkB,EAAE,MAAM,kBAAkB,CAAC;AACtD,OAAO,EACN,6BAA6B,EAE7B,MAAM,iCAAiC,CAAC;AAMzC;;GAEG;AACH,MAAM,OAAO,qCAAqC;IAIjD;;OAEG;IACI,MAAM,CAAU,SAAS,GAAW,gBAAgB,CAAC;IAE5D;;OAEG;IACI,MAAM,CAAU,UAAU,2CAA2D;IAE5F;;;OAGG;IACc,qBAAqB,CAA2C;IAEjF;;;OAGG;IACH,YAAY,OAAkE;QAC7E,IAAI,CAAC,qBAAqB,GAAG,6BAA6B,CAAC,GAAG,CAC7D,OAAO,EAAE,wBAAwB,IAAI,kBAAkB,CACvD,CAAC;IACH,CAAC;IAED;;;OAGG;IACI,SAAS;QACf,OAAO,qCAAqC,CAAC,UAAU,CAAC;IACzD,CAAC;IAED;;;;;;OAMG;IACI,KAAK,CAAC,MAAM,CAAC,QAAgB,EAAE,aAAiB,EAAE,cAAkB;QAC1E,MAAM,CAAC,WAAW,CACjB,qCAAqC,CAAC,UAAU,cAEhD,QAAQ,CACR,CAAC;QAEF,IAAI,CAAC;YACJ,MAAM,OAAO,GAAG,MAAM,IAAI,CAAC,qBAAqB,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC;YAE/D,IAAI,CAAC,EAAE,CAAC,KAAK,CAAC,OAAO,CAAC,EAAE,CAAC;gB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-2.0.\nimport {\n\tAlreadyExistsError,\n\tBaseError,\n\tGeneralError,\n\tGuards,\n\tIs,\n\tNotFoundError,\n\tObjectHelper\n} from \"@twin.org/core\";\nimport type { IJsonLdDocument } from \"@twin.org/data-json-ld\";\nimport { ComparisonOperator } from \"@twin.org/entity\";\nimport {\n\tEntityStorageConnectorFactory,\n\ttype IEntityStorageConnector\n} from \"@twin.org/entity-storage-models\";\nimport type { IIdentityProfileConnector } from \"@twin.org/identity-models\";\nimport { nameof } from \"@twin.org/nameof\";\nimport type { IdentityProfile } from \"./entities/identityProfile.js\";\nimport type { IEntityStorageIdentityProfileConnectorConstructorOptions } from \"./models/IEntityStorageIdentityProfileConnectorConstructorOptions.js\";\n\n/**\n * Class which implements the identity profile connector contract.\n */\nexport class EntityStorageIdentityProfileConnector<\n\tT extends IJsonLdDocument = IJsonLdDocument,\n\tU extends IJsonLdDocument = IJsonLdDocument\n> implements IIdentityProfileConnector<T, U> {\n\t/**\n\t * The namespace supported by the identity profile connector.\n\t */\n\tpublic static readonly NAMESPACE: string = \"entity-storage\";\n\n\t/**\n\t * Runtime name for the class.\n\t */\n\tpublic static readonly CLASS_NAME: string = nameof<EntityStorageIdentityProfileConnector>();\n\n\t/**\n\t * The storage connector for the profiles.\n\t * @internal\n\t */\n\tprivate readonly _profileEntityStorage: IEntityStorageConnector<IdentityProfile>;\n\n\t/**\n\t * Create a new instance of EntityStorageIdentityProfileConnector.\n\t * @param options The options for the identity service.\n\t */\n\tconstructor(options?: IEntityStorageIdentityProfileConnectorConstructorOptions) {\n\t\tthis._profileEntityStorage = EntityStorageConnectorFactory.get(\n\t\t\toptions?.profileEntityStorageType ?? \"identity-profile\"\n\t\t);\n\t}\n\n\t/**\n\t * Returns the class name of the component.\n\t * @returns The class name of the component.\n\t */\n\tpublic className(): string {\n\t\treturn EntityStorageIdentityProfileConnector.CLASS_NAME;\n\t}\n\n\t/**\n\t * Create the profile properties for an identity.\n\t * @param identity The identity of the profile to create.\n\t * @param publicProfile The public profile data.\n\t * @param privateProfile The private profile data.\n\t * @returns Nothing.\n\t */\n\tpublic async create(identity: string, publicProfile?: T, privateProfile?: U): Promise<void> {\n\t\tGuards.stringValue(\n\t\t\tEntityStorageIdentityProfileConnector.CLASS_NAME,\n\t\t\tnameof(identity),\n\t\t\tidentity\n\t\t);\n\n\t\ttry {\n\t\t\tconst profile = await this._profileEntityStorage.get(identity);\n\n\t\t\tif (!Is.empty(profile)) {\n\t\t\t\tthrow new AlreadyExistsError(\n\t\t\t\t\tEntityStorageIdentityProfileConnector.CLASS_NAME,\n\t\t\t\t\t\"alreadyExists\",\n\t\t\t\t\tidentity\n\t\t\t\t);\n\t\t\t}\n\n\t\t\tawait this._profileEntityStorage.set({\n\t\t\t\tidentity,\n\t\t\t\tpublicProfile,\n\t\t\t\tprivateProfile\n\t\t\t});\n\t\t} catch (error) {\n\t\t\tif (BaseError.someErrorClass(error, EntityStorageIdentityProfileConnector.CLASS_NAME)) {\n\t\t\t\tthrow error;\n\t\t\t}\n\t\t\tthrow new GeneralError(\n\t\t\t\tEntityStorageIdentityProfileConnector.CLASS_NAME,\n\t\t\t\t\"createFailed\",\n\t\t\t\t{ identity },\n\t\t\t\terror\n\t\t\t);\n\t\t}\n\t}\n\n\t/**\n\t * Get the profile properties for an identity.\n\t * @param identity The identity of the item to get.\n\t * @param publicPropertyNames The public properties to get for the profile, defaults to all.\n\t * @param privatePropertyNames The private properties to get for the profile, defaults to all.\n\t * @returns The items properties.\n\t */\n\tpublic async get(\n\t\tidentity: string,\n\t\tpublicPropertyNames?: (keyof T)[],\n\t\tprivatePropertyNames?: (keyof U)[]\n\t): Promise<{\n\t\tpublicProfile: Partial<T>;\n\t\tprivateProfile: Partial<U>;\n\t}> {\n\t\ttry {\n\t\t\tconst profile = await this._profileEntityStorage.get(identity);\n\t\t\tif (!profile) {\n\t\t\t\tthrow new NotFoundError(\n\t\t\t\t\tEntityStorageIdentityProfileConnector.CLASS_NAME,\n\t\t\t\t\t\"identityNotFound\",\n\t\t\t\t\tidentity\n\t\t\t\t);\n\t\t\t}\n\n\t\t\treturn this.pickProperties(profile, publicPropertyNames, privatePropertyNames);\n\t\t} catch (error) {\n\t\t\tif (BaseError.someErrorClass(error, EntityStorageIdentityProfileConnector.CLASS_NAME)) {\n\t\t\t\tthrow error;\n\t\t\t}\n\t\t\tthrow new GeneralError(\n\t\t\t\tEntityStorageIdentityProfileConnector.CLASS_NAME,\n\t\t\t\t\"getFailed\",\n\t\t\t\t{ identity },\n\t\t\t\terror\n\t\t\t);\n\t\t}\n\t}\n\n\t/**\n\t * Update the profile properties of an identity.\n\t * @param identity The identity to update.\n\t * @param publicProfile The public profile data.\n\t * @param privateProfile The private profile data.\n\t * @returns Nothing.\n\t */\n\tpublic async update(identity: string, publicProfile?: T, privateProfile?: U): Promise<void> {\n\t\tGuards.stringValue(\n\t\t\tEntityStorageIdentityProfileConnector.CLASS_NAME,\n\t\t\tnameof(identity),\n\t\t\tidentity\n\t\t);\n\n\t\ttry {\n\t\t\tconst profile = await this._profileEntityStorage.get(identity);\n\t\t\tif (Is.empty(profile)) {\n\t\t\t\tthrow new NotFoundError(\n\t\t\t\t\tEntityStorageIdentityProfileConnector.CLASS_NAME,\n\t\t\t\t\t\"notFound\",\n\t\t\t\t\tidentity\n\t\t\t\t);\n\t\t\t}\n\n\t\t\tprofile.publicProfile = publicProfile ?? profile.publicProfile;\n\t\t\tprofile.privateProfile = privateProfile ?? profile.privateProfile;\n\n\t\t\tawait this._profileEntityStorage.set(profile);\n\t\t} catch (error) {\n\t\t\tif (BaseError.someErrorClass(error, EntityStorageIdentityProfileConnector.CLASS_NAME)) {\n\t\t\t\tthrow error;\n\t\t\t}\n\t\t\tthrow new GeneralError(\n\t\t\t\tEntityStorageIdentityProfileConnector.CLASS_NAME,\n\t\t\t\t\"updateFailed\",\n\t\t\t\t{ identity },\n\t\t\t\terror\n\t\t\t);\n\t\t}\n\t}\n\n\t/**\n\t * Delete the profile for an identity.\n\t * @param identity The identity to delete.\n\t * @returns Nothing.\n\t */\n\tpublic async remove(identity: string): Promise<void> {\n\t\tGuards.stringValue(\n\t\t\tEntityStorageIdentityProfileConnector.CLASS_NAME,\n\t\t\tnameof(identity),\n\t\t\tidentity\n\t\t);\n\n\t\ttry {\n\t\t\tconst profile = await this._profileEntityStorage.get(identity);\n\t\t\tif (Is.empty(profile)) {\n\t\t\t\tthrow new NotFoundError(\n\t\t\t\t\tEntityStorageIdentityProfileConnector.CLASS_NAME,\n\t\t\t\t\t\"notFound\",\n\t\t\t\t\tidentity\n\t\t\t\t);\n\t\t\t}\n\n\t\t\tawait this._profileEntityStorage.remove(identity);\n\t\t} catch (error) {\n\t\t\tif (BaseError.someErrorClass(error, EntityStorageIdentityProfileConnector.CLASS_NAME)) {\n\t\t\t\tthrow error;\n\t\t\t}\n\t\t\tthrow new GeneralError(\n\t\t\t\tEntityStorageIdentityProfileConnector.CLASS_NAME,\n\t\t\t\t\"removeFailed\",\n\t\t\t\t{ identity },\n\t\t\t\terror\n\t\t\t);\n\t\t}\n\t}\n\n\t/**\n\t * Get a list of the requested types.\n\t * @param publicFilters The filters to apply to the identities public profiles.\n\t * @param privateFilters The filters to apply to the identities private profiles.\n\t * @param publicPropertyNames The public properties to get for the profile, defaults to all.\n\t * @param privatePropertyNames The private properties to get for the profile, defaults to all.\n\t * @param cursor The cursor for paged requests.\n\t * @param limit The maximum number of items in a page.\n\t * @returns The list of items and cursor for paging.\n\t */\n\tpublic async list(\n\t\tpublicFilters?: {\n\t\t\tpropertyName: string;\n\t\t\tpropertyValue: unknown;\n\t\t}[],\n\t\tprivateFilters?: {\n\t\t\tpropertyName: string;\n\t\t\tpropertyValue: unknown;\n\t\t}[],\n\t\tpublicPropertyNames?: (keyof T)[],\n\t\tprivatePropertyNames?: (keyof U)[],\n\t\tcursor?: string,\n\t\tlimit?: number\n\t): Promise<{\n\t\t/**\n\t\t * The identities.\n\t\t */\n\t\titems: {\n\t\t\tidentity: string;\n\t\t\tpublicProfile?: Partial<T>;\n\t\t\tprivateProfile?: Partial<U>;\n\t\t}[];\n\t\t/**\n\t\t * An optional cursor, when defined can be used to call find to get more entities.\n\t\t */\n\t\tcursor?: string;\n\t}> {\n\t\ttry {\n\t\t\tconst conditions = [];\n\n\t\t\tif (Is.arrayValue(publicFilters)) {\n\t\t\t\tfor (const filter of publicFilters) {\n\t\t\t\t\tconditions.push({\n\t\t\t\t\t\tproperty: `publicProfile.${filter.propertyName}`,\n\t\t\t\t\t\tvalue: filter.propertyValue,\n\t\t\t\t\t\tcomparison: ComparisonOperator.Equals\n\t\t\t\t\t});\n\t\t\t\t}\n\t\t\t}\n\t\t\tif (Is.arrayValue(privateFilters)) {\n\t\t\t\tfor (const filter of privateFilters) {\n\t\t\t\t\tconditions.push({\n\t\t\t\t\t\tproperty: `privateProfile.${filter.propertyName}`,\n\t\t\t\t\t\tvalue: filter.propertyValue,\n\t\t\t\t\t\tcomparison: ComparisonOperator.Equals\n\t\t\t\t\t});\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tconst result = await this._profileEntityStorage.query(\n\t\t\t\tIs.arrayValue(conditions)\n\t\t\t\t\t? {\n\t\t\t\t\t\t\tconditions\n\t\t\t\t\t\t}\n\t\t\t\t\t: undefined,\n\t\t\t\tundefined,\n\t\t\t\tundefined,\n\t\t\t\tcursor,\n\t\t\t\tlimit\n\t\t\t);\n\n\t\t\tconst items: {\n\t\t\t\tidentity: string;\n\t\t\t\tpublicProfile?: Partial<T>;\n\t\t\t\tprivateProfile?: Partial<U>;\n\t\t\t}[] = [];\n\t\t\tfor (const resultEntity of result.entities) {\n\t\t\t\titems.push({\n\t\t\t\t\tidentity: resultEntity.identity ?? \"\",\n\t\t\t\t\t...this.pickProperties(resultEntity, publicPropertyNames, privatePropertyNames)\n\t\t\t\t});\n\t\t\t}\n\n\t\t\treturn {\n\t\t\t\titems,\n\t\t\t\tcursor: result.cursor\n\t\t\t};\n\t\t} catch (error) {\n\t\t\tthrow new GeneralError(\n\t\t\t\tEntityStorageIdentityProfileConnector.CLASS_NAME,\n\t\t\t\t\"listFailed\",\n\t\t\t\tundefined,\n\t\t\t\terror\n\t\t\t);\n\t\t}\n\t}\n\n\t/**\n\t * Get the profile properties for an identity.\n\t * @param profile The profile to pick the properties from.\n\t * @param publicPropertyNames The public properties to get for the profile, defaults to all.\n\t * @param privatePropertyNames The private properties to get for the profile, defaults to all.\n\t * @returns The identity profile, will only return private data if you have correct permissions.\n\t * @internal\n\t */\n\tprivate pickProperties(\n\t\tprofile: Partial<IdentityProfile>,\n\t\tpublicPropertyNames?: (keyof T)[],\n\t\tprivatePropertyNames?: (keyof U)[]\n\t): {\n\t\tpublicProfile: Partial<T>;\n\t\tprivateProfile: Partial<U>;\n\t} {\n\t\treturn {\n\t\t\tpublicProfile: Is.array(publicPropertyNames)\n\t\t\t\t? ObjectHelper.pick<T>(profile.publicProfile as T, publicPropertyNames)\n\t\t\t\t: (profile.publicProfile as T),\n\t\t\tprivateProfile: Is.array(privatePropertyNames)\n\t\t\t\t? ObjectHelper.pick<U>(profile.privateProfile as U, privatePropertyNames)\n\t\t\t\t: (profile.privateProfile as U)\n\t\t};\n\t}\n}\n"]}
1
+ {"version":3,"file":"entityStorageIdentityProfileConnector.js","sourceRoot":"","sources":["../../src/entityStorageIdentityProfileConnector.ts"],"names":[],"mappings":"AAAA,gCAAgC;AAChC,uCAAuC;AACvC,OAAO,EACN,kBAAkB,EAClB,SAAS,EACT,YAAY,EACZ,MAAM,EACN,EAAE,EACF,aAAa,EACb,YAAY,EACZ,MAAM,gBAAgB,CAAC;AAExB,OAAO,EAAE,kBAAkB,EAAE,MAAM,kBAAkB,CAAC;AACtD,OAAO,EACN,6BAA6B,EAE7B,MAAM,iCAAiC,CAAC;AAMzC;;GAEG;AACH,MAAM,OAAO,qCAAqC;IAIjD;;OAEG;IACI,MAAM,CAAU,SAAS,GAAW,gBAAgB,CAAC;IAE5D;;OAEG;IACI,MAAM,CAAU,UAAU,2CAA2D;IAE5F;;;OAG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YAAY,EACZ,SAAS,EACT,KAAK,CACL,CAAC;QACH,CAAC;IACF,CAAC;IAED;;;;;;;OAOG;IACK,cAAc,CACrB,OAAiC,EACjC,mBAAiC,EACjC,oBAAkC;QAKlC,OAAO;YACN,aAAa,EAAE,EAAE,CAAC,KAAK,CAAC,mBAAmB,CAAC;gBAC3C,CAAC,CAAC,YAAY,CAAC,IAAI,CAAC,OAAO,CAAC,aAAkB,EAAE,mBAAmB,CAAC;gBACpE,CAAC,CAAE,OAAO,CAAC,aAAmB;YAC/B,cAAc,EAAE,EAAE,CAAC,KAAK,CAAC,oBAAoB,CAAC;gBAC7C,CAAC,CAAC,YAAY,CAAC,IAAI,CAAC,OAAO,CAAC,cAAmB,EAAE,oBAAoB,CAAC;gBACtE,CAAC,CAAE,OAAO,CAAC,cAAoB;SAChC,CAAC;IACH,CAAC","sourcesContent":["// Copyright 2024 IOTA Stiftung.\n// SPDX-License-Identifier: Apache-2.0.\nimport {\n\tAlreadyExistsError,\n\tBaseError,\n\tGeneralError,\n\tGuards,\n\tIs,\n\tNotFoundError,\n\tObjectHelper\n} from \"@twin.org/core\";\nimport type { IJsonLdDocument } from \"@twin.org/data-json-ld\";\nimport { ComparisonOperator } from \"@twin.org/entity\";\nimport {\n\tEntityStorageConnectorFactory,\n\ttype IEntityStorageConnector\n} from \"@twin.org/entity-storage-models\";\nimport type { IIdentityProfileConnector } from \"@twin.org/identity-models\";\nimport { nameof } from \"@twin.org/nameof\";\nimport type { IdentityProfile } from \"./entities/identityProfile.js\";\nimport type { IEntityStorageIdentityProfileConnectorConstructorOptions } from \"./models/IEntityStorageIdentityProfileConnectorConstructorOptions.js\";\n\n/**\n * Class which implements the identity profile connector contract.\n */\nexport class EntityStorageIdentityProfileConnector<\n\tT extends IJsonLdDocument = IJsonLdDocument,\n\tU extends IJsonLdDocument = IJsonLdDocument\n> implements IIdentityProfileConnector<T, U> {\n\t/**\n\t * The namespace supported by the identity profile connector.\n\t */\n\tpublic static readonly NAMESPACE: string = \"entity-storage\";\n\n\t/**\n\t * Runtime name for the class.\n\t */\n\tpublic static readonly CLASS_NAME: string = nameof<EntityStorageIdentityProfileConnector>();\n\n\t/**\n\t * The storage connector for the profiles.\n\t * @internal\n\t */\n\tprivate readonly _profileEntityStorage: IEntityStorageConnector<IdentityProfile>;\n\n\t/**\n\t * Create a new instance of EntityStorageIdentityProfileConnector.\n\t * @param options The options for the identity service.\n\t */\n\tconstructor(options?: IEntityStorageIdentityProfileConnectorConstructorOptions) {\n\t\tthis._profileEntityStorage = EntityStorageConnectorFactory.get(\n\t\t\toptions?.profileEntityStorageType ?? \"identity-profile\"\n\t\t);\n\t}\n\n\t/**\n\t * Returns the class name of the component.\n\t * @returns The class name of the component.\n\t */\n\tpublic className(): string {\n\t\treturn EntityStorageIdentityProfileConnector.CLASS_NAME;\n\t}\n\n\t/**\n\t * Create the profile properties for an identity.\n\t * @param identity The identity of the profile to create.\n\t * @param publicProfile The public profile data.\n\t * @param privateProfile The private profile data.\n\t * @returns Nothing.\n\t */\n\tpublic async create(identity: string, publicProfile?: T, privateProfile?: U): Promise<void> {\n\t\tGuards.stringValue(\n\t\t\tEntityStorageIdentityProfileConnector.CLASS_NAME,\n\t\t\tnameof(identity),\n\t\t\tidentity\n\t\t);\n\n\t\ttry {\n\t\t\tconst profile = await this._profileEntityStorage.get(identity);\n\n\t\t\tif (!Is.empty(profile)) {\n\t\t\t\tthrow new AlreadyExistsError(\n\t\t\t\t\tEntityStorageIdentityProfileConnector.CLASS_NAME,\n\t\t\t\t\t\"alreadyExists\",\n\t\t\t\t\tidentity\n\t\t\t\t);\n\t\t\t}\n\n\t\t\tawait this._profileEntityStorage.set({\n\t\t\t\tidentity,\n\t\t\t\tpublicProfile,\n\t\t\t\tprivateProfile\n\t\t\t});\n\t\t} catch (error) {\n\t\t\tif (BaseError.someErrorClass(error, EntityStorageIdentityProfileConnector.CLASS_NAME)) {\n\t\t\t\tthrow error;\n\t\t\t}\n\t\t\tthrow new GeneralError(\n\t\t\t\tEntityStorageIdentityProfileConnector.CLASS_NAME,\n\t\t\t\t\"createFailed\",\n\t\t\t\t{ identity },\n\t\t\t\terror\n\t\t\t);\n\t\t}\n\t}\n\n\t/**\n\t * Get the profile properties for an identity.\n\t * @param identity The identity of the item to get.\n\t * @param publicPropertyNames The public properties to get for the profile, defaults to all.\n\t * @param privatePropertyNames The private properties to get for the profile, defaults to all.\n\t * @returns The items properties.\n\t */\n\tpublic async get(\n\t\tidentity: string,\n\t\tpublicPropertyNames?: (keyof T)[],\n\t\tprivatePropertyNames?: (keyof U)[]\n\t): Promise<{\n\t\tpublicProfile: Partial<T>;\n\t\tprivateProfile: Partial<U>;\n\t}> {\n\t\ttry {\n\t\t\tconst profile = await this._profileEntityStorage.get(identity);\n\t\t\tif (!profile) {\n\t\t\t\tthrow new NotFoundError(\n\t\t\t\t\tEntityStorageIdentityProfileConnector.CLASS_NAME,\n\t\t\t\t\t\"identityNotFound\",\n\t\t\t\t\tidentity\n\t\t\t\t);\n\t\t\t}\n\n\t\t\treturn this.pickProperties(profile, publicPropertyNames, privatePropertyNames);\n\t\t} catch (error) {\n\t\t\tif (BaseError.someErrorClass(error, EntityStorageIdentityProfileConnector.CLASS_NAME)) {\n\t\t\t\tthrow error;\n\t\t\t}\n\t\t\tthrow new GeneralError(\n\t\t\t\tEntityStorageIdentityProfileConnector.CLASS_NAME,\n\t\t\t\t\"getFailed\",\n\t\t\t\t{ identity },\n\t\t\t\terror\n\t\t\t);\n\t\t}\n\t}\n\n\t/**\n\t * Update the profile properties of an identity.\n\t * @param identity The identity to update.\n\t * @param publicProfile The public profile data.\n\t * @param privateProfile The private profile data.\n\t * @returns Nothing.\n\t */\n\tpublic async update(identity: string, publicProfile?: T, privateProfile?: U): Promise<void> {\n\t\tGuards.stringValue(\n\t\t\tEntityStorageIdentityProfileConnector.CLASS_NAME,\n\t\t\tnameof(identity),\n\t\t\tidentity\n\t\t);\n\n\t\ttry {\n\t\t\tconst profile = await this._profileEntityStorage.get(identity);\n\t\t\tif (Is.empty(profile)) {\n\t\t\t\tthrow new NotFoundError(\n\t\t\t\t\tEntityStorageIdentityProfileConnector.CLASS_NAME,\n\t\t\t\t\t\"notFound\",\n\t\t\t\t\tidentity\n\t\t\t\t);\n\t\t\t}\n\n\t\t\tprofile.publicProfile = publicProfile ?? profile.publicProfile;\n\t\t\tprofile.privateProfile = privateProfile ?? profile.privateProfile;\n\n\t\t\tawait this._profileEntityStorage.set(profile);\n\t\t} catch (error) {\n\t\t\tif (BaseError.someErrorClass(error, EntityStorageIdentityProfileConnector.CLASS_NAME)) {\n\t\t\t\tthrow error;\n\t\t\t}\n\t\t\tthrow new GeneralError(\n\t\t\t\tEntityStorageIdentityProfileConnector.CLASS_NAME,\n\t\t\t\t\"updateFailed\",\n\t\t\t\t{ identity },\n\t\t\t\terror\n\t\t\t);\n\t\t}\n\t}\n\n\t/**\n\t * Delete the profile for an identity.\n\t * @param identity The identity to delete.\n\t * @returns Nothing.\n\t */\n\tpublic async remove(identity: string): Promise<void> {\n\t\tGuards.stringValue(\n\t\t\tEntityStorageIdentityProfileConnector.CLASS_NAME,\n\t\t\tnameof(identity),\n\t\t\tidentity\n\t\t);\n\n\t\ttry {\n\t\t\tconst profile = await this._profileEntityStorage.get(identity);\n\t\t\tif (Is.empty(profile)) {\n\t\t\t\tthrow new NotFoundError(\n\t\t\t\t\tEntityStorageIdentityProfileConnector.CLASS_NAME,\n\t\t\t\t\t\"notFound\",\n\t\t\t\t\tidentity\n\t\t\t\t);\n\t\t\t}\n\n\t\t\tawait this._profileEntityStorage.remove(identity);\n\t\t} catch (error) {\n\t\t\tif (BaseError.someErrorClass(error, EntityStorageIdentityProfileConnector.CLASS_NAME)) {\n\t\t\t\tthrow error;\n\t\t\t}\n\t\t\tthrow new GeneralError(\n\t\t\t\tEntityStorageIdentityProfileConnector.CLASS_NAME,\n\t\t\t\t\"removeFailed\",\n\t\t\t\t{ identity },\n\t\t\t\terror\n\t\t\t);\n\t\t}\n\t}\n\n\t/**\n\t * Get a list of the requested types.\n\t * @param publicFilters The filters to apply to the identities public profiles.\n\t * @param privateFilters The filters to apply to the identities private profiles.\n\t * @param publicPropertyNames The public properties to get for the profile, defaults to all.\n\t * @param privatePropertyNames The private properties to get for the profile, defaults to all.\n\t * @param cursor The cursor for paged requests.\n\t * @param limit The maximum number of items in a page.\n\t * @returns The list of items and cursor for paging.\n\t */\n\tpublic async list(\n\t\tpublicFilters?: {\n\t\t\tpropertyName: string;\n\t\t\tpropertyValue: unknown;\n\t\t}[],\n\t\tprivateFilters?: {\n\t\t\tpropertyName: string;\n\t\t\tpropertyValue: unknown;\n\t\t}[],\n\t\tpublicPropertyNames?: (keyof T)[],\n\t\tprivatePropertyNames?: (keyof U)[],\n\t\tcursor?: string,\n\t\tlimit?: number\n\t): Promise<{\n\t\t/**\n\t\t * The identities.\n\t\t */\n\t\titems: {\n\t\t\tidentity: string;\n\t\t\tpublicProfile?: Partial<T>;\n\t\t\tprivateProfile?: Partial<U>;\n\t\t}[];\n\t\t/**\n\t\t * An optional cursor, when defined can be used to call find to get more entities.\n\t\t */\n\t\tcursor?: string;\n\t}> {\n\t\ttry {\n\t\t\tconst conditions = [];\n\n\t\t\tif (Is.arrayValue(publicFilters)) {\n\t\t\t\tfor (const filter of publicFilters) {\n\t\t\t\t\tconditions.push({\n\t\t\t\t\t\tproperty: `publicProfile.${filter.propertyName}`,\n\t\t\t\t\t\tvalue: filter.propertyValue,\n\t\t\t\t\t\tcomparison: ComparisonOperator.Equals\n\t\t\t\t\t});\n\t\t\t\t}\n\t\t\t}\n\t\t\tif (Is.arrayValue(privateFilters)) {\n\t\t\t\tfor (const filter of privateFilters) {\n\t\t\t\t\tconditions.push({\n\t\t\t\t\t\tproperty: `privateProfile.${filter.propertyName}`,\n\t\t\t\t\t\tvalue: filter.propertyValue,\n\t\t\t\t\t\tcomparison: ComparisonOperator.Equals\n\t\t\t\t\t});\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tconst result = await this._profileEntityStorage.query(\n\t\t\t\tIs.arrayValue(conditions)\n\t\t\t\t\t? {\n\t\t\t\t\t\t\tconditions\n\t\t\t\t\t\t}\n\t\t\t\t\t: undefined,\n\t\t\t\tundefined,\n\t\t\t\tundefined,\n\t\t\t\tcursor,\n\t\t\t\tlimit\n\t\t\t);\n\n\t\t\tconst items: {\n\t\t\t\tidentity: string;\n\t\t\t\tpublicProfile?: Partial<T>;\n\t\t\t\tprivateProfile?: Partial<U>;\n\t\t\t}[] = [];\n\t\t\tfor (const resultEntity of result.entities) {\n\t\t\t\titems.push({\n\t\t\t\t\tidentity: resultEntity.identity ?? \"\",\n\t\t\t\t\t...this.pickProperties(resultEntity, publicPropertyNames, privatePropertyNames)\n\t\t\t\t});\n\t\t\t}\n\n\t\t\treturn {\n\t\t\t\titems,\n\t\t\t\tcursor: result.cursor\n\t\t\t};\n\t\t} catch (error) {\n\t\t\tthrow new GeneralError(\n\t\t\t\tEntityStorageIdentityProfileConnector.CLASS_NAME,\n\t\t\t\t\"listFailed\",\n\t\t\t\tundefined,\n\t\t\t\terror\n\t\t\t);\n\t\t}\n\t}\n\n\t/**\n\t * Get the profile properties for an identity.\n\t * @param profile The profile to pick the properties from.\n\t * @param publicPropertyNames The public properties to get for the profile, defaults to all.\n\t * @param privatePropertyNames The private properties to get for the profile, defaults to all.\n\t * @returns The identity profile, will only return private data if you have correct permissions.\n\t * @internal\n\t */\n\tprivate pickProperties(\n\t\tprofile: Partial<IdentityProfile>,\n\t\tpublicPropertyNames?: (keyof T)[],\n\t\tprivatePropertyNames?: (keyof U)[]\n\t): {\n\t\tpublicProfile: Partial<T>;\n\t\tprivateProfile: Partial<U>;\n\t} {\n\t\treturn {\n\t\t\tpublicProfile: Is.array(publicPropertyNames)\n\t\t\t\t? ObjectHelper.pick(profile.publicProfile as T, publicPropertyNames)\n\t\t\t\t: (profile.publicProfile as T),\n\t\t\tprivateProfile: Is.array(privatePropertyNames)\n\t\t\t\t? ObjectHelper.pick(profile.privateProfile as U, privatePropertyNames)\n\t\t\t\t: (profile.privateProfile as U)\n\t\t};\n\t}\n}\n"]}
package/docs/changelog.md CHANGED
@@ -1,5 +1,33 @@
1
1
  # @twin.org/identity-connector-entity-storage- Changelog
2
2
 
3
+ ## [0.0.3-next.26](https://github.com/iotaledger/twin-identity/compare/identity-connector-entity-storage-v0.0.3-next.25...identity-connector-entity-storage-v0.0.3-next.26) (2026-05-21)
4
+
5
+
6
+ ### Miscellaneous Chores
7
+
8
+ * **identity-connector-entity-storage:** Synchronize repo versions
9
+
10
+
11
+ ### Dependencies
12
+
13
+ * The following workspace dependencies were updated
14
+ * dependencies
15
+ * @twin.org/identity-models bumped from 0.0.3-next.25 to 0.0.3-next.26
16
+
17
+ ## [0.0.3-next.25](https://github.com/iotaledger/twin-identity/compare/identity-connector-entity-storage-v0.0.3-next.24...identity-connector-entity-storage-v0.0.3-next.25) (2026-05-20)
18
+
19
+
20
+ ### Miscellaneous Chores
21
+
22
+ * **identity-connector-entity-storage:** Synchronize repo versions
23
+
24
+
25
+ ### Dependencies
26
+
27
+ * The following workspace dependencies were updated
28
+ * dependencies
29
+ * @twin.org/identity-models bumped from 0.0.3-next.24 to 0.0.3-next.25
30
+
3
31
  ## [0.0.3-next.24](https://github.com/iotaledger/twin-identity/compare/identity-connector-entity-storage-v0.0.3-next.23...identity-connector-entity-storage-v0.0.3-next.24) (2026-05-13)
4
32
 
5
33
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@twin.org/identity-connector-entity-storage",
3
- "version": "0.0.3-next.24",
3
+ "version": "0.0.3-next.26",
4
4
  "description": "Entity storage connector for persisting and retrieving identity records through a consistent data layer.",
5
5
  "repository": {
6
6
  "type": "git",
@@ -19,7 +19,7 @@
19
19
  "@twin.org/data-core": "next",
20
20
  "@twin.org/data-json-ld": "next",
21
21
  "@twin.org/entity": "next",
22
- "@twin.org/identity-models": "0.0.3-next.24",
22
+ "@twin.org/identity-models": "0.0.3-next.26",
23
23
  "@twin.org/nameof": "next",
24
24
  "@twin.org/standards-w3c-did": "next",
25
25
  "@twin.org/vault-models": "next",