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

@dotcms/client

Package Overview
Dependencies
Maintainers
1
Versions
65
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@dotcms/client - npm Package Compare versions

Comparing version 0.0.1-alpha.18 to 0.0.1-alpha.19

src/lib/client/content/builders/collection/collection.d.ts

2

package.json
{
"name": "@dotcms/client",
"version": "0.0.1-alpha.18",
"version": "0.0.1-alpha.19",
"type": "module",

@@ -5,0 +5,0 @@ "description": "Official JavaScript library for interacting with DotCMS REST APIs.",

@@ -6,1 +6,2 @@ export * from './lib/client/sdk-js-client';

export * from './lib/query-builder/sdk-query-builder';
export * from './lib/utils';

@@ -6,2 +6,3 @@ export * from './lib/client/sdk-js-client';

export * from './lib/query-builder/sdk-query-builder';
export * from './lib/utils';
//# sourceMappingURL=index.js.map

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

import { GetCollection } from './methods/get-collection/get-collection';
import { CollectionBuilder } from './builders/collection/collection';
import { ClientOptions } from '../sdk-js-client';

@@ -10,13 +10,70 @@ /**

export declare class Content {
private requestOptions;
private serverUrl;
#private;
constructor(requestOptions: ClientOptions, serverUrl: string);
/**
* Allows you to build a query to get a collection of an specified content type
* Takes a content type and returns a builder to filter and fetch the collection
*
* @param {string} contentType
* @return {*}
* @example
* ```javascript
* // Using await and async
* const collectionResponse = await client.content
* .getCollection('Blog')
* .limit(10)
* .page(2)
* .sortBy([{ field: 'title', order: 'asc' }])
* .query((queryBuilder) => queryBuilder.field('author').equals('John Doe'))
* .depth(1);
* ```
* @example
* ```javascript
* // Using then and catch
* client.content
* .getCollection('Blog')
* .limit(10)
* .page(2)
* .sortBy([{ field: 'title', order: 'asc' }])
* .query((queryBuilder) => queryBuilder.field('author').equals('John Doe'))
* .depth(1)
* .then((response) => {
* console.log(response.contentlets);
* })
* .catch((error) => {
* console.error(error);
* });
* ```
* @example
* ```typescript
* // Using an specific type for your content
*
* type Blog = {
* summary: string;
* author: string;
* title: string;
* };
*
* client.content
* .getCollection<Blog>('Blog')
* .limit(10)
* .page(2)
* .sortBy([{ field: 'title', order: 'asc' }])
* .query((queryBuilder) => queryBuilder.field('author').equals('John Doe'))
* .depth(1)
* .then((response) => {
* response.contentlets.forEach((blog) => {
* console.log(blog.title);
* console.log(blog.author);
* console.log(blog.summary);
* });
* })
* .catch((error) => {
* console.error(error);
* });
* ```
*
* @param {string} contentType The content type to get the collection
* @return {CollectionBuilder} CollectionBuilder to filter and fetch the collection
* @template T Represents the type of the content type to fetch. Defaults to unknown
* @memberof Content
*/
getCollection(contentType: string): GetCollection;
getCollection<T = unknown>(contentType: string): CollectionBuilder<T>;
}

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

import { GetCollection } from './methods/get-collection/get-collection';
var _Content_requestOptions, _Content_serverUrl;
import { __classPrivateFieldGet, __classPrivateFieldSet } from "tslib";
import { CollectionBuilder } from './builders/collection/collection';
/**

@@ -10,16 +12,77 @@ * Content classs exposes the content api methods

constructor(requestOptions, serverUrl) {
this.requestOptions = requestOptions;
this.serverUrl = serverUrl;
_Content_requestOptions.set(this, void 0);
_Content_serverUrl.set(this, void 0);
__classPrivateFieldSet(this, _Content_requestOptions, requestOptions, "f");
__classPrivateFieldSet(this, _Content_serverUrl, serverUrl, "f");
}
/**
* Allows you to build a query to get a collection of an specified content type
* Takes a content type and returns a builder to filter and fetch the collection
*
* @param {string} contentType
* @return {*}
* @example
* ```javascript
* // Using await and async
* const collectionResponse = await client.content
* .getCollection('Blog')
* .limit(10)
* .page(2)
* .sortBy([{ field: 'title', order: 'asc' }])
* .query((queryBuilder) => queryBuilder.field('author').equals('John Doe'))
* .depth(1);
* ```
* @example
* ```javascript
* // Using then and catch
* client.content
* .getCollection('Blog')
* .limit(10)
* .page(2)
* .sortBy([{ field: 'title', order: 'asc' }])
* .query((queryBuilder) => queryBuilder.field('author').equals('John Doe'))
* .depth(1)
* .then((response) => {
* console.log(response.contentlets);
* })
* .catch((error) => {
* console.error(error);
* });
* ```
* @example
* ```typescript
* // Using an specific type for your content
*
* type Blog = {
* summary: string;
* author: string;
* title: string;
* };
*
* client.content
* .getCollection<Blog>('Blog')
* .limit(10)
* .page(2)
* .sortBy([{ field: 'title', order: 'asc' }])
* .query((queryBuilder) => queryBuilder.field('author').equals('John Doe'))
* .depth(1)
* .then((response) => {
* response.contentlets.forEach((blog) => {
* console.log(blog.title);
* console.log(blog.author);
* console.log(blog.summary);
* });
* })
* .catch((error) => {
* console.error(error);
* });
* ```
*
* @param {string} contentType The content type to get the collection
* @return {CollectionBuilder} CollectionBuilder to filter and fetch the collection
* @template T Represents the type of the content type to fetch. Defaults to unknown
* @memberof Content
*/
getCollection(contentType) {
return new GetCollection(this.requestOptions, this.serverUrl, contentType);
return new CollectionBuilder(__classPrivateFieldGet(this, _Content_requestOptions, "f"), __classPrivateFieldGet(this, _Content_serverUrl, "f"), contentType);
}
}
_Content_requestOptions = new WeakMap(), _Content_serverUrl = new WeakMap();
//# sourceMappingURL=content-api.js.map

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

import { Equals } from '../../../query-builder/lucene-syntax/Equals';
import { Equals } from '../../../query-builder/lucene-syntax';
import { QueryBuilder } from '../../../query-builder/sdk-query-builder';
export type SortBy = {

@@ -6,3 +7,3 @@ field: string;

};
export type QueryBuilderCallback = (qb: Equals) => Equals;
export type BuildQuery = (qb: QueryBuilder) => Equals;
export interface ContentTypeMainFields {

@@ -42,2 +43,4 @@ hostName: string;

export type Contentlet<T> = T & ContentTypeMainFields;
export type OnFullfilled<T> = ((value: GetCollectionResponse<T>) => GetCollectionResponse<T> | PromiseLike<GetCollectionResponse<T>> | void) | undefined | null;
export type OnRejected = ((error: GetCollectionError) => GetCollectionError | PromiseLike<GetCollectionError> | void) | undefined | null;
export interface GetCollectionResponse<T> {

@@ -50,1 +53,13 @@ contentlets: Contentlet<T>[];

}
export interface GetCollectionRawResponse<T> {
entity: {
jsonObjectView: {
contentlets: Contentlet<T>[];
};
resultsSize: number;
};
}
export interface GetCollectionError {
status: number;
[key: string]: unknown;
}

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