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
696
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 4.0.3 to 5.0.0-0

2

dist/package.json
{
"name": "@builder.io/sdk",
"version": "4.0.3",
"version": "5.0.0-0",
"unpkg": "./dist/index.browser.js",

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

@@ -119,2 +119,7 @@ /// <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.

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

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

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

@@ -543,2 +543,31 @@ 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,

@@ -560,3 +589,3 @@ },

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

@@ -576,2 +605,31 @@ 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,

@@ -593,3 +651,3 @@ },

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

@@ -609,2 +667,59 @@ 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,

@@ -626,3 +741,35 @@ },

}); });
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 = "4.0.3";
export declare const SDK_VERSION = "5.0.0-0";
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.SDK_VERSION = void 0;
exports.SDK_VERSION = '4.0.3';
exports.SDK_VERSION = '3.0.6';
//# sourceMappingURL=sdk-version.js.map
{
"name": "@builder.io/sdk",
"version": "4.0.3",
"version": "5.0.0-0",
"unpkg": "./dist/index.browser.js",

@@ -75,2 +75,2 @@ "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