@pisell/pisellos 3.0.69 → 3.0.70

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.
@@ -0,0 +1,594 @@
1
+ var __defProp = Object.defineProperty;
2
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
+ var __getOwnPropNames = Object.getOwnPropertyNames;
4
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
5
+ var __export = (target, all) => {
6
+ for (var name in all)
7
+ __defProp(target, name, { get: all[name], enumerable: true });
8
+ };
9
+ var __copyProps = (to, from, except, desc) => {
10
+ if (from && typeof from === "object" || typeof from === "function") {
11
+ for (let key of __getOwnPropNames(from))
12
+ if (!__hasOwnProp.call(to, key) && key !== except)
13
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
14
+ }
15
+ return to;
16
+ };
17
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
18
+
19
+ // src/solution/RegisterAndLogin/config.ts
20
+ var config_exports = {};
21
+ __export(config_exports, {
22
+ ApiCaller: () => ApiCaller,
23
+ channelConfigMap: () => channelConfigMap,
24
+ createApiCaller: () => createApiCaller,
25
+ getChannelConfig: () => getChannelConfig
26
+ });
27
+ module.exports = __toCommonJS(config_exports);
28
+ var onlineStoreConfig = {
29
+ sendEmailVerificationCode: {
30
+ url: "/auth/email/register-code",
31
+ method: "GET",
32
+ transformParams: (params) => ({
33
+ email: params.target
34
+ })
35
+ },
36
+ sendEmailLoginCode: {
37
+ url: "/auth/send-email-code",
38
+ method: "POST",
39
+ transformParams: (params) => ({
40
+ email: params.target,
41
+ purpose: params.purpose,
42
+ type: params.type
43
+ })
44
+ },
45
+ sendSmsRegisterCode: {
46
+ url: "/auth/mobile/sms-register",
47
+ method: "POST",
48
+ transformParams: (params) => ({
49
+ phone: String(params.phone),
50
+ country_calling_code: String(params.country_calling_code)
51
+ })
52
+ },
53
+ sendEmailRegisterLink: {
54
+ url: "/auth/email/link/new-send-register-link",
55
+ method: "POST",
56
+ transformParams: (email) => ({
57
+ email
58
+ })
59
+ },
60
+ verifyEmailRegistrationLink: {
61
+ url: "/auth/email/link/new-register",
62
+ method: "POST",
63
+ transformParams: (params) => ({
64
+ code: params.code,
65
+ password: params.password
66
+ })
67
+ },
68
+ emailPasswordLogin: {
69
+ url: "/auth/email/login",
70
+ method: "POST",
71
+ transformParams: (params) => ({
72
+ email: params.email,
73
+ password: params.password
74
+ }),
75
+ options: {
76
+ withCredentials: true
77
+ }
78
+ },
79
+ emailCodeRegister: {
80
+ url: "/auth/email/register",
81
+ method: "POST",
82
+ transformParams: (params) => ({
83
+ email: params.email,
84
+ code: params.code,
85
+ password: params.password
86
+ })
87
+ },
88
+ phoneCodeRegister: {
89
+ url: "/auth/mobile/register",
90
+ method: "POST",
91
+ transformParams: (params) => ({
92
+ phone: String(params.phone),
93
+ password: params.password,
94
+ code: params.code,
95
+ country_calling_code: String(params.country_calling_code)
96
+ })
97
+ },
98
+ resendEmailRegisterLink: {
99
+ url: "/auth/email/link/resend_register_link",
100
+ method: "POST",
101
+ transformParams: (params) => ({
102
+ code: params.code
103
+ })
104
+ },
105
+ checkEmailLinkCode: {
106
+ url: "/auth/email/link/new-register-check-code",
107
+ method: "GET",
108
+ transformParams: (params) => ({
109
+ code: params.code
110
+ })
111
+ },
112
+ sendSmsLoginCode: {
113
+ url: "/auth/send-login-msg",
114
+ method: "POST",
115
+ transformParams: (params) => ({
116
+ phone: String(params.phone),
117
+ country_calling_code: String(params.country_calling_code)
118
+ })
119
+ },
120
+ phoneCodeLogin: {
121
+ url: "/auth/mobile-login",
122
+ method: "POST",
123
+ transformParams: (params) => ({
124
+ phone: String(params.phone),
125
+ country_calling_code: String(params.country_calling_code),
126
+ code: params.code
127
+ })
128
+ },
129
+ guestLogin: {
130
+ url: "/auth/guest/login",
131
+ method: "POST",
132
+ transformParams: (params) => ({
133
+ login_channel: params.login_channel,
134
+ guest_code: params.guest_code
135
+ })
136
+ },
137
+ checkEmailExists: {
138
+ url: "/auth/email/check-email",
139
+ method: "GET",
140
+ transformParams: (params) => ({
141
+ email: params.email,
142
+ sales_channel: "online_store"
143
+ })
144
+ },
145
+ checkEmailCode: {
146
+ url: "/auth/email/check-email-code",
147
+ method: "GET",
148
+ transformParams: (params) => ({
149
+ email: params.email,
150
+ code: params.code,
151
+ action: params.action
152
+ })
153
+ },
154
+ checkMobileCode: {
155
+ url: "/auth/mobile/check-mobile-code",
156
+ method: "GET",
157
+ transformParams: (params) => ({
158
+ phone: String(params.phone),
159
+ code: params.code,
160
+ country_calling_code: String(params.country_calling_code)
161
+ })
162
+ },
163
+ phonePasswordLogin: {
164
+ url: "/auth/mobile/login",
165
+ method: "POST",
166
+ transformParams: (params) => ({
167
+ phone: String(params.phone),
168
+ password: params.password,
169
+ country_calling_code: String(params.country_calling_code)
170
+ })
171
+ },
172
+ sendPasswordResetEmail: {
173
+ url: "/auth/email/reset-password-code",
174
+ method: "GET",
175
+ transformParams: (params) => ({
176
+ email: params.email
177
+ })
178
+ },
179
+ sendPasswordResetSms: {
180
+ url: "/auth/mobile/sms-forget",
181
+ method: "POST",
182
+ transformParams: (params) => ({
183
+ phone: String(params.phone),
184
+ country_calling_code: String(params.country_calling_code)
185
+ })
186
+ },
187
+ sendResetPasswordLink: {
188
+ url: "/auth/email/link/send_reset_pwd_link",
189
+ method: "POST",
190
+ transformParams: (params) => ({
191
+ email: params.email
192
+ })
193
+ },
194
+ checkResetPasswordCode: {
195
+ url: "/auth/email/link/check_code",
196
+ method: "GET",
197
+ transformParams: (params) => ({
198
+ code: params.code
199
+ })
200
+ },
201
+ resetPasswordByCode: {
202
+ url: "/auth/email/link/reset_pwd_by_code",
203
+ method: "POST",
204
+ transformParams: (params) => ({
205
+ code: params.code,
206
+ password: params.password
207
+ })
208
+ },
209
+ resetPasswordByEmail: {
210
+ url: "/auth/email/reset-password",
211
+ method: "POST",
212
+ transformParams: (params) => ({
213
+ email: params.email,
214
+ password: params.password,
215
+ code: params.code
216
+ })
217
+ },
218
+ resetPasswordByPhone: {
219
+ url: "/auth/mobile/reset-password",
220
+ method: "POST",
221
+ transformParams: (params) => ({
222
+ phone: String(params.phone),
223
+ password: params.password,
224
+ code: params.code,
225
+ country_calling_code: String(params.country_calling_code)
226
+ })
227
+ },
228
+ verifyCode: {
229
+ url: "/auth/verify-code",
230
+ method: "POST",
231
+ transformParams: (params) => params
232
+ },
233
+ register: {
234
+ url: "/auth/register",
235
+ method: "POST",
236
+ transformParams: (params) => params
237
+ },
238
+ login: {
239
+ url: "/auth/login",
240
+ method: "POST",
241
+ transformParams: (params) => params
242
+ },
243
+ oauthLogin: {
244
+ url: "/auth/oauth-login",
245
+ method: "POST",
246
+ transformParams: (params) => params
247
+ },
248
+ validateToken: {
249
+ url: "/auth/validate",
250
+ method: "GET",
251
+ transformParams: (token) => ({}),
252
+ options: {
253
+ headers: (token) => ({
254
+ Authorization: `Bearer ${token}`
255
+ })
256
+ }
257
+ },
258
+ logout: {
259
+ url: "/auth/logout",
260
+ method: "POST",
261
+ transformParams: () => ({})
262
+ },
263
+ getCountries: {
264
+ url: "/area/country",
265
+ method: "GET",
266
+ transformParams: () => ({})
267
+ },
268
+ facebookLogin: {
269
+ url: "/auth/facebook/login",
270
+ method: "POST",
271
+ transformParams: (params) => ({
272
+ token: params.token
273
+ })
274
+ },
275
+ appleLogin: {
276
+ url: "/auth/apple/login",
277
+ method: "POST",
278
+ transformParams: (params) => ({
279
+ code: params.code
280
+ })
281
+ }
282
+ };
283
+ var defaultConfig = {
284
+ sendEmailVerificationCode: {
285
+ url: "/auth/send-email-code",
286
+ method: "POST",
287
+ transformParams: (params) => ({
288
+ email: params.target,
289
+ purpose: params.purpose,
290
+ type: params.type
291
+ })
292
+ },
293
+ sendEmailLoginCode: {
294
+ url: "/auth/send-email-code",
295
+ method: "POST",
296
+ transformParams: (params) => ({
297
+ email: params.target,
298
+ purpose: params.purpose,
299
+ type: params.type
300
+ })
301
+ },
302
+ sendSmsRegisterCode: {
303
+ url: "/auth/send-sms-register",
304
+ method: "POST",
305
+ transformParams: (params) => ({
306
+ phone: String(params.phone),
307
+ country_calling_code: String(params.country_calling_code)
308
+ })
309
+ },
310
+ sendEmailRegisterLink: {
311
+ url: "/auth/send-email-register-link",
312
+ method: "POST",
313
+ transformParams: (email) => ({
314
+ email
315
+ })
316
+ },
317
+ verifyEmailRegistrationLink: {
318
+ url: "/auth/verify-email-registration-link",
319
+ method: "POST",
320
+ transformParams: (code) => ({
321
+ code
322
+ })
323
+ },
324
+ emailPasswordLogin: {
325
+ url: "/auth/email-password-login",
326
+ method: "POST",
327
+ transformParams: (params) => ({
328
+ email: params.email,
329
+ password: params.password
330
+ })
331
+ },
332
+ emailCodeRegister: {
333
+ url: "/auth/email/register",
334
+ method: "POST",
335
+ transformParams: (params) => ({
336
+ email: params.email,
337
+ code: params.code,
338
+ password: params.password
339
+ })
340
+ },
341
+ phoneCodeRegister: {
342
+ url: "/auth/mobile/register",
343
+ method: "POST",
344
+ transformParams: (params) => ({
345
+ phone: String(params.phone),
346
+ password: params.password,
347
+ code: params.code,
348
+ country_calling_code: String(params.country_calling_code)
349
+ })
350
+ },
351
+ resendEmailRegisterLink: {
352
+ url: "/auth/resend-email-register-link",
353
+ method: "POST",
354
+ transformParams: (params) => ({
355
+ code: params.code
356
+ })
357
+ },
358
+ checkEmailLinkCode: {
359
+ url: "/email/link/check_code",
360
+ method: "GET",
361
+ transformParams: (params) => ({
362
+ code: params.code
363
+ })
364
+ },
365
+ sendSmsLoginCode: {
366
+ url: "/auth/send-sms-login-code",
367
+ method: "POST",
368
+ transformParams: (params) => ({
369
+ phone: String(params.phone),
370
+ country_calling_code: String(params.country_calling_code)
371
+ })
372
+ },
373
+ phoneCodeLogin: {
374
+ url: "/auth/phone-code-login",
375
+ method: "POST",
376
+ transformParams: (params) => ({
377
+ phone: String(params.phone),
378
+ country_calling_code: String(params.country_calling_code),
379
+ code: params.code
380
+ })
381
+ },
382
+ guestLogin: {
383
+ url: "/auth/guest-login",
384
+ method: "POST",
385
+ transformParams: (channel) => ({
386
+ login_channel: channel
387
+ })
388
+ },
389
+ checkEmailExists: {
390
+ url: "/auth/check-email-exists",
391
+ method: "GET",
392
+ transformParams: (params) => ({
393
+ email: params.email
394
+ })
395
+ },
396
+ checkEmailCode: {
397
+ url: "/auth/check-email-code",
398
+ method: "GET",
399
+ transformParams: (params) => ({
400
+ email: params.email,
401
+ code: params.code
402
+ })
403
+ },
404
+ checkMobileCode: {
405
+ url: "/auth/check-mobile-code",
406
+ method: "GET",
407
+ transformParams: (params) => ({
408
+ phone: String(params.phone),
409
+ code: params.code,
410
+ country_calling_code: String(params.country_calling_code)
411
+ })
412
+ },
413
+ phonePasswordLogin: {
414
+ url: "/auth/mobile-password-login",
415
+ method: "POST",
416
+ transformParams: (params) => ({
417
+ phone: String(params.phone),
418
+ password: params.password,
419
+ country_calling_code: String(params.country_calling_code)
420
+ })
421
+ },
422
+ sendPasswordResetEmail: {
423
+ url: "/auth/send-password-reset-email",
424
+ method: "GET",
425
+ transformParams: (params) => ({
426
+ email: params.email
427
+ })
428
+ },
429
+ sendPasswordResetSms: {
430
+ url: "/auth/send-password-reset-sms",
431
+ method: "POST",
432
+ transformParams: (params) => ({
433
+ phone: String(params.phone),
434
+ country_calling_code: String(params.country_calling_code)
435
+ })
436
+ },
437
+ sendResetPasswordLink: {
438
+ url: "/auth/send-reset-password-link",
439
+ method: "POST",
440
+ transformParams: (params) => ({
441
+ email: params.email
442
+ })
443
+ },
444
+ checkResetPasswordCode: {
445
+ url: "/auth/check-reset-password-code",
446
+ method: "GET",
447
+ transformParams: (params) => ({
448
+ code: params.code
449
+ })
450
+ },
451
+ resetPasswordByCode: {
452
+ url: "/auth/reset-password-by-code",
453
+ method: "GET",
454
+ transformParams: (params) => ({
455
+ code: params.code,
456
+ password: params.password
457
+ })
458
+ },
459
+ resetPasswordByEmail: {
460
+ url: "/auth/reset-password-email",
461
+ method: "POST",
462
+ transformParams: (params) => ({
463
+ email: params.email,
464
+ password: params.password,
465
+ code: params.code
466
+ })
467
+ },
468
+ resetPasswordByPhone: {
469
+ url: "/auth/reset-password-phone",
470
+ method: "POST",
471
+ transformParams: (params) => ({
472
+ phone: String(params.phone),
473
+ password: params.password,
474
+ code: params.code,
475
+ country_calling_code: String(params.country_calling_code)
476
+ })
477
+ },
478
+ verifyCode: {
479
+ url: "/auth/verify-code",
480
+ method: "POST",
481
+ transformParams: (params) => params
482
+ },
483
+ register: {
484
+ url: "/auth/register",
485
+ method: "POST",
486
+ transformParams: (params) => params
487
+ },
488
+ login: {
489
+ url: "/auth/login",
490
+ method: "POST",
491
+ transformParams: (params) => params
492
+ },
493
+ oauthLogin: {
494
+ url: "/auth/oauth-login",
495
+ method: "POST",
496
+ transformParams: (params) => params
497
+ },
498
+ validateToken: {
499
+ url: "/auth/validate",
500
+ method: "GET",
501
+ transformParams: (token) => ({}),
502
+ options: {
503
+ headers: (token) => ({
504
+ Authorization: `Bearer ${token}`
505
+ })
506
+ }
507
+ },
508
+ logout: {
509
+ url: "/auth/logout",
510
+ method: "POST",
511
+ transformParams: () => ({})
512
+ },
513
+ getCountries: {
514
+ url: "/auth/countries",
515
+ method: "GET",
516
+ transformParams: () => ({})
517
+ },
518
+ facebookLogin: {
519
+ url: "/auth/facebook/login",
520
+ method: "POST",
521
+ transformParams: (params) => ({
522
+ token: params.token
523
+ })
524
+ },
525
+ appleLogin: {
526
+ url: "/auth/apple/login",
527
+ method: "POST",
528
+ transformParams: (params) => ({
529
+ code: params.code
530
+ })
531
+ }
532
+ };
533
+ var channelConfigMap = {
534
+ "online-store": onlineStoreConfig,
535
+ "default": defaultConfig
536
+ };
537
+ function getChannelConfig(channel) {
538
+ return channelConfigMap[channel] || channelConfigMap["default"];
539
+ }
540
+ var ApiCaller = class {
541
+ constructor(request, config) {
542
+ this.request = request;
543
+ this.config = config;
544
+ }
545
+ /**
546
+ * 执行 API 调用
547
+ */
548
+ async call(apiName, params, additionalOptions) {
549
+ const apiConfig = this.config[apiName];
550
+ if (!apiConfig) {
551
+ throw new Error(`API 配置未找到: ${String(apiName)}`);
552
+ }
553
+ const transformedParams = apiConfig.transformParams ? apiConfig.transformParams(params) : params;
554
+ let requestOptions = { ...apiConfig.options, ...additionalOptions };
555
+ if (requestOptions.headers && typeof requestOptions.headers === "function") {
556
+ requestOptions.headers = requestOptions.headers(params);
557
+ }
558
+ requestOptions.customToast = () => {
559
+ };
560
+ let response;
561
+ switch (apiConfig.method) {
562
+ case "GET":
563
+ if (transformedParams && Object.keys(transformedParams).length > 0) {
564
+ response = await this.request.get(apiConfig.url, transformedParams, requestOptions);
565
+ } else {
566
+ response = await this.request.get(apiConfig.url, void 0, requestOptions);
567
+ }
568
+ break;
569
+ case "POST":
570
+ response = await this.request.post(apiConfig.url, transformedParams, requestOptions);
571
+ break;
572
+ case "PUT":
573
+ response = await this.request.put(apiConfig.url, transformedParams, requestOptions);
574
+ break;
575
+ case "DELETE":
576
+ response = await this.request.delete(apiConfig.url, requestOptions);
577
+ break;
578
+ default:
579
+ throw new Error(`不支持的 HTTP 方法: ${apiConfig.method}`);
580
+ }
581
+ return apiConfig.transformResponse ? apiConfig.transformResponse(response) : response;
582
+ }
583
+ };
584
+ function createApiCaller(request, channel) {
585
+ const config = getChannelConfig(channel);
586
+ return new ApiCaller(request, config);
587
+ }
588
+ // Annotate the CommonJS export names for ESM import in node:
589
+ 0 && (module.exports = {
590
+ ApiCaller,
591
+ channelConfigMap,
592
+ createApiCaller,
593
+ getChannelConfig
594
+ });