@choosemycompany/lib
v0.7.0
Published
Shared composables, stores and types for ChooseMyCompany front apps
Readme
@choosemycompany/lib
Composables, stores and types shared between the ChooseMyCompany front-end apps (commercial, workspace).
Installation
pnpm add @choosemycompany/libUsage
import { useHttp, useStore, type Store, type View } from '@choosemycompany/lib'A single entry point: everything is re-exported from @choosemycompany/lib.
Dependencies
The package expects to be consumed inside a Nuxt 4 project, with the following peer deps installed:
vue,vue-i18n,vue-router,piniamande(HTTP client)h3(foruseErrorHandling)@nuxtjs/i18n(useLocalePath)nuxt(foruseRuntimeConfig,useState,showError, imported fromnuxt/app)
Composables using useRuntimeConfig(), useRoute() or useI18n() must be called inside a Nuxt scope (setup, plugin, middleware).
Local development (HMR through the sandbox)
cd sandbox && pnpm install && pnpm devThen http://localhost:3000. The sandbox has its own package.json and its own lockfile: it is not part of a pnpm workspace, hence the cd.
The sandbox uses a Vite alias @choosemycompany/lib → ../src/index.ts, so every change to the lib's sources triggers immediate HMR. A mock API is served by Nitro: /api/philosophers for useHttp + useStore, and an authentication backend for the /auth page.
The /auth page
It reproduces a session that expires, against a mocked auth backend: POST /auth/api/v2/login, POST /auth/api/v2/login/token/refresh and POST /auth/api/v2/logout served at the origin like the real auth-api, a protected resource under /api/session/protected, and POST /api/session/simulate to age the session without waiting 4 h.
The scenario: sign in, call the protected API, expire the token, call again. The network trace shows what the lib does — or does not do — between the app's call and the response.
Build & publish
pnpm build # vite build → dist/
pnpm typecheck
pnpm test
pnpm publish # through CircleCI on a push to mainNotable API changes
useStore: unified signature absorbing theworkspacevariant (search, filters, a fourthFilterItemgeneric). Public method:isPending(key).getViewKeysorts keys to guarantee a deterministic cache.usePrimaryTypeTranslation(primaryTypes): now receives the list of primary types as an argument instead of importing it from commercial's@/entities/form.
