@bisondesk/core-sdk 1.0.551 → 1.0.553

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.
@@ -0,0 +1,7 @@
1
+ import { NextList } from '@bisondesk/commons-sdk/types';
2
+ import { InsightsSimilarRequest, InsightsVehicleComparableResponse } from '../types/insights.js';
3
+ import { ReferenceData } from '../types/utils.js';
4
+ import { SearchVehicle } from '../types/vehicles.js';
5
+ export declare const getStockVehicleComparableWithMeta: (tenantId: string, vehicleId: string) => Promise<InsightsVehicleComparableResponse>;
6
+ export declare const getSimilarStockVehicles: (tenantId: string, request: InsightsSimilarRequest) => Promise<NextList<SearchVehicle, ReferenceData>>;
7
+ //# sourceMappingURL=insights.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"insights.d.ts","sourceRoot":"/","sources":["apis/insights.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,QAAQ,EAAE,MAAM,8BAA8B,CAAC;AAIxD,OAAO,EAAE,sBAAsB,EAAE,iCAAiC,EAAE,MAAM,sBAAsB,CAAC;AACjG,OAAO,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAC;AAClD,OAAO,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AAErD,eAAO,MAAM,iCAAiC,GAC5C,UAAU,MAAM,EAChB,WAAW,MAAM,KAChB,OAAO,CAAC,iCAAiC,CAgB3C,CAAC;AAEF,eAAO,MAAM,uBAAuB,GAClC,UAAU,MAAM,EAChB,SAAS,sBAAsB,KAC9B,OAAO,CAAC,QAAQ,CAAC,aAAa,EAAE,aAAa,CAAC,CAmBhD,CAAC"}
@@ -0,0 +1,38 @@
1
+ import { TENANT_ID_ADMIN_HEADER } from '@bisondesk/commons-sdk/constants';
2
+ import { XError } from '@bisondesk/commons-sdk/errors';
3
+ import { getAdminAuth } from '@bisondesk/commons-sdk/fetch';
4
+ import fetch from 'node-fetch';
5
+ export const getStockVehicleComparableWithMeta = async (tenantId, vehicleId) => {
6
+ const auth = await getAdminAuth();
7
+ const url = `${process.env.CORE_API_ORIGIN}/api/insights/comparable/stock-vehicle/${vehicleId}`;
8
+ const response = await fetch(url, {
9
+ headers: {
10
+ Authorization: auth,
11
+ [TENANT_ID_ADMIN_HEADER]: tenantId,
12
+ },
13
+ });
14
+ if (response.ok) {
15
+ return response.json();
16
+ }
17
+ const body = await response.text();
18
+ throw new XError(response.statusText, { url, body, tenantId, vehicleId });
19
+ };
20
+ export const getSimilarStockVehicles = async (tenantId, request) => {
21
+ const auth = await getAdminAuth();
22
+ const url = `${process.env.CORE_API_ORIGIN}/api/insights/similar/stock`;
23
+ const response = await fetch(url, {
24
+ method: 'POST',
25
+ headers: {
26
+ Authorization: auth,
27
+ 'Content-Type': 'application/json',
28
+ [TENANT_ID_ADMIN_HEADER]: tenantId,
29
+ },
30
+ body: JSON.stringify(request),
31
+ });
32
+ if (response.ok) {
33
+ return response.json();
34
+ }
35
+ const body = await response.text();
36
+ throw new XError(response.statusText, { url, body, tenantId, request });
37
+ };
38
+ //# sourceMappingURL=insights.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"insights.js","sourceRoot":"/","sources":["apis/insights.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,sBAAsB,EAAE,MAAM,kCAAkC,CAAC;AAE1E,OAAO,EAAE,MAAM,EAAE,MAAM,+BAA+B,CAAC;AACvD,OAAO,EAAE,YAAY,EAAE,MAAM,8BAA8B,CAAC;AAC5D,OAAO,KAAmB,MAAM,YAAY,CAAC;AAK7C,MAAM,CAAC,MAAM,iCAAiC,GAAG,KAAK,EACpD,QAAgB,EAChB,SAAiB,EAC2B,EAAE;IAC9C,MAAM,IAAI,GAAG,MAAM,YAAY,EAAE,CAAC;IAClC,MAAM,GAAG,GAAG,GAAG,OAAO,CAAC,GAAG,CAAC,eAAe,0CAA0C,SAAS,EAAE,CAAC;IAChG,MAAM,QAAQ,GAAa,MAAM,KAAK,CAAC,GAAG,EAAE;QAC1C,OAAO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List } from '@bisondesk/commons-sdk/types';\nimport { XError } from '@bisondesk/commons-sdk/errors';\nimport { getAdminAuth } from '@bisondesk/commons-sdk/fetch';\nimport fetch, { Response } from 'node-fetch';\nimport { InsightsSimilarRequest, InsightsVehicleComparableResponse } from '../types/insights.js';\nimport { ReferenceData } from '../types/utils.js';\nimport { SearchVehicle } from '../types/vehicles.js';\n\nexport const getStockVehicleComparableWithMeta = async (\n tenantId: string,\n vehicleId: string\n): Promise<InsightsVehicleComparableResponse> => {\n const auth = await getAdminAuth();\n const url = `${process.env.CORE_API_ORIGIN}/api/insights/comparable/stock-vehicle/${vehicleId}`;\n const response: Response = await fetch(url, {\n headers: {\n Authorization: auth,\n [TENANT_ID_ADMIN_HEADER]: tenantId,\n },\n });\n\n if (response.ok) {\n return response.json() as any;\n }\n\n const body = await response.text();\n throw new XError(response.statusText, { url, body, tenantId, vehicleId });\n};\n\nexport const getSimilarStockVehicles = async (\n tenantId: string,\n request: InsightsSimilarRequest\n): Promise<NextList<SearchVehicle, ReferenceData>> => {\n const auth = await getAdminAuth();\n const url = `${process.env.CORE_API_ORIGIN}/api/insights/similar/stock`;\n const response: Response = await fetch(url, {\n method: 'POST',\n headers: {\n Authorization: auth,\n 'Content-Type': 'application/json',\n [TENANT_ID_ADMIN_HEADER]: tenantId,\n },\n body: JSON.stringify(request),\n });\n\n if (response.ok) {\n return response.json() as any;\n }\n\n const body = await response.text();\n throw new XError(response.statusText, { url, body, tenantId, request });\n};\n"]}
@@ -1,5 +1,6 @@
1
1
  import { AppRoles, TopLevelActions } from '@bisondesk/commons-sdk/constants';
2
2
  import { AttachmentValue, PhoneNumberRawValue, PhoneNumberValue } from '@bisondesk/commons-sdk/types';
3
+ import { OpportunityType } from '../constants.js';
3
4
  export type NewUserRequest = {
4
5
  email: string;
5
6
  firstName: string;
@@ -12,6 +13,8 @@ export type NewUserRequest = {
12
13
  picture?: AttachmentValue;
13
14
  roles: AppRoles[];
14
15
  teamId?: string;
16
+ preferredBranchIds?: string[];
17
+ preferredOpportunityTypes?: OpportunityType[];
15
18
  };
16
19
  export type ValidNewUserRequest = Omit<NewUserRequest, 'phone' | 'landline'> & {
17
20
  phone: PhoneNumberValue;
@@ -38,6 +41,8 @@ export type User = {
38
41
  roles: AppRoles[];
39
42
  updatedAt: string;
40
43
  teamId?: string;
44
+ preferredBranchIds?: string[];
45
+ preferredOpportunityTypes?: OpportunityType[];
41
46
  };
42
47
  export type UserSummary = {
43
48
  firstName: string;
@@ -1 +1 @@
1
- {"version":3,"file":"users.d.ts","sourceRoot":"/","sources":["types/users.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,eAAe,EAAE,MAAM,kCAAkC,CAAC;AAC7E,OAAO,EACL,eAAe,EACf,mBAAmB,EACnB,gBAAgB,EACjB,MAAM,8BAA8B,CAAC;AAEtC,MAAM,MAAM,cAAc,GAAG;IAC3B,KAAK,EAAE,MAAM,CAAC;IACd,SAAS,EAAE,MAAM,CAAC;IAClB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,QAAQ,CAAC,EAAE,mBAAmB,CAAC;IAC/B,QAAQ,EAAE,MAAM,CAAC;IACjB,QAAQ,EAAE,MAAM,CAAC;IACjB,KAAK,EAAE,mBAAmB,CAAC;IAC3B,OAAO,CAAC,EAAE,eAAe,CAAC;IAC1B,KAAK,EAAE,QAAQ,EAAE,CAAC;IAClB,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB,CAAC;AAEF,MAAM,MAAM,mBAAmB,GAAG,IAAI,CAAC,cAAc,EAAE,OAAO,GAAG,UAAU,CAAC,GAAG;IAC7E,KAAK,EAAE,gBAAgB,CAAC;IACxB,QAAQ,CAAC,EAAE,gBAAgB,CAAC;CAC7B,CAAC;AAEF,MAAM,MAAM,iBAAiB,GAAG,IAAI,CAAC,IAAI,EAAE,OAAO,GAAG,UAAU,CAAC,GAAG;IACjE,KAAK,EAAE,mBAAmB,GAAG,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X,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,QAAQ,CAAC,EAAE,gBAAgB,CAAC;IAC5B,QAAQ,EAAE,MAAM,CAAC;IACjB,QAAQ,EAAE,MAAM,CAAC;IACjB,KAAK,EAAE,gBAAgB,CAAC;IACxB,OAAO,CAAC,EAAE,eAAe,CAAC;IAC1B,WAAW,CAAC,EAAE,eAAe,EAAE,CAAC;IAChC,KAAK,EAAE,QAAQ,EAAE,CAAC;IAClB,SAAS,EAAE,MAAM,CAAC;IAClB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,kBAAkB,CAAC,EAAE,MAAM,EAAE,CAAC;IAC9B,yBAAyB,CAAC,EAAE,eAAe,EAAE,CAAC;CAC/C,CAAC;AAIF,MAAM,MAAM,WAAW,GAAG;IACxB,SAAS,EAAE,MAAM,CAAC;IAClB,EAAE,EAAE,MAAM,CAAC;IACX,QAAQ,EAAE,MAAM,CAAC;IACjB,OAAO,CAAC,EAAE,eAAe,CAAC;IAC1B,MAAM,EAAE,OAAO,CAAC;CACjB,CAAC;AAEF,MAAM,MAAM,IAAI,GAAG;IACjB,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,MAAM,CAAC;IACb,QAAQ,EAAE,OAAO,CAAC;IAClB,SAAS,EAAE,MAAM,CAAC;CACnB,CAAC;AAEF,MAAM,MAAM,cAAc,GAAG;IAC3B,IAAI,EAAE,MAAM,CAAC;CACd,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"users.js","sourceRoot":"/","sources":["types/users.ts"],"names":[],"mappings":"","sourcesContent":["import { AppRoles, TopLevelActions } from '@bisondesk/commons-sdk/constants';\nimport {\n AttachmentValue,\n PhoneNumberRawValue,\n PhoneNumberValue,\n} from '@bisondesk/commons-sdk/types';\n\nexport type NewUserRequest = {\n email: string;\n firstName: string;\n googleEmail?: string;\n jobTitle?: string;\n landline?: PhoneNumberRawValue; // landline phone number\n language: string;\n lastName: string;\n phone: PhoneNumberRawValue;\n picture?: AttachmentValue;\n roles: AppRoles[];\n teamId?: string;\n};\n\nexport type ValidNewUserRequest = Omit<NewUserRequest, 'phone' | 'landline'> & {\n phone: PhoneNumberValue;\n landline?: PhoneNumberValue;\n};\n\nexport type UpdateUserRequest = Omit<User, 'phone' | 'landline'> & {\n phone: PhoneNumberRawValue | PhoneNumberValue;\n landline?: PhoneNumberRawValue | PhoneNumberValue;\n};\n\nexport type User = {\n active: boolean;\n createdAt: string;\n email: string;\n firstName: string;\n googleEmail?: string;\n id: string;\n jobTitle?: string;\n landline?: PhoneNumberValue; // landline phone number\n language: string;\n lastName: string;\n phone: PhoneNumberValue;\n picture?: AttachmentValue;\n roleActions?: TopLevelActions[]; // auto-generated based on the roles provided in the request\n roles: AppRoles[];\n updatedAt: string;\n teamId?: string; // at most one team, otherwise we would not be able to know which team to use in the vehicle-performance logic\n};\n\n// Short version of the User entity, with only the properties\n// that should be available to any app user.\nexport type UserSummary = {\n firstName: string;\n id: string;\n lastName: string;\n picture?: AttachmentValue;\n active: boolean;\n};\n\nexport type Team = {\n id: string;\n name: string;\n archived: boolean;\n createdAt: string;\n};\n\nexport type NewTeamRequest = {\n name: string;\n};\n"]}
1
+ {"version":3,"file":"users.js","sourceRoot":"/","sources":["types/users.ts"],"names":[],"mappings":"","sourcesContent":["import { AppRoles, TopLevelActions } from '@bisondesk/commons-sdk/constants';\nimport {\n AttachmentValue,\n PhoneNumberRawValue,\n PhoneNumberValue,\n} from '@bisondesk/commons-sdk/types';\nimport { OpportunityType } from '../constants.js';\n\nexport type NewUserRequest = {\n email: string;\n firstName: string;\n googleEmail?: string;\n jobTitle?: string;\n landline?: PhoneNumberRawValue; // landline phone number\n language: string;\n lastName: string;\n phone: PhoneNumberRawValue;\n picture?: AttachmentValue;\n roles: AppRoles[];\n teamId?: string;\n preferredBranchIds?: string[];\n preferredOpportunityTypes?: OpportunityType[];\n};\n\nexport type ValidNewUserRequest = Omit<NewUserRequest, 'phone' | 'landline'> & {\n phone: PhoneNumberValue;\n landline?: PhoneNumberValue;\n};\n\nexport type UpdateUserRequest = Omit<User, 'phone' | 'landline'> & {\n phone: PhoneNumberRawValue | PhoneNumberValue;\n landline?: PhoneNumberRawValue | PhoneNumberValue;\n};\n\nexport type User = {\n active: boolean;\n createdAt: string;\n email: string;\n firstName: string;\n googleEmail?: string;\n id: string;\n jobTitle?: string;\n landline?: PhoneNumberValue; // landline phone number\n language: string;\n lastName: string;\n phone: PhoneNumberValue;\n picture?: AttachmentValue;\n roleActions?: TopLevelActions[]; // auto-generated based on the roles provided in the request\n roles: AppRoles[];\n updatedAt: string;\n teamId?: string; // at most one team, otherwise we would not be able to know which team to use in the vehicle-performance logic\n preferredBranchIds?: string[];\n preferredOpportunityTypes?: OpportunityType[];\n};\n\n// Short version of the User entity, with only the properties\n// that should be available to any app user.\nexport type UserSummary = {\n firstName: string;\n id: string;\n lastName: string;\n picture?: AttachmentValue;\n active: boolean;\n};\n\nexport type Team = {\n id: string;\n name: string;\n archived: boolean;\n createdAt: string;\n};\n\nexport type NewTeamRequest = {\n name: string;\n};\n"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bisondesk/core-sdk",
3
- "version": "1.0.551",
3
+ "version": "1.0.553",
4
4
  "description": "",
5
5
  "type": "module",
6
6
  "scripts": {
@@ -15,7 +15,7 @@
15
15
  "decimal.js": "10.4.3",
16
16
  "immer": "10.0.3",
17
17
  "joi": "17.13.3",
18
- "lodash-es": "4.17.21",
18
+ "lodash-es": "4.17.23",
19
19
  "slugify": "1.6.6"
20
20
  },
21
21
  "devDependencies": {
@@ -0,0 +1,53 @@
1
+ import { TENANT_ID_ADMIN_HEADER } from '@bisondesk/commons-sdk/constants';
2
+ import { NextList } from '@bisondesk/commons-sdk/types';
3
+ import { XError } from '@bisondesk/commons-sdk/errors';
4
+ import { getAdminAuth } from '@bisondesk/commons-sdk/fetch';
5
+ import fetch, { Response } from 'node-fetch';
6
+ import { InsightsSimilarRequest, InsightsVehicleComparableResponse } from '../types/insights.js';
7
+ import { ReferenceData } from '../types/utils.js';
8
+ import { SearchVehicle } from '../types/vehicles.js';
9
+
10
+ export const getStockVehicleComparableWithMeta = async (
11
+ tenantId: string,
12
+ vehicleId: string
13
+ ): Promise<InsightsVehicleComparableResponse> => {
14
+ const auth = await getAdminAuth();
15
+ const url = `${process.env.CORE_API_ORIGIN}/api/insights/comparable/stock-vehicle/${vehicleId}`;
16
+ const response: Response = await fetch(url, {
17
+ headers: {
18
+ Authorization: auth,
19
+ [TENANT_ID_ADMIN_HEADER]: tenantId,
20
+ },
21
+ });
22
+
23
+ if (response.ok) {
24
+ return response.json() as any;
25
+ }
26
+
27
+ const body = await response.text();
28
+ throw new XError(response.statusText, { url, body, tenantId, vehicleId });
29
+ };
30
+
31
+ export const getSimilarStockVehicles = async (
32
+ tenantId: string,
33
+ request: InsightsSimilarRequest
34
+ ): Promise<NextList<SearchVehicle, ReferenceData>> => {
35
+ const auth = await getAdminAuth();
36
+ const url = `${process.env.CORE_API_ORIGIN}/api/insights/similar/stock`;
37
+ const response: Response = await fetch(url, {
38
+ method: 'POST',
39
+ headers: {
40
+ Authorization: auth,
41
+ 'Content-Type': 'application/json',
42
+ [TENANT_ID_ADMIN_HEADER]: tenantId,
43
+ },
44
+ body: JSON.stringify(request),
45
+ });
46
+
47
+ if (response.ok) {
48
+ return response.json() as any;
49
+ }
50
+
51
+ const body = await response.text();
52
+ throw new XError(response.statusText, { url, body, tenantId, request });
53
+ };
@@ -4,6 +4,7 @@ import {
4
4
  PhoneNumberRawValue,
5
5
  PhoneNumberValue,
6
6
  } from '@bisondesk/commons-sdk/types';
7
+ import { OpportunityType } from '../constants.js';
7
8
 
8
9
  export type NewUserRequest = {
9
10
  email: string;
@@ -17,6 +18,8 @@ export type NewUserRequest = {
17
18
  picture?: AttachmentValue;
18
19
  roles: AppRoles[];
19
20
  teamId?: string;
21
+ preferredBranchIds?: string[];
22
+ preferredOpportunityTypes?: OpportunityType[];
20
23
  };
21
24
 
22
25
  export type ValidNewUserRequest = Omit<NewUserRequest, 'phone' | 'landline'> & {
@@ -46,6 +49,8 @@ export type User = {
46
49
  roles: AppRoles[];
47
50
  updatedAt: string;
48
51
  teamId?: string; // at most one team, otherwise we would not be able to know which team to use in the vehicle-performance logic
52
+ preferredBranchIds?: string[];
53
+ preferredOpportunityTypes?: OpportunityType[];
49
54
  };
50
55
 
51
56
  // Short version of the User entity, with only the properties