@sitecore-cloudsdk/utils
Advanced tools
Comparing version 0.1.1 to 0.1.2
import { createCookieString } from './lib/cookies/create-cookie-string'; | ||
import { ICookieProperties } from './lib/cookies/interfaces'; | ||
import { CookieProperties } from './lib/cookies/interfaces'; | ||
import { fetchWithTimeout } from './lib/fetch-with-timeout'; | ||
@@ -12,9 +12,9 @@ import { getCookieValueClientSide } from './lib/cookies/get-cookie-value-client-side'; | ||
import { cookieExists } from './lib/cookies/cookie-exists'; | ||
import { flattenObject, INestedObject, IFlattenedObject } from './lib/converters/flatten-object'; | ||
import { flattenObject, NestedObject, FlattenedObject } from './lib/converters/flatten-object'; | ||
import { isShortISODateString } from './lib/validators/is-short-iso-date-string'; | ||
import { isValidEmail } from './lib/validators/is-valid-email'; | ||
import type { TRequest, IMiddlewareNextResponse, IHttpResponse, IMiddlewareRequest, IHttpRequest, BasicTypes } from './lib/interfaces'; | ||
import type { ICookie } from './lib/cookies/interfaces'; | ||
import type { Request, MiddlewareNextResponse, HttpResponse, MiddlewareRequest, HttpRequest, BasicTypes } from './lib/interfaces'; | ||
import type { Cookie } from './lib/cookies/interfaces'; | ||
export { createCookieString, fetchWithTimeout, getCookieValueClientSide, isNextJsMiddlewareRequest, isNextJsMiddlewareResponse, isHttpRequest, isHttpResponse, getCookie, getCookieServerSide, cookieExists, flattenObject, isShortISODateString, isValidEmail, }; | ||
export type { INestedObject, TRequest, IMiddlewareNextResponse, BasicTypes, IHttpResponse, IHttpRequest, IMiddlewareRequest, IFlattenedObject, }; | ||
export type { ICookie, ICookieProperties }; | ||
export type { NestedObject, Request, MiddlewareNextResponse, BasicTypes, HttpResponse, HttpRequest, MiddlewareRequest, FlattenedObject, }; | ||
export type { Cookie, CookieProperties }; |
@@ -14,10 +14,10 @@ import { BasicTypes } from '../interfaces'; | ||
*/ | ||
export declare function flattenObject(data: IFlattenObjectDataParameters): IFlattenedObject; | ||
export declare function flattenObject(data: FlattenObjectDataParameters): FlattenedObject; | ||
/** | ||
* Interface for the data object parameter of the flattenObject function | ||
*/ | ||
interface IFlattenObjectDataParameters { | ||
object: INestedObject; | ||
interface FlattenObjectDataParameters { | ||
object: NestedObject; | ||
currentKey?: string; | ||
newObject?: IFlattenedObject; | ||
newObject?: FlattenedObject; | ||
} | ||
@@ -27,3 +27,3 @@ /** | ||
*/ | ||
export interface IFlattenedObject { | ||
export interface FlattenedObject { | ||
[key: string]: BasicTypes; | ||
@@ -34,5 +34,5 @@ } | ||
*/ | ||
export interface INestedObject { | ||
[key: string]: BasicTypes | INestedObject; | ||
export interface NestedObject { | ||
[key: string]: BasicTypes | NestedObject; | ||
} | ||
export {}; |
@@ -1,2 +0,2 @@ | ||
import { ICookieProperties } from './interfaces'; | ||
import { CookieProperties } from './interfaces'; | ||
/** | ||
@@ -9,2 +9,2 @@ * Creates the cookie string with the respectively cookie attributes | ||
*/ | ||
export declare function createCookieString(name: string, value: string, attributes: ICookieProperties): string; | ||
export declare function createCookieString(name: string, value: string, attributes: CookieProperties): string; |
/** | ||
* Cookie properties | ||
*/ | ||
export interface ICookieProperties { | ||
export interface CookieProperties { | ||
maxAge: number; | ||
@@ -16,5 +16,5 @@ sameSite: string; | ||
*/ | ||
export interface ICookie { | ||
export interface Cookie { | ||
name: string; | ||
value: string; | ||
} |
@@ -1,2 +0,2 @@ | ||
import { ICookie } from './cookies/interfaces'; | ||
import { Cookie } from './cookies/interfaces'; | ||
/** | ||
@@ -11,3 +11,3 @@ * A reusable type that accepts only basic types and arrays of those | ||
*/ | ||
export interface IHttpRequest { | ||
export interface HttpRequest { | ||
headers: { | ||
@@ -23,6 +23,6 @@ 'cookie'?: string; | ||
*/ | ||
export interface IHttpResponse { | ||
export interface HttpResponse { | ||
setHeader(name: string, value: number | string | ReadonlyArray<string>): void; | ||
} | ||
export type TRequest = IHttpRequest | IMiddlewareRequest; | ||
export type Request = HttpRequest | MiddlewareRequest; | ||
/** | ||
@@ -32,6 +32,6 @@ * Interface for supporting request from Edge Next.js | ||
*/ | ||
export interface IMiddlewareRequest { | ||
export interface MiddlewareRequest { | ||
cookies: { | ||
set: ((key: string, value: string, options: any) => any) | ((...args: [key: string, value: string] | [options: ICookie]) => any); | ||
get: (key: string) => ICookie | string | undefined; | ||
set: ((key: string, value: string, options: any) => any) | ((...args: [key: string, value: string] | [options: Cookie]) => any); | ||
get: (key: string) => Cookie | string | undefined; | ||
}; | ||
@@ -47,6 +47,6 @@ headers: { | ||
*/ | ||
export interface IMiddlewareNextResponse { | ||
export interface MiddlewareNextResponse { | ||
cookies: { | ||
set: ((key: string, value: unknown, options?: any) => any) | ((...args: [key: string, value: string] | [options: ICookie]) => any); | ||
set: ((key: string, value: unknown, options?: any) => any) | ((...args: [key: string, value: string] | [options: Cookie]) => any); | ||
}; | ||
} |
@@ -1,2 +0,2 @@ | ||
import { IHttpRequest, TRequest } from '../interfaces'; | ||
import { HttpRequest, Request } from '../interfaces'; | ||
/** | ||
@@ -9,2 +9,2 @@ * Checks if the given 'request' object is a valid HTTP Request | ||
*/ | ||
export declare function isHttpRequest(request: TRequest): request is IHttpRequest; | ||
export declare function isHttpRequest(request: Request): request is HttpRequest; |
@@ -1,2 +0,2 @@ | ||
import { IHttpResponse, IMiddlewareNextResponse } from '../interfaces'; | ||
import { HttpResponse, MiddlewareNextResponse } from '../interfaces'; | ||
/** | ||
@@ -6,5 +6,5 @@ * Checks if the given 'response' object is a valid HTTP Response | ||
* | ||
* @param response - IMiddlewareNextResponse | IHttpResponse - The response object to be validated. | ||
* @param response - MiddlewareNextResponse | HttpResponse - The response object to be validated. | ||
* @returns Returns true if 'response' is a valid HTTP Response, otherwise false. | ||
*/ | ||
export declare function isHttpResponse(response: IMiddlewareNextResponse | IHttpResponse): response is IHttpResponse; | ||
export declare function isHttpResponse(response: MiddlewareNextResponse | HttpResponse): response is HttpResponse; |
@@ -9,3 +9,3 @@ "use strict"; | ||
* | ||
* @param response - IMiddlewareNextResponse | IHttpResponse - The response object to be validated. | ||
* @param response - MiddlewareNextResponse | HttpResponse - The response object to be validated. | ||
* @returns Returns true if 'response' is a valid HTTP Response, otherwise false. | ||
@@ -12,0 +12,0 @@ */ |
@@ -1,2 +0,2 @@ | ||
import { IMiddlewareRequest, TRequest } from '../interfaces'; | ||
import { MiddlewareRequest, Request } from '../interfaces'; | ||
/** | ||
@@ -9,2 +9,2 @@ * Checks if the given 'request' object is a valid Middleware Request | ||
*/ | ||
export declare function isNextJsMiddlewareRequest(request: TRequest): request is IMiddlewareRequest; | ||
export declare function isNextJsMiddlewareRequest(request: Request): request is MiddlewareRequest; |
@@ -1,9 +0,9 @@ | ||
import { IHttpResponse, IMiddlewareNextResponse } from '../interfaces'; | ||
import { HttpResponse, MiddlewareNextResponse } from '../interfaces'; | ||
/** | ||
* Checks if the given 'response' object is a valid IMiddlewareNextResponse Response | ||
* Checks if the given 'response' object is a valid MiddlewareNextResponse Response | ||
* by verifying the presence of necessary properties. | ||
* | ||
* @param response - IMiddlewareNextResponse | IHttpResponse - The response object to be validated. | ||
* @returns Returns true if 'response' is a valid IMiddlewareNextResponse Response, otherwise false. | ||
* @param response - MiddlewareNextResponse | HttpResponse - The response object to be validated. | ||
* @returns Returns true if 'response' is a valid MiddlewareNextResponse Response, otherwise false. | ||
*/ | ||
export declare function isNextJsMiddlewareResponse(response: IMiddlewareNextResponse | IHttpResponse): response is IMiddlewareNextResponse; | ||
export declare function isNextJsMiddlewareResponse(response: MiddlewareNextResponse | HttpResponse): response is MiddlewareNextResponse; |
@@ -6,7 +6,7 @@ "use strict"; | ||
/** | ||
* Checks if the given 'response' object is a valid IMiddlewareNextResponse Response | ||
* Checks if the given 'response' object is a valid MiddlewareNextResponse Response | ||
* by verifying the presence of necessary properties. | ||
* | ||
* @param response - IMiddlewareNextResponse | IHttpResponse - The response object to be validated. | ||
* @returns Returns true if 'response' is a valid IMiddlewareNextResponse Response, otherwise false. | ||
* @param response - MiddlewareNextResponse | HttpResponse - The response object to be validated. | ||
* @returns Returns true if 'response' is a valid MiddlewareNextResponse Response, otherwise false. | ||
*/ | ||
@@ -13,0 +13,0 @@ function isNextJsMiddlewareResponse(response) { |
import { createCookieString } from './lib/cookies/create-cookie-string'; | ||
import { ICookieProperties } from './lib/cookies/interfaces'; | ||
import { CookieProperties } from './lib/cookies/interfaces'; | ||
import { fetchWithTimeout } from './lib/fetch-with-timeout'; | ||
@@ -12,9 +12,9 @@ import { getCookieValueClientSide } from './lib/cookies/get-cookie-value-client-side'; | ||
import { cookieExists } from './lib/cookies/cookie-exists'; | ||
import { flattenObject, INestedObject, IFlattenedObject } from './lib/converters/flatten-object'; | ||
import { flattenObject, NestedObject, FlattenedObject } from './lib/converters/flatten-object'; | ||
import { isShortISODateString } from './lib/validators/is-short-iso-date-string'; | ||
import { isValidEmail } from './lib/validators/is-valid-email'; | ||
import type { TRequest, IMiddlewareNextResponse, IHttpResponse, IMiddlewareRequest, IHttpRequest, BasicTypes } from './lib/interfaces'; | ||
import type { ICookie } from './lib/cookies/interfaces'; | ||
import type { Request, MiddlewareNextResponse, HttpResponse, MiddlewareRequest, HttpRequest, BasicTypes } from './lib/interfaces'; | ||
import type { Cookie } from './lib/cookies/interfaces'; | ||
export { createCookieString, fetchWithTimeout, getCookieValueClientSide, isNextJsMiddlewareRequest, isNextJsMiddlewareResponse, isHttpRequest, isHttpResponse, getCookie, getCookieServerSide, cookieExists, flattenObject, isShortISODateString, isValidEmail, }; | ||
export type { INestedObject, TRequest, IMiddlewareNextResponse, BasicTypes, IHttpResponse, IHttpRequest, IMiddlewareRequest, IFlattenedObject, }; | ||
export type { ICookie, ICookieProperties }; | ||
export type { NestedObject, Request, MiddlewareNextResponse, BasicTypes, HttpResponse, HttpRequest, MiddlewareRequest, FlattenedObject, }; | ||
export type { Cookie, CookieProperties }; |
@@ -14,10 +14,10 @@ import { BasicTypes } from '../interfaces'; | ||
*/ | ||
export declare function flattenObject(data: IFlattenObjectDataParameters): IFlattenedObject; | ||
export declare function flattenObject(data: FlattenObjectDataParameters): FlattenedObject; | ||
/** | ||
* Interface for the data object parameter of the flattenObject function | ||
*/ | ||
interface IFlattenObjectDataParameters { | ||
object: INestedObject; | ||
interface FlattenObjectDataParameters { | ||
object: NestedObject; | ||
currentKey?: string; | ||
newObject?: IFlattenedObject; | ||
newObject?: FlattenedObject; | ||
} | ||
@@ -27,3 +27,3 @@ /** | ||
*/ | ||
export interface IFlattenedObject { | ||
export interface FlattenedObject { | ||
[key: string]: BasicTypes; | ||
@@ -34,5 +34,5 @@ } | ||
*/ | ||
export interface INestedObject { | ||
[key: string]: BasicTypes | INestedObject; | ||
export interface NestedObject { | ||
[key: string]: BasicTypes | NestedObject; | ||
} | ||
export {}; |
@@ -1,2 +0,2 @@ | ||
import { ICookieProperties } from './interfaces'; | ||
import { CookieProperties } from './interfaces'; | ||
/** | ||
@@ -9,2 +9,2 @@ * Creates the cookie string with the respectively cookie attributes | ||
*/ | ||
export declare function createCookieString(name: string, value: string, attributes: ICookieProperties): string; | ||
export declare function createCookieString(name: string, value: string, attributes: CookieProperties): string; |
/** | ||
* Cookie properties | ||
*/ | ||
export interface ICookieProperties { | ||
export interface CookieProperties { | ||
maxAge: number; | ||
@@ -16,5 +16,5 @@ sameSite: string; | ||
*/ | ||
export interface ICookie { | ||
export interface Cookie { | ||
name: string; | ||
value: string; | ||
} |
@@ -1,2 +0,2 @@ | ||
import { ICookie } from './cookies/interfaces'; | ||
import { Cookie } from './cookies/interfaces'; | ||
/** | ||
@@ -11,3 +11,3 @@ * A reusable type that accepts only basic types and arrays of those | ||
*/ | ||
export interface IHttpRequest { | ||
export interface HttpRequest { | ||
headers: { | ||
@@ -23,6 +23,6 @@ 'cookie'?: string; | ||
*/ | ||
export interface IHttpResponse { | ||
export interface HttpResponse { | ||
setHeader(name: string, value: number | string | ReadonlyArray<string>): void; | ||
} | ||
export type TRequest = IHttpRequest | IMiddlewareRequest; | ||
export type Request = HttpRequest | MiddlewareRequest; | ||
/** | ||
@@ -32,6 +32,6 @@ * Interface for supporting request from Edge Next.js | ||
*/ | ||
export interface IMiddlewareRequest { | ||
export interface MiddlewareRequest { | ||
cookies: { | ||
set: ((key: string, value: string, options: any) => any) | ((...args: [key: string, value: string] | [options: ICookie]) => any); | ||
get: (key: string) => ICookie | string | undefined; | ||
set: ((key: string, value: string, options: any) => any) | ((...args: [key: string, value: string] | [options: Cookie]) => any); | ||
get: (key: string) => Cookie | string | undefined; | ||
}; | ||
@@ -47,6 +47,6 @@ headers: { | ||
*/ | ||
export interface IMiddlewareNextResponse { | ||
export interface MiddlewareNextResponse { | ||
cookies: { | ||
set: ((key: string, value: unknown, options?: any) => any) | ((...args: [key: string, value: string] | [options: ICookie]) => any); | ||
set: ((key: string, value: unknown, options?: any) => any) | ((...args: [key: string, value: string] | [options: Cookie]) => any); | ||
}; | ||
} |
@@ -1,2 +0,2 @@ | ||
import { IHttpRequest, TRequest } from '../interfaces'; | ||
import { HttpRequest, Request } from '../interfaces'; | ||
/** | ||
@@ -9,2 +9,2 @@ * Checks if the given 'request' object is a valid HTTP Request | ||
*/ | ||
export declare function isHttpRequest(request: TRequest): request is IHttpRequest; | ||
export declare function isHttpRequest(request: Request): request is HttpRequest; |
@@ -1,2 +0,2 @@ | ||
import { IHttpResponse, IMiddlewareNextResponse } from '../interfaces'; | ||
import { HttpResponse, MiddlewareNextResponse } from '../interfaces'; | ||
/** | ||
@@ -6,5 +6,5 @@ * Checks if the given 'response' object is a valid HTTP Response | ||
* | ||
* @param response - IMiddlewareNextResponse | IHttpResponse - The response object to be validated. | ||
* @param response - MiddlewareNextResponse | HttpResponse - The response object to be validated. | ||
* @returns Returns true if 'response' is a valid HTTP Response, otherwise false. | ||
*/ | ||
export declare function isHttpResponse(response: IMiddlewareNextResponse | IHttpResponse): response is IHttpResponse; | ||
export declare function isHttpResponse(response: MiddlewareNextResponse | HttpResponse): response is HttpResponse; |
@@ -6,3 +6,3 @@ // © Sitecore Corporation A/S. All rights reserved. Sitecore® is a registered trademark of Sitecore Corporation A/S. | ||
* | ||
* @param response - IMiddlewareNextResponse | IHttpResponse - The response object to be validated. | ||
* @param response - MiddlewareNextResponse | HttpResponse - The response object to be validated. | ||
* @returns Returns true if 'response' is a valid HTTP Response, otherwise false. | ||
@@ -9,0 +9,0 @@ */ |
@@ -1,2 +0,2 @@ | ||
import { IMiddlewareRequest, TRequest } from '../interfaces'; | ||
import { MiddlewareRequest, Request } from '../interfaces'; | ||
/** | ||
@@ -9,2 +9,2 @@ * Checks if the given 'request' object is a valid Middleware Request | ||
*/ | ||
export declare function isNextJsMiddlewareRequest(request: TRequest): request is IMiddlewareRequest; | ||
export declare function isNextJsMiddlewareRequest(request: Request): request is MiddlewareRequest; |
@@ -1,9 +0,9 @@ | ||
import { IHttpResponse, IMiddlewareNextResponse } from '../interfaces'; | ||
import { HttpResponse, MiddlewareNextResponse } from '../interfaces'; | ||
/** | ||
* Checks if the given 'response' object is a valid IMiddlewareNextResponse Response | ||
* Checks if the given 'response' object is a valid MiddlewareNextResponse Response | ||
* by verifying the presence of necessary properties. | ||
* | ||
* @param response - IMiddlewareNextResponse | IHttpResponse - The response object to be validated. | ||
* @returns Returns true if 'response' is a valid IMiddlewareNextResponse Response, otherwise false. | ||
* @param response - MiddlewareNextResponse | HttpResponse - The response object to be validated. | ||
* @returns Returns true if 'response' is a valid MiddlewareNextResponse Response, otherwise false. | ||
*/ | ||
export declare function isNextJsMiddlewareResponse(response: IMiddlewareNextResponse | IHttpResponse): response is IMiddlewareNextResponse; | ||
export declare function isNextJsMiddlewareResponse(response: MiddlewareNextResponse | HttpResponse): response is MiddlewareNextResponse; |
// © Sitecore Corporation A/S. All rights reserved. Sitecore® is a registered trademark of Sitecore Corporation A/S. | ||
/** | ||
* Checks if the given 'response' object is a valid IMiddlewareNextResponse Response | ||
* Checks if the given 'response' object is a valid MiddlewareNextResponse Response | ||
* by verifying the presence of necessary properties. | ||
* | ||
* @param response - IMiddlewareNextResponse | IHttpResponse - The response object to be validated. | ||
* @returns Returns true if 'response' is a valid IMiddlewareNextResponse Response, otherwise false. | ||
* @param response - MiddlewareNextResponse | HttpResponse - The response object to be validated. | ||
* @returns Returns true if 'response' is a valid MiddlewareNextResponse Response, otherwise false. | ||
*/ | ||
@@ -9,0 +9,0 @@ export function isNextJsMiddlewareResponse(response) { |
{ | ||
"name": "@sitecore-cloudsdk/utils", | ||
"version": "0.1.1", | ||
"version": "0.1.2", | ||
"license": "Apache-2.0", | ||
@@ -5,0 +5,0 @@ "main": "dist/cjs/src/index.js", |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
99909