@apicrafthq/script-sdk 0.1.0-beta.2 → 0.1.0-beta.3
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.ts +10 -4
- package/package.json +4 -2
package/dist/index.d.ts
CHANGED
|
@@ -14,11 +14,17 @@ interface HttpRequestInit {
|
|
|
14
14
|
/** Workflow scripts only: resolve `{{placeholders}}` against this API's bound environment. */
|
|
15
15
|
api?: string;
|
|
16
16
|
}
|
|
17
|
-
|
|
17
|
+
/**
|
|
18
|
+
* Parsed JSON when the response is JSON, the raw string otherwise, null when empty.
|
|
19
|
+
* Kept permissive so scripts can write `body.items[0].id` without narrowing first.
|
|
20
|
+
*/
|
|
21
|
+
type HttpResponseBody = any;
|
|
22
|
+
interface HttpResponse<TBody = HttpResponseBody> {
|
|
18
23
|
status: number;
|
|
19
24
|
statusText: string;
|
|
20
25
|
headers: Record<string, string>;
|
|
21
|
-
body:
|
|
26
|
+
body: TBody;
|
|
27
|
+
duration?: number;
|
|
22
28
|
}
|
|
23
29
|
/** Persistent key/value store across executions. */
|
|
24
30
|
interface ScriptCache {
|
|
@@ -87,7 +93,7 @@ type WorkflowBlockId = keyof BlockResultSchema extends never ? string : keyof Bl
|
|
|
87
93
|
/** Shared base for workflow scripts (assert, condition, transform, script). */
|
|
88
94
|
interface WorkflowScopedContext extends BaseContext {
|
|
89
95
|
/** Reads the result of a previous block by its id. */
|
|
90
|
-
blockResult(blockId:
|
|
96
|
+
blockResult<K extends WorkflowBlockId>(blockId: K): K extends keyof BlockResultSchema ? BlockResultSchema[K] : BlockResult;
|
|
91
97
|
/** Resolved environment of an API bound to this run. Throws when the API is unbound. */
|
|
92
98
|
env(apiSlug: string): Promise<Record<string, string | number | boolean>>;
|
|
93
99
|
}
|
|
@@ -111,4 +117,4 @@ interface ScriptContext extends WorkflowScopedContext {
|
|
|
111
117
|
sleep(milliseconds: number): Promise<void>;
|
|
112
118
|
}
|
|
113
119
|
|
|
114
|
-
export type { AfterResponseContext, AssertContext, BaseContext, BeforeRequestContext, BlockResult, BlockResultSchema, ConditionContext, EnvSchema, HttpClient, HttpRequestInit, HttpResponse, MutableResolvedRequest, RequestScopedContext, ResolvedRequest, ScriptCache, ScriptContext, ScriptLogger, TransformContext, WorkflowScopedContext };
|
|
120
|
+
export type { AfterResponseContext, AssertContext, BaseContext, BeforeRequestContext, BlockResult, BlockResultSchema, ConditionContext, EnvSchema, HttpClient, HttpRequestInit, HttpResponse, HttpResponseBody, MutableResolvedRequest, RequestScopedContext, ResolvedRequest, ScriptCache, ScriptContext, ScriptLogger, TransformContext, WorkflowScopedContext };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@apicrafthq/script-sdk",
|
|
3
|
-
"version": "0.1.0-beta.
|
|
3
|
+
"version": "0.1.0-beta.3",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "TypeScript types for API Craft middleware and custom-auth scripts.",
|
|
6
6
|
"license": "MIT",
|
|
@@ -34,6 +34,7 @@
|
|
|
34
34
|
},
|
|
35
35
|
"exports": {
|
|
36
36
|
".": {
|
|
37
|
+
"development": "./src/index.ts",
|
|
37
38
|
"types": "./dist/index.d.ts",
|
|
38
39
|
"import": "./dist/index.js"
|
|
39
40
|
}
|
|
@@ -44,6 +45,7 @@
|
|
|
44
45
|
},
|
|
45
46
|
"scripts": {
|
|
46
47
|
"build": "tsup src/index.ts --format esm --dts --clean",
|
|
47
|
-
"dev": "tsup src/index.ts --format esm --dts --watch"
|
|
48
|
+
"dev": "tsup src/index.ts --format esm --dts --watch",
|
|
49
|
+
"typecheck": "tsc --noEmit -p tsconfig.json"
|
|
48
50
|
}
|
|
49
51
|
}
|