{"_id":"@appbank_packages/appbank-shared-copy","name":"@appbank_packages/appbank-shared-copy","dist-tags":{"latest":"1.0.0"},"versions":{"1.0.0":{"name":"@appbank_packages/appbank-shared-copy","version":"1.0.0","main":"dist/index.js","types":"dist/index.d.ts","scripts":{"build":"tsc","prepare":"npm run build"},"exports":{".":{"types":"./dist/index.d.ts","import":"./dist/index.js","default":"./dist/index.js"},"./errors":{"types":"./dist/errors.d.ts","default":"./dist/errors.js"},"./auth":{"types":"./dist/auth.d.ts","default":"./dist/auth.js"},"./regulatory":{"types":"./dist/regulatory.d.ts","default":"./dist/regulatory.js"},"./kyc":{"types":"./dist/kyc.d.ts","default":"./dist/kyc.js"},"./formatting":{"types":"./dist/formatting.d.ts","default":"./dist/formatting.js"}},"devDependencies":{"typescript":"^5.0.0"},"_id":"@appbank_packages/appbank-shared-copy@1.0.0","description":"Single source of truth for user-facing copy and FCA-compliant error messages used by **appbank-customer-portal-web** (React) and **appbank-mobile-app** (React Native).","_nodeVersion":"24.6.0","_npmVersion":"11.5.1","dist":{"integrity":"sha512-Z0vh5/ZBWVeB4fL80Bp8emHg7dWtlaBLyy76UvcivSuX/pDNXgGPNECI0wRYQzFH1paugfipvEzzFZID1C8itg==","shasum":"367ed7e69576039a24402de4e00436f1cbe8611c","tarball":"https://registry.npmjs.org/@appbank_packages/appbank-shared-copy/-/appbank-shared-copy-1.0.0.tgz","fileCount":20,"unpackedSize":20007,"signatures":[{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEUCIE2/VGfiz+THw18jChCYKGORLDJHHx2EAyZhJKxZq0jVAiEAkfz3MBTK0frmm/gctHPLoRkm+5U0fsU4gkpOHatxLJY="}]},"_npmUser":{"name":"appbank_packages","email":"utsav@appbank.org"},"directories":{},"maintainers":[{"name":"appbank_packages","email":"utsav@appbank.org"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/appbank-shared-copy_1.0.0_1771846604160_0.34953348819748964"},"_hasShrinkwrap":false}},"time":{"created":"2026-02-23T11:36:44.069Z","1.0.0":"2026-02-23T11:36:44.296Z","modified":"2026-02-23T11:36:44.492Z"},"maintainers":[{"name":"appbank_packages","email":"utsav@appbank.org"}],"description":"Single source of truth for user-facing copy and FCA-compliant error messages used by **appbank-customer-portal-web** (React) and **appbank-mobile-app** (React Native).","readme":"# appbank-shared-copy\n\nSingle source of truth for user-facing copy and FCA-compliant error messages used by **appbank-customer-portal-web** (React) and **appbank-mobile-app** (React Native).\n\n## Build\n\nThe package **must be built** before consumption so both React and React Native get plain JavaScript (no TypeScript in `node_modules`):\n\n```bash\nnpm install\nnpm run build\n```\n\nThis writes `dist/` (JS + `.d.ts`). The `prepare` script runs `build` after `npm install`, so local installs get a built package.\n\n## How to use it in production\n\n### Option A: Same repo (recommended for one codebase)\n\nKeep all three projects in one repo:\n\n- `frontend/appbank-shared-copy`\n- `frontend/appbank-customer-portal-web`\n- `frontend/appbank-mobile-app`\n\n**Dependency:** In both apps’ `package.json`:\n\n```json\n\"appbank-shared-copy\": \"file:../appbank-shared-copy\"\n```\n\n**CI/CD (important):** Build the shared package first, then build each app:\n\n```bash\n# 1. Build shared copy (produces dist/)\ncd frontend/appbank-shared-copy && npm ci && npm run build && cd ../..\n\n# 2. Install and build web\ncd frontend/appbank-customer-portal-web && npm ci && npm run build\n\n# 3. Install and build mobile\ncd frontend/appbank-mobile-app && npm ci && npm run build\n```\n\nCommit the `dist/` folder of `appbank-shared-copy` so that `file:../appbank-shared-copy` always has built output when someone clones and runs `npm install` in web or mobile. Alternatively, in CI do not commit `dist/` and always run `npm run build` in `appbank-shared-copy` before building web/mobile (as above).\n\n**Recommendation:** Add a root or frontend script, e.g.:\n\n```bash\n# scripts/build-all.sh or package.json \"build:all\"\n(cd appbank-shared-copy && npm run build) && (cd appbank-customer-portal-web && npm run build)\n(cd appbank-shared-copy && npm run build) && (cd appbank-mobile-app && npm run build)\n```\n\n### Option B: Private npm (or GitHub Packages)\n\nUseful if web and mobile are in different repos or you want versioned releases.\n\n1. **Build and publish** (from this package):\n\n   ```bash\n   cd appbank-shared-copy\n   npm run build\n   npm publish --access restricted\n   ```\n\n   Or point `publishConfig` to your registry (e.g. GitHub Packages) and run `npm publish`.\n\n2. **Consume in web and mobile:**\n\n   ```json\n   \"appbank-shared-copy\": \"^1.0.0\"\n   ```\n\n3. In CI, install as usual; no need to build the shared package in the app’s job.\n\n### Option C: Git dependency\n\nIf you move this package to its own repo:\n\n```json\n\"appbank-shared-copy\": \"git+https://github.com/your-org/appbank-shared-copy.git#v1.0.0\"\n```\n\nPublish **built** output (commit `dist/` or run `npm run build` in that repo and publish). Otherwise the consuming app would need to build it; npm install from git usually does not run `prepare` in a way that guarantees a built package for React Native.\n\n## Why build to `dist/`?\n\n- **React (Vite):** Can consume either TS or JS from `node_modules`. Using built JS is simpler and consistent.\n- **React Native (Metro):** By default Metro does not compile TypeScript inside symlinked or local `node_modules` packages. If the package only exposed `.ts` sources, you’d need extra Metro config (`watchFolders`, etc.). Shipping **pre-built JS** in `dist/` avoids that and works the same in dev and production.\n\n## Checklist so production builds don’t break\n\n1. **Always build shared-copy before building web or mobile** (either in CI or by committing `dist/`).\n2. **Do not** rely on raw TypeScript entry points in production: `package.json` `main` and `exports` point to `dist/*.js`.\n3. **Web:** No extra config needed; Vite resolves `dist/index.js`.\n4. **Mobile:** No Metro `watchFolders` needed when using built `dist/`; `file:../appbank-shared-copy` or a published tarball both work.\n\n## Exports\n\n- `appbank-shared-copy` — errors, auth, regulatory, kyc, formatting\n- `appbank-shared-copy/errors` — error catalogue only\n- `appbank-shared-copy/auth` — auth copy\n- `appbank-shared-copy/regulatory` — FCA/FSCS copy\n- `appbank-shared-copy/kyc` — KYC copy\n- `appbank-shared-copy/formatting` — formatDate, formatCurrency, etc.\n","readmeFilename":"README.md","_rev":"1-f9b6de40bb019018323f4bc2c00d87bd"}