From df34285f62d80cf0e2b5960fe3095d5a99d87ec1 Mon Sep 17 00:00:00 2001 From: JanKulhavy Date: Thu, 16 Apr 2026 17:12:23 +0200 Subject: [PATCH 01/17] test: add mock data files for templates endpoint Co-Authored-By: Claude Opus 4.6 (1M context) --- test/mocks/templates/blueprint.json | 34 +++++++++++++++++++++++++++ test/mocks/templates/get.json | 18 ++++++++++++++ test/mocks/templates/list-public.json | 26 ++++++++++++++++++++ test/mocks/templates/list.json | 26 ++++++++++++++++++++ 4 files changed, 104 insertions(+) create mode 100644 test/mocks/templates/blueprint.json create mode 100644 test/mocks/templates/get.json create mode 100644 test/mocks/templates/list-public.json create mode 100644 test/mocks/templates/list.json diff --git a/test/mocks/templates/blueprint.json b/test/mocks/templates/blueprint.json new file mode 100644 index 0000000..bac9ad4 --- /dev/null +++ b/test/mocks/templates/blueprint.json @@ -0,0 +1,34 @@ +{ + "blueprint": { + "name": "My Private Template", + "flow": [ + { + "id": 1, + "module": "http:ActionSendData", + "version": 3, + "parameters": {}, + "mapper": { + "url": "https://example.com", + "method": "get" + }, + "metadata": { + "expect": [] + } + } + ], + "metadata": { + "version": 1 + } + }, + "controller": { + "name": "My Private Template", + "modules": {}, + "idSequence": 2 + }, + "scheduling": { + "type": "indefinitely", + "interval": 900 + }, + "language": "en", + "metadata": null +} diff --git a/test/mocks/templates/get.json b/test/mocks/templates/get.json new file mode 100644 index 0000000..c555d83 --- /dev/null +++ b/test/mocks/templates/get.json @@ -0,0 +1,18 @@ +{ + "template": { + "id": 61, + "name": "My Private Template", + "teamId": 1, + "description": "A template for testing", + "usedApps": ["http", "json"], + "public": false, + "published": null, + "approved": null, + "approvedId": null, + "requestedApproval": false, + "publishedId": null, + "publicUrl": null, + "approvedName": null, + "publishedName": null + } +} diff --git a/test/mocks/templates/list-public.json b/test/mocks/templates/list-public.json new file mode 100644 index 0000000..bef7656 --- /dev/null +++ b/test/mocks/templates/list-public.json @@ -0,0 +1,26 @@ +{ + "templatesPublic": [ + { + "id": 13, + "name": "Http template example", + "description": null, + "url": "13-http-template-example", + "usedApps": ["http"], + "usage": 321 + }, + { + "id": 17, + "name": "Webhook to Email", + "description": "Send email when webhook is triggered", + "url": "17-webhook-to-email", + "usedApps": ["gateway", "gmail"], + "usage": 52 + } + ], + "pg": { + "sortBy": "usage", + "limit": 100, + "sortDir": "desc", + "offset": 0 + } +} diff --git a/test/mocks/templates/list.json b/test/mocks/templates/list.json new file mode 100644 index 0000000..ad020b5 --- /dev/null +++ b/test/mocks/templates/list.json @@ -0,0 +1,26 @@ +{ + "templates": [ + { + "id": 61, + "name": "My Private Template", + "teamId": 1, + "description": "A template for testing", + "usedApps": ["http", "json"], + "public": false, + "published": null, + "approved": null, + "approvedId": null, + "requestedApproval": false, + "publishedId": null, + "publicUrl": null, + "approvedName": null, + "publishedName": null + } + ], + "pg": { + "sortBy": "name", + "limit": 10, + "sortDir": "asc", + "offset": 0 + } +} From 48602c556e24d9f34d54463d1ee3e3bc5c69ec5c Mon Sep 17 00:00:00 2001 From: JanKulhavy Date: Thu, 16 Apr 2026 17:15:45 +0200 Subject: [PATCH 02/17] feat: add Templates endpoint class and unit tests Co-Authored-By: Claude Opus 4.6 (1M context) --- src/endpoints/templates.ts | 267 +++++++++++++++++++++++++++++++++++++ test/templates.spec.ts | 45 +++++++ 2 files changed, 312 insertions(+) create mode 100644 src/endpoints/templates.ts create mode 100644 test/templates.spec.ts diff --git a/src/endpoints/templates.ts b/src/endpoints/templates.ts new file mode 100644 index 0000000..40df1bc --- /dev/null +++ b/src/endpoints/templates.ts @@ -0,0 +1,267 @@ +import type { FetchFunction, Pagination, PickColumns } from '../types.js'; + +/** + * Represents a private team-scoped template in Make. + * Templates allow users to create reusable scenario configurations + * that can optionally be shared publicly or submitted for approval. + */ +export type Template = { + /** Unique identifier of the template */ + id: number; + /** Name of the template */ + name: string; + /** ID of the team that owns the template */ + teamId: number; + /** Human-readable description of what the template does, or null if not set */ + description: string | null; + /** List of app identifiers used in the template */ + usedApps: string[]; + /** Whether the template has been made publicly visible */ + public: boolean; + /** ISO timestamp when the template was published, or null if not published */ + published: string | null; + /** ISO timestamp when the template was approved, or null if not approved */ + approved: string | null; + /** ID of the approving user, or null if not approved */ + approvedId: number | null; + /** Whether approval has been requested for the template, or null if not applicable */ + requestedApproval: boolean | null; + /** ID of the publishing user, or null if not published */ + publishedId: number | null; + /** Public URL slug of the template, or null if not published */ + publicUrl: string | null; + /** Name of the approving user, or null if not approved */ + approvedName: string | null; + /** Name of the publishing user, or null if not published */ + publishedName: string | null; +}; + +/** + * Represents a publicly available approved template in Make. + * Public templates can be discovered and used by all Make users. + */ +export type TemplatePublic = { + /** Unique identifier of the public template */ + id: number; + /** Name of the public template */ + name: string; + /** Human-readable description of what the 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 template */ + usedApps: string[]; + /** Number of times this template has been used */ + usage: number; +}; + +/** + * Represents the blueprint (scenario definition) extracted from a template. + * Contains the full scenario configuration including flow, scheduling, and metadata. + */ +export type TemplateBlueprint = { + /** The scenario blueprint definition */ + blueprint: Record; + /** Controller configuration for the scenario */ + controller: Record; + /** Scheduling configuration for the scenario */ + scheduling: Record; + /** Language code for the template */ + language: string; + /** Additional metadata for the template, or null if not set */ + metadata: Record | null; +}; + +/** + * Options for listing private team templates. + * @template C Keys of the Template type to include in the response + */ +export type ListTemplatesOptions = { + /** Specific columns/fields to include in the response */ + cols?: C[] | ['*']; + /** Pagination options */ + pg?: Partial>; + /** Filter templates by team ID */ + teamId?: number; + /** Filter by whether the template is public */ + public?: boolean; + /** Filter templates by apps used */ + usedApps?: string[]; +}; + +/** + * Options for listing public approved templates. + * @template C Keys of the TemplatePublic type to include in the response + */ +export type ListTemplatesPublicOptions = { + /** Specific columns/fields to include in the response */ + cols?: C[] | ['*']; + /** Pagination options */ + pg?: Partial>; + /** Search templates by name */ + name?: string; + /** Filter templates by apps used */ + usedApps?: string[]; + /** Whether to include English-language templates in results */ + includeEn?: boolean; +}; + +/** + * Options for getting a single template. + * @template C Keys of the Template type to include in the response + */ +export type GetTemplateOptions = { + /** Specific columns/fields to include in the response */ + cols?: C[] | ['*']; +}; + +/** + * Options for getting a template blueprint. + */ +export type GetTemplateBlueprintOptions = { + /** Whether to retrieve the blueprint for immediate use in a new scenario */ + forUse?: boolean; + /** ID of the public template to retrieve the blueprint for */ + templatePublicId?: number; +}; + +/** + * Response format for listing private templates. + */ +type ListTemplatesResponse = { + /** List of templates matching the query */ + templates: PickColumns[]; + /** Pagination information */ + pg: Pagination