Core AI
    正在准备搜索索引...
    索引

    方法

    • 归档应用

      参数

      • applicationId: string

      返回 Promise<void>

      归档应用

      await client.application.archive(applicationId)
      
    • 签出指定的版本 注意:传入 versionId 前请确认不要和 application.currentVersionId 相同,因为签出相同的版本没有实际意义。

      参数

      • applicationId: string
      • versionId: string

      返回 Promise<
          {
              data: {
                  createdAt: string;
                  creator: {
                      banExpires: null
                      | string;
                      banned: null | boolean;
                      banReason: null | string;
                      createdAt: string;
                      email: string;
                      emailVerified: boolean;
                      id: string;
                      image: null | string;
                      name: string;
                      role: null | string;
                      updatedAt: string;
                  };
                  creatorId: string;
                  currentVersion: {
                      createdAt: string;
                      id: string;
                      resourceId: null
                      | string;
                      resourceType: "application";
                      snapshot: Snapshot;
                      tags: string[];
                      updatedAt: string;
                      version: string;
                  };
                  currentVersionId: null
                  | string;
                  description: null | string;
                  id: string;
                  name: string;
                  settings: {
                      color?: string;
                      icon?: {
                          code: string;
                          emoji: string;
                          id: number;
                          name: string;
                          nameUrl: string;
                          [x: string]: unknown;
                      };
                      [x: string]: unknown;
                  };
                  status: "draft"
                  | "published"
                  | "publishing"
                  | "archived";
                  type: "form" | "quiz" | "survey";
                  updatedAt: string;
              };
          },
      >

      签出指定的版本

      if (versionId !== application.id) {
      const { data: versionedApplication } = await client.application.checkout(application.id, versionId)
      }
    • 创建一个新应用

      参数

      • body: {
            creatorId?: string;
            description?: null | string;
            name: string;
            settings?: {
                color?: string;
                icon?: {
                    code: string;
                    emoji: string;
                    id: number;
                    name: string;
                    nameUrl: string;
                    [x: string]: unknown;
                };
                [x: string]: unknown;
            };
            status?: "draft"
            | "published"
            | "publishing"
            | "archived";
            type: "form" | "quiz" | "survey";
        }

      返回 Promise<
          {
              data: {
                  createdAt: string;
                  creator: {
                      banExpires: null
                      | string;
                      banned: null | boolean;
                      banReason: null | string;
                      createdAt: string;
                      email: string;
                      emailVerified: boolean;
                      id: string;
                      image: null | string;
                      name: string;
                      role: null | string;
                      updatedAt: string;
                  };
                  creatorId: string;
                  currentVersion: {
                      createdAt: string;
                      id: string;
                      resourceId: null
                      | string;
                      resourceType: "application";
                      snapshot: Snapshot;
                      tags: string[];
                      updatedAt: string;
                      version: string;
                  };
                  currentVersionId: null
                  | string;
                  description: null | string;
                  id: string;
                  name: string;
                  settings: {
                      color?: string;
                      icon?: {
                          code: string;
                          emoji: string;
                          id: number;
                          name: string;
                          nameUrl: string;
                          [x: string]: unknown;
                      };
                      [x: string]: unknown;
                  };
                  status: "draft"
                  | "published"
                  | "publishing"
                  | "archived";
                  type: "form" | "quiz" | "survey";
                  updatedAt: string;
              };
          },
      >

      以当前用户身份创建新应用

      const { data: createdApplication } = await client.application.create({
      name: "A new application",
      type: "form"
      })

      以指定用户身份创建新应用

      const { data: createdApplication } = await client.application.create({
      creatorId: "user-id"
      name: "A new application",
      type: "form",
      })
    • 删除应用

      参数

      • applicationId: string

      返回 Promise<{ data: string }>

      删除应用

      await client.application.delete(applicationId)
      
    • 按 ID 获取应用详情(仅限当前登陆用户)

      参数

      • applicationId: string

      返回 Promise<
          {
              data: {
                  createdAt: string;
                  creator: {
                      banExpires: null
                      | string;
                      banned: null | boolean;
                      banReason: null | string;
                      createdAt: string;
                      email: string;
                      emailVerified: boolean;
                      id: string;
                      image: null | string;
                      name: string;
                      role: null | string;
                      updatedAt: string;
                  };
                  creatorId: string;
                  currentVersion: {
                      createdAt: string;
                      id: string;
                      resourceId: null
                      | string;
                      resourceType: "application";
                      snapshot: Snapshot;
                      tags: string[];
                      updatedAt: string;
                      version: string;
                  };
                  currentVersionId: null
                  | string;
                  description: null | string;
                  id: string;
                  name: string;
                  settings: {
                      color?: string;
                      icon?: {
                          code: string;
                          emoji: string;
                          id: number;
                          name: string;
                          nameUrl: string;
                          [x: string]: unknown;
                      };
                      [x: string]: unknown;
                  };
                  status: "draft"
                  | "published"
                  | "publishing"
                  | "archived";
                  type: "form" | "quiz" | "survey";
                  updatedAt: string;
              };
          },
      >

      获取应用详情

      const { data: application } = await client.application.findById(applicationId)
      
    • 按创建者获取应用列表(仅限当前登陆用户)

      参数

      • params: { archived: boolean } = ...

      返回 Promise<
          {
              data: {
                  createdAt: string;
                  creator: {
                      banExpires: null
                      | string;
                      banned: null | boolean;
                      banReason: null | string;
                      createdAt: string;
                      email: string;
                      emailVerified: boolean;
                      id: string;
                      image: null | string;
                      name: string;
                      role: null | string;
                      updatedAt: string;
                  };
                  creatorId: string;
                  currentVersion: {
                      createdAt: string;
                      id: string;
                      resourceId: null
                      | string;
                      resourceType: "application";
                      snapshot: Snapshot;
                      tags: string[];
                      updatedAt: string;
                      version: string;
                  };
                  currentVersionId: null
                  | string;
                  description: null | string;
                  id: string;
                  name: string;
                  settings: {
                      color?: string;
                      icon?: {
                          code: string;
                          emoji: string;
                          id: number;
                          name: string;
                          nameUrl: string;
                          [x: string]: unknown;
                      };
                      [x: string]: unknown;
                  };
                  status: "draft"
                  | "published"
                  | "publishing"
                  | "archived";
                  type: "form" | "quiz" | "survey";
                  updatedAt: string;
              }[];
          },
      >

      应用列表(不包含已归档应用)

      const { data: applications } = await client.application.listByCreator()
      

      已归档的应用列表

      const { data: archivedApplications } = await client.application.listByCreator({ archived: true })
      
    • 更新应用

      参数

      • applicationId: string
      • body: {
            description?: null | string;
            name?: string;
            settings?: {
                color?: string;
                icon?: {
                    code: string;
                    emoji: string;
                    id: number;
                    name: string;
                    nameUrl: string;
                    [x: string]: unknown;
                };
                [x: string]: unknown;
            };
            status?: "draft"
            | "published"
            | "publishing"
            | "archived";
            type?: "form" | "quiz" | "survey";
        }

      返回 Promise<
          {
              data: {
                  createdAt: string;
                  creator: {
                      banExpires: null
                      | string;
                      banned: null | boolean;
                      banReason: null | string;
                      createdAt: string;
                      email: string;
                      emailVerified: boolean;
                      id: string;
                      image: null | string;
                      name: string;
                      role: null | string;
                      updatedAt: string;
                  };
                  creatorId: string;
                  currentVersion: {
                      createdAt: string;
                      id: string;
                      resourceId: null
                      | string;
                      resourceType: "application";
                      snapshot: Snapshot;
                      tags: string[];
                      updatedAt: string;
                      version: string;
                  };
                  currentVersionId: null
                  | string;
                  description: null | string;
                  id: string;
                  name: string;
                  settings: {
                      color?: string;
                      icon?: {
                          code: string;
                          emoji: string;
                          id: number;
                          name: string;
                          nameUrl: string;
                          [x: string]: unknown;
                      };
                      [x: string]: unknown;
                  };
                  status: "draft"
                  | "published"
                  | "publishing"
                  | "archived";
                  type: "form" | "quiz" | "survey";
                  updatedAt: string;
              };
          },
      >

      更新应用

      const { data: updatedApplication } = await client.application.update(
      applicationId,
      { name: "A new name" }
      )