@t4h.framework/dev 0.13.2 → 0.14.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/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,46 @@
|
|
|
1
1
|
# @t4h.framework/dev
|
|
2
2
|
|
|
3
|
+
## 0.14.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- [`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
|
|
8
|
+
|
|
9
|
+
There was no supported way to turn a string or a Buffer into a `Binary` inside
|
|
10
|
+
a workflow — every `Binary` came from an existing file (`http` response,
|
|
11
|
+
`sftp.get`, `split`, `join`). Anyone needing to upload computed content had to
|
|
12
|
+
implement `Binary` by hand, and such an instance can never be persisted, so the
|
|
13
|
+
activity carrying it failed to serialize.
|
|
14
|
+
|
|
15
|
+
`write(content, options?)` covers that gap: it pushes an activity that stores
|
|
16
|
+
the content through the `FileSystemClaim` and returns a `Binary` that survives
|
|
17
|
+
replay.
|
|
18
|
+
|
|
19
|
+
```ts
|
|
20
|
+
const file = await write(JSON.stringify(data), {
|
|
21
|
+
contentType: 'application/json',
|
|
22
|
+
})
|
|
23
|
+
|
|
24
|
+
await sftp.put('/out/data.json', file)
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
`FileSystemClaim.write` takes an optional `contentType` — until now the content
|
|
28
|
+
type was always inferred from the file extension.
|
|
29
|
+
|
|
30
|
+
The dev codec no longer diverges from the runtime one: its binary kind used to
|
|
31
|
+
match only `DevFileBinary`, so a hand-written `Binary` was silently serialized
|
|
32
|
+
as a plain object locally and blew up once deployed. It now matches any
|
|
33
|
+
`Binary` and spools unknown ones to disk, the same way the runtime spools them
|
|
34
|
+
to the file storage.
|
|
35
|
+
|
|
36
|
+
- [`8c56f76`](https://github.com/tech4humans-brasil/framework/commit/8c56f7697390a1ea966d1e91ff5f35ce5751a0d7) Thanks [@gusteycamargo](https://github.com/gusteycamargo)! - Adds FS write activity
|
|
37
|
+
|
|
38
|
+
### Patch Changes
|
|
39
|
+
|
|
40
|
+
- Updated dependencies [[`8c56f76`](https://github.com/tech4humans-brasil/framework/commit/8c56f7697390a1ea966d1e91ff5f35ce5751a0d7), [`8c56f76`](https://github.com/tech4humans-brasil/framework/commit/8c56f7697390a1ea966d1e91ff5f35ce5751a0d7)]:
|
|
41
|
+
- @t4h.framework/fs@0.8.0
|
|
42
|
+
- @t4h.framework/http@1.0.0
|
|
43
|
+
|
|
3
44
|
## 0.13.2
|
|
4
45
|
|
|
5
46
|
### Patch Changes
|
|
@@ -3,7 +3,7 @@ import type { Binary } from '@t4h.framework/core';
|
|
|
3
3
|
import { FileSystemClaim } from '@t4h.framework/fs';
|
|
4
4
|
import { DevFileBinary } from '../DevFileBinary.js';
|
|
5
5
|
export declare class DevFileSystemClaim extends FileSystemClaim {
|
|
6
|
-
write(filepath: string, readable: Readable): Promise<DevFileBinary>;
|
|
6
|
+
write(filepath: string, readable: Readable | Buffer, contentType?: string): Promise<DevFileBinary>;
|
|
7
7
|
read(filepath: string): Promise<DevFileBinary>;
|
|
8
8
|
slice(binary: Binary, range: {
|
|
9
9
|
start: number;
|
|
@@ -6,7 +6,7 @@ import { FileSystemClaim } from '@t4h.framework/fs';
|
|
|
6
6
|
import mime from 'mime-types';
|
|
7
7
|
import { DevFileBinary } from '../DevFileBinary.js';
|
|
8
8
|
export class DevFileSystemClaim extends FileSystemClaim {
|
|
9
|
-
async write(filepath, readable) {
|
|
9
|
+
async write(filepath, readable, contentType) {
|
|
10
10
|
const { base } = path.parse(filepath);
|
|
11
11
|
const tempDir = await fs.promises.mkdtemp(path.join(os.tmpdir(), 'fs-'));
|
|
12
12
|
const _filepath = path.join(tempDir, filepath);
|
|
@@ -15,7 +15,7 @@ export class DevFileSystemClaim extends FileSystemClaim {
|
|
|
15
15
|
const stat = await fs.promises.stat(_filepath);
|
|
16
16
|
return DevFileBinary.from({
|
|
17
17
|
path: _filepath,
|
|
18
|
-
contentType: mime.lookup(base) || 'application/octet-stream',
|
|
18
|
+
contentType: contentType || mime.lookup(base) || 'application/octet-stream',
|
|
19
19
|
contentLength: stat.size,
|
|
20
20
|
});
|
|
21
21
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DevFileSystemClaim.js","sourceRoot":"","sources":["../../../src/models/claims/DevFileSystemClaim.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,SAAS,CAAA;AACxB,OAAO,EAAE,MAAM,SAAS,CAAA;AACxB,OAAO,IAAI,MAAM,WAAW,CAAA;AAC5B,OAAO,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAA;AAGtC,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAA;AACnD,OAAO,IAAI,MAAM,YAAY,CAAA;AAE7B,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAA;AAEnD,MAAM,OAAO,kBAAmB,SAAQ,eAAe;IAC9C,KAAK,CAAC,KAAK,CAChB,QAAgB,EAChB,
|
|
1
|
+
{"version":3,"file":"DevFileSystemClaim.js","sourceRoot":"","sources":["../../../src/models/claims/DevFileSystemClaim.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,SAAS,CAAA;AACxB,OAAO,EAAE,MAAM,SAAS,CAAA;AACxB,OAAO,IAAI,MAAM,WAAW,CAAA;AAC5B,OAAO,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAA;AAGtC,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAA;AACnD,OAAO,IAAI,MAAM,YAAY,CAAA;AAE7B,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAA;AAEnD,MAAM,OAAO,kBAAmB,SAAQ,eAAe;IAC9C,KAAK,CAAC,KAAK,CAChB,QAAgB,EAChB,QAA2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zB,IAAI,CAAC,CAAC,MAAM,YAAY,aAAa,CAAC;YACpC,MAAM,IAAI,SAAS,CAAC,kDAAkD,CAAC,CAAA;QAEzE,OAAO,aAAa,CAAC,KAAK,CAAC,MAAM,EAAE,KAAK,EAAE,QAAQ,CAAC,CAAA;IACrD,CAAC;CACF"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@t4h.framework/dev",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.14.0",
|
|
4
4
|
"description": "Dev server for the T4H Framework",
|
|
5
5
|
"homepage": "https://github.com/tech4humans-brasil/framework/tree/main/packages/dev",
|
|
6
6
|
"bugs": "https://github.com/tech4humans-brasil/framework/issues",
|
|
@@ -43,8 +43,8 @@
|
|
|
43
43
|
},
|
|
44
44
|
"dependencies": {
|
|
45
45
|
"@t4h.framework/cache": "^0.5.0",
|
|
46
|
-
"@t4h.framework/fs": "^0.
|
|
47
|
-
"@t4h.framework/http": "^0.
|
|
46
|
+
"@t4h.framework/fs": "^0.8.0",
|
|
47
|
+
"@t4h.framework/http": "^1.0.0",
|
|
48
48
|
"@t4h.framework/orm": "^0.6.1",
|
|
49
49
|
"@t4h.framework/runtime-claims": "^0.1.0",
|
|
50
50
|
"@t4h.framework/sftp": "^0.6.0",
|