2
0
mirror of https://github.com/frappe/books.git synced 2024-11-09 15:20:56 +00:00

incr: fix build issue and minor updates to readme

This commit is contained in:
18alantom 2022-05-27 00:45:05 +05:30
parent 3af46dc24a
commit f27d22504b
9 changed files with 109 additions and 119 deletions

View File

@ -5,3 +5,7 @@ a demo instance.
There are a few `.json` files here (eg: `items.json`) which have been generated,
these are not to be edited.
The generated data has some randomness, there is a `baseCount` arg to the
exported `setupDummyInstance` function, the number of transactions generated are
always more than this.

View File

@ -18,17 +18,19 @@ allows for a single source of truth and a common interface to access different
modules such as `db`, `doc` an `auth`.
**Localization**: Since Books' functionality changes depending on region,
regional information is required in the initialization process.
regional information (`countryCode`) is required in the initialization process.
**Doc**: This is `fyo`'s abstraction for an ORM, the associated files are
located in `model`, all classes exported from `books/models` extend this.
**`Doc`**: This is `fyo`'s abstraction for an ORM, the associated files are
located in `model/doc.ts`, all classes exported from `books/models` extend this.
### Terminology
- **Schema**: object that defines shape of the data in the database.
- **Model**: the controller class that extends the `Doc` class or the `Doc`
class itself (if a controller doesn't exist).
- **Doc**: instance of a Model, i.e. what has the data.
- **Model**: the controller class that extends the `Doc` class, or the `Doc`
class itself (if a specific controller doesn't exist).
- **doc** (not `Doc`): instance of a Model, i.e. what has the data.
If you are confused, I understand.
## Initialization
@ -94,7 +96,7 @@ This can be done using `fyo/utils/translation.ts/setLanguageMapOnTranslationStri
Since translations are runtime, if the code is evaluated before the language map
is loaded, translations won't work. To prevent this, don't maintain translation
strings globally.
strings globally since this will be evaluated before the map is loaded.
## Observers

View File

@ -30,7 +30,7 @@
"luxon": "^2.0.2",
"node-fetch": "2",
"pesa": "^1.1.12",
"vue": "^3.2.30",
"vue": "^3.2.36",
"vue-router": "^4.0.12"
},
"devDependencies": {
@ -74,7 +74,6 @@
"tslib": "^2.3.1",
"typescript": "^4.6.2",
"vue-cli-plugin-electron-builder": "^2.0.0",
"vue-template-compiler": "^2.6.10",
"webpack": "^5.66.0"
},
"prettier": {

View File

@ -3,4 +3,5 @@
Reports are a view of stored data, the code here doesn't alter any data.
All reports should extend the `Report` class in `reports/Report.ts`, depending
on the report it may have custom `.vue` files.
on the report it may have custom `.vue` files. Check the `type.ts` file for the
shape of the report data.

View File

@ -21,4 +21,4 @@ All of them are triggered from `src/App.vue`.
## Global Fyo
Global fyo is exported from `initFyo.ts`. Only code that isn't going to be unit
tested should use this.
tested using `mocha` should use this, i.e. code in `src`

View File

@ -1,6 +1,3 @@
<script setup>
const keys = useKeys();
</script>
<template>
<div>
<!-- Search Bar Button -->
@ -149,6 +146,10 @@ import { nextTick, watch } from 'vue';
import Modal from './Modal.vue';
export default {
setup() {
const keys = useKeys();
return { keys };
},
data() {
return {
idx: 0,
@ -332,11 +333,14 @@ export default {
.map(({ si }) => si);
let docs = [];
/*
if (this.groupFilters.Docs && this.inputValue) {
docs = this.docSearch.search(this.inputValue);
}
*/
const all = [docs, nonDocs].flat();
// eslint-disable-next-line
this.totalLength = all.length;
return all.slice(0, 50);
},

View File

@ -267,18 +267,18 @@ class Search {
[ModelNameEnum.JournalEntry]: 50,
};
#groupedKeywords?: Dictionary<Keyword[]>;
_groupedKeywords?: Dictionary<Keyword[]>;
constructor() {
this.keywords = {};
}
get groupedKeywords() {
if (!this.#groupedKeywords || !Object.keys(this.#groupedKeywords!).length) {
this.#groupedKeywords = this.getGroupedKeywords();
if (!this._groupedKeywords || !Object.keys(this._groupedKeywords!).length) {
this._groupedKeywords = this.getGroupedKeywords();
}
return this.#groupedKeywords!;
return this._groupedKeywords!;
}
search(keyword: string /*, array: DocSearchItem[]*/): DocSearchItem[] {
@ -326,7 +326,7 @@ class Search {
}
async fetchKeywords() {
const searchables = this.#getSearchables();
const searchables = this._getSearchables();
for (const searchable of searchables) {
const options: GetAllOptions = {
fields: [searchable.fields, searchable.meta].flat(),
@ -338,13 +338,13 @@ class Search {
}
const maps = await fyo.db.getAllRaw(searchable.schemaName, options);
this.#addToSearchable(maps, searchable);
this._addToSearchable(maps, searchable);
}
this.#setPriority();
this._setPriority();
}
#getSearchables(): Searchable[] {
_getSearchables(): Searchable[] {
const searchable: Searchable[] = [];
for (const schemaName of Object.keys(fyo.schemaMap)) {
const schema = fyo.schemaMap[schemaName];
@ -374,7 +374,7 @@ class Search {
return searchable;
}
#setPriority() {
_setPriority() {
for (const schemaName in this.keywords) {
const kw = this.keywords[schemaName];
const basePriority = this.priorityMap[schemaName] ?? 0;
@ -397,7 +397,7 @@ class Search {
}
}
#addToSearchable(maps: DocValueMap[], searchable: Searchable) {
_addToSearchable(maps: DocValueMap[], searchable: Searchable) {
if (!maps.length) {
return;
}
@ -406,13 +406,13 @@ class Search {
for (const map of maps) {
const keyword: Keyword = { values: [], meta: {}, priority: 0 };
this.#setKeywords(map, searchable, keyword);
this.#setMeta(map, searchable, keyword);
this._setKeywords(map, searchable, keyword);
this._setMeta(map, searchable, keyword);
this.keywords[searchable.schemaName]!.keywords.push(keyword);
}
}
#setKeywords(map: DocValueMap, searchable: Searchable, keyword: Keyword) {
_setKeywords(map: DocValueMap, searchable: Searchable, keyword: Keyword) {
// Set individual field values
for (const fn of searchable.fields) {
let value = map[fn] as string | undefined;
@ -426,7 +426,7 @@ class Search {
}
}
#setMeta(map: DocValueMap, searchable: Searchable, keyword: Keyword) {
_setMeta(map: DocValueMap, searchable: Searchable, keyword: Keyword) {
// Set the meta map
for (const fn of searchable.meta) {
const meta = map[fn];

View File

@ -4,7 +4,7 @@ const webpack = require('webpack');
module.exports = {
pluginOptions: {
electronBuilder: {
externals: ['knex', 'sqlite3'],
externals: ['knex', 'better-sqlite3'],
nodeIntegration: true,
mainProcessFile: 'main.ts',
disableMainProcessTypescript: false,
@ -32,6 +32,7 @@ module.exports = {
filename: 'index.html',
},
},
parallel: false,
runtimeCompiler: true,
lintOnSave: process.env.NODE_ENV !== 'production',
configureWebpack(config) {
@ -48,14 +49,6 @@ module.exports = {
fixtures: path.resolve(__dirname, './fixtures'),
});
config.plugins.push(
// https://github.com/knex/knex/issues/1446#issuecomment-537715431
new webpack.ContextReplacementPlugin(
/knex[/\\]lib[/\\]dialects/,
/sqlite3[/\\]index.js/
)
);
config.module.rules.push({
test: /\.txt$/i,
use: 'raw-loader',

151
yarn.lock
View File

@ -1942,47 +1942,47 @@
semver "^7.3.4"
strip-ansi "^6.0.0"
"@vue/compiler-core@3.2.30":
version "3.2.30"
resolved "https://registry.yarnpkg.com/@vue/compiler-core/-/compiler-core-3.2.30.tgz#6c5b362490930e72de8d033270a145e3830ae5c4"
integrity sha512-64fq1KfcR+k3Vlw+IsBM2VhV5B+2IP3YxvKU8LWCDLrkmlXtbf2eMK6+0IwX5KP41D0f1gzryIiXR7P8cB9O5Q==
"@vue/compiler-core@3.2.36":
version "3.2.36"
resolved "https://registry.yarnpkg.com/@vue/compiler-core/-/compiler-core-3.2.36.tgz#2fa44595308c95610602df54dcb69063ba2c8383"
integrity sha512-bbyZM5hvBicv0PW3KUfVi+x3ylHnfKG7DOn5wM+f2OztTzTjLEyBb/5yrarIYpmnGitVGbjZqDbODyW4iK8hqw==
dependencies:
"@babel/parser" "^7.16.4"
"@vue/shared" "3.2.30"
"@vue/shared" "3.2.36"
estree-walker "^2.0.2"
source-map "^0.6.1"
"@vue/compiler-dom@3.2.30":
version "3.2.30"
resolved "https://registry.yarnpkg.com/@vue/compiler-dom/-/compiler-dom-3.2.30.tgz#ed15e6243227baeaa445d04df804aee6e4926eab"
integrity sha512-t7arHz2SXLCXlF2fdGDFVbhENbGMez254Z5edUqb//6WXJU1lC7GvSkUE7i5x8WSjgfqt60i0V8zdmk16rvLdw==
"@vue/compiler-dom@3.2.36":
version "3.2.36"
resolved "https://registry.yarnpkg.com/@vue/compiler-dom/-/compiler-dom-3.2.36.tgz#16d911ff163ed5fc8087a01645bf14bb7f325401"
integrity sha512-tcOTAOiW4s24QLnq+ON6J+GRONXJ+A/mqKCORi0LSlIh8XQlNnlm24y8xIL8la+ZDgkdbjarQ9ZqYSvEja6gVA==
dependencies:
"@vue/compiler-core" "3.2.30"
"@vue/shared" "3.2.30"
"@vue/compiler-core" "3.2.36"
"@vue/shared" "3.2.36"
"@vue/compiler-sfc@3.2.30":
version "3.2.30"
resolved "https://registry.yarnpkg.com/@vue/compiler-sfc/-/compiler-sfc-3.2.30.tgz#9d2e56adb859059551fc1204bc37503f168c4d0c"
integrity sha512-P/5YpILtcQY92z72gxhkyOUPHVskEzhSrvYi91Xcr+csOxaDaYU5OqOxCzZKcf3Og70Tat404vO1OHrwprN90A==
"@vue/compiler-sfc@3.2.36":
version "3.2.36"
resolved "https://registry.yarnpkg.com/@vue/compiler-sfc/-/compiler-sfc-3.2.36.tgz#e5065e7c0e5170ffa750e3c3dd93a29db109d0f2"
integrity sha512-AvGb4bTj4W8uQ4BqaSxo7UwTEqX5utdRSMyHy58OragWlt8nEACQ9mIeQh3K4di4/SX+41+pJrLIY01lHAOFOA==
dependencies:
"@babel/parser" "^7.16.4"
"@vue/compiler-core" "3.2.30"
"@vue/compiler-dom" "3.2.30"
"@vue/compiler-ssr" "3.2.30"
"@vue/reactivity-transform" "3.2.30"
"@vue/shared" "3.2.30"
"@vue/compiler-core" "3.2.36"
"@vue/compiler-dom" "3.2.36"
"@vue/compiler-ssr" "3.2.36"
"@vue/reactivity-transform" "3.2.36"
"@vue/shared" "3.2.36"
estree-walker "^2.0.2"
magic-string "^0.25.7"
postcss "^8.1.10"
source-map "^0.6.1"
"@vue/compiler-ssr@3.2.30":
version "3.2.30"
resolved "https://registry.yarnpkg.com/@vue/compiler-ssr/-/compiler-ssr-3.2.30.tgz#fc2bc13a9cdfd70fcffab3f0bc7de141cd9c3411"
integrity sha512-OUh3MwAu/PsD7VN3UOdBbTkltkrUCNouSht47+CMRzpUR5+ta7+xyMAVHeq8wg4YZenWaJimbR5TL35Ka4Vk6g==
"@vue/compiler-ssr@3.2.36":
version "3.2.36"
resolved "https://registry.yarnpkg.com/@vue/compiler-ssr/-/compiler-ssr-3.2.36.tgz#314f3a9424db58142c3608f48cbda7aa05fc66cb"
integrity sha512-+KugInUFRvOxEdLkZwE+W43BqHyhBh0jpYXhmqw1xGq2dmE6J9eZ8UUSOKNhdHtQ/iNLWWeK/wPZkVLUf3YGaw==
dependencies:
"@vue/compiler-dom" "3.2.30"
"@vue/shared" "3.2.30"
"@vue/compiler-dom" "3.2.36"
"@vue/shared" "3.2.36"
"@vue/component-compiler-utils@^3.1.0", "@vue/component-compiler-utils@^3.1.2":
version "3.3.0"
@ -2017,53 +2017,53 @@
resolved "https://registry.yarnpkg.com/@vue/preload-webpack-plugin/-/preload-webpack-plugin-1.1.2.tgz#ceb924b4ecb3b9c43871c7a429a02f8423e621ab"
integrity sha512-LIZMuJk38pk9U9Ur4YzHjlIyMuxPlACdBIHH9/nGYVTsaGKOSnSuELiE8vS9wa+dJpIYspYUOqk+L1Q4pgHQHQ==
"@vue/reactivity-transform@3.2.30":
version "3.2.30"
resolved "https://registry.yarnpkg.com/@vue/reactivity-transform/-/reactivity-transform-3.2.30.tgz#2006e9f4645777a481b78ae77fc486159afa8480"
integrity sha512-Le5XzCJyK3qTjoTnvQG/Ehu8fYjayauMNFyMaEnwFlm/avDofpuibpS9u+/6AgzsGnVWN+i0Jgf25bJd9DIwMw==
"@vue/reactivity-transform@3.2.36":
version "3.2.36"
resolved "https://registry.yarnpkg.com/@vue/reactivity-transform/-/reactivity-transform-3.2.36.tgz#8426a941b0b09d1b94fc162d4642758183b5d133"
integrity sha512-Jk5o2BhpODC9XTA7o4EL8hSJ4JyrFWErLtClG3NH8wDS7ri9jBDWxI7/549T7JY9uilKsaNM+4pJASLj5dtRwA==
dependencies:
"@babel/parser" "^7.16.4"
"@vue/compiler-core" "3.2.30"
"@vue/shared" "3.2.30"
"@vue/compiler-core" "3.2.36"
"@vue/shared" "3.2.36"
estree-walker "^2.0.2"
magic-string "^0.25.7"
"@vue/reactivity@3.2.30":
version "3.2.30"
resolved "https://registry.yarnpkg.com/@vue/reactivity/-/reactivity-3.2.30.tgz#fdae2bb66d075c34593ea7e15c6831300a1ad39e"
integrity sha512-qlNKbkRn2JiGxVUEdoXbLAy+vcuHUCcq+YH2uXWz0BNMvXY2plmz+oqsw+694llwmYLkke5lbdYF4DIupisIkg==
"@vue/reactivity@3.2.36":
version "3.2.36"
resolved "https://registry.yarnpkg.com/@vue/reactivity/-/reactivity-3.2.36.tgz#026b14e716febffe80cd284fd8a2b33378968646"
integrity sha512-c2qvopo0crh9A4GXi2/2kfGYMxsJW4tVILrqRPydVGZHhq0fnzy6qmclWOhBFckEhmyxmpHpdJtIRYGeKcuhnA==
dependencies:
"@vue/shared" "3.2.30"
"@vue/shared" "3.2.36"
"@vue/runtime-core@3.2.30":
version "3.2.30"
resolved "https://registry.yarnpkg.com/@vue/runtime-core/-/runtime-core-3.2.30.tgz#1acc119ff8a49c06af6b03611bc4e03f464ca8a2"
integrity sha512-RTi7xH0Ht/6wfbo2WFBMJTEiyWFTqGhrksJm8lz6E+auO6lXZ6Eq3gPNfLt47GDWCm4xyrv+rs5R4UbarPEQ1Q==
"@vue/runtime-core@3.2.36":
version "3.2.36"
resolved "https://registry.yarnpkg.com/@vue/runtime-core/-/runtime-core-3.2.36.tgz#be5115e665679c26bf3807d2326675dc1d847134"
integrity sha512-PTWBD+Lub+1U3/KhbCExrfxyS14hstLX+cBboxVHaz+kXoiDLNDEYAovPtxeTutbqtClIXtft+wcGdC+FUQ9qQ==
dependencies:
"@vue/reactivity" "3.2.30"
"@vue/shared" "3.2.30"
"@vue/reactivity" "3.2.36"
"@vue/shared" "3.2.36"
"@vue/runtime-dom@3.2.30":
version "3.2.30"
resolved "https://registry.yarnpkg.com/@vue/runtime-dom/-/runtime-dom-3.2.30.tgz#16a85b359ea1fff9b1dd61e9d00e93f4652aba5e"
integrity sha512-a3+jrncDvEFQmB+v9k0VyT4/Y3XO6OAueCroXXY4yLyr6PJeyxljweV5TzvW0rvVzH9sZO0QAvG76Lo+6C92Qw==
"@vue/runtime-dom@3.2.36":
version "3.2.36"
resolved "https://registry.yarnpkg.com/@vue/runtime-dom/-/runtime-dom-3.2.36.tgz#cd5d403ea23c18ee7c17767103a1b2f8263c54bb"
integrity sha512-gYPYblm7QXHVuBohqNRRT7Wez0f2Mx2D40rb4fleehrJU9CnkjG0phhcGEZFfGwCmHZRqBCRgbFWE98bPULqkg==
dependencies:
"@vue/runtime-core" "3.2.30"
"@vue/shared" "3.2.30"
"@vue/runtime-core" "3.2.36"
"@vue/shared" "3.2.36"
csstype "^2.6.8"
"@vue/server-renderer@3.2.30":
version "3.2.30"
resolved "https://registry.yarnpkg.com/@vue/server-renderer/-/server-renderer-3.2.30.tgz#4acccad3933475d07b94560c6cb205363975b969"
integrity sha512-pzb8J/w+JdZVOtuKFlirGqrs4GP60FXGDJySw3WV2pCetuFstaacDrnymEeSo3ohAD+Qjv7zAG+Y7OvkdxQxmQ==
"@vue/server-renderer@3.2.36":
version "3.2.36"
resolved "https://registry.yarnpkg.com/@vue/server-renderer/-/server-renderer-3.2.36.tgz#1e7c1cf63bd17df7828d04e8c780ee6ca7a9ed7c"
integrity sha512-uZE0+jfye6yYXWvAQYeHZv+f50sRryvy16uiqzk3jn8hEY8zTjI+rzlmZSGoE915k+W/Ol9XSw6vxOUD8dGkUg==
dependencies:
"@vue/compiler-ssr" "3.2.30"
"@vue/shared" "3.2.30"
"@vue/compiler-ssr" "3.2.36"
"@vue/shared" "3.2.36"
"@vue/shared@3.2.30":
version "3.2.30"
resolved "https://registry.yarnpkg.com/@vue/shared/-/shared-3.2.30.tgz#e2ba8f6692399c27c81c668ecd3f1a4e13ee2f5e"
integrity sha512-B3HouBtUxcfu2w2d+VhdLcVBXKYYhXiFMAfQ+hoe8NUhKkPRkWDIqhpuehCZxVQ3S2dN1P1WfKGlxGC+pfmxGg==
"@vue/shared@3.2.36":
version "3.2.36"
resolved "https://registry.yarnpkg.com/@vue/shared/-/shared-3.2.36.tgz#35e11200542cf29068ba787dad57da9bdb82f644"
integrity sha512-JtB41wXl7Au3+Nl3gD16Cfpj7k/6aCroZ6BbOiCMFCMvrOpkg/qQUXTso2XowaNqBbnkuGHurLAqkLBxNGc1hQ==
"@vue/web-component-wrapper@^1.2.0":
version "1.3.0"
@ -4508,11 +4508,6 @@ dashdash@^1.12.0:
dependencies:
assert-plus "^1.0.0"
de-indent@^1.0.2:
version "1.0.2"
resolved "https://registry.yarnpkg.com/de-indent/-/de-indent-1.0.2.tgz#b2038e846dc33baa5796128d0804b455b8c1e21d"
integrity sha1-sgOOhG3DO6pXlhKNCAS0VbjB4h0=
debounce-fn@^4.0.0:
version "4.0.0"
resolved "https://registry.yarnpkg.com/debounce-fn/-/debounce-fn-4.0.0.tgz#ed76d206d8a50e60de0dd66d494d82835ffe61c7"
@ -6665,7 +6660,7 @@ hash.js@^1.0.0, hash.js@^1.0.3:
inherits "^2.0.3"
minimalistic-assert "^1.0.1"
he@1.2.0, he@1.2.x, he@^1.1.0:
he@1.2.0, he@1.2.x:
version "1.2.0"
resolved "https://registry.yarnpkg.com/he/-/he-1.2.0.tgz#84ae65fa7eafb165fddb61566ae14baf05664f0f"
integrity sha512-F/1DnUGPopORZi0ni+CvrCgHQ5FyEAHRLSApuYWMmrbSwoN2Mn/7k+Gl38gJnR7yyDZk6WLXwiGod1JOWNDKGw==
@ -12471,29 +12466,21 @@ vue-style-loader@^4.1.0, vue-style-loader@^4.1.2:
hash-sum "^1.0.2"
loader-utils "^1.0.2"
vue-template-compiler@^2.6.10:
version "2.6.14"
resolved "https://registry.yarnpkg.com/vue-template-compiler/-/vue-template-compiler-2.6.14.tgz#a2f0e7d985670d42c9c9ee0d044fed7690f4f763"
integrity sha512-ODQS1SyMbjKoO1JBJZojSw6FE4qnh9rIpUZn2EUT86FKizx9uH5z6uXiIrm4/Nb/gwxTi/o17ZDEGWAXHvtC7g==
dependencies:
de-indent "^1.0.2"
he "^1.1.0"
vue-template-es2015-compiler@^1.9.0:
version "1.9.1"
resolved "https://registry.yarnpkg.com/vue-template-es2015-compiler/-/vue-template-es2015-compiler-1.9.1.tgz#1ee3bc9a16ecbf5118be334bb15f9c46f82f5825"
integrity sha512-4gDntzrifFnCEvyoO8PqyJDmguXgVPxKiIxrBKjIowvL9l+N66196+72XVYR8BBf1Uv1Fgt3bGevJ+sEmxfZzw==
vue@^3.2.30:
version "3.2.30"
resolved "https://registry.yarnpkg.com/vue/-/vue-3.2.30.tgz#47de3039631ac22cab2fd26b427575260199b8bb"
integrity sha512-ZmTFWVJUX2XADkuOB8GcLTuxnBLogjJBTNVrM7WsTnjqRQ+VR8bLNrvNsbn8vj/LaP5+0WFAPrpngOYE2x+e+Q==
vue@^3.2.36:
version "3.2.36"
resolved "https://registry.yarnpkg.com/vue/-/vue-3.2.36.tgz#8daa996e2ced521708de97d066c7c998e8bc3378"
integrity sha512-5yTXmrE6gW8IQgttzHW5bfBiFA6mx35ZXHjGLDmKYzW6MMmYvCwuKybANRepwkMYeXw2v1buGg3/lPICY5YlZw==
dependencies:
"@vue/compiler-dom" "3.2.30"
"@vue/compiler-sfc" "3.2.30"
"@vue/runtime-dom" "3.2.30"
"@vue/server-renderer" "3.2.30"
"@vue/shared" "3.2.30"
"@vue/compiler-dom" "3.2.36"
"@vue/compiler-sfc" "3.2.36"
"@vue/runtime-dom" "3.2.36"
"@vue/server-renderer" "3.2.36"
"@vue/shared" "3.2.36"
watchpack-chokidar2@^2.0.1:
version "2.0.1"