@weirdfingers/boards 0.4.0 → 0.5.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -39,6 +39,7 @@ __export(index_exports, {
39
39
  GET_GENERATIONS: () => GET_GENERATIONS,
40
40
  GET_GENERATORS: () => GET_GENERATORS,
41
41
  GenerationStatus: () => GenerationStatus,
42
+ GeneratorSelectionProvider: () => GeneratorSelectionProvider,
42
43
  NoAuthProvider: () => NoAuthProvider,
43
44
  REMOVE_BOARD_MEMBER: () => REMOVE_BOARD_MEMBER,
44
45
  RETRY_GENERATION: () => RETRY_GENERATION,
@@ -58,6 +59,7 @@ __export(index_exports, {
58
59
  useBoard: () => useBoard,
59
60
  useBoards: () => useBoards,
60
61
  useGeneration: () => useGeneration,
62
+ useGeneratorSelection: () => useGeneratorSelection,
61
63
  useGenerators: () => useGenerators
62
64
  });
63
65
  module.exports = __toCommonJS(index_exports);
@@ -269,6 +271,240 @@ function useApiConfig() {
269
271
  return context;
270
272
  }
271
273
 
274
+ // src/config/GeneratorSelectionContext.tsx
275
+ var import_react3 = require("react");
276
+
277
+ // src/utils/schemaParser.ts
278
+ function isArtifactReference(property) {
279
+ if (!property || typeof property === "boolean") {
280
+ return false;
281
+ }
282
+ if (property.$ref && property.$ref.includes("Artifact")) {
283
+ return true;
284
+ }
285
+ if (property.type === "array" && property.items && typeof property.items === "object" && !Array.isArray(property.items)) {
286
+ const items = property.items;
287
+ return !!(items.$ref && items.$ref.includes("Artifact"));
288
+ }
289
+ return false;
290
+ }
291
+ function getArtifactType(ref) {
292
+ const match = ref.match(/(Audio|Video|Image|Text)Artifact/);
293
+ if (match) {
294
+ return match[1].toLowerCase();
295
+ }
296
+ return "image";
297
+ }
298
+ function parseArtifactSlot(name, property, required) {
299
+ const title = property.title || name;
300
+ const description = property.description;
301
+ if (property.type === "array" && property.items) {
302
+ const items = typeof property.items === "object" && !Array.isArray(property.items) ? property.items : void 0;
303
+ const artifactType2 = items?.$ref ? getArtifactType(items.$ref) : "image";
304
+ return {
305
+ name: title,
306
+ fieldName: name,
307
+ artifactType: artifactType2,
308
+ required,
309
+ description,
310
+ isArray: true,
311
+ minItems: property.minItems,
312
+ maxItems: property.maxItems
313
+ };
314
+ }
315
+ const artifactType = property.$ref ? getArtifactType(property.$ref) : "image";
316
+ return {
317
+ name: title,
318
+ fieldName: name,
319
+ artifactType,
320
+ required,
321
+ description,
322
+ isArray: false
323
+ };
324
+ }
325
+ function isSlider(property) {
326
+ return (property.type === "number" || property.type === "integer") && property.minimum !== void 0 && property.maximum !== void 0;
327
+ }
328
+ function parseSettingsField(name, property) {
329
+ const title = property.title || name;
330
+ const description = property.description;
331
+ if (property.enum && Array.isArray(property.enum)) {
332
+ const options = property.enum.map((val) => String(val));
333
+ const defaultValue = property.default !== void 0 ? String(property.default) : void 0;
334
+ return {
335
+ type: "dropdown",
336
+ fieldName: name,
337
+ title,
338
+ description,
339
+ options,
340
+ default: defaultValue
341
+ };
342
+ }
343
+ if (isSlider(property)) {
344
+ const isInteger = property.type === "integer";
345
+ return {
346
+ type: "slider",
347
+ fieldName: name,
348
+ title,
349
+ description,
350
+ min: property.minimum,
351
+ max: property.maximum,
352
+ step: property.multipleOf,
353
+ default: property.default !== void 0 ? property.default : void 0,
354
+ isInteger
355
+ };
356
+ }
357
+ if (property.type === "number" || property.type === "integer") {
358
+ const isInteger = property.type === "integer";
359
+ return {
360
+ type: "number",
361
+ fieldName: name,
362
+ title,
363
+ description,
364
+ default: property.default !== void 0 ? property.default : void 0,
365
+ min: property.minimum,
366
+ max: property.maximum,
367
+ isInteger
368
+ };
369
+ }
370
+ if (property.type === "string") {
371
+ return {
372
+ type: "text",
373
+ fieldName: name,
374
+ title,
375
+ description,
376
+ default: property.default !== void 0 ? String(property.default) : void 0,
377
+ pattern: property.pattern
378
+ };
379
+ }
380
+ return null;
381
+ }
382
+ function parseGeneratorSchema(schema) {
383
+ const artifactSlots = [];
384
+ const settingsFields = [];
385
+ let promptField = null;
386
+ if (!schema.properties) {
387
+ return { artifactSlots, promptField, settingsFields };
388
+ }
389
+ const required = schema.required || [];
390
+ for (const [name, propertyDef] of Object.entries(schema.properties)) {
391
+ if (typeof propertyDef === "boolean") {
392
+ continue;
393
+ }
394
+ const property = propertyDef;
395
+ const isRequired = required.includes(name);
396
+ if (isArtifactReference(property)) {
397
+ const slot = parseArtifactSlot(name, property, isRequired);
398
+ artifactSlots.push(slot);
399
+ continue;
400
+ }
401
+ if (name === "prompt" && property.type === "string") {
402
+ promptField = {
403
+ fieldName: name,
404
+ description: property.description,
405
+ required: isRequired,
406
+ default: property.default !== void 0 ? String(property.default) : void 0
407
+ };
408
+ continue;
409
+ }
410
+ const settingsField = parseSettingsField(name, property);
411
+ if (settingsField) {
412
+ settingsFields.push(settingsField);
413
+ }
414
+ }
415
+ return {
416
+ artifactSlots,
417
+ promptField,
418
+ settingsFields
419
+ };
420
+ }
421
+
422
+ // src/config/GeneratorSelectionContext.tsx
423
+ var import_jsx_runtime3 = require("react/jsx-runtime");
424
+ var GeneratorSelectionContext = (0, import_react3.createContext)(null);
425
+ function GeneratorSelectionProvider({
426
+ children
427
+ }) {
428
+ const [selectedGenerator, setSelectedGenerator] = (0, import_react3.useState)(null);
429
+ const [selectedArtifacts, setSelectedArtifacts] = (0, import_react3.useState)(/* @__PURE__ */ new Map());
430
+ const parsedSchema = (0, import_react3.useMemo)(() => {
431
+ if (!selectedGenerator) {
432
+ return null;
433
+ }
434
+ try {
435
+ return parseGeneratorSchema(selectedGenerator.inputSchema);
436
+ } catch (error) {
437
+ console.error("Failed to parse generator schema:", error);
438
+ return null;
439
+ }
440
+ }, [selectedGenerator]);
441
+ const artifactSlots = (0, import_react3.useMemo)(() => {
442
+ if (!parsedSchema) {
443
+ return [];
444
+ }
445
+ return parsedSchema.artifactSlots.map((slot) => ({
446
+ fieldName: slot.fieldName,
447
+ artifactType: slot.artifactType,
448
+ required: slot.required
449
+ }));
450
+ }, [parsedSchema]);
451
+ const canArtifactBeAdded = (0, import_react3.useCallback)((artifactType) => {
452
+ if (!artifactSlots.length) {
453
+ return false;
454
+ }
455
+ return artifactSlots.some(
456
+ (slot) => slot.artifactType.toLowerCase() === artifactType.toLowerCase() && !selectedArtifacts.has(slot.fieldName)
457
+ );
458
+ }, [artifactSlots, selectedArtifacts]);
459
+ const addArtifactToSlot = (0, import_react3.useCallback)((artifact) => {
460
+ if (!artifactSlots.length) {
461
+ return false;
462
+ }
463
+ const compatibleSlot = artifactSlots.find(
464
+ (slot) => slot.artifactType.toLowerCase() === artifact.artifactType.toLowerCase() && !selectedArtifacts.has(slot.fieldName)
465
+ );
466
+ if (!compatibleSlot) {
467
+ return false;
468
+ }
469
+ const newArtifacts = new Map(selectedArtifacts);
470
+ newArtifacts.set(compatibleSlot.fieldName, artifact);
471
+ setSelectedArtifacts(newArtifacts);
472
+ return true;
473
+ }, [artifactSlots, selectedArtifacts]);
474
+ const removeArtifactFromSlot = (0, import_react3.useCallback)((slotName) => {
475
+ const newArtifacts = new Map(selectedArtifacts);
476
+ newArtifacts.delete(slotName);
477
+ setSelectedArtifacts(newArtifacts);
478
+ }, [selectedArtifacts]);
479
+ const clearAllArtifacts = (0, import_react3.useCallback)(() => {
480
+ setSelectedArtifacts(/* @__PURE__ */ new Map());
481
+ }, []);
482
+ const handleSetSelectedGenerator = (0, import_react3.useCallback)((generator) => {
483
+ setSelectedGenerator(generator);
484
+ setSelectedArtifacts(/* @__PURE__ */ new Map());
485
+ }, []);
486
+ const value = {
487
+ selectedGenerator,
488
+ setSelectedGenerator: handleSetSelectedGenerator,
489
+ parsedSchema,
490
+ artifactSlots,
491
+ canArtifactBeAdded,
492
+ selectedArtifacts,
493
+ setSelectedArtifacts,
494
+ addArtifactToSlot,
495
+ removeArtifactFromSlot,
496
+ clearAllArtifacts
497
+ };
498
+ return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(GeneratorSelectionContext.Provider, { value, children });
499
+ }
500
+ function useGeneratorSelection() {
501
+ const context = (0, import_react3.useContext)(GeneratorSelectionContext);
502
+ if (!context) {
503
+ throw new Error("useGeneratorSelection must be used within GeneratorSelectionProvider");
504
+ }
505
+ return context;
506
+ }
507
+
272
508
  // src/graphql/client.ts
273
509
  var import_urql = require("urql");
274
510
  var import_exchange_auth = require("@urql/exchange-auth");
@@ -422,7 +658,7 @@ var GET_BOARD = import_urql2.gql`
422
658
  ${BOARD_FRAGMENT}
423
659
  ${USER_FRAGMENT}
424
660
  ${GENERATION_FRAGMENT}
425
- query GetBoard($id: UUID!) {
661
+ query GetBoard($id: UUID!, $limit: Int, $offset: Int) {
426
662
  board(id: $id) {
427
663
  ...BoardFragment
428
664
  owner {
@@ -442,7 +678,7 @@ var GET_BOARD = import_urql2.gql`
442
678
  ...UserFragment
443
679
  }
444
680
  }
445
- generations(limit: 10) {
681
+ generations(limit: $limit, offset: $offset) {
446
682
  ...GenerationFragment
447
683
  }
448
684
  }
@@ -593,19 +829,19 @@ var ArtifactType = /* @__PURE__ */ ((ArtifactType4) => {
593
829
  })(ArtifactType || {});
594
830
 
595
831
  // src/hooks/useBoards.ts
596
- var import_react3 = require("react");
832
+ var import_react4 = require("react");
597
833
  var import_urql3 = require("urql");
598
834
  function useBoards(options = {}) {
599
835
  const { limit = 50, offset = 0 } = options;
600
- const [searchQuery, setSearchQuery] = (0, import_react3.useState)("");
836
+ const [searchQuery, setSearchQuery] = (0, import_react4.useState)("");
601
837
  const [{ data, fetching, error }, reexecuteQuery] = (0, import_urql3.useQuery)({
602
838
  query: GET_BOARDS,
603
839
  variables: { limit, offset }
604
840
  });
605
841
  const [, createBoardMutation] = (0, import_urql3.useMutation)(CREATE_BOARD);
606
842
  const [, deleteBoardMutation] = (0, import_urql3.useMutation)(DELETE_BOARD);
607
- const boards = (0, import_react3.useMemo)(() => data?.myBoards || [], [data?.myBoards]);
608
- const createBoard = (0, import_react3.useCallback)(
843
+ const boards = (0, import_react4.useMemo)(() => data?.myBoards || [], [data?.myBoards]);
844
+ const createBoard = (0, import_react4.useCallback)(
609
845
  async (input) => {
610
846
  const result = await createBoardMutation({ input });
611
847
  if (result.error) {
@@ -619,7 +855,7 @@ function useBoards(options = {}) {
619
855
  },
620
856
  [createBoardMutation, reexecuteQuery]
621
857
  );
622
- const deleteBoard = (0, import_react3.useCallback)(
858
+ const deleteBoard = (0, import_react4.useCallback)(
623
859
  async (boardId) => {
624
860
  const result = await deleteBoardMutation({ id: boardId });
625
861
  if (result.error) {
@@ -632,7 +868,7 @@ function useBoards(options = {}) {
632
868
  },
633
869
  [deleteBoardMutation, reexecuteQuery]
634
870
  );
635
- const searchBoards = (0, import_react3.useCallback)(
871
+ const searchBoards = (0, import_react4.useCallback)(
636
872
  async (query) => {
637
873
  setSearchQuery(query);
638
874
  return new Promise((resolve) => {
@@ -647,7 +883,7 @@ function useBoards(options = {}) {
647
883
  },
648
884
  [boards]
649
885
  );
650
- const refresh = (0, import_react3.useCallback)(async () => {
886
+ const refresh = (0, import_react4.useCallback)(async () => {
651
887
  await reexecuteQuery({ requestPolicy: "network-only" });
652
888
  }, [reexecuteQuery]);
653
889
  return {
@@ -664,13 +900,18 @@ function useBoards(options = {}) {
664
900
  }
665
901
 
666
902
  // src/hooks/useBoard.ts
667
- var import_react4 = require("react");
903
+ var import_react5 = require("react");
668
904
  var import_urql4 = require("urql");
669
- function useBoard(boardId) {
905
+ function useBoard(boardId, options) {
670
906
  const { user } = useAuth();
671
907
  const [{ data, fetching, error }, reexecuteQuery] = (0, import_urql4.useQuery)({
672
908
  query: GET_BOARD,
673
- variables: { id: boardId },
909
+ variables: {
910
+ id: boardId,
911
+ limit: options?.limit ?? 100,
912
+ // Default to 100 generations
913
+ offset: options?.offset ?? 0
914
+ },
674
915
  pause: !boardId,
675
916
  requestPolicy: "cache-and-network"
676
917
  // Always fetch fresh data while showing cached data
@@ -680,9 +921,9 @@ function useBoard(boardId) {
680
921
  const [, addMemberMutation] = (0, import_urql4.useMutation)(ADD_BOARD_MEMBER);
681
922
  const [, updateMemberRoleMutation] = (0, import_urql4.useMutation)(UPDATE_BOARD_MEMBER_ROLE);
682
923
  const [, removeMemberMutation] = (0, import_urql4.useMutation)(REMOVE_BOARD_MEMBER);
683
- const board = (0, import_react4.useMemo)(() => data?.board || null, [data?.board]);
684
- const members = (0, import_react4.useMemo)(() => board?.members || [], [board?.members]);
685
- const permissions = (0, import_react4.useMemo)(() => {
924
+ const board = (0, import_react5.useMemo)(() => data?.board || null, [data?.board]);
925
+ const members = (0, import_react5.useMemo)(() => board?.members || [], [board?.members]);
926
+ const permissions = (0, import_react5.useMemo)(() => {
686
927
  if (!board || !user) {
687
928
  return {
688
929
  canEdit: false,
@@ -711,7 +952,7 @@ function useBoard(boardId) {
711
952
  // Even viewers can export
712
953
  };
713
954
  }, [board, user, members]);
714
- const updateBoard = (0, import_react4.useCallback)(
955
+ const updateBoard = (0, import_react5.useCallback)(
715
956
  async (updates) => {
716
957
  if (!boardId) {
717
958
  throw new Error("Board ID is required");
@@ -730,7 +971,7 @@ function useBoard(boardId) {
730
971
  },
731
972
  [boardId, updateBoardMutation]
732
973
  );
733
- const deleteBoard = (0, import_react4.useCallback)(async () => {
974
+ const deleteBoard = (0, import_react5.useCallback)(async () => {
734
975
  if (!boardId) {
735
976
  throw new Error("Board ID is required");
736
977
  }
@@ -742,7 +983,7 @@ function useBoard(boardId) {
742
983
  throw new Error("Failed to delete board");
743
984
  }
744
985
  }, [boardId, deleteBoardMutation]);
745
- const addMember = (0, import_react4.useCallback)(
986
+ const addMember = (0, import_react5.useCallback)(
746
987
  async (email, role) => {
747
988
  if (!boardId) {
748
989
  throw new Error("Board ID is required");
@@ -763,7 +1004,7 @@ function useBoard(boardId) {
763
1004
  },
764
1005
  [boardId, addMemberMutation, reexecuteQuery]
765
1006
  );
766
- const removeMember = (0, import_react4.useCallback)(
1007
+ const removeMember = (0, import_react5.useCallback)(
767
1008
  async (memberId) => {
768
1009
  const result = await removeMemberMutation({ id: memberId });
769
1010
  if (result.error) {
@@ -776,7 +1017,7 @@ function useBoard(boardId) {
776
1017
  },
777
1018
  [removeMemberMutation, reexecuteQuery]
778
1019
  );
779
- const updateMemberRole = (0, import_react4.useCallback)(
1020
+ const updateMemberRole = (0, import_react5.useCallback)(
780
1021
  async (memberId, role) => {
781
1022
  const result = await updateMemberRoleMutation({
782
1023
  id: memberId,
@@ -793,19 +1034,19 @@ function useBoard(boardId) {
793
1034
  },
794
1035
  [updateMemberRoleMutation, reexecuteQuery]
795
1036
  );
796
- const generateShareLink = (0, import_react4.useCallback)(
1037
+ const generateShareLink = (0, import_react5.useCallback)(
797
1038
  async (_options) => {
798
1039
  throw new Error("Share links not implemented yet");
799
1040
  },
800
1041
  []
801
1042
  );
802
- const revokeShareLink = (0, import_react4.useCallback)(
1043
+ const revokeShareLink = (0, import_react5.useCallback)(
803
1044
  async (_linkId) => {
804
1045
  throw new Error("Share link revocation not implemented yet");
805
1046
  },
806
1047
  []
807
1048
  );
808
- const refresh = (0, import_react4.useCallback)(async () => {
1049
+ const refresh = (0, import_react5.useCallback)(async () => {
809
1050
  await reexecuteQuery({ requestPolicy: "network-only" });
810
1051
  }, [reexecuteQuery]);
811
1052
  return {
@@ -826,22 +1067,22 @@ function useBoard(boardId) {
826
1067
  }
827
1068
 
828
1069
  // src/hooks/useGeneration.ts
829
- var import_react5 = require("react");
1070
+ var import_react6 = require("react");
830
1071
  var import_fetch_event_source = require("@microsoft/fetch-event-source");
831
1072
  var import_urql5 = require("urql");
832
1073
  function useGeneration() {
833
- const [progress, setProgress] = (0, import_react5.useState)(null);
834
- const [result, setResult] = (0, import_react5.useState)(null);
835
- const [error, setError] = (0, import_react5.useState)(null);
836
- const [isGenerating, setIsGenerating] = (0, import_react5.useState)(false);
837
- const [history, setHistory] = (0, import_react5.useState)([]);
1074
+ const [progress, setProgress] = (0, import_react6.useState)(null);
1075
+ const [result, setResult] = (0, import_react6.useState)(null);
1076
+ const [error, setError] = (0, import_react6.useState)(null);
1077
+ const [isGenerating, setIsGenerating] = (0, import_react6.useState)(false);
1078
+ const [history, setHistory] = (0, import_react6.useState)([]);
838
1079
  const { apiUrl } = useApiConfig();
839
1080
  const auth = useAuth();
840
- const abortControllers = (0, import_react5.useRef)(/* @__PURE__ */ new Map());
1081
+ const abortControllers = (0, import_react6.useRef)(/* @__PURE__ */ new Map());
841
1082
  const [, createGenerationMutation] = (0, import_urql5.useMutation)(CREATE_GENERATION);
842
1083
  const [, cancelGenerationMutation] = (0, import_urql5.useMutation)(CANCEL_GENERATION);
843
1084
  const [, retryGenerationMutation] = (0, import_urql5.useMutation)(RETRY_GENERATION);
844
- (0, import_react5.useEffect)(() => {
1085
+ (0, import_react6.useEffect)(() => {
845
1086
  return () => {
846
1087
  abortControllers.current.forEach((controller) => {
847
1088
  controller.abort();
@@ -849,7 +1090,7 @@ function useGeneration() {
849
1090
  abortControllers.current.clear();
850
1091
  };
851
1092
  }, []);
852
- const connectToSSE = (0, import_react5.useCallback)(
1093
+ const connectToSSE = (0, import_react6.useCallback)(
853
1094
  async (jobId) => {
854
1095
  const existingController = abortControllers.current.get(jobId);
855
1096
  if (existingController) {
@@ -953,7 +1194,7 @@ function useGeneration() {
953
1194
  },
954
1195
  [apiUrl, auth]
955
1196
  );
956
- const submit = (0, import_react5.useCallback)(
1197
+ const submit = (0, import_react6.useCallback)(
957
1198
  async (request) => {
958
1199
  setError(null);
959
1200
  setProgress(null);
@@ -1005,7 +1246,7 @@ function useGeneration() {
1005
1246
  },
1006
1247
  [createGenerationMutation, connectToSSE]
1007
1248
  );
1008
- const cancel = (0, import_react5.useCallback)(
1249
+ const cancel = (0, import_react6.useCallback)(
1009
1250
  async (jobId) => {
1010
1251
  try {
1011
1252
  const result2 = await cancelGenerationMutation({ id: jobId });
@@ -1027,7 +1268,7 @@ function useGeneration() {
1027
1268
  },
1028
1269
  [cancelGenerationMutation]
1029
1270
  );
1030
- const retry = (0, import_react5.useCallback)(
1271
+ const retry = (0, import_react6.useCallback)(
1031
1272
  async (jobId) => {
1032
1273
  try {
1033
1274
  setError(null);
@@ -1050,7 +1291,7 @@ function useGeneration() {
1050
1291
  },
1051
1292
  [retryGenerationMutation, connectToSSE]
1052
1293
  );
1053
- const clearHistory = (0, import_react5.useCallback)(() => {
1294
+ const clearHistory = (0, import_react6.useCallback)(() => {
1054
1295
  setHistory([]);
1055
1296
  }, []);
1056
1297
  return {
@@ -1067,7 +1308,7 @@ function useGeneration() {
1067
1308
  }
1068
1309
 
1069
1310
  // src/hooks/useGenerators.ts
1070
- var import_react6 = require("react");
1311
+ var import_react7 = require("react");
1071
1312
  var import_urql6 = require("urql");
1072
1313
  function useGenerators(options = {}) {
1073
1314
  const { artifactType } = options;
@@ -1075,7 +1316,7 @@ function useGenerators(options = {}) {
1075
1316
  query: GET_GENERATORS,
1076
1317
  variables: artifactType ? { artifactType } : {}
1077
1318
  });
1078
- const generators = (0, import_react6.useMemo)(() => data?.generators || [], [data?.generators]);
1319
+ const generators = (0, import_react7.useMemo)(() => data?.generators || [], [data?.generators]);
1079
1320
  return {
1080
1321
  generators,
1081
1322
  loading: fetching,
@@ -1083,154 +1324,9 @@ function useGenerators(options = {}) {
1083
1324
  };
1084
1325
  }
1085
1326
 
1086
- // src/utils/schemaParser.ts
1087
- function isArtifactReference(property) {
1088
- if (!property || typeof property === "boolean") {
1089
- return false;
1090
- }
1091
- if (property.$ref && property.$ref.includes("Artifact")) {
1092
- return true;
1093
- }
1094
- if (property.type === "array" && property.items && typeof property.items === "object" && !Array.isArray(property.items)) {
1095
- const items = property.items;
1096
- return !!(items.$ref && items.$ref.includes("Artifact"));
1097
- }
1098
- return false;
1099
- }
1100
- function getArtifactType(ref) {
1101
- const match = ref.match(/(Audio|Video|Image|Text)Artifact/);
1102
- if (match) {
1103
- return match[1].toLowerCase();
1104
- }
1105
- return "image";
1106
- }
1107
- function parseArtifactSlot(name, property, required) {
1108
- const title = property.title || name;
1109
- const description = property.description;
1110
- if (property.type === "array" && property.items) {
1111
- const items = typeof property.items === "object" && !Array.isArray(property.items) ? property.items : void 0;
1112
- const artifactType2 = items?.$ref ? getArtifactType(items.$ref) : "image";
1113
- return {
1114
- name: title,
1115
- fieldName: name,
1116
- artifactType: artifactType2,
1117
- required,
1118
- description,
1119
- isArray: true,
1120
- minItems: property.minItems,
1121
- maxItems: property.maxItems
1122
- };
1123
- }
1124
- const artifactType = property.$ref ? getArtifactType(property.$ref) : "image";
1125
- return {
1126
- name: title,
1127
- fieldName: name,
1128
- artifactType,
1129
- required,
1130
- description,
1131
- isArray: false
1132
- };
1133
- }
1134
- function isSlider(property) {
1135
- return (property.type === "number" || property.type === "integer") && property.minimum !== void 0 && property.maximum !== void 0;
1136
- }
1137
- function parseSettingsField(name, property) {
1138
- const title = property.title || name;
1139
- const description = property.description;
1140
- if (property.enum && Array.isArray(property.enum)) {
1141
- const options = property.enum.map((val) => String(val));
1142
- const defaultValue = property.default !== void 0 ? String(property.default) : void 0;
1143
- return {
1144
- type: "dropdown",
1145
- fieldName: name,
1146
- title,
1147
- description,
1148
- options,
1149
- default: defaultValue
1150
- };
1151
- }
1152
- if (isSlider(property)) {
1153
- const isInteger = property.type === "integer";
1154
- return {
1155
- type: "slider",
1156
- fieldName: name,
1157
- title,
1158
- description,
1159
- min: property.minimum,
1160
- max: property.maximum,
1161
- step: property.multipleOf,
1162
- default: property.default !== void 0 ? property.default : void 0,
1163
- isInteger
1164
- };
1165
- }
1166
- if (property.type === "number" || property.type === "integer") {
1167
- const isInteger = property.type === "integer";
1168
- return {
1169
- type: "number",
1170
- fieldName: name,
1171
- title,
1172
- description,
1173
- default: property.default !== void 0 ? property.default : void 0,
1174
- min: property.minimum,
1175
- max: property.maximum,
1176
- isInteger
1177
- };
1178
- }
1179
- if (property.type === "string") {
1180
- return {
1181
- type: "text",
1182
- fieldName: name,
1183
- title,
1184
- description,
1185
- default: property.default !== void 0 ? String(property.default) : void 0,
1186
- pattern: property.pattern
1187
- };
1188
- }
1189
- return null;
1190
- }
1191
- function parseGeneratorSchema(schema) {
1192
- const artifactSlots = [];
1193
- const settingsFields = [];
1194
- let promptField = null;
1195
- if (!schema.properties) {
1196
- return { artifactSlots, promptField, settingsFields };
1197
- }
1198
- const required = schema.required || [];
1199
- for (const [name, propertyDef] of Object.entries(schema.properties)) {
1200
- if (typeof propertyDef === "boolean") {
1201
- continue;
1202
- }
1203
- const property = propertyDef;
1204
- const isRequired = required.includes(name);
1205
- if (isArtifactReference(property)) {
1206
- const slot = parseArtifactSlot(name, property, isRequired);
1207
- artifactSlots.push(slot);
1208
- continue;
1209
- }
1210
- if (name === "prompt" && property.type === "string") {
1211
- promptField = {
1212
- fieldName: name,
1213
- description: property.description,
1214
- required: isRequired,
1215
- default: property.default !== void 0 ? String(property.default) : void 0
1216
- };
1217
- continue;
1218
- }
1219
- const settingsField = parseSettingsField(name, property);
1220
- if (settingsField) {
1221
- settingsFields.push(settingsField);
1222
- }
1223
- }
1224
- return {
1225
- artifactSlots,
1226
- promptField,
1227
- settingsFields
1228
- };
1229
- }
1230
-
1231
1327
  // src/providers/BoardsProvider.tsx
1232
1328
  var import_urql7 = require("urql");
1233
- var import_jsx_runtime3 = require("react/jsx-runtime");
1329
+ var import_jsx_runtime4 = require("react/jsx-runtime");
1234
1330
  function BoardsProvider({
1235
1331
  children,
1236
1332
  apiUrl,
@@ -1253,7 +1349,7 @@ function BoardsProvider({
1253
1349
  },
1254
1350
  tenantId
1255
1351
  });
1256
- return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(AuthProvider, { provider: authProvider, children: /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(ApiConfigProvider, { config: apiConfig, children: /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_urql7.Provider, { value: client, children }) }) });
1352
+ return /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(AuthProvider, { provider: authProvider, children: /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(ApiConfigProvider, { config: apiConfig, children: /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(import_urql7.Provider, { value: client, children }) }) });
1257
1353
  }
1258
1354
 
1259
1355
  // src/index.ts
@@ -1279,6 +1375,7 @@ var VERSION = "0.1.0";
1279
1375
  GET_GENERATIONS,
1280
1376
  GET_GENERATORS,
1281
1377
  GenerationStatus,
1378
+ GeneratorSelectionProvider,
1282
1379
  NoAuthProvider,
1283
1380
  REMOVE_BOARD_MEMBER,
1284
1381
  RETRY_GENERATION,
@@ -1298,6 +1395,7 @@ var VERSION = "0.1.0";
1298
1395
  useBoard,
1299
1396
  useBoards,
1300
1397
  useGeneration,
1398
+ useGeneratorSelection,
1301
1399
  useGenerators
1302
1400
  });
1303
1401
  //# sourceMappingURL=index.js.map