@newsteam/cosmos
Advanced tools
Comparing version
@@ -15,3 +15,3 @@ import type { Request, RequestOptions, Response } from "../request"; | ||
constructor(request: Request, options: ArticlesModuleOptions); | ||
get(args?: { | ||
get<Keys extends string[] | undefined = undefined, Key extends number | undefined = undefined>(args?: { | ||
/** | ||
@@ -29,6 +29,6 @@ * Compute all articles in articles embeddedArticlesList | ||
excludeFields?: string[]; | ||
key?: number; | ||
keys?: string[]; | ||
key?: Key; | ||
keys?: Keys; | ||
slug?: string; | ||
}, options?: RequestOptions): Promise<Response<Article>>; | ||
}, options?: RequestOptions): Promise<Response<Key extends undefined ? Keys extends undefined ? Article : Article[] : Article>>; | ||
getByUuid(args?: { | ||
@@ -35,0 +35,0 @@ /** |
@@ -13,5 +13,7 @@ "use strict"; | ||
const defaults = { | ||
next: this.options.next.revalidate.issueAccessToken === undefined ? undefined : { | ||
revalidate: this.options.next.revalidate.issueAccessToken, | ||
}, | ||
next: this.options.next.revalidate.issueAccessToken === undefined | ||
? undefined | ||
: { | ||
revalidate: this.options.next.revalidate.issueAccessToken, | ||
}, | ||
}; | ||
@@ -29,5 +31,7 @@ return this.request.fetch({ | ||
const defaults = { | ||
next: this.options.next.revalidate.issueRequestToken === undefined ? undefined : { | ||
revalidate: this.options.next.revalidate.issueRequestToken, | ||
}, | ||
next: this.options.next.revalidate.issueRequestToken === undefined | ||
? undefined | ||
: { | ||
revalidate: this.options.next.revalidate.issueRequestToken, | ||
}, | ||
}; | ||
@@ -45,5 +49,7 @@ return this.request.fetch({ | ||
const defaults = { | ||
next: this.options.next.revalidate.revokeAccessToken === undefined ? undefined : { | ||
revalidate: this.options.next.revalidate.revokeAccessToken, | ||
}, | ||
next: this.options.next.revalidate.revokeAccessToken === undefined | ||
? undefined | ||
: { | ||
revalidate: this.options.next.revalidate.revokeAccessToken, | ||
}, | ||
}; | ||
@@ -50,0 +56,0 @@ return this.request.fetch({ |
@@ -13,5 +13,7 @@ "use strict"; | ||
const defaults = { | ||
next: this.options.next.revalidate.get === undefined ? undefined : { | ||
revalidate: this.options.next.revalidate.get, | ||
}, | ||
next: this.options.next.revalidate.get === undefined | ||
? undefined | ||
: { | ||
revalidate: this.options.next.revalidate.get, | ||
}, | ||
}; | ||
@@ -29,5 +31,7 @@ return this.request.fetch({ | ||
const defaults = { | ||
next: this.options.next.revalidate.getAll === undefined ? undefined : { | ||
revalidate: this.options.next.revalidate.getAll, | ||
}, | ||
next: this.options.next.revalidate.getAll === undefined | ||
? undefined | ||
: { | ||
revalidate: this.options.next.revalidate.getAll, | ||
}, | ||
}; | ||
@@ -34,0 +38,0 @@ return this.request.fetch({ |
@@ -13,5 +13,7 @@ "use strict"; | ||
const defaults = { | ||
next: this.options.next.revalidate.get === undefined ? undefined : { | ||
revalidate: this.options.next.revalidate.get, | ||
}, | ||
next: this.options.next.revalidate.get === undefined | ||
? undefined | ||
: { | ||
revalidate: this.options.next.revalidate.get, | ||
}, | ||
}; | ||
@@ -29,5 +31,7 @@ return this.request.fetch({ | ||
const defaults = { | ||
next: this.options.next.revalidate.getAll === undefined ? undefined : { | ||
revalidate: this.options.next.revalidate.getAll, | ||
}, | ||
next: this.options.next.revalidate.getAll === undefined | ||
? undefined | ||
: { | ||
revalidate: this.options.next.revalidate.getAll, | ||
}, | ||
}; | ||
@@ -34,0 +38,0 @@ return this.request.fetch({ |
@@ -13,5 +13,7 @@ "use strict"; | ||
const defaults = { | ||
next: this.options.next.revalidate.getAll === undefined ? undefined : { | ||
revalidate: this.options.next.revalidate.getAll, | ||
}, | ||
next: this.options.next.revalidate.getAll === undefined | ||
? undefined | ||
: { | ||
revalidate: this.options.next.revalidate.getAll, | ||
}, | ||
}; | ||
@@ -18,0 +20,0 @@ return this.request.fetch({ |
@@ -13,5 +13,7 @@ "use strict"; | ||
const defaults = { | ||
next: this.options.next.revalidate.addCard === undefined ? undefined : { | ||
revalidate: this.options.next.revalidate.addCard, | ||
}, | ||
next: this.options.next.revalidate.addCard === undefined | ||
? undefined | ||
: { | ||
revalidate: this.options.next.revalidate.addCard, | ||
}, | ||
}; | ||
@@ -29,5 +31,7 @@ return this.request.fetch({ | ||
const defaults = { | ||
next: this.options.next.revalidate.create === undefined ? undefined : { | ||
revalidate: this.options.next.revalidate.create, | ||
}, | ||
next: this.options.next.revalidate.create === undefined | ||
? undefined | ||
: { | ||
revalidate: this.options.next.revalidate.create, | ||
}, | ||
}; | ||
@@ -45,5 +49,7 @@ return this.request.fetch({ | ||
const defaults = { | ||
next: this.options.next.revalidate.get === undefined ? undefined : { | ||
revalidate: this.options.next.revalidate.get, | ||
}, | ||
next: this.options.next.revalidate.get === undefined | ||
? undefined | ||
: { | ||
revalidate: this.options.next.revalidate.get, | ||
}, | ||
}; | ||
@@ -61,5 +67,7 @@ return this.request.fetch({ | ||
const defaults = { | ||
next: this.options.next.revalidate.getPaymentMethods === undefined ? undefined : { | ||
revalidate: this.options.next.revalidate.getPaymentMethods, | ||
}, | ||
next: this.options.next.revalidate.getPaymentMethods === undefined | ||
? undefined | ||
: { | ||
revalidate: this.options.next.revalidate.getPaymentMethods, | ||
}, | ||
}; | ||
@@ -66,0 +74,0 @@ return this.request.fetch({ |
@@ -13,5 +13,7 @@ "use strict"; | ||
const defaults = { | ||
next: this.options.next.revalidate.get === undefined ? undefined : { | ||
revalidate: this.options.next.revalidate.get, | ||
}, | ||
next: this.options.next.revalidate.get === undefined | ||
? undefined | ||
: { | ||
revalidate: this.options.next.revalidate.get, | ||
}, | ||
}; | ||
@@ -18,0 +20,0 @@ return this.request.fetch({ |
@@ -13,5 +13,7 @@ "use strict"; | ||
const defaults = { | ||
next: this.options.next.revalidate.getAll === undefined ? undefined : { | ||
revalidate: this.options.next.revalidate.getAll, | ||
}, | ||
next: this.options.next.revalidate.getAll === undefined | ||
? undefined | ||
: { | ||
revalidate: this.options.next.revalidate.getAll, | ||
}, | ||
}; | ||
@@ -18,0 +20,0 @@ return this.request.fetch({ |
@@ -13,5 +13,7 @@ "use strict"; | ||
const defaults = { | ||
next: this.options.next.revalidate.get === undefined ? undefined : { | ||
revalidate: this.options.next.revalidate.get, | ||
}, | ||
next: this.options.next.revalidate.get === undefined | ||
? undefined | ||
: { | ||
revalidate: this.options.next.revalidate.get, | ||
}, | ||
}; | ||
@@ -29,5 +31,7 @@ return this.request.fetch({ | ||
const defaults = { | ||
next: this.options.next.revalidate.getAll === undefined ? undefined : { | ||
revalidate: this.options.next.revalidate.getAll, | ||
}, | ||
next: this.options.next.revalidate.getAll === undefined | ||
? undefined | ||
: { | ||
revalidate: this.options.next.revalidate.getAll, | ||
}, | ||
}; | ||
@@ -34,0 +38,0 @@ return this.request.fetch({ |
@@ -13,5 +13,7 @@ "use strict"; | ||
const defaults = { | ||
next: this.options.next.revalidate.getAll === undefined ? undefined : { | ||
revalidate: this.options.next.revalidate.getAll, | ||
}, | ||
next: this.options.next.revalidate.getAll === undefined | ||
? undefined | ||
: { | ||
revalidate: this.options.next.revalidate.getAll, | ||
}, | ||
}; | ||
@@ -18,0 +20,0 @@ return this.request.fetch({ |
@@ -13,5 +13,7 @@ "use strict"; | ||
const defaults = { | ||
next: this.options.next.revalidate.create === undefined ? undefined : { | ||
revalidate: this.options.next.revalidate.create, | ||
}, | ||
next: this.options.next.revalidate.create === undefined | ||
? undefined | ||
: { | ||
revalidate: this.options.next.revalidate.create, | ||
}, | ||
}; | ||
@@ -29,5 +31,7 @@ return this.request.fetch({ | ||
const defaults = { | ||
next: this.options.next.revalidate.me === undefined ? undefined : { | ||
revalidate: this.options.next.revalidate.me, | ||
}, | ||
next: this.options.next.revalidate.me === undefined | ||
? undefined | ||
: { | ||
revalidate: this.options.next.revalidate.me, | ||
}, | ||
}; | ||
@@ -44,5 +48,7 @@ return this.request.fetch({ | ||
const defaults = { | ||
next: this.options.next.revalidate.resetPassword === undefined ? undefined : { | ||
revalidate: this.options.next.revalidate.resetPassword, | ||
}, | ||
next: this.options.next.revalidate.resetPassword === undefined | ||
? undefined | ||
: { | ||
revalidate: this.options.next.revalidate.resetPassword, | ||
}, | ||
}; | ||
@@ -60,6 +66,8 @@ return this.request.fetch({ | ||
const defaults = { | ||
next: this.options.next.revalidate.sendResetPasswordMail === undefined ? undefined : { | ||
revalidate: this.options.next.revalidate | ||
.sendResetPasswordMail, | ||
}, | ||
next: this.options.next.revalidate.sendResetPasswordMail === undefined | ||
? undefined | ||
: { | ||
revalidate: this.options.next.revalidate | ||
.sendResetPasswordMail, | ||
}, | ||
}; | ||
@@ -77,5 +85,7 @@ return this.request.fetch({ | ||
const defaults = { | ||
next: this.options.next.revalidate.updateAddress === undefined ? undefined : { | ||
revalidate: this.options.next.revalidate.updateAddress, | ||
}, | ||
next: this.options.next.revalidate.updateAddress === undefined | ||
? undefined | ||
: { | ||
revalidate: this.options.next.revalidate.updateAddress, | ||
}, | ||
}; | ||
@@ -93,5 +103,7 @@ return this.request.fetch({ | ||
const defaults = { | ||
next: this.options.next.revalidate.updateProfile === undefined ? undefined : { | ||
revalidate: this.options.next.revalidate.updateProfile, | ||
}, | ||
next: this.options.next.revalidate.updateProfile === undefined | ||
? undefined | ||
: { | ||
revalidate: this.options.next.revalidate.updateProfile, | ||
}, | ||
}; | ||
@@ -98,0 +110,0 @@ return this.request.fetch({ |
@@ -13,5 +13,7 @@ "use strict"; | ||
const defaults = { | ||
next: this.options.next.revalidate.redeem === undefined ? undefined : { | ||
revalidate: this.options.next.revalidate.redeem, | ||
}, | ||
next: this.options.next.revalidate.redeem === undefined | ||
? undefined | ||
: { | ||
revalidate: this.options.next.revalidate.redeem, | ||
}, | ||
}; | ||
@@ -18,0 +20,0 @@ return this.request.fetch({ |
@@ -13,5 +13,7 @@ "use strict"; | ||
const defaults = { | ||
next: this.options.next.revalidate.getAll === undefined ? undefined : { | ||
revalidate: this.options.next.revalidate.getAll, | ||
}, | ||
next: this.options.next.revalidate.getAll === undefined | ||
? undefined | ||
: { | ||
revalidate: this.options.next.revalidate.getAll, | ||
}, | ||
}; | ||
@@ -18,0 +20,0 @@ return this.request.fetch({ |
@@ -41,20 +41,30 @@ "use strict"; | ||
if (typeof input === "object" && !Array.isArray(input)) { | ||
// eslint-disable-next-line @typescript-eslint/no-unsafe-type-assertion -- acceptable | ||
const object = input; | ||
// eslint-disable-next-line unicorn/no-array-reduce -- acceptable in this context | ||
return Object.keys(object).reduce((previous, key) => object[key] === undefined ? previous : { | ||
...previous, | ||
[key]: stripUndefinedProperties(object[key]), | ||
}, {}); | ||
// eslint-disable-next-line unicorn/no-array-reduce, @typescript-eslint/no-unsafe-type-assertion -- acceptable in this context | ||
return Object.keys(object).reduce((previous, key) => object[key] === undefined | ||
? previous | ||
: { | ||
...previous, | ||
[key]: stripUndefinedProperties(object[key]), | ||
}, {}); | ||
} | ||
return input; | ||
}; | ||
// eslint-disable-next-line @typescript-eslint/no-unsafe-type-assertion -- acceptable | ||
const normalizeArgs = (data) => (0, snakecase_keys_1.default)(data, { deep: true }); | ||
const normailzeResponse = (data) => stripUndefinedProperties(nullToUndefined((0, camelcase_keys_1.default)(data, { | ||
const normailzeResponse = (data) => stripUndefinedProperties(nullToUndefined( | ||
// eslint-disable-next-line @typescript-eslint/no-unsafe-type-assertion -- acceptable | ||
(0, camelcase_keys_1.default)( | ||
// eslint-disable-next-line @typescript-eslint/no-unsafe-type-assertion -- acceptable | ||
data, { | ||
deep: true, | ||
}))); | ||
const logSection = (label, value) => ` ${label}\n\n ${typeof value === "string" ? value : String(JSON.stringify(value, undefined, 2)).split("\n") | ||
.map((ln) => ` ${ln}`) | ||
.slice(0, MAX_LOG_LENGTH) | ||
.join("\n") | ||
.trim()}`; | ||
const logSection = (label, value) => ` ${label}\n\n ${typeof value === "string" | ||
? value | ||
: String(JSON.stringify(value, undefined, 2)).split("\n") | ||
.map((ln) => ` ${ln}`) | ||
.slice(0, MAX_LOG_LENGTH) | ||
.join("\n") | ||
.trim()}`; | ||
const formatLog = (args) => { | ||
@@ -65,2 +75,3 @@ const { logData } = args; | ||
...rawRequest, | ||
// eslint-disable-next-line @typescript-eslint/no-unsafe-type-assertion -- acceptable | ||
body: rawRequest.body ? JSON.parse(rawRequest.body) : undefined, | ||
@@ -90,3 +101,3 @@ }; | ||
const columns = globalThis.process.stdout.columns ?? Number.POSITIVE_INFINITY; | ||
size = size < columns ? size : columns; | ||
size = Math.min(size, columns); | ||
} | ||
@@ -229,2 +240,3 @@ const breaker = `${Array.from({ length: size + 1 }).join("-")}-\n`; | ||
try { | ||
// eslint-disable-next-line @typescript-eslint/no-unsafe-type-assertion -- acceptable | ||
json = await response.json(); | ||
@@ -252,2 +264,3 @@ } | ||
if (ok) { | ||
// eslint-disable-next-line @typescript-eslint/no-unsafe-type-assertion -- acceptable | ||
const data = normailzeResponse(json); | ||
@@ -265,2 +278,3 @@ /** | ||
} | ||
// eslint-disable-next-line @typescript-eslint/no-unsafe-type-assertion -- acceptable | ||
const error = json; | ||
@@ -319,2 +333,3 @@ /** | ||
} | ||
// eslint-disable-next-line @typescript-eslint/no-unsafe-type-assertion -- acceptable | ||
return { | ||
@@ -321,0 +336,0 @@ data: undefined, |
@@ -15,3 +15,3 @@ import type { Request, RequestOptions, Response } from "../request"; | ||
constructor(request: Request, options: ArticlesModuleOptions); | ||
get(args?: { | ||
get<Keys extends string[] | undefined = undefined, Key extends number | undefined = undefined>(args?: { | ||
/** | ||
@@ -29,6 +29,6 @@ * Compute all articles in articles embeddedArticlesList | ||
excludeFields?: string[]; | ||
key?: number; | ||
keys?: string[]; | ||
key?: Key; | ||
keys?: Keys; | ||
slug?: string; | ||
}, options?: RequestOptions): Promise<Response<Article>>; | ||
}, options?: RequestOptions): Promise<Response<Key extends undefined ? Keys extends undefined ? Article : Article[] : Article>>; | ||
getByUuid(args?: { | ||
@@ -35,0 +35,0 @@ /** |
@@ -10,5 +10,7 @@ export class AuthModule { | ||
const defaults = { | ||
next: this.options.next.revalidate.issueAccessToken === undefined ? undefined : { | ||
revalidate: this.options.next.revalidate.issueAccessToken, | ||
}, | ||
next: this.options.next.revalidate.issueAccessToken === undefined | ||
? undefined | ||
: { | ||
revalidate: this.options.next.revalidate.issueAccessToken, | ||
}, | ||
}; | ||
@@ -26,5 +28,7 @@ return this.request.fetch({ | ||
const defaults = { | ||
next: this.options.next.revalidate.issueRequestToken === undefined ? undefined : { | ||
revalidate: this.options.next.revalidate.issueRequestToken, | ||
}, | ||
next: this.options.next.revalidate.issueRequestToken === undefined | ||
? undefined | ||
: { | ||
revalidate: this.options.next.revalidate.issueRequestToken, | ||
}, | ||
}; | ||
@@ -42,5 +46,7 @@ return this.request.fetch({ | ||
const defaults = { | ||
next: this.options.next.revalidate.revokeAccessToken === undefined ? undefined : { | ||
revalidate: this.options.next.revalidate.revokeAccessToken, | ||
}, | ||
next: this.options.next.revalidate.revokeAccessToken === undefined | ||
? undefined | ||
: { | ||
revalidate: this.options.next.revalidate.revokeAccessToken, | ||
}, | ||
}; | ||
@@ -47,0 +53,0 @@ return this.request.fetch({ |
@@ -10,5 +10,7 @@ export class AuthorsModule { | ||
const defaults = { | ||
next: this.options.next.revalidate.get === undefined ? undefined : { | ||
revalidate: this.options.next.revalidate.get, | ||
}, | ||
next: this.options.next.revalidate.get === undefined | ||
? undefined | ||
: { | ||
revalidate: this.options.next.revalidate.get, | ||
}, | ||
}; | ||
@@ -26,5 +28,7 @@ return this.request.fetch({ | ||
const defaults = { | ||
next: this.options.next.revalidate.getAll === undefined ? undefined : { | ||
revalidate: this.options.next.revalidate.getAll, | ||
}, | ||
next: this.options.next.revalidate.getAll === undefined | ||
? undefined | ||
: { | ||
revalidate: this.options.next.revalidate.getAll, | ||
}, | ||
}; | ||
@@ -31,0 +35,0 @@ return this.request.fetch({ |
@@ -10,5 +10,7 @@ export class CatalogModule { | ||
const defaults = { | ||
next: this.options.next.revalidate.get === undefined ? undefined : { | ||
revalidate: this.options.next.revalidate.get, | ||
}, | ||
next: this.options.next.revalidate.get === undefined | ||
? undefined | ||
: { | ||
revalidate: this.options.next.revalidate.get, | ||
}, | ||
}; | ||
@@ -26,5 +28,7 @@ return this.request.fetch({ | ||
const defaults = { | ||
next: this.options.next.revalidate.getAll === undefined ? undefined : { | ||
revalidate: this.options.next.revalidate.getAll, | ||
}, | ||
next: this.options.next.revalidate.getAll === undefined | ||
? undefined | ||
: { | ||
revalidate: this.options.next.revalidate.getAll, | ||
}, | ||
}; | ||
@@ -31,0 +35,0 @@ return this.request.fetch({ |
@@ -10,5 +10,7 @@ export class NotificationsModule { | ||
const defaults = { | ||
next: this.options.next.revalidate.getAll === undefined ? undefined : { | ||
revalidate: this.options.next.revalidate.getAll, | ||
}, | ||
next: this.options.next.revalidate.getAll === undefined | ||
? undefined | ||
: { | ||
revalidate: this.options.next.revalidate.getAll, | ||
}, | ||
}; | ||
@@ -15,0 +17,0 @@ return this.request.fetch({ |
@@ -10,5 +10,7 @@ export class PaymentsModule { | ||
const defaults = { | ||
next: this.options.next.revalidate.addCard === undefined ? undefined : { | ||
revalidate: this.options.next.revalidate.addCard, | ||
}, | ||
next: this.options.next.revalidate.addCard === undefined | ||
? undefined | ||
: { | ||
revalidate: this.options.next.revalidate.addCard, | ||
}, | ||
}; | ||
@@ -26,5 +28,7 @@ return this.request.fetch({ | ||
const defaults = { | ||
next: this.options.next.revalidate.create === undefined ? undefined : { | ||
revalidate: this.options.next.revalidate.create, | ||
}, | ||
next: this.options.next.revalidate.create === undefined | ||
? undefined | ||
: { | ||
revalidate: this.options.next.revalidate.create, | ||
}, | ||
}; | ||
@@ -42,5 +46,7 @@ return this.request.fetch({ | ||
const defaults = { | ||
next: this.options.next.revalidate.get === undefined ? undefined : { | ||
revalidate: this.options.next.revalidate.get, | ||
}, | ||
next: this.options.next.revalidate.get === undefined | ||
? undefined | ||
: { | ||
revalidate: this.options.next.revalidate.get, | ||
}, | ||
}; | ||
@@ -58,5 +64,7 @@ return this.request.fetch({ | ||
const defaults = { | ||
next: this.options.next.revalidate.getPaymentMethods === undefined ? undefined : { | ||
revalidate: this.options.next.revalidate.getPaymentMethods, | ||
}, | ||
next: this.options.next.revalidate.getPaymentMethods === undefined | ||
? undefined | ||
: { | ||
revalidate: this.options.next.revalidate.getPaymentMethods, | ||
}, | ||
}; | ||
@@ -63,0 +71,0 @@ return this.request.fetch({ |
@@ -10,5 +10,7 @@ export class ProductModule { | ||
const defaults = { | ||
next: this.options.next.revalidate.get === undefined ? undefined : { | ||
revalidate: this.options.next.revalidate.get, | ||
}, | ||
next: this.options.next.revalidate.get === undefined | ||
? undefined | ||
: { | ||
revalidate: this.options.next.revalidate.get, | ||
}, | ||
}; | ||
@@ -15,0 +17,0 @@ return this.request.fetch({ |
@@ -10,5 +10,7 @@ export class SectionsModule { | ||
const defaults = { | ||
next: this.options.next.revalidate.getAll === undefined ? undefined : { | ||
revalidate: this.options.next.revalidate.getAll, | ||
}, | ||
next: this.options.next.revalidate.getAll === undefined | ||
? undefined | ||
: { | ||
revalidate: this.options.next.revalidate.getAll, | ||
}, | ||
}; | ||
@@ -15,0 +17,0 @@ return this.request.fetch({ |
@@ -10,5 +10,7 @@ export class SubscriptionsModule { | ||
const defaults = { | ||
next: this.options.next.revalidate.get === undefined ? undefined : { | ||
revalidate: this.options.next.revalidate.get, | ||
}, | ||
next: this.options.next.revalidate.get === undefined | ||
? undefined | ||
: { | ||
revalidate: this.options.next.revalidate.get, | ||
}, | ||
}; | ||
@@ -26,5 +28,7 @@ return this.request.fetch({ | ||
const defaults = { | ||
next: this.options.next.revalidate.getAll === undefined ? undefined : { | ||
revalidate: this.options.next.revalidate.getAll, | ||
}, | ||
next: this.options.next.revalidate.getAll === undefined | ||
? undefined | ||
: { | ||
revalidate: this.options.next.revalidate.getAll, | ||
}, | ||
}; | ||
@@ -31,0 +35,0 @@ return this.request.fetch({ |
@@ -10,5 +10,7 @@ export class TeasersModule { | ||
const defaults = { | ||
next: this.options.next.revalidate.getAll === undefined ? undefined : { | ||
revalidate: this.options.next.revalidate.getAll, | ||
}, | ||
next: this.options.next.revalidate.getAll === undefined | ||
? undefined | ||
: { | ||
revalidate: this.options.next.revalidate.getAll, | ||
}, | ||
}; | ||
@@ -15,0 +17,0 @@ return this.request.fetch({ |
@@ -10,5 +10,7 @@ export class UserModule { | ||
const defaults = { | ||
next: this.options.next.revalidate.create === undefined ? undefined : { | ||
revalidate: this.options.next.revalidate.create, | ||
}, | ||
next: this.options.next.revalidate.create === undefined | ||
? undefined | ||
: { | ||
revalidate: this.options.next.revalidate.create, | ||
}, | ||
}; | ||
@@ -26,5 +28,7 @@ return this.request.fetch({ | ||
const defaults = { | ||
next: this.options.next.revalidate.me === undefined ? undefined : { | ||
revalidate: this.options.next.revalidate.me, | ||
}, | ||
next: this.options.next.revalidate.me === undefined | ||
? undefined | ||
: { | ||
revalidate: this.options.next.revalidate.me, | ||
}, | ||
}; | ||
@@ -41,5 +45,7 @@ return this.request.fetch({ | ||
const defaults = { | ||
next: this.options.next.revalidate.resetPassword === undefined ? undefined : { | ||
revalidate: this.options.next.revalidate.resetPassword, | ||
}, | ||
next: this.options.next.revalidate.resetPassword === undefined | ||
? undefined | ||
: { | ||
revalidate: this.options.next.revalidate.resetPassword, | ||
}, | ||
}; | ||
@@ -57,6 +63,8 @@ return this.request.fetch({ | ||
const defaults = { | ||
next: this.options.next.revalidate.sendResetPasswordMail === undefined ? undefined : { | ||
revalidate: this.options.next.revalidate | ||
.sendResetPasswordMail, | ||
}, | ||
next: this.options.next.revalidate.sendResetPasswordMail === undefined | ||
? undefined | ||
: { | ||
revalidate: this.options.next.revalidate | ||
.sendResetPasswordMail, | ||
}, | ||
}; | ||
@@ -74,5 +82,7 @@ return this.request.fetch({ | ||
const defaults = { | ||
next: this.options.next.revalidate.updateAddress === undefined ? undefined : { | ||
revalidate: this.options.next.revalidate.updateAddress, | ||
}, | ||
next: this.options.next.revalidate.updateAddress === undefined | ||
? undefined | ||
: { | ||
revalidate: this.options.next.revalidate.updateAddress, | ||
}, | ||
}; | ||
@@ -90,5 +100,7 @@ return this.request.fetch({ | ||
const defaults = { | ||
next: this.options.next.revalidate.updateProfile === undefined ? undefined : { | ||
revalidate: this.options.next.revalidate.updateProfile, | ||
}, | ||
next: this.options.next.revalidate.updateProfile === undefined | ||
? undefined | ||
: { | ||
revalidate: this.options.next.revalidate.updateProfile, | ||
}, | ||
}; | ||
@@ -95,0 +107,0 @@ return this.request.fetch({ |
@@ -10,5 +10,7 @@ export class VoucherModule { | ||
const defaults = { | ||
next: this.options.next.revalidate.redeem === undefined ? undefined : { | ||
revalidate: this.options.next.revalidate.redeem, | ||
}, | ||
next: this.options.next.revalidate.redeem === undefined | ||
? undefined | ||
: { | ||
revalidate: this.options.next.revalidate.redeem, | ||
}, | ||
}; | ||
@@ -15,0 +17,0 @@ return this.request.fetch({ |
@@ -10,5 +10,7 @@ export class WidgetsModule { | ||
const defaults = { | ||
next: this.options.next.revalidate.getAll === undefined ? undefined : { | ||
revalidate: this.options.next.revalidate.getAll, | ||
}, | ||
next: this.options.next.revalidate.getAll === undefined | ||
? undefined | ||
: { | ||
revalidate: this.options.next.revalidate.getAll, | ||
}, | ||
}; | ||
@@ -15,0 +17,0 @@ return this.request.fetch({ |
@@ -35,20 +35,30 @@ import camelcaseKeys from "camelcase-keys"; | ||
if (typeof input === "object" && !Array.isArray(input)) { | ||
// eslint-disable-next-line @typescript-eslint/no-unsafe-type-assertion -- acceptable | ||
const object = input; | ||
// eslint-disable-next-line unicorn/no-array-reduce -- acceptable in this context | ||
return Object.keys(object).reduce((previous, key) => object[key] === undefined ? previous : { | ||
...previous, | ||
[key]: stripUndefinedProperties(object[key]), | ||
}, {}); | ||
// eslint-disable-next-line unicorn/no-array-reduce, @typescript-eslint/no-unsafe-type-assertion -- acceptable in this context | ||
return Object.keys(object).reduce((previous, key) => object[key] === undefined | ||
? previous | ||
: { | ||
...previous, | ||
[key]: stripUndefinedProperties(object[key]), | ||
}, {}); | ||
} | ||
return input; | ||
}; | ||
// eslint-disable-next-line @typescript-eslint/no-unsafe-type-assertion -- acceptable | ||
const normalizeArgs = (data) => snakeCaseKeys(data, { deep: true }); | ||
const normailzeResponse = (data) => stripUndefinedProperties(nullToUndefined(camelcaseKeys(data, { | ||
const normailzeResponse = (data) => stripUndefinedProperties(nullToUndefined( | ||
// eslint-disable-next-line @typescript-eslint/no-unsafe-type-assertion -- acceptable | ||
camelcaseKeys( | ||
// eslint-disable-next-line @typescript-eslint/no-unsafe-type-assertion -- acceptable | ||
data, { | ||
deep: true, | ||
}))); | ||
const logSection = (label, value) => ` ${label}\n\n ${typeof value === "string" ? value : String(JSON.stringify(value, undefined, 2)).split("\n") | ||
.map((ln) => ` ${ln}`) | ||
.slice(0, MAX_LOG_LENGTH) | ||
.join("\n") | ||
.trim()}`; | ||
const logSection = (label, value) => ` ${label}\n\n ${typeof value === "string" | ||
? value | ||
: String(JSON.stringify(value, undefined, 2)).split("\n") | ||
.map((ln) => ` ${ln}`) | ||
.slice(0, MAX_LOG_LENGTH) | ||
.join("\n") | ||
.trim()}`; | ||
const formatLog = (args) => { | ||
@@ -59,2 +69,3 @@ const { logData } = args; | ||
...rawRequest, | ||
// eslint-disable-next-line @typescript-eslint/no-unsafe-type-assertion -- acceptable | ||
body: rawRequest.body ? JSON.parse(rawRequest.body) : undefined, | ||
@@ -84,3 +95,3 @@ }; | ||
const columns = globalThis.process.stdout.columns ?? Number.POSITIVE_INFINITY; | ||
size = size < columns ? size : columns; | ||
size = Math.min(size, columns); | ||
} | ||
@@ -223,2 +234,3 @@ const breaker = `${Array.from({ length: size + 1 }).join("-")}-\n`; | ||
try { | ||
// eslint-disable-next-line @typescript-eslint/no-unsafe-type-assertion -- acceptable | ||
json = await response.json(); | ||
@@ -246,2 +258,3 @@ } | ||
if (ok) { | ||
// eslint-disable-next-line @typescript-eslint/no-unsafe-type-assertion -- acceptable | ||
const data = normailzeResponse(json); | ||
@@ -259,2 +272,3 @@ /** | ||
} | ||
// eslint-disable-next-line @typescript-eslint/no-unsafe-type-assertion -- acceptable | ||
const error = json; | ||
@@ -313,2 +327,3 @@ /** | ||
} | ||
// eslint-disable-next-line @typescript-eslint/no-unsafe-type-assertion -- acceptable | ||
return { | ||
@@ -315,0 +330,0 @@ data: undefined, |
{ | ||
"name": "@newsteam/cosmos", | ||
"version": "1.0.11", | ||
"version": "1.0.12", | ||
"author": "newsteam.io", | ||
@@ -48,11 +48,11 @@ "license": "ISC", | ||
"devDependencies": { | ||
"@babel/core": "^7.25.2", | ||
"@babel/preset-env": "^7.25.4", | ||
"@babel/preset-typescript": "^7.24.7", | ||
"@faker-js/faker": "9.0.3", | ||
"@babel/core": "^7.26.0", | ||
"@babel/preset-env": "^7.26.0", | ||
"@babel/preset-typescript": "^7.26.0", | ||
"@faker-js/faker": "9.3.0", | ||
"@jest/globals": "^29.7.0", | ||
"@types/dashify": "^1.0.3", | ||
"@types/fs-extra": "^11.0.4", | ||
"@types/jest": "^29.5.13", | ||
"@types/node": "22.7.3", | ||
"@types/jest": "^29.5.14", | ||
"@types/node": "22.10.1", | ||
"@types/sha1": "1.1.5", | ||
@@ -59,0 +59,0 @@ "babel-jest": "^29.7.0", |
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
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
408970
1.1%8513
1.55%