@ikenxuan/amagi 4.3.3 → 4.4.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.
@@ -1656,18 +1656,45 @@ var registerKuaishouRoutes = (fastify, cookie) => {
1656
1656
  };
1657
1657
 
1658
1658
  // src/model/DataFetchers.ts
1659
- var getDouyinData = async (type, cookie, options) => {
1659
+ async function getDouyinData(type, arg2, arg3) {
1660
+ let cookie;
1661
+ let options;
1662
+ if (typeof arg2 === "string") {
1663
+ cookie = arg2;
1664
+ options = arg3;
1665
+ } else {
1666
+ options = arg2;
1667
+ cookie = arg3;
1668
+ }
1660
1669
  const data2 = await DouyinData({ ...options, methodType: type }, cookie);
1661
1670
  return data2;
1662
- };
1663
- async function getBilibiliData(methodType, cookie, options) {
1671
+ }
1672
+ async function getBilibiliData(methodType, arg2, arg3) {
1673
+ let cookie;
1674
+ let options;
1675
+ if (typeof arg2 === "string") {
1676
+ cookie = arg2;
1677
+ options = arg3;
1678
+ } else {
1679
+ options = arg2;
1680
+ cookie = arg3;
1681
+ }
1664
1682
  const data2 = await BilibiliData({ ...options, methodType }, cookie);
1665
1683
  return data2;
1666
1684
  }
1667
- var getKuaishouData = async (methodType, cookie, options) => {
1685
+ async function getKuaishouData(methodType, arg2, arg3) {
1686
+ let cookie;
1687
+ let options;
1688
+ if (typeof arg2 === "string") {
1689
+ cookie = arg2;
1690
+ options = arg3;
1691
+ } else {
1692
+ options = arg2;
1693
+ cookie = arg3;
1694
+ }
1668
1695
  const data2 = await KuaishouData({ ...options, methodType }, cookie);
1669
1696
  return data2;
1670
- };
1697
+ }
1671
1698
  var fetchDouyinData = getDouyinData;
1672
1699
  var fetchBilibiliData = getBilibiliData;
1673
1700
  var fetchKuaishouData = getKuaishouData;
@@ -1644,18 +1644,45 @@ var registerKuaishouRoutes = (fastify, cookie) => {
1644
1644
  };
1645
1645
 
1646
1646
  // src/model/DataFetchers.ts
1647
- var getDouyinData = async (type, cookie, options) => {
1647
+ async function getDouyinData(type, arg2, arg3) {
1648
+ let cookie;
1649
+ let options;
1650
+ if (typeof arg2 === "string") {
1651
+ cookie = arg2;
1652
+ options = arg3;
1653
+ } else {
1654
+ options = arg2;
1655
+ cookie = arg3;
1656
+ }
1648
1657
  const data2 = await DouyinData({ ...options, methodType: type }, cookie);
1649
1658
  return data2;
1650
- };
1651
- async function getBilibiliData(methodType, cookie, options) {
1659
+ }
1660
+ async function getBilibiliData(methodType, arg2, arg3) {
1661
+ let cookie;
1662
+ let options;
1663
+ if (typeof arg2 === "string") {
1664
+ cookie = arg2;
1665
+ options = arg3;
1666
+ } else {
1667
+ options = arg2;
1668
+ cookie = arg3;
1669
+ }
1652
1670
  const data2 = await BilibiliData({ ...options, methodType }, cookie);
1653
1671
  return data2;
1654
1672
  }
1655
- var getKuaishouData = async (methodType, cookie, options) => {
1673
+ async function getKuaishouData(methodType, arg2, arg3) {
1674
+ let cookie;
1675
+ let options;
1676
+ if (typeof arg2 === "string") {
1677
+ cookie = arg2;
1678
+ options = arg3;
1679
+ } else {
1680
+ options = arg2;
1681
+ cookie = arg3;
1682
+ }
1656
1683
  const data2 = await KuaishouData({ ...options, methodType }, cookie);
1657
1684
  return data2;
1658
- };
1685
+ }
1659
1686
  var fetchDouyinData = getDouyinData;
1660
1687
  var fetchBilibiliData = getBilibiliData;
1661
1688
  var fetchKuaishouData = getKuaishouData;
package/dist/index.d.ts CHANGED
@@ -13360,6 +13360,10 @@ type OmitMethodType<T> = Omit<T, 'methodType'>;
13360
13360
  type DouyinDataOptions<T extends keyof DouyinDataOptionsMap> = OmitMethodType<DouyinDataOptionsMap[T]['opt']> & TypeControl;
13361
13361
  type BilibiliDataOptions<T extends keyof BilibiliDataOptionsMap> = OmitMethodType<BilibiliDataOptionsMap[T]['opt']> & TypeControl;
13362
13362
  type KuaishouDataOptions<T extends keyof KuaishouDataOptionsMap> = OmitMethodType<KuaishouDataOptionsMap[T]['opt']> & TypeControl;
13363
+ /** 根据 `typeMode` 定义返回类型 */
13364
+ type Fnc<T extends {
13365
+ data: any;
13366
+ }, R extends TypeControl['typeMode']> = R extends 'strict' ? T['data'] : any;
13363
13367
  /**
13364
13368
  * 类型精度控制参数
13365
13369
  */
@@ -13396,56 +13400,63 @@ type TypeControl = {
13396
13400
  * @param cookie - 有效的用户Cookie
13397
13401
  * @param options - 请求参数,是一个对象
13398
13402
  * @returns 返回接口的原始数据
13399
- * @example
13400
- * ```ts
13401
- * const data = await getDouyinData('搜索数据', 'User Cookies', {
13402
- * query: '114514',
13403
- * number: 10
13404
- * })
13405
- * ```
13406
13403
  */
13407
- declare const getDouyinData: <T extends keyof DouyinDataOptionsMap, R extends TypeControl["typeMode"]>(type: T, cookie?: string, options?: DouyinDataOptions<T> & {
13404
+ declare function getDouyinData<T extends keyof DouyinDataOptionsMap, R extends 'strict' | 'loose'>(type: T, cookie: string, options?: DouyinDataOptions<T> & {
13408
13405
  typeMode?: R;
13409
- }) => Promise<R extends "strict" ? DouyinDataOptionsMap[T]["data"] : any>;
13406
+ }): Promise<Fnc<DouyinDataOptionsMap[T], R>>;
13407
+ /**
13408
+ * 获取抖音数据
13409
+ * @param type - 请求数据类型
13410
+ * @param options - 请求参数,是一个对象
13411
+ * @param cookie - 有效的用户Cookie
13412
+ * @returns 返回接口的原始数据
13413
+ */
13414
+ declare function getDouyinData<T extends keyof DouyinDataOptionsMap, R extends 'strict' | 'loose'>(type: T, options?: DouyinDataOptions<T> & {
13415
+ typeMode?: R;
13416
+ }, cookie?: string): Promise<Fnc<DouyinDataOptionsMap[T], R>>;
13410
13417
  /**
13411
13418
  * 获取B站数据
13412
13419
  * @param type - 请求数据类型
13413
13420
  * @param cookie - 有效的用户Cookie
13414
13421
  * @param options - 请求参数,是一个对象
13415
13422
  * @returns 返回接口的原始数据
13416
- * @example
13417
- * ```ts
13418
- * const data = await getBilibiliData('单个视频作品数据', 'User Cookies', {
13419
- * bvid: 'BV1fK4y1q79u'
13420
- * })
13421
- * ```
13422
13423
  */
13423
- declare function getBilibiliData<T extends keyof BilibiliDataOptionsMap, R extends TypeControl['typeMode']>(methodType: T, cookie?: string, options?: BilibiliDataOptions<T> & {
13424
+ declare function getBilibiliData<T extends keyof BilibiliDataOptionsMap, R extends 'strict' | 'loose'>(methodType: T, cookie?: string, options?: BilibiliDataOptions<T> & {
13425
+ typeMode?: R;
13426
+ }): Promise<Fnc<BilibiliDataOptionsMap[T], R>>;
13427
+ /**
13428
+ * 获取B站数据
13429
+ * @param type - 请求数据类型
13430
+ * @param options - 请求参数,是一个对象
13431
+ * @param cookie - 有效的用户Cookie
13432
+ * @returns 返回接口的原始数据
13433
+ */
13434
+ declare function getBilibiliData<T extends keyof BilibiliDataOptionsMap, R extends 'strict' | 'loose'>(methodType: T, options?: BilibiliDataOptions<T> & {
13424
13435
  typeMode?: R;
13425
- }): Promise<R extends 'strict' ? BilibiliDataOptionsMap[T]["data"] : any>;
13436
+ }, cookie?: string): Promise<Fnc<BilibiliDataOptionsMap[T], R>>;
13426
13437
  /**
13427
13438
  * 获取快手数据
13428
13439
  * @param type - 请求数据类型
13429
13440
  * @param cookie - 有效的用户Cookie
13430
13441
  * @param options - 请求参数,是一个对象
13431
13442
  * @returns 返回接口的原始数据
13432
- * @example
13433
- * ```ts
13434
- * const data = await getKuaishouData('单个视频作品数据', 'User Cookies', {
13435
- * photoId: '3xdpv6sfi8yjsqy'
13436
- * })
13437
- * ```
13438
13443
  */
13439
- declare const getKuaishouData: <T extends keyof KuaishouDataOptionsMap, R extends TypeControl["typeMode"]>(methodType: T, cookie?: string, options?: KuaishouDataOptions<T> & {
13444
+ declare function getKuaishouData<T extends keyof KuaishouDataOptionsMap, R extends 'strict' | 'loose'>(methodType: T, cookie?: string, options?: KuaishouDataOptions<T> & {
13440
13445
  typeMode?: R;
13441
- }) => Promise<R extends "strict" ? KuaishouDataOptionsMap[T]["data"] : any>;
13442
- declare const fetchDouyinData: <T extends keyof DouyinDataOptionsMap, R extends TypeControl["typeMode"]>(type: T, cookie?: string, options?: DouyinDataOptions<T> & {
13446
+ }): Promise<Fnc<KuaishouDataOptionsMap[T], R>>;
13447
+ /**
13448
+ * 获取快手数据
13449
+ * @param type - 请求数据类型
13450
+ * @param options - 请求参数,是一个对象
13451
+ * @param cookie - 有效的用户Cookie
13452
+ * @returns 返回接口的原始数据
13453
+ */
13454
+ declare function getKuaishouData<T extends keyof KuaishouDataOptionsMap, R extends 'strict' | 'loose'>(methodType: T, options?: KuaishouDataOptions<T> & {
13443
13455
  typeMode?: R;
13444
- }) => Promise<R extends "strict" ? DouyinDataOptionsMap[T]["data"] : any>;
13456
+ }, cookie?: string): Promise<Fnc<KuaishouDataOptionsMap[T], R>>;
13457
+ declare const fetchDouyinData: typeof getDouyinData;
13445
13458
  declare const fetchBilibiliData: typeof getBilibiliData;
13446
- declare const fetchKuaishouData: <T extends keyof KuaishouDataOptionsMap, R extends TypeControl["typeMode"]>(methodType: T, cookie?: string, options?: KuaishouDataOptions<T> & {
13447
- typeMode?: R;
13448
- }) => Promise<R extends "strict" ? KuaishouDataOptionsMap[T]["data"] : any>;
13459
+ declare const fetchKuaishouData: typeof getKuaishouData;
13449
13460
 
13450
13461
  declare class CustomLogger {
13451
13462
  private logger;
@@ -13704,9 +13715,9 @@ declare class amagi {
13704
13715
  * })
13705
13716
  * ```
13706
13717
  */
13707
- getDouyinData: <T extends keyof DouyinDataOptionsMap, R extends TypeControl["typeMode"]>(methodType: T, options?: DouyinDataOptions<T> & {
13718
+ getDouyinData: <T extends keyof DouyinDataOptionsMap, R extends "strict" | "loose">(methodType: T, options?: DouyinDataOptions<T> & {
13708
13719
  typeMode?: R;
13709
- }) => Promise<R extends "strict" ? DouyinDataOptionsMap[T]["data"] : any>;
13720
+ }) => Promise<Fnc<DouyinDataOptionsMap[T], R>>;
13710
13721
  /**
13711
13722
  * 获取B站数据
13712
13723
  * @param type - 请求数据类型
@@ -13724,9 +13735,9 @@ declare class amagi {
13724
13735
  * })
13725
13736
  * ```
13726
13737
  */
13727
- getBilibiliData: <T extends keyof BilibiliDataOptionsMap, R extends TypeControl["typeMode"]>(methodType: T, options?: BilibiliDataOptions<T> & {
13738
+ getBilibiliData: <T extends keyof BilibiliDataOptionsMap, R extends "strict" | "loose">(methodType: T, options?: BilibiliDataOptions<T> & {
13728
13739
  typeMode?: R;
13729
- }) => Promise<R extends "strict" ? BilibiliDataOptionsMap[T]["data"] : any>;
13740
+ }) => Promise<Fnc<BilibiliDataOptionsMap[T], R>>;
13730
13741
  /**
13731
13742
  * 获取快手数据
13732
13743
  * @param type - 请求数据类型
@@ -13744,9 +13755,9 @@ declare class amagi {
13744
13755
  * })
13745
13756
  * ```
13746
13757
  */
13747
- getKuaishouData: <T extends keyof KuaishouDataOptionsMap, R extends TypeControl["typeMode"]>(methodType: T, options?: KuaishouDataOptions<T> & {
13758
+ getKuaishouData: <T extends keyof KuaishouDataOptionsMap, R extends "strict" | "loose">(methodType: T, options?: KuaishouDataOptions<T> & {
13748
13759
  typeMode?: R;
13749
- }) => Promise<R extends "strict" ? KuaishouDataOptionsMap[T]["data"] : any>;
13760
+ }) => Promise<Fnc<KuaishouDataOptionsMap[T], R>>;
13750
13761
  }
13751
13762
 
13752
13763
  /**
@@ -13759,4 +13770,4 @@ declare const startClient: (client: FastifyInstance, port: 4567) => void;
13759
13770
 
13760
13771
  declare function Amagi(options: ckParams): amagi;
13761
13772
 
13762
- export { Amagi, BilibiliData, type BilibiliDataOptions, type BilibiliDataOptionsMap, type BilibiliMethodOptionsMap, DouyinData, type DouyinDataOptions, type DouyinDataOptionsMap, type DouyinMethodOptionsMap, KuaishouAPI, KuaishouData, type KuaishouDataOptions, type KuaishouDataOptionsMap, Networks, type NetworksConfigType, type OmitMethodType, type TypeControl, amagi, av2bv, bilibiliAPI, bv2av, type ckParams, amagi as default, douyinAPI, douyinSign, fetchBilibiliData, fetchDouyinData, fetchKuaishouData, getBilibiliData, getDouyinData, getKuaishouData, logger, qtparam, registerBilibiliRoutes, registerDouyinRoutes, registerKuaishouRoutes, startClient, validateData, wbi_sign };
13773
+ export { Amagi, BilibiliData, type BilibiliDataOptions, type BilibiliDataOptionsMap, type BilibiliMethodOptionsMap, DouyinData, type DouyinDataOptions, type DouyinDataOptionsMap, type DouyinMethodOptionsMap, type Fnc, KuaishouAPI, KuaishouData, type KuaishouDataOptions, type KuaishouDataOptionsMap, Networks, type NetworksConfigType, type OmitMethodType, type TypeControl, amagi, av2bv, bilibiliAPI, bv2av, type ckParams, amagi as default, douyinAPI, douyinSign, fetchBilibiliData, fetchDouyinData, fetchKuaishouData, getBilibiliData, getDouyinData, getKuaishouData, logger, qtparam, registerBilibiliRoutes, registerDouyinRoutes, registerKuaishouRoutes, startClient, validateData, wbi_sign };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ikenxuan/amagi",
3
- "version": "4.3.3",
3
+ "version": "4.4.0",
4
4
  "description": "抖音、B站的 web 端相关数据接口基于 Node.js 的实现",
5
5
  "keywords": [
6
6
  "douyin",