@bisondesk/core-sdk 1.0.392 → 1.0.394
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/utils/search.d.ts +2 -1
- package/lib/utils/search.d.ts.map +1 -1
- package/lib/utils/search.js +18 -6
- package/lib/utils/search.js.map +1 -1
- package/package.json +1 -1
- package/src/utils/search.ts +51 -20
- package/tsconfig.tsbuildinfo +1 -1
package/lib/utils/search.d.ts
CHANGED
|
@@ -19,7 +19,8 @@ export declare const mappings: {
|
|
|
19
19
|
[key in BusinessEntityIds]?: {
|
|
20
20
|
getMainEntity: (entity: any) => GlobalBusinessEntity;
|
|
21
21
|
getTitle: (entity: any) => string;
|
|
22
|
-
getTags: (entity: any) =>
|
|
22
|
+
getTags: (entity: any) => string[];
|
|
23
|
+
getTagsForSearchEntity?: (entity: any) => string[];
|
|
23
24
|
getDescription?: (entity: any) => string;
|
|
24
25
|
getMeta?: (entity: any) => Record<string, any>;
|
|
25
26
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"search.d.ts","sourceRoot":"/","sources":["utils/search.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,iBAAiB,EAAE,MAAM,iBAAiB,CAAC;AACpD,OAAO,EAAE,OAAO,EAAE,YAAY,EAAE,kBAAkB,EAAE,MAAM,iBAAiB,CAAC;AAC5E,OAAO,EAAE,qBAAqB,EAAE,MAAM,4BAA4B,CAAC;AACnE,OAAO,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAC;AACtD,OAAO,EAAE,WAAW,EAAE,iBAAiB,EAAE,MAAM,2BAA2B,CAAC;AAC3E,OAAO,EAAE,aAAa,EAAE,OAAO,EAAE,MAAM,sBAAsB,CAAC;AAE9D,MAAM,MAAM,oBAAoB,GAAG,WAAW,GAAG,OAAO,GAAG,YAAY,GAAG,eAAe,CAAC;AAC1F,MAAM,MAAM,kBAAkB,GAC1B,iBAAiB,GACjB,aAAa,GACb,kBA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AG,KAAK,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;KAChD;CA+DF,CAAC;AAUF,eAAO,MAAM,wBAAwB,qBACjB,iBAAiB,UAC3B,oBAAoB,KAC3B,MAAM,EAAkD,CAAC;AAE5D,eAAO,MAAM,8BAA8B,qBACvB,iBAAiB,UAC3B,kBAAkB,aAY3B,CAAC;AAEF,eAAO,MAAM,+BAA+B,qBACxB,iBAAiB,UAC3B,oBAAoB,WAC4C,CAAC;AAE3E,eAAO,MAAM,qCAAqC,qBAC9B,iBAAiB,UAC3B,kBAAkB,WAS3B,CAAC;AAEF,eAAO,MAAM,6BAA6B,qBACtB,iBAAiB,UAC3B,kBAAkB,yBAC2B,CAAC;AAExD,eAAO,MAAM,yBAAyB,qBAClB,iBAAiB,UAC3B,oBAAoB,WACoB,CAAC;AAEnD,eAAO,MAAM,+BAA+B,qBACxB,iBAAiB,gBACrB,kBAAkB,WAK/B,CAAC;AAEJ,eAAO,MAAM,wBAAwB,qBACjB,iBAAiB,UAC3B,oBAAoB,oCACqB,CAAC;AAEpD,eAAO,MAAM,8BAA8B,qBACvB,iBAAiB,gBACrB,kBAAkB,oCAK/B,CAAC"}
|
package/lib/utils/search.js
CHANGED
|
@@ -24,6 +24,12 @@ export const mappings = {
|
|
|
24
24
|
return joinWithSeparator([customer?.code, customer?.title, opp.vehicle?.external.identification.stockNumber].filter(Boolean));
|
|
25
25
|
},
|
|
26
26
|
getTags: (opp) => [opp.id],
|
|
27
|
+
getTagsForSearchEntity: (opp) => {
|
|
28
|
+
const vehicleTags = opp.vehicle != null
|
|
29
|
+
? getTagsForBusinessEntity(BusinessEntityIds.Vehicles, opp.vehicle)
|
|
30
|
+
: [];
|
|
31
|
+
return [...vehicleTags, opp.opportunity.id];
|
|
32
|
+
},
|
|
27
33
|
getMeta: (opp) => ({
|
|
28
34
|
status: opp.status,
|
|
29
35
|
wonAt: opp.wonAt,
|
|
@@ -37,7 +43,7 @@ export const mappings = {
|
|
|
37
43
|
vehicle.external.identification?.stockNumber,
|
|
38
44
|
vehicle.internal.identification?.administrativeNumber,
|
|
39
45
|
vehicle.external.identification?.vin,
|
|
40
|
-
],
|
|
46
|
+
].filter(Boolean),
|
|
41
47
|
},
|
|
42
48
|
[BusinessEntityIds.ExternalVehicleSale]: {
|
|
43
49
|
getMainEntity: (entity) => entity.vehicle,
|
|
@@ -46,17 +52,17 @@ export const mappings = {
|
|
|
46
52
|
vehicle.external.identification?.stockNumber,
|
|
47
53
|
vehicle.internal.identification?.administrativeNumber,
|
|
48
54
|
vehicle.external.identification?.vin,
|
|
49
|
-
],
|
|
55
|
+
].filter(Boolean),
|
|
50
56
|
},
|
|
51
57
|
[BusinessEntityIds.Organizations]: {
|
|
52
58
|
getMainEntity: (entity) => entity.org,
|
|
53
59
|
getTitle: (org) => org.name,
|
|
54
|
-
getTags: (org) => [`${org.externalId}`, org.vatNumber],
|
|
60
|
+
getTags: (org) => [`${org.externalId}`, org.vatNumber].filter(Boolean),
|
|
55
61
|
},
|
|
56
62
|
[BusinessEntityIds.LeasingContracts]: {
|
|
57
63
|
getMainEntity: (entity) => entity.contract,
|
|
58
64
|
getTitle: (contract) => contract.contractNumber ?? contract.id,
|
|
59
|
-
getTags: (contract) => [contract.contractNumber, contract.slbPartner],
|
|
65
|
+
getTags: (contract) => [contract.contractNumber, contract.slbPartner].filter(Boolean),
|
|
60
66
|
},
|
|
61
67
|
};
|
|
62
68
|
const getMapping = (businessEntityId) => {
|
|
@@ -66,8 +72,14 @@ const getMapping = (businessEntityId) => {
|
|
|
66
72
|
}
|
|
67
73
|
return mapping;
|
|
68
74
|
};
|
|
69
|
-
export const getTagsForBusinessEntity = (businessEntityId, entity) => getMapping(businessEntityId).getTags(entity)
|
|
70
|
-
export const getTagsForSearchBusinessEntity = (businessEntityId, entity) =>
|
|
75
|
+
export const getTagsForBusinessEntity = (businessEntityId, entity) => getMapping(businessEntityId).getTags(entity);
|
|
76
|
+
export const getTagsForSearchBusinessEntity = (businessEntityId, entity) => {
|
|
77
|
+
const tags = getMapping(businessEntityId).getTagsForSearchEntity?.(entity);
|
|
78
|
+
if (tags) {
|
|
79
|
+
return tags;
|
|
80
|
+
}
|
|
81
|
+
return getTagsForBusinessEntity(businessEntityId, getMainEntityFromSearchEntity(businessEntityId, entity));
|
|
82
|
+
};
|
|
71
83
|
export const getDescriptionForBusinessEntity = (businessEntityId, entity) => joinWithSeparator(getTagsForBusinessEntity(businessEntityId, entity));
|
|
72
84
|
export const getDescriptionForSearchBusinessEntity = (businessEntityId, entity) => {
|
|
73
85
|
return (getMapping(businessEntityId).getDescription?.(entity) ??
|
package/lib/utils/search.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"search.js","sourceRoot":"/","sources":["utils/search.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,mCAAmC,CAAC;AACtE,OAAO,EAAE,iBAAiB,EAAE,MAAM,iBAAiB,CAAC;AAcpD,MAAM,CAAC,MAAM,sBAAsB,GAAG,CAAC,GAAkB,EAAE,OAAiB,EAAE,EAAE;IAC9E,IAAI,GAAG,IAAI,IAAI,EAAE,CAAC;QAChB,OAAO;YACL,WAAW,EAAE,GAAG,CAAC,WAAW;YAC5B,KAAK,EAAE,GAAG,CAAC,IAAI;YACf,IAAI,EAAE,GAAG,CAAC,UAAU;SACrB,CAAC;IACJ,CAAC;IAED,IAAI,OAAO,IAAI,IAAI,EAAE,CAAC;QACpB,OAAO;YACL,WAAW,EAAE,OAAO,CAAC,WAAW;YAChC,KAAK,EAAE,CAAC,OAAO,EAAE,SAAS,EAAE,OAAO,EAAE,QAAQ,CAAC,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC;SACzE,CAAC;IACJ,CAAC;AACH,CAAC,CAAC;AAEF,MAAM,CAAC,MAAM,QAAQ,GAQjB;IACF,CAAC,iBAAiB,CAAC,aAAa,CAAC,EAAE;QACjC,aAAa,EAAE,C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,CAAC,MAAM,wBAAwB,GAAG,CACtC,gBAAmC,EACnC,MAA4B,EAC5B,EAAE,CAAC,UAAU,CAAC,gBAAgB,CAAC,CAAC,OAAO,EAAE,CAAC,MAAM,CAAC,CAAC;AAEpD,MAAM,CAAC,MAAM,8BAA8B,GAAG,CAC5C,gBAAmC,EACnC,YAAgC,EAChC,EAAE,CACF,wBAAwB,CACtB,gBAAgB,EAChB,6BAA6B,CAAC,gBAAgB,EAAE,YAAY,CAAC,CAC9D,CAAC","sourcesContent":["import { joinWithSeparator } from '@bisondesk/commons-sdk/formatting';\nimport { BusinessEntityIds } from '../constants.js';\nimport { Contact, Organization, SearchOrganization } from '../types/crm.js';\nimport { SearchLeasingContract } from '../types/leasing-search.js';\nimport { LeasingContract } from '../types/leasing.js';\nimport { Opportunity, SearchOpportunity } from '../types/opportunities.js';\nimport { SearchVehicle, Vehicle } from '../types/vehicles.js';\n\nexport type GlobalBusinessEntity = Opportunity | Vehicle | Organization | LeasingContract;\nexport type GlobalSearchEntity =\n | SearchOpportunity\n | SearchVehicle\n | SearchOrganization\n | SearchLeasingContract;\n\nexport const getCustomerInformation = (org?: Organization, contact?: Contact) => {\n if (org != null) {\n return {\n countryCode: org.countryCode,\n title: org.name,\n code: org.externalId,\n };\n }\n\n if (contact != null) {\n return {\n countryCode: contact.countryCode,\n title: [contact?.firstName, contact?.lastName].filter(Boolean).join(' '),\n };\n }\n};\n\nexport const mappings: {\n [key in BusinessEntityIds]?: {\n getMainEntity: (entity: any) => GlobalBusinessEntity;\n getTitle: (entity: any) => string;\n getTags: (entity: any) => (string | undefined)[];\n getDescription?: (entity: any) => string;\n getMeta?: (entity: any) => Record<string, any>;\n };\n} = {\n [BusinessEntityIds.Opportunities]: {\n getMainEntity: (entity: SearchOpportunity) => entity.opportunity,\n getTitle: (opp: Opportunity) => opp.id,\n getDescription: (opp: SearchOpportunity) => {\n const customer = getCustomerInformation(opp.org, opp.contact);\n return joinWithSeparator(\n [customer?.code, customer?.title, opp.vehicle?.external.identification.stockNumber].filter(\n Boolean\n )\n );\n },\n getTags: (opp: Opportunity) => [opp.id],\n getMeta: (opp: Opportunity) => ({\n status: opp.status,\n wonAt: opp.wonAt,\n lostAt: opp.lostAt,\n }),\n },\n [BusinessEntityIds.Vehicles]: {\n getMainEntity: (entity: SearchVehicle) => entity.vehicle,\n getTitle: (vehicle: Vehicle) => vehicle.internal.description.title,\n getTags: (vehicle: Vehicle) => [\n // the order of the tags here is relevant for exact integration\n // see: packages/exact/src/service/purchase.ts\n vehicle.external.identification?.stockNumber,\n vehicle.internal.identification?.administrativeNumber,\n vehicle.external.identification?.vin,\n ],\n },\n [BusinessEntityIds.ExternalVehicleSale]: {\n getMainEntity: (entity: SearchVehicle) => entity.vehicle,\n getTitle: (vehicle: Vehicle) => vehicle.internal.description.title,\n getTags: (vehicle: Vehicle) => [\n // the order of the tags here is relevant for exact integration\n // see: packages/exact/src/service/purchase.ts\n vehicle.external.identification?.stockNumber,\n vehicle.internal.identification?.administrativeNumber,\n vehicle.external.identification?.vin,\n ],\n },\n [BusinessEntityIds.Organizations]: {\n getMainEntity: (entity: SearchOrganization) => entity.org,\n getTitle: (org: Organization) => org.name,\n getTags: (org: Organization) => [`${org.externalId}`, org.vatNumber],\n },\n [BusinessEntityIds.LeasingContracts]: {\n getMainEntity: (entity: SearchLeasingContract) => entity.contract,\n getTitle: (contract: LeasingContract) => contract.contractNumber ?? contract.id,\n getTags: (contract: LeasingContract) => [contract.contractNumber, contract.slbPartner],\n },\n};\n\nconst getMapping = (businessEntityId: BusinessEntityIds) => {\n const mapping = mappings[businessEntityId];\n if (!mapping) {\n throw new Error(`Invalid business entity id ${businessEntityId}`);\n }\n return mapping;\n};\n\nexport const getTagsForBusinessEntity = (\n businessEntityId: BusinessEntityIds,\n entity: GlobalBusinessEntity\n): string[] => getMapping(businessEntityId).getTags(entity).filter(Boolean) as string[];\n\nexport const getTagsForSearchBusinessEntity = (\n businessEntityId: BusinessEntityIds,\n entity: GlobalSearchEntity\n) =>\n getTagsForBusinessEntity(\n businessEntityId,\n getMainEntityFromSearchEntity(businessEntityId, entity)\n );\n\nexport const getDescriptionForBusinessEntity = (\n businessEntityId: BusinessEntityIds,\n entity: GlobalBusinessEntity\n) => joinWithSeparator(getTagsForBusinessEntity(businessEntityId, entity));\n\nexport const getDescriptionForSearchBusinessEntity = (\n businessEntityId: BusinessEntityIds,\n entity: GlobalSearchEntity\n) => {\n return (\n getMapping(businessEntityId).getDescription?.(entity) ??\n getDescriptionForBusinessEntity(\n businessEntityId,\n getMainEntityFromSearchEntity(businessEntityId, entity)\n )\n );\n};\n\nexport const getMainEntityFromSearchEntity = (\n businessEntityId: BusinessEntityIds,\n entity: GlobalSearchEntity\n) => getMapping(businessEntityId).getMainEntity(entity);\n\nexport const getTitleForBusinessEntity = (\n businessEntityId: BusinessEntityIds,\n entity: GlobalBusinessEntity\n) => getMapping(businessEntityId).getTitle(entity);\n\nexport const getTitleForSearchBusinessEntity = (\n businessEntityId: BusinessEntityIds,\n searchEntity: GlobalSearchEntity\n) =>\n getTitleForBusinessEntity(\n businessEntityId,\n getMainEntityFromSearchEntity(businessEntityId, searchEntity)\n );\n\nexport const getMetaForBusinessEntity = (\n businessEntityId: BusinessEntityIds,\n entity: GlobalBusinessEntity\n) => getMapping(businessEntityId).getMeta?.(entity);\n\nexport const getMetaForSearchBusinessEntity = (\n businessEntityId: BusinessEntityIds,\n searchEntity: GlobalSearchEntity\n) =>\n getMetaForBusinessEntity(\n businessEntityId,\n getMainEntityFromSearchEntity(businessEntityId, searchEntity)\n );\n"]}
|
|
1
|
+
{"version":3,"file":"search.js","sourceRoot":"/","sources":["utils/search.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,mCAAmC,CAAC;AACtE,OAAO,EAAE,iBAAiB,EAAE,MAAM,iBAAiB,CAAC;AAcpD,MAAM,CAAC,MAAM,sBAAsB,GAAG,CAAC,GAAkB,EAAE,OAAiB,EAAE,EAAE;IA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AAC,OAAO,EAAE,CAAC,MAAM,CAAC,CAAC;AAEpD,MAAM,CAAC,MAAM,8BAA8B,GAAG,CAC5C,gBAAmC,EACnC,YAAgC,EAChC,EAAE,CACF,wBAAwB,CACtB,gBAAgB,EAChB,6BAA6B,CAAC,gBAAgB,EAAE,YAAY,CAAC,CAC9D,CAAC","sourcesContent":["import { joinWithSeparator } from '@bisondesk/commons-sdk/formatting';\nimport { BusinessEntityIds } from '../constants.js';\nimport { Contact, Organization, SearchOrganization } from '../types/crm.js';\nimport { SearchLeasingContract } from '../types/leasing-search.js';\nimport { LeasingContract } from '../types/leasing.js';\nimport { Opportunity, SearchOpportunity } from '../types/opportunities.js';\nimport { SearchVehicle, Vehicle } from '../types/vehicles.js';\n\nexport type GlobalBusinessEntity = Opportunity | Vehicle | Organization | LeasingContract;\nexport type GlobalSearchEntity =\n | SearchOpportunity\n | SearchVehicle\n | SearchOrganization\n | SearchLeasingContract;\n\nexport const getCustomerInformation = (org?: Organization, contact?: Contact) => {\n if (org != null) {\n return {\n countryCode: org.countryCode,\n title: org.name,\n code: org.externalId,\n };\n }\n\n if (contact != null) {\n return {\n countryCode: contact.countryCode,\n title: [contact?.firstName, contact?.lastName].filter(Boolean).join(' '),\n };\n }\n};\n\n// type Getters = {\n// getVehicle: (tenantId: string, vehicleId: string) => Promise<Vehicle>;\n// }\n\n// class Mapper() {\n// constructor({}: Getters) {\n\n// }\n\n// // mappings here\n// }\n\nexport const mappings: {\n [key in BusinessEntityIds]?: {\n getMainEntity: (entity: any) => GlobalBusinessEntity;\n getTitle: (entity: any) => string;\n getTags: (entity: any) => string[];\n getTagsForSearchEntity?: (entity: any) => string[];\n getDescription?: (entity: any) => string;\n getMeta?: (entity: any) => Record<string, any>;\n };\n} = {\n [BusinessEntityIds.Opportunities]: {\n getMainEntity: (entity: SearchOpportunity) => entity.opportunity,\n getTitle: (opp: Opportunity) => opp.id,\n getDescription: (opp: SearchOpportunity) => {\n const customer = getCustomerInformation(opp.org, opp.contact);\n return joinWithSeparator(\n [customer?.code, customer?.title, opp.vehicle?.external.identification.stockNumber].filter(\n Boolean\n )\n );\n },\n getTags: (opp: Opportunity) => [opp.id],\n getTagsForSearchEntity: (opp: SearchOpportunity) => {\n const vehicleTags =\n opp.vehicle != null\n ? getTagsForBusinessEntity(BusinessEntityIds.Vehicles, opp.vehicle)\n : [];\n return [...vehicleTags, opp.opportunity.id];\n },\n getMeta: (opp: Opportunity) => ({\n status: opp.status,\n wonAt: opp.wonAt,\n lostAt: opp.lostAt,\n }),\n },\n [BusinessEntityIds.Vehicles]: {\n getMainEntity: (entity: SearchVehicle) => entity.vehicle,\n getTitle: (vehicle: Vehicle) => vehicle.internal.description.title,\n getTags: (vehicle: Vehicle) =>\n [\n // the order of the tags here is relevant for exact integration\n // see: packages/exact/src/service/purchase.ts\n vehicle.external.identification?.stockNumber,\n vehicle.internal.identification?.administrativeNumber,\n vehicle.external.identification?.vin,\n ].filter(Boolean) as string[],\n },\n [BusinessEntityIds.ExternalVehicleSale]: {\n getMainEntity: (entity: SearchVehicle) => entity.vehicle,\n getTitle: (vehicle: Vehicle) => vehicle.internal.description.title,\n getTags: (vehicle: Vehicle) =>\n [\n // the order of the tags here is relevant for exact integration\n // see: packages/exact/src/service/purchase.ts\n vehicle.external.identification?.stockNumber,\n vehicle.internal.identification?.administrativeNumber,\n vehicle.external.identification?.vin,\n ].filter(Boolean) as string[],\n },\n [BusinessEntityIds.Organizations]: {\n getMainEntity: (entity: SearchOrganization) => entity.org,\n getTitle: (org: Organization) => org.name,\n getTags: (org: Organization) =>\n [`${org.externalId}`, org.vatNumber].filter(Boolean) as string[],\n },\n [BusinessEntityIds.LeasingContracts]: {\n getMainEntity: (entity: SearchLeasingContract) => entity.contract,\n getTitle: (contract: LeasingContract) => contract.contractNumber ?? contract.id,\n getTags: (contract: LeasingContract) =>\n [contract.contractNumber, contract.slbPartner].filter(Boolean) as string[],\n },\n};\n\nconst getMapping = (businessEntityId: BusinessEntityIds) => {\n const mapping = mappings[businessEntityId];\n if (!mapping) {\n throw new Error(`Invalid business entity id ${businessEntityId}`);\n }\n return mapping;\n};\n\nexport const getTagsForBusinessEntity = (\n businessEntityId: BusinessEntityIds,\n entity: GlobalBusinessEntity\n): string[] => getMapping(businessEntityId).getTags(entity);\n\nexport const getTagsForSearchBusinessEntity = (\n businessEntityId: BusinessEntityIds,\n entity: GlobalSearchEntity\n) => {\n const tags = getMapping(businessEntityId).getTagsForSearchEntity?.(entity);\n\n if (tags) {\n return tags;\n }\n\n return getTagsForBusinessEntity(\n businessEntityId,\n getMainEntityFromSearchEntity(businessEntityId, entity)\n );\n};\n\nexport const getDescriptionForBusinessEntity = (\n businessEntityId: BusinessEntityIds,\n entity: GlobalBusinessEntity\n) => joinWithSeparator(getTagsForBusinessEntity(businessEntityId, entity));\n\nexport const getDescriptionForSearchBusinessEntity = (\n businessEntityId: BusinessEntityIds,\n entity: GlobalSearchEntity\n) => {\n return (\n getMapping(businessEntityId).getDescription?.(entity) ??\n getDescriptionForBusinessEntity(\n businessEntityId,\n getMainEntityFromSearchEntity(businessEntityId, entity)\n )\n );\n};\n\nexport const getMainEntityFromSearchEntity = (\n businessEntityId: BusinessEntityIds,\n entity: GlobalSearchEntity\n) => getMapping(businessEntityId).getMainEntity(entity);\n\nexport const getTitleForBusinessEntity = (\n businessEntityId: BusinessEntityIds,\n entity: GlobalBusinessEntity\n) => getMapping(businessEntityId).getTitle(entity);\n\nexport const getTitleForSearchBusinessEntity = (\n businessEntityId: BusinessEntityIds,\n searchEntity: GlobalSearchEntity\n) =>\n getTitleForBusinessEntity(\n businessEntityId,\n getMainEntityFromSearchEntity(businessEntityId, searchEntity)\n );\n\nexport const getMetaForBusinessEntity = (\n businessEntityId: BusinessEntityIds,\n entity: GlobalBusinessEntity\n) => getMapping(businessEntityId).getMeta?.(entity);\n\nexport const getMetaForSearchBusinessEntity = (\n businessEntityId: BusinessEntityIds,\n searchEntity: GlobalSearchEntity\n) =>\n getMetaForBusinessEntity(\n businessEntityId,\n getMainEntityFromSearchEntity(businessEntityId, searchEntity)\n );\n"]}
|
package/package.json
CHANGED
package/src/utils/search.ts
CHANGED
|
@@ -30,11 +30,24 @@ export const getCustomerInformation = (org?: Organization, contact?: Contact) =>
|
|
|
30
30
|
}
|
|
31
31
|
};
|
|
32
32
|
|
|
33
|
+
// type Getters = {
|
|
34
|
+
// getVehicle: (tenantId: string, vehicleId: string) => Promise<Vehicle>;
|
|
35
|
+
// }
|
|
36
|
+
|
|
37
|
+
// class Mapper() {
|
|
38
|
+
// constructor({}: Getters) {
|
|
39
|
+
|
|
40
|
+
// }
|
|
41
|
+
|
|
42
|
+
// // mappings here
|
|
43
|
+
// }
|
|
44
|
+
|
|
33
45
|
export const mappings: {
|
|
34
46
|
[key in BusinessEntityIds]?: {
|
|
35
47
|
getMainEntity: (entity: any) => GlobalBusinessEntity;
|
|
36
48
|
getTitle: (entity: any) => string;
|
|
37
|
-
getTags: (entity: any) =>
|
|
49
|
+
getTags: (entity: any) => string[];
|
|
50
|
+
getTagsForSearchEntity?: (entity: any) => string[];
|
|
38
51
|
getDescription?: (entity: any) => string;
|
|
39
52
|
getMeta?: (entity: any) => Record<string, any>;
|
|
40
53
|
};
|
|
@@ -51,6 +64,13 @@ export const mappings: {
|
|
|
51
64
|
);
|
|
52
65
|
},
|
|
53
66
|
getTags: (opp: Opportunity) => [opp.id],
|
|
67
|
+
getTagsForSearchEntity: (opp: SearchOpportunity) => {
|
|
68
|
+
const vehicleTags =
|
|
69
|
+
opp.vehicle != null
|
|
70
|
+
? getTagsForBusinessEntity(BusinessEntityIds.Vehicles, opp.vehicle)
|
|
71
|
+
: [];
|
|
72
|
+
return [...vehicleTags, opp.opportunity.id];
|
|
73
|
+
},
|
|
54
74
|
getMeta: (opp: Opportunity) => ({
|
|
55
75
|
status: opp.status,
|
|
56
76
|
wonAt: opp.wonAt,
|
|
@@ -60,34 +80,38 @@ export const mappings: {
|
|
|
60
80
|
[BusinessEntityIds.Vehicles]: {
|
|
61
81
|
getMainEntity: (entity: SearchVehicle) => entity.vehicle,
|
|
62
82
|
getTitle: (vehicle: Vehicle) => vehicle.internal.description.title,
|
|
63
|
-
getTags: (vehicle: Vehicle) =>
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
83
|
+
getTags: (vehicle: Vehicle) =>
|
|
84
|
+
[
|
|
85
|
+
// the order of the tags here is relevant for exact integration
|
|
86
|
+
// see: packages/exact/src/service/purchase.ts
|
|
87
|
+
vehicle.external.identification?.stockNumber,
|
|
88
|
+
vehicle.internal.identification?.administrativeNumber,
|
|
89
|
+
vehicle.external.identification?.vin,
|
|
90
|
+
].filter(Boolean) as string[],
|
|
70
91
|
},
|
|
71
92
|
[BusinessEntityIds.ExternalVehicleSale]: {
|
|
72
93
|
getMainEntity: (entity: SearchVehicle) => entity.vehicle,
|
|
73
94
|
getTitle: (vehicle: Vehicle) => vehicle.internal.description.title,
|
|
74
|
-
getTags: (vehicle: Vehicle) =>
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
95
|
+
getTags: (vehicle: Vehicle) =>
|
|
96
|
+
[
|
|
97
|
+
// the order of the tags here is relevant for exact integration
|
|
98
|
+
// see: packages/exact/src/service/purchase.ts
|
|
99
|
+
vehicle.external.identification?.stockNumber,
|
|
100
|
+
vehicle.internal.identification?.administrativeNumber,
|
|
101
|
+
vehicle.external.identification?.vin,
|
|
102
|
+
].filter(Boolean) as string[],
|
|
81
103
|
},
|
|
82
104
|
[BusinessEntityIds.Organizations]: {
|
|
83
105
|
getMainEntity: (entity: SearchOrganization) => entity.org,
|
|
84
106
|
getTitle: (org: Organization) => org.name,
|
|
85
|
-
getTags: (org: Organization) =>
|
|
107
|
+
getTags: (org: Organization) =>
|
|
108
|
+
[`${org.externalId}`, org.vatNumber].filter(Boolean) as string[],
|
|
86
109
|
},
|
|
87
110
|
[BusinessEntityIds.LeasingContracts]: {
|
|
88
111
|
getMainEntity: (entity: SearchLeasingContract) => entity.contract,
|
|
89
112
|
getTitle: (contract: LeasingContract) => contract.contractNumber ?? contract.id,
|
|
90
|
-
getTags: (contract: LeasingContract) =>
|
|
113
|
+
getTags: (contract: LeasingContract) =>
|
|
114
|
+
[contract.contractNumber, contract.slbPartner].filter(Boolean) as string[],
|
|
91
115
|
},
|
|
92
116
|
};
|
|
93
117
|
|
|
@@ -102,16 +126,23 @@ const getMapping = (businessEntityId: BusinessEntityIds) => {
|
|
|
102
126
|
export const getTagsForBusinessEntity = (
|
|
103
127
|
businessEntityId: BusinessEntityIds,
|
|
104
128
|
entity: GlobalBusinessEntity
|
|
105
|
-
): string[] => getMapping(businessEntityId).getTags(entity)
|
|
129
|
+
): string[] => getMapping(businessEntityId).getTags(entity);
|
|
106
130
|
|
|
107
131
|
export const getTagsForSearchBusinessEntity = (
|
|
108
132
|
businessEntityId: BusinessEntityIds,
|
|
109
133
|
entity: GlobalSearchEntity
|
|
110
|
-
) =>
|
|
111
|
-
|
|
134
|
+
) => {
|
|
135
|
+
const tags = getMapping(businessEntityId).getTagsForSearchEntity?.(entity);
|
|
136
|
+
|
|
137
|
+
if (tags) {
|
|
138
|
+
return tags;
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
return getTagsForBusinessEntity(
|
|
112
142
|
businessEntityId,
|
|
113
143
|
getMainEntityFromSearchEntity(businessEntityId, entity)
|
|
114
144
|
);
|
|
145
|
+
};
|
|
115
146
|
|
|
116
147
|
export const getDescriptionForBusinessEntity = (
|
|
117
148
|
businessEntityId: BusinessEntityIds,
|