Socket
Socket
Sign inDemoInstall

@last-rev/app-config

Package Overview
Dependencies
1
Maintainers
5
Versions
19
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 0.3.1 to 0.4.0

6

CHANGELOG.md
# @last-rev/app-config
## 0.4.0
### Minor Changes
- bc28135: separated out content and caching strategies in order to support no cache
## 0.3.1

@@ -4,0 +10,0 @@

3

dist/index.d.ts

@@ -28,3 +28,4 @@ /// <reference types="node" />

get cms(): "Contentful";
get strategy(): import("./types").LastRevStrategy;
get contentStrategy(): import("./types").ContentStrategy;
get cmsCacheStrategy(): import("./types").CmsCacheStrategy;
get fs(): {

@@ -31,0 +32,0 @@ contentDir: string;

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

import{__assign as e}from"tslib";import t from"lodash/merge";import i from"lodash/isNil";var n={cms:"Contentful",strategy:"fs",contentful:{env:"master",usePreview:!1},logLevel:"warn",graphql:{port:5e3,host:"localhost"},sites:[]},o=function(){function o(e){this.config=t({},n,e),this.validateCmsVars(),this.validateStrategy(),this.validatePaths()}return o.prototype.validateCmsVars=function(){var e,t,i;if("Contentful"!==this.config.cms)throw new Error("Invalid CMS: ".concat(this.config.cms));if(!(null===(e=this.config.contentful)||void 0===e?void 0:e.spaceId))throw new Error("Contentful CMS: contentful.spaceId is required.");if(!(null===(t=this.config.contentful)||void 0===t?void 0:t.contentDeliveryToken))throw new Error("Contentful CMS: contentful.contentDeliveryToken is required.");if(!(null===(i=this.config.contentful)||void 0===i?void 0:i.contentPreviewToken))throw new Error("Contentful CMS: contentful.contentPreviewToken is required.")},o.prototype.validateStrategy=function(){var e,t,i,n,o,r,s;if("fs"===this.config.strategy){if(!(null===(e=this.config.fs)||void 0===e?void 0:e.contentDir))throw new Error("FS strategy: fs.contentDir is required")}else if("redis"===this.config.strategy){if(!(null===(t=this.config.redis)||void 0===t?void 0:t.host))throw new Error("Redis strategy: redis.host is required");if(!(null===(i=this.config.redis)||void 0===i?void 0:i.port))throw new Error("Redis strategy: redis.port is required")}else{if("dynamodb"!==this.config.strategy)throw new Error("Invalid strategy: ".concat(this.config.strategy));if(!(null===(n=this.config.dynamodb)||void 0===n?void 0:n.region))throw new Error("DynamoDB strategy: dynamodb.region is required");if(!(null===(o=this.config.dynamodb)||void 0===o?void 0:o.accessKeyId))throw new Error("DynamoDB strategy: dynamodb.accessKeyId is required");if(!(null===(r=this.config.dynamodb)||void 0===r?void 0:r.secretAccessKey))throw new Error("DynamoDB strategy: dynamodb.secretAccessKey is required");if(!(null===(s=this.config.dynamodb)||void 0===s?void 0:s.tableName))throw new Error("DynamoDB strategy: dynamodb.tableName is required")}},o.prototype.validatePaths=function(){var e,t;if("v2"!==(null===(e=this.config.paths)||void 0===e?void 0:e.version)&&!1===(null===(t=this.config.paths)||void 0===t?void 0:t.generateFullPathTree))throw new Error("Invalid paths configuration: generateFullPathTree must be true when using paths v1")},o.prototype.clone=function(e){return new o(t({},this.config,e))},Object.defineProperty(o.prototype,"contentful",{get:function(){var e,t,i,n,o,r,s;return{spaceId:null===(e=this.config.contentful)||void 0===e?void 0:e.spaceId,contentDeliveryToken:null===(t=this.config.contentful)||void 0===t?void 0:t.contentDeliveryToken,contentPreviewToken:null===(i=this.config.contentful)||void 0===i?void 0:i.contentPreviewToken,env:null===(n=this.config.contentful)||void 0===n?void 0:n.env,usePreview:!!(null===(o=this.config.contentful)||void 0===o?void 0:o.usePreview),maxBatchSize:(null===(r=this.config.contentful)||void 0===r?void 0:r.maxBatchSize)||1e3,syncLimit:null===(s=this.config.contentful)||void 0===s?void 0:s.syncLimit}},enumerable:!1,configurable:!0}),Object.defineProperty(o.prototype,"algolia",{get:function(){var e,t,i,n;return{applicationId:null===(e=this.config.algolia)||void 0===e?void 0:e.applicationId,adminApiKey:null===(t=this.config.algolia)||void 0===t?void 0:t.adminApiKey,contentTypeIds:null===(i=this.config.algolia)||void 0===i?void 0:i.contentTypeIds,indexDraftContent:!!(null===(n=this.config.algolia)||void 0===n?void 0:n.indexDraftContent)}},enumerable:!1,configurable:!0}),Object.defineProperty(o.prototype,"logLevel",{get:function(){return this.config.logLevel||"warn"},enumerable:!1,configurable:!0}),Object.defineProperty(o.prototype,"cms",{get:function(){return this.config.cms},enumerable:!1,configurable:!0}),Object.defineProperty(o.prototype,"strategy",{get:function(){return this.config.strategy},enumerable:!1,configurable:!0}),Object.defineProperty(o.prototype,"fs",{get:function(){var e;return{contentDir:null===(e=this.config.fs)||void 0===e?void 0:e.contentDir}},enumerable:!1,configurable:!0}),Object.defineProperty(o.prototype,"redis",{get:function(){var t,i;return e(e({},this.config.redis),{maxBatchSize:(null===(t=this.config.redis)||void 0===t?void 0:t.maxBatchSize)||1e3,ttlSeconds:(null===(i=this.config.redis)||void 0===i?void 0:i.ttlSeconds)||2592e3})},enumerable:!1,configurable:!0}),Object.defineProperty(o.prototype,"dynamodb",{get:function(){var e,t,i,n;return{region:null===(e=this.config.dynamodb)||void 0===e?void 0:e.region,accessKeyId:null===(t=this.config.dynamodb)||void 0===t?void 0:t.accessKeyId,secretAccessKey:null===(i=this.config.dynamodb)||void 0===i?void 0:i.secretAccessKey,tableName:null===(n=this.config.dynamodb)||void 0===n?void 0:n.tableName}},enumerable:!1,configurable:!0}),Object.defineProperty(o.prototype,"extensions",{get:function(){return this.config.extensions||{typeDefs:"",resolvers:{},mappers:{},typeMappings:{},pathsConfigs:{}}},enumerable:!1,configurable:!0}),Object.defineProperty(o.prototype,"graphql",{get:function(){var e,t;return{port:null===(e=this.config.graphql)||void 0===e?void 0:e.port,host:null===(t=this.config.graphql)||void 0===t?void 0:t.host}},enumerable:!1,configurable:!0}),Object.defineProperty(o.prototype,"sites",{get:function(){return this.config.sites},enumerable:!1,configurable:!0}),Object.defineProperty(o.prototype,"paths",{get:function(){var e,t;return{version:(null===(e=this.config.paths)||void 0===e?void 0:e.version)||"v1",generateFullPathTree:(null===(t=this.config.paths)||void 0===t?void 0:t.generateFullPathTree)||!0}},enumerable:!1,configurable:!0}),Object.defineProperty(o.prototype,"skipReferenceFields",{get:function(){return!!i(this.config.skipReferenceFields)||this.config.skipReferenceFields},enumerable:!1,configurable:!0}),Object.defineProperty(o.prototype,"sitemapMaxPageSize",{get:function(){return this.config.sitemapMaxPageSize||1e3},enumerable:!1,configurable:!0}),o}();export{o as default};
import{__assign as e}from"tslib";import t from"lodash/merge";import i from"lodash/isNil";var o={cms:"Contentful",strategy:"fs",contentful:{env:"master",usePreview:!1},logLevel:"warn",graphql:{port:5e3,host:"localhost"},sites:[]},n=function(){function n(e){this.config=t({},o,e),this.validateCmsVars(),this.validateStrategy(),this.validatePaths()}return n.prototype.validateCmsVars=function(){var e,t,i;if("Contentful"!==this.config.cms)throw new Error("Invalid CMS: ".concat(this.config.cms));if(!(null===(e=this.config.contentful)||void 0===e?void 0:e.spaceId))throw new Error("Contentful CMS: contentful.spaceId is required.");if(!(null===(t=this.config.contentful)||void 0===t?void 0:t.contentDeliveryToken))throw new Error("Contentful CMS: contentful.contentDeliveryToken is required.");if(!(null===(i=this.config.contentful)||void 0===i?void 0:i.contentPreviewToken))throw new Error("Contentful CMS: contentful.contentPreviewToken is required.")},n.prototype.validateStrategy=function(){var e,t,i,o,n,r,s,c,a,d,l,f,g,u;if(this.config.contentStrategy)if("fs"===this.config.contentStrategy){if(!(null===(e=this.config.fs)||void 0===e?void 0:e.contentDir))throw new Error("FS strategy: fs.contentDir is required")}else{if("cms"!==this.config.contentStrategy)throw new Error("Invalid contentStrategy: ".concat(this.config.contentStrategy));if("redis"===this.config.cmsCacheStrategy){if(!(null===(t=this.config.redis)||void 0===t?void 0:t.host))throw new Error("Redis strategy: redis.host is required");if(!(null===(i=this.config.redis)||void 0===i?void 0:i.port))throw new Error("Redis strategy: redis.port is required")}else if("dynamodb"===this.config.cmsCacheStrategy){if(!(null===(o=this.config.dynamodb)||void 0===o?void 0:o.region))throw new Error("DynamoDB strategy: dynamodb.region is required");if(!(null===(n=this.config.dynamodb)||void 0===n?void 0:n.accessKeyId))throw new Error("DynamoDB strategy: dynamodb.accessKeyId is required");if(!(null===(r=this.config.dynamodb)||void 0===r?void 0:r.secretAccessKey))throw new Error("DynamoDB strategy: dynamodb.secretAccessKey is required");if(!(null===(s=this.config.dynamodb)||void 0===s?void 0:s.tableName))throw new Error("DynamoDB strategy: dynamodb.tableName is required")}}else{if(!this.config.strategy)throw new Error("Must specify a content stratgy");if("fs"===this.config.strategy){if(!(null===(c=this.config.fs)||void 0===c?void 0:c.contentDir))throw new Error("FS strategy: fs.contentDir is required")}else if("redis"===this.config.strategy){if(!(null===(a=this.config.redis)||void 0===a?void 0:a.host))throw new Error("Redis strategy: redis.host is required");if(!(null===(d=this.config.redis)||void 0===d?void 0:d.port))throw new Error("Redis strategy: redis.port is required")}else{if("dynamodb"!==this.config.strategy)throw new Error("Invalid strategy: ".concat(this.config.strategy));if(!(null===(l=this.config.dynamodb)||void 0===l?void 0:l.region))throw new Error("DynamoDB strategy: dynamodb.region is required");if(!(null===(f=this.config.dynamodb)||void 0===f?void 0:f.accessKeyId))throw new Error("DynamoDB strategy: dynamodb.accessKeyId is required");if(!(null===(g=this.config.dynamodb)||void 0===g?void 0:g.secretAccessKey))throw new Error("DynamoDB strategy: dynamodb.secretAccessKey is required");if(!(null===(u=this.config.dynamodb)||void 0===u?void 0:u.tableName))throw new Error("DynamoDB strategy: dynamodb.tableName is required")}}},n.prototype.validatePaths=function(){var e,t;if("v2"!==(null===(e=this.config.paths)||void 0===e?void 0:e.version)&&!1===(null===(t=this.config.paths)||void 0===t?void 0:t.generateFullPathTree))throw new Error("Invalid paths configuration: generateFullPathTree must be true when using paths v1")},n.prototype.clone=function(e){return new n(t({},this.config,e))},Object.defineProperty(n.prototype,"contentful",{get:function(){var e,t,i,o,n,r,s;return{spaceId:null===(e=this.config.contentful)||void 0===e?void 0:e.spaceId,contentDeliveryToken:null===(t=this.config.contentful)||void 0===t?void 0:t.contentDeliveryToken,contentPreviewToken:null===(i=this.config.contentful)||void 0===i?void 0:i.contentPreviewToken,env:null===(o=this.config.contentful)||void 0===o?void 0:o.env,usePreview:!!(null===(n=this.config.contentful)||void 0===n?void 0:n.usePreview),maxBatchSize:(null===(r=this.config.contentful)||void 0===r?void 0:r.maxBatchSize)||1e3,syncLimit:null===(s=this.config.contentful)||void 0===s?void 0:s.syncLimit}},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"algolia",{get:function(){var e,t,i,o;return{applicationId:null===(e=this.config.algolia)||void 0===e?void 0:e.applicationId,adminApiKey:null===(t=this.config.algolia)||void 0===t?void 0:t.adminApiKey,contentTypeIds:null===(i=this.config.algolia)||void 0===i?void 0:i.contentTypeIds,indexDraftContent:!!(null===(o=this.config.algolia)||void 0===o?void 0:o.indexDraftContent)}},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"logLevel",{get:function(){return this.config.logLevel||"warn"},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"cms",{get:function(){return this.config.cms},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"contentStrategy",{get:function(){return this.config.contentStrategy?this.config.contentStrategy:"fs"!==this.config.strategy?"cms":"fs"},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"cmsCacheStrategy",{get:function(){return this.config.cmsCacheStrategy?this.config.cmsCacheStrategy:"cms"===this.config.contentStrategy?"none":(this.config.strategy,this.config.strategy)},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"fs",{get:function(){var e;return{contentDir:null===(e=this.config.fs)||void 0===e?void 0:e.contentDir}},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"redis",{get:function(){var t,i;return e(e({},this.config.redis),{maxBatchSize:(null===(t=this.config.redis)||void 0===t?void 0:t.maxBatchSize)||1e3,ttlSeconds:(null===(i=this.config.redis)||void 0===i?void 0:i.ttlSeconds)||2592e3})},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"dynamodb",{get:function(){var e,t,i,o;return{region:null===(e=this.config.dynamodb)||void 0===e?void 0:e.region,accessKeyId:null===(t=this.config.dynamodb)||void 0===t?void 0:t.accessKeyId,secretAccessKey:null===(i=this.config.dynamodb)||void 0===i?void 0:i.secretAccessKey,tableName:null===(o=this.config.dynamodb)||void 0===o?void 0:o.tableName}},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"extensions",{get:function(){return this.config.extensions||{typeDefs:"",resolvers:{},mappers:{},typeMappings:{},pathsConfigs:{}}},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"graphql",{get:function(){var e,t;return{port:null===(e=this.config.graphql)||void 0===e?void 0:e.port,host:null===(t=this.config.graphql)||void 0===t?void 0:t.host}},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"sites",{get:function(){return this.config.sites},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"paths",{get:function(){var e,t;return{version:(null===(e=this.config.paths)||void 0===e?void 0:e.version)||"v1",generateFullPathTree:(null===(t=this.config.paths)||void 0===t?void 0:t.generateFullPathTree)||!0}},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"skipReferenceFields",{get:function(){return!!i(this.config.skipReferenceFields)||this.config.skipReferenceFields},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"sitemapMaxPageSize",{get:function(){return this.config.sitemapMaxPageSize||1e3},enumerable:!1,configurable:!0}),n}();export{n as default};

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

"use strict";var e=require("tslib"),t=require("lodash/merge"),i=require("lodash/isNil");function n(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var o=n(t),r=n(i),s={cms:"Contentful",strategy:"fs",contentful:{env:"master",usePreview:!1},logLevel:"warn",graphql:{port:5e3,host:"localhost"},sites:[]},l=function(){function t(e){this.config=o.default({},s,e),this.validateCmsVars(),this.validateStrategy(),this.validatePaths()}return t.prototype.validateCmsVars=function(){var e,t,i;if("Contentful"!==this.config.cms)throw new Error("Invalid CMS: ".concat(this.config.cms));if(!(null===(e=this.config.contentful)||void 0===e?void 0:e.spaceId))throw new Error("Contentful CMS: contentful.spaceId is required.");if(!(null===(t=this.config.contentful)||void 0===t?void 0:t.contentDeliveryToken))throw new Error("Contentful CMS: contentful.contentDeliveryToken is required.");if(!(null===(i=this.config.contentful)||void 0===i?void 0:i.contentPreviewToken))throw new Error("Contentful CMS: contentful.contentPreviewToken is required.")},t.prototype.validateStrategy=function(){var e,t,i,n,o,r,s;if("fs"===this.config.strategy){if(!(null===(e=this.config.fs)||void 0===e?void 0:e.contentDir))throw new Error("FS strategy: fs.contentDir is required")}else if("redis"===this.config.strategy){if(!(null===(t=this.config.redis)||void 0===t?void 0:t.host))throw new Error("Redis strategy: redis.host is required");if(!(null===(i=this.config.redis)||void 0===i?void 0:i.port))throw new Error("Redis strategy: redis.port is required")}else{if("dynamodb"!==this.config.strategy)throw new Error("Invalid strategy: ".concat(this.config.strategy));if(!(null===(n=this.config.dynamodb)||void 0===n?void 0:n.region))throw new Error("DynamoDB strategy: dynamodb.region is required");if(!(null===(o=this.config.dynamodb)||void 0===o?void 0:o.accessKeyId))throw new Error("DynamoDB strategy: dynamodb.accessKeyId is required");if(!(null===(r=this.config.dynamodb)||void 0===r?void 0:r.secretAccessKey))throw new Error("DynamoDB strategy: dynamodb.secretAccessKey is required");if(!(null===(s=this.config.dynamodb)||void 0===s?void 0:s.tableName))throw new Error("DynamoDB strategy: dynamodb.tableName is required")}},t.prototype.validatePaths=function(){var e,t;if("v2"!==(null===(e=this.config.paths)||void 0===e?void 0:e.version)&&!1===(null===(t=this.config.paths)||void 0===t?void 0:t.generateFullPathTree))throw new Error("Invalid paths configuration: generateFullPathTree must be true when using paths v1")},t.prototype.clone=function(e){return new t(o.default({},this.config,e))},Object.defineProperty(t.prototype,"contentful",{get:function(){var e,t,i,n,o,r,s;return{spaceId:null===(e=this.config.contentful)||void 0===e?void 0:e.spaceId,contentDeliveryToken:null===(t=this.config.contentful)||void 0===t?void 0:t.contentDeliveryToken,contentPreviewToken:null===(i=this.config.contentful)||void 0===i?void 0:i.contentPreviewToken,env:null===(n=this.config.contentful)||void 0===n?void 0:n.env,usePreview:!!(null===(o=this.config.contentful)||void 0===o?void 0:o.usePreview),maxBatchSize:(null===(r=this.config.contentful)||void 0===r?void 0:r.maxBatchSize)||1e3,syncLimit:null===(s=this.config.contentful)||void 0===s?void 0:s.syncLimit}},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"algolia",{get:function(){var e,t,i,n;return{applicationId:null===(e=this.config.algolia)||void 0===e?void 0:e.applicationId,adminApiKey:null===(t=this.config.algolia)||void 0===t?void 0:t.adminApiKey,contentTypeIds:null===(i=this.config.algolia)||void 0===i?void 0:i.contentTypeIds,indexDraftContent:!!(null===(n=this.config.algolia)||void 0===n?void 0:n.indexDraftContent)}},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"logLevel",{get:function(){return this.config.logLevel||"warn"},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"cms",{get:function(){return this.config.cms},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"strategy",{get:function(){return this.config.strategy},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"fs",{get:function(){var e;return{contentDir:null===(e=this.config.fs)||void 0===e?void 0:e.contentDir}},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"redis",{get:function(){var t,i;return e.__assign(e.__assign({},this.config.redis),{maxBatchSize:(null===(t=this.config.redis)||void 0===t?void 0:t.maxBatchSize)||1e3,ttlSeconds:(null===(i=this.config.redis)||void 0===i?void 0:i.ttlSeconds)||2592e3})},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"dynamodb",{get:function(){var e,t,i,n;return{region:null===(e=this.config.dynamodb)||void 0===e?void 0:e.region,accessKeyId:null===(t=this.config.dynamodb)||void 0===t?void 0:t.accessKeyId,secretAccessKey:null===(i=this.config.dynamodb)||void 0===i?void 0:i.secretAccessKey,tableName:null===(n=this.config.dynamodb)||void 0===n?void 0:n.tableName}},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"extensions",{get:function(){return this.config.extensions||{typeDefs:"",resolvers:{},mappers:{},typeMappings:{},pathsConfigs:{}}},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"graphql",{get:function(){var e,t;return{port:null===(e=this.config.graphql)||void 0===e?void 0:e.port,host:null===(t=this.config.graphql)||void 0===t?void 0:t.host}},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"sites",{get:function(){return this.config.sites},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"paths",{get:function(){var e,t;return{version:(null===(e=this.config.paths)||void 0===e?void 0:e.version)||"v1",generateFullPathTree:(null===(t=this.config.paths)||void 0===t?void 0:t.generateFullPathTree)||!0}},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"skipReferenceFields",{get:function(){return!!r.default(this.config.skipReferenceFields)||this.config.skipReferenceFields},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"sitemapMaxPageSize",{get:function(){return this.config.sitemapMaxPageSize||1e3},enumerable:!1,configurable:!0}),t}();module.exports=l;
"use strict";var e=require("tslib"),t=require("lodash/merge"),i=require("lodash/isNil");function n(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var o=n(t),r=n(i),s={cms:"Contentful",strategy:"fs",contentful:{env:"master",usePreview:!1},logLevel:"warn",graphql:{port:5e3,host:"localhost"},sites:[]},c=function(){function t(e){this.config=o.default({},s,e),this.validateCmsVars(),this.validateStrategy(),this.validatePaths()}return t.prototype.validateCmsVars=function(){var e,t,i;if("Contentful"!==this.config.cms)throw new Error("Invalid CMS: ".concat(this.config.cms));if(!(null===(e=this.config.contentful)||void 0===e?void 0:e.spaceId))throw new Error("Contentful CMS: contentful.spaceId is required.");if(!(null===(t=this.config.contentful)||void 0===t?void 0:t.contentDeliveryToken))throw new Error("Contentful CMS: contentful.contentDeliveryToken is required.");if(!(null===(i=this.config.contentful)||void 0===i?void 0:i.contentPreviewToken))throw new Error("Contentful CMS: contentful.contentPreviewToken is required.")},t.prototype.validateStrategy=function(){var e,t,i,n,o,r,s,c,a,d,l,f,g,u;if(this.config.contentStrategy)if("fs"===this.config.contentStrategy){if(!(null===(e=this.config.fs)||void 0===e?void 0:e.contentDir))throw new Error("FS strategy: fs.contentDir is required")}else{if("cms"!==this.config.contentStrategy)throw new Error("Invalid contentStrategy: ".concat(this.config.contentStrategy));if("redis"===this.config.cmsCacheStrategy){if(!(null===(t=this.config.redis)||void 0===t?void 0:t.host))throw new Error("Redis strategy: redis.host is required");if(!(null===(i=this.config.redis)||void 0===i?void 0:i.port))throw new Error("Redis strategy: redis.port is required")}else if("dynamodb"===this.config.cmsCacheStrategy){if(!(null===(n=this.config.dynamodb)||void 0===n?void 0:n.region))throw new Error("DynamoDB strategy: dynamodb.region is required");if(!(null===(o=this.config.dynamodb)||void 0===o?void 0:o.accessKeyId))throw new Error("DynamoDB strategy: dynamodb.accessKeyId is required");if(!(null===(r=this.config.dynamodb)||void 0===r?void 0:r.secretAccessKey))throw new Error("DynamoDB strategy: dynamodb.secretAccessKey is required");if(!(null===(s=this.config.dynamodb)||void 0===s?void 0:s.tableName))throw new Error("DynamoDB strategy: dynamodb.tableName is required")}}else{if(!this.config.strategy)throw new Error("Must specify a content stratgy");if("fs"===this.config.strategy){if(!(null===(c=this.config.fs)||void 0===c?void 0:c.contentDir))throw new Error("FS strategy: fs.contentDir is required")}else if("redis"===this.config.strategy){if(!(null===(a=this.config.redis)||void 0===a?void 0:a.host))throw new Error("Redis strategy: redis.host is required");if(!(null===(d=this.config.redis)||void 0===d?void 0:d.port))throw new Error("Redis strategy: redis.port is required")}else{if("dynamodb"!==this.config.strategy)throw new Error("Invalid strategy: ".concat(this.config.strategy));if(!(null===(l=this.config.dynamodb)||void 0===l?void 0:l.region))throw new Error("DynamoDB strategy: dynamodb.region is required");if(!(null===(f=this.config.dynamodb)||void 0===f?void 0:f.accessKeyId))throw new Error("DynamoDB strategy: dynamodb.accessKeyId is required");if(!(null===(g=this.config.dynamodb)||void 0===g?void 0:g.secretAccessKey))throw new Error("DynamoDB strategy: dynamodb.secretAccessKey is required");if(!(null===(u=this.config.dynamodb)||void 0===u?void 0:u.tableName))throw new Error("DynamoDB strategy: dynamodb.tableName is required")}}},t.prototype.validatePaths=function(){var e,t;if("v2"!==(null===(e=this.config.paths)||void 0===e?void 0:e.version)&&!1===(null===(t=this.config.paths)||void 0===t?void 0:t.generateFullPathTree))throw new Error("Invalid paths configuration: generateFullPathTree must be true when using paths v1")},t.prototype.clone=function(e){return new t(o.default({},this.config,e))},Object.defineProperty(t.prototype,"contentful",{get:function(){var e,t,i,n,o,r,s;return{spaceId:null===(e=this.config.contentful)||void 0===e?void 0:e.spaceId,contentDeliveryToken:null===(t=this.config.contentful)||void 0===t?void 0:t.contentDeliveryToken,contentPreviewToken:null===(i=this.config.contentful)||void 0===i?void 0:i.contentPreviewToken,env:null===(n=this.config.contentful)||void 0===n?void 0:n.env,usePreview:!!(null===(o=this.config.contentful)||void 0===o?void 0:o.usePreview),maxBatchSize:(null===(r=this.config.contentful)||void 0===r?void 0:r.maxBatchSize)||1e3,syncLimit:null===(s=this.config.contentful)||void 0===s?void 0:s.syncLimit}},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"algolia",{get:function(){var e,t,i,n;return{applicationId:null===(e=this.config.algolia)||void 0===e?void 0:e.applicationId,adminApiKey:null===(t=this.config.algolia)||void 0===t?void 0:t.adminApiKey,contentTypeIds:null===(i=this.config.algolia)||void 0===i?void 0:i.contentTypeIds,indexDraftContent:!!(null===(n=this.config.algolia)||void 0===n?void 0:n.indexDraftContent)}},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"logLevel",{get:function(){return this.config.logLevel||"warn"},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"cms",{get:function(){return this.config.cms},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"contentStrategy",{get:function(){return this.config.contentStrategy?this.config.contentStrategy:"fs"!==this.config.strategy?"cms":"fs"},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"cmsCacheStrategy",{get:function(){return this.config.cmsCacheStrategy?this.config.cmsCacheStrategy:"cms"===this.config.contentStrategy?"none":(this.config.strategy,this.config.strategy)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"fs",{get:function(){var e;return{contentDir:null===(e=this.config.fs)||void 0===e?void 0:e.contentDir}},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"redis",{get:function(){var t,i;return e.__assign(e.__assign({},this.config.redis),{maxBatchSize:(null===(t=this.config.redis)||void 0===t?void 0:t.maxBatchSize)||1e3,ttlSeconds:(null===(i=this.config.redis)||void 0===i?void 0:i.ttlSeconds)||2592e3})},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"dynamodb",{get:function(){var e,t,i,n;return{region:null===(e=this.config.dynamodb)||void 0===e?void 0:e.region,accessKeyId:null===(t=this.config.dynamodb)||void 0===t?void 0:t.accessKeyId,secretAccessKey:null===(i=this.config.dynamodb)||void 0===i?void 0:i.secretAccessKey,tableName:null===(n=this.config.dynamodb)||void 0===n?void 0:n.tableName}},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"extensions",{get:function(){return this.config.extensions||{typeDefs:"",resolvers:{},mappers:{},typeMappings:{},pathsConfigs:{}}},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"graphql",{get:function(){var e,t;return{port:null===(e=this.config.graphql)||void 0===e?void 0:e.port,host:null===(t=this.config.graphql)||void 0===t?void 0:t.host}},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"sites",{get:function(){return this.config.sites},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"paths",{get:function(){var e,t;return{version:(null===(e=this.config.paths)||void 0===e?void 0:e.version)||"v1",generateFullPathTree:(null===(t=this.config.paths)||void 0===t?void 0:t.generateFullPathTree)||!0}},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"skipReferenceFields",{get:function(){return!!r.default(this.config.skipReferenceFields)||this.config.skipReferenceFields},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"sitemapMaxPageSize",{get:function(){return this.config.sitemapMaxPageSize||1e3},enumerable:!1,configurable:!0}),t}();module.exports=c;

@@ -5,6 +5,9 @@ import { Extensions } from '@last-rev/types';

export declare type LastRevStrategy = 'fs' | 'redis' | 'dynamodb';
export declare type ContentStrategy = 'fs' | 'cms';
export declare type CmsCacheStrategy = 'redis' | 'dynamodb' | 'none';
export declare type PathVersion = 'v1' | 'v2';
export interface LastRevAppConfiguration {
cms: 'Contentful';
strategy: LastRevStrategy;
contentStrategy: ContentStrategy;
cmsCacheStrategy: CmsCacheStrategy;
redis: RedisOptions & {

@@ -55,2 +58,4 @@ maxBatchSize: number;

strategy?: LastRevStrategy;
contentStrategy?: ContentStrategy;
cmsCacheStrategy?: CmsCacheStrategy;
redis?: RedisOptions & {

@@ -57,0 +62,0 @@ maxBatchSize?: number;

{
"name": "@last-rev/app-config",
"version": "0.3.1",
"version": "0.4.0",
"description": "",

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

@@ -47,28 +47,62 @@ import { LastRevAppConfigArgs, LastRevAppConfiguration } from './types';

validateStrategy() {
if (this.config.strategy === 'fs') {
if (!this.config.fs?.contentDir) {
throw new Error(`FS strategy: fs.contentDir is required`);
if (this.config.contentStrategy) {
if (this.config.contentStrategy === 'fs') {
if (!this.config.fs?.contentDir) {
throw new Error(`FS strategy: fs.contentDir is required`);
}
} else if (this.config.contentStrategy === 'cms') {
if (this.config.cmsCacheStrategy === 'redis') {
if (!this.config.redis?.host) {
throw new Error(`Redis strategy: redis.host is required`);
}
if (!this.config.redis?.port) {
throw new Error(`Redis strategy: redis.port is required`);
}
} else if (this.config.cmsCacheStrategy === 'dynamodb') {
if (!this.config.dynamodb?.region) {
throw new Error(`DynamoDB strategy: dynamodb.region is required`);
}
if (!this.config.dynamodb?.accessKeyId) {
throw new Error(`DynamoDB strategy: dynamodb.accessKeyId is required`);
}
if (!this.config.dynamodb?.secretAccessKey) {
throw new Error(`DynamoDB strategy: dynamodb.secretAccessKey is required`);
}
if (!this.config.dynamodb?.tableName) {
throw new Error(`DynamoDB strategy: dynamodb.tableName is required`);
}
}
} else {
throw new Error(`Invalid contentStrategy: ${this.config.contentStrategy}`);
}
} else if (this.config.strategy === 'redis') {
if (!this.config.redis?.host) {
throw new Error(`Redis strategy: redis.host is required`);
} else if (this.config.strategy) {
if (this.config.strategy === 'fs') {
if (!this.config.fs?.contentDir) {
throw new Error(`FS strategy: fs.contentDir is required`);
}
} else if (this.config.strategy === 'redis') {
if (!this.config.redis?.host) {
throw new Error(`Redis strategy: redis.host is required`);
}
if (!this.config.redis?.port) {
throw new Error(`Redis strategy: redis.port is required`);
}
} else if (this.config.strategy === 'dynamodb') {
if (!this.config.dynamodb?.region) {
throw new Error(`DynamoDB strategy: dynamodb.region is required`);
}
if (!this.config.dynamodb?.accessKeyId) {
throw new Error(`DynamoDB strategy: dynamodb.accessKeyId is required`);
}
if (!this.config.dynamodb?.secretAccessKey) {
throw new Error(`DynamoDB strategy: dynamodb.secretAccessKey is required`);
}
if (!this.config.dynamodb?.tableName) {
throw new Error(`DynamoDB strategy: dynamodb.tableName is required`);
}
} else {
throw new Error(`Invalid strategy: ${this.config.strategy}`);
}
if (!this.config.redis?.port) {
throw new Error(`Redis strategy: redis.port is required`);
}
} else if (this.config.strategy === 'dynamodb') {
if (!this.config.dynamodb?.region) {
throw new Error(`DynamoDB strategy: dynamodb.region is required`);
}
if (!this.config.dynamodb?.accessKeyId) {
throw new Error(`DynamoDB strategy: dynamodb.accessKeyId is required`);
}
if (!this.config.dynamodb?.secretAccessKey) {
throw new Error(`DynamoDB strategy: dynamodb.secretAccessKey is required`);
}
if (!this.config.dynamodb?.tableName) {
throw new Error(`DynamoDB strategy: dynamodb.tableName is required`);
}
} else {
throw new Error(`Invalid strategy: ${this.config.strategy}`);
throw new Error(`Must specify a content stratgy`);
}

@@ -116,6 +150,15 @@ }

get strategy() {
return this.config.strategy!;
get contentStrategy() {
if (this.config.contentStrategy) return this.config.contentStrategy;
if (this.config.strategy !== 'fs') return 'cms';
return 'fs';
}
get cmsCacheStrategy() {
if (this.config.cmsCacheStrategy) return this.config.cmsCacheStrategy;
if (this.config.contentStrategy === 'cms') return 'none';
if (this.config.strategy === 'redis' || 'dynamodb') return this.config.strategy as 'redis' | 'dynamodb';
return 'none';
}
get fs() {

@@ -122,0 +165,0 @@ return {

@@ -6,2 +6,4 @@ import { Extensions } from '@last-rev/types';

export type LastRevStrategy = 'fs' | 'redis' | 'dynamodb';
export type ContentStrategy = 'fs' | 'cms';
export type CmsCacheStrategy = 'redis' | 'dynamodb' | 'none';

@@ -12,3 +14,4 @@ export type PathVersion = 'v1' | 'v2';

cms: 'Contentful';
strategy: LastRevStrategy;
contentStrategy: ContentStrategy;
cmsCacheStrategy: CmsCacheStrategy;
redis: RedisOptions & {

@@ -59,3 +62,8 @@ maxBatchSize: number;

cms?: 'Contentful';
/*
@deprecated use contentStrategy and cmsCacheStrategy instead
*/
strategy?: LastRevStrategy;
contentStrategy?: ContentStrategy;
cmsCacheStrategy?: CmsCacheStrategy;
redis?: RedisOptions & {

@@ -62,0 +70,0 @@ maxBatchSize?: number;

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

Sorry, the diff of this file is not supported yet

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