@yanqirenshi/d3.ter 0.1.17 → 0.1.18

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.
Files changed (2) hide show
  1. package/dist/index.d.ts +175 -0
  2. package/package.json +2 -1
@@ -0,0 +1,175 @@
1
+ // @yanqirenshi/d3.ter の型定義(手書き同梱)。
2
+ // 実装は Babel(JavaScript)のため、この宣言が公開 API の正となる。
3
+ // Babel の --copy-files で dist/ へコピーされ、package.json の types が指す。
4
+
5
+ import type { ComponentType } from 'react';
6
+
7
+ /* **************************************************************** *
8
+ * 入力データ(data() に渡す構造)
9
+ * **************************************************************** */
10
+
11
+ /** 名称(論理名 / 物理名) */
12
+ export interface TerName {
13
+ logical?: string;
14
+ physical?: string;
15
+ }
16
+
17
+ /** 識別子(主キー)のマスタ定義。entities から id 参照される */
18
+ export interface TerIdentifier {
19
+ id: number | string;
20
+ name: TerName;
21
+ description?: string;
22
+ }
23
+
24
+ /** 属性(カラム)のマスタ定義。entities から id 参照される */
25
+ export interface TerAttribute {
26
+ id: number | string;
27
+ name: TerName;
28
+ description?: string;
29
+ }
30
+
31
+ /** TM(T字形ER)のエンティティ種別(9種)。これ以外の値は描画時に例外になる */
32
+ export type TerEntityType =
33
+ | 'RESOURCE'
34
+ | 'RESOURCE-SUBSET'
35
+ | 'EVENT'
36
+ | 'EVENT-SUBSET'
37
+ | 'COMPARATIVE'
38
+ | 'CORRESPONDENCE'
39
+ | 'RECURSION'
40
+ | 'MANY-VALUED-OR'
41
+ | 'MANY-VALUED-AND';
42
+
43
+ /** カーディナリティ(1 または 多=3) */
44
+ export type TerCardinality = 1 | 3;
45
+
46
+ /** オプショナリティ(0=必須, 1=任意) */
47
+ export type TerOptionality = 0 | 1;
48
+
49
+ /** エンティティが持つ識別子インスタンス(identifier はマスタの id を参照) */
50
+ export interface TerIdentifierInstance {
51
+ id: number | string;
52
+ identifier: number | string;
53
+ description?: string;
54
+ }
55
+
56
+ /** エンティティが持つ属性インスタンス(attribute はマスタの id を参照) */
57
+ export interface TerAttributeInstance {
58
+ id: number | string;
59
+ attribute: number | string;
60
+ description?: string;
61
+ }
62
+
63
+ /** エンティティ(テーブル) */
64
+ export interface TerEntity {
65
+ id: number | string;
66
+ type: TerEntityType;
67
+ name: string;
68
+ description?: string;
69
+ position: { x: number; y: number; z?: number };
70
+ /** w/h に 0 を渡すと内容に自動フィットする */
71
+ size: { w: number; h: number };
72
+ identifiers: TerIdentifierInstance[];
73
+ attributes: TerAttributeInstance[];
74
+ }
75
+
76
+ /** リレーションシップの端点 */
77
+ export interface TerRelationshipEnd {
78
+ /** 接続先エンティティの id */
79
+ entity: number | string;
80
+ cardinality: TerCardinality;
81
+ optionality: TerOptionality;
82
+ /** ポートの取り付け角度(ノード中心から見て 0=真下・時計回り。90=左, 180=真上, 270=右) */
83
+ position?: number;
84
+ }
85
+
86
+ /** ポートの取付カラム(from/to とも識別子・属性インスタンスの id を参照) */
87
+ export interface TerRelationshipDetail {
88
+ from: { id: number | string; description?: string };
89
+ to: { id: number | string; description?: string };
90
+ }
91
+
92
+ /** エンティティ間のリレーションシップ */
93
+ export interface TerRelationship {
94
+ id: number | string;
95
+ type?: string | null;
96
+ from: TerRelationshipEnd;
97
+ to: TerRelationshipEnd;
98
+ /** 省略時は先頭の識別子インスタンスに取り付く */
99
+ details?: TerRelationshipDetail[];
100
+ description?: string;
101
+ }
102
+
103
+ /** data() に渡すデータ一式 */
104
+ export interface TerData {
105
+ identifiers: TerIdentifier[];
106
+ attributes: TerAttribute[];
107
+ entities: TerEntity[];
108
+ relationships: TerRelationship[];
109
+ }
110
+
111
+ /* **************************************************************** *
112
+ * Rectum / D3Ter
113
+ * **************************************************************** */
114
+
115
+ /**
116
+ * クリック通知などで渡される正規化済みエンティティ。
117
+ * _core に入力(TerEntity)がそのまま入る。内部レイアウト系のフィールドは省略。
118
+ */
119
+ export interface TerEntityDatum {
120
+ _id: number | string;
121
+ _core: TerEntity;
122
+ position: { x: number; y: number; z?: number };
123
+ size: { w: number; h: number };
124
+ [key: string]: unknown;
125
+ }
126
+
127
+ export interface TerCallbacks {
128
+ entity?: {
129
+ /** エンティティのクリック通知(正規化済みデータが渡される) */
130
+ click?: ((entity: TerEntityDatum) => void) | null;
131
+ };
132
+ }
133
+
134
+ /** Rectum のコンストラクタ引数(共通基盤 Colon の描画設定 + コールバック) */
135
+ export interface RectumParams {
136
+ /** ズーム初期値 */
137
+ transform?: { k?: number; x?: number; y?: number };
138
+ /** 背景グリッド */
139
+ grid?: { draw?: boolean; size?: number; span?: number };
140
+ svg?: { style?: { background?: string } };
141
+ callbacks?: TerCallbacks;
142
+ /** その他の Colon パラメータ(camera / layers 等) */
143
+ [key: string]: unknown;
144
+ }
145
+
146
+ /**
147
+ * ER 図(TER)の総括クラス。データ構築・レイアウト計算を行い、描画はペインタへ委譲する。
148
+ * (型を付けているのは利用側が触る代表的なメンバーのみ。内部 API は含めない)
149
+ */
150
+ export class Rectum {
151
+ constructor(params?: RectumParams);
152
+
153
+ /** ter 形式のデータを構築する。引数なしの場合は現在の内部データを返す */
154
+ data(data: TerData): unknown;
155
+ data(): unknown;
156
+
157
+ /** 描画先の SVG 要素(セレクタ文字列 or 要素)を設定する */
158
+ selector(v: string | Element): unknown;
159
+
160
+ /** SVG のピクセルサイズ */
161
+ bounds(v?: { w: number; h: number }): unknown;
162
+
163
+ /** 正規化済みエンティティのプール({ list, ht }) */
164
+ entities(): { list: TerEntityDatum[]; ht: Record<string | number, TerEntityDatum> };
165
+ }
166
+
167
+ export interface D3TerProps {
168
+ rectum: Rectum;
169
+ /** SVG コンテナの DOM id(既定 "d3-ter-graph") */
170
+ id?: string;
171
+ }
172
+
173
+ /** React ラッパコンポーネント */
174
+ declare const D3Ter: ComponentType<D3TerProps>;
175
+ export default D3Ter;
package/package.json CHANGED
@@ -1,10 +1,11 @@
1
1
  {
2
2
  "name": "@yanqirenshi/d3.ter",
3
- "version": "0.1.17",
3
+ "version": "0.1.18",
4
4
  "author": "yanqirenshi@gmail.com",
5
5
  "license": "GPL-3.0-or-later",
6
6
  "description": "See `src/index.html`",
7
7
  "main": "dist/index.js",
8
+ "types": "dist/index.d.ts",
8
9
  "directories": {
9
10
  "doc": "docs",
10
11
  "example": "example"