Làm ứng dụng mở rộng

Ứng dụng chạy trên máy chủ của bạn. Gym Master gọi ứng dụng để vẽ thẻ trong hồ sơ, mở trang, thêm nút và chạy bước ⚡ — trên web và điện thoại, bằng giao diện của Gym Master.

Từ máy trắng tới thẻ hiện được

terminal
gymmaster login
gymmaster app init my-app        # nextx.app.json + sample server
gymmaster app link <client_id>   # the OAuth app you created in the console
gymmaster app validate           # schema + platform rules, all errors at once
gymmaster app deploy             # immutable version; installed workspaces get it immediately
gymmaster app preview card:gym.member.sidebar:1 --record <member_id>
gymmaster app logs -f            # every call we make to your app
gymmaster app check              # publish checklist (exit 1 while something is red)

nextx.app.json

Một tệp khai mọi thứ app làm. Schema công khai: /schema/app/v1.json · /schema/blocks/v1.json

nextx.app.json
{
  "$schema": "https://developers.nextx.vn/schema/app/v1.json",
  "app": "fitness-test",
  "version": "1.0.0",
  "type": "private",
  "name": { "vi": "Đo thể lực", "en": "Fitness test" },
  "auth": { "scopes": ["gym.members.view"] },
  "support": { "email": "[email protected]", "privacy": "https://example.com/privacy" },
  "webhooks": { "url": "https://api.example.com/hook", "events": [] },
  "extensions": [
    { "type": "card", "surface": "gym.member.sidebar", "title": { "vi": "Thể lực" },
      "fetch": "https://api.example.com/cards/member", "mobile": true }
  ],
  "automation": {
    "actions": [{ "key": "send_result", "label": { "vi": "Gửi kết quả đo" },
      "inputs": [{ "key": "member", "type": "ref:gym.member", "required": true }],
      "url": "https://api.example.com/actions/send-result" }],
    "triggers": [{ "key": "test_done", "label": { "vi": "Khi đo xong" },
      "subject": "gym.member", "payload": { "score": "number" } }]
  }
}

Chỗ cắm

Chỗ cắmỞ đâu
crm.contact.sidebar · crm.contact.tabHồ sơ khách (web + điện thoại)
crm.deal.sidebarThương vụ
sales.order.sidebar · sales.order.bulkĐơn bán · chọn nhiều đơn
gym.member.sidebarHồ sơ hội viên (web + điện thoại)
chat.conversation.sidebar · chat.composerChi tiết hội thoại · ô soạn tin
<object>.moreMenu ⋯ của hồ sơ
nav.<module>Nhóm Ứng dụng ▾ của phân hệ
home.todayTrang Hôm nay

Thẻ

node
// POST {fetch} — called from our servers, Authorization: Bearer <context ticket>
app.post("/cards/member", async (req, res) => {
  const ticket = await verifyTicket(req.headers.authorization); // JWKS https://api.nextx.vn/.well-known/nextx-app-jwks.json, aud = your client_id
  const memberId = req.body.record.id;
  res.json({
    ttl: 60,
    blocks: [
      { type: "stat", items: [{ label: "Score", value: 82, format: "number" }] },
      { type: "button", label: "New test", action: { kind: "action", key: "new_test" } }
    ]
  });
});
Giới hạn: 3 giây (tính cả cấp vé), 32 KB, 40 khối, không chuyển hướng, chỉ địa chỉ công khai. 5 lỗi liên tiếp ⇒ ngừng gọi app 60 giây. Đệm theo ttl (≤ 300 giây) và theo từng người xem.

Hành động + trình kích hoạt ⚡

Hành động: ta POST tới url của bạn với inputs (đã ép đúng kiểu khai), subject và Idempotency-Key giữ nguyên qua mọi lần retry. 408/429/5xx/hết giờ (10 giây) ⇒ retry sau 1, 5, 30 phút; 4xx khác ⇒ hỏng ngay, câu error.message hiện trong nhật ký lượt chạy.

Trình kích hoạt: app gọi bằng token cài app.

curl
curl -X POST https://api.nextx.vn/api/v1/apps/triggers/test_done \
  -H "Authorization: Bearer $INSTALL_TOKEN" -H "Idempotency-Key: test-8812" \
  -H "Content-Type: application/json" \
  -d '{"subject":{"type":"gym.member","id":"M-00042"},"payload":{"score":82}}'

Công bố lên chợ

Mục kiểmNgưỡng
Bản khai đã deploy, email hỗ trợ, chính sách riêng tư HTTPS✓
iframe chỉ từ HTTPS công khai✓
Nhận app.data_erasure_requested (webhooks.url)48 giờ sau khi gỡ
Thẻ P95 (7 ngày)< 1.5 s
Tỉ lệ lỗi thẻ (7 ngày)< 2%