* @method string getuserId()
* @method setAppId(string $type)
* @method string getAppId()
+ * @method setIdentifier(string $type)
+ * @method string getIdentifier()
*/
class Task extends Entity {
protected $lastUpdated;
protected $status;
protected $userId;
protected $appId;
+ protected $identifier;
/**
* @var string[]
*/
- public static array $columns = ['id', 'last_updated', 'type', 'input', 'output', 'status', 'user_id', 'app_id'];
+ public static array $columns = ['id', 'last_updated', 'type', 'input', 'output', 'status', 'user_id', 'app_id', 'identifier'];
/**
* @var string[]
*/
- public static array $fields = ['id', 'lastUpdated', 'type', 'input', 'output', 'status', 'userId', 'appId'];
+ public static array $fields = ['id', 'lastUpdated', 'type', 'input', 'output', 'status', 'userId', 'appId', 'identifier'];
public function __construct() {
$this->addType('status', 'integer');
$this->addType('userId', 'string');
$this->addType('appId', 'string');
+ $this->addType('identifier', 'string');
}
public function toRow(): array {
'output' => $task->getOutput(),
'userId' => $task->getUserId(),
'appId' => $task->getAppId(),
+ 'identifier' => $task->getIdentifier(),
]);
}
}
* @param string $input
* @param string $appId
* @param string|null $userId
+ * @param string $identifier An arbitrary identifier for this task. max length: 255 chars
* @since 28.0.0
*/
final public function __construct(
protected string $input,
protected string $appId,
protected ?string $userId,
+ protected string $identifier = '',
) {
}
return $this->appId;
}
+ /**
+ * @return string
+ * @since 28.0.0
+ */
+ final public function getIdentifier(): string {
+ return $this->identifier;
+ }
+
/**
* @return string|null
* @since 28.0.0
'appId' => $this->getAppId(),
'input' => $this->getInput(),
'output' => $this->getOutput(),
+ 'identifier' => $this->getIdentifier(),
];
}
* @since 28.0.0
*/
final public static function fromTaskEntity(Task $taskEntity): ILanguageModelTask {
- $task = self::factory($taskEntity->getType(), $taskEntity->getInput(), $taskEntity->getuserId(), $taskEntity->getAppId());
+ $task = self::factory($taskEntity->getType(), $taskEntity->getInput(), $taskEntity->getuserId(), $taskEntity->getAppId(), $taskEntity->getIdentifier());
$task->setId($taskEntity->getId());
$task->setStatus($taskEntity->getStatus());
$task->setOutput($taskEntity->getOutput());
* @param string $input
* @param string|null $userId
* @param string $appId
+ * @param string $identifier
* @return ILanguageModelTask
* @throws \InvalidArgumentException
* @since 28.0.0
*/
- final public static function factory(string $type, string $input, ?string $userId, string $appId): ILanguageModelTask {
+ final public static function factory(string $type, string $input, ?string $userId, string $appId, string $identifier): ILanguageModelTask {
if (!in_array($type, array_keys(self::TYPES))) {
throw new \InvalidArgumentException('Unknown task type');
}
- return new (ILanguageModelTask::TYPES[$type])($input, $appId, $userId);
+ return new (ILanguageModelTask::TYPES[$type])($input, $appId, $userId, $identifier);
}
}