@myapihq/cli 1.2.4 → 1.2.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,86 @@
1
+ // 2026-05-15 additive changes for my-webhook-api:
2
+ // - POST /webhook/orgs/{org_id}/endpoints body now accepts forward_url.
3
+ // - PATCH /webhook/orgs/{org_id}/endpoints/{id} is a new endpoint.
4
+ //
5
+ // Both surfaced through the SDK (createEndpoint+forward_url, updateEndpoint).
6
+ import { describe, it, expect, beforeEach, afterEach, vi } from 'vitest';
7
+ import { webhook } from '@myapihq/sdk';
8
+ const API_KEY = 'myapi_test';
9
+ const ORG_ID = '11111111-1111-4111-8111-111111111111';
10
+ const ENDPOINT_ID = '22222222-2222-4222-8222-222222222222';
11
+ let fetchMock;
12
+ function ok(data) {
13
+ return new Response(JSON.stringify({ success: true, data, meta: {} }), {
14
+ status: 200,
15
+ headers: { 'content-type': 'application/json' },
16
+ });
17
+ }
18
+ beforeEach(() => {
19
+ fetchMock = vi.fn().mockResolvedValue(ok({
20
+ id: ENDPOINT_ID, org_id: ORG_ID, name: 'x', slug: 'abc', url: 'https://webhook/in/abc',
21
+ }));
22
+ globalThis.fetch = fetchMock;
23
+ });
24
+ afterEach(() => {
25
+ vi.restoreAllMocks();
26
+ });
27
+ describe('webhook.createEndpoint — forward_url (additive 2026-05-15)', () => {
28
+ it('omits forward_url by default (back-compat)', async () => {
29
+ await webhook.createEndpoint(API_KEY, ORG_ID, 'my-hook');
30
+ const body = JSON.parse(fetchMock.mock.calls[0][1].body);
31
+ expect(body).toEqual({ name: 'my-hook' });
32
+ expect(body).not.toHaveProperty('forward_url');
33
+ });
34
+ it('includes forward_url when passed', async () => {
35
+ await webhook.createEndpoint(API_KEY, ORG_ID, 'my-hook', {
36
+ forward_url: 'https://example.com/forward',
37
+ });
38
+ const body = JSON.parse(fetchMock.mock.calls[0][1].body);
39
+ expect(body.forward_url).toBe('https://example.com/forward');
40
+ });
41
+ it('allows explicit empty string for forward_url (clears it)', async () => {
42
+ await webhook.createEndpoint(API_KEY, ORG_ID, 'my-hook', { forward_url: '' });
43
+ const body = JSON.parse(fetchMock.mock.calls[0][1].body);
44
+ expect(body).toHaveProperty('forward_url', '');
45
+ });
46
+ it('combines forward_url with other options', async () => {
47
+ await webhook.createEndpoint(API_KEY, ORG_ID, 'my-hook', {
48
+ description: 'Stripe events',
49
+ crm_email_path: 'data.object.customer_email',
50
+ forward_url: 'https://example.com/forward',
51
+ });
52
+ const body = JSON.parse(fetchMock.mock.calls[0][1].body);
53
+ expect(body).toEqual({
54
+ name: 'my-hook',
55
+ description: 'Stripe events',
56
+ crm_email_path: 'data.object.customer_email',
57
+ forward_url: 'https://example.com/forward',
58
+ });
59
+ });
60
+ });
61
+ describe('webhook.updateEndpoint — PATCH (new 2026-05-15)', () => {
62
+ it('PATCHes /webhook/orgs/{org_id}/endpoints/{id}', async () => {
63
+ await webhook.updateEndpoint(API_KEY, ORG_ID, ENDPOINT_ID, { name: 'renamed' });
64
+ const [url, init] = fetchMock.mock.calls[0];
65
+ expect(url).toContain(`/webhook/orgs/${ORG_ID}/endpoints/${ENDPOINT_ID}`);
66
+ expect(init.method).toBe('PATCH');
67
+ expect(JSON.parse(init.body)).toEqual({ name: 'renamed' });
68
+ });
69
+ it('sends only the fields that were provided', async () => {
70
+ await webhook.updateEndpoint(API_KEY, ORG_ID, ENDPOINT_ID, {
71
+ forward_url: 'https://other.example.com/fwd',
72
+ });
73
+ expect(JSON.parse(fetchMock.mock.calls[0][1].body)).toEqual({
74
+ forward_url: 'https://other.example.com/fwd',
75
+ });
76
+ });
77
+ it('preserves empty-string sentinel (explicit clear)', async () => {
78
+ await webhook.updateEndpoint(API_KEY, ORG_ID, ENDPOINT_ID, { forward_url: '' });
79
+ expect(JSON.parse(fetchMock.mock.calls[0][1].body)).toEqual({ forward_url: '' });
80
+ });
81
+ });
82
+ describe('webhook.EXPOSES — current contract', () => {
83
+ it('includes PATCH for endpoints (2026-05-15)', () => {
84
+ expect(webhook.EXPOSES).toContain('PATCH /webhook/orgs/{org_id}/endpoints/{endpoint_id}');
85
+ });
86
+ });
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@myapihq/cli",
3
3
  "license": "Apache-2.0",
4
- "version": "1.2.4",
4
+ "version": "1.2.5",
5
5
  "description": "MyAPI command-line interface",
6
6
  "type": "module",
7
7
  "files": [
@@ -27,7 +27,7 @@
27
27
  "lint:changelog": "node ../../scripts/lint-changelog.js"
28
28
  },
29
29
  "dependencies": {
30
- "@myapihq/sdk": "^1.2.4",
30
+ "@myapihq/sdk": "^1.2.5",
31
31
  "omelette": "^0.4.17"
32
32
  },
33
33
  "devDependencies": {