druxt-schema
Advanced tools
Comparing version 0.6.1 to 0.6.2
@@ -260,3 +260,3 @@ import consola from 'consola'; | ||
var resourceType = "entity_" + schemaType + "_display--entity_" + schemaType + "_display"; | ||
var displays = await this.druxtRouter.getResources(resourceType); | ||
var displays = await this.druxtRouter.getResources(resourceType, {}, { all: true }); | ||
@@ -263,0 +263,0 @@ for (var display of displays) { |
@@ -1,1 +0,1 @@ | ||
var VueDrupalSchema=function(t,e,i,s,r){"use strict";e=e&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e;var n=function(t,e){var i=e.druxtSchema,s=e.data;if(t.resourceFields&&(this.resourceFields=t.resourceFields,delete t.resourceFields),this.config=Object.assign({},{entityType:"node",bundle:null,mode:"default",schemaType:"view",filter:[]},t),!this.id&&this.config.resourceType&&(this.id=[this.config.resourceType,this.config.mode,this.config.schemaType].join("--")),!this.id&&this.config.bundle&&(this.id=[this.config.entityType,this.config.bundle,this.config.mode,this.config.schemaType].join("--")),this.isValid=!0,this.config.filter.length>0)for(var r of(this.isValid=!1,this.config.filter)){if(this.id.match(r)){this.isValid=!0;break}}this.displayId=[this.config.entityType,this.config.bundle,this.config.mode].join("."),this.resourceType=[this.config.entityType,this.config.bundle].join("--"),this.data={},void 0!==s&&(this.data[s.type]=s),this.fields={},this.druxtSchema=i};n.prototype.generate=async function(){return this[this.config.schemaType]()},n.prototype.getResources=async function(t,e){return this.data[t]||(this.data[t]=await this.druxtSchema.druxtRouter.getResources(t,e)),this.data[t]},n.prototype.form=async function(){var t=this,e=await this.getResources("entity_form_display--entity_form_display",{"filter[drupal_internal__id]":this.displayId}).then((function(t){return Array.isArray(t)?t[0]:t}));if(!e)return!1;var i=await this.getResources("field_config--field_config",{"filter[entity_type]":this.config.entityType,"filter[bundle]":this.config.bundle});if(!i)return!1;var s=await this.getResources("field_storage_config--field_storage_config",{"filter[entity_type]":this.config.entityType});if(!s)return!1;var r=function(r){var n=Object.assign({},{id:null,label:null,type:null,weight:null,settings:{},third_party_settings:{}},e.attributes.content[r]),a=Object.assign({},{attributes:{}},i.find((function(t){return t.attributes.field_name===r})));a=Object.assign({},{description:null,label:null,required:!1,settings:{}},a.attributes);var o=Object.assign({},{attributes:{}},s.find((function(t){return t.attributes.field_name===r})));o=Object.assign({},{cardinality:null,settings:{}},o.attributes);var u=r;t.resourceFields&&t.resourceFields[r]&&t.resourceFields[r].publicName!==r&&(u=t.resourceFields[r].publicName),t.fields[u]={id:u,description:a.description,label:{text:a.label,position:n.label},cardinality:o.cardinality,required:a.required,type:n.type,weight:n.weight,settings:{config:a.settings,display:n.settings,storage:o.settings},thirdPartySettings:n.third_party_settings}};for(var n in e.attributes.content)r(n);return this.schema={id:this.id,resourceType:this.resourceType,fields:Object.values(this.fields).sort((function(t,e){return t.weight-e.weight})),groups:[],config:this.config},this.schema},n.prototype.view=async function(){var t=this,e=await this.getResources("entity_view_display--entity_view_display",{"filter[drupal_internal__id]":this.displayId}).then((function(t){return Array.isArray(t)?t[0]:t}));if(!e)return!1;var i=await this.getResources("field_config--field_config",{"filter[entity_type]":this.config.entityType,"filter[bundle]":this.config.bundle});if(!i)return!1;var s=function(s){var r=Object.assign({},{id:null,label:null,type:null,weight:null,settings:{},third_party_settings:{}},e.attributes.content[s]),n=Object.assign({},{attributes:{}},i.find((function(t){return t.attributes.field_name===s})));n=Object.assign({},{description:null,label:null,required:!1,settings:{}},n.attributes);var a=s;t.resourceFields&&t.resourceFields[s]&&t.resourceFields[s].publicName!==s&&(a=t.resourceFields[s].publicName),t.fields[a]={id:a,description:n.description,label:{text:n.label,position:r.label},required:n.required,type:r.type,weight:r.weight,settings:{config:n.settings,display:r.settings},thirdPartySettings:r.third_party_settings}};for(var r in e.attributes.content)s(r);return this.schema={id:this.id,resourceType:this.resourceType,fields:Object.values(this.fields).sort((function(t,e){return t.weight-e.weight})),groups:[],config:this.config},this.schema};var a=function(t,e){if(void 0===e&&(e={}),!t)throw new Error("The 'baseURL' parameter is required.");this.options=Object.assign({},{auth:{type:!1},schema:{filter:[]}},e),this.druxtRouter=new s.DruxtRouter(t,this.options)};a.prototype.get=async function(){var t=await this.druxtRouter.getIndex(),e={};for(var i of["view","form"]){var s="entity_"+i+"_display--entity_"+i+"_display",r=await this.druxtRouter.getResources(s);for(var n of r){var a=t[[n.attributes.targetEntityType,n.attributes.bundle].join("--")],o=Object.assign({},{entityType:n.attributes.targetEntityType,bundle:n.attributes.bundle,mode:n.attributes.mode,schemaType:i,filter:this.options.schema.filter},a),u=await this.getSchema(o,{data:n});u&&(e[u.id]=u.schema)}}return{index:t,schemas:e}},a.prototype.getSchema=async function(t,e){void 0===e&&(e={});var i=new n(t,Object.assign({},{druxtSchema:this},e));return!!i.isValid&&(await i.generate(),i)};var o={props:{mode:{type:String,default:"default"},type:{type:String,required:!0}},fetch:async function(){this.schema=await this.getSchema({resourceType:this.type,mode:this.mode})},data:function(){return{schema:!1}},methods:Object.assign({},r.mapActions({getSchema:"druxtSchema/get"}))};return t.DruxtSchema=a,t.DruxtSchemaMixin=o,t.DruxtSchemaStore=function(t){var e=t.store;if(void 0===e)throw new TypeError("Vuex store not found.");var i="druxtSchema",s={namespaced:!0,state:function(){return{schemas:{}}},mutations:{addSchema:function(t,e){var i=e.id,s=e.schema;t.schemas[i]=s}},actions:{get:async function(t,e){var i=t.state,s=t.commit;if(void 0===e&&(e={}),!(e=Object.assign({},{id:null,resourceType:null,entityType:"node",bundle:null,mode:"default",schemaType:"view"},e)).id&&e.resourceType&&(e.id=[e.resourceType,e.mode,e.schemaType].join("--")),!e.id&&e.bundle&&(e.id=[e.entityType,e.bundle,e.mode,e.schemaType].join("--")),!e.id)return!1;if(!i.schemas[e.id]){var r=await this.$druxtSchema.import(e.id);s("addSchema",{id:e.id,schema:r})}return i.schemas[e.id]}}};e.registerModule(i,s,{preserveState:Boolean(e.state[i])})},t.default=function(t){var s=this;if(void 0===this.options||!this.options.druxt)throw new TypeError("Druxt settings missing.");var r=this.options.druxt;this.addPlugin({src:i.resolve(__dirname,"../nuxt/plugin.js"),fileName:"druxt-schema.js",options:r}),this.addPlugin({src:i.resolve(__dirname,"../nuxt/store.js"),fileName:"store/druxt-schema.js",options:r}),this.nuxt.hook("builder:prepared",(async function(t,n){var o=new a(r.baseUrl,r),u=(await o.get()).schemas;for(var c in u){var d=u[c];void 0!==d&&s.addTemplate({src:i.resolve(__dirname,"../nuxt/schema.json"),fileName:"schemas/"+c+".json",options:{schema:d}})}e.success("Druxt schema generated")}))},t}({},consola,path,druxtRouter,vuex); | ||
var VueDrupalSchema=function(t,e,i,s,r){"use strict";e=e&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e;var n=function(t,e){var i=e.druxtSchema,s=e.data;if(t.resourceFields&&(this.resourceFields=t.resourceFields,delete t.resourceFields),this.config=Object.assign({},{entityType:"node",bundle:null,mode:"default",schemaType:"view",filter:[]},t),!this.id&&this.config.resourceType&&(this.id=[this.config.resourceType,this.config.mode,this.config.schemaType].join("--")),!this.id&&this.config.bundle&&(this.id=[this.config.entityType,this.config.bundle,this.config.mode,this.config.schemaType].join("--")),this.isValid=!0,this.config.filter.length>0)for(var r of(this.isValid=!1,this.config.filter)){if(this.id.match(r)){this.isValid=!0;break}}this.displayId=[this.config.entityType,this.config.bundle,this.config.mode].join("."),this.resourceType=[this.config.entityType,this.config.bundle].join("--"),this.data={},void 0!==s&&(this.data[s.type]=s),this.fields={},this.druxtSchema=i};n.prototype.generate=async function(){return this[this.config.schemaType]()},n.prototype.getResources=async function(t,e){return this.data[t]||(this.data[t]=await this.druxtSchema.druxtRouter.getResources(t,e)),this.data[t]},n.prototype.form=async function(){var t=this,e=await this.getResources("entity_form_display--entity_form_display",{"filter[drupal_internal__id]":this.displayId}).then((function(t){return Array.isArray(t)?t[0]:t}));if(!e)return!1;var i=await this.getResources("field_config--field_config",{"filter[entity_type]":this.config.entityType,"filter[bundle]":this.config.bundle});if(!i)return!1;var s=await this.getResources("field_storage_config--field_storage_config",{"filter[entity_type]":this.config.entityType});if(!s)return!1;var r=function(r){var n=Object.assign({},{id:null,label:null,type:null,weight:null,settings:{},third_party_settings:{}},e.attributes.content[r]),a=Object.assign({},{attributes:{}},i.find((function(t){return t.attributes.field_name===r})));a=Object.assign({},{description:null,label:null,required:!1,settings:{}},a.attributes);var o=Object.assign({},{attributes:{}},s.find((function(t){return t.attributes.field_name===r})));o=Object.assign({},{cardinality:null,settings:{}},o.attributes);var u=r;t.resourceFields&&t.resourceFields[r]&&t.resourceFields[r].publicName!==r&&(u=t.resourceFields[r].publicName),t.fields[u]={id:u,description:a.description,label:{text:a.label,position:n.label},cardinality:o.cardinality,required:a.required,type:n.type,weight:n.weight,settings:{config:a.settings,display:n.settings,storage:o.settings},thirdPartySettings:n.third_party_settings}};for(var n in e.attributes.content)r(n);return this.schema={id:this.id,resourceType:this.resourceType,fields:Object.values(this.fields).sort((function(t,e){return t.weight-e.weight})),groups:[],config:this.config},this.schema},n.prototype.view=async function(){var t=this,e=await this.getResources("entity_view_display--entity_view_display",{"filter[drupal_internal__id]":this.displayId}).then((function(t){return Array.isArray(t)?t[0]:t}));if(!e)return!1;var i=await this.getResources("field_config--field_config",{"filter[entity_type]":this.config.entityType,"filter[bundle]":this.config.bundle});if(!i)return!1;var s=function(s){var r=Object.assign({},{id:null,label:null,type:null,weight:null,settings:{},third_party_settings:{}},e.attributes.content[s]),n=Object.assign({},{attributes:{}},i.find((function(t){return t.attributes.field_name===s})));n=Object.assign({},{description:null,label:null,required:!1,settings:{}},n.attributes);var a=s;t.resourceFields&&t.resourceFields[s]&&t.resourceFields[s].publicName!==s&&(a=t.resourceFields[s].publicName),t.fields[a]={id:a,description:n.description,label:{text:n.label,position:r.label},required:n.required,type:r.type,weight:r.weight,settings:{config:n.settings,display:r.settings},thirdPartySettings:r.third_party_settings}};for(var r in e.attributes.content)s(r);return this.schema={id:this.id,resourceType:this.resourceType,fields:Object.values(this.fields).sort((function(t,e){return t.weight-e.weight})),groups:[],config:this.config},this.schema};var a=function(t,e){if(void 0===e&&(e={}),!t)throw new Error("The 'baseURL' parameter is required.");this.options=Object.assign({},{auth:{type:!1},schema:{filter:[]}},e),this.druxtRouter=new s.DruxtRouter(t,this.options)};a.prototype.get=async function(){var t=await this.druxtRouter.getIndex(),e={};for(var i of["view","form"]){var s="entity_"+i+"_display--entity_"+i+"_display",r=await this.druxtRouter.getResources(s,{},{all:!0});for(var n of r){var a=t[[n.attributes.targetEntityType,n.attributes.bundle].join("--")],o=Object.assign({},{entityType:n.attributes.targetEntityType,bundle:n.attributes.bundle,mode:n.attributes.mode,schemaType:i,filter:this.options.schema.filter},a),u=await this.getSchema(o,{data:n});u&&(e[u.id]=u.schema)}}return{index:t,schemas:e}},a.prototype.getSchema=async function(t,e){void 0===e&&(e={});var i=new n(t,Object.assign({},{druxtSchema:this},e));return!!i.isValid&&(await i.generate(),i)};var o={props:{mode:{type:String,default:"default"},type:{type:String,required:!0}},fetch:async function(){this.schema=await this.getSchema({resourceType:this.type,mode:this.mode})},data:function(){return{schema:!1}},methods:Object.assign({},r.mapActions({getSchema:"druxtSchema/get"}))};return t.DruxtSchema=a,t.DruxtSchemaMixin=o,t.DruxtSchemaStore=function(t){var e=t.store;if(void 0===e)throw new TypeError("Vuex store not found.");var i="druxtSchema",s={namespaced:!0,state:function(){return{schemas:{}}},mutations:{addSchema:function(t,e){var i=e.id,s=e.schema;t.schemas[i]=s}},actions:{get:async function(t,e){var i=t.state,s=t.commit;if(void 0===e&&(e={}),!(e=Object.assign({},{id:null,resourceType:null,entityType:"node",bundle:null,mode:"default",schemaType:"view"},e)).id&&e.resourceType&&(e.id=[e.resourceType,e.mode,e.schemaType].join("--")),!e.id&&e.bundle&&(e.id=[e.entityType,e.bundle,e.mode,e.schemaType].join("--")),!e.id)return!1;if(!i.schemas[e.id]){var r=await this.$druxtSchema.import(e.id);s("addSchema",{id:e.id,schema:r})}return i.schemas[e.id]}}};e.registerModule(i,s,{preserveState:Boolean(e.state[i])})},t.default=function(t){var s=this;if(void 0===this.options||!this.options.druxt)throw new TypeError("Druxt settings missing.");var r=this.options.druxt;this.addPlugin({src:i.resolve(__dirname,"../nuxt/plugin.js"),fileName:"druxt-schema.js",options:r}),this.addPlugin({src:i.resolve(__dirname,"../nuxt/store.js"),fileName:"store/druxt-schema.js",options:r}),this.nuxt.hook("builder:prepared",(async function(t,n){var o=new a(r.baseUrl,r),u=(await o.get()).schemas;for(var c in u){var d=u[c];void 0!==d&&s.addTemplate({src:i.resolve(__dirname,"../nuxt/schema.json"),fileName:"schemas/"+c+".json",options:{schema:d}})}e.success("Druxt schema generated")}))},t}({},consola,path,druxtRouter,vuex); |
@@ -253,3 +253,3 @@ 'use strict';Object.defineProperty(exports,'__esModule',{value:true});function _interopDefault(e){return(e&&(typeof e==='object')&&'default'in e)?e['default']:e}var consola=_interopDefault(require('consola')),path=require('path'),druxtRouter=require('druxt-router'),vuex=require('vuex');/** | ||
var resourceType = "entity_" + schemaType + "_display--entity_" + schemaType + "_display"; | ||
var displays = await this.druxtRouter.getResources(resourceType); | ||
var displays = await this.druxtRouter.getResources(resourceType, {}, { all: true }); | ||
@@ -256,0 +256,0 @@ for (var display of displays) { |
{ | ||
"name": "druxt-schema", | ||
"version": "0.6.1", | ||
"version": "0.6.2", | ||
"description": "Entity Form and View mode schemas for Drupal driven frontends.", | ||
@@ -5,0 +5,0 @@ "repository": { |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
43797