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

@newsteam/cosmos

Package Overview
Dependencies
Maintainers
0
Versions
8
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@newsteam/cosmos - npm Package Compare versions

Comparing version 1.0.4 to 1.0.5

2

dist/cjs/errors.js

@@ -21,3 +21,3 @@ "use strict";

"UserNotActivatedError",
"UserNotFoundError"
"UserNotFoundError",
];

@@ -15,3 +15,3 @@ import { AnalyticsModule } from "./modules/analytics";

import { WidgetsModule } from "./modules/widgets";
export type { Response } from "./request";
export type { AccessTokenNotFoundError, AddressRequiredError, AlreadySubscribedToPackageError, APIError, ConflictingPackageSubscriptionError, InvalidPasswordError, InvalidResetTokenError, OfferNotGiftableError, PasswordNeedsDigitError, PasswordNeedsLowerCharError, PasswordTooShortError, RequestError, SubNotFoundError, TransNotFoundError, UnsupportedPaymentMethodError, UserAlreadyExistsError, UserNotActivatedError, UserNotFoundError, } from "./errors";
export { AnalyticsModule } from "./modules/analytics";

@@ -31,4 +31,4 @@ export { ArticlesModule } from "./modules/articles";

export { WidgetsModule } from "./modules/widgets";
export type { AccessTokenNotFoundError, AddressRequiredError, AlreadySubscribedToPackageError, APIError, ConflictingPackageSubscriptionError, InvalidPasswordError, InvalidResetTokenError, OfferNotGiftableError, PasswordNeedsDigitError, PasswordNeedsLowerCharError, PasswordTooShortError, RequestError, SubNotFoundError, TransNotFoundError, UnsupportedPaymentMethodError, UserAlreadyExistsError, UserNotActivatedError, UserNotFoundError } from "./errors";
export type { AccessToken, AccordionWidget, AccountSettings, Article, ArticleListWidget, ArticlePlacement, ArticleSection, Author, Catalog, ChartblocksWidget, FacebookPostWidget, FacebookVideoWidget, GalleryWidget, GoogleMapWidget, HrWidget, HtmlWidget, IframelyWidget, Image, ImageWidget, InfoBlockWidget, InfogramWidget, InstagramWidget, IonoWidget, IssuuWidget, JWPlayerWidget, KickstarterWidget, LinkBarWidget, NoAccessWidget, Notification, OovvuuWidget, PartialArticle, Payment, PaymentMethod, PollDaddyWidget, Product, PublicationSettings, QuoteWidget, RelatedArticlesWidget, RequestToken, ScribdWidget, SectionSettings, SoundCloudWidget, Sponsor, Subscription, SubsectionSettings, Success, Teaser, TextWidget, TweetWidget, UserCreate, UserMe, VideoListingProperty, WidgetMedia, WidgetMediaAudio, WidgetMediaBlockquote, WidgetMediaImage, WidgetMediaInfographic, WidgetMediaSocial, WidgetMediaVideo, YoutubeWidget } from "./types";
export type { Response } from "./request";
export type { AccessToken, AccordionWidget, AccountSettings, Article, ArticleListWidget, ArticlePlacement, ArticleSection, Author, Catalog, ChartblocksWidget, FacebookPostWidget, FacebookVideoWidget, GalleryWidget, GoogleMapWidget, HrWidget, HtmlWidget, IframelyWidget, Image, ImageWidget, InfoBlockWidget, InfogramWidget, InstagramWidget, IonoWidget, IssuuWidget, JWPlayerWidget, KickstarterWidget, LinkBarWidget, NoAccessWidget, Notification, OovvuuWidget, PartialArticle, Payment, PaymentMethod, PollDaddyWidget, Product, PublicationSettings, QuoteWidget, RelatedArticlesWidget, RequestToken, ScribdWidget, SectionSettings, SoundCloudWidget, Sponsor, Subscription, SubsectionSettings, Success, Teaser, TextWidget, TweetWidget, UserCreate, UserMe, VideoListingProperty, WidgetMedia, WidgetMediaAudio, WidgetMediaBlockquote, WidgetMediaImage, WidgetMediaInfographic, WidgetMediaSocial, WidgetMediaVideo, YoutubeWidget, } from "./types";
export type NextFetchOptions = {

@@ -43,3 +43,3 @@ revalidate?: number;

custom?: CustomModule;
getAccessToken?: (authCookieName: string) => Promise<string | undefined> | string;
getAccessToken?: (authCookieName: string) => string | Promise<string | undefined>;
host: string;

@@ -46,0 +46,0 @@ log?: boolean | "all" | "error" | "none";

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.NewsTeamCosmosAPI = exports.WidgetsModule = exports.VoucherModule = exports.UserModule = exports.TeasersModule = exports.SubscriptionsModule = exports.SectionsModule = exports.ProductModule = exports.PaymentsModule = exports.NotificationsModule = exports.CatalogModule = exports.AuthorsModule = exports.AuthModule = exports.ArticlesModule = exports.AnalyticsModule = void 0;
const request_1 = require("./request");
const analytics_1 = require("./modules/analytics");

@@ -19,2 +18,3 @@ const articles_1 = require("./modules/articles");

const widgets_1 = require("./modules/widgets");
const request_1 = require("./request");
var analytics_2 = require("./modules/analytics");

@@ -64,3 +64,3 @@ Object.defineProperty(exports, "AnalyticsModule", { enumerable: true, get: function () { return analytics_2.AnalyticsModule; } });

"voucher",
"widgets"
"widgets",
];

@@ -67,0 +67,0 @@ static openAPIV3Doc = "https:/api.newsteam.io/cosmos/next/openapi";

import type { Request, RequestOptions, Response } from "../request";
import type { PartialArticle } from "../types";
export type AnalyticsModuleOptions = {
type AnalyticsModuleOptions = {
next: {

@@ -33,2 +33,3 @@ revalidate: {

}
export {};
//# sourceMappingURL=analytics.d.ts.map
import type { Request, RequestOptions, Response } from "../request";
import type { Article } from "../types";
export type ArticlesModuleOptions = {
type ArticlesModuleOptions = {
next: {

@@ -182,2 +182,3 @@ revalidate: {

}
export {};
//# sourceMappingURL=articles.d.ts.map
import type { Request, RequestOptions, Response } from "../request";
import type { AccessToken, RequestToken, Success } from "../types";
export type AuthModuleOptions = {
type AuthModuleOptions = {
next: {

@@ -42,2 +42,3 @@ revalidate: {

}
export {};
//# sourceMappingURL=auth.d.ts.map
import type { Request, RequestOptions, Response } from "../request";
import type { Author } from "../types";
export type AuthorsModuleOptions = {
type AuthorsModuleOptions = {
next: {

@@ -27,2 +27,3 @@ revalidate: {

}
export {};
//# sourceMappingURL=authors.d.ts.map
import type { Request, RequestOptions, Response } from "../request";
import type { Catalog } from "../types";
export type CatalogModuleOptions = {
type CatalogModuleOptions = {
next: {

@@ -23,2 +23,3 @@ revalidate: {

}
export {};
//# sourceMappingURL=catalog.d.ts.map
import type { Request, RequestOptions, Response } from "../request";
import type { Notification } from "../types";
export type NotificationsModuleOptions = {
type NotificationsModuleOptions = {
next: {

@@ -18,2 +18,3 @@ revalidate: {

}
export {};
//# sourceMappingURL=notifications.d.ts.map

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

import type { AddressRequiredError, AlreadySubscribedToPackageError, ConflictingPackageSubscriptionError, OfferNotGiftableError, SubNotFoundError, TransNotFoundError, UnsupportedPaymentMethodError } from "../errors";
import type { Request, RequestOptions, Response } from "../request";
import type { AddressRequiredError, AlreadySubscribedToPackageError, ConflictingPackageSubscriptionError, OfferNotGiftableError, SubNotFoundError, TransNotFoundError, UnsupportedPaymentMethodError } from "../errors";
import type { Payment, PaymentMethod } from "../types";
export type PaymentsModuleOptions = {
type PaymentsModuleOptions = {
next: {

@@ -42,2 +42,3 @@ revalidate: {

}
export {};
//# sourceMappingURL=payments.d.ts.map
import type { Request, RequestOptions, Response } from "../request";
import type { Product } from "../types";
export type ProductModuleOptions = {
type ProductModuleOptions = {
next: {

@@ -18,2 +18,3 @@ revalidate: {

}
export {};
//# sourceMappingURL=product.d.ts.map
import type { Request, RequestOptions, Response } from "../request";
import type { PublicationSettings } from "../types";
export type SectionsModuleOptions = {
type SectionsModuleOptions = {
next: {

@@ -21,2 +21,3 @@ revalidate: {

}
export {};
//# sourceMappingURL=sections.d.ts.map

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

import type { SubNotFoundError } from "../errors";
import type { Request, RequestOptions, Response } from "../request";
import type { SubNotFoundError } from "../errors";
import type { Subscription } from "../types";
export type SubscriptionsModuleOptions = {
type SubscriptionsModuleOptions = {
next: {

@@ -23,2 +23,3 @@ revalidate: {

}
export {};
//# sourceMappingURL=subscriptions.d.ts.map
import type { Request, RequestOptions, Response } from "../request";
import type { Teaser } from "../types";
export type TeasersModuleOptions = {
type TeasersModuleOptions = {
next: {

@@ -34,2 +34,3 @@ revalidate: {

}
export {};
//# sourceMappingURL=teasers.d.ts.map

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

import type { AccessTokenNotFoundError, InvalidPasswordError, InvalidResetTokenError, PasswordNeedsDigitError, PasswordNeedsLowerCharError, PasswordTooShortError, UserAlreadyExistsError, UserNotActivatedError, UserNotFoundError } from "../errors";
import type { Request, RequestOptions, Response } from "../request";
import type { AccessTokenNotFoundError, InvalidPasswordError, InvalidResetTokenError, PasswordNeedsDigitError, PasswordNeedsLowerCharError, PasswordTooShortError, UserAlreadyExistsError, UserNotActivatedError, UserNotFoundError } from "../errors";
import type { UserCreate, UserMe } from "../types";
export type UserModuleOptions = {
type UserModuleOptions = {
next: {

@@ -56,2 +56,3 @@ revalidate: {

}
export {};
//# sourceMappingURL=user.d.ts.map

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

import type { AlreadySubscribedToPackageError } from "../errors";
import type { Request, RequestOptions, Response } from "../request";
import type { AlreadySubscribedToPackageError } from "../errors";
import type { Subscription } from "../types";
export type VoucherModuleOptions = {
type VoucherModuleOptions = {
next: {

@@ -19,2 +19,3 @@ revalidate: {

}
export {};
//# sourceMappingURL=voucher.d.ts.map
import type { Request, RequestOptions, Response } from "../request";
import type { WidgetMedia } from "../types";
export type WidgetsModuleOptions = {
type WidgetsModuleOptions = {
next: {

@@ -45,2 +45,3 @@ revalidate: {

}
export {};
//# sourceMappingURL=widgets.d.ts.map

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

import type { NextFetchOptions } from ".";
import type { RequestError } from "./errors";
import type { NextFetchOptions } from ".";
import type { JSONSchema4 } from "json-schema";
type LogLevel = "all" | "error" | "none";
export interface SuccessResponse<SuccessResponseData> {
interface SuccessResponse<SuccessResponseData> {
data: SuccessResponseData;

@@ -10,3 +9,3 @@ error: undefined;

}
export type ErrorResponse<ErrorResponseData = undefined> = [ErrorResponseData] extends [undefined] ? {
type ErrorResponse<ErrorResponseData = undefined> = [ErrorResponseData] extends [undefined] ? {
data: undefined;

@@ -20,3 +19,3 @@ error: RequestError;

};
export type Response<SuccessResponseData, ErrorResponseData = undefined> = ErrorResponse<ErrorResponseData> | SuccessResponse<SuccessResponseData>;
type Response<SuccessResponseData, ErrorResponseData = undefined> = ErrorResponse<ErrorResponseData> | SuccessResponse<SuccessResponseData>;
/**

@@ -26,3 +25,3 @@ * Request options exposed in the options of each module method. These are meant

*/
export interface RequestOptions {
interface RequestOptions {
accessToken?: string;

@@ -34,10 +33,6 @@ cache?: RequestCache;

host?: string;
log?: LogLevel | boolean;
log?: boolean | LogLevel;
next?: NextFetchOptions;
signal?: AbortSignal;
}
export interface RequestSchema {
args?: JSONSchema4;
response?: JSONSchema4;
}
/**

@@ -47,7 +42,7 @@ * Request options used when registering a module method fetch. These options

*/
export type PrivateRequestOption = RequestOptions;
export type FetchRequestOptions = RequestInit & {
type PrivateRequestOption = RequestOptions;
type FetchRequestOptions = RequestInit & {
next?: NextFetchOptions;
};
export declare class Request {
declare class Request {
private readonly authCookieName;

@@ -66,5 +61,5 @@ private readonly clientProxy?;

consumer: string;
getAccessToken?: (authCookieName: string) => Promise<string | undefined> | string;
getAccessToken?: (authCookieName: string) => string | Promise<string | undefined>;
host: string;
log?: LogLevel | boolean;
log?: boolean | LogLevel;
protocol?: "http" | "https";

@@ -83,3 +78,4 @@ });

}
export {};
export { Request, };
export type { FetchRequestOptions, RequestOptions, Response, };
//# sourceMappingURL=request.d.ts.map

@@ -7,7 +7,8 @@ "use strict";

exports.Request = void 0;
const camelcase_keys_1 = __importDefault(require("camelcase-keys"));
const snakecase_keys_1 = __importDefault(require("snakecase-keys"));
const vaper_1 = __importDefault(require("vaper"));
const snakecase_keys_1 = __importDefault(require("snakecase-keys"));
const camelcase_keys_1 = __importDefault(require("camelcase-keys"));
const errors_1 = require("./errors");
const maxLogLength = 25;
const MAX_LOG_LENGTH = 25;
const TAB_SIZE = 4;
const getLogLevel = (log) => {

@@ -56,3 +57,3 @@ if (log === true) {

.map((ln) => ` ${ln}`)
.slice(0, maxLogLength)
.slice(0, MAX_LOG_LENGTH)
.join("\n")

@@ -62,3 +63,3 @@ .trim()}`;

const { logData } = args;
const { headers, response, request: rawRequest, url, } = logData;
const { headers, request: rawRequest, response, url, } = logData;
const request = {

@@ -68,3 +69,2 @@ ...rawRequest,

};
const tabSize = 4;
const urlLog = logSection("url", url);

@@ -81,10 +81,9 @@ const requestLog = logSection("request", request);

const headersLog = headersObject ? logSection("response headers", headersObject) : undefined;
let outputs = [];
outputs = [
const outputs = [
urlLog,
requestLog,
responseLog ?? "",
headersLog ?? ""
headersLog ?? "",
].filter(Boolean);
let size = Math.max(...outputs.flatMap((chunk) => chunk.split("\n")).map((line) => line.length)) + tabSize * 2;
let size = Math.max(...outputs.flatMap((chunk) => chunk.split("\n")).map((line) => line.length)) + TAB_SIZE * 2;
// eslint-disable-next-line @typescript-eslint/no-unnecessary-condition -- necessary for isomorphic

@@ -141,4 +140,4 @@ if (globalThis.process?.stdout !== undefined) {

async fetch(args) {
const { url: fetchUrl, options: fetchOptions, method = "post", args: fetchArgs, } = args;
const { accessToken: manualAccessToken, cache, host: fetchHost, log: rawLogArgument = this.log, signal, next, } = fetchOptions;
const { args: fetchArgs, method = "post", options: fetchOptions, url: fetchUrl, } = args;
const { accessToken: manualAccessToken, cache, host: fetchHost, log: rawLogArgument = this.log, next, signal, } = fetchOptions;
const logLevel = getLogLevel(rawLogArgument);

@@ -191,3 +190,3 @@ const accessToken = await (async () => {

if (method === "get" && fetchArgs) {
response = await fetch(`${url}?${Object.entries(fetchArgs).map((kv) => kv.map((key) => encodeURIComponent(key)).join("=")).join("&")}`, request);
response = await fetch(`${url}?${Object.entries(fetchArgs).map((kv) => kv.map((key) => encodeURIComponent(String(key))).join("=")).join("&")}`, request);
}

@@ -194,0 +193,0 @@ else {

@@ -54,4 +54,4 @@ export interface AccessToken {

image?: Image;
indexed?: boolean;
indexPosition?: number;
indexed?: boolean;
key: number;

@@ -149,2 +149,6 @@ name?: string;

/**
* Indicates whether or not an article is flagged as editors choice/editors pick
*/
editorsChoice?: boolean;
/**
* This is the edit/backend slug/url-portion for this article. All stories contain a `editUrl`

@@ -154,6 +158,2 @@ */

/**
* Indicates whether or not an article is flagged as editors choice/editors pick
*/
editorsChoice?: boolean;
/**
* List of articles keys that have been linked within the widgets of this article (related article widgets and list widgets)

@@ -249,2 +249,6 @@ */

/**
* Computed list of all images used within the article, in usage/priority order (first image in the list could be considered the main image, however if you are trying to simple show the main/thumbnail for this article, use the `image` property)
*/
images?: Image[];
/**
* Custom thumbnail set by editorial (use `image` prop when making client templates)

@@ -284,8 +288,4 @@ */

};
/**
* Computed list of all images used within the article, in usage/priority order (first image in the list could be considered the main image, however if you are trying to simple show the main/thumbnail for this article, use the `image` property)
*/
images?: Image[];
indexed?: boolean;
indexPosition?: number;
indexed?: boolean;
/**

@@ -392,6 +392,2 @@ * Intro block (this prop can contain HTML markup)

/**
* This is the public facing/published slug/url-portion for this article. Only once a story is published will it have a `pubUrl`, all client facing templates should only ever route to this url
*/
pubUrl?: string;
/**
* Computed primary publication

@@ -410,2 +406,6 @@ */

/**
* This is the public facing/published slug/url-portion for this article. Only once a story is published will it have a `pubUrl`, all client facing templates should only ever route to this url
*/
pubUrl?: string;
/**
* This can be set by editorial and used as a filter query to retrive a list of articles marked by editorial that are worthy of being sent as a push notification

@@ -651,4 +651,4 @@ */

image?: Image;
indexed?: boolean;
indexPosition?: number;
indexed?: boolean;
key: number;

@@ -695,5 +695,5 @@ name?: string;

expiresInDays: number;
externalSub: boolean;
recurring: boolean;
refundAmount: boolean;
externalSub: boolean;
refundCard?: {

@@ -878,4 +878,4 @@ cardNumber: string;

float?: "left" | "right";
id?: string;
image: Image;
id?: string;
};

@@ -1083,4 +1083,4 @@ id: string;

image?: Image;
indexed?: boolean;
indexPosition?: number;
indexed?: boolean;
key: number;

@@ -1178,2 +1178,6 @@ name?: string;

/**
* Indicates whether or not an article is flagged as editors choice/editors pick
*/
editorsChoice?: boolean;
/**
* This is the edit/backend slug/url-portion for this article. All stories contain a `editUrl`

@@ -1183,6 +1187,2 @@ */

/**
* Indicates whether or not an article is flagged as editors choice/editors pick
*/
editorsChoice?: boolean;
/**
* List of articles keys that have been linked within the widgets of this article (related article widgets and list widgets)

@@ -1278,2 +1278,6 @@ */

/**
* Computed list of all images used within the article, in usage/priority order (first image in the list could be considered the main image, however if you are trying to simple show the main/thumbnail for this article, use the `image` property)
*/
images?: Image[];
/**
* Custom thumbnail set by editorial (use `image` prop when making client templates)

@@ -1313,8 +1317,4 @@ */

};
/**
* Computed list of all images used within the article, in usage/priority order (first image in the list could be considered the main image, however if you are trying to simple show the main/thumbnail for this article, use the `image` property)
*/
images?: Image[];
indexed?: boolean;
indexPosition?: number;
indexed?: boolean;
/**

@@ -1421,6 +1421,2 @@ * Intro block (this prop can contain HTML markup)

/**
* This is the public facing/published slug/url-portion for this article. Only once a story is published will it have a `pubUrl`, all client facing templates should only ever route to this url
*/
pubUrl?: string;
/**
* Computed primary publication

@@ -1439,2 +1435,6 @@ */

/**
* This is the public facing/published slug/url-portion for this article. Only once a story is published will it have a `pubUrl`, all client facing templates should only ever route to this url
*/
pubUrl?: string;
/**
* This can be set by editorial and used as a filter query to retrive a list of articles marked by editorial that are worthy of being sent as a push notification

@@ -1692,3 +1692,3 @@ */

googleNewsName?: string;
id?: string;
id: string;
meta?: {

@@ -1695,0 +1695,0 @@ description?: string;

@@ -18,3 +18,3 @@ export const errorTypes = [

"UserNotActivatedError",
"UserNotFoundError"
"UserNotFoundError",
];

@@ -15,3 +15,3 @@ import { AnalyticsModule } from "./modules/analytics";

import { WidgetsModule } from "./modules/widgets";
export type { Response } from "./request";
export type { AccessTokenNotFoundError, AddressRequiredError, AlreadySubscribedToPackageError, APIError, ConflictingPackageSubscriptionError, InvalidPasswordError, InvalidResetTokenError, OfferNotGiftableError, PasswordNeedsDigitError, PasswordNeedsLowerCharError, PasswordTooShortError, RequestError, SubNotFoundError, TransNotFoundError, UnsupportedPaymentMethodError, UserAlreadyExistsError, UserNotActivatedError, UserNotFoundError, } from "./errors";
export { AnalyticsModule } from "./modules/analytics";

@@ -31,4 +31,4 @@ export { ArticlesModule } from "./modules/articles";

export { WidgetsModule } from "./modules/widgets";
export type { AccessTokenNotFoundError, AddressRequiredError, AlreadySubscribedToPackageError, APIError, ConflictingPackageSubscriptionError, InvalidPasswordError, InvalidResetTokenError, OfferNotGiftableError, PasswordNeedsDigitError, PasswordNeedsLowerCharError, PasswordTooShortError, RequestError, SubNotFoundError, TransNotFoundError, UnsupportedPaymentMethodError, UserAlreadyExistsError, UserNotActivatedError, UserNotFoundError } from "./errors";
export type { AccessToken, AccordionWidget, AccountSettings, Article, ArticleListWidget, ArticlePlacement, ArticleSection, Author, Catalog, ChartblocksWidget, FacebookPostWidget, FacebookVideoWidget, GalleryWidget, GoogleMapWidget, HrWidget, HtmlWidget, IframelyWidget, Image, ImageWidget, InfoBlockWidget, InfogramWidget, InstagramWidget, IonoWidget, IssuuWidget, JWPlayerWidget, KickstarterWidget, LinkBarWidget, NoAccessWidget, Notification, OovvuuWidget, PartialArticle, Payment, PaymentMethod, PollDaddyWidget, Product, PublicationSettings, QuoteWidget, RelatedArticlesWidget, RequestToken, ScribdWidget, SectionSettings, SoundCloudWidget, Sponsor, Subscription, SubsectionSettings, Success, Teaser, TextWidget, TweetWidget, UserCreate, UserMe, VideoListingProperty, WidgetMedia, WidgetMediaAudio, WidgetMediaBlockquote, WidgetMediaImage, WidgetMediaInfographic, WidgetMediaSocial, WidgetMediaVideo, YoutubeWidget } from "./types";
export type { Response } from "./request";
export type { AccessToken, AccordionWidget, AccountSettings, Article, ArticleListWidget, ArticlePlacement, ArticleSection, Author, Catalog, ChartblocksWidget, FacebookPostWidget, FacebookVideoWidget, GalleryWidget, GoogleMapWidget, HrWidget, HtmlWidget, IframelyWidget, Image, ImageWidget, InfoBlockWidget, InfogramWidget, InstagramWidget, IonoWidget, IssuuWidget, JWPlayerWidget, KickstarterWidget, LinkBarWidget, NoAccessWidget, Notification, OovvuuWidget, PartialArticle, Payment, PaymentMethod, PollDaddyWidget, Product, PublicationSettings, QuoteWidget, RelatedArticlesWidget, RequestToken, ScribdWidget, SectionSettings, SoundCloudWidget, Sponsor, Subscription, SubsectionSettings, Success, Teaser, TextWidget, TweetWidget, UserCreate, UserMe, VideoListingProperty, WidgetMedia, WidgetMediaAudio, WidgetMediaBlockquote, WidgetMediaImage, WidgetMediaInfographic, WidgetMediaSocial, WidgetMediaVideo, YoutubeWidget, } from "./types";
export type NextFetchOptions = {

@@ -43,3 +43,3 @@ revalidate?: number;

custom?: CustomModule;
getAccessToken?: (authCookieName: string) => Promise<string | undefined> | string;
getAccessToken?: (authCookieName: string) => string | Promise<string | undefined>;
host: string;

@@ -46,0 +46,0 @@ log?: boolean | "all" | "error" | "none";

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

import { Request } from "./request";
import { AnalyticsModule } from "./modules/analytics";

@@ -16,2 +15,3 @@ import { ArticlesModule } from "./modules/articles";

import { WidgetsModule } from "./modules/widgets";
import { Request } from "./request";
export { AnalyticsModule } from "./modules/analytics";

@@ -47,3 +47,3 @@ export { ArticlesModule } from "./modules/articles";

"voucher",
"widgets"
"widgets",
];

@@ -50,0 +50,0 @@ static openAPIV3Doc = "https:/api.newsteam.io/cosmos/next/openapi";

import type { Request, RequestOptions, Response } from "../request";
import type { PartialArticle } from "../types";
export type AnalyticsModuleOptions = {
type AnalyticsModuleOptions = {
next: {

@@ -33,2 +33,3 @@ revalidate: {

}
export {};
//# sourceMappingURL=analytics.d.ts.map
import type { Request, RequestOptions, Response } from "../request";
import type { Article } from "../types";
export type ArticlesModuleOptions = {
type ArticlesModuleOptions = {
next: {

@@ -182,2 +182,3 @@ revalidate: {

}
export {};
//# sourceMappingURL=articles.d.ts.map
import type { Request, RequestOptions, Response } from "../request";
import type { AccessToken, RequestToken, Success } from "../types";
export type AuthModuleOptions = {
type AuthModuleOptions = {
next: {

@@ -42,2 +42,3 @@ revalidate: {

}
export {};
//# sourceMappingURL=auth.d.ts.map
import type { Request, RequestOptions, Response } from "../request";
import type { Author } from "../types";
export type AuthorsModuleOptions = {
type AuthorsModuleOptions = {
next: {

@@ -27,2 +27,3 @@ revalidate: {

}
export {};
//# sourceMappingURL=authors.d.ts.map
import type { Request, RequestOptions, Response } from "../request";
import type { Catalog } from "../types";
export type CatalogModuleOptions = {
type CatalogModuleOptions = {
next: {

@@ -23,2 +23,3 @@ revalidate: {

}
export {};
//# sourceMappingURL=catalog.d.ts.map
import type { Request, RequestOptions, Response } from "../request";
import type { Notification } from "../types";
export type NotificationsModuleOptions = {
type NotificationsModuleOptions = {
next: {

@@ -18,2 +18,3 @@ revalidate: {

}
export {};
//# sourceMappingURL=notifications.d.ts.map

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

import type { AddressRequiredError, AlreadySubscribedToPackageError, ConflictingPackageSubscriptionError, OfferNotGiftableError, SubNotFoundError, TransNotFoundError, UnsupportedPaymentMethodError } from "../errors";
import type { Request, RequestOptions, Response } from "../request";
import type { AddressRequiredError, AlreadySubscribedToPackageError, ConflictingPackageSubscriptionError, OfferNotGiftableError, SubNotFoundError, TransNotFoundError, UnsupportedPaymentMethodError } from "../errors";
import type { Payment, PaymentMethod } from "../types";
export type PaymentsModuleOptions = {
type PaymentsModuleOptions = {
next: {

@@ -42,2 +42,3 @@ revalidate: {

}
export {};
//# sourceMappingURL=payments.d.ts.map
import type { Request, RequestOptions, Response } from "../request";
import type { Product } from "../types";
export type ProductModuleOptions = {
type ProductModuleOptions = {
next: {

@@ -18,2 +18,3 @@ revalidate: {

}
export {};
//# sourceMappingURL=product.d.ts.map
import type { Request, RequestOptions, Response } from "../request";
import type { PublicationSettings } from "../types";
export type SectionsModuleOptions = {
type SectionsModuleOptions = {
next: {

@@ -21,2 +21,3 @@ revalidate: {

}
export {};
//# sourceMappingURL=sections.d.ts.map

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

import type { SubNotFoundError } from "../errors";
import type { Request, RequestOptions, Response } from "../request";
import type { SubNotFoundError } from "../errors";
import type { Subscription } from "../types";
export type SubscriptionsModuleOptions = {
type SubscriptionsModuleOptions = {
next: {

@@ -23,2 +23,3 @@ revalidate: {

}
export {};
//# sourceMappingURL=subscriptions.d.ts.map
import type { Request, RequestOptions, Response } from "../request";
import type { Teaser } from "../types";
export type TeasersModuleOptions = {
type TeasersModuleOptions = {
next: {

@@ -34,2 +34,3 @@ revalidate: {

}
export {};
//# sourceMappingURL=teasers.d.ts.map

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

import type { AccessTokenNotFoundError, InvalidPasswordError, InvalidResetTokenError, PasswordNeedsDigitError, PasswordNeedsLowerCharError, PasswordTooShortError, UserAlreadyExistsError, UserNotActivatedError, UserNotFoundError } from "../errors";
import type { Request, RequestOptions, Response } from "../request";
import type { AccessTokenNotFoundError, InvalidPasswordError, InvalidResetTokenError, PasswordNeedsDigitError, PasswordNeedsLowerCharError, PasswordTooShortError, UserAlreadyExistsError, UserNotActivatedError, UserNotFoundError } from "../errors";
import type { UserCreate, UserMe } from "../types";
export type UserModuleOptions = {
type UserModuleOptions = {
next: {

@@ -56,2 +56,3 @@ revalidate: {

}
export {};
//# sourceMappingURL=user.d.ts.map

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

import type { AlreadySubscribedToPackageError } from "../errors";
import type { Request, RequestOptions, Response } from "../request";
import type { AlreadySubscribedToPackageError } from "../errors";
import type { Subscription } from "../types";
export type VoucherModuleOptions = {
type VoucherModuleOptions = {
next: {

@@ -19,2 +19,3 @@ revalidate: {

}
export {};
//# sourceMappingURL=voucher.d.ts.map
import type { Request, RequestOptions, Response } from "../request";
import type { WidgetMedia } from "../types";
export type WidgetsModuleOptions = {
type WidgetsModuleOptions = {
next: {

@@ -45,2 +45,3 @@ revalidate: {

}
export {};
//# sourceMappingURL=widgets.d.ts.map

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

import type { NextFetchOptions } from ".";
import type { RequestError } from "./errors";
import type { NextFetchOptions } from ".";
import type { JSONSchema4 } from "json-schema";
type LogLevel = "all" | "error" | "none";
export interface SuccessResponse<SuccessResponseData> {
interface SuccessResponse<SuccessResponseData> {
data: SuccessResponseData;

@@ -10,3 +9,3 @@ error: undefined;

}
export type ErrorResponse<ErrorResponseData = undefined> = [ErrorResponseData] extends [undefined] ? {
type ErrorResponse<ErrorResponseData = undefined> = [ErrorResponseData] extends [undefined] ? {
data: undefined;

@@ -20,3 +19,3 @@ error: RequestError;

};
export type Response<SuccessResponseData, ErrorResponseData = undefined> = ErrorResponse<ErrorResponseData> | SuccessResponse<SuccessResponseData>;
type Response<SuccessResponseData, ErrorResponseData = undefined> = ErrorResponse<ErrorResponseData> | SuccessResponse<SuccessResponseData>;
/**

@@ -26,3 +25,3 @@ * Request options exposed in the options of each module method. These are meant

*/
export interface RequestOptions {
interface RequestOptions {
accessToken?: string;

@@ -34,10 +33,6 @@ cache?: RequestCache;

host?: string;
log?: LogLevel | boolean;
log?: boolean | LogLevel;
next?: NextFetchOptions;
signal?: AbortSignal;
}
export interface RequestSchema {
args?: JSONSchema4;
response?: JSONSchema4;
}
/**

@@ -47,7 +42,7 @@ * Request options used when registering a module method fetch. These options

*/
export type PrivateRequestOption = RequestOptions;
export type FetchRequestOptions = RequestInit & {
type PrivateRequestOption = RequestOptions;
type FetchRequestOptions = RequestInit & {
next?: NextFetchOptions;
};
export declare class Request {
declare class Request {
private readonly authCookieName;

@@ -66,5 +61,5 @@ private readonly clientProxy?;

consumer: string;
getAccessToken?: (authCookieName: string) => Promise<string | undefined> | string;
getAccessToken?: (authCookieName: string) => string | Promise<string | undefined>;
host: string;
log?: LogLevel | boolean;
log?: boolean | LogLevel;
protocol?: "http" | "https";

@@ -83,3 +78,4 @@ });

}
export {};
export { Request, };
export type { FetchRequestOptions, RequestOptions, Response, };
//# sourceMappingURL=request.d.ts.map

@@ -0,6 +1,7 @@

import camelcaseKeys from "camelcase-keys";
import snakeCaseKeys from "snakecase-keys";
import { default as vaper } from "vaper";
import snakeCaseKeys from "snakecase-keys";
import camelcaseKeys from "camelcase-keys";
import { errorTypes } from "./errors";
const maxLogLength = 25;
const MAX_LOG_LENGTH = 25;
const TAB_SIZE = 4;
const getLogLevel = (log) => {

@@ -49,3 +50,3 @@ if (log === true) {

.map((ln) => ` ${ln}`)
.slice(0, maxLogLength)
.slice(0, MAX_LOG_LENGTH)
.join("\n")

@@ -55,3 +56,3 @@ .trim()}`;

const { logData } = args;
const { headers, response, request: rawRequest, url, } = logData;
const { headers, request: rawRequest, response, url, } = logData;
const request = {

@@ -61,3 +62,2 @@ ...rawRequest,

};
const tabSize = 4;
const urlLog = logSection("url", url);

@@ -74,10 +74,9 @@ const requestLog = logSection("request", request);

const headersLog = headersObject ? logSection("response headers", headersObject) : undefined;
let outputs = [];
outputs = [
const outputs = [
urlLog,
requestLog,
responseLog ?? "",
headersLog ?? ""
headersLog ?? "",
].filter(Boolean);
let size = Math.max(...outputs.flatMap((chunk) => chunk.split("\n")).map((line) => line.length)) + tabSize * 2;
let size = Math.max(...outputs.flatMap((chunk) => chunk.split("\n")).map((line) => line.length)) + TAB_SIZE * 2;
// eslint-disable-next-line @typescript-eslint/no-unnecessary-condition -- necessary for isomorphic

@@ -109,3 +108,3 @@ if (globalThis.process?.stdout !== undefined) {

};
export class Request {
class Request {
authCookieName;

@@ -135,4 +134,4 @@ clientProxy;

async fetch(args) {
const { url: fetchUrl, options: fetchOptions, method = "post", args: fetchArgs, } = args;
const { accessToken: manualAccessToken, cache, host: fetchHost, log: rawLogArgument = this.log, signal, next, } = fetchOptions;
const { args: fetchArgs, method = "post", options: fetchOptions, url: fetchUrl, } = args;
const { accessToken: manualAccessToken, cache, host: fetchHost, log: rawLogArgument = this.log, next, signal, } = fetchOptions;
const logLevel = getLogLevel(rawLogArgument);

@@ -185,3 +184,3 @@ const accessToken = await (async () => {

if (method === "get" && fetchArgs) {
response = await fetch(`${url}?${Object.entries(fetchArgs).map((kv) => kv.map((key) => encodeURIComponent(key)).join("=")).join("&")}`, request);
response = await fetch(`${url}?${Object.entries(fetchArgs).map((kv) => kv.map((key) => encodeURIComponent(String(key))).join("=")).join("&")}`, request);
}

@@ -360,1 +359,2 @@ else {

}
export { Request, };

@@ -54,4 +54,4 @@ export interface AccessToken {

image?: Image;
indexed?: boolean;
indexPosition?: number;
indexed?: boolean;
key: number;

@@ -149,2 +149,6 @@ name?: string;

/**
* Indicates whether or not an article is flagged as editors choice/editors pick
*/
editorsChoice?: boolean;
/**
* This is the edit/backend slug/url-portion for this article. All stories contain a `editUrl`

@@ -154,6 +158,2 @@ */

/**
* Indicates whether or not an article is flagged as editors choice/editors pick
*/
editorsChoice?: boolean;
/**
* List of articles keys that have been linked within the widgets of this article (related article widgets and list widgets)

@@ -249,2 +249,6 @@ */

/**
* Computed list of all images used within the article, in usage/priority order (first image in the list could be considered the main image, however if you are trying to simple show the main/thumbnail for this article, use the `image` property)
*/
images?: Image[];
/**
* Custom thumbnail set by editorial (use `image` prop when making client templates)

@@ -284,8 +288,4 @@ */

};
/**
* Computed list of all images used within the article, in usage/priority order (first image in the list could be considered the main image, however if you are trying to simple show the main/thumbnail for this article, use the `image` property)
*/
images?: Image[];
indexed?: boolean;
indexPosition?: number;
indexed?: boolean;
/**

@@ -392,6 +392,2 @@ * Intro block (this prop can contain HTML markup)

/**
* This is the public facing/published slug/url-portion for this article. Only once a story is published will it have a `pubUrl`, all client facing templates should only ever route to this url
*/
pubUrl?: string;
/**
* Computed primary publication

@@ -410,2 +406,6 @@ */

/**
* This is the public facing/published slug/url-portion for this article. Only once a story is published will it have a `pubUrl`, all client facing templates should only ever route to this url
*/
pubUrl?: string;
/**
* This can be set by editorial and used as a filter query to retrive a list of articles marked by editorial that are worthy of being sent as a push notification

@@ -651,4 +651,4 @@ */

image?: Image;
indexed?: boolean;
indexPosition?: number;
indexed?: boolean;
key: number;

@@ -695,5 +695,5 @@ name?: string;

expiresInDays: number;
externalSub: boolean;
recurring: boolean;
refundAmount: boolean;
externalSub: boolean;
refundCard?: {

@@ -878,4 +878,4 @@ cardNumber: string;

float?: "left" | "right";
id?: string;
image: Image;
id?: string;
};

@@ -1083,4 +1083,4 @@ id: string;

image?: Image;
indexed?: boolean;
indexPosition?: number;
indexed?: boolean;
key: number;

@@ -1178,2 +1178,6 @@ name?: string;

/**
* Indicates whether or not an article is flagged as editors choice/editors pick
*/
editorsChoice?: boolean;
/**
* This is the edit/backend slug/url-portion for this article. All stories contain a `editUrl`

@@ -1183,6 +1187,2 @@ */

/**
* Indicates whether or not an article is flagged as editors choice/editors pick
*/
editorsChoice?: boolean;
/**
* List of articles keys that have been linked within the widgets of this article (related article widgets and list widgets)

@@ -1278,2 +1278,6 @@ */

/**
* Computed list of all images used within the article, in usage/priority order (first image in the list could be considered the main image, however if you are trying to simple show the main/thumbnail for this article, use the `image` property)
*/
images?: Image[];
/**
* Custom thumbnail set by editorial (use `image` prop when making client templates)

@@ -1313,8 +1317,4 @@ */

};
/**
* Computed list of all images used within the article, in usage/priority order (first image in the list could be considered the main image, however if you are trying to simple show the main/thumbnail for this article, use the `image` property)
*/
images?: Image[];
indexed?: boolean;
indexPosition?: number;
indexed?: boolean;
/**

@@ -1421,6 +1421,2 @@ * Intro block (this prop can contain HTML markup)

/**
* This is the public facing/published slug/url-portion for this article. Only once a story is published will it have a `pubUrl`, all client facing templates should only ever route to this url
*/
pubUrl?: string;
/**
* Computed primary publication

@@ -1439,2 +1435,6 @@ */

/**
* This is the public facing/published slug/url-portion for this article. Only once a story is published will it have a `pubUrl`, all client facing templates should only ever route to this url
*/
pubUrl?: string;
/**
* This can be set by editorial and used as a filter query to retrive a list of articles marked by editorial that are worthy of being sent as a push notification

@@ -1692,3 +1692,3 @@ */

googleNewsName?: string;
id?: string;
id: string;
meta?: {

@@ -1695,0 +1695,0 @@ description?: string;

{
"name": "@newsteam/cosmos",
"version": "1.0.4",
"version": "1.0.5",
"author": "newsteam.io",

@@ -21,17 +21,20 @@ "license": "ISC",

"type": "module",
"engines": {
"node": ">=18.15.0"
},
"files": [
"/dist"
],
"engines": {
"node": ">=12.0.0"
},
"scripts": {
"build": "npm run clean && npm run build:cjs && npm run build:esm",
"build:cjs": "tsc --module commonjs --outDir dist/cjs",
"build:esm": "tsc",
"clean": "rimraf dist",
"depcheck": "depcheck",
"build:cjs": "tsc --module commonjs --outDir dist/cjs --project tsconfig.lib.json",
"build:esm": "tsc --project tsconfig.lib.json",
"clean": "rimraf dist .turbo",
"depcheck": "depcheck || true",
"lint": "npm run lint:eslint && npm run depcheck && npm run prune",
"lint:eslint": "eslint --fix",
"prepublishOnly": "npm run clean && npm run build && npm run test",
"reinstall": "rimraf node_modules package-lock.json pnpm-lock.yaml",
"test": "tsc --noEmit && tsc --project tsconfig.jest.json --noEmit"
"prune": "ts-prune",
"reinstall": "rimraf node_modules package-lock.json pnpm-lock.yaml .turbo",
"test": "tsc --noEmit"
},

@@ -42,16 +45,15 @@ "dependencies": {

"change-case-all": "^2.1.0",
"snakecase-keys": "6.0.0",
"snakecase-keys": "8.0.1",
"vaper": "1.0.1"
},
"devDependencies": {
"@babel/core": "^7.23.9",
"@babel/preset-env": "^7.23.9",
"@babel/preset-typescript": "^7.23.3",
"@faker-js/faker": "8.4.1",
"@babel/core": "^7.25.2",
"@babel/preset-env": "^7.25.4",
"@babel/preset-typescript": "^7.24.7",
"@faker-js/faker": "9.0.1",
"@jest/globals": "^29.7.0",
"@types/dashify": "^1.0.3",
"@types/fs-extra": "^11.0.4",
"@types/jest": "^29.5.12",
"@types/json-schema": "^7.0.15",
"@types/node": "20.11.19",
"@types/jest": "^29.5.13",
"@types/node": "22.5.5",
"@types/sha1": "1.1.5",

@@ -64,5 +66,5 @@ "babel-jest": "^29.7.0",

"sha1": "1.1.1",
"ts-jest": "^29.1.2",
"tsx": "^4.7.1"
"ts-jest": "^29.2.5",
"ts-prune": "^0.10.3"
}
}
}

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

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