Rthur2003 commited on
Commit
a013512
·
1 Parent(s): e704e6c

feat: implement FL-MCP commerce, licensing, and credit management backend

Browse files
app/routes/flmcp.py CHANGED
@@ -430,3 +430,4 @@ def admin_lookup_account(email: str, authorization: str | None = Header(None)):
430
  }
431
  except ApiError as exc:
432
  return _problem_response(exc)
 
 
430
  }
431
  except ApiError as exc:
432
  return _problem_response(exc)
433
+
app/services/flmcp/__init__.py CHANGED
@@ -50,3 +50,4 @@ __all__ = [
50
  "sign",
51
  "apply",
52
  ]
 
 
50
  "sign",
51
  "apply",
52
  ]
53
+
app/services/flmcp/accounts.py CHANGED
@@ -219,3 +219,4 @@ def devices(conn: Any, license_id: str) -> list[dict]:
219
  }
220
  for r in rows
221
  ]
 
 
219
  }
220
  for r in rows
221
  ]
222
+
app/services/flmcp/db.py CHANGED
@@ -362,3 +362,4 @@ class DB:
362
  conn.execute("COMMIT")
363
  finally:
364
  conn.close()
 
 
362
  conn.execute("COMMIT")
363
  finally:
364
  conn.close()
365
+
app/services/flmcp/errors.py CHANGED
@@ -12,3 +12,4 @@ class ApiError(Exception):
12
  self.code = code
13
  self.detail = detail
14
  self.extra = extra
 
 
12
  self.code = code
13
  self.detail = detail
14
  self.extra = extra
15
+
app/services/flmcp/keys.py CHANGED
@@ -47,3 +47,4 @@ def hash_key(text: str) -> str | None:
47
  def display(text: str) -> str | None:
48
  s = normalize(text)
49
  return _format(s) if s else None
 
 
47
  def display(text: str) -> str | None:
48
  s = normalize(text)
49
  return _format(s) if s else None
50
+
app/services/flmcp/ledger.py CHANGED
@@ -237,3 +237,4 @@ def history(conn: Any, account_id: str, limit: int = 20) -> list[dict]:
237
  (account_id, limit),
238
  ).fetchall()
239
  return [dict(r) for r in rows]
 
 
237
  (account_id, limit),
238
  ).fetchall()
239
  return [dict(r) for r in rows]
240
+
app/services/flmcp/plans.py CHANGED
@@ -77,3 +77,4 @@ def require_usable(status: str, period_end: int | None, now: int) -> None:
77
  f"the subscription is {state}; renew it to continue",
78
  subscription=state,
79
  )
 
 
77
  f"the subscription is {state}; renew it to continue",
78
  subscription=state,
79
  )
80
+
app/services/flmcp/webhooks.py CHANGED
@@ -154,3 +154,4 @@ def apply(conn: Any, provider: str, ev: dict, now: int, cfg: Config) -> dict:
154
  if not fresh.rowcount:
155
  return {"duplicate": True}
156
  return handler(conn, provider, ev, now, cfg)
 
 
154
  if not fresh.rowcount:
155
  return {"duplicate": True}
156
  return handler(conn, provider, ev, now, cfg)
157
+
tests/test_flmcp.py CHANGED
@@ -252,3 +252,4 @@ def test_webhook_payment_provisioning(client):
252
  assert data["plan"] == "pro"
253
  assert data["balance"] == 300
254
  assert data["seats_allowed"] == 2
 
 
252
  assert data["plan"] == "pro"
253
  assert data["balance"] == 300
254
  assert data["seats_allowed"] == 2
255
+