Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
*.DS_Store
examples/*
node_modules/*
**/node_modules/*
.idea/*
reports/*
apidocs-templates/*
Expand All @@ -10,4 +9,5 @@ test/sync_config.js/*
test/report.json/*
tap-html.html
*html-report
coverage
coverage
.env
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
## Change log
### Version: 3.14.0
#### Date: Oct-19-2021
##### New Features:
- Live preview feature support added

### Version: 3.13.2
#### Date: May-26-2021
Expand Down
365 changes: 127 additions & 238 deletions dist/nativescript/contentstack.js

Large diffs are not rendered by default.

488 changes: 249 additions & 239 deletions dist/node/contentstack.js

Large diffs are not rendered by default.

365 changes: 127 additions & 238 deletions dist/react-native/contentstack.js

Large diffs are not rendered by default.

390 changes: 368 additions & 22 deletions dist/web/contentstack.js

Large diffs are not rendered by default.

59 changes: 59 additions & 0 deletions examples/PromiseError/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
require('dotenv').config()

const Contentstack = require('../../dist/node/contentstack');
const { RequestInterceptor } = require('node-request-interceptor');
const { default: withDefaultInterceptors } = require('node-request-interceptor/lib/presets/default');

const interceptor = new RequestInterceptor(withDefaultInterceptors)

// Log any outgoing requests to contentstack and return a mock HTML response
// which will cause the SDK to throw an unhandled exception
interceptor.use((req) => {

console.log('%s %s', req.method, req.url.href);

return {
status: 400,
headers: {
'x-powered-by': 'node-request-interceptor',
'content-type': 'text/html'
},
body: `
<html>
<head></head>
<body>
<h1>Nodata</h1>
</body>
</html>
`,
}
});

const Stack = Contentstack.Stack(
process.env.CONTENTSTACK_API_KEY,
process.env.CONTENTSTACK_DELIVERY_TOKEN,
process.env.CONTENTSTACK_ENVIRONMENT,
{ timeout: 5000,
retryCondition: () => true
});

Stack.setHost('dev15-api.contentstack.com');

const Query = Stack
.ContentType(process.env.CONTENTSTACK_CONTENT_TYPE)
.Query({})
.language("en-us")
.includeCount();

// Executing this async invocation cause an unhandled promise rejection
Query
.toJSON()
.find()
.then((res) => {
const [,count] = res;
console.log(`${count} total blogs.`);
})
.catch((err) => {
// Error is not caught
console.error('ERRR Catch', err);
});
75 changes: 75 additions & 0 deletions examples/PromiseError/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

11 changes: 3 additions & 8 deletions examples/node/contentstack-demo.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,7 @@ const Contentstack = require('../../dist/node/contentstack.js');
class ContentstackDemo {
constructor(...config) {
config = config || { 'api_key': 'blt123something', 'delivery_token': 'blt123something', 'environment': 'development', }
// Initialize the Contentstackstack
//console.log("datattatata", Contentstack.Region.EUROPE)


this.Stack = Contentstack.Stack(...config);
}

Expand Down Expand Up @@ -51,7 +49,6 @@ class ContentstackDemo {
getContentTypedemo() {
contentTypeUid = contentTypeUid || 'source'
return this.Stack.ContentType(contentTypeUid).fetch()
// return this.Stack.ContentType('event_list').Entry('blt5d40c608567844d4').toJSON().fetch()
}

/**
Expand All @@ -61,10 +58,8 @@ class ContentstackDemo {
* @return : Result {Promise}
*/
getContentType(uid) {
//contentTypeUid = contentTypeUid || 'source'
// return this.Stack.getContentType(uid)
// return this.Stack.ContentType(uid).Entry("blta07130f8b344b260").includeReferenceContentTypeUID().includeSchema().toJSON().fetch()
//return this.Stack.getContentTypes({"include_global_field_schema": true})
contentTypeUid = contentTypeUid || 'source'
return this.Stack.getContentType(uid)
}

/**
Expand Down
18 changes: 15 additions & 3 deletions index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -61,14 +61,25 @@ export interface StackConfig {

// ContentTypeCollection
export interface ContentTypeCollection{
contentTypes: Array<any>
content_types: Array<any>
count?: number
}

export interface LivePreview {
host: string
authorization: string
enable: boolean
}

export interface LivePreviewQuery {
hash: string
content_type_uid: string
}

// Stack
export class Stack {
constructor(config: Config);
constructor(api_key: string, delivery_token: string, environment_name: string, region?: Region, fetchOptions?: any);
constructor(api_key: string, delivery_token: string, environment_name: string, region?: Region, fetchOptions?: any, live_preview?: LivePreview);

environment: string;
cachePolicy: CachePolicy;
Expand All @@ -84,6 +95,7 @@ export class Stack {
setHost(host: string): Stack;
setCachePolicy(policy: CachePolicy): Stack;
setCacheProvider(provider: object): Stack;
livePreviewQuery(query: LivePreviewQuery): void;
clearByQuery(): Stack;
clearByContentType(): Stack;
clearAll(): Stack;
Expand Down Expand Up @@ -219,4 +231,4 @@ export class Query extends Entry {

find(fetchOptions?: object): Promise<any>;
findOne(): Promise<any>;
}
}
Loading