@driveflux/config 3.0.4 → 3.0.5
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.
- package/dist/backend.js +116 -92
- package/dist/constants.js +122 -41
- package/dist/frontend.js +23 -25
- package/dist/next.config.js +51 -37
- package/dist/utils.js +8 -7
- package/package.json +2 -2
package/dist/backend.js
CHANGED
|
@@ -1,8 +1,36 @@
|
|
|
1
|
+
function _define_property(obj, key, value) {
|
|
2
|
+
if (key in obj) {
|
|
3
|
+
Object.defineProperty(obj, key, {
|
|
4
|
+
value: value,
|
|
5
|
+
enumerable: true,
|
|
6
|
+
configurable: true,
|
|
7
|
+
writable: true
|
|
8
|
+
});
|
|
9
|
+
} else {
|
|
10
|
+
obj[key] = value;
|
|
11
|
+
}
|
|
12
|
+
return obj;
|
|
13
|
+
}
|
|
14
|
+
function _object_spread(target) {
|
|
15
|
+
for(var i = 1; i < arguments.length; i++){
|
|
16
|
+
var source = arguments[i] != null ? arguments[i] : {};
|
|
17
|
+
var ownKeys = Object.keys(source);
|
|
18
|
+
if (typeof Object.getOwnPropertySymbols === "function") {
|
|
19
|
+
ownKeys = ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function(sym) {
|
|
20
|
+
return Object.getOwnPropertyDescriptor(source, sym).enumerable;
|
|
21
|
+
}));
|
|
22
|
+
}
|
|
23
|
+
ownKeys.forEach(function(key) {
|
|
24
|
+
_define_property(target, key, source[key]);
|
|
25
|
+
});
|
|
26
|
+
}
|
|
27
|
+
return target;
|
|
28
|
+
}
|
|
1
29
|
import { singleton } from '@driveflux/singleton';
|
|
2
30
|
import { z } from 'zod';
|
|
3
31
|
import { getNotionIds, getSlackIds } from './constants.js';
|
|
4
32
|
import { getAppEnv, isProd, requiredStringIfProdValidation } from './utils.js';
|
|
5
|
-
export
|
|
33
|
+
export var ConfigValidation = z.object({
|
|
6
34
|
appUrl: z.url(),
|
|
7
35
|
appEnv: z.string().optional(),
|
|
8
36
|
tunnelUrl: z.string().optional(),
|
|
@@ -12,21 +40,23 @@ export const ConfigValidation = z.object({
|
|
|
12
40
|
isProd: z.boolean(),
|
|
13
41
|
taxRate: z.number(),
|
|
14
42
|
oldTaxRate: z.number(),
|
|
15
|
-
baseCurrency: z.enum([
|
|
43
|
+
baseCurrency: z.enum([
|
|
44
|
+
'MYR'
|
|
45
|
+
]),
|
|
16
46
|
dbUrl: z.string(),
|
|
17
47
|
cse: z.object({
|
|
18
48
|
login: requiredStringIfProdValidation,
|
|
19
49
|
password: requiredStringIfProdValidation,
|
|
20
|
-
templateId: requiredStringIfProdValidation
|
|
50
|
+
templateId: requiredStringIfProdValidation
|
|
21
51
|
}),
|
|
22
52
|
utilization: z.object({
|
|
23
|
-
amountThreshold: z.number().min(0).default(5)
|
|
53
|
+
amountThreshold: z.number().min(0).default(5)
|
|
24
54
|
}),
|
|
25
55
|
algolia: z.object({
|
|
26
56
|
appId: z.string(),
|
|
27
57
|
adminKey: z.string(),
|
|
28
58
|
searchKey: z.string(),
|
|
29
|
-
knowledgeBaseIndex: z.string()
|
|
59
|
+
knowledgeBaseIndex: z.string()
|
|
30
60
|
}),
|
|
31
61
|
upload: z.object({
|
|
32
62
|
awsKey: z.string(),
|
|
@@ -36,7 +66,7 @@ export const ConfigValidation = z.object({
|
|
|
36
66
|
siteBucket: z.string(),
|
|
37
67
|
region: z.string(),
|
|
38
68
|
secret: z.string().optional(),
|
|
39
|
-
debug: z.boolean().optional()
|
|
69
|
+
debug: z.boolean().optional()
|
|
40
70
|
}),
|
|
41
71
|
stripe: z.object({
|
|
42
72
|
secretKey: z.string(),
|
|
@@ -46,23 +76,21 @@ export const ConfigValidation = z.object({
|
|
|
46
76
|
// Both possess different keys
|
|
47
77
|
webhook: z.object({
|
|
48
78
|
connectAccountKey: z.string(),
|
|
49
|
-
accountKey: z.string()
|
|
50
|
-
})
|
|
79
|
+
accountKey: z.string()
|
|
80
|
+
})
|
|
51
81
|
}),
|
|
52
|
-
twilio: z
|
|
53
|
-
.object({
|
|
82
|
+
twilio: z.object({
|
|
54
83
|
accountSid: z.string().optional(),
|
|
55
84
|
authToken: z.string().optional(),
|
|
56
|
-
phoneNumber: z.string().optional()
|
|
57
|
-
})
|
|
58
|
-
.optional(),
|
|
85
|
+
phoneNumber: z.string().optional()
|
|
86
|
+
}).optional(),
|
|
59
87
|
vonage: z.object({
|
|
60
88
|
apiKey: requiredStringIfProdValidation,
|
|
61
|
-
apiSecret: requiredStringIfProdValidation
|
|
89
|
+
apiSecret: requiredStringIfProdValidation
|
|
62
90
|
}),
|
|
63
91
|
esms: z.object({
|
|
64
92
|
apiKey: requiredStringIfProdValidation,
|
|
65
|
-
apiSecret: requiredStringIfProdValidation
|
|
93
|
+
apiSecret: requiredStringIfProdValidation
|
|
66
94
|
}),
|
|
67
95
|
slack: z.object({
|
|
68
96
|
token: requiredStringIfProdValidation,
|
|
@@ -80,7 +108,7 @@ export const ConfigValidation = z.object({
|
|
|
80
108
|
comingServicesChannelId: z.string().min(1),
|
|
81
109
|
engineeringRequestsChannel: z.string().min(1),
|
|
82
110
|
esmsChannelId: z.string().min(1),
|
|
83
|
-
excessMileageChannelId: z.string().min(1)
|
|
111
|
+
excessMileageChannelId: z.string().min(1)
|
|
84
112
|
}),
|
|
85
113
|
noStaticGenerating: z.boolean(),
|
|
86
114
|
notion: z.object({
|
|
@@ -92,7 +120,7 @@ export const ConfigValidation = z.object({
|
|
|
92
120
|
bdDatabaseId: z.string().min(1),
|
|
93
121
|
referralsDatabaseId: z.string().min(1),
|
|
94
122
|
brandsLandingPagesDatabaseId: z.string().min(1),
|
|
95
|
-
knowledgeBaseDatabaseId: z.string().min(1)
|
|
123
|
+
knowledgeBaseDatabaseId: z.string().min(1)
|
|
96
124
|
}),
|
|
97
125
|
flux: z.object({
|
|
98
126
|
defaultBillingAddress: z.object({
|
|
@@ -102,71 +130,74 @@ export const ConfigValidation = z.object({
|
|
|
102
130
|
city: z.string(),
|
|
103
131
|
state: z.string(),
|
|
104
132
|
/**
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
}),
|
|
133
|
+
* Two-letter country code ([ISO 3166-1 alpha-2](https://en.wikipedia.org/wiki/ISO_3166-1_alpha-2)).
|
|
134
|
+
*/ country: z.string(),
|
|
135
|
+
postalCode: z.string()
|
|
136
|
+
})
|
|
110
137
|
}),
|
|
111
138
|
html2pdfKey: z.string(),
|
|
112
139
|
cmsPreviewSecret: requiredStringIfProdValidation,
|
|
113
140
|
search: z.object({
|
|
114
|
-
noIdOptimization: z.boolean()
|
|
141
|
+
noIdOptimization: z.boolean()
|
|
115
142
|
}),
|
|
116
143
|
auth: z.object({
|
|
117
144
|
secureCookies: z.boolean(),
|
|
118
145
|
authSecret: z.string(),
|
|
119
146
|
jwtSecret: z.string(),
|
|
120
|
-
google: z
|
|
121
|
-
.object({
|
|
147
|
+
google: z.object({
|
|
122
148
|
clientId: z.string(),
|
|
123
|
-
clientSecret: z.string()
|
|
124
|
-
})
|
|
125
|
-
|
|
126
|
-
facebook: z
|
|
127
|
-
.object({
|
|
149
|
+
clientSecret: z.string()
|
|
150
|
+
}).optional(),
|
|
151
|
+
facebook: z.object({
|
|
128
152
|
clientId: z.string(),
|
|
129
|
-
clientSecret: z.string()
|
|
130
|
-
})
|
|
131
|
-
|
|
132
|
-
apple: z
|
|
133
|
-
.object({
|
|
153
|
+
clientSecret: z.string()
|
|
154
|
+
}).optional(),
|
|
155
|
+
apple: z.object({
|
|
134
156
|
clientId: z.string(),
|
|
135
|
-
clientSecret: z.string()
|
|
136
|
-
})
|
|
137
|
-
|
|
138
|
-
email: z
|
|
139
|
-
.object({
|
|
157
|
+
clientSecret: z.string()
|
|
158
|
+
}).optional(),
|
|
159
|
+
email: z.object({
|
|
140
160
|
server: z.string(),
|
|
141
|
-
from: z.string()
|
|
142
|
-
})
|
|
143
|
-
.optional(),
|
|
161
|
+
from: z.string()
|
|
162
|
+
}).optional()
|
|
144
163
|
}),
|
|
145
164
|
kv: z.object({
|
|
146
165
|
url: z.string(),
|
|
147
166
|
token: z.string(),
|
|
148
|
-
apiUrl: z.string()
|
|
167
|
+
apiUrl: z.string()
|
|
149
168
|
}),
|
|
150
169
|
sendSMSOutsideOfProd: z.boolean().optional(),
|
|
151
|
-
vercel: z
|
|
152
|
-
.
|
|
153
|
-
|
|
154
|
-
})
|
|
155
|
-
.optional(),
|
|
170
|
+
vercel: z.object({
|
|
171
|
+
cronSecret: z.string().optional()
|
|
172
|
+
}).optional()
|
|
156
173
|
});
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
174
|
+
var augmentEnv = function() {
|
|
175
|
+
var allEnv = _object_spread({}, getSlackIds(getAppEnv(), process.env), getNotionIds(getAppEnv()));
|
|
176
|
+
var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
|
|
177
|
+
try {
|
|
178
|
+
for(var _iterator = Object.keys(allEnv)[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){
|
|
179
|
+
var key = _step.value;
|
|
180
|
+
if (process.env[key]) {
|
|
181
|
+
continue;
|
|
182
|
+
}
|
|
183
|
+
process.env[key] = allEnv[key];
|
|
184
|
+
}
|
|
185
|
+
} catch (err) {
|
|
186
|
+
_didIteratorError = true;
|
|
187
|
+
_iteratorError = err;
|
|
188
|
+
} finally{
|
|
189
|
+
try {
|
|
190
|
+
if (!_iteratorNormalCompletion && _iterator.return != null) {
|
|
191
|
+
_iterator.return();
|
|
192
|
+
}
|
|
193
|
+
} finally{
|
|
194
|
+
if (_didIteratorError) {
|
|
195
|
+
throw _iteratorError;
|
|
196
|
+
}
|
|
165
197
|
}
|
|
166
|
-
process.env[key] = allEnv[key];
|
|
167
198
|
}
|
|
168
199
|
};
|
|
169
|
-
|
|
200
|
+
var getConfig = function() {
|
|
170
201
|
augmentEnv();
|
|
171
202
|
return {
|
|
172
203
|
appUrl: process.env.APP_URL,
|
|
@@ -174,8 +205,7 @@ const getConfig = () => {
|
|
|
174
205
|
apiVersion: process.env.API_VERSION,
|
|
175
206
|
tunnelUrl: process.env.TUNNEL_URL,
|
|
176
207
|
prodAppUrl: process.env.PROD_APP_URL || process.env.APP_URL,
|
|
177
|
-
apiUrl: process.env.API_URL ||
|
|
178
|
-
(process.env.APP_URL ? `${process.env.APP_URL}/api` : undefined),
|
|
208
|
+
apiUrl: process.env.API_URL || (process.env.APP_URL ? "".concat(process.env.APP_URL, "/api") : undefined),
|
|
179
209
|
reservationFee: 49,
|
|
180
210
|
isProd: isProd(),
|
|
181
211
|
taxRate: 0.1,
|
|
@@ -187,7 +217,7 @@ const getConfig = () => {
|
|
|
187
217
|
cse: {
|
|
188
218
|
login: process.env.CSE_LOGIN,
|
|
189
219
|
password: process.env.CSE_PASSWORD,
|
|
190
|
-
templateId: process.env.CSE_TEMPLATE_ID
|
|
220
|
+
templateId: process.env.CSE_TEMPLATE_ID
|
|
191
221
|
},
|
|
192
222
|
upload: {
|
|
193
223
|
awsKey: process.env.AWS_KEY,
|
|
@@ -197,28 +227,28 @@ const getConfig = () => {
|
|
|
197
227
|
siteBucket: process.env.SITE_BUCKET,
|
|
198
228
|
region: process.env.STORAGE_REGION,
|
|
199
229
|
secret: process.env.COMPANION_SECRET,
|
|
200
|
-
debug: process.env.COMPANION_DEBUG === 'true'
|
|
230
|
+
debug: process.env.COMPANION_DEBUG === 'true'
|
|
201
231
|
},
|
|
202
232
|
stripe: {
|
|
203
233
|
secretKey: process.env.STRIPE_SECRET_KEY,
|
|
204
234
|
apiVersion: '2020-08-27',
|
|
205
235
|
webhook: {
|
|
206
236
|
connectAccountKey: process.env.STRIPE_CONNECT_WEBHOOK_ENDPOINT_SECRET,
|
|
207
|
-
accountKey: process.env.STRIPE_WEBHOOK_SECRET
|
|
208
|
-
}
|
|
237
|
+
accountKey: process.env.STRIPE_WEBHOOK_SECRET
|
|
238
|
+
}
|
|
209
239
|
},
|
|
210
240
|
twilio: {
|
|
211
241
|
accountSid: process.env.TWILIO_ACCOUNT_SID,
|
|
212
242
|
authToken: process.env.TWILIO_AUTH_TOKEN,
|
|
213
|
-
phoneNumber: process.env.TWILIO_PHONE_NUMBER
|
|
243
|
+
phoneNumber: process.env.TWILIO_PHONE_NUMBER
|
|
214
244
|
},
|
|
215
245
|
vonage: {
|
|
216
246
|
apiKey: process.env.VONAGE_API_KEY,
|
|
217
|
-
apiSecret: process.env.VONAGE_API_SECRET
|
|
247
|
+
apiSecret: process.env.VONAGE_API_SECRET
|
|
218
248
|
},
|
|
219
249
|
esms: {
|
|
220
250
|
apiKey: process.env.ESMS_API_KEY,
|
|
221
|
-
apiSecret: process.env.ESMS_API_SECRET
|
|
251
|
+
apiSecret: process.env.ESMS_API_SECRET
|
|
222
252
|
},
|
|
223
253
|
redisUrl: process.env.REDIS_URL,
|
|
224
254
|
slack: {
|
|
@@ -237,7 +267,7 @@ const getConfig = () => {
|
|
|
237
267
|
comingServicesChannelId: process.env.SLACK_COMING_SERVICES_CHANNEL_ID,
|
|
238
268
|
engineeringRequestsChannel: process.env.SLACK_ENGINEERING_REQUESTS_CHANNEL_ID,
|
|
239
269
|
esmsChannelId: process.env.SLACK_ESMS_CHANNEL_ID,
|
|
240
|
-
excessMileageChannelId: process.env.SLACK_EXCESS_MILEAGE_CHANNEL_ID
|
|
270
|
+
excessMileageChannelId: process.env.SLACK_EXCESS_MILEAGE_CHANNEL_ID
|
|
241
271
|
},
|
|
242
272
|
noStaticGenerating: process.env.NO_STATIC_GENERATING === 'true',
|
|
243
273
|
notion: {
|
|
@@ -249,13 +279,13 @@ const getConfig = () => {
|
|
|
249
279
|
bdDatabaseId: process.env.NOTION_BD_DATABASE_ID,
|
|
250
280
|
referralsDatabaseId: process.env.NOTION_REFERRALS_DATABASE_ID,
|
|
251
281
|
brandsLandingPagesDatabaseId: process.env.NOTION_BRANDS_LANDING_PAGES_DATABASE_ID,
|
|
252
|
-
knowledgeBaseDatabaseId: process.env.NOTION_KNOWLEDGE_BASE_DATABASE_ID
|
|
282
|
+
knowledgeBaseDatabaseId: process.env.NOTION_KNOWLEDGE_BASE_DATABASE_ID
|
|
253
283
|
},
|
|
254
284
|
algolia: {
|
|
255
285
|
appId: process.env.ALGOLIA_APP_ID,
|
|
256
286
|
adminKey: process.env.ALGOLIA_ADMIN_KEY,
|
|
257
287
|
searchKey: process.env.ALGOLIA_SEARCH_KEY,
|
|
258
|
-
knowledgeBaseIndex: process.env.ALGOLIA_KNOWLEDGE_BASE_INDEX
|
|
288
|
+
knowledgeBaseIndex: process.env.ALGOLIA_KNOWLEDGE_BASE_INDEX
|
|
259
289
|
},
|
|
260
290
|
flux: {
|
|
261
291
|
defaultBillingAddress: {
|
|
@@ -265,16 +295,15 @@ const getConfig = () => {
|
|
|
265
295
|
city: 'Kuala Lumpur',
|
|
266
296
|
state: 'Kuala Lumpur',
|
|
267
297
|
/**
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
},
|
|
298
|
+
* Two-letter country code ([ISO 3166-1 alpha-2](https://en.wikipedia.org/wiki/ISO_3166-1_alpha-2)).
|
|
299
|
+
*/ country: 'MY',
|
|
300
|
+
postalCode: '50480'
|
|
301
|
+
}
|
|
273
302
|
},
|
|
274
303
|
html2pdfKey: process.env.HTML_2_PDF_APP_KEY,
|
|
275
304
|
cmsPreviewSecret: process.env.CMS_PREVIEW_SECRET,
|
|
276
305
|
search: {
|
|
277
|
-
noIdOptimization: process.env.NO_ID_OPTIMIZATION_IN_SEARCH === 'true'
|
|
306
|
+
noIdOptimization: process.env.NO_ID_OPTIMIZATION_IN_SEARCH === 'true'
|
|
278
307
|
},
|
|
279
308
|
auth: {
|
|
280
309
|
secureCookies: process.env.SECURE_COOKIES !== 'false',
|
|
@@ -282,38 +311,33 @@ const getConfig = () => {
|
|
|
282
311
|
jwtSecret: process.env.NEXTAUTH_SECRET,
|
|
283
312
|
google: {
|
|
284
313
|
clientId: process.env.GOOGLE_CLIENT_ID,
|
|
285
|
-
clientSecret: process.env.GOOGLE_CLIENT_SECRET
|
|
314
|
+
clientSecret: process.env.GOOGLE_CLIENT_SECRET
|
|
286
315
|
},
|
|
287
316
|
facebook: {
|
|
288
317
|
clientId: process.env.FACEBOOK_CLIENT_ID,
|
|
289
|
-
clientSecret: process.env.FACEBOOK_CLIENT_SECRET
|
|
318
|
+
clientSecret: process.env.FACEBOOK_CLIENT_SECRET
|
|
290
319
|
},
|
|
291
320
|
apple: {
|
|
292
321
|
clientId: process.env.APPLE_ID,
|
|
293
|
-
clientSecret: process.env.APPLE_SECRET
|
|
294
|
-
}
|
|
295
|
-
// email: {
|
|
296
|
-
// server: process.env.EMAIL_SERVER! || composeMailServer(),
|
|
297
|
-
// from: process.env.AUTH_EMAIL_FROM || process.env.FROM_MAIL!,
|
|
298
|
-
// }
|
|
322
|
+
clientSecret: process.env.APPLE_SECRET
|
|
323
|
+
}
|
|
299
324
|
},
|
|
300
325
|
sendSMSOutsideOfProd: process.env.SEND_SMS_OUTSIDE_OF_PROD === 'true',
|
|
301
326
|
vercel: {
|
|
302
|
-
cronSecret: process.env.CRON_SECRET
|
|
327
|
+
cronSecret: process.env.CRON_SECRET
|
|
303
328
|
},
|
|
304
329
|
kv: {
|
|
305
330
|
url: process.env.KV_URL,
|
|
306
331
|
token: process.env.KV_REST_API_TOKEN,
|
|
307
|
-
apiUrl: process.env.KV_REST_API_URL
|
|
308
|
-
}
|
|
332
|
+
apiUrl: process.env.KV_REST_API_URL
|
|
333
|
+
}
|
|
309
334
|
};
|
|
310
335
|
};
|
|
311
|
-
export
|
|
336
|
+
export var resetConfig = function() {
|
|
312
337
|
config = singleton('backendConfig', getConfig(), true);
|
|
313
338
|
return config;
|
|
314
339
|
};
|
|
315
|
-
export
|
|
316
|
-
export
|
|
340
|
+
export var config = singleton('backendConfig', getConfig());
|
|
341
|
+
export var setConfig = function(key, value) {
|
|
317
342
|
config[key] = value;
|
|
318
343
|
};
|
|
319
|
-
//# sourceMappingURL=backend.js.map
|
package/dist/constants.js
CHANGED
|
@@ -1,4 +1,56 @@
|
|
|
1
|
-
|
|
1
|
+
function _define_property(obj, key, value) {
|
|
2
|
+
if (key in obj) {
|
|
3
|
+
Object.defineProperty(obj, key, {
|
|
4
|
+
value: value,
|
|
5
|
+
enumerable: true,
|
|
6
|
+
configurable: true,
|
|
7
|
+
writable: true
|
|
8
|
+
});
|
|
9
|
+
} else {
|
|
10
|
+
obj[key] = value;
|
|
11
|
+
}
|
|
12
|
+
return obj;
|
|
13
|
+
}
|
|
14
|
+
function _object_spread(target) {
|
|
15
|
+
for(var i = 1; i < arguments.length; i++){
|
|
16
|
+
var source = arguments[i] != null ? arguments[i] : {};
|
|
17
|
+
var ownKeys = Object.keys(source);
|
|
18
|
+
if (typeof Object.getOwnPropertySymbols === "function") {
|
|
19
|
+
ownKeys = ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function(sym) {
|
|
20
|
+
return Object.getOwnPropertyDescriptor(source, sym).enumerable;
|
|
21
|
+
}));
|
|
22
|
+
}
|
|
23
|
+
ownKeys.forEach(function(key) {
|
|
24
|
+
_define_property(target, key, source[key]);
|
|
25
|
+
});
|
|
26
|
+
}
|
|
27
|
+
return target;
|
|
28
|
+
}
|
|
29
|
+
function ownKeys(object, enumerableOnly) {
|
|
30
|
+
var keys = Object.keys(object);
|
|
31
|
+
if (Object.getOwnPropertySymbols) {
|
|
32
|
+
var symbols = Object.getOwnPropertySymbols(object);
|
|
33
|
+
if (enumerableOnly) {
|
|
34
|
+
symbols = symbols.filter(function(sym) {
|
|
35
|
+
return Object.getOwnPropertyDescriptor(object, sym).enumerable;
|
|
36
|
+
});
|
|
37
|
+
}
|
|
38
|
+
keys.push.apply(keys, symbols);
|
|
39
|
+
}
|
|
40
|
+
return keys;
|
|
41
|
+
}
|
|
42
|
+
function _object_spread_props(target, source) {
|
|
43
|
+
source = source != null ? source : {};
|
|
44
|
+
if (Object.getOwnPropertyDescriptors) {
|
|
45
|
+
Object.defineProperties(target, Object.getOwnPropertyDescriptors(source));
|
|
46
|
+
} else {
|
|
47
|
+
ownKeys(Object(source)).forEach(function(key) {
|
|
48
|
+
Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));
|
|
49
|
+
});
|
|
50
|
+
}
|
|
51
|
+
return target;
|
|
52
|
+
}
|
|
53
|
+
var slackProductionChannels = {
|
|
2
54
|
SLACK_DEFAULT_CHANNEL_ID: 'C0679V8KGSH',
|
|
3
55
|
SLACK_RESERVATIONS_CHANNEL_ID: 'C01G8B12G67',
|
|
4
56
|
SLACK_FBC_CHANNEL: 'C01L1AAKB3N',
|
|
@@ -12,60 +64,89 @@ const slackProductionChannels = {
|
|
|
12
64
|
SLACK_COMING_SERVICES_CHANNEL_ID: 'C06SB20H2J1',
|
|
13
65
|
SLACK_ESMS_CHANNEL_ID: 'C07RPEP2BMY',
|
|
14
66
|
SLACK_EXCESS_MILEAGE_CHANNEL_ID: 'C0679URBY93',
|
|
15
|
-
SLACK_ENGINEERING_REQUESTS_CHANNEL_ID: 'C01U8GTK3K9'
|
|
67
|
+
SLACK_ENGINEERING_REQUESTS_CHANNEL_ID: 'C01U8GTK3K9'
|
|
68
|
+
};
|
|
69
|
+
var getSlackIdsMap = function(processEnv) {
|
|
70
|
+
return {
|
|
71
|
+
production: slackProductionChannels,
|
|
72
|
+
staging: Object.keys(slackProductionChannels).reduce(function(acc, key) {
|
|
73
|
+
acc[key] = 'C0661UNMBQU'; // #platform-staging-notifications
|
|
74
|
+
return acc;
|
|
75
|
+
}, {}),
|
|
76
|
+
development: Object.keys(slackProductionChannels).reduce(function(acc, key) {
|
|
77
|
+
acc[key] = (processEnv === null || processEnv === void 0 ? void 0 : processEnv.SLACK_MY_CHANNEL_ID) || 'C09GJ4FJVRS'; // #platform-dev-notifications
|
|
78
|
+
return acc;
|
|
79
|
+
}, {})
|
|
80
|
+
};
|
|
16
81
|
};
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
processEnv
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
82
|
+
export var getSlackIds = function(appEnv, processEnv) {
|
|
83
|
+
var slackIdsMap = getSlackIdsMap(processEnv);
|
|
84
|
+
var envIds = appEnv && appEnv in slackIdsMap ? slackIdsMap[appEnv] : slackIdsMap.staging;
|
|
85
|
+
var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
|
|
86
|
+
try {
|
|
87
|
+
// Override the values from ENV if available
|
|
88
|
+
for(var _iterator = Object.keys(envIds)[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){
|
|
89
|
+
var key = _step.value;
|
|
90
|
+
if (processEnv === null || processEnv === void 0 ? void 0 : processEnv[key]) {
|
|
91
|
+
envIds[key] = processEnv[key];
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
} catch (err) {
|
|
95
|
+
_didIteratorError = true;
|
|
96
|
+
_iteratorError = err;
|
|
97
|
+
} finally{
|
|
98
|
+
try {
|
|
99
|
+
if (!_iteratorNormalCompletion && _iterator.return != null) {
|
|
100
|
+
_iterator.return();
|
|
101
|
+
}
|
|
102
|
+
} finally{
|
|
103
|
+
if (_didIteratorError) {
|
|
104
|
+
throw _iteratorError;
|
|
105
|
+
}
|
|
38
106
|
}
|
|
39
107
|
}
|
|
40
108
|
return envIds;
|
|
41
109
|
};
|
|
42
|
-
|
|
110
|
+
var notionProductionChannels = {
|
|
43
111
|
NOTION_REQUEST_DATABASE_ID: '32332c0e-4277-43fa-b10e-7d458234f9ea',
|
|
44
|
-
NOTION_REVIEWS_DATABASE_ID: '8a8b0df9-567d-433f-8937-583db2766176',
|
|
45
|
-
NOTION_FBC_DATABASE_ID: '76960d4b-2b43-4019-a77e-ac46a0b3d752',
|
|
112
|
+
NOTION_REVIEWS_DATABASE_ID: '8a8b0df9-567d-433f-8937-583db2766176',
|
|
113
|
+
NOTION_FBC_DATABASE_ID: '76960d4b-2b43-4019-a77e-ac46a0b3d752',
|
|
46
114
|
NOTION_FLUXSTERS_DATABASE_ID: '4ea6953a-61c2-4673-8950-c0d0e158de0a',
|
|
47
115
|
NOTION_BD_DATABASE_ID: '172a9182-56c0-4358-b4f1-7e8fcfa44e46',
|
|
48
116
|
NOTION_BRANDS_LANDING_PAGES_DATABASE_ID: 'e321d71a-0d29-42da-ab0b-dca2260b643e',
|
|
49
117
|
NOTION_KNOWLEDGE_BASE_DATABASE_ID: '7a81653f-4351-4a17-aa1e-c3082c378441',
|
|
50
|
-
NOTION_REFERRALS_DATABASE_ID: 'b5599d70-b414-4aa9-9ff2-d445c8f3f0fc'
|
|
118
|
+
NOTION_REFERRALS_DATABASE_ID: 'b5599d70-b414-4aa9-9ff2-d445c8f3f0fc'
|
|
51
119
|
};
|
|
52
|
-
|
|
120
|
+
var NOTION_IDS_MAP = {
|
|
53
121
|
production: notionProductionChannels,
|
|
54
|
-
staging: {
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
},
|
|
122
|
+
staging: _object_spread_props(_object_spread({}, notionProductionChannels), {
|
|
123
|
+
NOTION_KNOWLEDGE_BASE_DATABASE_ID: 'f95b9986-c1c9-46ca-a742-d49f3f80d7dd'
|
|
124
|
+
})
|
|
58
125
|
};
|
|
59
|
-
export
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
126
|
+
export var getNotionIds = function(appEnv, processEnv) {
|
|
127
|
+
var envIds = appEnv && appEnv in NOTION_IDS_MAP ? NOTION_IDS_MAP[appEnv] : NOTION_IDS_MAP.staging;
|
|
128
|
+
var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
|
|
129
|
+
try {
|
|
130
|
+
// Override the values from ENV if available
|
|
131
|
+
for(var _iterator = Object.keys(envIds)[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){
|
|
132
|
+
var key = _step.value;
|
|
133
|
+
if (processEnv === null || processEnv === void 0 ? void 0 : processEnv[key]) {
|
|
134
|
+
envIds[key] = processEnv[key];
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
} catch (err) {
|
|
138
|
+
_didIteratorError = true;
|
|
139
|
+
_iteratorError = err;
|
|
140
|
+
} finally{
|
|
141
|
+
try {
|
|
142
|
+
if (!_iteratorNormalCompletion && _iterator.return != null) {
|
|
143
|
+
_iterator.return();
|
|
144
|
+
}
|
|
145
|
+
} finally{
|
|
146
|
+
if (_didIteratorError) {
|
|
147
|
+
throw _iteratorError;
|
|
148
|
+
}
|
|
67
149
|
}
|
|
68
150
|
}
|
|
69
151
|
return envIds;
|
|
70
152
|
};
|
|
71
|
-
//# sourceMappingURL=constants.js.map
|
package/dist/frontend.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { initSingleton } from '@driveflux/singleton';
|
|
2
2
|
import { z } from 'zod';
|
|
3
|
-
export
|
|
3
|
+
export var ConfigValidation = z.object({
|
|
4
4
|
appUrl: z.url(),
|
|
5
5
|
apiUrl: z.string(),
|
|
6
6
|
taxRate: z.number(),
|
|
@@ -9,7 +9,7 @@ export const ConfigValidation = z.object({
|
|
|
9
9
|
currency: z.string(),
|
|
10
10
|
stripe: z.object({
|
|
11
11
|
publishableKey: z.string(),
|
|
12
|
-
connectClientId: z.string()
|
|
12
|
+
connectClientId: z.string()
|
|
13
13
|
}),
|
|
14
14
|
gtmCode: z.string().optional(),
|
|
15
15
|
secureCookies: z.boolean(),
|
|
@@ -17,7 +17,7 @@ export const ConfigValidation = z.object({
|
|
|
17
17
|
graphCms: z.object({
|
|
18
18
|
devAuthToken: z.string(),
|
|
19
19
|
prodAuthToken: z.string(),
|
|
20
|
-
projectApi: z.string()
|
|
20
|
+
projectApi: z.string()
|
|
21
21
|
}),
|
|
22
22
|
isProd: z.boolean(),
|
|
23
23
|
noStaticGenerating: z.boolean(),
|
|
@@ -27,40 +27,39 @@ export const ConfigValidation = z.object({
|
|
|
27
27
|
vehicleIndexName: z.string(),
|
|
28
28
|
appId: z.string(),
|
|
29
29
|
searchKey: z.string(),
|
|
30
|
-
knowledgeBaseIndex: z.string()
|
|
30
|
+
knowledgeBaseIndex: z.string()
|
|
31
31
|
}),
|
|
32
32
|
glitchTip: z.object({
|
|
33
|
-
dsn: z.string().optional()
|
|
33
|
+
dsn: z.string().optional()
|
|
34
34
|
}),
|
|
35
35
|
postHog: z.object({
|
|
36
36
|
apiKey: z.string(),
|
|
37
|
-
apiHost: z.string().optional()
|
|
38
|
-
})
|
|
37
|
+
apiHost: z.string().optional()
|
|
38
|
+
})
|
|
39
39
|
});
|
|
40
40
|
/**
|
|
41
41
|
* Do not use this function, use the config object directly
|
|
42
|
-
*/
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
const apiUrl = process.env.API_URL || `${appUrl}/api`;
|
|
42
|
+
*/ var getConfig = function() {
|
|
43
|
+
var appUrl = process.env.APP_URL;
|
|
44
|
+
var apiUrl = process.env.API_URL || "".concat(appUrl, "/api");
|
|
46
45
|
return {
|
|
47
|
-
appUrl,
|
|
48
|
-
apiUrl,
|
|
46
|
+
appUrl: appUrl,
|
|
47
|
+
apiUrl: apiUrl,
|
|
49
48
|
taxRate: 0.1,
|
|
50
49
|
oldTaxRate: 0.08,
|
|
51
50
|
reservationFee: 49,
|
|
52
51
|
currency: 'MYR',
|
|
53
52
|
stripe: {
|
|
54
53
|
publishableKey: process.env.STRIPE_PUBLISHABLE_KEY,
|
|
55
|
-
connectClientId: process.env.STRIPE_CONNECT_CLIENT_ID || ''
|
|
54
|
+
connectClientId: process.env.STRIPE_CONNECT_CLIENT_ID || ''
|
|
56
55
|
},
|
|
57
56
|
gtmCode: process.env.GTM_CODE,
|
|
58
57
|
secureCookies: process.env.SECURE_COOKIES !== 'false',
|
|
59
58
|
appEnv: process.env.APP_ENV,
|
|
60
59
|
graphCms: {
|
|
61
|
-
devAuthToken:
|
|
62
|
-
prodAuthToken:
|
|
63
|
-
projectApi:
|
|
60
|
+
devAuthToken: "".concat(process.env.GRAPHCMS_AUTH_TOKEN),
|
|
61
|
+
prodAuthToken: "".concat(process.env.GRAPHCMS_AUTH_TOKEN),
|
|
62
|
+
projectApi: "".concat(process.env.GRAPHCMS_PROJECT_API)
|
|
64
63
|
},
|
|
65
64
|
isProd: process.env.APP_ENV === 'production',
|
|
66
65
|
noStaticGenerating: process.env.NO_STATIC_GENERATING === 'true',
|
|
@@ -70,23 +69,22 @@ const getConfig = () => {
|
|
|
70
69
|
vehicleIndexName: process.env.ALGOLIA_VEHICLE_INDEX_NAME || 'vehicles',
|
|
71
70
|
appId: process.env.ALGOLIA_APP_ID,
|
|
72
71
|
searchKey: process.env.ALGOLIA_SEARCH_KEY,
|
|
73
|
-
knowledgeBaseIndex: process.env.ALGOLIA_KNOWLEDGE_BASE_INDEX || 'knowledge_base'
|
|
72
|
+
knowledgeBaseIndex: process.env.ALGOLIA_KNOWLEDGE_BASE_INDEX || 'knowledge_base'
|
|
74
73
|
},
|
|
75
74
|
glitchTip: {
|
|
76
|
-
dsn: process.env.GLITCHTIP_DSN
|
|
75
|
+
dsn: process.env.GLITCHTIP_DSN
|
|
77
76
|
},
|
|
78
77
|
postHog: {
|
|
79
78
|
apiKey: process.env.NEXT_PUBLIC_POSTHOG_KEY,
|
|
80
|
-
apiHost: process.env.NEXT_PUBLIC_POSTHOG_HOST
|
|
81
|
-
}
|
|
79
|
+
apiHost: process.env.NEXT_PUBLIC_POSTHOG_HOST
|
|
80
|
+
}
|
|
82
81
|
};
|
|
83
82
|
};
|
|
84
|
-
export
|
|
83
|
+
export var resetConfig = function() {
|
|
85
84
|
config = initSingleton('frontendConfig', getConfig, true);
|
|
86
85
|
return config;
|
|
87
86
|
};
|
|
88
|
-
export
|
|
89
|
-
export
|
|
87
|
+
export var config = initSingleton('frontendConfig', getConfig);
|
|
88
|
+
export var setConfig = function(key, value) {
|
|
90
89
|
config[key] = value;
|
|
91
90
|
};
|
|
92
|
-
//# sourceMappingURL=frontend.js.map
|
package/dist/next.config.js
CHANGED
|
@@ -1,89 +1,103 @@
|
|
|
1
|
+
function _type_of(obj) {
|
|
2
|
+
"@swc/helpers - typeof";
|
|
3
|
+
return obj && typeof Symbol !== "undefined" && obj.constructor === Symbol ? "symbol" : typeof obj;
|
|
4
|
+
}
|
|
1
5
|
/**
|
|
2
6
|
* Remove React properties from the bundle when explicitly set via DO_NOT_REMOVE_REACT_PROPERTIES
|
|
3
7
|
* or when the app is in production mode.
|
|
4
|
-
*/
|
|
5
|
-
|
|
6
|
-
typeof process.env.DO_NOT_REMOVE_REACT_PROPERTIES
|
|
7
|
-
? process.env.DO_NOT_REMOVE_REACT_PROPERTIES.toLowerCase() === 'true'
|
|
8
|
-
: process.env.APP_ENV === 'production';
|
|
9
|
-
export const baseNextConfig = {
|
|
8
|
+
*/ var reactRemoveProperties = typeof process.env.DO_NOT_REMOVE_REACT_PROPERTIES === 'string' && _type_of(process.env.DO_NOT_REMOVE_REACT_PROPERTIES) ? process.env.DO_NOT_REMOVE_REACT_PROPERTIES.toLowerCase() === 'true' : process.env.APP_ENV === 'production';
|
|
9
|
+
export var baseNextConfig = {
|
|
10
10
|
i18n: {
|
|
11
|
-
locales: [
|
|
12
|
-
|
|
11
|
+
locales: [
|
|
12
|
+
'en',
|
|
13
|
+
'ms'
|
|
14
|
+
],
|
|
15
|
+
defaultLocale: 'en'
|
|
13
16
|
},
|
|
14
17
|
env: {
|
|
15
|
-
BASE_CURRENCY: 'MYR'
|
|
18
|
+
BASE_CURRENCY: 'MYR'
|
|
16
19
|
},
|
|
17
20
|
reactStrictMode: true,
|
|
18
21
|
images: {
|
|
19
|
-
deviceSizes: [
|
|
20
|
-
|
|
21
|
-
|
|
22
|
+
deviceSizes: [
|
|
23
|
+
640,
|
|
24
|
+
750,
|
|
25
|
+
1200,
|
|
26
|
+
1920
|
|
27
|
+
],
|
|
28
|
+
qualities: [
|
|
29
|
+
70,
|
|
30
|
+
75,
|
|
31
|
+
90
|
|
32
|
+
],
|
|
33
|
+
minimumCacheTTL: 31536000,
|
|
22
34
|
remotePatterns: [
|
|
23
35
|
{
|
|
24
36
|
protocol: 'https',
|
|
25
|
-
hostname: 'driveflux.com'
|
|
37
|
+
hostname: 'driveflux.com'
|
|
26
38
|
},
|
|
27
39
|
{
|
|
28
40
|
protocol: 'https',
|
|
29
|
-
hostname: 'dev-flux-site-files.s3.ap-southeast-1.amazonaws.com'
|
|
41
|
+
hostname: 'dev-flux-site-files.s3.ap-southeast-1.amazonaws.com'
|
|
30
42
|
},
|
|
31
43
|
{
|
|
32
44
|
protocol: 'https',
|
|
33
|
-
hostname: 'flux-site-files.s3.ap-southeast-1.amazonaws.com'
|
|
45
|
+
hostname: 'flux-site-files.s3.ap-southeast-1.amazonaws.com'
|
|
34
46
|
},
|
|
35
47
|
{
|
|
36
48
|
protocol: 'https',
|
|
37
|
-
hostname: 's3.ap-southeast-1.amazonaws.com'
|
|
49
|
+
hostname: 's3.ap-southeast-1.amazonaws.com'
|
|
38
50
|
},
|
|
39
51
|
{
|
|
40
52
|
protocol: 'https',
|
|
41
|
-
hostname: 'flux-admin.s3.ap-southeast-1.amazonaws.com'
|
|
53
|
+
hostname: 'flux-admin.s3.ap-southeast-1.amazonaws.com'
|
|
42
54
|
},
|
|
43
55
|
{
|
|
44
56
|
protocol: 'https',
|
|
45
|
-
hostname: 'vercel.app'
|
|
57
|
+
hostname: 'vercel.app'
|
|
46
58
|
},
|
|
47
59
|
{
|
|
48
60
|
protocol: 'https',
|
|
49
|
-
hostname: 'media.graphcms.com'
|
|
61
|
+
hostname: 'media.graphcms.com'
|
|
50
62
|
},
|
|
51
63
|
{
|
|
52
64
|
protocol: 'https',
|
|
53
|
-
hostname: 'media.graphassets.com'
|
|
65
|
+
hostname: 'media.graphassets.com'
|
|
54
66
|
},
|
|
55
67
|
{
|
|
56
68
|
protocol: 'https',
|
|
57
|
-
hostname: 'www.notion.so'
|
|
69
|
+
hostname: 'www.notion.so'
|
|
58
70
|
},
|
|
59
71
|
// This is for notion images
|
|
60
72
|
{
|
|
61
73
|
protocol: 'https',
|
|
62
|
-
hostname: 'prod-files-secure.s3.us-west-2.amazonaws.com'
|
|
74
|
+
hostname: 'prod-files-secure.s3.us-west-2.amazonaws.com'
|
|
63
75
|
},
|
|
64
76
|
{
|
|
65
77
|
protocol: 'https',
|
|
66
|
-
hostname: 'ap-northeast-1.graphassets.com'
|
|
67
|
-
}
|
|
68
|
-
]
|
|
78
|
+
hostname: 'ap-northeast-1.graphassets.com'
|
|
79
|
+
}
|
|
80
|
+
]
|
|
69
81
|
},
|
|
70
82
|
experimental: {
|
|
71
83
|
esmExternals: true,
|
|
72
|
-
swcPlugins: [
|
|
84
|
+
swcPlugins: [
|
|
85
|
+
[
|
|
86
|
+
'@lingui/swc-plugin',
|
|
87
|
+
{}
|
|
88
|
+
]
|
|
89
|
+
]
|
|
73
90
|
},
|
|
74
91
|
compiler: {
|
|
75
|
-
reactRemoveProperties,
|
|
76
|
-
removeConsole: process.env.FORCE_LOGGING_IN_PROD
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
}
|
|
82
|
-
: false,
|
|
92
|
+
reactRemoveProperties: reactRemoveProperties,
|
|
93
|
+
removeConsole: process.env.FORCE_LOGGING_IN_PROD ? false : process.env.APP_ENV === 'production' ? {
|
|
94
|
+
exclude: [
|
|
95
|
+
'error'
|
|
96
|
+
]
|
|
97
|
+
} : false
|
|
83
98
|
},
|
|
84
99
|
typescript: {
|
|
85
|
-
ignoreBuildErrors: process.env.IGNORE_NEXT_BUILD_ERRORS === 'true'
|
|
100
|
+
ignoreBuildErrors: process.env.IGNORE_NEXT_BUILD_ERRORS === 'true'
|
|
86
101
|
},
|
|
87
|
-
poweredByHeader: false
|
|
102
|
+
poweredByHeader: false
|
|
88
103
|
};
|
|
89
|
-
//# sourceMappingURL=next.config.js.map
|
package/dist/utils.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import z from 'zod';
|
|
2
|
-
export
|
|
2
|
+
export var getAppEnv = function() {
|
|
3
3
|
if (process.env.APP_ENV) {
|
|
4
4
|
return process.env.APP_ENV;
|
|
5
5
|
}
|
|
@@ -14,9 +14,10 @@ export const getAppEnv = () => {
|
|
|
14
14
|
// Default to development as a last resort
|
|
15
15
|
return 'development';
|
|
16
16
|
};
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
17
|
+
var isAppEnv = function(env) {
|
|
18
|
+
return getAppEnv() === env;
|
|
19
|
+
};
|
|
20
|
+
export var isProd = function() {
|
|
21
|
+
return isAppEnv('production');
|
|
22
|
+
};
|
|
23
|
+
export var requiredStringIfProdValidation = isProd() ? z.string().min(1) : z.string().optional();
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@driveflux/config",
|
|
3
|
-
"version": "3.0.
|
|
3
|
+
"version": "3.0.5",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"exports": {
|
|
6
6
|
"./backend": {
|
|
@@ -35,7 +35,7 @@
|
|
|
35
35
|
"@types/node": "^24.9.1",
|
|
36
36
|
"@types/react": "19.2.2",
|
|
37
37
|
"del-cli": "^7.0.0",
|
|
38
|
-
"next": "16.0.
|
|
38
|
+
"next": "16.0.3",
|
|
39
39
|
"typescript": "^5.9.3"
|
|
40
40
|
},
|
|
41
41
|
"scripts": {
|