diff --git a/packages/query/CHANGELOG.md b/packages/query/CHANGELOG.md deleted file mode 100644 index 6b70263cae..0000000000 --- a/packages/query/CHANGELOG.md +++ /dev/null @@ -1,437 +0,0 @@ -# @latticexyz/query - -## 2.2.2 - -### Patch Changes - -- @latticexyz/common@2.2.2 -- @latticexyz/config@2.2.2 -- @latticexyz/schema-type@2.2.2 -- @latticexyz/store@2.2.2 - -## 2.2.1 - -### Patch Changes - -- Updated dependencies [c0764a5] - - @latticexyz/common@2.2.1 - - @latticexyz/config@2.2.1 - - @latticexyz/store@2.2.1 - - @latticexyz/schema-type@2.2.1 - -## 2.2.0 - -### Patch Changes - -- Updated dependencies [69cd0a1] -- Updated dependencies [04c675c] - - @latticexyz/common@2.2.0 - - @latticexyz/config@2.2.0 - - @latticexyz/store@2.2.0 - - @latticexyz/schema-type@2.2.0 - -## 2.1.1 - -### Patch Changes - -- 9e21e42: Bumped viem to `2.19.8` and abitype to `1.0.5`. - - MUD projects using viem or abitype should do the same to ensure no type errors due to mismatched versions: - - ``` - pnpm recursive up viem@2.19.8 abitype@1.0.5 - ``` - -- Updated dependencies [9e21e42] -- Updated dependencies [2daaab1] -- Updated dependencies [57bf8c3] - - @latticexyz/common@2.1.1 - - @latticexyz/config@2.1.1 - - @latticexyz/schema-type@2.1.1 - - @latticexyz/store@2.1.1 - -## 2.1.0 - -### Patch Changes - -- 7129a16: Bumped `@arktype/util` and moved `evaluate`/`satisfy` usages to its `show`/`satisfy` helpers. -- Updated dependencies [24e285d] -- Updated dependencies [7129a16] -- Updated dependencies [7129a16] -- Updated dependencies [e85dc53] -- Updated dependencies [a10b453] -- Updated dependencies [69eb63b] -- Updated dependencies [8d0453e] -- Updated dependencies [fb1cfef] - - @latticexyz/store@2.1.0 - - @latticexyz/config@2.1.0 - - @latticexyz/common@2.1.0 - - @latticexyz/schema-type@2.1.0 - -## 2.0.12 - -### Patch Changes - -- 96e7bf430: TS source has been removed from published packages in favor of DTS in an effort to improve TS performance. All packages now inherit from a base TS config in `@latticexyz/common` to allow us to continue iterating on TS performance without requiring changes in your project code. - - If you have a MUD project that you're upgrading, we suggest adding a `tsconfig.json` file to your project workspace that extends this base config. - - ```sh - pnpm add -D @latticexyz/common - echo "{\n \"extends\": \"@latticexyz/common/tsconfig.base.json\"\n}" > tsconfig.json - ``` - - Then in each package of your project, inherit from your workspace root's config. - - For example, your TS config in `packages/contracts/tsconfig.json` might look like: - - ```json - { - "extends": "../../tsconfig.json" - } - ``` - - And your TS config in `packages/client/tsconfig.json` might look like: - - ```json - { - "extends": "../../tsconfig.json", - "compilerOptions": { - "types": ["vite/client"], - "target": "ESNext", - "lib": ["ESNext", "DOM"], - "jsx": "react-jsx", - "jsxImportSource": "react" - }, - "include": ["src"] - } - ``` - - You may need to adjust the above configs to include any additional TS options you've set. This config pattern may also reveal new TS errors that need to be fixed or rules disabled. - - If you want to keep your existing TS configs, we recommend at least updating your `moduleResolution` setting. - - ```diff - -"moduleResolution": "node" - +"moduleResolution": "Bundler" - ``` - -- Updated dependencies [c10c9fb2d] -- Updated dependencies [c10c9fb2d] -- Updated dependencies [96e7bf430] - - @latticexyz/store@2.0.12 - - @latticexyz/common@2.0.12 - - @latticexyz/config@2.0.12 - - @latticexyz/schema-type@2.0.12 - -## 2.0.11 - -### Patch Changes - -- @latticexyz/common@2.0.11 -- @latticexyz/config@2.0.11 -- @latticexyz/schema-type@2.0.11 -- @latticexyz/store@2.0.11 - -## 2.0.10 - -### Patch Changes - -- Updated dependencies [4e4e9104] -- Updated dependencies [51b137d3] -- Updated dependencies [32c1cda6] -- Updated dependencies [4caca05e] -- Updated dependencies [27f888c7] - - @latticexyz/store@2.0.10 - - @latticexyz/common@2.0.10 - - @latticexyz/config@2.0.10 - - @latticexyz/schema-type@2.0.10 - -## 2.0.9 - -### Patch Changes - -- Updated dependencies [764ca0a0] -- Updated dependencies [bad3ad1b] - - @latticexyz/common@2.0.9 - - @latticexyz/config@2.0.9 - - @latticexyz/store@2.0.9 - - @latticexyz/schema-type@2.0.9 - -## 2.0.8 - -### Patch Changes - -- Updated dependencies [df4781ac] - - @latticexyz/common@2.0.8 - - @latticexyz/config@2.0.8 - - @latticexyz/store@2.0.8 - - @latticexyz/schema-type@2.0.8 - -## 2.0.7 - -### Patch Changes - -- Updated dependencies [375d902e] -- Updated dependencies [38c61158] -- Updated dependencies [ed404b7d] -- Updated dependencies [f736c43d] - - @latticexyz/common@2.0.7 - - @latticexyz/store@2.0.7 - - @latticexyz/config@2.0.7 - - @latticexyz/schema-type@2.0.7 - -## 2.0.6 - -### Patch Changes - -- c18e93c5: Bumped viem to 2.9.20. -- d95028a6: Bumped viem to 2.9.16. -- Updated dependencies [6c8ab471] -- Updated dependencies [103db6ce] -- Updated dependencies [9720b568] -- Updated dependencies [c18e93c5] -- Updated dependencies [d95028a6] - - @latticexyz/common@2.0.6 - - @latticexyz/store@2.0.6 - - @latticexyz/config@2.0.6 - - @latticexyz/schema-type@2.0.6 - -## 2.0.5 - -### Patch Changes - -- Updated dependencies [a9e8a407] -- Updated dependencies [b798ccb2] - - @latticexyz/common@2.0.5 - - @latticexyz/store@2.0.5 - - @latticexyz/config@2.0.5 - - @latticexyz/schema-type@2.0.5 - -## 2.0.4 - -### Patch Changes - -- Updated dependencies [620e4ec1] - - @latticexyz/common@2.0.4 - - @latticexyz/config@2.0.4 - - @latticexyz/store@2.0.4 - - @latticexyz/schema-type@2.0.4 - -## 2.0.3 - -### Patch Changes - -- Updated dependencies [d2e4d0fb] - - @latticexyz/common@2.0.3 - - @latticexyz/config@2.0.3 - - @latticexyz/store@2.0.3 - - @latticexyz/schema-type@2.0.3 - -## 2.0.2 - -### Patch Changes - -- @latticexyz/common@2.0.2 -- @latticexyz/config@2.0.2 -- @latticexyz/schema-type@2.0.2 -- @latticexyz/store@2.0.2 - -## 2.0.1 - -### Patch Changes - -- Updated dependencies [4a6b4598] - - @latticexyz/store@2.0.1 - - @latticexyz/common@2.0.1 - - @latticexyz/config@2.0.1 - - @latticexyz/schema-type@2.0.1 - -## 2.0.0 - -### Patch Changes - -- Updated dependencies [7ce82b6fc] -- Updated dependencies [d8c8f66bf] -- Updated dependencies [c6c13f2ea] -- Updated dependencies [1b86eac05] -- Updated dependencies [a35c05ea9] -- Updated dependencies [c9ee5e4a] -- Updated dependencies [c963b46c7] -- Updated dependencies [05b3e8882] -- Updated dependencies [16b13ea8f] -- Updated dependencies [aea67c580] -- Updated dependencies [82693072] -- Updated dependencies [07dd6f32c] -- Updated dependencies [90e4161bb] -- Updated dependencies [aabd30767] -- Updated dependencies [65c9546c4] -- Updated dependencies [331dbfdcb] -- Updated dependencies [d5c0682fb] -- Updated dependencies [1d60930d6] -- Updated dependencies [01e46d99] -- Updated dependencies [f9f9609ef] -- Updated dependencies [904fd7d4e] -- Updated dependencies [e6c03a87a] -- Updated dependencies [1077c7f53] -- Updated dependencies [2c920de7] -- Updated dependencies [b9e562d8f] -- Updated dependencies [331dbfdcb] -- Updated dependencies [44236041f] -- Updated dependencies [066056154] -- Updated dependencies [759514d8b] -- Updated dependencies [952cd5344] -- Updated dependencies [d5094a242] -- Updated dependencies [3fb9ce283] -- Updated dependencies [bb6ada740] -- Updated dependencies [35c9f33df] -- Updated dependencies [a25881160] -- Updated dependencies [0b8ce3f2c] -- Updated dependencies [933b54b5f] -- Updated dependencies [c4d5eb4e4] -- Updated dependencies [f62c767e7] -- Updated dependencies [9aa5e786] -- Updated dependencies [307abab3] -- Updated dependencies [de151fec0] -- Updated dependencies [37c228c63] -- Updated dependencies [aacffcb59] -- Updated dependencies [c991c71a] -- Updated dependencies [ae340b2bf] -- Updated dependencies [1bf2e9087] -- Updated dependencies [b38c096d] -- Updated dependencies [211be2a1e] -- Updated dependencies [0f3e2e02b] -- Updated dependencies [d08789282] -- Updated dependencies [5c965a919] -- Updated dependencies [f99e88987] -- Updated dependencies [939916bcd] -- Updated dependencies [d5b73b126] -- Updated dependencies [e34d1170] -- Updated dependencies [b8a6158d6] -- Updated dependencies [190fdd11] -- Updated dependencies [433078c54] -- Updated dependencies [db314a74] -- Updated dependencies [b2d2aa715] -- Updated dependencies [83583a505] -- Updated dependencies [5e723b90e] -- Updated dependencies [6573e38e9] -- Updated dependencies [afaf2f5ff] -- Updated dependencies [37c228c63] -- Updated dependencies [59267655] -- Updated dependencies [37c228c63] -- Updated dependencies [44a5432ac] -- Updated dependencies [6e66c5b74] -- Updated dependencies [8d51a0348] -- Updated dependencies [c162ad5a5] -- Updated dependencies [65c9546c4] -- Updated dependencies [48909d151] -- Updated dependencies [7b28d32e5] -- Updated dependencies [b02f9d0e4] -- Updated dependencies [f62c767e7] -- Updated dependencies [bb91edaa0] -- Updated dependencies [590542030] -- Updated dependencies [1b5eb0d07] -- Updated dependencies [44a5432ac] -- Updated dependencies [48c51b52a] -- Updated dependencies [9f8b84e73] -- Updated dependencies [66cc35a8c] -- Updated dependencies [672d05ca1] -- Updated dependencies [55a05fd7a] -- Updated dependencies [f03531d97] -- Updated dependencies [63831a264] -- Updated dependencies [b8a6158d6] -- Updated dependencies [6db95ce15] -- Updated dependencies [8193136a9] -- Updated dependencies [5d737cf2e] -- Updated dependencies [d075f82f3] -- Updated dependencies [331dbfdcb] -- Updated dependencies [a7b30c79b] -- Updated dependencies [92de59982] -- Updated dependencies [22ee44700] -- Updated dependencies [ad4ac4459] -- Updated dependencies [be313068b] -- Updated dependencies [ac508bf18] -- Updated dependencies [93390d89] -- Updated dependencies [bb91edaa0] -- Updated dependencies [144c0d8d] -- Updated dependencies [5ac4c97f4] -- Updated dependencies [bfcb293d1] -- Updated dependencies [3e057061d] -- Updated dependencies [1890f1a06] -- Updated dependencies [e48171741] -- Updated dependencies [9b43029c3] -- Updated dependencies [37c228c63] -- Updated dependencies [55ab88a60] -- Updated dependencies [c58da9ad] -- Updated dependencies [37c228c63] -- Updated dependencies [535229984] -- Updated dependencies [af639a264] -- Updated dependencies [5e723b90e] -- Updated dependencies [99ab9cd6f] -- Updated dependencies [0c4f9fea9] -- Updated dependencies [0d12db8c2] -- Updated dependencies [c049c23f4] -- Updated dependencies [80dd6992e] -- Updated dependencies [60cfd089f] -- Updated dependencies [24a6cd536] -- Updated dependencies [37c228c63] -- Updated dependencies [708b49c50] -- Updated dependencies [d2f8e9400] -- Updated dependencies [25086be5f] -- Updated dependencies [b1d41727d] -- Updated dependencies [3ac68ade6] -- Updated dependencies [22ba7b675] -- Updated dependencies [4c1dcd81e] -- Updated dependencies [3042f86e] -- Updated dependencies [5e71e1cb5] -- Updated dependencies [6071163f7] -- Updated dependencies [6c6733256] -- Updated dependencies [cd5abcc3b] -- Updated dependencies [d7b1c588a] -- Updated dependencies [5c52bee09] -- Updated dependencies [8025c3505] -- Updated dependencies [c4f49240d] -- Updated dependencies [745485cda] -- Updated dependencies [37c228c63] -- Updated dependencies [3e7d83d0] -- Updated dependencies [5df1f31bc] -- Updated dependencies [cea754dde] -- Updated dependencies [331f0d636] -- Updated dependencies [cc2c8da00] -- Updated dependencies [252a1852] -- Updated dependencies [103f635eb] - - @latticexyz/store@2.0.0 - - @latticexyz/common@2.0.0 - - @latticexyz/schema-type@2.0.0 - - @latticexyz/config@2.0.0 - -## 2.0.0-next.18 - -### Patch Changes - -- Updated dependencies [c9ee5e4a] -- Updated dependencies [82693072] -- Updated dependencies [d5c0682fb] -- Updated dependencies [01e46d99] -- Updated dependencies [2c920de7] -- Updated dependencies [44236041] -- Updated dependencies [9aa5e786] -- Updated dependencies [307abab3] -- Updated dependencies [c991c71a] -- Updated dependencies [b38c096d] -- Updated dependencies [e34d1170] -- Updated dependencies [190fdd11] -- Updated dependencies [db314a74] -- Updated dependencies [59267655] -- Updated dependencies [8193136a9] -- Updated dependencies [93390d89] -- Updated dependencies [144c0d8d] -- Updated dependencies [c58da9ad] -- Updated dependencies [3042f86e] -- Updated dependencies [d7b1c588a] -- Updated dependencies [3e7d83d0] -- Updated dependencies [252a1852] - - @latticexyz/store@2.0.0-next.18 - - @latticexyz/common@2.0.0-next.18 - - @latticexyz/schema-type@2.0.0-next.18 - - @latticexyz/config@2.0.0-next.18 diff --git a/packages/query/README.md b/packages/query/README.md deleted file mode 100644 index 023c580b18..0000000000 --- a/packages/query/README.md +++ /dev/null @@ -1,3 +0,0 @@ -# query - -Tools for interacting with the MUD query API. diff --git a/packages/query/package.json b/packages/query/package.json deleted file mode 100644 index 57e6bad646..0000000000 --- a/packages/query/package.json +++ /dev/null @@ -1,51 +0,0 @@ -{ - "name": "@latticexyz/query", - "version": "2.2.2", - "description": "Tools for interacting with the MUD query API", - "repository": { - "type": "git", - "url": "https://github.com/latticexyz/mud.git", - "directory": "packages/query" - }, - "license": "MIT", - "type": "module", - "exports": { - ".": "./dist/index.js", - "./internal": "./dist/internal.js" - }, - "typesVersions": { - "*": { - "index": [ - "./dist/index.d.ts" - ], - "internal": [ - "./dist/internal.d.ts" - ] - } - }, - "files": [ - "dist" - ], - "scripts": { - "build": "tsup", - "clean": "shx rm -rf dist", - "dev": "tsup --watch", - "test": "vitest typecheck --run --passWithNoTests && vitest --run --passWithNoTests", - "test:ci": "pnpm run test" - }, - "dependencies": { - "@ark/util": "catalog:", - "@latticexyz/common": "workspace:*", - "@latticexyz/config": "workspace:*", - "@latticexyz/schema-type": "workspace:*", - "@latticexyz/store": "workspace:*", - "viem": "catalog:" - }, - "devDependencies": { - "tsup": "^6.7.0", - "vitest": "0.34.6" - }, - "publishConfig": { - "access": "public" - } -} diff --git a/packages/query/src/api.ts b/packages/query/src/api.ts deleted file mode 100644 index 622f0b15ef..0000000000 --- a/packages/query/src/api.ts +++ /dev/null @@ -1,89 +0,0 @@ -import { Hex } from "viem"; -import { satisfy } from "@ark/util"; -import { StaticPrimitiveType, DynamicPrimitiveType, SchemaAbiType } from "@latticexyz/schema-type/internal"; -import { SchemaToPrimitives } from "@latticexyz/store/internal"; -import { Table } from "@latticexyz/config"; - -/** - * These types represent the "over the wire" protocol (i.e. JSON) for the query API. - * - * Currently always returns matching records for each subject. We may add separate endpoints and return types for just subjects later. - */ - -// TODO: decide if we want to support stronger types here (e.g. table generic that constrains subjects, records, etc.) -// TODO: decide if/how we want to add block number throughout (esp as it relates to instant sequencing) -// TODO: separate set of types for querying just - -export type QueryTable = { - readonly tableId: Hex; - readonly field: string; -}; - -export type QuerySubject = { - readonly tableId: Hex; - readonly subject: readonly string[]; -}; - -// TODO: should we exclude arrays? might be hard to support array comparisons in SQL -export type ConditionLiteral = StaticPrimitiveType | DynamicPrimitiveType; - -export type ComparisonCondition = { - readonly left: QueryTable; - readonly op: "<" | "<=" | "=" | ">" | ">=" | "!="; - // TODO: add support for QueryTable - readonly right: ConditionLiteral; -}; - -export type InCondition = { - readonly left: QueryTable; - readonly op: "in"; - readonly right: readonly ConditionLiteral[]; -}; - -export type QueryCondition = satisfy<{ readonly op: string }, ComparisonCondition | InCondition>; - -export type Query = { - readonly from: readonly QuerySubject[]; - readonly except?: readonly QuerySubject[]; - readonly where?: readonly QueryCondition[]; -}; - -export type PrimitiveType = StaticPrimitiveType | DynamicPrimitiveType; - -export type ResultRecord = { - readonly tableId: Hex; - readonly keyTuple: readonly Hex[]; - readonly primaryKey: readonly StaticPrimitiveType[]; - readonly fields: SchemaToPrimitives; -}; - -export type Subject = readonly PrimitiveType[]; -export type SubjectSchema = readonly SchemaAbiType[]; - -export type SubjectRecords = { - readonly subject: Subject; - readonly subjectSchema: SubjectSchema; - readonly records: readonly ResultRecord[]; -}; - -// TODO: consider flattening this to be more like `ResultRecord & { subject: Subject }` -export type SubjectRecord = { - readonly subject: Subject; - readonly subjectSchema: SubjectSchema; - readonly record: ResultRecord; -}; - -// TODO: for change event, should this include previous record? -// TODO: use merge helper instead of `&` intersection? -export type SubjectEvent = SubjectRecord & { - /** - * `enter` = a new subject+record pair matched - * `exit` = a subject+record pair no longer matches - * `change` = the record oft he subject+record pair changed - */ - readonly type: "enter" | "exit" | "change"; -}; - -export type Result = { - readonly subjects: readonly SubjectRecords[]; -}; diff --git a/packages/query/src/common.ts b/packages/query/src/common.ts deleted file mode 100644 index a107a6a1b0..0000000000 --- a/packages/query/src/common.ts +++ /dev/null @@ -1,13 +0,0 @@ -import { StaticPrimitiveType } from "@latticexyz/schema-type/internal"; -import { SchemaToPrimitives } from "@latticexyz/store/internal"; -import { Table } from "@latticexyz/config"; -import { Hex } from "viem"; - -export type TableRecord = { - readonly table: table; - // TODO: refine to just static types - // TODO: add helper to extract primary key of primitive types from table primary key + field values - readonly primaryKey: readonly StaticPrimitiveType[]; - readonly keyTuple: readonly Hex[]; - readonly fields: SchemaToPrimitives; -}; diff --git a/packages/query/src/exports/index.ts b/packages/query/src/exports/index.ts deleted file mode 100644 index 3b94ec7da6..0000000000 --- a/packages/query/src/exports/index.ts +++ /dev/null @@ -1,22 +0,0 @@ -/** - * External exports. - * - * Be sure we're ready to commit to these being supported and changes made backward compatible! - */ - -export type { - Query, - QueryCondition, - QuerySubject, - QueryTable, - ConditionLiteral, - InCondition, - ComparisonCondition, - ResultRecord, - Subject, - SubjectSchema, - SubjectRecord, - SubjectRecords, - SubjectEvent, - Result, -} from "../api"; diff --git a/packages/query/src/exports/internal.ts b/packages/query/src/exports/internal.ts deleted file mode 100644 index 5c1ed7149b..0000000000 --- a/packages/query/src/exports/internal.ts +++ /dev/null @@ -1,3 +0,0 @@ -export * from "../common"; -export * from "../findSubjects"; -export * from "../matchRecords"; diff --git a/packages/query/src/findSubjects.ts b/packages/query/src/findSubjects.ts deleted file mode 100644 index 81243c8661..0000000000 --- a/packages/query/src/findSubjects.ts +++ /dev/null @@ -1,89 +0,0 @@ -import { encodeAbiParameters } from "viem"; -import { Table } from "@latticexyz/config"; -import { groupBy, uniqueBy } from "@latticexyz/common/utils"; -import { Query, SubjectRecords } from "./api"; -import { matchRecords } from "./matchRecords"; -import { TableRecord } from "./common"; - -// This assumes upstream has fully validated query -// This also assumes we have full records, which may not always be the case and we may need some way to request records for a given table subject -// We don't carry around config types here for ease, they get handled by the wrapping `query` function - -export type FindSubjectsParameters
= { - readonly records: readonly TableRecord
[]; - readonly query: Query; -}; - -// TODO: make condition types smarter? so condition literal matches the field primitive type - -export function findSubjects
({ - records: initialRecords, - query, -}: FindSubjectsParameters
): readonly SubjectRecords[] { - const targetTables = Object.fromEntries( - uniqueBy([...query.from, ...(query.except ?? [])], (subject) => subject.tableId).map((subject) => [ - subject.tableId, - subject.subject, - ]), - ); - const fromTableIds = new Set(query.from.map((subject) => subject.tableId)); - const exceptTableIds = new Set((query.except ?? []).map((subject) => subject.tableId)); - - // TODO: store/lookup subjects separately rather than mapping each time so we can "memoize" better? - const records = initialRecords - .filter((record) => targetTables[record.table.tableId]) - .map((record) => { - const subjectFields = targetTables[record.table.tableId]; - const subject = subjectFields.map((field) => record.fields[field]); - const subjectSchema = subjectFields.map((field) => record.table.schema[field]); - const subjectId = encodeAbiParameters(subjectSchema, subject); - return { - ...record, - subjectSchema, - subject, - subjectId, - }; - }); - - const matchedSubjects = Array.from(groupBy(records, (record) => record.subjectId).values()) - .map((records) => ({ - subjectId: records[0].subjectId, - subject: records[0].subject, - subjectSchema: records[0].subjectSchema.map((abiType) => abiType.type), - records, - })) - .filter(({ records }) => { - // make sure our matched subject has no records in `query.except` tables - return exceptTableIds.size ? !records.some((record) => exceptTableIds.has(record.table.tableId)) : true; - }) - .filter(({ records }) => { - // make sure our matched subject has records in all `query.from` tables - const tableIds = new Set(records.map((record) => record.table.tableId)); - return tableIds.size === fromTableIds.size; - }) - .map((match) => { - if (!query.where) return match; - - let records: readonly TableRecord
[] = match.records; - for (const condition of query.where) { - if (!records.length) break; - records = matchRecords(condition, records); - } - - return { ...match, records }; - }) - .filter((match) => match.records.length > 0); - - const subjects = matchedSubjects.map((match) => ({ - subject: match.subject, - subjectSchema: match.subjectSchema, - records: match.records.map((record) => ({ - tableId: record.table.tableId, - primaryKey: record.primaryKey, - keyTuple: record.keyTuple, - fields: record.fields, - })), - })); - - return subjects; -} diff --git a/packages/query/src/index.ts b/packages/query/src/index.ts deleted file mode 100644 index 471b43d6d7..0000000000 --- a/packages/query/src/index.ts +++ /dev/null @@ -1,3 +0,0 @@ -export * from "./api"; -export * from "./findSubjects"; -export * from "./matchRecords"; diff --git a/packages/query/src/matchRecords.ts b/packages/query/src/matchRecords.ts deleted file mode 100644 index d7aba8bb5a..0000000000 --- a/packages/query/src/matchRecords.ts +++ /dev/null @@ -1,37 +0,0 @@ -import { Table } from "@latticexyz/config"; -import { ComparisonCondition, ConditionLiteral, QueryCondition } from "./api"; -import { TableRecord } from "./common"; - -const comparisons = { - "<": (left, right) => left < right, - "<=": (left, right) => left <= right, - "=": (left, right) => left === right, - ">": (left, right) => left > right, - ">=": (left, right) => left >= right, - "!=": (left, right) => left !== right, -} as const satisfies Record boolean>; - -export function matchRecords
( - condition: QueryCondition, - records: readonly TableRecord
[], -): readonly TableRecord
[] { - switch (condition.op) { - case "<": - case "<=": - case "=": - case ">": - case ">=": - case "!=": - return records.filter( - (record) => - record.table.tableId === condition.left.tableId && - comparisons[condition.op](record.fields[condition.left.field], condition.right), - ); - case "in": - return records.filter( - (record) => - record.table.tableId === condition.left.tableId && - condition.right.includes(record.fields[condition.left.field]), - ); - } -} diff --git a/packages/query/tsconfig.json b/packages/query/tsconfig.json deleted file mode 100644 index 039e0b4d16..0000000000 --- a/packages/query/tsconfig.json +++ /dev/null @@ -1,7 +0,0 @@ -{ - "extends": "../../tsconfig.json", - "compilerOptions": { - "outDir": "dist" - }, - "include": ["src"] -} diff --git a/packages/query/tsup.config.ts b/packages/query/tsup.config.ts deleted file mode 100644 index 709f21cd88..0000000000 --- a/packages/query/tsup.config.ts +++ /dev/null @@ -1,14 +0,0 @@ -import { defineConfig } from "tsup"; - -export default defineConfig({ - entry: { - index: "src/exports/index.ts", - internal: "src/exports/internal.ts", - }, - target: "esnext", - format: ["esm"], - dts: !process.env.TSUP_SKIP_DTS, - sourcemap: true, - clean: true, - minify: true, -}); diff --git a/packages/store-sync/package.json b/packages/store-sync/package.json index 5112189663..8a0ab2fa1f 100644 --- a/packages/store-sync/package.json +++ b/packages/store-sync/package.json @@ -67,7 +67,6 @@ "@latticexyz/common": "workspace:*", "@latticexyz/config": "workspace:*", "@latticexyz/protocol-parser": "workspace:*", - "@latticexyz/query": "workspace:*", "@latticexyz/recs": "workspace:*", "@latticexyz/schema-type": "workspace:*", "@latticexyz/store": "workspace:*", diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index da5e3efbbf..740266f6de 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -712,34 +712,6 @@ importers: specifier: 0.34.6 version: 0.34.6(jsdom@22.1.0(bufferutil@4.0.8)(utf-8-validate@5.0.10))(terser@5.31.6) - packages/query: - dependencies: - '@ark/util': - specifier: 'catalog:' - version: 0.2.2 - '@latticexyz/common': - specifier: workspace:* - version: link:../common - '@latticexyz/config': - specifier: workspace:* - version: link:../config - '@latticexyz/schema-type': - specifier: workspace:* - version: link:../schema-type - '@latticexyz/store': - specifier: workspace:* - version: link:../store - viem: - specifier: 'catalog:' - version: 2.19.8(bufferutil@4.0.8)(typescript@5.4.2)(utf-8-validate@5.0.10)(zod@3.23.8) - devDependencies: - tsup: - specifier: ^6.7.0 - version: 6.7.0(postcss@8.4.31)(typescript@5.4.2) - vitest: - specifier: 0.34.6 - version: 0.34.6(jsdom@22.1.0(bufferutil@4.0.8)(utf-8-validate@5.0.10))(terser@5.31.6) - packages/react: dependencies: '@latticexyz/recs': @@ -1109,9 +1081,6 @@ importers: '@latticexyz/protocol-parser': specifier: workspace:* version: link:../protocol-parser - '@latticexyz/query': - specifier: workspace:* - version: link:../query '@latticexyz/recs': specifier: workspace:* version: link:../recs