forked from bombastictranz/demo-editor
-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
334.04664df1.chunk.js.download
1 lines (1 loc) · 6.45 KB
/
334.04664df1.chunk.js.download
1
(this["[email protected]/app"]=this["[email protected]/app"]||[]).push([[334],{6322:function(module,__webpack_exports__,__webpack_require__){"use strict";__webpack_require__.r(__webpack_exports__),__webpack_require__.d(__webpack_exports__,"BuilderDataPlugin",function(){return BuilderDataPlugin});var _emotion_react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__=__webpack_require__(0),lodash__WEBPACK_IMPORTED_MODULE_1__=__webpack_require__(6),lodash__WEBPACK_IMPORTED_MODULE_1___default=__webpack_require__.n(lodash__WEBPACK_IMPORTED_MODULE_1__),mobx__WEBPACK_IMPORTED_MODULE_2__=__webpack_require__(4),react__WEBPACK_IMPORTED_MODULE_3__=__webpack_require__(3),react__WEBPACK_IMPORTED_MODULE_3___default=__webpack_require__.n(react__WEBPACK_IMPORTED_MODULE_3__),_components_TextLink__WEBPACK_IMPORTED_MODULE_4__=__webpack_require__(84),_constants_app_state_constant__WEBPACK_IMPORTED_MODULE_5__=__webpack_require__(1),_functions_human_case_function__WEBPACK_IMPORTED_MODULE_6__=__webpack_require__(73),_functions_update_query_param_function__WEBPACK_IMPORTED_MODULE_7__=__webpack_require__(100),_models_query_model__WEBPACK_IMPORTED_MODULE_8__=__webpack_require__(152);Promise.all([__webpack_require__.e(0),__webpack_require__.e(1),__webpack_require__.e(2),__webpack_require__.e(3),__webpack_require__.e(234)]).then(__webpack_require__.bind(null,5962));const BuilderDataPlugin={name:"Builder.io",icon:"https://cdn.builder.io/api/v1/image/assets%2FYJIGb4i01jvw0SRdL5Bt%2F3b5fbb631f084b0ab8cf42f038168557?width=400",noResourceTypesFoundMessage:Object(_emotion_react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.c)("span",{children:["No"," ",Object(_emotion_react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.b)(_components_TextLink__WEBPACK_IMPORTED_MODULE_4__.a,Object.assign({target:"_blank",href:"https://www.builder.io/c/docs/guides/getting-started-with-models"},{children:"data models"}))," ","found, have you created any?"]}),getResourceTypes:async()=>{var _a,_b,_c;const localeInput=!((_a=_constants_app_state_constant__WEBPACK_IMPORTED_MODULE_5__.appState.user.organization)===null||_a===void 0)&&_a.value.allowLocaleParam?[{name:"locale",type:"text",enum:[...((_c=(_b=_constants_app_state_constant__WEBPACK_IMPORTED_MODULE_5__.appState.user.organization)===null||_b===void 0?void 0:_b.value.customTargetingAttributes.get("locale"))===null||_c===void 0?void 0:_c.get("enum"))||[]].map(locale=>({value:locale,label:locale})).concat([{label:"Dynamic (bound to state)",value:"{{state.locale}}"}])}]:[];return _constants_app_state_constant__WEBPACK_IMPORTED_MODULE_5__.appState.models.result.filter(model=>model.type!=="page"&&!model.archived).map(model=>{const locales=model.type==="data"?localeInput:[];return{name:model.humanName,id:model.id,description:model.helperText,entryInputs:()=>locales,inputs:()=>[...locales,{name:"limit",type:"number",defaultValue:10,showIf:"!options.get('single')"},{name:"query",type:"BuilderModelQueryEditor",defaultValue:[],options:mobx__WEBPACK_IMPORTED_MODULE_2__.observable.map({model}),advanced:!0},{name:"orderBy",type:"string",defaultValue:"priority",advanced:!0,showIf:"!options.get('single')",enum:[{label:"Priority",value:"priority"}].concat(model.fields.map(item=>({label:Object(_functions_human_case_function__WEBPACK_IMPORTED_MODULE_6__.a)(item.name),value:"data."+item.name})))},{name:"orderType",type:"string",defaultValue:"descending",enum:["ascending","descending"],showIf:"options.get('orderBy') && !options.get('single')",advanced:!0},{name:"single",type:"boolean",defaultValue:!1,helperText:"Turn on to query a single matching entry instead of a list",advanced:!0},{name:"respectScheduling",type:"boolean",defaultValue:!0,helperText:"Turn off to list all entries regardless of scheduling",advanced:!0},{name:"omit",type:"string",defaultValue:"data.blocks",helperText:'A comma separated list of paths to omit from the response, e.g. "id,data.blocks',advanced:!0}],toUrl:options=>{var _a2;console.log("TO URL");const entry=options.entry!=="_new"&&options.entry;let url=`${_constants_app_state_constant__WEBPACK_IMPORTED_MODULE_5__.appState.config.contentApiRoot()}/${model.name}${entry?`/${entry}`:""}?apiKey=${_constants_app_state_constant__WEBPACK_IMPORTED_MODULE_5__.appState.user.apiKey}&includeRefs=true&fields=data`;if(!entry&&options.orderBy&&(options.orderBy!=="priority"||options.orderType!=="descending")&&(url=Object(_functions_update_query_param_function__WEBPACK_IMPORTED_MODULE_7__.b)(url,{[`sort.${options.orderBy}`]:String(options.orderType==="ascending"?1:-1)})),entry||(url=Object(_functions_update_query_param_function__WEBPACK_IMPORTED_MODULE_7__.b)(url,{limit:options.limit||10})),options.single&&(url=Object(_functions_update_query_param_function__WEBPACK_IMPORTED_MODULE_7__.b)(url,{single:"true"})),options.omit&&(url=Object(_functions_update_query_param_function__WEBPACK_IMPORTED_MODULE_7__.b)(url,{omit:options.omit})),options.respectScheduling===!0&&(url=Object(_functions_update_query_param_function__WEBPACK_IMPORTED_MODULE_7__.b)(url,{"userAttributes.respectScheduling":"true"})),!((_a2=options.query)===null||_a2===void 0)&&_a2.length){const mongoQuery=Object(_models_query_model__WEBPACK_IMPORTED_MODULE_8__.d)(options.query).query;mongoQuery.data&&(url=Object(_functions_update_query_param_function__WEBPACK_IMPORTED_MODULE_7__.b)(url,{"query.data":JSON.stringify(mongoQuery.data)}))}return options.locale&&(url=`${url}&locale=${options.locale}`),url},canPickEntries:!0}})},getEntriesByResourceType:async(resourceTypeId,options={})=>{var _a;const model=(_a=_constants_app_state_constant__WEBPACK_IMPORTED_MODULE_5__.appState.models)===null||_a===void 0?void 0:_a.result.find(item=>item.id===resourceTypeId);let contentUrl=`${_constants_app_state_constant__WEBPACK_IMPORTED_MODULE_5__.appState.config.contentApiRoot()}/${model.name}${options.resourceEntryId?`/${options.resourceEntryId}`:""}?apiKey=${_constants_app_state_constant__WEBPACK_IMPORTED_MODULE_5__.appState.user.apiKey}&cachebust=true&limit=50&omit=data.blocks,data.jsCode,data.cssCode,query`;options.searchText&&(contentUrl=Object(_functions_update_query_param_function__WEBPACK_IMPORTED_MODULE_7__.b)(contentUrl,{"query.name":JSON.stringify({$regex:".*"+Object(lodash__WEBPACK_IMPORTED_MODULE_1__.escapeRegExp)(options.searchText.replace(/\W/g,""))+".*",$options:"i"})}));const response=await fetch(contentUrl).then(res=>res.json());return options.resourceEntryId?[response]:response.results.map(result=>({id:result.id,name:result.name}))}};_constants_app_state_constant__WEBPACK_IMPORTED_MODULE_5__.appState.registerDataPlugin(BuilderDataPlugin)}}]);