{"_id":"@calculator53295/cloud-proxy","name":"@calculator53295/cloud-proxy","dist-tags":{"latest":"0.3.1"},"versions":{"0.3.1":{"name":"@calculator53295/cloud-proxy","version":"0.3.1","description":"TypeScript client SDK for the Cloud Run proxy server","type":"module","main":"dist/index.js","types":"dist/index.d.ts","sideEffects":false,"exports":{".":{"types":"./dist/index.d.ts","import":"./dist/index.js"}},"publishConfig":{"access":"public"},"repository":{"type":"git","url":"git+https://github.com/Calculator5329/crs-package.git"},"homepage":"https://github.com/Calculator5329/crs-package#readme","bugs":{"url":"https://github.com/Calculator5329/crs-package/issues"},"scripts":{"build":"tsc","prepublishOnly":"npm run build","test":"vitest run --dir tests","test:e2e":"vitest run --dir tests/e2e","test:e2e:watch":"vitest --dir tests/e2e","test:all":"vitest run --dir tests","test:watch":"vitest --dir tests"},"devDependencies":{"tsx":"^4.21.0","typescript":"^5.9","vitest":"^4.0.18"},"engines":{"node":">=18.0.0"},"keywords":["cloud-run","sdk","typescript","firebase","firestore","gcs","openai","anthropic","gemini"],"license":"MIT","_id":"@calculator53295/cloud-proxy@0.3.1","_integrity":"sha512-0eiXaaWOyxQ6oRpNFgsbKhqJz4p1P0U5aYVbe7WGL2+QEpZykRdOW5MQkBUfxTgmzJ9pkB0OkC3XFEMPPuiNBQ==","_resolved":"/home/ethan/projects/web/crs-package/_release/npm/calculator53295-cloud-proxy-0.3.1.tgz","_from":"file:/home/ethan/projects/web/crs-package/_release/npm/calculator53295-cloud-proxy-0.3.1.tgz","_nodeVersion":"24.18.0","_npmVersion":"11.16.0","dist":{"integrity":"sha512-0eiXaaWOyxQ6oRpNFgsbKhqJz4p1P0U5aYVbe7WGL2+QEpZykRdOW5MQkBUfxTgmzJ9pkB0OkC3XFEMPPuiNBQ==","shasum":"dbc9af80a48a4f4da67dcc99b2aa83c7b4b0fc40","tarball":"https://registry.npmjs.org/@calculator53295/cloud-proxy/-/cloud-proxy-0.3.1.tgz","fileCount":50,"unpackedSize":103100,"signatures":[{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEUCIAQvuUz/TQXFsWO1JQhzqhlDezkw4HIKtYxoPmf048LPAiEApXFBwVC5xMRJB4VxGHrKW4Q+UxwyV+TnpWjW6Qzkerc="}]},"_npmUser":{"name":"calculator53295","email":"5329548871.eg@gmail.com"},"directories":{},"maintainers":[{"name":"calculator53295","email":"5329548871.eg@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/cloud-proxy_0.3.1_1783897243519_0.47184808808431566"},"_hasShrinkwrap":false}},"time":{"created":"2026-07-12T23:00:43.373Z","0.3.1":"2026-07-12T23:00:43.646Z","modified":"2026-07-12T23:00:43.846Z"},"maintainers":[{"name":"calculator53295","email":"5329548871.eg@gmail.com"}],"description":"TypeScript client SDK for the Cloud Run proxy server","homepage":"https://github.com/Calculator5329/crs-package#readme","keywords":["cloud-run","sdk","typescript","firebase","firestore","gcs","openai","anthropic","gemini"],"repository":{"type":"git","url":"git+https://github.com/Calculator5329/crs-package.git"},"bugs":{"url":"https://github.com/Calculator5329/crs-package/issues"},"license":"MIT","readme":"# @calculator53295/cloud-proxy\n\nTypeScript client SDK for the Cloud Run proxy server. Zero runtime dependencies, fully typed, ESM-only.\n\n## Install\n\n```bash\nnpm install @calculator53295/cloud-proxy\n```\n\n**Requirements:** Node 18+ (uses global `fetch`)\n\n## Quick Start\n\n```typescript\nimport { createClient } from \"@calculator53295/cloud-proxy\";\n\nconst proxy = createClient({\n  baseUrl: process.env.PROXY_URL!,\n  token: process.env.PROXY_TOKEN!,\n});\n\n// Health check\nconst { status } = await proxy.health();\n```\n\nSet two environment variables and you're done:\n\n```env\nPROXY_URL=https://your-service-xyz.run.app\nPROXY_TOKEN=your-static-bearer-token\n```\n\n## Modules\n\nEvery module is accessible as a property on the client object. Modules are lazily instantiated on first access.\n\n| Module | Accessor | Description |\n|--------|----------|-------------|\n| AI | `proxy.ai` | OpenAI, Anthropic, Gemini, OpenRouter passthrough |\n| Auth | `proxy.auth` | Firebase Auth user management |\n| Firestore | `proxy.firestore` | Firestore CRUD, queries, batch, aggregates |\n| Storage | `proxy.storage` | GCS upload, download, signed URLs, buckets |\n| Vectors | `proxy.vectors` | Vector search + Gemini embeddings |\n| Setup | `proxy.setup` | Provisioning + project bootstrap |\n| Agent | `proxy.agent` | Wikipedia lookup, Brave Search, event enrichment |\n\n---\n\n## AI\n\n```typescript\n// Direct provider passthrough\nconst response = await proxy.ai.openai(\"/v1/chat/completions\", {\n  model: \"gpt-4o\",\n  messages: [{ role: \"user\", content: \"Hello\" }],\n});\n\n// Convenience chat — normalized response across all providers\nconst reply = await proxy.ai.chat({\n  provider: \"anthropic\",\n  model: \"claude-sonnet-4-20250514\",\n  messages: [{ role: \"user\", content: \"Explain quantum computing\" }],\n  maxTokens: 1024,\n});\nconsole.log(reply.content);\n\n// Streaming\nconst stream = await proxy.ai.chatStream({\n  provider: \"openai\",\n  model: \"gpt-4o\",\n  messages: [{ role: \"user\", content: \"Write a poem\" }],\n});\nfor await (const chunk of stream) {\n  process.stdout.write(new TextDecoder().decode(chunk));\n}\n```\n\n## Auth\n\n```typescript\nconst user = await proxy.auth.createUser({\n  email: \"alice@example.com\",\n  password: \"securepassword\",\n  displayName: \"Alice\",\n});\n\nawait proxy.auth.setClaims(user.uid, { admin: true });\n\nconst users = await proxy.auth.listUsers({ limit: 50 });\n\n// Email links\nconst { link } = await proxy.auth.generatePasswordResetLink(\"alice@example.com\");\n\n// Session cookies\nconst { cookie } = await proxy.auth.createSessionCookie(idToken, 7 * 24 * 60 * 60 * 1000);\nconst decoded = await proxy.auth.verifySessionCookie(cookie, true);\n```\n\n`setClaims()` and `createSessionCookie()` now send the request shape expected by the proxy service.\n\n## Firestore\n\n```typescript\n// CRUD\nconst post = await proxy.firestore.create(\"posts\", { title: \"Hello\", body: \"World\" });\nconst doc = await proxy.firestore.get<{ title: string }>(\"posts/abc123\");\nawait proxy.firestore.update(\"posts/abc123\", { title: \"Updated\" });\nawait proxy.firestore.delete(\"posts/abc123\");\n\n// Query\nconst published = await proxy.firestore.query(\"posts\", {\n  filters: [{ field: \"status\", op: \"==\", value: \"published\" }],\n  orderBy: [{ field: \"createdAt\", direction: \"desc\" }],\n  limit: 50,\n});\n\n// Subcollections\nconst comments = await proxy.firestore.list(\"posts/abc123/comments\");\n// Or scoped:\nconst scoped = proxy.firestore.sub(\"posts/abc123\");\nawait scoped.list(\"comments\");\n\n// Atomic field operations\nimport { FieldOp } from \"@calculator53295/cloud-proxy\";\n\nawait proxy.firestore.patch(\"posts/abc123\", {\n  views: FieldOp.increment(1),\n  tags: FieldOp.arrayUnion(\"featured\"),\n});\n\n// Batch\nawait proxy.firestore.batch([\n  { type: \"create\", collection: \"posts\", data: { title: \"A\" } },\n  { type: \"delete\", collection: \"posts\", docId: \"old\" },\n]);\n\n// Aggregates\nconst stats = await proxy.firestore.aggregate(\"orders\", {\n  aggregations: [\n    { type: \"count\", alias: \"total\" },\n    { type: \"sum\", field: \"amount\", alias: \"revenue\" },\n  ],\n  filters: [{ field: \"status\", op: \"==\", value: \"completed\" }],\n});\n\n// Collection group queries\nconst allComments = await proxy.firestore.query(\"comments\", {\n  collectionGroup: true,\n  filters: [{ field: \"flagged\", op: \"==\", value: true }],\n});\n```\n\n## Storage\n\n```typescript\n// Direct upload\nconst result = await proxy.storage.upload(\"my-bucket\", file, {\n  path: \"avatars\",\n  public: true,\n});\n\n// Signed URL upload (large files)\nconst { uploadUrl } = await proxy.storage.getUploadUrl(\"my-bucket\", {\n  filename: \"video.mp4\",\n  contentType: \"video/mp4\",\n  expiresInMinutes: 30,\n});\n\n// Download\nconst { downloadUrl } = await proxy.storage.getDownloadUrl(\"my-bucket\", \"photo.jpg\", 120);\nconst response = await proxy.storage.download(\"my-bucket\", \"report.pdf\");\n\n// List & delete\nconst files = await proxy.storage.listFiles(\"my-bucket\", { prefix: \"avatars/\" });\nawait proxy.storage.deleteFile(\"my-bucket\", \"old-file.txt\");\n\n// Bucket management\nawait proxy.storage.createBucket({ name: \"new-bucket\", location: \"US\" });\nconst { buckets } = await proxy.storage.listBuckets();\n```\n\n## Vectors\n\n```typescript\n// Embed and store\nconst doc = await proxy.vectors.embed(\"articles\", \"Quantum computing uses qubits...\", {\n  data: { title: \"Intro to Quantum\", category: \"science\" },\n});\n\n// Batch embed\nawait proxy.vectors.embedBatch(\"articles\", [\n  { text: \"First article...\", data: { title: \"AI\" } },\n  { text: \"Second article...\", data: { title: \"ML\" } },\n]);\n\n// Semantic search\nconst hits = await proxy.vectors.semanticSearch(\"articles\", \"quantum physics basics\", {\n  topK: 5,\n  filters: [{ field: \"category\", op: \"==\", value: \"science\" }],\n});\n\n// Update & delete\nawait proxy.vectors.update(\"articles\", doc.id, { text: \"Updated content...\" });\nawait proxy.vectors.delete(\"articles\", doc.id);\n```\n\n`store()` now sends `{ data, embedding, docId? }`, matching the server contract.\n\n## Setup\n\n```typescript\n// Bootstrap an entire project\nconst status = await proxy.setup.bootstrapProject({\n  projectName: \"my-app\",\n  firestore: {\n    collections: [\n      { name: \"users\" },\n      { name: \"documents\", vectorIndex: true },\n    ],\n  },\n  storage: { bucketName: \"my-app-assets\", public: true },\n  auth: { enableEmailPassword: true },\n});\n\n// Check status\nconst current = await proxy.setup.getStatus();\n```\n\n## Error Handling\n\nAll errors are thrown as `ProxyError` with `code`, `status`, and `details`:\n\n```typescript\nimport { ProxyError } from \"@calculator53295/cloud-proxy\";\n\ntry {\n  await proxy.firestore.get(\"posts/nonexistent\");\n} catch (err) {\n  if (err instanceof ProxyError && err.code === \"FIRESTORE_NOT_FOUND\") {\n    // handle 404\n  }\n}\n```\n\n## License\n\nMIT\n","readmeFilename":"README.md","_rev":"1-04a98d74e0fb435f8f5b2bb021282e24"}