@ikenxuan/amagi 4.3.2 → 4.3.3

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.
@@ -1283,7 +1283,7 @@ var DouyinData = async (data2, cookie) => {
1283
1283
  const url = douyinAPI.\u641C\u7D22({
1284
1284
  query: data2.query,
1285
1285
  number: requestCount,
1286
- search_id: search_id === "" ? undefined : search_id
1286
+ search_id: search_id === "" ? void 0 : search_id
1287
1287
  });
1288
1288
  const response = await GlobalGetData2({
1289
1289
  url: `${url}&a_bogus=${douyinSign.AB(url)}`,
@@ -1771,7 +1771,7 @@ var Networks = class {
1771
1771
  this.data = {};
1772
1772
  this.timeout = data2.timeout ?? 15e3;
1773
1773
  this.isGetResult = false;
1774
- this.timer = undefined;
1774
+ this.timer = void 0;
1775
1775
  this.axiosInstance = axios__default.default.create({
1776
1776
  timeout: this.timeout,
1777
1777
  headers: this.headers,
@@ -1902,9 +1902,9 @@ var amagi = class {
1902
1902
  * @param cookie - 包含抖音ck、B站ck、快手ck的对象
1903
1903
  */
1904
1904
  constructor(data2) {
1905
- this.douyin = (data2 == null ? undefined : data2.douyin) ?? "";
1906
- this.bilibili = (data2 == null ? undefined : data2.bilibili) ?? "";
1907
- this.kuaishou = (data2 == null ? undefined : data2.kuaishou) ?? "";
1905
+ this.douyin = (data2 == null ? void 0 : data2.douyin) ?? "";
1906
+ this.bilibili = (data2 == null ? void 0 : data2.bilibili) ?? "";
1907
+ this.kuaishou = (data2 == null ? void 0 : data2.kuaishou) ?? "";
1908
1908
  }
1909
1909
  /**
1910
1910
  * 启动本地http服务
@@ -1271,7 +1271,7 @@ var DouyinData = async (data2, cookie) => {
1271
1271
  const url = douyinAPI.\u641C\u7D22({
1272
1272
  query: data2.query,
1273
1273
  number: requestCount,
1274
- search_id: search_id === "" ? undefined : search_id
1274
+ search_id: search_id === "" ? void 0 : search_id
1275
1275
  });
1276
1276
  const response = await GlobalGetData2({
1277
1277
  url: `${url}&a_bogus=${douyinSign.AB(url)}`,
@@ -1759,7 +1759,7 @@ var Networks = class {
1759
1759
  this.data = {};
1760
1760
  this.timeout = data2.timeout ?? 15e3;
1761
1761
  this.isGetResult = false;
1762
- this.timer = undefined;
1762
+ this.timer = void 0;
1763
1763
  this.axiosInstance = axios.create({
1764
1764
  timeout: this.timeout,
1765
1765
  headers: this.headers,
@@ -1890,9 +1890,9 @@ var amagi = class {
1890
1890
  * @param cookie - 包含抖音ck、B站ck、快手ck的对象
1891
1891
  */
1892
1892
  constructor(data2) {
1893
- this.douyin = (data2 == null ? undefined : data2.douyin) ?? "";
1894
- this.bilibili = (data2 == null ? undefined : data2.bilibili) ?? "";
1895
- this.kuaishou = (data2 == null ? undefined : data2.kuaishou) ?? "";
1893
+ this.douyin = (data2 == null ? void 0 : data2.douyin) ?? "";
1894
+ this.bilibili = (data2 == null ? void 0 : data2.bilibili) ?? "";
1895
+ this.kuaishou = (data2 == null ? void 0 : data2.kuaishou) ?? "";
1896
1896
  }
1897
1897
  /**
1898
1898
  * 启动本地http服务
package/dist/index.d.ts CHANGED
@@ -13357,9 +13357,38 @@ type NetworksConfigType = {
13357
13357
 
13358
13358
  /** 定义一个泛型类型 OmitMethodType<T>,从类型 T 中排除 'methodType' 属性 */
13359
13359
  type OmitMethodType<T> = Omit<T, 'methodType'>;
13360
- type DouyinDataOptions<T extends keyof DouyinDataOptionsMap> = OmitMethodType<DouyinDataOptionsMap[T]['opt']>;
13361
- type BilibiliDataOptions<T extends keyof BilibiliDataOptionsMap> = OmitMethodType<BilibiliDataOptionsMap[T]['opt']>;
13362
- type KuaishouDataOptions<T extends keyof KuaishouDataOptionsMap> = OmitMethodType<KuaishouDataOptionsMap[T]['opt']>;
13360
+ type DouyinDataOptions<T extends keyof DouyinDataOptionsMap> = OmitMethodType<DouyinDataOptionsMap[T]['opt']> & TypeControl;
13361
+ type BilibiliDataOptions<T extends keyof BilibiliDataOptionsMap> = OmitMethodType<BilibiliDataOptionsMap[T]['opt']> & TypeControl;
13362
+ type KuaishouDataOptions<T extends keyof KuaishouDataOptionsMap> = OmitMethodType<KuaishouDataOptionsMap[T]['opt']> & TypeControl;
13363
+ /**
13364
+ * 类型精度控制参数
13365
+ */
13366
+ type TypeControl = {
13367
+ /**
13368
+ * 获取返回类型
13369
+ * 类型定义时间:2025-02-02
13370
+ *
13371
+ * 类型解析模式:
13372
+ * - `strict`: 返回严格类型(基于接口响应定义,随时间推移可能缺少未声明的字段)
13373
+ * - `loose` 或 `未指定`: 返回宽松的 any 类型(默认)
13374
+ *
13375
+ * @default 'loose'
13376
+ * @example
13377
+ * ```ts
13378
+ * // 严格模式
13379
+ * const data = await amagi.getDouyinData('视频作品数据', {
13380
+ * aweme_id: '123',
13381
+ * typeMode: 'strict' // 返回精确的 VideoWork 类型
13382
+ * });
13383
+ *
13384
+ * // 宽松模式
13385
+ * const data = await amagi.getDouyinData('视频作品数据', {
13386
+ * aweme_id: '123' // 返回 any 类型
13387
+ * });
13388
+ * ```
13389
+ */
13390
+ typeMode?: 'strict' | 'loose';
13391
+ };
13363
13392
 
13364
13393
  /**
13365
13394
  * 获取抖音数据
@@ -13375,7 +13404,9 @@ type KuaishouDataOptions<T extends keyof KuaishouDataOptionsMap> = OmitMethodTyp
13375
13404
  * })
13376
13405
  * ```
13377
13406
  */
13378
- declare const getDouyinData: <T extends keyof DouyinDataOptionsMap>(type: T, cookie?: string, options?: DouyinDataOptions<T>) => Promise<DouyinDataOptionsMap[T]["data"]>;
13407
+ declare const getDouyinData: <T extends keyof DouyinDataOptionsMap, R extends TypeControl["typeMode"]>(type: T, cookie?: string, options?: DouyinDataOptions<T> & {
13408
+ typeMode?: R;
13409
+ }) => Promise<R extends "strict" ? DouyinDataOptionsMap[T]["data"] : any>;
13379
13410
  /**
13380
13411
  * 获取B站数据
13381
13412
  * @param type - 请求数据类型
@@ -13389,7 +13420,9 @@ declare const getDouyinData: <T extends keyof DouyinDataOptionsMap>(type: T, coo
13389
13420
  * })
13390
13421
  * ```
13391
13422
  */
13392
- declare function getBilibiliData<T extends keyof BilibiliDataOptionsMap>(methodType: T, cookie?: string, options?: BilibiliDataOptions<T>): Promise<BilibiliDataOptionsMap[T]['data']>;
13423
+ declare function getBilibiliData<T extends keyof BilibiliDataOptionsMap, R extends TypeControl['typeMode']>(methodType: T, cookie?: string, options?: BilibiliDataOptions<T> & {
13424
+ typeMode?: R;
13425
+ }): Promise<R extends 'strict' ? BilibiliDataOptionsMap[T]["data"] : any>;
13393
13426
  /**
13394
13427
  * 获取快手数据
13395
13428
  * @param type - 请求数据类型
@@ -13403,10 +13436,16 @@ declare function getBilibiliData<T extends keyof BilibiliDataOptionsMap>(methodT
13403
13436
  * })
13404
13437
  * ```
13405
13438
  */
13406
- declare const getKuaishouData: <T extends keyof KuaishouDataOptionsMap>(methodType: T, cookie?: string, options?: KuaishouDataOptions<T>) => Promise<KuaishouDataOptionsMap[T]["data"]>;
13407
- declare const fetchDouyinData: <T extends keyof DouyinDataOptionsMap>(type: T, cookie?: string, options?: DouyinDataOptions<T>) => Promise<DouyinDataOptionsMap[T]["data"]>;
13439
+ declare const getKuaishouData: <T extends keyof KuaishouDataOptionsMap, R extends TypeControl["typeMode"]>(methodType: T, cookie?: string, options?: KuaishouDataOptions<T> & {
13440
+ 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> & {
13443
+ typeMode?: R;
13444
+ }) => Promise<R extends "strict" ? DouyinDataOptionsMap[T]["data"] : any>;
13408
13445
  declare const fetchBilibiliData: typeof getBilibiliData;
13409
- declare const fetchKuaishouData: <T extends keyof KuaishouDataOptionsMap>(methodType: T, cookie?: string, options?: KuaishouDataOptions<T>) => Promise<KuaishouDataOptionsMap[T]["data"]>;
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>;
13410
13449
 
13411
13450
  declare class CustomLogger {
13412
13451
  private logger;
@@ -13665,7 +13704,9 @@ declare class amagi {
13665
13704
  * })
13666
13705
  * ```
13667
13706
  */
13668
- getDouyinData: <T extends keyof DouyinDataOptionsMap = keyof DouyinDataOptionsMap>(methodType: T, options?: DouyinDataOptions<T>) => Promise<DouyinDataOptionsMap[T]["data"]>;
13707
+ getDouyinData: <T extends keyof DouyinDataOptionsMap, R extends TypeControl["typeMode"]>(methodType: T, options?: DouyinDataOptions<T> & {
13708
+ typeMode?: R;
13709
+ }) => Promise<R extends "strict" ? DouyinDataOptionsMap[T]["data"] : any>;
13669
13710
  /**
13670
13711
  * 获取B站数据
13671
13712
  * @param type - 请求数据类型
@@ -13683,7 +13724,9 @@ declare class amagi {
13683
13724
  * })
13684
13725
  * ```
13685
13726
  */
13686
- getBilibiliData: <T extends keyof BilibiliDataOptionsMap = keyof BilibiliDataOptionsMap>(methodType: T, options?: BilibiliDataOptions<T>) => Promise<BilibiliDataOptionsMap[T]["data"]>;
13727
+ getBilibiliData: <T extends keyof BilibiliDataOptionsMap, R extends TypeControl["typeMode"]>(methodType: T, options?: BilibiliDataOptions<T> & {
13728
+ typeMode?: R;
13729
+ }) => Promise<R extends "strict" ? BilibiliDataOptionsMap[T]["data"] : any>;
13687
13730
  /**
13688
13731
  * 获取快手数据
13689
13732
  * @param type - 请求数据类型
@@ -13701,7 +13744,9 @@ declare class amagi {
13701
13744
  * })
13702
13745
  * ```
13703
13746
  */
13704
- getKuaishouData: <T extends keyof KuaishouDataOptionsMap = keyof KuaishouDataOptionsMap>(methodType: T, options?: KuaishouDataOptions<T>) => Promise<KuaishouDataOptionsMap[T]["data"]>;
13747
+ getKuaishouData: <T extends keyof KuaishouDataOptionsMap, R extends TypeControl["typeMode"]>(methodType: T, options?: KuaishouDataOptions<T> & {
13748
+ typeMode?: R;
13749
+ }) => Promise<R extends "strict" ? KuaishouDataOptionsMap[T]["data"] : any>;
13705
13750
  }
13706
13751
 
13707
13752
  /**
@@ -13714,4 +13759,4 @@ declare const startClient: (client: FastifyInstance, port: 4567) => void;
13714
13759
 
13715
13760
  declare function Amagi(options: ckParams): amagi;
13716
13761
 
13717
- 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, 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 };
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 };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ikenxuan/amagi",
3
- "version": "4.3.2",
3
+ "version": "4.3.3",
4
4
  "description": "抖音、B站的 web 端相关数据接口基于 Node.js 的实现",
5
5
  "keywords": [
6
6
  "douyin",
@@ -31,7 +31,7 @@
31
31
  },
32
32
  "main": "dist/cjs/index.cjs",
33
33
  "module": "dist/esm/index.mjs",
34
- "types": "dist/esm/index.d.ts",
34
+ "types": "dist/index.d.ts",
35
35
  "files": [
36
36
  "dist/*",
37
37
  "LICENSE",