docus 2.1.0 → 3.0.0-beta.11
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +6 -4
- package/package.json +39 -83
- package/theme/app/router.options.ts +18 -0
- package/theme/assets/css/fonts.css +84 -0
- package/theme/assets/css/main.css +104 -0
- package/theme/components/app/Container.vue +25 -0
- package/theme/components/app/Footer.vue +40 -0
- package/theme/components/app/MobileNav.vue +85 -0
- package/theme/components/app/Navbar.vue +37 -0
- package/theme/components/app/NavbarLogo.vue +33 -0
- package/theme/components/app/Page.vue +7 -0
- package/theme/components/app/PoweredByDocus.vue +11 -0
- package/theme/components/content/Alert.vue +124 -0
- package/theme/components/content/BlockHero.vue +54 -0
- package/theme/components/content/ButtonLink.vue +45 -0
- package/theme/components/content/Card.vue +46 -0
- package/theme/components/content/CardGrid.vue +23 -0
- package/theme/components/content/CodeBlock.vue +47 -0
- package/theme/components/content/CodeGroup.vue +135 -0
- package/theme/components/content/CopyButton.vue +49 -0
- package/{dist/runtime/app/components/prose/ProseOl.vue → theme/components/content/List.vue} +2 -2
- package/theme/components/content/NeedContribution.vue +23 -0
- package/theme/components/content/ReadMore.vue +25 -0
- package/theme/components/content/Sandbox.vue +102 -0
- package/theme/components/content/TabsHeader.vue +44 -0
- package/theme/components/content/Terminal.vue +64 -0
- package/theme/components/content/VideoPlayer.vue +115 -0
- package/theme/components/dev/Debug.vue +65 -0
- package/theme/components/docs/DocsAside.vue +21 -0
- package/theme/components/docs/DocsAsideTree.vue +104 -0
- package/theme/components/docs/DocsHero.vue +39 -0
- package/theme/components/docs/DocsPage.vue +21 -0
- package/theme/components/docs/DocsPageContent.vue +32 -0
- package/theme/components/docs/DocsToc.vue +77 -0
- package/theme/components/globals/Icon.vue +24 -0
- package/{dist/runtime/app/components/prose/ProseHr.vue → theme/components/globals/Logo.vue} +1 -1
- package/theme/components/globals/NuxtImg.vue +45 -0
- package/theme/components/globals/SocialIcons.vue +45 -0
- package/theme/components/globals/ThemeSelect.vue +35 -0
- package/theme/components/icons/IconAlgolia.vue +8 -0
- package/theme/components/icons/IconArrowLeft.vue +10 -0
- package/theme/components/icons/IconArrowRight.vue +10 -0
- package/theme/components/icons/IconBadgeCheck.vue +14 -0
- package/theme/components/icons/IconCheck.vue +10 -0
- package/theme/components/icons/IconCheckCircle.vue +10 -0
- package/theme/components/icons/IconChevronRight.vue +12 -0
- package/theme/components/icons/IconClipboardCheck.vue +14 -0
- package/theme/components/icons/IconClipboardCopy.vue +14 -0
- package/theme/components/icons/IconCodeSandbox.vue +8 -0
- package/theme/components/icons/IconCopy.vue +17 -0
- package/theme/components/icons/IconDots.vue +10 -0
- package/theme/components/icons/IconEdit.vue +18 -0
- package/theme/components/icons/IconExclamationCircle.vue +12 -0
- package/theme/components/icons/IconExclamationTriangle.vue +10 -0
- package/theme/components/icons/IconExternalLink.vue +12 -0
- package/theme/components/icons/IconGit.vue +7 -0
- package/theme/components/icons/IconGitHub.vue +10 -0
- package/theme/components/icons/IconHeart.vue +9 -0
- package/theme/components/icons/IconInformationCircle.vue +10 -0
- package/theme/components/icons/IconLighthouse.vue +83 -0
- package/theme/components/icons/IconLine.vue +10 -0
- package/theme/components/icons/IconMarkdown.vue +13 -0
- package/theme/components/icons/IconMenu.vue +12 -0
- package/theme/components/icons/IconMenuAlt.vue +10 -0
- package/theme/components/icons/IconMinus.vue +10 -0
- package/theme/components/icons/IconMoon.vue +10 -0
- package/theme/components/icons/IconNuxt.vue +14 -0
- package/theme/components/icons/IconNuxtContent.vue +20 -0
- package/theme/components/icons/IconNuxtLabs.vue +21 -0
- package/theme/components/icons/IconPlus.vue +10 -0
- package/theme/components/icons/IconPuzzle.vue +8 -0
- package/theme/components/icons/IconSSG.vue +7 -0
- package/theme/components/icons/IconSearch.vue +12 -0
- package/theme/components/icons/IconSun.vue +10 -0
- package/theme/components/icons/IconTailwind.vue +3 -0
- package/theme/components/icons/IconTocBack.vue +21 -0
- package/theme/components/icons/IconTocCurrent.vue +21 -0
- package/theme/components/icons/IconTocNext.vue +8 -0
- package/theme/components/icons/IconTranslate.vue +14 -0
- package/theme/components/icons/IconTwitter.vue +8 -0
- package/theme/components/icons/IconVite.vue +30 -0
- package/theme/components/icons/IconVue.vue +6 -0
- package/theme/components/icons/IconVueTelescope.vue +11 -0
- package/theme/components/icons/IconWindi.vue +17 -0
- package/theme/components/icons/IconX.vue +12 -0
- package/theme/components/icons/IconXCircle.vue +10 -0
- package/theme/components/icons/IconZap.vue +8 -0
- package/theme/components/prose/ProseA.vue +66 -0
- package/theme/components/prose/ProseBlockquote.vue +21 -0
- package/theme/components/prose/ProseCode.vue +67 -0
- package/theme/components/prose/ProseCodeInline.vue +38 -0
- package/theme/components/prose/ProseEm.vue +11 -0
- package/theme/components/prose/ProseH1.vue +22 -0
- package/theme/components/prose/ProseH2.vue +22 -0
- package/theme/components/prose/ProseH3.vue +24 -0
- package/theme/components/prose/ProseH4.vue +24 -0
- package/theme/components/prose/ProseHr.vue +13 -0
- package/theme/components/prose/ProseImg.vue +30 -0
- package/theme/components/prose/ProseLi.vue +31 -0
- package/theme/components/prose/ProseOl.vue +16 -0
- package/theme/components/prose/ProseP.vue +14 -0
- package/theme/components/prose/ProseStrong.vue +14 -0
- package/theme/components/prose/ProseTable.vue +13 -0
- package/{dist/runtime/app → theme}/components/prose/ProseTbody.vue +0 -0
- package/theme/components/prose/ProseTd.vue +11 -0
- package/theme/components/prose/ProseTh.vue +11 -0
- package/theme/components/prose/ProseThead.vue +11 -0
- package/theme/components/prose/ProseTr.vue +11 -0
- package/theme/components/prose/ProseUl.vue +15 -0
- package/theme/composables/useDocus.ts +43 -0
- package/theme/composables/useMenu.ts +7 -0
- package/theme/composables/useScrollToHeading.ts +35 -0
- package/theme/composables/useScrollspy.ts +46 -0
- package/theme/composables/useUserAgent.ts +7 -0
- package/theme/composables/utils.ts +4 -0
- package/theme/layouts/default.vue +29 -0
- package/theme/layouts/page.vue +19 -0
- package/theme/middleware/components.ts +26 -0
- package/theme/middleware/navigation.global.ts +12 -0
- package/theme/middleware/page.ts +8 -0
- package/theme/middleware/theme.global.ts +12 -0
- package/theme/nuxt.config.ts +171 -0
- package/theme/pages/[...slug].vue +64 -0
- package/theme/plugins/menu.ts +67 -0
- package/theme/plugins/user-agent.ts +27 -0
- package/theme/utils/components.ts +25 -0
- package/theme/utils/navigation.ts +49 -0
- package/theme/utils/plugin.ts +21 -0
- package/theme/utils/queries.ts +68 -0
- package/theme/utils/state.ts +33 -0
- package/theme/utils/theme.ts +66 -0
- package/LICENSE +0 -21
- package/dist/index.cjs +0 -549
- package/dist/index.d.ts +0 -25
- package/dist/index.mjs +0 -523
- package/dist/runtime/app/components/DocusContent.vue +0 -215
- package/dist/runtime/app/components/DocusContent.vue.d.ts +0 -25
- package/dist/runtime/app/components/Error.vue +0 -19
- package/dist/runtime/app/components/Error.vue.d.ts +0 -9
- package/dist/runtime/app/components/Markdown.vue +0 -56
- package/dist/runtime/app/components/Markdown.vue.d.ts +0 -25
- package/dist/runtime/app/components/Page.vue +0 -29
- package/dist/runtime/app/components/Page.vue.d.ts +0 -2
- package/dist/runtime/app/components/Props.vue +0 -130
- package/dist/runtime/app/components/Props.vue.d.ts +0 -80
- package/dist/runtime/app/components/prose/ProseA.vue +0 -41
- package/dist/runtime/app/components/prose/ProseA.vue.d.ts +0 -23
- package/dist/runtime/app/components/prose/ProseBlockquote.vue +0 -5
- package/dist/runtime/app/components/prose/ProseCode.vue +0 -5
- package/dist/runtime/app/components/prose/ProseCodeInline.vue +0 -5
- package/dist/runtime/app/components/prose/ProseEm.vue +0 -5
- package/dist/runtime/app/components/prose/ProseH1.vue +0 -3
- package/dist/runtime/app/components/prose/ProseH2.vue +0 -3
- package/dist/runtime/app/components/prose/ProseH3.vue +0 -3
- package/dist/runtime/app/components/prose/ProseH4.vue +0 -3
- package/dist/runtime/app/components/prose/ProseH5.vue +0 -3
- package/dist/runtime/app/components/prose/ProseH6.vue +0 -3
- package/dist/runtime/app/components/prose/ProseImg.vue +0 -32
- package/dist/runtime/app/components/prose/ProseImg.vue.d.ts +0 -21
- package/dist/runtime/app/components/prose/ProseLi.vue +0 -3
- package/dist/runtime/app/components/prose/ProseParagraph.vue +0 -3
- package/dist/runtime/app/components/prose/ProseStrong.vue +0 -5
- package/dist/runtime/app/components/prose/ProseTable.vue +0 -5
- package/dist/runtime/app/components/prose/ProseTd.vue +0 -5
- package/dist/runtime/app/components/prose/ProseTh.vue +0 -5
- package/dist/runtime/app/components/prose/ProseThead.vue +0 -5
- package/dist/runtime/app/components/prose/ProseTr.vue +0 -5
- package/dist/runtime/app/components/prose/ProseUl.vue +0 -5
- package/dist/runtime/app/composables/helpers.d.ts +0 -4
- package/dist/runtime/app/composables/helpers.js +0 -66
- package/dist/runtime/app/composables/helpers.mjs +0 -40
- package/dist/runtime/app/composables/index.d.ts +0 -90
- package/dist/runtime/app/composables/index.js +0 -108
- package/dist/runtime/app/composables/index.mjs +0 -63
- package/dist/runtime/app/composables/navigation.d.ts +0 -37
- package/dist/runtime/app/composables/navigation.js +0 -227
- package/dist/runtime/app/composables/navigation.mjs +0 -148
- package/dist/runtime/app/composables/store.d.ts +0 -7
- package/dist/runtime/app/composables/store.js +0 -52
- package/dist/runtime/app/composables/store.mjs +0 -35
- package/dist/runtime/app/composables/style.d.ts +0 -11
- package/dist/runtime/app/composables/style.js +0 -117
- package/dist/runtime/app/composables/style.mjs +0 -71
- package/dist/runtime/app/composables/theme-colors.d.ts +0 -30
- package/dist/runtime/app/composables/theme-colors.js +0 -80
- package/dist/runtime/app/composables/theme-colors.mjs +0 -48
- package/dist/runtime/app/composables/websocket.d.ts +0 -3
- package/dist/runtime/app/composables/websocket.js +0 -79
- package/dist/runtime/app/composables/websocket.mjs +0 -63
- package/dist/runtime/app/layouts/default.vue +0 -5
- package/dist/runtime/app/layouts/error.vue +0 -33
- package/dist/runtime/app/layouts/error.vue.d.ts +0 -21
- package/dist/runtime/app/pages/_.vue +0 -222
- package/dist/runtime/app/pages/_.vue.d.ts +0 -2
- package/dist/runtime/context.d.ts +0 -1
- package/dist/runtime/context.js +0 -17
- package/dist/runtime/context.mjs +0 -5
- package/dist/runtime/database/Query.d.ts +0 -18
- package/dist/runtime/database/Query.js +0 -68
- package/dist/runtime/database/Query.mjs +0 -49
- package/dist/runtime/database/index.d.ts +0 -4
- package/dist/runtime/database/index.js +0 -45
- package/dist/runtime/database/index.mjs +0 -25
- package/dist/runtime/database/providers/local/Query.d.ts +0 -14
- package/dist/runtime/database/providers/local/Query.js +0 -85
- package/dist/runtime/database/providers/local/Query.mjs +0 -60
- package/dist/runtime/database/providers/local/index.d.ts +0 -3
- package/dist/runtime/database/providers/local/index.js +0 -63
- package/dist/runtime/database/providers/local/index.mjs +0 -39
- package/dist/runtime/database/providers/local/operations.d.ts +0 -2
- package/dist/runtime/database/providers/local/operations.js +0 -83
- package/dist/runtime/database/providers/local/operations.mjs +0 -53
- package/dist/runtime/database/providers/local/utils.d.ts +0 -8
- package/dist/runtime/database/providers/local/utils.js +0 -28
- package/dist/runtime/database/providers/local/utils.mjs +0 -17
- package/dist/runtime/index.d.ts +0 -3
- package/dist/runtime/index.js +0 -44
- package/dist/runtime/index.mjs +0 -3
- package/dist/runtime/navigation.d.ts +0 -4
- package/dist/runtime/navigation.js +0 -176
- package/dist/runtime/navigation.mjs +0 -137
- package/dist/runtime/server/api/get.d.ts +0 -10
- package/dist/runtime/server/api/get.js +0 -24
- package/dist/runtime/server/api/get.mjs +0 -13
- package/dist/runtime/server/api/list.d.ts +0 -9
- package/dist/runtime/server/api/list.js +0 -34
- package/dist/runtime/server/api/list.mjs +0 -18
- package/dist/runtime/server/api/navigation.d.ts +0 -7
- package/dist/runtime/server/api/navigation.js +0 -20
- package/dist/runtime/server/api/navigation.mjs +0 -10
- package/dist/runtime/server/api/preview.d.ts +0 -3
- package/dist/runtime/server/api/preview.js +0 -54
- package/dist/runtime/server/api/preview.mjs +0 -31
- package/dist/runtime/server/api/reload.d.ts +0 -6
- package/dist/runtime/server/api/reload.js +0 -27
- package/dist/runtime/server/api/reload.mjs +0 -11
- package/dist/runtime/server/api/search.d.ts +0 -6
- package/dist/runtime/server/api/search.js +0 -27
- package/dist/runtime/server/api/search.mjs +0 -13
- package/dist/runtime/server/content.d.ts +0 -46
- package/dist/runtime/server/content.js +0 -175
- package/dist/runtime/server/content.mjs +0 -114
- package/dist/runtime/server/socket.d.ts +0 -9
- package/dist/runtime/server/socket.js +0 -33
- package/dist/runtime/server/socket.mjs +0 -20
- package/dist/runtime/server/utils/cache.d.ts +0 -19
- package/dist/runtime/server/utils/cache.js +0 -110
- package/dist/runtime/server/utils/cache.mjs +0 -75
- package/dist/runtime/server/utils/index.d.ts +0 -4
- package/dist/runtime/server/utils/index.js +0 -18
- package/dist/runtime/server/utils/index.mjs +0 -8
- package/dist/runtime/transformers/index.d.ts +0 -1
- package/dist/runtime/transformers/index.js +0 -26
- package/dist/runtime/transformers/index.mjs +0 -11
- package/dist/runtime/transformers/json.d.ts +0 -3
- package/dist/runtime/transformers/json.js +0 -15
- package/dist/runtime/transformers/json.mjs +0 -5
- package/dist/runtime/transformers/markdown/index.d.ts +0 -8
- package/dist/runtime/transformers/markdown/index.js +0 -25
- package/dist/runtime/transformers/markdown/index.mjs +0 -16
- package/dist/runtime/transformers/utils/index.d.ts +0 -1
- package/dist/runtime/transformers/utils/index.js +0 -18
- package/dist/runtime/transformers/utils/index.mjs +0 -1
- package/dist/runtime/transformers/utils/path.d.ts +0 -26
- package/dist/runtime/transformers/utils/path.js +0 -88
- package/dist/runtime/transformers/utils/path.mjs +0 -56
- package/dist/runtime/utils/index.d.ts +0 -1
- package/dist/runtime/utils/index.js +0 -18
- package/dist/runtime/utils/index.mjs +0 -1
- package/dist/runtime/utils/log.d.ts +0 -1
- package/dist/runtime/utils/log.js +0 -14
- package/dist/runtime/utils/log.mjs +0 -2
- package/dist/runtime/utils/object.d.ts +0 -9
- package/dist/runtime/utils/object.js +0 -22
- package/dist/runtime/utils/object.mjs +0 -4
- package/dist/templates/content.mjs +0 -50
- package/dist/templates/docus.mjs +0 -13
- package/dist/templates/hot.mjs +0 -16
- package/dist/templates/i18n.mjs +0 -23
- package/dist/templates/options.mjs +0 -46
- package/shims.d.ts +0 -24
- package/types.d.ts +0 -397
|
@@ -1,49 +0,0 @@
|
|
|
1
|
-
export class BaseQueryBuilder {
|
|
2
|
-
constructor() {
|
|
3
|
-
this.params = {
|
|
4
|
-
skip: 0,
|
|
5
|
-
limit: 0,
|
|
6
|
-
only: [],
|
|
7
|
-
without: [],
|
|
8
|
-
sortBy: [],
|
|
9
|
-
where: {}
|
|
10
|
-
};
|
|
11
|
-
}
|
|
12
|
-
only(keys) {
|
|
13
|
-
this.params.only = Array.isArray(keys) ? keys : [keys];
|
|
14
|
-
return this;
|
|
15
|
-
}
|
|
16
|
-
without(keys) {
|
|
17
|
-
this.params.without = Array.isArray(keys) ? keys : [keys];
|
|
18
|
-
return this;
|
|
19
|
-
}
|
|
20
|
-
sortBy(field, direction) {
|
|
21
|
-
this.params.sortBy.push([field, direction]);
|
|
22
|
-
return this;
|
|
23
|
-
}
|
|
24
|
-
where(query) {
|
|
25
|
-
this.params.where = query;
|
|
26
|
-
return this;
|
|
27
|
-
}
|
|
28
|
-
surround(slugOrTo, options) {
|
|
29
|
-
this.params.surround = {
|
|
30
|
-
slugOrTo,
|
|
31
|
-
options
|
|
32
|
-
};
|
|
33
|
-
return this;
|
|
34
|
-
}
|
|
35
|
-
limit(count) {
|
|
36
|
-
if (typeof count === "string") {
|
|
37
|
-
count = parseInt(count);
|
|
38
|
-
}
|
|
39
|
-
this.params.limit = count;
|
|
40
|
-
return this;
|
|
41
|
-
}
|
|
42
|
-
skip(count) {
|
|
43
|
-
if (typeof count === "string") {
|
|
44
|
-
count = parseInt(count);
|
|
45
|
-
}
|
|
46
|
-
this.params.skip = count;
|
|
47
|
-
return this;
|
|
48
|
-
}
|
|
49
|
-
}
|
|
@@ -1,45 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.createDatabase = createDatabase;
|
|
7
|
-
|
|
8
|
-
var _object = require("../utils/object");
|
|
9
|
-
|
|
10
|
-
var _context = require("../context");
|
|
11
|
-
|
|
12
|
-
var _local = _interopRequireDefault(require("./providers/local"));
|
|
13
|
-
|
|
14
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
15
|
-
|
|
16
|
-
async function createDatabase(navigation) {
|
|
17
|
-
const {
|
|
18
|
-
database: {
|
|
19
|
-
provider,
|
|
20
|
-
options
|
|
21
|
-
}
|
|
22
|
-
} = (0, _context.useDocusContext)();
|
|
23
|
-
let db;
|
|
24
|
-
|
|
25
|
-
switch (provider) {
|
|
26
|
-
case "local":
|
|
27
|
-
default:
|
|
28
|
-
db = (0, _local.default)(options);
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
await initializeDatabase(db, navigation);
|
|
32
|
-
return db;
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
function initializeDatabase(db, navigation) {
|
|
36
|
-
function index(item) {
|
|
37
|
-
db?.setItem(item.id, (0, _object.omit)(["children"])(item));
|
|
38
|
-
|
|
39
|
-
if (item.children) {
|
|
40
|
-
item.children.forEach(index);
|
|
41
|
-
}
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
Object.values(navigation || {}).flatMap(i => i).forEach(index);
|
|
45
|
-
}
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
import { omit } from "../utils/object.mjs";
|
|
2
|
-
import { useDocusContext } from "../context.mjs";
|
|
3
|
-
import createLocalDatabase from "./providers/local/index.mjs";
|
|
4
|
-
export async function createDatabase(navigation) {
|
|
5
|
-
const {
|
|
6
|
-
database: { provider, options }
|
|
7
|
-
} = useDocusContext();
|
|
8
|
-
let db;
|
|
9
|
-
switch (provider) {
|
|
10
|
-
case "local":
|
|
11
|
-
default:
|
|
12
|
-
db = createLocalDatabase(options);
|
|
13
|
-
}
|
|
14
|
-
await initializeDatabase(db, navigation);
|
|
15
|
-
return db;
|
|
16
|
-
}
|
|
17
|
-
function initializeDatabase(db, navigation) {
|
|
18
|
-
function index(item) {
|
|
19
|
-
db?.setItem(item.id, omit(["children"])(item));
|
|
20
|
-
if (item.children) {
|
|
21
|
-
item.children.forEach(index);
|
|
22
|
-
}
|
|
23
|
-
}
|
|
24
|
-
Object.values(navigation || {}).flatMap((i) => i).forEach(index);
|
|
25
|
-
}
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import { BaseQueryBuilder } from '../../Query';
|
|
2
|
-
export default class Query<T> extends BaseQueryBuilder<T> {
|
|
3
|
-
items: any[];
|
|
4
|
-
base: string;
|
|
5
|
-
dbUrl: string;
|
|
6
|
-
constructor(to: string, { base, db, ...params }?: any);
|
|
7
|
-
/**
|
|
8
|
-
* Call server middleware with generated params
|
|
9
|
-
* @returns {(Object|Array)} Returns processed data
|
|
10
|
-
*/
|
|
11
|
-
remoteFetch(): any;
|
|
12
|
-
initDBFromNavigationData(dataUrl: string): Promise<any[]>;
|
|
13
|
-
fetch(params?: QueryBuilderParams): Promise<T | T[]>;
|
|
14
|
-
}
|
|
@@ -1,85 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
module.exports = void 0;
|
|
7
|
-
|
|
8
|
-
var _ohmyfetch = require("ohmyfetch");
|
|
9
|
-
|
|
10
|
-
var _object = require("../../../utils/object");
|
|
11
|
-
|
|
12
|
-
var _Query = require("../../Query");
|
|
13
|
-
|
|
14
|
-
var _operations = require("./operations");
|
|
15
|
-
|
|
16
|
-
var _utils = require("./utils");
|
|
17
|
-
|
|
18
|
-
class Query extends _Query.BaseQueryBuilder {
|
|
19
|
-
constructor(to, {
|
|
20
|
-
base = "",
|
|
21
|
-
db = null,
|
|
22
|
-
...params
|
|
23
|
-
} = {}) {
|
|
24
|
-
super();
|
|
25
|
-
this.items = [];
|
|
26
|
-
this.dbUrl = "";
|
|
27
|
-
this.base = base;
|
|
28
|
-
Object.assign(this.params, params);
|
|
29
|
-
this.params.to = this.params.to || to;
|
|
30
|
-
this.items = db;
|
|
31
|
-
|
|
32
|
-
if (typeof db === "string") {
|
|
33
|
-
this.dbUrl = db;
|
|
34
|
-
}
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
remoteFetch() {
|
|
38
|
-
return globalThis.$fetch(this.base, {
|
|
39
|
-
method: "POST",
|
|
40
|
-
body: JSON.stringify(this.params),
|
|
41
|
-
headers: {
|
|
42
|
-
"Content-Type": "application/json"
|
|
43
|
-
}
|
|
44
|
-
});
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
async initDBFromNavigationData(dataUrl) {
|
|
48
|
-
const {
|
|
49
|
-
body: navigation
|
|
50
|
-
} = await (0, _ohmyfetch.$fetch)(dataUrl);
|
|
51
|
-
const _items = [];
|
|
52
|
-
|
|
53
|
-
function index(item) {
|
|
54
|
-
_items.push({ ...item,
|
|
55
|
-
children: void 0
|
|
56
|
-
});
|
|
57
|
-
|
|
58
|
-
if (item.children) {
|
|
59
|
-
item.children.forEach(index);
|
|
60
|
-
}
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
Object.values(navigation || {}).flatMap(i => i).forEach(index);
|
|
64
|
-
return _items;
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
async fetch(params = this.params) {
|
|
68
|
-
if (this.dbUrl) {
|
|
69
|
-
this.items = await this.initDBFromNavigationData(this.dbUrl);
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
if (!this.items) {
|
|
73
|
-
return this.remoteFetch();
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
const data = this.items;
|
|
77
|
-
params = params || this.params;
|
|
78
|
-
const pipelines = [data2 => params.to ? data2.filter(item => item.to === params.to || item.to.startsWith(params.to)) : data2, data2 => data2.filter(item => (0, _operations.match)(item, params.where)), data2 => params.sortBy.forEach(([key, direction]) => (0, _utils.sortByKey)(data2, key, direction)), data2 => params.skip ? data2.slice(params.skip) : data2, data2 => params.limit ? data2.slice(0, params.limit) : data2, (0, _object.apply)((0, _object.omit)(params.without)), (0, _object.apply)((0, _object.pick)(params.only)), data2 => !params.deep && data2[0]?.to === params.to ? data2[0] : data2];
|
|
79
|
-
const result = pipelines.reduce((value, fn) => fn(value) || value, data);
|
|
80
|
-
return result;
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
module.exports = Query;
|
|
@@ -1,60 +0,0 @@
|
|
|
1
|
-
import { $fetch } from "ohmyfetch";
|
|
2
|
-
import { apply, omit, pick } from "../../../utils/object.mjs";
|
|
3
|
-
import { BaseQueryBuilder } from "../../Query.mjs";
|
|
4
|
-
import { match } from "./operations.mjs";
|
|
5
|
-
import { sortByKey } from "./utils.mjs";
|
|
6
|
-
export default class Query extends BaseQueryBuilder {
|
|
7
|
-
constructor(to, { base = "", db = null, ...params } = {}) {
|
|
8
|
-
super();
|
|
9
|
-
this.items = [];
|
|
10
|
-
this.dbUrl = "";
|
|
11
|
-
this.base = base;
|
|
12
|
-
Object.assign(this.params, params);
|
|
13
|
-
this.params.to = this.params.to || to;
|
|
14
|
-
this.items = db;
|
|
15
|
-
if (typeof db === "string") {
|
|
16
|
-
this.dbUrl = db;
|
|
17
|
-
}
|
|
18
|
-
}
|
|
19
|
-
remoteFetch() {
|
|
20
|
-
return globalThis.$fetch(this.base, {
|
|
21
|
-
method: "POST",
|
|
22
|
-
body: JSON.stringify(this.params),
|
|
23
|
-
headers: { "Content-Type": "application/json" }
|
|
24
|
-
});
|
|
25
|
-
}
|
|
26
|
-
async initDBFromNavigationData(dataUrl) {
|
|
27
|
-
const { body: navigation } = await $fetch(dataUrl);
|
|
28
|
-
const _items = [];
|
|
29
|
-
function index(item) {
|
|
30
|
-
_items.push({ ...item, children: void 0 });
|
|
31
|
-
if (item.children) {
|
|
32
|
-
item.children.forEach(index);
|
|
33
|
-
}
|
|
34
|
-
}
|
|
35
|
-
Object.values(navigation || {}).flatMap((i) => i).forEach(index);
|
|
36
|
-
return _items;
|
|
37
|
-
}
|
|
38
|
-
async fetch(params = this.params) {
|
|
39
|
-
if (this.dbUrl) {
|
|
40
|
-
this.items = await this.initDBFromNavigationData(this.dbUrl);
|
|
41
|
-
}
|
|
42
|
-
if (!this.items) {
|
|
43
|
-
return this.remoteFetch();
|
|
44
|
-
}
|
|
45
|
-
const data = this.items;
|
|
46
|
-
params = params || this.params;
|
|
47
|
-
const pipelines = [
|
|
48
|
-
(data2) => params.to ? data2.filter((item) => item.to === params.to || item.to.startsWith(params.to)) : data2,
|
|
49
|
-
(data2) => data2.filter((item) => match(item, params.where)),
|
|
50
|
-
(data2) => params.sortBy.forEach(([key, direction]) => sortByKey(data2, key, direction)),
|
|
51
|
-
(data2) => params.skip ? data2.slice(params.skip) : data2,
|
|
52
|
-
(data2) => params.limit ? data2.slice(0, params.limit) : data2,
|
|
53
|
-
apply(omit(params.without)),
|
|
54
|
-
apply(pick(params.only)),
|
|
55
|
-
(data2) => !params.deep && data2[0]?.to === params.to ? data2[0] : data2
|
|
56
|
-
];
|
|
57
|
-
const result = pipelines.reduce((value, fn) => fn(value) || value, data);
|
|
58
|
-
return result;
|
|
59
|
-
}
|
|
60
|
-
}
|
|
@@ -1,63 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.createDatabase = void 0;
|
|
7
|
-
module.exports = createArrayDatabase;
|
|
8
|
-
|
|
9
|
-
var _Query = _interopRequireDefault(require("./Query"));
|
|
10
|
-
|
|
11
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
12
|
-
|
|
13
|
-
function createArrayDatabase(_options = {}) {
|
|
14
|
-
const database = {};
|
|
15
|
-
|
|
16
|
-
const query = (path, params) => {
|
|
17
|
-
const to = typeof path === "string" ? path : "";
|
|
18
|
-
const opts = (typeof path === "object" ? path : params) || {};
|
|
19
|
-
return new _Query.default(to, { ...opts,
|
|
20
|
-
db: Object.values(database)
|
|
21
|
-
});
|
|
22
|
-
};
|
|
23
|
-
|
|
24
|
-
const getItem = key => database[key];
|
|
25
|
-
|
|
26
|
-
const setItem = (key, document) => {
|
|
27
|
-
database[key] = document;
|
|
28
|
-
};
|
|
29
|
-
|
|
30
|
-
const removeItem = key => {
|
|
31
|
-
delete database[key];
|
|
32
|
-
};
|
|
33
|
-
|
|
34
|
-
const clear = () => {
|
|
35
|
-
for (const key in database) {
|
|
36
|
-
removeItem(key);
|
|
37
|
-
}
|
|
38
|
-
};
|
|
39
|
-
|
|
40
|
-
const search = (to, params) => query(to, params).fetch();
|
|
41
|
-
|
|
42
|
-
const serialize = () => Promise.resolve(JSON.stringify(database));
|
|
43
|
-
|
|
44
|
-
const load = data => {
|
|
45
|
-
clear();
|
|
46
|
-
Object.assign(database, JSON.parse(data));
|
|
47
|
-
return Promise.resolve();
|
|
48
|
-
};
|
|
49
|
-
|
|
50
|
-
return {
|
|
51
|
-
getItem,
|
|
52
|
-
setItem,
|
|
53
|
-
removeItem,
|
|
54
|
-
clear,
|
|
55
|
-
query,
|
|
56
|
-
search,
|
|
57
|
-
serialize,
|
|
58
|
-
load
|
|
59
|
-
};
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
const createDatabase = createArrayDatabase;
|
|
63
|
-
exports.createDatabase = createDatabase;
|
|
@@ -1,39 +0,0 @@
|
|
|
1
|
-
import ArrayQuery from "./Query.mjs";
|
|
2
|
-
export default function createArrayDatabase(_options = {}) {
|
|
3
|
-
const database = {};
|
|
4
|
-
const query = (path, params) => {
|
|
5
|
-
const to = typeof path === "string" ? path : "";
|
|
6
|
-
const opts = (typeof path === "object" ? path : params) || {};
|
|
7
|
-
return new ArrayQuery(to, { ...opts, db: Object.values(database) });
|
|
8
|
-
};
|
|
9
|
-
const getItem = (key) => database[key];
|
|
10
|
-
const setItem = (key, document) => {
|
|
11
|
-
database[key] = document;
|
|
12
|
-
};
|
|
13
|
-
const removeItem = (key) => {
|
|
14
|
-
delete database[key];
|
|
15
|
-
};
|
|
16
|
-
const clear = () => {
|
|
17
|
-
for (const key in database) {
|
|
18
|
-
removeItem(key);
|
|
19
|
-
}
|
|
20
|
-
};
|
|
21
|
-
const search = (to, params) => query(to, params).fetch();
|
|
22
|
-
const serialize = () => Promise.resolve(JSON.stringify(database));
|
|
23
|
-
const load = (data) => {
|
|
24
|
-
clear();
|
|
25
|
-
Object.assign(database, JSON.parse(data));
|
|
26
|
-
return Promise.resolve();
|
|
27
|
-
};
|
|
28
|
-
return {
|
|
29
|
-
getItem,
|
|
30
|
-
setItem,
|
|
31
|
-
removeItem,
|
|
32
|
-
clear,
|
|
33
|
-
query,
|
|
34
|
-
search,
|
|
35
|
-
serialize,
|
|
36
|
-
load
|
|
37
|
-
};
|
|
38
|
-
}
|
|
39
|
-
export const createDatabase = createArrayDatabase;
|
|
@@ -1,83 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.get = void 0;
|
|
7
|
-
exports.match = match;
|
|
8
|
-
|
|
9
|
-
const get = (obj, path) => path.split(".").reduce((acc, part) => acc && acc[part], obj);
|
|
10
|
-
|
|
11
|
-
exports.get = get;
|
|
12
|
-
|
|
13
|
-
function match(item, where) {
|
|
14
|
-
return Object.keys(where || {}).every(key => {
|
|
15
|
-
const condition = where[key];
|
|
16
|
-
|
|
17
|
-
if (key.startsWith("$")) {
|
|
18
|
-
return $operator(item, key, condition);
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
const value = get(item, key);
|
|
22
|
-
|
|
23
|
-
if (typeof condition === "object") {
|
|
24
|
-
return match(value, condition);
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
return value === condition;
|
|
28
|
-
});
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
function $operator(item, operator, condition) {
|
|
32
|
-
switch (operator) {
|
|
33
|
-
case "$not":
|
|
34
|
-
return !match(item, condition);
|
|
35
|
-
|
|
36
|
-
case "$and":
|
|
37
|
-
if (!Array.isArray(condition)) {
|
|
38
|
-
throw new TypeError("$containsAny requires an array as condition");
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
return condition.every(cond => match(item, cond));
|
|
42
|
-
|
|
43
|
-
case "$or":
|
|
44
|
-
if (!Array.isArray(condition)) {
|
|
45
|
-
throw new TypeError("$containsAny requires an array as condition");
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
return condition.some(cond => match(item, cond));
|
|
49
|
-
|
|
50
|
-
case "$ne":
|
|
51
|
-
return item !== condition;
|
|
52
|
-
|
|
53
|
-
case "$eq":
|
|
54
|
-
return item === condition;
|
|
55
|
-
|
|
56
|
-
case "$in":
|
|
57
|
-
return (Array.isArray(condition) ? condition : [condition]).includes(item);
|
|
58
|
-
|
|
59
|
-
case "$contains":
|
|
60
|
-
item = Array.isArray(item) ? item : String(item);
|
|
61
|
-
return Array.isArray(condition) ? condition.every(i => item.includes(i)) : item.includes(condition);
|
|
62
|
-
|
|
63
|
-
case "$containsAny":
|
|
64
|
-
if (!Array.isArray(condition)) {
|
|
65
|
-
throw new TypeError("$containsAny requires an array as condition");
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
item = Array.isArray(item) ? item : String(item);
|
|
69
|
-
return condition.some(i => item.includes(i));
|
|
70
|
-
|
|
71
|
-
case "$exists":
|
|
72
|
-
return condition ? typeof item !== "undefined" : typeof item === "undefined";
|
|
73
|
-
|
|
74
|
-
case "$type":
|
|
75
|
-
{
|
|
76
|
-
const type = typeof item;
|
|
77
|
-
return type === String(condition);
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
default:
|
|
81
|
-
return false;
|
|
82
|
-
}
|
|
83
|
-
}
|
|
@@ -1,53 +0,0 @@
|
|
|
1
|
-
export const get = (obj, path) => path.split(".").reduce((acc, part) => acc && acc[part], obj);
|
|
2
|
-
export function match(item, where) {
|
|
3
|
-
return Object.keys(where || {}).every((key) => {
|
|
4
|
-
const condition = where[key];
|
|
5
|
-
if (key.startsWith("$")) {
|
|
6
|
-
return $operator(item, key, condition);
|
|
7
|
-
}
|
|
8
|
-
const value = get(item, key);
|
|
9
|
-
if (typeof condition === "object") {
|
|
10
|
-
return match(value, condition);
|
|
11
|
-
}
|
|
12
|
-
return value === condition;
|
|
13
|
-
});
|
|
14
|
-
}
|
|
15
|
-
function $operator(item, operator, condition) {
|
|
16
|
-
switch (operator) {
|
|
17
|
-
case "$not":
|
|
18
|
-
return !match(item, condition);
|
|
19
|
-
case "$and":
|
|
20
|
-
if (!Array.isArray(condition)) {
|
|
21
|
-
throw new TypeError("$containsAny requires an array as condition");
|
|
22
|
-
}
|
|
23
|
-
return condition.every((cond) => match(item, cond));
|
|
24
|
-
case "$or":
|
|
25
|
-
if (!Array.isArray(condition)) {
|
|
26
|
-
throw new TypeError("$containsAny requires an array as condition");
|
|
27
|
-
}
|
|
28
|
-
return condition.some((cond) => match(item, cond));
|
|
29
|
-
case "$ne":
|
|
30
|
-
return item !== condition;
|
|
31
|
-
case "$eq":
|
|
32
|
-
return item === condition;
|
|
33
|
-
case "$in":
|
|
34
|
-
return (Array.isArray(condition) ? condition : [condition]).includes(item);
|
|
35
|
-
case "$contains":
|
|
36
|
-
item = Array.isArray(item) ? item : String(item);
|
|
37
|
-
return Array.isArray(condition) ? condition.every((i) => item.includes(i)) : item.includes(condition);
|
|
38
|
-
case "$containsAny":
|
|
39
|
-
if (!Array.isArray(condition)) {
|
|
40
|
-
throw new TypeError("$containsAny requires an array as condition");
|
|
41
|
-
}
|
|
42
|
-
item = Array.isArray(item) ? item : String(item);
|
|
43
|
-
return condition.some((i) => item.includes(i));
|
|
44
|
-
case "$exists":
|
|
45
|
-
return condition ? typeof item !== "undefined" : typeof item === "undefined";
|
|
46
|
-
case "$type": {
|
|
47
|
-
const type = typeof item;
|
|
48
|
-
return type === String(condition);
|
|
49
|
-
}
|
|
50
|
-
default:
|
|
51
|
-
return false;
|
|
52
|
-
}
|
|
53
|
-
}
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Comperator to sort array of objects based on a property
|
|
3
|
-
*/
|
|
4
|
-
export declare const sortComparable: (key: string, direction: string | boolean) => (a: any, b: any) => 0 | 1 | -1;
|
|
5
|
-
/**
|
|
6
|
-
* Sort an array based on a key
|
|
7
|
-
*/
|
|
8
|
-
export declare const sortByKey: (data: any[], key: string, direction: string | boolean) => any[];
|
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.sortComparable = exports.sortByKey = void 0;
|
|
7
|
-
|
|
8
|
-
var _operations = require("./operations");
|
|
9
|
-
|
|
10
|
-
const sortComparable = (key, direction) => (a, b) => {
|
|
11
|
-
const values = [(0, _operations.get)(a, key), (0, _operations.get)(b, key)];
|
|
12
|
-
|
|
13
|
-
if (direction === "desc" || direction === true) {
|
|
14
|
-
values.reverse();
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
if (values[0] === void 0) return 1;
|
|
18
|
-
if (values[1] === void 0) return -1;
|
|
19
|
-
if (values[0] > values[1]) return 1;
|
|
20
|
-
if (values[0] < values[1]) return -1;
|
|
21
|
-
return 0;
|
|
22
|
-
};
|
|
23
|
-
|
|
24
|
-
exports.sortComparable = sortComparable;
|
|
25
|
-
|
|
26
|
-
const sortByKey = (data, key, direction) => data.sort(sortComparable(key, direction));
|
|
27
|
-
|
|
28
|
-
exports.sortByKey = sortByKey;
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
import { get } from "./operations.mjs";
|
|
2
|
-
export const sortComparable = (key, direction) => (a, b) => {
|
|
3
|
-
const values = [get(a, key), get(b, key)];
|
|
4
|
-
if (direction === "desc" || direction === true) {
|
|
5
|
-
values.reverse();
|
|
6
|
-
}
|
|
7
|
-
if (values[0] === void 0)
|
|
8
|
-
return 1;
|
|
9
|
-
if (values[1] === void 0)
|
|
10
|
-
return -1;
|
|
11
|
-
if (values[0] > values[1])
|
|
12
|
-
return 1;
|
|
13
|
-
if (values[0] < values[1])
|
|
14
|
-
return -1;
|
|
15
|
-
return 0;
|
|
16
|
-
};
|
|
17
|
-
export const sortByKey = (data, key, direction) => data.sort(sortComparable(key, direction));
|
package/dist/runtime/index.d.ts
DELETED
package/dist/runtime/index.js
DELETED
|
@@ -1,44 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
|
|
7
|
-
var _utils = require("./utils");
|
|
8
|
-
|
|
9
|
-
Object.keys(_utils).forEach(function (key) {
|
|
10
|
-
if (key === "default" || key === "__esModule") return;
|
|
11
|
-
if (key in exports && exports[key] === _utils[key]) return;
|
|
12
|
-
Object.defineProperty(exports, key, {
|
|
13
|
-
enumerable: true,
|
|
14
|
-
get: function () {
|
|
15
|
-
return _utils[key];
|
|
16
|
-
}
|
|
17
|
-
});
|
|
18
|
-
});
|
|
19
|
-
|
|
20
|
-
var _composables = require("./app/composables");
|
|
21
|
-
|
|
22
|
-
Object.keys(_composables).forEach(function (key) {
|
|
23
|
-
if (key === "default" || key === "__esModule") return;
|
|
24
|
-
if (key in exports && exports[key] === _composables[key]) return;
|
|
25
|
-
Object.defineProperty(exports, key, {
|
|
26
|
-
enumerable: true,
|
|
27
|
-
get: function () {
|
|
28
|
-
return _composables[key];
|
|
29
|
-
}
|
|
30
|
-
});
|
|
31
|
-
});
|
|
32
|
-
|
|
33
|
-
var _utils2 = require("@docus/mdc/utils");
|
|
34
|
-
|
|
35
|
-
Object.keys(_utils2).forEach(function (key) {
|
|
36
|
-
if (key === "default" || key === "__esModule") return;
|
|
37
|
-
if (key in exports && exports[key] === _utils2[key]) return;
|
|
38
|
-
Object.defineProperty(exports, key, {
|
|
39
|
-
enumerable: true,
|
|
40
|
-
get: function () {
|
|
41
|
-
return _utils2[key];
|
|
42
|
-
}
|
|
43
|
-
});
|
|
44
|
-
});
|
package/dist/runtime/index.mjs
DELETED