@databricks/appkit 0.74.0 → 0.74.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/appkit/package.js +1 -1
- package/dist/cli/commands/agent/eval.js +7 -4
- package/dist/cli/commands/agent/eval.js.map +1 -1
- package/dist/cli/commands/registry/add.js +77 -6
- package/dist/cli/commands/registry/add.js.map +1 -1
- package/dist/evals/discover.d.ts.map +1 -1
- package/dist/evals/discover.js +22 -16
- package/dist/evals/discover.js.map +1 -1
- package/dist/plugins/server/index.js +2 -2
- package/dist/plugins/server/index.js.map +1 -1
- package/dist/plugins/server/remote-tunnel/remote-tunnel-manager.js +3 -3
- package/dist/plugins/server/remote-tunnel/remote-tunnel-manager.js.map +1 -1
- package/dist/plugins/server/static-server.js +3 -3
- package/dist/plugins/server/static-server.js.map +1 -1
- package/dist/plugins/server/utils.js +3 -3
- package/dist/plugins/server/utils.js.map +1 -1
- package/dist/plugins/server/vite-dev-server.js +4 -4
- package/dist/plugins/server/vite-dev-server.js.map +1 -1
- package/dist/registry/manifest-loader.d.ts +1 -1
- package/dist/shared/src/schemas/manifest.d.ts +54 -54
- package/dist/type-generator/database/generate.js +3 -3
- package/dist/type-generator/database/generate.js.map +1 -1
- package/dist/type-generator/migration.js +2 -2
- package/dist/type-generator/migration.js.map +1 -1
- package/dist/type-generator/serving/server-file-extractor.js +3 -3
- package/dist/type-generator/serving/server-file-extractor.js.map +1 -1
- package/docs/plugins/agents.md +255 -4
- package/package.json +1 -1
- package/sbom.cdx.json +1 -1
|
@@ -12,12 +12,12 @@ declare const resourceFieldEntrySchema: z.ZodObject<{
|
|
|
12
12
|
discovery: z.ZodOptional<z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
13
13
|
type: z.ZodLiteral<"kind">;
|
|
14
14
|
resourceKind: z.ZodEnum<{
|
|
15
|
+
warehouse: "warehouse";
|
|
16
|
+
genie_space: "genie_space";
|
|
15
17
|
postgres_project: "postgres_project";
|
|
16
18
|
postgres_branch: "postgres_branch";
|
|
17
19
|
postgres_database: "postgres_database";
|
|
18
20
|
volume: "volume";
|
|
19
|
-
genie_space: "genie_space";
|
|
20
|
-
warehouse: "warehouse";
|
|
21
21
|
}>;
|
|
22
22
|
select: z.ZodOptional<z.ZodString>;
|
|
23
23
|
display: z.ZodOptional<z.ZodString>;
|
|
@@ -58,12 +58,12 @@ declare const pluginManifestSchema: z.ZodObject<{
|
|
|
58
58
|
discovery: z.ZodOptional<z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
59
59
|
type: z.ZodLiteral<"kind">;
|
|
60
60
|
resourceKind: z.ZodEnum<{
|
|
61
|
+
warehouse: "warehouse";
|
|
62
|
+
genie_space: "genie_space";
|
|
61
63
|
postgres_project: "postgres_project";
|
|
62
64
|
postgres_branch: "postgres_branch";
|
|
63
65
|
postgres_database: "postgres_database";
|
|
64
66
|
volume: "volume";
|
|
65
|
-
genie_space: "genie_space";
|
|
66
|
-
warehouse: "warehouse";
|
|
67
67
|
}>;
|
|
68
68
|
select: z.ZodOptional<z.ZodString>;
|
|
69
69
|
display: z.ZodOptional<z.ZodString>;
|
|
@@ -99,12 +99,12 @@ declare const pluginManifestSchema: z.ZodObject<{
|
|
|
99
99
|
discovery: z.ZodOptional<z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
100
100
|
type: z.ZodLiteral<"kind">;
|
|
101
101
|
resourceKind: z.ZodEnum<{
|
|
102
|
+
warehouse: "warehouse";
|
|
103
|
+
genie_space: "genie_space";
|
|
102
104
|
postgres_project: "postgres_project";
|
|
103
105
|
postgres_branch: "postgres_branch";
|
|
104
106
|
postgres_database: "postgres_database";
|
|
105
107
|
volume: "volume";
|
|
106
|
-
genie_space: "genie_space";
|
|
107
|
-
warehouse: "warehouse";
|
|
108
108
|
}>;
|
|
109
109
|
select: z.ZodOptional<z.ZodString>;
|
|
110
110
|
display: z.ZodOptional<z.ZodString>;
|
|
@@ -139,12 +139,12 @@ declare const pluginManifestSchema: z.ZodObject<{
|
|
|
139
139
|
discovery: z.ZodOptional<z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
140
140
|
type: z.ZodLiteral<"kind">;
|
|
141
141
|
resourceKind: z.ZodEnum<{
|
|
142
|
+
warehouse: "warehouse";
|
|
143
|
+
genie_space: "genie_space";
|
|
142
144
|
postgres_project: "postgres_project";
|
|
143
145
|
postgres_branch: "postgres_branch";
|
|
144
146
|
postgres_database: "postgres_database";
|
|
145
147
|
volume: "volume";
|
|
146
|
-
genie_space: "genie_space";
|
|
147
|
-
warehouse: "warehouse";
|
|
148
148
|
}>;
|
|
149
149
|
select: z.ZodOptional<z.ZodString>;
|
|
150
150
|
display: z.ZodOptional<z.ZodString>;
|
|
@@ -180,12 +180,12 @@ declare const pluginManifestSchema: z.ZodObject<{
|
|
|
180
180
|
discovery: z.ZodOptional<z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
181
181
|
type: z.ZodLiteral<"kind">;
|
|
182
182
|
resourceKind: z.ZodEnum<{
|
|
183
|
+
warehouse: "warehouse";
|
|
184
|
+
genie_space: "genie_space";
|
|
183
185
|
postgres_project: "postgres_project";
|
|
184
186
|
postgres_branch: "postgres_branch";
|
|
185
187
|
postgres_database: "postgres_database";
|
|
186
188
|
volume: "volume";
|
|
187
|
-
genie_space: "genie_space";
|
|
188
|
-
warehouse: "warehouse";
|
|
189
189
|
}>;
|
|
190
190
|
select: z.ZodOptional<z.ZodString>;
|
|
191
191
|
display: z.ZodOptional<z.ZodString>;
|
|
@@ -220,12 +220,12 @@ declare const pluginManifestSchema: z.ZodObject<{
|
|
|
220
220
|
discovery: z.ZodOptional<z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
221
221
|
type: z.ZodLiteral<"kind">;
|
|
222
222
|
resourceKind: z.ZodEnum<{
|
|
223
|
+
warehouse: "warehouse";
|
|
224
|
+
genie_space: "genie_space";
|
|
223
225
|
postgres_project: "postgres_project";
|
|
224
226
|
postgres_branch: "postgres_branch";
|
|
225
227
|
postgres_database: "postgres_database";
|
|
226
228
|
volume: "volume";
|
|
227
|
-
genie_space: "genie_space";
|
|
228
|
-
warehouse: "warehouse";
|
|
229
229
|
}>;
|
|
230
230
|
select: z.ZodOptional<z.ZodString>;
|
|
231
231
|
display: z.ZodOptional<z.ZodString>;
|
|
@@ -259,12 +259,12 @@ declare const pluginManifestSchema: z.ZodObject<{
|
|
|
259
259
|
discovery: z.ZodOptional<z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
260
260
|
type: z.ZodLiteral<"kind">;
|
|
261
261
|
resourceKind: z.ZodEnum<{
|
|
262
|
+
warehouse: "warehouse";
|
|
263
|
+
genie_space: "genie_space";
|
|
262
264
|
postgres_project: "postgres_project";
|
|
263
265
|
postgres_branch: "postgres_branch";
|
|
264
266
|
postgres_database: "postgres_database";
|
|
265
267
|
volume: "volume";
|
|
266
|
-
genie_space: "genie_space";
|
|
267
|
-
warehouse: "warehouse";
|
|
268
268
|
}>;
|
|
269
269
|
select: z.ZodOptional<z.ZodString>;
|
|
270
270
|
display: z.ZodOptional<z.ZodString>;
|
|
@@ -298,12 +298,12 @@ declare const pluginManifestSchema: z.ZodObject<{
|
|
|
298
298
|
discovery: z.ZodOptional<z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
299
299
|
type: z.ZodLiteral<"kind">;
|
|
300
300
|
resourceKind: z.ZodEnum<{
|
|
301
|
+
warehouse: "warehouse";
|
|
302
|
+
genie_space: "genie_space";
|
|
301
303
|
postgres_project: "postgres_project";
|
|
302
304
|
postgres_branch: "postgres_branch";
|
|
303
305
|
postgres_database: "postgres_database";
|
|
304
306
|
volume: "volume";
|
|
305
|
-
genie_space: "genie_space";
|
|
306
|
-
warehouse: "warehouse";
|
|
307
307
|
}>;
|
|
308
308
|
select: z.ZodOptional<z.ZodString>;
|
|
309
309
|
display: z.ZodOptional<z.ZodString>;
|
|
@@ -337,12 +337,12 @@ declare const pluginManifestSchema: z.ZodObject<{
|
|
|
337
337
|
discovery: z.ZodOptional<z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
338
338
|
type: z.ZodLiteral<"kind">;
|
|
339
339
|
resourceKind: z.ZodEnum<{
|
|
340
|
+
warehouse: "warehouse";
|
|
341
|
+
genie_space: "genie_space";
|
|
340
342
|
postgres_project: "postgres_project";
|
|
341
343
|
postgres_branch: "postgres_branch";
|
|
342
344
|
postgres_database: "postgres_database";
|
|
343
345
|
volume: "volume";
|
|
344
|
-
genie_space: "genie_space";
|
|
345
|
-
warehouse: "warehouse";
|
|
346
346
|
}>;
|
|
347
347
|
select: z.ZodOptional<z.ZodString>;
|
|
348
348
|
display: z.ZodOptional<z.ZodString>;
|
|
@@ -376,12 +376,12 @@ declare const pluginManifestSchema: z.ZodObject<{
|
|
|
376
376
|
discovery: z.ZodOptional<z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
377
377
|
type: z.ZodLiteral<"kind">;
|
|
378
378
|
resourceKind: z.ZodEnum<{
|
|
379
|
+
warehouse: "warehouse";
|
|
380
|
+
genie_space: "genie_space";
|
|
379
381
|
postgres_project: "postgres_project";
|
|
380
382
|
postgres_branch: "postgres_branch";
|
|
381
383
|
postgres_database: "postgres_database";
|
|
382
384
|
volume: "volume";
|
|
383
|
-
genie_space: "genie_space";
|
|
384
|
-
warehouse: "warehouse";
|
|
385
385
|
}>;
|
|
386
386
|
select: z.ZodOptional<z.ZodString>;
|
|
387
387
|
display: z.ZodOptional<z.ZodString>;
|
|
@@ -415,12 +415,12 @@ declare const pluginManifestSchema: z.ZodObject<{
|
|
|
415
415
|
discovery: z.ZodOptional<z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
416
416
|
type: z.ZodLiteral<"kind">;
|
|
417
417
|
resourceKind: z.ZodEnum<{
|
|
418
|
+
warehouse: "warehouse";
|
|
419
|
+
genie_space: "genie_space";
|
|
418
420
|
postgres_project: "postgres_project";
|
|
419
421
|
postgres_branch: "postgres_branch";
|
|
420
422
|
postgres_database: "postgres_database";
|
|
421
423
|
volume: "volume";
|
|
422
|
-
genie_space: "genie_space";
|
|
423
|
-
warehouse: "warehouse";
|
|
424
424
|
}>;
|
|
425
425
|
select: z.ZodOptional<z.ZodString>;
|
|
426
426
|
display: z.ZodOptional<z.ZodString>;
|
|
@@ -457,12 +457,12 @@ declare const pluginManifestSchema: z.ZodObject<{
|
|
|
457
457
|
discovery: z.ZodOptional<z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
458
458
|
type: z.ZodLiteral<"kind">;
|
|
459
459
|
resourceKind: z.ZodEnum<{
|
|
460
|
+
warehouse: "warehouse";
|
|
461
|
+
genie_space: "genie_space";
|
|
460
462
|
postgres_project: "postgres_project";
|
|
461
463
|
postgres_branch: "postgres_branch";
|
|
462
464
|
postgres_database: "postgres_database";
|
|
463
465
|
volume: "volume";
|
|
464
|
-
genie_space: "genie_space";
|
|
465
|
-
warehouse: "warehouse";
|
|
466
466
|
}>;
|
|
467
467
|
select: z.ZodOptional<z.ZodString>;
|
|
468
468
|
display: z.ZodOptional<z.ZodString>;
|
|
@@ -498,12 +498,12 @@ declare const pluginManifestSchema: z.ZodObject<{
|
|
|
498
498
|
discovery: z.ZodOptional<z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
499
499
|
type: z.ZodLiteral<"kind">;
|
|
500
500
|
resourceKind: z.ZodEnum<{
|
|
501
|
+
warehouse: "warehouse";
|
|
502
|
+
genie_space: "genie_space";
|
|
501
503
|
postgres_project: "postgres_project";
|
|
502
504
|
postgres_branch: "postgres_branch";
|
|
503
505
|
postgres_database: "postgres_database";
|
|
504
506
|
volume: "volume";
|
|
505
|
-
genie_space: "genie_space";
|
|
506
|
-
warehouse: "warehouse";
|
|
507
507
|
}>;
|
|
508
508
|
select: z.ZodOptional<z.ZodString>;
|
|
509
509
|
display: z.ZodOptional<z.ZodString>;
|
|
@@ -537,12 +537,12 @@ declare const pluginManifestSchema: z.ZodObject<{
|
|
|
537
537
|
discovery: z.ZodOptional<z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
538
538
|
type: z.ZodLiteral<"kind">;
|
|
539
539
|
resourceKind: z.ZodEnum<{
|
|
540
|
+
warehouse: "warehouse";
|
|
541
|
+
genie_space: "genie_space";
|
|
540
542
|
postgres_project: "postgres_project";
|
|
541
543
|
postgres_branch: "postgres_branch";
|
|
542
544
|
postgres_database: "postgres_database";
|
|
543
545
|
volume: "volume";
|
|
544
|
-
genie_space: "genie_space";
|
|
545
|
-
warehouse: "warehouse";
|
|
546
546
|
}>;
|
|
547
547
|
select: z.ZodOptional<z.ZodString>;
|
|
548
548
|
display: z.ZodOptional<z.ZodString>;
|
|
@@ -579,12 +579,12 @@ declare const pluginManifestSchema: z.ZodObject<{
|
|
|
579
579
|
discovery: z.ZodOptional<z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
580
580
|
type: z.ZodLiteral<"kind">;
|
|
581
581
|
resourceKind: z.ZodEnum<{
|
|
582
|
+
warehouse: "warehouse";
|
|
583
|
+
genie_space: "genie_space";
|
|
582
584
|
postgres_project: "postgres_project";
|
|
583
585
|
postgres_branch: "postgres_branch";
|
|
584
586
|
postgres_database: "postgres_database";
|
|
585
587
|
volume: "volume";
|
|
586
|
-
genie_space: "genie_space";
|
|
587
|
-
warehouse: "warehouse";
|
|
588
588
|
}>;
|
|
589
589
|
select: z.ZodOptional<z.ZodString>;
|
|
590
590
|
display: z.ZodOptional<z.ZodString>;
|
|
@@ -620,12 +620,12 @@ declare const pluginManifestSchema: z.ZodObject<{
|
|
|
620
620
|
discovery: z.ZodOptional<z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
621
621
|
type: z.ZodLiteral<"kind">;
|
|
622
622
|
resourceKind: z.ZodEnum<{
|
|
623
|
+
warehouse: "warehouse";
|
|
624
|
+
genie_space: "genie_space";
|
|
623
625
|
postgres_project: "postgres_project";
|
|
624
626
|
postgres_branch: "postgres_branch";
|
|
625
627
|
postgres_database: "postgres_database";
|
|
626
628
|
volume: "volume";
|
|
627
|
-
genie_space: "genie_space";
|
|
628
|
-
warehouse: "warehouse";
|
|
629
629
|
}>;
|
|
630
630
|
select: z.ZodOptional<z.ZodString>;
|
|
631
631
|
display: z.ZodOptional<z.ZodString>;
|
|
@@ -660,12 +660,12 @@ declare const pluginManifestSchema: z.ZodObject<{
|
|
|
660
660
|
discovery: z.ZodOptional<z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
661
661
|
type: z.ZodLiteral<"kind">;
|
|
662
662
|
resourceKind: z.ZodEnum<{
|
|
663
|
+
warehouse: "warehouse";
|
|
664
|
+
genie_space: "genie_space";
|
|
663
665
|
postgres_project: "postgres_project";
|
|
664
666
|
postgres_branch: "postgres_branch";
|
|
665
667
|
postgres_database: "postgres_database";
|
|
666
668
|
volume: "volume";
|
|
667
|
-
genie_space: "genie_space";
|
|
668
|
-
warehouse: "warehouse";
|
|
669
669
|
}>;
|
|
670
670
|
select: z.ZodOptional<z.ZodString>;
|
|
671
671
|
display: z.ZodOptional<z.ZodString>;
|
|
@@ -701,12 +701,12 @@ declare const pluginManifestSchema: z.ZodObject<{
|
|
|
701
701
|
discovery: z.ZodOptional<z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
702
702
|
type: z.ZodLiteral<"kind">;
|
|
703
703
|
resourceKind: z.ZodEnum<{
|
|
704
|
+
warehouse: "warehouse";
|
|
705
|
+
genie_space: "genie_space";
|
|
704
706
|
postgres_project: "postgres_project";
|
|
705
707
|
postgres_branch: "postgres_branch";
|
|
706
708
|
postgres_database: "postgres_database";
|
|
707
709
|
volume: "volume";
|
|
708
|
-
genie_space: "genie_space";
|
|
709
|
-
warehouse: "warehouse";
|
|
710
710
|
}>;
|
|
711
711
|
select: z.ZodOptional<z.ZodString>;
|
|
712
712
|
display: z.ZodOptional<z.ZodString>;
|
|
@@ -741,12 +741,12 @@ declare const pluginManifestSchema: z.ZodObject<{
|
|
|
741
741
|
discovery: z.ZodOptional<z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
742
742
|
type: z.ZodLiteral<"kind">;
|
|
743
743
|
resourceKind: z.ZodEnum<{
|
|
744
|
+
warehouse: "warehouse";
|
|
745
|
+
genie_space: "genie_space";
|
|
744
746
|
postgres_project: "postgres_project";
|
|
745
747
|
postgres_branch: "postgres_branch";
|
|
746
748
|
postgres_database: "postgres_database";
|
|
747
749
|
volume: "volume";
|
|
748
|
-
genie_space: "genie_space";
|
|
749
|
-
warehouse: "warehouse";
|
|
750
750
|
}>;
|
|
751
751
|
select: z.ZodOptional<z.ZodString>;
|
|
752
752
|
display: z.ZodOptional<z.ZodString>;
|
|
@@ -780,12 +780,12 @@ declare const pluginManifestSchema: z.ZodObject<{
|
|
|
780
780
|
discovery: z.ZodOptional<z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
781
781
|
type: z.ZodLiteral<"kind">;
|
|
782
782
|
resourceKind: z.ZodEnum<{
|
|
783
|
+
warehouse: "warehouse";
|
|
784
|
+
genie_space: "genie_space";
|
|
783
785
|
postgres_project: "postgres_project";
|
|
784
786
|
postgres_branch: "postgres_branch";
|
|
785
787
|
postgres_database: "postgres_database";
|
|
786
788
|
volume: "volume";
|
|
787
|
-
genie_space: "genie_space";
|
|
788
|
-
warehouse: "warehouse";
|
|
789
789
|
}>;
|
|
790
790
|
select: z.ZodOptional<z.ZodString>;
|
|
791
791
|
display: z.ZodOptional<z.ZodString>;
|
|
@@ -819,12 +819,12 @@ declare const pluginManifestSchema: z.ZodObject<{
|
|
|
819
819
|
discovery: z.ZodOptional<z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
820
820
|
type: z.ZodLiteral<"kind">;
|
|
821
821
|
resourceKind: z.ZodEnum<{
|
|
822
|
+
warehouse: "warehouse";
|
|
823
|
+
genie_space: "genie_space";
|
|
822
824
|
postgres_project: "postgres_project";
|
|
823
825
|
postgres_branch: "postgres_branch";
|
|
824
826
|
postgres_database: "postgres_database";
|
|
825
827
|
volume: "volume";
|
|
826
|
-
genie_space: "genie_space";
|
|
827
|
-
warehouse: "warehouse";
|
|
828
828
|
}>;
|
|
829
829
|
select: z.ZodOptional<z.ZodString>;
|
|
830
830
|
display: z.ZodOptional<z.ZodString>;
|
|
@@ -858,12 +858,12 @@ declare const pluginManifestSchema: z.ZodObject<{
|
|
|
858
858
|
discovery: z.ZodOptional<z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
859
859
|
type: z.ZodLiteral<"kind">;
|
|
860
860
|
resourceKind: z.ZodEnum<{
|
|
861
|
+
warehouse: "warehouse";
|
|
862
|
+
genie_space: "genie_space";
|
|
861
863
|
postgres_project: "postgres_project";
|
|
862
864
|
postgres_branch: "postgres_branch";
|
|
863
865
|
postgres_database: "postgres_database";
|
|
864
866
|
volume: "volume";
|
|
865
|
-
genie_space: "genie_space";
|
|
866
|
-
warehouse: "warehouse";
|
|
867
867
|
}>;
|
|
868
868
|
select: z.ZodOptional<z.ZodString>;
|
|
869
869
|
display: z.ZodOptional<z.ZodString>;
|
|
@@ -897,12 +897,12 @@ declare const pluginManifestSchema: z.ZodObject<{
|
|
|
897
897
|
discovery: z.ZodOptional<z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
898
898
|
type: z.ZodLiteral<"kind">;
|
|
899
899
|
resourceKind: z.ZodEnum<{
|
|
900
|
+
warehouse: "warehouse";
|
|
901
|
+
genie_space: "genie_space";
|
|
900
902
|
postgres_project: "postgres_project";
|
|
901
903
|
postgres_branch: "postgres_branch";
|
|
902
904
|
postgres_database: "postgres_database";
|
|
903
905
|
volume: "volume";
|
|
904
|
-
genie_space: "genie_space";
|
|
905
|
-
warehouse: "warehouse";
|
|
906
906
|
}>;
|
|
907
907
|
select: z.ZodOptional<z.ZodString>;
|
|
908
908
|
display: z.ZodOptional<z.ZodString>;
|
|
@@ -936,12 +936,12 @@ declare const pluginManifestSchema: z.ZodObject<{
|
|
|
936
936
|
discovery: z.ZodOptional<z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
937
937
|
type: z.ZodLiteral<"kind">;
|
|
938
938
|
resourceKind: z.ZodEnum<{
|
|
939
|
+
warehouse: "warehouse";
|
|
940
|
+
genie_space: "genie_space";
|
|
939
941
|
postgres_project: "postgres_project";
|
|
940
942
|
postgres_branch: "postgres_branch";
|
|
941
943
|
postgres_database: "postgres_database";
|
|
942
944
|
volume: "volume";
|
|
943
|
-
genie_space: "genie_space";
|
|
944
|
-
warehouse: "warehouse";
|
|
945
945
|
}>;
|
|
946
946
|
select: z.ZodOptional<z.ZodString>;
|
|
947
947
|
display: z.ZodOptional<z.ZodString>;
|
|
@@ -978,12 +978,12 @@ declare const pluginManifestSchema: z.ZodObject<{
|
|
|
978
978
|
discovery: z.ZodOptional<z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
979
979
|
type: z.ZodLiteral<"kind">;
|
|
980
980
|
resourceKind: z.ZodEnum<{
|
|
981
|
+
warehouse: "warehouse";
|
|
982
|
+
genie_space: "genie_space";
|
|
981
983
|
postgres_project: "postgres_project";
|
|
982
984
|
postgres_branch: "postgres_branch";
|
|
983
985
|
postgres_database: "postgres_database";
|
|
984
986
|
volume: "volume";
|
|
985
|
-
genie_space: "genie_space";
|
|
986
|
-
warehouse: "warehouse";
|
|
987
987
|
}>;
|
|
988
988
|
select: z.ZodOptional<z.ZodString>;
|
|
989
989
|
display: z.ZodOptional<z.ZodString>;
|
|
@@ -1019,12 +1019,12 @@ declare const pluginManifestSchema: z.ZodObject<{
|
|
|
1019
1019
|
discovery: z.ZodOptional<z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
1020
1020
|
type: z.ZodLiteral<"kind">;
|
|
1021
1021
|
resourceKind: z.ZodEnum<{
|
|
1022
|
+
warehouse: "warehouse";
|
|
1023
|
+
genie_space: "genie_space";
|
|
1022
1024
|
postgres_project: "postgres_project";
|
|
1023
1025
|
postgres_branch: "postgres_branch";
|
|
1024
1026
|
postgres_database: "postgres_database";
|
|
1025
1027
|
volume: "volume";
|
|
1026
|
-
genie_space: "genie_space";
|
|
1027
|
-
warehouse: "warehouse";
|
|
1028
1028
|
}>;
|
|
1029
1029
|
select: z.ZodOptional<z.ZodString>;
|
|
1030
1030
|
display: z.ZodOptional<z.ZodString>;
|
|
@@ -1058,12 +1058,12 @@ declare const pluginManifestSchema: z.ZodObject<{
|
|
|
1058
1058
|
discovery: z.ZodOptional<z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
1059
1059
|
type: z.ZodLiteral<"kind">;
|
|
1060
1060
|
resourceKind: z.ZodEnum<{
|
|
1061
|
+
warehouse: "warehouse";
|
|
1062
|
+
genie_space: "genie_space";
|
|
1061
1063
|
postgres_project: "postgres_project";
|
|
1062
1064
|
postgres_branch: "postgres_branch";
|
|
1063
1065
|
postgres_database: "postgres_database";
|
|
1064
1066
|
volume: "volume";
|
|
1065
|
-
genie_space: "genie_space";
|
|
1066
|
-
warehouse: "warehouse";
|
|
1067
1067
|
}>;
|
|
1068
1068
|
select: z.ZodOptional<z.ZodString>;
|
|
1069
1069
|
display: z.ZodOptional<z.ZodString>;
|
|
@@ -3,7 +3,7 @@ import { walkSchema } from "./walk-schema.js";
|
|
|
3
3
|
import { randomUUID } from "node:crypto";
|
|
4
4
|
import fs from "node:fs/promises";
|
|
5
5
|
import path from "node:path";
|
|
6
|
-
import
|
|
6
|
+
import fs$1 from "node:fs";
|
|
7
7
|
|
|
8
8
|
//#region src/type-generator/database/generate.ts
|
|
9
9
|
/** Safe diagnostic raised when database declarations cannot be generated. */
|
|
@@ -63,7 +63,7 @@ ${walkSchema(schema).map((entry) => ` ${JSON.stringify(entry.name)}: {
|
|
|
63
63
|
}
|
|
64
64
|
/** Atomically replace generated output only when its content changes. */
|
|
65
65
|
async function writeIfChanged(outFile, content) {
|
|
66
|
-
if (
|
|
66
|
+
if (fs$1.existsSync(outFile) && await fs.readFile(outFile, "utf8") === content) return;
|
|
67
67
|
await fs.mkdir(path.dirname(outFile), { recursive: true });
|
|
68
68
|
const temporary = path.join(path.dirname(outFile), `.${path.basename(outFile)}.${randomUUID()}.tmp`);
|
|
69
69
|
try {
|
|
@@ -80,7 +80,7 @@ async function importSchema(schemaFile) {
|
|
|
80
80
|
}
|
|
81
81
|
/** Generate current registry types or neutralize them when loading fails. */
|
|
82
82
|
async function generateDatabaseTypes(options) {
|
|
83
|
-
if (!
|
|
83
|
+
if (!fs$1.existsSync(options.schemaFile)) {
|
|
84
84
|
await writeIfChanged(options.outFile, NEUTRAL_DATABASE_TYPES);
|
|
85
85
|
return;
|
|
86
86
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"generate.js","names":[],"sources":["../../../src/type-generator/database/generate.ts"],"sourcesContent":["import { randomUUID } from \"node:crypto\";\nimport fsSync from \"node:fs\";\nimport fs from \"node:fs/promises\";\nimport path from \"node:path\";\n\nimport type { Schema } from \"../../database/schema-builder\";\nimport { assertFinalizedSchema } from \"../../database/schema-builder/define-schema\";\nimport { walkSchema } from \"./walk-schema\";\n\n/** Safe diagnostic raised when database declarations cannot be generated. */\nexport class DatabaseTypegenError extends Error {\n constructor(message = \"Database schema generation failed\") {\n super(message);\n this.name = \"DatabaseTypegenError\";\n }\n}\n\ninterface GenerateDatabaseTypesOptions {\n readonly schemaFile: string;\n readonly outFile: string;\n}\n\nexport const DATABASE_TYPES_FILE = \"database.d.ts\";\n\nfunction schemaLabel(schemaFile: string): string {\n return path.relative(process.cwd(), schemaFile) || schemaFile;\n}\n\nfunction importFailureReason(error: unknown): string {\n if (error instanceof SyntaxError) return \"could not be parsed\";\n let code: unknown;\n try {\n code =\n error && typeof error === \"object\"\n ? Reflect.get(error, \"code\")\n : undefined;\n } catch {\n code = undefined;\n }\n if (code === \"MODULE_NOT_FOUND\" || code === \"ERR_MODULE_NOT_FOUND\") {\n return \"contains an unresolved import\";\n }\n return \"threw while loading\";\n}\n\n/** Empty augmentation used when no valid database schema is available. */\nexport const NEUTRAL_DATABASE_TYPES = `// Auto-generated by AppKit - DO NOT EDIT\nimport \"@databricks/appkit\";\n\ndeclare module \"@databricks/appkit\" {\n interface DatabaseRegistry {}\n}\n`;\n\n/** Render one `DatabaseRegistry` augmentation from a finalized schema. */\nfunction render(schema: Schema): string {\n const entries = walkSchema(schema)\n .map(\n (entry) => ` ${JSON.stringify(entry.name)}: {\n row: ${entry.row};\n publicRow: ${entry.publicRow};\n insert: ${entry.insert};\n update: ${entry.update};\n filters: ${entry.filters};\n includes: ${entry.includes};\n hasPrimaryKey: ${entry.hasPrimaryKey};\n };`,\n )\n .join(\"\\n\");\n return `// Auto-generated by AppKit - DO NOT EDIT\nimport \"@databricks/appkit\";\n\ndeclare module \"@databricks/appkit\" {\n type DatabaseLogicalFilter<T> = T & {\n and?: readonly DatabaseLogicalFilter<T>[];\n or?: readonly DatabaseLogicalFilter<T>[];\n };\n\n interface DatabaseRegistry {\n${entries}\n }\n}\n`;\n}\n\n/** Atomically replace generated output only when its content changes. */\nasync function writeIfChanged(outFile: string, content: string): Promise<void> {\n if (\n fsSync.existsSync(outFile) &&\n (await fs.readFile(outFile, \"utf8\")) === content\n )\n return;\n await fs.mkdir(path.dirname(outFile), { recursive: true });\n const temporary = path.join(\n path.dirname(outFile),\n `.${path.basename(outFile)}.${randomUUID()}.tmp`,\n );\n try {\n await fs.writeFile(temporary, content, \"utf8\");\n await fs.rename(temporary, outFile);\n } finally {\n await fs.rm(temporary, { force: true });\n }\n}\n\n/** Disable Jiti's module cache so watch-mode runs observe schema edits. */\nasync function importSchema(schemaFile: string): Promise<unknown> {\n const { createJiti } = await import(\"jiti\");\n return createJiti(import.meta.url, { moduleCache: false }).import(schemaFile);\n}\n\n/** Generate current registry types or neutralize them when loading fails. */\nexport async function generateDatabaseTypes(\n options: GenerateDatabaseTypesOptions,\n): Promise<void> {\n if (!fsSync.existsSync(options.schemaFile)) {\n await writeIfChanged(options.outFile, NEUTRAL_DATABASE_TYPES);\n return;\n }\n try {\n const module = (await importSchema(options.schemaFile)) as {\n schema?: Schema;\n };\n if (!(\"schema\" in module)) {\n throw new DatabaseTypegenError(\n `Database schema module \"${schemaLabel(options.schemaFile)}\" must export a named \"schema\"`,\n );\n }\n try {\n assertFinalizedSchema(module.schema);\n } catch {\n throw new DatabaseTypegenError(\n `Database schema \"${schemaLabel(options.schemaFile)}\" is not a finalized AppKit schema`,\n );\n }\n await writeIfChanged(options.outFile, render(module.schema));\n } catch (error) {\n // A failed run must not leave stale entities visible to TypeScript.\n await writeIfChanged(options.outFile, NEUTRAL_DATABASE_TYPES);\n throw error instanceof DatabaseTypegenError\n ? error\n : new DatabaseTypegenError(\n `Database schema \"${schemaLabel(options.schemaFile)}\" ${importFailureReason(error)}`,\n );\n }\n}\n"],"mappings":";;;;;;;;;AAUA,IAAa,uBAAb,cAA0C,MAAM;CAC9C,YAAY,UAAU,qCAAqC;AACzD,QAAM,QAAQ;AACd,OAAK,OAAO;;;AAShB,MAAa,sBAAsB;AAEnC,SAAS,YAAY,YAA4B;AAC/C,QAAO,KAAK,SAAS,QAAQ,KAAK,EAAE,WAAW,IAAI;;AAGrD,SAAS,oBAAoB,OAAwB;AACnD,KAAI,iBAAiB,YAAa,QAAO;CACzC,IAAI;AACJ,KAAI;AACF,SACE,SAAS,OAAO,UAAU,WACtB,QAAQ,IAAI,OAAO,OAAO,GAC1B;SACA;AACN,SAAO;;AAET,KAAI,SAAS,sBAAsB,SAAS,uBAC1C,QAAO;AAET,QAAO;;;AAIT,MAAa,yBAAyB;;;;;;;;AAStC,SAAS,OAAO,QAAwB;AActC,QAAO;;;;;;;;;;EAbS,WAAW,OAAO,CAC/B,KACE,UAAU,OAAO,KAAK,UAAU,MAAM,KAAK,CAAC;aACtC,MAAM,IAAI;mBACJ,MAAM,UAAU;gBACnB,MAAM,OAAO;gBACb,MAAM,OAAO;iBACZ,MAAM,QAAQ;kBACb,MAAM,SAAS;uBACV,MAAM,cAAc;QAEtC,CACA,KAAK,KAAK,CAWL;;;;;;AAOV,eAAe,eAAe,SAAiB,SAAgC;AAC7E,
|
|
1
|
+
{"version":3,"file":"generate.js","names":["fsSync"],"sources":["../../../src/type-generator/database/generate.ts"],"sourcesContent":["import { randomUUID } from \"node:crypto\";\nimport fsSync from \"node:fs\";\nimport fs from \"node:fs/promises\";\nimport path from \"node:path\";\n\nimport type { Schema } from \"../../database/schema-builder\";\nimport { assertFinalizedSchema } from \"../../database/schema-builder/define-schema\";\nimport { walkSchema } from \"./walk-schema\";\n\n/** Safe diagnostic raised when database declarations cannot be generated. */\nexport class DatabaseTypegenError extends Error {\n constructor(message = \"Database schema generation failed\") {\n super(message);\n this.name = \"DatabaseTypegenError\";\n }\n}\n\ninterface GenerateDatabaseTypesOptions {\n readonly schemaFile: string;\n readonly outFile: string;\n}\n\nexport const DATABASE_TYPES_FILE = \"database.d.ts\";\n\nfunction schemaLabel(schemaFile: string): string {\n return path.relative(process.cwd(), schemaFile) || schemaFile;\n}\n\nfunction importFailureReason(error: unknown): string {\n if (error instanceof SyntaxError) return \"could not be parsed\";\n let code: unknown;\n try {\n code =\n error && typeof error === \"object\"\n ? Reflect.get(error, \"code\")\n : undefined;\n } catch {\n code = undefined;\n }\n if (code === \"MODULE_NOT_FOUND\" || code === \"ERR_MODULE_NOT_FOUND\") {\n return \"contains an unresolved import\";\n }\n return \"threw while loading\";\n}\n\n/** Empty augmentation used when no valid database schema is available. */\nexport const NEUTRAL_DATABASE_TYPES = `// Auto-generated by AppKit - DO NOT EDIT\nimport \"@databricks/appkit\";\n\ndeclare module \"@databricks/appkit\" {\n interface DatabaseRegistry {}\n}\n`;\n\n/** Render one `DatabaseRegistry` augmentation from a finalized schema. */\nfunction render(schema: Schema): string {\n const entries = walkSchema(schema)\n .map(\n (entry) => ` ${JSON.stringify(entry.name)}: {\n row: ${entry.row};\n publicRow: ${entry.publicRow};\n insert: ${entry.insert};\n update: ${entry.update};\n filters: ${entry.filters};\n includes: ${entry.includes};\n hasPrimaryKey: ${entry.hasPrimaryKey};\n };`,\n )\n .join(\"\\n\");\n return `// Auto-generated by AppKit - DO NOT EDIT\nimport \"@databricks/appkit\";\n\ndeclare module \"@databricks/appkit\" {\n type DatabaseLogicalFilter<T> = T & {\n and?: readonly DatabaseLogicalFilter<T>[];\n or?: readonly DatabaseLogicalFilter<T>[];\n };\n\n interface DatabaseRegistry {\n${entries}\n }\n}\n`;\n}\n\n/** Atomically replace generated output only when its content changes. */\nasync function writeIfChanged(outFile: string, content: string): Promise<void> {\n if (\n fsSync.existsSync(outFile) &&\n (await fs.readFile(outFile, \"utf8\")) === content\n )\n return;\n await fs.mkdir(path.dirname(outFile), { recursive: true });\n const temporary = path.join(\n path.dirname(outFile),\n `.${path.basename(outFile)}.${randomUUID()}.tmp`,\n );\n try {\n await fs.writeFile(temporary, content, \"utf8\");\n await fs.rename(temporary, outFile);\n } finally {\n await fs.rm(temporary, { force: true });\n }\n}\n\n/** Disable Jiti's module cache so watch-mode runs observe schema edits. */\nasync function importSchema(schemaFile: string): Promise<unknown> {\n const { createJiti } = await import(\"jiti\");\n return createJiti(import.meta.url, { moduleCache: false }).import(schemaFile);\n}\n\n/** Generate current registry types or neutralize them when loading fails. */\nexport async function generateDatabaseTypes(\n options: GenerateDatabaseTypesOptions,\n): Promise<void> {\n if (!fsSync.existsSync(options.schemaFile)) {\n await writeIfChanged(options.outFile, NEUTRAL_DATABASE_TYPES);\n return;\n }\n try {\n const module = (await importSchema(options.schemaFile)) as {\n schema?: Schema;\n };\n if (!(\"schema\" in module)) {\n throw new DatabaseTypegenError(\n `Database schema module \"${schemaLabel(options.schemaFile)}\" must export a named \"schema\"`,\n );\n }\n try {\n assertFinalizedSchema(module.schema);\n } catch {\n throw new DatabaseTypegenError(\n `Database schema \"${schemaLabel(options.schemaFile)}\" is not a finalized AppKit schema`,\n );\n }\n await writeIfChanged(options.outFile, render(module.schema));\n } catch (error) {\n // A failed run must not leave stale entities visible to TypeScript.\n await writeIfChanged(options.outFile, NEUTRAL_DATABASE_TYPES);\n throw error instanceof DatabaseTypegenError\n ? error\n : new DatabaseTypegenError(\n `Database schema \"${schemaLabel(options.schemaFile)}\" ${importFailureReason(error)}`,\n );\n }\n}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AAe,aAAa,YAAsC;CAChE,MAAM,EAAE,eAAe,MAAM,OAAO;AACpC,QAAO,WAAW,OAAO,KAAK,KAAK,EAAE,aAAa,OAAO,CAAC,CAAC,OAAO,WAAW;;;AAI/E,eAAsB,sBACpB,SACe;AACf,KAAI,CAACA,KAAO,WAAW,QAAQ,WAAW,EAAE;AAC1C,QAAM,eAAe,QAAQ,SAAS,uBAAuB;AAC7D;;AAEF,KAAI;EACF,MAAM,SAAU,MAAM,aAAa,QAAQ,WAAW;AAGtD,MAAI,EAAE,YAAY,QAChB,OAAM,IAAI,qBACR,2BAA2B,YAAY,QAAQ,WAAW,CAAC,gCAC5D;AAEH,MAAI;AACF,yBAAsB,OAAO,OAAO;UAC9B;AACN,SAAM,IAAI,qBACR,oBAAoB,YAAY,QAAQ,WAAW,CAAC,oCACrD;;AAEH,QAAM,eAAe,QAAQ,SAAS,OAAO,OAAO,OAAO,CAAC;UACrD,OAAO;AAEd,QAAM,eAAe,QAAQ,SAAS,uBAAuB;AAC7D,QAAM,iBAAiB,uBACnB,QACA,IAAI,qBACF,oBAAoB,YAAY,QAAQ,WAAW,CAAC,IAAI,oBAAoB,MAAM,GACnF"}
|
|
@@ -2,7 +2,7 @@ import { createLogger } from "../logging/logger.js";
|
|
|
2
2
|
import pc from "picocolors";
|
|
3
3
|
import fs from "node:fs/promises";
|
|
4
4
|
import path from "node:path";
|
|
5
|
-
import
|
|
5
|
+
import fs$1 from "node:fs";
|
|
6
6
|
|
|
7
7
|
//#region src/type-generator/migration.ts
|
|
8
8
|
const logger = createLogger("type-generator:migration");
|
|
@@ -16,7 +16,7 @@ const logger = createLogger("type-generator:migration");
|
|
|
16
16
|
*/
|
|
17
17
|
function resolveProjectRoot(outFile) {
|
|
18
18
|
const root = path.resolve(path.dirname(outFile), "..", "..");
|
|
19
|
-
if (!
|
|
19
|
+
if (!fs$1.existsSync(path.join(root, "package.json"))) logger.warn("Resolved project root %s has no package.json — migration may target the wrong directory. Check your outFile path: %s", root, outFile);
|
|
20
20
|
return root;
|
|
21
21
|
}
|
|
22
22
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"migration.js","names":[],"sources":["../../src/type-generator/migration.ts"],"sourcesContent":["import fsSync from \"node:fs\";\nimport fs from \"node:fs/promises\";\nimport path from \"node:path\";\n\nimport pc from \"picocolors\";\n\nimport { createLogger } from \"../logging/logger\";\n\nconst logger = createLogger(\"type-generator:migration\");\n\n/**\n * Derive project root from an outFile path.\n * outFile is always `<projectRoot>/shared/appkit-types/<file>` — both the Vite plugins\n * and the CLI construct it this way, so going up two levels is safe.\n *\n * Validates that the resolved root contains a package.json — if not, logs a warning\n * so custom outFile paths don't silently operate on the wrong directory.\n */\nexport function resolveProjectRoot(outFile: string): string {\n const root = path.resolve(path.dirname(outFile), \"..\", \"..\");\n if (!fsSync.existsSync(path.join(root, \"package.json\"))) {\n logger.warn(\n \"Resolved project root %s has no package.json — migration may target the wrong directory. \" +\n \"Check your outFile path: %s\",\n root,\n outFile,\n );\n }\n return root;\n}\n\n/**\n * Remove old generated types from client/src/ (pre-shared/ location).\n * Best-effort: silently ignores missing files.\n */\nexport async function removeOldGeneratedTypes(\n projectRoot: string,\n filename: string,\n): Promise<void> {\n const oldFile = path.join(projectRoot, \"client\", \"src\", filename);\n try {\n await fs.unlink(oldFile);\n logger.debug(\"Removed old types at %s\", oldFile);\n } catch {\n // File doesn't exist — nothing to clean up\n }\n}\n\n// ── Project config migration ────────────────────────────────────────────\n\nconst migratedProjects = new Set<string>();\n\n/**\n * One-time config migration: update tsconfig and package.json for shared/ types output.\n * Idempotent — each sub-migration checks current file state and skips if already migrated.\n * Deduplicates per project root so monorepo builds migrate each app independently.\n * Opt-out: set `\"appkit\": { \"autoMigrate\": false }` in package.json.\n */\nexport async function migrateProjectConfig(projectRoot: string): Promise<void> {\n const resolved = path.resolve(projectRoot);\n if (migratedProjects.has(resolved)) return;\n migratedProjects.add(resolved);\n\n if (await isAutoMigrateDisabled(projectRoot)) {\n logger.debug(\"Auto-migration disabled via package.json appkit.autoMigrate\");\n return;\n }\n\n const results: Array<{ file: string; action: string }> = [];\n\n results.push(...(await migrateTsconfigClient(projectRoot)));\n results.push(...(await migrateTsconfigServer(projectRoot)));\n results.push(...(await migratePackageJsonScripts(projectRoot)));\n\n if (results.length > 0) {\n printMigrationSummary(results);\n }\n}\n\n/** Exported for testing only. */\nexport function _resetMigrationState(): void {\n migratedProjects.clear();\n}\n\n// ── Helpers ─────────────────────────────────────────────────────────────\n\nasync function isAutoMigrateDisabled(projectRoot: string): Promise<boolean> {\n try {\n const raw = await fs.readFile(\n path.join(projectRoot, \"package.json\"),\n \"utf-8\",\n );\n const parsed = JSON.parse(raw);\n return parsed.appkit?.autoMigrate === false;\n } catch {\n return false;\n }\n}\n\n/** Strip JSONC comments (block and line) so JSON.parse can handle tsconfig files. */\nfunction stripJsonComments(text: string): string {\n // Match strings (to skip them) or comments (to remove them).\n // Strings must be matched first to avoid stripping comment-like patterns inside string values\n // (e.g. \"server/**/*\" contains /* which looks like a block comment start).\n return text.replace(/\"(?:[^\"\\\\]|\\\\.)*\"|\\/\\*[\\s\\S]*?\\*\\/|\\/\\/.*/g, (match) =>\n match.startsWith('\"') ? match : \"\",\n );\n}\n\ntype MigrationResult = Array<{ file: string; action: string }>;\n\n// ── tsconfig.client.json ────────────────────────────────────────────────\n\nasync function migrateTsconfigClient(\n projectRoot: string,\n): Promise<MigrationResult> {\n const results: MigrationResult = [];\n const filePath = path.join(projectRoot, \"tsconfig.client.json\");\n\n try {\n const raw = await fs.readFile(filePath, \"utf-8\");\n const parsed = JSON.parse(stripJsonComments(raw));\n\n if (!Array.isArray(parsed.include)) return results;\n if (parsed.include.includes(\"shared/appkit-types\")) return results;\n\n parsed.include.push(\"shared/appkit-types\");\n await fs.writeFile(\n filePath,\n `${JSON.stringify(parsed, null, 2)}\\n`,\n \"utf-8\",\n );\n results.push({\n file: \"tsconfig.client.json\",\n action: 'added \"shared/appkit-types\" to include',\n });\n } catch (err) {\n logger.warn(\n \"Failed to migrate tsconfig.client.json: %s\",\n (err as Error).message,\n );\n }\n\n return results;\n}\n\n// ── tsconfig.server.json ────────────────────────────────────────────────\n\nasync function migrateTsconfigServer(\n projectRoot: string,\n): Promise<MigrationResult> {\n const results: MigrationResult = [];\n const filePath = path.join(projectRoot, \"tsconfig.server.json\");\n\n try {\n const raw = await fs.readFile(filePath, \"utf-8\");\n const parsed = JSON.parse(stripJsonComments(raw));\n const opts = parsed.compilerOptions;\n\n if (!opts || !opts.outDir) return results; // already migrated or non-standard\n\n delete opts.outDir;\n delete opts.declaration;\n delete opts.declarationMap;\n delete opts.sourceMap;\n opts.noEmit = true;\n\n await fs.writeFile(\n filePath,\n `${JSON.stringify(parsed, null, 2)}\\n`,\n \"utf-8\",\n );\n results.push({\n file: \"tsconfig.server.json\",\n action: \"switched to noEmit mode\",\n });\n } catch (err) {\n logger.warn(\n \"Failed to migrate tsconfig.server.json: %s\",\n (err as Error).message,\n );\n }\n\n return results;\n}\n\n// ── package.json ────────────────────────────────────────────────────────\n\nconst SCRIPT_MIGRATIONS: Record<string, { old: string; new: string }> = {\n \"build:server\": {\n old: \"tsdown -c tsdown.server.config.ts\",\n new: \"tsc -b tsconfig.server.json && tsdown -c tsdown.server.config.ts\",\n },\n typecheck: {\n old: \"tsc -p ./tsconfig.server.json --noEmit && tsc -p ./tsconfig.client.json --noEmit\",\n new: \"tsc -b tsconfig.server.json && tsc -b tsconfig.client.json\",\n },\n};\n\nasync function migratePackageJsonScripts(\n projectRoot: string,\n): Promise<MigrationResult> {\n const results: MigrationResult = [];\n const filePath = path.join(projectRoot, \"package.json\");\n\n try {\n const raw = await fs.readFile(filePath, \"utf-8\");\n const parsed = JSON.parse(raw);\n const scripts = parsed.scripts;\n if (!scripts) return results;\n\n const updated: string[] = [];\n\n for (const [name, { old, new: replacement }] of Object.entries(\n SCRIPT_MIGRATIONS,\n )) {\n if (scripts[name] === old) {\n scripts[name] = replacement;\n updated.push(name);\n }\n }\n\n if (updated.length === 0) return results;\n\n const indent = raw.match(/^\\s+/m)?.[0]?.length === 4 ? 4 : 2;\n await fs.writeFile(\n filePath,\n `${JSON.stringify(parsed, null, indent)}\\n`,\n \"utf-8\",\n );\n results.push({\n file: \"package.json\",\n action: `updated ${updated.join(\" and \")} scripts`,\n });\n } catch (err) {\n logger.warn(\n \"Failed to migrate package.json scripts: %s\",\n (err as Error).message,\n );\n }\n\n return results;\n}\n\n// ── Summary ─────────────────────────────────────────────────────────────\n\nfunction printMigrationSummary(\n results: Array<{ file: string; action: string }>,\n) {\n const separator = pc.dim(\"─\".repeat(50));\n console.log(\"\");\n console.log(` ${pc.bold(\"Typegen Migration\")}`);\n console.log(` ${separator}`);\n for (const { file, action } of results) {\n console.log(` ${pc.green(\"✓\")} ${file.padEnd(24)} ${pc.dim(action)}`);\n }\n console.log(` ${separator}`);\n console.log(\"\");\n}\n"],"mappings":";;;;;;;AAQA,MAAM,SAAS,aAAa,2BAA2B;;;;;;;;;AAUvD,SAAgB,mBAAmB,SAAyB;CAC1D,MAAM,OAAO,KAAK,QAAQ,KAAK,QAAQ,QAAQ,EAAE,MAAM,KAAK;AAC5D,KAAI,CAAC,OAAO,WAAW,KAAK,KAAK,MAAM,eAAe,CAAC,CACrD,QAAO,KACL,wHAEA,MACA,QACD;AAEH,QAAO;;;;;;AAOT,eAAsB,wBACpB,aACA,UACe;CACf,MAAM,UAAU,KAAK,KAAK,aAAa,UAAU,OAAO,SAAS;AACjE,KAAI;AACF,QAAM,GAAG,OAAO,QAAQ;AACxB,SAAO,MAAM,2BAA2B,QAAQ;SAC1C;;AAOV,MAAM,mCAAmB,IAAI,KAAa;;;;;;;AAQ1C,eAAsB,qBAAqB,aAAoC;CAC7E,MAAM,WAAW,KAAK,QAAQ,YAAY;AAC1C,KAAI,iBAAiB,IAAI,SAAS,CAAE;AACpC,kBAAiB,IAAI,SAAS;AAE9B,KAAI,MAAM,sBAAsB,YAAY,EAAE;AAC5C,SAAO,MA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K,KAAK;AACZ,SAAO,KACL,8CACC,IAAc,QAChB;;AAGH,QAAO;;AAKT,SAAS,sBACP,SACA;CACA,MAAM,YAAY,GAAG,IAAI,IAAI,OAAO,GAAG,CAAC;AACxC,SAAQ,IAAI,GAAG;AACf,SAAQ,IAAI,KAAK,GAAG,KAAK,oBAAoB,GAAG;AAChD,SAAQ,IAAI,KAAK,YAAY;AAC7B,MAAK,MAAM,EAAE,MAAM,YAAY,QAC7B,SAAQ,IAAI,KAAK,GAAG,MAAM,IAAI,CAAC,GAAG,KAAK,OAAO,GAAG,CAAC,GAAG,GAAG,IAAI,OAAO,GAAG;AAExE,SAAQ,IAAI,KAAK,YAAY;AAC7B,SAAQ,IAAI,GAAG"}
|
|
1
|
+
{"version":3,"file":"migration.js","names":["fsSync"],"sources":["../../src/type-generator/migration.ts"],"sourcesContent":["import fsSync from \"node:fs\";\nimport fs from \"node:fs/promises\";\nimport path from \"node:path\";\n\nimport pc from \"picocolors\";\n\nimport { createLogger } from \"../logging/logger\";\n\nconst logger = createLogger(\"type-generator:migration\");\n\n/**\n * Derive project root from an outFile path.\n * outFile is always `<projectRoot>/shared/appkit-types/<file>` — both the Vite plugins\n * and the CLI construct it this way, so going up two levels is safe.\n *\n * Validates that the resolved root contains a package.json — if not, logs a warning\n * so custom outFile paths don't silently operate on the wrong directory.\n */\nexport function resolveProjectRoot(outFile: string): string {\n const root = path.resolve(path.dirname(outFile), \"..\", \"..\");\n if (!fsSync.existsSync(path.join(root, \"package.json\"))) {\n logger.warn(\n \"Resolved project root %s has no package.json — migration may target the wrong directory. \" +\n \"Check your outFile path: %s\",\n root,\n outFile,\n );\n }\n return root;\n}\n\n/**\n * Remove old generated types from client/src/ (pre-shared/ location).\n * Best-effort: silently ignores missing files.\n */\nexport async function removeOldGeneratedTypes(\n projectRoot: string,\n filename: string,\n): Promise<void> {\n const oldFile = path.join(projectRoot, \"client\", \"src\", filename);\n try {\n await fs.unlink(oldFile);\n logger.debug(\"Removed old types at %s\", oldFile);\n } catch {\n // File doesn't exist — nothing to clean up\n }\n}\n\n// ── Project config migration ────────────────────────────────────────────\n\nconst migratedProjects = new Set<string>();\n\n/**\n * One-time config migration: update tsconfig and package.json for shared/ types output.\n * Idempotent — each sub-migration checks current file state and skips if already migrated.\n * Deduplicates per project root so monorepo builds migrate each app independently.\n * Opt-out: set `\"appkit\": { \"autoMigrate\": false }` in package.json.\n */\nexport async function migrateProjectConfig(projectRoot: string): Promise<void> {\n const resolved = path.resolve(projectRoot);\n if (migratedProjects.has(resolved)) return;\n migratedProjects.add(resolved);\n\n if (await isAutoMigrateDisabled(projectRoot)) {\n logger.debug(\"Auto-migration disabled via package.json appkit.autoMigrate\");\n return;\n }\n\n const results: Array<{ file: string; action: string }> = [];\n\n results.push(...(await migrateTsconfigClient(projectRoot)));\n results.push(...(await migrateTsconfigServer(projectRoot)));\n results.push(...(await migratePackageJsonScripts(projectRoot)));\n\n if (results.length > 0) {\n printMigrationSummary(results);\n }\n}\n\n/** Exported for testing only. */\nexport function _resetMigrationState(): void {\n migratedProjects.clear();\n}\n\n// ── Helpers ─────────────────────────────────────────────────────────────\n\nasync function isAutoMigrateDisabled(projectRoot: string): Promise<boolean> {\n try {\n const raw = await fs.readFile(\n path.join(projectRoot, \"package.json\"),\n \"utf-8\",\n );\n const parsed = JSON.parse(raw);\n return parsed.appkit?.autoMigrate === false;\n } catch {\n return false;\n }\n}\n\n/** Strip JSONC comments (block and line) so JSON.parse can handle tsconfig files. */\nfunction stripJsonComments(text: string): string {\n // Match strings (to skip them) or comments (to remove them).\n // Strings must be matched first to avoid stripping comment-like patterns inside string values\n // (e.g. \"server/**/*\" contains /* which looks like a block comment start).\n return text.replace(/\"(?:[^\"\\\\]|\\\\.)*\"|\\/\\*[\\s\\S]*?\\*\\/|\\/\\/.*/g, (match) =>\n match.startsWith('\"') ? match : \"\",\n );\n}\n\ntype MigrationResult = Array<{ file: string; action: string }>;\n\n// ── tsconfig.client.json ────────────────────────────────────────────────\n\nasync function migrateTsconfigClient(\n projectRoot: string,\n): Promise<MigrationResult> {\n const results: MigrationResult = [];\n const filePath = path.join(projectRoot, \"tsconfig.client.json\");\n\n try {\n const raw = await fs.readFile(filePath, \"utf-8\");\n const parsed = JSON.parse(stripJsonComments(raw));\n\n if (!Array.isArray(parsed.include)) return results;\n if (parsed.include.includes(\"shared/appkit-types\")) return results;\n\n parsed.include.push(\"shared/appkit-types\");\n await fs.writeFile(\n filePath,\n `${JSON.stringify(parsed, null, 2)}\\n`,\n \"utf-8\",\n );\n results.push({\n file: \"tsconfig.client.json\",\n action: 'added \"shared/appkit-types\" to include',\n });\n } catch (err) {\n logger.warn(\n \"Failed to migrate tsconfig.client.json: %s\",\n (err as Error).message,\n );\n }\n\n return results;\n}\n\n// ── tsconfig.server.json ────────────────────────────────────────────────\n\nasync function migrateTsconfigServer(\n projectRoot: string,\n): Promise<MigrationResult> {\n const results: MigrationResult = [];\n const filePath = path.join(projectRoot, \"tsconfig.server.json\");\n\n try {\n const raw = await fs.readFile(filePath, \"utf-8\");\n const parsed = JSON.parse(stripJsonComments(raw));\n const opts = parsed.compilerOptions;\n\n if (!opts || !opts.outDir) return results; // already migrated or non-standard\n\n delete opts.outDir;\n delete opts.declaration;\n delete opts.declarationMap;\n delete opts.sourceMap;\n opts.noEmit = true;\n\n await fs.writeFile(\n filePath,\n `${JSON.stringify(parsed, null, 2)}\\n`,\n \"utf-8\",\n );\n results.push({\n file: \"tsconfig.server.json\",\n action: \"switched to noEmit mode\",\n });\n } catch (err) {\n logger.warn(\n \"Failed to migrate tsconfig.server.json: %s\",\n (err as Error).message,\n );\n }\n\n return results;\n}\n\n// ── package.json ────────────────────────────────────────────────────────\n\nconst SCRIPT_MIGRATIONS: Record<string, { old: string; new: string }> = {\n \"build:server\": {\n old: \"tsdown -c tsdown.server.config.ts\",\n new: \"tsc -b tsconfig.server.json && tsdown -c tsdown.server.config.ts\",\n },\n typecheck: {\n old: \"tsc -p ./tsconfig.server.json --noEmit && tsc -p ./tsconfig.client.json --noEmit\",\n new: \"tsc -b tsconfig.server.json && tsc -b tsconfig.client.json\",\n },\n};\n\nasync function migratePackageJsonScripts(\n projectRoot: string,\n): Promise<MigrationResult> {\n const results: MigrationResult = [];\n const filePath = path.join(projectRoot, \"package.json\");\n\n try {\n const raw = await fs.readFile(filePath, \"utf-8\");\n const parsed = JSON.parse(raw);\n const scripts = parsed.scripts;\n if (!scripts) return results;\n\n const updated: string[] = [];\n\n for (const [name, { old, new: replacement }] of Object.entries(\n SCRIPT_MIGRATIONS,\n )) {\n if (scripts[name] === old) {\n scripts[name] = replacement;\n updated.push(name);\n }\n }\n\n if (updated.length === 0) return results;\n\n const indent = raw.match(/^\\s+/m)?.[0]?.length === 4 ? 4 : 2;\n await fs.writeFile(\n filePath,\n `${JSON.stringify(parsed, null, indent)}\\n`,\n \"utf-8\",\n );\n results.push({\n file: \"package.json\",\n action: `updated ${updated.join(\" and \")} scripts`,\n });\n } catch (err) {\n logger.warn(\n \"Failed to migrate package.json scripts: %s\",\n (err as Error).message,\n );\n }\n\n return results;\n}\n\n// ── Summary ─────────────────────────────────────────────────────────────\n\nfunction printMigrationSummary(\n results: Array<{ file: string; action: string }>,\n) {\n const separator = pc.dim(\"─\".repeat(50));\n console.log(\"\");\n console.log(` ${pc.bold(\"Typegen Migration\")}`);\n console.log(` ${separator}`);\n for (const { file, action } of results) {\n console.log(` ${pc.green(\"✓\")} ${file.padEnd(24)} ${pc.dim(action)}`);\n }\n console.log(` ${separator}`);\n console.log(\"\");\n}\n"],"mappings":";;;;;;;AAQA,MAAM,SAAS,aAAa,2BAA2B;;;;;;;;;AAUvD,SAAgB,mBAAmB,SAAyB;CAC1D,MAAM,OAAO,KAAK,QAAQ,KAAK,QAAQ,QAAQ,EAAE,MAAM,KAAK;AAC5D,KAAI,CAACA,KAAO,WAAW,KAAK,KAAK,MAAM,eAAe,CAAC,CACrD,QAAO,KACL,wHAEA,MACA,QACD;AAEH,QAAO;;;;;;AAOT,eAAsB,w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K,kBAAkB,OAAO,QACrD,kBACD,CACC,KAAI,QAAQ,UAAU,KAAK;AACzB,WAAQ,QAAQ;AAChB,WAAQ,KAAK,KAAK;;AAItB,MAAI,QAAQ,WAAW,EAAG,QAAO;EAEjC,MAAM,SAAS,IAAI,MAAM,QAAQ,GAAG,IAAI,WAAW,IAAI,IAAI;AAC3D,QAAM,GAAG,UACP,UACA,GAAG,KAAK,UAAU,QAAQ,MAAM,OAAO,CAAC,KACxC,QACD;AACD,UAAQ,KAAK;GACX,MAAM;GACN,QAAQ,WAAW,QAAQ,KAAK,QAAQ,CAAC;GAC1C,CAAC;UACK,KAAK;AACZ,SAAO,KACL,8CACC,IAAc,QAChB;;AAGH,QAAO;;AAKT,SAAS,sBACP,SACA;CACA,MAAM,YAAY,GAAG,IAAI,IAAI,OAAO,GAAG,CAAC;AACxC,SAAQ,IAAI,GAAG;AACf,SAAQ,IAAI,KAAK,GAAG,KAAK,oBAAoB,GAAG;AAChD,SAAQ,IAAI,KAAK,YAAY;AAC7B,MAAK,MAAM,EAAE,MAAM,YAAY,QAC7B,SAAQ,IAAI,KAAK,GAAG,MAAM,IAAI,CAAC,GAAG,KAAK,OAAO,GAAG,CAAC,GAAG,GAAG,IAAI,OAAO,GAAG;AAExE,SAAQ,IAAI,KAAK,YAAY;AAC7B,SAAQ,IAAI,GAAG"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { createLogger } from "../../logging/logger.js";
|
|
2
2
|
import path from "node:path";
|
|
3
|
-
import
|
|
3
|
+
import fs from "node:fs";
|
|
4
4
|
import { Lang, parse } from "@ast-grep/napi";
|
|
5
5
|
|
|
6
6
|
//#region src/type-generator/serving/server-file-extractor.ts
|
|
@@ -20,7 +20,7 @@ const SERVER_FILE_CANDIDATES = ["server/index.ts", "server/server.ts"];
|
|
|
20
20
|
function findServerFile(basePath) {
|
|
21
21
|
for (const candidate of SERVER_FILE_CANDIDATES) {
|
|
22
22
|
const fullPath = path.join(basePath, candidate);
|
|
23
|
-
if (
|
|
23
|
+
if (fs.existsSync(fullPath)) return fullPath;
|
|
24
24
|
}
|
|
25
25
|
return null;
|
|
26
26
|
}
|
|
@@ -35,7 +35,7 @@ function findServerFile(basePath) {
|
|
|
35
35
|
function extractServingEndpoints(serverFilePath) {
|
|
36
36
|
let content;
|
|
37
37
|
try {
|
|
38
|
-
content =
|
|
38
|
+
content = fs.readFileSync(serverFilePath, "utf-8");
|
|
39
39
|
} catch {
|
|
40
40
|
logger.debug("Could not read server file: %s", serverFilePath);
|
|
41
41
|
return null;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"server-file-extractor.js","names":[
|
|
1
|
+
{"version":3,"file":"server-file-extractor.js","names":[],"sources":["../../../src/type-generator/serving/server-file-extractor.ts"],"sourcesContent":["import fs from \"node:fs\";\nimport path from \"node:path\";\n\nimport { Lang, parse, type SgNode } from \"@ast-grep/napi\";\n\nimport { createLogger } from \"../../logging/logger\";\nimport type { EndpointConfig } from \"../../plugins/serving/types\";\n\nconst logger = createLogger(\"type-generator:serving:extractor\");\n\n/**\n * Candidate paths for the server entry file, relative to the project root.\n * Checked in order; the first that exists is used.\n * Same convention as plugin sync (sync.ts SERVER_FILE_CANDIDATES).\n */\nconst SERVER_FILE_CANDIDATES = [\"server/index.ts\", \"server/server.ts\"];\n\n/**\n * Find the server entry file by checking candidate paths in order.\n *\n * @param basePath - Project root directory to search from\n * @returns Absolute path to the server file, or null if none found\n */\nexport function findServerFile(basePath: string): string | null {\n for (const candidate of SERVER_FILE_CANDIDATES) {\n const fullPath = path.join(basePath, candidate);\n if (fs.existsSync(fullPath)) {\n return fullPath;\n }\n }\n return null;\n}\n\n/**\n * Extract serving endpoint config from a server file by AST-parsing it.\n * Looks for `serving({ endpoints: { alias: { env: \"...\" }, ... } })` calls\n * and extracts the endpoint alias names and their environment variable mappings.\n *\n * @param serverFilePath - Absolute path to the server entry file\n * @returns Extracted endpoint config, or null if not found or not extractable\n */\nexport function extractServingEndpoints(\n serverFilePath: string,\n): Record<string, EndpointConfig> | null {\n let content: string;\n try {\n content = fs.readFileSync(serverFilePath, \"utf-8\");\n } catch {\n logger.debug(\"Could not read server file: %s\", serverFilePath);\n return null;\n }\n\n const lang = serverFilePath.endsWith(\".tsx\") ? Lang.Tsx : Lang.TypeScript;\n const ast = parse(lang, content);\n const root = ast.root();\n\n // Find serving(...) call expressions\n const servingCall = findServingCall(root);\n if (!servingCall) {\n logger.debug(\"No serving() call found in %s\", serverFilePath);\n return null;\n }\n\n // Get the first argument (the config object)\n const args = servingCall.field(\"arguments\");\n if (!args) {\n return null;\n }\n\n const configArg = args.children().find((child) => child.kind() === \"object\");\n if (!configArg) {\n // serving() called with no args or non-object arg\n return null;\n }\n\n // Find the \"endpoints\" property in the config object\n const endpointsPair = findProperty(configArg, \"endpoints\");\n if (!endpointsPair) {\n // Config object has no \"endpoints\" property (e.g. serving({ timeout: 5000 }))\n return null;\n }\n\n // Get the value of the endpoints property\n const endpointsValue = getPropertyValue(endpointsPair);\n if (!endpointsValue || endpointsValue.kind() !== \"object\") {\n // endpoints is a variable reference, not an inline object\n logger.debug(\n \"serving() endpoints is not an inline object literal in %s. \" +\n \"Pass endpoints explicitly via appKitServingTypesPlugin({ endpoints }) in vite.config.ts.\",\n serverFilePath,\n );\n return null;\n }\n\n // Extract each endpoint entry\n const endpoints: Record<string, EndpointConfig> = {};\n const pairs = endpointsValue\n .children()\n .filter((child) => child.kind() === \"pair\");\n\n for (const pair of pairs) {\n const entry = extractEndpointEntry(pair);\n if (entry) {\n endpoints[entry.alias] = entry.config;\n }\n }\n\n if (Object.keys(endpoints).length === 0) {\n return null;\n }\n\n logger.debug(\n \"Extracted %d endpoint(s) from %s: %s\",\n Object.keys(endpoints).length,\n serverFilePath,\n Object.keys(endpoints).join(\", \"),\n );\n\n return endpoints;\n}\n\n/**\n * Find the serving() call expression in the AST.\n * Looks for call expressions where the callee identifier is \"serving\".\n */\nfunction findServingCall(root: SgNode): SgNode | null {\n const callExpressions = root.findAll({\n rule: { kind: \"call_expression\" },\n });\n\n for (const call of callExpressions) {\n const callee = call.children()[0];\n if (callee?.kind() === \"identifier\" && callee.text() === \"serving\") {\n return call;\n }\n }\n\n return null;\n}\n\n/**\n * Find a property (pair node) with the given key name in an object expression.\n */\nfunction findProperty(objectNode: SgNode, propertyName: string): SgNode | null {\n const pairs = objectNode\n .children()\n .filter((child) => child.kind() === \"pair\");\n\n for (const pair of pairs) {\n const key = pair.children()[0];\n if (!key) continue;\n\n const keyText =\n key.kind() === \"property_identifier\"\n ? key.text()\n : key.kind() === \"string\"\n ? key.text().replace(/^['\"]|['\"]$/g, \"\")\n : null;\n\n if (keyText === propertyName) {\n return pair;\n }\n }\n\n return null;\n}\n\n/**\n * Get the value node from a pair (property: value).\n * The value is typically the last meaningful child after the colon.\n */\nfunction getPropertyValue(pairNode: SgNode): SgNode | null {\n const children = pairNode.children();\n // pair children: [key, \":\", value]\n return children.length >= 3 ? children[children.length - 1] : null;\n}\n\n/**\n * Extract a single endpoint entry from a pair node like:\n * `demo: { env: \"DATABRICKS_SERVING_ENDPOINT_NAME\", servedModel: \"my-model\" }`\n */\nfunction extractEndpointEntry(\n pair: SgNode,\n): { alias: string; config: EndpointConfig } | null {\n const children = pair.children();\n if (children.length < 3) return null;\n\n // Get alias name (the key)\n const keyNode = children[0];\n const alias =\n keyNode.kind() === \"property_identifier\"\n ? keyNode.text()\n : keyNode.kind() === \"string\"\n ? keyNode.text().replace(/^['\"]|['\"]$/g, \"\")\n : null;\n\n if (!alias) return null;\n\n // Get the value (should be an object like { env: \"...\" })\n const valueNode = children[children.length - 1];\n if (valueNode.kind() !== \"object\") return null;\n\n // Extract env field\n const envPair = findProperty(valueNode, \"env\");\n if (!envPair) return null;\n\n const envValue = getPropertyValue(envPair);\n if (!envValue || envValue.kind() !== \"string\") return null;\n\n const env = envValue.text().replace(/^['\"]|['\"]$/g, \"\");\n\n // Extract optional servedModel field\n const config: EndpointConfig = { env };\n const servedModelPair = findProperty(valueNode, \"servedModel\");\n if (servedModelPair) {\n const servedModelValue = getPropertyValue(servedModelPair);\n if (servedModelValue?.kind() === \"string\") {\n config.servedModel = servedModelValue.text().replace(/^['\"]|['\"]$/g, \"\");\n }\n }\n\n return { alias, config };\n}\n"],"mappings":";;;;;;AAQA,MAAM,SAAS,aAAa,mCAAmC;;;;;;AAO/D,MAAM,yBAAyB,CAAC,mBAAmB,mBAAmB;;;;;;;AAQtE,SAAgB,eAAe,UAAiC;AAC9D,MAAK,MAAM,aAAa,wBAAwB;EAC9C,MAAM,WAAW,KAAK,KAAK,UAAU,UAAU;AAC/C,MAAI,GAAG,WAAW,SAAS,CACzB,QAAO;;AAGX,QAAO;;;;;;;;;;AAWT,SAAgB,wBACd,gBACuC;CACvC,IAAI;AACJ,KAAI;AACF,YAAU,GAAG,aAAa,gBAAgB,QAAQ;SAC5C;AACN,SAAO,MAAM,kCAAkC,eAAe;AAC9D,SAAO;;CAQT,MAAM,cAAc,gBAJR,MADC,eAAe,SAAS,OAAO,GAAG,KAAK,MAAM,KAAK,YACvC,QAAQ,CACf,MAAM,CAGkB;AACzC,KAAI,CAAC,aAAa;AAChB,SAAO,MAAM,iCAAiC,eAAe;AAC7D,SAAO;;CAIT,MAAM,OAAO,YAAY,MAAM,YAAY;AAC3C,KAAI,CAAC,KACH,QAAO;CAGT,MAAM,YAAY,KAAK,UAAU,CAAC,MAAM,UAAU,MAAM,MAAM,KAAK,SAAS;AAC5E,KAAI,CAAC,UAEH,QAAO;CAIT,MAAM,gBAAgB,aAAa,WAAW,YAAY;AAC1D,KAAI,CAAC,cAEH,QAAO;CAIT,MAAM,iBAAiB,iBAAiB,cAAc;AACtD,KAAI,CAAC,kBAAkB,eAAe,MAAM,KAAK,UAAU;AAEzD,SAAO,MACL,uJAEA,eACD;AACD,SAAO;;CAIT,MAAM,YAA4C,EAAE;CACpD,MAAM,QAAQ,eACX,UAAU,CACV,QAAQ,UAAU,MAAM,MAAM,KAAK,OAAO;AAE7C,MAAK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