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

@builder.io/sdk

Package Overview
Dependencies
Maintainers
0
Versions
695
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@builder.io/sdk - npm Package Compare versions

Comparing version 3.0.7 to 4.0.0

10

CHANGELOG.md
# @builder.io/sdk
## 4.0.0
### Major Changes
- f4fffe9: Permanently removes the `apiEndpoint` prop from `builder.get()` and `builder.getAll()` which had options `'content'` and `'query'`. Content API is now the only possible API endpoint for content fetching.
### Patch Changes
- 443a3e3: Types: add jsdoc comments for some Builder SDK types
## 3.0.7

@@ -4,0 +14,0 @@

2

dist/package.json
{
"name": "@builder.io/sdk",
"version": "3.0.7",
"version": "4.0.0",
"unpkg": "./dist/index.browser.js",

@@ -5,0 +5,0 @@ "main": "./dist/index.cjs.js",

@@ -119,7 +119,2 @@ /// <reference types="node" />

/**
* Dictates which API endpoint is used when fetching content. Allows `'content'` and `'query'`.
* Defaults to `'query'`.
*/
apiEndpoint?: 'content' | 'query';
/**
* Optional fetch options to be passed as the second argument to the `fetch` function.

@@ -126,0 +121,0 @@ */

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

}); });
test("hits query url when apiEndpoint is undefined and format is 'html'", function () { return __awaiter(void 0, void 0, void 0, function () {
test("hits content url when format is 'html'", function () { return __awaiter(void 0, void 0, void 0, function () {
var expectedFormat, result, observerNextMock;

@@ -539,31 +539,2 @@ var _a;

fields: 'data',
},
])];
case 1:
result = _b.sent();
observerNextMock = (_a = builder.observersByKey[MODEL]) === null || _a === void 0 ? void 0 : _a.next;
expect(observerNextMock).toBeCalledTimes(1);
expect(observerNextMock.mock.calls[0][0][0]).toStrictEqual(__assign(__assign({}, codegenOrQueryApiResult[MODEL][0]), { variationId: expect.any(String) }));
expect(builder['makeFetchApiCall']).toBeCalledTimes(1);
expect(builder['makeFetchApiCall']).toBeCalledWith("https://cdn.builder.io/api/v3/query/".concat(API_KEY, "/").concat(MODEL, "?omit=").concat(OMIT, "&apiKey=").concat(API_KEY, "&fields=data&format=").concat(expectedFormat, "&userAttributes=%7B%22respectScheduling%22%3Atrue%7D&options.").concat(MODEL, ".model=%22").concat(MODEL, "%22"), { headers: { Authorization: "Bearer ".concat(AUTH_TOKEN) } });
return [2 /*return*/];
}
});
}); });
test("hits content url when apiEndpoint is 'content' and format is 'html'", function () { return __awaiter(void 0, void 0, void 0, function () {
var expectedFormat, result, observerNextMock;
var _a;
return __generator(this, function (_b) {
switch (_b.label) {
case 0:
expectedFormat = 'html';
return [4 /*yield*/, builder['flushGetContentQueue'](true, [
{
apiEndpoint: 'content',
model: MODEL,
format: expectedFormat,
key: MODEL,
userAttributes: { respectScheduling: true },
omit: OMIT,
fields: 'data',
limit: 10,

@@ -585,3 +556,3 @@ },

}); });
test("hits query url when apiEndpoint is undefined and format is 'amp'", function () { return __awaiter(void 0, void 0, void 0, function () {
test("hits content url when format is 'amp'", function () { return __awaiter(void 0, void 0, void 0, function () {
var expectedFormat, result, observerNextMock;

@@ -601,31 +572,2 @@ var _a;

fields: 'data',
},
])];
case 1:
result = _b.sent();
observerNextMock = (_a = builder.observersByKey[MODEL]) === null || _a === void 0 ? void 0 : _a.next;
expect(observerNextMock).toBeCalledTimes(1);
expect(observerNextMock.mock.calls[0][0][0]).toStrictEqual(__assign(__assign({}, codegenOrQueryApiResult[MODEL][0]), { variationId: expect.any(String) }));
expect(builder['makeFetchApiCall']).toBeCalledTimes(1);
expect(builder['makeFetchApiCall']).toBeCalledWith("https://cdn.builder.io/api/v3/query/".concat(API_KEY, "/").concat(MODEL, "?omit=").concat(OMIT, "&apiKey=").concat(API_KEY, "&fields=data&format=").concat(expectedFormat, "&userAttributes=%7B%22respectScheduling%22%3Atrue%7D&options.").concat(MODEL, ".model=%22").concat(MODEL, "%22"), { headers: { Authorization: "Bearer ".concat(AUTH_TOKEN) } });
return [2 /*return*/];
}
});
}); });
test("hits content url when apiEndpoint is 'content' and format is 'amp'", function () { return __awaiter(void 0, void 0, void 0, function () {
var expectedFormat, result, observerNextMock;
var _a;
return __generator(this, function (_b) {
switch (_b.label) {
case 0:
expectedFormat = 'amp';
return [4 /*yield*/, builder['flushGetContentQueue'](true, [
{
apiEndpoint: 'content',
model: MODEL,
format: expectedFormat,
key: MODEL,
userAttributes: { respectScheduling: true },
omit: OMIT,
fields: 'data',
limit: 10,

@@ -647,3 +589,3 @@ },

}); });
test("hits query url when apiEndpoint is undefined and format is 'email'", function () { return __awaiter(void 0, void 0, void 0, function () {
test("hits content url when format is 'email'", function () { return __awaiter(void 0, void 0, void 0, function () {
var expectedFormat, result, observerNextMock;

@@ -663,59 +605,2 @@ var _a;

fields: 'data',
},
])];
case 1:
result = _b.sent();
observerNextMock = (_a = builder.observersByKey[MODEL]) === null || _a === void 0 ? void 0 : _a.next;
expect(observerNextMock).toBeCalledTimes(1);
expect(observerNextMock.mock.calls[0][0][0]).toStrictEqual(__assign(__assign({}, codegenOrQueryApiResult[MODEL][0]), { variationId: expect.any(String) }));
expect(builder['makeFetchApiCall']).toBeCalledTimes(1);
expect(builder['makeFetchApiCall']).toBeCalledWith("https://cdn.builder.io/api/v3/query/".concat(API_KEY, "/").concat(MODEL, "?omit=").concat(OMIT, "&apiKey=").concat(API_KEY, "&fields=data&format=").concat(expectedFormat, "&userAttributes=%7B%22respectScheduling%22%3Atrue%7D&options.").concat(MODEL, ".model=%22").concat(MODEL, "%22"), { headers: { Authorization: "Bearer ".concat(AUTH_TOKEN) } });
return [2 /*return*/];
}
});
}); });
test("hits query url when apiEndpoint is undefined and format is 'email' and url is passed instead of userAttributes", function () { return __awaiter(void 0, void 0, void 0, function () {
var expectedFormat, result, observerNextMock;
var _a;
return __generator(this, function (_b) {
switch (_b.label) {
case 0:
expectedFormat = 'email';
return [4 /*yield*/, builder['flushGetContentQueue'](true, [
{
model: MODEL,
format: expectedFormat,
key: MODEL,
url: '/test-page',
omit: OMIT,
fields: 'data',
},
])];
case 1:
result = _b.sent();
observerNextMock = (_a = builder.observersByKey[MODEL]) === null || _a === void 0 ? void 0 : _a.next;
expect(observerNextMock).toBeCalledTimes(1);
expect(observerNextMock.mock.calls[0][0][0]).toStrictEqual(__assign(__assign({}, codegenOrQueryApiResult[MODEL][0]), { variationId: expect.any(String) }));
expect(builder['makeFetchApiCall']).toBeCalledTimes(1);
expect(builder['makeFetchApiCall']).toBeCalledWith("https://cdn.builder.io/api/v3/query/".concat(API_KEY, "/").concat(MODEL, "?omit=").concat(OMIT, "&apiKey=").concat(API_KEY, "&fields=data&format=").concat(expectedFormat, "&userAttributes=%7B%22urlPath%22%3A%22%2Ftest-page%22%2C%22host%22%3A%22localhost%22%2C%22device%22%3A%22desktop%22%7D&options.").concat(MODEL, ".model=%22").concat(MODEL, "%22"), { headers: { Authorization: "Bearer ".concat(AUTH_TOKEN) } });
return [2 /*return*/];
}
});
}); });
test("hits content url when apiEndpoint is 'content' and format is 'email'", function () { return __awaiter(void 0, void 0, void 0, function () {
var expectedFormat, result, observerNextMock;
var _a;
return __generator(this, function (_b) {
switch (_b.label) {
case 0:
expectedFormat = 'email';
return [4 /*yield*/, builder['flushGetContentQueue'](true, [
{
apiEndpoint: 'content',
model: MODEL,
format: expectedFormat,
key: MODEL,
userAttributes: { respectScheduling: true },
omit: OMIT,
fields: 'data',
limit: 10,

@@ -737,35 +622,3 @@ },

}); });
test("hits content url when apiEndpoint is 'content' and format is 'email' and url is passed instead of userAttributes", function () { return __awaiter(void 0, void 0, void 0, function () {
var expectedFormat, result, observerNextMock;
var _a;
return __generator(this, function (_b) {
switch (_b.label) {
case 0:
expectedFormat = 'email';
return [4 /*yield*/, builder['flushGetContentQueue'](true, [
{
apiEndpoint: 'content',
model: MODEL,
format: expectedFormat,
key: MODEL,
url: '/test-page',
omit: OMIT,
fields: 'data',
limit: 10,
},
])];
case 1:
result = _b.sent();
observerNextMock = (_a = builder.observersByKey[MODEL]) === null || _a === void 0 ? void 0 : _a.next;
expect(observerNextMock).toBeCalledTimes(1);
expect(observerNextMock.mock.calls[0][0][0]).toStrictEqual(__assign(__assign({}, contentApiResult.results[0]), { variationId: expect.any(String) }));
expect(observerNextMock.mock.calls[0][0][1]).toStrictEqual(__assign({}, contentApiResult.results[1]));
expect(observerNextMock.mock.calls[0][0][2]).toStrictEqual(__assign(__assign({}, contentApiResult.results[2]), { variationId: expect.any(String) }));
expect(builder['makeFetchApiCall']).toBeCalledTimes(1);
expect(builder['makeFetchApiCall']).toBeCalledWith("https://cdn.builder.io/api/v3/content/".concat(MODEL, "?omit=data.blocks&apiKey=").concat(API_KEY, "&fields=data&format=").concat(expectedFormat, "&userAttributes=%7B%22urlPath%22%3A%22%2Ftest-page%22%2C%22host%22%3A%22localhost%22%2C%22device%22%3A%22desktop%22%7D&limit=10&model=%22").concat(MODEL, "%22&enrich=true"), { headers: { Authorization: "Bearer ".concat(AUTH_TOKEN) } });
return [2 /*return*/];
}
});
}); });
});
//# sourceMappingURL=builder.class.test.js.map

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

export declare const SDK_VERSION = "3.0.7";
export declare const SDK_VERSION = "4.0.0";
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.SDK_VERSION = void 0;
exports.SDK_VERSION = '3.0.7';
exports.SDK_VERSION = '4.0.0';
//# sourceMappingURL=sdk-version.js.map

@@ -31,5 +31,21 @@ type JSONValue = string | number | boolean | JSONObject | JSONArray;

name: string;
/**
* el.component.options is a key-value record where the values are static, literal expressions.
* These may be set as a result of el.bindings being evaluated.
* These get passed as props to the underlying component, such as a React component.
*
* el.component.options["bar"] = "abc" --> <CustomReactComponent bar={"abc"} ...>
*/
options?: any;
tag?: string;
};
/**
* el.bindings is a key-value record where the values can be dynamic JS expressions.
* These may be set as a result of el.code.bindings being edited and then transpiled.
* After the expressions are evaluated, the key and result value get bound elsewhere
* according to this pattern:
*
* el.bindings["foo"] will be bound to el.properties["foo"]
* el.bindings["component.options.bar"] will be bound to el.component.options["bar"]
*/
bindings?: {

@@ -44,2 +60,9 @@ [key: string]: string;

};
/**
* el.properties is a key-value record where the values are static, literal expressions.
* These may be set as a result of el.bindings being evaluated.
* These get applied as attributes on the top-level HTML element inside this Element.
*
* el.properties["foo"] = "1" --> <htmlnode foo="1" ...>
*/
properties?: {

@@ -49,2 +72,8 @@ [key: string]: string;

code?: {
/**
* el.code.bindings is a key-value record where the values represent user-authored code
* written in Builder's Data view. The values can be literal or dynamic expressions,
* can use Types, and can even add complex logic like async/await. These values get transpiled
* and the results override the matching key-value pair in el.bindings.
*/
bindings?: {

@@ -51,0 +80,0 @@ [key: string]: string;

{
"name": "@builder.io/sdk",
"version": "3.0.7",
"version": "4.0.0",
"unpkg": "./dist/index.browser.js",

@@ -5,0 +5,0 @@ "main": "./dist/index.cjs.js",

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is too big to display

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