@nodetool-ai/project-services 0.8.9-beta.2 → 0.8.9-beta.4
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/.nodetool-build-stamp +1 -1
- package/dist/asset-autosave.d.ts +80 -0
- package/dist/asset-autosave.d.ts.map +1 -0
- package/dist/asset-autosave.js +456 -0
- package/dist/asset-autosave.js.map +1 -0
- package/dist/example-catalog.d.ts +11 -0
- package/dist/example-catalog.d.ts.map +1 -0
- package/dist/example-catalog.js +154 -0
- package/dist/example-catalog.js.map +1 -0
- package/dist/example-thumbnail.d.ts +21 -0
- package/dist/example-thumbnail.d.ts.map +1 -0
- package/dist/example-thumbnail.js +50 -0
- package/dist/example-thumbnail.js.map +1 -0
- package/dist/example-workflows.d.ts +22 -0
- package/dist/example-workflows.d.ts.map +1 -0
- package/dist/example-workflows.js +141 -0
- package/dist/example-workflows.js.map +1 -0
- package/dist/examples/nodetool-base/50 Ad Variants Overnight.json +270 -0
- package/dist/examples/nodetool-base/A Campaign Concept from a Brief.json +135 -0
- package/dist/examples/nodetool-base/A Gradient Card as PNG.json +128 -0
- package/dist/examples/nodetool-base/A Poster in Portrait.json +129 -0
- package/dist/examples/nodetool-base/A Repeating Texture Tile.json +129 -0
- package/dist/examples/nodetool-base/A Run Button for Any Job.json +152 -0
- package/dist/examples/nodetool-base/A Webhook That Answers.json +170 -0
- package/dist/examples/nodetool-base/AI Spokesperson.json +328 -0
- package/dist/examples/nodetool-base/Action Items from a Meeting Recording.json +198 -0
- package/dist/examples/nodetool-base/Ad Copy in Three Registers.json +135 -0
- package/dist/examples/nodetool-base/Ad Loop from a Product Photo.json +277 -0
- package/dist/examples/nodetool-base/Add Reverb to a Voice.json +125 -0
- package/dist/examples/nodetool-base/Album Art from a Mood.json +129 -0
- package/dist/examples/nodetool-base/Assemble a UGC Product Video.json +158 -0
- package/dist/examples/nodetool-base/Audio To Image.json +184 -0
- package/dist/examples/nodetool-base/B-Roll Reel from a Brief.json +339 -0
- package/dist/examples/nodetool-base/Batch a List.json +171 -0
- package/dist/examples/nodetool-base/Black and White, Hard.json +147 -0
- package/dist/examples/nodetool-base/Blog Post to Social Thread.json +135 -0
- package/dist/examples/nodetool-base/Blur a Channel.json +205 -0
- package/dist/examples/nodetool-base/Blur an Image.json +179 -0
- package/dist/examples/nodetool-base/Boost Saturation.json +178 -0
- package/dist/examples/nodetool-base/Brand Asset Generator.json +585 -0
- package/dist/examples/nodetool-base/Brand a UGC Product Video.json +402 -0
- package/dist/examples/nodetool-base/Bring a Still to Life.json +250 -0
- package/dist/examples/nodetool-base/Bullet Points to Press Release.json +135 -0
- package/dist/examples/nodetool-base/Camera Move Contact Sheet.json +210 -0
- package/dist/examples/nodetool-base/Camera Move.json +257 -0
- package/dist/examples/nodetool-base/Chapter Markers for a Long Recording.json +198 -0
- package/dist/examples/nodetool-base/Character in Any Scene.json +276 -0
- package/dist/examples/nodetool-base/Chat With Your Documents.json +569 -0
- package/dist/examples/nodetool-base/Chunk a Transcript for Indexing.json +202 -0
- package/dist/examples/nodetool-base/Circles and Lines.json +126 -0
- package/dist/examples/nodetool-base/Clean Up a Rough Voice Recording.json +208 -0
- package/dist/examples/nodetool-base/Clip on Kie.json +173 -0
- package/dist/examples/nodetool-base/Cold Outreach Co-Pilot.json +423 -0
- package/dist/examples/nodetool-base/Color Boost Video.json +250 -0
- package/dist/examples/nodetool-base/Compose Directed Campaign Formats.json +764 -0
- package/dist/examples/nodetool-base/Concept Art Iteration Board.json +439 -0
- package/dist/examples/nodetool-base/Concept Art, Then a Moving Version.json +173 -0
- package/dist/examples/nodetool-base/Conditional Logic Engine.json +535 -0
- package/dist/examples/nodetool-base/Consistent Cast Storyboard.json +330 -0
- package/dist/examples/nodetool-base/Count a List.json +168 -0
- package/dist/examples/nodetool-base/Count to Three with a Loop.json +157 -0
- package/dist/examples/nodetool-base/Crop an Image.json +181 -0
- package/dist/examples/nodetool-base/Crop then Fit.json +208 -0
- package/dist/examples/nodetool-base/Crush It to 8 Bits.json +123 -0
- package/dist/examples/nodetool-base/Cut Out the Subject.json +184 -0
- package/dist/examples/nodetool-base/Cut a Landscape Clip for Vertical.json +123 -0
- package/dist/examples/nodetool-base/Cut a Product Out of Its Background.json +238 -0
- package/dist/examples/nodetool-base/Data Generator.json +216 -0
- package/dist/examples/nodetool-base/Denoise Footage.json +178 -0
- package/dist/examples/nodetool-base/Direct a Short Film.json +305 -0
- package/dist/examples/nodetool-base/Directed Film to Timeline.json +385 -0
- package/dist/examples/nodetool-base/Does This Text Mention the Deadline.json +130 -0
- package/dist/examples/nodetool-base/Draft Answers for an FAQ.json +135 -0
- package/dist/examples/nodetool-base/Draw a Badge in SVG.json +126 -0
- package/dist/examples/nodetool-base/Drop Duplicates.json +170 -0
- package/dist/examples/nodetool-base/Drop the First Few.json +148 -0
- package/dist/examples/nodetool-base/Dub a Video into 5 Languages.json +285 -0
- package/dist/examples/nodetool-base/Dungeon and Ruins Starter Pack.json +786 -0
- package/dist/examples/nodetool-base/Edit a Still with Words.json +284 -0
- package/dist/examples/nodetool-base/Editorial Still from a Line.json +197 -0
- package/dist/examples/nodetool-base/Effects Gallery.json +189 -0
- package/dist/examples/nodetool-base/Emboss a Still.json +120 -0
- package/dist/examples/nodetool-base/Every Combination.json +225 -0
- package/dist/examples/nodetool-base/Every Hour, On the Hour.json +162 -0
- package/dist/examples/nodetool-base/Executive Summary of a Long Document.json +135 -0
- package/dist/examples/nodetool-base/Explainer Clip from a Paragraph.json +244 -0
- package/dist/examples/nodetool-base/Extract the Claims Worth Checking.json +135 -0
- package/dist/examples/nodetool-base/Fade Audio In and Out.json +203 -0
- package/dist/examples/nodetool-base/Fade Audio Out.json +202 -0
- package/dist/examples/nodetool-base/Fill a Template.json +149 -0
- package/dist/examples/nodetool-base/Find Every Number in a Sentence.json +127 -0
- package/dist/examples/nodetool-base/Find and Replace.json +224 -0
- package/dist/examples/nodetool-base/Find the Edges.json +123 -0
- package/dist/examples/nodetool-base/Fit an Image.json +179 -0
- package/dist/examples/nodetool-base/Five Headlines for a Landing Page.json +135 -0
- package/dist/examples/nodetool-base/Flashcard Generator.json +297 -0
- package/dist/examples/nodetool-base/Gate Out the Room Noise.json +124 -0
- package/dist/examples/nodetool-base/Generate a Native-Audio UGC Testimonial.json +276 -0
- package/dist/examples/nodetool-base/Generate a Silent Bed.json +126 -0
- package/dist/examples/nodetool-base/Generate then Upscale a Poster.json +164 -0
- package/dist/examples/nodetool-base/Hacker News Agent.json +183 -0
- package/dist/examples/nodetool-base/Hook & Thumbnail Factory.json +498 -0
- package/dist/examples/nodetool-base/How Long Is This Transcript.json +185 -0
- package/dist/examples/nodetool-base/Image Enhance.json +272 -0
- package/dist/examples/nodetool-base/Image To Audio Story.json +180 -0
- package/dist/examples/nodetool-base/Image to Video Animation.json +346 -0
- package/dist/examples/nodetool-base/Inspect a Clip's Audio.json +187 -0
- package/dist/examples/nodetool-base/Inspect a Clip.json +163 -0
- package/dist/examples/nodetool-base/Invert a Still.json +120 -0
- package/dist/examples/nodetool-base/Keep Only the Long Lines.json +220 -0
- package/dist/examples/nodetool-base/Keep Only the Matches.json +148 -0
- package/dist/examples/nodetool-base/Key Out a Green Screen.json +124 -0
- package/dist/examples/nodetool-base/Last One Wins.json +144 -0
- package/dist/examples/nodetool-base/Lens and Look.json +327 -0
- package/dist/examples/nodetool-base/Lip-sync a Clip to a Voice Track.json +313 -0
- package/dist/examples/nodetool-base/Localise a Product Listing.json +135 -0
- package/dist/examples/nodetool-base/Localise a Script and Revoice It.json +242 -0
- package/dist/examples/nodetool-base/Localized Explainer.json +430 -0
- package/dist/examples/nodetool-base/Low-poly Adventure Starter Pack.json +786 -0
- package/dist/examples/nodetool-base/Low-poly Seaside Starter Pack.json +786 -0
- package/dist/examples/nodetool-base/Master a Voice Track.json +180 -0
- package/dist/examples/nodetool-base/Meeting Transcript Summarizer.json +524 -0
- package/dist/examples/nodetool-base/Model Arena.json +550 -0
- package/dist/examples/nodetool-base/Moodboard Frame from a Theme.json +129 -0
- package/dist/examples/nodetool-base/Movie Posters.json +660 -0
- package/dist/examples/nodetool-base/Movie Trailer Generator.json +418 -0
- package/dist/examples/nodetool-base/Music Video Visualizer.json +720 -0
- package/dist/examples/nodetool-base/Name a File from Its Narration.json +231 -0
- package/dist/examples/nodetool-base/Narrate a Script.json +169 -0
- package/dist/examples/nodetool-base/Narration with a Music Bed.json +360 -0
- package/dist/examples/nodetool-base/Normalize a Clip's Audio.json +201 -0
- package/dist/examples/nodetool-base/One Tagline, Six Markets.json +135 -0
- package/dist/examples/nodetool-base/Pad a Canvas.json +188 -0
- package/dist/examples/nodetool-base/Per-SKU Ad Factory.json +511 -0
- package/dist/examples/nodetool-base/Photo Enhancement Suite.json +417 -0
- package/dist/examples/nodetool-base/Picture in Picture.json +231 -0
- package/dist/examples/nodetool-base/Pitch a Voice Up.json +122 -0
- package/dist/examples/nodetool-base/Pixelate a Still.json +122 -0
- package/dist/examples/nodetool-base/Platformer Playground Starter Pack.json +786 -0
- package/dist/examples/nodetool-base/Podcast Episode to Show Notes.json +198 -0
- package/dist/examples/nodetool-base/Podcast Repurposing Studio.json +745 -0
- package/dist/examples/nodetool-base/Pokemon Maker.json +282 -0
- package/dist/examples/nodetool-base/Poster on Kie.json +172 -0
- package/dist/examples/nodetool-base/Posterize to Four Bits.json +122 -0
- package/dist/examples/nodetool-base/Private Assistant.json +236 -0
- package/dist/examples/nodetool-base/Product Mockup Generator.json +608 -0
- package/dist/examples/nodetool-base/Product Spot from Text.json +330 -0
- package/dist/examples/nodetool-base/Product URL to CGI Commercial.json +289 -0
- package/dist/examples/nodetool-base/Product URL to UGC Ad.json +298 -0
- package/dist/examples/nodetool-base/Product Video Generator.json +344 -0
- package/dist/examples/nodetool-base/Prompt Template.json +221 -0
- package/dist/examples/nodetool-base/Propose Three Campaign Directions.json +614 -0
- package/dist/examples/nodetool-base/Pull a Field out of JSON Text.json +128 -0
- package/dist/examples/nodetool-base/Pull a Still from a Clip.json +179 -0
- package/dist/examples/nodetool-base/Pull the Quotable Lines Out of an Interview.json +198 -0
- package/dist/examples/nodetool-base/Put a Product on a Studio Backdrop.json +252 -0
- package/dist/examples/nodetool-base/Put a Voice Over a Music Bed.json +358 -0
- package/dist/examples/nodetool-base/README_EXAMPLES.md +59 -0
- package/dist/examples/nodetool-base/Re-delimit a List.json +199 -0
- package/dist/examples/nodetool-base/Read a Clip's Frame Rate.json +120 -0
- package/dist/examples/nodetool-base/Redact Email Addresses.json +129 -0
- package/dist/examples/nodetool-base/Redact and Tidy a Log Line.json +266 -0
- package/dist/examples/nodetool-base/Relight a Product for a Seasonal Campaign.json +131 -0
- package/dist/examples/nodetool-base/Render a Directed Campaign Hero.json +338 -0
- package/dist/examples/nodetool-base/Reopen a Directed Campaign.json +1748 -0
- package/dist/examples/nodetool-base/Research Agent.json +231 -0
- package/dist/examples/nodetool-base/Research a Brand from Its Website.json +445 -0
- package/dist/examples/nodetool-base/Restyle a Photo as an Illustration.json +136 -0
- package/dist/examples/nodetool-base/Reverse Audio.json +201 -0
- package/dist/examples/nodetool-base/Reverse a Clip.json +176 -0
- package/dist/examples/nodetool-base/Revise an Accepted Campaign Hero.json +486 -0
- package/dist/examples/nodetool-base/Rewrite This So a Customer Understands It.json +135 -0
- package/dist/examples/nodetool-base/Rotate Footage.json +178 -0
- package/dist/examples/nodetool-base/SEO Content Engine.json +708 -0
- package/dist/examples/nodetool-base/SEO Title and Meta Description.json +135 -0
- package/dist/examples/nodetool-base/Sci-fi Game Model Starter Pack.json +693 -0
- package/dist/examples/nodetool-base/Sci-fi Outpost Expansion.json +601 -0
- package/dist/examples/nodetool-base/Score a Clip from Its Own Mood.json +229 -0
- package/dist/examples/nodetool-base/Score a Silent Clip.json +382 -0
- package/dist/examples/nodetool-base/Script to Narrated Clip.json +224 -0
- package/dist/examples/nodetool-base/Script to Screen.json +940 -0
- package/dist/examples/nodetool-base/Sharpen Footage.json +179 -0
- package/dist/examples/nodetool-base/Shot List from a Synopsis.json +136 -0
- package/dist/examples/nodetool-base/Single Shot from a Line.json +199 -0
- package/dist/examples/nodetool-base/Slice Text.json +159 -0
- package/dist/examples/nodetool-base/Slow a Clip Without Dropping Pitch.json +122 -0
- package/dist/examples/nodetool-base/Soften a Plate.json +178 -0
- package/dist/examples/nodetool-base/Solarize a Still.json +122 -0
- package/dist/examples/nodetool-base/Speak a Line, Then Trim the Silence.json +157 -0
- package/dist/examples/nodetool-base/Spin a Packshot into a Turntable Clip.json +137 -0
- package/dist/examples/nodetool-base/Split a Channel.json +178 -0
- package/dist/examples/nodetool-base/Split a Log into Records.json +128 -0
- package/dist/examples/nodetool-base/Stabilize Handheld.json +179 -0
- package/dist/examples/nodetool-base/Still on Replicate.json +172 -0
- package/dist/examples/nodetool-base/Subject Lines Worth Testing.json +135 -0
- package/dist/examples/nodetool-base/Subtitle Lines from a Script.json +170 -0
- package/dist/examples/nodetool-base/Subtitle Text from a Recording.json +198 -0
- package/dist/examples/nodetool-base/Summarise a Recorded Call.json +198 -0
- package/dist/examples/nodetool-base/Swirl and Echo.json +154 -0
- package/dist/examples/nodetool-base/Take While the Numbers Are Small.json +148 -0
- package/dist/examples/nodetool-base/Take a Product Shot to Print Resolution.json +209 -0
- package/dist/examples/nodetool-base/Take the First Few Seconds of a Bed.json +127 -0
- package/dist/examples/nodetool-base/Take the First Few.json +170 -0
- package/dist/examples/nodetool-base/Talking Avatar from a Photo and a Script.json +252 -0
- package/dist/examples/nodetool-base/Telephone Voice.json +174 -0
- package/dist/examples/nodetool-base/Themes Across Customer Feedback.json +135 -0
- package/dist/examples/nodetool-base/Three Ratios.json +315 -0
- package/dist/examples/nodetool-base/Tidy Up Messy Text.json +199 -0
- package/dist/examples/nodetool-base/Top-down Native Asset Pack.json +955 -0
- package/dist/examples/nodetool-base/Trailer Beats from a Premise.json +136 -0
- package/dist/examples/nodetool-base/Train a Character.json +243 -0
- package/dist/examples/nodetool-base/Transcribe Audio.json +138 -0
- package/dist/examples/nodetool-base/Transcribe a Clip.json +198 -0
- package/dist/examples/nodetool-base/Translate Marketing Copy to German.json +135 -0
- package/dist/examples/nodetool-base/Translate a Script for Dubbing.json +224 -0
- package/dist/examples/nodetool-base/Trim Audio to a Range.json +203 -0
- package/dist/examples/nodetool-base/Trim a Blurb to Length.json +128 -0
- package/dist/examples/nodetool-base/Trim a Clip.json +180 -0
- package/dist/examples/nodetool-base/Turn Research Notes into a Comparison Table.json +136 -0
- package/dist/examples/nodetool-base/Turn Specs into Product Copy.json +135 -0
- package/dist/examples/nodetool-base/Turn a Changelog into Release Notes.json +135 -0
- package/dist/examples/nodetool-base/Turn a Logo into Print-Ready Vector.json +126 -0
- package/dist/examples/nodetool-base/Turn a Support Thread into a Bug Report.json +135 -0
- package/dist/examples/nodetool-base/Turn a Talk into a Blog Post.json +198 -0
- package/dist/examples/nodetool-base/Upscale a Still.json +186 -0
- package/dist/examples/nodetool-base/Vectorize a Generated Logo.json +162 -0
- package/dist/examples/nodetool-base/Video Restyle Studio.json +281 -0
- package/dist/examples/nodetool-base/Vignette a Portrait.json +124 -0
- package/dist/examples/nodetool-base/Voice a Script in Two Voices.json +217 -0
- package/dist/examples/nodetool-base/Warm Up a Cold Clip.json +124 -0
- package/dist/examples/nodetool-base/Watch a Folder, Act on What Lands.json +177 -0
- package/dist/examples/nodetool-base/Widen a Mono Voice.json +151 -0
- package/dist/examples/nodetool-base/Workflow As A Tool.json +257 -0
- package/dist/examples/nodetool-base/Write a Listing from the Product Photo.json +139 -0
- package/dist/examples/nodetool-base/Write the Prompt, Then Make the Image.json +200 -0
- package/dist/examples/nodetool-base/gallery_thumbnail_generator.ts +384 -0
- package/dist/mcp-tool-host-deps.d.ts +29 -0
- package/dist/mcp-tool-host-deps.d.ts.map +1 -0
- package/dist/mcp-tool-host-deps.js +69 -0
- package/dist/mcp-tool-host-deps.js.map +1 -0
- package/dist/package-assets.d.ts +41 -0
- package/dist/package-assets.d.ts.map +1 -0
- package/dist/package-assets.js +155 -0
- package/dist/package-assets.js.map +1 -0
- package/dist/project-delete.d.ts +14 -0
- package/dist/project-delete.d.ts.map +1 -0
- package/dist/project-delete.js +66 -0
- package/dist/project-delete.js.map +1 -0
- package/dist/worker-settings-env.d.ts +23 -0
- package/dist/worker-settings-env.d.ts.map +1 -0
- package/dist/worker-settings-env.js +47 -0
- package/dist/worker-settings-env.js.map +1 -0
- package/dist/workflow-runtime-environment.d.ts +20 -0
- package/dist/workflow-runtime-environment.d.ts.map +1 -0
- package/dist/workflow-runtime-environment.js +137 -0
- package/dist/workflow-runtime-environment.js.map +1 -0
- package/package.json +12 -8
|
@@ -0,0 +1,154 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The shipped example workflow catalog: lightweight list entries from the
|
|
3
|
+
* examples directory or the installed Python packages, and the agent-facing
|
|
4
|
+
* catalog the MCP tools read.
|
|
5
|
+
*/
|
|
6
|
+
import { existsSync, readFileSync, readdirSync } from "node:fs";
|
|
7
|
+
import nodePath from "node:path";
|
|
8
|
+
import { createLogger } from "@nodetool-ai/config";
|
|
9
|
+
import { loadPythonPackageMetadata } from "@nodetool-ai/node-sdk";
|
|
10
|
+
import { isObjectLike, isString, scanExampleNeeds } from "@nodetool-ai/protocol";
|
|
11
|
+
import { withCacheBuster } from "./example-thumbnail.js";
|
|
12
|
+
import { deriveExampleAssetsDir, shippedWorkflowExamplesDir } from "./example-workflows.js";
|
|
13
|
+
const log = createLogger("nodetool.examples");
|
|
14
|
+
// ── Workflow examples ──────────────────────────────────────────────────
|
|
15
|
+
/** URL prefix for example workflow thumbnail images served by this API. */
|
|
16
|
+
const EXAMPLES_THUMBNAILS_PREFIX = "/api/workflows/examples/thumbnails/";
|
|
17
|
+
/**
|
|
18
|
+
* Read example workflow metadata from a directory of JSON files.
|
|
19
|
+
* Returns lightweight objects (no graph data) suitable for the /examples list.
|
|
20
|
+
*
|
|
21
|
+
* When the sibling `assets` directory exists (e.g.
|
|
22
|
+
* `packages/base-nodes/nodetool/assets/nodetool-base`), a `thumbnail_url`
|
|
23
|
+
* pointing to `/api/workflows/examples/thumbnails/<name>` is set so the
|
|
24
|
+
* frontend can display the pre-generated JPG thumbnails.
|
|
25
|
+
*/
|
|
26
|
+
function buildExamplesFromDir(examplesDir, examplesAssetsFallbackDir, registry) {
|
|
27
|
+
if (!existsSync(examplesDir))
|
|
28
|
+
return [];
|
|
29
|
+
const assetsDir = deriveExampleAssetsDir(examplesDir, examplesAssetsFallbackDir);
|
|
30
|
+
const now = new Date().toISOString();
|
|
31
|
+
const workflows = [];
|
|
32
|
+
let files;
|
|
33
|
+
try {
|
|
34
|
+
files = readdirSync(examplesDir)
|
|
35
|
+
.filter((f) => f.toLowerCase().endsWith(".json"))
|
|
36
|
+
.sort((a, b) => a.localeCompare(b));
|
|
37
|
+
}
|
|
38
|
+
catch (err) {
|
|
39
|
+
log.warn(`Failed to read examples directory ${examplesDir}: ${err}`);
|
|
40
|
+
return [];
|
|
41
|
+
}
|
|
42
|
+
for (const file of files) {
|
|
43
|
+
try {
|
|
44
|
+
const raw = readFileSync(nodePath.join(examplesDir, file), "utf8");
|
|
45
|
+
const parsed = JSON.parse(raw);
|
|
46
|
+
const name = isString(parsed.name)
|
|
47
|
+
? parsed.name
|
|
48
|
+
: file.replace(/\.json$/i, "");
|
|
49
|
+
// Point thumbnail_url to the served JPG when the file exists in
|
|
50
|
+
// assets. withCacheBuster() appends ?v=<md5-8> so the browser cache
|
|
51
|
+
// invalidates whenever the JPG is regenerated.
|
|
52
|
+
const jpgFile = `${name}.jpg`;
|
|
53
|
+
const jpgPath = nodePath.join(assetsDir, jpgFile);
|
|
54
|
+
const thumbnailUrl = existsSync(jpgPath)
|
|
55
|
+
? withCacheBuster(`${EXAMPLES_THUMBNAILS_PREFIX}${encodeURIComponent(jpgFile)}`, jpgPath)
|
|
56
|
+
: null;
|
|
57
|
+
workflows.push({
|
|
58
|
+
id: file,
|
|
59
|
+
access: "public",
|
|
60
|
+
created_at: now,
|
|
61
|
+
updated_at: now,
|
|
62
|
+
name,
|
|
63
|
+
tool_name: null,
|
|
64
|
+
description: isString(parsed.description) ? parsed.description : "",
|
|
65
|
+
tags: Array.isArray(parsed.tags) ? parsed.tags.filter(isString) : [],
|
|
66
|
+
thumbnail: thumbnailUrl ? jpgFile : null,
|
|
67
|
+
thumbnail_url: thumbnailUrl,
|
|
68
|
+
graph: { nodes: [], edges: [] },
|
|
69
|
+
input_schema: null,
|
|
70
|
+
output_schema: null,
|
|
71
|
+
settings: null,
|
|
72
|
+
package_name: isString(parsed.package_name)
|
|
73
|
+
? parsed.package_name
|
|
74
|
+
: null,
|
|
75
|
+
path: null,
|
|
76
|
+
run_mode: null,
|
|
77
|
+
workspace_id: null,
|
|
78
|
+
required_providers: null,
|
|
79
|
+
required_models: null,
|
|
80
|
+
needs: scanExampleNeeds(parsed.graph, (nodeType) => registry?.getMetadata(nodeType)?.required_settings),
|
|
81
|
+
html_app: null,
|
|
82
|
+
app_doc: isObjectLike(parsed.app_doc) ? parsed.app_doc : null,
|
|
83
|
+
etag: null
|
|
84
|
+
});
|
|
85
|
+
}
|
|
86
|
+
catch (err) {
|
|
87
|
+
log.debug(`Skipping invalid example workflow file ${file}: ${err}`);
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
return workflows;
|
|
91
|
+
}
|
|
92
|
+
export function buildExampleWorkflows(options) {
|
|
93
|
+
if (options.examplesDir) {
|
|
94
|
+
return buildExamplesFromDir(options.examplesDir, options.examplesAssetsFallbackDir, options.registry);
|
|
95
|
+
}
|
|
96
|
+
const loaded = loadPythonPackageMetadata({
|
|
97
|
+
roots: options.metadataRoots,
|
|
98
|
+
maxDepth: options.metadataMaxDepth
|
|
99
|
+
});
|
|
100
|
+
const now = new Date().toISOString();
|
|
101
|
+
const workflows = [];
|
|
102
|
+
for (const pkg of loaded.packages) {
|
|
103
|
+
if (!pkg.examples || pkg.examples.length === 0)
|
|
104
|
+
continue;
|
|
105
|
+
for (const ex of pkg.examples) {
|
|
106
|
+
const meta = ex;
|
|
107
|
+
workflows.push({
|
|
108
|
+
id: meta.id ?? "",
|
|
109
|
+
access: "public",
|
|
110
|
+
created_at: now,
|
|
111
|
+
updated_at: now,
|
|
112
|
+
name: meta.name,
|
|
113
|
+
tool_name: null,
|
|
114
|
+
description: meta.description ?? "",
|
|
115
|
+
tags: meta.tags ?? [],
|
|
116
|
+
thumbnail: null,
|
|
117
|
+
thumbnail_url: null,
|
|
118
|
+
graph: { nodes: [], edges: [] },
|
|
119
|
+
input_schema: null,
|
|
120
|
+
output_schema: null,
|
|
121
|
+
settings: null,
|
|
122
|
+
package_name: pkg.name,
|
|
123
|
+
path: null,
|
|
124
|
+
run_mode: null,
|
|
125
|
+
workspace_id: null,
|
|
126
|
+
required_providers: null,
|
|
127
|
+
required_models: null,
|
|
128
|
+
html_app: null,
|
|
129
|
+
app_doc: null,
|
|
130
|
+
etag: null
|
|
131
|
+
});
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
const shippedDirectory = shippedWorkflowExamplesDir();
|
|
135
|
+
const shipped = shippedDirectory
|
|
136
|
+
? buildExamplesFromDir(shippedDirectory, options.examplesAssetsFallbackDir, options.registry)
|
|
137
|
+
: [];
|
|
138
|
+
const seen = new Set();
|
|
139
|
+
return [...workflows, ...shipped].filter((workflow) => {
|
|
140
|
+
if (!isObjectLike(workflow)) {
|
|
141
|
+
return false;
|
|
142
|
+
}
|
|
143
|
+
const key = JSON.stringify([
|
|
144
|
+
workflow.package_name ?? "nodetool-base",
|
|
145
|
+
isString(workflow.id) && workflow.id !== "" ? workflow.id : workflow.name
|
|
146
|
+
]);
|
|
147
|
+
if (seen.has(key)) {
|
|
148
|
+
return false;
|
|
149
|
+
}
|
|
150
|
+
seen.add(key);
|
|
151
|
+
return true;
|
|
152
|
+
});
|
|
153
|
+
}
|
|
154
|
+
//# sourceMappingURL=example-catalog.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"example-catalog.js","sourceRoot":"","sources":["../src/example-catalog.ts"],"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AAQ,EAAE,IAAI;gBACd,OAAO,EAAE,IAAI;gBACb,IAAI,EAAE,IAAI;aACX,CAAC,CAAC;QACL,CAAC;IACH,CAAC;IACD,MAAM,gBAAgB,GAAG,0BAA0B,EAAE,CAAC;IACtD,MAAM,OAAO,GAAG,gBAAgB;QAC9B,CAAC,CAAC,oBAAoB,CAAC,gBAAgB,EAAE,OAAO,CAAC,yBAAyB,EAAE,OAAO,CAAC,QAAQ,CAAC;QAC7F,CAAC,CAAC,EAAE,CAAC;IACP,MAAM,IAAI,GAAG,IAAI,GAAG,EAAU,CAAC;IAC/B,OAAO,CAAC,GAAG,SAAS,EAAE,GAAG,OAAO,CAAC,CAAC,MAAM,CAAC,CAAC,QAAQ,EAAE,EAAE;QACpD,IAAI,CAAC,YAAY,CAAC,QAAQ,CAAC,EAAE,CAAC;YAC5B,OAAO,KAAK,CAAC;QACf,CAAC;QACD,MAAM,GAAG,GAAG,IAAI,CAAC,SAAS,CAAC;YACzB,QAAQ,CAAC,YAAY,IAAI,eAAe;YACxC,QAAQ,CAAC,QAAQ,CAAC,EAAE,CAAC,IAAI,QAAQ,CAAC,EAAE,KAAK,EAAE,CAAC,CAAC,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC,CAAC,QAAQ,CAAC,IAAI;SAC1E,CAAC,CAAC;QACH,IAAI,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC,EAAE,CAAC;YAClB,OAAO,KAAK,CAAC;QACf,CAAC;QACD,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;QACd,OAAO,IAAI,CAAC;IACd,CAAC,CAAC,CAAC;AACL,CAAC"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Cache-buster for example workflow thumbnail JPGs.
|
|
3
|
+
*
|
|
4
|
+
* Each thumbnail's md5 (first 8 hex chars) is appended to its
|
|
5
|
+
* `thumbnail_url` as `?v=<hash>` so that browsers drop their cached copy
|
|
6
|
+
* whenever the JPG is regenerated. Hashes are cached by `(absPath, mtimeMs)`
|
|
7
|
+
* — re-hashed only when the file is replaced on disk.
|
|
8
|
+
*/
|
|
9
|
+
/**
|
|
10
|
+
* Return the 8-char md5 of `absPath`'s contents, or `null` if the file is
|
|
11
|
+
* missing / unreadable. The result is memoised by `(path, mtime)` so the
|
|
12
|
+
* read+hash happens once per file per process (and once again whenever the
|
|
13
|
+
* file is regenerated).
|
|
14
|
+
*/
|
|
15
|
+
export declare function thumbnailHash(absPath: string): string | null;
|
|
16
|
+
/**
|
|
17
|
+
* Append `?v=<md5-8>` to a thumbnail URL, or return the URL unchanged if
|
|
18
|
+
* the file isn't readable.
|
|
19
|
+
*/
|
|
20
|
+
export declare function withCacheBuster(url: string, absPath: string): string;
|
|
21
|
+
//# sourceMappingURL=example-thumbnail.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"example-thumbnail.d.ts","sourceRoot":"","sources":["../src/example-thumbnail.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAYH;;;;;GAKG;AACH,wBAAgB,aAAa,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAoB5D;AAED;;;GAGG;AACH,wBAAgB,eAAe,CAAC,GAAG,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,GAAG,MAAM,CAGpE"}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Cache-buster for example workflow thumbnail JPGs.
|
|
3
|
+
*
|
|
4
|
+
* Each thumbnail's md5 (first 8 hex chars) is appended to its
|
|
5
|
+
* `thumbnail_url` as `?v=<hash>` so that browsers drop their cached copy
|
|
6
|
+
* whenever the JPG is regenerated. Hashes are cached by `(absPath, mtimeMs)`
|
|
7
|
+
* — re-hashed only when the file is replaced on disk.
|
|
8
|
+
*/
|
|
9
|
+
import { readFileSync, statSync } from "node:fs";
|
|
10
|
+
import { createHash } from "node:crypto";
|
|
11
|
+
const cache = new Map();
|
|
12
|
+
/**
|
|
13
|
+
* Return the 8-char md5 of `absPath`'s contents, or `null` if the file is
|
|
14
|
+
* missing / unreadable. The result is memoised by `(path, mtime)` so the
|
|
15
|
+
* read+hash happens once per file per process (and once again whenever the
|
|
16
|
+
* file is regenerated).
|
|
17
|
+
*/
|
|
18
|
+
export function thumbnailHash(absPath) {
|
|
19
|
+
let stat;
|
|
20
|
+
try {
|
|
21
|
+
stat = statSync(absPath);
|
|
22
|
+
}
|
|
23
|
+
catch {
|
|
24
|
+
return null;
|
|
25
|
+
}
|
|
26
|
+
const cached = cache.get(absPath);
|
|
27
|
+
if (cached && cached.mtimeMs === stat.mtimeMs)
|
|
28
|
+
return cached.hash;
|
|
29
|
+
let hash;
|
|
30
|
+
try {
|
|
31
|
+
hash = createHash("md5")
|
|
32
|
+
.update(readFileSync(absPath))
|
|
33
|
+
.digest("hex")
|
|
34
|
+
.slice(0, 8);
|
|
35
|
+
}
|
|
36
|
+
catch {
|
|
37
|
+
return null;
|
|
38
|
+
}
|
|
39
|
+
cache.set(absPath, { mtimeMs: stat.mtimeMs, hash });
|
|
40
|
+
return hash;
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* Append `?v=<md5-8>` to a thumbnail URL, or return the URL unchanged if
|
|
44
|
+
* the file isn't readable.
|
|
45
|
+
*/
|
|
46
|
+
export function withCacheBuster(url, absPath) {
|
|
47
|
+
const hash = thumbnailHash(absPath);
|
|
48
|
+
return hash ? `${url}?v=${hash}` : url;
|
|
49
|
+
}
|
|
50
|
+
//# sourceMappingURL=example-thumbnail.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"example-thumbnail.js","sourceRoot":"","sources":["../src/example-thumbnail.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,EAAE,YAAY,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAC;AACjD,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAOzC,MAAM,KAAK,GAAG,IAAI,GAAG,EAAsB,CAAC;AAE5C;;;;;GAKG;AACH,MAAM,UAAU,aAAa,CAAC,OAAe;IAC3C,IAAI,IAAiC,CAAC;IACtC,IAAI,CAAC;QACH,IAAI,GAAG,QAAQ,CAAC,OAAO,CAAC,CAAC;IAC3B,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,IAAI,CAAC;IACd,CAAC;IACD,MAAM,MAAM,GAAG,KAAK,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC;IAClC,IAAI,MAAM,IAAI,MAAM,CAAC,OAAO,KAAK,IAAI,CAAC,OAAO;QAAE,OAAO,MAAM,CAAC,IAAI,CAAC;IAClE,IAAI,IAAY,CAAC;IACjB,IAAI,CAAC;QACH,IAAI,GAAG,UAAU,CAAC,KAAK,CAAC;aACrB,MAAM,CAAC,YAAY,CAAC,OAAO,CAAC,CAAC;aAC7B,MAAM,CAAC,KAAK,CAAC;aACb,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;IACjB,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,IAAI,CAAC;IACd,CAAC;IACD,KAAK,CAAC,GAAG,CAAC,OAAO,EAAE,EAAE,OAAO,EAAE,IAAI,CAAC,OAAO,EAAE,IAAI,EAAE,CAAC,CAAC;IACpD,OAAO,IAAI,CAAC;AACd,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,eAAe,CAAC,GAAW,EAAE,OAAe;IAC1D,MAAM,IAAI,GAAG,aAAa,CAAC,OAAO,CAAC,CAAC;IACpC,OAAO,IAAI,CAAC,CAAC,CAAC,GAAG,GAAG,MAAM,IAAI,EAAE,CAAC,CAAC,CAAC,GAAG,CAAC;AACzC,CAAC"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
interface ExampleWorkflowLoadOptions {
|
|
2
|
+
examplesDir?: string;
|
|
3
|
+
/** Fallback thumbnail directory when the sibling of examplesDir has no JPGs. */
|
|
4
|
+
examplesAssetsFallbackDir?: string;
|
|
5
|
+
metadataRoots?: string[];
|
|
6
|
+
metadataMaxDepth?: number;
|
|
7
|
+
}
|
|
8
|
+
/** Default examples shipped inside the npm package or bundled server. */
|
|
9
|
+
export declare function shippedWorkflowExamplesDir(): string | undefined;
|
|
10
|
+
/**
|
|
11
|
+
* Resolve the directory containing gallery thumbnail JPGs/PNGs for an examples dir.
|
|
12
|
+
* Prefer the sibling `assets/<package>` layout; fall back to bundled assets when
|
|
13
|
+
* examples are mounted elsewhere (common in Docker compose overrides).
|
|
14
|
+
*/
|
|
15
|
+
export declare function deriveExampleAssetsDir(examplesDir: string, fallbackAssetsDir?: string | null): string;
|
|
16
|
+
/** Resolve a display name, slug, or filename to an on-disk example JSON path. */
|
|
17
|
+
export declare function resolveExampleJsonPath(examplesDir: string, exampleRef: string): string | null;
|
|
18
|
+
/** Load a full example workflow JSON (including graph) for workflow creation. */
|
|
19
|
+
export declare function loadExampleGraph(packageName: string, exampleRef: string, options?: ExampleWorkflowLoadOptions): Record<string, unknown> | null;
|
|
20
|
+
export declare function defaultExamplePackageName(options: ExampleWorkflowLoadOptions): string | null;
|
|
21
|
+
export {};
|
|
22
|
+
//# sourceMappingURL=example-workflows.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"example-workflows.d.ts","sourceRoot":"","sources":["../src/example-workflows.ts"],"names":[],"mappings":"AAMA,UAAU,0BAA0B;IAClC,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,gFAAgF;IAChF,yBAAyB,CAAC,EAAE,MAAM,CAAC;IACnC,aAAa,CAAC,EAAE,MAAM,EAAE,CAAC;IACzB,gBAAgB,CAAC,EAAE,MAAM,CAAC;CAC3B;AAED,yEAAyE;AACzE,wBAAgB,0BAA0B,IAAI,MAAM,GAAG,SAAS,CAO/D;AAaD;;;;GAIG;AACH,wBAAgB,sBAAsB,CACpC,WAAW,EAAE,MAAM,EACnB,iBAAiB,CAAC,EAAE,MAAM,GAAG,IAAI,GAChC,MAAM,CAiBR;AAED,iFAAiF;AACjF,wBAAgB,sBAAsB,CACpC,WAAW,EAAE,MAAM,EACnB,UAAU,EAAE,MAAM,GACjB,MAAM,GAAG,IAAI,CAwDf;AAyCD,iFAAiF;AACjF,wBAAgB,gBAAgB,CAC9B,WAAW,EAAE,MAAM,EACnB,UAAU,EAAE,MAAM,EAClB,OAAO,GAAE,0BAA+B,GACvC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,IAAI,CAchC;AAED,wBAAgB,yBAAyB,CACvC,OAAO,EAAE,0BAA0B,GAClC,MAAM,GAAG,IAAI,CAMf"}
|
|
@@ -0,0 +1,141 @@
|
|
|
1
|
+
import { existsSync, readFileSync, readdirSync } from "node:fs";
|
|
2
|
+
import nodePath from "node:path";
|
|
3
|
+
import { fileURLToPath } from "node:url";
|
|
4
|
+
import { loadPythonPackageMetadata } from "@nodetool-ai/node-sdk";
|
|
5
|
+
import { isString } from "@nodetool-ai/protocol";
|
|
6
|
+
/** Default examples shipped inside the npm package or bundled server. */
|
|
7
|
+
export function shippedWorkflowExamplesDir() {
|
|
8
|
+
const here = nodePath.dirname(fileURLToPath(import.meta.url));
|
|
9
|
+
const candidates = [
|
|
10
|
+
nodePath.join(here, "examples", "nodetool-base"),
|
|
11
|
+
nodePath.resolve(here, "../../base-nodes/nodetool/examples/nodetool-base")
|
|
12
|
+
];
|
|
13
|
+
return candidates.find((directory) => existsSync(directory));
|
|
14
|
+
}
|
|
15
|
+
function directoryHasGalleryThumbnails(dir) {
|
|
16
|
+
if (!existsSync(dir)) {
|
|
17
|
+
return false;
|
|
18
|
+
}
|
|
19
|
+
try {
|
|
20
|
+
return readdirSync(dir).some((file) => /\.(jpg|jpeg|png)$/i.test(file));
|
|
21
|
+
}
|
|
22
|
+
catch {
|
|
23
|
+
return false;
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* Resolve the directory containing gallery thumbnail JPGs/PNGs for an examples dir.
|
|
28
|
+
* Prefer the sibling `assets/<package>` layout; fall back to bundled assets when
|
|
29
|
+
* examples are mounted elsewhere (common in Docker compose overrides).
|
|
30
|
+
*/
|
|
31
|
+
export function deriveExampleAssetsDir(examplesDir, fallbackAssetsDir) {
|
|
32
|
+
const derived = nodePath.join(nodePath.dirname(nodePath.dirname(examplesDir)), "assets", nodePath.basename(examplesDir));
|
|
33
|
+
if (directoryHasGalleryThumbnails(derived)) {
|
|
34
|
+
return derived;
|
|
35
|
+
}
|
|
36
|
+
if (fallbackAssetsDir &&
|
|
37
|
+
existsSync(fallbackAssetsDir) &&
|
|
38
|
+
directoryHasGalleryThumbnails(fallbackAssetsDir)) {
|
|
39
|
+
return fallbackAssetsDir;
|
|
40
|
+
}
|
|
41
|
+
return derived;
|
|
42
|
+
}
|
|
43
|
+
/** Resolve a display name, slug, or filename to an on-disk example JSON path. */
|
|
44
|
+
export function resolveExampleJsonPath(examplesDir, exampleRef) {
|
|
45
|
+
const ref = exampleRef.trim();
|
|
46
|
+
if (!ref) {
|
|
47
|
+
return null;
|
|
48
|
+
}
|
|
49
|
+
const directCandidates = ref.toLowerCase().endsWith(".json")
|
|
50
|
+
? [nodePath.join(examplesDir, nodePath.basename(ref))]
|
|
51
|
+
: [
|
|
52
|
+
nodePath.join(examplesDir, `${ref}.json`),
|
|
53
|
+
nodePath.join(examplesDir, ref)
|
|
54
|
+
];
|
|
55
|
+
for (const candidate of directCandidates) {
|
|
56
|
+
// The ref is caller input: a candidate outside the examples directory
|
|
57
|
+
// (`../../x`) would read any JSON file on the host.
|
|
58
|
+
const rel = nodePath.relative(examplesDir, candidate);
|
|
59
|
+
if (!rel || rel.startsWith("..") || nodePath.isAbsolute(rel)) {
|
|
60
|
+
continue;
|
|
61
|
+
}
|
|
62
|
+
if (existsSync(candidate)) {
|
|
63
|
+
return candidate;
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
let files;
|
|
67
|
+
try {
|
|
68
|
+
files = readdirSync(examplesDir).filter((file) => file.toLowerCase().endsWith(".json"));
|
|
69
|
+
}
|
|
70
|
+
catch {
|
|
71
|
+
return null;
|
|
72
|
+
}
|
|
73
|
+
for (const file of files) {
|
|
74
|
+
if (file === ref || file === `${ref}.json`) {
|
|
75
|
+
return nodePath.join(examplesDir, file);
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
for (const file of files) {
|
|
79
|
+
try {
|
|
80
|
+
const raw = readFileSync(nodePath.join(examplesDir, file), "utf8");
|
|
81
|
+
const parsed = JSON.parse(raw);
|
|
82
|
+
if (isString(parsed.name) && parsed.name === ref) {
|
|
83
|
+
return nodePath.join(examplesDir, file);
|
|
84
|
+
}
|
|
85
|
+
if (isString(parsed.id) && parsed.id === ref) {
|
|
86
|
+
return nodePath.join(examplesDir, file);
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
catch {
|
|
90
|
+
// skip invalid example files
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
return null;
|
|
94
|
+
}
|
|
95
|
+
function loadExampleGraphFromDir(examplesDir, exampleRef) {
|
|
96
|
+
const examplePath = resolveExampleJsonPath(examplesDir, exampleRef);
|
|
97
|
+
if (!examplePath) {
|
|
98
|
+
return null;
|
|
99
|
+
}
|
|
100
|
+
try {
|
|
101
|
+
const raw = readFileSync(examplePath, "utf8");
|
|
102
|
+
return JSON.parse(raw);
|
|
103
|
+
}
|
|
104
|
+
catch {
|
|
105
|
+
return null;
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
function loadExampleGraphFromPythonPackage(packageName, exampleRef, options) {
|
|
109
|
+
const loaded = loadPythonPackageMetadata({
|
|
110
|
+
roots: options.metadataRoots,
|
|
111
|
+
maxDepth: options.metadataMaxDepth
|
|
112
|
+
});
|
|
113
|
+
const pkg = loaded.packages.find((p) => p.name === packageName);
|
|
114
|
+
if (!pkg?.sourceFolder) {
|
|
115
|
+
return null;
|
|
116
|
+
}
|
|
117
|
+
const examplesDir = nodePath.join(pkg.sourceFolder, "nodetool", "examples", pkg.name);
|
|
118
|
+
return loadExampleGraphFromDir(examplesDir, exampleRef);
|
|
119
|
+
}
|
|
120
|
+
/** Load a full example workflow JSON (including graph) for workflow creation. */
|
|
121
|
+
export function loadExampleGraph(packageName, exampleRef, options = {}) {
|
|
122
|
+
const examplesDir = options.examplesDir ?? shippedWorkflowExamplesDir();
|
|
123
|
+
if (examplesDir && existsSync(examplesDir) && (options.examplesDir || !packageName || packageName === nodePath.basename(examplesDir))) {
|
|
124
|
+
const fromDir = loadExampleGraphFromDir(examplesDir, exampleRef);
|
|
125
|
+
if (fromDir) {
|
|
126
|
+
return fromDir;
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
if (packageName) {
|
|
130
|
+
return loadExampleGraphFromPythonPackage(packageName, exampleRef, options);
|
|
131
|
+
}
|
|
132
|
+
return null;
|
|
133
|
+
}
|
|
134
|
+
export function defaultExamplePackageName(options) {
|
|
135
|
+
const examplesDir = options.examplesDir ?? shippedWorkflowExamplesDir();
|
|
136
|
+
if (examplesDir && existsSync(examplesDir)) {
|
|
137
|
+
return nodePath.basename(examplesDir);
|
|
138
|
+
}
|
|
139
|
+
return null;
|
|
140
|
+
}
|
|
141
|
+
//# sourceMappingURL=example-workflows.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"example-workflows.js","sourceRoot":"","sources":["../src/example-workflows.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,YAAY,EAAE,WAAW,EAAE,MAAM,SAAS,CAAC;AAChE,OAAO,QAAQ,MAAM,WAAW,CAAC;AACjC,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AACzC,OAAO,EAAE,yBAAyB,EAAE,MAAM,uBAAuB,CAAC;AAClE,OAAO,EAAE,QAAQ,EAAE,MAAM,uBAAuB,CAAC;AAUjD,yEAAyE;AACzE,MAAM,UAAU,0BAA0B;IACxC,MAAM,IAAI,GAAG,QAAQ,CAAC,OAAO,CAAC,aAAa,CAAC,OAAO,IAAI,CAAC,GAAG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