@cedarjs/internal 4.2.1-next.0 → 4.2.1-next.269
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/build/api.d.ts +1 -0
- package/dist/build/api.d.ts.map +1 -1
- package/dist/build/api.js +74 -7
- package/dist/build/esbuild-plugin-cedar-context-wrapping.d.ts +4 -0
- package/dist/build/esbuild-plugin-cedar-context-wrapping.d.ts.map +1 -0
- package/dist/build/esbuild-plugin-cedar-context-wrapping.js +35 -0
- package/dist/cjs/build/api.d.ts +1 -0
- package/dist/cjs/build/api.d.ts.map +1 -1
- package/dist/cjs/build/api.js +75 -7
- package/dist/cjs/build/esbuild-plugin-cedar-context-wrapping.d.ts +4 -0
- package/dist/cjs/build/esbuild-plugin-cedar-context-wrapping.d.ts.map +1 -0
- package/dist/cjs/build/esbuild-plugin-cedar-context-wrapping.js +59 -0
- package/dist/cjs/generate/gqlormSchema.d.ts +2 -0
- package/dist/cjs/generate/gqlormSchema.d.ts.map +1 -1
- package/dist/cjs/generate/gqlormSchema.js +325 -1
- package/dist/cjs/generate/plugins/rw-typescript-resolvers/visitor.d.ts.map +1 -1
- package/dist/cjs/generate/typeDefinitions.js +5 -8
- package/dist/cjs/validateSchema.js +2 -2
- package/dist/generate/gqlormSchema.d.ts +2 -0
- package/dist/generate/gqlormSchema.d.ts.map +1 -1
- package/dist/generate/gqlormSchema.js +325 -1
- package/dist/generate/plugins/rw-typescript-resolvers/visitor.d.ts.map +1 -1
- package/dist/generate/typeDefinitions.js +5 -8
- package/dist/validateSchema.js +2 -2
- package/package.json +20 -14
|
@@ -308,7 +308,9 @@ function buildBackendModelInfo(dmmf) {
|
|
|
308
308
|
name: field.name,
|
|
309
309
|
graphqlType: mapDmmfTypeToGraphql(field.type, field.kind),
|
|
310
310
|
isRequired: field.isRequired,
|
|
311
|
-
isId: field.isId
|
|
311
|
+
isId: field.isId,
|
|
312
|
+
hasDefaultValue: field.hasDefaultValue,
|
|
313
|
+
isUpdatedAt: field.isUpdatedAt ?? false
|
|
312
314
|
});
|
|
313
315
|
}
|
|
314
316
|
if (fields.length > 0) {
|
|
@@ -423,6 +425,46 @@ function generateGqlormBackendContent(models, config = DEFAULT_GQLORM_BACKEND_CO
|
|
|
423
425
|
lines.push(" where: Record<string, unknown>");
|
|
424
426
|
lines.push(" }): Promise<Record<string, unknown> | null>");
|
|
425
427
|
}
|
|
428
|
+
lines.push(" create(args: {");
|
|
429
|
+
lines.push(" data: Record<string, unknown>");
|
|
430
|
+
lines.push(` select: { ${selectType} }`);
|
|
431
|
+
lines.push(" }): Promise<{");
|
|
432
|
+
for (const field of model.fields) {
|
|
433
|
+
const tsType = graphqlTypeToTsInterfaceType(
|
|
434
|
+
field.graphqlType,
|
|
435
|
+
field.isRequired
|
|
436
|
+
);
|
|
437
|
+
lines.push(` ${field.name}: ${tsType}`);
|
|
438
|
+
}
|
|
439
|
+
lines.push(" }>");
|
|
440
|
+
if (model.idField) {
|
|
441
|
+
const idTsType = graphqlTypeToTsType(model.idField.graphqlType);
|
|
442
|
+
lines.push(" update(args: {");
|
|
443
|
+
lines.push(` where: { ${model.idField.name}: ${idTsType} }`);
|
|
444
|
+
lines.push(" data: Record<string, unknown>");
|
|
445
|
+
lines.push(` select: { ${selectType} }`);
|
|
446
|
+
lines.push(" }): Promise<{");
|
|
447
|
+
for (const field of model.fields) {
|
|
448
|
+
const tsType = graphqlTypeToTsInterfaceType(
|
|
449
|
+
field.graphqlType,
|
|
450
|
+
field.isRequired
|
|
451
|
+
);
|
|
452
|
+
lines.push(` ${field.name}: ${tsType}`);
|
|
453
|
+
}
|
|
454
|
+
lines.push(" }>");
|
|
455
|
+
lines.push(" delete(args: {");
|
|
456
|
+
lines.push(` where: { ${model.idField.name}: ${idTsType} }`);
|
|
457
|
+
lines.push(` select: { ${selectType} }`);
|
|
458
|
+
lines.push(" }): Promise<{");
|
|
459
|
+
for (const field of model.fields) {
|
|
460
|
+
const tsType = graphqlTypeToTsInterfaceType(
|
|
461
|
+
field.graphqlType,
|
|
462
|
+
field.isRequired
|
|
463
|
+
);
|
|
464
|
+
lines.push(` ${field.name}: ${tsType}`);
|
|
465
|
+
}
|
|
466
|
+
lines.push(" }>");
|
|
467
|
+
}
|
|
426
468
|
lines.push(" }");
|
|
427
469
|
}
|
|
428
470
|
const membershipAlreadyInModels = models.some(
|
|
@@ -454,6 +496,26 @@ function generateGqlormBackendContent(models, config = DEFAULT_GQLORM_BACKEND_CO
|
|
|
454
496
|
}
|
|
455
497
|
lines.push(" }");
|
|
456
498
|
lines.push("");
|
|
499
|
+
if (!model.idField) {
|
|
500
|
+
continue;
|
|
501
|
+
}
|
|
502
|
+
const writableFields = model.fields.filter(
|
|
503
|
+
(field) => !field.isId && !field.isUpdatedAt && field.name !== config.membershipUserField
|
|
504
|
+
);
|
|
505
|
+
lines.push(` input Create${model.modelName}Input {`);
|
|
506
|
+
for (const field of writableFields) {
|
|
507
|
+
const isClientRequired = field.isRequired && !field.hasDefaultValue;
|
|
508
|
+
const nullMark = isClientRequired ? "!" : "";
|
|
509
|
+
lines.push(` ${field.name}: ${field.graphqlType}${nullMark}`);
|
|
510
|
+
}
|
|
511
|
+
lines.push(" }");
|
|
512
|
+
lines.push("");
|
|
513
|
+
lines.push(` input Update${model.modelName}Input {`);
|
|
514
|
+
for (const field of writableFields) {
|
|
515
|
+
lines.push(` ${field.name}: ${field.graphqlType}`);
|
|
516
|
+
}
|
|
517
|
+
lines.push(" }");
|
|
518
|
+
lines.push("");
|
|
457
519
|
}
|
|
458
520
|
lines.push(" type Query {");
|
|
459
521
|
for (const model of models) {
|
|
@@ -477,6 +539,32 @@ function generateGqlormBackendContent(models, config = DEFAULT_GQLORM_BACKEND_CO
|
|
|
477
539
|
}
|
|
478
540
|
}
|
|
479
541
|
lines.push(" }");
|
|
542
|
+
lines.push("");
|
|
543
|
+
lines.push(" type Mutation {");
|
|
544
|
+
for (const model of models) {
|
|
545
|
+
if (model.idField) {
|
|
546
|
+
const hasUserField = model.fields.some(
|
|
547
|
+
(f) => f.name === config.membershipUserField
|
|
548
|
+
);
|
|
549
|
+
const hasOrgField = model.fields.some(
|
|
550
|
+
(f) => f.name === config.membershipOrganizationField
|
|
551
|
+
);
|
|
552
|
+
const isMembershipModel = model.camelName === config.membershipModelCamel;
|
|
553
|
+
const needsAuth = hasUserField || hasOrgField && config.membershipModelExists && !isMembershipModel;
|
|
554
|
+
const authDirective = needsAuth ? "@requireAuth" : "@skipAuth";
|
|
555
|
+
const idNullMark = model.idField.isRequired ? "!" : "";
|
|
556
|
+
lines.push(
|
|
557
|
+
` create${model.modelName}(input: Create${model.modelName}Input!): ${model.modelName}! ${authDirective}`
|
|
558
|
+
);
|
|
559
|
+
lines.push(
|
|
560
|
+
` update${model.modelName}(${model.idField.name}: ${model.idField.graphqlType}${idNullMark}, input: Update${model.modelName}Input!): ${model.modelName}! ${authDirective}`
|
|
561
|
+
);
|
|
562
|
+
lines.push(
|
|
563
|
+
` delete${model.modelName}(${model.idField.name}: ${model.idField.graphqlType}${idNullMark}): ${model.modelName}! ${authDirective}`
|
|
564
|
+
);
|
|
565
|
+
}
|
|
566
|
+
}
|
|
567
|
+
lines.push(" }");
|
|
480
568
|
lines.push("`");
|
|
481
569
|
lines.push("");
|
|
482
570
|
lines.push(
|
|
@@ -625,6 +713,242 @@ function generateGqlormBackendContent(models, config = DEFAULT_GQLORM_BACKEND_CO
|
|
|
625
713
|
}
|
|
626
714
|
}
|
|
627
715
|
lines.push(" },");
|
|
716
|
+
lines.push(" Mutation: {");
|
|
717
|
+
for (const model of models) {
|
|
718
|
+
if (!model.idField) {
|
|
719
|
+
continue;
|
|
720
|
+
}
|
|
721
|
+
const selectObj = model.fields.map((f) => `${f.name}: true`).join(", ");
|
|
722
|
+
const hasUserField = model.fields.some(
|
|
723
|
+
(f) => f.name === config.membershipUserField
|
|
724
|
+
);
|
|
725
|
+
const hasOrgField = model.fields.some(
|
|
726
|
+
(f) => f.name === config.membershipOrganizationField
|
|
727
|
+
);
|
|
728
|
+
const isMembershipModel = model.camelName === config.membershipModelCamel;
|
|
729
|
+
const useOrgScoping = hasOrgField && config.membershipModelExists && !isMembershipModel;
|
|
730
|
+
const idFieldName = model.idField.name;
|
|
731
|
+
const idTsType = graphqlTypeToTsType(model.idField.graphqlType);
|
|
732
|
+
lines.push(
|
|
733
|
+
` create${model.modelName}: async (_root: unknown, { input }: { input: Record<string, unknown> }, ${hasUserField || useOrgScoping ? "context" : "_context"}: GqlormContext) => {`
|
|
734
|
+
);
|
|
735
|
+
if (hasUserField || useOrgScoping) {
|
|
736
|
+
lines.push(" if (!context.currentUser) {");
|
|
737
|
+
lines.push(
|
|
738
|
+
` throw new AuthenticationError("You don't have permission to do that.")`
|
|
739
|
+
);
|
|
740
|
+
lines.push(" }");
|
|
741
|
+
lines.push(" const currentUserId = context.currentUser['id']");
|
|
742
|
+
lines.push(
|
|
743
|
+
" if (currentUserId === undefined || currentUserId === null) {"
|
|
744
|
+
);
|
|
745
|
+
lines.push(
|
|
746
|
+
` throw new AuthenticationError("Could not determine the current user's ID.")`
|
|
747
|
+
);
|
|
748
|
+
lines.push(" }");
|
|
749
|
+
}
|
|
750
|
+
lines.push(" const data: Record<string, unknown> = { ...input }");
|
|
751
|
+
if (hasUserField) {
|
|
752
|
+
lines.push(
|
|
753
|
+
` data['${config.membershipUserField}'] = currentUserId`
|
|
754
|
+
);
|
|
755
|
+
}
|
|
756
|
+
if (useOrgScoping) {
|
|
757
|
+
lines.push(
|
|
758
|
+
` const organizationId = data['${config.membershipOrganizationField}']`
|
|
759
|
+
);
|
|
760
|
+
lines.push(
|
|
761
|
+
" if (organizationId === undefined || organizationId === null) {"
|
|
762
|
+
);
|
|
763
|
+
lines.push(
|
|
764
|
+
` throw new ForbiddenError('Organization membership is required for this operation')`
|
|
765
|
+
);
|
|
766
|
+
lines.push(" }");
|
|
767
|
+
lines.push(
|
|
768
|
+
` const membership = await db.${config.membershipModelCamel}.findFirst({`
|
|
769
|
+
);
|
|
770
|
+
lines.push(" where: {");
|
|
771
|
+
lines.push(` ${config.membershipUserField}: currentUserId,`);
|
|
772
|
+
lines.push(
|
|
773
|
+
` ${config.membershipOrganizationField}: organizationId,`
|
|
774
|
+
);
|
|
775
|
+
lines.push(" },");
|
|
776
|
+
lines.push(" })");
|
|
777
|
+
lines.push(" if (!membership) {");
|
|
778
|
+
lines.push(
|
|
779
|
+
` throw new ForbiddenError('Not authorized to access this resource')`
|
|
780
|
+
);
|
|
781
|
+
lines.push(" }");
|
|
782
|
+
}
|
|
783
|
+
lines.push(` return db.${model.camelName}.create({`);
|
|
784
|
+
lines.push(" data,");
|
|
785
|
+
lines.push(` select: { ${selectObj} },`);
|
|
786
|
+
lines.push(" })");
|
|
787
|
+
lines.push(" },");
|
|
788
|
+
lines.push(
|
|
789
|
+
` update${model.modelName}: async (_root: unknown, { ${idFieldName}, input }: { ${idFieldName}: ${idTsType}; input: Record<string, unknown> }, ${hasUserField || useOrgScoping ? "context" : "_context"}: GqlormContext) => {`
|
|
790
|
+
);
|
|
791
|
+
if (hasUserField || useOrgScoping) {
|
|
792
|
+
lines.push(" if (!context.currentUser) {");
|
|
793
|
+
lines.push(
|
|
794
|
+
` throw new AuthenticationError("You don't have permission to do that.")`
|
|
795
|
+
);
|
|
796
|
+
lines.push(" }");
|
|
797
|
+
lines.push(" const currentUserId = context.currentUser['id']");
|
|
798
|
+
lines.push(
|
|
799
|
+
" if (currentUserId === undefined || currentUserId === null) {"
|
|
800
|
+
);
|
|
801
|
+
lines.push(
|
|
802
|
+
` throw new AuthenticationError("Could not determine the current user's ID.")`
|
|
803
|
+
);
|
|
804
|
+
lines.push(" }");
|
|
805
|
+
lines.push(
|
|
806
|
+
` const existingRecord = await db.${model.camelName}.findUnique({`
|
|
807
|
+
);
|
|
808
|
+
lines.push(` where: { ${idFieldName} },`);
|
|
809
|
+
lines.push(` select: { ${selectObj} },`);
|
|
810
|
+
lines.push(" })");
|
|
811
|
+
lines.push(" if (!existingRecord) {");
|
|
812
|
+
lines.push(
|
|
813
|
+
` throw new ForbiddenError('Not authorized to access this resource')`
|
|
814
|
+
);
|
|
815
|
+
lines.push(" }");
|
|
816
|
+
lines.push(" const data: Record<string, unknown> = { ...input }");
|
|
817
|
+
if (hasUserField) {
|
|
818
|
+
lines.push(
|
|
819
|
+
` if (existingRecord.${config.membershipUserField} !== currentUserId) {`
|
|
820
|
+
);
|
|
821
|
+
lines.push(
|
|
822
|
+
` throw new ForbiddenError('Not authorized to access this resource')`
|
|
823
|
+
);
|
|
824
|
+
lines.push(" }");
|
|
825
|
+
lines.push(` delete data['${config.membershipUserField}']`);
|
|
826
|
+
}
|
|
827
|
+
if (useOrgScoping) {
|
|
828
|
+
lines.push(
|
|
829
|
+
` const currentOrganizationId = existingRecord.${config.membershipOrganizationField}`
|
|
830
|
+
);
|
|
831
|
+
lines.push(
|
|
832
|
+
` const currentOrganizationMembership = await db.${config.membershipModelCamel}.findFirst({`
|
|
833
|
+
);
|
|
834
|
+
lines.push(" where: {");
|
|
835
|
+
lines.push(` ${config.membershipUserField}: currentUserId,`);
|
|
836
|
+
lines.push(
|
|
837
|
+
` ${config.membershipOrganizationField}: currentOrganizationId,`
|
|
838
|
+
);
|
|
839
|
+
lines.push(" },");
|
|
840
|
+
lines.push(" })");
|
|
841
|
+
lines.push(" if (!currentOrganizationMembership) {");
|
|
842
|
+
lines.push(
|
|
843
|
+
` throw new ForbiddenError('Not authorized to access this resource')`
|
|
844
|
+
);
|
|
845
|
+
lines.push(" }");
|
|
846
|
+
lines.push(
|
|
847
|
+
` const requestedOrganizationId = input['${config.membershipOrganizationField}'] ?? currentOrganizationId`
|
|
848
|
+
);
|
|
849
|
+
lines.push(
|
|
850
|
+
` const requestedOrganizationMembership = await db.${config.membershipModelCamel}.findFirst({`
|
|
851
|
+
);
|
|
852
|
+
lines.push(" where: {");
|
|
853
|
+
lines.push(` ${config.membershipUserField}: currentUserId,`);
|
|
854
|
+
lines.push(
|
|
855
|
+
` ${config.membershipOrganizationField}: requestedOrganizationId,`
|
|
856
|
+
);
|
|
857
|
+
lines.push(" },");
|
|
858
|
+
lines.push(" })");
|
|
859
|
+
lines.push(" if (!requestedOrganizationMembership) {");
|
|
860
|
+
lines.push(
|
|
861
|
+
` throw new ForbiddenError('Not authorized to access this resource')`
|
|
862
|
+
);
|
|
863
|
+
lines.push(" }");
|
|
864
|
+
}
|
|
865
|
+
}
|
|
866
|
+
if (!(hasUserField || useOrgScoping)) {
|
|
867
|
+
lines.push(
|
|
868
|
+
` const existingRecord = await db.${model.camelName}.findUnique({`
|
|
869
|
+
);
|
|
870
|
+
lines.push(` where: { ${idFieldName} },`);
|
|
871
|
+
lines.push(` select: { ${selectObj} },`);
|
|
872
|
+
lines.push(" })");
|
|
873
|
+
lines.push(" if (!existingRecord) {");
|
|
874
|
+
lines.push(
|
|
875
|
+
` throw new ForbiddenError('Not authorized to access this resource')`
|
|
876
|
+
);
|
|
877
|
+
lines.push(" }");
|
|
878
|
+
lines.push(" const data: Record<string, unknown> = { ...input }");
|
|
879
|
+
}
|
|
880
|
+
lines.push(` return db.${model.camelName}.update({`);
|
|
881
|
+
lines.push(` where: { ${idFieldName} },`);
|
|
882
|
+
lines.push(" data,");
|
|
883
|
+
lines.push(` select: { ${selectObj} },`);
|
|
884
|
+
lines.push(" })");
|
|
885
|
+
lines.push(" },");
|
|
886
|
+
lines.push(
|
|
887
|
+
` delete${model.modelName}: async (_root: unknown, { ${idFieldName} }: { ${idFieldName}: ${idTsType} }, ${hasUserField || useOrgScoping ? "context" : "_context"}: GqlormContext) => {`
|
|
888
|
+
);
|
|
889
|
+
lines.push(
|
|
890
|
+
` const existingRecord = await db.${model.camelName}.findUnique({`
|
|
891
|
+
);
|
|
892
|
+
lines.push(` where: { ${idFieldName} },`);
|
|
893
|
+
lines.push(` select: { ${selectObj} },`);
|
|
894
|
+
lines.push(" })");
|
|
895
|
+
lines.push(" if (!existingRecord) {");
|
|
896
|
+
lines.push(
|
|
897
|
+
` throw new ForbiddenError('Not authorized to access this resource')`
|
|
898
|
+
);
|
|
899
|
+
lines.push(" }");
|
|
900
|
+
if (hasUserField || useOrgScoping) {
|
|
901
|
+
lines.push(" if (!context.currentUser) {");
|
|
902
|
+
lines.push(
|
|
903
|
+
` throw new AuthenticationError("You don't have permission to do that.")`
|
|
904
|
+
);
|
|
905
|
+
lines.push(" }");
|
|
906
|
+
lines.push(" const currentUserId = context.currentUser['id']");
|
|
907
|
+
lines.push(
|
|
908
|
+
" if (currentUserId === undefined || currentUserId === null) {"
|
|
909
|
+
);
|
|
910
|
+
lines.push(
|
|
911
|
+
` throw new AuthenticationError("Could not determine the current user's ID.")`
|
|
912
|
+
);
|
|
913
|
+
lines.push(" }");
|
|
914
|
+
if (hasUserField) {
|
|
915
|
+
lines.push(
|
|
916
|
+
` if (existingRecord.${config.membershipUserField} !== currentUserId) {`
|
|
917
|
+
);
|
|
918
|
+
lines.push(
|
|
919
|
+
` throw new ForbiddenError('Not authorized to access this resource')`
|
|
920
|
+
);
|
|
921
|
+
lines.push(" }");
|
|
922
|
+
}
|
|
923
|
+
if (useOrgScoping) {
|
|
924
|
+
lines.push(
|
|
925
|
+
` const membership = await db.${config.membershipModelCamel}.findFirst({`
|
|
926
|
+
);
|
|
927
|
+
lines.push(" where: {");
|
|
928
|
+
lines.push(` ${config.membershipUserField}: currentUserId,`);
|
|
929
|
+
lines.push(
|
|
930
|
+
` ${config.membershipOrganizationField}: existingRecord.${config.membershipOrganizationField},`
|
|
931
|
+
);
|
|
932
|
+
lines.push(" },");
|
|
933
|
+
lines.push(" })");
|
|
934
|
+
lines.push(" if (!membership) {");
|
|
935
|
+
lines.push(
|
|
936
|
+
` throw new ForbiddenError('Not authorized to access this resource')`
|
|
937
|
+
);
|
|
938
|
+
lines.push(" }");
|
|
939
|
+
}
|
|
940
|
+
}
|
|
941
|
+
lines.push(` return db.${model.camelName}.delete({`);
|
|
942
|
+
lines.push(` where: { ${idFieldName} },`);
|
|
943
|
+
lines.push(` select: { ${selectObj} },`);
|
|
944
|
+
lines.push(" })");
|
|
945
|
+
lines.push(" },");
|
|
946
|
+
lines.push("");
|
|
947
|
+
}
|
|
948
|
+
while (lines[lines.length - 1] === "") {
|
|
949
|
+
lines.pop();
|
|
950
|
+
}
|
|
951
|
+
lines.push(" },");
|
|
628
952
|
lines.push(" }");
|
|
629
953
|
lines.push("}");
|
|
630
954
|
lines.push("");
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"visitor.d.ts","sourceRoot":"","sources":["../../../../../src/generate/plugins/rw-typescript-resolvers/visitor.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"visitor.d.ts","sourceRoot":"","sources":["../../../../../src/generate/plugins/rw-typescript-resolvers/visitor.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,+BAA+B,EAAE,MAAM,uCAAuC,CAAA;AAC5F,OAAO,EAAE,0BAA0B,EAAE,MAAM,uCAAuC,CAAA;AAElF,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,wCAAwC,CAAA;AACnF,OAAO,KAAK,EACV,mBAAmB,EACnB,aAAa,EACb,wBAAwB,EACzB,MAAM,SAAS,CAAA;AAEhB,qBAAa,4BAA6B,SAAQ,0BAA0B;gBAExE,YAAY,EAAE,+BAA+B,EAC7C,MAAM,EAAE,aAAa;IAMvB,eAAe,CACb,IAAI,EAAE,mBAAmB,EACzB,GAAG,EAAE,MAAM,GAAG,MAAM,EACpB,MAAM,EAAE,GAAG,GACV,qBAAqB;IAgCxB,oBAAoB,CAAC,IAAI,EAAE,wBAAwB,GAAG,MAAM,GAAG,IAAI;CA6FpE"}
|
|
@@ -320,9 +320,9 @@ const generateTypeDefGlobalContext = () => {
|
|
|
320
320
|
};
|
|
321
321
|
const generateViteClientTypesDirective = () => {
|
|
322
322
|
const viteClientDirective = `/// <reference types="vite/client" />`;
|
|
323
|
-
const
|
|
323
|
+
const cedarProjectPaths = (0, import_project_config.getPaths)();
|
|
324
324
|
const viteClientDirectivePath = import_path.default.join(
|
|
325
|
-
|
|
325
|
+
cedarProjectPaths.generated.types.includes,
|
|
326
326
|
"web-vite-client.d.ts"
|
|
327
327
|
);
|
|
328
328
|
import_node_fs.default.writeFileSync(viteClientDirectivePath, viteClientDirective);
|
|
@@ -334,12 +334,9 @@ function generateStubStorybookTypes() {
|
|
|
334
334
|
export type StoryObj<T = any> = any
|
|
335
335
|
}
|
|
336
336
|
`;
|
|
337
|
-
const
|
|
337
|
+
const cedarProjectPaths = (0, import_project_config.getPaths)();
|
|
338
338
|
const packageJson = JSON.parse(
|
|
339
|
-
import_node_fs.default.readFileSync(
|
|
340
|
-
import_path.default.join(redwoodProjectPaths.base, "package.json"),
|
|
341
|
-
"utf-8"
|
|
342
|
-
)
|
|
339
|
+
import_node_fs.default.readFileSync(import_path.default.join(cedarProjectPaths.base, "package.json"), "utf-8")
|
|
343
340
|
);
|
|
344
341
|
const hasCliStorybookVite = Object.keys(
|
|
345
342
|
packageJson["devDependencies"]
|
|
@@ -348,7 +345,7 @@ function generateStubStorybookTypes() {
|
|
|
348
345
|
return [];
|
|
349
346
|
}
|
|
350
347
|
const stubStorybookTypesFilePath = import_path.default.join(
|
|
351
|
-
|
|
348
|
+
cedarProjectPaths.generated.types.includes,
|
|
352
349
|
"web-storybook.d.ts"
|
|
353
350
|
);
|
|
354
351
|
import_node_fs.default.writeFileSync(stubStorybookTypesFilePath, stubStorybookTypesFileContent);
|
|
@@ -79,11 +79,11 @@ function validateSchema(schemaDocumentNode, typesToCheck = ["Query", "Mutation"]
|
|
|
79
79
|
for (const field of typeNode.fields || []) {
|
|
80
80
|
const fieldName = field.name.value;
|
|
81
81
|
const fieldTypeName = typeNode.name.value;
|
|
82
|
-
const
|
|
82
|
+
const isLegacyRedwoodQuery = fieldName === "redwood" && fieldTypeName === "Query";
|
|
83
83
|
const isCedarQuery = fieldName === "cedar" && fieldTypeName === "Query" || // TODO: Remove this when I remove the root schema
|
|
84
84
|
fieldName === "cedarjs" && fieldTypeName === "Query";
|
|
85
85
|
const isCurrentUserQuery = fieldName === "currentUser" && fieldTypeName === "Query";
|
|
86
|
-
if (!(
|
|
86
|
+
if (!(isCedarQuery || isCurrentUserQuery || isLegacyRedwoodQuery)) {
|
|
87
87
|
const hasDirective = field.directives?.length;
|
|
88
88
|
if (!hasDirective) {
|
|
89
89
|
validationOutput.push(`${fieldName} ${fieldTypeName}`);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"gqlormSchema.d.ts","sourceRoot":"","sources":["../../src/generate/gqlormSchema.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,KAAK,IAAI,MAAM,cAAc,CAAA;AA8BzC,KAAK,WAAW,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,EAAE,CAAC,CAAA;AAE3C,UAAU,iBAAiB;IACzB,IAAI,EAAE,MAAM,CAAA;IACZ,MAAM,EAAE,MAAM,CAAA;CACf;AAED,UAAU,iBAAiB;IACzB,SAAS,EAAE,MAAM,CAAA;IACjB,SAAS,EAAE,MAAM,CAAA;IACjB,MAAM,EAAE,iBAAiB,EAAE,CAAA;CAC5B;AAMD,MAAM,WAAW,gBAAgB;IAC/B,IAAI,EAAE,MAAM,CAAA;IACZ,WAAW,EAAE,MAAM,CAAA;IACnB,UAAU,EAAE,OAAO,CAAA;IACnB,IAAI,EAAE,OAAO,CAAA;
|
|
1
|
+
{"version":3,"file":"gqlormSchema.d.ts","sourceRoot":"","sources":["../../src/generate/gqlormSchema.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,KAAK,IAAI,MAAM,cAAc,CAAA;AA8BzC,KAAK,WAAW,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,EAAE,CAAC,CAAA;AAE3C,UAAU,iBAAiB;IACzB,IAAI,EAAE,MAAM,CAAA;IACZ,MAAM,EAAE,MAAM,CAAA;CACf;AAED,UAAU,iBAAiB;IACzB,SAAS,EAAE,MAAM,CAAA;IACjB,SAAS,EAAE,MAAM,CAAA;IACjB,MAAM,EAAE,iBAAiB,EAAE,CAAA;CAC5B;AAMD,MAAM,WAAW,gBAAgB;IAC/B,IAAI,EAAE,MAAM,CAAA;IACZ,WAAW,EAAE,MAAM,CAAA;IACnB,UAAU,EAAE,OAAO,CAAA;IACnB,IAAI,EAAE,OAAO,CAAA;IACb,eAAe,EAAE,OAAO,CAAA;IACxB,WAAW,EAAE,OAAO,CAAA;CACrB;AAED,MAAM,WAAW,gBAAgB;IAC/B,SAAS,EAAE,MAAM,CAAA;IACjB,SAAS,EAAE,MAAM,CAAA;IACjB,UAAU,EAAE,MAAM,CAAA;IAClB,MAAM,EAAE,gBAAgB,EAAE,CAAA;IAC1B,OAAO,EAAE,gBAAgB,GAAG,SAAS,CAAA;CACtC;AAED,MAAM,WAAW,mBAAmB;IAClC,eAAe,EAAE,MAAM,CAAA;IACvB,oBAAoB,EAAE,MAAM,CAAA;IAC5B,mBAAmB,EAAE,MAAM,CAAA;IAC3B,2BAA2B,EAAE,MAAM,CAAA;IACnC,qBAAqB,EAAE,OAAO,CAAA;CAC/B;AA6DD;;;;;GAKG;AACH,wBAAgB,oBAAoB,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,MAAM,CAMvE;AAoGD,wBAAgB,sBAAsB,CACpC,IAAI,EAAE,IAAI,CAAC,QAAQ,GAClB,iBAAiB,EAAE,CAiDrB;AAED,wBAAgB,8BAA8B,CAC5C,MAAM,EAAE,iBAAiB,EAAE,GAC1B,MAAM,CA2CR;AAED;;;;;GAKG;AACH,wBAAgB,gBAAgB,CAAC,IAAI,EAAE,IAAI,CAAC,QAAQ,GAAG,WAAW,CAkDjE;AAMD;;;;;;;;;;;;GAYG;AACH,wBAAgB,qBAAqB,CAAC,IAAI,EAAE,IAAI,CAAC,QAAQ,GAAG,gBAAgB,EAAE,CA6D7E;AAkBD;;;;;;GAMG;AACH,wBAAgB,uBAAuB,CAAC,UAAU,EAAE,MAAM,GAAG,GAAG,CAAC,MAAM,CAAC,CA6BvE;AAED;;;;;;;;;;;;;;;GAeG;AACH,wBAAgB,4BAA4B,CAC1C,MAAM,EAAE,gBAAgB,EAAE,EAC1B,MAAM,GAAE,mBAAmD,GAC1D,MAAM,CA+rBR;AAMD;;;;;;;;;;;;;;;GAeG;AACH,wBAAsB,uBAAuB,IAAI,OAAO,CAAC;IACvD,KAAK,EAAE,MAAM,EAAE,CAAA;IACf,MAAM,EAAE;QAAE,OAAO,EAAE,MAAM,CAAC;QAAC,KAAK,EAAE,OAAO,CAAA;KAAE,EAAE,CAAA;CAC9C,CAAC,CAkID"}
|