diff --git a/packages/pl-api/lib/client.ts b/packages/pl-api/lib/client.ts index 0d5ffdc9e..33a0015ae 100644 --- a/packages/pl-api/lib/client.ts +++ b/packages/pl-api/lib/client.ts @@ -3,25 +3,26 @@ import omit from 'lodash.omit'; import pick from 'lodash.pick'; import * as v from 'valibot'; +import { + type Account, + type AdminAccount, + type AdminAnnouncement, + type AdminModerationLogEntry, + type AdminReport, + type GroupRole, + type Instance, + instanceSchema, + type Notification, + type PleromaConfig, + type Status, + type StreamingEvent, +} from './entities'; import { filteredArray } from './entities/utils'; import { AKKOMA, type Features, getFeatures, GOTOSOCIAL, MITRA, PIXELFED } from './features'; import request, { getNextLink, getPrevLink, type RequestBody, type RequestMeta } from './request'; import { SCHEMAS } from './schemas'; import { buildFullPath } from './utils/url'; -import type { - Account, - AdminAccount, - AdminAnnouncement, - AdminModerationLogEntry, - AdminReport, - GroupRole, - Instance, - Notification, - PleromaConfig, - Status, - StreamingEvent, -} from './entities'; import type { GroupedNotificationsResults, NotificationGroup } from './entities/grouped-notifications-results'; import type { PlApiResponse } from './main'; import type { @@ -198,7 +199,7 @@ class PlApiClient { baseURL: string; #accessToken?: string; - #instance: Instance = v.parse(SCHEMAS.instanceSchema, {}); + #instance: Instance = v.parse(instanceSchema, {}); public request = request.bind(this) as typeof request; public features: Features = getFeatures(this.#instance); #socket?: { diff --git a/packages/pl-api/lib/schemas/index.ts b/packages/pl-api/lib/schemas/index.ts index 5a89ec5da..f1d5be6aa 100644 --- a/packages/pl-api/lib/schemas/index.ts +++ b/packages/pl-api/lib/schemas/index.ts @@ -1,10 +1,14 @@ import * as v from 'valibot'; +import { instanceSchema } from '../entities'; + import type { ALL_SCHEMAS } from './all-schemas'; const nullSchema = v.fallback(v.null(), null); -const IMPORTED_SCHEMAS = {} as typeof ALL_SCHEMAS; +const IMPORTED_SCHEMAS = { + instanceSchema, +} as typeof ALL_SCHEMAS; const SCHEMAS = new Proxy(IMPORTED_SCHEMAS, { get: (target, p: keyof typeof ALL_SCHEMAS) => p in target ? target[p] : nullSchema, diff --git a/packages/pl-api/vite.config.ts b/packages/pl-api/vite.config.ts index 0928cfc7a..2d0d84b4f 100644 --- a/packages/pl-api/vite.config.ts +++ b/packages/pl-api/vite.config.ts @@ -1,5 +1,6 @@ import { resolve } from 'path'; +import treeShakeable from 'rollup-plugin-tree-shakeable'; import { defineConfig } from 'vite'; import dts from 'vite-plugin-dts'; @@ -19,6 +20,7 @@ export default defineConfig({ sourcemap: true, rollupOptions: { external: Object.keys(pkg.dependencies), + plugins: [treeShakeable()], }, }, }); diff --git a/packages/pl-api/yarn.lock b/packages/pl-api/yarn.lock index 03a37e111..422f02af0 100644 --- a/packages/pl-api/yarn.lock +++ b/packages/pl-api/yarn.lock @@ -547,6 +547,13 @@ dependencies: undici-types "~6.20.0" +"@types/node@^22.7.7": + version "22.10.3" + resolved "https://registry.yarnpkg.com/@types/node/-/node-22.10.3.tgz#cdc2a89bf6e5d5e593fad08e83f74d7348d5dd10" + integrity sha512-DifAyw4BkrufCILvD3ucnuN8eydUfc/C1GlyrnI+LK6543w5/L3VeVgf05o3B4fqSXP1dKYLOZsKfutpxPzZrw== + dependencies: + undici-types "~6.20.0" + "@types/semver@^7.5.8": version "7.5.8" resolved "https://registry.yarnpkg.com/@types/semver/-/semver-7.5.8.tgz#8268a8c57a3e4abd25c165ecd36237db7948a55e" @@ -1461,6 +1468,13 @@ estree-walker@^2.0.2: resolved "https://registry.yarnpkg.com/estree-walker/-/estree-walker-2.0.2.tgz#52f010178c2a4c117a7757cfe942adb7d2da4cac" integrity sha512-Rfkk/Mp/DL7JVje3u18FxFujQlTNR2q6QfMSMB7AvCBx91NGj/ba3kCfza0f6dVDbw7YlRf/nDrn7pQrCCyQ/w== +estree-walker@^3.0.3: + version "3.0.3" + resolved "https://registry.yarnpkg.com/estree-walker/-/estree-walker-3.0.3.tgz#67c3e549ec402a487b4fc193d1953a524752340d" + integrity sha512-7RUKfXgSMMkzt6ZuXmqapOurLGPPfgj6l9uRZ7lRGolvk0y2yocc35LdcxKC5PQZdn2DMqioAQ2NoWcrTKmm6g== + dependencies: + "@types/estree" "^1.0.0" + esutils@^2.0.2: version "2.0.3" resolved "https://registry.yarnpkg.com/esutils/-/esutils-2.0.3.tgz#74d2eb4de0b8da1293711910d50775b9b710ef64" @@ -2050,7 +2064,7 @@ lunr@^2.3.9: resolved "https://registry.yarnpkg.com/lunr/-/lunr-2.3.9.tgz#18b123142832337dd6e964df1a5a7707b25d35e1" integrity sha512-zTU3DaZaF3Rt9rhN3uBMGQD3dD2/vFQqnvZCDv4dl5iOzq2IZQqTxu90r4E5J+nP70J3ilqVCrbho2eWaeW8Ow== -magic-string@^0.30.17: +magic-string@^0.30.12, magic-string@^0.30.17: version "0.30.17" resolved "https://registry.yarnpkg.com/magic-string/-/magic-string-0.30.17.tgz#450a449673d2460e5bbcfba9a61916a1714c7453" integrity sha512-sNPKHvyjVf7gyjwS4xGTaW/mCnF8wnjtifKBEhxfZ7E/S8tQ0rssrwGNn6q8JH/ohItJfSQp9mBtQYuTlH5QnA== @@ -2389,6 +2403,15 @@ rimraf@^3.0.2: dependencies: glob "^7.1.3" +rollup-plugin-tree-shakeable@^1.0.3: + version "1.0.3" + resolved "https://registry.yarnpkg.com/rollup-plugin-tree-shakeable/-/rollup-plugin-tree-shakeable-1.0.3.tgz#8c63528ff119575968e7c9af5e938ee7c071efca" + integrity sha512-A4c06mvUYIuYMN2NJnnPNh5AZlW3KzisCXSENBABUFK4HDgLycuKRsDMRFT21P5CfijoHIo7FDdrVrOGFce4vg== + dependencies: + "@types/node" "^22.7.7" + estree-walker "^3.0.3" + magic-string "^0.30.12" + rollup@^4.23.0: version "4.28.1" resolved "https://registry.yarnpkg.com/rollup/-/rollup-4.28.1.tgz#7718ba34d62b449dfc49adbfd2f312b4fe0df4de" diff --git a/packages/pl-hooks/yarn.lock b/packages/pl-hooks/yarn.lock index d9660033b..63f661ddd 100644 --- a/packages/pl-hooks/yarn.lock +++ b/packages/pl-hooks/yarn.lock @@ -2158,10 +2158,10 @@ pkg-types@^1.0.3, pkg-types@^1.1.1: mlly "^1.7.1" pathe "^1.1.2" -pl-api@^1.0.0-rc.11: - version "1.0.0-rc.11" - resolved "https://registry.yarnpkg.com/pl-api/-/pl-api-1.0.0-rc.11.tgz#57336fa1907ad62daf46c641e75bc32a93126554" - integrity sha512-7trd+istbYdDYC8lXE7soUVOJGBMlKdYM0RLuBSzdV6UnL8h0TOgJKQ6lD/hc8bFYKXbN0i/vJYW6GDgcuAEAQ== +pl-api@^1.0.0-rc.15: + version "1.0.0-rc.15" + resolved "https://registry.yarnpkg.com/pl-api/-/pl-api-1.0.0-rc.15.tgz#fa9d0bbc940388f5a18914e2b7e0b04a540dcd04" + integrity sha512-TqKOJ0URSUOpUJMVyGeRGCNRMocCbSCwSHx4ZkJoC7s/pcbcFWFB0aKDER9LoEOGk3SvBBH7mBDc/4Bnviqd6g== dependencies: blurhash "^2.0.5" http-link-header "^1.1.3"