@lobb-js/studio 0.1.43 → 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.
Files changed (33) hide show
  1. package/dist/components/codeEditor.svelte +1 -1
  2. package/dist/components/dataTable/childRecords.svelte +1 -1
  3. package/dist/components/dataTable/childRecords.svelte.d.ts +1 -1
  4. package/dist/components/dataTable/dataTable.svelte +1 -1
  5. package/dist/components/dataTable/dataTable.svelte.d.ts +1 -1
  6. package/dist/components/dataTable/table.svelte +4 -4
  7. package/dist/components/dataTable/table.svelte.d.ts +1 -1
  8. package/dist/components/detailView/create/children.svelte +1 -1
  9. package/dist/components/detailView/create/createManyView.svelte +4 -4
  10. package/dist/components/detailView/fieldInput.svelte +11 -42
  11. package/dist/components/detailView/fieldInputReplacement.svelte +7 -7
  12. package/dist/components/detailView/update/children.svelte +3 -3
  13. package/dist/components/diffViewer.svelte +1 -1
  14. package/dist/components/foreingKeyInput.svelte +2 -2
  15. package/dist/components/rangeCalendarButton.svelte +10 -10
  16. package/dist/components/sidebar/sidebar.svelte +1 -1
  17. package/dist/components/sidebar/sidebarElements.svelte +1 -1
  18. package/dist/components/ui/input/input.svelte +2 -2
  19. package/dist/components/ui/select/select-content.svelte +1 -1
  20. package/dist/components/ui/select/select-trigger.svelte +1 -1
  21. package/dist/components/ui/textarea/textarea.svelte +1 -1
  22. package/dist/extensions/extension.types.d.ts +2 -2
  23. package/dist/index.d.ts +0 -1
  24. package/dist/store.svelte.d.ts +1 -2
  25. package/dist/store.svelte.js +2 -2
  26. package/dist/utils.d.ts +0 -1
  27. package/dist/utils.js +0 -11
  28. package/package.json +9 -5
  29. package/vite-plugins/contextual-lib-alias.js +39 -38
  30. package/vite-plugins/index.js +0 -2
  31. package/dist/Lobb.d.ts +0 -30
  32. package/dist/Lobb.js +0 -358
  33. package/vite-plugins/monorepo-import-resolver.js +0 -92
@@ -132,7 +132,7 @@
132
132
  });
133
133
  </script>
134
134
 
135
- <div class={cn('resize-y rounded-md border bg-soft shadow-sm h-60', className)}>
135
+ <div class={cn('resize-y rounded-md border bg-muted/30 h-60', className)}>
136
136
  <div bind:this={editorContainer} class="h-full w-full pl-2" />
137
137
  </div>
138
138
 
@@ -10,7 +10,7 @@
10
10
  collectionName: string;
11
11
  recordId: string;
12
12
  width: number;
13
- unifiedBgColor?: "bg-soft" | "bg-background";
13
+ unifiedBgColor?: "bg-muted/30" | "bg-background";
14
14
  }
15
15
 
16
16
  let { collectionName, recordId, width, unifiedBgColor }: Props = $props();
@@ -2,7 +2,7 @@ interface Props {
2
2
  collectionName: string;
3
3
  recordId: string;
4
4
  width: number;
5
- unifiedBgColor?: "bg-soft" | "bg-background";
5
+ unifiedBgColor?: "bg-muted/30" | "bg-background";
6
6
  }
7
7
  declare const ChildRecords: import("svelte").Component<Props, {}, "">;
8
8
  type ChildRecords = ReturnType<typeof ChildRecords>;
@@ -21,7 +21,7 @@
21
21
  filter?: any;
22
22
  showHeader?: boolean;
23
23
  showFooter?: boolean;
24
- unifiedBgColor?: "bg-soft" | "bg-background";
24
+ unifiedBgColor?: "bg-muted/30" | "bg-background";
25
25
  showDelete?: boolean;
26
26
  tableProps?: Partial<TableProps>;
27
27
  headerLeft?: Snippet<[]>;
@@ -5,7 +5,7 @@ interface Props {
5
5
  filter?: any;
6
6
  showHeader?: boolean;
7
7
  showFooter?: boolean;
8
- unifiedBgColor?: "bg-soft" | "bg-background";
8
+ unifiedBgColor?: "bg-muted/30" | "bg-background";
9
9
  showDelete?: boolean;
10
10
  tableProps?: Partial<TableProps>;
11
11
  headerLeft?: Snippet<[]>;
@@ -36,7 +36,7 @@
36
36
 
37
37
  // other
38
38
  parentWidth?: number;
39
- unifiedBgColor?: "bg-soft" | "bg-background";
39
+ unifiedBgColor?: "bg-muted/30" | "bg-background";
40
40
  select?: Select;
41
41
  tableWidth?: number;
42
42
  }
@@ -179,7 +179,7 @@
179
179
  sticky left-0 top-0 z-20
180
180
  flex items-center p-2.5 text-xs h-10
181
181
  border-r border-b gap-2
182
- {unifiedBgColor ? unifiedBgColor : 'bg-soft'}
182
+ {unifiedBgColor ? unifiedBgColor : 'bg-muted/30'}
183
183
  "
184
184
  >
185
185
  <!-- collapsable toggle -->
@@ -204,7 +204,7 @@
204
204
  class="
205
205
  sticky top-0 z-10
206
206
  flex items-center p-2.5 text-xs h-10
207
- {unifiedBgColor ? unifiedBgColor : 'bg-soft'}
207
+ {unifiedBgColor ? unifiedBgColor : 'bg-muted/30'}
208
208
  {lastColumn && !showLastColumnBorder ? '' : 'border-r'}
209
209
  border-b gap-2
210
210
  "
@@ -307,7 +307,7 @@
307
307
  {expandedRows[index] ? '' : 'height: 0px;'}
308
308
  "
309
309
  class="
310
- sticky left-0 top-0 overflow-auto bg-soft
310
+ sticky left-0 top-0 overflow-auto bg-muted/30
311
311
  {unifiedBgColor ? unifiedBgColor : ''}
312
312
  {expandedRows[index] ? 'border-t' : ''}
313
313
  "
@@ -22,7 +22,7 @@ export interface TableProps {
22
22
  tools?: Snippet<[Entry, number]>;
23
23
  collapsible?: Snippet<[Entry, number]>;
24
24
  parentWidth?: number;
25
- unifiedBgColor?: "bg-soft" | "bg-background";
25
+ unifiedBgColor?: "bg-muted/30" | "bg-background";
26
26
  select?: Select;
27
27
  tableWidth?: number;
28
28
  }
@@ -49,7 +49,7 @@
49
49
  id: entry.id,
50
50
  collectionName: collectionName,
51
51
  }}
52
- class="bg-soft border rounded-md overflow-hidden"
52
+ class="bg-muted/30 border rounded-md overflow-hidden"
53
53
  bind:value={entry[childCollection]}
54
54
  >
55
55
  <CreateManyView
@@ -106,7 +106,7 @@
106
106
  >
107
107
  <div
108
108
  class="
109
- flex items-center justify-between px-2 h-10 bg-soft
109
+ flex items-center justify-between px-2 h-10 bg-muted/30
110
110
  {expanded ? 'border-b' : ''}
111
111
  "
112
112
  >
@@ -159,13 +159,13 @@
159
159
  </div>
160
160
  </div>
161
161
  {#if expanded}
162
- <div bind:clientWidth={tableWidth} class="bg-soft overflow-auto">
162
+ <div bind:clientWidth={tableWidth} class="bg-muted/30 overflow-auto">
163
163
  <Table
164
164
  data={entries}
165
165
  {columns}
166
166
  selectByColumn="id"
167
167
  showCollapsible={doesCollectionHasChildren}
168
- unifiedBgColor="bg-soft"
168
+ unifiedBgColor="bg-muted/30"
169
169
  >
170
170
  {#snippet tools(entry, index)}
171
171
  <Button
@@ -234,7 +234,7 @@
234
234
  {collectionName}
235
235
  recordId={entry.id}
236
236
  width={tableWidth}
237
- unifiedBgColor="bg-soft"
237
+ unifiedBgColor="bg-muted/30"
238
238
  />
239
239
  {:else}
240
240
  <SubRecords
@@ -1,15 +1,11 @@
1
1
  <script lang="ts">
2
2
  import { ctx } from "../../store.svelte";
3
- import {
4
- getDiscriminatorFieldRelation,
5
- getFieldRelation,
6
- } from "../../utils";
3
+ import { getFieldRelation } from "../../utils";
7
4
  import { Ban, Check, CircleAlert, X } from "lucide-svelte";
8
5
  import { getField } from "../dataTable/utils";
9
6
  import Button from "../ui/button/button.svelte";
10
7
  import FieldCustomInput from "./fieldCustomInput.svelte";
11
8
  import Input from "../ui/input/input.svelte";
12
- import Combobox from "../combobox.svelte";
13
9
  import * as Select from "../ui/select/index";
14
10
  import Textarea from "../ui/textarea/textarea.svelte";
15
11
  import ForeingKeyInput from "../foreingKeyInput.svelte";
@@ -38,10 +34,6 @@
38
34
  ctx.meta.collections[collectionName].fields[fieldName].ui;
39
35
  const field = getField(fieldName, collectionName);
40
36
  const fieldRelation = getFieldRelation(collectionName, fieldName);
41
- const discriminatorFieldRelation = getDiscriminatorFieldRelation(
42
- collectionName,
43
- fieldName,
44
- );
45
37
  const isDisabled = field.key === 'id' || Boolean(ui?.disabled)
46
38
  const disabledClasses = "pointer-events-none opacity-50";
47
39
  const destructive: boolean = $derived(Boolean(errorMessages.length));
@@ -74,30 +66,7 @@
74
66
  {:else if field.label === "id"}
75
67
  <Input
76
68
  placeholder="AUTO GENERATED"
77
- class="bg-soft text-xs"
78
- bind:value
79
- />
80
- {:else if discriminatorFieldRelation}
81
- {@const availableCollections =
82
- discriminatorFieldRelation.to === "*"
83
- ? Object.keys(ctx.meta.collections)
84
- : discriminatorFieldRelation.to.map(
85
- (item: any) => item.collection,
86
- )}
87
- {@const collections = availableCollections.map((key: any) => {
88
- return {
89
- label: key,
90
- value: key,
91
- };
92
- })}
93
- <Combobox
94
- placeholder="NULL"
95
- searchPlaceholder="Search Collections"
96
- options={collections}
97
- buttonClass="
98
- bg-soft text-muted-foreground px-0 pl-4 pr-8 font-normal
99
- {destructive ? 'border-destructive bg-destructive/10' : ''}
100
- "
69
+ class="bg-muted/30 text-xs"
101
70
  bind:value
102
71
  />
103
72
  {:else if fieldRelation && entry}
@@ -132,7 +101,7 @@
132
101
  <Select.Trigger
133
102
  placeholder={ui?.placeholder ? ui.placeholder : "NULL"}
134
103
  class="
135
- h-9 w-full bg-soft pr-8
104
+ h-9 w-full bg-muted/30 pr-8
136
105
  {destructive ? 'border-destructive bg-destructive/10' : ''}
137
106
  "
138
107
  >
@@ -151,7 +120,7 @@
151
120
  placeholder={ui?.placeholder ? ui.placeholder : "NULL"}
152
121
  type="text"
153
122
  class="
154
- bg-soft text-xs
123
+ bg-muted/30 text-xs
155
124
  {destructive ? 'border-destructive bg-destructive/10' : ''}
156
125
  "
157
126
  bind:value
@@ -162,7 +131,7 @@
162
131
  placeholder={ui?.placeholder ? ui.placeholder : value === "" ? "EMPTY STRING" : "NULL"}
163
132
  rows={5}
164
133
  class="
165
- bg-soft text-xs
134
+ bg-muted/30 text-xs
166
135
  {destructive ? 'border-destructive bg-destructive/10' : ''}
167
136
  "
168
137
  bind:value
@@ -172,7 +141,7 @@
172
141
  type="date"
173
142
  placeholder={ui?.placeholder ? ui.placeholder : "NULL"}
174
143
  class="
175
- dateInput block w-full bg-soft pr-9 text-xs
144
+ dateInput block w-full bg-muted/30 pr-9 text-xs
176
145
  {destructive ? 'border-destructive bg-destructive/10' : ''}
177
146
  "
178
147
  bind:value={
@@ -191,7 +160,7 @@
191
160
  type="time"
192
161
  placeholder={ui?.placeholder ? ui.placeholder : "NULL"}
193
162
  class="
194
- dateInput block w-full bg-soft pr-9 text-xs
163
+ dateInput block w-full bg-muted/30 pr-9 text-xs
195
164
  {destructive ? 'border-destructive bg-destructive/10' : ''}
196
165
  "
197
166
  bind:value={
@@ -209,7 +178,7 @@
209
178
  type="datetime-local"
210
179
  placeholder={ui?.placeholder ? ui.placeholder : "NULL"}
211
180
  class="
212
- dateInput block w-full bg-soft pr-9 text-xs
181
+ dateInput block w-full bg-muted/30 pr-9 text-xs
213
182
  {destructive ? 'border-destructive bg-destructive/10' : ''}
214
183
  "
215
184
  bind:value={
@@ -230,7 +199,7 @@
230
199
  <Select.Trigger
231
200
  placeholder={ui?.placeholder ? ui.placeholder : "NULL"}
232
201
  class="
233
- bg-soft pr-9
202
+ bg-muted/30 pr-9
234
203
  {destructive ? 'border-destructive bg-destructive/10' : ''}
235
204
  "
236
205
  >
@@ -257,7 +226,7 @@
257
226
  type="number"
258
227
  step="any"
259
228
  class="
260
- bg-soft text-xs
229
+ bg-muted/30 text-xs
261
230
  {destructive ? 'border-destructive bg-destructive/10' : ''}
262
231
  "
263
232
  bind:value
@@ -267,7 +236,7 @@
267
236
  placeholder={ui?.placeholder ? ui.placeholder : "NULL"}
268
237
  type="number"
269
238
  class="
270
- bg-soft text-xs
239
+ bg-muted/30 text-xs
271
240
  {destructive ? 'border-destructive bg-destructive/10' : ''}
272
241
  "
273
242
  bind:value
@@ -49,7 +49,7 @@
49
49
  placeholder={field.placeholder ? field.placeholder : "NULL"}
50
50
  type="text"
51
51
  class="
52
- bg-soft text-xs
52
+ bg-muted/30 text-xs
53
53
  {destructive ? 'border-destructive bg-destructive/10' : ''}
54
54
  "
55
55
  bind:value
@@ -64,7 +64,7 @@
64
64
  <Select.Trigger
65
65
  placeholder={field.placeholder ? field.placeholder : "NULL"}
66
66
  class="
67
- h-9 w-full bg-soft pr-8
67
+ h-9 w-full bg-muted/30 pr-8
68
68
  {destructive ? 'border-destructive bg-destructive/10' : ''}
69
69
  "
70
70
  >
@@ -84,7 +84,7 @@
84
84
  placeholder={field.placeholder ? field.placeholder : value === "" ? "EMPTY STRING" : "NULL"}
85
85
  rows={5}
86
86
  class="
87
- bg-soft text-xs
87
+ bg-muted/30 text-xs
88
88
  {destructive ? 'border-destructive bg-destructive/10' : ''}
89
89
  "
90
90
  bind:value
@@ -98,7 +98,7 @@
98
98
  <Input
99
99
  type="date"
100
100
  class="
101
- dateInput block w-full bg-soft pr-9 text-xs
101
+ dateInput block w-full bg-muted/30 pr-9 text-xs
102
102
  {destructive ? 'border-destructive bg-destructive/10' : ''}
103
103
  "
104
104
  bind:value={
@@ -116,7 +116,7 @@
116
116
  <Input
117
117
  type="time"
118
118
  class="
119
- dateInput block w-full bg-soft pr-9 text-xs
119
+ dateInput block w-full bg-muted/30 pr-9 text-xs
120
120
  {destructive ? 'border-destructive bg-destructive/10' : ''}
121
121
  "
122
122
  bind:value={
@@ -133,7 +133,7 @@
133
133
  <Input
134
134
  type="datetime-local"
135
135
  class="
136
- dateInput block w-full bg-soft pr-9 text-xs
136
+ dateInput block w-full bg-muted/30 pr-9 text-xs
137
137
  {destructive ? 'border-destructive bg-destructive/10' : ''}
138
138
  "
139
139
  bind:value={
@@ -154,7 +154,7 @@
154
154
  <Select.Root type="single" bind:value>
155
155
  <Select.Trigger
156
156
  class="
157
- bg-soft pr-9
157
+ bg-muted/30 pr-9
158
158
  {destructive ? 'border-destructive bg-destructive/10' : ''}
159
159
  "
160
160
  >
@@ -38,11 +38,11 @@
38
38
  filter={{
39
39
  [childField]: entry.id,
40
40
  }}
41
- class="bg-soft border rounded-md overflow-hidden"
41
+ class="bg-muted/30 border rounded-md overflow-hidden"
42
42
  >
43
43
  <div class="border rounded-md overflow-clip">
44
44
  <div
45
- class="flex items-center justify-between px-2 h-10 bg-soft border-b"
45
+ class="flex items-center justify-between px-2 h-10 bg-muted/30 border-b"
46
46
  >
47
47
  <div class="flex-1 flex h-full items-center gap-2">
48
48
  <TableIcon
@@ -74,7 +74,7 @@
74
74
  filter={{
75
75
  [childField]: entry.id,
76
76
  }}
77
- unifiedBgColor="bg-soft"
77
+ unifiedBgColor="bg-muted/30"
78
78
  showHeader={false}
79
79
  showFooter={false}
80
80
  showDelete={true}
@@ -96,7 +96,7 @@
96
96
  });
97
97
  </script>
98
98
 
99
- <div class={cn("w-full resize-y rounded-md border bg-soft shadow-sm", className)}>
99
+ <div class={cn("w-full resize-y rounded-md border bg-muted/30 shadow-sm", className)}>
100
100
  <div
101
101
  bind:this={editorContainer}
102
102
  class="editor pl-2"
@@ -63,7 +63,7 @@
63
63
  placeholder={"NULL"}
64
64
  type="number"
65
65
  class="
66
- bg-soft text-xs
66
+ bg-muted/30 text-xs
67
67
  {destructive ? 'border-destructive bg-destructive/10' : ''}
68
68
  "
69
69
  bind:value={() => refrenceId, (v) => (value.id = v)}
@@ -73,7 +73,7 @@
73
73
  <div class="relative z-10">
74
74
  <Input
75
75
  placeholder={"PARENT ID"}
76
- class="bg-soft text-xs"
76
+ class="bg-muted/30 text-xs"
77
77
  disabled={true}
78
78
  />
79
79
  </div>
@@ -59,7 +59,7 @@
59
59
  class="flex flex-col overflow-hidden text-muted-foreground"
60
60
  >
61
61
  <button
62
- class="text-start text-sm py-2 px-2 hover:bg-soft hover:text-primary"
62
+ class="text-start text-sm py-2 px-2 hover:bg-muted/30 hover:text-primary"
63
63
  onclick={() => {
64
64
  const currentDate = today(getLocalTimeZone());
65
65
  value = {
@@ -71,7 +71,7 @@
71
71
  Today
72
72
  </button>
73
73
  <button
74
- class="text-start text-sm py-2 px-2 hover:bg-soft hover:text-primary"
74
+ class="text-start text-sm py-2 px-2 hover:bg-muted/30 hover:text-primary"
75
75
  onclick={() => {
76
76
  const currentDate = today(getLocalTimeZone());
77
77
  value = {
@@ -83,7 +83,7 @@
83
83
  Yesterday
84
84
  </button>
85
85
  <button
86
- class="text-start text-sm py-2 px-2 hover:bg-soft hover:text-primary"
86
+ class="text-start text-sm py-2 px-2 hover:bg-muted/30 hover:text-primary"
87
87
  onclick={() => {
88
88
  const currentDate = today(getLocalTimeZone());
89
89
  const weekStart = startOfWeek(currentDate, "en-US");
@@ -96,7 +96,7 @@
96
96
  This week (Sun - Today)
97
97
  </button>
98
98
  <button
99
- class="text-start text-sm py-2 px-2 hover:bg-soft hover:text-primary"
99
+ class="text-start text-sm py-2 px-2 hover:bg-muted/30 hover:text-primary"
100
100
  onclick={() => {
101
101
  const currentDate = today(getLocalTimeZone());
102
102
  const thisWeekStart = startOfWeek(
@@ -119,7 +119,7 @@
119
119
  Last week (Sun - Sat)
120
120
  </button>
121
121
  <button
122
- class="text-start text-sm py-2 px-2 hover:bg-soft hover:text-primary"
122
+ class="text-start text-sm py-2 px-2 hover:bg-muted/30 hover:text-primary"
123
123
  onclick={() => {
124
124
  const currentDate = today(getLocalTimeZone());
125
125
  value = {
@@ -131,7 +131,7 @@
131
131
  Last 7 days
132
132
  </button>
133
133
  <button
134
- class="text-start text-sm py-2 px-2 hover:bg-soft hover:text-primary"
134
+ class="text-start text-sm py-2 px-2 hover:bg-muted/30 hover:text-primary"
135
135
  onclick={() => {
136
136
  const currentDate = today(getLocalTimeZone());
137
137
  value = {
@@ -143,7 +143,7 @@
143
143
  Last 30 days
144
144
  </button>
145
145
  <button
146
- class="text-start text-sm py-2 px-2 hover:bg-soft hover:text-primary"
146
+ class="text-start text-sm py-2 px-2 hover:bg-muted/30 hover:text-primary"
147
147
  onclick={() => {
148
148
  const currentDate = today(getLocalTimeZone());
149
149
  value = {
@@ -155,7 +155,7 @@
155
155
  Last 90 days
156
156
  </button>
157
157
  <button
158
- class="text-start text-sm py-2 px-2 hover:bg-soft hover:text-primary"
158
+ class="text-start text-sm py-2 px-2 hover:bg-muted/30 hover:text-primary"
159
159
  onclick={() => {
160
160
  const currentDate = today(getLocalTimeZone());
161
161
  value = {
@@ -167,7 +167,7 @@
167
167
  Last 12 months
168
168
  </button>
169
169
  <button
170
- class="text-start text-sm py-2 px-2 hover:bg-soft hover:text-primary"
170
+ class="text-start text-sm py-2 px-2 hover:bg-muted/30 hover:text-primary"
171
171
  onclick={() => {
172
172
  const currentDate = today(getLocalTimeZone());
173
173
  const lastYearStart = currentDate
@@ -185,7 +185,7 @@
185
185
  Last Calendar year
186
186
  </button>
187
187
  <button
188
- class="text-start text-sm py-2 px-2 hover:bg-soft hover:text-primary"
188
+ class="text-start text-sm py-2 px-2 hover:bg-muted/30 hover:text-primary"
189
189
  onclick={() => {
190
190
  const currentDate = today(getLocalTimeZone());
191
191
  const yearStart = currentDate.set({
@@ -99,7 +99,7 @@
99
99
  {#if showSearch}
100
100
  <div class="p-2">
101
101
  <div
102
- class="flex items-center px-4 py-1 text-muted-foreground bg-soft border rounded-md"
102
+ class="flex items-center px-4 py-1 text-muted-foreground bg-muted/30 border rounded-md"
103
103
  >
104
104
  <input
105
105
  type="text"
@@ -107,7 +107,7 @@
107
107
  href={element.href}
108
108
  variant="ghost"
109
109
  class="
110
- flex items-center justify-between p-2 gap-2 hover:bg-soft text-muted-foreground
110
+ flex items-center justify-between p-2 gap-2 hover:bg-muted/30 text-muted-foreground
111
111
  rounded-md {isselected ? 'bg-muted' : ''}
112
112
  "
113
113
  title={element.name}
@@ -24,7 +24,7 @@
24
24
  <input
25
25
  bind:this={ref}
26
26
  class={cn(
27
- "border-input placeholder:text-muted-foreground focus-visible:ring-ring flex h-9 w-full rounded-md border bg-transparent px-3 py-1 text-base shadow-sm transition-colors file:border-0 file:bg-transparent file:text-sm file:font-medium focus-visible:outline-none focus-visible:ring-1 disabled:cursor-not-allowed disabled:opacity-50 md:text-sm",
27
+ "border-input placeholder:text-muted-foreground focus-visible:ring-ring flex h-9 w-full rounded-md border bg-transparent px-3 py-1 text-base transition-colors file:border-0 file:bg-transparent file:text-sm file:font-medium focus-visible:outline-none focus-visible:ring-1 disabled:cursor-not-allowed disabled:opacity-50 md:text-sm",
28
28
  className
29
29
  )}
30
30
  type="file"
@@ -36,7 +36,7 @@
36
36
  <input
37
37
  bind:this={ref}
38
38
  class={cn(
39
- "border-input placeholder:text-muted-foreground focus-visible:ring-ring flex h-9 w-full rounded-md border bg-transparent px-3 py-1 text-base shadow-sm transition-colors file:border-0 file:bg-transparent file:text-sm file:font-medium focus-visible:outline-none focus-visible:ring-1 disabled:cursor-not-allowed disabled:opacity-50 md:text-sm",
39
+ "border-input placeholder:text-muted-foreground focus-visible:ring-ring flex h-9 w-full rounded-md border bg-transparent px-3 py-1 text-base transition-colors file:border-0 file:bg-transparent file:text-sm file:font-medium focus-visible:outline-none focus-visible:ring-1 disabled:cursor-not-allowed disabled:opacity-50 md:text-sm",
40
40
  className
41
41
  )}
42
42
  {type}
@@ -20,7 +20,7 @@
20
20
  bind:ref
21
21
  {sideOffset}
22
22
  class={cn(
23
- "data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 bg-popover text-popover-foreground relative z-50 max-h-96 min-w-32 overflow-hidden rounded-md border shadow-md data-[side=bottom]:translate-y-1 data-[side=left]:-translate-x-1 data-[side=right]:translate-x-1 data-[side=top]:-translate-y-1",
23
+ "data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 bg-popover text-popover-foreground relative z-50 max-h-96 min-w-32 overflow-hidden rounded-md border data-[side=bottom]:translate-y-1 data-[side=left]:-translate-x-1 data-[side=right]:translate-x-1 data-[side=top]:-translate-y-1",
24
24
  className
25
25
  )}
26
26
  {...restProps}
@@ -14,7 +14,7 @@
14
14
  <SelectPrimitive.Trigger
15
15
  bind:ref
16
16
  class={cn(
17
- "border-input ring-offset-background data-[placeholder]:text-muted-foreground focus:ring-ring flex h-9 w-full items-center justify-between whitespace-nowrap rounded-md border bg-transparent px-3 py-2 text-sm shadow-sm focus:outline-none focus:ring-1 disabled:cursor-not-allowed disabled:opacity-50 [&>span]:line-clamp-1",
17
+ "border-input ring-offset-background data-[placeholder]:text-muted-foreground focus:ring-ring flex h-9 w-full items-center justify-between whitespace-nowrap rounded-md border bg-transparent px-3 py-2 text-sm focus:outline-none focus:ring-1 disabled:cursor-not-allowed disabled:opacity-50 [&>span]:line-clamp-1",
18
18
  className
19
19
  )}
20
20
  {...restProps}
@@ -15,7 +15,7 @@
15
15
  bind:this={ref}
16
16
  bind:value
17
17
  class={cn(
18
- "border-input placeholder:text-muted-foreground focus-visible:ring-ring flex min-h-[60px] w-full rounded-md border bg-transparent px-3 py-2 text-base shadow-sm focus-visible:outline-none focus-visible:ring-1 disabled:cursor-not-allowed disabled:opacity-50 md:text-sm",
18
+ "border-input placeholder:text-muted-foreground focus-visible:ring-ring flex min-h-[60px] w-full rounded-md border bg-transparent px-3 py-2 text-base focus-visible:outline-none focus-visible:ring-1 disabled:cursor-not-allowed disabled:opacity-50 md:text-sm",
19
19
  className
20
20
  )}
21
21
  {...restProps}
@@ -1,4 +1,4 @@
1
- import type { Lobb } from "../Lobb";
1
+ import type { LobbClient } from "@lobb/sdk";
2
2
  import type { CTX } from "../lib/store.types";
3
3
  import type { Button } from "../components/ui/button";
4
4
  import type { Input } from "../components/ui/input";
@@ -49,7 +49,7 @@ export interface Components {
49
49
  }
50
50
  export interface ExtensionUtils {
51
51
  ctx: CTX;
52
- lobb: Lobb;
52
+ lobb: LobbClient;
53
53
  location: Location;
54
54
  toast: typeof toast;
55
55
  showDialog: typeof showDialog;
package/dist/index.d.ts CHANGED
@@ -1,5 +1,4 @@
1
1
  export type { ExtensionProps, Extension, ExtensionUtils } from "./extensions/extension.types";
2
- export type { Lobb } from "./Lobb";
3
2
  export { default as Studio } from "./components/Studio.svelte";
4
3
  export { Button } from "./components/ui/button";
5
4
  export { Input } from "./components/ui/input";
@@ -1,4 +1,3 @@
1
1
  import type { CTX } from './store.types';
2
- import { Lobb } from './Lobb';
3
2
  export declare const ctx: CTX;
4
- export declare const lobb: Lobb;
3
+ export declare const lobb: any;
@@ -34,7 +34,7 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
34
34
  if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
35
35
  }
36
36
  };
37
- import { Lobb } from './Lobb';
37
+ import { LobbClient } from '@lobb/sdk';
38
38
  import { toast } from 'svelte-sonner';
39
39
  if (!window.APP_ENV) {
40
40
  window.APP_ENV = {};
@@ -56,7 +56,7 @@ export var ctx = $state.raw({
56
56
  filter: null
57
57
  },
58
58
  });
59
- export var lobb = new Lobb(ctx.lobbUrl);
59
+ export var lobb = new LobbClient(ctx.lobbUrl);
60
60
  // logging the message if got any bad responses
61
61
  lobb.onResponse(function (response) { return __awaiter(void 0, void 0, void 0, function () {
62
62
  var body;
package/dist/utils.d.ts CHANGED
@@ -19,7 +19,6 @@ export declare const mediaQueries: {
19
19
  '2xl': MediaQuery;
20
20
  };
21
21
  export declare function getFieldRelation(collectionName: string, fieldName: string): any;
22
- export declare function getDiscriminatorFieldRelation(collectionName: string, fieldName: string): any;
23
22
  export declare function recordHasChildrean(collectionName: string): boolean;
24
23
  export declare function calculateDrawerWidth(): number;
25
24
  export declare function getChangedProperties(oldObj: Record<string, any>, newObj: Record<string, any>): Record<string, any>;
package/dist/utils.js CHANGED
@@ -27,17 +27,6 @@ export function getFieldRelation(collectionName, fieldName) {
27
27
  return null;
28
28
  }
29
29
  ;
30
- export function getDiscriminatorFieldRelation(collectionName, fieldName) {
31
- var relations = ctx.meta.relations;
32
- for (var index = 0; index < relations.length; index++) {
33
- var relation = relations[index];
34
- if (relation.from.collection === collectionName && relation.from.discriminator === fieldName) {
35
- return relation;
36
- }
37
- }
38
- return null;
39
- }
40
- ;
41
30
  export function recordHasChildrean(collectionName) {
42
31
  for (var index = 0; index < ctx.meta.relations.length; index++) {
43
32
  var relation = ctx.meta.relations[index];
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lobb-js/studio",
3
- "version": "0.1.43",
3
+ "version": "0.2.1",
4
4
  "type": "module",
5
5
  "publishConfig": {
6
6
  "access": "public"
@@ -12,8 +12,7 @@
12
12
  "exports": {
13
13
  ".": {
14
14
  "svelte": "./dist/index.js",
15
- "types": "./dist/index.d.ts",
16
- "default": "./src/lib/index.ts"
15
+ "types": "./dist/index.d.ts"
17
16
  },
18
17
  "./vite-plugins": "./vite-plugins/index.js"
19
18
  },
@@ -27,7 +26,9 @@
27
26
  "storybook": "storybook dev -p 6006",
28
27
  "build-storybook": "storybook build",
29
28
  "test": "vitest",
30
- "test-storybook": "vitest --project=storybook"
29
+ "test-storybook": "vitest --project=storybook",
30
+ "prepublishOnly": "npm run package && jq '.exports[\".\"] = {\"svelte\": \"./dist/index.js\", \"types\": \"./dist/index.d.ts\"}' package.json > package.json.tmp && mv package.json.tmp package.json",
31
+ "postpublish": "jq '.exports[\".\"] = {\"__svelte\": \"./dist/index.js\", \"__types\": \"./dist/index.d.ts\", \"default\": \"./src/lib/index.ts\"}' package.json > package.json.tmp && mv package.json.tmp package.json"
31
32
  },
32
33
  "devDependencies": {
33
34
  "@chromatic-com/storybook": "^4.1.2",
@@ -60,7 +61,9 @@
60
61
  "vitest": "^4.0.5"
61
62
  },
62
63
  "peerDependencies": {
63
- "svelte": "^5.0.0"
64
+ "svelte": "^5.0.0",
65
+ "tailwindcss": "^4.0.0",
66
+ "@tailwindcss/vite": "^4.0.0"
64
67
  },
65
68
  "dependencies": {
66
69
  "@andrewbranch/untar.js": "^1.0.3",
@@ -71,6 +74,7 @@
71
74
  "@codemirror/theme-one-dark": "^6.1.3",
72
75
  "@codemirror/view": "^6.39.12",
73
76
  "@dagrejs/dagre": "^1.1.5",
77
+ "@lobb/sdk": "0.1.0",
74
78
  "@lucide/svelte": "^0.563.1",
75
79
  "@tailwindcss/vite": "^4.1.18",
76
80
  "@wjfe/n-savant": "^0.3.0",
@@ -1,63 +1,64 @@
1
1
  import path from "path";
2
2
  import fs from "fs";
3
- import { fileURLToPath } from "url";
4
-
5
- const __filename = fileURLToPath(import.meta.url);
6
- const __dirname = path.dirname(__filename);
7
3
 
8
4
  /**
9
- * Vite plugin that resolves $lib imports contextually based on the importing file location.
5
+ * Vite plugin that resolves $lib imports contextually based on the importing file's package.
10
6
  *
11
- * - Files inside the consuming project -> resolve to local ./src/lib
12
- * - Files from Studio package in monorepo -> resolve to Studio's src/lib
13
- * - Files from Studio package in node_modules -> resolve to node_modules/@lobb-js/studio/src/lib
7
+ * Walks up the directory tree from the importer to find the nearest package.json,
8
+ * then checks if that package has a src/lib directory. If so, resolves $lib to that path.
14
9
  *
15
- * This allows shadcn components to work in both the Studio package and consuming projects
16
- * without conflicts.
10
+ * This allows any package using the src/lib convention to use $lib imports without conflicts.
17
11
  *
18
12
  * @returns {import('vite').Plugin}
19
13
  */
20
14
  export function contextualLibAlias() {
21
- let projectRoot;
22
- let localLibPath;
23
- const studioLibPath = path.resolve(__dirname, "../src/lib");
15
+ const packageRootCache = new Map();
16
+
17
+ function findPackageRoot(filePath) {
18
+ const dir = path.dirname(filePath);
19
+
20
+ // Check cache
21
+ if (packageRootCache.has(dir)) {
22
+ return packageRootCache.get(dir);
23
+ }
24
+
25
+ // Walk up directories to find package.json
26
+ let currentDir = dir;
27
+ const rootDir = path.parse(currentDir).root;
28
+
29
+ while (currentDir !== rootDir) {
30
+ const pkgPath = path.join(currentDir, "package.json");
31
+ if (fs.existsSync(pkgPath)) {
32
+ packageRootCache.set(dir, currentDir);
33
+ return currentDir;
34
+ }
35
+ currentDir = path.dirname(currentDir);
36
+ }
37
+
38
+ // Not found
39
+ packageRootCache.set(dir, null);
40
+ return null;
41
+ }
24
42
 
25
43
  return {
26
44
  name: "contextual-lib-alias",
27
45
  enforce: "pre",
28
46
 
29
- configResolved(config) {
30
- projectRoot = config.root;
31
- localLibPath = path.resolve(projectRoot, "./src/lib");
32
- },
33
-
34
47
  async resolveId(source, importer, options) {
35
48
  if (!source.startsWith("$lib")) return null;
36
49
  if (!importer) return null;
37
50
 
38
- // Determine if the importing file is inside this project or external (e.g., Studio package)
39
- const isLocalImport = importer.startsWith(projectRoot);
40
-
41
- let targetPath;
51
+ // Find the package root for the importing file
52
+ const packageRoot = findPackageRoot(importer);
53
+ if (!packageRoot) return null;
42
54
 
43
- if (isLocalImport && fs.existsSync(localLibPath)) {
44
- // Local file importing $lib -> resolve to local src/lib
45
- targetPath = localLibPath;
46
- } else if (importer.includes("node_modules/@lobb-js/studio")) {
47
- // Import from Studio package in node_modules -> resolve to node_modules/@lobb-js/studio/src/lib
48
- const nodeModulesStudioPath = importer.substring(0, importer.indexOf("node_modules/@lobb-js/studio") + "node_modules/@lobb-js/studio".length);
49
- targetPath = path.join(nodeModulesStudioPath, "src/lib");
50
- } else if (fs.existsSync(studioLibPath)) {
51
- // External file (e.g., Studio in monorepo) importing $lib -> resolve to Studio's src/lib
52
- targetPath = studioLibPath;
53
- } else {
54
- // Neither path exists, let default resolution handle it
55
- return null;
56
- }
55
+ // Check if this package has src/lib
56
+ const libPath = path.join(packageRoot, "src/lib");
57
+ if (!fs.existsSync(libPath)) return null;
57
58
 
58
- // Extract the import path after $lib (e.g., "$lib/store.svelte" -> "/store.svelte")
59
+ // Resolve $lib to this package's src/lib
59
60
  const importPath = source.slice(4); // Remove "$lib"
60
- const resolvedPath = path.join(targetPath, importPath);
61
+ const resolvedPath = path.join(libPath, importPath);
61
62
 
62
63
  // Let Vite resolve the actual file (handles .js, .ts, .svelte extensions)
63
64
  return this.resolve(resolvedPath, importer, { skipSelf: true, ...options });
@@ -1,5 +1,4 @@
1
1
  import { contextualLibAlias } from "./contextual-lib-alias.js";
2
- import { monorepoImportResolver } from "./monorepo-import-resolver.js";
3
2
 
4
3
  /**
5
4
  * Returns an array of Vite plugins needed for Lobb Studio integration.
@@ -12,7 +11,6 @@ import { monorepoImportResolver } from "./monorepo-import-resolver.js";
12
11
  */
13
12
  export function lobbStudioPlugins() {
14
13
  return [
15
- // monorepoImportResolver(),
16
14
  contextualLibAlias(),
17
15
  ];
18
16
  }
package/dist/Lobb.d.ts DELETED
@@ -1,30 +0,0 @@
1
- interface RouteParams {
2
- method: string;
3
- route: string;
4
- payload?: any;
5
- }
6
- type OnResponseHandlers = (reponse: Response) => void;
7
- export declare class Lobb {
8
- lobbUrl: string;
9
- private headers;
10
- private onResponseHandlers;
11
- constructor(lobbUrl: string);
12
- onResponse(callback: OnResponseHandlers): Promise<void>;
13
- setHeaders(headers: HeadersInit): void;
14
- getHeaders(): HeadersInit;
15
- getMeta(): Promise<any>;
16
- findAll(collectionName: string, params: any): Promise<Response>;
17
- findOne(collectionName: string, id: string, queryParams?: any): Promise<Response>;
18
- createOne(collectionName: string, body: any, file?: File): Promise<Response>;
19
- updateOne(collectionName: string, id: string, body: any): Promise<Response>;
20
- readSingleton(collectionName: string): Promise<Response>;
21
- updateSingleton(collectionName: string, body: Record<string, any>): Promise<Response>;
22
- deleteOne(collectionName: string, id: string, force?: boolean): Promise<Response>;
23
- deleteMany(collectionName: string, filter: any, force?: boolean): Promise<Response>;
24
- createMany(collectionName: string, body: any): Promise<Response>;
25
- updateMany(collectionName: string, body: any, filter: any): Promise<Response>;
26
- transactions(body: any[], rollback?: boolean): Promise<Response>;
27
- request(params: RouteParams): Promise<Response>;
28
- private handleResponse;
29
- }
30
- export {};
package/dist/Lobb.js DELETED
@@ -1,358 +0,0 @@
1
- var __assign = (this && this.__assign) || function () {
2
- __assign = Object.assign || function(t) {
3
- for (var s, i = 1, n = arguments.length; i < n; i++) {
4
- s = arguments[i];
5
- for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
6
- t[p] = s[p];
7
- }
8
- return t;
9
- };
10
- return __assign.apply(this, arguments);
11
- };
12
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
13
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
14
- return new (P || (P = Promise))(function (resolve, reject) {
15
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
16
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
17
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
18
- step((generator = generator.apply(thisArg, _arguments || [])).next());
19
- });
20
- };
21
- var __generator = (this && this.__generator) || function (thisArg, body) {
22
- var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g = Object.create((typeof Iterator === "function" ? Iterator : Object).prototype);
23
- return g.next = verb(0), g["throw"] = verb(1), g["return"] = verb(2), typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
24
- function verb(n) { return function (v) { return step([n, v]); }; }
25
- function step(op) {
26
- if (f) throw new TypeError("Generator is already executing.");
27
- while (g && (g = 0, op[0] && (_ = 0)), _) try {
28
- if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
29
- if (y = 0, t) op = [op[0] & 2, t.value];
30
- switch (op[0]) {
31
- case 0: case 1: t = op; break;
32
- case 4: _.label++; return { value: op[1], done: false };
33
- case 5: _.label++; y = op[1]; op = [0]; continue;
34
- case 7: op = _.ops.pop(); _.trys.pop(); continue;
35
- default:
36
- if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
37
- if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
38
- if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
39
- if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
40
- if (t[2]) _.ops.pop();
41
- _.trys.pop(); continue;
42
- }
43
- op = body.call(thisArg, _);
44
- } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
45
- if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
46
- }
47
- };
48
- import qs from "qs";
49
- import { parseFunction } from "./utils";
50
- var Lobb = /** @class */ (function () {
51
- function Lobb(lobbUrl) {
52
- this.headers = [];
53
- this.onResponseHandlers = [];
54
- this.lobbUrl = lobbUrl;
55
- }
56
- Lobb.prototype.onResponse = function (callback) {
57
- return __awaiter(this, void 0, void 0, function () {
58
- return __generator(this, function (_a) {
59
- this.onResponseHandlers.push(callback);
60
- return [2 /*return*/];
61
- });
62
- });
63
- };
64
- Lobb.prototype.setHeaders = function (headers) {
65
- this.headers = headers;
66
- };
67
- Lobb.prototype.getHeaders = function () {
68
- return this.headers;
69
- };
70
- Lobb.prototype.getMeta = function () {
71
- return __awaiter(this, void 0, void 0, function () {
72
- var response, metaResponse, meta;
73
- return __generator(this, function (_a) {
74
- switch (_a.label) {
75
- case 0: return [4 /*yield*/, fetch("".concat(this.lobbUrl, "/api/meta"), {
76
- headers: this.headers,
77
- })];
78
- case 1:
79
- response = _a.sent();
80
- return [4 /*yield*/, this.handleResponse(response)];
81
- case 2:
82
- metaResponse = _a.sent();
83
- return [4 /*yield*/, metaResponse.json()];
84
- case 3:
85
- meta = _a.sent();
86
- meta.studio_workflows = meta.studio_workflows.map(function (workflow) {
87
- return __assign(__assign({}, workflow), { handler: parseFunction(workflow.handler) });
88
- });
89
- return [2 /*return*/, meta];
90
- }
91
- });
92
- });
93
- };
94
- // CRUD methods
95
- Lobb.prototype.findAll = function (collectionName, params) {
96
- return __awaiter(this, void 0, void 0, function () {
97
- var response;
98
- return __generator(this, function (_a) {
99
- switch (_a.label) {
100
- case 0: return [4 /*yield*/, fetch("".concat(this.lobbUrl, "/api/collections/").concat(collectionName, "/search"), {
101
- method: "POST",
102
- headers: this.headers,
103
- body: JSON.stringify(params),
104
- })];
105
- case 1:
106
- response = _a.sent();
107
- return [4 /*yield*/, this.handleResponse(response)];
108
- case 2: return [2 /*return*/, _a.sent()];
109
- }
110
- });
111
- });
112
- };
113
- Lobb.prototype.findOne = function (collectionName, id, queryParams) {
114
- return __awaiter(this, void 0, void 0, function () {
115
- var response;
116
- return __generator(this, function (_a) {
117
- switch (_a.label) {
118
- case 0:
119
- queryParams = queryParams ? "?".concat(qs.stringify(queryParams)) : "";
120
- return [4 /*yield*/, fetch("".concat(this.lobbUrl, "/api/collections/").concat(collectionName, "/").concat(id).concat(queryParams), {
121
- method: "GET",
122
- headers: this.headers,
123
- })];
124
- case 1:
125
- response = _a.sent();
126
- return [4 /*yield*/, this.handleResponse(response)];
127
- case 2: return [2 /*return*/, _a.sent()];
128
- }
129
- });
130
- });
131
- };
132
- Lobb.prototype.createOne = function (collectionName, body, file) {
133
- return __awaiter(this, void 0, void 0, function () {
134
- var formData_1, response;
135
- return __generator(this, function (_a) {
136
- switch (_a.label) {
137
- case 0:
138
- if (file) {
139
- formData_1 = new FormData();
140
- Object.keys(body).forEach(function (key) {
141
- formData_1.append(key, body[key]);
142
- });
143
- formData_1.append("file", file, file.name);
144
- formData_1.append("payload", JSON.stringify({
145
- data: body,
146
- }));
147
- body = formData_1;
148
- }
149
- else {
150
- body = JSON.stringify({
151
- data: body,
152
- });
153
- }
154
- return [4 /*yield*/, fetch("".concat(this.lobbUrl, "/api/collections/").concat(collectionName), {
155
- method: "POST",
156
- headers: this.headers,
157
- body: body,
158
- })];
159
- case 1:
160
- response = _a.sent();
161
- return [4 /*yield*/, this.handleResponse(response)];
162
- case 2: return [2 /*return*/, _a.sent()];
163
- }
164
- });
165
- });
166
- };
167
- Lobb.prototype.updateOne = function (collectionName, id, body) {
168
- return __awaiter(this, void 0, void 0, function () {
169
- var response;
170
- return __generator(this, function (_a) {
171
- switch (_a.label) {
172
- case 0: return [4 /*yield*/, fetch("".concat(this.lobbUrl, "/api/collections/").concat(collectionName, "/").concat(id), {
173
- method: "PATCH",
174
- headers: this.headers,
175
- body: JSON.stringify({
176
- data: body,
177
- }),
178
- })];
179
- case 1:
180
- response = _a.sent();
181
- return [4 /*yield*/, this.handleResponse(response)];
182
- case 2: return [2 /*return*/, _a.sent()];
183
- }
184
- });
185
- });
186
- };
187
- Lobb.prototype.readSingleton = function (collectionName) {
188
- return __awaiter(this, void 0, void 0, function () {
189
- var response;
190
- return __generator(this, function (_a) {
191
- switch (_a.label) {
192
- case 0: return [4 /*yield*/, fetch("".concat(this.lobbUrl, "/api/collections/").concat(collectionName, "/singleton"), {
193
- method: "GET",
194
- headers: this.headers,
195
- })];
196
- case 1:
197
- response = _a.sent();
198
- return [4 /*yield*/, this.handleResponse(response)];
199
- case 2: return [2 /*return*/, _a.sent()];
200
- }
201
- });
202
- });
203
- };
204
- Lobb.prototype.updateSingleton = function (collectionName, body) {
205
- return __awaiter(this, void 0, void 0, function () {
206
- var response;
207
- return __generator(this, function (_a) {
208
- switch (_a.label) {
209
- case 0: return [4 /*yield*/, fetch("".concat(this.lobbUrl, "/api/collections/").concat(collectionName, "/singleton"), {
210
- method: "PATCH",
211
- headers: this.headers,
212
- body: JSON.stringify({
213
- data: body,
214
- }),
215
- })];
216
- case 1:
217
- response = _a.sent();
218
- return [4 /*yield*/, this.handleResponse(response)];
219
- case 2: return [2 /*return*/, _a.sent()];
220
- }
221
- });
222
- });
223
- };
224
- Lobb.prototype.deleteOne = function (collectionName_1, id_1) {
225
- return __awaiter(this, arguments, void 0, function (collectionName, id, force) {
226
- var response;
227
- if (force === void 0) { force = false; }
228
- return __generator(this, function (_a) {
229
- switch (_a.label) {
230
- case 0: return [4 /*yield*/, fetch("".concat(this.lobbUrl, "/api/collections/").concat(collectionName, "/").concat(id).concat(force ? "?force" : ""), {
231
- method: "DELETE",
232
- headers: this.headers,
233
- })];
234
- case 1:
235
- response = _a.sent();
236
- return [4 /*yield*/, this.handleResponse(response)];
237
- case 2: return [2 /*return*/, _a.sent()];
238
- }
239
- });
240
- });
241
- };
242
- Lobb.prototype.deleteMany = function (collectionName_1, filter_1) {
243
- return __awaiter(this, arguments, void 0, function (collectionName, filter, force) {
244
- var response;
245
- if (force === void 0) { force = false; }
246
- return __generator(this, function (_a) {
247
- switch (_a.label) {
248
- case 0: return [4 /*yield*/, fetch("".concat(this.lobbUrl, "/api/collections/").concat(collectionName).concat(force ? "?force" : ""), {
249
- method: "DELETE",
250
- headers: this.headers,
251
- body: JSON.stringify({
252
- filter: filter,
253
- }),
254
- })];
255
- case 1:
256
- response = _a.sent();
257
- return [4 /*yield*/, this.handleResponse(response)];
258
- case 2: return [2 /*return*/, _a.sent()];
259
- }
260
- });
261
- });
262
- };
263
- Lobb.prototype.createMany = function (collectionName, body) {
264
- return __awaiter(this, void 0, void 0, function () {
265
- var response;
266
- return __generator(this, function (_a) {
267
- switch (_a.label) {
268
- case 0:
269
- body = JSON.stringify({
270
- data: body,
271
- });
272
- return [4 /*yield*/, fetch("".concat(this.lobbUrl, "/api/collections/").concat(collectionName), {
273
- method: "POST",
274
- headers: this.headers,
275
- body: body,
276
- })];
277
- case 1:
278
- response = _a.sent();
279
- return [4 /*yield*/, this.handleResponse(response)];
280
- case 2: return [2 /*return*/, _a.sent()];
281
- }
282
- });
283
- });
284
- };
285
- Lobb.prototype.updateMany = function (collectionName, body, filter) {
286
- return __awaiter(this, void 0, void 0, function () {
287
- var response;
288
- return __generator(this, function (_a) {
289
- switch (_a.label) {
290
- case 0: return [4 /*yield*/, fetch("".concat(this.lobbUrl, "/api/collections/").concat(collectionName), {
291
- method: "PATCH",
292
- headers: this.headers,
293
- body: JSON.stringify({
294
- filter: filter,
295
- data: body,
296
- }),
297
- })];
298
- case 1:
299
- response = _a.sent();
300
- return [4 /*yield*/, this.handleResponse(response)];
301
- case 2: return [2 /*return*/, _a.sent()];
302
- }
303
- });
304
- });
305
- };
306
- Lobb.prototype.transactions = function (body, rollback) {
307
- return __awaiter(this, void 0, void 0, function () {
308
- var response;
309
- return __generator(this, function (_a) {
310
- switch (_a.label) {
311
- case 0: return [4 /*yield*/, fetch("".concat(this.lobbUrl, "/api/collections/transactions").concat(rollback ? "?rollback" : ""), {
312
- method: "POST",
313
- headers: this.headers,
314
- body: JSON.stringify(body),
315
- })];
316
- case 1:
317
- response = _a.sent();
318
- return [4 /*yield*/, this.handleResponse(response)];
319
- case 2: return [2 /*return*/, _a.sent()];
320
- }
321
- });
322
- });
323
- };
324
- // CUSTOM REQUEST methods
325
- Lobb.prototype.request = function (params) {
326
- return __awaiter(this, void 0, void 0, function () {
327
- var response;
328
- return __generator(this, function (_a) {
329
- switch (_a.label) {
330
- case 0: return [4 /*yield*/, fetch("".concat(this.lobbUrl).concat(params.route), {
331
- method: params.method,
332
- headers: this.headers,
333
- body: JSON.stringify(params.payload),
334
- })];
335
- case 1:
336
- response = _a.sent();
337
- return [4 /*yield*/, this.handleResponse(response)];
338
- case 2: return [2 /*return*/, _a.sent()];
339
- }
340
- });
341
- });
342
- };
343
- // HELPER methods
344
- Lobb.prototype.handleResponse = function (response) {
345
- return __awaiter(this, void 0, Promise, function () {
346
- var index, handler;
347
- return __generator(this, function (_a) {
348
- for (index = 0; index < this.onResponseHandlers.length; index++) {
349
- handler = this.onResponseHandlers[index];
350
- handler(response.clone());
351
- }
352
- return [2 /*return*/, response];
353
- });
354
- });
355
- };
356
- return Lobb;
357
- }());
358
- export { Lobb };
@@ -1,92 +0,0 @@
1
- import path from "path";
2
- import fs from "fs";
3
-
4
- /**
5
- * Detects if the current project is inside a monorepo workspace.
6
- *
7
- * Checks for workspace configuration files in parent directories:
8
- * - pnpm-workspace.yaml (pnpm)
9
- * - package.json with "workspaces" field (npm/yarn)
10
- *
11
- * @param {string} startDir - Directory to start searching from
12
- * @returns {boolean} True if inside a monorepo workspace
13
- */
14
- function isInMonorepo(startDir) {
15
- let currentDir = startDir;
16
- const root = path.parse(currentDir).root;
17
-
18
- while (currentDir !== root) {
19
- // Check for pnpm-workspace.yaml
20
- if (fs.existsSync(path.join(currentDir, 'pnpm-workspace.yaml'))) {
21
- return true;
22
- }
23
-
24
- // Check for package.json with workspaces field
25
- const pkgPath = path.join(currentDir, 'package.json');
26
- if (fs.existsSync(pkgPath)) {
27
- try {
28
- const pkg = JSON.parse(fs.readFileSync(pkgPath, 'utf-8'));
29
- if (pkg.workspaces) {
30
- return true;
31
- }
32
- } catch (e) {
33
- // Ignore parse errors
34
- }
35
- }
36
-
37
- // Move up one directory
38
- currentDir = path.dirname(currentDir);
39
- }
40
-
41
- return false;
42
- }
43
-
44
- /**
45
- * Vite plugin that resolves @lobb-js/studio imports contextually.
46
- *
47
- * - Inside monorepo: Rewrites to @lobb-js/studio/internal (uses source files from /src for fast HMR)
48
- * - Outside monorepo: Uses default export (uses built files from /dist)
49
- *
50
- * This allows consuming projects to use identical import syntax everywhere:
51
- * `import Studio from '@lobb-js/studio'`
52
- *
53
- * The plugin automatically optimizes the resolution based on the environment.
54
- *
55
- * @returns {import('vite').Plugin}
56
- */
57
- export function monorepoImportResolver() {
58
- let isMonorepo = false;
59
-
60
- return {
61
- name: "monorepo-import-resolver",
62
- enforce: "pre",
63
-
64
- configResolved(config) {
65
- // Detect monorepo once during config resolution
66
- isMonorepo = isInMonorepo(config.root);
67
-
68
- if (isMonorepo) {
69
- console.log('🎯 Lobb Studio: Running in monorepo mode - using source files for fast HMR');
70
- } else {
71
- console.log('📦 Lobb Studio: Running in standalone mode - using built distribution files');
72
- }
73
- },
74
-
75
- async resolveId(source, importer, options) {
76
- // Handle @lobb-js/studio imports (and subpaths like @lobb-js/studio/*)
77
- if (!source.startsWith("@lobb-js/studio")) return null;
78
-
79
- // Don't rewrite if already using /internal path
80
- if (source.startsWith("@lobb-js/studio/internal")) return null;
81
-
82
- // In monorepo, rewrite to /internal path which points to source files
83
- if (isMonorepo) {
84
- const rewrittenSource = source.replace("@lobb-js/studio", "@lobb-js/studio/internal");
85
- return this.resolve(rewrittenSource, importer, { skipSelf: true, ...options });
86
- }
87
-
88
- // Not in monorepo - let default resolution handle it (uses dist/ from node_modules)
89
- return null;
90
- }
91
- };
92
- }