import { LogContext } from '@balena/jellyfish-logger'; import type { AutumnDBSession, Contract, JsonSchema, Kernel } from 'autumndb'; import type { ActionContract } from '.'; /** * @summary Get the current timestamp * @function * @public * * @returns RFC 3339 timestamp * * @example * const timestamp = utils.getCurrentTimestamp(); */ export declare const getCurrentTimestamp: () => string; /** * @summary Get the arguments schema from an action contract * @function * @public * * @param actionContract - action contract * @returns arguments schema * * @example * const schema = utils.getActionArgumentsSchema({ ... }); * console.log(schema.type); */ export declare const getActionArgumentsSchema: (actionContract: ActionContract) => JsonSchema; /** * @summary Check if a contract exists in the system * @function * @public * * @param logContext - log context * @param kernel - kernel instance * @param session - session id * @param object - contract properties * @returns whether the contract exists * * @example * const session = '4a962ad9-20b5-4dd8-a707-bf819593cc84'; * const hasContract = await utils.hasContract({ ... }, kernel, session, { * id: 'a13474e4-7b44-453b-9f3e-aa783b8f37ea', * active: true, * data: { * foo: 'bar', * }, * }); * * if (hasContract) { * console.log('This contract already exists'); * } */ export declare const hasContract: (logContext: LogContext, kernel: Kernel, session: AutumnDBSession, object: Pick) => Promise; /** * @summary Get the slug for an event * @function * @public * * @param {String} type - event type * @returns {String} slug * * @example * const slug = await utils.getEventSlug('execute') */ export declare const getEventSlug: (type: string) => string; /** * @summary Convert an ISO 8601 duration to milliseconds * @function * * @param duration - the ISO 8601 duration (e.g. 'PT1H') * @returns the duration in milliseconds, or 0 if the duration is invalid */ export declare const durationToMs: (duration: string) => number; export declare const getQueryWithOptionalLinks: (object: { id?: string; slug?: string; version?: string; }, linkVerbs?: string[]) => JsonSchema;