@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
|
@@ -3,6 +3,7 @@ import { Effect as Effect2, Schema as Schema2 } from "effect";
|
|
|
3
3
|
import { Tool, Toolkit } from "effect/ai";
|
|
4
4
|
|
|
5
5
|
// ../../src/lib/httpapi-adapter.ts
|
|
6
|
+
import * as Data from "effect/Data";
|
|
6
7
|
import {
|
|
7
8
|
Context,
|
|
8
9
|
Effect,
|
|
@@ -13,6 +14,9 @@ import {
|
|
|
13
14
|
} from "effect";
|
|
14
15
|
import { HttpClient } from "effect/http";
|
|
15
16
|
import { HttpApi, HttpApiClient, OpenApi } from "effect/http-api";
|
|
17
|
+
|
|
18
|
+
class HttpApiAdapterError extends Data.TaggedError("HttpApiAdapterError") {
|
|
19
|
+
}
|
|
16
20
|
var HttpApiMethods = [
|
|
17
21
|
"get",
|
|
18
22
|
"post",
|
|
@@ -49,7 +53,7 @@ var HttpApiOperationResultValue = Schema.suspend(() => Schema.Union([
|
|
|
49
53
|
Schema.Null,
|
|
50
54
|
UndefinedFromNull,
|
|
51
55
|
Schema.String,
|
|
52
|
-
Schema.
|
|
56
|
+
Schema.Finite,
|
|
53
57
|
Schema.Boolean,
|
|
54
58
|
Schema.DateFromString,
|
|
55
59
|
Schema.Uint8ArrayFromBase64,
|
|
@@ -60,9 +64,15 @@ var HttpApiOperationResult = Schema.Union([
|
|
|
60
64
|
HttpApiOperationResultValue,
|
|
61
65
|
Schema.Undefined
|
|
62
66
|
]).annotate({ identifier: "HttpApiOperationResult" });
|
|
63
|
-
var encodeHttpApiOperationResult = Effect.fn("HttpApiAdapter.encodeOperationResult")((result) => Schema.encodeUnknownEffect(HttpApiOperationResult)(result).pipe(Effect.map((encoded) => encoded ?? null), Effect.mapError((cause) => new
|
|
64
|
-
|
|
65
|
-
cause
|
|
67
|
+
var encodeHttpApiOperationResult = Effect.fn("HttpApiAdapter.encodeOperationResult")((result) => Schema.encodeUnknownEffect(HttpApiOperationResult)(result).pipe(Effect.map((encoded) => encoded ?? null), Effect.mapError((cause) => new HttpApiAdapterError({
|
|
68
|
+
message: "HTTP API result is not serializable",
|
|
69
|
+
cause: { cause }.cause
|
|
70
|
+
}))));
|
|
71
|
+
var encodeOperationResult = Effect.fn("HttpApiAdapter.encodeResult")((result, operation) => operation.successSchema ? Schema.encodeUnknownEffect(operation.successSchema)(result).pipe(Effect.flatMap(encodeHttpApiOperationResult), Effect.mapError((cause) => new HttpApiAdapterError({
|
|
72
|
+
message: "HTTP API result does not match its success schema",
|
|
73
|
+
cause: {
|
|
74
|
+
cause
|
|
75
|
+
}.cause
|
|
66
76
|
}))) : encodeHttpApiOperationResult(result));
|
|
67
77
|
var reflectedSchema = (schema) => Schema.make(schema.ast);
|
|
68
78
|
var sanitizeHttpName = (name) => name.replace(/[^a-zA-Z0-9_-]/g, "_").replace(/_+/g, "_").replace(/^_+|_+$/g, "");
|
|
@@ -70,7 +80,9 @@ var httpApiToolName = (entry) => (entry.operation.operationId || `${entry.method
|
|
|
70
80
|
var makeCatalogue = (api, methods, include) => Effect.try({
|
|
71
81
|
try: () => {
|
|
72
82
|
if (!HttpApi.isHttpApi(api))
|
|
73
|
-
throw new
|
|
83
|
+
throw new HttpApiAdapterError({
|
|
84
|
+
message: "HttpApiAdapter requires a valid HttpApi"
|
|
85
|
+
});
|
|
74
86
|
const spec = OpenApi.fromApi(api);
|
|
75
87
|
const reflected = new Map;
|
|
76
88
|
HttpApi.reflect(api, {
|
|
@@ -80,7 +92,9 @@ var makeCatalogue = (api, methods, include) => Effect.try({
|
|
|
80
92
|
onEndpoint: ({ endpoint, group, successes }) => {
|
|
81
93
|
const operationId = Context.getOrElse(endpoint.annotations, OpenApi.Identifier, () => group.topLevel ? endpoint.identifier : `${group.identifier}.${endpoint.identifier}`);
|
|
82
94
|
if (reflected.has(operationId))
|
|
83
|
-
throw new
|
|
95
|
+
throw new HttpApiAdapterError({
|
|
96
|
+
message: `Duplicate HTTP API operation ID: ${operationId}`
|
|
97
|
+
});
|
|
84
98
|
const fields = {};
|
|
85
99
|
if (endpoint.params)
|
|
86
100
|
fields.params = Schema.toType(reflectedSchema(endpoint.params));
|
|
@@ -119,10 +133,14 @@ var makeCatalogue = (api, methods, include) => Effect.try({
|
|
|
119
133
|
continue;
|
|
120
134
|
const metadata = entry.operation.operationId ? reflected.get(entry.operation.operationId) : undefined;
|
|
121
135
|
if (!metadata)
|
|
122
|
-
throw new
|
|
136
|
+
throw new HttpApiAdapterError({
|
|
137
|
+
message: `Missing endpoint schema for ${entry.operation.operationId}`
|
|
138
|
+
});
|
|
123
139
|
const name = httpApiToolName(entry);
|
|
124
140
|
if (!name || names.has(name))
|
|
125
|
-
throw new
|
|
141
|
+
throw new HttpApiAdapterError({
|
|
142
|
+
message: `Duplicate or empty HTTP API tool name: ${name}`
|
|
143
|
+
});
|
|
126
144
|
names.add(name);
|
|
127
145
|
const document = Schema.toJsonSchemaDocument(metadata.inputSchema.annotate({ identifier: undefined }));
|
|
128
146
|
operations.push({
|
|
@@ -141,7 +159,10 @@ var makeCatalogue = (api, methods, include) => Effect.try({
|
|
|
141
159
|
}
|
|
142
160
|
return { info: spec.info, operations };
|
|
143
161
|
},
|
|
144
|
-
catch: (cause) => new
|
|
162
|
+
catch: (cause) => new HttpApiAdapterError({
|
|
163
|
+
message: "Failed to build HTTP API adapter catalogue",
|
|
164
|
+
cause: { cause }.cause
|
|
165
|
+
})
|
|
145
166
|
});
|
|
146
167
|
var GeneratedOperation = Schema.declare((value) => value instanceof Function).annotate({ identifier: "GeneratedOperation" });
|
|
147
168
|
var GeneratedOperationEffect = Schema.declare((value) => Effect.isEffect(value)).annotate({ identifier: "GeneratedOperationEffect" });
|
|
@@ -150,15 +171,19 @@ var executeGeneratedOperation = Effect.fn("HttpApiAdapter.executeGeneratedOperat
|
|
|
150
171
|
const candidate = Object.entries(Object(group)).find(([name]) => name === operation.endpointIdentifier)?.[1];
|
|
151
172
|
const endpoint = Schema.decodeUnknownOption(GeneratedOperation)(candidate);
|
|
152
173
|
if (Option.isNone(endpoint))
|
|
153
|
-
return yield*
|
|
154
|
-
|
|
174
|
+
return yield* new HttpApiAdapterError({
|
|
175
|
+
message: `No generated API client operation for ${operation.operation.operationId}`
|
|
176
|
+
});
|
|
177
|
+
const result = Schema.decodeOption(GeneratedOperationEffect)(endpoint.value({
|
|
155
178
|
headers: input.headers ?? {},
|
|
156
179
|
params: input.params ?? {},
|
|
157
180
|
query: input.query ?? {},
|
|
158
181
|
payload: input.body
|
|
159
182
|
}));
|
|
160
183
|
if (Option.isNone(result))
|
|
161
|
-
return yield*
|
|
184
|
+
return yield* new HttpApiAdapterError({
|
|
185
|
+
message: `Generated API client operation ${operation.operation.operationId} is invalid`
|
|
186
|
+
});
|
|
162
187
|
return yield* result.value;
|
|
163
188
|
});
|
|
164
189
|
|
|
@@ -176,7 +201,9 @@ class HttpApiAdapter extends Context.Service()("@krak-stack/registry/HttpApiAdap
|
|
|
176
201
|
execute: Effect.fn("HttpApiAdapter.execute")(function* (options) {
|
|
177
202
|
const operation = catalogue.operations.find((entry) => entry.method === options.operation.method && entry.path === options.operation.path && entry.operation.operationId === options.operation.operation.operationId);
|
|
178
203
|
if (!operation) {
|
|
179
|
-
return yield*
|
|
204
|
+
return yield* new HttpApiAdapterError({
|
|
205
|
+
message: "Operation is not in this HTTP API adapter catalogue"
|
|
206
|
+
});
|
|
180
207
|
}
|
|
181
208
|
return yield* executeGeneratedOperation(client, {
|
|
182
209
|
operation,
|
package/dist/lib/query.d.ts
CHANGED
|
@@ -103,8 +103,8 @@ export declare const ColumnFilters: Schema.declare<readonly ({
|
|
|
103
103
|
readonly values: readonly [string, ...string[]];
|
|
104
104
|
})[]>;
|
|
105
105
|
export declare const Query: Schema.Struct<{
|
|
106
|
-
readonly page: Schema.decodeTo<Schema.Int, Schema.optional<Schema.Union<readonly [Schema.
|
|
107
|
-
readonly pageSize: Schema.decodeTo<Schema.Int, Schema.optional<Schema.Union<readonly [Schema.
|
|
106
|
+
readonly page: Schema.decodeTo<Schema.Int, Schema.optional<Schema.Union<readonly [Schema.Finite, Schema.FiniteFromString]>>, never, never>;
|
|
107
|
+
readonly pageSize: Schema.decodeTo<Schema.Int, Schema.optional<Schema.Union<readonly [Schema.Finite, Schema.FiniteFromString]>>, never, never>;
|
|
108
108
|
readonly globalFilter: Schema.optional<Schema.String>;
|
|
109
109
|
readonly sort: Schema.optional<Schema.declare<readonly {
|
|
110
110
|
readonly id: string;
|
|
@@ -228,8 +228,8 @@ export declare const QueryStandard: import("effect/StandardSchema").StandardSche
|
|
|
228
228
|
readonly values: readonly [string, ...string[]];
|
|
229
229
|
})[] | undefined;
|
|
230
230
|
}> & Schema.Struct<{
|
|
231
|
-
readonly page: Schema.decodeTo<Schema.Int, Schema.optional<Schema.Union<readonly [Schema.
|
|
232
|
-
readonly pageSize: Schema.decodeTo<Schema.Int, Schema.optional<Schema.Union<readonly [Schema.
|
|
231
|
+
readonly page: Schema.decodeTo<Schema.Int, Schema.optional<Schema.Union<readonly [Schema.Finite, Schema.FiniteFromString]>>, never, never>;
|
|
232
|
+
readonly pageSize: Schema.decodeTo<Schema.Int, Schema.optional<Schema.Union<readonly [Schema.Finite, Schema.FiniteFromString]>>, never, never>;
|
|
233
233
|
readonly globalFilter: Schema.optional<Schema.String>;
|
|
234
234
|
readonly sort: Schema.optional<Schema.declare<readonly {
|
|
235
235
|
readonly id: string;
|
package/dist/lib/query.js
CHANGED
|
@@ -125,11 +125,11 @@ var ColumnFilters = Schema.declare(Schema.is(ColumnFiltersArray), {
|
|
|
125
125
|
toCodecStringTree: () => Schema.link()(Schema.fromJsonString(ColumnFiltersArray), SchemaTransformation.passthrough())
|
|
126
126
|
});
|
|
127
127
|
var Query = Schema.Struct({
|
|
128
|
-
page: Schema.optional(Schema.Union([Schema.
|
|
128
|
+
page: Schema.optional(Schema.Union([Schema.Finite, Schema.FiniteFromString]).check(Schema.isInt(), Schema.isGreaterThanOrEqualTo(0))).pipe(Schema.decodeTo(Schema.Int.check(Schema.isGreaterThanOrEqualTo(0)), {
|
|
129
129
|
decode: SchemaGetter.withDefault(Effect.succeed(0)),
|
|
130
130
|
encode: SchemaGetter.transformOptional(Option.filter((page) => page !== 0))
|
|
131
131
|
})),
|
|
132
|
-
pageSize: Schema.optional(Schema.Union([Schema.
|
|
132
|
+
pageSize: Schema.optional(Schema.Union([Schema.Finite, Schema.FiniteFromString]).check(Schema.isInt(), Schema.isBetween({ minimum: 1, maximum: 100 }))).pipe(Schema.decodeTo(Schema.Int.check(Schema.isBetween({ minimum: 1, maximum: 100 })), {
|
|
133
133
|
decode: SchemaGetter.withDefault(Effect.succeed(20)),
|
|
134
134
|
encode: SchemaGetter.transformOptional(Option.filter((pageSize) => pageSize !== 20))
|
|
135
135
|
})),
|
|
@@ -163,7 +163,7 @@ var SupportedMediaType = Schema2.Literals([
|
|
|
163
163
|
"text/xml"
|
|
164
164
|
]).annotate({ identifier: "WebFetchSupportedMediaType" });
|
|
165
165
|
var decodeMediaType = Schema2.decodeUnknownOption(SupportedMediaType);
|
|
166
|
-
var decodeContentLength = Schema2.decodeUnknownOption(Schema2.
|
|
166
|
+
var decodeContentLength = Schema2.decodeUnknownOption(Schema2.FiniteFromString.check(Schema2.isGreaterThanOrEqualTo(0)));
|
|
167
167
|
var WebFetchRequest = Schema2.Struct({
|
|
168
168
|
url: WebFetchUrl
|
|
169
169
|
}).annotate({
|
|
@@ -92,7 +92,7 @@ class AgentHistoryError extends Data.TaggedError("AgentHistoryError") {
|
|
|
92
92
|
var AgentStreamErrorDetails = Schema.Struct({
|
|
93
93
|
message: Schema.optional(Schema.String),
|
|
94
94
|
reason: Schema.optional(Schema.String),
|
|
95
|
-
status: Schema.optional(Schema.
|
|
95
|
+
status: Schema.optional(Schema.Finite),
|
|
96
96
|
_tag: Schema.optional(Schema.String)
|
|
97
97
|
}).annotate({ identifier: "AgentStreamErrorDetails" });
|
|
98
98
|
var decodeAgentStreamErrorDetails = Schema.decodeUnknownOption(AgentStreamErrorDetails);
|
|
@@ -109,7 +109,7 @@ class OtlpEvents extends Context.Service()("krakstack/opentelemetry/Events") {
|
|
|
109
109
|
}));
|
|
110
110
|
}
|
|
111
111
|
var event = Effect.fnUntraced(function* (name, properties, options) {
|
|
112
|
-
const decoded = yield* Schema2.
|
|
112
|
+
const decoded = yield* Schema2.decodeEffect(TelemetryEvent)({
|
|
113
113
|
name,
|
|
114
114
|
properties,
|
|
115
115
|
options
|
|
@@ -148,8 +148,11 @@ var event = Effect.fnUntraced(function* (name, properties, options) {
|
|
|
148
148
|
import { Context as Context2, Effect as Effect5, FiberSet, Layer as Layer2, Option as Option5, Schema as Schema6 } from "effect";
|
|
149
149
|
|
|
150
150
|
// ../../src/services/opentelemetry/consent.ts
|
|
151
|
+
import * as Data from "effect/Data";
|
|
151
152
|
import { SecureRandom } from "effect/crypto";
|
|
152
153
|
import { Effect as Effect2, Option as Option2, Schema as Schema3 } from "effect";
|
|
154
|
+
class AnalyticsPreferenceStorageError extends Data.TaggedError("AnalyticsPreferenceStorageError") {
|
|
155
|
+
}
|
|
153
156
|
var ANALYTICS_CONSENT_COOKIE = "krakstack_analytics_consent";
|
|
154
157
|
var ANALYTICS_NOTICE_VERSION = "1";
|
|
155
158
|
var changedEvent = "krakstack:analytics-consent";
|
|
@@ -160,7 +163,7 @@ var analyticsPreference = (cookie, now = Date.now()) => {
|
|
|
160
163
|
const value = readCookie(cookie);
|
|
161
164
|
if (!value)
|
|
162
165
|
return;
|
|
163
|
-
const decoded = Schema3.
|
|
166
|
+
const decoded = Schema3.decodeOption(codec)(value);
|
|
164
167
|
if (Option2.isNone(decoded))
|
|
165
168
|
return;
|
|
166
169
|
const preference = decoded.value;
|
|
@@ -177,8 +180,10 @@ var browserPreference = () => {
|
|
|
177
180
|
return;
|
|
178
181
|
const cookie = Effect2.runSync(Effect2.try({
|
|
179
182
|
try: () => document.cookie,
|
|
180
|
-
catch: () => new
|
|
181
|
-
|
|
183
|
+
catch: () => new AnalyticsPreferenceStorageError({
|
|
184
|
+
message: "Analytics preference storage unavailable"
|
|
185
|
+
})
|
|
186
|
+
}).pipe(Effect2.orElseSucceed(() => "")));
|
|
182
187
|
return analyticsPreference(cookie);
|
|
183
188
|
};
|
|
184
189
|
var consentGeneration = 0;
|
|
@@ -361,11 +366,11 @@ var ColumnFilters = Schema4.declare(Schema4.is(ColumnFiltersArray), {
|
|
|
361
366
|
toCodecStringTree: () => Schema4.link()(Schema4.fromJsonString(ColumnFiltersArray), SchemaTransformation.passthrough())
|
|
362
367
|
});
|
|
363
368
|
var Query = Schema4.Struct({
|
|
364
|
-
page: Schema4.optional(Schema4.Union([Schema4.
|
|
369
|
+
page: Schema4.optional(Schema4.Union([Schema4.Finite, Schema4.FiniteFromString]).check(Schema4.isInt(), Schema4.isGreaterThanOrEqualTo(0))).pipe(Schema4.decodeTo(Schema4.Int.check(Schema4.isGreaterThanOrEqualTo(0)), {
|
|
365
370
|
decode: SchemaGetter.withDefault(Effect3.succeed(0)),
|
|
366
371
|
encode: SchemaGetter.transformOptional(Option3.filter((page) => page !== 0))
|
|
367
372
|
})),
|
|
368
|
-
pageSize: Schema4.optional(Schema4.Union([Schema4.
|
|
373
|
+
pageSize: Schema4.optional(Schema4.Union([Schema4.Finite, Schema4.FiniteFromString]).check(Schema4.isInt(), Schema4.isBetween({ minimum: 1, maximum: 100 }))).pipe(Schema4.decodeTo(Schema4.Int.check(Schema4.isBetween({ minimum: 1, maximum: 100 })), {
|
|
369
374
|
decode: SchemaGetter.withDefault(Effect3.succeed(20)),
|
|
370
375
|
encode: SchemaGetter.transformOptional(Option3.filter((pageSize) => pageSize !== 20))
|
|
371
376
|
})),
|
|
@@ -409,7 +414,7 @@ var EventIdentity = Schema5.Struct({
|
|
|
409
414
|
userId: Schema5.optional(Schema5.NonEmptyString),
|
|
410
415
|
organizationId: Schema5.optional(Schema5.NonEmptyString)
|
|
411
416
|
}).annotate({ identifier: "EventIdentity" });
|
|
412
|
-
var EventIpAddress = Schema5.String.check(Schema5.makeFilter((value) => Option4.isSome(Schema5.
|
|
417
|
+
var EventIpAddress = Schema5.String.check(Schema5.makeFilter((value) => Option4.isSome(Schema5.decodeOption(Schema5.IpAddressFromString)(value)) || "Invalid IP address")).annotate({ identifier: "EventIpAddress" });
|
|
413
418
|
var EventCountry = Schema5.String.check(Schema5.isPattern(/^[A-Z]{2}$/), Schema5.makeFilter((value) => !["XX", "T1"].includes(value) || "Unknown country")).annotate({ identifier: "EventCountry" });
|
|
414
419
|
var EventRegion = Schema5.String.check(Schema5.isPattern(/^[A-Z0-9]{1,3}$/)).annotate({ identifier: "EventRegion" });
|
|
415
420
|
var EventCity = Schema5.NonEmptyString.check(Schema5.isMaxLength(128)).annotate({ identifier: "EventCity" });
|
|
@@ -616,14 +621,14 @@ var emit = Effect5.fnUntraced(function* (name, properties, options) {
|
|
|
616
621
|
const client = yield* BrowserEventsClient;
|
|
617
622
|
if (!client.allowed())
|
|
618
623
|
return;
|
|
619
|
-
const decoded = yield* Schema6.
|
|
624
|
+
const decoded = yield* Schema6.decodeEffect(BrowserEventOptions)(options ?? {});
|
|
620
625
|
yield* event(name, { ...properties, ...client.context(name, properties) }, decoded).pipe(Effect5.provideService(OtlpEvents, client.events));
|
|
621
626
|
});
|
|
622
627
|
var page = Effect5.fnUntraced(function* (input = {}) {
|
|
623
628
|
const client = yield* BrowserEventsClient;
|
|
624
629
|
if (!client.allowed())
|
|
625
630
|
return;
|
|
626
|
-
const decoded = yield* Schema6.
|
|
631
|
+
const decoded = yield* Schema6.decodeEffect(BrowserPage)(input);
|
|
627
632
|
const properties = eventProperties(decoded.properties);
|
|
628
633
|
if (decoded.name)
|
|
629
634
|
properties["analytics.page.name"] = decoded.name;
|
|
@@ -652,18 +657,20 @@ var pageViewListeners = new Set;
|
|
|
652
657
|
var stopPageViewTracking;
|
|
653
658
|
var subscribePageViews = (listener) => {
|
|
654
659
|
if (pageViewListeners.size === 0) {
|
|
655
|
-
const
|
|
656
|
-
const
|
|
660
|
+
const pushDescriptor = Object.getOwnPropertyDescriptor(history, "pushState");
|
|
661
|
+
const replaceDescriptor = Object.getOwnPropertyDescriptor(history, "replaceState");
|
|
662
|
+
const pushState = history.pushState.bind(history);
|
|
663
|
+
const replaceState = history.replaceState.bind(history);
|
|
657
664
|
const notify = () => {
|
|
658
665
|
for (const onPage of pageViewListeners)
|
|
659
666
|
onPage();
|
|
660
667
|
};
|
|
661
668
|
const trackedPushState = (...args) => {
|
|
662
|
-
pushState
|
|
669
|
+
pushState(...args);
|
|
663
670
|
notify();
|
|
664
671
|
};
|
|
665
672
|
const trackedReplaceState = (...args) => {
|
|
666
|
-
replaceState
|
|
673
|
+
replaceState(...args);
|
|
667
674
|
notify();
|
|
668
675
|
};
|
|
669
676
|
history.pushState = trackedPushState;
|
|
@@ -671,10 +678,18 @@ var subscribePageViews = (listener) => {
|
|
|
671
678
|
globalThis.addEventListener("popstate", notify);
|
|
672
679
|
stopPageViewTracking = () => {
|
|
673
680
|
globalThis.removeEventListener("popstate", notify);
|
|
674
|
-
if (history.pushState === trackedPushState)
|
|
675
|
-
|
|
676
|
-
|
|
677
|
-
|
|
681
|
+
if (history.pushState === trackedPushState) {
|
|
682
|
+
if (pushDescriptor)
|
|
683
|
+
Object.defineProperty(history, "pushState", pushDescriptor);
|
|
684
|
+
else
|
|
685
|
+
Reflect.deleteProperty(history, "pushState");
|
|
686
|
+
}
|
|
687
|
+
if (history.replaceState === trackedReplaceState) {
|
|
688
|
+
if (replaceDescriptor)
|
|
689
|
+
Object.defineProperty(history, "replaceState", replaceDescriptor);
|
|
690
|
+
else
|
|
691
|
+
Reflect.deleteProperty(history, "replaceState");
|
|
692
|
+
}
|
|
678
693
|
};
|
|
679
694
|
}
|
|
680
695
|
pageViewListeners.add(listener);
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
// ../../src/components/ui/data-table.tsx
|
|
2
2
|
import { useAtom, useAtomSet } from "@effect/atom-react";
|
|
3
3
|
import { BrowserKeyValueStore } from "@effect/platform-browser";
|
|
4
|
-
import { DateTime as DateTime2, Effect as Effect2, Option as Option2, Schema as Schema2, Stream } from "effect";
|
|
4
|
+
import { DateTime as DateTime2, Effect as Effect2, Formatter, Option as Option2, Schema as Schema2, Stream } from "effect";
|
|
5
5
|
import { Csv } from "effect/encoding";
|
|
6
6
|
import { AsyncResult, Atom } from "effect/reactivity";
|
|
7
7
|
import {
|
|
@@ -1161,11 +1161,11 @@ var ColumnFilters = Schema.declare(Schema.is(ColumnFiltersArray), {
|
|
|
1161
1161
|
toCodecStringTree: () => Schema.link()(Schema.fromJsonString(ColumnFiltersArray), SchemaTransformation.passthrough())
|
|
1162
1162
|
});
|
|
1163
1163
|
var Query = Schema.Struct({
|
|
1164
|
-
page: Schema.optional(Schema.Union([Schema.
|
|
1164
|
+
page: Schema.optional(Schema.Union([Schema.Finite, Schema.FiniteFromString]).check(Schema.isInt(), Schema.isGreaterThanOrEqualTo(0))).pipe(Schema.decodeTo(Schema.Int.check(Schema.isGreaterThanOrEqualTo(0)), {
|
|
1165
1165
|
decode: SchemaGetter.withDefault(Effect.succeed(0)),
|
|
1166
1166
|
encode: SchemaGetter.transformOptional(Option.filter((page) => page !== 0))
|
|
1167
1167
|
})),
|
|
1168
|
-
pageSize: Schema.optional(Schema.Union([Schema.
|
|
1168
|
+
pageSize: Schema.optional(Schema.Union([Schema.Finite, Schema.FiniteFromString]).check(Schema.isInt(), Schema.isBetween({ minimum: 1, maximum: 100 }))).pipe(Schema.decodeTo(Schema.Int.check(Schema.isBetween({ minimum: 1, maximum: 100 })), {
|
|
1169
1169
|
decode: SchemaGetter.withDefault(Effect.succeed(20)),
|
|
1170
1170
|
encode: SchemaGetter.transformOptional(Option.filter((pageSize) => pageSize !== 20))
|
|
1171
1171
|
})),
|
|
@@ -1206,7 +1206,7 @@ import { useKrakstackLocale as useKrakstackLocale3 } from "@krak-stack/registry/
|
|
|
1206
1206
|
import { jsx as jsx15, jsxs as jsxs9, Fragment } from "react/jsx-runtime";
|
|
1207
1207
|
var DataTablePersistedUiStateSchema = Schema2.Struct({
|
|
1208
1208
|
columnVisibility: Schema2.Record(Schema2.String, Schema2.Boolean),
|
|
1209
|
-
columnSizing: Schema2.Record(Schema2.String, Schema2.
|
|
1209
|
+
columnSizing: Schema2.Record(Schema2.String, Schema2.Finite),
|
|
1210
1210
|
grouping: Schema2.optionalKey(Schema2.Array(Schema2.String)),
|
|
1211
1211
|
view: Schema2.Literals(["table", "gallery"])
|
|
1212
1212
|
}).annotate({ identifier: "DataTablePersistedUiState" });
|
|
@@ -1486,6 +1486,14 @@ var formatNumberValue = (value, options = {}, defaultLocale = "en") => {
|
|
|
1486
1486
|
} = options;
|
|
1487
1487
|
return new Intl.NumberFormat(locale ?? defaultLocale, format).format(value);
|
|
1488
1488
|
};
|
|
1489
|
+
var scalarText = Schema2.is(Schema2.Union([
|
|
1490
|
+
Schema2.String,
|
|
1491
|
+
Schema2.Finite,
|
|
1492
|
+
Schema2.Boolean,
|
|
1493
|
+
Schema2.BigInt,
|
|
1494
|
+
Schema2.Symbol
|
|
1495
|
+
]));
|
|
1496
|
+
var dataTableValueText = (value) => value == null ? "" : scalarText(value) ? String(value) : Formatter.format(value);
|
|
1489
1497
|
var booleanLabel = (value, options) => value ? options?.trueLabel : options?.falseLabel;
|
|
1490
1498
|
var getDataTableExportValue = (row, column, locale = "en") => {
|
|
1491
1499
|
const value = row.values.get(column.id);
|
|
@@ -1517,7 +1525,7 @@ var filterDataTableRows = (rows, columns, globalFilter, locale = "en") => {
|
|
|
1517
1525
|
return rows.filter((row) => searchable.some((column) => {
|
|
1518
1526
|
const value = row.values.get(column.id);
|
|
1519
1527
|
const colDef = column.colDef;
|
|
1520
|
-
let text =
|
|
1528
|
+
let text = dataTableValueText(value);
|
|
1521
1529
|
if (colDef.type === "date" || colDef.type === "dateTime") {
|
|
1522
1530
|
const date = resolveDate(value, colDef.type);
|
|
1523
1531
|
text = date ? `${formatDateValue(date, colDef, locale)} ${dateIsoValue(date)}` : "";
|
|
@@ -1564,7 +1572,7 @@ var filterDataTableColumnRows = (rows, columns, filters) => {
|
|
|
1564
1572
|
}) : row.values.get(column.id);
|
|
1565
1573
|
switch (filter.kind) {
|
|
1566
1574
|
case "text": {
|
|
1567
|
-
const text =
|
|
1575
|
+
const text = dataTableValueText(value).toLocaleLowerCase();
|
|
1568
1576
|
const query = filter.value.toLocaleLowerCase();
|
|
1569
1577
|
switch (filter.operator) {
|
|
1570
1578
|
case "contains":
|
|
@@ -1591,7 +1599,7 @@ var filterDataTableColumnRows = (rows, columns, filters) => {
|
|
|
1591
1599
|
case "boolean":
|
|
1592
1600
|
return Option2.getOrUndefined(decodeBooleanValue(value)) === filter.value;
|
|
1593
1601
|
case "values": {
|
|
1594
|
-
const values = column.colDef.type === "list" ? column.colDef.typeOptions.getItems(row.data).map((item) => item.value ?? item.label) : [
|
|
1602
|
+
const values = column.colDef.type === "list" ? column.colDef.typeOptions.getItems(row.data).map((item) => item.value ?? item.label) : [dataTableValueText(value)];
|
|
1595
1603
|
return filter.values.some((selected) => values.includes(selected));
|
|
1596
1604
|
}
|
|
1597
1605
|
}
|
|
@@ -1638,7 +1646,7 @@ var sortDataTableRows = (rows, columns, sorting) => {
|
|
|
1638
1646
|
return sort.direction === "desc" ? -comparison : comparison;
|
|
1639
1647
|
continue;
|
|
1640
1648
|
}
|
|
1641
|
-
const comparison = column.colDef.comparator ? column.colDef.comparator(leftValue, rightValue, left.row.data, right.row.data) : Object.is(leftValue, rightValue) ? 0 : leftValue === null || leftValue === undefined ? 1 : rightValue === null || rightValue === undefined ? -1 : Schema2.is(Schema2.
|
|
1649
|
+
const comparison = column.colDef.comparator ? column.colDef.comparator(leftValue, rightValue, left.row.data, right.row.data) : Object.is(leftValue, rightValue) ? 0 : leftValue === null || leftValue === undefined ? 1 : rightValue === null || rightValue === undefined ? -1 : Schema2.is(Schema2.Finite)(leftValue) && Schema2.is(Schema2.Finite)(rightValue) ? leftValue - rightValue : dataTableValueText(leftValue).localeCompare(dataTableValueText(rightValue), undefined, { numeric: true, sensitivity: "base" });
|
|
1642
1650
|
if (comparison !== 0)
|
|
1643
1651
|
return sort.direction === "desc" ? -comparison : comparison;
|
|
1644
1652
|
}
|
|
@@ -1918,10 +1926,10 @@ var renderCell = (row, column, locale = "en", labels = dataTableMessages(locale)
|
|
|
1918
1926
|
totalCount: config.getTotalCount?.(row.data)
|
|
1919
1927
|
});
|
|
1920
1928
|
}
|
|
1921
|
-
return column.colDef.valueFormatter?.(params) ?? (value === null || value === undefined ? null :
|
|
1929
|
+
return column.colDef.valueFormatter?.(params) ?? (value === null || value === undefined ? null : dataTableValueText(value));
|
|
1922
1930
|
};
|
|
1923
1931
|
var nodeText = (node) => {
|
|
1924
|
-
if (Schema2.is(Schema2.String)(node) || Schema2.is(Schema2.
|
|
1932
|
+
if (Schema2.is(Schema2.String)(node) || Schema2.is(Schema2.Finite)(node))
|
|
1925
1933
|
return String(node);
|
|
1926
1934
|
if (!isValidElement(node))
|
|
1927
1935
|
return "";
|
|
@@ -2238,7 +2246,7 @@ var DataTableToolbar = ({
|
|
|
2238
2246
|
children: [
|
|
2239
2247
|
/* @__PURE__ */ jsxs9(MenubarItem, {
|
|
2240
2248
|
disabled: exporting || !exportRows.length,
|
|
2241
|
-
onClick: () => downloadCsv(exportColumns.map(columnLabel), exportRows.map((row) => exportColumns.map((column) =>
|
|
2249
|
+
onClick: () => downloadCsv(exportColumns.map(columnLabel), exportRows.map((row) => exportColumns.map((column) => dataTableValueText(getDataTableExportValue(row, column, store.config.locale) ?? ""))), features.export ? features.export.baseName : "table"),
|
|
2242
2250
|
children: [
|
|
2243
2251
|
/* @__PURE__ */ jsx15(FileText, {}),
|
|
2244
2252
|
labels.exportCsv
|
|
@@ -2417,8 +2425,8 @@ var FilterEditor = ({
|
|
|
2417
2425
|
to: secondary || undefined
|
|
2418
2426
|
});
|
|
2419
2427
|
else {
|
|
2420
|
-
const min = primary ? Schema2.
|
|
2421
|
-
const max = secondary ? Schema2.
|
|
2428
|
+
const min = primary ? Schema2.decodeOption(Schema2.FiniteFromString)(primary) : Option2.some(undefined);
|
|
2429
|
+
const max = secondary ? Schema2.decodeOption(Schema2.FiniteFromString)(secondary) : Option2.some(undefined);
|
|
2422
2430
|
if (Option2.isNone(min) || Option2.isNone(max)) {
|
|
2423
2431
|
setInvalid(true);
|
|
2424
2432
|
return;
|
|
@@ -3911,7 +3919,11 @@ var EditableDataTableListCell = ({
|
|
|
3911
3919
|
messages
|
|
3912
3920
|
}) => {
|
|
3913
3921
|
const [selected, setSelected] = useState([...items]);
|
|
3914
|
-
|
|
3922
|
+
const [previousItems, setPreviousItems] = useState(items);
|
|
3923
|
+
if (previousItems !== items) {
|
|
3924
|
+
setPreviousItems(items);
|
|
3925
|
+
setSelected([...items]);
|
|
3926
|
+
}
|
|
3915
3927
|
const selectedValues = new Set(selected.map((item) => item.value));
|
|
3916
3928
|
const available = options.filter((item) => !selectedValues.has(item.value));
|
|
3917
3929
|
const canAdd = !!onAdd && available.length > 0;
|
|
@@ -148,6 +148,7 @@ function DialogDescription({
|
|
|
148
148
|
}
|
|
149
149
|
|
|
150
150
|
// ../../src/services/opentelemetry/consent.ts
|
|
151
|
+
import * as Data from "effect/Data";
|
|
151
152
|
import { SecureRandom } from "effect/crypto";
|
|
152
153
|
import { Effect, Option, Schema as Schema2 } from "effect";
|
|
153
154
|
|
|
@@ -203,6 +204,8 @@ var TelemetryEvent = Schema.Struct({
|
|
|
203
204
|
}).annotate({ identifier: "TelemetryEvent" });
|
|
204
205
|
|
|
205
206
|
// ../../src/services/opentelemetry/consent.ts
|
|
207
|
+
class AnalyticsPreferenceStorageError extends Data.TaggedError("AnalyticsPreferenceStorageError") {
|
|
208
|
+
}
|
|
206
209
|
var ANALYTICS_CONSENT_COOKIE = "krakstack_analytics_consent";
|
|
207
210
|
var ANALYTICS_NOTICE_VERSION = "1";
|
|
208
211
|
var changedEvent = "krakstack:analytics-consent";
|
|
@@ -213,7 +216,7 @@ var analyticsPreference = (cookie, now = Date.now()) => {
|
|
|
213
216
|
const value = readCookie(cookie);
|
|
214
217
|
if (!value)
|
|
215
218
|
return;
|
|
216
|
-
const decoded = Schema2.
|
|
219
|
+
const decoded = Schema2.decodeOption(codec)(value);
|
|
217
220
|
if (Option.isNone(decoded))
|
|
218
221
|
return;
|
|
219
222
|
const preference = decoded.value;
|
|
@@ -230,8 +233,10 @@ var browserPreference = () => {
|
|
|
230
233
|
return;
|
|
231
234
|
const cookie = Effect.runSync(Effect.try({
|
|
232
235
|
try: () => document.cookie,
|
|
233
|
-
catch: () => new
|
|
234
|
-
|
|
236
|
+
catch: () => new AnalyticsPreferenceStorageError({
|
|
237
|
+
message: "Analytics preference storage unavailable"
|
|
238
|
+
})
|
|
239
|
+
}).pipe(Effect.orElseSucceed(() => "")));
|
|
235
240
|
return analyticsPreference(cookie);
|
|
236
241
|
};
|
|
237
242
|
var consentGeneration = 0;
|
|
@@ -338,7 +343,7 @@ var TrackingNotice = ({
|
|
|
338
343
|
const result = Effect2.runSync(Effect2.try({
|
|
339
344
|
try: () => saveAnalyticsPreference(choice),
|
|
340
345
|
catch: () => new ConsentStorageError
|
|
341
|
-
}).pipe(Effect2.
|
|
346
|
+
}).pipe(Effect2.orElseSucceed(() => false)));
|
|
342
347
|
setFailed(!result);
|
|
343
348
|
if (result)
|
|
344
349
|
setOpen(false);
|
|
@@ -24,7 +24,9 @@ export interface EventsOptions {
|
|
|
24
24
|
}
|
|
25
25
|
declare const EventsConfigurationError_base: Schema.Class<EventsConfigurationError, Schema.TaggedStruct<"EventsConfigurationError", {
|
|
26
26
|
readonly message: Schema.String;
|
|
27
|
-
}>, Cause.YieldableError
|
|
27
|
+
}>, Cause.YieldableError & {
|
|
28
|
+
readonly brand: unique symbol;
|
|
29
|
+
}>;
|
|
28
30
|
export declare class EventsConfigurationError extends EventsConfigurationError_base {
|
|
29
31
|
}
|
|
30
32
|
export declare const dailyVisitorId: (input: {
|