@krak-stack/registry 0.1.61 → 0.2.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.
- package/CHANGELOG.md +12 -0
- package/dist/components/ui/color-picker.d.ts +30 -0
- package/dist/components/ui/color-picker.js +384 -0
- package/dist/components/ui/data-table.js +26 -14
- package/dist/components/ui/effect-form.js +2 -2
- package/dist/components/ui/error-component.js +4 -12
- package/dist/components/ui/form.d.ts +126 -330
- package/dist/components/ui/google-map.js +38 -6
- package/dist/components/ui/sidebar-layout.js +10 -13
- package/dist/lib/docs.d.ts +2 -2
- package/dist/lib/docs.js +16 -19
- package/dist/lib/docs.server.js +5 -5
- package/dist/lib/documentation-toolkit.d.ts +2 -2
- package/dist/lib/documentation-toolkit.js +4 -4
- package/dist/lib/httpapi-adapter.d.ts +11 -3
- package/dist/lib/httpapi-adapter.js +40 -13
- package/dist/lib/httpapi-cli.d.ts +13 -4
- package/dist/lib/httpapi-cli.js +63 -21
- package/dist/lib/httpapi-toolkit.js +40 -13
- package/dist/lib/query.d.ts +4 -4
- package/dist/lib/query.js +2 -2
- package/dist/lib/webfetch-toolkit.js +1 -1
- package/dist/services/agent/index.js +1 -1
- package/dist/services/events/browser.js +32 -17
- package/dist/services/events/client/audit-log-table.js +26 -14
- package/dist/services/events/client/tracking-notice.js +9 -4
- package/dist/services/events/index.d.ts +3 -1
- package/dist/services/events/index.js +22 -17
- package/dist/services/events/schema.d.ts +18 -10
- package/dist/services/events/schema.js +3 -3
- package/dist/services/file-extraction/schema.d.ts +3 -1
- package/dist/services/health/api.builder.d.ts +8 -8
- package/dist/services/health/api.group.d.ts +8 -8
- package/dist/services/health/index.d.ts +10 -6
- package/dist/services/health/index.js +8 -4
- package/dist/services/health/schema.d.ts +7 -7
- package/dist/services/notification/index.js +1 -1
- package/dist/services/notification/public.js +1 -1
- package/dist/services/notification/schema.d.ts +3 -1
- package/dist/services/opentelemetry/api.js +5 -3
- package/dist/services/opentelemetry/browser.js +2 -2
- package/dist/services/opentelemetry/index.js +2 -2
- package/dist/services/opentelemetry/processor.d.ts +3 -1
- package/dist/services/opentelemetry/web-vitals.js +10 -5
- package/dist/services/s3/schema.d.ts +3 -1
- package/dist/services/speech/api.js +3 -1
- package/dist/services/speech/index.js +15 -8
- package/dist/services/speech/schema.d.ts +3 -1
- package/dist/services/speech/schema.js +3 -1
- package/dist/services/webhooks/client/delivery-table.js +26 -14
- package/dist/services/webhooks/http-client.js +1 -1
- package/dist/services/webhooks/index.js +14 -14
- package/dist/services/webhooks/receiver.d.ts +6 -2
- package/dist/services/webhooks/schema.d.ts +7 -5
- package/dist/services/webhooks/schema.js +2 -2
- package/package.json +6 -1
|
@@ -29,7 +29,9 @@ import {
|
|
|
29
29
|
// ../../src/services/opentelemetry/processor.ts
|
|
30
30
|
import { Context, Schema } from "effect";
|
|
31
31
|
|
|
32
|
-
class OtlpProcessingError extends Schema.TaggedError()("OtlpProcessingError", {
|
|
32
|
+
class OtlpProcessingError extends Schema.TaggedError()("OtlpProcessingError", {
|
|
33
|
+
status: Schema.Literals([400, 403, 409, 413, 503])
|
|
34
|
+
}) {
|
|
33
35
|
}
|
|
34
36
|
|
|
35
37
|
class OtlpLogsProcessor extends Context.Service()("krakstack/opentelemetry/OtlpLogsProcessor") {
|
|
@@ -156,7 +158,7 @@ class OtlpEvents extends Context2.Service()("krakstack/opentelemetry/Events") {
|
|
|
156
158
|
}));
|
|
157
159
|
}
|
|
158
160
|
var event = Effect2.fnUntraced(function* (name, properties, options) {
|
|
159
|
-
const decoded = yield* Schema3.
|
|
161
|
+
const decoded = yield* Schema3.decodeEffect(TelemetryEvent)({
|
|
160
162
|
name,
|
|
161
163
|
properties,
|
|
162
164
|
options
|
|
@@ -218,7 +220,7 @@ var ServerEventsLive = Layer2.unwrap(Effect3.gen(function* () {
|
|
|
218
220
|
|
|
219
221
|
class Otlp extends Context3.Service()("krakstack/opentelemetry/Otlp") {
|
|
220
222
|
static event = event;
|
|
221
|
-
static layer = Layer2.mergeAll(Layer2.succeed(this, { resource: OtlpResource2.fromConfig() }), EffectOtlp.layerFromConfig(),
|
|
223
|
+
static layer = Layer2.mergeAll(Layer2.succeed(this, { resource: OtlpResource2.fromConfig() }), ServerEventsLive).pipe(Layer2.provideMerge(EffectOtlp.layerFromConfig()), Layer2.provideMerge(OtlpExporter2.layerFlusher), Layer2.provide(OtlpSerialization2.layerJson), Layer2.provide(FetchHttpClient.layer));
|
|
222
224
|
}
|
|
223
225
|
|
|
224
226
|
// ../../src/services/events/request-context.ts
|
|
@@ -355,11 +357,11 @@ var ColumnFilters = Schema5.declare(Schema5.is(ColumnFiltersArray), {
|
|
|
355
357
|
toCodecStringTree: () => Schema5.link()(Schema5.fromJsonString(ColumnFiltersArray), SchemaTransformation.passthrough())
|
|
356
358
|
});
|
|
357
359
|
var Query = Schema5.Struct({
|
|
358
|
-
page: Schema5.optional(Schema5.Union([Schema5.
|
|
360
|
+
page: Schema5.optional(Schema5.Union([Schema5.Finite, Schema5.FiniteFromString]).check(Schema5.isInt(), Schema5.isGreaterThanOrEqualTo(0))).pipe(Schema5.decodeTo(Schema5.Int.check(Schema5.isGreaterThanOrEqualTo(0)), {
|
|
359
361
|
decode: SchemaGetter.withDefault(Effect4.succeed(0)),
|
|
360
362
|
encode: SchemaGetter.transformOptional(Option2.filter((page) => page !== 0))
|
|
361
363
|
})),
|
|
362
|
-
pageSize: Schema5.optional(Schema5.Union([Schema5.
|
|
364
|
+
pageSize: Schema5.optional(Schema5.Union([Schema5.Finite, Schema5.FiniteFromString]).check(Schema5.isInt(), Schema5.isBetween({ minimum: 1, maximum: 100 }))).pipe(Schema5.decodeTo(Schema5.Int.check(Schema5.isBetween({ minimum: 1, maximum: 100 })), {
|
|
363
365
|
decode: SchemaGetter.withDefault(Effect4.succeed(20)),
|
|
364
366
|
encode: SchemaGetter.transformOptional(Option2.filter((pageSize) => pageSize !== 20))
|
|
365
367
|
})),
|
|
@@ -403,7 +405,7 @@ var EventIdentity = Schema6.Struct({
|
|
|
403
405
|
userId: Schema6.optional(Schema6.NonEmptyString),
|
|
404
406
|
organizationId: Schema6.optional(Schema6.NonEmptyString)
|
|
405
407
|
}).annotate({ identifier: "EventIdentity" });
|
|
406
|
-
var EventIpAddress = Schema6.String.check(Schema6.makeFilter((value) => Option3.isSome(Schema6.
|
|
408
|
+
var EventIpAddress = Schema6.String.check(Schema6.makeFilter((value) => Option3.isSome(Schema6.decodeOption(Schema6.IpAddressFromString)(value)) || "Invalid IP address")).annotate({ identifier: "EventIpAddress" });
|
|
407
409
|
var EventCountry = Schema6.String.check(Schema6.isPattern(/^[A-Z]{2}$/), Schema6.makeFilter((value) => !["XX", "T1"].includes(value) || "Unknown country")).annotate({ identifier: "EventCountry" });
|
|
408
410
|
var EventRegion = Schema6.String.check(Schema6.isPattern(/^[A-Z0-9]{1,3}$/)).annotate({ identifier: "EventRegion" });
|
|
409
411
|
var EventCity = Schema6.NonEmptyString.check(Schema6.isMaxLength(128)).annotate({ identifier: "EventCity" });
|
|
@@ -665,8 +667,11 @@ var migrateEvents = Migrator.make({})({
|
|
|
665
667
|
});
|
|
666
668
|
|
|
667
669
|
// ../../src/services/opentelemetry/consent.ts
|
|
670
|
+
import * as Data from "effect/Data";
|
|
668
671
|
import { SecureRandom } from "effect/crypto";
|
|
669
672
|
import { Effect as Effect7, Option as Option5, Schema as Schema8 } from "effect";
|
|
673
|
+
class AnalyticsPreferenceStorageError extends Data.TaggedError("AnalyticsPreferenceStorageError") {
|
|
674
|
+
}
|
|
670
675
|
var ANALYTICS_CONSENT_COOKIE = "krakstack_analytics_consent";
|
|
671
676
|
var ANALYTICS_NOTICE_VERSION = "1";
|
|
672
677
|
var lifetime = 180 * 24 * 60 * 60 * 1000;
|
|
@@ -676,7 +681,7 @@ var analyticsPreference = (cookie, now = Date.now()) => {
|
|
|
676
681
|
const value = readCookie(cookie);
|
|
677
682
|
if (!value)
|
|
678
683
|
return;
|
|
679
|
-
const decoded = Schema8.
|
|
684
|
+
const decoded = Schema8.decodeOption(codec)(value);
|
|
680
685
|
if (Option5.isNone(decoded))
|
|
681
686
|
return;
|
|
682
687
|
const preference = decoded.value;
|
|
@@ -771,7 +776,7 @@ class Events extends Context4.Service()("krakstack/events/Events", {
|
|
|
771
776
|
const telemetry = yield* Otlp;
|
|
772
777
|
const exporter = yield* OtlpEvents;
|
|
773
778
|
const resource = options.serviceName ? yield* OtlpResource3.fromConfig({ serviceName: options.serviceName }) : yield* telemetry.resource;
|
|
774
|
-
const configuration = yield* Schema9.
|
|
779
|
+
const configuration = yield* Schema9.decodeEffect(Configuration)({
|
|
775
780
|
...options,
|
|
776
781
|
serviceName: OtlpResource3.serviceNameUnsafe(resource),
|
|
777
782
|
secret: Redacted.value(options.secret)
|
|
@@ -856,7 +861,7 @@ class Events extends Context4.Service()("krakstack/events/Events", {
|
|
|
856
861
|
}) : undefined;
|
|
857
862
|
const resolveGeolocation = Effect8.fnUntraced(function* (request) {
|
|
858
863
|
const location2 = configuration.geolocation === "cloudflare" ? cloudflareGeolocation(request.headers) : configuration.geolocation ? yield* configuration.geolocation(request) : null;
|
|
859
|
-
return yield* Schema9.
|
|
864
|
+
return yield* Schema9.decodeEffect(Schema9.NullOr(EventGeolocation))(location2);
|
|
860
865
|
}, Effect8.mapError(() => new EventGeolocationError({})));
|
|
861
866
|
const resolveRequestContext = Effect8.fnUntraced(function* (request, now, location2) {
|
|
862
867
|
const userAgent = request.headers["user-agent"]?.slice(0, 2048) ?? "";
|
|
@@ -915,14 +920,14 @@ class Events extends Context4.Service()("krakstack/events/Events", {
|
|
|
915
920
|
name: `HandleEventV1-${attempt}`,
|
|
916
921
|
success: Schema9.Void,
|
|
917
922
|
error: EventSubscriberError,
|
|
918
|
-
execute: definition.handle({ ...event, eventId }).pipe(Effect8.scoped, Effect8.updateContext((
|
|
923
|
+
execute: definition.handle({ ...event, eventId }).pipe(Effect8.scoped, Effect8.updateContext(() => subscriberContext), Effect8.asVoid, Effect8.mapError(() => new EventSubscriberError({
|
|
919
924
|
subscription: subscription.name
|
|
920
925
|
})))
|
|
921
926
|
}).pipe(Effect8.result);
|
|
922
927
|
if (Result.isSuccess(result))
|
|
923
928
|
return;
|
|
924
929
|
if (attempt >= 7)
|
|
925
|
-
return yield*
|
|
930
|
+
return yield* result.failure;
|
|
926
931
|
const now = yield* DateTime3.now;
|
|
927
932
|
const [, delay] = yield* step(DateTime3.toEpochMillis(now), result.failure).pipe(Effect8.orDie);
|
|
928
933
|
yield* DurableClock.sleep({
|
|
@@ -943,11 +948,11 @@ class Events extends Context4.Service()("krakstack/events/Events", {
|
|
|
943
948
|
if (subscribers.get(subscription.name) === registered)
|
|
944
949
|
subscribers.delete(subscription.name);
|
|
945
950
|
}));
|
|
946
|
-
}, registration.withPermit);
|
|
951
|
+
}, registration.withPermit.bind(registration));
|
|
947
952
|
const track = Effect8.fn("Events.track")(function* (input) {
|
|
948
|
-
const decoded = yield* Schema9.
|
|
953
|
+
const decoded = yield* Schema9.decodeEffect(TrackEventInput)(input);
|
|
949
954
|
const properties = decoded.properties === undefined ? undefined : yield* Schema9.encodeEffect(Schema9.fromJsonString(EventInputProperties))(decoded.properties).pipe(Effect8.flatMap(Schema9.decodeUnknownEffect(Schema9.fromJsonString(EventPropertiesSchema))));
|
|
950
|
-
const event = yield* Schema9.
|
|
955
|
+
const event = yield* Schema9.decodeEffect(TrackEvent)({
|
|
951
956
|
...decoded,
|
|
952
957
|
properties
|
|
953
958
|
});
|
|
@@ -1051,8 +1056,8 @@ class Events extends Context4.Service()("krakstack/events/Events", {
|
|
|
1051
1056
|
})));
|
|
1052
1057
|
});
|
|
1053
1058
|
const list = Effect8.fn("Events.list")(function* (input) {
|
|
1054
|
-
const request = yield* Schema9.
|
|
1055
|
-
const columnFilters = yield* Schema9.
|
|
1059
|
+
const request = yield* Schema9.decodeEffect(ListEvents)(input);
|
|
1060
|
+
const columnFilters = yield* Schema9.decodeEffect(Schema9.Array(EventColumnFilter))(request.filters ?? []);
|
|
1056
1061
|
if (!storage)
|
|
1057
1062
|
return yield* new EventsPersistenceError({
|
|
1058
1063
|
operation: "persistence-disabled"
|
|
@@ -1153,7 +1158,7 @@ class Events extends Context4.Service()("krakstack/events/Events", {
|
|
|
1153
1158
|
});
|
|
1154
1159
|
const process = Effect8.fnUntraced(function* (body) {
|
|
1155
1160
|
const request = yield* HttpServerRequest.HttpServerRequest;
|
|
1156
|
-
let payload = yield* Schema9.
|
|
1161
|
+
let payload = yield* Schema9.decodeEffect(codec2)(new TextDecoder().decode(body)).pipe(Effect8.mapError(() => new OtlpProcessingError({ status: 400 })));
|
|
1157
1162
|
if (options.requireConsent && !hasAnalyticsConsent(request.headers.cookie ?? "", request.headers)) {
|
|
1158
1163
|
payload = {
|
|
1159
1164
|
...payload,
|
|
@@ -18,7 +18,9 @@ export declare const EventGeolocation: Schema.Struct<{
|
|
|
18
18
|
readonly city: Schema.optional<Schema.NonEmptyString>;
|
|
19
19
|
}>;
|
|
20
20
|
export type EventGeolocation = typeof EventGeolocation.Type;
|
|
21
|
-
declare const EventGeolocationError_base: Schema.Class<EventGeolocationError, Schema.TaggedStruct<"EventGeolocationError", {}>, import("effect/Cause").YieldableError
|
|
21
|
+
declare const EventGeolocationError_base: Schema.Class<EventGeolocationError, Schema.TaggedStruct<"EventGeolocationError", {}>, import("effect/Cause").YieldableError & {
|
|
22
|
+
readonly brand: unique symbol;
|
|
23
|
+
}>;
|
|
22
24
|
export declare class EventGeolocationError extends EventGeolocationError_base {
|
|
23
25
|
}
|
|
24
26
|
export declare const BrowserEventOptions: Schema.Struct<{
|
|
@@ -114,7 +116,9 @@ export interface EventSubscriber<E = never, R = never> {
|
|
|
114
116
|
}
|
|
115
117
|
declare const EventSubscriberError_base: Schema.Class<EventSubscriberError, Schema.TaggedStruct<"EventSubscriberError", {
|
|
116
118
|
readonly subscription: Schema.String;
|
|
117
|
-
}>, import("effect/Cause").YieldableError
|
|
119
|
+
}>, import("effect/Cause").YieldableError & {
|
|
120
|
+
readonly brand: unique symbol;
|
|
121
|
+
}>;
|
|
118
122
|
export declare class EventSubscriberError extends EventSubscriberError_base {
|
|
119
123
|
}
|
|
120
124
|
export declare const EventActionFilter: Schema.Struct<{
|
|
@@ -147,8 +151,8 @@ export declare const EventColumnFilter: Schema.Union<readonly [Schema.Struct<{
|
|
|
147
151
|
readonly values: Schema.NonEmptyArray<Schema.String>;
|
|
148
152
|
}>]>;
|
|
149
153
|
export declare const EventQuery: Schema.Struct<{
|
|
150
|
-
readonly page: Schema.decodeTo<Schema.Int, Schema.optional<Schema.Union<readonly [Schema.
|
|
151
|
-
readonly pageSize: Schema.decodeTo<Schema.Int, Schema.optional<Schema.Union<readonly [Schema.
|
|
154
|
+
readonly page: Schema.decodeTo<Schema.Int, Schema.optional<Schema.Union<readonly [Schema.Finite, Schema.FiniteFromString]>>, never, never>;
|
|
155
|
+
readonly pageSize: Schema.decodeTo<Schema.Int, Schema.optional<Schema.Union<readonly [Schema.Finite, Schema.FiniteFromString]>>, never, never>;
|
|
152
156
|
readonly globalFilter: Schema.optional<Schema.String>;
|
|
153
157
|
readonly sort: Schema.optional<Schema.declare<readonly {
|
|
154
158
|
readonly id: string;
|
|
@@ -275,8 +279,8 @@ export declare const EventQueryStandard: import("effect/StandardSchema").Standar
|
|
|
275
279
|
})[] | undefined;
|
|
276
280
|
readonly eventName?: string | undefined;
|
|
277
281
|
}> & Schema.Struct<{
|
|
278
|
-
readonly page: Schema.decodeTo<Schema.Int, Schema.optional<Schema.Union<readonly [Schema.
|
|
279
|
-
readonly pageSize: Schema.decodeTo<Schema.Int, Schema.optional<Schema.Union<readonly [Schema.
|
|
282
|
+
readonly page: Schema.decodeTo<Schema.Int, Schema.optional<Schema.Union<readonly [Schema.Finite, Schema.FiniteFromString]>>, never, never>;
|
|
283
|
+
readonly pageSize: Schema.decodeTo<Schema.Int, Schema.optional<Schema.Union<readonly [Schema.Finite, Schema.FiniteFromString]>>, never, never>;
|
|
280
284
|
readonly globalFilter: Schema.optional<Schema.String>;
|
|
281
285
|
readonly sort: Schema.optional<Schema.declare<readonly {
|
|
282
286
|
readonly id: string;
|
|
@@ -336,8 +340,8 @@ export declare const EventQueryStandard: import("effect/StandardSchema").Standar
|
|
|
336
340
|
readonly eventName: Schema.optional<Schema.NonEmptyString>;
|
|
337
341
|
}>;
|
|
338
342
|
export declare const ListEvents: Schema.Struct<{
|
|
339
|
-
readonly page: Schema.decodeTo<Schema.Int, Schema.optional<Schema.Union<readonly [Schema.
|
|
340
|
-
readonly pageSize: Schema.decodeTo<Schema.Int, Schema.optional<Schema.Union<readonly [Schema.
|
|
343
|
+
readonly page: Schema.decodeTo<Schema.Int, Schema.optional<Schema.Union<readonly [Schema.Finite, Schema.FiniteFromString]>>, never, never>;
|
|
344
|
+
readonly pageSize: Schema.decodeTo<Schema.Int, Schema.optional<Schema.Union<readonly [Schema.Finite, Schema.FiniteFromString]>>, never, never>;
|
|
341
345
|
readonly globalFilter: Schema.optional<Schema.String>;
|
|
342
346
|
readonly sort: Schema.optional<Schema.declare<readonly {
|
|
343
347
|
readonly id: string;
|
|
@@ -419,12 +423,16 @@ export declare const RequestActorAttribution: Schema.Struct<{
|
|
|
419
423
|
}>;
|
|
420
424
|
declare const EventsPersistenceError_base: Schema.Class<EventsPersistenceError, Schema.TaggedStruct<"EventsPersistenceError", {
|
|
421
425
|
readonly operation: Schema.String;
|
|
422
|
-
}>, import("effect/Cause").YieldableError
|
|
426
|
+
}>, import("effect/Cause").YieldableError & {
|
|
427
|
+
readonly brand: unique symbol;
|
|
428
|
+
}>;
|
|
423
429
|
export declare class EventsPersistenceError extends EventsPersistenceError_base {
|
|
424
430
|
}
|
|
425
431
|
declare const EventConflictError_base: Schema.Class<EventConflictError, Schema.TaggedStruct<"EventConflictError", {
|
|
426
432
|
readonly eventId: Schema.NonEmptyString;
|
|
427
|
-
}>, import("effect/Cause").YieldableError
|
|
433
|
+
}>, import("effect/Cause").YieldableError & {
|
|
434
|
+
readonly brand: unique symbol;
|
|
435
|
+
}>;
|
|
428
436
|
export declare class EventConflictError extends EventConflictError_base {
|
|
429
437
|
}
|
|
430
438
|
export declare const EventSource: Schema.Literals<readonly ["browser", "server"]>;
|
|
@@ -179,11 +179,11 @@ var ColumnFilters = Schema2.declare(Schema2.is(ColumnFiltersArray), {
|
|
|
179
179
|
toCodecStringTree: () => Schema2.link()(Schema2.fromJsonString(ColumnFiltersArray), SchemaTransformation.passthrough())
|
|
180
180
|
});
|
|
181
181
|
var Query = Schema2.Struct({
|
|
182
|
-
page: Schema2.optional(Schema2.Union([Schema2.
|
|
182
|
+
page: Schema2.optional(Schema2.Union([Schema2.Finite, Schema2.FiniteFromString]).check(Schema2.isInt(), Schema2.isGreaterThanOrEqualTo(0))).pipe(Schema2.decodeTo(Schema2.Int.check(Schema2.isGreaterThanOrEqualTo(0)), {
|
|
183
183
|
decode: SchemaGetter.withDefault(Effect.succeed(0)),
|
|
184
184
|
encode: SchemaGetter.transformOptional(Option.filter((page) => page !== 0))
|
|
185
185
|
})),
|
|
186
|
-
pageSize: Schema2.optional(Schema2.Union([Schema2.
|
|
186
|
+
pageSize: Schema2.optional(Schema2.Union([Schema2.Finite, Schema2.FiniteFromString]).check(Schema2.isInt(), Schema2.isBetween({ minimum: 1, maximum: 100 }))).pipe(Schema2.decodeTo(Schema2.Int.check(Schema2.isBetween({ minimum: 1, maximum: 100 })), {
|
|
187
187
|
decode: SchemaGetter.withDefault(Effect.succeed(20)),
|
|
188
188
|
encode: SchemaGetter.transformOptional(Option.filter((pageSize) => pageSize !== 20))
|
|
189
189
|
})),
|
|
@@ -227,7 +227,7 @@ var EventIdentity = Schema3.Struct({
|
|
|
227
227
|
userId: Schema3.optional(Schema3.NonEmptyString),
|
|
228
228
|
organizationId: Schema3.optional(Schema3.NonEmptyString)
|
|
229
229
|
}).annotate({ identifier: "EventIdentity" });
|
|
230
|
-
var EventIpAddress = Schema3.String.check(Schema3.makeFilter((value) => Option2.isSome(Schema3.
|
|
230
|
+
var EventIpAddress = Schema3.String.check(Schema3.makeFilter((value) => Option2.isSome(Schema3.decodeOption(Schema3.IpAddressFromString)(value)) || "Invalid IP address")).annotate({ identifier: "EventIpAddress" });
|
|
231
231
|
var EventCountry = Schema3.String.check(Schema3.isPattern(/^[A-Z]{2}$/), Schema3.makeFilter((value) => !["XX", "T1"].includes(value) || "Unknown country")).annotate({ identifier: "EventCountry" });
|
|
232
232
|
var EventRegion = Schema3.String.check(Schema3.isPattern(/^[A-Z0-9]{1,3}$/)).annotate({ identifier: "EventRegion" });
|
|
233
233
|
var EventCity = Schema3.NonEmptyString.check(Schema3.isMaxLength(128)).annotate({ identifier: "EventCity" });
|
|
@@ -7,7 +7,9 @@ export declare const FileExtractedTextSchema: Schema.Struct<{
|
|
|
7
7
|
export type FileExtractedText = typeof FileExtractedTextSchema.Type;
|
|
8
8
|
declare const FileExtractionFailed_base: Schema.Class<FileExtractionFailed, Schema.TaggedStruct<"FileExtractionFailed", {
|
|
9
9
|
readonly message: Schema.String;
|
|
10
|
-
}>, import("effect/Cause").YieldableError
|
|
10
|
+
}>, import("effect/Cause").YieldableError & {
|
|
11
|
+
readonly brand: unique symbol;
|
|
12
|
+
}>;
|
|
11
13
|
export declare class FileExtractionFailed extends FileExtractionFailed_base {
|
|
12
14
|
}
|
|
13
15
|
export {};
|
|
@@ -8,14 +8,14 @@ export declare const healthHandler: <const Prefix extends HttpRouter.PathInput>(
|
|
|
8
8
|
readonly checks: import("effect/Schema").$Array<import("effect/Schema").Struct<{
|
|
9
9
|
readonly name: import("effect/Schema").NonEmptyString;
|
|
10
10
|
readonly status: import("effect/Schema").Literals<readonly ["UP", "DOWN"]>;
|
|
11
|
-
readonly data: import("effect/Schema").optionalKey<import("effect/Schema").$Record<import("effect/Schema").String, import("effect/Schema").Union<readonly [import("effect/Schema").String, import("effect/Schema").Boolean, import("effect/Schema").
|
|
11
|
+
readonly data: import("effect/Schema").optionalKey<import("effect/Schema").$Record<import("effect/Schema").String, import("effect/Schema").Union<readonly [import("effect/Schema").String, import("effect/Schema").Boolean, import("effect/Schema").Finite]>>>;
|
|
12
12
|
}>>;
|
|
13
13
|
}>>, import("effect/Schema").toCodecJson<import("effect/Schema").Struct<{
|
|
14
14
|
readonly status: import("effect/Schema").Literal<"DOWN">;
|
|
15
15
|
readonly checks: import("effect/Schema").$Array<import("effect/Schema").Struct<{
|
|
16
16
|
readonly name: import("effect/Schema").NonEmptyString;
|
|
17
17
|
readonly status: import("effect/Schema").Literals<readonly ["UP", "DOWN"]>;
|
|
18
|
-
readonly data: import("effect/Schema").optionalKey<import("effect/Schema").$Record<import("effect/Schema").String, import("effect/Schema").Union<readonly [import("effect/Schema").String, import("effect/Schema").Boolean, import("effect/Schema").
|
|
18
|
+
readonly data: import("effect/Schema").optionalKey<import("effect/Schema").$Record<import("effect/Schema").String, import("effect/Schema").Union<readonly [import("effect/Schema").String, import("effect/Schema").Boolean, import("effect/Schema").Finite]>>>;
|
|
19
19
|
}>>;
|
|
20
20
|
}> | typeof import("effect/http-api/HttpApiError").InternalServerError>, never, never>;
|
|
21
21
|
readonly getLiveness: import("effect/http-api/HttpApiEndpoint").HttpApiEndpoint<"getLiveness", "GET", `${Prefix}/health/live`, never, never, never, never, import("effect/Schema").toCodecJson<import("effect/Schema").Struct<{
|
|
@@ -23,14 +23,14 @@ export declare const healthHandler: <const Prefix extends HttpRouter.PathInput>(
|
|
|
23
23
|
readonly checks: import("effect/Schema").$Array<import("effect/Schema").Struct<{
|
|
24
24
|
readonly name: import("effect/Schema").NonEmptyString;
|
|
25
25
|
readonly status: import("effect/Schema").Literals<readonly ["UP", "DOWN"]>;
|
|
26
|
-
readonly data: import("effect/Schema").optionalKey<import("effect/Schema").$Record<import("effect/Schema").String, import("effect/Schema").Union<readonly [import("effect/Schema").String, import("effect/Schema").Boolean, import("effect/Schema").
|
|
26
|
+
readonly data: import("effect/Schema").optionalKey<import("effect/Schema").$Record<import("effect/Schema").String, import("effect/Schema").Union<readonly [import("effect/Schema").String, import("effect/Schema").Boolean, import("effect/Schema").Finite]>>>;
|
|
27
27
|
}>>;
|
|
28
28
|
}>>, import("effect/Schema").toCodecJson<import("effect/Schema").Struct<{
|
|
29
29
|
readonly status: import("effect/Schema").Literal<"DOWN">;
|
|
30
30
|
readonly checks: import("effect/Schema").$Array<import("effect/Schema").Struct<{
|
|
31
31
|
readonly name: import("effect/Schema").NonEmptyString;
|
|
32
32
|
readonly status: import("effect/Schema").Literals<readonly ["UP", "DOWN"]>;
|
|
33
|
-
readonly data: import("effect/Schema").optionalKey<import("effect/Schema").$Record<import("effect/Schema").String, import("effect/Schema").Union<readonly [import("effect/Schema").String, import("effect/Schema").Boolean, import("effect/Schema").
|
|
33
|
+
readonly data: import("effect/Schema").optionalKey<import("effect/Schema").$Record<import("effect/Schema").String, import("effect/Schema").Union<readonly [import("effect/Schema").String, import("effect/Schema").Boolean, import("effect/Schema").Finite]>>>;
|
|
34
34
|
}>>;
|
|
35
35
|
}> | typeof import("effect/http-api/HttpApiError").InternalServerError>, never, never>;
|
|
36
36
|
readonly getReadiness: import("effect/http-api/HttpApiEndpoint").HttpApiEndpoint<"getReadiness", "GET", `${Prefix}/health/ready`, never, never, never, never, import("effect/Schema").toCodecJson<import("effect/Schema").Struct<{
|
|
@@ -38,14 +38,14 @@ export declare const healthHandler: <const Prefix extends HttpRouter.PathInput>(
|
|
|
38
38
|
readonly checks: import("effect/Schema").$Array<import("effect/Schema").Struct<{
|
|
39
39
|
readonly name: import("effect/Schema").NonEmptyString;
|
|
40
40
|
readonly status: import("effect/Schema").Literals<readonly ["UP", "DOWN"]>;
|
|
41
|
-
readonly data: import("effect/Schema").optionalKey<import("effect/Schema").$Record<import("effect/Schema").String, import("effect/Schema").Union<readonly [import("effect/Schema").String, import("effect/Schema").Boolean, import("effect/Schema").
|
|
41
|
+
readonly data: import("effect/Schema").optionalKey<import("effect/Schema").$Record<import("effect/Schema").String, import("effect/Schema").Union<readonly [import("effect/Schema").String, import("effect/Schema").Boolean, import("effect/Schema").Finite]>>>;
|
|
42
42
|
}>>;
|
|
43
43
|
}>>, import("effect/Schema").toCodecJson<import("effect/Schema").Struct<{
|
|
44
44
|
readonly status: import("effect/Schema").Literal<"DOWN">;
|
|
45
45
|
readonly checks: import("effect/Schema").$Array<import("effect/Schema").Struct<{
|
|
46
46
|
readonly name: import("effect/Schema").NonEmptyString;
|
|
47
47
|
readonly status: import("effect/Schema").Literals<readonly ["UP", "DOWN"]>;
|
|
48
|
-
readonly data: import("effect/Schema").optionalKey<import("effect/Schema").$Record<import("effect/Schema").String, import("effect/Schema").Union<readonly [import("effect/Schema").String, import("effect/Schema").Boolean, import("effect/Schema").
|
|
48
|
+
readonly data: import("effect/Schema").optionalKey<import("effect/Schema").$Record<import("effect/Schema").String, import("effect/Schema").Union<readonly [import("effect/Schema").String, import("effect/Schema").Boolean, import("effect/Schema").Finite]>>>;
|
|
49
49
|
}>>;
|
|
50
50
|
}> | typeof import("effect/http-api/HttpApiError").InternalServerError>, never, never>;
|
|
51
51
|
readonly getStartup: import("effect/http-api/HttpApiEndpoint").HttpApiEndpoint<"getStartup", "GET", `${Prefix}/health/started`, never, never, never, never, import("effect/Schema").toCodecJson<import("effect/Schema").Struct<{
|
|
@@ -53,14 +53,14 @@ export declare const healthHandler: <const Prefix extends HttpRouter.PathInput>(
|
|
|
53
53
|
readonly checks: import("effect/Schema").$Array<import("effect/Schema").Struct<{
|
|
54
54
|
readonly name: import("effect/Schema").NonEmptyString;
|
|
55
55
|
readonly status: import("effect/Schema").Literals<readonly ["UP", "DOWN"]>;
|
|
56
|
-
readonly data: import("effect/Schema").optionalKey<import("effect/Schema").$Record<import("effect/Schema").String, import("effect/Schema").Union<readonly [import("effect/Schema").String, import("effect/Schema").Boolean, import("effect/Schema").
|
|
56
|
+
readonly data: import("effect/Schema").optionalKey<import("effect/Schema").$Record<import("effect/Schema").String, import("effect/Schema").Union<readonly [import("effect/Schema").String, import("effect/Schema").Boolean, import("effect/Schema").Finite]>>>;
|
|
57
57
|
}>>;
|
|
58
58
|
}>>, import("effect/Schema").toCodecJson<import("effect/Schema").Struct<{
|
|
59
59
|
readonly status: import("effect/Schema").Literal<"DOWN">;
|
|
60
60
|
readonly checks: import("effect/Schema").$Array<import("effect/Schema").Struct<{
|
|
61
61
|
readonly name: import("effect/Schema").NonEmptyString;
|
|
62
62
|
readonly status: import("effect/Schema").Literals<readonly ["UP", "DOWN"]>;
|
|
63
|
-
readonly data: import("effect/Schema").optionalKey<import("effect/Schema").$Record<import("effect/Schema").String, import("effect/Schema").Union<readonly [import("effect/Schema").String, import("effect/Schema").Boolean, import("effect/Schema").
|
|
63
|
+
readonly data: import("effect/Schema").optionalKey<import("effect/Schema").$Record<import("effect/Schema").String, import("effect/Schema").Union<readonly [import("effect/Schema").String, import("effect/Schema").Boolean, import("effect/Schema").Finite]>>>;
|
|
64
64
|
}>>;
|
|
65
65
|
}> | typeof import("effect/http-api/HttpApiError").InternalServerError>, never, never>;
|
|
66
66
|
}, "getHealth" | "getLiveness" | "getReadiness" | "getStartup">;
|
|
@@ -4,55 +4,55 @@ export declare const HealthApiGroup: HttpApiGroup.HttpApiGroup<"health", HttpApi
|
|
|
4
4
|
readonly checks: import("effect/Schema").$Array<import("effect/Schema").Struct<{
|
|
5
5
|
readonly name: import("effect/Schema").NonEmptyString;
|
|
6
6
|
readonly status: import("effect/Schema").Literals<readonly ["UP", "DOWN"]>;
|
|
7
|
-
readonly data: import("effect/Schema").optionalKey<import("effect/Schema").$Record<import("effect/Schema").String, import("effect/Schema").Union<readonly [import("effect/Schema").String, import("effect/Schema").Boolean, import("effect/Schema").
|
|
7
|
+
readonly data: import("effect/Schema").optionalKey<import("effect/Schema").$Record<import("effect/Schema").String, import("effect/Schema").Union<readonly [import("effect/Schema").String, import("effect/Schema").Boolean, import("effect/Schema").Finite]>>>;
|
|
8
8
|
}>>;
|
|
9
9
|
}>>, import("effect/Schema").toCodecJson<import("effect/Schema").Struct<{
|
|
10
10
|
readonly status: import("effect/Schema").Literal<"DOWN">;
|
|
11
11
|
readonly checks: import("effect/Schema").$Array<import("effect/Schema").Struct<{
|
|
12
12
|
readonly name: import("effect/Schema").NonEmptyString;
|
|
13
13
|
readonly status: import("effect/Schema").Literals<readonly ["UP", "DOWN"]>;
|
|
14
|
-
readonly data: import("effect/Schema").optionalKey<import("effect/Schema").$Record<import("effect/Schema").String, import("effect/Schema").Union<readonly [import("effect/Schema").String, import("effect/Schema").Boolean, import("effect/Schema").
|
|
14
|
+
readonly data: import("effect/Schema").optionalKey<import("effect/Schema").$Record<import("effect/Schema").String, import("effect/Schema").Union<readonly [import("effect/Schema").String, import("effect/Schema").Boolean, import("effect/Schema").Finite]>>>;
|
|
15
15
|
}>>;
|
|
16
16
|
}> | typeof HttpApiError.InternalServerError>, never, never> | HttpApiEndpoint.HttpApiEndpoint<"getLiveness", "GET", "/health/live", never, never, never, never, import("effect/Schema").toCodecJson<import("effect/Schema").Struct<{
|
|
17
17
|
readonly status: import("effect/Schema").Literal<"UP">;
|
|
18
18
|
readonly checks: import("effect/Schema").$Array<import("effect/Schema").Struct<{
|
|
19
19
|
readonly name: import("effect/Schema").NonEmptyString;
|
|
20
20
|
readonly status: import("effect/Schema").Literals<readonly ["UP", "DOWN"]>;
|
|
21
|
-
readonly data: import("effect/Schema").optionalKey<import("effect/Schema").$Record<import("effect/Schema").String, import("effect/Schema").Union<readonly [import("effect/Schema").String, import("effect/Schema").Boolean, import("effect/Schema").
|
|
21
|
+
readonly data: import("effect/Schema").optionalKey<import("effect/Schema").$Record<import("effect/Schema").String, import("effect/Schema").Union<readonly [import("effect/Schema").String, import("effect/Schema").Boolean, import("effect/Schema").Finite]>>>;
|
|
22
22
|
}>>;
|
|
23
23
|
}>>, import("effect/Schema").toCodecJson<import("effect/Schema").Struct<{
|
|
24
24
|
readonly status: import("effect/Schema").Literal<"DOWN">;
|
|
25
25
|
readonly checks: import("effect/Schema").$Array<import("effect/Schema").Struct<{
|
|
26
26
|
readonly name: import("effect/Schema").NonEmptyString;
|
|
27
27
|
readonly status: import("effect/Schema").Literals<readonly ["UP", "DOWN"]>;
|
|
28
|
-
readonly data: import("effect/Schema").optionalKey<import("effect/Schema").$Record<import("effect/Schema").String, import("effect/Schema").Union<readonly [import("effect/Schema").String, import("effect/Schema").Boolean, import("effect/Schema").
|
|
28
|
+
readonly data: import("effect/Schema").optionalKey<import("effect/Schema").$Record<import("effect/Schema").String, import("effect/Schema").Union<readonly [import("effect/Schema").String, import("effect/Schema").Boolean, import("effect/Schema").Finite]>>>;
|
|
29
29
|
}>>;
|
|
30
30
|
}> | typeof HttpApiError.InternalServerError>, never, never> | HttpApiEndpoint.HttpApiEndpoint<"getReadiness", "GET", "/health/ready", never, never, never, never, import("effect/Schema").toCodecJson<import("effect/Schema").Struct<{
|
|
31
31
|
readonly status: import("effect/Schema").Literal<"UP">;
|
|
32
32
|
readonly checks: import("effect/Schema").$Array<import("effect/Schema").Struct<{
|
|
33
33
|
readonly name: import("effect/Schema").NonEmptyString;
|
|
34
34
|
readonly status: import("effect/Schema").Literals<readonly ["UP", "DOWN"]>;
|
|
35
|
-
readonly data: import("effect/Schema").optionalKey<import("effect/Schema").$Record<import("effect/Schema").String, import("effect/Schema").Union<readonly [import("effect/Schema").String, import("effect/Schema").Boolean, import("effect/Schema").
|
|
35
|
+
readonly data: import("effect/Schema").optionalKey<import("effect/Schema").$Record<import("effect/Schema").String, import("effect/Schema").Union<readonly [import("effect/Schema").String, import("effect/Schema").Boolean, import("effect/Schema").Finite]>>>;
|
|
36
36
|
}>>;
|
|
37
37
|
}>>, import("effect/Schema").toCodecJson<import("effect/Schema").Struct<{
|
|
38
38
|
readonly status: import("effect/Schema").Literal<"DOWN">;
|
|
39
39
|
readonly checks: import("effect/Schema").$Array<import("effect/Schema").Struct<{
|
|
40
40
|
readonly name: import("effect/Schema").NonEmptyString;
|
|
41
41
|
readonly status: import("effect/Schema").Literals<readonly ["UP", "DOWN"]>;
|
|
42
|
-
readonly data: import("effect/Schema").optionalKey<import("effect/Schema").$Record<import("effect/Schema").String, import("effect/Schema").Union<readonly [import("effect/Schema").String, import("effect/Schema").Boolean, import("effect/Schema").
|
|
42
|
+
readonly data: import("effect/Schema").optionalKey<import("effect/Schema").$Record<import("effect/Schema").String, import("effect/Schema").Union<readonly [import("effect/Schema").String, import("effect/Schema").Boolean, import("effect/Schema").Finite]>>>;
|
|
43
43
|
}>>;
|
|
44
44
|
}> | typeof HttpApiError.InternalServerError>, never, never> | HttpApiEndpoint.HttpApiEndpoint<"getStartup", "GET", "/health/started", never, never, never, never, import("effect/Schema").toCodecJson<import("effect/Schema").Struct<{
|
|
45
45
|
readonly status: import("effect/Schema").Literal<"UP">;
|
|
46
46
|
readonly checks: import("effect/Schema").$Array<import("effect/Schema").Struct<{
|
|
47
47
|
readonly name: import("effect/Schema").NonEmptyString;
|
|
48
48
|
readonly status: import("effect/Schema").Literals<readonly ["UP", "DOWN"]>;
|
|
49
|
-
readonly data: import("effect/Schema").optionalKey<import("effect/Schema").$Record<import("effect/Schema").String, import("effect/Schema").Union<readonly [import("effect/Schema").String, import("effect/Schema").Boolean, import("effect/Schema").
|
|
49
|
+
readonly data: import("effect/Schema").optionalKey<import("effect/Schema").$Record<import("effect/Schema").String, import("effect/Schema").Union<readonly [import("effect/Schema").String, import("effect/Schema").Boolean, import("effect/Schema").Finite]>>>;
|
|
50
50
|
}>>;
|
|
51
51
|
}>>, import("effect/Schema").toCodecJson<import("effect/Schema").Struct<{
|
|
52
52
|
readonly status: import("effect/Schema").Literal<"DOWN">;
|
|
53
53
|
readonly checks: import("effect/Schema").$Array<import("effect/Schema").Struct<{
|
|
54
54
|
readonly name: import("effect/Schema").NonEmptyString;
|
|
55
55
|
readonly status: import("effect/Schema").Literals<readonly ["UP", "DOWN"]>;
|
|
56
|
-
readonly data: import("effect/Schema").optionalKey<import("effect/Schema").$Record<import("effect/Schema").String, import("effect/Schema").Union<readonly [import("effect/Schema").String, import("effect/Schema").Boolean, import("effect/Schema").
|
|
56
|
+
readonly data: import("effect/Schema").optionalKey<import("effect/Schema").$Record<import("effect/Schema").String, import("effect/Schema").Union<readonly [import("effect/Schema").String, import("effect/Schema").Boolean, import("effect/Schema").Finite]>>>;
|
|
57
57
|
}>>;
|
|
58
58
|
}> | typeof HttpApiError.InternalServerError>, never, never>, false>;
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { Context, Effect, Layer } from "effect";
|
|
1
|
+
import { Context, Effect, Exit, Layer } from "effect";
|
|
2
2
|
import type { HealthCheckData, HealthCheckOutcome } from "./schema.js";
|
|
3
|
-
export type HealthCheck<Requirements = never> = {
|
|
3
|
+
export type HealthCheck<Requirements = never, E = unknown> = {
|
|
4
4
|
readonly name: string;
|
|
5
|
-
readonly check: Effect.Effect<HealthCheckOutcome,
|
|
5
|
+
readonly check: Effect.Effect<HealthCheckOutcome, E, Requirements>;
|
|
6
6
|
};
|
|
7
7
|
export type HealthServiceChecks<Requirements = never> = {
|
|
8
8
|
readonly live?: ReadonlyArray<HealthCheck<Requirements>>;
|
|
@@ -12,10 +12,14 @@ export type HealthServiceChecks<Requirements = never> = {
|
|
|
12
12
|
export type HealthServiceOptions<Requirements = never> = {
|
|
13
13
|
readonly checks?: HealthServiceChecks<Requirements>;
|
|
14
14
|
};
|
|
15
|
+
type RegisteredHealthCheck = {
|
|
16
|
+
readonly name: string;
|
|
17
|
+
readonly check: Effect.Effect<Exit.Exit<HealthCheckOutcome, unknown>>;
|
|
18
|
+
};
|
|
15
19
|
type RegisteredHealthChecks = {
|
|
16
|
-
readonly live: ReadonlyArray<
|
|
17
|
-
readonly ready: ReadonlyArray<
|
|
18
|
-
readonly started: ReadonlyArray<
|
|
20
|
+
readonly live: ReadonlyArray<RegisteredHealthCheck>;
|
|
21
|
+
readonly ready: ReadonlyArray<RegisteredHealthCheck>;
|
|
22
|
+
readonly started: ReadonlyArray<RegisteredHealthCheck>;
|
|
19
23
|
};
|
|
20
24
|
declare const HealthServiceConfig_base: Context.ServiceClass<HealthServiceConfig, "@krak-stack/registry/HealthServiceConfig", RegisteredHealthChecks>;
|
|
21
25
|
declare class HealthServiceConfig extends HealthServiceConfig_base {
|
|
@@ -3,7 +3,11 @@ import { Context, Effect as Effect2, Exit, Layer } from "effect";
|
|
|
3
3
|
|
|
4
4
|
// ../../src/services/health/api.builder.ts
|
|
5
5
|
import { Effect } from "effect";
|
|
6
|
-
var respond = (check) => check.pipe(Effect.flatMap((response) =>
|
|
6
|
+
var respond = (check) => check.pipe(Effect.flatMap((response) => Effect.gen(function* () {
|
|
7
|
+
if (response.status === "DOWN")
|
|
8
|
+
return yield* Effect.fail(response);
|
|
9
|
+
return response;
|
|
10
|
+
})));
|
|
7
11
|
var healthHandler = (handlers) => handlers.handle("getHealth", () => Effect.flatMap(HealthService, ({ aggregate }) => respond(aggregate()))).handle("getLiveness", () => Effect.flatMap(HealthService, ({ live }) => respond(live()))).handle("getReadiness", () => Effect.flatMap(HealthService, ({ ready }) => respond(ready()))).handle("getStartup", () => Effect.flatMap(HealthService, ({ started }) => respond(started())));
|
|
8
12
|
// ../../src/services/health/api.group.ts
|
|
9
13
|
import {
|
|
@@ -21,7 +25,7 @@ var HealthStatus = Schema.Literals(["UP", "DOWN"]).annotate({
|
|
|
21
25
|
title: "Health Status",
|
|
22
26
|
description: "Whether a health check is up or down"
|
|
23
27
|
});
|
|
24
|
-
var HealthCheckData = Schema.Record(Schema.String, Schema.Union([Schema.String, Schema.Boolean, Schema.
|
|
28
|
+
var HealthCheckData = Schema.Record(Schema.String, Schema.Union([Schema.String, Schema.Boolean, Schema.Finite])).annotate({
|
|
25
29
|
identifier: "HealthCheckData",
|
|
26
30
|
title: "Health Check Data",
|
|
27
31
|
description: "Non-sensitive diagnostic values for a health check"
|
|
@@ -114,7 +118,7 @@ class HealthServiceConfig extends Context.Service()("@krak-stack/registry/Health
|
|
|
114
118
|
const services = yield* Effect2.context();
|
|
115
119
|
const resolve = (registered) => (registered ?? []).map(({ name, check }) => ({
|
|
116
120
|
name,
|
|
117
|
-
check: Effect2.provide(
|
|
121
|
+
check: Effect2.exit(check).pipe(Effect2.provide(services))
|
|
118
122
|
}));
|
|
119
123
|
return {
|
|
120
124
|
live: resolve(checks.live),
|
|
@@ -129,7 +133,7 @@ class HealthService extends Context.Service()("@krak-stack/registry/HealthServic
|
|
|
129
133
|
const checks = yield* HealthServiceConfig;
|
|
130
134
|
const allChecks = Array.from(new Set([...checks.live, ...checks.ready, ...checks.started]));
|
|
131
135
|
const execute = Effect2.fn("HealthService.execute")(function* (healthCheck) {
|
|
132
|
-
const exit = yield*
|
|
136
|
+
const exit = yield* healthCheck.check;
|
|
133
137
|
if (!Exit.isSuccess(exit)) {
|
|
134
138
|
return {
|
|
135
139
|
name: healthCheck.name,
|
|
@@ -1,17 +1,17 @@
|
|
|
1
1
|
import { Schema } from "effect";
|
|
2
2
|
export declare const HealthStatus: Schema.Literals<readonly ["UP", "DOWN"]>;
|
|
3
3
|
export type HealthStatus = typeof HealthStatus.Type;
|
|
4
|
-
export declare const HealthCheckData: Schema.$Record<Schema.String, Schema.Union<readonly [Schema.String, Schema.Boolean, Schema.
|
|
4
|
+
export declare const HealthCheckData: Schema.$Record<Schema.String, Schema.Union<readonly [Schema.String, Schema.Boolean, Schema.Finite]>>;
|
|
5
5
|
export type HealthCheckData = typeof HealthCheckData.Type;
|
|
6
6
|
export declare const HealthCheckOutcome: Schema.Struct<{
|
|
7
7
|
readonly status: Schema.Literals<readonly ["UP", "DOWN"]>;
|
|
8
|
-
readonly data: Schema.optionalKey<Schema.$Record<Schema.String, Schema.Union<readonly [Schema.String, Schema.Boolean, Schema.
|
|
8
|
+
readonly data: Schema.optionalKey<Schema.$Record<Schema.String, Schema.Union<readonly [Schema.String, Schema.Boolean, Schema.Finite]>>>;
|
|
9
9
|
}>;
|
|
10
10
|
export type HealthCheckOutcome = typeof HealthCheckOutcome.Type;
|
|
11
11
|
export declare const HealthCheckResult: Schema.Struct<{
|
|
12
12
|
readonly name: Schema.NonEmptyString;
|
|
13
13
|
readonly status: Schema.Literals<readonly ["UP", "DOWN"]>;
|
|
14
|
-
readonly data: Schema.optionalKey<Schema.$Record<Schema.String, Schema.Union<readonly [Schema.String, Schema.Boolean, Schema.
|
|
14
|
+
readonly data: Schema.optionalKey<Schema.$Record<Schema.String, Schema.Union<readonly [Schema.String, Schema.Boolean, Schema.Finite]>>>;
|
|
15
15
|
}>;
|
|
16
16
|
export type HealthCheckResult = typeof HealthCheckResult.Type;
|
|
17
17
|
export declare const HealthUpResponse: Schema.Struct<{
|
|
@@ -19,7 +19,7 @@ export declare const HealthUpResponse: Schema.Struct<{
|
|
|
19
19
|
readonly checks: Schema.$Array<Schema.Struct<{
|
|
20
20
|
readonly name: Schema.NonEmptyString;
|
|
21
21
|
readonly status: Schema.Literals<readonly ["UP", "DOWN"]>;
|
|
22
|
-
readonly data: Schema.optionalKey<Schema.$Record<Schema.String, Schema.Union<readonly [Schema.String, Schema.Boolean, Schema.
|
|
22
|
+
readonly data: Schema.optionalKey<Schema.$Record<Schema.String, Schema.Union<readonly [Schema.String, Schema.Boolean, Schema.Finite]>>>;
|
|
23
23
|
}>>;
|
|
24
24
|
}>;
|
|
25
25
|
export type HealthUpResponse = typeof HealthUpResponse.Type;
|
|
@@ -28,7 +28,7 @@ export declare const HealthDownResponse: Schema.Struct<{
|
|
|
28
28
|
readonly checks: Schema.$Array<Schema.Struct<{
|
|
29
29
|
readonly name: Schema.NonEmptyString;
|
|
30
30
|
readonly status: Schema.Literals<readonly ["UP", "DOWN"]>;
|
|
31
|
-
readonly data: Schema.optionalKey<Schema.$Record<Schema.String, Schema.Union<readonly [Schema.String, Schema.Boolean, Schema.
|
|
31
|
+
readonly data: Schema.optionalKey<Schema.$Record<Schema.String, Schema.Union<readonly [Schema.String, Schema.Boolean, Schema.Finite]>>>;
|
|
32
32
|
}>>;
|
|
33
33
|
}>;
|
|
34
34
|
export type HealthDownResponse = typeof HealthDownResponse.Type;
|
|
@@ -37,14 +37,14 @@ export declare const HealthResponse: Schema.Union<readonly [Schema.Struct<{
|
|
|
37
37
|
readonly checks: Schema.$Array<Schema.Struct<{
|
|
38
38
|
readonly name: Schema.NonEmptyString;
|
|
39
39
|
readonly status: Schema.Literals<readonly ["UP", "DOWN"]>;
|
|
40
|
-
readonly data: Schema.optionalKey<Schema.$Record<Schema.String, Schema.Union<readonly [Schema.String, Schema.Boolean, Schema.
|
|
40
|
+
readonly data: Schema.optionalKey<Schema.$Record<Schema.String, Schema.Union<readonly [Schema.String, Schema.Boolean, Schema.Finite]>>>;
|
|
41
41
|
}>>;
|
|
42
42
|
}>, Schema.Struct<{
|
|
43
43
|
readonly status: Schema.Literal<"DOWN">;
|
|
44
44
|
readonly checks: Schema.$Array<Schema.Struct<{
|
|
45
45
|
readonly name: Schema.NonEmptyString;
|
|
46
46
|
readonly status: Schema.Literals<readonly ["UP", "DOWN"]>;
|
|
47
|
-
readonly data: Schema.optionalKey<Schema.$Record<Schema.String, Schema.Union<readonly [Schema.String, Schema.Boolean, Schema.
|
|
47
|
+
readonly data: Schema.optionalKey<Schema.$Record<Schema.String, Schema.Union<readonly [Schema.String, Schema.Boolean, Schema.Finite]>>>;
|
|
48
48
|
}>>;
|
|
49
49
|
}>]>;
|
|
50
50
|
export type HealthResponse = typeof HealthResponse.Type;
|
|
@@ -82,7 +82,7 @@ class NotificationService extends Context2.Service()("NotificationService", {
|
|
|
82
82
|
store
|
|
83
83
|
}) => this.layer.pipe(Layer2.provide(NotificationChannelRegistry.layer(channels)), Layer2.provide(NotificationPersistenceStore.layer(store)));
|
|
84
84
|
static noopLayer = Layer2.succeed(this, {
|
|
85
|
-
send: () => Effect2.
|
|
85
|
+
send: () => Effect2.undefined
|
|
86
86
|
});
|
|
87
87
|
static localLayer = this.makeLayer([
|
|
88
88
|
{
|
|
@@ -82,7 +82,7 @@ class NotificationService extends Context2.Service()("NotificationService", {
|
|
|
82
82
|
store
|
|
83
83
|
}) => this.layer.pipe(Layer2.provide(NotificationChannelRegistry.layer(channels)), Layer2.provide(NotificationPersistenceStore.layer(store)));
|
|
84
84
|
static noopLayer = Layer2.succeed(this, {
|
|
85
|
-
send: () => Effect2.
|
|
85
|
+
send: () => Effect2.undefined
|
|
86
86
|
});
|
|
87
87
|
static localLayer = this.makeLayer([
|
|
88
88
|
{
|
|
@@ -4,7 +4,9 @@ declare const NotificationSendError_base: Schema.Class<NotificationSendError, Sc
|
|
|
4
4
|
readonly message: Schema.String;
|
|
5
5
|
readonly channel: Schema.optional<Schema.String>;
|
|
6
6
|
readonly error: Schema.optional<Schema.Defect>;
|
|
7
|
-
}>, import("effect/Cause").YieldableError
|
|
7
|
+
}>, import("effect/Cause").YieldableError & {
|
|
8
|
+
readonly brand: unique symbol;
|
|
9
|
+
}>;
|
|
8
10
|
export declare class NotificationSendError extends NotificationSendError_base {
|
|
9
11
|
}
|
|
10
12
|
export type { NotificationMessage, NotificationSendInput } from "./channels/index.js";
|
|
@@ -129,7 +129,7 @@ class OtlpEvents extends Context.Service()("krakstack/opentelemetry/Events") {
|
|
|
129
129
|
}));
|
|
130
130
|
}
|
|
131
131
|
var event = Effect.fnUntraced(function* (name, properties, options) {
|
|
132
|
-
const decoded = yield* Schema2.
|
|
132
|
+
const decoded = yield* Schema2.decodeEffect(TelemetryEvent)({
|
|
133
133
|
name,
|
|
134
134
|
properties,
|
|
135
135
|
options
|
|
@@ -191,13 +191,15 @@ var ServerEventsLive = Layer2.unwrap(Effect2.gen(function* () {
|
|
|
191
191
|
|
|
192
192
|
class Otlp extends Context2.Service()("krakstack/opentelemetry/Otlp") {
|
|
193
193
|
static event = event;
|
|
194
|
-
static layer = Layer2.mergeAll(Layer2.succeed(this, { resource: OtlpResource2.fromConfig() }), EffectOtlp.layerFromConfig(),
|
|
194
|
+
static layer = Layer2.mergeAll(Layer2.succeed(this, { resource: OtlpResource2.fromConfig() }), ServerEventsLive).pipe(Layer2.provideMerge(EffectOtlp.layerFromConfig()), Layer2.provideMerge(OtlpExporter2.layerFlusher), Layer2.provide(OtlpSerialization2.layerJson), Layer2.provide(FetchHttpClient.layer));
|
|
195
195
|
}
|
|
196
196
|
|
|
197
197
|
// ../../src/services/opentelemetry/processor.ts
|
|
198
198
|
import { Context as Context3, Schema as Schema4 } from "effect";
|
|
199
199
|
|
|
200
|
-
class OtlpProcessingError extends Schema4.TaggedError()("OtlpProcessingError", {
|
|
200
|
+
class OtlpProcessingError extends Schema4.TaggedError()("OtlpProcessingError", {
|
|
201
|
+
status: Schema4.Literals([400, 403, 409, 413, 503])
|
|
202
|
+
}) {
|
|
201
203
|
}
|
|
202
204
|
|
|
203
205
|
class OtlpLogsProcessor extends Context3.Service()("krakstack/opentelemetry/OtlpLogsProcessor") {
|
|
@@ -117,7 +117,7 @@ class OtlpEvents extends Context.Service()("krakstack/opentelemetry/Events") {
|
|
|
117
117
|
}));
|
|
118
118
|
}
|
|
119
119
|
var event = Effect.fnUntraced(function* (name, properties, options) {
|
|
120
|
-
const decoded = yield* Schema2.
|
|
120
|
+
const decoded = yield* Schema2.decodeEffect(TelemetryEvent)({
|
|
121
121
|
name,
|
|
122
122
|
properties,
|
|
123
123
|
options
|
|
@@ -239,7 +239,7 @@ class BrowserOtlp {
|
|
|
239
239
|
const resource = { attributes, serviceName, serviceVersion };
|
|
240
240
|
const request = HttpClientRequest.get(baseUrl);
|
|
241
241
|
const signalUrl = (signal) => HttpClientRequest.appendUrl(request, `/v1/${signal}`).url;
|
|
242
|
-
const exporters = Layer2.mergeAll(
|
|
242
|
+
const exporters = Layer2.mergeAll(events !== false ? OtlpEvents.layer({
|
|
243
243
|
exportInterval: "30 seconds",
|
|
244
244
|
maxBatchSize: 100,
|
|
245
245
|
shutdownTimeout: "3 seconds",
|