Skip to main content

SDK: Yellow Pages

The Yellow Pages client provides methods for managing the service catalog -- registering services, querying dependencies, and searching across the catalog.

Access it via client.yellowpages.

Services

List all services

const services = await client.yellowpages.services.list();
// services: Service[]

Get a service by ID or name

const service = await client.yellowpages.services.get("a1b2c3d4");
// or by name
const service = await client.yellowpages.services.get("payment-api");

Returns a Service object:

interface Service {
id: string;
name: string;
description: string;
tags: string[];
system?: string;
owner?: string;
dependencies: string[];
createdAt: string;
updatedAt: string;
}

Create a service

const service = await client.yellowpages.services.create({
name: "payment-api",
description: "Handles payment processing",
tags: ["payments", "core"],
system: "billing-system",
owner: "platform-team",
});

Delete a service

await client.yellowpages.services.delete("a1b2c3d4");

Add a dependency

await client.yellowpages.services.addDependency("a1b2c3d4", "x9y8z7w6");

Search across service names, descriptions, and tags:

const results = await client.yellowpages.search("payment");
// results: Service[]

Dependency Graph

Traverse the dependency graph for a service:

// Downstream: what does this service depend on?
const downstream = await client.yellowpages.deps("a1b2c3d4", "down");

// Upstream: what depends on this service?
const upstream = await client.yellowpages.deps("a1b2c3d4", "up");

Systems and Owners

List systems

const systems = await client.yellowpages.systems.list();

Create a system

const system = await client.yellowpages.systems.create({
name: "billing-system",
description: "All billing-related services",
});

List owners

const owners = await client.yellowpages.owners.list();

Create an owner

const owner = await client.yellowpages.owners.create({
name: "Platform Team",
email: "platform@example.com",
team: "engineering",
});

Full Example

import { createClient } from "@the-shift/sdk";

const client = createClient({
gatewayUrl: "https://app.the-shift.dev",
apiKey: process.env.SHIFT_API_KEY,
});

// Register a new service
const svc = await client.yellowpages.services.create({
name: "notification-service",
description: "Sends emails and push notifications",
tags: ["notifications", "email"],
system: "messaging-system",
owner: "platform-team",
});

console.log(`Created service: ${svc.id}`);

// Search for it
const results = await client.yellowpages.search("notification");
console.log(`Found ${results.length} matching services`);

// Check dependencies
const deps = await client.yellowpages.deps(svc.id, "down");
console.log(`Downstream dependencies: ${deps.length}`);