@builder.io/sdk
Advanced tools
Comparing version 0.0.16 to 0.0.17
@@ -0,1 +1,2 @@ | ||
import { Observable } from 'rxjs/Observable'; | ||
import { Observer } from 'rxjs/Observer'; | ||
@@ -39,4 +40,4 @@ export interface ParamsMap { | ||
getUserAttributes(userAgent?: string): UserAttributes; | ||
getContent(modelName: string, options?: GetContentOptions): any; | ||
getContent(modelName: string, options?: GetContentOptions): Observable<any[]>; | ||
} | ||
export declare const builder: Builder; |
26
index.js
@@ -1,7 +0,9 @@ | ||
import { sortBy } from 'lodash'; | ||
import * as queryString from 'query-string'; | ||
import * as parser from 'ua-parser-js'; | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
var lodash_1 = require("lodash"); | ||
var queryString = require("query-string"); | ||
var parser = require("ua-parser-js"); | ||
// import { ContentModelType } from '../../app/models/content.model'; | ||
import { Observable } from 'rxjs/Observable'; | ||
import stringify from 'json-stable-stringify'; | ||
var Observable_1 = require("rxjs/Observable"); | ||
var json_stable_stringify_1 = require("json-stable-stringify"); | ||
var anyParser = parser; | ||
@@ -16,3 +18,3 @@ // Workaround for oddly random module loading issues | ||
var contentData = data.data.data; // hmmm... | ||
var observer = builder.observersByModelType[model]; | ||
var observer = exports.builder.observersByModelType[model]; | ||
if (observer) { | ||
@@ -57,3 +59,3 @@ observer.next([contentData]); | ||
// TODO: merge in the attribute from query string ones | ||
queryParams.userAttributes = stringify(this.getUserAttributes()); | ||
queryParams.userAttributes = json_stable_stringify_1.default(this.getUserAttributes()); | ||
// TODO: cachebust if bd.noCache in request, also perhaps if in iframe | ||
@@ -73,3 +75,3 @@ if (options.cachebust) { | ||
var host = options.dev ? 'http://localhost:5000' : 'https://builder.io'; | ||
return new Observable(function (observer) { | ||
return new Observable_1.Observable(function (observer) { | ||
// TODO: will there by use cases of multiple separate requests for same model type? | ||
@@ -80,3 +82,3 @@ _this.observersByModelType[modelName] = observer; | ||
.then(function (res) { return res.json(); }) | ||
.then(function (list) { return sortBy(list, function (item) { return item.priority; }); }) | ||
.then(function (list) { return lodash_1.sortBy(list, function (item) { return item.priority; }); }) | ||
.then(function (result) { | ||
@@ -92,6 +94,6 @@ observer.next(result); | ||
}()); | ||
export { Builder }; | ||
export var builder = new Builder(); | ||
exports.Builder = Builder; | ||
exports.builder = new Builder(); | ||
// FIXME: remove | ||
// TODO: UMD with window | ||
window.builder = builder; | ||
window.builder = exports.builder; |
{ | ||
"name": "@builder.io/sdk", | ||
"version": "0.0.16", | ||
"version": "0.0.17", | ||
"main": "./index.js", | ||
@@ -5,0 +5,0 @@ "types": "./index.d.ts", |
{ | ||
"compilerOptions": { | ||
"target": "es5", | ||
"module": "es6", | ||
"module": "commonjs", | ||
"strict": true, | ||
"declaration": true, | ||
"lib": ["dom", "es6"], | ||
"typeRoots": ["@types./node_modules/@types"], | ||
"typeRoots": ["./node_modules/@types"], | ||
"allowSyntheticDefaultImports": true | ||
@@ -10,0 +10,0 @@ }, |
8822
148