udpate add columns types
This commit is contained in:
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@kevisual/noco",
|
"name": "@kevisual/noco",
|
||||||
"version": "0.0.5",
|
"version": "0.0.6",
|
||||||
"description": "",
|
"description": "",
|
||||||
"main": "index.js",
|
"main": "index.js",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
@@ -32,7 +32,8 @@
|
|||||||
"nocodb-sdk": "^0.265.1"
|
"nocodb-sdk": "^0.265.1"
|
||||||
},
|
},
|
||||||
"exports": {
|
"exports": {
|
||||||
".": "./dist/app.js"
|
".": "./dist/app.js",
|
||||||
|
"./src/**/*": "./src/**/"
|
||||||
},
|
},
|
||||||
"dependencies": {}
|
"dependencies": {}
|
||||||
}
|
}
|
||||||
@@ -3,4 +3,7 @@ export * from './api.ts';
|
|||||||
export * from './main.ts';
|
export * from './main.ts';
|
||||||
export * from './meta/index.ts';
|
export * from './meta/index.ts';
|
||||||
|
|
||||||
export * from './data/upload.ts';
|
export * from './data/upload.ts';
|
||||||
|
|
||||||
|
// 重要的类型定义模块
|
||||||
|
export type { CreateColumnData, CreateTableData } from './meta/tables.ts';
|
||||||
@@ -1,5 +1,5 @@
|
|||||||
import { Query } from './api.ts';
|
import { Query } from './api.ts';
|
||||||
import { Meta } from './meta/index.ts';
|
import { Meta, CreateColumnData } from './meta/index.ts';
|
||||||
import { Record } from './record.ts';
|
import { Record } from './record.ts';
|
||||||
import { Upload } from './data/upload.ts';
|
import { Upload } from './data/upload.ts';
|
||||||
export type NocoApiOptions = {
|
export type NocoApiOptions = {
|
||||||
|
|||||||
@@ -5,7 +5,6 @@ import { Webhook } from './webhook.ts';
|
|||||||
export type MetaOptions = {
|
export type MetaOptions = {
|
||||||
query: Query;
|
query: Query;
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* NocoDB Meta API 管理类
|
* NocoDB Meta API 管理类
|
||||||
* 统一管理所有的 meta 相关操作
|
* 统一管理所有的 meta 相关操作
|
||||||
|
|||||||
@@ -45,7 +45,7 @@ export class MetaTables {
|
|||||||
method: 'GET',
|
method: 'GET',
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
async createTable(baseId: string, data: CreateTableData): Promise<{ code: number; data: TableMetaInfo }> {
|
async createTable(baseId: string, data: CreateTableData): Promise<{ code: number; data: TableMetaInfo }> {
|
||||||
return this.query.makeRequest(`/api/v2/meta/bases/${baseId}/tables`, {
|
return this.query.makeRequest(`/api/v2/meta/bases/${baseId}/tables`, {
|
||||||
method: 'POST',
|
method: 'POST',
|
||||||
data,
|
data,
|
||||||
@@ -68,6 +68,28 @@ export type CreateColumnData = {
|
|||||||
title: string;
|
title: string;
|
||||||
uidt?: ColumnTypes
|
uidt?: ColumnTypes
|
||||||
description?: string;
|
description?: string;
|
||||||
|
/**
|
||||||
|
* 是否为主键 primay 的值
|
||||||
|
*/
|
||||||
|
pv?: boolean;
|
||||||
|
/** 是否必填 */
|
||||||
|
rqd?: boolean;
|
||||||
|
/** 单元格默认值 */
|
||||||
|
cdf?: string;
|
||||||
|
/**
|
||||||
|
* 列选项配置
|
||||||
|
*/
|
||||||
|
colOptions?: {
|
||||||
|
options?: Array<{
|
||||||
|
title: string;
|
||||||
|
color?: string;
|
||||||
|
[key: string]: any;
|
||||||
|
}>;
|
||||||
|
};
|
||||||
|
/**
|
||||||
|
* 其他元信息
|
||||||
|
*/
|
||||||
|
meta?: Record<string, any>;
|
||||||
}
|
}
|
||||||
export const columnTypes = [
|
export const columnTypes = [
|
||||||
'SingleLineText',
|
'SingleLineText',
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
import { NocoApi } from './../src/main.ts';
|
import { NocoApi } from './../src/main.ts';
|
||||||
import { useConfig } from '@kevisual/use-config'
|
import { useConfig } from '@kevisual/use-config'
|
||||||
|
import { CreateColumnData } from '../src/meta/index.ts';
|
||||||
export const config = useConfig()
|
export const config = useConfig()
|
||||||
import util from 'node:util';
|
import util from 'node:util';
|
||||||
// # 签到表
|
// # 签到表
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
|
import { title } from "process";
|
||||||
import { nocoApi } from "./common";
|
import { nocoApi } from "./common";
|
||||||
import bun from 'bun'
|
import bun from 'bun'
|
||||||
|
|
||||||
@@ -7,11 +8,12 @@ import bun from 'bun'
|
|||||||
|
|
||||||
// AI id
|
// AI id
|
||||||
const baseId = 'pypv3deh9qzol7q'
|
const baseId = 'pypv3deh9qzol7q'
|
||||||
|
// 个人知识库 id
|
||||||
const startId = 'prg9dee7ldbemzd'
|
const startId = 'prg9dee7ldbemzd'
|
||||||
// const res = await nocoApi.meta.tables.list(baseId)
|
// const res = await nocoApi.meta.tables.list(baseId)
|
||||||
// console.log('tables list', res);
|
// console.log('tables list', res);
|
||||||
|
|
||||||
const tableId = 'm9rcgc95ev9d1uo'
|
// const tableId = 'm9rcgc95ev9d1uo'
|
||||||
|
|
||||||
// const tableMeta = await nocoApi.meta.tables.getTableMeta(tableId)
|
// const tableMeta = await nocoApi.meta.tables.getTableMeta(tableId)
|
||||||
|
|
||||||
@@ -20,34 +22,96 @@ const tableId = 'm9rcgc95ev9d1uo'
|
|||||||
// bun.write('meta.json', JSON.stringify(tableMeta, null, 2))
|
// bun.write('meta.json', JSON.stringify(tableMeta, null, 2))
|
||||||
|
|
||||||
const newTables = await nocoApi.meta.tables.createTable(startId, {
|
const newTables = await nocoApi.meta.tables.createTable(startId, {
|
||||||
title: '测试表3',
|
title: '测试表4',
|
||||||
description: '这是一个测试表3',
|
description: '这是一个测试表3',
|
||||||
columns: [
|
columns: [
|
||||||
|
// {
|
||||||
|
// title: 'Title',
|
||||||
|
// uidt: 'SingleLineText',
|
||||||
|
// description: '标题列',
|
||||||
|
// },
|
||||||
|
// {
|
||||||
|
// title: 'Summary',
|
||||||
|
// uidt: 'LongText',
|
||||||
|
// description: '摘要列',
|
||||||
|
// },
|
||||||
|
// {
|
||||||
|
// title: 'Tags',
|
||||||
|
// uidt: 'MultiSelect',
|
||||||
|
// description: '标签列',
|
||||||
|
// },
|
||||||
|
// {
|
||||||
|
// title: 'Description',
|
||||||
|
// uidt: 'LongText',
|
||||||
|
// description: '描述列',
|
||||||
|
// },
|
||||||
|
// {
|
||||||
|
// title: 'Link',
|
||||||
|
// uidt: 'URL',
|
||||||
|
// description: '链接列',
|
||||||
|
// },
|
||||||
{
|
{
|
||||||
title: 'Title',
|
title: '标题',
|
||||||
uidt: 'SingleLineText',
|
uidt: 'SingleLineText',
|
||||||
description: '标题列',
|
description: '标题列',
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
title: 'Summary',
|
title: '标签',
|
||||||
uidt: 'LongText',
|
|
||||||
description: '摘要列',
|
|
||||||
},
|
|
||||||
{
|
|
||||||
title: 'Tags',
|
|
||||||
uidt: 'MultiSelect',
|
uidt: 'MultiSelect',
|
||||||
description: '标签列',
|
description: '标签列',
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
title: 'Description',
|
title: '总结',
|
||||||
|
uidt: 'LongText',
|
||||||
|
description: '总结列',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
title: '描述',
|
||||||
uidt: 'LongText',
|
uidt: 'LongText',
|
||||||
description: '描述列',
|
description: '描述列',
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
title: 'Link',
|
title: '数据',
|
||||||
|
uidt: 'JSON',
|
||||||
|
description: '数据列',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
title: '链接',
|
||||||
uidt: 'URL',
|
uidt: 'URL',
|
||||||
description: '链接列',
|
description: '链接列',
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
title: '类型',
|
||||||
|
uidt: 'SingleSelect',
|
||||||
|
// dtxp: toStr(['每日', '每周', '每月', '每年', '一次性', '备忘', '归档', '智能']),
|
||||||
|
colOptions: {
|
||||||
|
options: [
|
||||||
|
{
|
||||||
|
title: '每日',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
title: '每周',
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
title: '启动时间',
|
||||||
|
uidt: 'DateTime',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
title: '任务',
|
||||||
|
uidt: 'MultiSelect'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
title: '任务结果',
|
||||||
|
uidt: 'LongText'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
title: '提示词',
|
||||||
|
uidt: 'LongText',
|
||||||
|
description: '和AI交互时候简单的实时提示词',
|
||||||
|
}
|
||||||
]
|
]
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user