@vonq/hapi-elements-types 1.4.0 → 1.6.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.
Files changed (107) hide show
  1. package/package.json +17 -8
  2. package/src/_window/api.types.ts +61 -0
  3. package/src/_window/auth.types.ts +13 -0
  4. package/src/_window/config.types.ts +5 -0
  5. package/src/_window/events.types.ts +158 -0
  6. package/src/_window/index.ts +16 -0
  7. package/src/_window/instances.types.ts +27 -0
  8. package/src/_window/qa.types.ts +30 -0
  9. package/src/_window/routing.types.ts +23 -0
  10. package/src/_window/sdk.types.ts +149 -0
  11. package/src/_window/service.types.ts +69 -0
  12. package/src/_window/state.types.ts +114 -0
  13. package/src/_window/ui.types.ts +15 -0
  14. package/src/_window/utils.types.ts +36 -0
  15. package/src/_window/validation.types.ts +45 -0
  16. package/src/_window/window.ts +140 -0
  17. package/src/alert/enums.ts +22 -0
  18. package/src/alert/index.ts +6 -0
  19. package/src/alert/service.types.ts +15 -0
  20. package/src/alert/state.types.ts +9 -0
  21. package/src/alert/types.ts +63 -0
  22. package/src/ats/api.types.ts +16 -0
  23. package/src/ats/index.ts +6 -0
  24. package/src/ats/service.types.ts +17 -0
  25. package/src/ats/state.types.ts +5 -0
  26. package/src/ats/types.ts +19 -0
  27. package/src/basket/index.ts +7 -0
  28. package/src/basket/service.types.ts +32 -0
  29. package/src/basket/state.types.ts +34 -0
  30. package/src/basket/types.ts +4 -0
  31. package/src/basket/utils.types.ts +10 -0
  32. package/src/basket/validations.types.ts +25 -0
  33. package/src/campaign/api.types.ts +45 -0
  34. package/src/campaign/enums.ts +17 -0
  35. package/src/campaign/index.ts +10 -0
  36. package/src/campaign/qa.types.ts +12 -0
  37. package/src/campaign/service.types.ts +48 -0
  38. package/src/campaign/state.types.ts +55 -0
  39. package/src/campaign/types.ts +237 -0
  40. package/src/campaign/utils.types.ts +59 -0
  41. package/src/campaign/validations.types.ts +215 -0
  42. package/src/common/enums.ts +42 -0
  43. package/src/common/events/EventCommand/enums.ts +49 -0
  44. package/src/common/events/EventCommand/index.ts +4 -0
  45. package/src/common/events/EventCommand/types.ts +18 -0
  46. package/src/common/events/index.ts +4 -0
  47. package/src/common/events/types.ts +52 -0
  48. package/src/common/index.ts +7 -0
  49. package/src/common/logger/enums.ts +12 -0
  50. package/src/common/logger/types.ts +18 -0
  51. package/src/common/qa.types.ts +9 -0
  52. package/src/common/types.ts +109 -0
  53. package/src/common/validations.types.ts +89 -0
  54. package/src/common/validator/types.ts +4 -0
  55. package/src/contract/api.types.ts +47 -0
  56. package/src/contract/index.ts +9 -0
  57. package/src/contract/qa.types.ts +12 -0
  58. package/src/contract/service.types.ts +54 -0
  59. package/src/contract/state.types.ts +74 -0
  60. package/src/contract/types.ts +145 -0
  61. package/src/contract/utils.types.ts +11 -0
  62. package/src/contract/validations.types.ts +104 -0
  63. package/src/debugging/index.ts +3 -0
  64. package/src/debugging/state.types.ts +18 -0
  65. package/src/index.ts +18 -0
  66. package/src/language/index.ts +5 -0
  67. package/src/language/qa.types.ts +19 -0
  68. package/src/language/state.types.ts +25 -0
  69. package/src/language/validations.types.ts +13 -0
  70. package/src/modal/enums.ts +14 -0
  71. package/src/modal/index.ts +6 -0
  72. package/src/modal/service.types.ts +32 -0
  73. package/src/modal/state.types.ts +8 -0
  74. package/src/modal/types.ts +44 -0
  75. package/src/orderJourney/enums.ts +25 -0
  76. package/src/orderJourney/index.ts +8 -0
  77. package/src/orderJourney/qa.types.ts +16 -0
  78. package/src/orderJourney/state.types.ts +99 -0
  79. package/src/orderJourney/types.ts +31 -0
  80. package/src/orderJourney/utils.types.ts +11 -0
  81. package/src/orderJourney/validations.types.ts +34 -0
  82. package/src/product/api.types.ts +62 -0
  83. package/src/product/enums.ts +11 -0
  84. package/src/product/index.ts +10 -0
  85. package/src/product/qa.types.ts +11 -0
  86. package/src/product/service.types.ts +68 -0
  87. package/src/product/state.types.ts +93 -0
  88. package/src/product/types.ts +161 -0
  89. package/src/product/utils.types.ts +22 -0
  90. package/src/product/validations.types.ts +189 -0
  91. package/src/routing/index.ts +3 -0
  92. package/src/routing/state.types.ts +30 -0
  93. package/src/theming/index.ts +6 -0
  94. package/src/theming/qa.types.ts +11 -0
  95. package/src/theming/state.types.ts +6 -0
  96. package/src/theming/types.ts +123 -0
  97. package/src/theming/validations.types.ts +62 -0
  98. package/src/ui/index.ts +3 -0
  99. package/src/ui/service.types.ts +26 -0
  100. package/src/wallet/api.types.ts +33 -0
  101. package/src/wallet/index.ts +7 -0
  102. package/src/wallet/service.types.ts +26 -0
  103. package/src/wallet/state.types.ts +58 -0
  104. package/src/wallet/types.ts +65 -0
  105. package/src/wallet/validations.types.ts +18 -0
  106. package/tsconfig.json +36 -0
  107. package/index.d.ts +0 -5207
@@ -0,0 +1,215 @@
1
+ import {
2
+ ZodAny,
3
+ ZodArray,
4
+ ZodNullable,
5
+ ZodNumber,
6
+ ZodObject,
7
+ ZodOptional,
8
+ ZodRecord,
9
+ ZodString,
10
+ ZodUnion,
11
+ } from "zod"
12
+ import { ZodProductDuration } from "../product/validations.types"
13
+
14
+ export type ZodCampaignTotalPrice = ZodObject<{
15
+ amount: ZodNumber
16
+ currency: ZodString
17
+ }>
18
+ export type ZodCampaignEmploymentType = ZodObject<{
19
+ label: ZodString
20
+ value: ZodString
21
+ }>
22
+ export type ZodCampaignRecruiterInfo = ZodObject<{
23
+ id: ZodOptional<ZodNullable<ZodUnion<[ZodNumber, ZodString]>>>
24
+ name: ZodString
25
+ emailAddress: ZodOptional<ZodNullable<ZodString>>
26
+ }>
27
+ export type ZodCampaignTargetGroupData = ZodObject<{
28
+ description: ZodString
29
+ vonqId: ZodString
30
+ }>
31
+ export type ZodCampaignTargetGroupDatas = ZodArray<ZodCampaignTargetGroupData>
32
+ export type ZodCampaignTargetGroup = ZodObject<{
33
+ educationLevel: ZodCampaignTargetGroupDatas
34
+ industry: ZodCampaignTargetGroupDatas
35
+ jobCategory: ZodCampaignTargetGroupDatas
36
+ seniority: ZodCampaignTargetGroupDatas
37
+ }>
38
+ export type ZodCampaignPosting = ZodObject<{
39
+ clicks: ZodNumber
40
+ name: ZodString
41
+ productId: ZodString
42
+ }>
43
+ export type ZodCampaignPostings = ZodArray<ZodCampaignPosting>
44
+ export type ZodCampaignPostingDetailsContactInfo = ZodObject<{
45
+ emailAddress: ZodOptional<ZodNullable<ZodString>>
46
+ name: ZodOptional<ZodNullable<ZodString>>
47
+ phoneNumber: ZodOptional<ZodNullable<ZodString>>
48
+ }>
49
+ export type ZodCampaignPostingDetailsOrganization = ZodObject<{
50
+ companyLogo: ZodString
51
+ name: ZodString
52
+ }>
53
+ export type ZodCampaignPostingDetailsSalaryIndication = ZodObject<{
54
+ period: ZodString
55
+ range: ZodObject<{
56
+ currency: ZodOptional<ZodNullable<ZodString>>
57
+ from: ZodOptional<ZodNullable<ZodNumber>>
58
+ to: ZodNumber
59
+ }>
60
+ }>
61
+ export type ZodCampaignPostingDetailsWeeklyWorkingHours = ZodObject<{
62
+ from: ZodOptional<ZodNullable<ZodNumber>>
63
+ to: ZodNumber
64
+ }>
65
+ export type ZodCampaignPostingDetailsWorkingLocationPostCodeDefinition = {
66
+ postCode: ZodOptional<ZodNullable<ZodString>>
67
+ }
68
+ export type ZodCampaignPostingDetailsWorkingLocationAddressDetailsDefinition = {
69
+ addressLine1: ZodString
70
+ addressLine2: ZodOptional<ZodNullable<ZodString>>
71
+ allowsRemoteWork: ZodOptional<ZodNullable<ZodNumber>>
72
+ city: ZodString
73
+ country: ZodString
74
+ postcode: ZodString
75
+ }
76
+ export type ZodCampaignPostingDetailsWorkingLocation = ZodObject<
77
+ ZodCampaignPostingDetailsWorkingLocationAddressDetailsDefinition &
78
+ ZodCampaignPostingDetailsWorkingLocationPostCodeDefinition
79
+ >
80
+ export type ZodCampaignTaxonomyNameWithLanguage = ZodObject<{
81
+ languageCode: ZodString
82
+ value: ZodString
83
+ }>
84
+ export type ZodCampaignTaxonomyEducationLevel = ZodObject<{
85
+ id: ZodNumber
86
+ name: ZodArray<ZodCampaignTaxonomyNameWithLanguage>
87
+ }>
88
+ export type ZodCampaignTaxonomyEducationLevels =
89
+ ZodArray<ZodCampaignTaxonomyEducationLevel>
90
+ export type ZodCampaignTaxonomySeniority = ZodObject<{
91
+ id: ZodNumber
92
+ name: ZodArray<ZodCampaignTaxonomyNameWithLanguage>
93
+ }>
94
+ export type ZodCampaignTaxonomySeniorities =
95
+ ZodArray<ZodCampaignTaxonomySeniority>
96
+ export type ZodCampaignPostingDetails = ZodObject<{
97
+ applicationUrl: ZodString
98
+ description: ZodString
99
+ contactInfo: ZodCampaignPostingDetailsContactInfo
100
+ employmentType: ZodString
101
+ jobPageUrl: ZodString
102
+ organization: ZodCampaignPostingDetailsOrganization
103
+ salaryIndication: ZodCampaignPostingDetailsSalaryIndication
104
+ title: ZodString
105
+ weeklyWorkingHours: ZodCampaignPostingDetailsWeeklyWorkingHours
106
+ workingLocation: ZodCampaignPostingDetailsWorkingLocation
107
+ yearsOfExperience: ZodNumber
108
+ }>
109
+ export type ZodCampaignOrderedProductSpec = ZodObject<{
110
+ contractId: ZodNullable<ZodString>
111
+ postingRequirements: ZodNullable<ZodObject<any>>
112
+ productId: ZodString
113
+ utm: ZodNullable<ZodString>
114
+ deliveredOn: ZodNullable<ZodString>
115
+ duration: ZodString
116
+ durationPeriod: ZodProductDuration
117
+ jobBoardLink: ZodNullable<ZodString>
118
+ status: ZodString
119
+ statusDescription: ZodNullable<ZodString>
120
+ }>
121
+ export type ZodCampaignOrderedProductSpecs =
122
+ ZodArray<ZodCampaignOrderedProductSpec>
123
+ export type ZodCampaignCreateFormOrderedProductSpecs = ZodRecord<
124
+ ZodString,
125
+ ZodAny
126
+ >
127
+
128
+ export type ZodCampaign = ZodObject<{
129
+ currency: ZodString
130
+ campaignId: ZodString
131
+ campaignName: ZodNullable<ZodString>
132
+ companyId: ZodString
133
+ createdOn: ZodString
134
+ customerId: ZodString
135
+ orderReference: ZodNullable<ZodString>
136
+ orderedProducts: ZodArray<ZodString>
137
+ orderedProductsSpecs: ZodCampaignOrderedProductSpecs
138
+ postingDetails: ZodCampaignPostingDetails
139
+ postings: ZodCampaignPostings
140
+ recruiterInfo: ZodCampaignRecruiterInfo
141
+ status: ZodString
142
+ targetGroup: ZodCampaignTargetGroup
143
+ totalPrice: ZodCampaignTotalPrice
144
+ walletId: ZodOptional<ZodNullable<ZodString>>
145
+ poNumber: ZodOptional<ZodNullable<ZodString>>
146
+ }>
147
+ export type ZodCampaigns = ZodArray<ZodCampaign>
148
+ export type ZodCampaignCreateFormPostingDetails = ZodObject<{
149
+ title: ZodString
150
+ description: ZodString
151
+ organization: ZodCampaignPostingDetailsOrganization
152
+ workingLocation: ZodObject<ZodCampaignPostingDetailsWorkingLocationAddressDetailsDefinition>
153
+ yearsOfExperience: ZodNumber
154
+ employmentType: ZodString
155
+ weeklyWorkingHours: ZodCampaignPostingDetailsWeeklyWorkingHours
156
+ salaryIndication: ZodCampaignPostingDetailsSalaryIndication
157
+ jobPageUrl: ZodString
158
+ applicationUrl: ZodString
159
+ }>
160
+ export type ZodCampaignCreateFormTargetGroup = ZodObject<{
161
+ educationLevel: ZodCampaignTaxonomyEducationLevels
162
+ seniority: ZodCampaignTaxonomySeniorities
163
+ industry: ZodArray<ZodObject<{ id: ZodNumber; name: ZodString }>>
164
+ jobCategory: ZodArray<
165
+ ZodObject<{
166
+ label: ZodString
167
+ value: ZodNumber
168
+ }>
169
+ >
170
+ }>
171
+ export type ZodCampaignCreateForm = ZodObject<{
172
+ companyId: ZodString
173
+ campaignName: ZodOptional<ZodNullable<ZodString>>
174
+ targetGroup: ZodCampaignCreateFormTargetGroup
175
+ recruiterInfo: ZodCampaignRecruiterInfo
176
+ postingDetails: ZodCampaignCreateFormPostingDetails
177
+ orderedProductsSpecs: ZodCampaignCreateFormOrderedProductSpecs
178
+ orderedProducts: ZodArray<ZodString>
179
+ }>
180
+ export type WindowHapiValidationsCampaign = {
181
+ status: string[]
182
+ statusRegex: RegExp
183
+ supportedEmploymentType: string[]
184
+ employmentTypeRegex: RegExp
185
+ employmentType: ZodCampaignEmploymentType
186
+ employmentTypes: ZodArray<ZodCampaignEmploymentType>
187
+ salaryPeriod: string[]
188
+ salaryPeriodRegex: RegExp
189
+ totalPrice: ZodCampaignTotalPrice
190
+ recruiterInfo: ZodCampaignRecruiterInfo
191
+ targetGroupData: ZodCampaignTargetGroupData
192
+ targetGroupDatas: ZodCampaignTargetGroupDatas
193
+ targetGroup: ZodCampaignTargetGroup
194
+ posting: ZodCampaignPosting
195
+ postings: ZodCampaignPostings
196
+ postingDetailsContactInfo: ZodCampaignPostingDetailsContactInfo
197
+ postingDetailsOrganization: ZodCampaignPostingDetailsOrganization
198
+ postingDetailsSalaryIndication: ZodCampaignPostingDetailsSalaryIndication
199
+ postingDetailsWeeklyWorkingHours: ZodCampaignPostingDetailsWeeklyWorkingHours
200
+ postingDetailsWorkingLocation: ZodCampaignPostingDetailsWorkingLocation
201
+ nameWithLanguage: ZodCampaignTaxonomyNameWithLanguage
202
+ educationLevel: ZodCampaignTaxonomyEducationLevel
203
+ educationLevels: ZodCampaignTaxonomyEducationLevels
204
+ seniority: ZodCampaignTaxonomySeniority
205
+ seniorities: ZodCampaignTaxonomySeniorities
206
+ postingDetails: ZodCampaignPostingDetails
207
+ orderedProductsSpec: ZodCampaignOrderedProductSpec
208
+ orderedProductsSpecs: ZodCampaignOrderedProductSpecs
209
+ campaign: ZodCampaign
210
+ campaigns: ZodCampaigns
211
+ campaignForm: ZodCampaignCreateForm
212
+ campaignFormTargetGroup: ZodCampaignCreateFormTargetGroup
213
+ campaignFormPostingDetails: ZodCampaignCreateFormPostingDetails
214
+ campaignFormOrderedProductsSpecs: ZodCampaignCreateFormOrderedProductSpecs
215
+ }
@@ -0,0 +1,42 @@
1
+ export enum WindowHapiSubmoduleName {
2
+ "api" = "hapiApi",
3
+ auth = "hapiAuth",
4
+ config = "hapiConfig",
5
+ instances = "hapiInstances",
6
+ qa = "hapiQA",
7
+ routing = "hapiRouting",
8
+ sdk = "hapi",
9
+ service = "hapiService",
10
+ state = "hapiState",
11
+ ui = "hapiUI",
12
+ utils = "hapiUtils",
13
+ validation = "hapiValidation",
14
+ events = "hapiEvents",
15
+ instance = "hapiInstance",
16
+ }
17
+
18
+ export enum WindowHapiModuleName {
19
+ ats = "ats",
20
+ basket = "basket",
21
+ campaign = "campaign",
22
+ contract = "contract",
23
+ product = "product",
24
+ "common" = "common",
25
+ wallet = "wallet",
26
+ debugging = "debugging",
27
+ language = "language",
28
+ theming = "theming",
29
+ orderJourney = "orderJourney",
30
+ userJourney = "userJourney",
31
+ alert = "alert",
32
+ modal = "modal",
33
+ "ui" = "ui",
34
+ }
35
+
36
+ export enum WindowHapiSDKModuleName {
37
+ api = "api",
38
+ state = "state",
39
+ validation = "validation",
40
+ service = "service",
41
+ utils = "utils",
42
+ }
@@ -0,0 +1,49 @@
1
+ export enum WindowHapiEventCommandName {
2
+ /* State */
3
+ stateHydrate = "state:hydrate",
4
+ stateTransfer = "state:transfer",
5
+ stateRestore = "state:restore",
6
+ stateLoad = "state:load",
7
+ stateInit = "state:init",
8
+
9
+ /* Service */
10
+ serviceLoad = "service:load",
11
+ serviceInit = "service:init",
12
+ serviceRequest = "service:request",
13
+ serviceStart = "service:start",
14
+ serviceSuccess = "service:success",
15
+ serviceFailure = "service:failure",
16
+ serviceFinish = "service:finish",
17
+
18
+ /* Config */
19
+ configSetPartnerId = "config:partnerId",
20
+ configSetClientId = "config:clientId",
21
+ configSetAreLogsEnabled = "config:areLogsEnabled",
22
+
23
+ /* App */
24
+ appLoad = "app:load",
25
+
26
+ /* API */
27
+ apiRequest = "api:request",
28
+
29
+ /* QA */
30
+ qaRequest = "qa:request",
31
+
32
+ /* DOM */
33
+ domAppendChild = "dom:append-child",
34
+ domElementEvent = "dom:element-event",
35
+ domRemoveChild = "dom:remove-child",
36
+ domHideElement = "dom:hide-element",
37
+ domShowElement = "dom:show-element",
38
+ domSetStyleAttribute = "dom:set-style-attribute",
39
+ domAddClass = "dom:add-class",
40
+ domRemoveClass = "dom:remove-class",
41
+ domSlotAvailable = "dom:slot-available",
42
+
43
+ /* Location */
44
+ locationSetHref = "location:href",
45
+ }
46
+
47
+ export enum EventCommandErrorResponse {
48
+ stateNotFound = "state-undefined-or-not-found",
49
+ }
@@ -0,0 +1,4 @@
1
+ // created from 'create-ts-index'
2
+
3
+ export * from './enums';
4
+ export * from './types';
@@ -0,0 +1,18 @@
1
+ import { WindowHapiEventCommandName } from "./enums"
2
+
3
+ export type WindowHapiEventCommandNames =
4
+ | WindowHapiEventCommandName
5
+ | `dom:element-event-${string}`
6
+
7
+ export type WindowHapiEventCommandData =
8
+ | [string]
9
+ | [string, ...any[]]
10
+ | [...any[]]
11
+ | undefined
12
+
13
+ export type WindowHapiEventCommandStatus =
14
+ | "pending"
15
+ | "dispatched"
16
+ | "resolved"
17
+ | "rejected"
18
+ | "consumed"
@@ -0,0 +1,4 @@
1
+ // created from 'create-ts-index'
2
+
3
+ export * from './EventCommand';
4
+ export * from './types';
@@ -0,0 +1,52 @@
1
+ import {
2
+ WindowHapiEventCommandData,
3
+ WindowHapiEventCommandNames,
4
+ WindowHapiEventCommandStatus,
5
+ } from "./EventCommand/types"
6
+ import { WindowHapiInstance } from "../../_window"
7
+ import { WindowHapiLogger } from "../logger/types"
8
+
9
+ export type WindowHapiEventStrategy = {
10
+ handleEvent: (
11
+ event: WindowHapiEventCommand,
12
+ ) => Promise<WindowHapiEventCommand>
13
+ }
14
+
15
+ export type WindowHapiEventMediatorInstances = {
16
+ source: WindowHapiInstance
17
+ targets: WindowHapiInstance[]
18
+ }
19
+
20
+ export type WindowHapiEventMediatorGetInstancesHandler =
21
+ () => WindowHapiEventMediatorInstances
22
+
23
+ export type WindowHapiEventCommand = {
24
+ id: string
25
+ name: WindowHapiEventCommandNames
26
+ createdAt: string
27
+ updatedAt: string | undefined
28
+ status: WindowHapiEventCommandStatus
29
+ logger: WindowHapiLogger
30
+ instance?: WindowHapiInstance
31
+ data: WindowHapiEventCommandData | undefined
32
+ sourceInstanceName: string
33
+ targetInstancesNames: string[]
34
+ toJSON: Record<string, any>
35
+ }
36
+
37
+ export type WindowHapiEventCommandCallbackHandler = (data: any) => void
38
+ export type WindowHapiEventCommandCommitHandler = (
39
+ ...args: any[]
40
+ ) => void | never | Promise<void | never>
41
+
42
+ export type WindowHapiEventCommandWithCallback = WindowHapiEventCommand & {
43
+ callback?: WindowHapiEventCommandCallbackHandler
44
+ }
45
+
46
+ export type WindowHapiEventListener = {
47
+ id?: string
48
+ name: WindowHapiEventCommandNames
49
+ callback:
50
+ | WindowHapiEventCommandCallbackHandler
51
+ | WindowHapiEventCommandCommitHandler
52
+ }
@@ -0,0 +1,7 @@
1
+ // created from 'create-ts-index'
2
+
3
+ export * from "./events"
4
+ export * from "./qa.types"
5
+ export * from "./types"
6
+ export * from "./validations.types"
7
+ export * from "./enums"
@@ -0,0 +1,12 @@
1
+ export enum LogLevel {
2
+ Off = 0,
3
+ Error,
4
+ Warning,
5
+ Info,
6
+ Debug,
7
+ }
8
+
9
+ export enum NetworkErrorLoggerType {
10
+ "XHR" = "XHR",
11
+ "WS" = "WS",
12
+ }
@@ -0,0 +1,18 @@
1
+ import { LogLevel } from "./enums"
2
+
3
+ export type LogOutput = (
4
+ source: string,
5
+ level: LogLevel,
6
+ ...objects: any[]
7
+ ) => void
8
+
9
+ export type WindowHapiLogger = {
10
+ id: string
11
+ setIsEnabled: (isEnabled: boolean) => void
12
+ debug: (...objects: any[]) => void
13
+ info: (...objects: any[]) => void
14
+ warn: (...objects: any[]) => void
15
+ error: (...objects: any[]) => void
16
+ timeStart: (message: string) => void
17
+ timeEnd: (message: string) => void
18
+ }
@@ -0,0 +1,9 @@
1
+ import { WindowHapiQA } from "../_window/qa.types"
2
+ import { WindowHapiModuleWithConstructorArgs } from "../_window"
3
+
4
+ export type WindowHapiQACommon = WindowHapiModuleWithConstructorArgs<
5
+ {
6
+ setComponentDebuggingIsEnabled: (isEnabled: boolean) => boolean
7
+ },
8
+ { readonly qa: WindowHapiQA }
9
+ >
@@ -0,0 +1,109 @@
1
+ import validator from "validator"
2
+ import { MessageDescriptor } from "react-intl"
3
+ import { WindowHapiLogger } from "./logger/types"
4
+ import { Validators } from "./validator/types"
5
+
6
+ export type ValueOf<T> = T[keyof T]
7
+ export type AnyNonFunction<T> = Omit<T, "function">
8
+ export declare type PrimitiveType =
9
+ | string
10
+ | number
11
+ | boolean
12
+ | null
13
+ | undefined
14
+ | Date
15
+ export type PartialBy<T, K extends keyof T> = Omit<T, K> & Partial<Pick<T, K>>
16
+ export type RecursivePartial<T> = {
17
+ [P in keyof T]?: RecursivePartial<T[P]>
18
+ }
19
+ export type PartialRecord<K extends keyof any, T> = Partial<Record<K, T>>
20
+ export type RemoveIndex<T> = {
21
+ [K in keyof T as string extends K
22
+ ? never
23
+ : number extends K
24
+ ? never
25
+ : K]: T[K]
26
+ }
27
+ export type PaginationLimitOffset = {
28
+ limit?: number
29
+ offset?: number
30
+ }
31
+ export type PaginationResponseV1 = {
32
+ count?: number
33
+ next?: string | null
34
+ previous?: string | null
35
+ } & PaginationLimitOffset
36
+ export type PaginationResponseV2 = {
37
+ total?: number
38
+ meta?: {
39
+ first: string
40
+ last: string
41
+ next: string
42
+ previous: string
43
+ }
44
+ } & PaginationLimitOffset
45
+ export type PaginatedAPIResponseV1<T> = {
46
+ results: T[]
47
+ } & PaginationResponseV1
48
+ export type PaginatedAPIResponseV2<T> = {
49
+ data: T[]
50
+ } & PaginationResponseV2
51
+ export type HapiInputErrorMessageOrValidity =
52
+ | MessageDescriptor
53
+ | boolean
54
+ | undefined
55
+ | null
56
+ export type UseValidatorResult = {
57
+ validityOrErrorMessages: Record<string, HapiInputErrorMessageOrValidity>
58
+ areAllValid: boolean
59
+ }
60
+ export type ValidatorKey =
61
+ | Exclude<
62
+ keyof typeof validator,
63
+ | "version"
64
+ | "AlphaLocale"
65
+ | "isAlphaLocales"
66
+ | "AlphanumericLocale"
67
+ | "isAlphanumericLocales"
68
+ | "ibanLocales"
69
+ | "FloatLocale"
70
+ | "isFloatLocales"
71
+ | "MobilePhoneLocale"
72
+ | "PhoneLocale"
73
+ | "PhoneLocaleAlias"
74
+ | "isMobilePhoneLocales"
75
+ | "PostalCodeLocale"
76
+ | "isPostalCodeLocales"
77
+ >
78
+ | keyof Validators
79
+ export type NestedValidatorKeys =
80
+ | ValidatorKey
81
+ | {
82
+ [k: string]: ValidatorKey | NestedValidatorKeys
83
+ }
84
+ export type BaseService = {
85
+ logger: WindowHapiLogger
86
+ }
87
+ // the reason there are no types like enums here is because
88
+ // the options should be a serializable JSON during generation of web component files
89
+ export type HapiWebComponent = {
90
+ title: string
91
+ description: string
92
+ moduleName: string //WindowHapiModuleName
93
+ secondaryModuleName?: string //WindowHapiModuleName
94
+ notes?: string //additional remarks like some best practices for this individual widget
95
+ path: string
96
+ key: string
97
+ id: string
98
+ injects?: string[]
99
+ initialState?: Partial<Record<string, any>>
100
+ isUserJourney?: boolean
101
+ webComponentCSS?: Record<string, any> //React.CSSProperties
102
+ attributes?: Record<string, string>
103
+ qaFunctionToMockId?: Record<string, string> //some widgets have attributes like <widget campaign-id=IDHERE> and they show 404 inside demo pages and documentation so this will map to window.hapiQA function that will grab that id. example below
104
+ /* mock id example
105
+ {
106
+ "campaignId": "campaign.getRandomCampaignId" //campaignId being the path parameter like [campaignId].tsx
107
+ }
108
+ */
109
+ }
@@ -0,0 +1,89 @@
1
+ import {
2
+ ZodAny,
3
+ ZodArray,
4
+ ZodBoolean,
5
+ ZodFunction,
6
+ ZodNullable,
7
+ ZodNumber,
8
+ ZodObject,
9
+ ZodOptional,
10
+ ZodRecord,
11
+ ZodString,
12
+ ZodTuple,
13
+ ZodUnion,
14
+ ZodUnknown,
15
+ } from "zod"
16
+
17
+ export type ZodIntlDescriptor = ZodObject<{
18
+ id: ZodString
19
+ defaultMessage: ZodString
20
+ }>
21
+ export type ZodPaginationLimit = ZodNumber
22
+ export type ZodPaginationOffset = ZodNumber
23
+ export type ZodPaginationLimitOffsetDefinition = {
24
+ limit: ZodOptional<ZodPaginationLimit>
25
+ offset: ZodOptional<ZodPaginationOffset>
26
+ }
27
+ export type ZodPaginationLimitOffset =
28
+ ZodObject<ZodPaginationLimitOffsetDefinition>
29
+ export type ZodPaginationNext = ZodString
30
+ export type ZodPaginationPrevious = ZodString
31
+ export type ZodPaginationFirst = ZodString
32
+ export type ZodPaginationLast = ZodString
33
+ export type ZodPaginationNextPreviousDefinition = {
34
+ next: ZodOptional<ZodNullable<ZodPaginationNext>>
35
+ previous: ZodOptional<ZodNullable<ZodPaginationPrevious>>
36
+ }
37
+ export type ZodPaginationFirstLastDefinition = {
38
+ first: ZodOptional<ZodNullable<ZodPaginationFirst>>
39
+ last: ZodOptional<ZodNullable<ZodPaginationLast>>
40
+ }
41
+ export type ZodPaginationTotal = ZodNumber
42
+ export type ZodPaginationResponseV1 = ZodObject<
43
+ {
44
+ count: ZodOptional<ZodNullable<ZodNumber>>
45
+ } & ZodPaginationLimitOffsetDefinition &
46
+ ZodPaginationNextPreviousDefinition
47
+ >
48
+ export type ZodPaginationMeta = ZodObject<
49
+ ZodPaginationFirstLastDefinition & ZodPaginationNextPreviousDefinition
50
+ >
51
+ export type ZodPaginationResponseV2 = ZodObject<
52
+ {
53
+ total: ZodOptional<ZodNullable<ZodPaginationTotal>>
54
+ meta: ZodOptional<ZodPaginationMeta>
55
+ } & ZodPaginationLimitOffsetDefinition
56
+ >
57
+ export type WindowHapiValidationsCommon = {
58
+ genericBoolean: ZodBoolean
59
+ genericNumber: ZodNumber
60
+ genericNumberArray: ZodArray<ZodNumber>
61
+ genericString: ZodString
62
+ genericStringArray: ZodArray<ZodString>
63
+ genericObject: ZodObject<any>
64
+ genericRecordFunction: ZodRecord<
65
+ ZodString,
66
+ ZodFunction<ZodTuple<[], ZodUnknown>, ZodUnknown>
67
+ >
68
+ genericRecordBoolean: ZodRecord<ZodString, ZodBoolean>
69
+ genericRecordString: ZodRecord<ZodString, ZodString>
70
+ genericStringOrNumber: ZodUnion<[ZodNumber, ZodString]>
71
+ genericNullableStringOrNumber: ZodNullable<ZodUnion<[ZodNumber, ZodString]>>
72
+ genericNullableString: ZodNullable<ZodString>
73
+ genericAny: ZodAny
74
+ genericAnyArray: ZodArray<ZodAny>
75
+ genericStringOrNumberArray: ZodArray<ZodUnion<[ZodNumber, ZodString]>>
76
+ recordString: ZodRecord<ZodString, ZodString>
77
+ intlDescriptor: ZodIntlDescriptor
78
+ limitOffsetPagination: ZodPaginationLimitOffsetDefinition
79
+ paginationMetaV1: ZodPaginationResponseV1
80
+ paginationMetaV2: ZodPaginationResponseV2
81
+ hexRegex: RegExp
82
+ hex: ZodString
83
+ camelCaseRegex: RegExp
84
+ camelCase: ZodString
85
+ urlRegex: RegExp
86
+ url: ZodString
87
+ apiResourceRegex: RegExp
88
+ apiResource: ZodString
89
+ }
@@ -0,0 +1,4 @@
1
+ export type Validators = {
2
+ isNotEmpty: (value: string | Record<string, any> | any[]) => boolean
3
+ isNotZero: (value: number) => boolean
4
+ }