Socket
Socket
Sign inDemoInstall

@kodo-is/prismic

Package Overview
Dependencies
11
Maintainers
6
Versions
36
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 0.6.7 to 0.6.8

65

dist/fetch.js

@@ -78,5 +78,5 @@ "use strict";

return __awaiter(this, void 0, void 0, function () {
var isDev, GRAPHQL_API_URL_DEV, GRAPHQL_API_URL, PrismicClient, devUrl, url, prismicRef, res, json_1, json, err_1;
return __generator(this, function (_f) {
switch (_f.label) {
var isDev, GRAPHQL_API_URL_DEV, GRAPHQL_API_URL, PrismicClient, devUrl, url, prismicRef, releaseDetails, _f, error_1, res, json_1, json, err_1;
return __generator(this, function (_g) {
switch (_g.label) {
case 0:

@@ -91,22 +91,43 @@ isDev = process.env.NODE_ENV === 'development';

url = apiUrl(GRAPHQL_API_URL, query, variables);
_f.label = 1;
_g.label = 1;
case 1:
_f.trys.push([1, 7, , 8]);
_g.trys.push([1, 13, , 14]);
return [4 /*yield*/, PrismicClient.getMasterRef()];
case 2:
prismicRef = _f.sent();
return [4 /*yield*/, fetch(isDev ? devUrl : url, {
headers: __assign(__assign({ 'Prismic-Ref': (previewData === null || previewData === void 0 ? void 0 : previewData.ref) || prismicRef.ref, 'Content-Type': 'application/json' }, (config.release && { 'Prismic-ref': config.release })), (config.accessToken && { Authorization: "Token " + config.accessToken })),
})];
prismicRef = _g.sent();
if (config.release && !config.accessToken) {
throw new Error("[PRISMIC CLIENT ERROR] You need to provide an \"accessToken\" to use a release\nCreate or copy from: https://" + config.repo + ".prismic.io/settings/apps/\n");
}
releaseDetails = null;
_g.label = 3;
case 3:
res = _f.sent();
if (!(res.status !== 200)) return [3 /*break*/, 5];
_g.trys.push([3, 7, , 8]);
if (!config.release) return [3 /*break*/, 5];
return [4 /*yield*/, PrismicClient.getReleaseByID(config.release)];
case 4:
_f = _g.sent();
return [3 /*break*/, 6];
case 5:
_f = null;
_g.label = 6;
case 6:
releaseDetails = _f;
return [3 /*break*/, 8];
case 7:
error_1 = _g.sent();
throw new Error("[PRISMIC CLIENT ERROR] Couldn't find a release ref. Make sure the accessToken has access to master+releases: https://" + config.repo + ".prismic.io/settings/apps/\n");
case 8: return [4 /*yield*/, fetch(isDev ? devUrl : url, {
headers: __assign(__assign({ 'Prismic-Ref': (previewData === null || previewData === void 0 ? void 0 : previewData.ref) || prismicRef.ref, 'Content-Type': 'application/json' }, (releaseDetails && { 'Prismic-ref': releaseDetails.ref })), (config.accessToken && { Authorization: "Token " + config.accessToken })),
})];
case 9:
res = _g.sent();
if (!(res.status !== 200)) return [3 /*break*/, 11];
return [4 /*yield*/, res.json()];
case 4:
json_1 = _f.sent();
case 10:
json_1 = _g.sent();
(_b = json_1.errors) === null || _b === void 0 ? void 0 : _b.map(function (error) { return console.error(error.message); });
throw new Error('Failed to fetch API');
case 5: return [4 /*yield*/, res.json()];
case 6:
json = _f.sent();
case 11: return [4 /*yield*/, res.json()];
case 12:
json = _g.sent();
if (json.errors) {

@@ -121,9 +142,11 @@ (_c = json.errors) === null || _c === void 0 ? void 0 : _c.map(function (error) { return console.error(error.message); });

return [2 /*return*/, json.data];
case 7:
err_1 = _f.sent();
case 13:
err_1 = _g.sent();
console.error(err_1.message);
console.log(query);
console.log('\n[DEBUG] GraphiQL:', devUrl, '\n');
if (!err_1.message.includes('[PRISMIC CLIENT ERROR]')) {
console.log(query);
console.log('\n[DEBUG] GraphiQL:', devUrl, '\n');
}
return [2 /*return*/, null];
case 8: return [2 /*return*/];
case 14: return [2 /*return*/];
}

@@ -130,0 +153,0 @@ });

@@ -98,3 +98,4 @@ "use strict";

var parseSlices = function (_a) {
var id = _a.id, tabs = _a.tabs, data = _a.data, userData = _a.userData, resolver = _a.resolver, serializer = _a.serializer, redirects = _a.redirects;
var id = _a.id, tabs = _a.tabs, data = _a.data, userData = _a.userData, resolver = _a.resolver, serializer = _a.serializer, // TODO: don't remember why I was passing the serializer here
redirects = _a.redirects;
return __awaiter(void 0, void 0, void 0, function () {

@@ -101,0 +102,0 @@ var final;

{
"name": "@kodo-is/prismic",
"description": "Prismic helper for Next.js",
"version": "0.6.7",
"version": "0.6.8",
"main": "index.js",

@@ -6,0 +6,0 @@ "author": "Finnur Sigurðsson <finnur@kodo.is>",

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc