# @or-sdk/library-types

## 9.0.0

### Major Changes

- 945eb1d: Major upgrade across the monorepo: Node.js 22 + pnpm 10.33.4 runtime, NestJS 11, Prisma 7 (Rust-free), Express 5, Sentry 10, Zod 4. The Prisma workspace package was folded into the API service, dependencies were realigned across all packages, and Docker/Helm/Terraform deployment was reshaped accordingly.

  ### Runtime and toolchain

  - Bumped target runtime to Node.js 22 and pnpm 10.33.4 (lockfile and engines updated).
  - Upgraded NestJS to 11 (`@nestjs/common`, `@nestjs/core`, `@nestjs/platform-express`, `@nestjs/event-emitter`, `@nestjs/swagger`, `@nestjs/cli`, `@nestjs/testing`).
  - Upgraded Express to 5 (with `body-parser` 2). `main.ts` now resets the Express `query parser` back to `extended` so existing Zod query schemas like `GetPackagesQuery.scope.id` keep parsing nested params.
  - Upgraded Sentry to v10 (`@sentry/node`, `@sentry/vue`); removed the dead `@sentry/tracing` v7 dependency.
  - Bumped `@willsoto/nestjs-prometheus`, `archiver` 8, `axios` 1.16, `class-validator` 0.15, `dotenv` 17, `mime-types` 3, `morgan` 1.10, `nestjs-zod` 5, `openai` 6, `zod` 4, plus the full AWS SDK v3 set to 3.1052+.
  - Dropped now-unused deps from `@onereach/library-api`: `@aws-sdk/client-kms`, `aws-lambda`, `cache-manager`, `nestjs-prisma`, `@sentry/tracing`.
  - Jest config: added a `moduleNameMapper` rule that rewrites relative `.js` imports back to `.ts` so the new Prisma-generated client (which emits ESM-style `./internal/class.js` paths) resolves under CJS Jest.

  ### Prisma 7 migration (Rust-free + driver adapter)

  - Upgraded to Prisma 7.8.0 and switched runtime to `@prisma/adapter-pg` (`PrismaPg`) since Prisma 7 is Rust-free by default and requires a driver adapter for actual queries.
  - `src/db/extension.ts` now builds the master adapter, derives one or more replica `PrismaClient`+`PrismaPg` instances from `PG_REPLICA_URL` (supports both string and string-array), and wires them through `@prisma/extension-read-replicas` 0.5 (`readReplicas({ replicas: [...] })`). Falls back to a master-backed replica when no replica URL is configured.
  - `src/db/getPrismaInstance.ts` switched the migration/admin singleton to the driver-adapter constructor.
  - Generator switched to `prisma-client` (CJS, `runtime: nodejs`, `importFileExtension: "js"`); preview features `fullTextSearchPostgres` and `nativeDistinct` enabled.
  - `src/metrics/metrics.controller.ts` reduced to a plain `PrometheusController` because Prisma 7 removed the `metrics` preview feature; `$metrics.prometheus()` is no longer wired in. Hook OpenTelemetry here if granular Prisma metrics are needed again.
  - Small TS migration fixups under `src/db/migrations/**` for Prisma 7 typing changes.

  ### Folding `@or-sdk/library-prisma` into the API

  - Removed the standalone `packages/prisma` workspace package (`@or-sdk/library-prisma`).
  - Schema, migrations, and Prisma config now live inside the API:
    - `packages/api/prisma/schema.prisma` (generator output retargeted to `../src/prisma/generated/client`).
    - `packages/api/prisma/migrations/**`.
    - `packages/api/prisma.config.ts` with `schema: 'prisma/schema.prisma'` and `migrations.path: 'prisma/migrations'`.
  - The Prisma client wrapper now lives at `packages/api/src/prisma/index.ts` and is imported app-wide as `@/prisma`. All 51 in-tree imports of `@or-sdk/library-prisma` were rewritten.
  - Generated client output `packages/api/src/prisma/generated/client` is gitignored; the wrapper is the only public import surface, so future generator/runtime changes stay localized.
  - Removed the separate `prisma` library project from `packages/api/nest-cli.json`; `tsconfig.base.json` no longer references the removed package; `pnpm-workspace.yaml` lost the `packages/prisma` entry.
  - Added `@prisma/client`, `prisma`, `pg`, `dotenv` directly to the API (`prisma` and `dotenv` survive `--prod` for `prisma migrate deploy` and `prisma.config.ts`).
  - Root scripts no longer fan out to the removed package: `build:nest`, `migrate:prepare`, `migrate:dev`, `migrate:prod` now go through `@onereach/library-api`. Root `prisma.schema` was updated to point at the new location.

  ### API service scripts and config

  - Added API-local scripts: `build:prisma` (format + generate with a local-DB env fallback), `migrate:prisma` (`prisma migrate deploy`), `migrate:create` (`prisma migrate dev --create-only` plus `pnpm -w docker:start`), and `migrate:prod` (`npm run migrate:admin && npm run migrate:prisma && npm run migrate`). The new `migrate:prod` runs purely on `npm`, so the slim `pnpm deploy` output does not need pnpm installed at runtime.
  - Added required `AUTH_CONFIG` field to `ConfigSchema` with a `JSON.parse` transform so it accepts both stringified JSON env (Terraform/Helm) and direct object payloads (test/config.json).
  - Added `SERVICE_DISCOVERY_API_URL` to `ConfigSchema`.
  - Swagger setup removes synthetic `root` query parameters emitted for Zod query DTOs before calling `cleanupOpenApiDoc`, preventing docs cleanup from crashing service startup.
  - `/health` is now a lightweight liveness endpoint and no longer blocks on a Prisma migration count query.
  - `GET /api/v2/packages/:type` now skips the unpaginated categories aggregation (`getPackagesCategoriesQueryTime`) on subsequent pages, falling back to a cheap `groupBy` distinct count (`getPackagesDistinctCountQueryTime`). The aggregation still runs on the first page, when `includeCategories=true` is passed, or when a category filter/scope by name/id requires translation through `_byName`/`_byId`. New optional `includeCategories` query param added to `GetPackagesParams`.
  - UI: `steps` store stops clobbering `state.steps.categoriesIds` on infinite-scroll requests so chip name lookups in `EntitiesView` / `IframeEntitiesView` keep working when the v2 packages API returns empty `categories` on subsequent pages. The `SET_STEPS_CATEGORIES_IDS` mutation also has a defensive guard against empty-array overwrites, and both `withPaging/getEntities` and `getRelatedStepTemplates` now only emit it when `loadMore !== true`.
  - Optional `LOG_V2_PACKAGES_SQL=true` env flag (read in `src/db/extension.ts` and `packages.service.getters.v2.ts`) captures the raw replica SQL + params + duration for `"PackageRelease"`-touching queries plus a structured request shape, to enable `EXPLAIN ANALYZE`-driven follow-up optimization of the main paginated query. Off by default; remove together with the gated logging code once the next optimization lands.
  - `packages/api/resources/shell.js` annotated with `eslint-env node` + `@ts-expect-error` so the deploy-platform CommonJS resource stops triggering ESLint/TS migration warnings.
  - Stress, e2e and unit test scripts now pass `--colors` and use the renamed `--testPathPatterns` flag.

  ### Docker, CI, and Helm wiring

  - `Dockerfile.api` restored to a slim `pnpm deploy --filter @onereach/library-api --prod --legacy /prod/api` flow:
    - Build stage runs `pnpm install` (ignored scripts + frozen lockfile), copies only API + types packages, then `pnpm install && pnpm run build:api && pnpm deploy …`.
    - Final `api` stage installs only system deps (no pnpm), copies `/prod/api`, and starts with `node dist/main`.
    - `ENV CI=true` added to the build stage to keep pnpm non-interactive (fixes `ERR_PNPM_ABORTED_REMOVE_MODULES_DIR_NO_TTY`).
    - Lambda stage continues to pull `/app/packages/api/dist/lambda_functions/*` from the build stage.
  - `.dockerignore` rewritten as a whitelist scoped to the API image inputs (root pnpm/tsconfig files + `packages/api`, `packages/api/prisma`, `packages/api/prisma.config.ts`, `packages/types-v1`, `packages/types-v2`).
  - `.gitlab-ci.yml` `changes` triggers updated to watch `packages/api/prisma/**` instead of the removed `packages/prisma/**` paths.
  - Lambda function bundling externalizes `nestjs-zod` so Node loads its CJS entry at runtime instead of esbuild inlining the ESM entry that calls `createRequire(import.meta.url)`.
  - Helm/Terraform env plumbing for non-scalar values:
    - `service/locals.tf` now stringifies non-scalar entries (`v == null ? "" : can(tostring(v)) ? tostring(v) : jsonencode(v)`) for `global_env`, `api_env`, `migration_env`, and the new `library_extractor_lambda_env`.
    - `service/lambda.tf` switched `aws_lambda_function.library_extractor.environment.variables` from the raw config to the stringified `library_extractor_lambda_env` so object values (e.g. `AUTH_CONFIG`) no longer fail Terraform's string-typed env shape.
    - `packages/api/config/library_api/env.yaml` now sources `AUTH_CONFIG: $[auth_api.config]` in the `global:` section, so both the API container and the migrate init container receive it after `concat(local.global_env, …)` in `locals.tf`.

  ### Types packages (v1, v2)

  - Major bump on both `@or-sdk/library-types-v1` and `@or-sdk/library-types-v2`.
  - Migrated to `zod` 4.4.3 + `nestjs-zod` 5.4.0 (request/response schemas updated for the new Zod 4 API surface).
  - Removed the `@or-sdk/library-prisma` dev dependency; both packages now ship plain TS `domain/enums.ts` and `domain/models.ts` that mirror `packages/api/prisma/schema.prisma` without importing Prisma.
  - The published file whitelist now includes `dist/nest/**`, matching the existing `./nest` package export used by the API at runtime.

  ### UI package

  - Major bump (`@onereach/library-ui` 9.0.0).
  - Bumped `@onereach/auth-ui-module` 11.2, `@onereach/ui-config` 2.0.4, `@onereach/ui-utils` 3.15.1, `@vue/compiler-sfc` 3.5.34, `markdown-it` 14.1.1, and the full `@or-sdk/*` consumer set (`accounts`, `agents`, `auth`, `bots`, `cards`, `flows`, `library`, `library-categories`, `settings`, `step-templates`, `tags`, `users`, `view-templates`, `views`, `bot-templates`, `card-templates`, `content-request`, `flow-templates`).
  - Switched Sentry on the browser to `@sentry/vue` 10; dropped `@sentry/browser` v8 and `@sentry/tracing` v7.
  - Removed now-unused `@onereach/or-i18n`, `@onereach/ui-utils`-adjacent legacy deps that are no longer referenced.
  - Small fix in `src/api/users.or-sdk.js`; Vite config tweak; deploy script touch-up.
  - Removed the obsolete `packages/ui-modules/LibraryView` package (assets, components, stores, composables, types, utils, vite/tailwind/tsconfig) — UI no longer ships that bundle.

  ### Workspace and lockfile housekeeping

  - `pnpm-workspace.yaml`: removed `packages/prisma`; large `overrides` and `onlyBuiltDependencies` allow-lists added/updated to cover the new dependency graph (Prisma engines, NestJS core, parcel watcher, esbuild, swc, etc.).
  - `pnpm-lock.yaml` fully regenerated against the new manifests; no leftover `@or-sdk/library-prisma` entries.
  - `tsconfig.base.json` and root `tsconfig.json` cleaned up to drop references to the removed package.
  - Updated `.cursor/rules/project.mdc` with the new Prisma location, a full endpoint inventory per controller, and corrected current-state notes.

## 7.1.0

### Minor Changes

- 88c8332: add image versions

## 7.0.3

### Patch Changes

- 0f3e754: feat: add search option to legacy sync

## 7.0.2

### Patch Changes

- 1b348561: remove v8-compile-cache-0

## 7.0.1

### Patch Changes

- bfa84dd0: fix filter value

## 7.0.0

### Major Changes

- a34446a2: change build structure(bundle d.ts, resolve nest and browsers imports), fix node-linker=hoisted

### Minor Changes

- a34446a2: use dts bundler, update dependencies, fix all SAST and DAST

## 6.0.15

### Patch Changes

- 40fbb233: v1 api packages latest endpoint fix prerelease for admin account

## 6.0.14

### Patch Changes

- d52d1acb: fix for json recreate for non uploaded packages

## 6.0.13

### Patch Changes

- 6df06387: remove servingType, add schemaServingType and schemaVersion prop

## 6.0.12

### Patch Changes

- d7e078d7: add more sort orders, add label and relevance sort order

## 6.0.11

### Patch Changes

- f0e68cc8: move packageReleases data to another table

## 6.0.10

### Patch Changes

- b27e49bc: add prereleases query and remove preleases from get packages, update query

## 6.0.9

### Patch Changes

- 6b81ac6d: update cjs build

## 6.0.8

### Patch Changes

- 49ae2d62: add esm, cjs, types build artifacts, make this package public

## 6.0.7

### Patch Changes

- 47edc270: add releases and include deprecated, etc for get lastest package, try to fix categories param on get packages

## 6.0.6

### Patch Changes

- 0d145a33: fix zod intersection error, bump prisma from 5.4.1 => 5.4.2, zod 3.22.3 => 3.22.4
- Updated dependencies [0d145a33]
  - @or-sdk/library-prisma@6.0.6

## 6.0.5

### Patch Changes

- Updated dependencies [be8072b]
  - @or-sdk/library-prisma@6.0.5

## 6.0.4

### Patch Changes

- 9dc9834: test interruptible property
- Updated dependencies [9dc9834]
  - @or-sdk/library-prisma@6.0.4

## 6.0.3

### Patch Changes

- 27f7a1f: add more types
- Updated dependencies [27f7a1f]
  - @or-sdk/library-prisma@6.0.3

## 6.0.2

### Patch Changes

- 7ecdb79: use changeset publish
- Updated dependencies [7ecdb79]
  - @or-sdk/library-prisma@6.0.2

## 6.0.1

### Patch Changes

- 1672d9d: try to rebuild
- Updated dependencies [1672d9d]
  - @or-sdk/library-prisma@6.0.1

## 6.0.0

### Major Changes

- 78cbaca: use playground instead of sandbox terminology, added TODO with #SA-32 for apply braking changes

### Patch Changes

- Updated dependencies [78cbaca]
  - @or-sdk/library-prisma@6.0.0

## 5.0.4

### Patch Changes

- f91b030: bump dependencies

## 5.0.3

### Patch Changes

- Updated dependencies [003bccc]
  - @or-sdk/library-prisma@5.0.3

## 5.0.2

### Patch Changes

- 92ed66e: test prerelease
- Updated dependencies [92ed66e]
  - @or-sdk/library-prisma@5.0.2

## 5.0.1

### Patch Changes

- Updated dependencies [8594386]
  - @or-sdk/library-prisma@5.0.1

## 5.0.0

### Major Changes

- 9b95169: up version

### Patch Changes

- Updated dependencies [9b95169]
  - @or-sdk/library-prisma@5.0.0

## 4.4.0

### Minor Changes

- 8d378d3: use npm for publishing

### Patch Changes

- Updated dependencies [8d378d3]
  - @or-sdk/library-prisma@4.2.0

## 4.3.0

### Minor Changes

- 76f818d: try to release new version

### Patch Changes

- Updated dependencies [76f818d]
  - @or-sdk/library-prisma@4.1.0

## 4.2.0

### Minor Changes

- dd2f6ab: fix ci publish

## 4.1.0

### Minor Changes

- 9270760: fix ci stage

## 4.0.0

### Major Changes

- 2ee0ff9: feat: stable versions of types and api packages

### Patch Changes

- Updated dependencies [2ee0ff9]
  - @or-sdk/library-prisma@4.0.0

## 3.3.0

### Minor Changes

- 1da66f6: refactor or-sdk

## 3.2.2

### Patch Changes

- Updated dependencies [2bd1b42]
  - @or-sdk/library-prisma@3.3.0

## 3.2.1

### Patch Changes

- Updated dependencies [46ebbfe]
  - @or-sdk/library-prisma@3.2.0

## 3.2.0

### Minor Changes

- 123da22: feat: get packages includeDeprecated filter

## 3.1.1

### Patch Changes

- Updated dependencies [445bdcb]
  - @or-sdk/library-prisma@3.1.0

## 3.1.0

### Minor Changes

- 05a80fd: add filter id param

### Patch Changes

- 608e129: add features support for data hub service

## 3.0.0

### Major Changes

- bdb6787: use releases label, description, categories

### Minor Changes

- f5f3739: fix eslint config, move library-manager project
- bdb6787: more e2e cases, fix packges releases levels

### Patch Changes

- Updated dependencies [f5f3739]
- Updated dependencies [bdb6787]
- Updated dependencies [bdb6787]
  - @or-sdk/library-prisma@3.0.0

## 2.3.0

### Minor Changes

- 3d756a4: use sort ordering in right way, add playground tests

### Patch Changes

- Updated dependencies [3d756a4]
  - @or-sdk/library-prisma@2.3.0

## 2.2.0

### Minor Changes

- 5d8e3c6: better test covering

### Patch Changes

- Updated dependencies [5d8e3c6]
  - @or-sdk/library-prisma@2.2.0

## 2.1.0

### Minor Changes

- 710aa1a: add v2 api, servingType; remove packages on sources deletion

### Patch Changes

- Updated dependencies [710aa1a]
  - @or-sdk/library-prisma@2.1.0

## 2.0.0

### Major Changes

- 6e683c1: refactor packages schema and logic, use Package and PackageRelease tables

### Patch Changes

- Updated dependencies [6e683c1]
  - @or-sdk/library-prisma@2.0.0

## 1.6.1

### Patch Changes

- Updated dependencies [dfda4b9]
- Updated dependencies [dfda4b9]
  - @or-sdk/library-prisma@1.4.0

## 1.6.0

### Minor Changes

- 5d4c408: add package dependencies CRUD

## 1.5.1

### Patch Changes

- Updated dependencies [63c7c7e]
- Updated dependencies [63c7c7e]
  - @or-sdk/library-prisma@1.3.0

## 1.5.0

### Minor Changes

- 5972252: make migration in parallel

## 1.4.0

### Minor Changes

- aadc907: fix package migrations, fix extractor NPM_UNPACKED, remove status level for package DEPRECATED status

## 1.3.0

### Minor Changes

- 581058c: add system status endpoint, external steps sync, fix get packages params

## 1.2.0

### Minor Changes

- 7c174d7: try changeset ci
- 9e5b0c9: test

### Patch Changes

- Updated dependencies [7c174d7]
- Updated dependencies [9e5b0c9]
  - @or-sdk/library-prisma@1.2.0
