mobx-lark 2.6.0 → 2.6.1

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/type.d.ts CHANGED
@@ -29,4 +29,7 @@ export interface JSTicket {
29
29
  export type I18nKey = `${string}_${string}`;
30
30
  export type TranslationMap = Record<I18nKey, string>;
31
31
  export type LarkDocumentType = `doc${'' | 'x'}` | 'mindnote' | 'sheet' | 'bitable' | 'slides' | 'file';
32
+ export type LarkDocumentPathType = `doc${'' | 'x'}` | 'mindnote' | 'sheets' | 'base' | 'slides' | 'file';
33
+ export declare const LarkDocumentPathTypeMap: Record<LarkDocumentType, LarkDocumentPathType>;
34
+ export declare const getLarkDocumentType: (path: LarkDocumentPathType) => LarkDocumentType;
32
35
  export type UploadTargetType = 'doc_image' | 'docx_image' | 'sheet_image' | 'doc_file' | 'docx_file' | 'sheet_file' | 'vc_virtual_background' | 'bitable_image' | 'bitable_file' | 'moments' | 'ccm_import_open';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "mobx-lark",
3
- "version": "2.6.0",
3
+ "version": "2.6.1",
4
4
  "license": "LGPL-3.0",
5
5
  "author": "shiy2008@gmail.com",
6
6
  "description": "Unofficial TypeScript SDK for FeiShu/Lark API, which is based on MobX-RESTful.",
package/src/Lark.ts CHANGED
@@ -10,9 +10,11 @@ import {
10
10
  WikiNodeModel
11
11
  } from './module';
12
12
  import {
13
+ getLarkDocumentType,
13
14
  isLarkError,
14
15
  JSTicket,
15
16
  LarkData,
17
+ LarkDocumentPathType,
16
18
  LarkDocumentType,
17
19
  TenantAccessToken,
18
20
  UploadTargetType,
@@ -204,7 +206,7 @@ export class LarkApp implements LarkAppOption {
204
206
  user_id_type?: UserIdType
205
207
  ): Promise<WikiNode>;
206
208
  copyFile(
207
- URI: `${string}${LarkDocumentType}/${string}`,
209
+ URI: `${string}${LarkDocumentPathType}/${string}`,
208
210
  name?: string,
209
211
  folder_token?: string,
210
212
  user_id_type?: UserIdType
@@ -223,6 +225,9 @@ export class LarkApp implements LarkAppOption {
223
225
  space_id,
224
226
  parent_node_token
225
227
  } = await this.wiki2drive(token));
228
+ else {
229
+ type = getLarkDocumentType(type as LarkDocumentPathType);
230
+ }
226
231
 
227
232
  const copidFile = await this.driveFileStore.copyOne(
228
233
  type as LarkDocumentType,
@@ -2,7 +2,7 @@ import { makeFormData } from 'koajax';
2
2
  import { BaseListModel, RESTClient, toggle } from 'mobx-restful';
3
3
  import { buildURLData, splitArray } from 'web-utility';
4
4
 
5
- import { LarkData, LarkDocumentType, UploadTargetType } from '../../type';
5
+ import { LarkData, LarkDocumentPathTypeMap, LarkDocumentType, UploadTargetType } from '../../type';
6
6
  import { UserIdType } from '../User/type';
7
7
  import { CopiedFile, DriveFile } from './type';
8
8
 
@@ -94,7 +94,9 @@ export abstract class DriveFileModel extends BaseListModel<DriveFile> {
94
94
  folder_token?: string,
95
95
  user_id_type?: UserIdType
96
96
  ) {
97
- name ||= (await this.getOne(`${type}/${file_token}`, user_id_type)).title + ' (copy)';
97
+ name ||=
98
+ (await this.getOne(`${LarkDocumentPathTypeMap[type]}/${file_token}`, user_id_type))
99
+ .title + ' (copy)';
98
100
  folder_token ||= (await this.getRootFolder()).token;
99
101
 
100
102
  const { body } = await this.client.post<LarkData<{ file: CopiedFile }>>(
package/src/type.ts CHANGED
@@ -60,6 +60,27 @@ export type LarkDocumentType =
60
60
  | 'slides'
61
61
  | 'file';
62
62
 
63
+ export type LarkDocumentPathType =
64
+ | `doc${'' | 'x'}`
65
+ | 'mindnote'
66
+ | 'sheets'
67
+ | 'base'
68
+ | 'slides'
69
+ | 'file';
70
+
71
+ export const LarkDocumentPathTypeMap: Record<LarkDocumentType, LarkDocumentPathType> = {
72
+ doc: 'doc',
73
+ docx: 'docx',
74
+ mindnote: 'mindnote',
75
+ sheet: 'sheets',
76
+ bitable: 'base',
77
+ slides: 'slides',
78
+ file: 'file'
79
+ };
80
+
81
+ export const getLarkDocumentType = (path: LarkDocumentPathType) =>
82
+ Object.entries(LarkDocumentPathTypeMap).find(([, p]) => p === path)![0] as LarkDocumentType;
83
+
63
84
  export type UploadTargetType =
64
85
  | 'doc_image'
65
86
  | 'docx_image'