@mawaru/sdk 0.19.0 → 0.21.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.
@@ -776,7 +776,7 @@ describe("saveGraphBodySchema(hooks)", () => {
776
776
  on_output: false,
777
777
  })
778
778
 
779
- it("program ノードの hooks 配列を受け付ける(省略時は [] が補われる)", () => {
779
+ it("hooks 配列を受け付ける(省略時は [] が補われる)", () => {
780
780
  const withHooks = {
781
781
  ...programNode(),
782
782
  hooks: [hook(), { ...hook("通知"), ref: "main" }],
@@ -795,14 +795,13 @@ describe("saveGraphBodySchema(hooks)", () => {
795
795
  expect(without.nodes[0]?.hooks).toEqual([])
796
796
  })
797
797
 
798
- it("program 以外のノードへの hooks を拒否する", () => {
798
+ it("program 以外のノードにも hooks をアタッチできる", () => {
799
799
  for (const node of [makeNode(), humanNode()]) {
800
- expect(() =>
801
- saveGraphBodySchema.parse({
802
- nodes: [{ ...node, hooks: [hook()] }],
803
- connections: [],
804
- }),
805
- ).toThrow(/program ノード/)
800
+ const parsed = saveGraphBodySchema.parse({
801
+ nodes: [{ ...node, hooks: [hook()] }],
802
+ connections: [],
803
+ })
804
+ expect(parsed.nodes[0]?.hooks).toHaveLength(1)
806
805
  }
807
806
  })
808
807
 
package/_schemas/graph.ts CHANGED
@@ -208,7 +208,7 @@ export const componentConfigSchema = z.object({
208
208
  })
209
209
  export type ComponentConfig = z.infer<typeof componentConfigSchema>
210
210
 
211
- // ノードにアタッチされた IOHook(node_hooks に対応。アタッチできるのは program ノードのみ)。
211
+ // ノードにアタッチされた IOHook(node_hooks に対応。アタッチは全 kind で可能)。
212
212
  // on_input / on_output / on_signal はアタッチ時に repo の config.json(hookManifestSchema)から
213
213
  // エディタが焼き込むスナップショット。ref 省略時はデフォルトブランチ
214
214
  // (docs/tasks/done/NodeIOHooks(ノードへのIOフックのアタッチ).md・
@@ -275,6 +275,9 @@ export const graphNodeSchema = z.object({
275
275
  // (カタログは非公開。@mawaru/common の slack-view.ts)。省略時は従来表示。
276
276
  // ポートの型には一切影響しない
277
277
  slack_view: z.string().min(1).optional(),
278
+ // Slack の完了メッセージにデータを残すか(false = 1行に畳む)。
279
+ // 省略時は defaultSlackKeepData(kind) が入る
280
+ slack_keep_data: z.boolean().optional(),
278
281
  // kind 別設定(自 kind のときだけ意味を持つ。省略時は保存側がデフォルトを補う)
279
282
  wait: waitConfigSchema.optional(),
280
283
  program: programConfigSchema.optional(),
@@ -284,6 +287,13 @@ export const graphNodeSchema = z.object({
284
287
  })
285
288
  export type GraphNode = z.infer<typeof graphNodeSchema>
286
289
 
290
+ // slack_keep_data の省略時の値。エディタのノード雛形と graph 保存の両方がここを見る
291
+ // (DB には常に具体値が入り、「既定に従う」という状態は persist しない)。
292
+ // 構造ノードは run の入力・結果そのものなので残し、それ以外は畳む:中間ノードの完了まで
293
+ // データで埋まるとスレッドが読めなくなる
294
+ export const defaultSlackKeepData = (kind: string): boolean =>
295
+ kind === "start" || kind === "end"
296
+
287
297
  // 手動ルートの折れ点(loop 座標系の絶対座標)。connection の waypoints に並べる
288
298
  // (docs/tasks/wip/connection線ルートの手動編集(ウェイポイント).md)
289
299
  export const waypointSchema = z.object({ x: z.number(), y: z.number() })
@@ -385,15 +395,6 @@ export const saveGraphBodySchema = z
385
395
  })
386
396
  }
387
397
 
388
- // フックをアタッチできるのは program ノードのみ
389
- if (node.kind !== "program" && node.hooks.length > 0) {
390
- ctx.addIssue({
391
- code: "custom",
392
- path: ["nodes", i, "hooks"],
393
- message: "フックをアタッチできるのは program ノードだけです",
394
- })
395
- }
396
-
397
398
  // フックの重複アタッチ(unique(node_id, hook_dir) の事前検証)
398
399
  const hookDirs = new Set<string>()
399
400
  node.hooks.forEach((hook, j) => {
@@ -174,6 +174,7 @@ export declare const graphNodeSchema: z.ZodObject<{
174
174
  image_url: z.ZodURL;
175
175
  }, z.core.$strict>]>>;
176
176
  slack_view: z.ZodOptional<z.ZodString>;
177
+ slack_keep_data: z.ZodOptional<z.ZodBoolean>;
177
178
  wait: z.ZodOptional<z.ZodDiscriminatedUnion<[z.ZodObject<{
178
179
  wait_type: z.ZodLiteral<"duration">;
179
180
  duration_seconds: z.ZodNumber;
@@ -212,6 +213,7 @@ export declare const graphNodeSchema: z.ZodObject<{
212
213
  }, z.core.$strip>>;
213
214
  }, z.core.$strip>;
214
215
  export type GraphNode = z.infer<typeof graphNodeSchema>;
216
+ export declare const defaultSlackKeepData: (kind: string) => boolean;
215
217
  export declare const waypointSchema: z.ZodObject<{
216
218
  x: z.ZodNumber;
217
219
  y: z.ZodNumber;
@@ -274,6 +276,7 @@ export declare const saveGraphBodySchema: z.ZodObject<{
274
276
  image_url: z.ZodURL;
275
277
  }, z.core.$strict>]>>;
276
278
  slack_view: z.ZodOptional<z.ZodString>;
279
+ slack_keep_data: z.ZodOptional<z.ZodBoolean>;
277
280
  wait: z.ZodOptional<z.ZodDiscriminatedUnion<[z.ZodObject<{
278
281
  wait_type: z.ZodLiteral<"duration">;
279
282
  duration_seconds: z.ZodNumber;
@@ -161,7 +161,7 @@ export const componentConfigSchema = z.object({
161
161
  // 起動時の mergeRefs が行う。コンポーネントの設定値(refs)と1ノードのコンポーネント化.md)
162
162
  refs: z.record(z.string(), z.unknown()).optional(),
163
163
  });
164
- // ノードにアタッチされた IOHook(node_hooks に対応。アタッチできるのは program ノードのみ)。
164
+ // ノードにアタッチされた IOHook(node_hooks に対応。アタッチは全 kind で可能)。
165
165
  // on_input / on_output / on_signal はアタッチ時に repo の config.json(hookManifestSchema)から
166
166
  // エディタが焼き込むスナップショット。ref 省略時はデフォルトブランチ
167
167
  // (docs/tasks/done/NodeIOHooks(ノードへのIOフックのアタッチ).md・
@@ -219,6 +219,9 @@ export const graphNodeSchema = z.object({
219
219
  // (カタログは非公開。@mawaru/common の slack-view.ts)。省略時は従来表示。
220
220
  // ポートの型には一切影響しない
221
221
  slack_view: z.string().min(1).optional(),
222
+ // Slack の完了メッセージにデータを残すか(false = 1行に畳む)。
223
+ // 省略時は defaultSlackKeepData(kind) が入る
224
+ slack_keep_data: z.boolean().optional(),
222
225
  // kind 別設定(自 kind のときだけ意味を持つ。省略時は保存側がデフォルトを補う)
223
226
  wait: waitConfigSchema.optional(),
224
227
  program: programConfigSchema.optional(),
@@ -226,6 +229,11 @@ export const graphNodeSchema = z.object({
226
229
  human: humanConfigSchema.optional(),
227
230
  component: componentConfigSchema.optional(),
228
231
  });
232
+ // slack_keep_data の省略時の値。エディタのノード雛形と graph 保存の両方がここを見る
233
+ // (DB には常に具体値が入り、「既定に従う」という状態は persist しない)。
234
+ // 構造ノードは run の入力・結果そのものなので残し、それ以外は畳む:中間ノードの完了まで
235
+ // データで埋まるとスレッドが読めなくなる
236
+ export const defaultSlackKeepData = (kind) => kind === "start" || kind === "end";
229
237
  // 手動ルートの折れ点(loop 座標系の絶対座標)。connection の waypoints に並べる
230
238
  // (docs/tasks/wip/connection線ルートの手動編集(ウェイポイント).md)
231
239
  export const waypointSchema = z.object({ x: z.number(), y: z.number() });
@@ -318,14 +326,6 @@ export const saveGraphBodySchema = z
318
326
  message: "out ポートが最低1つ必要です",
319
327
  });
320
328
  }
321
- // フックをアタッチできるのは program ノードのみ
322
- if (node.kind !== "program" && node.hooks.length > 0) {
323
- ctx.addIssue({
324
- code: "custom",
325
- path: ["nodes", i, "hooks"],
326
- message: "フックをアタッチできるのは program ノードだけです",
327
- });
328
- }
329
329
  // フックの重複アタッチ(unique(node_id, hook_dir) の事前検証)
330
330
  const hookDirs = new Set();
331
331
  node.hooks.forEach((hook, j) => {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mawaru/sdk",
3
- "version": "0.19.0",
3
+ "version": "0.21.0",
4
4
  "description": "mawaru 実行 repo の開発 SDK。契約スキーマ(config.json 規約・ループ graph API)の正 + typegen / validate CLI",
5
5
  "type": "module",
6
6
  "bin": {