@scrypted/server 0.81.0 → 0.83.0

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,11 +1,22 @@
1
1
  import { ScryptedInterfaceProperty, ScryptedNativeId } from "@scrypted/types";
2
2
  import semver from 'semver';
3
3
  import { Plugin } from '../db-types';
4
- import { getNpmPackageInfo } from "../http-fetch-helpers";
5
4
  import { hasMixinCycle } from "../mixin/mixin-cycle";
6
5
  import { ScryptedRuntime } from "../runtime";
7
6
  import { sleep } from "../sleep";
8
7
  import { getState } from "../state";
8
+ import { httpFetch } from "../fetch/http-fetch";
9
+
10
+
11
+ export async function getNpmPackageInfo(pkg: string) {
12
+ const { body } = await httpFetch({
13
+ url: `https://registry.npmjs.org/${pkg}`,
14
+ // force ipv4 in case of busted ipv6.
15
+ family: 4,
16
+ responseType: 'json',
17
+ });
18
+ return body;
19
+ }
9
20
 
10
21
  export class PluginComponent {
11
22
  scrypted: ScryptedRuntime;
@@ -1,5 +1,5 @@
1
1
  import fs from 'fs';
2
- import { httpFetch } from "../http-fetch-helpers";
2
+ import { httpFetch } from "../fetch/http-fetch";
3
3
  import { ScryptedRuntime } from "../runtime";
4
4
 
5
5
  export class ServiceControl {
@@ -1,42 +0,0 @@
1
- /// <reference types="node" />
2
- /// <reference types="node" />
3
- /// <reference types="node" />
4
- import { IncomingMessage } from 'http';
5
- import type { Readable } from 'stream';
6
- export type HttpFetchResponseType = 'json' | 'text' | 'buffer' | 'readable';
7
- export interface HttpFetchOptions<T extends HttpFetchResponseType> {
8
- url: string | URL;
9
- family?: 4 | 6;
10
- method?: string;
11
- headers?: HeadersInit;
12
- timeout?: number;
13
- rejectUnauthorized?: boolean;
14
- ignoreStatusCode?: boolean;
15
- body?: Readable;
16
- responseType?: T;
17
- }
18
- export interface HttpFetchJsonOptions extends HttpFetchOptions<'json'> {
19
- }
20
- export interface HttpFetchBufferOptions extends HttpFetchOptions<'buffer'> {
21
- }
22
- export interface HttpFetchTextOptions extends HttpFetchOptions<'text'> {
23
- }
24
- export interface HttpFetchReadableOptions extends HttpFetchOptions<'readable'> {
25
- }
26
- export interface FetchParser<T> {
27
- accept: string;
28
- parse(message: IncomingMessage): Promise<T>;
29
- }
30
- export declare function getNpmPackageInfo(pkg: string): Promise<any>;
31
- export declare function getHttpFetchAccept(responseType: HttpFetchResponseType): string;
32
- export declare function setDefaultHttpFetchAccept(headers: Headers, responseType: HttpFetchResponseType): void;
33
- export declare function fetchStatusCodeOk(statusCode: number): boolean;
34
- export declare function checkStatus(statusCode: number): void;
35
- export interface HttpFetchResponse<T> {
36
- statusCode: number;
37
- headers: Headers;
38
- body: T;
39
- }
40
- export declare function getHttpFetchParser(responseType: HttpFetchResponseType): FetchParser<any>;
41
- export declare function parseResponseType(readable: IncomingMessage, responseType: HttpFetchResponseType): Promise<any>;
42
- export declare function httpFetch<T extends HttpFetchOptions<HttpFetchResponseType>>(options: T): Promise<HttpFetchResponse<T extends HttpFetchBufferOptions ? Buffer : T extends HttpFetchTextOptions ? string : T extends HttpFetchReadableOptions ? IncomingMessage : T extends HttpFetchJsonOptions ? any : Buffer>>;
@@ -1 +0,0 @@
1
- {"version":3,"file":"http-fetch-helpers.js","sourceRoot":"","sources":["../src/http-fetch-helpers.ts"],"names":[],"mappings":";;;AAAA,mCAA8B;AAC9B,uDAA+C;AA4B/C,KAAK,UAAU,iBAAiB,CAAC,QAAyB;IACtD,MAAM,OAAO,GAAa,EAAE,CAAC;IAC7B,QAAQ,CAAC,EAAE,CAAC,MAAM,EAAE,MAAM,CAAC,EAAE,CAAC,OAAO,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC;IACpD,MAAM,IAAA,aAAI,EAAC,QAAQ,EAAE,KAAK,CAAC,CAAC;IAC5B,OAAO,MAAM,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC;AAClC,CAAC;AAOD,MAAM,UAAU,GAAwB;IACpC,MAAM,EAAE,YAAY;IACpB,KAAK,CAA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