@fonoster/apiserver 0.43.0 → 0.46.0

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.
@@ -29,13 +29,13 @@ const featuresSchema = zod_1.z
29
29
  billing: zod_1.z
30
30
  .object({
31
31
  enabled: zod_1.z.boolean().default(false),
32
- /** The billing service's Billing API (host:port); defaults to authz.host:50073. */
32
+ /** The billing service's Billing API (host:port); required when billing is enabled. */
33
33
  address: zod_1.z.string().min(1).optional()
34
34
  })
35
- .default({}),
35
+ .prefault({}),
36
36
  costs: zod_1.z
37
37
  .object({ display: zod_1.z.enum(["none", "usage", "prices"]).default("usage") })
38
- .default({}),
38
+ .prefault({}),
39
39
  calls: zod_1.z
40
40
  .object({
41
41
  transcripts: zod_1.z
@@ -43,10 +43,10 @@ const featuresSchema = zod_1.z
43
43
  store: zod_1.z.boolean().default(true),
44
44
  retentionDays: zod_1.z.number().int().positive().default(30)
45
45
  })
46
- .default({}),
47
- recordings: zod_1.z.object({ store: zod_1.z.boolean().default(false) }).default({})
46
+ .prefault({}),
47
+ recordings: zod_1.z.object({ store: zod_1.z.boolean().default(false) }).prefault({})
48
48
  })
49
- .default({}),
49
+ .prefault({}),
50
50
  /**
51
51
  * SIP names (trunk inbound URIs, domains): "domain" requires one DNS label
52
52
  * under `sip.<domain>` (carriers and phones reach a wildcard `*.sip.<domain>`);
@@ -54,9 +54,9 @@ const featuresSchema = zod_1.z
54
54
  */
55
55
  sip: zod_1.z
56
56
  .object({ names: zod_1.z.enum(["domain", "any"]).default("domain") })
57
- .default({})
57
+ .prefault({})
58
58
  })
59
- .default({});
59
+ .prefault({});
60
60
  exports.featuresSchema = featuresSchema;
61
61
  /** Where call records live (add-call-record): a directory, or S3-compatible storage. */
62
62
  const recordStoreSchema = zod_1.z.union([
@@ -89,7 +89,7 @@ const callRecordsSchema = zod_1.z
89
89
  retentionIntervalMinutes: zod_1.z.number().int().positive().default(60),
90
90
  maintenanceTimeoutMs: zod_1.z.number().int().positive().default(30000)
91
91
  })
92
- .default({});
92
+ .prefault({});
93
93
  /**
94
94
  * Session apps (voice-session G2): the hosted Autopilot that Autopilot apps point at, and the
95
95
  * secret AppBridge signs their sessions with (the hosted Autopilot verifies one secret for every
@@ -107,7 +107,7 @@ const sessionAppsSchema = zod_1.z
107
107
  */
108
108
  allowedDestinations: zod_1.z.array(zod_1.z.string().min(1)).optional()
109
109
  })
110
- .default({});
110
+ .prefault({});
111
111
  /**
112
112
  * The provider catalog file (add-self-host-installer D7): applied to the registry tables on
113
113
  * every start with `fonoster-registry apply --store database` semantics. Listed entries are added
@@ -127,8 +127,8 @@ const catalogSchema = zod_1.z
127
127
  * workspace has no key of its own for the provider. Values take `secret://` references (D8).
128
128
  */
129
129
  const evaluationsSchema = zod_1.z
130
- .object({ credentials: zod_1.z.record(zod_1.z.string().min(1)).default({}) })
131
- .default({});
130
+ .object({ credentials: zod_1.z.record(zod_1.z.string(), zod_1.z.string().min(1)).prefault({}) })
131
+ .prefault({});
132
132
  /**
133
133
  * Workspace webhooks fan-out (add-workspace-webhooks 2.2): events producers publish on the bus
134
134
  * (`webhooks.events`) are delivered from here.
@@ -139,7 +139,7 @@ const webhooksSchema = zod_1.z
139
139
  intervalMs: zod_1.z.number().int().positive().default(1000),
140
140
  refreshMs: zod_1.z.number().int().positive().default(10000)
141
141
  })
142
- .default({});
142
+ .prefault({});
143
143
  /**
144
144
  * Regions (add-private-regions). Public regions come from data (PR-10); private regions need the
145
145
  * region-signing key (ES256 PEM) and the region hub (NATS in operator mode, RG-B2), both generated
@@ -213,12 +213,12 @@ const regionsSchema = zod_1.z
213
213
  /** Relays in flight per region (HTTP 429 beyond). */
214
214
  maxConcurrent: zod_1.z.number().int().positive().default(8)
215
215
  })
216
- .default({}),
216
+ .prefault({}),
217
217
  /** The release cells are measured against (default: this apiserver's version). */
218
218
  currentVersion: zod_1.z.string().optional(),
219
219
  configDebounceMs: zod_1.z.number().int().nonnegative().default(500)
220
220
  })
221
- .default({});
221
+ .prefault({});
222
222
  /** fonoster.yaml: everything the API server (and embedded Identity) needs. */
223
223
  const fonosterConfigSchema = zod_1.z
224
224
  .object({
@@ -235,7 +235,7 @@ const fonosterConfigSchema = zod_1.z
235
235
  /** How other services reach this one. */
236
236
  host: zod_1.z.string().default("apiserver")
237
237
  })
238
- .default({}),
238
+ .prefault({}),
239
239
  logs: common_1.logsSchema,
240
240
  /** OTLP export (empty = off): `otlpEndpoint: "${OTEL_EXPORTER_OTLP_ENDPOINT:-}"`. */
241
241
  telemetry: common_1.telemetrySchema,
@@ -251,7 +251,7 @@ const fonosterConfigSchema = zod_1.z
251
251
  .array(zod_1.z.string().min(1))
252
252
  .default(["/fonoster.calls.v1beta2.Calls/CreateCall"])
253
253
  })
254
- .default({}),
254
+ .prefault({}),
255
255
  features: featuresSchema,
256
256
  routr: zod_1.z
257
257
  .object({
@@ -272,9 +272,9 @@ const fonosterConfigSchema = zod_1.z
272
272
  username: zod_1.z.string().default("roomr"),
273
273
  password: zod_1.z.string().optional()
274
274
  })
275
- .default({})
275
+ .prefault({})
276
276
  })
277
- .default({}),
277
+ .prefault({}),
278
278
  // user/password: the apiserver's NATS user when the server has per-service users
279
279
  // (add-platform 4.1); password is usually a secret:// reference.
280
280
  nats: zod_1.z.object({
@@ -301,11 +301,11 @@ const fonosterConfigSchema = zod_1.z
301
301
  message: "required when authz.enabled is true"
302
302
  });
303
303
  }
304
- if (config.features.billing.enabled && !config.authz.enabled) {
304
+ if (config.features.billing.enabled && !config.features.billing.address) {
305
305
  ctx.addIssue({
306
306
  code: "custom",
307
- path: ["features", "billing", "enabled"],
308
- message: "billing needs the authorization service (authz.enabled)"
307
+ path: ["features", "billing", "address"],
308
+ message: "required when features.billing.enabled is true"
309
309
  });
310
310
  }
311
311
  if (config.features.auth.methods.includes("github") &&
package/dist/envs.d.ts CHANGED
@@ -49,14 +49,14 @@ export declare const AUTHZ_SERVICE_HOST: string;
49
49
  export declare const AUTHZ_SERVICE_PORT: number;
50
50
  export declare const AUTHZ_SERVICE_METHODS: string[];
51
51
  export declare const EVALUATIONS: {
52
- credentials?: Record<string, string>;
52
+ credentials: Record<string, string>;
53
53
  };
54
54
  export declare const NATS_URL: string;
55
55
  /** The `nats` setting itself (URL, user, password), for helpers that take a NatsTarget. */
56
56
  export declare const NATS_CONNECTION: {
57
- url?: string;
58
- password?: string;
57
+ url: string;
59
58
  user?: string;
59
+ password?: string;
60
60
  };
61
61
  /** nats.js connect options: the URL plus the apiserver's NATS user, when set (add-platform 4.1). */
62
62
  export declare const NATS: {
@@ -67,9 +67,9 @@ export declare const NATS: {
67
67
  };
68
68
  export declare const ROUTR_API_ENDPOINT: string;
69
69
  export declare const ROUTR_ROOMR_PEER: {
70
- name?: string;
71
- aor?: string;
72
- username?: string;
70
+ aor: string;
71
+ name: string;
72
+ username: string;
73
73
  password?: string;
74
74
  };
75
75
  /** Routr's SIP address: API-originated calls are dialed through it (Roomr CreateCall). */
@@ -85,79 +85,79 @@ export declare const TWILIO_ACCOUNT_SID: string;
85
85
  export declare const TWILIO_AUTH_TOKEN: string;
86
86
  export declare const TWILIO_PHONE_NUMBER: string;
87
87
  export declare const CALL_RECORDS: {
88
- enabled?: boolean;
89
- stores?: ({
90
- dir?: string;
88
+ enabled: boolean;
89
+ stores: ({
90
+ dir: string;
91
91
  } | {
92
- s3?: {
93
- bucket?: string;
92
+ s3: {
93
+ bucket: string;
94
94
  prefix?: string;
95
95
  region?: string;
96
96
  endpoint?: string;
97
97
  forcePathStyle?: boolean;
98
98
  credentials?: {
99
- accessKeyId?: string;
100
- secretAccessKey?: string;
99
+ accessKeyId: string;
100
+ secretAccessKey: string;
101
101
  };
102
102
  };
103
103
  })[];
104
- retentionIntervalMinutes?: number;
105
- maintenanceTimeoutMs?: number;
104
+ retentionIntervalMinutes: number;
105
+ maintenanceTimeoutMs: number;
106
106
  };
107
107
  export declare const SESSION_APPS: {
108
- autopilotUrl?: string;
108
+ autopilotUrl: string;
109
+ allowInsecureWebhooks: boolean;
109
110
  autopilotSigningSecret?: string;
110
- allowInsecureWebhooks?: boolean;
111
111
  allowedDestinations?: string[];
112
112
  };
113
113
  export declare const WEBHOOKS: {
114
- fanout?: boolean;
115
- intervalMs?: number;
116
- refreshMs?: number;
114
+ fanout: boolean;
115
+ intervalMs: number;
116
+ refreshMs: number;
117
117
  };
118
118
  export declare const REGIONS: {
119
- public?: {
120
- id?: string;
121
- name?: string;
119
+ public: {
120
+ id: string;
121
+ name: string;
122
122
  default?: boolean;
123
123
  endpoints?: {
124
- sip?: {
125
- host?: string;
126
- port?: number;
127
- transport?: "udp" | "tcp" | "tls" | "ws" | "wss";
124
+ sip: {
125
+ host: string;
126
+ port: number;
127
+ transport: "udp" | "tcp" | "tls" | "ws" | "wss";
128
128
  }[];
129
- signalingAddresses?: string[];
130
- mediaAddresses?: string[];
129
+ signalingAddresses: string[];
130
+ mediaAddresses: string[];
131
131
  rtpPorts?: {
132
- min?: number;
133
- max?: number;
132
+ min: number;
133
+ max: number;
134
134
  };
135
135
  };
136
136
  }[];
137
+ allowInsecureLeaf: boolean;
138
+ relay: {
139
+ firstChunkTimeoutMs: number;
140
+ idleTimeoutMs: number;
141
+ maxBytes: number;
142
+ maxConcurrent: number;
143
+ };
144
+ configDebounceMs: number;
137
145
  operatorKey?: string;
138
146
  privateRegionMonthlyFeeCents?: number;
139
147
  controlPlaneUrl?: string;
140
148
  leafUrl?: string;
141
- allowInsecureLeaf?: boolean;
142
149
  signingKey?: {
143
- file?: string;
150
+ file: string;
144
151
  kid?: string;
145
152
  };
146
153
  hub?: {
147
- url?: string;
148
- credentialsFile?: string;
149
- systemCredentialsFile?: string;
150
- operatorSeedFile?: string;
151
- accountSeedFile?: string;
152
- };
153
- relay?: {
154
- firstChunkTimeoutMs?: number;
155
- idleTimeoutMs?: number;
156
- maxBytes?: number;
157
- maxConcurrent?: number;
154
+ url: string;
155
+ credentialsFile: string;
156
+ systemCredentialsFile: string;
157
+ operatorSeedFile: string;
158
+ accountSeedFile: string;
158
159
  };
159
160
  currentVersion?: string;
160
- configDebounceMs?: number;
161
161
  };
162
162
  export declare const DOMAIN: string;
163
163
  /**
package/dist/envs.js CHANGED
@@ -80,7 +80,7 @@ exports.IDENTITY_DATABASE_URL = identity.dbUrl;
80
80
  /** Billing is on (Cloud): stored usage is published for the billing service (add-billing-service D2). */
81
81
  exports.BILLING_ENABLED = config.features.billing.enabled;
82
82
  /** Where the Billing API is served (the billing service). */
83
- exports.BILLING_ADDRESS = (_c = config.features.billing.address) !== null && _c !== void 0 ? _c : `${config.authz.host}:50073`;
83
+ exports.BILLING_ADDRESS = (_c = config.features.billing.address) !== null && _c !== void 0 ? _c : "";
84
84
  // Authz configurations
85
85
  exports.AUTHZ_SERVICE_ENABLED = config.authz.enabled;
86
86
  exports.AUTHZ_SERVICE_HOST = config.authz.host;
@@ -17,7 +17,23 @@
17
17
  * limitations under the License.
18
18
  */
19
19
  import { GrpcErrorMessage } from "@fonoster/common";
20
+ import { z } from "zod";
20
21
  import { UsageSql } from "./types";
22
+ /** GetUsage's request; exported for the array-limit tests. */
23
+ export declare const getUsageRequestSchema: z.ZodObject<{
24
+ fromDay: z.ZodString;
25
+ toDay: z.ZodString;
26
+ groupBy: z.ZodOptional<z.ZodArray<z.ZodEnum<{
27
+ origin: "origin";
28
+ model: "model";
29
+ provider: "provider";
30
+ workspace: "workspace";
31
+ meter: "meter";
32
+ day: "day";
33
+ key_source: "key_source";
34
+ }>>>;
35
+ allOwned: z.ZodOptional<z.ZodBoolean>;
36
+ }, z.core.$strip>;
21
37
  /**
22
38
  * Usage totals (usage-metering "Usage API"): quantities from usage_daily, never money. Each day is
23
39
  * totalled first; across days counted meters add up and snapshot meters (storage) take the peak.
@@ -9,6 +9,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
9
9
  });
10
10
  };
11
11
  Object.defineProperty(exports, "__esModule", { value: true });
12
+ exports.getUsageRequestSchema = void 0;
12
13
  exports.createGetUsage = createGetUsage;
13
14
  /**
14
15
  * Copyright (C) 2025 by Fonoster Inc (https://fonoster.com)
@@ -46,12 +47,15 @@ const COLUMNS = {
46
47
  key_source: "key_source",
47
48
  origin: "origin"
48
49
  };
49
- const schema = zod_1.z
50
+ const DIMENSIONS = Object.keys(COLUMNS).length;
51
+ /** GetUsage's request; exported for the array-limit tests. */
52
+ exports.getUsageRequestSchema = zod_1.z
50
53
  .object({
51
54
  fromDay: zod_1.z.string().regex(DAY, "fromDay must be YYYY-MM-DD"),
52
55
  toDay: zod_1.z.string().regex(DAY, "toDay must be YYYY-MM-DD"),
53
56
  groupBy: zod_1.z
54
57
  .array(zod_1.z.enum(Object.keys(COLUMNS)))
58
+ .max(DIMENSIONS, { message: `At most ${DIMENSIONS} dimensions` })
55
59
  .optional(),
56
60
  allOwned: zod_1.z.boolean().optional()
57
61
  })
@@ -114,5 +118,5 @@ function createGetUsage(db) {
114
118
  }))
115
119
  });
116
120
  });
117
- return (0, common_1.withErrorHandlingAndValidation)(fn, schema);
121
+ return (0, common_1.withErrorHandlingAndValidation)(fn, exports.getUsageRequestSchema);
118
122
  }
@@ -30,7 +30,7 @@ class Deepgram {
30
30
  smartFormat: zod_1.z.boolean().optional(),
31
31
  noDelay: zod_1.z.boolean().optional(),
32
32
  languageCode: zod_1.z
33
- .union([zod_1.z.nativeEnum(common_1.VoiceLanguage), zod_1.z.literal(types_1.DEEPGRAM_MULTILINGUAL)], { errorMap: () => ({ message: common_1.Messages.VALID_LANGUAGE_CODE }) })
33
+ .union([zod_1.z.nativeEnum(common_1.VoiceLanguage), zod_1.z.literal(types_1.DEEPGRAM_MULTILINGUAL)], { error: common_1.Messages.VALID_LANGUAGE_CODE })
34
34
  .optional(),
35
35
  model: zod_1.z
36
36
  .nativeEnum(types_1.DeepgramModel, { message: "Invalid Deepgram model" })
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fonoster/apiserver",
3
- "version": "0.43.0",
3
+ "version": "0.46.0",
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.43.0",
27
- "@fonoster/autopilot": "^0.43.0",
28
- "@fonoster/callrecord": "^0.43.0",
29
- "@fonoster/common": "^0.43.0",
30
- "@fonoster/identity": "^0.43.0",
31
- "@fonoster/logger": "^0.43.0",
32
- "@fonoster/sipnet": "^0.43.0",
33
- "@fonoster/types": "^0.43.0",
26
+ "@fonoster/authz": "^0.46.0",
27
+ "@fonoster/autopilot": "^0.46.0",
28
+ "@fonoster/callrecord": "^0.46.0",
29
+ "@fonoster/common": "^0.46.0",
30
+ "@fonoster/identity": "^0.46.0",
31
+ "@fonoster/logger": "^0.46.0",
32
+ "@fonoster/sipnet": "^0.46.0",
33
+ "@fonoster/types": "^0.46.0",
34
34
  "@grpc/grpc-js": "~1.14.6",
35
35
  "@prisma/client": "^6.19.1",
36
36
  "@routr/common": "^2.24.0",
@@ -46,7 +46,7 @@
46
46
  "prisma-field-encryption": "^1.6.0",
47
47
  "uuid": "^11.0.3",
48
48
  "validator": "^13.12.0",
49
- "zod": "^3.23.8"
49
+ "zod": "^4.6.7"
50
50
  },
51
51
  "files": [
52
52
  "dist"
@@ -67,7 +67,7 @@
67
67
  "@types/uuid": "^10.0.0",
68
68
  "@types/validator": "^13.15.10"
69
69
  },
70
- "gitHead": "091231327ebe27c11d882b8ea2e2deadea916697",
70
+ "gitHead": "32fd292a6832d2e784f8b428c6e7a6b1f3f3f3e2",
71
71
  "prisma": {
72
72
  "seed": "tsx src/core/seed.ts"
73
73
  }