@funcd-dev/shim 0.4.0 → 0.4.2
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/blob.js +2 -0
- package/dist/kv.js +2 -0
- package/dist/types.d.ts +6 -1
- package/package.json +2 -1
package/dist/blob.js
CHANGED
|
@@ -16,6 +16,8 @@ function request(method, path, body) {
|
|
|
16
16
|
headers['content-length'] = body.byteLength;
|
|
17
17
|
const req = http.request({ socketPath, path, method, headers }, (res) => {
|
|
18
18
|
const chunks = [];
|
|
19
|
+
// A connection that drops mid-body errors the response, not the request, and never ends it.
|
|
20
|
+
res.on('error', (err) => reject(new Error(`context.blob ${method} ${path} failed: connection closed before the reply ended`, { cause: err })));
|
|
19
21
|
res.on('data', (c) => chunks.push(c));
|
|
20
22
|
res.on('end', () => resolve({ status: res.statusCode ?? 0, body: Buffer.concat(chunks) }));
|
|
21
23
|
});
|
package/dist/kv.js
CHANGED
|
@@ -14,6 +14,8 @@ function request(method, path, body) {
|
|
|
14
14
|
headers['content-length'] = body.byteLength;
|
|
15
15
|
const req = http.request({ socketPath, path, method, headers }, (res) => {
|
|
16
16
|
const chunks = [];
|
|
17
|
+
// A connection that drops mid-body errors the response, not the request, and never ends it.
|
|
18
|
+
res.on('error', (err) => reject(new Error(`context.kv ${method} ${path} failed: connection closed before the reply ended`, { cause: err })));
|
|
17
19
|
res.on('data', (c) => chunks.push(c));
|
|
18
20
|
res.on('end', () => resolve({ status: res.statusCode ?? 0, body: Buffer.concat(chunks) }));
|
|
19
21
|
});
|
package/dist/types.d.ts
CHANGED
|
@@ -21,7 +21,12 @@ export interface FunctionContext {
|
|
|
21
21
|
log(...args: unknown[]): void;
|
|
22
22
|
/** Synchronously invoke a linked function by its spec.links alias (ADR-0064). The input is
|
|
23
23
|
* validated against the target's contract by the target's shim; its result is returned. Fails
|
|
24
|
-
* closed (rejects) if the caller declares no such link.
|
|
24
|
+
* closed (rejects) if the caller declares no such link.
|
|
25
|
+
*
|
|
26
|
+
* The target receives `input` as its `event.data`, except that an object with a top-level `data` or
|
|
27
|
+
* `specversion` key is taken as a full CloudEvent envelope (ADR-0134): the target receives only its
|
|
28
|
+
* `data`, and the other keys are dropped. To send an object that has its own `data` key, wrap it in an
|
|
29
|
+
* envelope: `{ specversion: '1.0', data: { data: [1], page: 2 } }`. */
|
|
25
30
|
invoke<I = unknown, O = unknown>(alias: string, input: I): Promise<O>;
|
|
26
31
|
/** Namespace-scoped key-value storage (ADR-0069): get/put/del a binding's key, or list keys. */
|
|
27
32
|
kv: KVClient;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@funcd-dev/shim",
|
|
3
|
-
"version": "0.4.
|
|
3
|
+
"version": "0.4.2",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "Types and the contract build for writing funcd functions in TypeScript",
|
|
6
6
|
"license": "Apache-2.0",
|
|
@@ -39,6 +39,7 @@
|
|
|
39
39
|
},
|
|
40
40
|
"dependencies": {
|
|
41
41
|
"ajv": "^8.20.0",
|
|
42
|
+
"ajv-formats": "^3.0.1",
|
|
42
43
|
"ts-json-schema-generator": "^2.9.0"
|
|
43
44
|
},
|
|
44
45
|
"devDependencies": {
|