Skip to content

Commit

Permalink
Implement basic full-text-search
Browse files Browse the repository at this point in the history
  • Loading branch information
justinfagnani committed Oct 13, 2022
1 parent 3e1eb52 commit 9a80564
Show file tree
Hide file tree
Showing 14 changed files with 341 additions and 47 deletions.
121 changes: 121 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

21 changes: 1 addition & 20 deletions packages/catalog-api/src/lib/schema.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -8,27 +8,8 @@ type Query {
"""
Queries custom elements in the entire catalog, from the latest version of each
package.
Eventually this will have more query parameters, and use some sort of ranking
algorithm, otherwise the order will just be defined by the database
implementation.
NOT IMPLEMENTED
DO_NOT_LAUNCH
"""
elements(distTag: String = "latest", limit: Int): [CustomElement!]!

"""
Retrieves the custom element data for a single element.
NOT IMPLEMENTED
DO_NOT_LAUNCH
"""
element(
packageName: String!
elementName: String!
tag: String = "latest"
): CustomElement
elements(query: String, limit: Int): [CustomElement!]!
}

type Mutation {
Expand Down
2 changes: 2 additions & 0 deletions packages/catalog-server/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -84,13 +84,15 @@
"@koa/router": "^12.0.0",
"@types/koa__router": "^12.0.0",
"@types/koa-bodyparser": "^4.3.8",
"@types/natural": "^5.1.1",
"@webcomponents/catalog-api": "0.0.0",
"@webcomponents/custom-elements-manifest-tools": "0.0.0",
"custom-elements-manifest": "^2.0.0",
"firebase": "^9.6.10",
"firebase-admin": "^11.0.0",
"graphql-helix": "^1.13.0",
"koa-bodyparser": "^4.3.0",
"natural": "^5.2.3",
"node-fetch": "^3.2.3",
"npm-registry-fetch": "^13.1.0",
"semver": "^7.3.7"
Expand Down
13 changes: 11 additions & 2 deletions packages/catalog-server/src/lib/catalog.ts
Original file line number Diff line number Diff line change
Expand Up @@ -272,8 +272,7 @@ export class Catalog {

console.log('Writing custom elements...');
await this.#repository.writeCustomElements(
packageName,
version,
packageVersionMetadata,
customElements,
versionDistTags,
author
Expand Down Expand Up @@ -307,11 +306,21 @@ export class Catalog {
return this.#repository.getPackageVersion(packageName, version);
}

/**
* Gets the custom elements for a package
*/
async getCustomElements(
packageName: string,
version: string,
tagName: string | undefined
): Promise<Array<CustomElement>> {
return this.#repository.getCustomElements(packageName, version, tagName);
}

async queryElements({query, limit}: {query?: string; limit?: number}) {
// TODO (justinfagnani): The catalog should parse out GitHub-style search
// operators (like "author:yogibear") and pass structured + text queries
// to the repository
return this.#repository.queryElements({query, limit});
}
}
Loading

0 comments on commit 9a80564

Please sign in to comment.