@workwell-global/component-library 1.1.32 → 1.1.34

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,6 +1,7 @@
1
1
  import { z } from 'zod'
2
2
  import { documentBaseFields } from './bases/SDocumentBase'
3
3
  import { createEntityToolkit } from '../helpers/EntityToolkit'
4
+ import { d365OwnershipBaseFields } from './bases/SBaseAPI'
4
5
 
5
6
  export const companyDocumentFields = {
6
7
  ...documentBaseFields,
@@ -20,7 +21,7 @@ export const companyDocumentFields = {
20
21
 
21
22
  export const CompanyDocumentToolkit = createEntityToolkit(
22
23
  companyDocumentFields,
23
- 'ownership',
24
+ d365OwnershipBaseFields,
24
25
  )
25
26
 
26
27
  // Export Types
@@ -1,6 +1,7 @@
1
1
  import { z } from 'zod'
2
2
  import { documentBaseFields } from './bases/SDocumentBase'
3
3
  import { createEntityToolkit } from '../helpers/EntityToolkit'
4
+ import { d365OwnershipBaseFields } from './bases/SBaseAPI'
4
5
 
5
6
  export const contractorDocumentFields = {
6
7
  ...documentBaseFields, // Merge the base
@@ -12,8 +13,8 @@ export const contractorDocumentFields = {
12
13
  pretty: 'directorApprovedValue',
13
14
  type: z.string().nullish(),
14
15
  },
15
- _ww_scats_contractingcompany_value: {
16
- pretty: 'scatsContractingCompanyValue',
16
+ _ww_scats_contractingContractor_value: {
17
+ pretty: 'scatsContractingContractorValue',
17
18
  type: z.string().nullish(),
18
19
  },
19
20
  ww_contractordocumentid: {
@@ -59,7 +60,7 @@ export const contractorDocumentFields = {
59
60
 
60
61
  export const ContractorDocumentToolkit = createEntityToolkit(
61
62
  contractorDocumentFields,
62
- 'ownership',
63
+ d365OwnershipBaseFields,
63
64
  )
64
65
 
65
66
  export type TContractorDocumentD365 = z.infer<
@@ -1,5 +1,6 @@
1
1
  import { z } from 'zod'
2
2
  import { createEntityToolkit } from '../helpers/EntityToolkit'
3
+ import { d365OrganisationBaseFields } from './bases/SBaseAPI'
3
4
 
4
5
  export const countryFields = {
5
6
  ww_countryid: { pretty: 'countryId', type: z.string().nullish() },
@@ -44,7 +45,10 @@ export const countryFields = {
44
45
  },
45
46
  } as const
46
47
 
47
- export const CountryToolkit = createEntityToolkit(countryFields, 'organisation')
48
+ export const CountryToolkit = createEntityToolkit(
49
+ countryFields,
50
+ d365OrganisationBaseFields,
51
+ )
48
52
 
49
53
  // Export Types
50
54
  export type TCountryD365 = z.infer<typeof CountryToolkit.SResponseD365>
@@ -1,5 +1,6 @@
1
1
  import { z } from 'zod'
2
2
  import { createEntityToolkit } from '../helpers/EntityToolkit'
3
+ import { d365OrganisationBaseFields } from './bases/SBaseAPI'
3
4
 
4
5
  export const currencyFields = {
5
6
  transactioncurrencyid: { pretty: 'currencyId', type: z.string().nullish() },
@@ -15,7 +16,7 @@ export const currencyFields = {
15
16
 
16
17
  export const CurrencyToolkit = createEntityToolkit(
17
18
  currencyFields,
18
- 'organisation',
19
+ d365OrganisationBaseFields,
19
20
  )
20
21
 
21
22
  // Export Types
@@ -1,6 +1,7 @@
1
1
  import { z } from 'zod'
2
2
  import { createEntityToolkit } from '../helpers/EntityToolkit'
3
3
  import { SimulationToolkit } from './SSimulationAPI'
4
+ import { d365OwnershipBaseFields } from './bases/SBaseAPI'
4
5
 
5
6
  const enquiryFields = {
6
7
  ww_enquiryid: { pretty: 'enquiryId', type: z.string() }, // Required in your type
@@ -115,7 +116,10 @@ const enquiryFields = {
115
116
  },
116
117
  } as const
117
118
 
118
- export const EnquiryToolkit = createEntityToolkit(enquiryFields, 'ownership')
119
+ export const EnquiryToolkit = createEntityToolkit(
120
+ enquiryFields,
121
+ d365OwnershipBaseFields,
122
+ )
119
123
 
120
124
  export type TEnquiryD365 = z.infer<typeof EnquiryToolkit.SResponseD365>
121
125
  export type TEnquiryPayloadD365 = z.infer<typeof EnquiryToolkit.SPayloadD365>
@@ -4,6 +4,7 @@ import { ContractorDocumentToolkit } from './SContractorDocumentAPI'
4
4
  import { CountryToolkit } from './SCountryApi'
5
5
  import { CurrencyToolkit } from './SCurrencyAPI'
6
6
  import { SolutionToolkit } from './SSolutionAPI'
7
+ import { d365OwnershipBaseFields } from './bases/SBaseAPI'
7
8
 
8
9
  const simulationFields = {
9
10
  _ww_enquiry_value: {
@@ -566,7 +567,7 @@ const simulationFields = {
566
567
 
567
568
  export const SimulationToolkit = createEntityToolkit(
568
569
  simulationFields,
569
- 'ownership',
570
+ d365OwnershipBaseFields,
570
571
  )
571
572
 
572
573
  export type TSimulationD365 = z.infer<typeof SimulationToolkit.SResponseD365>
@@ -1,12 +1,27 @@
1
1
  import { z } from 'zod'
2
2
  import { createEntityToolkit } from '../helpers/EntityToolkit'
3
+ import { d365OrganisationBaseFields } from './bases/SBaseAPI'
4
+
5
+ export const solutionKeyMap = {
6
+ ww_scats_parent_aor: 'AOR',
7
+ ww_scats_parent_eor: 'EOR',
8
+ ww_scats_ctc_full_ser: 'C2CFullService',
9
+ ww_scats_ltdco: 'C2CNoAccount',
10
+ ww_scats_selfemployed: 'SEFullService',
11
+ ww_scats_selfemployed_noaccnt: 'SENoAccount',
12
+ ww_scats_sla: 'SLA',
13
+ ww_scats_employed: 'ICP',
14
+ ww_scats_mpp: 'MPP',
15
+ ww_scats_cpaye: 'PAYE',
16
+ ww_scats_ppaye: 'PremiumAFunding',
17
+ ww_scats_premium_b: 'PremiumBERObligations',
18
+ ww_scats_eor: 'Salaried',
19
+ }
3
20
 
4
21
  export const solutionFields = {
5
22
  productid: { pretty: 'productId', type: z.string().nullish() },
6
23
  name: { pretty: 'name', type: z.string().nullish() },
7
- productnumber: { pretty: 'solutionKey', type: z.string().nullish() },
8
- //we are adding this so it doesnt complain when we differentiate between solution and type key
9
- solutionTypeKey: { pretty: 'solutionTypeKey', type: z.string().nullish() },
24
+ productnumber: { pretty: 'productNumber', type: z.string().nullish() },
10
25
  description: { pretty: 'description', type: z.string().nullish() },
11
26
 
12
27
  ww_locationcode: { pretty: 'locationCode', type: z.string().nullish() },
@@ -97,7 +112,7 @@ export const solutionFields = {
97
112
 
98
113
  export const SolutionToolkit = createEntityToolkit(
99
114
  solutionFields,
100
- 'organisation',
115
+ d365OrganisationBaseFields,
101
116
  )
102
117
 
103
118
  export type TSolutionD365 = z.infer<typeof SolutionToolkit.SResponseD365>
@@ -43,13 +43,15 @@ export const d365BaseFields = {
43
43
  } as const
44
44
 
45
45
  export const d365OrganisationBaseFields = {
46
+ ...d365BaseFields,
46
47
  _organizationid_value: {
47
48
  pretty: 'organizationIdValue',
48
49
  type: z.string().nullish(),
49
50
  },
50
- }
51
+ } as const
51
52
 
52
53
  export const d365OwnershipBaseFields = {
54
+ ...d365BaseFields,
53
55
  _ownerid_value: {
54
56
  pretty: 'ownerIdValue',
55
57
  type: z.string().nullish(),
@@ -66,29 +68,16 @@ export const d365OwnershipBaseFields = {
66
68
  pretty: 'owningUserValue',
67
69
  type: z.string().nullish(),
68
70
  },
69
- }
71
+ } as const
70
72
 
71
- export const withD365OwnershipFields = <
72
- TField extends Record<string, FieldObj>,
73
- >(
74
- fields: TField,
75
- ) =>
76
- ({
77
- ...fields,
78
- ...d365BaseFields,
79
- ...d365OwnershipBaseFields,
80
- }) as const
73
+ export const baseD365KeysArray = Object.keys(d365OwnershipBaseFields)
74
+ export type TBaseD365Keys = keyof typeof d365OwnershipBaseFields
81
75
 
82
- export const withD365OrganisationFields = <
83
- TField extends Record<string, FieldObj>,
84
- >(
85
- fields: TField,
86
- ) =>
87
- ({
88
- ...fields,
89
- ...d365BaseFields,
90
- ...d365OrganisationBaseFields,
91
- }) as const
76
+ export const basePrettyKeysArray = Object.values(d365OwnershipBaseFields).map(
77
+ field => field.pretty,
78
+ )
79
+ export type TBasePrettyKeys =
80
+ (typeof d365OwnershipBaseFields)[keyof typeof d365OwnershipBaseFields]['pretty']
92
81
 
93
82
  export type PatchValue = string | number | boolean | null | unknown[] | object
94
83
  export type PatchResponse = Record<string, PatchValue>
@@ -3,7 +3,8 @@ import { EnquiryToolkit } from '../../api/SEnquiryAPI'
3
3
 
4
4
  export const SGetEnquiriesSummaryBFF = EnquiryToolkit.SResponseAPI.pick({
5
5
  createdOn: true,
6
- disqualificationReason: true,
6
+ disqualificationReasonValue: true,
7
+ disqualificationDetailReasonValue: true,
7
8
  enquiryFriendlyName: true,
8
9
  enquiryId: true,
9
10
  enquiryStatus: true,
@@ -8,11 +8,17 @@ import { SWorkCountryBFF } from './SGetEnquirySimWorkCountryBFF'
8
8
 
9
9
  export const SGetEnquirySimBFF = SimulationToolkit.SResponseAPI.pick({
10
10
  simulationFriendlyId: true,
11
- simulationName: true,
11
+ simulationId: true,
12
12
  simulationStatus: true,
13
+ simulationBasedOn: true,
14
+ solutionValue: true,
15
+ solutionTypeValue: true,
16
+ jobTitle: true,
17
+ jobDescription: true,
13
18
  rate: true,
14
19
  rateFrequency: true,
15
- simulationId: true,
20
+ estimatedConfirmedStartDate: true,
21
+ estimatedConfirmedEndDate: true,
16
22
  }).extend({
17
23
  workCountry: SWorkCountryBFF,
18
24
  currency: SCurrencyBFF,
@@ -1,10 +1,30 @@
1
1
  import { z } from 'zod'
2
2
  import { SolutionToolkit } from '../../api/SSolutionAPI'
3
3
 
4
+ const solutionKeyMap = {
5
+ ww_scats_parent_aor: 'AOR',
6
+ ww_scats_parent_eor: 'EOR',
7
+ ww_scats_ctc_full_ser: 'C2CFullService',
8
+ ww_scats_ltdco: 'C2CNoAccount',
9
+ ww_scats_selfemployed: 'SEFullService',
10
+ ww_scats_selfemployed_noaccnt: 'SENoAccount',
11
+ ww_scats_sla: 'SLA',
12
+ ww_scats_employed: 'ICP',
13
+ ww_scats_mpp: 'MPP',
14
+ ww_scats_cpaye: 'PAYE',
15
+ ww_scats_ppaye: 'PremiumAFunding',
16
+ ww_scats_premium_b: 'PremiumBERObligations',
17
+ ww_scats_eor: 'Salaried',
18
+ }
19
+ //as there is only 1 - use transform to flatten
20
+ //also map above
4
21
  export const SSolutionBFF = SolutionToolkit.SResponseAPI.pick({
5
- solutionKey: true,
22
+ productNumber: true,
6
23
  })
7
- .transform(val => val.solutionKey)
24
+ .transform(val => {
25
+ const pn = val.productNumber
26
+ return solutionKeyMap[pn as keyof typeof solutionKeyMap] || pn
27
+ })
8
28
  .nullish()
9
29
 
10
30
  export type TGetEnquirySimSolutionBFF = z.infer<typeof SSolutionBFF>
@@ -1,6 +1,7 @@
1
1
  import { z } from 'zod'
2
2
  import { CountryToolkit } from '../../api/SCountryApi'
3
3
 
4
+ //as there is only 1 - use transform to flatten
4
5
  export const SWorkCountryBFF = CountryToolkit.SResponseAPI.pick({
5
6
  code: true,
6
7
  })
@@ -7,4 +7,4 @@ export const SPatchSimulationBFF = SimulationToolkit.SPayloadAPI.pick({
7
7
  rejectionDetailReasonValue: true,
8
8
  })
9
9
 
10
- export type TPatchEnquiryBFF = z.infer<typeof SPatchSimulationBFF>
10
+ export type TPatchSimulationBFF = z.infer<typeof SPatchSimulationBFF>
@@ -1,8 +1,4 @@
1
1
  import { z, ZodObject, ZodRawShape, ZodTypeAny } from 'zod'
2
- import {
3
- withD365OrganisationFields,
4
- withD365OwnershipFields,
5
- } from '../api/bases/SBaseAPI'
6
2
 
7
3
  export type FieldObj = {
8
4
  type?: ZodTypeAny
@@ -15,22 +11,15 @@ export type FieldObj = {
15
11
 
16
12
  type TBase = 'ownership' | 'organisation' | 'none'
17
13
 
18
- export function createEntityToolkit<TField extends Record<string, FieldObj>>(
19
- uniqueFields: TField,
20
- base: TBase = 'ownership',
21
- ) {
22
- const applyBase = (fields: TField) => {
23
- if (base === 'ownership') return withD365OwnershipFields(fields)
24
- if (base === 'organisation') return withD365OrganisationFields(fields)
25
- return fields
26
- }
27
-
28
- const combinedFields = applyBase(uniqueFields)
29
-
14
+ export function createEntityToolkit<
15
+ TUnique extends Record<string, FieldObj>,
16
+ TBase extends Record<string, FieldObj>,
17
+ >(uniqueFields: TUnique, baseFields: TBase) {
30
18
  const SPayloadD365 = create365Schema(uniqueFields).partial()
31
- const SResponseD365 = create365Schema(combinedFields).partial()
32
-
33
19
  const SPayloadAPI = createPrettySchema(uniqueFields).partial()
20
+
21
+ const combinedFields = { ...baseFields, ...uniqueFields }
22
+ const SResponseD365 = create365Schema(combinedFields).partial()
34
23
  const SResponseAPI = createPrettySchema(combinedFields)
35
24
 
36
25
  const mapD365ToPretty = (data: unknown) => {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@workwell-global/component-library",
3
- "version": "1.1.32",
3
+ "version": "1.1.34",
4
4
  "description": "A component library for Workwell",
5
5
  "license": "MIT",
6
6
  "main": "dist/cjs",
@@ -1,10 +0,0 @@
1
- import { z } from 'zod'
2
- import { SolutionToolkit } from '../../api/SSolutionAPI'
3
-
4
- export const SSolutionTypeBFF = SolutionToolkit.SResponseAPI.pick({
5
- solutionTypeKey: true,
6
- })
7
- .transform(val => val.solutionTypeKey)
8
- .nullish()
9
-
10
- export type TGetEnquirySimSolutionTypeBFF = z.infer<typeof SSolutionTypeBFF>