-
Notifications
You must be signed in to change notification settings - Fork 9
feat: Templates endpoint (public templates) #55
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
19 commits
Select commit
Hold shift + click to select a range
df34285
test: add mock data files for templates endpoint
JanKulhavy 48602c5
feat: add Templates endpoint class and unit tests
JanKulhavy fe24fea
feat: wire Templates endpoint into Make client and exports
JanKulhavy c2861c5
style: align listPublic with codebase conventions
JanKulhavy 62af959
feat: add MCP tool definitions for templates endpoint
JanKulhavy 21ca17a
test: add integration tests for templates endpoint
JanKulhavy b237c0b
chore: format templates files and fix conditional expects
JanKulhavy 4d9ce92
feat: add getPublic and getPublicBlueprint methods for templates
JanKulhavy 4d853ca
refactor(templates): drop private templates, keep public only
JanKulhavy 9a6c6a7
chore(scripts): add usedApps filter to templates smoke test
JanKulhavy b672277
remove: file
JanKulhavy b7161bb
feat(templates): update template names and enhance documentation for …
JanKulhavy ab9c170
feat(templates): rename templates to public-templates and update rela…
JanKulhavy b2d609b
Merge branch 'main' into feat/templates
JanKulhavy d333930
Update src/endpoints/public-templates.mcp.ts
JanKulhavy c710f30
Merge remote-tracking branch 'origin/main' into feat/templates
JanKulhavy d9e6142
Update test/public-templates.integration.test.ts
patriksimek 87d394e
refactor: rename templates to publicTemplates for consistency
patriksimek 82fe4fb
refactor: rename templates to publicTemplates for consistency
patriksimek File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,92 @@ | ||
| import type { Make } from '../make.js'; | ||
|
|
||
| export const tools = [ | ||
| { | ||
| name: 'public-templates_list', | ||
| title: 'List public templates', | ||
| description: | ||
| 'Search and list public (approved) templates available for anyone. Supports name-based search for template discovery. Results are sorted by usage by default.', | ||
| category: 'public-templates', | ||
| scope: 'templates:read', | ||
| annotations: { | ||
| readOnlyHint: true, | ||
| }, | ||
| inputSchema: { | ||
| type: 'object', | ||
| properties: { | ||
| name: { type: 'string', description: 'Search public templates by name' }, | ||
| usedApps: { | ||
| type: 'array', | ||
| items: { type: 'string' }, | ||
| description: 'Filter public templates by apps used', | ||
| }, | ||
| includeEn: { | ||
| type: 'boolean', | ||
| description: 'Whether to include English-language public templates in results', | ||
| }, | ||
| }, | ||
| }, | ||
| examples: [{ name: 'webhook' }], | ||
| execute: async (make: Make, args?: { name?: string; usedApps?: string[]; includeEn?: boolean }) => { | ||
| return await make.publicTemplates.list({ ...(args ?? {}), cols: ['*'] }); | ||
| }, | ||
| }, | ||
| { | ||
| name: 'public-templates_get', | ||
| title: 'Get public template', | ||
| description: | ||
| 'Get details of a public template by its URL slug (e.g. "12289-add-webhook-data-to-a-google-sheet"). Use this for templates discovered via public-templates_list.', | ||
| category: 'public-templates', | ||
| scope: 'templates:read', | ||
| scopeId: 'templateUrl', | ||
| identifier: 'templateUrl', | ||
| resourceId: 'templateUrl', | ||
| annotations: { | ||
| readOnlyHint: true, | ||
| }, | ||
| inputSchema: { | ||
| type: 'object', | ||
| properties: { | ||
| templateUrl: { | ||
| type: 'string', | ||
| description: | ||
| 'The URL slug of the public template (e.g. "12289-add-webhook-data-to-a-google-sheet")', | ||
| }, | ||
| }, | ||
| required: ['templateUrl'], | ||
| }, | ||
| examples: [{ templateUrl: '12289-add-webhook-data-to-a-google-sheet' }], | ||
| execute: async (make: Make, args: { templateUrl: string }) => { | ||
| return await make.publicTemplates.get(args.templateUrl, { cols: ['*'] }); | ||
| }, | ||
| }, | ||
| { | ||
| name: 'public-templates_get-blueprint', | ||
| title: 'Get public template blueprint', | ||
| description: | ||
| 'Get the full blueprint of a public template including scenario flow, controller configuration, scheduling, and metadata. Use this for templates discovered via public-templates_list.', | ||
| category: 'public-templates', | ||
| scope: 'templates:read', | ||
| scopeId: 'templateUrl', | ||
| identifier: 'templateUrl', | ||
| resourceId: 'templateUrl', | ||
| annotations: { | ||
| readOnlyHint: true, | ||
| }, | ||
| inputSchema: { | ||
| type: 'object', | ||
| properties: { | ||
| templateUrl: { | ||
| type: 'string', | ||
| description: | ||
| 'The URL slug of the public template (e.g. "12289-add-webhook-data-to-a-google-sheet")', | ||
| }, | ||
| }, | ||
| required: ['templateUrl'], | ||
| }, | ||
| examples: [{ templateUrl: '12289-add-webhook-data-to-a-google-sheet' }], | ||
| execute: async (make: Make, args: { templateUrl: string }) => { | ||
| return await make.publicTemplates.getBlueprint(args.templateUrl); | ||
| }, | ||
| }, | ||
| ]; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,180 @@ | ||
| import type { FetchFunction, Pagination, PickColumns } from '../types.js'; | ||
| import type { Blueprint } from './blueprints.js'; | ||
| import type { Scheduling } from './scenarios.js'; | ||
|
|
||
| /** | ||
| * Represents a publicly available approved template in Make. | ||
| * Public templates can be discovered and used by all Make users. | ||
| */ | ||
| export type PublicTemplate = { | ||
| /** Unique identifier of the public template */ | ||
| id: number; | ||
| /** Name of the public template */ | ||
| name: string; | ||
| /** Human-readable description of what the public template does, or null if not set */ | ||
| description: string | null; | ||
| /** URL slug identifying this public template */ | ||
| url: string; | ||
| /** List of app identifiers used in the public template */ | ||
| usedApps: string[]; | ||
| /** Number of times this public template has been used */ | ||
| usage: number; | ||
| }; | ||
|
|
||
| /** | ||
| * Blueprint payload returned by the public-template blueprint endpoint. | ||
| * Wraps the scenario blueprint together with its scheduling and controller configuration. | ||
| */ | ||
| export type PublicTemplateBlueprint = { | ||
| /** The scenario blueprint definition (modules, flow, metadata). Scheduling is exposed at the top level of this payload instead. */ | ||
| blueprint: Omit<Blueprint, 'scheduling' | 'interface'>; | ||
| /** Controller configuration for the scenario */ | ||
| controller: { | ||
| /** Controller name */ | ||
| name: string; | ||
| /** Controller-tracked module state, keyed by module ID */ | ||
| modules: Record<string, unknown>; | ||
| /** Next ID to assign when adding a module */ | ||
| idSequence: number; | ||
| }; | ||
| /** Scheduling configuration for the scenario */ | ||
| scheduling: Scheduling; | ||
| /** Language code for the public template (e.g. "en") */ | ||
| language: string; | ||
| /** Additional metadata for the public template, or null if not set */ | ||
| metadata: Record<string, unknown> | null; | ||
| }; | ||
|
|
||
| /** | ||
| * Options for listing public (approved) templates. | ||
| * @template C Keys of the PublicTemplate type to include in the response | ||
| */ | ||
| export type ListPublicTemplatesOptions<C extends keyof PublicTemplate = never> = { | ||
| /** Specific columns/fields to include in the response */ | ||
| cols?: C[] | ['*']; | ||
| /** Pagination options */ | ||
| pg?: Partial<Pagination<PublicTemplate>>; | ||
| /** Search public templates by name */ | ||
| name?: string; | ||
| /** Filter public templates by apps used */ | ||
| usedApps?: string[]; | ||
| /** Whether to include English-language public templates in results */ | ||
| includeEn?: boolean; | ||
| }; | ||
|
|
||
| /** | ||
| * Options for getting a single public template. | ||
| * @template C Keys of the PublicTemplate type to include in the response | ||
| */ | ||
| export type GetPublicTemplateOptions<C extends keyof PublicTemplate = never> = { | ||
| /** Specific columns/fields to include in the response */ | ||
| cols?: C[] | ['*']; | ||
| }; | ||
|
|
||
| /** | ||
| * Response format for listing public templates. | ||
| */ | ||
| type ListPublicTemplatesResponse<C extends keyof PublicTemplate = never> = { | ||
| /** List of public templates matching the query */ | ||
| templatesPublic: PickColumns<PublicTemplate, C>[]; | ||
| /** Pagination information */ | ||
| pg: Pagination<PublicTemplate>; | ||
| }; | ||
|
|
||
| /** | ||
| * Response format for getting a single public template. | ||
| */ | ||
| type GetPublicTemplateResponse<C extends keyof PublicTemplate = never> = { | ||
| /** The requested public template */ | ||
| templatePublic: PickColumns<PublicTemplate, C>; | ||
| }; | ||
|
|
||
| /** | ||
| * Class providing methods for working with public Make templates. | ||
| * Public templates are approved scenario configurations that can be | ||
| * discovered and used by any Make user. | ||
| */ | ||
| export class PublicTemplates { | ||
| readonly #fetch: FetchFunction; | ||
|
|
||
| /** | ||
| * Create a new PublicTemplates instance. | ||
| * @param fetch Function for making API requests | ||
| */ | ||
| constructor(fetch: FetchFunction) { | ||
| this.#fetch = fetch; | ||
| } | ||
|
|
||
| /** | ||
| * List public (approved) templates available for anyone. | ||
| * Supports name-based search for template discovery. | ||
| * Results are sorted by usage in descending order by default. | ||
| * @param options Optional parameters for searching, filtering, and pagination | ||
| * @returns Promise with the list of public templates | ||
| * | ||
| * @example | ||
| * ```typescript | ||
| * // Search public templates by name | ||
| * const templates = await make.publicTemplates.list({ name: 'webhook' }); | ||
| * | ||
| * // Filter by apps used | ||
| * const gmailTemplates = await make.publicTemplates.list({ usedApps: ['gmail'] }); | ||
| * ``` | ||
| */ | ||
| async list<C extends keyof PublicTemplate = never>( | ||
| options: ListPublicTemplatesOptions<C> = {}, | ||
| ): Promise<PickColumns<PublicTemplate, C>[]> { | ||
| return ( | ||
| await this.#fetch<ListPublicTemplatesResponse<C>>('/templates/public', { | ||
| query: { | ||
| name: options.name, | ||
| usedApps: options.usedApps, | ||
| includeEn: options.includeEn, | ||
| cols: options.cols, | ||
| pg: options.pg, | ||
| }, | ||
| }) | ||
| ).templatesPublic; | ||
| } | ||
|
|
||
| /** | ||
| * Get a single public template by its URL slug. | ||
| * Use this for templates discovered via {@link list}. | ||
| * @param templateUrl The URL slug of the template (e.g. "12289-add-webhook-data-to-a-google-sheet") | ||
| * @param options Optional parameters for field selection | ||
| * @returns Promise with the public template details | ||
| * | ||
| * @example | ||
| * ```typescript | ||
| * const template = await make.publicTemplates.get('12289-add-webhook-data-to-a-google-sheet'); | ||
| * ``` | ||
| */ | ||
| async get<C extends keyof PublicTemplate = never>( | ||
| templateUrl: string, | ||
| options: GetPublicTemplateOptions<C> = {}, | ||
| ): Promise<PickColumns<PublicTemplate, C>> { | ||
| return ( | ||
| await this.#fetch<GetPublicTemplateResponse<C>>(`/templates/public/${templateUrl}`, { | ||
| query: { | ||
| cols: options.cols, | ||
| }, | ||
| }) | ||
| ).templatePublic; | ||
| } | ||
|
|
||
| /** | ||
| * Get the blueprint (scenario definition) for a public template by its URL slug. | ||
| * The full response object is returned directly since the API returns a flat | ||
| * structure rather than wrapping the blueprint in a named property. | ||
| * @param templateUrl The URL slug of the template (e.g. "12289-add-webhook-data-to-a-google-sheet") | ||
| * @returns Promise with the full blueprint response | ||
| * | ||
| * @example | ||
| * ```typescript | ||
| * const blueprint = await make.publicTemplates.getBlueprint('12289-add-webhook-data-to-a-google-sheet'); | ||
| * ``` | ||
| */ | ||
| async getBlueprint(templateUrl: string): Promise<PublicTemplateBlueprint> { | ||
| return await this.#fetch<PublicTemplateBlueprint>(`/templates/public/${templateUrl}/blueprint`); | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,34 @@ | ||
| { | ||
| "blueprint": { | ||
| "name": "Http template example", | ||
| "flow": [ | ||
| { | ||
| "id": 1, | ||
| "module": "http:ActionSendData", | ||
| "version": 3, | ||
| "parameters": {}, | ||
| "mapper": { | ||
| "url": "https://example.com", | ||
| "method": "get" | ||
| }, | ||
| "metadata": { | ||
| "expect": [] | ||
| } | ||
| } | ||
| ], | ||
| "metadata": { | ||
| "version": 1 | ||
| } | ||
| }, | ||
| "controller": { | ||
| "name": "Http template example", | ||
| "modules": {}, | ||
| "idSequence": 2 | ||
| }, | ||
| "scheduling": { | ||
| "type": "indefinitely", | ||
| "interval": 900 | ||
| }, | ||
| "language": "en", | ||
| "metadata": null | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,10 @@ | ||
| { | ||
| "templatePublic": { | ||
| "id": 13, | ||
| "name": "Http template example", | ||
| "description": null, | ||
| "url": "13-http-template-example", | ||
| "usedApps": ["http"], | ||
| "usage": 321 | ||
| } | ||
| } |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.