@tinkerlandai/longplay-react-native 0.10.6 → 0.10.8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -344,7 +344,11 @@ class IndianaClient internal constructor(private val configuration: IndianaConfi
344
344
  suspend fun previewAttach(requestId: UUID, plans: List<IndianaSubscriptionPlan>, provider: IndianaSubscriptionProvider, currency: String, billingSubscriptionId: UUID? = null, offerId: UUID? = null, nativeOffer: IndianaNativeStoreOffer? = null): JSONObject {
345
345
  if (plans.size !in 1..20 || plans.map { it.productVersionId }.distinct().size != plans.size || !currency.matches(Regex("[A-Z]{3}")) || plans.any { it.featureQuantities.size > 100 || it.featureQuantities.values.any { q -> q !in 0..10000 } || it.seatQuantities.size > 20 || it.seatQuantities.any { (key, quantity) -> !key.matches(Regex("[a-z][a-z0-9_]{0,63}")) || quantity !in 0..10000 } }) throw IndianaClientException("invalid_request")
346
346
  val entries = JSONArray()
347
- plans.forEach { entries.put(JSONObject().put("productVersionId", it.productVersionId.toString()).put("seatQuantities", JSONObject(it.seatQuantities)).put("featureQuantities", JSONObject(it.featureQuantities.mapKeys { entry -> entry.key.toString() }))) }
347
+ // Empty quantity maps are omitted: the contract treats them as absent and the deployed runtime refuses an empty object.
348
+ plans.forEach { plan -> entries.put(JSONObject().put("productVersionId", plan.productVersionId.toString()).apply {
349
+ if (plan.seatQuantities.isNotEmpty()) put("seatQuantities", JSONObject(plan.seatQuantities))
350
+ if (plan.featureQuantities.isNotEmpty()) put("featureQuantities", JSONObject(plan.featureQuantities.mapKeys { entry -> entry.key.toString() }))
351
+ }) }
348
352
  val body = JSONObject().put("requestId", requestId.toString()).put("plans", entries).put("provider", provider.value).put("currency", currency)
349
353
  billingSubscriptionId?.let { body.put("billingSubscriptionId", it.toString()) }
350
354
  if (nativeOffer != null && (!nativeOffer.matches(provider) || plans.size != 1) ||
@@ -2,5 +2,5 @@
2
2
  package ai.tinkerland.indiana
3
3
 
4
4
  object IndianaSDK {
5
- const val version = "0.10.6"
5
+ const val version = "0.10.8"
6
6
  }
@@ -498,7 +498,13 @@ public actor IndianaClient {
498
498
  guard (1...20).contains(plans.count), Set(plans.map(\.productVersionId)).count == plans.count,
499
499
  currency.range(of: "^[A-Z]{3}$", options: .regularExpression) != nil,
500
500
  plans.allSatisfy({ $0.featureQuantities.count <= 100 && $0.featureQuantities.values.allSatisfy { (0...10000).contains($0) } && $0.seatQuantities.count <= 20 && $0.seatQuantities.allSatisfy { $0.key.range(of: "^[a-z][a-z0-9_]{0,63}$", options: .regularExpression) != nil && (0...10000).contains($0.value) } }) else { throw IndianaClientError.invalidResponse }
501
- let entries = plans.map { plan in IndianaJSON.object(["productVersionId":.string(plan.productVersionId.uuidString.lowercased()), "seatQuantities":.object(plan.seatQuantities.mapValues { .number(Double($0)) }), "featureQuantities":.object(Dictionary(uniqueKeysWithValues: plan.featureQuantities.map { ($0.key.uuidString.lowercased(), IndianaJSON.number(Double($0.value))) }))]) }
501
+ // Empty quantity maps are omitted: the contract treats them as absent and the deployed runtime refuses an empty object.
502
+ let entries = plans.map { plan -> IndianaJSON in
503
+ var entry: [String: IndianaJSON] = ["productVersionId": .string(plan.productVersionId.uuidString.lowercased())]
504
+ if !plan.seatQuantities.isEmpty { entry["seatQuantities"] = .object(plan.seatQuantities.mapValues { .number(Double($0)) }) }
505
+ if !plan.featureQuantities.isEmpty { entry["featureQuantities"] = .object(Dictionary(uniqueKeysWithValues: plan.featureQuantities.map { ($0.key.uuidString.lowercased(), IndianaJSON.number(Double($0.value))) })) }
506
+ return .object(entry)
507
+ }
502
508
  var fields: [String: IndianaJSON] = ["requestId":.string(requestId.uuidString.lowercased()), "plans":.array(entries), "provider":.string(provider.rawValue), "currency":.string(currency)]
503
509
  if let billingSubscriptionId { fields["billingSubscriptionId"] = .string(billingSubscriptionId.uuidString.lowercased()) }
504
510
  guard nativeOffer == nil || (nativeOffer!.matches(provider) && plans.count == 1),
@@ -1,4 +1,4 @@
1
1
  // Generated by scripts/sdk/generate-native-protocol.mjs. Do not edit.
2
2
  public enum IndianaSDK {
3
- public static let version = "0.10.6"
3
+ public static let version = "0.10.8"
4
4
  }