New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@ts-ghost/core-api

Package Overview
Dependencies
Maintainers
1
Versions
45
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@ts-ghost/core-api - npm Package Compare versions

Comparing version 0.0.6 to 0.0.7

50

./dist/index.js

@@ -302,4 +302,4 @@ "use strict";

}
async fetch() {
const res = import_zod3.z.discriminatedUnion("status", [
_getResultSchema() {
return import_zod3.z.discriminatedUnion("status", [
import_zod3.z.object({

@@ -320,2 +320,5 @@ status: import_zod3.z.literal("success"),

]);
}
async fetch() {
const resultSchema = this._getResultSchema();
const result = await this._fetch();

@@ -333,4 +336,45 @@ let data = {};

}
return res.parse(data);
return resultSchema.parse(data);
}
async paginate() {
if (!this._params.browseParams?.page) {
this._params.browseParams = {
...this._params.browseParams,
page: 1
};
this._buildUrlParams();
}
const resultSchema = this._getResultSchema();
const result = await this._fetch();
let data = {};
if (result.errors) {
data.status = "error";
data.errors = result.errors;
} else {
data = {
status: "success",
meta: result.meta,
data: result[this._endpoint]
};
}
const response = {
current: resultSchema.parse(data),
next: void 0
};
if (response.current.status === "error")
return response;
const { meta } = response.current;
if (meta.pagination.pages <= 1 || meta.pagination.page === meta.pagination.pages)
return response;
const params = {
...this._params,
browseParams: {
...this._params.browseParams,
page: meta.pagination.page + 1
}
};
const next = new BrowseFetcher(this.config, params, this._api);
response.next = next;
return response;
}
async _fetch() {

@@ -337,0 +381,0 @@ if (this._URL === void 0)

@@ -83,2 +83,3 @@ import { z, ZodRawShape } from 'zod';

}>;
type GhostMeta = z.infer<typeof ghostMetaSchema>;
declare const ghostExcerptSchema: z.ZodObject<{

@@ -346,2 +347,3 @@ excerpt: z.ZodOptional<z.ZodString>;

private _urlBrowseParams;
private _getResultSchema;
fetch(): Promise<{

@@ -367,2 +369,25 @@ status: "success";

}>;
paginate(): Promise<{
current: {
status: "success";
data: (z.baseObjectOutputType<OutputShape> extends infer T extends object ? { [k in keyof T]: z.baseObjectOutputType<OutputShape>[k]; } : never)[];
meta: {
pagination: {
pages: number;
page: number;
limit: number;
total: number;
prev: number | null;
next: number | null;
};
};
} | {
status: "error";
errors: {
message: string;
type: string;
}[];
};
next: BrowseFetcher<Params, Fields, BaseShape, OutputShape, IncludeShape, Api> | undefined;
}>;
_fetch(): Promise<any>;

@@ -421,2 +446,12 @@ }

/**
* QueryBuilder class
* @param {ZodRawShape} Shape
* @param {ZodRawShape} OutputShape
* @param {ZodRawShape} IncludeShape
* @param {ContentAPICredentials} Api
*
* @returns {QueryBuilder} QueryBuilder
*
*/
declare class QueryBuilder<Shape extends ZodRawShape, OutputShape extends ZodRawShape, IncludeShape extends ZodRawShape, Api extends ContentAPICredentials> {

@@ -505,2 +540,2 @@ protected config: {

export { BasicFetcher, BrowseFetcher, BrowseFilter, BrowseOrder, BrowseParams, BrowseParamsSchema, ContentAPICredentials, ContentAPIEndpoints, ContentAPIVersions, FilterQueryOperators, FilterQuerySeparator, GhostIdentity, GhostIdentityInput, OrderPredicate, QueryBuilder, ReadFetcher, apiVersionsSchema, browseParamsSchema, contentAPICredentialsSchema, contentAPIEndpointsSchema, ghostCodeInjectionSchema, ghostExcerptSchema, ghostFacebookSchema, ghostIdentityInputSchema, ghostIdentitySchema, ghostMetaSchema, ghostMetadataSchema, ghostSocialMediaSchema, ghostTwitterSchema, ghostVisibilitySchema, parseBrowseParams, queryIdentitySchema, schemaWithPickedFields };
export { BasicFetcher, BrowseFetcher, BrowseFilter, BrowseOrder, BrowseParams, BrowseParamsSchema, ContentAPICredentials, ContentAPIEndpoints, ContentAPIVersions, FilterQueryOperators, FilterQuerySeparator, GhostIdentity, GhostIdentityInput, GhostMeta, OrderPredicate, QueryBuilder, ReadFetcher, apiVersionsSchema, browseParamsSchema, contentAPICredentialsSchema, contentAPIEndpointsSchema, ghostCodeInjectionSchema, ghostExcerptSchema, ghostFacebookSchema, ghostIdentityInputSchema, ghostIdentitySchema, ghostMetaSchema, ghostMetadataSchema, ghostSocialMediaSchema, ghostTwitterSchema, ghostVisibilitySchema, parseBrowseParams, queryIdentitySchema, schemaWithPickedFields };

@@ -302,4 +302,4 @@ "use strict";

}
async fetch() {
const res = import_zod3.z.discriminatedUnion("status", [
_getResultSchema() {
return import_zod3.z.discriminatedUnion("status", [
import_zod3.z.object({

@@ -320,2 +320,5 @@ status: import_zod3.z.literal("success"),

]);
}
async fetch() {
const resultSchema = this._getResultSchema();
const result = await this._fetch();

@@ -333,4 +336,45 @@ let data = {};

}
return res.parse(data);
return resultSchema.parse(data);
}
async paginate() {
if (!this._params.browseParams?.page) {
this._params.browseParams = {
...this._params.browseParams,
page: 1
};
this._buildUrlParams();
}
const resultSchema = this._getResultSchema();
const result = await this._fetch();
let data = {};
if (result.errors) {
data.status = "error";
data.errors = result.errors;
} else {
data = {
status: "success",
meta: result.meta,
data: result[this._endpoint]
};
}
const response = {
current: resultSchema.parse(data),
next: void 0
};
if (response.current.status === "error")
return response;
const { meta } = response.current;
if (meta.pagination.pages <= 1 || meta.pagination.page === meta.pagination.pages)
return response;
const params = {
...this._params,
browseParams: {
...this._params.browseParams,
page: meta.pagination.page + 1
}
};
const next = new BrowseFetcher(this.config, params, this._api);
response.next = next;
return response;
}
async _fetch() {

@@ -337,0 +381,0 @@ if (this._URL === void 0)

2

package.json

@@ -12,3 +12,3 @@ {

},
"version": "0.0.6",
"version": "0.0.7",
"main": "./dist/index.js",

@@ -15,0 +15,0 @@ "module": "./dist/index.mjs",

@@ -18,3 +18,3 @@ <br/>

![License](https://img.shields.io/github/license/PhilDL/ts-ghost) <img src="https://img.shields.io/badge/status-beta-orange.svg" alt="Status: Beta" />
![License](https://img.shields.io/github/license/PhilDL/ts-ghost) <img src="https://img.shields.io/badge/status-beta-orange.svg" alt="Status: Beta" /> <img alt="GitHub package.json version (subfolder of monorepo)" src="https://img.shields.io/github/package-json/v/PhilDL/ts-ghost?filename=packages%2Fts-ghost-core-api%2Fpackage.json">

@@ -31,7 +31,12 @@ ## About The Project

## Basic Usage
## Query Builders
To do...
### Global instantiation
Dependeing on the Fetcher you want to use, the instantiation may be a bit different
### `BrowseQueryBuilder`
## Roadmap

@@ -38,0 +43,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

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