Skip to content

Commit 6bdaa4b

Browse files
committed
fix(apps): the batch-1 connector apps carry their own iconUrl
connector-github and connector-stripe each own a neutral connector glyph under assets/icon.svg, and objectstack.manifest.json points iconUrl at its raw.githubusercontent.com URL on main, the way HotCRM's manifest does. Each app's listing test now refuses a manifest whose iconUrl is absent or not http(s). Claude-Session: https://claude.ai/code/session_01FEkQ5p28hxU1qvesRWw9LU Co-authored-by: Claude <noreply@anthropic.com>
1 parent f23e051 commit 6bdaa4b

6 files changed

Lines changed: 106 additions & 4 deletions

File tree

Lines changed: 7 additions & 0 deletions
Loading

‎packages/apps/connector-github/objectstack.manifest.json‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
"category": "devtools",
99
"tags": ["github", "mcp", "connector", "issues"],
1010
"license": "Apache-2.0",
11+
"iconUrl": "https://raw.githubusercontent.com/objectstack-ai/objectstack/main/packages/apps/connector-github/assets/icon.svg",
1112
"homepageUrl": "https://github.com/objectstack-ai/objectstack/tree/main/packages/apps/connector-github",
1213
"readmePath": "README.md"
1314
}

‎packages/apps/connector-github/test/listing.test.ts‎

Lines changed: 45 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,21 +3,43 @@
33
/**
44
* The listing this package publishes as: `objectstack.manifest.json` parses
55
* against the spec's own schema for that file, names the same package id as
6-
* the stack, points at a README that exists, and that README's credentials
6+
* the stack, points at a README that exists and at the icon the package owns
7+
* (a public http(s) `iconUrl`), and that README's credentials
78
* section names every credential the app's connectors reference — the
89
* marketplace handbook's "every credential it needs" rule, checked against
910
* the metadata rather than trusted.
1011
*/
1112

1213
import { describe, it, expect } from 'vitest';
13-
import { readFileSync, existsSync } from 'node:fs';
14+
import { readFileSync, existsSync, statSync } from 'node:fs';
1415
import { fileURLToPath } from 'node:url';
1516
import { TemplateManifestSchema } from '@objectstack/spec/marketplace';
1617
import stack from '../objectstack.config.js';
1718

1819
const manifestPath = fileURLToPath(new URL('../objectstack.manifest.json', import.meta.url));
1920
const manifest = JSON.parse(readFileSync(manifestPath, 'utf8')) as Record<string, unknown>;
2021

22+
/** Where the listing icon is served from once this package's tree is on `main`. */
23+
const ICON_URL = 'https://raw.githubusercontent.com/objectstack-ai/objectstack/main/packages/apps/connector-github/assets/icon.svg';
24+
25+
/**
26+
* Why a manifest's `iconUrl` cannot be the listing icon, or `null` when it can:
27+
* `os package publish` sends the key as the package's `icon_url`, and the
28+
* marketplace handbook asks for a public http(s) URL. `TemplateManifestSchema`
29+
* accepts any URL scheme, so the scheme is checked here.
30+
*/
31+
function iconUrlProblem(m: Record<string, unknown>): string | null {
32+
const value = m.iconUrl;
33+
if (typeof value !== 'string') return 'iconUrl is absent';
34+
let url: URL;
35+
try {
36+
url = new URL(value);
37+
} catch {
38+
return `iconUrl is not a URL: ${value}`;
39+
}
40+
return url.protocol === 'https:' || url.protocol === 'http:' ? null : `iconUrl is not http(s): ${value}`;
41+
}
42+
2143
/** The README's `## Credentials` section, up to the next second-level heading. */
2244
function credentialsSection(readme: string): string {
2345
const start = readme.indexOf('\n## Credentials\n');
@@ -55,6 +77,27 @@ describe('connector-github listing', () => {
5577
expect(section).toContain('https://github.com/settings/personal-access-tokens/new');
5678
});
5779

80+
it('carries a public http(s) iconUrl', () => {
81+
expect(iconUrlProblem(manifest)).toBeNull();
82+
});
83+
84+
it('refuses an iconUrl that is absent or not http(s)', () => {
85+
const withoutIcon = { ...manifest };
86+
delete withoutIcon.iconUrl;
87+
expect(iconUrlProblem(withoutIcon)).toBe('iconUrl is absent');
88+
expect(iconUrlProblem({ ...manifest, iconUrl: 'ftp://example.com/icon.svg' })).toMatch(/not http\(s\)/);
89+
expect(iconUrlProblem({ ...manifest, iconUrl: 'assets/icon.svg' })).toMatch(/not a URL/);
90+
});
91+
92+
it('points iconUrl at the icon this package owns', () => {
93+
expect(manifest.iconUrl).toBe(ICON_URL);
94+
const iconPath = fileURLToPath(new URL('../assets/icon.svg', import.meta.url));
95+
expect(existsSync(iconPath)).toBe(true);
96+
// `--icon-file` takes up to 256 KB; hold the owned asset to the same bound.
97+
expect(statSync(iconPath).size).toBeLessThan(256 * 1024);
98+
expect(readFileSync(iconPath, 'utf8')).toMatch(/^<svg [^>]*viewBox="0 0 256 256"/);
99+
});
100+
58101
it('carries no secret in metadata', () => {
59102
for (const c of stack.connectors ?? []) {
60103
expect(c).not.toHaveProperty('authentication.token');
Lines changed: 7 additions & 0 deletions
Loading

‎packages/apps/connector-stripe/objectstack.manifest.json‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
"category": "finance",
99
"tags": ["stripe", "openapi", "connector", "payments"],
1010
"license": "Apache-2.0",
11+
"iconUrl": "https://raw.githubusercontent.com/objectstack-ai/objectstack/main/packages/apps/connector-stripe/assets/icon.svg",
1112
"homepageUrl": "https://github.com/objectstack-ai/objectstack/tree/main/packages/apps/connector-stripe",
1213
"readmePath": "README.md"
1314
}

‎packages/apps/connector-stripe/test/listing.test.ts‎

Lines changed: 45 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,8 @@
33
/**
44
* The listing this package publishes as, and the document it packages:
55
* `objectstack.manifest.json` parses against the spec's own schema for that
6-
* file and names the same package id as the stack; the README's credentials
6+
* file, names the same package id as the stack and points at the icon the
7+
* package owns (a public http(s) `iconUrl`); the README's credentials
78
* section names every credential the app's connectors reference (the
89
* marketplace handbook's "every credential it needs" rule, checked against
910
* the metadata rather than trusted); and the packaged OpenAPI document is the
@@ -13,14 +14,35 @@
1314

1415
import { describe, it, expect } from 'vitest';
1516
import { createHash } from 'node:crypto';
16-
import { readFileSync, existsSync } from 'node:fs';
17+
import { readFileSync, existsSync, statSync } from 'node:fs';
1718
import { fileURLToPath } from 'node:url';
1819
import { TemplateManifestSchema } from '@objectstack/spec/marketplace';
1920
import stack from '../objectstack.config.js';
2021
import { STRIPE_READ_OPERATIONS, StripeConnector } from '../src/connectors/stripe.connector.js';
2122

2223
const manifestPath = fileURLToPath(new URL('../objectstack.manifest.json', import.meta.url));
2324
const manifest = JSON.parse(readFileSync(manifestPath, 'utf8')) as Record<string, unknown>;
25+
26+
/** Where the listing icon is served from once this package's tree is on `main`. */
27+
const ICON_URL = 'https://raw.githubusercontent.com/objectstack-ai/objectstack/main/packages/apps/connector-stripe/assets/icon.svg';
28+
29+
/**
30+
* Why a manifest's `iconUrl` cannot be the listing icon, or `null` when it can:
31+
* `os package publish` sends the key as the package's `icon_url`, and the
32+
* marketplace handbook asks for a public http(s) URL. `TemplateManifestSchema`
33+
* accepts any URL scheme, so the scheme is checked here.
34+
*/
35+
function iconUrlProblem(m: Record<string, unknown>): string | null {
36+
const value = m.iconUrl;
37+
if (typeof value !== 'string') return 'iconUrl is absent';
38+
let url: URL;
39+
try {
40+
url = new URL(value);
41+
} catch {
42+
return `iconUrl is not a URL: ${value}`;
43+
}
44+
return url.protocol === 'https:' || url.protocol === 'http:' ? null : `iconUrl is not http(s): ${value}`;
45+
}
2446
const readme = readFileSync(fileURLToPath(new URL('../README.md', import.meta.url)), 'utf8');
2547
const documentBytes = readFileSync(fileURLToPath(new URL('../openapi/stripe.openapi.json', import.meta.url)));
2648
const document = JSON.parse(documentBytes.toString('utf8')) as {
@@ -65,6 +87,27 @@ describe('connector-stripe listing', () => {
6587
expect(credentials).toContain('https://dashboard.stripe.com/apikeys');
6688
});
6789

90+
it('carries a public http(s) iconUrl', () => {
91+
expect(iconUrlProblem(manifest)).toBeNull();
92+
});
93+
94+
it('refuses an iconUrl that is absent or not http(s)', () => {
95+
const withoutIcon = { ...manifest };
96+
delete withoutIcon.iconUrl;
97+
expect(iconUrlProblem(withoutIcon)).toBe('iconUrl is absent');
98+
expect(iconUrlProblem({ ...manifest, iconUrl: 'ftp://example.com/icon.svg' })).toMatch(/not http\(s\)/);
99+
expect(iconUrlProblem({ ...manifest, iconUrl: 'assets/icon.svg' })).toMatch(/not a URL/);
100+
});
101+
102+
it('points iconUrl at the icon this package owns', () => {
103+
expect(manifest.iconUrl).toBe(ICON_URL);
104+
const iconPath = fileURLToPath(new URL('../assets/icon.svg', import.meta.url));
105+
expect(existsSync(iconPath)).toBe(true);
106+
// `--icon-file` takes up to 256 KB; hold the owned asset to the same bound.
107+
expect(statSync(iconPath).size).toBeLessThan(256 * 1024);
108+
expect(readFileSync(iconPath, 'utf8')).toMatch(/^<svg [^>]*viewBox="0 0 256 256"/);
109+
});
110+
68111
it('carries no secret in metadata', () => {
69112
for (const c of stack.connectors ?? []) {
70113
expect(c).not.toHaveProperty('authentication.token');

0 commit comments

Comments
 (0)