@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
|
@@ -268,7 +268,9 @@ function buildBackendModelInfo(dmmf) {
|
|
|
268
268
|
name: field.name,
|
|
269
269
|
graphqlType: mapDmmfTypeToGraphql(field.type, field.kind),
|
|
270
270
|
isRequired: field.isRequired,
|
|
271
|
-
isId: field.isId
|
|
271
|
+
isId: field.isId,
|
|
272
|
+
hasDefaultValue: field.hasDefaultValue,
|
|
273
|
+
isUpdatedAt: field.isUpdatedAt ?? false
|
|
272
274
|
});
|
|
273
275
|
}
|
|
274
276
|
if (fields.length > 0) {
|
|
@@ -383,6 +385,46 @@ function generateGqlormBackendContent(models, config = DEFAULT_GQLORM_BACKEND_CO
|
|
|
383
385
|
lines.push(" where: Record<string, unknown>");
|
|
384
386
|
lines.push(" }): Promise<Record<string, unknown> | null>");
|
|
385
387
|
}
|
|
388
|
+
lines.push(" create(args: {");
|
|
389
|
+
lines.push(" data: Record<string, unknown>");
|
|
390
|
+
lines.push(` select: { ${selectType} }`);
|
|
391
|
+
lines.push(" }): Promise<{");
|
|
392
|
+
for (const field of model.fields) {
|
|
393
|
+
const tsType = graphqlTypeToTsInterfaceType(
|
|
394
|
+
field.graphqlType,
|
|
395
|
+
field.isRequired
|
|
396
|
+
);
|
|
397
|
+
lines.push(` ${field.name}: ${tsType}`);
|
|
398
|
+
}
|
|
399
|
+
lines.push(" }>");
|
|
400
|
+
if (model.idField) {
|
|
401
|
+
const idTsType = graphqlTypeToTsType(model.idField.graphqlType);
|
|
402
|
+
lines.push(" update(args: {");
|
|
403
|
+
lines.push(` where: { ${model.idField.name}: ${idTsType} }`);
|
|
404
|
+
lines.push(" data: Record<string, unknown>");
|
|
405
|
+
lines.push(` select: { ${selectType} }`);
|
|
406
|
+
lines.push(" }): Promise<{");
|
|
407
|
+
for (const field of model.fields) {
|
|
408
|
+
const tsType = graphqlTypeToTsInterfaceType(
|
|
409
|
+
field.graphqlType,
|
|
410
|
+
field.isRequired
|
|
411
|
+
);
|
|
412
|
+
lines.push(` ${field.name}: ${tsType}`);
|
|
413
|
+
}
|
|
414
|
+
lines.push(" }>");
|
|
415
|
+
lines.push(" delete(args: {");
|
|
416
|
+
lines.push(` where: { ${model.idField.name}: ${idTsType} }`);
|
|
417
|
+
lines.push(` select: { ${selectType} }`);
|
|
418
|
+
lines.push(" }): Promise<{");
|
|
419
|
+
for (const field of model.fields) {
|
|
420
|
+
const tsType = graphqlTypeToTsInterfaceType(
|
|
421
|
+
field.graphqlType,
|
|
422
|
+
field.isRequired
|
|
423
|
+
);
|
|
424
|
+
lines.push(` ${field.name}: ${tsType}`);
|
|
425
|
+
}
|
|
426
|
+
lines.push(" }>");
|
|
427
|
+
}
|
|
386
428
|
lines.push(" }");
|
|
387
429
|
}
|
|
388
430
|
const membershipAlreadyInModels = models.some(
|
|
@@ -414,6 +456,26 @@ function generateGqlormBackendContent(models, config = DEFAULT_GQLORM_BACKEND_CO
|
|
|
414
456
|
}
|
|
415
457
|
lines.push(" }");
|
|
416
458
|
lines.push("");
|
|
459
|
+
if (!model.idField) {
|
|
460
|
+
continue;
|
|
461
|
+
}
|
|
462
|
+
const writableFields = model.fields.filter(
|
|
463
|
+
(field) => !field.isId && !field.isUpdatedAt && field.name !== config.membershipUserField
|
|
464
|
+
);
|
|
465
|
+
lines.push(` input Create${model.modelName}Input {`);
|
|
466
|
+
for (const field of writableFields) {
|
|
467
|
+
const isClientRequired = field.isRequired && !field.hasDefaultValue;
|
|
468
|
+
const nullMark = isClientRequired ? "!" : "";
|
|
469
|
+
lines.push(` ${field.name}: ${field.graphqlType}${nullMark}`);
|
|
470
|
+
}
|
|
471
|
+
lines.push(" }");
|
|
472
|
+
lines.push("");
|
|
473
|
+
lines.push(` input Update${model.modelName}Input {`);
|
|
474
|
+
for (const field of writableFields) {
|
|
475
|
+
lines.push(` ${field.name}: ${field.graphqlType}`);
|
|
476
|
+
}
|
|
477
|
+
lines.push(" }");
|
|
478
|
+
lines.push("");
|
|
417
479
|
}
|
|
418
480
|
lines.push(" type Query {");
|
|
419
481
|
for (const model of models) {
|
|
@@ -437,6 +499,32 @@ function generateGqlormBackendContent(models, config = DEFAULT_GQLORM_BACKEND_CO
|
|
|
437
499
|
}
|
|
438
500
|
}
|
|
439
501
|
lines.push(" }");
|
|
502
|
+
lines.push("");
|
|
503
|
+
lines.push(" type Mutation {");
|
|
504
|
+
for (const model of models) {
|
|
505
|
+
if (model.idField) {
|
|
506
|
+
const hasUserField = model.fields.some(
|
|
507
|
+
(f) => f.name === config.membershipUserField
|
|
508
|
+
);
|
|
509
|
+
const hasOrgField = model.fields.some(
|
|
510
|
+
(f) => f.name === config.membershipOrganizationField
|
|
511
|
+
);
|
|
512
|
+
const isMembershipModel = model.camelName === config.membershipModelCamel;
|
|
513
|
+
const needsAuth = hasUserField || hasOrgField && config.membershipModelExists && !isMembershipModel;
|
|
514
|
+
const authDirective = needsAuth ? "@requireAuth" : "@skipAuth";
|
|
515
|
+
const idNullMark = model.idField.isRequired ? "!" : "";
|
|
516
|
+
lines.push(
|
|
517
|
+
` create${model.modelName}(input: Create${model.modelName}Input!): ${model.modelName}! ${authDirective}`
|
|
518
|
+
);
|
|
519
|
+
lines.push(
|
|
520
|
+
` update${model.modelName}(${model.idField.name}: ${model.idField.graphqlType}${idNullMark}, input: Update${model.modelName}Input!): ${model.modelName}! ${authDirective}`
|
|
521
|
+
);
|
|
522
|
+
lines.push(
|
|
523
|
+
` delete${model.modelName}(${model.idField.name}: ${model.idField.graphqlType}${idNullMark}): ${model.modelName}! ${authDirective}`
|
|
524
|
+
);
|
|
525
|
+
}
|
|
526
|
+
}
|
|
527
|
+
lines.push(" }");
|
|
440
528
|
lines.push("`");
|
|
441
529
|
lines.push("");
|
|
442
530
|
lines.push(
|
|
@@ -585,6 +673,242 @@ function generateGqlormBackendContent(models, config = DEFAULT_GQLORM_BACKEND_CO
|
|
|
585
673
|
}
|
|
586
674
|
}
|
|
587
675
|
lines.push(" },");
|
|
676
|
+
lines.push(" Mutation: {");
|
|
677
|
+
for (const model of models) {
|
|
678
|
+
if (!model.idField) {
|
|
679
|
+
continue;
|
|
680
|
+
}
|
|
681
|
+
const selectObj = model.fields.map((f) => `${f.name}: true`).join(", ");
|
|
682
|
+
const hasUserField = model.fields.some(
|
|
683
|
+
(f) => f.name === config.membershipUserField
|
|
684
|
+
);
|
|
685
|
+
const hasOrgField = model.fields.some(
|
|
686
|
+
(f) => f.name === config.membershipOrganizationField
|
|
687
|
+
);
|
|
688
|
+
const isMembershipModel = model.camelName === config.membershipModelCamel;
|
|
689
|
+
const useOrgScoping = hasOrgField && config.membershipModelExists && !isMembershipModel;
|
|
690
|
+
const idFieldName = model.idField.name;
|
|
691
|
+
const idTsType = graphqlTypeToTsType(model.idField.graphqlType);
|
|
692
|
+
lines.push(
|
|
693
|
+
` create${model.modelName}: async (_root: unknown, { input }: { input: Record<string, unknown> }, ${hasUserField || useOrgScoping ? "context" : "_context"}: GqlormContext) => {`
|
|
694
|
+
);
|
|
695
|
+
if (hasUserField || useOrgScoping) {
|
|
696
|
+
lines.push(" if (!context.currentUser) {");
|
|
697
|
+
lines.push(
|
|
698
|
+
` throw new AuthenticationError("You don't have permission to do that.")`
|
|
699
|
+
);
|
|
700
|
+
lines.push(" }");
|
|
701
|
+
lines.push(" const currentUserId = context.currentUser['id']");
|
|
702
|
+
lines.push(
|
|
703
|
+
" if (currentUserId === undefined || currentUserId === null) {"
|
|
704
|
+
);
|
|
705
|
+
lines.push(
|
|
706
|
+
` throw new AuthenticationError("Could not determine the current user's ID.")`
|
|
707
|
+
);
|
|
708
|
+
lines.push(" }");
|
|
709
|
+
}
|
|
710
|
+
lines.push(" const data: Record<string, unknown> = { ...input }");
|
|
711
|
+
if (hasUserField) {
|
|
712
|
+
lines.push(
|
|
713
|
+
` data['${config.membershipUserField}'] = currentUserId`
|
|
714
|
+
);
|
|
715
|
+
}
|
|
716
|
+
if (useOrgScoping) {
|
|
717
|
+
lines.push(
|
|
718
|
+
` const organizationId = data['${config.membershipOrganizationField}']`
|
|
719
|
+
);
|
|
720
|
+
lines.push(
|
|
721
|
+
" if (organizationId === undefined || organizationId === null) {"
|
|
722
|
+
);
|
|
723
|
+
lines.push(
|
|
724
|
+
` throw new ForbiddenError('Organization membership is required for this operation')`
|
|
725
|
+
);
|
|
726
|
+
lines.push(" }");
|
|
727
|
+
lines.push(
|
|
728
|
+
` const membership = await db.${config.membershipModelCamel}.findFirst({`
|
|
729
|
+
);
|
|
730
|
+
lines.push(" where: {");
|
|
731
|
+
lines.push(` ${config.membershipUserField}: currentUserId,`);
|
|
732
|
+
lines.push(
|
|
733
|
+
` ${config.membershipOrganizationField}: organizationId,`
|
|
734
|
+
);
|
|
735
|
+
lines.push(" },");
|
|
736
|
+
lines.push(" })");
|
|
737
|
+
lines.push(" if (!membership) {");
|
|
738
|
+
lines.push(
|
|
739
|
+
` throw new ForbiddenError('Not authorized to access this resource')`
|
|
740
|
+
);
|
|
741
|
+
lines.push(" }");
|
|
742
|
+
}
|
|
743
|
+
lines.push(` return db.${model.camelName}.create({`);
|
|
744
|
+
lines.push(" data,");
|
|
745
|
+
lines.push(` select: { ${selectObj} },`);
|
|
746
|
+
lines.push(" })");
|
|
747
|
+
lines.push(" },");
|
|
748
|
+
lines.push(
|
|
749
|
+
` update${model.modelName}: async (_root: unknown, { ${idFieldName}, input }: { ${idFieldName}: ${idTsType}; input: Record<string, unknown> }, ${hasUserField || useOrgScoping ? "context" : "_context"}: GqlormContext) => {`
|
|
750
|
+
);
|
|
751
|
+
if (hasUserField || useOrgScoping) {
|
|
752
|
+
lines.push(" if (!context.currentUser) {");
|
|
753
|
+
lines.push(
|
|
754
|
+
` throw new AuthenticationError("You don't have permission to do that.")`
|
|
755
|
+
);
|
|
756
|
+
lines.push(" }");
|
|
757
|
+
lines.push(" const currentUserId = context.currentUser['id']");
|
|
758
|
+
lines.push(
|
|
759
|
+
" if (currentUserId === undefined || currentUserId === null) {"
|
|
760
|
+
);
|
|
761
|
+
lines.push(
|
|
762
|
+
` throw new AuthenticationError("Could not determine the current user's ID.")`
|
|
763
|
+
);
|
|
764
|
+
lines.push(" }");
|
|
765
|
+
lines.push(
|
|
766
|
+
` const existingRecord = await db.${model.camelName}.findUnique({`
|
|
767
|
+
);
|
|
768
|
+
lines.push(` where: { ${idFieldName} },`);
|
|
769
|
+
lines.push(` select: { ${selectObj} },`);
|
|
770
|
+
lines.push(" })");
|
|
771
|
+
lines.push(" if (!existingRecord) {");
|
|
772
|
+
lines.push(
|
|
773
|
+
` throw new ForbiddenError('Not authorized to access this resource')`
|
|
774
|
+
);
|
|
775
|
+
lines.push(" }");
|
|
776
|
+
lines.push(" const data: Record<string, unknown> = { ...input }");
|
|
777
|
+
if (hasUserField) {
|
|
778
|
+
lines.push(
|
|
779
|
+
` if (existingRecord.${config.membershipUserField} !== currentUserId) {`
|
|
780
|
+
);
|
|
781
|
+
lines.push(
|
|
782
|
+
` throw new ForbiddenError('Not authorized to access this resource')`
|
|
783
|
+
);
|
|
784
|
+
lines.push(" }");
|
|
785
|
+
lines.push(` delete data['${config.membershipUserField}']`);
|
|
786
|
+
}
|
|
787
|
+
if (useOrgScoping) {
|
|
788
|
+
lines.push(
|
|
789
|
+
` const currentOrganizationId = existingRecord.${config.membershipOrganizationField}`
|
|
790
|
+
);
|
|
791
|
+
lines.push(
|
|
792
|
+
` const currentOrganizationMembership = await db.${config.membershipModelCamel}.findFirst({`
|
|
793
|
+
);
|
|
794
|
+
lines.push(" where: {");
|
|
795
|
+
lines.push(` ${config.membershipUserField}: currentUserId,`);
|
|
796
|
+
lines.push(
|
|
797
|
+
` ${config.membershipOrganizationField}: currentOrganizationId,`
|
|
798
|
+
);
|
|
799
|
+
lines.push(" },");
|
|
800
|
+
lines.push(" })");
|
|
801
|
+
lines.push(" if (!currentOrganizationMembership) {");
|
|
802
|
+
lines.push(
|
|
803
|
+
` throw new ForbiddenError('Not authorized to access this resource')`
|
|
804
|
+
);
|
|
805
|
+
lines.push(" }");
|
|
806
|
+
lines.push(
|
|
807
|
+
` const requestedOrganizationId = input['${config.membershipOrganizationField}'] ?? currentOrganizationId`
|
|
808
|
+
);
|
|
809
|
+
lines.push(
|
|
810
|
+
` const requestedOrganizationMembership = await db.${config.membershipModelCamel}.findFirst({`
|
|
811
|
+
);
|
|
812
|
+
lines.push(" where: {");
|
|
813
|
+
lines.push(` ${config.membershipUserField}: currentUserId,`);
|
|
814
|
+
lines.push(
|
|
815
|
+
` ${config.membershipOrganizationField}: requestedOrganizationId,`
|
|
816
|
+
);
|
|
817
|
+
lines.push(" },");
|
|
818
|
+
lines.push(" })");
|
|
819
|
+
lines.push(" if (!requestedOrganizationMembership) {");
|
|
820
|
+
lines.push(
|
|
821
|
+
` throw new ForbiddenError('Not authorized to access this resource')`
|
|
822
|
+
);
|
|
823
|
+
lines.push(" }");
|
|
824
|
+
}
|
|
825
|
+
}
|
|
826
|
+
if (!(hasUserField || useOrgScoping)) {
|
|
827
|
+
lines.push(
|
|
828
|
+
` const existingRecord = await db.${model.camelName}.findUnique({`
|
|
829
|
+
);
|
|
830
|
+
lines.push(` where: { ${idFieldName} },`);
|
|
831
|
+
lines.push(` select: { ${selectObj} },`);
|
|
832
|
+
lines.push(" })");
|
|
833
|
+
lines.push(" if (!existingRecord) {");
|
|
834
|
+
lines.push(
|
|
835
|
+
` throw new ForbiddenError('Not authorized to access this resource')`
|
|
836
|
+
);
|
|
837
|
+
lines.push(" }");
|
|
838
|
+
lines.push(" const data: Record<string, unknown> = { ...input }");
|
|
839
|
+
}
|
|
840
|
+
lines.push(` return db.${model.camelName}.update({`);
|
|
841
|
+
lines.push(` where: { ${idFieldName} },`);
|
|
842
|
+
lines.push(" data,");
|
|
843
|
+
lines.push(` select: { ${selectObj} },`);
|
|
844
|
+
lines.push(" })");
|
|
845
|
+
lines.push(" },");
|
|
846
|
+
lines.push(
|
|
847
|
+
` delete${model.modelName}: async (_root: unknown, { ${idFieldName} }: { ${idFieldName}: ${idTsType} }, ${hasUserField || useOrgScoping ? "context" : "_context"}: GqlormContext) => {`
|
|
848
|
+
);
|
|
849
|
+
lines.push(
|
|
850
|
+
` const existingRecord = await db.${model.camelName}.findUnique({`
|
|
851
|
+
);
|
|
852
|
+
lines.push(` where: { ${idFieldName} },`);
|
|
853
|
+
lines.push(` select: { ${selectObj} },`);
|
|
854
|
+
lines.push(" })");
|
|
855
|
+
lines.push(" if (!existingRecord) {");
|
|
856
|
+
lines.push(
|
|
857
|
+
` throw new ForbiddenError('Not authorized to access this resource')`
|
|
858
|
+
);
|
|
859
|
+
lines.push(" }");
|
|
860
|
+
if (hasUserField || useOrgScoping) {
|
|
861
|
+
lines.push(" if (!context.currentUser) {");
|
|
862
|
+
lines.push(
|
|
863
|
+
` throw new AuthenticationError("You don't have permission to do that.")`
|
|
864
|
+
);
|
|
865
|
+
lines.push(" }");
|
|
866
|
+
lines.push(" const currentUserId = context.currentUser['id']");
|
|
867
|
+
lines.push(
|
|
868
|
+
" if (currentUserId === undefined || currentUserId === null) {"
|
|
869
|
+
);
|
|
870
|
+
lines.push(
|
|
871
|
+
` throw new AuthenticationError("Could not determine the current user's ID.")`
|
|
872
|
+
);
|
|
873
|
+
lines.push(" }");
|
|
874
|
+
if (hasUserField) {
|
|
875
|
+
lines.push(
|
|
876
|
+
` if (existingRecord.${config.membershipUserField} !== currentUserId) {`
|
|
877
|
+
);
|
|
878
|
+
lines.push(
|
|
879
|
+
` throw new ForbiddenError('Not authorized to access this resource')`
|
|
880
|
+
);
|
|
881
|
+
lines.push(" }");
|
|
882
|
+
}
|
|
883
|
+
if (useOrgScoping) {
|
|
884
|
+
lines.push(
|
|
885
|
+
` const membership = await db.${config.membershipModelCamel}.findFirst({`
|
|
886
|
+
);
|
|
887
|
+
lines.push(" where: {");
|
|
888
|
+
lines.push(` ${config.membershipUserField}: currentUserId,`);
|
|
889
|
+
lines.push(
|
|
890
|
+
` ${config.membershipOrganizationField}: existingRecord.${config.membershipOrganizationField},`
|
|
891
|
+
);
|
|
892
|
+
lines.push(" },");
|
|
893
|
+
lines.push(" })");
|
|
894
|
+
lines.push(" if (!membership) {");
|
|
895
|
+
lines.push(
|
|
896
|
+
` throw new ForbiddenError('Not authorized to access this resource')`
|
|
897
|
+
);
|
|
898
|
+
lines.push(" }");
|
|
899
|
+
}
|
|
900
|
+
}
|
|
901
|
+
lines.push(` return db.${model.camelName}.delete({`);
|
|
902
|
+
lines.push(` where: { ${idFieldName} },`);
|
|
903
|
+
lines.push(` select: { ${selectObj} },`);
|
|
904
|
+
lines.push(" })");
|
|
905
|
+
lines.push(" },");
|
|
906
|
+
lines.push("");
|
|
907
|
+
}
|
|
908
|
+
while (lines[lines.length - 1] === "") {
|
|
909
|
+
lines.pop();
|
|
910
|
+
}
|
|
911
|
+
lines.push(" },");
|
|
588
912
|
lines.push(" }");
|
|
589
913
|
lines.push("}");
|
|
590
914
|
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"}
|
|
@@ -280,9 +280,9 @@ const generateTypeDefGlobalContext = () => {
|
|
|
280
280
|
};
|
|
281
281
|
const generateViteClientTypesDirective = () => {
|
|
282
282
|
const viteClientDirective = `/// <reference types="vite/client" />`;
|
|
283
|
-
const
|
|
283
|
+
const cedarProjectPaths = getPaths();
|
|
284
284
|
const viteClientDirectivePath = path.join(
|
|
285
|
-
|
|
285
|
+
cedarProjectPaths.generated.types.includes,
|
|
286
286
|
"web-vite-client.d.ts"
|
|
287
287
|
);
|
|
288
288
|
fs.writeFileSync(viteClientDirectivePath, viteClientDirective);
|
|
@@ -294,12 +294,9 @@ function generateStubStorybookTypes() {
|
|
|
294
294
|
export type StoryObj<T = any> = any
|
|
295
295
|
}
|
|
296
296
|
`;
|
|
297
|
-
const
|
|
297
|
+
const cedarProjectPaths = getPaths();
|
|
298
298
|
const packageJson = JSON.parse(
|
|
299
|
-
fs.readFileSync(
|
|
300
|
-
path.join(redwoodProjectPaths.base, "package.json"),
|
|
301
|
-
"utf-8"
|
|
302
|
-
)
|
|
299
|
+
fs.readFileSync(path.join(cedarProjectPaths.base, "package.json"), "utf-8")
|
|
303
300
|
);
|
|
304
301
|
const hasCliStorybookVite = Object.keys(
|
|
305
302
|
packageJson["devDependencies"]
|
|
@@ -308,7 +305,7 @@ function generateStubStorybookTypes() {
|
|
|
308
305
|
return [];
|
|
309
306
|
}
|
|
310
307
|
const stubStorybookTypesFilePath = path.join(
|
|
311
|
-
|
|
308
|
+
cedarProjectPaths.generated.types.includes,
|
|
312
309
|
"web-storybook.d.ts"
|
|
313
310
|
);
|
|
314
311
|
fs.writeFileSync(stubStorybookTypesFilePath, stubStorybookTypesFileContent);
|
package/dist/validateSchema.js
CHANGED
|
@@ -52,11 +52,11 @@ function validateSchema(schemaDocumentNode, typesToCheck = ["Query", "Mutation"]
|
|
|
52
52
|
for (const field of typeNode.fields || []) {
|
|
53
53
|
const fieldName = field.name.value;
|
|
54
54
|
const fieldTypeName = typeNode.name.value;
|
|
55
|
-
const
|
|
55
|
+
const isLegacyRedwoodQuery = fieldName === "redwood" && fieldTypeName === "Query";
|
|
56
56
|
const isCedarQuery = fieldName === "cedar" && fieldTypeName === "Query" || // TODO: Remove this when I remove the root schema
|
|
57
57
|
fieldName === "cedarjs" && fieldTypeName === "Query";
|
|
58
58
|
const isCurrentUserQuery = fieldName === "currentUser" && fieldTypeName === "Query";
|
|
59
|
-
if (!(
|
|
59
|
+
if (!(isCedarQuery || isCurrentUserQuery || isLegacyRedwoodQuery)) {
|
|
60
60
|
const hasDirective = field.directives?.length;
|
|
61
61
|
if (!hasDirective) {
|
|
62
62
|
validationOutput.push(`${fieldName} ${fieldTypeName}`);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cedarjs/internal",
|
|
3
|
-
"version": "4.2.1-next.
|
|
3
|
+
"version": "4.2.1-next.269",
|
|
4
4
|
"repository": {
|
|
5
5
|
"type": "git",
|
|
6
6
|
"url": "git+https://github.com/cedarjs/cedar.git",
|
|
@@ -140,13 +140,13 @@
|
|
|
140
140
|
"dist"
|
|
141
141
|
],
|
|
142
142
|
"scripts": {
|
|
143
|
-
"build": "
|
|
143
|
+
"build": "node ./build.mts",
|
|
144
144
|
"build:clean-dist": "rimraf 'dist/**/*/__tests__' --glob",
|
|
145
145
|
"build:pack": "yarn pack -o cedarjs-internal.tgz",
|
|
146
146
|
"build:types": "tsc --build --verbose ./tsconfig.build.json",
|
|
147
147
|
"build:types-cjs": "tsc --build --verbose ./tsconfig.cjs.json",
|
|
148
148
|
"build:watch": "nodemon --watch src --ext \"js,jsx,ts,tsx\" --ignore dist --exec \"yarn build\"",
|
|
149
|
-
"check:attw": "yarn attw
|
|
149
|
+
"check:attw": "yarn cedar-fwtools-attw",
|
|
150
150
|
"check:package": "concurrently npm:check:attw yarn:publint",
|
|
151
151
|
"fix:permissions": "chmod +x dist/generate/generate.js dist/generate/watch.js",
|
|
152
152
|
"prepublishOnly": "NODE_ENV=production yarn build",
|
|
@@ -155,10 +155,10 @@
|
|
|
155
155
|
},
|
|
156
156
|
"dependencies": {
|
|
157
157
|
"@babel/core": "^7.26.10",
|
|
158
|
-
"@babel/parser": "7.29.
|
|
159
|
-
"@babel/plugin-transform-react-jsx": "7.
|
|
158
|
+
"@babel/parser": "7.29.7",
|
|
159
|
+
"@babel/plugin-transform-react-jsx": "7.29.7",
|
|
160
160
|
"@babel/plugin-transform-typescript": "^7.26.8",
|
|
161
|
-
"@babel/traverse": "7.29.
|
|
161
|
+
"@babel/traverse": "7.29.7",
|
|
162
162
|
"@cedarjs/babel-config": "4.2.0",
|
|
163
163
|
"@cedarjs/cli-helpers": "4.2.0",
|
|
164
164
|
"@cedarjs/graphql-server": "4.2.0",
|
|
@@ -171,40 +171,46 @@
|
|
|
171
171
|
"@graphql-codegen/client-preset": "5.3.0",
|
|
172
172
|
"@graphql-codegen/core": "5.0.2",
|
|
173
173
|
"@graphql-codegen/fragment-matcher": "6.0.1",
|
|
174
|
+
"@graphql-codegen/plugin-helpers": "6.3.0",
|
|
174
175
|
"@graphql-codegen/schema-ast": "5.0.2",
|
|
175
176
|
"@graphql-codegen/typed-document-node": "6.1.8",
|
|
176
177
|
"@graphql-codegen/typescript": "5.0.10",
|
|
177
178
|
"@graphql-codegen/typescript-operations": "5.1.0",
|
|
178
179
|
"@graphql-codegen/typescript-react-apollo": "4.4.2",
|
|
179
180
|
"@graphql-codegen/typescript-resolvers": "5.1.8",
|
|
181
|
+
"@graphql-codegen/visitor-plugin-common": "6.3.0",
|
|
182
|
+
"@graphql-tools/code-file-loader": "8.1.29",
|
|
180
183
|
"@graphql-tools/documents": "1.0.1",
|
|
184
|
+
"@graphql-tools/graphql-file-loader": "8.1.12",
|
|
185
|
+
"@graphql-tools/load": "8.1.8",
|
|
186
|
+
"@graphql-tools/merge": "9.1.9",
|
|
181
187
|
"@prisma/dmmf": "7.8.0",
|
|
182
188
|
"@prisma/internals": "7.8.0",
|
|
183
189
|
"@sdl-codegen/node": "2.0.1",
|
|
184
190
|
"ansis": "4.2.0",
|
|
185
191
|
"deepmerge": "4.3.1",
|
|
186
192
|
"esbuild": "0.27.7",
|
|
193
|
+
"execa": "5.1.1",
|
|
187
194
|
"fast-glob": "3.3.3",
|
|
188
|
-
"graphql": "16.
|
|
195
|
+
"graphql": "16.14.2",
|
|
189
196
|
"kill-port": "1.6.1",
|
|
190
|
-
"prettier": "3.8.
|
|
197
|
+
"prettier": "3.8.4",
|
|
191
198
|
"rimraf": "6.1.3",
|
|
192
199
|
"source-map": "0.7.6",
|
|
193
200
|
"string-env-interpolation": "1.0.1",
|
|
194
|
-
"systeminformation": "5.31.
|
|
201
|
+
"systeminformation": "5.31.7",
|
|
195
202
|
"termi-link": "1.1.0",
|
|
196
203
|
"ts-node": "10.9.2",
|
|
197
204
|
"typescript": "5.9.3",
|
|
198
|
-
"vite": "7.3.
|
|
205
|
+
"vite": "7.3.5"
|
|
199
206
|
},
|
|
200
207
|
"devDependencies": {
|
|
201
|
-
"@arethetypeswrong/cli": "0.18.
|
|
208
|
+
"@arethetypeswrong/cli": "0.18.4",
|
|
202
209
|
"@cedarjs/framework-tools": "4.2.0",
|
|
203
210
|
"concurrently": "9.2.1",
|
|
204
211
|
"graphql-tag": "2.12.6",
|
|
205
|
-
"publint": "0.3.
|
|
206
|
-
"
|
|
207
|
-
"vitest": "3.2.4"
|
|
212
|
+
"publint": "0.3.21",
|
|
213
|
+
"vitest": "3.2.6"
|
|
208
214
|
},
|
|
209
215
|
"engines": {
|
|
210
216
|
"node": ">=24"
|