Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

yaschema-api

Package Overview
Dependencies
Maintainers
1
Versions
43
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

yaschema-api - npm Package Compare versions

Comparing version 2.3.0 to 3.0.0

lib/cjs/types/HttpApiSchemas.js

8

lib/cjs/type-makers/make-http-api.js
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.makeHttpApi = void 0;
const makeHttpApi = (api) => (Object.assign(Object.assign({}, api), { isYaschemaApi: true, isYaschemaHttpApi: true }));
/**
* If name is omitted, it will be generated as:
* ```
* `HTTP ${api.routeType}:${api.method} ${api.url}`
* ```
*/
const makeHttpApi = (api) => { var _a; return (Object.assign(Object.assign({}, api), { name: (_a = api.name) !== null && _a !== void 0 ? _a : `HTTP ${api.routeType}:${api.method} ${api.url}`, isYaschemaApi: true, isYaschemaHttpApi: true })); };
exports.makeHttpApi = makeHttpApi;
//# sourceMappingURL=make-http-api.js.map

3

lib/cjs/types/exports.js

@@ -26,5 +26,3 @@ "use strict";

__exportStar(require("./ApiResponse"), exports);
__exportStar(require("./ApiSchemas"), exports);
__exportStar(require("./CachePolicy"), exports);
__exportStar(require("./GenericApi"), exports);
__exportStar(require("./GenericApiRequest"), exports);

@@ -35,2 +33,3 @@ __exportStar(require("./GenericApiResponse"), exports);

__exportStar(require("./HttpApiCredentialsSetting"), exports);
__exportStar(require("./HttpApiSchemas"), exports);
__exportStar(require("./HttpMethod"), exports);

@@ -37,0 +36,0 @@ __exportStar(require("./HttpRequestType"), exports);

@@ -1,2 +0,8 @@

export const makeHttpApi = (api) => (Object.assign(Object.assign({}, api), { isYaschemaApi: true, isYaschemaHttpApi: true }));
/**
* If name is omitted, it will be generated as:
* ```
* `HTTP ${api.routeType}:${api.method} ${api.url}`
* ```
*/
export const makeHttpApi = (api) => { var _a; return (Object.assign(Object.assign({}, api), { name: (_a = api.name) !== null && _a !== void 0 ? _a : `HTTP ${api.routeType}:${api.method} ${api.url}`, isYaschemaApi: true, isYaschemaHttpApi: true })); };
//# sourceMappingURL=make-http-api.js.map

@@ -10,5 +10,3 @@ export * from './AnyBody';

export * from './ApiResponse';
export * from './ApiSchemas';
export * from './CachePolicy';
export * from './GenericApi';
export * from './GenericApiRequest';

@@ -19,2 +17,3 @@ export * from './GenericApiResponse';

export * from './HttpApiCredentialsSetting';
export * from './HttpApiSchemas';
export * from './HttpMethod';

@@ -21,0 +20,0 @@ export * from './HttpRequestType';

import type { AnyHeaders } from '../types/AnyHeaders';
import type { AnyParams } from '../types/AnyParams';
import type { AnyQuery } from '../types/AnyQuery';
import type { ApiSchemas } from '../types/ApiSchemas';
export declare const makeApiSchemas: <ReqHeadersT extends AnyHeaders, ReqParamsT extends AnyParams, ReqQueryT extends AnyQuery, ReqBodyT extends unknown, ResStatusT extends number, ResHeadersT extends AnyHeaders, ResBodyT extends unknown, ErrResStatusT extends number, ErrResHeadersT extends AnyHeaders, ErrResBodyT extends unknown>(schemas: ApiSchemas<ReqHeadersT, ReqParamsT, ReqQueryT, ReqBodyT, ResStatusT, ResHeadersT, ResBodyT, ErrResStatusT, ErrResHeadersT, ErrResBodyT>) => ApiSchemas<ReqHeadersT, ReqParamsT, ReqQueryT, ReqBodyT, ResStatusT, ResHeadersT, ResBodyT, ErrResStatusT, ErrResHeadersT, ErrResBodyT>;
import type { HttpApiSchemas } from '../types/HttpApiSchemas';
export declare const makeApiSchemas: <ReqHeadersT extends AnyHeaders, ReqParamsT extends AnyParams, ReqQueryT extends AnyQuery, ReqBodyT extends unknown, ResStatusT extends number, ResHeadersT extends AnyHeaders, ResBodyT extends unknown, ErrResStatusT extends number, ErrResHeadersT extends AnyHeaders, ErrResBodyT extends unknown>(schemas: HttpApiSchemas<ReqHeadersT, ReqParamsT, ReqQueryT, ReqBodyT, ResStatusT, ResHeadersT, ResBodyT, ErrResStatusT, ErrResHeadersT, ErrResBodyT>) => HttpApiSchemas<ReqHeadersT, ReqParamsT, ReqQueryT, ReqBodyT, ResStatusT, ResHeadersT, ResBodyT, ErrResStatusT, ErrResHeadersT, ErrResBodyT>;
//# sourceMappingURL=make-api-schemas.d.ts.map

@@ -1,6 +0,3 @@

import type { AnyHeaders } from '../types/AnyHeaders';
import type { AnyParams } from '../types/AnyParams';
import type { AnyQuery } from '../types/AnyQuery';
import type { Api } from '../types/Api';
export declare const makeApi: <ReqHeadersT extends AnyHeaders, ReqParamsT extends AnyParams, ReqQueryT extends AnyQuery, ReqBodyT extends unknown, ResStatusT extends number, ResHeadersT extends AnyHeaders, ResBodyT extends unknown, ErrResStatusT extends number, ErrResHeadersT extends AnyHeaders, ErrResBodyT extends unknown>(api: Omit<Api<ReqHeadersT, ReqParamsT, ReqQueryT, ReqBodyT, ResStatusT, ResHeadersT, ResBodyT, ErrResStatusT, ErrResHeadersT, ErrResBodyT>, "isYaschemaApi">) => Api<ReqHeadersT, ReqParamsT, ReqQueryT, ReqBodyT, ResStatusT, ResHeadersT, ResBodyT, ErrResStatusT, ErrResHeadersT, ErrResBodyT>;
export declare const makeApi: (api: Omit<Api, 'isYaschemaApi'>) => Api;
//# sourceMappingURL=make-api.d.ts.map

@@ -5,3 +5,11 @@ import type { AnyHeaders } from '../types/AnyHeaders';

import type { HttpApi } from '../types/HttpApi';
export declare const makeHttpApi: <ReqHeadersT extends AnyHeaders = undefined, ReqParamsT extends AnyParams = undefined, ReqQueryT extends AnyQuery = undefined, ReqBodyT extends unknown = undefined, ResStatusT extends number = number, ResHeadersT extends AnyHeaders = undefined, ResBodyT extends unknown = undefined, ErrResStatusT extends number = number, ErrResHeadersT extends AnyHeaders = undefined, ErrResBodyT extends unknown = undefined>(api: Omit<HttpApi<ReqHeadersT, ReqParamsT, ReqQueryT, ReqBodyT, ResStatusT, ResHeadersT, ResBodyT, ErrResStatusT, ErrResHeadersT, ErrResBodyT>, "isYaschemaApi" | "isYaschemaHttpApi">) => HttpApi<ReqHeadersT, ReqParamsT, ReqQueryT, ReqBodyT, ResStatusT, ResHeadersT, ResBodyT, ErrResStatusT, ErrResHeadersT, ErrResBodyT>;
/**
* If name is omitted, it will be generated as:
* ```
* `HTTP ${api.routeType}:${api.method} ${api.url}`
* ```
*/
export declare const makeHttpApi: <ReqHeadersT extends AnyHeaders = undefined, ReqParamsT extends AnyParams = undefined, ReqQueryT extends AnyQuery = undefined, ReqBodyT extends unknown = undefined, ResStatusT extends number = number, ResHeadersT extends AnyHeaders = undefined, ResBodyT extends unknown = undefined, ErrResStatusT extends number = number, ErrResHeadersT extends AnyHeaders = undefined, ErrResBodyT extends unknown = undefined>(api: Omit<HttpApi<ReqHeadersT, ReqParamsT, ReqQueryT, ReqBodyT, ResStatusT, ResHeadersT, ResBodyT, ErrResStatusT, ErrResHeadersT, ErrResBodyT>, "name" | "isYaschemaApi" | "isYaschemaHttpApi"> & {
name?: string | undefined;
}) => HttpApi<ReqHeadersT, ReqParamsT, ReqQueryT, ReqBodyT, ResStatusT, ResHeadersT, ResBodyT, ErrResStatusT, ErrResHeadersT, ErrResBodyT>;
//# sourceMappingURL=make-http-api.d.ts.map

@@ -1,27 +0,9 @@

import type { AnyBody } from './AnyBody';
import type { AnyHeaders } from './AnyHeaders';
import type { AnyParams } from './AnyParams';
import type { AnyQuery } from './AnyQuery';
import type { AnyStatus } from './AnyStatus';
import type { ApiSchemas } from './ApiSchemas';
import type { CachePolicy } from './CachePolicy';
/** A generic API description. See `HttpApi` */
export interface Api<ReqHeadersT extends AnyHeaders, ReqParamsT extends AnyParams, ReqQueryT extends AnyQuery, ReqBodyT extends AnyBody, ResStatusT extends AnyStatus, ResHeadersT extends AnyHeaders, ResBodyT extends AnyBody, ErrResStatusT extends AnyStatus, ErrResHeadersT extends AnyHeaders, ErrResBodyT extends AnyBody> {
export interface Api {
isYaschemaApi: true;
schemas: ApiSchemas<ReqHeadersT, ReqParamsT, ReqQueryT, ReqBodyT, ResStatusT, ResHeadersT, ResBodyT, ErrResStatusT, ErrResHeadersT, ErrResBodyT>;
/** The type of route, which will be used to select a URL base and is configurable using `setUrlBaseForRouteType` */
routeType: string;
/**
* The statically known cache policy. Use `"dynamic"` if the policy is determine dynamically.
*
* @defaultValue `{ canCache: false }`
*/
cachePolicy?: CachePolicy | 'dynamic';
/**
* If `true`, it's safe to retry this API any time.
*
* @defaultValue `false`
*/
isSafeToRetry?: boolean;
/** A name that can be used to describe this API, when logging for example */
name: string;
}
//# sourceMappingURL=Api.d.ts.map

@@ -10,5 +10,3 @@ export * from './AnyBody';

export * from './ApiResponse';
export * from './ApiSchemas';
export * from './CachePolicy';
export * from './GenericApi';
export * from './GenericApiRequest';

@@ -19,2 +17,3 @@ export * from './GenericApiResponse';

export * from './HttpApiCredentialsSetting';
export * from './HttpApiSchemas';
export * from './HttpMethod';

@@ -21,0 +20,0 @@ export * from './HttpRequestType';

@@ -7,3 +7,5 @@ import type { AnyBody } from './AnyBody';

import type { Api } from './Api';
import type { CachePolicy } from './CachePolicy';
import type { HttpApiCredentialsSetting } from './HttpApiCredentialsSetting';
import type { HttpApiSchemas } from './HttpApiSchemas';
import type { HttpMethod } from './HttpMethod';

@@ -13,4 +15,5 @@ import type { HttpRequestType } from './HttpRequestType';

/** An HTTP API description */
export interface HttpApi<ReqHeadersT extends AnyHeaders, ReqParamsT extends AnyParams, ReqQueryT extends AnyQuery, ReqBodyT extends AnyBody, ResStatusT extends AnyStatus, ResHeadersT extends AnyHeaders, ResBodyT extends AnyBody, ErrResStatusT extends AnyStatus, ErrResHeadersT extends AnyHeaders, ErrResBodyT extends AnyBody> extends Api<ReqHeadersT, ReqParamsT, ReqQueryT, ReqBodyT, ResStatusT, ResHeadersT, ResBodyT, ErrResStatusT, ErrResHeadersT, ErrResBodyT> {
export interface HttpApi<ReqHeadersT extends AnyHeaders, ReqParamsT extends AnyParams, ReqQueryT extends AnyQuery, ReqBodyT extends AnyBody, ResStatusT extends AnyStatus, ResHeadersT extends AnyHeaders, ResBodyT extends AnyBody, ErrResStatusT extends AnyStatus, ErrResHeadersT extends AnyHeaders, ErrResBodyT extends AnyBody> extends Api {
isYaschemaHttpApi: true;
schemas: HttpApiSchemas<ReqHeadersT, ReqParamsT, ReqQueryT, ReqBodyT, ResStatusT, ResHeadersT, ResBodyT, ErrResStatusT, ErrResHeadersT, ErrResBodyT>;
method: HttpMethod;

@@ -48,3 +51,15 @@ /** The URL for accessing this API, which may be relative to a URL base configuring for the `routeType`. Use `{…}` syntax to mark

credentials?: HttpApiCredentialsSetting;
/**
* The statically known cache policy. Use `"dynamic"` if the policy is determine dynamically.
*
* @defaultValue `{ canCache: false }`
*/
cachePolicy?: CachePolicy | 'dynamic';
/**
* If `true`, it's safe to retry this API any time.
*
* @defaultValue `false`
*/
isSafeToRetry?: boolean;
}
//# sourceMappingURL=HttpApi.d.ts.map

@@ -1,3 +0,3 @@

import type { GenericApi } from '../types/GenericApi';
export declare const findAllApisInRoot: (root: any) => GenericApi[];
import type { Api } from '../types/Api';
export declare const findAllApisInRoot: (root: any) => Api[];
//# sourceMappingURL=find-all-apis-in-root.d.ts.map

@@ -1,3 +0,3 @@

import type { GenericApi } from '../types/GenericApi';
export declare const isApi: (value: any) => value is GenericApi;
import type { Api } from '../types/Api';
export declare const isApi: (value: any) => value is Api;
//# sourceMappingURL=is-api.d.ts.map
{
"name": "yaschema-api",
"version": "2.3.0",
"version": "3.0.0",
"description": "Yet another API",

@@ -5,0 +5,0 @@ "keywords": [

@@ -6,3 +6,3 @@ import type { AnyBody } from '../types/AnyBody';

import type { AnyStatus } from '../types/AnyStatus';
import type { ApiSchemas } from '../types/ApiSchemas';
import type { HttpApiSchemas } from '../types/HttpApiSchemas';

@@ -21,3 +21,3 @@ export const makeApiSchemas = <

>(
schemas: ApiSchemas<
schemas: HttpApiSchemas<
ReqHeadersT,

@@ -24,0 +24,0 @@ ReqParamsT,

@@ -1,27 +0,6 @@

import type { AnyBody } from '../types/AnyBody';
import type { AnyHeaders } from '../types/AnyHeaders';
import type { AnyParams } from '../types/AnyParams';
import type { AnyQuery } from '../types/AnyQuery';
import type { AnyStatus } from '../types/AnyStatus';
import type { Api } from '../types/Api';
export const makeApi = <
ReqHeadersT extends AnyHeaders,
ReqParamsT extends AnyParams,
ReqQueryT extends AnyQuery,
ReqBodyT extends AnyBody,
ResStatusT extends AnyStatus,
ResHeadersT extends AnyHeaders,
ResBodyT extends AnyBody,
ErrResStatusT extends AnyStatus,
ErrResHeadersT extends AnyHeaders,
ErrResBodyT extends AnyBody
>(
api: Omit<
Api<ReqHeadersT, ReqParamsT, ReqQueryT, ReqBodyT, ResStatusT, ResHeadersT, ResBodyT, ErrResStatusT, ErrResHeadersT, ErrResBodyT>,
'isYaschemaApi'
>
): Api<ReqHeadersT, ReqParamsT, ReqQueryT, ReqBodyT, ResStatusT, ResHeadersT, ResBodyT, ErrResStatusT, ErrResHeadersT, ErrResBodyT> => ({
export const makeApi = (api: Omit<Api, 'isYaschemaApi'>): Api => ({
...api,
isYaschemaApi: true
});

@@ -8,2 +8,8 @@ import type { AnyBody } from '../types/AnyBody';

/**
* If name is omitted, it will be generated as:
* ```
* `HTTP ${api.routeType}:${api.method} ${api.url}`
* ```
*/
export const makeHttpApi = <

@@ -23,4 +29,4 @@ ReqHeadersT extends AnyHeaders = undefined,

HttpApi<ReqHeadersT, ReqParamsT, ReqQueryT, ReqBodyT, ResStatusT, ResHeadersT, ResBodyT, ErrResStatusT, ErrResHeadersT, ErrResBodyT>,
'isYaschemaApi' | 'isYaschemaHttpApi'
>
'isYaschemaApi' | 'isYaschemaHttpApi' | 'name'
> & { name?: string }
): HttpApi<

@@ -37,2 +43,2 @@ ReqHeadersT,

ErrResBodyT
> => ({ ...api, isYaschemaApi: true, isYaschemaHttpApi: true });
> => ({ ...api, name: api.name ?? `HTTP ${api.routeType}:${api.method} ${api.url}`, isYaschemaApi: true, isYaschemaHttpApi: true });

@@ -1,52 +0,10 @@

import type { AnyBody } from './AnyBody';
import type { AnyHeaders } from './AnyHeaders';
import type { AnyParams } from './AnyParams';
import type { AnyQuery } from './AnyQuery';
import type { AnyStatus } from './AnyStatus';
import type { ApiSchemas } from './ApiSchemas';
import type { CachePolicy } from './CachePolicy';
/** A generic API description. See `HttpApi` */
export interface Api<
ReqHeadersT extends AnyHeaders,
ReqParamsT extends AnyParams,
ReqQueryT extends AnyQuery,
ReqBodyT extends AnyBody,
ResStatusT extends AnyStatus,
ResHeadersT extends AnyHeaders,
ResBodyT extends AnyBody,
ErrResStatusT extends AnyStatus,
ErrResHeadersT extends AnyHeaders,
ErrResBodyT extends AnyBody
> {
export interface Api {
isYaschemaApi: true;
schemas: ApiSchemas<
ReqHeadersT,
ReqParamsT,
ReqQueryT,
ReqBodyT,
ResStatusT,
ResHeadersT,
ResBodyT,
ErrResStatusT,
ErrResHeadersT,
ErrResBodyT
>;
/** The type of route, which will be used to select a URL base and is configurable using `setUrlBaseForRouteType` */
routeType: string;
/**
* The statically known cache policy. Use `"dynamic"` if the policy is determine dynamically.
*
* @defaultValue `{ canCache: false }`
*/
cachePolicy?: CachePolicy | 'dynamic';
/**
* If `true`, it's safe to retry this API any time.
*
* @defaultValue `false`
*/
isSafeToRetry?: boolean;
/** A name that can be used to describe this API, when logging for example */
name: string;
}

@@ -10,5 +10,3 @@ export * from './AnyBody';

export * from './ApiResponse';
export * from './ApiSchemas';
export * from './CachePolicy';
export * from './GenericApi';
export * from './GenericApiRequest';

@@ -19,2 +17,3 @@ export * from './GenericApiResponse';

export * from './HttpApiCredentialsSetting';
export * from './HttpApiSchemas';
export * from './HttpMethod';

@@ -21,0 +20,0 @@ export * from './HttpRequestType';

@@ -7,3 +7,5 @@ import type { AnyBody } from './AnyBody';

import type { Api } from './Api';
import type { CachePolicy } from './CachePolicy';
import type { HttpApiCredentialsSetting } from './HttpApiCredentialsSetting';
import type { HttpApiSchemas } from './HttpApiSchemas';
import type { HttpMethod } from './HttpMethod';

@@ -25,5 +27,18 @@ import type { HttpRequestType } from './HttpRequestType';

ErrResBodyT extends AnyBody
> extends Api<ReqHeadersT, ReqParamsT, ReqQueryT, ReqBodyT, ResStatusT, ResHeadersT, ResBodyT, ErrResStatusT, ErrResHeadersT, ErrResBodyT> {
> extends Api {
isYaschemaHttpApi: true;
schemas: HttpApiSchemas<
ReqHeadersT,
ReqParamsT,
ReqQueryT,
ReqBodyT,
ResStatusT,
ResHeadersT,
ResBodyT,
ErrResStatusT,
ErrResHeadersT,
ErrResBodyT
>;
method: HttpMethod;

@@ -62,2 +77,15 @@ /** The URL for accessing this API, which may be relative to a URL base configuring for the `routeType`. Use `{…}` syntax to mark

credentials?: HttpApiCredentialsSetting;
/**
* The statically known cache policy. Use `"dynamic"` if the policy is determine dynamically.
*
* @defaultValue `{ canCache: false }`
*/
cachePolicy?: CachePolicy | 'dynamic';
/**
* If `true`, it's safe to retry this API any time.
*
* @defaultValue `false`
*/
isSafeToRetry?: boolean;
}

@@ -1,5 +0,5 @@

import type { GenericApi } from '../types/GenericApi';
import type { Api } from '../types/Api';
import { isApi } from './is-api';
export const findAllApisInRoot = (root: any): GenericApi[] => internalFindAllApisInRoot(root, 0, []);
export const findAllApisInRoot = (root: any): Api[] => internalFindAllApisInRoot(root, 0, []);

@@ -10,3 +10,3 @@ // Helpers

const internalFindAllApisInRoot = (root: any, depth: number, output: GenericApi[]): GenericApi[] => {
const internalFindAllApisInRoot = (root: any, depth: number, output: Api[]): Api[] => {
if (depth >= MAX_DEPTH || root === null || root === undefined || Array.isArray(root) || typeof root !== 'object') {

@@ -13,0 +13,0 @@ return output;

@@ -1,4 +0,4 @@

import type { GenericApi } from '../types/GenericApi';
import type { Api } from '../types/Api';
export const isApi = (value: any): value is GenericApi =>
export const isApi = (value: any): value is Api =>
value !== undefined && typeof value === 'object' && 'isYaschemaApi' in value && (value as { isYaschemaApi: any }).isYaschemaApi === true;

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc