hobots 3.0.0 → 3.2.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/dist/index.d.cts CHANGED
@@ -1,5 +1,5 @@
1
1
  import { RunLogLevel, RunAttachmentContentType, EventType, EnvironmentInput, MachineSnapshot, EventPayload, TransactionPayload, HeartbeatPayload, StepStatus, StepData, RunItemStatus, RunProgress } from './protocol.cjs';
2
- export { Breadcrumb, BreadcrumbLevel, Envelope, EnvelopeItem, Environment, EventUser, ExceptionData, InstanceInfo, MachineProcess, PollRequest, PollResponse, RunAttachmentConfirmRequest, RunAttachmentConfirmResponse, RunAttachmentCreateRequest, RunAttachmentCreateResponse, RunCreateRequest, RunCreateResponse, RunDescriptor, RunError, RunItemInput, RunItemsCreateRequest, RunItemsCreateResponse, RunLogEntry, RunStatus, RunUpdateRequest, RunUpdateResponse, RunUpdateStatus, StackFrame } from './protocol.cjs';
2
+ export { Breadcrumb, BreadcrumbLevel, Envelope, EnvelopeItem, Environment, EventUser, ExceptionData, InstanceInfo, ItemColumn, MachineProcess, PollRequest, PollResponse, RunAttachmentConfirmRequest, RunAttachmentConfirmResponse, RunAttachmentCreateRequest, RunAttachmentCreateResponse, RunCreateRequest, RunCreateResponse, RunDescriptor, RunError, RunItemInput, RunItemsCreateRequest, RunItemsCreateResponse, RunLogEntry, RunStatus, RunUpdateRequest, RunUpdateResponse, RunUpdateStatus, StackFrame, TaskItemsDeclaration } 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);
@@ -37,6 +37,18 @@ interface AttachResult {
37
37
  /** Aceita tudo que o handler pode ter em mãos: bytes ou um caminho de arquivo (só Node). */
38
38
  type AttachInput = Uint8Array | ArrayBuffer | string;
39
39
 
40
+ interface Logger {
41
+ debug: (...args: unknown[]) => void;
42
+ warn: (...args: unknown[]) => void;
43
+ error: (...args: unknown[]) => void;
44
+ }
45
+
46
+ /** Coluna de itens como o dev declara: só a chave, ou chave + rótulo. */
47
+ type ItemColumnInput = string | {
48
+ key: string;
49
+ label?: string;
50
+ };
51
+
40
52
  /**
41
53
  * Opções do processo (telemetria, identidade, handlers globais). Valem as da PRIMEIRA
42
54
  * chamada a register()/start(); chamadas seguintes com valores diferentes avisam e são ignoradas.
@@ -52,7 +64,8 @@ interface HobotsOptions {
52
64
  /**
53
65
  * Ambiente lógico onde este robô roda: 'development', 'testing', 'staging' ou
54
66
  * 'production'. Vai em todo evento, transaction e na identidade da instância — é por
55
- * ele que as regras de alerta decidem se notificam. Default: 'production'.
67
+ * ele que as regras de alerta decidem se notificam. Default: env HOBOTS_ENVIRONMENT;
68
+ * sem ela, 'production'.
56
69
  */
57
70
  environment?: EnvironmentInput;
58
71
  /** Versão do programa, ex.: 'robo-nfe@1.4.2' */
@@ -75,8 +88,20 @@ interface HobotsOptions {
75
88
  */
76
89
  installExitHandlers?: boolean;
77
90
  }
91
+ /** Colunas de itens declaradas no código (até 12; chave: letras, números, `.`, `-`, `_`). */
92
+ interface TaskItemsOptions {
93
+ columns: ItemColumnInput[];
94
+ }
78
95
  /** Opções de uma task (register ou start). */
79
96
  interface TaskOptions extends HobotsOptions {
97
+ /**
98
+ * Colunas da aba "itens" da execução na plataforma: chaves do `payload` que cada
99
+ * item reportado (`ctx.items.*`) carrega, com rótulo opcional. Independe de
100
+ * formulário — vale para register e start. Personalizar na plataforma
101
+ * (Configurações → agente) sobrepõe o que for declarado aqui.
102
+ * Ex.: `{ columns: ['numero_nota', { key: 'valor', label: 'valor (R$)' }] }`
103
+ */
104
+ items?: TaskItemsOptions;
80
105
  /**
81
106
  * Tentativas extras do handler quando ele lança, na mesma run (itens e progresso já
82
107
  * enviados permanecem — escreva handlers idempotentes). Cancelamento e timeout nunca
@@ -150,12 +175,6 @@ interface ResolvedConfig {
150
175
  tasksBaseUrl: string;
151
176
  }
152
177
 
153
- interface Logger {
154
- debug: (...args: unknown[]) => void;
155
- warn: (...args: unknown[]) => void;
156
- error: (...args: unknown[]) => void;
157
- }
158
-
159
178
  /**
160
179
  * Coleta CPU/memória/disco da máquina e do processo — só em Node (no browser é no-op).
161
180
  *
@@ -290,12 +309,16 @@ declare class Transaction {
290
309
  finish(): void;
291
310
  }
292
311
 
312
+ /**
313
+ * `hobots.log`: cada método aceita vários argumentos, como `console.log` — cada um vira
314
+ * texto (`safeString`) e são unidos por espaço. Nunca lança, nem com a run cancelada.
315
+ */
293
316
  interface RunLogger {
294
- debug(message: string): void;
295
- info(message: string): void;
296
- warn(message: string): void;
297
- error(message: string): void;
298
- success(message: string): void;
317
+ debug(message: unknown, ...rest: unknown[]): void;
318
+ info(message: unknown, ...rest: unknown[]): void;
319
+ warn(message: unknown, ...rest: unknown[]): void;
320
+ error(message: unknown, ...rest: unknown[]): void;
321
+ success(message: unknown, ...rest: unknown[]): void;
299
322
  }
300
323
  interface RunItemOptions {
301
324
  /**
@@ -411,4 +434,4 @@ declare const close: (timeoutMs?: number) => Promise<boolean>;
411
434
  declare const captureException: (error: unknown, hint?: CaptureHint) => string | undefined;
412
435
  declare const retry: <T>(fn: (attempt: number) => T | Promise<T>, options?: RetryOptions) => Promise<T>;
413
436
 
414
- export { type AttachFailureReason, type AttachInput, type AttachOptions, type AttachResult, type CaptureAttachment, type CaptureHint, EnvironmentInput, EventPayload, EventType, HeartbeatPayload, type Hobots, type HobotsOptions, MachineSnapshot, type RegisterOptions, type RetryDelay, type RetryOptions, RunAttachmentContentType, type RunContext, type RunItemOptions, RunItemStatus, type RunItems, RunLogLevel, type RunLogger, RunProgress, type RunProgressReporter, type StartOptions, Step, StepData, StepStatus, type TaskHandler, type TaskOptions, Transaction, TransactionPayload, captureException, close, hobots as default, hobots, register, retry, start };
437
+ export { type AttachFailureReason, type AttachInput, type AttachOptions, type AttachResult, type CaptureAttachment, type CaptureHint, EnvironmentInput, EventPayload, EventType, HeartbeatPayload, type Hobots, type HobotsOptions, type ItemColumnInput, MachineSnapshot, type RegisterOptions, type RetryDelay, type RetryOptions, RunAttachmentContentType, type RunContext, type RunItemOptions, RunItemStatus, type RunItems, RunLogLevel, type RunLogger, RunProgress, type RunProgressReporter, type StartOptions, Step, StepData, StepStatus, type TaskHandler, type TaskItemsOptions, type TaskOptions, Transaction, TransactionPayload, captureException, close, hobots as default, hobots, register, retry, start };
package/dist/index.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  import { RunLogLevel, RunAttachmentContentType, EventType, EnvironmentInput, MachineSnapshot, EventPayload, TransactionPayload, HeartbeatPayload, StepStatus, StepData, RunItemStatus, RunProgress } from './protocol.js';
2
- export { Breadcrumb, BreadcrumbLevel, Envelope, EnvelopeItem, Environment, EventUser, ExceptionData, InstanceInfo, MachineProcess, PollRequest, PollResponse, RunAttachmentConfirmRequest, RunAttachmentConfirmResponse, RunAttachmentCreateRequest, RunAttachmentCreateResponse, RunCreateRequest, RunCreateResponse, RunDescriptor, RunError, RunItemInput, RunItemsCreateRequest, RunItemsCreateResponse, RunLogEntry, RunStatus, RunUpdateRequest, RunUpdateResponse, RunUpdateStatus, StackFrame } from './protocol.js';
2
+ export { Breadcrumb, BreadcrumbLevel, Envelope, EnvelopeItem, Environment, EventUser, ExceptionData, InstanceInfo, ItemColumn, MachineProcess, PollRequest, PollResponse, RunAttachmentConfirmRequest, RunAttachmentConfirmResponse, RunAttachmentCreateRequest, RunAttachmentCreateResponse, RunCreateRequest, RunCreateResponse, RunDescriptor, RunError, RunItemInput, RunItemsCreateRequest, RunItemsCreateResponse, RunLogEntry, RunStatus, RunUpdateRequest, RunUpdateResponse, RunUpdateStatus, StackFrame, TaskItemsDeclaration } 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);
@@ -37,6 +37,18 @@ interface AttachResult {
37
37
  /** Aceita tudo que o handler pode ter em mãos: bytes ou um caminho de arquivo (só Node). */
38
38
  type AttachInput = Uint8Array | ArrayBuffer | string;
39
39
 
40
+ interface Logger {
41
+ debug: (...args: unknown[]) => void;
42
+ warn: (...args: unknown[]) => void;
43
+ error: (...args: unknown[]) => void;
44
+ }
45
+
46
+ /** Coluna de itens como o dev declara: só a chave, ou chave + rótulo. */
47
+ type ItemColumnInput = string | {
48
+ key: string;
49
+ label?: string;
50
+ };
51
+
40
52
  /**
41
53
  * Opções do processo (telemetria, identidade, handlers globais). Valem as da PRIMEIRA
42
54
  * chamada a register()/start(); chamadas seguintes com valores diferentes avisam e são ignoradas.
@@ -52,7 +64,8 @@ interface HobotsOptions {
52
64
  /**
53
65
  * Ambiente lógico onde este robô roda: 'development', 'testing', 'staging' ou
54
66
  * 'production'. Vai em todo evento, transaction e na identidade da instância — é por
55
- * ele que as regras de alerta decidem se notificam. Default: 'production'.
67
+ * ele que as regras de alerta decidem se notificam. Default: env HOBOTS_ENVIRONMENT;
68
+ * sem ela, 'production'.
56
69
  */
57
70
  environment?: EnvironmentInput;
58
71
  /** Versão do programa, ex.: 'robo-nfe@1.4.2' */
@@ -75,8 +88,20 @@ interface HobotsOptions {
75
88
  */
76
89
  installExitHandlers?: boolean;
77
90
  }
91
+ /** Colunas de itens declaradas no código (até 12; chave: letras, números, `.`, `-`, `_`). */
92
+ interface TaskItemsOptions {
93
+ columns: ItemColumnInput[];
94
+ }
78
95
  /** Opções de uma task (register ou start). */
79
96
  interface TaskOptions extends HobotsOptions {
97
+ /**
98
+ * Colunas da aba "itens" da execução na plataforma: chaves do `payload` que cada
99
+ * item reportado (`ctx.items.*`) carrega, com rótulo opcional. Independe de
100
+ * formulário — vale para register e start. Personalizar na plataforma
101
+ * (Configurações → agente) sobrepõe o que for declarado aqui.
102
+ * Ex.: `{ columns: ['numero_nota', { key: 'valor', label: 'valor (R$)' }] }`
103
+ */
104
+ items?: TaskItemsOptions;
80
105
  /**
81
106
  * Tentativas extras do handler quando ele lança, na mesma run (itens e progresso já
82
107
  * enviados permanecem — escreva handlers idempotentes). Cancelamento e timeout nunca
@@ -150,12 +175,6 @@ interface ResolvedConfig {
150
175
  tasksBaseUrl: string;
151
176
  }
152
177
 
153
- interface Logger {
154
- debug: (...args: unknown[]) => void;
155
- warn: (...args: unknown[]) => void;
156
- error: (...args: unknown[]) => void;
157
- }
158
-
159
178
  /**
160
179
  * Coleta CPU/memória/disco da máquina e do processo — só em Node (no browser é no-op).
161
180
  *
@@ -290,12 +309,16 @@ declare class Transaction {
290
309
  finish(): void;
291
310
  }
292
311
 
312
+ /**
313
+ * `hobots.log`: cada método aceita vários argumentos, como `console.log` — cada um vira
314
+ * texto (`safeString`) e são unidos por espaço. Nunca lança, nem com a run cancelada.
315
+ */
293
316
  interface RunLogger {
294
- debug(message: string): void;
295
- info(message: string): void;
296
- warn(message: string): void;
297
- error(message: string): void;
298
- success(message: string): void;
317
+ debug(message: unknown, ...rest: unknown[]): void;
318
+ info(message: unknown, ...rest: unknown[]): void;
319
+ warn(message: unknown, ...rest: unknown[]): void;
320
+ error(message: unknown, ...rest: unknown[]): void;
321
+ success(message: unknown, ...rest: unknown[]): void;
299
322
  }
300
323
  interface RunItemOptions {
301
324
  /**
@@ -411,4 +434,4 @@ declare const close: (timeoutMs?: number) => Promise<boolean>;
411
434
  declare const captureException: (error: unknown, hint?: CaptureHint) => string | undefined;
412
435
  declare const retry: <T>(fn: (attempt: number) => T | Promise<T>, options?: RetryOptions) => Promise<T>;
413
436
 
414
- export { type AttachFailureReason, type AttachInput, type AttachOptions, type AttachResult, type CaptureAttachment, type CaptureHint, EnvironmentInput, EventPayload, EventType, HeartbeatPayload, type Hobots, type HobotsOptions, MachineSnapshot, type RegisterOptions, type RetryDelay, type RetryOptions, RunAttachmentContentType, type RunContext, type RunItemOptions, RunItemStatus, type RunItems, RunLogLevel, type RunLogger, RunProgress, type RunProgressReporter, type StartOptions, Step, StepData, StepStatus, type TaskHandler, type TaskOptions, Transaction, TransactionPayload, captureException, close, hobots as default, hobots, register, retry, start };
437
+ export { type AttachFailureReason, type AttachInput, type AttachOptions, type AttachResult, type CaptureAttachment, type CaptureHint, EnvironmentInput, EventPayload, EventType, HeartbeatPayload, type Hobots, type HobotsOptions, type ItemColumnInput, MachineSnapshot, type RegisterOptions, type RetryDelay, type RetryOptions, RunAttachmentContentType, type RunContext, type RunItemOptions, RunItemStatus, type RunItems, RunLogLevel, type RunLogger, RunProgress, type RunProgressReporter, type StartOptions, Step, StepData, StepStatus, type TaskHandler, type TaskItemsOptions, type TaskOptions, Transaction, TransactionPayload, captureException, close, hobots as default, hobots, register, retry, start };