@krak-stack/assets 0.1.6 → 0.1.7

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.
@@ -1,110 +1,6 @@
1
1
  // ../assets/src/components/asset-input/html.ts
2
- import { Effect as Effect4, Layer, Redacted as Redacted4, Schema as Schema14 } from "effect";
2
+ import { Effect as Effect4, Layer, Redacted as Redacted4 } from "effect";
3
3
  import { AsyncResult as AsyncResult2 } from "effect/reactivity";
4
-
5
- // ../assets/src/services/assets/library.ts
6
- import {
7
- Context,
8
- Schema
9
- } from "effect";
10
- import { AsyncResult } from "effect/reactivity";
11
- import { Component, Query, UiSchema, View } from "effect/ui";
12
- var AssetLibraryAccessSchema = Schema.Struct({
13
- scopeKey: Schema.NonEmptyString,
14
- permissions: Schema.Array(Schema.Literals(["list", "read", "create", "update", "delete"]))
15
- }).annotate({ identifier: "AssetLibraryAccess" });
16
- var AssetListQuerySchema = Schema.Struct({
17
- search: Schema.optionalKey(Schema.String.check(Schema.isMaxLength(200))),
18
- kind: Schema.optionalKey(Schema.Literals(["image", "video", "caption", "document"]))
19
- }).annotate({ identifier: "AssetListQuery" });
20
- var AssetListItemSchema = Schema.Struct({
21
- id: Schema.String.check(Schema.isUUID()),
22
- name: Schema.NonEmptyString,
23
- mimeType: Schema.NonEmptyString,
24
- byteSize: Schema.Int,
25
- createdAt: Schema.Date,
26
- updatedAt: Schema.Date,
27
- url: Schema.optionalKey(Schema.String)
28
- }).annotate({ identifier: "AssetListItem" });
29
- var AssetStatsSchema = Schema.Struct({
30
- assetCount: Schema.Int,
31
- storageUsedBytes: Schema.Int
32
- }).annotate({ identifier: "AssetStats" });
33
- var AssetListSchema = Schema.Struct({
34
- items: Schema.Array(AssetListItemSchema),
35
- stats: AssetStatsSchema
36
- }).annotate({ identifier: "AssetList" });
37
- var AssetListArgsSchema = Schema.Struct({
38
- ...AssetListQuerySchema.fields,
39
- scopeKey: Schema.NonEmptyString,
40
- showFiles: Schema.Boolean
41
- }).annotate({ identifier: "AssetListArgs" });
42
- var AssetListError = Schema.Literals([
43
- "unauthorized",
44
- "forbidden",
45
- "unavailable"
46
- ]).annotate({ identifier: "AssetListError" });
47
-
48
- class AssetList extends Query.Service()("@krak-stack/assets/AssetList", {
49
- args: AssetListArgsSchema,
50
- success: AssetListSchema,
51
- error: AssetListError,
52
- staleTime: "30 seconds"
53
- }) {
54
- }
55
- var assetListArgs = (scopeKey, permissions, query = {}) => permissions.includes("list") ? { ...query, scopeKey, showFiles: permissions.includes("read") } : undefined;
56
- var AssetLibrarySnapshot = Schema.Struct({
57
- data: Schema.NullOr(AssetListSchema),
58
- status: Schema.Literals(["idle", "loading", "ready", "failed"])
59
- }).annotate({ identifier: "AssetLibrarySnapshot" });
60
- var AssetLibraryMessage = UiSchema.TaggedEnum({
61
- LibraryChanged: { library: AssetLibrarySnapshot }
62
- }).annotate({ identifier: "AssetLibraryMessage" });
63
- var emptyAssetLibrary = { data: null, status: "idle" };
64
- var libraryQuery = (result) => AssetLibraryMessage.LibraryChanged({
65
- library: AsyncResult.isSuccess(result) ? { data: result.value, status: "ready" } : {
66
- data: null,
67
- status: AsyncResult.isFailure(result) ? "failed" : "loading"
68
- }
69
- });
70
- var options = {
71
- name: "AssetLibraryModel",
72
- props: Schema.Struct({ access: AssetLibraryAccessSchema }).annotate({
73
- identifier: "AssetLibraryModelProps"
74
- }),
75
- model: AssetLibrarySnapshot,
76
- message: AssetLibraryMessage,
77
- restore: false,
78
- queries: {
79
- library: {
80
- query: AssetList,
81
- dropPrevious: true,
82
- args: ({ props }) => assetListArgs(props.access.scopeKey, props.access.permissions),
83
- onChange: libraryQuery
84
- }
85
- }
86
- };
87
- var definition = Component.define(options);
88
- var AssetLibraryModel = definition.make({
89
- init: () => emptyAssetLibrary,
90
- update: definition.update({ LibraryChanged: (_, { library }) => library }),
91
- view: () => View.text("")
92
- });
93
- var AssetUploadTransportMessages = {
94
- en: {
95
- rejected: "The file did not pass the security scan.",
96
- failed: "The file could not be published."
97
- },
98
- fr: {
99
- rejected: "Le fichier n’a pas passé l’analyse de sécurité.",
100
- failed: "Impossible de publier le fichier."
101
- }
102
- };
103
-
104
- class AssetLibraryActions extends Context.Service()("@krak-stack/assets/AssetLibraryActions") {
105
- }
106
-
107
- // ../assets/src/components/asset-input/html.ts
108
4
  import { Component as Component7 } from "effect/ui";
109
5
  import { Html as Html4 } from "effect/ui/html";
110
6
  import { Dialog, Field } from "effect/ui/kit";
@@ -120,8 +16,8 @@ import {
120
16
  import { FieldLabel, FieldRoot } from "@/components/effectcn/field";
121
17
 
122
18
  // ../../src/components/file-input/html.ts
123
- import { Effect as Effect2, Redacted as Redacted2, Schema as Schema4, Stream } from "effect";
124
- import { Component as Component3, Mount } from "effect/ui";
19
+ import { Effect, Redacted as Redacted2, Schema as Schema3, Stream } from "effect";
20
+ import { Component as Component2, Mount } from "effect/ui";
125
21
  import { Html } from "effect/ui/html";
126
22
  import { Button, buttonVariants } from "@/components/effectcn/button";
127
23
  import {
@@ -275,42 +171,42 @@ var fileType = (mimeType) => {
275
171
  };
276
172
 
277
173
  // ../../src/components/file-input/index.ts
278
- import { Redacted, Schema as Schema3 } from "effect";
279
- import { Component as Component2, UiSchema as UiSchema2 } from "effect/ui";
174
+ import { Redacted, Schema as Schema2 } from "effect";
175
+ import { Component, UiSchema } from "effect/ui";
280
176
 
281
177
  // ../../src/components/file-input/schema.ts
282
- import { Schema as Schema2, Struct } from "effect";
283
- var AcceptLabel = Schema2.declare((value) => typeof value === "function").annotate({ identifier: "FilePickerAcceptLabel" });
284
- var FilePickerFilesSchema = Schema2.Redacted(Schema2.Array(Schema2.File)).annotate({ identifier: "FilePickerFiles" });
285
- var FileInputClassesOverridesSchema = Schema2.Record(Schema2.Literals(Struct.keys(fileInputClasses)), Schema2.optionalKey(Schema2.String)).annotate({ identifier: "FileInputClassesOverrides" });
286
- var FilePickerPropsSchema = Schema2.Struct({
287
- classes: Schema2.optional(FileInputClassesOverridesSchema),
288
- accept: Schema2.optional(Schema2.String),
289
- canClear: Schema2.optional(Schema2.Boolean),
290
- file: Schema2.optional(Schema2.File),
291
- files: Schema2.optional(Schema2.Array(Schema2.File)),
292
- id: Schema2.String,
293
- image: Schema2.optional(Schema2.Struct({
294
- alt: Schema2.String,
295
- height: Schema2.Number,
296
- src: Schema2.optional(Schema2.String),
297
- width: Schema2.Number
178
+ import { Schema, Struct } from "effect";
179
+ var AcceptLabel = Schema.declare((value) => typeof value === "function").annotate({ identifier: "FilePickerAcceptLabel" });
180
+ var FilePickerFilesSchema = Schema.Redacted(Schema.Array(Schema.File)).annotate({ identifier: "FilePickerFiles" });
181
+ var FileInputClassesOverridesSchema = Schema.Record(Schema.Literals(Struct.keys(fileInputClasses)), Schema.optionalKey(Schema.String)).annotate({ identifier: "FileInputClassesOverrides" });
182
+ var FilePickerPropsSchema = Schema.Struct({
183
+ classes: Schema.optional(FileInputClassesOverridesSchema),
184
+ accept: Schema.optional(Schema.String),
185
+ canClear: Schema.optional(Schema.Boolean),
186
+ file: Schema.optional(Schema.File),
187
+ files: Schema.optional(Schema.Array(Schema.File)),
188
+ id: Schema.String,
189
+ image: Schema.optional(Schema.Struct({
190
+ alt: Schema.String,
191
+ height: Schema.Number,
192
+ src: Schema.optional(Schema.String),
193
+ width: Schema.Number
298
194
  }).annotate({ identifier: "FilePickerImage" })),
299
- invalid: Schema2.optional(Schema2.Boolean),
300
- locale: Schema2.optional(Schema2.String),
301
- messages: Schema2.optional(Schema2.Record(Schema2.String, Schema2.Struct({
302
- accepts: Schema2.optional(AcceptLabel),
303
- chooseFile: Schema2.optional(Schema2.String),
304
- chooseFiles: Schema2.optional(Schema2.String),
305
- deleteFile: Schema2.optional(Schema2.String),
306
- dropFile: Schema2.optional(Schema2.String),
307
- dropFiles: Schema2.optional(Schema2.String),
308
- replaceFile: Schema2.optional(Schema2.String)
195
+ invalid: Schema.optional(Schema.Boolean),
196
+ locale: Schema.optional(Schema.String),
197
+ messages: Schema.optional(Schema.Record(Schema.String, Schema.Struct({
198
+ accepts: Schema.optional(AcceptLabel),
199
+ chooseFile: Schema.optional(Schema.String),
200
+ chooseFiles: Schema.optional(Schema.String),
201
+ deleteFile: Schema.optional(Schema.String),
202
+ dropFile: Schema.optional(Schema.String),
203
+ dropFiles: Schema.optional(Schema.String),
204
+ replaceFile: Schema.optional(Schema.String)
309
205
  }).annotate({ identifier: "FilePickerMessageOverrides" }))),
310
- multiple: Schema2.optional(Schema2.Boolean),
311
- name: Schema2.String,
312
- required: Schema2.optional(Schema2.Boolean),
313
- showImageThumbnails: Schema2.optionalKey(Schema2.Boolean)
206
+ multiple: Schema.optional(Schema.Boolean),
207
+ name: Schema.String,
208
+ required: Schema.optional(Schema.Boolean),
209
+ showImageThumbnails: Schema.optionalKey(Schema.Boolean)
314
210
  }).annotate({ identifier: "FilePickerProps" });
315
211
 
316
212
  // ../../src/components/file-input/index.ts
@@ -361,17 +257,17 @@ var fileDescription = (file, locale) => [
361
257
  ].filter(Boolean).join(" · ");
362
258
  var filePickerKey = ({ name, size, lastModified }) => `${name}:${size}:${lastModified}`;
363
259
  var mergePickedFiles = (files, added) => Array.from(new Map([...files, ...added].map((file) => [filePickerKey(file), file])).values());
364
- var FilePickerMessage = UiSchema2.TaggedEnum({
260
+ var FilePickerMessage = UiSchema.TaggedEnum({
365
261
  Selected: { files: FilePickerFilesSchema },
366
262
  Dropped: { files: FilePickerFilesSchema },
367
- Removed: { index: Schema3.Int },
263
+ Removed: { index: Schema2.Int },
368
264
  Cleared: {},
369
265
  Blurred: {},
370
266
  DragEntered: {},
371
267
  DragLeft: {}
372
268
  }).annotate({ identifier: "FilePickerMessage" });
373
- var FilePickerEvents = UiSchema2.TaggedEnum({
374
- Change: { file: Schema3.Redacted(Schema3.File) },
269
+ var FilePickerEvents = UiSchema.TaggedEnum({
270
+ Change: { file: Schema2.Redacted(Schema2.File) },
375
271
  FilesChange: { files: FilePickerFilesSchema },
376
272
  Clear: {},
377
273
  Blur: {}
@@ -379,7 +275,7 @@ var FilePickerEvents = UiSchema2.TaggedEnum({
379
275
  var filePickerOptions = {
380
276
  name: "FilePicker",
381
277
  props: FilePickerPropsSchema,
382
- model: Schema3.Int,
278
+ model: Schema2.Int,
383
279
  message: FilePickerMessage,
384
280
  events: FilePickerEvents,
385
281
  restore: false
@@ -401,7 +297,7 @@ var selectFiles = ($, files, dropped) => {
401
297
  };
402
298
  var filePickerBehaviours = {
403
299
  init: () => 0,
404
- update: Component2.define(filePickerOptions).update({
300
+ update: Component.define(filePickerOptions).update({
405
301
  Selected: ($, { files }) => selectFiles($, Redacted.value(files), false),
406
302
  Dropped: ($, { files }) => selectFiles($, Redacted.value(files), true),
407
303
  Removed: ($, { index }) => $.set($.model).emit(FilePickerEvents.FilesChange({
@@ -442,25 +338,25 @@ var fileIcons = {
442
338
  };
443
339
  var fileTypeIconRenderer = (mimeType) => fileIcons[fileType(mimeType)];
444
340
  var FileTypeIcon = (h, mimeType) => fileTypeIconRenderer(mimeType)(h, { size: 18 });
445
- var PreviewFile = Mount.make("FilePickerPreviewFile", { args: { file: Schema4.Redacted(Schema4.File) } }, (image, _, changes) => Effect2.gen(function* () {
341
+ var PreviewFile = Mount.make("FilePickerPreviewFile", { args: { file: Schema3.Redacted(Schema3.File) } }, (image, _, changes) => Effect.gen(function* () {
446
342
  let url;
447
- yield* Effect2.addFinalizer(() => Effect2.sync(() => {
343
+ yield* Effect.addFinalizer(() => Effect.sync(() => {
448
344
  if (url)
449
345
  URL.revokeObjectURL(url);
450
346
  }));
451
- yield* changes.pipe(Stream.runForEach(({ file }) => Effect2.sync(() => {
347
+ yield* changes.pipe(Stream.runForEach(({ file }) => Effect.sync(() => {
452
348
  if (url)
453
349
  URL.revokeObjectURL(url);
454
350
  url = URL.createObjectURL(Redacted2.value(file));
455
351
  image.src = url;
456
352
  })));
457
- return Component3.noop;
353
+ return Component2.noop;
458
354
  }));
459
355
  var FileThumbnail = (h, file) => fileType(file.type) === "image" ? h.img.class("size-9 shrink-0 rounded-md object-cover").attr("alt", "").onMount(PreviewFile({ file: Redacted2.make(file) })) : FileTypeIcon(h, file.type);
460
- var props = Schema4.Struct({
356
+ var props = Schema3.Struct({
461
357
  ...filePickerOptions.props.fields,
462
- title: Schema4.String,
463
- showAcceptHint: Schema4.optionalKey(Schema4.Boolean)
358
+ title: Schema3.String,
359
+ showAcceptHint: Schema3.optionalKey(Schema3.Boolean)
464
360
  }).annotate({ identifier: "FilePickerHtmlProps" });
465
361
  var FileInput = Html.component({
466
362
  ...filePickerOptions,
@@ -512,7 +408,7 @@ var FileInput = Html.component({
512
408
  import { krakstackLocaleRead as krakstackLocaleRead4 } from "@krak-stack/registry/krakstack-provider/html";
513
409
 
514
410
  // ../../src/components/upload-attachment/html.ts
515
- import { Schema as Schema7 } from "effect";
411
+ import { Schema as Schema6 } from "effect";
516
412
  import { Html as Html2 } from "effect/ui/html";
517
413
  import { Button as Button2 } from "@/components/effectcn/button";
518
414
  import { krakstackLocaleRead as krakstackLocaleRead2 } from "@krak-stack/registry/krakstack-provider/html";
@@ -538,49 +434,49 @@ var resolveUploadAttachmentClasses = (overrides) => ({
538
434
  });
539
435
 
540
436
  // ../../src/components/upload-attachment/index.ts
541
- import { Schema as Schema6 } from "effect";
542
- import { Component as Component4, UiSchema as UiSchema3 } from "effect/ui";
437
+ import { Schema as Schema5 } from "effect";
438
+ import { Component as Component3, UiSchema as UiSchema2 } from "effect/ui";
543
439
 
544
440
  // ../../src/components/upload-attachment/schema.ts
545
- import { Schema as Schema5, Struct as Struct2 } from "effect";
546
- var UploadAttachmentStateSchema = Schema5.Union([
547
- Schema5.Struct({
548
- status: Schema5.Literals(["idle", "processing", "done", "cancelled"])
441
+ import { Schema as Schema4, Struct as Struct2 } from "effect";
442
+ var UploadAttachmentStateSchema = Schema4.Union([
443
+ Schema4.Struct({
444
+ status: Schema4.Literals(["idle", "processing", "done", "cancelled"])
549
445
  }),
550
- Schema5.Struct({
551
- status: Schema5.Literal("uploading"),
552
- progress: Schema5.optional(Schema5.Number)
446
+ Schema4.Struct({
447
+ status: Schema4.Literal("uploading"),
448
+ progress: Schema4.optional(Schema4.Number)
553
449
  }),
554
- Schema5.Struct({ status: Schema5.Literal("error"), message: Schema5.String })
450
+ Schema4.Struct({ status: Schema4.Literal("error"), message: Schema4.String })
555
451
  ]).annotate({ identifier: "UploadAttachmentState" });
556
- var Messages = Schema5.Struct({
557
- idle: Schema5.String,
558
- uploading: Schema5.String,
559
- processing: Schema5.String,
560
- done: Schema5.String,
561
- cancelled: Schema5.String,
562
- cancel: Schema5.String,
563
- retry: Schema5.String,
564
- remove: Schema5.String
452
+ var Messages = Schema4.Struct({
453
+ idle: Schema4.String,
454
+ uploading: Schema4.String,
455
+ processing: Schema4.String,
456
+ done: Schema4.String,
457
+ cancelled: Schema4.String,
458
+ cancel: Schema4.String,
459
+ retry: Schema4.String,
460
+ remove: Schema4.String
565
461
  }).annotate({ identifier: "UploadAttachmentMessages" });
566
- var UploadAttachmentClassesOverridesSchema = Schema5.Record(Schema5.Literals(Struct2.keys(uploadAttachmentClasses)), Schema5.optionalKey(Schema5.String)).annotate({ identifier: "UploadAttachmentClassesOverrides" });
567
- var UploadAttachmentPropsSchema = Schema5.Struct({
568
- classes: Schema5.optional(UploadAttachmentClassesOverridesSchema),
569
- name: Schema5.String,
570
- description: Schema5.optional(Schema5.String),
462
+ var UploadAttachmentClassesOverridesSchema = Schema4.Record(Schema4.Literals(Struct2.keys(uploadAttachmentClasses)), Schema4.optionalKey(Schema4.String)).annotate({ identifier: "UploadAttachmentClassesOverrides" });
463
+ var UploadAttachmentPropsSchema = Schema4.Struct({
464
+ classes: Schema4.optional(UploadAttachmentClassesOverridesSchema),
465
+ name: Schema4.String,
466
+ description: Schema4.optional(Schema4.String),
571
467
  state: UploadAttachmentStateSchema,
572
- disabled: Schema5.optional(Schema5.Boolean),
573
- className: Schema5.optional(Schema5.String),
574
- locale: Schema5.optional(Schema5.String),
575
- messages: Schema5.optional(Schema5.Record(Schema5.String, Messages.mapFields((fields) => ({
576
- idle: Schema5.optional(fields.idle),
577
- uploading: Schema5.optional(fields.uploading),
578
- processing: Schema5.optional(fields.processing),
579
- done: Schema5.optional(fields.done),
580
- cancelled: Schema5.optional(fields.cancelled),
581
- cancel: Schema5.optional(fields.cancel),
582
- retry: Schema5.optional(fields.retry),
583
- remove: Schema5.optional(fields.remove)
468
+ disabled: Schema4.optional(Schema4.Boolean),
469
+ className: Schema4.optional(Schema4.String),
470
+ locale: Schema4.optional(Schema4.String),
471
+ messages: Schema4.optional(Schema4.Record(Schema4.String, Messages.mapFields((fields) => ({
472
+ idle: Schema4.optional(fields.idle),
473
+ uploading: Schema4.optional(fields.uploading),
474
+ processing: Schema4.optional(fields.processing),
475
+ done: Schema4.optional(fields.done),
476
+ cancelled: Schema4.optional(fields.cancelled),
477
+ cancel: Schema4.optional(fields.cancel),
478
+ retry: Schema4.optional(fields.retry),
479
+ remove: Schema4.optional(fields.remove)
584
480
  }))))
585
481
  }).annotate({ identifier: "UploadAttachmentProps" });
586
482
 
@@ -621,7 +517,7 @@ var getUploadAttachmentPresentation = (state, locale = "en", messages) => {
621
517
  status: state.status === "error" ? state.message : copy[state.status]
622
518
  };
623
519
  };
624
- var UploadAttachmentAction = UiSchema3.TaggedEnum({
520
+ var UploadAttachmentAction = UiSchema2.TaggedEnum({
625
521
  Cancel: {},
626
522
  Retry: {},
627
523
  Remove: {}
@@ -629,7 +525,7 @@ var UploadAttachmentAction = UiSchema3.TaggedEnum({
629
525
  var uploadAttachmentOptions = {
630
526
  name: "UploadAttachment",
631
527
  props: UploadAttachmentPropsSchema,
632
- model: Schema6.Null,
528
+ model: Schema5.Null,
633
529
  message: UploadAttachmentAction,
634
530
  events: UploadAttachmentAction,
635
531
  restore: false
@@ -641,7 +537,7 @@ var update = ($, action) => {
641
537
  };
642
538
  var uploadAttachmentBehaviours = {
643
539
  init: () => null,
644
- update: Component4.define(uploadAttachmentOptions).update({
540
+ update: Component3.define(uploadAttachmentOptions).update({
645
541
  Cancel: update,
646
542
  Retry: update,
647
543
  Remove: update
@@ -649,11 +545,11 @@ var uploadAttachmentBehaviours = {
649
545
  };
650
546
 
651
547
  // ../../src/components/upload-attachment/html.ts
652
- var props2 = Schema7.Struct({
548
+ var props2 = Schema6.Struct({
653
549
  ...uploadAttachmentOptions.props.fields,
654
- canCancel: Schema7.optional(Schema7.Boolean),
655
- canRetry: Schema7.optional(Schema7.Boolean),
656
- canRemove: Schema7.optional(Schema7.Boolean)
550
+ canCancel: Schema6.optional(Schema6.Boolean),
551
+ canRetry: Schema6.optional(Schema6.Boolean),
552
+ canRemove: Schema6.optional(Schema6.Boolean)
657
553
  }).annotate({ identifier: "UploadAttachmentHtmlProps" });
658
554
  var UploadAttachment = Html2.component({
659
555
  ...uploadAttachmentOptions,
@@ -725,65 +621,65 @@ var resolveVirtualizedComboboxClasses = (overrides) => ({
725
621
  });
726
622
 
727
623
  // ../../src/components/virtualized-combobox/index.ts
728
- import { Schema as Schema9 } from "effect";
729
- import { Component as Component5, UiSchema as UiSchema4 } from "effect/ui";
624
+ import { Schema as Schema8 } from "effect";
625
+ import { Component as Component4, UiSchema as UiSchema3 } from "effect/ui";
730
626
 
731
627
  // ../../src/components/virtualized-combobox/schema.ts
732
- import { Predicate, Schema as Schema8, Struct as Struct3 } from "effect";
733
- var Icon = Schema8.declare((value) => Predicate.isFunction(value)).annotate({ identifier: "VirtualizedComboboxIcon" });
734
- var VirtualizedComboboxOptionSchema = Schema8.Struct({
735
- value: Schema8.String.pipe(Schema8.mutableKey),
736
- label: Schema8.String.pipe(Schema8.mutableKey),
737
- description: Schema8.optionalKey(Schema8.String),
738
- imageSrc: Schema8.optionalKey(Schema8.String),
739
- icon: Schema8.optionalKey(Icon)
628
+ import { Predicate, Schema as Schema7, Struct as Struct3 } from "effect";
629
+ var Icon = Schema7.declare((value) => Predicate.isFunction(value)).annotate({ identifier: "VirtualizedComboboxIcon" });
630
+ var VirtualizedComboboxOptionSchema = Schema7.Struct({
631
+ value: Schema7.String.pipe(Schema7.mutableKey),
632
+ label: Schema7.String.pipe(Schema7.mutableKey),
633
+ description: Schema7.optionalKey(Schema7.String),
634
+ imageSrc: Schema7.optionalKey(Schema7.String),
635
+ icon: Schema7.optionalKey(Icon)
740
636
  }).annotate({ identifier: "VirtualizedComboboxOption" });
741
- var VirtualizedComboboxLabelsSchema = Schema8.Struct({
742
- clear: Schema8.optionalKey(Schema8.String),
743
- search: Schema8.optionalKey(Schema8.String),
744
- selectMore: Schema8.optionalKey(Schema8.String)
637
+ var VirtualizedComboboxLabelsSchema = Schema7.Struct({
638
+ clear: Schema7.optionalKey(Schema7.String),
639
+ search: Schema7.optionalKey(Schema7.String),
640
+ selectMore: Schema7.optionalKey(Schema7.String)
745
641
  }).annotate({ identifier: "VirtualizedComboboxLabels" });
746
- var VirtualizedComboboxClassesOverridesSchema = Schema8.Record(Schema8.Literals(Struct3.keys(virtualizedComboboxClasses)), Schema8.optionalKey(Schema8.String)).annotate({ identifier: "VirtualizedComboboxClassesOverrides" });
747
- var VirtualizedComboboxSharedPropsSchema = Schema8.Struct({
748
- classes: Schema8.optional(VirtualizedComboboxClassesOverridesSchema),
749
- ariaLabel: Schema8.String,
750
- ariaInvalid: Schema8.optionalKey(Schema8.Boolean),
751
- contentClassName: Schema8.optionalKey(Schema8.String),
752
- disabled: Schema8.optionalKey(Schema8.Boolean),
753
- items: Schema8.Array(VirtualizedComboboxOptionSchema),
754
- locale: Schema8.optionalKey(Schema8.String),
755
- open: Schema8.optionalKey(Schema8.Boolean),
756
- searchValue: Schema8.optionalKey(Schema8.String),
757
- triggerId: Schema8.optionalKey(Schema8.String)
642
+ var VirtualizedComboboxClassesOverridesSchema = Schema7.Record(Schema7.Literals(Struct3.keys(virtualizedComboboxClasses)), Schema7.optionalKey(Schema7.String)).annotate({ identifier: "VirtualizedComboboxClassesOverrides" });
643
+ var VirtualizedComboboxSharedPropsSchema = Schema7.Struct({
644
+ classes: Schema7.optional(VirtualizedComboboxClassesOverridesSchema),
645
+ ariaLabel: Schema7.String,
646
+ ariaInvalid: Schema7.optionalKey(Schema7.Boolean),
647
+ contentClassName: Schema7.optionalKey(Schema7.String),
648
+ disabled: Schema7.optionalKey(Schema7.Boolean),
649
+ items: Schema7.Array(VirtualizedComboboxOptionSchema),
650
+ locale: Schema7.optionalKey(Schema7.String),
651
+ open: Schema7.optionalKey(Schema7.Boolean),
652
+ searchValue: Schema7.optionalKey(Schema7.String),
653
+ triggerId: Schema7.optionalKey(Schema7.String)
758
654
  }).annotate({ identifier: "VirtualizedComboboxSharedProps" });
759
655
  var htmlFields = {
760
656
  ...VirtualizedComboboxSharedPropsSchema.fields,
761
- emptyLabel: Schema8.String,
762
- placeholder: Schema8.String,
763
- triggerLabel: Schema8.optionalKey(Schema8.String),
764
- triggerIcon: Schema8.optionalKey(Icon),
765
- itemHeight: Schema8.optionalKey(Schema8.Int.check(Schema8.isGreaterThan(0))),
766
- filter: Schema8.optionalKey(Schema8.Literals(["contains", "none"])),
767
- messages: Schema8.optionalKey(Schema8.Record(Schema8.String, Schema8.Struct({
657
+ emptyLabel: Schema7.String,
658
+ placeholder: Schema7.String,
659
+ triggerLabel: Schema7.optionalKey(Schema7.String),
660
+ triggerIcon: Schema7.optionalKey(Icon),
661
+ itemHeight: Schema7.optionalKey(Schema7.Int.check(Schema7.isGreaterThan(0))),
662
+ filter: Schema7.optionalKey(Schema7.Literals(["contains", "none"])),
663
+ messages: Schema7.optionalKey(Schema7.Record(Schema7.String, Schema7.Struct({
768
664
  ...VirtualizedComboboxLabelsSchema.fields,
769
- selected: Schema8.optionalKey(Schema8.String)
665
+ selected: Schema7.optionalKey(Schema7.String)
770
666
  })))
771
667
  };
772
- var VirtualizedComboboxPropsSchema = Schema8.Union([
773
- Schema8.Struct({
668
+ var VirtualizedComboboxPropsSchema = Schema7.Union([
669
+ Schema7.Struct({
774
670
  ...htmlFields,
775
- multiple: Schema8.optionalKey(Schema8.Literal(false)),
776
- value: Schema8.NullOr(VirtualizedComboboxOptionSchema)
671
+ multiple: Schema7.optionalKey(Schema7.Literal(false)),
672
+ value: Schema7.NullOr(VirtualizedComboboxOptionSchema)
777
673
  }),
778
- Schema8.Struct({
674
+ Schema7.Struct({
779
675
  ...htmlFields,
780
- multiple: Schema8.Literal(true),
781
- value: Schema8.Array(VirtualizedComboboxOptionSchema)
676
+ multiple: Schema7.Literal(true),
677
+ value: Schema7.Array(VirtualizedComboboxOptionSchema)
782
678
  })
783
679
  ]).annotate({ identifier: "VirtualizedComboboxProps" });
784
680
 
785
681
  // ../../src/components/virtualized-combobox/index.ts
786
- var isText = Schema9.is(Schema9.String);
682
+ var isText = Schema8.is(Schema8.String);
787
683
  var defaultMessages3 = {
788
684
  en: {
789
685
  clear: "Clear selection",
@@ -841,36 +737,36 @@ var selectionEntries = (items, selected, groupSelections, labels) => {
841
737
  ];
842
738
  };
843
739
  var events = {
844
- OpenChanged: { open: Schema9.Boolean },
845
- SearchChanged: { searchValue: Schema9.String },
740
+ OpenChanged: { open: Schema8.Boolean },
741
+ SearchChanged: { searchValue: Schema8.String },
846
742
  ValueChanged: {
847
- value: Schema9.NullOr(Schema9.Union([Schema9.String, Schema9.Array(Schema9.String)]))
743
+ value: Schema8.NullOr(Schema8.Union([Schema8.String, Schema8.Array(Schema8.String)]))
848
744
  }
849
745
  };
850
746
  var selectionId = (value) => isText(value) ? value : null;
851
747
  var selectionIds = (value) => isText(value) ? [value] : value ?? [];
852
- var VirtualizedComboboxEvents = UiSchema4.TaggedEnum(events).annotate({
748
+ var VirtualizedComboboxEvents = UiSchema3.TaggedEnum(events).annotate({
853
749
  identifier: "VirtualizedComboboxEvents"
854
750
  });
855
- var VirtualizedComboboxMessage = UiSchema4.TaggedEnum({
751
+ var VirtualizedComboboxMessage = UiSchema3.TaggedEnum({
856
752
  ...events,
857
- Highlighted: { value: Schema9.String },
858
- ImageFailed: { src: Schema9.String }
753
+ Highlighted: { value: Schema8.String },
754
+ ImageFailed: { src: Schema8.String }
859
755
  }).annotate({ identifier: "VirtualizedComboboxMessage" });
860
756
  var virtualizedComboboxOptions = {
861
757
  name: "VirtualizedCombobox",
862
758
  props: VirtualizedComboboxPropsSchema,
863
- model: Schema9.Struct({
864
- open: Schema9.Boolean,
865
- searchValue: Schema9.String,
866
- failedImages: Schema9.Array(Schema9.String),
867
- highlight: Schema9.NullOr(Schema9.Struct({ value: Schema9.String, id: Schema9.Int }))
759
+ model: Schema8.Struct({
760
+ open: Schema8.Boolean,
761
+ searchValue: Schema8.String,
762
+ failedImages: Schema8.Array(Schema8.String),
763
+ highlight: Schema8.NullOr(Schema8.Struct({ value: Schema8.String, id: Schema8.Int }))
868
764
  }).annotate({ identifier: "VirtualizedComboboxModel" }),
869
765
  message: VirtualizedComboboxMessage,
870
766
  events: VirtualizedComboboxEvents,
871
767
  restore: false
872
768
  };
873
- var update2 = Component5.define(virtualizedComboboxOptions).update({
769
+ var update2 = Component4.define(virtualizedComboboxOptions).update({
874
770
  OpenChanged: ($, { open }) => $.set({
875
771
  ...$.model,
876
772
  open: $.props.open === undefined ? open : $.model.open,
@@ -1013,11 +909,11 @@ var VirtualizedCombobox = Html3.component({
1013
909
  import { FolderOpen, X as X2 } from "@krak-stack/registry/lucide-effect";
1014
910
 
1015
911
  // ../assets/src/services/assets/url.ts
1016
- import { Schema as Schema11 } from "effect";
912
+ import { Schema as Schema10 } from "effect";
1017
913
 
1018
914
  // ../assets/src/services/assets/schema.ts
1019
- import { Schema as Schema10 } from "effect";
1020
- var AssetHttpUrl = Schema10.String.check(Schema10.makeFilter((value) => {
915
+ import { Schema as Schema9 } from "effect";
916
+ var AssetHttpUrl = Schema9.String.check(Schema9.makeFilter((value) => {
1021
917
  if (!/^https?:\/\/[^/]/i.test(value) || /[\s\\]/u.test(value))
1022
918
  return false;
1023
919
  try {
@@ -1027,11 +923,11 @@ var AssetHttpUrl = Schema10.String.check(Schema10.makeFilter((value) => {
1027
923
  return false;
1028
924
  }
1029
925
  })).annotate({ identifier: "AssetHttpUrl" });
1030
- var AssetRelativeUrl = Schema10.String.check(Schema10.isPattern(/^\/(?!\/)[^\s\\]*$/u)).annotate({ identifier: "AssetRelativeUrl" });
926
+ var AssetRelativeUrl = Schema9.String.check(Schema9.isPattern(/^\/(?!\/)[^\s\\]*$/u)).annotate({ identifier: "AssetRelativeUrl" });
1031
927
 
1032
928
  // ../assets/src/services/assets/url.ts
1033
- var isAssetHttpUrl = Schema11.is(AssetHttpUrl);
1034
- var isAssetRelativeUrl = Schema11.is(AssetRelativeUrl);
929
+ var isAssetHttpUrl = Schema10.is(AssetHttpUrl);
930
+ var isAssetRelativeUrl = Schema10.is(AssetRelativeUrl);
1035
931
  var assetUrl = ({ url }) => isAssetHttpUrl(url) || isAssetRelativeUrl(url) ? url : undefined;
1036
932
  var assetImage = (asset) => {
1037
933
  const url = asset.mimeType.trim().toLowerCase().startsWith("image/") ? assetUrl(asset) : undefined;
@@ -1046,6 +942,125 @@ var assetImage = (asset) => {
1046
942
  import { Effect as Effect3, Queue, Redacted as Redacted3, Schema as Schema13, Stream as Stream2 } from "effect";
1047
943
  import { Command, Component as Component6, UiSchema as UiSchema5 } from "effect/ui";
1048
944
 
945
+ // ../assets/src/services/assets/library.ts
946
+ import {
947
+ Context,
948
+ Effect as Effect2,
949
+ Schema as Schema11
950
+ } from "effect";
951
+ import { AsyncResult } from "effect/reactivity";
952
+ import { Component as Component5, Query, UiSchema as UiSchema4, View } from "effect/ui";
953
+ var AssetLibraryAccessSchema = Schema11.Struct({
954
+ scopeKey: Schema11.NonEmptyString,
955
+ permissions: Schema11.Array(Schema11.Literals(["list", "read", "create", "update", "delete"]))
956
+ }).annotate({ identifier: "AssetLibraryAccess" });
957
+ var AssetListQuerySchema = Schema11.Struct({
958
+ search: Schema11.optionalKey(Schema11.String.check(Schema11.isMaxLength(200))),
959
+ kind: Schema11.optionalKey(Schema11.Literals(["image", "video", "caption", "document"]))
960
+ }).annotate({ identifier: "AssetListQuery" });
961
+ var AssetListItemSchema = Schema11.Struct({
962
+ id: Schema11.String.check(Schema11.isUUID()),
963
+ name: Schema11.NonEmptyString,
964
+ mimeType: Schema11.NonEmptyString,
965
+ byteSize: Schema11.Int,
966
+ createdAt: Schema11.Date,
967
+ updatedAt: Schema11.Date,
968
+ url: Schema11.optionalKey(Schema11.String)
969
+ }).annotate({ identifier: "AssetListItem" });
970
+ var AssetStatsSchema = Schema11.Struct({
971
+ assetCount: Schema11.Int,
972
+ storageUsedBytes: Schema11.Int
973
+ }).annotate({ identifier: "AssetStats" });
974
+ var AssetListSchema = Schema11.Struct({
975
+ items: Schema11.Array(AssetListItemSchema),
976
+ stats: AssetStatsSchema
977
+ }).annotate({ identifier: "AssetList" });
978
+ var AssetListArgsSchema = Schema11.Struct({
979
+ ...AssetListQuerySchema.fields,
980
+ scopeKey: Schema11.NonEmptyString,
981
+ showFiles: Schema11.Boolean
982
+ }).annotate({ identifier: "AssetListArgs" });
983
+ var AssetListError = Schema11.Literals([
984
+ "unauthorized",
985
+ "forbidden",
986
+ "unavailable"
987
+ ]).annotate({ identifier: "AssetListError" });
988
+
989
+ class AssetList extends Query.Service()("@krak-stack/assets/AssetList", {
990
+ args: AssetListArgsSchema,
991
+ success: AssetListSchema,
992
+ error: AssetListError,
993
+ staleTime: "30 seconds"
994
+ }) {
995
+ }
996
+ var disabledAssetListLayer = AssetList.toLayer(() => Effect2.fail("unavailable"));
997
+ var assetListArgs = (scopeKey, permissions, query = {}) => permissions.includes("list") ? { ...query, scopeKey, showFiles: permissions.includes("read") } : undefined;
998
+ var assetLibraryQuery = (getAccess) => ({
999
+ query: AssetList,
1000
+ dropPrevious: true,
1001
+ args: ({ props }) => {
1002
+ const access = getAccess(props);
1003
+ return access && assetListArgs(access.scopeKey, access.permissions);
1004
+ }
1005
+ });
1006
+ var AssetLibraryPropsSchema = Schema11.Struct({
1007
+ access: AssetLibraryAccessSchema
1008
+ }).annotate({ identifier: "AssetLibraryModelProps" });
1009
+ var AssetLibrarySnapshot = Schema11.Struct({
1010
+ data: Schema11.NullOr(AssetListSchema),
1011
+ status: Schema11.Literals(["idle", "loading", "ready", "failed"])
1012
+ }).annotate({ identifier: "AssetLibrarySnapshot" });
1013
+ var AssetLibraryMessage = UiSchema4.TaggedEnum({
1014
+ LibraryChanged: { library: AssetLibrarySnapshot }
1015
+ }).annotate({ identifier: "AssetLibraryMessage" });
1016
+ var emptyAssetLibrary = { data: null, status: "idle" };
1017
+ var assetLibrarySnapshot = (result) => AsyncResult.isSuccess(result) ? { data: result.value, status: "ready" } : {
1018
+ data: null,
1019
+ status: AsyncResult.isFailure(result) ? "failed" : "loading"
1020
+ };
1021
+ var libraryQuery = (result) => AssetLibraryMessage.LibraryChanged({ library: assetLibrarySnapshot(result) });
1022
+ var assetLibraryOptions = {
1023
+ name: "AssetLibraryView",
1024
+ props: AssetLibraryPropsSchema,
1025
+ model: Schema11.Null,
1026
+ message: Schema11.Never,
1027
+ restore: false,
1028
+ queries: {
1029
+ library: assetLibraryQuery((props) => props.access)
1030
+ }
1031
+ };
1032
+ var options = {
1033
+ ...assetLibraryOptions,
1034
+ name: "AssetLibraryModel",
1035
+ model: AssetLibrarySnapshot,
1036
+ message: AssetLibraryMessage,
1037
+ queries: {
1038
+ library: {
1039
+ ...assetLibraryOptions.queries.library,
1040
+ onChange: libraryQuery
1041
+ }
1042
+ }
1043
+ };
1044
+ var definition = Component5.define(options);
1045
+ var AssetLibraryModel = definition.make({
1046
+ init: () => emptyAssetLibrary,
1047
+ update: definition.update({ LibraryChanged: (_, { library }) => library }),
1048
+ view: () => View.text("")
1049
+ });
1050
+ var AssetUploadTransportMessages = {
1051
+ en: {
1052
+ rejected: "The file did not pass the security scan.",
1053
+ failed: "The file could not be published."
1054
+ },
1055
+ fr: {
1056
+ rejected: "Le fichier n’a pas passé l’analyse de sécurité.",
1057
+ failed: "Impossible de publier le fichier."
1058
+ }
1059
+ };
1060
+
1061
+ class AssetLibraryActions extends Context.Service()("@krak-stack/assets/AssetLibraryActions") {
1062
+ }
1063
+
1049
1064
  // ../assets/src/components/asset-input/schema.ts
1050
1065
  import { Schema as Schema12 } from "effect";
1051
1066
  var AssetInputItemSchema = Schema12.Struct({
@@ -1100,6 +1115,7 @@ var AssetInputPropsSchema = Schema12.Struct({
1100
1115
  }))),
1101
1116
  uploader: Schema12.optionalKey(AssetUploadPropsSchema)
1102
1117
  }).annotate({ identifier: "AssetInputProps" });
1118
+ var AssetInputPickerPropsSchema = AssetInputPropsSchema.mapFields(({ assets, access, value }) => ({ assets, access, value })).annotate({ identifier: "AssetInputPickerProps" });
1103
1119
  var AssetUploadJobSchema = Schema12.Struct({
1104
1120
  id: Schema12.Int,
1105
1121
  file: Schema12.Redacted(Schema12.File),
@@ -1116,6 +1132,20 @@ var AssetUploadJobSchema = Schema12.Struct({
1116
1132
  }).annotate({ identifier: "AssetUploadJob" });
1117
1133
 
1118
1134
  // ../assets/src/components/asset-input/index.ts
1135
+ var assetInputPickerOptions = {
1136
+ name: "AssetInputPicker",
1137
+ props: AssetInputPickerPropsSchema,
1138
+ model: Schema13.Null,
1139
+ message: Schema13.Never,
1140
+ restore: false,
1141
+ queries: {
1142
+ library: assetLibraryQuery((props) => props.assets === undefined && props.value !== undefined ? props.access : undefined)
1143
+ }
1144
+ };
1145
+ var assetInputPickerBehaviours = {
1146
+ init: () => null,
1147
+ update: () => null
1148
+ };
1119
1149
  var inputCopy = {
1120
1150
  en: {
1121
1151
  placeholder: "Choose asset",
@@ -1384,22 +1414,11 @@ var assetUploadState = (job, copy) => {
1384
1414
  var AssetInputView = Html4.component({
1385
1415
  ...assetInputOptions,
1386
1416
  slots: ["uploadAction"],
1387
- reads: { localeConfig: krakstackLocaleRead4 },
1388
- queries: {
1389
- library: {
1390
- query: AssetList,
1391
- dropPrevious: true,
1392
- args: ({ props }) => props.assets === undefined && props.value !== undefined && props.access ? assetListArgs(props.access.scopeKey, props.access.permissions) : undefined
1393
- }
1394
- }
1417
+ reads: { localeConfig: krakstackLocaleRead4 }
1395
1418
  }).make({
1396
1419
  ...assetInputBehaviours,
1397
1420
  view: (h, model) => {
1398
- const result = h.queries.library;
1399
- const p = {
1400
- ...h.props,
1401
- assets: h.props.assets ?? (h.props.value !== undefined && h.props.access?.permissions.includes("list") ? AsyncResult2.isSuccess(result) ? result.value.items : [] : undefined)
1402
- };
1421
+ const p = h.props;
1403
1422
  const locale = p.locale ?? h.reads.localeConfig?.locale ?? "en";
1404
1423
  const labels = assetInputMessages(locale, p.messages);
1405
1424
  const upload = p.uploader;
@@ -1515,25 +1534,31 @@ var AssetInputView = Html4.component({
1515
1534
  var connectedUpload = (props) => Layer.unwrap(Effect4.context().pipe(Effect4.map((context) => assetUploadLayer(libraryUpload(Effect4.runPromiseWith(context), props.locale ?? "en", props.replaceId)))));
1516
1535
  var ConnectedAssetInput = AssetInputView.pipe(Component7.provide(connectedUpload));
1517
1536
  var AssetInput = Html4.component({
1537
+ ...assetInputPickerOptions,
1518
1538
  name: "AssetInputConnection",
1519
1539
  props: assetInputOptions.props,
1520
- model: Schema14.Null,
1521
1540
  message: AssetInputEvents,
1522
1541
  events: AssetInputEvents,
1523
1542
  slots: ["uploadAction"],
1524
- reads: { localeConfig: krakstackLocaleRead4 },
1525
- restore: false
1543
+ reads: { localeConfig: krakstackLocaleRead4 }
1526
1544
  }).make({
1527
- init: () => null,
1545
+ ...assetInputPickerBehaviours,
1528
1546
  update: ($, event) => $.emit(event),
1529
1547
  view: (h) => {
1530
- const { access, uploader, replaceId } = h.props;
1548
+ const { access, uploader, replaceId, value } = h.props;
1549
+ const result = h.queries.library;
1550
+ const assets = h.props.assets ?? (value !== undefined && access?.permissions.includes("list") ? AsyncResult2.isSuccess(result) ? result.value.items : [] : undefined);
1531
1551
  const connected = !uploader && access?.permissions.includes(replaceId ? "update" : "create");
1532
1552
  const Input = connected ? ConnectedAssetInput : AssetInputView;
1533
1553
  const locale = h.props.locale ?? h.reads.localeConfig?.locale ?? "en";
1534
1554
  return Input(h, {
1535
1555
  key: JSON.stringify([access?.scopeKey, connected, replaceId, locale]),
1536
- props: { ...h.props, locale, ...connected ? { uploader: {} } : {} },
1556
+ props: {
1557
+ ...h.props,
1558
+ ...assets === undefined ? {} : { assets },
1559
+ locale,
1560
+ ...connected ? { uploader: {} } : {}
1561
+ },
1537
1562
  slots: h.slots,
1538
1563
  onEmit: (event) => event
1539
1564
  });