@cisri/db-schema-core 1.0.0

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/index.cjs ADDED
@@ -0,0 +1 @@
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});let r=0;function t(e="id"){return`${e}-${++r}`}function n(){r=0}function u(e=""){return{id:t("col"),name:e,type:"varchar",nullable:!0,primaryKey:!1,unique:!1}}function a(e=""){return{id:t("tbl"),name:e,columns:[]}}exports.createEmptyColumn=u;exports.createEmptyTable=a;exports.generateId=t;exports.resetIdCounter=n;
@@ -0,0 +1,3 @@
1
+ export type { DbColumnType, DbColumn, DbTable } from './types';
2
+ export { generateId, resetIdCounter, createEmptyColumn, createEmptyTable, } from './utils';
3
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,YAAY,EAAE,YAAY,EAAE,QAAQ,EAAE,OAAO,EAAE,MAAM,SAAS,CAAC;AAC/D,OAAO,EACL,UAAU,EACV,cAAc,EACd,iBAAiB,EACjB,gBAAgB,GACjB,MAAM,SAAS,CAAC"}
package/dist/index.js ADDED
@@ -0,0 +1,30 @@
1
+ let t = 0;
2
+ function n(e = "id") {
3
+ return `${e}-${++t}`;
4
+ }
5
+ function r() {
6
+ t = 0;
7
+ }
8
+ function u(e = "") {
9
+ return {
10
+ id: n("col"),
11
+ name: e,
12
+ type: "varchar",
13
+ nullable: !0,
14
+ primaryKey: !1,
15
+ unique: !1
16
+ };
17
+ }
18
+ function l(e = "") {
19
+ return {
20
+ id: n("tbl"),
21
+ name: e,
22
+ columns: []
23
+ };
24
+ }
25
+ export {
26
+ u as createEmptyColumn,
27
+ l as createEmptyTable,
28
+ n as generateId,
29
+ r as resetIdCounter
30
+ };
@@ -0,0 +1,23 @@
1
+ /**
2
+ * 数据库列类型。常见通用类型集合,可在后续按需扩展。
3
+ */
4
+ export type DbColumnType = 'varchar' | 'text' | 'integer' | 'bigint' | 'decimal' | 'boolean' | 'date' | 'timestamp' | 'uuid' | 'jsonb';
5
+ /** 数据库列定义 */
6
+ export interface DbColumn {
7
+ id: string;
8
+ name: string;
9
+ type: DbColumnType;
10
+ nullable: boolean;
11
+ primaryKey: boolean;
12
+ unique: boolean;
13
+ defaultValue?: string;
14
+ description?: string;
15
+ }
16
+ /** 数据库表定义 */
17
+ export interface DbTable {
18
+ id: string;
19
+ name: string;
20
+ description?: string;
21
+ columns: DbColumn[];
22
+ }
23
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,MAAM,MAAM,YAAY,GACpB,SAAS,GACT,MAAM,GACN,SAAS,GACT,QAAQ,GACR,SAAS,GACT,SAAS,GACT,MAAM,GACN,WAAW,GACX,MAAM,GACN,OAAO,CAAC;AAEZ,aAAa;AACb,MAAM,WAAW,QAAQ;IACvB,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,YAAY,CAAC;IACnB,QAAQ,EAAE,OAAO,CAAC;IAClB,UAAU,EAAE,OAAO,CAAC;IACpB,MAAM,EAAE,OAAO,CAAC;IAChB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,WAAW,CAAC,EAAE,MAAM,CAAC;CACtB;AAED,aAAa;AACb,MAAM,WAAW,OAAO;IACtB,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,OAAO,EAAE,QAAQ,EAAE,CAAC;CACrB"}
@@ -0,0 +1,10 @@
1
+ import type { DbColumn, DbTable } from './types';
2
+ /** 生成可读的唯一 ID,形如 `${prefix}-${n}`。 */
3
+ export declare function generateId(prefix?: string): string;
4
+ /** 重置 ID 计数器,用于测试确定性。 */
5
+ export declare function resetIdCounter(): void;
6
+ /** 创建一个空列:默认 varchar、可空、无约束。 */
7
+ export declare function createEmptyColumn(name?: string): DbColumn;
8
+ /** 创建一个空表:无列。 */
9
+ export declare function createEmptyTable(name?: string): DbTable;
10
+ //# sourceMappingURL=utils.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../src/utils.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,OAAO,EAAE,MAAM,SAAS,CAAC;AAIjD,sCAAsC;AACtC,wBAAgB,UAAU,CAAC,MAAM,SAAO,GAAG,MAAM,CAEhD;AAED,yBAAyB;AACzB,wBAAgB,cAAc,IAAI,IAAI,CAErC;AAED,gCAAgC;AAChC,wBAAgB,iBAAiB,CAAC,IAAI,SAAK,GAAG,QAAQ,CASrD;AAED,iBAAiB;AACjB,wBAAgB,gBAAgB,CAAC,IAAI,SAAK,GAAG,OAAO,CAMnD"}
package/package.json ADDED
@@ -0,0 +1,33 @@
1
+ {
2
+ "name": "@cisri/db-schema-core",
3
+ "version": "1.0.0",
4
+ "description": "Shared DB schema types and utilities for @cisri business components",
5
+ "type": "module",
6
+ "main": "./dist/index.js",
7
+ "module": "./dist/index.js",
8
+ "types": "./dist/index.d.ts",
9
+ "exports": {
10
+ ".": {
11
+ "types": "./dist/index.d.ts",
12
+ "import": "./dist/index.js",
13
+ "require": "./dist/index.cjs"
14
+ }
15
+ },
16
+ "files": [
17
+ "dist"
18
+ ],
19
+ "sideEffects": false,
20
+ "publishConfig": {
21
+ "access": "public"
22
+ },
23
+ "devDependencies": {
24
+ "typescript": "^5.4.5",
25
+ "vite": "^5.2.11",
26
+ "vitest": "^1.6.0"
27
+ },
28
+ "scripts": {
29
+ "build": "tsc && vite build",
30
+ "test": "vitest run",
31
+ "test:watch": "vitest"
32
+ }
33
+ }