@vonq/hapi-elements-types 1.27.0 → 1.29.0

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.
@@ -16,8 +16,10 @@ import {
16
16
  } from "./window"
17
17
  import { WindowHapiLogger } from "../common/logger/types"
18
18
  import { ATSUserTokenResponse } from "../ats"
19
+ import { PartialRecord } from "../common"
20
+ import { WindowHapiAPIExperimental } from "../experimental"
19
21
 
20
- export type WindowHapiAPIModule<ModuleType, ModuleConfig> = {
22
+ export type WindowHapiAPIModule<ModuleRequests, ModuleConfig> = {
21
23
  propertiesThatShouldNotBeDocumented: string[]
22
24
  logger: WindowHapiLogger
23
25
  configs: ModuleConfig
@@ -27,7 +29,11 @@ export type WindowHapiAPIModule<ModuleType, ModuleConfig> = {
27
29
  resourceKey: keyof ModuleConfig,
28
30
  config: RawAxiosRequestConfig,
29
31
  ) => void
30
- } & ModuleType
32
+ abortControllers: PartialRecord<
33
+ keyof ModuleRequests,
34
+ Map<RawAxiosRequestConfig, AbortController>
35
+ >
36
+ } & ModuleRequests
31
37
  export type HapiRequestConfig<T> = Omit<AxiosRequestConfig<T>, "headers"> & {
32
38
  headers?: any
33
39
  }
@@ -43,6 +49,17 @@ export type WindowHapiAPIRefreshJWTTokenHandler = () => Promise<
43
49
 
44
50
  export type WindowHapiAPIValidateJWTTokenHandler = () => Promise<boolean>
45
51
 
52
+ export type WindowHapiAPIModules = {
53
+ [WindowHapiModuleName.contract]: WindowHapiAPIContract
54
+ [WindowHapiModuleName.wallet]: WindowHapiAPIWallet
55
+ [WindowHapiModuleName.product]: WindowHapiAPIProduct
56
+ [WindowHapiModuleName.campaign]: WindowHapiAPICampaign
57
+ [WindowHapiModuleName.ats]: WindowHapiAPIATS
58
+ [WindowHapiModuleName.experimental]: WindowHapiAPIExperimental
59
+ }
60
+
61
+ type Test = WindowHapiAPIModules[keyof WindowHapiAPIModules]
62
+
46
63
  export type WindowHapiAPI = WindowHapiModuleWithConstructorArgs<
47
64
  {
48
65
  /* Common */
@@ -60,6 +77,21 @@ export type WindowHapiAPI = WindowHapiModuleWithConstructorArgs<
60
77
  request: <T = any, R = AxiosResponse<T>, D = any>(
61
78
  config: Partial<HapiRequestConfig<D>>,
62
79
  ) => Promise<R>
80
+ requestAbortable: <
81
+ ModuleKlass extends WindowHapiAPIModule<
82
+ ModuleRequests,
83
+ ModuleConfig
84
+ >,
85
+ ModuleRequests,
86
+ ModuleConfig,
87
+ T = any,
88
+ R = AxiosResponse<T>,
89
+ D = any,
90
+ >(
91
+ moduleKlass: WindowHapiAPIModule<any, any>,
92
+ functionName: keyof ModuleRequests,
93
+ config: Partial<HapiRequestConfig<D>>,
94
+ ) => Promise<R>
63
95
  jwtHeaderKey: string
64
96
  jwtRefreshIntervalInSeconds: number
65
97
  setJWTRefreshIntervalInSeconds: (seconds: number) => void
@@ -84,18 +116,7 @@ export type WindowHapiAPI = WindowHapiModuleWithConstructorArgs<
84
116
  endpoint: string,
85
117
  data?: any,
86
118
  ) => Promise<any>
87
- [WindowHapiModuleName.contract]: WindowHapiAPIContract
88
- [WindowHapiModuleName.wallet]: WindowHapiAPIWallet
89
- [WindowHapiModuleName.product]: WindowHapiAPIProduct
90
- [WindowHapiModuleName.campaign]: WindowHapiAPICampaign
91
- [WindowHapiModuleName.ats]: WindowHapiAPIATS
92
- modules: {
93
- [WindowHapiModuleName.contract]: WindowHapiAPIContract
94
- [WindowHapiModuleName.wallet]: WindowHapiAPIWallet
95
- [WindowHapiModuleName.product]: WindowHapiAPIProduct
96
- [WindowHapiModuleName.campaign]: WindowHapiAPICampaign
97
- [WindowHapiModuleName.ats]: WindowHapiAPIATS
98
- }
99
- },
119
+ modules: WindowHapiAPIModules
120
+ } & WindowHapiAPIModules,
100
121
  { readonly core: WindowHapiClassInterface }
101
122
  >
@@ -16,6 +16,7 @@ import { WindowHapiLogger } from "../common/logger/types"
16
16
  import { WindowHapiServiceOrderJourney } from "../orderJourney/service.types"
17
17
  import { WindowHapiServiceDebugging } from "../debugging/service.types"
18
18
  import { WindowHapiServiceLanguage } from "../language/service.types"
19
+ import { WindowHapiServiceExperimental } from "../experimental"
19
20
 
20
21
  export type HapiServiceFunctionLifecycleHookCallbackHandler = (
21
22
  ...args: any[]
@@ -23,6 +24,7 @@ export type HapiServiceFunctionLifecycleHookCallbackHandler = (
23
24
 
24
25
  export type HapiServiceFunctionLifecycleHookHandler = (
25
26
  callback: HapiServiceFunctionLifecycleHookCallbackHandler,
27
+ runArgs?: any[],
26
28
  ) => void
27
29
 
28
30
  export type HapiServiceFunctionWithLifecycleHooks<HandlerType> = {
@@ -56,6 +58,7 @@ export type WindowHapiService = WindowHapiModuleWithConstructorArgs<
56
58
  [WindowHapiModuleName.ats]: WindowHapiServiceATS
57
59
  [WindowHapiModuleName.debugging]: WindowHapiServiceDebugging
58
60
  [WindowHapiModuleName.language]: WindowHapiServiceLanguage
61
+ [WindowHapiModuleName.experimental]: WindowHapiServiceExperimental
59
62
  services: {
60
63
  [WindowHapiModuleName.alert]: WindowHapiServiceAlert
61
64
  [WindowHapiModuleName.basket]: WindowHapiServiceBasket
@@ -69,6 +72,7 @@ export type WindowHapiService = WindowHapiModuleWithConstructorArgs<
69
72
  [WindowHapiModuleName.ats]: WindowHapiServiceATS
70
73
  [WindowHapiModuleName.debugging]: WindowHapiServiceDebugging
71
74
  [WindowHapiModuleName.language]: WindowHapiServiceLanguage
75
+ [WindowHapiModuleName.experimental]: WindowHapiServiceExperimental
72
76
  }
73
77
 
74
78
  decorateFunctionWithLifecycleEvents: <HandlerType extends Function>(
@@ -8,7 +8,7 @@ import {
8
8
  import { WindowHapiModuleWithConstructorArgs } from "../_window"
9
9
 
10
10
  export type BasketServiceGetProductsHandler = (
11
- products?: BasketProduct[],
11
+ products: BasketProduct[],
12
12
  shouldSet?: boolean,
13
13
  ) => Promise<(Product | Contract)[]>
14
14
  export type BasketServiceAddProductOrContractByIdHandler = (
@@ -25,13 +25,14 @@ export type BasketServiceRemoveContractsWithConflictingGroupsHandler = (
25
25
  export type BasketServiceKeepContractsWithConflictingGroupsHandler = () => void
26
26
  export type BasketServiceSetProductsMetaHandler = (
27
27
  meta: BasketProduct[],
28
- ) => Promise<(Product | Contract)[]>
28
+ ) => void
29
29
 
30
30
  export type WindowHapiServiceBasket = WindowHapiModuleWithConstructorArgs<
31
31
  {
32
32
  onAfterGetBasketData: (
33
33
  basketItemData: (Contract | Product)[],
34
- shouldSet: boolean,
34
+ shouldSet?: boolean,
35
+ shouldSetMeta?: boolean,
35
36
  ) => BasketProduct[]
36
37
  setProductsMeta: BasketServiceSetProductsMetaHandler
37
38
  getProducts: HapiServiceFunctionWithLifecycleHooks<BasketServiceGetProductsHandler>
@@ -90,6 +90,7 @@ export type WindowHapiServiceCampaign = WindowHapiModuleWithConstructorArgs<
90
90
  onAfterOrderCampaignSuccess: (
91
91
  alertKey?: AlertKey,
92
92
  disclaimerTexts?: string[],
93
+ isSuccessFromEditing?: boolean,
93
94
  ) => void
94
95
  validateContractPostingRequirementsWithCampaign: HapiServiceFunctionWithLifecycleHooks<CampaignServiceValidateContractPostingRequirementsWithCampaignHandler>
95
96
  saveCampaign: HapiServiceFunctionWithLifecycleHooks<CampaignServiceSaveCampaignHandler>
@@ -27,6 +27,7 @@ import {
27
27
  import {
28
28
  FormFacetsFieldType,
29
29
  PostingRequirement,
30
+ PostingRequirementLabelsMap,
30
31
  TransformedPostingRequirement,
31
32
  } from "../common"
32
33
 
@@ -64,6 +65,10 @@ export type WindowHapiUtilsCampaign = WindowHapiModuleWithConstructorArgs<
64
65
  string,
65
66
  CampaignCreateFormOrderedProductSpec
66
67
  >,
68
+ orderedProductsSpecsLabels?: Record<
69
+ string,
70
+ PostingRequirementLabelsMap
71
+ >,
67
72
  ) => CampaignOrderRequestBodyOrderedProductsSpec[]
68
73
  getPostBodyForOrderedProductsSpecsPostingRequirement: (
69
74
  postingRequirement: any,
package/common/enums.ts CHANGED
@@ -33,6 +33,7 @@ export enum WindowHapiModuleName {
33
33
  alert = "alert",
34
34
  modal = "modal",
35
35
  "ui" = "ui",
36
+ "experimental" = "experimental",
36
37
  }
37
38
 
38
39
  export enum WindowHapiSDKModuleName {
package/common/types.ts CHANGED
@@ -131,7 +131,6 @@ export type PostingRequirementType =
131
131
  | "TEXTAREA"
132
132
  | "AUTOCOMPLETE"
133
133
  | "STATISCH"
134
- | "FILE-URL"
135
134
  | "HTMLAREA"
136
135
 
137
136
  export type PostingRequirementRuleName =
@@ -151,13 +150,8 @@ export type PostingRequirementRuleName =
151
150
  | "before"
152
151
  | "after"
153
152
  | "url"
154
- | "fileMimeType"
155
- | "fileMimeSubType"
156
- | "editorTest"
157
- | "libraryTest"
158
153
  | "autocomplete"
159
- | "statictype"
160
- | "staticsubtype"
154
+ | "mimetype"
161
155
 
162
156
  export type PostingRequirementRule = {
163
157
  rule: PostingRequirementRuleName
@@ -168,10 +162,17 @@ export type PostingRequirementRuleWithObjectData = {
168
162
  data: Record<string, any>
169
163
  } & Omit<PostingRequirementRule, "data">
170
164
 
165
+ export type PostingRequirementDisplayRuleShowOperand =
166
+ | "notempty"
167
+ | "equal"
168
+ | "in"
169
+ | "contains"
170
+ | "selected_option_show_contains"
171
+
171
172
  export type PostingRequirementDisplayRuleShow = {
172
173
  facet: string
173
- value: any
174
- op: "notempty" | "equal" | "in" | "selected_option_show_contains"
174
+ value: string | string[]
175
+ op: PostingRequirementDisplayRuleShowOperand
175
176
  }
176
177
  export type PostingRequirementDisplayRule = {
177
178
  show: PostingRequirementDisplayRuleShow[]
@@ -192,11 +193,6 @@ export type PostingRequirementAutocomplete = {
192
193
  required_parameters: string[] | null
193
194
  parameters_source: PostingRequirementParametersSource | null
194
195
  }
195
- export type PostingRequirementGroup = {
196
- id: string
197
- name: string
198
- sort: number
199
- }
200
196
  export type PostingRequirement = {
201
197
  name: string
202
198
  label: string
@@ -221,7 +217,7 @@ export type PostingRequirementOptionRequiresField = {
221
217
  }
222
218
  export type PostingRequirementOption = {
223
219
  default?: string
224
- key: string
220
+ key: string | number
225
221
  label: string
226
222
  data?: PostingRequirementOptionData
227
223
  labels?: Record<"default", string>
@@ -241,13 +237,12 @@ export type PostingRequirementOptionData = {
241
237
  images?: PostingRequirementOptionDataImage[]
242
238
  }
243
239
  export type TransformedPostingRequirementOption = {
244
- value?: string
240
+ value?: string | number
245
241
  data?: PostingRequirementOptionData
246
242
  requires?: PostingRequirementOptionRequiresField[] | null
247
243
  label: string
248
244
  show?: string[]
249
245
  }
250
- export type PostingRequirementReactiveDescription = { description: string }
251
246
  export type TransformedPostingRequirement = Omit<
252
247
  PostingRequirement,
253
248
  "options"
@@ -1,5 +1,6 @@
1
1
  export type Validators = {
2
2
  isNotEmpty: (value: string | Record<string, any> | any[]) => boolean
3
+ isNotEmptyObject: (value: Object | undefined | null) => boolean
3
4
  isNotZero: (value: number) => boolean
4
5
  isHandledByBackend: (value: any) => false
5
6
  }
package/contract/types.ts CHANGED
@@ -67,6 +67,7 @@ export type Contract = {
67
67
  posting_duration_days: number | null
68
68
  group: ContractGroup | null
69
69
  posting_requirements_defaults: Record<string, string | string[]> | null
70
+ errors?: string[]
70
71
  }
71
72
 
72
73
  export type ContractGroup = {
@@ -92,6 +92,7 @@ export type ZodContract = ZodObject<{
92
92
  product: ZodContractProduct
93
93
  purchase_price: ZodNullable<ZodContractPurchasePrice>
94
94
  group: ZodNullable<ZodContractGroup>
95
+ errors: ZodOptional<ZodArray<ZodString>>
95
96
  }>
96
97
  export type WindowHapiValidationsContract = {
97
98
  channel: ZodContractChannel
@@ -0,0 +1,17 @@
1
+ import { RawAxiosRequestConfig } from "axios"
2
+ import { WindowHapiAPI, WindowHapiAPIModule } from "../_window/api.types"
3
+ import { WindowHapiModuleWithConstructorArgs } from "../_window"
4
+
5
+ export type WindowHapiAPIExperimentalConfigs = {
6
+ getExperimental: RawAxiosRequestConfig
7
+ }
8
+ export type WindowHapiAPIExperimentalRequests = {
9
+ getExperimental: () => Promise<any>
10
+ }
11
+ export type WindowHapiAPIExperimental = WindowHapiModuleWithConstructorArgs<
12
+ WindowHapiAPIModule<
13
+ WindowHapiAPIExperimentalRequests,
14
+ WindowHapiAPIExperimentalConfigs
15
+ >,
16
+ { readonly api: WindowHapiAPI }
17
+ >
@@ -0,0 +1,4 @@
1
+ // created from 'create-ts-index'
2
+
3
+ export * from "./api.types"
4
+ export * from "./service.types"
@@ -0,0 +1,14 @@
1
+ import {
2
+ HapiServiceFunctionWithLifecycleHooks,
3
+ WindowHapiService,
4
+ } from "../_window/service.types"
5
+ import { WindowHapiModuleWithConstructorArgs } from "../_window"
6
+
7
+ export type WindowHapiServiceExperimental = WindowHapiModuleWithConstructorArgs<
8
+ {
9
+ getExperimental: HapiServiceFunctionWithLifecycleHooks<
10
+ () => Promise<any>
11
+ >
12
+ },
13
+ { readonly service: WindowHapiService }
14
+ >
package/modal/enums.ts CHANGED
@@ -30,5 +30,6 @@ export enum ModalKeys {
30
30
 
31
31
  export enum FilePickerModalPropsActionFor {
32
32
  postingOrganization = "posting-organization",
33
- postingRequirements = "posting-requirements",
33
+ productPostingRequirements = "product-posting-requirements",
34
+ contractPostingRequirements = "contract-posting-requirements",
34
35
  }
package/modal/types.ts CHANGED
@@ -78,8 +78,7 @@ export type WalletPurchaseOrderModalProps = {}
78
78
  export type FilePickerModalPropsActionDataPostingRequirements = {
79
79
  requirement: TransformedPostingRequirement
80
80
  id: string | number
81
- mimeTypesFull: string[]
82
- mimeTypesSplit?: { mimeType: string; mimeSubType: string }[]
81
+ mimetype: string[]
83
82
  }
84
83
  export type FilePickerModalPropsActionData =
85
84
  FilePickerModalPropsActionDataPostingRequirements
@@ -10,7 +10,9 @@ import { OrderJourneyStepKey } from "./enums"
10
10
 
11
11
  export type OrderJourneyServiceSwitchToNextStepHandler = () => Promise<void>
12
12
  export type OrderJourneyServiceSwitchToPreviousStepHandler = () => Promise<void>
13
- export type OrderJourneyServiceRestartJourneyHandler = () => void
13
+ export type OrderJourneyServiceRestartJourneyHandler = (
14
+ shouldResetStepBackToFirstStep?: boolean,
15
+ ) => void
14
16
 
15
17
  export type WindowHapiServiceOrderJourney = WindowHapiModuleWithConstructorArgs<
16
18
  {
@@ -203,3 +203,13 @@ export type OrderJourneyStepMap = {
203
203
  [OrderJourneyStepKey.paymentMethod]: OrderJourneyStep
204
204
  [OrderJourneyStepKey.orderConfirmation]: OrderJourneyStep
205
205
  }
206
+ export type OrderReviewAccordionKeys = Exclude<
207
+ OrderJourneyStepKey,
208
+ | OrderJourneyStepKey.searchRecommendProducts
209
+ | OrderJourneyStepKey.selectProducts
210
+ | OrderJourneyStepKey.addContracts
211
+ | OrderJourneyStepKey.selectContracts
212
+ | OrderJourneyStepKey.orderReview
213
+ | OrderJourneyStepKey.orderConfirmation
214
+ | OrderJourneyStepKey.paymentMethod
215
+ >
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "private": false,
3
3
  "name": "@vonq/hapi-elements-types",
4
- "version": "1.27.0",
4
+ "version": "1.29.0",
5
5
  "description": "This package contains Typescript definitions for HAPI Elements",
6
6
  "author": "VONQ HAPI Team",
7
7
  "license": "BSD-3-Clause",