@last-rev/app-config
Advanced tools
Comparing version
# @last-rev/app-config | ||
## 0.6.0 | ||
### Minor Changes | ||
- 5a8c889: Added support for Sanity, renamed some packages, added more test coverage, switched to PNPM | ||
## 0.5.1 | ||
@@ -4,0 +10,0 @@ |
import { LastRevAppConfigArgs } from './types'; | ||
export declare const redisConfig: () => LastRevAppConfigArgs; | ||
export declare const sanityConfig: () => LastRevAppConfigArgs; | ||
declare const _default: () => LastRevAppConfigArgs; | ||
export default _default; | ||
//# sourceMappingURL=app-config.mock.d.ts.map |
@@ -1,4 +0,3 @@ | ||
/// <reference types="node" /> | ||
/// <reference types="node" /> | ||
import { LastRevAppConfigArgs, LastRevAppConfiguration } from './types'; | ||
import { RedisOptions } from 'ioredis'; | ||
export default class LastRevAppConfig implements LastRevAppConfiguration { | ||
@@ -21,2 +20,11 @@ config: LastRevAppConfigArgs; | ||
}; | ||
get sanity(): { | ||
projectId: string; | ||
dataset: string; | ||
token: string; | ||
apiVersion: string; | ||
usePreview: boolean; | ||
schemaTypes: any[]; | ||
supportedLanguages: import("./types").SupportedLanguage[]; | ||
}; | ||
get algolia(): { | ||
@@ -30,3 +38,3 @@ applicationId: string; | ||
get logLevel(): string; | ||
get cms(): "Contentful"; | ||
get cms(): "Contentful" | "Sanity"; | ||
get contentStrategy(): import("./types").ContentStrategy; | ||
@@ -37,6 +45,3 @@ get cmsCacheStrategy(): import("./types").CmsCacheStrategy; | ||
}; | ||
get redis(): import("ioredis").CommonRedisOptions & import("ioredis").SentinelConnectionOptions & Partial<import("net").TcpNetConnectOpts> & Partial<import("net").IpcNetConnectOpts> & { | ||
disconnectTimeout?: number | undefined; | ||
tls?: import("tls").ConnectionOptions | undefined; | ||
} & { | ||
get redis(): RedisOptions & { | ||
maxBatchSize: number; | ||
@@ -51,3 +56,9 @@ ttlSeconds: number; | ||
}; | ||
get extensions(): import("packages/types").Extensions; | ||
get extensions(): import("packages/types").Extensions | { | ||
typeDefs: string; | ||
resolvers: {}; | ||
mappers: {}; | ||
typeMappings: {}; | ||
pathsConfigs: {}; | ||
}; | ||
get graphql(): { | ||
@@ -58,3 +69,3 @@ port: number; | ||
get apolloServerOptions(): Partial<import("@apollo/server").ApolloServerOptions<import("packages/types").ApolloContext>> & { | ||
context?: import("@apollo/server").ContextFunction<any, import("packages/types").ApolloContext> | undefined; | ||
context?: import("@apollo/server").ContextFunction<any, import("packages/types").ApolloContext>; | ||
}; | ||
@@ -61,0 +72,0 @@ get sites(): string[]; |
@@ -1,1 +0,1 @@ | ||
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"},apolloServerOptions:{},sites:[],features:{}},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,a,c,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===(a=this.config.fs)||void 0===a?void 0:a.contentDir))throw new Error("FS strategy: fs.contentDir is required")}else if("redis"===this.config.strategy){if(!(null===(c=this.config.redis)||void 0===c?void 0:c.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,"jwtSigningSecret",{get:function(){return this.config.jwtSigningSecret},enumerable:!1,configurable:!0}),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,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===(o=this.config.algolia)||void 0===o?void 0:o.indexDraftContent),maxBatchSize:(null===(n=this.config.algolia)||void 0===n?void 0:n.maxBatchSize)||1e3}},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,"apolloServerOptions",{get:function(){return this.config.apolloServerOptions||{}},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;return{generateFullPathTree:(null===(e=this.config.paths)||void 0===e?void 0:e.generateFullPathTree)||!0}},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"sitemap",{get:function(){var e,t,i,o,n;return{domain:(null===(e=this.config.sitemap)||void 0===e?void 0:e.domain)||"",maxPageSize:(null===(t=this.config.sitemap)||void 0===t?void 0:t.maxPageSize)||1e3,indexRootPath:(null===(i=this.config.sitemap)||void 0===i?void 0:i.indexRootPath)||"/",pagesRootPath:(null===(o=this.config.sitemap)||void 0===o?void 0:o.pagesRootPath)||"/sitemap",excludePages:(null===(n=this.config.sitemap)||void 0===n?void 0:n.excludePages)||[]}},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"features",{get:function(){var e,t,o,n,r,s,a;return(null===(e=this.config.features)||void 0===e?void 0:e.disableCoreSidekickLookup)||console.warn("The SidekickLookupResolver in the core is being deprecated. See how to migrate: https://lastrev.atlassian.net/wiki/spaces/KB/pages/108167187/Sidekick+Lookup+Migration"),(null===(t=this.config.paths)||void 0===t?void 0:t.version)&&console.warn("The paths.version config option is deprecated. Use the features.enablePathsV2 option instead"),{disableCoreSidekickLookup:!!(null===(o=this.config.features)||void 0===o?void 0:o.disableCoreSidekickLookup),disableFederatedSchema:!!(null===(n=this.config.features)||void 0===n?void 0:n.disableFederatedSchema),enablePathsV2:i(null===(r=this.config.features)||void 0===r?void 0:r.enablePathsV2)?"v2"===(null===(s=this.config.paths)||void 0===s?void 0:s.version):!!(null===(a=this.config.features)||void 0===a?void 0:a.enablePathsV2)}},enumerable:!1,configurable:!0}),n}();export{n as default}; | ||
import e from"lodash/merge";import i from"lodash/isNil";function _define_property(e,i,t){return i in e?Object.defineProperty(e,i,{value:t,enumerable:!0,configurable:!0,writable:!0}):e[i]=t,e}function _object_spread_props(e,i){return i=null!=i?i:{},Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(i)):function(e,i){var t=Object.keys(e);if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(e);t.push.apply(t,o)}return t}(Object(i)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(i,t))})),e}const t={cms:"Contentful",strategy:"fs",contentful:{env:"master",usePreview:!1},logLevel:"warn",graphql:{port:5e3,host:"localhost"},apolloServerOptions:{},sites:[],features:{}};class LastRevAppConfig{validateCmsVars(){if("Contentful"===this.config.cms){var e,i,t;if(!(null===(e=this.config.contentful)||void 0===e?void 0:e.spaceId))throw new Error("Contentful CMS: contentful.spaceId is required.");if(!(null===(i=this.config.contentful)||void 0===i?void 0:i.contentDeliveryToken))throw new Error("Contentful CMS: contentful.contentDeliveryToken is required.");if(!(null===(t=this.config.contentful)||void 0===t?void 0:t.contentPreviewToken))throw new Error("Contentful CMS: contentful.contentPreviewToken is required.")}else{if("Sanity"!==this.config.cms)throw new Error(`Invalid CMS: ${this.config.cms}`);var o,n,r,s,a,d;if(!(null===(o=this.config.sanity)||void 0===o?void 0:o.projectId))throw new Error("Sanity CMS: sanity.projectId is required.");if(!(null===(n=this.config.sanity)||void 0===n?void 0:n.dataset))throw new Error("Sanity CMS: sanity.dataset is required.");if(!(null===(r=this.config.sanity)||void 0===r?void 0:r.token))throw new Error("Sanity CMS: sanity.token is required.");if(!(null===(s=this.config.sanity)||void 0===s?void 0:s.apiVersion))throw new Error("Sanity CMS: sanity.apiVersion is required.");if(!(null===(a=this.config.sanity)||void 0===a?void 0:a.schemaTypes))throw new Error("Sanity CMS: sanity.schemaTypes is required.");if(!(null===(d=this.config.sanity)||void 0===d?void 0:d.supportedLanguages))throw new Error("Sanity CMS: sanity.supportedLanguages is required.")}}validateStrategy(){if(this.config.contentStrategy)if("fs"===this.config.contentStrategy){var e;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: ${this.config.contentStrategy}`);if("redis"===this.config.cmsCacheStrategy){var i,t;if(!(null===(i=this.config.redis)||void 0===i?void 0:i.host))throw new Error("Redis strategy: redis.host is required");if(!(null===(t=this.config.redis)||void 0===t?void 0:t.port))throw new Error("Redis strategy: redis.port is required")}else if("dynamodb"===this.config.cmsCacheStrategy){var o,n,r,s;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");var a;if("fs"===this.config.strategy){if(!(null===(a=this.config.fs)||void 0===a?void 0:a.contentDir))throw new Error("FS strategy: fs.contentDir is required")}else if("redis"===this.config.strategy){var d,c;if(!(null===(d=this.config.redis)||void 0===d?void 0:d.host))throw new Error("Redis strategy: redis.host is required");if(!(null===(c=this.config.redis)||void 0===c?void 0:c.port))throw new Error("Redis strategy: redis.port is required")}else{if("dynamodb"!==this.config.strategy)throw new Error(`Invalid strategy: ${this.config.strategy}`);var l,g,f,v;if(!(null===(l=this.config.dynamodb)||void 0===l?void 0:l.region))throw new Error("DynamoDB strategy: dynamodb.region is required");if(!(null===(g=this.config.dynamodb)||void 0===g?void 0:g.accessKeyId))throw new Error("DynamoDB strategy: dynamodb.accessKeyId is required");if(!(null===(f=this.config.dynamodb)||void 0===f?void 0:f.secretAccessKey))throw new Error("DynamoDB strategy: dynamodb.secretAccessKey is required");if(!(null===(v=this.config.dynamodb)||void 0===v?void 0:v.tableName))throw new Error("DynamoDB strategy: dynamodb.tableName is required")}}}validatePaths(){var e,i;if("v2"!==(null===(e=this.config.paths)||void 0===e?void 0:e.version)&&!1===(null===(i=this.config.paths)||void 0===i?void 0:i.generateFullPathTree))throw new Error("Invalid paths configuration: generateFullPathTree must be true when using paths v1")}clone(i){return new LastRevAppConfig(e({},this.config,i))}get jwtSigningSecret(){return this.config.jwtSigningSecret}get contentful(){var e,i,t,o,n,r,s;return{spaceId:null===(e=this.config.contentful)||void 0===e?void 0:e.spaceId,contentDeliveryToken:null===(i=this.config.contentful)||void 0===i?void 0:i.contentDeliveryToken,contentPreviewToken:null===(t=this.config.contentful)||void 0===t?void 0:t.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}}get sanity(){var e,i,t,o,n,r,s;return{projectId:null===(e=this.config.sanity)||void 0===e?void 0:e.projectId,dataset:null===(i=this.config.sanity)||void 0===i?void 0:i.dataset,token:null===(t=this.config.sanity)||void 0===t?void 0:t.token,apiVersion:null===(o=this.config.sanity)||void 0===o?void 0:o.apiVersion,usePreview:!!(null===(n=this.config.sanity)||void 0===n?void 0:n.usePreview),schemaTypes:null===(r=this.config.sanity)||void 0===r?void 0:r.schemaTypes,supportedLanguages:null===(s=this.config.sanity)||void 0===s?void 0:s.supportedLanguages}}get algolia(){var e,i,t,o,n;return{applicationId:null===(e=this.config.algolia)||void 0===e?void 0:e.applicationId,adminApiKey:null===(i=this.config.algolia)||void 0===i?void 0:i.adminApiKey,contentTypeIds:null===(t=this.config.algolia)||void 0===t?void 0:t.contentTypeIds,indexDraftContent:!!(null===(o=this.config.algolia)||void 0===o?void 0:o.indexDraftContent),maxBatchSize:(null===(n=this.config.algolia)||void 0===n?void 0:n.maxBatchSize)||1e3}}get logLevel(){return this.config.logLevel||"warn"}get cms(){return this.config.cms}get contentStrategy(){return this.config.contentStrategy?this.config.contentStrategy:"fs"!==this.config.strategy?"cms":"fs"}get cmsCacheStrategy(){return this.config.cmsCacheStrategy?this.config.cmsCacheStrategy:"cms"===this.config.contentStrategy?"none":(this.config.strategy,this.config.strategy)}get fs(){var e;return{contentDir:null===(e=this.config.fs)||void 0===e?void 0:e.contentDir}}get redis(){var e,i;return _object_spread_props(function(e){for(var i=1;i<arguments.length;i++){var t=null!=arguments[i]?arguments[i]:{},o=Object.keys(t);"function"==typeof Object.getOwnPropertySymbols&&(o=o.concat(Object.getOwnPropertySymbols(t).filter((function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable})))),o.forEach((function(i){_define_property(e,i,t[i])}))}return e}({},this.config.redis),{maxBatchSize:(null===(e=this.config.redis)||void 0===e?void 0:e.maxBatchSize)||1e3,ttlSeconds:(null===(i=this.config.redis)||void 0===i?void 0:i.ttlSeconds)||2592e3})}get dynamodb(){var e,i,t,o;return{region:null===(e=this.config.dynamodb)||void 0===e?void 0:e.region,accessKeyId:null===(i=this.config.dynamodb)||void 0===i?void 0:i.accessKeyId,secretAccessKey:null===(t=this.config.dynamodb)||void 0===t?void 0:t.secretAccessKey,tableName:null===(o=this.config.dynamodb)||void 0===o?void 0:o.tableName}}get extensions(){return this.config.extensions||{typeDefs:"",resolvers:{},mappers:{},typeMappings:{},pathsConfigs:{}}}get graphql(){var e,i;return{port:null===(e=this.config.graphql)||void 0===e?void 0:e.port,host:null===(i=this.config.graphql)||void 0===i?void 0:i.host}}get apolloServerOptions(){return this.config.apolloServerOptions||{}}get sites(){return this.config.sites}get paths(){var e;return{generateFullPathTree:(null===(e=this.config.paths)||void 0===e?void 0:e.generateFullPathTree)||!0}}get sitemap(){var e,i,t,o,n;return{domain:(null===(e=this.config.sitemap)||void 0===e?void 0:e.domain)||"",maxPageSize:(null===(i=this.config.sitemap)||void 0===i?void 0:i.maxPageSize)||1e3,indexRootPath:(null===(t=this.config.sitemap)||void 0===t?void 0:t.indexRootPath)||"/",pagesRootPath:(null===(o=this.config.sitemap)||void 0===o?void 0:o.pagesRootPath)||"/sitemap",excludePages:(null===(n=this.config.sitemap)||void 0===n?void 0:n.excludePages)||[]}}get features(){var e,t,o,n,r,s,a;return(null===(e=this.config.features)||void 0===e?void 0:e.disableCoreSidekickLookup)||console.warn("The SidekickLookupResolver in the core is being deprecated. See how to migrate: https://lastrev.atlassian.net/wiki/spaces/KB/pages/108167187/Sidekick+Lookup+Migration"),(null===(t=this.config.paths)||void 0===t?void 0:t.version)&&console.warn("The paths.version config option is deprecated. Use the features.enablePathsV2 option instead"),{disableCoreSidekickLookup:!!(null===(o=this.config.features)||void 0===o?void 0:o.disableCoreSidekickLookup),disableFederatedSchema:!!(null===(n=this.config.features)||void 0===n?void 0:n.disableFederatedSchema),enablePathsV2:i(null===(r=this.config.features)||void 0===r?void 0:r.enablePathsV2)?"v2"===(null===(s=this.config.paths)||void 0===s?void 0:s.version):!!(null===(a=this.config.features)||void 0===a?void 0:a.enablePathsV2)}}constructor(i){_define_property(this,"config",void 0),this.config=e({},t,i),this.validateCmsVars(),this.validateStrategy(),this.validatePaths()}}export{LastRevAppConfig as default}; |
@@ -1,1 +0,1 @@ | ||
"use strict";var e=require("tslib"),t=require("lodash/merge"),i=require("lodash/isNil");function o(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var n=o(t),r=o(i),s={cms:"Contentful",strategy:"fs",contentful:{env:"master",usePreview:!1},logLevel:"warn",graphql:{port:5e3,host:"localhost"},apolloServerOptions:{},sites:[],features:{}},a=function(){function t(e){this.config=n.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,o,n,r,s,a,c,d,l,f,u,g;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===(a=this.config.fs)||void 0===a?void 0:a.contentDir))throw new Error("FS strategy: fs.contentDir is required")}else if("redis"===this.config.strategy){if(!(null===(c=this.config.redis)||void 0===c?void 0:c.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===(u=this.config.dynamodb)||void 0===u?void 0:u.secretAccessKey))throw new Error("DynamoDB strategy: dynamodb.secretAccessKey is required");if(!(null===(g=this.config.dynamodb)||void 0===g?void 0:g.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(n.default({},this.config,e))},Object.defineProperty(t.prototype,"jwtSigningSecret",{get:function(){return this.config.jwtSigningSecret},enumerable:!1,configurable:!0}),Object.defineProperty(t.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(t.prototype,"algolia",{get:function(){var e,t,i,o,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===(o=this.config.algolia)||void 0===o?void 0:o.indexDraftContent),maxBatchSize:(null===(n=this.config.algolia)||void 0===n?void 0:n.maxBatchSize)||1e3}},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,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(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,"apolloServerOptions",{get:function(){return this.config.apolloServerOptions||{}},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;return{generateFullPathTree:(null===(e=this.config.paths)||void 0===e?void 0:e.generateFullPathTree)||!0}},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"sitemap",{get:function(){var e,t,i,o,n;return{domain:(null===(e=this.config.sitemap)||void 0===e?void 0:e.domain)||"",maxPageSize:(null===(t=this.config.sitemap)||void 0===t?void 0:t.maxPageSize)||1e3,indexRootPath:(null===(i=this.config.sitemap)||void 0===i?void 0:i.indexRootPath)||"/",pagesRootPath:(null===(o=this.config.sitemap)||void 0===o?void 0:o.pagesRootPath)||"/sitemap",excludePages:(null===(n=this.config.sitemap)||void 0===n?void 0:n.excludePages)||[]}},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"features",{get:function(){var e,t,i,o,n,s,a;return(null===(e=this.config.features)||void 0===e?void 0:e.disableCoreSidekickLookup)||console.warn("The SidekickLookupResolver in the core is being deprecated. See how to migrate: https://lastrev.atlassian.net/wiki/spaces/KB/pages/108167187/Sidekick+Lookup+Migration"),(null===(t=this.config.paths)||void 0===t?void 0:t.version)&&console.warn("The paths.version config option is deprecated. Use the features.enablePathsV2 option instead"),{disableCoreSidekickLookup:!!(null===(i=this.config.features)||void 0===i?void 0:i.disableCoreSidekickLookup),disableFederatedSchema:!!(null===(o=this.config.features)||void 0===o?void 0:o.disableFederatedSchema),enablePathsV2:r.default(null===(n=this.config.features)||void 0===n?void 0:n.enablePathsV2)?"v2"===(null===(s=this.config.paths)||void 0===s?void 0:s.version):!!(null===(a=this.config.features)||void 0===a?void 0:a.enablePathsV2)}},enumerable:!1,configurable:!0}),t}();module.exports=a; | ||
"use strict";var e=require("lodash/merge"),i=require("lodash/isNil");function _interopDefault(e){return e&&e.__esModule?e:{default:e}}var t=_interopDefault(e),o=_interopDefault(i);function _define_property(e,i,t){return i in e?Object.defineProperty(e,i,{value:t,enumerable:!0,configurable:!0,writable:!0}):e[i]=t,e}function _object_spread_props(e,i){return i=null!=i?i:{},Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(i)):function(e,i){var t=Object.keys(e);if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(e);t.push.apply(t,o)}return t}(Object(i)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(i,t))})),e}const n={cms:"Contentful",strategy:"fs",contentful:{env:"master",usePreview:!1},logLevel:"warn",graphql:{port:5e3,host:"localhost"},apolloServerOptions:{},sites:[],features:{}};class LastRevAppConfig{validateCmsVars(){if("Contentful"===this.config.cms){var e,i,t;if(!(null===(e=this.config.contentful)||void 0===e?void 0:e.spaceId))throw new Error("Contentful CMS: contentful.spaceId is required.");if(!(null===(i=this.config.contentful)||void 0===i?void 0:i.contentDeliveryToken))throw new Error("Contentful CMS: contentful.contentDeliveryToken is required.");if(!(null===(t=this.config.contentful)||void 0===t?void 0:t.contentPreviewToken))throw new Error("Contentful CMS: contentful.contentPreviewToken is required.")}else{if("Sanity"!==this.config.cms)throw new Error(`Invalid CMS: ${this.config.cms}`);var o,n,r,s,a,d;if(!(null===(o=this.config.sanity)||void 0===o?void 0:o.projectId))throw new Error("Sanity CMS: sanity.projectId is required.");if(!(null===(n=this.config.sanity)||void 0===n?void 0:n.dataset))throw new Error("Sanity CMS: sanity.dataset is required.");if(!(null===(r=this.config.sanity)||void 0===r?void 0:r.token))throw new Error("Sanity CMS: sanity.token is required.");if(!(null===(s=this.config.sanity)||void 0===s?void 0:s.apiVersion))throw new Error("Sanity CMS: sanity.apiVersion is required.");if(!(null===(a=this.config.sanity)||void 0===a?void 0:a.schemaTypes))throw new Error("Sanity CMS: sanity.schemaTypes is required.");if(!(null===(d=this.config.sanity)||void 0===d?void 0:d.supportedLanguages))throw new Error("Sanity CMS: sanity.supportedLanguages is required.")}}validateStrategy(){if(this.config.contentStrategy)if("fs"===this.config.contentStrategy){var e;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: ${this.config.contentStrategy}`);if("redis"===this.config.cmsCacheStrategy){var i,t;if(!(null===(i=this.config.redis)||void 0===i?void 0:i.host))throw new Error("Redis strategy: redis.host is required");if(!(null===(t=this.config.redis)||void 0===t?void 0:t.port))throw new Error("Redis strategy: redis.port is required")}else if("dynamodb"===this.config.cmsCacheStrategy){var o,n,r,s;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");var a;if("fs"===this.config.strategy){if(!(null===(a=this.config.fs)||void 0===a?void 0:a.contentDir))throw new Error("FS strategy: fs.contentDir is required")}else if("redis"===this.config.strategy){var d,c;if(!(null===(d=this.config.redis)||void 0===d?void 0:d.host))throw new Error("Redis strategy: redis.host is required");if(!(null===(c=this.config.redis)||void 0===c?void 0:c.port))throw new Error("Redis strategy: redis.port is required")}else{if("dynamodb"!==this.config.strategy)throw new Error(`Invalid strategy: ${this.config.strategy}`);var l,g,f,v;if(!(null===(l=this.config.dynamodb)||void 0===l?void 0:l.region))throw new Error("DynamoDB strategy: dynamodb.region is required");if(!(null===(g=this.config.dynamodb)||void 0===g?void 0:g.accessKeyId))throw new Error("DynamoDB strategy: dynamodb.accessKeyId is required");if(!(null===(f=this.config.dynamodb)||void 0===f?void 0:f.secretAccessKey))throw new Error("DynamoDB strategy: dynamodb.secretAccessKey is required");if(!(null===(v=this.config.dynamodb)||void 0===v?void 0:v.tableName))throw new Error("DynamoDB strategy: dynamodb.tableName is required")}}}validatePaths(){var e,i;if("v2"!==(null===(e=this.config.paths)||void 0===e?void 0:e.version)&&!1===(null===(i=this.config.paths)||void 0===i?void 0:i.generateFullPathTree))throw new Error("Invalid paths configuration: generateFullPathTree must be true when using paths v1")}clone(e){return new LastRevAppConfig(t.default({},this.config,e))}get jwtSigningSecret(){return this.config.jwtSigningSecret}get contentful(){var e,i,t,o,n,r,s;return{spaceId:null===(e=this.config.contentful)||void 0===e?void 0:e.spaceId,contentDeliveryToken:null===(i=this.config.contentful)||void 0===i?void 0:i.contentDeliveryToken,contentPreviewToken:null===(t=this.config.contentful)||void 0===t?void 0:t.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}}get sanity(){var e,i,t,o,n,r,s;return{projectId:null===(e=this.config.sanity)||void 0===e?void 0:e.projectId,dataset:null===(i=this.config.sanity)||void 0===i?void 0:i.dataset,token:null===(t=this.config.sanity)||void 0===t?void 0:t.token,apiVersion:null===(o=this.config.sanity)||void 0===o?void 0:o.apiVersion,usePreview:!!(null===(n=this.config.sanity)||void 0===n?void 0:n.usePreview),schemaTypes:null===(r=this.config.sanity)||void 0===r?void 0:r.schemaTypes,supportedLanguages:null===(s=this.config.sanity)||void 0===s?void 0:s.supportedLanguages}}get algolia(){var e,i,t,o,n;return{applicationId:null===(e=this.config.algolia)||void 0===e?void 0:e.applicationId,adminApiKey:null===(i=this.config.algolia)||void 0===i?void 0:i.adminApiKey,contentTypeIds:null===(t=this.config.algolia)||void 0===t?void 0:t.contentTypeIds,indexDraftContent:!!(null===(o=this.config.algolia)||void 0===o?void 0:o.indexDraftContent),maxBatchSize:(null===(n=this.config.algolia)||void 0===n?void 0:n.maxBatchSize)||1e3}}get logLevel(){return this.config.logLevel||"warn"}get cms(){return this.config.cms}get contentStrategy(){return this.config.contentStrategy?this.config.contentStrategy:"fs"!==this.config.strategy?"cms":"fs"}get cmsCacheStrategy(){return this.config.cmsCacheStrategy?this.config.cmsCacheStrategy:"cms"===this.config.contentStrategy?"none":(this.config.strategy,this.config.strategy)}get fs(){var e;return{contentDir:null===(e=this.config.fs)||void 0===e?void 0:e.contentDir}}get redis(){var e,i;return _object_spread_props(function(e){for(var i=1;i<arguments.length;i++){var t=null!=arguments[i]?arguments[i]:{},o=Object.keys(t);"function"==typeof Object.getOwnPropertySymbols&&(o=o.concat(Object.getOwnPropertySymbols(t).filter((function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable})))),o.forEach((function(i){_define_property(e,i,t[i])}))}return e}({},this.config.redis),{maxBatchSize:(null===(e=this.config.redis)||void 0===e?void 0:e.maxBatchSize)||1e3,ttlSeconds:(null===(i=this.config.redis)||void 0===i?void 0:i.ttlSeconds)||2592e3})}get dynamodb(){var e,i,t,o;return{region:null===(e=this.config.dynamodb)||void 0===e?void 0:e.region,accessKeyId:null===(i=this.config.dynamodb)||void 0===i?void 0:i.accessKeyId,secretAccessKey:null===(t=this.config.dynamodb)||void 0===t?void 0:t.secretAccessKey,tableName:null===(o=this.config.dynamodb)||void 0===o?void 0:o.tableName}}get extensions(){return this.config.extensions||{typeDefs:"",resolvers:{},mappers:{},typeMappings:{},pathsConfigs:{}}}get graphql(){var e,i;return{port:null===(e=this.config.graphql)||void 0===e?void 0:e.port,host:null===(i=this.config.graphql)||void 0===i?void 0:i.host}}get apolloServerOptions(){return this.config.apolloServerOptions||{}}get sites(){return this.config.sites}get paths(){var e;return{generateFullPathTree:(null===(e=this.config.paths)||void 0===e?void 0:e.generateFullPathTree)||!0}}get sitemap(){var e,i,t,o,n;return{domain:(null===(e=this.config.sitemap)||void 0===e?void 0:e.domain)||"",maxPageSize:(null===(i=this.config.sitemap)||void 0===i?void 0:i.maxPageSize)||1e3,indexRootPath:(null===(t=this.config.sitemap)||void 0===t?void 0:t.indexRootPath)||"/",pagesRootPath:(null===(o=this.config.sitemap)||void 0===o?void 0:o.pagesRootPath)||"/sitemap",excludePages:(null===(n=this.config.sitemap)||void 0===n?void 0:n.excludePages)||[]}}get features(){var e,i,t,n,r,s,a;return(null===(e=this.config.features)||void 0===e?void 0:e.disableCoreSidekickLookup)||console.warn("The SidekickLookupResolver in the core is being deprecated. See how to migrate: https://lastrev.atlassian.net/wiki/spaces/KB/pages/108167187/Sidekick+Lookup+Migration"),(null===(i=this.config.paths)||void 0===i?void 0:i.version)&&console.warn("The paths.version config option is deprecated. Use the features.enablePathsV2 option instead"),{disableCoreSidekickLookup:!!(null===(t=this.config.features)||void 0===t?void 0:t.disableCoreSidekickLookup),disableFederatedSchema:!!(null===(n=this.config.features)||void 0===n?void 0:n.disableFederatedSchema),enablePathsV2:o.default(null===(r=this.config.features)||void 0===r?void 0:r.enablePathsV2)?"v2"===(null===(s=this.config.paths)||void 0===s?void 0:s.version):!!(null===(a=this.config.features)||void 0===a?void 0:a.enablePathsV2)}}constructor(e){_define_property(this,"config",void 0),this.config=t.default({},n,e),this.validateCmsVars(),this.validateStrategy(),this.validatePaths()}}module.exports=LastRevAppConfig; |
import { ApolloContext, Extensions } from '@last-rev/types'; | ||
import { ApolloServerOptions, ContextFunction } from '@apollo/server'; | ||
import { RedisOptions } from 'ioredis'; | ||
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 type LastRevStrategy = 'fs' | 'redis' | 'dynamodb'; | ||
export type ContentStrategy = 'fs' | 'cms'; | ||
export type CmsCacheStrategy = 'redis' | 'dynamodb' | 'none'; | ||
export type PathVersion = 'v1' | 'v2'; | ||
export type SupportedLanguage = { | ||
id: string; | ||
title: string; | ||
}; | ||
export interface LastRevAppConfiguration { | ||
cms: 'Contentful'; | ||
cms: 'Contentful' | 'Sanity'; | ||
contentStrategy: ContentStrategy; | ||
@@ -35,2 +39,11 @@ cmsCacheStrategy: CmsCacheStrategy; | ||
}; | ||
sanity: { | ||
projectId: string; | ||
dataset: string; | ||
token: string; | ||
apiVersion: string; | ||
usePreview: boolean; | ||
schemaTypes: any[]; | ||
supportedLanguages: SupportedLanguage[]; | ||
}; | ||
algolia: { | ||
@@ -67,7 +80,7 @@ applicationId: string; | ||
} | ||
declare type LRApolloServerOptions = Partial<ApolloServerOptions<ApolloContext>> & { | ||
type LRApolloServerOptions = Partial<ApolloServerOptions<ApolloContext>> & { | ||
context?: ContextFunction<any, ApolloContext>; | ||
}; | ||
export declare type LastRevAppConfigArgs = { | ||
cms?: 'Contentful'; | ||
export type LastRevAppConfigArgs = { | ||
cms?: 'Contentful' | 'Sanity'; | ||
strategy?: LastRevStrategy; | ||
@@ -99,2 +112,11 @@ contentStrategy?: ContentStrategy; | ||
}; | ||
sanity?: { | ||
projectId?: string; | ||
dataset?: string; | ||
token?: string; | ||
apiVersion?: string; | ||
usePreview?: boolean; | ||
schemaTypes?: any[]; | ||
supportedLanguages?: SupportedLanguage[]; | ||
}; | ||
algolia?: { | ||
@@ -101,0 +123,0 @@ applicationId?: string; |
{ | ||
"name": "@last-rev/app-config", | ||
"version": "0.5.1", | ||
"version": "0.6.0", | ||
"description": "", | ||
"main": "dist/index.js", | ||
"devDependencies": { | ||
"@apollo/server": "^4.12.2", | ||
"@testing-library/jest-dom": "^5.16.4", | ||
"@types/jest": "^30.0.0", | ||
"@types/lodash": "^4.17.18", | ||
"esbuild": "^0.25.5", | ||
"ioredis": "^5.0.4", | ||
"jest": "^30.0.2", | ||
"rollup": "^4.44.0", | ||
"tslint": "^5.20.1", | ||
"@last-rev/rollup-config": "0.2.0", | ||
"@last-rev/testing-library": "0.2.0", | ||
"@last-rev/types": "0.5.0" | ||
}, | ||
"dependencies": { | ||
"lodash": "^4.17.21" | ||
}, | ||
"keywords": [], | ||
"author": "", | ||
"license": "ISC", | ||
"scripts": { | ||
@@ -14,16 +34,3 @@ "clean": "rimraf dist", | ||
"test:watch": "jest --watch" | ||
}, | ||
"devDependencies": { | ||
"@last-rev/rollup-config": "^0.1.5", | ||
"@last-rev/testing-library": "^0.1.10", | ||
"@last-rev/types": "^0.3.6", | ||
"ioredis": "^5.0.4", | ||
"jest": "^26.6.3" | ||
}, | ||
"dependencies": { | ||
"lodash": "^4.17.21" | ||
}, | ||
"keywords": [], | ||
"author": "", | ||
"license": "ISC" | ||
} | ||
} | ||
} |
@@ -1,6 +0,6 @@ | ||
import { config } from '@last-rev/rollup-config'; | ||
const { config } = require('@last-rev/rollup-config'); | ||
export default config({ | ||
module.exports = config({ | ||
input: './src/index.ts', | ||
babelHelpers: 'runtime' | ||
}); |
@@ -32,2 +32,18 @@ import { LastRevAppConfigArgs } from './types'; | ||
const sanity = () => ({ | ||
projectId: 'projectId', | ||
dataset: 'dataset', | ||
token: 'token', | ||
apiVersion: '2021-06-07', | ||
schemaTypes: [ | ||
{ name: 'page', type: 'document' }, | ||
{ name: 'blog', type: 'document' } | ||
], | ||
supportedLanguages: [ | ||
{ id: 'en', title: 'English' }, | ||
{ id: 'es', title: 'Spanish' }, | ||
{ id: 'fr', title: 'French' } | ||
] | ||
}); | ||
export const redisConfig = (): LastRevAppConfigArgs => ({ | ||
@@ -37,2 +53,6 @@ redis: { ...redis() } | ||
export const sanityConfig = (): LastRevAppConfigArgs => ({ | ||
sanity: { ...sanity() } | ||
}); | ||
export default (): LastRevAppConfigArgs => ({ | ||
@@ -43,2 +63,3 @@ redis: { ...redis() }, | ||
contentful: { ...contentful() }, | ||
sanity: { ...sanity() }, | ||
extensions: { | ||
@@ -45,0 +66,0 @@ typeDefs: 'typeDefs', |
@@ -43,2 +43,21 @@ import { LastRevAppConfigArgs, LastRevAppConfiguration } from './types'; | ||
} | ||
} else if (this.config.cms === 'Sanity') { | ||
if (!this.config.sanity?.projectId) { | ||
throw new Error('Sanity CMS: sanity.projectId is required.'); | ||
} | ||
if (!this.config.sanity?.dataset) { | ||
throw new Error('Sanity CMS: sanity.dataset is required.'); | ||
} | ||
if (!this.config.sanity?.token) { | ||
throw new Error('Sanity CMS: sanity.token is required.'); | ||
} | ||
if (!this.config.sanity?.apiVersion) { | ||
throw new Error('Sanity CMS: sanity.apiVersion is required.'); | ||
} | ||
if (!this.config.sanity?.schemaTypes) { | ||
throw new Error('Sanity CMS: sanity.schemaTypes is required.'); | ||
} | ||
if (!this.config.sanity?.supportedLanguages) { | ||
throw new Error('Sanity CMS: sanity.supportedLanguages is required.'); | ||
} | ||
} else { | ||
@@ -139,2 +158,14 @@ throw new Error(`Invalid CMS: ${this.config.cms}`); | ||
get sanity() { | ||
return { | ||
projectId: this.config.sanity?.projectId!, | ||
dataset: this.config.sanity?.dataset!, | ||
token: this.config.sanity?.token!, | ||
apiVersion: this.config.sanity?.apiVersion!, | ||
usePreview: !!this.config.sanity?.usePreview, | ||
schemaTypes: this.config.sanity?.schemaTypes!, | ||
supportedLanguages: this.config.sanity?.supportedLanguages! | ||
}; | ||
} | ||
get algolia() { | ||
@@ -141,0 +172,0 @@ return { |
@@ -11,4 +11,9 @@ import { ApolloContext, Extensions } from '@last-rev/types'; | ||
export type SupportedLanguage = { | ||
id: string; | ||
title: string; | ||
}; | ||
export interface LastRevAppConfiguration { | ||
cms: 'Contentful'; | ||
cms: 'Contentful' | 'Sanity'; | ||
contentStrategy: ContentStrategy; | ||
@@ -39,2 +44,11 @@ cmsCacheStrategy: CmsCacheStrategy; | ||
}; | ||
sanity: { | ||
projectId: string; | ||
dataset: string; | ||
token: string; | ||
apiVersion: string; | ||
usePreview: boolean; | ||
schemaTypes: any[]; | ||
supportedLanguages: SupportedLanguage[]; | ||
}; | ||
algolia: { | ||
@@ -76,3 +90,3 @@ applicationId: string; | ||
export type LastRevAppConfigArgs = { | ||
cms?: 'Contentful'; | ||
cms?: 'Contentful' | 'Sanity'; | ||
/* | ||
@@ -107,2 +121,11 @@ @deprecated use contentStrategy and cmsCacheStrategy instead | ||
}; | ||
sanity?: { | ||
projectId?: string; | ||
dataset?: string; | ||
token?: string; | ||
apiVersion?: string; | ||
usePreview?: boolean; | ||
schemaTypes?: any[]; | ||
supportedLanguages?: SupportedLanguage[]; | ||
}; | ||
algolia?: { | ||
@@ -109,0 +132,0 @@ applicationId?: string; |
@@ -12,2 +12,3 @@ { | ||
"moduleResolution": "node", | ||
"types": ["jest", "node"], | ||
"allowSyntheticDefaultImports": true, | ||
@@ -14,0 +15,0 @@ "esModuleInterop": true |
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
Sorry, the diff of this file is not supported yet
Minified code
QualityThis package contains minified code. This may be harmless in some cases where minified code is included in packaged libraries, however packages on npm should not minify code.
Found 1 instance in 1 package
Mixed license
License(Experimental) Package contains multiple licenses.
Found 1 instance in 1 package
81151
29.27%21
5%1237
12.97%12
140%1
Infinity%4
33.33%