# Changelog

## 3.2.6-2

detectPackagedFood is deprecated now

```typescript
  /**
   * @deprecated This is no longer supported.
   * Detect packaged food labels using OCR. Results will be returned
   * as OCRCandidates in the `FoodCandidates` property of `FoodDetectionEvent`
   * By default, this is set to false.
   */
  detectPackagedFood?: boolean
```

## 3.2.6-1

**New API**

```typescript
  /**
   * This method groups a list of `PassioFoodItem
   * @param text - Text for recognizing food logging actions
   * @returns A `Promise` resolving to an array of `PassioRecognitionResult`.
   */
  recognizeSpeechRemoteWithGrouping(
    text: string
  ): Promise<PassioRecognitionResult | null>

  /**
   * This method groups a list of `PassioFoodItem` ,
   * Smaller resolutions will result in faster response times
   * while higher resolutions should provide more accurate results
   * @param imageUri - The local URI of the image.
   * @param message - An optional message to indicate the context of the image.
   * @param resolution - enables the caller to set the target resolution of the image uploaded to the server, Default is RES_512
   * @returns A `Promise` resolving to an array of `PassioRecognitionResult`.
   */

  recognizeImageRemoteWithGrouping(
    imageUri: string,
    message?: string,
    resolution?: PassioImageResolution
  ): Promise<PassioRecognitionResult | null>

```

## **3.2.6**

**New API:**

```typescript
/**
   * Use this method to generate a meal plan.
   * @param request - Pass a string to generate a meal plan
   * @returns It returns `PassioGeneratedMealPlanResult` that can be either an `errorMessage` or the `boolean` noting the success of the operation.
   */
  generateMealPlan(request: string): Promise<PassioGeneratedMealPlanResult>
```

```typescript
  /**
   * Use this method to generate a meal plan preview.
   * @param request - Pass a string to generate a meal plan
   * @returns It returns `PassioGeneratedMealPlanResult` that can be either an `errorMessage` or the `boolean` noting the success of the operation.
   */
  generateMealPlanPreview(
    request: string
  ): Promise<PassioGeneratedMealPlanResult>
```

## 3.2.5-2

The new version `3.2.5-2` released with resolves the Android build issue with **React Native 0.77** with Expo 52 when the **new architecture is enabled**. Only one patch needs to be applied externally.

{% file src="https://872966647-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FES2kGechp4srgCTrBTxs%2Fuploads%2FzmXPnziPxQGQNEOwNbLT%2F%40passiolife%2Bnutritionai-react-native-sdk-v3%2B3.2.5-2.patch?alt=media&token=19513143-e6e5-410b-8408-e9a7b5248410" %}

## 3.2.5-1

#### Added APIs

* Added a new function `fetchUltraProcessingFoodRating` that provides the ultra-processing food rating for a given food item:

```typescript
  fetchUltraProcessingFoodRating(
    passioFoodItem: PassioFoodItem
  ): Promise<PassioUPFRatingResult>


export type PassioUPFRatingError = {
  status: 'Error'
  message: string
}

export type PassioUPFRatingSuccess = {
  status: 'Success'
  response: PassioUPFRating
}

export type PassioUPFRatingResult =
  | PassioUPFRatingError
  | PassioUPFRatingSuccess

export interface PassioUPFRating {
  highlightedIngredients: string[]
  rating?: number
  chainOfThought: string
}

```

* Added field concerns to the `PassioFoodMetadata` object

```dart
concerns?: number[] | null
```

#### Deprecated APIs

* Deprecated the following local recognition functions, which will be removed in a future release. Use `recognizeImageRemote` instead:
  * `startFoodDetection`
  * `stopFoodDetection`
  * `startNutritionFactsDetection`
  * `stopNutritionFactsDetection`

#### Removed APIs

* Removed volume detection related functionality from the SDK.

## 3.2.4

**Added APIs**

* Added two new parameters to the PassioConfiguration object: proxyUrl and proxyHeaders. If supplied, the SDK will use the proxyUrl value as a base url when executing networking calls, and will append the provided proxyHeaders to the request itself. When proxyUrl is provided, the SDK operates in remoteOnly state.

**Removed APIs**

* Removed function detectFoodIn. Instead, recognizeImageRemote should be used

## 3.2.3

#### Added APIs

* Added a new search function that provides contextually connected items to the search term:

```typescript
  /**
   * Search for food semantic will return a list of alternate search and search result
   * @param searchQuery - User typed text.
   * @returns A `Promise` resolving to an array of food item result.
   */
  searchForFoodSemantic(searchQuery: string): Promise<PassioSearchResult | null>

```

* Added a new api for a recipe builder feature, that gives a list of predicted next ingredients based on the current list of ingredients in the recipe:

```typescript
  /**
   * gives a list of predicted next ingredients based on the current list of ingredients in the recipe
   * @param currentIngredients - List of food ingredients name.
   * @returns A `Promise` resolving to an array of food data info.
   */
  predictNextIngredients(
    currentIngredients: string[]
  ): Promise<PassioFoodDataInfo[] | null>

```

## 3.2.1-1

**Refactor API**

```js
  /**
   * This method fetches tags for a given refCode.
   * @param refCode - The refCode for the tags query.
   * @returns A `string` array of tags if the record exists in the database or `null` if not.
   */
  fetchTagsFor(refCode: RefCode): Promise<string[]>
```

```js
  /**
   * fetch a map of nutrients for a 100 grams of a specific food item
   * @param refCode - The refCode for the attributes query.
   * @returns A `Promise` resolving to a `PassioNutrient` object if the record exists in the database or `null` if not.
   */
  fetchNutrientsFor(refCode: RefCode): Promise<PassioNutrient[] | null>
```

## 3.2.1

## Breaking Change ⚠️

### Android:

It's no longer necessary to mention the Passio AAR path in the **`build.gradle`** file.&#x20;

NOTE: If you don't remove it, you'll get the compile issues.

## Refactor API / Breaking Change

removed **weighGram** and now have **servingQuantity** and **servingUnit** in place

```typescript
 /**
   * Data info of the food with a given result.
   * @param passioFoodDataInfo - Provide `PassioFoodDataInfo` object get `PassioFoodItem` detail.
   * @param servingQuantity - Provide `servingQuantity` number to get `PassioFoodItem` detail.
   * @param servingUnit - Provide `servingUnit` unit to get `PassioFoodItem` detail.
   * @returns A `Promise` resolving to `PassioFoodItem` detail.
   */
  fetchFoodItemForDataInfo(
    passioFoodDataInfo: PassioFoodDataInfo,
    servingQuantity?: number,
    servingUnit?: String
  ): Promise<PassioFoodItem | null>
```

## New APIs:

**`reportFoodItem`** use this API to report incorrect food item.&#x20;

```typescript
/**
   * Use this method to report incorrect food item
   * Precondition: Either `refCode` or `productCode` must be present
   * @param refCode - Reference code of food item
   * @param productCode - Product code
   * @param notes - Note if any (optional)
   * @returns It returns `PassioResult` that can be either an `errorMessage` or the `boolean` noting the success of the operation.
   */
  reportFoodItem(report: PassioReport): Promise<PassioResult>

```

**`submitUserCreatedFood` u**se API method to submit User Created Food

```typescript
  /**
   * Use this method to submit User Created Food. The method will return `true` if the uploading of user food is successful
   * @param passioFoodItem - Pass ``PassioFoodItem`` to submit it to Passio
   * @returns It returns `PassioResult` that can be either an `errorMessage` or the `boolean` noting the success of the operation.
   */
  submitUserCreatedFood(passioFoodItem: PassioFoodItem): Promise<PassioResult>

```

##



## 3.2.0-1

#### -  Fixed `fetchIngredients` API crashed issue.&#x20;

## 3.2.0

### Added APIs

* Added function `recognizeNutritionFactsRemote` that can parse the nutrition facts table from an image and return a PassioFoodItem with the scanned nutrients
* Added support for localized content. Using `fun updateLanguage(languageCode: String): Boolean` with a two digit ISO 639-1 language code will transform the food names and serving sizes in the SDK responses.
* Added `remoteOnly` flag to the `PassioConfiguration` class. With this flag enabled, the SDK won't download the files needed for local recognition. In this case only remote recognition is possible.

### Refactored APIs

* `recognizeImageRemote` can now scan barcodes and nutrition facts. The `PassioAdvisorFoodInfo` class has been augmented to handle these responses

```typescript
export interface PassioAdvisorFoodInfo {
 ...,
  packagedFoodItem?: PassioFoodItem
  resultType: PassioFoodResultType
}
```

```typescript
export type PassioFoodResultType = 'foodItem' | 'barcode' | 'nutritionFacts'
```

* Property  **`tags`**`?: string` was added to **`PassioFoodDataInfo`**.
* Vitamin A RAE was added to the **`PassioNutrients`**.
* **`apiName`**` ``was added to the`` `**`PassioTokenBudget`**



## 3.1.4-1

* Fixed the fetchPossibleIngredients function for native integration.
* Removed the need to manually add the following line in build.gradle.

```
implementation files("$rootDir/../node_modules/@passiolife/nutritionai-react-native-sdk-v3/android/libs/passiolib-release.aar")
```

## 3.1.4

### **Breaking Changes**

* The ~~`NutritionAdvisor.configure`~~ no longer needs a separate key for configuration. The PassioSDK needs to be configured in order to call the NutritionAdvisor APIs. Also, any previous NutritionAdvisor keys won't work with this version, a new key needs to be obtained at [https://www.passio.ai/](https://www.passio.ai/)
* Changed ~~`weight`~~  to **`ingredientWeight`** in `PassioFoodItem`

### &#x20;**API Changes**

* Updated the `fetchFoodItemForDataInfo` method to include an optional `weightGrams` parameter

```typescript
  fetchFoodItemForDataInfo(
    passioFoodDataInfo: PassioFoodDataInfo,
    weightGram?: number
  ): PassioFoodItem
```

### **Introduce New API**

* With the new key comes the new pricing model using tokens. Although all token usage can be seen in the portal, the SDK itself offers a listener to count the tokens being used by the SDK.

```typescript

PassioSDK.setAccountListener({
    onTokenBudgetUpdate: (tokenBudget: PassioTokenBudget) => {
      console.log('tokenBudget', tokenBudget)
    },
  })  

export interface PassioAccountListener {
  onTokenBudgetUpdate: (tokenBudget: PassioTokenBudget) => void
}

export interface PassioTokenBudget {
  budgetCap: number
  periodUsage: number
  requestUsage: number
  usedPercent: number
}
```



**Flashlight API**

```typescript
  /**
   * Use this method to turn Flashlight on/off.
   * @param enabled - Pass true to turn flashlight on or pass false to turn in off.
   * @param torchLevel - Only Available for IOS, Sets the illumination level when in Flashlight mode.
   * This value must be a floating-point number between 0.0 and 1.0 default is 1.0.
   */
  enableFlashlight(enabled: boolean, torchLevel?: number): void

```

**Camera Zoom Level API**

```typescript
**
   * Use this function if you want to change zoom level of SDK's camera
   * @param zoomLevel - Level of zoom. Allowed values range from 1.0 (full field of view) to the value of the active format’s of device.
   */
  setCameraZoomLevel(zoomLevel?: number): void

  /**
   * Use this property to get Min and Max available VideoZoomFactor for camera
   */
  getMinMaxCameraZoomLevel(): Promise<PassioCameraZoomLevel>
```

## 3.1.1-3

* Now retrieving added sugars nutrients

## 3.1.1-1

*   "Provide a message parameter to indicate the context of the image as optional for `recognizeImageRemote`\
    \


    ```typescript
    recognizeImageRemote(
        imageUri: string,
        message?: string,
        resolution?: PassioImageResolution
      ): Promise<PassioAdvisorFoodInfo[] | null>

    ```


* Stop the camera when the view is unmounted for Android

## 3.1.1

## Added API

```typescript
/**
   * fetch list of possible hidden ingredients for a given food name.
   * @param foodName - query for foodName.
   * @returns A `Promise` resolving to a `PassioFetchAdvisorInfoResult`.
   */
  fetchHiddenIngredients(
    foodName: string
  ): Promise<PassioFetchAdvisorInfoResult>

  /**
   * fetch list of possible visual alternatives for a given food name.
   * @param foodName - query for foodName.
   * @returns A `Promise` resolving to a `PassioFetchAdvisorInfoResult`.
   */
  fetchVisualAlternatives(
    foodName: string
  ): Promise<PassioFetchAdvisorInfoResult>

  /**
   * fetch list of possible ingredients if a more complex food for a given food name.
   * @param foodName - query for foodName.
   * @returns A `Promise` resolving to a `PassioFetchAdvisorInfoResult`.
   */
  fetchPossibleIngredients(
    foodName: string
  ): Promise<PassioFetchAdvisorInfoResult>
```

* Added `resolution: PassioImageResolution` as a parameter of the `recognizeImageRemote` function. This enables the caller to set the target resolution of the image uploaded to the server. Smaller resolutions will result in faster response times, while higher resolutions should provide more accurate results.

```typescript
export type PassioImageResolution = 'RES_512' | 'RES_1080' | 'FULL'
```

```typescript
  recognizeImageRemote(
    imageUri: string,
    resolution?: PassioImageResolution
  ): Promise<PassioAdvisorFoodInfo[] | null>
```

## 3.1.0-3

* Added `volumeDetectionMode` prop \`DetectionCameraView\` \


```typescriptreact
 volumeDetectionMode?: 'auto' | 'dualWideCamera' | 'none'
```

Example:

```javascript
   <DetectionCameraView
        style={styles.detectionCamera}
        volumeDetectionMode="auto"
      />
```

NOTE:

When using `startNutritionFactsDetection`, ensure that `DetectionCameraView` has `volumeDetectionMode` set to '`none`.



## 3.1.0-1

### **Introduce NutritionAdvisor**

```typescript
/**
   * Configures the Nutrition Advisor with the provided license key.
   * @param licenseKey - The license key to configure the advisor.
   * @returns A Promise resolving to the status of the configuration.
   */
  configure(licenseKey: string): Promise<PassioAdvisorResultStatus | null>

  /**
   * Initiates a conversation with the Nutrition Advisor.
   * @returns A Promise resolving to the status of the conversation initiation.
   */
  initConversation(): Promise<PassioAdvisorResultStatus | null>

  /**
   * Sends a text message to the Nutrition Advisor.
   * @param message - The message to be sent.
   * @returns A Promise resolving to the status of the message sending.
   */
  sendMessage(message: string): Promise<PassioAdvisorMessageResultStatus | null>

  /**
   * Sends an image to the Nutrition Advisor.
   * @param imageURI - The local URI of the image to be sent.
   * @returns A Promise resolving to the status of the image sending.
   */
  sendImage(imageURI: string): Promise<PassioAdvisorMessageResultStatus | null>

  /**
   * Fetches ingredients from the Nutrition Advisor's response.
   * @param response - The response object from the Nutrition Advisor.
   * @returns A Promise resolving to the status of the ingredient fetching.
   */
  fetchIngredients(
    response: PassioAdvisorResponse
  ): Promise<PassioAdvisorMessageResultStatus | null>
```

## How to use API?

<pre class="language-typescript"><code class="lang-typescript"><strong>
</strong>import { NutritionAdvisor } from '@passiolife/nutritionai-react-native-sdk-v3'

<strong>const status = await NutritionAdvisor.configure(PASSIO_ADVISOR_KEY)
</strong>
switch (status?.status) {
          case 'Success':
            return
          case 'Error':
            return
        }

// Send Message
await NutritionAdvisor.sendMessage(message)

//Send Image
<strong>await NutritionAdvisor.sendImage(imgUrl)
</strong></code></pre>

## 3.0.4

### **Introduce new API**

* Fetch PassioFoodItem for a v2 PassioID

```typescript
  fetchFoodItemLegacy(passioID: PassioID): Promise<PassioFoodItem | null>
```

* Use this method to fetch PassioAdvisorFoodInfo using Image

```typescript
  recognizeImageRemote(imageUri: string): Promise<PassioAdvisorFoodInfo[] | null>
```

* Use this method to fetch PassioSpeechRecognitionModel using speech

<pre class="language-typescript"><code class="lang-typescript"><strong>recognizeSpeechRemote(text: string): Promise&#x3C;PassioSpeechRecognitionModel[] | null>
</strong></code></pre>

* Use this function to detect Nutrition Facts via pointing the camera at Nutrition Facts

```typescript
startNutritionFactsDetection(
    callback: (detection: NutritionDetectionEvent) => void
  ): Subscription

```

## Refactor&#x20;

Removed `nutritionFact` from `startFoodDetection`

## 3.0.3

* Added `weightUnit` and `weightQuantity` into `PassioNutritionPreview`&#x20;
* Added `refCode`  as a unique identifier of the food In `PassioFoodItem` and `PassioIngredient`&#x20;
* Added `fetchFoodItemForRefCode` API to get `PassioFoodItem` using `refCode`.&#x20;

```typescript
  /**
   * Look up the food item result for a given refCode.
   * @param refCode - The refCode for the  query.
   * @returns A `Promise` resolving to a `PassioFoodItem` object if the record exists in the database or `null` if not.
   */
  fetchFoodItemForRefCode(refCode: RefCode): Promise<PassioFoodItem | null>
```

* Added two functions to fetch a list of meal plans and fetch a meal plan for a certain day.

```typescript
/**
   * fetch list of all meal Plans
   * @returns A `Promise` resolving to a `PassioMealPlan` array if the record exists in the database or `null` if not.
   */
  fetchMealPlans(): Promise<PassioMealPlan[] | null>

  /**
   * fetch list of all meal Plan item
   * @param mealPlanLabel - query for type of mealPlan.
   * @param day - for which day meal plan is needed
   * @returns A `Promise` resolving to a `PassioMealPlanItem` array if the record exists in the database or `null` if not.
   */
  fetchMealPlanForDay(
    mealPlanLabel: string,
    day: number
  ): Promise<PassioMealPlanItem[] | null>
```



### Refactor API

* Now use `fetchFoodItemForProductCode` API instead of `fetchAttributesForBarcode` and `fetchPassioIDAttributesForPackagedFood` API.

```typescript
  /**
   * Look up the food item result for a given by barcode or packagedFoodCode.
   * @param barcode  - barcode for the query.
   * or
   * @param packageFoodCode  - packageFoodCode for the query.
   * @returns A `Promise` resolving to a `PassioFoodItem` object if the record exists in the database or `null` if not.
   */
  fetchFoodItemForProductCode(
    code: Barcode | PackagedFoodCode
  ): Promise<PassioFoodItem | null>
```

* ~~`getAttributesForPassioID`~~  renamed to `fetchFoodItemForPassioID`
* ~~`fetchAttributesForBarcode`~~ and ~~`fetchPassioIDAttributesForPackagedFood`~~ renamed to `fetchFoodItemForProductCode`
* PassioSearchResult object return `PassioFoodDataInfo` instead of `FoodSearchResult`
* ~~`fetchSearchResult`~~ renamed  to `fetchFoodItemForDataInfo`
* `PassioSearchNutritionPreview` renamed to `PassioNutritionPreview`
* Removed unnecessary nutrition data while log object of `PassioFoodItem` or `PassioIngredient`

## 3.0.2-3

* Fix the isOpenFood boolean issue in android.
* Introduce a new field openFoodLicense.
* Rename method from **`fetchNutrientsForPassioFoodItem`** to **`getNutrientsOfPassioFoodItem`**
* Rename method from **`fetchNutrientsSelectedSizeForPassioFoodItem`** to **`getNutrientsSelectedSizeOfPassioFoodItem`**
* Rename method from **`fetchNutrientsReferenceForPassioFoodItem`** to **`getNutrientsReferenceOfPassioFoodItem`**



## 3.0.2-2

* Fixed IOS weight gram value.

## 3.0.2-1

* Fixed symbol unit for iOS.
* Wide Angle camera issue resolved.

## 3.0.2&#x20;

Added `carbs` , `protein` and `fat` in `PassioSearchNutritionPreview`

### Added API

```typescript
  /**
   * fetch a suggestions for particular meal time  'breakfast' | 'lunch' | 'dinner' | 'snack' and returning results.
   * @param mealTime - 'breakfast' | 'lunch' | 'dinner' | 'snack',
   * @returns A `Promise` resolving to a `PassioFoodItem` object if the record exists in the database or `null` if not.
   */
  fetchSuggestions(mealTime: MealTime): Promise<FoodSearchResult[] | null>

  /**
   * Detail of search food with a given search result.
   * @param result - Provide `PassioSearchResult` object get `PassioFoodItem` detail.
   * @returns A `Promise` resolving to `PassioFoodItem` detail.
   */
  fetchFoodItemForSuggestion(
    result: FoodSearchResult
  ): Promise<PassioFoodItem | null>
```

Added below nutrients in `PassioNutrients`

```typescript
zinc, 
selenium, 
folicAcid, 
vitaminKPhylloquinone, 
vitaminKMenaquinone4, 
vitaminKDihydrophylloquinone, 
chromium
```

## **3.0.1-2**

**Deprecated API**

```
getAttributesForPassioID(passioID: PassioID): Promise<PassioIDAttributes | null>

fetchAttributesForBarcode(barcode: Barcode): Promise<PassioIDAttributes | null>

fetchPassioIDAttributesForPackagedFood(packagedFoodCode: PackagedFoodCode): Promise<PassioIDAttributes | null>

fetchSearchResult(result: FoodSearchResult): Promise<PassioIDAttributes | null>
```

***

**Refactored API**

* `getAttributesForPassioID`, `fetchAttributesForBarcode`, `fetchPassioIDAttributesForPackagedFood` now returns a PassioFoodItem result

```
getAttributesForPassioID(passioID: PassioID): Promise<PassioFoodItem | null>

fetchAttributesForBarcode(barcode: Barcode): Promise<PassioFoodItem | null>

fetchPassioIDAttributesForPackagedFood(packagedFoodCode: PackagedFoodCode): Promise<PassioFoodItem | null>
```

* searchForFood now returns PassioSearchResult and a list of search options. The PassioSearchResult represent a specific food item associated with the search term, while search options provide a list of possible suggested search terms connected to the input term.

```
searchForFood(searchQuery: string): Promise<PassioSearchResult | null>
```

* Now `DetectedCandidate` have `alternatives` and `croppedImage`

***

**New API**

* fetchSearchResult returns a PassioFoodItem object for a given PassioSearchResult

```
fetchSearchResult(result: FoodSearchResult): Promise<PassioFoodItem | null>
```

* To retrieve all macro and micronutrient values using PassioFoodItemNutrients by passing a passioFoodItem, you would typically follow these steps:

```
   new PassioFoodItemNutrients(passioFoodItem).nutrientsSelectedSize()
   new PassioFoodItemNutrients(passioFoodItem).nutrientsReference()
   new PassioFoodItemNutrients(passioFoodItem).nutrients({
      unit: calculatedWeightUnit,
      value: calculatedWeight,
    })
```

## 2.3.15-1

In the FoodItem class, the data type of `VitaminA` has been updated from `number` to `UnitMass`.

```typescript
/**
     * Vitamin A, in IU
     */
    vitaminA?: UnitMass;
```

## **2.3.15**

* Added fetchNutrientsFor API.

```
/**
   * fetch a map of nutrients for a 100 grams of a specific food item
   * @param passioID - The Passio ID for the attributes query.
   * @returns A `Promise` resolving to a `PassioNutrient` object if the record exists in the database or `null` if not.
   */
  fetchNutrientsFor(passioID: PassioID): Promise<PassioNutrient[] | null>
```

```
export interface PassioNutrient {
  // The name of the nutrient.
  name: string

  // The amount of the nutrient, measured in a specific unit.
  amount?: number

  // The unit in which the nutrient amount is measured (e.g., grams, milligrams).
  unit: string

  // The inflammatory effect score associated with the nutrient.
  inflammatoryEffectScore?: number
}
```

**Models**

* Number of food items recognized via HNN: 4104
* Nutrition database version: passio\_nutrition.4105.0.301
* Number of products recognized via OCR: 27756

**New included HNN foods**

```
corn chowder
```

**Excluded HNN foods**

```
coconut sandwich cookies
mollete
strawberry cream cheese bagel
```

##
