@bisondesk/core-sdk 1.0.355 → 1.0.357
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 +3 -0
- package/lib/utils/search.d.ts.map +1 -1
- package/lib/utils/search.js +10 -5
- package/lib/utils/search.js.map +1 -1
- package/package.json +1 -1
- package/src/utils/search.ts +27 -8
- package/tsconfig.tsbuildinfo +1 -1
package/lib/utils/search.d.ts
CHANGED
|
@@ -21,6 +21,7 @@ export declare const mappings: {
|
|
|
21
21
|
getTitle: (entity: any) => string;
|
|
22
22
|
getTags: (entity: any) => (string | undefined)[];
|
|
23
23
|
getDescription?: (entity: any) => string;
|
|
24
|
+
getMeta?: (entity: any) => Record<string, any>;
|
|
24
25
|
};
|
|
25
26
|
};
|
|
26
27
|
export declare const getTagsForBusinessEntity: (businessEntityId: BusinessEntityIds, entity: GlobalBusinessEntity) => string[];
|
|
@@ -30,4 +31,6 @@ export declare const getDescriptionForSearchBusinessEntity: (businessEntityId: B
|
|
|
30
31
|
export declare const getMainEntityFromSearchEntity: (businessEntityId: BusinessEntityIds, entity: GlobalSearchEntity) => GlobalBusinessEntity;
|
|
31
32
|
export declare const getTitleForBusinessEntity: (businessEntityId: BusinessEntityIds, entity: GlobalBusinessEntity) => string;
|
|
32
33
|
export declare const getTitleForSearchBusinessEntity: (businessEntityId: BusinessEntityIds, searchEntity: GlobalSearchEntity) => string;
|
|
34
|
+
export declare const getMetaForBusinessEntity: (businessEntityId: BusinessEntityIds, entity: GlobalBusinessEntity) => Record<string, any> | undefined;
|
|
35
|
+
export declare const getMetaForSearchBusinessEntity: (businessEntityId: BusinessEntityIds, searchEntity: GlobalSearchEntity) => Record<string, any> | undefined;
|
|
33
36
|
//# sourceMappingURL=search.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"search.d.ts","sourceRoot":"/","sources":["utils/search.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,i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B,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
|
@@ -19,11 +19,14 @@ export const mappings = {
|
|
|
19
19
|
[BusinessEntityIds.Opportunities]: {
|
|
20
20
|
getMainEntity: (entity) => entity.opportunity,
|
|
21
21
|
getTitle: (opp) => opp.id,
|
|
22
|
-
getDescription: (opp) =>
|
|
23
|
-
getCustomerInformation(opp.org, opp.contact)
|
|
24
|
-
opp.vehicle?.external.identification.stockNumber
|
|
25
|
-
|
|
26
|
-
getTags: (opp) => [opp.id],
|
|
22
|
+
getDescription: (opp) => {
|
|
23
|
+
const customer = getCustomerInformation(opp.org, opp.contact);
|
|
24
|
+
return joinWithSeparator([customer?.code, customer?.title, opp.vehicle?.external.identification.stockNumber].filter(Boolean));
|
|
25
|
+
},
|
|
26
|
+
getTags: (opp) => [opp.id, opp.status],
|
|
27
|
+
getMeta: (opp) => ({
|
|
28
|
+
status: opp.status,
|
|
29
|
+
}),
|
|
27
30
|
},
|
|
28
31
|
[BusinessEntityIds.Vehicles]: {
|
|
29
32
|
getMainEntity: (entity) => entity.vehicle,
|
|
@@ -62,4 +65,6 @@ export const getDescriptionForSearchBusinessEntity = (businessEntityId, entity)
|
|
|
62
65
|
export const getMainEntityFromSearchEntity = (businessEntityId, entity) => getMapping(businessEntityId).getMainEntity(entity);
|
|
63
66
|
export const getTitleForBusinessEntity = (businessEntityId, entity) => getMapping(businessEntityId).getTitle(entity);
|
|
64
67
|
export const getTitleForSearchBusinessEntity = (businessEntityId, searchEntity) => getTitleForBusinessEntity(businessEntityId, getMainEntityFromSearchEntity(businessEntityId, searchEntity));
|
|
68
|
+
export const getMetaForBusinessEntity = (businessEntityId, entity) => getMapping(businessEntityId).getMeta?.(entity);
|
|
69
|
+
export const getMetaForSearchBusinessEntity = (businessEntityId, searchEntity) => getMetaForBusinessEntity(businessEntityId, getMainEntityFromSearchEntity(businessEntityId, searchEntity));
|
|
65
70
|
//# sourceMappingURL=search.js.map
|
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,
|
|
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,MA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C7C,gBAAmC,EACnC,YAAgC,EAChC,EAAE,CACF,yBAAyB,CACvB,gBAAgB,EAChB,6BAA6B,CAAC,gBAAgB,EAAE,YAAY,CAAC,CAC9D,CAAC;AAEJ,MAAM,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, opp.status],\n getMeta: (opp: Opportunity) => ({\n status: opp.status,\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.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"]}
|
package/package.json
CHANGED
package/src/utils/search.ts
CHANGED
|
@@ -36,19 +36,24 @@ export const mappings: {
|
|
|
36
36
|
getTitle: (entity: any) => string;
|
|
37
37
|
getTags: (entity: any) => (string | undefined)[];
|
|
38
38
|
getDescription?: (entity: any) => string;
|
|
39
|
+
getMeta?: (entity: any) => Record<string, any>;
|
|
39
40
|
};
|
|
40
41
|
} = {
|
|
41
42
|
[BusinessEntityIds.Opportunities]: {
|
|
42
43
|
getMainEntity: (entity: SearchOpportunity) => entity.opportunity,
|
|
43
44
|
getTitle: (opp: Opportunity) => opp.id,
|
|
44
|
-
getDescription: (opp: SearchOpportunity) =>
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
)
|
|
51
|
-
|
|
45
|
+
getDescription: (opp: SearchOpportunity) => {
|
|
46
|
+
const customer = getCustomerInformation(opp.org, opp.contact);
|
|
47
|
+
return joinWithSeparator(
|
|
48
|
+
[customer?.code, customer?.title, opp.vehicle?.external.identification.stockNumber].filter(
|
|
49
|
+
Boolean
|
|
50
|
+
)
|
|
51
|
+
);
|
|
52
|
+
},
|
|
53
|
+
getTags: (opp: Opportunity) => [opp.id, opp.status],
|
|
54
|
+
getMeta: (opp: Opportunity) => ({
|
|
55
|
+
status: opp.status,
|
|
56
|
+
}),
|
|
52
57
|
},
|
|
53
58
|
[BusinessEntityIds.Vehicles]: {
|
|
54
59
|
getMainEntity: (entity: SearchVehicle) => entity.vehicle,
|
|
@@ -131,3 +136,17 @@ export const getTitleForSearchBusinessEntity = (
|
|
|
131
136
|
businessEntityId,
|
|
132
137
|
getMainEntityFromSearchEntity(businessEntityId, searchEntity)
|
|
133
138
|
);
|
|
139
|
+
|
|
140
|
+
export const getMetaForBusinessEntity = (
|
|
141
|
+
businessEntityId: BusinessEntityIds,
|
|
142
|
+
entity: GlobalBusinessEntity
|
|
143
|
+
) => getMapping(businessEntityId).getMeta?.(entity);
|
|
144
|
+
|
|
145
|
+
export const getMetaForSearchBusinessEntity = (
|
|
146
|
+
businessEntityId: BusinessEntityIds,
|
|
147
|
+
searchEntity: GlobalSearchEntity
|
|
148
|
+
) =>
|
|
149
|
+
getMetaForBusinessEntity(
|
|
150
|
+
businessEntityId,
|
|
151
|
+
getMainEntityFromSearchEntity(businessEntityId, searchEntity)
|
|
152
|
+
);
|