API রেফারেন্স

নিচে বান্ডেল বিল্ডার API-এর স্পেসিফিকেশনের একটি সারসংক্ষেপ দেওয়া হল, যার মধ্যে টাইপস্ক্রিপ্ট সংজ্ঞা এবং বিস্তারিত বিবরণ অন্তর্ভুক্ত রয়েছে।

বান্ডেল ডকুমেন্ট ইন্টারফেস

কনফিগার করা সংগ্রহের মধ্যে একটি একক নথির জন্য স্পেসিফিকেশন:

type BundleDocument = {
  // A list of document IDs to serve in the bundle.
  docs?: Array<string>;
  // A map containing individual named queries and their definitions.
  queries?: Map<string, QueryDefinition[]>;
  // A map of parameters and their definitions, which can be provided to a query definition.
  params?: Map<string, ParamDefinition>;
  // Specifies how long to keep the bundle in the client's cache, in seconds. If not defined, client-side cache is disabled.
  clientCache?: string;
  // Only used in combination with Firebase Hosting. Specifies how long to keep the bundle in Firebase Hosting CDN cache, in seconds.
  serverCache: string;
  // Specifies how long (in seconds) to keep the bundle in a Cloud Storage bucket, in seconds. If not defined, Cloud Storage bucket is not accessed.
  fileCache?: string;
  // If a 'File Cache' is specified, bundles created before this timestamp will not be file cached.
  notBefore?: Timestamp;
};

প্যারামডেফিনিশন ইন্টারফেস

একটি BundleDocument এ সংজ্ঞায়িত একটি একক প্যারামিটারের স্পেসিফিকেশন।

type ParamDefinition = {
  // Whether this parameter is required. If not provided as a query string, an error will be thrown.
  required: boolean;
  // The type of value which will be parsed, defaults to 'string'.
  type?:
    | "string"
    | "integer"
    | "float"
    | "boolean"
    | "string-array"
    | "integer-array"
    | "float-array";
};

উদাহরণস্বরূপ, নিম্নলিখিত প্যারামিটারটি দেওয়া হয়েছে:

params: {
  name: {
    required: true,
    type: 'string',
  }
}

বান্ডেল HTTP এন্ডপয়েন্টে অনুরোধ করার সময়, প্যারামিটারটি একটি কোয়েরি প্যারামিটারের মাধ্যমে প্রদান করা যেতে পারে, যেমন ?name=david । প্যারামিটারটি QueryDefinition (নীচে দেখুন) মানের ( $name ) মধ্যে ব্যবহার করে গতিশীলভাবে বান্ডেল তৈরি করা যেতে পারে।

কোয়েরিডেফিনিশন ইন্টারফেস

বান্ডেলে নামযুক্ত কোয়েরি তৈরি করতে একটি কোয়েরি সংজ্ঞা ব্যবহার করা হয়। queries ম্যাপের মধ্যে প্রতিটি অবজেক্ট একটি নতুন নামযুক্ত কোয়েরি তৈরি করবে, যার নাম অবজেক্ট কী ব্যবহার করবে। প্রতিটি কোয়েরিতে একটি সংগ্রহ এবং ঐচ্ছিকভাবে সম্পাদনের জন্য কোয়েরি শর্তগুলির একটি তালিকা নির্দিষ্ট করতে হবে।

type QueryDefinition = {
  // The collection to perform the query on.
  collection: string;
  // An optional list of conditions to perform on the specified collection.
  conditions?: QueryCondition[];
};

conditions প্যারামিটারে QueryCondition ইন্টারফেসের একটি অ্যারে থাকতে পারে। অ্যারের প্রতিটি আইটেমে কেবল একটি শর্ত অন্তর্ভুক্ত থাকতে হবে।

type QueryCondition = {
  // Performs a `where` filter on the collection on a given FieldPath, operator and value.
  where?: [
    string,
    (
      | "<"
      | "<="
      | "=="
      | ">="
      | ">"
      | "!="
      | "array-contains"
      | "in"
      | "not-in"
      | "array-contains-any"
    ),
    any
  ];
  orderBy?: [string, ("asc" | "desc")?];
  limit?: number;
  limitToLast?: number;
  offset?: number;
  startAt?: string;
  startAfter?: string;
  endAt?: string;
  endBefore?: string;
};

উদাহরণস্বরূপ, where এবং limit শর্ত সহ একটি products সংগ্রহে "products" নামে একটি কোয়েরি তৈরি করতে, ডেটা স্ট্রাকচার আউটপুটটি নিম্নলিখিতগুলির সাথে মিলিত হওয়া উচিত:

queries: {
  products: {
    collection: 'products',
    conditions: [
      { where: ['type', '==', 'featured'] },
      { limit: 10 },
    ],
  }
}

in , not-in , অথবা array-contains-any ফিল্টারগুলিতে অ্যারে মান প্রদান করার সময়, আপনাকে অবশ্যই একটি কমা দ্বারা পৃথক মান প্রদান করতে হবে কারণ নেস্টেড অ্যারে মানগুলি Firestore-এ সমর্থিত নয়। উদাহরণস্বরূপ:

{ where: ['category', 'in', 'womens,shorts'] }, // ['womens', 'shorts']

যেকোনো সংখ্যার মানকে একটি সংখ্যা হিসেবে পার্স করা হবে, তবে যদি একটি স্ট্রিং সংখ্যার মান প্রয়োজন হয় তবে এটি বন্ধনীতে মোড়ানো উচিত:

{ where: ['price', 'in', '1,2.5'] }, // [1, 2.5]
{ where: ['price', 'in', '"1","2.5"'] }, // ['1', '2.5']

প্যারামিটারের পাশাপাশি শর্তাবলীও ব্যবহার করা যেতে পারে। উদাহরণস্বরূপ, যদি একটি প্যারামিটার type সংজ্ঞায়িত করা হয় (উপরে দেখুন), তাহলে এটি $ সিনট্যাক্সের মাধ্যমে গতিশীল ডেটা বান্ডেল প্রদানের জন্য একটি শর্ত মানের সাথে সরবরাহ করা যেতে পারে:

// ?type=featured


    conditions: [
      { where: ['type', '==', '$type'] },