@fonoster/apiserver 0.53.0 → 0.54.1

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.
@@ -38,7 +38,9 @@ export declare function ensureRecordedUsageStream(nc: NatsConnection): Promise<v
38
38
  /**
39
39
  * Publishes one batch of unpublished usage, oldest first, each with its usage id as the message id
40
40
  * (JetStream drops a repeat), then marks the batch published. A crash between the two only
41
- * publishes the batch again. Returns how many were published.
41
+ * publishes the batch again. Rows without an owner are skipped and stay unpublished: there is no
42
+ * subject to publish them on, and one of them must not hold back the rest. Returns how many were
43
+ * published.
42
44
  */
43
45
  export declare function publishRecordedUsageOnce(nc: NatsConnection, db: UsageSql, batch?: number): Promise<number>;
44
46
  /**
@@ -57,13 +57,16 @@ function ensureRecordedUsageStream(nc) {
57
57
  /**
58
58
  * Publishes one batch of unpublished usage, oldest first, each with its usage id as the message id
59
59
  * (JetStream drops a repeat), then marks the batch published. A crash between the two only
60
- * publishes the batch again. Returns how many were published.
60
+ * publishes the batch again. Rows without an owner are skipped and stay unpublished: there is no
61
+ * subject to publish them on, and one of them must not hold back the rest. Returns how many were
62
+ * published.
61
63
  */
62
64
  function publishRecordedUsageOnce(nc_1, db_1) {
63
65
  return __awaiter(this, arguments, void 0, function* (nc, db, batch = 500) {
64
66
  const rows = yield db.$queryRawUnsafe(`SELECT id, owner_ref, workspace_ref, app_ref, call_ref, region, region_kind, origin, meter,
65
67
  quantity, provider, model, key_source, occurred_at
66
- FROM usage_events WHERE published_at IS NULL ORDER BY recorded_at, id LIMIT $1`, batch);
68
+ FROM usage_events WHERE published_at IS NULL AND owner_ref <> ''
69
+ ORDER BY recorded_at, id LIMIT $1`, batch);
67
70
  if (!rows.length)
68
71
  return 0;
69
72
  const js = nc.jetstream();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fonoster/apiserver",
3
- "version": "0.53.0",
3
+ "version": "0.54.1",
4
4
  "description": "APIServer for Fonoster",
5
5
  "author": "Pedro Sanders <psanders@fonoster.com>",
6
6
  "homepage": "https://github.com/fonoster/fonoster#readme",
@@ -23,14 +23,14 @@
23
23
  "fonoster-owner": "./dist/bin/owner.js"
24
24
  },
25
25
  "dependencies": {
26
- "@fonoster/authz": "^0.53.0",
27
- "@fonoster/autopilot": "^0.53.0",
28
- "@fonoster/callrecord": "^0.53.0",
29
- "@fonoster/common": "^0.53.0",
30
- "@fonoster/identity": "^0.53.0",
31
- "@fonoster/logger": "^0.53.0",
32
- "@fonoster/sipnet": "^0.53.0",
33
- "@fonoster/types": "^0.53.0",
26
+ "@fonoster/authz": "^0.54.0",
27
+ "@fonoster/autopilot": "^0.54.1",
28
+ "@fonoster/callrecord": "^0.54.0",
29
+ "@fonoster/common": "^0.54.0",
30
+ "@fonoster/identity": "^0.54.0",
31
+ "@fonoster/logger": "^0.54.0",
32
+ "@fonoster/sipnet": "^0.54.0",
33
+ "@fonoster/types": "^0.54.0",
34
34
  "@grpc/grpc-js": "~1.14.6",
35
35
  "@prisma/client": "^6.19.1",
36
36
  "@routr/common": "^2.24.0",
@@ -62,13 +62,13 @@
62
62
  "url": "https://github.com/fonoster/fonoster/issues"
63
63
  },
64
64
  "devDependencies": {
65
- "@fonoster/ops": "^0.53.0",
65
+ "@fonoster/ops": "^0.54.0",
66
66
  "@types/express": "^5.0.6",
67
67
  "@types/jsonwebtoken": "^9.0.10",
68
68
  "@types/uuid": "^10.0.0",
69
69
  "@types/validator": "^13.15.10"
70
70
  },
71
- "gitHead": "473eaef2f3847eaa15ff0f80fe84eea7eedfe4b9",
71
+ "gitHead": "493553716161a4e30e3882a926d5708c9ecca63a",
72
72
  "prisma": {
73
73
  "seed": "tsx src/core/seed.ts"
74
74
  }