@yaakapp/api 0.2.19 → 0.2.21

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.
@@ -1,5 +1,14 @@
1
- import type { Environment, Folder, GrpcRequest, HttpRequest, HttpResponse, Workspace } from './models';
2
- import type { JsonValue } from './serde_json/JsonValue';
1
+ import type { Environment } from "./models";
2
+ import type { Folder } from "./models";
3
+ import type { GrpcRequest } from "./models";
4
+ import type { HttpRequest } from "./models";
5
+ import type { HttpResponse } from "./models";
6
+ import type { JsonValue } from "./serde_json/JsonValue";
7
+ import type { Workspace } from "./models";
8
+ export type AuthMiddleware = {
9
+ name: string;
10
+ args: Array<FormInput>;
11
+ };
3
12
  export type BootRequest = {
4
13
  dir: string;
5
14
  watch: boolean;
@@ -9,6 +18,18 @@ export type BootResponse = {
9
18
  version: string;
10
19
  capabilities: Array<string>;
11
20
  };
21
+ export type CallAuthMiddlewareRequest = {
22
+ config: {
23
+ [key in string]?: JsonValue;
24
+ };
25
+ method: string;
26
+ url: string;
27
+ headers: Array<HttpHeader>;
28
+ };
29
+ export type CallAuthMiddlewareResponse = {
30
+ url: string;
31
+ headers: Array<HttpHeader>;
32
+ };
12
33
  export type CallHttpRequestActionArgs = {
13
34
  httpRequest: HttpRequest;
14
35
  };
@@ -30,16 +51,24 @@ export type CallTemplateFunctionRequest = {
30
51
  export type CallTemplateFunctionResponse = {
31
52
  value: string | null;
32
53
  };
33
- export type Color = 'custom' | 'default' | 'primary' | 'secondary' | 'info' | 'success' | 'notice' | 'warning' | 'danger';
54
+ export type Color = "custom" | "default" | "primary" | "secondary" | "info" | "success" | "notice" | "warning" | "danger";
34
55
  export type CopyTextRequest = {
35
56
  text: string;
36
57
  };
58
+ export type EmptyPayload = {};
37
59
  export type ExportHttpRequestRequest = {
38
60
  httpRequest: HttpRequest;
39
61
  };
40
62
  export type ExportHttpRequestResponse = {
41
63
  content: string;
42
64
  };
65
+ export type FileFilter = {
66
+ name: string;
67
+ /**
68
+ * File extensions to require
69
+ */
70
+ extensions: Array<string>;
71
+ };
43
72
  export type FilterRequest = {
44
73
  content: string;
45
74
  filter: string;
@@ -54,190 +83,18 @@ export type FindHttpResponsesRequest = {
54
83
  export type FindHttpResponsesResponse = {
55
84
  httpResponses: Array<HttpResponse>;
56
85
  };
57
- export type GetHttpRequestActionsRequest = Record<string, never>;
58
- export type GetHttpRequestActionsResponse = {
59
- actions: Array<HttpRequestAction>;
60
- pluginRefId: string;
61
- };
62
- export type GetHttpRequestByIdRequest = {
63
- id: string;
64
- };
65
- export type GetHttpRequestByIdResponse = {
66
- httpRequest: HttpRequest | null;
67
- };
68
- export type GetTemplateFunctionsResponse = {
69
- functions: Array<TemplateFunction>;
70
- pluginRefId: string;
71
- };
72
- export type HttpRequestAction = {
73
- key: string;
74
- label: string;
75
- icon?: Icon;
76
- };
77
- export type Icon = 'copy' | 'info' | 'check_circle' | 'alert_triangle' | '_unknown';
78
- export type ImportRequest = {
79
- content: string;
80
- };
81
- export type ImportResources = {
82
- workspaces: Array<Workspace>;
83
- environments: Array<Environment>;
84
- folders: Array<Folder>;
85
- httpRequests: Array<HttpRequest>;
86
- grpcRequests: Array<GrpcRequest>;
87
- };
88
- export type ImportResponse = {
89
- resources: ImportResources;
90
- };
91
- export type InternalEvent = {
92
- id: string;
93
- pluginRefId: string;
94
- replyId: string | null;
95
- payload: InternalEventPayload;
96
- windowContext: WindowContext;
97
- };
98
- export type InternalEventPayload = ({
99
- type: 'boot_request';
100
- } & BootRequest) | ({
101
- type: 'boot_response';
102
- } & BootResponse) | {
103
- type: 'reload_request';
104
- } | {
105
- type: 'reload_response';
106
- } | {
107
- type: 'terminate_request';
108
- } | {
109
- type: 'terminate_response';
110
- } | ({
111
- type: 'import_request';
112
- } & ImportRequest) | ({
113
- type: 'import_response';
114
- } & ImportResponse) | ({
115
- type: 'filter_request';
116
- } & FilterRequest) | ({
117
- type: 'filter_response';
118
- } & FilterResponse) | ({
119
- type: 'export_http_request_request';
120
- } & ExportHttpRequestRequest) | ({
121
- type: 'export_http_request_response';
122
- } & ExportHttpRequestResponse) | ({
123
- type: 'send_http_request_request';
124
- } & SendHttpRequestRequest) | ({
125
- type: 'send_http_request_response';
126
- } & SendHttpRequestResponse) | ({
127
- type: 'get_http_request_actions_request';
128
- } & GetHttpRequestActionsRequest) | ({
129
- type: 'get_http_request_actions_response';
130
- } & GetHttpRequestActionsResponse) | ({
131
- type: 'call_http_request_action_request';
132
- } & CallHttpRequestActionRequest) | {
133
- type: 'get_template_functions_request';
134
- } | ({
135
- type: 'get_template_functions_response';
136
- } & GetTemplateFunctionsResponse) | ({
137
- type: 'call_template_function_request';
138
- } & CallTemplateFunctionRequest) | ({
139
- type: 'call_template_function_response';
140
- } & CallTemplateFunctionResponse) | ({
141
- type: 'copy_text_request';
142
- } & CopyTextRequest) | ({
143
- type: 'render_http_request_request';
144
- } & RenderHttpRequestRequest) | ({
145
- type: 'render_http_request_response';
146
- } & RenderHttpRequestResponse) | ({
147
- type: 'template_render_request';
148
- } & TemplateRenderRequest) | ({
149
- type: 'template_render_response';
150
- } & TemplateRenderResponse) | ({
151
- type: 'show_toast_request';
152
- } & ShowToastRequest) | ({
153
- type: 'prompt_text_request';
154
- } & PromptTextRequest) | ({
155
- type: 'prompt_text_response';
156
- } & PromptTextResponse) | ({
157
- type: 'get_http_request_by_id_request';
158
- } & GetHttpRequestByIdRequest) | ({
159
- type: 'get_http_request_by_id_response';
160
- } & GetHttpRequestByIdResponse) | ({
161
- type: 'find_http_responses_request';
162
- } & FindHttpResponsesRequest) | ({
163
- type: 'find_http_responses_response';
164
- } & FindHttpResponsesResponse) | {
165
- type: 'empty_response';
166
- };
167
- export type OpenFileFilter = {
168
- name: string;
169
- /**
170
- * File extensions to require
171
- */
172
- extensions: Array<string>;
173
- };
174
- export type PromptTextRequest = {
175
- id: string;
176
- title: string;
177
- label: string;
178
- description?: string;
179
- defaultValue?: string;
180
- placeholder?: string;
181
- /**
182
- * Text to add to the confirmation button
183
- */
184
- confirmText?: string;
185
- /**
186
- * Text to add to the cancel button
187
- */
188
- cancelText?: string;
189
- /**
190
- * Require the user to enter a non-empty value
191
- */
192
- require?: boolean;
193
- };
194
- export type PromptTextResponse = {
195
- value: string | null;
196
- };
197
- export type RenderHttpRequestRequest = {
198
- httpRequest: HttpRequest;
199
- purpose: RenderPurpose;
200
- };
201
- export type RenderHttpRequestResponse = {
202
- httpRequest: HttpRequest;
203
- };
204
- export type RenderPurpose = 'send' | 'preview';
205
- export type SendHttpRequestRequest = {
206
- httpRequest: HttpRequest;
207
- };
208
- export type SendHttpRequestResponse = {
209
- httpResponse: HttpResponse;
210
- };
211
- export type ShowToastRequest = {
212
- message: string;
213
- color?: Color;
214
- icon?: Icon;
215
- };
216
- export type TemplateFunction = {
217
- name: string;
218
- description?: string;
219
- /**
220
- * Also support alternative names. This is useful for not breaking existing
221
- * tags when changing the `name` property
222
- */
223
- aliases?: Array<string>;
224
- args: Array<TemplateFunctionArg>;
225
- };
226
- export type TemplateFunctionArg = ({
227
- type: 'text';
228
- } & TemplateFunctionTextArg) | ({
229
- type: 'select';
230
- } & TemplateFunctionSelectArg) | ({
231
- type: 'checkbox';
232
- } & TemplateFunctionCheckboxArg) | ({
233
- type: 'http_request';
234
- } & TemplateFunctionHttpRequestArg) | ({
235
- type: 'file';
236
- } & TemplateFunctionFileArg);
237
- export type TemplateFunctionBaseArg = {
238
- /**
239
- * The name of the argument. Should be `camelCase` format
240
- */
86
+ export type FormInput = {
87
+ "type": "text";
88
+ } & FormInputText | {
89
+ "type": "select";
90
+ } & FormInputSelect | {
91
+ "type": "checkbox";
92
+ } & FormInputCheckbox | {
93
+ "type": "file";
94
+ } & FormInputFile | {
95
+ "type": "http_request";
96
+ } & FormInputHttpRequest;
97
+ export type FormInputBase = {
241
98
  name: string;
242
99
  /**
243
100
  * Whether the user must fill in the argument
@@ -252,10 +109,7 @@ export type TemplateFunctionBaseArg = {
252
109
  */
253
110
  defaultValue?: string;
254
111
  };
255
- export type TemplateFunctionCheckboxArg = {
256
- /**
257
- * The name of the argument. Should be `camelCase` format
258
- */
112
+ export type FormInputCheckbox = {
259
113
  name: string;
260
114
  /**
261
115
  * Whether the user must fill in the argument
@@ -270,7 +124,7 @@ export type TemplateFunctionCheckboxArg = {
270
124
  */
271
125
  defaultValue?: string;
272
126
  };
273
- export type TemplateFunctionFileArg = {
127
+ export type FormInputFile = {
274
128
  /**
275
129
  * The title of the file selection window
276
130
  */
@@ -281,10 +135,7 @@ export type TemplateFunctionFileArg = {
281
135
  multiple?: boolean;
282
136
  directory?: boolean;
283
137
  defaultPath?: string;
284
- filters?: Array<OpenFileFilter>;
285
- /**
286
- * The name of the argument. Should be `camelCase` format
287
- */
138
+ filters?: Array<FileFilter>;
288
139
  name: string;
289
140
  /**
290
141
  * Whether the user must fill in the argument
@@ -299,10 +150,7 @@ export type TemplateFunctionFileArg = {
299
150
  */
300
151
  defaultValue?: string;
301
152
  };
302
- export type TemplateFunctionHttpRequestArg = {
303
- /**
304
- * The name of the argument. Should be `camelCase` format
305
- */
153
+ export type FormInputHttpRequest = {
306
154
  name: string;
307
155
  /**
308
156
  * Whether the user must fill in the argument
@@ -317,14 +165,11 @@ export type TemplateFunctionHttpRequestArg = {
317
165
  */
318
166
  defaultValue?: string;
319
167
  };
320
- export type TemplateFunctionSelectArg = {
168
+ export type FormInputSelect = {
321
169
  /**
322
170
  * The options that will be available in the select input
323
171
  */
324
- options: Array<TemplateFunctionSelectOption>;
325
- /**
326
- * The name of the argument. Should be `camelCase` format
327
- */
172
+ options: Array<FormInputSelectOption>;
328
173
  name: string;
329
174
  /**
330
175
  * Whether the user must fill in the argument
@@ -339,18 +184,15 @@ export type TemplateFunctionSelectArg = {
339
184
  */
340
185
  defaultValue?: string;
341
186
  };
342
- export type TemplateFunctionSelectOption = {
343
- label: string;
187
+ export type FormInputSelectOption = {
188
+ name: string;
344
189
  value: string;
345
190
  };
346
- export type TemplateFunctionTextArg = {
191
+ export type FormInputText = {
347
192
  /**
348
193
  * Placeholder for the text input
349
194
  */
350
- placeholder?: string;
351
- /**
352
- * The name of the argument. Should be `camelCase` format
353
- */
195
+ placeholder?: string | null;
354
196
  name: string;
355
197
  /**
356
198
  * Whether the user must fill in the argument
@@ -365,6 +207,183 @@ export type TemplateFunctionTextArg = {
365
207
  */
366
208
  defaultValue?: string;
367
209
  };
210
+ export type GetAuthMiddlewareResponse = {
211
+ authMiddleware: Array<AuthMiddleware>;
212
+ };
213
+ export type GetHttpRequestActionsRequest = Record<string, never>;
214
+ export type GetHttpRequestActionsResponse = {
215
+ actions: Array<HttpRequestAction>;
216
+ pluginRefId: string;
217
+ };
218
+ export type GetHttpRequestByIdRequest = {
219
+ id: string;
220
+ };
221
+ export type GetHttpRequestByIdResponse = {
222
+ httpRequest: HttpRequest | null;
223
+ };
224
+ export type GetTemplateFunctionsResponse = {
225
+ functions: Array<TemplateFunction>;
226
+ pluginRefId: string;
227
+ };
228
+ export type HttpHeader = {
229
+ name: string;
230
+ value: string;
231
+ };
232
+ export type HttpRequestAction = {
233
+ key: string;
234
+ label: string;
235
+ icon?: Icon;
236
+ };
237
+ export type Icon = "copy" | "info" | "check_circle" | "alert_triangle" | "_unknown";
238
+ export type ImportRequest = {
239
+ content: string;
240
+ };
241
+ export type ImportResources = {
242
+ workspaces: Array<Workspace>;
243
+ environments: Array<Environment>;
244
+ folders: Array<Folder>;
245
+ httpRequests: Array<HttpRequest>;
246
+ grpcRequests: Array<GrpcRequest>;
247
+ };
248
+ export type ImportResponse = {
249
+ resources: ImportResources;
250
+ };
251
+ export type InternalEvent = {
252
+ id: string;
253
+ pluginRefId: string;
254
+ replyId: string | null;
255
+ payload: InternalEventPayload;
256
+ windowContext: WindowContext;
257
+ };
258
+ export type InternalEventPayload = {
259
+ "type": "boot_request";
260
+ } & BootRequest | {
261
+ "type": "boot_response";
262
+ } & BootResponse | {
263
+ "type": "reload_request";
264
+ } & EmptyPayload | {
265
+ "type": "reload_response";
266
+ } & EmptyPayload | {
267
+ "type": "terminate_request";
268
+ } | {
269
+ "type": "terminate_response";
270
+ } | {
271
+ "type": "import_request";
272
+ } & ImportRequest | {
273
+ "type": "import_response";
274
+ } & ImportResponse | {
275
+ "type": "filter_request";
276
+ } & FilterRequest | {
277
+ "type": "filter_response";
278
+ } & FilterResponse | {
279
+ "type": "export_http_request_request";
280
+ } & ExportHttpRequestRequest | {
281
+ "type": "export_http_request_response";
282
+ } & ExportHttpRequestResponse | {
283
+ "type": "send_http_request_request";
284
+ } & SendHttpRequestRequest | {
285
+ "type": "send_http_request_response";
286
+ } & SendHttpRequestResponse | {
287
+ "type": "get_http_request_actions_request";
288
+ } & EmptyPayload | {
289
+ "type": "get_http_request_actions_response";
290
+ } & GetHttpRequestActionsResponse | {
291
+ "type": "call_http_request_action_request";
292
+ } & CallHttpRequestActionRequest | {
293
+ "type": "get_template_functions_request";
294
+ } | {
295
+ "type": "get_template_functions_response";
296
+ } & GetTemplateFunctionsResponse | {
297
+ "type": "call_template_function_request";
298
+ } & CallTemplateFunctionRequest | {
299
+ "type": "call_template_function_response";
300
+ } & CallTemplateFunctionResponse | {
301
+ "type": "get_auth_middleware_request";
302
+ } & EmptyPayload | {
303
+ "type": "get_auth_middleware_response";
304
+ } & GetAuthMiddlewareResponse | {
305
+ "type": "call_auth_middleware_request";
306
+ } & CallAuthMiddlewareRequest | {
307
+ "type": "call_auth_middleware_response";
308
+ } & CallAuthMiddlewareResponse | {
309
+ "type": "copy_text_request";
310
+ } & CopyTextRequest | {
311
+ "type": "render_http_request_request";
312
+ } & RenderHttpRequestRequest | {
313
+ "type": "render_http_request_response";
314
+ } & RenderHttpRequestResponse | {
315
+ "type": "template_render_request";
316
+ } & TemplateRenderRequest | {
317
+ "type": "template_render_response";
318
+ } & TemplateRenderResponse | {
319
+ "type": "show_toast_request";
320
+ } & ShowToastRequest | {
321
+ "type": "prompt_text_request";
322
+ } & PromptTextRequest | {
323
+ "type": "prompt_text_response";
324
+ } & PromptTextResponse | {
325
+ "type": "get_http_request_by_id_request";
326
+ } & GetHttpRequestByIdRequest | {
327
+ "type": "get_http_request_by_id_response";
328
+ } & GetHttpRequestByIdResponse | {
329
+ "type": "find_http_responses_request";
330
+ } & FindHttpResponsesRequest | {
331
+ "type": "find_http_responses_response";
332
+ } & FindHttpResponsesResponse | {
333
+ "type": "empty_response";
334
+ } & EmptyPayload;
335
+ export type PromptTextRequest = {
336
+ id: string;
337
+ title: string;
338
+ label: string;
339
+ description?: string;
340
+ defaultValue?: string;
341
+ placeholder?: string;
342
+ /**
343
+ * Text to add to the confirmation button
344
+ */
345
+ confirmText?: string;
346
+ /**
347
+ * Text to add to the cancel button
348
+ */
349
+ cancelText?: string;
350
+ /**
351
+ * Require the user to enter a non-empty value
352
+ */
353
+ require?: boolean;
354
+ };
355
+ export type PromptTextResponse = {
356
+ value: string | null;
357
+ };
358
+ export type RenderHttpRequestRequest = {
359
+ httpRequest: HttpRequest;
360
+ purpose: RenderPurpose;
361
+ };
362
+ export type RenderHttpRequestResponse = {
363
+ httpRequest: HttpRequest;
364
+ };
365
+ export type RenderPurpose = "send" | "preview";
366
+ export type SendHttpRequestRequest = {
367
+ httpRequest: HttpRequest;
368
+ };
369
+ export type SendHttpRequestResponse = {
370
+ httpResponse: HttpResponse;
371
+ };
372
+ export type ShowToastRequest = {
373
+ message: string;
374
+ color?: Color;
375
+ icon?: Icon;
376
+ };
377
+ export type TemplateFunction = {
378
+ name: string;
379
+ description?: string;
380
+ /**
381
+ * Also support alternative names. This is useful for not breaking existing
382
+ * tags when changing the `name` property
383
+ */
384
+ aliases?: Array<string>;
385
+ args: Array<FormInput>;
386
+ };
368
387
  export type TemplateRenderRequest = {
369
388
  data: JsonValue;
370
389
  purpose: RenderPurpose;
@@ -373,8 +392,8 @@ export type TemplateRenderResponse = {
373
392
  data: JsonValue;
374
393
  };
375
394
  export type WindowContext = {
376
- type: 'none';
395
+ "type": "none";
377
396
  } | {
378
- type: 'label';
397
+ "type": "label";
379
398
  label: string;
380
399
  };
@@ -12,6 +12,7 @@ export type EnvironmentVariable = {
12
12
  enabled?: boolean;
13
13
  name: string;
14
14
  value: string;
15
+ id: string;
15
16
  };
16
17
  export type Folder = {
17
18
  model: "folder";
@@ -28,6 +29,7 @@ export type GrpcMetadataEntry = {
28
29
  enabled?: boolean;
29
30
  name: string;
30
31
  value: string;
32
+ id: string;
31
33
  };
32
34
  export type GrpcRequest = {
33
35
  model: "grpc_request";
@@ -70,6 +72,7 @@ export type HttpRequestHeader = {
70
72
  enabled?: boolean;
71
73
  name: string;
72
74
  value: string;
75
+ id: string;
73
76
  };
74
77
  export type HttpResponse = {
75
78
  model: "http_response";
@@ -100,6 +103,7 @@ export type HttpUrlParameter = {
100
103
  enabled?: boolean;
101
104
  name: string;
102
105
  value: string;
106
+ id: string;
103
107
  };
104
108
  export type Workspace = {
105
109
  model: "workspace";
@@ -0,0 +1,5 @@
1
+ import { CallAuthMiddlewareRequest, CallAuthMiddlewareResponse, GetAuthMiddlewareResponse } from '..';
2
+ import type { Context } from './Context';
3
+ export type AuthenticationPlugin = GetAuthMiddlewareResponse & {
4
+ onApply(ctx: Context, args: CallAuthMiddlewareRequest): Promise<CallAuthMiddlewareResponse> | CallAuthMiddlewareResponse;
5
+ };
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -1,3 +1,4 @@
1
+ import { AuthenticationPlugin } from './AuthenticationPlugin';
1
2
  import type { FilterPlugin } from './FilterPlugin';
2
3
  import type { HttpRequestActionPlugin } from './HttpRequestActionPlugin';
3
4
  import type { ImporterPlugin } from './ImporterPlugin';
@@ -11,6 +12,7 @@ export type PluginDefinition = {
11
12
  importer?: ImporterPlugin;
12
13
  theme?: ThemePlugin;
13
14
  filter?: FilterPlugin;
15
+ authentication?: AuthenticationPlugin;
14
16
  httpRequestActions?: HttpRequestActionPlugin[];
15
17
  templateFunctions?: TemplateFunctionPlugin[];
16
18
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@yaakapp/api",
3
- "version": "0.2.19",
3
+ "version": "0.2.21",
4
4
  "main": "lib/index.js",
5
5
  "typings": "./lib/index.d.ts",
6
6
  "files": [
@@ -11,8 +11,8 @@
11
11
  "build": "run-s build:copy-types build:tsc",
12
12
  "build:tsc": "tsc",
13
13
  "build:copy-types": "run-p build:copy-types:*",
14
- "build:copy-types:root": "cpy --flat ../../src-tauri/yaak-plugin-runtime/bindings/*.ts ./src/bindings",
15
- "build:copy-types:next": "cpy --flat ../../src-tauri/yaak-plugin-runtime/bindings/serde_json/*.ts ./src/bindings/serde_json",
14
+ "build:copy-types:root": "cpy --flat ../../src-tauri/yaak-plugins/bindings/*.ts ./src/bindings",
15
+ "build:copy-types:next": "cpy --flat ../../src-tauri/yaak-plugins/bindings/serde_json/*.ts ./src/bindings/serde_json",
16
16
  "prepublishOnly": "npm run build"
17
17
  },
18
18
  "dependencies": {