Skip to content

improvement(templates): make it top-level route and change management/editing process - #1834

Merged
icecrasher321 merged 36 commits into
stagingfrom
improvements/templates-refactor
Nov 8, 2025
Merged

improvement(templates): make it top-level route and change management/editing process#1834
icecrasher321 merged 36 commits into
stagingfrom
improvements/templates-refactor

Conversation

@icecrasher321

@icecrasher321icecrasher321 commented Nov 7, 2025

Copy link
Copy Markdown
Collaborator

Summary

New system for Templates to be based on creator profiles and public accessibility.

Type of Change

  • New feature

Testing

Tested manually.

Checklist

  • Code follows project style guidelines
  • Self-reviewed my changes
  • Tests added/updated and passing
  • No new warnings introduced
  • I confirm that I have read and agree to the terms outlined in the Contributor License Agreement (CLA)

waleedlatif1and others added 20 commits October 11, 2025 22:23
* improvement(performance): remove unused source/target indices, add index on snapshot id (#1603)
* fix(blog): rename building to blogs with redirect (#1604)
* improvement(privacy-policy): updated privacy policy for google (#1602)
* updated privacy policy for google
* update terms, privacy, and emails to incl address and update verbiage
* feat(guardrails): added guardrails block/tools and docs (#1605)
* Adding guardrails block
* ack PR comments
* cleanup checkbox in dark mode
* cleanup
* fix supabase tools
* fix(inference-billing): fix inference billing when stream is true via API, add drag-and-drop functionality to deployed chat (#1606)
* fix(inference): fix inference billing when stream is true via API
* add drag-and-drop to deployed chat
* feat(mistal): added mistral as a provider, updated model prices (#1607)
* feat(mistal): added mistral as a provider, updated model prices
* remove the ability for a block to reference its own outluts
* fixed order of responses for guardrails block
* feat(versions): added the ability to rename deployment versions (#1610)
* fix(vulns): fix various vulnerabilities and enhanced code security (#1611)
* fix(vulns): fix SSRF vulnerabilities
* cleanup
* cleanup
* regen docs
* remove unused deps
* fix failing tests
* cleanup
* update deps
* regen bun lock
* fix(debug-mode): remove duplicate debug mode flag (#1714)
* feat(i18n): update translations (#1709)
* improvement(condition): added variable and envvar highlighting for condition input (#1718)
* fix(dashboard): add additional context for paginated logs in dashboard, add empty state when selected cell has no data (#1719)
* fix(dashboard): add additional context for paginated logs in dashboard, add empty state when selected cell has no data
* apps/sim
* renaming
* remove relative import
* feat(tools): added webflow OAuth + tools (#1720)
* feat(tools): added webflow OAuth + tools
* remove itemId from delete item
* remove siteId
* added webhook triggers + oauth scopes + site/collection selector
* update sample payload for webflow triggers
* cleanup
* fix discord color
* feat(i18n): update translations (#1721)
* improvement(schedule): fix UI bug with schedule modal (#1722)
* fix(already-cancelled-sub): UI should allow restoring subscription
* restore functionality fixed
* fix
@vercel

vercelBot commented Nov 7, 2025

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

ProjectDeploymentPreviewCommentsUpdated (UTC)
docsReadyReadyPreviewCommentNov 8, 2025 1:57am

@icecrasher321
icecrasher321 marked this pull request as ready for review November 8, 2025 01:37

@greptile-appsgreptile-appsBot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Greptile Overview

Greptile Summary

This PR transforms templates from user-owned resources to a public marketplace with creator profiles and approval workflow.

Key Changes

  • Database restructure: New template_creators table separates creator identity from templates, supporting both user and organization profiles. Templates table drops user ownership and category-based organization in favor of status-based approval workflow (pending, approved, rejected)

  • Approval workflow: All new templates start as pending and require super user approval before becoming publicly visible. Super users can approve/reject templates through new API endpoints

  • Creator profiles: Users and organizations can create branded profiles with social links, profile pictures, and descriptions. Templates are published under these profiles, enabling professional branding

  • Credential extraction: New credential-extractor.ts utility identifies OAuth and secret requirements in workflows, sanitizes credentials from template state, and stores requirements separately for users to configure when using templates

  • Public access: /templates route is now public (no auth required) for SEO and discovery. Middleware allows unauthenticated access, and pages handle both logged-in and anonymous users

  • Template management: Templates can be "used" in two modes: (1) copy mode creates a new workflow with regenerated IDs, or (2) connect mode links the template to an editable workflow. Updates to connected workflows can sync back to templates via explicit "Update Template" action

  • Super user system: New isSuperUser flag on users with superUserModeEnabled setting to toggle the mode on/off in UI

Issues Found

None - the implementation is thorough and well-structured.

Confidence Score: 4/5

  • This PR is safe to merge with minimal risk - comprehensive refactor with proper authorization and data sanitization
  • Score reflects a well-architected feature with strong security controls (super user approval, creator profile permissions, credential sanitization) and thorough implementation across database, API, and UI layers. The migration safely drops columns while adding new structures. Minor caution warranted due to: (1) large scope touching 53 files, (2) breaking schema changes requiring careful deployment coordination, and (3) complex workflow state manipulation logic that could have edge cases in production
  • Pay close attention to packages/db/migrations/0107_silky_agent_brand.sql to ensure existing template data migration strategy is planned, and apps/sim/lib/workflows/credential-extractor.ts for edge cases in credential detection across different block types

Important Files Changed

File Analysis

FilenameScoreOverview
packages/db/schema.ts4/5Major restructure of templates table: removes user-based ownership, adds creator profiles, approval workflow, and credential tracking
packages/db/migrations/0107_silky_agent_brand.sql4/5Database migration creates template_creators table, drops old template columns, and restructures relationships
apps/sim/app/api/templates/route.ts4/5Major refactor: templates now require deployment, use creator profiles, extract/sanitize credentials, and start with pending status
apps/sim/app/api/templates/[id]/route.ts4/5Updated GET/PUT/DELETE with creator profile authorization, public access for approved templates, and state synchronization
apps/sim/app/api/creator-profiles/route.ts5/5New creator profile API with user/org permissions, duplicate prevention, and proper validation
apps/sim/lib/workflows/credential-extractor.ts5/5New utility for extracting credential requirements and sanitizing workflow state for sharing/templates
apps/sim/middleware.ts5/5Added public access to /templates route for SEO and unauthenticated viewing
apps/sim/app/templates/page.tsx5/5New top-level public template page with super user mode support and approval status filtering

Sequence Diagram

sequenceDiagram
participant User
participant Browser
participant Middleware
participant TemplatesPage
participant TemplateAPI
participant CreatorProfileAPI
participant DB
participant WorkflowAPI
Note over User,WorkflowAPI: Template Publishing Flow
User->>Browser: Navigate to Settings
Browser->>CreatorProfileAPI: GET /api/creator-profiles
CreatorProfileAPI->>DB: Query template_creators
DB-->>CreatorProfileAPI: Return profiles
CreatorProfileAPI-->>Browser: Creator profiles
User->>Browser: Create/Update Creator Profile
Browser->>CreatorProfileAPI: POST /api/creator-profiles
CreatorProfileAPI->>DB: Verify permissions (user/org membership)
CreatorProfileAPI->>DB: Insert/Update template_creators
DB-->>CreatorProfileAPI: Profile created
CreatorProfileAPI-->>Browser: Success
User->>Browser: Deploy Workflow as Template
Browser->>TemplateAPI: POST /api/templates
TemplateAPI->>DB: Verify workflow deployed
TemplateAPI->>DB: Verify creator profile permissions
TemplateAPI->>WorkflowAPI: GET active deployment version
WorkflowAPI-->>TemplateAPI: Workflow state
TemplateAPI->>TemplateAPI: Extract credentials (extractRequiredCredentials)
TemplateAPI->>TemplateAPI: Sanitize state (sanitizeCredentials)
TemplateAPI->>DB: Insert template (status: pending)
DB-->>TemplateAPI: Template created
TemplateAPI-->>Browser: Template submitted for approval
Note over User,WorkflowAPI: Super User Approval Flow
User->>Browser: View pending templates (super user mode)
Browser->>TemplatesPage: GET /templates?includeAllStatuses=true
TemplatesPage->>DB: Query templates (check isSuperUser)
DB-->>TemplatesPage: All templates
User->>Browser: Approve template
Browser->>TemplateAPI: POST /api/templates/{id}/approve
TemplateAPI->>DB: Verify user is super user
TemplateAPI->>DB: Update template status = approved
DB-->>TemplateAPI: Success
TemplateAPI-->>Browser: Template approved
Note over User,WorkflowAPI: Public Template Viewing Flow
User->>Browser: Navigate to /templates
Browser->>Middleware: Check authentication
Middleware-->>Browser: Allow (public route)
Browser->>TemplatesPage: GET /templates
TemplatesPage->>DB: Query approved templates only
DB-->>TemplatesPage: Approved templates with creators
TemplatesPage-->>Browser: Render template gallery
Note over User,WorkflowAPI: Template Usage Flow
User->>Browser: Click "Use Template"
Browser->>TemplateAPI: POST /api/templates/{id}/use
TemplateAPI->>DB: Get template state
TemplateAPI->>DB: Increment views counter
TemplateAPI->>TemplateAPI: Remap variable IDs
TemplateAPI->>DB: Create new workflow
TemplateAPI->>WorkflowAPI: PUT /api/workflows/{id}/state
WorkflowAPI->>DB: Save workflow state (normalized tables)
WorkflowAPI-->>TemplateAPI: Success
TemplateAPI->>DB: Create deployment version (if connected)
DB-->>TemplateAPI: Workflow created
TemplateAPI-->>Browser: Redirect to workflow editor
Loading

53 files reviewed, no comments

Edit Code Review Agent Settings | Greptile

@icecrasher321
icecrasher321 merged commit a73e2aa into stagingNov 8, 2025
9 checks passed
@waleedlatif1
waleedlatif1 deleted the improvements/templates-refactor branch November 8, 2025 23:27
waleedlatif1 added a commit that referenced this pull request Nov 9, 2025
…/editing process (#1834)
* fix(billing): should allow restoring subscription (#1728)
* fix(already-cancelled-sub): UI should allow restoring subscription
* restore functionality fixed
* fix
* make templates root level url and make it part of deployment system
* separate updating template and deployment versions
* add tags
* add credentials extraction logic + use should import with workflow variables
* fix credential extraction
* add trigger mode indicator
* add starred tracking
* last updated field
* progress on creator profiles
* revert creator profile context type
* progress fix image uploads
* render templates details with creator details
* fix collab rules for workflow edit button
* creator profile perm check improvements
* restore accidental changes
* fix accessibility issues for non logged in users
* remove unused code
* fix type errors
---------
Co-authored-by: Waleed <walif6@gmail.com>
Co-authored-by: Siddharth Ganesan <33737564+Sg312@users.noreply.github.com>
waleedlatif1 added a commit that referenced this pull request Nov 12, 2025
…/editing process (#1834)
* fix(billing): should allow restoring subscription (#1728)
* fix(already-cancelled-sub): UI should allow restoring subscription
* restore functionality fixed
* fix
* make templates root level url and make it part of deployment system
* separate updating template and deployment versions
* add tags
* add credentials extraction logic + use should import with workflow variables
* fix credential extraction
* add trigger mode indicator
* add starred tracking
* last updated field
* progress on creator profiles
* revert creator profile context type
* progress fix image uploads
* render templates details with creator details
* fix collab rules for workflow edit button
* creator profile perm check improvements
* restore accidental changes
* fix accessibility issues for non logged in users
* remove unused code
* fix type errors
---------
Co-authored-by: Waleed <walif6@gmail.com>
Co-authored-by: Siddharth Ganesan <33737564+Sg312@users.noreply.github.com>
@waleedlatif1waleedlatif1 mentioned this pull request Nov 12, 2025
10 tasks
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants

@icecrasher321@waleedlatif1@Sg312