Docs are not available for mobile use. Please use a desktop computer to view the documentation.
Sources
Data source configurations and authentication details
Purpose
The sources
table manages external data source configurations, including OAuth credentials, device pairing information, and synchronization settings. Each source represents a connected service or device that provides data to the platform.
Schema Definition
Field | Type | Description | Constraints |
---|---|---|---|
name | varchar | Unique source identifier | Primary key |
company | varchar | Company/provider name | Not null |
platform | varchar | Platform type | Default: ‘cloud’ |
userId | uuid | Associated user ID | Foreign key to users.id |
defaultFidelityScore | real | Default data quality score (0-1) | Default: 1.0 |
defaultSyncSchedule | varchar | Default cron schedule | Default: ’/5 * * *’ |
minSyncFrequency | varchar | Minimum sync frequency | Optional |
maxSyncFrequency | varchar | Maximum sync frequency | Optional |
authType | varchar | Authentication method | Default: ‘oauth2’ |
syncType | varchar | Synchronization type | Default: ‘cron’ |
wizardConfig | json | Setup wizard configuration | Optional |
pairedDeviceId | varchar | Paired device identifier | Optional |
pairedDeviceName | varchar | Human-readable device name | Optional |
pairedDeviceToken | varchar | Device authentication token | Optional |
deviceLastSeen | timestamptz | Last device communication | Optional |
pairingExpiresAt | timestamptz | Device pairing expiration | Optional |
oauthAccessToken | text | OAuth access token | Optional |
oauthRefreshToken | text | OAuth refresh token | Optional |
oauthExpiresAt | timestamptz | OAuth token expiration | Optional |
deviceType | varchar | Type of device/source | Optional |
isActive | boolean | Whether source is active | Default: true |
scopes | json | OAuth/API scopes granted | Optional |
createdAt | timestamptz | Source creation timestamp | Auto-generated |
updatedAt | timestamptz | Last update timestamp | Auto-updated |
Relationships
Referenced by:
signals.sourceName
- Signals from this sourceambient_signals.sourceName
- Ambient data from this sourceepisodic_signals.sourceName
- Episodic data from this source
References:
users.id
viauserId
- Source owner (cascade delete)
Indexes
sources_platform_idx
- B-tree index on platform for filteringsources_user_id_idx
- B-tree index on userId for user queries
Constraints
fidelity_score_check
- Fidelity score must be between 0.0 and 1.0- Source names must be unique (primary key)
- User cascade delete - removing user removes all their sources
Usage Examples
Find all active sources for a user
SELECT name, company, platform, isActive
FROM sources
WHERE userId = 'user-uuid' AND isActive = true;
Get OAuth sources requiring token refresh
SELECT name, oauthExpiresAt
FROM sources
WHERE authType = 'oauth2'
AND oauthExpiresAt < NOW() + INTERVAL '1 day';
Update device last seen timestamp
UPDATE sources
SET deviceLastSeen = NOW(), updatedAt = NOW()
WHERE pairedDeviceId = 'device-123';
Find sources by platform
SELECT name, company, defaultSyncSchedule
FROM sources
WHERE platform = 'cloud' AND isActive = true;