নিম্নে বান্ডেল বিল্ডার এপিআই-এর স্পেসিফিকেশনের একটি সংক্ষিপ্ত বিবরণ দেওয়া হলো, যার মধ্যে টাইপস্ক্রিপ্ট ডেফিনিশন ও বিস্তারিত বর্ণনা অন্তর্ভুক্ত রয়েছে।
বান্ডেলডকুমেন্ট ইন্টারফেস
কনফিগার করা সংগ্রহের মধ্যে একটি একক নথির স্পেসিফিকেশন:
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;
};
উদাহরণস্বরূপ, ` products কালেকশনের উপর `where` এবং `limit` শর্ত ব্যবহার করে 'products' নামের একটি কোয়েরি তৈরি করতে হলে, ডেটা স্ট্রাকচারের আউটপুটটি নিম্নলিখিতের সাথে মিলতে হবে:
queries: {
products: {
collection: 'products',
conditions: [
{ where: ['type', '==', 'featured'] },
{ limit: 10 },
],
}
}
` in , not-in , বা array-contains-any ফিল্টারে অ্যারের ভ্যালু দেওয়ার সময়, আপনাকে অবশ্যই ভ্যালু হিসেবে কমা দিয়ে আলাদা করা একটি ভ্যালু দিতে হবে, কারণ ফায়ারস্টোরে নেস্টেড অ্যারে ভ্যালু সমর্থিত নয়। উদাহরণস্বরূপ:
{ 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'] },