-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathconfig.ts
215 lines (210 loc) · 5.92 KB
/
config.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
import * as path from "path";
import { NonNegativeNumber } from "@pagopa/ts-commons/lib/numbers";
import { readableReport } from "@pagopa/ts-commons/lib/reporters";
import { FiscalCode, NonEmptyString } from "@pagopa/ts-commons/lib/strings";
import chalk from "chalk";
import * as E from "fp-ts/lib/Either";
import _ from "lodash";
import { EmailAddress } from "../generated/definitions/backend/EmailAddress";
import { PreferredLanguageEnum } from "../generated/definitions/backend/PreferredLanguage";
import { PushNotificationsContentTypeEnum } from "../generated/definitions/backend/PushNotificationsContentType";
import { ReminderStatusEnum } from "../generated/definitions/backend/ReminderStatus";
import {
IoDevServerConfig,
ProfileAttrs,
WalletMethodConfig
} from "./types/config";
import { readFileAsJSON } from "./utils/file";
export const staticContentRootPath = "/static_contents";
const root = path.resolve(".");
export const assetsFolder = path.join(root, "assets");
export const configFolder = path.join(root, "config");
const defaultProfileAttrs: ProfileAttrs = {
name: "Maria Giovanna",
family_name: "Rossi",
mobile: "5555555555" as NonEmptyString,
fiscal_code: "TAMMRA80A41H501I" as FiscalCode,
email: "maria.giovanna.rossi@email.it" as EmailAddress,
accepted_tos_version: 4.5 as NonNegativeNumber,
preferred_languages: [PreferredLanguageEnum.it_IT],
reminder_status: ReminderStatusEnum.ENABLED,
push_notifications_content_type: PushNotificationsContentTypeEnum.FULL
};
const paymentMethods: WalletMethodConfig = {
walletBancomatCount: 0,
walletCreditCardCount: 1,
walletCreditCardCoBadgeCount: 0,
privativeCount: 0,
satispayCount: 0,
paypalCount: 1,
bPayCount: 1,
citizenSatispay: true,
citizenBancomatCount: 1,
citizenBPayCount: 1,
citizenCreditCardCoBadgeCount: 1,
citizenPrivative: true,
citizenPaypal: true
};
/**
* default config to setup dev-server
* warning: you should not edit this file (neither commit). Instead you should add or edit the json config file (see 'config' folder)
*/
const defaultConfig: IoDevServerConfig = {
global: {
delay: 0,
autoLogin: false,
allowRandomValues: true,
responseError: undefined,
logSAMLRequest: false
},
profile: {
attrs: defaultProfileAttrs,
authenticationProvider: "spid",
firstOnboarding: false,
allowRandomValues: true
},
messages: {
response: {
getMessagesResponseCode: 200,
getMessageResponseCode: 200,
getThirdPartyMessageResponseCode: 200
},
pnMessageTemplateWrappers: [
{
count: 0,
template: {
unpaidValidPayments: 360,
unpaidExpiredPayments: 5,
paidPayments: 12,
failedPayments: 7,
unrelatedPayments: 20,
isCancelled: false,
attachmentCount: 2,
f24Count: 19
}
}
],
attachmentAvailableAfterSeconds: 5,
attachmentExpiredAfterSeconds: 10,
attachmentRetryAfterSeconds: 2,
pnOptInMessage: false,
withRemoteAttachments: 0,
paymentsCount: 1,
paymentInvalidAfterDueDateWithValidDueDateCount: 0,
paymentInvalidAfterDueDateWithExpiredDueDateCount: 0,
paymentWithValidDueDateCount: 0,
paymentWithExpiredDueDateCount: 0,
medicalCount: 0,
fci: {
waitForSignatureCount: 0,
rejectedCount: 0,
expiredCount: 0,
expired90Count: 0,
waitForQtspCount: 0,
signedCount: 0,
canceledCount: 0,
noSignatureFieldsCount: 0,
response: {
getFciResponseCode: 200
}
},
withCTA: false,
withEUCovidCert: false,
withValidDueDateCount: 0,
withInValidDueDateCount: 0,
// sending 2 messages at minimum to allow for basic pagination
standardMessageCount: 2,
archivedMessageCount: 1,
// atm it has effect only on message flow (pr welcome)
allowRandomValues: true
},
wallet: {
methods: paymentMethods,
shuffleAbi: true,
useLegacyRptIdVerificationSystem: false,
verificaError: undefined,
attivaError: undefined,
// atm it has no effect (pr welcome)
allowRandomValues: true,
payment: undefined,
// success (0 outcome code)
onboardingCreditCardOutCode: 0,
// success (0 outcome code)
onboardingPaypalOutCode: 0,
// success (0 outcome code)
paymentOutCode: 0,
// IDPay initiatives show in wallet
idPay: {
refundCount: 1,
refundNotConfiguredCount: 0,
refundUnsubscribedCount: 0,
refundSuspendedCount: 0,
discountCount: 1
}
},
services: {
response: {
getServicesPreference: 200,
getServicesResponseCode: 200,
postServicesPreference: 200,
getServiceResponseCode: 200
},
national: 5,
local: 5,
specialServices: {
siciliaVola: true,
cgn: true,
cdc: true,
pn: false,
fci: true
},
// it has partially effect (pr welcome)
allowRandomValues: true
},
features: {
bonus: {
cgn: {
isCgnEligible: true,
isEycaEligible: true,
allowRandomValues: true
}
},
idpay: {
ibanSize: 3
},
lollipop: {
enabled: false
},
fastLogin: {
sessionTTLinMS: 60000
},
allowRandomValues: true
}
};
/**
* set your config file you want to load and apply
* config file should be included in "config" directory
*/
const customConfigFile = "config.json";
const customConfig =
readFileAsJSON(`${configFolder}/${customConfigFile}`) ?? undefined;
if (customConfig !== undefined) {
// eslint-disable-next-line no-console
console.log(
chalk.bgGreenBright(
`successfully loaded custom config file: ${customConfigFile}`
)
);
}
export const ioDevServerConfig: typeof defaultConfig = _.merge(
defaultConfig,
customConfig
);
const checkData = IoDevServerConfig.decode(ioDevServerConfig);
if (E.isLeft(checkData)) {
throw new Error(
`your custom config file ${customConfig} contains some invalid data:\n${readableReport(
checkData.left
)}`
);
}