UNPKG

scrivito

Version:

Scrivito is a professional, yet easy to use SaaS Enterprise Content Management Service, built for digital agencies and medium to large businesses. It is completely maintenance-free, cost-effective, and has unprecedented performance and security.

1,498 lines (1,376 loc) 906 kB
(function webpackUniversalModuleDefinition(root, factory) { if(typeof exports === 'object' && typeof module === 'object') module.exports = factory(require("@justrelate/slugify"), require("lodash-es/debounce"), require("lodash-es/escape"), require("lodash-es/isDate"), require("lodash-es/isEmpty"), require("lodash-es/isEqual"), require("lodash-es/mapValues"), require("lodash-es/memoize"), require("lodash-es/merge"), require("lodash-es/sortBy"), require("lodash-es/unescape"), require("react"), require("react-dom")); else if(typeof define === 'function' && define.amd) define(["@justrelate/slugify", "lodash-es/debounce", "lodash-es/escape", "lodash-es/isDate", "lodash-es/isEmpty", "lodash-es/isEqual", "lodash-es/mapValues", "lodash-es/memoize", "lodash-es/merge", "lodash-es/sortBy", "lodash-es/unescape", "react", "react-dom"], factory); else if(typeof exports === 'object') exports["scrivito"] = factory(require("@justrelate/slugify"), require("lodash-es/debounce"), require("lodash-es/escape"), require("lodash-es/isDate"), require("lodash-es/isEmpty"), require("lodash-es/isEqual"), require("lodash-es/mapValues"), require("lodash-es/memoize"), require("lodash-es/merge"), require("lodash-es/sortBy"), require("lodash-es/unescape"), require("react"), require("react-dom")); else root["scrivito"] = factory(root["@justrelate/slugify"], root["lodash-es/debounce"], root["lodash-es/escape"], root["lodash-es/isDate"], root["lodash-es/isEmpty"], root["lodash-es/isEqual"], root["lodash-es/mapValues"], root["lodash-es/memoize"], root["lodash-es/merge"], root["lodash-es/sortBy"], root["lodash-es/unescape"], root["react"], root["react-dom"]); })((typeof self !== 'undefined' ? self : global), (__WEBPACK_EXTERNAL_MODULE__5929__, __WEBPACK_EXTERNAL_MODULE__16__, __WEBPACK_EXTERNAL_MODULE__3444__, __WEBPACK_EXTERNAL_MODULE__8307__, __WEBPACK_EXTERNAL_MODULE__5020__, __WEBPACK_EXTERNAL_MODULE__9477__, __WEBPACK_EXTERNAL_MODULE__7885__, __WEBPACK_EXTERNAL_MODULE__721__, __WEBPACK_EXTERNAL_MODULE__2925__, __WEBPACK_EXTERNAL_MODULE__5682__, __WEBPACK_EXTERNAL_MODULE__3655__, __WEBPACK_EXTERNAL_MODULE__629__, __WEBPACK_EXTERNAL_MODULE__400__) => { return /******/ (() => { // webpackBootstrap /******/ "use strict"; /******/ var __webpack_modules__ = ({ /***/ 16: /***/ ((module) => { module.exports = __WEBPACK_EXTERNAL_MODULE__16__; /***/ }), /***/ 93: /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { /* harmony export */ __webpack_require__.d(__webpack_exports__, { /* harmony export */ I: () => (/* binding */ hasComponent) /* harmony export */ }); /* harmony import */ var scrivito_sdk_react_component_registry__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(9242); function hasComponent(name) { return !!(0,scrivito_sdk_react_component_registry__WEBPACK_IMPORTED_MODULE_0__/* .getComponentForAppClass */ .cb)(name); } /***/ }), /***/ 279: /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { /* harmony export */ __webpack_require__.d(__webpack_exports__, { /* harmony export */ eW: () => (/* binding */ importFrom) /* harmony export */ }); /* unused harmony exports provideLoadedEditingModule, isEditingModuleBeingLoaded */ /* harmony import */ var scrivito_sdk_app_support_ui_adapter__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(1391); /* harmony import */ var scrivito_sdk_loadable__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(5986); const moduleLoaders = { reactEditing: () => __webpack_require__.e(/* import() */ 723).then(__webpack_require__.bind(__webpack_require__, 6508)), editingSupport: () => __webpack_require__.e(/* import() */ 723).then(__webpack_require__.bind(__webpack_require__, 8403)) }; const loadableModules = (0,scrivito_sdk_loadable__WEBPACK_IMPORTED_MODULE_1__/* .createLoadableCollection */ .rL)({ loadElement: (moduleName) => ({ loader: moduleLoaders[moduleName] }) }); function importFrom(moduleName, symbol) { if (!scrivito_sdk_app_support_ui_adapter__WEBPACK_IMPORTED_MODULE_0__/* .uiAdapter */ .B) return; const loadable = loadableModules.get(moduleName); const loadedModule = loadable.get(); if (!loadedModule) return; return loadedModule[symbol]; } function provideLoadedEditingModule(moduleName, editingModule) { loadableModules.get(moduleName).set(editingModule); } function isEditingModuleBeingLoaded(moduleName) { return loadableModules.get(moduleName).numSubscribers() > 0; } /***/ }), /***/ 400: /***/ ((module) => { module.exports = __WEBPACK_EXTERNAL_MODULE__400__; /***/ }), /***/ 629: /***/ ((module) => { module.exports = __WEBPACK_EXTERNAL_MODULE__629__; /***/ }), /***/ 671: /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { /* harmony export */ __webpack_require__.d(__webpack_exports__, { /* harmony export */ $V: () => (/* binding */ getCurrentRoute), /* harmony export */ OU: () => (/* binding */ withCurrentPageContext), /* harmony export */ Vd: () => (/* binding */ getCurrentPageData), /* harmony export */ tj: () => (/* binding */ setNavigationStateProvider), /* harmony export */ uR: () => (/* binding */ getNotFoundErrorPageState) /* harmony export */ }); /* harmony import */ var scrivito_sdk_app_support_current_app_space__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(2945); /* harmony import */ var scrivito_sdk_app_support_routing__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(1446); /* harmony import */ var scrivito_sdk_common__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(7462); /* harmony import */ var scrivito_sdk_loadable__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(5986); /* harmony import */ var scrivito_sdk_models__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(1964); var __defProp = Object.defineProperty; var __defProps = Object.defineProperties; var __getOwnPropDescs = Object.getOwnPropertyDescriptors; var __getOwnPropSymbols = Object.getOwnPropertySymbols; var __hasOwnProp = Object.prototype.hasOwnProperty; var __propIsEnum = Object.prototype.propertyIsEnumerable; var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value; var __spreadValues = (a, b) => { for (var prop in b || (b = {})) if (__hasOwnProp.call(b, prop)) __defNormalProp(a, prop, b[prop]); if (__getOwnPropSymbols) for (var prop of __getOwnPropSymbols(b)) { if (__propIsEnum.call(b, prop)) __defNormalProp(a, prop, b[prop]); } return a; }; var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b)); let getCurrentNavigationState = () => void 0; function setNavigationStateProvider(provider) { getCurrentNavigationState = provider; } const navigationContext = new scrivito_sdk_common__WEBPACK_IMPORTED_MODULE_2__/* .ContextContainer */ .hl(); function getCurrentPageData() { return (0,scrivito_sdk_loadable__WEBPACK_IMPORTED_MODULE_3__/* .loadableWithDefault */ .s4)(void 0, () => { var _a; const navigationState = (_a = navigationContext.current()) != null ? _a : getCurrentNavigationState(); if (!navigationState) return void 0; const route = navigationState.locationRoute; if (route.objId) { const currentPage = (0,scrivito_sdk_models__WEBPACK_IMPORTED_MODULE_4__/* .getObjFrom */ .ED)((0,scrivito_sdk_app_support_current_app_space__WEBPACK_IMPORTED_MODULE_0__/* .currentAppSpace */ .p)(), route.objId); if (!currentPage) { return { navigationState: __spreadProps(__spreadValues({}, navigationState), { locationRoute: __spreadProps(__spreadValues({}, route), { objId: void 0 }) }) }; } return { navigationState, currentPage }; } return { navigationState }; }); } function getCurrentRoute() { var _a; const navigationState = (_a = navigationContext.current()) != null ? _a : (0,scrivito_sdk_loadable__WEBPACK_IMPORTED_MODULE_3__/* .loadableWithDefault */ .s4)(void 0, getCurrentNavigationState); return navigationState == null ? void 0 : navigationState.locationRoute; } function withCurrentPageContext(context, fn) { return navigationContext.runWith( { locationRoute: { objId: context.page.id(), sitePath: context.sitePath, siteData: { siteId: context.siteId, baseUrl: context.baseUrl } }, historyState: { historyChangesCount: 0, location: `${context.baseUrl}${context.sitePath}`, isRevisit: false } }, fn ); } function getNotFoundErrorPageState() { var _a; if (navigationContext.current()) return; const navigationState = (_a = getCurrentPageData()) == null ? void 0 : _a.navigationState; if (!navigationState) return; if (!(0,scrivito_sdk_app_support_routing__WEBPACK_IMPORTED_MODULE_1__/* .isObjNotFoundRoute */ .UO)(navigationState.locationRoute)) return; return navigationState; } /***/ }), /***/ 687: /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { // EXPORTS __webpack_require__.d(__webpack_exports__, { N_: () => (/* reexport */ Link), OH: () => (/* reexport */ Obj), mZ: () => (/* reexport */ ObjFacetValue), G5: () => (/* reexport */ ObjSearch), Sj: () => (/* reexport */ Schema), x0: () => (/* reexport */ Widget), Pi: () => (/* reexport */ allObjClasses), Yh: () => (/* reexport */ allWidgetClasses), KZ: () => (/* reexport */ createObjClass), dl: () => (/* reexport */ createWidgetClass), w5: () => (/* reexport */ enableStrictSearchOperators), an: () => (/* reexport */ getRealmClass), Xg: () => (/* reexport */ isBinaryBasicObj), I6: () => (/* reexport */ isObjClass), Hk: () => (/* reexport */ registerObjClass), C4: () => (/* reexport */ registerWidgetClass), e6: () => (/* reexport */ schemaFromBasicObjOrWidget), kI: () => (/* reexport */ setCurrentSiteIdHandler), OE: () => (/* reexport */ unwrapAppAttributes), zo: () => (/* reexport */ unwrapAppClass), Dy: () => (/* reexport */ wrapInAppClass) }); // EXTERNAL MODULE: ./scrivito_sdk/models/index.ts + 39 modules var models = __webpack_require__(1964); // EXTERNAL MODULE: ./scrivito_sdk/common/index.ts + 63 modules var common = __webpack_require__(7462); // EXTERNAL MODULE: external "lodash-es/mapValues" var mapValues_ = __webpack_require__(7885); var mapValues_default = /*#__PURE__*/__webpack_require__.n(mapValues_); ;// ./scrivito_sdk/realm/assert_valid_attribute_name.ts function assertValidAttributeName(attributeName) { if (!(0,common/* isCamelCase */.Dz)(attributeName)) { throw new common/* ArgumentError */.c1("Attribute names have to be in camel case."); } if ((0,common/* isSystemAttribute */.iI)(attributeName)) { throw new common/* ArgumentError */.c1( `Attribute name "${attributeName}" is not a valid custom attribute name.` ); } } // EXTERNAL MODULE: ./scrivito_sdk/realm/initial_content_registry.ts var initial_content_registry = __webpack_require__(1645); ;// ./scrivito_sdk/realm/initial_attributes_for.ts function initialAttributesFor(providedAttributes, schema, appClassName) { const initialAttributes = {}; Object.keys(schema.attributes()).forEach((attributeName) => { if (!Object.prototype.hasOwnProperty.call(providedAttributes, attributeName)) { const initialValue = (0,initial_content_registry/* initialContentFor */.h)(appClassName, attributeName); if (initialValue !== void 0) { initialAttributes[attributeName] = initialValue; } } }); return initialAttributes; } ;// ./scrivito_sdk/realm/schema.ts var __defProp = Object.defineProperty; var __defProps = Object.defineProperties; var __getOwnPropDescs = Object.getOwnPropertyDescriptors; var __getOwnPropSymbols = Object.getOwnPropertySymbols; var __hasOwnProp = Object.prototype.hasOwnProperty; var __propIsEnum = Object.prototype.propertyIsEnumerable; var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value; var __spreadValues = (a, b) => { for (var prop in b || (b = {})) if (__hasOwnProp.call(b, prop)) __defNormalProp(a, prop, b[prop]); if (__getOwnPropSymbols) for (var prop of __getOwnPropSymbols(b)) { if (__propIsEnum.call(b, prop)) __defNormalProp(a, prop, b[prop]); } return a; }; var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b)); var __objRest = (source, exclude) => { var target = {}; for (var prop in source) if (__hasOwnProp.call(source, prop) && exclude.indexOf(prop) < 0) target[prop] = source[prop]; if (source != null && __getOwnPropSymbols) for (var prop of __getOwnPropSymbols(source)) { if (exclude.indexOf(prop) < 0 && __propIsEnum.call(source, prop)) target[prop] = source[prop]; } return target; }; class Schema { constructor(classDefinition, parentClass) { this.parentClass = parentClass; const parentSchema = this.parentClass._scrivitoPrivateSchema; const basicAttributeDefinitions = parentSchema ? __spreadValues({}, parentSchema.attributes()) : {}; const _a = classDefinition, { attributes: rawAttributeDefinitions, onlyInside: rawOnlyInside, onlyChildren: rawOnlyChildren } = _a, restOfRawDefinition = __objRest(_a, [ "attributes", "onlyInside", "onlyChildren" ]); if (rawAttributeDefinitions) { Object.keys(rawAttributeDefinitions).forEach((name) => { basicAttributeDefinitions[name] = toBasicAttributeDefinition( rawAttributeDefinitions[name] ); }); } const onlyChildren = toArrayOfStrings(rawOnlyChildren); const onlyInside = toArrayOfStrings(rawOnlyInside); if (onlyChildren) { this.basicClassDefinition = __spreadProps(__spreadValues({}, restOfRawDefinition), { attributes: basicAttributeDefinitions, onlyChildren, onlyInside }); } else { this.basicClassDefinition = __spreadProps(__spreadValues({}, restOfRawDefinition), { attributes: basicAttributeDefinitions, onlyInside }); } } static forInstance(model) { return Schema.forClass(model.constructor); } static forClass(klass) { return klass._scrivitoPrivateSchema; } static basicFieldFor(model, attributeName) { const schema = Schema.forInstance(model); if (!schema) return null; const typeInfo = schema.attribute(attributeName); if (!typeInfo) return null; return new models/* BasicField */.$e( model._scrivitoPrivateContent, attributeName, typeInfo ); } attributes() { return this.basicClassDefinition.attributes; } normalizedAttributes() { const attributes = this.attributes(); const normalizedAttributes = {}; Object.keys(attributes).forEach((name) => { normalizedAttributes[name] = toNormalizedAttributeDefinition( attributes[name] ); }); return normalizedAttributes; } extractTextAttributes() { return this.basicClassDefinition.extractTextAttributes || []; } name() { return this.basicClassDefinition.name; } onlyInside() { return this.basicClassDefinition.onlyInside; } onlyChildren() { return this.basicClassDefinition.onlyChildren; } validAsRoot() { return this.basicClassDefinition.validAsRoot; } onlyAsRoot() { return this.basicClassDefinition.onlyAsRoot; } attribute(name) { return this.attributes()[name]; } isBinary() { const blobDefinition = this.attribute("blob"); if (!blobDefinition) return false; return blobDefinition[0] === "binary"; } parent() { return this.parentClass; } } function isAppClass(object) { return !!(object && object._scrivitoPrivateSchema); } function toBasicAttributeDefinition(attrDefinition) { if (typeof attrDefinition === "string") return [attrDefinition]; const type = attrDefinition[0]; if (type === "enum" || type === "multienum") return [type, attrDefinition[1]]; const _a = attrDefinition[1], { only } = _a, otherOptions = __objRest(_a, ["only"]); const validClasses = typeof only === "string" ? [only] : only; if (type === "widgetlist" && !validClasses && attrDefinition[1].maximum) { return ["widgetlist", { maximum: attrDefinition[1].maximum }]; } return validClasses ? [type, __spreadProps(__spreadValues({}, otherOptions), { validClasses })] : [type]; } function toNormalizedAttributeDefinition(definition) { if (definition.length === 1) return [definition[0], {}]; switch (definition[0]) { case "reference": case "referencelist": case "widget": case "widgetlist": { const _a = definition[1], { validClasses: only } = _a, otherConfig = __objRest(_a, ["validClasses"]); return [definition[0], only ? __spreadValues({ only }, otherConfig) : otherConfig]; } } return definition; } function toArrayOfStrings(value) { if (typeof value === "string") return [value]; if (value == null ? void 0 : value.length) return value; } ;// ./scrivito_sdk/realm/sub_widgets.ts function subWidgets(content) { const contentSchema = schemaFromBasicObjOrWidget(content); if (!contentSchema) return []; const attributes = contentSchema.attributes(); return Object.keys(attributes).reduce((memo, attrName) => { const [attrType] = attributes[attrName]; if (attrType === "widget") { const widget = content.get(attrName, "widget"); if (widget) return [...memo, widget, ...subWidgets(widget)]; } if (attrType === "widgetlist") { const widgets = content.get(attrName, "widgetlist"); return Array.prototype.concat( memo, ...widgets.map((widget) => [widget, ...subWidgets(widget)]) ); } return memo; }, []); } ;// ./scrivito_sdk/realm/widget.ts var widget_defProp = Object.defineProperty; var widget_defProps = Object.defineProperties; var widget_getOwnPropDescs = Object.getOwnPropertyDescriptors; var widget_getOwnPropSymbols = Object.getOwnPropertySymbols; var widget_hasOwnProp = Object.prototype.hasOwnProperty; var widget_propIsEnum = Object.prototype.propertyIsEnumerable; var widget_defNormalProp = (obj, key, value) => key in obj ? widget_defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value; var widget_spreadValues = (a, b) => { for (var prop in b || (b = {})) if (widget_hasOwnProp.call(b, prop)) widget_defNormalProp(a, prop, b[prop]); if (widget_getOwnPropSymbols) for (var prop of widget_getOwnPropSymbols(b)) { if (widget_propIsEnum.call(b, prop)) widget_defNormalProp(a, prop, b[prop]); } return a; }; var widget_spreadProps = (a, b) => widget_defProps(a, widget_getOwnPropDescs(b)); class Widget { constructor(attributes = {}) { const appClassName = objClassNameFor(this.constructor); if (!appClassName) { throw new common/* ArgumentError */.c1( "Use a specific class (like TextWidget or ImageWidget) to create a Widget." ); } assertValidAttributes(attributes); const schema = Schema.forInstance(this); if (!schema) throw new common/* InternalError */.Gd(); const basicAttributes = unwrapAppAttributes( widget_spreadProps(widget_spreadValues({}, attributes), { _objClass: appClassName }), schema, appClassName ); const basicWidget = models/* BasicWidget */.$R.createWithUnknownValues(basicAttributes); basicWidget.onDidPersist((copiedWidget) => { const appWidget = wrapInAppClass(copiedWidget); const initialAttributes = initialAttributesFor( basicAttributes, schema, appClassName ); updateAppAttributes(appWidget, initialAttributes); }); this._scrivitoPrivateContent = basicWidget; } static attributeDefinitions() { const schema = Schema.forClass(this); if (!schema) return {}; return schema.normalizedAttributes(); } id() { return this._scrivitoPrivateContent.id(); } objClass() { return this._scrivitoPrivateContent.objClass(); } get(attributeName) { assertValidAttributeName(attributeName); return readAppAttribute(this, attributeName); } update(attributes) { updateAppAttributes(this, attributes); } obj() { const basicObj = this._scrivitoPrivateContent.obj(); return wrapInAppClass(basicObj); } widgets() { return wrapInAppClass(subWidgets(this._scrivitoPrivateContent)); } copy() { const basicWidget = this._scrivitoPrivateContent.copy(); return wrapInAppClass(basicWidget); } /** @deprecated Use `Widget#delete` instead */ destroy() { this.delete(); } delete() { this._scrivitoPrivateContent.delete(); } container() { const container = this._scrivitoPrivateContent.container(); return wrapInAppClass(container); } attributeDefinitions() { const schema = Schema.forInstance(this); if (!schema) return {}; return schema.normalizedAttributes(); } } function assertValidAttributes(attributes) { if (attributes.constructor !== Object) { throw new common/* ArgumentError */.c1( "The provided attributes are invalid. They have to be an Object with valid Scrivito attribute values." ); } if (attributes._objClass) { throw new common/* ArgumentError */.c1( `Invalid attribute "_objClass". "new ${String( attributes._objClass )}" will automatically set the CMS object class correctly.` ); } } ;// ./scrivito_sdk/realm/registry.ts let mapping = {}; function registerRealmClass(name, klass) { mapping[name] = klass; } function getRealmClass(name) { return mapping[name] || null; } function objClassNameFor(modelClass) { return Object.keys(mapping).find((klass) => mapping[klass] === modelClass) || null; } function appClassFor(name, baseClass) { const appClass = getRealmClass(name); return appClass && baseClass.isPrototypeOf(appClass) ? appClass : baseClass; } function allObjClasses() { return Object.fromEntries( Object.entries(mapping).filter( ([, modelClass]) => Obj.isPrototypeOf(modelClass) ) ); } function allWidgetClasses() { return Object.fromEntries( Object.entries(mapping).filter( ([, modelClass]) => Widget.isPrototypeOf(modelClass) ) ); } function objClassFor(name) { return appClassFor(name, Obj); } function widgetClassFor(name) { return appClassFor(name, Widget); } (0,common/* onReset */.Nj)(() => mapping = {}); ;// ./scrivito_sdk/realm/wrap_in_app_class.ts function wrapInAppClass(internalValue) { if (Array.isArray(internalValue)) { return internalValue.map((value) => wrapInAppClass(value)).filter((value) => value !== null); } if (internalValue instanceof models/* BasicObj */.kI) { return buildAppClassInstance( internalValue, objClassFor(internalValue.objClass()) ); } if (internalValue instanceof models/* BasicWidget */.$R) { return buildAppClassInstance( internalValue, widgetClassFor(internalValue.objClass()) ); } if (internalValue instanceof models/* BasicLink */.Re) { if (!internalValue.hasDestination()) return null; return buildAppClassInstance(internalValue, Link); } if (internalValue instanceof models/* ObjUnavailable */.Wk) return null; return internalValue; } function unwrapAppClass(value) { if (Array.isArray(value)) return value.map((v) => unwrapAppClass(v)); if (hasPrivateContent(value)) return value._scrivitoPrivateContent; return value; } function unwrapAppAttributes(appAttributes, schema, appClassName) { return mapValues_default()(appAttributes, (value, name) => { if ((0,common/* isSystemAttribute */.iI)(name)) return [value]; const normalizedTypeInfo = schema.attribute(name); if (!normalizedTypeInfo) { throw new common/* ArgumentError */.c1( `Attribute "${name}" is not defined for CMS object class "${appClassName}".` ); } const unwrappedValue = unwrapAppClass(value); return [unwrappedValue, normalizedTypeInfo]; }); } function buildAppClassInstance(internalValue, appClass) { const externalValue = Object.create(appClass.prototype); externalValue._scrivitoPrivateContent = internalValue; return externalValue; } function hasPrivateContent(value) { return !!value && !!value._scrivitoPrivateContent; } ;// ./scrivito_sdk/realm/app_model_accessor.ts function readAppAttribute(model, attributeName) { const basicField = Schema.basicFieldFor( model, attributeName ); return basicField && wrapInAppClass(basicField.get()); } function updateAppAttributes(model, attributes) { const objClass = model.objClass(); const appClass = getRealmClass(objClass); if (!appClass) { let baseClass; if (model.constructor === Obj) { baseClass = "Obj"; } else { baseClass = "Widget"; } throw new common/* ArgumentError */.c1( `Updating is not supported on the base class "${baseClass}".` ); } if (attributes.constructor !== Object) { throw new common/* ArgumentError */.c1( "The provided attributes are invalid. They have to be an Object with valid Scrivito attribute values." ); } const schema = Schema.forInstance(model); const attributesWithTypeInfo = unwrapAppAttributes( attributes, schema, objClass ); model._scrivitoPrivateContent.updateWithUnknownValues(attributesWithTypeInfo); } ;// ./scrivito_sdk/realm/obj_facet_value.ts class ObjFacetValue { /** @internal */ constructor(basicObjFacetValue) { this._basicObjFacetValue = basicObjFacetValue; } name() { return this._basicObjFacetValue.name(); } count() { return this._basicObjFacetValue.count(); } includedObjs() { const response = this._basicObjFacetValue.includedObjs(); return wrapInAppClass(response); } } ;// ./scrivito_sdk/realm/strict_search_operators.ts let strictSearchOperators = false; function enableStrictSearchOperators() { strictSearchOperators = true; } function areStrictSearchOperatorsEnabled() { return strictSearchOperators; } (0,common/* onReset */.Nj)(() => strictSearchOperators = false); ;// ./scrivito_sdk/realm/obj_search.ts class ObjSearch { /** @internal */ constructor(basicSearch) { this._scrivitoPrivateContent = basicSearch; } /** @internal */ and(fieldOrSearchToExtendBy, operator, value, boost) { if (fieldOrSearchToExtendBy instanceof ObjSearch) { const search = fieldOrSearchToExtendBy; this._scrivitoPrivateContent.and(search._scrivitoPrivateContent); } else { if (operator === void 0) { throw new common/* ArgumentError */.c1("Missing operator to search with"); } if (value === void 0) { throw new common/* ArgumentError */.c1( 'Missing value to search (specify "null" for missing)' ); } if (areStrictSearchOperatorsEnabled()) { checkNonFullTextSearchOperator( "objSearch.and", operator, "js-sdk/ObjSearch-and" ); } const field = fieldOrSearchToExtendBy; const unwrappedValue = unwrapAppClassValue(value); this._scrivitoPrivateContent.and(field, operator, unwrappedValue, boost); } return this; } andFullTextOf(field, operator, value, boost) { checkFullTextSearchOperator( "objSearch.andFullTextOf", operator, "js-sdk/ObjSearch-andFullTextOf" ); const unwrappedValue = unwrapAppClassValue(value); this._scrivitoPrivateContent.and(field, operator, unwrappedValue, boost); return this; } andNot(field, operator, value) { const unwrappedValue = unwrapAppClassValue(value); this._scrivitoPrivateContent.andNot(field, operator, unwrappedValue); return this; } andIsChildOf(obj) { this._scrivitoPrivateContent.andIsChildOf(unwrapAppClass(obj)); return this; } andIsInsideSubtreeOf(obj) { this._scrivitoPrivateContent.andIsInsideSubtreeOf(unwrapAppClass(obj)); return this; } boost(field, operator, value, factor) { this._scrivitoPrivateContent.boost( field, operator, unwrapAppClassValue(value), factor ); return this; } facet(attribute, options) { const basicFacets = this._scrivitoPrivateContent.facet(attribute, options); return basicFacets.map((facetValue) => new ObjFacetValue(facetValue)); } suggest(prefix, options) { return this._scrivitoPrivateContent.suggest(prefix, options); } first() { const basicObj = this._scrivitoPrivateContent.first(); if (!basicObj) return null; return wrapInAppClass(basicObj); } /** @internal */ take(count) { const basicObjs = count === void 0 ? this._scrivitoPrivateContent.dangerouslyUnboundedTake() : this._scrivitoPrivateContent.take(count); return basicObjs.map((obj) => wrapInAppClass(obj)); } toArray() { const basicObjs = this._scrivitoPrivateContent.dangerouslyUnboundedTake(); return basicObjs.map((obj) => wrapInAppClass(obj)); } offset(offset) { this._scrivitoPrivateContent.offset(offset); return this; } /** @internal */ order(attributeOrAttributes, direction) { if (Array.isArray(attributeOrAttributes)) { if (direction !== void 0) { throw new common/* ArgumentError */.c1( "Direction can not be set independent of attributes." ); } this._scrivitoPrivateContent.order(attributeOrAttributes); return this; } this._scrivitoPrivateContent.order(attributeOrAttributes, direction); return this; } count() { return this._scrivitoPrivateContent.count(); } } if (typeof Symbol === "function") { const iteratorSymbol = Symbol.iterator; if (iteratorSymbol) { const proto = ObjSearch.prototype; proto[iteratorSymbol] = function iterator() { const basicObjsIterator = this._scrivitoPrivateContent.iterator(); return { next() { const iteratorResult = basicObjsIterator.next(); if (iteratorResult.done) { return { done: iteratorResult.done }; } return { done: iteratorResult.done, value: wrapInAppClass(iteratorResult.value) }; } }; }; } } function unwrapAppClassValue(value) { if (Array.isArray(value)) return value.map((v) => unwrapAppClass(v)); return unwrapAppClass(value); } function checkNonFullTextSearchOperator(functionName, operator, docPermalink) { if (models/* FULL_TEXT_OPERATORS */.Wc.indexOf(operator) !== -1) { (0,common/* throwInvalidArgumentsError */.Ht)( functionName, `operator '${operator}' must be a search operator except: ${models/* FULL_TEXT_OPERATORS */.Wc.join( ", " )}`, { docPermalink } ); } } function checkFullTextSearchOperator(functionName, operator, docPermalink) { if (models/* FULL_TEXT_OPERATORS */.Wc.indexOf(operator) === -1) { (0,common/* throwInvalidArgumentsError */.Ht)( functionName, `operator '${operator}' must be a full text search operator: ${models/* FULL_TEXT_OPERATORS */.Wc.join( ", " )}`, { docPermalink } ); } } ;// ./scrivito_sdk/realm/basic_site_context.ts var basic_site_context_defProp = Object.defineProperty; var basic_site_context_getOwnPropSymbols = Object.getOwnPropertySymbols; var basic_site_context_hasOwnProp = Object.prototype.hasOwnProperty; var basic_site_context_propIsEnum = Object.prototype.propertyIsEnumerable; var basic_site_context_defNormalProp = (obj, key, value) => key in obj ? basic_site_context_defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value; var basic_site_context_spreadValues = (a, b) => { for (var prop in b || (b = {})) if (basic_site_context_hasOwnProp.call(b, prop)) basic_site_context_defNormalProp(a, prop, b[prop]); if (basic_site_context_getOwnPropSymbols) for (var prop of basic_site_context_getOwnPropSymbols(b)) { if (basic_site_context_propIsEnum.call(b, prop)) basic_site_context_defNormalProp(a, prop, b[prop]); } return a; }; var __async = (__this, __arguments, generator) => { return new Promise((resolve, reject) => { var fulfilled = (value) => { try { step(generator.next(value)); } catch (e) { reject(e); } }; var rejected = (value) => { try { step(generator.throw(value)); } catch (e) { reject(e); } }; var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected); step((generator = generator.apply(__this, __arguments)).next()); }); }; class BasicSiteContext { constructor(objClass, scopeIncludingDeletedObjs) { this.objClass = objClass; this.scopeIncludingDeletedObjs = scopeIncludingDeletedObjs; } get(id) { return this.getObj(id, this.scope()); } getIncludingDeleted(id) { return this.getObj(id, this.scopeIncludingDeletedObjs); } getByPath(path) { const obj = (0,models/* getObjBy */.Z0)(this.scope().and(models/* excludeGlobal */.S$), "_path", path); return wrapInAppClass(obj); } getByPermalink(permalink) { const obj = (0,models/* getObjBy */.Z0)(this.scope(), "_permalink", permalink); return wrapInAppClass(obj); } root() { return wrapInAppClass((0,models/* getRootObjFrom */.Mp)(this.scope())); } all() { return this.getSearch(1e3); } where(attribute, operator, value, boost) { return this.getSearch().and(attribute, operator, value, boost); } whereFullTextOf(attribute, operator, value, boost) { return this.getSearch().andFullTextOf(attribute, operator, value, boost); } create(attributes = {}) { const objClassName = this.objClassNameForCreate(); assertValidCreateAttributes(attributes); const attributesForCreate = prepareAttributesForCreate( attributes, objClassName, // Bang: objClassNameForCreate above ensures that it's a subclass of Obj Schema.forClass(this.objClass) ); const basicObj = (0,models/* createObjIn */.ZU)( this.scope().and((0,models/* restrictToObjClass */.Lw)(objClassName)), attributesForCreate ); return wrapInAppClass(basicObj); } createFromFile(_0) { return __async(this, arguments, function* (file, attributes = {}) { const objClassName = this.objClassNameForCreate(); assertValidFile(file); assertValidCreateAttributes(attributes); if (Object.prototype.hasOwnProperty.call(attributes, "blob")) { throw new common/* ArgumentError */.c1( 'Setting attribute "blob" is not allowed when creating CMS objects from file, because the file will be assigned to that attribute' ); } const schema = Schema.forClass(this.objClass); if (!schema.isBinary()) { throw new common/* ArgumentError */.c1( 'Creating CMS objects from file is only available for classes with a binary attribute "blob"' ); } const attributesForCreate = prepareAttributesForCreate( attributes, objClassName, schema ); const basicObj = yield (0,models/* createObjFromFileIn */.fK)( this.scope().and((0,models/* restrictToObjClass */.Lw)(objClassName)), file, attributesForCreate ); return wrapInAppClass(basicObj); }); } toSiteContext() { return { get: this.get.bind(this), getIncludingDeleted: this.getIncludingDeleted.bind(this), getByPath: this.getByPath.bind(this), getByPermalink: this.getByPermalink.bind(this), root: this.root.bind(this), all: this.all.bind(this), where: this.where.bind(this), whereFullTextOf: this.where.bind(this), create: this.create.bind(this), createFromFile: this.createFromFile.bind(this) }; } getObj(id, scope) { return wrapInAppClass( (0,models/* getObjFrom */.ED)(this.getScopeRestrictedToSameClass(scope), id) ); } getSearch(batchSize) { const search = this.getScopeRestrictedToSameClass(this.scope()).search(); if (batchSize !== void 0) search.batchSize(batchSize); return new ObjSearch(search); } getScopeRestrictedToSameClass(scope) { const objClassName = this.objClassName(); return objClassName ? scope.and((0,models/* restrictToObjClass */.Lw)(objClassName)) : scope; } objClassName() { return objClassNameFor(this.objClass); } objClassNameForCreate() { const objClassName = this.objClassName(); if (!objClassName) { throw new common/* ArgumentError */.c1( "Use a specific class (like Page or Image) in order to create an Obj." ); } return objClassName; } scope() { return this.scopeIncludingDeletedObjs.and(models/* excludeDeletedObjs */.cb); } } function prepareAttributesForCreate(appAttributes, appClassName, schema) { const initialAttributes = initialAttributesFor( appAttributes, schema, appClassName ); const createAttributes = basic_site_context_spreadValues(basic_site_context_spreadValues({}, appAttributes), initialAttributes); return unwrapAppAttributes(createAttributes, schema, appClassName); } function assertValidCreateAttributes(attributes) { if (attributes.constructor !== Object) { throw new common/* ArgumentError */.c1( "The provided attributes are invalid. They have to be an Object with valid Scrivito attribute values." ); } if (attributes._objClass) { throw new common/* ArgumentError */.c1( `Invalid attribute "_objClass". "${String( attributes._objClass )}.create" will automatically set the CMS object class correctly.` ); } } function assertValidFile(file) { if (!(0,common/* isFile */.fo)(file)) { if ((0,common/* isBlob */.qf)(file)) { throw new common/* ArgumentError */.c1( 'Creating CMS objects from file is only available with instances of "File", but an instance of "Blob" is given' ); } throw new common/* ArgumentError */.c1( 'Creating CMS objects from file is only available with instances of "File"' ); } } ;// ./scrivito_sdk/realm/current_site_id.ts let siteIdHandler; function currentSiteId() { return siteIdHandler(); } function setCurrentSiteIdHandler(handler) { siteIdHandler = handler; } ;// ./scrivito_sdk/realm/obj.ts var obj_async = (__this, __arguments, generator) => { return new Promise((resolve, reject) => { var fulfilled = (value) => { try { step(generator.next(value)); } catch (e) { reject(e); } }; var rejected = (value) => { try { step(generator.throw(value)); } catch (e) { reject(e); } }; var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected); step((generator = generator.apply(__this, __arguments)).next()); }); }; function currentSiteContext(objClass) { const siteId = currentSiteId(); if (!siteId) return new BasicSiteContext(objClass, (0,models/* emptyScope */.Kp)()); return getBasicSiteContext(objClass, (0,models/* restrictToSiteAndGlobal */.y7)(siteId)); } function getSiteContext(objClass, transformation) { return getBasicSiteContext(objClass, transformation).toSiteContext(); } function getBasicSiteContext(objClass, transformation) { const scope = (0,models/* objSpaceScope */.aG)((0,models/* currentObjSpaceId */.eb)()).and(transformation); return new BasicSiteContext(objClass, scope); } class Obj { static get(id) { return currentSiteContext(this).get(id); } /** @internal */ static getIncludingDeleted(id) { return currentSiteContext(this).getIncludingDeleted(id); } static getByPath(path) { return currentSiteContext(this).getByPath(path); } static getByPermalink(permalink) { return currentSiteContext(this).getByPermalink(permalink); } static all() { return currentSiteContext(this).all(); } static root() { return currentSiteContext(this).root(); } static where(attribute, operator, value, boost) { if (areStrictSearchOperatorsEnabled()) { checkNonFullTextSearchOperator("Obj.where", operator, "js-sdk/Obj-where"); } return currentSiteContext(this).where(attribute, operator, value, boost); } static whereFullTextOf(attribute, operator, value, boost) { checkFullTextSearchOperator( "Obj.whereFullTextOf", operator, "js-sdk/Obj-whereFullTextOf" ); return currentSiteContext(this).whereFullTextOf( attribute, operator, value, boost ); } static create(attributes) { return currentSiteContext(this).create(attributes); } static createFromFile(file, attributes) { return currentSiteContext(this).createFromFile(file, attributes); } static onAllSites() { return getSiteContext(this, models/* allSitesAndGlobal */.uz); } static onSite(siteId) { return getSiteContext(this, (0,models/* restrictToSiteAndGlobal */.y7)(siteId)); } static attributeDefinitions() { const schema = Schema.forClass(this); if (!schema) return {}; return schema.normalizedAttributes(); } id() { return this._scrivitoPrivateContent.id(); } objClass() { return this._scrivitoPrivateContent.objClass(); } get(attributeName) { assertValidAttributeName(attributeName); return readAppAttribute(this, attributeName); } update(attributes) { updateAppAttributes(this, attributes); } versionsOnAllSites() { return wrapInAppClass((0,models/* versionsOnAllSites */.GY)(this._scrivitoPrivateContent)); } versionOnSite(siteId) { return wrapInAppClass((0,models/* versionOnSite */.$9)(this._scrivitoPrivateContent, siteId)); } createdAt() { return this._scrivitoPrivateContent.createdAt(); } firstPublishedAt() { return this._scrivitoPrivateContent.firstPublishedAt(); } publishedAt() { return this._scrivitoPrivateContent.publishedAt(); } lastChanged() { return this._scrivitoPrivateContent.lastChanged(); } path() { return this._scrivitoPrivateContent.path(); } parent() { return wrapInAppClass(this._scrivitoPrivateContent.parent()); } ancestors() { return this._scrivitoPrivateContent.ancestors().map((maybeObj) => wrapInAppClass(maybeObj)); } /** * Resolves when all previous updates have been persisted. * If an update fails the promise is rejected. */ finishSaving() { return this._scrivitoPrivateContent.finishSaving(); } modification() { return this._scrivitoPrivateContent.modification(); } backlinks() { return wrapInAppClass(this._scrivitoPrivateContent.backlinks()); } children() { return wrapInAppClass(this._scrivitoPrivateContent.children()); } orderedChildren() { return wrapInAppClass(this._scrivitoPrivateContent.orderedChildren()); } permalink() { return this._scrivitoPrivateContent.permalink(); } siteId() { return this._scrivitoPrivateContent.siteId(); } language() { return this._scrivitoPrivateContent.language(); } slug() { return this._scrivitoPrivateContent.slug(); } isBinary() { const schema = Schema.forInstance(this); if (!schema) return false; return schema.isBinary(); } isRestricted() { return this._scrivitoPrivateContent.isRestricted(); } contentLength() { if (this.isBinary()) return this._scrivitoPrivateContent.contentLength(); return 0; } contentType() { if (this.isBinary()) return this._scrivitoPrivateContent.contentType(); return ""; } contentUrl() { if (this.isBinary()) return this._scrivitoPrivateContent.contentUrl(); return ""; } contentId() { return this._scrivitoPrivateContent.contentId(); } metadata() { if (this.isBinary()) return this._scrivitoPrivateContent.metadata(); return new models/* MetadataCollection */.gT(); } restrict() { this._scrivitoPrivateContent.restrict(); } unrestrict() { this._scrivitoPrivateContent.unrestrict(); } /** @internal */ updateReferences(mapping) { return (0,models/* updateReferences */.s8)(this._scrivitoPrivateContent, mapping); } widget(id) { const maybeWidget = this._scrivitoPrivateContent.widget(id); return maybeWidget && wrapInAppClass(maybeWidget); } widgets() { return wrapInAppClass(subWidgets(this._scrivitoPrivateContent)); } copy() { return obj_async(this, null, function* () { const newObj = yield (0,models/* copyObjViaHandler */.rB)(this._scrivitoPrivateContent); return wrapInAppClass(newObj); }); } /** @deprecated Use `Obj#delete` instead */ destroy() { this.delete(); } delete() { this._scrivitoPrivateContent.delete(); } attributeDefinitions() { const schema = Schema.forInstance(this); if (!schema) return {}; return schema.normalizedAttributes(); } } // EXTERNAL MODULE: external "lodash-es/isEmpty" var isEmpty_ = __webpack_require__(5020); var isEmpty_default = /*#__PURE__*/__webpack_require__.n(isEmpty_); ;// ./scrivito_sdk/realm/link.ts var link_defProp = Object.defineProperty; var link_defProps = Object.defineProperties; var link_getOwnPropDescs = Object.getOwnPropertyDescriptors; var link_getOwnPropSymbols = Object.getOwnPropertySymbols; var link_hasOwnProp = Object.prototype.hasOwnProperty; var link_propIsEnum = Object.prototype.propertyIsEnumerable; var link_defNormalProp = (obj, key, value) => key in obj ? link_defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value; var link_spreadValues = (a, b) => { for (var prop in b || (b = {})) if (link_hasOwnProp.call(b, prop)) link_defNormalProp(a, prop, b[prop]); if (link_getOwnPropSymbols) for (var prop of link_getOwnPropSymbols(b)) { if (link_propIsEnum.call(b, prop)) link_defNormalProp(a, prop, b[prop]); } return a; }; var link_spreadProps = (a, b) => link_defProps(a, link_getOwnPropDescs(b)); class Link { constructor(attributes) { const basicAttributes = toBasicAttributes(attributes); this._scrivitoPrivateContent = new models/* BasicLink */.Re(basicAttributes); } title() { return this._scrivitoPrivateContent.title(); } query() { return this._scrivitoPrivateContent.query(); } hash() { return this._scrivitoPrivateContent.hash(); } rel() { return this._scrivitoPrivateContent.rel(); } target() { return this._scrivitoPrivateContent.target(); } url() { return this._scrivitoPrivateContent.url(); } obj() { const obj = this._scrivitoPrivateContent.obj(); return obj instanceof models/* BasicObj */.kI ? wrapInAppClass(obj) : null; } queryParameters() { return this._scrivitoPrivateContent.queryParameters(); } copy(attributes) { const basicLink = this._scrivitoPrivateContent.copy( toBasicAttributes(attributes) ); const link = Object.create(Link.prototype); link._scrivitoPrivateContent = basicLink; return link; } isExternal() { return this._scrivitoPrivateContent.isExternal(); } isInternal() { return this._scrivitoPrivateContent.isInternal(); } } const ALLOWED_ATTRIBUTES = [ "hash", "obj", "query", "rel", "target", "title", "url" ]; function assertValidPublicAttributes(attributes) { const unknownAttrs = Object.keys(attributes).filter( (key) => !ALLOWED_ATTRIBUTES.includes(key) ); if (!isEmpty_default()(unknownAttrs)) { throw new common/* ArgumentError */.c1( `Unexpected attributes ${(0,common/* prettyPrint */.aO)(unknownAttrs)}. Available attributes: ${(0,common/* prettyPrint */.aO)(ALLOWED_ATTRIBUTES)}` ); } } function toBasicAttributes(attributes) { assertValidPublicAttributes(attributes); if (attributes.hasOwnProperty("obj")) { return link_spreadProps(link_spreadValues({}, attributes), { objId: objIdFromObjValue(attributes.obj) }); } return attributes; } function objIdFromObjValue(obj) { if (!obj) return null; return unwrapAppClass(obj).id(); } ;// ./scrivito_sdk/realm/app_class_api_check.ts function validateAttributeDefinitions(attributeDefinitions, apiFunctionName) { Object.entries(attributeDefinitions).forEach( ([attributeName, definition]) => { assertCustomAttributeName(attributeName, apiFunctionName); const [attributeType, attributeTypeOptions] = definition; if (attributeType === "widgetlist" && typeof attributeTypeOptions !== "string") { assertWidgetlistDefinition( attributeName, attributeTypeOptions, apiFunctionName ); } if ((attributeType === "enum" || attributeType === "multienum") && typeof attributeTypeOptions !== "string") { assertEnumOrMultienumDefinition( attributeName, attributeTypeOptions, apiFunctionName ); } } ); } function assertWidgetlistDefinition(attributeName, options, apiFunctionName) { if (options.maximum !== void 0) { const { maximum } = options; if (Number.isInteger(maximum) && maximum > 0) return; (0,common/* throwInvalidArgumentsError */.Ht)( apiFunctionName, `invalid value "${maximum}" supplied to ${attributeName}: The "maximum" must be a positive integer.`, { docPermalink: `js-sdk/${apiFunctionName}` } ); } } function assertEnumOrMultienumDefinition(attributeName, { values }, apiFunctionName) { if (values.includes("")) { (0,common/* throwInvalidArgumentsError */.Ht)( apiFunctionName, `invalid "values" config supplied for ${attributeName}: An empty string is not a valid enum or multienum value.`, { docPermalink: `js-sdk/${apiFunctionName}` } ); } } function assertCustomAttributeName(name, target) { if (isCustomAttributeName(name)) return; (0,common/* throwInvalidArgumentsError */.Ht)( target,