/** * Shared types for the ConvosConnections content codecs. * * Mirrors the iOS `ConvosConnections` package (PR #767) so that * payloads, invocations, and results round-trip between platforms. * * Wire format notes (must match Swift's default JSONEncoder/JSONDecoder): * - `Date` is encoded as a `Double` representing seconds since the Swift * reference date (2001-01-01 00:00:00 UTC), not the Unix epoch. Use * `dateToSwiftReference()` / `swiftReferenceToDate()` to convert. * - `UUID` is encoded as an uppercase hex string with dashes. * - Enum raw values are lowercase or snake_case (e.g. `home_kit`, * `screen_time`, `capability_not_enabled`). */ /** Seconds between Unix epoch (1970-01-01) and Swift reference date (2001-01-01). */ export declare const SWIFT_REFERENCE_EPOCH_OFFSET_SECONDS = 978307200; /** Convert a JS Date to a Swift `Date` wire value (seconds since 2001-01-01). */ export declare function dateToSwiftReference(date: Date): number; /** Convert a Swift `Date` wire value (seconds since 2001-01-01) back to a JS Date. */ export declare function swiftReferenceToDate(seconds: number): Date; /** * Identifies a native iOS data source. Raw values are the discriminator * used in `ConnectionPayloadBody` and `ConnectionInvocation.kind`. */ export type ConnectionKind = "health" | "calendar" | "contacts" | "location" | "photos" | "music" | "home_kit" | "screen_time" | "motion"; export declare const ALL_CONNECTION_KINDS: readonly ConnectionKind[]; /** * Tagged-union value carried by `ConnectionAction.arguments` and the * `success` branch of `ConnectionInvocationResult.result`. Wire form is * `{"type": , "value": ...}`. * * The `date` variant carries a Swift reference-date Double; `iso8601` * carries a pre-formatted ISO 8601 string. Producers usually pick one * based on how the consuming action schema declares the parameter type. */ export type ArgumentValue = { type: "string"; value: string; } | { type: "bool"; value: boolean; } | { type: "int"; value: number; } | { type: "double"; value: number; } | { type: "date"; value: number; } | { type: "iso8601"; value: string; } | { type: "enum"; value: string; } | { type: "array"; value: ArgumentValue[]; } | { type: "null"; value: null; }; /** * Validate that an arbitrary JSON value is a well-formed `ArgumentValue`. * Throws on the first invalid node. */ export declare function assertArgumentValue(value: unknown, path?: string): asserts value is ArgumentValue; /** * Verbs an action can require, orthogonal to its `ConnectionKind`. A user * grants capabilities per `(kind, conversation)` independently — a * read-only Strava cloud provider declares `[read]`; a calendar device * sink declares all four. Used as the discriminator for capability * resolution and as the wire-level field on `CapabilityRequest`. * * Raw values match `ConnectionCapability` on iOS — `read` plus three * snake_case write verbs. */ export type ConnectionCapability = "read" | "write_create" | "write_update" | "write_delete"; export declare const ALL_CONNECTION_CAPABILITIES: readonly ConnectionCapability[]; /** True for every capability except `read`. */ export declare function isWriteCapability(capability: ConnectionCapability): boolean; /** Runtime guard for decoded payloads — raw values from the wire aren't typed. */ export declare function isConnectionCapability(value: unknown): value is ConnectionCapability; /** * Result status emitted by the device after attempting an invocation. * Raw values match `ConnectionInvocationResult.Status` on iOS. */ export type InvocationStatus = "success" | "capability_not_enabled" | "capability_revoked" | "requires_confirmation" | "authorization_denied" | "execution_failed" | "unknown_action"; export declare const ALL_INVOCATION_STATUSES: readonly InvocationStatus[];