extension-to-functions-codebase

द्वारा firebase

एक स्थापित Firebase एक्सटेंशन (या एक्सटेंशन स्रोत) को स्टैंडअलोन Cloud Functions for Firebase कोडबेस या प्रकाशन योग्य npm पैकेज में परिवर्तित करने के लिए स्किल,…

npx skills add https://github.com/firebase/agent-skills --skill extension-to-functions-codebase

Extension to Functions Codebase & npm Package Migration

Overview

Migrates a Firebase Extension into either:

  1. A local Cloud Functions codebase (functions/src/ for app integration).
  2. A publishable npm package (reusable open-source package exporting V2 functions).

Leverages native Cloud Functions features (declarative IAM, Parameterized Config, SDK Lifecycle Hooks) and modernizes 1st Gen triggers to 2nd Gen using the Destructuring Compatibility Shim.


Target Migration Workflows

  • Target A: Local Functions Codebase (End-User App Integration)

    • Output: Code under functions/src/. Config in .env.
    • Deployment: firebase deploy --only functions.
  • Target B: Publishable npm Package / Shareable Package

    • Output: Reusable npm package exporting V2 functions.
    • Configuration: package.json specifying exports map, engines: { "node": ">=22" }, and peerDependencies: { "firebase-functions": ">=6.0.0" }.
    • Usage: Consumers install package and re-export functions in index.ts (export * from "<package-name>").

Core Rules & Constraints

1. Declarative IAM & APIs (Zero-Local-Overhead)

Use native SDK declarations instead of manual gcloud scripts or console instructions:

  • Use requiresRole("roles/...") for required GCP IAM permissions.
  • Use requiresAPI("service.googleapis.com", "Description") for Google APIs.

2. Global Parameter Access Restriction

  • Never call .value() at top-level module load scope.
  • Initialize global SDK instances inside onInit() or lazy getters:
    import { defineString } from "firebase-functions/params";
    import { onInit } from "firebase-functions/v2";
    
    const dataset = defineString("DATASET_ID");
    let client: BigQuery;
    
    onInit(() => {
      client = new BigQuery({ datasetId: dataset.value() });
    });
    

3. V2 Concurrency & Cost Parity

V2 enables concurrency (up to 80 requests). To preserve V1 single-concurrency pricing, set cpu: "gcf_gen1".


Step-by-Step Migration Execution

Step 1: Inventory Extension Resources

  1. extension.yaml:
    • paramsdefineString, defineInt, defineBoolean, defineSecret.
    • apisrequiresAPI(...).
    • rolesrequiresRole(...).
    • lifecycleEventsafterFirstDeploy & afterRedeploy.
    • resources → Upgrade 1st Gen triggers to 2nd Gen (onDocumentWritten, onTaskDispatched, onRequest).
  2. Files & Scripts: Preserve devDependencies, test framework (jest), and test scripts.

Step 2: Configure package.json

  • Set name: "<package-name>", engines: { "node": ">=22" }.
  • Set peerDependencies:
    "peerDependencies": {
      "firebase-admin": "^11.0.0 || ^12.0.0",
      "firebase-functions": ">=6.0.0"
    }
    
  • Configure exports map targeting ESM/CommonJS and TypeScript declarations (lib/index.js, lib/index.d.ts).

Step 3: Upgrade Triggers from V1 to V2

  • Firestore: Use onDocumentWritten from firebase-functions/v2/firestore.
  • Tasks: Use onTaskDispatched from firebase-functions/v2/tasks. Remove EXT_INSTANCE_ID when enqueueing tasks.
  • HTTP: Use onRequest from firebase-functions/v2/https.
  • Apply Destructuring Compatibility Shim ({ change, context }, { snapshot, context }) where legacy 1st Gen handlers expect (change, context).

Step 4: Convert Lifecycle Events

Map extension lifecycle events to SDK lifecycle hooks in src/index.ts:

  • onInstallafterFirstDeploy({ task: { function: "initTask" } })
  • onUpdate / onConfigureafterRedeploy({ task: { function: "setupTask" } })

Step 5: Package README & Export Instructions

Generate README.md containing:

  1. Installation instructions (npm install).
  2. Re-export snippet (export * from "<package-name>").
  3. Parameterized Configuration .env reference table.
  4. What Changed (Extension vs Package) comparison table.

Reminder: NEVER execute npm publish.

firebase की और Skills

developing-genkit-dart
firebase
We need to translate the given English text to Hindi. The text describes a unified AI SDK for Dart. We must preserve product names, protocol names, URLs, numbers, technical terms. The name "developing-genkit-dart" is not in the text, so we don't include it. We translate only the text inside <text>. No extra commentary, labels, etc. Let's break down the text: "Unified AI SDK for Dart enabling code generation, structured outputs, tools, flows, and agents. Provides core APIs for generation, tool definition, flow orchestration, embeddings, and streaming with a single interface Includes 8+ plugins for LLM providers (Google Gemini, Anthropic Claude, OpenAI GPT), Firebase AI, Model Context Protocol, Chrome browser integration, and HTTP server hosting via Shelf Built-in CLI with local development UI for flow execution, tracing, model experimentation, and..." We need to translate into Hindi. Keep technical terms like SDK, APIs, plugins, LLM, Google Gemini, Anthropic Claude, OpenAI GPT, Firebase AI, Model Context Protocol, Chrome,
official
developing-genkit-js
firebase
Genkit फ्लो, टूल और मल्टी-मॉडल सपोर्ट के साथ AI-संचालित Node.js/TypeScript एप्लिकेशन बनाएं। Genkit प्रदाता-अज्ञेयवादी है; प्लगइन के माध्यम से Google AI, OpenAI, Anthropic, Ollama और अन्य LLM प्रदाताओं को सपोर्ट करता है। Zod का उपयोग करके टाइप-सेफ स्कीमा के साथ फ्लो परिभाषित करें, जनरेशन अनुरोध निष्पादित करें और TypeScript में मल्टी-स्टेप AI वर्कफ़्लो बनाएं। Genkit CLI v1.29.0+ आवश्यक है; हाल के प्रमुख API परिवर्तनों के कारण
official
firebase-ai-logic
firebase
वेब ऐप्स के लिए क्लाइंट-साइड जेमिनी एकीकरण, जिसमें मल्टीमॉडल अनुमान, स्ट्रीमिंग और ऑन-डिवाइस हाइब्रिड निष्पादन शामिल है। केवल-टेक्स्ट और मल्टीमॉडल इनपुट (चित्र, ऑडियो, वीडियो, PDF) का समर्थन करता है; 20 MB से अधिक की फ़ाइलें क्लाउड स्टोरेज के माध्यम से रूट होती हैं। इसमें स्वचालित इतिहास वाले चैट सत्र, रीयल-टाइम प्रदर्शन के लिए स्ट्रीमिंग प्रतिक्रियाएँ और सं
official
firebase-ai-logic-basics
firebase
फायरबेस AI लॉजिक (Gemini API) को वेब एप्लिकेशन में एकीकृत करने के लिए आधिकारिक कौशल। सेटअप, मल्टीमॉडल इन्फ्रेंस, संरचित आउटपुट और सुरक्षा को शामिल करता है।
official
firebase-app-hosting-basics
firebase
Firebase App Hosting के साथ Next.js, Angular और अन्य समर्थित फ्रेमवर्क का उपयोग करके फुल-स्टैक वेब ऐप्स को डिप्लॉय और प्रबंधित करें। Blaze मूल्य योजना पर Firebase प्रोजेक्ट आवश्यक है; सर्वर-साइड रेंडरिंग (SSR) और इंक्रीमेंटल स्टैटिक रीजनरेशन (ISR) वर्कफ़्लो का समर्थन करता है। बैकएंड सेटअप के लिए वैकल्पिक apphosting.yaml के साथ firebase.json कॉन्फ़िगरेशन के माध्यम से डिप्लॉय करें, या GitHub एकीकरण के माध्यम से स्वचालित "git push to deploy
official
firebase-auth-basics
firebase
Firebase Authentication को कई पहचान प्रदाताओं और सुरक्षित डेटा एक्सेस नियमों के साथ सेट अप करें। ईमेल/पासवर्ड, फ़ोन नंबर, अनाम, फ़ेडरेटेड प्रदाताओं (Google, Facebook, Twitter, GitHub, Microsoft, Apple) और कस्टम ऑथ इंटीग्रेशन का समर्थन करता है। प्रत्येक प्रमाणित उपयोगकर्ता को Firebase सेवाओं तक पहुँचने के लिए एक अद्वितीय ID और JWT-आधारित टोकन (अल्पकालिक ID टोकन और दीर्घकालिक रिफ्रेश टोकन) प्राप्त होते हैं। Google Sign In, अनाम और ईमेल
official
firebase-basics
firebase
Firebase प्रोजेक्ट सेटअप और AI एजेंट एकीकरण के लिए CLI वर्कफ़्लो। firebase-local-env-setup स्किल और Firebase CLI इंस्टॉलेशन का पूर्व समापन आवश्यक है। मुख्य वर्कफ़्लो में firebase login के माध्यम से प्रमाणीकरण, अद्वितीय आईडी के साथ प्रोजेक्ट निर्माण, और इंटरैक्टिव firebase init कमांड के माध्यम से सेवा आरंभीकरण शामिल है। सेटअप के दौरान फीचर चयन का समर्थन करता है जिसमें Firestore, Functions, और Hosting शामिल हैं, जिसमें स्वचालित कॉन्फ़िगरेशन फ़
official
firebase-crashlytics
firebase
Firebase Crashlytics के लिए व्यापक मार्गदर्शिका, जिसमें प्रोविज़निंग और SDK उपयोग शामिल है। इस कौशल का उपयोग तब करें जब उपयोगकर्ता को Crashlytics सेट अप करने, जोड़ने में सहायता की आवश्यकता हो...
official