# @t4h.framework/fs

## 0.13.1

### Patch Changes

- [#229](https://github.com/tech4humans-brasil/framework/pull/229) [`d4d7d97`](https://github.com/tech4humans-brasil/framework/commit/d4d7d973233ec1f4d78628a69283701b9a55fbf9) Thanks [@gusteycamargo](https://github.com/gusteycamargo)! - Fixes the published packages:
  - harness: the published types import `typings/PublicProperties.js`, which was not in `dist`. `uuidv7` is now a dependency.
  - dev: `tar` is now a dependency.
  - fs: the published types of `FileSplitActivity` no longer import `typebox`, which `fs` does not depend on.

- [#241](https://github.com/tech4humans-brasil/framework/pull/241) [`f6b8454`](https://github.com/tech4humans-brasil/framework/commit/f6b845484d22e7c8e7240fe2e113f1cdea7c8ce3) Thanks [@gusteycamargo](https://github.com/gusteycamargo)! - Adds seven rules to `@t4h.framework/core/eslint` and turns them on in `configs.recommended`:
  - `no-io-in-workflow` reports `fetch` and calls to network, file, database and mail modules in a workflow and in the `constructor`, `toInput` and `toOutput` of an activity. It also reports `zlib` and `stream` calls there, because they work on the content in memory on each replay.
  - `no-binary-subclass` reports a class that extends `Binary`.
  - `no-framework-activity-in-app` reports `new` and `extends` on an activity of a framework package other than the core.
  - `no-testing-import-in-source` reports an import of a `@t4h.framework/<package>/testing` entry out of a test file.
  - `require-workflow-id` reports a `Workflow` with no `id`.
  - `no-secret-to-string` reports a `Secret` that becomes a string.
  - `no-literal-secret-in-authorization` reports a string literal in the `secret` or `clientSecret` field of an `Authorization`.

  The package skills now name these rules in place of the text that the rules enforce. The docs and skills give each `Workflow` an `id`, read the HMAC secret from `EnvDesign`, and do not document a custom HTTP activity.

- [#238](https://github.com/tech4humans-brasil/framework/pull/238) [`8567806`](https://github.com/tech4humans-brasil/framework/commit/8567806ec537288076c3a18a4816f26d58a67905) Thanks [@gusteycamargo](https://github.com/gusteycamargo)! - The `framework-fs` skill says to call `Binary.stream()` only in a method of an activity, not in the workflow.

- [#240](https://github.com/tech4humans-brasil/framework/pull/240) [`0606115`](https://github.com/tech4humans-brasil/framework/commit/0606115e2e0baa994e9f0ed3559ee54ecac88e44) Thanks [@gusteycamargo](https://github.com/gusteycamargo)! - The skills do not repeat a rule that a lint rule, `tsc` or a runtime error already enforces. Each such rule is now one line that names the gate. The examples that broke a gate (`process.env`, `as any`, an inline secret, an `EnvDesign` in a workflow file, `ref.output` before `wait()`) are correct now.

- [#228](https://github.com/tech4humans-brasil/framework/pull/228) [`d29e1ab`](https://github.com/tech4humans-brasil/framework/commit/d29e1ab29a039b13c3e4b075472bd615566ae75e) Thanks [@gusteycamargo](https://github.com/gusteycamargo)! - Uses exact types and `unknown` in place of `any`, and checks external data with guards.
  - harness: the fix-issues prompt lists each sensor as `- checkTypes: PASS`. Before, it printed `- 0: [object Object]`.
  - hmac: an algorithm name such as `constructor` throws `Unsupported algorithm`.
  - oidc: a discovery response with no `introspection_endpoint`, or a null introspection body, throws a clear error.
  - `HttpRequestActivity.toOutput` takes `HttpRequestActivityOutput` in place of `any`.

## 0.13.0

### Minor Changes

- [#214](https://github.com/tech4humans-brasil/framework/pull/214) [`fc4db5f`](https://github.com/tech4humans-brasil/framework/commit/fc4db5fa01454a45a3727b76dbacc215aa6b3ab7) Thanks [@gusteycamargo](https://github.com/gusteycamargo)! - `split` reads the file once, as a stream: it cuts the records, drops the ones
  `where` rejects, groups the rest by `every` and hands each slice to
  `startMany` as a string as soon as it is complete. No durable copy of the file
  is written and no slice is read back by range. A slice may take up to 3 MiB
  (the same as the runtime's default limit for the input of a workflow
  run); past that the split fails while it reads, naming the byte the slice
  starts at, where `where` used to cap a record at 1 MiB and nothing capped a
  slice. `inlineMaxBytes` is removed: every slice reaches its child as a
  string. `ByteDelimiterScanner` is removed from the public API.

## 0.12.2

## 0.12.1

## 0.12.0

### Minor Changes

- [#190](https://github.com/tech4humans-brasil/framework/pull/190) [`910047b`](https://github.com/tech4humans-brasil/framework/commit/910047bf61dc0dd08ff02a1fb897b3629f264abc) Thanks [@gusteycamargo](https://github.com/gusteycamargo)! - Adds `WorkflowBatchCollectionRef`, a serializable batch handle (`id`, `count`) that can be narrowed with `filter({ status, where })`. Filters are immutable and compose (statuses intersect, wheres are `$and`ed); `join` from `@t4h.framework/fs` applies them on top of its own `status`/`where`. `WorkflowBatchRef` remains as a deprecated alias of the same class, so existing `new WorkflowBatchRef(...)`, `instanceof` checks and `split`/`join` calls keep working, and a join over an unfiltered ref records the same history input as before. The dev codec serializes the ref as the `workflow:batch-collection-ref` kind.

  Adds `size()`, `take(limit)` and `toArray()` to `WorkflowBatchCollectionRef`, each recorded as a single sync activity (`WorkflowBatchSizeActivity`, `WorkflowBatchTakeActivity`, `WorkflowBatchToArrayActivity`) built on the existing `WorkflowBatchClaim.outputs`. Runtimes that register activities explicitly must register the three new activities. The `where` operators and their validation moved to core as `WorkflowBatchQuery` (core now depends on `sift`), and `filter()` rejects a non-serializable `where` immediately.

  The dev server now rejects an activity whose serialized output is above 1 MiB (`ActivityOutputTooLargeException`), matching the runtime's limit on the size of an activity output.

## 0.11.0

### Minor Changes

- [#188](https://github.com/tech4humans-brasil/framework/pull/188) [`814b5e5`](https://github.com/tech4humans-brasil/framework/commit/814b5e5fd46eccb925041b695e03306e44b0432f) Thanks [@gusteycamargo](https://github.com/gusteycamargo)! - `split` accepts a `where` that drops junk records before any child workflow is
  started.

  The query is the same declarative MongoDB-style subset as `join`'s, plus
  `$regex`/`$options`, tested against each record as a string after `trim`.
  `every` groups only the kept records, and the durable copy is the filtered
  file. Like `join`, a function or `RegExp` is rejected in `toInput`, since the
  options are stored in the history.

## 0.10.0

### Minor Changes

- [#181](https://github.com/tech4humans-brasil/framework/pull/181) [`9449e4e`](https://github.com/tech4humans-brasil/framework/commit/9449e4e9889f42dea1d52418140f47d25dff0535) Thanks [@gusteycamargo](https://github.com/gusteycamargo)! - `split` hands a slice to its child as a string when it fits `inlineMaxBytes`
  (default 16 KiB) instead of a range read back from the durable copy.

  Every child paid a lookup and a ranged read to fetch a few hundred bytes, so a
  large file cost as many object reads as it has lines. The scanner keeps the
  bytes of the open slice while it is under the limit, so memory stays bounded
  by `inlineMaxBytes` whatever the file size. A larger slice still travels by
  range; `inlineMaxBytes: 0` restores the previous behavior.

### Patch Changes

- Updated dependencies [[`9449e4e`](https://github.com/tech4humans-brasil/framework/commit/9449e4e9889f42dea1d52418140f47d25dff0535), [`9449e4e`](https://github.com/tech4humans-brasil/framework/commit/9449e4e9889f42dea1d52418140f47d25dff0535)]:
  - @t4h.framework/core@0.15.0

## 0.9.5

### Patch Changes

- [#174](https://github.com/tech4humans-brasil/framework/pull/174) [`7cd75e4`](https://github.com/tech4humans-brasil/framework/commit/7cd75e4f557d9f5fbe3e486d5a3981186fa38797) Thanks [@gusteycamargo](https://github.com/gusteycamargo)! - Adds `asset(path)`, which reads a file shipped with the project.

  Fonts a PDF embeds, images a template draws, a fixed lookup table: they belong
  to the project, not to a run. Reading them with `readFileSync` appears to work
  and then costs dearly, because every primitive persists its input — a value
  holding a `Buffer` is serialized whole, once per activity that receives it, so
  a 1.5 MB font used by a workflow that runs per record is written into the
  history per record. `asset` returns a `Binary`, which travels as a reference
  and is read only where the bytes are needed.

  Declare the files in `framework.config.ts` under `build.assets` (renamed from
  `build.additionalFiles`, with no fallback — rename the key to keep shipping
  files). `build` now records the copied paths and `publish` sends them, so a
  runtime knows which entries of the artifact are assets. `AssetClaim` is the
  contract each runtime implements.

## 0.9.4

### Patch Changes

- Updated dependencies [[`aa72268`](https://github.com/tech4humans-brasil/framework/commit/aa72268d040a743743cac31cc14e26b8620b0e3f)]:
  - @t4h.framework/core@0.14.0

## 0.9.3

### Patch Changes

- Updated dependencies [[`1b1509f`](https://github.com/tech4humans-brasil/framework/commit/1b1509f9b6d2554dfab1f7633c3d022249e4fa01), [`1b1509f`](https://github.com/tech4humans-brasil/framework/commit/1b1509f9b6d2554dfab1f7633c3d022249e4fa01)]:
  - @t4h.framework/core@0.13.0

## 0.9.2

### Patch Changes

- Updated dependencies [[`72e08ff`](https://github.com/tech4humans-brasil/framework/commit/72e08ff86e0ce735ef73ccdf33b0dc01cdb8b6f5)]:
  - @t4h.framework/core@0.12.0

## 0.9.1

### Patch Changes

- Updated dependencies [[`8e8ffb2`](https://github.com/tech4humans-brasil/framework/commit/8e8ffb2ac0739e2f2a1f0af2ed9ebeffe2964776)]:
  - @t4h.framework/core@0.11.0

## 0.9.0

### Minor Changes

- Updated dependencies [[`8098041`](https://github.com/tech4humans-brasil/framework/commit/80980419d59a987378b7c94372ee2f7b7dcc00f5)]:
  - @t4h.framework/core@0.10.0

## 0.8.1

### Patch Changes

- [#152](https://github.com/tech4humans-brasil/framework/pull/152) [`e0f3f27`](https://github.com/tech4humans-brasil/framework/commit/e0f3f27bc3954e4f06604114dfbc0057f98d6e58) Thanks [@gusteycamargo](https://github.com/gusteycamargo)! - Fix import of sift create query tester

## 0.8.0

### Minor Changes

- [`8c56f76`](https://github.com/tech4humans-brasil/framework/commit/8c56f7697390a1ea966d1e91ff5f35ce5751a0d7) Thanks [@gusteycamargo](https://github.com/gusteycamargo)! - feat: write in-memory content to durable storage from a workflow

  There was no supported way to turn a string or a Buffer into a `Binary` inside
  a workflow — every `Binary` came from an existing file (`http` response,
  `sftp.get`, `split`, `join`). Anyone needing to upload computed content had to
  implement `Binary` by hand, and such an instance can never be persisted, so the
  activity carrying it failed to serialize.

  `write(content, options?)` covers that gap: it pushes an activity that stores
  the content through the `FileSystemClaim` and returns a `Binary` that survives
  replay.

  ```ts
  const file = await write(JSON.stringify(data), {
    contentType: 'application/json',
  })

  await sftp.put('/out/data.json', file)
  ```

  `FileSystemClaim.write` takes an optional `contentType` — until now the content
  type was always inferred from the file extension.

  The dev codec no longer diverges from the runtime one: its binary kind used to
  match only `DevFileBinary`, so a hand-written `Binary` was silently serialized
  as a plain object locally and blew up once deployed. It now matches any
  `Binary` and spools unknown ones to disk, the same way the runtime spools them
  to the file storage.

- [`8c56f76`](https://github.com/tech4humans-brasil/framework/commit/8c56f7697390a1ea966d1e91ff5f35ce5751a0d7) Thanks [@gusteycamargo](https://github.com/gusteycamargo)! - Adds FS write activity

## 0.7.0

### Minor Changes

- Adds support to read file ([#109](https://github.com/tech4humans-brasil/framework/pull/109))

## 0.6.0

### Minor Changes

- Adds activity to split and join binary ([#100](https://github.com/tech4humans-brasil/framework/pull/100))

## 0.5.0

### Patch Changes

- Update skills ([`6d7e7bc`](https://github.com/tech4humans-brasil/framework/commit/6d7e7bca0c780a9c53a0c9e5aa0a865c5af67959))

## 0.4.0

### Patch Changes

- Internal dependency updates

## 0.3.0

### Minor Changes

- Adds fs package ([`538c9bd`](https://github.com/tech4humans-brasil/framework/commit/538c9bd5c49031ceb94ef8d6c513f6ffc9c848c5))
- Adds support to buffer in fs write package ([`476f9f0`](https://github.com/tech4humans-brasil/framework/commit/476f9f08a7b379a3361e42f8577078462276210b))
- Adds .ai/skills in packages ([#88](https://github.com/tech4humans-brasil/framework/pull/88))

### Patch Changes

- Remove activity prefix from file system claim class name ([`d257bd1`](https://github.com/tech4humans-brasil/framework/commit/d257bd177d477a56a897ba862a0be1f50531c633))
- Adds github workflow to run, build, tests and lint ([#18](https://github.com/tech4humans-brasil/framework/pull/18))
- Adds readme ([`3a55794`](https://github.com/tech4humans-brasil/framework/commit/3a557942769fa022b9a39504046d22b0083e734f))
- Update package metadata and author information across multiple packages ([`2ca73df`](https://github.com/tech4humans-brasil/framework/commit/2ca73df42dc63c86ed44717b50d5402fca45b4e7))
- Improve repository info ([`1fad92d`](https://github.com/tech4humans-brasil/framework/commit/1fad92d959b804189fd1486d047115995ac81eb0))
- Fix resolve module resolution issues in check-types ([`c97a0d2`](https://github.com/tech4humans-brasil/framework/commit/c97a0d2747f38e561cc5c7d592b20de0459bc1ee))
- Update package dependencies across multiple packages ([`8b4fc1d`](https://github.com/tech4humans-brasil/framework/commit/8b4fc1d0e92d6bd880ddf4c8119fb68c49c53760))
