@unaffi/schema
v1.1.8
Published
This reflects what the API returns, and not what the DB Schema looks like in MongoDB. Can be imported into any repo and be used by both TS and JS (JSDocs) code.
Readme
UNAFFI Schema
This reflects what the API returns, not what the DB Schema looks like in MongoDB.
Can be imported into any repo and be used by both TS and JS (JSDocs) code.
Installation
npm i --save-dev @unaffi/schemaUsage
Example:
/** @type {import('@unaffi/schema').Profile} */
const profile = await getProfile();
/** @type {import('@unaffi/schema').Profile[]} */
const dependants = await getDependants();or define it at the top of the page to use the type throughout the file:
/** @typedef {import('@unaffi/schema').Profile} Profile */
/** @type {Profile} */
const profile = await getProfile();
/** @type {Profile[]} */
const dependants = await getDependants();or define it in a types/index.js file (where the file directory, types, is a peer directory or the peer of a parent directory of the file you will be using it).
/** @typedef {import('@unaffi/schema').Profile} Profile */and then in the svelte file you need it:
/** @type {Profile} */
const profile = await getProfile();
/** @type {Profile[]} */
const dependants = await getDependants();NOTE: This 3rd option only works in Svelte Projects – I believe in vite projects.
Updating the Schema
- Bump the version in the
package.json:
{
// …existing code…
"version": "1.0.0" // to "1.0.1" | Always update 3rd number, unless it is a large update (such as an extra collection added). Never update 1st number unless we restart unaffi's schema entirely.
// …existing code…
}Create authentication token (one-time setup):
- Go to https://www.npmjs.com/settings/YOUR_USERNAME/tokens
- Click "Generate New Token" → Select "Granular Access Token"
- Give it a name (e.g., "publish-token")
- Under Packages and scopes:
- Permissions: Select Read and write
- Packages: Select the
@unaffi/schemapackage (or "All packages")
- Important: Check the "Bypass 2FA" option
- Click "Generate Token" and copy the token
Create a
.npmrcfile in the project root with://registry.npmjs.org/:_authToken=YOUR_TOKEN_HEREReplace
YOUR_TOKEN_HEREwith the token you just copied.Security Note: Do not commit the
.npmrcfile content. It is in the.gitignorefile.Update Github:
git add .
git commit -m "Your commit message"
git push- Update npm:
npm login
npm publish --access public