2020-04-14 11:25:37 +02:00
{
"version": 3,
"file": "bundle.js",
"sources": [
"../node_modules/svelte/internal/index.mjs",
"../node_modules/svelte/store/index.mjs",
"../src/Textbox.svelte",
"../src/Form.svelte",
"../src/Button.svelte",
"../src/Login.svelte",
"../src/buildStyle.js",
"../src/Grid.svelte",
"../src/Text.svelte",
"../src/cssVars.js",
"../src/Nav.svelte",
"../src/Panel.svelte",
"../src/StackPanel.svelte",
"../src/Table.svelte",
"../node_modules/lodash/lodash.min.js",
"../node_modules/lodash/fp/_mapping.js",
"../node_modules/lodash/fp/placeholder.js",
"../node_modules/lodash/fp/_baseConvert.js",
"../node_modules/lodash/fp.js",
"../node_modules/lodash/lodash.js",
"../../core/src/common/events.js",
"../node_modules/shortid/lib/random/random-from-seed.js",
"../node_modules/shortid/lib/alphabet.js",
"../node_modules/shortid/lib/random/random-byte-browser.js",
"../node_modules/nanoid/format.js",
"../node_modules/shortid/lib/generate.js",
"../node_modules/shortid/lib/build.js",
"../node_modules/shortid/lib/is-valid.js",
"../node_modules/shortid/lib/index.js",
"../node_modules/shortid/index.js",
"../../core/src/common/errors.js",
"../../core/src/common/apiWrapper.js",
"../../core/src/common/index.js",
"../../client/src/state/setState.js",
"../../client/src/state/isState.js",
"../../client/src/state/getState.js",
"../../client/src/state/standardState.js",
"../../client/src/common/trimSlash.js",
"../../client/src/api/loadRecord.js",
"../../client/src/api/listRecords.js",
"../../client/src/api/authenticate.js",
"../../client/src/api/index.js",
"../../client/src/state/coreHandlers.js",
"../../client/src/state/eventHandlers.js",
"../../client/src/state/stateBinding.js",
"../../client/src/core/createCoreApp.js",
"../../core/src/common/validationCommon.js",
"../node_modules/@nx-js/compiler-util/dist/es.es5.js",
"../../core/src/indexing/evaluate.js",
"../../core/src/templateApi/indexes.js",
"../../core/src/templateApi/hierarchy.js",
"../../core/src/types/typeHelpers.js",
"../../core/src/types/string.js",
"../../core/src/types/bool.js",
"../../core/src/types/number.js",
"../../core/src/types/datetime.js",
"../../core/src/types/array.js",
"../../core/src/types/reference.js",
"../../core/src/types/file.js",
"../../core/src/types/index.js",
"../../core/src/authApi/authCommon.js",
"../../core/src/authApi/isAuthorized.js",
"../../core/src/authApi/permissions.js",
"../../core/src/recordApi/getNew.js",
"../../client/src/core/index.js",
"../../client/src/createApp.js",
"../src/Test/createApp.js",
"../src/Test/props.js",
"../src/Test/TestApp.svelte",
"../src/Test/testMain.js"
],
"sourcesContent": [
"function noop() { }\nconst identity = x => x;\nfunction assign(tar, src) {\n // @ts-ignore\n for (const k in src)\n tar[k] = src[k];\n return tar;\n}\nfunction is_promise(value) {\n return value && typeof value === 'object' && typeof value.then === 'function';\n}\nfunction add_location(element, file, line, column, char) {\n element.__svelte_meta = {\n loc: { file, line, column, char }\n };\n}\nfunction run(fn) {\n return fn();\n}\nfunction blank_object() {\n return Object.create(null);\n}\nfunction run_all(fns) {\n fns.forEach(run);\n}\nfunction is_function(thing) {\n return typeof thing === 'function';\n}\nfunction safe_not_equal(a, b) {\n return a != a ? b == b : a !== b || ((a && typeof a === 'object') || typeof a === 'function');\n}\nfunction not_equal(a, b) {\n return a != a ? b == b : a !== b;\n}\nfunction validate_store(store, name) {\n if (!store || typeof store.subscribe !== 'function') {\n throw new Error(`'${name}' is not a store with a 'subscribe' method`);\n }\n}\nfunction subscribe(store, callback) {\n const unsub = store.subscribe(callback);\n return unsub.unsubscribe ? () => unsub.unsubscribe() : unsub;\n}\nfunction get_store_value(store) {\n let value;\n subscribe(store, _ => value = _)();\n return value;\n}\nfunction component_subscribe(component, store, callback) {\n component.$$.on_destroy.push(subscribe(store, callback));\n}\nfunction create_slot(definition, ctx, fn) {\n if (definition) {\n const slot_ctx = get_slot_context(definition, ctx, fn);\n return definition[0](slot_ctx);\n }\n}\nfunction get_slot_context(definition, ctx, fn) {\n return definition[1]\n ? assign({}, assign(ctx.$$scope.ctx, definition[1](fn ? fn(ctx) : {})))\n : ctx.$$scope.ctx;\n}\nfunction get_slot_changes(definition, ctx, changed, fn) {\n return definition[1]\n ? assign({}, assign(ctx.$$scope.changed || {}, definition[1](fn ? fn(changed) : {})))\n : ctx.$$scope.changed || {};\n}\nfunction exclude_internal_props(props) {\n const result = {};\n for (const k in props)\n if (k[0] !== '$')\n result[k] = props[k];\n return result;\n}\nfunction once(fn) {\n let ran = false;\n return function (...args) {\n if (ran)\n return;\n ran = true;\n fn.call(this, ...args);\n };\n}\nfunction null_to_empty(value) {\n return value == null ? '' : value;\n}\nfunction set_store_value(store, ret, value = ret) {\n store.set(value);\n return ret;\n}\n\nconst is_client = typeof window !== 'undefined';\nlet now = is_client\n ? () => window.performance.now()\n : () => Date.now();\nlet raf = is_client ? cb => requestAnimationFrame(cb) : noop;\n// used internally for testing\nfunction set_now(fn) {\n now = fn;\n}\nfunction set_raf(fn) {\n raf = fn;\n}\n\nconst tasks = new Set();\nlet running = false;\nfunction run_tasks() {\n tasks.forEach(task => {\n if (!task[0](now())) {\n tasks.delete(task);\n task[1]();\n }\n });\n running = tasks.size > 0;\n if (running)\n raf(run_tasks);\n}\nfunction clear_loops() {\n // for testing...\n tasks.forEach(task => tasks.delete(task));\n running = false;\n}\nfunction loop(fn) {\n let task;\n if (!running) {\n running = true;\n raf(run_tasks);\n }\n return {\n promise: new Promise(fulfil => {\n tasks.add(task = [fn, fulfil]);\n }),\n abort() {\n tasks.delete(task);\n }\n };\n}\n\nfunction append(target, node) {\n target.appendChild(node);\n}\nfunction insert(target, node, anchor) {\n target.insertBefore(node, anchor || null);\n}\nfunction detach(node) {\n node.parentNode.removeChild(node);\n}\nfunction destroy_each(iterations, detaching) {\n for (let i = 0; i < iterations.length; i += 1) {\n if (iterations[i])\n iterations[i].d(detaching);\n }\n}\nfunction element(name) {\n return document.createElement(name);\n}\nfunctio
"import { safe_not_equal, noop, run_all, is_function } from '../internal';\nexport { get_store_value as get } from '../internal';\n\nconst subscriber_queue = [];\n/**\n * Creates a `Readable` store that allows reading by subscription.\n * @param value initial value\n * @param {StartStopNotifier}start start and stop notifications for subscriptions\n */\nfunction readable(value, start) {\n return {\n subscribe: writable(value, start).subscribe,\n };\n}\n/**\n * Create a `Writable` store that allows both updating and reading by subscription.\n * @param {*=}value initial value\n * @param {StartStopNotifier=}start start and stop notifications for subscriptions\n */\nfunction writable(value, start = noop) {\n let stop;\n const subscribers = [];\n function set(new_value) {\n if (safe_not_equal(value, new_value)) {\n value = new_value;\n if (stop) { // store is ready\n const run_queue = !subscriber_queue.length;\n for (let i = 0; i < subscribers.length; i += 1) {\n const s = subscribers[i];\n s[1]();\n subscriber_queue.push(s, value);\n }\n if (run_queue) {\n for (let i = 0; i < subscriber_queue.length; i += 2) {\n subscriber_queue[i][0](subscriber_queue[i + 1]);\n }\n subscriber_queue.length = 0;\n }\n }\n }\n }\n function update(fn) {\n set(fn(value));\n }\n function subscribe(run, invalidate = noop) {\n const subscriber = [run, invalidate];\n subscribers.push(subscriber);\n if (subscribers.length === 1) {\n stop = start(set) || noop;\n }\n run(value);\n return () => {\n const index = subscribers.indexOf(subscriber);\n if (index !== -1) {\n subscribers.splice(index, 1);\n }\n if (subscribers.length === 0) {\n stop();\n stop = null;\n }\n };\n }\n return { set, update, subscribe };\n}\n/**\n * Derived value store by synchronizing one or more readable stores and\n * applying an aggregation function over its input values.\n * @param {Stores} stores input stores\n * @param {function(Stores=, function(*)=):*}fn function callback that aggregates the values\n * @param {*=}initial_value when used asynchronously\n */\nfunction derived(stores, fn, initial_value) {\n const single = !Array.isArray(stores);\n const stores_array = single\n ? [stores]\n : stores;\n const auto = fn.length < 2;\n return readable(initial_value, (set) => {\n let inited = false;\n const values = [];\n let pending = 0;\n let cleanup = noop;\n const sync = () => {\n if (pending) {\n return;\n }\n cleanup();\n const result = fn(single ? values[0] : values, set);\n if (auto) {\n set(result);\n }\n else {\n cleanup = is_function(result) ? result : noop;\n }\n };\n const unsubscribers = stores_array.map((store, i) => store.subscribe((value) => {\n values[i] = value;\n pending &= ~(1 << i);\n if (inited) {\n sync();\n }\n }, () => {\n pending |= (1 << i);\n }));\n inited = true;\n sync();\n return function stop() {\n run_all(unsubscribers);\n cleanup();\n };\n });\n}\n\nexport { derived, readable, writable };\n",
"<script>\n\nexport let value=\"\";\nexport let hideValue = false;\nexport let className = \"default\";\n\nexport let _bb;\n\nlet actualValue = \"\";\n$: {\n\tif(_bb && value._isstate) {\n\t\t_bb.store.subscribe(s => {\n\t\t\tactualValue = _bb.store.getValue(s, value);\n\t\t});\n\t}\n}\n\nconst onchange = (ev) => {\n\tif(_bb && value._isstate) {\n\t\t_bb.store.setValue(value, ev.target.value);\n\t} else if(!value._isstate) {\n\t\tactualValue = ev.target.value;\n\t}\n}\n\n</script>\n\n{#if hideValue}\n<input class={className} \n\t type=\"password\" \n\t value={actualValue} on:change/>\n{:else}\n<input class={className} type=\"text\" value={actualValue}/>\n{/if}\n\n<style>\n.default {\n width: 100%;\n\tfont-family: inherit;\n\tfont-size: inherit;\n\tpadding: 0.4em;\n\tmargin: 0 0 0.5em 0;\n\tbox-sizing: border-box;\n\tborder: 1px solid #ccc;\n border-radius: 2px;\n width: 100%;\n}\n\n.default:disabled {\n\tcolor: #ccc;\n}\n\n</style>",
"<script>\nexport let containerClass = \"\";\nexport let formControls = [];\n\nexport let _bb;\n\nlet htmlElements = {};\nlet labels = {};\n\n$ : {\n let cIndex = 0;\n for(let c of formControls) {\n labels[cIndex] = c.label;\n cIndex++;\n }\n\n if(_bb && htmlElements) {\n for(let el in htmlElements) {\n _bb.initialiseComponent(\n formControls[el].control,\n htmlElements[el]\n );\n }\n }\n}\n\n</script>\n\n<div class=\"form-root {containerClass}\">\n {#each formControls as child, index}\n <div class=\"label\">{labels[index]}</div>\n <div class=\"control\"\n bind:this={htmlElements[index]}>\n </div>\n {/each}\n</div>\n\n<style>\n.form-root {\n display: grid;\n grid-template-columns: [label] auto [control] 1fr; /* [overflow] auto;*/\n}\n\n.label {\n grid-column-start: label;\n padding: 5px 10px;\n vertical-align: middle;\n}\n.control {\n grid-column-start: control;\n padding: 5px 10px;\n}\n.overflow {\n grid-column-start: overflow;\n}\n.full-width {\n width: 100%;\n}\n</style>",
"<script>\nexport let className = \"default\";\nexport let disabled = false;\nexport let contentText;\nexport let contentComponent;\nexport let onClick = () => {};\n\nexport let _bb;\nlet contentComponentContainer;\n\n$:{\n\tif(_bb && contentComponentContainer && contentComponent._component)\n\t\t_bb.initialiseComponent(contentComponent, contentComponentContainer);\n}\n\n\nconst clickHandler = () => {\n\tif(onClick) onClick();\n}\n\n</script>\n\n\n<button class={className} {disabled} on:click={clickHandler}>\n {#if contentComponent && contentComponent._component}\n\t<div bind:this={contentComponentContainer}>\n\t</div>\n {:else if contentText}\n {contentText}\n {:else}\n <slot />\n {/if}\n</button>\n\n\n<style>\n\n.default {\n\tfont-family: inherit;\n\tfont-size: inherit;\n\tpadding: 0.4em;\n\tmargin: 0 0 0.5em 0;\n\tbox-sizing: border-box;\n\tborder: 1px solid #ccc;\n\tborder-radius: 2px;\n\tcolor: #333;\n\tbackground-color: #f4f4f4;\n\toutline: none;\n}\n\n.default:active {\n\tbackground-color: #ddd;\n}\n\n.default:focus {\n\tborder-color: #666;\n}\n\n</style>",
"<script>\n\nimport Textbox from \"./Textbox.svelte\";\nimport Form from \"./Form.svelte\";\nimport Button from \"./Button.svelte\";\n\nexport let usernameLabel = \"Username\";\nexport let passwordLabel = \"Password\";\nexport let loginButtonLabel = \"Login\";\nexport let loginRedirect = \"\";\nexport let logo = \"\";\nexport let buttonClass = \"\";\nexport let inputClass=\"\"\n\nexport let _bb;\n\nlet username = \"\";\nlet password = \"\";\nlet busy = false;\nlet incorrect = false;\nlet _logo = \"\";\nlet _buttonClass = \"\";\nlet _inputClass = \"\";\n\n$: {\n _logo = _bb.relativeUrl(logo);\n _buttonClass = buttonClass || \"default-button\";\n _inputClass = inputClass || \"default-input\";\n}\n\nconst login = () => {\n busy = true;\n _bb.api.post(\"/api/authenticate\", {username, password})\n .then(r => {\n busy = false;\n if(r.status === 200) {\n return r.json();\n } else {\n incorrect = true;\n return;\n }\n })\n .then(user => {\n if(user) {\n localStorage.setItem(\"budibase:user\", user);\n location.reload();\n }\n })\n}\n\n</script>\n\n<div class=\"root\">\n\n <div class=\"content\">\n\n {#if _logo}\n <div class=\"logo-container\">\n <img src={_logo} alt=\"logo\"/>\n </div>\n {/if}\n\n <div class=\"form-root\">\n <div class=\"label\">\n {usernameLabel}\n </div>\n <div class=\"control\">\n <input bind:value={username} type=\"text\" class={_inputClass}/>\n </div>\n <div class=\"label\">\n {passwordLabel}\n </div>\n <div class=\"control\">\n <input bind:value={password} type=\"password\" class={_inputClass}/>\n </div>\n </div>\n\n <div class=\"login-button-container\">\n <button disabled={busy} \n on:click={login}\n class={_buttonClass}>\n {loginButtonLabel}\n </button>\n </div>\n\n {#if incorrect}\n <div class=\"incorrect-details-panel\">\n Incorrect username or password\n </div>\n {/if}\n\n </div>\n\n</div>\n\n<style>\n\n.root {\n height: 100%;\n display:grid;\n grid-template-columns: [left] 1fr [middle] auto [right] 1fr;\n grid-template-rows: [top] 1fr [center] auto [bottom] 1fr;\n}\n\n.content {\n grid-column-start: middle;\n grid-row-start: center;\n width: 400px;\n}\n\n.logo-container {\n margin-bottom: 20px\n}\n\n.logo-container > img {\n max-width: 100%;\n}\n\n.login-button-container {\n text-align: right;\n margin-top: 20px;\n}\n\n.incorrect-details-panel {\n margin-top: 30px;\n padding: 10px;\n border-style: solid;\n border-width: 1px;\n border-color: maroon;\n border-radius: 1px;\n text-align: center;\n color: maroon;\n background-color: mistyrose;\n}\n\n.form-root {\n display: grid;\n grid-template-columns: [label] auto [control] 1fr; /* [overflow] auto;*/\n}\n\n.label {\n grid-column-start: label;\n padding: 5px 10px;\n vertical-align: middle;\n}\n.control {\n grid-column-start: control;\n padding: 5px 10px;\n}\n\n.default-input {\n\tfont-family: inherit;\n\tfont-size: inherit;\n\tpadding: 0.4em;\n\tmargin: 0 0 0.5em 0;\n\tbox-sizing: border-box;\n\tborder: 1px solid #ccc;\n border-radius: 2px;\n width: 100%;\n}\n\n.default-button {\n\tfont-family: inherit;\n\tfont-size: inherit;\n\tpadding: 0.4em;\n\tmargin: 0 0 0.5em 0;\n\tbox-sizing: border-box;\n\tborder: 1px solid #ccc;\n\tborder-radius: 2px;\n\tcolor: #333;\n\tbackground-color: #f4f4f4;\n\toutline: none;\n}\n\n.default-button:active {\n\tbackground-color: #ddd;\n}\n\n.default-button:focus {\n\tborder-color: #666;\n}\n\n</style>",
"export const buildStyle = (styles) => {\r\n let str = \"\";\r\n for(let s in styles) {\r\n if(styles[s]) {\r\n str += `${s}: ${styles[s]}; `\r\n }\r\n }\r\n return str;\r\n}",
"<script>\r\nimport { onMount } from 'svelte'\r\nimport {buildStyle} from \"./buildStyle\";\r\n\r\nexport let gridTemplateRows =\"\";\r\nexport let gridTemplateColumns =\"\";\r\nexport let children = [];\r\nexport let width = \"auto\";\r\nexport let height = \"auto\";\r\nexport let containerClass=\"\";\r\nexport let itemContainerClass=\"\";\r\n\r\n/*\"gridColumnStart\":\"string\",\r\n\"gridColumnEnd\":\"string\",\r\n\"gridRowStart\":\"string\",\r\n\"gridRowEnd\":\"string\"*/\r\n\r\n\r\nexport let _bb;\r\n\r\nlet style=\"\";\r\nlet htmlElements = {};\r\n\r\n$ : {\r\n if(_bb && htmlElements) {\r\n for(let el in htmlElements) {\r\n _bb.initialiseComponent(\r\n children[el].control,\r\n htmlElements[el]\r\n );\r\n }\r\n }\r\n}\r\n\r\nconst childStyle = child => \r\n buildStyle({\r\n \"grid-column-start\": child.gridColumnStart,\r\n \"grid-column-end\": child.gridColumnEnd,\r\n \"grid-column\": child.gridColumn,\r\n \"grid-row-start\": child.gridRowStart,\r\n \"grid-row-end\": child.gridRowStart,\r\n \"grid-row\": child.gridRow,\r\n });\r\n\r\n</script>\r\n\r\n<div class=\"root {containerClass}\"\r\n style=\"width: {width}; height: {height}; grid-template-columns: {gridTemplateColumns}; grid-template-rows: {gridTemplateRows};\">\r\n {#each children as child, index}\r\n <div class=\"{itemContainerClass}\"\r\n style={childStyle(child)}\r\n bind:this={htmlElements[index]}>\r\n </div>\r\n {/each}\r\n</div>\r\n\r\n<style>\r\n\r\n.root {\r\n display: grid;\r\n}\r\n\r\n</style>",
"<script>\r\nimport {buildStyle} from \"./buildStyle\";\r\n\r\nexport let value=\"\";\r\nexport let containerClass=\"\";\r\n\r\nexport let font=\"\";\r\nexport let textAlign=\"\";\r\nexport let verticalAlign=\"\"\r\nexport let color=\"\";\r\nexport let display=\"\";\r\n\r\nexport let _bb;\r\n\r\nlet style=\"\";\r\n\r\n\r\n$: {\r\n style=buildStyle({\r\n font, verticalAlign, color, \r\n \"text-align\": textAlign,\r\n \"vertical-align\": verticalAlign\r\n });\r\n}\r\n\r\n</script>\r\n\r\n<div class={containerClass}\r\n style={style}>\r\n {value}\r\n</div>\r\n",
"// https://github.com/kaisermann/svelte-css-vars\r\n\r\nexport default (node, props) => {\r\n Object.entries(props).forEach(([key, value]) => {\r\n node.style.setProperty(`--${key}`, value);\r\n });\r\n \r\n return {\r\n update(new_props) {\r\n Object.entries(new_props).forEach(([key, value]) => {\r\n node.style.setProperty(`--${key}`, value);\r\n delete props[key];\r\n });\r\n \r\n Object.keys(props).forEach(name =>\r\n node.style.removeProperty(`--${name}`),\r\n );\r\n props = new_props;\r\n },\r\n };\r\n };",
"<script>\r\nimport cssVars from \"./cssVars\";\r\n\r\nexport let navBarBackground = \"\";\r\nexport let navBarBorder=\"\";\r\nexport let navBarColor=\"\";\r\nexport let selectedItemBackground=\"\";\r\nexport let selectedItemColor=\"\";\r\nexport let selectedItemBorder=\"\";\r\nexport let itemHoverBackground=\"\";\r\nexport let itemHoverColor=\"\";\r\nexport let items = [];\r\nexport let hideNavBar=false;\r\nexport let selectedItem=\"\";\r\n\r\nexport let _bb;\r\n\r\nlet selectedIndex = -1;\r\nlet styleVars={};\r\nlet components = {};\r\nlet componentElements = {}\r\n\r\n\r\nconst hasComponentElements = () => \r\n Object.getOwnPropertyNames(componentElements).length > 0;\r\n\r\n$: {\r\n styleVars = {\r\n navBarBackground, navBarBorder,\r\n navBarColor, selectedItemBackground,\r\n selectedItemColor, selectedItemBorder,\r\n itemHoverBackground, itemHoverColor\r\n };\r\n\r\n if(items && items.length > 0 && hasComponentElements()) {\r\n const currentSelectedItem = selectedIndex > 0\r\n ? items[selectedIndex].title\r\n : \"\";\r\n if(selectedItem && currentSelectedItem !== selectedItem) {\r\n let i=0;\r\n for(let item of items) {\r\n if(item.title === selectedItem) {\r\n onSelectItem(i)();\r\n }\r\n i++;\r\n }\r\n } else if(!currentSelectedItem) {\r\n onSelectItem(0);\r\n }\r\n }\r\n}\r\n\r\nconst onSelectItem = (index) => () => {\r\n selectedIndex = index;\r\n if(!components[index]) {\r\n const comp = _bb.initialiseComponent(\r\n items[index].component, componentElements[index]);\r\n components[index] = comp; \r\n }\r\n}\r\n\r\n\r\n</script>\r\n\r\n<div class=\"root\" use:cssVars={styleVars}>\r\n {#if !hideNavBar}\r\n <div class=\"navbar\">\r\n {#each items as navItem, index}\r\n <div class=\"navitem\"\r\n on:click={onSelectItem(index)}\r\n class:selected={selectedIndex === index}>\r\n {navItem.title}\r\n </div>\r\n {/each}\r\n </div>\r\n {/if}\r\n {#each items as navItem, index}\r\n\r\n <div class=\"content\"\r\n bind:this={componentElements[index]}>\r\n </div>\r\n {/each}\r\n</div>\r\n\r\n<style>\r\n\r\n.root {\r\n height: 100%;\r\n width:100%;\r\n grid-template-columns: [navbar] auto [content] 1fr;\r\n display: grid;\r\n}\r\n\r\n.navbar {\r\n grid-column: navbar;\r\n background: var(--navBarBackground);\r\n border: var(--navBarBorder);\r\n color: var(--navBarColor);\r\n}\r\n\r\n.navitem {\r\n padding: 10px 17px;\r\n cursor: pointer;\r\n}\r\n\r\n.navitem:hover {\r\n background: var(--itemHoverBackground);\r\n color: var(--itemHoverColor);\r\n}\r\n\r\n.navitem.selected {\r\n background: var(--selectedItemBackground);\r\n border: var(--selectedItemBorder);\r\n color: var(--selectedItemColor);\r\n}\r\n\r\n.content {\r\n grid-column: content;\r\n}\r\n\r\n</style>\r\n\r\n",
"<script>\r\nimport {buildStyle} from \"./buildStyle\";\r\nimport cssVars from \"./cssVars\";\r\n\r\nexport let component=\"\";\r\nexport let text=\"\";\r\nexport let containerClass=\"\";\r\nexport let background=\"\";\r\nexport let border=\"\";\r\nexport let borderRadius=\"\";\r\nexport let font=\"\";\r\nexport let display=\"\";\r\nexport let textAlign=\"\";\r\nexport let color=\"\";\r\nexport let padding=\"\";\r\nexport let margin=\"\";\r\nexport let hoverBackground=\"\";\r\nexport let hoverColor=\"\";\r\nexport let onClick;\r\nexport let height;\r\nexport let width;\r\n\r\nexport let _bb;\r\n\r\nlet styleVars;\r\nlet style=\"\";\r\nlet componentElement;\r\n\r\n$: {\r\n style=buildStyle({\r\n border, background, font, margin,\r\n padding, display, color, height, width,\r\n \"text-align\": textAlign,\r\n \"border-radius\":borderRadius,\r\n cursor: onClick ? \"pointer\" : \"none\"\r\n });\r\n\r\n if(_bb && component) {\r\n _bb.initialiseComponent(component, componentElement);\r\n }\r\n\r\n styleVars = {\r\n hoverBackground:hoverBackground || background, \r\n hoverColor:hoverColor || color\r\n }\r\n}\r\n\r\nconst clickHandler = () => {\r\n if(onClick) onClick();\r\n}\r\n\r\n</script>\r\n\r\n<div class=\"{containerClass} panel\" \r\n style={style}\r\n use:cssVars={styleVars}\r\n this:bind={componentElement}\r\n on:click={clickHandler}>\r\n {component && component._component ? \"\" : text}\r\n</div>\r\n\r\n<style>\r\n\r\n.panel:hover {\r\n background: var(--hoverBackground);\r\n color: var(--hoverColor);\r\n\r\n}\r\n\r\n</style>\r\n",
"<script>\n\nimport { emptyProps } from \"./emptyProps\";\n\nexport let direction = \"horizontal\";\nexport let children = [];\nexport let width = \"auto\";\nexport let height = \"auto\";\nexport let containerClass=\"\";\nexport let itemContainerClass=\"\";\nexport let onLoad;\n\nexport let data=[];\nexport let dataItemComponent;\n\nexport let _bb;\n\nlet staticHtmlElements = {};\nlet staticComponents = {};\nlet dataBoundElements = {};\nlet dataBoundComponents = {};\n\nlet onLoadCalled = false;\n\nconst hasDataBoundComponents = () => \n Object.getOwnPropertyNames(dataBoundComponents).length > 0;\n\nconst hasData = () => \n Array.isArray(data) && data.length > 0;\n\nconst hasStaticComponents = () => {\n return Object.getOwnPropertyNames(staticComponents).length > 0;\n}\n\n$: {\n\n if(staticHtmlElements) {\n if(hasStaticComponents()) {\n for(let c in staticComponents) {\n staticComponents[c].$destroy();\n }\n staticComponents = {};\n }\n\n for(let el in staticHtmlElements) {\n staticComponents[el] = _bb.initialiseComponent(\n children[el].control,\n staticHtmlElements[el]\n );\n }\n }\n \n\n if(hasDataBoundComponents()) {\n for(let c in dataBoundComponents) {\n dataBoundComponents[c].$destroy();\n }\n dataBoundComponents = {};\n }\n\n if(hasData()) {\n let index = 0;\n for(let d in dataBoundElements) {\n _bb.initialiseComponent(\n dataItemComponent,\n dataBoundElements[d],\n data[parseInt(d)]\n );\n }\n }\n\n if(!onLoadCalled && onLoad && !onLoad.isPlaceholder) {\n onLoad();\n onLoadCalled = true;\n }\n}\n\n\n</script>\n\n<div class=\"root {containerClass}\"\n style=\"width: {width}; height: {height}\">\n\n {#if children}\n {#each children as child, index}\n <div class={direction}>\n <div class=\"{itemContainerClass}\"\n bind:this={staticHtmlElements[index]}>\n </div>\n </div>\n {/each}\n {/if}\n\n {#if data && data.length > 0}\n {#each data as child, index}\n <div class={direction}>\n <div class=\"{itemContainerClass}\"\n bind:this={dataBoundElements[index]}>\n </div>\n </div>\n {/each}\n {/if}\n</div>\n\n<style>\n\n.horizontal {\n display:inline-block;\n}\n\n.vertical {\n display: block;\n}\n\n</style>",
"<script>\r\n\r\nexport let columns=[];\r\nexport let data=\"\";\r\nexport let tableClass=\"\";\r\nexport let theadClass=\"\";\r\nexport let tbodyClass=\"\";\r\nexport let trClass=\"\";\r\nexport let thClass=\"\";\r\nexport let onRowClick;\r\n\r\nexport let _bb;\r\n\r\nconst rowClickHandler = (row) => () => {\r\n onRowClick(row);\r\n}\r\n\r\n</script>\r\n\r\n <table class={tableClass}>\r\n <thead class={theadClass}>\r\n <tr class={trClass}>\r\n {#each columns as col}\r\n <th class={thClass}>{col.title}</th>\r\n {/each}\r\n </tr>\r\n </thead>\r\n <tbody class={tbodyClass}>\r\n {#each data as row}\r\n <tr class={trClass}\r\n on:click={rowClickHandler(row)} >\r\n {#each columns as col}\r\n <th class={thClass}>{_bb.getStateOrValue(col.value, row)}</th>\r\n {/each}\r\n </tr>\r\n {/each}\r\n </tbody>\r\n</table> \r\n\r\n<style>\r\n\r\n.table-default {\r\n width: 100%;\r\n margin-bottom: 1rem;\r\n color: #212529;\r\n border-collapse: collapse;\r\n}\r\n\r\n.table-default .thead-default .th-default {\r\n vertical-align: bottom;\r\n border-bottom: 2px solid #dee2e6;\r\n font-weight: bold;\r\n}\r\n\r\n.table-default .th-default {\r\n padding: .75rem;\r\n vertical-align: top;\r\n border-top: 1px solid #dee2e6;\r\n font-weight: normal;\r\n}\r\n\r\n.th-default {\r\n text-align: inherit;\r\n}\r\n\r\n.table-default .tbody-default .tr-default:hover {\r\n color: #212529;\r\n background-color: rgba(0,0,0,.075);\r\n cursor: pointer;\r\n}\r\n\r\n</style>",
"/**\n * @license\n * Lodash lodash.com/license | Underscore.js 1.8.3 underscorejs.org/LICENSE\n */\n;(function(){function n(n,t,r){switch(r.length){case 0:return n.call(t);case 1:return n.call(t,r[0]);case 2:return n.call(t,r[0],r[1]);case 3:return n.call(t,r[0],r[1],r[2])}return n.apply(t,r)}function t(n,t,r,e){for(var u=-1,i=null==n?0:n.length;++u<i;){var o=n[u];t(e,o,r(o),n)}return e}function r(n,t){for(var r=-1,e=null==n?0:n.length;++r<e&&false!==t(n[r],r,n););return n}function e(n,t){for(var r=null==n?0:n.length;r--&&false!==t(n[r],r,n););return n}function u(n,t){for(var r=-1,e=null==n?0:n.length;++r<e;)if(!t(n[r],r,n))return false;\nreturn true}function i(n,t){for(var r=-1,e=null==n?0:n.length,u=0,i=[];++r<e;){var o=n[r];t(o,r,n)&&(i[u++]=o)}return i}function o(n,t){return!(null==n||!n.length)&&-1<v(n,t,0)}function f(n,t,r){for(var e=-1,u=null==n?0:n.length;++e<u;)if(r(t,n[e]))return true;return false}function c(n,t){for(var r=-1,e=null==n?0:n.length,u=Array(e);++r<e;)u[r]=t(n[r],r,n);return u}function a(n,t){for(var r=-1,e=t.length,u=n.length;++r<e;)n[u+r]=t[r];return n}function l(n,t,r,e){var u=-1,i=null==n?0:n.length;for(e&&i&&(r=n[++u]);++u<i;)r=t(r,n[u],u,n);\nreturn r}function s(n,t,r,e){var u=null==n?0:n.length;for(e&&u&&(r=n[--u]);u--;)r=t(r,n[u],u,n);return r}function h(n,t){for(var r=-1,e=null==n?0:n.length;++r<e;)if(t(n[r],r,n))return true;return false}function p(n,t,r){var e;return r(n,function(n,r,u){if(t(n,r,u))return e=r,false}),e}function _(n,t,r,e){var u=n.length;for(r+=e?1:-1;e?r--:++r<u;)if(t(n[r],r,n))return r;return-1}function v(n,t,r){if(t===t)n:{--r;for(var e=n.length;++r<e;)if(n[r]===t){n=r;break n}n=-1}else n=_(n,d,r);return n}function g(n,t,r,e){\n--r;for(var u=n.length;++r<u;)if(e(n[r],t))return r;return-1}function d(n){return n!==n}function y(n,t){var r=null==n?0:n.length;return r?m(n,t)/r:F}function b(n){return function(t){return null==t?T:t[n]}}function x(n){return function(t){return null==n?T:n[t]}}function j(n,t,r,e,u){return u(n,function(n,u,i){r=e?(e=false,n):t(r,n,u,i)}),r}function w(n,t){var r=n.length;for(n.sort(t);r--;)n[r]=n[r].c;return n}function m(n,t){for(var r,e=-1,u=n.length;++e<u;){var i=t(n[e]);i!==T&&(r=r===T?i:r+i)}return r;\n}function A(n,t){for(var r=-1,e=Array(n);++r<n;)e[r]=t(r);return e}function E(n,t){return c(t,function(t){return[t,n[t]]})}function k(n){return function(t){return n(t)}}function S(n,t){return c(t,function(t){return n[t]})}function O(n,t){return n.has(t)}function I(n,t){for(var r=-1,e=n.length;++r<e&&-1<v(t,n[r],0););return r}function R(n,t){for(var r=n.length;r--&&-1<v(t,n[r],0););return r}function z(n){return\"\\\\\"+Un[n]}function W(n){var t=-1,r=Array(n.size);return n.forEach(function(n,e){r[++t]=[e,n];\n}),r}function B(n,t){return function(r){return n(t(r))}}function L(n,t){for(var r=-1,e=n.length,u=0,i=[];++r<e;){var o=n[r];o!==t&&\"__lodash_placeholder__\"!==o||(n[r]=\"__lodash_placeholder__\",i[u++]=r)}return i}function U(n){var t=-1,r=Array(n.size);return n.forEach(function(n){r[++t]=n}),r}function C(n){var t=-1,r=Array(n.size);return n.forEach(function(n){r[++t]=[n,n]}),r}function D(n){if(Rn.test(n)){for(var t=On.lastIndex=0;On.test(n);)++t;n=t}else n=Qn(n);return n}function M(n){return Rn.test(n)?n.match(On)||[]:n.split(\"\");\n}var T,$=1/0,F=NaN,N=[[\"ary\",128],[\"bind\",1],[\"bindKey\",2],[\"curry\",8],[\"curryRight\",16],[\"flip\",512],[\"partial\",32],[\"partialRight\",64],[\"rearg\",256]],P=/\\b__p\\+='';/g,Z=/\\b(__p\\+=)''\\+/g,q=/(__e\\(.*?\\)|\\b__t\\))\\+'';/g,V=/&(?:amp|lt|gt|quot|#39);/g,K=/[&<>\"']/g,G=RegExp(V.source),H=RegExp(K.source),J=/<%-([\\s\\S]+?)%>/g,Y=/<%([\\s\\S]+?)%>/g,Q=/<%=([\\s\\S]+?)%>/g,X=/\\.|\\[(?:[^[\\]]*|([\"'])(?:(?!\\1)[^\\\\]|\\\\.)*?\\1)\\]/,nn=/^\\w*$/,tn=/[^.[\\]]+|\\[(?:(-?\\d+(?:\\.\\d+)?)|([\"'])((?:(?!\\2)[^\\\\]|\\\\.)*?)\\2)\\]|(?=(?:\\.|\\[\\])(?:\\.|\\[\\]|$))/g,rn=/[\\\\^$.*+?()[\\]{}|]/g,en=RegExp(rn.source),un=/^\\s+|\\s+$/g,on=/^\\s+/,fn=/\\s+$/,cn=/\\{(?:\\n\\/\\* \\[wrapped with .+\\] \\*\\/)?\\n?/,an=/\\{\\n\\/\\* \\[wrapped with (.+)\\] \\*/,ln=/,? & /,sn=/[^\\x00-\\x2f\\x3
"/** Used to map aliases to their real names. */\nexports.aliasToReal = {\n\n // Lodash aliases.\n 'each': 'forEach',\n 'eachRight': 'forEachRight',\n 'entries': 'toPairs',\n 'entriesIn': 'toPairsIn',\n 'extend': 'assignIn',\n 'extendAll': 'assignInAll',\n 'extendAllWith': 'assignInAllWith',\n 'extendWith': 'assignInWith',\n 'first': 'head',\n\n // Methods that are curried variants of others.\n 'conforms': 'conformsTo',\n 'matches': 'isMatch',\n 'property': 'get',\n\n // Ramda aliases.\n '__': 'placeholder',\n 'F': 'stubFalse',\n 'T': 'stubTrue',\n 'all': 'every',\n 'allPass': 'overEvery',\n 'always': 'constant',\n 'any': 'some',\n 'anyPass': 'overSome',\n 'apply': 'spread',\n 'assoc': 'set',\n 'assocPath': 'set',\n 'complement': 'negate',\n 'compose': 'flowRight',\n 'contains': 'includes',\n 'dissoc': 'unset',\n 'dissocPath': 'unset',\n 'dropLast': 'dropRight',\n 'dropLastWhile': 'dropRightWhile',\n 'equals': 'isEqual',\n 'identical': 'eq',\n 'indexBy': 'keyBy',\n 'init': 'initial',\n 'invertObj': 'invert',\n 'juxt': 'over',\n 'omitAll': 'omit',\n 'nAry': 'ary',\n 'path': 'get',\n 'pathEq': 'matchesProperty',\n 'pathOr': 'getOr',\n 'paths': 'at',\n 'pickAll': 'pick',\n 'pipe': 'flow',\n 'pluck': 'map',\n 'prop': 'get',\n 'propEq': 'matchesProperty',\n 'propOr': 'getOr',\n 'props': 'at',\n 'symmetricDifference': 'xor',\n 'symmetricDifferenceBy': 'xorBy',\n 'symmetricDifferenceWith': 'xorWith',\n 'takeLast': 'takeRight',\n 'takeLastWhile': 'takeRightWhile',\n 'unapply': 'rest',\n 'unnest': 'flatten',\n 'useWith': 'overArgs',\n 'where': 'conformsTo',\n 'whereEq': 'isMatch',\n 'zipObj': 'zipObject'\n};\n\n/** Used to map ary to method names. */\nexports.aryMethod = {\n '1': [\n 'assignAll', 'assignInAll', 'attempt', 'castArray', 'ceil', 'create',\n 'curry', 'curryRight', 'defaultsAll', 'defaultsDeepAll', 'floor', 'flow',\n 'flowRight', 'fromPairs', 'invert', 'iteratee', 'memoize', 'method', 'mergeAll',\n 'methodOf', 'mixin', 'nthArg', 'over', 'overEvery', 'overSome','rest', 'reverse',\n 'round', 'runInContext', 'spread', 'template', 'trim', 'trimEnd', 'trimStart',\n 'uniqueId', 'words', 'zipAll'\n ],\n '2': [\n 'add', 'after', 'ary', 'assign', 'assignAllWith', 'assignIn', 'assignInAllWith',\n 'at', 'before', 'bind', 'bindAll', 'bindKey', 'chunk', 'cloneDeepWith',\n 'cloneWith', 'concat', 'conformsTo', 'countBy', 'curryN', 'curryRightN',\n 'debounce', 'defaults', 'defaultsDeep', 'defaultTo', 'delay', 'difference',\n 'divide', 'drop', 'dropRight', 'dropRightWhile', 'dropWhile', 'endsWith', 'eq',\n 'every', 'filter', 'find', 'findIndex', 'findKey', 'findLast', 'findLastIndex',\n 'findLastKey', 'flatMap', 'flatMapDeep', 'flattenDepth', 'forEach',\n 'forEachRight', 'forIn', 'forInRight', 'forOwn', 'forOwnRight', 'get',\n 'groupBy', 'gt', 'gte', 'has', 'hasIn', 'includes', 'indexOf', 'intersection',\n 'invertBy', 'invoke', 'invokeMap', 'isEqual', 'isMatch', 'join', 'keyBy',\n 'lastIndexOf', 'lt', 'lte', 'map', 'mapKeys', 'mapValues', 'matchesProperty',\n 'maxBy', 'meanBy', 'merge', 'mergeAllWith', 'minBy', 'multiply', 'nth', 'omit',\n 'omitBy', 'overArgs', 'pad', 'padEnd', 'padStart', 'parseInt', 'partial',\n 'partialRight', 'partition', 'pick', 'pickBy', 'propertyOf', 'pull', 'pullAll',\n 'pullAt', 'random', 'range', 'rangeRight', 'rearg', 'reject', 'remove',\n 'repeat', 'restFrom', 'result', 'sampleSize', 'some', 'sortBy', 'sortedIndex',\n 'sortedIndexOf', 'sortedLastIndex', 'sortedLastIndexOf', 'sortedUniqBy',\n 'split', 'spreadFrom', 'startsWith', 'subtract', 'sumBy', 'take', 'takeRight',\n 'takeRightWhile', 'takeWhile', 'tap', 'throttle', 'thru', 'times', 'trimChars',\n 'trimCharsEnd', 'trimCharsStart', 'truncate', 'union', 'uniqBy', 'uniqWith',\n 'unset', 'unzipWith', 'without', 'wrap', 'xor', 'zip', 'zipObject',\n 'zipObjectDeep'\n ],\n '3': [\n 'assignInWith', 'assignWith', 'clamp', 'differenceBy', 'differenceWith',\n 'findFrom', 'findIndexFrom', 'findLastFrom',
"/**\n * The default argument placeholder value for methods.\n *\n * @type {Object}\n */\nmodule.exports = {};\n",
"var mapping = require('./_mapping'),\n fallbackHolder = require('./placeholder');\n\n/** Built-in value reference. */\nvar push = Array.prototype.push;\n\n/**\n * Creates a function, with an arity of `n`, that invokes `func` with the\n * arguments it receives.\n *\n * @private\n * @param {Function} func The function to wrap.\n * @param {number} n The arity of the new function.\n * @returns {Function} Returns the new function.\n */\nfunction baseArity(func, n) {\n return n == 2\n ? function(a, b) { return func.apply(undefined, arguments); }\n : function(a) { return func.apply(undefined, arguments); };\n}\n\n/**\n * Creates a function that invokes `func`, with up to `n` arguments, ignoring\n * any additional arguments.\n *\n * @private\n * @param {Function} func The function to cap arguments for.\n * @param {number} n The arity cap.\n * @returns {Function} Returns the new function.\n */\nfunction baseAry(func, n) {\n return n == 2\n ? function(a, b) { return func(a, b); }\n : function(a) { return func(a); };\n}\n\n/**\n * Creates a clone of `array`.\n *\n * @private\n * @param {Array} array The array to clone.\n * @returns {Array} Returns the cloned array.\n */\nfunction cloneArray(array) {\n var length = array ? array.length : 0,\n result = Array(length);\n\n while (length--) {\n result[length] = array[length];\n }\n return result;\n}\n\n/**\n * Creates a function that clones a given object using the assignment `func`.\n *\n * @private\n * @param {Function} func The assignment function.\n * @returns {Function} Returns the new cloner function.\n */\nfunction createCloner(func) {\n return function(object) {\n return func({}, object);\n };\n}\n\n/**\n * A specialized version of `_.spread` which flattens the spread array into\n * the arguments of the invoked `func`.\n *\n * @private\n * @param {Function} func The function to spread arguments over.\n * @param {number} start The start position of the spread.\n * @returns {Function} Returns the new function.\n */\nfunction flatSpread(func, start) {\n return function() {\n var length = arguments.length,\n lastIndex = length - 1,\n args = Array(length);\n\n while (length--) {\n args[length] = arguments[length];\n }\n var array = args[start],\n otherArgs = args.slice(0, start);\n\n if (array) {\n push.apply(otherArgs, array);\n }\n if (start != lastIndex) {\n push.apply(otherArgs, args.slice(start + 1));\n }\n return func.apply(this, otherArgs);\n };\n}\n\n/**\n * Creates a function that wraps `func` and uses `cloner` to clone the first\n * argument it receives.\n *\n * @private\n * @param {Function} func The function to wrap.\n * @param {Function} cloner The function to clone arguments.\n * @returns {Function} Returns the new immutable function.\n */\nfunction wrapImmutable(func, cloner) {\n return function() {\n var length = arguments.length;\n if (!length) {\n return;\n }\n var args = Array(length);\n while (length--) {\n args[length] = arguments[length];\n }\n var result = args[0] = cloner.apply(undefined, args);\n func.apply(undefined, args);\n return result;\n };\n}\n\n/**\n * The base implementation of `convert` which accepts a `util` object of methods\n * required to perform conversions.\n *\n * @param {Object} util The util object.\n * @param {string} name The name of the function to convert.\n * @param {Function} func The function to convert.\n * @param {Object} [options] The options object.\n * @param {boolean} [options.cap=true] Specify capping iteratee arguments.\n * @param {boolean} [options.curry=true] Specify currying.\n * @param {boolean} [options.fixed=true] Specify fixed arity.\n * @param {boolean} [options.immutable=true] Specify immutable operations.\n * @param {boolean} [options.rearg=true] Specify rearranging arguments.\n * @returns {Function|Object} Returns the converted function or object.\n */\nfunction baseConvert(util, name, func, options) {\n var isLib = typeof name == 'function',\n isObj = name === Object
"var _ = require('./lodash.min').runInContext();\nmodule.exports = require('./fp/_baseConvert')(_, _);\n",
"/**\n * @license\n * Lodash <https://lodash.com/>\n * Copyright OpenJS Foundation and other contributors <https://openjsf.org/>\n * Released under MIT license <https://lodash.com/license>\n * Based on Underscore.js 1.8.3 <http://underscorejs.org/LICENSE>\n * Copyright Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors\n */\n;(function() {\n\n /** Used as a safe reference for `undefined` in pre-ES5 environments. */\n var undefined;\n\n /** Used as the semantic version number. */\n var VERSION = '4.17.15';\n\n /** Used as the size to enable large array optimizations. */\n var LARGE_ARRAY_SIZE = 200;\n\n /** Error message constants. */\n var CORE_ERROR_TEXT = 'Unsupported core-js use. Try https://npms.io/search?q=ponyfill.',\n FUNC_ERROR_TEXT = 'Expected a function';\n\n /** Used to stand-in for `undefined` hash values. */\n var HASH_UNDEFINED = '__lodash_hash_undefined__';\n\n /** Used as the maximum memoize cache size. */\n var MAX_MEMOIZE_SIZE = 500;\n\n /** Used as the internal argument placeholder. */\n var PLACEHOLDER = '__lodash_placeholder__';\n\n /** Used to compose bitmasks for cloning. */\n var CLONE_DEEP_FLAG = 1,\n CLONE_FLAT_FLAG = 2,\n CLONE_SYMBOLS_FLAG = 4;\n\n /** Used to compose bitmasks for value comparisons. */\n var COMPARE_PARTIAL_FLAG = 1,\n COMPARE_UNORDERED_FLAG = 2;\n\n /** Used to compose bitmasks for function metadata. */\n var WRAP_BIND_FLAG = 1,\n WRAP_BIND_KEY_FLAG = 2,\n WRAP_CURRY_BOUND_FLAG = 4,\n WRAP_CURRY_FLAG = 8,\n WRAP_CURRY_RIGHT_FLAG = 16,\n WRAP_PARTIAL_FLAG = 32,\n WRAP_PARTIAL_RIGHT_FLAG = 64,\n WRAP_ARY_FLAG = 128,\n WRAP_REARG_FLAG = 256,\n WRAP_FLIP_FLAG = 512;\n\n /** Used as default options for `_.truncate`. */\n var DEFAULT_TRUNC_LENGTH = 30,\n DEFAULT_TRUNC_OMISSION = '...';\n\n /** Used to detect hot functions by number of calls within a span of milliseconds. */\n var HOT_COUNT = 800,\n HOT_SPAN = 16;\n\n /** Used to indicate the type of lazy iteratees. */\n var LAZY_FILTER_FLAG = 1,\n LAZY_MAP_FLAG = 2,\n LAZY_WHILE_FLAG = 3;\n\n /** Used as references for various `Number` constants. */\n var INFINITY = 1 / 0,\n MAX_SAFE_INTEGER = 9007199254740991,\n MAX_INTEGER = 1.7976931348623157e+308,\n NAN = 0 / 0;\n\n /** Used as references for the maximum length and index of an array. */\n var MAX_ARRAY_LENGTH = 4294967295,\n MAX_ARRAY_INDEX = MAX_ARRAY_LENGTH - 1,\n HALF_MAX_ARRAY_LENGTH = MAX_ARRAY_LENGTH >>> 1;\n\n /** Used to associate wrap methods with their bit flags. */\n var wrapFlags = [\n ['ary', WRAP_ARY_FLAG],\n ['bind', WRAP_BIND_FLAG],\n ['bindKey', WRAP_BIND_KEY_FLAG],\n ['curry', WRAP_CURRY_FLAG],\n ['curryRight', WRAP_CURRY_RIGHT_FLAG],\n ['flip', WRAP_FLIP_FLAG],\n ['partial', WRAP_PARTIAL_FLAG],\n ['partialRight', WRAP_PARTIAL_RIGHT_FLAG],\n ['rearg', WRAP_REARG_FLAG]\n ];\n\n /** `Object#toString` result references. */\n var argsTag = '[object Arguments]',\n arrayTag = '[object Array]',\n asyncTag = '[object AsyncFunction]',\n boolTag = '[object Boolean]',\n dateTag = '[object Date]',\n domExcTag = '[object DOMException]',\n errorTag = '[object Error]',\n funcTag = '[object Function]',\n genTag = '[object GeneratorFunction]',\n mapTag = '[object Map]',\n numberTag = '[object Number]',\n nullTag = '[object Null]',\n objectTag = '[object Object]',\n promiseTag = '[object Promise]',\n proxyTag = '[object Proxy]',\n regexpTag = '[object RegExp]',\n setTag = '[object Set]',\n stringTag = '[object String]',\n symbolTag = '[object Symbol]',\n undefinedTag = '[object Undefined]',\n weakMapTag = '[object WeakMap]',\n weakSetTag = '[object WeakSet]';\n\n var arrayBufferTag = '[object ArrayBuffer]',\n dataViewTag = '[object DataView]',\n float32Tag = '[object Float32Array]',\n float64Tag = '[object Float64Array]',\n int8Tag = '[object Int8Array]',\n
"import { union, reduce } from 'lodash/fp';\n\nconst commonPlus = extra => union(['onBegin', 'onComplete', 'onError'])(extra);\n\nconst common = () => commonPlus([]);\n\nconst _events = {\n recordApi: {\n save: commonPlus([\n 'onInvalid',\n 'onRecordUpdated',\n 'onRecordCreated']),\n delete: common(),\n getContext: common(),\n getNew: common(),\n load: common(),\n validate: common(),\n uploadFile: common(),\n downloadFile: common(),\n },\n indexApi: {\n buildIndex: common(),\n listItems: common(),\n delete: common(),\n aggregates: common(),\n },\n collectionApi: {\n getAllowedRecordTypes: common(),\n initialise: common(),\n delete: common(),\n },\n authApi: {\n authenticate: common(),\n authenticateTemporaryAccess: common(),\n createTemporaryAccess: common(),\n createUser: common(),\n enableUser: common(),\n disableUser: common(),\n loadAccessLevels: common(),\n getNewAccessLevel: common(),\n getNewUser: common(),\n getNewUserAuth: common(),\n getUsers: common(),\n saveAccessLevels: common(),\n isAuthorized: common(),\n changeMyPassword: common(),\n setPasswordFromTemporaryCode: common(),\n scorePassword: common(),\n isValidPassword: common(),\n validateUser: common(),\n validateAccessLevels: common(),\n setUserAccessLevels: common(),\n },\n templateApi: {\n saveApplicationHierarchy: common(),\n saveActionsAndTriggers: common(),\n },\n actionsApi: {\n execute: common(),\n },\n};\n\nconst _eventsList = [];\n\nconst makeEvent = (area, method, name) => `${area}:${method}:${name}`;\n\nfor (const areaKey in _events) {\n for (const methodKey in _events[areaKey]) {\n _events[areaKey][methodKey] = reduce((obj, s) => {\n obj[s] = makeEvent(areaKey, methodKey, s);\n return obj;\n },\n {})(_events[areaKey][methodKey]);\n }\n}\n\n\nfor (const areaKey in _events) {\n for (const methodKey in _events[areaKey]) {\n for (const name in _events[areaKey][methodKey]) {\n _eventsList.push(\n _events[areaKey][methodKey][name],\n );\n }\n }\n}\n\n\nexport const events = _events;\n\nexport const eventsList = _eventsList;\n\nexport default { events: _events, eventsList: _eventsList };\n",
"'use strict';\n\n// Found this seed-based random generator somewhere\n// Based on The Central Randomizer 1.3 (C) 1997 by Paul Houle (houle@msc.cornell.edu)\n\nvar seed = 1;\n\n/**\n * return a random number based on a seed\n * @param seed\n * @returns {number}\n */\nfunction getNextValue() {\n seed = (seed * 9301 + 49297) % 233280;\n return seed/(233280.0);\n}\n\nfunction setSeed(_seed_) {\n seed = _seed_;\n}\n\nmodule.exports = {\n nextValue: getNextValue,\n seed: setSeed\n};\n",
"'use strict';\n\nvar randomFromSeed = require('./random/random-from-seed');\n\nvar ORIGINAL = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ_-';\nvar alphabet;\nvar previousSeed;\n\nvar shuffled;\n\nfunction reset() {\n shuffled = false;\n}\n\nfunction setCharacters(_alphabet_) {\n if (!_alphabet_) {\n if (alphabet !== ORIGINAL) {\n alphabet = ORIGINAL;\n reset();\n }\n return;\n }\n\n if (_alphabet_ === alphabet) {\n return;\n }\n\n if (_alphabet_.length !== ORIGINAL.length) {\n throw new Error('Custom alphabet for shortid must be ' + ORIGINAL.length + ' unique characters. You submitted ' + _alphabet_.length + ' characters: ' + _alphabet_);\n }\n\n var unique = _alphabet_.split('').filter(function(item, ind, arr){\n return ind !== arr.lastIndexOf(item);\n });\n\n if (unique.length) {\n throw new Error('Custom alphabet for shortid must be ' + ORIGINAL.length + ' unique characters. These characters were not unique: ' + unique.join(', '));\n }\n\n alphabet = _alphabet_;\n reset();\n}\n\nfunction characters(_alphabet_) {\n setCharacters(_alphabet_);\n return alphabet;\n}\n\nfunction setSeed(seed) {\n randomFromSeed.seed(seed);\n if (previousSeed !== seed) {\n reset();\n previousSeed = seed;\n }\n}\n\nfunction shuffle() {\n if (!alphabet) {\n setCharacters(ORIGINAL);\n }\n\n var sourceArray = alphabet.split('');\n var targetArray = [];\n var r = randomFromSeed.nextValue();\n var characterIndex;\n\n while (sourceArray.length > 0) {\n r = randomFromSeed.nextValue();\n characterIndex = Math.floor(r * sourceArray.length);\n targetArray.push(sourceArray.splice(characterIndex, 1)[0]);\n }\n return targetArray.join('');\n}\n\nfunction getShuffled() {\n if (shuffled) {\n return shuffled;\n }\n shuffled = shuffle();\n return shuffled;\n}\n\n/**\n * lookup shuffled letter\n * @param index\n * @returns {string}\n */\nfunction lookup(index) {\n var alphabetShuffled = getShuffled();\n return alphabetShuffled[index];\n}\n\nfunction get () {\n return alphabet || ORIGINAL;\n}\n\nmodule.exports = {\n get: get,\n characters: characters,\n seed: setSeed,\n lookup: lookup,\n shuffled: getShuffled\n};\n",
"'use strict';\n\nvar crypto = typeof window === 'object' && (window.crypto || window.msCrypto); // IE 11 uses window.msCrypto\n\nvar randomByte;\n\nif (!crypto || !crypto.getRandomValues) {\n randomByte = function(size) {\n var bytes = [];\n for (var i = 0; i < size; i++) {\n bytes.push(Math.floor(Math.random() * 256));\n }\n return bytes;\n };\n} else {\n randomByte = function(size) {\n return crypto.getRandomValues(new Uint8Array(size));\n };\n}\n\nmodule.exports = randomByte;\n",
"/**\n * Secure random string generator with custom alphabet.\n *\n * Alphabet must contain 256 symbols or less. Otherwise, the generator\n * will not be secure.\n *\n * @param {generator} random The random bytes generator.\n * @param {string} alphabet Symbols to be used in new random string.\n * @param {size} size The number of symbols in new random string.\n *\n * @return {string} Random string.\n *\n * @example\n * const format = require('nanoid/format')\n *\n * function random (size) {\n * const result = []\n * for (let i = 0; i < size; i++) {\n * result.push(randomByte())\n * }\n * return result\n * }\n *\n * format(random, \"abcdef\", 5) //=> \"fbaef\"\n *\n * @name format\n * @function\n */\nmodule.exports = function (random, alphabet, size) {\n var mask = (2 << Math.log(alphabet.length - 1) / Math.LN2) - 1\n var step = Math.ceil(1.6 * mask * size / alphabet.length)\n size = +size\n\n var id = ''\n while (true) {\n var bytes = random(step)\n for (var i = 0; i < step; i++) {\n var byte = bytes[i] & mask\n if (alphabet[byte]) {\n id += alphabet[byte]\n if (id.length === size) return id\n }\n }\n }\n}\n\n/**\n * @callback generator\n * @param {number} bytes The number of bytes to generate.\n * @return {number[]} Random bytes.\n */\n",
"'use strict';\n\nvar alphabet = require('./alphabet');\nvar random = require('./random/random-byte');\nvar format = require('nanoid/format');\n\nfunction generate(number) {\n var loopCounter = 0;\n var done;\n\n var str = '';\n\n while (!done) {\n str = str + format(random, alphabet.get(), 1);\n done = number < (Math.pow(16, loopCounter + 1 ) );\n loopCounter++;\n }\n return str;\n}\n\nmodule.exports = generate;\n",
"'use strict';\n\nvar generate = require('./generate');\nvar alphabet = require('./alphabet');\n\n// Ignore all milliseconds before a certain time to reduce the size of the date entropy without sacrificing uniqueness.\n// This number should be updated every year or so to keep the generated id short.\n// To regenerate `new Date() - 0` and bump the version. Always bump the version!\nvar REDUCE_TIME = 1567752802062;\n\n// don't change unless we change the algos or REDUCE_TIME\n// must be an integer and less than 16\nvar version = 7;\n\n// Counter is used when shortid is called multiple times in one second.\nvar counter;\n\n// Remember the last time shortid was called in case counter is needed.\nvar previousSeconds;\n\n/**\n * Generate unique id\n * Returns string id\n */\nfunction build(clusterWorkerId) {\n var str = '';\n\n var seconds = Math.floor((Date.now() - REDUCE_TIME) * 0.001);\n\n if (seconds === previousSeconds) {\n counter++;\n } else {\n counter = 0;\n previousSeconds = seconds;\n }\n\n str = str + generate(version);\n str = str + generate(clusterWorkerId);\n if (counter > 0) {\n str = str + generate(counter);\n }\n str = str + generate(seconds);\n return str;\n}\n\nmodule.exports = build;\n",
"'use strict';\nvar alphabet = require('./alphabet');\n\nfunction isShortId(id) {\n if (!id || typeof id !== 'string' || id.length < 6 ) {\n return false;\n }\n\n var nonAlphabetic = new RegExp('[^' +\n alphabet.get().replace(/[|\\\\{}()[\\]^$+*?.-]/g, '\\\\$&') +\n ']');\n return !nonAlphabetic.test(id);\n}\n\nmodule.exports = isShortId;\n",
"'use strict';\n\nvar alphabet = require('./alphabet');\nvar build = require('./build');\nvar isValid = require('./is-valid');\n\n// if you are using cluster or multiple servers use this to make each instance\n// has a unique value for worker\n// Note: I don't know if this is automatically set when using third\n// party cluster solutions such as pm2.\nvar clusterWorkerId = require('./util/cluster-worker-id') || 0;\n\n/**\n * Set the seed.\n * Highly recommended if you don't want people to try to figure out your id schema.\n * exposed as shortid.seed(int)\n * @param seed Integer value to seed the random alphabet. ALWAYS USE THE SAME SEED or you might get overlaps.\n */\nfunction seed(seedValue) {\n alphabet.seed(seedValue);\n return module.exports;\n}\n\n/**\n * Set the cluster worker or machine id\n * exposed as shortid.worker(int)\n * @param workerId worker must be positive integer. Number less than 16 is recommended.\n * returns shortid module so it can be chained.\n */\nfunction worker(workerId) {\n clusterWorkerId = workerId;\n return module.exports;\n}\n\n/**\n *\n * sets new characters to use in the alphabet\n * returns the shuffled alphabet\n */\nfunction characters(newCharacters) {\n if (newCharacters !== undefined) {\n alphabet.characters(newCharacters);\n }\n\n return alphabet.shuffled();\n}\n\n/**\n * Generate unique id\n * Returns string id\n */\nfunction generate() {\n return build(clusterWorkerId);\n}\n\n// Export all other functions as properties of the generate function\nmodule.exports = generate;\nmodule.exports.generate = generate;\nmodule.exports.seed = seed;\nmodule.exports.worker = worker;\nmodule.exports.characters = characters;\nmodule.exports.isValid = isValid;\n",
"'use strict';\nmodule.exports = require('./lib/index');\n",
"export class BadRequestError extends Error {\n constructor(message) {\n super(message);\n this.httpStatusCode = 400;\n }\n}\n\nexport class UnauthorisedError extends Error {\n constructor(message) {\n super(message);\n this.httpStatusCode = 401;\n }\n}\n\nexport class ForbiddenError extends Error {\n constructor(message) {\n super(message);\n this.httpStatusCode = 403;\n }\n}\n\nexport class NotFoundError extends Error {\n constructor(message) {\n super(message);\n this.httpStatusCode = 404;\n }\n}\n\nexport class ConflictError extends Error {\n constructor(message) {\n super(message);\n this.httpStatusCode = 409;\n }\n}",
"import { cloneDeep, isUndefined } from 'lodash/fp';\nimport { generate } from 'shortid';\nimport { UnauthorisedError } from './errors';\n\nexport const apiWrapper = async (app, eventNamespace, isAuthorized, eventContext, func, ...params) => {\n pushCallStack(app, eventNamespace);\n\n if (!isAuthorized(app)) {\n handleNotAuthorized(app, eventContext, eventNamespace);\n return;\n }\n\n const startDate = Date.now();\n const elapsed = () => (Date.now() - startDate);\n\n try {\n await app.publish(\n eventNamespace.onBegin,\n eventContext,\n );\n\n const result = await func(...params);\n\n await publishComplete(app, eventContext, eventNamespace, elapsed, result);\n return result;\n } catch (error) {\n await publishError(app, eventContext, eventNamespace, elapsed, error);\n throw error;\n }\n};\n\nexport const apiWrapperSync = (app, eventNamespace, isAuthorized, eventContext, func, ...params) => {\n pushCallStack(app, eventNamespace);\n\n if (!isAuthorized(app)) {\n handleNotAuthorized(app, eventContext, eventNamespace);\n return;\n }\n\n const startDate = Date.now();\n const elapsed = () => (Date.now() - startDate);\n\n try {\n app.publish(\n eventNamespace.onBegin,\n eventContext,\n );\n\n const result = func(...params);\n\n publishComplete(app, eventContext, eventNamespace, elapsed, result);\n return result;\n } catch (error) {\n publishError(app, eventContext, eventNamespace, elapsed, error);\n throw error;\n }\n};\n\nconst handleNotAuthorized = (app, eventContext, eventNamespace) => {\n const err = new UnauthorisedError(`Unauthorized: ${eventNamespace}`);\n publishError(app, eventContext, eventNamespace, () => 0, err);\n throw err;\n};\n\nconst pushCallStack = (app, eventNamespace, seedCallId) => {\n const callId = generate();\n\n const createCallStack = () => ({\n seedCallId: !isUndefined(seedCallId)\n ? seedCallId\n : callId,\n threadCallId: callId,\n stack: [],\n });\n\n if (isUndefined(app.calls)) {\n app.calls = createCallStack();\n }\n\n app.calls.stack.push({\n namespace: eventNamespace,\n callId,\n });\n};\n\nconst popCallStack = (app) => {\n app.calls.stack.pop();\n if (app.calls.stack.length === 0) {\n delete app.calls;\n }\n};\n\nconst publishError = async (app, eventContext, eventNamespace, elapsed, err) => {\n const ctx = cloneDeep(eventContext);\n ctx.error = err;\n ctx.elapsed = elapsed();\n await app.publish(\n eventNamespace.onError,\n ctx,\n );\n popCallStack(app);\n};\n\nconst publishComplete = async (app, eventContext, eventNamespace, elapsed, result) => {\n const endcontext = cloneDeep(eventContext);\n endcontext.result = result;\n endcontext.elapsed = elapsed();\n await app.publish(\n eventNamespace.onComplete,\n endcontext,\n );\n popCallStack(app);\n return result;\n};\n\nexport default apiWrapper;\n",
"import {\n \n head, \n tail, findIndex, startsWith, \n dropRight, flow, takeRight, trim,\n replace\n \n} from 'lodash';\nimport { \n some, reduce, isEmpty, isArray, join,\n isString, isInteger, isDate, toNumber,\n isUndefined, isNaN, isNull, constant,\n split, includes\n} from 'lodash/fp';\nimport { events, eventsList } from './events';\nimport { apiWrapper } from './apiWrapper';\nimport {\n getLock, NO_LOCK,\n isNolock\n} from './lock';\n\n// this is the combinator function\nexport const $$ = (...funcs) => arg => flow(funcs)(arg);\n\n// this is the pipe function\nexport const $ = (arg, funcs) => $$(...funcs)(arg);\n\nexport const keySep = '/';\nconst trimKeySep = str => trim(str, keySep);\nconst splitByKeySep = str => split(keySep)(str);\nexport const safeKey = key => replace(`${keySep}${trimKeySep(key)}`, `${keySep}${keySep}`, keySep);\nexport const joinKey = (...strs) => {\n const paramsOrArray = strs.length === 1 & isArray(strs[0])\n ? strs[0] : strs;\n return safeKey(join(keySep)(paramsOrArray));\n};\nexport const splitKey = $$(trimKeySep, splitByKeySep);\nexport const getDirFomKey = $$(splitKey, dropRight, p => joinKey(...p));\nexport const getFileFromKey = $$(splitKey, takeRight, head);\n\nexport const configFolder = `${keySep}.config`;\nexport const fieldDefinitions = joinKey(configFolder, 'fields.json');\nexport const templateDefinitions = joinKey(configFolder, 'templates.json');\nexport const appDefinitionFile = joinKey(configFolder, 'appDefinition.json');\nexport const dirIndex = folderPath => joinKey(configFolder, 'dir', ...splitKey(folderPath), 'dir.idx');\nexport const getIndexKeyFromFileKey = $$(getDirFomKey, dirIndex);\n\nexport const ifExists = (val, exists, notExists) => (isUndefined(val)\n ? isUndefined(notExists) ? (() => { })() : notExists()\n : exists());\n\nexport const getOrDefault = (val, defaultVal) => ifExists(val, () => val, () => defaultVal);\n\nexport const not = func => val => !func(val);\nexport const isDefined = not(isUndefined);\nexport const isNonNull = not(isNull);\nexport const isNotNaN = not(isNaN);\n\nexport const allTrue = (...funcArgs) => val => reduce(\n (result, conditionFunc) => (isNull(result) || result == true) && conditionFunc(val),\n null)(funcArgs);\n\nexport const anyTrue = (...funcArgs) => val => reduce(\n (result, conditionFunc) => result == true || conditionFunc(val),\n null)(funcArgs);\n\nexport const insensitiveEquals = (str1, str2) => str1.trim().toLowerCase() === str2.trim().toLowerCase();\n\nexport const isSomething = allTrue(isDefined, isNonNull, isNotNaN);\nexport const isNothing = not(isSomething);\nexport const isNothingOrEmpty = v => isNothing(v) || isEmpty(v);\nexport const somethingOrGetDefault = getDefaultFunc => val => (isSomething(val) ? val : getDefaultFunc());\nexport const somethingOrDefault = (val, defaultVal) => somethingOrGetDefault(constant(defaultVal))(val);\n\nexport const mapIfSomethingOrDefault = (mapFunc, defaultVal) => val => (isSomething(val) ? mapFunc(val) : defaultVal);\n\nexport const mapIfSomethingOrBlank = mapFunc => mapIfSomethingOrDefault(mapFunc, '');\n\nexport const none = predicate => collection => !some(predicate)(collection);\n\nexport const all = predicate => collection => none(v => !predicate(v))(collection);\n\nexport const isNotEmpty = ob => !isEmpty(ob);\nexport const isAsync = fn => fn.constructor.name === 'AsyncFunction';\nexport const isNonEmptyArray = allTrue(isArray, isNotEmpty);\nexport const isNonEmptyString = allTrue(isString, isNotEmpty);\nexport const tryOr = failFunc => (func, ...args) => {\n try {\n return func.apply(null, ...args);\n } catch (_) {\n return failFunc();\n }\n};\n\nexport const tryAwaitOr = failFunc => async (func, ...args) => {\n try {\n return await func.apply(null, ...args);\n } catch (_) {\n return await failFunc();\n }\n};\n\nexport const defineError = (func, errorPrefix) => {\n try {\n return func();\n } catch (err) {\n err.message = `${errorPrefix} : ${err.message}`;\n throw err;\n }\n};\n\nexport const tryOrIgnore = tryOr(() => { }
"import {\r\n isObject\r\n} from \"lodash/fp\";\r\n\r\n\r\nexport const setState = (store, path, value) => {\r\n\r\n if(!path || path.length === 0) return;\r\n\r\n const pathParts = path.split(\".\");\r\n const safeSetPath = (obj, currentPartIndex=0) => {\r\n\r\n const currentKey = pathParts[currentPartIndex];\r\n\r\n if(pathParts.length - 1 == currentPartIndex) {\r\n obj[currentKey] = value;\r\n return;\r\n }\r\n\r\n if(obj[currentKey] === null \r\n || obj[currentKey] === undefined\r\n || !isObject(obj.currentKey)) {\r\n\r\n obj[currentKey] = {};\r\n }\r\n\r\n safeSetPath(obj[currentKey], currentPartIndex + 1);\r\n\r\n }\r\n\r\n store.update(s => {\r\n safeSetPath(s);\r\n return s;\r\n });\r\n}",
"export const BB_STATE_BINDINGPATH = \"##bbstate\";\r\nexport const BB_STATE_BINDINGSOURCE = \"##bbsource\";\r\nexport const BB_STATE_FALLBACK = \"##bbstatefallback\";\r\n\r\nexport const isBound = (prop) => prop[BB_STATE_BINDINGPATH] !== undefined;\r\nexport const takeStateFromStore = (prop) => \r\n prop[BB_STATE_BINDINGSOURCE] === undefined \r\n || prop[BB_STATE_BINDINGSOURCE] === \"store\";\r\n\r\nexport const takeStateFromContext = (prop) => \r\n prop[BB_STATE_BINDINGSOURCE] === \"context\";\r\n\r\nexport const takeStateFromEventParameters = (prop) => \r\n prop[BB_STATE_BINDINGSOURCE] === \"event\";",
"import {\r\n isUndefined,\r\n isObject\r\n} from \"lodash/fp\";\r\nimport { \r\n isBound,BB_STATE_BINDINGPATH, BB_STATE_FALLBACK, takeStateFromStore\r\n} from \"./isState\";\r\n\r\nexport const getState = (s, path, fallback) => {\r\n\r\n if(!path || path.length === 0) return fallback;\r\n\r\n const pathParts = path.split(\".\");\r\n const safeGetPath = (obj, currentPartIndex=0) => {\r\n\r\n const currentKey = pathParts[currentPartIndex];\r\n\r\n if(pathParts.length - 1 == currentPartIndex) {\r\n const value = obj[currentKey];\r\n if(isUndefined(value))\r\n return fallback;\r\n else \r\n return value;\r\n }\r\n\r\n if(obj[currentKey] === null \r\n || obj[currentKey] === undefined\r\n || !isObject(obj[currentKey])) {\r\n\r\n return fallback;\r\n }\r\n\r\n return safeGetPath(obj[currentKey], currentPartIndex + 1);\r\n\r\n }\r\n\r\n\r\n return safeGetPath(s);\r\n}\r\n\r\nexport const getStateOrValue = (globalState, prop, currentContext) => {\r\n if(!isBound(prop)) return prop;\r\n\r\n const stateToUse = takeStateFromStore(prop) \r\n ? globalState\r\n : currentContext;\r\n\r\n return getState(stateToUse, prop[BB_STATE_BINDINGPATH], prop[BB_STATE_FALLBACK]);\r\n}",
"\r\nexport const ERROR = \"##error_message\";",
"export const trimSlash = (str) => str.replace(/^\\/+|\\/+$/g, '');",
"import {trimSlash} from \"../common/trimSlash\";\r\n\r\n export const loadRecord = (api) => async ({recordKey, statePath}) => {\r\n\r\n if(!recordKey) {\r\n api.error(\"Load Record: record key not set\");\r\n return;\r\n } \r\n \r\n if(!statePath) {\r\n api.error(\"Load Record: state path not set\");\r\n return;\r\n } \r\n\r\n const record = await api.get({\r\n url:`/api/record/${trimSlash(key)}`\r\n });\r\n\r\n if(api.isSuccess(record))\r\n api.setState(statePath, record);\r\n}",
"import {trimSlash} from \"../common/trimSlash\";\r\n\r\nexport const listRecords = api => async ({indexKey, statePath}) => {\r\n if(!indexKey) {\r\n api.error(\"Load Record: record key not set\");\r\n return;\r\n } \r\n \r\n if(!statePath) {\r\n api.error(\"Load Record: state path not set\");\r\n return;\r\n } \r\n\r\n const records = api.get({\r\n url:`/api/listRecords/${trimSlash(indexKey)}`\r\n });\r\n\r\n if(api.isSuccess(records))\r\n api.setState(statePath, records);\r\n}",
"\r\nexport const USER_STATE_PATH = \"_bbuser\";\r\n\r\nexport const authenticate = (api) => async ({username, password}) => {\r\n\r\n if(!username) {\r\n api.error(\"Authenticate: username not set\");\r\n return;\r\n } \r\n \r\n if(!password) {\r\n api.error(\"Authenticate: password not set\");\r\n return;\r\n } \r\n\r\n const user = await api.post({\r\n url:\"/api/authenticate\",\r\n body : {username, password}\r\n });\r\n\r\n // set user even if error - so it is defined at least\r\n api.setState(USER_STATE_PATH, user);\r\n localStorage.setItem(\"budibase:user\", user);\r\n}",
"import { ERROR } from \"../state/standardState\";\r\nimport {loadRecord} from \"./loadRecord\";\r\nimport {listRecords} from \"./listRecords\";\r\nimport {authenticate} from \"./authenticate\";\r\n\r\nexport const createApi = ({rootPath, setState, getState}) => {\r\n\r\n const apiCall = (method) => ({url, body, notFound, badRequest, forbidden}) => {\r\n fetch(`${rootPath}${url}`, {\r\n method: method,\r\n headers: {\r\n 'Content-Type': 'application/json',\r\n },\r\n body: body && JSON.stringify(body), \r\n credentials: \"same-origin\"\r\n }).then(r => {\r\n switch (r.status) {\r\n case 200:\r\n return r.json();\r\n case 404:\r\n return error(notFound || `${url} Not found`);\r\n case 400:\r\n return error(badRequest || `${url} Bad Request`);\r\n case 403:\r\n return error(forbidden || `${url} Forbidden`);\r\n default:\r\n if(r.status.toString().startsWith(\"2\")\r\n || r.status.toString().startsWith(\"3\"))\r\n return r.json()\r\n else\r\n return error(`${url} - ${r.statusText}`);\r\n }\r\n });\r\n }\r\n\r\n const post = apiCall(\"POST\");\r\n const get = apiCall(\"GET\");\r\n const patch = apiCall(\"PATCH\");\r\n const del = apiCall(\"DELETE\");\r\n\r\n const ERROR_MEMBER = \"##error\";\r\n const error = message => {\r\n const e = {};\r\n e[ERROR_MEMBER] = message;\r\n setState(ERROR, message);\r\n return e;\r\n }\r\n\r\n const isSuccess = obj => !!obj[ERROR_MEMBER];\r\n\r\n const apiOpts = {\r\n rootPath, setState, getState, isSuccess, error,\r\n post, get, patch, delete:del\r\n };\r\n\r\n return {\r\n loadRecord:loadRecord(apiOpts), \r\n listRecords: listRecords(apiOpts),\r\n authenticate: authenticate(apiOpts)\r\n }\r\n}\r\n\r\n\r\n",
"import { ERROR } from \"./standardState\";\r\n\r\nexport const getNewChildRecordToState = (store, coreApi, setState) =>\r\n ({recordKey, collectionName,childRecordType,statePath}) => {\r\n const error = errorHandler(setState);\r\n try {\r\n if(!recordKey) {\r\n error(\"getNewChild > recordKey not set\");\r\n return;\r\n }\r\n\r\n if(!collectionName) {\r\n error(\"getNewChild > collectionName not set\");\r\n return;\r\n }\r\n\r\n if(!childRecordType) {\r\n error(\"getNewChild > childRecordType not set\");\r\n return;\r\n }\r\n\r\n if(!statePath) {\r\n error(\"getNewChild > statePath not set\");\r\n return;\r\n }\r\n\r\n const rec = coreApi.recordApi.getNewChild(recordKey, collectionName, childRecordType);\r\n setState(store, statePath, rec);\r\n }\r\n catch(e) {\r\n error(e.message);\r\n }\r\n}\r\n\r\n\r\nexport const getNewRecordToState = (store, coreApi, setState) =>\r\n ({collectionKey,childRecordType,statePath}) => {\r\n const error = errorHandler(setState);\r\n try {\r\n if(!collectionKey) {\r\n error(\"getNewChild > collectionKey not set\");\r\n return;\r\n }\r\n\r\n if(!childRecordType) {\r\n error(\"getNewChild > childRecordType not set\");\r\n return;\r\n }\r\n\r\n if(!statePath) {\r\n error(\"getNewChild > statePath not set\");\r\n return;\r\n }\r\n\r\n const rec = coreApi.recordApi.getNew(collectionKey, childRecordType);\r\n setState(store, statePath, rec);\r\n }\r\n catch(e) {\r\n error(e.message);\r\n }\r\n}\r\n\r\nconst errorHandler = setState => message => setState(ERROR, message);",
"import { setState } from \"./setState\";\r\nimport { getState } from \"./getState\";\r\nimport {\r\n isArray, isUndefined\r\n} from \"lodash/fp\";\r\n\r\nimport { createApi } from \"../api\";\r\nimport {\r\n getNewChildRecordToState, getNewRecordToState\r\n} from \"./coreHandlers\";\r\n\r\nexport const EVENT_TYPE_MEMBER_NAME = \"##eventHandlerType\";\r\n\r\nexport const eventHandlers = (store,coreApi,rootPath) => {\r\n \r\n const handler = (parameters, execute) => ({\r\n execute, parameters\r\n });\r\n\r\n const setStateWithStore = (path, value) => setState(store, path, value);\r\n\r\n const api = createApi({\r\n rootPath:rootPath,\r\n setState: (path, value) => setStateWithStore,\r\n getState: (path, fallback) => getState(store, path, fallback)\r\n });\r\n\r\n const setStateHandler = ({path, value}) => setState(store, path, value);\r\n \r\n return {\r\n \"Set State\": handler([\"path\", \"value\"], setStateHandler),\r\n \"Load Record\": handler([\"recordKey\", \"statePath\"], api.loadRecord),\r\n \"List Records\": handler([\"indexKey\", \"statePath\"], api.listRecords),\r\n \"Save Record\": handler([\"statePath\"], api.saveRecord),\r\n \r\n \"Get New Child Record\": handler(\r\n [\"recordKey\", \"collectionName\", \"childRecordType\", \"statePath\"], \r\n getNewChildRecordToState(store, coreApi, setStateWithStore)),\r\n\r\n \"Get New Record\": handler(\r\n [\"collectionKey\", \"childRecordType\", \"statePath\"], \r\n getNewRecordToState(store, coreApi, setStateWithStore)),\r\n\r\n \"Authenticate\": handler([\"username\", \"password\"], api.authenticate)\r\n };\r\n};\r\n\r\nexport const isEventType = prop => \r\n isArray(prop) \r\n && prop.length > 0\r\n && !isUndefined(prop[0][EVENT_TYPE_MEMBER_NAME]);\r\n",
"import {\r\n isEventType, eventHandlers, EVENT_TYPE_MEMBER_NAME\r\n} from \"./eventHandlers\";\r\n\r\nimport {\r\n getState\r\n} from \"./getState\";\r\n\r\nimport {\r\n isBound, takeStateFromStore,\r\n takeStateFromContext, takeStateFromEventParameters,\r\n BB_STATE_FALLBACK, BB_STATE_BINDINGPATH\r\n} from \"./isState\";\r\n\r\nconst doNothing = () => {};\r\ndoNothing.isPlaceholder=true;\r\n\r\nexport const setupBinding = (store, rootProps, coreApi, context, rootPath) => {\r\n\r\n const rootInitialProps = {...rootProps};\r\n\r\n const getBindings = (props, initialProps) => {\r\n\r\n const boundProps = [];\r\n const componentEventHandlers = [];\r\n const boundArrays = [];\r\n\r\n for(let propName in props) {\r\n \r\n if(propName === \"_component\") continue;\r\n\r\n const val = initialProps[propName];\r\n \r\n if(isBound(val) && takeStateFromStore(val)) {\r\n\r\n const binding = stateBinding(val);\r\n const fallback = stateFallback(val);\r\n\r\n boundProps.push({ \r\n stateBinding:binding,\r\n fallback, propName\r\n });\r\n\r\n initialProps[propName] = fallback;\r\n } else if(isBound(val) && takeStateFromContext(val)) {\r\n\r\n const binding = stateBinding(val);\r\n const fallback = stateFallback(val);\r\n\r\n initialProps[propName] = getState(\r\n context || {},\r\n binding,\r\n fallback\r\n );\r\n\r\n } else if(isEventType(val)) {\r\n\r\n const handlers = { propName, handlers:[] };\r\n componentEventHandlers.push(handlers);\r\n \r\n for(let e of val) {\r\n handlers.handlers.push({\r\n handlerType: e[EVENT_TYPE_MEMBER_NAME],\r\n parameters: e.parameters\r\n })\r\n }\r\n \r\n initialProps[propName] = doNothing;\r\n } else if(Array.isArray(val)) {\r\n const arrayOfBindings = [];\r\n for(let element of val){\r\n arrayOfBindings.push(getBindings(element, {...element}));\r\n }\r\n\r\n boundArrays.push({ \r\n arrayOfBindings,\r\n propName\r\n });\r\n }\r\n \r\n }\r\n\r\n return {boundProps, componentEventHandlers, boundArrays, initialProps};\r\n }\r\n\r\n\r\n\r\n const bind = (rootBindings) => (component) => {\r\n\r\n if(rootBindings.boundProps.length === 0 \r\n && rootBindings.componentEventHandlers.length === 0\r\n && rootBindings.boundArrays.length === 0) return;\r\n\r\n const handlerTypes = eventHandlers(store, coreApi, rootPath);\r\n\r\n const unsubscribe = store.subscribe(rootState => {\r\n \r\n\r\n const getPropsFromBindings = (s, bindings) => {\r\n\r\n const {boundProps, componentEventHandlers, boundArrays} = bindings;\r\n const newProps = {...bindings.initialProps};\r\n \r\n for(let boundProp of boundProps) {\r\n const val = getState(\r\n s, \r\n boundProp.stateBinding, \r\n boundProp.fallback);\r\n\r\n if(val === undefined && newProps[boundProp.propName] !== undefined) {\r\n delete newProps[boundProp.propName];\r\n }\r\n\r\n if(val !== undefined) {\r\n newProps[boundProp.propName] = val;\r\n }\r\n }\r\n\r\n for(let boundHandler of componentEventHandlers) {\r\n\r\n const closuredHandlers = [];\r\n for(let
"\r\n\r\nexport const createCoreApp = (appDefinition, user) => {\r\n const app = {\r\n datastore: null,\r\n crypto:null,\r\n publish: () => {},\r\n hierarchy: appDefinition.hierarchy,\r\n actions: appDefinition.actions,\r\n user\r\n };\r\n\r\n return app;\r\n}",
"import { filter, map } from 'lodash/fp';\nimport { $, isSomething } from './index';\n\nexport const stringNotEmpty = s => isSomething(s) && s.trim().length > 0;\n\nexport const makerule = (field, error, isValid) => ({ field, error, isValid });\n\nexport const validationError = (rule, item) => ({ ...rule, item });\n\nexport const applyRuleSet = ruleSet => itemToValidate => $(ruleSet, [\n map(applyRule(itemToValidate)),\n filter(isSomething),\n]);\n\nexport const applyRule = itemTovalidate => rule => (rule.isValid(itemTovalidate)\n ? null\n : validationError(rule, itemTovalidate));\n",
"var filters = new Map();\nvar limiters = new Map();\n\nfunction filter(name, handler) {\n if (typeof name !== 'string') {\n throw new TypeError('First argument must be a string.');\n }\n if (typeof handler !== 'function') {\n throw new TypeError('Second argument must be a function.');\n }\n if (filters.has(name)) {\n throw new Error((\"A filter named \" + name + \" is already registered.\"));\n }\n filters.set(name, handler);\n}\n\nfunction limiter(name, handler) {\n if (typeof name !== 'string') {\n throw new TypeError('First argument must be a string.');\n }\n if (typeof handler !== 'function') {\n throw new TypeError('Second argument must be a function.');\n }\n if (limiters.has(name)) {\n throw new Error((\"A limiter named \" + name + \" is already registered.\"));\n }\n limiters.set(name, handler);\n}\n\nfunction compileRawExpression(src) {\n return new Function('context', 'tempVars', // eslint-disable-line\n (\"const sandbox = $nxCompileToSandbox(context, tempVars)\\n try { with (sandbox) { return \" + src + \" } } catch (err) {\\n if (!(err instanceof TypeError)) throw err\\n }\\n $nxClearSandbox()\"));\n}\n\nfunction compileRawCode(src) {\n return new Function('context', 'tempVars', // eslint-disable-line\n (\"const sandbox = $nxCompileToSandbox(context, tempVars)\\n with (sandbox) { \" + src + \" }\\n $nxClearSandbox()\"));\n}\n\nvar filterRegex = /(?:[^\\|]|\\|\\|)+/g;\nvar limiterRegex = /(?:[^&]|&&)+/g;\nvar argsRegex = /\\S+/g;\n\nfunction parseExpression(src) {\n var tokens = src.match(filterRegex);\n if (tokens.length === 1) {\n return compileRawExpression(tokens[0]);\n }\n\n var expression = {\n exec: compileRawExpression(tokens[0]),\n filters: []\n };\n for (var i = 1; i < tokens.length; i++) {\n var filterTokens = tokens[i].match(argsRegex);\n var filterName = filterTokens.shift();\n var effect = filters.get(filterName);\n if (!effect) {\n throw new Error((\"There is no filter named: \" + filterName + \".\"));\n }\n expression.filters.push({ effect: effect, argExpressions: filterTokens.map(compileRawExpression) });\n }\n return expression;\n}\n\nfunction parseCode(src) {\n var tokens = src.match(limiterRegex);\n if (tokens.length === 1) {\n return compileRawCode(tokens[0]);\n }\n\n var code = {\n exec: compileRawCode(tokens[0]),\n limiters: []\n };\n for (var i = 1; i < tokens.length; i++) {\n var limiterTokens = tokens[i].match(argsRegex);\n var limiterName = limiterTokens.shift();\n var effect = limiters.get(limiterName);\n if (!effect) {\n throw new Error((\"There is no limiter named: \" + limiterName + \".\"));\n }\n code.limiters.push({ effect: effect, argExpressions: limiterTokens.map(compileRawExpression) });\n }\n return code;\n}\n\nvar expressionCache = new Map();\nvar codeCache = new Map();\n\nfunction compileExpression(src) {\n if (typeof src !== 'string') {\n throw new TypeError('First argument must be a string.');\n }\n var expression = expressionCache.get(src);\n if (!expression) {\n expression = parseExpression(src);\n expressionCache.set(src, expression);\n }\n\n if (typeof expression === 'function') {\n return expression;\n }\n\n return function evaluateExpression(context, tempVars) {\n var value = expression.exec(context, tempVars);\n for (var i = 0, list = expression.filters; i < list.length; i += 1) {\n var filter = list[i];\n\n var args = filter.argExpressions.map(evaluateArgExpression, context);\n value = filter.effect.apply(filter, [ value ].concat( args ));\n }\n return value;\n };\n}\n\nfunction compileCode(src) {\n if (typeof src !== 'string') {\n throw new TypeError('First argument must be a string.');\n }\n var code = codeCache.get(src);\n if (!code) {\n code = parseCode(src);\n codeCache.set(src, code);\n }\n\n if (typeof code === 'function') {\n return code;\n }\n\n var context = {};\n return function evaluateCode(state, tempVars) {\n var i = 0;\n function next
"import { compileExpression, compileCode } from '@nx-js/compiler-util';\nimport {\n isUndefined, keys, \n cloneDeep, isFunction,\n} from 'lodash/fp';\nimport { defineError } from '../common';\n\nexport const filterEval = 'FILTER_EVALUATE';\nexport const filterCompile = 'FILTER_COMPILE';\nexport const mapEval = 'MAP_EVALUATE';\nexport const mapCompile = 'MAP_COMPILE';\nexport const removeUndeclaredFields = 'REMOVE_UNDECLARED_FIELDS';\nexport const addUnMappedFields = 'ADD_UNMAPPED_FIELDS';\nexport const addTheKey = 'ADD_KEY';\n\n\nconst getEvaluateResult = () => ({\n isError: false,\n passedFilter: true,\n result: null,\n});\n\nexport const compileFilter = index => compileExpression(index.filter);\n\nexport const compileMap = index => compileCode(index.map);\n\nexport const passesFilter = (record, index) => {\n const context = { record };\n if (!index.filter) return true;\n\n const compiledFilter = defineError(\n () => compileFilter(index),\n filterCompile,\n );\n\n return defineError(\n () => compiledFilter(context),\n filterEval,\n );\n};\n\nexport const mapRecord = (record, index) => {\n const recordClone = cloneDeep(record);\n const context = { record: recordClone };\n\n const map = index.map ? index.map : 'return {...record};';\n\n const compiledMap = defineError(\n () => compileCode(map),\n mapCompile,\n );\n\n const mapped = defineError(\n () => compiledMap(context),\n mapEval,\n );\n\n const mappedKeys = keys(mapped);\n for (let i = 0; i < mappedKeys.length; i++) {\n const key = mappedKeys[i];\n mapped[key] = isUndefined(mapped[key]) ? null : mapped[key];\n if (isFunction(mapped[key])) {\n delete mapped[key];\n }\n }\n\n mapped.key = record.key;\n mapped.sortKey = index.getSortKey\n ? compileCode(index.getSortKey)(context)\n : record.id;\n\n return mapped;\n};\n\nexport const evaluate = record => (index) => {\n const result = getEvaluateResult();\n\n try {\n result.passedFilter = passesFilter(record, index);\n } catch (err) {\n result.isError = true;\n result.passedFilter = false;\n result.result = err.message;\n }\n\n if (!result.passedFilter) return result;\n\n try {\n result.result = mapRecord(record, index);\n } catch (err) {\n result.isError = true;\n result.result = err.message;\n }\n\n return result;\n};\n\nexport default evaluate;\n",
"import {\n map, isEmpty, countBy, \n flatten, includes, join, keys\n} from 'lodash/fp';\nimport { } from 'lodash';\nimport { applyRuleSet, makerule } from '../common/validationCommon';\nimport { compileFilter, compileMap } from '../indexing/evaluate';\nimport { isNonEmptyString, executesWithoutException, $ } from '../common';\nimport { isRecord } from './hierarchy';\n\nexport const indexTypes = { reference: 'reference', ancestor: 'ancestor' };\n\nexport const indexRuleSet = [\n makerule('map', 'index has no map function',\n index => isNonEmptyString(index.map)),\n makerule('map', \"index's map function does not compile\",\n index => !isNonEmptyString(index.map)\n || executesWithoutException(() => compileMap(index))),\n makerule('filter', \"index's filter function does not compile\",\n index => !isNonEmptyString(index.filter)\n || executesWithoutException(() => compileFilter(index))),\n makerule('name', 'must declare a name for index',\n index => isNonEmptyString(index.name)),\n makerule('name', 'there is a duplicate named index on this node',\n index => isEmpty(index.name)\n || countBy('name')(index.parent().indexes)[index.name] === 1),\n makerule('indexType', 'reference index may only exist on a record node',\n index => isRecord(index.parent())\n || index.indexType !== indexTypes.reference),\n makerule('indexType', `index type must be one of: ${join(', ')(keys(indexTypes))}`,\n index => includes(index.indexType)(keys(indexTypes))),\n];\n\nexport const validateIndex = (index, allReferenceIndexesOnNode) => applyRuleSet(indexRuleSet(allReferenceIndexesOnNode))(index);\n\nexport const validateAllIndexes = node => $(node.indexes, [\n map(i => validateIndex(i, node.indexes)),\n flatten,\n]);\n",
"import {\n find, constant, map, last,\n first, split, intersection, take,\n union, includes, filter, some,\n} from 'lodash/fp';\nimport {\n $, switchCase, isNothing, isSomething,\n defaultCase, splitKey, isNonEmptyString,\n joinKey, getHashCode,\n} from '../common';\nimport { indexTypes } from './indexes';\n\nexport const getFlattenedHierarchy = (appHierarchy, useCached = true) => {\n if (isSomething(appHierarchy.getFlattenedHierarchy) && useCached) { return appHierarchy.getFlattenedHierarchy(); }\n\n const flattenHierarchy = (currentNode, flattened) => {\n flattened.push(currentNode);\n if ((!currentNode.children\n || currentNode.children.length === 0)\n && (!currentNode.indexes\n || currentNode.indexes.length === 0)\n && (!currentNode.aggregateGroups\n || currentNode.aggregateGroups.length === 0)) {\n return flattened;\n }\n\n const unionIfAny = l2 => l1 => union(l1)(!l2 ? [] : l2);\n\n const children = $([], [\n unionIfAny(currentNode.children),\n unionIfAny(currentNode.indexes),\n unionIfAny(currentNode.aggregateGroups),\n ]);\n\n for (const child of children) {\n flattenHierarchy(child, flattened);\n }\n return flattened;\n };\n\n appHierarchy.getFlattenedHierarchy = () => flattenHierarchy(appHierarchy, []);\n return appHierarchy.getFlattenedHierarchy();\n};\n\nexport const getLastPartInKey = key => last(splitKey(key));\n\nexport const getNodesInPath = appHierarchy => key => $(appHierarchy, [\n getFlattenedHierarchy,\n filter(n => new RegExp(`${n.pathRegx()}`).test(key)),\n]);\n\nexport const getExactNodeForPath = appHierarchy => key => $(appHierarchy, [\n getFlattenedHierarchy,\n find(n => new RegExp(`${n.pathRegx()}$`).test(key)),\n]);\n\nexport const getNodeForCollectionPath = appHierarchy => collectionKey => $(appHierarchy, [\n getFlattenedHierarchy,\n find(n => (isCollectionRecord(n)\n && new RegExp(`${n.collectionPathRegx()}$`).test(collectionKey))),\n]);\n\nexport const hasMatchingAncestor = ancestorPredicate => decendantNode => switchCase(\n\n [node => isNothing(node.parent()),\n constant(false)],\n\n [node => ancestorPredicate(node.parent()),\n constant(true)],\n\n [defaultCase,\n node => hasMatchingAncestor(ancestorPredicate)(node.parent())],\n\n)(decendantNode);\n\nexport const getNode = (appHierarchy, nodeKey) => $(appHierarchy, [\n getFlattenedHierarchy,\n find(n => n.nodeKey() === nodeKey\n || (isCollectionRecord(n)\n && n.collectionNodeKey() === nodeKey)),\n]);\n\nexport const getCollectionNode = (appHierarchy, nodeKey) => $(appHierarchy, [\n getFlattenedHierarchy,\n find(n => (isCollectionRecord(n)\n && n.collectionNodeKey() === nodeKey)),\n]);\n\nexport const getNodeByKeyOrNodeKey = (appHierarchy, keyOrNodeKey) => {\n const nodeByKey = getExactNodeForPath(appHierarchy)(keyOrNodeKey);\n return isNothing(nodeByKey)\n ? getNode(appHierarchy, keyOrNodeKey)\n : nodeByKey;\n};\n\nexport const getCollectionNodeByKeyOrNodeKey = (appHierarchy, keyOrNodeKey) => {\n const nodeByKey = getNodeForCollectionPath(appHierarchy)(keyOrNodeKey);\n return isNothing(nodeByKey)\n ? getCollectionNode(appHierarchy, keyOrNodeKey)\n : nodeByKey;\n};\n\nexport const isNode = (appHierarchy, key) => isSomething(getExactNodeForPath(appHierarchy)(key));\n\nexport const getActualKeyOfParent = (parentNodeKey, actualChildKey) => $(actualChildKey, [\n splitKey,\n take(splitKey(parentNodeKey).length),\n ks => joinKey(...ks),\n]);\n\nexport const getParentKey = (key) => {\n return $(key, [\n splitKey,\n take(splitKey(key).length - 1),\n joinKey,\n ]);\n};\n\nexport const isKeyAncestorOf = ancestorKey => decendantNode => hasMatchingAncestor(p => p.nodeKey() === ancestorKey)(decendantNode);\n\nexport const hasNoMatchingAncestors = parentPredicate => node => !hasMatchingAncestor(parentPredicate)(node);\n\nexport const findField = (recordNode, fieldName) => find(f => f.name == fieldName)(record
"import { merge } from 'lodash';\nimport {\n constant, isUndefined, has,\n mapValues, cloneDeep,\n} from 'lodash/fp';\nimport { isNotEmpty } from '../common';\n\nexport const getSafeFieldParser = (tryParse, defaultValueFunctions) => (field, record) => {\n if (has(field.name)(record)) {\n return getSafeValueParser(tryParse, defaultValueFunctions)(record[field.name]);\n }\n return defaultValueFunctions[field.getUndefinedValue]();\n};\n\nexport const getSafeValueParser = (tryParse, defaultValueFunctions) => (value) => {\n const parsed = tryParse(value);\n if (parsed.success) {\n return parsed.value;\n }\n return defaultValueFunctions.default();\n};\n\nexport const getNewValue = (tryParse, defaultValueFunctions) => (field) => {\n const getInitialValue = isUndefined(field) || isUndefined(field.getInitialValue)\n ? 'default'\n : field.getInitialValue;\n\n return has(getInitialValue)(defaultValueFunctions)\n ? defaultValueFunctions[getInitialValue]()\n : getSafeValueParser(tryParse, defaultValueFunctions)(getInitialValue);\n};\n\nexport const typeFunctions = specificFunctions => merge({\n value: constant,\n null: constant(null),\n}, specificFunctions);\n\nexport const validateTypeConstraints = validationRules => async (field, record, context) => {\n const fieldValue = record[field.name];\n const validateRule = async r => (!await r.isValid(fieldValue, field.typeOptions, context)\n ? r.getMessage(fieldValue, field.typeOptions)\n : '');\n\n const errors = [];\n for (const r of validationRules) {\n const err = await validateRule(r);\n if (isNotEmpty(err)) errors.push(err);\n }\n\n return errors;\n};\n\nconst getDefaultOptions = mapValues(v => v.defaultValue);\n\nexport const makerule = (isValid, getMessage) => ({ isValid, getMessage });\nexport const parsedFailed = val => ({ success: false, value: val });\nexport const parsedSuccess = val => ({ success: true, value: val });\nexport const getDefaultExport = (name, tryParse, functions, options, validationRules, sampleValue, stringify) => ({\n getNew: getNewValue(tryParse, functions),\n safeParseField: getSafeFieldParser(tryParse, functions),\n safeParseValue: getSafeValueParser(tryParse, functions),\n tryParse,\n name,\n getDefaultOptions: () => getDefaultOptions(cloneDeep(options)),\n optionDefinitions: options,\n validateTypeConstraints: validateTypeConstraints(validationRules),\n sampleValue,\n stringify: val => (val === null || val === undefined\n ? '' : stringify(val)),\n getDefaultValue: functions.default,\n});\n",
"import {\n constant, isString,\n isNull, includes, isBoolean,\n} from 'lodash/fp';\nimport {\n typeFunctions,\n makerule, parsedSuccess, getDefaultExport,\n} from './typeHelpers';\nimport {\n switchCase, defaultCase, toBoolOrNull, toNumberOrNull,\n isSafeInteger, isArrayOfString,\n} from '../common';\n\nconst stringFunctions = typeFunctions({\n default: constant(null),\n});\n\nconst stringTryParse = switchCase(\n [isString, parsedSuccess],\n [isNull, parsedSuccess],\n [defaultCase, v => parsedSuccess(v.toString())],\n);\n\nconst options = {\n maxLength: {\n defaultValue: null,\n isValid: n => n === null || isSafeInteger(n) && n > 0,\n requirementDescription: 'max length must be null (no limit) or a greater than zero integer',\n parse: toNumberOrNull,\n },\n values: {\n defaultValue: null,\n isValid: v => v === null || (isArrayOfString(v) && v.length > 0 && v.length < 10000),\n requirementDescription: \"'values' must be null (no values) or an arry of at least one string\",\n parse: s => s,\n },\n allowDeclaredValuesOnly: {\n defaultValue: false,\n isValid: isBoolean,\n requirementDescription: 'allowDeclaredValuesOnly must be true or false',\n parse: toBoolOrNull,\n },\n};\n\nconst typeConstraints = [\n makerule(async (val, opts) => val === null || opts.maxLength === null || val.length <= opts.maxLength,\n (val, opts) => `value exceeds maximum length of ${opts.maxLength}`),\n makerule(async (val, opts) => val === null\n || opts.allowDeclaredValuesOnly === false\n || includes(val)(opts.values),\n (val) => `\"${val}\" does not exist in the list of allowed values`),\n];\n\nexport default getDefaultExport(\n 'string',\n stringTryParse,\n stringFunctions,\n options,\n typeConstraints,\n 'abcde',\n str => str,\n);\n",
"import { constant, isBoolean, isNull } from 'lodash/fp';\nimport {\n typeFunctions,\n makerule, parsedFailed, parsedSuccess,\n getDefaultExport,\n} from './typeHelpers';\nimport {\n switchCase, defaultCase, isOneOf, toBoolOrNull,\n} from '../common';\n\nconst boolFunctions = typeFunctions({\n default: constant(null),\n});\n\nconst boolTryParse = switchCase(\n [isBoolean, parsedSuccess],\n [isNull, parsedSuccess],\n [isOneOf('true', '1', 'yes', 'on'), () => parsedSuccess(true)],\n [isOneOf('false', '0', 'no', 'off'), () => parsedSuccess(false)],\n [defaultCase, parsedFailed],\n);\n\nconst options = {\n allowNulls: {\n defaultValue: true,\n isValid: isBoolean,\n requirementDescription: 'must be a true or false',\n parse: toBoolOrNull,\n },\n};\n\nconst typeConstraints = [\n makerule(async (val, opts) => opts.allowNulls === true || val !== null,\n () => 'field cannot be null'),\n];\n\nexport default getDefaultExport(\n 'bool', boolTryParse, boolFunctions,\n options, typeConstraints, true, JSON.stringify,\n);\n",
"import {\n constant, isNumber, isString, isNull,\n} from 'lodash/fp';\nimport {\n makerule, typeFunctions,\n parsedFailed, parsedSuccess, getDefaultExport,\n} from './typeHelpers';\nimport {\n switchCase, defaultCase, toNumberOrNull,\n isSafeInteger,\n} from '../common';\n\nconst numberFunctions = typeFunctions({\n default: constant(null),\n});\n\nconst parseStringtoNumberOrNull = (s) => {\n const num = Number(s);\n return isNaN(num) ? parsedFailed(s) : parsedSuccess(num);\n};\n\nconst numberTryParse = switchCase(\n [isNumber, parsedSuccess],\n [isString, parseStringtoNumberOrNull],\n [isNull, parsedSuccess],\n [defaultCase, parsedFailed],\n);\n\nconst options = {\n maxValue: {\n defaultValue: Number.MAX_SAFE_INTEGER,\n isValid: isSafeInteger,\n requirementDescription: 'must be a valid integer',\n parse: toNumberOrNull,\n },\n minValue: {\n defaultValue: 0 - Number.MAX_SAFE_INTEGER,\n isValid: isSafeInteger,\n requirementDescription: 'must be a valid integer',\n parse: toNumberOrNull,\n },\n decimalPlaces: {\n defaultValue: 0,\n isValid: n => isSafeInteger(n) && n >= 0,\n requirementDescription: 'must be a positive integer',\n parse: toNumberOrNull,\n },\n};\n\nconst getDecimalPlaces = (val) => {\n const splitDecimal = val.toString().split('.');\n if (splitDecimal.length === 1) return 0;\n return splitDecimal[1].length;\n};\n\nconst typeConstraints = [\n makerule(async (val, opts) => val === null || opts.minValue === null || val >= opts.minValue,\n (val, opts) => `value (${val.toString()}) must be greater than or equal to ${opts.minValue}`),\n makerule(async (val, opts) => val === null || opts.maxValue === null || val <= opts.maxValue,\n (val, opts) => `value (${val.toString()}) must be less than or equal to ${opts.minValue} options`),\n makerule(async (val, opts) => val === null || opts.decimalPlaces >= getDecimalPlaces(val),\n (val, opts) => `value (${val.toString()}) must have ${opts.decimalPlaces} decimal places or less`),\n];\n\nexport default getDefaultExport(\n 'number',\n numberTryParse,\n numberFunctions,\n options,\n typeConstraints,\n 1,\n num => num.toString(),\n);\n",
"import {\n constant, isDate, isString, isNull\n} from 'lodash/fp';\nimport {\n makerule, typeFunctions,\n parsedFailed, parsedSuccess, getDefaultExport,\n} from './typeHelpers';\nimport {\n switchCase, defaultCase, toDateOrNull,\n} from '../common';\n\nconst dateFunctions = typeFunctions({\n default: constant(null),\n now: () => new Date(),\n});\n\nconst isValidDate = d => d instanceof Date && !isNaN(d);\n\nconst parseStringToDate = s => switchCase(\n [isValidDate, parsedSuccess],\n [defaultCase, parsedFailed],\n)(new Date(s));\n\n\nconst dateTryParse = switchCase(\n [isDate, parsedSuccess],\n [isString, parseStringToDate],\n [isNull, parsedSuccess],\n [defaultCase, parsedFailed],\n);\n\nconst options = {\n maxValue: {\n defaultValue: new Date(32503680000000),\n isValid: isDate,\n requirementDescription: 'must be a valid date',\n parse: toDateOrNull,\n },\n minValue: {\n defaultValue: new Date(-8520336000000),\n isValid: isDate,\n requirementDescription: 'must be a valid date',\n parse: toDateOrNull,\n },\n};\n\nconst typeConstraints = [\n makerule(async (val, opts) => val === null || opts.minValue === null || val >= opts.minValue,\n (val, opts) => `value (${val.toString()}) must be greater than or equal to ${opts.minValue}`),\n makerule(async (val, opts) => val === null || opts.maxValue === null || val <= opts.maxValue,\n (val, opts) => `value (${val.toString()}) must be less than or equal to ${opts.minValue} options`),\n];\n\nexport default getDefaultExport(\n 'datetime',\n dateTryParse,\n dateFunctions,\n options,\n typeConstraints,\n new Date(1984, 4, 1),\n date => JSON.stringify(date).replace(new RegExp('\"', 'g'), ''),\n);\n",
"import { \n map, constant, isArray \n} from 'lodash/fp';\nimport {\n typeFunctions, makerule,\n parsedFailed, getDefaultExport, parsedSuccess,\n} from './typeHelpers';\nimport {\n switchCase, defaultCase, toNumberOrNull,\n $$, isSafeInteger,\n} from '../common';\n\nconst arrayFunctions = () => typeFunctions({\n default: constant([]),\n});\n\nconst mapToParsedArrary = type => $$(\n map(i => type.safeParseValue(i)),\n parsedSuccess,\n);\n\nconst arrayTryParse = type => switchCase(\n [isArray, mapToParsedArrary(type)],\n [defaultCase, parsedFailed],\n);\n\nconst typeName = type => `array<${type}>`;\n\n\nconst options = {\n maxLength: {\n defaultValue: 10000,\n isValid: isSafeInteger,\n requirementDescription: 'must be a positive integer',\n parse: toNumberOrNull,\n },\n minLength: {\n defaultValue: 0,\n isValid: n => isSafeInteger(n) && n >= 0,\n requirementDescription: 'must be a positive integer',\n parse: toNumberOrNull,\n },\n};\n\nconst typeConstraints = [\n makerule(async (val, opts) => val === null || val.length >= opts.minLength,\n (val, opts) => `must choose ${opts.minLength} or more options`),\n makerule(async (val, opts) => val === null || val.length <= opts.maxLength,\n (val, opts) => `cannot choose more than ${opts.maxLength} options`),\n];\n\nexport default type => getDefaultExport(\n typeName(type.name),\n arrayTryParse(type),\n arrayFunctions(type),\n options,\n typeConstraints,\n [type.sampleValue],\n JSON.stringify,\n);\n",
"import {\n isString, isObjectLike,\n isNull, has, isEmpty,\n} from 'lodash/fp';\nimport {\n typeFunctions, makerule,\n parsedSuccess, getDefaultExport,\n parsedFailed,\n} from './typeHelpers';\nimport {\n switchCase, defaultCase,\n isNonEmptyString, isArrayOfString,\n} from '../common';\n\nconst referenceNothing = () => ({ key: '' });\n\nconst referenceFunctions = typeFunctions({\n default: referenceNothing,\n});\n\nconst hasStringValue = (ob, path) => has(path)(ob)\n && isString(ob[path]);\n\nconst isObjectWithKey = v => isObjectLike(v)\n && hasStringValue(v, 'key');\n\nconst tryParseFromString = s => {\n\n try {\n const asObj = JSON.parse(s);\n if(isObjectWithKey) {\n return parsedSuccess(asObj);\n }\n }\n catch(_) {\n // EMPTY\n }\n\n return parsedFailed(s);\n}\n\nconst referenceTryParse = v => switchCase(\n [isObjectWithKey, parsedSuccess],\n [isString, tryParseFromString],\n [isNull, () => parsedSuccess(referenceNothing())],\n [defaultCase, parsedFailed],\n)(v);\n\nconst options = {\n indexNodeKey: {\n defaultValue: null,\n isValid: isNonEmptyString,\n requirementDescription: 'must be a non-empty string',\n parse: s => s,\n },\n displayValue: {\n defaultValue: '',\n isValid: isNonEmptyString,\n requirementDescription: 'must be a non-empty string',\n parse: s => s,\n },\n reverseIndexNodeKeys: {\n defaultValue: null,\n isValid: v => isArrayOfString(v) && v.length > 0,\n requirementDescription: 'must be a non-empty array of strings',\n parse: s => s,\n },\n};\n\nconst isEmptyString = s => isString(s) && isEmpty(s);\n\nconst ensureReferenceExists = async (val, opts, context) => isEmptyString(val.key)\n || await context.referenceExists(opts, val.key);\n\nconst typeConstraints = [\n makerule(\n ensureReferenceExists,\n (val, opts) => `\"${val[opts.displayValue]}\" does not exist in options list (key: ${val.key})`,\n ),\n];\n\nexport default getDefaultExport(\n 'reference',\n referenceTryParse,\n referenceFunctions,\n options,\n typeConstraints,\n { key: 'key', value: 'value' },\n JSON.stringify,\n);\n",
"import {\n last, has, isString, intersection,\n isNull, isNumber,\n} from 'lodash/fp';\nimport {\n typeFunctions, parsedFailed,\n parsedSuccess, getDefaultExport,\n} from './typeHelpers';\nimport {\n switchCase, defaultCase, none,\n $, splitKey,\n} from '../common';\n\nconst illegalCharacters = '*?\\\\/:<>|\\0\\b\\f\\v';\n\nexport const isLegalFilename = (filePath) => {\n const fn = fileName(filePath);\n return fn.length <= 255\n && intersection(fn.split(''))(illegalCharacters.split('')).length === 0\n && none(f => f === '..')(splitKey(filePath));\n};\n\nconst fileNothing = () => ({ relativePath: '', size: 0 });\n\nconst fileFunctions = typeFunctions({\n default: fileNothing,\n});\n\nconst fileTryParse = v => switchCase(\n [isValidFile, parsedSuccess],\n [isNull, () => parsedSuccess(fileNothing())],\n [defaultCase, parsedFailed],\n)(v);\n\nconst fileName = filePath => $(filePath, [\n splitKey,\n last,\n]);\n\nconst isValidFile = f => !isNull(f)\n && has('relativePath')(f) && has('size')(f)\n && isNumber(f.size)\n && isString(f.relativePath)\n && isLegalFilename(f.relativePath);\n\nconst options = {};\n\nconst typeConstraints = [];\n\nexport default getDefaultExport(\n 'file',\n fileTryParse,\n fileFunctions,\n options,\n typeConstraints,\n { relativePath: 'some_file.jpg', size: 1000 },\n JSON.stringify,\n);\n",
"import {\n assign, merge, \n} from 'lodash';\nimport {\n map, isString, isNumber,\n isBoolean, isDate, keys,\n isObject, isArray, has\n} from 'lodash/fp';\nimport { $ } from '../common';\nimport { parsedSuccess } from './typeHelpers';\nimport string from './string';\nimport bool from './bool';\nimport number from './number';\nimport datetime from './datetime';\nimport array from './array';\nimport reference from './reference';\nimport file from './file';\nimport { BadRequestError } from '../common/errors';\n\nconst allTypes = () => {\n const basicTypes = {\n string, number, datetime, bool, reference, file,\n };\n\n const arrays = $(basicTypes, [\n keys,\n map((k) => {\n const kvType = {};\n const concreteArray = array(basicTypes[k]);\n kvType[concreteArray.name] = concreteArray;\n return kvType;\n }),\n types => assign({}, ...types),\n ]);\n\n return merge({}, basicTypes, arrays);\n};\n\n\nexport const all = allTypes();\n\nexport const getType = (typeName) => {\n if (!has(typeName)(all)) throw new BadRequestError(`Do not recognise type ${typeName}`);\n return all[typeName];\n};\n\nexport const getSampleFieldValue = field => getType(field.type).sampleValue;\n\nexport const getNewFieldValue = field => getType(field.type).getNew(field);\n\nexport const safeParseField = (field, record) => getType(field.type).safeParseField(field, record);\n\nexport const validateFieldParse = (field, record) => (has(field.name)(record)\n ? getType(field.type).tryParse(record[field.name])\n : parsedSuccess(undefined)); // fields may be undefined by default\n\nexport const getDefaultOptions = type => getType(type).getDefaultOptions();\n\nexport const validateTypeConstraints = async (field, record, context) => await getType(field.type).validateTypeConstraints(field, record, context);\n\nexport const detectType = (value) => {\n if (isString(value)) return string;\n if (isBoolean(value)) return bool;\n if (isNumber(value)) return number;\n if (isDate(value)) return datetime;\n if (isArray(value)) return array(detectType(value[0]));\n if (isObject(value)\n && has('key')(value)\n && has('value')(value)) return reference;\n if (isObject(value)\n && has('relativePath')(value)\n && has('size')(value)) return file;\n\n throw new BadRequestError(`cannot determine type: ${JSON.stringify(value)}`);\n};\n",
"import { clone, find, split } from 'lodash/fp';\nimport { joinKey, $ } from '../common';\n// 5 minutes\nexport const tempCodeExpiryLength = 5 * 60 * 1000;\n\nexport const AUTH_FOLDER = '/.auth';\nexport const USERS_LIST_FILE = joinKey(AUTH_FOLDER, 'users.json');\nexport const userAuthFile = username => joinKey(AUTH_FOLDER, `auth_${username}.json`);\nexport const USERS_LOCK_FILE = joinKey(AUTH_FOLDER, 'users_lock');\nexport const ACCESS_LEVELS_FILE = joinKey(AUTH_FOLDER, 'access_levels.json');\nexport const ACCESS_LEVELS_LOCK_FILE = joinKey(AUTH_FOLDER, 'access_levels_lock');\n\nexport const permissionTypes = {\n CREATE_RECORD: 'create record',\n UPDATE_RECORD: 'update record',\n READ_RECORD: 'read record',\n DELETE_RECORD: 'delete record',\n READ_INDEX: 'read index',\n MANAGE_INDEX: 'manage index',\n MANAGE_COLLECTION: 'manage collection',\n WRITE_TEMPLATES: 'write templates',\n CREATE_USER: 'create user',\n SET_PASSWORD: 'set password',\n CREATE_TEMPORARY_ACCESS: 'create temporary access',\n ENABLE_DISABLE_USER: 'enable or disable user',\n WRITE_ACCESS_LEVELS: 'write access levels',\n LIST_USERS: 'list users',\n LIST_ACCESS_LEVELS: 'list access levels',\n EXECUTE_ACTION: 'execute action',\n SET_USER_ACCESS_LEVELS: 'set user access levels',\n};\n\nexport const getUserByName = (users, name) => $(users, [\n find(u => u.name.toLowerCase() === name.toLowerCase()),\n]);\n\nexport const stripUserOfSensitiveStuff = (user) => {\n const stripped = clone(user);\n delete stripped.tempCode;\n return stripped;\n};\n\nexport const parseTemporaryCode = fullCode => $(fullCode, [\n split(':'),\n parts => ({\n id: parts[1],\n code: parts[2],\n }),\n]);\n",
"import { values, includes, some } from 'lodash/fp';\nimport { permissionTypes } from './authCommon';\nimport {\n $, isNothing, apiWrapperSync, events,\n} from '../common';\nimport { getNodeByKeyOrNodeKey, isNode } from '../templateApi/hierarchy';\nimport { alwaysAuthorized } from './permissions';\n\nexport const isAuthorized = app => (permissionType, resourceKey) => apiWrapperSync(\n app,\n events.authApi.isAuthorized,\n alwaysAuthorized,\n { resourceKey, permissionType },\n _isAuthorized, app, permissionType, resourceKey,\n);\n\nexport const _isAuthorized = (app, permissionType, resourceKey) => {\n if (!app.user) {\n return false;\n }\n\n const validType = $(permissionTypes, [\n values,\n includes(permissionType),\n ]);\n\n if (!validType) {\n return false;\n }\n\n const permMatchesResource = (userperm) => {\n const nodeKey = isNothing(resourceKey)\n ? null\n : isNode(app.hierarchy, resourceKey)\n ? getNodeByKeyOrNodeKey(\n app.hierarchy, resourceKey,\n ).nodeKey()\n : resourceKey;\n\n return (userperm.type === permissionType)\n && (\n isNothing(resourceKey)\n || nodeKey === userperm.nodeKey\n );\n };\n\n return $(app.user.permissions, [\n some(permMatchesResource),\n ]);\n};\n",
"import { permissionTypes } from './authCommon';\nimport { isAuthorized } from './isAuthorized';\n\nexport const temporaryAccessPermissions = () => ([{ type: permissionTypes.SET_PASSWORD }]);\n\nconst nodePermission = type => ({\n add: (nodeKey, accessLevel) => accessLevel.permissions.push({ type, nodeKey }),\n isAuthorized: resourceKey => app => isAuthorized(app)(type, resourceKey),\n isNode: true,\n get: nodeKey => ({ type, nodeKey }),\n});\n\nconst staticPermission = type => ({\n add: accessLevel => accessLevel.permissions.push({ type }),\n isAuthorized: app => isAuthorized(app)(type),\n isNode: false,\n get: () => ({ type }),\n});\n\nconst createRecord = nodePermission(permissionTypes.CREATE_RECORD);\n\nconst updateRecord = nodePermission(permissionTypes.UPDATE_RECORD);\n\nconst deleteRecord = nodePermission(permissionTypes.DELETE_RECORD);\n\nconst readRecord = nodePermission(permissionTypes.READ_RECORD);\n\nconst writeTemplates = staticPermission(permissionTypes.WRITE_TEMPLATES);\n\nconst createUser = staticPermission(permissionTypes.CREATE_USER);\n\nconst setPassword = staticPermission(permissionTypes.SET_PASSWORD);\n\nconst readIndex = nodePermission(permissionTypes.READ_INDEX);\n\nconst manageIndex = staticPermission(permissionTypes.MANAGE_INDEX);\n\nconst manageCollection = staticPermission(permissionTypes.MANAGE_COLLECTION);\n\nconst createTemporaryAccess = staticPermission(permissionTypes.CREATE_TEMPORARY_ACCESS);\n\nconst enableDisableUser = staticPermission(permissionTypes.ENABLE_DISABLE_USER);\n\nconst writeAccessLevels = staticPermission(permissionTypes.WRITE_ACCESS_LEVELS);\n\nconst listUsers = staticPermission(permissionTypes.LIST_USERS);\n\nconst listAccessLevels = staticPermission(permissionTypes.LIST_ACCESS_LEVELS);\n\nconst setUserAccessLevels = staticPermission(permissionTypes.SET_USER_ACCESS_LEVELS);\n\nconst executeAction = nodePermission(permissionTypes.EXECUTE_ACTION);\n\nexport const alwaysAuthorized = () => true;\n\nexport const permission = {\n createRecord,\n updateRecord,\n deleteRecord,\n readRecord,\n writeTemplates,\n createUser,\n setPassword,\n readIndex,\n createTemporaryAccess,\n enableDisableUser,\n writeAccessLevels,\n listUsers,\n listAccessLevels,\n manageIndex,\n manageCollection,\n executeAction,\n setUserAccessLevels,\n};\n",
"import {\n keyBy, mapValues,\n} from 'lodash/fp';\nimport { generate } from 'shortid';\nimport { getNodeForCollectionPath } from '../templateApi/hierarchy';\nimport { getNewFieldValue } from '../types';\nimport {\n $, joinKey, safeKey, apiWrapperSync, events,\n} from '../common';\nimport { permission } from '../authApi/permissions';\n\nexport const getNew = app => (collectionKey, recordTypeName) => {\n const recordNode = getRecordNode(app, collectionKey, recordTypeName);\n collectionKey=safeKey(collectionKey);\n return apiWrapperSync(\n app,\n events.recordApi.getNew,\n permission.createRecord.isAuthorized(recordNode.nodeKey()),\n { collectionKey, recordTypeName },\n _getNew, recordNode, collectionKey,\n );\n};\n\nconst _getNew = (recordNode, collectionKey) => constructRecord(recordNode, getNewFieldValue, collectionKey);\n\nconst getRecordNode = (app, collectionKey) => {\n collectionKey = safeKey(collectionKey);\n return getNodeForCollectionPath(app.hierarchy)(collectionKey);\n};\n\nexport const getNewChild = app => (recordKey, collectionName, recordTypeName) => \n getNew(app)(joinKey(recordKey, collectionName), recordTypeName);\n\nexport const constructRecord = (recordNode, getFieldValue, collectionKey) => {\n const record = $(recordNode.fields, [\n keyBy('name'),\n mapValues(getFieldValue),\n ]);\n\n record.id = `${recordNode.nodeId}-${generate()}`;\n record.key = joinKey(collectionKey, record.id);\n record.isNew = true;\n record.type = recordNode.name;\n return record;\n};\n",
"import { createCoreApp } from \"./createCoreApp\"\r\nimport {\r\n getNew, getNewChild\r\n} from \"../../../core/src/recordApi/getNew\";\r\n\r\nexport const createCoreApi = (appDefinition, user) => {\r\n \r\n const app = createCoreApp(appDefinition, user);\r\n\r\n return {\r\n recordApi: {\r\n getNew: getNew(app),\r\n getNewChild: getNewChild(app)\r\n }\r\n }\r\n\r\n}",
"import { \n split,\n last\n} from \"lodash/fp\";\nimport {writable} from \"svelte/store\";\nimport { $ } from \"./core/common\";\nimport { \n setupBinding \n} from \"./state/stateBinding\";\nimport { createCoreApi } from \"./core\";\nimport { getStateOrValue } from \"./state/getState\";\nimport { trimSlash } from \"./common/trimSlash\";\n\n\nexport const createApp = (componentLibraries, appDefinition, user) => {\n\n const initialiseComponent = (parentContext) => (props, htmlElement, context) => {\n\n const {componentName, libName} = splitName(props._component);\n\n if(!componentName || !libName) return;\n\n const {initialProps, bind} = setupBinding(store, props, coreApi, context, appDefinition.appRootPath);\n\n const component = new (componentLibraries[libName][componentName])({\n target: htmlElement,\n props: {...initialProps, _bb:bbInContext(context || parentContext)},\n hydrate:true\n });\n\n bind(component);\n\n return component;\n }\n\n const coreApi = createCoreApi(appDefinition, user);\n const store = writable({\n _bbuser: user\n });\n\n\n let globalState = null;\n store.subscribe(s => {\n globalState = s;\n });\n\n const relativeUrl = (url) => \n appDefinition.appRootPath \n ? appDefinition.appRootPath + \"/\" + trimSlash(url)\n : url;\n\n\n const apiCall = (method) => (url, body) => \n fetch(relativeUrl(url), {\n method: method,\n headers: {\n 'Content-Type': 'application/json',\n },\n body: body && JSON.stringify(body), \n });\n\n const api = {\n post: apiCall(\"POST\"), \n get: apiCall(\"GET\"), \n patch: apiCall(\"PATCH\"), \n delete:apiCall(\"DELETE\")\n };\n\n const bb = () => ({\n initialiseComponent: initialiseComponent(), \n store,\n relativeUrl,\n api,\n getStateOrValue: (prop, currentContext) => \n getStateOrValue(globalState, prop, currentContext)\n });\n\n const bbRoot = bb();\n\n const bbInContext = (context) => {\n if(!context) return bbRoot;\n const bbCxt = bb();\n bbCxt.context = context;\n bbCxt.initialiseComponent=initialiseComponent(context);\n return bbCxt;\n }\n\n return bbRoot;\n\n}\n\n\nconst splitName = fullname => {\n const componentName = $(fullname, [\n split(\"/\"),\n last\n ]);\n\n const libName =fullname.substring(\n 0, fullname.length - componentName.length - 1);\n\n return {libName, componentName}; \n}\n\n\n",
"import { writable } from \"svelte/store\";\r\nimport Login from \"../Login.svelte\";\r\nimport Grid from \"../Grid.svelte\";\r\nimport Form from \"../Form.svelte\";\r\nimport Textbox from \"../Textbox.svelte\";\r\nimport Text from \"../Text.svelte\";\r\nimport Nav from \"../Nav.svelte\";\r\nimport Panel from \"../Panel.svelte\";\r\nimport StackPanel from \"../StackPanel.svelte\";\r\nimport Table from \"../Table.svelte\";\r\nimport Button from \"../Button.svelte\";\r\nimport { createApp } from \"@budibase/client/src/createApp\";\r\n\r\nexport default async () => {\r\n\r\n const componentLibraries = {\r\n components : {\r\n login : Login,\r\n grid : Grid,\r\n form : Form,\r\n textbox : Textbox,\r\n text: Text,\r\n nav: Nav,\r\n panel: Panel,\r\n table: Table,\r\n stackpanel: StackPanel,\r\n button: Button\r\n }\r\n }\r\n\r\n const appDef = {hierarchy:{}, actions:{}};\r\n const user = {name:\"yeo\", permissions:[]};\r\n \r\n var app = createApp(componentLibraries, appDef, user);\r\n app.store.update(s => {\r\n s.people = [\r\n {name:\"bob\", address: \"123 Main Street\", status: \"Open\"},\r\n {name:\"poppy\", address: \"456 Side Road\", status: \"Closed\"},\r\n {name:\"Oscar\", address: \"678 Dodgy Alley\", status: \"Open\"},\r\n ];\r\n return s;\r\n })\r\n\r\n return app;\r\n\r\n}",
"\r\nexport const props = {\r\n\r\n login: { _component:\"components/login\" },\r\n\r\n form: {\r\n _component: \"components/form\",\r\n formControls: [\r\n {\r\n control: {\r\n _component: \"components/textbox\"\r\n },\r\n label:\"First Name\"\r\n },\r\n {\r\n control: {\r\n _component: \"components/textbox\"\r\n },\r\n label:\"Last Name\"\r\n }\r\n ]\r\n },\r\n\r\n nav: {\r\n _component: \"components/nav\",\r\n navBarBackground: \"red\",\r\n navBarBorder: \"1px solid maroon\",\r\n navBarColor: \"black\",\r\n selectedItemBackground: \"maroon\",\r\n selectedItemColor: \"white\",\r\n selectedItemBorder: \"green\",\r\n itemHoverBackground: \"yellow\",\r\n itemHoverColor: \"pink\",\r\n items: [\r\n {\r\n title: \"People\",\r\n component: {\r\n _component: \"components/panel\",\r\n text:\"People Panel\",\r\n padding: \"40px\",\r\n border: \"2px solid pink\",\r\n background: \"mistyrose\"\r\n\r\n }\r\n },\r\n {\r\n title: \"Animals\",\r\n component: {\r\n _component: \"components/panel\",\r\n text:\"Animals Panel\",\r\n padding: \"40px\",\r\n border: \"2px solid green\",\r\n background: \"azure\"\r\n }\r\n }\r\n ]\r\n },\r\n\r\n table: {\r\n _component:\"components/table\",\r\n columns: [\r\n {\r\n title: {\r\n \"##bbstate\":\"NameColumnName\",\r\n \"##bbsource\":\"store\",\r\n \"##bbstatefallback\": \"Name\"\r\n },\r\n value: {\r\n \"##bbstate\":\"name\",\r\n \"##bbsource\":\"context\"\r\n }\r\n },\r\n {\r\n title: \"Address\",\r\n value: {\r\n \"##bbstate\":\"address\",\r\n \"##bbsource\":\"context\"\r\n }\r\n },\r\n {\r\n title: \"Status\",\r\n value: {\r\n \"##bbstate\":\"status\",\r\n \"##bbsource\":\"context\"\r\n }\r\n }\r\n ],\r\n data: {\r\n \"##bbstate\":\"people\"\r\n },\r\n onRowClick: [\r\n {\r\n \"##eventHandlerType\": \"Set State\",\r\n parameters: {\r\n path: \"NameColumnName\",\r\n value: {\r\n \"##bbstate\":\"name\",\r\n \"##bbsource\":\"context\",\r\n \"##bbstatefallback\": \"balls to that\"\r\n }\r\n }\r\n }\r\n ],\r\n tableClass: \"table-default\",\r\n theadClass: \"thead-default\",\r\n tbodyClass: \"tbody-default\",\r\n trClass: \"tr-default\",\r\n thClass: \"th-default\"\r\n\r\n },\r\n\r\n grid: {\r\n _component: \"components/grid\",\r\n gridTemplateColumns: \"[left] auto [center] auto [right] auto\",\r\n gridTemplateRows: \"[top] auto [middle] auto [bottom] auto\",\r\n children : [\r\n {\r\n control: {\r\n _component: \"components/text\",\r\n value: \"1\",\r\n background: \"blue\",\r\n textAlign:\"center\",\r\n color: \"white\"\r\n },\r\n gridColumn: \"left\",\r\n gridRow: \"top\"\r\n },\r\n {\r\n contr
"<script>\nimport createApp from \"./createApp\";\nimport { props } from \"./props\";\n\nlet _bb;\n\nconst _appPromise = createApp();\n_appPromise.then(a => _bb = a);\n\nconst testProps = props.hiddenNav;\n\nlet currentComponent;\n\n$: {\n if(_bb && currentComponent) {\n _bb.initialiseComponent(testProps, currentComponent);\n }\n}\n\n\n\n</script>\n\n{#await _appPromise}\nloading\n{:then _bb}\n\n<div id=\"current_component\" bind:this={currentComponent}>\n</div>\n\n{/await}\n\n\n<style>\n#current_component {\n height: 100%;\n width: 100%;\n}\n</style>\n\n",
"import App from './TestApp.svelte';\n\nconst app = new App({\n\ttarget: document.body,\n});\n\nexport default app;"
],
"names": [
"global",
"this",
"fallbackHolder",
"mapping",
"require$$0",
"require$$1",
"undefined",
"union",
"reduce",
"setSeed",
"random",
"alphabet",
"generate",
"build",
"isUndefined",
"cloneDeep",
"flow",
"trim",
"split",
"replace",
"isArray",
"join",
"isNull",
"isNaN",
"some",
"isEmpty",
"isString",
"constant",
"head",
"tail",
"includes",
"isInteger",
"isDate",
"toNumber",
"isObject",
"get",
"globals",
"countBy",
"keys",
"find",
"has",
"merge",
"mapValues",
"makerule",
"isBoolean",
"options",
"typeConstraints",
"isNumber",
"map",
"isObjectLike",
"intersection",
"last",
"file",
"assign",
"all",
"values",
"keyBy",
"createApp",
"App"
],
"mappings": ";;;;;IAAA,SAAS,IAAI,GAAG,GAAG;AACnB,IACA,SAAS,MAAM,CAAC,GAAG,EAAE,GAAG,EAAE;IAC1B;IACA,IAAI,KAAK,MAAM,CAAC,IAAI,GAAG;IACvB,QAAQ,GAAG,CAAC,CAAC,CAAC,GAAG,GAAG,CAAC,CAAC,CAAC,CAAC;IACxB,IAAI,OAAO,GAAG,CAAC;IACf,CAAC;IACD,SAAS,UAAU,CAAC,KAAK,EAAE;IAC3B,IAAI,OAAO,KAAK,IAAI,OAAO,KAAK,KAAK,QAAQ,IAAI,OAAO,KAAK,CAAC,IAAI,KAAK,UAAU,CAAC;IAClF,CAAC;IACD,SAAS,YAAY,CAAC,OAAO,EAAE,IAAI,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE;IACzD,IAAI,OAAO,CAAC,aAAa,GAAG;IAC5B,QAAQ,GAAG,EAAE,EAAE,IAAI,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE;IACzC,KAAK,CAAC;IACN,CAAC;IACD,SAAS,GAAG,CAAC,EAAE,EAAE;IACjB,IAAI,OAAO,EAAE,EAAE,CAAC;IAChB,CAAC;IACD,SAAS,YAAY,GAAG;IACxB,IAAI,OAAO,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;IAC/B,CAAC;IACD,SAAS,OAAO,CAAC,GAAG,EAAE;IACtB,IAAI,GAAG,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC;IACrB,CAAC;IACD,SAAS,WAAW,CAAC,KAAK,EAAE;IAC5B,IAAI,OAAO,OAAO,KAAK,KAAK,UAAU,CAAC;IACvC,CAAC;IACD,SAAS,cAAc,CAAC,CAAC,EAAE,CAAC,EAAE;IAC9B,IAAI,OAAO,CAAC,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,GAAG,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,IAAI,OAAO,CAAC,KAAK,QAAQ,KAAK,OAAO,CAAC,KAAK,UAAU,CAAC,CAAC;IAClG,CAAC;AACD,IAoBA,SAAS,WAAW,CAAC,UAAU,EAAE,GAAG,EAAE,EAAE,EAAE;IAC1C,IAAI,IAAI,UAAU,EAAE;IACpB,QAAQ,MAAM,QAAQ,GAAG,gBAAgB,CAAC,UAAU,EAAE,GAAG,EAAE,EAAE,CAAC,CAAC;IAC/D,QAAQ,OAAO,UAAU,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC;IACvC,KAAK;IACL,CAAC;IACD,SAAS,gBAAgB,CAAC,UAAU,EAAE,GAAG,EAAE,EAAE,EAAE;IAC/C,IAAI,OAAO,UAAU,CAAC,CAAC,CAAC;IACxB,UAAU,MAAM,CAAC,EAAE,EAAE,MAAM,CAAC,GAAG,CAAC,OAAO,CAAC,GAAG,EAAE,UAAU,CAAC,CAAC,CAAC,CAAC,EAAE,GAAG,EAAE,CAAC,GAAG,CAAC,GAAG,EAAE,CAAC,CAAC,CAAC;IAC/E,UAAU,GAAG,CAAC,OAAO,CAAC,GAAG,CAAC;IAC1B,CAAC;IACD,SAAS,gBAAgB,CAAC,UAAU,EAAE,GAAG,EAAE,OAAO,EAAE,EAAE,EAAE;IACxD,IAAI,OAAO,UAAU,CAAC,CAAC,CAAC;IACxB,UAAU,MAAM,CAAC,EAAE,EAAE,MAAM,CAAC,GAAG,CAAC,OAAO,CAAC,OAAO,IAAI,EAAE,EAAE,UAAU,CAAC,CAAC,CAAC,CAAC,EAAE,GAAG,EAAE,CAAC,OAAO,CAAC,GAAG,EAAE,CAAC,CAAC,CAAC;IAC7F,UAAU,GAAG,CAAC,OAAO,CAAC,OAAO,IAAI,EAAE,CAAC;IACpC,CAAC;AACD,IAgBA,SAAS,aAAa,CAAC,KAAK,EAAE;IAC9B,IAAI,OAAO,KAAK,IAAI,IAAI,GAAG,EAAE,GAAG,KAAK,CAAC;IACtC,CAAC;AACD,AAmDA;IACA,SAAS,MAAM,CAAC,MAAM,EAAE,IAAI,EAAE;IAC9B,IAAI,MAAM,CAAC,WAAW,CAAC,IAAI,CAAC,CAAC;IAC7B,CAAC;IACD,SAAS,MAAM,CAAC,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE;IACtC,IAAI,MAAM,CAAC,YAAY,CAAC,IAAI,EAAE,MAAM,IAAI,IAAI,CAAC,CAAC;IAC9C,CAAC;IACD,SAAS,MAAM,CAAC,IAAI,EAAE;IACtB,IAAI,IAAI,CAAC,UAAU,CAAC,WAAW,CAAC,IAAI,CAAC,CAAC;IACtC,CAAC;IACD,SAAS,YAAY,CAAC,UAAU,EAAE,SAAS,EAAE;IAC7C,IAAI,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,UAAU,CAAC,MAAM,EAAE,CAAC,IAAI,CAAC,EAAE;IACnD,QAAQ,IAAI,UAAU,CAAC,CAAC,CAAC;IACzB,YAAY,UAAU,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC;IACvC,KAAK;IACL,CAAC;IACD,SAAS,OAAO,CAAC,IAAI,EAAE;IACvB,IAAI,OAAO,QAAQ,CAAC,aAAa,CAAC,IAAI,CAAC,CAAC;IACxC,CAAC;AACD,IAgBA,SAAS,WAAW,CAAC,IAAI,EAAE;IAC3B,IAAI,OAAO,QAAQ,CAAC,eAAe,CAAC,4BAA4B,EAAE,IAAI,CAAC,CAAC;IACxE,CAAC;IACD,SAAS,IAAI,CAAC,IAAI,EAAE;IACpB,IAAI,OAAO,QAAQ,CAAC,cAAc,CAAC,IAAI,CAAC,CAAC;IACzC,CAAC;IACD,SAAS,KAAK,GAAG;IACjB,IAAI,OAAO,IAAI,CAAC,GAAG,CAAC,CAAC;IACrB,CAAC;IACD,SAAS,KAAK,GAAG;IACjB,IAAI,OAAO,IAAI,CAAC,EAAE,CAAC,CAAC;IACpB,CAAC;IACD,SAAS,MAAM,CAAC,IAAI,EAAE,KAAK,EAAE,OAAO,EAAE,OAAO,EAAE;IAC/C,IAAI,IAAI,CAAC,gBAAgB,CAAC,KAAK,EAAE,OAAO,EAAE,OAAO,CAAC,CAAC;IACnD,IAAI,OAAO,MAAM,IAAI,CAAC,mBAAmB,CAAC,KAAK,EAAE,OAAO,EAAE,OAAO,CAAC,CAAC;IACnE,CAAC;AACD,IAqBA,SAAS,IAAI,CAAC,IAAI,EAAE,SAAS,EAAE,KAAK,EAAE;IACtC,IAAI,IAAI,KAAK,IAAI,IAAI;IACrB,QAAQ,IAAI,CAAC,eAAe,CAAC,SAAS,CAAC,CAAC;IACxC;IACA,QAAQ,IAAI,CAAC,YAAY,CAAC,SAAS,EAAE,KAAK,CAAC,CAAC;IAC5C,CAAC;AACD,IA+CA,SAAS,QAAQ,CAAC,OAAO,EAAE;IAC3B,IAAI,OAAO,KAAK,CAAC,IAAI,CAAC,OAAO,CAAC,UAAU,CAAC,CAAC;IAC1C,CAAC;IACD,SAAS,aAAa,CAAC,KAAK,EAAE,IAAI,EAAE,UAAU,EAAE,GAAG,EAAE;IACrD,IAAI,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,KAAK,CAAC,MAAM,EAAE,CAAC,IAAI,CAAC,EAAE;IAC9C,QAAQ,MAAM,IAAI,GAAG,KAAK,CAAC,CAAC,CAAC,CAAC;IAC9B,QAAQ,IAAI,IAAI,CAAC,QAAQ,KAAK,IAAI,EAAE;IACpC,YAAY,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,IAAI,CAAC,UAAU,CAAC,MAAM,EAAE,CAAC,IAAI,CAAC,EAAE;IAChE,gBAAgB,MAAM,SAAS,GAAG,IAAI,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC;IACrD,gBAAgB,IAAI,CAAC,UAAU,CAAC,SAAS,CAAC,IAAI,CAAC;IAC/C,oBAAoB,IAAI,CAAC,eAAe,CAAC,SAAS,CAAC,IAAI,CAAC,CAAC;IACzD,a
}