import assert from "node:assert/strict"; import test from "node:test"; import { buildSourceDocument } from "../packages/core/src/index.ts"; test("builds a PAL source with published releases only", () => { const source = { id: "source-1", workspaceId: "workspace-1", slug: "my-apps", name: "My Apps", subtitle: "Small iOS experiments", description: "A test source", tintColor: "#E9694B", visibility: "public", createdAt: "2026-01-01T00:00:00.000Z", updatedAt: "2026-01-01T00:00:00.000Z", }; const app = { id: "app-1", sourceId: "source-1", name: "Orbit", bundleIdentifier: "com.example.orbit", marketplaceID: "123", developerName: "Example", subtitle: "", localizedDescription: "An orbit app", tintColor: "#E9694B", category: "utilities", screenshots: [], appPermissions: { entitlements: [], privacy: {} }, createdAt: "2026-01-01T00:00:00.000Z", updatedAt: "2026-01-01T00:00:00.000Z", }; const published = { id: "release-1", appId: "app-1", uploadId: "upload-1", version: "1.0", buildVersion: "1", appleItemId: "123", date: "2026-02-01T00:00:00.000Z", localizedDescription: "First release", sizeBytes: 1024, status: "published", manifest: { bundleId: "com.example.orbit", appleItemId: "123", shortVersionString: "1.0", bundleVersion: "1", variantPaths: [], deltaPaths: [], platforms: [], minimumSystemVersions: {} }, createdAt: "2026-02-01T00:00:00.000Z", }; const draft = { ...published, id: "release-2", version: "2.0", status: "ready" }; const document = buildSourceDocument(source, [app], [published, draft], "https://example.test"); assert.equal(document.apps.length, 1); assert.equal(document.apps[0].versions.length, 1); assert.equal(document.apps[0].versions[0].downloadURL, "https://example.test/artifacts/release-1/manifest.json"); assert.deepEqual(document.featuredApps, ["com.example.orbit"]); });