@fonoster/apiserver 0.43.0 → 0.44.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.
- package/dist/applications/session/appModel.d.ts +50 -137
- package/dist/applications/session/appModel.js +10 -12
- package/dist/config/schema.d.ts +158 -1725
- package/dist/config/schema.js +18 -18
- package/dist/envs.d.ts +45 -45
- package/dist/usage/createGetUsage.d.ts +16 -0
- package/dist/usage/createGetUsage.js +6 -2
- package/dist/voice/stt/Deepgram.js +1 -1
- package/package.json +11 -11
package/dist/config/schema.js
CHANGED
|
@@ -32,10 +32,10 @@ const featuresSchema = zod_1.z
|
|
|
32
32
|
/** The billing service's Billing API (host:port); defaults to authz.host:50073. */
|
|
33
33
|
address: zod_1.z.string().min(1).optional()
|
|
34
34
|
})
|
|
35
|
-
.
|
|
35
|
+
.prefault({}),
|
|
36
36
|
costs: zod_1.z
|
|
37
37
|
.object({ display: zod_1.z.enum(["none", "usage", "prices"]).default("usage") })
|
|
38
|
-
.
|
|
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
|
-
.
|
|
47
|
-
recordings: zod_1.z.object({ store: zod_1.z.boolean().default(false) }).
|
|
46
|
+
.prefault({}),
|
|
47
|
+
recordings: zod_1.z.object({ store: zod_1.z.boolean().default(false) }).prefault({})
|
|
48
48
|
})
|
|
49
|
-
.
|
|
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
|
-
.
|
|
57
|
+
.prefault({})
|
|
58
58
|
})
|
|
59
|
-
.
|
|
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
|
-
.
|
|
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
|
-
.
|
|
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)).
|
|
131
|
-
.
|
|
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
|
-
.
|
|
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
|
-
.
|
|
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
|
-
.
|
|
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
|
-
.
|
|
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
|
-
.
|
|
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
|
-
.
|
|
275
|
+
.prefault({})
|
|
276
276
|
})
|
|
277
|
-
.
|
|
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({
|
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
|
|
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
|
|
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
|
-
|
|
71
|
-
|
|
72
|
-
username
|
|
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
|
|
89
|
-
stores
|
|
90
|
-
dir
|
|
88
|
+
enabled: boolean;
|
|
89
|
+
stores: ({
|
|
90
|
+
dir: string;
|
|
91
91
|
} | {
|
|
92
|
-
s3
|
|
93
|
-
bucket
|
|
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
|
|
100
|
-
secretAccessKey
|
|
99
|
+
accessKeyId: string;
|
|
100
|
+
secretAccessKey: string;
|
|
101
101
|
};
|
|
102
102
|
};
|
|
103
103
|
})[];
|
|
104
|
-
retentionIntervalMinutes
|
|
105
|
-
maintenanceTimeoutMs
|
|
104
|
+
retentionIntervalMinutes: number;
|
|
105
|
+
maintenanceTimeoutMs: number;
|
|
106
106
|
};
|
|
107
107
|
export declare const SESSION_APPS: {
|
|
108
|
-
autopilotUrl
|
|
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
|
|
115
|
-
intervalMs
|
|
116
|
-
refreshMs
|
|
114
|
+
fanout: boolean;
|
|
115
|
+
intervalMs: number;
|
|
116
|
+
refreshMs: number;
|
|
117
117
|
};
|
|
118
118
|
export declare const REGIONS: {
|
|
119
|
-
public
|
|
120
|
-
id
|
|
121
|
-
name
|
|
119
|
+
public: {
|
|
120
|
+
id: string;
|
|
121
|
+
name: string;
|
|
122
122
|
default?: boolean;
|
|
123
123
|
endpoints?: {
|
|
124
|
-
sip
|
|
125
|
-
host
|
|
126
|
-
port
|
|
127
|
-
transport
|
|
124
|
+
sip: {
|
|
125
|
+
host: string;
|
|
126
|
+
port: number;
|
|
127
|
+
transport: "udp" | "tcp" | "tls" | "ws" | "wss";
|
|
128
128
|
}[];
|
|
129
|
-
signalingAddresses
|
|
130
|
-
mediaAddresses
|
|
129
|
+
signalingAddresses: string[];
|
|
130
|
+
mediaAddresses: string[];
|
|
131
131
|
rtpPorts?: {
|
|
132
|
-
min
|
|
133
|
-
max
|
|
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
|
|
150
|
+
file: string;
|
|
144
151
|
kid?: string;
|
|
145
152
|
};
|
|
146
153
|
hub?: {
|
|
147
|
-
url
|
|
148
|
-
credentialsFile
|
|
149
|
-
systemCredentialsFile
|
|
150
|
-
operatorSeedFile
|
|
151
|
-
accountSeedFile
|
|
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
|
/**
|
|
@@ -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
|
|
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,
|
|
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)], {
|
|
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.
|
|
3
|
+
"version": "0.44.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.
|
|
27
|
-
"@fonoster/autopilot": "^0.
|
|
28
|
-
"@fonoster/callrecord": "^0.
|
|
29
|
-
"@fonoster/common": "^0.
|
|
30
|
-
"@fonoster/identity": "^0.
|
|
31
|
-
"@fonoster/logger": "^0.
|
|
32
|
-
"@fonoster/sipnet": "^0.
|
|
33
|
-
"@fonoster/types": "^0.
|
|
26
|
+
"@fonoster/authz": "^0.44.0",
|
|
27
|
+
"@fonoster/autopilot": "^0.44.0",
|
|
28
|
+
"@fonoster/callrecord": "^0.44.0",
|
|
29
|
+
"@fonoster/common": "^0.44.0",
|
|
30
|
+
"@fonoster/identity": "^0.44.0",
|
|
31
|
+
"@fonoster/logger": "^0.44.0",
|
|
32
|
+
"@fonoster/sipnet": "^0.44.0",
|
|
33
|
+
"@fonoster/types": "^0.44.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": "^
|
|
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": "
|
|
70
|
+
"gitHead": "2dbe93e2d836a33e58764f12081cd1e6bb654a3e",
|
|
71
71
|
"prisma": {
|
|
72
72
|
"seed": "tsx src/core/seed.ts"
|
|
73
73
|
}
|