@yanqirenshi/model.deployment 0.0.0-stage → 0.1.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/LICENSE +21 -0
- package/README.md +130 -2
- package/dist/check.d.ts +15 -0
- package/dist/check.d.ts.map +1 -0
- package/dist/check.js +27 -0
- package/dist/cjs/check.js +32 -0
- package/dist/cjs/defaults.js +119 -0
- package/dist/cjs/fields.js +44 -0
- package/dist/cjs/index.js +46 -0
- package/dist/cjs/package.json +3 -0
- package/dist/cjs/patch.js +141 -0
- package/dist/cjs/schema.js +97 -0
- package/dist/cjs/types.js +7 -0
- package/dist/defaults.d.ts +61 -0
- package/dist/defaults.d.ts.map +1 -0
- package/dist/defaults.js +111 -0
- package/dist/fields.d.ts +8 -0
- package/dist/fields.d.ts.map +1 -0
- package/dist/fields.js +40 -0
- package/dist/index.d.ts +8 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +16 -0
- package/dist/patch.d.ts +19 -0
- package/dist/patch.d.ts.map +1 -0
- package/dist/patch.js +130 -0
- package/dist/schema.d.ts +274 -0
- package/dist/schema.d.ts.map +1 -0
- package/dist/schema.js +94 -0
- package/dist/types.d.ts +79 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +6 -0
- package/package.json +55 -5
- package/src/check.ts +33 -0
- package/src/defaults.ts +138 -0
- package/src/fields.ts +46 -0
- package/src/index.ts +28 -0
- package/src/patch.ts +158 -0
- package/src/schema.ts +100 -0
- package/src/types.ts +94 -0
package/dist/schema.d.ts
ADDED
|
@@ -0,0 +1,274 @@
|
|
|
1
|
+
export declare const NODES_SCHEMA: {
|
|
2
|
+
readonly $schema: "https://json-schema.org/draft/2020-12/schema";
|
|
3
|
+
readonly title: "システム構成図のノード";
|
|
4
|
+
readonly description: "d3.deployment に渡すノード。children に子のノードを入れ子で持つ。id は子のノードも含めて一意にする。position は親の中での位置で、ドラッグで動かすと書き換わる。link を付けると、ノードの左下にリンクを出す。見た目の項目 (label・padding・border・background・description) は d3.deployment の入力の形のまま書ける。";
|
|
5
|
+
readonly 'x-id-start': 1;
|
|
6
|
+
readonly type: "array";
|
|
7
|
+
readonly items: {
|
|
8
|
+
readonly $ref: "#/$defs/node";
|
|
9
|
+
};
|
|
10
|
+
readonly $defs: {
|
|
11
|
+
readonly node: {
|
|
12
|
+
readonly type: "object";
|
|
13
|
+
readonly properties: {
|
|
14
|
+
readonly id: {
|
|
15
|
+
readonly type: readonly ["integer", "string"];
|
|
16
|
+
};
|
|
17
|
+
readonly type: {
|
|
18
|
+
readonly enum: readonly import("./types.js").DeploymentNodeType[];
|
|
19
|
+
};
|
|
20
|
+
readonly label: {
|
|
21
|
+
readonly type: "object";
|
|
22
|
+
readonly properties: {
|
|
23
|
+
readonly text: {
|
|
24
|
+
readonly type: readonly ["string", "null"];
|
|
25
|
+
};
|
|
26
|
+
};
|
|
27
|
+
};
|
|
28
|
+
readonly description: {
|
|
29
|
+
readonly type: readonly ["string", "null"];
|
|
30
|
+
};
|
|
31
|
+
readonly size: {
|
|
32
|
+
readonly type: "object";
|
|
33
|
+
readonly properties: {
|
|
34
|
+
readonly w: {
|
|
35
|
+
readonly type: "number";
|
|
36
|
+
readonly minimum: 0;
|
|
37
|
+
};
|
|
38
|
+
readonly h: {
|
|
39
|
+
readonly type: "number";
|
|
40
|
+
readonly minimum: 0;
|
|
41
|
+
};
|
|
42
|
+
};
|
|
43
|
+
readonly required: readonly ["w", "h"];
|
|
44
|
+
};
|
|
45
|
+
readonly position: {
|
|
46
|
+
readonly type: "object";
|
|
47
|
+
readonly properties: {
|
|
48
|
+
readonly x: {
|
|
49
|
+
readonly type: "number";
|
|
50
|
+
};
|
|
51
|
+
readonly y: {
|
|
52
|
+
readonly type: "number";
|
|
53
|
+
};
|
|
54
|
+
};
|
|
55
|
+
readonly required: readonly ["x", "y"];
|
|
56
|
+
};
|
|
57
|
+
readonly link: {
|
|
58
|
+
readonly type: readonly ["object", "null"];
|
|
59
|
+
readonly properties: {
|
|
60
|
+
readonly url: {
|
|
61
|
+
readonly type: readonly ["string", "null"];
|
|
62
|
+
};
|
|
63
|
+
};
|
|
64
|
+
};
|
|
65
|
+
readonly children: {
|
|
66
|
+
readonly type: "array";
|
|
67
|
+
readonly items: {
|
|
68
|
+
readonly $ref: "#/$defs/node";
|
|
69
|
+
};
|
|
70
|
+
};
|
|
71
|
+
};
|
|
72
|
+
readonly required: readonly ["id"];
|
|
73
|
+
readonly additionalProperties: true;
|
|
74
|
+
};
|
|
75
|
+
};
|
|
76
|
+
};
|
|
77
|
+
export declare const EDGES_SCHEMA: {
|
|
78
|
+
readonly $schema: "https://json-schema.org/draft/2020-12/schema";
|
|
79
|
+
readonly title: "システム構成図の線";
|
|
80
|
+
readonly description: "ノードの間の線。from.id / to.id はノード (子を含む) の id。position は接続位置の角度 (0=真下・時計回り。省略すると 90=左)。stroke.marker は両端の矢印の有無 (既定: 終点だけ)。";
|
|
81
|
+
readonly 'x-id-start': 100;
|
|
82
|
+
readonly type: "array";
|
|
83
|
+
readonly items: {
|
|
84
|
+
readonly type: "object";
|
|
85
|
+
readonly properties: {
|
|
86
|
+
readonly id: {
|
|
87
|
+
readonly type: readonly ["integer", "string"];
|
|
88
|
+
};
|
|
89
|
+
readonly from: {
|
|
90
|
+
readonly $ref: "#/$defs/end";
|
|
91
|
+
};
|
|
92
|
+
readonly to: {
|
|
93
|
+
readonly $ref: "#/$defs/end";
|
|
94
|
+
};
|
|
95
|
+
readonly stroke: {
|
|
96
|
+
readonly type: "object";
|
|
97
|
+
readonly properties: {
|
|
98
|
+
readonly color: {
|
|
99
|
+
readonly type: "string";
|
|
100
|
+
};
|
|
101
|
+
readonly width: {
|
|
102
|
+
readonly type: "number";
|
|
103
|
+
};
|
|
104
|
+
readonly marker: {
|
|
105
|
+
readonly type: "object";
|
|
106
|
+
readonly properties: {
|
|
107
|
+
readonly start: {
|
|
108
|
+
readonly type: "boolean";
|
|
109
|
+
};
|
|
110
|
+
readonly end: {
|
|
111
|
+
readonly type: "boolean";
|
|
112
|
+
};
|
|
113
|
+
};
|
|
114
|
+
};
|
|
115
|
+
};
|
|
116
|
+
};
|
|
117
|
+
};
|
|
118
|
+
readonly required: readonly ["id", "from", "to"];
|
|
119
|
+
readonly additionalProperties: true;
|
|
120
|
+
};
|
|
121
|
+
readonly $defs: {
|
|
122
|
+
readonly end: {
|
|
123
|
+
readonly type: "object";
|
|
124
|
+
readonly properties: {
|
|
125
|
+
readonly id: {
|
|
126
|
+
readonly type: readonly ["integer", "string"];
|
|
127
|
+
};
|
|
128
|
+
readonly position: {
|
|
129
|
+
readonly type: "number";
|
|
130
|
+
};
|
|
131
|
+
};
|
|
132
|
+
readonly required: readonly ["id"];
|
|
133
|
+
};
|
|
134
|
+
};
|
|
135
|
+
};
|
|
136
|
+
/** コレクション名 → スキーマ */
|
|
137
|
+
export declare const SCHEMAS: {
|
|
138
|
+
readonly nodes: {
|
|
139
|
+
readonly $schema: "https://json-schema.org/draft/2020-12/schema";
|
|
140
|
+
readonly title: "システム構成図のノード";
|
|
141
|
+
readonly description: "d3.deployment に渡すノード。children に子のノードを入れ子で持つ。id は子のノードも含めて一意にする。position は親の中での位置で、ドラッグで動かすと書き換わる。link を付けると、ノードの左下にリンクを出す。見た目の項目 (label・padding・border・background・description) は d3.deployment の入力の形のまま書ける。";
|
|
142
|
+
readonly 'x-id-start': 1;
|
|
143
|
+
readonly type: "array";
|
|
144
|
+
readonly items: {
|
|
145
|
+
readonly $ref: "#/$defs/node";
|
|
146
|
+
};
|
|
147
|
+
readonly $defs: {
|
|
148
|
+
readonly node: {
|
|
149
|
+
readonly type: "object";
|
|
150
|
+
readonly properties: {
|
|
151
|
+
readonly id: {
|
|
152
|
+
readonly type: readonly ["integer", "string"];
|
|
153
|
+
};
|
|
154
|
+
readonly type: {
|
|
155
|
+
readonly enum: readonly import("./types.js").DeploymentNodeType[];
|
|
156
|
+
};
|
|
157
|
+
readonly label: {
|
|
158
|
+
readonly type: "object";
|
|
159
|
+
readonly properties: {
|
|
160
|
+
readonly text: {
|
|
161
|
+
readonly type: readonly ["string", "null"];
|
|
162
|
+
};
|
|
163
|
+
};
|
|
164
|
+
};
|
|
165
|
+
readonly description: {
|
|
166
|
+
readonly type: readonly ["string", "null"];
|
|
167
|
+
};
|
|
168
|
+
readonly size: {
|
|
169
|
+
readonly type: "object";
|
|
170
|
+
readonly properties: {
|
|
171
|
+
readonly w: {
|
|
172
|
+
readonly type: "number";
|
|
173
|
+
readonly minimum: 0;
|
|
174
|
+
};
|
|
175
|
+
readonly h: {
|
|
176
|
+
readonly type: "number";
|
|
177
|
+
readonly minimum: 0;
|
|
178
|
+
};
|
|
179
|
+
};
|
|
180
|
+
readonly required: readonly ["w", "h"];
|
|
181
|
+
};
|
|
182
|
+
readonly position: {
|
|
183
|
+
readonly type: "object";
|
|
184
|
+
readonly properties: {
|
|
185
|
+
readonly x: {
|
|
186
|
+
readonly type: "number";
|
|
187
|
+
};
|
|
188
|
+
readonly y: {
|
|
189
|
+
readonly type: "number";
|
|
190
|
+
};
|
|
191
|
+
};
|
|
192
|
+
readonly required: readonly ["x", "y"];
|
|
193
|
+
};
|
|
194
|
+
readonly link: {
|
|
195
|
+
readonly type: readonly ["object", "null"];
|
|
196
|
+
readonly properties: {
|
|
197
|
+
readonly url: {
|
|
198
|
+
readonly type: readonly ["string", "null"];
|
|
199
|
+
};
|
|
200
|
+
};
|
|
201
|
+
};
|
|
202
|
+
readonly children: {
|
|
203
|
+
readonly type: "array";
|
|
204
|
+
readonly items: {
|
|
205
|
+
readonly $ref: "#/$defs/node";
|
|
206
|
+
};
|
|
207
|
+
};
|
|
208
|
+
};
|
|
209
|
+
readonly required: readonly ["id"];
|
|
210
|
+
readonly additionalProperties: true;
|
|
211
|
+
};
|
|
212
|
+
};
|
|
213
|
+
};
|
|
214
|
+
readonly edges: {
|
|
215
|
+
readonly $schema: "https://json-schema.org/draft/2020-12/schema";
|
|
216
|
+
readonly title: "システム構成図の線";
|
|
217
|
+
readonly description: "ノードの間の線。from.id / to.id はノード (子を含む) の id。position は接続位置の角度 (0=真下・時計回り。省略すると 90=左)。stroke.marker は両端の矢印の有無 (既定: 終点だけ)。";
|
|
218
|
+
readonly 'x-id-start': 100;
|
|
219
|
+
readonly type: "array";
|
|
220
|
+
readonly items: {
|
|
221
|
+
readonly type: "object";
|
|
222
|
+
readonly properties: {
|
|
223
|
+
readonly id: {
|
|
224
|
+
readonly type: readonly ["integer", "string"];
|
|
225
|
+
};
|
|
226
|
+
readonly from: {
|
|
227
|
+
readonly $ref: "#/$defs/end";
|
|
228
|
+
};
|
|
229
|
+
readonly to: {
|
|
230
|
+
readonly $ref: "#/$defs/end";
|
|
231
|
+
};
|
|
232
|
+
readonly stroke: {
|
|
233
|
+
readonly type: "object";
|
|
234
|
+
readonly properties: {
|
|
235
|
+
readonly color: {
|
|
236
|
+
readonly type: "string";
|
|
237
|
+
};
|
|
238
|
+
readonly width: {
|
|
239
|
+
readonly type: "number";
|
|
240
|
+
};
|
|
241
|
+
readonly marker: {
|
|
242
|
+
readonly type: "object";
|
|
243
|
+
readonly properties: {
|
|
244
|
+
readonly start: {
|
|
245
|
+
readonly type: "boolean";
|
|
246
|
+
};
|
|
247
|
+
readonly end: {
|
|
248
|
+
readonly type: "boolean";
|
|
249
|
+
};
|
|
250
|
+
};
|
|
251
|
+
};
|
|
252
|
+
};
|
|
253
|
+
};
|
|
254
|
+
};
|
|
255
|
+
readonly required: readonly ["id", "from", "to"];
|
|
256
|
+
readonly additionalProperties: true;
|
|
257
|
+
};
|
|
258
|
+
readonly $defs: {
|
|
259
|
+
readonly end: {
|
|
260
|
+
readonly type: "object";
|
|
261
|
+
readonly properties: {
|
|
262
|
+
readonly id: {
|
|
263
|
+
readonly type: readonly ["integer", "string"];
|
|
264
|
+
};
|
|
265
|
+
readonly position: {
|
|
266
|
+
readonly type: "number";
|
|
267
|
+
};
|
|
268
|
+
};
|
|
269
|
+
readonly required: readonly ["id"];
|
|
270
|
+
};
|
|
271
|
+
};
|
|
272
|
+
};
|
|
273
|
+
};
|
|
274
|
+
//# sourceMappingURL=schema.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"schema.d.ts","sourceRoot":"","sources":["../src/schema.ts"],"names":[],"mappings":"AAoBA,eAAO,MAAM,YAAY;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAkCf,CAAC;AAEX,eAAO,MAAM,YAAY;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAqCf,CAAC;AAEX,qBAAqB;AACrB,eAAO,MAAM,OAAO;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAGV,CAAC"}
|
package/dist/schema.js
ADDED
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
// d3.deployment の入力データの JSON Schema(2020-12)。
|
|
2
|
+
//
|
|
3
|
+
// iHub の server/schemas/deployment/{nodes,edges}.schema.json を移したもの。
|
|
4
|
+
// 検査するのは、図の構造にかかわる項目(id・type・size・position・children・link、線の from / to)だけで、
|
|
5
|
+
// 見た目の項目(label・border・background・padding・description)は d3.deployment の入力の形のまま書けるよう
|
|
6
|
+
// additionalProperties を閉じていない(iHub 版は閉じていた)。
|
|
7
|
+
//
|
|
8
|
+
// x-id-start はスキーマの検証には使わない注釈(コレクションが空のときに最初に振る id)。
|
|
9
|
+
// Ajv で使うときは addKeyword({ keyword: 'x-id-start', schemaType: 'number' }) を足す。
|
|
10
|
+
import { NODE_TYPES } from './defaults.js';
|
|
11
|
+
const ID = { type: ['integer', 'string'] };
|
|
12
|
+
const POINT = {
|
|
13
|
+
type: 'object',
|
|
14
|
+
properties: { x: { type: 'number' }, y: { type: 'number' } },
|
|
15
|
+
required: ['x', 'y'],
|
|
16
|
+
};
|
|
17
|
+
export const NODES_SCHEMA = {
|
|
18
|
+
$schema: 'https://json-schema.org/draft/2020-12/schema',
|
|
19
|
+
title: 'システム構成図のノード',
|
|
20
|
+
description: 'd3.deployment に渡すノード。children に子のノードを入れ子で持つ。id は子のノードも含めて一意にする。position は親の中での位置で、ドラッグで動かすと書き換わる。link を付けると、ノードの左下にリンクを出す。見た目の項目 (label・padding・border・background・description) は d3.deployment の入力の形のまま書ける。',
|
|
21
|
+
'x-id-start': 1,
|
|
22
|
+
type: 'array',
|
|
23
|
+
items: { $ref: '#/$defs/node' },
|
|
24
|
+
$defs: {
|
|
25
|
+
node: {
|
|
26
|
+
type: 'object',
|
|
27
|
+
properties: {
|
|
28
|
+
id: ID,
|
|
29
|
+
type: { enum: [...NODE_TYPES] },
|
|
30
|
+
label: {
|
|
31
|
+
type: 'object',
|
|
32
|
+
properties: { text: { type: ['string', 'null'] } },
|
|
33
|
+
},
|
|
34
|
+
description: { type: ['string', 'null'] },
|
|
35
|
+
size: {
|
|
36
|
+
type: 'object',
|
|
37
|
+
properties: { w: { type: 'number', minimum: 0 }, h: { type: 'number', minimum: 0 } },
|
|
38
|
+
required: ['w', 'h'],
|
|
39
|
+
},
|
|
40
|
+
position: POINT,
|
|
41
|
+
link: {
|
|
42
|
+
type: ['object', 'null'],
|
|
43
|
+
properties: { url: { type: ['string', 'null'] } },
|
|
44
|
+
},
|
|
45
|
+
children: { type: 'array', items: { $ref: '#/$defs/node' } },
|
|
46
|
+
},
|
|
47
|
+
required: ['id'],
|
|
48
|
+
additionalProperties: true,
|
|
49
|
+
},
|
|
50
|
+
},
|
|
51
|
+
};
|
|
52
|
+
export const EDGES_SCHEMA = {
|
|
53
|
+
$schema: 'https://json-schema.org/draft/2020-12/schema',
|
|
54
|
+
title: 'システム構成図の線',
|
|
55
|
+
description: 'ノードの間の線。from.id / to.id はノード (子を含む) の id。position は接続位置の角度 (0=真下・時計回り。省略すると 90=左)。stroke.marker は両端の矢印の有無 (既定: 終点だけ)。',
|
|
56
|
+
'x-id-start': 100,
|
|
57
|
+
type: 'array',
|
|
58
|
+
items: {
|
|
59
|
+
type: 'object',
|
|
60
|
+
properties: {
|
|
61
|
+
id: ID,
|
|
62
|
+
from: { $ref: '#/$defs/end' },
|
|
63
|
+
to: { $ref: '#/$defs/end' },
|
|
64
|
+
stroke: {
|
|
65
|
+
type: 'object',
|
|
66
|
+
properties: {
|
|
67
|
+
color: { type: 'string' },
|
|
68
|
+
width: { type: 'number' },
|
|
69
|
+
marker: {
|
|
70
|
+
type: 'object',
|
|
71
|
+
properties: { start: { type: 'boolean' }, end: { type: 'boolean' } },
|
|
72
|
+
},
|
|
73
|
+
},
|
|
74
|
+
},
|
|
75
|
+
},
|
|
76
|
+
required: ['id', 'from', 'to'],
|
|
77
|
+
additionalProperties: true,
|
|
78
|
+
},
|
|
79
|
+
$defs: {
|
|
80
|
+
end: {
|
|
81
|
+
type: 'object',
|
|
82
|
+
properties: {
|
|
83
|
+
id: ID,
|
|
84
|
+
position: { type: 'number' },
|
|
85
|
+
},
|
|
86
|
+
required: ['id'],
|
|
87
|
+
},
|
|
88
|
+
},
|
|
89
|
+
};
|
|
90
|
+
/** コレクション名 → スキーマ */
|
|
91
|
+
export const SCHEMAS = {
|
|
92
|
+
nodes: NODES_SCHEMA,
|
|
93
|
+
edges: EDGES_SCHEMA,
|
|
94
|
+
};
|
package/dist/types.d.ts
ADDED
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
import type { MergePatch, ModelField, ModelFieldType, ModelMove, ModelValues } from '@yanqirenshi/model.core';
|
|
2
|
+
import type { Background, Border, Font, Position, Size, Stroke } from '@yanqirenshi/types';
|
|
3
|
+
/** レコードの id(nodes / edges とも。ノードは子も含めて一意) */
|
|
4
|
+
export type DeploymentId = number | string;
|
|
5
|
+
/** ノードの種類。NODE(通常のノード)か COMPONENT */
|
|
6
|
+
export type DeploymentNodeType = 'NODE' | 'COMPONENT';
|
|
7
|
+
/** ノードのラベル */
|
|
8
|
+
export interface DeploymentNodeLabel {
|
|
9
|
+
text?: string | null;
|
|
10
|
+
position?: Position;
|
|
11
|
+
font?: Font;
|
|
12
|
+
}
|
|
13
|
+
/** ノードのレコード(入れ子可)。ライブラリが解釈しない項目も持てる(index signature) */
|
|
14
|
+
export interface DeploymentNodeRecord {
|
|
15
|
+
id: DeploymentId;
|
|
16
|
+
type?: DeploymentNodeType | string;
|
|
17
|
+
label?: DeploymentNodeLabel | null;
|
|
18
|
+
/** ホバーのツールチップ(SVG title) */
|
|
19
|
+
description?: string | null;
|
|
20
|
+
size?: Size;
|
|
21
|
+
position?: Position;
|
|
22
|
+
padding?: number;
|
|
23
|
+
border?: Border;
|
|
24
|
+
background?: Background;
|
|
25
|
+
/** ノードの左下に出すリンク */
|
|
26
|
+
link?: {
|
|
27
|
+
url?: string | null;
|
|
28
|
+
[key: string]: unknown;
|
|
29
|
+
} | null;
|
|
30
|
+
children?: DeploymentNodeRecord[];
|
|
31
|
+
[key: string]: unknown;
|
|
32
|
+
}
|
|
33
|
+
/** 線の端点。position はノードの中心から見た角度(0=真下・時計回り。90=左 / 180=真上 / 270=右) */
|
|
34
|
+
export interface DeploymentEdgeEnd {
|
|
35
|
+
id: DeploymentId;
|
|
36
|
+
position?: number;
|
|
37
|
+
}
|
|
38
|
+
/** 線の見た目。marker は両端の矢印の有無 */
|
|
39
|
+
export interface DeploymentEdgeStroke extends Stroke {
|
|
40
|
+
marker?: {
|
|
41
|
+
start?: boolean;
|
|
42
|
+
end?: boolean;
|
|
43
|
+
};
|
|
44
|
+
}
|
|
45
|
+
/** 線のレコード */
|
|
46
|
+
export interface DeploymentEdgeRecord {
|
|
47
|
+
id: DeploymentId;
|
|
48
|
+
from: DeploymentEdgeEnd;
|
|
49
|
+
to: DeploymentEdgeEnd;
|
|
50
|
+
stroke?: DeploymentEdgeStroke;
|
|
51
|
+
[key: string]: unknown;
|
|
52
|
+
}
|
|
53
|
+
export type DeploymentRecord = DeploymentNodeRecord | DeploymentEdgeRecord;
|
|
54
|
+
/** 図全体(d3.deployment の data() に渡すもの) */
|
|
55
|
+
export interface DeploymentGraph {
|
|
56
|
+
nodes?: DeploymentNodeRecord[];
|
|
57
|
+
edges?: DeploymentEdgeRecord[];
|
|
58
|
+
}
|
|
59
|
+
/** レコードを置くコレクション */
|
|
60
|
+
export type DeploymentCollection = 'nodes' | 'edges';
|
|
61
|
+
/** JSON Merge Patch(RFC 7386)。null は「その項目を除く」。model.core の MergePatch と同じ(iHub の PATCH /{collection}/{id} が受け取る形) */
|
|
62
|
+
export type { MergePatch };
|
|
63
|
+
/** 保存する変更。利用側は図の種類を知らずにこれを保存すればよい */
|
|
64
|
+
export interface DeploymentChange {
|
|
65
|
+
collection: DeploymentCollection;
|
|
66
|
+
id: DeploymentId;
|
|
67
|
+
patch: MergePatch;
|
|
68
|
+
}
|
|
69
|
+
/** ドラッグの移動量(世界座標。d3.deployment の callbacks.node.dragend が渡す move と同じ) */
|
|
70
|
+
export type DeploymentMove = ModelMove;
|
|
71
|
+
/**
|
|
72
|
+
* 編集できる項目。colonoscope の ColonoscopeField(path / label / type)と同じ形で、
|
|
73
|
+
* 取りうる値の一覧 options だけ足している(型は構造的に互換。colonoscope には依存しない)。
|
|
74
|
+
*/
|
|
75
|
+
export type DeploymentFieldType = ModelFieldType;
|
|
76
|
+
export type DeploymentField = ModelField;
|
|
77
|
+
/** インスペクタの「適用」が渡す値(path → 入力した文字列) */
|
|
78
|
+
export type DeploymentValues = ModelValues;
|
|
79
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"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"}
|
package/dist/types.js
ADDED
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
// model.deployment の公開型。
|
|
2
|
+
//
|
|
3
|
+
// ここで言う「レコード」は、d3.deployment の data() に渡す入力そのもの({ nodes, edges })の 1 要素。
|
|
4
|
+
// iHub では data/deployment/{nodes,edges}.json の 1 要素。d3.deployment が正規化したあとの datum(_id / _core / _position を持つもの)ではない。
|
|
5
|
+
// ノードと線の図なので model.unchi / model.sitemap と形が近い。ラベルは label.text(unchi と同じ。sitemap は label.contents)。
|
|
6
|
+
export {};
|
package/package.json
CHANGED
|
@@ -1,6 +1,56 @@
|
|
|
1
1
|
{
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
2
|
+
"name": "@yanqirenshi/model.deployment",
|
|
3
|
+
"version": "0.1.1",
|
|
4
|
+
"description": "Diagram model for deployment diagrams (d3.deployment) — JSON Schema, consistency rules, drawing defaults, editable fields and patch conversion. Pure data and functions: no React / d3 dependency",
|
|
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/cjs/index.js"
|
|
14
|
+
}
|
|
15
|
+
},
|
|
16
|
+
"files": [
|
|
17
|
+
"dist",
|
|
18
|
+
"src"
|
|
19
|
+
],
|
|
20
|
+
"scripts": {
|
|
21
|
+
"build": "tsc && tsc -p tsconfig.cjs.json && node scripts/cjs-package.cjs",
|
|
22
|
+
"typecheck": "tsc --noEmit",
|
|
23
|
+
"test": "vitest run",
|
|
24
|
+
"prepare": "npm run build",
|
|
25
|
+
"prepublishOnly": "npm run build"
|
|
26
|
+
},
|
|
27
|
+
"repository": {
|
|
28
|
+
"type": "git",
|
|
29
|
+
"url": "git+https://github.com/Foolsgolds/Assholes.git",
|
|
30
|
+
"directory": "packages/model.deployment"
|
|
31
|
+
},
|
|
32
|
+
"bugs": {
|
|
33
|
+
"url": "https://github.com/Foolsgolds/Assholes/issues"
|
|
34
|
+
},
|
|
35
|
+
"homepage": "https://github.com/Foolsgolds/Assholes/tree/main/packages/model.deployment#readme",
|
|
36
|
+
"publishConfig": {
|
|
37
|
+
"access": "public"
|
|
38
|
+
},
|
|
39
|
+
"dependencies": {
|
|
40
|
+
"@yanqirenshi/model.core": "^0.1.0",
|
|
41
|
+
"@yanqirenshi/types": "^0.1.2"
|
|
42
|
+
},
|
|
43
|
+
"devDependencies": {
|
|
44
|
+
"typescript": "~5.9.3",
|
|
45
|
+
"vitest": "^2.1.8"
|
|
46
|
+
},
|
|
47
|
+
"author": "yanqirenshi@gmail.com",
|
|
48
|
+
"keywords": [
|
|
49
|
+
"diagram",
|
|
50
|
+
"model",
|
|
51
|
+
"json-schema",
|
|
52
|
+
"deployment",
|
|
53
|
+
"d3.deployment"
|
|
54
|
+
],
|
|
55
|
+
"license": "MIT"
|
|
56
|
+
}
|
package/src/check.ts
ADDED
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
// コレクションをまたぐ整合性の検査(id の重複・参照先の存在)。
|
|
2
|
+
// スキーマ(schema.ts)に合っているデータを渡す。戻り値はエラーのメッセージの配列(空なら問題なし)。
|
|
3
|
+
//
|
|
4
|
+
// iHub の server/validation/rules.mjs の checkGraph('deployment', data) と同じ検査・同じ文言。
|
|
5
|
+
// 検査そのものは graph 系(unchi / sitemap / deployment)で共通なので model.core の checkGraph にあり、
|
|
6
|
+
// ここでは model.deployment の型を付けて公開する(#151)。
|
|
7
|
+
// メッセージの先頭はコレクション名で、prefix を渡すと 'deployment/nodes: ...' のように付けられる。
|
|
8
|
+
|
|
9
|
+
import { checkGraph, flattenNodes, findById as findInList } from '@yanqirenshi/model.core';
|
|
10
|
+
|
|
11
|
+
import type { DeploymentGraph, DeploymentId, DeploymentNodeRecord, DeploymentRecord } from './types.js';
|
|
12
|
+
|
|
13
|
+
/** 入れ子のノード(children)を平らにする(親 → 子 の順) */
|
|
14
|
+
export function flatten(nodes: DeploymentNodeRecord[]): DeploymentNodeRecord[] {
|
|
15
|
+
return flattenNodes(nodes);
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* 図全体を検査する。
|
|
20
|
+
* - nodes(子を含む)の id が重複していない
|
|
21
|
+
* - edges の id が重複していない
|
|
22
|
+
* - edges の from.id / to.id がノードに存在する
|
|
23
|
+
*
|
|
24
|
+
* @param prefix メッセージのコレクション名の前に付ける文字列(例: 'deployment/')
|
|
25
|
+
*/
|
|
26
|
+
export function check(data: DeploymentGraph, prefix = ''): string[] {
|
|
27
|
+
return checkGraph(data, prefix);
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
/** ノード(子を含む)か線を id で探す(無ければ null) */
|
|
31
|
+
export function findById<T extends DeploymentRecord>(list: readonly T[] | undefined, id: DeploymentId): T | null {
|
|
32
|
+
return findInList(list, id);
|
|
33
|
+
}
|