@kevisual/cnb 0.0.65 → 0.0.67

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/routes.d.ts CHANGED
@@ -369,7 +369,8 @@ declare class Repo extends CNBCore {
369
369
  path?: string;
370
370
  size?: number;
371
371
  }): Promise<any>;
372
- getCommitList(repo: string, params: {
372
+ getLastCommit(repo: string, opts?: RequestOptions): Promise<Result<CommitInfo>>;
373
+ getCommitList(repo: string, params?: {
373
374
  author?: string;
374
375
  commiter?: string;
375
376
  page?: number;
@@ -377,7 +378,7 @@ declare class Repo extends CNBCore {
377
378
  sha?: string;
378
379
  since?: string;
379
380
  until?: string;
380
- }, opts?: RequestOptions): Promise<any>;
381
+ }, opts?: RequestOptions): Promise<Result<CommitInfo[]>>;
381
382
  getRepoList(params: {
382
383
  desc?: boolean;
383
384
  filter_type?: 'private' | 'public' | 'secret';
@@ -460,6 +461,46 @@ type RepoItem = {
460
461
  pinned: boolean;
461
462
  pinned_time: string;
462
463
  };
464
+ type CommitInfo = {
465
+ sha: string;
466
+ commit: {
467
+ author?: {
468
+ name: string;
469
+ email: string;
470
+ date: string;
471
+ };
472
+ committer: {
473
+ name: string;
474
+ email: string;
475
+ date: string;
476
+ };
477
+ message: string;
478
+ tree: {
479
+ sha: string;
480
+ };
481
+ comment_count: number;
482
+ verification: {
483
+ verified: boolean;
484
+ reason: string;
485
+ signature: string;
486
+ payload: string;
487
+ verified_at: string;
488
+ };
489
+ };
490
+ author: {
491
+ nickname: string;
492
+ email: string;
493
+ is_npc: boolean;
494
+ };
495
+ committer: {
496
+ nickname: string;
497
+ email: string;
498
+ is_npc: boolean;
499
+ };
500
+ parents: {
501
+ sha: string;
502
+ }[];
503
+ };
463
504
 
464
505
  declare class User extends CNBCore {
465
506
  constructor(options: CNBCoreOptions<{}>);
@@ -467,7 +508,7 @@ declare class User extends CNBCore {
467
508
  * 获取当前用户信息,使用 Cookie 认证
468
509
  * @returns
469
510
  */
470
- getCurrentUser(): Promise<Result$2<UserInfo>>;
511
+ getCurrentUser(): Promise<Result$2<UserInfo$1>>;
471
512
  /**
472
513
  * 判断当前 Cookie 是否有效
473
514
  * @returns
@@ -477,7 +518,7 @@ declare class User extends CNBCore {
477
518
  * 使用 Token 获取用户信息
478
519
  * @returns
479
520
  */
480
- getUser(): Promise<Result$2<UserInfo>>;
521
+ getUser(): Promise<Result$2<UserInfo$1>>;
481
522
  createAccessToken(data?: {
482
523
  description?: string;
483
524
  scope?: string;
@@ -492,7 +533,7 @@ type AccessTokenResponse = {
492
533
  token: string;
493
534
  description: string;
494
535
  };
495
- type UserInfo = {
536
+ type UserInfo$1 = {
496
537
  id: string;
497
538
  username: string;
498
539
  nickname: string;
@@ -1741,6 +1782,208 @@ declare class Organization extends CNBCore {
1741
1782
  }): Promise<Result$2<OrganizationUnion[]>>;
1742
1783
  }
1743
1784
 
1785
+ type UserInfo = {
1786
+ /** 用户登录名 */
1787
+ login: string;
1788
+ /** 用户 ID */
1789
+ id: string;
1790
+ /** 用户头像 URL */
1791
+ avatar_url: string;
1792
+ };
1793
+ type ReleaseAsset = {
1794
+ /** 附件唯一标识符 */
1795
+ id: string;
1796
+ /** 附件名称 */
1797
+ name: string;
1798
+ /** 附件路径 */
1799
+ path: string;
1800
+ /** 附件大小(字节) */
1801
+ size: number;
1802
+ /** 附件内容类型 */
1803
+ content_type: string;
1804
+ /** 下载次数 */
1805
+ download_count: number;
1806
+ /** 附件哈希算法 */
1807
+ hash_algo: string;
1808
+ /** 附件哈希值 */
1809
+ hash_value: string;
1810
+ /** API 下载 URL(通过 API 域名,用于程序化下载) */
1811
+ url: string;
1812
+ /** 浏览器下载 URL(通过主域名,用于用户直接访问) */
1813
+ brower_download_url: string;
1814
+ /** 附件上传者信息 */
1815
+ uploader: UserInfo;
1816
+ /** 创建时间 */
1817
+ created_at: string;
1818
+ /** 更新时间 */
1819
+ updated_at: string;
1820
+ };
1821
+ type ReleaseItem = {
1822
+ /** 版本唯一标识符 */
1823
+ id: string;
1824
+ /** 版本标题 */
1825
+ name: string;
1826
+ /** 标签名称 */
1827
+ tag_name: string;
1828
+ /** 标签与提交标识符 */
1829
+ tag_commitish: string;
1830
+ /** 版本描述 */
1831
+ body: string;
1832
+ /** 是否为草稿版本 */
1833
+ draft: boolean;
1834
+ /** 是否为预发布版本 */
1835
+ prerelease: boolean;
1836
+ /** 是否为最新版本 */
1837
+ is_latest: boolean;
1838
+ /** 作者信息 */
1839
+ author: UserInfo;
1840
+ /** 附件列表 */
1841
+ assets: ReleaseAsset[];
1842
+ /** 创建时间 */
1843
+ created_at: string;
1844
+ /** 版本发布时间 */
1845
+ published_at: string;
1846
+ /** 更新时间 */
1847
+ updated_at: string;
1848
+ };
1849
+ type PostReleaseForm = {
1850
+ /** 标签名称 */
1851
+ tag_name: string;
1852
+ /** 目标提交哈希或分支名称 */
1853
+ target_commitish?: string;
1854
+ /** 版本标题 */
1855
+ name?: string;
1856
+ /** 版本描述 */
1857
+ body?: string;
1858
+ /** 是否为草稿版本 */
1859
+ draft?: boolean;
1860
+ /** 是否为预发布版本 */
1861
+ prerelease?: boolean;
1862
+ /** 是否设置为最新版本。可选值:`true`, `false`, `legacy` */
1863
+ make_latest?: string;
1864
+ };
1865
+ type PatchReleaseForm = {
1866
+ /** 版本标题 */
1867
+ name?: string;
1868
+ /** 版本描述 */
1869
+ body?: string;
1870
+ /** 是否为草稿版本 */
1871
+ draft?: boolean;
1872
+ /** 是否为预发布版本 */
1873
+ prerelease?: boolean;
1874
+ /** 是否设置为最新版本。可选值:`true`, `false`, `legacy` */
1875
+ make_latest?: string;
1876
+ };
1877
+ type PostReleaseAssetUploadURLForm = {
1878
+ /** 附件名称 */
1879
+ asset_name: string;
1880
+ /** 附件大小,单位为字节 */
1881
+ size: number;
1882
+ /** 附件存在时间,单位为天 */
1883
+ ttl?: number;
1884
+ /** 是否覆盖同名附件 */
1885
+ overwrite?: boolean;
1886
+ };
1887
+ type ReleaseAssetUploadURL = {
1888
+ /** 附件上传 URL */
1889
+ upload_url: string;
1890
+ /** 附件上传确认验证 URL */
1891
+ verify_url: string;
1892
+ /** URL 过期时间,单位为秒 */
1893
+ expires_in_sec: number;
1894
+ };
1895
+ type ListReleasesParams = {
1896
+ /** 分页页码,默认 1 */
1897
+ page?: number;
1898
+ /** 分页页大小,默认 10 */
1899
+ page_size?: number;
1900
+ query?: string;
1901
+ };
1902
+ declare class Release extends CNBCore {
1903
+ constructor(options: CNBCoreOptions);
1904
+ /**
1905
+ * 查询 release 列表
1906
+ * @param repo 仓库路径
1907
+ * @param params 分页参数
1908
+ */
1909
+ list(repo: string, params?: ListReleasesParams): Promise<Result$2<ReleaseItem[]>>;
1910
+ /**
1911
+ * 新增一个 release
1912
+ * @param repo 仓库路径
1913
+ * @param data 创建表单
1914
+ */
1915
+ create(repo: string, data: PostReleaseForm): Promise<Result$2<ReleaseItem>>;
1916
+ /**
1917
+ * 查询最新的 release
1918
+ * @param repo 仓库路径
1919
+ */
1920
+ getLatest(repo: string): Promise<Result$2<ReleaseItem>>;
1921
+ /**
1922
+ * 通过 tag 查询指定 release,包含附件信息
1923
+ * @param repo 仓库路径
1924
+ * @param tag 标签名称
1925
+ */
1926
+ getByTag(repo: string, tag: string): Promise<Result$2<ReleaseItem>>;
1927
+ /**
1928
+ * 根据 id 查询指定 release,包含附件信息
1929
+ * @param repo 仓库路径
1930
+ * @param releaseId 版本唯一标识符
1931
+ */
1932
+ getById(repo: string, releaseId: string): Promise<Result$2<ReleaseItem>>;
1933
+ /**
1934
+ * 更新 release
1935
+ * @param repo 仓库路径
1936
+ * @param releaseId 版本唯一标识符
1937
+ * @param data 更新表单
1938
+ */
1939
+ update(repo: string, releaseId: string, data: PatchReleaseForm): Promise<Result$2<any>>;
1940
+ /**
1941
+ * 删除指定的 release
1942
+ * @param repo 仓库路径
1943
+ * @param releaseId 版本唯一标识符
1944
+ */
1945
+ deleteRelease(repo: string, releaseId: string): Promise<Result$2<any>>;
1946
+ /**
1947
+ * 获取 release 附件上传 URL
1948
+ * @param repo 仓库路径
1949
+ * @param releaseId 版本唯一标识符
1950
+ * @param data 附件上传表单
1951
+ */
1952
+ getAssetUploadURL(repo: string, releaseId: string, data: PostReleaseAssetUploadURLForm): Promise<Result$2<ReleaseAssetUploadURL>>;
1953
+ /**
1954
+ * 确认 release 附件上传完成
1955
+ * @param repo 仓库路径
1956
+ * @param releaseId 版本唯一标识符
1957
+ * @param uploadToken verify_url 字段提取的 upload_token
1958
+ * @param assetPath verify_url 字段提取的 asset_path
1959
+ * @param ttl 附件保持的天数(0 表示永久,最大 180)
1960
+ */
1961
+ confirmAssetUpload(repo: string, releaseId: string, uploadToken: string, assetPath: string, ttl?: number): Promise<Result$2<any>>;
1962
+ verifyUrlAsstetupload(url: string): Promise<Result$2<any>>;
1963
+ /**
1964
+ * 查询指定的 release 附件
1965
+ * @param repo 仓库路径
1966
+ * @param releaseId 版本唯一标识符
1967
+ * @param assetId 附件唯一标识符
1968
+ */
1969
+ getAsset(repo: string, releaseId: string, assetId: string): Promise<Result$2<ReleaseAsset>>;
1970
+ /**
1971
+ * 删除指定的 release 附件
1972
+ * @param repo 仓库路径
1973
+ * @param releaseId 版本唯一标识符
1974
+ * @param assetId 附件唯一标识符
1975
+ */
1976
+ deleteAsset(repo: string, releaseId: string, assetId: string): Promise<Result$2<any>>;
1977
+ /**
1978
+ * 获取 release 附件下载地址(302 重定向)
1979
+ * @param repo 仓库路径
1980
+ * @param tag 标签名称
1981
+ * @param filename 文件名称
1982
+ * @param share 是否生成可分享的下载地址(有效期 12 小时,最多下载 10 次)
1983
+ */
1984
+ getAssetDownloadURL(repo: string, tag: string, filename: string, share?: boolean): string;
1985
+ }
1986
+
1744
1987
  type CNBOptions = CNBCoreOptions<{}>;
1745
1988
  declare class CNB extends CNBCore {
1746
1989
  workspace: Workspace;
@@ -1761,6 +2004,7 @@ declare class CNB extends CNBCore {
1761
2004
  };
1762
2005
  org: Organization;
1763
2006
  dashboard: Dashboard;
2007
+ release: Release;
1764
2008
  constructor(options: CNBOptions);
1765
2009
  init(cnbOptions?: CNBOptions): void;
1766
2010
  setToken(token: string): void;