From 7dca63f0057fee581e70638ac946bf91130e7903 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jind=C5=99ich=20B=C3=A4r?= Date: Wed, 15 Feb 2023 14:13:01 +0100 Subject: [PATCH] feat: add setStatusMessage implementation --- package.json | 1 + src/index.ts | 13 ++++++++++++- 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/package.json b/package.json index dfaaed9..680e618 100644 --- a/package.json +++ b/package.json @@ -52,6 +52,7 @@ "dependencies": { "@apify/consts": "^1.10.0", "@apify/log": "^1.2.3", + "@crawlee/types": "^3.2.2", "better-sqlite3-with-prebuilds": "^7.4.3", "content-type": "^1.0.4", "fs-extra": "^10.1.0", diff --git a/src/index.ts b/src/index.ts index c40a336..6ba26c8 100644 --- a/src/index.ts +++ b/src/index.ts @@ -4,6 +4,7 @@ import { readdir, rm } from 'fs/promises'; import { join, resolve } from 'path'; import log from '@apify/log'; import { ENV_VARS, KEY_VALUE_STORE_KEYS, LOCAL_ENV_VARS } from '@apify/consts'; +import { SetStatusMessageOptions, StorageClient } from '@crawlee/types'; import { STORAGE_NAMES, STORAGE_TYPES } from './consts'; import { DatabaseConnectionCache } from './database_connection_cache'; import { DatasetClient } from './resource_clients/dataset'; @@ -41,7 +42,7 @@ export interface RequestQueueOptions { /** * Represents local emulation of [Apify Storage](https://apify.com/storage). */ -export class ApifyStorageLocal { +export class ApifyStorageLocal implements StorageClient { readonly storageDir: string; readonly requestQueueDir: string; @@ -158,6 +159,16 @@ export class ApifyStorageLocal { }); } + setStatusMessage(message: string, options: SetStatusMessageOptions = {}): Promise { + ow(message, ow.string); + ow(options, ow.optional.object.exactShape({ + isStatusMessageTerminal: ow.optional.boolean, + })); + + log.info(`Setting${options.isStatusMessageTerminal ? ' terminal' : ''} status message: ${message}`); + return Promise.resolve(); + } + /** * Cleans up the default local storage directories before the run starts: * - local directory containing the default dataset;