forevue/harvester-metadata-sdk

SDK for accessing source-level and document-level metadata generated by Forevue's Crawler

dev-main 2023-06-24 17:07 UTC

This package is not auto-updated.

Last update: 2024-04-14 18:57:11 UTC


README

Tests Formats Version Total Downloads License

Installation

Requires PHP 8.2+

You can install the package via composer:

composer require forevue/harvester-metadata-sdk

Usage

This is a cowboy-style SDK, you connect to the database directly.

Getting started

use Forevue\HarvesterMetadataSdk\Client;

// This creates a PDO instance behind the scenes
$client = new Client(
    host: 'localhost',
    password: 'root',
    port: 5432,
    user: 'postgres',
    database: 'postgres',
    driver: 'pgsql',
)

// Or,
$client = new Client(dsn: 'pgsql:...')

// Or,
$client = new Client(pdo: new PDO(...))

Querying

/* @var \Forevue\HarvesterMetadataSdk\Client $client */
$client->sources()->all();
$client->sources()->find(1234);
$client->sources()->findByUrn('urn:forevue:source:code-hash:static-hash');

$client->providers()->all();
$client->providers()->find(1234);
$client->providers()->findByUrn('urn:forevue:provider:code-hash:static-hash');

/* @var \Forevue\HarvesterMetadataSdk\DataObjects\Source $source */
$source->id();
$source->name(); // etc
$source->isDirty() // this is the only computed property
$source->subSources(); // returns the child sources
$source->provider(); // returns the parent provider object

/* @var \Forevue\HarvesterMetadataSdk\DataObjects\Provider $provider */
$provider->id();
$provider->name(); // etc
$provider->sources(); // returns the provider's sources

$source->crawlInterval() and $source->recrawlInterval() returns an array{int, int} not an object

Testing

composer test

harvester-metadata-sdk was created by Félix Dorn under the * *MIT license**.