diff --git a/package.json b/package.json index a9d980504..0a11a8606 100644 --- a/package.json +++ b/package.json @@ -40,7 +40,7 @@ "test:unit": "nuxi prepare test/fixtures/basic && nuxi prepare test/fixtures/document-driven && vitest run" }, "dependencies": { - "@nuxt/kit": "^3.0.0-rc.5", + "@nuxt/kit": "^3.0.0-rc.6", "consola": "^2.15.3", "csvtojson": "^2.0.10", "defu": "^6.0.0", @@ -51,7 +51,7 @@ "listhen": "^0.2.13", "mdast-util-to-hast": "^12.1.2", "mdurl": "^1.0.1", - "ohash": "^0.1.0", + "ohash": "^0.1.4", "pathe": "^0.3.2", "property-information": "^6.1.1", "rehype-external-links": "^1.0.1", @@ -74,18 +74,18 @@ "unist-builder": "^3.0.0", "unist-util-position": "^4.0.3", "unist-util-visit": "^4.1.0", - "unstorage": "^0.5.4", - "ws": "^8.8.0" + "unstorage": "^0.5.5", + "ws": "^8.8.1" }, "devDependencies": { "@nuxt/module-builder": "^0.1.7", - "@nuxt/schema": "^3.0.0-rc.5", + "@nuxt/schema": "^3.0.0-rc.6", "@nuxt/test-utils": "npm:@nuxt/test-utils-edge@latest", "@nuxthq/admin": "npm:@nuxthq/admin-edge@latest", "@nuxtjs/eslint-config-typescript": "latest", "@types/ws": "^8.5.3", "c8": "^7.11.3", - "eslint": "^8.19.0", + "eslint": "^8.20.0", "globby": "^13.1.2", "husky": "^8.0.1", "jiti": "^1.14.0", @@ -93,7 +93,7 @@ "nuxt": "^3.0.0-rc.5", "rehype-figure": "^1.0.1", "remark-oembed": "^1.2.2", - "vitest": "^0.18.0", + "vitest": "^0.18.1", "vue-docgen-web-types": "^0.1.7" } } diff --git a/src/runtime/components/ContentDoc.ts b/src/runtime/components/ContentDoc.vue similarity index 99% rename from src/runtime/components/ContentDoc.ts rename to src/runtime/components/ContentDoc.vue index d7be877e7..2436395c7 100644 --- a/src/runtime/components/ContentDoc.ts +++ b/src/runtime/components/ContentDoc.vue @@ -1,4 +1,4 @@ - + diff --git a/src/runtime/components/ContentList.ts b/src/runtime/components/ContentList.vue similarity index 98% rename from src/runtime/components/ContentList.ts rename to src/runtime/components/ContentList.vue index fc468f5a8..7f6cd6f5f 100644 --- a/src/runtime/components/ContentList.ts +++ b/src/runtime/components/ContentList.vue @@ -1,4 +1,4 @@ - + diff --git a/src/runtime/components/ContentNavigation.ts b/src/runtime/components/ContentNavigation.vue similarity index 98% rename from src/runtime/components/ContentNavigation.ts rename to src/runtime/components/ContentNavigation.vue index b08c9bdf4..164097623 100644 --- a/src/runtime/components/ContentNavigation.ts +++ b/src/runtime/components/ContentNavigation.vue @@ -1,3 +1,4 @@ + diff --git a/src/runtime/components/ContentQuery.ts b/src/runtime/components/ContentQuery.vue similarity index 99% rename from src/runtime/components/ContentQuery.ts rename to src/runtime/components/ContentQuery.vue index fee93189d..11c0a0303 100644 --- a/src/runtime/components/ContentQuery.ts +++ b/src/runtime/components/ContentQuery.vue @@ -1,3 +1,4 @@ + diff --git a/src/runtime/components/ContentRenderer.ts b/src/runtime/components/ContentRenderer.vue similarity index 98% rename from src/runtime/components/ContentRenderer.ts rename to src/runtime/components/ContentRenderer.vue index 4b4bdf466..2a273147e 100644 --- a/src/runtime/components/ContentRenderer.ts +++ b/src/runtime/components/ContentRenderer.vue @@ -1,3 +1,4 @@ + diff --git a/src/runtime/components/ContentRendererMarkdown.ts b/src/runtime/components/ContentRendererMarkdown.vue similarity index 99% rename from src/runtime/components/ContentRendererMarkdown.ts rename to src/runtime/components/ContentRendererMarkdown.vue index 77de4d2dc..c767a1e2c 100644 --- a/src/runtime/components/ContentRendererMarkdown.ts +++ b/src/runtime/components/ContentRendererMarkdown.vue @@ -1,3 +1,4 @@ + diff --git a/src/runtime/components/DocumentDrivenEmpty.ts b/src/runtime/components/DocumentDrivenEmpty.vue similarity index 94% rename from src/runtime/components/DocumentDrivenEmpty.ts rename to src/runtime/components/DocumentDrivenEmpty.vue index 2a0d7b5f4..8eacd8aab 100644 --- a/src/runtime/components/DocumentDrivenEmpty.ts +++ b/src/runtime/components/DocumentDrivenEmpty.vue @@ -1,3 +1,4 @@ + diff --git a/src/runtime/components/DocumentDrivenNotFound.ts b/src/runtime/components/DocumentDrivenNotFound.vue similarity index 88% rename from src/runtime/components/DocumentDrivenNotFound.ts rename to src/runtime/components/DocumentDrivenNotFound.vue index da7caf348..97af52154 100644 --- a/src/runtime/components/DocumentDrivenNotFound.ts +++ b/src/runtime/components/DocumentDrivenNotFound.vue @@ -1,3 +1,4 @@ + diff --git a/src/runtime/components/Markdown.ts b/src/runtime/components/Markdown.vue similarity index 98% rename from src/runtime/components/Markdown.ts rename to src/runtime/components/Markdown.vue index 20da93bca..5bd66aec0 100644 --- a/src/runtime/components/Markdown.ts +++ b/src/runtime/components/Markdown.vue @@ -1,3 +1,4 @@ + diff --git a/src/runtime/types.d.ts b/src/runtime/types.d.ts index 47a9b6dad..f04b5a5a5 100644 --- a/src/runtime/types.d.ts +++ b/src/runtime/types.d.ts @@ -1,6 +1,6 @@ import type { Theme } from 'shiki-es' -export interface ParsedContentMeta { +export interface ParsedContentInternalMeta { /** * Content id */ @@ -41,7 +41,9 @@ export interface ParsedContentMeta { * Extension of the file */ _extension?: string +} +export interface ParsedContentMeta extends ParsedContentInternalMeta { [key: string]: any } @@ -185,6 +187,221 @@ export interface SortFields { export type SortOptions = SortParams | SortFields +export interface QueryBuilderWhere extends Partial> { + /** + * Match only if all of nested conditions are true + * + * @example + ```ts + queryContent().where({ + $and: [ + { score: { $gte: 5 } }, + { score: { $lte: 10 } } + ] + }) + ``` + **/ + $and?: QueryBuilderWhere[] + /** + * Match if any of nested conditions is true + * + * @example + ```ts + queryContent().where({ + $or: [ + { score: { $gt: 5 } }, + { score: { $lt: 3 } } + ] + }) + ``` + **/ + $or?: QueryBuilderWhere[] + /** + * Match is condition is false + * + * @example + ```ts + queryContent().where({ + title: { + $not: 'Hello World' + } + }) + ``` + **/ + $not?: string | number | boolean | RegExp | QueryBuilderWhere + /** + * Match if item equals condition + * + * @example + ```ts + queryContent().where({ + title: { + $eq: 'Hello World' + } + }) + ``` + **/ + $eq?: string | number | boolean | RegExp + /** + * Match if item not equals condition + * + * @example + ```ts + queryContent().where({ + score: { + $ne: 100 + } + }) + ``` + **/ + $ne?: string | number | boolean | RegExp + /** + * Check if item is greater than condition + * + * @example + ```ts + queryContent().where({ + score: { + $gt: 99.5 + } + }) + ``` + */ + $gt?: number + /** + * Check if item is greater than or equal to condition + * + * @example + ```ts + queryContent().where({ + score: { + $gte: 99.5 + } + }) + ``` + */ + $gte?: number + /** + * Check if item is less than condition + * + * @example + ```ts + queryContent().where({ + score: { + $lt: 99.5 + } + }) + ``` + */ + $lt?: number + /** + * Check if item is less than or equal to condition + * + * @example + ```ts + queryContent().where({ + score: { + $lte: 99.5 + } + }) + ``` + */ + $lte?: number + /** + * Provides regular expression capabilities for pattern matching strings. + * + * @example + ```ts + queryContent().where({ + title: { + $regex: /^foo/ + } + }) + ``` + */ + $regex?: RegExp | string + /** + * Match if type of item equals condition + * + * @example + ```ts + queryContent().where({ + field: { + $type: 'boolean' + } + }) + ``` + */ + $type?: string + /** + * Check key existence + * + * @example + ```ts + queryContent().where({ + tag: { + $exists: false + } + }) + ``` + */ + $exists?: boolean + /** + * Match if item contains every condition or math every rule in condition array + * + * @example + ```ts + queryContent().where({ + title: { + $contains: ['Hello', 'World'] + } + }) + ``` + **/ + $contains?: Array | string | number | boolean + /** + * Match if item contains at least one rule from condition array + * + * @example + ```ts + queryContent().where({ + title: { + $containsAny: ['Hello', 'World'] + } + }) + ``` + */ + $containsAny?: Array + /** + * Ignore case contains + * + * @example + ```ts + queryContent().where({ + title: { + $icontains: 'hello world' + } + }) + ``` + **/ + $icontains?: string + /** + * Match if item is in condition array + * + * @example + ```ts + queryContent().where({ + category: { + $in: ['sport', 'nature', 'travel'] + } + }) + ``` + **/ + $in?: Array + + [key: string]: string | number | boolean | RegExp | QueryBuilderWhere | Array +} + export interface QueryBuilderParams { first?: boolean skip?: number @@ -192,9 +409,9 @@ export interface QueryBuilderParams { only?: string[] without?: string[] sort?: SortOptions[] - where?: object[] + where?: QueryBuilderWhere[] surround?: { - query: string | object + query: string | QueryBuilderWhere before?: number after?: number } @@ -223,7 +440,7 @@ export interface QueryBuilder { /** * Filter results */ - where(query: any): QueryBuilder + where(query: QueryBuilderWhere): QueryBuilder /** * Limit number of results diff --git a/yarn.lock b/yarn.lock index 106bbbc30..a55e135bf 100644 --- a/yarn.lock +++ b/yarn.lock @@ -487,6 +487,30 @@ unimport "^0.4.4" untyped "^0.4.4" +"@nuxt/kit@^3.0.0-rc.6": + version "3.0.0-rc.6" + resolved "https://registry.yarnpkg.com/@nuxt/kit/-/kit-3.0.0-rc.6.tgz#b59c10639cb591bdc5a63164fb352b344230a065" + integrity sha512-+lxSd6dSWlAzMXfGOPcY4856xnMF1Ck1rycFUZ+K2QYiDXphq/fiW2eMaWLVvqgPyL2Box2WzVDZJ6C5ceptcw== + dependencies: + "@nuxt/schema" "^3.0.0-rc.6" + c12 "^0.2.8" + consola "^2.15.3" + defu "^6.0.0" + globby "^13.1.2" + hash-sum "^2.0.0" + ignore "^5.2.0" + jiti "^1.14.0" + knitwork "^0.1.2" + lodash.template "^4.5.0" + mlly "^0.5.4" + pathe "^0.3.2" + pkg-types "^0.3.3" + scule "^0.2.1" + semver "^7.3.7" + unctx "^1.1.4" + unimport "^0.4.5" + untyped "^0.4.4" + "@nuxt/kit@npm:@nuxt/kit-edge@3.0.0-rc.4-27605536.8c2c80e": version "3.0.0-rc.4-27605536.8c2c80e" resolved "https://registry.yarnpkg.com/@nuxt/kit-edge/-/kit-edge-3.0.0-rc.4-27605536.8c2c80e.tgz#dde4865cbf4b33f3566a19bbf0284ec11854b1b9" @@ -554,6 +578,22 @@ ufo "^0.8.5" unimport "^0.4.4" +"@nuxt/schema@^3.0.0-rc.6": + version "3.0.0-rc.6" + resolved "https://registry.yarnpkg.com/@nuxt/schema/-/schema-3.0.0-rc.6.tgz#47baab10792057c799cd60ab2570d4fa20d65e1d" + integrity sha512-BcD5YtWRhn+jU2DlzuI1TeITFeOt5x6qm2KeaU/d5jzJ0oZDzmZwKsAimLtRbHwyU6/kKa+zFbK6pp5obm1XLg== + dependencies: + c12 "^0.2.8" + create-require "^1.1.1" + defu "^6.0.0" + jiti "^1.14.0" + pathe "^0.3.2" + postcss-import-resolver "^2.0.0" + scule "^0.2.1" + std-env "^3.1.1" + ufo "^0.8.5" + unimport "^0.4.5" + "@nuxt/schema@npm:@nuxt/schema-edge@3.0.0-rc.4-27605536.8c2c80e": version "3.0.0-rc.4-27605536.8c2c80e" resolved "https://registry.yarnpkg.com/@nuxt/schema-edge/-/schema-edge-3.0.0-rc.4-27605536.8c2c80e.tgz#132614dc45d109e0461d40386bb947d5a32866c7" @@ -2921,10 +2961,10 @@ eslint-visitor-keys@^3.1.0, eslint-visitor-keys@^3.3.0: resolved "https://registry.yarnpkg.com/eslint-visitor-keys/-/eslint-visitor-keys-3.3.0.tgz#f6480fa6b1f30efe2d1968aa8ac745b862469826" integrity sha512-mQ+suqKJVyeuwGYHAdjMFqjCyfl8+Ldnxuyp3ldiMBFKkvytrXUZWaiPCEav8qDHKty44bD+qV1IP4T+w+xXRA== -eslint@^8.19.0: - version "8.19.0" - resolved "https://registry.yarnpkg.com/eslint/-/eslint-8.19.0.tgz#7342a3cbc4fbc5c106a1eefe0fd0b50b6b1a7d28" - integrity sha512-SXOPj3x9VKvPe81TjjUJCYlV4oJjQw68Uek+AM0X4p+33dj2HY5bpTZOgnQHcG2eAm1mtCU9uNMnJi7exU/kYw== +eslint@^8.20.0: + version "8.20.0" + resolved "https://registry.yarnpkg.com/eslint/-/eslint-8.20.0.tgz#048ac56aa18529967da8354a478be4ec0a2bc81b" + integrity sha512-d4ixhz5SKCa1D6SCPrivP7yYVi7nyD6A4vs6HIAul9ujBzcEmZVM3/0NN/yu5nKhmO1wjp5xQ46iRfmDGlOviA== dependencies: "@eslint/eslintrc" "^1.3.0" "@humanwhocodes/config-array" "^0.9.2" @@ -3922,6 +3962,21 @@ ioredis@^5.0.4, ioredis@^5.1.0: redis-parser "^3.0.0" standard-as-callback "^2.1.0" +ioredis@^5.2.0: + version "5.2.1" + resolved "https://registry.yarnpkg.com/ioredis/-/ioredis-5.2.1.tgz#0e145e1f70478b5838c0b1545959948a049fbbcf" + integrity sha512-+rgPUIawiT+L3am9FbUcwjI7R7KtLDUSJNYWF82NZmlUXCZELws7iJkVDuECQoNUHqZTf/EGn3uw9IA+PlBiyg== + dependencies: + "@ioredis/commands" "^1.1.1" + cluster-key-slot "^1.1.0" + debug "^4.3.4" + denque "^2.0.1" + lodash.defaults "^4.2.0" + lodash.isarguments "^3.1.0" + redis-errors "^1.2.0" + redis-parser "^3.0.0" + standard-as-callback "^2.1.0" + is-absolute-url@^4.0.0: version "4.0.1" resolved "https://registry.yarnpkg.com/is-absolute-url/-/is-absolute-url-4.0.1.tgz#16e4d487d4fded05cfe0685e53ec86804a5e94dc" @@ -5532,6 +5587,11 @@ ohash@^0.1.0: resolved "https://registry.yarnpkg.com/ohash/-/ohash-0.1.0.tgz#cde74db91cfb7259477a93e0959221c4e20a5881" integrity sha512-KvclyhWseX6F2UTEEp9Qzybb0LTGorTSVufAToV5tR2B6Q64rVhKhkcU/o+mBaiqGa5+PdobtfSVelp8VOCR6A== +ohash@^0.1.4: + version "0.1.4" + resolved "https://registry.yarnpkg.com/ohash/-/ohash-0.1.4.tgz#e5b55740b6047b9b66a3b836b1c92cc747197c05" + integrity sha512-imsZ/lYOvZldyO6clK9uu6t2PIMr3bxCPAi6jJyPezKLU5/42UwMfGIlZML6GlpUxmSHxRoDo7VMWqI8VGllQQ== + ohmyfetch@^0.4.15, ohmyfetch@^0.4.16, ohmyfetch@^0.4.18: version "0.4.18" resolved "https://registry.yarnpkg.com/ohmyfetch/-/ohmyfetch-0.4.18.tgz#2952e04bd52662d0618d3d2f344db0250c3eeac2" @@ -7275,15 +7335,15 @@ tiny-invariant@^1.1.0: resolved "https://registry.yarnpkg.com/tiny-invariant/-/tiny-invariant-1.2.0.tgz#a1141f86b672a9148c72e978a19a73b9b94a15a9" integrity sha512-1Uhn/aqw5C6RI4KejVeTg6mIS7IqxnLJ8Mv2tV5rTc0qWobay7pDUz6Wi392Cnc8ak1H0F2cjoRzb2/AW4+Fvg== -tinypool@^0.2.1: - version "0.2.1" - resolved "https://registry.yarnpkg.com/tinypool/-/tinypool-0.2.1.tgz#7c3347514de36113f224212590de17f04fdf0078" - integrity sha512-HFU5ZYVq3wBfhSaf8qdqGsneaqXm0FgJQpoUlJbVdHpRLzm77IneKAD3RjzJWZvIv0YpPB9S7LUW53f6BE6ZSg== +tinypool@^0.2.4: + version "0.2.4" + resolved "https://registry.yarnpkg.com/tinypool/-/tinypool-0.2.4.tgz#4d2598c4689d1a2ce267ddf3360a9c6b3925a20c" + integrity sha512-Vs3rhkUH6Qq1t5bqtb816oT+HeJTXfwt2cbPH17sWHIYKTotQIFPk3tf2fgqRrVyMDVOc1EnPgzIxfIulXVzwQ== -tinyspy@^0.3.3: - version "0.3.3" - resolved "https://registry.yarnpkg.com/tinyspy/-/tinyspy-0.3.3.tgz#8b57f8aec7fe1bf583a3a49cb9ab30c742f69237" - integrity sha512-gRiUR8fuhUf0W9lzojPf1N1euJYA30ISebSfgca8z76FOvXtVXqd5ojEIaKLWbDQhAaC3ibxZIjqbyi4ybjcTw== +tinyspy@^1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/tinyspy/-/tinyspy-1.0.0.tgz#0cb34587287b0432b33fe36a9bd945fe22b1eb89" + integrity sha512-FI5B2QdODQYDRjfuLF+OrJ8bjWRMCXokQPcwKm0W3IzcbUmBNv536cQc7eXGoAuXphZwgx1DFbqImwzz08Fnhw== tmp@^0.0.33: version "0.0.33" @@ -7541,7 +7601,7 @@ unimport@^0.3.0: strip-literal "^0.4.0" unplugin "^0.7.0" -unimport@^0.4.4: +unimport@^0.4.4, unimport@^0.4.5: version "0.4.5" resolved "https://registry.yarnpkg.com/unimport/-/unimport-0.4.5.tgz#aa4c4aa2ef1027352f9ad79693f083929f18b660" integrity sha512-DnmiSt/HQIfhdcxOy4CGqwZDBh3WHg33euX1ge4X8hvquKBmw2PFvhoAJaBKxscOz0oYosoPoPT4tkDZWHhV0Q== @@ -7702,6 +7762,22 @@ unstorage@^0.5.4: ufo "^0.8.4" ws "^8.8.0" +unstorage@^0.5.5: + version "0.5.5" + resolved "https://registry.yarnpkg.com/unstorage/-/unstorage-0.5.5.tgz#5fba120c631302684fe393c9e501a4a8283f912c" + integrity sha512-hiaJUOCWrgBp8cc7bnVYe2vAMkd6gRJ3iRLFRZuwL7LjTnPJ3o/r5F55N4t7CdRq4WThTZCRNDKZ4qzZGF7TIA== + dependencies: + anymatch "^3.1.2" + chokidar "^3.5.3" + destr "^1.1.1" + h3 "^0.7.10" + ioredis "^5.2.0" + listhen "^0.2.13" + mri "^1.2.0" + ohmyfetch "^0.4.18" + ufo "^0.8.5" + ws "^8.8.0" + untyped@^0.3.0: version "0.3.0" resolved "https://registry.yarnpkg.com/untyped/-/untyped-0.3.0.tgz#854df4dec055cc6a0a2217aa2d20152277b6ada9" @@ -7851,19 +7927,19 @@ vite@^2.9.14: optionalDependencies: fsevents "~2.3.2" -vitest@^0.18.0: - version "0.18.0" - resolved "https://registry.yarnpkg.com/vitest/-/vitest-0.18.0.tgz#a9b59213ee6917e9da0797a2e1d7cb52b8f1b644" - integrity sha512-ryAtlh5Gvg3+aLNuOQ8YOHxgQCCu46jx40X5MBL0K0/ejB9i5zsr8fV8LTGXbXex80UMHlzceI9F+ouGaiR+mQ== +vitest@^0.18.1: + version "0.18.1" + resolved "https://registry.yarnpkg.com/vitest/-/vitest-0.18.1.tgz#33c5003fc8c4b296801897ae1a3f142f57015574" + integrity sha512-4F/1K/Vn4AvJwe7i2YblR02PT5vMKcw9KN4unDq2KD0YcSxX0B/6D6Qu9PJaXwVuxXMFTQ5ovd4+CQaW3bwofA== dependencies: "@types/chai" "^4.3.1" "@types/chai-subset" "^1.3.3" "@types/node" "*" chai "^4.3.6" debug "^4.3.4" - local-pkg "^0.4.1" - tinypool "^0.2.1" - tinyspy "^0.3.3" + local-pkg "^0.4.2" + tinypool "^0.2.4" + tinyspy "^1.0.0" vite "^2.9.12 || ^3.0.0-0" void-elements@^3.1.0: @@ -8101,6 +8177,11 @@ ws@^8.6.0, ws@^8.8.0: resolved "https://registry.yarnpkg.com/ws/-/ws-8.8.0.tgz#8e71c75e2f6348dbf8d78005107297056cb77769" integrity sha512-JDAgSYQ1ksuwqfChJusw1LSJ8BizJ2e/vVu5Lxjq3YvNJNlROv1ui4i+c/kUUrPheBvQl4c5UbERhTwKa6QBJQ== +ws@^8.8.1: + version "8.8.1" + resolved "https://registry.yarnpkg.com/ws/-/ws-8.8.1.tgz#5dbad0feb7ade8ecc99b830c1d77c913d4955ff0" + integrity sha512-bGy2JzvzkPowEJV++hF07hAD6niYSr0JzBNo/J29WsB57A2r7Wlc1UFcTR9IzrPvuNVO4B8LGqF8qcpsVOhJCA== + ws@~8.2.3: version "8.2.3" resolved "https://registry.yarnpkg.com/ws/-/ws-8.2.3.tgz#63a56456db1b04367d0b721a0b80cae6d8becbba"