@krak-stack/registry 0.1.59 → 0.1.61

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.
Files changed (37) hide show
  1. package/CHANGELOG.md +13 -1
  2. package/dist/components/ui/data-table.d.ts +2 -0
  3. package/dist/components/ui/data-table.js +6 -2
  4. package/dist/components/ui/item.d.ts +22 -0
  5. package/dist/components/ui/trace.d.ts +18 -0
  6. package/dist/services/agent/client/index.js +584 -434
  7. package/dist/services/agent/client/widget.d.ts +1 -0
  8. package/dist/services/events/browser.js +29 -3
  9. package/dist/services/events/client/audit-log-table.js +6 -2
  10. package/dist/services/events/client/tracking-notice.js +2 -1
  11. package/dist/services/events/index.d.ts +26 -56
  12. package/dist/services/events/index.js +118 -7
  13. package/dist/services/events/schema.d.ts +66 -24
  14. package/dist/services/events/schema.js +34 -3
  15. package/dist/services/opentelemetry/api.js +2 -1
  16. package/dist/services/opentelemetry/browser.d.ts +1 -1
  17. package/dist/services/opentelemetry/browser.js +2 -1
  18. package/dist/services/opentelemetry/events.d.ts +1 -1
  19. package/dist/services/opentelemetry/index.d.ts +1 -1
  20. package/dist/services/opentelemetry/index.js +2 -1
  21. package/dist/services/opentelemetry/schema.d.ts +3 -1
  22. package/dist/services/opentelemetry/web-vitals.js +2 -1
  23. package/dist/services/webhooks/client/delivery-table.d.ts +62 -0
  24. package/dist/services/webhooks/client/delivery-table.js +4698 -0
  25. package/dist/services/webhooks/http-client.d.ts +8 -0
  26. package/dist/services/webhooks/http-client.js +69 -0
  27. package/dist/services/webhooks/index.d.ts +343 -0
  28. package/dist/services/webhooks/index.js +872 -0
  29. package/dist/services/webhooks/migrations.d.ts +8 -0
  30. package/dist/services/webhooks/migrations.js +63 -0
  31. package/dist/services/webhooks/receiver.d.ts +41 -0
  32. package/dist/services/webhooks/schema.d.ts +251 -0
  33. package/dist/services/webhooks/schema.js +353 -0
  34. package/dist/services/webhooks/url.d.ts +8 -0
  35. package/dist/services/webhooks/url.js +48 -0
  36. package/package.json +29 -1
  37. package/dist/components/ui/marker.d.ts +0 -10
@@ -0,0 +1,8 @@
1
+ import { Effect, Layer } from "effect";
2
+ import { Migrator, SqlClient } from "effect/sql";
3
+ export declare const webhookMigrations: Migrator.Loader<never>;
4
+ export declare const migrateWebhooks: Effect.Effect<readonly (readonly [id: number, name: string])[], Migrator.MigrationError | import("effect/sql/SqlError").SqlError, SqlClient.SqlClient>;
5
+ export declare const webhookMigrationsLayer: Layer.Layer<never, Migrator.MigrationError | import("effect/sql/SqlError").SqlError, SqlClient.SqlClient>;
6
+ export declare const webhookReceiverMigrations: Migrator.Loader<never>;
7
+ export declare const migrateWebhookReceiver: Effect.Effect<readonly (readonly [id: number, name: string])[], Migrator.MigrationError | import("effect/sql/SqlError").SqlError, SqlClient.SqlClient>;
8
+ export declare const webhookReceiverMigrationsLayer: Layer.Layer<never, Migrator.MigrationError | import("effect/sql/SqlError").SqlError, SqlClient.SqlClient>;
@@ -0,0 +1,63 @@
1
+ // ../../src/services/webhooks/migrations.ts
2
+ import { Effect, Layer } from "effect";
3
+ import { Migrator, SqlClient } from "effect/sql";
4
+ var webhookMigrations = Migrator.fromRecord({
5
+ "1_webhooks_initial": Effect.gen(function* () {
6
+ const sql = yield* SqlClient.SqlClient;
7
+ yield* sql`CREATE TABLE IF NOT EXISTS webhooks (
8
+ id text PRIMARY KEY, organization_id text NOT NULL, url text NOT NULL,
9
+ description text, headers jsonb, events jsonb, secret text NOT NULL,
10
+ enabled boolean NOT NULL DEFAULT true,
11
+ created_at timestamp NOT NULL DEFAULT now(), updated_at timestamp NOT NULL DEFAULT now()
12
+ )`;
13
+ yield* sql`CREATE TABLE IF NOT EXISTS webhook_deliveries (
14
+ id text PRIMARY KEY, webhook_id text NOT NULL REFERENCES webhooks(id) ON DELETE CASCADE,
15
+ event text NOT NULL, data jsonb NOT NULL DEFAULT '{}', status text NOT NULL DEFAULT 'pending',
16
+ completed_at timestamp, retry_at timestamp NOT NULL DEFAULT now(), retries integer NOT NULL DEFAULT 0,
17
+ created_at timestamp NOT NULL DEFAULT now(), updated_at timestamp NOT NULL DEFAULT now()
18
+ )`;
19
+ yield* sql`ALTER TABLE webhook_deliveries ADD COLUMN IF NOT EXISTS event_id text`;
20
+ yield* sql`CREATE UNIQUE INDEX IF NOT EXISTS krakstack_webhook_event_endpoint ON webhook_deliveries (webhook_id, event_id) WHERE event_id IS NOT NULL`;
21
+ yield* sql`CREATE INDEX IF NOT EXISTS krakstack_webhook_pending ON webhook_deliveries (retry_at) WHERE status = 'pending'`;
22
+ yield* sql`CREATE INDEX IF NOT EXISTS krakstack_webhook_organization ON webhooks (organization_id)`;
23
+ yield* sql`CREATE TABLE IF NOT EXISTS webhook_publications (
24
+ organization_id text NOT NULL, event_id text NOT NULL, event text NOT NULL, data jsonb NOT NULL,
25
+ PRIMARY KEY (organization_id, event_id)
26
+ )`;
27
+ }),
28
+ "2_webhook_names": Effect.gen(function* () {
29
+ const sql = yield* SqlClient.SqlClient;
30
+ yield* sql`ALTER TABLE webhooks ADD COLUMN name text`;
31
+ yield* sql`UPDATE webhooks SET name = url WHERE name IS NULL`;
32
+ yield* sql`ALTER TABLE webhook_deliveries ADD COLUMN error text`;
33
+ })
34
+ });
35
+ var migrateWebhooks = Migrator.make({})({
36
+ loader: webhookMigrations,
37
+ table: "krakstack_webhook_migrations"
38
+ });
39
+ var webhookMigrationsLayer = Layer.effectDiscard(migrateWebhooks);
40
+ var webhookReceiverMigrations = Migrator.fromRecord({
41
+ "1_webhook_receipts": Effect.gen(function* () {
42
+ const sql = yield* SqlClient.SqlClient;
43
+ yield* sql`CREATE TABLE webhook_receipts (
44
+ receiver text NOT NULL, event_id text NOT NULL, body_hash text NOT NULL,
45
+ completed_at timestamptz NOT NULL DEFAULT now(),
46
+ PRIMARY KEY (receiver, event_id)
47
+ )`;
48
+ yield* sql`CREATE INDEX webhook_receipts_completed ON webhook_receipts (completed_at)`;
49
+ })
50
+ });
51
+ var migrateWebhookReceiver = Migrator.make({})({
52
+ loader: webhookReceiverMigrations,
53
+ table: "krakstack_webhook_receiver_migrations"
54
+ });
55
+ var webhookReceiverMigrationsLayer = Layer.effectDiscard(migrateWebhookReceiver);
56
+ export {
57
+ migrateWebhookReceiver,
58
+ migrateWebhooks,
59
+ webhookMigrations,
60
+ webhookMigrationsLayer,
61
+ webhookReceiverMigrations,
62
+ webhookReceiverMigrationsLayer
63
+ };
@@ -0,0 +1,41 @@
1
+ import { Context, Effect, Layer, Redacted, Schema } from "effect";
2
+ import { SqlClient } from "effect/sql";
3
+ declare const WebhookVerificationError_base: Schema.Class<WebhookVerificationError, Schema.TaggedStruct<"WebhookVerificationError", {
4
+ readonly reason: Schema.Literals<readonly ["headers", "timestamp", "signature", "payload"]>;
5
+ }>, import("effect/Cause").YieldableError>;
6
+ export declare class WebhookVerificationError extends WebhookVerificationError_base {
7
+ }
8
+ declare const WebhookReceiptConflict_base: Schema.Class<WebhookReceiptConflict, Schema.TaggedStruct<"WebhookReceiptConflict", {}>, import("effect/Cause").YieldableError>;
9
+ export declare class WebhookReceiptConflict extends WebhookReceiptConflict_base {
10
+ }
11
+ declare const WebhooksReceiver_base: Context.ServiceClass<WebhooksReceiver, "krakstack/webhooks/WebhooksReceiver", {
12
+ receive: <S extends Schema.Top, E, R>(input: {
13
+ readonly receiver: string;
14
+ readonly secret: Redacted.Redacted<string>;
15
+ readonly headers: Readonly<Record<string, string | undefined>>;
16
+ readonly body: string;
17
+ readonly schema: S;
18
+ readonly handle: (payload: S["Type"]) => Effect.Effect<void, E, R>;
19
+ }) => Effect.Effect<{
20
+ duplicate: boolean;
21
+ }, E | import("effect/crypto/CryptoError").CryptoError | import("effect/Cause").NoSuchElementError | Schema.SchemaError | import("effect/sql/SqlError").SqlError | WebhookReceiptConflict | WebhookVerificationError, R | S["DecodingServices"]>;
22
+ cleanup: () => Effect.Effect<void, import("effect/sql/SqlError").SqlError, never>;
23
+ }> & {
24
+ readonly make: Effect.Effect<{
25
+ receive: <S extends Schema.Top, E, R>(input: {
26
+ readonly receiver: string;
27
+ readonly secret: Redacted.Redacted<string>;
28
+ readonly headers: Readonly<Record<string, string | undefined>>;
29
+ readonly body: string;
30
+ readonly schema: S;
31
+ readonly handle: (payload: S["Type"]) => Effect.Effect<void, E, R>;
32
+ }) => Effect.Effect<{
33
+ duplicate: boolean;
34
+ }, E | import("effect/crypto/CryptoError").CryptoError | import("effect/Cause").NoSuchElementError | Schema.SchemaError | import("effect/sql/SqlError").SqlError | WebhookReceiptConflict | WebhookVerificationError, R | S["DecodingServices"]>;
35
+ cleanup: () => Effect.Effect<void, import("effect/sql/SqlError").SqlError, never>;
36
+ }, never, SqlClient.SqlClient>;
37
+ };
38
+ export declare class WebhooksReceiver extends WebhooksReceiver_base {
39
+ static readonly layer: Layer.Layer<WebhooksReceiver, import("effect/sql/Migrator").MigrationError | import("effect/sql/SqlError").SqlError, SqlClient.SqlClient>;
40
+ }
41
+ export {};
@@ -0,0 +1,251 @@
1
+ import { Schema } from "effect";
2
+ export declare const webhookColumns = "id, organization_id AS \"organizationId\", COALESCE(name, url) AS name, url, description, headers, events, secret, enabled, created_at AS \"createdAt\", updated_at AS \"updatedAt\"";
3
+ export declare const deliveryColumns = "d.id, d.webhook_id AS \"webhookId\", d.event, d.data, d.status, d.error, d.completed_at AS \"completedAt\", d.retry_at AS \"retryAt\", d.retries, d.created_at AS \"createdAt\", d.updated_at AS \"updatedAt\"";
4
+ export declare const WebhookScope: Schema.Struct<{
5
+ readonly organizationId: Schema.NonEmptyString;
6
+ }>;
7
+ export declare const WebhookRequest: Schema.Struct<{
8
+ readonly organizationId: Schema.NonEmptyString;
9
+ readonly id: Schema.NonEmptyString;
10
+ }>;
11
+ export declare const WebhookStatisticsInterval: Schema.Literals<readonly ["hour", "day"]>;
12
+ export type WebhookStatisticsInterval = typeof WebhookStatisticsInterval.Type;
13
+ export declare const WebhookStatisticsRequest: Schema.Struct<{
14
+ readonly organizationId: Schema.NonEmptyString;
15
+ readonly id: Schema.NonEmptyString;
16
+ readonly interval: Schema.Literals<readonly ["hour", "day"]>;
17
+ }>;
18
+ export declare const WebhookDeliveryCounts: Schema.Struct<{
19
+ readonly total: Schema.Int;
20
+ readonly success: Schema.Int;
21
+ readonly failed: Schema.Int;
22
+ }>;
23
+ export declare const WebhookEventCount: Schema.Struct<{
24
+ readonly event: Schema.String;
25
+ readonly total: Schema.Int;
26
+ }>;
27
+ export declare const WebhookDeliveryBucket: Schema.Struct<{
28
+ readonly total: Schema.Int;
29
+ readonly success: Schema.Int;
30
+ readonly failed: Schema.Int;
31
+ readonly bucket: Schema.Date;
32
+ readonly events: Schema.$Array<Schema.Struct<{
33
+ readonly event: Schema.String;
34
+ readonly total: Schema.Int;
35
+ }>>;
36
+ }>;
37
+ export declare const WebhookStatistics: Schema.Struct<{
38
+ readonly total: Schema.Int;
39
+ readonly success: Schema.Int;
40
+ readonly failed: Schema.Int;
41
+ readonly buckets: Schema.$Array<Schema.Struct<{
42
+ readonly total: Schema.Int;
43
+ readonly success: Schema.Int;
44
+ readonly failed: Schema.Int;
45
+ readonly bucket: Schema.Date;
46
+ readonly events: Schema.$Array<Schema.Struct<{
47
+ readonly event: Schema.String;
48
+ readonly total: Schema.Int;
49
+ }>>;
50
+ }>>;
51
+ }>;
52
+ export declare const WebhookName: Schema.Trim;
53
+ export declare const WebhookPayload: Schema.Struct<{
54
+ readonly name: Schema.optional<Schema.Trim>;
55
+ readonly url: Schema.String;
56
+ readonly description: Schema.NullOr<Schema.String>;
57
+ readonly enabled: Schema.Boolean;
58
+ readonly events: Schema.NullOr<Schema.$Array<Schema.NonEmptyString>>;
59
+ readonly customHeaders: Schema.NullOr<Schema.$Record<Schema.String, Schema.String>>;
60
+ }>;
61
+ export declare const webhookPayloadSchema: (allowLoopback: boolean) => Schema.Struct<{
62
+ readonly name: Schema.optional<Schema.Trim>;
63
+ readonly description: Schema.NullOr<Schema.String>;
64
+ readonly enabled: Schema.Boolean;
65
+ readonly events: Schema.NullOr<Schema.$Array<Schema.NonEmptyString>>;
66
+ readonly customHeaders: Schema.NullOr<Schema.$Record<Schema.String, Schema.String>>;
67
+ readonly url: Schema.String;
68
+ }>;
69
+ export declare const Webhook: Schema.Struct<{
70
+ readonly id: Schema.String;
71
+ readonly name: Schema.String;
72
+ readonly organizationId: Schema.String;
73
+ readonly url: Schema.String;
74
+ readonly description: Schema.NullOr<Schema.String>;
75
+ readonly headers: Schema.NullOr<Schema.$Record<Schema.String, Schema.String>>;
76
+ readonly events: Schema.NullOr<Schema.$Array<Schema.String>>;
77
+ readonly secret: Schema.String;
78
+ readonly enabled: Schema.Boolean;
79
+ readonly createdAt: Schema.Date;
80
+ readonly updatedAt: Schema.Date;
81
+ }>;
82
+ export declare const WebhookDelivery: Schema.Struct<{
83
+ readonly id: Schema.String;
84
+ readonly webhookId: Schema.String;
85
+ readonly event: Schema.String;
86
+ readonly data: Schema.Codec<Schema.Json, Schema.Json, never, never>;
87
+ readonly status: Schema.Literals<readonly ["pending", "success", "failed"]>;
88
+ readonly error: Schema.NullOr<Schema.String>;
89
+ readonly completedAt: Schema.NullOr<Schema.Date>;
90
+ readonly retryAt: Schema.Date;
91
+ readonly retries: Schema.Int;
92
+ readonly createdAt: Schema.Date;
93
+ readonly updatedAt: Schema.Date;
94
+ }>;
95
+ export declare const WebhookDeliverySortId: Schema.Literals<readonly ["id", "event", "status", "createdAt", "completedAt"]>;
96
+ export declare const WebhookDeliveriesQuery: Schema.Struct<{
97
+ readonly page: Schema.decodeTo<Schema.Int, Schema.optional<Schema.Union<readonly [Schema.Number, Schema.NumberFromString]>>, never, never>;
98
+ readonly pageSize: Schema.decodeTo<Schema.Int, Schema.optional<Schema.Union<readonly [Schema.Number, Schema.NumberFromString]>>, never, never>;
99
+ readonly globalFilter: Schema.optional<Schema.String>;
100
+ readonly filters: Schema.optional<Schema.declare<readonly ({
101
+ readonly id: string;
102
+ readonly kind: "number";
103
+ readonly min?: number | undefined;
104
+ readonly max?: number | undefined;
105
+ } | {
106
+ readonly id: string;
107
+ readonly kind: "date";
108
+ readonly from?: string | undefined;
109
+ readonly to?: string | undefined;
110
+ } | {
111
+ readonly id: string;
112
+ readonly kind: "text";
113
+ readonly operator: "contains" | "endsWith" | "equals" | "startsWith";
114
+ readonly value: string;
115
+ } | {
116
+ readonly id: string;
117
+ readonly kind: "boolean";
118
+ readonly value: boolean;
119
+ } | {
120
+ readonly id: string;
121
+ readonly kind: "values";
122
+ readonly values: readonly [string, ...string[]];
123
+ })[], readonly ({
124
+ readonly id: string;
125
+ readonly kind: "number";
126
+ readonly min?: number | undefined;
127
+ readonly max?: number | undefined;
128
+ } | {
129
+ readonly id: string;
130
+ readonly kind: "date";
131
+ readonly from?: string | undefined;
132
+ readonly to?: string | undefined;
133
+ } | {
134
+ readonly id: string;
135
+ readonly kind: "text";
136
+ readonly operator: "contains" | "endsWith" | "equals" | "startsWith";
137
+ readonly value: string;
138
+ } | {
139
+ readonly id: string;
140
+ readonly kind: "boolean";
141
+ readonly value: boolean;
142
+ } | {
143
+ readonly id: string;
144
+ readonly kind: "values";
145
+ readonly values: readonly [string, ...string[]];
146
+ })[]>>;
147
+ readonly sort: Schema.optional<Schema.declare<readonly {
148
+ readonly id: string;
149
+ readonly direction: "asc" | "desc";
150
+ }[], readonly {
151
+ readonly id: string;
152
+ readonly direction: "asc" | "desc";
153
+ }[]>>;
154
+ }>;
155
+ export declare const ListWebhookDeliveries: Schema.Struct<{
156
+ readonly page: Schema.decodeTo<Schema.Int, Schema.optional<Schema.Union<readonly [Schema.Number, Schema.NumberFromString]>>, never, never>;
157
+ readonly pageSize: Schema.decodeTo<Schema.Int, Schema.optional<Schema.Union<readonly [Schema.Number, Schema.NumberFromString]>>, never, never>;
158
+ readonly globalFilter: Schema.optional<Schema.String>;
159
+ readonly organizationId: Schema.NonEmptyString;
160
+ readonly id: Schema.NonEmptyString;
161
+ readonly filters: Schema.optional<Schema.declare<readonly ({
162
+ readonly id: string;
163
+ readonly kind: "number";
164
+ readonly min?: number | undefined;
165
+ readonly max?: number | undefined;
166
+ } | {
167
+ readonly id: string;
168
+ readonly kind: "date";
169
+ readonly from?: string | undefined;
170
+ readonly to?: string | undefined;
171
+ } | {
172
+ readonly id: string;
173
+ readonly kind: "text";
174
+ readonly operator: "contains" | "endsWith" | "equals" | "startsWith";
175
+ readonly value: string;
176
+ } | {
177
+ readonly id: string;
178
+ readonly kind: "boolean";
179
+ readonly value: boolean;
180
+ } | {
181
+ readonly id: string;
182
+ readonly kind: "values";
183
+ readonly values: readonly [string, ...string[]];
184
+ })[], readonly ({
185
+ readonly id: string;
186
+ readonly kind: "number";
187
+ readonly min?: number | undefined;
188
+ readonly max?: number | undefined;
189
+ } | {
190
+ readonly id: string;
191
+ readonly kind: "date";
192
+ readonly from?: string | undefined;
193
+ readonly to?: string | undefined;
194
+ } | {
195
+ readonly id: string;
196
+ readonly kind: "text";
197
+ readonly operator: "contains" | "endsWith" | "equals" | "startsWith";
198
+ readonly value: string;
199
+ } | {
200
+ readonly id: string;
201
+ readonly kind: "boolean";
202
+ readonly value: boolean;
203
+ } | {
204
+ readonly id: string;
205
+ readonly kind: "values";
206
+ readonly values: readonly [string, ...string[]];
207
+ })[]>>;
208
+ readonly sort: Schema.optional<Schema.declare<readonly {
209
+ readonly id: string;
210
+ readonly direction: "asc" | "desc";
211
+ }[], readonly {
212
+ readonly id: string;
213
+ readonly direction: "asc" | "desc";
214
+ }[]>>;
215
+ }>;
216
+ export declare const WebhookDeliveries: Schema.Struct<{
217
+ readonly data: Schema.$Array<Schema.Struct<{
218
+ readonly id: Schema.String;
219
+ readonly webhookId: Schema.String;
220
+ readonly event: Schema.String;
221
+ readonly data: Schema.Codec<Schema.Json, Schema.Json, never, never>;
222
+ readonly status: Schema.Literals<readonly ["pending", "success", "failed"]>;
223
+ readonly error: Schema.NullOr<Schema.String>;
224
+ readonly completedAt: Schema.NullOr<Schema.Date>;
225
+ readonly retryAt: Schema.Date;
226
+ readonly retries: Schema.Int;
227
+ readonly createdAt: Schema.Date;
228
+ readonly updatedAt: Schema.Date;
229
+ }>>;
230
+ readonly meta: Schema.Struct<{
231
+ readonly page: Schema.Int;
232
+ readonly pageSize: Schema.Int;
233
+ readonly total: Schema.Int;
234
+ readonly pageCount: Schema.Int;
235
+ }>;
236
+ }>;
237
+ export declare const PublishWebhook: Schema.Struct<{
238
+ readonly organizationId: Schema.NonEmptyString;
239
+ readonly eventId: Schema.NonEmptyString;
240
+ readonly event: Schema.NonEmptyString;
241
+ readonly data: Schema.Codec<Schema.Json, Schema.Json, never, never>;
242
+ }>;
243
+ declare const WebhookError_base: Schema.Class<WebhookError, Schema.TaggedStruct<"WebhookError", {
244
+ readonly message: Schema.String;
245
+ }>, import("effect/Cause").YieldableError>;
246
+ export declare class WebhookError extends WebhookError_base {
247
+ }
248
+ export type Webhook = typeof Webhook.Type;
249
+ export type WebhookDelivery = typeof WebhookDelivery.Type;
250
+ export type WebhookPayload = typeof WebhookPayload.Type;
251
+ export {};