@pisell/pisellos 3.0.69 → 3.0.71

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,596 @@
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
+ action: params.action
162
+ })
163
+ },
164
+ phonePasswordLogin: {
165
+ url: "/auth/mobile/login",
166
+ method: "POST",
167
+ transformParams: (params) => ({
168
+ phone: String(params.phone),
169
+ password: params.password,
170
+ country_calling_code: String(params.country_calling_code)
171
+ })
172
+ },
173
+ sendPasswordResetEmail: {
174
+ url: "/auth/email/reset-password-code",
175
+ method: "GET",
176
+ transformParams: (params) => ({
177
+ email: params.email
178
+ })
179
+ },
180
+ sendPasswordResetSms: {
181
+ url: "/auth/mobile/sms-forget",
182
+ method: "POST",
183
+ transformParams: (params) => ({
184
+ phone: String(params.phone),
185
+ country_calling_code: String(params.country_calling_code)
186
+ })
187
+ },
188
+ sendResetPasswordLink: {
189
+ url: "/auth/email/link/send_reset_pwd_link",
190
+ method: "POST",
191
+ transformParams: (params) => ({
192
+ email: params.email
193
+ })
194
+ },
195
+ checkResetPasswordCode: {
196
+ url: "/auth/email/link/check_code",
197
+ method: "GET",
198
+ transformParams: (params) => ({
199
+ code: params.code
200
+ })
201
+ },
202
+ resetPasswordByCode: {
203
+ url: "/auth/email/link/reset_pwd_by_code",
204
+ method: "POST",
205
+ transformParams: (params) => ({
206
+ code: params.code,
207
+ password: params.password
208
+ })
209
+ },
210
+ resetPasswordByEmail: {
211
+ url: "/auth/email/reset-password",
212
+ method: "POST",
213
+ transformParams: (params) => ({
214
+ email: params.email,
215
+ password: params.password,
216
+ code: params.code
217
+ })
218
+ },
219
+ resetPasswordByPhone: {
220
+ url: "/auth/mobile/reset-password",
221
+ method: "POST",
222
+ transformParams: (params) => ({
223
+ phone: String(params.phone),
224
+ password: params.password,
225
+ code: params.code,
226
+ country_calling_code: String(params.country_calling_code)
227
+ })
228
+ },
229
+ verifyCode: {
230
+ url: "/auth/verify-code",
231
+ method: "POST",
232
+ transformParams: (params) => params
233
+ },
234
+ register: {
235
+ url: "/auth/register",
236
+ method: "POST",
237
+ transformParams: (params) => params
238
+ },
239
+ login: {
240
+ url: "/auth/login",
241
+ method: "POST",
242
+ transformParams: (params) => params
243
+ },
244
+ oauthLogin: {
245
+ url: "/auth/oauth-login",
246
+ method: "POST",
247
+ transformParams: (params) => params
248
+ },
249
+ validateToken: {
250
+ url: "/auth/validate",
251
+ method: "GET",
252
+ transformParams: (token) => ({}),
253
+ options: {
254
+ headers: (token) => ({
255
+ Authorization: `Bearer ${token}`
256
+ })
257
+ }
258
+ },
259
+ logout: {
260
+ url: "/auth/logout",
261
+ method: "POST",
262
+ transformParams: () => ({})
263
+ },
264
+ getCountries: {
265
+ url: "/area/country",
266
+ method: "GET",
267
+ transformParams: () => ({})
268
+ },
269
+ facebookLogin: {
270
+ url: "/auth/facebook/login",
271
+ method: "POST",
272
+ transformParams: (params) => ({
273
+ token: params.token
274
+ })
275
+ },
276
+ appleLogin: {
277
+ url: "/auth/apple/login",
278
+ method: "POST",
279
+ transformParams: (params) => ({
280
+ code: params.code
281
+ })
282
+ }
283
+ };
284
+ var defaultConfig = {
285
+ sendEmailVerificationCode: {
286
+ url: "/auth/send-email-code",
287
+ method: "POST",
288
+ transformParams: (params) => ({
289
+ email: params.target,
290
+ purpose: params.purpose,
291
+ type: params.type
292
+ })
293
+ },
294
+ sendEmailLoginCode: {
295
+ url: "/auth/send-email-code",
296
+ method: "POST",
297
+ transformParams: (params) => ({
298
+ email: params.target,
299
+ purpose: params.purpose,
300
+ type: params.type
301
+ })
302
+ },
303
+ sendSmsRegisterCode: {
304
+ url: "/auth/send-sms-register",
305
+ method: "POST",
306
+ transformParams: (params) => ({
307
+ phone: String(params.phone),
308
+ country_calling_code: String(params.country_calling_code)
309
+ })
310
+ },
311
+ sendEmailRegisterLink: {
312
+ url: "/auth/send-email-register-link",
313
+ method: "POST",
314
+ transformParams: (email) => ({
315
+ email
316
+ })
317
+ },
318
+ verifyEmailRegistrationLink: {
319
+ url: "/auth/verify-email-registration-link",
320
+ method: "POST",
321
+ transformParams: (code) => ({
322
+ code
323
+ })
324
+ },
325
+ emailPasswordLogin: {
326
+ url: "/auth/email-password-login",
327
+ method: "POST",
328
+ transformParams: (params) => ({
329
+ email: params.email,
330
+ password: params.password
331
+ })
332
+ },
333
+ emailCodeRegister: {
334
+ url: "/auth/email/register",
335
+ method: "POST",
336
+ transformParams: (params) => ({
337
+ email: params.email,
338
+ code: params.code,
339
+ password: params.password
340
+ })
341
+ },
342
+ phoneCodeRegister: {
343
+ url: "/auth/mobile/register",
344
+ method: "POST",
345
+ transformParams: (params) => ({
346
+ phone: String(params.phone),
347
+ password: params.password,
348
+ code: params.code,
349
+ country_calling_code: String(params.country_calling_code)
350
+ })
351
+ },
352
+ resendEmailRegisterLink: {
353
+ url: "/auth/resend-email-register-link",
354
+ method: "POST",
355
+ transformParams: (params) => ({
356
+ code: params.code
357
+ })
358
+ },
359
+ checkEmailLinkCode: {
360
+ url: "/email/link/check_code",
361
+ method: "GET",
362
+ transformParams: (params) => ({
363
+ code: params.code
364
+ })
365
+ },
366
+ sendSmsLoginCode: {
367
+ url: "/auth/send-sms-login-code",
368
+ method: "POST",
369
+ transformParams: (params) => ({
370
+ phone: String(params.phone),
371
+ country_calling_code: String(params.country_calling_code)
372
+ })
373
+ },
374
+ phoneCodeLogin: {
375
+ url: "/auth/phone-code-login",
376
+ method: "POST",
377
+ transformParams: (params) => ({
378
+ phone: String(params.phone),
379
+ country_calling_code: String(params.country_calling_code),
380
+ code: params.code
381
+ })
382
+ },
383
+ guestLogin: {
384
+ url: "/auth/guest-login",
385
+ method: "POST",
386
+ transformParams: (channel) => ({
387
+ login_channel: channel
388
+ })
389
+ },
390
+ checkEmailExists: {
391
+ url: "/auth/check-email-exists",
392
+ method: "GET",
393
+ transformParams: (params) => ({
394
+ email: params.email
395
+ })
396
+ },
397
+ checkEmailCode: {
398
+ url: "/auth/check-email-code",
399
+ method: "GET",
400
+ transformParams: (params) => ({
401
+ email: params.email,
402
+ code: params.code
403
+ })
404
+ },
405
+ checkMobileCode: {
406
+ url: "/auth/check-mobile-code",
407
+ method: "GET",
408
+ transformParams: (params) => ({
409
+ phone: String(params.phone),
410
+ code: params.code,
411
+ country_calling_code: String(params.country_calling_code),
412
+ action: params.action
413
+ })
414
+ },
415
+ phonePasswordLogin: {
416
+ url: "/auth/mobile-password-login",
417
+ method: "POST",
418
+ transformParams: (params) => ({
419
+ phone: String(params.phone),
420
+ password: params.password,
421
+ country_calling_code: String(params.country_calling_code)
422
+ })
423
+ },
424
+ sendPasswordResetEmail: {
425
+ url: "/auth/send-password-reset-email",
426
+ method: "GET",
427
+ transformParams: (params) => ({
428
+ email: params.email
429
+ })
430
+ },
431
+ sendPasswordResetSms: {
432
+ url: "/auth/send-password-reset-sms",
433
+ method: "POST",
434
+ transformParams: (params) => ({
435
+ phone: String(params.phone),
436
+ country_calling_code: String(params.country_calling_code)
437
+ })
438
+ },
439
+ sendResetPasswordLink: {
440
+ url: "/auth/send-reset-password-link",
441
+ method: "POST",
442
+ transformParams: (params) => ({
443
+ email: params.email
444
+ })
445
+ },
446
+ checkResetPasswordCode: {
447
+ url: "/auth/check-reset-password-code",
448
+ method: "GET",
449
+ transformParams: (params) => ({
450
+ code: params.code
451
+ })
452
+ },
453
+ resetPasswordByCode: {
454
+ url: "/auth/reset-password-by-code",
455
+ method: "GET",
456
+ transformParams: (params) => ({
457
+ code: params.code,
458
+ password: params.password
459
+ })
460
+ },
461
+ resetPasswordByEmail: {
462
+ url: "/auth/reset-password-email",
463
+ method: "POST",
464
+ transformParams: (params) => ({
465
+ email: params.email,
466
+ password: params.password,
467
+ code: params.code
468
+ })
469
+ },
470
+ resetPasswordByPhone: {
471
+ url: "/auth/reset-password-phone",
472
+ method: "POST",
473
+ transformParams: (params) => ({
474
+ phone: String(params.phone),
475
+ password: params.password,
476
+ code: params.code,
477
+ country_calling_code: String(params.country_calling_code)
478
+ })
479
+ },
480
+ verifyCode: {
481
+ url: "/auth/verify-code",
482
+ method: "POST",
483
+ transformParams: (params) => params
484
+ },
485
+ register: {
486
+ url: "/auth/register",
487
+ method: "POST",
488
+ transformParams: (params) => params
489
+ },
490
+ login: {
491
+ url: "/auth/login",
492
+ method: "POST",
493
+ transformParams: (params) => params
494
+ },
495
+ oauthLogin: {
496
+ url: "/auth/oauth-login",
497
+ method: "POST",
498
+ transformParams: (params) => params
499
+ },
500
+ validateToken: {
501
+ url: "/auth/validate",
502
+ method: "GET",
503
+ transformParams: (token) => ({}),
504
+ options: {
505
+ headers: (token) => ({
506
+ Authorization: `Bearer ${token}`
507
+ })
508
+ }
509
+ },
510
+ logout: {
511
+ url: "/auth/logout",
512
+ method: "POST",
513
+ transformParams: () => ({})
514
+ },
515
+ getCountries: {
516
+ url: "/auth/countries",
517
+ method: "GET",
518
+ transformParams: () => ({})
519
+ },
520
+ facebookLogin: {
521
+ url: "/auth/facebook/login",
522
+ method: "POST",
523
+ transformParams: (params) => ({
524
+ token: params.token
525
+ })
526
+ },
527
+ appleLogin: {
528
+ url: "/auth/apple/login",
529
+ method: "POST",
530
+ transformParams: (params) => ({
531
+ code: params.code
532
+ })
533
+ }
534
+ };
535
+ var channelConfigMap = {
536
+ "online-store": onlineStoreConfig,
537
+ "default": defaultConfig
538
+ };
539
+ function getChannelConfig(channel) {
540
+ return channelConfigMap[channel] || channelConfigMap["default"];
541
+ }
542
+ var ApiCaller = class {
543
+ constructor(request, config) {
544
+ this.request = request;
545
+ this.config = config;
546
+ }
547
+ /**
548
+ * 执行 API 调用
549
+ */
550
+ async call(apiName, params, additionalOptions) {
551
+ const apiConfig = this.config[apiName];
552
+ if (!apiConfig) {
553
+ throw new Error(`API 配置未找到: ${String(apiName)}`);
554
+ }
555
+ const transformedParams = apiConfig.transformParams ? apiConfig.transformParams(params) : params;
556
+ let requestOptions = { ...apiConfig.options, ...additionalOptions };
557
+ if (requestOptions.headers && typeof requestOptions.headers === "function") {
558
+ requestOptions.headers = requestOptions.headers(params);
559
+ }
560
+ requestOptions.customToast = () => {
561
+ };
562
+ let response;
563
+ switch (apiConfig.method) {
564
+ case "GET":
565
+ if (transformedParams && Object.keys(transformedParams).length > 0) {
566
+ response = await this.request.get(apiConfig.url, transformedParams, requestOptions);
567
+ } else {
568
+ response = await this.request.get(apiConfig.url, void 0, requestOptions);
569
+ }
570
+ break;
571
+ case "POST":
572
+ response = await this.request.post(apiConfig.url, transformedParams, requestOptions);
573
+ break;
574
+ case "PUT":
575
+ response = await this.request.put(apiConfig.url, transformedParams, requestOptions);
576
+ break;
577
+ case "DELETE":
578
+ response = await this.request.delete(apiConfig.url, requestOptions);
579
+ break;
580
+ default:
581
+ throw new Error(`不支持的 HTTP 方法: ${apiConfig.method}`);
582
+ }
583
+ return apiConfig.transformResponse ? apiConfig.transformResponse(response) : response;
584
+ }
585
+ };
586
+ function createApiCaller(request, channel) {
587
+ const config = getChannelConfig(channel);
588
+ return new ApiCaller(request, config);
589
+ }
590
+ // Annotate the CommonJS export names for ESM import in node:
591
+ 0 && (module.exports = {
592
+ ApiCaller,
593
+ channelConfigMap,
594
+ createApiCaller,
595
+ getChannelConfig
596
+ });