hobots 5.0.0 → 5.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +2 -1
- package/dist/{chunk-HKCDMUA3.js → chunk-6YTOYIZM.js} +2 -1
- package/dist/chunk-6YTOYIZM.js.map +1 -0
- package/dist/index.cjs +1649 -1465
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +52 -6
- package/dist/index.d.ts +52 -6
- package/dist/index.js +1649 -1466
- package/dist/index.js.map +1 -1
- package/dist/protocol.cjs +1 -0
- package/dist/protocol.cjs.map +1 -1
- package/dist/protocol.d.cts +20 -1
- package/dist/protocol.d.ts +20 -1
- package/dist/protocol.js +1 -1
- package/package.json +1 -1
- package/dist/chunk-HKCDMUA3.js.map +0 -1
package/dist/index.d.cts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { RunAttachmentContentType, EnvironmentInput, EventType, FileRef, RunItemStatus, RunProgress } from './protocol.cjs';
|
|
2
|
-
export { Breadcrumb, BreadcrumbLevel, Envelope, EnvelopeItem, Environment, EventPayload, EventUser, ExceptionData, FileDownloadResponse, FileStorage, HeartbeatPayload, InstanceInfo, InstanceMode, ItemColumn, ItemsDeclaration, MachineProcess, MachineSnapshot, PollRequest, PollResponse, RunAttachmentConfirmRequest, RunAttachmentConfirmResponse, RunAttachmentCreateRequest, RunAttachmentCreateResponse, RunCreateRequest, RunCreateResponse, RunDescriptor, RunError, RunItemInput, RunItemsCreateRequest, RunItemsCreateResponse, RunLogEntry, RunLogLevel, RunStartRequest, RunStartResponse, RunStatus, RunUpdateRequest, RunUpdateResponse, RunUpdateStatus, StackFrame, StepData, StepStatus, TransactionPayload } from './protocol.cjs';
|
|
2
|
+
export { Breadcrumb, BreadcrumbLevel, Envelope, EnvelopeItem, Environment, EventPayload, EventUser, ExceptionData, FileDownloadResponse, FileStorage, HeartbeatPayload, InstanceInfo, InstanceMode, ItemColumn, ItemsDeclaration, MachineProcess, MachineSnapshot, PollRequest, PollResponse, RunAttachmentConfirmRequest, RunAttachmentConfirmResponse, RunAttachmentCreateRequest, RunAttachmentCreateResponse, RunCreateRequest, RunCreateResponse, RunDescriptor, RunError, RunItemInput, RunItemsCreateRequest, RunItemsCreateResponse, RunItemsDoneRequest, RunItemsDoneResponse, RunLogEntry, RunLogLevel, RunStartRequest, RunStartResponse, RunStatus, RunUpdateRequest, RunUpdateResponse, RunUpdateStatus, StackFrame, StepData, StepStatus, TransactionPayload } from './protocol.cjs';
|
|
3
3
|
|
|
4
4
|
/** Espera entre tentativas: ms fixo ou função do número da tentativa que acabou de falhar (1-based). */
|
|
5
5
|
type RetryDelay = number | ((attempt: number) => number);
|
|
@@ -279,12 +279,16 @@ interface RunItemOptions extends RunItemImageOptions {
|
|
|
279
279
|
interface RunItemHandle {
|
|
280
280
|
/** Posição do elemento na lista (0-based). */
|
|
281
281
|
readonly index: number;
|
|
282
|
-
/** Identidade
|
|
283
|
-
readonly id: string
|
|
282
|
+
/** Identidade do item: a resolvida por `options.id` ou, sem ela, uma gerada pelo SDK — a mesma em todas as tentativas. */
|
|
283
|
+
readonly id: string;
|
|
284
284
|
/** Handle da etapa deste item no waterfall de performance; undefined fora de uma execução. */
|
|
285
285
|
readonly step: StepHandle | undefined;
|
|
286
286
|
/** true depois do primeiro desfecho registrado (o SDK não sobrescreve o que o handler decidiu). */
|
|
287
287
|
readonly reported: boolean;
|
|
288
|
+
/** Desfecho registrado até agora (undefined = nenhum). */
|
|
289
|
+
readonly status: RunItemStatus | undefined;
|
|
290
|
+
/** Tentativa em curso (1-based) — o handler pode ler para logar. */
|
|
291
|
+
readonly attempt: number;
|
|
288
292
|
/** Item processado com sucesso. `payload` é mesclado sobre o payload base de `options.payload`. */
|
|
289
293
|
succeeded(payload?: Record<string, unknown>, options?: RunItemImageOptions): void;
|
|
290
294
|
/** Falha sem lançar — o loop segue igual; a etapa vira `error` com o motivo. A imagem vai no item. */
|
|
@@ -293,8 +297,14 @@ interface RunItemHandle {
|
|
|
293
297
|
occurrence(message: string, payload?: Record<string, unknown>, options?: RunItemImageOptions): void;
|
|
294
298
|
}
|
|
295
299
|
interface RunItemsEachOptions<T> {
|
|
296
|
-
/**
|
|
297
|
-
|
|
300
|
+
/**
|
|
301
|
+
* Identidade de negócio do item: nome do campo do elemento (`'numero'`), chave composta
|
|
302
|
+
* (`['cnpj', 'competencia']`, juntada com `|`) ou função `(elemento, índice) => id`.
|
|
303
|
+
* Omitido: o campo `id` do elemento, se existir. `null`, ou elemento sem o campo padrão:
|
|
304
|
+
* o SDK gera um id único (e o item nunca é pulado na reexecução). Campo explícito ausente
|
|
305
|
+
* no elemento é erro do bot (lança e interrompe o loop).
|
|
306
|
+
*/
|
|
307
|
+
id?: string | readonly string[] | ((element: T, index: number) => string | number | null | undefined) | null;
|
|
298
308
|
/** Atributos base do item (viram colunas no app) — presentes em qualquer desfecho, inclusive falha. */
|
|
299
309
|
payload?: (element: T, index: number) => Record<string, unknown> | undefined;
|
|
300
310
|
/** `op` da etapa de cada item no waterfall. Default: 'item'. */
|
|
@@ -311,6 +321,18 @@ interface RunItemsEachOptions<T> {
|
|
|
311
321
|
* Central na hora. `false` desliga (tudo sai no envio periódico ou no fim da run). Default: true.
|
|
312
322
|
*/
|
|
313
323
|
flush?: boolean;
|
|
324
|
+
/**
|
|
325
|
+
* Tentativas extras quando o handler lança (falha técnica). Uma etapa só por elemento,
|
|
326
|
+
* com `data.attempts`. `0` desliga. `Occurrence` nunca é retentada. Default: 1.
|
|
327
|
+
*/
|
|
328
|
+
retries?: number;
|
|
329
|
+
/** Espera entre as tentativas: ms fixo ou função da tentativa que falhou (1-based). Default: 5_000. */
|
|
330
|
+
retryDelayMs?: RetryDelay;
|
|
331
|
+
/**
|
|
332
|
+
* Na reexecução do mesmo trabalho (Central/Studio → executar novamente), pula o item cujo `id`
|
|
333
|
+
* já deu `succeeded`/`occurrence` — só `failed` roda de novo. `false` processa tudo. Default: true.
|
|
334
|
+
*/
|
|
335
|
+
skipDone?: boolean;
|
|
314
336
|
}
|
|
315
337
|
/** Totalizadores do `items.each`, pelo desfecho final de cada elemento. */
|
|
316
338
|
interface RunItemsEachResult {
|
|
@@ -318,6 +340,8 @@ interface RunItemsEachResult {
|
|
|
318
340
|
succeeded: number;
|
|
319
341
|
failed: number;
|
|
320
342
|
occurrence: number;
|
|
343
|
+
/** Já concluídos neste trabalho (reexecução): não rodaram, mas contam no `total`. */
|
|
344
|
+
skipped: number;
|
|
321
345
|
}
|
|
322
346
|
type RunItemsEachHandler<T> = (element: T, item: RunItemHandle, index: number) => unknown;
|
|
323
347
|
/**
|
|
@@ -462,4 +486,26 @@ declare const retry: <T>(fn: (attempt: number) => T | Promise<T>, options?: Retr
|
|
|
462
486
|
declare const image: (input: AttachInput, options?: ImageOptions) => ImageAttachment;
|
|
463
487
|
declare const isFileRef: (value: unknown) => value is FileRef;
|
|
464
488
|
|
|
465
|
-
|
|
489
|
+
/** Erros de controle do ciclo de vida de uma run — identificados pelo `name`, nunca pela classe. */
|
|
490
|
+
/**
|
|
491
|
+
* Ocorrência de negócio lançada de dentro do handler de `hobots.items.each`: o item vira
|
|
492
|
+
* `occurrence` com esta mensagem (e `payload`/`image`, se vierem), a etapa do item vira
|
|
493
|
+
* `warning` e o loop segue — **sem nova tentativa**: o retry do `each` é só para falha
|
|
494
|
+
* técnica (qualquer outro erro). Use para regra de negócio: "nota já cadastrada",
|
|
495
|
+
* "cliente sem pendência", "produto fora do cardápio".
|
|
496
|
+
*
|
|
497
|
+
* throw new Occurrence('nota já cadastrada', { situacao: 'já cadastrada' });
|
|
498
|
+
*
|
|
499
|
+
* Fora do `each` (handler de `register()`/`start()` sem loop) é um erro comum: a run falha
|
|
500
|
+
* com ele como com qualquer outro.
|
|
501
|
+
*/
|
|
502
|
+
declare class Occurrence extends Error {
|
|
503
|
+
readonly payload: Record<string, unknown> | undefined;
|
|
504
|
+
/** Print do item (bytes/caminho ou `hobots.image(...)`) — o `each` pendura no item. */
|
|
505
|
+
readonly image: ImageInput | undefined;
|
|
506
|
+
constructor(message: string, payload?: Record<string, unknown>, options?: {
|
|
507
|
+
image?: ImageInput;
|
|
508
|
+
});
|
|
509
|
+
}
|
|
510
|
+
|
|
511
|
+
export { type AttachInput, type CaptureAttachment, type CaptureHint, EnvironmentInput, EventType, type FileDownloadOptions, FileRef, type Hobots, type HobotsOptions, ImageAttachment, type ImageInput, type ImageOptions, type ItemColumnInput, type ItemsOptions, Occurrence, type RegisterOptions, type RetryDelay, type RetryOptions, RunAttachmentContentType, type RunContext, type RunFiles, type RunHandler, type RunItemHandle, type RunItemImageOptions, type RunItemOptions, RunItemStatus, type RunItems, type RunItemsEachHandler, type RunItemsEachOptions, type RunItemsEachResult, type RunLogger, type RunOptions, RunProgress, type RunProgressReporter, type StartOptions, type StepFn, type StepHandle, type StepOptions, captureException, close, hobots as default, hobots, image, isFileRef, register, retry, start };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { RunAttachmentContentType, EnvironmentInput, EventType, FileRef, RunItemStatus, RunProgress } from './protocol.js';
|
|
2
|
-
export { Breadcrumb, BreadcrumbLevel, Envelope, EnvelopeItem, Environment, EventPayload, EventUser, ExceptionData, FileDownloadResponse, FileStorage, HeartbeatPayload, InstanceInfo, InstanceMode, ItemColumn, ItemsDeclaration, MachineProcess, MachineSnapshot, PollRequest, PollResponse, RunAttachmentConfirmRequest, RunAttachmentConfirmResponse, RunAttachmentCreateRequest, RunAttachmentCreateResponse, RunCreateRequest, RunCreateResponse, RunDescriptor, RunError, RunItemInput, RunItemsCreateRequest, RunItemsCreateResponse, RunLogEntry, RunLogLevel, RunStartRequest, RunStartResponse, RunStatus, RunUpdateRequest, RunUpdateResponse, RunUpdateStatus, StackFrame, StepData, StepStatus, TransactionPayload } from './protocol.js';
|
|
2
|
+
export { Breadcrumb, BreadcrumbLevel, Envelope, EnvelopeItem, Environment, EventPayload, EventUser, ExceptionData, FileDownloadResponse, FileStorage, HeartbeatPayload, InstanceInfo, InstanceMode, ItemColumn, ItemsDeclaration, MachineProcess, MachineSnapshot, PollRequest, PollResponse, RunAttachmentConfirmRequest, RunAttachmentConfirmResponse, RunAttachmentCreateRequest, RunAttachmentCreateResponse, RunCreateRequest, RunCreateResponse, RunDescriptor, RunError, RunItemInput, RunItemsCreateRequest, RunItemsCreateResponse, RunItemsDoneRequest, RunItemsDoneResponse, RunLogEntry, RunLogLevel, RunStartRequest, RunStartResponse, RunStatus, RunUpdateRequest, RunUpdateResponse, RunUpdateStatus, StackFrame, StepData, StepStatus, TransactionPayload } from './protocol.js';
|
|
3
3
|
|
|
4
4
|
/** Espera entre tentativas: ms fixo ou função do número da tentativa que acabou de falhar (1-based). */
|
|
5
5
|
type RetryDelay = number | ((attempt: number) => number);
|
|
@@ -279,12 +279,16 @@ interface RunItemOptions extends RunItemImageOptions {
|
|
|
279
279
|
interface RunItemHandle {
|
|
280
280
|
/** Posição do elemento na lista (0-based). */
|
|
281
281
|
readonly index: number;
|
|
282
|
-
/** Identidade
|
|
283
|
-
readonly id: string
|
|
282
|
+
/** Identidade do item: a resolvida por `options.id` ou, sem ela, uma gerada pelo SDK — a mesma em todas as tentativas. */
|
|
283
|
+
readonly id: string;
|
|
284
284
|
/** Handle da etapa deste item no waterfall de performance; undefined fora de uma execução. */
|
|
285
285
|
readonly step: StepHandle | undefined;
|
|
286
286
|
/** true depois do primeiro desfecho registrado (o SDK não sobrescreve o que o handler decidiu). */
|
|
287
287
|
readonly reported: boolean;
|
|
288
|
+
/** Desfecho registrado até agora (undefined = nenhum). */
|
|
289
|
+
readonly status: RunItemStatus | undefined;
|
|
290
|
+
/** Tentativa em curso (1-based) — o handler pode ler para logar. */
|
|
291
|
+
readonly attempt: number;
|
|
288
292
|
/** Item processado com sucesso. `payload` é mesclado sobre o payload base de `options.payload`. */
|
|
289
293
|
succeeded(payload?: Record<string, unknown>, options?: RunItemImageOptions): void;
|
|
290
294
|
/** Falha sem lançar — o loop segue igual; a etapa vira `error` com o motivo. A imagem vai no item. */
|
|
@@ -293,8 +297,14 @@ interface RunItemHandle {
|
|
|
293
297
|
occurrence(message: string, payload?: Record<string, unknown>, options?: RunItemImageOptions): void;
|
|
294
298
|
}
|
|
295
299
|
interface RunItemsEachOptions<T> {
|
|
296
|
-
/**
|
|
297
|
-
|
|
300
|
+
/**
|
|
301
|
+
* Identidade de negócio do item: nome do campo do elemento (`'numero'`), chave composta
|
|
302
|
+
* (`['cnpj', 'competencia']`, juntada com `|`) ou função `(elemento, índice) => id`.
|
|
303
|
+
* Omitido: o campo `id` do elemento, se existir. `null`, ou elemento sem o campo padrão:
|
|
304
|
+
* o SDK gera um id único (e o item nunca é pulado na reexecução). Campo explícito ausente
|
|
305
|
+
* no elemento é erro do bot (lança e interrompe o loop).
|
|
306
|
+
*/
|
|
307
|
+
id?: string | readonly string[] | ((element: T, index: number) => string | number | null | undefined) | null;
|
|
298
308
|
/** Atributos base do item (viram colunas no app) — presentes em qualquer desfecho, inclusive falha. */
|
|
299
309
|
payload?: (element: T, index: number) => Record<string, unknown> | undefined;
|
|
300
310
|
/** `op` da etapa de cada item no waterfall. Default: 'item'. */
|
|
@@ -311,6 +321,18 @@ interface RunItemsEachOptions<T> {
|
|
|
311
321
|
* Central na hora. `false` desliga (tudo sai no envio periódico ou no fim da run). Default: true.
|
|
312
322
|
*/
|
|
313
323
|
flush?: boolean;
|
|
324
|
+
/**
|
|
325
|
+
* Tentativas extras quando o handler lança (falha técnica). Uma etapa só por elemento,
|
|
326
|
+
* com `data.attempts`. `0` desliga. `Occurrence` nunca é retentada. Default: 1.
|
|
327
|
+
*/
|
|
328
|
+
retries?: number;
|
|
329
|
+
/** Espera entre as tentativas: ms fixo ou função da tentativa que falhou (1-based). Default: 5_000. */
|
|
330
|
+
retryDelayMs?: RetryDelay;
|
|
331
|
+
/**
|
|
332
|
+
* Na reexecução do mesmo trabalho (Central/Studio → executar novamente), pula o item cujo `id`
|
|
333
|
+
* já deu `succeeded`/`occurrence` — só `failed` roda de novo. `false` processa tudo. Default: true.
|
|
334
|
+
*/
|
|
335
|
+
skipDone?: boolean;
|
|
314
336
|
}
|
|
315
337
|
/** Totalizadores do `items.each`, pelo desfecho final de cada elemento. */
|
|
316
338
|
interface RunItemsEachResult {
|
|
@@ -318,6 +340,8 @@ interface RunItemsEachResult {
|
|
|
318
340
|
succeeded: number;
|
|
319
341
|
failed: number;
|
|
320
342
|
occurrence: number;
|
|
343
|
+
/** Já concluídos neste trabalho (reexecução): não rodaram, mas contam no `total`. */
|
|
344
|
+
skipped: number;
|
|
321
345
|
}
|
|
322
346
|
type RunItemsEachHandler<T> = (element: T, item: RunItemHandle, index: number) => unknown;
|
|
323
347
|
/**
|
|
@@ -462,4 +486,26 @@ declare const retry: <T>(fn: (attempt: number) => T | Promise<T>, options?: Retr
|
|
|
462
486
|
declare const image: (input: AttachInput, options?: ImageOptions) => ImageAttachment;
|
|
463
487
|
declare const isFileRef: (value: unknown) => value is FileRef;
|
|
464
488
|
|
|
465
|
-
|
|
489
|
+
/** Erros de controle do ciclo de vida de uma run — identificados pelo `name`, nunca pela classe. */
|
|
490
|
+
/**
|
|
491
|
+
* Ocorrência de negócio lançada de dentro do handler de `hobots.items.each`: o item vira
|
|
492
|
+
* `occurrence` com esta mensagem (e `payload`/`image`, se vierem), a etapa do item vira
|
|
493
|
+
* `warning` e o loop segue — **sem nova tentativa**: o retry do `each` é só para falha
|
|
494
|
+
* técnica (qualquer outro erro). Use para regra de negócio: "nota já cadastrada",
|
|
495
|
+
* "cliente sem pendência", "produto fora do cardápio".
|
|
496
|
+
*
|
|
497
|
+
* throw new Occurrence('nota já cadastrada', { situacao: 'já cadastrada' });
|
|
498
|
+
*
|
|
499
|
+
* Fora do `each` (handler de `register()`/`start()` sem loop) é um erro comum: a run falha
|
|
500
|
+
* com ele como com qualquer outro.
|
|
501
|
+
*/
|
|
502
|
+
declare class Occurrence extends Error {
|
|
503
|
+
readonly payload: Record<string, unknown> | undefined;
|
|
504
|
+
/** Print do item (bytes/caminho ou `hobots.image(...)`) — o `each` pendura no item. */
|
|
505
|
+
readonly image: ImageInput | undefined;
|
|
506
|
+
constructor(message: string, payload?: Record<string, unknown>, options?: {
|
|
507
|
+
image?: ImageInput;
|
|
508
|
+
});
|
|
509
|
+
}
|
|
510
|
+
|
|
511
|
+
export { type AttachInput, type CaptureAttachment, type CaptureHint, EnvironmentInput, EventType, type FileDownloadOptions, FileRef, type Hobots, type HobotsOptions, ImageAttachment, type ImageInput, type ImageOptions, type ItemColumnInput, type ItemsOptions, Occurrence, type RegisterOptions, type RetryDelay, type RetryOptions, RunAttachmentContentType, type RunContext, type RunFiles, type RunHandler, type RunItemHandle, type RunItemImageOptions, type RunItemOptions, RunItemStatus, type RunItems, type RunItemsEachHandler, type RunItemsEachOptions, type RunItemsEachResult, type RunLogger, type RunOptions, RunProgress, type RunProgressReporter, type StartOptions, type StepFn, type StepHandle, type StepOptions, captureException, close, hobots as default, hobots, image, isFileRef, register, retry, start };
|