@harborclient/sdk 1.0.37 → 1.0.39

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.
Files changed (2) hide show
  1. package/dist/snippets.d.ts +131 -0
  2. package/package.json +14 -2
@@ -0,0 +1,131 @@
1
+ /**
2
+ * Ambient globals for HarborClient request/post-request script snippets.
3
+ *
4
+ * Keep in sync with the runtime hc sandbox in harborclient
5
+ * `src/main/scripting/scriptApi.ts` and editor completions in
6
+ * `src/renderer/src/scripting/hcCompletions.ts`.
7
+ */
8
+
9
+ /**
10
+ * Header helpers on hc.request.headers and hc.collection.headers.
11
+ */
12
+ interface HcHeaderApi {
13
+ /**
14
+ * Returns the first enabled header value for key (case-insensitive), or undefined.
15
+ */
16
+ get(key: string): string | undefined;
17
+
18
+ /**
19
+ * Sets an existing header or appends a new enabled row.
20
+ */
21
+ upsert(key: string, value: string): void;
22
+
23
+ /**
24
+ * Returns enabled headers as a flat key/value map.
25
+ */
26
+ toObject(): Record<string, string>;
27
+ }
28
+
29
+ /**
30
+ * Variable helpers on hc.variables, hc.collection.variables, hc.environment.variables, and hc.globals.
31
+ */
32
+ interface HcVariablesApi {
33
+ /**
34
+ * Returns a variable value, preferring values set in the current script run.
35
+ */
36
+ get(key: string): string | undefined;
37
+
38
+ /**
39
+ * Sets a variable for the remainder of the script run.
40
+ */
41
+ set(key: string, value: unknown): void;
42
+
43
+ /**
44
+ * Replaces {{variable}} tokens and dynamic $ tokens in a template string.
45
+ */
46
+ replaceIn(template: unknown): string;
47
+ }
48
+
49
+ /**
50
+ * Chai-lite matcher returned by hc.expect(actual).
51
+ */
52
+ interface HcExpectMatcher {
53
+ to: {
54
+ equal(expected: unknown): void;
55
+ eql(expected: unknown): void;
56
+ include(substr: string): void;
57
+ };
58
+ be: {
59
+ ok(): void;
60
+ };
61
+ }
62
+
63
+ /**
64
+ * Element surface exposed by hc.response.document() for HTML bodies.
65
+ */
66
+ interface HcResponseElement {
67
+ textContent: string;
68
+ getAttribute(name: string): string | null;
69
+ innerHTML: string;
70
+ }
71
+
72
+ /**
73
+ * Document surface backed by Cheerio for querying HTML response bodies.
74
+ */
75
+ interface HcResponseDocument {
76
+ querySelector(selector: string): HcResponseElement | null;
77
+ querySelectorAll(selector: string): HcResponseElement[];
78
+ }
79
+
80
+ /**
81
+ * Response snapshot available in post-request scripts as hc.response.
82
+ */
83
+ interface HcResponseApi {
84
+ readonly code: number;
85
+ readonly status: string;
86
+ readonly headers: Record<string, string>;
87
+ readonly responseTime: number;
88
+ text(): string;
89
+ json(): unknown;
90
+ document(): HcResponseDocument;
91
+ }
92
+
93
+ /**
94
+ * HarborClient script sandbox API exposed as the global hc object.
95
+ */
96
+ interface HcScriptApi {
97
+ request: {
98
+ method: string;
99
+ url: string;
100
+ body: string;
101
+ headers: HcHeaderApi;
102
+ };
103
+ variables: HcVariablesApi;
104
+ collection: {
105
+ readonly id: number | null;
106
+ readonly name: string;
107
+ variables: HcVariablesApi;
108
+ headers: HcHeaderApi;
109
+ };
110
+ environment: {
111
+ readonly name: string;
112
+ variables: HcVariablesApi;
113
+ };
114
+ globals: HcVariablesApi;
115
+ test(name: string, fn: () => void): void;
116
+ expect(actual: unknown): HcExpectMatcher;
117
+ response: HcResponseApi;
118
+ }
119
+
120
+ /**
121
+ * HarborClient script sandbox API for pre/post request scripts and snippet files.
122
+ */
123
+ declare const hc: HcScriptApi;
124
+
125
+ /**
126
+ * Capturing console available inside request/post-request script sandboxes.
127
+ */
128
+ declare const console: {
129
+ log(...args: unknown[]): void;
130
+ error(...args: unknown[]): void;
131
+ };
package/package.json CHANGED
@@ -1,10 +1,12 @@
1
1
  {
2
2
  "name": "@harborclient/sdk",
3
- "version": "1.0.37",
3
+ "version": "1.0.39",
4
4
  "description": "TypeScript SDK for HarborClient development.",
5
5
  "keywords": [
6
6
  "harborclient",
7
- "plugin",
7
+ "plugins",
8
+ "themes",
9
+ "snippets",
8
10
  "typescript",
9
11
  "types"
10
12
  ],
@@ -66,6 +68,9 @@
66
68
  "./main": {
67
69
  "types": "./dist/main.d.ts"
68
70
  },
71
+ "./snippets": {
72
+ "types": "./dist/snippets.d.ts"
73
+ },
69
74
  "./http": {
70
75
  "types": "./dist/http/index.d.ts",
71
76
  "import": "./dist/http/index.js",
@@ -144,6 +149,13 @@
144
149
  "default": "./dist/styles.css"
145
150
  }
146
151
  },
152
+ "typesVersions": {
153
+ "*": {
154
+ "snippets": [
155
+ "./dist/snippets.d.ts"
156
+ ]
157
+ }
158
+ },
147
159
  "bin": {
148
160
  "hc-plugin-sign": "./dist/signing/cli-sign.js",
149
161
  "hc-plugin-verify": "./dist/signing/cli-verify.js"