From 2c1eeca9d5a7620fee072abaa9e0a6d842bb4dac Mon Sep 17 00:00:00 2001 From: Kevin Delong Date: Thu, 12 Dec 2024 11:50:45 -0500 Subject: [PATCH 01/12] update: add assigned vendor field in service ticket --- .../service-ticket/v1/service-ticket.data.ts | 5 +++ .../v1/service-ticket.domain.ts | 17 ++++++++- .../http-graphql/schema/builder/generated.ts | 4 +++ .../schema/builder/graphql.schema.json | 36 +++++++++++++++++++ .../schema/types/service-ticket.graphql | 4 ++- .../mongodb/models/cases/service-ticket.ts | 4 ++- ui-community/src/generated.tsx | 3 ++ 7 files changed, 70 insertions(+), 3 deletions(-) diff --git a/data-access/src/app/application-services/cases/service-ticket/v1/service-ticket.data.ts b/data-access/src/app/application-services/cases/service-ticket/v1/service-ticket.data.ts index 9c367ace..1a8a3671 100644 --- a/data-access/src/app/application-services/cases/service-ticket/v1/service-ticket.data.ts +++ b/data-access/src/app/application-services/cases/service-ticket/v1/service-ticket.data.ts @@ -9,6 +9,7 @@ export interface ServiceTicketV1DataApi { getServiceTicketsOpenByRequestor(memberId: string): Promise; getServiceTicketsClosedByRequestor(memberId: string): Promise; getServiceTicketsByAssignedTo(communityId: string, memberId: string): Promise; + getServiceTicketsByVendor(vendorId: string): Promise; } export class ServiceTicketV1DataApiImpl @@ -37,6 +38,10 @@ export class ServiceTicketV1DataApiImpl let dbData = await this.findByFields({ community: communityId, assignedTo: memberId }); return this.applyPermissionFilter(dbData, this.context); } + async getServiceTicketsByVendor(vendorId: string): Promise { + let dbData = await this.findByFields({ assignedVendor: vendorId }); + return this.applyPermissionFilter(dbData, this.context); + } private async applyPermissionFilter(serviceTickets: ServiceTicketData[], context: AppContext): Promise { let converter = new ServiceTicketV1Converter(); diff --git a/data-access/src/app/application-services/cases/service-ticket/v1/service-ticket.domain.ts b/data-access/src/app/application-services/cases/service-ticket/v1/service-ticket.domain.ts index 335108e4..51c264cb 100644 --- a/data-access/src/app/application-services/cases/service-ticket/v1/service-ticket.domain.ts +++ b/data-access/src/app/application-services/cases/service-ticket/v1/service-ticket.domain.ts @@ -73,6 +73,14 @@ export class ServiceTicketV1DomainApiImpl extends DomainDataSource>>; assignedTo?: Maybe; + assignedVendor?: Maybe; community: Community; createdAt?: Maybe; description: Scalars['String']; @@ -1517,6 +1518,7 @@ export type ServiceTicketChangeStatusInput = { }; export type ServiceTicketCreateInput = { + assignedVendor?: InputMaybe; description: Scalars['String']; propertyId: Scalars['ObjectID']; requestorId?: InputMaybe; @@ -1575,6 +1577,7 @@ export type ServiceTicketSubmitInput = { }; export type ServiceTicketUpdateInput = { + assignedVendor?: InputMaybe; description?: InputMaybe; messages?: InputMaybe>>; priority?: InputMaybe; @@ -3800,6 +3803,7 @@ export type ServiceTicketResolvers< > = ResolversObject<{ activityLog?: Resolver>>, ParentType, ContextType>; assignedTo?: Resolver, ParentType, ContextType>; + assignedVendor?: Resolver, ParentType, ContextType>; community?: Resolver; createdAt?: Resolver, ParentType, ContextType>; description?: Resolver; diff --git a/data-access/src/functions/http-graphql/schema/builder/graphql.schema.json b/data-access/src/functions/http-graphql/schema/builder/graphql.schema.json index de2f70b4..3943dca3 100644 --- a/data-access/src/functions/http-graphql/schema/builder/graphql.schema.json +++ b/data-access/src/functions/http-graphql/schema/builder/graphql.schema.json @@ -11782,6 +11782,18 @@ "isDeprecated": false, "deprecationReason": null }, + { + "name": "assignedVendor", + "description": null, + "args": [], + "type": { + "kind": "SCALAR", + "name": "String", + "ofType": null + }, + "isDeprecated": false, + "deprecationReason": null + }, { "name": "community", "description": null, @@ -12341,6 +12353,18 @@ "description": null, "fields": null, "inputFields": [ + { + "name": "assignedVendor", + "description": null, + "type": { + "kind": "SCALAR", + "name": "String", + "ofType": null + }, + "defaultValue": null, + "isDeprecated": false, + "deprecationReason": null + }, { "name": "description", "description": null, @@ -12862,6 +12886,18 @@ "description": null, "fields": null, "inputFields": [ + { + "name": "assignedVendor", + "description": null, + "type": { + "kind": "SCALAR", + "name": "String", + "ofType": null + }, + "defaultValue": null, + "isDeprecated": false, + "deprecationReason": null + }, { "name": "description", "description": null, diff --git a/data-access/src/functions/http-graphql/schema/types/service-ticket.graphql b/data-access/src/functions/http-graphql/schema/types/service-ticket.graphql index 15227709..f4736c46 100644 --- a/data-access/src/functions/http-graphql/schema/types/service-ticket.graphql +++ b/data-access/src/functions/http-graphql/schema/types/service-ticket.graphql @@ -13,7 +13,7 @@ type ServiceTicket implements MongoBase { activityLog: [ServiceTicketActivityDetail] messages: [ServiceTicketV1Message] revisionRequest: ServiceTicketV1RevisionRequest - + assignedVendor: String id: ObjectID! schemaVersion: String createdAt: DateTime @@ -104,6 +104,7 @@ input ServiceTicketCreateInput { title: String! description: String! serviceId: ObjectID + assignedVendor:String } input ServiceTicketUpdateInput { @@ -115,6 +116,7 @@ input ServiceTicketUpdateInput { serviceId: ObjectID messages: [ServiceTicketV1MessageInput] revisionRequest: ServiceTicketV1RevisionRequestUpdateInput + assignedVendor:String } input ServiceTicketV1MessageInput { diff --git a/data-access/src/infrastructure-services-impl/datastore/mongodb/models/cases/service-ticket.ts b/data-access/src/infrastructure-services-impl/datastore/mongodb/models/cases/service-ticket.ts index 8d9d7284..171e1353 100644 --- a/data-access/src/infrastructure-services-impl/datastore/mongodb/models/cases/service-ticket.ts +++ b/data-access/src/infrastructure-services-impl/datastore/mongodb/models/cases/service-ticket.ts @@ -114,6 +114,7 @@ export interface ServiceTicket extends Ticket { hash: string; lastIndexed: Date; updateIndexFailedDate: Date; + assignedVendor: string } const ServiceTicketSchema = new Schema, ServiceTicket>( @@ -159,8 +160,9 @@ const ServiceTicketSchema = new Schema, Serv hash: { type: String, required: false, maxlength: 100 }, lastIndexed: { type: Date, required: false }, updateIndexFailedDate: { type: Date, required: false }, + assignedVendor: { type: String, required: false } }, - ticketOptions + ticketOptions, ); // TODO: Discriminator key and Version can't exist together, if we don't use version key it will fall back to __v diff --git a/ui-community/src/generated.tsx b/ui-community/src/generated.tsx index 92d92456..5baf10d8 100644 --- a/ui-community/src/generated.tsx +++ b/ui-community/src/generated.tsx @@ -1463,6 +1463,7 @@ export type ServiceTicket = MongoBase & { __typename?: 'ServiceTicket'; activityLog?: Maybe>>; assignedTo?: Maybe; + assignedVendor?: Maybe; community: Community; createdAt?: Maybe; description: Scalars['String']; @@ -1515,6 +1516,7 @@ export type ServiceTicketChangeStatusInput = { }; export type ServiceTicketCreateInput = { + assignedVendor?: InputMaybe; description: Scalars['String']; propertyId: Scalars['ObjectID']; requestorId?: InputMaybe; @@ -1573,6 +1575,7 @@ export type ServiceTicketSubmitInput = { }; export type ServiceTicketUpdateInput = { + assignedVendor?: InputMaybe; description?: InputMaybe; messages?: InputMaybe>>; priority?: InputMaybe; From 17d53e9c016b9b6ad58be1715d2d08fcff5acf5d Mon Sep 17 00:00:00 2001 From: Kevin Delong Date: Fri, 13 Dec 2024 10:30:46 -0500 Subject: [PATCH 02/12] update: community schema for approved vendors --- .../datastore/mongodb/models/community.ts | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/data-access/src/infrastructure-services-impl/datastore/mongodb/models/community.ts b/data-access/src/infrastructure-services-impl/datastore/mongodb/models/community.ts index 707d837e..45e915f1 100644 --- a/data-access/src/infrastructure-services-impl/datastore/mongodb/models/community.ts +++ b/data-access/src/infrastructure-services-impl/datastore/mongodb/models/community.ts @@ -2,14 +2,31 @@ import { Schema, model, Model, ObjectId, PopulatedDoc } from 'mongoose'; import { Base } from '../../../../../seedwork/services-seedwork-datastore-mongodb/interfaces/base'; import * as EndUser from './users/end-user'; + +export interface ApprovedVendor { + vendorId: string; //ref of vendor user record form mongoDB + displayName: string; //name of vendor user + email: string; //email of vendor user + approvedBy: string; //ref of staff user record from mongoDB + approvedAt: Date; +} export interface Community extends Base { name: string; domain: string; whiteLabelDomain: string; handle: string; + approvedVendors?: ApprovedVendor[]; createdBy:PopulatedDoc | ObjectId; } +export const approvedVendorSchema = new Schema, ApprovedVendor>({ + vendorId: { type: String, required: true }, + displayName: { type: String, required: true }, + email: { type: String, required: true }, + approvedBy: { type: String, required: true }, + approvedAt: { type: Date, required: true }, +}) + export const CommunityModel = model('Community',new Schema, Community>( { schemaVersion: { type: String, default: '1.0.0' }, @@ -25,6 +42,7 @@ export const CommunityModel = model('Community',new Schema Date: Fri, 13 Dec 2024 11:00:38 -0500 Subject: [PATCH 03/12] chore: run gen to update generated.ts --- .../http-graphql/schema/builder/generated.ts | 26 ++++++ .../schema/builder/graphql.schema.json | 87 +++++++++++++++++++ .../schema/types/community.graphql | 9 ++ ui-community/src/generated.tsx | 10 +++ 4 files changed, 132 insertions(+) diff --git a/data-access/src/functions/http-graphql/schema/builder/generated.ts b/data-access/src/functions/http-graphql/schema/builder/generated.ts index 561b6b7c..a0a36424 100644 --- a/data-access/src/functions/http-graphql/schema/builder/generated.ts +++ b/data-access/src/functions/http-graphql/schema/builder/generated.ts @@ -192,6 +192,15 @@ export type Approval = { isApplicantApproved?: Maybe; }; +export type ApprovedVendors = { + __typename?: 'ApprovedVendors'; + approvedAt?: Maybe; + approvedBy?: Maybe; + displayName?: Maybe; + email?: Maybe; + vendorId?: Maybe; +}; + export type BedroomDetails = MongoSubdocument & { __typename?: 'BedroomDetails'; bedDescriptions?: Maybe>>; @@ -237,6 +246,7 @@ export enum CacheControlScope { export type Community = MongoBase & { __typename?: 'Community'; + approvedVendors?: Maybe>>; createdAt?: Maybe; domain?: Maybe; domainStatus?: Maybe; @@ -2155,6 +2165,7 @@ export type ResolversTypes = ResolversObject<{ AdhocPaymentRequestInput: AdhocPaymentRequestInput; AdhocTransaction: ResolverTypeWrapper; Approval: ResolverTypeWrapper; + ApprovedVendors: ResolverTypeWrapper; BedroomDetails: ResolverTypeWrapper; BedroomDetailsInput: BedroomDetailsInput; BigInt: ResolverTypeWrapper; @@ -2437,6 +2448,7 @@ export type ResolversParentTypes = ResolversObject<{ AdhocPaymentRequestInput: AdhocPaymentRequestInput; AdhocTransaction: AdhocTransaction; Approval: Approval; + ApprovedVendors: ApprovedVendors; BedroomDetails: BedroomDetails; BedroomDetailsInput: BedroomDetailsInput; BigInt: Scalars['BigInt']; @@ -2786,6 +2798,18 @@ export type ApprovalResolvers; }>; +export type ApprovedVendorsResolvers< + ContextType = GraphqlContext, + ParentType extends ResolversParentTypes['ApprovedVendors'] = ResolversParentTypes['ApprovedVendors'], +> = ResolversObject<{ + approvedAt?: Resolver, ParentType, ContextType>; + approvedBy?: Resolver, ParentType, ContextType>; + displayName?: Resolver, ParentType, ContextType>; + email?: Resolver, ParentType, ContextType>; + vendorId?: Resolver, ParentType, ContextType>; + __isTypeOf?: IsTypeOfResolverFn; +}>; + export type BedroomDetailsResolvers< ContextType = GraphqlContext, ParentType extends ResolversParentTypes['BedroomDetails'] = ResolversParentTypes['BedroomDetails'], @@ -2838,6 +2862,7 @@ export interface ByteScalarConfig extends GraphQLScalarTypeConfig = ResolversObject<{ + approvedVendors?: Resolver>>, ParentType, ContextType>; createdAt?: Resolver, ParentType, ContextType>; domain?: Resolver, ParentType, ContextType>; domainStatus?: Resolver, ParentType, ContextType>; @@ -4253,6 +4278,7 @@ export type Resolvers = ResolversObject<{ Address?: AddressResolvers; AdhocTransaction?: AdhocTransactionResolvers; Approval?: ApprovalResolvers; + ApprovedVendors?: ApprovedVendorsResolvers; BedroomDetails?: BedroomDetailsResolvers; BigInt?: GraphQLScalarType; BlobAuthHeader?: BlobAuthHeaderResolvers; diff --git a/data-access/src/functions/http-graphql/schema/builder/graphql.schema.json b/data-access/src/functions/http-graphql/schema/builder/graphql.schema.json index 3943dca3..88ea4370 100644 --- a/data-access/src/functions/http-graphql/schema/builder/graphql.schema.json +++ b/data-access/src/functions/http-graphql/schema/builder/graphql.schema.json @@ -1186,6 +1186,77 @@ "enumValues": null, "possibleTypes": null }, + { + "kind": "OBJECT", + "name": "ApprovedVendors", + "description": null, + "fields": [ + { + "name": "approvedAt", + "description": null, + "args": [], + "type": { + "kind": "SCALAR", + "name": "String", + "ofType": null + }, + "isDeprecated": false, + "deprecationReason": null + }, + { + "name": "approvedBy", + "description": null, + "args": [], + "type": { + "kind": "SCALAR", + "name": "String", + "ofType": null + }, + "isDeprecated": false, + "deprecationReason": null + }, + { + "name": "displayName", + "description": null, + "args": [], + "type": { + "kind": "SCALAR", + "name": "String", + "ofType": null + }, + "isDeprecated": false, + "deprecationReason": null + }, + { + "name": "email", + "description": null, + "args": [], + "type": { + "kind": "SCALAR", + "name": "String", + "ofType": null + }, + "isDeprecated": false, + "deprecationReason": null + }, + { + "name": "vendorId", + "description": null, + "args": [], + "type": { + "kind": "SCALAR", + "name": "String", + "ofType": null + }, + "isDeprecated": false, + "deprecationReason": null + } + ], + "inputFields": null, + "interfaces": [], + "enumValues": null, + "possibleTypes": null + }, { "kind": "OBJECT", "name": "BedroomDetails", @@ -1557,6 +1628,22 @@ "name": "Community", "description": null, "fields": [ + { + "name": "approvedVendors", + "description": null, + "args": [], + "type": { + "kind": "LIST", + "name": null, + "ofType": { + "kind": "OBJECT", + "name": "ApprovedVendors", + "ofType": null + } + }, + "isDeprecated": false, + "deprecationReason": null + }, { "name": "createdAt", "description": null, diff --git a/data-access/src/functions/http-graphql/schema/types/community.graphql b/data-access/src/functions/http-graphql/schema/types/community.graphql index d2214b6e..10d6b416 100644 --- a/data-access/src/functions/http-graphql/schema/types/community.graphql +++ b/data-access/src/functions/http-graphql/schema/types/community.graphql @@ -13,6 +13,15 @@ type Community implements MongoBase { createdAt: DateTime updatedAt: DateTime userIsAdmin: Boolean + approvedVendors: [ApprovedVendors] +} + +type ApprovedVendors { + vendorId: String + displayName: String + email: String + approvedBy: String + approvedAt: String } type CommunityDomainResult { diff --git a/ui-community/src/generated.tsx b/ui-community/src/generated.tsx index 5baf10d8..0cf5526e 100644 --- a/ui-community/src/generated.tsx +++ b/ui-community/src/generated.tsx @@ -190,6 +190,15 @@ export type Approval = { isApplicantApproved?: Maybe; }; +export type ApprovedVendors = { + __typename?: 'ApprovedVendors'; + approvedAt?: Maybe; + approvedBy?: Maybe; + displayName?: Maybe; + email?: Maybe; + vendorId?: Maybe; +}; + export type BedroomDetails = MongoSubdocument & { __typename?: 'BedroomDetails'; bedDescriptions?: Maybe>>; @@ -235,6 +244,7 @@ export enum CacheControlScope { export type Community = MongoBase & { __typename?: 'Community'; + approvedVendors?: Maybe>>; createdAt?: Maybe; domain?: Maybe; domainStatus?: Maybe; From 012a708ecb730154787bd8ff9668ea6d45e7fb06 Mon Sep 17 00:00:00 2001 From: Kevin Delong Date: Fri, 13 Dec 2024 11:13:29 -0500 Subject: [PATCH 04/12] update: CommunityUpdateInput body --- .../http-graphql/schema/builder/generated.ts | 11 +++ .../schema/builder/graphql.schema.json | 87 +++++++++++++++++++ .../schema/types/community.graphql | 9 ++ ui-community/src/generated.tsx | 9 ++ 4 files changed, 116 insertions(+) diff --git a/data-access/src/functions/http-graphql/schema/builder/generated.ts b/data-access/src/functions/http-graphql/schema/builder/generated.ts index a0a36424..a023d471 100644 --- a/data-access/src/functions/http-graphql/schema/builder/generated.ts +++ b/data-access/src/functions/http-graphql/schema/builder/generated.ts @@ -201,6 +201,14 @@ export type ApprovedVendors = { vendorId?: Maybe; }; +export type ApprovedVendorsInput = { + approvedAt?: InputMaybe; + approvedBy?: InputMaybe; + displayName?: InputMaybe; + email?: InputMaybe; + vendorId?: InputMaybe; +}; + export type BedroomDetails = MongoSubdocument & { __typename?: 'BedroomDetails'; bedDescriptions?: Maybe>>; @@ -336,6 +344,7 @@ export type CommunityPublicFileRemoveInput = { }; export type CommunityUpdateInput = { + approvedVendors?: InputMaybe>>; domain?: InputMaybe; handle?: InputMaybe; id: Scalars['ID']; @@ -2166,6 +2175,7 @@ export type ResolversTypes = ResolversObject<{ AdhocTransaction: ResolverTypeWrapper; Approval: ResolverTypeWrapper; ApprovedVendors: ResolverTypeWrapper; + ApprovedVendorsInput: ApprovedVendorsInput; BedroomDetails: ResolverTypeWrapper; BedroomDetailsInput: BedroomDetailsInput; BigInt: ResolverTypeWrapper; @@ -2449,6 +2459,7 @@ export type ResolversParentTypes = ResolversObject<{ AdhocTransaction: AdhocTransaction; Approval: Approval; ApprovedVendors: ApprovedVendors; + ApprovedVendorsInput: ApprovedVendorsInput; BedroomDetails: BedroomDetails; BedroomDetailsInput: BedroomDetailsInput; BigInt: Scalars['BigInt']; diff --git a/data-access/src/functions/http-graphql/schema/builder/graphql.schema.json b/data-access/src/functions/http-graphql/schema/builder/graphql.schema.json index 88ea4370..2a463c0d 100644 --- a/data-access/src/functions/http-graphql/schema/builder/graphql.schema.json +++ b/data-access/src/functions/http-graphql/schema/builder/graphql.schema.json @@ -1257,6 +1257,77 @@ "enumValues": null, "possibleTypes": null }, + { + "kind": "INPUT_OBJECT", + "name": "ApprovedVendorsInput", + "description": null, + "fields": null, + "inputFields": [ + { + "name": "approvedAt", + "description": null, + "type": { + "kind": "SCALAR", + "name": "String", + "ofType": null + }, + "defaultValue": null, + "isDeprecated": false, + "deprecationReason": null + }, + { + "name": "approvedBy", + "description": null, + "type": { + "kind": "SCALAR", + "name": "String", + "ofType": null + }, + "defaultValue": null, + "isDeprecated": false, + "deprecationReason": null + }, + { + "name": "displayName", + "description": null, + "type": { + "kind": "SCALAR", + "name": "String", + "ofType": null + }, + "defaultValue": null, + "isDeprecated": false, + "deprecationReason": null + }, + { + "name": "email", + "description": null, + "type": { + "kind": "SCALAR", + "name": "String", + "ofType": null + }, + "defaultValue": null, + "isDeprecated": false, + "deprecationReason": null + }, + { + "name": "vendorId", + "description": null, + "type": { + "kind": "SCALAR", + "name": "String", + "ofType": null + }, + "defaultValue": null, + "isDeprecated": false, + "deprecationReason": null + } + ], + "interfaces": null, + "enumValues": null, + "possibleTypes": null + }, { "kind": "OBJECT", "name": "BedroomDetails", @@ -2475,6 +2546,22 @@ "description": null, "fields": null, "inputFields": [ + { + "name": "approvedVendors", + "description": null, + "type": { + "kind": "LIST", + "name": null, + "ofType": { + "kind": "INPUT_OBJECT", + "name": "ApprovedVendorsInput", + "ofType": null + } + }, + "defaultValue": null, + "isDeprecated": false, + "deprecationReason": null + }, { "name": "domain", "description": null, diff --git a/data-access/src/functions/http-graphql/schema/types/community.graphql b/data-access/src/functions/http-graphql/schema/types/community.graphql index 10d6b416..a67c3919 100644 --- a/data-access/src/functions/http-graphql/schema/types/community.graphql +++ b/data-access/src/functions/http-graphql/schema/types/community.graphql @@ -24,6 +24,14 @@ type ApprovedVendors { approvedAt: String } +input ApprovedVendorsInput { + vendorId: String + displayName: String + email: String + approvedBy: String + approvedAt: String +} + type CommunityDomainResult { verified: Boolean verification: [CommunityDomainVerificationDetail] @@ -67,6 +75,7 @@ input CommunityUpdateInput { domain: String whiteLabelDomain: String handle: String + approvedVendors: [ApprovedVendorsInput] } input CommunityBlobFileInput { diff --git a/ui-community/src/generated.tsx b/ui-community/src/generated.tsx index 0cf5526e..482c1712 100644 --- a/ui-community/src/generated.tsx +++ b/ui-community/src/generated.tsx @@ -199,6 +199,14 @@ export type ApprovedVendors = { vendorId?: Maybe; }; +export type ApprovedVendorsInput = { + approvedAt?: InputMaybe; + approvedBy?: InputMaybe; + displayName?: InputMaybe; + email?: InputMaybe; + vendorId?: InputMaybe; +}; + export type BedroomDetails = MongoSubdocument & { __typename?: 'BedroomDetails'; bedDescriptions?: Maybe>>; @@ -334,6 +342,7 @@ export type CommunityPublicFileRemoveInput = { }; export type CommunityUpdateInput = { + approvedVendors?: InputMaybe>>; domain?: InputMaybe; handle?: InputMaybe; id: Scalars['ID']; From c1624c29f1e82062ffa2cb3f74da7a523192f364 Mon Sep 17 00:00:00 2001 From: Kevin Delong Date: Fri, 13 Dec 2024 11:49:19 -0500 Subject: [PATCH 05/12] update: community domain for approved vendors --- .../interfaces/base.ts | 5 ++ .../community/community.domain.ts | 10 +++ .../users/vendor-user/vendor-user.data.ts | 12 ++-- .../contexts/community/community/community.ts | 9 +++ .../community/community.value-objects.ts | 19 ++++-- .../http-graphql/schema/builder/generated.ts | 11 ++-- .../schema/builder/graphql.schema.json | 64 ++++++++----------- .../schema/types/community.graphql | 10 ++- .../community/community.domain-adapter.ts | 8 +++ .../datastore/mongodb/models/community.ts | 2 - ui-community/src/generated.tsx | 10 ++- 11 files changed, 91 insertions(+), 69 deletions(-) diff --git a/data-access/seedwork/services-seedwork-datastore-mongodb/interfaces/base.ts b/data-access/seedwork/services-seedwork-datastore-mongodb/interfaces/base.ts index c4a03caf..fd4bfbf3 100644 --- a/data-access/seedwork/services-seedwork-datastore-mongodb/interfaces/base.ts +++ b/data-access/seedwork/services-seedwork-datastore-mongodb/interfaces/base.ts @@ -44,3 +44,8 @@ export const Patterns = { EMAIL_PATTERN: /^[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+@[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)*$/, GUID_PATTERN: /^[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i, }; + + +export type FindQuery = { + _id: { $in: string[] }; +}; \ No newline at end of file diff --git a/data-access/src/app/application-services/community/community.domain.ts b/data-access/src/app/application-services/community/community.domain.ts index ec8f2637..bf0f0380 100644 --- a/data-access/src/app/application-services/community/community.domain.ts +++ b/data-access/src/app/application-services/community/community.domain.ts @@ -44,6 +44,15 @@ export class CommunityDomainApiImpl throw new Error('Unauthorized'); } + if(community.approvedVendors){ + const {approvedVendors} = community; + const vendorIds:string[] = approvedVendors.map((vendor) => vendor.vendorId); + const vendors = await this._context.applicationServices.users.vendorUser.dataApi.getUsers({ _id: { $in: vendorIds } }); + if(vendors.length !== approvedVendors.length){ + throw new Error('Not all approved vendors exist'); + } + } + let result: CommunityData; await this.withTransaction(async (repo) => { let domainObject = await repo.get(community.id); @@ -54,6 +63,7 @@ export class CommunityDomainApiImpl domainObject.Domain = (community.domain); domainObject.WhiteLabelDomain = (community.whiteLabelDomain); domainObject.Handle = (community.handle); + domainObject.ApprovedVendors = (community.approvedVendors); result = (new CommunityConverter()).toPersistence(await repo.save(domainObject)); }); return result; diff --git a/data-access/src/app/application-services/users/vendor-user/vendor-user.data.ts b/data-access/src/app/application-services/users/vendor-user/vendor-user.data.ts index 410fe89b..f0b3ee23 100644 --- a/data-access/src/app/application-services/users/vendor-user/vendor-user.data.ts +++ b/data-access/src/app/application-services/users/vendor-user/vendor-user.data.ts @@ -1,12 +1,14 @@ import { CosmosDataSource } from "../../../data-sources/cosmos-data-source"; import { VendorUserData } from "../../../external-dependencies/datastore"; import { AppContext } from "../../../init/app-context-builder"; +import { FindQuery } from "../../../../../seedwork/services-seedwork-datastore-mongodb/interfaces/base"; export interface VendorUserDataApi { getUserById(userId : string): Promise; getUserByExternalId(externalId : string): Promise; - getUsers(): Promise; + getUsers(findQuery?: FindQuery): Promise; } + export class VendorUserDataApiImpl extends CosmosDataSource implements VendorUserDataApi { @@ -19,11 +21,11 @@ export class VendorUserDataApiImpl return (await this.findByFields({ externalId: externalId }))[0]; } - async getUsers(): Promise { + async getUsers(findQuery?: FindQuery): Promise { console.log(`getUsers:context${JSON.stringify(this.context.verifiedUser)}`); return this.model - .find({}) - .exec(); + .find(findQuery && typeof findQuery === 'object' ? findQuery : {}) // Ensures it's an object before using it + .exec(); } - + } diff --git a/data-access/src/app/domain/contexts/community/community/community.ts b/data-access/src/app/domain/contexts/community/community/community.ts index 0ea3c30e..574234e2 100644 --- a/data-access/src/app/domain/contexts/community/community/community.ts +++ b/data-access/src/app/domain/contexts/community/community/community.ts @@ -6,6 +6,7 @@ import { DomainExecutionContext, SystemDomainExecutionContext } from '../../../d import { CommunityVisa } from "../community.visa"; import { EndUser, EndUserEntityReference, EndUserProps } from '../../users/end-user/end-user'; import * as ValueObjects from './community.value-objects'; +import { ApprovedVendor } from '../../../../../infrastructure-services-impl/datastore/mongodb/models/community'; export interface CommunityProps extends DomainEntityProps { name: string; @@ -17,6 +18,7 @@ export interface CommunityProps extends DomainEntityProps { readonly schemaVersion: string; readonly createdBy: EndUserProps; setCreatedByRef(user: EndUserEntityReference): void; + approvedVendors?: ApprovedVendor[]; } export interface CommunityEntityReference extends Readonly> { @@ -110,6 +112,13 @@ export class Community extends AggregateRoot permissions.canManageCommunitySettings)) { + throw new Error('You do not have permission to change the handle of this community'); + } + this.props.approvedVendors = approvedVendors ? new ValueObjects.ApprovedVendors(approvedVendors).valueOf() : null; + } + set CreatedBy(createdBy: EndUserEntityReference) { if (!this.isNew && !this.visa.determineIf((permissions) => permissions.canManageCommunitySettings)) { throw new Error('You do not have permission to change the created by of this community'); diff --git a/data-access/src/app/domain/contexts/community/community/community.value-objects.ts b/data-access/src/app/domain/contexts/community/community/community.value-objects.ts index 52916af7..c24a6d2c 100644 --- a/data-access/src/app/domain/contexts/community/community/community.value-objects.ts +++ b/data-access/src/app/domain/contexts/community/community/community.value-objects.ts @@ -1,8 +1,13 @@ -import { - VOString -} from '@lucaspaganini/value-objects'; +import { VOArray, VOObject, VOString } from '@lucaspaganini/value-objects'; -export class Name extends VOString({trim:true, maxLength:200}) {} -export class Domain extends VOString({trim:true, maxLength:500}) {} -export class WhiteLabelDomain extends VOString({trim:true, maxLength:500}) {} -export class Handle extends VOString({trim:true, maxLength:50}) {} \ No newline at end of file +export class Name extends VOString({ trim: true, maxLength: 200 }) {} +export class Domain extends VOString({ trim: true, maxLength: 500 }) {} +export class WhiteLabelDomain extends VOString({ trim: true, maxLength: 500 }) {} +export class Handle extends VOString({ trim: true, maxLength: 50 }) {} +class ApprovedVendor extends VOObject({ + vendorId: String, + displayName: String, + email: String, + approvedBy: String, +}) {} +export class ApprovedVendors extends VOArray(ApprovedVendor, { maxLength: 50 }) {} diff --git a/data-access/src/functions/http-graphql/schema/builder/generated.ts b/data-access/src/functions/http-graphql/schema/builder/generated.ts index a023d471..8de77d3d 100644 --- a/data-access/src/functions/http-graphql/schema/builder/generated.ts +++ b/data-access/src/functions/http-graphql/schema/builder/generated.ts @@ -194,7 +194,6 @@ export type Approval = { export type ApprovedVendors = { __typename?: 'ApprovedVendors'; - approvedAt?: Maybe; approvedBy?: Maybe; displayName?: Maybe; email?: Maybe; @@ -202,11 +201,10 @@ export type ApprovedVendors = { }; export type ApprovedVendorsInput = { - approvedAt?: InputMaybe; - approvedBy?: InputMaybe; - displayName?: InputMaybe; - email?: InputMaybe; - vendorId?: InputMaybe; + approvedBy: Scalars['String']; + displayName: Scalars['String']; + email: Scalars['String']; + vendorId: Scalars['String']; }; export type BedroomDetails = MongoSubdocument & { @@ -2813,7 +2811,6 @@ export type ApprovedVendorsResolvers< ContextType = GraphqlContext, ParentType extends ResolversParentTypes['ApprovedVendors'] = ResolversParentTypes['ApprovedVendors'], > = ResolversObject<{ - approvedAt?: Resolver, ParentType, ContextType>; approvedBy?: Resolver, ParentType, ContextType>; displayName?: Resolver, ParentType, ContextType>; email?: Resolver, ParentType, ContextType>; diff --git a/data-access/src/functions/http-graphql/schema/builder/graphql.schema.json b/data-access/src/functions/http-graphql/schema/builder/graphql.schema.json index 2a463c0d..ce8384ca 100644 --- a/data-access/src/functions/http-graphql/schema/builder/graphql.schema.json +++ b/data-access/src/functions/http-graphql/schema/builder/graphql.schema.json @@ -1191,18 +1191,6 @@ "name": "ApprovedVendors", "description": null, "fields": [ - { - "name": "approvedAt", - "description": null, - "args": [], - "type": { - "kind": "SCALAR", - "name": "String", - "ofType": null - }, - "isDeprecated": false, - "deprecationReason": null - }, { "name": "approvedBy", "description": null, @@ -1263,25 +1251,17 @@ "description": null, "fields": null, "inputFields": [ - { - "name": "approvedAt", - "description": null, - "type": { - "kind": "SCALAR", - "name": "String", - "ofType": null - }, - "defaultValue": null, - "isDeprecated": false, - "deprecationReason": null - }, { "name": "approvedBy", "description": null, "type": { - "kind": "SCALAR", - "name": "String", - "ofType": null + "kind": "NON_NULL", + "name": null, + "ofType": { + "kind": "SCALAR", + "name": "String", + "ofType": null + } }, "defaultValue": null, "isDeprecated": false, @@ -1291,9 +1271,13 @@ "name": "displayName", "description": null, "type": { - "kind": "SCALAR", - "name": "String", - "ofType": null + "kind": "NON_NULL", + "name": null, + "ofType": { + "kind": "SCALAR", + "name": "String", + "ofType": null + } }, "defaultValue": null, "isDeprecated": false, @@ -1303,9 +1287,13 @@ "name": "email", "description": null, "type": { - "kind": "SCALAR", - "name": "String", - "ofType": null + "kind": "NON_NULL", + "name": null, + "ofType": { + "kind": "SCALAR", + "name": "String", + "ofType": null + } }, "defaultValue": null, "isDeprecated": false, @@ -1315,9 +1303,13 @@ "name": "vendorId", "description": null, "type": { - "kind": "SCALAR", - "name": "String", - "ofType": null + "kind": "NON_NULL", + "name": null, + "ofType": { + "kind": "SCALAR", + "name": "String", + "ofType": null + } }, "defaultValue": null, "isDeprecated": false, diff --git a/data-access/src/functions/http-graphql/schema/types/community.graphql b/data-access/src/functions/http-graphql/schema/types/community.graphql index a67c3919..8d4bef03 100644 --- a/data-access/src/functions/http-graphql/schema/types/community.graphql +++ b/data-access/src/functions/http-graphql/schema/types/community.graphql @@ -21,15 +21,13 @@ type ApprovedVendors { displayName: String email: String approvedBy: String - approvedAt: String } input ApprovedVendorsInput { - vendorId: String - displayName: String - email: String - approvedBy: String - approvedAt: String + vendorId: String! + displayName: String! + email: String! + approvedBy: String! } type CommunityDomainResult { diff --git a/data-access/src/infrastructure-services-impl/datastore/mongodb/infrastructure/community/community.domain-adapter.ts b/data-access/src/infrastructure-services-impl/datastore/mongodb/infrastructure/community/community.domain-adapter.ts index 717c64f1..a3859eab 100644 --- a/data-access/src/infrastructure-services-impl/datastore/mongodb/infrastructure/community/community.domain-adapter.ts +++ b/data-access/src/infrastructure-services-impl/datastore/mongodb/infrastructure/community/community.domain-adapter.ts @@ -50,6 +50,14 @@ export class CommunityDomainAdapter extends MongooseDomainAdapter('Community',new Schema, Community>( diff --git a/ui-community/src/generated.tsx b/ui-community/src/generated.tsx index 482c1712..ccae0a9b 100644 --- a/ui-community/src/generated.tsx +++ b/ui-community/src/generated.tsx @@ -192,7 +192,6 @@ export type Approval = { export type ApprovedVendors = { __typename?: 'ApprovedVendors'; - approvedAt?: Maybe; approvedBy?: Maybe; displayName?: Maybe; email?: Maybe; @@ -200,11 +199,10 @@ export type ApprovedVendors = { }; export type ApprovedVendorsInput = { - approvedAt?: InputMaybe; - approvedBy?: InputMaybe; - displayName?: InputMaybe; - email?: InputMaybe; - vendorId?: InputMaybe; + approvedBy: Scalars['String']; + displayName: Scalars['String']; + email: Scalars['String']; + vendorId: Scalars['String']; }; export type BedroomDetails = MongoSubdocument & { From c8c494940a2a8c576084370fa02964c12514fa44 Mon Sep 17 00:00:00 2001 From: Kevin Delong Date: Fri, 13 Dec 2024 13:18:14 -0500 Subject: [PATCH 06/12] chore: make query optional --- .../services-seedwork-datastore-mongodb/interfaces/base.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/data-access/seedwork/services-seedwork-datastore-mongodb/interfaces/base.ts b/data-access/seedwork/services-seedwork-datastore-mongodb/interfaces/base.ts index fd4bfbf3..66bc37a5 100644 --- a/data-access/seedwork/services-seedwork-datastore-mongodb/interfaces/base.ts +++ b/data-access/seedwork/services-seedwork-datastore-mongodb/interfaces/base.ts @@ -47,5 +47,5 @@ export const Patterns = { export type FindQuery = { - _id: { $in: string[] }; + _id?: { $in: string[] }; }; \ No newline at end of file From 78d162cdeb47a7704e02ed19be6db128d179a6f0 Mon Sep 17 00:00:00 2001 From: Kevin Delong Date: Tue, 17 Dec 2024 15:35:18 -0500 Subject: [PATCH 07/12] refactor --- .../interfaces/base.ts | 5 - .../v1/service-ticket.domain.ts | 17 +- .../community/community.domain.ts | 25 +-- .../users/vendor-user/vendor-user.data.ts | 7 +- .../service-ticket/v1/service-ticket-v1.ts | 37 ++++- .../v1/service-ticket.value-objects.ts | 20 ++- .../contexts/community/community/community.ts | 15 +- .../community/community.value-objects.ts | 10 +- .../http-graphql/schema/builder/generated.ts | 42 +---- .../schema/builder/graphql.schema.json | 156 +----------------- .../schema/types/community.graphql | 37 +++-- .../schema/types/community.resolvers.ts | 24 ++- .../schema/types/service-ticket.graphql | 33 +++- .../schema/types/service-ticket.resolvers.ts | 8 +- .../schema/types/vendor-user.graphql | 1 - .../v1/service-ticket.domain-adapter.ts | 8 + .../community/community.domain-adapter.ts | 9 +- .../mongodb/models/cases/service-ticket.ts | 5 +- .../datastore/mongodb/models/community.ts | 20 +-- .../mongodb/models/users/vendor-user.ts | 1 - ui-community/src/generated.tsx | 22 +-- 21 files changed, 201 insertions(+), 301 deletions(-) diff --git a/data-access/seedwork/services-seedwork-datastore-mongodb/interfaces/base.ts b/data-access/seedwork/services-seedwork-datastore-mongodb/interfaces/base.ts index 66bc37a5..1df0878c 100644 --- a/data-access/seedwork/services-seedwork-datastore-mongodb/interfaces/base.ts +++ b/data-access/seedwork/services-seedwork-datastore-mongodb/interfaces/base.ts @@ -43,9 +43,4 @@ export const NestedPathOptions : SchemaOptions = { export const Patterns = { EMAIL_PATTERN: /^[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+@[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)*$/, GUID_PATTERN: /^[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i, -}; - - -export type FindQuery = { - _id?: { $in: string[] }; }; \ No newline at end of file diff --git a/data-access/src/app/application-services/cases/service-ticket/v1/service-ticket.domain.ts b/data-access/src/app/application-services/cases/service-ticket/v1/service-ticket.domain.ts index 51c264cb..f409d478 100644 --- a/data-access/src/app/application-services/cases/service-ticket/v1/service-ticket.domain.ts +++ b/data-access/src/app/application-services/cases/service-ticket/v1/service-ticket.domain.ts @@ -15,6 +15,7 @@ import { ServiceDomainAdapter, ServiceConverter, ServiceTicketV1Converter, + VendorUserConverter, } from '../../../../external-dependencies/domain'; import { ServiceTicketAddUpdateActivityInput, @@ -73,14 +74,6 @@ export class ServiceTicketV1DomainApiImpl extends DomainDataSource vendor.vendorId); - const vendors = await this._context.applicationServices.users.vendorUser.dataApi.getUsers({ _id: { $in: vendorIds } }); - if(vendors.length !== approvedVendors.length){ - throw new Error('Not all approved vendors exist'); + for(const approvedVendor of approvedVendors){ + const vendor = await this._context.applicationServices.users.vendorUser.dataApi.getUserById(approvedVendor.id); + const vendorDo = new VendorUserConverter().toDomain(vendor, ReadOnlyInfrastructureContext(), ReadOnlyDomainExecutionContext()); + vendorsList.push(vendorDo); } } - + const updatedCommunity = {...community, approvedVendors: vendorsList} + let result: CommunityData; await this.withTransaction(async (repo) => { let domainObject = await repo.get(community.id); if (!domainObject) { throw new Error('invalid id'); } - domainObject.Name = (community.name); - domainObject.Domain = (community.domain); - domainObject.WhiteLabelDomain = (community.whiteLabelDomain); - domainObject.Handle = (community.handle); - domainObject.ApprovedVendors = (community.approvedVendors); + domainObject.Name = (updatedCommunity.name); + domainObject.Domain = (updatedCommunity.domain); + domainObject.WhiteLabelDomain = (updatedCommunity.whiteLabelDomain); + domainObject.Handle = (updatedCommunity.handle); + domainObject.ApprovedVendors = (updatedCommunity.approvedVendors); result = (new CommunityConverter()).toPersistence(await repo.save(domainObject)); }); return result; diff --git a/data-access/src/app/application-services/users/vendor-user/vendor-user.data.ts b/data-access/src/app/application-services/users/vendor-user/vendor-user.data.ts index f0b3ee23..a763734b 100644 --- a/data-access/src/app/application-services/users/vendor-user/vendor-user.data.ts +++ b/data-access/src/app/application-services/users/vendor-user/vendor-user.data.ts @@ -1,12 +1,11 @@ import { CosmosDataSource } from "../../../data-sources/cosmos-data-source"; import { VendorUserData } from "../../../external-dependencies/datastore"; import { AppContext } from "../../../init/app-context-builder"; -import { FindQuery } from "../../../../../seedwork/services-seedwork-datastore-mongodb/interfaces/base"; export interface VendorUserDataApi { getUserById(userId : string): Promise; getUserByExternalId(externalId : string): Promise; - getUsers(findQuery?: FindQuery): Promise; + getUsers(): Promise; } export class VendorUserDataApiImpl @@ -21,10 +20,10 @@ export class VendorUserDataApiImpl return (await this.findByFields({ externalId: externalId }))[0]; } - async getUsers(findQuery?: FindQuery): Promise { + async getUsers(): Promise { console.log(`getUsers:context${JSON.stringify(this.context.verifiedUser)}`); return this.model - .find(findQuery && typeof findQuery === 'object' ? findQuery : {}) // Ensures it's an object before using it + .find() .exec(); } diff --git a/data-access/src/app/domain/contexts/cases/service-ticket/v1/service-ticket-v1.ts b/data-access/src/app/domain/contexts/cases/service-ticket/v1/service-ticket-v1.ts index 157318e0..e8a1f2bd 100644 --- a/data-access/src/app/domain/contexts/cases/service-ticket/v1/service-ticket-v1.ts +++ b/data-access/src/app/domain/contexts/cases/service-ticket/v1/service-ticket-v1.ts @@ -19,7 +19,7 @@ import { ServiceTicketV1Message, ServiceTicketV1MessageEntityReference, ServiceT import { ServiceTicketV1RevisionRequest, ServiceTicketV1RevisionRequestEntityReference, ServiceTicketV1RevisionRequestProps } from './service-ticket-v1-revision-request'; import { ServiceTicketV1SyncDomainEventFactory, ServiceTicketV1SyncDomainEventFactoryImpl } from './sync-domain-events/service-ticket-v1.sync-domain-event-factory'; import { ServiceTicketV1SyncDomainEventHandlers } from './sync-domain-events/service-ticket-v1.sync-domain-event-handlers'; - +import { VendorUserEntityReference, VendorUserProps } from '../../../users/vendor-user/vendor-user'; export interface ServiceTicketV1Props extends DomainEntityProps { readonly community: CommunityProps; @@ -37,6 +37,9 @@ export interface ServiceTicketV1Props extends DomainEntityProps { readonly ticketType?: string; status: string; priority: number; + readonly assignedVendor: VendorUserProps; + setAssignedVendorRef(assignedVendor: VendorUserEntityReference): void; + readonly activityLog: PropArray; readonly messages: PropArray; readonly revisionRequest?: ServiceTicketV1RevisionRequestProps; @@ -69,6 +72,8 @@ export interface ServiceTicketV1EntityReference | 'messages' | 'photos' | 'revisionRequest' + | 'assignedVendor' + | 'setAssignedVendorRef' > > { readonly community: CommunityEntityReference; @@ -80,6 +85,7 @@ export interface ServiceTicketV1EntityReference readonly messages: ReadonlyArray; readonly photos: ReadonlyArray; readonly revisionRequest: ServiceTicketV1RevisionRequestEntityReference; + readonly assignedVendor: VendorUserEntityReference; } export interface ServiceTicketV1RootRegistry extends AggregateRootTypeForApplicationService { @@ -106,7 +112,8 @@ export class ServiceTicketV1 extends Aggrega community: CommunityEntityReference, property: PropertyEntityReference, requestor: MemberEntityReference, - context: DomainExecutionContext + context: DomainExecutionContext, + assignedVendor: VendorUserEntityReference ): ServiceTicketV1 { let serviceTicket = new ServiceTicketV1(newProps, context); serviceTicket.MarkAsNew(); @@ -120,6 +127,7 @@ export class ServiceTicketV1 extends Aggrega serviceTicket.Priority = 5; serviceTicket.syncDomainEventFactory.addServiceTicketV1CreatedEvent({ requestor }); serviceTicket.isNew = false; + serviceTicket.AssignedVendor = assignedVendor; return serviceTicket; } @@ -188,6 +196,10 @@ export class ServiceTicketV1 extends Aggrega return this.props.revisionRequest ? new ServiceTicketV1RevisionRequest(this.props.revisionRequest, this.context, this.visa) : undefined; } + get assignedVendor() { + return this.props.assignedVendor + } + private readonly validStatusTransitions = new Map([ [ValueObjects.StatusCodes.Draft, [ValueObjects.StatusCodes.Submitted]], [ValueObjects.StatusCodes.Submitted, [ValueObjects.StatusCodes.Draft, ValueObjects.StatusCodes.Assigned]], @@ -239,6 +251,16 @@ export class ServiceTicketV1 extends Aggrega this.props.setRequestorRef(requestor); } + private set AssignedVendor(assignedVendor: VendorUserEntityReference) { + if (!this.isNew) { + throw new Error('Unauthorized'); + } + if (!assignedVendor) { + throw new Error('assignedVendor cannot be null or undefined'); + } + this.props.setAssignedVendorRef(assignedVendor); + } + set AssignedTo(assignedTo: MemberEntityReference) { if (!this.isNew && !this.visa.determineIf((permissions) => permissions.isSystemAccount || permissions.canAssignTickets)) { throw new Error('Unauthorized2'); @@ -275,7 +297,18 @@ export class ServiceTicketV1 extends Aggrega } this.props.description = new ValueObjects.Description(description).valueOf(); } + + + setAssignedVendorRef(assignedVendor: VendorUserEntityReference) { + if ( + !this.isNew && + !this.visa.determineIf((permissions) => permissions.isSystemAccount || permissions.canManageTickets || (permissions.canCreateTickets && permissions.isEditingOwnTicket)) + ) { + throw new Error('Unauthorized3b'); + } + this.props.setAssignedVendorRef (assignedVendor) + } set Status(statusCode: ValueObjects.StatusCode) { if (!this.isNew && !this.visa.determineIf((permissions) => permissions.isSystemAccount)) { diff --git a/data-access/src/app/domain/contexts/cases/service-ticket/v1/service-ticket.value-objects.ts b/data-access/src/app/domain/contexts/cases/service-ticket/v1/service-ticket.value-objects.ts index 33a70dad..1dd4f2f3 100644 --- a/data-access/src/app/domain/contexts/cases/service-ticket/v1/service-ticket.value-objects.ts +++ b/data-access/src/app/domain/contexts/cases/service-ticket/v1/service-ticket.value-objects.ts @@ -1,5 +1,4 @@ -import { VOString, VOSet, VOInteger, VOObject, VOOptional } from '@lucaspaganini/value-objects'; -import { DateTime } from 'graphql-scalars/typings/typeDefs'; +import { VOString, VOSet, VOInteger, VOObject, VOOptional, VOArray, VOAny } from '@lucaspaganini/value-objects'; export const StatusCodes = { Draft: 'DRAFT', @@ -10,7 +9,16 @@ export const StatusCodes = { Closed: 'CLOSED', }; -export class Title extends VOString({ trim: true, maxLength: 200, minLength: 5 }) { } -export class Description extends VOString({ trim: true, maxLength: 2000 }) { } -export class StatusCode extends VOSet(Object.values(StatusCodes)) { } -export class Priority extends VOInteger({ min: 1, max: 5 }) { } \ No newline at end of file +export class Title extends VOString({ trim: true, maxLength: 200, minLength: 5 }) {} +export class Description extends VOString({ trim: true, maxLength: 2000 }) {} +export class StatusCode extends VOSet(Object.values(StatusCodes)) {} +export class Priority extends VOInteger({ min: 1, max: 5 }) {} +export class AssignedVendor extends VOObject({ + externalId: VOOptional(VOString()), + displayName: VOOptional(VOString()), + email: VOOptional(VOString()), + accessBlocked: Boolean, + tags: VOOptional(VOArray(VOString())), + id: VOString(), + schemaVersion: VOString(), +}) {} diff --git a/data-access/src/app/domain/contexts/community/community/community.ts b/data-access/src/app/domain/contexts/community/community/community.ts index 574234e2..2f0ee0c9 100644 --- a/data-access/src/app/domain/contexts/community/community/community.ts +++ b/data-access/src/app/domain/contexts/community/community/community.ts @@ -6,7 +6,7 @@ import { DomainExecutionContext, SystemDomainExecutionContext } from '../../../d import { CommunityVisa } from "../community.visa"; import { EndUser, EndUserEntityReference, EndUserProps } from '../../users/end-user/end-user'; import * as ValueObjects from './community.value-objects'; -import { ApprovedVendor } from '../../../../../infrastructure-services-impl/datastore/mongodb/models/community'; +import { VendorUserEntityReference, VendorUserProps } from '../../users/vendor-user/vendor-user'; export interface CommunityProps extends DomainEntityProps { name: string; @@ -18,11 +18,13 @@ export interface CommunityProps extends DomainEntityProps { readonly schemaVersion: string; readonly createdBy: EndUserProps; setCreatedByRef(user: EndUserEntityReference): void; - approvedVendors?: ApprovedVendor[]; + readonly approvedVendors?: VendorUserProps[]; + setApprovedVendorsRef(approvedVendors: VendorUserEntityReference[]): void; } -export interface CommunityEntityReference extends Readonly> { +export interface CommunityEntityReference extends Readonly> { readonly createdBy: EndUserEntityReference; + readonly approvedVendors?: VendorUserEntityReference[]; } export class Community extends AggregateRoot implements CommunityEntityReference { @@ -112,11 +114,14 @@ export class Community extends AggregateRoot permissions.canManageCommunitySettings)) { throw new Error('You do not have permission to change the handle of this community'); } - this.props.approvedVendors = approvedVendors ? new ValueObjects.ApprovedVendors(approvedVendors).valueOf() : null; + if (approvedVendors === null || approvedVendors === undefined) { + throw new Error('createdBy cannot be null or undefined'); + } + this.props.setApprovedVendorsRef(approvedVendors); } set CreatedBy(createdBy: EndUserEntityReference) { diff --git a/data-access/src/app/domain/contexts/community/community/community.value-objects.ts b/data-access/src/app/domain/contexts/community/community/community.value-objects.ts index c24a6d2c..9c3bf253 100644 --- a/data-access/src/app/domain/contexts/community/community/community.value-objects.ts +++ b/data-access/src/app/domain/contexts/community/community/community.value-objects.ts @@ -1,13 +1,7 @@ -import { VOArray, VOObject, VOString } from '@lucaspaganini/value-objects'; +import { VOArray, VOString } from '@lucaspaganini/value-objects'; export class Name extends VOString({ trim: true, maxLength: 200 }) {} export class Domain extends VOString({ trim: true, maxLength: 500 }) {} export class WhiteLabelDomain extends VOString({ trim: true, maxLength: 500 }) {} export class Handle extends VOString({ trim: true, maxLength: 50 }) {} -class ApprovedVendor extends VOObject({ - vendorId: String, - displayName: String, - email: String, - approvedBy: String, -}) {} -export class ApprovedVendors extends VOArray(ApprovedVendor, { maxLength: 50 }) {} +export class ApprovedVendors extends VOArray(VOString(), { maxLength: 50 }) {} diff --git a/data-access/src/functions/http-graphql/schema/builder/generated.ts b/data-access/src/functions/http-graphql/schema/builder/generated.ts index 8de77d3d..ef7b91b6 100644 --- a/data-access/src/functions/http-graphql/schema/builder/generated.ts +++ b/data-access/src/functions/http-graphql/schema/builder/generated.ts @@ -192,21 +192,6 @@ export type Approval = { isApplicantApproved?: Maybe; }; -export type ApprovedVendors = { - __typename?: 'ApprovedVendors'; - approvedBy?: Maybe; - displayName?: Maybe; - email?: Maybe; - vendorId?: Maybe; -}; - -export type ApprovedVendorsInput = { - approvedBy: Scalars['String']; - displayName: Scalars['String']; - email: Scalars['String']; - vendorId: Scalars['String']; -}; - export type BedroomDetails = MongoSubdocument & { __typename?: 'BedroomDetails'; bedDescriptions?: Maybe>>; @@ -252,7 +237,7 @@ export enum CacheControlScope { export type Community = MongoBase & { __typename?: 'Community'; - approvedVendors?: Maybe>>; + approvedVendors?: Maybe>>; createdAt?: Maybe; domain?: Maybe; domainStatus?: Maybe; @@ -342,7 +327,7 @@ export type CommunityPublicFileRemoveInput = { }; export type CommunityUpdateInput = { - approvedVendors?: InputMaybe>>; + approvedVendors?: InputMaybe>>; domain?: InputMaybe; handle?: InputMaybe; id: Scalars['ID']; @@ -1482,7 +1467,7 @@ export type ServiceTicket = MongoBase & { __typename?: 'ServiceTicket'; activityLog?: Maybe>>; assignedTo?: Maybe; - assignedVendor?: Maybe; + assignedVendor?: Maybe; community: Community; createdAt?: Maybe; description: Scalars['String']; @@ -1535,7 +1520,6 @@ export type ServiceTicketChangeStatusInput = { }; export type ServiceTicketCreateInput = { - assignedVendor?: InputMaybe; description: Scalars['String']; propertyId: Scalars['ObjectID']; requestorId?: InputMaybe; @@ -2172,8 +2156,6 @@ export type ResolversTypes = ResolversObject<{ AdhocPaymentRequestInput: AdhocPaymentRequestInput; AdhocTransaction: ResolverTypeWrapper; Approval: ResolverTypeWrapper; - ApprovedVendors: ResolverTypeWrapper; - ApprovedVendorsInput: ApprovedVendorsInput; BedroomDetails: ResolverTypeWrapper; BedroomDetailsInput: BedroomDetailsInput; BigInt: ResolverTypeWrapper; @@ -2456,8 +2438,6 @@ export type ResolversParentTypes = ResolversObject<{ AdhocPaymentRequestInput: AdhocPaymentRequestInput; AdhocTransaction: AdhocTransaction; Approval: Approval; - ApprovedVendors: ApprovedVendors; - ApprovedVendorsInput: ApprovedVendorsInput; BedroomDetails: BedroomDetails; BedroomDetailsInput: BedroomDetailsInput; BigInt: Scalars['BigInt']; @@ -2807,17 +2787,6 @@ export type ApprovalResolvers; }>; -export type ApprovedVendorsResolvers< - ContextType = GraphqlContext, - ParentType extends ResolversParentTypes['ApprovedVendors'] = ResolversParentTypes['ApprovedVendors'], -> = ResolversObject<{ - approvedBy?: Resolver, ParentType, ContextType>; - displayName?: Resolver, ParentType, ContextType>; - email?: Resolver, ParentType, ContextType>; - vendorId?: Resolver, ParentType, ContextType>; - __isTypeOf?: IsTypeOfResolverFn; -}>; - export type BedroomDetailsResolvers< ContextType = GraphqlContext, ParentType extends ResolversParentTypes['BedroomDetails'] = ResolversParentTypes['BedroomDetails'], @@ -2870,7 +2839,7 @@ export interface ByteScalarConfig extends GraphQLScalarTypeConfig = ResolversObject<{ - approvedVendors?: Resolver>>, ParentType, ContextType>; + approvedVendors?: Resolver>>, ParentType, ContextType>; createdAt?: Resolver, ParentType, ContextType>; domain?: Resolver, ParentType, ContextType>; domainStatus?: Resolver, ParentType, ContextType>; @@ -3836,7 +3805,7 @@ export type ServiceTicketResolvers< > = ResolversObject<{ activityLog?: Resolver>>, ParentType, ContextType>; assignedTo?: Resolver, ParentType, ContextType>; - assignedVendor?: Resolver, ParentType, ContextType>; + assignedVendor?: Resolver, ParentType, ContextType>; community?: Resolver; createdAt?: Resolver, ParentType, ContextType>; description?: Resolver; @@ -4286,7 +4255,6 @@ export type Resolvers = ResolversObject<{ Address?: AddressResolvers; AdhocTransaction?: AdhocTransactionResolvers; Approval?: ApprovalResolvers; - ApprovedVendors?: ApprovedVendorsResolvers; BedroomDetails?: BedroomDetailsResolvers; BigInt?: GraphQLScalarType; BlobAuthHeader?: BlobAuthHeaderResolvers; diff --git a/data-access/src/functions/http-graphql/schema/builder/graphql.schema.json b/data-access/src/functions/http-graphql/schema/builder/graphql.schema.json index ce8384ca..886f9d22 100644 --- a/data-access/src/functions/http-graphql/schema/builder/graphql.schema.json +++ b/data-access/src/functions/http-graphql/schema/builder/graphql.schema.json @@ -1186,140 +1186,6 @@ "enumValues": null, "possibleTypes": null }, - { - "kind": "OBJECT", - "name": "ApprovedVendors", - "description": null, - "fields": [ - { - "name": "approvedBy", - "description": null, - "args": [], - "type": { - "kind": "SCALAR", - "name": "String", - "ofType": null - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "displayName", - "description": null, - "args": [], - "type": { - "kind": "SCALAR", - "name": "String", - "ofType": null - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "email", - "description": null, - "args": [], - "type": { - "kind": "SCALAR", - "name": "String", - "ofType": null - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "vendorId", - "description": null, - "args": [], - "type": { - "kind": "SCALAR", - "name": "String", - "ofType": null - }, - "isDeprecated": false, - "deprecationReason": null - } - ], - "inputFields": null, - "interfaces": [], - "enumValues": null, - "possibleTypes": null - }, - { - "kind": "INPUT_OBJECT", - "name": "ApprovedVendorsInput", - "description": null, - "fields": null, - "inputFields": [ - { - "name": "approvedBy", - "description": null, - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "String", - "ofType": null - } - }, - "defaultValue": null, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "displayName", - "description": null, - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "String", - "ofType": null - } - }, - "defaultValue": null, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "email", - "description": null, - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "String", - "ofType": null - } - }, - "defaultValue": null, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "vendorId", - "description": null, - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "String", - "ofType": null - } - }, - "defaultValue": null, - "isDeprecated": false, - "deprecationReason": null - } - ], - "interfaces": null, - "enumValues": null, - "possibleTypes": null - }, { "kind": "OBJECT", "name": "BedroomDetails", @@ -1700,7 +1566,7 @@ "name": null, "ofType": { "kind": "OBJECT", - "name": "ApprovedVendors", + "name": "VendorUser", "ofType": null } }, @@ -2545,8 +2411,8 @@ "kind": "LIST", "name": null, "ofType": { - "kind": "INPUT_OBJECT", - "name": "ApprovedVendorsInput", + "kind": "SCALAR", + "name": "ObjectID", "ofType": null } }, @@ -11953,8 +11819,8 @@ "description": null, "args": [], "type": { - "kind": "SCALAR", - "name": "String", + "kind": "OBJECT", + "name": "VendorUser", "ofType": null }, "isDeprecated": false, @@ -12519,18 +12385,6 @@ "description": null, "fields": null, "inputFields": [ - { - "name": "assignedVendor", - "description": null, - "type": { - "kind": "SCALAR", - "name": "String", - "ofType": null - }, - "defaultValue": null, - "isDeprecated": false, - "deprecationReason": null - }, { "name": "description", "description": null, diff --git a/data-access/src/functions/http-graphql/schema/types/community.graphql b/data-access/src/functions/http-graphql/schema/types/community.graphql index 8d4bef03..ba7eabb7 100644 --- a/data-access/src/functions/http-graphql/schema/types/community.graphql +++ b/data-access/src/functions/http-graphql/schema/types/community.graphql @@ -13,23 +13,38 @@ type Community implements MongoBase { createdAt: DateTime updatedAt: DateTime userIsAdmin: Boolean - approvedVendors: [ApprovedVendors] + approvedVendors: [VendorUser] } -type ApprovedVendors { - vendorId: String - displayName: String +type VendorUserPersonalInformation { + identityDetails: VendorUserIdentityDetails + contactInformation: VendorUserContactInformation +} + +type VendorUserIdentityDetails { + lastName: String + legalNameConsistsOfOneName: Boolean + restOfName: String +} + +type VendorUserContactInformation { email: String - approvedBy: String } -input ApprovedVendorsInput { - vendorId: String! - displayName: String! - email: String! - approvedBy: String! +type VendorUser implements MongoBase { + externalId: String + displayName: String + email: String + accessBlocked: Boolean + tags: [String] + personalInformation: VendorUserPersonalInformation + id: ObjectID! + schemaVersion: String + createdAt: DateTime + updatedAt: DateTime } + type CommunityDomainResult { verified: Boolean verification: [CommunityDomainVerificationDetail] @@ -73,7 +88,7 @@ input CommunityUpdateInput { domain: String whiteLabelDomain: String handle: String - approvedVendors: [ApprovedVendorsInput] + approvedVendors: [ObjectID] } input CommunityBlobFileInput { diff --git a/data-access/src/functions/http-graphql/schema/types/community.resolvers.ts b/data-access/src/functions/http-graphql/schema/types/community.resolvers.ts index b988814f..ac75b4b6 100644 --- a/data-access/src/functions/http-graphql/schema/types/community.resolvers.ts +++ b/data-access/src/functions/http-graphql/schema/types/community.resolvers.ts @@ -1,6 +1,7 @@ -import { Resolvers, Community, CommunityMutationResult, Role } from '../builder/generated'; +import { Resolvers, Community, CommunityMutationResult, Role, VendorUser } from '../builder/generated'; import { Community as CommunityDo } from '../../../../infrastructure-services-impl/datastore/mongodb/models/community'; import { applyPermission, applyPermissionFilter, checkAccountPortalAccess, checkAnyAccess, checkStaffPortalAccess, checkSystemAccess } from '../resolver-helper'; +import { isValidObjectId } from 'mongoose'; const CommunityMutationResolver = async (getCommunity: Promise): Promise => { try { @@ -54,6 +55,27 @@ const community: Resolvers = { } return null; }, + approvedVendors: async (rootObj: Community, _args, { applicationServices, passport }) => { + if ( + checkPermission( + passport, + rootObj, + (permissions) => + permissions.canManageAllCommunities || + (permissions.canManageSiteContent && rootObj.approvedVendors?.length) + ) + ) { + return rootObj.approvedVendors.map(async (vendor) => { + if (isValidObjectId(vendor.toString())) { + return (await applicationServices.users.vendorUser.dataApi.getUserById( + vendor.toString() + )) as VendorUser; + } + }); + } + return null; + } + }, Query: { community: async (_, _args, { applicationServices, verifiedUser, passport, member }) => { diff --git a/data-access/src/functions/http-graphql/schema/types/service-ticket.graphql b/data-access/src/functions/http-graphql/schema/types/service-ticket.graphql index f4736c46..5fec41f6 100644 --- a/data-access/src/functions/http-graphql/schema/types/service-ticket.graphql +++ b/data-access/src/functions/http-graphql/schema/types/service-ticket.graphql @@ -13,7 +13,35 @@ type ServiceTicket implements MongoBase { activityLog: [ServiceTicketActivityDetail] messages: [ServiceTicketV1Message] revisionRequest: ServiceTicketV1RevisionRequest - assignedVendor: String + assignedVendor: VendorUser + id: ObjectID! + schemaVersion: String + createdAt: DateTime + updatedAt: DateTime +} + +type VendorUserPersonalInformation { + identityDetails: VendorUserIdentityDetails + contactInformation: VendorUserContactInformation +} + +type VendorUserIdentityDetails { + lastName: String + legalNameConsistsOfOneName: Boolean + restOfName: String +} + +type VendorUserContactInformation { + email: String +} + +type VendorUser implements MongoBase { + externalId: String + displayName: String + email: String + accessBlocked: Boolean + tags: [String] + personalInformation: VendorUserPersonalInformation id: ObjectID! schemaVersion: String createdAt: DateTime @@ -104,7 +132,6 @@ input ServiceTicketCreateInput { title: String! description: String! serviceId: ObjectID - assignedVendor:String } input ServiceTicketUpdateInput { @@ -116,7 +143,7 @@ input ServiceTicketUpdateInput { serviceId: ObjectID messages: [ServiceTicketV1MessageInput] revisionRequest: ServiceTicketV1RevisionRequestUpdateInput - assignedVendor:String + assignedVendor:ObjectID } input ServiceTicketV1MessageInput { diff --git a/data-access/src/functions/http-graphql/schema/types/service-ticket.resolvers.ts b/data-access/src/functions/http-graphql/schema/types/service-ticket.resolvers.ts index 8a6106f4..4e681ffe 100644 --- a/data-access/src/functions/http-graphql/schema/types/service-ticket.resolvers.ts +++ b/data-access/src/functions/http-graphql/schema/types/service-ticket.resolvers.ts @@ -1,4 +1,4 @@ -import { Community, Member, Property, Resolvers, Service, ServiceTicket, Ticket, ServiceTicketMutationResult } from '../builder/generated'; +import { Community, Member, Property, Resolvers, Service, ServiceTicket, Ticket, ServiceTicketMutationResult, VendorUser } from '../builder/generated'; import { getMemberForCurrentUser } from '../resolver-helper'; import { isValidObjectId } from 'mongoose'; import { ServiceTicket as ServiceTicketDo } from '../../../../infrastructure-services-impl/datastore/mongodb/models/cases/service-ticket'; @@ -50,6 +50,12 @@ const serviceTicket: Resolvers = { } return parent.service; }, + approvedVendor: async (parent, args, context, info) => { + if (parent.approvedVendor && isValidObjectId(parent.approvedVendor.toString())) { + return (await context.applicationServices.users.vendorUser.dataApi.getMemberById(parent.approvedVendor.toString())) as VendorUser; + } + return parent.approvedVendor; + }, }, ServiceTicketActivityDetail: { activityBy: async (parent, args, context, info) => { diff --git a/data-access/src/functions/http-graphql/schema/types/vendor-user.graphql b/data-access/src/functions/http-graphql/schema/types/vendor-user.graphql index bfab6d8f..a08d6a2e 100644 --- a/data-access/src/functions/http-graphql/schema/types/vendor-user.graphql +++ b/data-access/src/functions/http-graphql/schema/types/vendor-user.graphql @@ -1,4 +1,3 @@ -# vendor-user.graphql type VendorUser implements MongoBase { externalId: String displayName: String diff --git a/data-access/src/infrastructure-services-impl/datastore/mongodb/infrastructure/cases/service-ticket/v1/service-ticket.domain-adapter.ts b/data-access/src/infrastructure-services-impl/datastore/mongodb/infrastructure/cases/service-ticket/v1/service-ticket.domain-adapter.ts index 23699a58..8dbe9014 100644 --- a/data-access/src/infrastructure-services-impl/datastore/mongodb/infrastructure/cases/service-ticket/v1/service-ticket.domain-adapter.ts +++ b/data-access/src/infrastructure-services-impl/datastore/mongodb/infrastructure/cases/service-ticket/v1/service-ticket.domain-adapter.ts @@ -30,6 +30,7 @@ import { ServiceTicketV1RevisionRequestedChangesProps } from '../../../../../../ import { ServiceTicketV1Visa } from '../../../../../../../app/domain/contexts/cases/service-ticket/v1/service-ticket.visa'; import { InfrastructureContext } from '../../../../../../../app/init/infrastructure-context'; import { FuncToGetMemberRefFromAuditContextFactory } from '../../../../../../../app/init/audit-context'; +import { VendorUser, VendorUserEntityReference } from '../../../../../../../app/domain/contexts/users/vendor-user/vendor-user'; export class ServiceTicketV1Converter extends MongoTypeConverter< DomainExecutionContext, @@ -113,6 +114,13 @@ export class ServiceTicketV1DomainAdapter extends MongooseDomainAdapter new VendorUserDomainAdapter(item, this.infrastructureContext)); } - set approvedVendors(approvedVendors) { - this.doc.approvedVendors = approvedVendors; + setApprovedVendorsRef(approvedVendors: VendorUserEntityReference[]) { + const vendors = approvedVendors.map((item)=> item.id); + this.doc.set('approvedVendors', vendors); } diff --git a/data-access/src/infrastructure-services-impl/datastore/mongodb/models/cases/service-ticket.ts b/data-access/src/infrastructure-services-impl/datastore/mongodb/models/cases/service-ticket.ts index 171e1353..a6406228 100644 --- a/data-access/src/infrastructure-services-impl/datastore/mongodb/models/cases/service-ticket.ts +++ b/data-access/src/infrastructure-services-impl/datastore/mongodb/models/cases/service-ticket.ts @@ -5,6 +5,7 @@ import * as Property from './../property'; import * as Member from './../member'; import * as Service from './../service'; import { Ticket, TicketModel, ticketOptions } from './ticket'; +import * as VendorUser from '../users/vendor-user'; export interface ServiceTicketRevisionRequestChanges extends NestedPath { requestUpdatedAssignment: boolean; @@ -114,7 +115,7 @@ export interface ServiceTicket extends Ticket { hash: string; lastIndexed: Date; updateIndexFailedDate: Date; - assignedVendor: string + assignedVendor: PopulatedDoc; } const ServiceTicketSchema = new Schema, ServiceTicket>( @@ -160,7 +161,7 @@ const ServiceTicketSchema = new Schema, Serv hash: { type: String, required: false, maxlength: 100 }, lastIndexed: { type: Date, required: false }, updateIndexFailedDate: { type: Date, required: false }, - assignedVendor: { type: String, required: false } + assignedVendor: { type: Schema.Types.ObjectId, ref: VendorUser.VendorUserModel.modelName, required: true } }, ticketOptions, ); diff --git a/data-access/src/infrastructure-services-impl/datastore/mongodb/models/community.ts b/data-access/src/infrastructure-services-impl/datastore/mongodb/models/community.ts index 8ba40c92..a244cf0b 100644 --- a/data-access/src/infrastructure-services-impl/datastore/mongodb/models/community.ts +++ b/data-access/src/infrastructure-services-impl/datastore/mongodb/models/community.ts @@ -1,30 +1,16 @@ import { Schema, model, Model, ObjectId, PopulatedDoc } from 'mongoose'; import { Base } from '../../../../../seedwork/services-seedwork-datastore-mongodb/interfaces/base'; import * as EndUser from './users/end-user'; - - -export interface ApprovedVendor { - vendorId: string; //ref of vendor user record form mongoDB - displayName: string; //name of vendor user - email: string; //email of vendor user - approvedBy: string; //ref of staff user record from mongoDB -} +import { VendorUser, VendorUserModel } from './users/vendor-user'; export interface Community extends Base { name: string; domain: string; whiteLabelDomain: string; handle: string; - approvedVendors?: ApprovedVendor[]; + approvedVendors?: PopulatedDoc[] | ObjectId[]; createdBy:PopulatedDoc | ObjectId; } -export const approvedVendorSchema = new Schema, ApprovedVendor>({ - vendorId: { type: String, required: true }, - displayName: { type: String, required: true }, - email: { type: String, required: true }, - approvedBy: { type: String, required: true }, -}) - export const CommunityModel = model('Community',new Schema, Community>( { schemaVersion: { type: String, default: '1.0.0' }, @@ -40,7 +26,7 @@ export const CommunityModel = model('Community',new Schema; }; -export type ApprovedVendors = { - __typename?: 'ApprovedVendors'; - approvedBy?: Maybe; - displayName?: Maybe; - email?: Maybe; - vendorId?: Maybe; -}; - -export type ApprovedVendorsInput = { - approvedBy: Scalars['String']; - displayName: Scalars['String']; - email: Scalars['String']; - vendorId: Scalars['String']; -}; - export type BedroomDetails = MongoSubdocument & { __typename?: 'BedroomDetails'; bedDescriptions?: Maybe>>; @@ -250,7 +235,7 @@ export enum CacheControlScope { export type Community = MongoBase & { __typename?: 'Community'; - approvedVendors?: Maybe>>; + approvedVendors?: Maybe>>; createdAt?: Maybe; domain?: Maybe; domainStatus?: Maybe; @@ -340,7 +325,7 @@ export type CommunityPublicFileRemoveInput = { }; export type CommunityUpdateInput = { - approvedVendors?: InputMaybe>>; + approvedVendors?: InputMaybe>>; domain?: InputMaybe; handle?: InputMaybe; id: Scalars['ID']; @@ -1480,7 +1465,7 @@ export type ServiceTicket = MongoBase & { __typename?: 'ServiceTicket'; activityLog?: Maybe>>; assignedTo?: Maybe; - assignedVendor?: Maybe; + assignedVendor?: Maybe; community: Community; createdAt?: Maybe; description: Scalars['String']; @@ -1533,7 +1518,6 @@ export type ServiceTicketChangeStatusInput = { }; export type ServiceTicketCreateInput = { - assignedVendor?: InputMaybe; description: Scalars['String']; propertyId: Scalars['ObjectID']; requestorId?: InputMaybe; From e62d5033a7d7ea1f2e3845e8327f36cc62cde3c9 Mon Sep 17 00:00:00 2001 From: Kevin Delong Date: Thu, 19 Dec 2024 10:40:16 -0500 Subject: [PATCH 08/12] refactor: remove unused method --- .../cases/service-ticket/v1/service-ticket.data.ts | 5 ----- 1 file changed, 5 deletions(-) diff --git a/data-access/src/app/application-services/cases/service-ticket/v1/service-ticket.data.ts b/data-access/src/app/application-services/cases/service-ticket/v1/service-ticket.data.ts index 1a8a3671..9c367ace 100644 --- a/data-access/src/app/application-services/cases/service-ticket/v1/service-ticket.data.ts +++ b/data-access/src/app/application-services/cases/service-ticket/v1/service-ticket.data.ts @@ -9,7 +9,6 @@ export interface ServiceTicketV1DataApi { getServiceTicketsOpenByRequestor(memberId: string): Promise; getServiceTicketsClosedByRequestor(memberId: string): Promise; getServiceTicketsByAssignedTo(communityId: string, memberId: string): Promise; - getServiceTicketsByVendor(vendorId: string): Promise; } export class ServiceTicketV1DataApiImpl @@ -38,10 +37,6 @@ export class ServiceTicketV1DataApiImpl let dbData = await this.findByFields({ community: communityId, assignedTo: memberId }); return this.applyPermissionFilter(dbData, this.context); } - async getServiceTicketsByVendor(vendorId: string): Promise { - let dbData = await this.findByFields({ assignedVendor: vendorId }); - return this.applyPermissionFilter(dbData, this.context); - } private async applyPermissionFilter(serviceTickets: ServiceTicketData[], context: AppContext): Promise { let converter = new ServiceTicketV1Converter(); From 249787d7b388ef9e22fdf16c6d61e0386851d7bc Mon Sep 17 00:00:00 2001 From: Kevin Delong Date: Thu, 19 Dec 2024 10:58:39 -0500 Subject: [PATCH 09/12] fix: failing build --- .../cases/service-ticket/v1/service-ticket-v1.ts | 14 ++++++++------ .../contexts/community/community/community.ts | 2 +- 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/data-access/src/app/domain/contexts/cases/service-ticket/v1/service-ticket-v1.ts b/data-access/src/app/domain/contexts/cases/service-ticket/v1/service-ticket-v1.ts index e8a1f2bd..00b0f9b6 100644 --- a/data-access/src/app/domain/contexts/cases/service-ticket/v1/service-ticket-v1.ts +++ b/data-access/src/app/domain/contexts/cases/service-ticket/v1/service-ticket-v1.ts @@ -32,13 +32,13 @@ export interface ServiceTicketV1Props extends DomainEntityProps { setAssignedToRef(assignedTo: MemberEntityReference): void; readonly service: ServiceProps; setServiceRef(service: ServiceEntityReference): void; + readonly assignedVendor?: VendorUserProps; + setAssignedVendorRef?: (approvedVendors: VendorUserEntityReference) => void; title: string; description: string; readonly ticketType?: string; status: string; priority: number; - readonly assignedVendor: VendorUserProps; - setAssignedVendorRef(assignedVendor: VendorUserEntityReference): void; readonly activityLog: PropArray; readonly messages: PropArray; @@ -85,7 +85,7 @@ export interface ServiceTicketV1EntityReference readonly messages: ReadonlyArray; readonly photos: ReadonlyArray; readonly revisionRequest: ServiceTicketV1RevisionRequestEntityReference; - readonly assignedVendor: VendorUserEntityReference; + readonly assignedVendor?: VendorUserEntityReference; } export interface ServiceTicketV1RootRegistry extends AggregateRootTypeForApplicationService { @@ -113,7 +113,7 @@ export class ServiceTicketV1 extends Aggrega property: PropertyEntityReference, requestor: MemberEntityReference, context: DomainExecutionContext, - assignedVendor: VendorUserEntityReference + assignedVendor?: VendorUserEntityReference ): ServiceTicketV1 { let serviceTicket = new ServiceTicketV1(newProps, context); serviceTicket.MarkAsNew(); @@ -127,7 +127,9 @@ export class ServiceTicketV1 extends Aggrega serviceTicket.Priority = 5; serviceTicket.syncDomainEventFactory.addServiceTicketV1CreatedEvent({ requestor }); serviceTicket.isNew = false; - serviceTicket.AssignedVendor = assignedVendor; + if(assignedVendor){ + serviceTicket.AssignedVendor = assignedVendor; + } return serviceTicket; } @@ -251,7 +253,7 @@ export class ServiceTicketV1 extends Aggrega this.props.setRequestorRef(requestor); } - private set AssignedVendor(assignedVendor: VendorUserEntityReference) { + set AssignedVendor(assignedVendor: VendorUserEntityReference) { if (!this.isNew) { throw new Error('Unauthorized'); } diff --git a/data-access/src/app/domain/contexts/community/community/community.ts b/data-access/src/app/domain/contexts/community/community/community.ts index 2f0ee0c9..205f7475 100644 --- a/data-access/src/app/domain/contexts/community/community/community.ts +++ b/data-access/src/app/domain/contexts/community/community/community.ts @@ -19,7 +19,7 @@ export interface CommunityProps extends DomainEntityProps { readonly createdBy: EndUserProps; setCreatedByRef(user: EndUserEntityReference): void; readonly approvedVendors?: VendorUserProps[]; - setApprovedVendorsRef(approvedVendors: VendorUserEntityReference[]): void; + setApprovedVendorsRef?: (approvedVendors: VendorUserEntityReference[]) => void; } export interface CommunityEntityReference extends Readonly> { From b4e94862424ce369bf655f34d44c97372ef14559 Mon Sep 17 00:00:00 2001 From: Kevin Delong Date: Thu, 19 Dec 2024 11:07:17 -0500 Subject: [PATCH 10/12] fix: worker error --- .../functions/http-graphql/schema/builder/generated.ts | 2 +- .../http-graphql/schema/builder/graphql.schema.json | 2 +- .../http-graphql/schema/types/service-ticket.resolvers.ts | 8 ++++---- ui-community/src/generated.tsx | 2 +- 4 files changed, 7 insertions(+), 7 deletions(-) diff --git a/data-access/src/functions/http-graphql/schema/builder/generated.ts b/data-access/src/functions/http-graphql/schema/builder/generated.ts index ef7b91b6..769ce54d 100644 --- a/data-access/src/functions/http-graphql/schema/builder/generated.ts +++ b/data-access/src/functions/http-graphql/schema/builder/generated.ts @@ -1578,7 +1578,7 @@ export type ServiceTicketSubmitInput = { }; export type ServiceTicketUpdateInput = { - assignedVendor?: InputMaybe; + assignedVendor?: InputMaybe; description?: InputMaybe; messages?: InputMaybe>>; priority?: InputMaybe; diff --git a/data-access/src/functions/http-graphql/schema/builder/graphql.schema.json b/data-access/src/functions/http-graphql/schema/builder/graphql.schema.json index 886f9d22..7e6e56c5 100644 --- a/data-access/src/functions/http-graphql/schema/builder/graphql.schema.json +++ b/data-access/src/functions/http-graphql/schema/builder/graphql.schema.json @@ -12911,7 +12911,7 @@ "description": null, "type": { "kind": "SCALAR", - "name": "String", + "name": "ObjectID", "ofType": null }, "defaultValue": null, diff --git a/data-access/src/functions/http-graphql/schema/types/service-ticket.resolvers.ts b/data-access/src/functions/http-graphql/schema/types/service-ticket.resolvers.ts index 4e681ffe..c2c0c11e 100644 --- a/data-access/src/functions/http-graphql/schema/types/service-ticket.resolvers.ts +++ b/data-access/src/functions/http-graphql/schema/types/service-ticket.resolvers.ts @@ -50,11 +50,11 @@ const serviceTicket: Resolvers = { } return parent.service; }, - approvedVendor: async (parent, args, context, info) => { - if (parent.approvedVendor && isValidObjectId(parent.approvedVendor.toString())) { - return (await context.applicationServices.users.vendorUser.dataApi.getMemberById(parent.approvedVendor.toString())) as VendorUser; + assignedVendor: async (parent, args, context, info) => { + if (parent.assignedVendor && isValidObjectId(parent.assignedVendor.toString())) { + return (await context.applicationServices.users.vendorUser.dataApi.getUserById(parent.assignedVendor.toString())) as VendorUser; } - return parent.approvedVendor; + return parent.assignedVendor; }, }, ServiceTicketActivityDetail: { diff --git a/ui-community/src/generated.tsx b/ui-community/src/generated.tsx index fb896e7d..c9faee7b 100644 --- a/ui-community/src/generated.tsx +++ b/ui-community/src/generated.tsx @@ -1576,7 +1576,7 @@ export type ServiceTicketSubmitInput = { }; export type ServiceTicketUpdateInput = { - assignedVendor?: InputMaybe; + assignedVendor?: InputMaybe; description?: InputMaybe; messages?: InputMaybe>>; priority?: InputMaybe; From 7273c7cf81113c03d5fd822b0a53f13ebb3459c4 Mon Sep 17 00:00:00 2001 From: Kevin Delong Date: Thu, 19 Dec 2024 12:03:56 -0500 Subject: [PATCH 11/12] code refactor --- .../v1/service-ticket.domain.ts | 4 +- .../community/community.domain.ts | 11 +++--- .../service-ticket/v1/service-ticket-v1.ts | 38 +------------------ .../v1/service-ticket.value-objects.ts | 11 +----- .../contexts/community/community/community.ts | 2 +- .../schema/types/community.graphql | 29 -------------- .../schema/types/community.resolvers.ts | 2 +- .../schema/types/service-ticket.graphql | 28 -------------- .../v1/service-ticket.domain-adapter.ts | 6 ++- .../community/community.domain-adapter.ts | 3 +- .../datastore/mongodb/models/community.ts | 2 +- 11 files changed, 19 insertions(+), 117 deletions(-) diff --git a/data-access/src/app/application-services/cases/service-ticket/v1/service-ticket.domain.ts b/data-access/src/app/application-services/cases/service-ticket/v1/service-ticket.domain.ts index f409d478..99e18afb 100644 --- a/data-access/src/app/application-services/cases/service-ticket/v1/service-ticket.domain.ts +++ b/data-access/src/app/application-services/cases/service-ticket/v1/service-ticket.domain.ts @@ -167,12 +167,12 @@ export class ServiceTicketV1DomainApiImpl extends DomainDataSource { @@ -60,11 +59,11 @@ export class CommunityDomainApiImpl if (!domainObject) { throw new Error('invalid id'); } - domainObject.Name = (updatedCommunity.name); - domainObject.Domain = (updatedCommunity.domain); - domainObject.WhiteLabelDomain = (updatedCommunity.whiteLabelDomain); - domainObject.Handle = (updatedCommunity.handle); - domainObject.ApprovedVendors = (updatedCommunity.approvedVendors); + domainObject.Name = (community.name); + domainObject.Domain = (community.domain); + domainObject.WhiteLabelDomain = (community.whiteLabelDomain); + domainObject.Handle = (community.handle); + domainObject.ApprovedVendors = (vendorsList); result = (new CommunityConverter()).toPersistence(await repo.save(domainObject)); }); return result; diff --git a/data-access/src/app/domain/contexts/cases/service-ticket/v1/service-ticket-v1.ts b/data-access/src/app/domain/contexts/cases/service-ticket/v1/service-ticket-v1.ts index 00b0f9b6..afd9f04d 100644 --- a/data-access/src/app/domain/contexts/cases/service-ticket/v1/service-ticket-v1.ts +++ b/data-access/src/app/domain/contexts/cases/service-ticket/v1/service-ticket-v1.ts @@ -32,8 +32,6 @@ export interface ServiceTicketV1Props extends DomainEntityProps { setAssignedToRef(assignedTo: MemberEntityReference): void; readonly service: ServiceProps; setServiceRef(service: ServiceEntityReference): void; - readonly assignedVendor?: VendorUserProps; - setAssignedVendorRef?: (approvedVendors: VendorUserEntityReference) => void; title: string; description: string; readonly ticketType?: string; @@ -72,8 +70,7 @@ export interface ServiceTicketV1EntityReference | 'messages' | 'photos' | 'revisionRequest' - | 'assignedVendor' - | 'setAssignedVendorRef' + > > { readonly community: CommunityEntityReference; @@ -85,7 +82,6 @@ export interface ServiceTicketV1EntityReference readonly messages: ReadonlyArray; readonly photos: ReadonlyArray; readonly revisionRequest: ServiceTicketV1RevisionRequestEntityReference; - readonly assignedVendor?: VendorUserEntityReference; } export interface ServiceTicketV1RootRegistry extends AggregateRootTypeForApplicationService { @@ -113,7 +109,6 @@ export class ServiceTicketV1 extends Aggrega property: PropertyEntityReference, requestor: MemberEntityReference, context: DomainExecutionContext, - assignedVendor?: VendorUserEntityReference ): ServiceTicketV1 { let serviceTicket = new ServiceTicketV1(newProps, context); serviceTicket.MarkAsNew(); @@ -127,9 +122,6 @@ export class ServiceTicketV1 extends Aggrega serviceTicket.Priority = 5; serviceTicket.syncDomainEventFactory.addServiceTicketV1CreatedEvent({ requestor }); serviceTicket.isNew = false; - if(assignedVendor){ - serviceTicket.AssignedVendor = assignedVendor; - } return serviceTicket; } @@ -198,10 +190,6 @@ export class ServiceTicketV1 extends Aggrega return this.props.revisionRequest ? new ServiceTicketV1RevisionRequest(this.props.revisionRequest, this.context, this.visa) : undefined; } - get assignedVendor() { - return this.props.assignedVendor - } - private readonly validStatusTransitions = new Map([ [ValueObjects.StatusCodes.Draft, [ValueObjects.StatusCodes.Submitted]], [ValueObjects.StatusCodes.Submitted, [ValueObjects.StatusCodes.Draft, ValueObjects.StatusCodes.Assigned]], @@ -240,7 +228,7 @@ export class ServiceTicketV1 extends Aggrega ) { throw new Error('Unauthorized1'); } - this.props.setPropertyRef(property);this.Description + this.props.setPropertyRef(property); } private set Requestor(requestor: MemberEntityReference) { @@ -253,16 +241,6 @@ export class ServiceTicketV1 extends Aggrega this.props.setRequestorRef(requestor); } - set AssignedVendor(assignedVendor: VendorUserEntityReference) { - if (!this.isNew) { - throw new Error('Unauthorized'); - } - if (!assignedVendor) { - throw new Error('assignedVendor cannot be null or undefined'); - } - this.props.setAssignedVendorRef(assignedVendor); - } - set AssignedTo(assignedTo: MemberEntityReference) { if (!this.isNew && !this.visa.determineIf((permissions) => permissions.isSystemAccount || permissions.canAssignTickets)) { throw new Error('Unauthorized2'); @@ -300,18 +278,6 @@ export class ServiceTicketV1 extends Aggrega this.props.description = new ValueObjects.Description(description).valueOf(); } - - - setAssignedVendorRef(assignedVendor: VendorUserEntityReference) { - if ( - !this.isNew && - !this.visa.determineIf((permissions) => permissions.isSystemAccount || permissions.canManageTickets || (permissions.canCreateTickets && permissions.isEditingOwnTicket)) - ) { - throw new Error('Unauthorized3b'); - } - this.props.setAssignedVendorRef (assignedVendor) - } - set Status(statusCode: ValueObjects.StatusCode) { if (!this.isNew && !this.visa.determineIf((permissions) => permissions.isSystemAccount)) { throw new Error('Unauthorized5'); diff --git a/data-access/src/app/domain/contexts/cases/service-ticket/v1/service-ticket.value-objects.ts b/data-access/src/app/domain/contexts/cases/service-ticket/v1/service-ticket.value-objects.ts index 1dd4f2f3..c01ae578 100644 --- a/data-access/src/app/domain/contexts/cases/service-ticket/v1/service-ticket.value-objects.ts +++ b/data-access/src/app/domain/contexts/cases/service-ticket/v1/service-ticket.value-objects.ts @@ -1,4 +1,4 @@ -import { VOString, VOSet, VOInteger, VOObject, VOOptional, VOArray, VOAny } from '@lucaspaganini/value-objects'; +import { VOString, VOSet, VOInteger } from '@lucaspaganini/value-objects'; export const StatusCodes = { Draft: 'DRAFT', @@ -13,12 +13,3 @@ export class Title extends VOString({ trim: true, maxLength: 200, minLength: 5 } export class Description extends VOString({ trim: true, maxLength: 2000 }) {} export class StatusCode extends VOSet(Object.values(StatusCodes)) {} export class Priority extends VOInteger({ min: 1, max: 5 }) {} -export class AssignedVendor extends VOObject({ - externalId: VOOptional(VOString()), - displayName: VOOptional(VOString()), - email: VOOptional(VOString()), - accessBlocked: Boolean, - tags: VOOptional(VOArray(VOString())), - id: VOString(), - schemaVersion: VOString(), -}) {} diff --git a/data-access/src/app/domain/contexts/community/community/community.ts b/data-access/src/app/domain/contexts/community/community/community.ts index 205f7475..d1ebe33b 100644 --- a/data-access/src/app/domain/contexts/community/community/community.ts +++ b/data-access/src/app/domain/contexts/community/community/community.ts @@ -119,7 +119,7 @@ export class Community extends AggregateRoot new VendorUserDomainAdapter(item, this.infrastructureContext)); } setApprovedVendorsRef(approvedVendors: VendorUserEntityReference[]) { - const vendors = approvedVendors.map((item)=> item.id); - this.doc.set('approvedVendors', vendors); + this.doc.set('approvedVendors', approvedVendors.map((item)=> item.id)); } diff --git a/data-access/src/infrastructure-services-impl/datastore/mongodb/models/community.ts b/data-access/src/infrastructure-services-impl/datastore/mongodb/models/community.ts index a244cf0b..14b61b3d 100644 --- a/data-access/src/infrastructure-services-impl/datastore/mongodb/models/community.ts +++ b/data-access/src/infrastructure-services-impl/datastore/mongodb/models/community.ts @@ -26,7 +26,7 @@ export const CommunityModel = model('Community',new Schema Date: Thu, 19 Dec 2024 12:19:09 -0500 Subject: [PATCH 12/12] chore: remove value object --- .../v1/service-ticket.domain.ts | 3 +-- .../service-ticket/v1/service-ticket-v1.ts | 21 ++++++++++++++++++- .../community/community.value-objects.ts | 3 +-- 3 files changed, 22 insertions(+), 5 deletions(-) diff --git a/data-access/src/app/application-services/cases/service-ticket/v1/service-ticket.domain.ts b/data-access/src/app/application-services/cases/service-ticket/v1/service-ticket.domain.ts index 99e18afb..c8547fb1 100644 --- a/data-access/src/app/application-services/cases/service-ticket/v1/service-ticket.domain.ts +++ b/data-access/src/app/application-services/cases/service-ticket/v1/service-ticket.domain.ts @@ -1,6 +1,5 @@ import { DomainDataSource } from '../../../../data-sources/domain-data-source'; import { Member } from '../../../../domain/contexts/community/member/member'; -import { ReadOnlyDomainVisa } from '../../../../domain/domain.visa'; import { Service } from '../../../../domain/contexts/community/service/service'; import { ServiceTicketV1 } from '../../../../domain/contexts/cases/service-ticket/v1/service-ticket-v1'; import { SentBy, Message, Embedding } from '../../../../domain/contexts/cases/service-ticket/v1/service-ticket-v1-message.value-objects'; @@ -172,7 +171,7 @@ export class ServiceTicketV1DomainApiImpl extends DomainDataSource void; title: string; description: string; readonly ticketType?: string; @@ -70,7 +72,8 @@ export interface ServiceTicketV1EntityReference | 'messages' | 'photos' | 'revisionRequest' - + | 'assignedVendor' + | 'setAssignedVendorRef' > > { readonly community: CommunityEntityReference; @@ -82,6 +85,7 @@ export interface ServiceTicketV1EntityReference readonly messages: ReadonlyArray; readonly photos: ReadonlyArray; readonly revisionRequest: ServiceTicketV1RevisionRequestEntityReference; + readonly assignedVendor?: VendorUserEntityReference; } export interface ServiceTicketV1RootRegistry extends AggregateRootTypeForApplicationService { @@ -109,6 +113,7 @@ export class ServiceTicketV1 extends Aggrega property: PropertyEntityReference, requestor: MemberEntityReference, context: DomainExecutionContext, + assignedVendor?: VendorUserEntityReference ): ServiceTicketV1 { let serviceTicket = new ServiceTicketV1(newProps, context); serviceTicket.MarkAsNew(); @@ -122,6 +127,9 @@ export class ServiceTicketV1 extends Aggrega serviceTicket.Priority = 5; serviceTicket.syncDomainEventFactory.addServiceTicketV1CreatedEvent({ requestor }); serviceTicket.isNew = false; + if(assignedVendor){ + serviceTicket.AssignedVendor = assignedVendor; + } return serviceTicket; } @@ -190,6 +198,10 @@ export class ServiceTicketV1 extends Aggrega return this.props.revisionRequest ? new ServiceTicketV1RevisionRequest(this.props.revisionRequest, this.context, this.visa) : undefined; } + get assignedVendor() { + return this.props.assignedVendor + } + private readonly validStatusTransitions = new Map([ [ValueObjects.StatusCodes.Draft, [ValueObjects.StatusCodes.Submitted]], [ValueObjects.StatusCodes.Submitted, [ValueObjects.StatusCodes.Draft, ValueObjects.StatusCodes.Assigned]], @@ -241,6 +253,13 @@ export class ServiceTicketV1 extends Aggrega this.props.setRequestorRef(requestor); } + set AssignedVendor(assignedVendor: VendorUserEntityReference) { + if (!this.isNew) { + throw new Error('Unauthorized'); + } + this.props.setAssignedVendorRef(assignedVendor); + } + set AssignedTo(assignedTo: MemberEntityReference) { if (!this.isNew && !this.visa.determineIf((permissions) => permissions.isSystemAccount || permissions.canAssignTickets)) { throw new Error('Unauthorized2'); diff --git a/data-access/src/app/domain/contexts/community/community/community.value-objects.ts b/data-access/src/app/domain/contexts/community/community/community.value-objects.ts index 9c3bf253..a8486fb9 100644 --- a/data-access/src/app/domain/contexts/community/community/community.value-objects.ts +++ b/data-access/src/app/domain/contexts/community/community/community.value-objects.ts @@ -1,7 +1,6 @@ -import { VOArray, VOString } from '@lucaspaganini/value-objects'; +import { VOString } from '@lucaspaganini/value-objects'; export class Name extends VOString({ trim: true, maxLength: 200 }) {} export class Domain extends VOString({ trim: true, maxLength: 500 }) {} export class WhiteLabelDomain extends VOString({ trim: true, maxLength: 500 }) {} export class Handle extends VOString({ trim: true, maxLength: 50 }) {} -export class ApprovedVendors extends VOArray(VOString(), { maxLength: 50 }) {}