@sprucelabs/spruce-file-utils 16.2.0 → 17.0.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/build/.spruce/schemas/schemas.types.d.ts +155 -134
- package/build/esm/.spruce/schemas/schemas.types.d.ts +155 -134
- package/build/esm/uploading/FileUploader.d.ts +3 -3
- package/build/esm/uploading/FileUploader.js +10 -5
- package/build/esm/uploading/LocalUploadStrategy.d.ts +24 -1
- package/build/esm/uploading/LocalUploadStrategy.js +28 -3
- package/build/esm/uploading/S3UploadStrategy.d.ts +20 -0
- package/build/esm/uploading/S3UploadStrategy.js +22 -1
- package/build/uploading/FileUploader.d.ts +3 -3
- package/build/uploading/FileUploader.js +10 -5
- package/build/uploading/LocalUploadStrategy.d.ts +24 -1
- package/build/uploading/LocalUploadStrategy.js +25 -2
- package/build/uploading/S3UploadStrategy.d.ts +20 -0
- package/build/uploading/S3UploadStrategy.js +21 -0
- package/package.json +1 -1
@@ -719,45 +719,108 @@ declare module '@sprucelabs/spruce-core-schemas/build/.spruce/schemas/core.schem
|
|
719
719
|
}
|
720
720
|
}
|
721
721
|
namespace SpruceSchemas.Files.v2022_05_13 {
|
722
|
-
interface
|
723
|
-
|
722
|
+
interface GetUploadEndpointResponsePayload {
|
723
|
+
/** . The REST endpoint URL to user when uploading a file. If not set, you must use upload using the Mercury Client. */
|
724
|
+
'restEndpointUrl'?: string | undefined | null;
|
724
725
|
}
|
725
|
-
interface
|
726
|
-
id: '
|
726
|
+
interface GetUploadEndpointResponsePayloadSchema extends SpruceSchema.Schema {
|
727
|
+
id: 'getUploadEndpointResponsePayload';
|
727
728
|
version: 'v2022_05_13';
|
728
729
|
namespace: 'Files';
|
729
730
|
name: '';
|
730
731
|
fields: {
|
732
|
+
/** . The REST endpoint URL to user when uploading a file. If not set, you must use upload using the Mercury Client. */
|
733
|
+
'restEndpointUrl': {
|
734
|
+
type: 'text';
|
735
|
+
hint: 'The REST endpoint URL to user when uploading a file. If not set, you must use upload using the Mercury Client.';
|
736
|
+
options: undefined;
|
737
|
+
};
|
738
|
+
};
|
739
|
+
}
|
740
|
+
interface GetUploadEndpointResponsePayloadEntity extends SchemaEntity<SpruceSchemas.Files.v2022_05_13.GetUploadEndpointResponsePayloadSchema> {
|
741
|
+
}
|
742
|
+
}
|
743
|
+
namespace SpruceSchemas.Files.v2022_05_13 {
|
744
|
+
interface UploadEmitTarget {
|
745
|
+
'locationId'?: string | undefined | null;
|
746
|
+
'organizationId'?: string | undefined | null;
|
747
|
+
'filePersonId'?: string | undefined | null;
|
748
|
+
}
|
749
|
+
interface UploadEmitTargetSchema extends SpruceSchema.Schema {
|
750
|
+
id: 'uploadEmitTarget';
|
751
|
+
version: 'v2022_05_13';
|
752
|
+
namespace: 'Files';
|
753
|
+
name: '';
|
754
|
+
fields: {
|
755
|
+
/** . */
|
756
|
+
'locationId': {
|
757
|
+
type: 'id';
|
758
|
+
options: undefined;
|
759
|
+
};
|
731
760
|
/** . */
|
732
761
|
'organizationId': {
|
733
762
|
type: 'id';
|
734
|
-
|
763
|
+
options: undefined;
|
764
|
+
};
|
765
|
+
/** . */
|
766
|
+
'filePersonId': {
|
767
|
+
type: 'text';
|
735
768
|
options: undefined;
|
736
769
|
};
|
737
770
|
};
|
738
771
|
}
|
739
|
-
interface
|
772
|
+
interface UploadEmitTargetEntity extends SchemaEntity<SpruceSchemas.Files.v2022_05_13.UploadEmitTargetSchema> {
|
740
773
|
}
|
741
774
|
}
|
742
775
|
namespace SpruceSchemas.Files.v2022_05_13 {
|
743
|
-
interface
|
744
|
-
'
|
776
|
+
interface UploadEmitPayload {
|
777
|
+
'base64Body': string;
|
778
|
+
'name': string;
|
745
779
|
}
|
746
|
-
interface
|
747
|
-
id: '
|
780
|
+
interface UploadEmitPayloadSchema extends SpruceSchema.Schema {
|
781
|
+
id: 'uploadEmitPayload';
|
748
782
|
version: 'v2022_05_13';
|
749
783
|
namespace: 'Files';
|
750
784
|
name: '';
|
751
785
|
fields: {
|
752
786
|
/** . */
|
753
|
-
'
|
754
|
-
type: '
|
787
|
+
'base64Body': {
|
788
|
+
type: 'text';
|
789
|
+
isRequired: true;
|
790
|
+
options: undefined;
|
791
|
+
};
|
792
|
+
/** . */
|
793
|
+
'name': {
|
794
|
+
type: 'text';
|
755
795
|
isRequired: true;
|
756
796
|
options: undefined;
|
757
797
|
};
|
758
798
|
};
|
759
799
|
}
|
760
|
-
interface
|
800
|
+
interface UploadEmitPayloadEntity extends SchemaEntity<SpruceSchemas.Files.v2022_05_13.UploadEmitPayloadSchema> {
|
801
|
+
}
|
802
|
+
}
|
803
|
+
namespace SpruceSchemas.Files.v2022_05_13 {
|
804
|
+
interface UploadResponsePayload {
|
805
|
+
'file': SpruceSchemas.Files.v2022_05_13.UploadedFile;
|
806
|
+
}
|
807
|
+
interface UploadResponsePayloadSchema extends SpruceSchema.Schema {
|
808
|
+
id: 'uploadResponsePayload';
|
809
|
+
version: 'v2022_05_13';
|
810
|
+
namespace: 'Files';
|
811
|
+
name: '';
|
812
|
+
fields: {
|
813
|
+
/** . */
|
814
|
+
'file': {
|
815
|
+
type: 'schema';
|
816
|
+
isRequired: true;
|
817
|
+
options: {
|
818
|
+
schema: SpruceSchemas.Files.v2022_05_13.UploadedFileSchema;
|
819
|
+
};
|
820
|
+
};
|
821
|
+
};
|
822
|
+
}
|
823
|
+
interface UploadResponsePayloadEntity extends SchemaEntity<SpruceSchemas.Files.v2022_05_13.UploadResponsePayloadSchema> {
|
761
824
|
}
|
762
825
|
}
|
763
826
|
namespace SpruceSchemas.Files.v2022_05_13 {
|
@@ -783,9 +846,11 @@ declare module '@sprucelabs/spruce-core-schemas/build/.spruce/schemas/core.schem
|
|
783
846
|
}
|
784
847
|
namespace SpruceSchemas.Files.v2022_05_13 {
|
785
848
|
interface SaveSettingsEmitPayload {
|
786
|
-
'awsAccessKeyId'
|
787
|
-
'awsSecretAccessKey'
|
788
|
-
'awsS3Bucket'
|
849
|
+
'awsAccessKeyId'?: string | undefined | null;
|
850
|
+
'awsSecretAccessKey'?: string | undefined | null;
|
851
|
+
'awsS3Bucket'?: string | undefined | null;
|
852
|
+
'localUploadDir'?: string | undefined | null;
|
853
|
+
'fileHostUrl'?: string | undefined | null;
|
789
854
|
}
|
790
855
|
interface SaveSettingsEmitPayloadSchema extends SpruceSchema.Schema {
|
791
856
|
id: 'saveSettingsEmitPayload';
|
@@ -796,19 +861,26 @@ declare module '@sprucelabs/spruce-core-schemas/build/.spruce/schemas/core.schem
|
|
796
861
|
/** . */
|
797
862
|
'awsAccessKeyId': {
|
798
863
|
type: 'id';
|
799
|
-
isRequired: true;
|
800
864
|
options: undefined;
|
801
865
|
};
|
802
866
|
/** . */
|
803
867
|
'awsSecretAccessKey': {
|
804
868
|
type: 'text';
|
805
|
-
isRequired: true;
|
806
869
|
options: undefined;
|
807
870
|
};
|
808
871
|
/** . */
|
809
872
|
'awsS3Bucket': {
|
810
873
|
type: 'text';
|
811
|
-
|
874
|
+
options: undefined;
|
875
|
+
};
|
876
|
+
/** . */
|
877
|
+
'localUploadDir': {
|
878
|
+
type: 'text';
|
879
|
+
options: undefined;
|
880
|
+
};
|
881
|
+
/** . */
|
882
|
+
'fileHostUrl': {
|
883
|
+
type: 'text';
|
812
884
|
options: undefined;
|
813
885
|
};
|
814
886
|
};
|
@@ -821,7 +893,7 @@ declare module '@sprucelabs/spruce-core-schemas/build/.spruce/schemas/core.schem
|
|
821
893
|
/** Source. */
|
822
894
|
'source'?: SpruceSchemas.SpruceEventUtils.v2021_09_13.EventSource | undefined | null;
|
823
895
|
'target': SpruceSchemas.Files.v2022_05_13.SaveSettingsEmitTarget;
|
824
|
-
'payload'
|
896
|
+
'payload'?: SpruceSchemas.Files.v2022_05_13.SaveSettingsEmitPayload | undefined | null;
|
825
897
|
}
|
826
898
|
interface SaveSettingsEmitTargetAndPayloadSchema extends SpruceSchema.Schema {
|
827
899
|
id: 'saveSettingsEmitTargetAndPayload';
|
@@ -848,7 +920,6 @@ declare module '@sprucelabs/spruce-core-schemas/build/.spruce/schemas/core.schem
|
|
848
920
|
/** . */
|
849
921
|
'payload': {
|
850
922
|
type: 'schema';
|
851
|
-
isRequired: true;
|
852
923
|
options: {
|
853
924
|
schema: SpruceSchemas.Files.v2022_05_13.SaveSettingsEmitPayloadSchema;
|
854
925
|
};
|
@@ -880,35 +951,14 @@ declare module '@sprucelabs/spruce-core-schemas/build/.spruce/schemas/core.schem
|
|
880
951
|
}
|
881
952
|
}
|
882
953
|
namespace SpruceSchemas.Files.v2022_05_13 {
|
883
|
-
interface
|
884
|
-
/** . The REST endpoint URL to user when uploading a file. If not set, you must use upload using the Mercury Client. */
|
885
|
-
'restEndpointUrl'?: string | undefined | null;
|
886
|
-
}
|
887
|
-
interface GetUploadEndpointResponsePayloadSchema extends SpruceSchema.Schema {
|
888
|
-
id: 'getUploadEndpointResponsePayload';
|
889
|
-
version: 'v2022_05_13';
|
890
|
-
namespace: 'Files';
|
891
|
-
name: '';
|
892
|
-
fields: {
|
893
|
-
/** . The REST endpoint URL to user when uploading a file. If not set, you must use upload using the Mercury Client. */
|
894
|
-
'restEndpointUrl': {
|
895
|
-
type: 'text';
|
896
|
-
hint: 'The REST endpoint URL to user when uploading a file. If not set, you must use upload using the Mercury Client.';
|
897
|
-
options: undefined;
|
898
|
-
};
|
899
|
-
};
|
900
|
-
}
|
901
|
-
interface GetUploadEndpointResponsePayloadEntity extends SchemaEntity<SpruceSchemas.Files.v2022_05_13.GetUploadEndpointResponsePayloadSchema> {
|
902
|
-
}
|
903
|
-
}
|
904
|
-
namespace SpruceSchemas.Files.v2022_05_13 {
|
905
|
-
interface GetSettingsStatusEmitTargetAndPayload {
|
954
|
+
interface UploadEmitTargetAndPayload {
|
906
955
|
/** Source. */
|
907
956
|
'source'?: SpruceSchemas.SpruceEventUtils.v2021_09_13.EventSource | undefined | null;
|
908
|
-
'target'
|
957
|
+
'target'?: SpruceSchemas.Files.v2022_05_13.UploadEmitTarget | undefined | null;
|
958
|
+
'payload': SpruceSchemas.Files.v2022_05_13.UploadEmitPayload;
|
909
959
|
}
|
910
|
-
interface
|
911
|
-
id: '
|
960
|
+
interface UploadEmitTargetAndPayloadSchema extends SpruceSchema.Schema {
|
961
|
+
id: 'uploadEmitTargetAndPayload';
|
912
962
|
version: 'v2022_05_13';
|
913
963
|
namespace: 'Files';
|
914
964
|
name: '';
|
@@ -923,86 +973,53 @@ declare module '@sprucelabs/spruce-core-schemas/build/.spruce/schemas/core.schem
|
|
923
973
|
};
|
924
974
|
/** . */
|
925
975
|
'target': {
|
976
|
+
type: 'schema';
|
977
|
+
options: {
|
978
|
+
schema: SpruceSchemas.Files.v2022_05_13.UploadEmitTargetSchema;
|
979
|
+
};
|
980
|
+
};
|
981
|
+
/** . */
|
982
|
+
'payload': {
|
926
983
|
type: 'schema';
|
927
984
|
isRequired: true;
|
928
985
|
options: {
|
929
|
-
schema: SpruceSchemas.Files.v2022_05_13.
|
986
|
+
schema: SpruceSchemas.Files.v2022_05_13.UploadEmitPayloadSchema;
|
930
987
|
};
|
931
988
|
};
|
932
989
|
};
|
933
990
|
}
|
934
|
-
interface
|
991
|
+
interface UploadEmitTargetAndPayloadEntity extends SchemaEntity<SpruceSchemas.Files.v2022_05_13.UploadEmitTargetAndPayloadSchema> {
|
935
992
|
}
|
936
993
|
}
|
937
994
|
namespace SpruceSchemas.Files.v2022_05_13 {
|
938
|
-
interface
|
939
|
-
'
|
940
|
-
'organizationId'?: string | undefined | null;
|
941
|
-
'filePersonId'?: string | undefined | null;
|
995
|
+
interface GetSettingsStatusEmitTarget {
|
996
|
+
'organizationId': string;
|
942
997
|
}
|
943
|
-
interface
|
944
|
-
id: '
|
998
|
+
interface GetSettingsStatusEmitTargetSchema extends SpruceSchema.Schema {
|
999
|
+
id: 'getSettingsStatusEmitTarget';
|
945
1000
|
version: 'v2022_05_13';
|
946
1001
|
namespace: 'Files';
|
947
1002
|
name: '';
|
948
1003
|
fields: {
|
949
|
-
/** . */
|
950
|
-
'locationId': {
|
951
|
-
type: 'id';
|
952
|
-
options: undefined;
|
953
|
-
};
|
954
1004
|
/** . */
|
955
1005
|
'organizationId': {
|
956
1006
|
type: 'id';
|
957
|
-
options: undefined;
|
958
|
-
};
|
959
|
-
/** . */
|
960
|
-
'filePersonId': {
|
961
|
-
type: 'text';
|
962
|
-
options: undefined;
|
963
|
-
};
|
964
|
-
};
|
965
|
-
}
|
966
|
-
interface UploadEmitTargetEntity extends SchemaEntity<SpruceSchemas.Files.v2022_05_13.UploadEmitTargetSchema> {
|
967
|
-
}
|
968
|
-
}
|
969
|
-
namespace SpruceSchemas.Files.v2022_05_13 {
|
970
|
-
interface UploadEmitPayload {
|
971
|
-
'base64Body': string;
|
972
|
-
'name': string;
|
973
|
-
}
|
974
|
-
interface UploadEmitPayloadSchema extends SpruceSchema.Schema {
|
975
|
-
id: 'uploadEmitPayload';
|
976
|
-
version: 'v2022_05_13';
|
977
|
-
namespace: 'Files';
|
978
|
-
name: '';
|
979
|
-
fields: {
|
980
|
-
/** . */
|
981
|
-
'base64Body': {
|
982
|
-
type: 'text';
|
983
|
-
isRequired: true;
|
984
|
-
options: undefined;
|
985
|
-
};
|
986
|
-
/** . */
|
987
|
-
'name': {
|
988
|
-
type: 'text';
|
989
1007
|
isRequired: true;
|
990
1008
|
options: undefined;
|
991
1009
|
};
|
992
1010
|
};
|
993
1011
|
}
|
994
|
-
interface
|
1012
|
+
interface GetSettingsStatusEmitTargetEntity extends SchemaEntity<SpruceSchemas.Files.v2022_05_13.GetSettingsStatusEmitTargetSchema> {
|
995
1013
|
}
|
996
1014
|
}
|
997
1015
|
namespace SpruceSchemas.Files.v2022_05_13 {
|
998
|
-
interface
|
1016
|
+
interface GetSettingsStatusEmitTargetAndPayload {
|
999
1017
|
/** Source. */
|
1000
1018
|
'source'?: SpruceSchemas.SpruceEventUtils.v2021_09_13.EventSource | undefined | null;
|
1001
|
-
'target'
|
1002
|
-
'payload': SpruceSchemas.Files.v2022_05_13.UploadEmitPayload;
|
1019
|
+
'target': SpruceSchemas.Files.v2022_05_13.GetSettingsStatusEmitTarget;
|
1003
1020
|
}
|
1004
|
-
interface
|
1005
|
-
id: '
|
1021
|
+
interface GetSettingsStatusEmitTargetAndPayloadSchema extends SpruceSchema.Schema {
|
1022
|
+
id: 'getSettingsStatusEmitTargetAndPayload';
|
1006
1023
|
version: 'v2022_05_13';
|
1007
1024
|
namespace: 'Files';
|
1008
1025
|
name: '';
|
@@ -1018,21 +1035,35 @@ declare module '@sprucelabs/spruce-core-schemas/build/.spruce/schemas/core.schem
|
|
1018
1035
|
/** . */
|
1019
1036
|
'target': {
|
1020
1037
|
type: 'schema';
|
1038
|
+
isRequired: true;
|
1021
1039
|
options: {
|
1022
|
-
schema: SpruceSchemas.Files.v2022_05_13.
|
1040
|
+
schema: SpruceSchemas.Files.v2022_05_13.GetSettingsStatusEmitTargetSchema;
|
1023
1041
|
};
|
1024
1042
|
};
|
1043
|
+
};
|
1044
|
+
}
|
1045
|
+
interface GetSettingsStatusEmitTargetAndPayloadEntity extends SchemaEntity<SpruceSchemas.Files.v2022_05_13.GetSettingsStatusEmitTargetAndPayloadSchema> {
|
1046
|
+
}
|
1047
|
+
}
|
1048
|
+
namespace SpruceSchemas.Files.v2022_05_13 {
|
1049
|
+
interface GetSettingsStatusResponsePayload {
|
1050
|
+
'didSupplyS3Creds': boolean;
|
1051
|
+
}
|
1052
|
+
interface GetSettingsStatusResponsePayloadSchema extends SpruceSchema.Schema {
|
1053
|
+
id: 'getSettingsStatusResponsePayload';
|
1054
|
+
version: 'v2022_05_13';
|
1055
|
+
namespace: 'Files';
|
1056
|
+
name: '';
|
1057
|
+
fields: {
|
1025
1058
|
/** . */
|
1026
|
-
'
|
1027
|
-
type: '
|
1059
|
+
'didSupplyS3Creds': {
|
1060
|
+
type: 'boolean';
|
1028
1061
|
isRequired: true;
|
1029
|
-
options:
|
1030
|
-
schema: SpruceSchemas.Files.v2022_05_13.UploadEmitPayloadSchema;
|
1031
|
-
};
|
1062
|
+
options: undefined;
|
1032
1063
|
};
|
1033
1064
|
};
|
1034
1065
|
}
|
1035
|
-
interface
|
1066
|
+
interface GetSettingsStatusResponsePayloadEntity extends SchemaEntity<SpruceSchemas.Files.v2022_05_13.GetSettingsStatusResponsePayloadSchema> {
|
1036
1067
|
}
|
1037
1068
|
}
|
1038
1069
|
namespace SpruceSchemas.Files.v2022_05_13 {
|
@@ -1077,29 +1108,6 @@ declare module '@sprucelabs/spruce-core-schemas/build/.spruce/schemas/core.schem
|
|
1077
1108
|
interface UploadedFileEntity extends SchemaEntity<SpruceSchemas.Files.v2022_05_13.UploadedFileSchema> {
|
1078
1109
|
}
|
1079
1110
|
}
|
1080
|
-
namespace SpruceSchemas.Files.v2022_05_13 {
|
1081
|
-
interface UploadResponsePayload {
|
1082
|
-
'file': SpruceSchemas.Files.v2022_05_13.UploadedFile;
|
1083
|
-
}
|
1084
|
-
interface UploadResponsePayloadSchema extends SpruceSchema.Schema {
|
1085
|
-
id: 'uploadResponsePayload';
|
1086
|
-
version: 'v2022_05_13';
|
1087
|
-
namespace: 'Files';
|
1088
|
-
name: '';
|
1089
|
-
fields: {
|
1090
|
-
/** . */
|
1091
|
-
'file': {
|
1092
|
-
type: 'schema';
|
1093
|
-
isRequired: true;
|
1094
|
-
options: {
|
1095
|
-
schema: SpruceSchemas.Files.v2022_05_13.UploadedFileSchema;
|
1096
|
-
};
|
1097
|
-
};
|
1098
|
-
};
|
1099
|
-
}
|
1100
|
-
interface UploadResponsePayloadEntity extends SchemaEntity<SpruceSchemas.Files.v2022_05_13.UploadResponsePayloadSchema> {
|
1101
|
-
}
|
1102
|
-
}
|
1103
1111
|
namespace SpruceSchemas.Files.v2022_05_13 {
|
1104
1112
|
interface SettingsTarget {
|
1105
1113
|
'organizationId': string;
|
@@ -1125,11 +1133,15 @@ declare module '@sprucelabs/spruce-core-schemas/build/.spruce/schemas/core.schem
|
|
1125
1133
|
interface Settings {
|
1126
1134
|
'id': string;
|
1127
1135
|
/** AWS Access Key ID. */
|
1128
|
-
'awsAccessKeyId'
|
1136
|
+
'awsAccessKeyId'?: string | undefined | null;
|
1129
1137
|
/** AWS Secret Access Key. */
|
1130
|
-
'awsSecretAccessKey'
|
1138
|
+
'awsSecretAccessKey'?: string | undefined | null;
|
1131
1139
|
/** AWS S3 Bucket. */
|
1132
|
-
'awsS3Bucket'
|
1140
|
+
'awsS3Bucket'?: string | undefined | null;
|
1141
|
+
/** Local Upload Directory. */
|
1142
|
+
'localUploadDir'?: string | undefined | null;
|
1143
|
+
/** File Host URL. */
|
1144
|
+
'fileHostUrl'?: string | undefined | null;
|
1133
1145
|
'target'?: SpruceSchemas.Files.v2022_05_13.SettingsTarget | undefined | null;
|
1134
1146
|
}
|
1135
1147
|
interface SettingsSchema extends SpruceSchema.Schema {
|
@@ -1148,21 +1160,30 @@ declare module '@sprucelabs/spruce-core-schemas/build/.spruce/schemas/core.schem
|
|
1148
1160
|
'awsAccessKeyId': {
|
1149
1161
|
label: 'AWS Access Key ID';
|
1150
1162
|
type: 'text';
|
1151
|
-
isRequired: true;
|
1152
1163
|
options: undefined;
|
1153
1164
|
};
|
1154
1165
|
/** AWS Secret Access Key. */
|
1155
1166
|
'awsSecretAccessKey': {
|
1156
1167
|
label: 'AWS Secret Access Key';
|
1157
1168
|
type: 'text';
|
1158
|
-
isRequired: true;
|
1159
1169
|
options: undefined;
|
1160
1170
|
};
|
1161
1171
|
/** AWS S3 Bucket. */
|
1162
1172
|
'awsS3Bucket': {
|
1163
1173
|
label: 'AWS S3 Bucket';
|
1164
1174
|
type: 'text';
|
1165
|
-
|
1175
|
+
options: undefined;
|
1176
|
+
};
|
1177
|
+
/** Local Upload Directory. */
|
1178
|
+
'localUploadDir': {
|
1179
|
+
label: 'Local Upload Directory';
|
1180
|
+
type: 'text';
|
1181
|
+
options: undefined;
|
1182
|
+
};
|
1183
|
+
/** File Host URL. */
|
1184
|
+
'fileHostUrl': {
|
1185
|
+
label: 'File Host URL';
|
1186
|
+
type: 'text';
|
1166
1187
|
options: undefined;
|
1167
1188
|
};
|
1168
1189
|
/** . */
|
@@ -719,45 +719,108 @@ declare module '@sprucelabs/spruce-core-schemas/build/.spruce/schemas/core.schem
|
|
719
719
|
}
|
720
720
|
}
|
721
721
|
namespace SpruceSchemas.Files.v2022_05_13 {
|
722
|
-
interface
|
723
|
-
|
722
|
+
interface GetUploadEndpointResponsePayload {
|
723
|
+
/** . The REST endpoint URL to user when uploading a file. If not set, you must use upload using the Mercury Client. */
|
724
|
+
'restEndpointUrl'?: string | undefined | null;
|
724
725
|
}
|
725
|
-
interface
|
726
|
-
id: '
|
726
|
+
interface GetUploadEndpointResponsePayloadSchema extends SpruceSchema.Schema {
|
727
|
+
id: 'getUploadEndpointResponsePayload';
|
727
728
|
version: 'v2022_05_13';
|
728
729
|
namespace: 'Files';
|
729
730
|
name: '';
|
730
731
|
fields: {
|
732
|
+
/** . The REST endpoint URL to user when uploading a file. If not set, you must use upload using the Mercury Client. */
|
733
|
+
'restEndpointUrl': {
|
734
|
+
type: 'text';
|
735
|
+
hint: 'The REST endpoint URL to user when uploading a file. If not set, you must use upload using the Mercury Client.';
|
736
|
+
options: undefined;
|
737
|
+
};
|
738
|
+
};
|
739
|
+
}
|
740
|
+
interface GetUploadEndpointResponsePayloadEntity extends SchemaEntity<SpruceSchemas.Files.v2022_05_13.GetUploadEndpointResponsePayloadSchema> {
|
741
|
+
}
|
742
|
+
}
|
743
|
+
namespace SpruceSchemas.Files.v2022_05_13 {
|
744
|
+
interface UploadEmitTarget {
|
745
|
+
'locationId'?: string | undefined | null;
|
746
|
+
'organizationId'?: string | undefined | null;
|
747
|
+
'filePersonId'?: string | undefined | null;
|
748
|
+
}
|
749
|
+
interface UploadEmitTargetSchema extends SpruceSchema.Schema {
|
750
|
+
id: 'uploadEmitTarget';
|
751
|
+
version: 'v2022_05_13';
|
752
|
+
namespace: 'Files';
|
753
|
+
name: '';
|
754
|
+
fields: {
|
755
|
+
/** . */
|
756
|
+
'locationId': {
|
757
|
+
type: 'id';
|
758
|
+
options: undefined;
|
759
|
+
};
|
731
760
|
/** . */
|
732
761
|
'organizationId': {
|
733
762
|
type: 'id';
|
734
|
-
|
763
|
+
options: undefined;
|
764
|
+
};
|
765
|
+
/** . */
|
766
|
+
'filePersonId': {
|
767
|
+
type: 'text';
|
735
768
|
options: undefined;
|
736
769
|
};
|
737
770
|
};
|
738
771
|
}
|
739
|
-
interface
|
772
|
+
interface UploadEmitTargetEntity extends SchemaEntity<SpruceSchemas.Files.v2022_05_13.UploadEmitTargetSchema> {
|
740
773
|
}
|
741
774
|
}
|
742
775
|
namespace SpruceSchemas.Files.v2022_05_13 {
|
743
|
-
interface
|
744
|
-
'
|
776
|
+
interface UploadEmitPayload {
|
777
|
+
'base64Body': string;
|
778
|
+
'name': string;
|
745
779
|
}
|
746
|
-
interface
|
747
|
-
id: '
|
780
|
+
interface UploadEmitPayloadSchema extends SpruceSchema.Schema {
|
781
|
+
id: 'uploadEmitPayload';
|
748
782
|
version: 'v2022_05_13';
|
749
783
|
namespace: 'Files';
|
750
784
|
name: '';
|
751
785
|
fields: {
|
752
786
|
/** . */
|
753
|
-
'
|
754
|
-
type: '
|
787
|
+
'base64Body': {
|
788
|
+
type: 'text';
|
789
|
+
isRequired: true;
|
790
|
+
options: undefined;
|
791
|
+
};
|
792
|
+
/** . */
|
793
|
+
'name': {
|
794
|
+
type: 'text';
|
755
795
|
isRequired: true;
|
756
796
|
options: undefined;
|
757
797
|
};
|
758
798
|
};
|
759
799
|
}
|
760
|
-
interface
|
800
|
+
interface UploadEmitPayloadEntity extends SchemaEntity<SpruceSchemas.Files.v2022_05_13.UploadEmitPayloadSchema> {
|
801
|
+
}
|
802
|
+
}
|
803
|
+
namespace SpruceSchemas.Files.v2022_05_13 {
|
804
|
+
interface UploadResponsePayload {
|
805
|
+
'file': SpruceSchemas.Files.v2022_05_13.UploadedFile;
|
806
|
+
}
|
807
|
+
interface UploadResponsePayloadSchema extends SpruceSchema.Schema {
|
808
|
+
id: 'uploadResponsePayload';
|
809
|
+
version: 'v2022_05_13';
|
810
|
+
namespace: 'Files';
|
811
|
+
name: '';
|
812
|
+
fields: {
|
813
|
+
/** . */
|
814
|
+
'file': {
|
815
|
+
type: 'schema';
|
816
|
+
isRequired: true;
|
817
|
+
options: {
|
818
|
+
schema: SpruceSchemas.Files.v2022_05_13.UploadedFileSchema;
|
819
|
+
};
|
820
|
+
};
|
821
|
+
};
|
822
|
+
}
|
823
|
+
interface UploadResponsePayloadEntity extends SchemaEntity<SpruceSchemas.Files.v2022_05_13.UploadResponsePayloadSchema> {
|
761
824
|
}
|
762
825
|
}
|
763
826
|
namespace SpruceSchemas.Files.v2022_05_13 {
|
@@ -783,9 +846,11 @@ declare module '@sprucelabs/spruce-core-schemas/build/.spruce/schemas/core.schem
|
|
783
846
|
}
|
784
847
|
namespace SpruceSchemas.Files.v2022_05_13 {
|
785
848
|
interface SaveSettingsEmitPayload {
|
786
|
-
'awsAccessKeyId'
|
787
|
-
'awsSecretAccessKey'
|
788
|
-
'awsS3Bucket'
|
849
|
+
'awsAccessKeyId'?: string | undefined | null;
|
850
|
+
'awsSecretAccessKey'?: string | undefined | null;
|
851
|
+
'awsS3Bucket'?: string | undefined | null;
|
852
|
+
'localUploadDir'?: string | undefined | null;
|
853
|
+
'fileHostUrl'?: string | undefined | null;
|
789
854
|
}
|
790
855
|
interface SaveSettingsEmitPayloadSchema extends SpruceSchema.Schema {
|
791
856
|
id: 'saveSettingsEmitPayload';
|
@@ -796,19 +861,26 @@ declare module '@sprucelabs/spruce-core-schemas/build/.spruce/schemas/core.schem
|
|
796
861
|
/** . */
|
797
862
|
'awsAccessKeyId': {
|
798
863
|
type: 'id';
|
799
|
-
isRequired: true;
|
800
864
|
options: undefined;
|
801
865
|
};
|
802
866
|
/** . */
|
803
867
|
'awsSecretAccessKey': {
|
804
868
|
type: 'text';
|
805
|
-
isRequired: true;
|
806
869
|
options: undefined;
|
807
870
|
};
|
808
871
|
/** . */
|
809
872
|
'awsS3Bucket': {
|
810
873
|
type: 'text';
|
811
|
-
|
874
|
+
options: undefined;
|
875
|
+
};
|
876
|
+
/** . */
|
877
|
+
'localUploadDir': {
|
878
|
+
type: 'text';
|
879
|
+
options: undefined;
|
880
|
+
};
|
881
|
+
/** . */
|
882
|
+
'fileHostUrl': {
|
883
|
+
type: 'text';
|
812
884
|
options: undefined;
|
813
885
|
};
|
814
886
|
};
|
@@ -821,7 +893,7 @@ declare module '@sprucelabs/spruce-core-schemas/build/.spruce/schemas/core.schem
|
|
821
893
|
/** Source. */
|
822
894
|
'source'?: SpruceSchemas.SpruceEventUtils.v2021_09_13.EventSource | undefined | null;
|
823
895
|
'target': SpruceSchemas.Files.v2022_05_13.SaveSettingsEmitTarget;
|
824
|
-
'payload'
|
896
|
+
'payload'?: SpruceSchemas.Files.v2022_05_13.SaveSettingsEmitPayload | undefined | null;
|
825
897
|
}
|
826
898
|
interface SaveSettingsEmitTargetAndPayloadSchema extends SpruceSchema.Schema {
|
827
899
|
id: 'saveSettingsEmitTargetAndPayload';
|
@@ -848,7 +920,6 @@ declare module '@sprucelabs/spruce-core-schemas/build/.spruce/schemas/core.schem
|
|
848
920
|
/** . */
|
849
921
|
'payload': {
|
850
922
|
type: 'schema';
|
851
|
-
isRequired: true;
|
852
923
|
options: {
|
853
924
|
schema: SpruceSchemas.Files.v2022_05_13.SaveSettingsEmitPayloadSchema;
|
854
925
|
};
|
@@ -880,35 +951,14 @@ declare module '@sprucelabs/spruce-core-schemas/build/.spruce/schemas/core.schem
|
|
880
951
|
}
|
881
952
|
}
|
882
953
|
namespace SpruceSchemas.Files.v2022_05_13 {
|
883
|
-
interface
|
884
|
-
/** . The REST endpoint URL to user when uploading a file. If not set, you must use upload using the Mercury Client. */
|
885
|
-
'restEndpointUrl'?: string | undefined | null;
|
886
|
-
}
|
887
|
-
interface GetUploadEndpointResponsePayloadSchema extends SpruceSchema.Schema {
|
888
|
-
id: 'getUploadEndpointResponsePayload';
|
889
|
-
version: 'v2022_05_13';
|
890
|
-
namespace: 'Files';
|
891
|
-
name: '';
|
892
|
-
fields: {
|
893
|
-
/** . The REST endpoint URL to user when uploading a file. If not set, you must use upload using the Mercury Client. */
|
894
|
-
'restEndpointUrl': {
|
895
|
-
type: 'text';
|
896
|
-
hint: 'The REST endpoint URL to user when uploading a file. If not set, you must use upload using the Mercury Client.';
|
897
|
-
options: undefined;
|
898
|
-
};
|
899
|
-
};
|
900
|
-
}
|
901
|
-
interface GetUploadEndpointResponsePayloadEntity extends SchemaEntity<SpruceSchemas.Files.v2022_05_13.GetUploadEndpointResponsePayloadSchema> {
|
902
|
-
}
|
903
|
-
}
|
904
|
-
namespace SpruceSchemas.Files.v2022_05_13 {
|
905
|
-
interface GetSettingsStatusEmitTargetAndPayload {
|
954
|
+
interface UploadEmitTargetAndPayload {
|
906
955
|
/** Source. */
|
907
956
|
'source'?: SpruceSchemas.SpruceEventUtils.v2021_09_13.EventSource | undefined | null;
|
908
|
-
'target'
|
957
|
+
'target'?: SpruceSchemas.Files.v2022_05_13.UploadEmitTarget | undefined | null;
|
958
|
+
'payload': SpruceSchemas.Files.v2022_05_13.UploadEmitPayload;
|
909
959
|
}
|
910
|
-
interface
|
911
|
-
id: '
|
960
|
+
interface UploadEmitTargetAndPayloadSchema extends SpruceSchema.Schema {
|
961
|
+
id: 'uploadEmitTargetAndPayload';
|
912
962
|
version: 'v2022_05_13';
|
913
963
|
namespace: 'Files';
|
914
964
|
name: '';
|
@@ -923,86 +973,53 @@ declare module '@sprucelabs/spruce-core-schemas/build/.spruce/schemas/core.schem
|
|
923
973
|
};
|
924
974
|
/** . */
|
925
975
|
'target': {
|
976
|
+
type: 'schema';
|
977
|
+
options: {
|
978
|
+
schema: SpruceSchemas.Files.v2022_05_13.UploadEmitTargetSchema;
|
979
|
+
};
|
980
|
+
};
|
981
|
+
/** . */
|
982
|
+
'payload': {
|
926
983
|
type: 'schema';
|
927
984
|
isRequired: true;
|
928
985
|
options: {
|
929
|
-
schema: SpruceSchemas.Files.v2022_05_13.
|
986
|
+
schema: SpruceSchemas.Files.v2022_05_13.UploadEmitPayloadSchema;
|
930
987
|
};
|
931
988
|
};
|
932
989
|
};
|
933
990
|
}
|
934
|
-
interface
|
991
|
+
interface UploadEmitTargetAndPayloadEntity extends SchemaEntity<SpruceSchemas.Files.v2022_05_13.UploadEmitTargetAndPayloadSchema> {
|
935
992
|
}
|
936
993
|
}
|
937
994
|
namespace SpruceSchemas.Files.v2022_05_13 {
|
938
|
-
interface
|
939
|
-
'
|
940
|
-
'organizationId'?: string | undefined | null;
|
941
|
-
'filePersonId'?: string | undefined | null;
|
995
|
+
interface GetSettingsStatusEmitTarget {
|
996
|
+
'organizationId': string;
|
942
997
|
}
|
943
|
-
interface
|
944
|
-
id: '
|
998
|
+
interface GetSettingsStatusEmitTargetSchema extends SpruceSchema.Schema {
|
999
|
+
id: 'getSettingsStatusEmitTarget';
|
945
1000
|
version: 'v2022_05_13';
|
946
1001
|
namespace: 'Files';
|
947
1002
|
name: '';
|
948
1003
|
fields: {
|
949
|
-
/** . */
|
950
|
-
'locationId': {
|
951
|
-
type: 'id';
|
952
|
-
options: undefined;
|
953
|
-
};
|
954
1004
|
/** . */
|
955
1005
|
'organizationId': {
|
956
1006
|
type: 'id';
|
957
|
-
options: undefined;
|
958
|
-
};
|
959
|
-
/** . */
|
960
|
-
'filePersonId': {
|
961
|
-
type: 'text';
|
962
|
-
options: undefined;
|
963
|
-
};
|
964
|
-
};
|
965
|
-
}
|
966
|
-
interface UploadEmitTargetEntity extends SchemaEntity<SpruceSchemas.Files.v2022_05_13.UploadEmitTargetSchema> {
|
967
|
-
}
|
968
|
-
}
|
969
|
-
namespace SpruceSchemas.Files.v2022_05_13 {
|
970
|
-
interface UploadEmitPayload {
|
971
|
-
'base64Body': string;
|
972
|
-
'name': string;
|
973
|
-
}
|
974
|
-
interface UploadEmitPayloadSchema extends SpruceSchema.Schema {
|
975
|
-
id: 'uploadEmitPayload';
|
976
|
-
version: 'v2022_05_13';
|
977
|
-
namespace: 'Files';
|
978
|
-
name: '';
|
979
|
-
fields: {
|
980
|
-
/** . */
|
981
|
-
'base64Body': {
|
982
|
-
type: 'text';
|
983
|
-
isRequired: true;
|
984
|
-
options: undefined;
|
985
|
-
};
|
986
|
-
/** . */
|
987
|
-
'name': {
|
988
|
-
type: 'text';
|
989
1007
|
isRequired: true;
|
990
1008
|
options: undefined;
|
991
1009
|
};
|
992
1010
|
};
|
993
1011
|
}
|
994
|
-
interface
|
1012
|
+
interface GetSettingsStatusEmitTargetEntity extends SchemaEntity<SpruceSchemas.Files.v2022_05_13.GetSettingsStatusEmitTargetSchema> {
|
995
1013
|
}
|
996
1014
|
}
|
997
1015
|
namespace SpruceSchemas.Files.v2022_05_13 {
|
998
|
-
interface
|
1016
|
+
interface GetSettingsStatusEmitTargetAndPayload {
|
999
1017
|
/** Source. */
|
1000
1018
|
'source'?: SpruceSchemas.SpruceEventUtils.v2021_09_13.EventSource | undefined | null;
|
1001
|
-
'target'
|
1002
|
-
'payload': SpruceSchemas.Files.v2022_05_13.UploadEmitPayload;
|
1019
|
+
'target': SpruceSchemas.Files.v2022_05_13.GetSettingsStatusEmitTarget;
|
1003
1020
|
}
|
1004
|
-
interface
|
1005
|
-
id: '
|
1021
|
+
interface GetSettingsStatusEmitTargetAndPayloadSchema extends SpruceSchema.Schema {
|
1022
|
+
id: 'getSettingsStatusEmitTargetAndPayload';
|
1006
1023
|
version: 'v2022_05_13';
|
1007
1024
|
namespace: 'Files';
|
1008
1025
|
name: '';
|
@@ -1018,21 +1035,35 @@ declare module '@sprucelabs/spruce-core-schemas/build/.spruce/schemas/core.schem
|
|
1018
1035
|
/** . */
|
1019
1036
|
'target': {
|
1020
1037
|
type: 'schema';
|
1038
|
+
isRequired: true;
|
1021
1039
|
options: {
|
1022
|
-
schema: SpruceSchemas.Files.v2022_05_13.
|
1040
|
+
schema: SpruceSchemas.Files.v2022_05_13.GetSettingsStatusEmitTargetSchema;
|
1023
1041
|
};
|
1024
1042
|
};
|
1043
|
+
};
|
1044
|
+
}
|
1045
|
+
interface GetSettingsStatusEmitTargetAndPayloadEntity extends SchemaEntity<SpruceSchemas.Files.v2022_05_13.GetSettingsStatusEmitTargetAndPayloadSchema> {
|
1046
|
+
}
|
1047
|
+
}
|
1048
|
+
namespace SpruceSchemas.Files.v2022_05_13 {
|
1049
|
+
interface GetSettingsStatusResponsePayload {
|
1050
|
+
'didSupplyS3Creds': boolean;
|
1051
|
+
}
|
1052
|
+
interface GetSettingsStatusResponsePayloadSchema extends SpruceSchema.Schema {
|
1053
|
+
id: 'getSettingsStatusResponsePayload';
|
1054
|
+
version: 'v2022_05_13';
|
1055
|
+
namespace: 'Files';
|
1056
|
+
name: '';
|
1057
|
+
fields: {
|
1025
1058
|
/** . */
|
1026
|
-
'
|
1027
|
-
type: '
|
1059
|
+
'didSupplyS3Creds': {
|
1060
|
+
type: 'boolean';
|
1028
1061
|
isRequired: true;
|
1029
|
-
options:
|
1030
|
-
schema: SpruceSchemas.Files.v2022_05_13.UploadEmitPayloadSchema;
|
1031
|
-
};
|
1062
|
+
options: undefined;
|
1032
1063
|
};
|
1033
1064
|
};
|
1034
1065
|
}
|
1035
|
-
interface
|
1066
|
+
interface GetSettingsStatusResponsePayloadEntity extends SchemaEntity<SpruceSchemas.Files.v2022_05_13.GetSettingsStatusResponsePayloadSchema> {
|
1036
1067
|
}
|
1037
1068
|
}
|
1038
1069
|
namespace SpruceSchemas.Files.v2022_05_13 {
|
@@ -1077,29 +1108,6 @@ declare module '@sprucelabs/spruce-core-schemas/build/.spruce/schemas/core.schem
|
|
1077
1108
|
interface UploadedFileEntity extends SchemaEntity<SpruceSchemas.Files.v2022_05_13.UploadedFileSchema> {
|
1078
1109
|
}
|
1079
1110
|
}
|
1080
|
-
namespace SpruceSchemas.Files.v2022_05_13 {
|
1081
|
-
interface UploadResponsePayload {
|
1082
|
-
'file': SpruceSchemas.Files.v2022_05_13.UploadedFile;
|
1083
|
-
}
|
1084
|
-
interface UploadResponsePayloadSchema extends SpruceSchema.Schema {
|
1085
|
-
id: 'uploadResponsePayload';
|
1086
|
-
version: 'v2022_05_13';
|
1087
|
-
namespace: 'Files';
|
1088
|
-
name: '';
|
1089
|
-
fields: {
|
1090
|
-
/** . */
|
1091
|
-
'file': {
|
1092
|
-
type: 'schema';
|
1093
|
-
isRequired: true;
|
1094
|
-
options: {
|
1095
|
-
schema: SpruceSchemas.Files.v2022_05_13.UploadedFileSchema;
|
1096
|
-
};
|
1097
|
-
};
|
1098
|
-
};
|
1099
|
-
}
|
1100
|
-
interface UploadResponsePayloadEntity extends SchemaEntity<SpruceSchemas.Files.v2022_05_13.UploadResponsePayloadSchema> {
|
1101
|
-
}
|
1102
|
-
}
|
1103
1111
|
namespace SpruceSchemas.Files.v2022_05_13 {
|
1104
1112
|
interface SettingsTarget {
|
1105
1113
|
'organizationId': string;
|
@@ -1125,11 +1133,15 @@ declare module '@sprucelabs/spruce-core-schemas/build/.spruce/schemas/core.schem
|
|
1125
1133
|
interface Settings {
|
1126
1134
|
'id': string;
|
1127
1135
|
/** AWS Access Key ID. */
|
1128
|
-
'awsAccessKeyId'
|
1136
|
+
'awsAccessKeyId'?: string | undefined | null;
|
1129
1137
|
/** AWS Secret Access Key. */
|
1130
|
-
'awsSecretAccessKey'
|
1138
|
+
'awsSecretAccessKey'?: string | undefined | null;
|
1131
1139
|
/** AWS S3 Bucket. */
|
1132
|
-
'awsS3Bucket'
|
1140
|
+
'awsS3Bucket'?: string | undefined | null;
|
1141
|
+
/** Local Upload Directory. */
|
1142
|
+
'localUploadDir'?: string | undefined | null;
|
1143
|
+
/** File Host URL. */
|
1144
|
+
'fileHostUrl'?: string | undefined | null;
|
1133
1145
|
'target'?: SpruceSchemas.Files.v2022_05_13.SettingsTarget | undefined | null;
|
1134
1146
|
}
|
1135
1147
|
interface SettingsSchema extends SpruceSchema.Schema {
|
@@ -1148,21 +1160,30 @@ declare module '@sprucelabs/spruce-core-schemas/build/.spruce/schemas/core.schem
|
|
1148
1160
|
'awsAccessKeyId': {
|
1149
1161
|
label: 'AWS Access Key ID';
|
1150
1162
|
type: 'text';
|
1151
|
-
isRequired: true;
|
1152
1163
|
options: undefined;
|
1153
1164
|
};
|
1154
1165
|
/** AWS Secret Access Key. */
|
1155
1166
|
'awsSecretAccessKey': {
|
1156
1167
|
label: 'AWS Secret Access Key';
|
1157
1168
|
type: 'text';
|
1158
|
-
isRequired: true;
|
1159
1169
|
options: undefined;
|
1160
1170
|
};
|
1161
1171
|
/** AWS S3 Bucket. */
|
1162
1172
|
'awsS3Bucket': {
|
1163
1173
|
label: 'AWS S3 Bucket';
|
1164
1174
|
type: 'text';
|
1165
|
-
|
1175
|
+
options: undefined;
|
1176
|
+
};
|
1177
|
+
/** Local Upload Directory. */
|
1178
|
+
'localUploadDir': {
|
1179
|
+
label: 'Local Upload Directory';
|
1180
|
+
type: 'text';
|
1181
|
+
options: undefined;
|
1182
|
+
};
|
1183
|
+
/** File Host URL. */
|
1184
|
+
'fileHostUrl': {
|
1185
|
+
label: 'File Host URL';
|
1186
|
+
type: 'text';
|
1166
1187
|
options: undefined;
|
1167
1188
|
};
|
1168
1189
|
/** . */
|
@@ -2,7 +2,6 @@ import { Settings } from '../files.types';
|
|
2
2
|
import SettingsStore from '../stores/Settings.store';
|
3
3
|
export default class FileUploaderImpl implements FileUploader {
|
4
4
|
static Class?: new (options: FileUploaderConstructorOptions) => FileUploader;
|
5
|
-
private localUploadDir?;
|
6
5
|
private uploadStrategy;
|
7
6
|
private settings?;
|
8
7
|
protected constructor(options: FileUploaderConstructorOptions);
|
@@ -34,8 +33,9 @@ export interface UploadStrategyUploadOptions {
|
|
34
33
|
export interface UploadStrategy {
|
35
34
|
upload(options: UploadStrategyUploadOptions): Promise<string>;
|
36
35
|
}
|
37
|
-
interface FileUploaderConstructorOptions {
|
36
|
+
export interface FileUploaderConstructorOptions {
|
38
37
|
localUploadDir?: string;
|
38
|
+
fileHostUrl?: string;
|
39
|
+
strategy?: 'local' | 's3';
|
39
40
|
settings?: SettingsStore;
|
40
41
|
}
|
41
|
-
export {};
|
@@ -15,17 +15,22 @@ import LocalUploadStrategy from './LocalUploadStrategy.js';
|
|
15
15
|
import S3UploadStrategy from './S3UploadStrategy.js';
|
16
16
|
export default class FileUploaderImpl {
|
17
17
|
constructor(options) {
|
18
|
-
const { localUploadDir, settings } = options !== null && options !== void 0 ? options : {};
|
19
|
-
this.
|
20
|
-
|
21
|
-
|
22
|
-
|
18
|
+
const { localUploadDir, settings, strategy, fileHostUrl } = options !== null && options !== void 0 ? options : {};
|
19
|
+
this.uploadStrategy =
|
20
|
+
strategy === 'local'
|
21
|
+
? LocalUploadStrategy.Uploader({
|
22
|
+
localUploadDir: localUploadDir,
|
23
|
+
fileHostUrl: fileHostUrl,
|
24
|
+
})
|
25
|
+
: new S3UploadStrategy();
|
23
26
|
this.settings = settings;
|
24
27
|
}
|
25
28
|
static Uploader(settings) {
|
26
29
|
var _a;
|
27
30
|
return new ((_a = this.Class) !== null && _a !== void 0 ? _a : this)({
|
28
31
|
localUploadDir: process.env.LOCAL_UPLOAD_DIR,
|
32
|
+
fileHostUrl: process.env.FILE_HOST_URL,
|
33
|
+
strategy: process.env.UPLOAD_STRATEGY,
|
29
34
|
settings,
|
30
35
|
});
|
31
36
|
}
|
@@ -1,6 +1,29 @@
|
|
1
1
|
import { UploadStrategy, UploadStrategyUploadOptions } from './FileUploader';
|
2
2
|
export default class LocalUploadStrategy implements UploadStrategy {
|
3
|
+
static Class?: new (options: LocalStrategyOptions) => UploadStrategy;
|
3
4
|
private localUploadDir;
|
4
|
-
|
5
|
+
private fileHostUrl;
|
6
|
+
static settingsSchema: {
|
7
|
+
id: string;
|
8
|
+
fields: {
|
9
|
+
localUploadDir: {
|
10
|
+
label: string;
|
11
|
+
type: "text";
|
12
|
+
};
|
13
|
+
fileHostUrl: {
|
14
|
+
label: string;
|
15
|
+
type: "text";
|
16
|
+
};
|
17
|
+
};
|
18
|
+
};
|
19
|
+
constructor(options: {
|
20
|
+
localUploadDir: string;
|
21
|
+
fileHostUrl: string;
|
22
|
+
});
|
23
|
+
static Uploader(options: LocalStrategyOptions): UploadStrategy;
|
5
24
|
upload(options: UploadStrategyUploadOptions): Promise<string>;
|
6
25
|
}
|
26
|
+
export interface LocalStrategyOptions {
|
27
|
+
localUploadDir: string;
|
28
|
+
fileHostUrl: string;
|
29
|
+
}
|
@@ -7,17 +7,42 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
7
7
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
8
8
|
});
|
9
9
|
};
|
10
|
+
import { assertOptions, buildSchema } from '@sprucelabs/schema';
|
10
11
|
import { diskUtil } from '@sprucelabs/spruce-skill-utils';
|
11
|
-
|
12
|
-
constructor(
|
12
|
+
class LocalUploadStrategy {
|
13
|
+
constructor(options) {
|
14
|
+
const { localUploadDir, fileHostUrl } = assertOptions(options, [
|
15
|
+
'localUploadDir',
|
16
|
+
'fileHostUrl',
|
17
|
+
]);
|
18
|
+
this.fileHostUrl = fileHostUrl;
|
13
19
|
this.localUploadDir = localUploadDir;
|
14
20
|
}
|
21
|
+
static Uploader(options) {
|
22
|
+
var _a;
|
23
|
+
assertOptions(options, ['localUploadDir', 'fileHostUrl']);
|
24
|
+
return new ((_a = this.Class) !== null && _a !== void 0 ? _a : this)(options);
|
25
|
+
}
|
15
26
|
upload(options) {
|
16
27
|
return __awaiter(this, void 0, void 0, function* () {
|
17
28
|
const { name, buffer } = options;
|
18
29
|
const destination = diskUtil.resolvePath(this.localUploadDir, name);
|
19
30
|
diskUtil.writeFile(destination, buffer.toString('utf-8'));
|
20
|
-
return
|
31
|
+
return `${this.fileHostUrl}/${name}`;
|
21
32
|
});
|
22
33
|
}
|
23
34
|
}
|
35
|
+
LocalUploadStrategy.settingsSchema = buildSchema({
|
36
|
+
id: 'localUploadSettings',
|
37
|
+
fields: {
|
38
|
+
localUploadDir: {
|
39
|
+
label: 'Local Upload Directory',
|
40
|
+
type: 'text',
|
41
|
+
},
|
42
|
+
fileHostUrl: {
|
43
|
+
label: 'File Host URL',
|
44
|
+
type: 'text',
|
45
|
+
},
|
46
|
+
},
|
47
|
+
});
|
48
|
+
export default LocalUploadStrategy;
|
@@ -2,5 +2,25 @@ import AWS from 'aws-sdk';
|
|
2
2
|
import { UploadStrategy, UploadStrategyUploadOptions } from './FileUploader';
|
3
3
|
export default class S3UploadStrategy implements UploadStrategy {
|
4
4
|
static AWS: typeof AWS;
|
5
|
+
static settingsSchema: {
|
6
|
+
id: string;
|
7
|
+
fields: {
|
8
|
+
awsAccessKeyId: {
|
9
|
+
label: string;
|
10
|
+
type: "text";
|
11
|
+
options: undefined;
|
12
|
+
};
|
13
|
+
awsSecretAccessKey: {
|
14
|
+
label: string;
|
15
|
+
type: "text";
|
16
|
+
options: undefined;
|
17
|
+
};
|
18
|
+
awsS3Bucket: {
|
19
|
+
label: string;
|
20
|
+
type: "text";
|
21
|
+
options: undefined;
|
22
|
+
};
|
23
|
+
};
|
24
|
+
};
|
5
25
|
upload(options: UploadStrategyUploadOptions): Promise<string>;
|
6
26
|
}
|
@@ -7,7 +7,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
7
7
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
8
8
|
});
|
9
9
|
};
|
10
|
-
import { assertOptions } from '@sprucelabs/schema';
|
10
|
+
import { assertOptions, buildSchema } from '@sprucelabs/schema';
|
11
11
|
import AWS from 'aws-sdk';
|
12
12
|
class S3UploadStrategy {
|
13
13
|
upload(options) {
|
@@ -27,6 +27,7 @@ class S3UploadStrategy {
|
|
27
27
|
AWS_S3_BUCKET = awsS3Bucket;
|
28
28
|
}
|
29
29
|
else {
|
30
|
+
//TODO: added bang here
|
30
31
|
const { awsAccessKeyId, awsSecretAccessKey, awsS3Bucket } = settings;
|
31
32
|
AWS_ACCESS_KEY_ID = awsAccessKeyId;
|
32
33
|
AWS_SECRET_ACCESS_KEY = awsSecretAccessKey;
|
@@ -49,4 +50,24 @@ class S3UploadStrategy {
|
|
49
50
|
}
|
50
51
|
}
|
51
52
|
S3UploadStrategy.AWS = AWS;
|
53
|
+
S3UploadStrategy.settingsSchema = buildSchema({
|
54
|
+
id: 's3UploadSettings',
|
55
|
+
fields: {
|
56
|
+
awsAccessKeyId: {
|
57
|
+
label: 'AWS Access Key ID',
|
58
|
+
type: 'text',
|
59
|
+
options: undefined,
|
60
|
+
},
|
61
|
+
awsSecretAccessKey: {
|
62
|
+
label: 'AWS Secret Access Key',
|
63
|
+
type: 'text',
|
64
|
+
options: undefined,
|
65
|
+
},
|
66
|
+
awsS3Bucket: {
|
67
|
+
label: 'AWS S3 Bucket',
|
68
|
+
type: 'text',
|
69
|
+
options: undefined,
|
70
|
+
},
|
71
|
+
},
|
72
|
+
});
|
52
73
|
export default S3UploadStrategy;
|
@@ -2,7 +2,6 @@ import { Settings } from '../files.types';
|
|
2
2
|
import SettingsStore from '../stores/Settings.store';
|
3
3
|
export default class FileUploaderImpl implements FileUploader {
|
4
4
|
static Class?: new (options: FileUploaderConstructorOptions) => FileUploader;
|
5
|
-
private localUploadDir?;
|
6
5
|
private uploadStrategy;
|
7
6
|
private settings?;
|
8
7
|
protected constructor(options: FileUploaderConstructorOptions);
|
@@ -34,8 +33,9 @@ export interface UploadStrategyUploadOptions {
|
|
34
33
|
export interface UploadStrategy {
|
35
34
|
upload(options: UploadStrategyUploadOptions): Promise<string>;
|
36
35
|
}
|
37
|
-
interface FileUploaderConstructorOptions {
|
36
|
+
export interface FileUploaderConstructorOptions {
|
38
37
|
localUploadDir?: string;
|
38
|
+
fileHostUrl?: string;
|
39
|
+
strategy?: 'local' | 's3';
|
39
40
|
settings?: SettingsStore;
|
40
41
|
}
|
41
|
-
export {};
|
@@ -44,16 +44,21 @@ const LocalUploadStrategy_1 = __importDefault(require("./LocalUploadStrategy"));
|
|
44
44
|
const S3UploadStrategy_1 = __importDefault(require("./S3UploadStrategy"));
|
45
45
|
class FileUploaderImpl {
|
46
46
|
constructor(options) {
|
47
|
-
const { localUploadDir, settings } = options ?? {};
|
48
|
-
this.
|
49
|
-
|
50
|
-
|
51
|
-
|
47
|
+
const { localUploadDir, settings, strategy, fileHostUrl } = options ?? {};
|
48
|
+
this.uploadStrategy =
|
49
|
+
strategy === 'local'
|
50
|
+
? LocalUploadStrategy_1.default.Uploader({
|
51
|
+
localUploadDir: localUploadDir,
|
52
|
+
fileHostUrl: fileHostUrl,
|
53
|
+
})
|
54
|
+
: new S3UploadStrategy_1.default();
|
52
55
|
this.settings = settings;
|
53
56
|
}
|
54
57
|
static Uploader(settings) {
|
55
58
|
return new (this.Class ?? this)({
|
56
59
|
localUploadDir: process.env.LOCAL_UPLOAD_DIR,
|
60
|
+
fileHostUrl: process.env.FILE_HOST_URL,
|
61
|
+
strategy: process.env.UPLOAD_STRATEGY,
|
57
62
|
settings,
|
58
63
|
});
|
59
64
|
}
|
@@ -1,6 +1,29 @@
|
|
1
1
|
import { UploadStrategy, UploadStrategyUploadOptions } from './FileUploader';
|
2
2
|
export default class LocalUploadStrategy implements UploadStrategy {
|
3
|
+
static Class?: new (options: LocalStrategyOptions) => UploadStrategy;
|
3
4
|
private localUploadDir;
|
4
|
-
|
5
|
+
private fileHostUrl;
|
6
|
+
static settingsSchema: {
|
7
|
+
id: string;
|
8
|
+
fields: {
|
9
|
+
localUploadDir: {
|
10
|
+
label: string;
|
11
|
+
type: "text";
|
12
|
+
};
|
13
|
+
fileHostUrl: {
|
14
|
+
label: string;
|
15
|
+
type: "text";
|
16
|
+
};
|
17
|
+
};
|
18
|
+
};
|
19
|
+
constructor(options: {
|
20
|
+
localUploadDir: string;
|
21
|
+
fileHostUrl: string;
|
22
|
+
});
|
23
|
+
static Uploader(options: LocalStrategyOptions): UploadStrategy;
|
5
24
|
upload(options: UploadStrategyUploadOptions): Promise<string>;
|
6
25
|
}
|
26
|
+
export interface LocalStrategyOptions {
|
27
|
+
localUploadDir: string;
|
28
|
+
fileHostUrl: string;
|
29
|
+
}
|
@@ -1,15 +1,38 @@
|
|
1
1
|
"use strict";
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
+
const schema_1 = require("@sprucelabs/schema");
|
3
4
|
const spruce_skill_utils_1 = require("@sprucelabs/spruce-skill-utils");
|
4
5
|
class LocalUploadStrategy {
|
5
|
-
constructor(
|
6
|
+
constructor(options) {
|
7
|
+
const { localUploadDir, fileHostUrl } = (0, schema_1.assertOptions)(options, [
|
8
|
+
'localUploadDir',
|
9
|
+
'fileHostUrl',
|
10
|
+
]);
|
11
|
+
this.fileHostUrl = fileHostUrl;
|
6
12
|
this.localUploadDir = localUploadDir;
|
7
13
|
}
|
14
|
+
static Uploader(options) {
|
15
|
+
(0, schema_1.assertOptions)(options, ['localUploadDir', 'fileHostUrl']);
|
16
|
+
return new (this.Class ?? this)(options);
|
17
|
+
}
|
8
18
|
async upload(options) {
|
9
19
|
const { name, buffer } = options;
|
10
20
|
const destination = spruce_skill_utils_1.diskUtil.resolvePath(this.localUploadDir, name);
|
11
21
|
spruce_skill_utils_1.diskUtil.writeFile(destination, buffer.toString('utf-8'));
|
12
|
-
return
|
22
|
+
return `${this.fileHostUrl}/${name}`;
|
13
23
|
}
|
14
24
|
}
|
25
|
+
LocalUploadStrategy.settingsSchema = (0, schema_1.buildSchema)({
|
26
|
+
id: 'localUploadSettings',
|
27
|
+
fields: {
|
28
|
+
localUploadDir: {
|
29
|
+
label: 'Local Upload Directory',
|
30
|
+
type: 'text',
|
31
|
+
},
|
32
|
+
fileHostUrl: {
|
33
|
+
label: 'File Host URL',
|
34
|
+
type: 'text',
|
35
|
+
},
|
36
|
+
},
|
37
|
+
});
|
15
38
|
exports.default = LocalUploadStrategy;
|
@@ -2,5 +2,25 @@ import AWS from 'aws-sdk';
|
|
2
2
|
import { UploadStrategy, UploadStrategyUploadOptions } from './FileUploader';
|
3
3
|
export default class S3UploadStrategy implements UploadStrategy {
|
4
4
|
static AWS: typeof AWS;
|
5
|
+
static settingsSchema: {
|
6
|
+
id: string;
|
7
|
+
fields: {
|
8
|
+
awsAccessKeyId: {
|
9
|
+
label: string;
|
10
|
+
type: "text";
|
11
|
+
options: undefined;
|
12
|
+
};
|
13
|
+
awsSecretAccessKey: {
|
14
|
+
label: string;
|
15
|
+
type: "text";
|
16
|
+
options: undefined;
|
17
|
+
};
|
18
|
+
awsS3Bucket: {
|
19
|
+
label: string;
|
20
|
+
type: "text";
|
21
|
+
options: undefined;
|
22
|
+
};
|
23
|
+
};
|
24
|
+
};
|
5
25
|
upload(options: UploadStrategyUploadOptions): Promise<string>;
|
6
26
|
}
|
@@ -22,6 +22,7 @@ class S3UploadStrategy {
|
|
22
22
|
AWS_S3_BUCKET = awsS3Bucket;
|
23
23
|
}
|
24
24
|
else {
|
25
|
+
//TODO: added bang here
|
25
26
|
const { awsAccessKeyId, awsSecretAccessKey, awsS3Bucket } = settings;
|
26
27
|
AWS_ACCESS_KEY_ID = awsAccessKeyId;
|
27
28
|
AWS_SECRET_ACCESS_KEY = awsSecretAccessKey;
|
@@ -43,4 +44,24 @@ class S3UploadStrategy {
|
|
43
44
|
}
|
44
45
|
}
|
45
46
|
S3UploadStrategy.AWS = aws_sdk_1.default;
|
47
|
+
S3UploadStrategy.settingsSchema = (0, schema_1.buildSchema)({
|
48
|
+
id: 's3UploadSettings',
|
49
|
+
fields: {
|
50
|
+
awsAccessKeyId: {
|
51
|
+
label: 'AWS Access Key ID',
|
52
|
+
type: 'text',
|
53
|
+
options: undefined,
|
54
|
+
},
|
55
|
+
awsSecretAccessKey: {
|
56
|
+
label: 'AWS Secret Access Key',
|
57
|
+
type: 'text',
|
58
|
+
options: undefined,
|
59
|
+
},
|
60
|
+
awsS3Bucket: {
|
61
|
+
label: 'AWS S3 Bucket',
|
62
|
+
type: 'text',
|
63
|
+
options: undefined,
|
64
|
+
},
|
65
|
+
},
|
66
|
+
});
|
46
67
|
exports.default = S3UploadStrategy;
|