Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 20 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
name: Test Make app contracts

on:
pull_request:
push:
branches:
- main

permissions:
contents: read

jobs:
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: 22
- run: npm test
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ This integration follows the same lightweight pattern as OpnForm's Activepieces
## Structure

```
├── app.json # App metadata
├── base.iml.json # Shared API base URL, authorization, errors, and log sanitization
├── connection/
│ ├── parameters.json # Connection dialog fields (API key)
│ └── communication.json # Auth validation (GET /open/workspaces)
Expand Down Expand Up @@ -68,8 +68,8 @@ Docs: [developers.make.com/custom-apps-documentation](https://developers.make.co

1. Install the [Make Apps Editor](https://marketplace.visualstudio.com/items?itemName=Integromat.apps-sdk) VS Code extension
2. Generate a Make API key with `sdk-apps` scopes from your Make account
3. Connect the extension and sync the configs from this repo
4. Edit and test locally, then push changes to Make
3. Connect the extension to the existing Make app using the `Production` origin in `makecomapp.json`
4. Run `npm test`, then deploy the configs to the Testing origin before Production

## Related

Expand Down
11 changes: 0 additions & 11 deletions app.json

This file was deleted.

17 changes: 17 additions & 0 deletions base.iml.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
{
"baseUrl": "{{ifempty(connection.baseUrl, 'https://api.opnform.com')}}",
"headers": {
"Authorization": "Bearer {{connection.apiKey}}",
"Accept": "application/json"
},
"response": {
"error": {
"message": "[{{statusCode}}] {{ifempty(body.message, ifempty(body.error, 'Request failed'))}}"
}
},
"log": {
"sanitize": [
"request.headers.authorization"
]
}
}
Binary file modified icon/base.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
6 changes: 3 additions & 3 deletions makecomapp.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"fileVersion": 1,
"generalCodeFiles": {
"base": "app.json",
"base": "base.iml.json",
"common": null,
"readme": "README.md",
"groups": null
Expand Down Expand Up @@ -107,9 +107,9 @@
{
"label": "Production",
"baseUrl": "https://eu1.make.com/api",
"appId": "opnform",
"appId": "opnform-65ly55",
"appVersion": 1,
"apikeyFile": ".secrets/apikey"
}
]
}
}
5 changes: 5 additions & 0 deletions modules/watchNewSubmissions/interface.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,11 @@
"type": "uinteger",
"label": "Submission ID"
},
{
"name": "edit_link",
"type": "url",
"label": "Edit Submission URL"
},
{
"name": "data",
"type": "collection",
Expand Down
1 change: 1 addition & 0 deletions modules/watchNewSubmissions/samples.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
"form_title": "Contact Form",
"form_slug": "contact-form",
"submission_id": 42,
"edit_link": "https://opnform.com/forms/contact-form?submission_id=example",
"data": {
"a5e98088-a4af-4efc-ad01-ce9ef8adb0c6": {
"value": "Jane Doe",
Expand Down
7 changes: 7 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"name": "@opnform/make-integration",
"private": true,
"scripts": {
"test": "node --test tests/*.test.mjs"
}
}
12 changes: 3 additions & 9 deletions rpcs/listForms.json
Original file line number Diff line number Diff line change
@@ -1,12 +1,6 @@
{
"url": "{{ifempty(connection.baseUrl, 'https://api.opnform.com')}}/open/workspaces/{{parameters.workspaceId}}/forms",
"url": "/open/workspaces/{{parameters.workspaceId}}/forms",
"method": "GET",
"headers": {
"Authorization": "Bearer {{connection.apiKey}}"
},
"qs": {
"page": "{{parameters.page}}"
},
"response": {
"output": {
"label": "{{item.title}}",
Expand All @@ -16,7 +10,7 @@
},
"pagination": {
"mergeWithParent": true,
"url": "{{body.next_page_url}}",
"condition": "{{body.next_page_url}}"
"url": "{{body.links.next}}",
"condition": "{{body.links.next}}"
}
}
5 changes: 1 addition & 4 deletions rpcs/listWorkspaces.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
{
"url": "{{ifempty(connection.baseUrl, 'https://api.opnform.com')}}/open/workspaces",
"headers": {
"Authorization": "Bearer {{connection.apiKey}}"
},
"url": "/open/workspaces",
"response": {
"output": {
"label": "{{item.name}}",
Expand Down
71 changes: 71 additions & 0 deletions tests/contracts.test.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
import assert from 'node:assert/strict'
import { readFile } from 'node:fs/promises'
import test from 'node:test'

const readJson = async (path) => JSON.parse(await readFile(new URL(`../${path}`, import.meta.url), 'utf8'))

test('base inherits the self-hosted URL and protects the API key', async () => {
const base = await readJson('base.iml.json')

assert.match(base.baseUrl, /connection\.baseUrl/)
assert.equal(base.headers.Authorization, 'Bearer {{connection.apiKey}}')
assert.deepEqual(base.log.sanitize, ['request.headers.authorization'])
assert.ok(base.response.error.message)
})

test('production origin targets the real Make app', async () => {
const manifest = await readJson('makecomapp.json')
const production = manifest.origins.find(({ label }) => label === 'Production')

assert.equal(manifest.generalCodeFiles.base, 'base.iml.json')
assert.equal(production.appId, 'opnform-65ly55')
})

test('attached webhook persists and reuses the remote integration id', async () => {
const attach = await readJson('webhook/attach.json')
const detach = await readJson('webhook/detach.json')

assert.equal(attach.response.data.externalHookId, '{{body.form_integration.id}}')
assert.match(detach.url, /{{webhook\.externalHookId}}/)
assert.doesNotMatch(detach.url, /webhook\.data/)
})

test('form RPC follows the Laravel resource pagination envelope', async () => {
const rpc = await readJson('rpcs/listForms.json')
const response = {
data: [{ id: 1, title: 'First form' }],
links: { next: 'https://api.opnform.com/open/workspaces/1/forms?page=2' },
meta: { current_page: 1, last_page: 2 }
}

assert.equal(rpc.response.iterate, '{{body.data}}')
assert.equal(rpc.pagination.url, '{{body.links.next}}')
assert.equal(rpc.pagination.condition, '{{body.links.next}}')
assert.equal(response.links.next.endsWith('page=2'), true)
assert.equal(response.next_page_url, undefined)
assert.equal(rpc.qs, undefined)
})

test('trigger interface exposes dynamic fields and optional edit link', async () => {
const output = await readJson('modules/watchNewSubmissions/interface.json')
const data = output.find(({ name }) => name === 'data')
const editLink = output.find(({ name }) => name === 'edit_link')

assert.deepEqual(data.spec, [])
assert.equal(editLink.type, 'url')
})

test('Make requests use relative open API paths inherited from Base', async () => {
const paths = [
'rpcs/listWorkspaces.json',
'rpcs/listForms.json',
'webhook/attach.json',
'webhook/detach.json'
]

for (const path of paths) {
const request = await readJson(path)
assert.match(request.url, /^\/open\//)
assert.doesNotMatch(request.url, /external\/make/)
}
})
6 changes: 2 additions & 4 deletions webhook/attach.json
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
{
"url": "{{ifempty(connection.baseUrl, 'https://api.opnform.com')}}/open/forms/{{parameters.formId}}/integrations",
"url": "/open/forms/{{parameters.formId}}/integrations",
"method": "POST",
"headers": {
"Authorization": "Bearer {{connection.apiKey}}",
"Content-Type": "application/json",
"Accept": "application/json"
"Content-Type": "application/json"
},
"body": {
"integration_id": "make",
Expand Down
8 changes: 2 additions & 6 deletions webhook/detach.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,4 @@
{
"url": "{{ifempty(connection.baseUrl, 'https://api.opnform.com')}}/open/forms/{{parameters.formId}}/integrations/{{webhook.data.externalHookId}}",
"method": "DELETE",
"headers": {
"Authorization": "Bearer {{connection.apiKey}}",
"Accept": "application/json"
}
"url": "/open/forms/{{parameters.formId}}/integrations/{{webhook.externalHookId}}",
"method": "DELETE"
}
Loading