@mochabug/adapt-sdk 0.1.22 → 0.1.25

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/README.md CHANGED
@@ -8,7 +8,6 @@ Welcome to the Mochabug's Adapt Plugins Toolkit, your treasure trove for plugin
8
8
  - [Features](#features)
9
9
  - [Simplified Runtime API Wrapping](#simplified-runtime-api-wrapping)
10
10
  - [Communication Types](#communication-types)
11
- - [Mime-Type Helper Functions](#mime-type-helper-functions)
12
11
  - [Router Classes with Automatic Endpoint Generation](#router-classes-with-automatic-endpoint-generation)
13
12
  - [Automated API Exposure with Routers](#automated-api-exposure-with-routers)
14
13
  - [Installation](#installation)
@@ -101,9 +100,6 @@ The division of the APIs into various parts facilitates the management of underl
101
100
  ### Communication Types
102
101
  The package includes types to facilitate communication with the runtime APIs, ensuring seamless integration and interaction.
103
102
 
104
- ### Mime-Type Helper Functions
105
- Ease your work with mime-types using the provided helper functions, which are tailored for efficient handling and manipulation.
106
-
107
103
  ### Router Classes with Automatic Endpoint Generation
108
104
  Router classes are provided to simplify the handling of incoming requests, whether for internal or external endpoints. With the help of the [Adaptkit package](https://www.npmjs.com/package/@mochabug/adaptkit), all the endpoints are generated automatically. By using the `adaptkit --init` or `--add` commands, the correct routing gets generated without the need for memorization.
109
105
 
@@ -261,44 +257,8 @@ import {
261
257
  ExternalConfiguratorRouter,
262
258
  joinPaths
263
259
  } from '@mochabug/adapt-plugin-toolkit/router';
264
- import { getMimeType } from '@mochabug/adapt-plugin-toolkit/mime';
265
260
  import { Component, Config } from './types';
266
261
 
267
- /**
268
- * Reads files to be served to the client.
269
- * This function retrieves MIME types and optionally encodes in gzip.
270
- *
271
- * @param api Configurator API
272
- * @param filepath Path to the file
273
- * @param encoding Encoding type
274
- * @returns {Response} The file content as a response
275
- */
276
- async function readFile(
277
- api: ConfiguratorApi,
278
- filepath: string,
279
- encoding: string | null,
280
- ): Promise<Response> {
281
- const path = joinPaths('/config-gui', filepath);
282
- const res = await api.readFile(path);
283
- if (!res.ok) {
284
- console.error(res);
285
- return new Response(res.errorMessage, { status: res.errorStatus });
286
- }
287
-
288
- const data = res.data!;
289
- const mime = getMimeType(path);
290
- const headers = new Headers();
291
- if (mime) {
292
- headers.set('Content-Type', mime.mime);
293
- if (encoding?.includes('gzip') && mime.gzip) {
294
- headers.set('Content-Encoding', 'gzip');
295
- }
296
- } else {
297
- headers.set('Content-Type', data.mime);
298
- }
299
- return new Response(data.content, { headers });
300
- }
301
-
302
262
  /**
303
263
  * Constructs an instance of ExternalConfiguratorRouter.
304
264
  *